/*---------------------------------------------------------------------- Determine whether application *app needs to be updated. Returns latest app version from game server in *app. Not needed by most user programs. Returns dp_RES_OK if update needed, dp_RES_EMPTY if no update needed. ----------------------------------------------------------------------*/ DP_API dp_result_t DP_APIX dpCheckAppVersion( dp_t* dp, dp_appParam_t *app) { precondition(dp); precondition(app); getLatest(dp, app); /* Ignore errors */ if ((app->latest.major == dp_VERS_UNKNOWN) || (app->latest.minor == dp_VERS_UNKNOWN)) { DPRINT(("dpCheckAppVersion: no version info available for this app?\n")); return dp_RES_EMPTY; } if ((app->current.major > app->latest.major) || ((app->current.major == app->latest.major) && (app->current.minor >= app->latest.minor))) { DPRINT(("dpCheckAppVersion: this app is up to date.\n")); return dp_RES_EMPTY; } DPRINT(("dpCheckAppVersion: app needs updating: version cur %d/%d < latest %d/%d\n", app->current.major, app->current.minor, app->latest.major, app->latest.minor)); return dp_RES_OK; }
// dump data void dumpToFile(std::string path, std::string tag, std::string s) const { const station_info si(s, lineBreak()); boost::filesystem::fstream *ofs(0); ofs = dumpSingle(ofs, path, tag, this, si); for (auto const& h : handles_) ofs = dumpSingle(ofs, path, tag, h.get(), si); updateTimeTag(*ofs, posEndTime_, getLatest()->makeTimeLabel()); delete ofs; }
int Approximator::run(double precision, double stepsize) { if(precision <= 0) return 1; int numverts = Triangulation::vertexTable.size(); double curvs[2][numverts]; double radii[2][numverts]; int prev = 0; int curr; recordState(); getLatest(radii[prev], curvs[prev]); do{ step(stepsize); recordState(); curr = (prev + 1)%2; getLatest(radii[curr], curvs[curr]); prev = curr; } while(! (isPrecise(precision, curvs[0], curvs[1]) || errno) ); return errno; }
int Approximator::run(double precision, int maxNumSteps, double stepsize) { if(precision <= 0) return 1; int numverts = Triangulation::vertexTable.size(); double curvs[2][numverts]; double radii[2][numverts]; int prev = 0; int curr; recordState(); getLatest(radii[prev], curvs[prev]); for(int ii = 0; ii < maxNumSteps && !errno; ii++){ step(stepsize); recordState(); curr = (prev + 1)%2; getLatest(radii[curr], curvs[curr]); prev = curr; if( isPrecise(precision, curvs[0], curvs[1]) ) { return errno; } } return errno; }
IResultPtr PerforceDepotView::move(const char* srcFile, const char* dstFile, ChangeListId changeListId) { std::stringstream command; PathList paths; paths.emplace_back(srcFile); paths.emplace_back(dstFile); getLatest(paths); checkout(paths, changeListId); if (changeListId != kDefaultChangelist) { command << "move -c " << changeListId << " -f " << EscapePaths(paths); } else { command << "move -f " << EscapePaths(paths); } return RunCommand(command.str()); }
int ActionStack::resolve() { Interruptible * action = getLatest(NOT_RESOLVED); if (!action) return 0; DebugTrace("Resolving Action on stack: " << action->getDisplayName()); if (action->resolve()) { action->state = RESOLVED_OK; } else { action->state = RESOLVED_NOK; } if (action->type == ACTION_DAMAGE) ((Damage *) action)->target->afterDamage(); if (!getNext(NULL, NOT_RESOLVED)) { for (int i = 0; i < 2; i++) { if (interruptDecision[i] != 2) interruptDecision[i] = NOT_DECIDED; } } else { for (int i = 0; i < 2; i++) { if (interruptDecision[i] != DONT_INTERRUPT_ALL) interruptDecision[i] = NOT_DECIDED; } } lastActionController = NULL; return 1; }
void ActionStack::Update(float dt) { //This is a hack to avoid updating the stack while tuto messages are being shown //Ideally, the tuto messages should be moved to a layer above this one //No need for Tuto when no human in game if (getCurrentTutorial() && (observer->players[0]->isHuman() || observer->players[1]->isHuman() ) ) return; askIfWishesToInterrupt = NULL; //modal = 0; TargetChooser * tc = observer->getCurrentTargetChooser(); int newState = observer->getCurrentGamePhase(); currentState = newState; if (!tc) checked = 0; //Select Stack's display mode if (mode == ACTIONSTACK_STANDARD && tc && !checked) { checked = 1; for (size_t i = 0; i < mObjects.size(); i++) { Interruptible * current = (Interruptible *) mObjects[i]; if (tc->canTarget(current)) { if (mCurr < (int) mObjects.size() && mObjects[mCurr]) mObjects[mCurr]->Leaving(JGE_BTN_UP); current->display = 1; mCurr = i; mObjects[mCurr]->Entering(); mode = ACTIONSTACK_TARGET; modal = 1; } else { current->display = 0; } } if (mode != ACTIONSTACK_TARGET) { } } else if (mode == ACTIONSTACK_TARGET && !tc) { mode = ACTIONSTACK_STANDARD; checked = 0; } if (mode == ACTIONSTACK_STANDARD) { modal = 0; if (getLatest(NOT_RESOLVED) && !tc) { Interruptible * currentSpell = (Interruptible *)getLatest(NOT_RESOLVED); MTGCardInstance * card = currentSpell->source; if(card && card->has(Constants::SPLITSECOND)) { resolve(); } else { int currentPlayerId = 0; int otherPlayerId = 1; if (observer->currentlyActing() != observer->players[0]) { currentPlayerId = 1; otherPlayerId = 0; } if (interruptDecision[currentPlayerId] == NOT_DECIDED) { askIfWishesToInterrupt = observer->players[currentPlayerId]; observer->isInterrupting = observer->players[currentPlayerId]; modal = 1; } else if (interruptDecision[currentPlayerId] == INTERRUPT) { observer->isInterrupting = observer->players[currentPlayerId]; } else { if (interruptDecision[otherPlayerId] == NOT_DECIDED) { askIfWishesToInterrupt = observer->players[otherPlayerId]; observer->isInterrupting = observer->players[otherPlayerId]; modal = 1; } else if (interruptDecision[otherPlayerId] == INTERRUPT) { observer->isInterrupting = observer->players[otherPlayerId]; } else { resolve(); } } } } } else if (mode == ACTIONSTACK_TARGET) { GuiLayer::Update(dt); } if (askIfWishesToInterrupt) { // WALDORF - added code to use a game option setting to determine how // long the Interrupt timer should be. If it is set to zero (0), the // game will wait for ever for the user to make a selection. if (options[Options::INTERRUPT_SECONDS].number > 0) { int extraTime = 0; //extraTime is a multiplier, it counts the number of unresolved stack actions //then is used to extend the time you have to interupt. //this prevents you from "running out of time" while deciding. //before this int was added, it was possible to run out of time if you had 10 stack actions //and set the timer to 4 secs. BUG FIX //http://code.google.com/p/wagic/issues/detail?id=464 extraTime = count(0, NOT_RESOLVED, 0); if (extraTime == 0) extraTime = 1;//we never want this int to be 0. if (timer < 0) timer = static_cast<float>(options[Options::INTERRUPT_SECONDS].number * extraTime); timer -= dt; if (timer < 0) cancelInterruptOffer(); } } }
/*---------------------------------------------------------------------- Enumerate applications installed on this machine. Callback is called once for each application found. Callback ends when dpEnumApp() exits. ----------------------------------------------------------------------*/ DP_API dp_result_t DP_APIX /* status */ dpEnumApp( dp_t* dp, /* (input) info about latest versions */ dpEnumAppCallback_t cb, /* (input) callback for app info */ void *context) /* (input) context for callback */ { CHAR GameName[MAX_VALUE_NAME]; CHAR GamePath[MAX_PATH]; CHAR GameArgs[MAX_PATH]; CHAR GameCwd[MAX_PATH]; CHAR GameShellOpts[MAX_PATH]; CHAR ClassName[MAX_PATH] = ""; /* Buffer for class name. */ DWORD dwcClassLen = MAX_PATH; /* Length of class string. */ DWORD dwcSubKeys; /* Number of sub keys. */ DWORD dwcMaxSubKey; /* Longest sub key size. */ DWORD dwcMaxClass; /* Longest class string. */ DWORD dwcValues; /* Number of values for this key. */ DWORD dwcMaxValueName; /* Longest Value name. */ DWORD dwcMaxValueData; /* Longest Value data. */ DWORD dwcSecDesc; /* Security descriptor. */ FILETIME ftLastWriteTime; /* Last write time. */ HKEY hKeyApp; /* Key handle of SubKey. */ HKEY hKeyVal; /* Key handle of specific application. */ CHAR AppName[MAX_PATH]; /* Name of specific application. */ INT loopApp; /* Application index. */ INT loopVal; /* Value index. */ CHAR ValueName[MAX_VALUE_NAME]; /* Name of value. */ DWORD cbValueName; /* Size of value name. */ DWORD dwType; /* Type of data. */ CHAR *bData; /* Data buffer. */ DWORD cbData; /* Size of data buffer. */ DWORD retCodeApp; /* Error when accessing application list handles. */ DWORD retCodeVal; /* Error when accessing application handles. */ CHAR *Param; dp_result_t err = dp_RES_OK; dp_appParam_t appParam; precondition(cb != NULL); DPRINT(("dpEnumApp:\n")); appParam.name = GameName; appParam.path = GamePath; appParam.args = GameArgs; appParam.cwd = GameCwd; appParam.shellOpts = GameShellOpts; #if defined(dp_ANET2) /* Set up the server-list table (the list of latest version number) */ if(dp != NULL) { if(dp->apps == NULL) { err = dp_createAppsList(dp); if (err != dp_RES_OK) { DPRINT(("dpEnumApp: Could not create apps, err:%d\n",err)); return dp_RES_BAD; } err = dp_subscribeAppsList(dp); if (err != dp_RES_OK) { DPRINT(("dpEnumApp: Could not subscribe apps, err:%d\n",err)); return dp_RES_BAD; } } } #endif /* Open the key for list of games and get info about it. */ retCodeApp = RegOpenKeyEx(hKeyRoot, SubKey, 0, KEY_EXECUTE, &hKeyApp); if (retCodeApp) { DPRINT(("dpEnumApp: RegOpenKeyEx/hKeyApp rCode:%d\n", retCodeApp)); return dp_RES_BAD; } retCodeApp = RegQueryInfoKey(hKeyApp, ClassName, &dwcClassLen, NULL, &dwcSubKeys, &dwcMaxSubKey, &dwcMaxClass, &dwcValues, &dwcMaxValueName, &dwcMaxValueData, &dwcSecDesc, &ftLastWriteTime); /*DPRINT(("dpEnumApp: ClassName=%s, dwcClassLen=%d, dwcSubKeys=%d, dwcMaxClass=%d,\n\t dwcValues=%d; dwcMaxValueName=%s, dwcMaxValueData=%s\n", ClassName, dwcClassLen, dwcSubKeys, dwcMaxClass, dwcValues, dwcMaxValueName, dwcMaxValueData)); */ if (retCodeApp) { DPRINT(("dpEnumApp: RegQIK/hKeyApp rCode:%d\n", retCodeApp)); return dp_RES_BAD; } retCodeApp = ERROR_SUCCESS; for (loopApp = 0; retCodeApp == ERROR_SUCCESS; loopApp++) { /* Get a game name, open its key, and get info. */ retCodeApp = RegEnumKey(hKeyApp, loopApp, AppName, MAX_PATH); if (retCodeApp != ERROR_SUCCESS) { if (retCodeApp == ERROR_NO_MORE_ITEMS) { continue; } else { DPRINT(("dpEnumApp: RegEnumKey/hKeyApp rCode:%d\n", retCodeApp)); return dp_RES_BAD; } } if (!AppName) { DPRINT(("dpEnumApp: found a NULL AppName\n")); continue; } retCodeApp = RegOpenKeyEx(hKeyApp, AppName, 0, KEY_EXECUTE, &hKeyVal); if (retCodeApp != ERROR_SUCCESS) { DPRINT(("dpEnumApp: RegOpenKeyEx/hKeyVal rCode:%d\n", retCodeApp)); return dp_RES_BAD; } dwcClassLen = MAX_PATH; retCodeApp = RegQueryInfoKey(hKeyVal, ClassName, &dwcClassLen, NULL, &dwcSubKeys, &dwcMaxSubKey, &dwcMaxClass, &dwcValues, &dwcMaxValueName, &dwcMaxValueData, &dwcSecDesc, &ftLastWriteTime); if (retCodeApp != ERROR_SUCCESS) { DPRINT(("dpEnumApp: RegQIK/hKeyVal rCode:%d\n", retCodeApp)); return dp_RES_BAD; } *appParam.name = '\0'; *appParam.path = '\0'; *appParam.args = '\0'; *appParam.cwd = '\0'; *appParam.shellOpts = '\0'; appParam.sessionType = 0; bData = malloc(dwcMaxValueData); assert(bData); for (loopVal = 0, retCodeVal = ERROR_SUCCESS; retCodeVal == ERROR_SUCCESS; loopVal++) { bData[0] = '\0'; ValueName[0] = '\0'; cbData = dwcMaxValueData; cbValueName = MAX_VALUE_NAME; /* Enumerate the key values. */ retCodeVal = RegEnumValue(hKeyVal, loopVal, ValueName, &cbValueName, NULL, &dwType, bData, &cbData); if (retCodeVal != ERROR_SUCCESS) { if (dwType < REG_FULL_RESOURCE_DESCRIPTOR && retCodeVal != ERROR_NO_MORE_ITEMS) { DPRINT(("dpEnumApp: RegEnumValue = %d cbData = %d line %d\n" , retCodeVal, cbData, __LINE__)); return dp_RES_BAD; } } else if (ValueName) { /*DPRINT(("dpEnumApp: loopVal=%d, ValueName=%s, cbValueName=%d, dwType=%d,\n\t bData=%s, cbData=%d; retCodeVal=%d\n", loopVal, ValueName, cbValueName, dwType, bData, cbData, retCodeVal)); */ /* Process the value accordingly. */ if (bData) { Param = _strlwr(ValueName); if(!strcmp("cwd", Param)) { int len = strlen(bData); strcpy(appParam.cwd, bData); /* remove trailing slashes */ if ((len > 3) && (appParam.cwd[len - 1] == '\\')) { appParam.cwd[len - 1] = 0; } // } else if (!strcmp("name", Param)) { // strcpy(appParam.name, bData); // } else if(!strcmp("run", Param)) { // strcpy(appParam.path, bData); // } else if(!strcmp("cmdline", Param)) { // strcpy(appParam.args, bData); // } else if(!strcmp("sessiontype", Param)) { // appParam.sessionType = (dp_species_t) (*(int *)bData); } } else { DPRINT(("dpEnumApp: got a NULL bData\n")); } } else { DPRINT(("dpEnumApp: got a NULL Value name\n")); } } /* Get the rest of the parameters from the ini file */ if (*appParam.cwd) { /* Get info from app's .inf file */ err = dpReadAnetInf(appParam.cwd, &appParam); /* Get info from server's table */ #if defined(dp_ANET2) if ((err == dp_RES_OK) && (dp != NULL)) getLatest(dp, &appParam); /* Ignore errors */ #endif /* Call callback function to return data about this game. */ if (err == dp_RES_OK && *appParam.name && *appParam.path && *appParam.cwd) { cb(&appParam, context); } else { DPRINT(("dpEnumApp: Getting appParam, err:%d\n",err)); // DPRINT(("dpEnumApp: Error: App(name,path,cwd) = (%s, %s, %s)\n", // *(appParam.name), *(appParam.path), *(appParam.cwd))); } } else { DPRINT(("dpEnumApp: Error getting .ini file path\n")); } if (bData) free(bData); } return dp_RES_OK; }