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.
This commit is contained in:
toaster 2023-06-02 20:54:21 +01:00
parent 0bec8317f3
commit f91f075a0d
3 changed files with 61 additions and 0 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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()