mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-13 23:37:58 +03:00
Fixing bug with vscript restore cache not updating soon enough
This commit is contained in:
parent
264ee2b04f
commit
9510c03ab3
@ -65,8 +65,16 @@ struct WriteStateMap
|
|||||||
struct ReadStateMap
|
struct ReadStateMap
|
||||||
{
|
{
|
||||||
CUtlMap<int, HSQOBJECT> cache;
|
CUtlMap<int, HSQOBJECT> cache;
|
||||||
|
#ifdef _DEBUG
|
||||||
|
CUtlMap<int, bool> allocated;
|
||||||
|
#endif
|
||||||
HSQUIRRELVM vm_;
|
HSQUIRRELVM vm_;
|
||||||
ReadStateMap(HSQUIRRELVM vm) : cache(DefLessFunc(int)), vm_(vm)
|
ReadStateMap(HSQUIRRELVM vm) :
|
||||||
|
cache(DefLessFunc(int)),
|
||||||
|
#ifdef _DEBUG
|
||||||
|
allocated(DefLessFunc(int)),
|
||||||
|
#endif
|
||||||
|
vm_(vm)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~ReadStateMap()
|
~ReadStateMap()
|
||||||
@ -83,6 +91,16 @@ struct ReadStateMap
|
|||||||
int marker = pBuffer->GetInt();
|
int marker = pBuffer->GetInt();
|
||||||
|
|
||||||
auto idx = cache.Find(marker);
|
auto idx = cache.Find(marker);
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
auto allocatedIdx = allocated.Find(marker);
|
||||||
|
bool hasSeen = allocatedIdx != allocated.InvalidIndex();
|
||||||
|
if (!hasSeen)
|
||||||
|
{
|
||||||
|
allocated.Insert(marker, true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (idx != cache.InvalidIndex())
|
if (idx != cache.InvalidIndex())
|
||||||
{
|
{
|
||||||
sq_pushobject(vm, cache[idx]);
|
sq_pushobject(vm, cache[idx]);
|
||||||
@ -90,6 +108,9 @@ struct ReadStateMap
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
Assert(!hasSeen);
|
||||||
|
#endif
|
||||||
*outmarker = marker;
|
*outmarker = marker;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -3388,6 +3409,7 @@ void SquirrelVM::WriteState(CUtlBuffer* pBuffer)
|
|||||||
int count = sq_getsize(vm_, 1);
|
int count = sq_getsize(vm_, 1);
|
||||||
sq_pushnull(vm_);
|
sq_pushnull(vm_);
|
||||||
pBuffer->PutInt(count);
|
pBuffer->PutInt(count);
|
||||||
|
|
||||||
while (SQ_SUCCEEDED(sq_next(vm_, -2)))
|
while (SQ_SUCCEEDED(sq_next(vm_, -2)))
|
||||||
{
|
{
|
||||||
WriteObject(pBuffer, writeState, -2);
|
WriteObject(pBuffer, writeState, -2);
|
||||||
@ -3521,6 +3543,9 @@ void SquirrelVM::ReadObject(CUtlBuffer* pBuffer, ReadStateMap& readState)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vm_->Push(ret);
|
||||||
|
readState.StoreTopInCache(marker);
|
||||||
|
|
||||||
int noutervalues = _closure(ret)->_function->_noutervalues;
|
int noutervalues = _closure(ret)->_function->_noutervalues;
|
||||||
for (int i = 0; i < noutervalues; ++i)
|
for (int i = 0; i < noutervalues; ++i)
|
||||||
{
|
{
|
||||||
@ -3542,9 +3567,6 @@ void SquirrelVM::ReadObject(CUtlBuffer* pBuffer, ReadStateMap& readState)
|
|||||||
_closure(ret)->_defaultparams[i] = obj;
|
_closure(ret)->_defaultparams[i] = obj;
|
||||||
sq_poptop(vm_);
|
sq_poptop(vm_);
|
||||||
}
|
}
|
||||||
|
|
||||||
vm_->Push(ret);
|
|
||||||
readState.StoreTopInCache(marker);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadObject(pBuffer, readState);
|
ReadObject(pBuffer, readState);
|
||||||
@ -3816,16 +3838,17 @@ void SquirrelVM::ReadObject(CUtlBuffer* pBuffer, ReadStateMap& readState)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SQOuter* outer = SQOuter::Create(_ss(vm_), nullptr);
|
||||||
|
vm_->Push(outer);
|
||||||
|
readState.StoreTopInCache(marker);
|
||||||
|
|
||||||
ReadObject(pBuffer, readState);
|
ReadObject(pBuffer, readState);
|
||||||
HSQOBJECT inner;
|
HSQOBJECT inner;
|
||||||
sq_resetobject(&inner);
|
sq_resetobject(&inner);
|
||||||
sq_getstackobj(vm_, -1, &inner);
|
sq_getstackobj(vm_, -1, &inner);
|
||||||
SQOuter* outer = SQOuter::Create(_ss(vm_), nullptr);
|
|
||||||
outer->_value = inner;
|
outer->_value = inner;
|
||||||
outer->_valptr = &(outer->_value);
|
outer->_valptr = &(outer->_value);
|
||||||
sq_poptop(vm_);
|
sq_poptop(vm_);
|
||||||
vm_->Push(outer);
|
|
||||||
readState.StoreTopInCache(marker);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user