Skip to content

Commit

Permalink
Thinkers: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jun 14, 2013
1 parent e6eb617 commit 9640412
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
2 changes: 0 additions & 2 deletions doomsday/client/include/world/thinkers.h
Expand Up @@ -95,8 +95,6 @@ class Thinkers
*/
void setMobjId(thid_t id, bool inUse = true);

void clearMobjIds();

private:
DENG2_PRIVATE(d)
};
Expand Down
37 changes: 21 additions & 16 deletions doomsday/client/src/world/thinkers.cpp
Expand Up @@ -25,11 +25,16 @@
#include <de/memoryzone.h>

#include "de_base.h"
#include "de_defs.h"
#include "de_console.h"
#include "de_network.h"
#include "world/p_object.h"

#include "world/map.h"
#ifdef __CLIENT__
# include "client/cl_mobj.h"
#endif

#ifdef __SERVER__
# include "def_main.h"
# include "server/sv_pool.h"
#endif

#include "world/thinkers.h"

Expand All @@ -56,7 +61,7 @@ struct ThinkerList
sentinel.prev = sentinel.next = &sentinel;
}

void reInit()
void reinit()
{
sentinel.prev = sentinel.next = &sentinel;
}
Expand Down Expand Up @@ -113,15 +118,21 @@ DENG2_PIMPL(Thinkers)
iddealer(0),
inited(false)
{
self.clearMobjIds();
clearMobjIds();
}

~Instance()
{
qDeleteAll(lists);
}

thid_t newMobjID()
void clearMobjIds()
{
zap(idtable);
idtable[0] |= 1; // ID zero is always "used" (it's not a valid ID).
}

thid_t newMobjId()
{
// Increment the ID dealer until a free ID is found.
/// @todo fixme: What if all IDs are in use? 65535 thinkers!?
Expand Down Expand Up @@ -154,12 +165,6 @@ DENG2_PIMPL(Thinkers)
Thinkers::Thinkers() : d(new Instance(this))
{}

void Thinkers::clearMobjIds()
{
zap(d->idtable);
d->idtable[0] |= 1; // ID zero is always "used" (it's not a valid ID).
}

bool Thinkers::isUsedMobjId(thid_t id)
{
return d->idtable[id >> 5] & (1 << (id & 31) /*(id % 32) */ );
Expand Down Expand Up @@ -215,7 +220,7 @@ void Thinkers::add(thinker_t &th, bool makePublic)
if(!Cl_IsClientMobj(reinterpret_cast<mobj_t *>(&th)))
#endif
{
th.id = d->newMobjID();
th.id = d->newMobjId();
}
}
else
Expand Down Expand Up @@ -269,11 +274,11 @@ void Thinkers::initLists(byte flags)
if(list->isPublic && !(flags & 0x1)) continue;
if(!list->isPublic && !(flags & 0x2)) continue;

list->reInit();
list->reinit();
}
}

clearMobjIds();
d->clearMobjIds();
d->inited = true;
}

Expand Down

0 comments on commit 9640412

Please sign in to comment.