diff --git a/src/acs/call-funcs.cpp b/src/acs/call-funcs.cpp index b122c9943..f70fecc3e 100644 --- a/src/acs/call-funcs.cpp +++ b/src/acs/call-funcs.cpp @@ -1064,7 +1064,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 bfa296485..f2bf53743 100644 --- a/src/acs/environment.cpp +++ b/src/acs/environment.cpp @@ -303,13 +303,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]); } @@ -327,7 +327,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]); @@ -335,7 +335,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..32cc1e9db 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. @@ -263,9 +270,12 @@ struct mapthing_t UINT8 extrainfo; mtag_t tid; fixed_t scale; + fixed_t spritexscale, spriteyscale; + INT32 thing_args[NUM_MAPTHING_ARGS]; + char *thing_stringargs[NUM_MAPTHING_STRINGARGS]; INT16 special; - INT32 args[NUMMAPTHINGARGS]; - char *stringargs[NUMMAPTHINGSTRINGARGS]; + 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/g_demo.c b/src/g_demo.c index 7bb98fdbc..5bcee7d48 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -3768,7 +3768,7 @@ void G_AddGhost(savebuffer_t *buffer, char *defdemoname) gh->mo->angle = FixedAngle(mthing->angle << FRACBITS); f = gh->mo->floorz; c = gh->mo->ceilingz - mobjinfo[MT_PLAYER].height; - if (!!(mthing->args[0]) ^ !!(mthing->options & MTF_OBJECTFLIP)) + if (!!(mthing->thing_args[0]) ^ !!(mthing->options & MTF_OBJECTFLIP)) { z = c - offset; if (z < f) diff --git a/src/k_battle.c b/src/k_battle.c index 4daa5afe4..7020e7fcf 100644 --- a/src/k_battle.c +++ b/src/k_battle.c @@ -712,10 +712,10 @@ void K_RunBattleOvertime(void) void K_SetupMovingCapsule(mapthing_t *mt, mobj_t *mobj) { - UINT8 sequence = mt->args[0] - 1; - fixed_t speed = (FRACUNIT >> 3) * mt->args[1]; - boolean backandforth = (mt->args[2] & TMBCF_BACKANDFORTH); - boolean reverse = (mt->args[2] & TMBCF_REVERSE); + UINT8 sequence = mt->thing_args[0] - 1; + fixed_t speed = (FRACUNIT >> 3) * mt->thing_args[1]; + boolean backandforth = (mt->thing_args[2] & TMBCF_BACKANDFORTH); + boolean reverse = (mt->thing_args[2] & TMBCF_REVERSE); mobj_t *target = NULL; // Find the inital target diff --git a/src/k_kart.c b/src/k_kart.c index 08e80e2cf..193da3181 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -77,7 +77,7 @@ boolean K_IsDuelItem(mobjtype_t type) boolean K_DuelItemAlwaysSpawns(mapthing_t *mt) { - return !!(mt->args[0]); + return !!(mt->thing_args[0]); } static void K_SpawnDuelOnlyItems(void) @@ -122,14 +122,14 @@ static void K_SpawnItemCapsules(void) continue; } - isRingCapsule = (mt->args[0] < 1 || mt->args[0] == KITEM_SUPERRING || mt->args[0] >= NUMKARTITEMS); + isRingCapsule = (mt->thing_args[0] < 1 || mt->thing_args[0] == KITEM_SUPERRING || mt->thing_args[0] >= NUMKARTITEMS); if (isRingCapsule == true && ((gametyperules & GTR_SPHERES) || (modeattacking & ATTACKING_SPB))) { // don't spawn ring capsules in ringless gametypes continue; } - modeFlags = mt->args[3]; + modeFlags = mt->thing_args[3]; if (modeFlags == TMICM_DEFAULT) { if (isRingCapsule == true) diff --git a/src/k_waypoint.cpp b/src/k_waypoint.cpp index cab010095..127cee7a0 100644 --- a/src/k_waypoint.cpp +++ b/src/k_waypoint.cpp @@ -2399,7 +2399,7 @@ static boolean K_AnchorWaypointRadius( anchor->x, anchor->y); // Keep changes for -writetextmap - waypointmobj->spawnpoint->args[1] = waypointmobj->radius >> FRACBITS; + waypointmobj->spawnpoint->thing_args[1] = waypointmobj->radius >> FRACBITS; return true; } else 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..ce4668038 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -488,10 +488,10 @@ static int mobj_get(lua_State *L) lua_pushinteger(L, mo->special); break; case mobj_args: - LUA_PushUserdata(L, mo->args, META_THINGARGS); + LUA_PushUserdata(L, mo->thing_args, META_THINGARGS); break; case mobj_stringargs: - LUA_PushUserdata(L, mo->stringargs, META_THINGSTRINGARGS); + LUA_PushUserdata(L, mo->thing_stringargs, META_THINGSTRINGARGS); break; default: // extra custom variables in Lua memory lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); @@ -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; } @@ -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")) @@ -992,12 +996,12 @@ static int mapthing_get(lua_State *L) number = mt->special; else if(fastcmp(field,"args")) { - LUA_PushUserdata(L, mt->args, META_THINGARGS); + LUA_PushUserdata(L, mt->thing_args, META_THINGARGS); return 1; } else if(fastcmp(field,"stringargs")) { - LUA_PushUserdata(L, mt->stringargs, META_THINGSTRINGARGS); + LUA_PushUserdata(L, mt->thing_stringargs, META_THINGSTRINGARGS); return 1; } else if(fastcmp(field,"mobj")) { diff --git a/src/lua_script.c b/src/lua_script.c index ee0a5f5ba..f9e316b50 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -900,8 +900,8 @@ void LUA_InvalidateMapthings(void) for (i = 0; i < nummapthings; i++) { LUA_InvalidateUserdata(&mapthings[i]); - LUA_InvalidateUserdata(mapthings[i].args); - LUA_InvalidateUserdata(mapthings[i].stringargs); + LUA_InvalidateUserdata(mapthings[i].thing_args); + LUA_InvalidateUserdata(mapthings[i].thing_stringargs); } } diff --git a/src/m_cheat.c b/src/m_cheat.c index ecfb9a79c..081987198 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->thing_args, 0, NUM_MAPTHING_ARGS*sizeof(*mt->thing_args)); + memset(mt->thing_stringargs, 0x00, NUM_MAPTHING_STRINGARGS*sizeof(*mt->thing_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/objects/ark-arrow.c b/src/objects/ark-arrow.c index 4784dfb45..c514bc664 100644 --- a/src/objects/ark-arrow.c +++ b/src/objects/ark-arrow.c @@ -16,7 +16,7 @@ void Obj_ArkArrowSpawn(mobj_t *mobj) void Obj_ArkArrowSetup(mobj_t *mobj, mapthing_t *mthing) { const fixed_t oldHeight = mobj->height; - statenum_t stateNum = mobj->info->spawnstate + mthing->args[0]; + statenum_t stateNum = mobj->info->spawnstate + mthing->thing_args[0]; if (stateNum - mobj->info->spawnstate >= ARKARROW_OPTIONS) { diff --git a/src/objects/audience.c b/src/objects/audience.c index a43dbcc94..f1c1a0131 100644 --- a/src/objects/audience.c +++ b/src/objects/audience.c @@ -38,10 +38,10 @@ Obj_AudienceInit // Pick follower if (mthing != NULL) { - if (mthing->stringargs[0] != NULL) + if (mthing->thing_stringargs[0] != NULL) { // From mapthing - char *stringcopy = Z_StrDup(mthing->stringargs[0]); + char *stringcopy = Z_StrDup(mthing->thing_stringargs[0]); char *tok = strtok(stringcopy, " ,"); char *c; // for erasing underscores @@ -141,15 +141,15 @@ Obj_AudienceInit { UINT16 colorpick = SKINCOLOR_NONE; - if (mthing->stringargs[1] != NULL) + if (mthing->thing_stringargs[1] != NULL) { - if (!stricmp("Random", mthing->stringargs[1])) + if (!stricmp("Random", mthing->thing_stringargs[1])) { colorpick = FOLLOWERCOLOR_MATCH; } else { - char *stringcopy = Z_StrDup(mthing->stringargs[1]); + char *stringcopy = Z_StrDup(mthing->thing_stringargs[1]); char *tok = strtok(stringcopy, " "); numref = 0; diff --git a/src/objects/battle-ufo.cpp b/src/objects/battle-ufo.cpp index ea53e2bf8..2ccbb78da 100644 --- a/src/objects/battle-ufo.cpp +++ b/src/objects/battle-ufo.cpp @@ -14,7 +14,7 @@ #define BATTLEUFO_BOB_AMP (4) // UFO bob strength #define BATTLEUFO_BOB_SPEED (TICRATE*2) // UFO bob speed -#define spawner_id(o) ((o)->args[0]) +#define spawner_id(o) ((o)->thing_args[0]) #define ufo_spawner(o) ((o)->target) diff --git a/src/objects/dash-rings.c b/src/objects/dash-rings.c index cf3986abe..527157cb1 100644 --- a/src/objects/dash-rings.c +++ b/src/objects/dash-rings.c @@ -67,10 +67,10 @@ void Obj_RainbowDashRingSpawn(mobj_t *mobj) void Obj_DashRingSetup(mobj_t *mobj, mapthing_t *mthing) { static const UINT8 numColors = sizeof(rainbow_colors) / sizeof(skincolornum_t); - const UINT8 additionalThrust = mthing->args[1]; + const UINT8 additionalThrust = mthing->thing_args[1]; statenum_t ringState, overlayState; - mobj->extravalue1 = mthing->args[0]; + mobj->extravalue1 = mthing->thing_args[0]; mobj->cusval = 4 + additionalThrust; switch (mobj->extravalue1) diff --git a/src/objects/loops.c b/src/objects/loops.c index fab1033e1..21d67c12f 100644 --- a/src/objects/loops.c +++ b/src/objects/loops.c @@ -178,8 +178,8 @@ Obj_InitLoopEndpoint void Obj_InitLoopCenter (mobj_t *center) { - center_max_revolution(center) = center->args[1] * FRACUNIT / 360; - center_set_flip(center, center->args[0]); + center_max_revolution(center) = center->thing_args[1] * FRACUNIT / 360; + center_set_flip(center, center->thing_args[0]); } void diff --git a/src/p_enemy.c b/src/p_enemy.c index 5e82b57dd..5f29bf333 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3435,7 +3435,7 @@ static void P_DoBossVictory(mobj_t *mo) } // victory! - P_LinedefExecute(mo->args[3], mo, NULL); + P_LinedefExecute(mo->thing_args[3], mo, NULL); if (stoppedclock && modeattacking) // if you're just time attacking, skip making the capsule appear since you don't need to step on it anyways. return; @@ -3459,7 +3459,7 @@ static void P_DoBossVictory(mobj_t *mo) static void P_DoBossDefaultDeath(mobj_t *mo) { - INT32 bossid = mo->args[0]; + INT32 bossid = mo->thing_args[0]; // Stop exploding and prepare to run. P_SetMobjState(mo, mo->info->xdeathstate); @@ -3504,7 +3504,7 @@ void A_BossDeath(mobj_t *mo) if (LUA_CallAction(A_BOSSDEATH, mo)) return; - P_LinedefExecute(mo->args[2], mo, NULL); + P_LinedefExecute(mo->thing_args[2], mo, NULL); mo->health = 0; // Boss is dead (but not necessarily fleeing...) @@ -4079,8 +4079,8 @@ void A_FishJump(mobj_t *actor) jumpval = locvar1; else { - if (actor->args[0]) - jumpval = actor->args[0]; + if (actor->thing_args[0]) + jumpval = actor->thing_args[0]; else jumpval = 44; } @@ -5089,16 +5089,16 @@ void A_RockSpawn(mobj_t *actor) if (LUA_CallAction(A_ROCKSPAWN, actor)) return; - type = actor->stringargs[0] ? get_number(actor->stringargs[0]) : MT_ROCKCRUMBLE1; + type = actor->thing_stringargs[0] ? get_number(actor->thing_stringargs[0]) : MT_ROCKCRUMBLE1; if (type < MT_NULL || type >= NUMMOBJTYPES) { - CONS_Debug(DBG_GAMELOGIC, "A_RockSpawn: Invalid mobj type %s!\n", actor->stringargs[0]); + CONS_Debug(DBG_GAMELOGIC, "A_RockSpawn: Invalid mobj type %s!\n", actor->thing_stringargs[0]); return; } - dist = max(actor->args[0] << (FRACBITS - 4), 1); - if (actor->args[2]) + dist = max(actor->thing_args[0] << (FRACBITS - 4), 1); + if (actor->thing_args[2]) dist += P_RandomByte(PR_UNDEFINED) * (FRACUNIT/32); // random oomph mo = P_SpawnMobj(actor->x, actor->y, actor->z, MT_FALLINGROCK); @@ -5108,7 +5108,7 @@ void A_RockSpawn(mobj_t *actor) P_InstaThrust(mo, mo->angle, dist); mo->momz = dist; - var1 = actor->args[1]; + var1 = actor->thing_args[1]; A_SetTics(actor); } @@ -5770,7 +5770,7 @@ void A_Boss1Chase(mobj_t *actor) } else { - P_LinedefExecute(actor->args[4], actor, NULL); + P_LinedefExecute(actor->thing_args[4], actor, NULL); P_SetMobjState(actor, actor->info->raisestate); } @@ -6467,7 +6467,7 @@ void A_GuardChase(mobj_t *actor) false, NULL) && speed > 0) // can't be the same check as previous so that P_TryMove gets to happen. { - INT32 direction = actor->args[0]; + INT32 direction = actor->thing_args[0]; switch (direction) { @@ -6734,7 +6734,7 @@ void A_Boss3Path(mobj_t *actor) continue; if (mo2->type != MT_BOSS3WAYPOINT) continue; - if (mapthings[i].args[0] != actor->threshold) + if (mapthings[i].thing_args[0] != actor->threshold) continue; P_SetTarget(&actor->target, mo2); @@ -6902,13 +6902,13 @@ 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; } - tagnum = actor->args[locvar1]; + tagnum = actor->thing_args[locvar1]; CONS_Debug(DBG_GAMELOGIC, "A_LinedefExecuteFromArg: Running mobjtype %d's sector with tag %d\n", actor->type, tagnum); @@ -7927,7 +7927,7 @@ void A_StateRangeByParameter(mobj_t *actor) if (udmf) { - parameter = actor->args[0]; + parameter = actor->thing_args[0]; } else if (actor->spawnpoint != NULL) { @@ -10371,14 +10371,14 @@ void A_FlickyCenter(mobj_t *actor) P_SetTarget(&actor->tracer, flicky); actor->flags &= ~(MF_SLIDEME|MF_GRENADEBOUNCE|MF_NOCLIPTHING); - if (actor->args[1] & TMFF_AIMLESS) + if (actor->thing_args[1] & TMFF_AIMLESS) actor->flags |= MF_SLIDEME; - if (actor->args[1] & TMFF_STATIONARY) + if (actor->thing_args[1] & TMFF_STATIONARY) actor->flags |= MF_GRENADEBOUNCE; - if (actor->args[1] & TMFF_HOP) + if (actor->thing_args[1] & TMFF_HOP) actor->flags |= MF_NOCLIPTHING; - actor->extravalue1 = actor->args[0] ? abs(actor->args[0])*actor->scale : homeRadius; - actor->extravalue2 = actor->args[2]; + actor->extravalue1 = actor->thing_args[0] ? abs(actor->thing_args[0])*actor->scale : homeRadius; + actor->extravalue2 = actor->thing_args[2]; actor->friction = actor->x; actor->movefactor = actor->y; actor->watertop = actor->z; @@ -11299,7 +11299,7 @@ void A_Boss5FindWaypoint(mobj_t *actor) INT32 locvar1 = var1; boolean avoidcenter; INT32 i; - INT32 bossid = actor->args[0]; + INT32 bossid = actor->thing_args[0]; if (LUA_CallAction(A_BOSS5FINDWAYPOINT, actor)) return; @@ -11326,7 +11326,7 @@ void A_Boss5FindWaypoint(mobj_t *actor) continue; if (mapthings[i].mobj->type != MT_FANGWAYPOINT) continue; - if (!(mapthings[i].args[0])) + if (!(mapthings[i].thing_args[0])) continue; P_SetTarget(&actor->tracer, mapthings[i].mobj); @@ -11355,7 +11355,7 @@ void A_Boss5FindWaypoint(mobj_t *actor) continue; if (actor->tracer == mapthings[i].mobj) // this was your tracer last time continue; - if (mapthings[i].args[0]) + if (mapthings[i].thing_args[0]) { if (avoidcenter) continue; @@ -11410,7 +11410,7 @@ void A_Boss5FindWaypoint(mobj_t *actor) continue; if (actor->tracer == mapthings[i].mobj) // this was your tracer last time continue; - if (mapthings[i].args[0]) + if (mapthings[i].thing_args[0]) { if (avoidcenter) continue; @@ -12682,7 +12682,7 @@ void A_SpawnPterabytes(mobj_t *actor) if (LUA_CallAction(A_SPAWNPTERABYTES, actor)) return; - amount = min(1, actor->args[0]); + amount = min(1, actor->thing_args[0]); interval = FixedAngle(FRACUNIT*360/amount); @@ -13322,11 +13322,11 @@ void A_MayonakaArrow(mobj_t *actor) if (LUA_CallAction(A_MAYONAKAARROW, (actor))) return; - iswarning = (actor->args[0] == TMMA_WARN); // is our object a warning sign? + iswarning = (actor->thing_args[0] == TMMA_WARN); // is our object a warning sign? // "animtimer" is replaced by "extravalue1" here. actor->extravalue1 = ((actor->extravalue1) ? (actor->extravalue1+1) : (P_RandomRange(PR_DECORATION, 0, (iswarning) ? (TICRATE/2) : TICRATE*3))); - flip = ((actor->args[0] == TMMA_FLIP) ? (3) : (0)); // flip adds 3 frames, which is the flipped version of the sign. + flip = ((actor->thing_args[0] == TMMA_FLIP) ? (3) : (0)); // flip adds 3 frames, which is the flipped version of the sign. // special warning behavior: if (iswarning) flip = 6; diff --git a/src/p_inter.c b/src/p_inter.c index 0d99598dc..890644320 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -686,7 +686,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; case MT_STARPOST: - P_TouchStarPost(special, player, special->args[1]); + P_TouchStarPost(special, player, special->thing_args[1]); return; case MT_BIGTUMBLEWEED: diff --git a/src/p_map.c b/src/p_map.c index 0882f7187..bafc67d2e 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -527,7 +527,7 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) if (object->eflags & MFE_SPRUNG) break; - if (spring->args[1]) + if (spring->thing_args[1]) { if (object->player) { diff --git a/src/p_mobj.c b/src/p_mobj.c index 76ae716a3..bea139da0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4436,7 +4436,7 @@ static void P_RefreshItemCapsuleParts(mobj_t *mobj) color = SKINCOLOR_GOLD; newRenderFlags |= RF_SEMIBRIGHT; } - else if (mobj->args[3] & TMICM_TIMEATTACK) + else if (mobj->thing_args[3] & TMICM_TIMEATTACK) color = SKINCOLOR_SAPPHIRE; else if (itemType == KITEM_SPB) color = SKINCOLOR_JET; @@ -6539,7 +6539,7 @@ static void P_MobjSceneryThink(mobj_t *mobj) if (!(leveltime % 10)) { mobj_t *smok = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_PETSMOKE); - if (mobj->args[0]) + if (mobj->thing_args[0]) P_SetMobjStateNF(smok, smok->info->painstate); // same function, diff sprite } break; @@ -9735,7 +9735,7 @@ static boolean P_FuseThink(mobj_t *mobj) case MT_SPIKE: case MT_WALLSPIKE: P_SetMobjState(mobj, mobj->state->nextstate); - mobj->fuse = mobj->args[0]; + mobj->fuse = mobj->thing_args[0]; break; case MT_LAVAFALL: if (mobj->state - states == S_LAVAFALL_DORMANT) @@ -9872,7 +9872,7 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->flags & MF_NOTHINK) return; - if ((mobj->flags & MF_BOSS) && (bossdisabled & (1 << mobj->args[0]))) + if ((mobj->flags & MF_BOSS) && (bossdisabled & (1 << mobj->thing_args[0]))) return; mobj->flags2 &= ~(MF2_ALREADYHIT); @@ -12086,7 +12086,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) // Setting the spawnpoint's args[0] will make the player start on the ceiling // Objectflip inverts - if (!!(mthing->args[0]) ^ !!(mthing->options & MTF_OBJECTFLIP)) + if (!!(mthing->thing_args[0]) ^ !!(mthing->options & MTF_OBJECTFLIP)) z = ceilingspawn - offset; else z = floor + offset; @@ -12097,7 +12097,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) mobj->flags2 |= MF2_OBJECTFLIP; } - if (mthing->args[0]) + if (mthing->thing_args[0]) P_SetPlayerMobjState(mobj, S_KART_SPINOUT); } else @@ -12219,7 +12219,7 @@ fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mt case MT_YELLOWHORIZ: case MT_REDHORIZ: case MT_BLUEHORIZ: - offset += mthing->args[0] ? 0 : 16*FRACUNIT; + offset += mthing->thing_args[0] ? 0 : 16*FRACUNIT; break; // Ring-like items, float additional units unless args[0] is set. @@ -12228,7 +12228,7 @@ fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mt case MT_SPRAYCAN: case MT_RING: case MT_BLUESPHERE: - offset += mthing->args[0] ? 0 : 24*FRACUNIT; + offset += mthing->thing_args[0] ? 0 : 24*FRACUNIT; break; // This object does not have an offset @@ -12475,15 +12475,15 @@ static boolean P_SetupMace(mapthing_t *mthing, mobj_t *mobj) mobjeflag_t meflagsapply; const size_t mthingi = (size_t)(mthing - mapthings); - mlength = abs(mthing->args[0]); - mnumspokes = mthing->args[1] + 1; + mlength = abs(mthing->thing_args[0]); + mnumspokes = mthing->thing_args[1] + 1; mspokeangle = FixedAngle((360*FRACUNIT)/mnumspokes) >> ANGLETOFINESHIFT; - mwidth = max(0, mthing->args[2]); - mspeed = abs(mthing->args[3] << 4); - mphase = mthing->args[4] % 360; - mpinch = mthing->args[5] % 360; - mnumnospokes = mthing->args[6]; - mminlength = max(0, min(mlength - 1, mthing->args[7])); + mwidth = max(0, mthing->thing_args[2]); + mspeed = abs(mthing->thing_args[3] << 4); + mphase = mthing->thing_args[4] % 360; + mpinch = mthing->thing_args[5] % 360; + mnumnospokes = mthing->thing_args[6]; + mminlength = max(0, min(mlength - 1, mthing->thing_args[7])); mpitch = mthing->pitch % 360; myaw = mthing->angle % 360; mroll = mthing->roll % 360; @@ -12516,23 +12516,23 @@ static boolean P_SetupMace(mapthing_t *mthing, mobj_t *mobj) switch (mobj->type) { case MT_SPRINGBALLPOINT: - macetype = ((mthing->args[8] & TMM_DOUBLESIZE) + macetype = ((mthing->thing_args[8] & TMM_DOUBLESIZE) ? MT_REDSPRINGBALL : MT_YELLOWSPRINGBALL); chainlink = MT_SMALLMACECHAIN; break; case MT_FIREBARPOINT: - macetype = ((mthing->args[8] & TMM_DOUBLESIZE) + macetype = ((mthing->thing_args[8] & TMM_DOUBLESIZE) ? MT_BIGFIREBAR : MT_SMALLFIREBAR); chainlink = MT_NULL; break; case MT_CUSTOMMACEPOINT: - macetype = mthing->stringargs[0] ? get_number(mthing->stringargs[0]) : MT_NULL; - chainlink = mthing->stringargs[1] ? get_number(mthing->stringargs[1]) : MT_NULL; + macetype = mthing->thing_stringargs[0] ? get_number(mthing->thing_stringargs[0]) : MT_NULL; + chainlink = mthing->thing_stringargs[1] ? get_number(mthing->thing_stringargs[1]) : MT_NULL; break; case MT_CHAINPOINT: - if (mthing->args[8] & TMM_DOUBLESIZE) + if (mthing->thing_args[8] & TMM_DOUBLESIZE) { macetype = MT_BIGGRABCHAIN; chainlink = MT_BIGMACECHAIN; @@ -12545,7 +12545,7 @@ static boolean P_SetupMace(mapthing_t *mthing, mobj_t *mobj) mchainlike = true; break; default: - if (mthing->args[8] & TMM_DOUBLESIZE) + if (mthing->thing_args[8] & TMM_DOUBLESIZE) { macetype = MT_BIGMACE; chainlink = MT_BIGMACECHAIN; @@ -12572,11 +12572,11 @@ static boolean P_SetupMace(mapthing_t *mthing, mobj_t *mobj) firsttype = macetype; // Adjustable direction - if (mthing->args[8] & TMM_ALLOWYAWCONTROL) + if (mthing->thing_args[8] & TMM_ALLOWYAWCONTROL) mobj->flags |= MF_SLIDEME; // Swinging - if (mthing->args[8] & TMM_SWING) + if (mthing->thing_args[8] & TMM_SWING) { mobj->flags2 |= MF2_STRONGBOX; mmin = ((mnumnospokes > 1) ? 1 : 0); @@ -12585,11 +12585,11 @@ static boolean P_SetupMace(mapthing_t *mthing, mobj_t *mobj) mmin = mnumspokes; // If over distance away, don't move UNLESS this flag is applied - if (mthing->args[8] & TMM_ALWAYSTHINK) + if (mthing->thing_args[8] & TMM_ALWAYSTHINK) mobj->flags2 |= MF2_BOSSNOTRAP; // Make the links the same type as the end - repeated below - if ((mobj->type != MT_CHAINPOINT) && (((mthing->args[8] & TMM_MACELINKS) == TMM_MACELINKS) != (mobj->type == MT_FIREBARPOINT))) // exclusive or + if ((mobj->type != MT_CHAINPOINT) && (((mthing->thing_args[8] & TMM_MACELINKS) == TMM_MACELINKS) != (mobj->type == MT_FIREBARPOINT))) // exclusive or { linktype = macetype; radiusfactor = 2; // Double the radius. @@ -12601,7 +12601,7 @@ static boolean P_SetupMace(mapthing_t *mthing, mobj_t *mobj) mchainlike = (firsttype == chainlink); widthfactor = (mchainlike ? 1 : 2); - mflagsapply = (mthing->args[8] & TMM_CLIP) ? 0 : (MF_NOCLIP|MF_NOCLIPHEIGHT); + mflagsapply = (mthing->thing_args[8] & TMM_CLIP) ? 0 : (MF_NOCLIP|MF_NOCLIPHEIGHT); mflags2apply = ((mthing->options & MTF_OBJECTFLIP) ? MF2_OBJECTFLIP : 0); meflagsapply = ((mthing->options & MTF_OBJECTFLIP) ? MFE_VERTICALFLIP : 0); @@ -12627,14 +12627,14 @@ static boolean P_SetupMace(mapthing_t *mthing, mobj_t *mobj) hprev = spawnee;\ } - mdosound = (mspeed && !(mthing->args[8] & TMM_SILENT)); - mdocenter = (macetype && (mthing->args[8] & TMM_CENTERLINK)); + mdosound = (mspeed && !(mthing->thing_args[8] & TMM_SILENT)); + mdocenter = (macetype && (mthing->thing_args[8] & TMM_CENTERLINK)); // The actual spawning of spokes while (mnumspokes-- > 0) { // Offsets - if (mthing->args[8] & TMM_SWING) // Swinging + if (mthing->thing_args[8] & TMM_SWING) // Swinging mroll = (mroll - mspokeangle) & FINEMASK; else // Spinning mphase = (mphase - mspokeangle) & FINEMASK; @@ -12645,7 +12645,7 @@ static boolean P_SetupMace(mapthing_t *mthing, mobj_t *mobj) continue; linktype = chainlink; - firsttype = ((mthing->args[8] & TMM_DOUBLESIZE) ? MT_BIGGRABCHAIN : MT_SMALLGRABCHAIN); + firsttype = ((mthing->thing_args[8] & TMM_DOUBLESIZE) ? MT_BIGGRABCHAIN : MT_SMALLGRABCHAIN); mmaxlength = 1 + (mlength - 1) * radiusfactor; radiusfactor = widthfactor = 1; } @@ -12654,7 +12654,7 @@ static boolean P_SetupMace(mapthing_t *mthing, mobj_t *mobj) if (mobj->type == MT_CHAINMACEPOINT) { // Make the links the same type as the end - repeated above - if (mthing->args[8] & TMM_MACELINKS) + if (mthing->thing_args[8] & TMM_MACELINKS) { linktype = macetype; radiusfactor = 2; @@ -12744,20 +12744,20 @@ static boolean P_SetupParticleGen(mapthing_t *mthing, mobj_t *mobj) const size_t mthingi = (size_t)(mthing - mapthings); // Find the corresponding linedef special, using args[6] as tag - line = mthing->args[6] ? Tag_FindLineSpecial(15, mthing->args[6]) : -1; + line = mthing->thing_args[6] ? Tag_FindLineSpecial(15, mthing->thing_args[6]) : -1; - type = mthing->stringargs[0] ? get_number(mthing->stringargs[0]) : MT_PARTICLE; + type = mthing->thing_stringargs[0] ? get_number(mthing->thing_stringargs[0]) : MT_PARTICLE; - ticcount = mthing->args[4]; + ticcount = mthing->thing_args[4]; if (ticcount < 1) ticcount = 3; - numdivisions = mthing->args[0]; + numdivisions = mthing->thing_args[0]; if (numdivisions) { - radius = mthing->args[1] << FRACBITS; - anglespeed = (mthing->args[3]) % 360; + radius = mthing->thing_args[1] << FRACBITS; + anglespeed = (mthing->thing_args[3]) % 360; angledivision = 360/numdivisions; } else @@ -12768,11 +12768,11 @@ static boolean P_SetupParticleGen(mapthing_t *mthing, mobj_t *mobj) angledivision = 0; } - speed = abs(mthing->args[2]) << FRACBITS; + speed = abs(mthing->thing_args[2]) << FRACBITS; if (mthing->options & MTF_OBJECTFLIP) speed *= -1; - zdist = abs(mthing->args[5]) << FRACBITS; + zdist = abs(mthing->thing_args[5]) << FRACBITS; CONS_Debug(DBG_GAMELOGIC, "Particle Generator (mapthing #%s):\n" "Radius is %d\n" @@ -12874,7 +12874,7 @@ void P_InitSkyboxPoint(mobj_t *mobj, mapthing_t *mthing) return; } - if (mthing->args[0]) + if (mthing->thing_args[0]) P_SetTarget(&skyboxcenterpnts[tag], mobj); else P_SetTarget(&skyboxviewpnts[tag], mobj); @@ -12946,14 +12946,14 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) break; } case MT_EGGSTATUE: - if (mthing->args[1]) + if (mthing->thing_args[1]) { mobj->color = SKINCOLOR_GOLD; mobj->colorized = true; } break; case MT_FAN: - if (mthing->args[1] & TMF_INVISIBLE) + if (mthing->thing_args[1] & TMF_INVISIBLE) { P_UnsetThingPosition(mobj); if (sector_list) @@ -12964,21 +12964,21 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) mobj->flags |= MF_NOSECTOR; // this flag basically turns it invisible P_SetThingPosition(mobj); } - if (mthing->args[1] & TMF_NODISTANCECHECK) + if (mthing->thing_args[1] & TMF_NODISTANCECHECK) mobj->flags2 |= MF2_AMBUSH; - if (mthing->args[0]) - mobj->health = mthing->args[0]; + if (mthing->thing_args[0]) + mobj->health = mthing->thing_args[0]; else mobj->health = FixedMul(mobj->subsector->sector->ceilingheight - mobj->subsector->sector->floorheight, 3*(FRACUNIT/4)) >> FRACBITS; break; case MT_BALLOON: - if (mthing->stringargs[0]) - mobj->color = get_number(mthing->stringargs[0]); - if (mthing->args[0]) + if (mthing->thing_stringargs[0]) + mobj->color = get_number(mthing->thing_stringargs[0]); + if (mthing->thing_args[0]) mobj->flags2 |= MF2_AMBUSH; break; case MT_FLAME: - if (mthing->args[0]) + if (mthing->thing_args[0]) { mobj_t *corona = P_MakeSoftwareCorona(mobj, 20); P_SetScale(corona, (corona->destscale = mobj->scale*3)); @@ -12986,12 +12986,12 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) } break; case MT_FLAMEHOLDER: - if (!(mthing->args[0] & TMFH_NOFLAME)) // Spawn the fire + if (!(mthing->thing_args[0] & TMFH_NOFLAME)) // Spawn the fire { mobj_t *flame = P_SpawnMobjFromMobj(mobj, 0, 0, mobj->height, MT_FLAME); P_SetTarget(&flame->target, mobj); flame->flags2 |= MF2_BOSSNOTRAP; - if (mthing->args[0] & TMFH_CORONA) + if (mthing->thing_args[0] & TMFH_CORONA) { mobj_t *corona = P_MakeSoftwareCorona(flame, 20); P_SetScale(corona, (corona->destscale = flame->scale*3)); @@ -13001,13 +13001,13 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) break; case MT_CANDLE: case MT_CANDLEPRICKET: - if (mthing->args[0]) + if (mthing->thing_args[0]) P_MakeSoftwareCorona(mobj, ((mobj->type == MT_CANDLE) ? 42 : 176)); break; case MT_JACKO1: case MT_JACKO2: case MT_JACKO3: - if (!(mthing->args[0])) // take the torch out of the crafting recipe + if (!(mthing->thing_args[0])) // take the torch out of the crafting recipe { mobj_t *overlay = P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_OVERLAY); P_SetTarget(&overlay->target, mobj); @@ -13015,14 +13015,14 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) } break; case MT_WATERDRIP: - mobj->tics = 3*TICRATE + mthing->args[0]; + mobj->tics = 3*TICRATE + mthing->thing_args[0]; break; case MT_FLAMEJET: case MT_VERTICALFLAMEJET: - mobj->movecount = mthing->args[0]; - mobj->threshold = mthing->args[1]; - mobj->movedir = mthing->args[2]; - if (mthing->args[3]) + mobj->movecount = mthing->thing_args[0]; + mobj->threshold = mthing->thing_args[1]; + mobj->movedir = mthing->thing_args[2]; + if (mthing->thing_args[3]) mobj->flags2 |= MF2_AMBUSH; break; case MT_MACEPOINT: @@ -13040,8 +13040,8 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) break; case MT_TUBEWAYPOINT: { - UINT8 sequence = mthing->args[0]; - UINT8 id = mthing->args[1]; + UINT8 sequence = mthing->thing_args[0]; + UINT8 id = mthing->thing_args[1]; mobj->health = id; mobj->threshold = sequence; P_AddTubeWaypoint(sequence, id, mobj); @@ -13050,7 +13050,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) case MT_DSZSTALAGMITE: case MT_DSZ2STALAGMITE: case MT_KELP: - if (mthing->args[0]) { // make mobj twice as big as normal + if (mthing->thing_args[0]) { // make mobj twice as big as normal P_SetScale(mobj, 2*mobj->scale); // not 2*FRACUNIT in case of something like the old ERZ3 mode mobj->destscale = mobj->scale; } @@ -13090,8 +13090,8 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) } break; case MT_SMASHINGSPIKEBALL: - if (mthing->args[0] > 0) - mobj->tics += mthing->args[0]; + if (mthing->thing_args[0] > 0) + mobj->tics += mthing->thing_args[0]; break; case MT_BIGFERN: { @@ -13115,37 +13115,37 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) break; case MT_AXIS: // Inverted if args[3] is set - if (mthing->args[3]) + if (mthing->thing_args[3]) mobj->flags2 |= MF2_AMBUSH; - mobj->radius = abs(mthing->args[2]) << FRACBITS; + mobj->radius = abs(mthing->thing_args[2]) << FRACBITS; // FALLTHRU case MT_AXISTRANSFER: case MT_AXISTRANSFERLINE: // Mare it belongs to - mobj->threshold = min(mthing->args[0], 7); + mobj->threshold = min(mthing->thing_args[0], 7); // # in the mare - mobj->health = mthing->args[1]; + mobj->health = mthing->thing_args[1]; mobj->flags2 |= MF2_AXIS; break; case MT_STARPOST: - mobj->health = mthing->args[0] + 1; + mobj->health = mthing->thing_args[0] + 1; if (!P_MapAlreadyHasStarPost(mobj)) numstarposts++; break; case MT_SPIKE: // Pop up spikes! - if (mthing->args[0]) + if (mthing->thing_args[0]) { mobj->flags &= ~MF_SCENERY; - mobj->fuse = mthing->args[1]; + mobj->fuse = mthing->thing_args[1]; } - if (mthing->args[2] & TMSF_RETRACTED) + if (mthing->thing_args[2] & TMSF_RETRACTED) P_SetMobjState(mobj, mobj->info->meleestate); // Use per-thing collision for spikes unless the intangible flag is checked. - if (!(mthing->args[2] & TMSF_INTANGIBLE) && !metalrecording) + if (!(mthing->thing_args[2] & TMSF_INTANGIBLE) && !metalrecording) { P_UnsetThingPosition(mobj); mobj->flags &= ~(MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIPHEIGHT); @@ -13155,15 +13155,15 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) break; case MT_WALLSPIKE: // Pop up spikes! - if (mthing->args[0]) + if (mthing->thing_args[0]) { mobj->flags &= ~MF_SCENERY; - mobj->fuse = mthing->args[1]; + mobj->fuse = mthing->thing_args[1]; } - if (mthing->args[2] & TMSF_RETRACTED) + if (mthing->thing_args[2] & TMSF_RETRACTED) P_SetMobjState(mobj, mobj->info->meleestate); // Use per-thing collision for spikes unless the intangible flag is checked. - if (!(mthing->args[2] & TMSF_INTANGIBLE) && !metalrecording) + if (!(mthing->thing_args[2] & TMSF_INTANGIBLE) && !metalrecording) { P_UnsetThingPosition(mobj); mobj->flags &= ~(MF_NOBLOCKMAP | MF_NOCLIPHEIGHT); @@ -13187,7 +13187,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) break; case MT_BIGTUMBLEWEED: case MT_LITTLETUMBLEWEED: - if (mthing->args[0]) + if (mthing->thing_args[0]) { fixed_t offset = FixedMul(16*FRACUNIT, mobj->scale); mobj->momx += P_RandomChance(PR_DECORATION, FRACUNIT/2) ? offset : -offset; @@ -13197,9 +13197,9 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) } break; case MT_AMBIENT: - if (mthing->stringargs[0]) - mobj->threshold = get_number(mthing->stringargs[0]); - mobj->health = mthing->args[0] ? mthing->args[0] : TICRATE; + if (mthing->thing_stringargs[0]) + mobj->threshold = get_number(mthing->thing_stringargs[0]); + mobj->health = mthing->thing_args[0] ? mthing->thing_args[0] : TICRATE; break; // SRB2Kart case MT_WAYPOINT: @@ -13208,8 +13208,8 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) mapheaderinfo[gamemap-1]->default_waypoint_radius; mtag_t tag = mthing->tid; - if (mthing->args[1] > 0) - mobj->radius = (mthing->args[1]) * FRACUNIT; + if (mthing->thing_args[1] > 0) + mobj->radius = (mthing->thing_args[1]) * FRACUNIT; else if (mobjscale > 0) mobj->radius = mobjscale; else @@ -13221,9 +13221,9 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) // lastlook is used for indicating the waypoint is a shortcut // extravalue1 is used for indicating the waypoint is disabled // extravalue2 is used for indicating the waypoint is the finishline - mobj->threshold = mthing->args[0]; + mobj->threshold = mthing->thing_args[0]; mobj->movecount = tag; - if (mthing->args[2] & TMWPF_DISABLED) + if (mthing->thing_args[2] & TMWPF_DISABLED) { mobj->extravalue1 = 0; // The waypoint is disabled if extra is on } @@ -13231,7 +13231,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) { mobj->extravalue1 = 1; } - if (mthing->args[2] & TMWPF_SHORTCUT) + if (mthing->thing_args[2] & TMWPF_SHORTCUT) { mobj->lastlook = 1; // the waypoint is a shortcut if objectspecial is on } @@ -13239,7 +13239,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) { mobj->lastlook = 0; } - if (mthing->args[2] & TMWPF_NORESPAWN) + if (mthing->thing_args[2] & TMWPF_NORESPAWN) { mobj->reactiontime = 0; // Can't respawn at if Ambush is on } @@ -13247,7 +13247,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) { mobj->reactiontime = 1; } - if (mthing->args[2] & TMWPF_FINISHLINE) + if (mthing->thing_args[2] & TMWPF_FINISHLINE) { mobj->extravalue2 = 1; // args[2] of 1 means the waypoint is at the finish line mobj->reactiontime = 0; // Also don't respawn at finish lines @@ -13267,9 +13267,9 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) case MT_BOTHINT: { // Change size - if (mthing->args[0] > 0) + if (mthing->thing_args[0] > 0) { - mobj->radius = mthing->args[0] * FRACUNIT; + mobj->radius = mthing->thing_args[0] * FRACUNIT; } else { @@ -13277,7 +13277,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) } // Steer away instead of towards - if (mthing->args[2]) + if (mthing->thing_args[2]) { mobj->extravalue1 = 0; } @@ -13287,13 +13287,13 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) } // Steering amount - if (mthing->args[1] == 0) + if (mthing->thing_args[1] == 0) { mobj->extravalue2 = 4; } else { - mobj->extravalue2 = mthing->args[1]; + mobj->extravalue2 = mthing->thing_args[1]; } break; } @@ -13311,7 +13311,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) P_SetThingPosition(mobj); } } - if (mthing->args[0] == 1) + if (mthing->thing_args[0] == 1) mobj->flags2 |= MF2_AMBUSH; break; } @@ -13334,14 +13334,14 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) mobj->flags |= MF_NOGRAVITY; // Angle = item type - if (mthing->args[0] > 0 && mthing->args[0] < NUMKARTITEMS) - mobj->threshold = mthing->args[0]; + if (mthing->thing_args[0] > 0 && mthing->thing_args[0] < NUMKARTITEMS) + mobj->threshold = mthing->thing_args[0]; // Parameter = extra items (x5 for rings) - mobj->movecount += mthing->args[1]; + mobj->movecount += mthing->thing_args[1]; // Ambush = double size (grounded) / half size (aerial) - if (!(mthing->args[2] & TMICF_INVERTSIZE) == !P_IsObjectOnGround(mobj)) + if (!(mthing->thing_args[2] & TMICF_INVERTSIZE) == !P_IsObjectOnGround(mobj)) { mobj->extravalue1 = min(mobj->extravalue1 << 1, FixedDiv(MAPBLOCKSIZE, mobj->info->radius)); // don't make them larger than the blockmap can handle mobj->scalespeed <<= 1; @@ -13350,17 +13350,17 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) } case MT_RANDOMAUDIENCE: { - if (mthing->args[2] & TMAUDIM_FLOAT) + if (mthing->thing_args[2] & TMAUDIM_FLOAT) { mobj->flags |= MF_NOGRAVITY; } - if (mthing->args[2] & TMAUDIM_BORED) + if (mthing->thing_args[2] & TMAUDIM_BORED) { mobj->flags2 |= MF2_BOSSNOTRAP; } - if (mthing->args[3] != 0) + if (mthing->thing_args[3] != 0) { mobj->flags2 |= MF2_AMBUSH; } @@ -13376,8 +13376,8 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) { fixed_t top = mobj->z; UINT8 i; - UINT8 locnumsegs = abs(mthing->args[0])+2; - UINT8 numleaves = max(3, (abs(mthing->args[1])+1 % 6) + 3); + UINT8 locnumsegs = abs(mthing->thing_args[0])+2; + UINT8 numleaves = max(3, (abs(mthing->thing_args[1])+1 % 6) + 3); mobj_t *coconut; // Spawn tree segments @@ -13413,7 +13413,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) case MT_SUNBEAMPALM_STEM: { UINT8 i; - const UINT8 numleaves = max(4, (abs(mthing->args[0])+1 % 6) + 4); + const UINT8 numleaves = max(4, (abs(mthing->thing_args[0])+1 % 6) + 4); const fixed_t pivot = P_RandomRange(PR_DECORATION, -40, 20) * FRACUNIT; @@ -13515,7 +13515,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) } // Moving capsules! - if (mthing->args[0] && mthing->args[1]) + if (mthing->thing_args[0] && mthing->thing_args[1]) { K_SetupMovingCapsule(mthing, mobj); } @@ -13584,7 +13584,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) { Obj_DuelBombInit(mobj); - if (mthing->args[1]) + if (mthing->thing_args[1]) { Obj_DuelBombReverse(mobj); } @@ -13642,7 +13642,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) if (mobj->flags & MF_BOSS) { - if (mthing->args[1]) // No egg trap for this boss + if (mthing->thing_args[1]) // No egg trap for this boss mobj->flags2 |= MF2_BOSSNOTRAP; } @@ -13674,33 +13674,61 @@ 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; - for (arg = 0; arg < NUMMAPTHINGARGS; arg++) + for (arg = 0; arg < NUM_MAPTHING_ARGS; arg++) { - mobj->args[arg] = mthing->args[arg]; + mobj->thing_args[arg] = mthing->thing_args[arg]; } - for (arg = 0; arg < NUMMAPTHINGSTRINGARGS; arg++) + for (arg = 0; arg < NUM_MAPTHING_STRINGARGS; arg++) { size_t len = 0; - if (mthing->stringargs[arg]) + if (mthing->thing_stringargs[arg]) { - len = strlen(mthing->stringargs[arg]); + len = strlen(mthing->thing_stringargs[arg]); } if (len == 0) { - Z_Free(mobj->stringargs[arg]); - mobj->stringargs[arg] = NULL; + Z_Free(mobj->thing_stringargs[arg]); + mobj->thing_stringargs[arg] = NULL; continue; } - mobj->stringargs[arg] = Z_Realloc(mobj->stringargs[arg], len + 1, PU_LEVEL, NULL); - M_Memcpy(mobj->stringargs[arg], mthing->stringargs[arg], len + 1); + mobj->thing_stringargs[arg] = Z_Realloc(mobj->thing_stringargs[arg], len + 1, PU_LEVEL, NULL); + M_Memcpy(mobj->thing_stringargs[arg], mthing->thing_stringargs[arg], len + 1); + } + + for (arg = 0; arg < NUM_SCRIPT_ARGS; arg++) + { + mobj->script_args[arg] = mthing->script_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)) @@ -13773,7 +13801,7 @@ void P_SpawnHoop(mapthing_t *mthing) mobj_t *nextmobj = NULL; mobj_t *hoopcenter; TMatrix *pitchmatrix, *yawmatrix; - fixed_t radius = mthing->args[0] << FRACBITS; + fixed_t radius = mthing->thing_args[0] << FRACBITS; fixed_t sizefactor = 4*FRACUNIT; fixed_t hoopsize = radius/sizefactor; INT32 i; @@ -13925,7 +13953,7 @@ static void P_SpawnItemRow(mapthing_t *mthing, mobjtype_t *itemtypes, UINT8 numi loopanchor->spawnpoint = NULL; - Obj_LinkLoopAnchor(loopanchor, loopcenter, mthing->args[0]); + Obj_LinkLoopAnchor(loopanchor, loopcenter, mthing->thing_args[0]); } for (r = 0; r < numitems; r++) @@ -14081,8 +14109,8 @@ void P_SpawnItemPattern(mapthing_t *mthing) UINT8 numitemtypes; if (!udmf) return; - P_ParseItemTypes(mthing->stringargs[0], itemtypes, &numitemtypes); - P_SpawnItemRow(mthing, itemtypes, numitemtypes, mthing->args[0], mthing->args[1] << FRACBITS, mthing->args[2] << FRACBITS, mthing->angle); + P_ParseItemTypes(mthing->thing_stringargs[0], itemtypes, &numitemtypes); + P_SpawnItemRow(mthing, itemtypes, numitemtypes, mthing->thing_args[0], mthing->thing_args[1] << FRACBITS, mthing->thing_args[2] << FRACBITS, mthing->angle); return; } case 611: // Generic item circle @@ -14091,9 +14119,8 @@ void P_SpawnItemPattern(mapthing_t *mthing) UINT8 numitemtypes; if (!udmf) return; - CONS_Printf("Itemstring: %s\n", mthing->stringargs[0]); - P_ParseItemTypes(mthing->stringargs[0], itemtypes, &numitemtypes); - P_SpawnItemCircle(mthing, itemtypes, numitemtypes, mthing->args[0], mthing->args[1] << FRACBITS); + P_ParseItemTypes(mthing->thing_stringargs[0], itemtypes, &numitemtypes); + P_SpawnItemCircle(mthing, itemtypes, numitemtypes, mthing->thing_args[0], mthing->thing_args[1] << FRACBITS); return; } default: @@ -14754,9 +14781,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; + Z_Free(mobj->thing_stringargs[i]); + mobj->thing_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..0a3fb3939 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -426,9 +426,12 @@ struct mobj_t INT32 dispoffset; + INT32 thing_args[NUM_MAPTHING_ARGS]; + char *thing_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 6f4ecbacd..2c2e3ce11 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1549,7 +1549,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; @@ -1559,7 +1559,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]; @@ -1596,7 +1596,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; @@ -1606,7 +1606,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]; @@ -1869,12 +1869,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; @@ -2023,12 +2023,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; @@ -2159,13 +2159,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; @@ -2248,13 +2248,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; @@ -2320,8 +2320,8 @@ 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++) - if (mobj->args[i] != mapthing->args[i]) + for (i = 0; i < NUM_MAPTHING_ARGS; i++) + if (mobj->thing_args[i] != mapthing->thing_args[i]) return false; return true; @@ -2330,12 +2330,34 @@ 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]; + if (!mobj->thing_stringargs[i]) + return !mapthing->thing_stringargs[i]; - if (strcmp(mobj->stringargs[i], mapthing->stringargs[i])) + if (strcmp(mobj->thing_stringargs[i], mapthing->thing_stringargs[i])) + return false; + } + + 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; } @@ -2548,7 +2570,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 @@ -2556,18 +2578,18 @@ 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) + if (mobj->thing_args[j] != 0) { diff |= MD_ARGS; break; } } - for (j = 0; j < NUMMAPTHINGSTRINGARGS; j++) + for (j = 0; j < NUM_MAPTHING_STRINGARGS; j++) { - if (mobj->stringargs[j] != NULL) + if (mobj->thing_stringargs[j] != NULL) { diff |= MD_STRINGARGS; break; @@ -2578,6 +2600,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->script_stringargs[j] != NULL) + { + diff2 |= MD2_SPECIAL; + break; + } + } } // not the default but the most probable @@ -2828,25 +2868,25 @@ 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++) - WRITEINT32(save->p, mobj->args[j]); + for (j = 0; j < NUM_MAPTHING_ARGS; j++) + WRITEINT32(save->p, mobj->thing_args[j]); } if (diff & MD_STRINGARGS) { - for (j = 0; j < NUMMAPTHINGSTRINGARGS; j++) + for (j = 0; j < NUM_MAPTHING_STRINGARGS; j++) { size_t len, k; - if (!mobj->stringargs[j]) + if (!mobj->thing_stringargs[j]) { WRITEINT32(save->p, 0); continue; } - len = strlen(mobj->stringargs[j]); + len = strlen(mobj->thing_stringargs[j]); WRITEINT32(save->p, len); for (k = 0; k < len; k++) - WRITECHAR(save->p, mobj->stringargs[j][k]); + WRITECHAR(save->p, mobj->thing_stringargs[j][k]); } } if (diff2 & MD2_CUSVAL) @@ -2913,7 +2953,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; @@ -4031,27 +4092,27 @@ static thinker_t* LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) mobj->scalespeed = mapobjectscale/12; if (diff & MD_ARGS) { - for (j = 0; j < NUMMAPTHINGARGS; j++) - mobj->args[j] = READINT32(save->p); + for (j = 0; j < NUM_MAPTHING_ARGS; j++) + mobj->thing_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; if (!len) { - Z_Free(mobj->stringargs[j]); - mobj->stringargs[j] = NULL; + Z_Free(mobj->thing_stringargs[j]); + mobj->thing_stringargs[j] = NULL; continue; } - mobj->stringargs[j] = Z_Realloc(mobj->stringargs[j], len + 1, PU_LEVEL, NULL); + mobj->thing_stringargs[j] = Z_Realloc(mobj->thing_stringargs[j], len + 1, PU_LEVEL, NULL); for (k = 0; k < len; k++) - mobj->stringargs[j][k] = READCHAR(save->p); - mobj->stringargs[j][len] = '\0'; + mobj->thing_stringargs[j][k] = READCHAR(save->p); + mobj->thing_stringargs[j][len] = '\0'; } } if (diff2 & MD2_CUSVAL) @@ -4123,6 +4184,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 f55c13b09..beee4d955 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; @@ -723,7 +724,7 @@ static int cmp_loopends(const void *a, const void *b) // weighted sorting; tag takes precedence over type return intsign(mt1->tid - mt2->tid) * 2 + - intsign(mt1->args[0] - mt2->args[0]); + intsign(mt1->thing_args[0] - mt2->thing_args[0]); } static void P_SpawnMapThings(boolean spawnemblems) @@ -805,7 +806,7 @@ static void P_SpawnMapThings(boolean spawnemblems) *mt2 = loopends[i]; if (mt1->tid == mt2->tid && - mt1->args[0] == mt2->args[0]) + mt1->thing_args[0] == mt2->thing_args[0]) { P_SpawnItemLine(mt1, mt2); i++; @@ -985,8 +986,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); @@ -1094,8 +1095,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; @@ -1338,9 +1339,12 @@ 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)); + mt->spritexscale = mt->spriteyscale = FRACUNIT; + memset(mt->thing_args, 0, NUM_MAPTHING_ARGS*sizeof(*mt->thing_args)); + memset(mt->thing_stringargs, 0x00, NUM_MAPTHING_STRINGARGS*sizeof(*mt->thing_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; @@ -1383,8 +1387,8 @@ 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); while ((tkn = M_TokenizerRead(0)) && M_TokenizerGetEndPos() < size) { @@ -1407,6 +1411,13 @@ static boolean TextmapCount(size_t size) vertexesPos[numvertexes++] = M_TokenizerGetEndPos(); else if (fastcmp(tkn, "sector")) sectorsPos[numsectors++] = M_TokenizerGetEndPos(); + else 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); + } else CONS_Alert(CONS_NOTICE, "Unknown field '%s'.\n", tkn); } @@ -1735,7 +1746,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); @@ -1743,7 +1754,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); } @@ -1816,7 +1827,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); @@ -1824,7 +1835,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); } @@ -1920,7 +1931,40 @@ 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")) + { + if (udmf_version < 1) + { + mapthings[i].scale = FLOAT_TO_FIXED(atof(val)); + } + else + { + mapthings[i].spritexscale = mapthings[i].spriteyscale = FLOAT_TO_FIXED(atof(val)); + } + } + else if (fastcmp(param, "scalex")) + { + if (udmf_version < 1) + { + mapthings[i].scale = FLOAT_TO_FIXED(atof(val)); + } + else + { + mapthings[i].spritexscale = FLOAT_TO_FIXED(atof(val)); + } + } + else if (fastcmp(param, "scaley")) + { + if (udmf_version < 1) + { + mapthings[i].scale = FLOAT_TO_FIXED(atof(val)); + } + else + { + 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)) @@ -1932,20 +1976,60 @@ static void ParseTextmapThingParameter(UINT32 i, const char *param, const char * mapthings[i].layer = atol(val); else if (fastncmp(param, "stringarg", 9) && strlen(param) > 9) { - size_t argnum = atol(param + 9); - if (argnum >= NUMMAPTHINGSTRINGARGS) - return; - size_t len = strlen(val); - mapthings[i].stringargs[argnum] = Z_Malloc(len + 1, PU_LEVEL, NULL); - M_Memcpy(mapthings[i].stringargs[argnum], val, len); - mapthings[i].stringargs[argnum][len] = '\0'; + if (udmf_version < 1) + { + size_t argnum = atol(param + 9); + if (argnum >= NUM_MAPTHING_STRINGARGS) + return; + size_t len = strlen(val); + mapthings[i].thing_stringargs[argnum] = Z_Malloc(len + 1, PU_LEVEL, NULL); + M_Memcpy(mapthings[i].thing_stringargs[argnum], val, len); + mapthings[i].thing_stringargs[argnum][len] = '\0'; + } + else + { + size_t argnum = atol(param + 9); + 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, "arg", 3) && strlen(param) > 3) { - size_t argnum = atol(param + 3); - if (argnum >= NUMMAPTHINGARGS) + if (udmf_version < 1) + { + size_t argnum = atol(param + 3); + if (argnum >= NUM_MAPTHING_ARGS) + return; + mapthings[i].thing_args[argnum] = atol(val); + } + else + { + size_t argnum = atol(param + 3); + if (argnum >= NUM_SCRIPT_ARGS) + return; + mapthings[i].script_args[argnum] = atol(val); + } + } + else if (fastncmp(param, "thingstringarg", 14) && strlen(param) > 14) + { + size_t argnum = atol(param + 14); + if (argnum >= NUM_MAPTHING_STRINGARGS) return; - mapthings[i].args[argnum] = atol(val); + size_t len = strlen(val); + mapthings[i].thing_stringargs[argnum] = Z_Malloc(len + 1, PU_LEVEL, NULL); + M_Memcpy(mapthings[i].thing_stringargs[argnum], val, len); + mapthings[i].thing_stringargs[argnum][len] = '\0'; + } + else if (fastncmp(param, "thingarg", 8) && strlen(param) > 8) + { + size_t argnum = atol(param + 8); + if (argnum >= NUM_MAPTHING_ARGS) + return; + mapthings[i].thing_args[argnum] = atol(val); } else ParseUserProperty(&mapthings[i].user, param, val); @@ -2082,18 +2166,28 @@ 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) fprintf(f, "special = %d;\n", wmapthings[i].special); - for (j = 0; j < NUMMAPTHINGARGS; 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++) - if (mapthings[i].stringargs[j]) - fprintf(f, "stringarg%s = \"%s\";\n", sizeu1(j), mapthings[i].stringargs[j]); + for (j = 0; j < NUM_SCRIPT_ARGS; j++) + if (wmapthings[i].script_args[j] != 0) + 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, "stringarg%s = \"%s\";\n", sizeu1(j), mapthings[i].script_stringargs[j]); + for (j = 0; j < NUM_MAPTHING_ARGS; j++) + if (wmapthings[i].thing_args[j] != 0) + fprintf(f, "thingarg%s = %d;\n", sizeu1(j), wmapthings[i].thing_args[j]); + for (j = 0; j < NUM_MAPTHING_STRINGARGS; j++) + if (mapthings[i].thing_stringargs[j]) + fprintf(f, "stringthingarg%s = \"%s\";\n", sizeu1(j), mapthings[i].thing_stringargs[j]); if (wmapthings[i].user.length > 0) { for (j = 0; j < wmapthings[i].user.length; j++) @@ -2216,248 +2310,255 @@ 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; + } + + 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)); + } } } - 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, 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)); - } - } - - 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 - || 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); @@ -2512,10 +2613,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) @@ -2800,10 +2901,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) @@ -2996,8 +3097,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); @@ -3047,8 +3148,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; @@ -3101,9 +3202,12 @@ 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)); + mt->spritexscale = mt->spriteyscale = FRACUNIT; + memset(mt->thing_args, 0, NUM_MAPTHING_ARGS*sizeof(*mt->thing_args)); + memset(mt->thing_stringargs, 0x00, NUM_MAPTHING_STRINGARGS*sizeof(*mt->thing_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; @@ -6496,45 +6600,45 @@ static void P_ConvertBinaryThingTypes(void) if (mobjinfo[mobjtype].flags & MF_BOSS) { INT32 paramoffset = mapthings[i].extrainfo*LE_PARAMWIDTH; - mapthings[i].args[0] = mapthings[i].extrainfo; - mapthings[i].args[1] = !!(mapthings[i].options & MTF_OBJECTSPECIAL); - mapthings[i].args[2] = LE_BOSSDEAD + paramoffset; - mapthings[i].args[3] = LE_ALLBOSSESDEAD + paramoffset; - mapthings[i].args[4] = LE_PINCHPHASE + paramoffset; + mapthings[i].thing_args[0] = mapthings[i].extrainfo; + mapthings[i].thing_args[1] = !!(mapthings[i].options & MTF_OBJECTSPECIAL); + mapthings[i].thing_args[2] = LE_BOSSDEAD + paramoffset; + mapthings[i].thing_args[3] = LE_ALLBOSSESDEAD + paramoffset; + mapthings[i].thing_args[4] = LE_PINCHPHASE + paramoffset; } if (mobjinfo[mobjtype].flags & MF_PUSHABLE) { if ((mapthings[i].options & (MTF_OBJECTSPECIAL|MTF_AMBUSH)) == (MTF_OBJECTSPECIAL|MTF_AMBUSH)) - mapthings[i].args[0] = TMP_CLASSIC; + mapthings[i].thing_args[0] = TMP_CLASSIC; else if (mapthings[i].options & MTF_OBJECTSPECIAL) - mapthings[i].args[0] = TMP_SLIDE; + mapthings[i].thing_args[0] = TMP_SLIDE; else if (mapthings[i].options & MTF_AMBUSH) - mapthings[i].args[0] = TMP_IMMOVABLE; + mapthings[i].thing_args[0] = TMP_IMMOVABLE; else - mapthings[i].args[0] = TMP_NORMAL; + mapthings[i].thing_args[0] = TMP_NORMAL; } if (K_IsDuelItem(mobjtype) == true) { - mapthings[i].args[0] = !!(mapthings[i].options & MTF_EXTRA); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_EXTRA); } } if (mapthings[i].type >= 1 && mapthings[i].type <= 35) //Player starts { - mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_AMBUSH); continue; } else if (mapthings[i].type >= 2200 && mapthings[i].type <= 2217) //Flickies { - mapthings[i].args[0] = mapthings[i].angle; + mapthings[i].thing_args[0] = mapthings[i].angle; if (mapthings[i].options & MTF_EXTRA) - mapthings[i].args[1] |= TMFF_AIMLESS; + mapthings[i].thing_args[1] |= TMFF_AIMLESS; if (mapthings[i].options & MTF_OBJECTSPECIAL) - mapthings[i].args[1] |= TMFF_STATIONARY; + mapthings[i].thing_args[1] |= TMFF_STATIONARY; if (mapthings[i].options & MTF_AMBUSH) - mapthings[i].args[1] |= TMFF_HOP; + mapthings[i].thing_args[1] |= TMFF_HOP; if (mapthings[i].type == 2207) - mapthings[i].args[2] = mapthings[i].extrainfo; + mapthings[i].thing_args[2] = mapthings[i].extrainfo; continue; } @@ -6542,13 +6646,13 @@ static void P_ConvertBinaryThingTypes(void) { case 102: //SDURF case 1805: //Puma - mapthings[i].args[0] = mapthings[i].angle; + mapthings[i].thing_args[0] = mapthings[i].angle; break; case 110: //THZ Turret - mapthings[i].args[0] = LE_TURRET; + mapthings[i].thing_args[0] = LE_TURRET; break; case 111: //Pop-up Turret - mapthings[i].args[0] = mapthings[i].angle; + mapthings[i].thing_args[0] = mapthings[i].angle; break; case 103: //Buzz (Gold) case 104: //Buzz (Red) @@ -6560,62 +6664,62 @@ static void P_ConvertBinaryThingTypes(void) case 132: //Cacolantern case 138: //Banpyura case 1602: //Pian - mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_AMBUSH); break; case 119: //Egg Guard if ((mapthings[i].options & (MTF_EXTRA|MTF_OBJECTSPECIAL)) == MTF_OBJECTSPECIAL) - mapthings[i].args[0] = TMGD_LEFT; + mapthings[i].thing_args[0] = TMGD_LEFT; else if ((mapthings[i].options & (MTF_EXTRA|MTF_OBJECTSPECIAL)) == MTF_EXTRA) - mapthings[i].args[0] = TMGD_RIGHT; + mapthings[i].thing_args[0] = TMGD_RIGHT; else - mapthings[i].args[0] = TMGD_BACK; - mapthings[i].args[1] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = TMGD_BACK; + mapthings[i].thing_args[1] = !!(mapthings[i].options & MTF_AMBUSH); break; case 127: //Hive Elemental - mapthings[i].args[0] = mapthings[i].extrainfo; + mapthings[i].thing_args[0] = mapthings[i].extrainfo; break; case 135: //Pterabyte Spawner - mapthings[i].args[0] = mapthings[i].extrainfo + 1; + mapthings[i].thing_args[0] = mapthings[i].extrainfo + 1; break; case 136: //Pyre Fly - mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_AMBUSH); break; case 201: //Egg Slimer - mapthings[i].args[5] = !(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[5] = !(mapthings[i].options & MTF_AMBUSH); break; case 203: //Egg Colosseum - mapthings[i].args[5] = LE_BOSS4DROP + mapthings[i].extrainfo * LE_PARAMWIDTH; + mapthings[i].thing_args[5] = LE_BOSS4DROP + mapthings[i].extrainfo * LE_PARAMWIDTH; break; case 204: //Fang - mapthings[i].args[4] = LE_BOSS4DROP + mapthings[i].extrainfo*LE_PARAMWIDTH; + mapthings[i].thing_args[4] = LE_BOSS4DROP + mapthings[i].extrainfo*LE_PARAMWIDTH; if (mapthings[i].options & MTF_EXTRA) - mapthings[i].args[5] |= TMF_GRAYSCALE; + mapthings[i].thing_args[5] |= TMF_GRAYSCALE; if (mapthings[i].options & MTF_AMBUSH) - mapthings[i].args[5] |= TMF_SKIPINTRO; + mapthings[i].thing_args[5] |= TMF_SKIPINTRO; break; case 206: //Brak Eggman (Old) - mapthings[i].args[5] = LE_BRAKPLATFORM + mapthings[i].extrainfo*LE_PARAMWIDTH; + mapthings[i].thing_args[5] = LE_BRAKPLATFORM + mapthings[i].extrainfo*LE_PARAMWIDTH; break; case 207: //Metal Sonic (Race) case 2104: //Amy Cameo - mapthings[i].args[0] = !!(mapthings[i].options & MTF_EXTRA); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_EXTRA); break; case 208: //Metal Sonic (Battle) - mapthings[i].args[5] = !!(mapthings[i].options & MTF_EXTRA); + mapthings[i].thing_args[5] = !!(mapthings[i].options & MTF_EXTRA); break; case 209: //Brak Eggman - mapthings[i].args[5] = LE_BRAKVILEATACK + mapthings[i].extrainfo*LE_PARAMWIDTH; + mapthings[i].thing_args[5] = LE_BRAKVILEATACK + mapthings[i].extrainfo*LE_PARAMWIDTH; if (mapthings[i].options & MTF_EXTRA) - mapthings[i].args[6] |= TMB_NODEATHFLING; + mapthings[i].thing_args[6] |= TMB_NODEATHFLING; if (mapthings[i].options & MTF_AMBUSH) - mapthings[i].args[6] |= TMB_BARRIER; + mapthings[i].thing_args[6] |= TMB_BARRIER; break; case 292: //Boss waypoint - mapthings[i].args[0] = mapthings[i].angle; - mapthings[i].args[1] = mapthings[i].options & 7; + mapthings[i].thing_args[0] = mapthings[i].angle; + mapthings[i].thing_args[1] = mapthings[i].options & 7; break; case 294: //Fang waypoint - mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_AMBUSH); break; case 300: //Ring case 301: //Bounce ring @@ -6641,13 +6745,13 @@ static void P_ConvertBinaryThingTypes(void) case 521: //Spikeball case 1706: //Blue sphere case 1800: //Coin - mapthings[i].args[0] = !(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = !(mapthings[i].options & MTF_AMBUSH); break; case 409: //Extra life monitor - mapthings[i].args[2] = !(mapthings[i].options & (MTF_AMBUSH|MTF_OBJECTSPECIAL)); + mapthings[i].thing_args[2] = !(mapthings[i].options & (MTF_AMBUSH|MTF_OBJECTSPECIAL)); break; case 500: //Air bubble patch - mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_AMBUSH); break; case 502: //Star post if (mapthings[i].extrainfo) @@ -6655,64 +6759,64 @@ static void P_ConvertBinaryThingTypes(void) // For starposts above param 15 (the 16th), add 360 to the angle like before and start parameter from 1 (NOT 0)! // So the 16th starpost is angle=0 param=15, the 17th would be angle=360 param=1. // This seems more intuitive for mappers to use, since most SP maps won't have over 16 consecutive star posts. - mapthings[i].args[0] = mapthings[i].extrainfo + (mapthings[i].angle/360) * 15; + mapthings[i].thing_args[0] = mapthings[i].extrainfo + (mapthings[i].angle/360) * 15; else // Old behavior if Parameter is 0; add 360 to the angle for each consecutive star post. - mapthings[i].args[0] = (mapthings[i].angle/360); - mapthings[i].args[1] = !!(mapthings[i].options & MTF_OBJECTSPECIAL); + mapthings[i].thing_args[0] = (mapthings[i].angle/360); + mapthings[i].thing_args[1] = !!(mapthings[i].options & MTF_OBJECTSPECIAL); break; case 522: //Wall spike if (mapthings[i].options & MTF_OBJECTSPECIAL) { - mapthings[i].args[0] = mobjinfo[MT_WALLSPIKE].speed + mapthings[i].angle/360; - mapthings[i].args[1] = (16 - mapthings[i].extrainfo) * mapthings[i].args[0]/16; + mapthings[i].thing_args[0] = mobjinfo[MT_WALLSPIKE].speed + mapthings[i].angle/360; + mapthings[i].thing_args[1] = (16 - mapthings[i].extrainfo) * mapthings[i].thing_args[0]/16; if (mapthings[i].options & MTF_EXTRA) - mapthings[i].args[2] |= TMSF_RETRACTED; + mapthings[i].thing_args[2] |= TMSF_RETRACTED; } if (mapthings[i].options & MTF_AMBUSH) - mapthings[i].args[2] |= TMSF_INTANGIBLE; + mapthings[i].thing_args[2] |= TMSF_INTANGIBLE; break; case 523: //Spike if (mapthings[i].options & MTF_OBJECTSPECIAL) { - mapthings[i].args[0] = mobjinfo[MT_SPIKE].speed + mapthings[i].angle; - mapthings[i].args[1] = (16 - mapthings[i].extrainfo) * mapthings[i].args[0]/16; + mapthings[i].thing_args[0] = mobjinfo[MT_SPIKE].speed + mapthings[i].angle; + mapthings[i].thing_args[1] = (16 - mapthings[i].extrainfo) * mapthings[i].thing_args[0]/16; if (mapthings[i].options & MTF_EXTRA) - mapthings[i].args[2] |= TMSF_RETRACTED; + mapthings[i].thing_args[2] |= TMSF_RETRACTED; } if (mapthings[i].options & MTF_AMBUSH) - mapthings[i].args[2] |= TMSF_INTANGIBLE; + mapthings[i].thing_args[2] |= TMSF_INTANGIBLE; break; case 540: //Fan - mapthings[i].args[0] = mapthings[i].angle; + mapthings[i].thing_args[0] = mapthings[i].angle; if (mapthings[i].options & MTF_OBJECTSPECIAL) - mapthings[i].args[1] |= TMF_INVISIBLE; + mapthings[i].thing_args[1] |= TMF_INVISIBLE; if (mapthings[i].options & MTF_AMBUSH) - mapthings[i].args[1] |= TMF_NODISTANCECHECK; + mapthings[i].thing_args[1] |= TMF_NODISTANCECHECK; break; case 541: //Gas jet - mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); - mapthings[i].args[1] = !!(mapthings[i].options & MTF_OBJECTSPECIAL); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[1] = !!(mapthings[i].options & MTF_OBJECTSPECIAL); break; case 543: //Balloon if (mapthings[i].angle > 0) { - P_WriteSkincolor(((mapthings[i].angle - 1) % (numskincolors - 1)) + 1, &mapthings[i].stringargs[0]); + P_WriteSkincolor(((mapthings[i].angle - 1) % (numskincolors - 1)) + 1, &mapthings[i].thing_stringargs[0]); } - mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_AMBUSH); break; case 555: //Diagonal yellow spring case 556: //Diagonal red spring case 557: //Diagonal blue spring if (mapthings[i].options & MTF_OBJECTSPECIAL) - mapthings[i].args[0] |= TMDS_NOGRAVITY; + mapthings[i].thing_args[0] |= TMDS_NOGRAVITY; if (mapthings[i].options & MTF_AMBUSH) - mapthings[i].args[0] |= TMDS_ROTATEEXTRA; + mapthings[i].thing_args[0] |= TMDS_ROTATEEXTRA; break; case 558: //Horizontal yellow spring case 559: //Horizontal red spring case 560: //Horizontal blue spring - mapthings[i].args[0] = !(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = !(mapthings[i].options & MTF_AMBUSH); break; case 700: //Water ambience A case 701: //Water ambience B @@ -6722,31 +6826,31 @@ static void P_ConvertBinaryThingTypes(void) case 705: //Water ambience F case 706: //Water ambience G case 707: //Water ambience H - mapthings[i].args[0] = 35; - P_WriteSfx(sfx_amwtr1 + mapthings[i].type - 700, &mapthings[i].stringargs[0]); + mapthings[i].thing_args[0] = 35; + P_WriteSfx(sfx_amwtr1 + mapthings[i].type - 700, &mapthings[i].thing_stringargs[0]); mapthings[i].type = 700; break; case 708: //Disco ambience - mapthings[i].args[0] = 512; - P_WriteSfx(sfx_ambint, &mapthings[i].stringargs[0]); + mapthings[i].thing_args[0] = 512; + P_WriteSfx(sfx_ambint, &mapthings[i].thing_stringargs[0]); mapthings[i].type = 700; break; case 709: //Volcano ambience - mapthings[i].args[0] = 220; - P_WriteSfx(sfx_ambin2, &mapthings[i].stringargs[0]); + mapthings[i].thing_args[0] = 220; + P_WriteSfx(sfx_ambin2, &mapthings[i].thing_stringargs[0]); mapthings[i].type = 700; break; case 710: //Machine ambience - mapthings[i].args[0] = 24; - P_WriteSfx(sfx_ambmac, &mapthings[i].stringargs[0]); + mapthings[i].thing_args[0] = 24; + P_WriteSfx(sfx_ambmac, &mapthings[i].thing_stringargs[0]); mapthings[i].type = 700; break; case 750: //Slope vertex - mapthings[i].args[0] = mapthings[i].extrainfo; + mapthings[i].thing_args[0] = mapthings[i].extrainfo; break; case 753: //Zoom tube waypoint - mapthings[i].args[0] = mapthings[i].angle >> 8; - mapthings[i].args[1] = mapthings[i].angle & 255; + mapthings[i].thing_args[0] = mapthings[i].angle >> 8; + mapthings[i].thing_args[1] = mapthings[i].angle & 255; break; case 754: //Push point case 755: //Pull point @@ -6770,21 +6874,21 @@ static void P_ConvertBinaryThingTypes(void) break; } - mapthings[i].args[0] = mapthings[i].angle; - mapthings[i].args[1] = P_AproxDistance(line->dx >> FRACBITS, line->dy >> FRACBITS); + mapthings[i].thing_args[0] = mapthings[i].angle; + mapthings[i].thing_args[1] = P_AproxDistance(line->dx >> FRACBITS, line->dy >> FRACBITS); if (mapthings[i].type == 755) - mapthings[i].args[1] *= -1; + mapthings[i].thing_args[1] *= -1; if (mapthings[i].options & MTF_OBJECTSPECIAL) - mapthings[i].args[2] |= TMPP_NOZFADE; + mapthings[i].thing_args[2] |= TMPP_NOZFADE; if (mapthings[i].options & MTF_AMBUSH) - mapthings[i].args[2] |= TMPP_PUSHZ; + mapthings[i].thing_args[2] |= TMPP_PUSHZ; if (!(line->flags & ML_NOCLIMB)) - mapthings[i].args[2] |= TMPP_NONEXCLUSIVE; + mapthings[i].thing_args[2] |= TMPP_NONEXCLUSIVE; mapthings[i].type = 754; break; } case 756: //Blast linedef executor - mapthings[i].args[0] = mapthings[i].angle; + mapthings[i].thing_args[0] = mapthings[i].angle; break; case 757: //Fan particle generator { @@ -6795,13 +6899,13 @@ static void P_ConvertBinaryThingTypes(void) CONS_Debug(DBG_GAMELOGIC, "Particle generator (mapthing #%s) needs to be tagged to a #15 parameter line (trying to find tag %d).\n", sizeu1(i), mapthings[i].angle); break; } - mapthings[i].args[0] = mapthings[i].z; - mapthings[i].args[1] = R_PointToDist2(lines[j].v1->x, lines[j].v1->y, lines[j].v2->x, lines[j].v2->y) >> FRACBITS; - mapthings[i].args[2] = sides[lines[j].sidenum[0]].textureoffset >> FRACBITS; - mapthings[i].args[3] = sides[lines[j].sidenum[0]].rowoffset >> FRACBITS; - mapthings[i].args[4] = lines[j].backsector ? sides[lines[j].sidenum[1]].textureoffset >> FRACBITS : 0; - mapthings[i].args[6] = mapthings[i].angle; - P_WriteDuplicateText(lines[j].stringargs[0], &mapthings[i].stringargs[0]); + mapthings[i].thing_args[0] = mapthings[i].z; + mapthings[i].thing_args[1] = R_PointToDist2(lines[j].v1->x, lines[j].v1->y, lines[j].v2->x, lines[j].v2->y) >> FRACBITS; + mapthings[i].thing_args[2] = sides[lines[j].sidenum[0]].textureoffset >> FRACBITS; + mapthings[i].thing_args[3] = sides[lines[j].sidenum[0]].rowoffset >> FRACBITS; + mapthings[i].thing_args[4] = lines[j].backsector ? sides[lines[j].sidenum[1]].textureoffset >> FRACBITS : 0; + mapthings[i].thing_args[6] = mapthings[i].angle; + P_WriteDuplicateText(lines[j].stringargs[0], &mapthings[i].thing_stringargs[0]); break; } case 762: //PolyObject spawn point (crush) @@ -6825,21 +6929,21 @@ static void P_ConvertBinaryThingTypes(void) break; } case 780: //Skybox - mapthings[i].args[0] = !!(mapthings[i].options & MTF_OBJECTSPECIAL); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_OBJECTSPECIAL); break; case 799: //Tutorial plant - mapthings[i].args[0] = mapthings[i].extrainfo; + mapthings[i].thing_args[0] = mapthings[i].extrainfo; break; case 1002: //Dripping water - mapthings[i].args[0] = mapthings[i].angle; + mapthings[i].thing_args[0] = mapthings[i].angle; break; case 1007: //Kelp case 1008: //Stalagmite (DSZ1) case 1011: //Stalagmite (DSZ2) - mapthings[i].args[0] = !!(mapthings[i].options & MTF_OBJECTSPECIAL); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_OBJECTSPECIAL); break; case 1102: //Eggman Statue - mapthings[i].args[1] = !!(mapthings[i].options & MTF_EXTRA); + mapthings[i].thing_args[1] = !!(mapthings[i].options & MTF_EXTRA); break; case 1104: //Mace spawnpoint case 1105: //Chain with maces spawnpoint @@ -6859,63 +6963,63 @@ static void P_ConvertBinaryThingTypes(void) mapthings[i].angle = lines[j].frontsector->ceilingheight >> FRACBITS; mapthings[i].pitch = lines[j].frontsector->floorheight >> FRACBITS; - mapthings[i].args[0] = lines[j].dx >> FRACBITS; - mapthings[i].args[1] = mapthings[i].extrainfo; - mapthings[i].args[3] = lines[j].dy >> FRACBITS; - mapthings[i].args[4] = sides[lines[j].sidenum[0]].textureoffset >> FRACBITS; - mapthings[i].args[7] = -sides[lines[j].sidenum[0]].rowoffset >> FRACBITS; + mapthings[i].thing_args[0] = lines[j].dx >> FRACBITS; + mapthings[i].thing_args[1] = mapthings[i].extrainfo; + mapthings[i].thing_args[3] = lines[j].dy >> FRACBITS; + mapthings[i].thing_args[4] = sides[lines[j].sidenum[0]].textureoffset >> FRACBITS; + mapthings[i].thing_args[7] = -sides[lines[j].sidenum[0]].rowoffset >> FRACBITS; if (lines[j].backsector) { mapthings[i].roll = lines[j].backsector->ceilingheight >> FRACBITS; - mapthings[i].args[2] = sides[lines[j].sidenum[1]].rowoffset >> FRACBITS; - mapthings[i].args[5] = lines[j].backsector->floorheight >> FRACBITS; - mapthings[i].args[6] = sides[lines[j].sidenum[1]].textureoffset >> FRACBITS; + mapthings[i].thing_args[2] = sides[lines[j].sidenum[1]].rowoffset >> FRACBITS; + mapthings[i].thing_args[5] = lines[j].backsector->floorheight >> FRACBITS; + mapthings[i].thing_args[6] = sides[lines[j].sidenum[1]].textureoffset >> FRACBITS; } if (mapthings[i].options & MTF_AMBUSH) - mapthings[i].args[8] |= TMM_DOUBLESIZE; + mapthings[i].thing_args[8] |= TMM_DOUBLESIZE; if (mapthings[i].options & MTF_OBJECTSPECIAL) - mapthings[i].args[8] |= TMM_SILENT; + mapthings[i].thing_args[8] |= TMM_SILENT; if (lines[j].flags & ML_NOCLIMB) - mapthings[i].args[8] |= TMM_ALLOWYAWCONTROL; + mapthings[i].thing_args[8] |= TMM_ALLOWYAWCONTROL; if (lines[j].flags & ML_SKEWTD) - mapthings[i].args[8] |= TMM_SWING; + mapthings[i].thing_args[8] |= TMM_SWING; if (lines[j].flags & ML_NOSKEW) - mapthings[i].args[8] |= TMM_MACELINKS; + mapthings[i].thing_args[8] |= TMM_MACELINKS; if (lines[j].flags & ML_MIDPEG) - mapthings[i].args[8] |= TMM_CENTERLINK; + mapthings[i].thing_args[8] |= TMM_CENTERLINK; if (lines[j].flags & ML_MIDSOLID) - mapthings[i].args[8] |= TMM_CLIP; + mapthings[i].thing_args[8] |= TMM_CLIP; if (lines[j].flags & ML_WRAPMIDTEX) - mapthings[i].args[8] |= TMM_ALWAYSTHINK; + mapthings[i].thing_args[8] |= TMM_ALWAYSTHINK; if (mapthings[i].type == 1110) { - P_WriteDuplicateText(lines[j].stringargs[0], &mapthings[i].stringargs[0]); - P_WriteDuplicateText(lines[j].stringargs[1], &mapthings[i].stringargs[1]); + P_WriteDuplicateText(lines[j].stringargs[0], &mapthings[i].thing_stringargs[0]); + P_WriteDuplicateText(lines[j].stringargs[1], &mapthings[i].thing_stringargs[1]); } break; } case 1101: //Torch case 1119: //Candle case 1120: //Candle pricket - mapthings[i].args[0] = !!(mapthings[i].options & MTF_EXTRA); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_EXTRA); break; case 1121: //Flame holder if (mapthings[i].options & MTF_OBJECTSPECIAL) - mapthings[i].args[0] |= TMFH_NOFLAME; + mapthings[i].thing_args[0] |= TMFH_NOFLAME; if (mapthings[i].options & MTF_EXTRA) - mapthings[i].args[0] |= TMFH_CORONA; + mapthings[i].thing_args[0] |= TMFH_CORONA; break; case 1127: //Spectator EggRobo if (mapthings[i].options & MTF_AMBUSH) - mapthings[i].args[0] = TMED_LEFT; + mapthings[i].thing_args[0] = TMED_LEFT; else if (mapthings[i].options & MTF_OBJECTSPECIAL) - mapthings[i].args[0] = TMED_RIGHT; + mapthings[i].thing_args[0] = TMED_RIGHT; else - mapthings[i].args[0] = TMED_NONE; + mapthings[i].thing_args[0] = TMED_NONE; break; case 1200: //Tumbleweed (Big) case 1201: //Tumbleweed (Small) - mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_AMBUSH); break; case 1202: //Rock spawner { @@ -6928,73 +7032,73 @@ static void P_ConvertBinaryThingTypes(void) break; } mapthings[i].angle = AngleFixed(R_PointToAngle2(lines[j].v2->x, lines[j].v2->y, lines[j].v1->x, lines[j].v1->y)) >> FRACBITS; - mapthings[i].args[0] = P_AproxDistance(lines[j].dx, lines[j].dy) >> FRACBITS; - mapthings[i].args[1] = sides[lines[j].sidenum[0]].textureoffset >> FRACBITS; - mapthings[i].args[2] = !!(lines[j].flags & ML_NOCLIMB); + mapthings[i].thing_args[0] = P_AproxDistance(lines[j].dx, lines[j].dy) >> FRACBITS; + mapthings[i].thing_args[1] = sides[lines[j].sidenum[0]].textureoffset >> FRACBITS; + mapthings[i].thing_args[2] = !!(lines[j].flags & ML_NOCLIMB); INT32 id = (sides[lines[j].sidenum[0]].rowoffset >> FRACBITS); // Rather than introduce deh_tables.h as a dependency for literally one // conversion, we just... recreate the string expected to be produced. if (id > 0 && id < 16) - P_WriteDuplicateText(va("MT_ROCKCRUMBLE%d", id+1), &mapthings[i].stringargs[0]); + P_WriteDuplicateText(va("MT_ROCKCRUMBLE%d", id+1), &mapthings[i].thing_stringargs[0]); break; } case 1221: //Minecart saloon door - mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_AMBUSH); break; case 1229: //Minecart switch point - mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_AMBUSH); break; case 1300: //Flame jet (horizontal) case 1301: //Flame jet (vertical) - mapthings[i].args[0] = (mapthings[i].angle >> 13)*TICRATE/2; - mapthings[i].args[1] = ((mapthings[i].angle >> 10) & 7)*TICRATE/2; - mapthings[i].args[2] = 80 - 5*mapthings[i].extrainfo; - mapthings[i].args[3] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = (mapthings[i].angle >> 13)*TICRATE/2; + mapthings[i].thing_args[1] = ((mapthings[i].angle >> 10) & 7)*TICRATE/2; + mapthings[i].thing_args[2] = 80 - 5*mapthings[i].extrainfo; + mapthings[i].thing_args[3] = !!(mapthings[i].options & MTF_AMBUSH); break; case 1304: //Lavafall - mapthings[i].args[0] = mapthings[i].angle; - mapthings[i].args[1] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = mapthings[i].angle; + mapthings[i].thing_args[1] = !!(mapthings[i].options & MTF_AMBUSH); break; case 1305: //Rollout Rock - mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_AMBUSH); break; case 1488: // Follower Audience (unfortunately numbered) if (mapthings[i].options & MTF_OBJECTSPECIAL) - mapthings[i].args[2] |= TMAUDIM_FLOAT; + mapthings[i].thing_args[2] |= TMAUDIM_FLOAT; if (mapthings[i].options & MTF_EXTRA) - mapthings[i].args[2] |= TMAUDIM_BORED; + mapthings[i].thing_args[2] |= TMAUDIM_BORED; - mapthings[i].args[3] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[3] = !!(mapthings[i].options & MTF_AMBUSH); break; case 1500: //Glaregoyle case 1501: //Glaregoyle (Up) case 1502: //Glaregoyle (Down) case 1503: //Glaregoyle (Long) if (mapthings[i].angle >= 360) - mapthings[i].args[1] = 7*(mapthings[i].angle/360) + 1; + mapthings[i].thing_args[1] = 7*(mapthings[i].angle/360) + 1; break; case 1700: //Axis - mapthings[i].args[2] = mapthings[i].angle & 16383; - mapthings[i].args[3] = !!(mapthings[i].angle & 16384); + mapthings[i].thing_args[2] = mapthings[i].angle & 16383; + mapthings[i].thing_args[3] = !!(mapthings[i].angle & 16384); /* FALLTHRU */ case 1701: //Axis transfer case 1702: //Axis transfer line - mapthings[i].args[0] = mapthings[i].extrainfo; - mapthings[i].args[1] = mapthings[i].options; + mapthings[i].thing_args[0] = mapthings[i].extrainfo; + mapthings[i].thing_args[1] = mapthings[i].options; break; case 1703: //Ideya drone - mapthings[i].args[0] = mapthings[i].angle & 0xFFF; - mapthings[i].args[1] = mapthings[i].extrainfo*32; - mapthings[i].args[2] = ((mapthings[i].angle & 0xF000) >> 12)*32; + mapthings[i].thing_args[0] = mapthings[i].angle & 0xFFF; + mapthings[i].thing_args[1] = mapthings[i].extrainfo*32; + mapthings[i].thing_args[2] = ((mapthings[i].angle & 0xF000) >> 12)*32; if ((mapthings[i].options & (MTF_OBJECTSPECIAL|MTF_EXTRA)) == (MTF_OBJECTSPECIAL|MTF_EXTRA)) - mapthings[i].args[3] = TMDA_BOTTOM; + mapthings[i].thing_args[3] = TMDA_BOTTOM; else if ((mapthings[i].options & (MTF_OBJECTSPECIAL|MTF_EXTRA)) == MTF_OBJECTSPECIAL) - mapthings[i].args[3] = TMDA_TOP; + mapthings[i].thing_args[3] = TMDA_TOP; else if ((mapthings[i].options & (MTF_OBJECTSPECIAL|MTF_EXTRA)) == MTF_EXTRA) - mapthings[i].args[3] = TMDA_MIDDLE; + mapthings[i].thing_args[3] = TMDA_MIDDLE; else - mapthings[i].args[3] = TMDA_BOTTOMOFFSET; - mapthings[i].args[4] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[3] = TMDA_BOTTOMOFFSET; + mapthings[i].thing_args[4] = !!(mapthings[i].options & MTF_AMBUSH); break; case 1704: //NiGHTS bumper mapthings[i].pitch = 30 * (((mapthings[i].options & 15) + 9) % 12); @@ -7006,31 +7110,31 @@ static void P_ConvertBinaryThingTypes(void) UINT16 oldangle = mapthings[i].angle; mapthings[i].angle = ((oldangle >> 8)*360)/256; mapthings[i].pitch = ((oldangle & 255)*360)/256; - mapthings[i].args[0] = (mapthings[i].type == 1705) ? 96 : (mapthings[i].options & 0xF)*16 + 32; + mapthings[i].thing_args[0] = (mapthings[i].type == 1705) ? 96 : (mapthings[i].options & 0xF)*16 + 32; mapthings[i].options &= ~0xF; mapthings[i].type = 1713; break; } case 1710: //Ideya capture - mapthings[i].args[0] = mapthings[i].extrainfo; - mapthings[i].args[1] = mapthings[i].angle; + mapthings[i].thing_args[0] = mapthings[i].extrainfo; + mapthings[i].thing_args[1] = mapthings[i].angle; break; case 1714: //Ideya anchor point - mapthings[i].args[0] = mapthings[i].extrainfo; + mapthings[i].thing_args[0] = mapthings[i].extrainfo; break; case 1806: //King Bowser - mapthings[i].args[0] = LE_KOOPA; + mapthings[i].thing_args[0] = LE_KOOPA; break; case 1807: //Axe - mapthings[i].args[0] = LE_AXE; + mapthings[i].thing_args[0] = LE_AXE; break; case 2000: //Smashing spikeball - mapthings[i].args[0] = mapthings[i].angle; + mapthings[i].thing_args[0] = mapthings[i].angle; break; case 2006: //Jack-o'-lantern 1 case 2007: //Jack-o'-lantern 2 case 2008: //Jack-o'-lantern 3 - mapthings[i].args[0] = !!(mapthings[i].options & MTF_EXTRA); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_EXTRA); break; case 2001: // MT_WAYPOINT { @@ -7038,7 +7142,7 @@ static void P_ConvertBinaryThingTypes(void) mapthings[i].tid = mapthings[i].angle; - mapthings[i].args[0] = mapthings[i].z; + mapthings[i].thing_args[0] = mapthings[i].z; mapthings[i].z = 0; if (firstline != -1) @@ -7047,106 +7151,106 @@ static void P_ConvertBinaryThingTypes(void) fixed_t linez = sides[lines[firstline].sidenum[0]].rowoffset; if (lineradius > 0) - mapthings[i].args[1] = lineradius / FRACUNIT; + mapthings[i].thing_args[1] = lineradius / FRACUNIT; mapthings[i].z = linez / FRACUNIT; } if (mapthings[i].extrainfo == 1) { - mapthings[i].args[2] |= TMWPF_FINISHLINE; + mapthings[i].thing_args[2] |= TMWPF_FINISHLINE; } if (mapthings[i].options & MTF_EXTRA) { - mapthings[i].args[2] |= TMWPF_DISABLED; + mapthings[i].thing_args[2] |= TMWPF_DISABLED; } if (mapthings[i].options & MTF_OBJECTSPECIAL) { - mapthings[i].args[2] |= TMWPF_SHORTCUT; + mapthings[i].thing_args[2] |= TMWPF_SHORTCUT; } if (mapthings[i].options & MTF_AMBUSH) { - mapthings[i].args[2] |= TMWPF_NORESPAWN; + mapthings[i].thing_args[2] |= TMWPF_NORESPAWN; } break; } case 2004: // MT_BOTHINT - mapthings[i].args[0] = mapthings[i].angle; - mapthings[i].args[1] = mapthings[i].extrainfo; - mapthings[i].args[2] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[0] = mapthings[i].angle; + mapthings[i].thing_args[1] = mapthings[i].extrainfo; + mapthings[i].thing_args[2] = !!(mapthings[i].options & MTF_AMBUSH); break; case 2010: // MT_ITEMCAPSULE - mapthings[i].args[0] = mapthings[i].angle; - mapthings[i].args[1] = mapthings[i].extrainfo; + mapthings[i].thing_args[0] = mapthings[i].angle; + mapthings[i].thing_args[1] = mapthings[i].extrainfo; if (mapthings[i].options & MTF_OBJECTSPECIAL) { // Special = +16 items (+80 for rings) - mapthings[i].args[1] += 16; + mapthings[i].thing_args[1] += 16; } if (mapthings[i].options & MTF_EXTRA) { // was advertised as an "invert time attack" flag, actually was an "all gamemodes" flag - mapthings[i].args[3] = TMICM_MULTIPLAYER|TMICM_TIMEATTACK; + mapthings[i].thing_args[3] = TMICM_MULTIPLAYER|TMICM_TIMEATTACK; } else { - mapthings[i].args[3] = TMICM_DEFAULT; + mapthings[i].thing_args[3] = TMICM_DEFAULT; } if (mapthings[i].options & MTF_AMBUSH) { - mapthings[i].args[2] |= TMICF_INVERTSIZE; + mapthings[i].thing_args[2] |= TMICF_INVERTSIZE; } break; case 2020: // MT_LOOPENDPOINT { - mapthings[i].args[0] = + mapthings[i].thing_args[0] = mapthings[i].options & MTF_AMBUSH ? TMLOOP_BETA : TMLOOP_ALPHA; break; } case 2021: // MT_LOOPCENTERPOINT - mapthings[i].args[0] = (mapthings[i].options & MTF_AMBUSH) == MTF_AMBUSH; - mapthings[i].args[1] = mapthings[i].angle; + mapthings[i].thing_args[0] = (mapthings[i].options & MTF_AMBUSH) == MTF_AMBUSH; + mapthings[i].thing_args[1] = mapthings[i].angle; break; case 2050: // MT_DUELBOMB - mapthings[i].args[1] = !!(mapthings[i].options & MTF_AMBUSH); + mapthings[i].thing_args[1] = !!(mapthings[i].options & MTF_AMBUSH); break; case 1950: // MT_AAZTREE_HELPER - mapthings[i].args[0] = mapthings[i].extrainfo; - mapthings[i].args[1] = mapthings[i].angle; + mapthings[i].thing_args[0] = mapthings[i].extrainfo; + mapthings[i].thing_args[1] = mapthings[i].angle; break; case 2333: // MT_BATTLECAPSULE - mapthings[i].args[0] = mapthings[i].extrainfo; - mapthings[i].args[1] = mapthings[i].angle; + mapthings[i].thing_args[0] = mapthings[i].extrainfo; + mapthings[i].thing_args[1] = mapthings[i].angle; if (mapthings[i].options & MTF_OBJECTSPECIAL) { - mapthings[i].args[2] |= TMBCF_REVERSE; + mapthings[i].thing_args[2] |= TMBCF_REVERSE; } if (mapthings[i].options & MTF_AMBUSH) { - mapthings[i].args[2] |= TMBCF_BACKANDFORTH; + mapthings[i].thing_args[2] |= TMBCF_BACKANDFORTH; } break; case 3122: // MT_MAYONAKAARROW if (mapthings[i].options & MTF_OBJECTSPECIAL) - mapthings[i].args[0] = TMMA_WARN; + mapthings[i].thing_args[0] = TMMA_WARN; else if (mapthings[i].options & MTF_EXTRA) - mapthings[i].args[0] = TMMA_FLIP; + mapthings[i].thing_args[0] = TMMA_FLIP; break; case 2018: // MT_PETSMOKER - mapthings[i].args[0] = !!(mapthings[i].options & MTF_OBJECTSPECIAL); + mapthings[i].thing_args[0] = !!(mapthings[i].options & MTF_OBJECTSPECIAL); break; case 3786: // MT_BATTLEUFO_SPAWNER - mapthings[i].args[0] = mapthings[i].angle; + mapthings[i].thing_args[0] = mapthings[i].angle; break; case 3400: // MT_WATERPALACETURBINE (TODO: not yet hardcoded) { @@ -7168,55 +7272,55 @@ static void P_ConvertBinaryThingTypes(void) mapthings[i].angle = sides[lines[j].sidenum[0]].rowoffset >> FRACBITS; if (mapthings[i].options & MTF_EXTRA) - mapthings[i].args[0] = 1; + mapthings[i].thing_args[0] = 1; if (mapthings[i].options & MTF_OBJECTSPECIAL) - mapthings[i].args[1] = 1; + mapthings[i].thing_args[1] = 1; - mapthings[i].args[2] = lines[j].frontsector->floorheight >> FRACBITS; - mapthings[i].args[3] = lines[j].frontsector->ceilingheight >> FRACBITS; + mapthings[i].thing_args[2] = lines[j].frontsector->floorheight >> FRACBITS; + mapthings[i].thing_args[3] = lines[j].frontsector->ceilingheight >> FRACBITS; - mapthings[i].args[4] = lines[j].backsector->floorheight >> FRACBITS; + mapthings[i].thing_args[4] = lines[j].backsector->floorheight >> FRACBITS; - mapthings[i].args[5] = sides[lines[j].sidenum[0]].textureoffset >> FRACBITS; - if (mapthings[i].args[5] < 0) - mapthings[i].args[5] = -mapthings[i].args[5]; + mapthings[i].thing_args[5] = sides[lines[j].sidenum[0]].textureoffset >> FRACBITS; + if (mapthings[i].thing_args[5] < 0) + mapthings[i].thing_args[5] = -mapthings[i].thing_args[5]; - mapthings[i].args[6] = sides[lines[j].sidenum[1]].rowoffset >> FRACBITS; - if (mapthings[i].args[6] < 0) - mapthings[i].args[6] = -mapthings[i].args[6]; + mapthings[i].thing_args[6] = sides[lines[j].sidenum[1]].rowoffset >> FRACBITS; + if (mapthings[i].thing_args[6] < 0) + mapthings[i].thing_args[6] = -mapthings[i].thing_args[6]; - mapthings[i].args[7] = sides[lines[j].sidenum[1]].textureoffset >> FRACBITS; - if (mapthings[i].args[7] < 0) - mapthings[i].args[7] = -mapthings[i].args[7]; + mapthings[i].thing_args[7] = sides[lines[j].sidenum[1]].textureoffset >> FRACBITS; + if (mapthings[i].thing_args[7] < 0) + mapthings[i].thing_args[7] = -mapthings[i].thing_args[7]; if (lines[j].flags & ML_SKEWTD) - mapthings[i].args[8] = R_PointToDist2(lines[j].v2->x, lines[j].v2->y, lines[j].v1->x, lines[j].v1->y) >> FRACBITS; + mapthings[i].thing_args[8] = R_PointToDist2(lines[j].v2->x, lines[j].v2->y, lines[j].v1->x, lines[j].v1->y) >> FRACBITS; if (lines[j].flags & ML_NOSKEW) - mapthings[i].args[9] = 1; + mapthings[i].thing_args[9] = 1; break; } case 3441: // MT_DASHRING (TODO: not yet hardcoded) case 3442: // MT_RAINBOWDASHRING (TODO: not yet hardcoded) - mapthings[i].args[0] = mapthings[i].options & 13; - mapthings[i].args[1] = mapthings[i].extrainfo; + mapthings[i].thing_args[0] = mapthings[i].options & 13; + mapthings[i].thing_args[1] = mapthings[i].extrainfo; break; case FLOOR_SLOPE_THING: case CEILING_SLOPE_THING: - mapthings[i].args[0] = mapthings[i].extrainfo; + mapthings[i].thing_args[0] = mapthings[i].extrainfo; break; case 4094: // MT_ARKARROW - mapthings[i].args[0] = mapthings[i].extrainfo; + mapthings[i].thing_args[0] = mapthings[i].extrainfo; if (mapthings[i].options & MTF_OBJECTSPECIAL) { // Special = add 16 to the symbol type - mapthings[i].args[0] += 16; + mapthings[i].thing_args[0] += 16; } if (mapthings[i].options & MTF_AMBUSH) { // Ambush = add 32 to the symbol type - mapthings[i].args[0] += 32; + mapthings[i].thing_args[0] += 32; } break; default: @@ -7267,9 +7371,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 @@ -7338,7 +7439,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; @@ -7355,6 +7458,9 @@ static boolean P_LoadMapFromFile(void) if (!udmf) P_ConvertBinaryMap(); + 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); diff --git a/src/p_slopes.c b/src/p_slopes.c index d8cbee616..771cdbc1c 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -640,7 +640,7 @@ static pslope_t *MakeViaMapthings(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag vx[i].x = mt->x << FRACBITS; vx[i].y = mt->y << FRACBITS; vx[i].z = mt->z << FRACBITS; - if (!mt->args[0]) + if (!mt->thing_args[0]) vx[i].z += R_PointInSubsector(vx[i].x, vx[i].y)->sector->floorheight; } diff --git a/src/p_spec.c b/src/p_spec.c index 5bb9131cb..b640a9c41 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); @@ -4281,7 +4281,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; @@ -4326,7 +4326,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]) @@ -4335,17 +4335,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]) @@ -4354,12 +4354,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 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; diff --git a/src/slope_anchors.c b/src/slope_anchors.c index f5bbdccdb..05eebce7d 100644 --- a/src/slope_anchors.c +++ b/src/slope_anchors.c @@ -199,7 +199,7 @@ get_anchor for (i = 0; i < list->count; ++i) { - if (list->points[i] == v && list->anchors[i]->args[0] == group) + if (list->points[i] == v && list->anchors[i]->thing_args[0] == group) { for (k = 0; k < 3; ++k) {