// ====================方法一==================== void Print1ToMaxOfNDigits_1(int n) { if(n <= 0) return; char *number = new char[n + 1]; memset(number, '0', n); number[n] = '\0'; while(!Increment(number)) { PrintNumber(number); } delete []number; }
// Update the Fade Pattern void FadeUpdate() { // Calculate linear interpolation between Color1 and Color2 // Optimise order of operations to minimize truncation error uint8_t red = ((Red(Color1) * (TotalSteps - Index)) + (Red(Color2) * Index)) / TotalSteps; uint8_t green = ((Green(Color1) * (TotalSteps - Index)) + (Green(Color2) * Index)) / TotalSteps; uint8_t blue = ((Blue(Color1) * (TotalSteps - Index)) + (Blue(Color2) * Index)) / TotalSteps; uint8_t white = ((White(Color1) * (TotalSteps - Index)) + (White(Color2) * Index)) / TotalSteps; // Serial.print(red); Serial.print(","); // Serial.print(green); Serial.print(","); // Serial.print(blue); Serial.print(","); // Serial.print(white); Serial.println(); ColorSet(Color(red, green, blue, white)); show(); Increment(); }
static void KeyDown(AG_Event *event) { AG_Slider *sl = AG_SELF(); int keysym = AG_INT(1); switch (keysym) { case AG_KEY_UP: case AG_KEY_LEFT: Decrement(sl); AG_AddTimer(sl, &sl->moveTo, agKbdDelay, MoveTimeout, "%i", -1); break; case AG_KEY_DOWN: case AG_KEY_RIGHT: Increment(sl); AG_AddTimer(sl, &sl->moveTo, agKbdDelay, MoveTimeout, "%i", +1); break; } }
EXPORT_C TInteger& TInteger::operator--() { if (IsNegative()) { if (Increment(Ptr(), Size())) { CleanGrowL(2*Size()); (Ptr())[Size()/2]=1; } } else { if (Decrement(Ptr(), Size())) { this->CopyL(-1); } } return *this; }
void Profiler::ReadFrame(std::vector<GPUMarker>& frameMarkers) { int frame = CurrFrame - (NUM_BUFFERED_FRAMES - 1); while (GPUMarkers[GPUReadIndex].Frame == frame) { GLint resultAvailable = GL_FALSE; glGetQueryObjectiv(QueryIDs[GPUReadIndex], GL_QUERY_RESULT_AVAILABLE, &resultAvailable); if (resultAvailable == GL_TRUE) { GPUMarker& marker = GPUMarkers[GPUReadIndex]; glGetQueryObjectuiv(QueryIDs[GPUReadIndex], GL_QUERY_RESULT, &marker.TimeElapsed); frameMarkers.push_back(marker); } Increment(GPUReadIndex, NUM_GPU_MARKERS); } }
/////////////メイン関数///////////////////////////////////// int main () { int n, i, b, t, j; printf("集合の要素数は?\n"); scanf("%d", &n); /*要素数の入力*/ int S[n+1]; /*S[n]は条件判別に用いる*/ int A[MAX] = {}; /*A[]は集合Sに対応する2進数の配列*/ printf("集合の要素は?\n"); for (i=0; i<n; i++) { scanf("%d", &S[i]); /*集合の要素をすべて入力*/ } printf("判定したい部分和は?\n"); scanf("%d", &b); /*判定したい部分和を入力*/ clock_t start, end; /*時間を計測するのに用いる*/ start = clock(); /*計測開始*/ int k = sisu(n); /*kは部分集合S’の数*/ S[n] =0; t = 0; /*正しく条件判別を行う為にS[n]とtを0に初期化*/ for (j=0; j<k; j++) { /*部分集合の数kだけ操作を繰り返す*/ judge(n, A, S, b); /*judge関数にて条件適合時にS[n]=1*/ if (S[n]==1) { t = 1; /*t=1とすることで、すべての部分集合を挙げた後に*/ /*"YES"、"NO"判定を行える*/ } printf("."); /*printfの”.”で実行時間を稼がないと上のt=1が代入される前に*/ /*下の条件分岐ifで"else"を評価してしまう。*/ Increment(n, A); /*次の部分集合に更新する*/ } if (t==1) { printf("YES\n"); } else { printf("NO\n"); /*最後に"YES"、"NO"判定が出力される*/ } end = clock(); /*計測終了、及び計測結果を出力*/ printf("%.2f秒かかりました\n", (double)(end-start)/1000); return 0; }
EXPORT_C TInteger& TInteger::operator++() { if(NotNegative()) { if(Increment(Ptr(), Size())) { CleanGrowL(2*Size()); (Ptr())[Size()/2]=1; } } else { DecrementNoCarry(Ptr(), Size()); if(WordCount()==0) { this->CopyL(Zero()); } } return *this; }
void Legendre::FindPolynomial(DArray &dArray) { DMatrix dMatrix; dMatrix.reserve(nn); dArray.clear(); dArray.reserve(nn); //double dbg[6] = { -.7746, .5556, 0., .8889, .7746, .5556 }; for(int i = 0; i < nn; ++i) { double rat = static_cast<double>(i + 1) / static_cast<double>(nn); dArray.push_back((i % 2) ? 1. - fabs(dArray[i - 1]) / (ul - ll) * 2. : (ll + (ul - ll) * rat)); //dArray.push_back(rat); //dArray.push_back(dbg[i]); cerr << "Initially " << i << ": " << dArray[i] << endl; dMatrix.push_back(dIntegrals); } do { Increment(dMatrix, dArray); SolveSytem(dMatrix, dArray); } while(ComputeError(dArray) > precision); ExtractPolynomial(dArray); }
bool GridSearch::Increment(size_t index_){ fParams[index_] += fStepSizes.at(index_); // wrap around past the maximum if (fParams[index_] > fMaxima.at(index_)){ fParams[index_] = fMinima.at(index_); // if its the last index no rippling to do if (index_ == fStepSizes.size() - 1) return false; // ripple up to next index if (Increment(index_ + 1)) // propagate the false down return true; else return false; } return true; }
void print1ToMaxOfNDigits(int n) { if(n<=0) return; char *number = new char[n+1]; memset(number,'0',n); number[n] = '\0'; while(Increment(number)) { char *name = number; while (*name=='0') { name++; } printf("%s\n",name); } delete[] number; }
void Resize(int newsize) { if(newsize<=_size)return; if(newsize<=_size+_empty) { int sh=newsize-_size; _data-=sh; Copy(sh,0,_count); _size+=sh; _empty-=sh; return; } newsize=Increment(newsize); T** newdata=new T*[newsize+_empty/2]; newdata+=_empty/2; memcpy(newdata,_data,sizeof(T*)*_count); _size=newsize; delete [] (_data-_empty); _empty/=2; _data=newdata; }
void Resize(int newsize,int emptysize=0) { if(newsize<=_size)return; if(newsize<=_size+_empty && _size+_empty-newsize>_size/32) { int sh=newsize-_size; if(sh<_empty/2)sh=_empty/2; _data-=sh; //Copy(sh,0,_count); memcpy(_data,_data+sh,SZ*_count); _size+=sh; _empty-=sh; return; } newsize=Increment(newsize); emptysize=emptysize>_empty/2?emptysize:_empty/2; T* newdata=new T[newsize+emptysize]; newdata+=emptysize; if(_data)memcpy(newdata,_data,SZ*_count); _size=newsize; if(_data)delete [] (_data-_empty); _empty=emptysize; _data=newdata; }
// Called when a key is pressed. The only keys that have an effect are // the Select and Cancel keys which both terminate the action and the // arrow keys. The effect of the arrow keys depends on the orientation of // the slider. void MHSlider::KeyEvent(MHEngine *engine, int nCode) { switch (nCode) { case 15: // Select key case 16: // Cancel key m_fInteractionStatus = false; engine->SetInteraction(0); InteractionCompleted(engine); // Interaction is interrupted. engine->EventTriggered(this, EventInteractionCompleted); break; case 1: // Up if (m_orientation == SliderUp) { Increment(engine); } else if (m_orientation == SliderDown) { Decrement(engine); } break; case 2: // Down if (m_orientation == SliderUp) { Decrement(engine); } else if (m_orientation == SliderDown) { Increment(engine); } break; case 3: // Left if (m_orientation == SliderLeft) { Increment(engine); } else if (m_orientation == SliderRight) { Decrement(engine); } break; case 4: // Right if (m_orientation == SliderLeft) { Decrement(engine); } else if (m_orientation == SliderRight) { Increment(engine); } break; } }
CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { CFX_PtrArray* cornerPoints = m_rectangleDetector->Detect(e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CBC_ResultPoint* pointA = (CBC_ResultPoint*)(*cornerPoints)[0]; CBC_ResultPoint* pointB = (CBC_ResultPoint*)(*cornerPoints)[1]; CBC_ResultPoint* pointC = (CBC_ResultPoint*)(*cornerPoints)[2]; CBC_ResultPoint* pointD = (CBC_ResultPoint*)(*cornerPoints)[3]; delete cornerPoints; cornerPoints = NULL; CFX_PtrArray transitions; transitions.Add(TransitionsBetween(pointA, pointB)); transitions.Add(TransitionsBetween(pointA, pointC)); transitions.Add(TransitionsBetween(pointB, pointD)); transitions.Add(TransitionsBetween(pointC, pointD)); BC_FX_PtrArray_Sort(transitions, &ResultPointsAndTransitionsComparator); delete ((CBC_ResultPointsAndTransitions*)transitions[2]); delete ((CBC_ResultPointsAndTransitions*)transitions[3]); CBC_ResultPointsAndTransitions* lSideOne = (CBC_ResultPointsAndTransitions*)transitions[0]; CBC_ResultPointsAndTransitions* lSideTwo = (CBC_ResultPointsAndTransitions*)transitions[1]; CFX_MapPtrTemplate<CBC_ResultPoint*, int32_t> pointCount; Increment(pointCount, lSideOne->GetFrom()); Increment(pointCount, lSideOne->GetTo()); Increment(pointCount, lSideTwo->GetFrom()); Increment(pointCount, lSideTwo->GetTo()); delete ((CBC_ResultPointsAndTransitions*)transitions[1]); delete ((CBC_ResultPointsAndTransitions*)transitions[0]); transitions.RemoveAll(); CBC_ResultPoint* maybeTopLeft = NULL; CBC_ResultPoint* bottomLeft = NULL; CBC_ResultPoint* maybeBottomRight = NULL; FX_POSITION itBegin = pointCount.GetStartPosition(); while (itBegin != NULL) { CBC_ResultPoint* key = 0; int32_t value = 0; pointCount.GetNextAssoc(itBegin, key, value); if (value == 2) { bottomLeft = key; } else { if (maybeBottomRight == NULL) { maybeBottomRight = key; } else { maybeTopLeft = key; } } } if (maybeTopLeft == NULL || bottomLeft == NULL || maybeBottomRight == NULL) { delete pointA; delete pointB; delete pointC; delete pointD; e = BCExceptionNotFound; return NULL; } CFX_PtrArray corners; corners.SetSize(3); corners[0] = maybeTopLeft; corners[1] = bottomLeft; corners[2] = maybeBottomRight; OrderBestPatterns(&corners); CBC_ResultPoint* bottomRight = (CBC_ResultPoint*)corners[0]; bottomLeft = (CBC_ResultPoint*)corners[1]; CBC_ResultPoint* topLeft = (CBC_ResultPoint*)corners[2]; CBC_ResultPoint* topRight = NULL; int32_t value; if (!pointCount.Lookup(pointA, value)) { topRight = pointA; } else if (!pointCount.Lookup(pointB, value)) { topRight = pointB; } else if (!pointCount.Lookup(pointC, value)) { topRight = pointC; } else { topRight = pointD; } int32_t dimensionTop = CBC_AutoPtr<CBC_ResultPointsAndTransitions>( TransitionsBetween(topLeft, topRight)) ->GetTransitions(); int32_t dimensionRight = CBC_AutoPtr<CBC_ResultPointsAndTransitions>( TransitionsBetween(bottomRight, topRight)) ->GetTransitions(); if ((dimensionTop & 0x01) == 1) { dimensionTop++; } dimensionTop += 2; if ((dimensionRight & 0x01) == 1) { dimensionRight++; } dimensionRight += 2; CBC_AutoPtr<CBC_CommonBitMatrix> bits(NULL); CBC_AutoPtr<CBC_ResultPoint> correctedTopRight(NULL); if (4 * dimensionTop >= 7 * dimensionRight || 4 * dimensionRight >= 7 * dimensionTop) { correctedTopRight = CBC_AutoPtr<CBC_ResultPoint>( CorrectTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight, dimensionTop, dimensionRight)); if (correctedTopRight.get() == NULL) { correctedTopRight = CBC_AutoPtr<CBC_ResultPoint>(topRight); } else { delete topRight; topRight = NULL; } dimensionTop = CBC_AutoPtr<CBC_ResultPointsAndTransitions>( TransitionsBetween(topLeft, correctedTopRight.get())) ->GetTransitions(); dimensionRight = CBC_AutoPtr<CBC_ResultPointsAndTransitions>( TransitionsBetween(bottomRight, correctedTopRight.get())) ->GetTransitions(); if ((dimensionTop & 0x01) == 1) { dimensionTop++; } if ((dimensionRight & 0x01) == 1) { dimensionRight++; } bits = CBC_AutoPtr<CBC_CommonBitMatrix>( SampleGrid(m_image, topLeft, bottomLeft, bottomRight, correctedTopRight.get(), dimensionTop, dimensionRight, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } else { int32_t dimension = std::min(dimensionRight, dimensionTop); correctedTopRight = CBC_AutoPtr<CBC_ResultPoint>( CorrectTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension)); if (correctedTopRight.get() == NULL) { correctedTopRight = CBC_AutoPtr<CBC_ResultPoint>(topRight); } else { delete topRight; topRight = NULL; } int32_t dimensionCorrected = std::max(CBC_AutoPtr<CBC_ResultPointsAndTransitions>( TransitionsBetween(topLeft, correctedTopRight.get())) ->GetTransitions(), CBC_AutoPtr<CBC_ResultPointsAndTransitions>( TransitionsBetween(bottomRight, correctedTopRight.get())) ->GetTransitions()); dimensionCorrected++; if ((dimensionCorrected & 0x01) == 1) { dimensionCorrected++; } bits = CBC_AutoPtr<CBC_CommonBitMatrix>(SampleGrid( m_image, topLeft, bottomLeft, bottomRight, correctedTopRight.get(), dimensionCorrected, dimensionCorrected, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } CFX_PtrArray* result = new CFX_PtrArray; result->SetSize(4); result->Add(topLeft); result->Add(bottomLeft); result->Add(bottomRight); result->Add(correctedTopRight.release()); return new CBC_QRDetectorResult(bits.release(), result); }
void shapeFunc::halfcicle_bullet(float speed, Vec2 fromPosition, Vec2 toPosition, int number){ bool isjishu; float mMidValue = 0; if (number %2 == 0) { mMidValue = number % 2 + number - 3; isjishu = 0; }else { isjishu = 1; mMidValue = number % 2 + number - 3; } //以子弹起始点为原心,建立直角坐标系 //一,二,三,四象限内,和X轴正负方向,Y轴正负方向,原心9种情况 bool isInQuadrant1 = (toPosition.x > fromPosition.x) && (toPosition.y > fromPosition.y); bool isInQuadrant2 = (toPosition.x < fromPosition.x) && (toPosition.y > fromPosition.y); bool isInQuadrant3 = (toPosition.x < fromPosition.x) && (toPosition.y < fromPosition.y); bool isInQuadrant4 = (toPosition.x > fromPosition.x) && (toPosition.y < fromPosition.y); bool isOnXR = (toPosition.y == fromPosition.y) && (toPosition.x > fromPosition.x); bool isOnXL = (toPosition.y == fromPosition.y) && (toPosition.x < fromPosition.x); bool isOnYT = (toPosition.x == fromPosition.x) && (toPosition.y > fromPosition.y); bool isOnYD = (toPosition.x == fromPosition.x) && (toPosition.y < fromPosition.y); bool isZero = (toPosition.x == fromPosition.x) && (toPosition.y == fromPosition.y); //起始点和触摸点形成的直线的斜率 float mMidLineSlope = (fromPosition.y - toPosition.y) / (fromPosition.x - toPosition.x); //弧度值 float mMidLineAngleR = atan(mMidLineSlope); //角度值 float mMidLineAngleD =CC_RADIANS_TO_DEGREES( mMidLineAngleR); float mm = mMidLineAngleD; //lo //如果在二,三象限,mMidLineAngleD会小于0 if (isInQuadrant2 || isInQuadrant3) { //转换为正数,方便计算 mMidLineAngleD = 180 + mMidLineAngleD; } else if (isOnYT) { mMidLineAngleD = 90; } else if (isOnXR) { mMidLineAngleD = 0; } else if (isOnXL) { mMidLineAngleD = 180; } else if (isInQuadrant4) { //在第四象限mMidLineAngleD小于0,转换为正数 mMidLineAngleD = 360 + mMidLineAngleD; } else if (isOnYD) { mMidLineAngleD = 270; } else if (isZero) { return ; } if (isInQuadrant4) { mMidLineAngleD = 360 - mMidLineAngleD; } else if (isInQuadrant2) { mMidLineAngleD = 180 - mMidLineAngleD; } else if (isInQuadrant3) { mMidLineAngleD += 180; } //x和y方向的增量 float mIncrementX = 0; float mIncrementY = 0; float mIncrement = 3; bool isone = isInQuadrant1; bool istwo = isInQuadrant2; bool isthree = isInQuadrant3; bool isforth = isInQuadrant4; //每颗子弹形成的直线的角度 float mLineAngleD = 0; if (isjishu) { mLineAngleD = mm - (number-number/2-1)*ANGLE; }else { mLineAngleD = mm - (number/2 )*ANGLE+ANGLE/2; } for (int i = 1 ; i <= number ; i++) { float mlined = 0; if (mLineAngleD < 0) { if (isInQuadrant1) { mlined = mLineAngleD + 360; isone = false; isforth = true; }else if (isInQuadrant3) { mlined = mLineAngleD + 180; istwo = true; isthree = false; }else if (isInQuadrant2) { mlined = mLineAngleD; istwo = true; }else { mlined = mLineAngleD; isforth = true; } if (isOnYT) { isone = true; if (isjishu) { mIncrementY = speed; } } else if (isOnXR) { isforth = true; if (isjishu) { mIncrementX = speed; } } else if (isOnXL) { istwo = true; if (isjishu) { mIncrementX = -speed; } }else if (isOnYD) { isforth = true; if (isjishu) { mIncrementY = -speed; } } }else if(mLineAngleD > 0) { if (isInQuadrant1) { mlined = mLineAngleD; isone = true; isforth = false; }else if (isInQuadrant3) { mlined = mLineAngleD; istwo = false; isthree = true; }else if (isInQuadrant2) { mlined = 180 + mLineAngleD; istwo = false; isthree = true; }else { mlined = mLineAngleD; isforth = false; isone = true; } if (isOnYT) { istwo = true; isone = false; if (isjishu) { mIncrementY = speed; } } else if (isOnXR) { isforth = false; isone = true; if (isjishu) { mIncrementX = speed; } } else if (isOnXL) { istwo = false; isthree = true; if (isjishu) { mIncrementX = -speed; } }else if (isOnYD) { isthree = true; isforth = false; if (isjishu) { mIncrementY = -speed; } } } float mLineAngleR = CC_DEGREES_TO_RADIANS(mlined); if (isone) { mIncrementX = abs(mIncrement * cos(mLineAngleR))*this->getSpeed(); mIncrementY = abs(mIncrement * sin(mLineAngleR))*this->getSpeed(); } else if (istwo) { mIncrementX = mIncrement * cos(mLineAngleR)*this->getSpeed(); mIncrementY = abs(mIncrement * sin(mLineAngleR))*this->getSpeed(); if (mIncrementX > 0) mIncrementX = -mIncrementX; }else if (isthree) { mIncrementX = mIncrement * cos(mLineAngleR)*this->getSpeed(); mIncrementY = mIncrement * sin(mLineAngleR)*this->getSpeed(); if (mIncrementX > 0) mIncrementX = -mIncrementX; if (mIncrementY > 0) mIncrementY = -mIncrementY; } else if (isforth) { mIncrementX = abs(mIncrement * cos(mLineAngleR))*this->getSpeed(); mIncrementY = mIncrement * sin(mLineAngleR)*this->getSpeed(); if (mIncrementY > 0) mIncrementY = -mIncrementY; } Increment mResult = Increment(mIncrementX, mIncrementY); own.push_back(mResult); mLineAngleD += ANGLE; } //每颗子弹形成的直线的弧度 return; }
ZipIterator<Iterators...>& operator++() { TupleUtils::ApplyFunction(Increment(), m_iterators); return *this; }
T* operator--() volatile { return Increment() - 1; }
void DMYWDate<Cal, WeekType>::Increment( int weekday, int n ) { int days = DaysUntilWeekday( weekday, n ); Increment( days ); }
T FibCounter_t<T>::operator ++ (int) { T Count_ = _Count; Increment(); return Count_; }
Time_Range::Time_Range (int steps, Time_Type format) : Range_Array (10), Time_Step (steps, format) { Increment (1); Period_Flag (false); }
///////////////////////////////////////////////////////////////////////////////////////////////// // PCMACDec - PCMAC part of avalanche (does the decryption and generate the PCMAC tag) // * INPUT: cipherText c, mlen, nonce npub, PCMACKey // * OUTPUT: PCMACTag, plainText m ///////////////////////////////////////////////////////////////////////////////////////////////// int PCMACDec(Chunk PCMACTag, unsigned char *m, unsigned long long *mlen, const unsigned char *c, unsigned long long clen, unsigned char *nonce, unsigned char *PCMACKey) { Byte finalKey[kSIZE]; //array for the xored key int i, j; //counters int isValid = -1; //not valid message (missing EOT) int test = 0; unsigned long long numOfChunks = 0; //number of blocks/chunks to process in a message Chunk r; AESArguments *input; AES_KEY key; numOfChunks = (unsigned long long) clen / SIZE; input = (struct AES_Arguments*) malloc( (numOfChunks + 1) * sizeof(struct AES_Arguments)); SetupForDec(input, c, numOfChunks); for (j = 0; j < numOfChunks; j++) { Increment(nonce); for (i = 0; i < SIZE; i++) { for (i = 0; i < kSIZE; i++) input[j].nonce[i] = nonce[i]; } } for (j = 0; j < numOfChunks; j++) //decryption process { XORKey(input[j].nonce, PCMACKey, finalKey); AES_set_decrypt_key(finalKey, 192, &key); AES_decrypt(input[j].cipherText, input[j].plainText, &key); } for (j = 0; j < numOfChunks; j++) //to be edited for (i = 0; i < SIZE; i++) m[(j * SIZE) + i] = input[j + 1].plainText[i]; *mlen = clen - CRYPTO_ABYTES + SIZE; if (m[*mlen] == EOT) isValid = 0; if (isValid != 0) { free(input); return isValid; } memcpy(r, input[0].plainText, SIZE); TagGeneration(m, r, PCMACTag, numOfChunks); free(input); return isValid; }
/// Compute the next combination, returning the number of combinations computed /// so far; if there are no more combinations, return -1. int Next(void) throw() { if(k < 1) return -1; if(Increment(k-1) != -1) return ++nc; return -1; }
void InitStateMachine( struct TStateMachine *ptMachine) /****************************************************************************/ /* Initialises one single statemachine. */ /* The current state is initalised, and all action records are updated. */ /* In each action record, the ptNextState pointer is substituted. */ /* If the corresponding pcNextStateName is not found in the list of states, */ /* an error is generated. (In the previous internal releases of AutoTest */ /* the ptNextState field was not available, and the states were searched */ /* during runtime.) */ /****************************************************************************/ { struct TStateList *ptStateListWalker; struct TActionList *ptActionListWalker; struct TTransitionList *ptTransitionListWalker; struct TState *ptState; /* Initialise the initial state. Which is the first mentioned state.. */ ptMachine->ptCurrentState = ptMachine->ptStates->ptThis; ptMachine->ptActionInProgress = NULL; ptMachine->ptRunningTimer = NULL; ptMachine->ptRunningTimerTransition = NULL; ptMachine->ptStateInTimer = NULL; /* Next, reset all variables */ InitVarList(ptMachine->ptLocalVars); /* Next, initialise an eventually rescue state */ if (ptMachine->pcRescueStateName != NULL) { ptMachine->ptRescueState = FindState(ptMachine->pcRescueStateName, ptMachine->ptStates); if (ptMachine->ptRescueState == NULL) { AddError2("Rescue State %s not defined.", ptMachine->pcRescueStateName); } } else { ptMachine->ptRescueState = NULL; } /* Next, initialise all states. */ for (ptStateListWalker = ptMachine->ptStates; ptStateListWalker != NULL; ptStateListWalker = ptStateListWalker->ptNext) { if (ptStateListWalker->ptThis != NULL) { /* In a state, initialise all transitions: */ for (ptTransitionListWalker = ptStateListWalker->ptThis->ptTransitionList; ptTransitionListWalker != NULL; ptTransitionListWalker = ptTransitionListWalker->ptNext) { ptTransitionListWalker->ptThis->lTransitionCounter = 0; /* In a transition: Initialise all actions */ /* - set the lActionCounter to 0, */ for (ptActionListWalker = ptTransitionListWalker->ptThis->ptActionList; ptActionListWalker != NULL; ptActionListWalker = ptActionListWalker->ptNext) { ptActionListWalker->ptThis->lActionCounter = 0; InitVarList(ptActionListWalker->ptThis->ptVarList); } /* In a state, initialise all transitions: */ /* - initialise all ptNextState, based on pcNextStateName */ if (ptTransitionListWalker->ptThis != NULL) { if (ptTransitionListWalker->ptThis->pcNextStateName == NULL) { /* No new statename intended. This is only allowed by a */ /* transition containing a TERMINATE transition... */ if ((ptTransitionListWalker->ptThis->ptActionList->ptThis-> iActionType != TERMINATE_ACTION) /* && (ptTransitionListWalker->ptThis->ptActionList->ptThis->iActionType != END_ACTION) */ ) { AddError2("In line nr. %d, a next state must be defined", ptTransitionListWalker->ptThis->ptActionList->ptThis-> iSourceLineNumber); } } else if (*(ptTransitionListWalker->ptThis->pcNextStateName) == '\0') { /* No statename mentinoned, the next state is intended.. */ ptTransitionListWalker->ptThis->ptNextState = ptStateListWalker->ptNext->ptThis; if (ptTransitionListWalker->ptThis->ptNextState == NULL) { AddError3("In line nr. %d, implicit next state is defined. %s", ptTransitionListWalker->ptThis->ptActionList->ptThis-> iSourceLineNumber, "This is only allowed if there IS a next state.."); } } else { ptState = FindState(ptTransitionListWalker->ptThis->pcNextStateName, ptMachine->ptStates); if (ptState == NULL) { AddError3("In line nr. %d, state %s does not exist", ptTransitionListWalker->ptThis->ptActionList->ptThis-> iSourceLineNumber, ptTransitionListWalker->ptThis->pcNextStateName); } else { ptTransitionListWalker->ptThis->ptNextState = ptState; Increment(&(ptState->iRefCount)); } } } } } } }
T* operator++() volatile { return Increment() + 1; }
/* * This function injects a single character into the widget. */ static int _injectCDKUScale (CDKOBJS *object, chtype input) { CDKUSCALE *widget = (CDKUSCALE *)object; int ppReturn = 1; unsigned ret = unknownUnsigned; bool complete = FALSE; /* Set the exit type. */ setExitType(widget, 0); /* Draw the field. */ drawCDKUScaleField (widget); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf(widget) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf(widget) (vUSCALE, widget, PreProcessDataOf(widget), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a key binding. */ if (checkCDKObjectBind(vUSCALE, widget, input) != 0) { checkEarlyExit(widget); complete = TRUE; } else { switch (input) { case KEY_LEFT : setEditPosition(widget, widget->fieldEdit + 1); break; case KEY_RIGHT : setEditPosition(widget, widget->fieldEdit - 1); break; case KEY_DOWN : Decrement(widget->current, widget->inc); break; case KEY_UP : Increment(widget->current, widget->inc); break; case KEY_PPAGE : Increment(widget->current, widget->fastinc); break; case KEY_NPAGE : Decrement(widget->current, widget->fastinc); break; case KEY_HOME : widget->current = widget->low; break; case KEY_END : widget->current = widget->high; break; case KEY_TAB : case KEY_ENTER : setExitType(widget, input); ret = (widget->current); complete = TRUE; break; case KEY_ESC : setExitType(widget, input); complete = TRUE; break; case CDK_REFRESH : eraseCDKScreen (ScreenOf(widget)); refreshCDKScreen (ScreenOf(widget)); break; default : if (widget->fieldEdit) { if (!performEdit(widget, input)) BEEP(); } else { /* * The cursor is not within the editable text. Interpret * input as commands. */ switch (input) { case 'd': case '-': return _injectCDKUScale(object, KEY_DOWN); case '+': return _injectCDKUScale(object, KEY_UP); case 'D': return _injectCDKUScale(object, KEY_NPAGE); case '0': return _injectCDKUScale(object, KEY_HOME); default: BEEP(); break; } } break; } } limitCurrentValue(widget); /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf(widget) != 0)) { PostProcessFuncOf(widget) (vUSCALE, widget, PostProcessDataOf(widget), input); } } if (!complete) { drawCDKUScaleField (widget); setExitType(widget, 0); } ResultOf(widget).valueUnsigned = ret; return (ret != unknownUnsigned); }
void HlDebug::Update() { static BtBool isLoaded = BtFalse; if(isLoaded == BtFalse) { Load(); isLoaded = BtTrue; } if( ApConfig::IsDebug() == BtFalse ) { return; } // Select options if(UiKeyboard::pInstance()->IsPressed(UiKeyCode_UP)) { Decrement(); } else if(UiKeyboard::pInstance()->IsPressed(UiKeyCode_DOWN)) { Increment(); } HlItem &item = m_items[DebugIndex]; if( item.m_isReadOnly ) { return; } BtFloat diff = ( item.m_maxFloat - item.m_minFloat ) / 20.0f; diff = diff * BtTime::GetTick(); if( UiKeyboard::pInstance()->IsHeld( UiKeyCode_RSHIFT ) ) { diff *= 10.0f; } if( UiKeyboard::pInstance()->IsPressed( UiKeyCode_LEFT ) || ( UiKeyboard::pInstance()->IsHeld( UiKeyCode_LEFT ) && UiKeyboard::pInstance()->IsHeld( UiKeyCode_RSHIFT ))) { if(item.m_type == HlDebugEnum) { BtU32 value = *item.m_pEnum; if( value > 0 ) { value--; *item.m_pEnum = value; } } else if(item.m_type == HlDebugSave) { Save(); } else if(item.m_type == HlDebugNode) { item.m_isCollapsed = BtTrue; } else if(item.m_type == HlDebugBool) { *item.m_pBool = BtFalse; } else if(item.m_type == HlDebugFloat) { *item.m_pFloat -= diff; MtClamp( *item.m_pFloat, item.m_minFloat, item.m_maxFloat ); } else if( item.m_type == HlDebugInteger ) { *item.m_pInteger -= item.m_diffInt; MtClamp( *item.m_pInteger, item.m_minInt, item.m_maxInt ); } } if( UiKeyboard::pInstance()->IsPressed(UiKeyCode_RIGHT) || ( UiKeyboard::pInstance()->IsHeld(UiKeyCode_RIGHT) && UiKeyboard::pInstance()->IsHeld(UiKeyCode_RSHIFT))) { if( item.m_type == HlDebugEnum ) { BtU32 value = *item.m_pEnum; value++; if( value < item.m_maxInt ) { *item.m_pEnum = value; } } else if(item.m_type == HlDebugSave) { Save(); } else if(item.m_type == HlDebugBool) { *item.m_pBool = BtTrue; } else if(item.m_type == HlDebugNode) { item.m_isCollapsed = BtFalse; } else if( item.m_type == HlDebugFloat ) { *item.m_pFloat += diff; MtClamp( *item.m_pFloat, item.m_minFloat, item.m_maxFloat ); } else if( item.m_type == HlDebugInteger ) { *item.m_pInteger += item.m_diffInt; MtClamp( *item.m_pInteger, item.m_minInt, item.m_maxInt ); } } }
void VectorReader::ReadData(void* pDest, int iSize) { memcpy(pDest, &m_Data[m_iOffs], iSize); Increment(iSize); }
T* operator--(int) volatile { return Increment(); }
T FibCounter_t<T>::FindGreaterOrEqual(T Value_) { for (Reset(); Value_ > Counter(); Increment()); return _Count; }
void StatTracker::Render(float y) { BitmapFont* pFont = Game::GetInstance()->GetFont(); SGD::Point pos; pos.x = 200; pos.y = y; std::stringstream display; // Total Time Played int timePlayed = (int)m_fTimePlayed; display << "Total Time Played:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); int days = timePlayed / 86400; timePlayed -= days * 86400; display << "\t\t"; display << days; display << " Days"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); int hours = timePlayed / 3600; timePlayed -= hours * 3600; display << "\t\t"; display << hours; display << " Hours"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); int minutes = timePlayed / 60; timePlayed -= minutes * 60; display << "\t\t"; display << minutes; display << " Minutes"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); display << "\t\t"; display << timePlayed; display << " Seconds"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 3); // Build Phase Time Increment(pos, display); display << "Build Phase Time:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); timePlayed = (int)m_fBuildPhaseTime; Increment(pos, display); days = timePlayed / 86400; timePlayed -= days * 86400; display << "\t\t"; display << days; display << " Days"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); hours = timePlayed / 3600; timePlayed -= hours * 3600; display << "\t\t"; display << hours; display << " Hours"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); minutes = timePlayed / 60; timePlayed -= minutes * 60; display << "\t\t"; display << minutes; display << " Minutes"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); display << "\t\t"; display << timePlayed; display << " Seconds"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 3); // Survival Phase Time Increment(pos, display); display << "Survival Phase Time:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); timePlayed = (int)m_fSurvivalTime; Increment(pos, display); days = timePlayed / 86400; timePlayed -= days * 86400; display << "\t\t"; display << days; display << " Days"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); hours = timePlayed / 3600; timePlayed -= hours * 3600; display << "\t\t"; display << hours; display << " Hours"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); minutes = timePlayed / 60; timePlayed -= minutes * 60; display << "\t\t"; display << minutes; display << " Minutes"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); display << "\t\t"; display << timePlayed; display << " Seconds"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 3); // Distance Walked Increment(pos, display); display << "Distance Walked:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); int distance = (int)m_fDistanceWalked; Increment(pos, display); int kilo = distance/1000; distance -= kilo * 1000; display << "\t\t"; display << kilo; display << "."; display << distance; display << "Kilometers"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 6); // Total Rounds Survived Increment(pos, display); display << "Total Rounds Survived: "; display << m_uRoundsSurvived; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 7); // Survival Streak Increment(pos, display); display << "Highest Round Reached: "; display << m_uConsecutiveRoundsSurvived; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 7); // Total Kills Increment(pos, display); display << "Total Kills: "; display << m_uTotalKills; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 7); // Blood Spilled Increment(pos, display); display << "Blood Spilled:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); float blood = m_fBloodSpilled; float gallon = blood / 4.54f; display << "\t\t"; display << gallon; display << " Imperial Gallons"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 6); // Grenades Thrown Increment(pos, display); display << "Weight of Grenades Thrown:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); float weight = (float)((m_uGrenadesThrown * 400.0f)/1000.0f); Increment(pos, display); if ( weight > 1.0f ) { display << weight; display << " Kilograms"; } else { display << weight * 1000.0f; display << " Grams"; } pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 6); // Shots Fired Increment(pos, display); display << "Total Shots Fired: "; display << m_uTotalShotsFired; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 7); // Machine Gun Increment(pos, display); display << "Weight in Machine Gun Shells Fired:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); weight = (float)((m_uMachineGunBullets * 11.8f)/1000.0f); Increment(pos, display); if ( weight > 1.0f ) { display << weight; display << " Kilograms"; } else { display << weight * 1000.0f; display << " Grams"; } pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 6); // Shotgun Increment(pos, display); display << "Weight in Shotgun Shells Fired:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); weight = (float)((m_uShotgunShells * 7.795f)/1000.0f); Increment(pos, display); if ( weight > 1.0f ) { display << weight; display << " Kilograms"; } else { display << weight * 1000.0f; display << " Grams"; } pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 6); // RPG Increment(pos, display); display << "Weight in RPG's Fired:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); weight = (float)((m_uRPGRounds * 2200.0f)/1000.0f); Increment(pos, display); if ( weight > 1.0f ) { display << weight; display << " Kilograms"; } else { display << weight * 1000.0f; display << " Grams"; } pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 6); // HatTrick Increment(pos, display); display << "Weight in Hat Trick Pucks Fired:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); weight = (float)((m_uHatTrickShots * 185.0f)/1000.0f); Increment(pos, display); if ( weight > 1.0f ) { display << weight; display << " Kilograms"; } else { display << weight * 1000.0f; display << " Grams"; } pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 6); // Walls Increment(pos, display); display << "Walls:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); display << m_uWallsPlaced; display << " Placed"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); display << m_uWallsPickedUp; display << " Picked Up"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 5); // Windows Increment(pos, display); display << "Windows:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); display << m_uWindowsPlaced; display << " Placed"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); display << m_uWindowsPickedUp; display << " Picked Up"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 5); // Towers Increment(pos, display); display << "Towers:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); display << m_uTowersBought; display << " Bought"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); display << m_uTowersSold; display << " Sold"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 5); // Traps Increment(pos, display); display << "Traps:"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); display << m_uTrapsBought; display << " Bought"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display); display << m_uTrapsSold; display << " Sold"; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); Increment(pos, display, 5); // Money Increment(pos, display); display << "Loonies Spent: "; display << m_uMoneySpent; pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } ); }