From f856be35128fed954d5f900cb672ca7566f8abd2 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Mon, 18 Nov 2024 00:43:15 +0200 Subject: [PATCH] game: Add scale entity field (without real usage) --- README.md | 2 +- src/common/header/shared.h | 1 + src/game/g_misc.c | 1 + src/game/g_spawn.c | 27 ++++++++++++++++++++++----- src/game/header/local.h | 5 +++++ src/game/savegame/tables/fields.h | 4 +++- 6 files changed, 33 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fc3b86bc..9626b6eb 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ Goals: * [ ] Support textures/*/*_glow.png load from ReRelease, * [ ] Support tactile/*/*.bnvib/.wav feedback load from ReRelease, * [ ] Fix physics with incorrect floor height in psx/base0.bsp, -* [ ] Fix strange white flying boxes in psx/base0.bsp, +* [x] Fix strange white flying boxes in psx/base0.bsp, * [x] RGB particles support instead palette based one, * [x] Get rid of VID_PaletteColor client internal api use, * [x] Broken maps groups from base2 to next, diff --git a/src/common/header/shared.h b/src/common/header/shared.h index 2ffcfc5b..a71da662 100644 --- a/src/common/header/shared.h +++ b/src/common/header/shared.h @@ -1222,6 +1222,7 @@ typedef struct entity_state_s int event; /* impulse events -- muzzle flashes, footsteps, etc */ /* events only go out for a single frame, they */ /* are automatically cleared each frame */ + vec3_t scale; } entity_state_t; /* ============================================== */ diff --git a/src/game/g_misc.c b/src/game/g_misc.c index d1f86662..7b68e195 100644 --- a/src/game/g_misc.c +++ b/src/game/g_misc.c @@ -3336,6 +3336,7 @@ SP_misc_flare(edict_t* ent) ent->s.modelindex2 = st.fade_start_dist; ent->s.modelindex3 = st.fade_end_dist; + ent->s.skinnum = st.rgba; if (ent->targetname) { diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index 8e51c1ca..da8a0e0e 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -117,11 +117,27 @@ DynamicSpawnUpdate(edict_t *self, dynamicentity_t *data) VectorCopy(data->mins, self->mins); VectorCopy(data->maxs, self->maxs); - self->monsterinfo.scale = ( - data->scale[0] + - data->scale[1] + - data->scale[2] - ) / 3; + /* has updated scale */ + if (st.scale[0] || st.scale[1] || st.scale[2]) + { + /* copy to other parts if zero */ + if (!st.scale[1]) + { + st.scale[1] = st.scale[0]; + } + + if (!st.scale[2]) + { + st.scale[2] = st.scale[0]; + } + + /* Copy to entity scale field */ + VectorCopy(st.scale, self->s.scale); + } + else + { + VectorCopy(data->scale, self->s.scale); + } } void @@ -510,6 +526,7 @@ ED_ParseField(const char *key, const char *value, edict_t *ent) *(char **)(b + f->ofs) = ED_NewString(value, false); break; case F_VECTOR: + VectorClear(vec); sscanf(value, "%f %f %f", &vec[0], &vec[1], &vec[2]); ((float *)(b + f->ofs))[0] = vec[0]; ((float *)(b + f->ofs))[1] = vec[1]; diff --git a/src/game/header/local.h b/src/game/header/local.h index acdedb0f..998ad624 100644 --- a/src/game/header/local.h +++ b/src/game/header/local.h @@ -411,10 +411,15 @@ typedef struct float minpitch; float maxpitch; + /* misc_flare */ float radius; float fade_start_dist; float fade_end_dist; char *image; + unsigned rgba; + + /* Addional fields for models */ + vec3_t scale; } spawn_temp_t; typedef struct diff --git a/src/game/savegame/tables/fields.h b/src/game/savegame/tables/fields.h index 3a5cf336..a88da009 100644 --- a/src/game/savegame/tables/fields.h +++ b/src/game/savegame/tables/fields.h @@ -58,7 +58,9 @@ {"origin", FOFS(s.origin), F_VECTOR}, {"angles", FOFS(s.angles), F_VECTOR}, {"angle", FOFS(s.angles), F_ANGLEHACK}, -{"rgba", FOFS(s.skinnum), F_RGBA}, +{"rgb", STOFS(rgba), F_RGBA, FFL_SPAWNTEMP}, +{"rgba", STOFS(rgba), F_RGBA, FFL_SPAWNTEMP}, +{"scale", STOFS(scale), F_VECTOR, FFL_SPAWNTEMP}, {"radius", STOFS(radius), F_FLOAT, FFL_SPAWNTEMP}, {"fade_start_dist", STOFS(fade_start_dist), F_FLOAT, FFL_SPAWNTEMP}, {"fade_end_dist", STOFS(fade_end_dist), F_FLOAT, FFL_SPAWNTEMP},