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

Commit 0f7c11e

Browse files
authored
Merge branch 'development' into bug/500-fix-meson-builds-on-macos
2 parents b8d2b46 + 1e2f928 commit 0f7c11e

File tree

317 files changed

+181
-100129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

317 files changed

+181
-100129
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
101101

102102
- New `Settings.ini` property `DisableFactionBuyMenuThemes = 0/1` which will cause custom faction theme definitions in all modules to be ignored and the default theme to be used instead.
103103

104+
- New `Settings.ini` property `DisableFactionBuyMenuThemeCursors = 0/1` which will cause custom faction theme cursor definitions in all modules to be ignored and the default cursors to be used instead.
105+
104106
- New `Settings.ini` and `SceneMan` Lua (R/W) property `ScrapCompactingHeight` which determines the maximum height of a column of scrap terrain to collapse when the bottom pixel is knocked loose. 0 means no columns of terrain are ever collapsed, much like in old builds of CC.
105107

106108
- New `DataModule` INI and Lua (R/O) property `IsMerchant` which determines whether a module is an independent merchant. Defaults to false (0). ([Issue #401](https://github.com/cortex-command-community/Cortex-Command-Community-Project-Source/issues/401))
@@ -392,6 +394,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
392394
A new `GlobalScript` has been added that will automatically save the game every three minutes. To turn it on, enable the Autosaving `GlobalScript` in the main menu mod manager's Global Scripts section.
393395
To load games saved by this script, open the console and enter the command `ActivityMan:LoadGame("Autosave")`, or use the `Ctrl + F9` shortcut.
394396

397+
- New hardcoded `MovableObject` function `OnGameSave(self)` that gets run for each `MovableObject` with it when the game is saved. This can be used in tandem with custom values (for `MOSRotatings` and child classes) to store data, which can be read during `Create` when the game is loaded.
398+
395399
- New Lua `AEmitter` properties:
396400
**TotalParticlesPerMinute** (R/O) - The rate at which all of the `Emission`s of this `AEmitter` combined, emit their particles.
397401
**TotalBurstSize** (R/O) - The number of particles that will be emitted by all the `Emission`s of this `AEmitter` combined, in one shot when a burst is triggered.
@@ -474,7 +478,7 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
474478
Shift-clicking an item (or Shift + Fire in keyboard-only) in the cart will now empty the entire cart.
475479
Items in the cart will be indented to signify what actor's inventory they belong to.
476480
Middle-clicking (or pressing the Pickup key) on an item will duplicate it. This also duplicates an actor's inventory.
477-
You can now reorganize the cart by click-dragging, or by holding the item selection key and inputting up/down.
481+
You can now reorganize the cart by click-dragging. For kbd-only you can do this by holding the sharp aim key and pressing up/down.
478482

479483
- Added to Lua enum `ControlState` the state `RELEASE_FACEBUTTON`.
480484

Entities/MOSRotating.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,6 +2042,18 @@ void MOSRotating::CorrectAttachableAndWoundPositionsAndRotations() const {
20422042

20432043
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
20442044

2045+
void MOSRotating::OnGameSave() {
2046+
MovableObject::OnGameSave();
2047+
for (AEmitter *wound : m_Wounds) {
2048+
wound->OnGameSave();
2049+
}
2050+
for (Attachable *attachable : m_Attachables) {
2051+
attachable->OnGameSave();
2052+
}
2053+
}
2054+
2055+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2056+
20452057
bool MOSRotating::TransferForcesFromAttachable(Attachable *attachable) {
20462058
bool intact = false;
20472059
Vector forces;

Entities/MOSRotating.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,11 @@ ClassInfoGetters;
937937
/// </summary>
938938
virtual void CorrectAttachableAndWoundPositionsAndRotations() const;
939939

940+
/// <summary>
941+
/// Method to be run when the game is saved via ActivityMan::SaveCurrentGame. Not currently used in metagame or editor saving.
942+
/// </summary>
943+
void OnGameSave() override;
944+
940945

941946
//////////////////////////////////////////////////////////////////////////////////////////
942947
// Protected member variable and method declarations

Entities/MovableObject.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ friend struct EntityLuaBindings;
6363

6464
public:
6565

66-
ScriptFunctionNames("Create", "Destroy", "Update", "OnScriptDisable", "OnScriptEnable", "OnCollideWithTerrain", "OnCollideWithMO", "WhilePieMenuOpen");
66+
ScriptFunctionNames("Create", "Destroy", "Update", "OnScriptDisable", "OnScriptEnable", "OnCollideWithTerrain", "OnCollideWithMO", "WhilePieMenuOpen", "OnGameSave");
6767
SerializableOverrideMethods;
6868
ClassInfoGetters;
6969

@@ -1805,6 +1805,11 @@ enum MOType
18051805
/// <returns>Whether the object was successfully drawn to the terrain.</returns>
18061806
bool DrawToTerrain(SLTerrain *terrain);
18071807

1808+
/// <summary>
1809+
/// Method to be run when the game is saved via ActivityMan::SaveCurrentGame. Not currently used in metagame or editor saving.
1810+
/// </summary>
1811+
virtual void OnGameSave() { RunScriptedFunctionInAppropriateScripts("OnGameSave"); }
1812+
18081813
//////////////////////////////////////////////////////////////////////////////////////////
18091814
// Protected member variable and method declarations
18101815

Entities/Scene.cpp

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,9 @@ void Scene::Clear()
452452
m_AutoDesigned = true;
453453
m_TotalInvestment = 0;
454454
m_pTerrain = 0;
455-
m_NoTeamPathFinder.reset();
456-
for (std::unique_ptr<PathFinder> &pathFinder : m_PathFinders) {
455+
for (std::unique_ptr<PathFinder> &pathFinder : m_pPathFinders) {
457456
pathFinder.reset();
458457
}
459-
for (std::unique_ptr<PathFinder> &defaultDigStrengthPathFinder : m_DefaultDigStrengthPathfinders) {
460-
defaultDigStrengthPathFinder.reset();
461-
}
462458
m_PathfindingUpdated = false;
463459
m_PartialPathUpdateTimer.Reset();
464460

@@ -937,12 +933,8 @@ int Scene::LoadData(bool placeObjects, bool initPathfinding, bool placeUnits)
937933
//unsigned int numberOfBlocksToAllocate = std::min(128000, sceneArea / (pathFinderGridNodeSize * pathFinderGridNodeSize));
938934
unsigned int numberOfBlocksToAllocate = 4000;
939935

940-
m_NoTeamPathFinder = std::make_unique<PathFinder>(pathFinderGridNodeSize, numberOfBlocksToAllocate);
941-
for (int i = 0; i < m_PathFinders.size(); ++i) {
942-
m_PathFinders[i] = std::make_unique<PathFinder>(pathFinderGridNodeSize, numberOfBlocksToAllocate);
943-
}
944-
for (int i = 0; i < m_DefaultDigStrengthPathfinders.size(); ++i) {
945-
m_DefaultDigStrengthPathfinders[i] = std::make_unique<PathFinder>(pathFinderGridNodeSize, numberOfBlocksToAllocate);
936+
for (int i = 0; i < m_pPathFinders.size(); ++i) {
937+
m_pPathFinders[i] = std::make_unique<PathFinder>(pathFinderGridNodeSize, numberOfBlocksToAllocate);
946938
}
947939
ResetPathFinding();
948940
}
@@ -2986,7 +2978,6 @@ void Scene::ResetPathFinding() {
29862978
for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) {
29872979
g_MovableMan.OverrideMaterialDoors(true, team);
29882980
GetPathFinder(static_cast<Activity::Teams>(team))->RecalculateAllCosts();
2989-
GetPathFinder(static_cast<Activity::Teams>(team), c_PathFindingDefaultDigStrength)->RecalculateAllCosts();
29902981
g_MovableMan.OverrideMaterialDoors(false, team);
29912982
}
29922983
}
@@ -3022,7 +3013,6 @@ void Scene::UpdatePathFinding()
30223013
g_MovableMan.OverrideMaterialDoors(true, team);
30233014

30243015
GetPathFinder(static_cast<Activity::Teams>(team))->UpdateNodeList(updatedNodes);
3025-
GetPathFinder(static_cast<Activity::Teams>(team), c_PathFindingDefaultDigStrength)->UpdateNodeList(updatedNodes);
30263016

30273017
// Place back the material representation of all doors of this team so they are as we found them.
30283018
g_MovableMan.OverrideMaterialDoors(false, team);
@@ -3043,7 +3033,7 @@ void Scene::UpdatePathFinding()
30433033
float Scene::CalculatePath(const Vector &start, const Vector &end, std::list<Vector> &pathResult, float digStrength, Activity::Teams team) {
30443034
float totalCostResult = -1;
30453035

3046-
if (const std::unique_ptr<PathFinder> &pathFinder = GetPathFinder(team, digStrength)) {
3036+
if (const std::unique_ptr<PathFinder> &pathFinder = GetPathFinder(team)) {
30473037
int result = pathFinder->CalculatePath(start, end, pathResult, totalCostResult, digStrength);
30483038

30493039
// It's ok if start and end nodes happen to be the same, the exact pixel locations are added at the front and end of the result regardless
@@ -3126,14 +3116,9 @@ void Scene::Update()
31263116

31273117
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
31283118

3129-
std::unique_ptr<PathFinder>& Scene::GetPathFinder(Activity::Teams team, float digStrength) {
3130-
if (team == Activity::Teams::NoTeam) {
3131-
return m_NoTeamPathFinder;
3132-
} else if (std::abs(digStrength - c_PathFindingDefaultDigStrength) < 1.0F) {
3133-
return m_DefaultDigStrengthPathfinders[team];
3134-
} else {
3135-
return m_PathFinders[static_cast<int>(team)];
3136-
}
3119+
std::unique_ptr<PathFinder>& Scene::GetPathFinder(Activity::Teams team) {
3120+
// Note - we use + 1 when getting pathfinders by index, because our shared NoTeam pathfinder occupies index 0, and the rest come after that.
3121+
return m_pPathFinders[static_cast<int>(team) + 1];
31373122
}
31383123

31393124
} // namespace RTE

Entities/Scene.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,9 +1338,8 @@ const SceneObject * PickPlacedActorInRange(int whichSet, Vector &scenePoint, int
13381338
SLTerrain *m_pTerrain;
13391339

13401340
// Pathfinding graph and logic. Owned by this
1341-
std::unique_ptr<PathFinder> m_NoTeamPathFinder; //!< The shared pathfinder for when no team is specified.
1342-
std::array<std::unique_ptr<PathFinder>, Activity::Teams::MaxTeamCount> m_PathFinders; //!< The array of pathfinders for each team.
1343-
std::array<std::unique_ptr<PathFinder>, Activity::Teams::MaxTeamCount> m_DefaultDigStrengthPathfinders; //!< The array of pathfinders for each team to be used for default dig strength.
1341+
// The array of PathFinders for each team. Because we also have a shared pathfinder using index 0, we need to use MaxTeamCount + 1 to handle all the Teams' PathFinders.
1342+
std::array<std::unique_ptr<PathFinder>, Activity::Teams::MaxTeamCount + 1> m_pPathFinders;
13441343
// Is set to true on any frame the pathfinding data has been updated
13451344
bool m_PathfindingUpdated;
13461345
// Timer for when to do an update of the pathfinding data
@@ -1395,9 +1394,8 @@ const SceneObject * PickPlacedActorInRange(int whichSet, Vector &scenePoint, int
13951394
/// Gets the pathfinder for a given team.
13961395
/// </summary>
13971396
/// <param name="team">The team to get the pathfinder for. NoTeam is valid, and will give a shared pathfinder.</param>
1398-
/// <param name="digStrength">The dig strength to get the pathfinder for. A different pathfinder will be used if it's the default dig strength. Defaults to -1 so the normal pathfinder will be used if no argument is passed in.</param>
13991397
/// <returns>A pointer to the pathfinder for the given team.</returns>
1400-
std::unique_ptr<PathFinder> & GetPathFinder(Activity::Teams team, float digStrength = -1);
1398+
std::unique_ptr<PathFinder> & GetPathFinder(Activity::Teams team);
14011399

14021400
/// <summary>
14031401
/// Serializes the SceneObject via the Writer. Necessary because full serialization doesn't know how to deal with duplicate properties.

Managers/ActivityMan.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ namespace RTE {
110110
// Pull all stuff from MovableMan into the Scene for saving, so existing Actors/ADoors are saved, without transferring ownership, so the game can continue.
111111
// This is done after the activity is saved, in case the activity wants to add anything to the scene while saving.
112112
modifiableScene->RetrieveSceneObjects(false);
113+
for (SceneObject *objectToSave : *modifiableScene->GetPlacedObjects(Scene::PlacedObjectSets::PLACEONLOAD)) {
114+
if (MovableObject *objectToSaveAsMovableObject = dynamic_cast<MovableObject *>(objectToSave)) {
115+
objectToSaveAsMovableObject->OnGameSave();
116+
}
117+
}
113118

114119
writer->NewPropertyWithValue("OriginalScenePresetName", scene->GetPresetName());
115120
writer->NewPropertyWithValue("PlaceObjectsIfSceneIsRestarted", g_SceneMan.GetPlaceObjectsOnLoad());

Managers/MovableMan.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ MOID MovableMan::GetMOIDPixel(int pixelX, int pixelY, const std::vector<int> &mo
201201

202202
const MovableObject *mo = GetMOFromID(moid);
203203
RTEAssert(mo, "Null MO found in MOID list!");
204+
if (mo && mo->GetScale() == 0) {
205+
return g_NoMOID;
206+
}
204207
if (mo && HitTestMOAtPixel(*mo, pixelX, pixelY)) {
205208
return moid;
206209
}

Managers/SettingsMan.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ namespace RTE {
4848
m_SimplifiedCollisionDetection = false;
4949
m_SceneBackgroundAutoScaleMode = 1;
5050
m_DisableFactionBuyMenuThemes = false;
51+
m_DisableFactionBuyMenuThemeCursors = false;
5152
m_PathFinderGridNodeSize = c_PPM;
5253
m_AIUpdateInterval = 2;
5354

@@ -195,6 +196,8 @@ namespace RTE {
195196
SetSceneBackgroundAutoScaleMode(std::stoi(reader.ReadPropValue()));
196197
} else if (propName == "DisableFactionBuyMenuThemes") {
197198
reader >> m_DisableFactionBuyMenuThemes;
199+
} else if (propName == "DisableFactionBuyMenuThemeCursors") {
200+
reader >> m_DisableFactionBuyMenuThemeCursors;
198201
} else if (propName == "PathFinderGridNodeSize") {
199202
reader >> m_PathFinderGridNodeSize;
200203
} else if (propName == "AIUpdateInterval") {
@@ -388,6 +391,7 @@ namespace RTE {
388391
writer.NewPropertyWithValue("SimplifiedCollisionDetection", m_SimplifiedCollisionDetection);
389392
writer.NewPropertyWithValue("SceneBackgroundAutoScaleMode", m_SceneBackgroundAutoScaleMode);
390393
writer.NewPropertyWithValue("DisableFactionBuyMenuThemes", m_DisableFactionBuyMenuThemes);
394+
writer.NewPropertyWithValue("DisableFactionBuyMenuThemeCursors", m_DisableFactionBuyMenuThemeCursors);
391395
writer.NewPropertyWithValue("PathFinderGridNodeSize", m_PathFinderGridNodeSize);
392396
writer.NewPropertyWithValue("AIUpdateInterval", m_AIUpdateInterval);
393397
writer.NewPropertyWithValue("EnableParticleSettling", g_MovableMan.m_SettlingEnabled);

Managers/SettingsMan.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ namespace RTE {
9393
/// <param name="disable">Whether faction BuyMenu theme support is disabled or not.</param>
9494
void SetFactionBuyMenuThemesDisabled(bool disable) { m_DisableFactionBuyMenuThemes = disable; }
9595

96+
/// <summary>
97+
/// Gets whether custom cursor support in faction BuyMenu themes is disabled.
98+
/// </summary>
99+
/// <returns>Whether faction BuyMenu theme support is disabled.</returns>
100+
bool FactionBuyMenuThemeCursorsDisabled() const { return m_DisableFactionBuyMenuThemeCursors; }
101+
102+
/// <summary>
103+
/// Sets whether custom cursor support in faction BuyMenu themes is disabled.
104+
/// </summary>
105+
/// <param name="disable">Whether custom cursor support in faction BuyMenu themes is disabled or not.</param>
106+
void SetFactionBuyMenuThemeCursorsDisabled(bool disable) { m_DisableFactionBuyMenuThemeCursors = disable; }
107+
96108
/// <summary>
97109
/// Gets the PathFinder grid node size.
98110
/// </summary>
@@ -521,6 +533,7 @@ namespace RTE {
521533
bool m_SimplifiedCollisionDetection; //!< Whether simplified collision detection (reduced MOID layer sampling) is enabled.
522534
int m_SceneBackgroundAutoScaleMode; //!< Scene background layer auto-scaling mode. 0 for off, 1 for fit screen dimensions and 2 for always upscaled to x2.
523535
bool m_DisableFactionBuyMenuThemes; //!< Whether faction BuyMenu theme support is disabled.
536+
bool m_DisableFactionBuyMenuThemeCursors; //!< Whether custom cursor support in faction BuyMenu themes is disabled.
524537
int m_PathFinderGridNodeSize; //!< The grid size used by the PathFinder, in pixels.
525538
int m_AIUpdateInterval; //!< How often actor's AI should be updated, i.e. every n simulation updates.
526539

0 commit comments

Comments
 (0)