Skip to content

Commit 216ea46

Browse files
authored
Merge pull request #206 from samisalreadytaken/fix
Fix CScriptNetMsgHelper::WriteEntity()
2 parents 924f211 + a2cf90e commit 216ea46

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

sp/src/game/shared/mapbase/vscript_singletons.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,11 @@ void CScriptGameEventListener::StopListeningForEvent()
740740
#ifdef _DEBUG
741741
// Event listeners are iterated forwards in the game event manager,
742742
// removing while iterating will cause it to skip one listener.
743-
// This could be prevented by writing a custom game event manager.
743+
//
744+
// Fix this in engine without altering any behaviour by
745+
// changing event exeuction order to tail->head,
746+
// changing listener removal to tail->head,
747+
// changing listener addition to head
744748
if ( m_nEventTick == gpGlobals->tickcount )
745749
{
746750
Warning("CScriptGameEventListener stopped in the same frame it was fired. This will break other event listeners!\n");
@@ -1749,8 +1753,8 @@ void CNetMsgScriptHelper::WriteEntity( HSCRIPT hEnt )
17491753
{
17501754
SCRIPT_NETMSG_WRITE_FUNC
17511755
CBaseEntity *p = ToEnt(hEnt);
1752-
int i = p ? p->entindex() : -1;
1753-
m_MsgOut.WriteSBitLong( i, MAX_EDICT_BITS );
1756+
int i = p ? p->entindex() : 0;
1757+
m_MsgOut.WriteUBitLong( i, MAX_EDICT_BITS );
17541758
}
17551759

17561760
void CNetMsgScriptHelper::WriteEHandle( HSCRIPT hEnt )
@@ -1861,7 +1865,11 @@ bool CNetMsgScriptHelper::ReadBool()
18611865

18621866
HSCRIPT CNetMsgScriptHelper::ReadEntity()
18631867
{
1864-
int index = m_MsgIn_()ReadSBitLong( MAX_EDICT_BITS );
1868+
int index = m_MsgIn_()ReadUBitLong( MAX_EDICT_BITS );
1869+
1870+
if ( !index )
1871+
return NULL;
1872+
18651873
#ifdef GAME_DLL
18661874
edict_t *e = INDEXENT(index);
18671875
if ( e && !e->IsFree() )

sp/src/vscript/vscript_squirrel.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2779,7 +2779,6 @@ bool SquirrelVM::GenerateUniqueKey(const char* pszRoot, char* pBuf, int nBufSize
27792779
static int keyIdx = 0;
27802780
// This gets used for script scope, still confused why it needs to be inside IScriptVM
27812781
// is it just to be a compatible name for CreateScope?
2782-
SquirrelSafeCheck safeCheck(vm_);
27832782
V_snprintf(pBuf, nBufSize, "%08X_%s", ++keyIdx, pszRoot);
27842783
return true;
27852784
}

0 commit comments

Comments
 (0)