Skip to content

Commit 43f664e

Browse files
committed
Merge branch 'development' into zip-save-files
2 parents e16149a + 70c4512 commit 43f664e

File tree

2,857 files changed

+186146
-897
lines changed

Some content is hidden

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

2,857 files changed

+186146
-897
lines changed

.github/parameters/macports.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: "2.8.1"
2+
prefix: "/opt/local"
3+
ports:
4+
- name: gcc13
5+
- name: pkgconfig
6+
- name: meson
7+
- name: libsdl2
8+
- name: onetbb
9+
- name: lz4
10+
- name: libpng
11+
- name: minizip
12+
- name: luajit
13+
- name: flac
14+
- name: dylibbundler

.github/workflows/meson.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ jobs:
122122
- uses: actions/checkout@v3
123123
- uses: actions/setup-python@v3
124124

125-
- name: Install Dependencies
126-
run: |
127-
brew install pkg-config tbb sdl2 minizip lz4 flac luajit [email protected] libpng gcc@${{env.GCC_VERSION}} ninja meson dylibbundler tree
125+
- name: "Install Dependencies"
126+
uses: melusina-org/setup-macports@v1
127+
with:
128+
parameters: ".github/parameters/macports.yml"
128129

129130
- name: Setup Meson
130131
env:

Activities/GAScripted.cpp

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include "BuyMenuGUI.h"
3636
#include "SceneEditorGUI.h"
3737

38+
#include "tracy/Tracy.hpp"
39+
3840
namespace RTE {
3941

4042
ConcreteClassInfo(GAScripted, GameActivity, 0);
@@ -204,17 +206,30 @@ int GAScripted::ReloadScripts() {
204206
}
205207
}
206208

207-
std::unordered_map<std::string, LuabindObjectWrapper*> scriptFileFunctions;
208-
if ((error = g_LuaMan.GetMasterScriptState().RunScriptFileAndRetrieveFunctions(m_ScriptPath, m_LuaClassName, GetSupportedScriptFunctionNames(), scriptFileFunctions, true)) < 0) {
209+
if ((error = g_LuaMan.GetMasterScriptState().RunScriptFile(m_ScriptPath, true, false)) < 0) {
209210
return error;
210211
}
211212

213+
RefreshActivityFunctions();
214+
215+
return 0;
216+
}
217+
218+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
219+
220+
void GAScripted::RefreshActivityFunctions() {
212221
m_ScriptFunctions.clear();
222+
if (m_ScriptPath.empty()) {
223+
return;
224+
}
225+
226+
// We use m_LuaClassName here, because we ran the script file in the global state instead of in an environment
227+
std::unordered_map<std::string, LuabindObjectWrapper*> scriptFileFunctions;
228+
g_LuaMan.GetMasterScriptState().RetrieveFunctions(m_LuaClassName, GetSupportedScriptFunctionNames(), scriptFileFunctions);
229+
213230
for (const auto& [functionName, functionObject] : scriptFileFunctions) {
214231
m_ScriptFunctions[functionName] = std::unique_ptr<LuabindObjectWrapper>(functionObject);
215232
}
216-
217-
return 0;
218233
}
219234

220235
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -281,8 +296,8 @@ void GAScripted::HandleCraftEnteringOrbit(ACraft *orbitedCraft) {
281296

282297
if (orbitedCraft && g_MovableMan.IsActor(orbitedCraft)) {
283298
g_LuaMan.GetMasterScriptState().RunScriptFunctionString(m_LuaClassName + ".CraftEnteredOrbit", m_LuaClassName, {m_LuaClassName, m_LuaClassName + ".CraftEnteredOrbit"}, {orbitedCraft});
284-
for (const GlobalScript *globalScript : m_GlobalScriptsList) {
285-
if (globalScript->IsActive()) { globalScript->HandleCraftEnteringOrbit(orbitedCraft); }
299+
for (GlobalScript *globalScript : m_GlobalScriptsList) {
300+
globalScript->HandleCraftEnteringOrbit(orbitedCraft);
286301
}
287302
}
288303
}
@@ -333,18 +348,11 @@ int GAScripted::Start() {
333348
g_PresetMan.GetAllOfType(globalScripts, "GlobalScript");
334349

335350
for (std::list<Entity *>::iterator sItr = globalScripts.begin(); sItr != globalScripts.end(); ++sItr) {
336-
GlobalScript * script = dynamic_cast<GlobalScript *>(*sItr);
337-
if (script && g_SettingsMan.IsGlobalScriptEnabled(script->GetModuleAndPresetName())) {
338-
m_GlobalScriptsList.push_back(dynamic_cast<GlobalScript*>(script->Clone()));
339-
}
351+
m_GlobalScriptsList.push_back(dynamic_cast<GlobalScript*>((*sItr)->Clone()));
340352
}
341353

342354
// Start all global scripts
343355
for (std::vector<GlobalScript *>::iterator sItr = m_GlobalScriptsList.begin(); sItr < m_GlobalScriptsList.end(); ++sItr) {
344-
if (g_SettingsMan.PrintDebugInfo()) {
345-
g_ConsoleMan.PrintString("DEBUG: Start Global Script: " + (*sItr)->GetPresetName());
346-
}
347-
348356
(*sItr)->Start();
349357
}
350358

@@ -364,9 +372,7 @@ void GAScripted::SetPaused(bool pause) {
364372

365373
// Pause all global scripts
366374
for (std::vector<GlobalScript *>::iterator sItr = m_GlobalScriptsList.begin(); sItr < m_GlobalScriptsList.end(); ++sItr) {
367-
if ((*sItr)->IsActive()) {
368-
(*sItr)->Pause(pause);
369-
}
375+
(*sItr)->Pause(pause);
370376
}
371377
}
372378

@@ -383,12 +389,7 @@ void GAScripted::End() {
383389

384390
// End all global scripts
385391
for (std::vector<GlobalScript *>::iterator sItr = m_GlobalScriptsList.begin(); sItr < m_GlobalScriptsList.end(); ++sItr) {
386-
if ((*sItr)->IsActive()) {
387-
if (g_SettingsMan.PrintDebugInfo()) {
388-
g_ConsoleMan.PrintString("DEBUG: End Global Script: " + (*sItr)->GetPresetName());
389-
}
390-
(*sItr)->End();
391-
}
392+
(*sItr)->End();
392393
}
393394

394395
// Delete all global scripts, in case destructor is not called when activity restarts
@@ -436,6 +437,9 @@ void GAScripted::Update() {
436437
if (m_ActivityState != ActivityState::Over) {
437438
AddPieSlicesToActiveActorPieMenus();
438439

440+
// Need to call this continually unfortunately, as something might change due to dofile()
441+
RefreshActivityFunctions();
442+
439443
RunLuaFunction("UpdateActivity");
440444

441445
UpdateGlobalScripts(false);
@@ -449,9 +453,11 @@ void GAScripted::Update() {
449453
// Description: Updates globals scripts loaded with this activity.
450454

451455
void GAScripted::UpdateGlobalScripts(bool lateUpdate) {
456+
ZoneScoped;
457+
452458
// Update all global scripts
453459
for (std::vector<GlobalScript *>::iterator sItr = m_GlobalScriptsList.begin(); sItr < m_GlobalScriptsList.end(); ++sItr) {
454-
if ((*sItr)->IsActive() && (*sItr)->ShouldLateUpdate() == lateUpdate) {
460+
if ((*sItr)->ShouldLateUpdate() == lateUpdate) {
455461
(*sItr)->Update();
456462
}
457463
}
@@ -485,7 +491,9 @@ int GAScripted::RunLuaFunction(const std::string& functionName, const std::vecto
485491
return 0;
486492
}
487493

488-
return g_LuaMan.GetMasterScriptState().RunScriptFunctionObject(funcItr->second.get(), "_G", m_LuaClassName, functionEntityArguments, functionLiteralArguments, functionObjectArguments);
494+
int error = g_LuaMan.GetMasterScriptState().RunScriptFunctionObject(funcItr->second.get(), "_G", m_LuaClassName, functionEntityArguments, functionLiteralArguments, functionObjectArguments);
495+
496+
return error;
489497
}
490498

491499

@@ -562,10 +570,8 @@ void GAScripted::AddPieSlicesToActiveActorPieMenus() {
562570
controlledActorPieMenu->AddPieSliceIfPresetNameIsUnique(pieSlice.get(), this, true);
563571
}
564572
for (const GlobalScript *globalScript : m_GlobalScriptsList) {
565-
if (globalScript->IsActive()) {
566-
for (const std::unique_ptr<PieSlice> &pieSlice : globalScript->GetPieSlicesToAdd()) {
567-
controlledActorPieMenu->AddPieSliceIfPresetNameIsUnique(pieSlice.get(), globalScript, true);
568-
}
573+
for (const std::unique_ptr<PieSlice> &pieSlice : globalScript->GetPieSlicesToAdd()) {
574+
controlledActorPieMenu->AddPieSliceIfPresetNameIsUnique(pieSlice.get(), globalScript, true);
569575
}
570576
}
571577
}

Activities/GAScripted.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ ClassInfoGetters;
139139

140140
int ReloadScripts() override;
141141

142+
/// <summary>
143+
/// Refreshes our activity functions to find any changes from script.
144+
/// </summary>
145+
void RefreshActivityFunctions();
146+
142147

143148
//////////////////////////////////////////////////////////////////////////////////////////
144149
// Virtual method: GetLuaClassName

Activities/GameActivity.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ void GameActivity::Clear()
7575
m_InventoryMenuGUI[player] = nullptr;
7676
m_pBuyGUI[player] = 0;
7777
m_pEditorGUI[player] = 0;
78+
m_LuaLockActor[player] = false;
79+
m_LuaLockActorMode[player] = Controller::InputMode::CIM_AI;
7880
m_pBannerRed[player] = 0;
7981
m_pBannerYellow[player] = 0;
8082
m_BannerRepeats[player] = 0;
@@ -174,6 +176,8 @@ int GameActivity::Create(const GameActivity &reference)
174176
m_InventoryMenuGUI[player] = new InventoryMenuGUI;
175177
m_pBuyGUI[player] = new BuyMenuGUI;
176178
m_pEditorGUI[player] = new SceneEditorGUI;
179+
m_LuaLockActor[player] = reference.m_LuaLockActor[player];
180+
m_LuaLockActorMode[player] = reference.m_LuaLockActorMode[player];
177181
m_pBannerRed[player] = new GUIBanner();
178182
m_pBannerYellow[player] = new GUIBanner();
179183
m_ReadyToStart[player] = reference.m_ReadyToStart[player];
@@ -396,6 +400,18 @@ bool GameActivity::IsBuyGUIVisible(int which) const {
396400

397401
}
398402

403+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
404+
405+
bool GameActivity::LockControlledActor(Players player, bool lock, Controller::InputMode lockToMode) {
406+
if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) {
407+
bool prevLock = m_LuaLockActor[player];
408+
m_LuaLockActor[player] = lock;
409+
m_LuaLockActorMode[player] = lockToMode;
410+
return true;
411+
}
412+
return false;
413+
}
414+
399415
//////////////////////////////////////////////////////////////////////////////////////////
400416
// Virtual method: SwitchToActor
401417
//////////////////////////////////////////////////////////////////////////////////////////
@@ -1424,7 +1440,7 @@ void GameActivity::Update()
14241440
m_ViewState[player] = ViewState::Normal;
14251441
}
14261442
// Switch to next actor if the player wants to. Don't do it while the buy menu is open
1427-
else if (m_PlayerController[player].IsState(ACTOR_NEXT) && m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible())
1443+
else if (m_PlayerController[player].IsState(ACTOR_NEXT) && m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible() && !m_LuaLockActor[player])
14281444
{
14291445
if (m_ControlledActor[player] && m_ControlledActor[player]->GetPieMenu()) {
14301446
m_ControlledActor[player]->GetPieMenu()->SetEnabled(false);
@@ -1444,7 +1460,7 @@ void GameActivity::Update()
14441460
g_FrameMan.ClearScreenText(ScreenOfPlayer(player));
14451461
}
14461462
// Go into manual actor select mode if either actor switch buttons are held for a duration
1447-
else if (m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible() && (m_PlayerController[player].IsState(ACTOR_NEXT_PREP) || m_PlayerController[player].IsState(ACTOR_PREV_PREP)))
1463+
else if (m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible() && !m_LuaLockActor[player] && (m_PlayerController[player].IsState(ACTOR_NEXT_PREP) || m_PlayerController[player].IsState(ACTOR_PREV_PREP)))
14481464
{
14491465
if (m_ActorSelectTimer[player].IsPastRealMS(250))
14501466
{
@@ -1967,7 +1983,7 @@ void GameActivity::Update()
19671983
}
19681984

19691985
// Trap the mouse if we're in gameplay and not in menus
1970-
g_UInputMan.TrapMousePos(!m_pBuyGUI[player]->IsEnabled() && !m_InventoryMenuGUI[player]->IsEnabledAndNotCarousel(), player);
1986+
g_UInputMan.TrapMousePos(!m_pBuyGUI[player]->IsEnabled() && !m_InventoryMenuGUI[player]->IsEnabledAndNotCarousel() && !m_LuaLockActor[player], player);
19711987

19721988
// Start LZ picking mode if a purchase was made
19731989
if (m_pBuyGUI[player]->PurchaseMade())
@@ -2015,6 +2031,8 @@ void GameActivity::Update()
20152031
m_ControlledActor[player]->GetController()->SetInputMode(Controller::CIM_AI);
20162032
} else if (m_InventoryMenuGUI[player]->IsEnabledAndNotCarousel()) {
20172033
m_ControlledActor[player]->GetController()->SetInputMode(Controller::CIM_DISABLED);
2034+
} else if (m_LuaLockActor[player]) {
2035+
m_ControlledActor[player]->GetController()->SetInputMode(m_LuaLockActorMode[player]);
20182036
} else {
20192037
m_ControlledActor[player]->GetController()->SetInputMode(Controller::CIM_PLAYER);
20202038
}

Activities/GameActivity.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,15 @@ class GameActivity : public Activity {
252252

253253
SceneEditorGUI * GetEditorGUI(unsigned int which = 0) const { return m_pEditorGUI[which]; }
254254

255+
/// <summary>
256+
/// Locks a player controlled actor to a specific controller mode.
257+
/// Locking the actor will disable player input, including switching actors.
258+
/// </summary>
259+
/// <param name="player">Which player to lock the actor for.</param>
260+
/// <param name="lock">Whether to lock or unlock the actor. (Default: true)</param>
261+
/// <param name="lockToMode">Which controller mode to lock the actor to. (Default: `CIM_AI`)</param>
262+
/// <returns>Whether the (un)lock was performed.</returns>
263+
bool LockControlledActor(Players player, bool lock = true, Controller::InputMode lockToMode = Controller::InputMode::CIM_AI);
255264

256265
//////////////////////////////////////////////////////////////////////////////////////////
257266
// Virtual method: SwitchToActor
@@ -1035,6 +1044,8 @@ class GameActivity : public Activity {
10351044
BuyMenuGUI *m_pBuyGUI[Players::MaxPlayerCount];
10361045
// The in-game scene editor GUI for each player
10371046
SceneEditorGUI *m_pEditorGUI[Players::MaxPlayerCount];
1047+
bool m_LuaLockActor[Players::MaxPlayerCount]; //!< Whether or not to lock input for each player while lua has control.
1048+
Controller::InputMode m_LuaLockActorMode[Players::MaxPlayerCount]; //!< The input mode to lock to while lua has control.
10381049
// The in-game important message banners for each player
10391050
GUIBanner *m_pBannerRed[Players::MaxPlayerCount];
10401051
GUIBanner *m_pBannerYellow[Players::MaxPlayerCount];

Activities/GibEditor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ void GibEditor::Update()
511511
std::list<MovableObject *> *pEditedGibList = m_pEditorGUI->GetPlacedGibs();
512512
MovableObject *pGibCopy = 0;
513513

514-
for (std::list<Gib>::iterator gItr = pLoadedGibList->begin(); gItr != pLoadedGibList->end(); ++gItr)
514+
for (auto gItr = pLoadedGibList->begin(); gItr != pLoadedGibList->end(); ++gItr)
515515
{
516516
pGibCopy = dynamic_cast<MovableObject *>((*gItr).GetParticlePreset()->Clone());
517517
if (pGibCopy)

0 commit comments

Comments
 (0)