From f7b9c8c5188d7b4ba612b694d520f33a9e1ddc6d Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Wed, 25 Dec 2024 11:24:36 +0200 Subject: [PATCH] game: sync target_sky with ReRelease code Based on: https://github.com/Paril/quake2-rerelease-dll.git --- src/game/g_target.c | 55 ++++++++++++++++++++++++++++++++--------- src/game/header/game.h | 1 + src/game/header/local.h | 2 +- src/server/sv_game.c | 16 ++++++++++++ 4 files changed, 61 insertions(+), 13 deletions(-) diff --git a/src/game/g_target.c b/src/game/g_target.c index 6215f54b..90aa00d4 100644 --- a/src/game/g_target.c +++ b/src/game/g_target.c @@ -1639,10 +1639,6 @@ SP_target_music(edict_t* self) void target_sky_use(edict_t *self, edict_t *other, edict_t *activator) { - float rotate; - int autorotate; - - if (!self) { return; @@ -1653,12 +1649,31 @@ target_sky_use(edict_t *self, edict_t *other, edict_t *activator) gi.configstring(CS_SKY, self->map); } - rotate = self->accel; - autorotate = self->style; - gi.configstring(CS_SKYROTATE, va("%f %d", rotate, autorotate)); + if (self->count & 3) + { + float rotate; + int autorotate; - gi.configstring(CS_SKYAXIS, va("%f %f %f", - self->movedir[0], self->movedir[1], self->movedir[2])); + sscanf(gi.get_configstring(CS_SKYROTATE), "%f %i", &rotate, &autorotate); + + if (self->count & 1) + { + rotate = self->accel; + } + + if (self->count & 2) + { + autorotate = self->style; + } + + gi.configstring(CS_SKYROTATE, va("%f %d", rotate, autorotate)); + } + + if (self->count & 4) + { + gi.configstring(CS_SKYAXIS, va("%f %f %f", + self->movedir[0], self->movedir[1], self->movedir[2])); + } } void @@ -1676,7 +1691,23 @@ SP_target_sky(edict_t* self) self->map = st.sky; } - VectorCopy(st.skyaxis, self->movedir); - self->accel = st.skyrotate; - self->style = st.skyautorotate; + if (self->movedir[0] && + self->movedir[1] && + self->movedir[2]) + { + self->count |= 4; + VectorCopy(st.skyaxis, self->movedir); + } + + if (st.skyrotate) + { + self->count |= 1; + self->accel = st.skyrotate; + } + + if (st.skyautorotate) + { + self->count |= 2; + self->style = st.skyautorotate; + } } diff --git a/src/game/header/game.h b/src/game/header/game.h index dcfb2395..c0d3f4f4 100644 --- a/src/game/header/game.h +++ b/src/game/header/game.h @@ -200,6 +200,7 @@ typedef struct NULL can be passed for buf to just determine existance */ int (*FS_LoadFile) (const char *name, void **buf); void (*FS_FreeFile) (void *buf); + const char * (*get_configstring)(int num); } game_import_t; /* functions exported by the game subsystem */ diff --git a/src/game/header/local.h b/src/game/header/local.h index 341615bc..36bbd409 100644 --- a/src/game/header/local.h +++ b/src/game/header/local.h @@ -385,7 +385,7 @@ typedef struct edict_t *disguise_violator; int disguise_violation_framenum; - char *start_items; + char *start_items; /* level start items */ } level_locals_t; /* spawn_temp_t is only used to hold entity field values that diff --git a/src/server/sv_game.c b/src/server/sv_game.c index 124fb8ae..1c791dfc 100644 --- a/src/server/sv_game.c +++ b/src/server/sv_game.c @@ -224,6 +224,21 @@ PF_Configstring(int index, const char *val) } } +/* Direct get value for config string, index in library range */ +static const char * +PF_ConfigstringGet(int index) +{ + index = P_ConvertConfigStringFrom(index, SV_GetRecomendedProtocol()); + + if ((index < 0) || (index >= MAX_CONFIGSTRINGS)) + { + Com_Error(ERR_DROP, "configstring: bad index %i\n", index); + } + + /* change the string in sv */ + return sv.configstrings[index]; +} + static void PF_WriteChar(int c) { @@ -420,6 +435,7 @@ SV_InitGameProgs(void) import.imageindex = SV_ImageIndex; import.configstring = PF_Configstring; + import.get_configstring = PF_ConfigstringGet; import.sound = PF_StartSound; import.positioned_sound = SV_StartSound;