diff --git a/CHANGELOG.md b/CHANGELOG.md
index 54490caee..f92f72365 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -127,6 +127,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- `MOSRotating` Lua function `AddWound` now additionally accepts the format `MOSRotating:AddWound(AEmitter* woundToAdd, const Vector& parentOffsetToSet, bool checkGibWoundLimit, bool isEntryWound, bool isExitWound)`, allowing modders to specify added wounds as entry- or exit wounds, for the purpose of not playing multiple burst sounds on the same frame. These new arguments are optional.
+- Various performance improvements.
+
Fixed
@@ -147,6 +149,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fixed an issue where internal Lua functions OriginalDoFile, OriginalLoadFile, and OriginalRequire were polluting the global namespace. They have now been made inaccessible.
+- Fixed issue where MOSR `Gib`s, `AEmitter` or `PEmitter` `Emission`s, and MetaMan `Player`s were not correctly accessible from script.
+
+- Fixed a crash on launch when the `SupportedGameVersion` INI property was not set.
+
Removed
@@ -2677,7 +2683,7 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
- `TDExplosive.ActivatesWhenReleased` now works properly.
-- Various bug fixed related to all the Attachable and Emitter changes, so they can now me affected reliably and safely with lua.
+- Various bugs fixed related to all the Attachable and Emitter changes, so they can again be affected reliably and safely with lua.
- Various minor other things that have gotten lost in the shuffle.
diff --git a/Source/Activities/AreaEditor.cpp b/Source/Activities/AreaEditor.cpp
index aecc071d7..ff6f91035 100644
--- a/Source/Activities/AreaEditor.cpp
+++ b/Source/Activities/AreaEditor.cpp
@@ -294,12 +294,12 @@ void AreaEditor::Update() {
m_pEditorGUI->SetEditorGUIMode(AreaEditorGUI::PREADDMOVEBOX);
} else {
// Make and name new Area
- Scene::Area newArea(m_pNewAreaName->GetText());
+ Scene::Area* newArea = new Scene::Area(m_pNewAreaName->GetText());
pCurrentScene->m_AreaList.push_back(newArea);
// Set the new area as the active one in the GUI, note we're getting the correct one from the scene, it's a copy of the one passed in
- m_pEditorGUI->SetCurrentArea(pCurrentScene->GetArea(newArea.GetName()));
+ m_pEditorGUI->SetCurrentArea(pCurrentScene->GetArea(newArea->GetName()));
// Update teh picker list of the GUI so we can mousewheel between all the Areas, incl the new one
- m_pEditorGUI->UpdatePickerList(newArea.GetName());
+ m_pEditorGUI->UpdatePickerList(newArea->GetName());
}
// Change mode to start editing the new/newly selected Area
diff --git a/Source/Activities/GibEditor.cpp b/Source/Activities/GibEditor.cpp
index 16fc69c41..66140b9fc 100644
--- a/Source/Activities/GibEditor.cpp
+++ b/Source/Activities/GibEditor.cpp
@@ -400,14 +400,14 @@ void GibEditor::Update() {
m_pEditedObject->Update();
// Make proxy copies of the loaded objects' gib reference instances and place them in the list to be edited
- std::list* pLoadedGibList = m_pEditedObject->GetGibList();
+ std::list* pLoadedGibList = m_pEditedObject->GetGibList();
std::list* pEditedGibList = m_pEditorGUI->GetPlacedGibs();
MovableObject* pGibCopy = 0;
for (auto gItr = pLoadedGibList->begin(); gItr != pLoadedGibList->end(); ++gItr) {
- pGibCopy = dynamic_cast((*gItr).GetParticlePreset()->Clone());
+ pGibCopy = dynamic_cast((*gItr)->GetParticlePreset()->Clone());
if (pGibCopy) {
- pGibCopy->SetPos(m_pEditedObject->GetPos() + (*gItr).GetOffset());
+ pGibCopy->SetPos(m_pEditedObject->GetPos() + (*gItr)->GetOffset());
pEditedGibList->push_back(pGibCopy);
}
pGibCopy = 0;
@@ -599,8 +599,8 @@ bool GibEditor::SaveObject(const std::string& saveAsName, bool forceOverwrite) {
}
objectWriter.NewProperty(addObjectType);
m_pEditedObject->Entity::Save(objectWriter);
- for (const Gib& gib: *m_pEditedObject->GetGibList()) {
- objectWriter.NewPropertyWithValue("AddGib", gib);
+ for (const Gib* gib: *m_pEditedObject->GetGibList()) {
+ objectWriter.NewPropertyWithValue("AddGib", *gib);
}
objectWriter.ObjectEnd();
objectWriter.EndWrite();
@@ -626,18 +626,18 @@ void GibEditor::StuffEditedGibs(MOSRotating* pEditedObject) {
return;
// Replace the gibs of the object with the proxies that have been edited in the gui
- std::list* pObjectGibList = pEditedObject->GetGibList();
+ std::list* pObjectGibList = pEditedObject->GetGibList();
pObjectGibList->clear();
// Take each proxy object and stuff it into a Gib instance which then gets stuffed into the object to be saved
std::list* pProxyGibList = m_pEditorGUI->GetPlacedGibs();
for (std::list::iterator gItr = pProxyGibList->begin(); gItr != pProxyGibList->end(); ++gItr) {
- Gib newGib;
+ Gib* newGib;
// Only set the refernce instance directly from the isntanceman. OWNERSHIP IS NOT TRANSFERRED!
- newGib.m_GibParticle = dynamic_cast(g_PresetMan.GetEntityPreset((*gItr)->GetClassName(), (*gItr)->GetPresetName(), m_ModuleSpaceID));
- if (newGib.m_GibParticle) {
- newGib.m_Count = 1;
- newGib.m_Offset = (*gItr)->GetPos() - pEditedObject->GetPos();
+ newGib->m_GibParticle = dynamic_cast(g_PresetMan.GetEntityPreset((*gItr)->GetClassName(), (*gItr)->GetPresetName(), m_ModuleSpaceID));
+ if (newGib->m_GibParticle) {
+ newGib->m_Count = 1;
+ newGib->m_Offset = (*gItr)->GetPos() - pEditedObject->GetPos();
// TODO: do proper velocity calculations here!
// ... actually leave these as 0 and let them be calculated in GibThis
// newGib.m_MinVelocity = (100.0f + 50.0f * NormalRand()) / (*gItr)->GetMass();
diff --git a/Source/Entities/AEmitter.cpp b/Source/Entities/AEmitter.cpp
index a698f22be..d32c0a39a 100644
--- a/Source/Entities/AEmitter.cpp
+++ b/Source/Entities/AEmitter.cpp
@@ -64,8 +64,8 @@ int AEmitter::Create(const AEmitter& reference) {
SetFlash(dynamic_cast(reference.m_pFlash->Clone()));
}
- for (auto itr = reference.m_EmissionList.begin(); itr != reference.m_EmissionList.end(); ++itr) {
- m_EmissionList.push_back(*itr);
+ for (Emission* emission: reference.m_EmissionList) {
+ m_EmissionList.push_back(static_cast(emission->Clone()));
}
if (reference.m_EmissionSound) {
m_EmissionSound = dynamic_cast(reference.m_EmissionSound->Clone());
@@ -105,8 +105,8 @@ int AEmitter::ReadProperty(const std::string_view& propName, Reader& reader) {
StartPropertyList(return Attachable::ReadProperty(propName, reader));
MatchProperty("AddEmission", {
- Emission emission;
- reader >> emission;
+ Emission* emission = new Emission();
+ reader >> *emission;
m_EmissionList.push_back(emission);
});
MatchProperty("EmissionSound", {
@@ -128,8 +128,8 @@ int AEmitter::ReadProperty(const std::string_view& propName, Reader& reader) {
float ppm;
reader >> ppm;
// Go through all emissions and set the rate so that it emulates the way it used to work, for mod backwards compatibility.
- for (Emission& emission: m_EmissionList) {
- emission.m_PPM = ppm / static_cast(m_EmissionList.size());
+ for (Emission* emission: m_EmissionList) {
+ emission->m_PPM = ppm / static_cast(m_EmissionList.size());
}
});
MatchProperty("NegativeThrottleMultiplier", { reader >> m_NegativeThrottleMultiplier; });
@@ -140,8 +140,8 @@ int AEmitter::ReadProperty(const std::string_view& propName, Reader& reader) {
int burstSize;
reader >> burstSize;
// Go through all emissions and set the rate so that it emulates the way it used to work, for mod backwards compatibility.
- for (Emission& emission: m_EmissionList) {
- emission.m_BurstSize = std::ceil(static_cast(burstSize) / static_cast(m_EmissionList.size()));
+ for (Emission* emission: m_EmissionList) {
+ emission->m_BurstSize = std::ceil(static_cast(burstSize) / static_cast(m_EmissionList.size()));
}
});
MatchProperty("BurstScale", { reader >> m_BurstScale; });
@@ -166,9 +166,9 @@ int AEmitter::ReadProperty(const std::string_view& propName, Reader& reader) {
int AEmitter::Save(Writer& writer) const {
Attachable::Save(writer);
- for (auto itr = m_EmissionList.begin(); itr != m_EmissionList.end(); ++itr) {
+ for (Emission* emission: m_EmissionList) {
writer.NewProperty("AddEmission");
- writer << *itr;
+ writer << *emission;
}
writer.NewProperty("EmissionSound");
writer << m_EmissionSound;
@@ -233,21 +233,27 @@ void AEmitter::Destroy(bool notInherited) {
m_EmissionSound->Stop();
}
+ for (Emission* emission: m_EmissionList) {
+ delete emission;
+ }
+
delete m_EmissionSound;
delete m_BurstSound;
delete m_EndSound;
// m_BurstSound.Stop();
- if (!notInherited)
+ if (!notInherited) {
Attachable::Destroy();
+ }
Clear();
}
void AEmitter::ResetEmissionTimers() {
m_LastEmitTmr.Reset();
- for (auto eItr = m_EmissionList.begin(); eItr != m_EmissionList.end(); ++eItr)
- (*eItr).ResetEmissionTimers();
+ for (Emission* emission: m_EmissionList) {
+ emission->ResetEmissionTimers();
+ }
}
void AEmitter::EnableEmission(bool enable) {
@@ -268,22 +274,22 @@ float AEmitter::EstimateImpulse(bool burst) {
float velMin, velMax, velRange, spread;
// Go through all emissions and emit them according to their respective rates
- for (auto eItr = m_EmissionList.begin(); eItr != m_EmissionList.end(); ++eItr) {
+ for (Emission* emission: m_EmissionList) {
// Only check emissions that push the emitter
- if ((*eItr).PushesEmitter()) {
- float emissions = ((*eItr).GetRate() / 60.0f) * g_TimerMan.GetDeltaTimeSecs();
+ if (emission->PushesEmitter()) {
+ float emissions = (emission->GetRate() / 60.0f) * g_TimerMan.GetDeltaTimeSecs();
float scale = 1.0F;
if (burst) {
- emissions *= (*eItr).GetBurstSize();
+ emissions *= emission->GetBurstSize();
scale = m_BurstScale;
}
- velMin = (*eItr).GetMinVelocity() * scale;
- velRange = ((*eItr).GetMaxVelocity() - (*eItr).GetMinVelocity()) * 0.5F * scale;
- spread = (std::max(static_cast(c_PI) - (*eItr).GetSpread(), 0.0F) / c_PI) * scale; // A large spread will cause the forces to cancel eachother out
+ velMin = emission->GetMinVelocity() * scale;
+ velRange = (emission->GetMaxVelocity() - emission->GetMinVelocity()) * 0.5F * scale;
+ spread = (std::max(static_cast(c_PI) - emission->GetSpread(), 0.0F) / c_PI) * scale; // A large spread will cause the forces to cancel eachother out
// Add to accumulative recoil impulse generated, F = m * a.
- impulse += (velMin + velRange) * spread * (*eItr).m_pEmission->GetMass() * emissions;
+ impulse += (velMin + velRange) * spread * emission->m_pEmission->GetMass() * emissions;
}
}
@@ -305,16 +311,16 @@ float AEmitter::EstimateImpulse(bool burst) {
float AEmitter::GetTotalParticlesPerMinute() const {
float totalPPM = 0;
- for (const Emission& emission: m_EmissionList) {
- totalPPM += emission.m_PPM;
+ for (const Emission* emission: m_EmissionList) {
+ totalPPM += emission->m_PPM;
}
return totalPPM;
}
int AEmitter::GetTotalBurstSize() const {
int totalBurstSize = 0;
- for (const Emission& emission: m_EmissionList) {
- totalBurstSize += emission.m_BurstSize;
+ for (const Emission* emission: m_EmissionList) {
+ totalBurstSize += emission->m_BurstSize;
}
return totalBurstSize;
}
@@ -382,8 +388,8 @@ void AEmitter::Update() {
}
// Reset the timers of all emissions so they will start/stop at the correct relative offsets from now
- for (Emission& emission: m_EmissionList)
- emission.ResetEmissionTimers();
+ for (Emission* emission: m_EmissionList)
+ emission->ResetEmissionTimers();
}
// Update the distance attenuation
else if (m_EmissionSound) {
@@ -415,11 +421,11 @@ void AEmitter::Update() {
MovableObject* pParticle = 0;
Vector parentVel, emitVel, pushImpulses;
// Go through all emissions and emit them according to their respective rates
- for (Emission& emission: m_EmissionList) {
+ for (Emission* emission: m_EmissionList) {
// Make sure the emissions only happen between the start time and end time
- if (emission.IsEmissionTime()) {
+ if (emission->IsEmissionTime()) {
// Apply the throttle factor to the emission rate
- currentPPM = emission.GetRate() * throttleFactor;
+ currentPPM = emission->GetRate() * throttleFactor;
int emissionCount = 0;
// Only do all this if the PPM is actually above zero
@@ -428,50 +434,50 @@ void AEmitter::Update() {
SPE = 60.0 / currentPPM;
// Add the last elapsed time to the accumulator
- emission.m_Accumulator += m_LastEmitTmr.GetElapsedSimTimeS();
+ emission->m_Accumulator += m_LastEmitTmr.GetElapsedSimTimeS();
// Now figure how many full emissions can fit in the current accumulator
- emissionCount = std::floor(emission.m_Accumulator / SPE);
+ emissionCount = std::floor(emission->m_Accumulator / SPE);
// Deduct the about to be emitted emissions from the accumulator
- emission.m_Accumulator -= emissionCount * SPE;
+ emission->m_Accumulator -= emissionCount * SPE;
- RTEAssert(emission.m_Accumulator >= 0, "Emission accumulator negative!");
+ RTEAssert(emission->m_Accumulator >= 0, "Emission accumulator negative!");
} else {
- emission.m_Accumulator = 0;
+ emission->m_Accumulator = 0;
}
float scale = 1.0F;
// Add extra emissions if bursting.
if (m_BurstTriggered) {
- emissionCount += emission.GetBurstSize() * std::floor(throttleFactor);
+ emissionCount += emission->GetBurstSize() * std::floor(throttleFactor);
scale = m_BurstScale;
}
emissionCountTotal += emissionCount;
if (emissionCount > 0) {
- int extraEmissions = emission.GetParticleCount() - 1;
+ int extraEmissions = emission->GetParticleCount() - 1;
emissionCount += extraEmissions;
}
pParticle = 0;
emitVel.Reset();
- parentVel = pRootParent->GetVel() * emission.InheritsVelocity();
- Vector rotationalVel = (((RotateOffset(emission.GetOffset()) + (m_Pos - pRootParent->GetPos())) * pRootParent->GetAngularVel()).GetPerpendicular() / c_PPM) * emission.InheritsVelocity();
+ parentVel = pRootParent->GetVel() * emission->InheritsVelocity();
+ Vector rotationalVel = (((RotateOffset(emission->GetOffset()) + (m_Pos - pRootParent->GetPos())) * pRootParent->GetAngularVel()).GetPerpendicular() / c_PPM) * emission->InheritsVelocity();
for (int i = 0; i < emissionCount; ++i) {
- velMin = emission.GetMinVelocity() * scale;
- velRange = (emission.GetMaxVelocity() - emission.GetMinVelocity()) * scale;
- spread = emission.GetSpread() * scale;
+ velMin = emission->GetMinVelocity() * scale;
+ velRange = (emission->GetMaxVelocity() - emission->GetMinVelocity()) * scale;
+ spread = emission->GetSpread() * scale;
// Make a copy after the reference particle
- pParticle = dynamic_cast(emission.GetEmissionParticlePreset()->Clone());
+ pParticle = dynamic_cast(emission->GetEmissionParticlePreset()->Clone());
// Set up its position and velocity according to the parameters of this.
// Emission point offset not set
- if (emission.GetOffset().IsZero()) {
+ if (emission->GetOffset().IsZero()) {
if (m_EmissionOffset.IsZero()) {
pParticle->SetPos(m_Pos);
} else {
pParticle->SetPos(m_Pos + RotateOffset(m_EmissionOffset));
}
} else {
- pParticle->SetPos(m_Pos + RotateOffset(emission.GetOffset()));
+ pParticle->SetPos(m_Pos + RotateOffset(emission->GetOffset()));
}
// TODO: Optimize making the random angles!")
emitVel.SetXY(velMin + RandomNum(0.0F, velRange), 0.0F);
@@ -479,12 +485,12 @@ void AEmitter::Update() {
emitVel = RotateOffset(emitVel);
pParticle->SetVel(parentVel + rotationalVel + emitVel);
pParticle->SetRotAngle(emitVel.GetAbsRadAngle() + (m_HFlipped ? -c_PI : 0));
- pParticle->SetAngularVel(pRootParent->GetAngularVel() * emission.InheritsAngularVelocity());
+ pParticle->SetAngularVel(pRootParent->GetAngularVel() * emission->InheritsAngularVelocity());
pParticle->SetHFlipped(m_HFlipped);
// Scale the particle's lifetime based on life variation and throttle, as long as it's not 0
if (pParticle->GetLifetime() != 0) {
- pParticle->SetLifetime(std::max(static_cast(static_cast(pParticle->GetLifetime()) * (1.0F + (emission.GetLifeVariation() * RandomNormalNum()))), 1));
+ pParticle->SetLifetime(std::max(static_cast(static_cast(pParticle->GetLifetime()) * (1.0F + (emission->GetLifeVariation() * RandomNormalNum()))), 1));
pParticle->SetLifetime(std::max(static_cast(pParticle->GetLifetime() * throttleFactor), 1));
}
pParticle->SetTeam(m_Team);
@@ -492,7 +498,7 @@ void AEmitter::Update() {
// Add to accumulative recoil impulse generated, F = m * a
// If enabled, that is
- if (emission.PushesEmitter() && (GetParent() || GetMass() > 0)) {
+ if (emission->PushesEmitter() && (GetParent() || GetMass() > 0)) {
pushImpulses -= emitVel * pParticle->GetMass();
}
diff --git a/Source/Entities/AEmitter.h b/Source/Entities/AEmitter.h
index b4d9806e6..98cf08b57 100644
--- a/Source/Entities/AEmitter.h
+++ b/Source/Entities/AEmitter.h
@@ -367,7 +367,7 @@ namespace RTE {
static Entity::ClassInfo m_sClass;
// The list of MO instances that get emitted
- std::vector m_EmissionList;
+ std::list m_EmissionList;
// Sounds
SoundContainer* m_EmissionSound;
SoundContainer* m_BurstSound;
diff --git a/Source/Entities/MOSRotating.cpp b/Source/Entities/MOSRotating.cpp
index 3e6deffc9..20fc63d2f 100644
--- a/Source/Entities/MOSRotating.cpp
+++ b/Source/Entities/MOSRotating.cpp
@@ -231,8 +231,8 @@ int MOSRotating::Create(const MOSRotating& reference) {
}
m_ReferenceHardcodedAttachableUniqueIDs.clear();
- for (const Gib& gib: reference.m_Gibs) {
- m_Gibs.push_back(gib);
+ for (const Gib* gib: reference.m_Gibs) {
+ m_Gibs.push_back(new Gib(*gib));
}
m_GibImpulseLimit = reference.m_GibImpulseLimit;
@@ -305,8 +305,8 @@ int MOSRotating::ReadProperty(const std::string_view& propName, Reader& reader)
});
MatchProperty("AddGib",
{
- Gib gib;
- reader >> gib;
+ Gib* gib = new Gib();
+ reader >> *gib;
m_Gibs.push_back(gib);
});
MatchProperty("GibImpulseLimit", { reader >> m_GibImpulseLimit; });
@@ -359,7 +359,7 @@ int MOSRotating::Save(Writer& writer) const {
*/
for (auto gItr = m_Gibs.begin(); gItr != m_Gibs.end(); ++gItr) {
writer.NewProperty("AddGib");
- writer << (*gItr);
+ writer << (**gItr);
}
/*
writer.NewProperty("GibImpulseLimit");
@@ -573,6 +573,10 @@ void MOSRotating::Destroy(bool notInherited) {
delete (*itr);
}
+ for (auto gib = m_Gibs.begin(); gib != m_Gibs.end(); ++gib) {
+ delete (*gib);
+ }
+
for (auto aItr = m_Attachables.begin(); aItr != m_Attachables.end(); ++aItr) {
if (m_HardcodedAttachableUniqueIDsAndRemovers.find((*aItr)->GetUniqueID()) == m_HardcodedAttachableUniqueIDsAndRemovers.end()) {
delete (*aItr);
@@ -913,17 +917,17 @@ void MOSRotating::CreateGibsWhenGibbing(const Vector& impactImpulse, MovableObje
g_CameraMan.AddScreenShake(m_GibScreenShakeAmount, m_Pos);
}
- for (const Gib& gibSettingsObject: m_Gibs) {
- if (gibSettingsObject.GetCount() == 0) {
+ for (const Gib* gibSettingsObject: m_Gibs) {
+ if (gibSettingsObject->GetCount() == 0) {
continue;
}
- MovableObject* gibParticleClone = dynamic_cast(gibSettingsObject.GetParticlePreset()->Clone());
+ MovableObject* gibParticleClone = dynamic_cast(gibSettingsObject->GetParticlePreset()->Clone());
- int count = gibSettingsObject.GetCount();
- float lifeVariation = gibSettingsObject.GetLifeVariation();
- float spread = gibSettingsObject.GetSpread();
- float minVelocity = gibSettingsObject.GetMinVelocity();
- float maxVelocity = gibSettingsObject.GetMaxVelocity();
+ int count = gibSettingsObject->GetCount();
+ float lifeVariation = gibSettingsObject->GetLifeVariation();
+ float spread = gibSettingsObject->GetSpread();
+ float minVelocity = gibSettingsObject->GetMinVelocity();
+ float maxVelocity = gibSettingsObject->GetMaxVelocity();
float mass = (gibParticleClone->GetMass() != 0 ? gibParticleClone->GetMass() : 0.0001F);
int lifetime = gibParticleClone->GetLifetime();
@@ -941,10 +945,10 @@ void MOSRotating::CreateGibsWhenGibbing(const Vector& impactImpulse, MovableObje
}
float velocityRange = maxVelocity - minVelocity;
- Vector rotatedGibOffset = RotateOffset(gibSettingsObject.GetOffset());
+ Vector rotatedGibOffset = RotateOffset(gibSettingsObject->GetOffset());
// The "Spiral" spread mode uses the fermat spiral as means to determine the velocity of the gib particles, resulting in a evenly spaced out circle (or ring) of particles.
- if (gibSettingsObject.GetSpreadMode() == Gib::SpreadMode::SpreadSpiral) {
+ if (gibSettingsObject->GetSpreadMode() == Gib::SpreadMode::SpreadSpiral) {
float maxRadius = std::sqrt(static_cast(count));
float scale = velocityRange / maxRadius;
float randAngle = c_PI * RandomNormalNum();
@@ -952,7 +956,7 @@ void MOSRotating::CreateGibsWhenGibbing(const Vector& impactImpulse, MovableObje
for (int i = 0; i < count; i++) {
if (i > 0) {
- gibParticleClone = dynamic_cast(gibSettingsObject.GetParticlePreset()->Clone());
+ gibParticleClone = dynamic_cast(gibSettingsObject->GetParticlePreset()->Clone());
}
float radius = std::sqrt(static_cast(count - i));
@@ -962,20 +966,20 @@ void MOSRotating::CreateGibsWhenGibbing(const Vector& impactImpulse, MovableObje
gibVelocity.RadRotate(randAngle + RandomNum(0.0F, spread) + static_cast(i) * goldenAngle);
Vector offsetFromRootParent = m_Pos - GetRootParent()->GetPos() + rotatedGibOffset;
- Vector rotationalVelocity = (offsetFromRootParent.GetPerpendicular() * GetRootParent()->GetAngularVel() * gibSettingsObject.InheritsVelocity()) / c_PPM;
+ Vector rotationalVelocity = (offsetFromRootParent.GetPerpendicular() * GetRootParent()->GetAngularVel() * gibSettingsObject->InheritsVelocity()) / c_PPM;
gibVelocity += rotationalVelocity;
- gibParticleClone->SetAngularVel(gibParticleClone->GetAngularVel() + GetRootParent()->GetAngularVel() * gibSettingsObject.InheritsAngularVelocity());
+ gibParticleClone->SetAngularVel(gibParticleClone->GetAngularVel() + GetRootParent()->GetAngularVel() * gibSettingsObject->InheritsAngularVelocity());
if (lifetime != 0) {
gibParticleClone->SetLifetime(std::max(static_cast(static_cast(lifetime) * (1.0F - lifeVariation * ((radius / maxRadius) * 0.75F + RandomNormalNum() * 0.25F))), 1));
}
gibParticleClone->SetRotAngle(gibVelocity.GetAbsRadAngle() + (m_HFlipped ? c_PI : 0));
gibParticleClone->SetAngularVel((gibParticleClone->GetAngularVel() * 0.35F) + (gibParticleClone->GetAngularVel() * 0.65F / mass) * RandomNum());
- gibParticleClone->SetVel(gibVelocity + ((m_PrevVel + m_Vel) / 2) * gibSettingsObject.InheritsVelocity());
+ gibParticleClone->SetVel(gibVelocity + ((m_PrevVel + m_Vel) / 2) * gibSettingsObject->InheritsVelocity());
if (movableObjectToIgnore) {
gibParticleClone->SetWhichMOToNotHit(movableObjectToIgnore);
}
- if (gibSettingsObject.IgnoresTeamHits()) {
+ if (gibSettingsObject->IgnoresTeamHits()) {
gibParticleClone->SetTeam(m_Team);
gibParticleClone->SetIgnoresTeamHits(true);
}
@@ -985,7 +989,7 @@ void MOSRotating::CreateGibsWhenGibbing(const Vector& impactImpulse, MovableObje
} else {
for (int i = 0; i < count; i++) {
if (i > 0) {
- gibParticleClone = dynamic_cast(gibSettingsObject.GetParticlePreset()->Clone());
+ gibParticleClone = dynamic_cast(gibSettingsObject->GetParticlePreset()->Clone());
}
if (gibParticleClone->GetLifetime() != 0) {
@@ -1009,7 +1013,7 @@ void MOSRotating::CreateGibsWhenGibbing(const Vector& impactImpulse, MovableObje
// TODO: Figure out how much the magnitude of an offset should affect spread
float gibSpread = (rotatedGibOffset.IsZero() && spread == 0.1F) ? c_PI : spread;
// Determine the primary direction of the gib particles.
- if (gibSettingsObject.InheritsVelocity() > 0 && !impactImpulse.IsZero()) {
+ if (gibSettingsObject->InheritsVelocity() > 0 && !impactImpulse.IsZero()) {
gibVelocity.RadRotate(impactImpulse.GetAbsRadAngle());
} else if (!rotatedGibOffset.IsZero()) {
gibVelocity.RadRotate(rotatedGibOffset.GetAbsRadAngle());
@@ -1017,23 +1021,23 @@ void MOSRotating::CreateGibsWhenGibbing(const Vector& impactImpulse, MovableObje
gibVelocity.RadRotate(m_Rotation.GetRadAngle() + (m_HFlipped ? c_PI : 0));
}
// The "Even" spread will spread all gib particles evenly in an arc, while maintaining a randomized velocity magnitude.
- if (gibSettingsObject.GetSpreadMode() == Gib::SpreadMode::SpreadEven) {
+ if (gibSettingsObject->GetSpreadMode() == Gib::SpreadMode::SpreadEven) {
gibVelocity.RadRotate(gibSpread - (gibSpread * 2.0F * static_cast(i) / static_cast(count)));
} else {
gibVelocity.RadRotate(gibSpread * RandomNormalNum());
}
Vector offsetFromRootParent = m_Pos - GetRootParent()->GetPos() + rotatedGibOffset;
- Vector rotationalVelocity = (offsetFromRootParent.GetPerpendicular() * GetRootParent()->GetAngularVel() * gibSettingsObject.InheritsVelocity()) / c_PPM;
+ Vector rotationalVelocity = (offsetFromRootParent.GetPerpendicular() * GetRootParent()->GetAngularVel() * gibSettingsObject->InheritsVelocity()) / c_PPM;
gibVelocity += rotationalVelocity;
- gibParticleClone->SetAngularVel(gibParticleClone->GetAngularVel() + GetRootParent()->GetAngularVel() * gibSettingsObject.InheritsAngularVelocity());
+ gibParticleClone->SetAngularVel(gibParticleClone->GetAngularVel() + GetRootParent()->GetAngularVel() * gibSettingsObject->InheritsAngularVelocity());
- gibParticleClone->SetVel(gibVelocity + ((m_PrevVel + m_Vel) / 2) * gibSettingsObject.InheritsVelocity());
+ gibParticleClone->SetVel(gibVelocity + ((m_PrevVel + m_Vel) / 2) * gibSettingsObject->InheritsVelocity());
if (movableObjectToIgnore) {
gibParticleClone->SetWhichMOToNotHit(movableObjectToIgnore);
}
- if (gibSettingsObject.IgnoresTeamHits()) {
+ if (gibSettingsObject->IgnoresTeamHits()) {
gibParticleClone->SetTeam(m_Team);
gibParticleClone->SetIgnoresTeamHits(true);
}
diff --git a/Source/Entities/MOSRotating.h b/Source/Entities/MOSRotating.h
index f0ad18708..967af352c 100644
--- a/Source/Entities/MOSRotating.h
+++ b/Source/Entities/MOSRotating.h
@@ -146,7 +146,7 @@ namespace RTE {
/// Gets direct access to the list of object this is to generate upon gibbing.
/// @return A pointer to the list of gibs. Ownership is NOT transferred!
- std::list* GetGibList() { return &m_Gibs; }
+ std::list* GetGibList() { return &m_Gibs; }
/// Adds graphical recoil offset to this MOSprite according to its angle.
void AddRecoil();
@@ -559,7 +559,7 @@ namespace RTE {
float m_FarthestAttachableDistanceAndRadius; //!< The distance + radius of the radius affecting Attachable.
float m_AttachableAndWoundMass; //!< The mass of all Attachables and wounds on this MOSRotating. Used in combination with its actual mass and any other affecting factors to get its total mass.
// The list of Gib:s this will create when gibbed
- std::list m_Gibs;
+ std::list m_Gibs;
// The amount of impulse force required to gib this, in kg * (m/s). 0 means no limit
float m_GibImpulseLimit;
int m_GibWoundLimit; //!< The number of wounds that will gib this MOSRotating. 0 means that it can't be gibbed via wounds.
diff --git a/Source/Entities/PEmitter.cpp b/Source/Entities/PEmitter.cpp
index 39407274a..f0637098c 100644
--- a/Source/Entities/PEmitter.cpp
+++ b/Source/Entities/PEmitter.cpp
@@ -58,8 +58,8 @@ int PEmitter::Create() {
int PEmitter::Create(const PEmitter& reference) {
MOSParticle::Create(reference);
- for (auto itr = reference.m_EmissionList.begin(); itr != reference.m_EmissionList.end(); ++itr) {
- m_EmissionList.push_back(*itr);
+ for (Emission* emission: reference.m_EmissionList) {
+ m_EmissionList.push_back(static_cast(emission->Clone()));
}
m_EmissionSound = reference.m_EmissionSound;
m_BurstSound = reference.m_BurstSound;
@@ -89,38 +89,35 @@ int PEmitter::Create(const PEmitter& reference) {
int PEmitter::ReadProperty(const std::string_view& propName, Reader& reader) {
StartPropertyList(return MOSParticle::ReadProperty(propName, reader));
- MatchProperty("AddEmission",
- {
- Emission emission;
- reader >> emission;
- m_EmissionList.push_back(emission);
- });
+ MatchProperty("AddEmission", {
+ Emission* emission = new Emission();
+ reader >> *emission;
+ m_EmissionList.push_back(emission);
+ });
MatchProperty("EmissionSound", { reader >> m_EmissionSound; });
MatchProperty("BurstSound", { reader >> m_BurstSound; });
MatchProperty("EndSound", { reader >> m_EndSound; });
MatchProperty("EmissionEnabled", { reader >> m_EmitEnabled; });
MatchProperty("EmissionCount", { reader >> m_EmitCount; });
MatchProperty("EmissionCountLimit", { reader >> m_EmitCountLimit; });
- MatchProperty("ParticlesPerMinute",
- {
- float ppm;
- reader >> ppm;
- // Go through all emissions and set the rate so that it emulates the way it used to work, for mod backwards compatibility
- for (auto eItr = m_EmissionList.begin(); eItr != m_EmissionList.end(); ++eItr)
- (*eItr).m_PPM = ppm / m_EmissionList.size();
- });
+ MatchProperty("ParticlesPerMinute", {
+ float ppm;
+ reader >> ppm;
+ // Go through all emissions and set the rate so that it emulates the way it used to work, for mod backwards compatibility
+ for (Emission* emission: m_EmissionList)
+ emission->m_PPM = ppm / m_EmissionList.size();
+ });
MatchProperty("NegativeThrottleMultiplier", { reader >> m_NegativeThrottleMultiplier; });
MatchProperty("PositiveThrottleMultiplier", { reader >> m_PositiveThrottleMultiplier; });
MatchProperty("Throttle", { reader >> m_Throttle; });
MatchProperty("EmissionsIgnoreThis", { reader >> m_EmissionsIgnoreThis; });
- MatchProperty("BurstSize",
- {
- int burstSize;
- reader >> burstSize;
- // Go through all emissions and set the rate so that it emulates the way it used to work, for mod backwards compatibility
- for (auto eItr = m_EmissionList.begin(); eItr != m_EmissionList.end(); ++eItr)
- (*eItr).m_BurstSize = std::ceil((float)burstSize / (float)m_EmissionList.size());
- });
+ MatchProperty("BurstSize", {
+ int burstSize;
+ reader >> burstSize;
+ // Go through all emissions and set the rate so that it emulates the way it used to work, for mod backwards compatibility
+ for (Emission* emission: m_EmissionList)
+ emission->m_BurstSize = std::ceil((float)burstSize / (float)m_EmissionList.size());
+ });
MatchProperty("BurstScale", { reader >> m_BurstScale; });
MatchProperty("BurstSpacing", { reader >> m_BurstSpacing; });
MatchProperty("BurstTriggered", { reader >> m_BurstTriggered; });
@@ -139,9 +136,9 @@ int PEmitter::ReadProperty(const std::string_view& propName, Reader& reader) {
int PEmitter::Save(Writer& writer) const {
MOSParticle::Save(writer);
- for (auto itr = m_EmissionList.begin(); itr != m_EmissionList.end(); ++itr) {
+ for (Emission* emission: m_EmissionList) {
writer.NewProperty("AddEmission");
- writer << *itr;
+ writer << *emission;
}
writer.NewProperty("EmissionSound");
writer << m_EmissionSound;
@@ -191,10 +188,15 @@ int PEmitter::Save(Writer& writer) const {
void PEmitter::Destroy(bool notInherited) {
// Stop playback of sounds gracefully
- if (m_EmissionSound.IsBeingPlayed())
+ if (m_EmissionSound.IsBeingPlayed()) {
m_EndSound.Play(m_Pos);
- else
+ } else {
m_EndSound.Stop();
+ }
+
+ for (Emission* emission: m_EmissionList) {
+ delete emission;
+ }
m_EmissionSound.Stop();
// m_BurstSound.Stop();
@@ -206,8 +208,8 @@ void PEmitter::Destroy(bool notInherited) {
void PEmitter::ResetEmissionTimers() {
m_LastEmitTmr.Reset();
- for (auto eItr = m_EmissionList.begin(); eItr != m_EmissionList.end(); ++eItr)
- (*eItr).ResetEmissionTimers();
+ for (Emission* emission: m_EmissionList)
+ emission->ResetEmissionTimers();
}
void PEmitter::EnableEmission(bool enable) {
@@ -228,22 +230,22 @@ float PEmitter::EstimateImpulse(bool burst) {
float velMin, velMax, velRange, spread;
// Go through all emissions and emit them according to their respective rates
- for (auto eItr = m_EmissionList.begin(); eItr != m_EmissionList.end(); ++eItr) {
+ for (Emission* emission: m_EmissionList) {
// Only check emissions that push the emitter
- if ((*eItr).PushesEmitter()) {
- float emissions = ((*eItr).GetRate() / 60.0f) * g_TimerMan.GetDeltaTimeSecs();
+ if (emission->PushesEmitter()) {
+ float emissions = (emission->GetRate() / 60.0f) * g_TimerMan.GetDeltaTimeSecs();
float scale = 1.0F;
if (burst) {
- emissions *= (*eItr).GetBurstSize();
+ emissions *= emission->GetBurstSize();
scale = m_BurstScale;
}
- velMin = (*eItr).GetMinVelocity() * scale;
- velRange = ((*eItr).GetMaxVelocity() - (*eItr).GetMinVelocity()) * 0.5F * scale;
- spread = (std::max(static_cast(c_PI) - (*eItr).GetSpread(), 0.0F) / c_PI) * scale; // A large spread will cause the forces to cancel eachother out
+ velMin = emission->GetMinVelocity() * scale;
+ velRange = (emission->GetMaxVelocity() - emission->GetMinVelocity()) * 0.5F * scale;
+ spread = (std::max(static_cast(c_PI) - emission->GetSpread(), 0.0F) / c_PI) * scale; // A large spread will cause the forces to cancel eachother out
// Add to accumulative recoil impulse generated, F = m * a.
- impulse += (velMin + velRange) * spread * (*eItr).m_pEmission->GetMass() * emissions;
+ impulse += (velMin + velRange) * spread * emission->m_pEmission->GetMass() * emissions;
}
}
@@ -284,8 +286,8 @@ void PEmitter::Update() {
m_EmissionSound.Play(m_Pos);
// Reset the timers of all emissions so they will start/stop at the correct relative offsets from now
- for (Emission& emission: m_EmissionList) {
- emission.ResetEmissionTimers();
+ for (Emission* emission: m_EmissionList) {
+ emission->ResetEmissionTimers();
}
}
// Update the distance attenuation
@@ -316,11 +318,11 @@ void PEmitter::Update() {
MovableObject* pParticle = 0;
Vector parentVel, emitVel, pushImpulses;
// Go through all emissions and emit them according to their respective rates
- for (Emission& emission: m_EmissionList) {
+ for (Emission* emission: m_EmissionList) {
// Make sure the emissions only happen between the start time and end time
- if (emission.IsEmissionTime()) {
+ if (emission->IsEmissionTime()) {
// Apply the throttle factor to the emission rate
- currentPPM = emission.GetRate() * throttleFactor;
+ currentPPM = emission->GetRate() * throttleFactor;
emissions = 0;
// Only do all this if the PPM is acutally above zero
@@ -329,30 +331,30 @@ void PEmitter::Update() {
SPE = 60.0 / currentPPM;
// Add the last elapsed time to the accumulator
- emission.m_Accumulator += m_LastEmitTmr.GetElapsedSimTimeS();
+ emission->m_Accumulator += m_LastEmitTmr.GetElapsedSimTimeS();
// Now figure how many full emissions can fit in the current accumulator
- emissions = std::floor(emission.m_Accumulator / SPE);
+ emissions = std::floor(emission->m_Accumulator / SPE);
// Deduct the about to be emitted emissions from the accumulator
- emission.m_Accumulator -= emissions * SPE;
+ emission->m_Accumulator -= emissions * SPE;
- RTEAssert(emission.m_Accumulator >= 0, "Emission accumulator negative!");
+ RTEAssert(emission->m_Accumulator >= 0, "Emission accumulator negative!");
}
// Add extra emissions if bursting.
if (m_BurstTriggered)
- emissions += emission.GetBurstSize() * std::floor(throttleFactor);
+ emissions += emission->GetBurstSize() * std::floor(throttleFactor);
pParticle = 0;
emitVel.Reset();
- parentVel = pRootParent->GetVel() * emission.InheritsVelocity();
+ parentVel = pRootParent->GetVel() * emission->InheritsVelocity();
for (int i = 0; i < emissions; ++i) {
- velMin = emission.GetMinVelocity() * (m_BurstTriggered ? m_BurstScale : 1.0);
- velRange = emission.GetMaxVelocity() - emission.GetMinVelocity() * (m_BurstTriggered ? m_BurstScale : 1.0);
- spread = emission.GetSpread() * (m_BurstTriggered ? m_BurstScale : 1.0);
+ velMin = emission->GetMinVelocity() * (m_BurstTriggered ? m_BurstScale : 1.0);
+ velRange = emission->GetMaxVelocity() - emission->GetMinVelocity() * (m_BurstTriggered ? m_BurstScale : 1.0);
+ spread = emission->GetSpread() * (m_BurstTriggered ? m_BurstScale : 1.0);
// Make a copy after the reference particle
- pParticle = dynamic_cast(emission.GetEmissionParticlePreset()->Clone());
+ pParticle = dynamic_cast(emission->GetEmissionParticlePreset()->Clone());
// Set up its position and velocity according to the parameters of this.
// Emission point offset not set
if (m_EmissionOffset.IsZero())
@@ -366,14 +368,14 @@ void PEmitter::Update() {
pParticle->SetVel(parentVel + emitVel);
if (pParticle->GetLifetime() != 0) {
- pParticle->SetLifetime(std::max(static_cast(pParticle->GetLifetime() * (1.0F + (emission.GetLifeVariation() * RandomNormalNum()))), 1));
+ pParticle->SetLifetime(std::max(static_cast(pParticle->GetLifetime() * (1.0F + (emission->GetLifeVariation() * RandomNormalNum()))), 1));
}
pParticle->SetTeam(m_Team);
pParticle->SetIgnoresTeamHits(true);
// Add to accumulative recoil impulse generated, F = m * a
// If enabled, that is
- if (emission.PushesEmitter())
+ if (emission->PushesEmitter())
pushImpulses -= emitVel * pParticle->GetMass();
// Set the emitted particle to not hit this emitter's parent, if applicable
diff --git a/Source/Entities/PEmitter.h b/Source/Entities/PEmitter.h
index 637745ae8..48f3bef00 100644
--- a/Source/Entities/PEmitter.h
+++ b/Source/Entities/PEmitter.h
@@ -280,7 +280,7 @@ namespace RTE {
static Entity::ClassInfo m_sClass;
// The list of MO instances that get emitted
- std::vector m_EmissionList;
+ std::list m_EmissionList;
// Sounds
SoundContainer m_EmissionSound;
SoundContainer m_BurstSound;
diff --git a/Source/Entities/Scene.cpp b/Source/Entities/Scene.cpp
index e7c4f7daf..f99f0a4f4 100644
--- a/Source/Entities/Scene.cpp
+++ b/Source/Entities/Scene.cpp
@@ -58,8 +58,7 @@ void Scene::Area::Clear() {
}
int Scene::Area::Create(const Area& reference) {
- for (std::vector::const_iterator itr = reference.m_BoxList.begin(); itr != reference.m_BoxList.end(); ++itr)
- m_BoxList.push_back(*itr);
+ for (Box* box: reference.m_BoxList) m_BoxList.push_back(new Box(*box));
m_Name = reference.m_Name;
@@ -77,8 +76,8 @@ int Scene::Area::ReadProperty(const std::string_view& propName, Reader& reader)
StartPropertyList(return Serializable::ReadProperty(propName, reader));
MatchProperty("AddBox",
- Box box;
- reader >> box;
+ Box* box = new Box;
+ reader >> *box;
m_BoxList.push_back(box););
MatchProperty("Name", { reader >> m_Name; });
@@ -88,9 +87,9 @@ int Scene::Area::ReadProperty(const std::string_view& propName, Reader& reader)
int Scene::Area::Save(Writer& writer) const {
Serializable::Save(writer);
- for (std::vector::const_iterator itr = m_BoxList.begin(); itr != m_BoxList.end(); ++itr) {
+ for (Box* box: m_BoxList) {
writer.NewProperty("AddBox");
- writer << *itr;
+ writer << *box;
}
writer.NewProperty("Name");
writer << m_Name;
@@ -98,6 +97,14 @@ int Scene::Area::Save(Writer& writer) const {
return 0;
}
+void Scene::Area::Destroy(bool notInherited) {
+ for (Box* box: m_BoxList) {
+ delete box;
+ }
+
+ Clear();
+}
+
// Having a mutex on all areas is fugly, but this is only really useful to stop async pathfinding getting fucked by the list changing underneath us
// TODO: Something much, much better
static std::shared_mutex g_sceneAreaMutex;
@@ -108,14 +115,14 @@ bool Scene::Area::AddBox(const Box& newBox) {
}
std::unique_lock guard(g_sceneAreaMutex);
- m_BoxList.push_back(newBox);
+ m_BoxList.push_back(new Box(newBox));
return true;
}
bool Scene::Area::RemoveBox(const Box& boxToRemove) {
std::unique_lock guard(g_sceneAreaMutex);
- std::vector::iterator boxToRemoveIterator = std::find(m_BoxList.begin(), m_BoxList.end(), boxToRemove);
+ std::vector::iterator boxToRemoveIterator = std::find(m_BoxList.begin(), m_BoxList.end(), &boxToRemove);
if (boxToRemoveIterator != m_BoxList.end()) {
m_BoxList.erase(boxToRemoveIterator);
return true;
@@ -131,8 +138,8 @@ bool Scene::Area::HasNoArea() const {
// Search through the boxes to see if we find any with both width and height
std::shared_lock guard(g_sceneAreaMutex);
- for (std::vector::const_iterator itr = m_BoxList.begin(); itr != m_BoxList.end(); ++itr) {
- if (!itr->IsEmpty())
+ for (Box* box: m_BoxList) {
+ if (!box->IsEmpty())
return false;
}
@@ -143,10 +150,10 @@ bool Scene::Area::IsInside(const Vector& point) const {
std::shared_lock guard(g_sceneAreaMutex);
std::list wrappedBoxes;
- for (std::vector::const_iterator aItr = m_BoxList.begin(); aItr != m_BoxList.end(); ++aItr) {
+ for (Box* box: m_BoxList) {
// Handle wrapped boxes properly
wrappedBoxes.clear();
- g_SceneMan.WrapBox(*aItr, wrappedBoxes);
+ g_SceneMan.WrapBox(*box, wrappedBoxes);
// Iterate through the wrapped boxes - will only be one if there's no wrapping
for (std::list::iterator wItr = wrappedBoxes.begin(); wItr != wrappedBoxes.end(); ++wItr) {
@@ -161,10 +168,10 @@ bool Scene::Area::IsInsideX(float pointX) const {
std::shared_lock guard(g_sceneAreaMutex);
std::list wrappedBoxes;
- for (std::vector::const_iterator aItr = m_BoxList.begin(); aItr != m_BoxList.end(); ++aItr) {
+ for (Box* box: m_BoxList) {
// Handle wrapped boxes properly
wrappedBoxes.clear();
- g_SceneMan.WrapBox(*aItr, wrappedBoxes);
+ g_SceneMan.WrapBox(*box, wrappedBoxes);
// Iterate through the wrapped boxes - will only be one if there's no wrapping
for (std::list::iterator wItr = wrappedBoxes.begin(); wItr != wrappedBoxes.end(); ++wItr) {
@@ -179,10 +186,10 @@ bool Scene::Area::IsInsideY(float pointY) const {
std::shared_lock guard(g_sceneAreaMutex);
std::list wrappedBoxes;
- for (std::vector::const_iterator aItr = m_BoxList.begin(); aItr != m_BoxList.end(); ++aItr) {
+ for (Box* box: m_BoxList) {
// Handle wrapped boxes properly
wrappedBoxes.clear();
- g_SceneMan.WrapBox(*aItr, wrappedBoxes);
+ g_SceneMan.WrapBox(*box, wrappedBoxes);
// Iterate through the wrapped boxes - will only be one if there's no wrapping
for (std::list::iterator wItr = wrappedBoxes.begin(); wItr != wrappedBoxes.end(); ++wItr) {
@@ -205,10 +212,10 @@ bool Scene::Area::MovePointInsideX(float& pointX, int direction) const {
float shortestConstrained = notFoundValue;
float testDistance = 0;
std::list wrappedBoxes;
- for (std::vector::const_iterator aItr = m_BoxList.begin(); aItr != m_BoxList.end(); ++aItr) {
+ for (Box* box: m_BoxList) {
// Handle wrapped boxes properly
wrappedBoxes.clear();
- g_SceneMan.WrapBox(*aItr, wrappedBoxes);
+ g_SceneMan.WrapBox(*box, wrappedBoxes);
// Iterate through the wrapped boxes - will only be one if there's no wrapping
for (std::list::const_iterator wItr = wrappedBoxes.begin(); wItr != wrappedBoxes.end(); ++wItr) {
@@ -251,16 +258,16 @@ Box* Scene::Area::GetBoxInside(const Vector& point) {
std::shared_lock guard(g_sceneAreaMutex);
std::list wrappedBoxes;
- for (std::vector::iterator aItr = m_BoxList.begin(); aItr != m_BoxList.end(); ++aItr) {
+ for (Box* box: m_BoxList) {
// Handle wrapped boxes properly
wrappedBoxes.clear();
- g_SceneMan.WrapBox(*aItr, wrappedBoxes);
+ g_SceneMan.WrapBox(*box, wrappedBoxes);
// Iterate through the wrapped boxes - will only be one if there's no wrapping
for (std::list::const_iterator wItr = wrappedBoxes.begin(); wItr != wrappedBoxes.end(); ++wItr) {
// Return the BoxList box, not the inconsequential wrapped copy
if (wItr->IsWithinBox(point))
- return &(*aItr);
+ return &(*box);
}
}
return 0;
@@ -272,16 +279,16 @@ Box Scene::Area::RemoveBoxInside(const Vector& point) {
Box returnBox;
std::list wrappedBoxes;
- for (std::vector::iterator aItr = m_BoxList.begin(); aItr != m_BoxList.end(); ++aItr) {
+ for (std::vector::iterator aItr = m_BoxList.begin(); aItr != m_BoxList.end(); ++aItr) {
// Handle wrapped boxes properly
wrappedBoxes.clear();
- g_SceneMan.WrapBox(*aItr, wrappedBoxes);
+ g_SceneMan.WrapBox(**aItr, wrappedBoxes);
// Iterate through the wrapped boxes - will only be one if there's no wrapping
for (std::list::iterator wItr = wrappedBoxes.begin(); wItr != wrappedBoxes.end(); ++wItr) {
if (wItr->IsWithinBox(point)) {
// Remove the BoxList box, not the inconsequential wrapped copy
- returnBox = (*aItr);
+ returnBox = (**aItr);
m_BoxList.erase(aItr);
return returnBox;
}
@@ -296,14 +303,14 @@ Vector Scene::Area::GetCenterPoint() const {
Vector areaCenter;
if (!m_BoxList.empty()) {
if (m_BoxList.size() == 1) {
- return m_BoxList[0].GetCenter();
+ return m_BoxList[0]->GetCenter();
}
float totalWeight = 0;
- for (std::vector::const_iterator itr = m_BoxList.begin(); itr != m_BoxList.end(); ++itr) {
+ for (Box* box: m_BoxList) {
// Doubly weighted
- areaCenter += (*itr).GetCenter() * (*itr).GetArea() * 2;
- totalWeight += (*itr).GetArea() * 2;
+ areaCenter += box->GetCenter() * box->GetArea() * 2;
+ totalWeight += box->GetArea() * 2;
}
// Average center of the all the boxes, weighted by their respective areas
areaCenter /= totalWeight;
@@ -320,7 +327,7 @@ Vector Scene::Area::GetRandomPoint() const {
// Randomly choose a box, and a point within it
std::shared_lock guard(g_sceneAreaMutex);
- return m_BoxList[RandomNum(0, m_BoxList.size() - 1)].GetRandomPoint();
+ return m_BoxList[RandomNum(0, m_BoxList.size() - 1)]->GetRandomPoint();
}
void Scene::Clear() {
@@ -424,8 +431,8 @@ int Scene::Create(const Scene& reference) {
}
// Copy areas
- for (std::list::const_iterator aItr = reference.m_AreaList.begin(); aItr != reference.m_AreaList.end(); ++aItr)
- m_AreaList.push_back(*aItr);
+ for (Area* area: reference.m_AreaList)
+ m_AreaList.push_back(new Area(*area));
m_GlobalAcc = reference.m_GlobalAcc;
@@ -1149,11 +1156,11 @@ int Scene::Save(Writer& writer) const {
writer.NewProperty("ScanScheduledTeam4");
writer << m_ScanScheduled[Activity::TeamFour];
}
- for (std::list::const_iterator aItr = m_AreaList.begin(); aItr != m_AreaList.end(); ++aItr) {
+ for (Area* area: m_AreaList) {
// Only write the area if it has any boxes/area at all
- if (doFullGameSave || !(*aItr).HasNoArea()) {
+ if (doFullGameSave || !(*area).HasNoArea()) {
writer.NewProperty("AddArea");
- writer << *aItr;
+ writer << *area;
}
}
writer.NewProperty("GlobalAcceleration");
@@ -1436,6 +1443,9 @@ void Scene::Destroy(bool notInherited) {
*slItr = 0;
}
+ for (Area* area: m_AreaList)
+ delete area;
+
delete m_apUnseenLayer[Activity::TeamOne];
delete m_apUnseenLayer[Activity::TeamTwo];
delete m_apUnseenLayer[Activity::TeamThree];
@@ -1833,33 +1843,34 @@ int Scene::GetResidentBrainCount() const {
}
bool Scene::SetArea(Area& newArea) {
- for (std::list::iterator aItr = m_AreaList.begin(); aItr != m_AreaList.end(); ++aItr) {
+ for (Area* area: m_AreaList) {
// Try to find an existing area of the same name
- if ((*aItr).GetName() == newArea.GetName()) {
+ if (area->GetName() == newArea.GetName()) {
// Deep copy into the existing area
- (*aItr).Reset();
- (*aItr).Create(newArea);
+ area->Reset();
+ area->Create(newArea);
return true;
}
}
// Couldn't find one, so just add the new Area
- m_AreaList.push_back(newArea);
+ m_AreaList.push_back(new Area(newArea));
return false;
}
bool Scene::HasArea(const std::string& areaName) {
- for (std::list::iterator aItr = m_AreaList.begin(); aItr != m_AreaList.end(); ++aItr) {
- if ((*aItr).GetName() == areaName)
+ for (Area* area: m_AreaList) {
+ if (area->GetName() == areaName) {
return true;
+ }
}
return false;
}
Scene::Area* Scene::GetArea(const std::string& areaName) {
- for (Scene::Area& area: m_AreaList) {
- if (area.GetName() == areaName) {
- return &area;
+ for (Scene::Area*& area: m_AreaList) {
+ if (area->GetName() == areaName) {
+ return area;
}
}
@@ -1867,8 +1878,8 @@ Scene::Area* Scene::GetArea(const std::string& areaName) {
}
bool Scene::RemoveArea(const std::string& areaName) {
- for (std::list::iterator aItr = m_AreaList.begin(); aItr != m_AreaList.end(); ++aItr) {
- if ((*aItr).GetName() == areaName) {
+ for (std::list::iterator aItr = m_AreaList.begin(); aItr != m_AreaList.end(); ++aItr) {
+ if ((*aItr)->GetName() == areaName) {
m_AreaList.erase(aItr);
return true;
}
@@ -1880,8 +1891,8 @@ bool Scene::WithinArea(const std::string& areaName, const Vector& point) const {
if (areaName.empty())
return false;
- for (std::list::const_iterator aItr = m_AreaList.begin(); aItr != m_AreaList.end(); ++aItr) {
- if ((*aItr).GetName() == areaName && (*aItr).IsInside(point))
+ for (std::list::const_iterator aItr = m_AreaList.begin(); aItr != m_AreaList.end(); ++aItr) {
+ if ((*aItr)->GetName() == areaName && (*aItr)->IsInside(point))
return true;
}
@@ -2447,8 +2458,8 @@ void Scene::Update() {
for (const std::string& navigableArea: m_NavigableAreas) {
if (HasArea(navigableArea)) {
- for (const Box& navigableBox: GetArea(navigableArea)->GetBoxes()) {
- pathFinder.MarkBoxNavigable(navigableBox, true);
+ for (const Box* navigableBox: GetArea(navigableArea)->GetBoxes()) {
+ pathFinder.MarkBoxNavigable(*navigableBox, true);
}
}
}
diff --git a/Source/Entities/Scene.h b/Source/Entities/Scene.h
index 60ee11a62..2c98766f8 100644
--- a/Source/Entities/Scene.h
+++ b/Source/Entities/Scene.h
@@ -85,6 +85,10 @@ namespace RTE {
/// Anything below 0 is an error signal.
int Create(const Area& reference);
+ /// Destroys and resets (through Clear()) the Area object.
+ /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also.
+ void Destroy(bool notInherited);
+
/// Resets the entire Serializable, including its inherited members, to their
/// default settings or values.
void Reset() override { Clear(); }
@@ -101,11 +105,11 @@ namespace RTE {
/// Gets the first Box in this Area.
/// @return The first Box in this Area.
- const Box* GetFirstBox() const { return m_BoxList.empty() ? nullptr : &m_BoxList[0]; }
+ const Box* GetFirstBox() const { return m_BoxList.empty() ? nullptr : m_BoxList[0]; }
/// Gets the boxes for this area.
/// @return The boxes in this Area.
- const std::vector& GetBoxes() const { return m_BoxList; }
+ const std::vector& GetBoxes() const { return m_BoxList; }
/// Shows whether this really has no Area at all, ie it doesn't have any
/// Box:es with both width and height.
@@ -164,7 +168,7 @@ namespace RTE {
/// Protected member variable and method declarations
protected:
// The list of Box:es defining the Area in the owner Scene
- std::vector m_BoxList;
+ std::vector m_BoxList;
// The name tag of this Area
std::string m_Name;
@@ -341,7 +345,7 @@ namespace RTE {
/// Adds area to the list if this scene's areas.
/// @param m_AreaList.push_back(newArea Area to add.
- void AddArea(Scene::Area& newArea) { m_AreaList.push_back(newArea); }
+ void AddArea(Scene::Area& newArea) { m_AreaList.push_back(new Scene::Area(newArea)); }
/// Creates a new SceneLayer for a specific team and fills it with black
/// pixels that end up being a specific size on the screen.
@@ -757,7 +761,7 @@ namespace RTE {
bool m_ScanScheduled[Activity::MaxTeamCount];
// List of all the specified Area's of the scene
- std::list m_AreaList;
+ std::list m_AreaList;
// List of navigable areas in the scene. If this list is empty, the entire scene is assumed to be navigable
std::vector m_NavigableAreas;
diff --git a/Source/Entities/SoundSet.cpp b/Source/Entities/SoundSet.cpp
index 8c885d9fd..a931c9347 100644
--- a/Source/Entities/SoundSet.cpp
+++ b/Source/Entities/SoundSet.cpp
@@ -34,9 +34,8 @@ int SoundSet::Create(const SoundSet& reference) {
for (SoundData referenceSoundData: reference.m_SoundData) {
m_SoundData.push_back(referenceSoundData);
}
- for (const SoundSet& referenceSoundSet: reference.m_SubSoundSets) {
- SoundSet soundSet;
- soundSet.Create(referenceSoundSet);
+ for (const SoundSet* referenceSoundSet: reference.m_SubSoundSets) {
+ SoundSet* soundSet = new SoundSet(*referenceSoundSet);
m_SubSoundSets.push_back(soundSet);
}
@@ -57,6 +56,46 @@ int SoundSet::ReadProperty(const std::string_view& propName, Reader& reader) {
EndPropertyList;
}
+int SoundSet::Save(Writer& writer) const {
+ Serializable::Save(writer);
+
+ writer.NewProperty("SoundSelectionCycleMode");
+ SaveSoundSelectionCycleMode(writer, m_SoundSelectionCycleMode);
+
+ for (const SoundData& soundData: m_SoundData) {
+ writer.NewProperty("AddSound");
+ writer.ObjectStart("ContentFile");
+
+ writer.NewProperty("FilePath");
+ writer << soundData.SoundFile.GetDataPath();
+ writer.NewProperty("Offset");
+ writer << soundData.Offset;
+ writer.NewProperty("MinimumAudibleDistance");
+ writer << soundData.MinimumAudibleDistance;
+ writer.NewProperty("AttenuationStartDistance");
+ writer << soundData.AttenuationStartDistance;
+
+ writer.ObjectEnd();
+ }
+
+ for (const SoundSet* subSoundSet: m_SubSoundSets) {
+ writer.NewProperty("AddSoundSet");
+ writer.ObjectStart("SoundSet");
+ writer << *subSoundSet;
+ writer.ObjectEnd();
+ }
+
+ return 0;
+}
+
+void SoundSet::Destroy() {
+ for (const SoundSet* subSoundSet: m_SubSoundSets) {
+ delete subSoundSet;
+ }
+
+ Clear();
+}
+
SoundData SoundSet::ReadAndGetSoundData(Reader& reader) {
SoundData soundData;
@@ -123,38 +162,6 @@ SoundSet::SoundSelectionCycleMode SoundSet::ReadSoundSelectionCycleMode(Reader&
return soundSelectionCycleModeToReturn;
}
-int SoundSet::Save(Writer& writer) const {
- Serializable::Save(writer);
-
- writer.NewProperty("SoundSelectionCycleMode");
- SaveSoundSelectionCycleMode(writer, m_SoundSelectionCycleMode);
-
- for (const SoundData& soundData: m_SoundData) {
- writer.NewProperty("AddSound");
- writer.ObjectStart("ContentFile");
-
- writer.NewProperty("FilePath");
- writer << soundData.SoundFile.GetDataPath();
- writer.NewProperty("Offset");
- writer << soundData.Offset;
- writer.NewProperty("MinimumAudibleDistance");
- writer << soundData.MinimumAudibleDistance;
- writer.NewProperty("AttenuationStartDistance");
- writer << soundData.AttenuationStartDistance;
-
- writer.ObjectEnd();
- }
-
- for (const SoundSet& subSoundSet: m_SubSoundSets) {
- writer.NewProperty("AddSoundSet");
- writer.ObjectStart("SoundSet");
- writer << subSoundSet;
- writer.ObjectEnd();
- }
-
- return 0;
-}
-
void SoundSet::SaveSoundSelectionCycleMode(Writer& writer, SoundSelectionCycleMode soundSelectionCycleMode) {
auto cycleModeMapEntry = std::find_if(c_SoundSelectionCycleModeMap.begin(), c_SoundSelectionCycleModeMap.end(), [&soundSelectionCycleMode = soundSelectionCycleMode](auto element) { return element.second == soundSelectionCycleMode; });
if (cycleModeMapEntry != c_SoundSelectionCycleModeMap.end()) {
@@ -181,7 +188,7 @@ bool SoundSet::RemoveSound(const std::string& soundFilePath, bool removeFromSubS
m_SoundData.erase(soundsToRemove, m_SoundData.end());
}
if (removeFromSubSoundSets) {
- for (SoundSet subSoundSet: m_SubSoundSets) {
+ for (SoundSet* subSoundSet: m_SubSoundSets) {
anySoundsToRemove |= RemoveSound(soundFilePath, removeFromSubSoundSets);
}
}
@@ -191,8 +198,8 @@ bool SoundSet::RemoveSound(const std::string& soundFilePath, bool removeFromSubS
bool SoundSet::HasAnySounds(bool includeSubSoundSets) const {
bool hasAnySounds = !m_SoundData.empty();
if (!hasAnySounds && includeSubSoundSets) {
- for (const SoundSet& subSoundSet: m_SubSoundSets) {
- hasAnySounds = subSoundSet.HasAnySounds();
+ for (const SoundSet* subSoundSet: m_SubSoundSets) {
+ hasAnySounds = subSoundSet->HasAnySounds();
if (hasAnySounds) {
break;
}
@@ -206,14 +213,14 @@ void SoundSet::GetFlattenedSoundData(std::vector& flattenedSoundData
for (SoundData& soundData: m_SoundData) {
flattenedSoundData.push_back(&soundData);
}
- for (SoundSet& subSoundSet: m_SubSoundSets) {
- subSoundSet.GetFlattenedSoundData(flattenedSoundData, onlyGetSelectedSoundData);
+ for (SoundSet* subSoundSet: m_SubSoundSets) {
+ subSoundSet->GetFlattenedSoundData(flattenedSoundData, onlyGetSelectedSoundData);
}
} else {
if (m_CurrentSelection.first == false) {
flattenedSoundData.push_back(&m_SoundData[m_CurrentSelection.second]);
} else {
- m_SubSoundSets[m_CurrentSelection.second].GetFlattenedSoundData(flattenedSoundData, onlyGetSelectedSoundData);
+ m_SubSoundSets[m_CurrentSelection.second]->GetFlattenedSoundData(flattenedSoundData, onlyGetSelectedSoundData);
}
}
}
@@ -223,22 +230,22 @@ void SoundSet::GetFlattenedSoundData(std::vector& flattenedSou
for (const SoundData& soundData: m_SoundData) {
flattenedSoundData.push_back(&soundData);
}
- for (const SoundSet& subSoundSet: m_SubSoundSets) {
- subSoundSet.GetFlattenedSoundData(flattenedSoundData, onlyGetSelectedSoundData);
+ for (const SoundSet* subSoundSet: m_SubSoundSets) {
+ subSoundSet->GetFlattenedSoundData(flattenedSoundData, onlyGetSelectedSoundData);
}
} else {
if (m_CurrentSelection.first == false) {
flattenedSoundData.push_back(&m_SoundData[m_CurrentSelection.second]);
} else {
- m_SubSoundSets[m_CurrentSelection.second].GetFlattenedSoundData(flattenedSoundData, onlyGetSelectedSoundData);
+ m_SubSoundSets[m_CurrentSelection.second]->GetFlattenedSoundData(flattenedSoundData, onlyGetSelectedSoundData);
}
}
}
bool SoundSet::SelectNextSounds() {
if (m_SoundSelectionCycleMode == SoundSelectionCycleMode::ALL) {
- for (SoundSet& subSoundSet: m_SubSoundSets) {
- if (!subSoundSet.SelectNextSounds()) {
+ for (SoundSet* subSoundSet: m_SubSoundSets) {
+ if (!subSoundSet->SelectNextSounds()) {
return false;
}
}
@@ -303,7 +310,7 @@ bool SoundSet::SelectNextSounds() {
}
if (m_CurrentSelection.first == true) {
- return m_SubSoundSets[m_CurrentSelection.second].SelectNextSounds();
+ return m_SubSoundSets[m_CurrentSelection.second]->SelectNextSounds();
}
return true;
diff --git a/Source/Entities/SoundSet.h b/Source/Entities/SoundSet.h
index 1cd7a8ef3..cce68adf6 100644
--- a/Source/Entities/SoundSet.h
+++ b/Source/Entities/SoundSet.h
@@ -44,7 +44,7 @@ namespace RTE {
~SoundSet();
/// Destroys and resets (through Clear()) the SoundSet object.
- void Destroy() { Clear(); }
+ void Destroy();
#pragma endregion
#pragma region INI Handling
@@ -107,7 +107,7 @@ namespace RTE {
/// Adds a copy of the passed in SoundSet as a sub SoundSet of this SoundSet. Ownership IS transferred!
/// @param soundSetToAdd A reference to the SoundSet to be copied in as a sub SoundSet of this SoundSet. Ownership IS transferred!
- void AddSoundSet(const SoundSet& soundSetToAdd) { m_SubSoundSets.push_back(soundSetToAdd); }
+ void AddSoundSet(const SoundSet& soundSetToAdd) { m_SubSoundSets.push_back(new SoundSet(soundSetToAdd)); }
#pragma endregion
#pragma region Getters and Setters
@@ -140,7 +140,7 @@ namespace RTE {
/// Gets the vector of SubSoundSets for this SoundSet.
/// @return The vector of SubSoundSets for this SoundSet.
- std::vector& GetSubSoundSets() { return m_SubSoundSets; }
+ std::vector& GetSubSoundSets() { return m_SubSoundSets; }
#pragma endregion
#pragma region Miscellaneous
@@ -163,7 +163,7 @@ namespace RTE {
std::pair m_CurrentSelection; //!< Whether the current selection is in the SoundData (false) or SoundSet (true) vector, and its index in the appropriate vector.
std::vector m_SoundData; //!< The SoundData available for selection in this SoundSet.
- std::vector m_SubSoundSets; //!< The sub SoundSets available for selection in this SoundSet.
+ std::vector m_SubSoundSets; //!< The sub SoundSets available for selection in this SoundSet.
/// Clears all the member variables of this SoundSet, effectively resetting the members of this abstraction level only.
void Clear();
diff --git a/Source/Lua/LuaBindingsEntities.cpp b/Source/Lua/LuaBindingsEntities.cpp
index 16834600b..fb6aa9c53 100644
--- a/Source/Lua/LuaBindingsEntities.cpp
+++ b/Source/Lua/LuaBindingsEntities.cpp
@@ -217,8 +217,8 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Actor) {
.property("MoveProximityLimit", &Actor::GetMoveProximityLimit, &Actor::SetMoveProximityLimit)
.def_readwrite("MOMoveTarget", &Actor::m_pMOMoveTarget)
- .def_readwrite("MovePath", &Actor::m_MovePath, luabind::return_stl_iterator)
- .def_readwrite("Inventory", &Actor::m_Inventory, luabind::return_stl_iterator)
+ .def_readonly("MovePath", &Actor::m_MovePath, luabind::return_stl_iterator)
+ .def_readonly("Inventory", &Actor::m_Inventory, luabind::return_stl_iterator)
.def("GetController", &Actor::GetController)
.def("IsPlayerControlled", &Actor::IsPlayerControlled)
@@ -372,7 +372,7 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, AEmitter) {
.property("TotalParticlesPerMinute", &AEmitter::GetTotalParticlesPerMinute)
.property("TotalBurstSize", &AEmitter::GetTotalBurstSize)
- .def_readwrite("Emissions", &AEmitter::m_EmissionList, luabind::return_stl_iterator)
+ .def_readonly("Emissions", &AEmitter::m_EmissionList, luabind::return_stl_iterator)
.def("IsEmitting", &AEmitter::IsEmitting)
.def("WasEmitting", &AEmitter::WasEmitting)
@@ -1042,7 +1042,7 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, PEmitter) {
.property("EmitCountLimit", &PEmitter::GetEmitCountLimit, &PEmitter::SetEmitCountLimit)
.property("FlashScale", &PEmitter::GetFlashScale, &PEmitter::SetFlashScale)
- .def_readwrite("Emissions", &PEmitter::m_EmissionList, luabind::return_stl_iterator)
+ .def_readonly("Emissions", &PEmitter::m_EmissionList, luabind::return_stl_iterator)
.def("IsEmitting", &PEmitter::IsEmitting)
.def("WasEmitting", &PEmitter::WasEmitting)
@@ -1180,8 +1180,8 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Scene) {
.property("GlobalAcc", &Scene::GetGlobalAcc, &Scene::SetGlobalAcc)
.property("ScenePathSize", &Scene::GetScenePathSize)
- .def_readwrite("Deployments", &Scene::m_Deployments, luabind::return_stl_iterator)
-
+ .def_readonly("Deployments", &Scene::m_Deployments, luabind::return_stl_iterator)
+ .def_readonly("Areas", &Scene::m_AreaList, luabind::return_stl_iterator)
.def_readonly("BackgroundLayers", &Scene::m_BackLayerList, luabind::return_stl_iterator)
.def("GetScenePath", &Scene::GetScenePath, luabind::return_stl_iterator)
@@ -1195,7 +1195,6 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Scene) {
.def("RetrieveResidentBrains", &Scene::RetrieveResidentBrains)
.def("GetResidentBrain", &Scene::GetResidentBrain)
.def("SetResidentBrain", &Scene::SetResidentBrain)
- .def_readwrite("Areas", &Scene::m_AreaList, luabind::return_stl_iterator)
.def("SetArea", &Scene::SetArea)
.def("HasArea", &Scene::HasArea)
.def("GetArea", &Scene::GetArea)
@@ -1229,8 +1228,9 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, SceneArea) {
.property("Center", &Scene::Area::GetCenterPoint)
.property("RandomPoint", &Scene::Area::GetRandomPoint)
+ .def_readonly("Boxes", &Scene::Area::m_BoxList, luabind::return_stl_iterator)
+
.def("Reset", &Scene::Area::Reset)
- .def_readwrite("Boxes", &Scene::Area::m_BoxList, luabind::return_stl_iterator)
.def("AddBox", &Scene::Area::AddBox)
.def("RemoveBox", &Scene::Area::RemoveBox)
.def("HasNoArea", &Scene::Area::HasNoArea)
diff --git a/Source/Lua/LuaBindingsManagers.cpp b/Source/Lua/LuaBindingsManagers.cpp
index 455f02d8d..abd84e4a5 100644
--- a/Source/Lua/LuaBindingsManagers.cpp
+++ b/Source/Lua/LuaBindingsManagers.cpp
@@ -102,7 +102,7 @@ LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, MetaMan) {
.property("PlayerTurn", &MetaMan::GetPlayerTurn)
.property("PlayerCount", &MetaMan::GetPlayerCount)
- .def_readwrite("Players", &MetaMan::m_Players, luabind::return_stl_iterator)
+ .def_readonly("Players", &MetaMan::m_Players, luabind::return_stl_iterator)
.def("GetTeamOfPlayer", &MetaMan::GetTeamOfPlayer)
.def("GetPlayer", &MetaMan::GetPlayer)
@@ -114,14 +114,14 @@ LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, MovableMan) {
.property("MaxDroppedItems", &MovableMan::GetMaxDroppedItems, &MovableMan::SetMaxDroppedItems)
- .def_readwrite("Actors", &MovableMan::m_Actors, luabind::return_stl_iterator)
- .def_readwrite("Items", &MovableMan::m_Items, luabind::return_stl_iterator)
- .def_readwrite("Particles", &MovableMan::m_Particles, luabind::return_stl_iterator)
- .def_readwrite("AddedActors", &MovableMan::m_AddedActors, luabind::return_stl_iterator)
- .def_readwrite("AddedItems", &MovableMan::m_AddedItems, luabind::return_stl_iterator)
- .def_readwrite("AddedParticles", &MovableMan::m_AddedParticles, luabind::return_stl_iterator)
- .def_readwrite("AlarmEvents", &MovableMan::m_AlarmEvents, luabind::return_stl_iterator)
- .def_readwrite("AddedAlarmEvents", &MovableMan::m_AddedAlarmEvents, luabind::return_stl_iterator)
+ .def_readonly("Actors", &MovableMan::m_Actors, luabind::return_stl_iterator)
+ .def_readonly("Items", &MovableMan::m_Items, luabind::return_stl_iterator)
+ .def_readonly("Particles", &MovableMan::m_Particles, luabind::return_stl_iterator)
+ .def_readonly("AddedActors", &MovableMan::m_AddedActors, luabind::return_stl_iterator)
+ .def_readonly("AddedItems", &MovableMan::m_AddedItems, luabind::return_stl_iterator)
+ .def_readonly("AddedParticles", &MovableMan::m_AddedParticles, luabind::return_stl_iterator)
+ .def_readonly("AlarmEvents", &MovableMan::m_AlarmEvents, luabind::return_stl_iterator)
+ .def_readonly("AddedAlarmEvents", &MovableMan::m_AddedAlarmEvents, luabind::return_stl_iterator)
.def("GetMOFromID", &MovableMan::GetMOFromID)
.def("FindObjectByUniqueID", &MovableMan::FindObjectByUniqueID)
@@ -192,7 +192,7 @@ LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, PostProcessMan)
LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, PresetMan) {
return luabind::class_("PresetManager")
- .def_readwrite("Modules", &PresetMan::m_pDataModules, luabind::return_stl_iterator)
+ .def_readonly("Modules", &PresetMan::m_pDataModules, luabind::return_stl_iterator)
.def("LoadDataModule", (bool(PresetMan::*)(const std::string&)) & PresetMan::LoadDataModule)
.def("GetDataModule", &PresetMan::GetDataModule)
diff --git a/Source/Managers/MetaMan.cpp b/Source/Managers/MetaMan.cpp
index 5d2b8cbc2..e7cc7ace2 100644
--- a/Source/Managers/MetaMan.cpp
+++ b/Source/Managers/MetaMan.cpp
@@ -210,8 +210,8 @@ int MetaMan::ReadProperty(const std::string_view& propName, Reader& reader) {
MatchProperty("GameName", { reader >> m_GameName; });
MatchProperty("AddPlayer",
{
- MetaPlayer player;
- reader >> player;
+ MetaPlayer* player = new MetaPlayer();
+ reader >> *player;
m_Players.push_back(player);
});
MatchProperty("TeamCount", { reader >> m_TeamCount; });
@@ -255,8 +255,8 @@ int MetaMan::Save(Writer& writer) const {
writer.NewPropertyWithValue("Team3AISkill", m_TeamAISkill[Activity::TeamThree]);
writer.NewPropertyWithValue("Team4AISkill", m_TeamAISkill[Activity::TeamFour]);
- for (const MetaPlayer& metaPlayer: m_Players) {
- writer.NewPropertyWithValue("AddPlayer", metaPlayer);
+ for (const MetaPlayer* metaPlayer: m_Players) {
+ writer.NewPropertyWithValue("AddPlayer", *metaPlayer);
}
writer.NewPropertyWithValue("TeamCount", m_TeamCount);
@@ -301,6 +301,19 @@ int MetaMan::Save(Writer& writer) const {
return 0;
}
+void MetaMan::Destroy() {
+ delete m_pMetaGUI;
+
+ for (std::vector::iterator sItr = m_Scenes.begin(); sItr != m_Scenes.end(); ++sItr)
+ delete (*sItr);
+ for (std::vector::iterator aItr = m_RoundOffensives.begin(); aItr != m_RoundOffensives.end(); ++aItr)
+ delete (*aItr);
+ for (std::vector::iterator pItr = m_Players.begin(); pItr != m_Players.end(); ++pItr)
+ delete (*pItr);
+
+ Clear();
+}
+
int MetaMan::SaveSceneData(std::string pathBase) {
for (std::vector::const_iterator sItr = m_Scenes.begin(); sItr != m_Scenes.end(); ++sItr) {
// Only save the data of revealed scenes that have already had their layers built and saved into files
@@ -333,17 +346,6 @@ int MetaMan::ClearSceneData() {
return 0;
}
-void MetaMan::Destroy() {
- delete m_pMetaGUI;
-
- for (std::vector::iterator sItr = m_Scenes.begin(); sItr != m_Scenes.end(); ++sItr)
- delete (*sItr);
- for (std::vector::iterator aItr = m_RoundOffensives.begin(); aItr != m_RoundOffensives.end(); ++aItr)
- delete (*aItr);
-
- Clear();
-}
-
int MetaMan::GetPlayerTurn() const {
// Player 1's turn is coming up on this round
if (g_MetaMan.m_GameState <= PLAYER1TURN)
@@ -357,9 +359,9 @@ int MetaMan::GetPlayerTurn() const {
}
MetaPlayer* MetaMan::GetMetaPlayerOfInGamePlayer(int inGamePlayer) {
- for (std::vector::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) {
- if ((*itr).GetInGamePlayer() == inGamePlayer)
- return &(*itr);
+ for (std::vector::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) {
+ if ((*itr)->GetInGamePlayer() == inGamePlayer)
+ return &(**itr);
}
// Didn't find any metaplayer that is using that in-game player
@@ -404,14 +406,14 @@ int MetaMan::GetTotalBrainCountOfPlayer(int metaPlayer, bool countPoolsOnly) con
return 0;
// Count the pool first
- int brainCount = m_Players[metaPlayer].GetBrainPoolCount();
+ int brainCount = m_Players[metaPlayer]->GetBrainPoolCount();
// Plus any that are out travelling between sites
- brainCount += m_Players[metaPlayer].GetBrainsInTransit();
+ brainCount += m_Players[metaPlayer]->GetBrainsInTransit();
if (!countPoolsOnly) {
for (std::vector::const_iterator sItr = m_Scenes.begin(); sItr != m_Scenes.end(); ++sItr) {
// Add up any brains installed as resident on any sites
- if ((*sItr)->IsRevealed() && (*sItr)->GetTeamOwnership() == GetTeamOfPlayer(metaPlayer) && (*sItr)->GetResidentBrain(m_Players[metaPlayer].GetInGamePlayer()))
+ if ((*sItr)->IsRevealed() && (*sItr)->GetTeamOwnership() == GetTeamOfPlayer(metaPlayer) && (*sItr)->GetResidentBrain(m_Players[metaPlayer]->GetInGamePlayer()))
brainCount += 1;
}
}
@@ -426,8 +428,8 @@ int MetaMan::GetGoldCountOfTeam(int team) const {
float goldTotal = 0;
// Go through all players and add up the funds of all who belong to this team
for (int metaPlayer = Players::PlayerOne; metaPlayer < m_Players.size(); ++metaPlayer) {
- if (m_Players[metaPlayer].GetTeam() == team)
- goldTotal += m_Players[metaPlayer].GetFunds();
+ if (m_Players[metaPlayer]->GetTeam() == team)
+ goldTotal += m_Players[metaPlayer]->GetFunds();
}
return goldTotal;
@@ -456,7 +458,7 @@ int MetaMan::GetTotalBrainCountOfTeam(int team, bool countPoolsOnly) const {
int brainCount = 0;
for (int metaPlayer = Players::PlayerOne; metaPlayer < m_Players.size(); ++metaPlayer) {
- if (m_Players[metaPlayer].GetTeam() == team)
+ if (m_Players[metaPlayer]->GetTeam() == team)
brainCount += GetTotalBrainCountOfPlayer(metaPlayer, countPoolsOnly);
}
@@ -535,8 +537,8 @@ int MetaMan::WhichTeamLeft()
bool MetaMan::NoBrainsLeftInAnyPool() {
// Go through all players and check each for any brains in any pool
- for (std::vector::iterator mpItr = m_Players.begin(); mpItr != m_Players.end(); ++mpItr) {
- if ((*mpItr).GetBrainPoolCount() > 0)
+ for (std::vector::iterator mpItr = m_Players.begin(); mpItr != m_Players.end(); ++mpItr) {
+ if ((*mpItr)->GetBrainPoolCount() > 0)
return false;
}
return true;
@@ -616,15 +618,15 @@ float MetaMan::GetBudgetedRatioOfPlayer(int metaPlayer, const Scene* pException,
for (std::vector::const_iterator sItr = g_MetaMan.m_Scenes.begin(); sItr != g_MetaMan.m_Scenes.end(); ++sItr) {
// Add up all the allocated funds so far this round, first of bases we're building
if ((*sItr)->GetTeamOwnership() == g_MetaMan.GetTeamOfPlayer(metaPlayer) && *sItr != pException)
- totalAllocated += (*sItr)->GetBuildBudget(m_Players[metaPlayer].GetInGamePlayer());
+ totalAllocated += (*sItr)->GetBuildBudget(m_Players[metaPlayer]->GetInGamePlayer());
}
}
// Also the money allocated for offensive action
- if (includeOffensive && !m_Players[metaPlayer].GetOffensiveTargetName().empty() && (!pException || (pException && pException->GetPresetName() != m_Players[metaPlayer].GetOffensiveTargetName())))
- totalAllocated += m_Players[metaPlayer].GetOffensiveBudget();
+ if (includeOffensive && !m_Players[metaPlayer]->GetOffensiveTargetName().empty() && (!pException || (pException && pException->GetPresetName() != m_Players[metaPlayer]->GetOffensiveTargetName())))
+ totalAllocated += m_Players[metaPlayer]->GetOffensiveBudget();
- return totalAllocated / m_Players[metaPlayer].GetFunds();
+ return totalAllocated / m_Players[metaPlayer]->GetFunds();
}
void MetaMan::SetSuspend(bool suspend) {
@@ -761,7 +763,7 @@ void MetaMan::AIPlayerTurn(int metaPlayer) {
if (metaPlayer < 0 || metaPlayer >= m_Players.size())
return;
- MetaPlayer* pThisPlayer = &(m_Players[metaPlayer]);
+ MetaPlayer* pThisPlayer = m_Players[metaPlayer];
// If this player has no brains at all left, then do nothing
if (GetTotalBrainCountOfPlayer(metaPlayer) <= 0) {
@@ -1009,21 +1011,21 @@ void MetaMan::Update() {
int metaPlayer = m_GameState - PLAYER1TURN;
// If an AI player, do the AI player's logic now and go to next player immediately afterward
- if (!m_Players[metaPlayer].IsHuman())
+ if (!m_Players[metaPlayer]->IsHuman())
AIPlayerTurn(metaPlayer);
// State end - skip A.I. metaplayer turns in the GUI; also skip human player who have been knocked out of the game in previous rounds
- if (m_pMetaGUI->ContinuePhase() || !m_Players[metaPlayer].IsHuman() || m_Players[metaPlayer].IsGameOverByRound(m_CurrentRound)) {
+ if (m_pMetaGUI->ContinuePhase() || !m_Players[metaPlayer]->IsHuman() || m_Players[metaPlayer]->IsGameOverByRound(m_CurrentRound)) {
// If this player is now done for, mark him as such so he'll be completely skipped in future rounds
- if (GetTotalBrainCountOfPlayer(metaPlayer) <= 0 && !m_Players[metaPlayer].IsGameOverByRound(m_CurrentRound))
- m_Players[metaPlayer].SetGameOverRound(m_CurrentRound);
+ if (GetTotalBrainCountOfPlayer(metaPlayer) <= 0 && !m_Players[metaPlayer]->IsGameOverByRound(m_CurrentRound))
+ m_Players[metaPlayer]->SetGameOverRound(m_CurrentRound);
// Find the next player which is not out of the game yet
do {
// Next player, if any left
m_GameState++;
metaPlayer = m_GameState - PLAYER1TURN;
- } while (m_GameState <= PLAYER4TURN && metaPlayer < m_Players.size() && m_Players[metaPlayer].IsGameOverByRound(m_CurrentRound));
+ } while (m_GameState <= PLAYER4TURN && metaPlayer < m_Players.size() && m_Players[metaPlayer]->IsGameOverByRound(m_CurrentRound));
// If not, jump to building bases
if (m_GameState > PLAYER4TURN || metaPlayer >= m_Players.size())
diff --git a/Source/Managers/MetaMan.h b/Source/Managers/MetaMan.h
index 11ec6c35b..f8cb25415 100644
--- a/Source/Managers/MetaMan.h
+++ b/Source/Managers/MetaMan.h
@@ -146,12 +146,12 @@ namespace RTE {
/// Gets the designated team of a specific player
/// @param metaPlayer Which player.
/// @return The team of that player.
- int GetTeamOfPlayer(int metaPlayer) const { return metaPlayer >= Players::PlayerOne && metaPlayer < static_cast(m_Players.size()) ? m_Players[metaPlayer].GetTeam() : Activity::NoTeam; }
+ int GetTeamOfPlayer(int metaPlayer) const { return metaPlayer >= Players::PlayerOne && metaPlayer < static_cast(m_Players.size()) ? m_Players[metaPlayer]->GetTeam() : Activity::NoTeam; }
/// Gets the specified MetaPlayer
/// @param metaPlayer Which player.
/// @return The requested MetaPlayer
- MetaPlayer* GetPlayer(int metaPlayer) { return (metaPlayer >= Players::PlayerOne && metaPlayer < static_cast(m_Players.size())) ? &(m_Players[metaPlayer]) : nullptr; }
+ MetaPlayer* GetPlayer(int metaPlayer) { return (metaPlayer >= Players::PlayerOne && metaPlayer < static_cast(m_Players.size())) ? &*m_Players[metaPlayer] : nullptr; }
/// Gets the MetaPlayer playing a specific in-game player, if any.
/// @param inGamePlayer Which in-game player to translate into a metaplayer.
@@ -231,7 +231,7 @@ namespace RTE {
/// @param deductOffensive Whether to count the money allocated for offensive action as remaining. (default: false)
/// @param deductDefensive Whether to count the money allocated for defensive action as remaining. (default: false) const { return m_Players[metaPlayer].GetFunds() - m_Players[metaPlayer].GetFunds() * GetBudgetedRatioOfPlayer(metaPlayer)
/// @return The amount, in oz, that this player unallocated and unused this turn.
- float GetRemainingFundsOfPlayer(int metaPlayer, const Scene* pException = 0, bool deductOffensive = false, bool deductDefensive = false) const { return m_Players[metaPlayer].GetFunds() - m_Players[metaPlayer].GetFunds() * GetBudgetedRatioOfPlayer(metaPlayer, pException, !deductOffensive, !deductDefensive); }
+ float GetRemainingFundsOfPlayer(int metaPlayer, const Scene* pException = 0, bool deductOffensive = false, bool deductDefensive = false) const { return m_Players[metaPlayer]->GetFunds() - m_Players[metaPlayer]->GetFunds() * GetBudgetedRatioOfPlayer(metaPlayer, pException, !deductOffensive, !deductDefensive); }
/// Shows whether a game is currently in progress
/// @return Whether a game is going or not.
@@ -314,7 +314,7 @@ namespace RTE {
// The save name of the currently played metagame
std::string m_GameName;
// The players of the metagame
- std::vector m_Players;
+ std::vector m_Players;
// The number of Team:s in play this game
int m_TeamCount;
// The flag icons of all teams
diff --git a/Source/Managers/MovableMan.cpp b/Source/Managers/MovableMan.cpp
index 3692c6b0d..25faaf869 100644
--- a/Source/Managers/MovableMan.cpp
+++ b/Source/Managers/MovableMan.cpp
@@ -117,6 +117,10 @@ void MovableMan::Destroy() {
delete (*it2);
for (std::deque::iterator it3 = m_Particles.begin(); it3 != m_Particles.end(); ++it3)
delete (*it3);
+ for (std::vector::iterator it4 = m_AlarmEvents.begin(); it4 != m_AlarmEvents.end(); ++it4)
+ delete (*it4);
+ for (std::vector::iterator it5 = m_AddedAlarmEvents.begin(); it5 != m_AddedAlarmEvents.end(); ++it5)
+ delete (*it5);
Clear();
}
@@ -1157,7 +1161,7 @@ void MovableMan::OverrideMaterialDoors(bool eraseDoorMaterial, int team) const {
void MovableMan::RegisterAlarmEvent(const AlarmEvent& newEvent) {
std::lock_guard lock(m_AddedAlarmEventsMutex);
- m_AddedAlarmEvents.push_back(newEvent);
+ m_AddedAlarmEvents.push_back(new AlarmEvent(newEvent));
}
void callLuaFunctionOnMORecursive(MovableObject* mo, const std::string& functionName, const std::vector& functionEntityArguments, const std::vector& functionLiteralArguments, const std::vector& functionObjectArguments) {
@@ -1288,8 +1292,11 @@ void MovableMan::Update() {
m_SortTeamRoster[Activity::TeamFour] = false;
// Move all last frame's alarm events into the proper buffer, and clear out the new one to fill up with this frame's
+ for (AlarmEvent* alarmEvent: m_AlarmEvents) {
+ delete alarmEvent;
+ }
m_AlarmEvents.clear();
- for (std::vector::iterator aeItr = m_AddedAlarmEvents.begin(); aeItr != m_AddedAlarmEvents.end(); ++aeItr) {
+ for (std::vector::iterator aeItr = m_AddedAlarmEvents.begin(); aeItr != m_AddedAlarmEvents.end(); ++aeItr) {
m_AlarmEvents.push_back(*aeItr);
}
m_AddedAlarmEvents.clear();
diff --git a/Source/Managers/MovableMan.h b/Source/Managers/MovableMan.h
index cf3dfa019..e7f27763f 100644
--- a/Source/Managers/MovableMan.h
+++ b/Source/Managers/MovableMan.h
@@ -430,7 +430,7 @@ namespace RTE {
/// Gets the list of AlarmEvent:s from last frame's update.
/// @return The const list of AlarmEvent:s.
- const std::vector& GetAlarmEvents() const { return m_AlarmEvents; }
+ const std::vector& GetAlarmEvents() const { return m_AlarmEvents; }
/// Shows whetehr particles are set to get copied to the terrain upon
/// settling
@@ -597,10 +597,10 @@ namespace RTE {
// The alarm events on the scene where something alarming happened, for use with AI firings awareness os they react to shots fired etc.
// This is the last frame's events, is the one for Actors to poll for events, should be cleaned out and refilled each frame.
- std::vector m_AlarmEvents;
+ std::vector m_AlarmEvents;
// The alarm events on the scene where something alarming happened, for use with AI firings awareness os they react to shots fired etc.
// This is the current frame's events, will be filled up during MovableMan Updates, should be transferred to Last Frame at end of update.
- std::vector m_AddedAlarmEvents;
+ std::vector m_AddedAlarmEvents;
// Mutexes to ensure alarm events aren't being added from separate threads at the same time
std::mutex m_AddedAlarmEventsMutex;
diff --git a/Source/Managers/SceneMan.cpp b/Source/Managers/SceneMan.cpp
index a504cbdca..7bb85f256 100644
--- a/Source/Managers/SceneMan.cpp
+++ b/Source/Managers/SceneMan.cpp
@@ -2649,14 +2649,14 @@ void SceneMan::Draw(BITMAP* targetBitmap, BITMAP* targetGUIBitmap, const Vector&
static bool s_drawNoGravBoxes = false;
if (s_drawNoGravBoxes) {
if (Scene::Area* noGravArea = m_pCurrentScene->GetArea("NoGravityArea")) {
- const std::vector& boxList = noGravArea->GetBoxes();
+ const std::vector& boxList = noGravArea->GetBoxes();
g_FrameMan.SetTransTableFromPreset(TransparencyPreset::MoreTrans);
drawing_mode(DRAW_MODE_TRANS, 0, 0, 0);
std::list wrappedBoxes;
- for (std::vector::const_iterator bItr = boxList.begin(); bItr != boxList.end(); ++bItr) {
+ for (Box* box: boxList) {
wrappedBoxes.clear();
- g_SceneMan.WrapBox(*bItr, wrappedBoxes);
+ g_SceneMan.WrapBox(*box, wrappedBoxes);
for (std::list::iterator wItr = wrappedBoxes.begin(); wItr != wrappedBoxes.end(); ++wItr) {
Vector adjCorner = (*wItr).GetCorner() - targetPos;
diff --git a/Source/Menus/AreaEditorGUI.cpp b/Source/Menus/AreaEditorGUI.cpp
index c677e9d85..e199bdac1 100644
--- a/Source/Menus/AreaEditorGUI.cpp
+++ b/Source/Menus/AreaEditorGUI.cpp
@@ -133,7 +133,7 @@ void AreaEditorGUI::Update() {
// If no Area is selected yet, and there are Areas in the current scene, then select the first one automatically
if (!m_pCurrentArea && !g_SceneMan.GetScene()->m_AreaList.empty())
- m_pCurrentArea = &(g_SceneMan.GetScene()->m_AreaList.front());
+ m_pCurrentArea = g_SceneMan.GetScene()->m_AreaList.front();
m_EditMade = false;
m_pBoxToBlink = 0;
@@ -271,7 +271,7 @@ void AreaEditorGUI::Update() {
// Make sure we have a picked area if there are any areas at all!
if (!m_pCurrentArea && !g_SceneMan.GetScene()->m_AreaList.empty())
- m_pCurrentArea = &(g_SceneMan.GetScene()->m_AreaList.front());
+ m_pCurrentArea = g_SceneMan.GetScene()->m_AreaList.front();
// If there are no Area:s, AreaEditor should detect it and force user to create a new one with a dialog
// else
// m_EditorGUIMode = PREADDMOVEBOX;
@@ -494,7 +494,7 @@ void AreaEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const {
// Draw the Box:es defined for the currently selected Area
Vector adjCorner;
- const std::vector* pBoxList = &(m_pCurrentArea->m_BoxList);
+ const std::vector* pBoxList = &(m_pCurrentArea->m_BoxList);
if (m_FullFeatured) {
// Set the drawin mode to be transparent and use the
// g_FrameMan.SetTransTableFromPreset(m_BlinkTimer.AlternateReal(333) || m_EditorGUIMode == PLACINGOBJECT ? TransparencyPreset::LessTrans : TransparencyPreset::HalfTrans);
@@ -502,10 +502,10 @@ void AreaEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const {
drawing_mode(DRAW_MODE_TRANS, 0, 0, 0);
// Draw all already placed Box:es, and the currently edited one
- for (std::vector::const_iterator bItr = pBoxList->begin(); bItr != pBoxList->end(); ++bItr) {
+ for (const Box* box: *pBoxList) {
// Handle wrapped boxes properly
wrappedBoxes.clear();
- g_SceneMan.WrapBox(*bItr, wrappedBoxes);
+ g_SceneMan.WrapBox(*box, wrappedBoxes);
// Iterate through the wrapped boxes - will only be one if there's no wrapping
for (std::list::iterator wItr = wrappedBoxes.begin(); wItr != wrappedBoxes.end(); ++wItr) {
diff --git a/Source/Menus/AreaPickerGUI.cpp b/Source/Menus/AreaPickerGUI.cpp
index 54033d3ea..f2858b3c7 100644
--- a/Source/Menus/AreaPickerGUI.cpp
+++ b/Source/Menus/AreaPickerGUI.cpp
@@ -201,10 +201,10 @@ void AreaPickerGUI::UpdateAreasList(std::string selectAreaName) {
Scene* pScene = g_SceneMan.GetScene();
int indexToSelect = 0;
// Add all the current Scene's Area:s to the list!
- for (std::list::iterator itr = pScene->m_AreaList.begin(); itr != pScene->m_AreaList.end(); ++itr) {
- m_pAreasList->AddItem((*itr).GetName());
+ for (std::list::iterator itr = pScene->m_AreaList.begin(); itr != pScene->m_AreaList.end(); ++itr) {
+ m_pAreasList->AddItem((*itr)->GetName());
// If an Area's name matches the one we're supposed to leave selected after update, then save teh index
- if ((*itr).GetName() == selectAreaName)
+ if ((*itr)->GetName() == selectAreaName)
m_SelectedAreaIndex = indexToSelect;
indexToSelect++;
}
diff --git a/Source/Menus/MetagameGUI.cpp b/Source/Menus/MetagameGUI.cpp
index 587520cd2..9295e6018 100644
--- a/Source/Menus/MetagameGUI.cpp
+++ b/Source/Menus/MetagameGUI.cpp
@@ -775,20 +775,20 @@ void MetagameGUI::SelectScene(Scene* pScene) {
// If owned by this player's team, make the budget slider represent the currently set setting of this Scene
if (m_pSelectedScene->GetTeamOwnership() == g_MetaMan.GetTeamOfPlayer(metaPlayer)) {
- m_pSceneBudgetSlider->SetValue(std::floor((m_pSelectedScene->GetBuildBudget(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer()) / g_MetaMan.m_Players[metaPlayer].GetFunds()) * 100));
+ m_pSceneBudgetSlider->SetValue(std::floor((m_pSelectedScene->GetBuildBudget(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer()) / g_MetaMan.m_Players[metaPlayer]->GetFunds()) * 100));
}
// Owned by enemy player, so show the attack budget set up for this scene
else if (g_MetaMan.IsActiveTeam(m_pSelectedScene->GetTeamOwnership())) {
- if (m_pSelectedScene->GetPresetName() == g_MetaMan.m_Players[metaPlayer].GetOffensiveTargetName())
- m_pSceneBudgetSlider->SetValue(std::floor((g_MetaMan.m_Players[metaPlayer].GetOffensiveBudget() / g_MetaMan.m_Players[metaPlayer].GetFunds()) * 100));
+ if (m_pSelectedScene->GetPresetName() == g_MetaMan.m_Players[metaPlayer]->GetOffensiveTargetName())
+ m_pSceneBudgetSlider->SetValue(std::floor((g_MetaMan.m_Players[metaPlayer]->GetOffensiveBudget() / g_MetaMan.m_Players[metaPlayer]->GetFunds()) * 100));
// Not the current target, so set slider to 0. It will set the new budget as
else
m_pSceneBudgetSlider->SetValue(0);
}
// Unowned site, so set up expedition budget (same so far)
else {
- if (m_pSelectedScene->GetPresetName() == g_MetaMan.m_Players[metaPlayer].GetOffensiveTargetName())
- m_pSceneBudgetSlider->SetValue(std::floor((g_MetaMan.m_Players[metaPlayer].GetOffensiveBudget() / g_MetaMan.m_Players[metaPlayer].GetFunds()) * 100));
+ if (m_pSelectedScene->GetPresetName() == g_MetaMan.m_Players[metaPlayer]->GetOffensiveTargetName())
+ m_pSceneBudgetSlider->SetValue(std::floor((g_MetaMan.m_Players[metaPlayer]->GetOffensiveBudget() / g_MetaMan.m_Players[metaPlayer]->GetFunds()) * 100));
// Not the current target, so set slider to 0. It will set the new budget as
else
m_pSceneBudgetSlider->SetValue(0);
@@ -903,27 +903,27 @@ bool MetagameGUI::StartNewGame() {
}
// Set up the new player and add it
- MetaPlayer newPlayer;
- newPlayer.SetName(m_apPlayerNameBox[player]->GetText());
+ MetaPlayer* newPlayer = new MetaPlayer;
+ newPlayer->SetName(m_apPlayerNameBox[player]->GetText());
// Set the in-game control mapping of this metagame player
- newPlayer.m_InGamePlayer = player;
+ newPlayer->m_InGamePlayer = player;
// Whether this is a human or AI player
- newPlayer.SetHuman(m_apPlayerControlButton[player]->GetText() == "Human");
+ newPlayer->SetHuman(m_apPlayerControlButton[player]->GetText() == "Human");
// Set native cost multypliiers according to difficulty
- if (!newPlayer.IsHuman()) {
+ if (!newPlayer->IsHuman()) {
if (g_MetaMan.m_Difficulty < Activity::CakeDifficulty)
- newPlayer.SetNativeCostMultiplier(1.2);
+ newPlayer->SetNativeCostMultiplier(1.2);
else if (g_MetaMan.m_Difficulty < Activity::EasyDifficulty)
- newPlayer.SetNativeCostMultiplier(1.1);
+ newPlayer->SetNativeCostMultiplier(1.1);
else if (g_MetaMan.m_Difficulty < Activity::MediumDifficulty)
- newPlayer.SetNativeCostMultiplier(1.0);
+ newPlayer->SetNativeCostMultiplier(1.0);
else if (g_MetaMan.m_Difficulty < Activity::HardDifficulty)
- newPlayer.SetNativeCostMultiplier(0.80);
+ newPlayer->SetNativeCostMultiplier(0.80);
else if (g_MetaMan.m_Difficulty < Activity::NutsDifficulty)
- newPlayer.SetNativeCostMultiplier(0.60);
+ newPlayer->SetNativeCostMultiplier(0.60);
else
- newPlayer.SetNativeCostMultiplier(0.40);
+ newPlayer->SetNativeCostMultiplier(0.40);
}
// TODO: Add the control scheme icons to the newgame dialog for clarity
@@ -940,7 +940,7 @@ bool MetagameGUI::StartNewGame() {
for (int team = Activity::TeamOne; team < g_MetaMan.m_TeamCount; ++team) {
// Join existing team!
if (pTeamIcon->GetPresetName() == g_MetaMan.m_TeamIcons[team].GetPresetName()) {
- newPlayer.SetTeam(team);
+ newPlayer->SetTeam(team);
newTeam = false;
break;
}
@@ -949,7 +949,7 @@ bool MetagameGUI::StartNewGame() {
// If we didn't find that the team we were designated already exists, then create it
if (newTeam) {
// Set the team of the new player
- newPlayer.SetTeam(g_MetaMan.m_TeamCount);
+ newPlayer->SetTeam(g_MetaMan.m_TeamCount);
// Set AI Skill level
g_MetaMan.m_TeamAISkill[g_MetaMan.m_TeamCount] = m_apPlayerAISkillSlider[player]->GetValue();
// Set the new team icon
@@ -977,33 +977,33 @@ bool MetagameGUI::StartNewGame() {
selectedTech = m_apPlayerTechSelect[player]->GetItem(randomSelection);
}
if (selectedTech) {
- newPlayer.m_NativeTechModule = selectedTech->m_ExtraIndex;
+ newPlayer->m_NativeTechModule = selectedTech->m_ExtraIndex;
}
}
// Set the starting brains for this player
// Start with the baseline setting
- newPlayer.m_BrainPool = m_pLengthSlider->GetValue();
+ newPlayer->m_BrainPool = m_pLengthSlider->GetValue();
// Baseline can never be 0
- newPlayer.m_BrainPool = MAX(newPlayer.m_BrainPool, 1);
+ newPlayer->m_BrainPool = MAX(newPlayer->m_BrainPool, 1);
// Apply the handicap!
if (m_apPlayerHandicap[player]->GetSelectedIndex() == 0)
- newPlayer.m_BrainPool += 5;
+ newPlayer->m_BrainPool += 5;
else if (m_apPlayerHandicap[player]->GetSelectedIndex() == 1)
- newPlayer.m_BrainPool += 3;
+ newPlayer->m_BrainPool += 3;
else if (m_apPlayerHandicap[player]->GetSelectedIndex() == 2)
- newPlayer.m_BrainPool += 1;
+ newPlayer->m_BrainPool += 1;
else if (m_apPlayerHandicap[player]->GetSelectedIndex() == 4)
- newPlayer.m_BrainPool -= 1;
+ newPlayer->m_BrainPool -= 1;
else if (m_apPlayerHandicap[player]->GetSelectedIndex() == 5)
- newPlayer.m_BrainPool -= 3;
+ newPlayer->m_BrainPool -= 3;
else if (m_apPlayerHandicap[player]->GetSelectedIndex() == 6)
- newPlayer.m_BrainPool -= 5;
+ newPlayer->m_BrainPool -= 5;
// Give at least ONE brain!
- newPlayer.m_BrainPool = MAX(newPlayer.m_BrainPool, 1);
+ newPlayer->m_BrainPool = MAX(newPlayer->m_BrainPool, 1);
// Starting gold amount; common to all
- newPlayer.m_Funds = startGold;
+ newPlayer->m_Funds = startGold;
g_MetaMan.m_Players.push_back(newPlayer);
@@ -1415,20 +1415,20 @@ void MetagameGUI::Update() {
int metaPlayer = g_MetaMan.m_GameState - MetaMan::PLAYER1TURN;
// Set up the pre-player-turn intermediate status IF this is a human player still in the game
- if (g_MetaMan.m_Players[metaPlayer].IsHuman() && !g_MetaMan.m_Players[metaPlayer].IsGameOverByRound(g_MetaMan.m_CurrentRound)) {
+ if (g_MetaMan.m_Players[metaPlayer]->IsHuman() && !g_MetaMan.m_Players[metaPlayer]->IsGameOverByRound(g_MetaMan.m_CurrentRound)) {
if (g_MetaMan.m_StateChanged) {
// If this human player has no brains left anywhere, there's really nothing he can do, and it's game over for him
// Communicate it to the loser
if (g_MetaMan.GetTotalBrainCountOfPlayer(metaPlayer) <= 0) {
m_apMetaButton[CONTINUE]->SetText("Continue");
- m_pPhaseLabel->SetText(g_MetaMan.m_Players[metaPlayer].GetName() + "'s Turn");
+ m_pPhaseLabel->SetText(g_MetaMan.m_Players[metaPlayer]->GetName() + "'s Turn");
m_pBannerRedTop->ShowText("Game Over", GUIBanner::FLYBYLEFTWARD, -1, Vector(m_RootBoxMaxWidth, g_WindowMan.GetResY()), 0.4, 3500, 0);
- m_pBannerRedBottom->ShowText("for " + g_MetaMan.m_Players[metaPlayer].GetName() + "!", GUIBanner::FLYBYRIGHTWARD, -1, Vector(m_RootBoxMaxWidth, g_WindowMan.GetResY()), 0.6, 3500, 0);
+ m_pBannerRedBottom->ShowText("for " + g_MetaMan.m_Players[metaPlayer]->GetName() + "!", GUIBanner::FLYBYRIGHTWARD, -1, Vector(m_RootBoxMaxWidth, g_WindowMan.GetResY()), 0.6, 3500, 0);
// Show a lil descriptive message as to why the game ended
m_pGameMessageLabel->SetVisible(true);
m_pGameMessageLabel->SetPositionAbs(m_pGameMessageLabel->GetXPos(), (m_apScreenBox[ROOTBOX]->GetHeight() / 2) + 110 - 16);
- m_pGameMessageLabel->SetText(g_MetaMan.m_Players[metaPlayer].GetName() + "'s brains are all gone, so he/she can do nothing more. Good effort, though!");
+ m_pGameMessageLabel->SetText(g_MetaMan.m_Players[metaPlayer]->GetName() + "'s brains are all gone, so he/she can do nothing more. Good effort, though!");
// Just skip this guy's turn completely
m_PreTurn = false;
@@ -1436,8 +1436,8 @@ void MetagameGUI::Update() {
// Normal player turn start
else {
m_apMetaButton[CONTINUE]->SetText("Start Turn");
- m_pPhaseLabel->SetText(g_MetaMan.m_Players[metaPlayer].GetName() + "'s Turn");
- m_pBannerRedTop->ShowText(g_MetaMan.m_Players[metaPlayer].GetName() + "'s", GUIBanner::FLYBYLEFTWARD, -1, Vector(m_RootBoxMaxWidth, g_WindowMan.GetResY()), 0.4, 3500, 0);
+ m_pPhaseLabel->SetText(g_MetaMan.m_Players[metaPlayer]->GetName() + "'s Turn");
+ m_pBannerRedTop->ShowText(g_MetaMan.m_Players[metaPlayer]->GetName() + "'s", GUIBanner::FLYBYLEFTWARD, -1, Vector(m_RootBoxMaxWidth, g_WindowMan.GetResY()), 0.4, 3500, 0);
m_pBannerRedBottom->ShowText("Turn", GUIBanner::FLYBYRIGHTWARD, -1, Vector(m_RootBoxMaxWidth, g_WindowMan.GetResY()), 0.6, 3500, 0);
m_pGameMessageLabel->SetVisible(false);
m_PreTurn = true;
@@ -1509,14 +1509,14 @@ void MetagameGUI::Update() {
// Find out who was on this winning team so we can name them by name
std::string winnerNames = "";
bool plural = false;
- for (std::vector::iterator pItr = g_MetaMan.m_Players.begin(); pItr != g_MetaMan.m_Players.end(); ++pItr) {
+ for (std::vector::iterator pItr = g_MetaMan.m_Players.begin(); pItr != g_MetaMan.m_Players.end(); ++pItr) {
// WINRAR
- if ((*pItr).GetTeam() == winnerTeam) {
+ if ((*pItr)->GetTeam() == winnerTeam) {
// There's now more than one name in there
if (!winnerNames.empty())
plural = true;
- winnerNames = winnerNames + (winnerNames.empty() ? "" : " and ") + (*pItr).GetName();
+ winnerNames = winnerNames + (winnerNames.empty() ? "" : " and ") + (*pItr)->GetName();
}
}
m_pBannerRedTop->ShowText(winnerNames, GUIBanner::FLYBYLEFTWARD, -1, Vector(m_RootBoxMaxWidth, g_WindowMan.GetResY()), 0.4, 3500, 0);
@@ -2118,7 +2118,7 @@ void MetagameGUI::UpdateInput() {
if (anEvent.GetControl() == m_apMetaButton[SCENEACTION] && m_pSelectedScene) {
// Set up site scan of it (for a price)
int metaPlayer = g_MetaMan.GetPlayerTurn();
- int team = g_MetaMan.m_Players[metaPlayer].GetTeam();
+ int team = g_MetaMan.m_Players[metaPlayer]->GetTeam();
// Check if we have enough money for this!
if (g_MetaMan.GetRemainingFundsOfPlayer(metaPlayer, 0, false, false) < SCANCOST) {
m_apMetaButton[SCENEACTION]->SetText("NOT ENOUGH FUNDS!");
@@ -2152,10 +2152,10 @@ void MetagameGUI::UpdateInput() {
pNewEditor->ClearPlayers();
// Editing player
int metaPlayer = g_MetaMan.GetPlayerTurn();
- int team = g_MetaMan.m_Players[metaPlayer].GetTeam();
+ int team = g_MetaMan.m_Players[metaPlayer]->GetTeam();
// TODO: add all other players of same team, for coop editing?? Whata bout resident brains of lazy teammates who hacen't placed yet
// NO, this is silly. Just make the objects placed by this player marked as placed by him
- pNewEditor->AddPlayer(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer(), true, team, 0, &(g_MetaMan.GetTeamIcon(team)));
+ pNewEditor->AddPlayer(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer(), true, team, 0, &(g_MetaMan.GetTeamIcon(team)));
// Send in the Scene to load in later when the screen has faded out etc
m_pPlayingScene = m_pSelectedScene;
@@ -2170,9 +2170,9 @@ void MetagameGUI::UpdateInput() {
// Scan Now button pressed; time to start the scanning process immediately
if (anEvent.GetControl() == m_apMetaButton[SCANNOW] && m_pSelectedScene) {
int metaPlayer = g_MetaMan.GetPlayerTurn();
- int team = g_MetaMan.m_Players[metaPlayer].GetTeam();
+ int team = g_MetaMan.m_Players[metaPlayer]->GetTeam();
// Actually change the player's funds
- g_MetaMan.m_Players[metaPlayer].m_Funds -= SCANCOST;
+ g_MetaMan.m_Players[metaPlayer]->m_Funds -= SCANCOST;
// Set up and start the scripted activity for scanning the site for this' team
GAScripted* pScanActivity = new GAScripted;
pScanActivity->Create("Base.rte/Activities/SiteScan.lua", "SiteScan");
@@ -2183,15 +2183,15 @@ void MetagameGUI::UpdateInput() {
// Gotto deact all players since by default there is one in slot 1
pScanActivity->ClearPlayers();
// Add the player who ordered this snooping around
- pScanActivity->AddPlayer(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer(), true, team, SCANCOST, &(g_MetaMan.GetTeamIcon(team)));
+ pScanActivity->AddPlayer(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer(), true, team, SCANCOST, &(g_MetaMan.GetTeamIcon(team)));
// Add the players who own this place, if any - their actors and brains are in the scene and should be shown
if (g_MetaMan.IsActiveTeam(m_pSelectedScene->GetTeamOwnership())) {
// Go through all players and add the ones of the defending team, based on who has resident brains here
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// Got to remember to translate from metagame player index into the in-game player index and to flag them as not a human so they dont' get their own screens
- // if (g_MetaMan.m_Players[mp].GetTeam() == m_pSelectedScene->GetTeamOwnership())
- if (m_pSelectedScene->GetResidentBrain(g_MetaMan.m_Players[mp].GetInGamePlayer()))
- pScanActivity->AddPlayer(g_MetaMan.m_Players[mp].GetInGamePlayer(), false, g_MetaMan.m_Players[mp].GetTeam(), 0, &(g_MetaMan.GetTeamIcon(g_MetaMan.m_Players[mp].GetTeam())));
+ // if (g_MetaMan.m_Players[mp]->GetTeam() == m_pSelectedScene->GetTeamOwnership())
+ if (m_pSelectedScene->GetResidentBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer()))
+ pScanActivity->AddPlayer(g_MetaMan.m_Players[mp]->GetInGamePlayer(), false, g_MetaMan.m_Players[mp]->GetTeam(), 0, &(g_MetaMan.GetTeamIcon(g_MetaMan.m_Players[mp]->GetTeam())));
}
}
// Send in the Scene to load in later when the screen has faded out etc
@@ -2206,15 +2206,15 @@ void MetagameGUI::UpdateInput() {
// Scan Later button pressed; mark the Scene for scanning by this metaplayer's team
if (anEvent.GetControl() == m_apMetaButton[SCANLATER] && m_pSelectedScene) {
int metaPlayer = g_MetaMan.GetPlayerTurn();
- int team = g_MetaMan.m_Players[metaPlayer].GetTeam();
+ int team = g_MetaMan.m_Players[metaPlayer]->GetTeam();
// Double-check to make sure we do have the funds to do this AND that the scan hasn't already been paid for
- if (g_MetaMan.m_Players[metaPlayer].m_Funds < SCANCOST && !m_pSelectedScene->IsScanScheduled(team))
+ if (g_MetaMan.m_Players[metaPlayer]->m_Funds < SCANCOST && !m_pSelectedScene->IsScanScheduled(team))
g_GUISound.UserErrorSound()->Play();
else {
// Show the cost change the funds meter
FundsChangeIndication(metaPlayer, -SCANCOST, Vector(m_apPlayerBarLabel[metaPlayer]->GetXPos() + m_apPlayerBarLabel[metaPlayer]->GetWidth(), m_apPlayerBarLabel[metaPlayer]->GetYPos()), 2000);
// Actually change the player's funds
- g_MetaMan.m_Players[metaPlayer].m_Funds -= SCANCOST;
+ g_MetaMan.m_Players[metaPlayer]->m_Funds -= SCANCOST;
// Mark the selected Scene to be scanned next time it is loaded by a player of this' team
m_pSelectedScene->SetScheduledScan(team, true);
@@ -2223,8 +2223,8 @@ void MetagameGUI::UpdateInput() {
UpdateScenesBox(true);
// Update the budget slider to reflect the scan cost being deducted from the funds
- if (g_MetaMan.m_Players[metaPlayer].GetOffensiveTargetName() == m_pSelectedScene->GetPresetName())
- m_pSceneBudgetSlider->SetValue(std::floor((g_MetaMan.m_Players[metaPlayer].GetOffensiveBudget() / g_MetaMan.m_Players[metaPlayer].GetFunds()) * 100));
+ if (g_MetaMan.m_Players[metaPlayer]->GetOffensiveTargetName() == m_pSelectedScene->GetPresetName())
+ m_pSceneBudgetSlider->SetValue(std::floor((g_MetaMan.m_Players[metaPlayer]->GetOffensiveBudget() / g_MetaMan.m_Players[metaPlayer]->GetFunds()) * 100));
// Play an appropriate sound to indicate that the scan is bought and scheduled
g_GUISound.ItemChangeSound()->Play();
@@ -2261,19 +2261,19 @@ void MetagameGUI::UpdateInput() {
UpdateScenesBox(true);
// If owned by this player, then set update base building budget for this Scene
- float budget = ((float)m_pSceneBudgetSlider->GetValue() / 100.0f) * g_MetaMan.m_Players[metaPlayer].GetFunds();
+ float budget = ((float)m_pSceneBudgetSlider->GetValue() / 100.0f) * g_MetaMan.m_Players[metaPlayer]->GetFunds();
if (m_pSelectedScene->GetTeamOwnership() == g_MetaMan.GetTeamOfPlayer(metaPlayer)) {
- m_pSelectedScene->SetBuildBudget(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer(), budget);
+ m_pSelectedScene->SetBuildBudget(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer(), budget);
}
// Site owned by enemy player, update the attack budget
else if (g_MetaMan.IsActiveTeam(m_pSelectedScene->GetTeamOwnership())) {
- g_MetaMan.m_Players[metaPlayer].SetOffensiveBudget(budget);
- g_MetaMan.m_Players[metaPlayer].SetOffensiveTargetName(m_pSelectedScene->GetPresetName());
+ g_MetaMan.m_Players[metaPlayer]->SetOffensiveBudget(budget);
+ g_MetaMan.m_Players[metaPlayer]->SetOffensiveTargetName(m_pSelectedScene->GetPresetName());
}
// Unowned site, update the expedition budget
else {
- g_MetaMan.m_Players[metaPlayer].SetOffensiveBudget(budget);
- g_MetaMan.m_Players[metaPlayer].SetOffensiveTargetName(m_pSelectedScene->GetPresetName());
+ g_MetaMan.m_Players[metaPlayer]->SetOffensiveBudget(budget);
+ g_MetaMan.m_Players[metaPlayer]->SetOffensiveTargetName(m_pSelectedScene->GetPresetName());
}
}
}
@@ -2573,18 +2573,18 @@ void MetagameGUI::CompletedActivity() {
{
// ANIMATE THIS NICELY INSTEAD
// Deduct the player's original contribution to team funds
- g_MetaMan.m_Players[metaPlayer].m_Funds -= pDoneActivity->GetPlayerFundsContribution(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer());
+ g_MetaMan.m_Players[metaPlayer]->m_Funds -= pDoneActivity->GetPlayerFundsContribution(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer());
// Add back whatever his share of whatever his team has left in the fight at its end
- g_MetaMan.m_Players[metaPlayer].m_Funds += pDoneActivity->GetPlayerFundsShare(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer());
+ g_MetaMan.m_Players[metaPlayer]->m_Funds += pDoneActivity->GetPlayerFundsShare(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer());
// IF This guy was ATTACKING this turn, adjust his attack budget to match what just happened in the battle
// so in case he is defending in a upcoming battle this turn, his avaialbe funds will be accurately calculated
- if (g_MetaMan.m_Players[metaPlayer].GetOffensiveTargetName() == m_pAnimScene->GetPresetName())
+ if (g_MetaMan.m_Players[metaPlayer]->GetOffensiveTargetName() == m_pAnimScene->GetPresetName())
{
- g_MetaMan.m_Players[metaPlayer].SetOffensiveBudget(g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsShare(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer()));
- // g_MetaMan.m_Players[metaPlayer].SetOffensiveTargetName("");
+ g_MetaMan.m_Players[metaPlayer]->SetOffensiveBudget(g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsShare(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer()));
+ // g_MetaMan.m_Players[metaPlayer]->SetOffensiveTargetName("");
}
// Update the ratios of the meter now that the funds have changed
- UpdatePlayerLineRatios(m_ActionSiteLines[metaPlayer], metaPlayer, false, g_MetaMan.m_Players[metaPlayer].m_Funds);
+ UpdatePlayerLineRatios(m_ActionSiteLines[metaPlayer], metaPlayer, false, g_MetaMan.m_Players[metaPlayer]->m_Funds);
}
*/
}
@@ -2952,8 +2952,8 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) {
// First set up all the site lines we should be animating into view
if (g_MetaMan.m_StateChanged || initOverride) {
// Make note of all funds from previous round
- for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr)
- (*mpItr).m_PhaseStartFunds = (*mpItr).m_Funds;
+ for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr)
+ (*mpItr)->m_PhaseStartFunds = (*mpItr)->m_Funds;
// If this is the very first round and no Scenes are owned yet, then we should just skip this
// Don't return out of this yet thuogh because there's some finalization going on in the end of this func
@@ -2972,7 +2972,7 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) {
do {
// If this player is DONE FOR, skip income counting completely
if (g_MetaMan.GetTotalBrainCountOfPlayer(m_AnimMetaPlayer) <= 0 ||
- g_MetaMan.m_Players[m_AnimMetaPlayer].IsGameOverByRound(g_MetaMan.m_CurrentRound)) {
+ g_MetaMan.m_Players[m_AnimMetaPlayer]->IsGameOverByRound(g_MetaMan.m_CurrentRound)) {
m_aBrainSaleIncomeLineIndices[m_AnimMetaPlayer] = -1;
UpdatePlayerLineRatios(m_IncomeSiteLines, m_AnimMetaPlayer, false);
continue;
@@ -2980,16 +2980,16 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) {
// Only charge rent if there's any brains left in pool
// Make this rent variable somehow??
- totalRent = initOverride ? 0 : g_MetaMan.m_Players[m_AnimMetaPlayer].GetBrainPoolCount() > 0 ? TRADESTARRENT
+ totalRent = initOverride ? 0 : g_MetaMan.m_Players[m_AnimMetaPlayer]->GetBrainPoolCount() > 0 ? TRADESTARRENT
: 0;
totalIncome = initOverride ? 0 : g_MetaMan.GetSceneIncomeOfPlayer(m_AnimMetaPlayer);
- totalEndFunds = g_MetaMan.m_Players[m_AnimMetaPlayer].m_PhaseStartFunds + totalIncome - totalRent;
+ totalEndFunds = g_MetaMan.m_Players[m_AnimMetaPlayer]->m_PhaseStartFunds + totalIncome - totalRent;
channelHeight = 60;
// TRADESTAR BANK ACCOUNT AND RENT
// Add line to show existing funds stored in space station, and deduct rent from
m_IncomeSiteLines.push_back(SiteLine(m_AnimMetaPlayer, 0, 1.0, m_StationPosOnOrbit, "TradeStar Midas", 0, c_GUIColorYellow, -1, 0, channelHeight, 2.0f));
- m_IncomeSiteLines.back().m_FundsAmount = g_MetaMan.m_Players[m_AnimMetaPlayer].m_PhaseStartFunds;
+ m_IncomeSiteLines.back().m_FundsAmount = g_MetaMan.m_Players[m_AnimMetaPlayer]->m_PhaseStartFunds;
m_IncomeSiteLines.back().m_FundsTarget = m_IncomeSiteLines.back().m_FundsAmount - totalRent;
// Save the index so we can update the line later
m_aStationIncomeLineIndices[m_AnimMetaPlayer] = m_IncomeSiteLines.size() - 1;
@@ -3199,7 +3199,7 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) {
// This is the text label showing the brain going away
BrainsChangeIndication(m_AnimMetaPlayer, -1, Vector(m_apBrainPoolLabel[m_AnimMetaPlayer]->GetXPos(), m_apBrainPoolLabel[m_AnimMetaPlayer]->GetYPos()), m_apBrainPoolLabel[m_AnimMetaPlayer]->GetHAlignment(), m_AnimModeDuration);
// This is the display adjustment to the actual counter; the final actual change at the end of the animation
- g_MetaMan.m_Players[m_AnimMetaPlayer].ChangeBrainsInTransit(1);
+ g_MetaMan.m_Players[m_AnimMetaPlayer]->ChangeBrainsInTransit(1);
}
}
// Show the site name over the site loc
@@ -3208,7 +3208,7 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) {
if (!m_AnimTimer1.IsPastRealMS(m_AnimModeDuration)) {
// Make this animation correlate in duration with the funds change label that rises
m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsAmount = EaseOut(0, m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsTarget, m_AnimTimer1.GetElapsedRealTimeMS() / m_AnimModeDuration);
- g_MetaMan.m_Players[m_AnimMetaPlayer].m_Funds = GetPlayerLineFunds(m_IncomeSiteLines, m_AnimMetaPlayer);
+ g_MetaMan.m_Players[m_AnimMetaPlayer]->m_Funds = GetPlayerLineFunds(m_IncomeSiteLines, m_AnimMetaPlayer);
UpdatePlayerLineRatios(m_IncomeSiteLines, m_AnimMetaPlayer);
m_AnimTimer2.Reset();
}
@@ -3216,7 +3216,7 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) {
else {
UpdateSiteNameLabel(false);
m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsAmount = m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsTarget;
- g_MetaMan.m_Players[m_AnimMetaPlayer].m_Funds = GetPlayerLineFunds(m_IncomeSiteLines, m_AnimMetaPlayer);
+ g_MetaMan.m_Players[m_AnimMetaPlayer]->m_Funds = GetPlayerLineFunds(m_IncomeSiteLines, m_AnimMetaPlayer);
UpdatePlayerLineRatios(m_IncomeSiteLines, m_AnimMetaPlayer);
// Check if there's more lines to draw, and if so, if the next one is of a different player
@@ -3253,7 +3253,7 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) {
/* This is done above on init now
// Only charge rent if we've still got brains at the tradestar
- if (g_MetaMan.m_Players[m_AnimMetaPlayer].GetBrainPoolCount() > 0)
+ if (g_MetaMan.m_Players[m_AnimMetaPlayer]->GetBrainPoolCount() > 0)
{
// Establish the after-rent target
m_AnimFundsMin = m_IncomeSiteLines[m_AnimIncomeLine].m_FundsAmount - TRADESTARRENT;
@@ -3272,16 +3272,16 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) {
// Shrink for a certain amount of time
if (!m_AnimTimer1.IsPastRealMS(m_AnimModeDuration)) {
// Make this animation correlate in duration with the funds change label that rises
- m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsAmount = EaseOut(g_MetaMan.m_Players[m_AnimMetaPlayer].m_PhaseStartFunds, m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsTarget, m_AnimTimer1.GetElapsedRealTimeMS() / m_AnimModeDuration);
+ m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsAmount = EaseOut(g_MetaMan.m_Players[m_AnimMetaPlayer]->m_PhaseStartFunds, m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsTarget, m_AnimTimer1.GetElapsedRealTimeMS() / m_AnimModeDuration);
UpdatePlayerLineRatios(m_IncomeSiteLines, m_AnimMetaPlayer);
- g_MetaMan.m_Players[m_AnimMetaPlayer].m_Funds = GetPlayerLineFunds(m_IncomeSiteLines, m_AnimMetaPlayer);
+ g_MetaMan.m_Players[m_AnimMetaPlayer]->m_Funds = GetPlayerLineFunds(m_IncomeSiteLines, m_AnimMetaPlayer);
m_AnimTimer2.Reset();
}
// Finished shrinking the meter to the target size
else {
UpdateSiteNameLabel(false);
m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsAmount = m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsTarget;
- g_MetaMan.m_Players[m_AnimMetaPlayer].m_Funds = GetPlayerLineFunds(m_IncomeSiteLines, m_AnimMetaPlayer);
+ g_MetaMan.m_Players[m_AnimMetaPlayer]->m_Funds = GetPlayerLineFunds(m_IncomeSiteLines, m_AnimMetaPlayer);
UpdatePlayerLineRatios(m_IncomeSiteLines, m_AnimMetaPlayer);
// Check if there's more lines to draw, and if so, if the next one is of a different player
@@ -3347,8 +3347,8 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) {
if ((*slItr).m_Player >= Players::PlayerOne && (*slItr).m_Player < Players::MaxPlayerCount &&
m_aBrainSaleIncomeLineIndices[(*slItr).m_Player] == lineIndex) {
// Remove the display adjustment and APPLY the actual change to brains when one is liquidated
- g_MetaMan.m_Players[(*slItr).m_Player].SetBrainsInTransit(0);
- g_MetaMan.m_Players[(*slItr).m_Player].ChangeBrainPoolCount(-1);
+ g_MetaMan.m_Players[(*slItr).m_Player]->SetBrainsInTransit(0);
+ g_MetaMan.m_Players[(*slItr).m_Player]->ChangeBrainPoolCount(-1);
}
// Keep this synched with the iterator
lineIndex++;
@@ -3362,11 +3362,11 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) {
m_apPlayerBarLabel[metaPlayer]->SetVisible(true);
// Set all funds to the final values, if not a gameover guy
if (g_MetaMan.GetTotalBrainCountOfPlayer(metaPlayer) > 0)
- g_MetaMan.m_Players[metaPlayer].m_Funds = GetPlayerLineFunds(m_IncomeSiteLines, metaPlayer, false);
+ g_MetaMan.m_Players[metaPlayer]->m_Funds = GetPlayerLineFunds(m_IncomeSiteLines, metaPlayer, false);
if (g_SettingsMan.EndlessMetaGameMode()) {
- g_MetaMan.m_Players[metaPlayer].ChangeBrainPoolCount(20 - g_MetaMan.m_Players[metaPlayer].GetBrainPoolCount());
- g_MetaMan.m_Players[metaPlayer].ChangeFunds(10000 - g_MetaMan.m_Players[metaPlayer].GetFunds());
+ g_MetaMan.m_Players[metaPlayer]->ChangeBrainPoolCount(20 - g_MetaMan.m_Players[metaPlayer]->GetBrainPoolCount());
+ g_MetaMan.m_Players[metaPlayer]->ChangeFunds(10000 - g_MetaMan.m_Players[metaPlayer]->GetFunds());
}
}
}
@@ -3374,18 +3374,18 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) {
void MetagameGUI::UpdateHumanPlayerTurn(int metaPlayer) {
// In-game player - IMPORTANT to pass this to the Scenes, and not the metaplayer
- int player = g_MetaMan.m_Players[metaPlayer].GetInGamePlayer();
+ int player = g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer();
// First do setup
if (g_MetaMan.m_StateChanged) {
// Reset the target so we don't put the player into autopilot (and also he might not have brains to deploy!)
- g_MetaMan.m_Players[metaPlayer].SetOffensiveBudget(0);
- g_MetaMan.m_Players[metaPlayer].SetOffensiveTargetName("");
+ g_MetaMan.m_Players[metaPlayer]->SetOffensiveBudget(0);
+ g_MetaMan.m_Players[metaPlayer]->SetOffensiveTargetName("");
// Re-set up all build budgets in oz to match what the player spent on this site last round, proportionally
for (std::vector::iterator sItr = g_MetaMan.m_Scenes.begin(); sItr != g_MetaMan.m_Scenes.end(); ++sItr) {
// Only mess with Scenes we can see and that are owned by this player, and he spent something on last turn
- if ((*sItr)->IsRevealed() && (*sItr)->GetTeamOwnership() == g_MetaMan.m_Players[metaPlayer].GetTeam() && (*sItr)->GetBuildBudgetRatio(player) > 0)
- (*sItr)->SetBuildBudget(player, g_MetaMan.m_Players[metaPlayer].GetFunds() * (*sItr)->GetBuildBudgetRatio(player));
+ if ((*sItr)->IsRevealed() && (*sItr)->GetTeamOwnership() == g_MetaMan.m_Players[metaPlayer]->GetTeam() && (*sItr)->GetBuildBudgetRatio(player) > 0)
+ (*sItr)->SetBuildBudget(player, g_MetaMan.m_Players[metaPlayer]->GetFunds() * (*sItr)->GetBuildBudgetRatio(player));
}
}
@@ -3394,8 +3394,8 @@ void MetagameGUI::UpdateHumanPlayerTurn(int metaPlayer) {
// Save all the base building budget ratios sowe can re-set the gold values next turn, for player convenience
for (std::vector::iterator sItr = g_MetaMan.m_Scenes.begin(); sItr != g_MetaMan.m_Scenes.end(); ++sItr) {
// Only mess with Scenes we can see and that are owned by this player, and he spent something on last turn
- if ((*sItr)->IsRevealed() && (*sItr)->GetTeamOwnership() == g_MetaMan.m_Players[metaPlayer].GetTeam() && g_MetaMan.m_Players[metaPlayer].GetFunds() > 0)
- (*sItr)->SetBuildBudgetRatio(player, (*sItr)->GetBuildBudget(player) / g_MetaMan.m_Players[metaPlayer].GetFunds());
+ if ((*sItr)->IsRevealed() && (*sItr)->GetTeamOwnership() == g_MetaMan.m_Players[metaPlayer]->GetTeam() && g_MetaMan.m_Players[metaPlayer]->GetFunds() > 0)
+ (*sItr)->SetBuildBudgetRatio(player, (*sItr)->GetBuildBudget(player) / g_MetaMan.m_Players[metaPlayer]->GetFunds());
else
(*sItr)->SetBuildBudgetRatio(player, 0);
}
@@ -3413,7 +3413,7 @@ void MetagameGUI::UpdateBaseBuilding() {
// Make sure all fund labels and line ratios are good
for (int metaPlayer = Players::PlayerOne; metaPlayer < static_cast(g_MetaMan.m_Players.size()); ++metaPlayer) {
// Save the fund levels FROM THE START so we can calculate the after state if players skip the animation
- g_MetaMan.m_Players[metaPlayer].m_PhaseStartFunds = g_MetaMan.m_Players[metaPlayer].m_Funds;
+ g_MetaMan.m_Players[metaPlayer]->m_PhaseStartFunds = g_MetaMan.m_Players[metaPlayer]->m_Funds;
// Update the player action lines for all players one last time; this will catch the AI ones as well and reflect their actions
UpdatePlayerActionLines(metaPlayer);
@@ -3423,15 +3423,15 @@ void MetagameGUI::UpdateBaseBuilding() {
(*slItr).m_OnlyFirstSegments = 1;
(*slItr).m_OnlyLastSegments = -1;
}
- UpdatePlayerLineRatios(m_ActionSiteLines[metaPlayer], metaPlayer, false, g_MetaMan.m_Players[metaPlayer].m_Funds);
+ UpdatePlayerLineRatios(m_ActionSiteLines[metaPlayer], metaPlayer, false, g_MetaMan.m_Players[metaPlayer]->m_Funds);
// Also, for human players, auto design their blueprints if they have chosen to do so
- if (g_MetaMan.m_Players[metaPlayer].IsHuman()) {
+ if (g_MetaMan.m_Players[metaPlayer]->IsHuman()) {
// Go through all scenes and check if they're owned by this, and if so, whether their defenses should be automatically designed by canned AI plan
for (std::vector::iterator sItr = g_MetaMan.m_Scenes.begin(); sItr != g_MetaMan.m_Scenes.end(); ++sItr) {
// Move building pieces from the Scene's AI plan queue to the actual blueprints, but only approximately as much as can afford, so the entire AI pre-built base plan isn't revealed
- if ((*sItr)->GetTeamOwnership() == g_MetaMan.m_Players[metaPlayer].GetTeam() && (*sItr)->GetAutoDesigned())
- (*sItr)->ApplyAIPlan(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer());
+ if ((*sItr)->GetTeamOwnership() == g_MetaMan.m_Players[metaPlayer]->GetTeam() && (*sItr)->GetAutoDesigned())
+ (*sItr)->ApplyAIPlan(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer());
}
}
}
@@ -3530,14 +3530,14 @@ void MetagameGUI::UpdateBaseBuilding() {
m_ActionSiteLines[m_AnimMetaPlayer][m_AnimActionLine].m_OnlyLastSegments = -1;
m_ActionSiteLines[m_AnimMetaPlayer][m_AnimActionLine].m_OnlyFirstSegments = -1;
// Save the total funds so we can make the proportional animation right
- m_AnimTotalFunds = g_MetaMan.m_Players[m_AnimMetaPlayer].m_Funds;
+ m_AnimTotalFunds = g_MetaMan.m_Players[m_AnimMetaPlayer]->m_Funds;
// Get a handy pointer to the scene we're talking about
m_pAnimScene = m_ActionSiteLines[m_AnimMetaPlayer][m_AnimActionLine].m_pScene;
RTEAssert(m_pAnimScene, "Couldn't find the scene that we're building the base on!");
// Using the line target as the going-from point
m_AnimFundsMax = m_ActionSiteLines[m_AnimMetaPlayer][m_AnimActionLine].m_FundsAmount;
// The calculated budget use is the target value we're shrinking to
- m_AnimFundsMin = m_AnimFundsMax - m_pAnimScene->CalcBuildBudgetUse(g_MetaMan.m_Players[m_AnimMetaPlayer].GetInGamePlayer(), &m_AnimBuildCount);
+ m_AnimFundsMin = m_AnimFundsMax - m_pAnimScene->CalcBuildBudgetUse(g_MetaMan.m_Players[m_AnimMetaPlayer]->GetInGamePlayer(), &m_AnimBuildCount);
// Show the negative change of funds, if any
if ((m_AnimFundsMin - m_AnimFundsMax) < 0)
FundsChangeIndication(m_AnimMetaPlayer, m_AnimFundsMin - m_AnimFundsMax, Vector(m_apPlayerBarLabel[m_AnimMetaPlayer]->GetXPos() + m_apPlayerBarLabel[m_AnimMetaPlayer]->GetWidth(), m_apPlayerBarLabel[m_AnimMetaPlayer]->GetYPos()), 2000);
@@ -3549,15 +3549,15 @@ void MetagameGUI::UpdateBaseBuilding() {
// Make this animation match in duration with the funds change label that is falling
m_ActionSiteLines[m_AnimMetaPlayer][m_AnimActionLine].m_FundsAmount = EaseOut(m_AnimFundsMax, m_AnimFundsMin, m_AnimTimer1.GetElapsedRealTimeMS() / 2000); //(m_AnimFundsMax * 2));
// Adjust the funds to show how much we subtracted this frame
- g_MetaMan.m_Players[m_AnimMetaPlayer].m_Funds = m_AnimTotalFunds - (m_AnimFundsMax - m_ActionSiteLines[m_AnimMetaPlayer][m_AnimActionLine].m_FundsAmount);
- UpdatePlayerLineRatios(m_ActionSiteLines[m_AnimMetaPlayer], m_AnimMetaPlayer, false, g_MetaMan.m_Players[m_AnimMetaPlayer].m_Funds);
+ g_MetaMan.m_Players[m_AnimMetaPlayer]->m_Funds = m_AnimTotalFunds - (m_AnimFundsMax - m_ActionSiteLines[m_AnimMetaPlayer][m_AnimActionLine].m_FundsAmount);
+ UpdatePlayerLineRatios(m_ActionSiteLines[m_AnimMetaPlayer], m_AnimMetaPlayer, false, g_MetaMan.m_Players[m_AnimMetaPlayer]->m_Funds);
m_AnimTimer2.Reset();
}
// Finished shrinking the meter to the target size, now start disconnecting it
else {
UpdateSiteNameLabel(false);
m_ActionSiteLines[m_AnimMetaPlayer][m_AnimActionLine].m_FundsAmount = m_AnimFundsMin;
- UpdatePlayerLineRatios(m_ActionSiteLines[m_AnimMetaPlayer], m_AnimMetaPlayer, false, g_MetaMan.m_Players[m_AnimMetaPlayer].m_Funds);
+ UpdatePlayerLineRatios(m_ActionSiteLines[m_AnimMetaPlayer], m_AnimMetaPlayer, false, g_MetaMan.m_Players[m_AnimMetaPlayer]->m_Funds);
ChangeAnimMode(LINEDISCONNECTFW);
}
@@ -3615,7 +3615,7 @@ void MetagameGUI::UpdateBaseBuilding() {
Scene* pScene = 0;
for (int metaPlayer = Players::PlayerOne; metaPlayer < static_cast(g_MetaMan.m_Players.size()); ++metaPlayer) {
// Reset the funds to the full value before we started messing with animating them
- g_MetaMan.m_Players[metaPlayer].m_Funds = g_MetaMan.m_Players[metaPlayer].m_PhaseStartFunds;
+ g_MetaMan.m_Players[metaPlayer]->m_Funds = g_MetaMan.m_Players[metaPlayer]->m_PhaseStartFunds;
// Go through the sitelines and make sure all the things that need to be done are done before moving onto next phase
for (std::vector::iterator slItr = m_ActionSiteLines[metaPlayer].begin(); slItr != m_ActionSiteLines[metaPlayer].end(); ++slItr) {
@@ -3627,9 +3627,9 @@ void MetagameGUI::UpdateBaseBuilding() {
// Acutally do the spending on these places that have this player's brain and has funds budgeted for them
// THIS IS WHAT GETS STUFF BUILT
// NOTE THE CAREFUL MAPPING BETWEEN METAPLAYERS AND IN-GAME PLAYERS
- int player = g_MetaMan.m_Players[metaPlayer].GetInGamePlayer();
+ int player = g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer();
if (pScene->GetResidentBrain(player) && pScene->GetBuildBudget(player) > 0)
- g_MetaMan.m_Players[metaPlayer].m_Funds -= pScene->ApplyBuildBudget(player);
+ g_MetaMan.m_Players[metaPlayer]->m_Funds -= pScene->ApplyBuildBudget(player);
}
}
// Reset all non-defensive lines' segment animations so we can see them
@@ -3642,8 +3642,8 @@ void MetagameGUI::UpdateBaseBuilding() {
// Make all scene build budgets set to 0; they will be re-set to their previous turns' budget ratios on the next player turns
for (std::vector::iterator sItr = g_MetaMan.m_Scenes.begin(); sItr != g_MetaMan.m_Scenes.end(); ++sItr) {
// Only mess with Scenes we can see and that are owned by this player's team
- if ((*sItr)->IsRevealed() && (*sItr)->GetTeamOwnership() == g_MetaMan.m_Players[metaPlayer].GetTeam())
- (*sItr)->SetBuildBudget(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer(), 0);
+ if ((*sItr)->IsRevealed() && (*sItr)->GetTeamOwnership() == g_MetaMan.m_Players[metaPlayer]->GetTeam())
+ (*sItr)->SetBuildBudget(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer(), 0);
}
// Refresh the aciton lines one last time before moving on, which will CLEAN OUT all defensive action lines!
UpdatePlayerActionLines(metaPlayer);
@@ -3663,10 +3663,10 @@ void MetagameGUI::SetupOffensives() {
int offensiveCount = 0;
for (int metaPlayer = Players::PlayerOne; metaPlayer < static_cast(g_MetaMan.m_Players.size()); ++metaPlayer) {
playerDone = false;
- team = g_MetaMan.m_Players[metaPlayer].GetTeam();
+ team = g_MetaMan.m_Players[metaPlayer]->GetTeam();
// If we have a selected offensive target, find its scene in the metagame
- targetName = g_MetaMan.m_Players[metaPlayer].GetOffensiveTargetName();
- offensiveBudget = g_MetaMan.m_Players[metaPlayer].GetOffensiveBudget();
+ targetName = g_MetaMan.m_Players[metaPlayer]->GetOffensiveTargetName();
+ offensiveBudget = g_MetaMan.m_Players[metaPlayer]->GetOffensiveBudget();
if (!targetName.empty() && offensiveBudget > 0) {
for (std::vector::iterator sItr = g_MetaMan.m_Scenes.begin(); !playerDone && sItr != g_MetaMan.m_Scenes.end(); ++sItr) {
if ((*sItr)->IsRevealed() && (*sItr)->GetPresetName() == targetName) {
@@ -3674,7 +3674,7 @@ void MetagameGUI::SetupOffensives() {
for (std::vector::iterator aItr = g_MetaMan.m_RoundOffensives.begin(); aItr != g_MetaMan.m_RoundOffensives.end(); ++aItr) {
if ((*aItr)->GetSceneName() == targetName) {
// Ok, activity at this site already exists, so add this player to the attacking forces
- (*aItr)->AddPlayer(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer(), g_MetaMan.m_Players[metaPlayer].IsHuman(), team, offensiveBudget, &(g_MetaMan.GetTeamIcon(team)));
+ (*aItr)->AddPlayer(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer(), g_MetaMan.m_Players[metaPlayer]->IsHuman(), team, offensiveBudget, &(g_MetaMan.GetTeamIcon(team)));
// Move onto next player
playerDone = true;
}
@@ -3699,7 +3699,7 @@ void MetagameGUI::SetupOffensives() {
pOffensive->SetTeamAISkill(t, g_MetaMan.m_TeamAISkill[t]);
// Attacker
- pOffensive->AddPlayer(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer(), g_MetaMan.m_Players[metaPlayer].IsHuman(), team, offensiveBudget, &(g_MetaMan.GetTeamIcon(team)));
+ pOffensive->AddPlayer(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer(), g_MetaMan.m_Players[metaPlayer]->IsHuman(), team, offensiveBudget, &(g_MetaMan.GetTeamIcon(team)));
// Unless exploring an unclaimed spot, there's going to be defenders
if ((*sItr)->GetTeamOwnership() != Activity::NoTeam) {
@@ -3707,9 +3707,9 @@ void MetagameGUI::SetupOffensives() {
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// Got to remember to translate from metagame player index into the in-game player index
// TODO: Remove this requirement to have a brain resident to play? error-prone and not so fun for co-op player on sme team if they can't all play
- // if (g_MetaMan.m_Players[mp].GetTeam() == (*sItr)->GetTeamOwnership())
- if ((*sItr)->GetResidentBrain(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
- pOffensive->AddPlayer(g_MetaMan.m_Players[mp].GetInGamePlayer(), g_MetaMan.m_Players[mp].IsHuman(), g_MetaMan.m_Players[mp].GetTeam(), g_MetaMan.GetRemainingFundsOfPlayer(mp, *sItr, false, false), &(g_MetaMan.GetTeamIcon(g_MetaMan.m_Players[mp].GetTeam())));
+ // if (g_MetaMan.m_Players[mp]->GetTeam() == (*sItr)->GetTeamOwnership())
+ if ((*sItr)->GetResidentBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
+ pOffensive->AddPlayer(g_MetaMan.m_Players[mp]->GetInGamePlayer(), g_MetaMan.m_Players[mp]->IsHuman(), g_MetaMan.m_Players[mp]->GetTeam(), g_MetaMan.GetRemainingFundsOfPlayer(mp, *sItr, false, false), &(g_MetaMan.GetTeamIcon(g_MetaMan.m_Players[mp]->GetTeam())));
}
}
}
@@ -3804,9 +3804,9 @@ void MetagameGUI::UpdateOffensives() {
// Set up all the offensive and defensive lines for each player involved in this site's battle
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// If this player is involved in this fight, show his lines etc
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
// Save the fund levels FROM THE START of each battle so we can calculate the after state if players skip the animation
- g_MetaMan.m_Players[mp].m_PhaseStartFunds = g_MetaMan.m_Players[mp].m_Funds;
+ g_MetaMan.m_Players[mp]->m_PhaseStartFunds = g_MetaMan.m_Players[mp]->m_Funds;
// Rebuild all the action site lines for the player
float meterStart = UpdatePlayerActionLines(mp);
@@ -3817,8 +3817,8 @@ void MetagameGUI::UpdateOffensives() {
m_aBrainIconPos[mp].Reset();
// What is this player attacking?
- std::string targetName = g_MetaMan.m_Players[mp].GetOffensiveTargetName();
- float offensiveBudget = g_MetaMan.m_Players[mp].GetOffensiveBudget();
+ std::string targetName = g_MetaMan.m_Players[mp]->GetOffensiveTargetName();
+ float offensiveBudget = g_MetaMan.m_Players[mp]->GetOffensiveBudget();
// If attacking anything, see if it's the current site that's getting hit
if (!targetName.empty() && offensiveBudget > 0) {
// Set the displayed battle funds for this player if it's attacking this site
@@ -3830,20 +3830,20 @@ void MetagameGUI::UpdateOffensives() {
// If this player owns and has a resident brain at this site, add his defending action line of unallocated funds,
// and also update the offensive activity itself to match teh defensive funds to what he has left after multiple completed offensives this turn
- if (m_pAnimScene->GetTeamOwnership() == g_MetaMan.m_Players[mp].GetTeam() && m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (m_pAnimScene->GetTeamOwnership() == g_MetaMan.m_Players[mp]->GetTeam() && m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
// Find out how much gold this player has left after all allocations and previous battles this turn
float remainingFunds = g_MetaMan.GetRemainingFundsOfPlayer(mp);
// UPDATE the contributed funds of the defending player to whatever gold he has left after all (if any) previous battles this turn!
- bool updated = g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->UpdatePlayerFundsContribution(g_MetaMan.m_Players[mp].GetInGamePlayer(), remainingFunds);
+ bool updated = g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->UpdatePlayerFundsContribution(g_MetaMan.m_Players[mp]->GetInGamePlayer(), remainingFunds);
// Add the unused build budget FOR THIS SCENE to the battle funds display - doesn't do anyhting now because build budgets are set to 0 in UpdateBaseBuilding
- m_aBattleFunds[mp] += m_pAnimScene->GetBuildBudget(g_MetaMan.m_Players[mp].GetInGamePlayer());
+ m_aBattleFunds[mp] += m_pAnimScene->GetBuildBudget(g_MetaMan.m_Players[mp]->GetInGamePlayer());
// Add the unallocated funds meter, even if there's 0 left.. it shows why there's 0, and also the meter can grow after battle if the defending player digs up gold
if (remainingFunds >= 0) {
// Tell the player why he has no defensive money... uh too early
// if (remainingFunds <= 0)
// PlayerTextIndication(mp, "No unallocated funds!", Vector(m_apPlayerBox[mp]->GetXPos(), m_apPlayerBox[mp]->GetYPos()), 1500);
- m_ActionSiteLines[mp].push_back(SiteLine(mp, meterStart, remainingFunds / g_MetaMan.m_Players[mp].m_Funds, m_pAnimScene->GetLocation() + m_pAnimScene->GetLocationOffset(), m_pAnimScene->GetPresetName(), m_pAnimScene, c_GUIColorYellow, -1, -1, 60, 1.0f, g_MetaMan.IsActiveTeam(m_pAnimScene->GetTeamOwnership())));
+ m_ActionSiteLines[mp].push_back(SiteLine(mp, meterStart, remainingFunds / g_MetaMan.m_Players[mp]->m_Funds, m_pAnimScene->GetLocation() + m_pAnimScene->GetLocationOffset(), m_pAnimScene->GetPresetName(), m_pAnimScene, c_GUIColorYellow, -1, -1, 60, 1.0f, g_MetaMan.IsActiveTeam(m_pAnimScene->GetTeamOwnership())));
// This will actually affect the line meter
m_ActionSiteLines[mp].back().m_FundsAmount = remainingFunds;
// Add to the battle funds display too
@@ -3860,7 +3860,7 @@ void MetagameGUI::UpdateOffensives() {
}
// Update the ratios now that we've messed with them
- UpdatePlayerLineRatios(m_ActionSiteLines[mp], mp, false, g_MetaMan.m_Players[mp].m_Funds);
+ UpdatePlayerLineRatios(m_ActionSiteLines[mp], mp, false, g_MetaMan.m_Players[mp]->m_Funds);
}
// If player not involved in the fight then hide all lines of this player
{
@@ -3920,10 +3920,10 @@ void MetagameGUI::UpdateOffensives() {
// Make sure all offensive action lines are set up for this phase
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// Find all players that are active during this battle
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
// If this player is attacking, indicate that we've got a brain in transit.. this just changes the display, not the actual brain pool count yet
- if (m_pAnimScene->GetPresetName() == g_MetaMan.m_Players[mp].GetOffensiveTargetName())
- g_MetaMan.m_Players[mp].ChangeBrainsInTransit(1);
+ if (m_pAnimScene->GetPresetName() == g_MetaMan.m_Players[mp]->GetOffensiveTargetName())
+ g_MetaMan.m_Players[mp]->ChangeBrainsInTransit(1);
// Find their offensive funds site lines
for (std::vector::iterator slItr = m_ActionSiteLines[mp].begin(); slItr != m_ActionSiteLines[mp].end(); ++slItr) {
@@ -3950,8 +3950,8 @@ void MetagameGUI::UpdateOffensives() {
if (m_AnimTimer1.GetElapsedRealTimeMS() > 150) {
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// Only care if this player is attacking this site
- if (m_pAnimScene->GetPresetName() == g_MetaMan.m_Players[mp].GetOffensiveTargetName() && g_MetaMan.m_Players[mp].GetOffensiveBudget() > 0)
- // if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp].GetInGamePlayer()))
+ if (m_pAnimScene->GetPresetName() == g_MetaMan.m_Players[mp]->GetOffensiveTargetName() && g_MetaMan.m_Players[mp]->GetOffensiveBudget() > 0)
+ // if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp]->GetInGamePlayer()))
{
// Find their offensive funds site lines
for (std::vector::iterator slItr = m_ActionSiteLines[mp].begin(); slItr != m_ActionSiteLines[mp].end(); ++slItr) {
@@ -4027,9 +4027,9 @@ void MetagameGUI::UpdateOffensives() {
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// Only care of this player is involved in this particular battle
// Only care about defending players of this site
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp].GetInGamePlayer()) &&
- m_pAnimScene->GetTeamOwnership() == g_MetaMan.m_Players[mp].GetTeam() &&
- m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp]->GetInGamePlayer()) &&
+ m_pAnimScene->GetTeamOwnership() == g_MetaMan.m_Players[mp]->GetTeam() &&
+ m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
// Find their defensive funds site lines
for (std::vector::iterator slItr = m_ActionSiteLines[mp].begin(); slItr != m_ActionSiteLines[mp].end(); ++slItr) {
// Offensive lines are green; unallocated funds are white - attach all of them
@@ -4055,12 +4055,12 @@ void MetagameGUI::UpdateOffensives() {
if (m_AnimTimer1.GetElapsedRealTimeMS() > 150) {
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// Only care of this player is involved in this particular battle
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
// Find their defensive-related funds site lines
for (std::vector::iterator slItr = m_ActionSiteLines[mp].begin(); slItr != m_ActionSiteLines[mp].end(); ++slItr) {
// Offensive lines are red; grow the defensive ones relevant to this scene
if ((*slItr).m_Color != c_GUIColorRed && m_pAnimScene->GetPresetName() == (*slItr).m_SiteName &&
- (m_pAnimScene->GetTeamOwnership() == g_MetaMan.m_Players[mp].GetTeam() && m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp].GetInGamePlayer())))
+ (m_pAnimScene->GetTeamOwnership() == g_MetaMan.m_Players[mp]->GetTeam() && m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer())))
(*slItr).m_OnlyLastSegments++;
}
}
@@ -4124,22 +4124,22 @@ void MetagameGUI::UpdateOffensives() {
// Make sure all offensive action-related lines are set up for this battle review animation
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// Only the players of this battle
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
// Find their site lines that are connected to the site
for (std::vector::iterator slItr = m_ActionSiteLines[mp].begin(); slItr != m_ActionSiteLines[mp].end(); ++slItr) {
// Only lines that are connected are relevant
if ((*slItr).m_OnlyFirstSegments > 1 || (*slItr).m_OnlyLastSegments > 1) {
// Re-set the funds amount we're going from - actually, not necessary
- (*slItr).m_FundsAmount = g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsContribution(g_MetaMan.m_Players[mp].GetInGamePlayer());
+ (*slItr).m_FundsAmount = g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsContribution(g_MetaMan.m_Players[mp]->GetInGamePlayer());
// Set the target we're going toward
- (*slItr).m_FundsTarget = g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsShare(g_MetaMan.m_Players[mp].GetInGamePlayer());
+ (*slItr).m_FundsTarget = g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsShare(g_MetaMan.m_Players[mp]->GetInGamePlayer());
// Start the battle money display off at the right point too
m_aBattleFunds[mp] = (*slItr).m_FundsAmount;
// Display the change amount over/under the player bar
FundsChangeIndication(mp, (*slItr).m_FundsTarget - (*slItr).m_FundsAmount, Vector(m_apPlayerBarLabel[mp]->GetXPos() + m_apPlayerBarLabel[mp]->GetWidth(), m_apPlayerBarLabel[mp]->GetYPos()), m_AnimModeDuration);
// Update the ratios.. shouldn't do anyhitng, really
- UpdatePlayerLineRatios(m_ActionSiteLines[mp], mp, false, g_MetaMan.m_Players[mp].m_Funds);
+ UpdatePlayerLineRatios(m_ActionSiteLines[mp], mp, false, g_MetaMan.m_Players[mp]->m_Funds);
}
}
}
@@ -4152,10 +4152,10 @@ void MetagameGUI::UpdateOffensives() {
// Find the players who are involved in this battle
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// Only the players of this battle
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
// The brains who DID NOT MAKE IT - Show them blowing up at some random interval into the animation
- if (!m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp].GetInGamePlayer()) &&
- !g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (!m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer()) &&
+ !g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
// If not yet blown up, then see if we should yet
if (!m_aAnimDestroyed[mp] && m_AnimTimer2.GetElapsedRealTimeMS() > (m_AnimModeDuration * 0.5F) && RandomNum() < 0.05F) {
// Add circle explosion effect to where the brain icon used to be
@@ -4169,7 +4169,7 @@ void MetagameGUI::UpdateOffensives() {
for (std::vector::iterator slItr = m_ActionSiteLines[mp].begin(); slItr != m_ActionSiteLines[mp].end(); ++slItr) {
// Only lines that are connected are relevant
if ((*slItr).m_OnlyFirstSegments > 1 || (*slItr).m_OnlyLastSegments > 1) {
- float startFunds = g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsContribution(g_MetaMan.m_Players[mp].GetInGamePlayer());
+ float startFunds = g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsContribution(g_MetaMan.m_Players[mp]->GetInGamePlayer());
// Grow/shrink all the meters, showing how the funds changed during battle
if (m_AnimTimer1.GetElapsedRealTimeMS() < m_AnimModeDuration) {
@@ -4178,14 +4178,14 @@ void MetagameGUI::UpdateOffensives() {
// Update the battle funds display; it will be shown in the brian action label
m_aBattleFunds[mp] = (*slItr).m_FundsAmount;
// Adjust the funds to show how much we subtracted this frame - this will be reset in the end anyway, it's just for show during this battle review animation
- g_MetaMan.m_Players[mp].m_Funds = g_MetaMan.m_Players[mp].m_PhaseStartFunds - (startFunds - (*slItr).m_FundsAmount);
- UpdatePlayerLineRatios(m_ActionSiteLines[mp], mp, false, g_MetaMan.m_Players[mp].m_Funds);
+ g_MetaMan.m_Players[mp]->m_Funds = g_MetaMan.m_Players[mp]->m_PhaseStartFunds - (startFunds - (*slItr).m_FundsAmount);
+ UpdatePlayerLineRatios(m_ActionSiteLines[mp], mp, false, g_MetaMan.m_Players[mp]->m_Funds);
}
// Finished growing the meter to the target size
else {
m_aBattleFunds[mp] = (*slItr).m_FundsAmount = (*slItr).m_FundsTarget;
- g_MetaMan.m_Players[mp].m_Funds = g_MetaMan.m_Players[mp].m_PhaseStartFunds - (startFunds - (*slItr).m_FundsAmount);
- UpdatePlayerLineRatios(m_ActionSiteLines[mp], mp, false, g_MetaMan.m_Players[mp].m_Funds);
+ g_MetaMan.m_Players[mp]->m_Funds = g_MetaMan.m_Players[mp]->m_PhaseStartFunds - (startFunds - (*slItr).m_FundsAmount);
+ UpdatePlayerLineRatios(m_ActionSiteLines[mp], mp, false, g_MetaMan.m_Players[mp]->m_Funds);
}
}
}
@@ -4211,10 +4211,10 @@ void MetagameGUI::UpdateOffensives() {
// Find the players who are involved in this battle
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// Only the players of this battle who didn't evacuate
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp].GetInGamePlayer()) &&
- !g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer()) &&
+ !g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
// The brains who DID NOT MAKE IT - Show them blowing up
- if (!m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (!m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
// If not yet blown up, then we should be
if (!m_aAnimDestroyed[mp]) {
// Add circle explosion effect to where the brain icon used to be
@@ -4265,9 +4265,9 @@ void MetagameGUI::UpdateOffensives() {
// Find the players who are evacuated anything this battle
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// Only the players of this battle who evac'd their brain
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
// Both an Attacker aborting an attack, and a Defender abandoning his site has the same effect here on the brian pool display
- g_MetaMan.m_Players[mp].ChangeBrainsInTransit(-1);
+ g_MetaMan.m_Players[mp]->ChangeBrainsInTransit(-1);
}
}
}
@@ -4305,9 +4305,9 @@ void MetagameGUI::UpdateOffensives() {
// Find the players who are involved in this battle
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// Only the players of this battle
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
// The guys who died - remove their icons completely
- if (!m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp].GetInGamePlayer()))
+ if (!m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer()))
m_apPlayerBrainTravelLabel[mp]->SetVisible(false);
}
}
@@ -4333,7 +4333,7 @@ void MetagameGUI::UpdateOffensives() {
// Max out the offensive lines in case the player started the battle before the lines were fully animated as connected
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// Only care of this player is involved in this particular battle
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
for (std::vector::iterator slItr = m_ActionSiteLines[mp].begin(); slItr != m_ActionSiteLines[mp].end(); ++slItr) {
// Only show lines that are going to the site we're battling on
if ((*slItr).m_SiteName == m_pAnimScene->GetPresetName()) {
@@ -4341,7 +4341,7 @@ void MetagameGUI::UpdateOffensives() {
if ((*slItr).m_Color == c_GUIColorRed)
(*slItr).m_OnlyFirstSegments = 15;
// Defensive site
- else if (m_pAnimScene->GetTeamOwnership() == g_MetaMan.m_Players[mp].GetTeam() && m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp].GetInGamePlayer()))
+ else if (m_pAnimScene->GetTeamOwnership() == g_MetaMan.m_Players[mp]->GetTeam() && m_pAnimScene->GetResidentBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer()))
(*slItr).m_OnlyLastSegments = 15;
}
// Hide all other lines
@@ -4408,33 +4408,33 @@ bool MetagameGUI::FinalizeOffensive() {
// Deduct the original funds contribution of each player - less any unused funds of the team, taking original player contribution ratios into account
for (size_t mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
// Only the players who were battling this offensive
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp]->GetInGamePlayer())) {
// Re-set the funds level to where it was at the start of this offensive (NOT at the start of the phase, actually)
- g_MetaMan.m_Players[mp].m_Funds = g_MetaMan.m_Players[mp].m_PhaseStartFunds;
+ g_MetaMan.m_Players[mp]->m_Funds = g_MetaMan.m_Players[mp]->m_PhaseStartFunds;
// Deduct the original contribution to team funds
- g_MetaMan.m_Players[mp].m_Funds -= g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsContribution(g_MetaMan.m_Players[mp].GetInGamePlayer());
+ g_MetaMan.m_Players[mp]->m_Funds -= g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsContribution(g_MetaMan.m_Players[mp]->GetInGamePlayer());
// Add back whatever his share of whatever his team has left in the fight at its end
- g_MetaMan.m_Players[mp].m_Funds += g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsShare(g_MetaMan.m_Players[mp].GetInGamePlayer());
+ g_MetaMan.m_Players[mp]->m_Funds += g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsShare(g_MetaMan.m_Players[mp]->GetInGamePlayer());
// IF This guy was ATTACKING this turn, adjust his attack budget to match what just happened in the battle
// so in case he is defending in a upcoming battle this turn, his avaialbe funds will be accurately calculated
- if (g_MetaMan.m_Players[mp].GetOffensiveTargetName() == m_pAnimScene->GetPresetName()) {
- g_MetaMan.m_Players[mp].SetOffensiveBudget(g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsShare(g_MetaMan.m_Players[mp].GetInGamePlayer()));
- // g_MetaMan.m_Players[mp].SetOffensiveTargetName("");
+ if (g_MetaMan.m_Players[mp]->GetOffensiveTargetName() == m_pAnimScene->GetPresetName()) {
+ g_MetaMan.m_Players[mp]->SetOffensiveBudget(g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->GetPlayerFundsShare(g_MetaMan.m_Players[mp]->GetInGamePlayer()));
+ // g_MetaMan.m_Players[mp]->SetOffensiveTargetName("");
// The only condition where this attacking player does NOT get a brain deducted from pool, is when he aborts the attack with an evacuation and the brain goes back to pool!
- if (!g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated(g_MetaMan.m_Players[mp].GetInGamePlayer()))
- g_MetaMan.m_Players[mp].ChangeBrainPoolCount(-1);
+ if (!g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated(g_MetaMan.m_Players[mp]->GetInGamePlayer()))
+ g_MetaMan.m_Players[mp]->ChangeBrainPoolCount(-1);
}
// Defending player
else {
// If this player evacuated his brain, WHILE DEFENDING, then add it back to his pool
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated(g_MetaMan.m_Players[mp].GetInGamePlayer()))
- g_MetaMan.m_Players[mp].ChangeBrainPoolCount(1);
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated(g_MetaMan.m_Players[mp]->GetInGamePlayer()))
+ g_MetaMan.m_Players[mp]->ChangeBrainPoolCount(1);
}
// Update the ratios of the meter now that the funds have changed
- UpdatePlayerLineRatios(m_ActionSiteLines[mp], mp, false, g_MetaMan.m_Players[mp].m_Funds);
+ UpdatePlayerLineRatios(m_ActionSiteLines[mp], mp, false, g_MetaMan.m_Players[mp]->m_Funds);
// Clear out the brain transit display either way; nothing should be out flying now anyway
- g_MetaMan.m_Players[mp].SetBrainsInTransit(0);
+ g_MetaMan.m_Players[mp]->SetBrainsInTransit(0);
}
}
@@ -4469,12 +4469,12 @@ bool MetagameGUI::FinalizeOffensive() {
void MetagameGUI::ResetBattleInfo() {
int mp = 0;
- for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
+ for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
// Init and hide everything initially
if (!m_apPlayerTeamActionBox[mp]->GetDrawImage()) {
// Set the flag icons on the floating player bars
m_apPlayerTeamActionBox[mp]->SetDrawType(GUICollectionBox::Image);
- m_apPlayerTeamActionBox[mp]->SetDrawImage(new AllegroBitmap(g_MetaMan.m_TeamIcons[(*mpItr).GetTeam()].GetBitmaps32()[0]));
+ m_apPlayerTeamActionBox[mp]->SetDrawImage(new AllegroBitmap(g_MetaMan.m_TeamIcons[(*mpItr)->GetTeam()].GetBitmaps32()[0]));
}
// Hide everything initially
m_apPlayerTeamActionBox[mp]->SetVisible(false);
@@ -4496,7 +4496,7 @@ void MetagameGUI::UpdateBattleQuads(Vector targetPos) {
// Go through all players, assigning the quads depending on how the player bars are positioned in relation to each other
int mp = 0;
- for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
+ for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
// Select which quadrant makes most sense for this player, based on his floating bar's position relative to the site
int initialQuad = 0;
if (m_apPlayerBox[mp]->GetXPos() < targetPos.m_X)
@@ -4551,10 +4551,10 @@ void MetagameGUI::UpdatePreBattleAttackers(float progress) {
UpdateBattleQuads(siteScreenPos);
// Go through all attacking players for this activity
- for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
+ for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
// Player active and ATTACKING in current battle, so display his team flag and place it according to the animation progress
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive((*mpItr).GetInGamePlayer()) &&
- !m_pAnimScene->GetResidentBrain((*mpItr).GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive((*mpItr)->GetInGamePlayer()) &&
+ !m_pAnimScene->GetResidentBrain((*mpItr)->GetInGamePlayer())) {
// Show the active players' team flag icons around the site if the brains have arrived
m_apPlayerTeamActionBox[mp]->SetVisible(progress >= 1.0);
// Show the traveling brain if we're not at 0
@@ -4686,10 +4686,10 @@ void MetagameGUI::UpdatePreBattleDefenders(float progress) {
UpdateBattleQuads(siteScreenPos);
// Go through all players for this activity
- for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
+ for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
// Player active and DEFENDING in current battle, so display his team flag and place it according to the animation progress
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive((*mpItr).GetInGamePlayer()) &&
- m_pAnimScene->GetResidentBrain((*mpItr).GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive((*mpItr)->GetInGamePlayer()) &&
+ m_pAnimScene->GetResidentBrain((*mpItr)->GetInGamePlayer())) {
// Show the active players' team flag icons around the site if the brains have arrived
m_apPlayerTeamActionBox[mp]->SetVisible(progress >= 1.0);
// Show the traveling brain if we're not at 0
@@ -4809,10 +4809,10 @@ void MetagameGUI::UpdatePostBattleRetreaters(float progress) {
UpdateBattleQuads(siteScreenPos);
// Go through all players for this activity
- for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
+ for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
// Player active and EVACUATION/RETREATING in current battle, so display his team flag and place it according to the animation progress
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain((*mpItr).GetInGamePlayer()) &&
- g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated((*mpItr).GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain((*mpItr)->GetInGamePlayer()) &&
+ g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated((*mpItr)->GetInGamePlayer())) {
// Show the active players' team flag icons around the site if the brains have arrived
m_apPlayerTeamActionBox[mp]->SetVisible(progress <= 0);
// Show the traveling brain if we're not at destination yet
@@ -4945,11 +4945,11 @@ void MetagameGUI::UpdatePostBattleResidents(float progress) {
UpdateBattleQuads(siteScreenPos);
// Go through all players for this activity
- for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
+ for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
// Player active in the past battle, so display his team flag and place it according to the animation progress
// Also player who didn't evacuate - they are handled by UpdatePostBattleRetreaters
- if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain((*mpItr).GetInGamePlayer()) &&
- !g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated((*mpItr).GetInGamePlayer())) {
+ if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain((*mpItr)->GetInGamePlayer()) &&
+ !g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated((*mpItr)->GetInGamePlayer())) {
// Figure out which quad this player is assigned to
for (int q = Players::PlayerOne; q < Players::MaxPlayerCount; ++q) {
if (m_aQuadTakenBy[q] == mp) {
@@ -4959,7 +4959,7 @@ void MetagameGUI::UpdatePostBattleResidents(float progress) {
}
// The brains who DID NOT MAKE IT - DEAD and did not evac
- if (!m_pAnimScene->GetResidentBrain((*mpItr).GetInGamePlayer())) {
+ if (!m_pAnimScene->GetResidentBrain((*mpItr)->GetInGamePlayer())) {
// Hide the losers after the residents start moving in
m_apPlayerTeamActionBox[mp]->SetVisible(progress <= 0);
m_apPlayerBrainTravelLabel[mp]->SetVisible(progress <= 0);
@@ -5131,7 +5131,7 @@ float MetagameGUI::UpdatePlayerActionLines(int metaPlayer) //, bool addUnallocat
m_ActionSiteLines[metaPlayer].clear();
// Get the total funds we have to work with
- float totalFunds = g_MetaMan.m_Players[metaPlayer].GetFunds();
+ float totalFunds = g_MetaMan.m_Players[metaPlayer]->GetFunds();
// Loop through the scenes owned by that player, setting up the building budget site line for each
const Scene* pScene = 0;
@@ -5139,17 +5139,17 @@ float MetagameGUI::UpdatePlayerActionLines(int metaPlayer) //, bool addUnallocat
float meterStart = 0;
while (pScene = g_MetaMan.GetNextSceneOfPlayer(metaPlayer, pScene)) {
// Add line for scenes which are owned and whose build budgets have been set to something
- if (pScene->GetTeamOwnership() == g_MetaMan.GetTeamOfPlayer(metaPlayer) && std::floor(pScene->GetBuildBudget(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer())) > 0) {
- m_ActionSiteLines[metaPlayer].push_back(SiteLine(metaPlayer, meterStart, pScene->GetBuildBudget(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer()) / totalFunds, pScene->GetLocation() + pScene->GetLocationOffset(), pScene->GetPresetName(), pScene, c_GUIColorGreen, -1, -1, channelHeight, 1.0f, g_MetaMan.IsActiveTeam(pScene->GetTeamOwnership())));
- m_ActionSiteLines[metaPlayer].back().m_FundsAmount = pScene->GetBuildBudget(g_MetaMan.m_Players[metaPlayer].GetInGamePlayer());
+ if (pScene->GetTeamOwnership() == g_MetaMan.GetTeamOfPlayer(metaPlayer) && std::floor(pScene->GetBuildBudget(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer())) > 0) {
+ m_ActionSiteLines[metaPlayer].push_back(SiteLine(metaPlayer, meterStart, pScene->GetBuildBudget(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer()) / totalFunds, pScene->GetLocation() + pScene->GetLocationOffset(), pScene->GetPresetName(), pScene, c_GUIColorGreen, -1, -1, channelHeight, 1.0f, g_MetaMan.IsActiveTeam(pScene->GetTeamOwnership())));
+ m_ActionSiteLines[metaPlayer].back().m_FundsAmount = pScene->GetBuildBudget(g_MetaMan.m_Players[metaPlayer]->GetInGamePlayer());
meterStart += m_ActionSiteLines[metaPlayer].back().m_MeterAmount;
channelHeight += 10;
}
}
// If we have a selected offensive target, find it and create its line as well
- std::string targetName = g_MetaMan.m_Players[metaPlayer].GetOffensiveTargetName();
- float offensiveBudget = g_MetaMan.m_Players[metaPlayer].GetOffensiveBudget();
+ std::string targetName = g_MetaMan.m_Players[metaPlayer]->GetOffensiveTargetName();
+ float offensiveBudget = g_MetaMan.m_Players[metaPlayer]->GetOffensiveBudget();
if (!targetName.empty() && offensiveBudget > 0) {
for (std::vector::iterator sItr = g_MetaMan.m_Scenes.begin(); sItr != g_MetaMan.m_Scenes.end(); ++sItr) {
if ((*sItr)->IsRevealed() && (*sItr)->GetPresetName() == targetName) {
@@ -5209,7 +5209,7 @@ void MetagameGUI::UpdateScenesBox(bool sceneChanged) {
// If during a player's round phase, show the budget slider and edit button
if (g_MetaMan.m_GameState >= MetaMan::PLAYER1TURN && g_MetaMan.m_GameState <= MetaMan::PLAYER4TURN) {
int metaPlayer = g_MetaMan.m_GameState - MetaMan::PLAYER1TURN;
- int team = g_MetaMan.m_Players[metaPlayer].GetTeam();
+ int team = g_MetaMan.m_Players[metaPlayer]->GetTeam();
// Resize the collection box to fit the extra controls
m_pSceneInfoPopup->Resize(m_pSceneInfoPopup->GetWidth(), newHeight + 96);
@@ -5238,7 +5238,7 @@ void MetagameGUI::UpdateScenesBox(bool sceneChanged) {
// If owned by this player, then set up base building controls
if (sceneOwnedByPlayer) {
// Set the budget label as per the slider
- int budget = floorf(((float)m_pSceneBudgetSlider->GetValue() / 100.0f) * g_MetaMan.m_Players[metaPlayer].GetFunds());
+ int budget = floorf(((float)m_pSceneBudgetSlider->GetValue() / 100.0f) * g_MetaMan.m_Players[metaPlayer]->GetFunds());
std::snprintf(str, sizeof(str), "Build Budget: %d oz", budget);
m_pSceneBudgetLabel->SetText(str);
m_apMetaButton[SCANNOW]->SetVisible(false);
@@ -5257,7 +5257,7 @@ void MetagameGUI::UpdateScenesBox(bool sceneChanged) {
// Only update this if the scene has changed in any way - otherwise UI changes done elsewhere might be overridden
if (sceneChanged) {
// Set the budget label as per the slider
- int budget = std::floor(((float)m_pSceneBudgetSlider->GetValue() / 100.0f) * g_MetaMan.m_Players[metaPlayer].GetFunds());
+ int budget = std::floor(((float)m_pSceneBudgetSlider->GetValue() / 100.0f) * g_MetaMan.m_Players[metaPlayer]->GetFunds());
// Set the appropriate action message, depending on whether this is enemy owned, or merely unexplored
if (g_MetaMan.IsActiveTeam(m_pSelectedScene->GetTeamOwnership())) {
std::snprintf(str, sizeof(str), "Attack Budget: %d oz", budget);
@@ -5308,7 +5308,7 @@ void MetagameGUI::UpdateScenesBox(bool sceneChanged) {
}
// If the player doesn't have any brains left to deploy, then disable these attack controls instead
- if (g_MetaMan.m_Players[metaPlayer].GetBrainPoolCount() <= 0) {
+ if (g_MetaMan.m_Players[metaPlayer]->GetBrainPoolCount() <= 0) {
m_pSceneBudgetLabel->SetText("- NO BRAINS TO DEPLOY -");
m_pSceneBudgetLabel->SetToolTip("Since you do not have any more brains in your brain pool available for deployment, you can't attack this or any other site. Defend the sites you do own and hope you'll keep enough of them to win the game!");
m_pSceneBudgetBar->SetToolTip("Since you do not have any more brains in your brain pool available for deployment, you can't attack this or any other site. Defend the sites you do own and hope you'll keep enough of them to win the game!");
@@ -5479,7 +5479,7 @@ void MetagameGUI::UpdatePlayerBars() {
if (g_MetaMan.m_GameState >= MetaMan::NOGAME && g_MetaMan.m_GameState <= MetaMan::ENDROUND && !g_MetaMan.IsSuspended()) {
int metaPlayer = 0;
char str[256];
- for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
+ for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) {
// m_apPlayerBox[metaPlayer];
// m_apPlayerTeamBox[metaPlayer];
@@ -5490,14 +5490,14 @@ void MetagameGUI::UpdatePlayerBars() {
if (!m_apPlayerTeamBox[metaPlayer]->GetDrawImage()) {
// Set the flag icons on the floating player bars
m_apPlayerTeamBox[metaPlayer]->SetDrawType(GUICollectionBox::Image);
- m_apPlayerTeamBox[metaPlayer]->SetDrawImage(new AllegroBitmap(g_MetaMan.m_TeamIcons[(*mpItr).GetTeam()].GetBitmaps32()[0]));
+ m_apPlayerTeamBox[metaPlayer]->SetDrawImage(new AllegroBitmap(g_MetaMan.m_TeamIcons[(*mpItr)->GetTeam()].GetBitmaps32()[0]));
}
// Show funds of player if income lines are showing, or we are counting income/expenses somehow
if ((!m_PreTurn && metaPlayer == (g_MetaMan.m_GameState - MetaMan::PLAYER1TURN) && m_pSelectedScene) ||
metaPlayer == m_ActivePlayerIncomeLines || g_MetaMan.m_GameState == MetaMan::COUNTINCOME || g_MetaMan.m_GameState == MetaMan::BUILDBASES || g_MetaMan.m_GameState == MetaMan::RUNACTIVITIES || g_MetaMan.m_GameState == MetaMan::ENDROUND) {
- std::snprintf(str, sizeof(str), "%c %.0f oz", -58, (*mpItr).m_Funds);
- // std::snprintf(str, sizeof(str), "%cx%d %c %.0f oz", -48, (*mpItr).GetBrainPoolCount(), -58, (*mpItr).m_Funds);
+ std::snprintf(str, sizeof(str), "%c %.0f oz", -58, (*mpItr)->m_Funds);
+ // std::snprintf(str, sizeof(str), "%cx%d %c %.0f oz", -48, (*mpItr)->GetBrainPoolCount(), -58, (*mpItr)->m_Funds);
m_apPlayerBarLabel[metaPlayer]->SetText(str);
m_apPlayerBarLabel[metaPlayer]->SetHAlignment(GUIFont::Right);
m_apPlayerBarLabel[metaPlayer]->SetToolTip("This player's total funds");
@@ -5510,7 +5510,7 @@ void MetagameGUI::UpdatePlayerBars() {
else
str[0] = 0;
- m_apPlayerBarLabel[metaPlayer]->SetText(std::string(str) + (*mpItr).GetName());
+ m_apPlayerBarLabel[metaPlayer]->SetText(std::string(str) + (*mpItr)->GetName());
m_apPlayerBarLabel[metaPlayer]->SetHAlignment(GUIFont::Left);
m_apPlayerBarLabel[metaPlayer]->SetToolTip("");
}
@@ -5527,7 +5527,7 @@ void MetagameGUI::UpdatePlayerBars() {
}
// [Brain Icon] [X] Number
// The number to display is adjusted with whether any brains are out and about in the gui animations
- int brainDisplayCount = (*mpItr).GetBrainPoolCount() - (*mpItr).GetBrainsInTransit();
+ int brainDisplayCount = (*mpItr)->GetBrainPoolCount() - (*mpItr)->GetBrainsInTransit();
std::snprintf(str, sizeof(str), "%c%c%d", brainDisplayCount > 0 ? -48 : -25, -36, brainDisplayCount);
m_apBrainPoolLabel[metaPlayer]->SetText(str);
@@ -5567,7 +5567,7 @@ void MetagameGUI::UpdatePlayerBars() {
// Update the player name labels above each floating bar, IF we're not drawing lines
if (metaPlayer != m_ActivePlayerIncomeLines)
{
- m_apFundsChangeLabel[metaPlayer]->SetText((*mpItr).GetName());
+ m_apFundsChangeLabel[metaPlayer]->SetText((*mpItr)->GetName());
m_apFundsChangeLabel[metaPlayer]->SetPositionAbs(m_apPlayerBox[metaPlayer]->GetXPos() + 5, m_apPlayerBox[metaPlayer]->GetYPos() - 15);
m_apFundsChangeLabel[metaPlayer]->SetVisible(true);
}