str defaultScenario(Client c) { #ifdef NEED_MT_LOCK_INIT if (c == mal_clients) MT_lock_init(&scenarioLock, "scenarioLock"); #endif return initScenario(c, scenarioRec); }
/* * @- * Setting a new scenario calls for saving the previous state * and execution of the initClientScenario routine. */ str setScenario(Client c, str nme) { int i; str msg; Scenario scen = scenarioRec; scen = findScenario(nme); if (scen == NULL) throw(MAL, "setScenario", SCENARIO_NOT_FOUND " '%s'", nme); if (c->scenario) { c->oldscenario = c->scenario; for (i = 0; i < 7; i++) { c->oldstate[i] = c->state[i]; c->oldphase[i] = c->phase[i]; } } for (i = 0; i < 7; i++) c->state[i] = 0; msg = initScenario(c, scen); if (msg) { /* error occurred, reset the scenario , assume default always works */ c->scenario = c->oldscenario; for (i = 0; i < 7; i++) { c->state[i] = c->oldstate[i]; c->phase[i] = c->oldphase[i]; c->oldstate[i] = NULL; c->oldphase[i] = NULL; } c->oldscenario = NULL; return msg; } return MAL_SUCCEED; }
str defaultScenario(Client c) { return initScenario(c, scenarioRec); }