Browse Source

Replace NetLinkingMgr LIST with std::list.

Darryl Pogue 13 years ago
parent
commit
364ac73050
  1. 58
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

58
Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

@ -44,6 +44,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plNetCliAgeJoiner.h" #include "plNetCliAgeJoiner.h"
#include "plNetCliAgeLeaver.h" #include "plNetCliAgeLeaver.h"
#include <list>
#include "plNetTransport/plNetTransportMember.h" // OfferLinkToPlayer() #include "plNetTransport/plNetTransportMember.h" // OfferLinkToPlayer()
#include "plgDispatch.h" #include "plgDispatch.h"
@ -70,8 +72,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
* *
***/ ***/
struct NlmOpNode;
enum ENlmOp { enum ENlmOp {
kNlmOpNoOp, kNlmOpNoOp,
kNlmOpWaitOp, kNlmOpWaitOp,
@ -82,7 +82,6 @@ enum ENlmOp {
struct NlmOp { struct NlmOp {
ENlmOp opcode; ENlmOp opcode;
NlmOpNode * node;
NlmOp (const ENlmOp & op) NlmOp (const ENlmOp & op)
: opcode(op) : opcode(op)
{ } { }
@ -114,12 +113,6 @@ struct NlmLeaveAgeOp : NlmOp {
{ } { }
}; };
struct NlmOpNode {
LINK(NlmOpNode) link;
NlmOp * op;
~NlmOpNode () { delete op; }
};
/***************************************************************************** /*****************************************************************************
* *
@ -129,7 +122,7 @@ struct NlmOpNode {
static plNCAgeJoiner * s_ageJoiner; static plNCAgeJoiner * s_ageJoiner;
static plNCAgeLeaver * s_ageLeaver; static plNCAgeLeaver * s_ageLeaver;
static LISTDECL(NlmOpNode, link) s_oplist; static std::list<NlmOp*> s_opqueue;
/***************************************************************************** /*****************************************************************************
@ -140,10 +133,11 @@ static LISTDECL(NlmOpNode, link) s_oplist;
//============================================================================ //============================================================================
static void QueueOp (NlmOp * op, bool front = false) { static void QueueOp (NlmOp * op, bool front = false) {
NlmOpNode * node = NEWZERO(NlmOpNode); if (front) {
node->op = op; s_opqueue.push_front(op);
op->node = node; } else {
s_oplist.Link(node, front ? kListHead : kListTail); s_opqueue.push_back(op);
}
} }
@ -186,8 +180,10 @@ void plNetLinkingMgr::NCAgeJoinerCallback (
lm->SetEnabled(true); lm->SetEnabled(true);
// Pull our wait op off exec queue // Pull our wait op off exec queue
if (NlmOpWaitOp * waitOp = (NlmOpWaitOp *) userState) if (NlmOpWaitOp * waitOp = (NlmOpWaitOp *) userState) {
delete waitOp->node; s_opqueue.remove(waitOp);
delete waitOp;
}
} }
break; break;
@ -208,8 +204,10 @@ void plNetLinkingMgr::NCAgeLeaverCallback (
s_ageLeaver = nil; s_ageLeaver = nil;
// Pull our wait op off exec queue // Pull our wait op off exec queue
if (NlmOpWaitOp * waitOp = (NlmOpWaitOp *) userState) if (NlmOpWaitOp * waitOp = (NlmOpWaitOp *) userState) {
delete waitOp->node; s_opqueue.remove(waitOp);
delete waitOp;
}
} }
break; break;
@ -221,18 +219,17 @@ void plNetLinkingMgr::NCAgeLeaverCallback (
void plNetLinkingMgr::ExecNextOp () { void plNetLinkingMgr::ExecNextOp () {
plNetLinkingMgr * lm = plNetLinkingMgr::GetInstance(); plNetLinkingMgr * lm = plNetLinkingMgr::GetInstance();
NlmOpNode * opNode = s_oplist.Head(); if (!s_opqueue.size())
if (!opNode)
return; return;
switch (opNode->op->opcode) { NlmOp* op = s_opqueue.front();
case kNlmOpNoOp: {
}
break;
case kNlmOpWaitOp: { switch (op->opcode) {
} case kNlmOpNoOp:
return; // don't allow wait op to be unlinked/deleted from list break;
case kNlmOpWaitOp:
return; // don't allow wait op to be unlinked/deleted from list
case kNlmOpJoinAgeOp: { case kNlmOpJoinAgeOp: {
ASSERT(!s_ageJoiner); ASSERT(!s_ageJoiner);
@ -242,7 +239,7 @@ void plNetLinkingMgr::ExecNextOp () {
NlmOpWaitOp * waitOp = NEWZERO(NlmOpWaitOp); NlmOpWaitOp * waitOp = NEWZERO(NlmOpWaitOp);
QueueOp(waitOp, true); QueueOp(waitOp, true);
NlmJoinAgeOp * joinAgeOp = (NlmJoinAgeOp *) opNode->op; NlmJoinAgeOp * joinAgeOp = (NlmJoinAgeOp *)op;
NCAgeJoinerCreate( NCAgeJoinerCreate(
&s_ageJoiner, &s_ageJoiner,
joinAgeOp->age, joinAgeOp->age,
@ -263,7 +260,7 @@ void plNetLinkingMgr::ExecNextOp () {
lm->SetEnabled(false); lm->SetEnabled(false);
lm->fLinkedIn = false; lm->fLinkedIn = false;
NlmLeaveAgeOp * leaveAgeOp = (NlmLeaveAgeOp *) opNode->op; NlmLeaveAgeOp * leaveAgeOp = (NlmLeaveAgeOp *)op;
NCAgeLeaverCreate( NCAgeLeaverCreate(
&s_ageLeaver, &s_ageLeaver,
leaveAgeOp->quitting, leaveAgeOp->quitting,
@ -274,7 +271,8 @@ void plNetLinkingMgr::ExecNextOp () {
break; break;
} }
delete opNode; s_opqueue.pop_front();
delete op;
} }

Loading…
Cancel
Save