From b8fa67a8bbd51e25e96d019fa0e2d942bb0bc6c9 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 30 Sep 2003 06:40:01 +0000 Subject: Changed the "logic" object to use ScummVM naming conventions. svn-id: r10496 --- sword2/console.cpp | 2 +- sword2/controls.cpp | 8 ++-- sword2/debug.cpp | 2 +- sword2/events.cpp | 8 ++-- sword2/function.cpp | 6 +-- sword2/logic.cpp | 133 +++++++++++++++++++++++++-------------------------- sword2/logic.h | 30 ++++++------ sword2/save_rest.cpp | 7 ++- sword2/speech.cpp | 4 +- sword2/sword2.cpp | 4 +- 10 files changed, 99 insertions(+), 105 deletions(-) (limited to 'sword2') diff --git a/sword2/console.cpp b/sword2/console.cpp index ef1835acf2..3232aa4f5d 100644 --- a/sword2/console.cpp +++ b/sword2/console.cpp @@ -499,7 +499,7 @@ uint32 Parse_user_input(void) { Print_current_info(); return 0; case 15: // RUNLIST - LLogic.Examine_run_list(); + LLogic.examineRunList(); return 0; case 16: // KILL res_man.Kill_res(&input[1][0]); diff --git a/sword2/controls.cpp b/sword2/controls.cpp index 81d54c64a4..5e7af38e98 100644 --- a/sword2/controls.cpp +++ b/sword2/controls.cpp @@ -1305,7 +1305,7 @@ public: // FN_register_mouse and FN_register_frame) Reset_mouse_list(); - if (LLogic.Process_session()) + if (LLogic.processSession()) Con_fatal_error("restore 1st cycle failed??"); } } @@ -1399,11 +1399,11 @@ void Restart_control(void) { this_screen.scroll_flag = 2; - if (LLogic.Process_session()) + if (LLogic.processSession()) Con_fatal_error("restart 1st cycle failed??"); - // (JEL08oct97) so palette not restored immediately after control - // panel - we want to fade up instead! + // So palette not restored immediately after control panel - we want + // to fade up instead! this_screen.new_palette = 99; } diff --git a/sword2/debug.cpp b/sword2/debug.cpp index 60d0508937..17ef343f94 100644 --- a/sword2/debug.cpp +++ b/sword2/debug.cpp @@ -415,7 +415,7 @@ void Print_current_info(void) { Print_to_console(" %d normal layers", this_screen.number_of_layers); - LLogic.Examine_run_list(); + LLogic.examineRunList(); } else Print_to_console(" no screen"); diff --git a/sword2/events.cpp b/sword2/events.cpp index c7294bbcdd..14118c49a9 100644 --- a/sword2/events.cpp +++ b/sword2/events.cpp @@ -214,7 +214,7 @@ int32 FN_check_for_event(int32 *params) { if (event_list[j].id == ID) { // start the event // run 3rd script of target object on level 1 - LLogic.Logic_one(event_list[j].interact_id); + LLogic.logicOne(event_list[j].interact_id); // clear the event slot event_list[j].id = 0; return IR_TERMINATE; @@ -245,7 +245,7 @@ int32 FN_pause_for_event(int32 *params) { // start the event // run 3rd script of target object on level 1 - LLogic.Logic_one(event_list[j].interact_id); + LLogic.logicOne(event_list[j].interact_id); // clear the event slot event_list[j].id = 0; @@ -311,7 +311,7 @@ void Start_event(void) { for (int j = 0; j < MAX_events; j++) { if (event_list[j].id == ID) { // run 3rd script of target object on level 1 - LLogic.Logic_one( event_list[j].interact_id); + LLogic.logicOne(event_list[j].interact_id); //clear the slot event_list[j].id = 0; @@ -327,7 +327,7 @@ int32 FN_start_event(int32 *params) { for (int j = 0; j < MAX_events; j++) if (event_list[j].id == ID) { // run 3rd script of target object on level 1 - LLogic.Logic_one(event_list[j].interact_id); + LLogic.logicOne(event_list[j].interact_id); // clear the slot event_list[j].id = 0; diff --git a/sword2/function.cpp b/sword2/function.cpp index b9a6872a91..4f3e8d87a1 100644 --- a/sword2/function.cpp +++ b/sword2/function.cpp @@ -54,7 +54,7 @@ int32 FN_gosub(int32 *params) { // hurray, script subroutines // param 0 id of script - LLogic.Logic_up(params[0]); + LLogic.logicUp(params[0]); // logic goes up - pc is saved for current level return IR_GOSUB; @@ -70,7 +70,7 @@ int32 FN_new_script(int32 *params) { // must clear this PLAYER_ACTION = 0; - LLogic.Logic_replace(params[0]); + LLogic.logicReplace(params[0]); //drop out no pc save - and around again return IR_TERMINATE; @@ -88,7 +88,7 @@ int32 FN_interact(int32 *params) { PLAYER_ACTION = 0; // 3rd script of clicked on id - LLogic.Logic_up((params[0] * 65536) + 2); + LLogic.logicUp((params[0] * 65536) + 2); // out, up and around again - pc is saved for current level to be // returned to diff --git a/sword2/logic.cpp b/sword2/logic.cpp index 9d5d89ef6c..770982f94f 100644 --- a/sword2/logic.cpp +++ b/sword2/logic.cpp @@ -23,13 +23,13 @@ #include "debug.h" #include "interpreter.h" #include "logic.h" -#include "router.h" // for ClearWalkGridList() +#include "router.h" // for ClearWalkGridList() #include "sound.h" #include "sync.h" logic LLogic; -#define LEVEL (cur_object_hub->logic_level) +#define LEVEL (_curObjectHub->logic_level) // this must allow for the largest number of objects in a screen #define OBJECT_KILL_LIST_SIZE 50 @@ -39,7 +39,7 @@ uint32 object_kill_list[OBJECT_KILL_LIST_SIZE]; // keeps note of no. of objects in the kill list uint32 kills = 0; -int logic::Process_session(void) { +int logic::processSession(void) { // do one cycle of the current session uint32 run_list; @@ -53,15 +53,15 @@ int logic::Process_session(void) { uint32 id; // might change during the session, so take a copy here - run_list = current_run_list; + run_list = _currentRunList; // point to first object in list - pc = 0; + _pc = 0; // by minusing the pc we can cause an immediate cessation of logic // processing on the current list - while (pc != 0xffffffff) { + while (_pc != 0xffffffff) { head = (_standardHeader*) res_man.Res_open(run_list); if (head->fileType != RUN_LIST) @@ -70,7 +70,7 @@ int logic::Process_session(void) { game_object_list = (uint32 *) (head + 1); // read the next id - ID = game_object_list[pc++]; + ID = game_object_list[_pc++]; id = ID; // release the list again so it can float in memory - at this @@ -91,12 +91,12 @@ int logic::Process_session(void) { if (head->fileType != GAME_OBJECT) Con_fatal_error("Logic_engine %d not an object", ID); - cur_object_hub = (_object_hub *) (head + 1); + _curObjectHub = (_object_hub *) (head + 1); debug(5, " %d id(%d) pc(%d)", - cur_object_hub->logic_level, - cur_object_hub->script_id[cur_object_hub->logic_level], - cur_object_hub->script_pc[cur_object_hub->logic_level]); + LEVEL, + _curObjectHub->script_id[LEVEL], + _curObjectHub->script_pc[LEVEL]); // do the logic for this object // we keep going until a function says to stop - remember, @@ -106,7 +106,7 @@ int logic::Process_session(void) { // get the script id as we may be running a script // from another object... - script = cur_object_hub->script_id[LEVEL]; + script = _curObjectHub->script_id[LEVEL]; // there is a distinction between running one of our // own scripts and that of another object @@ -115,15 +115,15 @@ int logic::Process_session(void) { debug(5, "run script %d pc%d", script / SIZE, - cur_object_hub->script_pc[LEVEL]); + _curObjectHub->script_pc[LEVEL]); // this is the script data - // raw_script_ad = (char *) (cur_object_hub + 1); + // raw_script_ad = (char *) (_curObjectHub + 1); raw_script_ad = (char*) head; // script and data object are us/same - ret = RunScript(raw_script_ad, raw_script_ad, &cur_object_hub->script_pc[LEVEL]); + ret = RunScript(raw_script_ad, raw_script_ad, &_curObjectHub->script_pc[LEVEL]); } else { // we're running the script of another game // object - get our data object address @@ -140,11 +140,11 @@ int logic::Process_session(void) { // raw_script_ad = (char*) (head + 1) + sizeof(_standardHeader); // get our objects data address - // raw_data_ad = (char*) (cur_object_hub + 1); + // raw_data_ad = (char*) (_curObjectHub + 1); raw_script_ad = (char*) far_head; - ret = RunScript(raw_script_ad, raw_data_ad, &cur_object_hub->script_pc[LEVEL]); + ret = RunScript(raw_script_ad, raw_data_ad, &_curObjectHub->script_pc[LEVEL]); // close foreign object again res_man.Res_close(script / SIZE); @@ -157,8 +157,8 @@ int logic::Process_session(void) { if (ret == 1) { // check that it's not already on level 0 ! - if (cur_object_hub->logic_level) - cur_object_hub->logic_level--; + if (LEVEL) + LEVEL--; else { // Hmmm, level 0 terminated :-| Let's // be different this time and simply @@ -167,13 +167,13 @@ int logic::Process_session(void) { debug(5, "**WARNING object %d script 0 terminated!", id); // reset to rerun - cur_object_hub->script_pc[LEVEL] = cur_object_hub->script_id[LEVEL] & 0xffff; + _curObjectHub->script_pc[LEVEL] = _curObjectHub->script_id[LEVEL] & 0xffff; // cause us to drop out for a cycle ret = 0; } } else if (ret > 2) { - Con_fatal_error("Process_session: illegal script return type %d", ret); + Con_fatal_error("processSession: illegal script return type %d", ret); } // if ret == 2 then we simply go around again - a new @@ -189,7 +189,7 @@ int logic::Process_session(void) { Clear_syncs(ID); - if (pc != 0xffffffff) { + if (_pc != 0xffffffff) { // the session is still valid so run the service script null_pc = 0; @@ -207,7 +207,7 @@ int logic::Process_session(void) { } // leaving a room so remove all ids that must reboot correctly - Process_kill_list(); + processKillList(); debug(5, "RESTART the loop"); @@ -215,15 +215,15 @@ int logic::Process_session(void) { return 1; } -void logic::Express_change_session(uint32 sesh_id) { +void logic::expressChangeSession(uint32 sesh_id) { // a game-object can bring an immediate halt to the session and cause // a new one to start without a screen update //set to new - current_run_list = sesh_id; + _currentRunList = sesh_id; //causes session to quit - pc = 0xffffffff; + _pc = 0xffffffff; // reset now in case we double-clicked an exit prior to changing screen EXIT_FADING = 0; @@ -244,29 +244,25 @@ void logic::Express_change_session(uint32 sesh_id) { FreeAllRouteMem(); } -void logic::Natural_change_session(uint32 sesh_id) { - // a new session will begin next game cycle. - // the current cycle will conclude and build the screen and flip - // into view as normal +void logic::naturalChangeSession(uint32 sesh_id) { + // FIXME: This function doesn't seem to be used anywhere - //set to new - current_run_list = sesh_id; -} + // A new session will begin next game cycle. The current cycle will + // conclude and build the screen and flip into view as normal -uint32 logic::Return_run_list(void) { - // pass back the private cur_object_list variable - not sure we need - // this + _currentRunList = sesh_id; +} - //return the id - return current_run_list; +uint32 logic::getRunList(void) { + // pass back the private _currentRunList variable + return _currentRunList; } int32 FN_set_session(int32 *params) { // used by player invoked start scripts // param 0 id of new run list - //now! - LLogic.Express_change_session(*params); + LLogic.expressChangeSession(params[0]); return IR_CONT; } @@ -278,63 +274,63 @@ int32 FN_end_session(int32 *params) { // param 0 id of new run-list // terminate current and change to next run-list - LLogic.Express_change_session(*params); + LLogic.expressChangeSession(params[0]); // stop the script - logic engine will now go around and the new // screen will begin return IR_STOP; } -void logic::Logic_up(uint32 new_script) { +void logic::logicUp(uint32 new_script) { // move the current object up a level // called by FN_gosub command - remember, only the logic object has - // access to cur_object_hub + // access to _curObjectHub // going up a level - and we'll keeping going this cycle - cur_object_hub->logic_level++; + LEVEL++; // can be 0, 1, 2 - if (cur_object_hub->logic_level == 3) - Con_fatal_error("Logic_up id %d has run off script tree! :-O", ID); + if (LEVEL == 3) + Con_fatal_error("logicUp id %d has run off script tree! :-O", ID); // setup new script on next level (not the current level) debug(5, "new pc = %d", new_script & 0xffff); - cur_object_hub->script_id[cur_object_hub->logic_level] = new_script; - cur_object_hub->script_pc[cur_object_hub->logic_level] = new_script & 0xffff; + _curObjectHub->script_id[LEVEL] = new_script; + _curObjectHub->script_pc[LEVEL] = new_script & 0xffff; } -void logic::Logic_one(uint32 new_script) { +void logic::logicOne(uint32 new_script) { // force to level one - cur_object_hub->logic_level = 1; + LEVEL = 1; // setup new script on level 1 - cur_object_hub->script_id[1] = new_script; - cur_object_hub->script_pc[1] = new_script & 0xffff; + _curObjectHub->script_id[1] = new_script; + _curObjectHub->script_pc[1] = new_script & 0xffff; } -void logic::Logic_replace(uint32 new_script) { +void logic::logicReplace(uint32 new_script) { // change current logic - script must quit with a TERMINATE directive // - which does not write to &pc // setup new script on this level - cur_object_hub->script_id[cur_object_hub->logic_level] = new_script; - cur_object_hub->script_pc[cur_object_hub->logic_level] = new_script & 0xffff; + _curObjectHub->script_id[LEVEL] = new_script; + _curObjectHub->script_pc[LEVEL] = new_script & 0xffff; } -uint32 logic::Examine_run_list(void) { +uint32 logic::examineRunList(void) { uint32 *game_object_list; _standardHeader *file_header; int scrolls = 0; _keyboardEvent ke; - if (current_run_list) { + if (_currentRunList) { // open and lock in place - game_object_list = (uint32 *) (res_man.Res_open(current_run_list) + sizeof(_standardHeader)); + game_object_list = (uint32 *) (res_man.Res_open(_currentRunList) + sizeof(_standardHeader)); - Print_to_console("runlist number %d", current_run_list); + Print_to_console("runlist number %d", _currentRunList); while(*(game_object_list)) { file_header = (_standardHeader*) res_man.Res_open(*(game_object_list)); @@ -365,7 +361,7 @@ uint32 logic::Examine_run_list(void) { } } - res_man.Res_close(current_run_list); + res_man.Res_close(_currentRunList); } else Print_to_console("no run list set"); @@ -373,21 +369,21 @@ uint32 logic::Examine_run_list(void) { return 1; } -void logic::Total_restart(void) { +void logic::totalRestart(void) { // reset the object restart script 1 on level 0 - cur_object_hub->logic_level = 0; - // cur_object_hub->script_id[0] = 1; + LEVEL = 0; + // _curObjectHub->script_id[0] = 1; // reset to rerun - cur_object_hub->script_pc[0] = 1; + _curObjectHub->script_pc[0] = 1; } int32 FN_total_restart(int32 *params) { // mega runs this to restart its base logic again - like being cached // in again - LLogic.Total_restart(); + LLogic.totalRestart(); // drop out without saving pc and go around again return IR_TERMINATE; @@ -409,14 +405,13 @@ int32 FN_add_to_kill_list(int32 *params) { // DON'T EVER KILL GEORGE! if (ID != 8) { // first, scan list to see if this object is already included - // (05mar97 James) entry = 0; while (entry < kills && object_kill_list[entry] != ID) entry++; // if this ID isn't already in the list, then add it, - // (otherwise finish) (05mar97 James) + // (otherwise finish) if (entry == kills) { #ifdef _SWORD2_DEBUG @@ -443,13 +438,13 @@ int32 FN_add_to_kill_list(int32 *params) { return IR_CONT; } -void logic::Process_kill_list(void) { +void logic::processKillList(void) { for (uint32 j = 0; j < kills; j++) res_man.Remove_res(object_kill_list[j]); kills = 0; } -void logic::Reset_kill_list(void) { +void logic::resetKillList(void) { kills = 0; } diff --git a/sword2/logic.h b/sword2/logic.h index 5f374a3267..a78b5a9cbb 100644 --- a/sword2/logic.h +++ b/sword2/logic.h @@ -30,37 +30,37 @@ class logic { public: //do one cycle of the current session - int Process_session(void); + int processSession(void); // cause the logic loop to terminate and drop out - void Express_change_session(uint32 sesh_id); + void expressChangeSession(uint32 sesh_id); // new logic begins next cycle - void Natural_change_session(uint32 sesh_id); + void naturalChangeSession(uint32 sesh_id); - uint32 Return_run_list(void); + uint32 getRunList(void); - // setup script_id and script_pc in cur_object_hub - called by + // setup script_id and script_pc in _curObjectHub - called by // FN_gosub() - void Logic_up(uint32 new_script); + void logicUp(uint32 new_script); - void Logic_replace(uint32 new_script); - void Logic_one(uint32 new_script); - void Total_restart(void); - uint32 Examine_run_list(void); - void Reset_kill_list(void); + void logicReplace(uint32 new_script); + void logicOne(uint32 new_script); + void totalRestart(void); + uint32 examineRunList(void); + void resetKillList(void); private: // denotes the res id of the game-object-list in current use - uint32 current_run_list; + uint32 _currentRunList; - void Process_kill_list(void); + void processKillList(void); //pc during logic loop - uint32 pc; + uint32 _pc; // each object has one of these tacked onto the beginning - _object_hub *cur_object_hub; + _object_hub *_curObjectHub; }; extern logic LLogic; diff --git a/sword2/save_rest.cpp b/sword2/save_rest.cpp index 6a37048a5a..9740b802fa 100644 --- a/sword2/save_rest.cpp +++ b/sword2/save_rest.cpp @@ -183,7 +183,7 @@ void FillSaveBuffer(mem *buffer, uint32 size, uint8 *desc) { g_header.screenId = this_screen.background_layer_id; // resource id of current run-list - g_header.runListId = LLogic.Return_run_list(); + g_header.runListId = LLogic.getRunList(); // those scroll position control things g_header.feet_x = this_screen.feet_x; @@ -382,7 +382,7 @@ uint32 RestoreFromBuffer(mem *buffer, uint32 size) { res_man.Kill_all_res(0); // clean out the system kill list (no more objects to kill) - LLogic.Reset_kill_list(); + LLogic.resetKillList(); // get player character data from savegame buffer @@ -432,9 +432,8 @@ uint32 RestoreFromBuffer(mem *buffer, uint32 size) { this_screen.feet_y = g_header.feet_y; // start the new run list - LLogic.Express_change_session(g_header.runListId); + LLogic.expressChangeSession(g_header.runListId); - // (James01aug97) // Force in the new scroll position, so unsightly scroll-catch-up does // not occur when screen first draws after returning from restore panel diff --git a/sword2/speech.cpp b/sword2/speech.cpp index b0e1e41745..c95fa119d4 100644 --- a/sword2/speech.cpp +++ b/sword2/speech.cpp @@ -346,10 +346,10 @@ int32 FN_end_conversation(int32 *params) { debug(5, " holding"); } - TALK_FLAG = 0; //in-case DC forgets + TALK_FLAG = 0; // in-case DC forgets // restart george's base script - // LLogic.Total_restart(); + // LLogic.totalRestart(); //drop out without saving pc and go around again return IR_CONT; diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index 9cbc42af41..f3f288dac0 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -213,7 +213,7 @@ int32 GameCycle(void) { // do one game cycle //got a screen to run? - if (LLogic.Return_run_list()) { + if (LLogic.getRunList()) { //run the logic session UNTIL a full loop has been performed do { // reset the graphic 'buildit' list before a new @@ -226,7 +226,7 @@ int32 GameCycle(void) { // keep going as long as new lists keep getting put in // - i.e. screen changes - } while (LLogic.Process_session()); + } while (LLogic.processSession()); } else { // start the console and print the start options perhaps? StartConsole(); -- cgit v1.2.3