forked from Mirrors/openclonk
C4ObjectList: Replace trivial cases of manual list traversal with iterator usage
parent
cbf2136c58
commit
03f43f462b
|
@ -353,8 +353,8 @@ C4ControlPlayerSelect::C4ControlPlayerSelect(int32_t iPlr, const C4ObjectList &O
|
|||
{
|
||||
pObjNrs = new int32_t[iObjCnt];
|
||||
int32_t i = 0;
|
||||
for (C4ObjectLink *pLnk = Objs.First; pLnk; pLnk = pLnk->Next)
|
||||
pObjNrs[i++] = pLnk->Obj->Number;
|
||||
for (C4Object *obj : Objs)
|
||||
pObjNrs[i++] = obj->Number;
|
||||
assert(i == iObjCnt);
|
||||
}
|
||||
|
||||
|
@ -767,8 +767,8 @@ int32_t C4ControlSyncCheck::GetAllCrewPosX()
|
|||
{
|
||||
int32_t cpx=0;
|
||||
for (C4Player *pPlr=::Players.First; pPlr; pPlr=pPlr->Next)
|
||||
for (C4ObjectLink *clnk=pPlr->Crew.First; clnk; clnk=clnk->Next)
|
||||
cpx += fixtoi(clnk->Obj->fix_x, 100);
|
||||
for (C4Object *member : pPlr->Crew)
|
||||
cpx += fixtoi(member->fix_x, 100);
|
||||
return cpx;
|
||||
}
|
||||
|
||||
|
|
|
@ -306,12 +306,14 @@ bool C4EditCursor::RightButtonDown(DWORD dwKeyState)
|
|||
{
|
||||
// Check whether cursor is on anything in the selection
|
||||
bool fCursorIsOnSelection = false;
|
||||
for (C4ObjectLink *pLnk = Selection.First; pLnk; pLnk = pLnk->Next)
|
||||
if (pLnk->Obj->At(X,Y))
|
||||
for (C4Object *obj : Selection)
|
||||
{
|
||||
if (obj->At(X,Y))
|
||||
{
|
||||
fCursorIsOnSelection = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!fCursorIsOnSelection)
|
||||
{
|
||||
// Click on unselected
|
||||
|
@ -478,8 +480,7 @@ void C4EditCursor::Draw(C4TargetFacet &cgo)
|
|||
{
|
||||
ZoomDataStackItem zdsi(cgo.X, cgo.Y, cgo.Zoom);
|
||||
// Draw selection marks
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
for (clnk=Selection.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *cobj : Selection)
|
||||
{
|
||||
// target pos (parallax)
|
||||
float offX, offY, newzoom;
|
||||
|
@ -577,13 +578,14 @@ void C4EditCursor::MoveSelection(C4Real XOff, C4Real YOff)
|
|||
void C4EditCursor::FrameSelection()
|
||||
{
|
||||
ClearSelection();
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
for (clnk=::Objects.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
if (cobj->Status) if (cobj->OCF & OCF_NotContained)
|
||||
{
|
||||
if (Inside(cobj->GetX(),Min(X,X2),Max(X,X2)) && Inside(cobj->GetY(),Min(Y,Y2),Max(Y,Y2)))
|
||||
AddToSelection(cobj);
|
||||
}
|
||||
for (C4Object *cobj : Objects)
|
||||
{
|
||||
if (cobj->Status && cobj->OCF & OCF_NotContained)
|
||||
{
|
||||
if (Inside(cobj->GetX(),Min(X,X2),Max(X,X2)) && Inside(cobj->GetY(),Min(Y,Y2),Max(Y,Y2)))
|
||||
AddToSelection(cobj);
|
||||
}
|
||||
}
|
||||
OnSelectionChanged();
|
||||
}
|
||||
|
||||
|
@ -829,19 +831,20 @@ void C4EditCursor::GrabContents()
|
|||
|
||||
void C4EditCursor::UpdateDropTarget(DWORD dwKeyState)
|
||||
{
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
|
||||
DropTarget=NULL;
|
||||
|
||||
if (dwKeyState & MK_CONTROL)
|
||||
if (Selection.GetObject())
|
||||
for (clnk=::Objects.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *cobj : Objects)
|
||||
{
|
||||
if (cobj->Status)
|
||||
if (!cobj->Contained)
|
||||
if (Inside<int32_t>(X-(cobj->GetX()+cobj->Shape.x),0,cobj->Shape.Wdt-1))
|
||||
if (Inside<int32_t>(Y-(cobj->GetY()+cobj->Shape.y),0,cobj->Shape.Hgt-1))
|
||||
if (!Selection.GetLink(cobj))
|
||||
{ DropTarget=cobj; break; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -927,9 +930,11 @@ void C4EditCursor::EMMoveObject(C4ControlEMObjectAction eAction, C4Real tx, C4Re
|
|||
pObjIDs = new int32_t [iObjCnt];
|
||||
// fill
|
||||
int32_t i = 0;
|
||||
for (C4ObjectLink *pLnk = pObjs->First; pLnk; pLnk = pLnk->Next, i++)
|
||||
if (pLnk->Obj && pLnk->Obj->Status)
|
||||
pObjIDs[i] = pLnk->Obj->Number;
|
||||
for (C4Object *obj : *pObjs)
|
||||
{
|
||||
if (obj && obj->Status)
|
||||
pObjIDs[i] = obj->Number;
|
||||
}
|
||||
}
|
||||
|
||||
// execute control
|
||||
|
|
|
@ -896,12 +896,15 @@ void C4Game::ClearObjectPtrs(C4Object *pObj)
|
|||
// May not call Objects.ClearPointers() because that would
|
||||
// remove pObj from primary list and pObj is to be kept
|
||||
// until CheckObjectRemoval().
|
||||
C4Object *cObj; C4ObjectLink *clnk;
|
||||
for (clnk=Objects.First; clnk && (cObj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *cObj : Objects)
|
||||
{
|
||||
cObj->ClearPointers(pObj);
|
||||
}
|
||||
// check in inactive objects as well
|
||||
for (clnk=Objects.InactiveObjects.First; clnk && (cObj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *cObj : Objects)
|
||||
{
|
||||
cObj->ClearPointers(pObj);
|
||||
}
|
||||
}
|
||||
|
||||
void C4Game::ClearPointers(C4Object * pObj)
|
||||
|
@ -1122,12 +1125,11 @@ C4Object* C4Game::CreateObjectConstruction(C4PropList * PropList,
|
|||
|
||||
C4Object* C4Game::OverlapObject(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t Plane)
|
||||
{
|
||||
C4Object *cObj; C4ObjectLink *clnk;
|
||||
C4Rect rect1,rect2;
|
||||
rect1.x=tx; rect1.y=ty; rect1.Wdt=wdt; rect1.Hgt=hgt;
|
||||
C4LArea Area(&::Objects.Sectors, tx, ty, wdt, hgt); C4LSector *pSector;
|
||||
for (C4ObjectList *pObjs = Area.FirstObjectShapes(&pSector); pSector; pObjs = Area.NextObjectShapes(pObjs, &pSector))
|
||||
for (clnk=pObjs->First; clnk && (cObj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *cObj : *pObjs)
|
||||
if (cObj->Status && !cObj->Contained)
|
||||
if (cObj->GetPlane() == Plane)
|
||||
{
|
||||
|
@ -1145,8 +1147,6 @@ C4Object* C4Game::FindObject(C4Def * pDef,
|
|||
|
||||
C4Object *pClosest=NULL;
|
||||
int32_t iClosest = 0,iDistance,iFartherThan=-1;
|
||||
C4Object *cObj;
|
||||
C4ObjectLink *cLnk;
|
||||
C4Object *pFindNextCpy=pFindNext;
|
||||
|
||||
// check the easy case first: no instances at all?
|
||||
|
@ -1160,7 +1160,7 @@ C4Object* C4Game::FindObject(C4Def * pDef,
|
|||
}
|
||||
|
||||
// Scan all objects
|
||||
for (cLnk=Objects.First; cLnk && (cObj=cLnk->Obj); cLnk=cLnk->Next)
|
||||
for (C4Object *cObj : Objects)
|
||||
{
|
||||
// Not skipping to find next
|
||||
if (!pFindNext)
|
||||
|
@ -1220,8 +1220,7 @@ C4Object *C4Game::FindVisObject(float tx, float ty, int32_t iPlr, const C4Facet
|
|||
while (pLst)
|
||||
{
|
||||
// Scan all objects in list
|
||||
C4ObjectLink *cLnk; C4Object *cObj;
|
||||
for (cLnk=pLst->First; cLnk && (cObj=cLnk->Obj); cLnk=cLnk->Next)
|
||||
for (C4Object *cObj : *pLst)
|
||||
{
|
||||
// Status
|
||||
if (cObj->Status == C4OS_NORMAL)
|
||||
|
@ -1280,10 +1279,8 @@ int32_t C4Game::ObjectCount(C4ID id)
|
|||
if (!(pDef=C4Id2Def(id))) return 0; // no valid def
|
||||
return pDef->Count;
|
||||
}
|
||||
C4Object *cObj;
|
||||
C4ObjectLink *clnk;
|
||||
int32_t iResult = 0;
|
||||
for (clnk=Objects.First; clnk && (cObj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *cObj : Objects)
|
||||
// Status
|
||||
if (cObj->Status)
|
||||
++iResult;
|
||||
|
@ -1295,10 +1292,8 @@ int32_t C4Game::ObjectCount(C4ID id)
|
|||
|
||||
void C4Game::ObjectRemovalCheck() // Every ::Game.iTick255 by ExecObjects
|
||||
{
|
||||
C4Object *cObj; C4ObjectLink *clnk,*next;
|
||||
for (clnk=Objects.First; clnk && (cObj=clnk->Obj); clnk=next)
|
||||
for (C4Object *cObj : Objects)
|
||||
{
|
||||
next=clnk->Next;
|
||||
if (!cObj->Status && (cObj->RemovalDelay==0))
|
||||
{
|
||||
Objects.Remove(cObj);
|
||||
|
@ -1313,14 +1308,18 @@ void C4Game::ExecObjects() // Every Tick1 by Execute
|
|||
AddDbgRec(RCT_Block, "ObjEx", 6);
|
||||
|
||||
// Execute objects - reverse order to ensure
|
||||
C4Object *cObj; C4ObjectLink *clnk;
|
||||
for (clnk=Objects.Last; clnk && (cObj=clnk->Obj); clnk=clnk->Prev)
|
||||
if (cObj->Status)
|
||||
// Execute object
|
||||
cObj->Execute();
|
||||
else
|
||||
// Status reset: process removal delay
|
||||
if (cObj->RemovalDelay>0) cObj->RemovalDelay--;
|
||||
for (C4Object *cObj : Objects.reverse())
|
||||
{
|
||||
if (cObj)
|
||||
{
|
||||
if (cObj->Status)
|
||||
// Execute object
|
||||
cObj->Execute();
|
||||
else
|
||||
// Status reset: process removal delay
|
||||
if (cObj->RemovalDelay>0) cObj->RemovalDelay--;
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.General.DebugRec)
|
||||
AddDbgRec(RCT_Block, "ObjCC", 6);
|
||||
|
@ -1953,7 +1952,6 @@ bool C4Game::ReloadDef(C4ID id)
|
|||
// SolidMasks might be updated
|
||||
C4SolidMask::RemoveSolidMasks();
|
||||
// reload def
|
||||
C4ObjectLink *clnk;
|
||||
C4Def *pDef = ::Definitions.ID2Def(id);
|
||||
if (!pDef) return false;
|
||||
// Message
|
||||
|
@ -1964,19 +1962,19 @@ bool C4Game::ReloadDef(C4ID id)
|
|||
// Success, update all concerned object faces
|
||||
// may have been done by graphics-update already - but not for objects using graphics of another def
|
||||
// better update everything :)
|
||||
for (clnk=Objects.First; clnk && clnk->Obj; clnk=clnk->Next)
|
||||
for (C4Object *obj : Objects)
|
||||
{
|
||||
if (clnk->Obj->id == id)
|
||||
clnk->Obj->UpdateFace(true);
|
||||
if (obj->id == id)
|
||||
obj->UpdateFace(true);
|
||||
}
|
||||
fSucc = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Failure, remove all objects of this type
|
||||
for (clnk=Objects.First; clnk && clnk->Obj; clnk=clnk->Next)
|
||||
if (clnk->Obj->id == id)
|
||||
clnk->Obj->AssignRemoval();
|
||||
for (C4Object *obj : Objects)
|
||||
if (obj->id == id)
|
||||
obj->AssignRemoval();
|
||||
// safety: If a removed def is being profiled, profiling must stop
|
||||
C4AulProfiler::Abort();
|
||||
// Kill def
|
||||
|
@ -3346,13 +3344,13 @@ bool C4Game::LoadScenarioSection(const char *szSection, DWORD dwFlags)
|
|||
}
|
||||
// remove all objects (except inactive)
|
||||
// do correct removal calls, because this will stop fire sounds, etc.
|
||||
C4ObjectLink *clnk;
|
||||
for (clnk=Objects.First; clnk; clnk=clnk->Next) clnk->Obj->AssignRemoval();
|
||||
for (clnk=Objects.First; clnk; clnk=clnk->Next)
|
||||
if (clnk->Obj->Status)
|
||||
for (C4Object *obj : Objects)
|
||||
obj->AssignRemoval();
|
||||
for (C4Object *obj : Objects)
|
||||
if (obj->Status)
|
||||
{
|
||||
DebugLogF("LoadScenarioSection: WARNING: Object %d created in destruction process!", (int) clnk->Obj->Number);
|
||||
ClearPointers(clnk->Obj);
|
||||
DebugLogF("LoadScenarioSection: WARNING: Object %d created in destruction process!", (int) obj->Number);
|
||||
ClearPointers(obj);
|
||||
//clnk->Obj->AssignRemoval(); - this could create additional objects in endless recursion...
|
||||
}
|
||||
DeleteObjects(false);
|
||||
|
|
|
@ -226,10 +226,9 @@ int32_t C4FindObject::Count(const C4ObjectList &Objs)
|
|||
return Objs.ObjectCount();
|
||||
// Count
|
||||
int32_t iCount = 0;
|
||||
for (C4ObjectLink *pLnk = Objs.First; pLnk; pLnk = pLnk->Next)
|
||||
if (pLnk->Obj->Status)
|
||||
if (Check(pLnk->Obj))
|
||||
iCount++;
|
||||
for (C4Object *obj : Objs)
|
||||
if (obj->Status && Check(obj))
|
||||
iCount++;
|
||||
return iCount;
|
||||
}
|
||||
|
||||
|
@ -241,17 +240,17 @@ C4Object *C4FindObject::Find(const C4ObjectList &Objs)
|
|||
// Search
|
||||
// Double-check object status, as object might be deleted after Check()!
|
||||
C4Object *pBestResult = NULL;
|
||||
for (C4ObjectLink *pLnk = Objs.First; pLnk; pLnk = pLnk->Next)
|
||||
if (pLnk->Obj->Status)
|
||||
if (Check(pLnk->Obj))
|
||||
if (pLnk->Obj->Status)
|
||||
for (C4Object *obj : Objs)
|
||||
if (obj->Status)
|
||||
if (Check(obj))
|
||||
if (obj->Status)
|
||||
{
|
||||
// no sorting: Use first object found
|
||||
if (!pSort) return pLnk->Obj;
|
||||
if (!pSort) return obj;
|
||||
// Sorting: Check if found object is better
|
||||
if (!pBestResult || pSort->Compare(pLnk->Obj, pBestResult) > 0)
|
||||
if (pLnk->Obj->Status)
|
||||
pBestResult = pLnk->Obj;
|
||||
if (!pBestResult || pSort->Compare(obj, pBestResult) > 0)
|
||||
if (obj->Status)
|
||||
pBestResult = obj;
|
||||
}
|
||||
return pBestResult;
|
||||
}
|
||||
|
@ -266,15 +265,15 @@ C4ValueArray *C4FindObject::FindMany(const C4ObjectList &Objs)
|
|||
C4ValueArray *pArray = new C4ValueArray(32);
|
||||
int32_t iSize = 0;
|
||||
// Search
|
||||
for (C4ObjectLink *pLnk = Objs.First; pLnk; pLnk = pLnk->Next)
|
||||
if (pLnk->Obj->Status)
|
||||
if (Check(pLnk->Obj))
|
||||
for (C4Object *obj : Objs)
|
||||
if (obj->Status)
|
||||
if (Check(obj))
|
||||
{
|
||||
// Grow the array, if neccessary
|
||||
if (iSize >= pArray->GetSize())
|
||||
pArray->SetSize(iSize * 2);
|
||||
// Add object
|
||||
(*pArray)[iSize++] = C4VObj(pLnk->Obj);
|
||||
(*pArray)[iSize++] = C4VObj(obj);
|
||||
}
|
||||
// Shrink array
|
||||
pArray->SetSize(iSize);
|
||||
|
@ -308,12 +307,12 @@ int32_t C4FindObject::Count(const C4ObjectList &Objs, const C4LSectors &Sct)
|
|||
uint32_t iMarker = ::Objects.GetNextMarker();
|
||||
int32_t iCount = 0;
|
||||
for (; pLst; pLst=Area.NextObjectShapes(pLst, &pSct))
|
||||
for (C4ObjectLink *pLnk = pLst->First; pLnk; pLnk = pLnk->Next)
|
||||
if (pLnk->Obj->Status)
|
||||
if (pLnk->Obj->Marker != iMarker)
|
||||
for (C4Object *obj : Objs)
|
||||
if (obj->Status)
|
||||
if (obj->Marker != iMarker)
|
||||
{
|
||||
pLnk->Obj->Marker = iMarker;
|
||||
if (Check(pLnk->Obj))
|
||||
obj->Marker = iMarker;
|
||||
if (Check(obj))
|
||||
iCount++;
|
||||
}
|
||||
return iCount;
|
||||
|
@ -398,18 +397,18 @@ C4ValueArray *C4FindObject::FindMany(const C4ObjectList &Objs, const C4LSectors
|
|||
// Create marker, search all areas
|
||||
uint32_t iMarker = ::Objects.GetNextMarker();
|
||||
for (; pLst; pLst=Area.NextObjectShapes(pLst, &pSct))
|
||||
for (C4ObjectLink *pLnk = pLst->First; pLnk; pLnk = pLnk->Next)
|
||||
if (pLnk->Obj->Status)
|
||||
if (pLnk->Obj->Marker != iMarker)
|
||||
for (C4Object *obj : *pLst)
|
||||
if (obj->Status)
|
||||
if (obj->Marker != iMarker)
|
||||
{
|
||||
pLnk->Obj->Marker = iMarker;
|
||||
if (Check(pLnk->Obj))
|
||||
obj->Marker = iMarker;
|
||||
if (Check(obj))
|
||||
{
|
||||
// Grow the array, if neccessary
|
||||
if (iSize >= pArray->GetSize())
|
||||
pArray->SetSize(iSize * 2);
|
||||
// Add object
|
||||
(*pArray)[iSize++] = C4VObj(pLnk->Obj);
|
||||
(*pArray)[iSize++] = C4VObj(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -420,15 +419,15 @@ C4ValueArray *C4FindObject::FindMany(const C4ObjectList &Objs, const C4LSectors
|
|||
// Search
|
||||
C4LArea Area(&::Objects.Sectors, *pBounds); C4LSector *pSct;
|
||||
for (C4ObjectList *pLst=Area.FirstObjects(&pSct); pLst; pLst=Area.NextObjects(pLst, &pSct))
|
||||
for (C4ObjectLink *pLnk = pLst->First; pLnk; pLnk = pLnk->Next)
|
||||
if (pLnk->Obj->Status)
|
||||
if (Check(pLnk->Obj))
|
||||
for (C4Object *obj : *pLst)
|
||||
if (obj->Status)
|
||||
if (Check(obj))
|
||||
{
|
||||
// Grow the array, if neccessary
|
||||
if (iSize >= pArray->GetSize())
|
||||
pArray->SetSize(iSize * 2);
|
||||
// Add object
|
||||
(*pArray)[iSize++] = C4VObj(pLnk->Obj);
|
||||
(*pArray)[iSize++] = C4VObj(obj);
|
||||
}
|
||||
}
|
||||
// Shrink array
|
||||
|
|
|
@ -287,10 +287,10 @@ void C4SolidMask::Remove(bool fBackupAttachment)
|
|||
MaskRemovalY = pForObject->GetFixedY();
|
||||
iAttachingObjectsCount = 0;
|
||||
C4LArea SolidArea(&::Objects.Sectors, MaskPutRect.x-1, MaskPutRect.y-1, MaskPutRect.Wdt+2, MaskPutRect.Hgt+2);
|
||||
C4LSector *pSct; C4Object *pObj;
|
||||
C4LSector *pSct;
|
||||
for (C4ObjectList *pLst=SolidArea.FirstObjectShapes(&pSct); pLst; pLst=SolidArea.NextObjectShapes(pLst, &pSct))
|
||||
for (C4ObjectLink *clnk=pLst->First; clnk; clnk=clnk->Next)
|
||||
if ((pObj = clnk->Obj) && pObj != pForObject && pObj->IsMoveableBySolidMask(pForObject->GetSolidMaskPlane()) && !pObj->Shape.CheckContact(pObj->GetX(),pObj->GetY()))
|
||||
for (C4Object *pObj : *pLst)
|
||||
if (pObj && pObj != pForObject && pObj->IsMoveableBySolidMask(pForObject->GetSolidMaskPlane()) && !pObj->Shape.CheckContact(pObj->GetX(),pObj->GetY()))
|
||||
{
|
||||
// check for any contact to own SolidMask - attach-directions, bottom - "stuck" (CNAT_Center) is ignored, because that causes problems with things being stuck in basements :(
|
||||
int iVtx = 0;
|
||||
|
|
|
@ -1123,9 +1123,8 @@ void C4Command::Activate()
|
|||
{
|
||||
// If not specified get object from target contents by type
|
||||
// Find first object requested id that has no command exit yet
|
||||
C4Object *pObj; C4ObjectLink *cLnk;
|
||||
if (!Target)
|
||||
for (cLnk=Target2->Contents.First; cLnk && (pObj=cLnk->Obj); cLnk=cLnk->Next)
|
||||
for (C4Object *pObj : Target2->Contents)
|
||||
if (pObj->Status && (pObj->Def==Data.getDef()))
|
||||
if (!pObj->Command || (pObj->Command->Command!=C4CMD_Exit))
|
||||
{ Target=pObj; break; }
|
||||
|
@ -1584,9 +1583,8 @@ void C4Command::Attack()
|
|||
if (Target->OCF & OCF_CrewMember)
|
||||
{
|
||||
|
||||
C4Object *pProjectile=NULL;
|
||||
// Throw projectile at target
|
||||
for (C4ObjectLink *pLnk=cObj->Contents.First; pLnk && (pProjectile=pLnk->Obj); pLnk=pLnk->Next)
|
||||
for (C4Object *pProjectile : cObj->Contents)
|
||||
if (pProjectile->Def->Projectile)
|
||||
{
|
||||
// Add throw command
|
||||
|
|
|
@ -452,9 +452,9 @@ void C4DefGraphicsPtrBackup::AssignUpdate(C4DefGraphics *pNewGraphics)
|
|||
if (pGraphicsPtr)
|
||||
{
|
||||
// check all objects
|
||||
C4Object *pObj;
|
||||
for (C4ObjectLink *pLnk = ::Objects.First; pLnk; pLnk=pLnk->Next)
|
||||
if ((pObj=pLnk->Obj)) if (pObj->Status)
|
||||
for (C4Object *pObj : Objects)
|
||||
{
|
||||
if (pObj && pObj->Status)
|
||||
{
|
||||
if (pObj->pGraphics == pGraphicsPtr)
|
||||
{
|
||||
|
@ -500,6 +500,7 @@ void C4DefGraphicsPtrBackup::AssignUpdate(C4DefGraphics *pNewGraphics)
|
|||
if (!pDeco->UpdateGfx())
|
||||
pObj->Menu->SetFrameDeco(NULL);
|
||||
}
|
||||
}
|
||||
// done; reset field to indicate finished update
|
||||
pGraphicsPtr = NULL;
|
||||
}
|
||||
|
@ -517,9 +518,8 @@ void C4DefGraphicsPtrBackup::AssignRemoval()
|
|||
if (pGraphicsPtr)
|
||||
{
|
||||
// check all objects
|
||||
C4Object *pObj;
|
||||
for (C4ObjectLink *pLnk = ::Objects.First; pLnk; pLnk=pLnk->Next)
|
||||
if ((pObj=pLnk->Obj)) if (pObj->Status)
|
||||
for (C4Object *pObj : Objects)
|
||||
if (pObj && pObj->Status)
|
||||
{
|
||||
if (pObj->pGraphics == pGraphicsPtr)
|
||||
{
|
||||
|
@ -572,9 +572,9 @@ void C4DefGraphicsPtrBackup::UpdateMeshes()
|
|||
MeshMaterialUpdate.Update(iter->second->Graphics.Mesh);
|
||||
|
||||
// Update mesh materials for all mesh instances.
|
||||
C4Object *pObj;
|
||||
for (C4ObjectLink *pLnk = ::Objects.First; pLnk; pLnk=pLnk->Next)
|
||||
if ((pObj=pLnk->Obj)) if (pObj->Status)
|
||||
for (C4Object *pObj : Objects)
|
||||
{
|
||||
if (pObj && pObj->Status)
|
||||
{
|
||||
if(pObj->pMeshInstance)
|
||||
UpdateMesh(pObj->pMeshInstance);
|
||||
|
@ -582,6 +582,7 @@ void C4DefGraphicsPtrBackup::UpdateMeshes()
|
|||
if(pGfxOverlay->pMeshInstance)
|
||||
UpdateMesh(pGfxOverlay->pMeshInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void C4DefGraphicsPtrBackup::UpdateMesh(StdMeshInstance* instance)
|
||||
|
|
|
@ -102,7 +102,7 @@ void C4GameObjects::CrossCheck() // Every Tick1 by ExecObjects
|
|||
}
|
||||
focf |= OCF_Alive; tocf |= OCF_HitSpeed2;
|
||||
|
||||
for (C4ObjectList::iterator iter = begin(); iter != end() && (obj1 = *iter); ++iter)
|
||||
for (auto obj1 : *this)
|
||||
if (obj1->Status && !obj1->Contained && (obj1->OCF & focf))
|
||||
{
|
||||
uint32_t Marker = GetNextMarker();
|
||||
|
@ -159,9 +159,7 @@ void C4GameObjects::CrossCheck() // Every Tick1 by ExecObjects
|
|||
C4Object* C4GameObjects::AtObject(int ctx, int cty, DWORD &ocf, C4Object *exclude)
|
||||
{
|
||||
DWORD cocf;
|
||||
C4Object *cObj; C4ObjectLink *clnk;
|
||||
|
||||
for (clnk=ObjectsAt(ctx,cty).First; clnk && (cObj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *cObj : ObjectsAt(ctx,cty))
|
||||
if (!exclude || (cObj!=exclude && exclude->Layer == cObj->Layer)) if (cObj->Status)
|
||||
{
|
||||
cocf=ocf | OCF_Exclusive;
|
||||
|
@ -201,10 +199,9 @@ C4Object *C4GameObjects::SafeObjectPointer(int32_t iNumber)
|
|||
|
||||
void C4GameObjects::UpdateSolidMasks()
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
cLnk->Obj->UpdateSolidMask(false);
|
||||
for (C4Object *obj : *this)
|
||||
if (obj->Status)
|
||||
obj->UpdateSolidMask(false);
|
||||
}
|
||||
|
||||
void C4GameObjects::DeleteObjects(bool fDeleteInactive)
|
||||
|
@ -226,12 +223,9 @@ void C4GameObjects::Clear(bool fClearInactive)
|
|||
int C4GameObjects::PostLoad(bool fKeepInactive, C4ValueNumbers * numbers)
|
||||
{
|
||||
// Process objects
|
||||
C4ObjectLink *cLnk;
|
||||
C4Object *pObj;
|
||||
int32_t iMaxObjectNumber = 0;
|
||||
for (cLnk = Last; cLnk; cLnk = cLnk->Prev)
|
||||
for (C4Object *pObj : reverse())
|
||||
{
|
||||
C4Object *pObj = cLnk->Obj;
|
||||
// keep track of numbers
|
||||
iMaxObjectNumber = Max<long>(iMaxObjectNumber, pObj->Number);
|
||||
// add to list of foreobjects
|
||||
|
@ -261,8 +255,8 @@ int C4GameObjects::PostLoad(bool fKeepInactive, C4ValueNumbers * numbers)
|
|||
// special checks:
|
||||
// -contained/contents-consistency
|
||||
// -StaticBack-objects zero speed
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if ((pObj=cLnk->Obj)->Status)
|
||||
for (C4Object *pObj : *this)
|
||||
if (pObj->Status)
|
||||
{
|
||||
// staticback must not have speed
|
||||
if (pObj->Category & C4D_StaticBack)
|
||||
|
@ -300,7 +294,7 @@ int C4GameObjects::PostLoad(bool fKeepInactive, C4ValueNumbers * numbers)
|
|||
}
|
||||
// sort out inactive objects
|
||||
C4ObjectLink *cLnkNext;
|
||||
for (cLnk=First; cLnk; cLnk=cLnkNext)
|
||||
for (C4ObjectLink *cLnk=First; cLnk; cLnk=cLnkNext)
|
||||
{
|
||||
cLnkNext = cLnk->Next;
|
||||
if (cLnk->Obj->Status == C4OS_INACTIVE)
|
||||
|
@ -332,8 +326,8 @@ int C4GameObjects::PostLoad(bool fKeepInactive, C4ValueNumbers * numbers)
|
|||
//Sectors.Dump();
|
||||
|
||||
// misc updates
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if ((pObj=cLnk->Obj)->Status)
|
||||
for (C4Object *pObj : *this)
|
||||
if (pObj->Status)
|
||||
{
|
||||
// add to plrview
|
||||
pObj->PlrFoWActualize();
|
||||
|
@ -365,9 +359,8 @@ void C4GameObjects::UpdateScriptPointers()
|
|||
C4Value C4GameObjects::GRBroadcast(const char *szFunction, C4AulParSet *pPars, bool fPassError, bool fRejectTest)
|
||||
{
|
||||
// call objects first - scenario script might overwrite hostility, etc...
|
||||
C4Object *pObj;
|
||||
for (C4ObjectLink *clnk=::Objects.First; clnk; clnk=clnk->Next)
|
||||
if ((pObj=clnk->Obj) && (pObj->Category & (C4D_Goal | C4D_Rule | C4D_Environment)) && pObj->Status)
|
||||
for (C4Object *pObj : *this)
|
||||
if (pObj && (pObj->Category & (C4D_Goal | C4D_Rule | C4D_Environment)) && pObj->Status)
|
||||
{
|
||||
C4Value vResult = pObj->Call(szFunction, pPars/*, fPassError*/);
|
||||
// rejection tests abort on first nonzero result
|
||||
|
@ -460,10 +453,8 @@ void C4GameObjects::FixObjectOrder()
|
|||
|
||||
void C4GameObjects::ResortUnsorted()
|
||||
{
|
||||
C4ObjectLink *clnk=First; C4Object *cObj;
|
||||
while (clnk && (cObj=clnk->Obj))
|
||||
for (C4Object *cObj : *this)
|
||||
{
|
||||
clnk=clnk->Next;
|
||||
if (cObj->Unsorted)
|
||||
{
|
||||
// readd to main object list
|
||||
|
@ -500,40 +491,37 @@ bool C4GameObjects::AssignInfo()
|
|||
|
||||
void C4GameObjects::AssignPlrViewRange()
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=Last; cLnk; cLnk=cLnk->Prev)
|
||||
if (cLnk->Obj->Status)
|
||||
cLnk->Obj->AssignPlrViewRange();
|
||||
for (C4Object *obj : reverse())
|
||||
if (obj->Status)
|
||||
obj->AssignPlrViewRange();
|
||||
}
|
||||
|
||||
void C4GameObjects::SyncClearance()
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj)
|
||||
cLnk->Obj->SyncClearance();
|
||||
for (C4Object *obj : *this)
|
||||
if (obj)
|
||||
obj->SyncClearance();
|
||||
}
|
||||
|
||||
void C4GameObjects::OnSynchronized()
|
||||
{
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
for (clnk=First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
cobj->Call(PSF_OnSynchronized);
|
||||
for (C4Object *obj : *this)
|
||||
if (obj)
|
||||
obj->Call(PSF_OnSynchronized);
|
||||
}
|
||||
|
||||
void C4GameObjects::ResetAudibility()
|
||||
{
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
for (clnk=First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
cobj->Audible=cobj->AudiblePan=0;
|
||||
for (C4Object *obj : *this)
|
||||
if (obj)
|
||||
obj->Audible = obj->AudiblePan = 0;
|
||||
}
|
||||
|
||||
void C4GameObjects::SetOCF()
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
cLnk->Obj->SetOCF();
|
||||
for (C4Object *obj : *this)
|
||||
if (obj->Status)
|
||||
obj->SetOCF();
|
||||
}
|
||||
|
||||
uint32_t C4GameObjects::GetNextMarker()
|
||||
|
@ -543,9 +531,11 @@ uint32_t C4GameObjects::GetNextMarker()
|
|||
// If all markers are exceeded, restart marker at 1 and reset all object markers to zero.
|
||||
if (!marker)
|
||||
{
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
for (clnk=First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
cobj->Marker = 0;
|
||||
for (C4Object *cobj : *this)
|
||||
{
|
||||
if (cobj)
|
||||
cobj->Marker = 0;
|
||||
}
|
||||
marker = ++LastUsedMarker;
|
||||
}
|
||||
return marker;
|
||||
|
|
|
@ -375,10 +375,8 @@ void C4Object::AssignRemoval(bool fExitContents)
|
|||
// count decrease
|
||||
Def->Count--;
|
||||
// Kill contents
|
||||
C4Object *cobj; C4ObjectLink *clnk,*next;
|
||||
for (clnk=Contents.First; clnk && (cobj=clnk->Obj); clnk=next)
|
||||
for (C4Object *cobj : Contents)
|
||||
{
|
||||
next=clnk->Next;
|
||||
if (fExitContents)
|
||||
cobj->Exit(GetX(), GetY());
|
||||
else
|
||||
|
@ -1187,8 +1185,8 @@ bool C4Object::ChangeDef(C4ID idNew)
|
|||
// Any effect callbacks to this object might need to reinitialize their target functions
|
||||
// This is ugly, because every effect there is must be updated...
|
||||
if (Game.pGlobalEffects) Game.pGlobalEffects->OnObjectChangedDef(this);
|
||||
for (C4ObjectLink *pLnk = ::Objects.First; pLnk; pLnk = pLnk->Next)
|
||||
if (pLnk->Obj->pEffects) pLnk->Obj->pEffects->OnObjectChangedDef(this);
|
||||
for (C4Object *obj : Objects)
|
||||
if (obj->pEffects) obj->pEffects->OnObjectChangedDef(this);
|
||||
// Containment (no Entrance)
|
||||
if (pContainer) Enter(pContainer,false);
|
||||
// Done
|
||||
|
@ -4750,10 +4748,8 @@ bool C4Object::StatusDeactivate(bool fClearPointers)
|
|||
void C4Object::ClearContentsAndContained(bool fDoCalls)
|
||||
{
|
||||
// exit contents from container
|
||||
C4Object *cobj; C4ObjectLink *clnk,*next;
|
||||
for (clnk=Contents.First; clnk && (cobj=clnk->Obj); clnk=next)
|
||||
for (C4Object *cobj : Contents)
|
||||
{
|
||||
next=clnk->Next;
|
||||
cobj->Exit(GetX(), GetY(), 0,Fix0,Fix0,Fix0, fDoCalls);
|
||||
}
|
||||
// remove from container *after* contents have been removed!
|
||||
|
@ -4875,10 +4871,9 @@ void C4Object::GrabContents(C4Object *pFrom)
|
|||
// create a temp list of all objects and transfer it
|
||||
// this prevents nasty deadlocks caused by RejectEntrance-scripts
|
||||
C4ObjectList tmpList; tmpList.Copy(pFrom->Contents);
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=tmpList.First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
cLnk->Obj->Enter(this);
|
||||
for (C4Object *obj : tmpList)
|
||||
if (obj->Status)
|
||||
obj->Enter(this);
|
||||
}
|
||||
|
||||
bool C4Object::CanConcatPictureWith(C4Object *pOtherObject) const
|
||||
|
|
|
@ -115,9 +115,8 @@ void C4ObjectMenu::ClearPointers(C4Object *pObj)
|
|||
|
||||
C4Object* C4ObjectMenu::GetParentObject()
|
||||
{
|
||||
C4Object *cObj; C4ObjectLink *cLnk;
|
||||
for (cLnk=::Objects.First; cLnk && (cObj=cLnk->Obj); cLnk=cLnk->Next)
|
||||
if ( cObj->Menu == this )
|
||||
for (C4Object *cObj : Objects)
|
||||
if (cObj->Menu == this)
|
||||
return cObj;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -1605,9 +1605,9 @@ static C4Void FnSetObjectLayer(C4Object *Obj, C4Object *pNewLayer)
|
|||
// set layer object
|
||||
Obj->Layer = pNewLayer;
|
||||
// set for all contents as well
|
||||
for (C4ObjectLink *pLnk=Obj->Contents.First; pLnk; pLnk=pLnk->Next)
|
||||
if ((Obj=pLnk->Obj) && Obj->Status)
|
||||
Obj->Layer = pNewLayer;
|
||||
for (C4Object* contentObj : Obj->Contents)
|
||||
if (contentObj && contentObj->Status)
|
||||
contentObj->Layer = pNewLayer;
|
||||
// success
|
||||
return C4Void();
|
||||
}
|
||||
|
|
|
@ -57,9 +57,8 @@ C4Player::~C4Player()
|
|||
|
||||
bool C4Player::ObjectInCrew(C4Object *tobj)
|
||||
{
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
if (!tobj) return false;
|
||||
for (clnk=Crew.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *cobj : Crew)
|
||||
if (cobj==tobj) return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -190,11 +189,8 @@ void C4Player::Execute()
|
|||
Menu.Execute();
|
||||
|
||||
// decay of dead viewtargets
|
||||
C4ObjectLink *pLnkNext = FoWViewObjs.First, *pLnk;
|
||||
while ((pLnk = pLnkNext))
|
||||
for (C4Object *pDeadClonk : FoWViewObjs)
|
||||
{
|
||||
pLnkNext = pLnk->Next;
|
||||
C4Object *pDeadClonk = pLnk->Obj;
|
||||
if (!pDeadClonk->GetAlive() && (pDeadClonk->Category & C4D_Living) && pDeadClonk->Status)
|
||||
{
|
||||
pDeadClonk->PlrViewRange -= 10;
|
||||
|
@ -360,9 +356,8 @@ bool C4Player::Init(int32_t iNumber, int32_t iAtClient, const char *szAtClientNa
|
|||
GameJoinTime = Game.Time;
|
||||
|
||||
// Init FoW-viewobjects: NO_OWNER-FoW-repellers might need to be added
|
||||
for (C4ObjectLink *pLnk = ::Objects.First; pLnk; pLnk = pLnk->Next)
|
||||
for (C4Object *pObj : Objects)
|
||||
{
|
||||
C4Object *pObj = pLnk->Obj;
|
||||
if (pObj->PlrViewRange && pObj->Owner == NO_OWNER)
|
||||
pObj->PlrFoWActualize();
|
||||
}
|
||||
|
@ -817,10 +812,10 @@ bool C4Player::IsHostileTowards(const C4Player *plr) const
|
|||
|
||||
C4Object* C4Player::GetHiExpActiveCrew()
|
||||
{
|
||||
C4ObjectLink *clnk;
|
||||
C4Object *cobj,*hiexp=NULL;
|
||||
C4Object *hiexp=NULL;
|
||||
int32_t iHighestExp=-2, iExp;
|
||||
for (clnk=Crew.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *cobj : Crew)
|
||||
{
|
||||
if (!cobj->CrewDisabled)
|
||||
{
|
||||
if (cobj->Info) iExp = cobj->Info->Experience; else iExp=-1;
|
||||
|
@ -830,15 +825,16 @@ C4Object* C4Player::GetHiExpActiveCrew()
|
|||
iHighestExp=iExp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return hiexp;
|
||||
}
|
||||
|
||||
C4Object* C4Player::GetHiRankActiveCrew()
|
||||
{
|
||||
C4ObjectLink *clnk;
|
||||
C4Object *cobj,*hirank=NULL;
|
||||
C4Object *hirank=NULL;
|
||||
int32_t iHighestRank=-2, iRank;
|
||||
for (clnk=Crew.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *cobj : Crew)
|
||||
{
|
||||
if (!cobj->CrewDisabled)
|
||||
{
|
||||
if (cobj->Info) iRank = cobj->Info->Rank; else iRank=-1;
|
||||
|
@ -848,6 +844,7 @@ C4Object* C4Player::GetHiRankActiveCrew()
|
|||
iHighestRank=iRank;
|
||||
}
|
||||
}
|
||||
}
|
||||
return hirank;
|
||||
}
|
||||
|
||||
|
@ -1215,9 +1212,8 @@ void C4Player::ExecBaseProduction()
|
|||
|
||||
void C4Player::UpdateCounts()
|
||||
{
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
CrewCnt = 0;
|
||||
for (clnk=Crew.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *crew : Crew)
|
||||
{
|
||||
++CrewCnt;
|
||||
}
|
||||
|
@ -1369,13 +1365,11 @@ int32_t C4Player::FindNewOwner() const
|
|||
|
||||
void C4Player::NotifyOwnedObjects()
|
||||
{
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
|
||||
int32_t iNewOwner = FindNewOwner();
|
||||
// notify objects in all object lists
|
||||
for (C4ObjectList *pList = &::Objects; pList; pList = ((pList == &::Objects) ? &::Objects.InactiveObjects : NULL))
|
||||
{
|
||||
for (clnk = pList->First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *cobj : *pList)
|
||||
{
|
||||
if (cobj->Status && cobj->Owner == Number)
|
||||
{
|
||||
|
@ -1512,8 +1506,7 @@ void C4Player::FoW2Map(C4FogOfWar &rMap, int iOffX, int iOffY)
|
|||
// Add view for all FoW-repellers - keep track of FoW-generators, which should be avaluated finally
|
||||
// so they override repellers
|
||||
bool fAnyGenerators = false;
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
for (clnk=FoWViewObjs.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *cobj : FoWViewObjs)
|
||||
if (!cobj->Contained || cobj->Contained->Def->ClosedContainer != 1)
|
||||
{
|
||||
if (cobj->PlrViewRange > 0)
|
||||
|
@ -1539,8 +1532,7 @@ void C4Player::FoW2Map(C4FogOfWar &rMap, int iOffX, int iOffY)
|
|||
void C4Player::FoWGenerators2Map(C4FogOfWar &rMap, int iOffX, int iOffY)
|
||||
{
|
||||
// add fog to any generator pos (view range
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
for (clnk=FoWViewObjs.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *cobj : FoWViewObjs)
|
||||
if (!cobj->Contained || cobj->Contained->Def->ClosedContainer != 1)
|
||||
if (cobj->PlrViewRange < 0)
|
||||
rMap.AddModulation(cobj->GetX() + iOffX, cobj->GetY() + iOffY,-cobj->PlrViewRange, ((uint32_t)cobj->ColorMod)>>24);
|
||||
|
@ -1550,15 +1542,16 @@ bool C4Player::FoWIsVisible(int32_t x, int32_t y)
|
|||
{
|
||||
// check repellers and generators and ViewTarget
|
||||
bool fSeen=false;
|
||||
C4Object *cobj=NULL; C4ObjectLink *clnk;
|
||||
clnk=FoWViewObjs.First;
|
||||
auto it = FoWViewObjs.begin();
|
||||
auto end = FoWViewObjs.end();
|
||||
int32_t iRange;
|
||||
C4Object* cobj = nullptr;
|
||||
for (;;)
|
||||
{
|
||||
if (clnk)
|
||||
if (it != end)
|
||||
{
|
||||
cobj=clnk->Obj;
|
||||
clnk=clnk->Next;
|
||||
cobj=*it;
|
||||
it++;
|
||||
iRange = cobj->PlrViewRange;
|
||||
}
|
||||
else if (ViewMode!=C4PVM_Target || !ViewTarget || ViewTarget == cobj)
|
||||
|
@ -1619,9 +1612,8 @@ int32_t C4Player::ActiveCrewCount()
|
|||
{
|
||||
// get number of objects in crew that is not disabled
|
||||
int32_t iNum=0;
|
||||
C4Object *cObj;
|
||||
for (C4ObjectLink *cLnk=Crew.First; cLnk; cLnk=cLnk->Next)
|
||||
if ((cObj=cLnk->Obj))
|
||||
for (C4Object *cObj : Crew)
|
||||
if (cObj)
|
||||
if (!cObj->CrewDisabled)
|
||||
++iNum;
|
||||
// return it
|
||||
|
@ -1838,15 +1830,12 @@ void C4Player::SetPlayerColor(uint32_t dwNewClr)
|
|||
// this can never catch everything (thinking of overlays, etc.); scenarios that allow team changes should take care of the rest
|
||||
uint32_t dwOldClr = ColorDw;
|
||||
ColorDw = dwNewClr;
|
||||
C4Object *pObj;
|
||||
for (C4ObjectLink *pLnk = ::Objects.First; pLnk; pLnk = pLnk->Next)
|
||||
if ((pObj = pLnk->Obj))
|
||||
if ((pObj->Status))
|
||||
if (pObj->Owner == Number)
|
||||
{
|
||||
if ((pObj->Color & 0xffffff) == (dwOldClr & 0xffffff))
|
||||
pObj->Color = (pObj->Color & 0xff000000u) | (dwNewClr & 0xffffff);
|
||||
}
|
||||
for (C4Object *pObj : Objects)
|
||||
if (pObj && pObj->Status && pObj->Owner == Number)
|
||||
{
|
||||
if ((pObj->Color & 0xffffff) == (dwOldClr & 0xffffff))
|
||||
pObj->Color = (pObj->Color & 0xff000000u) | (dwNewClr & 0xffffff);
|
||||
}
|
||||
}
|
||||
|
||||
C4PlayerType C4Player::GetType() const
|
||||
|
|
|
@ -214,8 +214,7 @@ bool C4PlayerList::Remove(int iPlayer, bool fDisconnect, bool fNoCalls)
|
|||
bool C4PlayerList::RemoveUnjoined(int32_t iPlayer)
|
||||
{
|
||||
// Savegame resume missing player: Remove player objects only
|
||||
C4Object *pObj;
|
||||
for (C4ObjectLink *clnk=::Objects.First; clnk && (pObj=clnk->Obj); clnk=clnk->Next)
|
||||
for (C4Object *pObj : Objects)
|
||||
if (pObj->Status)
|
||||
if (pObj->IsPlayerObject(iPlayer))
|
||||
pObj->AssignRemoval(true);
|
||||
|
|
Loading…
Reference in New Issue