From 01b5e8f9eb5969da971bc645f618e69089402d98 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 16 Aug 2023 21:54:55 -0400 Subject: [PATCH 1/5] Separate script args from mapthing args SRB2 uses a LOT of mapthing args compared to Hexen (which has none) and ZDoom (which only has them on objects that will never ever activate scripts). So we really badly needed to separate the two if we want attaching scripts to things to be useful. --- src/acs/call-funcs.cpp | 2 +- src/acs/environment.cpp | 10 ++-- src/doomdata.h | 17 ++++-- src/lua_maplib.c | 26 ++++----- src/lua_mobjlib.c | 12 ++-- src/m_cheat.c | 7 ++- src/p_enemy.c | 2 +- src/p_mobj.c | 37 +++++++++++- src/p_mobj.h | 7 ++- src/p_saveg.c | 124 +++++++++++++++++++++++++++++++++------- src/p_setup.c | 75 ++++++++++++++++-------- src/p_spec.c | 16 +++--- src/r_defs.h | 16 ++---- 13 files changed, 250 insertions(+), 101 deletions(-) diff --git a/src/acs/call-funcs.cpp b/src/acs/call-funcs.cpp index 747d74144..1939c1d2d 100644 --- a/src/acs/call-funcs.cpp +++ b/src/acs/call-funcs.cpp @@ -1063,7 +1063,7 @@ bool CallFunc_SetLineSpecial(ACSVM::Thread *thread, const ACSVM::Word *argV, ACS tag = argV[0]; spec = argV[1]; - numArgs = std::min(std::max((signed)(argC - 2), 0), NUMLINEARGS); + numArgs = std::min(std::max((signed)(argC - 2), 0), NUM_SCRIPT_ARGS); TAG_ITER_LINES(tag, lineId) { diff --git a/src/acs/environment.cpp b/src/acs/environment.cpp index 78ffa2256..c886f3651 100644 --- a/src/acs/environment.cpp +++ b/src/acs/environment.cpp @@ -298,13 +298,13 @@ ACSVM::Word Environment::callSpecImpl auto info = &static_cast(thread)->info; ACSVM::MapScope *const map = thread->scopeMap; - INT32 args[NUMLINEARGS] = {0}; + INT32 args[NUM_SCRIPT_ARGS] = {0}; - char *stringargs[NUMLINESTRINGARGS] = {0}; + char *stringargs[NUM_SCRIPT_STRINGARGS] = {0}; auto _ = srb2::finally( [stringargs]() { - for (int i = 0; i < NUMLINESTRINGARGS; i++) + for (int i = 0; i < NUM_SCRIPT_STRINGARGS; i++) { Z_Free(stringargs[i]); } @@ -322,7 +322,7 @@ ACSVM::Word Environment::callSpecImpl int i = 0; - for (i = 0; i < std::min((signed)(argC), NUMLINESTRINGARGS); i++) + for (i = 0; i < std::min((signed)(argC), NUM_SCRIPT_STRINGARGS); i++) { ACSVM::String *strPtr = map->getString(argV[i]); @@ -330,7 +330,7 @@ ACSVM::Word Environment::callSpecImpl M_Memcpy(stringargs[i], strPtr->str, strPtr->len + 1); } - for (i = 0; i < std::min((signed)(argC), NUMLINEARGS); i++) + for (i = 0; i < std::min((signed)(argC), NUM_SCRIPT_ARGS); i++) { args[i] = argV[i]; } diff --git a/src/doomdata.h b/src/doomdata.h index cfed6fbcd..375635b52 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -36,6 +36,11 @@ extern "C" { // used in the lumps of the WAD files. // +// Number of args for ACS scripts. +// Increasing this requires you to also update the ACS compiler. +#define NUM_SCRIPT_ARGS 10 +#define NUM_SCRIPT_STRINGARGS 2 + // Lump order in a map WAD: each map needs a couple of lumps // to provide a complete scene geometry description. enum @@ -248,8 +253,10 @@ struct mapUserProperties_t size_t capacity; }; -#define NUMMAPTHINGARGS 10 -#define NUMMAPTHINGSTRINGARGS 2 +// Number of args for thing behaviors. +// These are safe to increase at any time. +#define NUM_MAPTHING_ARGS 10 +#define NUM_MAPTHING_STRINGARGS 2 // Thing definition, position, orientation and type, // plus visibility flags and attributes. @@ -264,8 +271,10 @@ struct mapthing_t mtag_t tid; fixed_t scale; INT16 special; - INT32 args[NUMMAPTHINGARGS]; - char *stringargs[NUMMAPTHINGSTRINGARGS]; + INT32 args[NUM_MAPTHING_ARGS]; + char *stringargs[NUM_MAPTHING_STRINGARGS]; + INT32 script_args[NUM_SCRIPT_ARGS]; + char *script_stringargs[NUM_SCRIPT_STRINGARGS]; UINT8 layer; // FOF layer to spawn on, see P_GetMobjSpawnHeight mapUserProperties_t user; // UDMF user-defined custom properties. mobj_t *mobj; diff --git a/src/lua_maplib.c b/src/lua_maplib.c index b7926fcca..ef9043ca0 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -601,16 +601,16 @@ static int sectorargs_get(lua_State *L) { INT32 *args = *((INT32**)luaL_checkudata(L, 1, META_SECTORARGS)); int i = luaL_checkinteger(L, 2); - if (i < 0 || i >= NUMSECTORARGS) + if (i < 0 || i >= NUM_SCRIPT_ARGS) return luaL_error(L, LUA_QL("sector_t.args") " index cannot be %d", i); lua_pushinteger(L, args[i]); return 1; } -// #args -> NUMSECTORARGS +// #args -> NUM_SCRIPT_ARGS static int sectorargs_len(lua_State* L) { - lua_pushinteger(L, NUMSECTORARGS); + lua_pushinteger(L, NUM_SCRIPT_ARGS); return 1; } @@ -619,16 +619,16 @@ static int sectorstringargs_get(lua_State *L) { char **stringargs = *((char***)luaL_checkudata(L, 1, META_SECTORSTRINGARGS)); int i = luaL_checkinteger(L, 2); - if (i < 0 || i >= NUMSECTORSTRINGARGS) - return luaL_error(L, LUA_QL("line_t.stringargs") " index cannot be %d", i); + if (i < 0 || i >= NUM_SCRIPT_STRINGARGS) + return luaL_error(L, LUA_QL("sector_t.stringargs") " index cannot be %d", i); lua_pushstring(L, stringargs[i]); return 1; } -// #stringargs -> NUMLINESTRINGARGS +// #stringargs -> NUM_SCRIPT_STRINGARGS static int sectorstringargs_len(lua_State *L) { - lua_pushinteger(L, NUMSECTORSTRINGARGS); + lua_pushinteger(L, NUM_SCRIPT_STRINGARGS); return 1; } @@ -944,16 +944,16 @@ static int lineargs_get(lua_State *L) { INT32 *args = *((INT32**)luaL_checkudata(L, 1, META_LINEARGS)); int i = luaL_checkinteger(L, 2); - if (i < 0 || i >= NUMLINEARGS) + if (i < 0 || i >= NUM_SCRIPT_ARGS) return luaL_error(L, LUA_QL("line_t.args") " index cannot be %d", i); lua_pushinteger(L, args[i]); return 1; } -// #args -> NUMLINEARGS +// #args -> NUM_SCRIPT_ARGS static int lineargs_len(lua_State* L) { - lua_pushinteger(L, NUMLINEARGS); + lua_pushinteger(L, NUM_SCRIPT_ARGS); return 1; } @@ -962,16 +962,16 @@ static int linestringargs_get(lua_State *L) { char **stringargs = *((char***)luaL_checkudata(L, 1, META_LINESTRINGARGS)); int i = luaL_checkinteger(L, 2); - if (i < 0 || i >= NUMLINESTRINGARGS) + if (i < 0 || i >= NUM_SCRIPT_STRINGARGS) return luaL_error(L, LUA_QL("line_t.stringargs") " index cannot be %d", i); lua_pushstring(L, stringargs[i]); return 1; } -// #stringargs -> NUMLINESTRINGARGS +// #stringargs -> NUM_SCRIPT_STRINGARGS static int linestringargs_len(lua_State *L) { - lua_pushinteger(L, NUMLINESTRINGARGS); + lua_pushinteger(L, NUM_SCRIPT_STRINGARGS); return 1; } diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index efcc62687..bc35e0b3a 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -916,16 +916,16 @@ static int thingargs_get(lua_State *L) { INT32 *args = *((INT32**)luaL_checkudata(L, 1, META_THINGARGS)); int i = luaL_checkinteger(L, 2); - if (i < 0 || i >= NUMMAPTHINGARGS) + if (i < 0 || i >= NUM_MAPTHING_ARGS) return luaL_error(L, LUA_QL("mapthing_t.args") " index cannot be %d", i); lua_pushinteger(L, args[i]); return 1; } -// #args -> NUMMAPTHINGARGS +// #args -> NUM_MAPTHING_ARGS static int thingargs_len(lua_State* L) { - lua_pushinteger(L, NUMMAPTHINGARGS); + lua_pushinteger(L, NUM_MAPTHING_ARGS); return 1; } @@ -934,16 +934,16 @@ static int thingstringargs_get(lua_State *L) { char **stringargs = *((char***)luaL_checkudata(L, 1, META_THINGSTRINGARGS)); int i = luaL_checkinteger(L, 2); - if (i < 0 || i >= NUMMAPTHINGSTRINGARGS) + if (i < 0 || i >= NUM_MAPTHING_STRINGARGS) return luaL_error(L, LUA_QL("mapthing_t.stringargs") " index cannot be %d", i); lua_pushstring(L, stringargs[i]); return 1; } -// #stringargs -> NUMMAPTHINGSTRINGARGS +// #stringargs -> NUM_MAPTHING_STRINGARGS static int thingstringargs_len(lua_State *L) { - lua_pushinteger(L, NUMMAPTHINGSTRINGARGS); + lua_pushinteger(L, NUM_MAPTHING_STRINGARGS); return 1; } diff --git a/src/m_cheat.c b/src/m_cheat.c index ecfb9a79c..d555e9b1d 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -792,8 +792,11 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c mt->options = (mt->z << ZSHIFT) | (UINT16)cv_opflags.value; mt->scale = player->mo->scale; - memset(mt->args, 0, NUMMAPTHINGARGS*sizeof(*mt->args)); - memset(mt->stringargs, 0x00, NUMMAPTHINGSTRINGARGS*sizeof(*mt->stringargs)); + memset(mt->args, 0, NUM_MAPTHING_ARGS*sizeof(*mt->args)); + memset(mt->stringargs, 0x00, NUM_MAPTHING_STRINGARGS*sizeof(*mt->stringargs)); + mt->special = 0; + memset(mt->script_args, 0, NUM_SCRIPT_ARGS*sizeof(*mt->script_args)); + memset(mt->script_stringargs, 0x00, NUM_SCRIPT_STRINGARGS*sizeof(*mt->script_stringargs)); mt->pitch = mt->roll = 0; return mt; } diff --git a/src/p_enemy.c b/src/p_enemy.c index 5e82b57dd..1eec607d0 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -6902,7 +6902,7 @@ void A_LinedefExecuteFromArg(mobj_t *actor) if (LUA_CallAction(A_LINEDEFEXECUTEFROMARG, actor)) return; - if (locvar1 < 0 || locvar1 > NUMMAPTHINGARGS) + if (locvar1 < 0 || locvar1 > NUM_MAPTHING_ARGS) { CONS_Debug(DBG_GAMELOGIC, "A_LinedefExecuteFromArg: Invalid mapthing arg %d\n", locvar1); return; diff --git a/src/p_mobj.c b/src/p_mobj.c index 47d20059b..f1db29b99 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -13604,12 +13604,12 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, mobj->special = mthing->special; - for (arg = 0; arg < NUMMAPTHINGARGS; arg++) + for (arg = 0; arg < NUM_MAPTHING_ARGS; arg++) { mobj->args[arg] = mthing->args[arg]; } - for (arg = 0; arg < NUMMAPTHINGSTRINGARGS; arg++) + for (arg = 0; arg < NUM_MAPTHING_STRINGARGS; arg++) { size_t len = 0; @@ -13629,6 +13629,31 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, M_Memcpy(mobj->stringargs[arg], mthing->stringargs[arg], len + 1); } + for (arg = 0; arg < NUM_SCRIPT_ARGS; arg++) + { + mobj->script_args[arg] = mthing->args[arg]; + } + + for (arg = 0; arg < NUM_SCRIPT_STRINGARGS; arg++) + { + size_t len = 0; + + if (mthing->script_stringargs[arg]) + { + len = strlen(mthing->script_stringargs[arg]); + } + + if (len == 0) + { + Z_Free(mobj->script_stringargs[arg]); + mobj->script_stringargs[arg] = NULL; + continue; + } + + mobj->script_stringargs[arg] = Z_Realloc(mobj->script_stringargs[arg], len + 1, PU_LEVEL, NULL); + M_Memcpy(mobj->script_stringargs[arg], mthing->script_stringargs[arg], len + 1); + } + if (!P_SetupSpawnedMapThing(mthing, mobj)) { if (P_MobjWasRemoved(mobj)) @@ -14680,9 +14705,15 @@ void P_DeleteMobjStringArgs(mobj_t *mobj) { size_t i = SIZE_MAX; - for (i = 0; i < NUMMAPTHINGSTRINGARGS; i++) + for (i = 0; i < NUM_MAPTHING_STRINGARGS; i++) { Z_Free(mobj->stringargs[i]); mobj->stringargs[i] = NULL; } + + for (i = 0; i < NUM_SCRIPT_STRINGARGS; i++) + { + Z_Free(mobj->script_stringargs[i]); + mobj->script_stringargs[i] = NULL; + } } diff --git a/src/p_mobj.h b/src/p_mobj.h index a531c456d..b1ac0004c 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -426,9 +426,12 @@ struct mobj_t INT32 dispoffset; + INT32 args[NUM_MAPTHING_ARGS]; + char *stringargs[NUM_MAPTHING_STRINGARGS]; + INT16 special; - INT32 args[NUMMAPTHINGARGS]; - char *stringargs[NUMMAPTHINGSTRINGARGS]; + INT32 script_args[NUM_SCRIPT_ARGS]; + char *script_stringargs[NUM_SCRIPT_STRINGARGS]; // WARNING: New fields must be added separately to savegame and Lua. }; diff --git a/src/p_saveg.c b/src/p_saveg.c index f948c7fa0..630888763 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1547,7 +1547,7 @@ static void P_NetUnArchiveColormaps(savebuffer_t *save) static boolean P_SectorArgsEqual(const sector_t *sc, const sector_t *spawnsc) { UINT8 i; - for (i = 0; i < NUMSECTORARGS; i++) + for (i = 0; i < NUM_SCRIPT_ARGS; i++) if (sc->args[i] != spawnsc->args[i]) return false; @@ -1557,7 +1557,7 @@ static boolean P_SectorArgsEqual(const sector_t *sc, const sector_t *spawnsc) static boolean P_SectorStringArgsEqual(const sector_t *sc, const sector_t *spawnsc) { UINT8 i; - for (i = 0; i < NUMSECTORSTRINGARGS; i++) + for (i = 0; i < NUM_SCRIPT_STRINGARGS; i++) { if (!sc->stringargs[i]) return !spawnsc->stringargs[i]; @@ -1594,7 +1594,7 @@ static boolean P_SectorStringArgsEqual(const sector_t *sc, const sector_t *spawn static boolean P_LineArgsEqual(const line_t *li, const line_t *spawnli) { UINT8 i; - for (i = 0; i < NUMLINEARGS; i++) + for (i = 0; i < NUM_SCRIPT_ARGS; i++) if (li->args[i] != spawnli->args[i]) return false; @@ -1604,7 +1604,7 @@ static boolean P_LineArgsEqual(const line_t *li, const line_t *spawnli) static boolean P_LineStringArgsEqual(const line_t *li, const line_t *spawnli) { UINT8 i; - for (i = 0; i < NUMLINESTRINGARGS; i++) + for (i = 0; i < NUM_SCRIPT_STRINGARGS; i++) { if (!li->stringargs[i]) return !spawnli->stringargs[i]; @@ -1867,12 +1867,12 @@ static void ArchiveSectors(savebuffer_t *save) WRITEINT16(save->p, ss->action); if (diff4 & SD_ARGS) { - for (j = 0; j < NUMSECTORARGS; j++) + for (j = 0; j < NUM_SCRIPT_ARGS; j++) WRITEINT32(save->p, ss->args[j]); } if (diff4 & SD_STRINGARGS) { - for (j = 0; j < NUMSECTORSTRINGARGS; j++) + for (j = 0; j < NUM_SCRIPT_STRINGARGS; j++) { size_t len, k; @@ -2021,12 +2021,12 @@ static void UnArchiveSectors(savebuffer_t *save) sectors[i].action = READINT16(save->p); if (diff4 & SD_ARGS) { - for (j = 0; j < NUMSECTORARGS; j++) + for (j = 0; j < NUM_SCRIPT_ARGS; j++) sectors[i].args[j] = READINT32(save->p); } if (diff4 & SD_STRINGARGS) { - for (j = 0; j < NUMLINESTRINGARGS; j++) + for (j = 0; j < NUM_SCRIPT_STRINGARGS; j++) { size_t len = READINT32(save->p); size_t k; @@ -2157,13 +2157,13 @@ static void ArchiveLines(savebuffer_t *save) if (diff2 & LD_ARGS) { UINT8 j; - for (j = 0; j < NUMLINEARGS; j++) + for (j = 0; j < NUM_SCRIPT_ARGS; j++) WRITEINT32(save->p, li->args[j]); } if (diff2 & LD_STRINGARGS) { UINT8 j; - for (j = 0; j < NUMLINESTRINGARGS; j++) + for (j = 0; j < NUM_SCRIPT_STRINGARGS; j++) { size_t len, k; @@ -2246,13 +2246,13 @@ static void UnArchiveLines(savebuffer_t *save) if (diff2 & LD_ARGS) { UINT8 j; - for (j = 0; j < NUMLINEARGS; j++) + for (j = 0; j < NUM_SCRIPT_ARGS; j++) li->args[j] = READINT32(save->p); } if (diff2 & LD_STRINGARGS) { UINT8 j; - for (j = 0; j < NUMLINESTRINGARGS; j++) + for (j = 0; j < NUM_SCRIPT_STRINGARGS; j++) { size_t len = READINT32(save->p); size_t k; @@ -2318,7 +2318,7 @@ static void P_NetUnArchiveWorld(savebuffer_t *save) static boolean P_ThingArgsEqual(const mobj_t *mobj, const mapthing_t *mapthing) { UINT8 i; - for (i = 0; i < NUMMAPTHINGARGS; i++) + for (i = 0; i < NUM_MAPTHING_ARGS; i++) if (mobj->args[i] != mapthing->args[i]) return false; @@ -2328,7 +2328,7 @@ static boolean P_ThingArgsEqual(const mobj_t *mobj, const mapthing_t *mapthing) static boolean P_ThingStringArgsEqual(const mobj_t *mobj, const mapthing_t *mapthing) { UINT8 i; - for (i = 0; i < NUMMAPTHINGSTRINGARGS; i++) + for (i = 0; i < NUM_MAPTHING_STRINGARGS; i++) { if (!mobj->stringargs[i]) return !mapthing->stringargs[i]; @@ -2340,6 +2340,28 @@ static boolean P_ThingStringArgsEqual(const mobj_t *mobj, const mapthing_t *mapt return true; } +static boolean P_ThingScriptEqual(const mobj_t *mobj, const mapthing_t *mapthing) +{ + UINT8 i; + if (mobj->special != mapthing->special) + return false; + + for (i = 0; i < NUM_SCRIPT_ARGS; i++) + if (mobj->script_args[i] != mapthing->script_args[i]) + return false; + + for (i = 0; i < NUM_SCRIPT_STRINGARGS; i++) + { + if (!mobj->script_stringargs[i]) + return !mapthing->script_stringargs[i]; + + if (strcmp(mobj->script_stringargs[i], mapthing->script_stringargs[i])) + return false; + } + + return true; +} + typedef enum { MD_SPAWNPOINT = 1, @@ -2546,7 +2568,7 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 if (!P_ThingStringArgsEqual(mobj, mobj->spawnpoint)) diff |= MD_STRINGARGS; - if (mobj->special != mobj->spawnpoint->type) + if (!P_ThingScriptEqual(mobj, mobj->spawnpoint)) diff2 |= MD2_SPECIAL; } else @@ -2554,7 +2576,7 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 // not a map spawned thing, so make it from scratch diff = MD_POS | MD_TYPE; - for (j = 0; j < NUMMAPTHINGARGS; j++) + for (j = 0; j < NUM_MAPTHING_ARGS; j++) { if (mobj->args[j] != 0) { @@ -2563,7 +2585,7 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 } } - for (j = 0; j < NUMMAPTHINGSTRINGARGS; j++) + for (j = 0; j < NUM_MAPTHING_STRINGARGS; j++) { if (mobj->stringargs[j] != NULL) { @@ -2576,6 +2598,24 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 { diff2 |= MD2_SPECIAL; } + + for (j = 0; j < NUM_SCRIPT_ARGS; j++) + { + if (mobj->script_args[j] != 0) + { + diff2 |= MD2_SPECIAL; + break; + } + } + + for (j = 0; j < NUM_SCRIPT_STRINGARGS; j++) + { + if (mobj->stringargs[j] != NULL) + { + diff2 |= MD2_SPECIAL; + break; + } + } } // not the default but the most probable @@ -2826,12 +2866,12 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 WRITEFIXED(save->p, mobj->scalespeed); if (diff & MD_ARGS) { - for (j = 0; j < NUMMAPTHINGARGS; j++) + for (j = 0; j < NUM_MAPTHING_ARGS; j++) WRITEINT32(save->p, mobj->args[j]); } if (diff & MD_STRINGARGS) { - for (j = 0; j < NUMMAPTHINGSTRINGARGS; j++) + for (j = 0; j < NUM_MAPTHING_STRINGARGS; j++) { size_t len, k; @@ -2911,7 +2951,28 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 WRITEFIXED(save->p, mobj->sprzoff); } if (diff2 & MD2_SPECIAL) + { WRITEINT16(save->p, mobj->special); + + for (j = 0; j < NUM_SCRIPT_ARGS; j++) + WRITEINT32(save->p, mobj->script_args[j]); + + for (j = 0; j < NUM_SCRIPT_STRINGARGS; j++) + { + size_t len, k; + + if (!mobj->script_stringargs[j]) + { + WRITEINT32(save->p, 0); + continue; + } + + len = strlen(mobj->script_stringargs[j]); + WRITEINT32(save->p, len); + for (k = 0; k < len; k++) + WRITECHAR(save->p, mobj->script_stringargs[j][k]); + } + } if (diff2 & MD2_FLOORSPRITESLOPE) { pslope_t *slope = mobj->floorspriteslope; @@ -4029,12 +4090,12 @@ static thinker_t* LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) mobj->scalespeed = mapobjectscale/12; if (diff & MD_ARGS) { - for (j = 0; j < NUMMAPTHINGARGS; j++) + for (j = 0; j < NUM_MAPTHING_ARGS; j++) mobj->args[j] = READINT32(save->p); } if (diff & MD_STRINGARGS) { - for (j = 0; j < NUMMAPTHINGSTRINGARGS; j++) + for (j = 0; j < NUM_MAPTHING_STRINGARGS; j++) { size_t len = READINT32(save->p); size_t k; @@ -4121,6 +4182,27 @@ static thinker_t* LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) if (diff2 & MD2_SPECIAL) { mobj->special = READINT16(save->p); + + for (j = 0; j < NUM_SCRIPT_ARGS; j++) + mobj->script_args[j] = READINT32(save->p); + + for (j = 0; j < NUM_SCRIPT_STRINGARGS; j++) + { + size_t len = READINT32(save->p); + size_t k; + + if (!len) + { + Z_Free(mobj->script_stringargs[j]); + mobj->script_stringargs[j] = NULL; + continue; + } + + mobj->script_stringargs[j] = Z_Realloc(mobj->script_stringargs[j], len + 1, PU_LEVEL, NULL); + for (k = 0; k < len; k++) + mobj->script_stringargs[j][k] = READCHAR(save->p); + mobj->script_stringargs[j][len] = '\0'; + } } if (diff2 & MD2_FLOORSPRITESLOPE) { diff --git a/src/p_setup.c b/src/p_setup.c index 3f9bfcd2e..1bc7de070 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -967,8 +967,8 @@ static void P_LoadSectors(UINT8 *data) ss->friction = ORIG_FRICTION; ss->action = 0; - memset(ss->args, 0, NUMLINEARGS*sizeof(*ss->args)); - memset(ss->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ss->stringargs)); + memset(ss->args, 0, NUM_SCRIPT_ARGS*sizeof(*ss->args)); + memset(ss->stringargs, 0x00, NUM_SCRIPT_STRINGARGS*sizeof(*ss->stringargs)); ss->activation = 0; P_InitializeSector(ss); @@ -1076,8 +1076,8 @@ static void P_LoadLinedefs(UINT8 *data) ld->flags = (UINT32)(SHORT(mld->flags)); ld->special = SHORT(mld->special); Tag_FSet(&ld->tags, SHORT(mld->tag)); - memset(ld->args, 0, NUMLINEARGS*sizeof(*ld->args)); - memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs)); + memset(ld->args, 0, NUM_SCRIPT_ARGS*sizeof(*ld->args)); + memset(ld->stringargs, 0x00, NUM_SCRIPT_STRINGARGS*sizeof(*ld->stringargs)); ld->alpha = FRACUNIT; ld->executordelay = 0; ld->activation = 0; @@ -1360,9 +1360,11 @@ static void P_LoadThings(UINT8 *data) mt->extrainfo = (UINT8)(mt->type >> 12); mt->tid = 0; mt->scale = FRACUNIT; - memset(mt->args, 0, NUMMAPTHINGARGS*sizeof(*mt->args)); - memset(mt->stringargs, 0x00, NUMMAPTHINGSTRINGARGS*sizeof(*mt->stringargs)); + memset(mt->args, 0, NUM_MAPTHING_ARGS*sizeof(*mt->args)); + memset(mt->stringargs, 0x00, NUM_MAPTHING_STRINGARGS*sizeof(*mt->stringargs)); mt->special = 0; + memset(mt->script_args, 0, NUM_SCRIPT_ARGS*sizeof(*mt->script_args)); + memset(mt->script_stringargs, 0x00, NUM_SCRIPT_STRINGARGS*sizeof(*mt->script_stringargs)); mt->pitch = mt->roll = 0; mt->layer = 0; @@ -1757,7 +1759,7 @@ static void ParseTextmapSectorParameter(UINT32 i, const char *param, const char else if (fastncmp(param, "stringarg", 9) && strlen(param) > 9) { size_t argnum = atol(param + 9); - if (argnum >= NUMSECTORSTRINGARGS) + if (argnum >= NUM_SCRIPT_STRINGARGS) return; sectors[i].stringargs[argnum] = Z_Malloc(strlen(val) + 1, PU_LEVEL, NULL); M_Memcpy(sectors[i].stringargs[argnum], val, strlen(val) + 1); @@ -1765,7 +1767,7 @@ static void ParseTextmapSectorParameter(UINT32 i, const char *param, const char else if (fastncmp(param, "arg", 3) && strlen(param) > 3) { size_t argnum = atol(param + 3); - if (argnum >= NUMSECTORARGS) + if (argnum >= NUM_SCRIPT_ARGS) return; sectors[i].args[argnum] = atol(val); } @@ -1838,7 +1840,7 @@ static void ParseTextmapLinedefParameter(UINT32 i, const char *param, const char else if (fastncmp(param, "stringarg", 9) && strlen(param) > 9) { size_t argnum = atol(param + 9); - if (argnum >= NUMLINESTRINGARGS) + if (argnum >= NUM_SCRIPT_STRINGARGS) return; lines[i].stringargs[argnum] = Z_Malloc(strlen(val) + 1, PU_LEVEL, NULL); M_Memcpy(lines[i].stringargs[argnum], val, strlen(val) + 1); @@ -1846,7 +1848,7 @@ static void ParseTextmapLinedefParameter(UINT32 i, const char *param, const char else if (fastncmp(param, "arg", 3) && strlen(param) > 3) { size_t argnum = atol(param + 3); - if (argnum >= NUMLINEARGS) + if (argnum >= NUM_SCRIPT_ARGS) return; lines[i].args[argnum] = atol(val); } @@ -1955,7 +1957,7 @@ static void ParseTextmapThingParameter(UINT32 i, const char *param, const char * else if (fastncmp(param, "stringarg", 9) && strlen(param) > 9) { size_t argnum = atol(param + 9); - if (argnum >= NUMMAPTHINGSTRINGARGS) + if (argnum >= NUM_MAPTHING_STRINGARGS) return; size_t len = strlen(val); mapthings[i].stringargs[argnum] = Z_Malloc(len + 1, PU_LEVEL, NULL); @@ -1965,10 +1967,27 @@ static void ParseTextmapThingParameter(UINT32 i, const char *param, const char * else if (fastncmp(param, "arg", 3) && strlen(param) > 3) { size_t argnum = atol(param + 3); - if (argnum >= NUMMAPTHINGARGS) + if (argnum >= NUM_MAPTHING_ARGS) return; mapthings[i].args[argnum] = atol(val); } + else if (fastncmp(param, "scriptstringarg", 15) && strlen(param) > 15) + { + size_t argnum = atol(param + 15); + if (argnum >= NUM_SCRIPT_STRINGARGS) + return; + size_t len = strlen(val); + mapthings[i].script_stringargs[argnum] = Z_Malloc(len + 1, PU_LEVEL, NULL); + M_Memcpy(mapthings[i].script_stringargs[argnum], val, len); + mapthings[i].script_stringargs[argnum][len] = '\0'; + } + else if (fastncmp(param, "scriptarg", 9) && strlen(param) > 9) + { + size_t argnum = atol(param + 9); + if (argnum >= NUM_SCRIPT_ARGS) + return; + mapthings[i].script_args[argnum] = atol(val); + } else ParseUserProperty(&mapthings[i].user, param, val); } @@ -2110,10 +2129,16 @@ static void P_WriteTextmapThing(FILE *f, mapthing_t *wmapthings, size_t i, size_ fprintf(f, "flip = true;\n"); if (wmapthings[i].special != 0) fprintf(f, "special = %d;\n", wmapthings[i].special); - for (j = 0; j < NUMMAPTHINGARGS; j++) + for (j = 0; j < NUM_SCRIPT_ARGS; j++) + if (wmapthings[i].script_args[j] != 0) + fprintf(f, "scriptarg%s = %d;\n", sizeu1(j), wmapthings[i].script_args[j]); + for (j = 0; j < NUM_SCRIPT_STRINGARGS; j++) + if (mapthings[i].script_stringargs[j]) + fprintf(f, "scriptstringarg%s = \"%s\";\n", sizeu1(j), mapthings[i].script_stringargs[j]); + for (j = 0; j < NUM_MAPTHING_ARGS; j++) if (wmapthings[i].args[j] != 0) fprintf(f, "arg%s = %d;\n", sizeu1(j), wmapthings[i].args[j]); - for (j = 0; j < NUMMAPTHINGSTRINGARGS; j++) + for (j = 0; j < NUM_MAPTHING_STRINGARGS; j++) if (mapthings[i].stringargs[j]) fprintf(f, "stringarg%s = \"%s\";\n", sizeu1(j), mapthings[i].stringargs[j]); if (wmapthings[i].user.length > 0) @@ -2534,10 +2559,10 @@ static void P_WriteTextmap(void) } if (wlines[i].special != 0) fprintf(f, "special = %d;\n", wlines[i].special); - for (j = 0; j < NUMLINEARGS; j++) + for (j = 0; j < NUM_SCRIPT_ARGS; j++) if (wlines[i].args[j] != 0) fprintf(f, "arg%s = %d;\n", sizeu1(j), wlines[i].args[j]); - for (j = 0; j < NUMLINESTRINGARGS; j++) + for (j = 0; j < NUM_SCRIPT_STRINGARGS; j++) if (lines[i].stringargs[j]) fprintf(f, "stringarg%s = \"%s\";\n", sizeu1(j), lines[i].stringargs[j]); if (wlines[i].alpha != FRACUNIT) @@ -2822,10 +2847,10 @@ static void P_WriteTextmap(void) } if (wsectors[i].action != 0) fprintf(f, "action = %d;\n", wsectors[i].action); - for (j = 0; j < NUMSECTORARGS; j++) + for (j = 0; j < NUM_SCRIPT_ARGS; j++) if (wsectors[i].args[j] != 0) fprintf(f, "arg%s = %d;\n", sizeu1(j), wsectors[i].args[j]); - for (j = 0; j < NUMSECTORSTRINGARGS; j++) + for (j = 0; j < NUM_SCRIPT_STRINGARGS; j++) if (wsectors[i].stringargs[j]) fprintf(f, "stringarg%s = \"%s\";\n", sizeu1(j), wsectors[i].stringargs[j]); switch (wsectors[i].activation & SECSPAC_TRIGGERMASK) @@ -3018,8 +3043,8 @@ static void P_LoadTextmap(void) sc->friction = ORIG_FRICTION; sc->action = 0; - memset(sc->args, 0, NUMSECTORARGS*sizeof(*sc->args)); - memset(sc->stringargs, 0x00, NUMSECTORSTRINGARGS*sizeof(*sc->stringargs)); + memset(sc->args, 0, NUM_SCRIPT_ARGS*sizeof(*sc->args)); + memset(sc->stringargs, 0x00, NUM_SCRIPT_STRINGARGS*sizeof(*sc->stringargs)); sc->activation = 0; K_UserPropertiesClear(&sc->user); @@ -3069,8 +3094,8 @@ static void P_LoadTextmap(void) ld->special = 0; Tag_FSet(&ld->tags, 0); - memset(ld->args, 0, NUMLINEARGS*sizeof(*ld->args)); - memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs)); + memset(ld->args, 0, NUM_SCRIPT_ARGS*sizeof(*ld->args)); + memset(ld->stringargs, 0x00, NUM_SCRIPT_STRINGARGS*sizeof(*ld->stringargs)); ld->alpha = FRACUNIT; ld->executordelay = 0; ld->sidenum[0] = 0xffff; @@ -3123,9 +3148,11 @@ static void P_LoadTextmap(void) mt->extrainfo = 0; mt->tid = 0; mt->scale = FRACUNIT; - memset(mt->args, 0, NUMMAPTHINGARGS*sizeof(*mt->args)); - memset(mt->stringargs, 0x00, NUMMAPTHINGSTRINGARGS*sizeof(*mt->stringargs)); + memset(mt->args, 0, NUM_MAPTHING_ARGS*sizeof(*mt->args)); + memset(mt->stringargs, 0x00, NUM_MAPTHING_STRINGARGS*sizeof(*mt->stringargs)); mt->special = 0; + memset(mt->script_args, 0, NUM_SCRIPT_ARGS*sizeof(*mt->script_args)); + memset(mt->script_stringargs, 0x00, NUM_SCRIPT_STRINGARGS*sizeof(*mt->script_stringargs)); mt->layer = 0; mt->mobj = NULL; diff --git a/src/p_spec.c b/src/p_spec.c index 0d08cdcc0..9e7336a14 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2380,7 +2380,7 @@ void P_ActivateThingSpecial(mobj_t *mo, mobj_t *source) activator->sector = source->subsector->sector; } - P_ProcessSpecial(activator, mo->special, mo->args, mo->stringargs); + P_ProcessSpecial(activator, mo->special, mo->script_args, mo->script_stringargs); P_SetTarget(&activator->mo, NULL); Z_Free(activator); @@ -4363,7 +4363,7 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha if (backwardsCompat) break; - if (args[1] < 0 || args[1] >= NUMLINEARGS) + if (args[1] < 0 || args[1] >= NUM_SCRIPT_ARGS) { CONS_Debug(DBG_GAMELOGIC, "Linedef type 468: Invalid linedef arg %d\n", args[1]); break; @@ -4408,7 +4408,7 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha case 475: // ACS_Execute { - INT32 newArgs[NUMLINEARGS-1] = {0}; + INT32 newArgs[NUM_SCRIPT_ARGS-1] = {0}; INT32 i; if (!stringargs[0]) @@ -4417,17 +4417,17 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha return false; } - for (i = 1; i < NUMLINEARGS; i++) + for (i = 1; i < NUM_SCRIPT_ARGS; i++) { newArgs[i - 1] = args[i]; } - ACS_Execute(stringargs[0], newArgs, NUMLINEARGS-1, activator); + ACS_Execute(stringargs[0], newArgs, NUM_SCRIPT_ARGS-1, activator); } break; case 476: // ACS_ExecuteAlways { - INT32 newArgs[NUMLINEARGS-1] = {0}; + INT32 newArgs[NUM_SCRIPT_ARGS-1] = {0}; INT32 i; if (!stringargs[0]) @@ -4436,12 +4436,12 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha return false; } - for (i = 1; i < NUMLINEARGS; i++) + for (i = 1; i < NUM_SCRIPT_ARGS; i++) { newArgs[i - 1] = args[i]; } - ACS_ExecuteAlways(stringargs[0], newArgs, NUMLINEARGS-1, activator); + ACS_ExecuteAlways(stringargs[0], newArgs, NUM_SCRIPT_ARGS-1, activator); } break; case 477: // ACS_Suspend diff --git a/src/r_defs.h b/src/r_defs.h index 26d0aaaaf..de7f5e499 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -445,9 +445,6 @@ typedef enum CRUMBLE_RESTORE, // Crumble thinker is about to restore to original position } crumblestate_t; -#define NUMSECTORARGS 10 -#define NUMSECTORSTRINGARGS 2 - // // The SECTORS record, at runtime. // Stores things/mobjs. @@ -554,8 +551,8 @@ struct sector_t // Action specials INT16 action; - INT32 args[NUMSECTORARGS]; - char *stringargs[NUMSECTORSTRINGARGS]; + INT32 args[NUM_SCRIPT_ARGS]; + char *stringargs[NUM_SCRIPT_STRINGARGS]; sectoractionflags_t activation; // UDMF user-defined custom properties. @@ -573,10 +570,7 @@ typedef enum ST_NEGATIVE } slopetype_t; -#define HORIZONSPECIAL 41 - -#define NUMLINEARGS 10 -#define NUMLINESTRINGARGS 2 +#define HORIZONSPECIAL (41) struct line_t { @@ -592,8 +586,8 @@ struct line_t UINT32 activation; INT16 special; taglist_t tags; - INT32 args[NUMLINEARGS]; - char *stringargs[NUMLINESTRINGARGS]; + INT32 args[NUM_SCRIPT_ARGS]; + char *stringargs[NUM_SCRIPT_STRINGARGS]; // Visual appearance: sidedefs. UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided From a19311d523c121eb18767b7af28c800eb69b222e Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 19 Aug 2023 06:26:20 -0400 Subject: [PATCH 2/5] Add UDMF version system This is needed to convert maps, since I needed to change thing arguments' variable names... --- src/p_setup.c | 70 +++++++++++++++++++++++++++++++++++++++++++-------- src/r_state.h | 1 + 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 1bc7de070..11bc81cd6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -123,6 +123,7 @@ unsigned char mapmd5[16]; // boolean udmf; +static INT32 udmf_version; size_t numvertexes, numsegs, numsectors, numsubsectors, numnodes, numlines, numsides, nummapthings; size_t num_orig_vertexes; vertex_t *vertexes; @@ -1407,8 +1408,18 @@ static boolean TextmapCount(size_t size) // Check if namespace is valid. tkn = M_TokenizerRead(0); - if (!fastcmp(tkn, "srb2")) // Would like to use "ringracers", but it turns off features in UZB. - CONS_Alert(CONS_WARNING, "Invalid namespace '%s', only 'srb2' is supported.\n", tkn); + if (!fastcmp(tkn, "ringracers")) + CONS_Alert(CONS_WARNING, "Invalid namespace '%s', only 'ringracers' is supported. This map may have issues loading.\n", tkn); + + // Check for version + tkn = M_TokenizerRead(0); + if (fastcmp(tkn, "version")) + { + tkn = M_TokenizerRead(0); + udmf_version = atoi(tkn); + if (udmf_version > UDMF_CURRENT_VERSION) + CONS_Alert(CONS_WARNING, "Map is intended for future UDMF version '%d', current supported version is '%d'. This map may have issues loading.\n", udmf_version, UDMF_CURRENT_VERSION); + } while ((tkn = M_TokenizerRead(0)) && M_TokenizerGetEndPos() < size) { @@ -1954,7 +1965,7 @@ static void ParseTextmapThingParameter(UINT32 i, const char *param, const char * mapthings[i].special = atol(val); else if (fastcmp(param, "foflayer")) mapthings[i].layer = atol(val); - else if (fastncmp(param, "stringarg", 9) && strlen(param) > 9) + else if (fastncmp(param, "stringthingarg", 9) && strlen(param) > 9) { size_t argnum = atol(param + 9); if (argnum >= NUM_MAPTHING_STRINGARGS) @@ -1964,14 +1975,14 @@ static void ParseTextmapThingParameter(UINT32 i, const char *param, const char * M_Memcpy(mapthings[i].stringargs[argnum], val, len); mapthings[i].stringargs[argnum][len] = '\0'; } - else if (fastncmp(param, "arg", 3) && strlen(param) > 3) + else if (fastncmp(param, "thingarg", 3) && strlen(param) > 3) { size_t argnum = atol(param + 3); if (argnum >= NUM_MAPTHING_ARGS) return; mapthings[i].args[argnum] = atol(val); } - else if (fastncmp(param, "scriptstringarg", 15) && strlen(param) > 15) + else if (fastncmp(param, "stringarg", 15) && strlen(param) > 15) { size_t argnum = atol(param + 15); if (argnum >= NUM_SCRIPT_STRINGARGS) @@ -1981,7 +1992,7 @@ static void ParseTextmapThingParameter(UINT32 i, const char *param, const char * M_Memcpy(mapthings[i].script_stringargs[argnum], val, len); mapthings[i].script_stringargs[argnum][len] = '\0'; } - else if (fastncmp(param, "scriptarg", 9) && strlen(param) > 9) + else if (fastncmp(param, "arg", 9) && strlen(param) > 9) { size_t argnum = atol(param + 9); if (argnum >= NUM_SCRIPT_ARGS) @@ -2131,16 +2142,16 @@ static void P_WriteTextmapThing(FILE *f, mapthing_t *wmapthings, size_t i, size_ fprintf(f, "special = %d;\n", wmapthings[i].special); for (j = 0; j < NUM_SCRIPT_ARGS; j++) if (wmapthings[i].script_args[j] != 0) - fprintf(f, "scriptarg%s = %d;\n", sizeu1(j), wmapthings[i].script_args[j]); + fprintf(f, "arg%s = %d;\n", sizeu1(j), wmapthings[i].script_args[j]); for (j = 0; j < NUM_SCRIPT_STRINGARGS; j++) if (mapthings[i].script_stringargs[j]) - fprintf(f, "scriptstringarg%s = \"%s\";\n", sizeu1(j), mapthings[i].script_stringargs[j]); + fprintf(f, "stringarg%s = \"%s\";\n", sizeu1(j), mapthings[i].script_stringargs[j]); for (j = 0; j < NUM_MAPTHING_ARGS; j++) if (wmapthings[i].args[j] != 0) - fprintf(f, "arg%s = %d;\n", sizeu1(j), wmapthings[i].args[j]); + fprintf(f, "thingarg%s = %d;\n", sizeu1(j), wmapthings[i].args[j]); for (j = 0; j < NUM_MAPTHING_STRINGARGS; j++) if (mapthings[i].stringargs[j]) - fprintf(f, "stringarg%s = \"%s\";\n", sizeu1(j), mapthings[i].stringargs[j]); + fprintf(f, "stringthingarg%s = \"%s\";\n", sizeu1(j), mapthings[i].stringargs[j]); if (wmapthings[i].user.length > 0) { for (j = 0; j < wmapthings[i].user.length; j++) @@ -2495,7 +2506,8 @@ static void P_WriteTextmap(void) } } - fprintf(f, "namespace = \"srb2\";\n"); + fprintf(f, "namespace = \"ringracers\";\n"); + fprintf(f, "version = %d;\n", UDMF_CURRENT_VERSION); for (i = k = 0; i < nummapthings; i++) { if (wmapthings[i].type == mobjinfo[MT_WAYPOINT].doomednum @@ -7409,7 +7421,9 @@ static boolean P_LoadMapFromFile(void) { virtlump_t *textmap = vres_Find(curmapvirt, "TEXTMAP"); size_t i; + udmf = textmap != NULL; + udmf_version = 0; if (!P_LoadMapData(curmapvirt)) return false; @@ -7426,6 +7440,40 @@ static boolean P_LoadMapFromFile(void) if (!udmf) P_ConvertBinaryMap(); + if (udmf_version < 1) + { + // version 0 is both binary & older versionless UDMF maps + for (i = 0; i < nummapthings; i++) + { + size_t j; + + for (j = 0; j < min(NUM_MAPTHING_ARGS, NUM_SCRIPT_ARGS); j++) + { + mapthings[i].args[j] = mapthings[i].script_args[j]; + } + + for (j = 0; j < min(NUM_MAPTHING_STRINGARGS, NUM_SCRIPT_STRINGARGS); j++) + { + size_t len = 0; + + if (mapthings[i].script_stringargs[j]) + { + len = strlen(mapthings[i].script_stringargs[j]); + } + + if (len == 0) + { + Z_Free(mapthings[i].stringargs[j]); + mapthings[i].stringargs[j] = NULL; + continue; + } + + mapthings[i].stringargs[j] = Z_Realloc(mapthings[i].stringargs[j], len + 1, PU_LEVEL, NULL); + M_Memcpy(mapthings[i].stringargs[j], mapthings[i].script_stringargs[j], len + 1); + } + } + } + // Copy relevant map data for NetArchive purposes. spawnsectors = Z_Calloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL); spawnlines = Z_Calloc(numlines * sizeof(*lines), PU_LEVEL, NULL); diff --git a/src/r_state.h b/src/r_state.h index 1a9652122..50b53a66f 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -67,6 +67,7 @@ extern size_t numspritelumps, max_spritelumps; // // Lookup tables for map data. // +#define UDMF_CURRENT_VERSION (1) extern boolean udmf; extern size_t numsprites; From 5e607704eb906ee8beb73909a1280285d512dd96 Mon Sep 17 00:00:00 2001 From: Sal Date: Fri, 4 Aug 2023 20:05:35 +0000 Subject: [PATCH 3/5] Make UDMF scale compatible with ZDoom's spec --- src/doomdata.h | 1 + src/lua_mobjlib.c | 4 ++++ src/p_mobj.c | 3 +++ src/p_setup.c | 18 ++++++++++++++++-- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/doomdata.h b/src/doomdata.h index 375635b52..9d3873364 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -270,6 +270,7 @@ struct mapthing_t UINT8 extrainfo; mtag_t tid; fixed_t scale; + fixed_t spritexscale, spriteyscale; INT16 special; INT32 args[NUM_MAPTHING_ARGS]; char *stringargs[NUM_MAPTHING_STRINGARGS]; diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index bc35e0b3a..023f9bd75 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -982,6 +982,10 @@ static int mapthing_get(lua_State *L) number = mt->options; else if(fastcmp(field,"scale")) number = mt->scale; + else if(fastcmp(field,"spritexscale")) + number = mt->spritexscale; + else if(fastcmp(field,"spriteyscale")) + number = mt->spriteyscale; else if(fastcmp(field,"z")) number = mt->z; else if(fastcmp(field,"extrainfo")) diff --git a/src/p_mobj.c b/src/p_mobj.c index f1db29b99..936981bbd 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -13600,6 +13600,9 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, P_SetScale(mobj, FixedMul(mobj->scale, mthing->scale)); mobj->destscale = FixedMul(mobj->destscale, mthing->scale); + mobj->spritexscale = mthing->spritexscale; + mobj->spriteyscale = mthing->spriteyscale; + P_SetThingTID(mobj, mthing->tid); mobj->special = mthing->special; diff --git a/src/p_setup.c b/src/p_setup.c index 11bc81cd6..f06c075f1 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1361,6 +1361,7 @@ static void P_LoadThings(UINT8 *data) mt->extrainfo = (UINT8)(mt->type >> 12); mt->tid = 0; mt->scale = FRACUNIT; + mt->spritexscale = mt->spriteyscale = FRACUNIT; memset(mt->args, 0, NUM_MAPTHING_ARGS*sizeof(*mt->args)); memset(mt->stringargs, 0x00, NUM_MAPTHING_STRINGARGS*sizeof(*mt->stringargs)); mt->special = 0; @@ -1955,7 +1956,13 @@ static void ParseTextmapThingParameter(UINT32 i, const char *param, const char * mapthings[i].roll = atol(val); else if (fastcmp(param, "type")) mapthings[i].type = atol(val); - else if (fastcmp(param, "scale") || fastcmp(param, "scalex") || fastcmp(param, "scaley")) + else if (fastcmp(param, "scale")) + mapthings[i].spritexscale = mapthings[i].spriteyscale = FLOAT_TO_FIXED(atof(val)); + else if (fastcmp(param, "scalex")) + mapthings[i].spritexscale = FLOAT_TO_FIXED(atof(val)); + else if (fastcmp(param, "scaley")) + mapthings[i].spriteyscale = FLOAT_TO_FIXED(atof(val)); + else if (fastcmp(param, "mobjscale")) mapthings[i].scale = FLOAT_TO_FIXED(atof(val)); // Flags else if (fastcmp(param, "flip") && fastcmp("true", val)) @@ -2134,8 +2141,12 @@ static void P_WriteTextmapThing(FILE *f, mapthing_t *wmapthings, size_t i, size_ fprintf(f, "roll = %d;\n", wmapthings[i].roll); if (wmapthings[i].type != 0) fprintf(f, "type = %d;\n", wmapthings[i].type); + if (wmapthings[i].spritexscale != FRACUNIT) + fprintf(f, "scalex = %f;\n", FIXED_TO_FLOAT(wmapthings[i].spritexscale)); + if (wmapthings[i].spriteyscale != FRACUNIT) + fprintf(f, "scaley = %f;\n", FIXED_TO_FLOAT(wmapthings[i].spriteyscale)); if (wmapthings[i].scale != FRACUNIT) - fprintf(f, "scale = %f;\n", FIXED_TO_FLOAT(wmapthings[i].scale)); + fprintf(f, "mobjscale = %f;\n", FIXED_TO_FLOAT(wmapthings[i].scale)); if (wmapthings[i].options & MTF_OBJECTFLIP) fprintf(f, "flip = true;\n"); if (wmapthings[i].special != 0) @@ -3160,6 +3171,7 @@ static void P_LoadTextmap(void) mt->extrainfo = 0; mt->tid = 0; mt->scale = FRACUNIT; + mt->spritexscale = mt->spriteyscale = FRACUNIT; memset(mt->args, 0, NUM_MAPTHING_ARGS*sizeof(*mt->args)); memset(mt->stringargs, 0x00, NUM_MAPTHING_STRINGARGS*sizeof(*mt->stringargs)); mt->special = 0; @@ -7447,6 +7459,8 @@ static boolean P_LoadMapFromFile(void) { size_t j; + mapthings[i].scale = max(mapthings[i].spritexscale, mapthings[i].spriteyscale); + for (j = 0; j < min(NUM_MAPTHING_ARGS, NUM_SCRIPT_ARGS); j++) { mapthings[i].args[j] = mapthings[i].script_args[j]; From 7dc65dd3a94ef540805f2ec48d5df905c9dd8829 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 19 Aug 2023 06:59:22 -0400 Subject: [PATCH 4/5] Allow writetextmap outside of binary maps This allows for using -writetextmap as a conversion method for old version maps, while the editor does not have it. --- src/p_setup.c | 452 +++++++++++++++++++++++++------------------------- 1 file changed, 229 insertions(+), 223 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index f06c075f1..0da408a0b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2285,235 +2285,238 @@ static void P_WriteTextmap(void) } } - freetag = Tag_NextUnused(0); - - for (i = 0; i < nummapthings; i++) + if (!udmf) { - subsector_t *ss; - INT32 s; + freetag = Tag_NextUnused(0); - if (wmapthings[i].type != 751 && wmapthings[i].type != 752 && wmapthings[i].type != 758) - continue; - - ss = R_PointInSubsector(wmapthings[i].x << FRACBITS, wmapthings[i].y << FRACBITS); - - if (!ss) - continue; - - s = ss->sector - sectors; - - switch (wmapthings[i].type) + for (i = 0; i < nummapthings; i++) { - case 751: - if (!specialthings[s].teleport) - specialthings[s].teleport = &wmapthings[i]; - break; - case 752: - if (!specialthings[s].altview) - specialthings[s].altview = &wmapthings[i]; - break; - case 758: - if (!specialthings[s].angleanchor) - specialthings[s].angleanchor = &wmapthings[i]; - break; - default: - break; + subsector_t *ss; + INT32 s; + + if (wmapthings[i].type != 751 && wmapthings[i].type != 752 && wmapthings[i].type != 758) + continue; + + ss = R_PointInSubsector(wmapthings[i].x << FRACBITS, wmapthings[i].y << FRACBITS); + + if (!ss) + continue; + + s = ss->sector - sectors; + + switch (wmapthings[i].type) + { + case 751: + if (!specialthings[s].teleport) + specialthings[s].teleport = &wmapthings[i]; + break; + case 752: + if (!specialthings[s].altview) + specialthings[s].altview = &wmapthings[i]; + break; + case 758: + if (!specialthings[s].angleanchor) + specialthings[s].angleanchor = &wmapthings[i]; + break; + default: + break; + } } - } - for (i = 0; i < numlines; i++) - { - INT32 s; - - switch (wlines[i].special) + for (i = 0; i < numlines; i++) { - case 1: - TAG_ITER_SECTORS(Tag_FGet(&wlines[i].tags), s) - { - CONS_Alert(CONS_WARNING, M_GetText("Linedef %s applies custom gravity to sector %d. Changes to this gravity at runtime will not be reflected in the converted map. Use linedef type 469 for this.\n"), sizeu1(i), s); - wsectors[s].gravity = FixedDiv(lines[i].frontsector->floorheight >> FRACBITS, 1000); - } - break; - case 2: - CONS_Alert(CONS_WARNING, M_GetText("Custom exit linedef %s detected. Changes to the next map at runtime will not be reflected in the converted map. Use linedef type 468 for this.\n"), sizeu1(i)); - wlines[i].args[0] = lines[i].frontsector->floorheight >> FRACBITS; - wlines[i].args[2] = lines[i].frontsector->ceilingheight >> FRACBITS; - break; - case 5: - case 50: - case 51: - CONS_Alert(CONS_WARNING, M_GetText("Linedef %s has type %d, which is not supported in UDMF.\n"), sizeu1(i), wlines[i].special); - break; - case 61: - if (wlines[i].flags & ML_MIDSOLID) - continue; - if (!wlines[i].args[1]) - continue; - CONS_Alert(CONS_WARNING, M_GetText("Linedef %s with crusher type 61 rises twice as fast on spawn. This behavior is not supported in UDMF.\n"), sizeu1(i)); - break; - case 76: - if (freetag == (mtag_t)MAXTAGS) - { - CONS_Alert(CONS_WARNING, M_GetText("No unused tag found. Linedef %s with type 76 cannot be converted.\n"), sizeu1(i)); - break; - } - TAG_ITER_SECTORS(wlines[i].args[0], s) - for (j = 0; (unsigned)j < wsectors[s].linecount; j++) - { - line_t *line = wsectors[s].lines[j] - lines + wlines; - if (line->special < 100 || line->special >= 300) - continue; - Tag_Add(&line->tags, freetag); - } - wlines[i].args[0] = freetag; - freetag = Tag_NextUnused(freetag); - break; - case 259: - if (wlines[i].args[3] & FOF_QUICKSAND) - CONS_Alert(CONS_WARNING, M_GetText("Quicksand properties of custom FOF on linedef %s cannot be converted. Use linedef type 75 instead.\n"), sizeu1(i)); - if (wlines[i].args[3] & FOF_BUSTUP) - CONS_Alert(CONS_WARNING, M_GetText("Bustable properties of custom FOF on linedef %s cannot be converted. Use linedef type 74 instead.\n"), sizeu1(i)); - break; - case 412: - if ((s = Tag_Iterate_Sectors(wlines[i].args[0], 0)) < 0) - break; - if (!specialthings[s].teleport) - break; - if (freetag == (mtag_t)MAXTAGS) - { - CONS_Alert(CONS_WARNING, M_GetText("No unused tag found. Linedef %s with type 412 cannot be converted.\n"), sizeu1(i)); - break; - } - specialthings[s].teleport->tid = freetag; - wlines[i].args[0] = freetag; - freetag = Tag_NextUnused(freetag); - break; - case 422: - if ((s = Tag_Iterate_Sectors(wlines[i].args[0], 0)) < 0) - break; - if (!specialthings[s].altview) - break; - if (freetag == (mtag_t)MAXTAGS) - { - CONS_Alert(CONS_WARNING, M_GetText("No unused tag found. Linedef %s with type 422 cannot be converted.\n"), sizeu1(i)); - break; - } - specialthings[s].altview->tid = freetag; - wlines[i].args[0] = freetag; - specialthings[s].altview->pitch = wlines[i].args[2]; - freetag = Tag_NextUnused(freetag); - break; - case 447: - CONS_Alert(CONS_WARNING, M_GetText("Linedef %s has change colormap action, which cannot be converted automatically. Tag arg0 to a sector with the desired colormap.\n"), sizeu1(i)); - if (wlines[i].flags & ML_TFERLINE) - CONS_Alert(CONS_WARNING, M_GetText("Linedef %s mixes front and back colormaps, which is not supported in UDMF. Copy one colormap to the target sector first, then mix in the second one.\n"), sizeu1(i)); - break; - case 455: - CONS_Alert(CONS_WARNING, M_GetText("Linedef %s has fade colormap action, which cannot be converted automatically. Tag arg0 to a sector with the desired colormap.\n"), sizeu1(i)); - if (wlines[i].flags & ML_TFERLINE) - CONS_Alert(CONS_WARNING, M_GetText("Linedef %s specifies starting colormap for the fade, which is not supported in UDMF. Change the colormap with linedef type 447 instead.\n"), sizeu1(i)); - break; - case 457: - if ((s = Tag_Iterate_Sectors(wlines[i].args[0], 0)) < 0) - break; - if (!specialthings[s].angleanchor) - break; - if (freetag == (mtag_t)MAXTAGS) - { - CONS_Alert(CONS_WARNING, M_GetText("No unused tag found. Linedef %s with type 457 cannot be converted.\n"), sizeu1(i)); - break; - } - specialthings[s].angleanchor->tid = freetag; - wlines[i].args[0] = freetag; - freetag = Tag_NextUnused(freetag); - break; - case 606: - if (wlines[i].args[0] == MTAG_GLOBAL) - { - sector_t *sec = wlines[i].frontsector - sectors + wsectors; - sec->extra_colormap = wsides[wlines[i].sidenum[0]].colormap_data; - } - else - { - TAG_ITER_SECTORS(wlines[i].args[0], s) - { - if (wsectors[s].colormap_protected) - continue; + INT32 s; - wsectors[s].extra_colormap = wsides[wlines[i].sidenum[0]].colormap_data; - if (freetag == (mtag_t)MAXTAGS) - { - CONS_Alert(CONS_WARNING, M_GetText("No unused tag found. Linedef %s with type 606 cannot be converted.\n"), sizeu1(i)); - break; - } - Tag_Add(&wsectors[s].tags, freetag); - wlines[i].args[1] = freetag; - freetag = Tag_NextUnused(freetag); + switch (wlines[i].special) + { + case 1: + TAG_ITER_SECTORS(Tag_FGet(&wlines[i].tags), s) + { + CONS_Alert(CONS_WARNING, M_GetText("Linedef %s applies custom gravity to sector %d. Changes to this gravity at runtime will not be reflected in the converted map. Use linedef type 469 for this.\n"), sizeu1(i), s); + wsectors[s].gravity = FixedDiv(lines[i].frontsector->floorheight >> FRACBITS, 1000); + } + break; + case 2: + CONS_Alert(CONS_WARNING, M_GetText("Custom exit linedef %s detected. Changes to the next map at runtime will not be reflected in the converted map. Use linedef type 468 for this.\n"), sizeu1(i)); + wlines[i].args[0] = lines[i].frontsector->floorheight >> FRACBITS; + wlines[i].args[2] = lines[i].frontsector->ceilingheight >> FRACBITS; + break; + case 5: + case 50: + case 51: + CONS_Alert(CONS_WARNING, M_GetText("Linedef %s has type %d, which is not supported in UDMF.\n"), sizeu1(i), wlines[i].special); + break; + case 61: + if (wlines[i].flags & ML_MIDSOLID) + continue; + if (!wlines[i].args[1]) + continue; + CONS_Alert(CONS_WARNING, M_GetText("Linedef %s with crusher type 61 rises twice as fast on spawn. This behavior is not supported in UDMF.\n"), sizeu1(i)); + break; + case 76: + if (freetag == (mtag_t)MAXTAGS) + { + CONS_Alert(CONS_WARNING, M_GetText("No unused tag found. Linedef %s with type 76 cannot be converted.\n"), sizeu1(i)); break; } - } - break; - default: - break; + TAG_ITER_SECTORS(wlines[i].args[0], s) + for (j = 0; (unsigned)j < wsectors[s].linecount; j++) + { + line_t *line = wsectors[s].lines[j] - lines + wlines; + if (line->special < 100 || line->special >= 300) + continue; + Tag_Add(&line->tags, freetag); + } + wlines[i].args[0] = freetag; + freetag = Tag_NextUnused(freetag); + break; + case 259: + if (wlines[i].args[3] & FOF_QUICKSAND) + CONS_Alert(CONS_WARNING, M_GetText("Quicksand properties of custom FOF on linedef %s cannot be converted. Use linedef type 75 instead.\n"), sizeu1(i)); + if (wlines[i].args[3] & FOF_BUSTUP) + CONS_Alert(CONS_WARNING, M_GetText("Bustable properties of custom FOF on linedef %s cannot be converted. Use linedef type 74 instead.\n"), sizeu1(i)); + break; + case 412: + if ((s = Tag_Iterate_Sectors(wlines[i].args[0], 0)) < 0) + break; + if (!specialthings[s].teleport) + break; + if (freetag == (mtag_t)MAXTAGS) + { + CONS_Alert(CONS_WARNING, M_GetText("No unused tag found. Linedef %s with type 412 cannot be converted.\n"), sizeu1(i)); + break; + } + specialthings[s].teleport->tid = freetag; + wlines[i].args[0] = freetag; + freetag = Tag_NextUnused(freetag); + break; + case 422: + if ((s = Tag_Iterate_Sectors(wlines[i].args[0], 0)) < 0) + break; + if (!specialthings[s].altview) + break; + if (freetag == (mtag_t)MAXTAGS) + { + CONS_Alert(CONS_WARNING, M_GetText("No unused tag found. Linedef %s with type 422 cannot be converted.\n"), sizeu1(i)); + break; + } + specialthings[s].altview->tid = freetag; + wlines[i].args[0] = freetag; + specialthings[s].altview->pitch = wlines[i].args[2]; + freetag = Tag_NextUnused(freetag); + break; + case 447: + CONS_Alert(CONS_WARNING, M_GetText("Linedef %s has change colormap action, which cannot be converted automatically. Tag arg0 to a sector with the desired colormap.\n"), sizeu1(i)); + if (wlines[i].flags & ML_TFERLINE) + CONS_Alert(CONS_WARNING, M_GetText("Linedef %s mixes front and back colormaps, which is not supported in UDMF. Copy one colormap to the target sector first, then mix in the second one.\n"), sizeu1(i)); + break; + case 455: + CONS_Alert(CONS_WARNING, M_GetText("Linedef %s has fade colormap action, which cannot be converted automatically. Tag arg0 to a sector with the desired colormap.\n"), sizeu1(i)); + if (wlines[i].flags & ML_TFERLINE) + CONS_Alert(CONS_WARNING, M_GetText("Linedef %s specifies starting colormap for the fade, which is not supported in UDMF. Change the colormap with linedef type 447 instead.\n"), sizeu1(i)); + break; + case 457: + if ((s = Tag_Iterate_Sectors(wlines[i].args[0], 0)) < 0) + break; + if (!specialthings[s].angleanchor) + break; + if (freetag == (mtag_t)MAXTAGS) + { + CONS_Alert(CONS_WARNING, M_GetText("No unused tag found. Linedef %s with type 457 cannot be converted.\n"), sizeu1(i)); + break; + } + specialthings[s].angleanchor->tid = freetag; + wlines[i].args[0] = freetag; + freetag = Tag_NextUnused(freetag); + break; + case 606: + if (wlines[i].args[0] == MTAG_GLOBAL) + { + sector_t *sec = wlines[i].frontsector - sectors + wsectors; + sec->extra_colormap = wsides[wlines[i].sidenum[0]].colormap_data; + } + else + { + TAG_ITER_SECTORS(wlines[i].args[0], s) + { + if (wsectors[s].colormap_protected) + continue; + + wsectors[s].extra_colormap = wsides[wlines[i].sidenum[0]].colormap_data; + if (freetag == (mtag_t)MAXTAGS) + { + CONS_Alert(CONS_WARNING, M_GetText("No unused tag found. Linedef %s with type 606 cannot be converted.\n"), sizeu1(i)); + break; + } + Tag_Add(&wsectors[s].tags, freetag); + wlines[i].args[1] = freetag; + freetag = Tag_NextUnused(freetag); + break; + } + } + break; + default: + break; + } + + if (wlines[i].special >= 300 && wlines[i].special < 400) + { + CONS_Alert(CONS_WARNING, M_GetText("Linedef %s is a linedef executor, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); + wlines[i].special = 0; + } + + if (wlines[i].executordelay != 0) + { + CONS_Alert(CONS_WARNING, M_GetText("Linedef %s has an linedef executor delay, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); + } } - if (wlines[i].special >= 300 && wlines[i].special < 400) + for (i = 0; i < numsectors; i++) { - CONS_Alert(CONS_WARNING, M_GetText("Linedef %s is a linedef executor, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); - wlines[i].special = 0; - } + if (Tag_Find(&wsectors[i].tags, LE_CAPSULE0)) + CONS_Alert(CONS_WARNING, M_GetText("Sector %s has reserved tag %d, which is not supported in UDMF. Use arg3 of the boss mapthing instead.\n"), sizeu1(i), LE_CAPSULE0); + if (Tag_Find(&wsectors[i].tags, LE_CAPSULE1)) + CONS_Alert(CONS_WARNING, M_GetText("Sector %s has reserved tag %d, which is not supported in UDMF. Use arg3 of the boss mapthing instead.\n"), sizeu1(i), LE_CAPSULE1); + if (Tag_Find(&wsectors[i].tags, LE_CAPSULE2)) + CONS_Alert(CONS_WARNING, M_GetText("Sector %s has reserved tag %d, which is not supported in UDMF. Use arg3 of the boss mapthing instead.\n"), sizeu1(i), LE_CAPSULE2); - if (wlines[i].executordelay != 0) - { - CONS_Alert(CONS_WARNING, M_GetText("Linedef %s has an linedef executor delay, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); - } - } + switch (GETSECSPECIAL(wsectors[i].special, 1)) + { + case 9: + case 10: + CONS_Alert(CONS_WARNING, M_GetText("Sector %s has ring drainer effect, which is not supported in UDMF. Use action 460 instead.\n"), sizeu1(i)); + break; + default: + break; + } - for (i = 0; i < numsectors; i++) - { - if (Tag_Find(&wsectors[i].tags, LE_CAPSULE0)) - CONS_Alert(CONS_WARNING, M_GetText("Sector %s has reserved tag %d, which is not supported in UDMF. Use arg3 of the boss mapthing instead.\n"), sizeu1(i), LE_CAPSULE0); - if (Tag_Find(&wsectors[i].tags, LE_CAPSULE1)) - CONS_Alert(CONS_WARNING, M_GetText("Sector %s has reserved tag %d, which is not supported in UDMF. Use arg3 of the boss mapthing instead.\n"), sizeu1(i), LE_CAPSULE1); - if (Tag_Find(&wsectors[i].tags, LE_CAPSULE2)) - CONS_Alert(CONS_WARNING, M_GetText("Sector %s has reserved tag %d, which is not supported in UDMF. Use arg3 of the boss mapthing instead.\n"), sizeu1(i), LE_CAPSULE2); + switch (GETSECSPECIAL(wsectors[i].special, 2)) + { + case 6: + CONS_Alert(CONS_WARNING, M_GetText("Sector %s has emerald check trigger type, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); + break; + case 7: + CONS_Alert(CONS_WARNING, M_GetText("Sector %s has NiGHTS mare trigger type, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); + break; + case 9: + CONS_Alert(CONS_WARNING, M_GetText("Sector %s has Egg Capsule type, which is not supported in UDMF. Use action 464 instead.\n"), sizeu1(i)); + break; + default: + break; + } - switch (GETSECSPECIAL(wsectors[i].special, 1)) - { - case 9: - case 10: - CONS_Alert(CONS_WARNING, M_GetText("Sector %s has ring drainer effect, which is not supported in UDMF. Use action 460 instead.\n"), sizeu1(i)); - break; - default: - break; - } - - switch (GETSECSPECIAL(wsectors[i].special, 2)) - { - case 6: - CONS_Alert(CONS_WARNING, M_GetText("Sector %s has emerald check trigger type, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); - break; - case 7: - CONS_Alert(CONS_WARNING, M_GetText("Sector %s has NiGHTS mare trigger type, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); - break; - case 9: - CONS_Alert(CONS_WARNING, M_GetText("Sector %s has Egg Capsule type, which is not supported in UDMF. Use action 464 instead.\n"), sizeu1(i)); - break; - default: - break; - } - - if (wsectors[i].triggertag) - { - CONS_Alert(CONS_WARNING, M_GetText("Sector %s uses a linedef executor trigger tag, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); - } - if (wsectors[i].triggerer) - { - CONS_Alert(CONS_WARNING, M_GetText("Sector %s uses a linedef executor trigger effect, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); - } - if ((wsectors[i].flags & (MSF_TRIGGERLINE_PLANE|MSF_TRIGGERLINE_MOBJ)) != 0) - { - CONS_Alert(CONS_WARNING, M_GetText("Sector %s uses a linedef executor trigger flag, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); + if (wsectors[i].triggertag) + { + CONS_Alert(CONS_WARNING, M_GetText("Sector %s uses a linedef executor trigger tag, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); + } + if (wsectors[i].triggerer) + { + CONS_Alert(CONS_WARNING, M_GetText("Sector %s uses a linedef executor trigger effect, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); + } + if ((wsectors[i].flags & (MSF_TRIGGERLINE_PLANE|MSF_TRIGGERLINE_MOBJ)) != 0) + { + CONS_Alert(CONS_WARNING, M_GetText("Sector %s uses a linedef executor trigger flag, which is not supported in UDMF. Use ACS instead.\n"), sizeu1(i)); + } } } @@ -2521,13 +2524,16 @@ static void P_WriteTextmap(void) fprintf(f, "version = %d;\n", UDMF_CURRENT_VERSION); for (i = k = 0; i < nummapthings; i++) { - if (wmapthings[i].type == mobjinfo[MT_WAYPOINT].doomednum - || wmapthings[i].type == mobjinfo[MT_WAYPOINT_ANCHOR].doomednum - || wmapthings[i].type == mobjinfo[MT_WAYPOINT_RISER].doomednum) + if (!udmf) { - // Skip waypoints. Because the multi-thing setup was merged into a - // single thing type in UDMF, these must be converted later. - continue; + if (wmapthings[i].type == mobjinfo[MT_WAYPOINT].doomednum + || wmapthings[i].type == mobjinfo[MT_WAYPOINT_ANCHOR].doomednum + || wmapthings[i].type == mobjinfo[MT_WAYPOINT_RISER].doomednum) + { + // Skip waypoints. Because the multi-thing setup was merged into a + // single thing type in UDMF, these must be converted later. + continue; + } } P_WriteTextmapThing(f, wmapthings, i, k); @@ -7362,9 +7368,6 @@ static void P_ConvertBinaryMap(void) P_ConvertBinarySectorTypes(); P_ConvertBinaryThingTypes(); P_ConvertBinaryLinedefFlags(); - - if (M_CheckParm("-writetextmap")) - P_WriteTextmap(); } /** Compute MD5 message digest for bytes read from memory source @@ -7488,6 +7491,9 @@ static boolean P_LoadMapFromFile(void) } } + if (M_CheckParm("-writetextmap")) + P_WriteTextmap(); + // Copy relevant map data for NetArchive purposes. spawnsectors = Z_Calloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL); spawnlines = Z_Calloc(numlines * sizeof(*lines), PU_LEVEL, NULL); From bd1f0e62161a265931fc972cc4a6d4fb1ba95da0 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 19 Aug 2023 07:21:23 -0400 Subject: [PATCH 5/5] Unset mapthing spritex/yscale when converting old maps --- src/p_setup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_setup.c b/src/p_setup.c index 0da408a0b..e6b6423d2 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -7463,6 +7463,7 @@ static boolean P_LoadMapFromFile(void) size_t j; mapthings[i].scale = max(mapthings[i].spritexscale, mapthings[i].spriteyscale); + mapthings[i].spritexscale = mapthings[i].spriteyscale = FRACUNIT; for (j = 0; j < min(NUM_MAPTHING_ARGS, NUM_SCRIPT_ARGS); j++) {