Make UDMF scale compatible with ZDoom's spec

This commit is contained in:
Sal 2023-08-04 20:05:35 +00:00 committed by Sally Coolatta
parent 55b8609251
commit eb72019426
4 changed files with 24 additions and 2 deletions

View file

@ -270,6 +270,7 @@ struct mapthing_t
UINT8 extrainfo;
mtag_t tid;
fixed_t scale;
fixed_t spritexscale, spriteyscale;
INT16 special;
INT32 args[NUM_MAPTHING_ARGS];
char *stringargs[NUM_MAPTHING_STRINGARGS];

View file

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

View file

@ -13629,6 +13629,9 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y,
P_SetScale(mobj, FixedMul(mobj->scale, mthing->scale));
mobj->destscale = FixedMul(mobj->destscale, mthing->scale);
mobj->spritexscale = mthing->spritexscale;
mobj->spriteyscale = mthing->spriteyscale;
P_SetThingTID(mobj, mthing->tid);
mobj->special = mthing->special;

View file

@ -1361,6 +1361,7 @@ static void P_LoadThings(UINT8 *data)
mt->extrainfo = (UINT8)(mt->type >> 12);
mt->tid = 0;
mt->scale = FRACUNIT;
mt->spritexscale = mt->spriteyscale = FRACUNIT;
memset(mt->args, 0, NUM_MAPTHING_ARGS*sizeof(*mt->args));
memset(mt->stringargs, 0x00, NUM_MAPTHING_STRINGARGS*sizeof(*mt->stringargs));
mt->special = 0;
@ -1955,7 +1956,13 @@ static void ParseTextmapThingParameter(UINT32 i, const char *param, const char *
mapthings[i].roll = atol(val);
else if (fastcmp(param, "type"))
mapthings[i].type = atol(val);
else if (fastcmp(param, "scale") || fastcmp(param, "scalex") || fastcmp(param, "scaley"))
else if (fastcmp(param, "scale"))
mapthings[i].spritexscale = mapthings[i].spriteyscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "scalex"))
mapthings[i].spritexscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "scaley"))
mapthings[i].spriteyscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "mobjscale"))
mapthings[i].scale = FLOAT_TO_FIXED(atof(val));
// Flags
else if (fastcmp(param, "flip") && fastcmp("true", val))
@ -2134,8 +2141,12 @@ static void P_WriteTextmapThing(FILE *f, mapthing_t *wmapthings, size_t i, size_
fprintf(f, "roll = %d;\n", wmapthings[i].roll);
if (wmapthings[i].type != 0)
fprintf(f, "type = %d;\n", wmapthings[i].type);
if (wmapthings[i].spritexscale != FRACUNIT)
fprintf(f, "scalex = %f;\n", FIXED_TO_FLOAT(wmapthings[i].spritexscale));
if (wmapthings[i].spriteyscale != FRACUNIT)
fprintf(f, "scaley = %f;\n", FIXED_TO_FLOAT(wmapthings[i].spriteyscale));
if (wmapthings[i].scale != FRACUNIT)
fprintf(f, "scale = %f;\n", FIXED_TO_FLOAT(wmapthings[i].scale));
fprintf(f, "mobjscale = %f;\n", FIXED_TO_FLOAT(wmapthings[i].scale));
if (wmapthings[i].options & MTF_OBJECTFLIP)
fprintf(f, "flip = true;\n");
if (wmapthings[i].special != 0)
@ -3160,6 +3171,7 @@ static void P_LoadTextmap(void)
mt->extrainfo = 0;
mt->tid = 0;
mt->scale = FRACUNIT;
mt->spritexscale = mt->spriteyscale = FRACUNIT;
memset(mt->args, 0, NUM_MAPTHING_ARGS*sizeof(*mt->args));
memset(mt->stringargs, 0x00, NUM_MAPTHING_STRINGARGS*sizeof(*mt->stringargs));
mt->special = 0;
@ -7447,6 +7459,8 @@ static boolean P_LoadMapFromFile(void)
{
size_t j;
mapthings[i].scale = max(mapthings[i].spritexscale, mapthings[i].spriteyscale);
for (j = 0; j < min(NUM_MAPTHING_ARGS, NUM_SCRIPT_ARGS); j++)
{
mapthings[i].args[j] = mapthings[i].script_args[j];