View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002977 | FSSCP | scripting | public | 2013-12-13 06:41 | 2013-12-18 12:27 |
Reporter | z64555 | Assigned To | z64555 | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | Sager NP8250 "BlackPhoenix" | OS | Windows | OS Version | 8 |
Product Version | 3.7.0 | ||||
Fixed in Version | 3.7.1 | ||||
Summary | 0002977: GS_STATE and GS_EVENT names not matching up to proper text strings | ||||
Description | FringeSpace had an issue where they could not bring up the ship lab via mainhall script since the new Pilot code went in. I have since tracked this down to an issue with the GS_STATE and GS_EVENT names in gamesequence.h not matching up to the text in the char arrays in gamesequence.cpp, resulting in improper referencing to GS_EVENT_LOOP_BRIEF and above, and GS_STATE_LOOP_BRIEF and above. Since LUA aparently gets the GS_EVENT and GS_STATE index values from this char arrays, any scripts that attempted to use these out-of-sequence indices would fail, or otherwise trigger on/call up the wrong event/state. Another effect, although minor, was that the "Got event..." strings in the fs2_open.log would show the improper GS_EVENT and GS_STATE names along with their index. | ||||
Steps To Reproduce | Try running a script that uses any of these, and take careful note of when they trigger in the fs2_open.log: GS_EVENT_LOOP_BRIEF, GS_EVENT_CAMPAIGN_CHEAT, GS_EVENT_PXO, GS_EVENT_LAB, GS_EVENT_PXO_HELP, GS_EVENT_FICTION_VIEWER, GS_EVENT_SCRIPTING GS_STATE_LOOP_BRIEF, GS_STATE_PXO, GS_STATE_LAB, GS_STATE_PXO_HELP, GS_STATE_START_GAME, GS_STATE_FICTION_VIEWER, GS_STATE_SCRIPTING | ||||
Tags | No tags attached. | ||||
|
Added a patch that changes the #define lists into enumerations, which should make things easier to add, delete, move around, etc. Just be sure that you make the strings in gamesequence.cpp match up to the enum's sequence or you'll screw up the LUA scripts |
|
Looks good to me although I don't think that the changes to the Visual Studio solution are necessary but everything else seems to be alright. |
|
mantis_2977_1.diff (17,629 bytes)
diff --git a/code/gamesequence/gamesequence.cpp b/code/gamesequence/gamesequence.cpp index c10bfd8..e0e7944 100644 --- a/code/gamesequence/gamesequence.cpp +++ b/code/gamesequence/gamesequence.cpp @@ -42,7 +42,7 @@ static int state_in_event_processer = 0; script_hook GS_state_hooks[GS_NUM_STATES]; -// Text of state, corresponding to #define values for GS_STATE_* +// Text of state, corresponding to enum values for GS_STATE_* //XSTR:OFF char *GS_event_text[] = { @@ -106,19 +106,19 @@ char *GS_event_text[] = "GS_EVENT_RED_ALERT", "GS_EVENT_SIMULATOR_ROOM", "GS_EVENT_END_CAMPAIGN", - "GS_EVENT_LOOP_BRIEF", + "GS_EVENT_LOOP_BRIEF", // 60 "GS_EVENT_CAMPAIGN_CHEAT", "GS_EVENT_PXO", "GS_EVENT_LAB", - "GS_EVENT_PXO_HELP", // 65 - "GS_EVENT_FICTION_VIEWER", + "GS_EVENT_PXO_HELP", + "GS_EVENT_FICTION_VIEWER", // 65 "GS_EVENT_SCRIPTING" }; //XSTR:ON int Num_gs_event_text = sizeof(GS_event_text)/sizeof(char*); -// Text of state, corresponding to #define values for GS_STATE_* +// Text of state, corresponding to enum values for GS_STATE_* //XSTR:OFF char *GS_state_text[] = { @@ -171,8 +171,8 @@ char *GS_state_text[] = "GS_STATE_GAMEPLAY_HELP", "GS_STATE_LOOP_BRIEF", "GS_STATE_PXO", - "GS_STATE_LAB", // 50 - "GS_STATE_PXO_HELP", + "GS_STATE_LAB", + "GS_STATE_PXO_HELP", // 50 "GS_STATE_START_GAME", "GS_STATE_FICTION_VIEWER", "GS_STATE_SCRIPTING" diff --git a/code/gamesequence/gamesequence.h b/code/gamesequence/gamesequence.h index e1788ff..33b9e57 100644 --- a/code/gamesequence/gamesequence.h +++ b/code/gamesequence/gamesequence.h @@ -15,143 +15,153 @@ #ifndef __GAMESEQUENCE_H__ #define __GAMESEQUENCE_H__ -// defines for game sequencing events -// - -#define GS_EVENT_MAIN_MENU 0 // first event to move to first state -#define GS_EVENT_START_GAME 1 // start a new game (Loads a mission then goes to briefing state) -#define GS_EVENT_ENTER_GAME 2 // switches into game state, probably after mission briefing or ship selection. -#define GS_EVENT_START_GAME_QUICK 3 // start a new game (Loads a mission then goes to directly to game state) -#define GS_EVENT_END_GAME 4 // end the current game (i.e. back to main menu) -#define GS_EVENT_QUIT_GAME 5 // quit the entire game -#define GS_EVENT_PAUSE_GAME 6 // pause the current game -#define GS_EVENT_PREVIOUS_STATE 7 // return to the previous state -#define GS_EVENT_OPTIONS_MENU 8 // go to the options menu -#define GS_EVENT_BARRACKS_MENU 9 // go to the barracks menu -#define GS_EVENT_TRAINING_MENU 10 // go to the training menu -#define GS_EVENT_TECH_MENU 11 // go to the tech room menu -#define GS_EVENT_LOAD_MISSION_MENU 12 // go to the load mission menu -#define GS_EVENT_SHIP_SELECTION 13 // Show ship selection menu -#define GS_EVENT_TOGGLE_FULLSCREEN 14 // toggle fullscreen mode -#define GS_EVENT_START_BRIEFING 15 // go to the briefing for the current mission -#define GS_EVENT_DEBUG_PAUSE_GAME 16 -#define GS_EVENT_HUD_CONFIG 17 // start the HUD configuration screen -#define GS_EVENT_MULTI_JOIN_GAME 18 // start multiplayer join game screen -#define GS_EVENT_CONTROL_CONFIG 19 // get user to choose what type of controller to config -#define GS_EVENT_EVENT_DEBUG 20 // an event debug trace scroll list display screen -#define GS_EVENT_WEAPON_SELECTION 21 // Do weapon loadout -#define GS_EVENT_MISSION_LOG_SCROLLBACK 22 // scrollback screen for message log entries -#define GS_EVENT_GAMEPLAY_HELP 23 // show help for the gameplay -#define GS_EVENT_DEATH_DIED 24 // Player just died -#define GS_EVENT_DEATH_BLEW_UP 25 // Saw ship explode. -#define GS_EVENT_NEW_CAMPAIGN 26 -#define GS_EVENT_CREDITS 27 // Got to the credits -#define GS_EVENT_SHOW_GOALS 28 // Show the goal status screen -#define GS_EVENT_HOTKEY_SCREEN 29 // Show the hotkey assignment screen -#define GS_EVENT_VIEW_MEDALS 30 // Go to the View Medals screen -#define GS_EVENT_MULTI_HOST_SETUP 31 // host setup for multiplayer -#define GS_EVENT_MULTI_CLIENT_SETUP 32 // client setup for multiplayer -#define GS_EVENT_DEBRIEF 33 // go to debriefing -#define GS_EVENT_GOTO_VIEW_CUTSCENES_SCREEN 34 // go to the management screen -#define GS_EVENT_MULTI_STD_WAIT 35 // standalone wait state -#define GS_EVENT_STANDALONE_MAIN 36 // the main do-nothing state of the standalone -#define GS_EVENT_MULTI_PAUSE 37 // pause your multiplayer game -#define GS_EVENT_TEAM_SELECT 38 // team selection for multiplayer -#define GS_EVENT_TRAINING_PAUSE 39 // pause game while training message is displayed -#define GS_EVENT_INGAME_PRE_JOIN 40 // go to ship selection screen for ingame join -#define GS_EVENT_PLAYER_WARPOUT_START 41 // player hit 'j' to warp out -#define GS_EVENT_PLAYER_WARPOUT_START_FORCED 42 // player is being forced out of mission no matter what -#define GS_EVENT_PLAYER_WARPOUT_STOP 43 // player hit 'esc' or something to cancel warp out -#define GS_EVENT_PLAYER_WARPOUT_DONE_STAGE1 44 // player ship got up to speed -#define GS_EVENT_PLAYER_WARPOUT_DONE_STAGE2 45 // player ship got through the warp effect -#define GS_EVENT_PLAYER_WARPOUT_DONE 46 // warp effect went away -#define GS_EVENT_STANDALONE_POSTGAME 47 // debriefing, etc -#define GS_EVENT_INITIAL_PLAYER_SELECT 48 // initial screen where player selects from multi/single player pilots -#define GS_EVENT_GAME_INIT 49 -#define GS_EVENT_MULTI_MISSION_SYNC 50 // sychronize/transfer/load any mission specific data in multiplayer -#define GS_EVENT_MULTI_START_GAME 51 // immediately before the create game screen for the host to set the game variables -#define GS_EVENT_MULTI_HOST_OPTIONS 52 // options the host can set while in the create game scree -#define GS_EVENT_MULTI_DOGFIGHT_DEBRIEF 53 // multiplayer furball debriefing screen (replaces normal debriefing) -#define GS_EVENT_CAMPAIGN_ROOM 54 -#define GS_EVENT_CMD_BRIEF 55 // switch to command briefing screen -#define GS_EVENT_TOGGLE_GLIDE 56 // GS_EVENT_TOGGLE_GLIDE -#define GS_EVENT_RED_ALERT 57 // go to red alert screen -#define GS_EVENT_SIMULATOR_ROOM 58 -#define GS_EVENT_END_CAMPAIGN 59 // end of the whole thang. -#define GS_EVENT_LOOP_BRIEF 61 // campaign loop brief -#define GS_EVENT_CAMPAIGN_CHEAT 62 // skip to a mission in a campaign -#define GS_EVENT_PXO 63 -#define GS_EVENT_LAB 64 // WMC - I-FRED concept -#define GS_EVENT_PXO_HELP 65 -#define GS_EVENT_FICTION_VIEWER 66 -#define GS_EVENT_SCRIPTING 67 - +/** + * @brief Enum's for Game Sequence Events. + * + * @details IMPORTANT: When you add a new event, update the initialization for GS_event_text[] which is done in + * gamesequence.cpp. Otherwise, the fs2_open.log string "Got event..." will not display properly. + */ +enum GS_EVENT { + GS_EVENT_MAIN_MENU = 0, // first event to move to first state + GS_EVENT_START_GAME, // start a new game (Loads a mission then goes to briefing state) + GS_EVENT_ENTER_GAME, // switches into game state, probably after mission briefing or ship selection. + GS_EVENT_START_GAME_QUICK, // start a new game (Loads a mission then goes to directly to game state) + GS_EVENT_END_GAME, // end the current game (i.e. back to main menu) + GS_EVENT_QUIT_GAME, // quit the entire game + GS_EVENT_PAUSE_GAME, // pause the current game + GS_EVENT_PREVIOUS_STATE, // return to the previous state + GS_EVENT_OPTIONS_MENU, // go to the options menu + GS_EVENT_BARRACKS_MENU, // go to the barracks menu + GS_EVENT_TRAINING_MENU, // go to the training menu + GS_EVENT_TECH_MENU, // go to the tech room menu + GS_EVENT_LOAD_MISSION_MENU, // go to the load mission menu + GS_EVENT_SHIP_SELECTION, // Show ship selection menu + GS_EVENT_TOGGLE_FULLSCREEN, // toggle fullscreen mode + GS_EVENT_START_BRIEFING, // go to the briefing for the current mission + GS_EVENT_DEBUG_PAUSE_GAME, + GS_EVENT_HUD_CONFIG, // start the HUD configuration screen + GS_EVENT_MULTI_JOIN_GAME, // start multiplayer join game screen + GS_EVENT_CONTROL_CONFIG, // get user to choose what type of controller to config + GS_EVENT_EVENT_DEBUG, // an event debug trace scroll list display screen + GS_EVENT_WEAPON_SELECTION, // Do weapon loadout + GS_EVENT_MISSION_LOG_SCROLLBACK, // scrollback screen for message log entries + GS_EVENT_GAMEPLAY_HELP, // show help for the gameplay + GS_EVENT_DEATH_DIED, // Player just died + GS_EVENT_DEATH_BLEW_UP, // Saw ship explode. + GS_EVENT_NEW_CAMPAIGN, + GS_EVENT_CREDITS, // Got to the credits + GS_EVENT_SHOW_GOALS, // Show the goal status screen + GS_EVENT_HOTKEY_SCREEN, // Show the hotkey assignment screen + GS_EVENT_VIEW_MEDALS, // Go to the View Medals screen + GS_EVENT_MULTI_HOST_SETUP, // host setup for multiplayer + GS_EVENT_MULTI_CLIENT_SETUP, // client setup for multiplayer + GS_EVENT_DEBRIEF, // go to debriefing + GS_EVENT_GOTO_VIEW_CUTSCENES_SCREEN, // go to the management screen + GS_EVENT_MULTI_STD_WAIT, // standalone wait state + GS_EVENT_STANDALONE_MAIN, // the main do-nothing state of the standalone + GS_EVENT_MULTI_PAUSE, // pause your multiplayer game + GS_EVENT_TEAM_SELECT, // team selection for multiplayer + GS_EVENT_TRAINING_PAUSE, // pause game while training message is displayed + GS_EVENT_INGAME_PRE_JOIN, // go to ship selection screen for ingame join + GS_EVENT_PLAYER_WARPOUT_START, // player hit 'j' to warp out + GS_EVENT_PLAYER_WARPOUT_START_FORCED, // player is being forced out of mission no matter what + GS_EVENT_PLAYER_WARPOUT_STOP, // player hit 'esc' or something to cancel warp out + GS_EVENT_PLAYER_WARPOUT_DONE_STAGE1, // player ship got up to speed + GS_EVENT_PLAYER_WARPOUT_DONE_STAGE2, // player ship got through the warp effect + GS_EVENT_PLAYER_WARPOUT_DONE, // warp effect went away + GS_EVENT_STANDALONE_POSTGAME, // debriefing, etc + GS_EVENT_INITIAL_PLAYER_SELECT, // initial screen where player selects from multi/single player pilots + GS_EVENT_GAME_INIT, + GS_EVENT_MULTI_MISSION_SYNC, // sychronize/transfer/load any mission specific data in multiplayer + GS_EVENT_MULTI_START_GAME, // immediately before the create game screen for the host to set the game variables + GS_EVENT_MULTI_HOST_OPTIONS, // options the host can set while in the create game scree + GS_EVENT_MULTI_DOGFIGHT_DEBRIEF, // multiplayer furball debriefing screen (replaces normal debriefing) + GS_EVENT_CAMPAIGN_ROOM, + GS_EVENT_CMD_BRIEF, // switch to command briefing screen + GS_EVENT_TOGGLE_GLIDE, // GS_EVENT_TOGGLE_GLIDE + GS_EVENT_RED_ALERT, // go to red alert screen + GS_EVENT_SIMULATOR_ROOM, + GS_EVENT_END_CAMPAIGN, // end of the whole thang. + GS_EVENT_LOOP_BRIEF, // campaign loop brief + GS_EVENT_CAMPAIGN_CHEAT, // skip to a mission in a campaign + GS_EVENT_PXO, + GS_EVENT_LAB, // WMC - I-FRED concept + GS_EVENT_PXO_HELP, + GS_EVENT_FICTION_VIEWER, + GS_EVENT_SCRIPTING, + + GS_NUM_EVENTS // Last one++ +}; // IMPORTANT: When you add a new event, update the initialization for GS_event_text[] -// which is done in GameSequence.cpp +// which is done in gamesequence.cpp // extern char *GS_event_text[]; // text description for the GS_EVENT_* #defines above -// defines for game sequencing states -// -// IMPORTANT: When you add a new state, update the initialization for GS_state_text[] -// which is done in GameSequence.cpp -#define GS_STATE_MAIN_MENU 1 -#define GS_STATE_GAME_PLAY 2 -#define GS_STATE_GAME_PAUSED 3 -#define GS_STATE_QUIT_GAME 4 -#define GS_STATE_OPTIONS_MENU 5 -#define GS_STATE_BARRACKS_MENU 6 -#define GS_STATE_TECH_MENU 7 -#define GS_STATE_TRAINING_MENU 8 -#define GS_STATE_LOAD_MISSION_MENU 9 -#define GS_STATE_BRIEFING 10 -#define GS_STATE_SHIP_SELECT 11 -#define GS_STATE_DEBUG_PAUSED 12 -#define GS_STATE_HUD_CONFIG 13 -#define GS_STATE_MULTI_JOIN_GAME 14 -#define GS_STATE_CONTROL_CONFIG 15 -#define GS_STATE_WEAPON_SELECT 16 -#define GS_STATE_MISSION_LOG_SCROLLBACK 17 -#define GS_STATE_DEATH_DIED 18 // Player just died -#define GS_STATE_DEATH_BLEW_UP 19 // Saw ship explode. -#define GS_STATE_SIMULATOR_ROOM 20 -#define GS_STATE_CREDITS 21 -#define GS_STATE_SHOW_GOALS 22 -#define GS_STATE_HOTKEY_SCREEN 23 -#define GS_STATE_VIEW_MEDALS 24 // Go to the View Medals screen -#define GS_STATE_MULTI_HOST_SETUP 25 // state where host sets up multiplayer game -#define GS_STATE_MULTI_CLIENT_SETUP 26 // client setup for multiplayer game -#define GS_STATE_DEBRIEF 27 -#define GS_STATE_VIEW_CUTSCENES 28 -#define GS_STATE_MULTI_STD_WAIT 29 -#define GS_STATE_STANDALONE_MAIN 30 -#define GS_STATE_MULTI_PAUSED 31 -#define GS_STATE_TEAM_SELECT 32 -#define GS_STATE_TRAINING_PAUSED 33 // game is paused while training msg is being read. -#define GS_STATE_INGAME_PRE_JOIN 34 // go to ship selection screen for ingame join -#define GS_STATE_EVENT_DEBUG 35 // an event debug trace scroll list display screen -#define GS_STATE_STANDALONE_POSTGAME 36 // debriefing, etc. -#define GS_STATE_INITIAL_PLAYER_SELECT 37 -#define GS_STATE_MULTI_MISSION_SYNC 38 -#define GS_STATE_MULTI_START_GAME 39 -#define GS_STATE_MULTI_HOST_OPTIONS 40 -#define GS_STATE_MULTI_DOGFIGHT_DEBRIEF 41 -#define GS_STATE_CAMPAIGN_ROOM 42 -#define GS_STATE_CMD_BRIEF 43 // command briefing screen -#define GS_STATE_RED_ALERT 44 // red alert screen -#define GS_STATE_END_OF_CAMPAIGN 45 // end of main campaign -- only applicable in single player -#define GS_STATE_GAMEPLAY_HELP 46 -#define GS_STATE_LOOP_BRIEF 48 -#define GS_STATE_PXO 49 -#define GS_STATE_LAB 50 -#define GS_STATE_PXO_HELP 51 -#define GS_STATE_START_GAME 52 -#define GS_STATE_FICTION_VIEWER 53 -#define GS_STATE_SCRIPTING 54 - -#define GS_NUM_STATES 55 //Last one++ - +/** + * @brief Enum's for game sequencing states + * + * @details IMPORTANT: When you add a new state, you must update the initialization for GS_state_text[] in + * gamesequence.cpp. Otherwise, the fs2_open.log string "Got event..." will not display properly. + */ +enum GS_STATE { + GS_STATE_INVALID = 0, // This state should never be reached + GS_STATE_MAIN_MENU, + GS_STATE_GAME_PLAY, + GS_STATE_GAME_PAUSED, + GS_STATE_QUIT_GAME, + GS_STATE_OPTIONS_MENU, + GS_STATE_BARRACKS_MENU, + GS_STATE_TECH_MENU, + GS_STATE_TRAINING_MENU, + GS_STATE_LOAD_MISSION_MENU, + GS_STATE_BRIEFING, + GS_STATE_SHIP_SELECT, + GS_STATE_DEBUG_PAUSED, + GS_STATE_HUD_CONFIG, + GS_STATE_MULTI_JOIN_GAME, + GS_STATE_CONTROL_CONFIG, + GS_STATE_WEAPON_SELECT, + GS_STATE_MISSION_LOG_SCROLLBACK, + GS_STATE_DEATH_DIED, // Player just died + GS_STATE_DEATH_BLEW_UP, // Saw ship explode. + GS_STATE_SIMULATOR_ROOM, + GS_STATE_CREDITS, + GS_STATE_SHOW_GOALS, + GS_STATE_HOTKEY_SCREEN, + GS_STATE_VIEW_MEDALS, // Go to the View Medals screen + GS_STATE_MULTI_HOST_SETUP, // state where host sets up multiplayer game + GS_STATE_MULTI_CLIENT_SETUP, // client setup for multiplayer game + GS_STATE_DEBRIEF, + GS_STATE_VIEW_CUTSCENES, + GS_STATE_MULTI_STD_WAIT, + GS_STATE_STANDALONE_MAIN, + GS_STATE_MULTI_PAUSED, + GS_STATE_TEAM_SELECT, + GS_STATE_TRAINING_PAUSED, // game is paused while training msg is being read. + GS_STATE_INGAME_PRE_JOIN, // go to ship selection screen for ingame join + GS_STATE_EVENT_DEBUG, // an event debug trace scroll list display screen + GS_STATE_STANDALONE_POSTGAME, // debriefing, etc. + GS_STATE_INITIAL_PLAYER_SELECT, + GS_STATE_MULTI_MISSION_SYNC, + GS_STATE_MULTI_START_GAME, + GS_STATE_MULTI_HOST_OPTIONS, + GS_STATE_MULTI_DOGFIGHT_DEBRIEF, + GS_STATE_CAMPAIGN_ROOM, + GS_STATE_CMD_BRIEF, // command briefing screen + GS_STATE_RED_ALERT, // red alert screen + GS_STATE_END_OF_CAMPAIGN, // end of main campaign -- only applicable in single player + GS_STATE_GAMEPLAY_HELP, + GS_STATE_LOOP_BRIEF, + GS_STATE_PXO, + GS_STATE_LAB, + GS_STATE_PXO_HELP, + GS_STATE_START_GAME, + GS_STATE_FICTION_VIEWER, + GS_STATE_SCRIPTING, + + GS_NUM_STATES // Last one++ +}; // IMPORTANT: When you add a new state, update the initialization for GS_state_text[] // which is done in GameSequence.cpp // |
|
Oh, right. It took me a few times to figure it out, but I uploaded a new version sans the VS solution changes. (Jeez, only took me 3 attempts to get the blasted thing done.) |
|
Fix committed @r10252 |
Date Modified | Username | Field | Change |
---|---|---|---|
2013-12-13 06:41 | z64555 | New Issue | |
2013-12-13 06:42 | z64555 | File Added: mantis_2977.diff | |
2013-12-13 06:43 | z64555 | Note Added: 0015512 | |
2013-12-13 06:43 | z64555 | Assigned To | => z64555 |
2013-12-13 06:43 | z64555 | Status | new => code review |
2013-12-13 08:16 | m_m | Note Added: 0015513 | |
2013-12-13 15:03 | z64555 | File Added: mantis_2977_1.diff | |
2013-12-13 15:06 | z64555 | File Deleted: mantis_2977_1.diff | |
2013-12-13 15:07 | z64555 | File Added: mantis_2977_1.diff | |
2013-12-13 15:08 | z64555 | File Deleted: mantis_2977_1.diff | |
2013-12-13 15:09 | z64555 | File Added: mantis_2977_1.diff | |
2013-12-13 15:10 | z64555 | File Deleted: mantis_2977.diff | |
2013-12-13 15:11 | z64555 | Note Added: 0015514 | |
2013-12-18 12:27 | z64555 | Note Added: 0015522 | |
2013-12-18 12:27 | z64555 | Status | code review => resolved |
2013-12-18 12:27 | z64555 | Fixed in Version | => 3.7.1 |
2013-12-18 12:27 | z64555 | Resolution | open => fixed |