blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 986
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 23
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 145
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 122
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
668e1c75fa499cb56d96988568d9567fea7f07f8 | 0de7df0382a8c18bde2e10b71631ac3587a9936a | /MainzPackage/CK_RungeKutta.h | 06cec73a361881364af9f379bcbb61902b5ad278 | [] | no_license | erezcoh4/Mainz_deep | c8ddcfe5ab4e372bedb52e306f872109174721d3 | b9bcdc7d3e0538ea75678c693283fb0ac26f49e3 | refs/heads/master | 2016-08-11T07:24:27.867464 | 2016-04-14T05:31:31 | 2016-04-14T05:31:31 | 54,966,906 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,301 | h | /**
* \file CK_RungeKutta.h
*
* \ingroup MainzPackage
*
* \brief Class def header for a class CK_RungeKutta
*
* @author erezcohen
*/
/** \addtogroup MainzPackage
@{*/
#ifndef CK_RUNGEKUTTA_H
#define CK_RUNGEKUTTA_H
#include <iostream>
#include <math.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
/**
\class CK_RungeKutta
User defined class CK_RungeKutta ... these comments are used to generate
doxygen documentation!
*/
class CK_RungeKutta{
public:
/// Default constructor
CK_RungeKutta(){}
/// Default destructor
~CK_RungeKutta(){}
// C++ file CK_RungeKutta.h
//
// Cash-Karp Runge-Kutta solution of ordinary diffrential equations
// (call routine odeint)
//
// The original functions are taken from the book "NUMERICAL RECIPES in C".
//
// Version 1.0, T.Pospischil, 12/97:
// Modification of the original routines:
// - memory handling (nrutil routines replaced by "new" statements)
// - step storage is written into a file instead of an array.
// - value of TINY raised from 1e-30 to 0.001.
//
/* ------- rkck: Take a Cash-Karp Runge-Kutta step:
Given values for n variables y[1..n] and their derivatives dydx[1..n]
known at x, use the fifth-order Cash-Karp Runge-Kutta method to advance
the solution over an interval h and return the incremented variables as
yout[1..n]. Also return an estimate of the local truncation error in
yout using the embedded fourth-order method.
The user supplies the routine derivs(x,y,dydx), which returns dervatives
dydx at x.
*/
void rkck(double y[],
double dydx[],
int n,
double x,
double h,
double yout[],
double yerr[],
void (*derivs)(double, double [], double []) );
/* ----------------------- rkqs: Fifth-order Runge-Kutta stepper
Fifth-order Runge-Kutta step with monitoring of local truncation error
to ensure accuracy and adjust stepsize. Input are the dependent variable
vector y[1..n] and jts derivative dydx[1..n] at the starting value of the
independent variable x. Also input are the stepsize to be attempted htry,
the required accuracy eps, and the vector yscal [1..n] against which the
error is scaled.
On output, y and x are replaced by their new values, hdid is the stepsize
that was actually accomplished, and hnext is the estimated next stepsize.
derivs is the user-supplied routine that computes the right-hand side
derivatives.
*/
void rkqs(double y[],
double dydx[],
int n,
double *x,
double htry,
double eps,
double yscal[],
double *hdid,
double *hnext,
void (*derivs)(double, double [], double []));
/* ---------------------------- odeint -------------------------------------
Runge-Kutta driver with adaptive stepsize control. Integrate starting
values ystart [1..nvar] from x1 to x2 with accuracy eps, storing inter-
mediate results in global variables. h1 should be set as a guessed first
stepsize, hmin as the minimum allowed stepsize (can be zero).
On output nok and nbad are the number of good and bad (but retried and
fixed) steps taken, and ystart is replaced by values at the end of the
integration interval. derivs is the user-supplied routine for calculating
the right-hand side derivative, while rkqs is the name of the stepper
routine to be used. */
int odeint(double ystart[], // Start values
int nvar, // number of ODEs (= dimension of the arrays)
double x1, // start value for the independent variable
double x2, // stop at this value of the independent variable
double y1min, // stop if y[1] smaller than y1min
double eps, // required accuracy
double h1, // guessed first stepsize
double hmin, // min. allowed stepsize (can be zero)
int *nok, // number of good steps taken
int *nbad, // number of bad (retried and fixed) steps taken
double dxsav, // interval size for step storing
int kmax, // max number of steps to store
int &kount, // number of stored steps
void (*stepstore)(double, double [], int, int),// func stores steps
void (*derivs)(double, double [], double []), // derivatives
double *xact ); // actual value for the independent variable
int odeint2(double ystart[], // Start values
int nvar, // number of ODEs (= dimension of the arrays)
double x1, // start value for the independent variable
double x2, // stop at this value of the independent variable
double y1min, // stop if y[1] smaller than y1min
double eps, // required accuracy
double h1, // guessed first stepsize
double hmin, // min. allowed stepsize (can be zero)
int *nok, // number of good steps taken
int *nbad, // number of bad (retried and fixed) steps taken
double dxsav, // interval size for step storing
int kmax, // max number of steps to store
int &kount, // number of stored steps
void (*stepstore)(double, double [], int, int),// func stores steps
void (*derivs)(double, double [], double []), // derivatives
double *xact, // actual value for the independent variable
int (*checkPosition)(double []) ) ;
int odeint3(double ystart[], // Start values
int nvar, // number of ODEs (= dimension of the arrays)
double x1, // start value for the independent variable
double x2, // stop at this value of the independent variable
double y1min, // stop if y[1] smaller than y1min
double eps, // required accuracy
double h1, // guessed first stepsize
double hmin, // min. allowed stepsize (can be zero)
int *nok, // number of good steps taken
int *nbad, // number of bad (retried and fixed) steps taken
double dxsav, // interval size for step storing
int kmax, // max number of steps to store
int &kount, // number of stored steps
void (*stepstore)(double, double [], int, int),// func stores steps
void (*derivs)(double, double [], double []), // derivatives
double *xact, // actual value for the independent variable
int (*checkPosition)(double []),
int (*checkInside)(double x, double y, double z)) ;
};
#endif
/** @} */ // end of doxygen group
| [
"cohen.erez7@gmail.com"
] | cohen.erez7@gmail.com |
9e3a0b95739989e96fa74af367149397002929c9 | a8003497954bdb3b6a91e128be211df1289f0c06 | /libs/base/include/suil/base/exception.hpp | 2c4668238f830e88ebba79cc48f874568dbb816f | [
"MIT"
] | permissive | dccarter/suil | 5bf4d47869582a4088c74ac65be33bf79e67d162 | 849ab2ac4b33cd1cbd24ae3253fe472ba5bb7f85 | refs/heads/main | 2022-12-17T12:17:33.581772 | 2022-11-17T02:08:29 | 2022-11-17T02:08:29 | 324,083,766 | 6 | 0 | MIT | 2022-11-17T01:53:30 | 2020-12-24T06:27:13 | C++ | UTF-8 | C++ | false | false | 6,557 | hpp | //
// Created by Mpho Mbotho on 2020-10-05.
//
#ifndef SUIL_BASE_EXCEPTION_HPP
#define SUIL_BASE_EXCEPTION_HPP
#include <exception>
#include <string>
#include <sstream>
#include <variant>
#include <suil/base/utils.hpp>
namespace suil {
class Exception: public std::exception {
public:
explicit Exception(std::string message);
COPY_CTOR(Exception) = default;
MOVE_CTOR(Exception) = default;
COPY_ASSIGN(Exception) = default;
MOVE_ASSIGN(Exception) = default;
/**
* Get the message that was constructed when creating the exception
*
* @return the message constructed when creating the exception
*/
[[nodiscard]]
const std::string& message() const noexcept {
return mMessage;
}
/**
* Gets the tag of the exception instance which is basically
* the name of the exception kind
*
* @return a string pointing to the name of the exception
*/
[[nodiscard]]
const std::string& tag() const noexcept {
return mTag;
}
/**
* Retrieve the ID of the exception which is a hash of the exception
* kind
*
* @return the ID of the exception
*/
[[nodiscard]]
int64_t id() const noexcept {
return mId;
}
/**
* eq equality comparison operator
* @param other the other exception to compare to
* @return true if the exceptions have the same code
*/
inline bool operator==(const Exception& other) const {
return mId == other.mId;
}
/**
* neq equality comparison operator
* @param other the other exception to compare to
* @return true if the exceptions have different codes
*/
inline bool operator!=(const Exception& other) const {
return mId != other.mId;
}
/**
* Get the message that was created when creating the exception in C style string
* format
*
* @return the message in C-style string
*/
[[nodiscard]]
const char* what() const noexcept override {
return mMessage.c_str();
}
/**
* Construct exception from current exception
* @return the current exception
*
* @note this function is only applicable on a catch exception
*/
static Exception fromCurrent();
protected:
template <typename... Args>
Exception(const std::string& tag, uint64_t id, Args... args)
: mTag{tag},
mId{id}
{
makeMessage(std::forward<Args>(args)...);
}
static std::string makeTag(const std::string_view& sv);
static std::uint64_t makeId(const std::string& tag);
private:
template <typename... Args>
void makeMessage(Args... args) {
if (sizeof...(args)) {
std::stringstream ss;
(ss << ... << args);
mMessage = ss.str();
}
}
std::string mMessage{};
const std::uint64_t mId{};
const std::string& mTag{};
};
#define AnT() __PRETTY_FUNCTION__, ":", __LINE__, " "
#define DECLARE_EXCEPTION(Name) \
class Name : public suil::Exception { \
public: \
template <typename... Args> \
Name (Args... args) \
: Exception( Name ::Tag(), Name ::Id(), std::forward<Args>(args)...)\
{} \
\
using Exception::operator=; \
using Exception::operator!=; \
\
static const std::string& Tag() { \
static std::string _Tag{Exception::makeTag(__PRETTY_FUNCTION__)}; \
return _Tag; \
} \
\
static const uint64_t& Id() { \
static uint64_t _Id{Exception::makeId(Tag())}; \
return _Id; \
} \
}
DECLARE_EXCEPTION(AccessViolation);
DECLARE_EXCEPTION(OutOfRange);
DECLARE_EXCEPTION(KeyNotFound);
DECLARE_EXCEPTION(MemoryAllocationFailure);
DECLARE_EXCEPTION(IndexOutOfBounds);
DECLARE_EXCEPTION(InvalidArguments);
DECLARE_EXCEPTION(UnsupportedOperation);
template <typename V, typename E = Exception>
requires (std::is_same_v<E, Exception> || std::is_base_of_v<Exception, E>)
struct Return : public std::variant<V, E> {
using std::variant<V, E>::variant;
operator bool() const { return std::holds_alternative<V>(Ego); }
V& operator*() { return std::get<V>(Ego); }
const V& operator*() const { return std::get<V>(Ego); }
const E& exception() const { return std::get<E>(Ego); }
const V& value() const { return std::get<V>(Ego); }
E& exception() { return std::get<E>(Ego); }
V& value() { return std::get<V>(Ego); }
void raise() {
if (!Ego) {
throw std::move(exception());
}
}
Return<V, E> operator||(V value) {
if (!std::holds_alternative<V>(Ego)) {
return {std::move(value)};
}
return std::move(Ego);
}
};
template <typename R, typename F, typename... Args>
Return<R> TryCatch(F func, Args&&... args)
{
try {
return {func(std::forward<Args>(args)...)};
}
catch (...) {
return {Exception::fromCurrent()};
}
}
}
#endif //SUIL_BASE_EXCEPTION_HPP
| [
"lastcarter@gmail.com"
] | lastcarter@gmail.com |
293569fa43476fb818f826eb05e1349594a93e49 | bfa2a4ce99b3f93d3f00e538e4195301e521a261 | /app/jni/DetectionBasedTracker_jni.cpp | d08e6297c954772aade2c7aa2cc960787ba22655 | [] | no_license | V0tis/OpenCV-Android | c467b4a307a1d7dfd9a46a6a4a1a232de500a7ac | bf714d38a93c4a8ae7519f10058a32b701bab43b | refs/heads/main | 2023-08-15T12:13:23.020487 | 2021-09-23T11:41:26 | 2021-09-23T11:41:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,808 | cpp | #include <DetectionBasedTracker_jni.h>
#include <opencv2/core.hpp>
#include <opencv2/objdetect.hpp>
#include <string>
#include <vector>
#include <android/log.h>
#define LOG_TAG "FaceDetection/DetectionBasedTracker"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
using namespace std;
using namespace cv;
inline void vector_Rect_to_Mat(vector<Rect>& v_rect, Mat& mat)
{
mat = Mat(v_rect, true);
}
class CascadeDetectorAdapter: public DetectionBasedTracker::IDetector
{
public:
CascadeDetectorAdapter(cv::Ptr<cv::CascadeClassifier> detector):
IDetector(),
Detector(detector)
{
LOGD("CascadeDetectorAdapter::Detect::Detect");
CV_Assert(detector);
}
void detect(const cv::Mat &Image, std::vector<cv::Rect> &objects)
{
LOGD("CascadeDetectorAdapter::Detect: begin");
LOGD("CascadeDetectorAdapter::Detect: scaleFactor=%.2f, minNeighbours=%d, minObjSize=(%dx%d), maxObjSize=(%dx%d)", scaleFactor, minNeighbours, minObjSize.width, minObjSize.height, maxObjSize.width, maxObjSize.height);
Detector->detectMultiScale(Image, objects, scaleFactor, minNeighbours, 0, minObjSize, maxObjSize);
LOGD("CascadeDetectorAdapter::Detect: end");
}
virtual ~CascadeDetectorAdapter()
{
LOGD("CascadeDetectorAdapter::Detect::~Detect");
}
private:
CascadeDetectorAdapter();
cv::Ptr<cv::CascadeClassifier> Detector;
};
struct DetectorAgregator
{
cv::Ptr<CascadeDetectorAdapter> mainDetector;
cv::Ptr<CascadeDetectorAdapter> trackingDetector;
cv::Ptr<DetectionBasedTracker> tracker;
DetectorAgregator(cv::Ptr<CascadeDetectorAdapter>& _mainDetector, cv::Ptr<CascadeDetectorAdapter>& _trackingDetector):
mainDetector(_mainDetector),
trackingDetector(_trackingDetector)
{
CV_Assert(_mainDetector);
CV_Assert(_trackingDetector);
DetectionBasedTracker::Parameters DetectorParams;
tracker = makePtr<DetectionBasedTracker>(mainDetector, trackingDetector, DetectorParams);
}
};
JNIEXPORT jlong JNICALL Java_com_sizl_facedetector_DetectionBasedTracker_nativeCreateObject
(JNIEnv * jenv, jclass, jstring jFileName, jint faceSize)
{
LOGD("Java_com_sizl_facedetector_DetectionBasedTracker_nativeCreateObject enter");
const char* jnamestr = jenv->GetStringUTFChars(jFileName, NULL);
string stdFileName(jnamestr);
jlong result = 0;
LOGD("Java_com_sizl_facedetector_DetectionBasedTracker_nativeCreateObject");
try
{
cv::Ptr<CascadeDetectorAdapter> mainDetector = makePtr<CascadeDetectorAdapter>(
makePtr<CascadeClassifier>(stdFileName));
cv::Ptr<CascadeDetectorAdapter> trackingDetector = makePtr<CascadeDetectorAdapter>(
makePtr<CascadeClassifier>(stdFileName));
result = (jlong)new DetectorAgregator(mainDetector, trackingDetector);
if (faceSize > 0)
{
mainDetector->setMinObjectSize(Size(faceSize, faceSize));
//trackingDetector->setMinObjectSize(Size(faceSize, faceSize));
}
}
catch(const cv::Exception& e)
{
LOGD("nativeCreateObject caught cv::Exception: %s", e.what());
jclass je = jenv->FindClass("org/opencv/core/CvException");
if(!je)
je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, e.what());
}
catch (...)
{
LOGD("nativeCreateObject caught unknown exception");
jclass je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, "Unknown exception in JNI code of DetectionBasedTracker.nativeCreateObject()");
return 0;
}
LOGD("Java_com_sizl_facedetector_DetectionBasedTracker_nativeCreateObject exit");
return result;
}
JNIEXPORT void JNICALL Java_com_sizl_facedetector_DetectionBasedTracker_nativeDestroyObject
(JNIEnv * jenv, jclass, jlong thiz)
{
LOGD("Java_com_sizl_facedetector_DetectionBasedTracker_nativeDestroyObject");
try
{
if(thiz != 0)
{
((DetectorAgregator*)thiz)->tracker->stop();
delete (DetectorAgregator*)thiz;
}
}
catch(const cv::Exception& e)
{
LOGD("nativeestroyObject caught cv::Exception: %s", e.what());
jclass je = jenv->FindClass("org/opencv/core/CvException");
if(!je)
je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, e.what());
}
catch (...)
{
LOGD("nativeDestroyObject caught unknown exception");
jclass je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, "Unknown exception in JNI code of DetectionBasedTracker.nativeDestroyObject()");
}
LOGD("Java_com_sizl_facedetector_DetectionBasedTracker_nativeDestroyObject exit");
}
JNIEXPORT void JNICALL Java_com_sizl_facedetector_DetectionBasedTracker_nativeStart
(JNIEnv * jenv, jclass, jlong thiz)
{
LOGD("Java_com_sizl_facedetector_DetectionBasedTracker_nativeStart");
try
{
((DetectorAgregator*)thiz)->tracker->run();
}
catch(const cv::Exception& e)
{
LOGD("nativeStart caught cv::Exception: %s", e.what());
jclass je = jenv->FindClass("org/opencv/core/CvException");
if(!je)
je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, e.what());
}
catch (...)
{
LOGD("nativeStart caught unknown exception");
jclass je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, "Unknown exception in JNI code of DetectionBasedTracker.nativeStart()");
}
LOGD("Java_com_sizl_facedetector_DetectionBasedTracker_nativeStart exit");
}
JNIEXPORT void JNICALL Java_com_sizl_facedetector_DetectionBasedTracker_nativeStop
(JNIEnv * jenv, jclass, jlong thiz)
{
LOGD("Java_com_sizl_facedetector_DetectionBasedTracker_nativeStop");
try
{
((DetectorAgregator*)thiz)->tracker->stop();
}
catch(const cv::Exception& e)
{
LOGD("nativeStop caught cv::Exception: %s", e.what());
jclass je = jenv->FindClass("org/opencv/core/CvException");
if(!je)
je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, e.what());
}
catch (...)
{
LOGD("nativeStop caught unknown exception");
jclass je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, "Unknown exception in JNI code of DetectionBasedTracker.nativeStop()");
}
LOGD("Java_com_sizl_facedetector_DetectionBasedTracker_nativeStop exit");
}
JNIEXPORT void JNICALL Java_com_sizl_facedetector_DetectionBasedTracker_nativeSetFaceSize
(JNIEnv * jenv, jclass, jlong thiz, jint faceSize)
{
LOGD("Java_com_sizl_facedetector_DetectionBasedTracker_nativeSetFaceSize -- BEGIN");
try
{
if (faceSize > 0)
{
((DetectorAgregator*)thiz)->mainDetector->setMinObjectSize(Size(faceSize, faceSize));
//((DetectorAgregator*)thiz)->trackingDetector->setMinObjectSize(Size(faceSize, faceSize));
}
}
catch(const cv::Exception& e)
{
LOGD("nativeStop caught cv::Exception: %s", e.what());
jclass je = jenv->FindClass("org/opencv/core/CvException");
if(!je)
je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, e.what());
}
catch (...)
{
LOGD("nativeSetFaceSize caught unknown exception");
jclass je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, "Unknown exception in JNI code of DetectionBasedTracker.nativeSetFaceSize()");
}
LOGD("Java_com_sizl_facedetector_DetectionBasedTracker_nativeSetFaceSize -- END");
}
JNIEXPORT void JNICALL Java_com_sizl_facedetector_DetectionBasedTracker_nativeDetect
(JNIEnv * jenv, jclass, jlong thiz, jlong imageGray, jlong faces)
{
LOGD("Java_com_sizl_facedetector_DetectionBasedTracker_nativeDetect");
try
{
vector<Rect> RectFaces;
((DetectorAgregator*)thiz)->tracker->process(*((Mat*)imageGray));
((DetectorAgregator*)thiz)->tracker->getObjects(RectFaces);
*((Mat*)faces) = Mat(RectFaces, true);
}
catch(const cv::Exception& e)
{
LOGD("nativeCreateObject caught cv::Exception: %s", e.what());
jclass je = jenv->FindClass("org/opencv/core/CvException");
if(!je)
je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, e.what());
}
catch (...)
{
LOGD("nativeDetect caught unknown exception");
jclass je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, "Unknown exception in JNI code DetectionBasedTracker.nativeDetect()");
}
LOGD("Java_com_sizl_facedetector_DetectionBasedTracker_nativeDetect END");
}
| [
"donggun.dev@gmail.com"
] | donggun.dev@gmail.com |
ff9164874723bd82b0d5864c9616e16a039bcd4d | 935b2ffce0fa7b00cd4f9f15867e88716e496118 | /main.cpp | ccd28ae628aa15a51fb91e669324d4d713645660 | [] | no_license | MalonzaElkanah/OpenGL-Lecture-room | fbb4855c6a292f2b57e1a3dd0b2a010275461943 | d333bf3e2c734de73a3fd67de822387d0c7736ac | refs/heads/master | 2020-05-19T01:47:36.023863 | 2019-05-03T14:11:45 | 2019-05-03T14:11:45 | 184,766,049 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,468 | cpp | #include <windows.h>
#include <GL/glut.h>
//Initializes 3D rendering
void initRendering() {
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING); //Enable lighting
glEnable(GL_LIGHT0); //Enable light #0
glEnable(GL_LIGHT1); //Enable light #1
glEnable(GL_NORMALIZE); //Automatically normalize normals
glShadeModel(GL_SMOOTH); //Enable smooth shading
}
//Called when the window is resized
void handleResize(int w, int h) {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(120.0, (double)w / (double)h, 1.0, 200.0);
}
float _angle = 0.0f;
//Draws the 3D scene
///DRAW FLOUR walls
void drawClassroomWalls(){
glBegin(GL_QUADS);
//flour
glColor3f(0.5f, 0.5f, 0.7f);
glVertex3f(-30.0f, -3.0f, -60.0f);
glVertex3f(30.0f, -3.0f, -60.0f);
glVertex3f(30.0f, -3.0f, 20.0f);
glVertex3f(-30.0f, -3.0f, 20.0f);
//frontwall
glColor3f(0.5f, 0.5f, 0.3f);
glVertex3f(-30.0f, -3.0f, 20.0f);
glVertex3f(30.0f, -3.0f, 20.0f);
glVertex3f(30.0f, 20.0f, 20.0f);
glVertex3f(-30.0f, 20.0f, 20.0f);
//WhiteBoard
glColor3f(01.0f, 01.0f, 01.0f);
glVertex3f(-20.0f, 0.0f, 19.8f);
glVertex3f(20.0f, 0.0f, 19.8f);
glVertex3f(20.0f, 10.0f, 19.8f);
glVertex3f(-20.0f, 10.0f, 19.8f);
//left wall
glColor3f(0.5f, 0.5f, 0.3f);
glVertex3f(30.0f, -3.0f, 20.0f);
glVertex3f(30.0f, -3.0f, -60.0f);
glVertex3f(30.0f, 20.0f, -60.0f);
glVertex3f(30.0f, 20.0f, 20.0f);
//right wall
glVertex3f(-30.0f, -3.0f, 20.0f);
glVertex3f(-30.0f, -3.0f, -60.0f);
glVertex3f(-30.0f, 20.0f, -60.0f);
glVertex3f(-30.0f, 20.0f, 20.0f);
//back wall
glVertex3f(-30.0f, -3.0f, -60.0f);
glVertex3f(30.0f, -3.0f, -60.0f);
glVertex3f(30.0f, 20.0f, -60.0f);
glVertex3f(-30.0f, 20.0f, -60.0f);
//Ceiling Board
glColor3f(0.3f, 0.3f, 0.3f);
glVertex3f(-30.0f, 20.0f, -60.0f);
glVertex3f(30.0f, 20.0f, -60.0f);
glVertex3f(30.0f, 20.0f, 20.0f);
glVertex3f(-30.0f, 20.0f, 20.0f);
glEnd();
}
///DRAW CHAIR
void drawScene(float x, float z) {
glBegin(GL_QUADS);
//Front
glVertex3f(-2.0f+x, -0.2f, 2.0f+z);
glVertex3f(2.0f+x, -0.2f, 2.0f+z);
glVertex3f(2.0f+x, 0.2f, 2.0f+z);
glVertex3f(-2.0f+x, 0.2f, 2.0f+z);
//Right
glVertex3f(2.0f+x, -0.2f, -2.0f+z);
glVertex3f(2.0f+x, 0.2f, -2.0f+z);
glVertex3f(2.0f+x, 0.2f, 2.0f+z);
glVertex3f(2.0f+x, -0.2f, 2.0f+z);
//Back
glVertex3f(-2.0f+x, -0.2f, -2.0f+z);
glVertex3f(-2.0f+x, 0.2f, -2.0f+z);
glVertex3f(2.0f+x, 0.2f, -2.0f+z);
glVertex3f(2.0f+x, -0.2f, -2.0f+z);
//Left
glVertex3f(-2.0f+x, -0.2f, -2.0f+z);
glVertex3f(-2.0f+x, -0.2f, 2.0f+z);
glVertex3f(-2.0f+x, 0.2f, 2.0f+z);
glVertex3f(-2.0f+x, 0.2f, -2.0f+z);
//top
glVertex3f(2.0f+x, 0.2f, 2.0f+z);
glVertex3f(-2.0f+x, 0.2f, 2.0f+z);
glVertex3f(-2.0f+x, 0.2f, -2.0f+z);
glVertex3f(2.0f+x, 0.2f, -2.0f+z);
//bottom
glVertex3f(2.0f+x, -0.2f, 2.0f+z);
glVertex3f(-2.0f+x, -0.2f, 2.0f+z);
glVertex3f(-2.0f+x, -0.2f, -2.0f+z);
glVertex3f(2.0f+x, -0.2f, -2.0f+z);
//table front leg
//front
glVertex3f(1.8f+x,-0.2f,1.6f+z);
glVertex3f(1.4f+x, -0.2f, 1.6f+z);
glVertex3f(1.4f+x, -3.0f, 1.6f+z);
glVertex3f(1.8f+x, -3.0f, 1.6f+z);
//back
glVertex3f(1.8f+x,-0.2f,1.2f+z);
glVertex3f(1.4f+x, -0.2f, 1.2f+z);
glVertex3f(1.4f+x, -3.0f, 1.2f+z);
glVertex3f(1.8f+x, -3.0f, 1.2f+z);
//right
glVertex3f(1.8f+x,-0.2f,1.6f+z);
glVertex3f(1.8f+x, -0.2f, 1.2f+z);
glVertex3f(1.8f+x, -3.0f, 1.2f+z);
glVertex3f(1.8f+x, -3.0f, 1.6f+z);
//left
glVertex3f(1.4f+x,-0.2f,1.6f+z);
glVertex3f(1.4f+x, -0.2f, 1.2f+z);
glVertex3f(1.4f+x, -3.0f, 1.2f+z);
glVertex3f(1.4f+x, -3.0f, 1.6f+z);
//back leg back
//front
glVertex3f(1.8f+x,-0.2f,-1.2f+z);
glVertex3f(1.4f+x, -0.2f, -1.2f+z);
glVertex3f(1.4f+x, -3.0f, -1.2f+z);
glVertex3f(1.8f+x, -3.0f, -1.2f+z);
//back
glVertex3f(1.8f+x,-0.2f,-1.6f+z);
glVertex3f(1.4f+x, -0.2f, -1.6f+z);
glVertex3f(1.4f+x, -3.0f, -1.6f+z);
glVertex3f(1.8f+x, -3.0f, -1.6f+z);
//right
glVertex3f(1.8f+x,-0.2f,-1.6f+z);
glVertex3f(1.8f+x, -0.2f, -1.2f+z);
glVertex3f(1.8f+x, -3.0f, -1.2f+z);
glVertex3f(1.8f+x, -3.0f, -1.6f+z);
//left
glVertex3f(1.4f+x,-0.2f,-1.6f+z);
glVertex3f(1.4f+x, -0.2f, -1.2f+z);
glVertex3f(1.4f+x, -3.0f, -1.2f+z);
glVertex3f(1.4f+x, -3.0f, -1.6f+z);
//leg left front
glVertex3f(-1.8f+x,-0.2f,1.6f+z);
glVertex3f(-1.4f+x, -0.2f, 1.6f+z);
glVertex3f(-1.4f+x, -3.0f, 1.6f+z);
glVertex3f(-1.8f+x, -3.0f, 1.6f+z);
//back
glVertex3f(-1.8f+x,-0.2f,1.2f+z);
glVertex3f(-1.4f+x, -0.2f, 1.2f+z);
glVertex3f(-1.4f+x, -3.0f, 1.2f+z);
glVertex3f(-1.8f+x, -3.0f, 1.2f+z);
//right
glVertex3f(-1.8f+x,-0.2f,1.6f+z);
glVertex3f(-1.8f+x, -0.2f, 1.2f+z);
glVertex3f(-1.8f+x, -3.0f, 1.2f+z);
glVertex3f(-1.8f+x, -3.0f, 1.6f+z);
//left
glVertex3f(-1.4f+x,-0.2f,1.6f+z);
glVertex3f(-1.4f+x, -0.2f, 1.2f+z);
glVertex3f(-1.4f+x, -3.0f, 1.2f+z);
glVertex3f(-1.4f+x, -3.0f, 1.6f+z);
//left leg back front
//front
glVertex3f(-1.8f+x,-0.2f,-1.2f+z);
glVertex3f(-1.4f+x, -0.2f, -1.2f+z);
glVertex3f(-1.4f+x, -3.0f, -1.2f+z);
glVertex3f(-1.8f+x, -3.0f, -1.2f+z);
//back
glVertex3f(-1.8f+x,-0.2f,-1.6f+z);
glVertex3f(-1.4f+x, -0.2f, -1.6f+z);
glVertex3f(-1.4f+x, -3.0f, -1.6f+z);
glVertex3f(-1.8f+x, -3.0f, -1.6f+z);
//right
glVertex3f(-1.8f+x,-0.2f,-1.6f+z);
glVertex3f(-1.8f+x, -0.2f, -1.2f+z);
glVertex3f(-1.8f+x, -3.0f, -1.2f+z);
glVertex3f(-1.8f+x, -3.0f, -1.6f+z);
//left
glVertex3f(-1.4f+x,-0.2f,-1.6f+z);
glVertex3f(-1.4f+x, -0.2f, -1.2f+z);
glVertex3f(-1.4f+x, -3.0f, -1.2f+z);
glVertex3f(-1.4f+x, -3.0f, -1.6f+z);
///chair back-arms
///left arm
//front
glVertex3f(-1.6f+x, 0.2f, -1.6f+z);
glVertex3f(-2.0f+x, 0.2f, -1.6f+z);
glVertex3f(-2.0f+x, 3.6f, -1.6f+z);
glVertex3f(-1.6f+x, 3.6f, -1.6f+z);
//back
glVertex3f(-1.6f+x, 0.2f, -2.0f+z);
glVertex3f(-2.0f+x, 0.2f, -2.0f+z);
glVertex3f(-2.0f+x, 3.6f, -2.0f+z);
glVertex3f(-1.6f+x, 3.6f, -2.0f+z);
//right
glVertex3f(-1.6f+x, 0.2f, -1.6f+z);
glVertex3f(-1.6f+x, 0.2f, -2.0f+z);
glVertex3f(-1.6f+x, 3.6f, -2.0f+z);
glVertex3f(-1.6f+x, 3.6f, -1.6f+z);
//left
glVertex3f(-2.0f+x, 0.2f, -1.6f+z);
glVertex3f(-2.0f+x, 0.2f, -2.0f+z);
glVertex3f(-2.0f+x, 3.6f, -2.0f+z);
glVertex3f(-2.0f+x, 3.6f, -1.6f+z);
//top+x
glVertex3f(-1.6f+x, 3.6f, -1.6f+z);
glVertex3f(-2.0f+x, 3.6f, -1.6f+z);
glVertex3f(-1.6f+x, 3.6f, -2.0f+z);
glVertex3f(-2.0f+x, 3.6f, -2.0f+z);
//right arm
//front
glVertex3f(1.6f+x, 0.2f, -1.6f+z);
glVertex3f(2.0f+x, 0.2f, -1.6f+z);
glVertex3f(2.0f+x, 3.6f, -1.6f+z);
glVertex3f(1.6f+x, 3.6f, -1.6f+z);
//back
glVertex3f(1.6f+x, 0.2f, -2.0f+z);
glVertex3f(2.0f+x, 0.2f, -2.0f+z);
glVertex3f(2.0f+x, 3.6f, -2.0f+z);
glVertex3f(1.6f+x, 3.6f, -2.0f+z);
//right
glVertex3f(1.6f+x, 0.2f, -1.6f+z);
glVertex3f(1.6f+x, 0.2f, -2.0f+z);
glVertex3f(1.6f+x, 3.6f, -2.0f+z);
glVertex3f(1.6f+x, 3.6f, -1.6f+z);
//left
glVertex3f(2.0f+x, 0.2f, -1.6f+z);
glVertex3f(2.0f+x, 0.2f, -2.0f+z);
glVertex3f(2.0f+x, 3.6f, -2.0f+z);
glVertex3f(2.0f+x, 3.6f, -1.6f+z);
//top
glVertex3f(1.6f+x, 3.6f, -1.6f+z);
glVertex3f(2.0f+x, 3.6f, -1.6f+z);
glVertex3f(1.6f+x, 3.6f, -2.0f+z);
glVertex3f(2.0f+x, 3.6f, -2.0f+z);
///chair back
//front
glColor3f(1,0,0);
glVertex3f(-2.1f+x, 2.0f, -1.7f+z);
glVertex3f(2.1f+x, 2.0f, -1.7f+z);
glVertex3f(2.1f+x, 3.5f, -1.7f+z);
glVertex3f(-2.1f+x, 3.5f, -1.7f+z);
//back
glVertex3f(-2.1f+x, 2.0f, -1.8f+z);
glVertex3f(2.1f+x, 2.0f, -1.8f+z);
glVertex3f(2.1f+x, 3.5f, -1.8f+z);
glVertex3f(-2.1f+x, 3.5f, -1.8f+z);
//left
glVertex3f(-2.1f+x, 2.0f, -1.7f+z);
glVertex3f(-2.1f+x, 2.0f, -1.8f+z);
glVertex3f(-2.1f+x, 3.5f, -1.8f+z);
glVertex3f(-2.1f+x, 3.5f, -1.7f+z);
//right
glVertex3f(2.1f+x, 2.0f, -1.7f+z);
glVertex3f(2.1f+x, 2.0f, -1.8f+z);
glVertex3f(2.1f+x, 3.5f, -1.8f+z);
glVertex3f(2.1f+x, 3.5f, -1.7f+z);
glEnd();
///CHAIR TABLE
glColor3f(1.0f, 1.0f, 0.0f);
glBegin(GL_QUADS);
//Front
glVertex3f(-2.0f+x, 1.6f, 3.0f+z);
glVertex3f(2.0f+x, 1.6f, 3.0f+z);
glVertex3f(2.0f+x, 2.0f, 3.0f+z);
glVertex3f(-2.0f+x, 2.0f, 3.0f+z);
//Right
glVertex3f(2.0f+x, 1.6f, 1.0f+z);
glVertex3f(2.0f+x, 2.0f, 1.0f+z);
glVertex3f(2.0f+x, 2.0f, 3.0f+z);
glVertex3f(2.0f+x, 1.6f, 3.0f+z);
//Back
glVertex3f(-2.0f+x, 1.6f, 1.0f+z);
glVertex3f(-2.0f+x, 2.0f, 1.0f+z);
glVertex3f(2.0f+x, 2.0f, 1.0f+z);
glVertex3f(2.0f+x, 1.6f, 1.0f+z);
//Left
glVertex3f(-2.0f+x, 1.6f, 1.0f+z);
glVertex3f(-2.0f+x, 1.6f, 3.0f+z);
glVertex3f(-2.0f+x, 2.0f, 3.0f+z);
glVertex3f(-2.0f+x, 2.0f, 1.0f+z);
//top
glVertex3f(2.0f+x, 2.0f, 3.0f+z);
glVertex3f(-2.0f+x, 2.0f, 3.0f+z);
glVertex3f(-2.0f+x, 2.0f, 1.0f+z);
glVertex3f(2.0f+x, 2.0f, 1.0f+z);
//bottom
glVertex3f(2.0f+x, 1.6f, 3.0f+z);
glVertex3f(-2.0f+x, 1.6f, 3.0f+z);
glVertex3f(-2.0f+x, 1.6f, 1.0f+z);
glVertex3f(2.0f+x, 1.6f, 1.0f+z);
///Connect Chair with the table
//Right
glVertex3f(-1.5f+x, 1.6f, -2.0f+z);
glVertex3f(-1.5f+x, 2.0f, -2.0f+z);
glVertex3f(-1.5f+x, 2.0f, 3.0f+z);
glVertex3f(-1.5f+x, 1.6f, 3.0f+z);
//Back
glVertex3f(-2.0f+x, 1.6f, -2.0f+z);
glVertex3f(-2.0f+x, 2.0f, -2.0f+z);
glVertex3f(-1.5f+x, 2.0f, -2.0f+z);
glVertex3f(-1.5f+x, 1.6f, -2.0f+z);
//Left
glVertex3f(-2.0f+x, 1.6f, -2.0f+z);
glVertex3f(-2.0f+x, 2.0f, -2.0f+z);
glVertex3f(-2.0f+x, 2.0f, 3.0f+z);
glVertex3f(-2.0f+x, 1.6f, 3.0f+z);
//top
glVertex3f(-1.5f+x, 2.0f, 3.0f+z);
glVertex3f(-2.0f+x, 2.0f, 3.0f+z);
glVertex3f(-2.0f+x, 2.0f, -2.0f+z);
glVertex3f(-1.5f+x, 2.0f, -2.0f+z);
//bottom
glVertex3f(-1.5f+x, 1.6f, 3.0f+z);
glVertex3f(-2.0f+x, 1.6f, 3.0f+z);
glVertex3f(-2.0f+x, 1.6f, -2.0f+z);
glVertex3f(-1.5f+x, 1.6f, -2.0f+z);
glEnd();
glFlush();
}
void drawMultipleChair(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW); // keep it like this
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -14.0f);
//Add ambient light
GLfloat ambientColor[] = {0.2f, 0.2f, 0.2f, 1.0f}; //Color (0.2, 0.2, 0.2)
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor);
//Add positioned light
GLfloat lightColor0[] = {0.5f, 0.5f, 0.5f, 1.0f}; //Color (0.5, 0.5, 0.5)
GLfloat lightPos0[] = {0.0f, -8.0f, 8.0f, 1.0f}; //Positioned at (4, 0, 8)
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0);
glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);
//Add directed light
GLfloat lightColor1[] = {0.5f, 0.2f, 0.2f, 1.0f}; //Color (0.5, 0.2, 0.2)
//Coming from the direction (-1, 0.5, 0.5)
GLfloat lightPos1[] = {-1.0f, 0.5f, 0.5f, 0.0f};
glLightfv(GL_LIGHT1, GL_DIFFUSE, lightColor1);
glLightfv(GL_LIGHT1, GL_POSITION, lightPos1);
glRotatef(10, 1.0f, 0.0f, 0.0f);
glRotatef(-10, 0.0f, 0.0f, 1.0f);
glRotatef(_angle,0.0f, 1.0f, 0.0f);
drawClassroomWalls();
glColor3f(1.0f, 1.0f, 0.0f);
///left column
//1st row
drawScene(14.0f, 0.0);
drawScene(19.0, 0.0);
drawScene(24.0f,0.0);
//2nd row
drawScene(14.0f, -7.0);
drawScene(19.0, -7.0);
drawScene(24.0f,-7.0);
//3rd row
drawScene(14.0f, -14.0);
drawScene(19.0, -14.0);
drawScene(24.0f,-14.0);
//4th row
drawScene(14.0f, -21.0);
drawScene(19.0, -21.0);
drawScene(24.0f,-21.0);
//5th row
drawScene(14.0f, -35.0);
drawScene(19.0, -35.0);
drawScene(24.0f,-35.0);
//6th row
drawScene(14.0f, -42.0);
drawScene(19.0, -42.0);
drawScene(24.0f,-42.0);
//7th row
drawScene(14.0f, -49.0);
drawScene(19.0, -49.0);
drawScene(24.0f,-49.0);
//8th row
drawScene(14.0f, -56.0);
drawScene(19.0, -56.0);
drawScene(24.0f,-56.0);
///center column
//1st row
drawScene(5.0f, 0.0);
drawScene(0.0, 0.0);
drawScene(-5.0f,0.0);
//2nd row
drawScene(5.0f, -07.0);
drawScene(0.0, -07.0);
drawScene(-5.0f,-07.0);
//3rd row
drawScene(5.0f, -14.0);
drawScene(0.0, -14.0);
drawScene(-5.0f,-14.0);
//4th row
drawScene(5.0f, -21.0);
drawScene(0.0, -21.0);
drawScene(-5.0f,-21.0);
//5th row
drawScene(5.0f, -35.0);
drawScene(0.0, -35.0);
drawScene(-5.0f,-35.0);
//6th row
drawScene(5.0f, -42.0);
drawScene(0.0, -42.0);
drawScene(-5.0f,-42.0);
//7th row
drawScene(5.0f, -49.0);
drawScene(0.0, -49.0);
drawScene(-5.0f,-49.0);
//8th row
drawScene(5.0f, -56.0);
drawScene(0.0, -56.0);
drawScene(-5.0f,-56.0);
///right column
//1st row
drawScene(-14.0f, 0.0);
drawScene(-19.0, 0.0);
drawScene(-24.0f,0.0);
//2nd row
drawScene(-14.0f, -07.0);
drawScene(-19.0, -07.0);
drawScene(-24.0f,-07.0);
//3rd row
drawScene(-14.0f, -14.0);
drawScene(-19.0, -14.0);
drawScene(-24.0f, -14.0);
//4th row
drawScene(-14.0f, -21.0);
drawScene(-19.0, -21.0);
drawScene(-24.0f,-21.0);
//5th row
drawScene(-14.0f, -35.0);
drawScene(-19.0, -35.0);
drawScene(-24.0f, -35.0);
//6th row
drawScene(-14.0f, -42.0);
drawScene(-19.0, -42.0);
drawScene(-24.0f,-42.0);
//7th row
drawScene(-14.0f, -49.0);
drawScene(-19.0, -49.0);
drawScene(-24.0f, -49.0);
//8th row
drawScene(-14.0f, -56.0);
drawScene(-19.0, -56.0);
drawScene(-24.0f,-56.0);
glutSwapBuffers();
}
void update(int value) {
_angle += 1.5f;
if (_angle > 360) {
_angle -= 360;
}
glutPostRedisplay();
glutTimerFunc(25, update, 0);
}
int main(int argc, char** argv) {
//Initialize GLUT
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(1200, 700);
//Create the window
glutCreateWindow("CLASSROOM CHAIR");
initRendering();
//Set handler functions
glutDisplayFunc(drawMultipleChair);
glutReshapeFunc(handleResize);
update(0);
glutMainLoop();
return 0;
}
| [
"noreply@github.com"
] | MalonzaElkanah.noreply@github.com |
409c09595b82939840bc12782b916f293f8fa583 | a740fa23e2e7c1d650ddc05f0651502367674ebf | /iterator.cpp | 26941f1b03ad6dabbaf015d14cb022c7cc3037e6 | [] | no_license | dimores28/Kurs | 7a2a292db7ab9403b8a6df04973fb466425c507e | 2a92766493ee5edc8a277c376160b4b10bbdf394 | refs/heads/master | 2020-03-28T14:20:23.342535 | 2018-10-05T13:13:40 | 2018-10-05T13:13:40 | 148,479,192 | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 5,785 | cpp | #include <iostream>
#include <string>
#include <memory>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
template<class T>
void print(const T& t)
{
for (typename T::const_iterator it = t.begin(); it != t.end(); ++it)
{
cout << *it ;
}
cout << endl;
}
template<class T>
struct Node
{
private:
template<class Iter>
class NodeIterator
{
friend struct Node;
public:
typedef Iter iterator_type;
typedef std::forward_iterator_tag iterator_category;
typedef iterator_type value_type;
typedef ptrdiff_t difference_type;
typedef iterator_type& reference;
typedef iterator_type* pointer;
iterator_type* value;
private:
NodeIterator(Iter* p): value(p){}
public:
NodeIterator(const NodeIterator& it) : value(it.value){}
bool operator !=(NodeIterator const& other)const
{
return value != other.value;
}
//Не обязательно реализововать
bool operator ==(NodeIterator const& other)const
{
return value == other.value;
}
typename NodeIterator::reference operator*()const
{
return *value;
}
NodeIterator& operator++()
{
if (value->parent == nullptr)
value = nullptr;
else if (value->parent->right.get() == value)
value = value->parent;
else
{
value = value->parent;
if (value->right.get() != nullptr)
{
value = value->right.get();
while (value->left.get() != nullptr)
value = value->left.get();
}
}
return *this;
}
};
public:
T value;
unique_ptr <Node> left;
unique_ptr <Node> right;
Node* parent;
Node(const T& value, unique_ptr <Node> left, unique_ptr <Node> right, Node* parent)
: value(value), left(std::move(left)), right(std::move(right)), parent(parent)
{}
Node(const Node&) = delete;
typedef NodeIterator<Node> iterator;
typedef NodeIterator<const Node> const_iterator;
iterator begin()
{
Node* node = this;
while (node->left != nullptr)
node = node->left.get();
return iterator(node);
}
iterator end()
{
return nullptr;
}
const_iterator begin()const
{
const Node* node = this;
while (node->left != nullptr)
node = node->left.get();
return const_iterator(node);
}
const_iterator end()const
{
return nullptr;
}
friend std::ostream& operator<<(std::ostream& os, const Node& n)
{
return os << n.value;
}
};
struct Point
{
unsigned x;
unsigned y;
friend bool operator<(const Point& p1, const Point& p2)
{
if (p1.y < p2.y)
return true;
if (p1.y > p2.y)
return false;
return (p1.x < p2.x);
}
};
//JAVA ITERATOR реализация на C++
template <class Container>
class Iterator
{
Container conteiner;
bool isStart;
typename Container::iterator it;
public:
Iterator(const Container& c): conteiner(c), isStart(false){}
Iterator() = delete;
bool next()
{
if (!isStart)
{
it = conteiner.begin();
isStart = true;
}
else
it++;
return !(it == conteiner.end());
}
inline typename Container::value_type current() const
{
return *it;
}
};
template<class Container>
Iterator<Container> create_iterator(const Container& c)
{
return Iterator<Container>(c);
}
int main()
{
/* string str{ "Hello world\n" };
for (std::string::iterator it = str.begin(); it != str.end(); ++it)
{
cout << *it << endl;
}
for (auto it = str.begin(); it != str.end(); ++it)
{
cout << *it << endl;
}
for (auto &&s : str)
{
cout << s << endl;
}
print(str);
*/
auto root = make_unique<Node<string>>("a1", nullptr, nullptr, nullptr);
root->left = make_unique<Node<string>>("b1", nullptr, nullptr, root.get());
root->right = make_unique<Node<string>>("b2", nullptr, nullptr, root.get());
auto b1 = root->left.get();
auto b2 = root->right.get();
b1->left = make_unique<Node<string>>("c1", nullptr, nullptr, b1);
b1->right = make_unique<Node<string>>("c2", nullptr, nullptr, b1);
b2->left = make_unique<Node<string>>("c3", nullptr, nullptr, b2);
b2->right = make_unique<Node<string>>("c3", nullptr, nullptr, b2);
auto c1 = b1->left.get();
auto c2 = b1->right.get();
auto c3 = b2->left.get();
auto c4 = b2->right.get();
/*
cout << root->value << endl;
cout << b1->value << endl;
cout << b2->value << endl;
cout << c1->value << endl;
cout << c2->value << endl;
cout << c3->value << endl;
cout << c4->value << endl;
*/
/*
auto it = root->begin();
cout << *it<< endl;
++it;
cout << *it << endl;
++it;
cout << *it << endl;*/
/*
for (auto it = root->begin(); it != root->end(); ++it)
{
cout << *it << endl;
}
for (auto&& node : *root)
{
cout << node << endl;
}
std::set<Point> points = { {5,3}, {1,2}, {0,0} };
for (auto it = points.begin(); it != points.end(); ++it)
{
Point& n = const_cast<Point&> (*it);
//it->x = 0;
//it->y = 0;
n.x = 0;
n.y = 0;
}
for (auto &&p : points)
{
cout << p.x << " " << p.y << endl;
}
string str{ "Hello world\n" };
auto it = str.begin();
cout << *std::next(it) << endl;
cout << std::distance(str.begin(), str.end()) << endl;
std::advance(it, 3);
std::advance(it, -2);
cout << *it << endl;
auto first = root->begin();
std::advance(first, 2);
std::next(first);
cout << *first << endl;
typename std::iterator_traits<std::set<int>::iterator>::iterator_category a;
*/
string s = "Hello world";
std::reverse_iterator<std::string::iterator> r = s.rbegin();
string new_s(r, s.rend());
cout << new_s << endl;
std::sort(s.begin(), s.end());
cout << s << endl;
std::sort(std::make_reverse_iterator(s.end()), std::make_reverse_iterator(s.begin()));
cout << s << endl;
///////Using JAVA Iteratir
vector<int> data{ 1,2,3,4,5,6,7,8,9,0 };
auto iter = create_iterator(data);
while (iter.next())
{
cout << iter.current() << " ";
}
cout << endl;
return 0;
}
| [
"dimores28@rambler.ru"
] | dimores28@rambler.ru |
120983fec41acc89299a1e8bcdc5221e647704e0 | 8b80f4edc7089a3823bcc051e7278daaf39fbc5e | /interpolate.hpp | df5ef4e386484fe896547d62503d1e290a75304d | [] | no_license | Arangojd/MAVI | d725d4576ab32ed03836630facafe4cea2d503c9 | 82b136dbe42602399bbb744c555802d57db54f35 | refs/heads/master | 2021-01-13T16:55:41.483002 | 2017-04-27T14:41:05 | 2017-04-27T14:41:05 | 79,232,161 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 678 | hpp | /*
* interpolate.hpp
* ---------------
*
* Function declarations and inline function
* definitions for various data interpolation methods.
*/
#ifndef INTERPOLATE_HPP
#define INTERPOLATE_HPP
/**
* Performs linear interpolation within the range [xmin, xmax] * [ymin, ymax].
*
* @param x Interpolant
* @param xmin x-dimension lower bound
* @param xmax x-dimension upper bound
* @param ymin y-dimension lower bound
* @param ymax y-dimension upper bound
*
* @returns the result of the interpolation operation.
*/
inline double lerp(double x, double xmin, double xmax, double ymin, double ymax)
{
return ymin + (x - xmin) * (ymax - ymin) / (xmax - xmin);
}
#endif
| [
"annoyingmoose.th@gmail.com"
] | annoyingmoose.th@gmail.com |
0d4b50a3b0f5f6fe4bca5993bed5ab9ce92351ed | 5d6278f9a2eda792f54f6cc8fb9bbafd6551c1fe | /Files/FrankowskiFantasy/Encounters/NeverEndingTower/Neverending-Tower_Hard.h | c60a3bb7b1707010b12c8cfbece69a0e0f9e0a4b | [] | no_license | 6b4cb9/JPO | 76a88e7f3bed15f87b1de706fec7aa0f7941a8e8 | 50eda1d68854ad8c577850248aafe9fe5f27159a | refs/heads/master | 2021-01-11T19:47:48.665415 | 2017-01-22T13:24:05 | 2017-01-22T13:24:05 | 79,398,416 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 757 | h | #pragma once
//Author: Kamil Janowski
// Difficulty: 3
// Priority : 3
#include"stdafx.h"
#include "..\..\Character.h"
#include "..\..\Encounter.h"
#include <fstream>
#include <string>
#include <vector>
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <Windows.h>
#include <cstdlib>
#include <chrono>
class Neverending_Tower_Hard : public Encounter
{
private:
void Read_Note(string Name_Of_File);
bool First_Floor(Character* Character);
bool Second_Floor(Character* Character);
bool Third_Floor(Character* Character);
bool Fourth_Floor(Character* Character);
bool Fifth_Floor(Character* Character);
bool Sixth_Floor(Character* Character);
bool Seventh_Floor(Character* Character);
public:
bool Proceed(Character* Character);
};
| [
"rosenhof@student.agh.edu.pl"
] | rosenhof@student.agh.edu.pl |
6000a0289fddc09b6b35514880e0b69a328ea6b2 | eda0aa1e172285968d075ff018d2620dce0c34e2 | /codeforces1203D2.cpp | 6e4ef1e6471e5125513712be1e7243ae8ca81d71 | [] | no_license | AbhJ/some-cp-files-2 | bb12596453010a5e2f60329cbb397b2dc42c151d | 8d3dbf726939fbd3ae4a952f5049ab3ab40e7917 | refs/heads/master | 2023-07-30T23:17:28.150149 | 2021-09-26T13:16:29 | 2021-09-26T13:16:29 | 402,768,725 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 721 | cpp | #include <bits/stdc++.h>
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
using namespace std;//coded by abhijay mitra
const int N=2e5+10;
int n,m,dp[2][N];
void f(string s,string t,bool x){
n=s.length(),m=t.length();
s='#'+s,t='#'+t;
int j=n+1;
for (int i = m; i; --i)
{
while(s[--j]!=t[i]);
dp[x][i]=j;
}
}
void solve(){
string s,t;
cin>>s>>t;
f(s,t,0);
reverse(s.begin(), s.end()),reverse(t.begin(), t.end());
f(s,t,1);
int left=0,ans=0;dp[0][m+1]=n+1,dp[1][m+1]=0;
ans=max(dp[0][1]-1,n-(n-dp[1][1]+1));
for (int i = 2; i <= m; ++i)ans=max(dp[0][i]-(n-dp[1][m-i+1+1]+1)-1,ans);
cout<<ans;
}
int main()
{
ibs;cti;
solve();
cout<<"\n";
return 0;
} | [
"mitraabhijay@gmail.com"
] | mitraabhijay@gmail.com |
577467ab6eb687f67d068b5a55679b88148174de | 4f3d6b63dd5d1975aca587cf26ab79d403d35771 | /Lab06/Invulnerability.cpp | 0b0bf26c1b89c657732e10e3d2ae358498e67bac | [] | no_license | alinaf/spaceGame | 473ecb9bba50fa3f15f40372a345bc0964b92746 | 0a2d0925b6755fb036ef1875fad1a47818d91ad6 | refs/heads/master | 2021-04-15T05:41:12.009246 | 2018-04-19T06:07:12 | 2018-04-19T06:07:12 | 126,744,350 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 896 | cpp | //
// Invulnerability.cpp
// Game-mac
//
// Created by tml on 4/15/18.
// Copyright © 2018 Sanjay Madhav. All rights reserved.
//
#include <stdio.h>
#include "Game.h"
#include "Invulnerability.h"
#include "Player.h"
Invulnerability::Invulnerability(class Game* game):Actor(game){
mSprite = new SpriteComponent(this);
mCollision = new CollisionComponent(this);
mCollision->SetSize(32, 32);
}
void Invulnerability::UpdateActor(float deltaTime){
if (this->GetCollision()->Intersect(this->GetGame()->GetPlayer()->GetCollision())){
Mix_PlayChannel(-1, GetGame()->GetSound("Assets/Sounds/Invincibility.wav"), 0);
this->GetGame()->GetPlayer()->SetInvulnerable(true);
this->SetState(Actor::EDead);
}
if (this->GetPosition().x - this->GetGame()->GetCameraPos().x < -this->GetCollision()->GetWidth()/2){
this->SetState(Actor::EDead);
}
}
| [
"TheJeffrey@tmldeMacBook-Pro.local"
] | TheJeffrey@tmldeMacBook-Pro.local |
b5dd94722e7d3a75662085f1eb590b3bf9ea7440 | 375389e3a1eeb45dd6ef79cfec28262e0e694009 | /Codes/706c.cpp | ceeee681b7553d39d7140cd11baadb3a9fe29f57 | [] | no_license | erocodesenin/PracticeCP-1500-1600- | 15fbb26d4f980b9051d87c06ad25636c38b5ad72 | 9e7054051efd594835c62d10df45d0fe041a638d | refs/heads/master | 2020-05-29T09:33:43.858921 | 2019-06-06T08:27:17 | 2019-06-06T08:27:17 | 189,067,873 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,333 | cpp | #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
string s[100005][2];
lld dp[100005][2];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("input.txt", "r", stdin);
int n;
cin >> n;
int arr[n];
// for(int i=0;i<n;i++)
// cin >> arr[i];
vector <pair <int,int> > v;
for(int i=0;i<10;i++)
{
int a,b;
cin >> a >> b;
v.push_back({a,b});
}
for(int i=0;i<10;i++)
{
cout << v[i].first << " " << v[i].second << "\n";
}
for(int i=0;i<n;i++)
{
cin >> s[i][0];
s[i][1]=s[i][0];
reverse(s[i][1].begin(),s[i][1].end());
}
dp[0][1]=arr[0];
for(int i=1;i<n;i++)
{
for(int j=0;j<2;j++)
{
dp[i][j]=1e18;
for(int k=0;k<2;k++)
{
if(s[i][j]>=s[i-1][k])
{
dp[i][j]=min(dp[i][j],dp[i-1][k]+j*arr[i]);
}
}
}
}
lld ans = min(dp[n-1][0],dp[n-1][1]);
if(ans==1e18)
cout <<"-1";
else
cout << ans;
} | [
"erocodesenin@gmail.com"
] | erocodesenin@gmail.com |
18bf1ceb4ceb10664de6e7696e8ad3241d034663 | 2bc2415e697671aea985d3145ec6b80b87f2e644 | /ScanVer1_0/highform.cpp | 5fc55c321ba50fbb233c96fdd638fd12ba69e270 | [] | no_license | zhuym799/scan | 36b66db55406c337facf3d1e288873295de4f938 | b5b16e5f3b4d89ce6e12bc19e054b0d810ffad0e | refs/heads/main | 2023-04-28T23:28:04.640498 | 2021-05-09T10:26:20 | 2021-05-09T10:26:20 | 353,310,198 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 201 | cpp | #include "highform.h"
#include "ui_highform.h"
HighForm::HighForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::HighForm)
{
ui->setupUi(this);
}
HighForm::~HighForm()
{
delete ui;
}
| [
"923637194@qq.com"
] | 923637194@qq.com |
af46ae826650eb30aab252e7de977de3a58728c9 | afec113dcac49a1f341d42be821973755051e103 | /seadmin/CAdminAPI.cpp | 8671cff4aaf749eb97f288ed589a2a4d8fb982ae | [] | no_license | radtek/earnsmart | e080bafa824bf2728fbf8603d46c11430d77cfb6 | df3983366a993d1e5ba0167d2483c3eb799b25be | refs/heads/master | 2020-06-22T06:14:04.646933 | 2019-02-15T13:32:59 | 2019-02-15T13:32:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 81,656 | cpp | /*
* File: CAdminAPI.cpp
* Author: santony
*
* Created on March 22, 2013, 9:20 PM
*
*
*/
#include "internal.h"
#include "CAdminAPI.h"
#include "../seglobal/CList.h"
#include "CAudit.h"
#include "../seglobal/CROList.h"
#include "CUser.h"
#include "CUserType.h"
#include "../semysql/CMyqlUtilities.h"
#include "../seglobal/exceptions.h"
#include "CProduct.h"
#include "CCustomer.h"
#include "CCustomerSubscriptionType.h"
#include "CCustomerSubscriptionInfo.h"
#include "CPurchase.h"
#include "CCustomerStatus.h"
#include <boost/tokenizer.hpp>
#include "../seglobal/exceptions.h"
#include "../seglobal/CFunctionCache.h"
#include "CPaypalExpressCheckout.h"
#include "../seglobal/CROList.h"
#include "CCountry.h"
#include "CCountryState.h"
#include "CWebSession.h"
#include "../seglobal/CSecure.h"
#include "../seglobal/CString.h"
#include "../external/mariadbpp/mystring.h"
#include <uuid/uuid.h>
//#include <pegtl/rules_string.hh>
#include "../semain/CSession.h"
#include "../seglobal/CStringUtility.h"
#include "../senet/CSmtpClient.h"
#include "CHelpDocTree.h"
#include "../senet/CEmailTemplate.h"
#include "CPositions.h"
#include "../senet/CSmtpVmimeClient.h"
#include "../senet/senetapi.h"
#include "../semath/CRandomizer.h"
#define SEDBCONN CSEConnections::GetMain()
#define SEDBADM CSEConnections::GetAdmin()
#define FROMEMAIL "postmaster@earn-smart.com"
#define SESSIONEXPIREDAYS 14
using namespace se;
using namespace se::data;
namespace se
{
namespace admin
{
Mutex CAdminAPI::adminLock;
SP<IAdminAPI> CAdminAPI::pApi;
#define QUERYFIELDLOGIC \
if (lgx == LGX_And) \
{ \
if (!bWhere) \
{ \
query << " where "; \
bWhere = true; \
} \
else \
query << " and "; \
} \
else \
{ \
if (!bWhere) \
{ \
query << " where "; \
bWhere = true; \
} \
else \
query << " or "; \
}
//NamedObjectNamingType IAdminAPI::Name = 0xD;
NamedObjectNamingType CAdminAPI::get_TypeId()
{
return IAdminAPIName;
}
CAdminAPI::CAdminAPI(ISession* ps) : CObjectRoot(ps)
{
}
CAdminAPI::~CAdminAPI()
{
}
long unsigned int CAdminAPI::Init()
{
return S_OK;
}
RP<IAudit> CAdminAPI::GetAuditor()
{
IAudit* pAudit;
CObject<CAudit>::Create(get_Session(), &pAudit);
return pAudit;
}
ErrorId CAdminAPI::get_Address(UID id, IAddress** ppOut)
{
if (id ==0 ) return S_False;
CSmartConnection conn(SEDBCONN);
try
{
Query q = conn->query();
q << "select addresses.*, se_gbl_countries.country_name as country, se_gbl_states.name as state from addresses \
left join se_gbl_countries on addresses.country_id = se_gbl_countries.country_id \
left join se_gbl_states on addresses.state_id = se_gbl_states.state_id \
where addresses.addr_id = " << id;
auto qRes = q.store();
if(qRes.size())
{
const Row& row = qRes[0];
SP<IAddress> pAddr ;
auto retCode = CreateAddress(get_Session(), &pAddr);
if (FAILED(retCode))
{
// LOGE(_logger, "Failed to create address instance.");
return retCode;
}
pAddr->set_Name(((string)row["name"]).c_str());
pAddr->set_City(((string)row["city"]).c_str());
pAddr->set_State(((string)row["state"]).c_str());
pAddr->set_Street(((string)row["street1"]).c_str());
pAddr->set_Street2(((string)row["street2"]).c_str());
pAddr->set_Country(((string)row["country"]).c_str());
pAddr.CopyTo(ppOut);
return S_Success;
}
return E_NotFound;
}
catch (const std::exception& ex)
{
// LOGE(_logger, "Error : " << ex.what());
return E_DBQueryException;
}
}
ErrorId CAdminAPI::set_Address(IAddress* pIn)
{
try
{
CSmartConnection conn(SEDBCONN);
ErrorId retCode = set_Address(conn, pIn);
if (SUCCEEDED(retCode))
conn.CommitTransaction();
else
conn.RollbackTransaction();
return retCode;
}
CATCHCLAUSE("set_Address");
}
ErrorId CAdminAPI::set_Address(CSmartConnection& conn, IAddress* pIn)
{
try
{
// the user may provide the country and state in
// full text or code. Verify both.
I16 country_id;
Query q = conn->query();
q << "select country_id from se_gbl_countries where country_name = " ;
q << quote << pIn->get_Country();
StoreQueryResult qr = q.store();
if (qr.size())
country_id = qr[0][0];
else
{
//q = conn->query();
q << "select country_id from se_gbl_countries where country_code = " ;
q << quote << pIn->get_Country();
qr = q.store();
if (qr.size())
country_id = qr[0][0];
else
{
//q = conn->query();
q << "select country_id from se_gbl_countries where country_code1 = " ;
q << quote << pIn->get_Country();
qr = q.store();
if (qr.size())
country_id = qr[0][0];
}
}
// match and then insert
//q = conn->query();
q << "SELECT address_id from addresses where ";
q << "city = " << quote << pIn->get_City();
q << " and state = " << quote << pIn->get_State();
q << " and street1 = " << quote << pIn->get_Street();
q << " and street2 = " << quote << pIn->get_Street2();
q << " and postcode = " << quote << pIn->get_PostalCode();
q << " and country_id = " << country_id;
qr = q.store();
if (!qr.size())
{
q << "INSERT INTO addresses (name, city, country_id, state ,street1,street2, postcode) ";
q << "VALUES (" ;
q << quote << pIn->get_Name() << ", " ;
q << quote << pIn->get_City() << ", " ;
q << country_id << ", " ;
q << quote << pIn->get_State() << ", " ;
q << quote << pIn->get_Street() << ", " ;
q << quote << pIn->get_Street2() << ", ";
q << quote << pIn->get_PostalCode();
q << " )";
// LOGIP(q.str());
q.exec();
// get auto increment id
UID addrid = (UID)q.insert_id();
pIn->set_Id(addrid);
}
else
pIn->set_Id((UID)qr[0][0]);
return S_Success;
}
CATCHCLAUSE("set_Address (private)");
}
long unsigned int CAdminAPI::set_UserAddress(CSmartConnection& conn, IUser* pUser, IAddress* pAddress)
{
try
{
SP<IUser> puser(pUser);
SP<IAddress> pAddr(pAddress) ;
I64 addId = 0;
if (pAddr)
{
THROWIFFAILED(set_Address(conn, pAddr), "Failed to get address from user.");
addId = pAddr->get_Id();
Query q = conn->query();
q << "SELECT * FROM user_addr where is_current = 1 and ";
q << "user_id = " << puser->get_Id() << " and addr_id = " << pAddr->get_Id();
auto qRes = q.store();
if(!qRes.size())
{
q = conn->query();
q << "update user_addr set is_current = 0 where ";
q << "user_id = " << puser->get_Id() << " and addr_id = " << pAddr->get_Id();
q.execute();
q = conn->query();
q << "INSERT INTO user_addr (user_id, addr_id, is_current, seton ) ";
q << "VALUES (" <<puser->get_Id()<<", "<<pAddr->get_Id()<<", 1, now())";
q.exec();
}
else
{
q = conn->query();
q << "UPDATE user_addr set ";
q << " is_current = 1, seton = now() ";
q << "where user_id = "<<puser->get_Id() << "and addr_id = "<<pAddr->get_Id();
q.exec();
}
}
return S_Success;
}
CATCHCLAUSE("set_UserAddress (private)");
}
////////////////////////Private method begins///////////////////////////
ErrorId CAdminAPI::get_User(CSTR userId, IUser** ppUser)
{
try
{
const string funcName = "se.admin.get_User1";
//TODO: utilize get_user that accept UID. in function , save userId -> uid in function map.
// then using cached uid, get Iuser instance from function cache.
CSmartConnection conn(SEDBCONN);
Row row ;
Query q = conn->query();
q<<"SELECT * FROM users where user_login = "<<quote<<userId;
auto qRes = q.store();
if (qRes.size())
{
const Row& row = qRes[0];
ErrorId retCode = SetUser(conn, row, ppUser);
if (FAILED(retCode))
{
// LOGE(_logger, "Failed with error code " << retCode);
}
return retCode;
}
// LOGE(_logger, "Failed with error code " << E_NotFound);
return E_NotFound;
}
catch (const std::exception& ex)
{
// LOGE(_logger, "Error : " << ex.what());
return E_DBQueryException;
}
}
ErrorId CAdminAPI::get_User(UID id, IUser** ppUser)
{
try
{
ostringstream funcName ;
funcName << "se.admin.get_User_" << id;
IUser* p;
if (!FC.TrySPGetFValue(funcName.str(), id, p))
{
Poco::ScopedLock<Mutex> g(adminLock);
if (!FC.TrySPGetFValue(funcName.str(), id, p))
{
// if id == 0, then anonymous user.
if (id == 0)
{
THROWIFFAILED(IUser::CreateAnonymous(get_Session(), &p), "Failed to create anonymous user.");
p->set_Active(true);
FC.SPSetFValue(funcName.str(), id, p);
*ppUser = p;
return S_Success;
}
else
{
CSmartConnection conn(SEDBADM);
Query q = conn->query();
{
q << "SELECT * FROM saadmin.users where ID = " <<quote << id;
auto qRes = q.store();
if (qRes.size())
{
Row& row = qRes[0];
ErrorId retCode = SetUser(conn, row, &p);
if (FAILED(retCode))
{
if (FAILED(retCode))
throw seexception(retCode, "Failed to open an user instance.");
}
FC.SPSetFValue(funcName.str(), id, p);
*ppUser = p;
return S_Success;
}
else
throw seexception(E_NotFound, "User not found.");
}
}
}
}
p->AddRef();
*ppUser = p;
return S_Success;
}
CATCHCLAUSE("get_User");
}
long unsigned int CAdminAPI::get_UserFromSessionUniqueID(const char* uniqueSessionId, IUser** ppUser)
{
try
{
CSmartConnection conn(SEDBADM);
Query q = conn->query();
q << "select `ID` from saadmin.users where user_sessionid = " << quote << uniqueSessionId;
auto store = q.store();
UID userId = 0;
if (store.size())
{
userId = store[0][0];
}
return get_User(userId, ppUser); // this method takes care of any anonymous user.
}
CATCHCLAUSE("get_UserFromSessionUniqueID");
}
////////////////////// Private method begins///////////////////////////////
/////////// private method begins/////////////////////////////
long unsigned int CAdminAPI::set_User(CSmartConnection& conn, IUser* pUser)
{
try
{
// ensure we have a safe pointer
SP<IUser> pIn(pUser);
if (pUser->get_Id()) // if saving an existing user info.
{
Query q = conn->query();
q << "UPDATE users set";
q << " user_login = " << quote << pIn->get_UserId();
q << ", user_roles = " << (I32)pIn->get_Roles();
q << ", user_email = " << quote << pIn->get_UserId();
q << ", user_firstname = " << quote << pIn->get_FirstName();
q << ", user_lastname = " << quote << pIn->get_LastName();
q << ", user_isactive = " << quote << pIn->get_IsActive() ? '1' : '0';
q << ", user_updatedon = NOW() ";
q << " where ID = " << pIn->get_Id();
q.exec();
}
else
{
Query q = conn->query();
q << "select ID from users where user_login = " << quote << pUser->get_UserId();
if (q.store().size())
{
// LOGE(_logger, "User with// LOGin " << pUser->get_UserId() << " already exists. Cannot continue.");
return E_UserLoginExists;
}
q = conn->query();
q << "INSERT INTO users ";
q << "(user_login, user_roles, user_email, user_registeredon, user_firstname, user_lastname, user_isactive, user_createdon ) ";
q << "VALUES (";
q << quote << pIn->get_UserId();
q << ", " << (I32)pIn->get_Roles();
q << ", " << quote << pIn->get_UserId();
q << ", NOW() ";
q << ", " << quote << pIn->get_FirstName();
q << ", " << quote << pIn->get_LastName();
q << ", " << pIn->get_IsActive() ? '1' : '0';
q << ", NOW() ";
q << ") " ;
q.exec();
pIn->set_Id((UID)q.insert_id());
}
return S_Success;
}
CATCHCLAUSE("set_User - private -");
}
//////////// private method ends/////////////////////////
ErrorId CAdminAPI::set_User(IUser* pIn)
{
try
{
/*start a transaction since multiple tables are involved.
* 1. grab address id from pIn->get_Address()
* 2. If this address_id = 0, then insert an address in address table
* 3. get the new address id in address instance.
* 4. save user information + addressid
* 5. insert or update a row in user_addr also.
*
*/
CSmartConnection conn(SEDBCONN);
conn.BeginTransaction();
ErrorId retCode = set_User(conn, pIn);
if (SUCCEEDED(retCode))
conn.CommitTransaction();
else
conn.RollbackTransaction();
return retCode;
}
CATCHCLAUSE("set_User");
}
ErrorId CAdminAPI::get_Users(CSTR criteria, IROSPList<IUser> **ppUsers)
{
string line = criteria;
using namespace boost;
typedef tokenizer< char_separator<char> > Tokenizer;
typedef vector<string> TokenVector;
TokenVector vec;
char_separator<char> sep(";", "", keep_empty_tokens);
Tokenizer tok(line, sep);
vec.assign(tok.begin(), tok.end());
I32 i = 0;
string aWhere;
while(i <vec.size())
{
string sub = vec[i];
TokenVector vecSub;
char_separator<char> sepSub("=", "", keep_empty_tokens);
Tokenizer tokSub(sub, sepSub);
vecSub.assign(tokSub.begin(), tokSub.end());
string sVlue = vecSub[0];
if(sVlue == "Id")
{
aWhere = aWhere + "ID LIKE '%" +vecSub[1]+"'%";
}
else if(sVlue == "UserId")
{
aWhere = aWhere + "user_login LIKE '%" +vecSub[1]+"'%";
}
else if(sVlue == "FirstName")
{
aWhere = aWhere + "user_firstname LIKE '%" +vecSub[1]+"'%";
}
else if(sVlue == "LastName")
{
aWhere = aWhere + "user_lastname LIKE '%" +vecSub[1]+"'%";
}
if(i<(vec.size()-1))
aWhere = aWhere+" and ";
i = i++;
}
CSmartConnection conn(SEDBCONN);
SP<CROSPList<IUser>> pList;
ErrorId retCode = CObject<CROSPList<IUser>>::Create(get_Session(), &pList);
if (FAILED(retCode))
{
// LOGEP("Error Creating List");
return retCode;
}
Row row ;
Query q = conn->query();
q<<"SELECT * FROM users where "<<aWhere;
auto qRes = q.store();
for (const Row& row : qRes)
{
SP<IUser> pUser;
retCode = IUser::Create(get_Session(), &pUser);
if (FAILED(retCode))
{
// LOGE(_logger, "can't create User Type");
return retCode;
}
retCode = SetUser(conn, row, &pUser);
if (FAILED(retCode))
{
// LOGE(_logger, "Failed with error code " << retCode);
return retCode;
}
pList->Add(pUser._ptr);
}
pList.CopyTo(ppUsers);
return S_Success;
}
long unsigned int CAdminAPI::set_UserPassword(CSmartConnection& conn, unsigned long userId, const char* clearpassword)
{
try
{
Query q = conn->query();
q << "update users set ";
q << " user_pass = AES_ENCRYPT(" << quote << clearpassword << ", " << quote << conn.get_Key() << ")";
q << " where ID = " << userId;
//LOGIP(q.str());
q.execute();
}
CATCHCLAUSE("set_UserPassword");
}
long unsigned int CAdminAPI::LoadRegistrationData(const char* uuid, IString** ppOut)
{
using namespace mysqlpp;
try
{
CSmartConnection conn(SEDBCONN);
Query q = conn->query();
q << "select regdata from user_registrations where uuid = " << quote << uuid;
auto uqr = q.use();
Row row;
if (uqr and (row = uqr.fetch_row()))
{
THROWIFFAILED( CString::Create( (CSTR)row["regdata"].c_str(), ppOut), "CString::Create");
return S_OK;
}
return E_NoDataToReturn;
}
CATCHCLAUSE("LoadRegistrationData");
}
long unsigned int CAdminAPI::SaveRegistrationData(const char* uuid, const char* regdata)
{
try
{
CSmartConnection conn(SEDBCONN);
/*
* INSERT INTO `sa`.`user_registrations`
(`uuid`,
`regdata`,
`createdon`,
`updatedon`)
VALUES
(<{uuid: }>,
<{regdata: }>,
<{createdon: }>,
<{updatedon: }>);
*
*
UPDATE `sa`.`user_registrations`
SET
`uuid` = <{uuid: }>,
`regdata` = <{regdata: }>,
`createdon` = <{createdon: }>,
`updatedon` = <{updatedon: }>
WHERE `uuid` = <{expr}>;
*/
Query q = conn->query();
q << "select uuid from user_registrations where uuid = " << quote << uuid;
if (q.store().size())
{
q << "update user_registrations set";
q << " regdata = " << quote << regdata;
q << " and updatedon = now()";
q << " where uuid = " << quote << uuid;
}
else
{
q << "insert into user_registrations (uuid, regdata, createdon) ";
q << "values (" << quote << uuid << ", " << quote << regdata << ", now())";
}
q.exec();
return S_OK;
}
CATCHCLAUSE("SaveRegistrationData");
}
long unsigned int CAdminAPI::RegisterUser(const Json::Value& regInfo)
{
// @regInfo : The regInfo parameter is json object of below format.
// {
// RegStages : 0, //// Registration stages 0=UserTypeAndAddress, 1=sendEmailToConfirmation, 2=emailConfirmed, 3=Paymentprovided, 4=RegistrationCompleted
// RegType : "standard", //// or licensed)
// FirsName : "",
// LastName : "",
// EmailAddress : "",
// Password : "",
// ConfirmPassword: "",
// RememberMe : false,
// Street1 : "",
// Street2 : "",
// Town : "",
// Country : 0,
// State : 0,
// StateProvince : "",
// PostalCode : ""
// }
#ifdef __DEBUG__
Json::StyledWriter writer;
BDBG << writer.write(regInfo);
#endif
// validate data
REGSTAGES regStage;
std::string regType = "standard";
UserRole role = UserRole::Standard;
std::string firstName, lastName, emailAddress;
CSmartConnection conn(SEDBADM);
std::string password, confirmPwd;
std::string street1, street2, town, pc, stateprovince;
I32 country = 0, state = 0;
bool remember;
firstName = regInfo.get("FirstName", "").asString();
lastName = regInfo.get("LastName", "").asString();
emailAddress = regInfo.get("EmailAddress", "").asString();
password = regInfo.get("Password", "").asString();
confirmPwd = regInfo.get("ConfirmPassword", "").asString();
remember = regInfo.get("RememberMe", false).asBool();
U64 emailCode = se::math::CRandomizer::DefaultRandomNumber();
try
{
if (emailAddress.empty())
{
return E_ValidateEmail;
}
if (password.empty() or password != confirmPwd)
{
return E_ValidatePassword;
}
if (firstName.empty() and lastName.empty())
{
return E_ValidateName;
}
if (!se::utils::CStringUtility::ValidateEmail(emailAddress))
{
return E_ValidateEmail;
}
SP<IUser> pUser;
if (SUCCEEDED(CheckUserLogin(emailAddress.c_str(), &pUser)))
{
((ISessionInterface*)get_Session())->Reset(pUser);
auto retSync = SyncUserSession(conn, pUser->get_Id(), get_Session()->get_UniqueId());
if (FAILED(retSync))
{
return retSync;
}
return E_PartiallyRegistered;
}
if (regType == "licensed")
{
street1 = regInfo.get("Street1", "").asString();
street2 = regInfo.get("Street2", "").asString();
town = regInfo.get("Town", "").asString();
pc = regInfo.get("PostalCode", "").asString();
state = regInfo.get("State", 0).asInt();
country = regInfo.get("Country", 0).asInt();
if (street1.empty() or town.empty() or pc.empty())
{
BERR << "street1, town or postal code not given.";
return E_Validation;
}
if (state == 0)
{
stateprovince = regInfo.get("StateProvince", "").asString();
}
if (stateprovince.empty())
{
if (state<= 0 or state>=10000)
{
return E_ValidateState;
}
}
if (country <= 0 or country >=1000)
{
return E_ValidateCountry;
}
else
{
// verify state against country
if (state > 0)
{
Json::Value jsstate;
CSqlAst ast = AST_CONDITION(QUERYFIELDS::State::State::Id, AST_OPERATOR::Equal, state);
ast & AST_CONDITION(QUERYFIELDS::Country::Id, AST_OPERATOR::Equal, country);
BDBG << ast;
if (FAILED(get_State(jsstate, &ast)))
{
BERR << "There is no state that matches state_id " << state << " for country with id " << country;
return E_ValidateState;
}
// print state info
BDBG << jsstate;
}
}
}
conn.BeginTransaction();
Query q = conn->query();
UID userId = 0;
q << "INSERT INTO saadmin.users ";
q << "(user_login, user_pass, user_firstname, user_lastname, user_email, user_emailconfirmcode, user_registeredon, user_regstage, user_role, user_isactive, user_sessionid, user_remember, user_createdon) ";
q << "VALUES ";
q << "(" << quote << emailAddress << ", AES_ENCRYPT(" << quote << password << ", " << quote << conn.get_Key() << "), ";
q << quote << firstName << ", ";
q << quote << lastName << ", ";
q << quote << emailAddress << ", ";
q << quote << emailCode << ", ";
q << "now(), " << (U16)REGSTAGES::SendEmailForConfirmation << ", " << (regType == "licensed" ? (int)UserRole::Licensed : (int)UserRole::Standard ) << ", 1, " << quote << get_Session()->get_UniqueId() << ", ";
q << quote << (remember ? "1" : "0") << ", now() )";
BDBG << q.str();
q.exec();
userId = q.insert_id();
// obtain a reference to the user instance.
pUser.Clear();
if (!street1.empty() && ISOK(get_User(userId, &pUser)))
{
//TODO
SP<IAddress> paddr;
IAddress::Create(this->get_Session(), &paddr);
paddr->set_City(street1.c_str());
paddr->set_Street2((street2.c_str()));
paddr->set_City(town.c_str());
paddr->set_State(stateprovince.c_str()); // paddr->set_State(state) //TODO takes integer
//paddr->set_Country() // TODO : takes integer.
THROWIFFAILED(pUser->set_Address(paddr), "User address not saved.");
}
// register user activity
auto retCode = RecordSessionActivity(conn, userId);
if (FAILED(retCode))
{
throw se::seexception(retCode);
}
get_Session()->set_Id(userId);
}
RBCATCHCLAUSE("RegisterUser")
try
{
// send an email
string emailTemplate = "standardregistration.html";
se::net::TemplateVaribles vars;
vars.insert(make_pair("FirstName", regInfo.get("FirstName", "").asString()));
std::ostringstream os;
// if device is IOS ///TODO FOR ANDROID, WINDOWS, BROWSER, ETC.
os << "earnsmart://confirmemail=";
os << emailCode;
vars.insert(make_pair("ConfirmUrl", os.str() ));
se::net::CEmailTemplate etempl(this->get_Session(),emailTemplate, vars);
std::string emailContent = etempl.Apply();
SP<IString> retMsg;
auto retVal = se::net::SendEmail(
se::net::EMLPROVD::Office365,
FROMEMAIL,
emailAddress.c_str(),
"Earnsmart Registration : Email Confirmation Required",
emailContent.c_str(),
&retMsg
);
if (FAILED(retVal))
{
BERR << "Failed to send email with error '" << get_CodeMessage(retVal) << "'";
throw se::seexception(E_EmailSendError);
}
else
{
BINF << retMsg->get_Buffer();
}
conn.CommitTransaction();
return S_OK;
}
RBCATCHCLAUSE("RegisterUser(SendEmailConfirmation)")
}
SE_CODE CAdminAPI::RegisterUser(IUser** ppUser)
{
ISession* pSession = this->get_Session();
// generate a unique id
uuid_t uniqueId;
uuid_generate_time_safe(uniqueId);
char buff2[256];
uuid_unparse_lower(uniqueId, buff2);
pSession->set_UniqueId(buff2);
pSession->set_Id(0);
// save a record in user sessions and return.
CSmartConnection conn(SEDBADM);
try
{
Query q = conn->query();
q << "INSERT INTO user_sessions (";
q << "session_id, user_id, session_date, session_type ";
q << ") VALUES (";
q << quote << buff2 << ", 0, NOW(), 1";
q << ")";
BDBG << q.str();
q.exec();
if (ppUser)
{
return IUser::CreateAnonymous(get_Session(), ppUser);
}
return S_OK;
}
CATCHCLAUSE("RegisterUser")
}
long unsigned int CAdminAPI::ConfirmUser(const char* emailCode)
{
CSmartConnection conn(SEDBADM);
try
{
conn.BeginTransaction();
// flag the user a email confirmed.
UID userId = 0;
Query q = conn->query();
q << "select ID from users where user_emailconfirmcode = " << quote << emailCode;
auto qstore = q.store();
if (qstore.size())
userId = qstore[0][0];
else
{
BERR << "Register user not found in the system.";
conn.RollbackTransaction();
return E_UserRegistrationNotFound;
}
q = conn->query();
q << "UPDATE saadmin.users SET ";
q << "user_regstage = " << (U16)REGSTAGES::RegistrationCompleted << ", user_updatedon = NOW() ";
q << "WHERE `ID` = " << userId;
q.exec();
conn.CommitTransaction();
return S_RegistrationCompleted;
}
RBCATCHCLAUSE("RegisterUser(EmailConfirmed)")
}
long unsigned int CAdminAPI::UnregisterUser(unsigned long userId)
{
try
{
CSmartConnection conn(SEDBADM);
conn.BeginTransaction();
try
{
// delete customer record 'customers'
// delete user type records
// delete session record.
// delete address record
// delete user record.
Query q = conn->query();
q << "delete from customers where user_id = " << userId;
q.execute();
//q = conn->query();
q << "delete from user_usertypes where user_id = " << userId;
q.execute();
//q = conn->query();
q << "delete from user_addr where user_id = " << userId;
q.execute();
//q = conn->query();
q << "delete from users where ID = " << userId;
q.execute();
//q = conn->query();
q << "delete from user_sessions where user_id = " << userId;
q.execute();
conn.CommitTransaction();
return S_Success;
}
RBCATCHCLAUSE("UnregisterUser");
}
CATCHCLAUSE("UnregisterUser");
}
SE_CODE CAdminAPI::UpgradeUser(const Json::Value& upgradeInfo)
{
/*
*
*/
// capture session user
RP<IUser> pUser = ((ISessionInterface*)get_Session())->get_User();
if (!pUser)
{
BERR << "get_Session() didn't return a user object of standard license.";
return E_UserRegistrationNotFound;
}
if (pUser->get_IsInRole(UserRole::Licensed))
{
return E_UserAlreadyLIcensed;
}
if (!pUser->get_IsInRole(UserRole::Standard))
{
return E_CannotUpgradeUser;
}
if (upgradeInfo.empty() || !upgradeInfo.isMember("paymentdetails") || !upgradeInfo.isMember("packages"))
{
BERR << "Invalid parameter 'upgradeInfo'. Doesn't contain required information.";
return E_JsonRpcInsufficientParameters;
}
assert(pUser->get_UserId() > 0);
CSTR customertoken = upgradeInfo["paymentdetails"]["customertoken"].asCString();
R8 fees = upgradeInfo["paymentdetails"]["fees"].asDouble();
const Json::Value& packages = upgradeInfo["packages"];
// verify user
auto ret = this->CheckUserLogin(pUser->get_UserId(), &pUser);
RETIFFAILED(ret);
CSmartConnection conn(SEDBADM);
conn.BeginTransaction();
try
{
// update users table (regstage completed,
Query q = conn->query();
q << "update users set user_role = " << (U32)UserRole::Licensed;
q << ", user_registered = Now() ";
q << ", user_updatedon = Now() ";
q << " where ID = " << pUser->get_Id();
BDBG << q.str();
q.execute();
ERRIFFAILED(BeginAsLicensedUser(conn, pUser->get_Id(), 1 /* paypal */, packages.asCString(), fees));
conn.CommitTransaction();
this->RecordSessionActivity();
return S_OK;
}
RBCATCHCLAUSE("UpgradeUser")
}
SE_CODE CAdminAPI::DowngradeUser(CSTR userlogin)
{
// apart from downgrading in our tables, we also want to cancel
// the payment processing of the user in the paypay server.
if (!userlogin || !strlen(userlogin))
{
return E_InvalidArg;
}
// verify user
SP<IUser> pUser;
auto ret = this->CheckUserLogin(userlogin, &pUser);
RETIFFAILED(ret);
if (pUser->get_Roles() != UserRole::Licensed)
{
return E_CannotDowngradeUser;
}
try
{
CSmartConnection conn(SEDBADM);
conn.BeginTransaction();
try
{
Query q = conn->query();
q << "update users set user_role = " << (U32)UserRole::Standard;
q << ", user_registered = Now() ";
q << ", user_updatedon = Now() ";
q << " where ID = " << pUser->get_Id();
BDBG << q.str();
q.execute();
ERRIFFAILED(EndAsLicensedUser(conn, pUser->get_Id()));
conn.CommitTransaction();
this->RecordSessionActivity();
}
RBCATCHCLAUSE("DowngradeUser")
bool yes =false;
if (yes)
{
SP<IPaypalExpressCheckout> ppCheckout;
auto retCode= this->get_PaypalExpressCheckOut(&ppCheckout);
if (ISOK(retCode))
{
SP<IString> profileId;
retCode = ppCheckout->Step0x1_CancelRecurringPaymentsProfileStatus("ss", "ss", &profileId);
}
if (FAILED(retCode))
{
// EMAIL TO ADMINISTRATION TO HANDLE THIS MANUALLY.
se::net::SendEmail(se::net::EMLPROVD::SparkPost, FROMEMAIL, "postmaster@earn-smart.com", "ADMIN-URGENT: Paypal Cancellation Failed", "User xxx's downgrade failed to paypal cancelation failure.");
}
}
return S_OK;
}
catch(const std::exception& ex)
{
BERR << ex.what();
return E_DBUpdateError;
}
}
ErrorId CAdminAPI::CheckUserLogin(CSTR login, IUser** ppUser)
{
try
{
if (!strlen(login))
throw seexception(E_InvalidArg, "login parameter is empty.");
//is email ?
bool isemail = se::utils::CStringUtility::ValidateEmail(login);
CSmartConnection conn(SEDBCONN);
Query qCheck = conn->query();
qCheck << "SELECT ID FROM saadmin.users where ";
if (isemail)
qCheck << " user_email = " << quote << login;
else
qCheck << " user_login = " << quote << login;
BDBG << qCheck.str();
auto store = qCheck.store();
if (store.size())
{
UID userId = store[0][0];
if (ppUser)
{
return get_User(userId, ppUser);
}
return S_OK;
}
else
{
return E_UnknownUser;
}
}
CATCHCLAUSE("CheckUserLogin")
}
long unsigned int CAdminAPI::ResetGetTemporaryPassword(const char* login, IString** ppOut)
{
CSmartConnection conn(SEDBADM);
try
{
if (!strlen(login))
throw seexception(E_InvalidArg, "login parameter is empty.");
conn.BeginTransaction();
Query qCheck = conn->query();
qCheck << "SELECT ID, user_pass FROM saadmin.users where user_login = " << quote << login;
auto sqr = qCheck.store();
if (!sqr.size())
throw seexception(E_NotFound, "Login not registered in the system.");
// reset password process involves generating a new password with 8 chars and then
// encrypting it and save to the database.
char buff1[8];
CSecure::GenerateRandomPassword(buff1, 8);
CString::Create(buff1, ppOut);
// generate a unique session id and store back in the table and return in the session instance.
uuid_t uniqueId;
uuid_generate_time_safe(uniqueId);
char buff2[256];
uuid_unparse_lower(uniqueId, buff2);
auto q = conn->query();
q << "Update saadmin.users set " ;
q << "user_pass=AES_ENCRYPT(" << quote << buff1 << ", " << quote << conn.get_Key() << ")";
q << ", user_sessionid = " << quote << buff2;
q << " where user_login=" << quote << login;
q.exec();
get_Session()->set_UniqueId(buff2);
conn.CommitTransaction();
return S_OK;
}
RBCATCHCLAUSE(__FUNCTION__)
}
long unsigned int CAdminAPI::UpdateAuthentication(const char* login, const char* currentPwd, const char* newPwd)
{
if (!newPwd or !strlen(newPwd))
{
BERR << "New password is invalid.";
return E_IncorrectOperation;
}
UID uid;
auto rcode = VerifyUser(login, currentPwd, &uid);
if (E_SecurityAuthorization == rcode)
{
BWRN << "Authentication failed for " << login;
return rcode;
}
try
{
CSmartConnection conn(SEDBCONN);
Query q = conn->query();
q << "Update users set user_pass=AES_ENCRYPT(" << quote << newPwd << ", " << quote << conn.get_Key() << ")";
q << " where ID=" << uid;
q.exec();
return S_Success;
}
CATCHCLAUSE(__FUNCTION__)
}
long unsigned int CAdminAPI::get_HasUserSessionExpired(const char* sessionId)
{
try
{
CSmartConnection conn(SEDBCONN);
Query q = conn->query();
q << "select user_sessionid from users";
q << " where user_sessionid = " << quote << sessionId;
q << " and datediff(now(), coalesce(user_createdon, user_updatedon)) > " << SESSIONEXPIREDAYS;
return q.store().size() ? S_False : E_SessionExpired;
}
CATCHCLAUSEAUTO
}
long unsigned int CAdminAPI::VerifyUser(const char* login, const char* pwd, UID* uid)
{
try
{
CSmartConnection conn(SEDBCONN);
Query q = conn->query();
q << "select * from users ";
q << "where user_login = " << quote << login ;
q << " and ";
q << " aes_encrypt(" << quote << pwd << ", " << quote << conn.get_Key() << ") ";
q << " = user_pass";
//LOGIP(q.str());
auto qRes = q.store();
if (!qRes.size())
throw seexception(E_SecurityAuthorization, "Security authentication failed for the user.");
if (uid)
*uid = qRes[0]["ID"];
return S_Success;
}
CATCHCLAUSE(__FUNCTION__)
}
ErrorId CAdminAPI::AuthenticateUser(CSTR userId, CSTR password, bool IsEmailAddress)
{
try
{
// generate a unique session id and store back in the table and return in the session instance.
uuid_t uniqueId;
uuid_generate_time_safe(uniqueId);
char buff[256];
uuid_unparse_lower(uniqueId, buff);
CSmartConnection conn(SEDBADM);
Query q = conn->query();
q << "select * from users ";
q << "where ";
if (IsEmailAddress)
q << "user_email = " << quote << userId;
else
q << "user_login = " << quote << userId ;
q << " and ";
q << " aes_encrypt(" << quote << password << ", " << quote << conn.get_Key() << ") ";
q << " = user_pass";
BDBG << q.str();
auto qRes = q.store();
if (qRes.size())
{
UID uid = qRes[0]["ID"];
get_Session()->set_Id(uid);
q = conn->query();
q << "update users set user_sessionid = " << quote << buff << ", user_updatedon = NOW() where ID = " << uid;
q.exec();
((CSession*)get_Session())->set_UniqueId(buff);
return S_Success;
}
else
{
((CSession*)get_Session())->set_UniqueId(buff);
throw seexception(E_SecurityAuthorization, "Security authentication failed for the user.");
}
}
CATCHCLAUSE("AuthenticateUser")
}
long unsigned int CAdminAPI::SetSessionAndRememberStates(CSmartConnection& conn, unsigned long UserId, const char* sessionId, bool Remember)
{
try
{
Query q = conn->query();
q << "update users set user_sessionid = " << quote << sessionId;
q << ", user_remember=" << (Remember ? '1' : '0') ;
q << " where ID = " << UserId;
q.exec();
return S_OK;
}
CATCHCLAUSE(__FUNCTION__)
}
ErrorId CAdminAPI::set_UserStatus(CSTR userId, bool IsActive)
{
try
{
CSmartConnection conn(SEDBCONN);
Query q = conn->query();
q<<"UPDATE users set user_status = "<<IsActive<<" where user_nickname = "<<quote<<userId;
q.exec();
return S_Success;
}
CATCHCLAUSE(__FUNCTION__)
}
long unsigned int CAdminAPI::set_UserRoles(unsigned long userId, UserRole roles)
{
try
{
CSmartConnection conn(SEDBCONN);
Query q = conn->query();
q << "UPDATE users set user_roles = "<< (I32)roles <<" where ID = " << userId;
q.exec();
return S_Success;
}
CATCHCLAUSE(__FUNCTION__)
}
///////////////////////////// User's session management ////////////////////////////
long unsigned int CAdminAPI::RecordSessionActivity()
{
if (!this->get_Session())
{
return E_SessionUnknown;
}
CSmartConnection conn(SEDBADM);
return RecordSessionActivity(conn, get_Session()->get_UserId());
}
long unsigned int CAdminAPI::RecordSessionActivity(CSmartConnection& conn, UID userId)
{
if (!this->get_Session())
{
return E_SessionUnknown;
}
try
{
Query q = conn->query();
q << "CALL spRegisterUserSession(" << quote << get_Session()->get_UniqueId() << ", " << userId << ")";
q.execute();
return S_OK;
}
CATCHCLAUSE("RecordSessionActivity")
}
/////////////////////////////////Global Methods///////////////////////////////////
SE_CODE CAdminAPI::get_Countries(mysqlpp::StoreQueryResult& sqr, const std::function<CSTR (ICountry::QUERYFLDS, LGX&, BOOL& include)>& criteria)
{
try
{
// ask for fields needed
CSmartConnection conn(SEDBCONN);
Query query = conn->query();
if (!criteria)
query << "select * from se_gbl_countries where country_id > 0 order by country_name";
else
{
bool bWhere = false;
query << "select * from se_gbl_countries ";
BOOL bresult = false;
LGX lgx = LGX_None;
CSTR sret = criteria(ICountry::QUERYFLDS::Name, lgx, bresult);
if (bresult && strlen(sret))
{
QUERYFIELDLOGIC;
query << " country_name = " << quote << sret;
bWhere=true;
}
bresult = false;
lgx = LGX_None;
sret = criteria(ICountry::QUERYFLDS::TwoChar, lgx, bresult);
if (bresult && strlen(sret))
{
QUERYFIELDLOGIC;
query << " country_code = " << quote << sret;
}
bresult = false;
lgx = LGX_None;
sret = criteria(ICountry::QUERYFLDS::ThreeChar, lgx, bresult);
if (bresult && strlen(sret))
{
QUERYFIELDLOGIC;
query << "country_code1 = " << quote << sret;
}
bresult = false;
lgx = LGX_None;
sret = criteria(ICountry::QUERYFLDS::IsPaypalavailable, lgx, bresult);
if (bresult && strlen(sret))
{
QUERYFIELDLOGIC;
query << "country_ispaypalavailable = " << quote << sret;
}
bresult = false;
lgx = LGX_None;
sret = criteria(ICountry::QUERYFLDS::Id, lgx, bresult);
if (bresult && strlen(sret))
{
QUERYFIELDLOGIC;
query << "country_id = " << sret;
}
query << " order by country_name";
}
// LOGIP(query.str());
sqr = query.store();
if (!sqr.size())
return E_NotFound;
return S_OK;
}
CATCHCLAUSE("get_Countries(private)");
}
long unsigned int CAdminAPI::get_Countries(Json::Value& jsonOut, std::function<CSTR (ICountry::QUERYFLDS, LGX&, bool&) > criteria)
{
try
{
Json::Value& list = jsonOut;
mysqlpp::StoreQueryResult sqr;
THROWIFFAILED(get_Countries(sqr, criteria), "Failed to query data for countries.");
for (const Row& row : sqr)
{
Json::Value cntry ;
cntry["key"] = (I16)row["country_id"];
cntry["name"] = (string)row["country_name"];
cntry["code1"] = (string)row["country_code1"];
cntry["code"] = (string)row["country_code"];
cntry["ispaypalavailable"] = (string)row["country_ispaypalavailable"]=="1";
list.append(cntry);
}
return S_OK;
}
CATCHCLAUSE("get_Countries(json)");
}
long unsigned int CAdminAPI::get_Countries(IROSPList<ICountry>** ppOut, std::function<CSTR (ICountry::QUERYFLDS, LGX&, BOOL& include)> criteria)
{
try
{
mysqlpp::StoreQueryResult sqr;
THROWIFFAILED(get_Countries(sqr, criteria), "Failed to query data for countries.");
SP<CROSPList<ICountry>> pList;
THROWIFFAILED(CROSPList<ICountry>::CreateROSPList(get_Session(), &pList), "Failed to create ROSPList for countries.");
for (const Row& row : sqr)
{
SP<ICountry> pc;
THROWIFFAILED(SetCountry(row, &pc), "Failed to create a country instance.");
pList->Add(pc);
}
pList.CopyTo(ppOut);
return S_Success;
}
CATCHCLAUSE("get_Countries(list)");
}
long unsigned int CAdminAPI::get_Country(ICountry** ppOut, std::function<CSTR (ICountry::QUERYFLDS, LGX&, BOOL& include)> criteria)
{
try
{
// ask for fields needed
CSmartConnection conn(SEDBCONN);
Query query = conn->query();
if (!criteria)
query << "select * from se_gbl_countries order by country_name";
else
{
bool bWhere = false;
query << "select * from se_gbl_countries ";
BOOL bresult = false;
LGX lgx = LGX_None;
CSTR sret = criteria(ICountry::QUERYFLDS::Name, lgx, bresult);
if (bresult && sret)
{
query << " where " << "country_name = " << quote << sret;
bWhere=true;
}
bresult = false;
lgx = LGX_None;
sret = criteria(ICountry::QUERYFLDS::TwoChar, lgx, bresult);
if (bresult && strlen(sret))
{
QUERYFIELDLOGIC;
query << " country_code = " << quote << sret;
}
bresult = false;
lgx = LGX_None;
sret = criteria(ICountry::QUERYFLDS::ThreeChar, lgx, bresult);
if (bresult && strlen(sret))
{
QUERYFIELDLOGIC;
query << "country_code1 = " << quote << sret;
}
bresult = false;
lgx = LGX_None;
sret = criteria(ICountry::QUERYFLDS::IsPaypalavailable, lgx, bresult);
if (bresult && strlen(sret))
{
QUERYFIELDLOGIC;
query << "country_ispaypalavailable = " << quote << sret;
}
bresult = false;
lgx = LGX_None;
sret = criteria(ICountry::QUERYFLDS::Id, lgx, bresult);
if (bresult && strlen(sret))
{
QUERYFIELDLOGIC;
query << "country_id = " << sret;
}
query << " order by country_name";
}
// LOGIP(query.str());
auto result = query.store();
if (result.size())
{
const Row& row = result[0];
return SetCountry(row, ppOut);
}
return E_NotFound;
}
CATCHCLAUSE("get_Country");
}
SE_CODE CAdminAPI::get_Country(Json::Value& outVal, CSqlAst* criteria)
{
if (!criteria)
{
return E_InvalidArg;
}
try
{
CSmartConnection conn(SEDBCONN);
Query query = conn->query();
query << "select * from list_CountryStates where " << *criteria;
auto store = query.store();
if (!store.size())
return E_NotFound;
SetCountry(store[0], outVal);
return S_OK;
}
CATCHCLAUSE("get_Country");
}
// private method begin
void CAdminAPI::SetCountry(const Row& row, Json::Value& out)
{
out["country_id"] = (I16)row["country_id"];
out["country_name"] = (string)row["country_name"];
out["country_code1"] = (string)row["country_code1"];
out["country_code"] = (string)row["country_code"];
out["country_ispaypalavailable"] = (string)row["country_ispaypalavailable"];
}
long unsigned int CAdminAPI::SetCountry(const Row& row, ICountry** ppOut)
{
return CObject<CCountry>::Create(
get_Session(),
(I16)row["country_id"],
(string)row["country_name"],
(string)row["country_code1"],
(string)row["country_code"],
(string)row["country_ispaypalavailable"]=="1",
ppOut);
}
// private method end
ErrorId CAdminAPI::get_States(IStateList** ppOut, std::function<CSTR(IState::QUERYFLDS,LGX&,bool&)> criteria)
{
try
{
CSmartConnection conn(SEDBCONN);
Query query = conn->query();
if (!criteria)
query << "select * from se_gbl_states order by name";
else
{
bool bWhere = false;
query << "select * from se_gbl_states ";
BOOL bresult = false;
LGX lgx = LGX_None;
CSTR sret = criteria(IState::QUERYFLDS::Name, lgx, bresult);
if (bresult && sret)
{
query << " where " << "name = " << quote << sret;
bWhere=true;
}
bresult = false;
lgx = LGX_None;
sret = criteria(IState::QUERYFLDS::Code, lgx, bresult);
if (bresult && strlen(sret))
{
QUERYFIELDLOGIC;
query << "code = " << quote << sret;
}
bresult = false;
lgx = LGX_None;
sret = criteria(IState::QUERYFLDS::CountryId, lgx, bresult);
if (bresult && strlen(sret))
{
QUERYFIELDLOGIC;
query << "country_id = " << sret;
}
bresult = false;
lgx = LGX_None;
sret = criteria(IState::QUERYFLDS::CountryCode, lgx, bresult);
if (bresult && strlen(sret))
{
QUERYFIELDLOGIC;
auto qcnty = conn->query();
qcnty << "select country_id from se_gbl_countries where country_code=" << quote << sret;
auto scnty = qcnty.store();
query << "country_id = " << (scnty.size() ? (CSTR)scnty[0][0] : "0");
}
query << " order by name";
}
// LOGIP(query.str());
auto qr = query.store();
if (!qr.size())
return E_NotFound;
else
{
SP<CROSPList<IState>> pList;
THROWIFFAILED(CROSPList<IState>::CreateROSPList(get_Session(), &pList), "Failed to create ROSPList for countries.");
for (const Row& row : qr)
{
SP<IState> pc;
THROWIFFAILED(SetState(row, &pc), "Failed to create a state instance.");
pList->Add(pc);
}
pList.CopyTo(ppOut);
return S_Success;
}
}
CATCHCLAUSE("get_States");
}
SE_CODE CAdminAPI::get_States(Json::Value& jsonOut, CSqlAst* criteria)
{
try
{
CSmartConnection conn(SEDBCONN);
Query query = conn->query();
if (!criteria)
query << "select * from list_CountryStates order by country_name, state_name";
else
{
const CSqlAst& ast = *criteria;
query << "select * from list_CountryStates where ";
query << ast;
query << " order by state_name";
}
BDBG << query.str();
auto qr = query.store();
if (!qr.size())
return E_NotFound;
else
{
for (const Row& row : qr)
{
Json::Value state;
THROWIFFAILED(SetState(row, state), "Failed to create a state instance.");
jsonOut.append(state);
}
return S_Success;
}
}
CATCHCLAUSE("get_States");
}
long unsigned int CAdminAPI::get_State(Json::Value& jsonOut, CSqlAst* criteria)
{
if (!criteria)
{
BERR << "Invalid argument criteria.";
return E_InvalidArg;
}
try
{
CSmartConnection conn(SEDBCONN);
Query query = conn->query();
query << "select * from list_CountryStates where " << *criteria;
BDBG << query.str();
auto store = query.store();
if (!store.size())
{
return E_NotFound;
}
SetState(store[0], jsonOut);
return S_OK;
}
CATCHCLAUSE("get_State");
}
// private method begin
long unsigned int CAdminAPI::SetState(const Row& row, IState** ppOut)
{
return CObject<CCountryState>::Create(
get_Session(),
(UID)row["state_id"],
(string)row["name"],
(string)row["code"],
(I16)row["country_id"],
ppOut);
}
long unsigned int CAdminAPI::SetState(const Row& row, Json::Value& jsout)
{
jsout["key"] = (I32)row["state_id"];
jsout["name"] = (string)row["state_name"];
jsout["code"] = (string)row["state_code"];
jsout["countrykey"] = (I16)row["country_id"];
SetCountry(row, jsout);
return S_OK;
}
/**********************Exchanges and Fees*************************/
/*
* Returns exchange code, name and fee
* @vendorSources (in): ['VENDOR1', 'VENDOR2']
* @jsOut (out): [{ key: 99, code : 'xx', name: 'xxxxx', fee: 99.99, vendor: 'xx'}]
*
*/
long unsigned int CAdminAPI::get_ExchangePackages(Json::Value& jsOut)
{
try
{
CSmartConnection conn(SEDBADM);
Query q = conn->query();
q << "select * from exchange_packages";
for (const Row& row : q.store())
{
Json::Value exchData;
exchData["key"] = (I32)row["package_id"];
exchData["name"] = (string)row["name"];
exchData["description"] = (string)row["description"];
exchData["fee"] = (R8)row["fee"];
jsOut.append(exchData);
}
return S_OK;
}
CATCHCLAUSE("get_ExchangePackages")
}
// private method end
/*************** busines operations **************/
ErrorId CAdminAPI::get_PaypalExpressCheckOut(IPaypalExpressCheckout** ppOut)
{
try
{
return CObject<CPaypalExpressCheckout>::Create(get_Session(), ppOut);
}
CATCHCLAUSE("get_PaypalExpressCheckOut");
}
ErrorId CAdminAPI::get_Product(UID id, IProduct** ppOut)
{
ErrorId retCode = E_UnknownError;
CSmartConnection conn(SEDBCONN);
Query q = conn->query();
try
{
Row row;
Query q = conn->query();
q << "select products.*, product_prices.monthly_price as monthly_price, product_prices.quarterly_price as quarterly_price, ";
q << "product_prices.yearly_price as yearly_price from products " ;
q << "left join product_prices on products.product_id = product_prices.product_id ";
q << "where products.product_id =" << id;
auto qRes = q.use();
row = qRes.fetch_row();
if(row)
{
retCode = SetProduct(row,ppOut);
if (FAILED(retCode))
{
// LOGE(_logger, "Failed with error code " << retCode);
}
return retCode;
}
return E_NotFound;
}
catch (const std::exception& ex)
{
// LOGE(_logger, "Error update: " << ex.what());
return E_DBUpdateError;
}
}
ErrorId CAdminAPI::set_Product(IProduct* pIn)
{
CSmartConnection conn(SEDBCONN);
Query q = conn->query();
try
{
{
q<<"INSERT INTO products (name) VALUES ("<<quote<<pIn->get_Name()<<")";
q.exec();
I64 pdt_Id = (I64)q.insert_id();
pIn->set_Id(pdt_Id);
}
{
q<<"INSERT INTO product_prices (product_id, monthly_price, quarterly_price, yearly_price) VALUES ("<<pIn->get_Id()<<",\
"<<pIn->get_PriceMonthlyRate()<<","<<pIn->get_PriceQuarterlyRate()<<","<<pIn->get_PriceYearlyRate()<<")";
q.exec();
}
return S_Success;
}
catch (const std::exception& ex)
{
// LOGE(_logger, "Error update: " << ex.what());
return E_DBUpdateError;
}
}
ErrorId CAdminAPI::get_Products(IROSPList<IProduct>** ppOut)
{
ErrorId retCode = E_UnknownError;
CSmartConnection conn(SEDBCONN);
SP<CROSPList<IProduct>> pList;
retCode = CObject<CROSPList<IProduct>>::Create(get_Session(), &pList);
if (FAILED(retCode))
{
// LOGEP("Error Creating List");
return retCode;
}
Query q = conn->query();
q << "select products.*, product_prices.monthly_price as monthly_price, product_prices.quarterly_price as quarterly_price, \
product_prices.yearly_price as yearly_price from products \
join product_prices on products.product_id = product_prices.product_id\
order by products.name";
auto qRes = q.use();
if (!qRes)
{
// LOGE(_logger, "can't found products");
return E_DBQueryException;
}
Row row ;
while (row = qRes.fetch_row())
{
SP<IProduct> pProduct ;
retCode = IProduct::Create(get_Session(), &pProduct);
if (FAILED(retCode))
{
// LOGE(_logger, "can't create products");
return retCode;
}
retCode = SetProduct(row, &pProduct);
if (FAILED(retCode))
{
// LOGE(_logger, "Failed with error code " << retCode);
return retCode;
}
pList->Add(pProduct);
}
pList.CopyTo(ppOut);
return S_Success;
}
/////////////////////////////// Portfolio Operations /////////////////////////////////
long unsigned int CAdminAPI::get_Porfolio(unsigned int portfolioId, IPortfolio** ppOut)
{
}
long unsigned int CAdminAPI::get_Porfolios(unsigned long ownerId, IPortfolioList** ppOut)
{
}
long unsigned int CAdminAPI::get_Positions(unsigned long ownerId, IPositions** ppOut)
{
Json::Value val;
auto ret = CObject<CPositions>::Create(get_Session(), val, ppOut);
return ret;
}
/********************* Private Methods ************************/
ErrorId CAdminAPI::SetUser(CSmartConnection &conn, Row const& row, IUser** ppOut)
{
try
{
ErrorId retCode = CObject<CUser>::Create(get_Session(), ppOut);
if (FAILED(retCode))
{
// LOGE(_logger, "can't create User Type");
return retCode;
}
(*ppOut)->set_Id(row["ID"]);
(*ppOut)->set_UserId(row["user_login"]);
(*ppOut)->add_Role((UserRole)(I32)row["user_role"]);
(*ppOut)->set_FirstName(row["user_firstname"]);
(*ppOut)->set_LastName(row["user_lastname"]);
(*ppOut)->set_Active(row["user_isactive"]);
(*ppOut)->set_RegistrationStage((REGSTAGES)(I32)row["user_regstage"]);
((CUser*)(*ppOut))->set_CurrentSessionId(row["user_sessionid"]);
auto q = conn->query();
q << "select a.* from addresses a, (select addr_id from user_addr where ";
q << "user_id = " << (UID)row["ID"] << " and is_current = 1 order by seton limit 1) b where a.address_id = b.addr_id";
StoreQueryResult result ;
if ((result = q.store()).size())
{
((CUser*)(*ppOut))->_addrId = row[0];
}
return retCode;
}
catch (std::exception const& ex)
{
// LOGE(_logger, "Error: " << ex.what());
return E_DBQueryException;
}
}
SE_CODE CAdminAPI::SyncUserSession(CSmartConnection &conn, UID userId, CSTR sessionId)
{
try
{
conn.BeginTransaction();
Query q = conn->query();
q << "update users set user_sessionid = " << quote << sessionId << ", user_updatedon = NOW() where ID = " << userId;
q.exec();
if (FAILED(this->RecordSessionActivity(conn, userId)))
{
throw se::seexception("Failed to record session activity. Rolling back.");
}
conn.CommitTransaction();
}
catch(const se::seexception& ex)
{
conn.RollbackTransaction();
BERR << ex.what();
return E_DBUpdateError;
}
catch(const mysqlpp::Exception& ex)
{
conn.RollbackTransaction();
BERR << ex.what();
return E_DBUpdateError;
}
catch (const std::exception& ex)
{
conn.RollbackTransaction();
BERR << ex.what();
return E_DBUpdateError;
}
}
ErrorId CAdminAPI::SetProduct(Row const& row, IProduct** ppOut)
{
if (!row) return E_NotFound;
ErrorId retCode = CObject<CProduct>::Create(get_Session(), ppOut);
if (FAILED(retCode))
{
return retCode;
}
(*ppOut)->set_Id(row["product_id"]);
(*ppOut)->set_Name(row["name"]);
(*ppOut)->set_PriceMonthlyRate(row["monthly_price"]);
(*ppOut)->set_PriceQuarterlyRate(row["quarterly_price"]);
(*ppOut)->set_PriceYearlyRate(row["yearly_price"]);
return retCode;
}
// Billing related
SE_CODE CAdminAPI::BeginAsLicensedUser(CSmartConnection& conn, UID userId, U16 paymentType, CSTR packages, R8 fee, UID* newId)
{
try
{
Query q = conn->query();
q << "insert into cust_licensesetup ";
q << "( userid, paymenttype, packagekeys, fees, startedon ) ";
q << "VALUES ";
q << "(" << userId << ", " << paymentType << ", " << quote << packages << ", " << fee << ", NOW())";
q.execute();
if (newId)
{
*newId = q.insert_id();
}
}
CATCHCLAUSEAUTO
}
SE_CODE CAdminAPI::EndAsLicensedUser(CSmartConnection& conn, UID userId)
{
try
{
Query q = conn->query();
q << "update cust_licensesetup set endedon = NOW() where userid = " << userId;
q.execute();
}
CATCHCLAUSEAUTO
}
SE_CODE CAdminAPI::RefundLicensedUser(CSmartConnection& conn, UID userId, R8 amount, CSTR notes, UID refId)
{
return BillLicensee(conn, userId, BILLINGTYPES::Refunds, amount, notes, refId);
}
SE_CODE CAdminAPI::BillLicensee(CSmartConnection& conn, UID userId, BILLINGTYPES billingType, R8 amount, CSTR notes, UID refId, TRANSACTIONTYPES transType)
{
// this table has only inserts. no deletes
// eg. if a fee is charged twice accidently and customer needs refund
// the duplicate entry remains there, but will capture its unique id and
// then create a new table for 'Debit-Refund' and refid set to the unique id.
if (!userId)
{
BERR << "User id not given.";
return E_InvalidArg;
}
if (!amount || amount <= 0)
{
BERR << "amount parameter must be a positive amount";
return E_InvalidArg;
}
if (!notes || !strlen(notes))
{
BERR << "notes parameter is empty";
return E_InvalidArg;
}
TRANSACTIONTYPES tt;
switch(billingType)
{
case BILLINGTYPES::SubscriptionFee:
tt = TRANSACTIONTYPES::Credit;
break;
case BILLINGTYPES::Refunds:
tt = TRANSACTIONTYPES::Debit;
if (!refId)
{
BERR << "refId parameter must be greater than zero.";
return E_InsufficientParameters;
}
break;
case BILLINGTYPES::OnceOnly:
tt = transType;
}
if (refId)
{
Query q = conn->query();
q << "select billingid from cust_billing where billingid = " << refId;
if (!q.store().size())
{
BERR << "refId provided is not found";
return E_IncorrectOperation;
}
}
try
{
Query q1 = conn->query();
q1 << "insert into cust_billing ";
q1 << "( userid, billingtype, transtype, transdate, amount, referid, notes ) ";
q1 << "VALUES (";
q1 << userId << ", ";
q1 << (U16)billingType << ", ";
q1 << quote << (char)transType << ", ";
q1 << "NOW(), ";
q1 << amount << ", ";
q1 << refId << ", ";
q1 << quote << notes ;
q1 << ")";
q1.execute();
}
CATCHCLAUSEAUTO
}
/////////////////////////// Help Related Methods ////////////////////////
RP<IHelpDocTree> CAdminAPI::get_HelpDocTree()
{
SP<IHelpDocTree> docTree ;
if (FAILED(CObject<CHelpDocTree>::Create(get_Session(), &docTree)))
return nullptr;
return docTree;
}
}
} | [
"sajiantony@hotmail.com"
] | sajiantony@hotmail.com |
980fc2cfc720232761d26acd52881bd2bc516aa1 | 935a397d01fba9e332f63c71d140de1a1bffe277 | /kmp.cpp | 46051ee2ad7e9cd54eea9eda63d8cbbd6bc76a4f | [] | no_license | dreamzen/programming | c043b54a0a42a3fbf9cdbc804a4aa08f1dfa3dc1 | a58f4449e4dfc6823ba0a2d3aa7793dec56358d2 | refs/heads/master | 2021-01-25T08:42:58.721002 | 2014-06-21T15:43:48 | 2014-06-21T15:43:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,739 | cpp | #include <iostream>
#include <vector>
using namespace std;
class Solution
{
private:
vector<int> p;
public:
char *strStr(char *haystack, char *needle)
{
if(haystack == NULL || needle == NULL)
{
return NULL;
}
int len1 = strlen(haystack);
int len2 = strlen(needle);
if(len2 == 0)
{
return haystack;
}
p.resize(len2);
getNextVal(needle);
int i = 0;
int j = -1;
while(i < len1 && j < len2)
{
if(haystack[i] == needle[j + 1])
{
i++;
j++;
if(j == len2 - 1)
{
return &haystack[i - len2];
}
}
else
{
if(j == -1)
{
i++;
}
else
{
j = p[j];
}
}
}
return NULL;
}
void getNextVal(char *str)
{
int len = strlen(str);
int j = 1;
int k = -1;
p[0] = -1;
while(j < len)
{
if(str[j] == str[k + 1])
{
p[j] = k + 1;
j++;
k++;
}
else
{
if(k == -1)
{
p[j] = -1;
j++;
}
else
{
k = p[k];
}
}
}
}
};
int main()
{
char A[1024];
char B[1024];
cin >> A >> B;
cout << A << B << endl;
Solution s;
cout << s.strStr(A,B) << endl;
return 0;
}
| [
"dreamzen@163.com"
] | dreamzen@163.com |
0ef886ea61fd7358a8283519322b4714730d920d | 8d4baaf91cee3ea8ae16ab3359ab89b0557b0a6c | /depenseGroupe.cpp | 5265d0de8a245c4aaa3e3d2c2fcc9773180986c1 | [] | no_license | Karl-Nels/H18-TP2 | 1599f2b7963786325dca9009597c760bfbb8380a | 3042110f650e003904740b955b54be7f7d451807 | refs/heads/master | 2020-04-01T08:18:56.293880 | 2018-10-22T01:49:13 | 2018-10-22T01:49:13 | 153,025,703 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,030 | cpp | #include "depenseGroupe.h"
//constructeurs
DepenseGroupe::DepenseGroupe(const string& nom, double montant,
const string& lieu): Depense::Depense(nom,montant,lieu,groupe),nombreParticipants_(0)
{
}
DepenseGroupe::DepenseGroupe(const DepenseGroupe& depense): Depense(depense),nombreParticipants_(0) {}
// accesseurs
unsigned int DepenseGroupe::getNombreParticipants() const {
return nombreParticipants_;
}
double DepenseGroupe::getMontantPersonnel() const {
if (nombreParticipants_ == 0)
return 0.0;
else
return getMontant() / getNombreParticipants();
}
//modificateurs
void DepenseGroupe::setNombreParticipants(unsigned int nombre) {
nombreParticipants_ = nombre;
}
//Surcharge de l'operateur << pour affichage
ostream& operator<<(ostream& os, const DepenseGroupe& depense) {
os << "\t\t Depense de groupe : "
<< "\t" << static_cast<Depense>(depense)
<< " fait par: " << depense.getNombreParticipants() << " soit: "
<< depense.getMontantPersonnel() << " par personne." << endl;
return os;
}
| [
"xhworking@gmail.com"
] | xhworking@gmail.com |
30e193897f4bbf5f424d10cd0eb690a21ffd323b | 1f63dde39fcc5f8be29f2acb947c41f1b6f1683e | /Boss2D/addon/webrtc-jumpingyang001_for_boss/modules/desktop_capture/win/screen_capture_utils.cc | 2effad745bcc5a48d376003d1159f26dea51b522 | [
"BSD-3-Clause",
"LicenseRef-scancode-google-patent-license-webm",
"LicenseRef-scancode-google-patent-license-webrtc",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | koobonil/Boss2D | 09ca948823e0df5a5a53b64a10033c4f3665483a | e5eb355b57228a701495f2660f137bd05628c202 | refs/heads/master | 2022-10-20T09:02:51.341143 | 2019-07-18T02:13:44 | 2019-07-18T02:13:44 | 105,999,368 | 7 | 2 | MIT | 2022-10-04T23:31:12 | 2017-10-06T11:57:07 | C++ | UTF-8 | C++ | false | false | 3,619 | cc | /*
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/win/screen_capture_utils.h"
#include <windows.h>
#include <string>
#include <vector>
#include BOSS_WEBRTC_U_modules__desktop_capture__desktop_capturer_h //original-code:"modules/desktop_capture/desktop_capturer.h"
#include BOSS_WEBRTC_U_rtc_base__checks_h //original-code:"rtc_base/checks.h"
#include BOSS_WEBRTC_U_rtc_base__stringutils_h //original-code:"rtc_base/stringutils.h"
#include BOSS_WEBRTC_U_rtc_base__win32_h //original-code:"rtc_base/win32.h"
namespace webrtc {
bool GetScreenList(DesktopCapturer::SourceList* screens,
std::vector<std::string>* device_names /* = nullptr */) {
RTC_DCHECK_EQ(screens->size(), 0U);
if (device_names) {
RTC_DCHECK_EQ(device_names->size(), 0U);
}
BOOL enum_result = TRUE;
for (int device_index = 0;; ++device_index) {
DISPLAY_DEVICE device;
device.cb = sizeof(device);
enum_result = EnumDisplayDevices(NULL, device_index, &device, 0);
// |enum_result| is 0 if we have enumerated all devices.
if (!enum_result)
break;
// We only care about active displays.
if (!(device.StateFlags & DISPLAY_DEVICE_ACTIVE))
continue;
screens->push_back({device_index, std::string()});
if (device_names) {
device_names->push_back(rtc::ToUtf8(device.DeviceName));
}
}
return true;
}
bool IsScreenValid(DesktopCapturer::SourceId screen, std::wstring* device_key) {
if (screen == kFullDesktopScreenId) {
*device_key = L"";
return true;
}
DISPLAY_DEVICE device;
device.cb = sizeof(device);
BOOL enum_result = EnumDisplayDevices(NULL, screen, &device, 0);
if (enum_result)
*device_key = device.DeviceKey;
return !!enum_result;
}
DesktopRect GetFullscreenRect() {
return DesktopRect::MakeXYWH(GetSystemMetrics(SM_XVIRTUALSCREEN),
GetSystemMetrics(SM_YVIRTUALSCREEN),
GetSystemMetrics(SM_CXVIRTUALSCREEN),
GetSystemMetrics(SM_CYVIRTUALSCREEN));
}
DesktopRect GetScreenRect(DesktopCapturer::SourceId screen,
const std::wstring& device_key) {
if (screen == kFullDesktopScreenId) {
return GetFullscreenRect();
}
DISPLAY_DEVICE device;
device.cb = sizeof(device);
BOOL result = EnumDisplayDevices(NULL, screen, &device, 0);
if (!result)
return DesktopRect();
// Verifies the device index still maps to the same display device, to make
// sure we are capturing the same device when devices are added or removed.
// DeviceKey is documented as reserved, but it actually contains the registry
// key for the device and is unique for each monitor, while DeviceID is not.
if (device_key != device.DeviceKey)
return DesktopRect();
DEVMODE device_mode;
device_mode.dmSize = sizeof(device_mode);
device_mode.dmDriverExtra = 0;
result = EnumDisplaySettingsEx(device.DeviceName, ENUM_CURRENT_SETTINGS,
&device_mode, 0);
if (!result)
return DesktopRect();
return DesktopRect::MakeXYWH(
device_mode.dmPosition.x, device_mode.dmPosition.y,
device_mode.dmPelsWidth, device_mode.dmPelsHeight);
}
} // namespace webrtc
| [
"slacealic@nate.com"
] | slacealic@nate.com |
5522d8e928c8055ad435a73d46887e5b89773983 | 6cb8560e1da833eeeba77cc05f22147d8ad8ad69 | /hello_world.cpp | e31111d477b1fd783471db374eef719dc539f89d | [
"MIT"
] | permissive | tugberkugurlu/cpp-samples | 8f6c51ac3aa83fe995eacf0f84cfef26fe3cc2cc | 14fd24af43b76848cbf71764fdae1da2a938dfdd | refs/heads/master | 2021-01-20T20:57:32.014863 | 2015-07-07T15:26:59 | 2015-07-07T15:26:59 | 38,696,173 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 102 | cpp | #include <iostream>
using namespace std;
int main() {
cout << "Hello World!\n";
return 0;
}
| [
"tugberk@outlook.com"
] | tugberk@outlook.com |
9a7d8df9234b46c619605fe60471f0cd78c62e1c | 08cbeb3db9317e892dc3ec683e4fbf9c3b0e86ac | /agc/041/a.cpp | 5881d19fcb3bd94bd24b52759150367a2ce99768 | [] | no_license | wonda-tea-coffee/atcoder | 0b7a8907d6b859e7b65bbf2829fb861e080e671a | 5282f9915da773df3fd27c8570690d912b0bbd90 | refs/heads/master | 2020-12-21T09:57:41.187968 | 2020-04-19T12:33:48 | 2020-05-02T14:49:48 | 236,391,204 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,705 | cpp | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>
#define fix(n) cout<<fixed<<setprecision(n)
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sort(a) sort((a).begin(), (a).end())
#define uniq(a) sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a) reverse((a).begin(), (a).end())
#define ctos(c) string(1, (c))
#define out(d) cout << (d)
#define outl(d) std::cout<<(d)<<"\n"
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define ceil(x, y) ((x + y - 1) / (y))
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007; // 10^9 + 7
void solve() {
ll n, a, b; cin >> n >> a >> b;
if ((b - a) % 2 == 0) outl((b - a) / 2);
else outl(min((a + b - 1) / 2, n - (a + b - 1) / 2));
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
srand((unsigned)time(NULL));
fix(12);
solve();
}
| [
"rikita.ishikawa@crowdworks.co.jp"
] | rikita.ishikawa@crowdworks.co.jp |
763a9f5fe4cf941b0bef6665c7846f89534e9d2c | adce6ec37a3bd41b6b26246615bceace9580a31b | /Binary_array_sorting.cpp | af6d630df3938e855327d0e7991ee3bf412b8c44 | [] | no_license | shivamkasat/Placement_Preparation_GFG | 8b2b2ad79ef2552bd5d4976b998239dd2cfb72eb | e7097ab03b2d86508476a831858b22840c30c861 | refs/heads/master | 2020-09-27T10:47:35.342988 | 2020-08-15T13:32:49 | 2020-08-15T13:32:49 | 226,497,961 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 612 | cpp | #include <bits/stdc++.h>
using namespace std;
void swap(int &n1, int &n2)
{
int temp;
temp = n1;
n1 = n2;
n2 = temp;
}
int main()
{
int test;
cin>>test;
while (test > 0) {
int n;
cin>>n;
vector < int > nums(n, 0);
for (int i = 0; i < nums.size(); i++) {
cin>>nums[i];
}
int i = 0;
int j = nums.size() - 1;
while (i < j) {
while (nums[i] != 1 && i < j) {
i++;
}
while (nums[j] != 0 && j > i) {
j--;
}
swap(nums[i], nums[j]);
i++;
j--;
}
for (int i = 0; i < nums.size(); i++) {
printf("%d ", nums[i]);
}
test--;
}
return 0;
}
| [
"shivamkasatt@gmail.com"
] | shivamkasatt@gmail.com |
a716aae1d7bbf003a6c688531c403f57ae49a5b1 | 0bae86219e690b4690633c309509eee379793abb | /1095.cpp | eab02ca2a34665427fb1fabca83380d2aa26194a | [] | no_license | toffanetto/URI_toffanetto | 959cb3074e4f3ac7f2745177f05af26d29d525c5 | 1d741f971ffb2395f74f041e7905fc70248963e5 | refs/heads/master | 2022-12-06T01:08:40.947325 | 2020-08-30T18:48:02 | 2020-08-30T18:48:02 | 291,491,068 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 148 | cpp | #include <iostream>
using namespace std;
int main(){
int h=1,j=60;
for(int i=0;i<=12;i++){
cout << "I=" << h << " J=" << j << endl;
h+=3;
j-=5;
}
}
| [
"gabrieltoffanetto@gmail.com"
] | gabrieltoffanetto@gmail.com |
09ed3fac8b05fc87183e2529803e4f4a5db4ea82 | 83bacfbdb7ad17cbc2fc897b3460de1a6726a3b1 | /v8_4_8/src/base/platform/platform-win32.cc | 1f4a2a9f35492e34a06ee5fa24a6e7b83f29020b | [
"Apache-2.0"
] | permissive | cool2528/miniblink49 | d909e39012f2c5d8ab658dc2a8b314ad0050d8ea | 7f646289d8074f098cf1244adc87b95e34ab87a8 | refs/heads/master | 2020-06-05T03:18:43.211372 | 2019-06-01T08:57:37 | 2019-06-01T08:59:56 | 192,294,645 | 2 | 0 | Apache-2.0 | 2019-06-17T07:16:28 | 2019-06-17T07:16:27 | null | UTF-8 | C++ | false | false | 46,571 | cc | // Copyright 2012 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Platform-specific code for Win32.
// Secure API functions are not available using MinGW with msvcrt.dll
// on Windows XP. Make sure MINGW_HAS_SECURE_API is not defined to
// disable definition of secure API functions in standard headers that
// would conflict with our own implementation.
#ifdef __MINGW32__
#include <_mingw.h>
#ifdef MINGW_HAS_SECURE_API
#undef MINGW_HAS_SECURE_API
#endif // MINGW_HAS_SECURE_API
#endif // __MINGW32__
#include <limits>
#include "src/base/win32-headers.h"
#include "src/base/bits.h"
#include "src/base/lazy-instance.h"
#include "src/base/macros.h"
#include "src/base/platform/platform.h"
#include "src/base/platform/time.h"
#include "src/base/utils/random-number-generator.h"
// Extra functions for MinGW. Most of these are the _s functions which are in
// the Microsoft Visual Studio C++ CRT.
#if USING_VC6RT == 1 //#ifdef __MINGW32__
#ifndef __MINGW64_VERSION_MAJOR
#define _TRUNCATE 0
#define STRUNCATE 80
//inline void MemoryBarrier() {
// int barrier = 0;
// __asm__ __volatile__("xchgl %%eax,%0 ":"=r" (barrier));
//}
#endif // __MINGW64_VERSION_MAJOR
int localtime_s(tm* out_tm, const time_t* time) {
tm* posix_local_time_struct = localtime(time); // NOLINT
if (posix_local_time_struct == NULL) return 1;
*out_tm = *posix_local_time_struct;
return 0;
}
int fopen_s(FILE** pFile, const char* filename, const char* mode) {
*pFile = fopen(filename, mode);
return *pFile != NULL ? 0 : 1;
}
int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count,
const char* format, va_list argptr) {
DCHECK(count == _TRUNCATE);
return _vsnprintf(buffer, sizeOfBuffer, format, argptr);
}
int strncpy_s(char* dest, size_t dest_size, const char* source, size_t count) {
CHECK(source != NULL);
CHECK(dest != NULL);
CHECK_GT(dest_size, 0);
if (count == _TRUNCATE) {
while (dest_size > 0 && *source != 0) {
*(dest++) = *(source++);
--dest_size;
}
if (dest_size == 0) {
*(dest - 1) = 0;
return STRUNCATE;
}
} else {
while (dest_size > 0 && count > 0 && *source != 0) {
*(dest++) = *(source++);
--dest_size;
--count;
}
}
CHECK_GT(dest_size, 0);
*dest = 0;
return 0;
}
#endif // __MINGW32__
namespace v8 {
namespace base {
namespace {
bool g_hard_abort = false;
} // namespace
class TimezoneCache {
public:
TimezoneCache() : initialized_(false) { }
void Clear() {
initialized_ = false;
}
// Initialize timezone information. The timezone information is obtained from
// windows. If we cannot get the timezone information we fall back to CET.
void InitializeIfNeeded() {
// Just return if timezone information has already been initialized.
if (initialized_) return;
// Initialize POSIX time zone data.
_tzset();
// Obtain timezone information from operating system.
memset(&tzinfo_, 0, sizeof(tzinfo_));
if (GetTimeZoneInformation(&tzinfo_) == TIME_ZONE_ID_INVALID) {
// If we cannot get timezone information we fall back to CET.
tzinfo_.Bias = -60;
tzinfo_.StandardDate.wMonth = 10;
tzinfo_.StandardDate.wDay = 5;
tzinfo_.StandardDate.wHour = 3;
tzinfo_.StandardBias = 0;
tzinfo_.DaylightDate.wMonth = 3;
tzinfo_.DaylightDate.wDay = 5;
tzinfo_.DaylightDate.wHour = 2;
tzinfo_.DaylightBias = -60;
}
// Make standard and DST timezone names.
WideCharToMultiByte(CP_UTF8, 0, tzinfo_.StandardName, -1,
std_tz_name_, kTzNameSize, NULL, NULL);
std_tz_name_[kTzNameSize - 1] = '\0';
WideCharToMultiByte(CP_UTF8, 0, tzinfo_.DaylightName, -1,
dst_tz_name_, kTzNameSize, NULL, NULL);
dst_tz_name_[kTzNameSize - 1] = '\0';
// If OS returned empty string or resource id (like "@tzres.dll,-211")
// simply guess the name from the UTC bias of the timezone.
// To properly resolve the resource identifier requires a library load,
// which is not possible in a sandbox.
if (std_tz_name_[0] == '\0' || std_tz_name_[0] == '@') {
OS::SNPrintF(std_tz_name_, kTzNameSize - 1,
"%s Standard Time",
GuessTimezoneNameFromBias(tzinfo_.Bias));
}
if (dst_tz_name_[0] == '\0' || dst_tz_name_[0] == '@') {
OS::SNPrintF(dst_tz_name_, kTzNameSize - 1,
"%s Daylight Time",
GuessTimezoneNameFromBias(tzinfo_.Bias));
}
// Timezone information initialized.
initialized_ = true;
}
// Guess the name of the timezone from the bias.
// The guess is very biased towards the northern hemisphere.
const char* GuessTimezoneNameFromBias(int bias) {
static const int kHour = 60;
switch (-bias) {
case -9*kHour: return "Alaska";
case -8*kHour: return "Pacific";
case -7*kHour: return "Mountain";
case -6*kHour: return "Central";
case -5*kHour: return "Eastern";
case -4*kHour: return "Atlantic";
case 0*kHour: return "GMT";
case +1*kHour: return "Central Europe";
case +2*kHour: return "Eastern Europe";
case +3*kHour: return "Russia";
case +5*kHour + 30: return "India";
case +8*kHour: return "China";
case +9*kHour: return "Japan";
case +12*kHour: return "New Zealand";
default: return "Local";
}
}
private:
static const int kTzNameSize = 128;
bool initialized_;
char std_tz_name_[kTzNameSize];
char dst_tz_name_[kTzNameSize];
TIME_ZONE_INFORMATION tzinfo_;
friend class Win32Time;
};
// ----------------------------------------------------------------------------
// The Time class represents time on win32. A timestamp is represented as
// a 64-bit integer in 100 nanoseconds since January 1, 1601 (UTC). JavaScript
// timestamps are represented as a doubles in milliseconds since 00:00:00 UTC,
// January 1, 1970.
class Win32Time {
public:
// Constructors.
Win32Time();
explicit Win32Time(double jstime);
Win32Time(int year, int mon, int day, int hour, int min, int sec);
// Convert timestamp to JavaScript representation.
double ToJSTime();
// Set timestamp to current time.
void SetToCurrentTime();
// Returns the local timezone offset in milliseconds east of UTC. This is
// the number of milliseconds you must add to UTC to get local time, i.e.
// LocalOffset(CET) = 3600000 and LocalOffset(PST) = -28800000. This
// routine also takes into account whether daylight saving is effect
// at the time.
int64_t LocalOffset(TimezoneCache* cache);
// Returns the daylight savings time offset for the time in milliseconds.
int64_t DaylightSavingsOffset(TimezoneCache* cache);
// Returns a string identifying the current timezone for the
// timestamp taking into account daylight saving.
char* LocalTimezone(TimezoneCache* cache);
private:
// Constants for time conversion.
static const int64_t kTimeEpoc = 116444736000000000LL;
static const int64_t kTimeScaler = 10000;
static const int64_t kMsPerMinute = 60000;
// Constants for timezone information.
static const bool kShortTzNames = false;
// Return whether or not daylight savings time is in effect at this time.
bool InDST(TimezoneCache* cache);
// Accessor for FILETIME representation.
FILETIME& ft() { return time_.ft_; }
// Accessor for integer representation.
int64_t& t() { return time_.t_; }
// Although win32 uses 64-bit integers for representing timestamps,
// these are packed into a FILETIME structure. The FILETIME structure
// is just a struct representing a 64-bit integer. The TimeStamp union
// allows access to both a FILETIME and an integer representation of
// the timestamp.
union TimeStamp {
FILETIME ft_;
int64_t t_;
};
TimeStamp time_;
};
// Initialize timestamp to start of epoc.
Win32Time::Win32Time() {
t() = 0;
}
// Initialize timestamp from a JavaScript timestamp.
Win32Time::Win32Time(double jstime) {
t() = static_cast<int64_t>(jstime) * kTimeScaler + kTimeEpoc;
}
// Initialize timestamp from date/time components.
Win32Time::Win32Time(int year, int mon, int day, int hour, int min, int sec) {
SYSTEMTIME st;
st.wYear = year;
st.wMonth = mon;
st.wDay = day;
st.wHour = hour;
st.wMinute = min;
st.wSecond = sec;
st.wMilliseconds = 0;
SystemTimeToFileTime(&st, &ft());
}
// Convert timestamp to JavaScript timestamp.
double Win32Time::ToJSTime() {
return static_cast<double>((t() - kTimeEpoc) / kTimeScaler);
}
// Set timestamp to current time.
void Win32Time::SetToCurrentTime() {
// The default GetSystemTimeAsFileTime has a ~15.5ms resolution.
// Because we're fast, we like fast timers which have at least a
// 1ms resolution.
//
// timeGetTime() provides 1ms granularity when combined with
// timeBeginPeriod(). If the host application for v8 wants fast
// timers, it can use timeBeginPeriod to increase the resolution.
//
// Using timeGetTime() has a drawback because it is a 32bit value
// and hence rolls-over every ~49days.
//
// To use the clock, we use GetSystemTimeAsFileTime as our base;
// and then use timeGetTime to extrapolate current time from the
// start time. To deal with rollovers, we resync the clock
// any time when more than kMaxClockElapsedTime has passed or
// whenever timeGetTime creates a rollover.
static bool initialized = false;
static TimeStamp init_time;
static DWORD init_ticks;
static const int64_t kHundredNanosecondsPerSecond = 10000000;
static const int64_t kMaxClockElapsedTime =
60*kHundredNanosecondsPerSecond; // 1 minute
// If we are uninitialized, we need to resync the clock.
bool needs_resync = !initialized;
// Get the current time.
TimeStamp time_now;
GetSystemTimeAsFileTime(&time_now.ft_);
DWORD ticks_now = timeGetTime();
// Check if we need to resync due to clock rollover.
needs_resync |= ticks_now < init_ticks;
// Check if we need to resync due to elapsed time.
needs_resync |= (time_now.t_ - init_time.t_) > kMaxClockElapsedTime;
// Check if we need to resync due to backwards time change.
needs_resync |= time_now.t_ < init_time.t_;
// Resync the clock if necessary.
if (needs_resync) {
GetSystemTimeAsFileTime(&init_time.ft_);
init_ticks = ticks_now = timeGetTime();
initialized = true;
}
// Finally, compute the actual time. Why is this so hard.
DWORD elapsed = ticks_now - init_ticks;
this->time_.t_ = init_time.t_ + (static_cast<int64_t>(elapsed) * 10000);
}
// Return the local timezone offset in milliseconds east of UTC. This
// takes into account whether daylight saving is in effect at the time.
// Only times in the 32-bit Unix range may be passed to this function.
// Also, adding the time-zone offset to the input must not overflow.
// The function EquivalentTime() in date.js guarantees this.
int64_t Win32Time::LocalOffset(TimezoneCache* cache) {
cache->InitializeIfNeeded();
Win32Time rounded_to_second(*this);
rounded_to_second.t() =
rounded_to_second.t() / 1000 / kTimeScaler * 1000 * kTimeScaler;
// Convert to local time using POSIX localtime function.
// Windows XP Service Pack 3 made SystemTimeToTzSpecificLocalTime()
// very slow. Other browsers use localtime().
// Convert from JavaScript milliseconds past 1/1/1970 0:00:00 to
// POSIX seconds past 1/1/1970 0:00:00.
double unchecked_posix_time = rounded_to_second.ToJSTime() / 1000;
if (unchecked_posix_time > INT_MAX || unchecked_posix_time < 0) {
return 0;
}
// Because _USE_32BIT_TIME_T is defined, time_t is a 32-bit int.
time_t posix_time = static_cast<time_t>(unchecked_posix_time);
// Convert to local time, as struct with fields for day, hour, year, etc.
tm posix_local_time_struct;
if (localtime_s(&posix_local_time_struct, &posix_time)) return 0;
if (posix_local_time_struct.tm_isdst > 0) {
return (cache->tzinfo_.Bias + cache->tzinfo_.DaylightBias) * -kMsPerMinute;
} else if (posix_local_time_struct.tm_isdst == 0) {
return (cache->tzinfo_.Bias + cache->tzinfo_.StandardBias) * -kMsPerMinute;
} else {
return cache->tzinfo_.Bias * -kMsPerMinute;
}
}
// Return whether or not daylight savings time is in effect at this time.
bool Win32Time::InDST(TimezoneCache* cache) {
cache->InitializeIfNeeded();
// Determine if DST is in effect at the specified time.
bool in_dst = false;
if (cache->tzinfo_.StandardDate.wMonth != 0 ||
cache->tzinfo_.DaylightDate.wMonth != 0) {
// Get the local timezone offset for the timestamp in milliseconds.
int64_t offset = LocalOffset(cache);
// Compute the offset for DST. The bias parameters in the timezone info
// are specified in minutes. These must be converted to milliseconds.
int64_t dstofs =
-(cache->tzinfo_.Bias + cache->tzinfo_.DaylightBias) * kMsPerMinute;
// If the local time offset equals the timezone bias plus the daylight
// bias then DST is in effect.
in_dst = offset == dstofs;
}
return in_dst;
}
// Return the daylight savings time offset for this time.
int64_t Win32Time::DaylightSavingsOffset(TimezoneCache* cache) {
return InDST(cache) ? 60 * kMsPerMinute : 0;
}
// Returns a string identifying the current timezone for the
// timestamp taking into account daylight saving.
char* Win32Time::LocalTimezone(TimezoneCache* cache) {
// Return the standard or DST time zone name based on whether daylight
// saving is in effect at the given time.
return InDST(cache) ? cache->dst_tz_name_ : cache->std_tz_name_;
}
// Returns the accumulated user time for thread.
int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) {
FILETIME dummy;
uint64_t usertime;
// Get the amount of time that the thread has executed in user mode.
if (!GetThreadTimes(GetCurrentThread(), &dummy, &dummy, &dummy,
reinterpret_cast<FILETIME*>(&usertime))) return -1;
// Adjust the resolution to micro-seconds.
usertime /= 10;
// Convert to seconds and microseconds
*secs = static_cast<uint32_t>(usertime / 1000000);
*usecs = static_cast<uint32_t>(usertime % 1000000);
return 0;
}
// Returns current time as the number of milliseconds since
// 00:00:00 UTC, January 1, 1970.
double OS::TimeCurrentMillis() {
return Time::Now().ToJsTime();
}
TimezoneCache* OS::CreateTimezoneCache() {
return new TimezoneCache();
}
void OS::DisposeTimezoneCache(TimezoneCache* cache) {
delete cache;
}
void OS::ClearTimezoneCache(TimezoneCache* cache) {
cache->Clear();
}
// Returns a string identifying the current timezone taking into
// account daylight saving.
const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
return Win32Time(time).LocalTimezone(cache);
}
// Returns the local time offset in milliseconds east of UTC without
// taking daylight savings time into account.
double OS::LocalTimeOffset(TimezoneCache* cache) {
// Use current time, rounded to the millisecond.
Win32Time t(TimeCurrentMillis());
// Time::LocalOffset inlcudes any daylight savings offset, so subtract it.
return static_cast<double>(t.LocalOffset(cache) -
t.DaylightSavingsOffset(cache));
}
// Returns the daylight savings offset in milliseconds for the given
// time.
double OS::DaylightSavingsOffset(double time, TimezoneCache* cache) {
int64_t offset = Win32Time(time).DaylightSavingsOffset(cache);
return static_cast<double>(offset);
}
int OS::GetLastError() {
return ::GetLastError();
}
int OS::GetCurrentProcessId() {
return static_cast<int>(::GetCurrentProcessId());
}
int OS::GetCurrentThreadId() {
return static_cast<int>(::GetCurrentThreadId());
}
// ----------------------------------------------------------------------------
// Win32 console output.
//
// If a Win32 application is linked as a console application it has a normal
// standard output and standard error. In this case normal printf works fine
// for output. However, if the application is linked as a GUI application,
// the process doesn't have a console, and therefore (debugging) output is lost.
// This is the case if we are embedded in a windows program (like a browser).
// In order to be able to get debug output in this case the the debugging
// facility using OutputDebugString. This output goes to the active debugger
// for the process (if any). Else the output can be monitored using DBMON.EXE.
enum OutputMode {
UNKNOWN, // Output method has not yet been determined.
CONSOLE, // Output is written to stdout.
ODS // Output is written to debug facility.
};
static OutputMode output_mode = UNKNOWN; // Current output mode.
// Determine if the process has a console for output.
static bool HasConsole() {
// Only check the first time. Eventual race conditions are not a problem,
// because all threads will eventually determine the same mode.
if (output_mode == UNKNOWN) {
// We cannot just check that the standard output is attached to a console
// because this would fail if output is redirected to a file. Therefore we
// say that a process does not have an output console if either the
// standard output handle is invalid or its file type is unknown.
if (GetStdHandle(STD_OUTPUT_HANDLE) != INVALID_HANDLE_VALUE &&
GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) != FILE_TYPE_UNKNOWN)
output_mode = CONSOLE;
else
output_mode = ODS;
}
return output_mode == CONSOLE;
}
static void VPrintHelper(FILE* stream, const char* format, va_list args) {
if ((stream == stdout || stream == stderr) && !HasConsole()) {
// It is important to use safe print here in order to avoid
// overflowing the buffer. We might truncate the output, but this
// does not crash.
char buffer[4096];
OS::VSNPrintF(buffer, sizeof(buffer), format, args);
OutputDebugStringA(buffer);
} else {
vfprintf(stream, format, args);
}
}
FILE* OS::FOpen(const char* path, const char* mode) {
FILE* result;
if (fopen_s(&result, path, mode) == 0) {
return result;
} else {
return NULL;
}
}
bool OS::Remove(const char* path) {
return (DeleteFileA(path) != 0);
}
bool OS::isDirectorySeparator(const char ch) {
return ch == '/' || ch == '\\';
}
FILE* OS::OpenTemporaryFile() {
// tmpfile_s tries to use the root dir, don't use it.
char tempPathBuffer[MAX_PATH];
DWORD path_result = 0;
path_result = GetTempPathA(MAX_PATH, tempPathBuffer);
if (path_result > MAX_PATH || path_result == 0) return NULL;
UINT name_result = 0;
char tempNameBuffer[MAX_PATH];
name_result = GetTempFileNameA(tempPathBuffer, "", 0, tempNameBuffer);
if (name_result == 0) return NULL;
FILE* result = FOpen(tempNameBuffer, "w+"); // Same mode as tmpfile uses.
if (result != NULL) {
Remove(tempNameBuffer); // Delete on close.
}
return result;
}
// Open log file in binary mode to avoid /n -> /r/n conversion.
const char* const OS::LogFileOpenMode = "wb";
// Print (debug) message to console.
void OS::Print(const char* format, ...) {
va_list args;
va_start(args, format);
VPrint(format, args);
va_end(args);
}
void OS::VPrint(const char* format, va_list args) {
VPrintHelper(stdout, format, args);
}
void OS::FPrint(FILE* out, const char* format, ...) {
va_list args;
va_start(args, format);
VFPrint(out, format, args);
va_end(args);
}
void OS::VFPrint(FILE* out, const char* format, va_list args) {
VPrintHelper(out, format, args);
}
// Print error message to console.
void OS::PrintError(const char* format, ...) {
va_list args;
va_start(args, format);
VPrintError(format, args);
va_end(args);
}
void OS::VPrintError(const char* format, va_list args) {
VPrintHelper(stderr, format, args);
}
int OS::SNPrintF(char* str, int length, const char* format, ...) {
va_list args;
va_start(args, format);
int result = VSNPrintF(str, length, format, args);
va_end(args);
return result;
}
int OS::VSNPrintF(char* str, int length, const char* format, va_list args) {
int n = _vsnprintf_s(str, length, _TRUNCATE, format, args);
// Make sure to zero-terminate the string if the output was
// truncated or if there was an error.
if (n < 0 || n >= length) {
if (length > 0)
str[length - 1] = '\0';
return -1;
} else {
return n;
}
}
char* OS::StrChr(char* str, int c) {
return const_cast<char*>(strchr(str, c));
}
void OS::StrNCpy(char* dest, int length, const char* src, size_t n) {
// Use _TRUNCATE or strncpy_s crashes (by design) if buffer is too small.
size_t buffer_size = static_cast<size_t>(length);
if (n + 1 > buffer_size) // count for trailing '\0'
n = _TRUNCATE;
int result = strncpy_s(dest, length, src, n);
USE(result);
DCHECK(result == 0 || (n == _TRUNCATE && result == STRUNCATE));
}
#undef _TRUNCATE
#undef STRUNCATE
// Get the system's page size used by VirtualAlloc() or the next power
// of two. The reason for always returning a power of two is that the
// rounding up in OS::Allocate expects that.
static size_t GetPageSize() {
static size_t page_size = 0;
if (page_size == 0) {
SYSTEM_INFO info;
GetSystemInfo(&info);
page_size = base::bits::RoundUpToPowerOfTwo32(info.dwPageSize);
}
return page_size;
}
// The allocation alignment is the guaranteed alignment for
// VirtualAlloc'ed blocks of memory.
size_t OS::AllocateAlignment() {
static size_t allocate_alignment = 0;
if (allocate_alignment == 0) {
SYSTEM_INFO info;
GetSystemInfo(&info);
allocate_alignment = info.dwAllocationGranularity;
}
return allocate_alignment;
}
static LazyInstance<RandomNumberGenerator>::type
platform_random_number_generator = LAZY_INSTANCE_INITIALIZER;
void OS::Initialize(int64_t random_seed, bool hard_abort,
const char* const gc_fake_mmap) {
if (random_seed) {
platform_random_number_generator.Pointer()->SetSeed(random_seed);
}
g_hard_abort = hard_abort;
}
void* OS::GetRandomMmapAddr() {
// The address range used to randomize RWX allocations in OS::Allocate
// Try not to map pages into the default range that windows loads DLLs
// Use a multiple of 64k to prevent committing unused memory.
// Note: This does not guarantee RWX regions will be within the
// range kAllocationRandomAddressMin to kAllocationRandomAddressMax
#ifdef V8_HOST_ARCH_64_BIT
static const uintptr_t kAllocationRandomAddressMin = 0x0000000080000000;
static const uintptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000;
#else
static const uintptr_t kAllocationRandomAddressMin = 0x04000000;
static const uintptr_t kAllocationRandomAddressMax = 0x3FFF0000;
#endif
uintptr_t address;
platform_random_number_generator.Pointer()->NextBytes(&address,
sizeof(address));
address <<= kPageSizeBits;
address += kAllocationRandomAddressMin;
address &= kAllocationRandomAddressMax;
return reinterpret_cast<void *>(address);
}
static void* RandomizedVirtualAlloc(size_t size, int action, int protection) {
LPVOID base = NULL;
static BOOL use_aslr = -1;
#ifdef V8_HOST_ARCH_32_BIT
// Don't bother randomizing on 32-bit hosts, because they lack the room and
// don't have viable ASLR anyway.
if (use_aslr == -1 && !IsWow64Process(GetCurrentProcess(), &use_aslr))
use_aslr = FALSE;
#else
use_aslr = TRUE;
#endif
if (use_aslr &&
(protection == PAGE_EXECUTE_READWRITE || protection == PAGE_NOACCESS)) {
// For executable pages try and randomize the allocation address
for (size_t attempts = 0; base == NULL && attempts < 3; ++attempts) {
base = VirtualAlloc(OS::GetRandomMmapAddr(), size, action, protection);
}
}
// After three attempts give up and let the OS find an address to use.
if (base == NULL) base = VirtualAlloc(NULL, size, action, protection);
return base;
}
void* OS::Allocate(const size_t requested,
size_t* allocated,
bool is_executable) {
// VirtualAlloc rounds allocated size to page size automatically.
size_t msize = RoundUp(requested, static_cast<int>(GetPageSize()));
// Windows XP SP2 allows Data Excution Prevention (DEP).
int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
LPVOID mbase = RandomizedVirtualAlloc(msize,
MEM_COMMIT | MEM_RESERVE,
prot);
if (mbase == NULL) return NULL;
DCHECK((reinterpret_cast<uintptr_t>(mbase) % OS::AllocateAlignment()) == 0);
*allocated = msize;
return mbase;
}
void OS::Free(void* address, const size_t size) {
// TODO(1240712): VirtualFree has a return value which is ignored here.
VirtualFree(address, 0, MEM_RELEASE);
USE(size);
}
intptr_t OS::CommitPageSize() {
return 4096;
}
void OS::ProtectCode(void* address, const size_t size) {
DWORD old_protect;
VirtualProtect(address, size, PAGE_EXECUTE_READ, &old_protect);
}
void OS::Guard(void* address, const size_t size) {
DWORD oldprotect;
VirtualProtect(address, size, PAGE_NOACCESS, &oldprotect);
}
void OS::Sleep(TimeDelta interval) {
::Sleep(static_cast<DWORD>(interval.InMilliseconds()));
}
void OS::Abort() {
if (g_hard_abort) {
V8_IMMEDIATE_CRASH();
}
// Make the MSVCRT do a silent abort.
raise(SIGABRT);
// Make sure function doesn't return.
abort();
}
void OS::DebugBreak() {
#if V8_CC_MSVC
// To avoid Visual Studio runtime support the following code can be used
// instead
// __asm { int 3 }
__debugbreak();
#else
::DebugBreak();
#endif
}
class Win32MemoryMappedFile final : public OS::MemoryMappedFile {
public:
Win32MemoryMappedFile(HANDLE file, HANDLE file_mapping, void* memory,
size_t size)
: file_(file),
file_mapping_(file_mapping),
memory_(memory),
size_(size) {}
~Win32MemoryMappedFile() final;
void* memory() const final { return memory_; }
size_t size() const final { return size_; }
private:
HANDLE const file_;
HANDLE const file_mapping_;
void* const memory_;
size_t const size_;
};
// static
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
// Open a physical file
HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (file == INVALID_HANDLE_VALUE) return NULL;
DWORD size = GetFileSize(file, NULL);
// Create a file mapping for the physical file
HANDLE file_mapping =
CreateFileMapping(file, NULL, PAGE_READWRITE, 0, size, NULL);
if (file_mapping == NULL) return NULL;
// Map a view of the file into memory
void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
return new Win32MemoryMappedFile(file, file_mapping, memory, size);
}
// static
OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name,
size_t size, void* initial) {
// Open a physical file
HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_ALWAYS, 0, NULL);
if (file == NULL) return NULL;
// Create a file mapping for the physical file
HANDLE file_mapping = CreateFileMapping(file, NULL, PAGE_READWRITE, 0,
static_cast<DWORD>(size), NULL);
if (file_mapping == NULL) return NULL;
// Map a view of the file into memory
void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
if (memory) memmove(memory, initial, size);
return new Win32MemoryMappedFile(file, file_mapping, memory, size);
}
Win32MemoryMappedFile::~Win32MemoryMappedFile() {
if (memory_) UnmapViewOfFile(memory_);
CloseHandle(file_mapping_);
CloseHandle(file_);
}
// The following code loads functions defined in DbhHelp.h and TlHelp32.h
// dynamically. This is to avoid being depending on dbghelp.dll and
// tlhelp32.dll when running (the functions in tlhelp32.dll have been moved to
// kernel32.dll at some point so loading functions defines in TlHelp32.h
// dynamically might not be necessary any more - for some versions of Windows?).
// Function pointers to functions dynamically loaded from dbghelp.dll.
#define DBGHELP_FUNCTION_LIST(V) \
V(SymInitialize) \
V(SymGetOptions) \
V(SymSetOptions) \
V(SymGetSearchPath) \
V(SymLoadModule64) \
V(StackWalk64) \
V(SymGetSymFromAddr64) \
V(SymGetLineFromAddr64) \
V(SymFunctionTableAccess64) \
V(SymGetModuleBase64)
// Function pointers to functions dynamically loaded from dbghelp.dll.
#define TLHELP32_FUNCTION_LIST(V) \
V(CreateToolhelp32Snapshot) \
V(Module32FirstW) \
V(Module32NextW)
// Define the decoration to use for the type and variable name used for
// dynamically loaded DLL function..
#define DLL_FUNC_TYPE(name) _##name##_
#define DLL_FUNC_VAR(name) _##name
// Define the type for each dynamically loaded DLL function. The function
// definitions are copied from DbgHelp.h and TlHelp32.h. The IN and VOID macros
// from the Windows include files are redefined here to have the function
// definitions to be as close to the ones in the original .h files as possible.
#ifndef IN
#define IN
#endif
#ifndef VOID
#define VOID void
#endif
// DbgHelp isn't supported on MinGW yet
#ifndef __MINGW32__
#if USING_VC6RT == 1
#define MAX_MODULE_NAME32 255
#define SYMOPT_LOAD_LINES 0x00000010
#define SYMOPT_FAIL_CRITICAL_ERRORS 0x00000200
#define TH32CS_SNAPMODULE 0x00000008
typedef enum {
AddrMode1616,
AddrMode1632,
AddrModeReal,
AddrModeFlat
} ADDRESS_MODE;
typedef struct _tagADDRESS64 {
DWORD64 Offset;
WORD Segment;
ADDRESS_MODE Mode;
} ADDRESS64, *LPADDRESS64;
typedef struct _KDHELP64 {
DWORD64 Thread;
DWORD ThCallbackStack;
DWORD ThCallbackBStore;
DWORD NextCallback;
DWORD FramePointer;
DWORD64 KiCallUserMode;
DWORD64 KeUserCallbackDispatcher;
DWORD64 SystemRangeStart;
DWORD64 KiUserExceptionDispatcher;
DWORD64 StackBase;
DWORD64 StackLimit;
DWORD BuildVersion;
DWORD Reserved0;
DWORD64 Reserved1[4];
} KDHELP64, *PKDHELP64;
typedef struct _tagSTACKFRAME64 {
ADDRESS64 AddrPC; // program counter
ADDRESS64 AddrReturn; // return address
ADDRESS64 AddrFrame; // frame pointer
ADDRESS64 AddrStack; // stack pointer
ADDRESS64 AddrBStore; // backing store pointer
PVOID FuncTableEntry; // pointer to pdata/fpo or NULL
DWORD64 Params[4]; // possible arguments to the function
BOOL Far; // WOW far call
BOOL Virtual; // is this a virtual frame?
DWORD64 Reserved[3];
KDHELP64 KdHelp;
} STACKFRAME64, *LPSTACKFRAME64;
typedef struct _IMAGEHLP_SYMBOL64 {
DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOL64)
DWORD64 Address; // virtual address including dll base address
DWORD Size; // estimated size of symbol, can be zero
DWORD Flags; // info about the symbols, see the SYMF defines
DWORD MaxNameLength; // maximum size of symbol name in 'Name'
CHAR Name[1]; // symbol name (null terminated string)
} IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64;
typedef struct _IMAGEHLP_LINE64 {
DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64)
PVOID Key; // internal
DWORD LineNumber; // line number in file
PCHAR FileName; // full filename
DWORD64 Address; // first instruction of line
} IMAGEHLP_LINE64, *PIMAGEHLP_LINE64;
typedef struct tagMODULEENTRY32W
{
DWORD dwSize;
DWORD th32ModuleID; // This module
DWORD th32ProcessID; // owning process
DWORD GlblcntUsage; // Global usage count on the module
DWORD ProccntUsage; // Module usage count in th32ProcessID's context
BYTE * modBaseAddr; // Base address of module in th32ProcessID's context
DWORD modBaseSize; // Size in bytes of module starting at modBaseAddr
HMODULE hModule; // The hModule of this module in th32ProcessID's context
WCHAR szModule[MAX_MODULE_NAME32 + 1];
WCHAR szExePath[MAX_PATH];
} MODULEENTRY32W;
typedef MODULEENTRY32W * PMODULEENTRY32W;
typedef MODULEENTRY32W * LPMODULEENTRY32W;
typedef
BOOL
(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64)(
HANDLE hProcess,
DWORD64 qwBaseAddress,
PVOID lpBuffer,
DWORD nSize,
LPDWORD lpNumberOfBytesRead
);
typedef
PVOID
(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64)(
HANDLE ahProcess,
DWORD64 AddrBase
);
typedef
DWORD64
(__stdcall *PGET_MODULE_BASE_ROUTINE64)(
HANDLE hProcess,
DWORD64 Address
);
typedef
DWORD64
(__stdcall *PTRANSLATE_ADDRESS_ROUTINE64)(
HANDLE hProcess,
HANDLE hThread,
LPADDRESS64 lpaddr
);
#endif
// DbgHelp.h functions.
typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymInitialize))(IN HANDLE hProcess,
IN PSTR UserSearchPath,
IN BOOL fInvadeProcess);
typedef DWORD (__stdcall *DLL_FUNC_TYPE(SymGetOptions))(VOID);
typedef DWORD (__stdcall *DLL_FUNC_TYPE(SymSetOptions))(IN DWORD SymOptions);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymGetSearchPath))(
IN HANDLE hProcess,
OUT PSTR SearchPath,
IN DWORD SearchPathLength);
typedef DWORD64 (__stdcall *DLL_FUNC_TYPE(SymLoadModule64))(
IN HANDLE hProcess,
IN HANDLE hFile,
IN PSTR ImageName,
IN PSTR ModuleName,
IN DWORD64 BaseOfDll,
IN DWORD SizeOfDll);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(StackWalk64))(
DWORD MachineType,
HANDLE hProcess,
HANDLE hThread,
LPSTACKFRAME64 StackFrame,
PVOID ContextRecord,
PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,
PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,
PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine,
PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymGetSymFromAddr64))(
IN HANDLE hProcess,
IN DWORD64 qwAddr,
OUT PDWORD64 pdwDisplacement,
OUT PIMAGEHLP_SYMBOL64 Symbol);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymGetLineFromAddr64))(
IN HANDLE hProcess,
IN DWORD64 qwAddr,
OUT PDWORD pdwDisplacement,
OUT PIMAGEHLP_LINE64 Line64);
// DbgHelp.h typedefs. Implementation found in dbghelp.dll.
typedef PVOID (__stdcall *DLL_FUNC_TYPE(SymFunctionTableAccess64))(
HANDLE hProcess,
DWORD64 AddrBase); // DbgHelp.h typedef PFUNCTION_TABLE_ACCESS_ROUTINE64
typedef DWORD64 (__stdcall *DLL_FUNC_TYPE(SymGetModuleBase64))(
HANDLE hProcess,
DWORD64 AddrBase); // DbgHelp.h typedef PGET_MODULE_BASE_ROUTINE64
// TlHelp32.h functions.
typedef HANDLE (__stdcall *DLL_FUNC_TYPE(CreateToolhelp32Snapshot))(
DWORD dwFlags,
DWORD th32ProcessID);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(Module32FirstW))(HANDLE hSnapshot,
LPMODULEENTRY32W lpme);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(Module32NextW))(HANDLE hSnapshot,
LPMODULEENTRY32W lpme);
#undef IN
#undef VOID
// Declare a variable for each dynamically loaded DLL function.
#define DEF_DLL_FUNCTION(name) DLL_FUNC_TYPE(name) DLL_FUNC_VAR(name) = NULL;
DBGHELP_FUNCTION_LIST(DEF_DLL_FUNCTION)
TLHELP32_FUNCTION_LIST(DEF_DLL_FUNCTION)
#undef DEF_DLL_FUNCTION
// Load the functions. This function has a lot of "ugly" macros in order to
// keep down code duplication.
static bool LoadDbgHelpAndTlHelp32() {
static bool dbghelp_loaded = false;
if (dbghelp_loaded) return true;
HMODULE module;
// Load functions from the dbghelp.dll module.
module = LoadLibrary(TEXT("dbghelp.dll"));
if (module == NULL) {
return false;
}
#define LOAD_DLL_FUNC(name) \
DLL_FUNC_VAR(name) = \
reinterpret_cast<DLL_FUNC_TYPE(name)>(GetProcAddress(module, #name));
DBGHELP_FUNCTION_LIST(LOAD_DLL_FUNC)
#undef LOAD_DLL_FUNC
// Load functions from the kernel32.dll module (the TlHelp32.h function used
// to be in tlhelp32.dll but are now moved to kernel32.dll).
module = LoadLibrary(TEXT("kernel32.dll"));
if (module == NULL) {
return false;
}
#define LOAD_DLL_FUNC(name) \
DLL_FUNC_VAR(name) = \
reinterpret_cast<DLL_FUNC_TYPE(name)>(GetProcAddress(module, #name));
TLHELP32_FUNCTION_LIST(LOAD_DLL_FUNC)
#undef LOAD_DLL_FUNC
// Check that all functions where loaded.
bool result =
#define DLL_FUNC_LOADED(name) (DLL_FUNC_VAR(name) != NULL) &&
DBGHELP_FUNCTION_LIST(DLL_FUNC_LOADED)
TLHELP32_FUNCTION_LIST(DLL_FUNC_LOADED)
#undef DLL_FUNC_LOADED
true;
dbghelp_loaded = result;
return result;
// NOTE: The modules are never unloaded and will stay around until the
// application is closed.
}
#undef DBGHELP_FUNCTION_LIST
#undef TLHELP32_FUNCTION_LIST
#undef DLL_FUNC_VAR
#undef DLL_FUNC_TYPE
// Load the symbols for generating stack traces.
static std::vector<OS::SharedLibraryAddress> LoadSymbols(
HANDLE process_handle) {
static std::vector<OS::SharedLibraryAddress> result;
static bool symbols_loaded = false;
if (symbols_loaded) return result;
BOOL ok;
// Initialize the symbol engine.
ok = _SymInitialize(process_handle, // hProcess
NULL, // UserSearchPath
false); // fInvadeProcess
if (!ok) return result;
DWORD options = _SymGetOptions();
options |= SYMOPT_LOAD_LINES;
options |= SYMOPT_FAIL_CRITICAL_ERRORS;
options = _SymSetOptions(options);
char buf[OS::kStackWalkMaxNameLen] = {0};
ok = _SymGetSearchPath(process_handle, buf, OS::kStackWalkMaxNameLen);
if (!ok) {
int err = GetLastError();
OS::Print("%d\n", err);
return result;
}
HANDLE snapshot = _CreateToolhelp32Snapshot(
TH32CS_SNAPMODULE, // dwFlags
GetCurrentProcessId()); // th32ProcessId
if (snapshot == INVALID_HANDLE_VALUE) return result;
MODULEENTRY32W module_entry;
module_entry.dwSize = sizeof(module_entry); // Set the size of the structure.
BOOL cont = _Module32FirstW(snapshot, &module_entry);
while (cont) {
DWORD64 base;
// NOTE the SymLoadModule64 function has the peculiarity of accepting a
// both unicode and ASCII strings even though the parameter is PSTR.
base = _SymLoadModule64(
process_handle, // hProcess
0, // hFile
reinterpret_cast<PSTR>(module_entry.szExePath), // ImageName
reinterpret_cast<PSTR>(module_entry.szModule), // ModuleName
reinterpret_cast<DWORD64>(module_entry.modBaseAddr), // BaseOfDll
module_entry.modBaseSize); // SizeOfDll
if (base == 0) {
int err = GetLastError();
if (err != ERROR_MOD_NOT_FOUND &&
err != ERROR_INVALID_HANDLE) {
result.clear();
return result;
}
}
int lib_name_length = WideCharToMultiByte(
CP_UTF8, 0, module_entry.szExePath, -1, NULL, 0, NULL, NULL);
std::string lib_name(lib_name_length, 0);
WideCharToMultiByte(CP_UTF8, 0, module_entry.szExePath, -1, &lib_name[0],
lib_name_length, NULL, NULL);
result.push_back(OS::SharedLibraryAddress(
lib_name, reinterpret_cast<uintptr_t>(module_entry.modBaseAddr),
reinterpret_cast<uintptr_t>(module_entry.modBaseAddr +
module_entry.modBaseSize)));
cont = _Module32NextW(snapshot, &module_entry);
}
CloseHandle(snapshot);
symbols_loaded = true;
return result;
}
std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
// SharedLibraryEvents are logged when loading symbol information.
// Only the shared libraries loaded at the time of the call to
// GetSharedLibraryAddresses are logged. DLLs loaded after
// initialization are not accounted for.
if (!LoadDbgHelpAndTlHelp32()) return std::vector<OS::SharedLibraryAddress>();
HANDLE process_handle = GetCurrentProcess();
return LoadSymbols(process_handle);
}
void OS::SignalCodeMovingGC() {
}
#else // __MINGW32__
std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
return std::vector<OS::SharedLibraryAddress>();
}
void OS::SignalCodeMovingGC() { }
#endif // __MINGW32__
int OS::ActivationFrameAlignment() {
#ifdef _WIN64
return 16; // Windows 64-bit ABI requires the stack to be 16-byte aligned.
#elif defined(__MINGW32__)
// With gcc 4.4 the tree vectorization optimizer can generate code
// that requires 16 byte alignment such as movdqa on x86.
return 16;
#else
return 8; // Floating-point math runs faster with 8-byte alignment.
#endif
}
VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { }
VirtualMemory::VirtualMemory(size_t size)
: address_(ReserveRegion(size)), size_(size) { }
VirtualMemory::VirtualMemory(size_t size, size_t alignment)
: address_(NULL), size_(0) {
DCHECK((alignment % OS::AllocateAlignment()) == 0);
size_t request_size = RoundUp(size + alignment,
static_cast<intptr_t>(OS::AllocateAlignment()));
void* address = ReserveRegion(request_size);
if (address == NULL) return;
uint8_t* base = RoundUp(static_cast<uint8_t*>(address), alignment);
// Try reducing the size by freeing and then reallocating a specific area.
bool result = ReleaseRegion(address, request_size);
USE(result);
DCHECK(result);
address = VirtualAlloc(base, size, MEM_RESERVE, PAGE_NOACCESS);
if (address != NULL) {
request_size = size;
DCHECK(base == static_cast<uint8_t*>(address));
} else {
// Resizing failed, just go with a bigger area.
address = ReserveRegion(request_size);
if (address == NULL) return;
}
address_ = address;
size_ = request_size;
}
VirtualMemory::~VirtualMemory() {
if (IsReserved()) {
bool result = ReleaseRegion(address(), size());
DCHECK(result);
USE(result);
}
}
bool VirtualMemory::IsReserved() {
return address_ != NULL;
}
void VirtualMemory::Reset() {
address_ = NULL;
size_ = 0;
}
bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) {
return CommitRegion(address, size, is_executable);
}
bool VirtualMemory::Uncommit(void* address, size_t size) {
DCHECK(IsReserved());
return UncommitRegion(address, size);
}
bool VirtualMemory::Guard(void* address) {
if (NULL == VirtualAlloc(address,
OS::CommitPageSize(),
MEM_COMMIT,
PAGE_NOACCESS)) {
return false;
}
return true;
}
void* VirtualMemory::ReserveRegion(size_t size) {
return RandomizedVirtualAlloc(size, MEM_RESERVE, PAGE_NOACCESS);
}
bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) {
int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
if (NULL == VirtualAlloc(base, size, MEM_COMMIT, prot)) {
return false;
}
return true;
}
bool VirtualMemory::UncommitRegion(void* base, size_t size) {
return VirtualFree(base, size, MEM_DECOMMIT) != 0;
}
bool VirtualMemory::ReleaseRegion(void* base, size_t size) {
return VirtualFree(base, 0, MEM_RELEASE) != 0;
}
bool VirtualMemory::HasLazyCommits() {
// TODO(alph): implement for the platform.
return false;
}
// ----------------------------------------------------------------------------
// Win32 thread support.
// Definition of invalid thread handle and id.
static const HANDLE kNoThread = INVALID_HANDLE_VALUE;
// Entry point for threads. The supplied argument is a pointer to the thread
// object. The entry function dispatches to the run method in the thread
// object. It is important that this function has __stdcall calling
// convention.
static unsigned int __stdcall ThreadEntry(void* arg) {
Thread* thread = reinterpret_cast<Thread*>(arg);
thread->NotifyStartedAndRun();
return 0;
}
class Thread::PlatformData {
public:
explicit PlatformData(HANDLE thread) : thread_(thread) {}
HANDLE thread_;
unsigned thread_id_;
};
// Initialize a Win32 thread object. The thread has an invalid thread
// handle until it is started.
Thread::Thread(const Options& options)
: stack_size_(options.stack_size()),
start_semaphore_(NULL) {
data_ = new PlatformData(kNoThread);
set_name(options.name());
}
void Thread::set_name(const char* name) {
OS::StrNCpy(name_, sizeof(name_), name, strlen(name));
name_[sizeof(name_) - 1] = '\0';
}
// Close our own handle for the thread.
Thread::~Thread() {
if (data_->thread_ != kNoThread) CloseHandle(data_->thread_);
delete data_;
}
// Create a new thread. It is important to use _beginthreadex() instead of
// the Win32 function CreateThread(), because the CreateThread() does not
// initialize thread specific structures in the C runtime library.
void Thread::Start() {
data_->thread_ = reinterpret_cast<HANDLE>(
_beginthreadex(NULL,
static_cast<unsigned>(stack_size_),
ThreadEntry,
this,
0,
&data_->thread_id_));
}
// Wait for thread to terminate.
void Thread::Join() {
if (data_->thread_id_ != GetCurrentThreadId()) {
WaitForSingleObject(data_->thread_, INFINITE);
}
}
Thread::LocalStorageKey Thread::CreateThreadLocalKey() {
DWORD result = TlsAlloc();
DCHECK(result != TLS_OUT_OF_INDEXES);
return static_cast<LocalStorageKey>(result);
}
void Thread::DeleteThreadLocalKey(LocalStorageKey key) {
BOOL result = TlsFree(static_cast<DWORD>(key));
USE(result);
DCHECK(result);
}
void* Thread::GetThreadLocal(LocalStorageKey key) {
return TlsGetValue(static_cast<DWORD>(key));
}
void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
BOOL result = TlsSetValue(static_cast<DWORD>(key), value);
USE(result);
DCHECK(result);
}
} // namespace base
} // namespace v8
| [
"22249030@qq.com"
] | 22249030@qq.com |
cd818e6ceefd6acbfc56015206b2c96d477c675b | 062a5099de7ab2fd1b12d6e98bdc446473cea455 | /140728/Graphic/model/character.h | 74eea0a58cdabc212ac562e771699dcbdc546edb | [
"MIT"
] | permissive | lthnim371/DirectX3D | 8fbda7a3f9b1cec2fad3c410465b4ab14bd87cf2 | 13848ae691747d5ec1d3b42e55a765cbbdc809c9 | refs/heads/master | 2016-09-05T21:44:02.897351 | 2014-08-22T03:43:30 | 2014-08-22T03:43:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 449 | h | #pragma once
namespace graphic
{
class cCharacter : public cModel
{
public:
cCharacter(const int id);
virtual ~cCharacter();
virtual bool Create(const string &modelName) override;
void LoadWeapon(const string &fileName);
virtual bool Move(const float elapseTime) override;
virtual void Render() override;
virtual void RenderShader(cShader &shader);
private:
cModel *m_weapon;
cBoneNode *m_weaponNode; // reference
};
}
| [
"taehoon0720@naver.com"
] | taehoon0720@naver.com |
fae5313593a9670be3b5f8d4e725627475bc7456 | 47ab3c1144428bfcdad475e404182e49fe18aa3a | /30DaysOfCode/Recursion3.cpp | 0d7249e3277ac1645dd3a0be231605a21d36fc1e | [] | no_license | adc-code/HackerRankPractice | 0748e4b4fa6c3fefc156d95826762fdbad955941 | 031e56bbd2311b5375609e2469f280a567d1dbbe | refs/heads/master | 2022-12-25T02:57:18.089761 | 2020-09-27T20:42:12 | 2020-09-27T20:42:12 | 277,374,557 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 443 | cpp | #include <bits/stdc++.h>
using namespace std;
// Complete the factorial function below.
int factorial(int n)
{
if (n == 1)
return 1;
else {
return n * factorial (n - 1);
}
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
int n;
cin >> n;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
int result = factorial(n);
fout << result << "\n";
fout.close();
return 0;
}
| [
"noreply@github.com"
] | adc-code.noreply@github.com |
677425bab4d42b189d1a11c5f3967f80850998f1 | 8dc84558f0058d90dfc4955e905dab1b22d12c08 | /content/public/browser/notification_database_data.h | 8d1298f0eb10e2b88829bca22c400fe446a6b43d | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | meniossin/src | 42a95cc6c4a9c71d43d62bc4311224ca1fd61e03 | 44f73f7e76119e5ab415d4593ac66485e65d700a | refs/heads/master | 2022-12-16T20:17:03.747113 | 2020-09-03T10:43:12 | 2020-09-03T10:43:12 | 263,710,168 | 1 | 0 | BSD-3-Clause | 2020-05-13T18:20:09 | 2020-05-13T18:20:08 | null | UTF-8 | C++ | false | false | 2,983 | h | // Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_BROWSER_NOTIFICATION_DATABASE_DATA_H_
#define CONTENT_PUBLIC_BROWSER_NOTIFICATION_DATABASE_DATA_H_
#include <stdint.h>
#include <string>
#include "base/time/time.h"
#include "content/common/content_export.h"
#include "content/public/common/platform_notification_data.h"
#include "url/gurl.h"
namespace content {
// Stores information about a Web Notification as available in the notification
// database. Beyond the notification's own data, its id and attribution need
// to be available for users of the database as well.
// Note: There are extra properties being stored for UKM logging purposes.
// TODO(https://crbug.com/842622): Add the UKM that will use these properties.
struct CONTENT_EXPORT NotificationDatabaseData {
NotificationDatabaseData();
NotificationDatabaseData(const NotificationDatabaseData& other);
~NotificationDatabaseData();
NotificationDatabaseData& operator=(const NotificationDatabaseData& other);
// Corresponds to why a notification was closed.
enum class ClosedReason {
// The user explicitly closed the notification.
USER,
// The notification was closed by the developer.
DEVELOPER,
// The notification was found to be closed in the notification database,
// but why it was closed was not found.
UNKNOWN
};
// Id of the notification as assigned by the NotificationIdGenerator.
std::string notification_id;
// Origin of the website this notification is associated with.
GURL origin;
// Id of the Service Worker registration this notification is associated with.
int64_t service_worker_registration_id = 0;
// Platform data of the notification that's being stored.
PlatformNotificationData notification_data;
// Boolean for if this current notification is replacing an existing
// notification.
bool replaced_existing_notification = false;
// Number of clicks on the notification itself, i.e. clicks on the
// notification that take the user to the website. This excludes action
// button clicks.
int num_clicks = 0;
// Number of action button clicks.
int num_action_button_clicks = 0;
// Time the notification was first requested to be shown.
base::Time creation_time_millis;
// Amount of time, in ms, between when the notification is shown and the
// first click.
base::TimeDelta time_until_first_click_millis;
// Amount of time, in ms, between when the notification is shown and the
// last click.
base::TimeDelta time_until_last_click_millis;
// Amount of time, in ms, between when the notification is shown and closed.
base::TimeDelta time_until_close_millis;
// Why the notification was closed.
ClosedReason closed_reason = ClosedReason::UNKNOWN;
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_DATABASE_DATA_H_
| [
"arnaud@geometry.ee"
] | arnaud@geometry.ee |
73baab8f3d7ec696ba0602b6f8f65e3cf9eb6110 | b1b734ab75a6fe114733d3c0b8ca5046d54b407d | /third_party/gloo/gloo/math.cc | f73cd3de9b7a72f9bd769a6464a636c0c3817b3e | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown",
"LicenseRef-scancode-generic-cla",
"BSD-2-Clause",
"Apache-2.0"
] | permissive | waybarrios/video_nonlocal_net_caffe2 | 754fea2b96318d677144f16faadf59cb6b00189b | b19c2ac3ddc1836d90d7d0fccb60d710c017253e | refs/heads/master | 2020-04-20T03:15:12.286080 | 2019-01-31T20:44:01 | 2019-01-31T20:44:01 | 168,593,110 | 0 | 0 | Apache-2.0 | 2019-01-31T20:40:40 | 2019-01-31T20:40:39 | null | UTF-8 | C++ | false | false | 2,727 | cc | #include "gloo/math.h"
#include <algorithm>
#if GLOO_USE_AVX
#include <immintrin.h>
#endif
#include "gloo/types.h"
#define is_aligned(POINTER, BYTE_COUNT) \
(((uintptr_t)(const void *)(POINTER)) % (BYTE_COUNT) == 0)
namespace gloo {
#if GLOO_USE_AVX
// Assumes x and y are either both aligned to 32 bytes or unaligned by the same
// offset, as would happen when reducing at an offset within an aligned buffer
template <>
void sum<float16>(float16* x, const float16* y, size_t n) {
size_t i;
for (i = 0; i < (n / 8) * 8; i += 8) {
__m256 va32 = _mm256_cvtph_ps(_mm_loadu_si128((__m128i*)(&x[i])));
__m256 vb32 = _mm256_cvtph_ps(_mm_loadu_si128((__m128i*)(&y[i])));
__m128i vc16 = _mm256_cvtps_ph(_mm256_add_ps(va32, vb32), 0);
_mm_storeu_si128((__m128i*)(&x[i]), vc16);
}
// Leftovers
for (; i < n; i++) {
x[i] += y[i];
}
}
// Assumes x and y are either both aligned to 32 bytes or unaligned by the same
// offset, as would happen when reducing at an offset within an aligned buffer
template <>
void product<float16>(float16* x, const float16* y, size_t n) {
size_t i;
for (i = 0; i < (n / 8) * 8; i += 8) {
__m256 va32 = _mm256_cvtph_ps(_mm_loadu_si128((__m128i*)(&x[i])));
__m256 vb32 = _mm256_cvtph_ps(_mm_loadu_si128((__m128i*)(&y[i])));
__m128i vc16 = _mm256_cvtps_ph(_mm256_mul_ps(va32, vb32), 0);
_mm_storeu_si128((__m128i*)(&x[i]), vc16);
}
// Leftovers
for (; i < n; i++) {
x[i] *= y[i];
}
}
// Assumes x and y are either both aligned to 32 bytes or unaligned by the same
// offset, as would happen when reducing at an offset within an aligned buffer
template <>
void max<float16>(float16* x, const float16* y, size_t n) {
size_t i;
for (i = 0; i < (n / 8) * 8; i += 8) {
__m256 va32 = _mm256_cvtph_ps(_mm_loadu_si128((__m128i*)(&x[i])));
__m256 vb32 = _mm256_cvtph_ps(_mm_loadu_si128((__m128i*)(&y[i])));
__m128i vc16 = _mm256_cvtps_ph(_mm256_max_ps(va32, vb32), 0);
_mm_storeu_si128((__m128i*)(&x[i]), vc16);
}
// Leftovers
for (; i < n; i++) {
x[i] = std::max(x[i], y[i]);
}
}
// Assumes x and y are either both aligned to 32 bytes or unaligned by the same
// offset, as would happen when reducing at an offset within an aligned buffer
template <>
void min<float16>(float16* x, const float16* y, size_t n) {
size_t i;
for (i = 0; i < (n / 8) * 8; i += 8) {
__m256 va32 = _mm256_cvtph_ps(_mm_loadu_si128((__m128i*)(&x[i])));
__m256 vb32 = _mm256_cvtph_ps(_mm_loadu_si128((__m128i*)(&y[i])));
__m128i vc16 = _mm256_cvtps_ph(_mm256_min_ps(va32, vb32), 0);
_mm_storeu_si128((__m128i*)(&x[i]), vc16);
}
// Leftovers
for (; i < n; i++) {
x[i] = std::min(x[i], y[i]);
}
}
#endif
}
| [
"gemfield@civilnet.cn"
] | gemfield@civilnet.cn |
24780bf511f1c9792cb98cc7fbb73bc6cef8a305 | 176af96059dfe7980aac5268027dc2d0bf597ebd | /src/autogen/auto_eigs.cpp | f2f406535baf9a3df519c2ca761ccaba1fc047d0 | [
"MIT"
] | permissive | ldXiao/polyfem | 46bffc1b396537bf04efc71ade374142b2ba7c3e | d4103af16979ff67d461a9ebe46a14bbc4dc8c7c | refs/heads/master | 2020-05-23T06:07:09.776594 | 2019-05-17T21:11:03 | 2019-05-17T21:11:03 | 186,660,692 | 0 | 0 | MIT | 2019-05-14T16:30:05 | 2019-05-14T16:30:04 | null | UTF-8 | C++ | false | false | 80 | cpp | #include <polyfem/auto_eigs.hpp>
namespace polyfem {
namespace autogen {
}}
| [
"teseo@bluewin.ch"
] | teseo@bluewin.ch |
a67d7fd69380005bc816525b50307801cdfc7323 | 6a61e361064f5dd5ae93c0b69adb7387701ca802 | /class/app/juego/rompible.cpp | 243a4125ec0e4aff0607b782bb2619c443a15db1 | [
"Beerware"
] | permissive | TheMarlboroMan/winter-fgj5 | 66092b93ef00272a73efa34d67aa2beea16bed42 | 28cd4bd4ae37230e51c1a9963bcd293e674cdc3c | refs/heads/master | 2021-07-06T13:46:51.195913 | 2021-06-08T11:21:59 | 2021-06-08T11:21:59 | 44,922,853 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 993 | cpp | #include "rompible.h"
using namespace App_Juego;
Rompible::Rompible(float x, float y)
:Actor(x, y, W, H)
{
}
unsigned int Rompible::obtener_ciclos_representable()const
{
return 1;
}
unsigned short int Rompible::obtener_profundidad_ordenacion() const
{
return 30;
}
void Rompible::transformar_bloque(App_Graficos::Bloque_transformacion_representable &b) const
{
const auto& a=b.obtener_animacion(App_Definiciones::animaciones::sprites, App_Definiciones::animaciones_sprites::rompible);
const auto& f=a.obtener_para_tiempo_animacion(App_Graficos::Animaciones::obtener_tiempo(), a.acc_duracion_total()).frame;
b.establecer_tipo(App_Graficos::Bloque_transformacion_representable::tipos::tr_bitmap);
b.establecer_alpha(255);
b.establecer_recurso(App::Recursos_graficos::rt_sprites);
b.establecer_recorte(f.x, f.y, f.w, f.h);
b.establecer_posicion(acc_espaciable_x()+f.desp_x, acc_espaciable_y()+f.desp_y, f.w, f.h);
}
void Rompible::recibir_disparo(int v)
{
mut_borrar(true);
}
| [
"marlborometal@gmail.com"
] | marlborometal@gmail.com |
d091e564f10f86989288ef4094276c29fc66142e | b367fe5f0c2c50846b002b59472c50453e1629bc | /xbox_leak_may_2020/xbox trunk/xbox/private/xdktest/common/draw.h | df4de59b35672040707f2678fb62732c19739e40 | [] | no_license | sgzwiz/xbox_leak_may_2020 | 11b441502a659c8da8a1aa199f89f6236dd59325 | fd00b4b3b2abb1ea6ef9ac64b755419741a3af00 | refs/heads/master | 2022-12-23T16:14:54.706755 | 2020-09-27T18:24:48 | 2020-09-27T18:24:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 987 | h | #ifndef __DRAW_H__
#define __DRAW_H__
#ifdef _XBOX
#include <xtl.h>
#else
#include <windows.h>
#include <d3d8.h>
#endif
#include "bitfont.h"
#define BACKDROP_BLUE 0x000080
#define PITCH_BLACK 0x0
#define LABEL_WHITE 0xffffff
#define DISCONNECTED_BLUE 0x000040
#define CONNECTED_YELLOW 0xffff00
class CDraw
{
private:
static IDirect3DDevice8* m_pDevice;
IDirect3DSurface8* m_pBackBuffer;
BitFont m_font;
public:
CDraw(INT width = 640, INT height = 480);
~CDraw();
VOID FillRect(
INT x,
INT y,
INT width,
INT height,
D3DCOLOR color);
VOID DrawText(
const TCHAR* string,
INT x,
INT y,
D3DCOLOR foregroundColor, // 0xff0000 is red
D3DCOLOR backgroundColor = 0,
DWORD flags = DRAWTEXT_TRANSPARENTBKGND);
VOID Present();
BOOL IsValid() { return m_pDevice != NULL; }
};
#endif __DRAW_H__
| [
"benjamin.barratt@icloud.com"
] | benjamin.barratt@icloud.com |
fa167006a9ffacc7ca3c5c61cef14ce33ee69531 | 5095bbe94f3af8dc3b14a331519cfee887f4c07e | /howwet/source/rainfall/TRainfallForm.cpp | 5d2bd84bd65eac2e02606c114180dc6dbc3db905 | [] | no_license | sativa/apsim_development | efc2b584459b43c89e841abf93830db8d523b07a | a90ffef3b4ed8a7d0cce1c169c65364be6e93797 | refs/heads/master | 2020-12-24T06:53:59.364336 | 2008-09-17T05:31:07 | 2008-09-17T05:31:07 | 64,154,433 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,507 | cpp | //---------------------------------------------------------------------------
#include <general\pch.h>
#include <vcl.h>
#pragma hdrstop
#include "TRainfallForm.h"
#include <ApsimShared\ApsimDataFile.h>
#include <ApsimShared\ApsimDataFileWriter.h>
#include <boost\lexical_cast.hpp>
#include <general\date_functions.h>
#include <general\string_functions.h>
using namespace boost::gregorian;
using namespace boost;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Planner"
#pragma link "AdvGrid"
#pragma link "BaseGrid"
#pragma link "AdvEdBtn"
#pragma link "AdvEdit"
#pragma link "AdvFileNameEdit"
#pragma resource "*.dfm"
TRainfallForm *RainfallForm;
//---------------------------------------------------------------------------
__fastcall TRainfallForm::TRainfallForm(TComponent* Owner)
: TForm(Owner)
{
dirty = false;
clearingCells = false;
}
//---------------------------------------------------------------------------
// setup the form.
//---------------------------------------------------------------------------
void TRainfallForm::setup(const std::string& fileName)
{
clear();
open(fileName);
}
//---------------------------------------------------------------------------
// User has close the form - save if necessary.
//---------------------------------------------------------------------------
void __fastcall TRainfallForm::FormClose(TObject *Sender,
TCloseAction &Action)
{
saveIfNecessary();
}
//---------------------------------------------------------------------------
// User has changed something in the grid - signal data is dirty.
//---------------------------------------------------------------------------
void __fastcall TRainfallForm::gridCellsChanged(TObject *Sender, TRect &R)
{
if (!clearingCells)
dirty = true;
}
//---------------------------------------------------------------------------
// Clear the grid back to default values.
//---------------------------------------------------------------------------
void TRainfallForm::clear(void)
{
clearingCells = true;
rainfall.erase(rainfall.begin(), rainfall.end());
grid->ClearRect(1, 1, grid->ColCount-1, grid->RowCount-1);
clearingCells = false;
fileName = "";
Caption = "Rainfall";
dirty = false;
}
//---------------------------------------------------------------------------
// open a met file
//---------------------------------------------------------------------------
void TRainfallForm::open(const std::string& file)
{
TCursor savedCursor = Screen->Cursor;
Screen->Cursor = savedCursor;
ApsimDataFile metFile;
try
{
metFile.open(file);
date startDate(metFile.getDate());
metFile.last();
date endDate(metFile.getDate());
// find rainfall column.
ApsimDataFile::iterator rainI = find(metFile.fieldsBegin(),
metFile.fieldsEnd(),
"rain");
if (rainI == metFile.fieldsEnd())
throw runtime_error("Cannot find a rainfall column in file " + file);
clear();
// fill grid with rainfall values.
metFile.first();
date currentDate(startDate);
while (currentDate <= endDate)
{
string rainString = rainI->values[0];
float rain = lexical_cast<float>(rainString);
if (rain != 0.0)
rainfall.insert(make_pair(currentDate, rain));
metFile.next();
currentDate = currentDate + date_duration(1);
}
populateGrid(startDate.year());
dirty = false;
fileName = file;
Caption = string("Rainfall - " + fileName).c_str();
YearUpDown->Position = startDate.year();
}
catch (const exception& err)
{
MessageBox(NULL, err.what(), "Error", MB_ICONSTOP | MB_OK);
}
metFile.close();
Screen->Cursor = savedCursor;
}
//---------------------------------------------------------------------------
// populate rainfall grid.
//---------------------------------------------------------------------------
void TRainfallForm::populateGrid(int year)
{
grid->ClearNormalCells();
gridYear = year;
Rainfall::iterator rainfallI = rainfall.begin();
while (rainfallI != rainfall.end() && rainfallI->first.year() < gridYear)
rainfallI++;
while (rainfallI != rainfall.end() && rainfallI->first.year() == gridYear)
{
date currentDate = rainfallI->first;
float rain = rainfallI->second;
int col = rainfallI->first.month();
int row = rainfallI->first.day();
grid->Floats[col][row] = rain;
rainfallI++;
}
// Put monthly sums of rainfall in footer.
float sum = 0.0;
for (int col = 1; col != grid->ColCount; col++)
{
grid->Floats[col][grid->RowCount - 1] = grid->ColumnSum(col,1,grid->RowCount - 2);
sum += grid->ColumnSum(col,1,grid->RowCount - 2);
}
TotalRainLabel->Caption = "Total rain: " + AnsiString(ftoa(sum, 1).c_str()) + "mm";
dirty = false;
}
//---------------------------------------------------------------------------
// save rainfall grid.
//---------------------------------------------------------------------------
void TRainfallForm::saveGrid(void)
{
if (dirty)
{
date startDate = date(gridYear, 1, 1);
date endDate = date(gridYear, 12, 31);
date currentDate = startDate;
for (unsigned col = 1; col <= 12; col++)
for (unsigned row = 1; row <= 31 && !isCellFixed(col, row); row++)
{
rainfall.erase(currentDate);
if (grid->Cells[col][row] != "")
rainfall.insert(make_pair(currentDate, grid->Floats[col][row]));
currentDate = currentDate + date_duration(1);
}
}
}
//---------------------------------------------------------------------------
// Save the data if it is dirty.
//---------------------------------------------------------------------------
void TRainfallForm::saveIfNecessary(void)
{
if (dirty)
{
if (MessageBox(NULL, "Do you want to save changes?", "Question", MB_ICONQUESTION | MB_YESNO)
== IDYES)
SaveButtonClick(NULL);
}
}
//---------------------------------------------------------------------------
// save all data in grid back to file.
//---------------------------------------------------------------------------
void TRainfallForm::save(void)
{
TCursor savedCursor = Screen->Cursor;
Screen->Cursor = crHourGlass;
try
{
saveGrid();
ApsimDataFileWriter writer;
writer.open(fileName, "weather.met.weather");
date startDate = rainfall.begin()->first;
startDate = date(startDate.year(), startDate.month(), 1);
date endDate = (--rainfall.end())->first;
endDate = date(endDate.year(), endDate.month(),
gregorian_calendar::end_of_month_day(endDate.year(), endDate.month()));
date previousDate = startDate;
for (Rainfall::iterator rainfallI = rainfall.begin();
rainfallI != rainfall.end();
rainfallI++)
{
date currentDate = rainfallI->first;
float rain = rainfallI->second;
for (date d = previousDate; d != currentDate; d = d + date_duration(1))
{
ApsimDataFileWriter::Values values;
values.push_back(Value("rain", "(mm)", "0.0", ""));
writer.addTemporalRecord(d, values);
}
ApsimDataFileWriter::Values values;
values.push_back(Value("rain", "(mm)", lexical_cast<string>(rain), ""));
writer.addTemporalRecord(currentDate, values);
previousDate = currentDate + date_duration(1);
}
Caption = string("Rainfall - " + fileName).c_str();
writer.close();
}
catch (const exception& err)
{
ShowMessage(err.what());
}
Screen->Cursor = savedCursor;
}
//---------------------------------------------------------------------------
// User has clicked new.
//---------------------------------------------------------------------------
void __fastcall TRainfallForm::NewButtonClick(TObject *Sender)
{
saveIfNecessary();
clear();
}
//---------------------------------------------------------------------------
// User has clicked open
//---------------------------------------------------------------------------
void __fastcall TRainfallForm::OpenButtonClick(TObject *Sender)
{
if (OpenDialog->Execute())
{
saveIfNecessary();
open(OpenDialog->FileName.c_str());
}
}
//---------------------------------------------------------------------------
// user has clicked save.
//---------------------------------------------------------------------------
void __fastcall TRainfallForm::SaveButtonClick(TObject *Sender)
{
if (fileName == "")
{
if (SaveDialog->Execute())
fileName = SaveDialog->FileName.c_str();
else
return;
}
save();
}
//---------------------------------------------------------------------------
// user has clicked on exit.
//---------------------------------------------------------------------------
void __fastcall TRainfallForm::ExitButtonClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
// return true if cell is fixed.
//---------------------------------------------------------------------------
bool TRainfallForm::isCellFixed(int ACol, int ARow)
{
unsigned year = YearUpDown->Position;
unsigned month = ACol;
return (ARow > gregorian_calendar::end_of_month_day(year, month));
}
//---------------------------------------------------------------------------
void __fastcall TRainfallForm::gridIsFixedCell(TObject *Sender, int ARow,
int ACol, bool &IsFixed)
{
IsFixed = isCellFixed(ACol, ARow);
}
//---------------------------------------------------------------------------
// User has changed the year combo box - save grid contents.
//---------------------------------------------------------------------------
void __fastcall TRainfallForm::YearUpDownChangingEx(TObject *Sender,
bool &AllowChange, short NewValue, TUpDownDirection Direction)
{
saveGrid();
populateGrid(NewValue);
}
//---------------------------------------------------------------------------
| [
"hol353@8bb03f63-af10-0410-889a-a89e84ef1bc8"
] | hol353@8bb03f63-af10-0410-889a-a89e84ef1bc8 |
420f506fed9512332fb9fc1450a20b968da56305 | 2da3214e10706f438aafebe58b9bd05770c566be | /exampleLoopback/src/ofApp.h | 40b9d6756de2f1205f67665755addd18b447e2d7 | [
"MIT"
] | permissive | elliotwoods/ofxSquashBuddies | dbd82e2f3f0e16e5f117bb1ac294a626438d585b | 2dbc95e14d3aad3201f285f7c48d62e0c3449fb5 | refs/heads/master | 2021-01-21T04:40:48.902942 | 2018-09-21T09:39:34 | 2018-09-21T09:39:34 | 51,491,463 | 56 | 7 | null | 2018-09-21T09:39:35 | 2016-02-11T03:21:18 | C++ | UTF-8 | C++ | false | false | 729 | h | #pragma once
#include "ofMain.h"
#include "ofxSquashBuddies.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseEntered(int x, int y);
void mouseExited(int x, int y);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofxSquashBuddies::Sender sender;
ofxSquashBuddies::Receiver receiver;
ofVideoGrabber video;
ofImage receivedPreview;
};
| [
"elliot@kimchiandchips.com"
] | elliot@kimchiandchips.com |
d62fb951dbf7462284769a192e19d4f830b09e37 | 96dcef865aa53f835ec151e5f66d158569916469 | /paddle/operators/math/detail/gru_gpu_kernel.h | 1783d46096858c874b27ce75760342082835b180 | [
"Apache-2.0"
] | permissive | typhoonzero/Paddle | ae7708d8db35c0858c92f3d39f22b556a88adf4d | 45a8c2759b8b8d6b59386a706ee37df6c258abc7 | refs/heads/develop | 2021-04-06T00:44:51.697475 | 2018-02-08T09:09:18 | 2018-02-08T09:09:18 | 83,394,080 | 1 | 1 | Apache-2.0 | 2018-10-12T11:08:12 | 2017-02-28T05:40:12 | C++ | UTF-8 | C++ | false | false | 7,552 | h | /* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <type_traits>
#include "paddle/operators/math/detail/activation_functions.h"
#include "paddle/operators/math/gru_compute.h"
#include "paddle/platform/cuda_helper.h"
#include "paddle/platform/device_context.h"
namespace paddle {
namespace operators {
namespace math {
namespace detail {
/*
* threads(frame_per_block, batch_per_block)
* grid(frame_blocks, batch_blocks)
*/
template <class OpResetOutput, bool is_batch, typename T>
__global__ void KeGruForwardResetOutput(OpResetOutput op_reset_output,
T *gate_value, T *reset_output_value,
T *prev_output_value, int frame_size,
int batch_size,
ActivationType active_gate) {
const int frame_idx = blockIdx.x * blockDim.x + threadIdx.x;
if (frame_idx >= frame_size) return;
int batch_idx = 0;
if (is_batch) {
batch_idx = blockIdx.y * blockDim.y + threadIdx.y;
if (batch_idx >= batch_size) return;
gate_value += batch_idx * 3 * frame_size;
reset_output_value += batch_idx * frame_size;
}
T r_prev_out = 0;
T r_value_reset_output;
T r_value_update_gate = gate_value[frame_idx + frame_size * 0];
T r_value_reset_gate = gate_value[frame_idx + frame_size * 1];
if (prev_output_value) {
if (is_batch) prev_output_value += batch_idx * frame_size;
r_prev_out = prev_output_value[frame_idx];
}
op_reset_output(r_value_update_gate, r_value_reset_gate, r_prev_out,
r_value_reset_output, active_gate);
gate_value[frame_idx + frame_size * 0] = r_value_update_gate;
gate_value[frame_idx + frame_size * 1] = r_value_reset_gate;
reset_output_value[frame_idx] = r_value_reset_output;
}
/*
* threads(frame_per_block, batch_per_block)
* grid(frame_blocks, batch_blocks)
*/
template <class OpFinalOutput, bool is_batch, typename T>
__global__ void KeGruForwardFinalOutput(OpFinalOutput op_final_output,
T *gate_value, T *prev_output_value,
T *output_value, int frame_size,
int batch_size,
ActivationType active_node) {
const int frame_idx = blockIdx.x * blockDim.x + threadIdx.x;
if (frame_idx >= frame_size) return;
int batch_idx = 0;
if (is_batch) {
batch_idx = blockIdx.y * blockDim.y + threadIdx.y;
if (batch_idx >= batch_size) return;
gate_value += batch_idx * 3 * frame_size;
output_value += batch_idx * frame_size;
}
T r_output;
T r_prev_out = 0;
T r_value_update_gate = gate_value[frame_idx + frame_size * 0];
T r_value_frame_state = gate_value[frame_idx + frame_size * 2];
if (prev_output_value) {
if (is_batch) prev_output_value += batch_idx * frame_size;
r_prev_out = prev_output_value[frame_idx];
}
op_final_output(r_value_update_gate, r_value_frame_state, r_prev_out,
r_output, active_node);
gate_value[frame_idx + frame_size * 2] = r_value_frame_state;
output_value[frame_idx] = r_output;
}
/*
* threads(frame_per_block, batch_per_block)
* grid(frame_blocks, batch_blocks)
*/
template <class OpStateGrad, bool is_batch, typename T>
__global__ void KeGruBackwardStateGrad(OpStateGrad op_state_grad, T *gate_value,
T *gate_grad, T *prev_out_value,
T *prev_out_grad, T *output_grad,
int frame_size, int batch_size,
ActivationType active_node) {
const int frame_idx = blockIdx.x * blockDim.x + threadIdx.x;
if (frame_idx >= frame_size) return;
int batch_idx = 0;
if (is_batch) {
batch_idx = blockIdx.y * blockDim.y + threadIdx.y;
if (batch_idx >= batch_size) return;
gate_value += batch_idx * 3 * frame_size;
gate_grad += batch_idx * 3 * frame_size;
output_grad += batch_idx * frame_size;
}
T r_update_gate_grad;
T r_frame_state_grad;
T r_prev_out_value = 0;
T r_prev_out_grad = 0;
T r_update_gate_value = gate_value[frame_idx + frame_size * 0];
T r_frame_state_value = gate_value[frame_idx + frame_size * 2];
T r_out_grad = output_grad[frame_idx];
if (prev_out_value && prev_out_grad) {
if (is_batch) prev_out_value += batch_idx * frame_size;
r_prev_out_value = prev_out_value[frame_idx];
if (is_batch) prev_out_grad += batch_idx * frame_size;
r_prev_out_grad = prev_out_grad[frame_idx];
}
op_state_grad(r_update_gate_value, r_update_gate_grad, r_frame_state_value,
r_frame_state_grad, r_prev_out_value, r_prev_out_grad,
r_out_grad, active_node);
gate_grad[frame_idx + frame_size * 0] = r_update_gate_grad;
gate_grad[frame_idx + frame_size * 2] = r_frame_state_grad;
if (prev_out_grad) {
prev_out_grad[frame_idx] = r_prev_out_grad;
}
}
/*
* threads(frame_per_block, batch_per_block)
* grid(frame_blocks, batch_blocks)
*/
template <class OpResetGrad, bool is_batch, typename T>
__global__ void KeGruBackwardResetGrad(OpResetGrad op_reset_grad, T *gate_value,
T *gate_grad, T *prev_out_value,
T *prev_out_grad, T *reset_output_grad,
int frame_size, int batch_size,
ActivationType active_gate) {
const int frame_idx = blockIdx.x * blockDim.x + threadIdx.x;
if (frame_idx >= frame_size) return;
int batch_idx = 0;
if (is_batch) {
batch_idx = blockIdx.y * blockDim.y + threadIdx.y;
if (batch_idx >= batch_size) return;
gate_value += batch_idx * 3 * frame_size;
gate_grad += batch_idx * 3 * frame_size;
reset_output_grad += batch_idx * frame_size;
}
T r_reset_gate_grad;
T r_prev_out_value = 0;
T r_prev_out_grad = 0;
T r_reset_output_grad = 0;
T r_update_gate_value = gate_value[frame_idx + frame_size * 0];
T r_update_gate_grad = gate_grad[frame_idx + frame_size * 0];
T r_reset_gate_value = gate_value[frame_idx + frame_size * 1];
if (prev_out_value && prev_out_grad) {
if (is_batch) prev_out_value += batch_idx * frame_size;
if (is_batch) prev_out_grad += batch_idx * frame_size;
r_prev_out_value = prev_out_value[frame_idx];
r_prev_out_grad = prev_out_grad[frame_idx];
r_reset_output_grad = reset_output_grad[frame_idx];
}
op_reset_grad(r_update_gate_value, r_update_gate_grad, r_reset_gate_value,
r_reset_gate_grad, r_prev_out_value, r_prev_out_grad,
r_reset_output_grad, active_gate);
gate_grad[frame_idx + frame_size * 0] = r_update_gate_grad;
gate_grad[frame_idx + frame_size * 1] = r_reset_gate_grad;
if (prev_out_grad) {
prev_out_grad[frame_idx] = r_prev_out_grad;
}
}
} // namespace detail
} // namespace math
} // namespace operators
} // namespace paddle
| [
"guosheng@baidu.com"
] | guosheng@baidu.com |
14ef77ae4de93f42b5d1ec9e32a743a12204a503 | 62e45e9478a5e5d9ec293916d9b549de663aba02 | /EGP-310/section03/burnett.jordan/snek/level.h | e6753f9d92648111ab2e6c725331e8fcf38e39b9 | [] | no_license | jburn7/Game-Programming-Projects | 88ea9a0978755019e5a81fb1d26078f32796db47 | 5eeca67d389f82c3a2355273b2d0bc3e46e6bd61 | refs/heads/master | 2020-08-31T02:07:19.287881 | 2019-10-30T14:57:20 | 2019-10-30T14:57:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,264 | h | #pragma once
#include <string>
#include <vector>
#include <fstream>
#include "unit.h"
#include "EventSystem.h"
#include "wall.h"
#include "SnakeIncrementPowerUp.h"
#include "scorePowerUp.h"
#include "speedPowerUp.h"
#include "unitAddEvent.h"
#include "sprite.h"
#include "jsonData.h"
class Level
{
friend class LevelManager;
public:
Level(std::string &filename, int levelNumber);
~Level();
void spawnFood();
void update(double timeElapsed);
//getters
int getFoodScore(){ return mFoodScore; }
int getScorePowerupScore(){ return mScorePowerupScore; }
int getSpeedScore(){ return mSpeedScore; }
std::string &getLevelString(){ return mLevelString; }
Vector2D &getSnakeSpawn(){ return mSnakeSpawn; }
private:
void addItemSpawn(int x, int y);
void addSnake(int x, int y);
void addWall(int x, int y);
void load();
void spawnItem(Unit *item);
int mTileSize; //width/height of walls
int mLevelNumber;
std::string mFilename;
int mItemFrequency;
int mFoodScore;
int mScorePowerupScore;
int mSpeedScore;
int mTargetSegments; //when snake eats this many food pieces, increment level
std::string mLevelString;
Vector2D mSnakeSpawn;
std::vector<Vector2D> mItemSpawns;
Snake *mpSnake; //for spawning items without spawning on top of snake
}; | [
"jleeburnett@gmail.com"
] | jleeburnett@gmail.com |
ae1df12201da5b4325b86f6fe1e1424b42c91bd2 | 947d0ceb0754476616797dc7a3071735ddfbb4a9 | /Algorithm_practice/CSE2021/mst_kruskal/warshal/main.cpp | 5e85dac485492955ce737e6697a8f7063948e117 | [] | no_license | monirmusa/Algoritm-2D-array-practice | b26651277b1d5518cc709041884dfcf8774c3abe | e73a4e341d9f022131dc2e528acd85d605e137a1 | refs/heads/master | 2020-04-13T01:14:42.234715 | 2018-12-23T06:41:43 | 2018-12-23T06:41:43 | 162,868,646 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,122 | cpp | #include <stdio.h>
#include <stdlib.h>
#define inf 999
#define max_vertex 5
int **g, **rg;
int vertex, edge;
void warshal()
{
int k = 0;
for(int k=0; k<vertex;)
{
int pri_val = 0;
int cal_val = 0;
for(int i=0; i<vertex; i++)
for(int j=0; j<vertex; j++)
{
pri_val = rg[i][j];
cal_val = g[i][k] + g[k][j];
if(cal_val < pri_val) rg[i][j] = cal_val;
}
printf("\nPrint rg : %d\n",k++);
for(int i=0; i<vertex; i++)
{
for(int j=0; j<vertex; j++)
printf("%d ",rg[i][j]);
printf("\n");
}
}
}
int main()
{
int u, v, c;
printf("\nEnter Vertex : ");
//scanf("%d",&vertex);
vertex = 5;
g = (int **)malloc(max_vertex * sizeof(int *));
rg = (int **)malloc(max_vertex * sizeof(int *));
for(int i=0; i<max_vertex; i++)
{
g[i] = (int *)malloc(max_vertex * sizeof(int));
rg[i] = (int *)malloc(max_vertex * sizeof(int));
}
for(int i=0; i<vertex; i++)
for(int j=0; j<vertex; j++)
{
g[i][j] = 0;
rg[i][j] = inf;
if(i==j) rg[i][j] = 0;
}
printf("\nEnter Edge : ");
//scanf("%d",&edge);
edge = 9;
/*for(int i=0; i<edge; i++)
{
scanf("%d",&u);
scanf("%d",&v);
scanf("%d",&c);
g[u][v] = c;
g[v][u] = c;
}*/
g[0][1] = 10; g[1][0] = 10;
g[0][2] = 12; g[2][0] = 12;
g[0][4] = 7; g[4][0] = 7;
g[1][2] = 15; g[2][1] = 15;
g[1][3] = 7; g[3][1] = 7;
g[1][4] = 10; g[4][1] = 10;
g[2][3] = 5; g[3][2] = 5;
g[2][4] = 8; g[4][2] = 8;
g[3][4] = 7; g[4][3] = 7;
printf("\nPrint Graph : \n");
for(int i=0; i<vertex; i++)
{
for(int j=0; j<vertex; j++)
printf("%d ",g[i][j]);
printf("\n");
}
printf("\nPrint rg : \n");
for(int i=0; i<vertex; i++)
{
for(int j=0; j<vertex; j++)
printf("%d ",rg[i][j]);
printf("\n");
}
warshal();
return 0;
}
| [
"monirmusa.bd@gmail.com"
] | monirmusa.bd@gmail.com |
c4cc829084ade968cadaa51a793376bda895c849 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/httpd/gumtree/httpd_new_log_4394.cpp | cf9c9b3a7d8f391dd61209f8745fed457718618d | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 83 | cpp | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01078) "serving URL %s", url); | [
"993273596@qq.com"
] | 993273596@qq.com |
841cd03c6f0eb03741d003c414118360c379a4c7 | 967775b8d057acb35e94510ab923527bd7595e9e | /Arduino/main/LEDController.h | 482dd4c652b9efd97ba038d46455fc0ed6aa7424 | [] | no_license | hikson7/arduino_posix_serial_com | 368c6c5e3f75d391a01b4265c5e7dc1e668209c2 | 39b06696efa6adc72200ad5826ac0e57665a6d24 | refs/heads/main | 2023-04-16T21:41:39.336633 | 2021-04-28T11:34:03 | 2021-04-28T11:34:03 | 334,571,939 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,340 | h | /**
* @file LEDController.h
* @author Hikari Hashida
* @brief Simple class that receives commands from serial input via USB/UART, and outputs to LED strip.
* @version 0.1
* @date 2021-02-03
*
* @copyright Copyright (c) 2021
*
*/
#include <Adafruit_NeoPixel.h>
/* Status indicator command format stored in struct */
struct __attribute__((__packed__)) LEDControllerCommand {
uint8_t duration;
uint8_t blink;
uint8_t red_val;
uint8_t green_val;
uint8_t blue_val;
uint8_t brightness;
};
constexpr static uint8_t PIN_STATUS_INDIC = 12;
constexpr static uint8_t NUM_STATUS_INDIC_PIXELS = 8;
constexpr static uint8_t START_MARKER = '<';
constexpr static uint8_t END_MARKER = '>';
class LEDController {
public:
LEDController();
void updateRoverStatus();
void readDataFromSerial();
void indicateLED();
void setBrightness(uint8_t brightness);
void LEDController::setAndShowLEDStatus(uint8_t red_val,
uint8_t green_val, uint8_t blue_val);
private:
/* status indicator struct to store the indication parameters */
LEDControllerCommand lcc_;
/* byte-sized pointer to keep track of the place in struct */
uint8_t* byte_ptr_;
/* data receiving in progress */
bool in_progress_;
bool is_new_data_ = false;
Adafruit_NeoPixel led_status_indicator_;
};
| [
"hikarihashida7@gmail.com"
] | hikarihashida7@gmail.com |
854736ea94cc78fb8b3ba91b23ee3ad4109a0c9b | fa10b09a97fe199a1a4534a2e4b66eef85233bbc | /tests/accumulators/stochastic/random/RandomTest.cc | 04279ac6661b773db3ddae648e7d52dcf6208693 | [] | no_license | dmorse/util | 0f53cb0431afb707973f563f27d6e8d155816481 | 928110f754aae7e7ba494b8fe31abc0cac40b344 | refs/heads/master | 2022-12-13T10:00:09.113704 | 2022-12-11T17:37:04 | 2022-12-11T17:37:04 | 77,802,805 | 2 | 1 | null | 2022-08-09T18:24:27 | 2017-01-02T00:23:03 | C++ | UTF-8 | C++ | false | false | 3,800 | cc | #ifndef RANDOM_TEST_H
#define RANDOM_TEST_H
#include <util/random/Random.h>
#include <util/accumulators/Average.h>
#include <util/accumulators/Distribution.h>
#include <util/accumulators/IntDistribution.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace Util;
class RandomTest
{
public:
RandomTest()
: randomPtr_(0),
verbose_(2)
{}
void setUp(const char* functionName)
{
std::cout << std::string(functionName) << " :" << std::endl << std::endl;
randomPtr_ = new Random;
std::ifstream file("in/Random");
random().readParam(file);
}
void tearDown()
{
delete randomPtr_;
std::cout << "----------------------------------------------------"
<< std::endl << std::endl;
}
void testReadParam()
{
setUp("testReadParam");
// Verbose output
if (verbose_ > 0) {
printf("idum: %ld\n", random().seed() );
}
tearDown();
}
void testGetFloat()
{
setUp("testGetFloat");
Average average;
int nSamplePerBlock = 1;
average.setNSamplePerBlock(nSamplePerBlock);
Distribution distribution;
double min = 0.0;
double max = 1.0;
int nBin = 10;
distribution.setParam(min, max, nBin);
const int nSample = 100000;
double x;
for (int i=0; i < nSample; i++) {
x = random().uniform(0.0,1.0);
average.sample(x);
distribution.sample(x);
}
average.output(std::cout);
distribution.output(std::cout);
tearDown();
}
void testGetInteger()
{
setUp("testGetInteger");
const int nSample = 100000;
Average average;
int nSamplePerBlock = 1;
average.setNSamplePerBlock(nSamplePerBlock);
int nBin = 11;
IntDistribution distribution;
int min = 0;
int max = min + nBin - 1;
distribution.setParam(min, max);
long x;
for (int i=0; i < nSample; i++) {
x = random().uniformInt(0, nBin);
average.sample(double(x));
distribution.sample(x);
}
average.output(std::cout);
distribution.output(std::cout);
tearDown();
}
void testGaussian()
{
setUp("testGaussian");
Average average;
int nSamplePerBlock = 1;
average.setNSamplePerBlock(nSamplePerBlock);
Distribution distribution;
double min = -3.0;
double max = 3.0;
int nBin = 60;
distribution.setParam(min, max, nBin);
const int nSample = 100000;
double x;
for (int i=0; i < nSample; i++) {
x = random().gaussian();
average.sample(x);
distribution.sample(x);
}
average.output(std::cout);
distribution.output(std::cout);
tearDown();
}
void testUnitVector()
{
setUp("testUnitVector");
Average average;
int nSamplePerBlock = 1;
average.setNSamplePerBlock(nSamplePerBlock);
Distribution distribution;
double min = -1.1;
double max = 1.1;
int nBin = 22;
distribution.setParam(min, max, nBin);
Vector v;
double vsq;
int nSample = 100000;
for (int i=0; i < nSample; i++ ) {
random().unitVector(v);
vsq = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
average.sample(v[1]);
distribution.sample(v[1]);
}
average.output(std::cout);
distribution.output(std::cout);
tearDown();
}
Random& random()
{ return *randomPtr_; }
private:
Random* randomPtr_;
int verbose_;
};
int main()
{
RandomTest test;
test.testReadParam();
test.testGetFloat();
test.testGetInteger();
test.testGaussian();
test.testUnitVector();
}
#endif
| [
"morse012@umn.edu"
] | morse012@umn.edu |
923e516842da1a1c32a70cbff7c92594b6cc777d | d1e4cf1bb916fb0850302da79acb6e5383405bc4 | /BTree.h | fd674cc8a6e42039917e6268b5496c68ebabdbb4 | [] | no_license | YinLiu-91/data_structure_djh | 05f15b0a8935d240f33627666982840c6c05b9a1 | 5ceaec412b32e818267ddf8cbb5468c37df3fb97 | refs/heads/master | 2022-11-24T20:53:29.556833 | 2020-08-01T07:07:59 | 2020-08-01T07:07:59 | 275,840,699 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,854 | h | /*
* @Author: your name
* @Date: 2020-07-26 12:45:14
* @LastEditTime: 2020-07-26 16:50:15
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \code\BTree.h
*/
#ifndef BTREE_H
#define BTREE_H
#include "BTNode.h"
template <typename T>
class BTree
{ //B-树模板类
protected:
int _size; //存放的关键码总数
int _order; //B-树的阶次,至少为3,创建时指定,一般不能修改
BTNodePosi(T) _root; //根节点
BTNodePosi(T) _hot; //BTree::sezrch()最后访问的非空(除非树空)的节点位置
void solveOverFlow(BTNodePosi(T)); //因插入而上溢之后的分裂处理
void solveUnderFlow(BTNodePosi(T)); //因删除而下溢之后的合并处理
public:
}
//p 217
template <typename T>
BTNodePosi(T) BTree<T>::search(const T &e)
{ //在B-树中查找关键码
BTNodePosi(T) v = _root;
_hot = nullptr; //从根节点出发
while (v)
{ //逐层查找
Rank r = v->key.search(e); //在当前节点中,找不到大于e的最大关键码
if ((0 <= r) && (e == v->key[r]))
return v; //成功:在当前节点命中目标关键码
_hot = v;
v = v->child[r + 1]; //否则,转入对应子树(_hot指向其父)--需要做io,最费时间
} //这里在向量内是二分查找,但对通常的_order可直接顺序查找
return nullptr;
}
//p219
template <typename T>
bool BTree<T>::insert(const T &e)
{ //将关键码e插入B树中
BTNodePosi(T) v = search(e);
if (v)
return false; //确认目标节点不存在
Rank r = _hot->key.search(c); //在节点_hot的有关关键码向量中查找合适的插入位置
_hot->key.insert(r + 1, e); //将新关键码插至对应的位置
_hot->child.insert(r + 2, nullptr); //创建一个空子树指针
_size++; //更新全树规模
solveOverflow(_hot); //如有必要,需要分裂
return true; //插入成功
}
//p220
template <typename T> //关键码插入后若节点上溢,则做节点分裂处理
void BTree<T>::solveOverFlow(BTNodePosi(T) v)
{
if (_order >= v->child.size())
return; //递归基:当前节点并未上溢
Rank s = _order / 2; //轴点(此时应有_order=key.size()=child.size()-1
BTNodePosi(T) u = new BTNode<T>(); //注意:新节点已经有一个空孩子
for (Rank j = 0; j < _order - s - 1; ++j)
{
//v右侧_order-s-1个孩子及关键码分裂为右侧节点u
u->child.insert(j, v->child.remove(s + 1)); //逐个移动效率低
u->key.insert(j, v->key.remove(s + 1)); //此策略可改进
}
u->child[_order - s - 1] = v->child.remove(s + 1); //移动v最靠右的孩子
if (u->child[0]) //若u的孩子们非空,则
for (Rank j = 0; j < _order - s; ++j) //令他们的父节点统一
u->child[j]->parent = u; //指向u
BTNodePosi(T) p = v->parent; //v当前的父节点p
if (!p)
{
_root = p = new BTNode<T>();
p->child[0] = v;
v->parent = p;
}
Rank r = 1 + p->key.search(v->key[0]); //p指向u的指针的秩
p->key.insert(r, v->key.remove(s)); //轴点关键码上升
p->child.insert(r + 1, u);
u->parent = p; //新节点u与父节点p互联
solveOverFlow(p); //上升一层,如有必要则继续分裂--至多递归O(logn)层
}
//p222
template <typename T>
bool BTree<T>::remove(const T &e)
{
BTNodePosi(T) v = search(e);
if (!v)
return false;
Rank r = v->key.search(e); //确定目标关键码在节点v中的秩
if (v->child[0])
{ //若v非叶子,则e的后继必属于某叶节点
BTNodePosi(T) u = v->child[r + 1]; //若右子树中一直向左,即可
v->key[r] = u->key[0];
v = u;
r = 0; //并与之交换位置
} //至此,v必然位于最底层,且其中第r个关键码就是待删除者
v->key.remove(r);
v->child.remove(r + 1);
_size--; //删除e,以及其下两个外部节点之一
soveOverFlow(v); //如有必要,需做旋转或合并
return true;
}
/******************************************************************************************
* Data Structures in C++
* ISBN: 7-302-33064-6 & 7-302-33065-3 & 7-302-29652-2 & 7-302-26883-3
* Junhui DENG, deng@tsinghua.edu.cn
* Computer Science & Technology, Tsinghua University
* Copyright (c) 2003-2019. All rights reserved.
******************************************************************************************/
//复制的
template <typename T> //关键码删除后若节点下溢,则做节点旋转或合并处理
void BTree<T>::solveUnderflow(BTNodePosi(T) v)
{
if ((_order + 1) / 2 <= v->child.size())
return; //递归基:当前节点并未下溢
BTNodePosi(T) p = v->parent;
if (!p)
{ //递归基:已到根节点,没有孩子的下限
if (!v->key.size() && v->child[0])
{
//但倘若作为树根的v已不含关键码,却有(唯一的)非空孩子,则
_root = v->child[0];
_root->parent = NULL; //这个节点可被跳过
v->child[0] = NULL;
release(v); //并因不再有用而被销毁
} //整树高度降低一层
return;
}
Rank r = 0;
while (p->child[r] != v)
r++;
//确定v是p的第r个孩子——此时v可能不含关键码,故不能通过关键码查找
//另外,在实现了孩子指针的判等器之后,也可直接调用Vector::find()定位
// 情况1:向左兄弟借关键码
if (0 < r)
{ //若v不是p的第一个孩子,则
BTNodePosi(T) ls = p->child[r - 1]; //左兄弟必存在
if ((_order + 1) / 2 < ls->child.size())
{ //若该兄弟足够“胖”,则
v->key.insert(0, p->key[r - 1]); //p借出一个关键码给v(作为最小关键码)
p->key[r - 1] = ls->key.remove(ls->key.size() - 1); //ls的最大关键码转入p
v->child.insert(0, ls->child.remove(ls->child.size() - 1));
//同时ls的最右侧孩子过继给v
if (v->child[0])
v->child[0]->parent = v; //作为v的最左侧孩子
return; //至此,通过右旋已完成当前层(以及所有层)的下溢处理
}
} //至此,左兄弟要么为空,要么太“瘦”
// 情况2:向右兄弟借关键码
if (p->child.size() - 1 > r)
{ //若v不是p的最后一个孩子,则
BTNodePosi(T) rs = p->child[r + 1]; //右兄弟必存在
if ((_order + 1) / 2 < rs->child.size())
{ //若该兄弟足够“胖”,则
v->key.insert(v->key.size(), p->key[r]); //p借出一个关键码给v(作为最大关键码)
p->key[r] = rs->key.remove(0); //ls的最小关键码转入p
v->child.insert(v->child.size(), rs->child.remove(0));
//同时rs的最左侧孩子过继给v
if (v->child[v->child.size() - 1]) //作为v的最右侧孩子
v->child[v->child.size() - 1]->parent = v;
return; //至此,通过左旋已完成当前层(以及所有层)的下溢处理
}
} //至此,右兄弟要么为空,要么太“瘦”
// 情况3:左、右兄弟要么为空(但不可能同时),要么都太“瘦”——合并
if (0 < r)
{ //与左兄弟合并
BTNodePosi(T) ls = p->child[r - 1]; //左兄弟必存在
ls->key.insert(ls->key.size(), p->key.remove(r - 1));
p->child.remove(r);
//p的第r - 1个关键码转入ls,v不再是p的第r个孩子
ls->child.insert(ls->child.size(), v->child.remove(0));
if (ls->child[ls->child.size() - 1]) //v的最左侧孩子过继给ls做最右侧孩子
ls->child[ls->child.size() - 1]->parent = ls;
while (!v->key.empty())
{ //v剩余的关键码和孩子,依次转入ls
ls->key.insert(ls->key.size(), v->key.remove(0));
ls->child.insert(ls->child.size(), v->child.remove(0));
if (ls->child[ls->child.size() - 1])
ls->child[ls->child.size() - 1]->parent = ls;
}
release(v); //释放v
}
else
{ //与右兄弟合并
BTNodePosi(T) rs = p->child[r + 1]; //右兄度必存在
rs->key.insert(0, p->key.remove(r));
p->child.remove(r);
//p的第r个关键码转入rs,v不再是p的第r个孩子
rs->child.insert(0, v->child.remove(v->child.size() - 1));
if (rs->child[0])
rs->child[0]->parent = rs; //v的最左侧孩子过继给ls做最右侧孩子
while (!v->key.empty())
{ //v剩余的关键码和孩子,依次转入rs
rs->key.insert(0, v->key.remove(v->key.size() - 1));
rs->child.insert(0, v->child.remove(v->child.size() - 1));
if (rs->child[0])
rs->child[0]->parent = rs;
}
release(v); //释放v
}
solveUnderflow(p); //上升一层,如有必要则继续分裂——至多递归O(logn)层
return;
}
#endif
| [
"2274882591@qq.com"
] | 2274882591@qq.com |
9efd3bad15ea71562fcd85648e4b8134cad4410d | 9c9003f4912e2065c3901f1f51ef5b398f999a10 | /projectb/client/game_xxx/newProtocol/game_rouletteak_protocol.pb.h | 8fc882915027ec4a6e76c6c6f384864be91506ef | [] | no_license | PHDaozhang/recharge_h5 | 41424d5725eae69cc6a921cd1ef954b255a0ca65 | 7d5e63d97e731ea860d927c37612fe35f7d3bd61 | refs/heads/master | 2020-08-11T21:57:49.842525 | 2019-10-15T07:32:40 | 2019-10-15T07:32:40 | 214,632,134 | 0 | 3 | null | null | null | null | UTF-8 | C++ | false | true | 265,276 | h | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: game_rouletteak_protocol.proto
#ifndef PROTOBUF_game_5frouletteak_5fprotocol_2eproto__INCLUDED
#define PROTOBUF_game_5frouletteak_5fprotocol_2eproto__INCLUDED
#include <string>
#include <google/protobuf/stubs/common.h>
#if GOOGLE_PROTOBUF_VERSION < 2005000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/unknown_field_set.h>
#include "game_rouletteak_def.pb.h"
#include "msg_type_def.pb.h"
// @@protoc_insertion_point(includes)
namespace game_rouletteak_protocols {
// Internal implementation detail -- do not call these.
void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
class msg_room_info;
class packetc2l_get_room_info;
class packetl2c_get_room_info_result;
class packetc2l_enter_room;
class packetl2c_enter_room_result;
class packetc2l_leave_room;
class packetl2c_leave_room_result;
class msg_player_info;
class msg_bet_info;
class msg_player_gold;
class msg_result_info;
class msg_scene_info;
class packetc2l_get_scene_info;
class packetl2c_get_scene_info_result;
class packetl2c_bc_scene_prepare_into;
class packetl2c_bc_scene_bet_into;
class packetl2c_bc_sync_scene_bet_into;
class packetl2c_bc_scene_deal_into;
class packetl2c_bc_scene_result_into;
class packetc2l_ask_bet_info;
class packetl2c_bet_info_result;
class packetl2c_enter_player_info;
class packetl2c_leave_player_info;
class packetl2c_bc_change_attr;
class packetc2l_supply_chip;
class packetl2c_supply_chip_result;
class packetc2l_check_state;
class packetc2l_check_state_result;
class msg_room_history;
class packetc2l_room_history_list;
class packetl2c_room_history_list_result;
class packetl2c_notify_history;
class packetc2l_continue_bet;
class packetl2c_continue_bet_result;
class packetc2l_cancel_bet;
class packetl2c_cancel_bet_result;
class room_player;
class packetl2c_gm_get_room_info;
class packetl2c_gm_get_room_info_result;
class packetl2c_gm_set_bead;
class packetl2c_gm_set_bead_result;
// ===================================================================
class msg_room_info : public ::google::protobuf::Message {
public:
msg_room_info();
virtual ~msg_room_info();
msg_room_info(const msg_room_info& from);
inline msg_room_info& operator=(const msg_room_info& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const msg_room_info& default_instance();
void Swap(msg_room_info* other);
// implements Message ----------------------------------------------
msg_room_info* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const msg_room_info& from);
void MergeFrom(const msg_room_info& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional int32 roomid = 1;
inline bool has_roomid() const;
inline void clear_roomid();
static const int kRoomidFieldNumber = 1;
inline ::google::protobuf::int32 roomid() const;
inline void set_roomid(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.msg_room_info)
private:
inline void set_has_roomid();
inline void clear_has_roomid();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::google::protobuf::int32 roomid_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static msg_room_info* default_instance_;
};
// -------------------------------------------------------------------
class packetc2l_get_room_info : public ::google::protobuf::Message {
public:
packetc2l_get_room_info();
virtual ~packetc2l_get_room_info();
packetc2l_get_room_info(const packetc2l_get_room_info& from);
inline packetc2l_get_room_info& operator=(const packetc2l_get_room_info& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetc2l_get_room_info& default_instance();
void Swap(packetc2l_get_room_info* other);
// implements Message ----------------------------------------------
packetc2l_get_room_info* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetc2l_get_room_info& from);
void MergeFrom(const packetc2l_get_room_info& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_get_room_info];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetc2l_get_room_info)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetc2l_get_room_info* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_get_room_info_result : public ::google::protobuf::Message {
public:
packetl2c_get_room_info_result();
virtual ~packetl2c_get_room_info_result();
packetl2c_get_room_info_result(const packetl2c_get_room_info_result& from);
inline packetl2c_get_room_info_result& operator=(const packetl2c_get_room_info_result& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_get_room_info_result& default_instance();
void Swap(packetl2c_get_room_info_result* other);
// implements Message ----------------------------------------------
packetl2c_get_room_info_result* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_get_room_info_result& from);
void MergeFrom(const packetl2c_get_room_info_result& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_get_room_info_result];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// repeated .game_rouletteak_protocols.msg_room_info room_list = 2;
inline int room_list_size() const;
inline void clear_room_list();
static const int kRoomListFieldNumber = 2;
inline const ::game_rouletteak_protocols::msg_room_info& room_list(int index) const;
inline ::game_rouletteak_protocols::msg_room_info* mutable_room_list(int index);
inline ::game_rouletteak_protocols::msg_room_info* add_room_list();
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_room_info >&
room_list() const;
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_room_info >*
mutable_room_list();
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_get_room_info_result)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_room_info > room_list_;
int packet_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_get_room_info_result* default_instance_;
};
// -------------------------------------------------------------------
class packetc2l_enter_room : public ::google::protobuf::Message {
public:
packetc2l_enter_room();
virtual ~packetc2l_enter_room();
packetc2l_enter_room(const packetc2l_enter_room& from);
inline packetc2l_enter_room& operator=(const packetc2l_enter_room& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetc2l_enter_room& default_instance();
void Swap(packetc2l_enter_room* other);
// implements Message ----------------------------------------------
packetc2l_enter_room* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetc2l_enter_room& from);
void MergeFrom(const packetc2l_enter_room& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_enter_room];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 roomid = 2;
inline bool has_roomid() const;
inline void clear_roomid();
static const int kRoomidFieldNumber = 2;
inline ::google::protobuf::int32 roomid() const;
inline void set_roomid(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetc2l_enter_room)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_roomid();
inline void clear_has_roomid();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 roomid_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetc2l_enter_room* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_enter_room_result : public ::google::protobuf::Message {
public:
packetl2c_enter_room_result();
virtual ~packetl2c_enter_room_result();
packetl2c_enter_room_result(const packetl2c_enter_room_result& from);
inline packetl2c_enter_room_result& operator=(const packetl2c_enter_room_result& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_enter_room_result& default_instance();
void Swap(packetl2c_enter_room_result* other);
// implements Message ----------------------------------------------
packetl2c_enter_room_result* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_enter_room_result& from);
void MergeFrom(const packetl2c_enter_room_result& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_enter_room_result];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional .msg_type_def.e_msg_result_def result = 2 [default = e_rmt_fail];
inline bool has_result() const;
inline void clear_result();
static const int kResultFieldNumber = 2;
inline ::msg_type_def::e_msg_result_def result() const;
inline void set_result(::msg_type_def::e_msg_result_def value);
// optional .game_rouletteak_protocols.msg_scene_info scene_info = 3;
inline bool has_scene_info() const;
inline void clear_scene_info();
static const int kSceneInfoFieldNumber = 3;
inline const ::game_rouletteak_protocols::msg_scene_info& scene_info() const;
inline ::game_rouletteak_protocols::msg_scene_info* mutable_scene_info();
inline ::game_rouletteak_protocols::msg_scene_info* release_scene_info();
inline void set_allocated_scene_info(::game_rouletteak_protocols::msg_scene_info* scene_info);
// optional int64 self_gold = 4;
inline bool has_self_gold() const;
inline void clear_self_gold();
static const int kSelfGoldFieldNumber = 4;
inline ::google::protobuf::int64 self_gold() const;
inline void set_self_gold(::google::protobuf::int64 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_enter_room_result)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_result();
inline void clear_has_result();
inline void set_has_scene_info();
inline void clear_has_scene_info();
inline void set_has_self_gold();
inline void clear_has_self_gold();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
int result_;
::game_rouletteak_protocols::msg_scene_info* scene_info_;
::google::protobuf::int64 self_gold_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(4 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_enter_room_result* default_instance_;
};
// -------------------------------------------------------------------
class packetc2l_leave_room : public ::google::protobuf::Message {
public:
packetc2l_leave_room();
virtual ~packetc2l_leave_room();
packetc2l_leave_room(const packetc2l_leave_room& from);
inline packetc2l_leave_room& operator=(const packetc2l_leave_room& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetc2l_leave_room& default_instance();
void Swap(packetc2l_leave_room* other);
// implements Message ----------------------------------------------
packetc2l_leave_room* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetc2l_leave_room& from);
void MergeFrom(const packetc2l_leave_room& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_leave_room];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetc2l_leave_room)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetc2l_leave_room* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_leave_room_result : public ::google::protobuf::Message {
public:
packetl2c_leave_room_result();
virtual ~packetl2c_leave_room_result();
packetl2c_leave_room_result(const packetl2c_leave_room_result& from);
inline packetl2c_leave_room_result& operator=(const packetl2c_leave_room_result& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_leave_room_result& default_instance();
void Swap(packetl2c_leave_room_result* other);
// implements Message ----------------------------------------------
packetl2c_leave_room_result* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_leave_room_result& from);
void MergeFrom(const packetl2c_leave_room_result& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_leave_room_result];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional .msg_type_def.e_msg_result_def result = 2 [default = e_rmt_success];
inline bool has_result() const;
inline void clear_result();
static const int kResultFieldNumber = 2;
inline ::msg_type_def::e_msg_result_def result() const;
inline void set_result(::msg_type_def::e_msg_result_def value);
// optional int64 player_gold = 3;
inline bool has_player_gold() const;
inline void clear_player_gold();
static const int kPlayerGoldFieldNumber = 3;
inline ::google::protobuf::int64 player_gold() const;
inline void set_player_gold(::google::protobuf::int64 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_leave_room_result)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_result();
inline void clear_has_result();
inline void set_has_player_gold();
inline void clear_has_player_gold();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
int result_;
::google::protobuf::int64 player_gold_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_leave_room_result* default_instance_;
};
// -------------------------------------------------------------------
class msg_player_info : public ::google::protobuf::Message {
public:
msg_player_info();
virtual ~msg_player_info();
msg_player_info(const msg_player_info& from);
inline msg_player_info& operator=(const msg_player_info& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const msg_player_info& default_instance();
void Swap(msg_player_info* other);
// implements Message ----------------------------------------------
msg_player_info* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const msg_player_info& from);
void MergeFrom(const msg_player_info& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional int32 player_id = 1;
inline bool has_player_id() const;
inline void clear_player_id();
static const int kPlayerIdFieldNumber = 1;
inline ::google::protobuf::int32 player_id() const;
inline void set_player_id(::google::protobuf::int32 value);
// optional string player_name = 2;
inline bool has_player_name() const;
inline void clear_player_name();
static const int kPlayerNameFieldNumber = 2;
inline const ::std::string& player_name() const;
inline void set_player_name(const ::std::string& value);
inline void set_player_name(const char* value);
inline void set_player_name(const char* value, size_t size);
inline ::std::string* mutable_player_name();
inline ::std::string* release_player_name();
inline void set_allocated_player_name(::std::string* player_name);
// optional int32 head_frame = 3;
inline bool has_head_frame() const;
inline void clear_head_frame();
static const int kHeadFrameFieldNumber = 3;
inline ::google::protobuf::int32 head_frame() const;
inline void set_head_frame(::google::protobuf::int32 value);
// optional string head_custom = 4;
inline bool has_head_custom() const;
inline void clear_head_custom();
static const int kHeadCustomFieldNumber = 4;
inline const ::std::string& head_custom() const;
inline void set_head_custom(const ::std::string& value);
inline void set_head_custom(const char* value);
inline void set_head_custom(const char* value, size_t size);
inline ::std::string* mutable_head_custom();
inline ::std::string* release_head_custom();
inline void set_allocated_head_custom(::std::string* head_custom);
// optional int64 player_gold = 5;
inline bool has_player_gold() const;
inline void clear_player_gold();
static const int kPlayerGoldFieldNumber = 5;
inline ::google::protobuf::int64 player_gold() const;
inline void set_player_gold(::google::protobuf::int64 value);
// optional int32 player_sex = 6;
inline bool has_player_sex() const;
inline void clear_player_sex();
static const int kPlayerSexFieldNumber = 6;
inline ::google::protobuf::int32 player_sex() const;
inline void set_player_sex(::google::protobuf::int32 value);
// optional int32 vip_level = 7;
inline bool has_vip_level() const;
inline void clear_vip_level();
static const int kVipLevelFieldNumber = 7;
inline ::google::protobuf::int32 vip_level() const;
inline void set_vip_level(::google::protobuf::int32 value);
// optional int32 history_bet_gold = 8;
inline bool has_history_bet_gold() const;
inline void clear_history_bet_gold();
static const int kHistoryBetGoldFieldNumber = 8;
inline ::google::protobuf::int32 history_bet_gold() const;
inline void set_history_bet_gold(::google::protobuf::int32 value);
// optional int32 win_count = 9;
inline bool has_win_count() const;
inline void clear_win_count();
static const int kWinCountFieldNumber = 9;
inline ::google::protobuf::int32 win_count() const;
inline void set_win_count(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.msg_player_info)
private:
inline void set_has_player_id();
inline void clear_has_player_id();
inline void set_has_player_name();
inline void clear_has_player_name();
inline void set_has_head_frame();
inline void clear_has_head_frame();
inline void set_has_head_custom();
inline void clear_has_head_custom();
inline void set_has_player_gold();
inline void clear_has_player_gold();
inline void set_has_player_sex();
inline void clear_has_player_sex();
inline void set_has_vip_level();
inline void clear_has_vip_level();
inline void set_has_history_bet_gold();
inline void clear_has_history_bet_gold();
inline void set_has_win_count();
inline void clear_has_win_count();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::std::string* player_name_;
::google::protobuf::int32 player_id_;
::google::protobuf::int32 head_frame_;
::std::string* head_custom_;
::google::protobuf::int64 player_gold_;
::google::protobuf::int32 player_sex_;
::google::protobuf::int32 vip_level_;
::google::protobuf::int32 history_bet_gold_;
::google::protobuf::int32 win_count_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(9 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static msg_player_info* default_instance_;
};
// -------------------------------------------------------------------
class msg_bet_info : public ::google::protobuf::Message {
public:
msg_bet_info();
virtual ~msg_bet_info();
msg_bet_info(const msg_bet_info& from);
inline msg_bet_info& operator=(const msg_bet_info& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const msg_bet_info& default_instance();
void Swap(msg_bet_info* other);
// implements Message ----------------------------------------------
msg_bet_info* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const msg_bet_info& from);
void MergeFrom(const msg_bet_info& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional int32 player_id = 1;
inline bool has_player_id() const;
inline void clear_player_id();
static const int kPlayerIdFieldNumber = 1;
inline ::google::protobuf::int32 player_id() const;
inline void set_player_id(::google::protobuf::int32 value);
// optional int32 bet_pos = 2;
inline bool has_bet_pos() const;
inline void clear_bet_pos();
static const int kBetPosFieldNumber = 2;
inline ::google::protobuf::int32 bet_pos() const;
inline void set_bet_pos(::google::protobuf::int32 value);
// optional int64 bet_gold = 3;
inline bool has_bet_gold() const;
inline void clear_bet_gold();
static const int kBetGoldFieldNumber = 3;
inline ::google::protobuf::int64 bet_gold() const;
inline void set_bet_gold(::google::protobuf::int64 value);
// optional int64 cur_gold = 4;
inline bool has_cur_gold() const;
inline void clear_cur_gold();
static const int kCurGoldFieldNumber = 4;
inline ::google::protobuf::int64 cur_gold() const;
inline void set_cur_gold(::google::protobuf::int64 value);
// optional int32 chip_index = 5;
inline bool has_chip_index() const;
inline void clear_chip_index();
static const int kChipIndexFieldNumber = 5;
inline ::google::protobuf::int32 chip_index() const;
inline void set_chip_index(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.msg_bet_info)
private:
inline void set_has_player_id();
inline void clear_has_player_id();
inline void set_has_bet_pos();
inline void clear_has_bet_pos();
inline void set_has_bet_gold();
inline void clear_has_bet_gold();
inline void set_has_cur_gold();
inline void clear_has_cur_gold();
inline void set_has_chip_index();
inline void clear_has_chip_index();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::google::protobuf::int32 player_id_;
::google::protobuf::int32 bet_pos_;
::google::protobuf::int64 bet_gold_;
::google::protobuf::int64 cur_gold_;
::google::protobuf::int32 chip_index_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(5 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static msg_bet_info* default_instance_;
};
// -------------------------------------------------------------------
class msg_player_gold : public ::google::protobuf::Message {
public:
msg_player_gold();
virtual ~msg_player_gold();
msg_player_gold(const msg_player_gold& from);
inline msg_player_gold& operator=(const msg_player_gold& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const msg_player_gold& default_instance();
void Swap(msg_player_gold* other);
// implements Message ----------------------------------------------
msg_player_gold* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const msg_player_gold& from);
void MergeFrom(const msg_player_gold& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional int32 player_id = 1;
inline bool has_player_id() const;
inline void clear_player_id();
static const int kPlayerIdFieldNumber = 1;
inline ::google::protobuf::int32 player_id() const;
inline void set_player_id(::google::protobuf::int32 value);
// optional int64 win_gold = 2;
inline bool has_win_gold() const;
inline void clear_win_gold();
static const int kWinGoldFieldNumber = 2;
inline ::google::protobuf::int64 win_gold() const;
inline void set_win_gold(::google::protobuf::int64 value);
// optional int64 cur_gold = 3;
inline bool has_cur_gold() const;
inline void clear_cur_gold();
static const int kCurGoldFieldNumber = 3;
inline ::google::protobuf::int64 cur_gold() const;
inline void set_cur_gold(::google::protobuf::int64 value);
// optional int32 history_bet_gold = 4;
inline bool has_history_bet_gold() const;
inline void clear_history_bet_gold();
static const int kHistoryBetGoldFieldNumber = 4;
inline ::google::protobuf::int32 history_bet_gold() const;
inline void set_history_bet_gold(::google::protobuf::int32 value);
// optional int64 win_count = 5;
inline bool has_win_count() const;
inline void clear_win_count();
static const int kWinCountFieldNumber = 5;
inline ::google::protobuf::int64 win_count() const;
inline void set_win_count(::google::protobuf::int64 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.msg_player_gold)
private:
inline void set_has_player_id();
inline void clear_has_player_id();
inline void set_has_win_gold();
inline void clear_has_win_gold();
inline void set_has_cur_gold();
inline void clear_has_cur_gold();
inline void set_has_history_bet_gold();
inline void clear_has_history_bet_gold();
inline void set_has_win_count();
inline void clear_has_win_count();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::google::protobuf::int64 win_gold_;
::google::protobuf::int32 player_id_;
::google::protobuf::int32 history_bet_gold_;
::google::protobuf::int64 cur_gold_;
::google::protobuf::int64 win_count_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(5 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static msg_player_gold* default_instance_;
};
// -------------------------------------------------------------------
class msg_result_info : public ::google::protobuf::Message {
public:
msg_result_info();
virtual ~msg_result_info();
msg_result_info(const msg_result_info& from);
inline msg_result_info& operator=(const msg_result_info& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const msg_result_info& default_instance();
void Swap(msg_result_info* other);
// implements Message ----------------------------------------------
msg_result_info* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const msg_result_info& from);
void MergeFrom(const msg_result_info& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional int32 number = 1;
inline bool has_number() const;
inline void clear_number();
static const int kNumberFieldNumber = 1;
inline ::google::protobuf::int32 number() const;
inline void set_number(::google::protobuf::int32 value);
// repeated .game_rouletteak_protocols.msg_player_gold player_golds = 2;
inline int player_golds_size() const;
inline void clear_player_golds();
static const int kPlayerGoldsFieldNumber = 2;
inline const ::game_rouletteak_protocols::msg_player_gold& player_golds(int index) const;
inline ::game_rouletteak_protocols::msg_player_gold* mutable_player_golds(int index);
inline ::game_rouletteak_protocols::msg_player_gold* add_player_golds();
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_player_gold >&
player_golds() const;
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_player_gold >*
mutable_player_golds();
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.msg_result_info)
private:
inline void set_has_number();
inline void clear_has_number();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_player_gold > player_golds_;
::google::protobuf::int32 number_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static msg_result_info* default_instance_;
};
// -------------------------------------------------------------------
class msg_scene_info : public ::google::protobuf::Message {
public:
msg_scene_info();
virtual ~msg_scene_info();
msg_scene_info(const msg_scene_info& from);
inline msg_scene_info& operator=(const msg_scene_info& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const msg_scene_info& default_instance();
void Swap(msg_scene_info* other);
// implements Message ----------------------------------------------
msg_scene_info* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const msg_scene_info& from);
void MergeFrom(const msg_scene_info& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional int32 roomid = 1;
inline bool has_roomid() const;
inline void clear_roomid();
static const int kRoomidFieldNumber = 1;
inline ::google::protobuf::int32 roomid() const;
inline void set_roomid(::google::protobuf::int32 value);
// optional int32 scene_state = 2;
inline bool has_scene_state() const;
inline void clear_scene_state();
static const int kSceneStateFieldNumber = 2;
inline ::google::protobuf::int32 scene_state() const;
inline void set_scene_state(::google::protobuf::int32 value);
// optional int32 cd = 3;
inline bool has_cd() const;
inline void clear_cd();
static const int kCdFieldNumber = 3;
inline ::google::protobuf::int32 cd() const;
inline void set_cd(::google::protobuf::int32 value);
// repeated .game_rouletteak_protocols.msg_player_info player_list = 4;
inline int player_list_size() const;
inline void clear_player_list();
static const int kPlayerListFieldNumber = 4;
inline const ::game_rouletteak_protocols::msg_player_info& player_list(int index) const;
inline ::game_rouletteak_protocols::msg_player_info* mutable_player_list(int index);
inline ::game_rouletteak_protocols::msg_player_info* add_player_list();
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_player_info >&
player_list() const;
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_player_info >*
mutable_player_list();
// repeated .game_rouletteak_protocols.msg_bet_info bet_infos = 5;
inline int bet_infos_size() const;
inline void clear_bet_infos();
static const int kBetInfosFieldNumber = 5;
inline const ::game_rouletteak_protocols::msg_bet_info& bet_infos(int index) const;
inline ::game_rouletteak_protocols::msg_bet_info* mutable_bet_infos(int index);
inline ::game_rouletteak_protocols::msg_bet_info* add_bet_infos();
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info >&
bet_infos() const;
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info >*
mutable_bet_infos();
// optional .game_rouletteak_protocols.msg_result_info result_info = 6;
inline bool has_result_info() const;
inline void clear_result_info();
static const int kResultInfoFieldNumber = 6;
inline const ::game_rouletteak_protocols::msg_result_info& result_info() const;
inline ::game_rouletteak_protocols::msg_result_info* mutable_result_info();
inline ::game_rouletteak_protocols::msg_result_info* release_result_info();
inline void set_allocated_result_info(::game_rouletteak_protocols::msg_result_info* result_info);
// repeated int32 pos_list = 7;
inline int pos_list_size() const;
inline void clear_pos_list();
static const int kPosListFieldNumber = 7;
inline ::google::protobuf::int32 pos_list(int index) const;
inline void set_pos_list(int index, ::google::protobuf::int32 value);
inline void add_pos_list(::google::protobuf::int32 value);
inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
pos_list() const;
inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
mutable_pos_list();
// optional int64 bet_gold_room = 8;
inline bool has_bet_gold_room() const;
inline void clear_bet_gold_room();
static const int kBetGoldRoomFieldNumber = 8;
inline ::google::protobuf::int64 bet_gold_room() const;
inline void set_bet_gold_room(::google::protobuf::int64 value);
// optional int64 bet_gold_self = 9;
inline bool has_bet_gold_self() const;
inline void clear_bet_gold_self();
static const int kBetGoldSelfFieldNumber = 9;
inline ::google::protobuf::int64 bet_gold_self() const;
inline void set_bet_gold_self(::google::protobuf::int64 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.msg_scene_info)
private:
inline void set_has_roomid();
inline void clear_has_roomid();
inline void set_has_scene_state();
inline void clear_has_scene_state();
inline void set_has_cd();
inline void clear_has_cd();
inline void set_has_result_info();
inline void clear_has_result_info();
inline void set_has_bet_gold_room();
inline void clear_has_bet_gold_room();
inline void set_has_bet_gold_self();
inline void clear_has_bet_gold_self();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::google::protobuf::int32 roomid_;
::google::protobuf::int32 scene_state_;
::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_player_info > player_list_;
::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info > bet_infos_;
::game_rouletteak_protocols::msg_result_info* result_info_;
::google::protobuf::RepeatedField< ::google::protobuf::int32 > pos_list_;
::google::protobuf::int64 bet_gold_room_;
::google::protobuf::int64 bet_gold_self_;
::google::protobuf::int32 cd_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(9 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static msg_scene_info* default_instance_;
};
// -------------------------------------------------------------------
class packetc2l_get_scene_info : public ::google::protobuf::Message {
public:
packetc2l_get_scene_info();
virtual ~packetc2l_get_scene_info();
packetc2l_get_scene_info(const packetc2l_get_scene_info& from);
inline packetc2l_get_scene_info& operator=(const packetc2l_get_scene_info& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetc2l_get_scene_info& default_instance();
void Swap(packetc2l_get_scene_info* other);
// implements Message ----------------------------------------------
packetc2l_get_scene_info* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetc2l_get_scene_info& from);
void MergeFrom(const packetc2l_get_scene_info& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_get_scene_info];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetc2l_get_scene_info)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetc2l_get_scene_info* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_get_scene_info_result : public ::google::protobuf::Message {
public:
packetl2c_get_scene_info_result();
virtual ~packetl2c_get_scene_info_result();
packetl2c_get_scene_info_result(const packetl2c_get_scene_info_result& from);
inline packetl2c_get_scene_info_result& operator=(const packetl2c_get_scene_info_result& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_get_scene_info_result& default_instance();
void Swap(packetl2c_get_scene_info_result* other);
// implements Message ----------------------------------------------
packetl2c_get_scene_info_result* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_get_scene_info_result& from);
void MergeFrom(const packetl2c_get_scene_info_result& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_get_scene_info_result];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional .game_rouletteak_protocols.msg_scene_info scene_info = 2;
inline bool has_scene_info() const;
inline void clear_scene_info();
static const int kSceneInfoFieldNumber = 2;
inline const ::game_rouletteak_protocols::msg_scene_info& scene_info() const;
inline ::game_rouletteak_protocols::msg_scene_info* mutable_scene_info();
inline ::game_rouletteak_protocols::msg_scene_info* release_scene_info();
inline void set_allocated_scene_info(::game_rouletteak_protocols::msg_scene_info* scene_info);
// optional int64 self_gold = 3;
inline bool has_self_gold() const;
inline void clear_self_gold();
static const int kSelfGoldFieldNumber = 3;
inline ::google::protobuf::int64 self_gold() const;
inline void set_self_gold(::google::protobuf::int64 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_get_scene_info_result)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_scene_info();
inline void clear_has_scene_info();
inline void set_has_self_gold();
inline void clear_has_self_gold();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::game_rouletteak_protocols::msg_scene_info* scene_info_;
::google::protobuf::int64 self_gold_;
int packet_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_get_scene_info_result* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_bc_scene_prepare_into : public ::google::protobuf::Message {
public:
packetl2c_bc_scene_prepare_into();
virtual ~packetl2c_bc_scene_prepare_into();
packetl2c_bc_scene_prepare_into(const packetl2c_bc_scene_prepare_into& from);
inline packetl2c_bc_scene_prepare_into& operator=(const packetl2c_bc_scene_prepare_into& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_bc_scene_prepare_into& default_instance();
void Swap(packetl2c_bc_scene_prepare_into* other);
// implements Message ----------------------------------------------
packetl2c_bc_scene_prepare_into* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_bc_scene_prepare_into& from);
void MergeFrom(const packetl2c_bc_scene_prepare_into& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bc_scene_prepare_into];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 cd = 2;
inline bool has_cd() const;
inline void clear_cd();
static const int kCdFieldNumber = 2;
inline ::google::protobuf::int32 cd() const;
inline void set_cd(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_bc_scene_prepare_into)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_cd();
inline void clear_has_cd();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 cd_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_bc_scene_prepare_into* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_bc_scene_bet_into : public ::google::protobuf::Message {
public:
packetl2c_bc_scene_bet_into();
virtual ~packetl2c_bc_scene_bet_into();
packetl2c_bc_scene_bet_into(const packetl2c_bc_scene_bet_into& from);
inline packetl2c_bc_scene_bet_into& operator=(const packetl2c_bc_scene_bet_into& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_bc_scene_bet_into& default_instance();
void Swap(packetl2c_bc_scene_bet_into* other);
// implements Message ----------------------------------------------
packetl2c_bc_scene_bet_into* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_bc_scene_bet_into& from);
void MergeFrom(const packetl2c_bc_scene_bet_into& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bc_scene_bet_into];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 cd = 2;
inline bool has_cd() const;
inline void clear_cd();
static const int kCdFieldNumber = 2;
inline ::google::protobuf::int32 cd() const;
inline void set_cd(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_bc_scene_bet_into)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_cd();
inline void clear_has_cd();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 cd_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_bc_scene_bet_into* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_bc_sync_scene_bet_into : public ::google::protobuf::Message {
public:
packetl2c_bc_sync_scene_bet_into();
virtual ~packetl2c_bc_sync_scene_bet_into();
packetl2c_bc_sync_scene_bet_into(const packetl2c_bc_sync_scene_bet_into& from);
inline packetl2c_bc_sync_scene_bet_into& operator=(const packetl2c_bc_sync_scene_bet_into& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_bc_sync_scene_bet_into& default_instance();
void Swap(packetl2c_bc_sync_scene_bet_into* other);
// implements Message ----------------------------------------------
packetl2c_bc_sync_scene_bet_into* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_bc_sync_scene_bet_into& from);
void MergeFrom(const packetl2c_bc_sync_scene_bet_into& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bc_sync_scene_bet_into];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// repeated .game_rouletteak_protocols.msg_bet_info bet_list = 2;
inline int bet_list_size() const;
inline void clear_bet_list();
static const int kBetListFieldNumber = 2;
inline const ::game_rouletteak_protocols::msg_bet_info& bet_list(int index) const;
inline ::game_rouletteak_protocols::msg_bet_info* mutable_bet_list(int index);
inline ::game_rouletteak_protocols::msg_bet_info* add_bet_list();
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info >&
bet_list() const;
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info >*
mutable_bet_list();
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_bc_sync_scene_bet_into)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info > bet_list_;
int packet_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_bc_sync_scene_bet_into* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_bc_scene_deal_into : public ::google::protobuf::Message {
public:
packetl2c_bc_scene_deal_into();
virtual ~packetl2c_bc_scene_deal_into();
packetl2c_bc_scene_deal_into(const packetl2c_bc_scene_deal_into& from);
inline packetl2c_bc_scene_deal_into& operator=(const packetl2c_bc_scene_deal_into& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_bc_scene_deal_into& default_instance();
void Swap(packetl2c_bc_scene_deal_into* other);
// implements Message ----------------------------------------------
packetl2c_bc_scene_deal_into* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_bc_scene_deal_into& from);
void MergeFrom(const packetl2c_bc_scene_deal_into& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bc_scene_deal_into];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 cd = 2;
inline bool has_cd() const;
inline void clear_cd();
static const int kCdFieldNumber = 2;
inline ::google::protobuf::int32 cd() const;
inline void set_cd(::google::protobuf::int32 value);
// optional int32 number = 3;
inline bool has_number() const;
inline void clear_number();
static const int kNumberFieldNumber = 3;
inline ::google::protobuf::int32 number() const;
inline void set_number(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_bc_scene_deal_into)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_cd();
inline void clear_has_cd();
inline void set_has_number();
inline void clear_has_number();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 cd_;
::google::protobuf::int32 number_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_bc_scene_deal_into* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_bc_scene_result_into : public ::google::protobuf::Message {
public:
packetl2c_bc_scene_result_into();
virtual ~packetl2c_bc_scene_result_into();
packetl2c_bc_scene_result_into(const packetl2c_bc_scene_result_into& from);
inline packetl2c_bc_scene_result_into& operator=(const packetl2c_bc_scene_result_into& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_bc_scene_result_into& default_instance();
void Swap(packetl2c_bc_scene_result_into* other);
// implements Message ----------------------------------------------
packetl2c_bc_scene_result_into* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_bc_scene_result_into& from);
void MergeFrom(const packetl2c_bc_scene_result_into& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bc_scene_result_into];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 cd = 2;
inline bool has_cd() const;
inline void clear_cd();
static const int kCdFieldNumber = 2;
inline ::google::protobuf::int32 cd() const;
inline void set_cd(::google::protobuf::int32 value);
// optional .game_rouletteak_protocols.msg_result_info result_info = 3;
inline bool has_result_info() const;
inline void clear_result_info();
static const int kResultInfoFieldNumber = 3;
inline const ::game_rouletteak_protocols::msg_result_info& result_info() const;
inline ::game_rouletteak_protocols::msg_result_info* mutable_result_info();
inline ::game_rouletteak_protocols::msg_result_info* release_result_info();
inline void set_allocated_result_info(::game_rouletteak_protocols::msg_result_info* result_info);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_bc_scene_result_into)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_cd();
inline void clear_has_cd();
inline void set_has_result_info();
inline void clear_has_result_info();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 cd_;
::game_rouletteak_protocols::msg_result_info* result_info_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_bc_scene_result_into* default_instance_;
};
// -------------------------------------------------------------------
class packetc2l_ask_bet_info : public ::google::protobuf::Message {
public:
packetc2l_ask_bet_info();
virtual ~packetc2l_ask_bet_info();
packetc2l_ask_bet_info(const packetc2l_ask_bet_info& from);
inline packetc2l_ask_bet_info& operator=(const packetc2l_ask_bet_info& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetc2l_ask_bet_info& default_instance();
void Swap(packetc2l_ask_bet_info* other);
// implements Message ----------------------------------------------
packetc2l_ask_bet_info* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetc2l_ask_bet_info& from);
void MergeFrom(const packetc2l_ask_bet_info& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_ask_bet_info];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 bet_pos = 2;
inline bool has_bet_pos() const;
inline void clear_bet_pos();
static const int kBetPosFieldNumber = 2;
inline ::google::protobuf::int32 bet_pos() const;
inline void set_bet_pos(::google::protobuf::int32 value);
// optional int64 bet_gold = 3;
inline bool has_bet_gold() const;
inline void clear_bet_gold();
static const int kBetGoldFieldNumber = 3;
inline ::google::protobuf::int64 bet_gold() const;
inline void set_bet_gold(::google::protobuf::int64 value);
// optional int32 chip_index = 4;
inline bool has_chip_index() const;
inline void clear_chip_index();
static const int kChipIndexFieldNumber = 4;
inline ::google::protobuf::int32 chip_index() const;
inline void set_chip_index(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetc2l_ask_bet_info)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_bet_pos();
inline void clear_has_bet_pos();
inline void set_has_bet_gold();
inline void clear_has_bet_gold();
inline void set_has_chip_index();
inline void clear_has_chip_index();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 bet_pos_;
::google::protobuf::int64 bet_gold_;
::google::protobuf::int32 chip_index_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(4 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetc2l_ask_bet_info* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_bet_info_result : public ::google::protobuf::Message {
public:
packetl2c_bet_info_result();
virtual ~packetl2c_bet_info_result();
packetl2c_bet_info_result(const packetl2c_bet_info_result& from);
inline packetl2c_bet_info_result& operator=(const packetl2c_bet_info_result& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_bet_info_result& default_instance();
void Swap(packetl2c_bet_info_result* other);
// implements Message ----------------------------------------------
packetl2c_bet_info_result* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_bet_info_result& from);
void MergeFrom(const packetl2c_bet_info_result& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bet_info_result];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional .msg_type_def.e_msg_result_def result = 2 [default = e_rmt_fail];
inline bool has_result() const;
inline void clear_result();
static const int kResultFieldNumber = 2;
inline ::msg_type_def::e_msg_result_def result() const;
inline void set_result(::msg_type_def::e_msg_result_def value);
// optional .game_rouletteak_protocols.msg_bet_info bet_info = 3;
inline bool has_bet_info() const;
inline void clear_bet_info();
static const int kBetInfoFieldNumber = 3;
inline const ::game_rouletteak_protocols::msg_bet_info& bet_info() const;
inline ::game_rouletteak_protocols::msg_bet_info* mutable_bet_info();
inline ::game_rouletteak_protocols::msg_bet_info* release_bet_info();
inline void set_allocated_bet_info(::game_rouletteak_protocols::msg_bet_info* bet_info);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_bet_info_result)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_result();
inline void clear_has_result();
inline void set_has_bet_info();
inline void clear_has_bet_info();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
int result_;
::game_rouletteak_protocols::msg_bet_info* bet_info_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_bet_info_result* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_enter_player_info : public ::google::protobuf::Message {
public:
packetl2c_enter_player_info();
virtual ~packetl2c_enter_player_info();
packetl2c_enter_player_info(const packetl2c_enter_player_info& from);
inline packetl2c_enter_player_info& operator=(const packetl2c_enter_player_info& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_enter_player_info& default_instance();
void Swap(packetl2c_enter_player_info* other);
// implements Message ----------------------------------------------
packetl2c_enter_player_info* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_enter_player_info& from);
void MergeFrom(const packetl2c_enter_player_info& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_enter_player_info];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional .game_rouletteak_protocols.msg_player_info player_info = 2;
inline bool has_player_info() const;
inline void clear_player_info();
static const int kPlayerInfoFieldNumber = 2;
inline const ::game_rouletteak_protocols::msg_player_info& player_info() const;
inline ::game_rouletteak_protocols::msg_player_info* mutable_player_info();
inline ::game_rouletteak_protocols::msg_player_info* release_player_info();
inline void set_allocated_player_info(::game_rouletteak_protocols::msg_player_info* player_info);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_enter_player_info)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_player_info();
inline void clear_has_player_info();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::game_rouletteak_protocols::msg_player_info* player_info_;
int packet_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_enter_player_info* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_leave_player_info : public ::google::protobuf::Message {
public:
packetl2c_leave_player_info();
virtual ~packetl2c_leave_player_info();
packetl2c_leave_player_info(const packetl2c_leave_player_info& from);
inline packetl2c_leave_player_info& operator=(const packetl2c_leave_player_info& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_leave_player_info& default_instance();
void Swap(packetl2c_leave_player_info* other);
// implements Message ----------------------------------------------
packetl2c_leave_player_info* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_leave_player_info& from);
void MergeFrom(const packetl2c_leave_player_info& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_leave_player_info];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 player_id = 2;
inline bool has_player_id() const;
inline void clear_player_id();
static const int kPlayerIdFieldNumber = 2;
inline ::google::protobuf::int32 player_id() const;
inline void set_player_id(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_leave_player_info)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_player_id();
inline void clear_has_player_id();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 player_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_leave_player_info* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_bc_change_attr : public ::google::protobuf::Message {
public:
packetl2c_bc_change_attr();
virtual ~packetl2c_bc_change_attr();
packetl2c_bc_change_attr(const packetl2c_bc_change_attr& from);
inline packetl2c_bc_change_attr& operator=(const packetl2c_bc_change_attr& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_bc_change_attr& default_instance();
void Swap(packetl2c_bc_change_attr* other);
// implements Message ----------------------------------------------
packetl2c_bc_change_attr* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_bc_change_attr& from);
void MergeFrom(const packetl2c_bc_change_attr& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bc_change_attr];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 player_id = 2;
inline bool has_player_id() const;
inline void clear_player_id();
static const int kPlayerIdFieldNumber = 2;
inline ::google::protobuf::int32 player_id() const;
inline void set_player_id(::google::protobuf::int32 value);
// optional int32 item_type = 3;
inline bool has_item_type() const;
inline void clear_item_type();
static const int kItemTypeFieldNumber = 3;
inline ::google::protobuf::int32 item_type() const;
inline void set_item_type(::google::protobuf::int32 value);
// optional int64 change_value = 4;
inline bool has_change_value() const;
inline void clear_change_value();
static const int kChangeValueFieldNumber = 4;
inline ::google::protobuf::int64 change_value() const;
inline void set_change_value(::google::protobuf::int64 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_bc_change_attr)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_player_id();
inline void clear_has_player_id();
inline void set_has_item_type();
inline void clear_has_item_type();
inline void set_has_change_value();
inline void clear_has_change_value();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 player_id_;
::google::protobuf::int64 change_value_;
::google::protobuf::int32 item_type_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(4 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_bc_change_attr* default_instance_;
};
// -------------------------------------------------------------------
class packetc2l_supply_chip : public ::google::protobuf::Message {
public:
packetc2l_supply_chip();
virtual ~packetc2l_supply_chip();
packetc2l_supply_chip(const packetc2l_supply_chip& from);
inline packetc2l_supply_chip& operator=(const packetc2l_supply_chip& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetc2l_supply_chip& default_instance();
void Swap(packetc2l_supply_chip* other);
// implements Message ----------------------------------------------
packetc2l_supply_chip* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetc2l_supply_chip& from);
void MergeFrom(const packetc2l_supply_chip& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_supply_chip];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetc2l_supply_chip)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetc2l_supply_chip* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_supply_chip_result : public ::google::protobuf::Message {
public:
packetl2c_supply_chip_result();
virtual ~packetl2c_supply_chip_result();
packetl2c_supply_chip_result(const packetl2c_supply_chip_result& from);
inline packetl2c_supply_chip_result& operator=(const packetl2c_supply_chip_result& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_supply_chip_result& default_instance();
void Swap(packetl2c_supply_chip_result* other);
// implements Message ----------------------------------------------
packetl2c_supply_chip_result* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_supply_chip_result& from);
void MergeFrom(const packetl2c_supply_chip_result& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_supply_chip_result];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional .msg_type_def.e_msg_result_def result = 2 [default = e_rmt_fail];
inline bool has_result() const;
inline void clear_result();
static const int kResultFieldNumber = 2;
inline ::msg_type_def::e_msg_result_def result() const;
inline void set_result(::msg_type_def::e_msg_result_def value);
// optional int64 gold = 6;
inline bool has_gold() const;
inline void clear_gold();
static const int kGoldFieldNumber = 6;
inline ::google::protobuf::int64 gold() const;
inline void set_gold(::google::protobuf::int64 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_supply_chip_result)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_result();
inline void clear_has_result();
inline void set_has_gold();
inline void clear_has_gold();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
int result_;
::google::protobuf::int64 gold_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_supply_chip_result* default_instance_;
};
// -------------------------------------------------------------------
class packetc2l_check_state : public ::google::protobuf::Message {
public:
packetc2l_check_state();
virtual ~packetc2l_check_state();
packetc2l_check_state(const packetc2l_check_state& from);
inline packetc2l_check_state& operator=(const packetc2l_check_state& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetc2l_check_state& default_instance();
void Swap(packetc2l_check_state* other);
// implements Message ----------------------------------------------
packetc2l_check_state* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetc2l_check_state& from);
void MergeFrom(const packetc2l_check_state& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_check_state];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetc2l_check_state)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetc2l_check_state* default_instance_;
};
// -------------------------------------------------------------------
class packetc2l_check_state_result : public ::google::protobuf::Message {
public:
packetc2l_check_state_result();
virtual ~packetc2l_check_state_result();
packetc2l_check_state_result(const packetc2l_check_state_result& from);
inline packetc2l_check_state_result& operator=(const packetc2l_check_state_result& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetc2l_check_state_result& default_instance();
void Swap(packetc2l_check_state_result* other);
// implements Message ----------------------------------------------
packetc2l_check_state_result* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetc2l_check_state_result& from);
void MergeFrom(const packetc2l_check_state_result& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_check_state_result];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 room_id = 2;
inline bool has_room_id() const;
inline void clear_room_id();
static const int kRoomIdFieldNumber = 2;
inline ::google::protobuf::int32 room_id() const;
inline void set_room_id(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetc2l_check_state_result)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_room_id();
inline void clear_has_room_id();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 room_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetc2l_check_state_result* default_instance_;
};
// -------------------------------------------------------------------
class msg_room_history : public ::google::protobuf::Message {
public:
msg_room_history();
virtual ~msg_room_history();
msg_room_history(const msg_room_history& from);
inline msg_room_history& operator=(const msg_room_history& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const msg_room_history& default_instance();
void Swap(msg_room_history* other);
// implements Message ----------------------------------------------
msg_room_history* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const msg_room_history& from);
void MergeFrom(const msg_room_history& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional int32 room_id = 1;
inline bool has_room_id() const;
inline void clear_room_id();
static const int kRoomIdFieldNumber = 1;
inline ::google::protobuf::int32 room_id() const;
inline void set_room_id(::google::protobuf::int32 value);
// optional int32 state = 2;
inline bool has_state() const;
inline void clear_state();
static const int kStateFieldNumber = 2;
inline ::google::protobuf::int32 state() const;
inline void set_state(::google::protobuf::int32 value);
// optional int32 cd = 3;
inline bool has_cd() const;
inline void clear_cd();
static const int kCdFieldNumber = 3;
inline ::google::protobuf::int32 cd() const;
inline void set_cd(::google::protobuf::int32 value);
// repeated int32 pos_list = 4;
inline int pos_list_size() const;
inline void clear_pos_list();
static const int kPosListFieldNumber = 4;
inline ::google::protobuf::int32 pos_list(int index) const;
inline void set_pos_list(int index, ::google::protobuf::int32 value);
inline void add_pos_list(::google::protobuf::int32 value);
inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
pos_list() const;
inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
mutable_pos_list();
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.msg_room_history)
private:
inline void set_has_room_id();
inline void clear_has_room_id();
inline void set_has_state();
inline void clear_has_state();
inline void set_has_cd();
inline void clear_has_cd();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::google::protobuf::int32 room_id_;
::google::protobuf::int32 state_;
::google::protobuf::RepeatedField< ::google::protobuf::int32 > pos_list_;
::google::protobuf::int32 cd_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(4 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static msg_room_history* default_instance_;
};
// -------------------------------------------------------------------
class packetc2l_room_history_list : public ::google::protobuf::Message {
public:
packetc2l_room_history_list();
virtual ~packetc2l_room_history_list();
packetc2l_room_history_list(const packetc2l_room_history_list& from);
inline packetc2l_room_history_list& operator=(const packetc2l_room_history_list& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetc2l_room_history_list& default_instance();
void Swap(packetc2l_room_history_list* other);
// implements Message ----------------------------------------------
packetc2l_room_history_list* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetc2l_room_history_list& from);
void MergeFrom(const packetc2l_room_history_list& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_room_history_list];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetc2l_room_history_list)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetc2l_room_history_list* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_room_history_list_result : public ::google::protobuf::Message {
public:
packetl2c_room_history_list_result();
virtual ~packetl2c_room_history_list_result();
packetl2c_room_history_list_result(const packetl2c_room_history_list_result& from);
inline packetl2c_room_history_list_result& operator=(const packetl2c_room_history_list_result& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_room_history_list_result& default_instance();
void Swap(packetl2c_room_history_list_result* other);
// implements Message ----------------------------------------------
packetl2c_room_history_list_result* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_room_history_list_result& from);
void MergeFrom(const packetl2c_room_history_list_result& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_room_history_list_result];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// repeated .game_rouletteak_protocols.msg_room_history history_list = 2;
inline int history_list_size() const;
inline void clear_history_list();
static const int kHistoryListFieldNumber = 2;
inline const ::game_rouletteak_protocols::msg_room_history& history_list(int index) const;
inline ::game_rouletteak_protocols::msg_room_history* mutable_history_list(int index);
inline ::game_rouletteak_protocols::msg_room_history* add_history_list();
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_room_history >&
history_list() const;
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_room_history >*
mutable_history_list();
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_room_history_list_result)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_room_history > history_list_;
int packet_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_room_history_list_result* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_notify_history : public ::google::protobuf::Message {
public:
packetl2c_notify_history();
virtual ~packetl2c_notify_history();
packetl2c_notify_history(const packetl2c_notify_history& from);
inline packetl2c_notify_history& operator=(const packetl2c_notify_history& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_notify_history& default_instance();
void Swap(packetl2c_notify_history* other);
// implements Message ----------------------------------------------
packetl2c_notify_history* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_notify_history& from);
void MergeFrom(const packetl2c_notify_history& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_notify_history];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 room_id = 2;
inline bool has_room_id() const;
inline void clear_room_id();
static const int kRoomIdFieldNumber = 2;
inline ::google::protobuf::int32 room_id() const;
inline void set_room_id(::google::protobuf::int32 value);
// optional int32 state = 3;
inline bool has_state() const;
inline void clear_state();
static const int kStateFieldNumber = 3;
inline ::google::protobuf::int32 state() const;
inline void set_state(::google::protobuf::int32 value);
// optional int32 cd = 4;
inline bool has_cd() const;
inline void clear_cd();
static const int kCdFieldNumber = 4;
inline ::google::protobuf::int32 cd() const;
inline void set_cd(::google::protobuf::int32 value);
// optional int32 pos = 5;
inline bool has_pos() const;
inline void clear_pos();
static const int kPosFieldNumber = 5;
inline ::google::protobuf::int32 pos() const;
inline void set_pos(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_notify_history)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_room_id();
inline void clear_has_room_id();
inline void set_has_state();
inline void clear_has_state();
inline void set_has_cd();
inline void clear_has_cd();
inline void set_has_pos();
inline void clear_has_pos();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 room_id_;
::google::protobuf::int32 state_;
::google::protobuf::int32 cd_;
::google::protobuf::int32 pos_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(5 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_notify_history* default_instance_;
};
// -------------------------------------------------------------------
class packetc2l_continue_bet : public ::google::protobuf::Message {
public:
packetc2l_continue_bet();
virtual ~packetc2l_continue_bet();
packetc2l_continue_bet(const packetc2l_continue_bet& from);
inline packetc2l_continue_bet& operator=(const packetc2l_continue_bet& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetc2l_continue_bet& default_instance();
void Swap(packetc2l_continue_bet* other);
// implements Message ----------------------------------------------
packetc2l_continue_bet* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetc2l_continue_bet& from);
void MergeFrom(const packetc2l_continue_bet& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_continue_bet];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetc2l_continue_bet)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetc2l_continue_bet* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_continue_bet_result : public ::google::protobuf::Message {
public:
packetl2c_continue_bet_result();
virtual ~packetl2c_continue_bet_result();
packetl2c_continue_bet_result(const packetl2c_continue_bet_result& from);
inline packetl2c_continue_bet_result& operator=(const packetl2c_continue_bet_result& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_continue_bet_result& default_instance();
void Swap(packetl2c_continue_bet_result* other);
// implements Message ----------------------------------------------
packetl2c_continue_bet_result* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_continue_bet_result& from);
void MergeFrom(const packetl2c_continue_bet_result& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_continue_bet_result];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional .msg_type_def.e_msg_result_def result = 2 [default = e_rmt_fail];
inline bool has_result() const;
inline void clear_result();
static const int kResultFieldNumber = 2;
inline ::msg_type_def::e_msg_result_def result() const;
inline void set_result(::msg_type_def::e_msg_result_def value);
// optional int64 cur_gold = 3;
inline bool has_cur_gold() const;
inline void clear_cur_gold();
static const int kCurGoldFieldNumber = 3;
inline ::google::protobuf::int64 cur_gold() const;
inline void set_cur_gold(::google::protobuf::int64 value);
// repeated .game_rouletteak_protocols.msg_bet_info bet_list = 4;
inline int bet_list_size() const;
inline void clear_bet_list();
static const int kBetListFieldNumber = 4;
inline const ::game_rouletteak_protocols::msg_bet_info& bet_list(int index) const;
inline ::game_rouletteak_protocols::msg_bet_info* mutable_bet_list(int index);
inline ::game_rouletteak_protocols::msg_bet_info* add_bet_list();
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info >&
bet_list() const;
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info >*
mutable_bet_list();
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_continue_bet_result)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_result();
inline void clear_has_result();
inline void set_has_cur_gold();
inline void clear_has_cur_gold();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
int result_;
::google::protobuf::int64 cur_gold_;
::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info > bet_list_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(4 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_continue_bet_result* default_instance_;
};
// -------------------------------------------------------------------
class packetc2l_cancel_bet : public ::google::protobuf::Message {
public:
packetc2l_cancel_bet();
virtual ~packetc2l_cancel_bet();
packetc2l_cancel_bet(const packetc2l_cancel_bet& from);
inline packetc2l_cancel_bet& operator=(const packetc2l_cancel_bet& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetc2l_cancel_bet& default_instance();
void Swap(packetc2l_cancel_bet* other);
// implements Message ----------------------------------------------
packetc2l_cancel_bet* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetc2l_cancel_bet& from);
void MergeFrom(const packetc2l_cancel_bet& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_cancel_bet];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 bet_pos = 2 [default = -1];
inline bool has_bet_pos() const;
inline void clear_bet_pos();
static const int kBetPosFieldNumber = 2;
inline ::google::protobuf::int32 bet_pos() const;
inline void set_bet_pos(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetc2l_cancel_bet)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_bet_pos();
inline void clear_has_bet_pos();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 bet_pos_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetc2l_cancel_bet* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_cancel_bet_result : public ::google::protobuf::Message {
public:
packetl2c_cancel_bet_result();
virtual ~packetl2c_cancel_bet_result();
packetl2c_cancel_bet_result(const packetl2c_cancel_bet_result& from);
inline packetl2c_cancel_bet_result& operator=(const packetl2c_cancel_bet_result& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_cancel_bet_result& default_instance();
void Swap(packetl2c_cancel_bet_result* other);
// implements Message ----------------------------------------------
packetl2c_cancel_bet_result* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_cancel_bet_result& from);
void MergeFrom(const packetl2c_cancel_bet_result& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_cancel_bet_result];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional .msg_type_def.e_msg_result_def result = 2 [default = e_rmt_fail];
inline bool has_result() const;
inline void clear_result();
static const int kResultFieldNumber = 2;
inline ::msg_type_def::e_msg_result_def result() const;
inline void set_result(::msg_type_def::e_msg_result_def value);
// optional int32 player_id = 3;
inline bool has_player_id() const;
inline void clear_player_id();
static const int kPlayerIdFieldNumber = 3;
inline ::google::protobuf::int32 player_id() const;
inline void set_player_id(::google::protobuf::int32 value);
// optional int64 cur_gold = 4;
inline bool has_cur_gold() const;
inline void clear_cur_gold();
static const int kCurGoldFieldNumber = 4;
inline ::google::protobuf::int64 cur_gold() const;
inline void set_cur_gold(::google::protobuf::int64 value);
// optional int32 bet_pos = 5;
inline bool has_bet_pos() const;
inline void clear_bet_pos();
static const int kBetPosFieldNumber = 5;
inline ::google::protobuf::int32 bet_pos() const;
inline void set_bet_pos(::google::protobuf::int32 value);
// optional int64 change_gold = 6;
inline bool has_change_gold() const;
inline void clear_change_gold();
static const int kChangeGoldFieldNumber = 6;
inline ::google::protobuf::int64 change_gold() const;
inline void set_change_gold(::google::protobuf::int64 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_cancel_bet_result)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_result();
inline void clear_has_result();
inline void set_has_player_id();
inline void clear_has_player_id();
inline void set_has_cur_gold();
inline void clear_has_cur_gold();
inline void set_has_bet_pos();
inline void clear_has_bet_pos();
inline void set_has_change_gold();
inline void clear_has_change_gold();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
int result_;
::google::protobuf::int64 cur_gold_;
::google::protobuf::int32 player_id_;
::google::protobuf::int32 bet_pos_;
::google::protobuf::int64 change_gold_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(6 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_cancel_bet_result* default_instance_;
};
// -------------------------------------------------------------------
class room_player : public ::google::protobuf::Message {
public:
room_player();
virtual ~room_player();
room_player(const room_player& from);
inline room_player& operator=(const room_player& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const room_player& default_instance();
void Swap(room_player* other);
// implements Message ----------------------------------------------
room_player* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const room_player& from);
void MergeFrom(const room_player& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional int32 player_id = 1;
inline bool has_player_id() const;
inline void clear_player_id();
static const int kPlayerIdFieldNumber = 1;
inline ::google::protobuf::int32 player_id() const;
inline void set_player_id(::google::protobuf::int32 value);
// optional int64 gold = 2;
inline bool has_gold() const;
inline void clear_gold();
static const int kGoldFieldNumber = 2;
inline ::google::protobuf::int64 gold() const;
inline void set_gold(::google::protobuf::int64 value);
// optional int64 profit_today = 3;
inline bool has_profit_today() const;
inline void clear_profit_today();
static const int kProfitTodayFieldNumber = 3;
inline ::google::protobuf::int64 profit_today() const;
inline void set_profit_today(::google::protobuf::int64 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.room_player)
private:
inline void set_has_player_id();
inline void clear_has_player_id();
inline void set_has_gold();
inline void clear_has_gold();
inline void set_has_profit_today();
inline void clear_has_profit_today();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::google::protobuf::int64 gold_;
::google::protobuf::int64 profit_today_;
::google::protobuf::int32 player_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static room_player* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_gm_get_room_info : public ::google::protobuf::Message {
public:
packetl2c_gm_get_room_info();
virtual ~packetl2c_gm_get_room_info();
packetl2c_gm_get_room_info(const packetl2c_gm_get_room_info& from);
inline packetl2c_gm_get_room_info& operator=(const packetl2c_gm_get_room_info& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_gm_get_room_info& default_instance();
void Swap(packetl2c_gm_get_room_info* other);
// implements Message ----------------------------------------------
packetl2c_gm_get_room_info* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_gm_get_room_info& from);
void MergeFrom(const packetl2c_gm_get_room_info& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_gm_get_room_info];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_gm_get_room_info)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_gm_get_room_info* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_gm_get_room_info_result : public ::google::protobuf::Message {
public:
packetl2c_gm_get_room_info_result();
virtual ~packetl2c_gm_get_room_info_result();
packetl2c_gm_get_room_info_result(const packetl2c_gm_get_room_info_result& from);
inline packetl2c_gm_get_room_info_result& operator=(const packetl2c_gm_get_room_info_result& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_gm_get_room_info_result& default_instance();
void Swap(packetl2c_gm_get_room_info_result* other);
// implements Message ----------------------------------------------
packetl2c_gm_get_room_info_result* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_gm_get_room_info_result& from);
void MergeFrom(const packetl2c_gm_get_room_info_result& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_gm_get_room_info_result];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 result = 2;
inline bool has_result() const;
inline void clear_result();
static const int kResultFieldNumber = 2;
inline ::google::protobuf::int32 result() const;
inline void set_result(::google::protobuf::int32 value);
// optional int32 bead_num = 3 [default = -1];
inline bool has_bead_num() const;
inline void clear_bead_num();
static const int kBeadNumFieldNumber = 3;
inline ::google::protobuf::int32 bead_num() const;
inline void set_bead_num(::google::protobuf::int32 value);
// repeated .game_rouletteak_protocols.room_player players = 4;
inline int players_size() const;
inline void clear_players();
static const int kPlayersFieldNumber = 4;
inline const ::game_rouletteak_protocols::room_player& players(int index) const;
inline ::game_rouletteak_protocols::room_player* mutable_players(int index);
inline ::game_rouletteak_protocols::room_player* add_players();
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::room_player >&
players() const;
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::room_player >*
mutable_players();
// optional int64 stock = 5;
inline bool has_stock() const;
inline void clear_stock();
static const int kStockFieldNumber = 5;
inline ::google::protobuf::int64 stock() const;
inline void set_stock(::google::protobuf::int64 value);
// optional int64 water = 6;
inline bool has_water() const;
inline void clear_water();
static const int kWaterFieldNumber = 6;
inline ::google::protobuf::int64 water() const;
inline void set_water(::google::protobuf::int64 value);
// optional int32 kill = 7;
inline bool has_kill() const;
inline void clear_kill();
static const int kKillFieldNumber = 7;
inline ::google::protobuf::int32 kill() const;
inline void set_kill(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_gm_get_room_info_result)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_result();
inline void clear_has_result();
inline void set_has_bead_num();
inline void clear_has_bead_num();
inline void set_has_stock();
inline void clear_has_stock();
inline void set_has_water();
inline void clear_has_water();
inline void set_has_kill();
inline void clear_has_kill();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 result_;
::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::room_player > players_;
::google::protobuf::int64 stock_;
::google::protobuf::int32 bead_num_;
::google::protobuf::int32 kill_;
::google::protobuf::int64 water_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(7 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_gm_get_room_info_result* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_gm_set_bead : public ::google::protobuf::Message {
public:
packetl2c_gm_set_bead();
virtual ~packetl2c_gm_set_bead();
packetl2c_gm_set_bead(const packetl2c_gm_set_bead& from);
inline packetl2c_gm_set_bead& operator=(const packetl2c_gm_set_bead& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_gm_set_bead& default_instance();
void Swap(packetl2c_gm_set_bead* other);
// implements Message ----------------------------------------------
packetl2c_gm_set_bead* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_gm_set_bead& from);
void MergeFrom(const packetl2c_gm_set_bead& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_gm_set_bead];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 bead_num = 2;
inline bool has_bead_num() const;
inline void clear_bead_num();
static const int kBeadNumFieldNumber = 2;
inline ::google::protobuf::int32 bead_num() const;
inline void set_bead_num(::google::protobuf::int32 value);
// optional int32 kill = 3;
inline bool has_kill() const;
inline void clear_kill();
static const int kKillFieldNumber = 3;
inline ::google::protobuf::int32 kill() const;
inline void set_kill(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_gm_set_bead)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_bead_num();
inline void clear_has_bead_num();
inline void set_has_kill();
inline void clear_has_kill();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 bead_num_;
::google::protobuf::int32 kill_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_gm_set_bead* default_instance_;
};
// -------------------------------------------------------------------
class packetl2c_gm_set_bead_result : public ::google::protobuf::Message {
public:
packetl2c_gm_set_bead_result();
virtual ~packetl2c_gm_set_bead_result();
packetl2c_gm_set_bead_result(const packetl2c_gm_set_bead_result& from);
inline packetl2c_gm_set_bead_result& operator=(const packetl2c_gm_set_bead_result& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const packetl2c_gm_set_bead_result& default_instance();
void Swap(packetl2c_gm_set_bead_result* other);
// implements Message ----------------------------------------------
packetl2c_gm_set_bead_result* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const packetl2c_gm_set_bead_result& from);
void MergeFrom(const packetl2c_gm_set_bead_result& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_gm_set_bead_result];
inline bool has_packet_id() const;
inline void clear_packet_id();
static const int kPacketIdFieldNumber = 1;
inline ::game_rouletteak_protocols::e_server_msg_type packet_id() const;
inline void set_packet_id(::game_rouletteak_protocols::e_server_msg_type value);
// optional int32 result = 2;
inline bool has_result() const;
inline void clear_result();
static const int kResultFieldNumber = 2;
inline ::google::protobuf::int32 result() const;
inline void set_result(::google::protobuf::int32 value);
// optional int32 bead_num = 3;
inline bool has_bead_num() const;
inline void clear_bead_num();
static const int kBeadNumFieldNumber = 3;
inline ::google::protobuf::int32 bead_num() const;
inline void set_bead_num(::google::protobuf::int32 value);
// optional int32 kill = 4;
inline bool has_kill() const;
inline void clear_kill();
static const int kKillFieldNumber = 4;
inline ::google::protobuf::int32 kill() const;
inline void set_kill(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:game_rouletteak_protocols.packetl2c_gm_set_bead_result)
private:
inline void set_has_packet_id();
inline void clear_has_packet_id();
inline void set_has_result();
inline void clear_has_result();
inline void set_has_bead_num();
inline void clear_has_bead_num();
inline void set_has_kill();
inline void clear_has_kill();
::google::protobuf::UnknownFieldSet _unknown_fields_;
int packet_id_;
::google::protobuf::int32 result_;
::google::protobuf::int32 bead_num_;
::google::protobuf::int32 kill_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(4 + 31) / 32];
friend void protobuf_AddDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_AssignDesc_game_5frouletteak_5fprotocol_2eproto();
friend void protobuf_ShutdownFile_game_5frouletteak_5fprotocol_2eproto();
void InitAsDefaultInstance();
static packetl2c_gm_set_bead_result* default_instance_;
};
// ===================================================================
// ===================================================================
// msg_room_info
// optional int32 roomid = 1;
inline bool msg_room_info::has_roomid() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void msg_room_info::set_has_roomid() {
_has_bits_[0] |= 0x00000001u;
}
inline void msg_room_info::clear_has_roomid() {
_has_bits_[0] &= ~0x00000001u;
}
inline void msg_room_info::clear_roomid() {
roomid_ = 0;
clear_has_roomid();
}
inline ::google::protobuf::int32 msg_room_info::roomid() const {
return roomid_;
}
inline void msg_room_info::set_roomid(::google::protobuf::int32 value) {
set_has_roomid();
roomid_ = value;
}
// -------------------------------------------------------------------
// packetc2l_get_room_info
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_get_room_info];
inline bool packetc2l_get_room_info::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetc2l_get_room_info::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetc2l_get_room_info::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetc2l_get_room_info::clear_packet_id() {
packet_id_ = 10014;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetc2l_get_room_info::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetc2l_get_room_info::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// -------------------------------------------------------------------
// packetl2c_get_room_info_result
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_get_room_info_result];
inline bool packetl2c_get_room_info_result::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_get_room_info_result::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_get_room_info_result::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_get_room_info_result::clear_packet_id() {
packet_id_ = 15058;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_get_room_info_result::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_get_room_info_result::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// repeated .game_rouletteak_protocols.msg_room_info room_list = 2;
inline int packetl2c_get_room_info_result::room_list_size() const {
return room_list_.size();
}
inline void packetl2c_get_room_info_result::clear_room_list() {
room_list_.Clear();
}
inline const ::game_rouletteak_protocols::msg_room_info& packetl2c_get_room_info_result::room_list(int index) const {
return room_list_.Get(index);
}
inline ::game_rouletteak_protocols::msg_room_info* packetl2c_get_room_info_result::mutable_room_list(int index) {
return room_list_.Mutable(index);
}
inline ::game_rouletteak_protocols::msg_room_info* packetl2c_get_room_info_result::add_room_list() {
return room_list_.Add();
}
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_room_info >&
packetl2c_get_room_info_result::room_list() const {
return room_list_;
}
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_room_info >*
packetl2c_get_room_info_result::mutable_room_list() {
return &room_list_;
}
// -------------------------------------------------------------------
// packetc2l_enter_room
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_enter_room];
inline bool packetc2l_enter_room::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetc2l_enter_room::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetc2l_enter_room::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetc2l_enter_room::clear_packet_id() {
packet_id_ = 10015;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetc2l_enter_room::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetc2l_enter_room::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 roomid = 2;
inline bool packetc2l_enter_room::has_roomid() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetc2l_enter_room::set_has_roomid() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetc2l_enter_room::clear_has_roomid() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetc2l_enter_room::clear_roomid() {
roomid_ = 0;
clear_has_roomid();
}
inline ::google::protobuf::int32 packetc2l_enter_room::roomid() const {
return roomid_;
}
inline void packetc2l_enter_room::set_roomid(::google::protobuf::int32 value) {
set_has_roomid();
roomid_ = value;
}
// -------------------------------------------------------------------
// packetl2c_enter_room_result
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_enter_room_result];
inline bool packetl2c_enter_room_result::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_enter_room_result::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_enter_room_result::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_enter_room_result::clear_packet_id() {
packet_id_ = 15059;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_enter_room_result::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_enter_room_result::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional .msg_type_def.e_msg_result_def result = 2 [default = e_rmt_fail];
inline bool packetl2c_enter_room_result::has_result() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_enter_room_result::set_has_result() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_enter_room_result::clear_has_result() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_enter_room_result::clear_result() {
result_ = 2;
clear_has_result();
}
inline ::msg_type_def::e_msg_result_def packetl2c_enter_room_result::result() const {
return static_cast< ::msg_type_def::e_msg_result_def >(result_);
}
inline void packetl2c_enter_room_result::set_result(::msg_type_def::e_msg_result_def value) {
assert(::msg_type_def::e_msg_result_def_IsValid(value));
set_has_result();
result_ = value;
}
// optional .game_rouletteak_protocols.msg_scene_info scene_info = 3;
inline bool packetl2c_enter_room_result::has_scene_info() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_enter_room_result::set_has_scene_info() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_enter_room_result::clear_has_scene_info() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_enter_room_result::clear_scene_info() {
if (scene_info_ != NULL) scene_info_->::game_rouletteak_protocols::msg_scene_info::Clear();
clear_has_scene_info();
}
inline const ::game_rouletteak_protocols::msg_scene_info& packetl2c_enter_room_result::scene_info() const {
return scene_info_ != NULL ? *scene_info_ : *default_instance_->scene_info_;
}
inline ::game_rouletteak_protocols::msg_scene_info* packetl2c_enter_room_result::mutable_scene_info() {
set_has_scene_info();
if (scene_info_ == NULL) scene_info_ = new ::game_rouletteak_protocols::msg_scene_info;
return scene_info_;
}
inline ::game_rouletteak_protocols::msg_scene_info* packetl2c_enter_room_result::release_scene_info() {
clear_has_scene_info();
::game_rouletteak_protocols::msg_scene_info* temp = scene_info_;
scene_info_ = NULL;
return temp;
}
inline void packetl2c_enter_room_result::set_allocated_scene_info(::game_rouletteak_protocols::msg_scene_info* scene_info) {
delete scene_info_;
scene_info_ = scene_info;
if (scene_info) {
set_has_scene_info();
} else {
clear_has_scene_info();
}
}
// optional int64 self_gold = 4;
inline bool packetl2c_enter_room_result::has_self_gold() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void packetl2c_enter_room_result::set_has_self_gold() {
_has_bits_[0] |= 0x00000008u;
}
inline void packetl2c_enter_room_result::clear_has_self_gold() {
_has_bits_[0] &= ~0x00000008u;
}
inline void packetl2c_enter_room_result::clear_self_gold() {
self_gold_ = GOOGLE_LONGLONG(0);
clear_has_self_gold();
}
inline ::google::protobuf::int64 packetl2c_enter_room_result::self_gold() const {
return self_gold_;
}
inline void packetl2c_enter_room_result::set_self_gold(::google::protobuf::int64 value) {
set_has_self_gold();
self_gold_ = value;
}
// -------------------------------------------------------------------
// packetc2l_leave_room
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_leave_room];
inline bool packetc2l_leave_room::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetc2l_leave_room::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetc2l_leave_room::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetc2l_leave_room::clear_packet_id() {
packet_id_ = 10016;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetc2l_leave_room::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetc2l_leave_room::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// -------------------------------------------------------------------
// packetl2c_leave_room_result
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_leave_room_result];
inline bool packetl2c_leave_room_result::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_leave_room_result::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_leave_room_result::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_leave_room_result::clear_packet_id() {
packet_id_ = 15060;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_leave_room_result::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_leave_room_result::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional .msg_type_def.e_msg_result_def result = 2 [default = e_rmt_success];
inline bool packetl2c_leave_room_result::has_result() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_leave_room_result::set_has_result() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_leave_room_result::clear_has_result() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_leave_room_result::clear_result() {
result_ = 1;
clear_has_result();
}
inline ::msg_type_def::e_msg_result_def packetl2c_leave_room_result::result() const {
return static_cast< ::msg_type_def::e_msg_result_def >(result_);
}
inline void packetl2c_leave_room_result::set_result(::msg_type_def::e_msg_result_def value) {
assert(::msg_type_def::e_msg_result_def_IsValid(value));
set_has_result();
result_ = value;
}
// optional int64 player_gold = 3;
inline bool packetl2c_leave_room_result::has_player_gold() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_leave_room_result::set_has_player_gold() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_leave_room_result::clear_has_player_gold() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_leave_room_result::clear_player_gold() {
player_gold_ = GOOGLE_LONGLONG(0);
clear_has_player_gold();
}
inline ::google::protobuf::int64 packetl2c_leave_room_result::player_gold() const {
return player_gold_;
}
inline void packetl2c_leave_room_result::set_player_gold(::google::protobuf::int64 value) {
set_has_player_gold();
player_gold_ = value;
}
// -------------------------------------------------------------------
// msg_player_info
// optional int32 player_id = 1;
inline bool msg_player_info::has_player_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void msg_player_info::set_has_player_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void msg_player_info::clear_has_player_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void msg_player_info::clear_player_id() {
player_id_ = 0;
clear_has_player_id();
}
inline ::google::protobuf::int32 msg_player_info::player_id() const {
return player_id_;
}
inline void msg_player_info::set_player_id(::google::protobuf::int32 value) {
set_has_player_id();
player_id_ = value;
}
// optional string player_name = 2;
inline bool msg_player_info::has_player_name() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void msg_player_info::set_has_player_name() {
_has_bits_[0] |= 0x00000002u;
}
inline void msg_player_info::clear_has_player_name() {
_has_bits_[0] &= ~0x00000002u;
}
inline void msg_player_info::clear_player_name() {
if (player_name_ != &::google::protobuf::internal::kEmptyString) {
player_name_->clear();
}
clear_has_player_name();
}
inline const ::std::string& msg_player_info::player_name() const {
return *player_name_;
}
inline void msg_player_info::set_player_name(const ::std::string& value) {
set_has_player_name();
if (player_name_ == &::google::protobuf::internal::kEmptyString) {
player_name_ = new ::std::string;
}
player_name_->assign(value);
}
inline void msg_player_info::set_player_name(const char* value) {
set_has_player_name();
if (player_name_ == &::google::protobuf::internal::kEmptyString) {
player_name_ = new ::std::string;
}
player_name_->assign(value);
}
inline void msg_player_info::set_player_name(const char* value, size_t size) {
set_has_player_name();
if (player_name_ == &::google::protobuf::internal::kEmptyString) {
player_name_ = new ::std::string;
}
player_name_->assign(reinterpret_cast<const char*>(value), size);
}
inline ::std::string* msg_player_info::mutable_player_name() {
set_has_player_name();
if (player_name_ == &::google::protobuf::internal::kEmptyString) {
player_name_ = new ::std::string;
}
return player_name_;
}
inline ::std::string* msg_player_info::release_player_name() {
clear_has_player_name();
if (player_name_ == &::google::protobuf::internal::kEmptyString) {
return NULL;
} else {
::std::string* temp = player_name_;
player_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
return temp;
}
}
inline void msg_player_info::set_allocated_player_name(::std::string* player_name) {
if (player_name_ != &::google::protobuf::internal::kEmptyString) {
delete player_name_;
}
if (player_name) {
set_has_player_name();
player_name_ = player_name;
} else {
clear_has_player_name();
player_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
}
}
// optional int32 head_frame = 3;
inline bool msg_player_info::has_head_frame() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void msg_player_info::set_has_head_frame() {
_has_bits_[0] |= 0x00000004u;
}
inline void msg_player_info::clear_has_head_frame() {
_has_bits_[0] &= ~0x00000004u;
}
inline void msg_player_info::clear_head_frame() {
head_frame_ = 0;
clear_has_head_frame();
}
inline ::google::protobuf::int32 msg_player_info::head_frame() const {
return head_frame_;
}
inline void msg_player_info::set_head_frame(::google::protobuf::int32 value) {
set_has_head_frame();
head_frame_ = value;
}
// optional string head_custom = 4;
inline bool msg_player_info::has_head_custom() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void msg_player_info::set_has_head_custom() {
_has_bits_[0] |= 0x00000008u;
}
inline void msg_player_info::clear_has_head_custom() {
_has_bits_[0] &= ~0x00000008u;
}
inline void msg_player_info::clear_head_custom() {
if (head_custom_ != &::google::protobuf::internal::kEmptyString) {
head_custom_->clear();
}
clear_has_head_custom();
}
inline const ::std::string& msg_player_info::head_custom() const {
return *head_custom_;
}
inline void msg_player_info::set_head_custom(const ::std::string& value) {
set_has_head_custom();
if (head_custom_ == &::google::protobuf::internal::kEmptyString) {
head_custom_ = new ::std::string;
}
head_custom_->assign(value);
}
inline void msg_player_info::set_head_custom(const char* value) {
set_has_head_custom();
if (head_custom_ == &::google::protobuf::internal::kEmptyString) {
head_custom_ = new ::std::string;
}
head_custom_->assign(value);
}
inline void msg_player_info::set_head_custom(const char* value, size_t size) {
set_has_head_custom();
if (head_custom_ == &::google::protobuf::internal::kEmptyString) {
head_custom_ = new ::std::string;
}
head_custom_->assign(reinterpret_cast<const char*>(value), size);
}
inline ::std::string* msg_player_info::mutable_head_custom() {
set_has_head_custom();
if (head_custom_ == &::google::protobuf::internal::kEmptyString) {
head_custom_ = new ::std::string;
}
return head_custom_;
}
inline ::std::string* msg_player_info::release_head_custom() {
clear_has_head_custom();
if (head_custom_ == &::google::protobuf::internal::kEmptyString) {
return NULL;
} else {
::std::string* temp = head_custom_;
head_custom_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
return temp;
}
}
inline void msg_player_info::set_allocated_head_custom(::std::string* head_custom) {
if (head_custom_ != &::google::protobuf::internal::kEmptyString) {
delete head_custom_;
}
if (head_custom) {
set_has_head_custom();
head_custom_ = head_custom;
} else {
clear_has_head_custom();
head_custom_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
}
}
// optional int64 player_gold = 5;
inline bool msg_player_info::has_player_gold() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void msg_player_info::set_has_player_gold() {
_has_bits_[0] |= 0x00000010u;
}
inline void msg_player_info::clear_has_player_gold() {
_has_bits_[0] &= ~0x00000010u;
}
inline void msg_player_info::clear_player_gold() {
player_gold_ = GOOGLE_LONGLONG(0);
clear_has_player_gold();
}
inline ::google::protobuf::int64 msg_player_info::player_gold() const {
return player_gold_;
}
inline void msg_player_info::set_player_gold(::google::protobuf::int64 value) {
set_has_player_gold();
player_gold_ = value;
}
// optional int32 player_sex = 6;
inline bool msg_player_info::has_player_sex() const {
return (_has_bits_[0] & 0x00000020u) != 0;
}
inline void msg_player_info::set_has_player_sex() {
_has_bits_[0] |= 0x00000020u;
}
inline void msg_player_info::clear_has_player_sex() {
_has_bits_[0] &= ~0x00000020u;
}
inline void msg_player_info::clear_player_sex() {
player_sex_ = 0;
clear_has_player_sex();
}
inline ::google::protobuf::int32 msg_player_info::player_sex() const {
return player_sex_;
}
inline void msg_player_info::set_player_sex(::google::protobuf::int32 value) {
set_has_player_sex();
player_sex_ = value;
}
// optional int32 vip_level = 7;
inline bool msg_player_info::has_vip_level() const {
return (_has_bits_[0] & 0x00000040u) != 0;
}
inline void msg_player_info::set_has_vip_level() {
_has_bits_[0] |= 0x00000040u;
}
inline void msg_player_info::clear_has_vip_level() {
_has_bits_[0] &= ~0x00000040u;
}
inline void msg_player_info::clear_vip_level() {
vip_level_ = 0;
clear_has_vip_level();
}
inline ::google::protobuf::int32 msg_player_info::vip_level() const {
return vip_level_;
}
inline void msg_player_info::set_vip_level(::google::protobuf::int32 value) {
set_has_vip_level();
vip_level_ = value;
}
// optional int32 history_bet_gold = 8;
inline bool msg_player_info::has_history_bet_gold() const {
return (_has_bits_[0] & 0x00000080u) != 0;
}
inline void msg_player_info::set_has_history_bet_gold() {
_has_bits_[0] |= 0x00000080u;
}
inline void msg_player_info::clear_has_history_bet_gold() {
_has_bits_[0] &= ~0x00000080u;
}
inline void msg_player_info::clear_history_bet_gold() {
history_bet_gold_ = 0;
clear_has_history_bet_gold();
}
inline ::google::protobuf::int32 msg_player_info::history_bet_gold() const {
return history_bet_gold_;
}
inline void msg_player_info::set_history_bet_gold(::google::protobuf::int32 value) {
set_has_history_bet_gold();
history_bet_gold_ = value;
}
// optional int32 win_count = 9;
inline bool msg_player_info::has_win_count() const {
return (_has_bits_[0] & 0x00000100u) != 0;
}
inline void msg_player_info::set_has_win_count() {
_has_bits_[0] |= 0x00000100u;
}
inline void msg_player_info::clear_has_win_count() {
_has_bits_[0] &= ~0x00000100u;
}
inline void msg_player_info::clear_win_count() {
win_count_ = 0;
clear_has_win_count();
}
inline ::google::protobuf::int32 msg_player_info::win_count() const {
return win_count_;
}
inline void msg_player_info::set_win_count(::google::protobuf::int32 value) {
set_has_win_count();
win_count_ = value;
}
// -------------------------------------------------------------------
// msg_bet_info
// optional int32 player_id = 1;
inline bool msg_bet_info::has_player_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void msg_bet_info::set_has_player_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void msg_bet_info::clear_has_player_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void msg_bet_info::clear_player_id() {
player_id_ = 0;
clear_has_player_id();
}
inline ::google::protobuf::int32 msg_bet_info::player_id() const {
return player_id_;
}
inline void msg_bet_info::set_player_id(::google::protobuf::int32 value) {
set_has_player_id();
player_id_ = value;
}
// optional int32 bet_pos = 2;
inline bool msg_bet_info::has_bet_pos() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void msg_bet_info::set_has_bet_pos() {
_has_bits_[0] |= 0x00000002u;
}
inline void msg_bet_info::clear_has_bet_pos() {
_has_bits_[0] &= ~0x00000002u;
}
inline void msg_bet_info::clear_bet_pos() {
bet_pos_ = 0;
clear_has_bet_pos();
}
inline ::google::protobuf::int32 msg_bet_info::bet_pos() const {
return bet_pos_;
}
inline void msg_bet_info::set_bet_pos(::google::protobuf::int32 value) {
set_has_bet_pos();
bet_pos_ = value;
}
// optional int64 bet_gold = 3;
inline bool msg_bet_info::has_bet_gold() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void msg_bet_info::set_has_bet_gold() {
_has_bits_[0] |= 0x00000004u;
}
inline void msg_bet_info::clear_has_bet_gold() {
_has_bits_[0] &= ~0x00000004u;
}
inline void msg_bet_info::clear_bet_gold() {
bet_gold_ = GOOGLE_LONGLONG(0);
clear_has_bet_gold();
}
inline ::google::protobuf::int64 msg_bet_info::bet_gold() const {
return bet_gold_;
}
inline void msg_bet_info::set_bet_gold(::google::protobuf::int64 value) {
set_has_bet_gold();
bet_gold_ = value;
}
// optional int64 cur_gold = 4;
inline bool msg_bet_info::has_cur_gold() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void msg_bet_info::set_has_cur_gold() {
_has_bits_[0] |= 0x00000008u;
}
inline void msg_bet_info::clear_has_cur_gold() {
_has_bits_[0] &= ~0x00000008u;
}
inline void msg_bet_info::clear_cur_gold() {
cur_gold_ = GOOGLE_LONGLONG(0);
clear_has_cur_gold();
}
inline ::google::protobuf::int64 msg_bet_info::cur_gold() const {
return cur_gold_;
}
inline void msg_bet_info::set_cur_gold(::google::protobuf::int64 value) {
set_has_cur_gold();
cur_gold_ = value;
}
// optional int32 chip_index = 5;
inline bool msg_bet_info::has_chip_index() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void msg_bet_info::set_has_chip_index() {
_has_bits_[0] |= 0x00000010u;
}
inline void msg_bet_info::clear_has_chip_index() {
_has_bits_[0] &= ~0x00000010u;
}
inline void msg_bet_info::clear_chip_index() {
chip_index_ = 0;
clear_has_chip_index();
}
inline ::google::protobuf::int32 msg_bet_info::chip_index() const {
return chip_index_;
}
inline void msg_bet_info::set_chip_index(::google::protobuf::int32 value) {
set_has_chip_index();
chip_index_ = value;
}
// -------------------------------------------------------------------
// msg_player_gold
// optional int32 player_id = 1;
inline bool msg_player_gold::has_player_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void msg_player_gold::set_has_player_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void msg_player_gold::clear_has_player_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void msg_player_gold::clear_player_id() {
player_id_ = 0;
clear_has_player_id();
}
inline ::google::protobuf::int32 msg_player_gold::player_id() const {
return player_id_;
}
inline void msg_player_gold::set_player_id(::google::protobuf::int32 value) {
set_has_player_id();
player_id_ = value;
}
// optional int64 win_gold = 2;
inline bool msg_player_gold::has_win_gold() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void msg_player_gold::set_has_win_gold() {
_has_bits_[0] |= 0x00000002u;
}
inline void msg_player_gold::clear_has_win_gold() {
_has_bits_[0] &= ~0x00000002u;
}
inline void msg_player_gold::clear_win_gold() {
win_gold_ = GOOGLE_LONGLONG(0);
clear_has_win_gold();
}
inline ::google::protobuf::int64 msg_player_gold::win_gold() const {
return win_gold_;
}
inline void msg_player_gold::set_win_gold(::google::protobuf::int64 value) {
set_has_win_gold();
win_gold_ = value;
}
// optional int64 cur_gold = 3;
inline bool msg_player_gold::has_cur_gold() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void msg_player_gold::set_has_cur_gold() {
_has_bits_[0] |= 0x00000004u;
}
inline void msg_player_gold::clear_has_cur_gold() {
_has_bits_[0] &= ~0x00000004u;
}
inline void msg_player_gold::clear_cur_gold() {
cur_gold_ = GOOGLE_LONGLONG(0);
clear_has_cur_gold();
}
inline ::google::protobuf::int64 msg_player_gold::cur_gold() const {
return cur_gold_;
}
inline void msg_player_gold::set_cur_gold(::google::protobuf::int64 value) {
set_has_cur_gold();
cur_gold_ = value;
}
// optional int32 history_bet_gold = 4;
inline bool msg_player_gold::has_history_bet_gold() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void msg_player_gold::set_has_history_bet_gold() {
_has_bits_[0] |= 0x00000008u;
}
inline void msg_player_gold::clear_has_history_bet_gold() {
_has_bits_[0] &= ~0x00000008u;
}
inline void msg_player_gold::clear_history_bet_gold() {
history_bet_gold_ = 0;
clear_has_history_bet_gold();
}
inline ::google::protobuf::int32 msg_player_gold::history_bet_gold() const {
return history_bet_gold_;
}
inline void msg_player_gold::set_history_bet_gold(::google::protobuf::int32 value) {
set_has_history_bet_gold();
history_bet_gold_ = value;
}
// optional int64 win_count = 5;
inline bool msg_player_gold::has_win_count() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void msg_player_gold::set_has_win_count() {
_has_bits_[0] |= 0x00000010u;
}
inline void msg_player_gold::clear_has_win_count() {
_has_bits_[0] &= ~0x00000010u;
}
inline void msg_player_gold::clear_win_count() {
win_count_ = GOOGLE_LONGLONG(0);
clear_has_win_count();
}
inline ::google::protobuf::int64 msg_player_gold::win_count() const {
return win_count_;
}
inline void msg_player_gold::set_win_count(::google::protobuf::int64 value) {
set_has_win_count();
win_count_ = value;
}
// -------------------------------------------------------------------
// msg_result_info
// optional int32 number = 1;
inline bool msg_result_info::has_number() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void msg_result_info::set_has_number() {
_has_bits_[0] |= 0x00000001u;
}
inline void msg_result_info::clear_has_number() {
_has_bits_[0] &= ~0x00000001u;
}
inline void msg_result_info::clear_number() {
number_ = 0;
clear_has_number();
}
inline ::google::protobuf::int32 msg_result_info::number() const {
return number_;
}
inline void msg_result_info::set_number(::google::protobuf::int32 value) {
set_has_number();
number_ = value;
}
// repeated .game_rouletteak_protocols.msg_player_gold player_golds = 2;
inline int msg_result_info::player_golds_size() const {
return player_golds_.size();
}
inline void msg_result_info::clear_player_golds() {
player_golds_.Clear();
}
inline const ::game_rouletteak_protocols::msg_player_gold& msg_result_info::player_golds(int index) const {
return player_golds_.Get(index);
}
inline ::game_rouletteak_protocols::msg_player_gold* msg_result_info::mutable_player_golds(int index) {
return player_golds_.Mutable(index);
}
inline ::game_rouletteak_protocols::msg_player_gold* msg_result_info::add_player_golds() {
return player_golds_.Add();
}
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_player_gold >&
msg_result_info::player_golds() const {
return player_golds_;
}
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_player_gold >*
msg_result_info::mutable_player_golds() {
return &player_golds_;
}
// -------------------------------------------------------------------
// msg_scene_info
// optional int32 roomid = 1;
inline bool msg_scene_info::has_roomid() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void msg_scene_info::set_has_roomid() {
_has_bits_[0] |= 0x00000001u;
}
inline void msg_scene_info::clear_has_roomid() {
_has_bits_[0] &= ~0x00000001u;
}
inline void msg_scene_info::clear_roomid() {
roomid_ = 0;
clear_has_roomid();
}
inline ::google::protobuf::int32 msg_scene_info::roomid() const {
return roomid_;
}
inline void msg_scene_info::set_roomid(::google::protobuf::int32 value) {
set_has_roomid();
roomid_ = value;
}
// optional int32 scene_state = 2;
inline bool msg_scene_info::has_scene_state() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void msg_scene_info::set_has_scene_state() {
_has_bits_[0] |= 0x00000002u;
}
inline void msg_scene_info::clear_has_scene_state() {
_has_bits_[0] &= ~0x00000002u;
}
inline void msg_scene_info::clear_scene_state() {
scene_state_ = 0;
clear_has_scene_state();
}
inline ::google::protobuf::int32 msg_scene_info::scene_state() const {
return scene_state_;
}
inline void msg_scene_info::set_scene_state(::google::protobuf::int32 value) {
set_has_scene_state();
scene_state_ = value;
}
// optional int32 cd = 3;
inline bool msg_scene_info::has_cd() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void msg_scene_info::set_has_cd() {
_has_bits_[0] |= 0x00000004u;
}
inline void msg_scene_info::clear_has_cd() {
_has_bits_[0] &= ~0x00000004u;
}
inline void msg_scene_info::clear_cd() {
cd_ = 0;
clear_has_cd();
}
inline ::google::protobuf::int32 msg_scene_info::cd() const {
return cd_;
}
inline void msg_scene_info::set_cd(::google::protobuf::int32 value) {
set_has_cd();
cd_ = value;
}
// repeated .game_rouletteak_protocols.msg_player_info player_list = 4;
inline int msg_scene_info::player_list_size() const {
return player_list_.size();
}
inline void msg_scene_info::clear_player_list() {
player_list_.Clear();
}
inline const ::game_rouletteak_protocols::msg_player_info& msg_scene_info::player_list(int index) const {
return player_list_.Get(index);
}
inline ::game_rouletteak_protocols::msg_player_info* msg_scene_info::mutable_player_list(int index) {
return player_list_.Mutable(index);
}
inline ::game_rouletteak_protocols::msg_player_info* msg_scene_info::add_player_list() {
return player_list_.Add();
}
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_player_info >&
msg_scene_info::player_list() const {
return player_list_;
}
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_player_info >*
msg_scene_info::mutable_player_list() {
return &player_list_;
}
// repeated .game_rouletteak_protocols.msg_bet_info bet_infos = 5;
inline int msg_scene_info::bet_infos_size() const {
return bet_infos_.size();
}
inline void msg_scene_info::clear_bet_infos() {
bet_infos_.Clear();
}
inline const ::game_rouletteak_protocols::msg_bet_info& msg_scene_info::bet_infos(int index) const {
return bet_infos_.Get(index);
}
inline ::game_rouletteak_protocols::msg_bet_info* msg_scene_info::mutable_bet_infos(int index) {
return bet_infos_.Mutable(index);
}
inline ::game_rouletteak_protocols::msg_bet_info* msg_scene_info::add_bet_infos() {
return bet_infos_.Add();
}
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info >&
msg_scene_info::bet_infos() const {
return bet_infos_;
}
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info >*
msg_scene_info::mutable_bet_infos() {
return &bet_infos_;
}
// optional .game_rouletteak_protocols.msg_result_info result_info = 6;
inline bool msg_scene_info::has_result_info() const {
return (_has_bits_[0] & 0x00000020u) != 0;
}
inline void msg_scene_info::set_has_result_info() {
_has_bits_[0] |= 0x00000020u;
}
inline void msg_scene_info::clear_has_result_info() {
_has_bits_[0] &= ~0x00000020u;
}
inline void msg_scene_info::clear_result_info() {
if (result_info_ != NULL) result_info_->::game_rouletteak_protocols::msg_result_info::Clear();
clear_has_result_info();
}
inline const ::game_rouletteak_protocols::msg_result_info& msg_scene_info::result_info() const {
return result_info_ != NULL ? *result_info_ : *default_instance_->result_info_;
}
inline ::game_rouletteak_protocols::msg_result_info* msg_scene_info::mutable_result_info() {
set_has_result_info();
if (result_info_ == NULL) result_info_ = new ::game_rouletteak_protocols::msg_result_info;
return result_info_;
}
inline ::game_rouletteak_protocols::msg_result_info* msg_scene_info::release_result_info() {
clear_has_result_info();
::game_rouletteak_protocols::msg_result_info* temp = result_info_;
result_info_ = NULL;
return temp;
}
inline void msg_scene_info::set_allocated_result_info(::game_rouletteak_protocols::msg_result_info* result_info) {
delete result_info_;
result_info_ = result_info;
if (result_info) {
set_has_result_info();
} else {
clear_has_result_info();
}
}
// repeated int32 pos_list = 7;
inline int msg_scene_info::pos_list_size() const {
return pos_list_.size();
}
inline void msg_scene_info::clear_pos_list() {
pos_list_.Clear();
}
inline ::google::protobuf::int32 msg_scene_info::pos_list(int index) const {
return pos_list_.Get(index);
}
inline void msg_scene_info::set_pos_list(int index, ::google::protobuf::int32 value) {
pos_list_.Set(index, value);
}
inline void msg_scene_info::add_pos_list(::google::protobuf::int32 value) {
pos_list_.Add(value);
}
inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
msg_scene_info::pos_list() const {
return pos_list_;
}
inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
msg_scene_info::mutable_pos_list() {
return &pos_list_;
}
// optional int64 bet_gold_room = 8;
inline bool msg_scene_info::has_bet_gold_room() const {
return (_has_bits_[0] & 0x00000080u) != 0;
}
inline void msg_scene_info::set_has_bet_gold_room() {
_has_bits_[0] |= 0x00000080u;
}
inline void msg_scene_info::clear_has_bet_gold_room() {
_has_bits_[0] &= ~0x00000080u;
}
inline void msg_scene_info::clear_bet_gold_room() {
bet_gold_room_ = GOOGLE_LONGLONG(0);
clear_has_bet_gold_room();
}
inline ::google::protobuf::int64 msg_scene_info::bet_gold_room() const {
return bet_gold_room_;
}
inline void msg_scene_info::set_bet_gold_room(::google::protobuf::int64 value) {
set_has_bet_gold_room();
bet_gold_room_ = value;
}
// optional int64 bet_gold_self = 9;
inline bool msg_scene_info::has_bet_gold_self() const {
return (_has_bits_[0] & 0x00000100u) != 0;
}
inline void msg_scene_info::set_has_bet_gold_self() {
_has_bits_[0] |= 0x00000100u;
}
inline void msg_scene_info::clear_has_bet_gold_self() {
_has_bits_[0] &= ~0x00000100u;
}
inline void msg_scene_info::clear_bet_gold_self() {
bet_gold_self_ = GOOGLE_LONGLONG(0);
clear_has_bet_gold_self();
}
inline ::google::protobuf::int64 msg_scene_info::bet_gold_self() const {
return bet_gold_self_;
}
inline void msg_scene_info::set_bet_gold_self(::google::protobuf::int64 value) {
set_has_bet_gold_self();
bet_gold_self_ = value;
}
// -------------------------------------------------------------------
// packetc2l_get_scene_info
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_get_scene_info];
inline bool packetc2l_get_scene_info::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetc2l_get_scene_info::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetc2l_get_scene_info::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetc2l_get_scene_info::clear_packet_id() {
packet_id_ = 10001;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetc2l_get_scene_info::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetc2l_get_scene_info::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// -------------------------------------------------------------------
// packetl2c_get_scene_info_result
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_get_scene_info_result];
inline bool packetl2c_get_scene_info_result::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_get_scene_info_result::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_get_scene_info_result::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_get_scene_info_result::clear_packet_id() {
packet_id_ = 15001;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_get_scene_info_result::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_get_scene_info_result::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional .game_rouletteak_protocols.msg_scene_info scene_info = 2;
inline bool packetl2c_get_scene_info_result::has_scene_info() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_get_scene_info_result::set_has_scene_info() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_get_scene_info_result::clear_has_scene_info() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_get_scene_info_result::clear_scene_info() {
if (scene_info_ != NULL) scene_info_->::game_rouletteak_protocols::msg_scene_info::Clear();
clear_has_scene_info();
}
inline const ::game_rouletteak_protocols::msg_scene_info& packetl2c_get_scene_info_result::scene_info() const {
return scene_info_ != NULL ? *scene_info_ : *default_instance_->scene_info_;
}
inline ::game_rouletteak_protocols::msg_scene_info* packetl2c_get_scene_info_result::mutable_scene_info() {
set_has_scene_info();
if (scene_info_ == NULL) scene_info_ = new ::game_rouletteak_protocols::msg_scene_info;
return scene_info_;
}
inline ::game_rouletteak_protocols::msg_scene_info* packetl2c_get_scene_info_result::release_scene_info() {
clear_has_scene_info();
::game_rouletteak_protocols::msg_scene_info* temp = scene_info_;
scene_info_ = NULL;
return temp;
}
inline void packetl2c_get_scene_info_result::set_allocated_scene_info(::game_rouletteak_protocols::msg_scene_info* scene_info) {
delete scene_info_;
scene_info_ = scene_info;
if (scene_info) {
set_has_scene_info();
} else {
clear_has_scene_info();
}
}
// optional int64 self_gold = 3;
inline bool packetl2c_get_scene_info_result::has_self_gold() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_get_scene_info_result::set_has_self_gold() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_get_scene_info_result::clear_has_self_gold() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_get_scene_info_result::clear_self_gold() {
self_gold_ = GOOGLE_LONGLONG(0);
clear_has_self_gold();
}
inline ::google::protobuf::int64 packetl2c_get_scene_info_result::self_gold() const {
return self_gold_;
}
inline void packetl2c_get_scene_info_result::set_self_gold(::google::protobuf::int64 value) {
set_has_self_gold();
self_gold_ = value;
}
// -------------------------------------------------------------------
// packetl2c_bc_scene_prepare_into
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bc_scene_prepare_into];
inline bool packetl2c_bc_scene_prepare_into::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_bc_scene_prepare_into::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_bc_scene_prepare_into::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_bc_scene_prepare_into::clear_packet_id() {
packet_id_ = 15050;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_bc_scene_prepare_into::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_bc_scene_prepare_into::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 cd = 2;
inline bool packetl2c_bc_scene_prepare_into::has_cd() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_bc_scene_prepare_into::set_has_cd() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_bc_scene_prepare_into::clear_has_cd() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_bc_scene_prepare_into::clear_cd() {
cd_ = 0;
clear_has_cd();
}
inline ::google::protobuf::int32 packetl2c_bc_scene_prepare_into::cd() const {
return cd_;
}
inline void packetl2c_bc_scene_prepare_into::set_cd(::google::protobuf::int32 value) {
set_has_cd();
cd_ = value;
}
// -------------------------------------------------------------------
// packetl2c_bc_scene_bet_into
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bc_scene_bet_into];
inline bool packetl2c_bc_scene_bet_into::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_bc_scene_bet_into::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_bc_scene_bet_into::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_bc_scene_bet_into::clear_packet_id() {
packet_id_ = 15051;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_bc_scene_bet_into::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_bc_scene_bet_into::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 cd = 2;
inline bool packetl2c_bc_scene_bet_into::has_cd() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_bc_scene_bet_into::set_has_cd() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_bc_scene_bet_into::clear_has_cd() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_bc_scene_bet_into::clear_cd() {
cd_ = 0;
clear_has_cd();
}
inline ::google::protobuf::int32 packetl2c_bc_scene_bet_into::cd() const {
return cd_;
}
inline void packetl2c_bc_scene_bet_into::set_cd(::google::protobuf::int32 value) {
set_has_cd();
cd_ = value;
}
// -------------------------------------------------------------------
// packetl2c_bc_sync_scene_bet_into
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bc_sync_scene_bet_into];
inline bool packetl2c_bc_sync_scene_bet_into::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_bc_sync_scene_bet_into::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_bc_sync_scene_bet_into::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_bc_sync_scene_bet_into::clear_packet_id() {
packet_id_ = 15052;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_bc_sync_scene_bet_into::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_bc_sync_scene_bet_into::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// repeated .game_rouletteak_protocols.msg_bet_info bet_list = 2;
inline int packetl2c_bc_sync_scene_bet_into::bet_list_size() const {
return bet_list_.size();
}
inline void packetl2c_bc_sync_scene_bet_into::clear_bet_list() {
bet_list_.Clear();
}
inline const ::game_rouletteak_protocols::msg_bet_info& packetl2c_bc_sync_scene_bet_into::bet_list(int index) const {
return bet_list_.Get(index);
}
inline ::game_rouletteak_protocols::msg_bet_info* packetl2c_bc_sync_scene_bet_into::mutable_bet_list(int index) {
return bet_list_.Mutable(index);
}
inline ::game_rouletteak_protocols::msg_bet_info* packetl2c_bc_sync_scene_bet_into::add_bet_list() {
return bet_list_.Add();
}
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info >&
packetl2c_bc_sync_scene_bet_into::bet_list() const {
return bet_list_;
}
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info >*
packetl2c_bc_sync_scene_bet_into::mutable_bet_list() {
return &bet_list_;
}
// -------------------------------------------------------------------
// packetl2c_bc_scene_deal_into
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bc_scene_deal_into];
inline bool packetl2c_bc_scene_deal_into::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_bc_scene_deal_into::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_bc_scene_deal_into::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_bc_scene_deal_into::clear_packet_id() {
packet_id_ = 15053;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_bc_scene_deal_into::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_bc_scene_deal_into::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 cd = 2;
inline bool packetl2c_bc_scene_deal_into::has_cd() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_bc_scene_deal_into::set_has_cd() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_bc_scene_deal_into::clear_has_cd() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_bc_scene_deal_into::clear_cd() {
cd_ = 0;
clear_has_cd();
}
inline ::google::protobuf::int32 packetl2c_bc_scene_deal_into::cd() const {
return cd_;
}
inline void packetl2c_bc_scene_deal_into::set_cd(::google::protobuf::int32 value) {
set_has_cd();
cd_ = value;
}
// optional int32 number = 3;
inline bool packetl2c_bc_scene_deal_into::has_number() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_bc_scene_deal_into::set_has_number() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_bc_scene_deal_into::clear_has_number() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_bc_scene_deal_into::clear_number() {
number_ = 0;
clear_has_number();
}
inline ::google::protobuf::int32 packetl2c_bc_scene_deal_into::number() const {
return number_;
}
inline void packetl2c_bc_scene_deal_into::set_number(::google::protobuf::int32 value) {
set_has_number();
number_ = value;
}
// -------------------------------------------------------------------
// packetl2c_bc_scene_result_into
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bc_scene_result_into];
inline bool packetl2c_bc_scene_result_into::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_bc_scene_result_into::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_bc_scene_result_into::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_bc_scene_result_into::clear_packet_id() {
packet_id_ = 15054;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_bc_scene_result_into::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_bc_scene_result_into::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 cd = 2;
inline bool packetl2c_bc_scene_result_into::has_cd() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_bc_scene_result_into::set_has_cd() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_bc_scene_result_into::clear_has_cd() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_bc_scene_result_into::clear_cd() {
cd_ = 0;
clear_has_cd();
}
inline ::google::protobuf::int32 packetl2c_bc_scene_result_into::cd() const {
return cd_;
}
inline void packetl2c_bc_scene_result_into::set_cd(::google::protobuf::int32 value) {
set_has_cd();
cd_ = value;
}
// optional .game_rouletteak_protocols.msg_result_info result_info = 3;
inline bool packetl2c_bc_scene_result_into::has_result_info() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_bc_scene_result_into::set_has_result_info() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_bc_scene_result_into::clear_has_result_info() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_bc_scene_result_into::clear_result_info() {
if (result_info_ != NULL) result_info_->::game_rouletteak_protocols::msg_result_info::Clear();
clear_has_result_info();
}
inline const ::game_rouletteak_protocols::msg_result_info& packetl2c_bc_scene_result_into::result_info() const {
return result_info_ != NULL ? *result_info_ : *default_instance_->result_info_;
}
inline ::game_rouletteak_protocols::msg_result_info* packetl2c_bc_scene_result_into::mutable_result_info() {
set_has_result_info();
if (result_info_ == NULL) result_info_ = new ::game_rouletteak_protocols::msg_result_info;
return result_info_;
}
inline ::game_rouletteak_protocols::msg_result_info* packetl2c_bc_scene_result_into::release_result_info() {
clear_has_result_info();
::game_rouletteak_protocols::msg_result_info* temp = result_info_;
result_info_ = NULL;
return temp;
}
inline void packetl2c_bc_scene_result_into::set_allocated_result_info(::game_rouletteak_protocols::msg_result_info* result_info) {
delete result_info_;
result_info_ = result_info;
if (result_info) {
set_has_result_info();
} else {
clear_has_result_info();
}
}
// -------------------------------------------------------------------
// packetc2l_ask_bet_info
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_ask_bet_info];
inline bool packetc2l_ask_bet_info::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetc2l_ask_bet_info::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetc2l_ask_bet_info::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetc2l_ask_bet_info::clear_packet_id() {
packet_id_ = 10011;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetc2l_ask_bet_info::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetc2l_ask_bet_info::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 bet_pos = 2;
inline bool packetc2l_ask_bet_info::has_bet_pos() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetc2l_ask_bet_info::set_has_bet_pos() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetc2l_ask_bet_info::clear_has_bet_pos() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetc2l_ask_bet_info::clear_bet_pos() {
bet_pos_ = 0;
clear_has_bet_pos();
}
inline ::google::protobuf::int32 packetc2l_ask_bet_info::bet_pos() const {
return bet_pos_;
}
inline void packetc2l_ask_bet_info::set_bet_pos(::google::protobuf::int32 value) {
set_has_bet_pos();
bet_pos_ = value;
}
// optional int64 bet_gold = 3;
inline bool packetc2l_ask_bet_info::has_bet_gold() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetc2l_ask_bet_info::set_has_bet_gold() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetc2l_ask_bet_info::clear_has_bet_gold() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetc2l_ask_bet_info::clear_bet_gold() {
bet_gold_ = GOOGLE_LONGLONG(0);
clear_has_bet_gold();
}
inline ::google::protobuf::int64 packetc2l_ask_bet_info::bet_gold() const {
return bet_gold_;
}
inline void packetc2l_ask_bet_info::set_bet_gold(::google::protobuf::int64 value) {
set_has_bet_gold();
bet_gold_ = value;
}
// optional int32 chip_index = 4;
inline bool packetc2l_ask_bet_info::has_chip_index() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void packetc2l_ask_bet_info::set_has_chip_index() {
_has_bits_[0] |= 0x00000008u;
}
inline void packetc2l_ask_bet_info::clear_has_chip_index() {
_has_bits_[0] &= ~0x00000008u;
}
inline void packetc2l_ask_bet_info::clear_chip_index() {
chip_index_ = 0;
clear_has_chip_index();
}
inline ::google::protobuf::int32 packetc2l_ask_bet_info::chip_index() const {
return chip_index_;
}
inline void packetc2l_ask_bet_info::set_chip_index(::google::protobuf::int32 value) {
set_has_chip_index();
chip_index_ = value;
}
// -------------------------------------------------------------------
// packetl2c_bet_info_result
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bet_info_result];
inline bool packetl2c_bet_info_result::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_bet_info_result::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_bet_info_result::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_bet_info_result::clear_packet_id() {
packet_id_ = 15011;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_bet_info_result::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_bet_info_result::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional .msg_type_def.e_msg_result_def result = 2 [default = e_rmt_fail];
inline bool packetl2c_bet_info_result::has_result() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_bet_info_result::set_has_result() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_bet_info_result::clear_has_result() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_bet_info_result::clear_result() {
result_ = 2;
clear_has_result();
}
inline ::msg_type_def::e_msg_result_def packetl2c_bet_info_result::result() const {
return static_cast< ::msg_type_def::e_msg_result_def >(result_);
}
inline void packetl2c_bet_info_result::set_result(::msg_type_def::e_msg_result_def value) {
assert(::msg_type_def::e_msg_result_def_IsValid(value));
set_has_result();
result_ = value;
}
// optional .game_rouletteak_protocols.msg_bet_info bet_info = 3;
inline bool packetl2c_bet_info_result::has_bet_info() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_bet_info_result::set_has_bet_info() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_bet_info_result::clear_has_bet_info() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_bet_info_result::clear_bet_info() {
if (bet_info_ != NULL) bet_info_->::game_rouletteak_protocols::msg_bet_info::Clear();
clear_has_bet_info();
}
inline const ::game_rouletteak_protocols::msg_bet_info& packetl2c_bet_info_result::bet_info() const {
return bet_info_ != NULL ? *bet_info_ : *default_instance_->bet_info_;
}
inline ::game_rouletteak_protocols::msg_bet_info* packetl2c_bet_info_result::mutable_bet_info() {
set_has_bet_info();
if (bet_info_ == NULL) bet_info_ = new ::game_rouletteak_protocols::msg_bet_info;
return bet_info_;
}
inline ::game_rouletteak_protocols::msg_bet_info* packetl2c_bet_info_result::release_bet_info() {
clear_has_bet_info();
::game_rouletteak_protocols::msg_bet_info* temp = bet_info_;
bet_info_ = NULL;
return temp;
}
inline void packetl2c_bet_info_result::set_allocated_bet_info(::game_rouletteak_protocols::msg_bet_info* bet_info) {
delete bet_info_;
bet_info_ = bet_info;
if (bet_info) {
set_has_bet_info();
} else {
clear_has_bet_info();
}
}
// -------------------------------------------------------------------
// packetl2c_enter_player_info
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_enter_player_info];
inline bool packetl2c_enter_player_info::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_enter_player_info::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_enter_player_info::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_enter_player_info::clear_packet_id() {
packet_id_ = 15055;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_enter_player_info::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_enter_player_info::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional .game_rouletteak_protocols.msg_player_info player_info = 2;
inline bool packetl2c_enter_player_info::has_player_info() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_enter_player_info::set_has_player_info() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_enter_player_info::clear_has_player_info() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_enter_player_info::clear_player_info() {
if (player_info_ != NULL) player_info_->::game_rouletteak_protocols::msg_player_info::Clear();
clear_has_player_info();
}
inline const ::game_rouletteak_protocols::msg_player_info& packetl2c_enter_player_info::player_info() const {
return player_info_ != NULL ? *player_info_ : *default_instance_->player_info_;
}
inline ::game_rouletteak_protocols::msg_player_info* packetl2c_enter_player_info::mutable_player_info() {
set_has_player_info();
if (player_info_ == NULL) player_info_ = new ::game_rouletteak_protocols::msg_player_info;
return player_info_;
}
inline ::game_rouletteak_protocols::msg_player_info* packetl2c_enter_player_info::release_player_info() {
clear_has_player_info();
::game_rouletteak_protocols::msg_player_info* temp = player_info_;
player_info_ = NULL;
return temp;
}
inline void packetl2c_enter_player_info::set_allocated_player_info(::game_rouletteak_protocols::msg_player_info* player_info) {
delete player_info_;
player_info_ = player_info;
if (player_info) {
set_has_player_info();
} else {
clear_has_player_info();
}
}
// -------------------------------------------------------------------
// packetl2c_leave_player_info
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_leave_player_info];
inline bool packetl2c_leave_player_info::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_leave_player_info::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_leave_player_info::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_leave_player_info::clear_packet_id() {
packet_id_ = 15056;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_leave_player_info::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_leave_player_info::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 player_id = 2;
inline bool packetl2c_leave_player_info::has_player_id() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_leave_player_info::set_has_player_id() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_leave_player_info::clear_has_player_id() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_leave_player_info::clear_player_id() {
player_id_ = 0;
clear_has_player_id();
}
inline ::google::protobuf::int32 packetl2c_leave_player_info::player_id() const {
return player_id_;
}
inline void packetl2c_leave_player_info::set_player_id(::google::protobuf::int32 value) {
set_has_player_id();
player_id_ = value;
}
// -------------------------------------------------------------------
// packetl2c_bc_change_attr
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_bc_change_attr];
inline bool packetl2c_bc_change_attr::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_bc_change_attr::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_bc_change_attr::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_bc_change_attr::clear_packet_id() {
packet_id_ = 15066;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_bc_change_attr::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_bc_change_attr::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 player_id = 2;
inline bool packetl2c_bc_change_attr::has_player_id() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_bc_change_attr::set_has_player_id() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_bc_change_attr::clear_has_player_id() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_bc_change_attr::clear_player_id() {
player_id_ = 0;
clear_has_player_id();
}
inline ::google::protobuf::int32 packetl2c_bc_change_attr::player_id() const {
return player_id_;
}
inline void packetl2c_bc_change_attr::set_player_id(::google::protobuf::int32 value) {
set_has_player_id();
player_id_ = value;
}
// optional int32 item_type = 3;
inline bool packetl2c_bc_change_attr::has_item_type() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_bc_change_attr::set_has_item_type() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_bc_change_attr::clear_has_item_type() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_bc_change_attr::clear_item_type() {
item_type_ = 0;
clear_has_item_type();
}
inline ::google::protobuf::int32 packetl2c_bc_change_attr::item_type() const {
return item_type_;
}
inline void packetl2c_bc_change_attr::set_item_type(::google::protobuf::int32 value) {
set_has_item_type();
item_type_ = value;
}
// optional int64 change_value = 4;
inline bool packetl2c_bc_change_attr::has_change_value() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void packetl2c_bc_change_attr::set_has_change_value() {
_has_bits_[0] |= 0x00000008u;
}
inline void packetl2c_bc_change_attr::clear_has_change_value() {
_has_bits_[0] &= ~0x00000008u;
}
inline void packetl2c_bc_change_attr::clear_change_value() {
change_value_ = GOOGLE_LONGLONG(0);
clear_has_change_value();
}
inline ::google::protobuf::int64 packetl2c_bc_change_attr::change_value() const {
return change_value_;
}
inline void packetl2c_bc_change_attr::set_change_value(::google::protobuf::int64 value) {
set_has_change_value();
change_value_ = value;
}
// -------------------------------------------------------------------
// packetc2l_supply_chip
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_supply_chip];
inline bool packetc2l_supply_chip::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetc2l_supply_chip::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetc2l_supply_chip::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetc2l_supply_chip::clear_packet_id() {
packet_id_ = 10020;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetc2l_supply_chip::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetc2l_supply_chip::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// -------------------------------------------------------------------
// packetl2c_supply_chip_result
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_supply_chip_result];
inline bool packetl2c_supply_chip_result::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_supply_chip_result::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_supply_chip_result::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_supply_chip_result::clear_packet_id() {
packet_id_ = 15067;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_supply_chip_result::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_supply_chip_result::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional .msg_type_def.e_msg_result_def result = 2 [default = e_rmt_fail];
inline bool packetl2c_supply_chip_result::has_result() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_supply_chip_result::set_has_result() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_supply_chip_result::clear_has_result() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_supply_chip_result::clear_result() {
result_ = 2;
clear_has_result();
}
inline ::msg_type_def::e_msg_result_def packetl2c_supply_chip_result::result() const {
return static_cast< ::msg_type_def::e_msg_result_def >(result_);
}
inline void packetl2c_supply_chip_result::set_result(::msg_type_def::e_msg_result_def value) {
assert(::msg_type_def::e_msg_result_def_IsValid(value));
set_has_result();
result_ = value;
}
// optional int64 gold = 6;
inline bool packetl2c_supply_chip_result::has_gold() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_supply_chip_result::set_has_gold() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_supply_chip_result::clear_has_gold() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_supply_chip_result::clear_gold() {
gold_ = GOOGLE_LONGLONG(0);
clear_has_gold();
}
inline ::google::protobuf::int64 packetl2c_supply_chip_result::gold() const {
return gold_;
}
inline void packetl2c_supply_chip_result::set_gold(::google::protobuf::int64 value) {
set_has_gold();
gold_ = value;
}
// -------------------------------------------------------------------
// packetc2l_check_state
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_check_state];
inline bool packetc2l_check_state::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetc2l_check_state::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetc2l_check_state::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetc2l_check_state::clear_packet_id() {
packet_id_ = 10021;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetc2l_check_state::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetc2l_check_state::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// -------------------------------------------------------------------
// packetc2l_check_state_result
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_check_state_result];
inline bool packetc2l_check_state_result::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetc2l_check_state_result::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetc2l_check_state_result::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetc2l_check_state_result::clear_packet_id() {
packet_id_ = 15068;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetc2l_check_state_result::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetc2l_check_state_result::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 room_id = 2;
inline bool packetc2l_check_state_result::has_room_id() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetc2l_check_state_result::set_has_room_id() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetc2l_check_state_result::clear_has_room_id() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetc2l_check_state_result::clear_room_id() {
room_id_ = 0;
clear_has_room_id();
}
inline ::google::protobuf::int32 packetc2l_check_state_result::room_id() const {
return room_id_;
}
inline void packetc2l_check_state_result::set_room_id(::google::protobuf::int32 value) {
set_has_room_id();
room_id_ = value;
}
// -------------------------------------------------------------------
// msg_room_history
// optional int32 room_id = 1;
inline bool msg_room_history::has_room_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void msg_room_history::set_has_room_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void msg_room_history::clear_has_room_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void msg_room_history::clear_room_id() {
room_id_ = 0;
clear_has_room_id();
}
inline ::google::protobuf::int32 msg_room_history::room_id() const {
return room_id_;
}
inline void msg_room_history::set_room_id(::google::protobuf::int32 value) {
set_has_room_id();
room_id_ = value;
}
// optional int32 state = 2;
inline bool msg_room_history::has_state() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void msg_room_history::set_has_state() {
_has_bits_[0] |= 0x00000002u;
}
inline void msg_room_history::clear_has_state() {
_has_bits_[0] &= ~0x00000002u;
}
inline void msg_room_history::clear_state() {
state_ = 0;
clear_has_state();
}
inline ::google::protobuf::int32 msg_room_history::state() const {
return state_;
}
inline void msg_room_history::set_state(::google::protobuf::int32 value) {
set_has_state();
state_ = value;
}
// optional int32 cd = 3;
inline bool msg_room_history::has_cd() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void msg_room_history::set_has_cd() {
_has_bits_[0] |= 0x00000004u;
}
inline void msg_room_history::clear_has_cd() {
_has_bits_[0] &= ~0x00000004u;
}
inline void msg_room_history::clear_cd() {
cd_ = 0;
clear_has_cd();
}
inline ::google::protobuf::int32 msg_room_history::cd() const {
return cd_;
}
inline void msg_room_history::set_cd(::google::protobuf::int32 value) {
set_has_cd();
cd_ = value;
}
// repeated int32 pos_list = 4;
inline int msg_room_history::pos_list_size() const {
return pos_list_.size();
}
inline void msg_room_history::clear_pos_list() {
pos_list_.Clear();
}
inline ::google::protobuf::int32 msg_room_history::pos_list(int index) const {
return pos_list_.Get(index);
}
inline void msg_room_history::set_pos_list(int index, ::google::protobuf::int32 value) {
pos_list_.Set(index, value);
}
inline void msg_room_history::add_pos_list(::google::protobuf::int32 value) {
pos_list_.Add(value);
}
inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
msg_room_history::pos_list() const {
return pos_list_;
}
inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
msg_room_history::mutable_pos_list() {
return &pos_list_;
}
// -------------------------------------------------------------------
// packetc2l_room_history_list
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_room_history_list];
inline bool packetc2l_room_history_list::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetc2l_room_history_list::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetc2l_room_history_list::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetc2l_room_history_list::clear_packet_id() {
packet_id_ = 10017;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetc2l_room_history_list::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetc2l_room_history_list::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// -------------------------------------------------------------------
// packetl2c_room_history_list_result
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_room_history_list_result];
inline bool packetl2c_room_history_list_result::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_room_history_list_result::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_room_history_list_result::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_room_history_list_result::clear_packet_id() {
packet_id_ = 15061;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_room_history_list_result::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_room_history_list_result::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// repeated .game_rouletteak_protocols.msg_room_history history_list = 2;
inline int packetl2c_room_history_list_result::history_list_size() const {
return history_list_.size();
}
inline void packetl2c_room_history_list_result::clear_history_list() {
history_list_.Clear();
}
inline const ::game_rouletteak_protocols::msg_room_history& packetl2c_room_history_list_result::history_list(int index) const {
return history_list_.Get(index);
}
inline ::game_rouletteak_protocols::msg_room_history* packetl2c_room_history_list_result::mutable_history_list(int index) {
return history_list_.Mutable(index);
}
inline ::game_rouletteak_protocols::msg_room_history* packetl2c_room_history_list_result::add_history_list() {
return history_list_.Add();
}
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_room_history >&
packetl2c_room_history_list_result::history_list() const {
return history_list_;
}
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_room_history >*
packetl2c_room_history_list_result::mutable_history_list() {
return &history_list_;
}
// -------------------------------------------------------------------
// packetl2c_notify_history
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_notify_history];
inline bool packetl2c_notify_history::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_notify_history::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_notify_history::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_notify_history::clear_packet_id() {
packet_id_ = 15062;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_notify_history::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_notify_history::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 room_id = 2;
inline bool packetl2c_notify_history::has_room_id() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_notify_history::set_has_room_id() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_notify_history::clear_has_room_id() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_notify_history::clear_room_id() {
room_id_ = 0;
clear_has_room_id();
}
inline ::google::protobuf::int32 packetl2c_notify_history::room_id() const {
return room_id_;
}
inline void packetl2c_notify_history::set_room_id(::google::protobuf::int32 value) {
set_has_room_id();
room_id_ = value;
}
// optional int32 state = 3;
inline bool packetl2c_notify_history::has_state() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_notify_history::set_has_state() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_notify_history::clear_has_state() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_notify_history::clear_state() {
state_ = 0;
clear_has_state();
}
inline ::google::protobuf::int32 packetl2c_notify_history::state() const {
return state_;
}
inline void packetl2c_notify_history::set_state(::google::protobuf::int32 value) {
set_has_state();
state_ = value;
}
// optional int32 cd = 4;
inline bool packetl2c_notify_history::has_cd() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void packetl2c_notify_history::set_has_cd() {
_has_bits_[0] |= 0x00000008u;
}
inline void packetl2c_notify_history::clear_has_cd() {
_has_bits_[0] &= ~0x00000008u;
}
inline void packetl2c_notify_history::clear_cd() {
cd_ = 0;
clear_has_cd();
}
inline ::google::protobuf::int32 packetl2c_notify_history::cd() const {
return cd_;
}
inline void packetl2c_notify_history::set_cd(::google::protobuf::int32 value) {
set_has_cd();
cd_ = value;
}
// optional int32 pos = 5;
inline bool packetl2c_notify_history::has_pos() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void packetl2c_notify_history::set_has_pos() {
_has_bits_[0] |= 0x00000010u;
}
inline void packetl2c_notify_history::clear_has_pos() {
_has_bits_[0] &= ~0x00000010u;
}
inline void packetl2c_notify_history::clear_pos() {
pos_ = 0;
clear_has_pos();
}
inline ::google::protobuf::int32 packetl2c_notify_history::pos() const {
return pos_;
}
inline void packetl2c_notify_history::set_pos(::google::protobuf::int32 value) {
set_has_pos();
pos_ = value;
}
// -------------------------------------------------------------------
// packetc2l_continue_bet
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_continue_bet];
inline bool packetc2l_continue_bet::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetc2l_continue_bet::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetc2l_continue_bet::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetc2l_continue_bet::clear_packet_id() {
packet_id_ = 10012;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetc2l_continue_bet::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetc2l_continue_bet::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// -------------------------------------------------------------------
// packetl2c_continue_bet_result
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_continue_bet_result];
inline bool packetl2c_continue_bet_result::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_continue_bet_result::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_continue_bet_result::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_continue_bet_result::clear_packet_id() {
packet_id_ = 15012;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_continue_bet_result::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_continue_bet_result::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional .msg_type_def.e_msg_result_def result = 2 [default = e_rmt_fail];
inline bool packetl2c_continue_bet_result::has_result() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_continue_bet_result::set_has_result() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_continue_bet_result::clear_has_result() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_continue_bet_result::clear_result() {
result_ = 2;
clear_has_result();
}
inline ::msg_type_def::e_msg_result_def packetl2c_continue_bet_result::result() const {
return static_cast< ::msg_type_def::e_msg_result_def >(result_);
}
inline void packetl2c_continue_bet_result::set_result(::msg_type_def::e_msg_result_def value) {
assert(::msg_type_def::e_msg_result_def_IsValid(value));
set_has_result();
result_ = value;
}
// optional int64 cur_gold = 3;
inline bool packetl2c_continue_bet_result::has_cur_gold() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_continue_bet_result::set_has_cur_gold() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_continue_bet_result::clear_has_cur_gold() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_continue_bet_result::clear_cur_gold() {
cur_gold_ = GOOGLE_LONGLONG(0);
clear_has_cur_gold();
}
inline ::google::protobuf::int64 packetl2c_continue_bet_result::cur_gold() const {
return cur_gold_;
}
inline void packetl2c_continue_bet_result::set_cur_gold(::google::protobuf::int64 value) {
set_has_cur_gold();
cur_gold_ = value;
}
// repeated .game_rouletteak_protocols.msg_bet_info bet_list = 4;
inline int packetl2c_continue_bet_result::bet_list_size() const {
return bet_list_.size();
}
inline void packetl2c_continue_bet_result::clear_bet_list() {
bet_list_.Clear();
}
inline const ::game_rouletteak_protocols::msg_bet_info& packetl2c_continue_bet_result::bet_list(int index) const {
return bet_list_.Get(index);
}
inline ::game_rouletteak_protocols::msg_bet_info* packetl2c_continue_bet_result::mutable_bet_list(int index) {
return bet_list_.Mutable(index);
}
inline ::game_rouletteak_protocols::msg_bet_info* packetl2c_continue_bet_result::add_bet_list() {
return bet_list_.Add();
}
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info >&
packetl2c_continue_bet_result::bet_list() const {
return bet_list_;
}
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::msg_bet_info >*
packetl2c_continue_bet_result::mutable_bet_list() {
return &bet_list_;
}
// -------------------------------------------------------------------
// packetc2l_cancel_bet
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_cancel_bet];
inline bool packetc2l_cancel_bet::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetc2l_cancel_bet::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetc2l_cancel_bet::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetc2l_cancel_bet::clear_packet_id() {
packet_id_ = 10022;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetc2l_cancel_bet::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetc2l_cancel_bet::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 bet_pos = 2 [default = -1];
inline bool packetc2l_cancel_bet::has_bet_pos() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetc2l_cancel_bet::set_has_bet_pos() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetc2l_cancel_bet::clear_has_bet_pos() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetc2l_cancel_bet::clear_bet_pos() {
bet_pos_ = -1;
clear_has_bet_pos();
}
inline ::google::protobuf::int32 packetc2l_cancel_bet::bet_pos() const {
return bet_pos_;
}
inline void packetc2l_cancel_bet::set_bet_pos(::google::protobuf::int32 value) {
set_has_bet_pos();
bet_pos_ = value;
}
// -------------------------------------------------------------------
// packetl2c_cancel_bet_result
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_cancel_bet_result];
inline bool packetl2c_cancel_bet_result::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_cancel_bet_result::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_cancel_bet_result::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_cancel_bet_result::clear_packet_id() {
packet_id_ = 15069;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_cancel_bet_result::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_cancel_bet_result::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional .msg_type_def.e_msg_result_def result = 2 [default = e_rmt_fail];
inline bool packetl2c_cancel_bet_result::has_result() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_cancel_bet_result::set_has_result() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_cancel_bet_result::clear_has_result() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_cancel_bet_result::clear_result() {
result_ = 2;
clear_has_result();
}
inline ::msg_type_def::e_msg_result_def packetl2c_cancel_bet_result::result() const {
return static_cast< ::msg_type_def::e_msg_result_def >(result_);
}
inline void packetl2c_cancel_bet_result::set_result(::msg_type_def::e_msg_result_def value) {
assert(::msg_type_def::e_msg_result_def_IsValid(value));
set_has_result();
result_ = value;
}
// optional int32 player_id = 3;
inline bool packetl2c_cancel_bet_result::has_player_id() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_cancel_bet_result::set_has_player_id() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_cancel_bet_result::clear_has_player_id() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_cancel_bet_result::clear_player_id() {
player_id_ = 0;
clear_has_player_id();
}
inline ::google::protobuf::int32 packetl2c_cancel_bet_result::player_id() const {
return player_id_;
}
inline void packetl2c_cancel_bet_result::set_player_id(::google::protobuf::int32 value) {
set_has_player_id();
player_id_ = value;
}
// optional int64 cur_gold = 4;
inline bool packetl2c_cancel_bet_result::has_cur_gold() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void packetl2c_cancel_bet_result::set_has_cur_gold() {
_has_bits_[0] |= 0x00000008u;
}
inline void packetl2c_cancel_bet_result::clear_has_cur_gold() {
_has_bits_[0] &= ~0x00000008u;
}
inline void packetl2c_cancel_bet_result::clear_cur_gold() {
cur_gold_ = GOOGLE_LONGLONG(0);
clear_has_cur_gold();
}
inline ::google::protobuf::int64 packetl2c_cancel_bet_result::cur_gold() const {
return cur_gold_;
}
inline void packetl2c_cancel_bet_result::set_cur_gold(::google::protobuf::int64 value) {
set_has_cur_gold();
cur_gold_ = value;
}
// optional int32 bet_pos = 5;
inline bool packetl2c_cancel_bet_result::has_bet_pos() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void packetl2c_cancel_bet_result::set_has_bet_pos() {
_has_bits_[0] |= 0x00000010u;
}
inline void packetl2c_cancel_bet_result::clear_has_bet_pos() {
_has_bits_[0] &= ~0x00000010u;
}
inline void packetl2c_cancel_bet_result::clear_bet_pos() {
bet_pos_ = 0;
clear_has_bet_pos();
}
inline ::google::protobuf::int32 packetl2c_cancel_bet_result::bet_pos() const {
return bet_pos_;
}
inline void packetl2c_cancel_bet_result::set_bet_pos(::google::protobuf::int32 value) {
set_has_bet_pos();
bet_pos_ = value;
}
// optional int64 change_gold = 6;
inline bool packetl2c_cancel_bet_result::has_change_gold() const {
return (_has_bits_[0] & 0x00000020u) != 0;
}
inline void packetl2c_cancel_bet_result::set_has_change_gold() {
_has_bits_[0] |= 0x00000020u;
}
inline void packetl2c_cancel_bet_result::clear_has_change_gold() {
_has_bits_[0] &= ~0x00000020u;
}
inline void packetl2c_cancel_bet_result::clear_change_gold() {
change_gold_ = GOOGLE_LONGLONG(0);
clear_has_change_gold();
}
inline ::google::protobuf::int64 packetl2c_cancel_bet_result::change_gold() const {
return change_gold_;
}
inline void packetl2c_cancel_bet_result::set_change_gold(::google::protobuf::int64 value) {
set_has_change_gold();
change_gold_ = value;
}
// -------------------------------------------------------------------
// room_player
// optional int32 player_id = 1;
inline bool room_player::has_player_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void room_player::set_has_player_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void room_player::clear_has_player_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void room_player::clear_player_id() {
player_id_ = 0;
clear_has_player_id();
}
inline ::google::protobuf::int32 room_player::player_id() const {
return player_id_;
}
inline void room_player::set_player_id(::google::protobuf::int32 value) {
set_has_player_id();
player_id_ = value;
}
// optional int64 gold = 2;
inline bool room_player::has_gold() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void room_player::set_has_gold() {
_has_bits_[0] |= 0x00000002u;
}
inline void room_player::clear_has_gold() {
_has_bits_[0] &= ~0x00000002u;
}
inline void room_player::clear_gold() {
gold_ = GOOGLE_LONGLONG(0);
clear_has_gold();
}
inline ::google::protobuf::int64 room_player::gold() const {
return gold_;
}
inline void room_player::set_gold(::google::protobuf::int64 value) {
set_has_gold();
gold_ = value;
}
// optional int64 profit_today = 3;
inline bool room_player::has_profit_today() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void room_player::set_has_profit_today() {
_has_bits_[0] |= 0x00000004u;
}
inline void room_player::clear_has_profit_today() {
_has_bits_[0] &= ~0x00000004u;
}
inline void room_player::clear_profit_today() {
profit_today_ = GOOGLE_LONGLONG(0);
clear_has_profit_today();
}
inline ::google::protobuf::int64 room_player::profit_today() const {
return profit_today_;
}
inline void room_player::set_profit_today(::google::protobuf::int64 value) {
set_has_profit_today();
profit_today_ = value;
}
// -------------------------------------------------------------------
// packetl2c_gm_get_room_info
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_gm_get_room_info];
inline bool packetl2c_gm_get_room_info::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_gm_get_room_info::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_gm_get_room_info::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_gm_get_room_info::clear_packet_id() {
packet_id_ = 10101;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_gm_get_room_info::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_gm_get_room_info::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// -------------------------------------------------------------------
// packetl2c_gm_get_room_info_result
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_gm_get_room_info_result];
inline bool packetl2c_gm_get_room_info_result::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_gm_get_room_info_result::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_gm_get_room_info_result::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_gm_get_room_info_result::clear_packet_id() {
packet_id_ = 15101;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_gm_get_room_info_result::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_gm_get_room_info_result::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 result = 2;
inline bool packetl2c_gm_get_room_info_result::has_result() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_gm_get_room_info_result::set_has_result() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_gm_get_room_info_result::clear_has_result() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_gm_get_room_info_result::clear_result() {
result_ = 0;
clear_has_result();
}
inline ::google::protobuf::int32 packetl2c_gm_get_room_info_result::result() const {
return result_;
}
inline void packetl2c_gm_get_room_info_result::set_result(::google::protobuf::int32 value) {
set_has_result();
result_ = value;
}
// optional int32 bead_num = 3 [default = -1];
inline bool packetl2c_gm_get_room_info_result::has_bead_num() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_gm_get_room_info_result::set_has_bead_num() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_gm_get_room_info_result::clear_has_bead_num() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_gm_get_room_info_result::clear_bead_num() {
bead_num_ = -1;
clear_has_bead_num();
}
inline ::google::protobuf::int32 packetl2c_gm_get_room_info_result::bead_num() const {
return bead_num_;
}
inline void packetl2c_gm_get_room_info_result::set_bead_num(::google::protobuf::int32 value) {
set_has_bead_num();
bead_num_ = value;
}
// repeated .game_rouletteak_protocols.room_player players = 4;
inline int packetl2c_gm_get_room_info_result::players_size() const {
return players_.size();
}
inline void packetl2c_gm_get_room_info_result::clear_players() {
players_.Clear();
}
inline const ::game_rouletteak_protocols::room_player& packetl2c_gm_get_room_info_result::players(int index) const {
return players_.Get(index);
}
inline ::game_rouletteak_protocols::room_player* packetl2c_gm_get_room_info_result::mutable_players(int index) {
return players_.Mutable(index);
}
inline ::game_rouletteak_protocols::room_player* packetl2c_gm_get_room_info_result::add_players() {
return players_.Add();
}
inline const ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::room_player >&
packetl2c_gm_get_room_info_result::players() const {
return players_;
}
inline ::google::protobuf::RepeatedPtrField< ::game_rouletteak_protocols::room_player >*
packetl2c_gm_get_room_info_result::mutable_players() {
return &players_;
}
// optional int64 stock = 5;
inline bool packetl2c_gm_get_room_info_result::has_stock() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void packetl2c_gm_get_room_info_result::set_has_stock() {
_has_bits_[0] |= 0x00000010u;
}
inline void packetl2c_gm_get_room_info_result::clear_has_stock() {
_has_bits_[0] &= ~0x00000010u;
}
inline void packetl2c_gm_get_room_info_result::clear_stock() {
stock_ = GOOGLE_LONGLONG(0);
clear_has_stock();
}
inline ::google::protobuf::int64 packetl2c_gm_get_room_info_result::stock() const {
return stock_;
}
inline void packetl2c_gm_get_room_info_result::set_stock(::google::protobuf::int64 value) {
set_has_stock();
stock_ = value;
}
// optional int64 water = 6;
inline bool packetl2c_gm_get_room_info_result::has_water() const {
return (_has_bits_[0] & 0x00000020u) != 0;
}
inline void packetl2c_gm_get_room_info_result::set_has_water() {
_has_bits_[0] |= 0x00000020u;
}
inline void packetl2c_gm_get_room_info_result::clear_has_water() {
_has_bits_[0] &= ~0x00000020u;
}
inline void packetl2c_gm_get_room_info_result::clear_water() {
water_ = GOOGLE_LONGLONG(0);
clear_has_water();
}
inline ::google::protobuf::int64 packetl2c_gm_get_room_info_result::water() const {
return water_;
}
inline void packetl2c_gm_get_room_info_result::set_water(::google::protobuf::int64 value) {
set_has_water();
water_ = value;
}
// optional int32 kill = 7;
inline bool packetl2c_gm_get_room_info_result::has_kill() const {
return (_has_bits_[0] & 0x00000040u) != 0;
}
inline void packetl2c_gm_get_room_info_result::set_has_kill() {
_has_bits_[0] |= 0x00000040u;
}
inline void packetl2c_gm_get_room_info_result::clear_has_kill() {
_has_bits_[0] &= ~0x00000040u;
}
inline void packetl2c_gm_get_room_info_result::clear_kill() {
kill_ = 0;
clear_has_kill();
}
inline ::google::protobuf::int32 packetl2c_gm_get_room_info_result::kill() const {
return kill_;
}
inline void packetl2c_gm_get_room_info_result::set_kill(::google::protobuf::int32 value) {
set_has_kill();
kill_ = value;
}
// -------------------------------------------------------------------
// packetl2c_gm_set_bead
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_c2l_gm_set_bead];
inline bool packetl2c_gm_set_bead::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_gm_set_bead::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_gm_set_bead::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_gm_set_bead::clear_packet_id() {
packet_id_ = 10102;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_gm_set_bead::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_gm_set_bead::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 bead_num = 2;
inline bool packetl2c_gm_set_bead::has_bead_num() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_gm_set_bead::set_has_bead_num() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_gm_set_bead::clear_has_bead_num() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_gm_set_bead::clear_bead_num() {
bead_num_ = 0;
clear_has_bead_num();
}
inline ::google::protobuf::int32 packetl2c_gm_set_bead::bead_num() const {
return bead_num_;
}
inline void packetl2c_gm_set_bead::set_bead_num(::google::protobuf::int32 value) {
set_has_bead_num();
bead_num_ = value;
}
// optional int32 kill = 3;
inline bool packetl2c_gm_set_bead::has_kill() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_gm_set_bead::set_has_kill() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_gm_set_bead::clear_has_kill() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_gm_set_bead::clear_kill() {
kill_ = 0;
clear_has_kill();
}
inline ::google::protobuf::int32 packetl2c_gm_set_bead::kill() const {
return kill_;
}
inline void packetl2c_gm_set_bead::set_kill(::google::protobuf::int32 value) {
set_has_kill();
kill_ = value;
}
// -------------------------------------------------------------------
// packetl2c_gm_set_bead_result
// optional .game_rouletteak_protocols.e_server_msg_type packet_id = 1 [default = e_mst_l2c_gm_set_bead_result];
inline bool packetl2c_gm_set_bead_result::has_packet_id() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void packetl2c_gm_set_bead_result::set_has_packet_id() {
_has_bits_[0] |= 0x00000001u;
}
inline void packetl2c_gm_set_bead_result::clear_has_packet_id() {
_has_bits_[0] &= ~0x00000001u;
}
inline void packetl2c_gm_set_bead_result::clear_packet_id() {
packet_id_ = 15102;
clear_has_packet_id();
}
inline ::game_rouletteak_protocols::e_server_msg_type packetl2c_gm_set_bead_result::packet_id() const {
return static_cast< ::game_rouletteak_protocols::e_server_msg_type >(packet_id_);
}
inline void packetl2c_gm_set_bead_result::set_packet_id(::game_rouletteak_protocols::e_server_msg_type value) {
assert(::game_rouletteak_protocols::e_server_msg_type_IsValid(value));
set_has_packet_id();
packet_id_ = value;
}
// optional int32 result = 2;
inline bool packetl2c_gm_set_bead_result::has_result() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void packetl2c_gm_set_bead_result::set_has_result() {
_has_bits_[0] |= 0x00000002u;
}
inline void packetl2c_gm_set_bead_result::clear_has_result() {
_has_bits_[0] &= ~0x00000002u;
}
inline void packetl2c_gm_set_bead_result::clear_result() {
result_ = 0;
clear_has_result();
}
inline ::google::protobuf::int32 packetl2c_gm_set_bead_result::result() const {
return result_;
}
inline void packetl2c_gm_set_bead_result::set_result(::google::protobuf::int32 value) {
set_has_result();
result_ = value;
}
// optional int32 bead_num = 3;
inline bool packetl2c_gm_set_bead_result::has_bead_num() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void packetl2c_gm_set_bead_result::set_has_bead_num() {
_has_bits_[0] |= 0x00000004u;
}
inline void packetl2c_gm_set_bead_result::clear_has_bead_num() {
_has_bits_[0] &= ~0x00000004u;
}
inline void packetl2c_gm_set_bead_result::clear_bead_num() {
bead_num_ = 0;
clear_has_bead_num();
}
inline ::google::protobuf::int32 packetl2c_gm_set_bead_result::bead_num() const {
return bead_num_;
}
inline void packetl2c_gm_set_bead_result::set_bead_num(::google::protobuf::int32 value) {
set_has_bead_num();
bead_num_ = value;
}
// optional int32 kill = 4;
inline bool packetl2c_gm_set_bead_result::has_kill() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void packetl2c_gm_set_bead_result::set_has_kill() {
_has_bits_[0] |= 0x00000008u;
}
inline void packetl2c_gm_set_bead_result::clear_has_kill() {
_has_bits_[0] &= ~0x00000008u;
}
inline void packetl2c_gm_set_bead_result::clear_kill() {
kill_ = 0;
clear_has_kill();
}
inline ::google::protobuf::int32 packetl2c_gm_set_bead_result::kill() const {
return kill_;
}
inline void packetl2c_gm_set_bead_result::set_kill(::google::protobuf::int32 value) {
set_has_kill();
kill_ = value;
}
// @@protoc_insertion_point(namespace_scope)
} // namespace game_rouletteak_protocols
#ifndef SWIG
namespace google {
namespace protobuf {
} // namespace google
} // namespace protobuf
#endif // SWIG
// @@protoc_insertion_point(global_scope)
#endif // PROTOBUF_game_5frouletteak_5fprotocol_2eproto__INCLUDED
| [
"czh850109@gmail.com"
] | czh850109@gmail.com |
96e84ea3295bd0090faaf59c77e4b70fcba34b4b | ad273708d98b1f73b3855cc4317bca2e56456d15 | /aws-cpp-sdk-appmesh/include/aws/appmesh/model/VirtualNodeRef.h | 64fc8164efc58dba505cf23334f941f5f567e24a | [
"MIT",
"Apache-2.0",
"JSON"
] | permissive | novaquark/aws-sdk-cpp | b390f2e29f86f629f9efcf41c4990169b91f4f47 | a0969508545bec9ae2864c9e1e2bb9aff109f90c | refs/heads/master | 2022-08-28T18:28:12.742810 | 2020-05-27T15:46:18 | 2020-05-27T15:46:18 | 267,351,721 | 1 | 0 | Apache-2.0 | 2020-05-27T15:08:16 | 2020-05-27T15:08:15 | null | UTF-8 | C++ | false | false | 16,022 | h | /*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#pragma once
#include <aws/appmesh/AppMesh_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/utils/DateTime.h>
#include <utility>
namespace Aws
{
namespace Utils
{
namespace Json
{
class JsonValue;
class JsonView;
} // namespace Json
} // namespace Utils
namespace AppMesh
{
namespace Model
{
/**
* <p>An object that represents a virtual node returned by a list
* operation.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/appmesh-2019-01-25/VirtualNodeRef">AWS
* API Reference</a></p>
*/
class AWS_APPMESH_API VirtualNodeRef
{
public:
VirtualNodeRef();
VirtualNodeRef(Aws::Utils::Json::JsonView jsonValue);
VirtualNodeRef& operator=(Aws::Utils::Json::JsonView jsonValue);
Aws::Utils::Json::JsonValue Jsonize() const;
/**
* <p>The full Amazon Resource Name (ARN) for the virtual node.</p>
*/
inline const Aws::String& GetArn() const{ return m_arn; }
/**
* <p>The full Amazon Resource Name (ARN) for the virtual node.</p>
*/
inline bool ArnHasBeenSet() const { return m_arnHasBeenSet; }
/**
* <p>The full Amazon Resource Name (ARN) for the virtual node.</p>
*/
inline void SetArn(const Aws::String& value) { m_arnHasBeenSet = true; m_arn = value; }
/**
* <p>The full Amazon Resource Name (ARN) for the virtual node.</p>
*/
inline void SetArn(Aws::String&& value) { m_arnHasBeenSet = true; m_arn = std::move(value); }
/**
* <p>The full Amazon Resource Name (ARN) for the virtual node.</p>
*/
inline void SetArn(const char* value) { m_arnHasBeenSet = true; m_arn.assign(value); }
/**
* <p>The full Amazon Resource Name (ARN) for the virtual node.</p>
*/
inline VirtualNodeRef& WithArn(const Aws::String& value) { SetArn(value); return *this;}
/**
* <p>The full Amazon Resource Name (ARN) for the virtual node.</p>
*/
inline VirtualNodeRef& WithArn(Aws::String&& value) { SetArn(std::move(value)); return *this;}
/**
* <p>The full Amazon Resource Name (ARN) for the virtual node.</p>
*/
inline VirtualNodeRef& WithArn(const char* value) { SetArn(value); return *this;}
inline const Aws::Utils::DateTime& GetCreatedAt() const{ return m_createdAt; }
inline bool CreatedAtHasBeenSet() const { return m_createdAtHasBeenSet; }
inline void SetCreatedAt(const Aws::Utils::DateTime& value) { m_createdAtHasBeenSet = true; m_createdAt = value; }
inline void SetCreatedAt(Aws::Utils::DateTime&& value) { m_createdAtHasBeenSet = true; m_createdAt = std::move(value); }
inline VirtualNodeRef& WithCreatedAt(const Aws::Utils::DateTime& value) { SetCreatedAt(value); return *this;}
inline VirtualNodeRef& WithCreatedAt(Aws::Utils::DateTime&& value) { SetCreatedAt(std::move(value)); return *this;}
inline const Aws::Utils::DateTime& GetLastUpdatedAt() const{ return m_lastUpdatedAt; }
inline bool LastUpdatedAtHasBeenSet() const { return m_lastUpdatedAtHasBeenSet; }
inline void SetLastUpdatedAt(const Aws::Utils::DateTime& value) { m_lastUpdatedAtHasBeenSet = true; m_lastUpdatedAt = value; }
inline void SetLastUpdatedAt(Aws::Utils::DateTime&& value) { m_lastUpdatedAtHasBeenSet = true; m_lastUpdatedAt = std::move(value); }
inline VirtualNodeRef& WithLastUpdatedAt(const Aws::Utils::DateTime& value) { SetLastUpdatedAt(value); return *this;}
inline VirtualNodeRef& WithLastUpdatedAt(Aws::Utils::DateTime&& value) { SetLastUpdatedAt(std::move(value)); return *this;}
/**
* <p>The name of the service mesh that the virtual node resides in.</p>
*/
inline const Aws::String& GetMeshName() const{ return m_meshName; }
/**
* <p>The name of the service mesh that the virtual node resides in.</p>
*/
inline bool MeshNameHasBeenSet() const { return m_meshNameHasBeenSet; }
/**
* <p>The name of the service mesh that the virtual node resides in.</p>
*/
inline void SetMeshName(const Aws::String& value) { m_meshNameHasBeenSet = true; m_meshName = value; }
/**
* <p>The name of the service mesh that the virtual node resides in.</p>
*/
inline void SetMeshName(Aws::String&& value) { m_meshNameHasBeenSet = true; m_meshName = std::move(value); }
/**
* <p>The name of the service mesh that the virtual node resides in.</p>
*/
inline void SetMeshName(const char* value) { m_meshNameHasBeenSet = true; m_meshName.assign(value); }
/**
* <p>The name of the service mesh that the virtual node resides in.</p>
*/
inline VirtualNodeRef& WithMeshName(const Aws::String& value) { SetMeshName(value); return *this;}
/**
* <p>The name of the service mesh that the virtual node resides in.</p>
*/
inline VirtualNodeRef& WithMeshName(Aws::String&& value) { SetMeshName(std::move(value)); return *this;}
/**
* <p>The name of the service mesh that the virtual node resides in.</p>
*/
inline VirtualNodeRef& WithMeshName(const char* value) { SetMeshName(value); return *this;}
/**
* <p>The AWS IAM account ID of the service mesh owner. If the account ID is not
* your own, then it's
the ID of the account that shared the mesh
* with your account. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline const Aws::String& GetMeshOwner() const{ return m_meshOwner; }
/**
* <p>The AWS IAM account ID of the service mesh owner. If the account ID is not
* your own, then it's
the ID of the account that shared the mesh
* with your account. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline bool MeshOwnerHasBeenSet() const { return m_meshOwnerHasBeenSet; }
/**
* <p>The AWS IAM account ID of the service mesh owner. If the account ID is not
* your own, then it's
the ID of the account that shared the mesh
* with your account. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline void SetMeshOwner(const Aws::String& value) { m_meshOwnerHasBeenSet = true; m_meshOwner = value; }
/**
* <p>The AWS IAM account ID of the service mesh owner. If the account ID is not
* your own, then it's
the ID of the account that shared the mesh
* with your account. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline void SetMeshOwner(Aws::String&& value) { m_meshOwnerHasBeenSet = true; m_meshOwner = std::move(value); }
/**
* <p>The AWS IAM account ID of the service mesh owner. If the account ID is not
* your own, then it's
the ID of the account that shared the mesh
* with your account. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline void SetMeshOwner(const char* value) { m_meshOwnerHasBeenSet = true; m_meshOwner.assign(value); }
/**
* <p>The AWS IAM account ID of the service mesh owner. If the account ID is not
* your own, then it's
the ID of the account that shared the mesh
* with your account. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline VirtualNodeRef& WithMeshOwner(const Aws::String& value) { SetMeshOwner(value); return *this;}
/**
* <p>The AWS IAM account ID of the service mesh owner. If the account ID is not
* your own, then it's
the ID of the account that shared the mesh
* with your account. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline VirtualNodeRef& WithMeshOwner(Aws::String&& value) { SetMeshOwner(std::move(value)); return *this;}
/**
* <p>The AWS IAM account ID of the service mesh owner. If the account ID is not
* your own, then it's
the ID of the account that shared the mesh
* with your account. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline VirtualNodeRef& WithMeshOwner(const char* value) { SetMeshOwner(value); return *this;}
/**
* <p>The AWS IAM account ID of the resource owner. If the account ID is not your
* own, then it's
the ID of the mesh owner or of another account
* that the mesh is shared with. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline const Aws::String& GetResourceOwner() const{ return m_resourceOwner; }
/**
* <p>The AWS IAM account ID of the resource owner. If the account ID is not your
* own, then it's
the ID of the mesh owner or of another account
* that the mesh is shared with. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline bool ResourceOwnerHasBeenSet() const { return m_resourceOwnerHasBeenSet; }
/**
* <p>The AWS IAM account ID of the resource owner. If the account ID is not your
* own, then it's
the ID of the mesh owner or of another account
* that the mesh is shared with. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline void SetResourceOwner(const Aws::String& value) { m_resourceOwnerHasBeenSet = true; m_resourceOwner = value; }
/**
* <p>The AWS IAM account ID of the resource owner. If the account ID is not your
* own, then it's
the ID of the mesh owner or of another account
* that the mesh is shared with. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline void SetResourceOwner(Aws::String&& value) { m_resourceOwnerHasBeenSet = true; m_resourceOwner = std::move(value); }
/**
* <p>The AWS IAM account ID of the resource owner. If the account ID is not your
* own, then it's
the ID of the mesh owner or of another account
* that the mesh is shared with. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline void SetResourceOwner(const char* value) { m_resourceOwnerHasBeenSet = true; m_resourceOwner.assign(value); }
/**
* <p>The AWS IAM account ID of the resource owner. If the account ID is not your
* own, then it's
the ID of the mesh owner or of another account
* that the mesh is shared with. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline VirtualNodeRef& WithResourceOwner(const Aws::String& value) { SetResourceOwner(value); return *this;}
/**
* <p>The AWS IAM account ID of the resource owner. If the account ID is not your
* own, then it's
the ID of the mesh owner or of another account
* that the mesh is shared with. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline VirtualNodeRef& WithResourceOwner(Aws::String&& value) { SetResourceOwner(std::move(value)); return *this;}
/**
* <p>The AWS IAM account ID of the resource owner. If the account ID is not your
* own, then it's
the ID of the mesh owner or of another account
* that the mesh is shared with. For more information about mesh sharing, see <a
* href="https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html">Working
* with Shared Meshes</a>.</p>
*/
inline VirtualNodeRef& WithResourceOwner(const char* value) { SetResourceOwner(value); return *this;}
inline long long GetVersion() const{ return m_version; }
inline bool VersionHasBeenSet() const { return m_versionHasBeenSet; }
inline void SetVersion(long long value) { m_versionHasBeenSet = true; m_version = value; }
inline VirtualNodeRef& WithVersion(long long value) { SetVersion(value); return *this;}
/**
* <p>The name of the virtual node.</p>
*/
inline const Aws::String& GetVirtualNodeName() const{ return m_virtualNodeName; }
/**
* <p>The name of the virtual node.</p>
*/
inline bool VirtualNodeNameHasBeenSet() const { return m_virtualNodeNameHasBeenSet; }
/**
* <p>The name of the virtual node.</p>
*/
inline void SetVirtualNodeName(const Aws::String& value) { m_virtualNodeNameHasBeenSet = true; m_virtualNodeName = value; }
/**
* <p>The name of the virtual node.</p>
*/
inline void SetVirtualNodeName(Aws::String&& value) { m_virtualNodeNameHasBeenSet = true; m_virtualNodeName = std::move(value); }
/**
* <p>The name of the virtual node.</p>
*/
inline void SetVirtualNodeName(const char* value) { m_virtualNodeNameHasBeenSet = true; m_virtualNodeName.assign(value); }
/**
* <p>The name of the virtual node.</p>
*/
inline VirtualNodeRef& WithVirtualNodeName(const Aws::String& value) { SetVirtualNodeName(value); return *this;}
/**
* <p>The name of the virtual node.</p>
*/
inline VirtualNodeRef& WithVirtualNodeName(Aws::String&& value) { SetVirtualNodeName(std::move(value)); return *this;}
/**
* <p>The name of the virtual node.</p>
*/
inline VirtualNodeRef& WithVirtualNodeName(const char* value) { SetVirtualNodeName(value); return *this;}
private:
Aws::String m_arn;
bool m_arnHasBeenSet;
Aws::Utils::DateTime m_createdAt;
bool m_createdAtHasBeenSet;
Aws::Utils::DateTime m_lastUpdatedAt;
bool m_lastUpdatedAtHasBeenSet;
Aws::String m_meshName;
bool m_meshNameHasBeenSet;
Aws::String m_meshOwner;
bool m_meshOwnerHasBeenSet;
Aws::String m_resourceOwner;
bool m_resourceOwnerHasBeenSet;
long long m_version;
bool m_versionHasBeenSet;
Aws::String m_virtualNodeName;
bool m_virtualNodeNameHasBeenSet;
};
} // namespace Model
} // namespace AppMesh
} // namespace Aws
| [
"aws-sdk-cpp-automation@github.com"
] | aws-sdk-cpp-automation@github.com |
16f8773cdd5db3bde949064041c2b3ab896dffdc | f39316b4b6d7874d4cb92f741489b63958a3ee5f | /test/test_tc_mapper.cc | de0b0b45f185c420ac47e50f095c23816368cb89 | [
"Apache-2.0"
] | permissive | PhenixI/TensorComprehensions | 2f7b26c54c42cade9a5147d976a24a864a1a255c | 9a9fcf5f79454a9cbae079394a4c47c9255c13f3 | refs/heads/master | 2020-03-07T22:45:58.666068 | 2018-04-02T13:00:10 | 2018-04-02T13:00:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,323 | cc | /**
* Copyright (c) 2017-present, Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#include <iostream>
#include <string>
#include <ATen/ATen.h>
#include "tc/aten/aten_compiler.h"
#include "tc/core/cuda/cuda.h"
#include "tc/core/cuda/cuda_compilation_cache.h"
#include "tc/core/cuda/cuda_tc_executor.h"
#include "tc/core/scope_guard.h"
#include "test_harness_aten_cuda.h"
using namespace std;
using OutputsAndCuda = std::pair<std::vector<at::Tensor>, std::string>;
struct TcMapperTest : public ::testing::Test {
uint32_t M = 165, N = 197, K = 227;
int B = 100, D = 1000;
int C1 = 512, C2 = 8, C3 = 2, H = 28, W = 28;
template <typename CheckFunction>
OutputsAndCuda Check(
const std::string& tc,
const std::string& name,
const tc::CudaMappingOptions& mappingOptions,
const std::vector<at::Tensor> inputs,
CheckFunction checkFun) {
tc::CudaCache::enableCache();
std::vector<at::Tensor> outputs;
tc::ATenCompilationUnit<tc::CudaTcExecutor> atCompl;
atCompl.define(tc);
auto handle = atCompl.compile(name, inputs, mappingOptions);
atCompl.run(name, inputs, outputs, handle);
checkFun(inputs, outputs);
auto inputDLTensorsPair = tc::toConstDlpackTensors(inputs);
auto outputDLTensorsPair = tc::toConstDlpackTensors(outputs);
tc::ScopeGuard sg([&]() {
tc::deleteDlmTensors(inputDLTensorsPair.second);
tc::deleteDlmTensors(outputDLTensorsPair.second);
});
auto cached = tc::CudaCache::getCache()->retrieveKernel(
name,
mappingOptions,
inputDLTensorsPair.first,
outputDLTensorsPair.first);
EXPECT_FALSE(cached == nullptr);
return std::make_pair(std::move(outputs), std::move(cached->source));
}
};
///////////////////////////////////////////////////////////////////////////////
// 1-D reduction
// C +=! A(j)
///////////////////////////////////////////////////////////////////////////////
constexpr auto reduction1DTCs = {
R"TC(
def sum1D(float(M) A) -> (C) {
C(0) +=! A(j) where i in 0:2
}
)TC",
R"TC(
def sum1D(float(M) A) -> (C) {
C() +=! A(j)
}
)TC",
R"TC(
def sum1D(float(M) A) -> (C) {
C +=! A(j)
}
)TC",
R"TC(
def sum1D(float(M) A) -> (C) {
C(i) +=! A(j) where i in 0:1
}
)TC"};
struct TcMapper1DReductionTest : public TcMapperTest {
using TcMapperTest::Check;
using TcMapperTest::M;
OutputsAndCuda Check(
at::Tensor A,
const tc::CudaMappingOptions& mappingOptions,
uint32_t version = 0) {
CHECK_GE(3, version) << "Versions [0-3] supported, asked for: " << version;
auto refOutput = A.sum();
auto checkFun = [&, refOutput](
const std::vector<at::Tensor>& inputs,
const std::vector<at::Tensor>& outputs) {
TC_CUDA_RUNTIMEAPI_ENFORCE(cudaDeviceSynchronize());
at::Tensor diff = outputs[0].sub(refOutput);
return checkRtol(diff, inputs, M, 5e-7);
};
return Check(
*(reduction1DTCs.begin() + version),
"sum1D",
mappingOptions,
{A},
checkFun);
}
};
TEST_F(TcMapper1DReductionTest, DISABLED_Reduction1Dv0) {
auto mappingOptions = tc::CudaMappingOptions::makeNaiveCudaMappingOptions()
.tile(0)
.mapToBlocks({})
.mapToThreads({16});
LOG(INFO) << mappingOptions << endl;
at::Tensor A = at::CUDA(at::kFloat).rand({M});
Check(A, mappingOptions, 0);
}
TEST_F(TcMapper1DReductionTest, DISABLED_Reduction1Dv1) {
auto mappingOptions = tc::CudaMappingOptions::makeNaiveCudaMappingOptions()
.tile(0)
.mapToBlocks({})
.mapToThreads({16});
LOG(INFO) << mappingOptions << endl;
at::Tensor A = at::CUDA(at::kFloat).rand({M});
Check(A, mappingOptions, 1);
}
TEST_F(TcMapper1DReductionTest, DISABLED_Reduction1Dv2) {
auto mappingOptions = tc::CudaMappingOptions::makeNaiveCudaMappingOptions()
.tile(0)
.mapToBlocks({})
.mapToThreads({16});
LOG(INFO) << mappingOptions << endl;
at::Tensor A = at::CUDA(at::kFloat).rand({M});
Check(A, mappingOptions, 2);
}
TEST_F(TcMapper1DReductionTest, DISABLED_Reduction1Dv3) {
auto mappingOptions = tc::CudaMappingOptions::makeNaiveCudaMappingOptions()
.tile(0)
.mapToBlocks({})
.mapToThreads({16});
LOG(INFO) << mappingOptions << endl;
at::Tensor A = at::CUDA(at::kFloat).rand({M});
Check(A, mappingOptions, 3);
}
///////////////////////////////////////////////////////////////////////////////
// 2-D reduction
// C(i) +=! A(i, j)
///////////////////////////////////////////////////////////////////////////////
struct TcMapper2DReductionTest : public TcMapperTest {
using TcMapperTest::Check;
using TcMapperTest::M;
using TcMapperTest::N;
OutputsAndCuda Check(
at::Tensor A,
const tc::CudaMappingOptions& mappingOptions,
bool skipCheck = false) {
string tc = R"TC(
def sum2D(float(M, N) A) -> (C) {
C(i) +=! A(i, j)
}
)TC";
auto refOutput = A.sum(1);
auto checkFun = [&, refOutput](
const std::vector<at::Tensor>& inputs,
const std::vector<at::Tensor>& outputs) {
TC_CUDA_RUNTIMEAPI_ENFORCE(cudaDeviceSynchronize());
at::Tensor diff = outputs[0].sub(refOutput);
return checkRtol(diff, inputs, N, 5e-7);
};
auto noCheckFun = [](const std::vector<at::Tensor>& inputs,
std::vector<at::Tensor>& outputs) { return true; };
return skipCheck ? Check(tc, "sum2D", mappingOptions, {A}, noCheckFun)
: Check(tc, "sum2D", mappingOptions, {A}, checkFun);
}
};
TEST_F(TcMapper2DReductionTest, Reduction2D1) {
auto mappingOptions = tc::CudaMappingOptions::makeNaiveCudaMappingOptions()
.tile(32, 32)
.mapToBlocks({1, 1})
.mapToThreads({32})
.matchLibraryCalls(true);
LOG(INFO) << mappingOptions << endl;
at::Tensor A = at::CUDA(at::kFloat).rand({M, N});
Check(A, mappingOptions);
}
struct TcMapper2DReductionStressTest : public TcMapper2DReductionTest {
using TcMapper2DReductionTest::M;
using TcMapper2DReductionTest::N;
OutputsAndCuda
Check(size_t tix, size_t tiy, bool skipCheck = false, bool ones = false) {
M = tiy;
N = tix;
auto mappingOptions = tc::CudaMappingOptions::makeNaiveCudaMappingOptions()
.tile(tiy, tix)
.mapToBlocks({1})
.mapToThreads({tix, tiy})
.matchLibraryCalls(true);
LOG(INFO) << mappingOptions << endl;
at::Tensor A = ones ? at::CUDA(at::kFloat).ones({M, N})
: at::CUDA(at::kFloat).rand({M, N});
return TcMapper2DReductionTest::Check(A, mappingOptions, skipCheck);
}
};
TEST_F(TcMapper2DReductionStressTest, ThreadIdy1) {
for (int i : {1, 2, 4, 7, 8, 11, 15, 17, 24, 32, 35, 42, 64, 128, 130}) {
auto res = Check(i, 1);
if (i > 1) {
std::string expected = std::string("__tc::CubReduceAlongX<") +
std::to_string(i) + std::string(",1,1,__tc::ReductionOp::Sum>");
ASSERT_NE(std::string::npos, res.second.find(expected))
<< "In resulting code:\n"
<< res.second << "\ncould not find: " << expected;
} else {
std::string expected = "__tc::CubReduceAlongX<";
ASSERT_EQ(std::string::npos, res.second.find(expected))
<< "In resulting code:\n"
<< res.second << "\nfound unexpected: " << expected;
}
}
}
TEST_F(TcMapper2DReductionStressTest, 4x7) {
Check(4, 7);
}
TEST_F(TcMapper2DReductionStressTest, 11x5) {
Check(11, 5);
}
TEST_F(TcMapper2DReductionStressTest, 16x9) {
Check(16, 9);
}
TEST_F(TcMapper2DReductionStressTest, 8x11) {
Check(8, 11);
}
TEST_F(TcMapper2DReductionStressTest, 11x8) {
Check(11, 8);
}
TEST_F(TcMapper2DReductionStressTest, 111x7) {
Check(111, 7);
}
TEST_F(TcMapper2DReductionStressTest, 128x7) {
Check(128, 7);
}
TEST_F(TcMapper2DReductionStressTest, 7x128) {
Check(7, 128);
}
// Run this iterative example to find new cases
TEST_F(TcMapper2DReductionStressTest, Iterate) {
for (auto tix : {1, 2, 5, 8, 11}) {
for (auto tiy : {3, 5, 11}) {
Check(tix, tiy);
}
}
}
///////////////////////////////////////////////////////////////////////////////
// Matmul tests
// C(i, j) += A(i, k) * B(k, j)
///////////////////////////////////////////////////////////////////////////////
struct TcMapperMatmulTest : public TcMapperTest {
using TcMapperTest::Check;
using TcMapperTest::K;
using TcMapperTest::M;
using TcMapperTest::N;
OutputsAndCuda Check(
at::Tensor A,
at::Tensor B,
const tc::CudaMappingOptions& mappingOptions) {
string tc = R"TC(
def matmul(float(M, K) A, float(K, N) B) -> (C) {
C(i, j) +=! A(i, k) * B(k, j)
}
)TC";
auto refOutput = A.mm(B);
auto checkFun = [&, refOutput](
const std::vector<at::Tensor>& inputs,
const std::vector<at::Tensor>& outputs) {
TC_CUDA_RUNTIMEAPI_ENFORCE(cudaDeviceSynchronize());
at::Tensor diff = outputs[0].sub(refOutput);
return checkRtol(diff, inputs, K, 5e-7);
};
return Check(tc, "matmul", mappingOptions, {A, B}, checkFun);
}
};
TEST_F(TcMapperMatmulTest, Matmul1DSchedule) {
auto mappingOptions = tc::CudaMappingOptions::makeNaiveCudaMappingOptions()
.fixParametersBeforeScheduling(true)
.tile(1, 1, K)
.mapToBlocks({M, N})
.mapToThreads({std::min(32u, K)})
.matchLibraryCalls(true);
LOG(INFO) << mappingOptions << endl;
at::Tensor A = at::CUDA(at::kFloat).rand({M, K});
at::Tensor B = at::CUDA(at::kFloat).rand({K, N});
Check(A, B, mappingOptions);
}
TEST_F(TcMapperMatmulTest, Matmul1DScheduleMultipleOccurrence) {
// Without full specialization, AST generator will duplicate the first
// statement C[i][j] = 0.0f (for K > 0 and K < 0). The codegen must be able
// to handle the same statement appearing in different contexts.
auto mappingOptions = tc::CudaMappingOptions::makeMlpCudaMappingOptions()
.fixParametersBeforeScheduling(false)
.tile(32, 32, 32)
.mapToBlocks({8})
.mapToThreads({16})
.matchLibraryCalls(true);
LOG(INFO) << mappingOptions << endl;
at::Tensor A = at::CUDA(at::kFloat).rand({M, K});
at::Tensor B = at::CUDA(at::kFloat).rand({K, N});
Check(A, B, mappingOptions);
}
TEST_F(TcMapperMatmulTest, Matmul3DSchedule) {
auto mappingOptions = tc::CudaMappingOptions::makeNaiveCudaMappingOptions()
.fixParametersBeforeScheduling(true)
.mapToBlocks({1, 1, 1})
.mapToThreads({4, 1, 1});
mappingOptions.matchLibraryCalls(true);
LOG(INFO) << mappingOptions << endl;
at::Tensor A = at::CUDA(at::kFloat).rand({M, K});
at::Tensor B = at::CUDA(at::kFloat).rand({K, N});
Check(A, B, mappingOptions);
}
TEST_F(TcMapperMatmulTest, Matmul3DScheduleMultipleOccurrence) {
auto mappingOptions = tc::CudaMappingOptions::makeMlpCudaMappingOptions()
.tile(32, 32, 32)
.mapToBlocks({8})
.mapToThreads({16})
.matchLibraryCalls(true);
LOG(INFO) << mappingOptions << endl;
at::Tensor A = at::CUDA(at::kFloat).rand({M, K});
at::Tensor B = at::CUDA(at::kFloat).rand({K, N});
Check(A, B, mappingOptions);
}
///////////////////////////////////////////////////////////////////////////////
// Batch Matmul tests
// Z(b, n, k) += X(b, n, mm) * Y(b, mm, k)
///////////////////////////////////////////////////////////////////////////////
struct TcMapperBatchMatmulTest : public TcMapperTest {
using TcMapperTest::Check;
using TcMapperTest::K;
using TcMapperTest::M;
using TcMapperTest::N;
OutputsAndCuda Check(
at::Tensor A,
at::Tensor B,
const tc::CudaMappingOptions& mappingOptions) {
string tc = R"TC(
def batch_matmul(float(B, N, M) X, float(B, M, K) Y) -> (Z) {
Z(b, n, k) +=! X(b, n, mm) * Y(b, mm, k)
}
)TC";
auto refOutput = A.bmm(B);
auto checkFun = [&, refOutput](
const std::vector<at::Tensor>& inputs,
const std::vector<at::Tensor>& outputs) {
TC_CUDA_RUNTIMEAPI_ENFORCE(cudaDeviceSynchronize());
at::Tensor diff = outputs[0].sub(refOutput);
return checkRtol(diff, inputs, K, 5e-7);
};
return Check(tc, "batch_matmul", mappingOptions, {A, B}, checkFun);
}
};
TEST_F(TcMapperBatchMatmulTest, BatchMatmul) {
auto mappingOptions = tc::CudaMappingOptions::makeNaiveCudaMappingOptions()
.tile(1)
.mapToThreads({123})
.mapToBlocks({50})
.usePrivateMemory(true)
.useSharedMemory(true);
mappingOptions.matchLibraryCalls(true);
LOG(INFO) << mappingOptions << endl;
at::Tensor A = at::CUDA(at::kFloat).rand({50, 26, 72});
at::Tensor B = at::CUDA(at::kFloat).rand({50, 72, 26});
Check(A, B, mappingOptions);
}
///////////////////////////////////////////////////////////////////////////////
// Hadamard tests
// Z(b, d) = U(b, d) * V(b, d) * W(b, d)
///////////////////////////////////////////////////////////////////////////////
TEST_F(TcMapperTest, BatchTripleHadamard) {
at::Tensor U = at::CUDA(at::kFloat).rand({B, D});
at::Tensor V = at::CUDA(at::kFloat).rand({B, D});
at::Tensor W = at::CUDA(at::kFloat).rand({B, D});
std::vector<at::Tensor> inputs = {U, V, W};
std::vector<at::Tensor> outputs;
static constexpr auto TC = R"TC(
def batch_triple_hadamard(float(B, D) U,
float(B, D) V,
float(B, D) W)
-> (Z)
{
Z(b, d) = U(b, d) * V(b, d) * W(b, d)
}
)TC";
auto checkFun = [=](const std::vector<at::Tensor>& inputs,
std::vector<at::Tensor>& outputs) {
at::Tensor diff = outputs[0].sub(inputs[0] * inputs[1] * inputs[2]);
checkRtol(diff, inputs, D);
};
Check(
TC,
"batch_triple_hadamard",
tc::CudaMappingOptions::makeNaiveCudaMappingOptions(),
inputs,
checkFun);
}
TEST_F(TcMapperTest, TensorDot) {
N = 32;
at::Tensor I0 = at::CUDA(at::kFloat).rand({N, C1, C2, H, W});
at::Tensor I1 = at::CUDA(at::kFloat).rand({N, C2, C3, H, W});
std::vector<at::Tensor> inputs = {I0, I1};
std::vector<at::Tensor> outputs;
static constexpr auto TC = R"TC(
def tensordot(float(N, C1, C2, H, W) I0,
float(N, C2, C3, H, W) I1)
-> (O)
{
O(n, c1, c3, h, w) +=! I0(n, c1, c2, h, w) * I1(n, c2, c3, h, w)
}
)TC";
// No defaults for this case
auto checkFun = [](const std::vector<at::Tensor>& inputs,
std::vector<at::Tensor>& outputs) { return true; };
auto options = tc::CudaMappingOptions::makeNaiveCudaMappingOptions();
auto name = "tensordot";
Check(TC, name, options, inputs, checkFun);
::benchmarkKernelOptions(TC, name, inputs, options);
}
TEST_F(TcMapperTest, LUT) {
const int B = 17, N = 82, R = 22;
at::Tensor LUT = at::CUDA(at::kFloat).rand({B, R});
at::Tensor I =
at::CUDA(at::kFloat).rand({B, N}).mul_(B).floor_().toType(at::kInt);
std::vector<at::Tensor> inputs = {LUT, I};
std::vector<at::Tensor> outputs;
static constexpr auto TC = R"TC(
def fun(float(B, R) LUT, int32(B, N) I) -> (O) {
O(b, n) +=! LUT(I(b, n), r)
}
)TC";
auto checkFun = [=](const std::vector<at::Tensor>& inputs,
std::vector<at::Tensor>& outputs) {
at::Tensor LUT = inputs[0].toBackend(at::kCPU);
at::Tensor I = inputs[1].toBackend(at::kCPU);
at::Tensor O = outputs[0].toBackend(at::kCPU);
auto LUTAccessor = LUT.accessor<float, 2>();
auto IAccessor = I.accessor<int, 2>();
auto OAccessor = O.accessor<float, 2>();
for (int b = 0; b < B; b++) {
for (int n = 0; n < N; n++) {
float correct = 0;
for (int r = 0; r < R; r++) {
int idx = IAccessor[b][n];
CHECK(idx >= 0 && idx < B);
correct += LUTAccessor[idx][r];
}
OAccessor[b][n] -= correct;
}
}
checkRtol(O, inputs, 5e-7);
};
Check(
TC,
"fun",
tc::CudaMappingOptions::makeNaiveCudaMappingOptions(),
inputs,
checkFun);
}
TEST_F(TcMapperTest, DISABLED_SpatialBatchNormalization) {
N = 32;
at::Tensor eps = at::CUDA(at::kFloat).rand({});
eps[0] = 1.0f;
at::Tensor momentum = at::CUDA(at::kFloat).rand({});
momentum[0] = 1.0;
at::Tensor I = at::CUDA(at::kFloat).rand({N, C2, H, W});
at::Tensor rMeanIn = at::CUDA(at::kFloat).rand({C2});
at::Tensor rVarIn = at::CUDA(at::kFloat).rand({C2});
std::vector<at::Tensor> inputs = {momentum, eps, I, rMeanIn, rVarIn};
std::vector<at::Tensor> outputs;
static constexpr auto TC = R"TC(
def spatial_batch_norm(
float momentum, float eps,
float(N,C,H,W) I, float(C) rMeanIn, float(C) rVarIn)
-> (O, rMeanOut, rVarOut, mean, centered, variance, expectedVariance, normalizedOut)
{
mean(c) +=! I(nn, c, hh, ww)
mean(c) = mean(c) / (N * H * W)
rMeanOut(c) = (1 - momentum) * rMeanIn(c) + momentum * mean(c)
centered(n, c, h, w) = I(n, c, h, w) - rMeanOut(c)
variance(n, c, h, w) = centered(n, c, h, w) * centered(n, c, h, w)
expectedVariance(c) +=! (variance(n, c, h, w) + eps) / (N * H * W)
rVarOut(c) = rsqrt(
(1 - momentum) * rVarIn(c) + momentum * expectedVariance(c))
O(n, c, h, w) = centered(n, c, h, w) * rVarOut(c)
normalizedOut(n, c, h, w) = O(n, c, h, w)
})TC";
auto checkFun = [=](const std::vector<at::Tensor>& inputs,
std::vector<at::Tensor>& outputs) {
TC_CUDA_RUNTIMEAPI_ENFORCE(cudaDeviceSynchronize());
double prec = 3e-7;
std::cout << "Checking expected output relative precision @" << prec;
bool training = true;
at::Tensor weight = at::CUDA(at::kFloat).ones({C1});
at::Tensor bias = at::CUDA(at::kFloat).zeros({C1});
auto save_mean = outputs[1].clone().zero_();
auto save_std = outputs[2].clone().zero_();
auto O = at::batch_norm_forward(
I,
weight,
bias,
rMeanIn,
rVarIn,
training,
at::Scalar(momentum).toFloat(),
at::Scalar(eps).toFloat(),
save_mean,
save_std);
auto diff = O.sub(outputs[0]);
checkRtol(diff, inputs, N * H * W, prec);
};
auto name = "spatial_batch_norm";
auto options = tc::CudaMappingOptions::makeNaiveCudaMappingOptions()
.outerScheduleFusionStrategy(tc::FusionStrategy::Max)
.intraTileScheduleFusionStrategy(tc::FusionStrategy::Min)
.tile(0)
.mapToBlocks({1})
.mapToThreads({32, 4});
Check(TC, name, options, inputs, checkFun);
::benchmarkKernelOptions(TC, name, inputs, options);
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
::gflags::ParseCommandLineFlags(&argc, &argv, true);
::google::InitGoogleLogging(argv[0]);
setAtenSeed(tc::initRandomSeed(), at::Backend::CUDA);
return RUN_ALL_TESTS();
}
| [
"nicolas.vasilache@gmail.com"
] | nicolas.vasilache@gmail.com |
ed3419c0787d454450562a96dc81ca0727160bc2 | 4fb0a3b01c54732282ee3f59a405b1995cf7ed10 | /chinese-query-app/cspcolor.cpp | 9c2890c2eb3365550cc0550f692e340023a280d5 | [] | no_license | gengtianuiowa/China-Query-App | f56dff520efa2aa29410207c2db052ba13f9eb43 | c30e67194faf63d6048cb7aa248861d1d50f0c1c | refs/heads/master | 2022-11-19T16:07:16.882687 | 2020-07-02T01:35:49 | 2020-07-02T01:35:49 | 215,859,477 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 49 | cpp | #include "cspcolor.h"
CSpColor::CSpColor()
{
}
| [
"56332753+gengtianuiowa@users.noreply.github.com"
] | 56332753+gengtianuiowa@users.noreply.github.com |
5851d5c3687fa8dfec289ec433ade7ded925d6d2 | 1994e87b87f815a894752d7a34906a75a4c0fbfd | /asteroids/src/utils.cpp | 8979143dc50379fec984e408d895a8044b04c3e6 | [] | no_license | Small-Embedded-Systems/assignment-2-asteroids-Usernarne | 1fb92a8391d47665f3959e35c306a4b532327dd8 | d1cecdf4d161c01a4ba43d8509f0a5fcd6762b99 | refs/heads/master | 2020-12-30T13:47:02.246924 | 2017-05-14T19:35:03 | 2017-05-14T19:35:03 | 91,257,868 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,410 | cpp | /*
* Assignment 2 - Small Embedded Systems.
* Constantin Strobel, 15004712 and Leon Riseborough, 1
*
* This file is responsible for performing calculations for norm, lerp, map
* randrange and radians.
*/
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include "model.h"
/*
* This method calculates the norm value which is the minimum value devided by the maximum value.
*/
float norm(float value, float min, float max)
{
return (value-min)/(max-min);
}
/*
* This method calculates the difference between minimum and maximum.
*/
float lerp(float min, float max, float value)
{
return max*value+(1.0f-value)*min;
}
/*
* This method calculates the size of the map needed to implement lerp(min and max),
* norm(min and max), value, lower and upper.
*/
float map(float value, float lower, float upper, float min, float max)
{
return lerp(min,max, norm(value,lower,upper));
}
/*
* This method calculates the randrange. Only numbers between 0 to 359 can be used.
*/
int randrange(int from, int to)
{
int range = to-from;
return from + rand()%range;
}
const float pi = 3.1415926f; // This converts degrees into radians using the pi number.
/*
* This method returns the radiant, which is pi multiplied by degrees divided by 180.
*/
float radians(float degrees)
{
return pi*(degrees/180);
}
| [
"noreply@github.com"
] | Small-Embedded-Systems.noreply@github.com |
773b698c0eac2d883e2e4634e1da2b9e04620bf1 | b5a9d42f7ea5e26cd82b3be2b26c324d5da79ba1 | /tensorflow/lite/delegates/gpu/gl/compiler/preprocessor.cc | 08f02139e20c95c06af6fda1dc20e85b3717040b | [
"Apache-2.0"
] | permissive | uve/tensorflow | e48cb29f39ed24ee27e81afd1687960682e1fbef | e08079463bf43e5963acc41da1f57e95603f8080 | refs/heads/master | 2020-11-29T11:30:40.391232 | 2020-01-11T13:43:10 | 2020-01-11T13:43:10 | 230,088,347 | 0 | 0 | Apache-2.0 | 2019-12-25T10:49:15 | 2019-12-25T10:49:14 | null | UTF-8 | C++ | false | false | 3,329 | cc | /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/lite/delegates/gpu/gl/compiler/preprocessor.h"
#include "absl/strings/str_cat.h"
#include "tensorflow/lite/delegates/gpu/common/status.h"
namespace tflite {
namespace gpu {
namespace gl {
namespace {
// Given input string and a delimiter returns back a substring including
// delimiters. If there was only starting delimiter found, returns single char.
absl::string_view FindInlineBlock(absl::string_view s, char delimiter) {
size_t start = s.find(delimiter);
if (start != absl::string_view::npos) {
size_t end = s.find(delimiter, start + 1);
if (end != std::string::npos) {
return s.substr(start, end - start + 1);
}
// Special case to indicate that we didn't find the end.
return s.substr(start, 1);
}
return s.substr(s.size(), 0);
}
// For the given 's' and its substring 'subs' returns new substring of 's' that
// begins past 'subs'.
absl::string_view PastSubstr(absl::string_view s, absl::string_view subs) {
return s.substr(subs.data() + subs.size() - s.data());
}
} // namespace
Status TextPreprocessor::Rewrite(const std::string& input,
std::string* output) {
absl::string_view s = input;
std::string result;
while (true) {
absl::string_view inline_block = FindInlineBlock(s, inline_delimiter_);
result.append(s.data(), inline_block.data() - s.data());
if (inline_block.empty()) {
break;
}
if (inline_block.size() == 1) {
return NotFoundError("Unable to find end of inline block");
}
s = PastSubstr(s, inline_block);
bool processed = false;
for (auto& rewrite : inline_rewrites_) {
if (processed) {
break;
}
switch (rewrite->Rewrite(inline_block.substr(1, inline_block.size() - 2),
&result)) {
case RewriteStatus::NOT_RECOGNIZED:
// try another rewrite.
break;
case RewriteStatus::SUCCESS:
processed = true;
break;
case RewriteStatus::ERROR:
return InternalError(absl::StrCat("Error while rewriting '",
inline_block, "': ", result));
}
}
if (!processed) {
if (!keep_unknown_rewrites_) {
return NotFoundError(absl::StrCat("Didn't find inline rewrite for '",
inline_block, "'"));
}
absl::StrAppend(&result, inline_block);
}
}
*output = std::move(result);
return OkStatus();
}
} // namespace gl
} // namespace gpu
} // namespace tflite
| [
"v-grniki@microsoft.com"
] | v-grniki@microsoft.com |
1b1a92bc84ec8a7ff0442e21a4eff89d887b41fd | 6520fd51fd3d10fb7539e28cc132721ca98e60d7 | /ObserverPattern/ForecastDisplay.h | f0b27f38e5ac947b0cc263b75c0d16bc05398144 | [] | no_license | saccha07/cuddly-goggles | 589ef6083377e3fbd1ded085efefd4a7296822bc | 6d3351aae8237072a6ed47fee18afb8b3fcb321a | refs/heads/master | 2022-08-14T19:26:37.464031 | 2022-07-29T10:32:56 | 2022-07-29T10:32:56 | 243,758,660 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 256 | h | #ifndef FORECAST_DISPLAY_
#define FORECAST_DISPLAY_
#include "Subject.h"
#include "Observer.h"
#include "DisplayElement.h"
class ForecastDisplay: public Observer,public DisplayElement
{
public:
ForecastDisplay();
void update();
void display();
};
#endif
| [
"noreply@github.com"
] | saccha07.noreply@github.com |
77d7066b792198f2775c5249b28e73bb172f2d3c | 63c71060f36866bca4ac27304cef6d5755fdc35c | /src/GICs/GicFloatingVpd.cpp | 18ef79d1561f2e63eb39849dadbe461c2b33f9e3 | [] | no_license | 15831944/barry_dev | bc8441cbfbd4b62fbb42bee3dcb79ff7f5fcaf8a | d4a83421458aa28ca293caa7a5567433e9358596 | refs/heads/master | 2022-03-24T07:00:26.810732 | 2015-12-22T07:19:58 | 2015-12-22T07:19:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,649 | cpp | ////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2005
// Packet Engineering, Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification is not permitted unless authorized in writing by a duly
// appointed officer of Packet Engineering, Inc. or its derivatives
//
// Description:
//
//
// Modification History:
// 07/08/2010: Created by Tracy
////////////////////////////////////////////////////////////////////////////
#include "GICs/GicFloatingVpd.h"
#include "HtmlUtil/HtmlUtil.h"
#include "XmlUtil/Ptrs.h"
#include "XmlUtil/XmlTag.h"
#include "Util/RCObject.h"
#include "Util/RCObjImp.h"
#include "Util/String.h"
// static AosGicPtr sgGic = new AosGicFloatingVpd();
AosGicFloatingVpd::AosGicFloatingVpd(const bool flag)
:
AosGic(AOSGIC_FLOATINGVPD, AosGicType::eFloatingVpd, flag)
{
}
AosGicFloatingVpd::~AosGicFloatingVpd()
{
}
bool
AosGicFloatingVpd::generateCode(
const AosHtmlReqProcPtr &htmlPtr,
AosXmlTagPtr &vpd,
const AosXmlTagPtr &obj,
const OmnString &parentid,
AosHtmlCode &code)
{
// This function will generate:
// 1. HTML code
// 2. CSS code
// 3. JavaScript Code
// 4. Flash code
// Tracy, = Debug
code.mJson
<< ",gic_vpdname: \"" << vpd->getAttrStr("gic_vpdname", "vpd_Jimmy")
<< "\",gic_iconsrc: \"" << vpd->getAttrStr("gic_iconsrc", "img101/ai7631.jpg")
<< "\",gic_moviconsrc: \"" << vpd->getAttrStr("gic_moviconsrc", "a1/ai4215.png")
<< "\",gic_iconww: " << vpd->getAttrInt("gic_iconww", 18)
<< ",gic_movable:" << vpd->getAttrStr("gic_movable", "true");
return true;
}
| [
"barryniu@jimodb.com"
] | barryniu@jimodb.com |
4d8ea4f0d3bb8c8f8097f919aa8118b3dbb87ac8 | 710bb2a30f464ee28d437e870dfe7944c829521b | /Phone_Interface/SeeedStudioTFTv2/SPI_TFT_ILI9341/SPI_TFT_ILI9341.cpp | 3557f8e503959bd775e314b80755d8499b01a8e1 | [] | no_license | akuhlens/phone | 8075a607c3431e6ed8709a61de89ed56158c0425 | 4b637c2baf04cb59d8caf93b16e95e50efd498e9 | refs/heads/master | 2021-01-02T09:33:21.195301 | 2014-10-28T14:16:07 | 2014-10-28T14:16:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,253 | cpp | /* mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller
* Copyright (c) 2013 Peter Drescher - DC2PD
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// 12.06.13 fork from SPI_TFT code because controller is different ...
// 14.07.13 Test with real display and bugfix
// 18.10.13 Better Circle function from Michael Ammann
// 22.10.13 Fixes for Kinetis Board - 8 bit spi
#include "SPI_TFT_ILI9341.h"
#include "mbed.h"
#define BPP 16 // Bits per pixel
//extern Serial pc;
//extern DigitalOut xx; // debug !!
SPI_TFT_ILI9341::SPI_TFT_ILI9341(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset, PinName dc, const char *name)
: GraphicsDisplay(name), _spi(mosi, miso, sclk), _cs(cs), _dc(dc)
{
orientation = 0;
char_x = 0;
_reset = reset;
tft_reset();
}
int SPI_TFT_ILI9341::width()
{
if (orientation == 0 || orientation == 2) return 240;
else return 320;
}
int SPI_TFT_ILI9341::height()
{
if (orientation == 0 || orientation == 2) return 320;
else return 240;
}
void SPI_TFT_ILI9341::set_orientation(unsigned int o)
{
orientation = o;
wr_cmd(0x36); // MEMORY_ACCESS_CONTROL
switch (orientation) {
case 0:
_spi.write(0x48);
break;
case 1:
_spi.write(0x28);
break;
case 2:
_spi.write(0x88);
break;
case 3:
_spi.write(0xE8);
break;
}
_cs = 1;
WindowMax();
}
// write command to tft register
void SPI_TFT_ILI9341::wr_cmd(unsigned char cmd)
{
_dc = 0;
_cs = 0;
_spi.write(cmd); // mbed lib
_dc = 1;
}
void SPI_TFT_ILI9341::wr_dat(unsigned char dat)
{
_spi.write(dat); // mbed lib
}
// the ILI9341 can read - has to be implemented later
// A read will return 0 at the moment
//unsigned short SPI_TFT_ILI9341::rd_dat (void)
//{
// unsigned short val = 0;
//val = _spi.write(0x73ff); /* Dummy read 1 */
//val = _spi.write(0x0000); /* Read D8..D15 */
// return (val);
//}
// Init code based on MI0283QT datasheet
void SPI_TFT_ILI9341::tft_reset()
{
_spi.format(8,3); // 8 bit spi mode 3
_spi.frequency(10000000); // 10 Mhz SPI clock
_cs = 1; // cs high
_dc = 1; // dc high
if (_reset != NC)
{
DigitalOut rst(_reset);
rst = 0; // display reset
wait_us(50);
rst = 1; // end hardware reset
}
wait_ms(5);
wr_cmd(0x01); // SW reset
wait_ms(5);
wr_cmd(0x28); // display off
/* Start Initial Sequence ----------------------------------------------------*/
wr_cmd(0xCF);
_spi.write(0x00);
_spi.write(0x83);
_spi.write(0x30);
_cs = 1;
wr_cmd(0xED);
_spi.write(0x64);
_spi.write(0x03);
_spi.write(0x12);
_spi.write(0x81);
_cs = 1;
wr_cmd(0xE8);
_spi.write(0x85);
_spi.write(0x01);
_spi.write(0x79);
_cs = 1;
wr_cmd(0xCB);
_spi.write(0x39);
_spi.write(0x2C);
_spi.write(0x00);
_spi.write(0x34);
_spi.write(0x02);
_cs = 1;
wr_cmd(0xF7);
_spi.write(0x20);
_cs = 1;
wr_cmd(0xEA);
_spi.write(0x00);
_spi.write(0x00);
_cs = 1;
wr_cmd(0xC0); // POWER_CONTROL_1
_spi.write(0x26);
_cs = 1;
wr_cmd(0xC1); // POWER_CONTROL_2
_spi.write(0x11);
_cs = 1;
wr_cmd(0xC5); // VCOM_CONTROL_1
_spi.write(0x35);
_spi.write(0x3E);
_cs = 1;
wr_cmd(0xC7); // VCOM_CONTROL_2
_spi.write(0xBE);
_cs = 1;
wr_cmd(0x36); // MEMORY_ACCESS_CONTROL
_spi.write(0x48);
_cs = 1;
wr_cmd(0x3A); // COLMOD_PIXEL_FORMAT_SET
_spi.write(0x55); // 16 bit pixel
_cs = 1;
wr_cmd(0xB1); // Frame Rate
_spi.write(0x00);
_spi.write(0x1B);
_cs = 1;
wr_cmd(0xF2); // Gamma Function Disable
_spi.write(0x08);
_cs = 1;
wr_cmd(0x26);
_spi.write(0x01); // gamma set for curve 01/2/04/08
_cs = 1;
wr_cmd(0xE0); // positive gamma correction
_spi.write(0x1F);
_spi.write(0x1A);
_spi.write(0x18);
_spi.write(0x0A);
_spi.write(0x0F);
_spi.write(0x06);
_spi.write(0x45);
_spi.write(0x87);
_spi.write(0x32);
_spi.write(0x0A);
_spi.write(0x07);
_spi.write(0x02);
_spi.write(0x07);
_spi.write(0x05);
_spi.write(0x00);
_cs = 1;
wr_cmd(0xE1); // negativ gamma correction
_spi.write(0x00);
_spi.write(0x25);
_spi.write(0x27);
_spi.write(0x05);
_spi.write(0x10);
_spi.write(0x09);
_spi.write(0x3A);
_spi.write(0x78);
_spi.write(0x4D);
_spi.write(0x05);
_spi.write(0x18);
_spi.write(0x0D);
_spi.write(0x38);
_spi.write(0x3A);
_spi.write(0x1F);
_cs = 1;
WindowMax ();
//wr_cmd(0x34); // tearing effect off
//_cs = 1;
//wr_cmd(0x35); // tearing effect on
//_cs = 1;
wr_cmd(0xB7); // entry mode
_spi.write(0x07);
_cs = 1;
wr_cmd(0xB6); // display function control
_spi.write(0x0A);
_spi.write(0x82);
_spi.write(0x27);
_spi.write(0x00);
_cs = 1;
wr_cmd(0x11); // sleep out
_cs = 1;
wait_ms(100);
wr_cmd(0x29); // display on
_cs = 1;
wait_ms(100);
}
void SPI_TFT_ILI9341::pixel(int x, int y, int color)
{
wr_cmd(0x2A);
_spi.write(x >> 8);
_spi.write(x);
_cs = 1;
wr_cmd(0x2B);
_spi.write(y >> 8);
_spi.write(y);
_cs = 1;
wr_cmd(0x2C); // send pixel
#if defined TARGET_KL25Z // 8 Bit SPI
_spi.write(color >> 8);
_spi.write(color & 0xff);
#else
_spi.format(16,3); // switch to 16 bit Mode 3
_spi.write(color); // Write D0..D15
_spi.format(8,3);
#endif
_cs = 1;
}
void SPI_TFT_ILI9341::window (unsigned int x, unsigned int y, unsigned int w, unsigned int h)
{
wr_cmd(0x2A);
_spi.write(x >> 8);
_spi.write(x);
_spi.write((x+w-1) >> 8);
_spi.write(x+w-1);
_cs = 1;
wr_cmd(0x2B);
_spi.write(y >> 8);
_spi.write(y);
_spi.write((y+h-1) >> 8);
_spi.write(y+h-1);
_cs = 1;
}
void SPI_TFT_ILI9341::WindowMax (void)
{
window (0, 0, width(), height());
}
void SPI_TFT_ILI9341::cls (void)
{
int pixel = ( width() * height());
WindowMax();
wr_cmd(0x2C); // send pixel
#if defined TARGET_KL25Z // 8 Bit SPI
unsigned int i;
for (i = 0; i < ( width() * height()); i++){
_spi.write(_background >> 8);
_spi.write(_background & 0xff);
}
#else
_spi.format(16,3); // switch to 16 bit Mode 3
unsigned int i;
for (i = 0; i < ( width() * height()); i++)
_spi.write(_background);
_spi.format(8,3);
#endif
_cs = 1;
}
void SPI_TFT_ILI9341::circle(int x0, int y0, int r, int color)
{
int x = -r, y = 0, err = 2-2*r, e2;
do {
pixel(x0-x, y0+y,color);
pixel(x0+x, y0+y,color);
pixel(x0+x, y0-y,color);
pixel(x0-x, y0-y,color);
e2 = err;
if (e2 <= y) {
err += ++y*2+1;
if (-x == y && e2 <= x) e2 = 0;
}
if (e2 > x) err += ++x*2+1;
} while (x <= 0);
}
void SPI_TFT_ILI9341::fillcircle(int x0, int y0, int r, int color)
{
int x = -r, y = 0, err = 2-2*r, e2;
do {
vline(x0-x, y0-y, y0+y, color);
vline(x0+x, y0-y, y0+y, color);
e2 = err;
if (e2 <= y) {
err += ++y*2+1;
if (-x == y && e2 <= x) e2 = 0;
}
if (e2 > x) err += ++x*2+1;
} while (x <= 0);
}
void SPI_TFT_ILI9341::hline(int x0, int x1, int y, int color)
{
int w;
w = x1 - x0 + 1;
window(x0,y,w,1);
wr_cmd(0x2C); // send pixel
#if defined TARGET_KL25Z // 8 Bit SPI
int j;
for (j=0; j<w; j++) {
_spi.write(color >> 8);
_spi.write(color & 0xff);
}
#else
_spi.format(16,3); // switch to 16 bit Mode 3
int j;
for (j=0; j<w; j++) {
_spi.write(color);
}
_spi.format(8,3);
#endif
_cs = 1;
WindowMax();
return;
}
void SPI_TFT_ILI9341::vline(int x, int y0, int y1, int color)
{
int h;
h = y1 - y0 + 1;
window(x,y0,1,h);
wr_cmd(0x2C); // send pixel
#if defined TARGET_KL25Z // 8 Bit SPI
for (int y=0; y<h; y++) {
_spi.write(color >> 8);
_spi.write(color & 0xff);
}
#else
_spi.format(16,3); // switch to 16 bit Mode 3
for (int y=0; y<h; y++) {
_spi.write(color);
}
_spi.format(8,3);
#endif
_cs = 1;
WindowMax();
return;
}
void SPI_TFT_ILI9341::line(int x0, int y0, int x1, int y1, int color)
{
//WindowMax();
int dx = 0, dy = 0;
int dx_sym = 0, dy_sym = 0;
int dx_x2 = 0, dy_x2 = 0;
int di = 0;
dx = x1-x0;
dy = y1-y0;
if (dx == 0) { /* vertical line */
if (y1 > y0) vline(x0,y0,y1,color);
else vline(x0,y1,y0,color);
return;
}
if (dx > 0) {
dx_sym = 1;
} else {
dx_sym = -1;
}
if (dy == 0) { /* horizontal line */
if (x1 > x0) hline(x0,x1,y0,color);
else hline(x1,x0,y0,color);
return;
}
if (dy > 0) {
dy_sym = 1;
} else {
dy_sym = -1;
}
dx = dx_sym*dx;
dy = dy_sym*dy;
dx_x2 = dx*2;
dy_x2 = dy*2;
if (dx >= dy) {
di = dy_x2 - dx;
while (x0 != x1) {
pixel(x0, y0, color);
x0 += dx_sym;
if (di<0) {
di += dy_x2;
} else {
di += dy_x2 - dx_x2;
y0 += dy_sym;
}
}
pixel(x0, y0, color);
} else {
di = dx_x2 - dy;
while (y0 != y1) {
pixel(x0, y0, color);
y0 += dy_sym;
if (di < 0) {
di += dx_x2;
} else {
di += dx_x2 - dy_x2;
x0 += dx_sym;
}
}
pixel(x0, y0, color);
}
return;
}
void SPI_TFT_ILI9341::rect(int x0, int y0, int x1, int y1, int color)
{
if (x1 > x0) hline(x0,x1,y0,color);
else hline(x1,x0,y0,color);
if (y1 > y0) vline(x0,y0,y1,color);
else vline(x0,y1,y0,color);
if (x1 > x0) hline(x0,x1,y1,color);
else hline(x1,x0,y1,color);
if (y1 > y0) vline(x1,y0,y1,color);
else vline(x1,y1,y0,color);
return;
}
void SPI_TFT_ILI9341::fillrect(int x0, int y0, int x1, int y1, int color)
{
int h = y1 - y0 + 1;
int w = x1 - x0 + 1;
int pixel = h * w;
window(x0,y0,w,h);
wr_cmd(0x2C); // send pixel
#if defined TARGET_KL25Z // 8 Bit SPI
for (int p=0; p<pixel; p++) {
_spi.write(color >> 8);
_spi.write(color & 0xff);
}
#else
_spi.format(16,3); // switch to 16 bit Mode 3
for (int p=0; p<pixel; p++) {
_spi.write(color);
}
_spi.format(8,3);
#endif
_cs = 1;
WindowMax();
return;
}
void SPI_TFT_ILI9341::locate(int x, int y)
{
char_x = x;
char_y = y;
}
int SPI_TFT_ILI9341::columns()
{
return width() / font[1];
}
int SPI_TFT_ILI9341::rows()
{
return height() / font[2];
}
int SPI_TFT_ILI9341::_putc(int value)
{
if (value == '\n') { // new line
char_x = 0;
char_y = char_y + font[2];
if (char_y >= height() - font[2]) {
char_y = 0;
}
} else {
character(char_x, char_y, value);
}
return value;
}
void SPI_TFT_ILI9341::character(int x, int y, int c)
{
unsigned int hor,vert,offset,bpl,j,i,b;
unsigned char* zeichen;
unsigned char z,w;
if ((c < 31) || (c > 127)) return; // test char range
// read font parameter from start of array
offset = font[0]; // bytes / char
hor = font[1]; // get hor size of font
vert = font[2]; // get vert size of font
bpl = font[3]; // bytes per line
if (char_x + hor > width()) {
char_x = 0;
char_y = char_y + vert;
if (char_y >= height() - font[2]) {
char_y = 0;
}
}
window(char_x, char_y,hor,vert); // char box
wr_cmd(0x2C); // send pixel
#ifndef TARGET_KL25Z // 16 Bit SPI
_spi.format(16,3);
#endif // switch to 16 bit Mode 3
zeichen = &font[((c -32) * offset) + 4]; // start of char bitmap
w = zeichen[0]; // width of actual char
for (j=0; j<vert; j++) { // vert line
for (i=0; i<hor; i++) { // horz line
z = zeichen[bpl * i + ((j & 0xF8) >> 3)+1];
b = 1 << (j & 0x07);
if (( z & b ) == 0x00) {
#ifndef TARGET_KL25Z // 16 Bit SPI
_spi.write(_background);
#else
_spi.write(_background >> 8);
_spi.write(_background & 0xff);
#endif
} else {
#ifndef TARGET_KL25Z // 16 Bit SPI
_spi.write(_foreground);
#else
_spi.write(_foreground >> 8);
_spi.write(_foreground & 0xff);
#endif
}
}
}
_cs = 1;
#ifndef TARGET_KL25Z // 16 Bit SPI
_spi.format(8,3);
#endif
WindowMax();
if ((w + 2) < hor) { // x offset to next char
char_x += w + 2;
} else char_x += hor;
}
void SPI_TFT_ILI9341::set_font(unsigned char* f)
{
font = f;
}
void SPI_TFT_ILI9341::Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned char *bitmap)
{
unsigned int j;
int padd;
unsigned short *bitmap_ptr = (unsigned short *)bitmap;
#if defined TARGET_KL25Z // 8 Bit SPI
unsigned short pix_temp;
#endif
unsigned int i;
// the lines are padded to multiple of 4 bytes in a bitmap
padd = -1;
do {
padd ++;
} while (2*(w + padd)%4 != 0);
window(x, y, w, h);
bitmap_ptr += ((h - 1)* (w + padd));
wr_cmd(0x2C); // send pixel
#ifndef TARGET_KL25Z // 16 Bit SPI
_spi.format(16,3);
#endif // switch to 16 bit Mode 3
for (j = 0; j < h; j++) { //Lines
for (i = 0; i < w; i++) { // one line
#if defined TARGET_KL25Z // 8 Bit SPI
pix_temp = *bitmap_ptr;
_spi.write(pix_temp >> 8);
_spi.write(pix_temp);
bitmap_ptr++;
#else
_spi.write(*bitmap_ptr); // one line
bitmap_ptr++;
#endif
}
bitmap_ptr -= 2*w;
bitmap_ptr -= padd;
}
_cs = 1;
#ifndef TARGET_KL25Z // 16 Bit SPI
_spi.format(8,3);
#endif
WindowMax();
}
// local filesystem is not implemented in kinetis board
#if DEVICE_LOCALFILESYSTEM
int SPI_TFT_ILI9341::BMP_16(unsigned int x, unsigned int y, const char *Name_BMP)
{
#define OffsetPixelWidth 18
#define OffsetPixelHeigh 22
#define OffsetFileSize 34
#define OffsetPixData 10
#define OffsetBPP 28
char filename[50];
unsigned char BMP_Header[54];
unsigned short BPP_t;
unsigned int PixelWidth,PixelHeigh,start_data;
unsigned int i,off;
int padd,j;
unsigned short *line;
// get the filename
LocalFileSystem local("local");
sprintf(&filename[0],"/local/");
i=7;
while (*Name_BMP!='\0') {
filename[i++]=*Name_BMP++;
}
fprintf(stderr, "filename : %s \n\r",filename);
FILE *Image = fopen((const char *)&filename[0], "rb"); // open the bmp file
if (!Image) {
return(0); // error file not found !
}
fread(&BMP_Header[0],1,54,Image); // get the BMP Header
if (BMP_Header[0] != 0x42 || BMP_Header[1] != 0x4D) { // check magic byte
fclose(Image);
return(-1); // error no BMP file
}
BPP_t = BMP_Header[OffsetBPP] + (BMP_Header[OffsetBPP + 1] << 8);
if (BPP_t != 0x0010) {
fclose(Image);
return(-2); // error no 16 bit BMP
}
PixelHeigh = BMP_Header[OffsetPixelHeigh] + (BMP_Header[OffsetPixelHeigh + 1] << 8) + (BMP_Header[OffsetPixelHeigh + 2] << 16) + (BMP_Header[OffsetPixelHeigh + 3] << 24);
PixelWidth = BMP_Header[OffsetPixelWidth] + (BMP_Header[OffsetPixelWidth + 1] << 8) + (BMP_Header[OffsetPixelWidth + 2] << 16) + (BMP_Header[OffsetPixelWidth + 3] << 24);
if (PixelHeigh > height() + y || PixelWidth > width() + x) {
fclose(Image);
return(-3); // to big
}
start_data = BMP_Header[OffsetPixData] + (BMP_Header[OffsetPixData + 1] << 8) + (BMP_Header[OffsetPixData + 2] << 16) + (BMP_Header[OffsetPixData + 3] << 24);
line = (unsigned short *) malloc (2 * PixelWidth); // we need a buffer for a line
if (line == NULL) {
return(-4); // error no memory
}
// the bmp lines are padded to multiple of 4 bytes
padd = -1;
do {
padd ++;
} while ((PixelWidth * 2 + padd)%4 != 0);
//fseek(Image, 70 ,SEEK_SET);
window(x, y,PixelWidth ,PixelHeigh);
wr_cmd(0x2C); // send pixel
_spi.format(16,3); // switch to 16 bit Mode 3
for (j = PixelHeigh - 1; j >= 0; j--) { //Lines bottom up
off = j * (PixelWidth * 2 + padd) + start_data; // start of line
fseek(Image, off ,SEEK_SET);
fread(line,1,PixelWidth * 2,Image); // read a line - slow !
for (i = 0; i < PixelWidth; i++) { // copy pixel data to TFT
_spi.write(line[i]); // one 16 bit pixel
}
}
_cs = 1;
_spi.format(8,3);
free (line);
fclose(Image);
WindowMax();
return(1);
}
#endif | [
"akuhlens@indiana.edu"
] | akuhlens@indiana.edu |
f7534dd6bfec2bfad4c58a5c3a9cb0986749b6e0 | 367dd448eb1e87a80a98744618238843151ecfd2 | /challenge/color_change/color_change.ino | 452a2145c435495ae75fbfc950a0a77246c4f4ef | [] | no_license | JooooosephY/Introduction-to-Robotics | 01546d41b1d667719115330b590552ebe206e1eb | 064547ab4b786be8a0c940e190c857776ac0a480 | refs/heads/main | 2023-01-08T04:25:49.791215 | 2020-11-11T03:22:57 | 2020-11-11T03:22:57 | 303,670,663 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 585 | ino | #include <FastLED.h>
// How many leds in your strip?
#define NUM_LEDS 2
#define DATA_PIN 25
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
int n = 0;
void loop() {
// Turn the LED on, then pause
leds[0] = CRGB::Red;
leds[1] = CRGB::Black;
FastLED.show();
delay(100);
leds[0] = CRGB::Black;
leds[1] = CRGB::Blue;
FastLED.show();
delay(100);
// // Now turn the LED off, then pause
// leds[0] = CRGB::Black;
// FastLED.show();
// n = n + 1;
// if (n > 2) {
// n = 0;
// }
}
| [
"noreply@github.com"
] | JooooosephY.noreply@github.com |
cfa56a2e98a45c8cfc51a7e6ceaa708cceb52656 | 7a070a8b5f56e3a07f460823e2fd72ea9263b838 | /OOStubs/loesung-4/main.cc | 694de199ba88b75f5dbf541252751ed941cbd959 | [] | no_license | sellung/BSB | 0b81c3f3fa2a23323ba6ae88a2ea7506bd74b539 | 73848200155744a509e6ddf885a19ccba4d27637 | refs/heads/master | 2020-06-13T11:58:51.541405 | 2018-05-17T13:25:35 | 2018-05-17T13:25:35 | 75,384,152 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 996 | cc | /* $Id: main.cc 956 2008-10-19 22:24:23Z hsc $ */
/* Hier muesst ihr selbst Code vervollstaendigen */
//#include "machine/cgascr.h"
#include "thread/scheduler.h"
#include "user/appl.h"
#include "device/cgastr.h"
#include "thread/dispatch.h"
void* stack_1[1024];
void* stack_2[1024];
void* stack_3[1024];
Scheduler scheduler;
int main()
{
kout.clearscreen();
kout << "size of stack_1: " << sizeof(stack_1) << endl;
kout << "size of stack_2: " << sizeof(stack_2) << endl;
kout << "size of stack_3: " << sizeof(stack_3) << endl;
Application app1(&stack_1[1024]);
Application app2(&stack_2[1024]);
Application app3(&stack_3[1024]);
int col = 30;
int row = 8;
app1.setName("App1");
app1.color = 0x03;
app1.setCoord(col, row);
app2.setName("App2");
app2.color = 0x04;
app2.setCoord(col, row + 2);
app3.setName("App3");
app3.color = 0x05;
app3.setCoord(col, row + 4);
scheduler.ready(app1);
scheduler.ready(app2);
scheduler.ready(app3);
scheduler.schedule();
}
| [
"pernes06@web.de"
] | pernes06@web.de |
4cb414d94ba739268e8cff9e18b6a5c03c6b3024 | 63403a947660409f7926b3e84521709392ab53fa | /client/systems/vehicleStore/dialog/vehiclestoreDefines.hpp | b6c2e2a5d6e717848c63b754ace2163663e372c6 | [
"MIT"
] | permissive | Exonical/Vanguard_Wasteland.cup_chernarus_A3 | 7ab5a342ed21710744f61626aab0ee00c3cb6b34 | ee8f51807847f35c924bb8bf701e863387b603b8 | refs/heads/master | 2022-11-15T13:48:56.055079 | 2020-07-13T09:20:42 | 2020-07-13T09:20:42 | 279,253,009 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,157 | hpp | // ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
#define vehshop_DIALOG 5285
#define vehshop_veh_TEXT 5286
#define vehshop_veh_list 5287
#define vehshop_color_list 5288
#define vehshop_defparts_checkbox 5388
#define vehshop_part_list 5389
#define vehshop_money 5289
#define vehshop_button0 5290 // Land
#define vehshop_button1 5291 // Armored
#define vehshop_button2 5292 // Tanks
#define vehshop_button3 5293 // Helis
#define vehshop_button4 5294 // Planes
#define vehshop_button5 5295 // Boats
#define vehshop_button6 5296 // Submarines (unused)
#define vehshop_BuyButton_IDC 100
#define A3W_vehPaintIDD 5785
#define vehshop_list_textureChecked (toLower getText (configFile >> "RscCheckBox" >> "textureChecked"))
#define vehshop_list_textureUnchecked (toLower getText (configFile >> "RscCheckBox" >> "textureUnchecked"))
#define vehshop_list_checkboxTextures [vehshop_list_textureUnchecked, vehshop_list_textureChecked] | [
"brycemanglin@gmail.com"
] | brycemanglin@gmail.com |
53f61ec6db32270a905886acfea7a0726f9468c5 | 82ed39c1ee2fc8c1be433cc0d2b3559365f5ae10 | /Queue/implementations/queue_with_stacks.cpp | 65f4650982ad03be137027fe613d93d5fba8426d | [] | no_license | sharopcha/cpp_data_structure | b532ada88a08b438a608a5e2a09d51dda52e5edf | 7883afa5184cca063fb4a6cd2ec8b0f8a8b64f1c | refs/heads/master | 2021-05-19T16:45:47.174059 | 2020-04-09T17:25:05 | 2020-04-09T17:25:05 | 252,034,070 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,503 | cpp | // Implementing queue using two stacks
// METHOD 1
/*
enQueue(q, x):
While stack1 is not empty, push everything from stack1 to stack2.
Push x to stack1 (assuming size of stacks is unlimited).
Push everything back to stack1.
Here time complexity will be O(n)
deQueue(q):
If stack1 is empty then error
Pop an item from stack1 and return it
*/
#include <bits/stdc++.h>
using namespace std;
/*
struct Queue
{
stack<int> s1, s2;
void enQueue(int x)
{
// move all elements from s1 to s2
while (!s1.empty())
{
s2.push(s1.top());
s1.pop();
}
// push item into s1
s1.push(x);
// push everything back to s1
while (!s2.empty())
{
s1.push(s2.top());
s2.pop();
}
}
// Dequeue an item from the queue
int deQueue()
{
// if first stack is empty
if (s1.empty())
{
cout << "Queue is empty" << endl;
exit(0);
}
// return top of s1
int x = s1.top();
s1.pop();
return x;
}
};
*/
// METHOD 2
/*
enQueue(q, x)
1) Push x to stack1 (assuming size of stacks is unlimited).
Here time complexity will be O(1)
deQueue(q)
1) If both stacks are empty then error.
2) If stack2 is empty
While stack1 is not empty, push everything from stack1 to stack2.
3) Pop the element from stack2 and return it.
Here time complexity will be O(n)
*/
struct Queue
{
stack<int> s1, s2;
// enqueue an item to the queue
void enQueue(int x)
{
// pushitem into the first stack
s1.push(x);
}
// dequeue an item from the queue
int deQueue()
{
// if both stacks are empty
if (s1.empty() && s2.empty())
{
cout << "Queue is empty" << endl;
exit(0);
}
// if s2 is empty, move elements from s1
if (s2.empty())
{
while (!s1.empty())
{
s2.push(s1.top());
s1.pop();
}
}
// return the top item from s2
int x = s2.top();
s2.pop();
return x;
}
};
// Driver
int main()
{
Queue queue;
queue.enQueue(1);
queue.enQueue(2);
queue.enQueue(3);
cout << queue.deQueue() << endl;
cout << queue.deQueue() << endl;
cout << queue.deQueue() << endl;
return 0;
} | [
"napster1202@gmail.com"
] | napster1202@gmail.com |
e710fbd37a49ed35ae3f4f936352e9cdea6eedcb | c92e5d70a188e02c251172d92d3f26b88b2cefd3 | /interface/RPCNtupleBaseFiller.h | 907a5bbaef8c236f87b3acfee49e51bac63b2f3c | [] | no_license | BrieucF/RPCNtupleMaker | 2d02b053468e41ef420e86f835c695f3b0e6e838 | b3ed4d53667f2a82abdd64946c6e5bdb061ca749 | refs/heads/master | 2021-02-14T22:13:10.337834 | 2020-04-22T13:21:03 | 2020-04-22T13:21:03 | 244,839,722 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,112 | h | #ifndef RPCNtupleBaseFiller_h
#define RPCNtupleBaseFiller_h
#include "RPCAnalysis/RPCNtupleMaker/interface/RPCNtupleConfig.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "TTree.h"
#include <memory>
#include <string>
class RPCNtupleBaseFiller
{
public :
/// Constructor
RPCNtupleBaseFiller(const std::shared_ptr<RPCNtupleConfig> config,
std::shared_ptr<TTree> tree, const std::string & label);
/// Destructor
virtual ~RPCNtupleBaseFiller();
/// Intialize function : setup tree branches etc ...
virtual void initialize() = 0;
/// Clear branches before event filling
virtual void clear() = 0;
/// Fill tree branches for a given event
virtual void fill(const edm::Event & ev) = 0;
protected :
/// Definition of default values for int variables
static constexpr int DEFAULT_INT_VAL = -999;
/// Definition of default values for positive int variables
static constexpr int DEFAULT_INT_VAL_POS = -1;
/// Definition of default values for float variables
static constexpr double DEFAULT_DOUBLE_VAL = -999.;
/// Definition of default values for positive float variables
static constexpr double DEFAULT_DOUBLE_VAL_POS = -1.;
/// Ponter to the configuration
std::shared_ptr<RPCNtupleConfig> m_config;
/// Pointer to the TTree
std::shared_ptr<TTree> m_tree;
/// The label at the beginning of each branch
std::string m_label;
/// Conditional getter :
/// checks whether a token is valid and if
/// retireving the data collection succeded
template<typename T> edm::Handle<T> conditionalGet(const edm::Event & ev,
const edm::EDGetTokenT<T> & token,
const std::string & collectionName)
{
edm::Handle<T> collection ;
if (!token.isUninitialized())
{
if (!ev.getByToken(token, collection))
edm::LogError("") << "[RPCNtuple]::conditionalGet: "
<< collectionName << " collection does not exist !!!";
}
return collection;
}
};
#endif
| [
"brieucfrancois@hotmail.com"
] | brieucfrancois@hotmail.com |
e550eba8c82c4ce0e5bac2c13efabc3cc08e8e69 | 73c7fe37bf6af775cac65f58b81d2284dae117f2 | /heckarank/data_structure/Tree_Huffman Decoding .cpp | ff2c2f4860be6193496667c968de0f3a5572eb37 | [] | no_license | atique7465/Competetive_programming | 9ad03427682270e889f751b8a8e2e9ab3b309be2 | 840b8b9133f5b993730ecde186ef4d4fdfca9c46 | refs/heads/master | 2023-08-03T15:16:47.582253 | 2023-07-25T04:07:01 | 2023-07-25T04:07:01 | 186,138,178 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,465 | cpp | //
// main.cpp
// Huffman
//
// Created by Vatsal Chanana
#include<bits/stdc++.h>
using namespace std;
typedef struct node {
int freq;
char data;
node * left;
node * right;
} node;
struct deref:public binary_function<node*, node*, bool> {
bool operator()(const node * a, const node * b)const {
return a->freq > b->freq;
}
};
typedef priority_queue<node *, vector<node*>, deref> spq;
node * huffman_hidden(string s) {
spq pq;
vector<int>count(256,0);
for(int i = 0; i < s.length(); i++ ) {
count[s[i]]++;
}
for(int i=0; i < 256; i++) {
node * n_node = new node;
n_node->left = NULL;
n_node->right = NULL;
n_node->data = (char)i;
n_node->freq = count[i];
if( count[i] != 0 )
pq.push(n_node);
}
while( pq.size() != 1 ) {
node * left = pq.top();
pq.pop();
node * right = pq.top();
pq.pop();
node * comb = new node;
comb->freq = left->freq + right->freq;
comb->data = '\0';
comb->left = left;
comb->right = right;
pq.push(comb);
}
return pq.top();
}
void print_codes_hidden(node * root, string code, map<char, string>&mp) {
if(root == NULL)
return;
if(root->data != '\0') {
mp[root->data] = code;
}
print_codes_hidden(root->left, code+'0', mp);
print_codes_hidden(root->right, code+'1', mp);
}
/*
The structure of the node is
typedef struct node {
int freq;
char data;
node * left;
node * right;
} node;
*/
void decode_huff(node * root, string s) {
if(root==NULL)
return;
node* cur=root;
int ln=s.length();
for(int i=0; i<ln; i++)
{
if(s[i]=='0')
{
cur=cur->left;
}
else
{
cur=cur->right;
}
if(cur->left == NULL && cur->right == NULL)
{
cout<<cur->data;
cur=root;
}
}
}
int main() {
string s;
std::cin >> s;
node * tree = huffman_hidden(s);
string code = "";
map<char, string>mp;
print_codes_hidden(tree, code, mp);
string coded;
for( int i = 0; i < s.length(); i++ ) {
coded += mp[s[i]];
}
decode_huff(tree,coded);
return 0;
}
| [
"noreply@github.com"
] | atique7465.noreply@github.com |
15872913440070ade406b48429c14477ec0b9e08 | 130fc6ecaf5f9e57ea64b08b5b6c287ce432dc1f | /Unreal 4/CppCourse/Source/CppCourse/MyActorComponent.h | 50033977ac39982c1e987899136d9bcfb80f45c5 | [] | no_license | Xuzon/PortFolio | d1dc98f352e6d0459d7739c0a866c6f1a701542d | c2f1674bc15930ce0d45143e4d935e3e631fe9c2 | refs/heads/master | 2021-01-17T15:05:08.179998 | 2020-05-13T17:26:19 | 2020-05-13T17:26:19 | 53,209,189 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 680 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "MyActorComponent.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class CPPCOURSE_API UMyActorComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UMyActorComponent();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};
| [
"xuzon69@gmail.com"
] | xuzon69@gmail.com |
95151f3f7eb7d3bac015eea4d2a02faa81f8301f | 8298059fcfe4950537959ec30345088b4b5c82f4 | /BinaryTrees/level_order_traverse.cpp | a2ed3b65ec8f402e909289584362d2db6b93c97c | [] | no_license | sumit-sngpt/practice | fcb6177e2663eaa709caf32f6ffd4e61203c8fd8 | 957a548c830c21031ec387c8c04feea78d4a88ec | refs/heads/master | 2021-01-19T04:52:11.041712 | 2014-11-06T17:10:01 | 2014-11-06T17:10:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,020 | cpp | #include <iostream>
#include <queue>
using namespace std;
/*
Level order traversal - Breadth first traversal
*/
typedef struct node {
int data;
struct node* left;
struct node* right;
} Node;
Node* newNode(int num) {
Node* ptr = new Node;
ptr->data = num;
ptr->right = NULL;
ptr->left = NULL;
return ptr;
}
void lvltraversal(Node* root) {
queue<Node*> qu;
if(root==NULL) {
return;
} else {
qu.push(root);
}
while(!qu.empty()) {
Node* ptr = qu.front();
qu.pop();
cout << ptr->data << endl;
if (ptr->left)
qu.push(ptr->left);
if(ptr->right)
qu.push(ptr->right);
}
}
int main()
{
Node* root = newNode(1);
root->left = newNode(2);
root->right = newNode(3);
root->left->left = newNode(4);
root->left->right = newNode(5);
root->right->right = newNode(6);
root->right->right->left = newNode(7);
lvltraversal(root);
cout << endl;
return 0;
}
| [
"sumit_sngpt@yahoo.co.in"
] | sumit_sngpt@yahoo.co.in |
ee6d7c9bd0d0316ab96ed1bacfa4cf057c657ba7 | f3a9419592d3a032b60383865ab766d62b8b83a2 | /Sprint04/t01/app/src/StormcloakSoldier.h | ae2fc5136669a33419866ae824fbc414065838c8 | [] | no_license | akostanda/Ucode-marathon-Cpp | 288267a2769eed6800abb0093f7da0c458ee6d97 | 75d90fd9ce32d63895175c238ee395e49e51fffd | refs/heads/master | 2022-12-19T14:56:59.554026 | 2020-09-22T09:22:34 | 2020-09-22T09:22:34 | 293,285,737 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 386 | h | #pragma once
#include <iostream>
#include "Axe.h"
#include "ImperialSoldier.h"
class ImperialSoldier;
class StormcloakSoldier final {
public:
StormcloakSoldier();
~StormcloakSoldier();
void setWeapon(Axe* axe);
void attack(ImperialSoldier& enemy);
void consumeDamage(int amount);
int getHealth() const;
private:
Axe* m_weapon;
int m_health = 100;
};
| [
"akostanda@e1r7p3.unit.ua"
] | akostanda@e1r7p3.unit.ua |
21eec6b200a5865b54d41e92f462d848a6801b6a | 725104e743ab6c99e6dcfd4e749c069af4c9cdc9 | /LeetCodeTestSolutions/Ex048-Anagrams.cpp | 218dfcab6f9e77f32a2fd85f7c3efeaffa15a372 | [] | no_license | Msudyc/LeetCodePartCpp | 7306af23a1921e0c52fc29d12b32fad337a62174 | 0204709753fdaeee6fa222f70fa11ff9bd1f6e6d | refs/heads/master | 2021-01-15T10:25:49.839340 | 2014-11-09T04:05:49 | 2014-11-09T04:05:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 954 | cpp | /*
Given an array of strings, return all groups of strings
that are anagrams.
Note: All inputs will be in lower-case.
class Solution {
public:
vector<string> anagrams(vector<string> &strs) {
}
};
*/
#include <sstream>
#include <map>
#include "Ex048-Anagrams.h"
namespace LeetCodeTestSolutions
{
vector<string> Ex48::anagrams(vector<string> &strs)
{
map<string, vector<string>> strmap;
for (string str : strs)
{
vector<int> counts(26, 0);
for (char c : str) counts[c - 'a']++;
stringstream ss;
for (int i = 0; i < 26; i++)
if (counts[i] > 0) ss << counts[i] << (char)('a' + i);
strmap[ss.str()].push_back(str);
}
vector<string> ans;
for (auto &sp : strmap)
if (sp.second.size() > 1)
ans.insert(ans.end(), sp.second.begin(), sp.second.end());
return ans;
}
} | [
"msudyc@gmail.com"
] | msudyc@gmail.com |
019b63005c76a290c7228d6a2bcc0986de38479a | 4d623ea7a585e58e4094c41dc212f60ba0aec5ea | /C_Strange_Birthday_Party.cpp | 083f4f5c654307f1c4c1a71b3cf2c1702f74a4dc | [] | no_license | akshit-04/CPP-Codes | 624aadeeec35bf608ef4e83f1020b7b54d992203 | ede0766d65df0328f7544cadb3f8ff0431147386 | refs/heads/main | 2023-08-30T13:28:14.748412 | 2021-11-19T12:04:43 | 2021-11-19T12:04:43 | 429,779,083 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 998 | cpp | #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define For(i,n) for(int i=0;i<n;i++)
#define VI vector<int>
#define VL vector<ll>
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
#define pb push_back
const int M = 200001;
char arr[1111][1111];
int a[101],r[10001],ans[10001];
int main()
{
fast;
int t;
cin>>t;
while(t--)
{
int n,m;
cin>>n>>m;
VI a(n);
For(i,n)
cin>>a[i];
int p[m];
For(i,m)
cin>>p[i];
sort(a.rbegin(),a.rend());
int j=0;
ll sum=0;
For(i,n)
{
if(j<a[i] && j<m)
{
if(p[j]<p[a[i]-1])
{
sum+=p[j];
j++;
}
else
sum+=p[a[i]-1];
}
else
{
sum+=p[a[i]-1];
}
}
cout<<sum<<"\n";
}
return 0;
} | [
"ishu.akshitgarg@gmail.com"
] | ishu.akshitgarg@gmail.com |
fb156fe502e90be48298a735257d20235e2276c4 | e1f11832ae94a27ac0eb9ae98c2166d79ca85a00 | /Nyctophobia/Gamestate.h | a18b9810d385ae36b5bbbbbf7ad473bc020c3fbe | [] | no_license | Focusrite/Nyctophobia | 4dc23570b784bae39af718ac9f3dbbfbb27b0e5f | a9e050b809de6cdc016d38edc6cceb449b051cd7 | refs/heads/master | 2021-01-22T06:53:38.053364 | 2012-05-24T19:37:18 | 2012-05-24T19:37:18 | 1,504,383 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 954 | h | #ifndef GAMESTATE_H
#define GAMESTATE_H
#include "Game.h"
class Game;
// Reference: http://gamedevgeek.com/tutorials/managing-game-states-in-c/
// Abstract baseclass
class GameState
{
public:
virtual void init(Game* game) = 0;
virtual void cleanup(void) = 0;
virtual void pause() = 0;
virtual void resume() = 0;
virtual void handleEvents(UINT msg, WPARAM wParam, LPARAM lParam) = 0;
virtual void update(double dt) = 0;
virtual void draw() = 0;
virtual void drawAlpha() = 0;
void setGame(Game* game) {mGame = game;};
void changeState(GameState* state) {
mGame->changeState(state);
}
void useCamera(bool b) {
mUsesCamera = b;
}
bool usesCamera() {
return mUsesCamera;
}
void drawToAlpha(bool b) {mDrawToAlpha = b;}
bool drawingToAlpha() {return mDrawToAlpha;}
protected:
GameState(){};
private:
bool mStateChanged;
Game *mGame;
bool mUsesCamera;
bool mDrawToAlpha;
}; // Class
extern GameState* gGameState;
#endif | [
"Focusrite@Focus.(none)"
] | Focusrite@Focus.(none) |
2f793363625870c7a26a00e2c36c1220f5a4ed80 | 3e629dc99de100aed68331b54e314dd8b0af8c85 | /NodeManager.h | 174e1ae6c22ce07ea32fb6f17b5c788610bef7fb | [] | no_license | AidanFok/MiniSQL | f868f4adc34b4deeeea370004c4c285b2572ea7f | ee68b80ad03a0996c1be832f302e13da8d2fe73c | refs/heads/master | 2021-01-20T20:57:38.091211 | 2016-08-02T15:40:48 | 2016-08-02T15:40:48 | 64,769,509 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,347 | h | #pragma once
#include "macros.h"
enum operationName
{
EMPTY,
OP_CREATE_TABLE,
OP_CREATE_INDEX,
OP_DROP_TABLE,
OP_DROP_INDEX,
OP_SELECT,
OP_INSERT,
OP_DELECT,
OP_SHOWTABLES,
OP_AND,
OP_OR,
CMP_EQ,
CMP_NEQ,
CMP_LT,
CMP_GT,
CMP_LE,
CMP_GE,
VAL_CHAR,
VAL_NUMBER,
VAL_NAME,
VAL_INT,
VAL_FLOAT,
DEF_UNIQUE,
DEF_PRIMARY,
DEF_SINGLE_PRIMARY
};
typedef struct node
{
node *leftSon;
node *rightSon;
// simultaneous
int operation;
// data, in val_list of creating,
// numval stores the len of char.
// (1 <= n <=255)
char *strval;
double numval;
} Node;
class NodeManager
{
private:
// Do not use unique ptr
// For a single line, multiple queries
// may generate more than one AST.
//
std::vector<Node*> m_manageRoot;
// Storing ALL of the node, simplifies
// the management of memory.
std::vector<Node*> m_manageArray;
public:
NodeManager();
~NodeManager();
Node* newEmptyNode();
Node* newCopyDataNode(Node* data);
void setRootNode(Node* root);
Node* getRootNode(size_t pos) const;
// v: delete the last unfinished node,
// v: for error processing in yyparse
void delLastRootNode();
const std::vector<Node*>& getRootTree() const;
size_t getRootTreeSize() const;
void clean();
};
| [
"394069071@qq.com"
] | 394069071@qq.com |
040c12a344f5e317aeae37cf85e094a701138e1b | 0a1be59f55b359866370c2815671af22bd96ff51 | /dependencies/skse64/src/skse64/CommonLibSSE/include/RE/ExtraRoom.h | e495e37739c8e466013c7a2bbf71129bcb70ca36 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | joelday/papyrus-debug-server | ba18b18d313a414daefdf0d3472b60a12ca21385 | f5c3878cd485ba68aaadf39bb830ca88bf53bfff | refs/heads/master | 2023-01-12T14:34:52.919190 | 2019-12-06T18:41:39 | 2019-12-06T18:41:39 | 189,772,905 | 15 | 10 | MIT | 2022-12-27T11:31:04 | 2019-06-01T20:02:31 | C++ | UTF-8 | C++ | false | false | 636 | h | #pragma once
#include "skse64/GameRTTI.h" // RTTI_ExtraRoom
#include "RE/BSExtraData.h" // BSExtraData
#include "RE/ExtraDataTypes.h" // ExtraDataType
#include "RE/NiSmartPointer.h" // NiPointer
namespace RE
{
class NiRefObject;
class ExtraRoom : public BSExtraData
{
public:
inline static const void* RTTI = RTTI_ExtraRoom;
enum { kExtraTypeID = ExtraDataType::kRoom };
virtual ~ExtraRoom(); // 00
// override (BSExtraData)
virtual ExtraDataType GetType() const override; // 01 - { return kRoom; }
// members
NiPointer<NiRefObject> unk10; // 10
};
STATIC_ASSERT(sizeof(ExtraRoom) == 0x18);
}
| [
"joelday@gmail.com"
] | joelday@gmail.com |
7eddf360954748494d8a52a2c324dc2fe18b39ed | 1b7bc0c8810624c79e1dade01bb63177058f1a28 | /Cpp14/Strou/templates_23-28/enable_if/enable_if_main.cpp | be02a05ad8a0133e07cf886ac45433ac34848273 | [
"MIT"
] | permissive | ernestyalumni/HrdwCCppCUDA | 61f123359fb585f279a32a19ba64dfdb60a4f66f | ad067fd4e605c230ea87bdc36cc38341e681a1e0 | refs/heads/master | 2023-07-21T06:00:51.881770 | 2023-04-26T13:58:57 | 2023-04-26T13:58:57 | 109,069,731 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,204 | cpp | //------------------------------------------------------------------------------
/// \file enable_if_main.cpp
/// \author Ernest Yeung
/// \email ernestyalumni@gmail.com
/// \brief Main driver function for enable_if.h.
/// \ref https://en.cppreference.com/w/cpp/types/enable_if
/// \details Demonstrate enable_if for template metaprogramming, and its
/// relationship to interfaces.
/// \copyright If you find this code useful, feel free to donate directly and
/// easily at this direct PayPal link:
///
/// https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ernestsaveschristmas%2bpaypal%40gmail%2ecom&lc=US&item_name=ernestyalumni¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
///
/// which won't go through a 3rd. party such as indiegogo, kickstarter, patreon.
/// Otherwise, I receive emails and messages on how all my (free) material on
/// physics, math, and engineering have helped students with their studies, and
/// I know what it's like to not have money as a student, but love physics (or
/// math, sciences, etc.), so I am committed to keeping all my material
/// open-source and free, whether or not sufficiently crowdfunded, under the
/// open-source MIT license: feel free to copy, edit, paste, make your own
/// versions, share, use as you wish.
/// Peace out, never give up! -EY
//------------------------------------------------------------------------------
/// COMPILATION TIPS:
/// g++ -std=c++14 enable_if_main.cpp -o enable_if_main
//------------------------------------------------------------------------------
#include "enable_if.h"
#include <string>
#include <type_traits> // std::aligned_union_t
using Templates::construct;
using Templates::destroy;
int main()
{
// \ref https://en.cppreference.com/w/cpp/types/enable_if
{
std::aligned_union_t<0, int, std::string> u;
construct(reinterpret_cast<int*>(&u));
destroy(reinterpret_cast<int*>(&u));
// Segmentation Fault
construct(reinterpret_cast<std::string*>(&u), "Hello");
destroy(reinterpret_cast<std::string*>(&u));
// A<int> a1; // OK, matches the primary template
// A<double> a2; // OK, matches the partial specialization
}
}
| [
"ernestyalumni@gmail.com"
] | ernestyalumni@gmail.com |
7c2adb4af44d71fd82de1f653ecfe6b544bbbc5d | ab686eb3a176b5845919d80c66662f94624ecc05 | /sde sheet/DAY - 10/1) Print All permutation/code.cpp | a46ce10808290c921d182c6c319c9a81d01c3e01 | [] | no_license | chiragasawa/interview-prep | 341be6be58159a75b91c3ca3ec572c371a7c2caf | 0200ba04d9cc46f04c33f20276b77f49825ea091 | refs/heads/main | 2023-09-03T07:59:09.658756 | 2021-10-19T05:16:44 | 2021-10-19T05:16:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 770 | cpp | // C++ program to print all
// permutations with duplicates allowed
#include <bits/stdc++.h>
using namespace std;
// Function to print permutations of string
// This function takes three parameters:
// 1. String
// 2. Starting index of the string
// 3. Ending index of the string.
void permute(string a, int l, int r)
{
// Base case
if (l == r)
cout<<a<<endl;
else
{
// Permutations made
for (int i = l; i <= r; i++)
{
// Swapping done
swap(a[l], a[i]);
// Recursion called
permute(a, l+1, r);
//backtrack
swap(a[l], a[i]);
}
}
}
// Driver Code
int main()
{
string str = "ABC";
int n = str.size();
permute(str, 0, n-1);
return 0;
}
// This is code is contributed by rathbhupendra
| [
"noreply@github.com"
] | chiragasawa.noreply@github.com |
d93cbf7f772eb00775a8f46cc6ab0027c70bd906 | f8976de87d3be3fbcff061b4b981756924a05c42 | /c++/codeblocks/RB_tree/main.cpp | e87b12a3967cabc5b966af1dc6e78d3dfbcbac3d | [] | no_license | blasdch18/AED | 90610bee2d12dd2fceddfeded445acc93303ef17 | a785f1aa7572bfcbe2f75ee1b302cd4961d4d057 | refs/heads/master | 2021-05-20T10:29:35.783024 | 2020-04-01T18:18:57 | 2020-04-01T18:18:57 | 252,247,723 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 5,142 | cpp | #include <iostream>
#include <stack>
#include <queue>
#include <string>
using namespace std;
enum Color{black,red};
// ************************************ Function Object
template<class T>
struct Greater
{
bool operator () (T a , T b)
{
return a>b;
}
};
template<class T>
struct Less
{
bool operator () (T a , T b)
{
return a<b;
}
};
template<class T>
struct TraitLess
{
typedef T type;
typedef Less<type> cmp;
};
//************************************ Nodo RB
template <class T>
struct nodo
{
Color color;
T data;
nodo (T n);
nodo<T>* leaf[2];
//Others Functions
T GetData();
Color GetColor();
};
template <class T>
nodo<T>::nodo(T n)
{
data=n;
leaf[0]=0;
leaf[1]=0;
color=red;
}
template<class T>
T nodo<T>::GetData()
{
return data;
}
template<class T>
Color nodo<T>::GetColor()
{
return color;
}
// ******************************************** arbol_RB
template <class Tr>
class arbol_RB{
public:
typedef typename Tr::type T;
typedef typename Tr::cmp C;
typedef nodo<T> Node;
Node* root_;
C cmp_;
arbol_RB();
void RotationDir(bool d, Node** u);
bool GetColor(Node * p);
void UpdateColor(Node **p, Node ** u);
void SimpleRotation(Node** p,bool dir);
void DoubleRotation(Node** p,bool dir);
bool Find(T n, Node ** &p, stack<Node **> &stack);
bool Insert(T n);
void DestroyTree(Node *&p);
void RPrint(Node *p);
void PrintTree();
void amplitud();
void printRoot();
};
template<class Tr>
arbol_RB<Tr>::arbol_RB(){
root_=0;
}
template<class Tr>
bool arbol_RB<Tr>::GetColor(Node *p){
if(p){
return p->GetColor();
}
return 0;
}
template<class Tr>
void arbol_RB<Tr>::DestroyTree(Node *&p){
if (!!p) {
DestroyTree(p->leaf[0]);
DestroyTree(p->leaf[1]);
delete p;
}
}
template<class Tr>
void arbol_RB<Tr>::RotationDir(bool d, Node **u){
bool d_r=GetColor((*u)->leaf[d]->leaf[!d])>GetColor((*u)->leaf[d]->leaf[d]);
if (d_r) {
DoubleRotation(u, d);
}
else{
SimpleRotation(u, d);
}
}
template<class Tr>
void arbol_RB<Tr>::UpdateColor(Node **p, Node **u){
int dir=GetColor((*u)->leaf[0])-GetColor((*u)->leaf[1]);
if (dir==0) {
if ((*u)->leaf[0]== *p) {
dir=1;
}
else{
dir=-1;
}
}
bool v=GetColor((*p)->leaf[0])||GetColor((*p)->leaf[1]);
if (dir==1 && v) {
RotationDir(0, u);
}
if(dir==-1 && v){
RotationDir(1, u);
}
if (root_->color) {
root_->color = black;
}
return;
}
template<class Tr>
void arbol_RB<Tr>::SimpleRotation(Node **p, bool dir){
Node * tmp = *p;
*p=(*p)->leaf[dir];
tmp->leaf[dir]=(*p)->leaf[!dir];
(*p)->leaf[!dir]=tmp;
if (!!(*p)->leaf[dir]) {
(*p)->leaf[dir]->color = black;
}
else if (!!(*p)->leaf[!dir]) {
(*p)->leaf[!dir]->color=black;
}
}
template<class Tr>
void arbol_RB<Tr>::DoubleRotation(Node **p, bool dir){
SimpleRotation(&(*p)->leaf[dir], !dir);
SimpleRotation(p,dir);
}
template<class Tr>
bool arbol_RB<Tr>::Find(T n, Node **&p, stack<Node **> &stack){
p=&root_;
while( *p && n!=(*p)->data ){
stack.push(p);
p=&(*p)->leaf[cmp_((*p)->data,n)];
}
return (*p) && n==(*p)->data;
}
template<class Tr>
bool arbol_RB<Tr>::Insert(T n){
Node **p;
stack <Node**> stack;
if (Find(n,p,stack)) {
return 0;
}
*p=new Node(n);
if ((root_)->color) {
root_->color=black;
}
while (!stack.empty()) {
if ((* stack.top())->color == red) {
Node **tmp = stack.top();
stack.pop();
UpdateColor(tmp, stack.top());
}
else{
stack.pop();
}
}
return 1;
}
template<class Tr>
void arbol_RB<Tr>::RPrint(Node *p){
if(!p) return;
RPrint(p->leaf[0]);
cout<<p->data<<"°"<<p->color<<"->";
RPrint(p->leaf[1]);
}
template<class Tr>
void arbol_RB<Tr>::PrintTree(){
RPrint(root_);
}
template<class Tr>
void arbol_RB<Tr>:: amplitud (){
queue<Node*>cola;
Node *p=root_;
cola.push(p);
while (!cola.empty()) {
p=cola.front();
cola.pop();
cout<<p->data<<"°"<<p->color<<"->";
if (p->leaf[0]!=0) cola.push(p->leaf[0]);
if (p->leaf[1]!=0) cola.push(p->leaf[1]);
}
}
template <class Tr>
void arbol_RB<Tr>:: printRoot(){
Node*p=root_;
cout<<p->data;
}
int main()
{
cout << "Hello world!" << endl;
arbol_RB< TraitLess<int> >a;
for(int i=1;i<11;i++){
a.Insert(i);
}
a.PrintTree();cout<<endl;
cout<<"pruebas para el arbol"<<endl;
// nodo<int>b;
// b=a.root_;
a.amplitud();
cout<<endl;
a.printRoot();
return 0;
return 0;
}
| [
"blas.cruz@ucsp.edu.pe"
] | blas.cruz@ucsp.edu.pe |
e5486cbf9785cec83856b6c604f161301934e90b | 58f46a28fc1b58f9cd4904c591b415c29ab2842f | /chromium-32.0.1700.107/ui/views/controls/menu/menu_controller.cc | fb6d47ed75938e70dfbe9a492721a2d3b0973b36 | [
"BSD-3-Clause"
] | permissive | bbmjja8123/chromium-1 | e739ef69d176c636d461e44d54ec66d11ed48f96 | 2a46d8855c48acd51dafc475be7a56420a716477 | refs/heads/master | 2021-01-16T17:50:45.184775 | 2015-03-20T18:38:11 | 2015-03-20T18:42:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 83,971 | cc | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/controls/menu/menu_controller.h"
#if defined(OS_WIN)
#include <windowsx.h>
#endif
#include "base/i18n/case_conversion.h"
#include "base/i18n/rtl.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "ui/base/dragdrop/drag_utils.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/vector2d.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/menu/menu_config.h"
#include "ui/views/controls/menu/menu_controller_delegate.h"
#include "ui/views/controls/menu/menu_host_root_view.h"
#include "ui/views/controls/menu/menu_scroll_view_container.h"
#include "ui/views/controls/menu/submenu_view.h"
#include "ui/views/drag_utils.h"
#include "ui/views/event_utils.h"
#include "ui/views/focus/view_storage.h"
#include "ui/views/mouse_constants.h"
#include "ui/views/view_constants.h"
#include "ui/views/views_delegate.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/tooltip_manager.h"
#include "ui/views/widget/widget.h"
#if defined(USE_AURA)
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#endif
#if defined(OS_WIN)
#include "ui/views/win/hwnd_message_handler.h"
#include "ui/views/win/hwnd_util.h"
#endif
#if defined(USE_X11)
#include <X11/Xlib.h>
#endif
using base::Time;
using base::TimeDelta;
using ui::OSExchangeData;
// Period of the scroll timer (in milliseconds).
static const int kScrollTimerMS = 30;
// Amount of time from when the drop exits the menu and the menu is hidden.
static const int kCloseOnExitTime = 1200;
// If a context menu is invoked by touch, we shift the menu by this offset so
// that the finger does not obscure the menu.
static const int kCenteredContextMenuYOffset = -15;
namespace views {
namespace {
// When showing context menu on mouse down, the user might accidentally select
// the menu item on the subsequent mouse up. To prevent this, we add the
// following delay before the user is able to select an item.
static int menu_selection_hold_time_ms = kMinimumMsPressedToActivate;
// The spacing offset for the bubble tip.
const int kBubbleTipSizeLeftRight = 12;
const int kBubbleTipSizeTopBottom = 11;
// The maximum distance (in DIPS) that the mouse can be moved before it should
// trigger a mouse menu item activation (regardless of how long the menu has
// been showing).
const float kMaximumLengthMovedToActivate = 4.0f;
// Returns true if the mnemonic of |menu| matches key.
bool MatchesMnemonic(MenuItemView* menu, char16 key) {
return menu->GetMnemonic() == key;
}
// Returns true if |menu| doesn't have a mnemonic and first character of the its
// title is |key|.
bool TitleMatchesMnemonic(MenuItemView* menu, char16 key) {
if (menu->GetMnemonic())
return false;
string16 lower_title = base::i18n::ToLower(menu->title());
return !lower_title.empty() && lower_title[0] == key;
}
} // namespace
// Returns the first descendant of |view| that is hot tracked.
static View* GetFirstHotTrackedView(View* view) {
if (!view)
return NULL;
if (!strcmp(view->GetClassName(), CustomButton::kViewClassName)) {
CustomButton* button = static_cast<CustomButton*>(view);
if (button->IsHotTracked())
return button;
}
for (int i = 0; i < view->child_count(); ++i) {
View* hot_view = GetFirstHotTrackedView(view->child_at(i));
if (hot_view)
return hot_view;
}
return NULL;
}
// Recurses through the child views of |view| returning the first view starting
// at |start| that is focusable. A value of -1 for |start| indicates to start at
// the first view (if |forward| is false, iterating starts at the last view). If
// |forward| is true the children are considered first to last, otherwise last
// to first.
static View* GetFirstFocusableView(View* view, int start, bool forward) {
if (forward) {
for (int i = start == -1 ? 0 : start; i < view->child_count(); ++i) {
View* deepest = GetFirstFocusableView(view->child_at(i), -1, forward);
if (deepest)
return deepest;
}
} else {
for (int i = start == -1 ? view->child_count() - 1 : start; i >= 0; --i) {
View* deepest = GetFirstFocusableView(view->child_at(i), -1, forward);
if (deepest)
return deepest;
}
}
return view->IsFocusable() ? view : NULL;
}
// Returns the first child of |start| that is focusable.
static View* GetInitialFocusableView(View* start, bool forward) {
return GetFirstFocusableView(start, -1, forward);
}
// Returns the next view after |start_at| that is focusable. Returns NULL if
// there are no focusable children of |ancestor| after |start_at|.
static View* GetNextFocusableView(View* ancestor,
View* start_at,
bool forward) {
DCHECK(ancestor->Contains(start_at));
View* parent = start_at;
do {
View* new_parent = parent->parent();
int index = new_parent->GetIndexOf(parent);
index += forward ? 1 : -1;
if (forward || index != -1) {
View* next = GetFirstFocusableView(new_parent, index, forward);
if (next)
return next;
}
parent = new_parent;
} while (parent != ancestor);
return NULL;
}
// MenuScrollTask --------------------------------------------------------------
// MenuScrollTask is used when the SubmenuView does not all fit on screen and
// the mouse is over the scroll up/down buttons. MenuScrollTask schedules
// itself with a RepeatingTimer. When Run is invoked MenuScrollTask scrolls
// appropriately.
class MenuController::MenuScrollTask {
public:
MenuScrollTask() : submenu_(NULL), is_scrolling_up_(false), start_y_(0) {
pixels_per_second_ = MenuItemView::pref_menu_height() * 20;
}
void Update(const MenuController::MenuPart& part) {
if (!part.is_scroll()) {
StopScrolling();
return;
}
DCHECK(part.submenu);
SubmenuView* new_menu = part.submenu;
bool new_is_up = (part.type == MenuController::MenuPart::SCROLL_UP);
if (new_menu == submenu_ && is_scrolling_up_ == new_is_up)
return;
start_scroll_time_ = base::Time::Now();
start_y_ = part.submenu->GetVisibleBounds().y();
submenu_ = new_menu;
is_scrolling_up_ = new_is_up;
if (!scrolling_timer_.IsRunning()) {
scrolling_timer_.Start(FROM_HERE,
TimeDelta::FromMilliseconds(kScrollTimerMS),
this, &MenuScrollTask::Run);
}
}
void StopScrolling() {
if (scrolling_timer_.IsRunning()) {
scrolling_timer_.Stop();
submenu_ = NULL;
}
}
// The menu being scrolled. Returns null if not scrolling.
SubmenuView* submenu() const { return submenu_; }
private:
void Run() {
DCHECK(submenu_);
gfx::Rect vis_rect = submenu_->GetVisibleBounds();
const int delta_y = static_cast<int>(
(base::Time::Now() - start_scroll_time_).InMilliseconds() *
pixels_per_second_ / 1000);
vis_rect.set_y(is_scrolling_up_ ?
std::max(0, start_y_ - delta_y) :
std::min(submenu_->height() - vis_rect.height(), start_y_ + delta_y));
submenu_->ScrollRectToVisible(vis_rect);
}
// SubmenuView being scrolled.
SubmenuView* submenu_;
// Direction scrolling.
bool is_scrolling_up_;
// Timer to periodically scroll.
base::RepeatingTimer<MenuScrollTask> scrolling_timer_;
// Time we started scrolling at.
base::Time start_scroll_time_;
// How many pixels to scroll per second.
int pixels_per_second_;
// Y-coordinate of submenu_view_ when scrolling started.
int start_y_;
DISALLOW_COPY_AND_ASSIGN(MenuScrollTask);
};
// MenuController:SelectByCharDetails ----------------------------------------
struct MenuController::SelectByCharDetails {
SelectByCharDetails()
: first_match(-1),
has_multiple(false),
index_of_item(-1),
next_match(-1) {
}
// Index of the first menu with the specified mnemonic.
int first_match;
// If true there are multiple menu items with the same mnemonic.
bool has_multiple;
// Index of the selected item; may remain -1.
int index_of_item;
// If there are multiple matches this is the index of the item after the
// currently selected item whose mnemonic matches. This may remain -1 even
// though there are matches.
int next_match;
};
// MenuController:State ------------------------------------------------------
MenuController::State::State()
: item(NULL),
submenu_open(false),
anchor(MenuItemView::TOPLEFT),
context_menu(false) {}
MenuController::State::~State() {}
// MenuController ------------------------------------------------------------
// static
MenuController* MenuController::active_instance_ = NULL;
// static
MenuController* MenuController::GetActiveInstance() {
return active_instance_;
}
MenuItemView* MenuController::Run(Widget* parent,
MenuButton* button,
MenuItemView* root,
const gfx::Rect& bounds,
MenuItemView::AnchorPosition position,
bool context_menu,
int* result_event_flags) {
exit_type_ = EXIT_NONE;
possible_drag_ = false;
drag_in_progress_ = false;
closing_event_time_ = base::TimeDelta();
menu_start_time_ = base::TimeTicks::Now();
menu_start_mouse_press_loc_ = gfx::Point();
// If we are shown on mouse press, we will eat the subsequent mouse down and
// the parent widget will not be able to reset its state (it might have mouse
// capture from the mouse down). So we clear its state here.
if (parent) {
View* root_view = parent->GetRootView();
if (root_view) {
root_view->SetMouseHandler(NULL);
const ui::Event* event =
static_cast<internal::RootView*>(root_view)->current_event();
if (event && event->type() == ui::ET_MOUSE_PRESSED) {
gfx::Point screen_loc(
static_cast<const ui::MouseEvent*>(event)->location());
View::ConvertPointToScreen(
static_cast<View*>(event->target()), &screen_loc);
menu_start_mouse_press_loc_ = screen_loc;
}
}
}
bool nested_menu = showing_;
if (showing_) {
// Only support nesting of blocking_run menus, nesting of
// blocking/non-blocking shouldn't be needed.
DCHECK(blocking_run_);
// We're already showing, push the current state.
menu_stack_.push_back(state_);
// The context menu should be owned by the same parent.
DCHECK_EQ(owner_, parent);
} else {
showing_ = true;
}
// Reset current state.
pending_state_ = State();
state_ = State();
UpdateInitialLocation(bounds, position, context_menu);
if (owner_)
owner_->RemoveObserver(this);
owner_ = parent;
if (owner_)
owner_->AddObserver(this);
// Set the selection, which opens the initial menu.
SetSelection(root, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
if (!blocking_run_) {
// Start the timer to hide the menu. This is needed as we get no
// notification when the drag has finished.
StartCancelAllTimer();
return NULL;
}
if (button)
menu_button_ = button;
// Make sure Chrome doesn't attempt to shut down while the menu is showing.
if (ViewsDelegate::views_delegate)
ViewsDelegate::views_delegate->AddRef();
// We need to turn on nestable tasks as in some situations (pressing alt-f for
// one) the menus are run from a task. If we don't do this and are invoked
// from a task none of the tasks we schedule are processed and the menu
// appears totally broken.
message_loop_depth_++;
DCHECK_LE(message_loop_depth_, 2);
RunMessageLoop(nested_menu);
message_loop_depth_--;
if (ViewsDelegate::views_delegate)
ViewsDelegate::views_delegate->ReleaseRef();
// Close any open menus.
SetSelection(NULL, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT);
#if defined(OS_WIN) && defined(USE_AURA)
// On Windows, if we select the menu item by touch and if the window at the
// location is another window on the same thread, that window gets a
// WM_MOUSEACTIVATE message and ends up activating itself, which is not
// correct. We workaround this by setting a property on the window at the
// current cursor location. We check for this property in our
// WM_MOUSEACTIVATE handler and don't activate the window if the property is
// set.
if (item_selected_by_touch_) {
item_selected_by_touch_ = false;
POINT cursor_pos;
::GetCursorPos(&cursor_pos);
HWND window = ::WindowFromPoint(cursor_pos);
if (::GetWindowThreadProcessId(window, NULL) ==
::GetCurrentThreadId()) {
::SetProp(window, views::kIgnoreTouchMouseActivateForWindow,
reinterpret_cast<HANDLE>(true));
}
}
#endif
if (nested_menu) {
DCHECK(!menu_stack_.empty());
// We're running from within a menu, restore the previous state.
// The menus are already showing, so we don't have to show them.
state_ = menu_stack_.back();
pending_state_ = menu_stack_.back();
menu_stack_.pop_back();
} else {
showing_ = false;
did_capture_ = false;
}
MenuItemView* result = result_;
// In case we're nested, reset result_.
result_ = NULL;
if (result_event_flags)
*result_event_flags = accept_event_flags_;
if (exit_type_ == EXIT_OUTERMOST) {
SetExitType(EXIT_NONE);
} else {
if (nested_menu && result) {
// We're nested and about to return a value. The caller might enter
// another blocking loop. We need to make sure all menus are hidden
// before that happens otherwise the menus will stay on screen.
CloseAllNestedMenus();
SetSelection(NULL, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT);
// Set exit_all_, which makes sure all nested loops exit immediately.
if (exit_type_ != EXIT_DESTROYED)
SetExitType(EXIT_ALL);
}
}
// If we stopped running because one of the menus was destroyed chances are
// the button was also destroyed.
if (exit_type_ != EXIT_DESTROYED && menu_button_) {
menu_button_->SetState(CustomButton::STATE_NORMAL);
menu_button_->SchedulePaint();
}
return result;
}
void MenuController::Cancel(ExitType type) {
// If the menu has already been destroyed, no further cancellation is
// needed. We especially don't want to set the |exit_type_| to a lesser
// value.
if (exit_type_ == EXIT_DESTROYED || exit_type_ == type)
return;
if (!showing_) {
// This occurs if we're in the process of notifying the delegate for a drop
// and the delegate cancels us.
return;
}
MenuItemView* selected = state_.item;
SetExitType(type);
SendMouseCaptureLostToActiveView();
// Hide windows immediately.
SetSelection(NULL, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT);
if (!blocking_run_) {
// If we didn't block the caller we need to notify the menu, which
// triggers deleting us.
DCHECK(selected);
showing_ = false;
delegate_->DropMenuClosed(
internal::MenuControllerDelegate::NOTIFY_DELEGATE,
selected->GetRootMenuItem());
// WARNING: the call to MenuClosed deletes us.
return;
}
}
void MenuController::OnMousePressed(SubmenuView* source,
const ui::MouseEvent& event) {
SetSelectionOnPointerDown(source, event);
}
void MenuController::OnMouseDragged(SubmenuView* source,
const ui::MouseEvent& event) {
MenuPart part = GetMenuPart(source, event.location());
UpdateScrolling(part);
if (!blocking_run_)
return;
if (possible_drag_) {
if (View::ExceededDragThreshold(event.location() - press_pt_))
StartDrag(source, press_pt_);
return;
}
MenuItemView* mouse_menu = NULL;
if (part.type == MenuPart::MENU_ITEM) {
if (!part.menu)
part.menu = source->GetMenuItem();
else
mouse_menu = part.menu;
SetSelection(part.menu ? part.menu : state_.item, SELECTION_OPEN_SUBMENU);
} else if (part.type == MenuPart::NONE) {
ShowSiblingMenu(source, event.location());
}
UpdateActiveMouseView(source, event, mouse_menu);
}
void MenuController::OnMouseReleased(SubmenuView* source,
const ui::MouseEvent& event) {
if (!blocking_run_)
return;
DCHECK(state_.item);
possible_drag_ = false;
DCHECK(blocking_run_);
MenuPart part = GetMenuPart(source, event.location());
if (event.IsRightMouseButton() && part.type == MenuPart::MENU_ITEM) {
MenuItemView* menu = part.menu;
// |menu| is NULL means this event is from an empty menu or a separator.
// If it is from an empty menu, use parent context menu instead of that.
if (menu == NULL &&
part.submenu->child_count() == 1 &&
part.submenu->child_at(0)->id() == MenuItemView::kEmptyMenuItemViewID) {
menu = part.parent;
}
if (menu != NULL && ShowContextMenu(menu, source, event,
ui::MENU_SOURCE_MOUSE))
return;
}
// We can use Ctrl+click or the middle mouse button to recursively open urls
// for selected folder menu items. If it's only a left click, show the
// contents of the folder.
if (!part.is_scroll() && part.menu &&
!(part.menu->HasSubmenu() &&
(event.flags() & ui::EF_LEFT_MOUSE_BUTTON))) {
if (GetActiveMouseView()) {
SendMouseReleaseToActiveView(source, event);
return;
}
// If a mouse release was received quickly after showing.
base::TimeDelta time_shown = base::TimeTicks::Now() - menu_start_time_;
if (time_shown.InMilliseconds() < menu_selection_hold_time_ms) {
// And it wasn't far from the mouse press location.
gfx::Point screen_loc(event.location());
View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
gfx::Vector2d moved = screen_loc - menu_start_mouse_press_loc_;
if (moved.Length() < kMaximumLengthMovedToActivate) {
// Ignore the mouse release as it was likely this menu was shown under
// the mouse and the action was just a normal click.
return;
}
}
if (part.menu->GetDelegate()->ShouldExecuteCommandWithoutClosingMenu(
part.menu->GetCommand(), event)) {
part.menu->GetDelegate()->ExecuteCommand(part.menu->GetCommand(),
event.flags());
return;
}
if (!part.menu->NonIconChildViewsCount() &&
part.menu->GetDelegate()->IsTriggerableEvent(part.menu, event)) {
base::TimeDelta shown_time = base::TimeTicks::Now() - menu_start_time_;
if (!state_.context_menu || !View::ShouldShowContextMenuOnMousePress() ||
shown_time.InMilliseconds() > menu_selection_hold_time_ms) {
Accept(part.menu, event.flags());
}
return;
}
} else if (part.type == MenuPart::MENU_ITEM) {
// User either clicked on empty space, or a menu that has children.
SetSelection(part.menu ? part.menu : state_.item,
SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
}
SendMouseCaptureLostToActiveView();
}
void MenuController::OnMouseMoved(SubmenuView* source,
const ui::MouseEvent& event) {
HandleMouseLocation(source, event.location());
}
void MenuController::OnMouseEntered(SubmenuView* source,
const ui::MouseEvent& event) {
// MouseEntered is always followed by a mouse moved, so don't need to
// do anything here.
}
#if defined(USE_AURA)
bool MenuController::OnMouseWheel(SubmenuView* source,
const ui::MouseWheelEvent& event) {
MenuPart part = GetMenuPart(source, event.location());
return part.submenu && part.submenu->OnMouseWheel(event);
}
#endif
void MenuController::OnGestureEvent(SubmenuView* source,
ui::GestureEvent* event) {
MenuPart part = GetMenuPart(source, event->location());
if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
SetSelectionOnPointerDown(source, *event);
event->StopPropagation();
} else if (event->type() == ui::ET_GESTURE_LONG_PRESS) {
if (part.type == MenuPart::MENU_ITEM && part.menu) {
if (ShowContextMenu(part.menu, source, *event, ui::MENU_SOURCE_TOUCH))
event->StopPropagation();
}
} else if (event->type() == ui::ET_GESTURE_TAP) {
if (!part.is_scroll() && part.menu &&
!(part.menu->HasSubmenu())) {
if (part.menu->GetDelegate()->IsTriggerableEvent(
part.menu, *event)) {
Accept(part.menu, event->flags());
item_selected_by_touch_ = true;
}
event->StopPropagation();
} else if (part.type == MenuPart::MENU_ITEM) {
// User either tapped on empty space, or a menu that has children.
SetSelection(part.menu ? part.menu : state_.item,
SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
event->StopPropagation();
}
} else if (event->type() == ui::ET_GESTURE_TAP_CANCEL &&
part.menu &&
part.type == MenuPart::MENU_ITEM) {
// Move the selection to the parent menu so that the selection in the
// current menu is unset. Make sure the submenu remains open by sending the
// appropriate SetSelectionTypes flags.
SetSelection(part.menu->GetParentMenuItem(),
SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
event->StopPropagation();
}
if (event->stopped_propagation())
return;
if (!part.submenu)
return;
part.submenu->OnGestureEvent(event);
}
bool MenuController::GetDropFormats(
SubmenuView* source,
int* formats,
std::set<OSExchangeData::CustomFormat>* custom_formats) {
return source->GetMenuItem()->GetDelegate()->GetDropFormats(
source->GetMenuItem(), formats, custom_formats);
}
bool MenuController::AreDropTypesRequired(SubmenuView* source) {
return source->GetMenuItem()->GetDelegate()->AreDropTypesRequired(
source->GetMenuItem());
}
bool MenuController::CanDrop(SubmenuView* source, const OSExchangeData& data) {
return source->GetMenuItem()->GetDelegate()->CanDrop(source->GetMenuItem(),
data);
}
void MenuController::OnDragEntered(SubmenuView* source,
const ui::DropTargetEvent& event) {
valid_drop_coordinates_ = false;
}
int MenuController::OnDragUpdated(SubmenuView* source,
const ui::DropTargetEvent& event) {
StopCancelAllTimer();
gfx::Point screen_loc(event.location());
View::ConvertPointToScreen(source, &screen_loc);
if (valid_drop_coordinates_ && screen_loc == drop_pt_)
return last_drop_operation_;
drop_pt_ = screen_loc;
valid_drop_coordinates_ = true;
MenuItemView* menu_item = GetMenuItemAt(source, event.x(), event.y());
bool over_empty_menu = false;
if (!menu_item) {
// See if we're over an empty menu.
menu_item = GetEmptyMenuItemAt(source, event.x(), event.y());
if (menu_item)
over_empty_menu = true;
}
MenuDelegate::DropPosition drop_position = MenuDelegate::DROP_NONE;
int drop_operation = ui::DragDropTypes::DRAG_NONE;
if (menu_item) {
gfx::Point menu_item_loc(event.location());
View::ConvertPointToTarget(source, menu_item, &menu_item_loc);
MenuItemView* query_menu_item;
if (!over_empty_menu) {
int menu_item_height = menu_item->height();
if (menu_item->HasSubmenu() &&
(menu_item_loc.y() > kDropBetweenPixels &&
menu_item_loc.y() < (menu_item_height - kDropBetweenPixels))) {
drop_position = MenuDelegate::DROP_ON;
} else {
drop_position = (menu_item_loc.y() < menu_item_height / 2) ?
MenuDelegate::DROP_BEFORE : MenuDelegate::DROP_AFTER;
}
query_menu_item = menu_item;
} else {
query_menu_item = menu_item->GetParentMenuItem();
drop_position = MenuDelegate::DROP_ON;
}
drop_operation = menu_item->GetDelegate()->GetDropOperation(
query_menu_item, event, &drop_position);
// If the menu has a submenu, schedule the submenu to open.
SetSelection(menu_item, menu_item->HasSubmenu() ? SELECTION_OPEN_SUBMENU :
SELECTION_DEFAULT);
if (drop_position == MenuDelegate::DROP_NONE ||
drop_operation == ui::DragDropTypes::DRAG_NONE)
menu_item = NULL;
} else {
SetSelection(source->GetMenuItem(), SELECTION_OPEN_SUBMENU);
}
SetDropMenuItem(menu_item, drop_position);
last_drop_operation_ = drop_operation;
return drop_operation;
}
void MenuController::OnDragExited(SubmenuView* source) {
StartCancelAllTimer();
if (drop_target_) {
StopShowTimer();
SetDropMenuItem(NULL, MenuDelegate::DROP_NONE);
}
}
int MenuController::OnPerformDrop(SubmenuView* source,
const ui::DropTargetEvent& event) {
DCHECK(drop_target_);
// NOTE: the delegate may delete us after invoking OnPerformDrop, as such
// we don't call cancel here.
MenuItemView* item = state_.item;
DCHECK(item);
MenuItemView* drop_target = drop_target_;
MenuDelegate::DropPosition drop_position = drop_position_;
// Close all menus, including any nested menus.
SetSelection(NULL, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT);
CloseAllNestedMenus();
// Set state such that we exit.
showing_ = false;
SetExitType(EXIT_ALL);
// If over an empty menu item, drop occurs on the parent.
if (drop_target->id() == MenuItemView::kEmptyMenuItemViewID)
drop_target = drop_target->GetParentMenuItem();
if (!IsBlockingRun()) {
delegate_->DropMenuClosed(
internal::MenuControllerDelegate::DONT_NOTIFY_DELEGATE,
item->GetRootMenuItem());
}
// WARNING: the call to MenuClosed deletes us.
return drop_target->GetDelegate()->OnPerformDrop(
drop_target, drop_position, event);
}
void MenuController::OnDragEnteredScrollButton(SubmenuView* source,
bool is_up) {
MenuPart part;
part.type = is_up ? MenuPart::SCROLL_UP : MenuPart::SCROLL_DOWN;
part.submenu = source;
UpdateScrolling(part);
// Do this to force the selection to hide.
SetDropMenuItem(source->GetMenuItemAt(0), MenuDelegate::DROP_NONE);
StopCancelAllTimer();
}
void MenuController::OnDragExitedScrollButton(SubmenuView* source) {
StartCancelAllTimer();
SetDropMenuItem(NULL, MenuDelegate::DROP_NONE);
StopScrolling();
}
void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) {
if (submenu->IsShowing()) {
gfx::Point point = GetScreen()->GetCursorScreenPoint();
const SubmenuView* root_submenu =
submenu->GetMenuItem()->GetRootMenuItem()->GetSubmenu();
View::ConvertPointFromScreen(
root_submenu->GetWidget()->GetRootView(), &point);
HandleMouseLocation(submenu, point);
}
}
void MenuController::OnWidgetDestroying(Widget* widget) {
DCHECK_EQ(owner_, widget);
owner_->RemoveObserver(this);
owner_ = NULL;
}
// static
void MenuController::TurnOffMenuSelectionHoldForTest() {
menu_selection_hold_time_ms = -1;
}
void MenuController::SetSelection(MenuItemView* menu_item,
int selection_types) {
size_t paths_differ_at = 0;
std::vector<MenuItemView*> current_path;
std::vector<MenuItemView*> new_path;
BuildPathsAndCalculateDiff(pending_state_.item, menu_item, ¤t_path,
&new_path, &paths_differ_at);
size_t current_size = current_path.size();
size_t new_size = new_path.size();
bool pending_item_changed = pending_state_.item != menu_item;
if (pending_item_changed && pending_state_.item) {
View* current_hot_view = GetFirstHotTrackedView(pending_state_.item);
if (current_hot_view && !strcmp(current_hot_view->GetClassName(),
CustomButton::kViewClassName)) {
CustomButton* button = static_cast<CustomButton*>(current_hot_view);
button->SetHotTracked(false);
}
}
// Notify the old path it isn't selected.
MenuDelegate* current_delegate =
current_path.empty() ? NULL : current_path.front()->GetDelegate();
for (size_t i = paths_differ_at; i < current_size; ++i) {
if (current_delegate &&
current_path[i]->GetType() == MenuItemView::SUBMENU) {
current_delegate->WillHideMenu(current_path[i]);
}
current_path[i]->SetSelected(false);
}
// Notify the new path it is selected.
for (size_t i = paths_differ_at; i < new_size; ++i) {
new_path[i]->ScrollRectToVisible(new_path[i]->GetLocalBounds());
new_path[i]->SetSelected(true);
}
if (menu_item && menu_item->GetDelegate())
menu_item->GetDelegate()->SelectionChanged(menu_item);
DCHECK(menu_item || (selection_types & SELECTION_EXIT) != 0);
pending_state_.item = menu_item;
pending_state_.submenu_open = (selection_types & SELECTION_OPEN_SUBMENU) != 0;
// Stop timers.
StopCancelAllTimer();
// Resets show timer only when pending menu item is changed.
if (pending_item_changed)
StopShowTimer();
if (selection_types & SELECTION_UPDATE_IMMEDIATELY)
CommitPendingSelection();
else if (pending_item_changed)
StartShowTimer();
// Notify an accessibility focus event on all menu items except for the root.
if (menu_item &&
(MenuDepth(menu_item) != 1 ||
menu_item->GetType() != MenuItemView::SUBMENU)) {
menu_item->NotifyAccessibilityEvent(
ui::AccessibilityTypes::EVENT_FOCUS, true);
}
}
void MenuController::SetSelectionOnPointerDown(SubmenuView* source,
const ui::LocatedEvent& event) {
if (!blocking_run_)
return;
DCHECK(!GetActiveMouseView());
MenuPart part = GetMenuPart(source, event.location());
if (part.is_scroll())
return; // Ignore presses on scroll buttons.
// When this menu is opened through a touch event, a simulated right-click
// is sent before the menu appears. Ignore it.
if ((event.flags() & ui::EF_RIGHT_MOUSE_BUTTON) &&
(event.flags() & ui::EF_FROM_TOUCH))
return;
if (part.type == MenuPart::NONE ||
(part.type == MenuPart::MENU_ITEM && part.menu &&
part.menu->GetRootMenuItem() != state_.item->GetRootMenuItem())) {
// Remember the time when we repost the event. The owner can then use this
// to figure out if this menu was finished with the same click which is
// sent to it thereafter. Note that the time stamp front he event cannot be
// used since the reposting will set a new timestamp when the event gets
// processed. As such it is better to take the current time which will be
// closer to the time when it arrives again in the menu handler.
closing_event_time_ = ui::EventTimeForNow();
// Mouse wasn't pressed over any menu, or the active menu, cancel.
#if defined(OS_WIN)
// We're going to close and we own the mouse capture. We need to repost the
// mouse down, otherwise the window the user clicked on won't get the event.
if (!state_.item) {
// We some times get an event after closing all the menus. Ignore it. Make
// sure the menu is in fact not visible. If the menu is visible, then
// we're in a bad state where we think the menu isn't visibile but it is.
DCHECK(!source->GetWidget()->IsVisible());
} else {
RepostEvent(source, event);
}
#endif
// And close.
ExitType exit_type = EXIT_ALL;
if (!menu_stack_.empty()) {
// We're running nested menus. Only exit all if the mouse wasn't over one
// of the menus from the last run.
gfx::Point screen_loc(event.location());
View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
MenuPart last_part = GetMenuPartByScreenCoordinateUsingMenu(
menu_stack_.back().item, screen_loc);
if (last_part.type != MenuPart::NONE)
exit_type = EXIT_OUTERMOST;
}
Cancel(exit_type);
#if defined(USE_AURA) && !defined(OS_WIN)
// We're going to exit the menu and want to repost the event so that is
// is handled normally after the context menu has exited. We call
// RepostEvent after Cancel so that mouse capture has been released so
// that finding the event target is unaffected by the current capture.
RepostEvent(source, event);
#endif
return;
}
// On a press we immediately commit the selection, that way a submenu
// pops up immediately rather than after a delay.
int selection_types = SELECTION_UPDATE_IMMEDIATELY;
if (!part.menu) {
part.menu = part.parent;
selection_types |= SELECTION_OPEN_SUBMENU;
} else {
if (part.menu->GetDelegate()->CanDrag(part.menu)) {
possible_drag_ = true;
press_pt_ = event.location();
}
if (part.menu->HasSubmenu())
selection_types |= SELECTION_OPEN_SUBMENU;
}
SetSelection(part.menu, selection_types);
}
void MenuController::StartDrag(SubmenuView* source,
const gfx::Point& location) {
MenuItemView* item = state_.item;
DCHECK(item);
// Points are in the coordinates of the submenu, need to map to that of
// the selected item. Additionally source may not be the parent of
// the selected item, so need to map to screen first then to item.
gfx::Point press_loc(location);
View::ConvertPointToScreen(source->GetScrollViewContainer(), &press_loc);
View::ConvertPointToTarget(NULL, item, &press_loc);
gfx::Point widget_loc(press_loc);
View::ConvertPointToWidget(item, &widget_loc);
scoped_ptr<gfx::Canvas> canvas(GetCanvasForDragImage(
source->GetWidget(), gfx::Size(item->width(), item->height())));
item->PaintButton(canvas.get(), MenuItemView::PB_FOR_DRAG);
OSExchangeData data;
item->GetDelegate()->WriteDragData(item, &data);
drag_utils::SetDragImageOnDataObject(*canvas, item->size(),
press_loc.OffsetFromOrigin(),
&data);
StopScrolling();
int drag_ops = item->GetDelegate()->GetDragOperations(item);
drag_in_progress_ = true;
// TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below.
item->GetWidget()->RunShellDrag(NULL, data, widget_loc, drag_ops,
ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
drag_in_progress_ = false;
if (GetActiveInstance() == this) {
if (showing_) {
// We're still showing, close all menus.
CloseAllNestedMenus();
Cancel(EXIT_ALL);
} // else case, drop was on us.
} // else case, someone canceled us, don't do anything
}
#if defined(OS_WIN)
bool MenuController::Dispatch(const MSG& msg) {
DCHECK(blocking_run_);
if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) {
// We must translate/dispatch the message here, otherwise we would drop
// the message on the floor.
TranslateMessage(&msg);
DispatchMessage(&msg);
return false;
}
// NOTE: we don't get WM_ACTIVATE or anything else interesting in here.
switch (msg.message) {
case WM_CONTEXTMENU: {
MenuItemView* item = pending_state_.item;
if (item && item->GetRootMenuItem() != item) {
gfx::Point screen_loc(0, item->height());
View::ConvertPointToScreen(item, &screen_loc);
ui::MenuSourceType source_type = ui::MENU_SOURCE_MOUSE;
if (GET_X_LPARAM(msg.lParam) == -1 && GET_Y_LPARAM(msg.lParam) == -1)
source_type = ui::MENU_SOURCE_KEYBOARD;
item->GetDelegate()->ShowContextMenu(item, item->GetCommand(),
screen_loc, source_type);
}
return true;
}
// NOTE: focus wasn't changed when the menu was shown. As such, don't
// dispatch key events otherwise the focused window will get the events.
case WM_KEYDOWN: {
bool result = OnKeyDown(ui::KeyboardCodeFromNative(msg));
TranslateMessage(&msg);
return result;
}
case WM_CHAR:
return !SelectByChar(static_cast<char16>(msg.wParam));
case WM_KEYUP:
return true;
case WM_SYSKEYUP:
// We may have been shown on a system key, as such don't do anything
// here. If another system key is pushed we'll get a WM_SYSKEYDOWN and
// close the menu.
return true;
case WM_CANCELMODE:
case WM_SYSKEYDOWN:
// Exit immediately on system keys.
Cancel(EXIT_ALL);
return false;
default:
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
return exit_type_ == EXIT_NONE;
}
#elif defined(USE_AURA)
bool MenuController::Dispatch(const base::NativeEvent& event) {
if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) {
aura::Env::GetInstance()->GetDispatcher()->Dispatch(event);
return false;
}
// Activates mnemonics only when it it pressed without modifiers except for
// caps and shift.
int flags = ui::EventFlagsFromNative(event) &
~ui::EF_CAPS_LOCK_DOWN & ~ui::EF_SHIFT_DOWN;
if (flags == ui::EF_NONE) {
switch (ui::EventTypeFromNative(event)) {
case ui::ET_KEY_PRESSED:
if (!OnKeyDown(ui::KeyboardCodeFromNative(event)))
return false;
return !SelectByChar(ui::KeyboardCodeFromNative(event));
case ui::ET_KEY_RELEASED:
return true;
default:
break;
}
}
aura::Env::GetInstance()->GetDispatcher()->Dispatch(event);
return exit_type_ == EXIT_NONE;
}
#endif
bool MenuController::OnKeyDown(ui::KeyboardCode key_code) {
DCHECK(blocking_run_);
switch (key_code) {
case ui::VKEY_UP:
IncrementSelection(-1);
break;
case ui::VKEY_DOWN:
IncrementSelection(1);
break;
// Handling of VK_RIGHT and VK_LEFT is different depending on the UI
// layout.
case ui::VKEY_RIGHT:
if (base::i18n::IsRTL())
CloseSubmenu();
else
OpenSubmenuChangeSelectionIfCan();
break;
case ui::VKEY_LEFT:
if (base::i18n::IsRTL())
OpenSubmenuChangeSelectionIfCan();
else
CloseSubmenu();
break;
case ui::VKEY_SPACE:
if (SendAcceleratorToHotTrackedView() == ACCELERATOR_PROCESSED_EXIT)
return false;
break;
case ui::VKEY_F4:
if (!accept_on_f4_)
break;
// Fallthrough to accept on F4, so combobox menus match Windows behavior.
case ui::VKEY_RETURN:
if (pending_state_.item) {
if (pending_state_.item->HasSubmenu()) {
OpenSubmenuChangeSelectionIfCan();
} else {
SendAcceleratorResultType result = SendAcceleratorToHotTrackedView();
if (result == ACCELERATOR_NOT_PROCESSED &&
pending_state_.item->enabled()) {
Accept(pending_state_.item, 0);
return false;
} else if (result == ACCELERATOR_PROCESSED_EXIT) {
return false;
}
}
}
break;
case ui::VKEY_ESCAPE:
if (!state_.item->GetParentMenuItem() ||
(!state_.item->GetParentMenuItem()->GetParentMenuItem() &&
(!state_.item->HasSubmenu() ||
!state_.item->GetSubmenu()->IsShowing()))) {
// User pressed escape and only one menu is shown, cancel it.
Cancel(EXIT_OUTERMOST);
return false;
}
CloseSubmenu();
break;
#if defined(OS_WIN)
case VK_APPS:
break;
#endif
default:
break;
}
return true;
}
MenuController::MenuController(ui::NativeTheme* theme,
bool blocking,
internal::MenuControllerDelegate* delegate)
: blocking_run_(blocking),
showing_(false),
exit_type_(EXIT_NONE),
did_capture_(false),
result_(NULL),
accept_event_flags_(0),
drop_target_(NULL),
drop_position_(MenuDelegate::DROP_UNKNOWN),
owner_(NULL),
possible_drag_(false),
drag_in_progress_(false),
valid_drop_coordinates_(false),
last_drop_operation_(MenuDelegate::DROP_UNKNOWN),
showing_submenu_(false),
menu_button_(NULL),
active_mouse_view_id_(ViewStorage::GetInstance()->CreateStorageID()),
delegate_(delegate),
message_loop_depth_(0),
menu_config_(theme),
closing_event_time_(base::TimeDelta()),
menu_start_time_(base::TimeTicks()),
accept_on_f4_(false),
item_selected_by_touch_(false) {
active_instance_ = this;
}
MenuController::~MenuController() {
DCHECK(!showing_);
if (owner_)
owner_->RemoveObserver(this);
if (active_instance_ == this)
active_instance_ = NULL;
StopShowTimer();
StopCancelAllTimer();
}
MenuController::SendAcceleratorResultType
MenuController::SendAcceleratorToHotTrackedView() {
View* hot_view = GetFirstHotTrackedView(pending_state_.item);
if (!hot_view)
return ACCELERATOR_NOT_PROCESSED;
ui::Accelerator accelerator(ui::VKEY_RETURN, ui::EF_NONE);
hot_view->AcceleratorPressed(accelerator);
if (!strcmp(hot_view->GetClassName(), CustomButton::kViewClassName)) {
CustomButton* button = static_cast<CustomButton*>(hot_view);
button->SetHotTracked(true);
}
return (exit_type_ == EXIT_NONE) ?
ACCELERATOR_PROCESSED : ACCELERATOR_PROCESSED_EXIT;
}
void MenuController::UpdateInitialLocation(
const gfx::Rect& bounds,
MenuItemView::AnchorPosition position,
bool context_menu) {
pending_state_.context_menu = context_menu;
pending_state_.initial_bounds = bounds;
if (bounds.height() > 1) {
// Inset the bounds slightly, otherwise drag coordinates don't line up
// nicely and menus close prematurely.
pending_state_.initial_bounds.Inset(0, 1);
}
// Reverse anchor position for RTL languages.
if (base::i18n::IsRTL() &&
(position == MenuItemView::TOPRIGHT ||
position == MenuItemView::TOPLEFT)) {
pending_state_.anchor = position == MenuItemView::TOPRIGHT ?
MenuItemView::TOPLEFT : MenuItemView::TOPRIGHT;
} else {
pending_state_.anchor = position;
}
// Calculate the bounds of the monitor we'll show menus on. Do this once to
// avoid repeated system queries for the info.
pending_state_.monitor_bounds = GetScreen()->GetDisplayNearestPoint(
bounds.origin()).work_area();
#if defined(USE_ASH)
if (!pending_state_.monitor_bounds.Contains(bounds)) {
// Use the monitor area if the work area doesn't contain the bounds. This
// handles showing a menu from the launcher.
gfx::Rect monitor_area = GetScreen()->GetDisplayNearestPoint(
bounds.origin()).bounds();
if (monitor_area.Contains(bounds))
pending_state_.monitor_bounds = monitor_area;
}
#endif
}
void MenuController::Accept(MenuItemView* item, int event_flags) {
DCHECK(IsBlockingRun());
result_ = item;
if (item && !menu_stack_.empty() &&
!item->GetDelegate()->ShouldCloseAllMenusOnExecute(item->GetCommand())) {
SetExitType(EXIT_OUTERMOST);
} else {
SetExitType(EXIT_ALL);
}
accept_event_flags_ = event_flags;
}
bool MenuController::ShowSiblingMenu(SubmenuView* source,
const gfx::Point& mouse_location) {
if (!menu_stack_.empty() || !menu_button_)
return false;
View* source_view = source->GetScrollViewContainer();
if (mouse_location.x() >= 0 &&
mouse_location.x() < source_view->width() &&
mouse_location.y() >= 0 &&
mouse_location.y() < source_view->height()) {
// The mouse is over the menu, no need to continue.
return false;
}
gfx::NativeWindow window_under_mouse = GetScreen()->GetWindowUnderCursor();
// TODO(oshima): Replace with views only API.
if (!owner_ || window_under_mouse != owner_->GetNativeWindow())
return false;
// The user moved the mouse outside the menu and over the owning window. See
// if there is a sibling menu we should show.
gfx::Point screen_point(mouse_location);
View::ConvertPointToScreen(source_view, &screen_point);
MenuItemView::AnchorPosition anchor;
bool has_mnemonics;
MenuButton* button = NULL;
MenuItemView* alt_menu = source->GetMenuItem()->GetDelegate()->
GetSiblingMenu(source->GetMenuItem()->GetRootMenuItem(),
screen_point, &anchor, &has_mnemonics, &button);
if (!alt_menu || (state_.item && state_.item->GetRootMenuItem() == alt_menu))
return false;
delegate_->SiblingMenuCreated(alt_menu);
if (!button) {
// If the delegate returns a menu, they must also return a button.
NOTREACHED();
return false;
}
// There is a sibling menu, update the button state, hide the current menu
// and show the new one.
menu_button_->SetState(CustomButton::STATE_NORMAL);
menu_button_->SchedulePaint();
menu_button_ = button;
menu_button_->SetState(CustomButton::STATE_PRESSED);
menu_button_->SchedulePaint();
// Need to reset capture when we show the menu again, otherwise we aren't
// going to get any events.
did_capture_ = false;
gfx::Point screen_menu_loc;
View::ConvertPointToScreen(button, &screen_menu_loc);
// It is currently not possible to show a submenu recursively in a bubble.
DCHECK(!MenuItemView::IsBubble(anchor));
// Subtract 1 from the height to make the popup flush with the button border.
UpdateInitialLocation(gfx::Rect(screen_menu_loc.x(), screen_menu_loc.y(),
button->width(), button->height() - 1),
anchor, state_.context_menu);
alt_menu->PrepareForRun(
false, has_mnemonics,
source->GetMenuItem()->GetRootMenuItem()->show_mnemonics_);
alt_menu->controller_ = this;
SetSelection(alt_menu, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
return true;
}
bool MenuController::ShowContextMenu(MenuItemView* menu_item,
SubmenuView* source,
const ui::LocatedEvent& event,
ui::MenuSourceType source_type) {
// Set the selection immediately, making sure the submenu is only open
// if it already was.
int selection_types = SELECTION_UPDATE_IMMEDIATELY;
if (state_.item == pending_state_.item && state_.submenu_open)
selection_types |= SELECTION_OPEN_SUBMENU;
SetSelection(pending_state_.item, selection_types);
gfx::Point loc(event.location());
View::ConvertPointToScreen(source->GetScrollViewContainer(), &loc);
if (menu_item->GetDelegate()->ShowContextMenu(
menu_item, menu_item->GetCommand(), loc, source_type)) {
SendMouseCaptureLostToActiveView();
return true;
}
return false;
}
void MenuController::CloseAllNestedMenus() {
for (std::list<State>::iterator i = menu_stack_.begin();
i != menu_stack_.end(); ++i) {
MenuItemView* last_item = i->item;
for (MenuItemView* item = last_item; item;
item = item->GetParentMenuItem()) {
CloseMenu(item);
last_item = item;
}
i->submenu_open = false;
i->item = last_item;
}
}
MenuItemView* MenuController::GetMenuItemAt(View* source, int x, int y) {
// Walk the view hierarchy until we find a menu item (or the root).
View* child_under_mouse = source->GetEventHandlerForPoint(gfx::Point(x, y));
while (child_under_mouse &&
child_under_mouse->id() != MenuItemView::kMenuItemViewID) {
child_under_mouse = child_under_mouse->parent();
}
if (child_under_mouse && child_under_mouse->enabled() &&
child_under_mouse->id() == MenuItemView::kMenuItemViewID) {
return static_cast<MenuItemView*>(child_under_mouse);
}
return NULL;
}
MenuItemView* MenuController::GetEmptyMenuItemAt(View* source, int x, int y) {
View* child_under_mouse = source->GetEventHandlerForPoint(gfx::Point(x, y));
if (child_under_mouse &&
child_under_mouse->id() == MenuItemView::kEmptyMenuItemViewID) {
return static_cast<MenuItemView*>(child_under_mouse);
}
return NULL;
}
bool MenuController::IsScrollButtonAt(SubmenuView* source,
int x,
int y,
MenuPart::Type* part) {
MenuScrollViewContainer* scroll_view = source->GetScrollViewContainer();
View* child_under_mouse =
scroll_view->GetEventHandlerForPoint(gfx::Point(x, y));
if (child_under_mouse && child_under_mouse->enabled()) {
if (child_under_mouse == scroll_view->scroll_up_button()) {
*part = MenuPart::SCROLL_UP;
return true;
}
if (child_under_mouse == scroll_view->scroll_down_button()) {
*part = MenuPart::SCROLL_DOWN;
return true;
}
}
return false;
}
MenuController::MenuPart MenuController::GetMenuPart(
SubmenuView* source,
const gfx::Point& source_loc) {
gfx::Point screen_loc(source_loc);
View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
return GetMenuPartByScreenCoordinateUsingMenu(state_.item, screen_loc);
}
MenuController::MenuPart MenuController::GetMenuPartByScreenCoordinateUsingMenu(
MenuItemView* item,
const gfx::Point& screen_loc) {
MenuPart part;
for (; item; item = item->GetParentMenuItem()) {
if (item->HasSubmenu() && item->GetSubmenu()->IsShowing() &&
GetMenuPartByScreenCoordinateImpl(item->GetSubmenu(), screen_loc,
&part)) {
return part;
}
}
return part;
}
bool MenuController::GetMenuPartByScreenCoordinateImpl(
SubmenuView* menu,
const gfx::Point& screen_loc,
MenuPart* part) {
// Is the mouse over the scroll buttons?
gfx::Point scroll_view_loc = screen_loc;
View* scroll_view_container = menu->GetScrollViewContainer();
View::ConvertPointToTarget(NULL, scroll_view_container, &scroll_view_loc);
if (scroll_view_loc.x() < 0 ||
scroll_view_loc.x() >= scroll_view_container->width() ||
scroll_view_loc.y() < 0 ||
scroll_view_loc.y() >= scroll_view_container->height()) {
// Point isn't contained in menu.
return false;
}
if (IsScrollButtonAt(menu, scroll_view_loc.x(), scroll_view_loc.y(),
&(part->type))) {
part->submenu = menu;
return true;
}
// Not over the scroll button. Check the actual menu.
if (DoesSubmenuContainLocation(menu, screen_loc)) {
gfx::Point menu_loc = screen_loc;
View::ConvertPointToTarget(NULL, menu, &menu_loc);
part->menu = GetMenuItemAt(menu, menu_loc.x(), menu_loc.y());
part->type = MenuPart::MENU_ITEM;
part->submenu = menu;
if (!part->menu)
part->parent = menu->GetMenuItem();
return true;
}
// While the mouse isn't over a menu item or the scroll buttons of menu, it
// is contained by menu and so we return true. If we didn't return true other
// menus would be searched, even though they are likely obscured by us.
return true;
}
bool MenuController::DoesSubmenuContainLocation(SubmenuView* submenu,
const gfx::Point& screen_loc) {
gfx::Point view_loc = screen_loc;
View::ConvertPointToTarget(NULL, submenu, &view_loc);
gfx::Rect vis_rect = submenu->GetVisibleBounds();
return vis_rect.Contains(view_loc.x(), view_loc.y());
}
void MenuController::CommitPendingSelection() {
StopShowTimer();
size_t paths_differ_at = 0;
std::vector<MenuItemView*> current_path;
std::vector<MenuItemView*> new_path;
BuildPathsAndCalculateDiff(state_.item, pending_state_.item, ¤t_path,
&new_path, &paths_differ_at);
// Hide the old menu.
for (size_t i = paths_differ_at; i < current_path.size(); ++i) {
if (current_path[i]->HasSubmenu()) {
current_path[i]->GetSubmenu()->Hide();
}
}
// Copy pending to state_, making sure to preserve the direction menus were
// opened.
std::list<bool> pending_open_direction;
state_.open_leading.swap(pending_open_direction);
state_ = pending_state_;
state_.open_leading.swap(pending_open_direction);
int menu_depth = MenuDepth(state_.item);
if (menu_depth == 0) {
state_.open_leading.clear();
} else {
int cached_size = static_cast<int>(state_.open_leading.size());
DCHECK_GE(menu_depth, 0);
while (cached_size-- >= menu_depth)
state_.open_leading.pop_back();
}
if (!state_.item) {
// Nothing to select.
StopScrolling();
return;
}
// Open all the submenus preceeding the last menu item (last menu item is
// handled next).
if (new_path.size() > 1) {
for (std::vector<MenuItemView*>::iterator i = new_path.begin();
i != new_path.end() - 1; ++i) {
OpenMenu(*i);
}
}
if (state_.submenu_open) {
// The submenu should be open, open the submenu if the item has a submenu.
if (state_.item->HasSubmenu()) {
OpenMenu(state_.item);
} else {
state_.submenu_open = false;
}
} else if (state_.item->HasSubmenu() &&
state_.item->GetSubmenu()->IsShowing()) {
state_.item->GetSubmenu()->Hide();
}
if (scroll_task_.get() && scroll_task_->submenu()) {
// Stop the scrolling if none of the elements of the selection contain
// the menu being scrolled.
bool found = false;
for (MenuItemView* item = state_.item; item && !found;
item = item->GetParentMenuItem()) {
found = (item->HasSubmenu() && item->GetSubmenu()->IsShowing() &&
item->GetSubmenu() == scroll_task_->submenu());
}
if (!found)
StopScrolling();
}
}
void MenuController::CloseMenu(MenuItemView* item) {
DCHECK(item);
if (!item->HasSubmenu())
return;
item->GetSubmenu()->Hide();
}
void MenuController::OpenMenu(MenuItemView* item) {
DCHECK(item);
if (item->GetSubmenu()->IsShowing()) {
return;
}
OpenMenuImpl(item, true);
did_capture_ = true;
}
void MenuController::OpenMenuImpl(MenuItemView* item, bool show) {
// TODO(oshima|sky): Don't show the menu if drag is in progress and
// this menu doesn't support drag drop. See crbug.com/110495.
if (show) {
int old_count = item->GetSubmenu()->child_count();
item->GetDelegate()->WillShowMenu(item);
if (old_count != item->GetSubmenu()->child_count()) {
// If the number of children changed then we may need to add empty items.
item->AddEmptyMenus();
}
}
bool prefer_leading =
state_.open_leading.empty() ? true : state_.open_leading.back();
bool resulting_direction;
gfx::Rect bounds = MenuItemView::IsBubble(state_.anchor) ?
CalculateBubbleMenuBounds(item, prefer_leading, &resulting_direction) :
CalculateMenuBounds(item, prefer_leading, &resulting_direction);
state_.open_leading.push_back(resulting_direction);
bool do_capture = (!did_capture_ && blocking_run_);
showing_submenu_ = true;
if (show) {
// Menus are the only place using kGroupingPropertyKey, so any value (other
// than 0) is fine.
const int kGroupingId = 1001;
item->GetSubmenu()->ShowAt(owner_, bounds, do_capture);
item->GetSubmenu()->GetWidget()->SetNativeWindowProperty(
TooltipManager::kGroupingPropertyKey,
reinterpret_cast<void*>(kGroupingId));
} else {
item->GetSubmenu()->Reposition(bounds);
}
showing_submenu_ = false;
}
void MenuController::MenuChildrenChanged(MenuItemView* item) {
DCHECK(item);
// Menu shouldn't be updated during drag operation.
DCHECK(!GetActiveMouseView());
// If the current item or pending item is a descendant of the item
// that changed, move the selection back to the changed item.
const MenuItemView* ancestor = state_.item;
while (ancestor && ancestor != item)
ancestor = ancestor->GetParentMenuItem();
if (!ancestor) {
ancestor = pending_state_.item;
while (ancestor && ancestor != item)
ancestor = ancestor->GetParentMenuItem();
if (!ancestor)
return;
}
SetSelection(item, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
if (item->HasSubmenu())
OpenMenuImpl(item, false);
}
void MenuController::BuildPathsAndCalculateDiff(
MenuItemView* old_item,
MenuItemView* new_item,
std::vector<MenuItemView*>* old_path,
std::vector<MenuItemView*>* new_path,
size_t* first_diff_at) {
DCHECK(old_path && new_path && first_diff_at);
BuildMenuItemPath(old_item, old_path);
BuildMenuItemPath(new_item, new_path);
size_t common_size = std::min(old_path->size(), new_path->size());
// Find the first difference between the two paths, when the loop
// returns, diff_i is the first index where the two paths differ.
for (size_t i = 0; i < common_size; ++i) {
if ((*old_path)[i] != (*new_path)[i]) {
*first_diff_at = i;
return;
}
}
*first_diff_at = common_size;
}
void MenuController::BuildMenuItemPath(MenuItemView* item,
std::vector<MenuItemView*>* path) {
if (!item)
return;
BuildMenuItemPath(item->GetParentMenuItem(), path);
path->push_back(item);
}
void MenuController::StartShowTimer() {
show_timer_.Start(FROM_HERE,
TimeDelta::FromMilliseconds(menu_config_.show_delay),
this, &MenuController::CommitPendingSelection);
}
void MenuController::StopShowTimer() {
show_timer_.Stop();
}
void MenuController::StartCancelAllTimer() {
cancel_all_timer_.Start(FROM_HERE,
TimeDelta::FromMilliseconds(kCloseOnExitTime),
this, &MenuController::CancelAll);
}
void MenuController::StopCancelAllTimer() {
cancel_all_timer_.Stop();
}
gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
bool prefer_leading,
bool* is_leading) {
DCHECK(item);
SubmenuView* submenu = item->GetSubmenu();
DCHECK(submenu);
gfx::Size pref = submenu->GetScrollViewContainer()->GetPreferredSize();
// Don't let the menu go too wide.
pref.set_width(std::min(pref.width(),
item->GetDelegate()->GetMaxWidthForMenu(item)));
if (!state_.monitor_bounds.IsEmpty())
pref.set_width(std::min(pref.width(), state_.monitor_bounds.width()));
// Assume we can honor prefer_leading.
*is_leading = prefer_leading;
int x, y;
const MenuConfig& menu_config = item->GetMenuConfig();
if (!item->GetParentMenuItem()) {
// First item, position relative to initial location.
x = state_.initial_bounds.x();
// Offsets for context menu prevent menu items being selected by
// simply opening the menu (bug 142992).
if (menu_config.offset_context_menus && state_.context_menu)
x += 1;
y = state_.initial_bounds.bottom();
if (state_.anchor == MenuItemView::TOPRIGHT) {
x = x + state_.initial_bounds.width() - pref.width();
if (menu_config.offset_context_menus && state_.context_menu)
x -= 1;
} else if (state_.anchor == MenuItemView::BOTTOMCENTER) {
x = x - (pref.width() - state_.initial_bounds.width()) / 2;
if (pref.height() >
state_.initial_bounds.y() + kCenteredContextMenuYOffset) {
// Menu does not fit above the anchor. We move it to below.
y = state_.initial_bounds.y() - kCenteredContextMenuYOffset;
} else {
y = std::max(0, state_.initial_bounds.y() - pref.height()) +
kCenteredContextMenuYOffset;
}
}
if (!state_.monitor_bounds.IsEmpty() &&
y + pref.height() > state_.monitor_bounds.bottom()) {
// The menu doesn't fit fully below the button on the screen. The menu
// position with respect to the bounds will be preserved if it has
// already been drawn. When the requested positioning is below the bounds
// it will shrink the menu to make it fit below.
// If the requested positioning is best fit, it will first try to fit the
// menu below. If that does not fit it will try to place it above. If
// that will not fit it will place it at the bottom of the work area and
// moving it off the initial_bounds region to avoid overlap.
// In all other requested position styles it will be flipped above and
// the height will be shrunken to the usable height.
if (item->actual_menu_position() == MenuItemView::POSITION_BELOW_BOUNDS) {
pref.set_height(std::min(pref.height(),
state_.monitor_bounds.bottom() - y));
} else if (item->actual_menu_position() ==
MenuItemView::POSITION_BEST_FIT) {
MenuItemView::MenuPosition orientation =
MenuItemView::POSITION_BELOW_BOUNDS;
if (state_.monitor_bounds.height() < pref.height()) {
// Handle very tall menus.
pref.set_height(state_.monitor_bounds.height());
y = state_.monitor_bounds.y();
} else if (state_.monitor_bounds.y() + pref.height() <
state_.initial_bounds.y()) {
// Flipping upwards if there is enough space.
y = state_.initial_bounds.y() - pref.height();
orientation = MenuItemView::POSITION_ABOVE_BOUNDS;
} else {
// It is allowed to move the menu a bit around in order to get the
// best fit and to avoid showing scroll elements.
y = state_.monitor_bounds.bottom() - pref.height();
}
if (orientation == MenuItemView::POSITION_BELOW_BOUNDS) {
// The menu should never overlap the owning button. So move it.
// We use the anchor view style to determine the preferred position
// relative to the owning button.
if (state_.anchor == MenuItemView::TOPLEFT) {
// The menu starts with the same x coordinate as the owning button.
if (x + state_.initial_bounds.width() + pref.width() >
state_.monitor_bounds.right())
x -= pref.width(); // Move the menu to the left of the button.
else
x += state_.initial_bounds.width(); // Move the menu right.
} else {
// The menu should end with the same x coordinate as the owning
// button.
if (state_.monitor_bounds.x() >
state_.initial_bounds.x() - pref.width())
x = state_.initial_bounds.right(); // Move right of the button.
else
x = state_.initial_bounds.x() - pref.width(); // Move left.
}
}
item->set_actual_menu_position(orientation);
} else {
pref.set_height(std::min(pref.height(),
state_.initial_bounds.y() - state_.monitor_bounds.y()));
y = state_.initial_bounds.y() - pref.height();
item->set_actual_menu_position(MenuItemView::POSITION_ABOVE_BOUNDS);
}
} else if (item->actual_menu_position() ==
MenuItemView::POSITION_ABOVE_BOUNDS) {
pref.set_height(std::min(pref.height(),
state_.initial_bounds.y() - state_.monitor_bounds.y()));
y = state_.initial_bounds.y() - pref.height();
} else {
item->set_actual_menu_position(MenuItemView::POSITION_BELOW_BOUNDS);
}
if (state_.monitor_bounds.width() != 0 &&
menu_config.offset_context_menus && state_.context_menu) {
if (x + pref.width() > state_.monitor_bounds.right())
x = state_.initial_bounds.x() - pref.width() - 1;
if (x < state_.monitor_bounds.x())
x = state_.monitor_bounds.x();
}
} else {
// Not the first menu; position it relative to the bounds of the menu
// item.
gfx::Point item_loc;
View::ConvertPointToScreen(item, &item_loc);
// We must make sure we take into account the UI layout. If the layout is
// RTL, then a 'leading' menu is positioned to the left of the parent menu
// item and not to the right.
bool layout_is_rtl = base::i18n::IsRTL();
bool create_on_the_right = (prefer_leading && !layout_is_rtl) ||
(!prefer_leading && layout_is_rtl);
int submenu_horizontal_inset = menu_config.submenu_horizontal_inset;
if (create_on_the_right) {
x = item_loc.x() + item->width() - submenu_horizontal_inset;
if (state_.monitor_bounds.width() != 0 &&
x + pref.width() > state_.monitor_bounds.right()) {
if (layout_is_rtl)
*is_leading = true;
else
*is_leading = false;
x = item_loc.x() - pref.width() + submenu_horizontal_inset;
}
} else {
x = item_loc.x() - pref.width() + submenu_horizontal_inset;
if (state_.monitor_bounds.width() != 0 && x < state_.monitor_bounds.x()) {
if (layout_is_rtl)
*is_leading = false;
else
*is_leading = true;
x = item_loc.x() + item->width() - submenu_horizontal_inset;
}
}
y = item_loc.y() - menu_config.menu_vertical_border_size;
if (state_.monitor_bounds.width() != 0) {
pref.set_height(std::min(pref.height(), state_.monitor_bounds.height()));
if (y + pref.height() > state_.monitor_bounds.bottom())
y = state_.monitor_bounds.bottom() - pref.height();
if (y < state_.monitor_bounds.y())
y = state_.monitor_bounds.y();
}
}
if (state_.monitor_bounds.width() != 0) {
if (x + pref.width() > state_.monitor_bounds.right())
x = state_.monitor_bounds.right() - pref.width();
if (x < state_.monitor_bounds.x())
x = state_.monitor_bounds.x();
}
return gfx::Rect(x, y, pref.width(), pref.height());
}
gfx::Rect MenuController::CalculateBubbleMenuBounds(MenuItemView* item,
bool prefer_leading,
bool* is_leading) {
DCHECK(item);
DCHECK(!item->GetParentMenuItem());
// Assume we can honor prefer_leading.
*is_leading = prefer_leading;
SubmenuView* submenu = item->GetSubmenu();
DCHECK(submenu);
gfx::Size pref = submenu->GetScrollViewContainer()->GetPreferredSize();
const gfx::Rect& owner_bounds = pending_state_.initial_bounds;
// First the size gets reduced to the possible space.
if (!state_.monitor_bounds.IsEmpty()) {
int max_width = state_.monitor_bounds.width();
int max_height = state_.monitor_bounds.height();
// In case of bubbles, the maximum width is limited by the space
// between the display corner and the target area + the tip size.
if (state_.anchor == MenuItemView::BUBBLE_LEFT) {
max_width = owner_bounds.x() - state_.monitor_bounds.x() +
kBubbleTipSizeLeftRight;
} else if (state_.anchor == MenuItemView::BUBBLE_RIGHT) {
max_width = state_.monitor_bounds.right() - owner_bounds.right() +
kBubbleTipSizeLeftRight;
} else if (state_.anchor == MenuItemView::BUBBLE_ABOVE) {
max_height = owner_bounds.y() - state_.monitor_bounds.y() +
kBubbleTipSizeTopBottom;
} else if (state_.anchor == MenuItemView::BUBBLE_BELOW) {
max_height = state_.monitor_bounds.bottom() - owner_bounds.bottom() +
kBubbleTipSizeTopBottom;
}
// The space for the menu to cover should never get empty.
DCHECK_GE(max_width, kBubbleTipSizeLeftRight);
DCHECK_GE(max_height, kBubbleTipSizeTopBottom);
pref.set_width(std::min(pref.width(), max_width));
pref.set_height(std::min(pref.height(), max_height));
}
// Also make sure that the menu does not go too wide.
pref.set_width(std::min(pref.width(),
item->GetDelegate()->GetMaxWidthForMenu(item)));
int x, y;
if (state_.anchor == MenuItemView::BUBBLE_ABOVE ||
state_.anchor == MenuItemView::BUBBLE_BELOW) {
if (state_.anchor == MenuItemView::BUBBLE_ABOVE)
y = owner_bounds.y() - pref.height() + kBubbleTipSizeTopBottom;
else
y = owner_bounds.bottom() - kBubbleTipSizeTopBottom;
x = owner_bounds.CenterPoint().x() - pref.width() / 2;
int x_old = x;
if (x < state_.monitor_bounds.x()) {
x = state_.monitor_bounds.x();
} else if (x + pref.width() > state_.monitor_bounds.right()) {
x = state_.monitor_bounds.right() - pref.width();
}
submenu->GetScrollViewContainer()->SetBubbleArrowOffset(
pref.width() / 2 - x + x_old);
} else {
if (state_.anchor == MenuItemView::BUBBLE_RIGHT)
x = owner_bounds.right() - kBubbleTipSizeLeftRight;
else
x = owner_bounds.x() - pref.width() + kBubbleTipSizeLeftRight;
y = owner_bounds.CenterPoint().y() - pref.height() / 2;
int y_old = y;
if (y < state_.monitor_bounds.y()) {
y = state_.monitor_bounds.y();
} else if (y + pref.height() > state_.monitor_bounds.bottom()) {
y = state_.monitor_bounds.bottom() - pref.height();
}
submenu->GetScrollViewContainer()->SetBubbleArrowOffset(
pref.height() / 2 - y + y_old);
}
return gfx::Rect(x, y, pref.width(), pref.height());
}
// static
int MenuController::MenuDepth(MenuItemView* item) {
return item ? (MenuDepth(item->GetParentMenuItem()) + 1) : 0;
}
void MenuController::IncrementSelection(int delta) {
MenuItemView* item = pending_state_.item;
DCHECK(item);
if (pending_state_.submenu_open && item->HasSubmenu() &&
item->GetSubmenu()->IsShowing()) {
// A menu is selected and open, but none of its children are selected,
// select the first menu item.
if (item->GetSubmenu()->GetMenuItemCount()) {
SetSelection(item->GetSubmenu()->GetMenuItemAt(0), SELECTION_DEFAULT);
return;
}
}
if (item->has_children()) {
View* hot_view = GetFirstHotTrackedView(item);
if (hot_view &&
!strcmp(hot_view->GetClassName(), CustomButton::kViewClassName)) {
CustomButton* button = static_cast<CustomButton*>(hot_view);
button->SetHotTracked(false);
View* to_make_hot = GetNextFocusableView(item, button, delta == 1);
if (to_make_hot &&
!strcmp(to_make_hot->GetClassName(), CustomButton::kViewClassName)) {
CustomButton* button_hot = static_cast<CustomButton*>(to_make_hot);
button_hot->SetHotTracked(true);
return;
}
} else {
View* to_make_hot = GetInitialFocusableView(item, delta == 1);
if (to_make_hot &&
!strcmp(to_make_hot->GetClassName(), CustomButton::kViewClassName)) {
CustomButton* button_hot = static_cast<CustomButton*>(to_make_hot);
button_hot->SetHotTracked(true);
return;
}
}
}
MenuItemView* parent = item->GetParentMenuItem();
if (parent) {
int parent_count = parent->GetSubmenu()->GetMenuItemCount();
if (parent_count > 1) {
for (int i = 0; i < parent_count; ++i) {
if (parent->GetSubmenu()->GetMenuItemAt(i) == item) {
MenuItemView* to_select =
FindNextSelectableMenuItem(parent, i, delta);
if (!to_select)
break;
SetSelection(to_select, SELECTION_DEFAULT);
View* to_make_hot = GetInitialFocusableView(to_select, delta == 1);
if (to_make_hot && !strcmp(to_make_hot->GetClassName(),
CustomButton::kViewClassName)) {
CustomButton* button_hot = static_cast<CustomButton*>(to_make_hot);
button_hot->SetHotTracked(true);
}
break;
}
}
}
}
}
MenuItemView* MenuController::FindNextSelectableMenuItem(MenuItemView* parent,
int index,
int delta) {
int start_index = index;
int parent_count = parent->GetSubmenu()->GetMenuItemCount();
// Loop through the menu items skipping any invisible menus. The loop stops
// when we wrap or find a visible child.
do {
index = (index + delta + parent_count) % parent_count;
if (index == start_index)
return NULL;
MenuItemView* child = parent->GetSubmenu()->GetMenuItemAt(index);
if (child->visible())
return child;
} while (index != start_index);
return NULL;
}
void MenuController::OpenSubmenuChangeSelectionIfCan() {
MenuItemView* item = pending_state_.item;
if (item->HasSubmenu() && item->enabled()) {
if (item->GetSubmenu()->GetMenuItemCount() > 0) {
SetSelection(item->GetSubmenu()->GetMenuItemAt(0),
SELECTION_UPDATE_IMMEDIATELY);
} else {
// No menu items, just show the sub-menu.
SetSelection(item, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
}
}
}
void MenuController::CloseSubmenu() {
MenuItemView* item = state_.item;
DCHECK(item);
if (!item->GetParentMenuItem())
return;
if (item->HasSubmenu() && item->GetSubmenu()->IsShowing())
SetSelection(item, SELECTION_UPDATE_IMMEDIATELY);
else if (item->GetParentMenuItem()->GetParentMenuItem())
SetSelection(item->GetParentMenuItem(), SELECTION_UPDATE_IMMEDIATELY);
}
MenuController::SelectByCharDetails MenuController::FindChildForMnemonic(
MenuItemView* parent,
char16 key,
bool (*match_function)(MenuItemView* menu, char16 mnemonic)) {
SubmenuView* submenu = parent->GetSubmenu();
DCHECK(submenu);
SelectByCharDetails details;
for (int i = 0, menu_item_count = submenu->GetMenuItemCount();
i < menu_item_count; ++i) {
MenuItemView* child = submenu->GetMenuItemAt(i);
if (child->enabled() && child->visible()) {
if (child == pending_state_.item)
details.index_of_item = i;
if (match_function(child, key)) {
if (details.first_match == -1)
details.first_match = i;
else
details.has_multiple = true;
if (details.next_match == -1 && details.index_of_item != -1 &&
i > details.index_of_item)
details.next_match = i;
}
}
}
return details;
}
bool MenuController::AcceptOrSelect(MenuItemView* parent,
const SelectByCharDetails& details) {
// This should only be invoked if there is a match.
DCHECK(details.first_match != -1);
DCHECK(parent->HasSubmenu());
SubmenuView* submenu = parent->GetSubmenu();
DCHECK(submenu);
if (!details.has_multiple) {
// There's only one match, activate it (or open if it has a submenu).
if (submenu->GetMenuItemAt(details.first_match)->HasSubmenu()) {
SetSelection(submenu->GetMenuItemAt(details.first_match),
SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
} else {
Accept(submenu->GetMenuItemAt(details.first_match), 0);
return true;
}
} else if (details.index_of_item == -1 || details.next_match == -1) {
SetSelection(submenu->GetMenuItemAt(details.first_match),
SELECTION_DEFAULT);
} else {
SetSelection(submenu->GetMenuItemAt(details.next_match),
SELECTION_DEFAULT);
}
return false;
}
bool MenuController::SelectByChar(char16 character) {
char16 char_array[] = { character, 0 };
char16 key = base::i18n::ToLower(char_array)[0];
MenuItemView* item = pending_state_.item;
if (!item->HasSubmenu() || !item->GetSubmenu()->IsShowing())
item = item->GetParentMenuItem();
DCHECK(item);
DCHECK(item->HasSubmenu());
DCHECK(item->GetSubmenu());
if (item->GetSubmenu()->GetMenuItemCount() == 0)
return false;
// Look for matches based on mnemonic first.
SelectByCharDetails details =
FindChildForMnemonic(item, key, &MatchesMnemonic);
if (details.first_match != -1)
return AcceptOrSelect(item, details);
// If no mnemonics found, look at first character of titles.
details = FindChildForMnemonic(item, key, &TitleMatchesMnemonic);
if (details.first_match != -1)
return AcceptOrSelect(item, details);
return false;
}
void MenuController::RepostEvent(SubmenuView* source,
const ui::LocatedEvent& event) {
gfx::Point screen_loc(event.location());
View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
gfx::NativeView native_view = source->GetWidget()->GetNativeView();
gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view);
gfx::NativeWindow window = screen->GetWindowAtScreenPoint(screen_loc);
if (!window)
return;
#if defined(OS_WIN)
// Release the capture.
SubmenuView* submenu = state_.item->GetRootMenuItem()->GetSubmenu();
submenu->ReleaseCapture();
gfx::NativeView view = submenu->GetWidget()->GetNativeView();
if (view) {
DWORD view_tid = GetWindowThreadProcessId(HWNDForNativeView(view), NULL);
if (view_tid != GetWindowThreadProcessId(HWNDForNativeView(window), NULL)) {
// Even though we have mouse capture, windows generates a mouse event if
// the other window is in a separate thread. Only repost an event if
// |view| was created on the same thread, else the target window can get
// double events leading to bad behavior.
return;
}
}
#endif
scoped_ptr<ui::LocatedEvent> clone;
if (event.IsMouseEvent()) {
clone.reset(new ui::MouseEvent(static_cast<const ui::MouseEvent&>(event)));
} else if (event.IsGestureEvent()) {
// TODO(rbyers): Gesture event repost is tricky to get right
// crbug.com/170987.
return;
} else {
NOTREACHED();
return;
}
clone->set_location(screen_loc);
RepostLocatedEvent(window, *clone);
}
void MenuController::SetDropMenuItem(
MenuItemView* new_target,
MenuDelegate::DropPosition new_position) {
if (new_target == drop_target_ && new_position == drop_position_)
return;
if (drop_target_) {
drop_target_->GetParentMenuItem()->GetSubmenu()->SetDropMenuItem(
NULL, MenuDelegate::DROP_NONE);
}
drop_target_ = new_target;
drop_position_ = new_position;
if (drop_target_) {
drop_target_->GetParentMenuItem()->GetSubmenu()->SetDropMenuItem(
drop_target_, drop_position_);
}
}
void MenuController::UpdateScrolling(const MenuPart& part) {
if (!part.is_scroll() && !scroll_task_.get())
return;
if (!scroll_task_.get())
scroll_task_.reset(new MenuScrollTask());
scroll_task_->Update(part);
}
void MenuController::StopScrolling() {
scroll_task_.reset(NULL);
}
void MenuController::UpdateActiveMouseView(SubmenuView* event_source,
const ui::MouseEvent& event,
View* target_menu) {
View* target = NULL;
gfx::Point target_menu_loc(event.location());
if (target_menu && target_menu->has_children()) {
// Locate the deepest child view to send events to. This code assumes we
// don't have to walk up the tree to find a view interested in events. This
// is currently true for the cases we are embedding views, but if we embed
// more complex hierarchies it'll need to change.
View::ConvertPointToScreen(event_source->GetScrollViewContainer(),
&target_menu_loc);
View::ConvertPointToTarget(NULL, target_menu, &target_menu_loc);
target = target_menu->GetEventHandlerForPoint(target_menu_loc);
if (target == target_menu || !target->enabled())
target = NULL;
}
View* active_mouse_view = GetActiveMouseView();
if (target != active_mouse_view) {
SendMouseCaptureLostToActiveView();
active_mouse_view = target;
SetActiveMouseView(active_mouse_view);
if (active_mouse_view) {
gfx::Point target_point(target_menu_loc);
View::ConvertPointToTarget(
target_menu, active_mouse_view, &target_point);
ui::MouseEvent mouse_entered_event(ui::ET_MOUSE_ENTERED,
target_point, target_point,
0);
active_mouse_view->OnMouseEntered(mouse_entered_event);
ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED,
target_point, target_point,
event.flags());
active_mouse_view->OnMousePressed(mouse_pressed_event);
}
}
if (active_mouse_view) {
gfx::Point target_point(target_menu_loc);
View::ConvertPointToTarget(target_menu, active_mouse_view, &target_point);
ui::MouseEvent mouse_dragged_event(ui::ET_MOUSE_DRAGGED,
target_point, target_point,
event.flags());
active_mouse_view->OnMouseDragged(mouse_dragged_event);
}
}
void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source,
const ui::MouseEvent& event) {
View* active_mouse_view = GetActiveMouseView();
if (!active_mouse_view)
return;
gfx::Point target_loc(event.location());
View::ConvertPointToScreen(event_source->GetScrollViewContainer(),
&target_loc);
View::ConvertPointToTarget(NULL, active_mouse_view, &target_loc);
ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, target_loc, target_loc,
event.flags());
// Reset active mouse view before sending mouse released. That way if it calls
// back to us, we aren't in a weird state.
SetActiveMouseView(NULL);
active_mouse_view->OnMouseReleased(release_event);
}
void MenuController::SendMouseCaptureLostToActiveView() {
View* active_mouse_view = GetActiveMouseView();
if (!active_mouse_view)
return;
// Reset the active_mouse_view_ before sending mouse capture lost. That way if
// it calls back to us, we aren't in a weird state.
SetActiveMouseView(NULL);
active_mouse_view->OnMouseCaptureLost();
}
void MenuController::SetActiveMouseView(View* view) {
if (view)
ViewStorage::GetInstance()->StoreView(active_mouse_view_id_, view);
else
ViewStorage::GetInstance()->RemoveView(active_mouse_view_id_);
}
View* MenuController::GetActiveMouseView() {
return ViewStorage::GetInstance()->RetrieveView(active_mouse_view_id_);
}
void MenuController::SetExitType(ExitType type) {
exit_type_ = type;
// Exit nested message loops as soon as possible. We do this as
// MessageLoop::Dispatcher is only invoked before native events, which means
// its entirely possible for a Widget::CloseNow() task to be processed before
// the next native message. By using QuitNow() we ensures the nested message
// loop returns as soon as possible and avoids having deleted views classes
// (such as widgets and rootviews) on the stack when the nested message loop
// stops.
//
// It's safe to invoke QuitNow multiple times, it only effects the current
// loop.
bool quit_now = ShouldQuitNow() && exit_type_ != EXIT_NONE &&
message_loop_depth_;
if (quit_now)
base::MessageLoop::current()->QuitNow();
}
void MenuController::HandleMouseLocation(SubmenuView* source,
const gfx::Point& mouse_location) {
if (showing_submenu_)
return;
// Ignore mouse events if we're closing the menu.
if (exit_type_ != EXIT_NONE)
return;
MenuPart part = GetMenuPart(source, mouse_location);
UpdateScrolling(part);
if (!blocking_run_)
return;
if (part.type == MenuPart::NONE && ShowSiblingMenu(source, mouse_location))
return;
if (part.type == MenuPart::MENU_ITEM && part.menu) {
SetSelection(part.menu, SELECTION_OPEN_SUBMENU);
} else if (!part.is_scroll() && pending_state_.item &&
pending_state_.item->GetParentMenuItem() &&
(!pending_state_.item->HasSubmenu() ||
!pending_state_.item->GetSubmenu()->IsShowing())) {
// On exit if the user hasn't selected an item with a submenu, move the
// selection back to the parent menu item.
SetSelection(pending_state_.item->GetParentMenuItem(),
SELECTION_OPEN_SUBMENU);
}
}
} // namespace views
| [
"Khilan.Gudka@cl.cam.ac.uk"
] | Khilan.Gudka@cl.cam.ac.uk |
f1f0e55ebb1b4fd83b140cb9218ff57d9b5597b6 | 49dd898e87ca407e35a80c7b3e6a613d87296928 | /stepsequencer.ino | ac6d3d9f5c308848e075b31448c215a7627af2d0 | [] | no_license | mdsohn9/stepsequencer | 6af811daf2f9409367684fa690d21a56b43cfa2b | 31046e99f7d9fe24b2831bb86dbe5e724cc2b125 | refs/heads/master | 2020-03-07T01:45:11.731448 | 2018-03-28T20:07:05 | 2018-03-28T20:07:05 | 127,192,124 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,009 | ino | int buttonPin[5] = {8, 9, 10, 33, 34};
int ledPins[4] = {2, 3, 4, 5};
boolean lastButtonState[6] = {LOW, LOW, LOW, LOW, LOW, LOW};
boolean buttonState[6] = {LOW, LOW, LOW, LOW, LOW, LOW};
boolean stepState[3][4] = {
{false, false, false, false},
{false, false, false, false},
{false, false, false, false}
};
int tempo = 0;
int currentStep = 0;
unsigned long lastStepTime = 0;
int midiNote[3] = {35, 57, 63};
int currentChannel = 0;
void setup() {
Serial.begin(9600);
for (int i = 0; i <= 3; i++) {
pinMode(ledPins[i], OUTPUT);
}
for (int i = 0; i <= 5; i++) {
pinMode(buttonPin[i], INPUT);
}
}
void loop() {
Serial.println(currentChannel);
updateChannel();
sequence();
checkButtons();
setLeds();
}
void sequence() {
int mappedTempo;
tempo = analogRead(A5);
mappedTempo = map(tempo, 0, 1023, 10, 300);
if (millis() > lastStepTime + mappedTempo) { //if its time to go to the next step...
// digitalWrite(ledPins[currentStep], LOW); //turn off the current led
for (int i = 0; i < 3; i++) {
if (stepState[i][currentStep] == HIGH) {
usbMIDI.sendNoteOn(midiNote[i], 127, 1);
} else {
usbMIDI.sendNoteOff(midiNote[i], 0, 1);
}
}
currentStep = currentStep + 1; //increment to the next step
if (currentStep > 3) {
currentStep = 0;
}
// digitalWrite(ledPins[currentStep], HIGH); //turn on the new led
lastStepTime = millis(); //set lastStepTime to the current time
} while (usbMIDI.read()) {
}
}
void updateChannel() {
for (int i = 4; i <= 5; i++) {
lastButtonState[i] = buttonState[i];
buttonState[i] = digitalRead(buttonPin[i]);
if (buttonState[i] == HIGH && lastButtonState[i] == LOW) {
// up button code
if (i == 4) {
currentChannel++;
if (currentChannel > 2) {
currentChannel = 0;
}
}
// down button code
if (i == 5) {
currentChannel--;
if (currentChannel < 0) {
currentChannel = 2;
}
}
}
}
}
void checkButtons() {
for (int i = 0; i <= 3; i++) {
lastButtonState[i] = buttonState[i];
buttonState[i] = digitalRead(buttonPin[i]);
if (buttonState[i] == HIGH && lastButtonState[i] == LOW) {
if (stepState[currentChannel][i] == false) {
stepState[currentChannel][i] = true;
} else if (stepState[currentChannel][i] == true) {
stepState[currentChannel][i] = false;
}
}
}
}
/*
void setLeds() {
for (int i = 0; i <= 3; i++) {
if (stepState[i] == true) {
// digitalWrite(ledPins[i], HIGH);
} else if (stepState[i] == false) {
// digitalWrite(ledPins[i], LOW);
}
}
*/
void setLeds() {
for (int i = 0; i <= 3; i++) {
if (currentStep == i) {
analogWrite(ledPins[i], 255);
}
else if (stepState[currentChannel][i] == true) {
analogWrite(ledPins[i], 50);
}
else {
analogWrite(ledPins[i], 0);
}
}
}
| [
"ms9558@nyu.edu"
] | ms9558@nyu.edu |
6e11d46cfe54a8c622c02339307fb7652b176822 | 229116ff4296a824f50c40f222d953c4148c8024 | /PCViewer/Elaboration/filters_downsampling.cpp | 52ac14220cd6e7957f90fc01ace2a6bfe2034d52 | [] | no_license | xijunke/VisualInertialKinectFusion | 51e22f234963b7343bdd8cfb98fe88ed3c39599b | 610910dca00e9ffe6b0844411f9479d2a15a4b1b | refs/heads/master | 2021-10-09T10:35:13.905499 | 2018-12-26T11:10:30 | 2018-12-26T11:10:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,381 | cpp | #include "filters_downsampling.h"
#include "ui_filters_downsampling.h"
Filters_Downsampling::Filters_Downsampling(QWidget *parent) :
QWidget(parent), ui(new Ui::Filters_Downsampling)
{
ui->setupUi(this);
// myCorrespondenceEstimation.reset(new pcl::registration::CorrespondenceEstimation<PointT, PointT>);
}
Filters_Downsampling::~Filters_Downsampling()
{
delete ui;
}
using namespace std;
//TODO : ADD NORMALSPACE / COVARIANCE / ISS3D
PointCloudT::Ptr Filters_Downsampling::downsample(PointCloudT::Ptr Input)
{
PointCloudT::Ptr Output(new PointCloudT);
if ( ui->DownSampling_RandomSampling->isChecked() )
{
float decimate_percent = ui->DownSampling_Random_Percent->value()/100.0;
pcl::RandomSample<PointT> random_sampler;
random_sampler.setInputCloud(Input);
random_sampler.setSample((int) (decimate_percent*Input->points.size()));
random_sampler.setKeepOrganized(false);
random_sampler.filter(*Output);
}
else if ( ui->DownSampling_VoxelGrid->isChecked() )
{
pcl::VoxelGrid<PointT> sor;
sor.setLeafSize (ui->DownSampling_VoxelGrid_Leaf->value(), ui->DownSampling_VoxelGrid_Leaf->value(), ui->DownSampling_VoxelGrid_Leaf->value());
sor.setInputCloud (Input);
sor.filter (*Output);
}
else if ( ui->Keypoint_SIFT3D->isChecked() )
{
DetectSIFT(Input,Output);
}
else if ( ui->Keypoint_AGAST->isChecked() )
{
DetectAGAST(Input, Output, ui->Keypoint_AGAST_Threshold->value());
}
else if ( ui->Keypoint_BRISK->isChecked() )
{
DetectBRISK(Input, Output, ui->Keypoint_BRISK_Threshold->value(), ui->Keypoint_BRISK_Octave->value());
}
else if ( ui->Keypoint_BRISKQuad->isChecked() )
{
DetectBRISKQuad(Input, Output, ui->Keypoint_BRISK_Threshold->value(), ui->Keypoint_BRISK_Octave->value());
}
else
{
pcl::copyPointCloud( *Input, *Output );
std::vector<int> ind;
pcl::removeNaNFromPointCloud(*Output, *Output,ind);
}
Output->sensor_orientation_ = Input->sensor_orientation_;
Output->sensor_origin_ = Input->sensor_origin_;
return Output;
}
//*******************//
//*** DETECTORS ***//
//*******************//
void Filters_Downsampling::DetectBRISK(PointCloudT::Ptr input, PointCloudT::Ptr output, int paramThreshold, int octave)
{
std::cout << "BRISK Detector...";
QTime t;
t.start();
// constructor
pcl::BriskKeypoint2D<PointT> brisk_keypoint_estimation;
//output
pcl::PointCloud<pcl::PointWithScale> brisk_keypoints_2D;
//parameters
brisk_keypoint_estimation.setThreshold(paramThreshold);
brisk_keypoint_estimation.setOctaves(octave);
brisk_keypoint_estimation.setInputCloud (input);
//compute
brisk_keypoint_estimation.compute (brisk_keypoints_2D);
//convert pointwithscale to 3D
output->resize(brisk_keypoints_2D.size());
int k = brisk_keypoints_2D.size();
for(int i = 0, j = 0; i < k; ++i)
{
/// TO DO: improve accuracy
int u = floor(brisk_keypoints_2D.points[i].x + 0.5);
int v = floor(brisk_keypoints_2D.points[i].y + 0.5);
j = u + v * input->width;
if(isnan(input->points[j].x))
{
--k;
}
else
{
output->points[i]=input->points[j];
/* output->points[i].b=input->points[j].b;
output->points[i].g=input->points[j].g;
output->points[i].r=input->points[j].r;
output->points[i].x=input->points[j].x;
output->points[i].y=input->points[j].y;
output->points[i].z=input->points[j].z;*/
}
}
std::vector<PointT,Eigen::aligned_allocator<PointT> >::iterator keypointIt=output->begin();
for(size_t i=k; k<brisk_keypoints_2D.size(); ++k)
output->erase(keypointIt+i);
pcl::PointIndices::Ptr indices (new pcl::PointIndices);
// Remove NAN from keypoints cloud
pcl::removeNaNFromPointCloud(*output, *output,indices->indices);
pcl::removeNaNNormalsFromPointCloud(*output, *output,indices->indices);
/* // remove 0 points
pcl::ConditionAnd<PointT>::Ptr range_cond (new pcl::ConditionAnd<PointT> ());
range_cond->addComparison (pcl::FieldComparison<PointT>::ConstPtr (new pcl::FieldComparison<PointT> ("z", pcl::ComparisonOps::GT, 0.1)));
// build the filter
pcl::ConditionalRemoval<PointT> condrem(true);
condrem.setCondition(range_cond);
condrem.setInputCloud (output);
condrem.setKeepOrganized(output->isOrganized());
condrem.filter (*output);
*/
std::cout << "DONE " << output->size() << " in " << t.elapsed() << std::endl;
}
void Filters_Downsampling::DetectBRISKQuad(PointCloudT::Ptr input, PointCloudT::Ptr output, int paramThreshold, int octave)
{
std::cout << "BRISK Detector...";
QTime t;
t.start();
// constructor
pcl::BriskKeypoint2D<PointT> brisk_keypoint_estimation;
//output
pcl::PointCloud<pcl::PointWithScale> brisk_keypoints_2D;
//parameters
brisk_keypoint_estimation.setThreshold(paramThreshold);
brisk_keypoint_estimation.setOctaves(octave);
brisk_keypoint_estimation.setInputCloud (input);
//compute
brisk_keypoint_estimation.compute (brisk_keypoints_2D);
//convert pointwithscale to 3D
output->resize(brisk_keypoints_2D.size());
int k = brisk_keypoints_2D.size();
for(int i = 0, j = 0; i < k; ++i)
{
int umin = floor(brisk_keypoints_2D.points[i].x);
int vmin = floor(brisk_keypoints_2D.points[i].y);
int umax = ceil(brisk_keypoints_2D.points[i].x);
int vmax = ceil(brisk_keypoints_2D.points[i].y);
double ures = brisk_keypoints_2D.points[i].x - floor(brisk_keypoints_2D.points[i].x);
double vres = brisk_keypoints_2D.points[i].y - floor(brisk_keypoints_2D.points[i].y);
PointT TL = input->points[umin + vmax * input->width];
PointT TR = input->points[umax + vmax * input->width];
PointT BL = input->points[umin + vmin * input->width];
PointT BR = input->points[umax + vmin * input->width];
double wTL = ures +(1-vres);
double wTR = (1-ures)+(1-vres);
double wBL = ures + vres;
double wBR = (1-ures)+ vres;
if(isnan(TL.x) || isnan(TR.x) || isnan(BL.x) || isnan(BR.x))
{
--k;
}
else
{
output->points[i].b = (wTL*TL.b + wTR*TR.b + wBL*BL.b + wBR*BR.b) / (wTL+wTR+wBL+wBR);
output->points[i].g = (wTL*TL.g + wTR*TR.g + wBL*BL.g + wBR*BR.g) / (wTL+wTR+wBL+wBR);
output->points[i].r = (wTL*TL.r + wTR*TR.r + wBL*BL.r + wBR*BR.r) / (wTL+wTR+wBL+wBR);
output->points[i].x = (wTL*TL.x + wTR*TR.x + wBL*BL.x + wBR*BR.x) / (wTL+wTR+wBL+wBR);
output->points[i].y = (wTL*TL.y + wTR*TR.y + wBL*BL.y + wBR*BR.y) / (wTL+wTR+wBL+wBR);
output->points[i].z = (wTL*TL.z + wTR*TR.z + wBL*BL.z + wBR*BR.z) / (wTL+wTR+wBL+wBR);
}
}
std::vector<PointT,Eigen::aligned_allocator<PointT> >::iterator keypointIt=output->begin();
for(size_t i=k; k<brisk_keypoints_2D.size(); ++k)
output->erase(keypointIt+i);
pcl::PointIndices::Ptr indices (new pcl::PointIndices);
// Remove NAN from keypoints cloud
pcl::removeNaNFromPointCloud(*output, *output,indices->indices);
pcl::removeNaNNormalsFromPointCloud(*output, *output,indices->indices);
// remove 0 points
pcl::ConditionAnd<PointT>::Ptr range_cond (new pcl::ConditionAnd<PointT> ());
range_cond->addComparison (pcl::FieldComparison<PointT>::ConstPtr (new pcl::FieldComparison<PointT> ("z", pcl::ComparisonOps::GT, 0.1)));
// build the filter
pcl::ConditionalRemoval<PointT> condrem(true);
condrem.setCondition(range_cond);
condrem.setInputCloud (output);
condrem.setKeepOrganized(output->isOrganized());
condrem.filter (*output);
std::cout << "DONE " << output->size() << " in " << t.elapsed() << std::endl;
}
void Filters_Downsampling::DetectAGAST(PointCloudT::Ptr input, PointCloudT::Ptr output, int paramThreshold)
{
std::cout << "AGAST Detector...";
// constructor
pcl::AgastKeypoint2D<PointT> agast_keypoint_estimation;
//output
pcl::PointCloud<pcl::PointUV> agast_keypoints_2D;
//parameters
agast_keypoint_estimation.setThreshold (paramThreshold);
agast_keypoint_estimation.setInputCloud (input);
//compute
agast_keypoint_estimation.compute (agast_keypoints_2D);
//convert UV to 3D
output->resize(agast_keypoints_2D.size());
int k = agast_keypoints_2D.size();
for(int i = 0, j = 0; i < k; ++i)
{
j = agast_keypoints_2D.points[i].u + agast_keypoints_2D.points[i].v * input->width;
if(isnan(input->points[j].x))
{
--k;
}
else
{
output->points[i].b=input->points[j].b;
output->points[i].g=input->points[j].g;
output->points[i].r=input->points[j].r;
output->points[i].x=input->points[j].x;
output->points[i].y=input->points[j].y;
output->points[i].z=input->points[j].z;
}
}
std::vector<PointT,Eigen::aligned_allocator<PointT> >::iterator keypointIt=output->begin();
for(int i=k; k<agast_keypoints_2D.size(); ++k)
output->erase(keypointIt+i);
pcl::PointIndices::Ptr indices (new pcl::PointIndices);
// Remove NAN from keypoints cloud
pcl::removeNaNFromPointCloud(*output, *output,indices->indices);
pcl::removeNaNNormalsFromPointCloud(*output, *output,indices->indices);
// remove 0 points
pcl::ConditionAnd<PointT>::Ptr range_cond (new pcl::ConditionAnd<PointT> ());
range_cond->addComparison (pcl::FieldComparison<PointT>::ConstPtr (new pcl::FieldComparison<PointT> ("z", pcl::ComparisonOps::GT, 0.1)));
// build the filter
pcl::ConditionalRemoval<PointT> condrem(true);
condrem.setCondition(range_cond);
condrem.setInputCloud (output);
condrem.setKeepOrganized(output->isOrganized());
condrem.filter (*output);
std::cout << "DONE " << output->size() << std::endl;
}
void Filters_Downsampling::DetectSIFT(PointCloudT::Ptr input, PointCloudT::Ptr output)
{
std::cout << "SIFT Detector...";
pcl::SIFTKeypoint<pcl::PointXYZRGB, pcl::PointXYZI> sift_detect;
const float min_scale = 0.005f;
const int nr_octaves = 6;
const int nr_scales_per_octave = 4;
const float min_contrast = 0.005f;
sift_detect.setSearchMethod(pcl::search::KdTree<pcl::PointXYZRGB>::Ptr (new pcl::search::KdTree<pcl::PointXYZRGB>));
sift_detect.setScales (min_scale, nr_octaves, nr_scales_per_octave);
sift_detect.setMinimumContrast (min_contrast);
pcl::PointCloud<pcl::PointXYZRGB>::Ptr inputXYZRGB(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::copyPointCloud(*input, *inputXYZRGB);
sift_detect.setInputCloud (inputXYZRGB);
pcl::PointCloud<pcl::PointXYZI> keypoints_temp;
sift_detect.compute (keypoints_temp);
//OPT1
// pcl::PointIndices::Ptr ind (new pcl::PointIndices ());
//OPT2
// std::vector<int> ind2;
// ind2 = sift_detect.getKeypointsIndices();
//
// pcl::ExtractIndices<PointT> extract;
//extract.setInputCloud (input);
// extract.setIndices (ind);
// extract.setNegative (false);
// extract.filter (*output);
output->resize(keypoints_temp.size());
pcl::copyPointCloud (keypoints_temp, *output);
pcl::PointIndices::Ptr indices (new pcl::PointIndices);
// Remove NAN from keypoints cloud
pcl::removeNaNFromPointCloud(*output, *output,indices->indices);
pcl::removeNaNNormalsFromPointCloud(*output, *output,indices->indices);
// remove 0 points
pcl::ConditionAnd<PointT>::Ptr range_cond (new pcl::ConditionAnd<PointT> ());
range_cond->addComparison (pcl::FieldComparison<PointT>::ConstPtr (new pcl::FieldComparison<PointT> ("z", pcl::ComparisonOps::GT, 0.1)));
// build the filter
pcl::ConditionalRemoval<PointT> condrem(true);
condrem.setCondition(range_cond);
condrem.setInputCloud (output);
condrem.setKeepOrganized(output->isOrganized());
condrem.filter (*output);
std::cout << "DONE " << output->size() << std::endl;
return ;
}
| [
"silvio.giancola@gmail.com"
] | silvio.giancola@gmail.com |
d48df35388ff83128c9881119ef6b7f62274d8b8 | 12c47aa3209534787ae0d5532e16a7e9a17cbccd | /trunk/3rd/dbgme/include/xmlConfKit/xmlParserHelper.h | de4bb7c86b0a58e163a4d28232466c87de62909b | [
"BSD-2-Clause"
] | permissive | scofieldzhu/blackconfigurator | 25c4d644e70223582909d21c2fcb69576ad38913 | a035d8fe242860da9ae98b09d331a13633e6aa1a | refs/heads/master | 2021-01-10T04:07:30.451868 | 2015-12-16T13:35:03 | 2015-12-16T13:35:03 | 46,601,185 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 447 | h | #ifndef __XML_PARSER_HELPER_H__
#define __XML_PARSER_HELPER_H__
#include "xmlClsNodeParserLodge.h"
DGR2_NP_BEGIN
namespace LotsOfKeyNodes
{
extern DGR2_API const xCharT* ROOT;
extern DGR2_API const xCharT* LOGGER;
extern DGR2_API const xCharT* FILTER;
extern DGR2_API const xCharT* APPENDER;
extern DGR2_API const xCharT* FORMATTER;
}
namespace LotsOfKeyAttrs
{
extern DGR2_API const xCharT* CLS_ATTR;
}
NP_END
#endif | [
"scofieldzhu@ymail.com"
] | scofieldzhu@ymail.com |
a3a2f9382393f83ae399c4bc651fce6e6b8b3f02 | 1cc631c61d85076c192a6946acb35d804f0620e4 | /Source/third_party/cegui-0.6.1/RendererModules/OpenGLGUIRenderer/opengltexture.h | c6aa0fe9121a66bb099efeccb5a512932c1670b8 | [
"Zlib",
"LicenseRef-scancode-pcre",
"MIT"
] | permissive | reven86/dreamfarmgdk | f9746e1c0e701f243c7dd2f14394970cc47346d9 | 4d5c26701bf05e89eef56ddd4553814aa6b0e770 | refs/heads/master | 2021-01-19T00:58:04.259208 | 2016-10-04T21:29:28 | 2016-10-04T21:33:10 | 906,953 | 2 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 6,502 | h | /***********************************************************************
filename: opengltexture.h
created: 9/4/2004
author: Mark Strom
mwstrom@gmail.com
purpose: Interface to Texture implemented via Opengl
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#ifndef _opengltexture_h_
#define _opengltexture_h_
#include "CEGUIBase.h"
#include "CEGUIRenderer.h"
#include "CEGUITexture.h"
#include "openglrenderer.h"
#include <list>
// Start of CEGUI namespace section
namespace CEGUI
{
/*!
\brief
Texture class that is created by OpenGLRenderer objects
*/
class OPENGL_GUIRENDERER_API OpenGLTexture : public Texture
{
private:
/*************************************************************************
Friends (to allow construction and destruction)
*************************************************************************/
friend Texture* OpenGLRenderer::createTexture(void);
friend Texture* OpenGLRenderer::createTexture(const String& filename, const String& resourceGroup);
friend Texture* OpenGLRenderer::createTexture(float size);
friend void OpenGLRenderer::destroyTexture(Texture* texture);
/*************************************************************************
Construction & Destruction (by Renderer object only)
*************************************************************************/
OpenGLTexture(Renderer* owner);
virtual ~OpenGLTexture(void);
public:
/*!
\brief
Returns the current pixel width of the texture
\return
ushort value that is the current width of the texture in pixels
*/
virtual ushort getWidth(void) const {return d_width;}
/*!
\brief
Returns the current pixel height of the texture
\return
ushort value that is the current height of the texture in pixels
*/
virtual ushort getHeight(void) const {return d_height;}
virtual ushort getOriginalWidth(void) const { return d_orgWidth; }
virtual ushort getOriginalHeight(void) const { return d_orgHeight; }
virtual float getXScale(void) const { return d_xScale; }
virtual float getYScale(void) const { return d_yScale; }
/*!
\brief
Loads the specified image file into the texture. The texture is resized as required to hold the image.
\param filename
The filename of the image file that is to be loaded into the texture
\param resourceGroup
Resource group identifier passed to the resource provider.
\return
Nothing.
*/
virtual void loadFromFile(const String& filename, const String& resourceGroup);
/*!
\brief
Loads (copies) an image in memory into the texture. The texture is resized as required to hold the image.
\param buffPtr
Pointer to the buffer containing the image data
\param buffWidth
Width of the buffer (in pixels as specified by \a pixelFormat )
\param buffHeight
Height of the buffer (in pixels as specified by \a pixelFormat )
\param pixelFormat
PixelFormat value describing the format contained in \a buffPtr
\return
Nothing.
*/
virtual void loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight, PixelFormat pixelFormat);
/*!
\brief
Return a pointer to the internal texture id
\return
Texture id that is loaded
*/
GLuint getOGLTexid(void) const {return d_ogltexture;}
/*!
\brief
set the size of the internal texture.
\param size
pixel size of the new internal texture. This will be rounded up to a power of 2.
\return
Nothing.
*/
void setOGLTextureSize(uint size);
/************************************************************************
Grab/restore
*************************************************************************/
/*!
\brief
Grab the texture to a local buffer.
This will destroy the OpenGL texture, and restoreTexture must be called before using it again.
*/
void grabTexture(void);
/*!
\brief
Restore the texture from the locally buffered copy previously create by a call to grabTexture.
*/
void restoreTexture(void);
private:
//! updates cached scale value used to map pixels to texture co-ords.
void updateCachedScaleValues();
//! returns next power of 2 size if \a size is not power of 2
uint getSizeNextPOT(uint size) const;
/*************************************************************************
Implementation Data
*************************************************************************/
GLuint d_ogltexture; //!< The 'real' texture.
ushort d_width; //!< cached width of the texture
ushort d_height; //!< cached height of the texture
uint8* d_grabBuffer; //!< cached image data for restoring the texture
//! original pixel width of data loaded into texture
ushort d_orgWidth;
//! original pixel height of data loaded into texture
ushort d_orgHeight;
//! cached value for x scale
float d_xScale;
//! cahced value foy y scale
float d_yScale;
};
} // End of CEGUI namespace section
#endif // end of guard _opengltexture_h_
| [
"reven86@gmail.com"
] | reven86@gmail.com |
404c3f64f7ad8a80e3e6ccdd7dc0eb60e2f46c45 | b1b0c55e741e4e9e5dc4a4f8d0b3fd050f477098 | /gameSource/objectBank.cpp | efc48affc83fed3db29edf4645b9d68ba44b998d | [
"LicenseRef-scancode-public-domain"
] | permissive | kenikamu/OneLife | e558323f501b279aa20281fbcbf5935b35ef71fd | 15a3a2437fab4ef22b4c2a3a006d18785bebddfa | refs/heads/master | 2020-03-14T10:31:24.255069 | 2018-04-28T19:20:05 | 2018-04-28T19:20:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 135,151 | cpp |
#include "objectBank.h"
#include "minorGems/util/StringTree.h"
#include "minorGems/util/SimpleVector.h"
#include "minorGems/util/stringUtils.h"
#include "minorGems/util/random/JenkinsRandomSource.h"
#include "minorGems/io/file/File.h"
#include "minorGems/graphics/converters/TGAImageConverter.h"
#include "spriteBank.h"
#include "ageControl.h"
#include "folderCache.h"
#include "soundBank.h"
#include "animationBank.h"
static int mapSize;
// maps IDs to records
// sparse, so some entries are NULL
static ObjectRecord **idMap;
static StringTree tree;
// track objects that are marked with the person flag
static SimpleVector<int> personObjectIDs;
// track female people
static SimpleVector<int> femalePersonObjectIDs;
// track monument calls
static SimpleVector<int> monumentCallObjectIDs;
// track death markers
static SimpleVector<int> deathMarkerObjectIDs;
// anything above race 100 is put in bin for race 100
#define MAX_RACE 100
static SimpleVector<int> racePersonObjectIDs[ MAX_RACE + 1 ];
static SimpleVector<int> raceList;
#define MAX_BIOME 511
static float biomeHeatMap[ MAX_BIOME + 1 ];
static int recomputeObjectHeight( int inNumSprites, int *inSprites,
doublePair *inSpritePos );
static void rebuildRaceList() {
raceList.deleteAll();
for( int i=0; i <= MAX_RACE; i++ ) {
if( racePersonObjectIDs[ i ].size() > 0 ) {
raceList.push_back( i );
// now sort into every-other gender order
int num = racePersonObjectIDs[i].size();
SimpleVector<int> boys;
SimpleVector<int> girls;
for( int j=0; j<num; j++ ) {
int id = racePersonObjectIDs[i].getElementDirect( j );
ObjectRecord *o = getObject( id );
if( o->male ) {
boys.push_back( id );
}
else {
girls.push_back( id );
}
}
racePersonObjectIDs[i].deleteAll();
int boyIndex = 0;
int girlIndex = 0;
int boysLeft = boys.size();
int girlsLeft = girls.size();
int flip = 0;
for( int j=0; j<num; j++ ) {
if( ( flip && boysLeft > 0 )
||
girlsLeft == 0 ) {
racePersonObjectIDs[i].push_back(
boys.getElementDirect( boyIndex ) );
boysLeft--;
boyIndex++;
}
else {
racePersonObjectIDs[i].push_back(
girls.getElementDirect( girlIndex ) );
girlsLeft--;
girlIndex++;
}
flip = !flip;
}
}
}
}
static JenkinsRandomSource randSource;
static ClothingSet emptyClothing = { NULL, NULL, NULL, NULL, NULL, NULL };
static FolderCache cache;
static int currentFile;
static SimpleVector<ObjectRecord*> records;
static int maxID;
static int maxWideRadius = 0;
int getMaxObjectID() {
return maxID;
}
void setDrawColor( FloatRGB inColor ) {
setDrawColor( inColor.r,
inColor.g,
inColor.b,
1 );
}
static char autoGenerateUsedObjects = false;
static char autoGenerateVariableObjects = false;
int initObjectBankStart( char *outRebuildingCache,
char inAutoGenerateUsedObjects,
char inAutoGenerateVariableObjects ) {
maxID = 0;
currentFile = 0;
cache = initFolderCache( "objects", outRebuildingCache );
autoGenerateUsedObjects = inAutoGenerateUsedObjects;
autoGenerateVariableObjects = inAutoGenerateVariableObjects;
return cache.numFiles;
}
char *boolArrayToSparseCommaString( const char *inLineName,
char *inArray, int inLength ) {
char numberBuffer[20];
SimpleVector<char> resultBuffer;
resultBuffer.appendElementString( inLineName );
resultBuffer.push_back( '=' );
char firstWritten = false;
for( int i=0; i<inLength; i++ ) {
if( inArray[i] ) {
if( firstWritten ) {
resultBuffer.push_back( ',' );
}
sprintf( numberBuffer, "%d", i );
resultBuffer.appendElementString( numberBuffer );
firstWritten = true;
}
}
if( !firstWritten ) {
resultBuffer.appendElementString( "-1" );
}
return resultBuffer.getElementString();
}
void sparseCommaLineToBoolArray( const char *inExpectedLineName,
char *inLine,
char *inBoolArray,
int inBoolArrayLength ) {
if( strstr( inLine, inExpectedLineName ) == NULL ) {
printf( "Expected line name %s not found in line %s\n",
inExpectedLineName, inLine );
return;
}
char *listStart = strstr( inLine, "=" );
if( listStart == NULL ) {
printf( "Expected character '=' not found in line %s\n",
inLine );
return;
}
listStart = &( listStart[1] );
int numParts;
char **listNumberStrings = split( listStart, ",", &numParts );
for( int i=0; i<numParts; i++ ) {
int scannedInt = -1;
sscanf( listNumberStrings[i], "%d", &scannedInt );
if( scannedInt >= 0 &&
scannedInt < inBoolArrayLength ) {
inBoolArray[ scannedInt ] = true;
}
delete [] listNumberStrings[i];
}
delete [] listNumberStrings;
}
static void fillObjectBiomeFromString( ObjectRecord *inRecord,
char *inBiomes ) {
char **biomeParts = split( inBiomes, ",", &( inRecord->numBiomes ) );
inRecord->biomes = new int[ inRecord->numBiomes ];
for( int i=0; i< inRecord->numBiomes; i++ ) {
sscanf( biomeParts[i], "%d", &( inRecord->biomes[i] ) );
delete [] biomeParts[i];
}
delete [] biomeParts;
}
float initObjectBankStep() {
if( currentFile == cache.numFiles ) {
return 1.0;
}
int i = currentFile;
char *txtFileName = getFileName( cache, i );
if( strstr( txtFileName, ".txt" ) != NULL &&
strstr( txtFileName, "groundHeat_" ) == NULL &&
strcmp( txtFileName, "nextObjectNumber.txt" ) != 0 ) {
// an object txt file!
char *objectText = getFileContents( cache, i );
if( objectText != NULL ) {
int numLines;
char **lines = split( objectText, "\n", &numLines );
delete [] objectText;
if( numLines >= 14 ) {
ObjectRecord *r = new ObjectRecord;
int next = 0;
r->id = 0;
sscanf( lines[next], "id=%d",
&( r->id ) );
if( r->id > maxID ) {
maxID = r->id;
}
next++;
r->description = stringDuplicate( lines[next] );
next++;
int contRead = 0;
sscanf( lines[next], "containable=%d",
&( contRead ) );
r->containable = contRead;
next++;
r->containSize = 1;
r->vertContainRotationOffset = 0;
sscanf( lines[next], "containSize=%f,vertSlotRot=%lf",
&( r->containSize ),
&( r->vertContainRotationOffset ) );
next++;
int permRead = 0;
r->minPickupAge = 3;
sscanf( lines[next], "permanent=%d,minPickupAge=%d",
&( permRead ),
&( r->minPickupAge ) );
r->permanent = permRead;
next++;
int heldInHandRead = 0;
sscanf( lines[next], "heldInHand=%d",
&( heldInHandRead ) );
r->heldInHand = false;
r->rideable = false;
if( heldInHandRead == 1 ) {
r->heldInHand = true;
}
else if( heldInHandRead == 2 ) {
r->rideable = true;
}
next++;
int blocksWalkingRead = 0;
r->leftBlockingRadius = 0;
r->rightBlockingRadius = 0;
int drawBehindPlayerRead = 0;
sscanf( lines[next],
"blocksWalking=%d,"
"leftBlockingRadius=%d,rightBlockingRadius=%d,"
"drawBehindPlayer=%d",
&( blocksWalkingRead ),
&( r->leftBlockingRadius ),
&( r->rightBlockingRadius ),
&( drawBehindPlayerRead ) );
r->blocksWalking = blocksWalkingRead;
r->drawBehindPlayer = drawBehindPlayerRead;
r->wide = ( r->leftBlockingRadius > 0 ||
r->rightBlockingRadius > 0 );
if( r->wide ) {
r->drawBehindPlayer = true;
if( r->leftBlockingRadius > maxWideRadius ) {
maxWideRadius = r->leftBlockingRadius;
}
if( r->rightBlockingRadius > maxWideRadius ) {
maxWideRadius = r->rightBlockingRadius;
}
}
next++;
r->mapChance = 0;
char biomeString[200];
int numRead = sscanf( lines[next],
"mapChance=%f#biomes_%199s",
&( r->mapChance ), biomeString );
if( numRead != 2 ) {
// biome not present (old format), treat as 0
biomeString[0] = '0';
biomeString[1] = '\0';
sscanf( lines[next], "mapChance=%f", &( r->mapChance ) );
// NOTE: I've avoided too many of these format
// bandaids, and forced whole-folder file rewrites
// in the past.
// But now we're part way into production, so bandaids
// are more effective.
}
fillObjectBiomeFromString( r, biomeString );
next++;
r->heatValue = 0;
sscanf( lines[next], "heatValue=%d",
&( r->heatValue ) );
next++;
r->rValue = 0;
sscanf( lines[next], "rValue=%f",
&( r->rValue ) );
next++;
int personRead = 0;
int noSpawnRead = 0;
sscanf( lines[next], "person=%d,noSpawn=%d",
&personRead, &noSpawnRead );
r->person = ( personRead > 0 );
r->race = personRead;
r->personNoSpawn = noSpawnRead;
next++;
int maleRead = 0;
sscanf( lines[next], "male=%d",
&( maleRead ) );
r->male = maleRead;
next++;
int deathMarkerRead = 0;
sscanf( lines[next], "deathMarker=%d",
&( deathMarkerRead ) );
r->deathMarker = deathMarkerRead;
if( r->deathMarker ) {
deathMarkerObjectIDs.push_back( r->id );
}
next++;
r->homeMarker = false;
if( strstr( lines[next], "homeMarker=" ) != NULL ) {
// home marker flag present
int homeMarkerRead = 0;
sscanf( lines[next], "homeMarker=%d", &( homeMarkerRead ) );
r->homeMarker = homeMarkerRead;
next++;
}
r->floor = false;
if( strstr( lines[next], "floor=" ) != NULL ) {
// floor flag present
int floorRead = 0;
sscanf( lines[next], "floor=%d", &( floorRead ) );
r->floor = floorRead;
next++;
}
r->floorHugging = false;
if( strstr( lines[next], "floorHugging=" ) != NULL ) {
// floorHugging flag present
int hugRead = 0;
sscanf( lines[next], "floorHugging=%d", &( hugRead ) );
r->floorHugging = hugRead;
next++;
}
sscanf( lines[next], "foodValue=%d",
&( r->foodValue ) );
next++;
sscanf( lines[next], "speedMult=%f",
&( r->speedMult ) );
next++;
r->heldOffset.x = 0;
r->heldOffset.y = 0;
sscanf( lines[next], "heldOffset=%lf,%lf",
&( r->heldOffset.x ),
&( r->heldOffset.y ) );
next++;
r->clothing = 'n';
sscanf( lines[next], "clothing=%c",
&( r->clothing ));
next++;
r->clothingOffset.x = 0;
r->clothingOffset.y = 0;
sscanf( lines[next], "clothingOffset=%lf,%lf",
&( r->clothingOffset.x ),
&( r->clothingOffset.y ) );
next++;
r->deadlyDistance = 0;
sscanf( lines[next], "deadlyDistance=%d",
&( r->deadlyDistance ) );
next++;
r->useDistance = 1;
if( strstr( lines[next],
"useDistance=" ) != NULL ) {
// use distance present
sscanf( lines[next], "useDistance=%d",
&( r->useDistance ) );
next++;
}
r->creationSound = blankSoundUsage;
r->usingSound = blankSoundUsage;
r->eatingSound = blankSoundUsage;
r->decaySound = blankSoundUsage;
if( strstr( lines[next], "sounds=" ) != NULL ) {
// sounds present
int numParts = 0;
char **parts = split( &( lines[next][7] ), ",", &numParts );
if( numParts == 4 ) {
r->creationSound = scanSoundUsage( parts[0] );
r->usingSound = scanSoundUsage( parts[1] );
r->eatingSound = scanSoundUsage( parts[2] );
r->decaySound = scanSoundUsage( parts[3] );
}
for( int i=0; i<numParts; i++ ) {
delete [] parts[i];
}
delete [] parts;
next++;
}
if( strstr( lines[next],
"creationSoundInitialOnly=" ) != NULL ) {
// flag present
int flagRead = 0;
sscanf( lines[next], "creationSoundInitialOnly=%d",
&( flagRead ) );
r->creationSoundInitialOnly = flagRead;
next++;
}
else {
r->creationSoundInitialOnly = 0;
}
r->numSlots = 0;
r->slotTimeStretch = 1.0f;
if( strstr( lines[next], "#" ) != NULL ) {
sscanf( lines[next], "numSlots=%d#timeStretch=%f",
&( r->numSlots ),
&( r->slotTimeStretch ) );
}
else {
sscanf( lines[next], "numSlots=%d",
&( r->numSlots ) );
}
next++;
r->slotSize = 1;
sscanf( lines[next], "slotSize=%f",
&( r->slotSize ) );
next++;
r->slotPos = new doublePair[ r->numSlots ];
r->slotVert = new char[ r->numSlots ];
r->slotParent = new int[ r->numSlots ];
for( int i=0; i< r->numSlots; i++ ) {
r->slotVert[i] = false;
r->slotParent[i] = -1;
int vertRead = 0;
sscanf( lines[ next ], "slotPos=%lf,%lf,vert=%d,parent=%d",
&( r->slotPos[i].x ),
&( r->slotPos[i].y ),
&vertRead,
&( r->slotParent[i] ) );
r->slotVert[i] = vertRead;
next++;
}
r->numSprites = 0;
sscanf( lines[next], "numSprites=%d",
&( r->numSprites ) );
next++;
r->sprites = new int[r->numSprites];
r->spritePos = new doublePair[ r->numSprites ];
r->spriteRot = new double[ r->numSprites ];
r->spriteHFlip = new char[ r->numSprites ];
r->spriteColor = new FloatRGB[ r->numSprites ];
r->spriteAgeStart = new double[ r->numSprites ];
r->spriteAgeEnd = new double[ r->numSprites ];
r->spriteParent = new int[ r->numSprites ];
r->spriteInvisibleWhenHolding = new char[ r->numSprites ];
r->spriteInvisibleWhenWorn = new int[ r->numSprites ];
r->spriteBehindSlots = new char[ r->numSprites ];
r->spriteIsHead = new char[ r->numSprites ];
r->spriteIsBody = new char[ r->numSprites ];
r->spriteIsBackFoot = new char[ r->numSprites ];
r->spriteIsFrontFoot = new char[ r->numSprites ];
memset( r->spriteIsHead, false, r->numSprites );
memset( r->spriteIsBody, false, r->numSprites );
memset( r->spriteIsBackFoot, false, r->numSprites );
memset( r->spriteIsFrontFoot, false, r->numSprites );
r->numUses = 1;
r->useChance = 1.0f;
r->spriteUseVanish = new char[ r->numSprites ];
r->spriteUseAppear = new char[ r->numSprites ];
r->useDummyIDs = NULL;
r->isUseDummy = false;
r->useDummyParent = 0;
r->cachedHeight = -1;
memset( r->spriteUseVanish, false, r->numSprites );
memset( r->spriteUseAppear, false, r->numSprites );
r->spriteSkipDrawing = new char[ r->numSprites ];
memset( r->spriteSkipDrawing, false, r->numSprites );
r->apocalypseTrigger = false;
if( r->description[0] == 'T' &&
r->description[1] == 'h' &&
strstr( r->description, "The Apocalypse" ) ==
r->description ) {
printf( "Object id %d (%s) seen as an apocalypse trigger\n",
r->id, r->description );
r->apocalypseTrigger = true;
}
r->monumentStep = false;
r->monumentDone = false;
r->monumentCall = false;
if( strstr( r->description, "monument" ) != NULL ) {
// some kind of monument state
if( strstr( r->description, "monumentStep" ) != NULL ) {
r->monumentStep = true;
}
else if( strstr( r->description,
"monumentDone" ) != NULL ) {
r->monumentDone = true;
}
else if( strstr( r->description,
"monumentCall" ) != NULL ) {
r->monumentCall = true;
monumentCallObjectIDs.push_back( r->id );
}
}
r->numVariableDummyIDs = 0;
r->variableDummyIDs = NULL;
r->isVariableDummy = false;
for( int i=0; i< r->numSprites; i++ ) {
sscanf( lines[next], "spriteID=%d",
&( r->sprites[i] ) );
next++;
sscanf( lines[next], "pos=%lf,%lf",
&( r->spritePos[i].x ),
&( r->spritePos[i].y ) );
next++;
sscanf( lines[next], "rot=%lf",
&( r->spriteRot[i] ) );
next++;
int flipRead = 0;
sscanf( lines[next], "hFlip=%d", &flipRead );
r->spriteHFlip[i] = flipRead;
next++;
sscanf( lines[next], "color=%f,%f,%f",
&( r->spriteColor[i].r ),
&( r->spriteColor[i].g ),
&( r->spriteColor[i].b ) );
next++;
sscanf( lines[next], "ageRange=%lf,%lf",
&( r->spriteAgeStart[i] ),
&( r->spriteAgeEnd[i] ) );
next++;
sscanf( lines[next], "parent=%d",
&( r->spriteParent[i] ) );
next++;
int invisRead = 0;
int invisWornRead = 0;
int behindSlotsRead = 0;
sscanf( lines[next],
"invisHolding=%d,invisWorn=%d,behindSlots=%d",
&invisRead, &invisWornRead,
&behindSlotsRead );
r->spriteInvisibleWhenHolding[i] = invisRead;
r->spriteInvisibleWhenWorn[i] = invisWornRead;
r->spriteBehindSlots[i] = behindSlotsRead;
next++;
}
sparseCommaLineToBoolArray( "headIndex", lines[next],
r->spriteIsHead, r->numSprites );
next++;
sparseCommaLineToBoolArray( "bodyIndex", lines[next],
r->spriteIsBody, r->numSprites );
next++;
sparseCommaLineToBoolArray( "backFootIndex", lines[next],
r->spriteIsBackFoot,
r->numSprites );
next++;
sparseCommaLineToBoolArray( "frontFootIndex", lines[next],
r->spriteIsFrontFoot,
r->numSprites );
next++;
if( next < numLines ) {
// info about num uses and vanish/appear sprites
sscanf( lines[next], "numUses=%d,%f",
&( r->numUses ),
&( r->useChance ) );
next++;
if( next < numLines ) {
sparseCommaLineToBoolArray( "useVanishIndex",
lines[next],
r->spriteUseVanish,
r->numSprites );
next++;
if( next < numLines ) {
sparseCommaLineToBoolArray( "useAppearIndex",
lines[next],
r->spriteUseAppear,
r->numSprites );
next++;
}
}
}
if( next < numLines ) {
sscanf( lines[next], "pixHeight=%d",
&( r->cachedHeight ) );
next++;
}
records.push_back( r );
if( r->person && ! r->personNoSpawn ) {
personObjectIDs.push_back( r->id );
if( ! r->male ) {
femalePersonObjectIDs.push_back( r->id );
}
if( r->race <= MAX_RACE ) {
racePersonObjectIDs[ r->race ].push_back( r->id );
}
else {
racePersonObjectIDs[ MAX_RACE ].push_back( r->id );
}
}
}
for( int i=0; i<numLines; i++ ) {
delete [] lines[i];
}
delete [] lines;
}
}
delete [] txtFileName;
currentFile ++;
return (float)( currentFile ) / (float)( cache.numFiles );
}
static char makeNewObjectsSearchable = false;
void enableObjectSearch( char inEnable ) {
makeNewObjectsSearchable = inEnable;
}
void initObjectBankFinish() {
freeFolderCache( cache );
mapSize = maxID + 1;
idMap = new ObjectRecord*[ mapSize ];
for( int i=0; i<mapSize; i++ ) {
idMap[i] = NULL;
}
int numRecords = records.size();
for( int i=0; i<numRecords; i++ ) {
ObjectRecord *r = records.getElementDirect(i);
idMap[ r->id ] = r;
if( makeNewObjectsSearchable ) {
char *lowercase = stringToLowerCase( r->description );
tree.insert( lowercase, r );
delete [] lowercase;
}
}
rebuildRaceList();
printf( "Loaded %d objects from objects folder\n", numRecords );
if( autoGenerateUsedObjects ) {
int numAutoGenerated = 0;
char oldSearch = makeNewObjectsSearchable;
// don't need to be able to search for dummy objs
makeNewObjectsSearchable = false;
for( int i=0; i<mapSize; i++ ) {
if( idMap[i] != NULL ) {
ObjectRecord *o = idMap[i];
if( o->numUses > 1 ) {
int mainID = o->id;
int numUses = o->numUses;
int numDummyObj = numUses - 1;
o->useDummyIDs = new int[ numDummyObj ];
for( int s=0; s<o->numSprites; s++ ) {
if( o->spriteUseAppear[s] ) {
// hide all appearing sprites in parent object
o->spriteSkipDrawing[s] = true;
}
}
for( int d=1; d<=numDummyObj; d++ ) {
numAutoGenerated ++;
char *desc = autoSprintf( "%s# use %d",
o->description,
d );
int dummyID = reAddObject( o, desc, true );
delete [] desc;
o->useDummyIDs[ d - 1 ] = dummyID;
ObjectRecord *dummyO = getObject( dummyID );
// only main object has uses
// dummies set to 0 so we don't recursively make
// more dummies out of them
dummyO->numUses = 0;
// used objects never occur naturally
dummyO->mapChance = 0;
dummyO->isUseDummy = true;
dummyO->useDummyParent = mainID;
if( o->creationSoundInitialOnly ) {
clearSoundUsage( &( dummyO->creationSound ) );
}
setupSpriteUseVis( o, d, dummyO->spriteSkipDrawing );
// copy anims too
for( int t=0; t<endAnimType; t++ ) {
AnimationRecord *a = getAnimation( mainID,
(AnimType)t );
if( a != NULL ) {
// feels more risky, but way faster
// than copying it
// temporarily replace the object ID
// before adding this record
// it will be copied internally
a->objectID = dummyID;
addAnimation( a, true );
// restore original record
a->objectID = mainID;
}
}
}
}
}
}
makeNewObjectsSearchable = oldSearch;
printf( " Auto-generated %d 'used' objects\n", numAutoGenerated );
}
if( autoGenerateVariableObjects ) {
int numAutoGenerated = 0;
char oldSearch = makeNewObjectsSearchable;
// don't need to be able to search for dummy objs
makeNewObjectsSearchable = false;
for( int i=0; i<mapSize; i++ ) {
if( idMap[i] != NULL ) {
ObjectRecord *o = idMap[i];
char *dollarPos = strstr( o->description, "$" );
if( dollarPos != NULL ) {
int mainID = o->id;
char *afterDollarPos = &( dollarPos[1] );
int numVar = 0;
int numRead = sscanf( afterDollarPos, "%d", &numVar );
if( numRead != 1 || numVar < 2 ) {
continue;
}
o->numVariableDummyIDs = numVar;
o->variableDummyIDs = new int[ numVar ];
char *target = autoSprintf( "$%d", numVar );
for( int d=1; d<=numVar; d++ ) {
numAutoGenerated ++;
char *sub = autoSprintf( "%d", d );
char found;
char *desc = replaceOnce( o->description, target,
sub,
&found );
delete [] sub;
int dummyID = reAddObject( o, desc, true );
delete [] desc;
o->variableDummyIDs[ d - 1 ] = dummyID;
ObjectRecord *dummyO = getObject( dummyID );
dummyO->isVariableDummy = true;
// copy anims too
for( int t=0; t<endAnimType; t++ ) {
AnimationRecord *a = getAnimation( mainID,
(AnimType)t );
if( a != NULL ) {
// feels more risky, but way faster
// than copying it
// temporarily replace the object ID
// before adding this record
// it will be copied internally
a->objectID = dummyID;
addAnimation( a, true );
// restore original record
a->objectID = mainID;
}
}
}
delete [] target;
}
}
}
makeNewObjectsSearchable = oldSearch;
printf( " Auto-generated %d 'variable' objects\n", numAutoGenerated );
}
for( int i=0; i<=MAX_BIOME; i++ ) {
biomeHeatMap[ i ] = 0;
}
SimpleVector<int> biomes;
getAllBiomes( &biomes );
// heat files stored in objects folder
File groundHeatDir( NULL, "objects" );
if( groundHeatDir.exists() && groundHeatDir.isDirectory() ) {
for( int i=0; i<biomes.size(); i++ ) {
int b = biomes.getElementDirect( i );
float heat = 0;
char *heatFileName = autoSprintf( "groundHeat_%d.txt", b );
File *heatFile = groundHeatDir.getChildFile( heatFileName );
if( heatFile->exists() && ! heatFile->isDirectory() ) {
char *cont = heatFile->readFileContents();
if( cont != NULL ) {
sscanf( cont, "%f", &heat );
delete [] cont;
}
}
delete heatFile;
delete [] heatFileName;
if( b <= MAX_BIOME ) {
biomeHeatMap[ b ] = heat;
}
}
}
// resaveAll();
}
float getBiomeHeatValue( int inBiome ) {
if( inBiome >= 0 && inBiome <= MAX_BIOME ) {
return biomeHeatMap[ inBiome ];
}
return 0;
}
// working vectors for this setup function
// don't re-compute these if we're repeating operation on same objectID
// (which we do when we compute use dummy objects at startup)
static int lastSetupObject = -1;
static int numVanishingSprites = 0;
static int numAppearingSprites = 0;
static SimpleVector<int> vanishingIndices;
static SimpleVector<int> appearingIndices;
void setupSpriteUseVis( ObjectRecord *inObject, int inUsesRemaining,
char *inSpriteSkipDrawing ) {
memset( inSpriteSkipDrawing, false, inObject->numSprites );
if( inObject->numUses == inUsesRemaining ) {
for( int s=0; s<inObject->numSprites; s++ ) {
if( inObject->spriteUseAppear[s] ) {
// hide all appearing sprites
inSpriteSkipDrawing[s] = true;
}
}
return;
}
else if( inUsesRemaining == 0 ) {
for( int s=0; s<inObject->numSprites; s++ ) {
if( inObject->spriteUseVanish[s] ) {
// hide all vanishing sprites
inSpriteSkipDrawing[s] = true;
}
}
}
else {
// generate vis for one of the use dummy objects
int numUses = inObject->numUses;
if( inObject->id != lastSetupObject ) {
numVanishingSprites = 0;
numAppearingSprites = 0;
vanishingIndices.deleteAll();
appearingIndices.deleteAll();
for( int s=0; s<inObject->numSprites; s++ ) {
if( inObject->spriteUseVanish[s] ) {
numVanishingSprites ++;
vanishingIndices.push_back( s );
}
}
for( int s=0; s<inObject->numSprites; s++ ) {
if( inObject->spriteUseAppear[s] ) {
numAppearingSprites ++;
appearingIndices.push_back( s );
// hide all appearing sprites as basis
inSpriteSkipDrawing[s] = true;
}
}
lastSetupObject = inObject->id;
}
else {
for( int i=0; i<numAppearingSprites; i++ ) {
// hide all appearing sprites as basis
inSpriteSkipDrawing[ appearingIndices.getElementDirect(i) ] =
true;
}
}
int d = inUsesRemaining;
// hide some sprites
int numSpritesLeft =
( d * (numVanishingSprites) ) / numUses;
int numInLastDummy = numVanishingSprites / numUses;
if( numInLastDummy == 0 ) {
// add 1 to everything to pad up, so last
// dummy has 1 sprite in it
numSpritesLeft += 1;
}
if( numSpritesLeft > numVanishingSprites ) {
numSpritesLeft = numVanishingSprites;
}
for( int v=numSpritesLeft; v<numVanishingSprites; v++ ) {
inSpriteSkipDrawing[ vanishingIndices.getElementDirect( v ) ] =
true;
}
// now handle appearing sprites
int numInvisSpritesLeft =
lrint( ( d * (numAppearingSprites) ) / (double)numUses );
/*
// testing... do we need to do this?
int numInvisInLastDummy = numAppearingSprites / numUses;
if( numInLastDummy == 0 ) {
// add 1 to everything to pad up, so last
// dummy has 1 sprite in it
numSpritesLeft += 1;
}
*/
if( numInvisSpritesLeft > numAppearingSprites ) {
numInvisSpritesLeft = numAppearingSprites;
}
for( int v=0; v<numAppearingSprites - numInvisSpritesLeft; v++ ) {
inSpriteSkipDrawing[ appearingIndices.getElementDirect( v ) ] =
false;
}
}
}
static void freeObjectRecord( int inID ) {
if( inID < mapSize ) {
if( idMap[inID] != NULL ) {
char *lower = stringToLowerCase( idMap[inID]->description );
tree.remove( lower, idMap[inID] );
delete [] lower;
int race = idMap[inID]->race;
delete [] idMap[inID]->description;
delete [] idMap[inID]->biomes;
delete [] idMap[inID]->slotPos;
delete [] idMap[inID]->slotVert;
delete [] idMap[inID]->slotParent;
delete [] idMap[inID]->sprites;
delete [] idMap[inID]->spritePos;
delete [] idMap[inID]->spriteRot;
delete [] idMap[inID]->spriteHFlip;
delete [] idMap[inID]->spriteColor;
delete [] idMap[inID]->spriteAgeStart;
delete [] idMap[inID]->spriteAgeEnd;
delete [] idMap[inID]->spriteParent;
delete [] idMap[inID]->spriteInvisibleWhenHolding;
delete [] idMap[inID]->spriteInvisibleWhenWorn;
delete [] idMap[inID]->spriteBehindSlots;
delete [] idMap[inID]->spriteIsHead;
delete [] idMap[inID]->spriteIsBody;
delete [] idMap[inID]->spriteIsBackFoot;
delete [] idMap[inID]->spriteIsFrontFoot;
delete [] idMap[inID]->spriteUseVanish;
delete [] idMap[inID]->spriteUseAppear;
if( idMap[inID]->useDummyIDs != NULL ) {
delete [] idMap[inID]->useDummyIDs;
}
if( idMap[inID]->variableDummyIDs != NULL ) {
delete [] idMap[inID]->variableDummyIDs;
}
delete [] idMap[inID]->spriteSkipDrawing;
clearSoundUsage( &( idMap[inID]->creationSound ) );
clearSoundUsage( &( idMap[inID]->usingSound ) );
clearSoundUsage( &( idMap[inID]->eatingSound ) );
clearSoundUsage( &( idMap[inID]->decaySound ) );
delete idMap[inID];
idMap[inID] = NULL;
personObjectIDs.deleteElementEqualTo( inID );
femalePersonObjectIDs.deleteElementEqualTo( inID );
monumentCallObjectIDs.deleteElementEqualTo( inID );
deathMarkerObjectIDs.deleteElementEqualTo( inID );
if( race <= MAX_RACE ) {
racePersonObjectIDs[ race ].deleteElementEqualTo( inID );
}
else {
racePersonObjectIDs[ MAX_RACE ].deleteElementEqualTo( inID );
}
rebuildRaceList();
}
}
}
void freeObjectBank() {
for( int i=0; i<mapSize; i++ ) {
if( idMap[i] != NULL ) {
delete [] idMap[i]->slotPos;
delete [] idMap[i]->slotVert;
delete [] idMap[i]->slotParent;
delete [] idMap[i]->description;
delete [] idMap[i]->biomes;
delete [] idMap[i]->sprites;
delete [] idMap[i]->spritePos;
delete [] idMap[i]->spriteRot;
delete [] idMap[i]->spriteHFlip;
delete [] idMap[i]->spriteColor;
delete [] idMap[i]->spriteAgeStart;
delete [] idMap[i]->spriteAgeEnd;
delete [] idMap[i]->spriteParent;
delete [] idMap[i]->spriteInvisibleWhenHolding;
delete [] idMap[i]->spriteInvisibleWhenWorn;
delete [] idMap[i]->spriteBehindSlots;
delete [] idMap[i]->spriteIsHead;
delete [] idMap[i]->spriteIsBody;
delete [] idMap[i]->spriteIsBackFoot;
delete [] idMap[i]->spriteIsFrontFoot;
delete [] idMap[i]->spriteUseVanish;
delete [] idMap[i]->spriteUseAppear;
if( idMap[i]->useDummyIDs != NULL ) {
delete [] idMap[i]->useDummyIDs;
}
if( idMap[i]->variableDummyIDs != NULL ) {
delete [] idMap[i]->variableDummyIDs;
}
delete [] idMap[i]->spriteSkipDrawing;
//printf( "\n\nClearing sound usage for id %d\n", i );
clearSoundUsage( &( idMap[i]->creationSound ) );
clearSoundUsage( &( idMap[i]->usingSound ) );
clearSoundUsage( &( idMap[i]->eatingSound ) );
clearSoundUsage( &( idMap[i]->decaySound ) );
delete idMap[i];
}
}
delete [] idMap;
personObjectIDs.deleteAll();
femalePersonObjectIDs.deleteAll();
monumentCallObjectIDs.deleteAll();
deathMarkerObjectIDs.deleteAll();
for( int i=0; i<= MAX_RACE; i++ ) {
racePersonObjectIDs[i].deleteAll();
}
rebuildRaceList();
}
int reAddObject( ObjectRecord *inObject,
char *inNewDescription,
char inNoWriteToFile, int inReplaceID ) {
const char *desc = inObject->description;
if( inNewDescription != NULL ) {
desc = inNewDescription;
}
char *biomeString = getBiomesString( inObject );
int id = addObject( desc,
inObject->containable,
inObject->containSize,
inObject->vertContainRotationOffset,
inObject->permanent,
inObject->minPickupAge,
inObject->heldInHand,
inObject->rideable,
inObject->blocksWalking,
inObject->leftBlockingRadius,
inObject->rightBlockingRadius,
inObject->drawBehindPlayer,
biomeString,
inObject->mapChance,
inObject->heatValue,
inObject->rValue,
inObject->person,
inObject->personNoSpawn,
inObject->male,
inObject->race,
inObject->deathMarker,
inObject->homeMarker,
inObject->floor,
inObject->floorHugging,
inObject->foodValue,
inObject->speedMult,
inObject->heldOffset,
inObject->clothing,
inObject->clothingOffset,
inObject->deadlyDistance,
inObject->useDistance,
inObject->creationSound,
inObject->usingSound,
inObject->eatingSound,
inObject->decaySound,
inObject->creationSoundInitialOnly,
inObject->numSlots,
inObject->slotSize,
inObject->slotPos,
inObject->slotVert,
inObject->slotParent,
inObject->slotTimeStretch,
inObject->numSprites,
inObject->sprites,
inObject->spritePos,
inObject->spriteRot,
inObject->spriteHFlip,
inObject->spriteColor,
inObject->spriteAgeStart,
inObject->spriteAgeEnd,
inObject->spriteParent,
inObject->spriteInvisibleWhenHolding,
inObject->spriteInvisibleWhenWorn,
inObject->spriteBehindSlots,
inObject->spriteIsHead,
inObject->spriteIsBody,
inObject->spriteIsBackFoot,
inObject->spriteIsFrontFoot,
inObject->numUses,
inObject->useChance,
inObject->spriteUseVanish,
inObject->spriteUseAppear,
inNoWriteToFile,
inReplaceID );
delete [] biomeString;
return id;
}
void resaveAll() {
printf( "Starting to resave all objects\n..." );
for( int i=0; i<mapSize; i++ ) {
if( idMap[i] != NULL ) {
ObjectRecord *o = idMap[i];
char anyNotLoaded = true;
while( anyNotLoaded ) {
anyNotLoaded = false;
for( int s=0; s< o->numSprites; s++ ) {
char loaded = markSpriteLive( o->sprites[s] );
if( ! loaded ) {
anyNotLoaded = true;
}
}
stepSpriteBank();
}
reAddObject( idMap[i], NULL, false, i );
}
}
printf( "...done with resave\n" );
}
ObjectRecord *getObject( int inID ) {
if( inID < mapSize ) {
if( idMap[inID] != NULL ) {
return idMap[inID];
}
}
return NULL;
}
int getNumContainerSlots( int inID ) {
ObjectRecord *r = getObject( inID );
if( r == NULL ) {
return 0;
}
else {
return r->numSlots;
}
}
char isContainable( int inID ) {
ObjectRecord *r = getObject( inID );
if( r == NULL ) {
return false;
}
else {
return r->containable;
}
}
char isApocalypseTrigger( int inID ) {
ObjectRecord *r = getObject( inID );
if( r == NULL ) {
return false;
}
else {
return r->apocalypseTrigger;
}
}
int getMonumentStatus( int inID ) {
ObjectRecord *r = getObject( inID );
if( r == NULL ) {
return 0;
}
else {
if( r->monumentStep ) {
return 1;
}
if( r->monumentDone ) {
return 2;
}
if( r->monumentCall ) {
return 3;
}
return 0;
}
}
SimpleVector<int> *getMonumentCallObjects() {
return &monumentCallObjectIDs;
}
// return array destroyed by caller, NULL if none found
ObjectRecord **searchObjects( const char *inSearch,
int inNumToSkip,
int inNumToGet,
int *outNumResults, int *outNumRemaining ) {
if( strcmp( inSearch, "" ) == 0 ) {
// special case, show objects in reverse-id order, newest first
SimpleVector< ObjectRecord *> results;
int numSkipped = 0;
int id = mapSize - 1;
while( id > 0 && numSkipped < inNumToSkip ) {
if( idMap[id] != NULL ) {
numSkipped++;
}
id--;
}
int numGotten = 0;
while( id > 0 && numGotten < inNumToGet ) {
if( idMap[id] != NULL ) {
results.push_back( idMap[id] );
numGotten++;
}
id--;
}
// rough estimate
*outNumRemaining = id;
if( *outNumRemaining < 100 ) {
// close enough to end, actually compute it
*outNumRemaining = 0;
while( id > 0 ) {
if( idMap[id] != NULL ) {
*outNumRemaining = *outNumRemaining + 1;
}
id--;
}
}
*outNumResults = results.size();
return results.getElementArray();
}
char *lowerSearch = stringToLowerCase( inSearch );
int numTotalMatches = tree.countMatches( lowerSearch );
int numAfterSkip = numTotalMatches - inNumToSkip;
if( numAfterSkip < 0 ) {
numAfterSkip = 0;
}
int numToGet = inNumToGet;
if( numToGet > numAfterSkip ) {
numToGet = numAfterSkip;
}
*outNumRemaining = numAfterSkip - numToGet;
ObjectRecord **results = new ObjectRecord*[ numToGet ];
*outNumResults =
tree.getMatches( lowerSearch, inNumToSkip, numToGet, (void**)results );
delete [] lowerSearch;
return results;
}
int addObject( const char *inDescription,
char inContainable,
float inContainSize,
double inVertContainRotationOffset,
char inPermanent,
int inMinPickupAge,
char inHeldInHand,
char inRideable,
char inBlocksWalking,
int inLeftBlockingRadius, int inRightBlockingRadius,
char inDrawBehindPlayer,
char *inBiomes,
float inMapChance,
int inHeatValue,
float inRValue,
char inPerson,
char inPersonNoSpawn,
char inMale,
int inRace,
char inDeathMarker,
char inHomeMarker,
char inFloor,
char inFloorHugging,
int inFoodValue,
float inSpeedMult,
doublePair inHeldOffset,
char inClothing,
doublePair inClothingOffset,
int inDeadlyDistance,
int inUseDistance,
SoundUsage inCreationSound,
SoundUsage inUsingSound,
SoundUsage inEatingSound,
SoundUsage inDecaySound,
char inCreationSoundInitialOnly,
int inNumSlots, float inSlotSize, doublePair *inSlotPos,
char *inSlotVert,
int *inSlotParent,
float inSlotTimeStretch,
int inNumSprites, int *inSprites,
doublePair *inSpritePos,
double *inSpriteRot,
char *inSpriteHFlip,
FloatRGB *inSpriteColor,
double *inSpriteAgeStart,
double *inSpriteAgeEnd,
int *inSpriteParent,
char *inSpriteInvisibleWhenHolding,
int *inSpriteInvisibleWhenWorn,
char *inSpriteBehindSlots,
char *inSpriteIsHead,
char *inSpriteIsBody,
char *inSpriteIsBackFoot,
char *inSpriteIsFrontFoot,
int inNumUses,
float inUseChance,
char *inSpriteUseVanish,
char *inSpriteUseAppear,
char inNoWriteToFile,
int inReplaceID ) {
if( inSlotTimeStretch < 0.0001 ) {
inSlotTimeStretch = 0.0001;
}
int newID = inReplaceID;
int newHeight = recomputeObjectHeight( inNumSprites,
inSprites, inSpritePos );
// add it to file structure
File objectsDir( NULL, "objects" );
if( ! inNoWriteToFile && !objectsDir.exists() ) {
objectsDir.makeDirectory();
}
int nextObjectNumber = 1;
if( objectsDir.exists() && objectsDir.isDirectory() ) {
File *nextNumberFile =
objectsDir.getChildFile( "nextObjectNumber.txt" );
if( nextNumberFile->exists() ) {
char *nextNumberString =
nextNumberFile->readFileContents();
if( nextNumberString != NULL ) {
sscanf( nextNumberString, "%d", &nextObjectNumber );
delete [] nextNumberString;
}
}
if( newID == -1 ) {
newID = nextObjectNumber;
if( newID < maxID + 1 ) {
newID = maxID + 1;
}
}
delete nextNumberFile;
}
if( ! inNoWriteToFile &&
objectsDir.exists() && objectsDir.isDirectory() ) {
char *fileName = autoSprintf( "%d.txt", newID );
File *objectFile = objectsDir.getChildFile( fileName );
SimpleVector<char*> lines;
lines.push_back( autoSprintf( "id=%d", newID ) );
lines.push_back( stringDuplicate( inDescription ) );
lines.push_back( autoSprintf( "containable=%d", (int)inContainable ) );
lines.push_back( autoSprintf( "containSize=%f,vertSlotRot=%f",
inContainSize,
inVertContainRotationOffset ) );
lines.push_back( autoSprintf( "permanent=%d,minPickupAge=%d",
(int)inPermanent,
inMinPickupAge ) );
int heldInHandNumber = 0;
if( inHeldInHand ) {
heldInHandNumber = 1;
}
if( inRideable ) {
// override
heldInHandNumber = 2;
}
lines.push_back( autoSprintf( "heldInHand=%d", heldInHandNumber ) );
lines.push_back( autoSprintf(
"blocksWalking=%d,"
"leftBlockingRadius=%d,"
"rightBlockingRadius=%d,"
"drawBehindPlayer=%d",
(int)inBlocksWalking,
inLeftBlockingRadius,
inRightBlockingRadius,
(int)inDrawBehindPlayer ) );
lines.push_back( autoSprintf( "mapChance=%f#biomes_%s",
inMapChance, inBiomes ) );
lines.push_back( autoSprintf( "heatValue=%d", inHeatValue ) );
lines.push_back( autoSprintf( "rValue=%f", inRValue ) );
int personNumber = 0;
if( inPerson ) {
personNumber = inRace;
}
lines.push_back( autoSprintf( "person=%d,noSpawn=%d", personNumber,
(int)inPersonNoSpawn ) );
lines.push_back( autoSprintf( "male=%d", (int)inMale ) );
lines.push_back( autoSprintf( "deathMarker=%d", (int)inDeathMarker ) );
lines.push_back( autoSprintf( "homeMarker=%d", (int)inHomeMarker ) );
lines.push_back( autoSprintf( "floor=%d", (int)inFloor ) );
lines.push_back( autoSprintf( "floorHugging=%d",
(int)inFloorHugging ) );
lines.push_back( autoSprintf( "foodValue=%d", inFoodValue ) );
lines.push_back( autoSprintf( "speedMult=%f", inSpeedMult ) );
lines.push_back( autoSprintf( "heldOffset=%f,%f",
inHeldOffset.x, inHeldOffset.y ) );
lines.push_back( autoSprintf( "clothing=%c", inClothing ) );
lines.push_back( autoSprintf( "clothingOffset=%f,%f",
inClothingOffset.x,
inClothingOffset.y ) );
lines.push_back( autoSprintf( "deadlyDistance=%d",
inDeadlyDistance ) );
lines.push_back( autoSprintf( "useDistance=%d",
inUseDistance ) );
char *usageStrings[4] =
{ stringDuplicate( printSoundUsage( inCreationSound ) ),
stringDuplicate( printSoundUsage( inUsingSound ) ),
stringDuplicate( printSoundUsage( inEatingSound ) ),
stringDuplicate( printSoundUsage( inDecaySound ) ) };
lines.push_back( autoSprintf( "sounds=%s,%s,%s,%s",
usageStrings[0],
usageStrings[1],
usageStrings[2],
usageStrings[3] ) );
for( int i=0; i<4; i++ ) {
delete [] usageStrings[i];
}
lines.push_back( autoSprintf( "creationSoundInitialOnly=%d",
(int)inCreationSoundInitialOnly ) );
lines.push_back( autoSprintf( "numSlots=%d#timeStretch=%f",
inNumSlots, inSlotTimeStretch ) );
lines.push_back( autoSprintf( "slotSize=%f", inSlotSize ) );
for( int i=0; i<inNumSlots; i++ ) {
lines.push_back( autoSprintf( "slotPos=%f,%f,vert=%d,parent=%d",
inSlotPos[i].x,
inSlotPos[i].y,
(int)( inSlotVert[i] ),
inSlotParent[i] ) );
}
lines.push_back( autoSprintf( "numSprites=%d", inNumSprites ) );
for( int i=0; i<inNumSprites; i++ ) {
lines.push_back( autoSprintf( "spriteID=%d", inSprites[i] ) );
lines.push_back( autoSprintf( "pos=%f,%f",
inSpritePos[i].x,
inSpritePos[i].y ) );
lines.push_back( autoSprintf( "rot=%f",
inSpriteRot[i] ) );
lines.push_back( autoSprintf( "hFlip=%d",
inSpriteHFlip[i] ) );
lines.push_back( autoSprintf( "color=%f,%f,%f",
inSpriteColor[i].r,
inSpriteColor[i].g,
inSpriteColor[i].b ) );
lines.push_back( autoSprintf( "ageRange=%f,%f",
inSpriteAgeStart[i],
inSpriteAgeEnd[i] ) );
lines.push_back( autoSprintf( "parent=%d",
inSpriteParent[i] ) );
lines.push_back( autoSprintf( "invisHolding=%d,invisWorn=%d,"
"behindSlots=%d",
inSpriteInvisibleWhenHolding[i],
inSpriteInvisibleWhenWorn[i],
inSpriteBehindSlots[i] ) );
}
// FIXME
lines.push_back(
boolArrayToSparseCommaString( "headIndex",
inSpriteIsHead, inNumSprites ) );
lines.push_back(
boolArrayToSparseCommaString( "bodyIndex",
inSpriteIsBody, inNumSprites ) );
lines.push_back(
boolArrayToSparseCommaString( "backFootIndex",
inSpriteIsBackFoot, inNumSprites ) );
lines.push_back(
boolArrayToSparseCommaString( "frontFootIndex",
inSpriteIsFrontFoot,
inNumSprites ) );
lines.push_back( autoSprintf( "numUses=%d,%f",
inNumUses, inUseChance ) );
lines.push_back(
boolArrayToSparseCommaString( "useVanishIndex",
inSpriteUseVanish,
inNumSprites ) );
lines.push_back(
boolArrayToSparseCommaString( "useAppearIndex",
inSpriteUseAppear,
inNumSprites ) );
lines.push_back( autoSprintf( "pixHeight=%d",
newHeight ) );
char **linesArray = lines.getElementArray();
char *contents = join( linesArray, lines.size(), "\n" );
delete [] linesArray;
lines.deallocateStringElements();
File *cacheFile = objectsDir.getChildFile( "cache.fcz" );
cacheFile->remove();
delete cacheFile;
objectFile->writeToFile( contents );
delete [] contents;
delete [] fileName;
delete objectFile;
if( inReplaceID == -1 ) {
nextObjectNumber++;
}
char *nextNumberString = autoSprintf( "%d", nextObjectNumber );
File *nextNumberFile =
objectsDir.getChildFile( "nextObjectNumber.txt" );
nextNumberFile->writeToFile( nextNumberString );
delete [] nextNumberString;
delete nextNumberFile;
}
if( newID == -1 && ! inNoWriteToFile ) {
// failed to save it to disk
return -1;
}
if( newID == -1 ) {
newID = maxID + 1;
}
// now add it to live, in memory database
if( newID >= mapSize ) {
// expand map
int newMapSize = newID + 1;
ObjectRecord **newMap = new ObjectRecord*[newMapSize];
for( int i=mapSize; i<newMapSize; i++ ) {
newMap[i] = NULL;
}
memcpy( newMap, idMap, sizeof(ObjectRecord*) * mapSize );
delete [] idMap;
idMap = newMap;
mapSize = newMapSize;
}
if( newID > maxID ) {
maxID = newID;
}
ObjectRecord *r = new ObjectRecord;
r->id = newID;
r->description = stringDuplicate( inDescription );
r->containable = inContainable;
r->containSize = inContainSize;
r->vertContainRotationOffset = inVertContainRotationOffset;
r->permanent = inPermanent;
r->minPickupAge = inMinPickupAge;
r->heldInHand = inHeldInHand;
r->rideable = inRideable;
if( r->heldInHand && r->rideable ) {
r->heldInHand = false;
}
r->blocksWalking = inBlocksWalking;
r->leftBlockingRadius = inLeftBlockingRadius;
r->rightBlockingRadius = inRightBlockingRadius;
r->drawBehindPlayer = inDrawBehindPlayer;
r->wide = ( r->leftBlockingRadius > 0 || r->rightBlockingRadius > 0 );
if( r->wide ) {
r->drawBehindPlayer = true;
if( r->leftBlockingRadius > maxWideRadius ) {
maxWideRadius = r->leftBlockingRadius;
}
if( r->rightBlockingRadius > maxWideRadius ) {
maxWideRadius = r->rightBlockingRadius;
}
}
fillObjectBiomeFromString( r, inBiomes );
r->mapChance = inMapChance;
r->heatValue = inHeatValue;
r->rValue = inRValue;
r->person = inPerson;
r->personNoSpawn = inPersonNoSpawn;
r->race = inRace;
r->male = inMale;
r->deathMarker = inDeathMarker;
deathMarkerObjectIDs.deleteElementEqualTo( newID );
if( r->deathMarker ) {
deathMarkerObjectIDs.push_back( newID );
}
r->homeMarker = inHomeMarker;
r->floor = inFloor;
r->floorHugging = inFloorHugging;
r->foodValue = inFoodValue;
r->speedMult = inSpeedMult;
r->heldOffset = inHeldOffset;
r->clothing = inClothing;
r->clothingOffset = inClothingOffset;
r->deadlyDistance = inDeadlyDistance;
r->useDistance = inUseDistance;
r->creationSound = copyUsage( inCreationSound );
r->usingSound = copyUsage( inUsingSound );
r->eatingSound = copyUsage( inEatingSound );
r->decaySound = copyUsage( inDecaySound );
r->creationSoundInitialOnly = inCreationSoundInitialOnly;
r->numSlots = inNumSlots;
r->slotSize = inSlotSize;
r->slotPos = new doublePair[ inNumSlots ];
r->slotVert = new char[ inNumSlots ];
r->slotParent = new int[ inNumSlots ];
memcpy( r->slotPos, inSlotPos, inNumSlots * sizeof( doublePair ) );
memcpy( r->slotVert, inSlotVert, inNumSlots * sizeof( char ) );
memcpy( r->slotParent, inSlotParent, inNumSlots * sizeof( int ) );
r->slotTimeStretch = inSlotTimeStretch;
r->numSprites = inNumSprites;
r->sprites = new int[ inNumSprites ];
r->spritePos = new doublePair[ inNumSprites ];
r->spriteRot = new double[ inNumSprites ];
r->spriteHFlip = new char[ inNumSprites ];
r->spriteColor = new FloatRGB[ inNumSprites ];
r->spriteAgeStart = new double[ inNumSprites ];
r->spriteAgeEnd = new double[ inNumSprites ];
r->spriteParent = new int[ inNumSprites ];
r->spriteInvisibleWhenHolding = new char[ inNumSprites ];
r->spriteInvisibleWhenWorn = new int[ inNumSprites ];
r->spriteBehindSlots = new char[ inNumSprites ];
r->spriteIsHead = new char[ inNumSprites ];
r->spriteIsBody = new char[ inNumSprites ];
r->spriteIsBackFoot = new char[ inNumSprites ];
r->spriteIsFrontFoot = new char[ inNumSprites ];
r->numUses = inNumUses;
r->useChance = inUseChance;
r->spriteUseVanish = new char[ inNumSprites ];
r->spriteUseAppear = new char[ inNumSprites ];
r->useDummyIDs = NULL;
r->isUseDummy = false;
r->useDummyParent = 0;
r->cachedHeight = newHeight;
r->spriteSkipDrawing = new char[ inNumSprites ];
r->apocalypseTrigger = false;
if( r->description[0] == 'T' &&
r->description[1] == 'h' &&
strstr( r->description, "The Apocalypse" ) == r->description ) {
printf( "Object id %d (%s) seen as an apocalypse trigger\n",
r->id, r->description );
r->apocalypseTrigger = true;
}
r->monumentStep = false;
r->monumentDone = false;
r->monumentCall = false;
monumentCallObjectIDs.deleteElementEqualTo( newID );
if( strstr( r->description, "monument" ) != NULL ) {
// some kind of monument state
if( strstr( r->description, "monumentStep" ) != NULL ) {
r->monumentStep = true;
}
else if( strstr( r->description,
"monumentDone" ) != NULL ) {
r->monumentDone = true;
}
else if( strstr( r->description,
"monumentCall" ) != NULL ) {
r->monumentCall = true;
monumentCallObjectIDs.push_back( newID );
}
}
r->numVariableDummyIDs = 0;
r->variableDummyIDs = NULL;
r->isVariableDummy = false;
memset( r->spriteSkipDrawing, false, inNumSprites );
memcpy( r->sprites, inSprites, inNumSprites * sizeof( int ) );
memcpy( r->spritePos, inSpritePos, inNumSprites * sizeof( doublePair ) );
memcpy( r->spriteRot, inSpriteRot, inNumSprites * sizeof( double ) );
memcpy( r->spriteHFlip, inSpriteHFlip, inNumSprites * sizeof( char ) );
memcpy( r->spriteColor, inSpriteColor, inNumSprites * sizeof( FloatRGB ) );
memcpy( r->spriteAgeStart, inSpriteAgeStart,
inNumSprites * sizeof( double ) );
memcpy( r->spriteAgeEnd, inSpriteAgeEnd,
inNumSprites * sizeof( double ) );
memcpy( r->spriteParent, inSpriteParent,
inNumSprites * sizeof( int ) );
memcpy( r->spriteInvisibleWhenHolding, inSpriteInvisibleWhenHolding,
inNumSprites * sizeof( char ) );
memcpy( r->spriteInvisibleWhenWorn, inSpriteInvisibleWhenWorn,
inNumSprites * sizeof( int ) );
memcpy( r->spriteBehindSlots, inSpriteBehindSlots,
inNumSprites * sizeof( char ) );
memcpy( r->spriteIsHead, inSpriteIsHead,
inNumSprites * sizeof( char ) );
memcpy( r->spriteIsBody, inSpriteIsBody,
inNumSprites * sizeof( char ) );
memcpy( r->spriteIsBackFoot, inSpriteIsBackFoot,
inNumSprites * sizeof( char ) );
memcpy( r->spriteIsFrontFoot, inSpriteIsFrontFoot,
inNumSprites * sizeof( char ) );
memcpy( r->spriteUseVanish, inSpriteUseVanish,
inNumSprites * sizeof( char ) );
memcpy( r->spriteUseAppear, inSpriteUseAppear,
inNumSprites * sizeof( char ) );
// delete old
// grab this before freeing, in case inDescription is the same as
// idMap[newID].description
char *lower = stringToLowerCase( inDescription );
ObjectRecord *oldRecord = getObject( newID );
SimpleVector<int> oldSoundIDs;
if( oldRecord != NULL ) {
for( int i=0; i<oldRecord->creationSound.numSubSounds; i++ ) {
oldSoundIDs.push_back( oldRecord->creationSound.ids[i] );
}
for( int i=0; i<oldRecord->usingSound.numSubSounds; i++ ) {
oldSoundIDs.push_back( oldRecord->usingSound.ids[i] );
}
for( int i=0; i<oldRecord->eatingSound.numSubSounds; i++ ) {
oldSoundIDs.push_back( oldRecord->eatingSound.ids[i] );
}
for( int i=0; i<oldRecord->decaySound.numSubSounds; i++ ) {
oldSoundIDs.push_back( oldRecord->decaySound.ids[i] );
}
}
freeObjectRecord( newID );
idMap[newID] = r;
if( makeNewObjectsSearchable ) {
tree.insert( lower, idMap[newID] );
}
delete [] lower;
personObjectIDs.deleteElementEqualTo( newID );
femalePersonObjectIDs.deleteElementEqualTo( newID );
for( int i=0; i<=MAX_RACE; i++ ) {
racePersonObjectIDs[ i ].deleteElementEqualTo( newID );
}
if( r->person && ! r->personNoSpawn ) {
personObjectIDs.push_back( newID );
if( ! r->male ) {
femalePersonObjectIDs.push_back( newID );
}
if( r->race <= MAX_RACE ) {
racePersonObjectIDs[ r->race ].push_back( r->id );
}
else {
racePersonObjectIDs[ MAX_RACE ].push_back( r->id );
}
rebuildRaceList();
}
// check if sounds still used (prevent orphan sounds)
for( int i=0; i<oldSoundIDs.size(); i++ ) {
checkIfSoundStillNeeded( oldSoundIDs.getElementDirect( i ) );
}
return newID;
}
static char logicalXOR( char inA, char inB ) {
return !inA != !inB;
}
static int objectLayerCutoff = -1;
void setObjectDrawLayerCutoff( int inCutoff ) {
objectLayerCutoff = inCutoff;
}
HoldingPos drawObject( ObjectRecord *inObject, int inDrawBehindSlots,
doublePair inPos,
double inRot, char inWorn, char inFlipH, double inAge,
int inHideClosestArm,
char inHideAllLimbs,
char inHeldNotInPlaceYet,
ClothingSet inClothing,
double inScale ) {
HoldingPos returnHoldingPos = { false, {0, 0}, 0 };
SimpleVector <int> frontArmIndices;
getFrontArmIndices( inObject, inAge, &frontArmIndices );
SimpleVector <int> backArmIndices;
getBackArmIndices( inObject, inAge, &backArmIndices );
SimpleVector <int> legIndices;
getAllLegIndices( inObject, inAge, &legIndices );
int headIndex = getHeadIndex( inObject, inAge );
int bodyIndex = getBodyIndex( inObject, inAge );
int backFootIndex = getBackFootIndex( inObject, inAge );
int frontFootIndex = getFrontFootIndex( inObject, inAge );
int topBackArmIndex = -1;
if( backArmIndices.size() > 0 ) {
topBackArmIndex =
backArmIndices.getElementDirect( backArmIndices.size() - 1 );
}
int backHandIndex = getBackHandIndex( inObject, inAge );
doublePair headPos = inObject->spritePos[ headIndex ];
doublePair frontFootPos = inObject->spritePos[ frontFootIndex ];
doublePair bodyPos = inObject->spritePos[ bodyIndex ];
doublePair animHeadPos = headPos;
doublePair tunicPos = { 0, 0 };
double tunicRot = 0;
doublePair bottomPos = { 0, 0 };
double bottomRot = 0;
doublePair backpackPos = { 0, 0 };
double backpackRot = 0;
doublePair backShoePos = { 0, 0 };
double backShoeRot = 0;
doublePair frontShoePos = { 0, 0 };
double frontShoeRot = 0;
int limit = inObject->numSprites;
if( objectLayerCutoff > -1 && objectLayerCutoff < limit ) {
limit = objectLayerCutoff;
}
objectLayerCutoff = -1;
for( int i=0; i<limit; i++ ) {
if( inObject->spriteSkipDrawing != NULL &&
inObject->spriteSkipDrawing[i] ) {
continue;
}
if( inObject->person &&
! isSpriteVisibleAtAge( inObject, i, inAge ) ) {
// skip drawing this aging layer entirely
continue;
}
if( inObject->clothing != 'n' &&
inObject->spriteInvisibleWhenWorn[i] != 0 ) {
if( inWorn &&
inObject->spriteInvisibleWhenWorn[i] == 1 ) {
// skip invisible layer in worn clothing
continue;
}
else if( ! inWorn &&
inObject->spriteInvisibleWhenWorn[i] == 2 ) {
// skip invisible layer in unworn clothing
continue;
}
}
if( inDrawBehindSlots != 2 ) {
if( inDrawBehindSlots == 0 &&
! inObject->spriteBehindSlots[i] ) {
continue;
}
else if( inDrawBehindSlots == 1 &&
inObject->spriteBehindSlots[i] ) {
continue;
}
}
doublePair spritePos = inObject->spritePos[i];
if( inObject->person &&
( i == headIndex ||
checkSpriteAncestor( inObject, i,
headIndex ) ) ) {
spritePos = add( spritePos, getAgeHeadOffset( inAge, headPos,
bodyPos,
frontFootPos ) );
}
if( inObject->person &&
( i == headIndex ||
checkSpriteAncestor( inObject, i,
bodyIndex ) ) ) {
spritePos = add( spritePos, getAgeBodyOffset( inAge, bodyPos ) );
}
if( i == headIndex ) {
// this is the head
animHeadPos = spritePos;
}
if( inFlipH ) {
spritePos.x *= -1;
}
if( inRot != 0 ) {
spritePos = rotate( spritePos, -2 * M_PI * inRot );
}
spritePos = mult( spritePos, inScale );
doublePair pos = add( spritePos, inPos );
char skipSprite = false;
if( !inHeldNotInPlaceYet &&
inHideClosestArm == 1 &&
frontArmIndices.getElementIndex( i ) != -1 ) {
skipSprite = true;
}
else if( !inHeldNotInPlaceYet &&
inHideClosestArm == -1 &&
backArmIndices.getElementIndex( i ) != -1 ) {
skipSprite = true;
}
else if( !inHeldNotInPlaceYet &&
inHideAllLimbs ) {
if( frontArmIndices.getElementIndex( i ) != -1
||
backArmIndices.getElementIndex( i ) != -1
||
legIndices.getElementIndex( i ) != -1 ) {
skipSprite = true;
}
}
if( i == backFootIndex
&& inClothing.backShoe != NULL ) {
doublePair cPos = add( spritePos,
inClothing.backShoe->clothingOffset );
if( inFlipH ) {
cPos.x *= -1;
}
cPos = add( cPos, inPos );
backShoePos = cPos;
backShoeRot = inRot;
}
if( i == bodyIndex ) {
if( inClothing.tunic != NULL ) {
doublePair cPos = add( spritePos,
inClothing.tunic->clothingOffset );
if( inFlipH ) {
cPos.x *= -1;
}
cPos = add( cPos, inPos );
tunicPos = cPos;
tunicRot = inRot;
}
if( inClothing.bottom != NULL ) {
doublePair cPos = add( spritePos,
inClothing.bottom->clothingOffset );
if( inFlipH ) {
cPos.x *= -1;
}
cPos = add( cPos, inPos );
bottomPos = cPos;
bottomRot = inRot;
}
if( inClothing.backpack != NULL ) {
doublePair cPos = add( spritePos,
inClothing.backpack->clothingOffset );
if( inFlipH ) {
cPos.x *= -1;
}
cPos = add( cPos, inPos );
backpackPos = cPos;
backpackRot = inRot;
}
}
else if( i == topBackArmIndex ) {
// draw under top of back arm
if( inClothing.bottom != NULL ) {
drawObject( inClothing.bottom, 2,
bottomPos, bottomRot, true,
inFlipH, -1, 0, false, false, emptyClothing );
}
if( inClothing.tunic != NULL ) {
drawObject( inClothing.tunic, 2,
tunicPos, tunicRot, true,
inFlipH, -1, 0, false, false, emptyClothing );
}
if( inClothing.backpack != NULL ) {
drawObject( inClothing.backpack, 2,
backpackPos, backpackRot,
true,
inFlipH, -1, 0, false, false, emptyClothing );
}
}
if( i == frontFootIndex
&& inClothing.frontShoe != NULL ) {
doublePair cPos = add( spritePos,
inClothing.frontShoe->clothingOffset );
if( inFlipH ) {
cPos.x *= -1;
}
cPos = add( cPos, inPos );
frontShoePos = cPos;
frontShoeRot = inRot;
}
if( ! skipSprite ) {
setDrawColor( inObject->spriteColor[i] );
double rot = inObject->spriteRot[i];
if( inFlipH ) {
rot *= -1;
}
rot += inRot;
char multiplicative =
getUsesMultiplicativeBlending( inObject->sprites[i] );
if( multiplicative ) {
toggleMultiplicativeBlend( true );
if( getTotalGlobalFade() < 1 ) {
toggleAdditiveTextureColoring( true );
// alpha ignored for multiplicative blend
// but leave 0 there so that they won't add to stencil
setDrawColor( 0.0f, 0.0f, 0.0f, 0.0f );
}
else {
// set 0 so translucent layers never add to stencil
setDrawFade( 0.0f );
}
}
drawSprite( getSprite( inObject->sprites[i] ), pos, inScale,
rot,
logicalXOR( inFlipH, inObject->spriteHFlip[i] ) );
if( multiplicative ) {
toggleMultiplicativeBlend( false );
toggleAdditiveTextureColoring( false );
}
// this is the front-most drawn hand
// in unanimated, unflipped object
if( i == backHandIndex && ( inHideClosestArm == 0 )
&& !inHideAllLimbs ) {
returnHoldingPos.valid = true;
// return screen pos for hand, which may be flipped, etc.
returnHoldingPos.pos = pos;
returnHoldingPos.rot = rot;
}
else if( i == bodyIndex && inHideClosestArm != 0 ) {
returnHoldingPos.valid = true;
// return screen pos for body, which may be flipped, etc.
returnHoldingPos.pos = pos;
returnHoldingPos.rot = rot;
}
}
// shoes on top of feet
if( inClothing.backShoe != NULL && i == backFootIndex ) {
drawObject( inClothing.backShoe, 2,
backShoePos, backShoeRot, true,
inFlipH, -1, 0, false, false, emptyClothing );
}
else if( inClothing.frontShoe != NULL && i == frontFootIndex ) {
drawObject( inClothing.backShoe, 2,
frontShoePos, frontShoeRot, true,
inFlipH, -1, 0, false, false, emptyClothing );
}
}
if( inClothing.hat != NULL ) {
// hat on top of everything
// relative to head
doublePair cPos = add( animHeadPos,
inClothing.hat->clothingOffset );
if( inFlipH ) {
cPos.x *= -1;
}
cPos = add( cPos, inPos );
drawObject( inClothing.hat, 2, cPos, inRot, true,
inFlipH, -1, 0, false, false, emptyClothing );
}
return returnHoldingPos;
}
HoldingPos drawObject( ObjectRecord *inObject, doublePair inPos, double inRot,
char inWorn, char inFlipH, double inAge,
int inHideClosestArm,
char inHideAllLimbs,
char inHeldNotInPlaceYet,
ClothingSet inClothing,
int inNumContained, int *inContainedIDs,
SimpleVector<int> *inSubContained ) {
drawObject( inObject, 0, inPos, inRot, inWorn, inFlipH, inAge,
inHideClosestArm,
inHideAllLimbs,
inHeldNotInPlaceYet,
inClothing );
int numSlots = getNumContainerSlots( inObject->id );
if( inNumContained > numSlots ) {
inNumContained = numSlots;
}
for( int i=0; i<inNumContained; i++ ) {
ObjectRecord *contained = getObject( inContainedIDs[i] );
doublePair centerOffset = getObjectCenterOffset( contained );
double rot = inRot;
if( inObject->slotVert[i] ) {
double rotOffset = 0.25 + contained->vertContainRotationOffset;
if( inFlipH ) {
centerOffset = rotate( centerOffset, - rotOffset * 2 * M_PI );
rot -= rotOffset;
}
else {
centerOffset = rotate( centerOffset, - rotOffset * 2 * M_PI );
rot += rotOffset;
}
}
doublePair slotPos = sub( inObject->slotPos[i],
centerOffset );
if( inRot != 0 ) {
if( inFlipH ) {
slotPos = rotate( slotPos, 2 * M_PI * inRot );
}
else {
slotPos = rotate( slotPos, -2 * M_PI * inRot );
}
}
if( inFlipH ) {
slotPos.x *= -1;
}
doublePair pos = add( slotPos, inPos );
if( inSubContained != NULL &&
inSubContained[i].size() > 0 ) {
// behind sub-contained
drawObject( contained, 0, pos, rot, false, inFlipH, inAge,
0,
false,
false,
emptyClothing );
for( int s=0; s<contained->numSlots; s++ ) {
if( s < inSubContained[i].size() ) {
doublePair subPos = contained->slotPos[s];
ObjectRecord *subContained = getObject(
inSubContained[i].getElementDirect( s ) );
doublePair subCenterOffset =
getObjectCenterOffset( subContained );
double subRot = rot;
if( contained->slotVert[s] ) {
double rotOffset =
0.25 + subContained->vertContainRotationOffset;
if( inFlipH ) {
subCenterOffset =
rotate( subCenterOffset,
- rotOffset * 2 * M_PI );
subRot -= rotOffset;
}
else {
subCenterOffset =
rotate( subCenterOffset,
- rotOffset * 2 * M_PI );
subRot += rotOffset;
}
}
subPos = sub( subPos, subCenterOffset );
if( inFlipH ) {
subPos.x *= -1;
}
if( rot != 0 ) {
subPos = rotate( subPos, -2 * M_PI * rot );
}
subPos = add( subPos, pos );
drawObject( subContained, 2, subPos, subRot,
false, inFlipH,
inAge, 0, false, false, emptyClothing );
}
}
// in front of sub-contained
drawObject( contained, 1, pos, rot, false, inFlipH, inAge,
0,
false,
false,
emptyClothing );
}
else {
// no sub-contained
// draw contained all at once
drawObject( contained, 2, pos, rot, false, inFlipH, inAge,
0,
false,
false,
emptyClothing );
}
}
return drawObject( inObject, 1, inPos, inRot, inWorn, inFlipH, inAge,
inHideClosestArm,
inHideAllLimbs,
inHeldNotInPlaceYet,
inClothing );
}
void deleteObjectFromBank( int inID ) {
File objectsDir( NULL, "objects" );
if( objectsDir.exists() && objectsDir.isDirectory() ) {
File *cacheFile = objectsDir.getChildFile( "cache.fcz" );
cacheFile->remove();
delete cacheFile;
char *fileName = autoSprintf( "%d.txt", inID );
File *objectFile = objectsDir.getChildFile( fileName );
objectFile->remove();
delete [] fileName;
delete objectFile;
}
freeObjectRecord( inID );
}
char isSpriteUsed( int inSpriteID ) {
for( int i=0; i<mapSize; i++ ) {
if( idMap[i] != NULL ) {
for( int s=0; s<idMap[i]->numSprites; s++ ) {
if( idMap[i]->sprites[s] == inSpriteID ) {
return true;
}
}
}
}
return false;
}
char isSoundUsedByObject( int inSoundID ) {
for( int i=0; i<mapSize; i++ ) {
if( idMap[i] != NULL ) {
if( doesUseSound( idMap[i]->creationSound, inSoundID ) ||
doesUseSound( idMap[i]->usingSound, inSoundID ) ||
doesUseSound( idMap[i]->eatingSound, inSoundID ) ||
doesUseSound( idMap[i]->decaySound, inSoundID ) ) {
return true;
}
}
}
return false;
}
int getRandomPersonObject() {
if( personObjectIDs.size() == 0 ) {
return -1;
}
return personObjectIDs.getElementDirect(
randSource.getRandomBoundedInt( 0,
personObjectIDs.size() - 1 ) );
}
int getRandomFemalePersonObject() {
if( femalePersonObjectIDs.size() == 0 ) {
return -1;
}
return femalePersonObjectIDs.getElementDirect(
randSource.getRandomBoundedInt( 0,
femalePersonObjectIDs.size() - 1 ) );
}
int *getRaces( int *outNumRaces ) {
*outNumRaces = raceList.size();
return raceList.getElementArray();
}
int getRandomPersonObjectOfRace( int inRace ) {
if( inRace > MAX_RACE ) {
inRace = MAX_RACE;
}
if( racePersonObjectIDs[ inRace ].size() == 0 ) {
return -1;
}
return racePersonObjectIDs[ inRace ].getElementDirect(
randSource.getRandomBoundedInt(
0,
racePersonObjectIDs[ inRace ].size() - 1 ) );
}
int getRandomFamilyMember( int inRace, int inMotherID, int inFamilySpan ) {
if( inRace > MAX_RACE ) {
inRace = MAX_RACE;
}
if( racePersonObjectIDs[ inRace ].size() == 0 ) {
return -1;
}
int motherIndex =
racePersonObjectIDs[ inRace ].getElementIndex( inMotherID );
if( motherIndex == -1 ) {
return getRandomPersonObjectOfRace( inRace );
}
// never have offset 0, so we can't ever have ourself as a baby
int offset = randSource.getRandomBoundedInt( 1, inFamilySpan );
if( randSource.getRandomBoolean() ) {
offset = -offset;
}
int familyIndex = motherIndex + offset;
while( familyIndex >= racePersonObjectIDs[ inRace ].size() ) {
familyIndex -= racePersonObjectIDs[ inRace ].size();
}
while( familyIndex < 0 ) {
familyIndex += racePersonObjectIDs[ inRace ].size();
}
return racePersonObjectIDs[ inRace ].getElementDirect( familyIndex );
}
int getNextPersonObject( int inCurrentPersonObjectID ) {
if( personObjectIDs.size() == 0 ) {
return -1;
}
int numPeople = personObjectIDs.size();
for( int i=0; i<numPeople - 1; i++ ) {
if( personObjectIDs.getElementDirect( i ) ==
inCurrentPersonObjectID ) {
return personObjectIDs.getElementDirect( i + 1 );
}
}
return personObjectIDs.getElementDirect( 0 );
}
int getPrevPersonObject( int inCurrentPersonObjectID ) {
if( personObjectIDs.size() == 0 ) {
return -1;
}
int numPeople = personObjectIDs.size();
for( int i=1; i<numPeople; i++ ) {
if( personObjectIDs.getElementDirect( i ) ==
inCurrentPersonObjectID ) {
return personObjectIDs.getElementDirect( i - 1 );
}
}
return personObjectIDs.getElementDirect( numPeople - 1 );
}
int getRandomDeathMarker() {
if( deathMarkerObjectIDs.size() == 0 ) {
return -1;
}
return deathMarkerObjectIDs.getElementDirect(
randSource.getRandomBoundedInt( 0,
deathMarkerObjectIDs.size() - 1 ) );
}
ObjectRecord **getAllObjects( int *outNumResults ) {
SimpleVector<ObjectRecord *> records;
for( int i=0; i<mapSize; i++ ) {
if( idMap[i] != NULL ) {
records.push_back( idMap[i] );
}
}
*outNumResults = records.size();
return records.getElementArray();
}
ClothingSet getEmptyClothingSet() {
return emptyClothing;
}
static ObjectRecord **clothingPointerByIndex( ClothingSet *inSet,
int inIndex ) {
switch( inIndex ) {
case 0:
return &( inSet->hat );
case 1:
return &( inSet->tunic );
case 2:
return &( inSet->frontShoe );
case 3:
return &( inSet->backShoe );
case 4:
return &( inSet->bottom );
case 5:
return &( inSet->backpack );
}
return NULL;
}
ObjectRecord *clothingByIndex( ClothingSet inSet, int inIndex ) {
ObjectRecord **pointer = clothingPointerByIndex( &inSet, inIndex );
if( pointer != NULL ) {
return *( pointer );
}
return NULL;
}
void setClothingByIndex( ClothingSet *inSet, int inIndex,
ObjectRecord *inClothing ) {
ObjectRecord **pointer = clothingPointerByIndex( inSet, inIndex );
*pointer = inClothing;
}
ObjectRecord *getClothingAdded( ClothingSet *inOldSet,
ClothingSet *inNewSet ) {
for( int i=0; i<=5; i++ ) {
ObjectRecord *oldC =
clothingByIndex( *inOldSet, i );
ObjectRecord *newC =
clothingByIndex( *inNewSet, i );
if( newC != NULL &&
newC != oldC ) {
return newC;
}
}
return NULL;
}
char checkSpriteAncestor( ObjectRecord *inObject, int inChildIndex,
int inPossibleAncestorIndex ) {
int nextParent = inChildIndex;
while( nextParent != -1 && nextParent != inPossibleAncestorIndex ) {
nextParent = inObject->spriteParent[nextParent];
}
if( nextParent == inPossibleAncestorIndex ) {
return true;
}
return false;
}
int getMaxDiameter( ObjectRecord *inObject ) {
int maxD = 0;
for( int i=0; i<inObject->numSprites; i++ ) {
doublePair pos = inObject->spritePos[i];
int rad = getSpriteRecord( inObject->sprites[i] )->maxD / 2;
int xR = lrint( fabs( pos.x ) + rad );
int yR = lrint( fabs( pos.y ) + rad );
int xD = 2 * xR;
int yD = 2 * yR;
if( xD > maxD ) {
maxD = xD;
}
if( yD > maxD ) {
maxD = yD;
}
}
return maxD;
}
int getObjectHeight( int inObjectID ) {
ObjectRecord *o = getObject( inObjectID );
if( o == NULL ) {
return 0;
}
if( o->cachedHeight == -1 ) {
o->cachedHeight =
recomputeObjectHeight( o->numSprites, o->sprites, o->spritePos );
}
return o->cachedHeight;
}
int recomputeObjectHeight( int inNumSprites, int *inSprites,
doublePair *inSpritePos ) {
double maxH = 0;
for( int i=0; i<inNumSprites; i++ ) {
doublePair pos = inSpritePos[i];
SpriteRecord *spriteRec = getSpriteRecord( inSprites[i] );
int rad = 0;
// don't count transparent sprites as part of height
if( spriteRec != NULL && ! spriteRec->multiplicativeBlend ) {
char hit = false;
if( spriteRec->hitMap != NULL ) {
int h = spriteRec->h;
int w = spriteRec->w;
char *hitMap = spriteRec->hitMap;
for( int y=0; y<h; y++ ) {
for( int x=0; x<w; x++ ) {
int p = y * spriteRec->w + x;
if( hitMap[p] ) {
hit = true;
// can be negative if anchor above top
// pixel
rad =
( h/2 + spriteRec->centerAnchorYOffset )
- y;
break;
}
}
if( hit ) {
break;
}
}
}
else {
rad = spriteRec->h / 2;
}
}
double h = pos.y + rad;
if( h > maxH ) {
maxH = h;
}
}
int returnH = lrint( maxH );
return returnH;
}
double getClosestObjectPart( ObjectRecord *inObject,
ClothingSet *inClothing,
SimpleVector<int> *inContained,
SimpleVector<int> *inClothingContained,
char inWorn,
double inAge,
int inPickedLayer,
char inFlip,
float inXCenterOffset, float inYCenterOffset,
int *outSprite,
int *outClothing,
int *outSlot,
char inConsiderTransparent,
char inConsiderEmptySlots ) {
doublePair pos = { inXCenterOffset, inYCenterOffset };
*outSprite = -1;
*outClothing = -1;
*outSlot = -1;
doublePair headPos = {0,0};
int headIndex = getHeadIndex( inObject, inAge );
if( headIndex < inObject->numSprites ) {
headPos = inObject->spritePos[ headIndex ];
}
doublePair frontFootPos = {0,0};
int frontFootIndex = getFrontFootIndex( inObject, inAge );
if( frontFootIndex < inObject->numSprites ) {
frontFootPos =
inObject->spritePos[ frontFootIndex ];
}
doublePair backFootPos = {0,0};
int backFootIndex = getBackFootIndex( inObject, inAge );
if( backFootIndex < inObject->numSprites ) {
backFootPos =
inObject->spritePos[ backFootIndex ];
}
doublePair bodyPos = {0,0};
int bodyIndex = getBodyIndex( inObject, inAge );
if( bodyIndex < inObject->numSprites ) {
bodyPos = inObject->spritePos[ bodyIndex ];
}
int backArmTopIndex = getBackArmTopIndex( inObject, inAge );
char tunicChecked = false;
char hatChecked = false;
AnimationRecord *a = NULL;
if( inWorn ) {
a = getAnimation( inObject->id, held );
}
for( int i=inObject->numSprites-1; i>=0; i-- ) {
// first check for clothing that is above this part
// (array because 3 pieces of clothing attached to body)
ObjectRecord *cObj[3] = { NULL, NULL, NULL };
int cObjIndex[3] = { -1, -1, -1 };
doublePair cObjBodyPartPos[3];
if( inClothing != NULL ) {
if( i <= inObject->numSprites - 1 && !hatChecked ) {
// hat above everything
cObj[0] = inClothing->hat;
cObjIndex[0] = 0;
cObjBodyPartPos[0] = add( headPos,
getAgeHeadOffset( inAge, headPos,
bodyPos,
frontFootPos ) );
if( checkSpriteAncestor( inObject, headIndex, bodyIndex ) ) {
cObjBodyPartPos[0] = add( cObjBodyPartPos[0],
getAgeBodyOffset( inAge,
bodyPos ) );
}
hatChecked = true;
}
else if( i < backArmTopIndex && ! tunicChecked ) {
// bottom, tunic, and backpack behind back arm
cObj[0] = inClothing->backpack;
cObjIndex[0] = 5;
cObjBodyPartPos[0] = add( bodyPos,
getAgeBodyOffset( inAge, bodyPos ) );
cObj[1] = inClothing->tunic;
cObjIndex[1] = 1;
cObjBodyPartPos[1] = add( bodyPos,
getAgeBodyOffset( inAge, bodyPos ) );
cObj[2] = inClothing->bottom;
cObjIndex[2] = 4;
cObjBodyPartPos[2] = add( bodyPos,
getAgeBodyOffset( inAge, bodyPos ) );
tunicChecked = true;
}
else if( i == frontFootIndex ) {
cObj[0] = inClothing->frontShoe;
cObjIndex[0] = 2;
cObjBodyPartPos[0] = frontFootPos;
}
else if( i == backFootIndex ) {
cObj[0] = inClothing->backShoe;
cObjIndex[0] = 3;
cObjBodyPartPos[0] = backFootPos;
}
}
for( int c=0; c<3; c++ ) {
if( cObj[c] != NULL ) {
int sp, cl, sl;
doublePair clothingOffset = cObj[c]->clothingOffset;
if( inFlip ) {
clothingOffset.x *= -1;
cObjBodyPartPos[c].x *= -1;
}
doublePair cSpritePos = add( cObjBodyPartPos[c],
clothingOffset );
doublePair cOffset = sub( pos, cSpritePos );
SimpleVector<int> *clothingCont = NULL;
if( inClothingContained != NULL ) {
clothingCont = &( inClothingContained[ cObjIndex[c] ] );
}
double dist = getClosestObjectPart( cObj[c],
NULL,
clothingCont,
NULL,
// clothing is worn
// on body currently
true,
-1,
-1,
inFlip,
cOffset.x, cOffset.y,
&sp, &cl, &sl,
inConsiderTransparent );
if( sp != -1 ) {
*outClothing = cObjIndex[c];
break;
}
else if( sl != -1 && dist == 0 ) {
*outClothing = cObjIndex[c];
*outSlot = sl;
break;
}
}
}
if( *outClothing != -1 ) {
break;
}
// clothing not hit, check sprite layer
doublePair thisSpritePos = inObject->spritePos[i];
if( inObject->person ) {
if( ! isSpriteVisibleAtAge( inObject, i, inAge ) ) {
if( i != inPickedLayer ) {
// invisible, don't let them pick it
continue;
}
}
if( i == headIndex ||
checkSpriteAncestor( inObject, i,
headIndex ) ) {
thisSpritePos = add( thisSpritePos,
getAgeHeadOffset( inAge, headPos,
bodyPos,
frontFootPos ) );
}
if( i == bodyIndex ||
checkSpriteAncestor( inObject, i,
bodyIndex ) ) {
thisSpritePos = add( thisSpritePos,
getAgeBodyOffset( inAge, bodyPos ) );
}
}
if( inFlip ) {
thisSpritePos.x *= -1;
}
doublePair offset = sub( pos, thisSpritePos );
SpriteRecord *sr = getSpriteRecord( inObject->sprites[i] );
if( !inConsiderTransparent &&
sr->multiplicativeBlend ){
// skip this transparent sprite
continue;
}
if( inObject->clothing != 'n' ) {
if( inObject->spriteInvisibleWhenWorn[i] != 0 ) {
if( inWorn && inObject->spriteInvisibleWhenWorn[i] == 1 ) {
// this layer invisible when worn
continue;
}
else if( ! inWorn &&
inObject->spriteInvisibleWhenWorn[i] == 2 ) {
// this layer invisible when NOT worn
continue;
}
}
}
if( inFlip ) {
offset = rotate( offset, -2 * M_PI * inObject->spriteRot[i] );
}
else {
offset = rotate( offset, 2 * M_PI * inObject->spriteRot[i] );
}
if( a != NULL ) {
// apply simplified version of animation
// a still snapshot at t=0 (only look at phases)
// this also ignores parent relationships for now
// however, since this only applies for worn clothing, and trying
// to make worn clothing properly clickable when it has a held
// rotation, it will work most of the time, since most clothing
// has one sprite, and for multi-sprite clothing, this should
// at least capture the rotation of the largest sprite
if( a->numSprites > i && a->spriteAnim[i].rotPhase != 0 ) {
doublePair rotCenter = a->spriteAnim[i].rotationCenterOffset;
if( inFlip ) {
rotCenter.x *= -1;
}
if( inObject->spriteRot[i] != 0 ) {
if( inFlip ) {
rotCenter =
rotate( rotCenter,
-2 * M_PI * inObject->spriteRot[i] );
}
else {
rotCenter =
rotate( rotCenter,
2 * M_PI * inObject->spriteRot[i] );
}
}
doublePair tempOffset =
sub( offset, rotCenter );
if( inFlip ) {
tempOffset =
rotate( tempOffset,
- a->spriteAnim[i].rotPhase * 2 * M_PI );
}
else {
tempOffset =
rotate( tempOffset,
a->spriteAnim[i].rotPhase * 2 * M_PI );
}
offset = add( tempOffset, rotCenter );
}
}
if( inObject->spriteHFlip[i] ) {
offset.x *= -1;
}
if( inFlip ) {
offset.x *= -1;
}
offset.x += sr->centerAnchorXOffset;
offset.y -= sr->centerAnchorYOffset;
if( getSpriteHit( inObject->sprites[i],
lrint( offset.x ),
lrint( offset.y ) ) ) {
*outSprite = i;
break;
}
}
double smallestDist = 9999999;
char closestBehindSlots = false;
if( *outSprite != -1 && inObject->spriteBehindSlots[ *outSprite ] ) {
closestBehindSlots = true;
}
if( ( *outSprite == -1 || closestBehindSlots )
&& *outClothing == -1 && *outSlot == -1 ) {
// consider slots
if( closestBehindSlots ) {
// consider only direct contianed
// object hits or slot placeholder hits
smallestDist = 16;
}
for( int i=inObject->numSlots-1; i>=0; i-- ) {
doublePair slotPos = inObject->slotPos[i];
if( inFlip ) {
slotPos.x *= -1;
}
if( inContained != NULL && i <inContained->size() ) {
ObjectRecord *contained =
getObject( inContained->getElementDirect( i ) );
doublePair centOffset = getObjectCenterOffset( contained );
if( inObject->slotVert[i] ) {
double rotOffset =
0.25 + contained->vertContainRotationOffset;
if( inFlip ) {
centOffset = rotate( centOffset,
- rotOffset * 2 * M_PI );
centOffset.x *= -1;
}
else {
centOffset = rotate( centOffset,
- rotOffset * 2 * M_PI );
}
}
else if( inFlip ) {
centOffset.x *= -1;
}
slotPos = sub( slotPos, centOffset );
doublePair slotOffset = sub( pos, slotPos );
if( inObject->slotVert[i] ) {
double rotOffset =
0.25 + contained->vertContainRotationOffset;
if( inFlip ) {
slotOffset = rotate( slotOffset,
- rotOffset * 2 * M_PI );
}
else {
slotOffset = rotate( slotOffset,
rotOffset * 2 * M_PI );
}
}
int sp, cl, sl;
getClosestObjectPart( contained,
NULL,
NULL,
NULL,
false,
-1,
-1,
inFlip,
slotOffset.x, slotOffset.y,
&sp, &cl, &sl,
inConsiderTransparent );
if( sp != -1 ) {
*outSlot = i;
smallestDist = 0;
break;
}
}
else if( inConsiderEmptySlots ) {
double dist = distance( pos, inObject->slotPos[i] );
if( dist < smallestDist ) {
*outSprite = -1;
*outSlot = i;
smallestDist = dist;
}
}
}
if( closestBehindSlots && smallestDist == 16 ) {
// hit no slot, stick with sprite behind
smallestDist = 0;
}
}
else{
smallestDist = 0;
}
return smallestDist;
}
// gets index of hands in no order by finding lowest two holders
static void getHandIndices( ObjectRecord *inObject, double inAge,
int *outHandOneIndex, int *outHandTwoIndex ) {
*outHandOneIndex = -1;
*outHandTwoIndex = -1;
double handOneY = 9999999;
double handTwoY = 9999999;
for( int i=0; i< inObject->numSprites; i++ ) {
if( inObject->spriteInvisibleWhenHolding[i] ) {
if( inObject->spriteAgeStart[i] != -1 ||
inObject->spriteAgeEnd[i] != -1 ) {
if( inAge < inObject->spriteAgeStart[i] ||
inAge >= inObject->spriteAgeEnd[i] ) {
// skip this layer
continue;
}
}
if( inObject->spritePos[i].y < handOneY ) {
*outHandTwoIndex = *outHandOneIndex;
handTwoY = handOneY;
*outHandOneIndex = i;
handOneY = inObject->spritePos[i].y;
}
else if( inObject->spritePos[i].y < handTwoY ) {
*outHandTwoIndex = i;
handTwoY = inObject->spritePos[i].y;
}
}
}
}
int getBackHandIndex( ObjectRecord *inObject,
double inAge ) {
int handOneIndex;
int handTwoIndex;
getHandIndices( inObject, inAge, &handOneIndex, &handTwoIndex );
if( handOneIndex != -1 ) {
if( handTwoIndex != -1 ) {
if( inObject->spritePos[handOneIndex].x <
inObject->spritePos[handTwoIndex].x ) {
return handOneIndex;
}
else {
return handTwoIndex;
}
}
else {
return handTwoIndex;
}
}
else {
return -1;
}
}
int getFrontHandIndex( ObjectRecord *inObject,
double inAge ) {
int handOneIndex;
int handTwoIndex;
getHandIndices( inObject, inAge, &handOneIndex, &handTwoIndex );
if( handOneIndex != -1 ) {
if( handTwoIndex != -1 ) {
if( inObject->spritePos[handOneIndex].x >
inObject->spritePos[handTwoIndex].x ) {
return handOneIndex;
}
else {
return handTwoIndex;
}
}
else {
return handTwoIndex;
}
}
else {
return -1;
}
}
static void getLimbIndices( ObjectRecord *inObject,
double inAge, SimpleVector<int> *outList,
int inHandOrFootIndex ) {
if( inHandOrFootIndex == -1 ) {
return;
}
int nextLimbPart = inHandOrFootIndex;
while( nextLimbPart != -1 && ! inObject->spriteIsBody[ nextLimbPart ] ) {
outList->push_back( nextLimbPart );
nextLimbPart = inObject->spriteParent[ nextLimbPart ];
}
}
void getFrontArmIndices( ObjectRecord *inObject,
double inAge, SimpleVector<int> *outList ) {
getLimbIndices( inObject, inAge, outList,
getFrontHandIndex( inObject, inAge ) );
}
void getBackArmIndices( ObjectRecord *inObject,
double inAge, SimpleVector<int> *outList ) {
getLimbIndices( inObject, inAge, outList,
getBackHandIndex( inObject, inAge ) );
}
int getBackArmTopIndex( ObjectRecord *inObject, double inAge ) {
SimpleVector<int> list;
getBackArmIndices( inObject, inAge, &list );
if( list.size() > 0 ) {
return list.getElementDirect( list.size() - 1 );
}
else {
return -1;
}
}
void getAllLegIndices( ObjectRecord *inObject,
double inAge, SimpleVector<int> *outList ) {
getLimbIndices( inObject, inAge, outList,
getBackFootIndex( inObject, inAge ) );
getLimbIndices( inObject, inAge, outList,
getFrontFootIndex( inObject, inAge ) );
if( outList->size() >= 2 ) {
int bodyIndex = getBodyIndex( inObject, inAge );
// add shadows to list, which we can find based on
// being lower than body and having no parent
doublePair bodyPos = inObject->spritePos[ bodyIndex ];
for( int i=0; i<inObject->numSprites; i++ ) {
if( outList->getElementIndex( i ) == -1 ) {
if( bodyPos.y > inObject->spritePos[i].y &&
inObject->spriteParent[i] == -1 ) {
outList->push_back( i );
}
}
}
}
}
char isSpriteVisibleAtAge( ObjectRecord *inObject,
int inSpriteIndex,
double inAge ) {
if( inObject->spriteAgeStart[inSpriteIndex] != -1 ||
inObject->spriteAgeEnd[inSpriteIndex] != -1 ) {
if( inAge < inObject->spriteAgeStart[inSpriteIndex] ||
inAge >= inObject->spriteAgeEnd[inSpriteIndex] ) {
return false;
}
}
return true;
}
static int getBodyPartIndex( ObjectRecord *inObject,
char *inBodyPartFlagArray,
double inAge ) {
for( int i=0; i< inObject->numSprites; i++ ) {
if( inBodyPartFlagArray[i] ) {
if( ! isSpriteVisibleAtAge( inObject, i, inAge ) ) {
// skip this layer
continue;
}
return i;
}
}
// default
// don't return -1 here, so it can be blindly used as an index
return 0;
}
int getHeadIndex( ObjectRecord *inObject,
double inAge ) {
return getBodyPartIndex( inObject, inObject->spriteIsHead, inAge );
}
int getBodyIndex( ObjectRecord *inObject,
double inAge ) {
return getBodyPartIndex( inObject, inObject->spriteIsBody, inAge );
}
int getBackFootIndex( ObjectRecord *inObject,
double inAge ) {
return getBodyPartIndex( inObject, inObject->spriteIsBackFoot, inAge );
}
int getFrontFootIndex( ObjectRecord *inObject,
double inAge ) {
return getBodyPartIndex( inObject, inObject->spriteIsFrontFoot, inAge );
}
char *getBiomesString( ObjectRecord *inObject ) {
SimpleVector <char>stringBuffer;
for( int i=0; i<inObject->numBiomes; i++ ) {
if( i != 0 ) {
stringBuffer.push_back( ',' );
}
char *intString = autoSprintf( "%d", inObject->biomes[i] );
stringBuffer.appendElementString( intString );
delete [] intString;
}
return stringBuffer.getElementString();
}
int compareBiomeInt( const void *inA, const void *inB ) {
int *a = (int*)inA;
int *b = (int*)inB;
if( *a > *b ) {
return 1;
}
if( *a < *b ) {
return -1;
}
return 0;
}
static SimpleVector<int> biomeCache;
void getAllBiomes( SimpleVector<int> *inVectorToFill ) {
if( biomeCache.size() == 0 ) {
for( int i=0; i<mapSize; i++ ) {
if( idMap[i] != NULL ) {
for( int j=0; j< idMap[i]->numBiomes; j++ ) {
int b = idMap[i]->biomes[j];
if( biomeCache.getElementIndex( b ) == -1 ) {
biomeCache.push_back( b );
}
}
}
}
// now sort it
int *a = biomeCache.getElementArray();
int num = biomeCache.size();
qsort( a, num, sizeof(int), compareBiomeInt );
biomeCache.deleteAll();
biomeCache.appendArray( a, num );
delete [] a;
}
for( int i=0; i<biomeCache.size(); i++ ) {
inVectorToFill->push_back( biomeCache.getElementDirect( i ) );
}
}
doublePair getObjectCenterOffset( ObjectRecord *inObject ) {
// find center of widest sprite
SpriteRecord *widestRecord = NULL;
int widestIndex = -1;
int widestWidth = 0;
double widestYPos = 0;
for( int i=0; i<inObject->numSprites; i++ ) {
SpriteRecord *sprite = getSpriteRecord( inObject->sprites[i] );
if( sprite->multiplicativeBlend ) {
// don't consider translucent sprites when computing wideness
continue;
}
int w = sprite->visibleW;
double rot = inObject->spriteRot[i];
if( rot != 0 ) {
double rotAbs = fabs( rot );
// just the fractional part
rotAbs -= floor( rotAbs );
if( rotAbs == 0.25 || rotAbs == 0.75 ) {
w = sprite->visibleH;
}
}
if( widestRecord == NULL ||
// wider than what we've seen so far
w > widestWidth ||
// or tied for wideness, and lower
( w == widestWidth &&
inObject->spritePos[i].y < widestYPos ) ) {
widestRecord = sprite;
widestIndex = i;
widestWidth = w;
widestYPos = inObject->spritePos[i].y;
}
}
if( widestRecord == NULL ) {
doublePair result = { 0, 0 };
return result;
}
doublePair centerOffset = { (double)widestRecord->centerXOffset,
(double)widestRecord->centerYOffset };
centerOffset = rotate( centerOffset,
2 * M_PI * inObject->spriteRot[widestIndex] );
doublePair spriteCenter = add( inObject->spritePos[widestIndex],
centerOffset );
return spriteCenter;
}
int getMaxWideRadius() {
return maxWideRadius;
}
char isSpriteSubset( int inSuperObjectID, int inSubObjectID ) {
ObjectRecord *superO = getObject( inSuperObjectID );
ObjectRecord *subO = getObject( inSubObjectID );
if( superO == NULL || subO == NULL ) {
return false;
}
if( subO->numSprites == 0 ) {
return true;
}
// allow global position adjustments, as long as all sub-sprites in same
// relative position to each other
int spriteSubSeroID = subO->sprites[0];
doublePair spriteSubZeroPos = subO->spritePos[0];
doublePair spriteSuperZeroPos;
// find zero sprite in super
char found = false;
for( int ss=0; ss<superO->numSprites; ss++ ) {
if( superO->sprites[ ss ] == spriteSubSeroID ) {
found = true;
spriteSuperZeroPos = superO->spritePos[ ss ];
break;
}
}
if( !found ) {
return false;
}
for( int s=0; s<subO->numSprites; s++ ) {
int spriteID = subO->sprites[s];
doublePair spritePosRel = sub( subO->spritePos[s],
spriteSubZeroPos );
double spriteRot = subO->spriteRot[s];
char spriteHFlip = subO->spriteHFlip[s];
// ignore sprite color for now
//FloatRGB spriteColor = subO->spriteColor[s];
char found = false;
for( int ss=0; ss<superO->numSprites; ss++ ) {
if( superO->sprites[ ss ] == spriteID &&
equal( sub( superO->spritePos[ ss ],
spriteSuperZeroPos ), spritePosRel ) &&
superO->spriteRot[ ss ] == spriteRot &&
superO->spriteHFlip[ ss ] == spriteHFlip
/* &&
equal( superO->spriteColor[ ss ], spriteColor ) */ ) {
found = true;
break;
}
}
if( !found ) {
return false;
}
}
return true;
}
char equal( FloatRGB inA, FloatRGB inB ) {
return
inA.r == inB.r &&
inA.g == inB.g &&
inA.b == inB.b;
}
void getArmHoldingParameters( ObjectRecord *inHeldObject,
int *outHideClosestArm,
char *outHideAllLimbs ) {
*outHideClosestArm = 0;
*outHideAllLimbs = false;
if( inHeldObject != NULL ) {
if( inHeldObject->heldInHand ) {
*outHideClosestArm = 0;
}
else if( inHeldObject->rideable ) {
*outHideClosestArm = 0;
*outHideAllLimbs = true;
}
else {
// try hiding no arms, but freezing them instead
// -2 means body position still returned as held pos
// instead of hand pos
*outHideClosestArm = -2;
*outHideAllLimbs = false;
}
}
}
void computeHeldDrawPos( HoldingPos inHoldingPos, doublePair inPos,
ObjectRecord *inHeldObject,
char inFlipH,
doublePair *outHeldDrawPos, double *outHeldDrawRot ) {
doublePair holdPos;
double holdRot = 0;
if( inHoldingPos.valid ) {
holdPos = inHoldingPos.pos;
}
else {
holdPos = inPos;
}
if( inHeldObject != NULL ) {
doublePair heldOffset = inHeldObject->heldOffset;
if( !inHeldObject->person ) {
heldOffset = sub( heldOffset,
getObjectCenterOffset( inHeldObject ) );
}
if( inFlipH ) {
heldOffset.x *= -1;
}
if( inHoldingPos.valid && inHoldingPos.rot != 0 &&
! inHeldObject->rideable ) {
if( inFlipH ) {
heldOffset =
rotate( heldOffset,
2 * M_PI * inHoldingPos.rot );
}
else {
heldOffset =
rotate( heldOffset,
-2 * M_PI * inHoldingPos.rot );
}
if( inFlipH ) {
holdRot = -inHoldingPos.rot;
}
else {
holdRot = inHoldingPos.rot;
}
if( holdRot > 1 ) {
while( holdRot > 1 ) {
holdRot -= 1;
}
}
else if( holdRot < -1 ) {
while( holdRot < -1 ) {
holdRot += 1;
}
}
}
holdPos.x += heldOffset.x;
holdPos.y += heldOffset.y;
}
*outHeldDrawPos = holdPos;
*outHeldDrawRot = holdRot;
}
char bothSameUseParent( int inAObjectID, int inBObjectID ) {
ObjectRecord *a = getObject( inAObjectID );
ObjectRecord *b = getObject( inBObjectID );
if( a != NULL && b != NULL ) {
if( a->isUseDummy && b->isUseDummy ) {
if( a->useDummyParent == b->useDummyParent ) {
return true;
}
}
if( ! a->isUseDummy && b->isUseDummy ) {
return ( b->useDummyParent == inAObjectID );
}
if( a->isUseDummy && ! b->isUseDummy ) {
return ( a->useDummyParent == inBObjectID );
}
}
return false;
}
| [
"jasonrohrer@fastmail.fm"
] | jasonrohrer@fastmail.fm |
79ea9df1d819c93e1413d32c9c9ae36071e9f7f3 | f0119e5464ea44c56c01e6f86f32475fa7c58510 | /src/qt/addressbookpage.cpp | c8cf23f10614516f915dd91a322784379e38a3f9 | [
"MIT"
] | permissive | bedri/CryptoFlowCoin | 5e0bed3f2459ff6420c5f3f87af2b2ecae5de04f | d3f21f5fdb8d5ac15308c9dadc2e0078ac36a009 | refs/heads/master | 2023-03-16T06:58:49.958281 | 2021-02-13T20:13:44 | 2021-02-13T20:13:44 | 342,163,094 | 0 | 0 | MIT | 2021-02-25T07:48:00 | 2021-02-25T07:45:28 | null | UTF-8 | C++ | false | false | 10,238 | cpp | // Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2018 LightPayCoin developers
// Copyright (c) 2018 The CryptoFlow developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#if defined(HAVE_CONFIG_H)
#include "config/cryptoflow-config.h"
#endif
#include "addressbookpage.h"
#include "ui_addressbookpage.h"
#include "addresstablemodel.h"
#include "bitcoingui.h"
#include "csvmodelwriter.h"
#include "editaddressdialog.h"
#include "guiutil.h"
#include <QIcon>
#include <QMenu>
#include <QMessageBox>
#include <QSortFilterProxyModel>
AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget* parent) : QDialog(parent),
ui(new Ui::AddressBookPage),
model(0),
mode(mode),
tab(tab)
{
ui->setupUi(this);
#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac
ui->newAddress->setIcon(QIcon());
ui->copyAddress->setIcon(QIcon());
ui->deleteAddress->setIcon(QIcon());
ui->exportButton->setIcon(QIcon());
#endif
switch (mode) {
case ForSelection:
switch (tab) {
case SendingTab:
setWindowTitle(tr("Choose the address to send coins to"));
break;
case ReceivingTab:
setWindowTitle(tr("Choose the address to receive coins with"));
break;
}
connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept()));
ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->tableView->setFocus();
ui->closeButton->setText(tr("C&hoose"));
ui->exportButton->hide();
break;
case ForEditing:
switch (tab) {
case SendingTab:
setWindowTitle(tr("Sending addresses"));
break;
case ReceivingTab:
setWindowTitle(tr("Receiving addresses"));
break;
}
break;
}
switch (tab) {
case SendingTab:
ui->labelExplanation->setText(tr("These are your CryptoFlow addresses for sending payments. Always check the amount and the receiving address before sending coins."));
ui->deleteAddress->setVisible(true);
break;
case ReceivingTab:
ui->labelExplanation->setText(tr("These are your CryptoFlow addresses for receiving payments. It is recommended to use a new receiving address for each transaction."));
ui->deleteAddress->setVisible(false);
break;
}
// Context menu actions
QAction* copyAddressAction = new QAction(tr("&Copy Address"), this);
QAction* copyLabelAction = new QAction(tr("Copy &Label"), this);
QAction* editAction = new QAction(tr("&Edit"), this);
deleteAction = new QAction(ui->deleteAddress->text(), this);
// Build context menu
contextMenu = new QMenu();
contextMenu->addAction(copyAddressAction);
contextMenu->addAction(copyLabelAction);
contextMenu->addAction(editAction);
if (tab == SendingTab)
contextMenu->addAction(deleteAction);
contextMenu->addSeparator();
// Connect signals for context menu actions
connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(on_copyAddress_clicked()));
connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction()));
connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction()));
connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteAddress_clicked()));
connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(accept()));
}
AddressBookPage::~AddressBookPage()
{
delete ui;
}
void AddressBookPage::setModel(AddressTableModel* model)
{
this->model = model;
if (!model)
return;
proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(model);
proxyModel->setDynamicSortFilter(true);
proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
switch (tab) {
case ReceivingTab:
// Receive filter
proxyModel->setFilterRole(AddressTableModel::TypeRole);
proxyModel->setFilterFixedString(AddressTableModel::Receive);
break;
case SendingTab:
// Send filter
proxyModel->setFilterRole(AddressTableModel::TypeRole);
proxyModel->setFilterFixedString(AddressTableModel::Send);
break;
}
ui->tableView->setModel(proxyModel);
ui->tableView->sortByColumn(0, Qt::AscendingOrder);
// Set column widths
#if QT_VERSION < 0x050000
ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Label, QHeaderView::Stretch);
ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents);
#else
ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Label, QHeaderView::Stretch);
ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents);
#endif
connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this, SLOT(selectionChanged()));
// Select row for newly created address
connect(model, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(selectNewAddress(QModelIndex, int, int)));
selectionChanged();
}
void AddressBookPage::on_copyAddress_clicked()
{
GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Address);
}
void AddressBookPage::onCopyLabelAction()
{
GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Label);
}
void AddressBookPage::onEditAction()
{
if (!model)
return;
if (!ui->tableView->selectionModel())
return;
QModelIndexList indexes = ui->tableView->selectionModel()->selectedRows();
if (indexes.isEmpty())
return;
EditAddressDialog dlg(
tab == SendingTab ?
EditAddressDialog::EditSendingAddress :
EditAddressDialog::EditReceivingAddress,
this);
dlg.setModel(model);
QModelIndex origIndex = proxyModel->mapToSource(indexes.at(0));
dlg.loadRow(origIndex.row());
dlg.exec();
}
void AddressBookPage::on_newAddress_clicked()
{
if (!model)
return;
EditAddressDialog dlg(
tab == SendingTab ?
EditAddressDialog::NewSendingAddress :
EditAddressDialog::NewReceivingAddress,
this);
dlg.setModel(model);
if (dlg.exec()) {
newAddressToSelect = dlg.getAddress();
}
}
void AddressBookPage::on_deleteAddress_clicked()
{
QTableView* table = ui->tableView;
if (!table->selectionModel())
return;
QModelIndexList indexes = table->selectionModel()->selectedRows();
if (!indexes.isEmpty()) {
table->model()->removeRow(indexes.at(0).row());
}
}
void AddressBookPage::selectionChanged()
{
// Set button states based on selected tab and selection
QTableView* table = ui->tableView;
if (!table->selectionModel())
return;
if (table->selectionModel()->hasSelection()) {
switch (tab) {
case SendingTab:
// In sending tab, allow deletion of selection
ui->deleteAddress->setEnabled(true);
ui->deleteAddress->setVisible(true);
deleteAction->setEnabled(true);
break;
case ReceivingTab:
// Deleting receiving addresses, however, is not allowed
ui->deleteAddress->setEnabled(false);
ui->deleteAddress->setVisible(false);
deleteAction->setEnabled(false);
break;
}
ui->copyAddress->setEnabled(true);
} else {
ui->deleteAddress->setEnabled(false);
ui->copyAddress->setEnabled(false);
}
}
void AddressBookPage::done(int retval)
{
QTableView* table = ui->tableView;
if (!table->selectionModel() || !table->model())
return;
// Figure out which address was selected, and return it
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
foreach (QModelIndex index, indexes) {
QVariant address = table->model()->data(index);
returnValue = address.toString();
}
if (returnValue.isEmpty()) {
// If no address entry selected, return rejected
retval = Rejected;
}
QDialog::done(retval);
}
void AddressBookPage::on_exportButton_clicked()
{
// CSV is currently the only supported format
QString filename = GUIUtil::getSaveFileName(this,
tr("Export Address List"), QString(),
tr("Comma separated file (*.csv)"), NULL);
if (filename.isNull())
return;
CSVModelWriter writer(filename);
// name, column, role
writer.setModel(proxyModel);
writer.addColumn("Label", AddressTableModel::Label, Qt::EditRole);
writer.addColumn("Address", AddressTableModel::Address, Qt::EditRole);
if (!writer.write()) {
QMessageBox::critical(this, tr("Exporting Failed"),
tr("There was an error trying to save the address list to %1. Please try again.").arg(filename));
}
}
void AddressBookPage::contextualMenu(const QPoint& point)
{
QModelIndex index = ui->tableView->indexAt(point);
if (index.isValid()) {
contextMenu->exec(QCursor::pos());
}
}
void AddressBookPage::selectNewAddress(const QModelIndex& parent, int begin, int /*end*/)
{
QModelIndex idx = proxyModel->mapFromSource(model->index(begin, AddressTableModel::Address, parent));
if (idx.isValid() && (idx.data(Qt::EditRole).toString() == newAddressToSelect)) {
// Select row of newly created address, once
ui->tableView->setFocus();
ui->tableView->selectRow(idx.row());
newAddressToSelect.clear();
}
}
| [
"root@localhost"
] | root@localhost |
d2ce075b4026bbe288c08342cd913b2f8d065fcd | 09ea1901af1caa0cd7a6977209c384e08278a371 | /code/Ardupilot/libraries/AP_HAL_AVR/Scheduler_Timer.cpp | e1f026e77d8ee7205c27520785fd1d91bd94ff89 | [] | no_license | sid1980/JAGUAR | e038e048a0542d7f3b67c480d27881f91ef42e4e | 2dc262fdc10a600335f71878e092265bc9da77c2 | refs/heads/master | 2021-12-03T05:19:44.367320 | 2014-05-01T23:21:27 | 2014-05-01T23:21:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,808 | cpp | #include <AP_HAL.h>
#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2)
#include <avr/io.h>
#include <avr/interrupt.h>
#include "Scheduler.h"
using namespace AP_HAL_AVR;
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
static volatile uint32_t timer0_overflow_count = 0;
static volatile uint32_t timer0_millis = 0;
static uint8_t timer0_fract = 0;
void AVRTimer::init() {
// this needs to be called before setup() or some functions won't
// work there
sei();
// set timer 0 prescale factor to 64
// this combination is for the standard 168/328/1280/2560
sbi(TCCR0B, CS01);
sbi(TCCR0B, CS00);
// enable timer 0 overflow interrupt
sbi(TIMSK0, TOIE0);
// timers 1 and 2 are used for phase-correct hardware pwm
// this is better for motors as it ensures an even waveform
// note, however, that fast pwm mode can achieve a frequency of up
// 8 MHz (with a 16 MHz clock) at 50% duty cycle
TCCR1B = 0;
// set timer 1 prescale factor to 64
sbi(TCCR1B, CS11);
sbi(TCCR1B, CS10);
// put timer 1 in 8-bit phase correct pwm mode
sbi(TCCR1A, WGM10);
sbi(TCCR3B, CS31); // set timer 3 prescale factor to 64
sbi(TCCR3B, CS30);
sbi(TCCR3A, WGM30); // put timer 3 in 8-bit phase correct pwm mode
sbi(TCCR4B, CS41); // set timer 4 prescale factor to 64
sbi(TCCR4B, CS40);
sbi(TCCR4A, WGM40); // put timer 4 in 8-bit phase correct pwm mode
sbi(TCCR5B, CS51); // set timer 5 prescale factor to 64
sbi(TCCR5B, CS50);
sbi(TCCR5A, WGM50); // put timer 5 in 8-bit phase correct pwm mode
// set a2d prescale factor to 128
// 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
// XXX: this will not work properly for other clock speeds, and
// this code should use F_CPU to determine the prescale factor.
sbi(ADCSRA, ADPS2);
sbi(ADCSRA, ADPS1);
sbi(ADCSRA, ADPS0);
// enable a2d conversions
sbi(ADCSRA, ADEN);
// the bootloader connects pins 0 and 1 to the USART; disconnect them
// here so they can be used as normal digital i/o; they will be
// reconnected in Serial.begin()
UCSR0B = 0;
}
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) )
// the prescaler is set so that timer0 ticks every 64 clock cycles, and the
// the overflow handler is called every 256 ticks.
#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))
// the whole number of milliseconds per timer0 overflow
#define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000)
// the fractional number of milliseconds per timer0 overflow. we shift right
// by three to fit these numbers into a byte. (for the clock speeds we care
// about - 8 and 16 MHz - this doesn't lose precision.)
#define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3)
#define FRACT_MAX (1000 >> 3)
SIGNAL(TIMER0_OVF_vect)
{
// copy these to local variables so they can be stored in registers
// (volatile variables must be read from memory on every access)
uint32_t m = timer0_millis;
uint8_t f = timer0_fract;
m += MILLIS_INC;
f += FRACT_INC;
if (f >= FRACT_MAX) {
f -= FRACT_MAX;
m += 1;
}
timer0_fract = f;
timer0_millis = m;
timer0_overflow_count++;
}
uint32_t AVRTimer::millis()
{
uint32_t m;
uint8_t oldSREG = SREG;
// disable interrupts while we read timer0_millis or we might get an
// inconsistent value (e.g. in the middle of a write to timer0_millis)
cli();
m = timer0_millis;
SREG = oldSREG;
return m;
}
uint32_t AVRTimer::micros() {
uint32_t m;
uint8_t t;
uint8_t oldSREG = SREG;
cli();
m = timer0_overflow_count;
t = TCNT0;
if ((TIFR0 & _BV(TOV0)) && (t < 255))
m++;
SREG = oldSREG;
return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
}
/* Delay for the given number of microseconds. Assumes a 16 MHz clock. */
void AVRTimer::delay_microseconds(uint16_t us)
{
// for the 16 MHz clock on most Arduino boards
// for a one-microsecond delay, simply return. the overhead
// of the function call yields a delay of approximately 1 1/8 us.
if (--us == 0)
return;
// the following loop takes a quarter of a microsecond (4 cycles)
// per iteration, so execute it four times for each microsecond of
// delay requested.
us <<= 2;
// account for the time taken in the preceeding commands.
us -= 2;
// busy wait
__asm__ __volatile__ (
"1: sbiw %0,1" "\n\t" // 2 cycles
"brne 1b" : "=w" (us) : "0" (us) // 2 cycles
);
}
#endif
| [
"jonathan2@Jonathans-MacBook-Pro.local"
] | jonathan2@Jonathans-MacBook-Pro.local |
6f9666831cc1602c86712e40ff9b992e176e4f2d | b505568bafb956c2d6bdc46cb09c3dfa5b8625ca | /filemanager.cpp | 5e34a3b64da8ac8a2466b2a746e5dd35a88e3741 | [
"Apache-2.0"
] | permissive | 2991535823/car | f1d0c1f96a8d37808ed8b887a3a55c76d29afd7f | ff8539c2cc169d9372d9f5eccf5d2e76d2b9e5f4 | refs/heads/main | 2023-05-25T19:53:03.147624 | 2021-06-02T11:54:54 | 2021-06-02T11:54:54 | 315,836,771 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,760 | cpp | #include "filemanager.h"
FileManager::FileManager(QObject *parent) : QObject(parent)
{
Q_UNUSED(parent)
if(createFolder(iniFolder))
{
setMapPath(MapFolder);
}
MapFolder=getMapPath();
DebugManager::v(MapFolder+"是目前的地图文件夹");
DebugManager::v(createFolder(MapFolder)?"地图文件夹创建":"地图文件夹存在");
startTimer(500);
setmaplist();
seteditfile(_maplist.size()>0?_maplist.first():"no file.json");
DebugManager::d("file manager create");
}
FileManager::~FileManager()
{
//写入日志
if(!createFile("carlog",".log",MapFolder))
{
QJsonObject temp;
temp.insert("creat",QDateTime::currentDateTime().toString());
temp.insert("log",logarray);
writefile("carlog",temp,".log",MapFolder);
}
_file->close();
delete _file;
DebugManager::d("file manager destory");
}
bool FileManager::doCmd(FileManager::Cmd cmd)
{
Q_UNUSED(cmd)
bool code=false;
switch (cmd) {
case Start:
code=startCollection();
break;
case Stop:
code=stopCollection();
break;
case Done:
code=doneCollection();
break;
case Delete:
code=deleteFile(_editfile,MapFolder);
break;
default:
break;
}
return code;
}
bool FileManager::setParms(QString filename)
{
//创建一个地图
_filename=filename;
clearMapData();
QJsonObject jsonObject;
// QJsonDocument jsonDoc;
bool fileExit=_file->exists(MapFolder+_filename+Suffix);
QString filestatus=fileExit?"Edit":"Create";
QDateTime time=QDateTime::currentDateTime();
if(fileExit){
jsonObject = readFile(filename,Suffix,MapFolder);
}else {
createFile(filename,Suffix,MapFolder);
}
jsonObject.insert(filestatus,time.toString());
writefile(filename,jsonObject,Suffix,MapFolder);
return true;
}
void FileManager::createmap(QString filename)
{
_filename=filename;
createFile(filename,Suffix,MapFolder);
}
//开放给MapManager和Cmd的接口
QJsonObject FileManager::getmap(QString filename, bool orNotToMap)
{
if(filename.indexOf(".json")!=-1)
{
filename.remove(".json");
}
QJsonObject temp=readFile(filename,Suffix,MapFolder);//下面的代码可以优化
if(orNotToMap)//发送给地图
{
QJsonArray pointmsgs= temp["data"].toArray();
QJsonArray returnPointMsgs;
QJsonObject t;
for(auto &&i:pointmsgs)
{
QStringList info=i.toString().split(',');
t["x"]=info[10];
t["y"]=info[9];
returnPointMsgs.append(t);
}
temp["data"]=returnPointMsgs;
return temp;
}else {//发送给cmd
QJsonArray pointmsgs= temp["data"].toArray();
QJsonArray returnPointMsgs;
for(auto &&i:pointmsgs)
{
QStringList msgs=i.toString().split(',');
returnPointMsgs.append(msgs[9]+','+msgs[10]);
}
temp.insert("data",returnPointMsgs);
return temp;
}
}
//设置编辑的地图
void FileManager::seteditfile(QString name)
{
if(_editfile!=name)
{
_editfile=name;
}
DebugManager::i("_editfile:"+_editfile);
emit editfileUpdata(_editfile);
}
QString FileManager::geteditfile()
{
return _editfile;
}
//采集一个地图点数据
bool FileManager::startCollection()
{
if(DataCheck::checkFormat(gpsData))//正则校验
{
if(map.last()!=gpsData&&DataCheck::checkEffect(gpsData))//有效性校验
{
map.append(gpsData);
return true;
}else {
DebugManager::v("小车位置没有变动,或校验位出错,采集停止");
}
}else {
QMessageBox::information(NULL, "提示信息", "地图数据不符合要求,请检查串口!",
QMessageBox::Yes);
}
return false;
}
bool FileManager::stopCollection()
{
if(map.size()>0)
{
map.pop_back();
}
return true;
}
//完成采集。写入数据
bool FileManager::doneCollection()
{
QJsonObject jsonobj=readFile(_filename,Suffix,MapFolder);
jsonobj.insert("data",map);
writefile(_filename,jsonobj,Suffix,MapFolder);
clearMapData();
return true;
}
//写日志
void FileManager::writeLog(QString data)
{
logarray.append(data);
}
//删除文件
bool FileManager::deleteFile(QString filename, QString folder)
{
QFile *deletefile=new QFile(folder+filename);
return deletefile->remove();
}
//读文件内容
QJsonObject FileManager::readFile(QString filename, QString suffix, QString folder)
{
_file=new QFile(folder+filename+suffix);
QJsonParseError error;
QJsonObject tempobj;
QJsonDocument tempdoc;
if(_file->exists()){
if(_file->open(QIODevice::ReadOnly|QIODevice::Text))
{
tempdoc=QJsonDocument::fromJson(_file->readAll(),&error);
tempobj=tempdoc.object();
_file->close();
}
}
return tempobj;
}
//写文件
bool FileManager::writefile(QString filename, QJsonObject obj, QString suffix, QString folder)
{
_file->setFileName(folder+filename+suffix);
bool code=false;
if(_file->exists()){
if(_file->open(QIODevice::ReadWrite|QIODevice::Truncate))
{
QJsonDocument _doc(obj);
_file->write(_doc.toJson());
_file->close();
code=true;
}else {
code=false;
}
}
return code;
}
//得到地图List
QStringList FileManager::getmaplist()
{
return _maplist;
}
//得到采集的地图点
int FileManager::getNodeSize()
{
return _nodesize;
}
//创建文件
bool FileManager::createFile(QString filename, QString suffix, QString folder)
{
bool code=false;
_file=new QFile(folder+filename+suffix);
if(!_file->exists())
{
code=_file->open(QIODevice::ReadWrite|QIODevice::Text);
_file->close();
}
return code;
}
//创建文件
bool FileManager::createFolder(QString folder)
{
bool code=false;
if(!dir.exists(folder)){
code=dir.mkdir(folder);
}
return code;
}
//更新地图列表信息
void FileManager::setmaplist()
{
QDir dir(MapFolder);
QStringList list;
QFileInfoList infolist=dir.entryInfoList();
for(auto &&i:infolist){
if(i.suffix()=="json")
{
list.append(i.fileName());
}
}
if(_maplist!=list){
_maplist=list;
emit maplistupdata();
}
}
//设置该类的Serial的对象
void FileManager::setserial(SerialManager *manager)
{
_serial = manager;
static int limit=0;
if(limit==0)
{
connect(_serial,&SerialManager::readDone,this,&FileManager::readSerial);
}
limit++;
}
SerialManager *FileManager::getSerial()
{
return _serial;
}
//设置采集数据的个数
void FileManager::setNodeSize()
{
if(_nodesize!=map.size())
{
_nodesize=map.size();
emit nodeSizeUpdata();
}
}
//清楚地图数据
bool FileManager::clearMapData()
{
int length=map.size();
for(int i=0;i<length ;i++)
{
map.removeFirst();
}
return true;
}
//得到地图文件存放的路径
QString FileManager::getMapPath()
{
if(createFile("settings",".ini",iniFolder))
{
DebugManager::d("配置文件不存在,开始进行设置......");
setMapPath(MapFolder);
return MapFolder;
}else {
QJsonObject temp=readFile("settings",".ini",iniFolder);
QJsonValue path=temp["mapfolder"];
return path.toString();
}
}
//设置地图文件存放的路径
bool FileManager::setMapPath(QString MapPath)
{
//这两行代码重要
MapPath.remove("file:///");
MapPath.append('/');
if(createFile("settings",".ini",iniFolder))
{
//第一次创建
QJsonObject temp;
temp.insert("mapfolder",MapPath);
writefile("settings",temp,".ini",iniFolder);
emit mapPathUpdata();
}else {
QJsonObject temp=readFile("settings",".ini",iniFolder);
QJsonValue path=temp["mapfolder"];
if(path!=MapPath)
{
temp.insert("mapfolder",MapPath);
writefile("settings",temp,".ini",iniFolder);
emit mapPathUpdata();
QMessageBox::information(NULL,"提示","修改了地图存放路径,必须重启软件加载设置",QMessageBox::Yes);
}
}
return true;//不规范,需要改
}
//槽函数
void FileManager::readSerial(const QString msg)
{
gpsData=msg;
writeLog(msg);
}
//重写事件
void FileManager::timerEvent(QTimerEvent *event)
{
Q_UNUSED(event)
setmaplist();
setNodeSize();
}
| [
"2991535823@qq.com"
] | 2991535823@qq.com |
6074bb93e8748025a1be1130bdd750909563be55 | 4a2c5dc402424bb12b02e667b4f5dbc1add90307 | /src/Helper/BitOperation.hpp | b27679ae8a10f18cbd01d6843b1464b838fedde5 | [] | no_license | knshnb/competitive_library | 75ff92101fc617f8e55090e77d42f5838863d01a | 54c93ca8056580fc73f83168353bb1298562ded1 | refs/heads/master | 2021-06-04T15:43:40.397585 | 2021-05-07T16:29:46 | 2021-05-07T16:29:46 | 150,403,917 | 6 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 105 | hpp |
// Sの部分集合の列挙
for (int T = S;; T = (T - 1) & S) {
// 操作
if (T == 0) break;
}
| [
"abe.kenshin@gmail.com"
] | abe.kenshin@gmail.com |
4a3e9160c6484ef8fcb34f22c34c830a4b9b1d82 | e014040a3bd59b9178c4f11a42b0abcfc1fc9abb | /Source/DirectWrite/Sample.cpp | 6f27fa7e7d42db7b98ed5d01adf193a045ea4270 | [] | no_license | tonnac/D3D11 | c68ee5d92f08da26f960905baee7d5546da59a61 | 4a8275b057444646fe6bffc076400db02f5c1acc | refs/heads/master | 2021-07-18T14:34:22.956587 | 2019-01-22T16:52:15 | 2019-01-22T16:52:15 | 147,910,342 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 846 | cpp | #include "Sample.h"
Sample::Sample()
{
}
bool Sample::Init()
{
m_DirectWrite.Init();
IDXGISwapChain * pSwapChain = getSwapChain();
IDXGISurface* pSurface = nullptr;
pSwapChain->GetBuffer(0, __uuidof(IDXGISurface), (LPVOID*)&pSurface);
m_DirectWrite.Set(pSurface);
pSurface->Release();
return true;
}
bool Sample::Frame()
{
return true;
}
bool Sample::Render()
{
m_DirectWrite.Begin();
D2D1_RECT_F pe = D2D1::RectF(0, 0, static_cast<FLOAT>(g_rtClient.right), static_cast<FLOAT>(g_rtClient.bottom));
m_DirectWrite.DrawText(pe,L"HelloWorld",D2D1::ColorF::Tan);
m_DirectWrite.End();
return true;
}
bool Sample::Release()
{
return true;
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE prevInst, LPWSTR szCmdLine, int nCmdShow)
{
Sample wd;
wd.InitWindow(hInstance, 800, 600, nCmdShow, L"FullScreen");
wd.Run();
return 0;
} | [
"tonnac35@gmail.com"
] | tonnac35@gmail.com |
66689235d1bf3fdb30aa9fd054e6432b208f35b0 | e3337d3395ec69eaa85898f64514557da279d124 | /freq_vis_rx.ino | cec042978f621e7d3d7ed767fbb58b60ebd2ec65 | [] | no_license | gsalaman/freq_vis_rx | 4ce3a9c891a1d074acd3803e959cab276d0aa78a | 1e244f03f38efdc15e4b3db6d6184f2c913c03bc | refs/heads/master | 2020-04-23T23:11:20.934656 | 2019-02-20T18:16:18 | 2019-02-20T18:16:18 | 171,527,010 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,300 | ino | // This is the receive module for the frequency visualizer.
// Brute force iteration: display on 64x32, use mega. Use Serial1 (pins 18 and 19) for com with tx side.
// Go to 21 bins for the cool rectangle effect.
#include "SoftwareSerial.h"
// These two defines are for the RGB Matrix
#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
// Pin defines for the 32x32 RGB matrix.
#define CLK 11
#define LAT 10
#define OE 9
#define A A0
#define B A1
#define C A2
#define D A3
/* Other Pin Mappings...hidden in the RGB library:
* Sig Uno Mega
* R0 2 24
* G0 3 25
* B0 4 26
* R1 5 27
* G1 6 28
* B1 7 29
*/
// Note "false" for double-buffering to consume less memory, or "true" for double-buffered.
// Double-buffered makes updates look smoother.
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, true, 64);
// Must match the TX side!
#define FREQ_BINS 21
int freq[FREQ_BINS];
int freq_hist[FREQ_BINS]={0};
#define START_CHAR 's'
// Color pallete for spectrum...cooler than just single green.
uint16_t spectrum_colors[] =
{
matrix.Color444(7,0,0), // index 0
matrix.Color444(6,1,0), // index 1
matrix.Color444(5,2,0), // index 2
matrix.Color444(4,3,0), // index 3
matrix.Color444(3,4,0), // index 4
matrix.Color444(2,5,0), // index 5
matrix.Color444(1,6,0), // index 6
matrix.Color444(0,7,0), // index 7
matrix.Color444(0,6,1), // index 8
matrix.Color444(0,5,2), // index 9
matrix.Color444(0,4,3), // index 10
matrix.Color444(0,3,4), // index 11
matrix.Color444(0,2,5), // index 12
matrix.Color444(0,1,6), // index 13
matrix.Color444(0,0,7), // index 14
matrix.Color444(1,0,6), // index 15
matrix.Color444(2,0,5), // index 16
matrix.Color444(3,0,4), // index 17
matrix.Color444(4,0,3), // index 18
matrix.Color444(5,0,2), // index 19
matrix.Color444(6,0,1), // index 20
matrix.Color444(7,0,0), // index 21
};
void setup()
{
matrix.begin();
Serial.begin(9600);
Serial1.begin(38400);
Serial.println("Freq RX initialized");
}
typedef enum
{
WAIT_FOR_BUFFER,
PROCESS_BUFFER
} state_type;
state_type current_state=WAIT_FOR_BUFFER;
void print_freq_results( void )
{
int i;
for (i = 0; i < FREQ_BINS; i++)
{
Serial.print( freq[i] );
Serial.print(" ");
}
Serial.println();
Serial.println("====================");
}
void display_freq_raw( void )
{
int i;
int mag;
int x;
matrix.fillScreen(0);
// we have 32 freq bins, but I want to each bin to be 3 wide.
// This means I'm going from bins 1 to 21 (which gets us to 63)
for (i = 0; i < FREQ_BINS; i++)
{
mag = freq[i];
x = i*3;
matrix.drawRect(x,32,3,0-mag, spectrum_colors[i]);
}
matrix.swapBuffers(true);
}
void display_freq_decay( void )
{
int i;
int mag;
int x;
matrix.fillScreen(0);
// we have 32 freq bins, but I want to each bin to be 3 wide.
// This means I'm going from bins 1 to 21 (which gets us to 63)
for (i = 0; i < FREQ_BINS; i++)
{
mag = freq[i];
// check if current magnitude is smaller than our recent history.
if (mag < freq_hist[i])
{
// decay by 1...but only if we're not going negative
if (freq_hist[i])
{
mag = freq_hist[i] - 1;
}
}
// store new value...this will either be the new max or the new "decayed" value.
freq_hist[i] = mag;
x = i*3;
matrix.drawRect(x,32,3,0-mag, spectrum_colors[i]);
}
matrix.swapBuffers(true);
}
void loop()
{
char c;
int buff_index;
while (Serial1.available())
{
c = Serial1.read();
switch (current_state)
{
case WAIT_FOR_BUFFER:
if (c == START_CHAR)
{
buff_index = 0;
current_state = PROCESS_BUFFER;
}
break;
case PROCESS_BUFFER:
freq[buff_index] = c;
buff_index++;
if (buff_index == FREQ_BINS)
{
//print_freq_results();
display_freq_raw();
current_state = WAIT_FOR_BUFFER;
}
break;
} // end switch on state
} // end while xbee available.
} // end of loop
| [
"43499190+gsalaman@users.noreply.github.com"
] | 43499190+gsalaman@users.noreply.github.com |
559997dad1f18bcb0fd790760fae0b793d9d8b35 | e773d41ff293c1c0b7f1968a26cc5764e00667bb | /libcef_dll_wrapper/ctocpp/test/translator_test_ref_ptr_library_ctocpp.cc | 88e893ebc00588ace7db23d1b9482fe01852058a | [] | no_license | yufanghu/fec | 43794ac187d3c1aa84bd4e660f5272c8addf830a | 87be1c1238ff638ed4c5488cf5f0701b78e4b82f | refs/heads/master | 2021-03-27T12:33:52.573027 | 2017-12-01T10:18:38 | 2017-12-01T10:18:38 | 108,273,897 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,462 | cc | // Copyright (c) 2017 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=adb8d1b6439ca458cb11aef7abda5c962988ca29$
//
#include "ctocpp/test/translator_test_ref_ptr_library_ctocpp.h"
#include "ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.h"
#include "ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.h"
// STATIC METHODS - Body may be edited by hand.
CefRefPtr<CefTranslatorTestRefPtrLibrary>
CefTranslatorTestRefPtrLibrary::Create(int value) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_translator_test_ref_ptr_library_t* _retval =
cef_translator_test_ref_ptr_library_create(value);
// Return type: refptr_same
return CefTranslatorTestRefPtrLibraryCToCpp::Wrap(_retval);
}
// VIRTUAL METHODS - Body may be edited by hand.
int CefTranslatorTestRefPtrLibraryCToCpp::GetValue() {
cef_translator_test_ref_ptr_library_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_value))
return 0;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = _struct->get_value(_struct);
// Return type: simple
return _retval;
}
void CefTranslatorTestRefPtrLibraryCToCpp::SetValue(int value) {
cef_translator_test_ref_ptr_library_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, set_value))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
_struct->set_value(_struct, value);
}
// CONSTRUCTOR - Do not edit by hand.
CefTranslatorTestRefPtrLibraryCToCpp::CefTranslatorTestRefPtrLibraryCToCpp() {}
template <>
cef_translator_test_ref_ptr_library_t*
CefCToCppRefCounted<CefTranslatorTestRefPtrLibraryCToCpp,
CefTranslatorTestRefPtrLibrary,
cef_translator_test_ref_ptr_library_t>::
UnwrapDerived(CefWrapperType type, CefTranslatorTestRefPtrLibrary* c) {
if (type == WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD) {
return reinterpret_cast<cef_translator_test_ref_ptr_library_t*>(
CefTranslatorTestRefPtrLibraryChildCToCpp::Unwrap(
reinterpret_cast<CefTranslatorTestRefPtrLibraryChild*>(c)));
}
if (type == WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD) {
return reinterpret_cast<cef_translator_test_ref_ptr_library_t*>(
CefTranslatorTestRefPtrLibraryChildChildCToCpp::Unwrap(
reinterpret_cast<CefTranslatorTestRefPtrLibraryChildChild*>(c)));
}
NOTREACHED() << "Unexpected class type: " << type;
return NULL;
}
#if DCHECK_IS_ON()
template <>
base::AtomicRefCount CefCToCppRefCounted<
CefTranslatorTestRefPtrLibraryCToCpp,
CefTranslatorTestRefPtrLibrary,
cef_translator_test_ref_ptr_library_t>::DebugObjCt ATOMIC_DECLARATION;
#endif
template <>
CefWrapperType
CefCToCppRefCounted<CefTranslatorTestRefPtrLibraryCToCpp,
CefTranslatorTestRefPtrLibrary,
cef_translator_test_ref_ptr_library_t>::kWrapperType =
WT_TRANSLATOR_TEST_REF_PTR_LIBRARY;
| [
"fibonacci2016@126.com"
] | fibonacci2016@126.com |
137c07019da2a9b7ed7b54de2508be994e7060a8 | 1b37a068a73fadb65dfc2f7f1c01c6f4285f868d | /PyNGL/src/PyQuaternion.cpp | fcbfec1e88cb1a7552b3f38687df0e01fef903de | [] | no_license | NCCA/NGL | 06906150a8444c6ec9be5a1674f736962eb91756 | e22cb142e879399835de53feadb8a06aded2e48c | refs/heads/main | 2023-06-19T10:27:06.802876 | 2023-06-14T08:07:57 | 2023-06-14T08:07:57 | 24,201,375 | 104 | 40 | null | 2022-10-31T18:20:15 | 2014-09-18T19:11:22 | C++ | UTF-8 | C++ | false | false | 2,339 | cpp | #include "PyBindIncludes.h"
#include "Quaternion.h"
namespace py = pybind11;
namespace ngl
{
void pyInitQuaternion(py::module & m)
{
py::class_<Quaternion>(m, "Quaternion")
.def(py::init<>())
.def(py::init<Real,Real,Real,Real>())
.def(py::init<const Mat4 &>())
.def(py::init<const Vec3 &>())
.def(py::init<const Quaternion &>())
.def("set",&Quaternion::set)
.def("getS",&Quaternion::getS)
.def("getX",&Quaternion::getX)
.def("getY",&Quaternion::getY)
.def("getZ",&Quaternion::getZ)
.def("getVector",&Quaternion::getVector)
.def("setVector",&Quaternion::setVector)
.def("setS",&Quaternion::setS)
.def("setX",&Quaternion::setX)
.def("setY",&Quaternion::setY)
.def("setZ",&Quaternion::setZ)
.def("normalise",&Quaternion::normalise)
.def("magnitude",&Quaternion::magnitude)
.def("conjugate",&Quaternion::conjugate)
.def("inverse",&Quaternion::inverse)
.def("slerp",&Quaternion::slerp)
.def("rotateX",&Quaternion::rotateX)
.def("rotateY",&Quaternion::rotateY)
.def("rotateZ",&Quaternion::rotateZ)
.def("fromAxisAngle",&Quaternion::fromAxisAngle)
.def("fromEulerAngles",&Quaternion::fromEulerAngles)
.def("rotatePoint",&Quaternion::rotatePoint)
.def("toAxisAngle",&Quaternion::toAxisAngle)
.def("toMat4",&Quaternion::toMat4)
.def("toMat4Transpose",&Quaternion::toMat4Transpose)
.def(py::self + py::self)
.def(py::self * py::self)
.def(py::self *= py::self)
.def(py::self * Real())
.def(py::self * Vec4())
.def(py::self *= Real())
.def(py::self - py::self)
.def(py::self += py::self)
.def(py::self -= py::self)
.def(py::self == py::self)
.def("__neg__",py::overload_cast<> (&Quaternion::operator-))
.def("__neg__",py::overload_cast<> (&Quaternion::operator- ,py::const_))
.def("__repr__",
[](const Quaternion &v) {
return std::to_string(v.getS())+"["+
std::to_string(v.getX())+","+
std::to_string(v.getY())+","+
std::to_string(v.getZ())
+"]";})
;
}
}
| [
"jmacey@bournemouth.ac.uk"
] | jmacey@bournemouth.ac.uk |
44f4e53bea12aa2464ed138cc0afe7d6d4511db0 | 87f1abe25c14be3d109cf8f5d1a4c7544347f4a6 | /include/ForegroundSystemLauncher.h | 4a0dccf1c60263c00a4737cd975743375b4cfbe7 | [
"Apache-2.0"
] | permissive | claremacrae/cppp2019 | 36d0cd8d6d1bf46a38d9775e581e3c5de44b2548 | ab6826322b9295ed43208b576e1bbf736bada1dc | refs/heads/master | 2020-06-03T13:55:36.956763 | 2019-09-03T14:04:14 | 2019-09-03T14:04:14 | 191,594,236 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,243 | h | #ifndef CPPP2019_FOREGROUNDSYSTEMLAUNCHER_H
#define CPPP2019_FOREGROUNDSYSTEMLAUNCHER_H
#include "ApprovalTests.hpp"
// Based on SystemLauncher, and differs in that it runs the command in
// the foreground instead of the background, so that any text output is
// interleaved in with the output from the test framework.
class ForegroundSystemLauncher : public CommandLauncher
{
public:
bool launch(std::vector<std::string> argv) override
{
SystemLauncher temp_launcher;
if (!temp_launcher.exists(argv.front()))
{
return false;
}
// Surround each of the arguments by double-quotes:
const std::string command = std::accumulate(
argv.begin(), argv.end(), std::string(""),
[](std::string a, std::string b) {return a + " " + "\"" + b + "\""; });
// See https://stackoverflow.com/a/9965141/104370 for why the Windows string is so complex:
const std::string launch = SystemUtils::isWindowsOs() ?
(std::string("cmd /S /C ") + "\"" + command + "\"") :
(command);
system(launch.c_str());
return true;
}
};
#endif //CPPP2019_FOREGROUNDSYSTEMLAUNCHER_H
| [
"github@cfmacrae.fastmail.co.uk"
] | github@cfmacrae.fastmail.co.uk |
26d6861ed4f91f0393dfd4c27db3b7e416c8bdfe | 5c12b628558371d486a6e1eb04b07e6918f54bef | /Object Oriented Programming/Laboratories/Lab14/main.cpp | e5938cbd59d020b4b7c0d7a1383067edbe7ff403 | [] | no_license | adelinmihoc/University | b8b488e73d826aa3a73adba33c384e6cb70a3f4b | aa64ef81a542f67d3a76925b1ee3cf7d3f002d61 | refs/heads/main | 2023-06-07T07:47:03.072025 | 2021-07-10T13:33:05 | 2021-07-10T13:33:05 | 356,818,055 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,473 | cpp | #include "mainwindow.h"
#include <QApplication>
#include <QLineEdit>
#include <QInputDialog>
#include <QMessageBox>
#include "Backend/controller.h"
Controller* load_settings();
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
Controller* ctrl = load_settings();
if (ctrl != nullptr) {
MainWindow w{ctrl};
w.test_backend();
w.show();
return a.exec();
}
}
Controller* load_settings() {
bool ok;
QString text = QInputDialog::getText(NULL, ("Configure settings"),
("Config file path:"), QLineEdit::Normal,
"config.txt", &ok);
std::ifstream f{text.toStdString()};
if (!ok || !f.is_open() || f.peek() == std::istream::traits_type::eof()) {
QMessageBox::critical(NULL, ("Error"), ("Unable to load settings"));
return nullptr;
}
std::string admin_repository_type;
std::string user_repository_type;
getline(f, admin_repository_type);
getline(f, user_repository_type);
std::string filename;
if (admin_repository_type == "memory") {
Repository* admin_repo = new Repository{};
if (user_repository_type == "memory") {
Repository* user_repo = new Repository{};
Controller* ctrl = new Controller{admin_repo, user_repo};
return ctrl;
} else if (user_repository_type == "csv_file") {
Repository* user_repo = new Csv_file{filename};
Controller* ctrl = new Controller{admin_repo, user_repo};
return ctrl;
} else if (user_repository_type == "html_file") {
Repository* user_repo = new Html_file{filename};
Controller* ctrl = new Controller{admin_repo, user_repo};
return ctrl;
} else {
return nullptr;
}
} else if (admin_repository_type == "csv_file") {
Repository* admin_repo = new Csv_file{filename};
if (user_repository_type == "memory") {
Repository* user_repo = new Repository{};
Controller* ctrl = new Controller{admin_repo, user_repo};
return ctrl;
} else if (user_repository_type == "csv_file") {
Repository* user_repo = new Csv_file{filename};
Controller* ctrl = new Controller{admin_repo, user_repo};
return ctrl;
} else if (user_repository_type == "html_file") {
Repository* user_repo = new Html_file{filename};
Controller* ctrl = new Controller{admin_repo, user_repo};
return ctrl;
} else {
return nullptr;
}
} else if (admin_repository_type == "html_file") {
Repository* admin_repo = new Html_file{filename};
if (user_repository_type == "memory") {
Repository* user_repo = new Repository{};
Controller* ctrl = new Controller{admin_repo, user_repo};
return ctrl;
} else if (user_repository_type == "csv_file") {
Repository* user_repo = new Csv_file{filename};
Controller* ctrl = new Controller{admin_repo, user_repo};
return ctrl;
} else if (user_repository_type == "html_file") {
Repository* user_repo = new Html_file{filename};
Controller* ctrl = new Controller{admin_repo, user_repo};
return ctrl;
} else {
return nullptr;
}
}
return nullptr;
}
| [
"adelinmihoc@gmail.com"
] | adelinmihoc@gmail.com |
942e8c3ef7d199d9b31ca0dfee2c1ce5f6d25eca | 1eacb6124e13c8c9527ad6c2457dc458f3ccc161 | /algorithms/quick_sort.cpp | 516f96cea1971ab1377ef04ba01a642b07e5216f | [] | no_license | zhaogaowei/algorithms | b195142197f26bc1bc5db304cf2e4fe716499eab | 2ba709dbaa63b18bf2571a965374d5725f536bb2 | refs/heads/master | 2021-08-30T18:33:04.614909 | 2017-12-19T01:27:33 | 2017-12-19T01:27:33 | 108,709,789 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 753 | cpp | #include<iostream>
#include<iomanip>
using namespace std;
size_t partition(int *, int, int);
void quickSort(int *, int, int);
//int main() {
// int a[] = { -65536,2,8,7,1,3,5,6,4 };
// quickSort(a,1,8);
// for (int i = 1; i < 9; ++i)
// cout << left << setw(3) << a[i];
// cout << endl;
// cin.get();
// return 0;
//}
size_t partition(int *arr, int l, int h) {
int x = arr[h];
int i = l - 1;
for (int j = l; j < h; ++j) {
if (arr[j] < x) {
i++;
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
int temp = arr[i + 1];
arr[i + 1] = arr[h];
arr[h] = temp;
return i + 1;
}
void quickSort(int *arr, int l, int h) {
if (l < h) {
int q = partition(arr, l, h);
quickSort(arr, l, q - 1);
quickSort(arr, q + 1, h);
}
}
| [
"489524001@qq.com"
] | 489524001@qq.com |
eb98c155e9377dd5bd2931dd0eabe5ecb3755afe | b9593d1a32fb132de18a9ffe36c826b1b26eaffb | /win32/boost/boost/mpl/aux_/msvc_is_class.hpp | 21cccc0cfe925f98046c33fb75c1227ef6829df9 | [
"BSL-1.0"
] | permissive | autofax/sfftobmp_copy | 8f8b3b0d9bec2cff6d81bb6855e34f4d54f9d7eb | 6058b7c0df917af19b4b27003a189cf71bade801 | refs/heads/master | 2020-12-02T16:36:16.956519 | 2017-07-07T17:10:57 | 2017-07-07T17:10:57 | 96,559,550 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,573 | hpp |
#ifndef BOOST_MPL_AUX_MSVC_IS_CLASS_HPP_INCLUDED
#define BOOST_MPL_AUX_MSVC_IS_CLASS_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2002-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id: msvc_is_class.hpp,v 1.1 2009/08/23 12:39:08 pschaefer Exp $
// $Date: 2009/08/23 12:39:08 $
// $Revision: 1.1 $
#include <boost/mpl/if.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/aux_/type_wrapper.hpp>
#include <boost/mpl/aux_/yes_no.hpp>
#include <boost/type_traits/is_reference.hpp>
namespace boost { namespace mpl { namespace aux {
template< typename T > struct is_class_helper
{
typedef int (T::* type)();
};
// MSVC 6.x-specific lightweight 'is_class' implementation;
// Distinguishing feature: does not instantiate the type being tested.
template< typename T >
struct msvc_is_class_impl
{
template< typename U>
static yes_tag test(type_wrapper<U>*, /*typename*/ is_class_helper<U>::type = 0);
static no_tag test(void const volatile*, ...);
enum { value = sizeof(test((type_wrapper<T>*)0)) == sizeof(yes_tag) };
typedef bool_<value> type;
};
// agurt, 17/sep/04: have to check for 'is_reference' upfront to avoid ICEs in
// complex metaprograms
template< typename T >
struct msvc_is_class
: if_<
is_reference<T>
, false_
, msvc_is_class_impl<T>
>::type
{
};
}}}
#endif // BOOST_MPL_AUX_MSVC_IS_CLASS_HPP_INCLUDED
| [
"gerald.schade@gmx.de"
] | gerald.schade@gmx.de |
a85bd60bc1774c87bb350d9047d47dd3c1900952 | 887c1e9fc5364a03cc16a6f74a13490061f0d851 | /commands.h | c52ac4db530f8a7c3f36b2e77c2c253685eecf79 | [] | no_license | ivelin-petrov/Project-17---Raster-graphics | 50e0ed1f70455af1da9336864cdc2c21a43e6b28 | 5cdbafb787b4cebd500636848f59c7175e09e7c9 | refs/heads/master | 2022-08-03T19:53:12.226498 | 2020-05-31T20:54:23 | 2020-05-31T20:54:23 | 268,353,710 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 948 | h | #ifndef COMMANDS_H__
#define COMMANDS_H__
#include <fstream>
#include "session.h"
class Commands{
public:
static Session load(const std::string& image);
static void help();
static void serialization(const Session& session);
static Session deserialization(int _ID);
static void choices(const std::string& line, Session& session);
static Session open(const std::string& file_name); // in this project functions 'load' and 'deserialization' are used instead of open
static void close(const std::string& file_name, const Session& session);
static void save(Session& session); // saves all images
static void saveas(Session& session, const std::string& new_file); // saves only the first image in a new file
static bool foundID(int _ID);
static Session _switch(int _ID); // session's ID
static void exit();
};
#endif | [
"noreply@github.com"
] | ivelin-petrov.noreply@github.com |
ab11523906f7d21cf732afa4210809ed2a3e9a4d | c2e2b0f27b7fa686f00cd846020fd2999e0197f4 | /novelhost.h | 39946fac4f568788625a4ce1e3fe8292ab6edde6 | [] | no_license | heisehuanyin/PlainWriter | 78832207caf44d2cc4830f89614b62b1d5d26560 | 4f73b3e03012f63e469d349bba4ca5298f1de550 | refs/heads/main | 2023-03-08T22:44:16.824615 | 2021-03-15T07:56:41 | 2021-03-15T07:56:41 | 347,880,923 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,524 | h | #ifndef NOVELHOST_H
#define NOVELHOST_H
#include "confighost.h"
#include "dbaccess.h"
#include <QItemDelegate>
#include <QRandomGenerator>
#include <QRunnable>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QSyntaxHighlighter>
class NovelHost;
namespace NovelBase {
class ChaptersItem : public QObject, public QStandardItem
{
Q_OBJECT
public:
ChaptersItem(NovelHost&host, const DBAccess::StoryTreeNode &refer, bool isGroup=false);
virtual ~ChaptersItem() override = default;
public slots:
void calcWordsCount();
private:
NovelHost &host;
};
class OutlinesItem : public QObject, public QStandardItem
{
Q_OBJECT
public:
OutlinesItem(const DBAccess::StoryTreeNode &refer);
};
class OutlinesRender : public QSyntaxHighlighter
{
public:
OutlinesRender(QTextDocument *doc, ConfigHost &config);
// QSyntaxHighlighter interface
protected:
virtual void highlightBlock(const QString &text) override;
private:
ConfigHost &config;
};
class WordsRender : public QSyntaxHighlighter
{
Q_OBJECT
public:
WordsRender(QTextDocument *target, NovelHost &novel_host);
virtual ~WordsRender() override;
ConfigHost &configBase() const;
void acceptRenderResult(const QString &content, const QList<std::tuple<QString, int, QTextCharFormat, int, int> > &rst);
// QSyntaxHighlighter interface
protected:
virtual void highlightBlock(const QString &text) override;
private:
QMutex mutex;
NovelHost &novel_host;
// format : keyword-id : start : length
QHash<QString, QList<std::tuple<QString, int, QTextCharFormat, int, int>>> _result_store;
bool _check_extract_render_result(const QString &text, QList<std::tuple<QString, int, QTextCharFormat, int, int> > &rst);
};
class WordsRenderWorker : public QObject, public QRunnable
{
Q_OBJECT
public:
WordsRenderWorker(WordsRender *poster, const QTextBlock pholder, const QString &content);
// QRunnable interface
public:
virtual void run() override;
signals:
void renderFinished(const QTextBlock blk);
private:
WordsRender *const poster_stored;
ConfigHost &config_symbo;
const QTextBlock placeholder;
const QString content_stored;
void keywords_highlighter_render(const QString &text, QList<std::tuple<QString, int, QString> > words, const QTextCharFormat &format,
QList<std::tuple<QString, int, QTextCharFormat, int, int> > &rst) const;
};
class WsBlockData : public QTextBlockUserData
{
public:
using Type = DBAccess::StoryTreeNode::Type;
WsBlockData(const QModelIndex &target, Type blockType);
virtual ~WsBlockData() = default;
bool operator==(const WsBlockData &other) const;
QModelIndex navigateIndex() const;
Type blockType() const;
private:
const QModelIndex outline_index; // 指向大纲树节点
Type block_type;
};
class DesplineFilterModel : public QSortFilterProxyModel
{
public:
enum Type{
UNDERVOLUME,
UNTILWITHVOLUME,
UNTILWITHCHAPTER
};
explicit DesplineFilterModel(Type operateType, QObject*parent=nullptr);
void setFilterBase(const DBAccess::StoryTreeNode &volume_node, const DBAccess::StoryTreeNode
&chapter_node = DBAccess::StoryTreeNode());
// QSortFilterProxyModel interface
protected:
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
private:
Type operate_type_store;
int volume_filter_index;
QVariant chapter_filter_id;
};
}
class NovelHost : public QObject
{
Q_OBJECT
using KfvType = NovelBase::DBAccess::KeywordField::ValueType;
public:
explicit NovelHost(ConfigHost &config);
virtual ~NovelHost() override;
/**
* @brief 载入作品描述文件
* @param desp 描述文件实例
*/
void loadBase(NovelBase::DBAccess *desp);
void save();
QString novelTitle() const;
void resetNovelTitle(const QString &title);
/**
* @brief 所有关键字类型清单
* @return
*/
QAbstractItemModel *keywordsTypeslistModel() const;
/**
* @brief 添加新关键字类型到模型
* @param name
* @return
*/
QAbstractItemModel *appendKeywordsModelToTheList(const QString &name);
/**
* @brief 通过类型列表ModelIndex获取指定关键字的管理模型
* @param mindex 类型列表的ModelIndex
* @return
*/
QAbstractItemModel *keywordsModelViaTheList(const QModelIndex &mindex) const;
/**
* @brief 通过类型列表的ModelIndex移除指定管理模型
* @param mindex
*/
void removeKeywordsModelViaTheList(const QModelIndex &mindex);
void keywordsTypeForward(const QModelIndex &mindex);
void keywordsTypeBackward(const QModelIndex &mindex);
void getAllKeywordsTableRefs(QList<QPair<QString, QString>> &name_ref_list) const;
QList<QPair<int,std::tuple<QString, QString, KfvType>>>
customedFieldsListViaTheList(const QModelIndex &mindex) const;
void renameKeywordsTypenameViaTheList(const QModelIndex &mindex, const QString &newName);
void adjustKeywordsFieldsViaTheList(const QModelIndex &mindex, const QList<QPair<int, std::tuple<QString,
QString, KfvType>>> fields_defines);
void appendNewItemViaTheList(const QModelIndex &mindex, const QString &name);
void removeTargetItemViaTheList(const QModelIndex &mindex, const QModelIndex &tIndex);
void queryKeywordsViaTheList(const QModelIndex &mindex, const QString &itemName) const;
QList<QPair<int, QString>> avaliableEnumsForIndex(const QModelIndex &index) const;
QList<QPair<int, QString>> avaliableItemsForIndex(const QModelIndex &index) const;
QAbstractItemModel *quicklookItemsModel() const;
// 大纲节点管理
/**
* @brief 获取大纲树形图,包含分卷、剧情、分解点
* @return
*/
QStandardItemModel *outlineNavigateTree() const;
/**
* @brief 获取全书大纲编辑文档
* @return
*/
QTextDocument *novelOutlinesPresent() const;
/**
* @brief 获取当前卷所有细纲
* @return
*/
QTextDocument *volumeOutlinesPresent() const;
/**
* @brief 获取本卷下所有伏笔汇总
* @return
*/
QAbstractItemModel *desplinesUnderVolume() const;
/**
* @brief 获取至此卷宗未闭合伏笔
* @return
*/
QAbstractItemModel *desplinesUntilVolumeRemain() const;
/**
* @brief 获取至此章节未闭合伏笔
* @return
*/
QAbstractItemModel *desplinesUntilChapterRemain() const;
// 章卷节点
/**
* @brief 章节导航模型
* @return
*/
QAbstractItemModel *chaptersNavigateTree() const;
/**
* @brief 章节细纲呈现
* @return
*/
QTextDocument *chapterOutlinePresent() const;
/**
* @brief 查找结果模型
* @return
*/
QStandardItemModel *findResultTable() const;
/**
* @brief 添加卷宗节点
* @param name 卷宗名称
* @param description 卷宗描述
* @param index 位置索引,-1代表尾增
* @return
*/
void insertVolume(const QString& name, const QString &description, int index=-1);
/**
* @brief 在指定大纲节点下添加关键剧情节点
* @param vmIndex
* @param kName
* @param description
* @param index 位置索引,-1代表尾增
*/
void insertStoryblock(const QModelIndex &pIndex, const QString &name, const QString &description, int index=-1);
/**
* @brief 在指定关键剧情下添加剧情分解点
* @param pIndex
* @param name
* @param description
* @param index 位置索引,-1代表尾增
*/
void insertKeypoint(const QModelIndex &pIndex, const QString &name, const QString description, int index=-1);
/**
* @brief 删除任何大纲节点
* @param nodeIndex 大纲节点
* @return
*/
void removeOutlinesNode(const QModelIndex &outlineNode);
/**
* @brief 设置指定大纲节点为当前节点,引起相应视图变化
* @param err
* @param outlineNode 大纲节点
* @return
*/
void setCurrentOutlineNode(const QModelIndex &outlineNode);
void checkOutlinesRemoveEffect(const QModelIndex &outlinesIndex, QList<QString> &msgList) const;
/**
* @brief 在指定卷宗下添加章节
* @param pIndex
* @param name
* @param description
* @param index 位置索引,-1代表尾增
*/
void insertChapter(const QModelIndex &pIndex, const QString &name, const QString &description, int index=-1);
void removeChaptersNode(const QModelIndex &chaptersNode);
void setCurrentChaptersNode(const QModelIndex &chaptersNode);
void checkChaptersRemoveEffect(const QModelIndex &chpsIndex, QList<QString> &msgList) const;
void appendDesplineUnder(const QModelIndex &anyVolumeIndex, const QString &name, const QString &description);
void appendDesplineUnderCurrentVolume(const QString &name, const QString &description);
/**
* @brief 在指定章节下添加支线驻点,index=-1就是附增
* @param desplineID
* @param title
* @param desp
* @param index 位置索引,-1代表尾增
*/
void insertAttachpoint(int desplineID, const QString &title, const QString &desp, int index=-1);
void removeDespline(int desplineID);
void removeAttachpoint(int attachpointID);
void attachPointMoveup(const QModelIndex &desplineIndex);
void attachPointMovedown(const QModelIndex &desplineIndex);
void allStoryblocksWithIDUnderCurrentVolume(QList<QPair<QString, int> > &storyblocks) const;
/**
* @brief 汇聚指定卷宗下的故事线(伏笔)
* @param node
* @param desplines
* @return
*/
void sumDesplinesUntilVolume(const QModelIndex &node, QList<QPair<QString, int>> &desplines) const;
/**
* @brief 汇聚所有本卷下未吸附伏笔
* @param foreshadowsList title,fullpath
*/
void sumPointWithChapterSuspend(int desplineID, QList<QPair<QString, int>> &suspendPoints) const;
void sumPointWithChapterAttached(const QModelIndex &chapterIndex, int desplineID, QList<QPair<QString, int>> &attachedPoints) const;
void chapterAttachSet(const QModelIndex &chapterIndex, int pointID);
void chapterAttachClear(int pointID);
void sumPointWithStoryblcokSuspend(int desplineID, QList<QPair<QString, int>> &suspendPoints) const;
void sumPointWithStoryblockAttached(const QModelIndex &outlinesIndex, int desplineID, QList<QPair<QString, int>> &attachedPoints) const;
void storyblockAttachSet(const QModelIndex &outlinesIndex, int pointID);
void storyblockAttachClear(int pointID);
void checkDesplineRemoveEffect(int fsid, QList<QString> &msgList) const;
void searchText(const QString& text);
void pushToQuickLook(const QTextBlock &block, const QList<QPair<QString,int>> &mixtureList);
int indexDepth(const QModelIndex &node) const;
void refreshWordsCount();
QString chapterActiveText(const QModelIndex& index);
int calcValidWordsCount(const QString &content);
void refreshDesplinesSummary();
ConfigHost &getConfigHost() const;
void testMethod();
void appendActiveTask(const QString &taskMask, int number=1);
void finishActiveTask(const QString &taskMask, const QString &finalTip, int number=1);
signals:
void documentAboutToBoClosed(QTextDocument *doc);
void documentPrepared(QTextDocument *doc, const QString &title);
void messagePopup(const QString &title, const QString &message);
void warningPopup(const QString &title, const QString &message);
void errorPopup(const QString &title, const QString &message);
void taskAppended(const QString &taskType, int number);
void taskFinished(const QString &taskType, const QString &finalTip, int number);
void currentChaptersActived();
void currentVolumeActived();
private:
ConfigHost &config_host;
NovelBase::DBAccess *desp_ins;
QStandardItemModel *const outline_navigate_treemodel;
QTextDocument *const novel_outlines_present;
QTextDocument *const volume_outlines_present;
QStandardItemModel *const chapters_navigate_treemodel;
QTextDocument *const chapter_outlines_present;
QStandardItemModel *const desplines_fuse_source_model;
NovelBase::DesplineFilterModel *const desplines_filter_under_volume;
NovelBase::DesplineFilterModel *const desplines_filter_until_volume_remain;
NovelBase::DesplineFilterModel *const desplines_filter_until_chapter_remain;
QStandardItemModel *const find_results_model;
// 所有活动文档存储容器anchor:<doc*,randerer*[nullable]>
QHash<NovelBase::ChaptersItem*,QPair<QTextDocument*, NovelBase::WordsRender*>> all_documents;
NovelBase::DBAccess::StoryTreeNode current_volume_node;
NovelBase::DBAccess::StoryTreeNode current_chapter_node;
QTextBlock current_editing_textblock;
void acceptEditingTextblock(const QTextCursor &cursor);
QStandardItemModel *const keywords_types_configmodel;
QList<QPair<NovelBase::DBAccess::KeywordField, QStandardItemModel*>> keywords_manager_group;
void _load_all_keywords_types_only_once();
QStandardItemModel *const quicklook_backend_model;
/**
* @brief 向chapters-tree和outline-tree上插入卷宗节点
* @param volume_handle
* @param index
* @return 返回对应的树节点,以供额外使用定制
*/
QPair<NovelBase::OutlinesItem *, NovelBase::ChaptersItem *>
insert_volume(const NovelBase::DBAccess::StoryTreeNode &volume_handle, int index);
void listen_novel_description_change();
void listen_volume_outlines_description_change(int pos, int removed, int added);
bool check_volume_structure_diff(const NovelBase::OutlinesItem *base_node, QTextBlock &blk) const;
void listen_volume_outlines_structure_changed();
void listen_chapter_outlines_description_change();
void outlines_node_title_changed(QStandardItem *item);
void chapters_node_title_changed(QStandardItem *item);
void _listen_basic_datamodel_changed(QStandardItem *item);
void set_current_volume_outlines(const NovelBase::DBAccess::StoryTreeNode &node_under_volume);
void set_current_chapter_content(const QModelIndex &chaptersNode, const NovelBase::DBAccess::StoryTreeNode &node);
void insert_description_at_volume_outlines_doc(QTextCursor cursor, NovelBase::OutlinesItem *outline_node);
NovelBase::DBAccess::StoryTreeNode _locate_outline_handle_via(QStandardItem *outline_item) const;
void _check_remove_effect(const NovelBase::DBAccess::StoryTreeNode &target, QList<QString> &msgList) const;
QTextDocument* load_chapter_text_content(QStandardItem* chpAnchor);
QModelIndex get_table_presentindex_via_typelist_model(const QModelIndex &mindex) const;
int extract_tableid_from_the_typelist_model(const QModelIndex &mindex) const;
};
#endif // NOVELHOST_H
| [
"2422523675@qq.com"
] | 2422523675@qq.com |
2f3840ad566b4cd94510cd16bb2637b8831cec86 | 3fd0b68895e76bc91b7cbf69287d92808fc9e07e | /Project/Camera.cpp | 9a252d19b97719dd23f93239642ce40d9022b49b | [] | no_license | ionutGMcatelina/3DScene | 11963008745d60008c4efb0ab34d4442dffce4a5 | c583a85b9efcf6f67682415b5971dad9da6ceef0 | refs/heads/master | 2021-02-16T15:38:24.143358 | 2020-03-04T23:13:13 | 2020-03-04T23:13:13 | 245,020,563 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,497 | cpp | //
// Camera.cpp
// Lab5
//
// Created by CGIS on 28/10/2016.
// Copyright © 2016 CGIS. All rights reserved.
//
#include "Camera.hpp"
namespace gps {
Camera::Camera(glm::vec3 cameraPosition, glm::vec3 cameraTarget)
{
this->cameraPosition = cameraPosition;
this->cameraTarget = cameraTarget;
this->cameraDirection = glm::normalize(cameraTarget - cameraPosition);
this->cameraRightDirection = glm::normalize(glm::cross(this->cameraDirection, glm::vec3(0.0f, 1.0f, 0.0f)));
}
glm::vec3 Camera::getPosition() {
return this->cameraPosition;
}
glm::vec3 Camera::getTarget() {
return this->cameraTarget;
}
glm::vec3 Camera::getDirection() {
return this->cameraDirection;
}
glm::mat4 Camera::getViewMatrix()
{
return glm::lookAt(cameraPosition, cameraPosition + cameraDirection , glm::vec3(0.0f, 1.0f, 0.0f));
}
glm::vec3 Camera::getCameraTarget()
{
return cameraTarget;
}
void Camera::move(MOVE_DIRECTION direction, float speed)
{
switch (direction) {
case MOVE_FORWARD:
cameraPosition += cameraDirection * speed;
break;
case MOVE_BACKWARD:
cameraPosition -= cameraDirection * speed;
break;
case MOVE_RIGHT:
cameraPosition += cameraRightDirection * speed;
break;
case MOVE_LEFT:
cameraPosition -= cameraRightDirection * speed;
break;
}
}
void Camera::ascend(float up) {
this->cameraPosition.y = up;
}
void Camera::changeX(float newX) {
this->cameraPosition.x = newX;
}
void Camera::changeZ(float newZ) {
this->cameraPosition.z = newZ;
}
void Camera::setDirection(glm::vec3 dir) {
this->cameraDirection = dir;
this->cameraRightDirection = glm::normalize(glm::cross(this->cameraDirection, glm::vec3(0.0f, 1.0f, 0.0f)));
}
void Camera::rotate(float pitch, float yaw)
{
if (pitch > 89.0f)
pitch = 89.0f;
if (pitch < -89.0f)
pitch = -89.0f;
glm::vec3 front;
front.x = cos(glm::radians(pitch)) * cos(glm::radians(yaw));
front.y = sin(glm::radians(pitch));
front.z = cos(glm::radians(pitch)) * sin(glm::radians(yaw));
this -> cameraDirection = glm::normalize(front);
this -> cameraRightDirection = glm::normalize(glm::cross(this->cameraDirection, glm::vec3(0.0f, 1.0f, 0.0f)));
}
}
| [
"ionut_catelina@yahoo.com"
] | ionut_catelina@yahoo.com |
425daebb40a83e3e70582dab4147baccc74ef909 | 75533f03521e3812dc9405139c5a27d3de8d2a91 | /Mischencontroll 1-1 to 2-6/mischencontroll2-6.1c/mischencontroll2-61c/mischencontroll2-61c.ino | 39d06e7673705b8ea1a23dd9d8aac2a6fbbfdf6b | [] | no_license | NicolaiFlemming/Test | 0f568283561ddb5da27b0c422278a6eed3426776 | 62adae37f476fd9aa9341ff335f7b4ab023eff82 | refs/heads/master | 2020-03-22T03:46:50.651645 | 2018-07-09T13:08:18 | 2018-07-09T13:08:18 | 139,451,978 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,500 | ino | +#include "HX711.h" //Bibliothek für Waage
#include <Wire.h> //Bibliothek für LCD
#include <LiquidCrystal_I2C.h> //Bibliothek für LCD
#include "benutzerv12.h" //eigene Benutzerbibliothek
//benoetigte Bibliotheken
#define DOUT 3
#define CLK 2 //fuer HX711 Inputs
HX711 scale(DOUT, CLK);
float calibration_factor = -92450; //Kalibrierungsfaktor fuer die Waage
int RelaisAlc = 4; //Definieren des Ports fuer Relais 1
int RelaisMix = 5; //Definieren des Ports fuer Relais 2
int But1 = 10; //Port für Button 1
int But2 = 11; //Port für Button 2
int But3 = 12; //Port für Button 3
char Pot1 = A5; //Port für Potentiometer
char Pot2 =A9; //Port für Potentiometer nr 2
//int a = 0; //Test Variable für seriellen Plotter
int VolAlc; //Volumen Alkohol
int VolMix; //Volumen Mixgetränk
int VolGes; //Volumen Gesamt
int AlcPerc; //Prozentsatz Alkohol
int MixPerc; //Prozentsatz Mischgetränk
float Ratio; //Mischverhältnis
float PreRatio; //Unmapped Mischverhältnis
float Vol; //Volumen
float PreVol; //Unmapped Volumen
const int max = 10; //Anzahl maximaler Benutzer
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); //LCD-Verbindungen
float weight; //erklären der Variable, welche die Waage nutzt
int weightP; //Nachkommastellen loswerden, durch int
bool btn = false; //Wert für button
int phase = 0; //Phase des Systems
int user = 0; //Aktuell ausgewählter Nutzer
int usercount = 0; //Anzahl erstellter Benutzer
//---------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
benutzer benutzer[max]; //initialisierung Benutzertabelle
bool sff; //Bool damit Sufflvl nur einmal pro phasendurchlauf im loop addiert wird
//-----------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------
void setup() {
Serial.begin(9600); //Seriellen Monitor mit 9600 Baud starten
Serial.println("T druecken, um zu tarieren"); //Auf Seriellem Monitor schreiben
scale.set_scale(calibration_factor); //kalibriert 2018-05-03
scale.tare(); //erste Kalibrierung
pinMode(RelaisAlc, OUTPUT); //Definieren des Pins als Output 5V
pinMode(RelaisMix, OUTPUT); //Definieren des Pins als Output 5V
pinMode (But1, INPUT); //Definieren des Pins als Digital Input 8Bit
pinMode (But2, INPUT); //Definieren des Pins als Digital Input 8Bit
pinMode (But3, INPUT); //Definieren des Pins als Digital Input 8Bit
pinMode (Pot1, INPUT); //Definieren des Pins als Analog Input 8Bit
pinMode (Pot2, INPUT); //Definieren des Pins als Analog Input 8Bit
lcd.begin(16,2); //Ausgabe LCD-Bildschirm
lcd.backlight(); //Anstellen Hintergrundlicht LCD
delay(2000); //benoetigte Verzoegerung
digitalWrite(RelaisAlc, LOW);
digitalWrite(RelaisMix, LOW); //Relais Pins auf 0V stellen
}
//----------------------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------------------------------------
void loop()
{
if(phase == 0) //Auswahl Benutzerauswahl oder -erstellung
{
lcd.clear();
do
{
lcd.setCursor(0,0); //Definieren wo auf LCD-Bildschirm Geschrieben wird (Stelle, Zeile)
lcd.print("Benutzer "); //Auf LCD-Bildschirm schreiben
lcd.setCursor(0,1); //Definieren wo auf LCD-Bildschirm Geschrieben wird (Stelle, Zeile)
lcd.print("ausw./erst. "); //Auf LCD-Bildschirm schreiben
if(digitalRead(But2) == HIGH) //Benutzer auswählen und Phasenwechsel
{
phase = 1;
delay(1000);
}
if(digitalRead(But3) == HIGH) //Benutzer erstellen Phasenwechsel
{
phase = 2;
delay(1000);
}
}
while(phase == 0);
}
if(phase == 1) //Auswahl Benutzer
{
lcd.setCursor(0,1);
lcd.print("</> T = ok");
lcd.setCursor(0,0);
if(user <= usercount )
{
lcd.print("Benutzer ");
lcd.print(user + 1);
}
if(user == (usercount + 1)) //usercount nicht größer als max. max + 1 ist der Gastbenutzer
{
lcd.print("Gast "); //Gastdaten werden nicht gespeichert
}
if(digitalRead(But2) == HIGH) //Durch die User wechseln
{
user -= 1;
if(user < 0) user = (usercount + 1);
delay(500);
}
if(digitalRead(But3) == HIGH)
{
user += 1;
if(user > (usercount + 1)) user = 0;
delay(500);
}
if(digitalRead(But1) == HIGH) //Benutzer bestätigen
{
phase = 3; //Einschenkvorgang wechseln
delay(1000);
}
}
if(phase == 2) //Benutzererstellung
{
bool w = 0; //Wechsel zwischen Bildschirmen
while(phase == 2)
{
if(usercount == max)
{
lcd.setCursor(0,0);
lcd.print("Keine Benutzer "); //Benutzer voll. Reset des Systems um Tabelle zu löschen
lcd.setCursor(0,1);
lcd.print("Weiter als Gast ");
delay(2000);
phase = 3; //Einschenkvorgang
user = max + 1;
}
else
{
float gew; //Temporäre Var um Werte in Tabelle zu speichern
char gesch; //Temporäre Var um Werte in Tabelle zu speichern
if(w == 0) //wechseln der eingabe
{
PreRatio = (constrain(analogRead(Pot1), 0, 1023));
Ratio = (PreRatio/1023); //benutzen des potis um gewicht einzustellen
gew = 40 + (Ratio * 100);
lcd.setCursor(0,0); //Definieren wo auf LCD-Bildschirm Geschrieben wird (Stelle, Zeile)
lcd.print("Gewicht einst.: "); //Auf LCD-Bildschirm schreiben
lcd.setCursor(0,1); //Definieren wo auf LCD-Bildschirm Geschrieben wird (Stelle, Zeile)
lcd.print(gew); //Auf LCD-Bildschirm schreiben
lcd.print(" kg T = ok ");
if(digitalRead(But1) == HIGH) //Gewichtvariable Festlegen
{
w = 1;
delay(1000);
}
}
if(w == 1) //Geschlecht wichtig für Promille berechnung
{
lcd.setCursor(0,0); //Definieren wo auf LCD-Bildschirm Geschrieben wird (Stelle, Zeile)
lcd.print("Geschlecht ausw.:"); //Auf LCD-Bildschirm schreiben
lcd.setCursor(0,1); //Definieren wo auf LCD-Bildschirm Geschrieben wird (Stelle, Zeile)
lcd.print("Maennl./Weibl. "); //Auf LCD-Bildschirm schreiben
if(digitalRead(But2) == HIGH)
{
gesch = 'M'; //Männliches Geschlecht eingegeben
benutzer[usercount].set_kge(gew); //Eingabe Gewicht in Klasse
benutzer[usercount].set_gen(gesch); //Eingabe Geschlecht in Klasse
usercount += 1;
phase = 3;
delay(1000);
}
if(digitalRead(But3) == HIGH)
{
gesch = 'W'; //Weibliches Geschlecht eingegeben
benutzer[usercount].set_kge(gew);
benutzer[usercount].set_gen(gesch);
usercount += 1;
phase = 3;
delay(1000);
}
benutzer[usercount].set_sufflvl(0); //Promille Zahl auf 0
}
}
}
}
if(phase == 3) //Einschenkvorgang
{
//a = analogRead(But);
//Serial.println(a);
//Serial.print("Weight: ");
//Serial.print((scale.get_units()*1000), 0); //Up to 3 decimal points
//Serial.println(" g"); //Change this to kg and re-adjust the calibration factor if you follow lbs
if(digitalRead(But1) == HIGH ) //bei Button drück Analog Wert > 1000
{
btn = true; //wenn Knopf gedrückt wurde wird btn bool Variable mit true ueberschrieben
scale.tare(); //bei knopfdruck tarieren
delay(50); //halbe sekunde verzoegerung
}
if (btn == false) //Alles was passieren soll bevor der knopf gedrückt wird
{
PreRatio = (constrain(analogRead(Pot1), 0, 1023)); //analog werte des Potentiometers zwischen 0 und 1023 (8bit) beschraenken und auf PreRatio Variable schreiben
Ratio = (PreRatio/1023); //Variable umrechnen zu einem Verhaeltnis für VolAlc und VolMix
VolAlc = (VolGes * Ratio); //VolAlc mithilfe der Ratio Variable berechnen
VolMix = (VolGes - VolAlc); //Volmix mithilfe von VolGes und VolAlc berechnen
AlcPerc = (Ratio*101); //Prozentsatz Alkohol mithilfe der Ratio Variablen berechnen. 101 wegen rundungsfehlern
MixPerc = ((1-Ratio)*101); //Prozentsatz Mischgetraenk mithilfe der Ratio Variablen berechnen. 101 wegen rundungsfehlern
PreVol = (constrain(analogRead(Pot2), 0 , 1023));
Vol = (PreVol/1023);
VolGes = (100+(Vol)*400);
lcd.setCursor(0,0); //Definieren wo auf LCD-Bildschirm Geschrieben wird (Stelle, Zeile)
lcd.print("Ratio: "); //Auf LCD-Bildschirm schreiben
lcd.setCursor (10,0);
lcd.print (AlcPerc);
lcd.print ("/");
lcd.print (MixPerc);
lcd.print (" ");
lcd.setCursor(0,1); //Definieren wo auf LCD-Bildschirm Geschrieben wird (Stelle, Zeile)
lcd.print("Volumen: "); //Auf LCD-Bildschirm schreiben
lcd.setCursor (10,1);
lcd.print (VolGes);
lcd.print ("ml ");
}
weight = (scale.get_units()*1000); //einholen der werte von der Waage und Umwandlung in Gramm
weightP = weight; //definieren der variable fuer Gewicht
if (btn==true)
{
lcd.setCursor(0,1); //Definieren wo auf LCD-Bildschirm Geschrieben wird (Stelle, Zeile)
lcd.print("Gewicht:"); //Auf LCD-Bildschirm schreiben
lcd.setCursor(10,1);
lcd.print(weightP); //Ausgabe des Gewichts auf dem LCD Bildschirm
lcd.print(" g " ); //Einheit
//Ausgabe des Verhaeltnisses auf dem LCD Bildschirm
}
if( VolAlc > weightP & weightP > -10 & btn == true ) //Schleife fuer Relais Alkohol auf Pin4
{
digitalWrite(RelaisAlc, HIGH);
}
else
{
digitalWrite(RelaisAlc, LOW);
}
if( VolMix + VolAlc >= weightP & VolAlc < weightP & btn==true ) //Schleife fuer Relais Mischgetraenk auf Pin5
{
digitalWrite(RelaisMix, HIGH);
}
else
{
digitalWrite(RelaisMix, LOW);
}
if(weightP >= VolAlc + VolMix) //beenden der Schleife durch btn bool variable
{
btn = false;
sff = true;
phase = 4;
}
if(Serial.available()) //Bei Input von T -> tarieren
{
char temp = Serial.read(); //Eingabe eines charakters
if(temp == 't' || temp == 'T') //wenn eingegebener charakter t ist wird tariert
{
scale.tare(); //Befehl zum Tarieren
}
delay(10); //Verzoegerung des gesamten Loops
}
}
if(phase == 4) //Ende und eintragen der Werte in die Benutzertabelle
{
int AlcinG, AlcinGges;
float AlcSet;
AlcinG = (VolAlc * 0.4); //40%er Alkohol
if(sff == true)
{
AlcinGges = AlcinG + benutzer[user].get_alkges();
benutzer[user].set_alkges(AlcinGges);
benutzer[user].err_sufflvl(benutzer[user].get_kge(), benutzer[user].get_gen(), AlcinGges);
sff = false;
}
lcd.setCursor(0,0); //Definieren wo auf LCD-Bildschirm Geschrieben wird (Stelle, Zeile)
lcd.print("Benutzer"); //Auf LCD-Bildschirm schreiben
lcd.print(user + 1); //Auf LCD-Bildschirm schreiben
lcd.setCursor(0,1); //Definieren wo auf LCD-Bildschirm Geschrieben wird (Stelle, Zeile)
if(benutzer[user].get_sufflvl() < 1.5) //Benutzer noch nicht sehr betrunken
{
lcd.print("Prost!!! ");
}
if(benutzer[user].get_sufflvl() >= 1.5) //Benutzer wahrscheinlich betrunken
{
lcd.print("Wasser vllt? ");
}
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Benutzer");
lcd.print(user + 1);
lcd.setCursor(0,1);
lcd.print(benutzer[user].get_sufflvl()); //Ausgabe der ungefähren Promille
delay(2000);
phase = 0; //Erster Bildschirm (von vorne)
}
delay(10);
}
| [
"j.jehn@tu-bs-de"
] | j.jehn@tu-bs-de |
7b5cecf21d2965b5e416a2d46218a14472c7a7ae | 372ad9c2f0db8709f5b7074acf601874e32266b6 | /Tests/OmniSQLUtilitiesTest.cpp | f7d5fb35ef27f16643729a6286c99c03b2318bbd | [
"LicenseRef-scancode-generic-cla",
"Apache-2.0"
] | permissive | Likes123/omniscidb | f69894656e8ae9e7b724e06d84a5fa28f097958c | 1e4904c0622bcef67dbe7a95ef9cb64f9d505d80 | refs/heads/master | 2020-08-31T14:21:26.728671 | 2019-10-29T05:56:57 | 2019-10-30T17:12:55 | 218,709,632 | 1 | 0 | Apache-2.0 | 2019-10-31T07:34:52 | 2019-10-31T07:34:51 | null | UTF-8 | C++ | false | false | 4,423 | cpp | /*
* Copyright 2019 OmniSci, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "../SQLFrontend/CommandHistoryFile.h"
#include "gtest/gtest.h"
#include <boost/program_options.hpp>
#include <cstring>
#include <fstream>
#include <type_traits>
// Mocks
using GetEnvRetType = decltype(DefaultEnvResolver().getenv(""));
using GetPWUIDRetType = decltype(DefaultEnvResolver().getpwuid(0));
class DefaultUnitTestResolver {
public:
template <typename... ARGS>
GetEnvRetType getenv(ARGS&&...) const {
return nullptr;
}
template <typename... ARGS>
GetPWUIDRetType getpwuid(ARGS&&...) const {
return nullptr;
}
auto getuid() const { return ::getuid(); }
};
class NoHomeNoPWEntResolver : public DefaultUnitTestResolver {};
class NoHomePWEntResolver : public DefaultUnitTestResolver {
public:
template <typename... ARGS>
GetPWUIDRetType getpwuid(ARGS&&... args) const {
return ::getpwuid(std::forward<ARGS>(args)...);
}
};
class HomeResolver : public DefaultEnvResolver {
public:
template <typename... ARGS>
GetEnvRetType getenv(ARGS&&... args) const {
return DefaultEnvResolver::getenv(std::forward<ARGS>(args)...);
}
template <typename... ARGS>
GetPWUIDRetType getpwuid(ARGS&&...) const {
throw std::runtime_error("Unexpected getpwuid() invocation.");
}
};
// Mock-base class equivalents of CommandHistoryFile
using CommandHistoryFile_NoHomeNoPWEnt = CommandHistoryFileImpl<NoHomeNoPWEntResolver>;
using CommandHistoryFile_NoHomePWEnt = CommandHistoryFileImpl<NoHomePWEntResolver>;
using CommandHistoryFile_Home = CommandHistoryFileImpl<HomeResolver>;
// Tests
TEST(CommandHistoryFile, NoHomeEnv) {
CommandHistoryFile_NoHomeNoPWEnt cmd_file;
ASSERT_EQ(std::string(getDefaultHistoryFilename()), std::string(cmd_file));
CommandHistoryFile_NoHomePWEnt cmd_file2;
ASSERT_EQ(std::string(getpwuid(getuid())->pw_dir) + '/' +
std::string(getDefaultHistoryFilename()),
std::string(cmd_file2));
}
TEST(CommandHistoryFile, HomeEnv) {
CommandHistoryFile_Home cmd_file;
ASSERT_EQ(std::string(getpwuid(getuid())->pw_dir) + '/' +
std::string(getDefaultHistoryFilename()),
std::string(cmd_file));
}
TEST(CommandHistoryFile, Basic) {
CommandHistoryFile cmd_file;
ASSERT_EQ(std::string(getpwuid(getuid())->pw_dir) + '/' +
std::string(getDefaultHistoryFilename()),
std::string(cmd_file));
}
TEST(CommandHistoryFile, Custom) {
CommandHistoryFile cmd_file("mutley.txt");
ASSERT_EQ(std::string("mutley.txt"), std::string(cmd_file));
}
TEST(CommandHistoryFile, BoostProgramOptionsCompatibility_DefaultOption) {
namespace po = boost::program_options;
po::options_description desc("Options");
CommandHistoryFile cmd_file;
int fake_argc = 1;
char const* fake_argv[] = {"lulz"};
desc.add_options()(
"history", po::value<CommandHistoryFile>(&cmd_file), "History filename");
po::variables_map vm;
po::store(po::command_line_parser(fake_argc, fake_argv).options(desc).run(), vm);
po::notify(vm);
ASSERT_EQ(std::string(getpwuid(getuid())->pw_dir) + '/' +
std::string(getDefaultHistoryFilename()),
std::string(cmd_file));
}
TEST(CommandHistoryFile, BoostProgramOptionsCompatibility_SetOption) {
namespace po = boost::program_options;
po::options_description desc("Options");
CommandHistoryFile cmd_file;
int fake_argc = 2;
char const* fake_argv[] = {"lulz", "--history=dudley_dawson.txt"};
desc.add_options()(
"history", po::value<CommandHistoryFile>(&cmd_file), "History filename");
po::variables_map vm;
po::store(po::command_line_parser(fake_argc, fake_argv).options(desc).run(), vm);
po::notify(vm);
ASSERT_EQ(std::string("dudley_dawson.txt"), std::string(cmd_file));
}
int main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
| [
"dev@aas.io"
] | dev@aas.io |
b1ac7c0cc07f7d4c42c4a4e5d64e35d51c778720 | 5a3abbe978efa2b15ee1185e0d14757f243e6fce | /TemplePlus/ui/ui_debug.cpp | 77672169fb2966e3d252f79b093622bfcf03298c | [
"MIT"
] | permissive | lucianposton/TemplePlus | 1b3807ae1da6ebcc4d620ddd670b32605757d124 | f645d4d25d09fb4b81266fa6e1e5b223e47a2a17 | refs/heads/master | 2021-09-20T21:55:45.892727 | 2017-11-07T22:56:14 | 2017-11-07T22:56:14 | 111,852,676 | 0 | 0 | null | 2017-11-23T21:47:46 | 2017-11-23T21:47:46 | null | UTF-8 | C++ | false | false | 3,572 | cpp |
#include "stdafx.h"
#include "ui.h"
#include "ui_debug.h"
#include "ui/widgets/widgets.h"
#include "tig/tig_startup.h"
#include <graphics/shaperenderer2d.h>
#include <debugui.h>
static bool debugUiVisible = false;
void UIShowDebug()
{
debugUiVisible = true;
}
static void DrawWidgetTreeNode(int widgetId);
static bool HasName(LgcyWidget *widget) {
if (!widget->name[0]) {
return false;
}
// Some names are just filled with garbage... We try to catch that here by checking
// if any of the name's chars is a null terminator
for (int i = 0; i < 64; i++) {
if (!widget->name[i]) {
return true;
}
}
return false;
}
static void DrawLegacyWidgetTreeNode(LgcyWidget *widget) {
std::string textEntry;
if (widget->IsWindow()) {
textEntry += "[wnd] ";
} else if (widget->IsButton()) {
textEntry += "[btn] ";
} else if (widget->IsScrollBar()) {
textEntry += "[scr] ";
}
textEntry += std::to_string(widget->widgetId);
if (HasName(widget)) {
textEntry.push_back(' ');
textEntry.append(widget->name);
}
bool opened = ImGui::TreeNode(textEntry.c_str());
// Draw the widget outline regardless of whether the tree node is opend
if (ImGui::IsItemHovered()) {
tig->GetShapeRenderer2d().DrawRectangleOutline(
{ (float) widget->x, (float) widget->y },
{ (float) widget->x + widget->width, (float) widget->y + widget->height },
XMCOLOR(1, 1, 1, 1)
);
}
if (!opened) {
return;
}
ImGui::BulletText(" X:%d Y:%d W:%d H:%d", widget->x, widget->y, widget->width, widget->height);
if (widget->IsWindow()) {
auto window = (LgcyWindow*)widget;
for (size_t i = 0; i < window->childrenCount; i++) {
DrawWidgetTreeNode(window->children[i]);
}
}
ImGui::TreePop();
}
static void DrawAdvWidgetTreeNode(WidgetBase *widget) {
std::string textEntry;
if (widget->IsContainer()) {
textEntry += "[cnt] ";
} else if (widget->IsButton()) {
textEntry += "[btn] ";
} else {
textEntry += "[unk] ";
}
textEntry += fmt::format("{} ", widget->GetWidgetId());
if (!widget->GetId().empty()) {
textEntry += widget->GetId();
textEntry.append(" ");
}
textEntry += widget->GetSourceURI();
bool opened = ImGui::TreeNode(textEntry.c_str());
// Draw the widget outline regardless of whether the tree node is opend
if (ImGui::IsItemHovered()) {
auto contentArea = widget->GetContentArea();
tig->GetShapeRenderer2d().DrawRectangleOutline(
{ (float) contentArea.x, (float) contentArea.y },
{ (float) contentArea.x + contentArea.width, (float) contentArea.y + contentArea.height },
XMCOLOR(1, 1, 1, 1)
);
}
if (!opened) {
return;
}
ImGui::BulletText(" X:%d Y:%d W:%d H:%d", widget->GetX(), widget->GetY(), widget->GetWidth(), widget->GetHeight());
if (!widget->IsVisible()) {
ImGui::SameLine();
ImGui::TextColored({1, 0, 0, 1}, "[Hidden]");
}
if (widget->IsContainer()) {
auto window = (WidgetContainer*)widget;
for (auto &child : window->GetChildren()) {
DrawAdvWidgetTreeNode(child.get());
}
}
ImGui::TreePop();
}
static void DrawWidgetTreeNode(int widgetId) {
auto widget = uiManager->GetWidget(widgetId);
auto advWidget = uiManager->GetAdvancedWidget(widgetId);
if (advWidget) {
DrawAdvWidgetTreeNode(advWidget);
} else {
DrawLegacyWidgetTreeNode(widget);
}
}
void UIRenderDebug()
{
if (!debugUiVisible) {
return;
}
ImGui::Begin("UI System", &debugUiVisible);
if (ImGui::CollapsingHeader("Top Level Windows (Bottom to Top)")) {
for (auto &widgetId : uiManager->GetActiveWindows()) {
DrawWidgetTreeNode(widgetId);
}
}
ImGui::End();
}
| [
"sebastian@hartte.de"
] | sebastian@hartte.de |
09ee0db148112b5e69753cd895b8c2b43e51a716 | 23d15b8cb760a278a6a2b2fd55297ed6415ef38a | /Plugins/ObjectDeliverer/Source/ObjectDeliverer/Public/Protocol/ProtocolUdpSocket.h | df41bbc712bae283ba38bce04d9ab3447ad05fcf | [
"MIT"
] | permissive | 17702513221/ObjectDeliverer | fb8ac7ba7fd4fef1b4c8ee02a4ab508a5c076e8e | cf2fa23526b21cb2de69ce0dc98c2a2816a92d42 | refs/heads/master | 2022-09-16T12:59:19.511837 | 2020-05-26T14:34:48 | 2020-05-26T14:34:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 652 | h | // Copyright 2019 ayumax. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "ProtocolSocketBase.h"
#include "GetIPV4Info.h"
#include "ProtocolUdpSocket.generated.h"
class FSocket;
UCLASS(BlueprintType, Blueprintable)
class OBJECTDELIVERER_API UProtocolUdpSocket : public UProtocolSocketBase, public IGetIPV4Info
{
GENERATED_BODY()
public:
UProtocolUdpSocket();
~UProtocolUdpSocket();
void Initialize(FIPv4Endpoint IP);
void NotifyReceived(const FArrayReaderPtr& data);
bool GetIPAddress(TArray<uint8>& IPAddress) override;
bool GetIPAddressInString(FString& IPAddress) override;
private:
FIPv4Endpoint IPEndPoint;
};
| [
"ayuma0913@gmail.com"
] | ayuma0913@gmail.com |
979e81eeb534f98d8ae71cd2df647ab397936f55 | 9f324e3c35a0c0172a6746e0ab96026adb590473 | /azrael.digipen.edu/~mmead/www/Courses/2020/winter/cs170/labs/week11/driver.cpp | 30c6c43d2d5598b2193575adb05f170890f25a8a | [] | no_license | platypuppy/MeadSite | ec3f2537e95b79e9b11e8ee46b32d58e9b1fe225 | 57958e1ce0d06d9cb87e2629c67da110d3790904 | refs/heads/master | 2022-07-28T12:27:10.344945 | 2020-05-20T17:30:19 | 2020-05-20T17:30:19 | 265,632,097 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,237 | cpp | #include "Vector.h"
#include <iostream> // cout, endl
void Print(const CS170::Vector& array, bool newline = true)
{
for (unsigned i = 0; i < array.size(); i++)
{
std::cout << array[i] << " ";
}
std::cout << "(size=" << array.size() << ", capacity=" <<
array.capacity() << ", allocs=" <<
array.allocations() << ")";
if (newline)
std::cout << std::endl;
}
void PrintPartial(const CS170::Vector& array, bool newline = true)
{
for (unsigned i = 1; i < array.size(); i *= 2)
{
std::cout << array[i - 1] << " ";
}
std::cout << "(size=" << array.size() << ", capacity=" <<
array.capacity() << ", allocs=" <<
array.allocations() << ")";
if (newline)
std::cout << std::endl;
}
void TestSwap1()
{
std::cout << "\n********** TestSwap1 **********\n";
CS170::Vector a, b, c;
std::cout << "push_back integers:\n";
for (int i = 0; i < 10; i++)
a.push_back(i + 1);
for (int i = 0; i < 5; i++)
b.push_back(10 * (i + 1));
std::cout << "a: ";
Print(a);
std::cout << "b: ";
Print(b);
std::cout << "swapv a,b:\n";
a.swapv(b);
std::cout << "a: ";
Print(a);
std::cout << "b: ";
Print(b);
std::cout << "swapv a,c:\n";
a.swapv(c);
std::cout << "a: ";
Print(a);
std::cout << "c: ";
Print(c);
std::cout << "swapv b,b:\n";
b.swapv(b);
std::cout << "b: ";
Print(b);
}
void TestReverse1()
{
int count = 10;
std::cout << "\n********** TestReverse1 **********\n";
CS170::Vector a;
std::cout << "push_back integers:\n";
for (int i = 0; i < count; i++)
a.push_back(i + 1);
Print(a);
a.reverse();
std::cout << "Reversed:\n";
Print(a);
std::cout << "Remove last element:\n";
a.pop_back();
Print(a);
a.reverse();
std::cout << "Reversed:\n";
Print(a);
}
void TestReverse2()
{
int count = 10;
std::cout << "\n********** TestReverse2 **********\n";
CS170::Vector a;
std::cout << "push_back integers:\n";
for (int i = 0; i < count; i++)
a.push_back(i + 1);
Print(a);
a.reverse();
std::cout << "Reversed:\n";
Print(a);
while (!a.empty())
{
if (a.size() % 2) // odd
{
std::cout << "Remove last element:\n";
a.pop_back();
}
else // even
{
std::cout << "Remove first element:\n";
a.pop_front();
}
Print(a);
a.reverse();
std::cout << "Reversed:\n";
Print(a);
}
}
void TestEqual1()
{
std::cout << "\n********** TestEqual1 **********\n";
CS170::Vector a, b, c;
std::cout << "push_back integers:\n";
for (int i = 0; i < 10; i++)
a.push_back(i + 1);
for (int i = 0; i < 10; i++)
b.push_back(i + 1);
std::cout << "a: ";
Print(a);
std::cout << "b: ";
Print(b);
if (a == b)
std::cout << "a is equal to b\n";
else
std::cout << "a is NOT equal to b\n";
std::cout << "remove last element of a:\n";
a.pop_back();
std::cout << "a: ";
Print(a);
std::cout << "b: ";
Print(b);
if (a == b)
std::cout << "a is equal to b\n";
else
std::cout << "a is NOT equal to b\n";
std::cout << "remove last element of b:\n";
b.pop_back();
std::cout << "a: ";
Print(a);
std::cout << "b: ";
Print(b);
if (a == b)
std::cout << "a is equal to b\n";
else
std::cout << "a is NOT equal to b\n";
std::cout << "change last element of b to 100:\n";
b[b.size() - 1] = 100;
std::cout << "a: ";
Print(a);
std::cout << "b: ";
Print(b);
if (a == b)
std::cout << "a is equal to b\n";
else
std::cout << "a is NOT equal to b\n";
}
/*
Before C++17, the exception output was undefined. Now, it is guaranteed
to print out the text before the exception gets thrown. This means that
this define is no longer needed. However, it's still fine and will work
with all compilers.
*/
#define SAFE_EXCEPTION
void TestSubscriptEx()
{
std::cout << "\n********** TestSubscriptEx **********\n";
int ia[] = {2, 4, 6, 6, 8, 10, 6, 12, -6, 14, 16, 6, 6};
unsigned size = static_cast<unsigned>(sizeof(ia) / sizeof(*ia));
std::cout << "Construct from int array:\n";
const CS170::Vector a(ia, size); // const
CS170::Vector b(ia, size); // non-const
Print(a);
Print(b);
try
{
unsigned index = a.size() * 2; // illegal
std::cout << "accessing subscript on const vector: a[" << index << "]" << std::endl;
#ifdef SAFE_EXCEPTION
std::cout << "a[" << index << "] = ";
std::cout.flush();
std::cout << a[index] << std::endl;
#else
std::cout << "a[" << index << "] = " << a[index] << std::endl;
#endif
}
catch(const CS170::SubscriptError &se)
{
std::cout << "Bad subscript: " << se.GetSubscript() << std::endl;
}
try
{
unsigned index = b.size() * 2; // illegal
std::cout << "accessing subscript on non-const vector: b[" << index << "]" << std::endl;
#ifdef SAFE_EXCEPTION
std::cout << "b[" << index << "] = ";
std::cout.flush();
std::cout << b[index] << std::endl;
#else
std::cout << "b[" << index << "] = " << b[index] << std::endl;
#endif
}
catch(const CS170::SubscriptError &se)
{
std::cout << "Bad subscript: " << se.GetSubscript() << std::endl;
}
}
void TestInsertEx()
{
std::cout << "\n********** TestInsertEx **********\n";
int ia[] = {2, 4, 6, 6, 8, 10, 6, 12, -6, 14, 16, 6, 6};
unsigned size = static_cast<unsigned>(sizeof(ia) / sizeof(*ia));
std::cout << "Construct from int array:\n";
CS170::Vector a(ia, size);
Print(a);
try
{
unsigned index = a.size() * 3; // illegal
std::cout << "insert integer at index " << index << ":\n";
a.insert(99, index);
}
catch(const CS170::SubscriptError &se)
{
std::cout << "Bad subscript: " << se.GetSubscript() << std::endl;
}
}
void TestSwapStress()
{
std::cout << "\n********** TestSwapStress **********\n";
CS170::Vector a, b, c;
int count = 1000000;
std::cout << "Pushing back...\n";
for (int i = 0; i < count; i++)
{
a.push_back(i);
b.push_back(i * 2);
c.push_back(i * 3);
}
std::cout << "Swapping...\n";
CS170::Vector x;
for (int i = 0; i < 1000001; i++)
{
a.swapv(b);
b.swapv(c);
c.swapv(a);
}
PrintPartial(a);
PrintPartial(b);
PrintPartial(c);
std::cout << "Done...\n";
}
void TestShrink1()
{
std::cout << "\n********** TestShrink1 **********\n";
CS170::Vector a;
std::cout << "push_back 8 integers:\n";
for (int i = 0; i < 8; i++)
a.push_back(i);
Print(a);
std::cout << "shrink:\n";
a.shrink_to_fit();
Print(a);
std::cout << "pop last 3:\n";
a.pop_back();
a.pop_back();
a.pop_back();
Print(a);
std::cout << "shrink:\n";
a.shrink_to_fit();
Print(a);
std::cout << "push_back one integer:\n";
a.push_back(100);
Print(a);
std::cout << "shrink:\n";
a.shrink_to_fit();
Print(a);
std::cout << "shrink:\n";
a.shrink_to_fit();
Print(a);
std::cout << "clear:\n";
a.clear();
Print(a);
std::cout << "shrink:\n";
a.shrink_to_fit();
Print(a);
}
int main()
{
TestSwap1();
TestReverse1();
TestReverse2();
TestEqual1();
TestShrink1();
TestSubscriptEx();
TestInsertEx();
TestSwapStress();
return 0;
}
| [
"61122248+platypuppy@users.noreply.github.com"
] | 61122248+platypuppy@users.noreply.github.com |
b6520a3d32ff11148c3b9d8aaac9220419d5d467 | 6102e9eb884aab14d9addd3e71c371bd6f41dc26 | /1017.cpp | 09ef14f16e57d78f7bebea1b272def182f6cbd43 | [] | no_license | limbowandering/PAT_Level2 | 2125377c9ced9b74736cd72f267b76104db8a04c | ae3173342d3d578c8d180b1d809effefc890087c | refs/heads/master | 2021-05-06T21:30:21.217255 | 2017-12-17T08:57:13 | 2017-12-17T08:57:13 | 112,616,186 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 422 | cpp | #include <iostream>
using namespace std;
int main(){
string s;
cin >> s;
int a;
cin >> a;
int len = s.length();
int t = 0;
int tmp = 0;
t = (s[0] - '0') / a;
if((t != 0 && len > 1) || len == 1){
cout << t;
}
tmp = (s[0] - '0') % a;
for(int i = 1; i < len; i++){
t = (tmp * 10 + s[i] - '0') / a;
cout << t;
tmp = (tmp * 10 + s[i] - '0') % a;
}
cout << " " << tmp;
return 0;
} | [
"591176276@qq.com"
] | 591176276@qq.com |
4f993c9a96d65390043a7ee6ebb40ac3df8c5ead | da0e478aa133828b46cd9cdce321440806d6f5df | /IbeoSDK6.0.4/sdk/source/sdk/test/src/timeRelationsListTests/TimeRelationsList9010Test.cpp | 2bce99ac6732bcd1a3da621aa99fde2f3ee7a3ad | [] | no_license | mak6gulati/IBEO_sdk_check | 1a911fe1b5bd92bab2800fa40e4dfa219a10cd5b | 1114cbb88fa1a95e00b912a501582b3a42544379 | refs/heads/master | 2022-12-30T17:27:45.848079 | 2020-10-20T07:59:07 | 2020-10-20T07:59:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,762 | cpp | //==============================================================================
//! \file
//!
//! $$IBEO_LICENSE_BEGIN$$
//! Copyright (c) Ibeo Automotive Systems GmbH 2010-2019
//! All Rights Reserved.
//!
//! For more details, please refer to the accompanying file
//! IbeoLicense.txt.
//! $$IBEO_LICENSE_END$$
//!
//! \date Apr 3, 2018
//------------------------------------------------------------------------------
#include "TimeRelationsListTestSupport.hpp"
#include <ibeo/common/sdk/datablocks/timerelation/special/TimeRelationsList9010Importer9010.hpp>
#include <ibeo/common/sdk/datablocks/timerelation/special/TimeRelationsList9010Exporter9010.hpp>
#define BOOST_TEST_MODULE TimeRelationsListTest
#include <boost/test/unit_test.hpp>
//==============================================================================
using namespace ibeo::common::sdk;
//==============================================================================
BOOST_AUTO_TEST_SUITE(TimeRelationsList9010TestSuite)
//==============================================================================
class Fixture : public unittests::TimeRelationsListTestSupport
{
}; // Fixture
//==============================================================================
// Test: create an empty timerelation list
BOOST_FIXTURE_TEST_CASE(createTimeRelationList9010, Fixture)
{
ibeo::common::sdk::TimeRelationsList9010 trl9010;
BOOST_CHECK(trl9010.getTimeRelations().size() == 0);
}
//==============================================================================
// Test: create an empty timerelation
BOOST_FIXTURE_TEST_CASE(createTimeRelation9010, Fixture)
{
ibeo::common::sdk::TimeRelationIn9010 tr9010;
BOOST_CHECK(tr9010.getEntryList().size() == 0);
}
//==============================================================================
// Test: create an empty importer
BOOST_FIXTURE_TEST_CASE(createTimeRelation9010Importer, Fixture)
{
ibeo::common::sdk::TimeRelationsList9010Importer9010 importer;
BOOST_CHECK(true);
}
//==============================================================================
// Test: create an empty exporter
BOOST_FIXTURE_TEST_CASE(createTimeRelation9010Exporter, Fixture)
{
ibeo::common::sdk::TimeRelationsList9010Exporter9010 importer;
BOOST_CHECK(true);
}
//==============================================================================
// Test: create an empty timerelation list
BOOST_FIXTURE_TEST_CASE(ioTimeRelationList9010Identity, Fixture)
{
for (int32_t r = 0; r < nbOfRepeats; ++r)
{
const ibeo::common::sdk::TimeRelationsList9010Exporter9010 exporter;
ibeo::common::sdk::TimeRelationsList9010 trl9010Orig = createTimeRelationsList9010C(false);
const ibeo::common::sdk::IbeoDataHeader dh(
exporter.getDataType(), 0U, uint32_t(exporter.getSerializedSize(trl9010Orig)), 0U, NTPTime());
std::stringstream ss;
BOOST_CHECK(exporter.serialize(ss, trl9010Orig));
ibeo::common::sdk::TimeRelationsList9010 trl9010Copy;
const ibeo::common::sdk::TimeRelationsList9010Importer9010 importer;
BOOST_CHECK(importer.deserialize(ss, trl9010Copy, dh));
BOOST_CHECK(trl9010Copy == trl9010Orig);
}
}
//==============================================================================
//operator!= and operator==
BOOST_FIXTURE_TEST_CASE(isContentTimeRelationsList9010Equal, Fixture)
{
for (int32_t r = 0; r < nbOfRepeats; ++r)
{
ibeo::common::sdk::TimeRelationsList9010 trlOrig;
ibeo::common::sdk::TimeRelationsList9010 trlCopy;
BOOST_CHECK(trlOrig == trlCopy);
trlOrig = createTimeRelationsList9010C(false);
BOOST_CHECK(trlOrig != trlCopy);
const TimeRelationsList9010::TimeRelationMap& timeRelMap = trlOrig.getTimeRelations();
TimeRelationsList9010::TimeRelationMap copyMap;
for (const auto& tr9010 : timeRelMap)
{
BOOST_CHECK(trlOrig != trlCopy);
copyMap[tr9010.first] = tr9010.second;
trlCopy.getTimeRelations() = copyMap;
}
BOOST_CHECK(trlOrig == trlCopy);
const uint16_t pos = getRandValue<uint16_t>(
0, static_cast<uint16_t>(trlCopy.getTimeRelations().begin()->second.getEntryList().size() - 1));
// deleting random entry in first relation
trlCopy.getTimeRelations().begin()->second.getEntryList().erase(
trlCopy.getTimeRelations().begin()->second.getEntryList().begin() + pos);
BOOST_CHECK(trlOrig != trlCopy);
} // for r
}
//==============================================================================
BOOST_AUTO_TEST_SUITE_END()
//==============================================================================
| [
"mayank.gulati@automotive-ai.com"
] | mayank.gulati@automotive-ai.com |
159dcca010919e8c0a628475f429f31495dcf23e | a23ac6e731cf41eed4a309159972d22724751774 | /include/sockets/abl/handle.h | ec1b965c64907ea4b10584bebbac1af2529e92c8 | [] | no_license | ILikePizza555/Sockets.cpp | f9938a31b8bc323bb4e346c3e01f5730760309c4 | d4f0c557d1cf99898b7f4d38866370c8e3778dbb | refs/heads/master | 2020-03-26T15:34:20.790634 | 2018-12-07T02:18:44 | 2018-12-07T02:18:44 | 145,051,158 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 917 | h | //
// Defines the abstraction for the system socket handle.
// Created by avris on 10/4/2018.
//
#pragma once
#include "enums.h"
#include <memory>
namespace sockets {
namespace abl {
/**
* Struct that contains the system socket handle.
*/
struct handle_t;
/**
* Destructor for the handle.
* This function is not intended to be called directly. Use UniqueHandle or SharedHandle instead.
* @param handle
*/
void close_handle(handle_t* handle);
using UniqueHandle = std::unique_ptr<handle_t, decltype(&close_handle)>;
using SharedHandle = std::shared_ptr<handle_t>;
using HandleRef = const handle_t *;
UniqueHandle new_unique_handle(ip_family family, sock_type type, sock_proto protocol);
SharedHandle new_shared_handle(ip_family family, sock_type type, sock_proto protocol);
}
} | [
"avrisaac555@gmail.com"
] | avrisaac555@gmail.com |
31d8efc71ee6819aef6ded26cca84906eab3ee98 | 0d0af8a5121a893459bbee88c857859d8635a1ab | /juego/src/JUEGO.cpp | c6187133d07d6348a45adfa9e68c9168eee90779 | [] | no_license | iriscuro/Proyecto_final | 2f53ccdfc828de2d561a9262c676f12b2d4b1990 | 770ecf5a997b6f940fd6eaa99570b2944b592804 | refs/heads/master | 2020-04-06T14:12:38.733007 | 2018-11-29T15:10:24 | 2018-11-29T15:10:24 | 157,532,123 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 698 | cpp | #include "JUEGO.h"
#include "score.h"
#include "SFML/Graphics.hpp"
using namespace sf;
void gamemostrar();
JUEGO::JUEGO(int ancho,int alto,std::string letra){//creamos ventana
ventana = new RenderWindow(sf::VideoMode(ancho,alto),letra);
ventana->setFramerateLimit(60);
gamemostrar();
}
void JUEGO::gamemostrar(){
while(ventana->isOpen())
{
// Procesamos la pila de eventos
while (ventana->pollEvent(event))
{
// Si el evento es de tipo Closed cerramos la ventana
if (event.type == sf::Event::Closed)
ventana->close();
}
dibujar();
}
}
void JUEGO::dibujar()
{
ventana->clear();
//score.show(sf::RenderWindow *ventana);
ventana->display();
}
| [
"iris.curo@ucsp.edu.pe"
] | iris.curo@ucsp.edu.pe |
3855f3710b0776c7e5b79df1c7347d77abd0f432 | 3b3a4f579c564d0e7958450d9b729d5dc4ad3d24 | /login_page/linux/my_application.cc | 4610106534d491f1d6195ed0ba19a986e6f67e5d | [] | no_license | Cagatay0/Flutter | 5acd5a24a2b86b2ebeeafff4079c13caca78a067 | 5bc237abb7f366fb1b064088c1beb62a329b396b | refs/heads/main | 2023-07-28T15:08:55.269981 | 2023-07-17T21:27:43 | 2023-07-17T21:27:43 | 308,714,555 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,718 | cc | #include "my_application.h"
#include <flutter_linux/flutter_linux.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#include "flutter/generated_plugin_registrant.h"
struct _MyApplication {
GtkApplication parent_instance;
char** dart_entrypoint_arguments;
};
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
// Implements GApplication::activate.
static void my_application_activate(GApplication* application) {
MyApplication* self = MY_APPLICATION(application);
GtkWindow* window =
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
// Use a header bar when running in GNOME as this is the common style used
// by applications and is the setup most users will be using (e.g. Ubuntu
// desktop).
// If running on X and not using GNOME then just use a traditional title bar
// in case the window manager does more exotic layout, e.g. tiling.
// If running on Wayland assume the header bar will work (may need changing
// if future cases occur).
gboolean use_header_bar = TRUE;
#ifdef GDK_WINDOWING_X11
GdkScreen* screen = gtk_window_get_screen(window);
if (GDK_IS_X11_SCREEN(screen)) {
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
use_header_bar = FALSE;
}
}
#endif
if (use_header_bar) {
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "login_page");
gtk_header_bar_set_show_close_button(header_bar, TRUE);
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
} else {
gtk_window_set_title(window, "login_page");
}
gtk_window_set_default_size(window, 1280, 720);
gtk_widget_show(GTK_WIDGET(window));
g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
FlView* view = fl_view_new(project);
gtk_widget_show(GTK_WIDGET(view));
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
gtk_widget_grab_focus(GTK_WIDGET(view));
}
// Implements GApplication::local_command_line.
static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
MyApplication* self = MY_APPLICATION(application);
// Strip out the first argument as it is the binary name.
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
g_autoptr(GError) error = nullptr;
if (!g_application_register(application, nullptr, &error)) {
g_warning("Failed to register: %s", error->message);
*exit_status = 1;
return TRUE;
}
g_application_activate(application);
*exit_status = 0;
return TRUE;
}
// Implements GObject::dispose.
static void my_application_dispose(GObject* object) {
MyApplication* self = MY_APPLICATION(object);
g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
}
static void my_application_class_init(MyApplicationClass* klass) {
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
}
static void my_application_init(MyApplication* self) {}
MyApplication* my_application_new() {
return MY_APPLICATION(g_object_new(my_application_get_type(),
"application-id", APPLICATION_ID,
"flags", G_APPLICATION_NON_UNIQUE,
nullptr));
}
| [
"32780592+Cagatay0@users.noreply.github.com"
] | 32780592+Cagatay0@users.noreply.github.com |
cf0c5e363144899b8471fed2f9231c4a3b35a16a | 2056dd8592a02cdc57b9691d0d49150444fac5f2 | /EOJ/P10/1086.cpp | 0e2d690222be7764f5ab85bb09b2c046d91ee4d6 | [] | no_license | fssqawj/ACM_CODE | 691565cdf7c13c973601918b13a696a55d8c7b7d | 0b9ed84d03cbb1f92211eec2716dae5d4fc41591 | refs/heads/master | 2021-01-22T00:54:59.083440 | 2015-02-03T10:28:45 | 2015-02-03T10:28:45 | 14,707,459 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,030 | cpp | #include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
const int maxn = 1000;
struct sub_t{
int l,r;
int maxx;
int minn;
};
struct tree{
int l,r;
//int maxx;
sub_t s_t[maxn];
};
tree t[maxn];
int a[maxn][maxn];
int n;
int ans[255][255];
inline int INP(){
int x = 0;
char c;
while((c = getchar()) != ' ' && c != '\n'){
x = x * 10 + c - '0';
}
return x;
}
void build_subtree(int rt,int sb_rt,int l,int r,int id){
//printf("rt = %d sb_rt = %d l = %d r = %d\n",rt,sb_rt,l,r);
t[rt].s_t[sb_rt].l = l;
t[rt].s_t[sb_rt].r = r;
if(l == r){
if(id != -1){
//printf("rt = %d sb_rt = %d id = %d l = %d\n",rt,sb_rt,id,l);
t[rt].s_t[sb_rt].maxx = a[id][l];
t[rt].s_t[sb_rt].minn = a[id][l];
//printf("rt = %d sb_rt = %d mx = %d mi = %d\n",rt,sb_rt,t[rt].s_t[sb_rt].maxx,t[rt].s_t[sb_rt].minn);
}
//else {
// t[rt].s_t[sb_rt].maxx = max(t[rt<<1].s_t[sb_rt].maxx,t[rt<<1|1].s_t[sb_rt].maxx);
// t[rt].s_t[sb_rt].minn = min(t[rt<<1].s_t[sb_rt].minn,t[rt<<1|1].s_t[sb_rt].minn);
//}
return ;
}
int mid = (l + r)>>1;
build_subtree(rt,sb_rt<<1,l,mid,id);
build_subtree(rt,sb_rt<<1|1,mid + 1,r,id);
//printf("id = %d\n",id);
if(id != -1){
//printf("rt = %d sb_rt = %d sb_rt<<1 = %d sb_rt<<1|1 = %d\n",rt,sb_rt,sb_rt<<1,sb_rt<<1|1);
//printf("lx = %d rx = %d\n",t[rt].s_t[sb_rt<<1].maxx,t[rt].s_t[sb_rt<<1|1].maxx);
t[rt].s_t[sb_rt].maxx = max(t[rt].s_t[sb_rt<<1].maxx,t[rt].s_t[sb_rt<<1|1].maxx);
t[rt].s_t[sb_rt].minn = min(t[rt].s_t[sb_rt<<1].minn,t[rt].s_t[sb_rt<<1|1].minn);
//printf("rt = %d sb_rt = %d id = %d l = %d r = %d maxx = %d minn = %d\n",rt,sb_rt,id,t[rt].s_t[sb_rt].l,t[rt].s_t[sb_rt].r,t[rt].s_t[sb_rt].maxx,t[rt].s_t[sb_rt].minn);
}
//else {
// printf("rt = %d sb_rt = %d\n",rt,sb_rt);
// printf("lx = %d rx = %d\n",t[rt<<1].s_t[sb_rt].maxx,t[rt<<1|1].s_t[sb_rt].maxx);
// t[rt].s_t[sb_rt].maxx = max(t[rt<<1].s_t[sb_rt].maxx,t[rt<<1|1].s_t[sb_rt].maxx);
// t[rt].s_t[sb_rt].minn = min(t[rt<<1].s_t[sb_rt].minn,t[rt<<1|1].s_t[sb_rt].minn);
//}
}
void push_up(int rt,int sb_rt,int l,int r){
if(l == r){
t[rt].s_t[sb_rt].maxx = max(t[rt<<1].s_t[sb_rt].maxx,t[rt<<1|1].s_t[sb_rt].maxx);
t[rt].s_t[sb_rt].minn = min(t[rt<<1].s_t[sb_rt].minn,t[rt<<1|1].s_t[sb_rt].minn);
return ;
}
int mid = (l + r)>>1;
push_up(rt,sb_rt<<1,l,mid);
push_up(rt,sb_rt<<1|1,mid + 1,r);
//printf("push rt = %d sb_rt = %d\n",rt,sb_rt);
t[rt].s_t[sb_rt].maxx = max(t[rt<<1].s_t[sb_rt].maxx,t[rt<<1|1].s_t[sb_rt].maxx);
t[rt].s_t[sb_rt].minn = min(t[rt<<1].s_t[sb_rt].minn,t[rt<<1|1].s_t[sb_rt].minn);
//printf("rt = %d sb_rt = %d l = %d r = %d d = %d u = %d maxx = %d minn = %d\n",rt,sb_rt,t[rt].l,t[rt].r,t[rt].s_t[sb_rt].l,t[rt].s_t[sb_rt].r,t[rt].s_t[sb_rt].maxx,t[rt].s_t[sb_rt].minn);
}
void build(int rt,int l,int r){
t[rt].l = l;
t[rt].r = r;
if(l == r){
build_subtree(rt,1,1,n,l);
return ;
}
else build_subtree(rt,1,1,n,-1);
int mid = (l + r)>>1;
build(rt<<1,l,mid);
build(rt<<1|1,mid + 1,r);
push_up(rt,1,1,n);
//t[rt].l =
//t[rt].maxx = max(t[rt<<1].maxx,t[rt<<1|1].maxx);
}
int query_subtree(int rt,int sb_rt,int l,int r,bool can){
//printf("sub rt = %d sb_rt = %d sl = %d l = %d sr = %d r = %d\n",rt,sb_rt,t[rt].s_t[sb_rt].l,l,t[rt].s_t[sb_rt].r,r);
if(t[rt].s_t[sb_rt].l >= l && t[rt].s_t[sb_rt].r <= r){
//printf("ma = %d mi = %d\n",t[rt].s_t[sb_rt].maxx,t[rt].s_t[sb_rt].minn);
if(can)return t[rt].s_t[sb_rt].maxx;
return t[rt].s_t[sb_rt].minn;
}
int mid = (t[rt].s_t[sb_rt].l + t[rt].s_t[sb_rt].r)>>1;
if(l > mid)return query_subtree(rt,sb_rt<<1|1,l,r,can);
else if(r <= mid)return query_subtree(rt,sb_rt<<1,l,r,can);
else {
if(can)return max(query_subtree(rt,sb_rt<<1,l,mid,can),query_subtree(rt,sb_rt<<1|1,mid + 1,r,can));
return min(query_subtree(rt,sb_rt<<1,l,mid,can),query_subtree(rt,sb_rt<<1|1,mid + 1,r,can));
}
}
int query(int rt,int l,int r,int d,int u,bool can){
//printf("rt = %d tl = %d l = %d tr = %d r = %d d = %d u = %d\n",rt,t[rt].l,l,t[rt].r,r,d,u);
if(t[rt].l >= l && t[rt].r <= r){
return query_subtree(rt,1,d,u,can);
}
int mid = (t[rt].l + t[rt].r)>>1;
if(l > mid)return query(rt<<1|1,l,r,d,u,can);
else if(r <= mid)return query(rt<<1,l,r,d,u,can);
else {
if(can)return max(query(rt<<1,l,mid,d,u,can),query(rt<<1|1,mid + 1,r,d,u,can));
return min(query(rt<<1,l,mid,d,u,can),query(rt<<1|1,mid + 1,r,d,u,can));
}
}
int main(){
int b,m;
while(scanf("%d%d%d",&n,&b,&m) != EOF){
memset(ans,-1,sizeof(ans));
for(int i = 1;i <= n;i ++){
for(int j = 1;j <= n;j ++){
scanf("%d",&a[i][j]);
}
}
getchar();
build(1,1,n);
for(int i = 0;i < m;i ++){
int x = INP(),y = INP();
//scanf("%d%d",&x,&y);
if(ans[x][y] != -1){
printf("%d\n",ans[x][y]);
continue;
}
int maxx = query(1,x,x + b - 1,y,y + b - 1,1);
int minn = query(1,x,x + b - 1,y,y + b - 1,0);
//printf("maxx = %d minn = %d\n",maxx,minn);
printf("%d\n",maxx - minn);
ans[x][y] = maxx - minn;
}
//break;
}
return 0;
}
| [
"fssqawj@163.com"
] | fssqawj@163.com |
91b98268c0239db0c2f64c81760a05254704f5cb | 8fa9074be698d8cbbeec169d21ab0cf10538ce37 | /Grand_life.Altis/The-Programmer/Iphone_X/dialogs/phone_chargements.hpp | fbf37c48c8c9e21ec4c84008d77fdb08283b8449 | [] | no_license | Speedy372/wl-remastered | a6d1d5e923c5dc2abf5b8d382e80fb42f20b4c88 | 7ecc83a38915d0716569d87a24ff3797d6df3e99 | refs/heads/main | 2023-04-09T05:46:26.645146 | 2021-03-30T11:22:07 | 2021-03-30T11:22:07 | 340,695,889 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,322 | hpp | class The_Programmer_Iphone_Loading_Menu {
idd = 542367;
name = "The_Programmer_Iphone_Loading_Menu";
movingenable = 1;
enablesimulation = 1;
class controlsBackground {
class FondPrincipale: Life_RscPicture {
text = "The-Programmer\Iphone_X\textures\fond.paa";
idc = -1;
x = 0.6379405 * safezoneW + safezoneX;
y = 0.288744481809243 * safezoneH + safezoneY;
w = 0.21 * safezoneW;
h = 0.7 * safezoneH;
};
};
class controls {
class Heure: Life_RscStructuredText {
idc = 2101;
text = "";
x = 0.689583333333333 * safezoneW + safezoneX;
y = 0.537551622418879 * safezoneH + safezoneY;
h = 0.05 * safezoneH;
w = 0.1 * safezoneW;
};
class deverouiller: Life_RscStructuredText {
idc = -1;
text = "<t align='center'>Dotknij, aby odblokowac</t>";
x = 0.660863833333334 * safezoneW + safezoneX;
y = 0.827665683382498 * safezoneH + safezoneY;
w = 0.165 * safezoneW;
h = 0.022 * safezoneH;
};
class phone: Life_RscButtonInvisible {
idc = -1;
text = "";
onbuttonclick = "closeDialog 0; player setVariable [""iphone_chargement_done"",false]; [1] spawn the_programmer_iphone_fnc_phone_init;";
x = 0.644072833333332 * safezoneW + safezoneX;
y = 0.408517994100295 * safezoneH + safezoneY;
w = 0.2 * safezoneW;
h = 0.4 * safezoneH;
};
class Image: Life_RscPicture {
text = "The-Programmer\Iphone_X\textures\lock.paa";
x = 0.719072833333332 * safezoneW + safezoneX;
y = 0.73398505408063 * safezoneH + safezoneY;
w = 0.0420000000000001 * safezoneW;
h = 0.07 * safezoneH;
idc = -1;
};
class Reboot: Life_RscButtonInvisible {
idc = -1;
tooltip = "Reboot";
onbuttonclick = "[] call the_programmer_iphone_fnc_reboot;";
x = 0.807894833333333 * safezoneW + safezoneX;
y = 0.312326017502458 * safezoneH + safezoneY;
w = 0.01 * safezoneW;
h = 0.02 * safezoneH;
};
};
}; | [
"59737499+Speedy372@users.noreply.github.com"
] | 59737499+Speedy372@users.noreply.github.com |
0b37b829fd0e7bdb1d248d0c9743b6c4cd609a11 | 94db0bd95a58fabfd47517ed7d7d819a542693cd | /client/ClientRes/IOSAPI/Classes/Native/mscorlib_System_Comparison_1_gen2248621462.h | 7e39c3071cc5eddc52a861323768826478480c9b | [] | no_license | Avatarchik/card | 9fc6efa058085bd25f2b8831267816aa12b24350 | d18dbc9c7da5cf32c963458ac13731ecfbf252fa | refs/heads/master | 2020-06-07T07:01:00.444233 | 2017-12-11T10:52:17 | 2017-12-11T10:52:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 743 | h | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
// System.IAsyncResult
struct IAsyncResult_t1999651008;
// System.AsyncCallback
struct AsyncCallback_t163412349;
// System.Object
struct Il2CppObject;
#include "mscorlib_System_MulticastDelegate3201952435.h"
#include "mscorlib_System_UInt16986882611.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Comparison`1<System.UInt16>
struct Comparison_1_t2248621462 : public MulticastDelegate_t3201952435
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| [
"1"
] | 1 |
d13e1643ec56093e9919ff95e1187bce0f42392a | ed5e941cc45dfc5f6bc457defd1f9cacf49a1012 | /Ajenda-abuela.cpp | 8e9a14107baaf9790ec9ed663b2893829c9d0303 | [] | no_license | Gonzalo345/proyecto-abuela | e8b513f62b7865d2bcb7a0344912ecd436a25c98 | 1bc42d8bbcc39852bb7aae68e5e7015b253db7bf | refs/heads/master | 2020-07-07T10:28:09.898186 | 2019-08-29T10:15:13 | 2019-08-29T10:15:13 | 203,324,135 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,285 | cpp | //============================================================================
// Name : Program.c
// Author : Gonzalo, Yarvi
// Version : 2.0
// Created on : August 20, 2019
// Description : Create an agenda for my grandmother
// Compiler : Eclipse IDE
//============================================================================
#include <sys/select.h> // To compile in Linux
#include <iostream>
#include "data.h"
#include "sistemTime.h"
using namespace std;
void Delay( long int secs ); // 3-second delay
void createNewTask(data &);
void taskInit(data &);
int kbhit( void ); // Controls if a key was pressed
unsigned int stringtoInt(string, unsigned int &, unsigned int &, bool &);
int stringtoInt(string );
int main (int argc, char** argv)
{
timeControl Time;
data Task;
string strOption;
int option = 0;
unsigned int Hour, Min;
unsigned int Speed;
taskInit(Task); // Initialization of tasks
cout << "****************************************************" << endl;
cout << " AGENDA FOR MY GRANDMOTHER " << endl;
cout << "****************************************************" << endl;
cout << "Actual Time: " << Time.hour() << ":" << Time.min() << endl << endl;
cout << "To see the task of the moment press 1" << endl;
cout << "To input an hour press 2" << endl;
cout << "To see the the actual Time 3" << endl;
cout << "To see the status of the task 4" << endl;
cout << "To input a speed factor press 5" << endl;
cout << "To see the menu press 6" << endl;
cout << "To add a new task press 7" << endl;
cout << "To finish press 8" << endl << endl;
while (option != 8){
while (!kbhit()) { // While no key is pressed
// Take the current time
Task.actualTask(Time.currentMin()); // Controls the automatic execution of tasks
Delay( 1 );
}
cin >> strOption;
option = stringtoInt(strOption);
switch (option) {
case 1: // Task of the moment
cout << "\nActual Time: " << Time.hour() << ":" << Time.min() << endl;
Task.taskStatus(Time.currentMin());
cout << "To see the menu press 6:" << endl;
break;
case 2: // Enter an hour, to show which task would be running
cout << "Enter the hour first, then the minutes" << endl;
cout << "Hours : ";
cin >> Hour;
cout << "Minutes: ";
cin >> Min;
Task.taskStatus(Hour * 60 + Min);
cout << "To see the menu press 6:" << endl;
break;
case 3: // Displaying the current time in standard format
cout << "Actual Time: " << Time.hour() << ":" << Time.min() << endl;
cout << "To see the menu press 6:" << endl;
break;
case 4: // Show the status of tasks
Task.showTasks();
Delay(3);
cout << "To see the menu press 6:" << endl;
break;
case 5: // Increase the speed factor
cout << "Actual Time: " << Time.hour() << ":" << Time.min() << endl;
cout << "Enter the speed factor ( 1 to 200 ) :" << endl;
cin >> Speed;
if ( Speed < 1 ){ Speed = 1;}
if ( Speed > 200 ){ Speed = 200;}
cout << "Speed :" << Speed << endl;
Time.speedFactor(Speed);
cout << "To see the menu press 6:" << endl;
break;
case 6: // Show the menu
cout << "To see the task of the moment press 1" << endl;
cout << "To input an hour press 2" << endl;
cout << "To see the the actual Time 3" << endl;
cout << "To see the status of the task 4" << endl;
cout << "To input a speed factor press 5" << endl;
cout << "To see the menu press 6" << endl;
cout << "To add a new task press 7" << endl;
cout << "To finish press 8" << endl;
break;
case 7: // New task
createNewTask(Task);
cout << "To see the menu press 6:" << endl;
break;
case 8: // Exit
cout << "Closing program" << endl;
break;
default:
cout << "Entry was not recognized enter again\n" << endl;
break;
}
}
Task.delet(Task);
//delete Task;
cout << "Press enter to continue ..." << endl;
cin >> strOption;
return 0;
}
// Detect if a key was pressed. To compile in Linux is required
int kbhit( void )
{
struct timeval tv;
fd_set read_fd;
tv.tv_sec=0;
tv.tv_usec=0;
FD_ZERO( &read_fd );
FD_SET( 0, &read_fd );
if( select( 1, &read_fd, NULL, NULL, &tv ) == -1 )
return 0;
if( FD_ISSET( 0,&read_fd ))
return 1;
return 0;
}
void createNewTask(data &Task){
string taskTexto;
string strStarTime, strEndTime;
unsigned int start, end,horaStart, minStart, horaEnd, minEnd;
bool ok1, ok2;
cout << "Creating a new task " << endl;
cout << "Enter the task text : ";
cin.ignore();
getline (cin,taskTexto); // I read the whole line of text
cout << "What is the start time of the task? enter the time as follows 15:45" << endl;
cout << "Time : ";
cin >> strStarTime;
cout << "What is the end time of the task?" << endl;
cout << "Time : ";
cin >> strEndTime;
start = stringtoInt(strStarTime, horaStart, minStart, ok1);
end = stringtoInt(strEndTime, horaEnd, minEnd, ok2);
if(ok1 && ok2){
Task.addNode(start, end, taskTexto, "Have you done it?");
cout << "The new task has been created" << endl;
cout << "Task : " << taskTexto << " Start " << horaStart <<":"<< minStart << " End " << horaEnd << ":" << minEnd << endl;
}
else{
cout << "Error!, the new task hasn't been created" << endl;
}
}
// initialization of the tasks
void taskInit(data &Task){
Task.addNode( 0, 0, 7, 0,"Sleep", "You should be sleeping");
Task.addNode( 7,12, 7,23,"Take the morning pills", "Did you take the pills?");
Task.addNode( 7,31, 8, 0,"Have breakfast", "Did you have breakfast?");
Task.addNode(11,30, 12, 0,"Cook", "Did you cook?");
Task.addNode(12,01, 12,45,"Lunch time", "Did you have lunch?");
Task.addNode(14,45, 15,45,"Take a nap", "Did you take a nap?");
Task.addNode(17, 0, 18, 0,"Go to the supermarket", "Did you do the shopping?");
Task.addNode(19,01, 20, 0,"Take the night pills", "Did you take the pills?");
Task.addNode(20,01, 21,45,"Have dinner", "Did you have dinner?");
}
unsigned int stringtoInt(string str,unsigned int &hora, unsigned int &min, bool &ok){
char charHora[] = {'0', '0','\0'},charMin[] = {'0', '0','\0'};
size_t found = str.find(':');
if (found!=std::string::npos){
str.copy(charHora,2,0);
str.copy(charMin,2,3);
hora = stoi(charHora);
min = stoi(charMin);
ok = true;
if (hora > 24){ hora = 24;}
if (min > 60){ min = 60;}
return(hora * 60 + min);
}
else{
cout << "Entry was not recognized" <<endl;
cout << "I didn't find the : in the string" << endl;
ok = false;
return 0;
}
}
int stringtoInt(string option){
int i;
try {
i = stoi(option); // string -> integer
}
catch (...) {
i = 9; // error management
//cout << "Entry was not recognized enter again\n" << endl;
}
return (i);
}
/* Three-Second Delay */
void Delay( long int secs ){
time_t tv_sec;
tv_sec = ( time_t )secs;
struct timespec delta = { tv_sec, 0}; // {seconds, nanoseconds}
while (nanosleep(&delta, &delta));
}
| [
"gon_x4@hotmail.com"
] | gon_x4@hotmail.com |
7042a2fca8190b7abe693d5c45d1b1f73a3c5d62 | 04e2587fdc480ad47a4329a0d87be13e8ed82560 | /Engine/include/Engine/Core/Components/ComponentsFactories.hh | 7f7bd26ec3dc0d40459f1b32acc5f2b430df3fbf | [] | no_license | MajorSquirrelTVS/Tekeimyung | 9309bb053572c3e3c3ffb1df5b514becff95bd1b | af70feeb5391a2f378acc9425f30568c66c8b6ca | refs/heads/master | 2020-04-15T05:36:40.209235 | 2017-05-22T09:36:25 | 2017-05-22T09:36:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 566 | hh | #pragma once
#include "BoxColliderComponentFactory.hpp"
#include "ButtonComponentFactory.hpp"
#include "CameraComponentFactory.hpp"
#include "DynamicComponentFactory.hpp"
#include "LightComponentFactory.hpp"
#include "NameComponentFactory.hpp"
#include "ParticleEmitterComponentFactory.hpp"
#include "RenderComponentFactory.hpp"
#include "RigidBodyComponentFactory.hpp"
#include "ScriptComponentFactory.hpp"
#include "SphereColliderComponentFactory.hpp"
#include "TextComponentFactory.hpp"
#include "TransformComponentFactory.hpp"
#include "UiComponentFactory.hpp"
| [
"guillaume.labey@epitech.eu"
] | guillaume.labey@epitech.eu |
b2ef6514c7019ab2ed225bcdef22bd6c376f9e18 | 29776f52905112cc99f30cb6f7a67bccaca0a257 | /Llista_03/quantes_xifres/X08783.cc | 3fa5416d60233757c11ac5d24f44ec50a6ea8b89 | [] | no_license | Cabahamaru/PRO1-FIB | 40e6d35f5ce8f69e3352d141d1ca9c190ac8d431 | 8b1ad27ec63acf0da1f507b5f02a1c75ece97113 | refs/heads/master | 2020-04-27T03:48:04.570903 | 2019-03-05T23:17:52 | 2019-03-05T23:17:52 | 174,035,144 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 243 | cc | #include <iostream>
using namespace std;
int main() {
int b, n, count;
count = 1;
while (cin >> b >> n) {
while (n >= b) {
count = count + 1;
n = n/b;
}
cout << count << endl;
count = 1;
}
}
| [
"jaume.riera200@gmail.com"
] | jaume.riera200@gmail.com |
42f418d9b3cb6699c2b845fbbaa3dc41a6346774 | 69005ab4c8cc5d88d7996d47ac8def0b28730b95 | /msvc-cluster-realistic-1000/src/dir_16/perf805.cpp | 8bf0f4e0307f876d71ca564868ffbe3be7b041f1 | [] | no_license | sakerbuild/performance-comparisons | ed603c9ffa0d34983a7da74f7b2b731dc3350d7e | 78cd8d7896c4b0255ec77304762471e6cab95411 | refs/heads/master | 2020-12-02T19:14:57.865537 | 2020-05-11T14:09:40 | 2020-05-11T14:09:40 | 231,092,201 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 207 | cpp | #include <Windows.h>
#include <vector>
#include <inc_0/header_4.h>
static_assert(sizeof(GenClass_4) > 0, "failed");
std::vector<int> perf_func_805() {
LoadLibrary("abc.dll");
return {805};
}
| [
"10866741+Sipkab@users.noreply.github.com"
] | 10866741+Sipkab@users.noreply.github.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.