Skip to content

Commit b1f97df

Browse files
author
Bart Roossien
committed
[GEN][ZH] Fix reselection of group not always working
1 parent d83fca1 commit b1f97df

File tree

2 files changed

+59
-63
lines changed

2 files changed

+59
-63
lines changed

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

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,50 +1024,48 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
10241024
m_lastGroupSelTime = now;
10251025
}
10261026

1027-
// check for double-press to jump view
1028-
if ( now - m_lastGroupSelTime < 20 && group == m_lastGroupSelGroup )
1027+
// TheSuperHackers @fix skyaero 22/07/2025
1028+
// Always select the units, even when double press, to prevent accidental deselect.
1029+
1030+
TheInGameUI->deselectAllDrawables(false); //No need to post message because we're just creating a new group!
1031+
bool isDoubleTap = (now - m_lastGroupSelTime < 20) && (group == m_lastGroupSelGroup);
1032+
1033+
if (!isDoubleTap)
10291034
{
1030-
DEBUG_LOG(("META: DOUBLETAP select team %d",group));
1031-
Player *player = ThePlayerList->getLocalPlayer();
1032-
if (player)
1035+
// no need to send two messages for selecting the same group.
1036+
TheMessageStream->appendMessage((GameMessage::Type)(GameMessage::MSG_SELECT_TEAM0 + group));
1037+
}
1038+
1039+
Player *player = ThePlayerList->getLocalPlayer();
1040+
if (player)
1041+
{
1042+
Squad *selectedSquad = player->getHotkeySquad(group);
1043+
if (selectedSquad != NULL)
10331044
{
1034-
Squad *selectedSquad = player->getHotkeySquad(group);
1035-
if (selectedSquad != NULL)
1045+
VecObjectPtr objlist = selectedSquad->getLiveObjects();
1046+
Int numObjs = objlist.size();
1047+
1048+
for (Int i = 0; i < numObjs; ++i)
10361049
{
1037-
VecObjectPtr objlist = selectedSquad->getLiveObjects();
1038-
Int numObjs = objlist.size();
1039-
if (numObjs > 0)
1050+
if( objlist[i]->getControllingPlayer() == player )
10401051
{
1041-
// if theres someone in the group, center the camera on them.
1042-
TheTacticalView->lookAt( objlist[numObjs-1]->getDrawable()->getPosition() );
1052+
TheInGameUI->selectDrawable(objlist[i]->getDrawable());
10431053
}
10441054
}
1045-
}
1046-
}
1047-
else
1048-
{
1049-
TheInGameUI->deselectAllDrawables( false ); //No need to post message because we're just creating a new group!
10501055

1051-
// no need to send two messages for selecting the same group.
1052-
TheMessageStream->appendMessage((GameMessage::Type)(GameMessage::MSG_SELECT_TEAM0 + group));
1053-
Player *player = ThePlayerList->getLocalPlayer();
1054-
if (player)
1055-
{
1056-
Squad *selectedSquad = player->getHotkeySquad(group);
1057-
if (selectedSquad != NULL)
1056+
if (isDoubleTap)
10581057
{
1059-
VecObjectPtr objlist = selectedSquad->getLiveObjects();
1060-
Int numObjs = objlist.size();
1061-
for (Int i = 0; i < numObjs; ++i)
1058+
DEBUG_LOG(("META: DOUBLETAP select team %d", group));
1059+
1060+
if (numObjs > 0)
10621061
{
1063-
if( objlist[i]->getControllingPlayer() == player )
1064-
{
1065-
TheInGameUI->selectDrawable(objlist[i]->getDrawable());
1066-
}
1062+
// if theres someone in the group, center the camera on them.
1063+
TheTacticalView->lookAt(objlist[numObjs - 1]->getDrawable()->getPosition());
10671064
}
10681065
}
10691066
}
1070-
}
1067+
}
1068+
10711069
m_lastGroupSelTime = now;
10721070
m_lastGroupSelGroup = group;
10731071
}

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

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,50 +1099,48 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
10991099
m_lastGroupSelTime = now;
11001100
}
11011101

1102-
// check for double-press to jump view
1103-
if ( now - m_lastGroupSelTime < 20 && group == m_lastGroupSelGroup )
1102+
// TheSuperHackers @fix skyaero 22/07/2025
1103+
// Always select the units, even when double press, to prevent accidental deselect.
1104+
1105+
TheInGameUI->deselectAllDrawables(false); //No need to post message because we're just creating a new group!
1106+
bool isDoubleTap = (now - m_lastGroupSelTime < 20) && (group == m_lastGroupSelGroup);
1107+
1108+
if (!isDoubleTap)
11041109
{
1105-
DEBUG_LOG(("META: DOUBLETAP select team %d",group));
1106-
Player *player = ThePlayerList->getLocalPlayer();
1107-
if (player)
1110+
// no need to send two messages for selecting the same group.
1111+
TheMessageStream->appendMessage((GameMessage::Type)(GameMessage::MSG_SELECT_TEAM0 + group));
1112+
}
1113+
1114+
Player* player = ThePlayerList->getLocalPlayer();
1115+
if (player)
1116+
{
1117+
Squad* selectedSquad = player->getHotkeySquad(group);
1118+
if (selectedSquad != NULL)
11081119
{
1109-
Squad *selectedSquad = player->getHotkeySquad(group);
1110-
if (selectedSquad != NULL)
1120+
VecObjectPtr objlist = selectedSquad->getLiveObjects();
1121+
Int numObjs = objlist.size();
1122+
1123+
for (Int i = 0; i < numObjs; ++i)
11111124
{
1112-
VecObjectPtr objlist = selectedSquad->getLiveObjects();
1113-
Int numObjs = objlist.size();
1114-
if (numObjs > 0)
1125+
if (objlist[i]->getControllingPlayer() == player)
11151126
{
1116-
// if theres someone in the group, center the camera on them.
1117-
TheTacticalView->lookAt( objlist[numObjs-1]->getDrawable()->getPosition() );
1127+
TheInGameUI->selectDrawable(objlist[i]->getDrawable());
11181128
}
11191129
}
1120-
}
1121-
}
1122-
else
1123-
{
1124-
TheInGameUI->deselectAllDrawables( false ); //No need to post message because we're just creating a new group!
11251130

1126-
// no need to send two messages for selecting the same group.
1127-
TheMessageStream->appendMessage((GameMessage::Type)(GameMessage::MSG_SELECT_TEAM0 + group));
1128-
Player *player = ThePlayerList->getLocalPlayer();
1129-
if (player)
1130-
{
1131-
Squad *selectedSquad = player->getHotkeySquad(group);
1132-
if (selectedSquad != NULL)
1131+
if (isDoubleTap)
11331132
{
1134-
VecObjectPtr objlist = selectedSquad->getLiveObjects();
1135-
Int numObjs = objlist.size();
1136-
for (Int i = 0; i < numObjs; ++i)
1133+
DEBUG_LOG(("META: DOUBLETAP select team %d", group));
1134+
1135+
if (numObjs > 0)
11371136
{
1138-
if( objlist[i]->getControllingPlayer() == player )
1139-
{
1140-
TheInGameUI->selectDrawable(objlist[i]->getDrawable());
1141-
}
1137+
// if theres someone in the group, center the camera on them.
1138+
TheTacticalView->lookAt(objlist[numObjs - 1]->getDrawable()->getPosition());
11421139
}
11431140
}
11441141
}
11451142
}
1143+
11461144
m_lastGroupSelTime = now;
11471145
m_lastGroupSelGroup = group;
11481146
}

0 commit comments

Comments
 (0)