Skip to content

Commit ffca48d

Browse files
committed
sgame: resend configstrings that could be wrong
...due to a map change during the client downloading something. This is a temporary workaround until clients have DaemonEngine/Daemon#1954.
1 parent d308a46 commit ffca48d

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

src/sgame/sg_client.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,28 @@ const char *ClientBotConnect( int clientNum, bool firstTime )
12651265
return nullptr;
12661266
}
12671267

1268+
// Resend configstrings that could be affected by https://github.com/Unvanquished/Unvanquished/issues/1102.
1269+
// TODO(0.57): remove since with the new version we have well-behaved clients.
1270+
static void ResendPossiblyWrongConfigstrings( int clientNum )
1271+
{
1272+
for ( int cs = CS_PLAYERS + level.maxclients; cs--; )
1273+
{
1274+
char configstring[ 1022 ];
1275+
trap_GetConfigstring( cs, configstring, sizeof( configstring ) );
1276+
std::string command = Str::Format( "cs %d %s", cs, Cmd::Escape( configstring ) );
1277+
if ( command.size() > 1022 )
1278+
{
1279+
// don't want to re-implement all of the bcs0 bcs1 bcs2 junk for this band-aid
1280+
Log::Warn( "Disabling configstring update workaround for client %d string %d due to length",
1281+
clientNum, cs );
1282+
}
1283+
else
1284+
{
1285+
trap_SendServerCommand( clientNum, command.c_str() );
1286+
}
1287+
}
1288+
}
1289+
12681290
/*
12691291
===========
12701292
ClientBegin
@@ -1322,6 +1344,8 @@ void ClientBegin( int clientNum )
13221344
// locate ent at a spawn point
13231345
ClientSpawn( ent, nullptr, nullptr, nullptr );
13241346

1347+
ResendPossiblyWrongConfigstrings( clientNum );
1348+
13251349
trap_SendServerCommand( -1, va( "print_tr %s %s", QQ( N_("$1$^* entered the game") ), Quote( client->pers.netname ) ) );
13261350

13271351
std::string startMsg = g_mapStartupMessage.Get();

src/shared/bg_public.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ enum team_t
242242
// CS_SERVERINFO and CS_SYSTEMINFO are defined in q_shared.h
243243
enum
244244
{
245-
CS_MUSIC = RESERVED_CONFIGSTRINGS,
246-
CS_MESSAGE, // from the map worldspawn's message field
247-
CS_MOTD, // g_motd string for server message of the day
245+
CS_MOTD = RESERVED_CONFIGSTRINGS, // g_motd string for server message of the day
248246
CS_WARMUP, // server time when the match will be restarted
249247

250248
CS_VOTE_TIME, // Vote stuff each needs NUM_TEAMS slots
@@ -260,15 +258,21 @@ enum
260258
CS_SHADERSTATE,
261259
CS_CLIENTS_READY,
262260

261+
CS_PLAYERS,
262+
263+
// Stuff below this normally never changes after the match starts
264+
265+
CS_MUSIC = CS_PLAYERS + MAX_CLIENTS,
266+
CS_MESSAGE, // from the map worldspawn's message field
267+
263268
CS_MODELS,
264269
CS_SOUNDS = CS_MODELS + MAX_MODELS,
265270
CS_SHADERS = CS_SOUNDS + MAX_SOUNDS,
266271
CS_GRADING_TEXTURES = CS_SHADERS + MAX_GAME_SHADERS,
267272
CS_REVERB_EFFECTS = CS_GRADING_TEXTURES + MAX_GRADING_TEXTURES,
268273
CS_PARTICLE_SYSTEMS = CS_REVERB_EFFECTS + MAX_REVERB_EFFECTS,
269274

270-
CS_PLAYERS = CS_PARTICLE_SYSTEMS + MAX_GAME_PARTICLE_SYSTEMS,
271-
CS_LOCATIONS = CS_PLAYERS + MAX_CLIENTS,
275+
CS_LOCATIONS = CS_PARTICLE_SYSTEMS + MAX_GAME_PARTICLE_SYSTEMS,
272276
CS_MAX = CS_LOCATIONS + MAX_LOCATIONS
273277
};
274278

0 commit comments

Comments
 (0)