Skip to content

Commit

Permalink
Small code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
HumanGamer committed Jun 23, 2021
1 parent 844853a commit e174ac5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 42 deletions.
25 changes: 17 additions & 8 deletions engine/source/game/gameConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,12 +887,17 @@ void GameConnection::ghostPreRead(NetObject* nobj, bool newGhost)
{
if ((nobj->getType() & GameBaseHiFiObjectType) != 0 && !newGhost)
{
GameBase* obj = (GameBase*)nobj;
AssertFatal(dynamic_cast<GameBase*>(nobj),"Should be a gamebase");
GameBase* obj = static_cast<GameBase*>(nobj);

// set next cache entry to start
obj->beginTickCacheList();
TickCacheEntry* entry = obj->incTickCacheList(false);
if (entry)

// reset to old state because we are about to unpack (and then tick forward)
TickCacheEntry* tce = obj->incTickCacheList(false);
if (tce)
{
BitStream bs(entry->packetData, TickCacheEntry::MaxPacketSize);
BitStream bs(tce->packetData, TickCacheEntry::MaxPacketSize);
obj->readPacketData(this, &bs);
}
}
Expand All @@ -902,15 +907,19 @@ void GameConnection::ghostReadExtra(NetObject* nobj, BitStream* bstream, bool ne
{
if ((nobj->getType() & GameBaseHiFiObjectType) != 0)
{
GameBase* obj = (GameBase*)nobj;
AssertFatal(dynamic_cast<GameBase*>(nobj),"Should be a gamebase");
GameBase* obj = static_cast<GameBase*>(nobj);

// mark ghost so that it updates correctly
obj->setGhostUpdated(true);
obj->setNewGhost(newGhost);
obj->beginTickCacheList();

TickCacheEntry* entry = obj->incTickCacheList(true);
// set next cache entry to start
obj->beginTickCacheList();

BitStream bs(entry->packetData, TickCacheEntry::MaxPacketSize);
// save state for future update
TickCacheEntry* tce = obj->incTickCacheList(true);
BitStream bs(tce->packetData, TickCacheEntry::MaxPacketSize);
obj->writePacketData(this, &bs);
}
}
Expand Down
44 changes: 10 additions & 34 deletions engine/source/sim/processList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,49 +283,25 @@ bool ProcessList::advanceClientTime(SimTime timeDelta)
if (!tickCount || mLastTick == targetTick)
{
LABEL_19:
if (mSkipAdvanceObjectsMs)
{
mSkipAdvanceObjectsMs -= timeDelta;
} else
if (!mSkipAdvanceObjectsMs)
{
ProcessObject* next = mHead.mProcessLink.next;
ProcessObject* pNext = next;
mLastDelta = (float)(-(targetTime + 1) & 0x1F) * 0.03125f;
AssertFatal(mLastDelta >= 0.0f && mLastDelta <= 1.0f, "Doh! That would be bad.");
if (next != &mHead)
for ( ProcessObject *pobj = mHead.mProcessLink.next; pobj != &mHead; pobj = pobj->mProcessLink.next )
{
while(true)
{
GameBase* gb = getGameBase(next);
if (gb->mProcessTick)
{
gb->interpolateTick(mLastDelta);
next = pNext;
}

pNext = next->mProcessLink.next;
if (pNext == &mHead)
break;
next = next->mProcessLink.next;
}
GameBase* gb = getGameBase(pobj);
if ( gb->mProcessTick)
gb->interpolateTick( mLastDelta );
}

F32 dt = F32(timeDelta) / 1000;
ProcessObject* next2 = mHead.mProcessLink.next;
ProcessObject* pNext2 = next2;
if (next2 != &mHead)
for ( ProcessObject *pobj = mHead.mProcessLink.next; pobj != &mHead; pobj = pobj->mProcessLink.next)
{
while (true)
{
GameBase* gb = getGameBase(next2);
gb->advanceTime(dt);

pNext2 = pNext2->mProcessLink.next;
if (pNext2 == &mHead)
break;
next2 = pNext2;
}
GameBase* gb = getGameBase(pobj);
gb->advanceTime( dt );
}
} else {
mSkipAdvanceObjectsMs -= timeDelta;
}

mLastTime = targetTime;
Expand Down

0 comments on commit e174ac5

Please sign in to comment.