Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gamenetwork): online staging slot list, player list, QM map pool

Olcay Seygan476a1cdb64a1
diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp
index 0bb8649f5..6a5fe49e7 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp
@@ -34,6 +34,7 @@
#include "Common/GameState.h"
#include "GameClient/MapUtil.h"
#include "GameNetwork/GameSpy/GSConfig.h"
+#include "GameNetwork/Online/OnlineQueues.h"
#include "GameNetwork/RankPointValue.h"
#ifdef _INTERNAL
@@ -333,12 +334,18 @@ m_qmChannel(0)
{
line.toLower();
AsciiString mapName;
- mapName.format("%s\\%s\\%s.map", TheMapCache->getMapDir().str(), line.str(), line.str());
+ // EA's file named a map by its folder; the online service's pool is the whole path
+ if (line.endsWith(".map"))
+ mapName = line;
+ else
+ mapName.format("%s\\%s\\%s.map", TheMapCache->getMapDir().str(), line.str(), line.str());
mapName = TheGameState->portableMapPathToRealMapPath(TheGameState->realMapPathToPortableMapPath(mapName));
mapName.toLower();
+ /* -online: the service's mapIdx and qm.join indices count its whole pool, so a map not
+ installed here keeps its place; the screens that list the pool skip it themselves */
const MapMetaData *md = TheMapCache->findMap(mapName);
- if (md)
+ if (md || OnlineIsEnabled())
{
m_qmMaps.push_back(mapName);
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Online/OnlinePeer.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Online/OnlinePeer.cpp
index 1e13b2f99..ea1df57ee 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Online/OnlinePeer.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Online/OnlinePeer.cpp
@@ -529,7 +529,7 @@ void OnlineSession::dispatch( const OnlineMessage &m )
if (m.has( "to" ))
r.message.isPrivate = TRUE;
else if (!namesGame( m, gameId ) && !namesChatRoom( m, groupRoom ))
- return; // a room this player has left (the server keeps a staging player in its chat room)
+ return; // a room this player has left, said before the server took the room.leave
peerResponse( r );
}
else if (t == "game")
@@ -587,6 +587,11 @@ void OnlineSession::dispatch( const OnlineMessage &m )
}
peerResponse( r );
}
+ /* Everyone in the room, ourselves included, into the screen's player list, which GameSpy filled from
+ each room's player keys. Staging chat is shown only from a nick on that list, and the lobby's list
+ has lost the host by now (its room.leave), so without this the staging chat box stayed empty. */
+ for (size_t i = 0; i < ids.size() && i < nicks.size(); ++i)
+ playerResponse( *this, PeerResponse::PEERRESPONSE_PLAYERINFO, StagingRoom, ids[i], nicks[i] );
for (size_t i = 0; i < ids.size(); ++i)
{
if (ids[i] == id)
@@ -601,6 +606,10 @@ void OnlineSession::dispatch( const OnlineMessage &m )
PeerResponse r = makePeer( PeerResponse::PEERRESPONSE_PLAYERUTM );
r.nick = m.getString( "nick" );
r.command = m.getString( "cmd" );
+ // the screens send "SL/", "REQ/", "KICK/" and compare "SL", "REQ", "KICK": GameSpy's peer SDK
+ // dropped the slash on the way, so a joiner never read the host's slot list and left after a minute
+ if (!r.command.empty() && r.command[r.command.size() - 1] == '/')
+ r.command.erase( r.command.size() - 1 );
r.commandOptions = m.getString( "opts" );
if (!m.has( "to" ))
{
@@ -739,6 +748,19 @@ static void leaveGame( OnlineSession &s )
s.hostLeftGame = 0;
}
+/* Out of the chat room on the server too, as GameSpy left the group room for a staging room or Quick Match:
+ the lobby's other players then stop listing somebody who no longer reads it. */
+static void leaveChatRoom( OnlineSession &s )
+{
+ if (s.groupRoom)
+ {
+ OnlineMessage m;
+ m.setString( "t", "room.leave" );
+ s.send( m );
+ }
+ s.groupRoom = 0;
+}
+
void OnlinePeerQueue::addRequest( const PeerRequest& req )
{
OnlineSession &s = OnlineSession::get();
@@ -777,7 +799,7 @@ void OnlinePeerQueue::addRequest( const PeerRequest& req )
return;
case PeerRequest::PEERREQUEST_LEAVEGROUPROOM:
- s.groupRoom = 0; // the server has no leave; the room's lines are dropped from here on
+ leaveChatRoom( s );
return;
case PeerRequest::PEERREQUEST_STARTGAMELIST:
@@ -795,7 +817,7 @@ void OnlinePeerQueue::addRequest( const PeerRequest& req )
case PeerRequest::PEERREQUEST_CREATESTAGINGROOM:
leaveGame( s );
- s.groupRoom = 0;
+ leaveChatRoom( s );
s.hosting = TRUE;
s.hostInfo.clear();
s.hostInfo.setInt( "exe", req.stagingRoomCreation.exeCRC );
@@ -850,7 +872,7 @@ void OnlinePeerQueue::addRequest( const PeerRequest& req )
case PeerRequest::PEERREQUEST_JOINSTAGINGROOM:
leaveGame( s );
- s.groupRoom = 0;
+ leaveChatRoom( s );
s.joiningGame = req.stagingRoom.id;
m.setString( "t", "game.join" ).setInt( "id", req.stagingRoom.id );
s.send( m );
@@ -885,7 +907,7 @@ void OnlinePeerQueue::addRequest( const PeerRequest& req )
case PeerRequest::PEERREQUEST_STARTQUICKMATCH:
{
leaveGame( s );
- s.groupRoom = 0;
+ leaveChatRoom( s );
std::vector<long long> maps;
for (size_t i = 0; i < req.qmMaps.size(); ++i)
if (req.qmMaps[i])
diff --git a/GeneralsMD/Code/Tests/test_online.cpp b/GeneralsMD/Code/Tests/test_online.cpp
index e42f6184f..00f458b41 100644
--- a/GeneralsMD/Code/Tests/test_online.cpp
+++ b/GeneralsMD/Code/Tests/test_online.cpp
@@ -863,11 +863,15 @@ TEST(online_adapter_game_list_round_trips_the_host_options)
rig.feed( "{\"t\":\"game.joined\",\"action\":\"joined\",\"id\":6,\"name\":\"fun game\",\"map\":\"-\",\"maxp\":8,\"host\":\"Tank\",\"hostId\":7,\"count\":1,\"opts\":\"\",\"ids\":[7],\"nicks\":[\"Tank\"]}" );
std::vector<PeerResponse> r = rig.peerResponses();
- CHECK_EQ( r.size(), (size_t)1 );
- if (r.size() == 1)
+ CHECK_EQ( r.size(), (size_t)2 );
+ if (r.size() == 2)
{
CHECK_EQ( (int)r[0].peerResponseType, (int)PeerResponse::PEERRESPONSE_CREATESTAGINGROOM );
CHECK_EQ( r[0].createStagingRoom.result, (Int)PEERJoinSuccess );
+ // the host itself on the staging room's player list, so its own chat lines show
+ CHECK_EQ( (int)r[1].peerResponseType, (int)PeerResponse::PEERRESPONSE_PLAYERINFO );
+ CHECK_STR( r[1].nick.c_str(), "Tank" );
+ CHECK_EQ( (int)r[1].player.roomType, (int)StagingRoom );
}
PeerRequest opts;
@@ -938,8 +942,8 @@ TEST(online_adapter_join_utm_and_start)
rig.feed( "{\"t\":\"game.joined\",\"action\":\"joined\",\"id\":5,\"name\":\"g\",\"map\":\"-\",\"maxp\":8,\"host\":\"Kim\",\"hostId\":9,\"count\":2,\"opts\":\"\",\"ids\":[9,7],\"nicks\":[\"Kim\",\"Tank\"]}" );
std::vector<PeerResponse> r = rig.peerResponses();
- CHECK_EQ( r.size(), (size_t)1 );
- if (r.size() == 1)
+ CHECK_EQ( r.size(), (size_t)3 );
+ if (r.size() == 3)
{
CHECK_EQ( (int)r[0].peerResponseType, (int)PeerResponse::PEERRESPONSE_JOINSTAGINGROOM );
CHECK( r[0].joinStagingRoom.ok );
@@ -947,6 +951,11 @@ TEST(online_adapter_join_utm_and_start)
CHECK( r[0].joinStagingRoom.isHostPresent );
CHECK_STR( r[0].stagingRoomPlayerNames[0].c_str(), "Kim" );
CHECK_STR( r[0].stagingRoomPlayerNames[1].c_str(), "Tank" );
+ // both on the staging room's player list, the host's chat lines need it
+ CHECK_EQ( (int)r[1].peerResponseType, (int)PeerResponse::PEERRESPONSE_PLAYERINFO );
+ CHECK_STR( r[1].nick.c_str(), "Kim" );
+ CHECK_EQ( r[1].player.profileID, 9 );
+ CHECK_STR( r[2].nick.c_str(), "Tank" );
}
CHECK_STR( rig.sentType( 1 ).c_str(), "stats.get" ); // the host's stats, as GameSpy's join read them
CHECK_EQ( rig.sent[1].getInt( "id" ), 9 );
@@ -960,10 +969,10 @@ TEST(online_adapter_join_utm_and_start)
{
CHECK_EQ( (int)r[0].peerResponseType, (int)PeerResponse::PEERRESPONSE_ROOMUTM );
CHECK_STR( r[0].nick.c_str(), "Kim" );
- CHECK_STR( r[0].command.c_str(), "SL/" );
+ CHECK_STR( r[0].command.c_str(), "SL" ); // the screens compare without GameSpy's slash
CHECK_STR( r[0].commandOptions.c_str(), "M=maps/a.map" );
CHECK_EQ( (int)r[1].peerResponseType, (int)PeerResponse::PEERRESPONSE_PLAYERUTM );
- CHECK_STR( r[1].command.c_str(), "KICK/" );
+ CHECK_STR( r[1].command.c_str(), "KICK" );
}
PeerRequest utm;
@@ -1227,3 +1236,29 @@ TEST(online_adapter_logs_the_rating_result)
rig.feed( "{\"t\":\"unrated\",\"match\":\"m2\",\"reason\":\"custom\"}" );
CHECK_STR( OnlineSession::get().resultLine.c_str(), "ONLINE UNRATED reason=custom" );
}
+
+TEST(online_adapter_leaves_the_chat_room_for_a_staging_room)
+{
+ AdapterRig rig;
+ rig.login();
+ PeerRequest join;
+ join.peerRequestType = PeerRequest::PEERREQUEST_JOINGROUPROOM;
+ join.groupRoom.id = 1;
+ rig.peer->addRequest( join );
+ rig.feed( "{\"t\":\"room\",\"id\":\"lobby1\",\"ids\":[7],\"nicks\":[\"Tank\"],\"vips\":[167772163]}" );
+ rig.peerResponses();
+ rig.sent.clear();
+
+ PeerRequest create;
+ create.peerRequestType = PeerRequest::PEERREQUEST_CREATESTAGINGROOM;
+ create.text = u"fun game";
+ rig.peer->addRequest( create );
+ CHECK_STR( rig.sentType( 0 ).c_str(), "room.leave" );
+ CHECK_STR( rig.sentType( 1 ).c_str(), "game.host" );
+
+ rig.sent.clear();
+ PeerRequest leave;
+ leave.peerRequestType = PeerRequest::PEERREQUEST_LEAVEGROUPROOM;
+ rig.peer->addRequest( leave );
+ CHECK_EQ( rig.sent.size(), (size_t)0 ); // already out
+}