Skip to content

Commit 67f50d1

Browse files
authored
tweak(input): Remove input latency for group creation in multiplayer games (#1471)
1 parent e1555bc commit 67f50d1

File tree

8 files changed

+50
-14
lines changed

8 files changed

+50
-14
lines changed

Generals/Code/GameEngine/Include/Common/Player.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ class Player : public Snapshot
603603
ScoreKeeper* getScoreKeeper( void ) { return &m_scoreKeeper; }
604604

605605
/// time to create a hotkey team based on this GameMessage
606-
void processCreateTeamGameMessage(Int hotkeyNum, GameMessage *msg);
606+
void processCreateTeamGameMessage(Int hotkeyNum, const GameMessage *msg);
607607

608608
/// time to select a hotkey team based on this GameMessage
609609
void processSelectTeamGameMessage(Int hotkeyNum, GameMessage *msg);

Generals/Code/GameEngine/Source/Common/RTS/Player.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3181,7 +3181,7 @@ void Player::applyBattlePlanBonusesForPlayerObjects( const BattlePlanBonuses *bo
31813181
//-------------------------------------------------------------------------------------------------
31823182
/** Create a hotkey team based on this GameMessage */
31833183
//-------------------------------------------------------------------------------------------------
3184-
void Player::processCreateTeamGameMessage(Int hotkeyNum, GameMessage *msg) {
3184+
void Player::processCreateTeamGameMessage(Int hotkeyNum, const GameMessage *msg) {
31853185
// GameMessage arguments are the object ID's of the objects that are to be in this team.
31863186

31873187
if ((hotkeyNum < 0) || (hotkeyNum >= NUM_HOTKEY_SQUADS)) {

Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,6 +3269,26 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
32693269
break;
32703270
}
32713271

3272+
// --------------------------------------------------------------------------------------------
3273+
case GameMessage::MSG_CREATE_TEAM0:
3274+
case GameMessage::MSG_CREATE_TEAM1:
3275+
case GameMessage::MSG_CREATE_TEAM2:
3276+
case GameMessage::MSG_CREATE_TEAM3:
3277+
case GameMessage::MSG_CREATE_TEAM4:
3278+
case GameMessage::MSG_CREATE_TEAM5:
3279+
case GameMessage::MSG_CREATE_TEAM6:
3280+
case GameMessage::MSG_CREATE_TEAM7:
3281+
case GameMessage::MSG_CREATE_TEAM8:
3282+
case GameMessage::MSG_CREATE_TEAM9:
3283+
{
3284+
Int playerIndex = msg->getPlayerIndex();
3285+
Player* player = ThePlayerList->getNthPlayer(playerIndex);
3286+
if (player && player->isLocalPlayer())
3287+
player->processCreateTeamGameMessage(t - GameMessage::MSG_CREATE_TEAM0, msg);
3288+
3289+
break;
3290+
}
3291+
32723292
// --------------------------------------------------------------------------------------------
32733293
case GameMessage::MSG_CREATE_SELECTED_GROUP:
32743294
case GameMessage::MSG_SELECT_TEAM0:

Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,12 +1901,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
19011901
Player *player = ThePlayerList->getNthPlayer(playerIndex);
19021902
DEBUG_ASSERTCRASH(player != NULL, ("Could not find player for create team message"));
19031903

1904-
if (player == NULL)
1905-
{
1906-
break;
1907-
}
1904+
// TheSuperHackers @tweak Stubbjax 17/08/2025 The local player processes this message in CommandXlat for immediate assignment.
1905+
if (player && !player->isLocalPlayer())
1906+
player->processCreateTeamGameMessage(msg->getType() - GameMessage::MSG_CREATE_TEAM0, msg);
19081907

1909-
player->processCreateTeamGameMessage(msg->getType() - GameMessage::MSG_CREATE_TEAM0, msg);
19101908
break;
19111909
} // end create team command
19121910

GeneralsMD/Code/GameEngine/Include/Common/Player.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ class Player : public Snapshot
629629
ScoreKeeper* getScoreKeeper( void ) { return &m_scoreKeeper; }
630630

631631
/// time to create a hotkey team based on this GameMessage
632-
void processCreateTeamGameMessage(Int hotkeyNum, GameMessage *msg);
632+
void processCreateTeamGameMessage(Int hotkeyNum, const GameMessage *msg);
633633

634634
/// time to select a hotkey team based on this GameMessage
635635
void processSelectTeamGameMessage(Int hotkeyNum, GameMessage *msg);

GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3682,7 +3682,7 @@ void Player::applyBattlePlanBonusesForPlayerObjects( const BattlePlanBonuses *bo
36823682
//-------------------------------------------------------------------------------------------------
36833683
/** Create a hotkey team based on this GameMessage */
36843684
//-------------------------------------------------------------------------------------------------
3685-
void Player::processCreateTeamGameMessage(Int hotkeyNum, GameMessage *msg) {
3685+
void Player::processCreateTeamGameMessage(Int hotkeyNum, const GameMessage *msg) {
36863686
// GameMessage arguments are the object ID's of the objects that are to be in this team.
36873687

36883688
if ((hotkeyNum < 0) || (hotkeyNum >= NUM_HOTKEY_SQUADS)) {

GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3610,6 +3610,26 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
36103610
break;
36113611
}
36123612

3613+
// --------------------------------------------------------------------------------------------
3614+
case GameMessage::MSG_CREATE_TEAM0:
3615+
case GameMessage::MSG_CREATE_TEAM1:
3616+
case GameMessage::MSG_CREATE_TEAM2:
3617+
case GameMessage::MSG_CREATE_TEAM3:
3618+
case GameMessage::MSG_CREATE_TEAM4:
3619+
case GameMessage::MSG_CREATE_TEAM5:
3620+
case GameMessage::MSG_CREATE_TEAM6:
3621+
case GameMessage::MSG_CREATE_TEAM7:
3622+
case GameMessage::MSG_CREATE_TEAM8:
3623+
case GameMessage::MSG_CREATE_TEAM9:
3624+
{
3625+
Int playerIndex = msg->getPlayerIndex();
3626+
Player* player = ThePlayerList->getNthPlayer(playerIndex);
3627+
if (player && player->isLocalPlayer())
3628+
player->processCreateTeamGameMessage(t - GameMessage::MSG_CREATE_TEAM0, msg);
3629+
3630+
break;
3631+
}
3632+
36133633
// --------------------------------------------------------------------------------------------
36143634
case GameMessage::MSG_CREATE_SELECTED_GROUP:
36153635
case GameMessage::MSG_SELECT_TEAM0:

GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,12 +1929,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
19291929
Player *player = ThePlayerList->getNthPlayer(playerIndex);
19301930
DEBUG_ASSERTCRASH(player != NULL, ("Could not find player for create team message"));
19311931

1932-
if (player == NULL)
1933-
{
1934-
break;
1935-
}
1932+
// TheSuperHackers @tweak Stubbjax 17/08/2025 The local player processes this message in CommandXlat for immediate assignment.
1933+
if (player && !player->isLocalPlayer())
1934+
player->processCreateTeamGameMessage(msg->getType() - GameMessage::MSG_CREATE_TEAM0, msg);
19361935

1937-
player->processCreateTeamGameMessage(msg->getType() - GameMessage::MSG_CREATE_TEAM0, msg);
19381936
break;
19391937
} // end create team command
19401938

0 commit comments

Comments
 (0)