Skip to content

Commit

Permalink
Map|Client: Removed fixed limit CLIENT_MAX_MOVERS (was 1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jan 10, 2014
1 parent 1d011e2 commit 638cd84
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 207 deletions.
4 changes: 2 additions & 2 deletions doomsday/client/include/client/cl_world.h
Expand Up @@ -23,12 +23,12 @@
/**
* Clears the arrays that track active plane and polyobj mover thinkers.
*/
void Cl_WorldInit();
void Cl_InitTransTables();

/**
* Removes all the active movers.
*/
void Cl_WorldReset();
void Cl_ResetTransTables();

/**
* Handles the PSV_MATERIAL_ARCHIVE packet sent by the server. The list of
Expand Down
1 change: 0 additions & 1 deletion doomsday/client/include/client/clpolymover.h
Expand Up @@ -31,7 +31,6 @@
struct ClPolyMover
{
thinker_t thinker;
int number;
Polyobj *polyobj;
bool move;
bool rotate;
Expand Down
18 changes: 3 additions & 15 deletions doomsday/client/include/world/map.h
Expand Up @@ -68,8 +68,6 @@ typedef struct cmhash_s {
struct clmoinfo_s *first, *last;
} cmhash_t;

#define CLIENT_MAX_MOVERS 1024 // Definitely enough!

#endif // __CLIENT__

class LineBlockmap;
Expand Down Expand Up @@ -671,8 +669,6 @@ class Map
*/
int clMobjIterator(int (*callback) (struct mobj_s *, void *), void *context);

void initClMovers();

void resetClMovers();

/**
Expand All @@ -684,24 +680,16 @@ class Map

void deleteClPlane(ClPlaneMover *mover);

int clPlaneIndex(ClPlaneMover *mover);

ClPlaneMover *clPlaneFor(Plane &plane);

bool isValidClPlane(int i);

/**
* @note Assumes there is no existing ClPolyobj for Polyobj @a index.
* @note Assumes there is no existing ClPolyobj for @a polyobj.
*/
ClPolyMover *newClPolyobj(int polyobjIndex);
ClPolyMover *newClPolyobj(Polyobj &polyobj);

void deleteClPolyobj(ClPolyMover *mover);

int clPolyobjIndex(ClPolyMover *mover);

ClPolyMover *clPolyobjByPolyobjIndex(int index);

bool isValidClPolyobj(int i);
ClPolyMover *clPolyobjFor(Polyobj &polyobj);

/**
* Link the given @a surface in all material lists and surface sets which
Expand Down
10 changes: 8 additions & 2 deletions doomsday/client/src/client/cl_main.cpp
Expand Up @@ -97,7 +97,13 @@ void Cl_CleanUp()
}

Cl_InitPlayers();
Cl_WorldReset();
Cl_ResetTransTables();

if(App_World().hasMap())
{
App_World().map().resetClMovers();
}

GL_SetFilter(false);
}

Expand Down Expand Up @@ -190,7 +196,7 @@ void Cl_AnswerHandshake()

// Prepare the client-side data.
Cl_InitPlayers();
Cl_WorldInit();
Cl_InitTransTables();

// Get ready for ticking.
DD_ResetTimer();
Expand Down
58 changes: 24 additions & 34 deletions doomsday/client/src/client/cl_world.cpp
Expand Up @@ -49,6 +49,25 @@ typedef QVector<int> IndexTransTable;
static IndexTransTable xlatMobjType;
static IndexTransTable xlatMobjState;

void Cl_InitTransTables()
{
serverMaterials = 0;
zap(xlatMobjType);
zap(xlatMobjState);
}

void Cl_ResetTransTables()
{
if(serverMaterials)
{
MaterialArchive_Delete(serverMaterials);
serverMaterials = 0;
}

xlatMobjType.clear();
xlatMobjState.clear();
}

void Cl_ReadServerMaterials()
{
LOG_AS("Cl_ReadServerMaterials");
Expand Down Expand Up @@ -137,35 +156,6 @@ int Cl_LocalMobjState(int serverMobjState)
return xlatMobjState[serverMobjState];
}

void Cl_WorldInit()
{
if(App_World().hasMap())
{
App_World().map().initClMovers();
}

serverMaterials = 0;
zap(xlatMobjType);
zap(xlatMobjState);
}

void Cl_WorldReset()
{
if(serverMaterials)
{
MaterialArchive_Delete(serverMaterials);
serverMaterials = 0;
}

xlatMobjType.clear();
xlatMobjState.clear();

if(App_World().hasMap())
{
App_World().map().resetClMovers();
}
}

void Cl_ReadSectorDelta(int /*deltaType*/)
{
/// @todo Do not assume the CURRENT map.
Expand Down Expand Up @@ -365,14 +355,14 @@ void Cl_ReadSideDelta(int /*deltaType*/)
}

/**
* Find the ClPolyMover associated with @a polyobjIndex; otherwise create it.
* Find the ClPolyMover for @a polyobj; otherwise create it.
*/
static ClPolyMover *getClPolyMover(uint polyobjIndex)
static ClPolyMover *getClPolyMover(Polyobj &polyobj)
{
ClPolyMover *mover = App_World().map().clPolyobjByPolyobjIndex(polyobjIndex);
ClPolyMover *mover = App_World().map().clPolyobjFor(polyobj);
if(mover) return mover;
// Not found; make a new one.
return App_World().map().newClPolyobj(polyobjIndex);
return App_World().map().newClPolyobj(polyobj);
}

void Cl_ReadPolyDelta()
Expand Down Expand Up @@ -417,7 +407,7 @@ void Cl_ReadPolyDelta()
}

// Update/create the polymover thinker.
if(ClPolyMover *mover = getClPolyMover(index))
if(ClPolyMover *mover = getClPolyMover(*po))
{
mover->move = CPP_BOOL(df & (PODF_DEST_X | PODF_DEST_Y | PODF_SPEED));
mover->rotate = CPP_BOOL(df & (PODF_DEST_ANGLE | PODF_ANGSPEED | PODF_PERPETUAL_ROTATE));
Expand Down
7 changes: 0 additions & 7 deletions doomsday/client/src/client/clplanemover.cpp
Expand Up @@ -39,13 +39,6 @@ void ClPlaneMover_Thinker(ClPlaneMover *mover)
DENG2_ASSERT(mover->plane != 0);
Plane *plane = mover->plane;

#ifdef DENG_DEBUG
if(plane->map().clPlaneIndex(mover) < 0)
{
LOG_MAP_WARNING("Running a mover that is not in activemovers!");
}
#endif

// The move is cancelled if the consolePlayer becomes obstructed.
bool const freeMove = ClPlayer_IsFreeToMove(consolePlayer);
float const fspeed = mover->speed;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/client/clpolymover.cpp
Expand Up @@ -68,8 +68,8 @@ void ClPolyMover_Thinker(ClPolyMover *mover)
// /* && po->destAngle != -1*/) || !po->angleSpeed)
if(!po->angleSpeed || ABS(dist >> 2) <= ABS(speed >> 2))
{
LOG_MAP_XVERBOSE("Mover %i reached end of turn, destAngle=%i")
<< mover->number << po->destAngle;
LOGDEV_MAP_XVERBOSE("Mover %p reached end of turn, destAngle=%i")
<< de::dintptr(mover) << po->destAngle;

This comment has been minimized.

Copy link
@skyjake

skyjake Jan 10, 2014

Owner

Note that you don't need dintptr when making log entries since LogEntry::Arg can be made out of pointers directly.

This comment has been minimized.

Copy link
@danij-deng

danij-deng Jan 10, 2014

Author Collaborator

Thanks for the tip. I'll clean this up...


// We'll arrive at the destination.
mover->rotate = false;
Expand Down
10 changes: 4 additions & 6 deletions doomsday/client/src/network/net_main.cpp
Expand Up @@ -560,10 +560,8 @@ void Net_InitGame(void)
clients[0].lastTransmit = -1;
}

void Net_StopGame(void)
void Net_StopGame()
{
int i;

LOG_AS("Net_StopGame");

#ifdef __SERVER__
Expand Down Expand Up @@ -604,10 +602,10 @@ void Net_StopGame(void)
#endif

// All remote players are forgotten.
for(i = 0; i < DDMAXPLAYERS; ++i)
for(int i = 0; i < DDMAXPLAYERS; ++i)
{
player_t *plr = &ddPlayers[i];
client_t *cl = &clients[i];
player_t *plr = &ddPlayers[i];
client_t *cl = &clients[i];

plr->shared.inGame = false;
cl->ready = cl->connected = false;
Expand Down

0 comments on commit 638cd84

Please sign in to comment.