From f91f075a0da0f2b3ec57dd4f148db474023eafc5 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 2 Jun 2023 20:54:21 +0100 Subject: [PATCH] ACS: void MapWarp(str mapname, bool showintermission) An immediate level change on command, to the specified level (via string). Utilises the existing nextmapoverride and skipstats system, but with skipstats assumed to be the default. --- src/acs/call-funcs.cpp | 58 +++++++++++++++++++++++++++++++++++++++++ src/acs/call-funcs.hpp | 2 ++ src/acs/environment.cpp | 1 + 3 files changed, 61 insertions(+) diff --git a/src/acs/call-funcs.cpp b/src/acs/call-funcs.cpp index c5e07f025..cfb84c7b8 100644 --- a/src/acs/call-funcs.cpp +++ b/src/acs/call-funcs.cpp @@ -1652,6 +1652,64 @@ bool CallFunc_SetLineRenderStyle(ACSVM::Thread *thread, const ACSVM::Word *argV, return false; } +/*-------------------------------------------------- + bool CallFunc_MapWarp(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) + + Immediately warps to another level. +--------------------------------------------------*/ + +bool CallFunc_MapWarp(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) +{ + ACSVM::MapScope *map = NULL; + + ACSVM::String *str = nullptr; + + const char *levelName = NULL; + size_t levelLen = 0; + + UINT16 nextmap = NEXTMAP_INVALID; + + (void)argC; + + if (exitcountdown == 1) + { + // An exit is already in progress. + return false; + } + + map = thread->scopeMap; + + str = map->getString(argV[0]); + + levelName = str->str; + levelLen = str->len; + + if (!levelLen || !levelName) + { + CONS_Alert(CONS_WARNING, "MapWarp level name was not provided.\n"); + } + + nextmap = G_MapNumber(levelName); + + if (nextmap == NEXTMAP_INVALID) + { + CONS_Alert(CONS_WARNING, "MapWarp level %s is not valid or loaded.\n", levelName); + return false; + } + + nextmapoverride = (nextmap + 1); + + if (argV[1] == 0) + skipstats = 1; + + exitcountdown = 1; + + if (server) + SendNetXCmd(XD_EXITLEVEL, NULL, 0); + + return false; +} + /*-------------------------------------------------- bool CallFunc_Get/SetLineProperty(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) diff --git a/src/acs/call-funcs.hpp b/src/acs/call-funcs.hpp index e2c43e945..a59b4d916 100644 --- a/src/acs/call-funcs.hpp +++ b/src/acs/call-funcs.hpp @@ -83,6 +83,8 @@ bool CallFunc_PodiumFinish(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM bool CallFunc_SetLineRenderStyle(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); +bool CallFunc_MapWarp(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); + bool CallFunc_GetLineProperty(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_SetLineProperty(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_GetSideProperty(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); diff --git a/src/acs/environment.cpp b/src/acs/environment.cpp index e90c34cb6..a3adaa50f 100644 --- a/src/acs/environment.cpp +++ b/src/acs/environment.cpp @@ -165,6 +165,7 @@ Environment::Environment() addFuncDataACS0( 501, addCallFunc(CallFunc_PodiumPosition)); addFuncDataACS0( 502, addCallFunc(CallFunc_PodiumFinish)); addFuncDataACS0( 503, addCallFunc(CallFunc_SetLineRenderStyle)); + addFuncDataACS0( 504, addCallFunc(CallFunc_MapWarp)); } ACSVM::Thread *Environment::allocThread()