summaryrefslogtreecommitdiffstats
path: root/TemplePushing.c4s
diff options
context:
space:
mode:
authorJan <>2015-07-10 21:06:58 +0200
committerJan <_>2015-07-22 14:40:18 +0200
commitb29ee57b37103930c911057c74eca5e04d08a849 (patch)
tree72771f6670861f3337d6abf59bd893b98cea50f6 /TemplePushing.c4s
parenta7c6d274f240e86a8b989aac9e9122180ec5606a (diff)
downloadtempelschubsen-b29ee57b37103930c911057c74eca5e04d08a849.tar.gz
tempelschubsen-b29ee57b37103930c911057c74eca5e04d08a849.zip
Move LoadScenarioSection call to script counter callback function
LoadScenarioSection was called directly from the scenario function StartGame which in turn was called by the menu object. When the "Done" entry in the menu was selected, C4ObjectMenu::MenuCommand executed the menu entry callback which called LoadScenarioSection. However, C4ObjectMenu::MenuCommand still used a dangling pointer to the object belonging to the menu that was deleted by LoadScenarioSection, thus causing random crashes.
Diffstat (limited to 'TemplePushing.c4s')
-rw-r--r--TemplePushing.c4s/Script.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/TemplePushing.c4s/Script.c b/TemplePushing.c4s/Script.c
index 535f242..d123912 100644
--- a/TemplePushing.c4s/Script.c
+++ b/TemplePushing.c4s/Script.c
@@ -14,6 +14,8 @@ static section, mode;
static numRelaunches;
static deathmatchEnabled, deathmatchWinScore;
static playerDeaths, playerScore, teamScore;
+static sectionID;
+static extinguisherEnabled, rotateInJumpEnabled;
static ambienceEnabled;
static suddendeathEnabled;
static loadingSection;
@@ -49,8 +51,6 @@ func Initialize()
// Set possible spells
SetScrollSpells([ABLA, MBOT, MFRB, MDBT, GVTY, MLGT, CFAL, MSSH, MINV, MARK, MFWV, MGFL, LAVS, MGPL, ICNL, MDFL, AFST, MGCY, MATT]);
-
- ScriptGo(true);
}
/*func TeamRow(int team) { return 1 + team * 1000; }
@@ -156,20 +156,30 @@ func ShowLobby()
LoadScenarioSection("Lobby");
}
-func StartGame(object menu, string message)
+func SetupDone(object menu, string message)
{
// Copy settings from menu
- var sectionID = menu->LocalN("section");
+ sectionID = menu->LocalN("section");
mode = menu->LocalN("mode");
- var extinguisherEnabled = menu->LocalN("extinguisherEnabled");
+ extinguisherEnabled = menu->LocalN("extinguisherEnabled");
suddendeathEnabled = menu->LocalN("suddendeathEnabled");
- var rotateInJumpEnabled = menu->LocalN("rotateInJumpEnabled");
+ rotateInJumpEnabled = menu->LocalN("rotateInJumpEnabled");
ambienceEnabled = menu->LocalN("ambienceEnabled");
numRelaunches = menu->LocalN("numRelaunches");
deathmatchEnabled = menu->LocalN("deathmatchEnabled");
deathmatchWinScore = menu->LocalN("deathmatchWinScore");
menu->RemoveObject();
+ gameStartMessage = message;
+
+ // Make sure LoadScenarioSection is not called from an object by swapping it out to a script counter callback
+ ScriptGo(true);
+}
+
+func Script0()
+{
+ ScriptGo(false);
+
// Change scenario section
loadingSection = true;
LoadScenarioSection(DefinitionCall(sectionID, "SectionName"));
@@ -243,8 +253,6 @@ func StartGame(object menu, string message)
if (rotateInJumpEnabled) CreateObject(RIJP, 0, 0, NO_OWNER);
CreateObject(OFDR, 0, 0, NO_OWNER);
-
-
// Create mode objects
if (mode == MODE_Magic)
{
@@ -286,7 +294,6 @@ func StartGame(object menu, string message)
InitializePlayer(GetPlayerByIndex(i));
}
- gameStartMessage = message;
ShowCountdown();
}