From 79ae66d5ec73f5773ecbf494c8bcd8e2ca35b81c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 Oct 2023 19:30:21 +0200 Subject: [PATCH] exported gGameOptions. --- source/games/blood/src/vmexports.cpp | 30 ++++++++++++------- .../static/zscript/games/blood/bloodactor.zs | 4 +-- .../static/zscript/games/blood/bloodgame.zs | 26 +++++++++++++++- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/source/games/blood/src/vmexports.cpp b/source/games/blood/src/vmexports.cpp index 216b6d68a..20b0fd927 100644 --- a/source/games/blood/src/vmexports.cpp +++ b/source/games/blood/src/vmexports.cpp @@ -24,6 +24,26 @@ See the GNU General Public License for more details. #include "blood.h" BEGIN_BLD_NS + +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, nGameType) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, nDifficulty) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, nMonsterSettings) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, uGameFlags) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, uNetGameFlags) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, nWeaponSettings) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, nItemSettings) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, nRespawnSettings) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, nTeamSettings) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, nMonsterRespawnTime) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, nWeaponRespawnTime) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, nItemRespawnTime) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, nSpecialRespawnTime) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, weaponsV10x) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, bFriendlyFire) +DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, bKeepKeysOnRespawn) +DEFINE_GLOBAL_UNSIZED(gGameOptions) + + DEFINE_ACTION_FUNCTION(_Blood, OriginalLoadScreen) { static int bLoadScreenCrcMatch = -1; @@ -87,16 +107,6 @@ DEFINE_ACTION_FUNCTION(_Blood, GetViewPlayer) ACTION_RETURN_POINTER(getPlayer(gViewIndex)); } -static int blood_gameMode() -{ - return gGameOptions.nGameType; -} -DEFINE_ACTION_FUNCTION_NATIVE(_Blood, gameType, blood_gameMode) -{ - PARAM_PROLOGUE; - ACTION_RETURN_INT(gGameOptions.nGameType); -} - DEFINE_ACTION_FUNCTION(_BloodPlayer, GetHealth) { PARAM_SELF_STRUCT_PROLOGUE(DBloodPlayer); diff --git a/wadsrc/static/zscript/games/blood/bloodactor.zs b/wadsrc/static/zscript/games/blood/bloodactor.zs index 42b531259..909530b9b 100644 --- a/wadsrc/static/zscript/games/blood/bloodactor.zs +++ b/wadsrc/static/zscript/games/blood/bloodactor.zs @@ -225,11 +225,11 @@ class BloodActor : CoreActor native spawned.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; spawned.shade = spawned.defshade; - if (itemtype is 'BloodKeyBase' && Blood.GameType() == kSingleplayer) + if (itemtype is 'BloodKeyBase' && gGameOptions.nGameType == kSingleplayer) { spawned.xspr.respawn = 3; } - if (itemtype is 'BloodFlagBase' && Blood.GameType() == kTeamplay) + if (itemtype is 'BloodFlagBase' && gGameOptions.nGameType == kTeamplay) { spawned.evPostActorCallback(1800, kCallbackReturnFlag); } diff --git a/wadsrc/static/zscript/games/blood/bloodgame.zs b/wadsrc/static/zscript/games/blood/bloodgame.zs index 592b651a5..3420d09f8 100644 --- a/wadsrc/static/zscript/games/blood/bloodgame.zs +++ b/wadsrc/static/zscript/games/blood/bloodgame.zs @@ -49,7 +49,6 @@ struct Blood native native static void sndStartSampleNamed(String sname, int volume, int channel); native static TextureID PowerupIcon(int pwup); native static BloodPlayer GetViewPlayer(); - native static int gameType(); // These are just dummies to make the MP statusbar code compile. @@ -64,6 +63,31 @@ struct Blood native } } +struct GAMEOPTIONS native +{ + native readonly uint8 nGameType; + native readonly uint8 nDifficulty; + native readonly uint8 nMonsterSettings; + native readonly int uGameFlags; + native readonly int uNetGameFlags; + native readonly uint8 nWeaponSettings; + native readonly uint8 nItemSettings; + native readonly uint8 nRespawnSettings; + native readonly uint8 nTeamSettings; + native readonly int nMonsterRespawnTime; + native readonly int nWeaponRespawnTime; + native readonly int nItemRespawnTime; + native readonly int nSpecialRespawnTime; + native readonly int weaponsV10x; + native readonly bool bFriendlyFire; + native readonly bool bKeepKeysOnRespawn; +} + +extend struct _ +{ + native readonly @GAMEOPTIONS gGameOptions; +} + struct PACKINFO // not native! { bool isActive;