From 14d3ee19d0866fe6d6d635145db13d9a653f4736 Mon Sep 17 00:00:00 2001 From: Blixibon Date: Wed, 27 Jan 2021 23:25:09 -0600 Subject: [PATCH] Fixed the client-side VScript "player" instance not being set once more after having moved around the VM init code again --- sp/src/game/client/c_baseplayer.cpp | 8 ++++++++ sp/src/game/client/vscript_client.cpp | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sp/src/game/client/c_baseplayer.cpp b/sp/src/game/client/c_baseplayer.cpp index e47f6de8..ced6ced9 100644 --- a/sp/src/game/client/c_baseplayer.cpp +++ b/sp/src/game/client/c_baseplayer.cpp @@ -855,6 +855,14 @@ void C_BasePlayer::PostDataUpdate( DataUpdateType_t updateType ) // changed level, which would cause the snd_soundmixer to be left modified. ConVar *pVar = (ConVar *)cvar->FindVar( "snd_soundmixer" ); pVar->Revert(); + +#ifdef MAPBASE_VSCRIPT + // Moved here from LevelInitPostEntity, which is executed before local player is spawned. + if ( g_pScriptVM ) + { + g_pScriptVM->SetValue( "player", GetScriptInstance() ); + } +#endif } } diff --git a/sp/src/game/client/vscript_client.cpp b/sp/src/game/client/vscript_client.cpp index 943a22b5..58b5431c 100644 --- a/sp/src/game/client/vscript_client.cpp +++ b/sp/src/game/client/vscript_client.cpp @@ -576,13 +576,6 @@ bool VScriptClientInit() if( g_pScriptVM ) { #ifdef MAPBASE_VSCRIPT - // Moved here from LevelInitPostEntity, which is executed before local player is spawned. - // This is executed after C_World::OnDataChanged, which is after C_BasePlayer::Spawn - if ( C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer() ) - { - g_pScriptVM->SetValue( "player", pPlayer->GetScriptInstance() ); - } - CGMsg( 0, CON_GROUP_VSCRIPT, "VSCRIPT CLIENT: Started VScript virtual machine using script language '%s'\n", g_pScriptVM->GetLanguageName() ); #else Log( "VSCRIPT: Started VScript virtual machine using script language '%s'\n", g_pScriptVM->GetLanguageName() );