twhl-community / halflife-updated

Half-Life SDK updated to compile under VS2019 and 2022. Check README.md for more information.
Other
382 stars 146 forks source link

"Entity is not a player" when loading a saved game while being in multiplayer #225

Closed FreeSlave closed 1 year ago

FreeSlave commented 1 year ago

Load some map via console, quicksave the game. Then leave the game (e.g. via "disconnect" command). Then start multiplayer server via menu. Then press quickload. I'm getting the fatal error image

If I do the same thing on Half-Life (i.e. valve folder, with original libraries), the save is loaded without the error.

SamVanheer commented 1 year ago

The engine has special logic to reset maxplayers to 1 before loading entity data:

if ( !Q_stricmp(com_gamedir, "valve")
    || !Q_stricmp(com_gamedir, "bshift")
    || !Q_stricmp(com_gamedir, "gearbox") )
{
    svs.maxclients = 1;
    Cvar_SetValue("maxplayers", 1.0);
}

Mods don't get this treatment so the engine thinks the first maxplayers - 1 entities are players when they're actually something else.

There is no way to change the engine's behavior here so this can't be fixed.