Merge pull request #7 from nev6502/nev6502_branch

Added ability to attach Lua/MapScript callbacks to a trigger. Can be …
This commit is contained in:
jmarshall23
2020-06-15 11:17:39 -07:00
committed by GitHub
6 changed files with 408 additions and 34 deletions
+11 -13
View File
@@ -60,7 +60,6 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
#include "MapScript.h"
#ifdef WIN32
#include "tcpip.h"
#include "ccdde.h"
@@ -111,7 +110,6 @@ bool Is_Mission_Counterstrike (char *file_name);
bool Is_Mission_Aftermath (char *file_name);
#endif
MapScript* mapScript = nullptr;
bool mapScriptPlayStart = false;
void Cmd_Map(void);
@@ -332,13 +330,13 @@ bool Start_Scenario(char * name, bool briefing)
}
// jmarshall: map scripts
if (mapScript) {
delete mapScript;
if (Scen.mapScript) {
delete Scen.mapScript;
}
mapScript = new MapScript();
if (!mapScript->Init(name)) {
delete mapScript;
mapScript = nullptr;
Scen.mapScript = new MapScript();
if (!Scen.mapScript->Init(name)) {
delete Scen.mapScript;
Scen.mapScript = nullptr;
}
else {
mapScriptPlayStart = true;
@@ -379,11 +377,11 @@ bool Start_Scenario(char * name, bool briefing)
// }
Theme.Stop();
// jmarshall - map scripts
if (mapScript) {
if (Scen.mapScript) {
Hide_Mouse();
VisiblePage.Clear();
Show_Mouse();
mapScript->CallFunction("map_briefing");
Scen.mapScript->CallFunction("map_briefing");
}
else if (briefing) {
Hide_Mouse();
@@ -430,16 +428,16 @@ bool Start_Scenario(char * name, bool briefing)
}
void Scenario_MapScriptFrame(void) {
if (!mapScript)
if (!Scen.mapScript)
return;
if (mapScriptPlayStart) {
mapScript->CallFunction("map_start");
Scen.mapScript->CallFunction("map_start");
mapScriptPlayStart = false;
return;
}
mapScript->CallFunction("map_frame");
Scen.mapScript->CallFunction("map_frame");
}