|
|
@ -559,94 +559,64 @@ int plNetClientMgr::Update(double secs) |
|
|
|
//
|
|
|
|
//
|
|
|
|
void plNetClientMgr::ICheckPendingStateLoad(double secs) |
|
|
|
void plNetClientMgr::ICheckPendingStateLoad(double secs) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ((!fPendingLoads.empty() && GetFlagsBit(kPlayingGame)) || (GetFlagsBit(kLoadingInitialAgeState) && !GetFlagsBit(kNeedInitialAgeStateCount))) |
|
|
|
// We only care if we're in an age or loading state
|
|
|
|
{ |
|
|
|
if (!(GetFlagsBit(kPlayingGame) || (GetFlagsBit(kLoadingInitialAgeState) && !GetFlagsBit(kNeedInitialAgeStateCount)))) |
|
|
|
PendingLoadsList::iterator it = fPendingLoads.begin(); |
|
|
|
return; |
|
|
|
while ( it!=fPendingLoads.end() ) |
|
|
|
|
|
|
|
|
|
|
|
for (auto it = fPendingLoads.begin(); it != fPendingLoads.end();) |
|
|
|
{ |
|
|
|
{ |
|
|
|
PendingLoad * pl = (*it); |
|
|
|
PendingLoad* load = *it; |
|
|
|
|
|
|
|
|
|
|
|
// cache rcvr key
|
|
|
|
// If no key has been cached, we need to find it.
|
|
|
|
if (!pl->fKey) |
|
|
|
if (!load->fKey) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// check for existence of key in dataset, excluding clone info.
|
|
|
|
load->fKey = hsgResMgr::ResMgr()->FindKey(load->fUoid); |
|
|
|
plUoid tmpUoid = pl->fUoid; |
|
|
|
|
|
|
|
tmpUoid.SetClone(0,0); |
|
|
|
// By this point, we should have all the age's keys downloaded from filesrv
|
|
|
|
if ( !hsgResMgr::ResMgr()->FindKey( tmpUoid ) ) |
|
|
|
// So, if fKey is null at this point, this state is garbage
|
|
|
|
|
|
|
|
if (!load->fKey) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// discard the state if object not found in dataset.
|
|
|
|
ErrorMsg("Key `%s` not found. Discarding state for `%s`", |
|
|
|
hsLogEntry( DebugMsg( "Failed to find object %s in dataset. Discarding pending state '%s'", |
|
|
|
load->fUoid.GetObjectName().c_str(), |
|
|
|
tmpUoid.StringIze().c_str(), |
|
|
|
load->fSDRec->GetDescriptor()->GetName().c_str()); |
|
|
|
pl->fSDRec->GetDescriptor()->GetName().c_str() ) ); |
|
|
|
|
|
|
|
delete pl; |
|
|
|
|
|
|
|
it = fPendingLoads.erase(it); |
|
|
|
it = fPendingLoads.erase(it); |
|
|
|
|
|
|
|
delete load; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
// find and cache the real key.
|
|
|
|
|
|
|
|
pl->fKey = hsgResMgr::ResMgr()->FindKey(pl->fUoid); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// deliver state if possible
|
|
|
|
// Time to deliver the state!
|
|
|
|
plSynchedObject*so = pl->fKey ? plSynchedObject::ConvertNoRef(pl->fKey->ObjectIsLoaded()) : nil; |
|
|
|
plSynchedObject* synchObj = plSynchedObject::ConvertNoRef(load->fKey->ObjectIsLoaded()); |
|
|
|
if (so && so->IsFinal()) |
|
|
|
if (synchObj && synchObj->IsFinal()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
plSDLModifierMsg* sdlMsg = new plSDLModifierMsg(pl->fSDRec->GetDescriptor()->GetName(),
|
|
|
|
plSDLModifierMsg* msg = new plSDLModifierMsg(load->fSDRec->GetDescriptor()->GetName(), plSDLModifierMsg::kRecv); |
|
|
|
plSDLModifierMsg::kRecv); |
|
|
|
msg->SetState(load->fSDRec, true); |
|
|
|
sdlMsg->SetState( pl->fSDRec, true/*delete pl->fSDRec for us*/ ); |
|
|
|
load->fSDRec = nullptr; |
|
|
|
sdlMsg->SetPlayerID( pl->fPlayerID ); |
|
|
|
msg->SetPlayerID(load->fPlayerID); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef HS_DEBUGGING |
|
|
|
#ifdef HS_DEBUGGING |
|
|
|
if (plNetObjectDebugger::GetInstance()->IsDebugObject(so)) |
|
|
|
if (plNetObjectDebugger::GetInstance()->IsDebugObject(synchObj)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
hsLogEntry( DebugMsg( "Delivering SDL state %s:%s", pl->fKey->GetName().c_str(), |
|
|
|
DebugMsg("Delivering SDL State '%s' to %s owned key %s", |
|
|
|
pl->fSDRec->GetDescriptor()->GetName().c_str() ) ); |
|
|
|
msg->GetState()->GetDescriptor()->GetName().c_str(), |
|
|
|
// hsLogEntry(plNetObjectDebugger::GetInstance()->LogMsg(plString::Format("Dispatching SDL state, type %s to object:%s, locallyOwned=%d, st=%.3f rt=%.3f",
|
|
|
|
(synchObj->IsLocallyOwned() == plSynchedObject::kYes) ? "locally" : "remote", |
|
|
|
// pl->fSDRec->GetDescriptor()->GetName().c_str(), pl->fKey->GetName().c_str(),
|
|
|
|
load->fUoid.StringIze().c_str()); |
|
|
|
// so->IsLocallyOwned()==plSynchedObject::kYes, secs, hsTimer::GetSeconds()).c_str()));
|
|
|
|
|
|
|
|
// hsLogEntry( pl->fSDRec->DumpToObjectDebugger( "Delivering SDL state", false, 0 ) );
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
msg->Send(load->fKey); |
|
|
|
sdlMsg->Send(pl->fKey); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pl->fSDRec = nil; // so it won't be deleted in the PendingLoad dtor.
|
|
|
|
|
|
|
|
delete pl; |
|
|
|
|
|
|
|
it = fPendingLoads.erase(it); |
|
|
|
it = fPendingLoads.erase(it); |
|
|
|
|
|
|
|
delete load; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else if (GetFlagsBit(kPlayingGame)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// report old pending state
|
|
|
|
// If we're playing the game and object isn't loaded/final, then this state is probably
|
|
|
|
double rawSecs = hsTimer::GetSeconds(); |
|
|
|
// never going to be useful (it's from some paged in hack or something that's been deleted)
|
|
|
|
if ((rawSecs - pl->fQueuedTime) > 60.f /*secs*/) |
|
|
|
// Throw it away.
|
|
|
|
{ |
|
|
|
|
|
|
|
if (pl->fQueueTimeResets >= 5) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// if this is our fifth time in here then we've been queued
|
|
|
|
|
|
|
|
// for around 5 minutes and its time to go
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WarningMsg( "Pending state '%s' for object [uoid:%s,key:%s] has been queued for about %f secs. Removing...", |
|
|
|
|
|
|
|
pl->fSDRec && pl->fSDRec->GetDescriptor() ? pl->fSDRec->GetDescriptor()->GetName().c_str() : "?", |
|
|
|
|
|
|
|
pl->fUoid.StringIze().c_str(), pl->fKey ? pl->fKey->GetUoid().StringIze().c_str() : "?", |
|
|
|
|
|
|
|
( rawSecs - pl->fQueuedTime ) * pl->fQueueTimeResets); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delete pl; |
|
|
|
|
|
|
|
it = fPendingLoads.erase(it); |
|
|
|
it = fPendingLoads.erase(it); |
|
|
|
continue; |
|
|
|
delete load; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WarningMsg( "Pending state '%s' for object [uoid:%s,key:%s] has been queued for about %f secs. %s", |
|
|
|
|
|
|
|
pl->fSDRec && pl->fSDRec->GetDescriptor() ? pl->fSDRec->GetDescriptor()->GetName().c_str() : "?", |
|
|
|
|
|
|
|
pl->fUoid.StringIze().c_str(), pl->fKey ? pl->fKey->GetUoid().StringIze().c_str() : "?", |
|
|
|
|
|
|
|
( rawSecs - pl->fQueuedTime ) * pl->fQueueTimeResets, |
|
|
|
|
|
|
|
so ? "(not loaded)" : "(not final)" ); |
|
|
|
|
|
|
|
// reset queue time so we don't spew too many log msgs.
|
|
|
|
|
|
|
|
pl->fQueuedTime = rawSecs; |
|
|
|
|
|
|
|
pl->fQueueTimeResets += 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
++it; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1437,11 +1407,10 @@ plUoid plNetClientMgr::GetAgeSDLObjectUoid(const char* ageName) const |
|
|
|
//
|
|
|
|
//
|
|
|
|
void plNetClientMgr::AddPendingLoad(PendingLoad *pl)
|
|
|
|
void plNetClientMgr::AddPendingLoad(PendingLoad *pl)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pl->fQueuedTime = hsTimer::GetSeconds(); // timestamp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// find corresponding key
|
|
|
|
// find corresponding key
|
|
|
|
pl->fKey = hsgResMgr::ResMgr()->FindKey(pl->fUoid); |
|
|
|
pl->fKey = hsgResMgr::ResMgr()->FindKey(pl->fUoid); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HS_DEBUGGING |
|
|
|
// check for age SDL state
|
|
|
|
// check for age SDL state
|
|
|
|
if (!pl->fUoid.GetObjectName().IsNull() && !pl->fUoid.GetObjectName().Compare(plSDL::kAgeSDLObjectName)) |
|
|
|
if (!pl->fUoid.GetObjectName().IsNull() && !pl->fUoid.GetObjectName().Compare(plSDL::kAgeSDLObjectName)) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1451,6 +1420,7 @@ void plNetClientMgr::AddPendingLoad(PendingLoad *pl) |
|
|
|
else |
|
|
|
else |
|
|
|
DebugMsg("Found age hook object"); |
|
|
|
DebugMsg("Found age hook object"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// check if object is ready
|
|
|
|
// check if object is ready
|
|
|
|
if (pl->fKey) |
|
|
|
if (pl->fKey) |
|
|
|