3636#include " Common/GlobalData.h"
3737#include " Common/QuotedPrintable.h"
3838#include " Common/UserPreferences.h"
39+ #include " Common/version.h"
3940#include " GameNetwork/LANAPI.h"
4041#include " GameNetwork/LANAPICallbacks.h"
4142#include " GameClient/MapUtil.h"
4243
44+ void LANAPI::handlePatchInfo (Int messageType, UnsignedInt senderIP, UnicodeString gameName)
45+ {
46+ LANMessage msg;
47+ fillInLANMessage (&msg);
48+ msg.messageType = (LANMessage::Type)messageType;
49+ wcslcpy (msg.PatchInfo .gameName , gameName.str (), ARRAY_SIZE (msg.PatchInfo .gameName ));
50+ msg.PatchInfo .patchVersion = TheVersion->getVersionNumber ();
51+
52+ sendMessage (&msg, senderIP);
53+ }
54+
55+ void LANAPI::handleGameRequestPatchInfo (LANMessage *msg, UnsignedInt senderIP)
56+ {
57+ if (!AmIHost ())
58+ return ;
59+
60+ // acknowledge as game host a request for patch information by a player in the lobby
61+ handlePatchInfo (LANMessage::MSG_GAME_ACKNOWLEDGE_PATCH_INFO, senderIP, m_currentGame->getName ());
62+ }
63+
64+ void LANAPI::handleGameAcknowledgePatchInfo (LANMessage *msg, UnsignedInt senderIP)
65+ {
66+ if (!m_inLobby)
67+ return ;
68+
69+ LANGameInfo *game = LookupGame (UnicodeString (msg->GameInfo .gameName ));
70+ if (!game)
71+ return ;
72+
73+ if (game->getIP (0 ) != senderIP)
74+ return ;
75+
76+ // a game host has acknowledged our request for patch information
77+ game->getSlot (0 )->setPatchVersion (msg->PatchInfo .patchVersion );
78+
79+ // update game list with colored names
80+ OnGameList (m_games);
81+ }
82+
83+ void LANAPI::handleLobbyRequestPatchInfo (LANMessage *msg, UnsignedInt senderIP)
84+ {
85+ if (!m_inLobby)
86+ return ;
87+
88+ // acknowledge a request for patch information by a fellow player in the lobby
89+ handlePatchInfo (LANMessage::MSG_LOBBY_ACKNOWLEDGE_PATCH_INFO, senderIP, UnicodeString ());
90+ }
91+
92+ void LANAPI::handleLobbyAcknowledgePatchInfo (LANMessage *msg, UnsignedInt senderIP)
93+ {
94+ if (!m_inLobby)
95+ return ;
96+
97+ LANPlayer *player = LookupPlayer (senderIP);
98+ if (!player)
99+ return ;
100+
101+ // a fellow player in the lobby has acknowledged our request for patch information
102+ player->setPatchVersion (msg->PatchInfo .patchVersion );
103+
104+ // update player list with colored names
105+ OnPlayerList (m_lobbyPlayers);
106+ }
107+
108+ void LANAPI::handleMatchRequestPatchInfo (LANMessage *msg, UnsignedInt senderIP)
109+ {
110+ if (!m_currentGame)
111+ return ;
112+
113+ // acknowledge a request for patch information by a fellow player in the game
114+ handlePatchInfo (LANMessage::MSG_MATCH_ACKNOWLEDGE_PATCH_INFO, senderIP, m_currentGame->getName ());
115+
116+ // treat request for patch information as acknowledgement
117+ handleMatchAcknowledgePatchInfo (msg, senderIP);
118+ }
119+
120+ void LANAPI::handleMatchAcknowledgePatchInfo (LANMessage *msg, UnsignedInt senderIP)
121+ {
122+ if (!m_currentGame)
123+ return ;
124+
125+ for (Int i = 0 ; i < MAX_SLOTS; ++i)
126+ {
127+ if (!m_currentGame->getLANSlot (i)->isHuman () || m_currentGame->getIP (i) != senderIP)
128+ continue ;
129+
130+ // a fellow player in the game has acknowledged our request for patch information
131+ m_currentGame->getSlot (i)->setPatchVersion (msg->PatchInfo .patchVersion );
132+
133+ // update player list with colored names
134+ lanUpdateSlotList ();
135+
136+ break ;
137+ }
138+ }
139+
43140void LANAPI::handleRequestLocations ( LANMessage *msg, UnsignedInt senderIP )
44141{
45142 if (m_inLobby)
@@ -139,6 +236,9 @@ void LANAPI::handleGameAnnounce( LANMessage *msg, UnsignedInt senderIP )
139236 game = NEW LANGameInfo;
140237 game->setName (UnicodeString (msg->GameInfo .gameName ));
141238 addGame (game);
239+
240+ // TheSuperHackers @feature Caball009 06/11/2025 Request a game host to send patch information.
241+ handlePatchInfo (LANMessage::MSG_GAME_REQUEST_PATCH_INFO, senderIP, game->getName ());
142242 }
143243 Bool success = ParseGameOptionsString (game,AsciiString (msg->GameInfo .options ));
144244 game->setGameInProgress (msg->GameInfo .inProgress );
@@ -165,6 +265,9 @@ void LANAPI::handleLobbyAnnounce( LANMessage *msg, UnsignedInt senderIP )
165265 {
166266 player = NEW LANPlayer;
167267 player->setIP (senderIP);
268+
269+ // TheSuperHackers @feature Caball009 06/11/2025 Request a player in the lobby to send patch information.
270+ handlePatchInfo (LANMessage::MSG_LOBBY_REQUEST_PATCH_INFO, senderIP, UnicodeString ());
168271 }
169272 else
170273 {
@@ -401,6 +504,9 @@ void LANAPI::handleJoinAccept( LANMessage *msg, UnsignedInt senderIP )
401504 OnGameJoin (RET_OK, m_currentGame);
402505 // DEBUG_ASSERTCRASH(false, ("setting host to %ls@%ls", m_currentGame->getLANSlot(0)->getUser()->getLogin().str(),
403506 // m_currentGame->getLANSlot(0)->getUser()->getHost().str()));
507+
508+ // TheSuperHackers @feature Caball009 06/11/2025 Request players in the match to send patch information.
509+ handlePatchInfo (LANMessage::MSG_MATCH_REQUEST_PATCH_INFO, 0 , m_currentGame->getName ());
404510 }
405511 m_pendingAction = ACT_NONE;
406512 m_expiration = 0 ;
0 commit comments