From 021f1b7832f5f761b83d9715b3332d8bca397428 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 26 Apr 2021 02:00:40 +0200 Subject: [PATCH] - make SummaryInfo a struct instead of passing a list of values to the script classes. --- source/common/scripting/backend/codegen.cpp | 2 +- source/core/gamecontrol.cpp | 9 +++++++ source/core/mapinfo.h | 12 ++++++++++ .../static/zscript/games/duke/ui/cutscenes.zs | 24 +++++++++++-------- .../static/zscript/games/duke/ui/screens.zs | 24 +++++++++---------- wadsrc/static/zscript/razebase.zs | 11 +++++++++ wadsrc/static/zscript/screenjob.zs | 15 +++--------- 7 files changed, 62 insertions(+), 35 deletions(-) diff --git a/source/common/scripting/backend/codegen.cpp b/source/common/scripting/backend/codegen.cpp index f6f52f0bc..eaafaba98 100644 --- a/source/common/scripting/backend/codegen.cpp +++ b/source/common/scripting/backend/codegen.cpp @@ -8706,7 +8706,7 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx) bool writable; ArgList[i] = ArgList[i]->Resolve(ctx); // must be resolved before the address is requested. - if (ArgList[i]->ValueType->isRealPointer()) + if (ArgList[i] && ArgList[i]->ValueType->isRealPointer()) { auto pointedType = ArgList[i]->ValueType->toPointer()->PointedType; if (pointedType && pointedType->isDynArray()) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 3f1778cea..396abc5de 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -1501,3 +1501,12 @@ DEFINE_FIELD_X(MapRecord, MapRecord, nextLevel) DEFINE_FIELD_X(MapRecord, MapRecord, nextSecret) //native readonly String messages[MAX_MESSAGES]; DEFINE_FIELD_X(MapRecord, MapRecord, author) + +DEFINE_FIELD_X(SummaryInfo, SummaryInfo, kills) +DEFINE_FIELD_X(SummaryInfo, SummaryInfo, maxkills) +DEFINE_FIELD_X(SummaryInfo, SummaryInfo, secrets) +DEFINE_FIELD_X(SummaryInfo, SummaryInfo, maxsecrets) +DEFINE_FIELD_X(SummaryInfo, SummaryInfo, supersecrets) +DEFINE_FIELD_X(SummaryInfo, SummaryInfo, time) +DEFINE_FIELD_X(SummaryInfo, SummaryInfo, cheated) +DEFINE_FIELD_X(SummaryInfo, SummaryInfo, endofgame) diff --git a/source/core/mapinfo.h b/source/core/mapinfo.h index 8b09db4ce..039d3d264 100644 --- a/source/core/mapinfo.h +++ b/source/core/mapinfo.h @@ -137,6 +137,18 @@ struct MapRecord }; +struct SummaryInfo +{ + int kills; + int maxkills; + int secrets; + int maxsecrets; + int supersecrets; + int time; + bool cheated; + bool endofgame; +}; + extern GlobalCutscenes globalCutscenes; extern VolumeRecord volumeList[MAXVOLUMES]; extern MapRecord *currentLevel; diff --git a/wadsrc/static/zscript/games/duke/ui/cutscenes.zs b/wadsrc/static/zscript/games/duke/ui/cutscenes.zs index df0c93413..d8592bdd3 100644 --- a/wadsrc/static/zscript/games/duke/ui/cutscenes.zs +++ b/wadsrc/static/zscript/games/duke/ui/cutscenes.zs @@ -26,7 +26,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms */ //------------------------------------------------------------------------- -class DukeCutscenes +struct DukeCutscenes { //--------------------------------------------------------------------------- // @@ -171,7 +171,7 @@ class DukeCutscenes // //--------------------------------------------------------------------------- - static void BuildE4Intro(ScreenJobRunner runner, MapRecord map) + static void BuildE4Intro(ScreenJobRunner runner) { Array soundinfo; @@ -214,10 +214,10 @@ class DukeCutscenes // //--------------------------------------------------------------------------- - static void BuildSPSummary(ScreenJobRunner runner, MapRecord map, int kills_, int maxkills_, int secrets_, int maxsecrets_, int supersecrets_, int time_, bool cheated) + static void BuildSPSummary(ScreenJobRunner runner, MapRecord map, SummaryInfo stats) { let screen = SummaryScreenBase(new("DukeLevelSummaryScreen").Init()); - if (screen) screen.SetParameters(map, kills_, maxkills_, secrets_, maxsecrets_, supersecrets_, time_, cheated); + if (screen) screen.SetParameters(map, stats); runner.Append(screen); } @@ -260,7 +260,7 @@ class DukeCutscenes } -class RRCutscenes +struct RRCutscenes { //--------------------------------------------------------------------------- @@ -275,6 +275,7 @@ class RRCutscenes { if (!Raze.isRRRA()) { + Array soundinfo; soundinfo.Pushv(1, RRSnd.URANUS + 1); runner.Append(MoviePlayerJob.CreateWithSoundinfo("rr_intro.anm", soundinfo, 0, 9, 9, 9)); @@ -286,7 +287,7 @@ class RRCutscenes } else { - runner.Append(MoviePlayerJob.Create("redint.mve"), 0); + runner.Append(MoviePlayerJob.Create("redint.mve", 0)); } } } @@ -300,6 +301,7 @@ class RRCutscenes static void BuildE1End(ScreenJobRunner runner) { + Array soundinfo; soundinfo.Pushv(1, RRSnd.CHKAMMO + 1); runner.Append(MoviePlayerJob.CreateWithSoundinfo("turdmov.anm", soundinfo, 0, 9, 9, 9)); } @@ -313,6 +315,7 @@ class RRCutscenes static void BuildE2End(ScreenJobRunner runner) { + Array soundinfo; soundinfo.Pushv(1, RRSnd.LN_FINAL + 1); runner.Append(MoviePlayerJob.CreateWithSoundinfo("rr_outro.anm", soundinfo, 0, 9, 9, 9)); runner.Append(ImageScreen.CreateNamed("TENSCREEN")); @@ -335,11 +338,12 @@ class RRCutscenes // //--------------------------------------------------------------------------- - static void BuildSPSummary(ScreenJobRunner runner, MapRecord map, int kills_, int maxkills_, int secrets_, int maxsecrets_, int supersecrets_, int time_, bool cheated) + static void BuildSPSummary(ScreenJobRunner runner, MapRecord map, SummaryInfo stats) { - let screen = SummaryScreenBase(new("RRLevelSummaryScreen").Init(!isRRRA() || map.flags & MapRecord.FORCEEOG)); - if (screen) screen.SetParameters(map, kills_, maxkills_, secrets_, maxsecrets_, supersecrets_, time_, cheated); - runner.Append(screen); + let sumscreen = new("RRLevelSummaryScreen").Init(!Raze.isRRRA() || stats.endOfGame); + let sumscreens = SummaryScreenBase(sumscreen); + if (sumscreens) sumscreens.SetParameters(map, stats); + runner.Append(sumscreen); } //--------------------------------------------------------------------------- diff --git a/wadsrc/static/zscript/games/duke/ui/screens.zs b/wadsrc/static/zscript/games/duke/ui/screens.zs index 6bf32bbb8..2fa3743c9 100644 --- a/wadsrc/static/zscript/games/duke/ui/screens.zs +++ b/wadsrc/static/zscript/games/duke/ui/screens.zs @@ -683,7 +683,7 @@ class DukeLevelSummaryScreen : SummaryScreenBase if (displaystate & printTimeVal) { - tempbuf = FormatTime(playtime); + tempbuf = FormatTime(stats.time); Duke.GameText((320 >> 2) + 71, 59 + 9, tempbuf, 0); tempbuf = FormatTime(level.parTime); @@ -705,16 +705,16 @@ class DukeLevelSummaryScreen : SummaryScreenBase if (displaystate & printKillsVal) { - tempbuf = String.Format("%-3d", kills); + tempbuf = String.Format("%-3d", stats.kills); Duke.GameText((320 >> 2) + 70, 94 + 9, tempbuf, 0); - if (maxkills < 0) + if (stats.maxkills < 0) { tempbuf = "$TXT_N_A"; } else { - tempbuf = String.Format("%-3d", max(0, maxkills - kills)); + tempbuf = String.Format("%-3d", max(0, stats.maxkills - stats.kills)); } Duke.GameText((320 >> 2) + 70, 104 + 9, tempbuf, 0); } @@ -728,9 +728,9 @@ class DukeLevelSummaryScreen : SummaryScreenBase if (displaystate & printSecretsVal) { - tempbuf = String.Format("%-3d", secrets); + tempbuf = String.Format("%-3d", stats.secrets); Duke.GameText((320 >> 2) + 70, 119 + 9, tempbuf, 0); - tempbuf = String.Format("%-3d", max(0, maxsecrets - secrets)); + tempbuf = String.Format("%-3d", max(0, stats.maxsecrets - stats.secrets)); Duke.GameText((320 >> 2) + 70, 129 + 9, tempbuf, 0); } } @@ -918,7 +918,7 @@ class RRLevelSummaryScreen : SummaryScreenBase if (displaystate & printTimeVal) { - tempbuf = FormatTime(playtime); + tempbuf = FormatTime(stats.time); Duke.BigText(191, 48, tempbuf, -1); tempbuf = FormatTime(level.parTime); @@ -937,15 +937,15 @@ class RRLevelSummaryScreen : SummaryScreenBase if (displaystate & printKillsVal) { - tempbuf.Format("%-3d", kills); + tempbuf.Format("%-3d", stats.kills); Duke.BigText(231, 112, tempbuf, -1); - if (maxkills < 0) + if (stats.maxkills < 0) { tempbuf = "$TXT_N_A"; } else { - tempbuf = String.Format("%-3d", max(0, maxkills - kills)); + tempbuf = String.Format("%-3d", max(0, stats.maxkills - stats.kills)); } Duke.BigText(231, 128, tempbuf, -1); } @@ -959,9 +959,9 @@ class RRLevelSummaryScreen : SummaryScreenBase if (displaystate & printSecretsVal) { - tempbuf = String.Format("%-3d", secrets); + tempbuf = String.Format("%-3d", stats.secrets); Duke.BigText(231, 144, tempbuf, -1); - tempbuf = String.Format("%-3d", max(0, maxsecrets - secrets)); + tempbuf = String.Format("%-3d", max(0, stats.maxsecrets - stats.secrets)); Duke.BigText(231, 160, tempbuf, -1); } } diff --git a/wadsrc/static/zscript/razebase.zs b/wadsrc/static/zscript/razebase.zs index a7dcd3254..6346a4e7a 100644 --- a/wadsrc/static/zscript/razebase.zs +++ b/wadsrc/static/zscript/razebase.zs @@ -87,6 +87,17 @@ struct MapRecord native } } +struct SummaryInfo native +{ + native readonly int kills; + native readonly int maxkills; + native readonly int secrets; + native readonly int maxsecrets; + native readonly int supersecrets; + native readonly int time; + native readonly bool cheated; + native readonly bool endofgame; +} struct Raze { diff --git a/wadsrc/static/zscript/screenjob.zs b/wadsrc/static/zscript/screenjob.zs index e41f62dab..8ae6e6f3a 100644 --- a/wadsrc/static/zscript/screenjob.zs +++ b/wadsrc/static/zscript/screenjob.zs @@ -198,21 +198,12 @@ class ImageScreen : SkippableScreenJob class SummaryScreenBase : ScreenJob { MapRecord level; - int kills, maxkills; - int secrets, maxsecrets, supersecrets; - int playtime; - bool cheatflag; + SummaryInfo stats; - void SetParameters(MapRecord map, int kills_, int maxkills_, int secrets_, int maxsecrets_, int supersecrets_, int time_, bool cheated) + void SetParameters(MapRecord map, SummaryInfo thestats) { level = map; - kills = kills_; - maxkills = maxkills_; - secrets = secrets_; - maxsecrets = maxsecrets_; - supersecrets = supersecrets_; - playtime = time_; - cheatflag = cheated; + stats = thestats; } String FormatTime(int time)