mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
[qw] Fix carried flag handling
I guess some of the earlier entity/scene handling hadn't been tested for flags as no entity was ever being created for a flag. This fixes a segfault when another player carrying a flag is potentially visible. Also make the -16 Z offset local. It looks better than global, and the global was quite wrong anyway as it was incorrectly updating W (which caused me to spend way too long figuring out why positions were breaking). There are still issues with flag handling, and things are likely to change with the ECS updates, but at least this lets me test.
This commit is contained in:
parent
b607fe0878
commit
394018b3c5
1 changed files with 16 additions and 10 deletions
|
@ -100,6 +100,16 @@ CL_GetEntity (int num)
|
|||
return cl_entities[num];
|
||||
}
|
||||
|
||||
static entity_t *
|
||||
CL_GetFlagEnt (int key)
|
||||
{
|
||||
if (!cl_flag_ents[key]) {
|
||||
cl_flag_ents[key] = Scene_CreateEntity (cl_world.scene);
|
||||
CL_Init_Entity (cl_flag_ents[key]);
|
||||
}
|
||||
return cl_flag_ents[key];
|
||||
}
|
||||
|
||||
// Hack hack hack
|
||||
static inline int
|
||||
is_dead_body (entity_state_t *s1)
|
||||
|
@ -305,7 +315,7 @@ CL_UpdateFlagModels (entity_t *ent, int key)
|
|||
float f;
|
||||
entity_t *fent;
|
||||
|
||||
fent = cl_flag_ents[key];
|
||||
fent = CL_GetFlagEnt (key);
|
||||
|
||||
if (!fent->active) {
|
||||
return;
|
||||
|
@ -325,13 +335,9 @@ CL_UpdateFlagModels (entity_t *ent, int key)
|
|||
vec4f_t scale = { 1, 1, 1, 1 };
|
||||
// -45 degree roll (x is forward)
|
||||
vec4f_t rotation = { -0.382683432, 0, 0, 0.923879533 };
|
||||
vec4f_t position = { -f, -22, 0, 1};
|
||||
vec4f_t position = { -f, -22, -16, 1};
|
||||
|
||||
Transform_SetLocalPosition (fent->transform, position);
|
||||
Transform_SetLocalTransform (fent->transform, scale, rotation, position);
|
||||
position = Transform_GetWorldPosition (fent->transform);
|
||||
position[3] -= 16;
|
||||
Transform_SetWorldPosition (fent->transform, position);
|
||||
}
|
||||
|
||||
static entity_t *
|
||||
|
@ -339,7 +345,7 @@ CL_AddFlagModels (entity_t *ent, int team, int key)
|
|||
{
|
||||
entity_t *fent;
|
||||
|
||||
fent = cl_flag_ents[key];
|
||||
fent = CL_GetFlagEnt (key);
|
||||
|
||||
if (cl_flagindex == -1) {
|
||||
fent->active = 0;
|
||||
|
@ -349,7 +355,7 @@ CL_AddFlagModels (entity_t *ent, int team, int key)
|
|||
fent->active = 1;
|
||||
|
||||
if (!Transform_GetParent (fent->transform)) {
|
||||
Transform_SetParent (fent->transform, ent->transform);
|
||||
Transform_SetParent (cl_world.scene, fent->transform, ent->transform);
|
||||
}
|
||||
CL_UpdateFlagModels (ent, key);
|
||||
|
||||
|
@ -364,9 +370,9 @@ CL_RemoveFlagModels (int key)
|
|||
{
|
||||
entity_t *fent;
|
||||
|
||||
fent = cl_flag_ents[key];
|
||||
fent = CL_GetFlagEnt (key);
|
||||
fent->active = 0;
|
||||
Transform_SetParent (fent->transform, 0);
|
||||
Transform_SetParent (cl_world.scene, fent->transform, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue