game: sync target_sky with ReRelease code

Based on: https://github.com/Paril/quake2-rerelease-dll.git
This commit is contained in:
Denis Pauk 2024-12-25 11:24:36 +02:00
parent dbcd1d0d6d
commit f7b9c8c518
4 changed files with 61 additions and 13 deletions

View file

@ -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;
}
}

View file

@ -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 */

View file

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

View file

@ -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;