Skip to content

Commit

Permalink
Merge pull request diasurgical#1 from Songoo7/turnBasedGameplay
Browse files Browse the repository at this point in the history
Turn based mode, initial commit. Press 'p' for enable command pause.
  • Loading branch information
Songoo7 authored Jan 22, 2024
2 parents 51ab010 + 44f5cbf commit ef7a313
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 24 deletions.
71 changes: 48 additions & 23 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ bool gbProcessPlayers;
bool gbLoadGame;
bool cineflag;
int PauseMode;
int BattlePauseMode;
bool gbBard;
bool gbBarbarian;
bool HeadlessMode = false;
Expand Down Expand Up @@ -208,6 +209,13 @@ void FreeGame()
music_stop();
}

bool isBattlePaused()
{
if (BattlePauseMode == 2) {
return false;
}
}

bool ProcessInput()
{
if (PauseMode == 2) {
Expand Down Expand Up @@ -1425,20 +1433,24 @@ void GameLogic()
return;
}
if (gbProcessPlayers) {
gGameLogicStep = GameLogicStep::ProcessPlayers;
ProcessPlayers();
if (BattlePauseMode != 2) {
gGameLogicStep = GameLogicStep::ProcessPlayers;
ProcessPlayers();
}
}
if (leveltype != DTYPE_TOWN) {
gGameLogicStep = GameLogicStep::ProcessMonsters;
ProcessMonsters();
gGameLogicStep = GameLogicStep::ProcessObjects;
ProcessObjects();
gGameLogicStep = GameLogicStep::ProcessMissiles;
ProcessMissiles();
gGameLogicStep = GameLogicStep::ProcessItems;
ProcessItems();
ProcessLightList();
ProcessVisionList();
if (BattlePauseMode != 2) {
gGameLogicStep = GameLogicStep::ProcessMonsters;
ProcessMonsters();
gGameLogicStep = GameLogicStep::ProcessObjects;
ProcessObjects();
gGameLogicStep = GameLogicStep::ProcessMissiles;
ProcessMissiles();
gGameLogicStep = GameLogicStep::ProcessItems;
ProcessItems();
ProcessLightList();
ProcessVisionList();
}
} else {
gGameLogicStep = GameLogicStep::ProcessTowners;
ProcessTowners();
Expand All @@ -1447,21 +1459,25 @@ void GameLogic()
gGameLogicStep = GameLogicStep::ProcessMissilesTown;
ProcessMissiles();
}
gGameLogicStep = GameLogicStep::None;

//removethis
if (BattlePauseMode != 2) {
gGameLogicStep = GameLogicStep::None;

#ifdef _DEBUG
if (DebugScrollViewEnabled && (SDL_GetModState() & KMOD_SHIFT) != 0) {
ScrollView();
}
if (DebugScrollViewEnabled && (SDL_GetModState() & KMOD_SHIFT) != 0) {
ScrollView();
}
#endif

sound_update();
CheckTriggers();
CheckQuests();
RedrawViewport();
pfile_update(false);
sound_update();
CheckTriggers();
CheckQuests();
RedrawViewport();
pfile_update(false);

plrctrls_after_game_logic();
plrctrls_after_game_logic();
}
}

void TimeoutCursor(bool bTimeout)
Expand Down Expand Up @@ -1893,7 +1909,7 @@ void InitKeymapActions()
N_("Pause Game"),
N_("Pauses the game."),
'P',
diablo_pause_game);
diablo_battle_pause_game);
sgOptions.Keymapper.AddAction(
"Pause Game (Alternate)",
N_("Pause Game (Alternate)"),
Expand Down Expand Up @@ -2692,6 +2708,15 @@ void diablo_pause_game()
}
}

void diablo_battle_pause_game()
{
if (BattlePauseMode != 0) {
BattlePauseMode = 0;
} else {
BattlePauseMode = 2;
}
}

bool GameWasAlreadyPaused = false;
bool MinimizePaused = false;

Expand Down
2 changes: 2 additions & 0 deletions Source/diablo.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ extern bool cineflag;
/* These are defined in fonts.h */
extern void FontsCleanup();
extern DVL_API_FOR_TEST int PauseMode;
extern DVL_API_FOR_TEST int BattlePauseMode;
extern bool gbBard;
extern bool gbBarbarian;
/**
Expand All @@ -89,6 +90,7 @@ bool StartGame(bool bNewGame, bool bSinglePlayer);
int DiabloMain(int argc, char **argv);
bool TryIconCurs();
void diablo_pause_game();
void diablo_battle_pause_game();
bool diablo_is_focused();
void diablo_focus_pause();
void diablo_focus_unpause();
Expand Down
2 changes: 1 addition & 1 deletion Source/nthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ bool nthread_has_500ms_passed(bool *drawGame /*= nullptr*/)

void nthread_UpdateProgressToNextGameTick()
{
if (!gbRunGame || PauseMode != 0 || (!gbIsMultiplayer && gmenu_is_active()) || !gbProcessPlayers || demo::IsRunning()) // if game is not running or paused there is no next gametick in the near future
if (!gbRunGame || PauseMode != 0 || BattlePauseMode != 0 || (!gbIsMultiplayer && gmenu_is_active()) || !gbProcessPlayers || demo::IsRunning()) // if game is not running or paused there is no next gametick in the near future
return;
int currentTickCount = SDL_GetTicks();
int ticksMissing = last_tick - currentTickCount;
Expand Down

0 comments on commit ef7a313

Please sign in to comment.