Merge branch 'scale-mishap' into 'next'

Make UDMF scale compatible with ZDoom's spec

See merge request STJr/SRB2!2086
This commit is contained in:
Sal 2023-08-04 20:05:35 +00:00
commit 9e72b78a24
4 changed files with 35 additions and 3 deletions

View file

@ -211,6 +211,7 @@ typedef struct
UINT8 extrainfo;
taglist_t tags;
fixed_t scale;
fixed_t spritexscale, spriteyscale;
INT32 args[NUMMAPTHINGARGS];
char *stringargs[NUMMAPTHINGSTRINGARGS];
struct mobj_s *mobj;

View file

@ -925,6 +925,8 @@ enum mapthing_e {
mapthing_type,
mapthing_options,
mapthing_scale,
mapthing_spritexscale,
mapthing_spriteyscale,
mapthing_z,
mapthing_extrainfo,
mapthing_tag,
@ -944,6 +946,8 @@ const char *const mapthing_opt[] = {
"type",
"options",
"scale",
"spritexscale",
"spriteyscale",
"z",
"extrainfo",
"tag",
@ -999,7 +1003,13 @@ static int mapthing_get(lua_State *L)
lua_pushinteger(L, mt->options);
break;
case mapthing_scale:
lua_pushinteger(L, mt->scale);
lua_pushfixed(L, mt->scale);
break;
case mapthing_spritexscale:
lua_pushfixed(L, mt->spritexscale);
break;
case mapthing_spriteyscale:
lua_pushfixed(L, mt->spriteyscale);
break;
case mapthing_z:
lua_pushinteger(L, mt->z);
@ -1072,6 +1082,12 @@ static int mapthing_set(lua_State *L)
case mapthing_scale:
mt->scale = luaL_checkfixed(L, 3);
break;
case mapthing_spritexscale:
mt->spritexscale = luaL_checkfixed(L, 3);
break;
case mapthing_spriteyscale:
mt->spriteyscale = luaL_checkfixed(L, 3);
break;
case mapthing_z:
mt->z = (INT16)luaL_checkinteger(L, 3);
break;

View file

@ -13332,6 +13332,9 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y,
P_SetScale(mobj, FixedMul(mobj->scale, mthing->scale));
mobj->destscale = FixedMul(mobj->destscale, mthing->scale);
mobj->spritexscale = mthing->spritexscale;
mobj->spriteyscale = mthing->spriteyscale;
if (!P_SetupSpawnedMapThing(mthing, mobj, &doangle))
return mobj;

View file

@ -1510,6 +1510,7 @@ static void P_LoadThings(UINT8 *data)
mt->extrainfo = (UINT8)(mt->type >> 12);
Tag_FSet(&mt->tags, 0);
mt->scale = FRACUNIT;
mt->spritexscale = mt->spriteyscale = FRACUNIT;
memset(mt->args, 0, NUMMAPTHINGARGS*sizeof(*mt->args));
memset(mt->stringargs, 0x00, NUMMAPTHINGSTRINGARGS*sizeof(*mt->stringargs));
mt->pitch = mt->roll = 0;
@ -2013,7 +2014,13 @@ static void ParseTextmapThingParameter(UINT32 i, const char *param, const char *
mapthings[i].roll = atol(val);
else if (fastcmp(param, "type"))
mapthings[i].type = atol(val);
else if (fastcmp(param, "scale") || fastcmp(param, "scalex") || fastcmp(param, "scaley"))
else if (fastcmp(param, "scale"))
mapthings[i].spritexscale = mapthings[i].spriteyscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "scalex"))
mapthings[i].spritexscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "scaley"))
mapthings[i].spriteyscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "mobjscale"))
mapthings[i].scale = FLOAT_TO_FIXED(atof(val));
// Flags
else if (fastcmp(param, "flip") && fastcmp("true", val))
@ -2431,8 +2438,12 @@ static void P_WriteTextmap(void)
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");
for (j = 0; j < NUMMAPTHINGARGS; j++)
@ -2978,6 +2989,7 @@ static void P_LoadTextmap(void)
mt->extrainfo = 0;
Tag_FSet(&mt->tags, 0);
mt->scale = FRACUNIT;
mt->spritexscale = mt->spriteyscale = FRACUNIT;
memset(mt->args, 0, NUMMAPTHINGARGS*sizeof(*mt->args));
memset(mt->stringargs, 0x00, NUMMAPTHINGSTRINGARGS*sizeof(*mt->stringargs));
mt->mobj = NULL;