diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/queueCommand.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/queueCommand.cpp index 1e8010d234..2bb5693a1c 100644 --- a/src/OpenSHC/Synchrony/GameSynchronyState/queueCommand.cpp +++ b/src/OpenSHC/Synchrony/GameSynchronyState/queueCommand.cpp @@ -26,7 +26,8 @@ namespace Synchrony { this->DAT_GameCommandArray[this->DAT_CurrentGameCommandID].stateUnk = Commands::GCS_UNPROCESSED; this->DAT_GameCommandArray[this->DAT_CurrentGameCommandID].playerUnk = this->DPLAYX_PlayerHandle; this->DAT_GameCommandArray[this->DAT_CurrentGameCommandID].commandType = commandType; - if (DAT_GameCore::instance.mapTimeInTicks > this->mapTimeInTicksSinglePlayer) { + // a signed compare, though mapTimeInTicks is a uint + if ((int)DAT_GameCore::instance.mapTimeInTicks > this->mapTimeInTicksSinglePlayer) { this->DAT_GameCommandArray[this->DAT_CurrentGameCommandID].time = this->commandDelay + DAT_GameCore::instance.mapTimeInTicks; } else { @@ -39,7 +40,7 @@ namespace Synchrony { // Calls the callback function for a specific command. See "GameCommandType" for possible // commands: placing buildings, walls, moving units, ... DAT_ProtocolDefinedData::instance - .commandFunctions[this->DAT_GameCommandArray[this->DAT_CurrentGameCommandID].commandType](); + .commandFunctions[this->DAT_GameCommandArray[this->DAT_CurrentGameCommandID].commandType](); this->DAT_CommandParameterOffset = 0; dword _time = this->DAT_GameCommandArray[this->DAT_CurrentGameCommandID].time; if (0 < (int)_time) { @@ -65,7 +66,7 @@ namespace Synchrony { this->DPLAYX_ReceivedPlayerID = this->DPLAYX_PlayerHandle; this->protocolInvokerPlayerID = this->currentPlayerSlotID; DAT_ProtocolDefinedData::instance - .commandFunctions[this->DAT_GameCommandArray[this->DAT_CurrentGameCommandID].commandType](); + .commandFunctions[this->DAT_GameCommandArray[this->DAT_CurrentGameCommandID].commandType](); } MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::clearGameCommandEntry, this)( this->DAT_CurrentGameCommandID); diff --git a/src/OpenSHC/UI/HoveredState/clearInvalidatedHoverStates.cpp b/src/OpenSHC/UI/HoveredState/clearInvalidatedHoverStates.cpp index 11e1cde1a3..723f6e5a3f 100644 --- a/src/OpenSHC/UI/HoveredState/clearInvalidatedHoverStates.cpp +++ b/src/OpenSHC/UI/HoveredState/clearInvalidatedHoverStates.cpp @@ -1,4 +1,5 @@ -#include "OpenSHC/UI/HoveredState.func.hpp" +#include "../HoveredState.func.hpp" + #include "OpenSHC/Commands/MappersEnum.hpp" #include "OpenSHC/Game/GameMode.hpp" #include "OpenSHC/UI/HoveredStateElement.hpp" @@ -20,8 +21,9 @@ namespace UI { return; } for (int i = 0; i < 20; ++i) { + // a signed compare, though mapTimeInTicks is a uint if (this->elements[i].type != OpenSHC::Commands::M_MAPPER_NULL - && DAT_GameCore::instance.mapTimeInTicks >= this->elements[i].time) { + && (int)DAT_GameCore::instance.mapTimeInTicks >= this->elements[i].time) { this->elements[i].type = OpenSHC::Commands::M_MAPPER_NULL; } } diff --git a/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_CurrentlySelectedTroopsDeselectHelper.cpp b/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_CurrentlySelectedTroopsDeselectHelper.cpp index 61b5b48e2f..bd65eb0d7e 100644 --- a/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_CurrentlySelectedTroopsDeselectHelper.cpp +++ b/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_CurrentlySelectedTroopsDeselectHelper.cpp @@ -1,5 +1,4 @@ -#include "OpenSHC/UI/MenuItems/BuildMenu.func.hpp" -#include "OpenSHC/Map/Units/Selection/UnitSelectionEnumInt.hpp" +#include "../BuildMenu.func.hpp" #include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" #include "OpenSHC/Globals/DAT_UnitsState.hpp" @@ -9,19 +8,17 @@ namespace UI { namespace MenuItems { namespace BuildMenu { - using Map::Units::Selection::UnitSelectionEnumInt; - // FUNCTION: STRONGHOLDCRUSADER 0x00439390 - void MenuItemRenderFunction_BuildMenu_CurrentlySelectedTroopsDeselectHelper( - UnitSelectionEnumInt selectionIndex, ...) + void MenuItemRenderFunction_BuildMenu_CurrentlySelectedTroopsDeselectHelper(int slotID, ...) { if (DAT_UnitsState::instance.nHasOwnedUnitInSelection == 0) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } - DAT_ButtonUnknownZero::instance = 0; - if (DAT_UnitsState::instance.selectionUnitType[selectionIndex] == -1) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = FALSE; + // the deselect buttons are slot IDs 20 to 27 + if (DAT_UnitsState::instance.selectionSlots[slotID - 20] == -1) { + DAT_ButtonUnknownZero::instance = TRUE; } } diff --git a/src/OpenSHC/UI/Rendering/DisplayMapDescriptionAndAllocatePlayersToSlots.cpp b/src/OpenSHC/UI/Rendering/DisplayMapDescriptionAndAllocatePlayersToSlots.cpp index c8825476d7..6c5ec971b5 100644 --- a/src/OpenSHC/UI/Rendering/DisplayMapDescriptionAndAllocatePlayersToSlots.cpp +++ b/src/OpenSHC/UI/Rendering/DisplayMapDescriptionAndAllocatePlayersToSlots.cpp @@ -31,9 +31,10 @@ namespace UI { // FUNCTION: STRONGHOLDCRUSADER 0x004410D0 void Rendering::DisplayMapDescriptionAndAllocatePlayersToSlots() { - if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset - + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected - >= 0 + // both read up front, the scroll offset first: the plain sum loads them the other way round + int const scrollOffset = DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + int const relativeSelected = DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected; + if (relativeSelected + scrollOffset >= 0 || (!DAT_GameSynchronyState::instance.isHost && strlen(DAT_GameSynchronyState::instance.mapName) != 0)) { char mapFileName[1008]; strcpy(mapFileName, DAT_GameSynchronyState::instance.mapName);