void RankScene::unlockHeroRequestCompleted(cocos2d::CCNode *sender, void *data){ CCHttpResponse* response = (CCHttpResponse*)data; if (!response) { return; } int statusCode = response->getResponseCode(); std::vector<char> *buffer = response->getResponseData(); printJson(buffer); if (statusCode == 201) { changeGold(-MainUser->HeroUnLockPrice[HeroProcessing]); MainUser->HeroUnLocked[HeroProcessing] = true; UnlockAnimation(HeroProcessing); goldProcessingIndex = 4; updateUserGold(); } else{ MessageBox->closeMessageBox(); MessageBox = AsMessageBox::createMessageBox("与服务器通信失败,\n请检查您的网络", 2, 1); MessageBox->setPosition(CCPointZero); addChild(MessageBox,1000); } }
void RankScene::HeroLevelUpRequestCompleted(CCNode* sender,void* data){ CCHttpResponse* response = (CCHttpResponse*)data; if (!response) { return; } int statusCode = response->getResponseCode(); std::vector<char> *buffer = response->getResponseData(); printJson(buffer); if (statusCode == 204) { changeGold(-MainUser->HeroLevelUpGold[MainUser->HeroLevel[roleIndex-1]-1]); MainUser->HeroLevel[roleIndex-1]++; LevelUpAnimation(roleIndex-1); goldProcessingIndex = 4; updateUserGold(); } else{ MessageBox->closeMessageBox(); MessageBox = AsMessageBox::createMessageBox("与服务器通信失败,\n请检查您的网络", 2, 1); MessageBox->setPosition(CCPointZero); addChild(MessageBox,1000); } }
DWORD WINAPI toolThreadProc(LPVOID lpParam) { CMemReader& reader = CMemReader::getMemReader(); CConfigData *config = (CConfigData *)lpParam; int persistentShouldGo = 0; time_t lastPathNotFoundTm = 0; time_t lastBankerSuccessTm = 0; int bankerPauseAfterSuccess = 5; int modRuns = 0; while (!toolThreadShouldStop) { Sleep(400); modRuns++; if (time(NULL) - lastBankerSuccessTm <= bankerPauseAfterSuccess) continue; if (!persistentShouldGo && shouldBank(config)) persistentShouldGo = 1; const char* controller = CVariableStore::getVariable("walking_control"); if (!persistentShouldGo && config->stopByBanker && (!strcmp(controller, "seller") || !strcmp(controller, "depotwalker")) && canBank(config)) persistentShouldGo = 1; if (persistentShouldGo && modRuns % 5 == 0 && !canBank(config))//do not go to bank if can't go anymore persistentShouldGo = 0; bool control = strcmp(CVariableStore::getVariable("walking_control"), "banker") == 0; int modpriority = atoi(CVariableStore::getVariable("walking_priority")); // if wants control if (persistentShouldGo) { //if no path found let other modules work and wait 10 secs before trying again if (time(NULL) - lastPathNotFoundTm > 10) { //if should have control, take it if (!control) { if (atoi(config->modPriorityStr) > modpriority) { CVariableStore::setVariable("walking_control", "banker"); CVariableStore::setVariable("walking_priority", config->modPriorityStr); } else { globalBankerState = CToolBankerState_halfSleep; } } } else { globalBankerState = CToolBankerState_noPathFound; //if has control, give it up if (control) { CVariableStore::setVariable("walking_control", ""); CVariableStore::setVariable("walking_priority", "0"); } } } else // if doesn't want control { globalBankerState = CToolBankerState_notRunning; //if has control, give it up if (control) { CVariableStore::setVariable("walking_control", ""); CVariableStore::setVariable("walking_priority", "0"); } } if (doneAttackingAndLooting() && strcmp(CVariableStore::getVariable("walking_control"), "banker") == 0) { if (findBanker(config)) { globalBankerState = CToolBankerState_walking; if (moveToBanker(config)) { globalBankerState = CToolBankerState_talking; //AfxMessageBox("Yup, found the banker!"); if (config->changeGold) { if (changeGold()) lastBankerSuccessTm = time(NULL); } else { if (depositGold()) { // High Priority Task CVariableStore::setVariable("walking_control", "banker"); CVariableStore::setVariable("walking_priority", "9"); int suggestedWithdrawAmount = atoi(CVariableStore::getVariable("banker_suggestion")); if (config->cashOnHand || suggestedWithdrawAmount > 0) withdrawGold(config, suggestedWithdrawAmount); getBalance(); CVariableStore::setVariable("walking_control", "banker"); CVariableStore::setVariable("walking_priority", config->modPriorityStr); lastBankerSuccessTm = time(NULL); } } persistentShouldGo = 0; } } else { lastPathNotFoundTm = time(NULL); } } } if (strcmp(CVariableStore::getVariable("walking_control"), "banker") == 0) { CVariableStore::setVariable("walking_control", ""); CVariableStore::setVariable("walking_priority", "0"); } globalBankerState = CToolBankerState_notRunning; toolThreadShouldStop = 0; return 0; }