mirror of
https://github.com/alexbatalov/fallout2-ce.git
synced 2024-09-04 13:59:04 +00:00
Add game mode tracking
This commit is contained in:
parent
90da2164f2
commit
dc90beb696
@ -297,6 +297,8 @@ int _automapDisplayMap(int map)
|
||||
// 0x41B8BC
|
||||
void automapShow(bool isInGame, bool isUsingScanner)
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kAutomap);
|
||||
|
||||
int frmIds[AUTOMAP_FRM_COUNT];
|
||||
memcpy(frmIds, gAutomapFrmIds, sizeof(gAutomapFrmIds));
|
||||
|
||||
|
@ -790,6 +790,8 @@ static std::vector<TownReputationEntry> gCustomTownReputationEntries;
|
||||
// 0x431DF8
|
||||
int characterEditorShow(bool isCreationMode)
|
||||
{
|
||||
ScopedGameMode gm(!isCreationMode ? GameMode::kEditor : 0);
|
||||
|
||||
char* messageListItemText;
|
||||
char line1[128];
|
||||
char line2[128];
|
||||
|
@ -3131,6 +3131,8 @@ void _combat_turn_run()
|
||||
// 0x4227F4
|
||||
static int _combat_input()
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kPlayerTurn);
|
||||
|
||||
while ((gCombatState & COMBAT_STATE_0x02) != 0) {
|
||||
sharedFpsLimiter.mark();
|
||||
|
||||
@ -3369,6 +3371,8 @@ static bool _combat_should_end()
|
||||
// 0x422D2C
|
||||
void _combat(STRUCT_664980* attack)
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kCombat);
|
||||
|
||||
if (attack == NULL
|
||||
|| (attack->attacker == NULL || attack->attacker->elevation == gElevation)
|
||||
|| (attack->defender == NULL || attack->defender->elevation == gElevation)) {
|
||||
|
32
src/game.cc
32
src/game.cc
@ -1151,6 +1151,8 @@ static void gameFreeGlobalVars()
|
||||
// 0x443F74
|
||||
static void showHelp()
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kHelp);
|
||||
|
||||
bool isoWasEnabled = isoDisable();
|
||||
gameMouseObjectsHide();
|
||||
|
||||
@ -1437,4 +1439,34 @@ int gameShowDeathDialog(const char* message)
|
||||
return rc;
|
||||
}
|
||||
|
||||
int GameMode::currentGameMode = 0;
|
||||
|
||||
void GameMode::enterGameMode(int gameMode)
|
||||
{
|
||||
currentGameMode |= gameMode;
|
||||
debugPrint("Entering game mode: %d", gameMode);
|
||||
}
|
||||
|
||||
void GameMode::exitGameMode(int gameMode)
|
||||
{
|
||||
currentGameMode &= ~gameMode;
|
||||
debugPrint("Exiting game mode: %d", gameMode);
|
||||
}
|
||||
|
||||
bool GameMode::isInGameMode(int gameMode)
|
||||
{
|
||||
return (currentGameMode & gameMode) != 0;
|
||||
}
|
||||
|
||||
ScopedGameMode::ScopedGameMode(int gameMode)
|
||||
{
|
||||
this->gameMode = gameMode;
|
||||
GameMode::enterGameMode(gameMode);
|
||||
}
|
||||
|
||||
ScopedGameMode::~ScopedGameMode()
|
||||
{
|
||||
GameMode::exitGameMode(gameMode);
|
||||
}
|
||||
|
||||
} // namespace fallout
|
||||
|
46
src/game.h
46
src/game.h
@ -41,6 +41,52 @@ int showQuitConfirmationDialog();
|
||||
|
||||
int gameShowDeathDialog(const char* message);
|
||||
|
||||
class GameMode
|
||||
{
|
||||
public:
|
||||
enum Flags
|
||||
{
|
||||
kWorldmap = 0x1,
|
||||
kDialog = 0x4,
|
||||
kOptions = 0x8,
|
||||
kSaveGame = 0x10,
|
||||
kLoadGame = 0x20,
|
||||
kCombat = 0x40,
|
||||
kPreferences = 0x80,
|
||||
kHelp = 0x100,
|
||||
kEditor = 0x200,
|
||||
kPipboy = 0x400,
|
||||
kPlayerTurn = 0x800,
|
||||
kInventory = 0x1000,
|
||||
kAutomap = 0x2000,
|
||||
kSkilldex = 0x4000,
|
||||
kUseOn = 0x8000,
|
||||
kLoot = 0x10000,
|
||||
kBarter = 0x20000,
|
||||
kHero = 0x40000,
|
||||
kDialogReview = 0x80000,
|
||||
kCounter = 0x100000,
|
||||
kSpecial = 0x80000000,
|
||||
};
|
||||
|
||||
static void enterGameMode(int gameMode);
|
||||
static void exitGameMode(int gameMode);
|
||||
static bool isInGameMode(int gameMode);
|
||||
static int getCurrentGameMode() { return currentGameMode; }
|
||||
|
||||
private:
|
||||
static int currentGameMode;
|
||||
};
|
||||
|
||||
class ScopedGameMode {
|
||||
public:
|
||||
ScopedGameMode(int gameMode);
|
||||
~ScopedGameMode();
|
||||
|
||||
private:
|
||||
int gameMode;
|
||||
};
|
||||
|
||||
} // namespace fallout
|
||||
|
||||
#endif /* GAME_H */
|
||||
|
@ -922,6 +922,8 @@ int _gdialogInitFromScript(int headFid, int reaction)
|
||||
|
||||
_gdDialogWentOff = true;
|
||||
|
||||
GameMode::enterGameMode(GameMode::kDialog);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -947,7 +949,11 @@ int _gdialogExitFromScript()
|
||||
_tile_scroll_to(gGameDialogOldCenterTile, 2);
|
||||
}
|
||||
|
||||
GameMode::exitGameMode(GameMode::kDialog);
|
||||
|
||||
GameMode::enterGameMode(GameMode::kSpecial);
|
||||
_gdDestroyHeadWindow();
|
||||
GameMode::exitGameMode(GameMode::kSpecial);
|
||||
|
||||
// CE: Fix Barter button.
|
||||
gameDialogRedButtonsExit();
|
||||
@ -1189,10 +1195,14 @@ void _gdialogUpdatePartyStatus()
|
||||
// NOTE: Uninline.
|
||||
gdHide();
|
||||
|
||||
GameMode::enterGameMode(GameMode::kSpecial);
|
||||
|
||||
_gdialog_window_destroy();
|
||||
|
||||
gGameDialogSpeakerIsPartyMember = isPartyMember;
|
||||
|
||||
GameMode::exitGameMode(GameMode::kSpecial);
|
||||
|
||||
_gdialog_window_create();
|
||||
|
||||
// NOTE: Uninline.
|
||||
@ -1430,6 +1440,8 @@ int gameDialogReviewWindowFree(int* win)
|
||||
// 0x445CA0
|
||||
int gameDialogShowReview()
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kDialogReview);
|
||||
|
||||
int win;
|
||||
|
||||
if (gameDialogReviewWindowInit(&win) == -1) {
|
||||
@ -1871,6 +1883,9 @@ int _gdProcess()
|
||||
} else {
|
||||
if (_dialogue_switch_mode == 3) {
|
||||
_dialogue_state = 4;
|
||||
|
||||
GameMode::exitGameMode(GameMode::kSpecial);
|
||||
|
||||
inventoryOpenTrade(gGameDialogWindow, gGameDialogSpeaker, _peon_table_obj, _barterer_table_obj, gGameDialogBarterModifier);
|
||||
_gdialog_barter_cleanup_tables();
|
||||
|
||||
@ -2745,6 +2760,9 @@ void gameDialogTicker()
|
||||
case 2:
|
||||
_loop_cnt = -1;
|
||||
_dialogue_switch_mode = 3;
|
||||
|
||||
GameMode::enterGameMode(GameMode::kSpecial);
|
||||
|
||||
_gdialog_window_destroy();
|
||||
_gdialog_barter_create_win();
|
||||
break;
|
||||
|
@ -548,6 +548,8 @@ void inventoryOpen()
|
||||
}
|
||||
}
|
||||
|
||||
ScopedGameMode gm(GameMode::kInventory);
|
||||
|
||||
if (inventoryCommonInit() == -1) {
|
||||
return;
|
||||
}
|
||||
@ -2618,6 +2620,8 @@ static void _adjust_fid()
|
||||
// 0x4717E4
|
||||
void inventoryOpenUseItemOn(Object* a1)
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kUseOn);
|
||||
|
||||
if (inventoryCommonInit() == -1) {
|
||||
return;
|
||||
}
|
||||
@ -4044,6 +4048,8 @@ int inventoryOpenLooting(Object* a1, Object* a2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ScopedGameMode gm(GameMode::kLoot);
|
||||
|
||||
if (FID_TYPE(a2->fid) == OBJ_TYPE_CRITTER) {
|
||||
if (_critter_flag_check(a2->pid, CRITTER_NO_STEAL)) {
|
||||
// You can't find anything to take from that.
|
||||
@ -5018,6 +5024,8 @@ static void inventoryWindowRenderInnerInventories(int win, Object* a2, Object* a
|
||||
// 0x4757F0
|
||||
void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kBarter);
|
||||
|
||||
_barter_mod = a5;
|
||||
|
||||
if (inventoryCommonInit() == -1) {
|
||||
@ -5568,6 +5576,8 @@ static void _draw_amount(int value, int inventoryWindowType)
|
||||
// 0x47688C
|
||||
static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int max)
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kCounter);
|
||||
|
||||
inventoryQuantityWindowInit(inventoryWindowType, item);
|
||||
|
||||
int value;
|
||||
|
@ -350,6 +350,8 @@ void _ResetLoadSave()
|
||||
// 0x47B88C
|
||||
int lsgSaveGame(int mode)
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kSaveGame);
|
||||
|
||||
MessageListItem messageListItem;
|
||||
|
||||
_ls_error_code = 0;
|
||||
@ -854,6 +856,8 @@ static int _QuickSnapShot()
|
||||
// 0x47C640
|
||||
int lsgLoadGame(int mode)
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kLoadGame);
|
||||
|
||||
MessageListItem messageListItem;
|
||||
|
||||
const char* body[] = {
|
||||
|
@ -462,6 +462,8 @@ int showOptions()
|
||||
// 0x48FC50
|
||||
int showOptionsWithInitialKeyCode(int initialKeyCode)
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kOptions);
|
||||
|
||||
if (optionsWindowInit() == -1) {
|
||||
debugPrint("\nOPTION MENU: Error loading option dialog data!\n");
|
||||
return -1;
|
||||
@ -1699,6 +1701,8 @@ static int preferencesWindowFree()
|
||||
// 0x490798
|
||||
static int _do_prefscreen()
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kPreferences);
|
||||
|
||||
if (preferencesWindowInit() == -1) {
|
||||
debugPrint("\nPREFERENCE MENU: Error loading preference dialog data!\n");
|
||||
return -1;
|
||||
|
@ -406,6 +406,8 @@ int pipboyOpen(int intent)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ScopedGameMode gm(GameMode::kPipboy);
|
||||
|
||||
intent = pipboyWindowInit(intent);
|
||||
if (intent == -1) {
|
||||
return -1;
|
||||
|
@ -109,6 +109,8 @@ static FrmImage _skilldexFrmImages[SKILLDEX_FRM_COUNT];
|
||||
// 0x4ABFD0
|
||||
int skilldexOpen()
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kSkilldex);
|
||||
|
||||
if (skilldexWindowInit() == -1) {
|
||||
debugPrint("\n ** Error loading skilldex dialog data! **\n");
|
||||
return -1;
|
||||
|
@ -2958,6 +2958,8 @@ void wmWorldMap()
|
||||
// 0x4BFE10
|
||||
static int wmWorldMapFunc(int a1)
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kWorldmap);
|
||||
|
||||
if (wmInterfaceInit() == -1) {
|
||||
wmInterfaceExit();
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user