unify(logic): Merge game loading related variables and functions from Zero Hour#2444
Conversation
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Include/GameLogic/GameLogic.h | Replaces m_loadingScene/isLoadingGame()/setGameLoading() with three new booleans (m_loadingMap, m_loadingSave, m_clearingGameData) and matching getters/setters. isLoadingSave() is declared and documented but setLoadingSave() is never called in the Generals codebase, so it will always return FALSE. |
| Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp | Moves setLoadingMap(TRUE) to the top of startNewGame() (previously setGameLoading(TRUE) was in prepareNewGame()), initializes the three new booleans to FALSE in the constructor, and removes the old setGameLoading() implementation. Logic is otherwise preserved. |
| Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp | Wraps clearGameData() body with setClearingGameData(TRUE/FALSE) and comments out setGameLoading(TRUE) in prepareNewGame() with an explanatory note, deferring to setLoadingMap() in startNewGame(). |
| Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp | Simple call-site update: isLoadingGame() → isLoadingMap(). Functionally equivalent since startNewGame() sets m_loadingMap=TRUE for all game types including save games. |
| Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp | Simple call-site update: isLoadingGame() → isLoadingMap(). Functionally equivalent for the same reason as Diplomacy.cpp. |
Sequence Diagram
sequenceDiagram
participant Dispatch as GameLogicDispatch
participant Logic as GameLogic
participant UI as UI (Diplomacy/QuitMenu)
participant GSM as GameStateMap
Note over Dispatch,Logic: Non-save-game path
Dispatch->>Logic: prepareNewGame()
Note right of Logic: m_loadingMap still FALSE here<br/>(old setGameLoading(TRUE) removed)
Dispatch->>Logic: startNewGame(FALSE)
Logic->>Logic: setLoadingMap(TRUE)
Logic->>Logic: m_startNewGame=TRUE, return early
UI->>Logic: isLoadingMap() → TRUE ✓
Logic->>Logic: update() → startNewGame(FALSE) again
Logic->>Logic: [full map load]
Logic->>Logic: setLoadingMap(FALSE)
Note over GSM,Logic: Save-game path
GSM->>Logic: startNewGame(TRUE)
Logic->>Logic: setLoadingMap(TRUE)
Note right of Logic: setLoadingSave(TRUE) NOT called<br/>in Generals (missing vs GeneralsMD)
Logic->>Logic: [full save load]
Logic->>Logic: setLoadingMap(FALSE)
Note right of Logic: m_loadingSave always FALSE in Generals
Note over Dispatch,Logic: clearGameData path
Dispatch->>Logic: clearGameData()
Logic->>Logic: setClearingGameData(TRUE)
Logic->>Logic: [teardown]
Logic->>Logic: setClearingGameData(FALSE)
Prompt To Fix All With AI
This is a comment left during a code review.
Path: Generals/Code/GameEngine/Include/GameLogic/GameLogic.h
Line: 185
Comment:
**`isLoadingSave()` always returns FALSE in Generals**
`setLoadingSave()` is never called anywhere in the `Generals/` codebase, so `isLoadingSave()` will always return `FALSE` here — making this API misleading and effectively a dead getter.
The GeneralsMD counterpart correctly calls the setter in `GameStateMap::xfer()`:
```cpp
// GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameStateMap.cpp : 247
if( xfer->getXferMode() == XFER_LOAD )
{
TheGameLogic->setLoadingSave( TRUE );
}
// ... later at line 441:
TheGameLogic->setLoadingSave( FALSE );
```
The equivalent `Generals/Code/GameEngine/Source/Common/System/SaveGame/GameStateMap.cpp::xfer()` has no such calls. Since `startNewGame(TRUE)` is called from that same function, the save-game load path exists and `setLoadingSave()` should be called there too — otherwise any future caller of `isLoadingSave()` in Generals will silently get `FALSE` even during an active save-game load.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: a0df0cc
| //Kris: Cut isLoadingGame() and replaced with isLoadingMap() and isLoadingSave() -- reason: nomenclature | ||
| //Bool isLoadingGame() const { return m_loadingScene; } // This is the old function that isn't very clear on it's definition. | ||
| Bool isLoadingMap() const { return m_loadingMap; } // Whenever a map is in the process of loading. | ||
| Bool isLoadingSave() const { return m_loadingSave; } // Whenever a saved game is in the process of loading. |
There was a problem hiding this comment.
isLoadingSave() always returns FALSE in Generals
setLoadingSave() is never called anywhere in the Generals/ codebase, so isLoadingSave() will always return FALSE here — making this API misleading and effectively a dead getter.
The GeneralsMD counterpart correctly calls the setter in GameStateMap::xfer():
// GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameStateMap.cpp : 247
if( xfer->getXferMode() == XFER_LOAD )
{
TheGameLogic->setLoadingSave( TRUE );
}
// ... later at line 441:
TheGameLogic->setLoadingSave( FALSE );The equivalent Generals/Code/GameEngine/Source/Common/System/SaveGame/GameStateMap.cpp::xfer() has no such calls. Since startNewGame(TRUE) is called from that same function, the save-game load path exists and setLoadingSave() should be called there too — otherwise any future caller of isLoadingSave() in Generals will silently get FALSE even during an active save-game load.
Prompt To Fix With AI
This is a comment left during a code review.
Path: Generals/Code/GameEngine/Include/GameLogic/GameLogic.h
Line: 185
Comment:
**`isLoadingSave()` always returns FALSE in Generals**
`setLoadingSave()` is never called anywhere in the `Generals/` codebase, so `isLoadingSave()` will always return `FALSE` here — making this API misleading and effectively a dead getter.
The GeneralsMD counterpart correctly calls the setter in `GameStateMap::xfer()`:
```cpp
// GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameStateMap.cpp : 247
if( xfer->getXferMode() == XFER_LOAD )
{
TheGameLogic->setLoadingSave( TRUE );
}
// ... later at line 441:
TheGameLogic->setLoadingSave( FALSE );
```
The equivalent `Generals/Code/GameEngine/Source/Common/System/SaveGame/GameStateMap.cpp::xfer()` has no such calls. Since `startNewGame(TRUE)` is called from that same function, the save-game load path exists and `setLoadingSave()` should be called there too — otherwise any future caller of `isLoadingSave()` in Generals will silently get `FALSE` even during an active save-game load.
How can I resolve this? If you propose a fix, please make it concise.
This unifies some variables/functions used for loading :
Removed (commented out):
isLoadingGame()Added:
isLoadingMap(),isLoadingSave(),isClearingGameData()This was done for the replicate to Generals in #2440.
Tested skirmish/campaign in Generals.
Replicated by hand using WinMerge