Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit cdd868d

Browse files
authored
Merge pull request #108 from cortex-command-community/CF49-variable-actor-passengerslots
Add PassengerSlots variable to Actors
2 parents 3f28910 + 18cdca9 commit cdd868d

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

Entities/Actor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ void Actor::Clear()
113113
m_WhiteFlashTimer.Reset();
114114
m_PieSlices.clear();
115115
m_DeploymentID = 0;
116+
m_PassengerSlots = 1;
116117

117118
m_ScriptedAIUpdate = false;
118119
m_AIMode = AIMODE_NONE;
@@ -293,6 +294,7 @@ int Actor::Create(const Actor &reference)
293294
m_sIconsLoaded = true;
294295
}
295296
m_DeploymentID = reference.m_DeploymentID;
297+
m_PassengerSlots = reference.m_PassengerSlots;
296298

297299
m_ScriptedAIUpdate = reference.m_ScriptedAIUpdate;
298300
m_AIMode = reference.m_AIMode;
@@ -338,6 +340,8 @@ int Actor::ReadProperty(std::string propName, Reader &reader)
338340
reader >> m_Status;
339341
else if (propName == "DeploymentID")
340342
reader >> m_DeploymentID;
343+
else if (propName == "PassengerSlots")
344+
reader >> m_PassengerSlots;
341345
else if (propName == "Health")
342346
{
343347
reader >> m_Health;

Entities/Actor.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,15 @@ ADD_SCRIPT_FUNCTION_NAMES(MOSRotating, "UpdateAI")
395395

396396
float GetAimAngle(bool adjustForFlipped = true) const { return adjustForFlipped ? FacingAngle(m_AimAngle) : m_AimAngle; }
397397

398+
//////////////////////////////////////////////////////////////////////////////////////////
399+
// Method: GetPassengerSlots
400+
//////////////////////////////////////////////////////////////////////////////////////////
401+
// Description: Gets this Actor's passenger slots.
402+
// Arguments: None.
403+
// Return value: The Actor's passenger plots
404+
405+
int GetPassengerSlots() const { return m_PassengerSlots; }
406+
398407

399408
//////////////////////////////////////////////////////////////////////////////////////////
400409
// Virtual method: GetCPUPos
@@ -530,6 +539,15 @@ ADD_SCRIPT_FUNCTION_NAMES(MOSRotating, "UpdateAI")
530539

531540
void SetAimAngle(float newAngle) { m_AimAngle = newAngle; Clamp(m_AimAngle, m_AimRange, -m_AimRange); }
532541

542+
//////////////////////////////////////////////////////////////////////////////////////////
543+
// Method: SetPassengerSlots
544+
//////////////////////////////////////////////////////////////////////////////////////////
545+
// Description: Sets this Actor's passenger slots.
546+
// Arguments: A new amount of passenger slots.
547+
// Return value: None.
548+
549+
void SetPassengerSlots(int newPassengerSlots) { m_PassengerSlots = newPassengerSlots;; }
550+
533551

534552
//////////////////////////////////////////////////////////////////////////////////////////
535553
// Method: SetViewPoint
@@ -1454,6 +1472,8 @@ ADD_SCRIPT_FUNCTION_NAMES(MOSRotating, "UpdateAI")
14541472
float m_DigStrength;
14551473
// ID of deployment which spawned this actor
14561474
unsigned int m_DeploymentID;
1475+
// How many passenger slots this actor will take in a craft
1476+
int m_PassengerSlots;
14571477

14581478

14591479
////////////////////

Managers/LuaMan.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,8 @@ int LuaMan::Create()
923923
.def("IsDead", &Actor::IsDead)
924924
.def("FacingAngle", &Actor::FacingAngle)
925925
.property("AIMode", &Actor::GetAIMode, &Actor::SetAIMode)
926-
.property("DeploymentID", &Actor::GetDeploymentID)
926+
.property("DeploymentID", &Actor::GetDeploymentID)
927+
.property("PassengerSlots", &Actor::GetPassengerSlots, &Actor::SetPassengerSlots)
927928
.def("AddAISceneWaypoint", &Actor::AddAISceneWaypoint)
928929
.def("AddAIMOWaypoint", &Actor::AddAIMOWaypoint)
929930
.def("ClearAIWaypoints", &Actor::ClearAIWaypoints)

Menus/BuyMenuGUI.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ float BuyMenuGUI::GetCraftMass()
782782
//////////////////////////////////////////////////////////////////////////////////////////
783783
// Method: GetTotalOrderPassengers
784784
//////////////////////////////////////////////////////////////////////////////////////////
785-
// Description: Return teh total number of passengers in the order box.
785+
// Description: Return the total number of passengers in the order box.
786786
// Arguments: None.
787787
// Return value: The total number of passengers.
788788

@@ -791,8 +791,11 @@ int BuyMenuGUI::GetTotalOrderPassengers()
791791
int passengers = 0;
792792
for (vector<GUIListPanel::Item *>::iterator itr = m_pCartList->GetItemList()->begin(); itr != m_pCartList->GetItemList()->end(); ++itr)
793793
{
794-
if (dynamic_cast<const Actor *>((*itr)->m_pEntity))
795-
passengers++;
794+
const Actor* passenger = dynamic_cast<const Actor*>((*itr)->m_pEntity);
795+
if (passenger)
796+
{
797+
passengers += passenger->GetPassengerSlots();
798+
}
796799
}
797800

798801
return passengers;

0 commit comments

Comments
 (0)