diff --git a/include/QF/render.h b/include/QF/render.h index 4b0f567d8..4f999914c 100644 --- a/include/QF/render.h +++ b/include/QF/render.h @@ -163,5 +163,7 @@ void R_SetVrect (vrect_t *pvrect, vrect_t *pvrectin, int lineadj); void R_LoadSkys (const char *); void R_ClearEfrags (void); +void R_ClearEnts (void); +struct entity_s **R_NewEntity (void); #endif // __render_h diff --git a/include/r_dynamic.h b/include/r_dynamic.h index 9ce18a8b9..044e8e0bc 100644 --- a/include/r_dynamic.h +++ b/include/r_dynamic.h @@ -41,7 +41,7 @@ void R_RunSpikeEffect (vec3_t org, byte type); #ifdef QUAKE2 void R_DarkFieldParticles (entity_t *ent); #endif -void R_EntityParticles (entity_t *ent); +void R_EntityParticles (struct entity_s *ent); void R_BlobExplosion (vec3_t org); void R_ParticleExplosion (vec3_t org); void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength); diff --git a/include/r_local.h b/include/r_local.h index e8867e9a7..2b966d25a 100644 --- a/include/r_local.h +++ b/include/r_local.h @@ -333,6 +333,9 @@ extern int r_clipflags; extern int r_dlightframecount; extern qboolean r_fov_greater_than_90; +extern int r_numvisedicts; +extern struct entity_s *r_visedicts[]; + void R_StoreEfrags (efrag_t **ppefrag); void R_TimeRefresh_f (void); void R_TimeGraph (void); diff --git a/nq/include/client.h b/nq/include/client.h index ef648efde..6bc47be33 100644 --- a/nq/include/client.h +++ b/nq/include/client.h @@ -304,10 +304,6 @@ void CL_Disconnect (void); void CL_Disconnect_f (void); void CL_NextDemo (void); -#define MAX_VISEDICTS 256 -extern int cl_numvisedicts; -extern entity_t *cl_visedicts[MAX_VISEDICTS]; - /* cl_input @@ -366,7 +362,6 @@ void CL_TEnts_Init (void); void CL_ClearEnts (void); void CL_ClearTEnts (void); void CL_Init_Entity (struct entity_s *ent); -struct entity_s **CL_NewTempEntity (void); void CL_ParseTEnt (void); void CL_SignonReply (void); diff --git a/nq/source/Makefile.am b/nq/source/Makefile.am index a49806393..2e6b65521 100644 --- a/nq/source/Makefile.am +++ b/nq/source/Makefile.am @@ -73,7 +73,7 @@ client_LIBS= -L. -lqfnet $(qf_client_LIBS) $(NET_LIBS) client_LIB_DEPS= libqfnet.a $(qf_client_LIBS) client_SOURCES= cl_cam.c cl_cmd.c cl_demo.c cl_input.c cl_main.c cl_parse.c \ - cl_tent.c console.c keys.c sbar.c r_cvar.c r_efrag.c r_part.c r_view.c \ + cl_tent.c console.c keys.c sbar.c r_cvar.c r_efrag.c r_ent.c r_part.c r_view.c \ nonintel.c locs.c pcx.c tga.c server_SOURCES= host.c host_cmd.c pr_cmds.c sv_cvar.c sv_main.c \ diff --git a/nq/source/cl_main.c b/nq/source/cl_main.c index 0bf40b53b..05e20a52e 100644 --- a/nq/source/cl_main.c +++ b/nq/source/cl_main.c @@ -91,9 +91,6 @@ entity_state_t cl_static_entity_baselines[MAX_STATIC_ENTITIES]; lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES]; dlight_t cl_dlights[MAX_DLIGHTS]; -int cl_numvisedicts; -entity_t *cl_visedicts[MAX_VISEDICTS]; - void CL_InitCvars (void) @@ -715,7 +712,7 @@ CL_RelinkEntities (void) if (ent->effects & EF_NODRAW) continue; #endif - if ((_ent = CL_NewTempEntity ())) + if ((_ent = R_NewEntity ())) *_ent = ent; } } @@ -748,7 +745,7 @@ CL_ReadFromServer (void) if (cl_shownet->int_val) Con_Printf ("\n"); - cl_numvisedicts = 0; + R_ClearEnts (); CL_RelinkEntities (); CL_UpdateTEnts (); diff --git a/nq/source/cl_tent.c b/nq/source/cl_tent.c index d85d10d8a..91f00d441 100644 --- a/nq/source/cl_tent.c +++ b/nq/source/cl_tent.c @@ -418,16 +418,6 @@ CL_ParseTEnt (void) } -entity_t ** -CL_NewTempEntity (void) -{ - - if (cl_numvisedicts == MAX_VISEDICTS) - return NULL; - return &cl_visedicts[cl_numvisedicts++]; -} - - void CL_UpdateBeams (void) { @@ -473,7 +463,7 @@ CL_UpdateBeams (void) d = VectorNormalize (dist); b->ent_count = 0; while (d > 0 && b->ent_count < MAX_BEAM_ENTS) { - ent = CL_NewTempEntity (); + ent = R_NewEntity (); if (!ent) return; *ent = &b->ent_list[b->ent_count++]; @@ -507,7 +497,7 @@ CL_UpdateExplosions (void) continue; } - ent = CL_NewTempEntity (); + ent = R_NewEntity (); if (!ent) return; ex->ent.frame = f; diff --git a/nq/source/gl_rmain.c b/nq/source/gl_rmain.c index ba8e1c0d0..29ff4e9fe 100644 --- a/nq/source/gl_rmain.c +++ b/nq/source/gl_rmain.c @@ -818,19 +818,19 @@ R_DrawEntitiesOnList (void) } // LordHavoc: split into 3 loops to simplify state changes - for (i = 0; i < cl_numvisedicts; i++) { - if (cl_visedicts[i]->model->type != mod_brush) + for (i = 0; i < r_numvisedicts; i++) { + if (r_visedicts[i]->model->type != mod_brush) continue; - currententity = cl_visedicts[i]; + currententity = r_visedicts[i]; modelalpha = currententity->alpha; R_DrawBrushModel (currententity); } - for (i = 0; i < cl_numvisedicts; i++) { - if (cl_visedicts[i]->model->type != mod_alias) + for (i = 0; i < r_numvisedicts; i++) { + if (r_visedicts[i]->model->type != mod_alias) continue; - currententity = cl_visedicts[i]; + currententity = r_visedicts[i]; modelalpha = currententity->alpha; if (currententity == &cl_entities[cl.viewentity]) @@ -839,10 +839,10 @@ R_DrawEntitiesOnList (void) R_DrawAliasModel (currententity); } - for (i = 0; i < cl_numvisedicts; i++) { - if (cl_visedicts[i]->model->type != mod_sprite) + for (i = 0; i < r_numvisedicts; i++) { + if (r_visedicts[i]->model->type != mod_sprite) continue; - currententity = cl_visedicts[i]; + currententity = r_visedicts[i]; modelalpha = currententity->alpha; R_DrawSpriteModel (currententity); @@ -1107,7 +1107,7 @@ R_Mirror (void) r_refdef.viewangles[1] = atan2 (vpn[1], vpn[0]) / M_PI * 180; r_refdef.viewangles[2] = -r_refdef.viewangles[2]; - ent = CL_NewTempEntity(); + ent = R_NewEntity(); if (ent) *ent = &cl_entities[cl.viewentity]; diff --git a/nq/source/r_efrag.c b/nq/source/r_efrag.c index 1c9d28cff..17664290d 100644 --- a/nq/source/r_efrag.c +++ b/nq/source/r_efrag.c @@ -34,7 +34,6 @@ #include "QF/render.h" #include "QF/sys.h" -#include "client.h" #include "r_local.h" mnode_t *r_pefragtopnode; @@ -248,7 +247,7 @@ R_StoreEfrags (efrag_t **ppefrag) pent = pefrag->entity; if (pent->visframe != r_framecount) { - entity_t **ent = CL_NewTempEntity (); + entity_t **ent = R_NewEntity (); if (!ent) return; *ent = pent; diff --git a/nq/source/r_ent.c b/nq/source/r_ent.c new file mode 100644 index 000000000..6c5d11bc2 --- /dev/null +++ b/nq/source/r_ent.c @@ -0,0 +1,87 @@ +/* + r_tent.c + + rendering entities + + Copyright (C) 1996-1997 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + + $Id$ +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif + +#include +#include + +#include "QF/console.h" +#include "QF/model.h" +#include "QF/msg.h" +#include "QF/sound.h" +#include "QF/sys.h" + +#include "r_dynamic.h" +#include "QF/render.h" + +#define MAX_VISEDICTS 256 +int r_numvisedicts; +entity_t *r_visedicts[MAX_VISEDICTS]; + +void +R_Ents_Init (void) +{ +} + +void +R_Init_Entity (entity_t *ent) +{ + memset (ent, 0, sizeof (*ent)); + + ent->colormap = vid.colormap; + ent->glow_size = 0; + ent->glow_color = 254; + ent->alpha = 1; + ent->scale = 1; + ent->colormod[0] = ent->colormod[1] = ent->colormod[2] = 1; + ent->pose1 = ent->pose2 = -1; +} + +void +R_ClearEnts (void) +{ + r_numvisedicts = 0; +} + +entity_t ** +R_NewEntity (void) +{ + + if (r_numvisedicts == MAX_VISEDICTS) + return NULL; + return &r_visedicts[r_numvisedicts++]; +} diff --git a/nq/source/sw_rmain.c b/nq/source/sw_rmain.c index dce471919..8fcc1f4c4 100644 --- a/nq/source/sw_rmain.c +++ b/nq/source/sw_rmain.c @@ -494,8 +494,8 @@ R_DrawEntitiesOnList (void) return; } - for (i = 0; i < cl_numvisedicts; i++) { - currententity = cl_visedicts[i]; + for (i = 0; i < r_numvisedicts; i++) { + currententity = r_visedicts[i]; if (currententity == &cl_entities[cl.viewentity]) { if (!chase_active->int_val) @@ -693,8 +693,8 @@ R_DrawBEntitiesOnList (void) insubmodel = true; r_dlightframecount = r_framecount; - for (i = 0; i < cl_numvisedicts; i++) { - currententity = cl_visedicts[i]; + for (i = 0; i < r_numvisedicts; i++) { + currententity = r_visedicts[i]; switch (currententity->model->type) { case mod_brush: diff --git a/qw/include/cl_main.h b/qw/include/cl_main.h index ab4d2a8bc..509a2746a 100644 --- a/qw/include/cl_main.h +++ b/qw/include/cl_main.h @@ -48,10 +48,6 @@ qboolean CL_DemoBehind(void); void CL_BeginServerConnect(void); -#define MAX_VISEDICTS 256 -extern int cl_numvisedicts; -extern entity_t *cl_visedicts[MAX_VISEDICTS]; - extern char emodel_name[], pmodel_name[], prespawn_name[], modellist_name[], soundlist_name[]; #endif // _CL_MAIN_H diff --git a/qw/include/cl_tent.h b/qw/include/cl_tent.h index 0e843abea..8e59a05f9 100644 --- a/qw/include/cl_tent.h +++ b/qw/include/cl_tent.h @@ -33,7 +33,6 @@ void CL_TEnts_Init (void); void CL_ClearEnts (void); void CL_ClearTEnts (void); void CL_Init_Entity (struct entity_s *ent); -struct entity_s **CL_NewTempEntity (void); void CL_ParseTEnt (void); void CL_UpdateTEnts (void); diff --git a/qw/source/Makefile.am b/qw/source/Makefile.am index 1f34b9963..5a1b81ce1 100644 --- a/qw/source/Makefile.am +++ b/qw/source/Makefile.am @@ -98,7 +98,7 @@ client_LIB_DEPS= libqfnet.a $(qf_client_LIBS) client_SOURCES= cl_cam.c cl_cmd.c cl_cvar.c cl_demo.c cl_ents.c cl_input.c \ cl_main.c cl_misc.c cl_parse.c cl_pred.c cl_skin.c cl_slist.c \ cl_tent.c console.c keys.c locs.c nonintel.c \ - pcx.c r_cvar.c r_efrag.c r_view.c sbar.c skin.c teamplay.c tga.c wad.c cl_math.S $(syscl_SRC) + pcx.c r_cvar.c r_efrag.c r_ent.c r_view.c sbar.c skin.c teamplay.c tga.c wad.c cl_math.S $(syscl_SRC) # Software-rendering clients # diff --git a/qw/source/cl_ents.c b/qw/source/cl_ents.c index 572d726c6..1428e6591 100644 --- a/qw/source/cl_ents.c +++ b/qw/source/cl_ents.c @@ -484,7 +484,7 @@ CL_LinkPacketEntities (void) continue; // create a new entity - ent = CL_NewTempEntity (); + ent = R_NewEntity (); if (!ent) break; // object list is full @@ -642,7 +642,7 @@ CL_LinkProjectiles (void) continue; // grab an entity to fill in - ent = CL_NewTempEntity (); + ent = R_NewEntity (); if (!ent) break; // object list is full *ent = &pr->ent; @@ -790,7 +790,7 @@ CL_AddFlagModels (entity_t *ent, int team) f = f + 7; // shotattack } - newent = CL_NewTempEntity (); + newent = R_NewEntity (); if (!newent) return; *newent = &cl_flag_ents[ent->keynum]; @@ -864,7 +864,7 @@ CL_LinkPlayers (void) continue; // grab an entity to fill in - ent = CL_NewTempEntity (); + ent = R_NewEntity (); if (!ent) // object list is full break; *ent = &cl_player_ents[state - frame->playerstate]; @@ -1080,7 +1080,7 @@ CL_EmitEntities (void) if (!cl.validsequence) return; - cl_numvisedicts = 0; + R_ClearEnts (); CL_LinkPlayers (); CL_LinkPacketEntities (); diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 1b4fe6c1e..0353b62e8 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -167,12 +167,6 @@ entity_t cl_static_entities[MAX_STATIC_ENTITIES]; lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES]; dlight_t cl_dlights[MAX_DLIGHTS]; -// refresh list -// this is double buffered so the last frame -// can be scanned for oldorigins of trailing objects -int cl_numvisedicts; -entity_t *cl_visedicts[MAX_VISEDICTS]; - double connect_time = -1; // for connection retransmits quakeparms_t host_parms; diff --git a/qw/source/cl_tent.c b/qw/source/cl_tent.c index 3de0d12bb..c5f89a60a 100644 --- a/qw/source/cl_tent.c +++ b/qw/source/cl_tent.c @@ -409,16 +409,6 @@ CL_ParseTEnt (void) } -entity_t ** -CL_NewTempEntity (void) -{ - - if (cl_numvisedicts == MAX_VISEDICTS) - return NULL; - return &cl_visedicts[cl_numvisedicts++]; -} - - void CL_UpdateBeams (void) { @@ -464,7 +454,7 @@ CL_UpdateBeams (void) d = VectorNormalize (dist); b->ent_count = 0; while (d > 0 && b->ent_count < MAX_BEAM_ENTS) { - ent = CL_NewTempEntity (); + ent = R_NewEntity (); if (!ent) return; *ent = &b->ent_list[b->ent_count++]; @@ -498,7 +488,7 @@ CL_UpdateExplosions (void) continue; } - ent = CL_NewTempEntity (); + ent = R_NewEntity (); if (!ent) return; ex->ent.frame = f; diff --git a/qw/source/gl_rmain.c b/qw/source/gl_rmain.c index 3ffacccbb..fd6b6fe2f 100644 --- a/qw/source/gl_rmain.c +++ b/qw/source/gl_rmain.c @@ -831,28 +831,28 @@ R_DrawEntitiesOnList (void) } // LordHavoc: split into 3 loops to simplify state changes - for (i = 0; i < cl_numvisedicts; i++) { - if (cl_visedicts[i]->model->type != mod_brush) + for (i = 0; i < r_numvisedicts; i++) { + if (r_visedicts[i]->model->type != mod_brush) continue; - currententity = cl_visedicts[i]; + currententity = r_visedicts[i]; modelalpha = currententity->alpha; R_DrawBrushModel (currententity); } - for (i = 0; i < cl_numvisedicts; i++) { - if (cl_visedicts[i]->model->type != mod_alias) + for (i = 0; i < r_numvisedicts; i++) { + if (r_visedicts[i]->model->type != mod_alias) continue; - currententity = cl_visedicts[i]; + currententity = r_visedicts[i]; modelalpha = currententity->alpha; R_DrawAliasModel (currententity); } - for (i = 0; i < cl_numvisedicts; i++) { - if (cl_visedicts[i]->model->type != mod_sprite) + for (i = 0; i < r_numvisedicts; i++) { + if (r_visedicts[i]->model->type != mod_sprite) continue; - currententity = cl_visedicts[i]; + currententity = r_visedicts[i]; modelalpha = currententity->alpha; R_DrawSpriteModel (currententity); @@ -1106,7 +1106,7 @@ R_Mirror (void) r_refdef.viewangles[1] = atan2 (vpn[1], vpn[0]) / M_PI * 180; r_refdef.viewangles[2] = -r_refdef.viewangles[2]; - ent = CL_NewTempEntity(); + ent = R_NewEntity(); if (ent) *ent = &cl_entities[cl.viewentity]; diff --git a/qw/source/r_efrag.c b/qw/source/r_efrag.c index bd5455814..17664290d 100644 --- a/qw/source/r_efrag.c +++ b/qw/source/r_efrag.c @@ -34,7 +34,6 @@ #include "QF/render.h" #include "QF/sys.h" -#include "cl_tent.h" #include "r_local.h" mnode_t *r_pefragtopnode; @@ -248,7 +247,7 @@ R_StoreEfrags (efrag_t **ppefrag) pent = pefrag->entity; if (pent->visframe != r_framecount) { - entity_t **ent = CL_NewTempEntity (); + entity_t **ent = R_NewEntity (); if (!ent) return; *ent = pent; diff --git a/qw/source/r_ent.c b/qw/source/r_ent.c new file mode 100644 index 000000000..6c5d11bc2 --- /dev/null +++ b/qw/source/r_ent.c @@ -0,0 +1,87 @@ +/* + r_tent.c + + rendering entities + + Copyright (C) 1996-1997 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + + $Id$ +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif + +#include +#include + +#include "QF/console.h" +#include "QF/model.h" +#include "QF/msg.h" +#include "QF/sound.h" +#include "QF/sys.h" + +#include "r_dynamic.h" +#include "QF/render.h" + +#define MAX_VISEDICTS 256 +int r_numvisedicts; +entity_t *r_visedicts[MAX_VISEDICTS]; + +void +R_Ents_Init (void) +{ +} + +void +R_Init_Entity (entity_t *ent) +{ + memset (ent, 0, sizeof (*ent)); + + ent->colormap = vid.colormap; + ent->glow_size = 0; + ent->glow_color = 254; + ent->alpha = 1; + ent->scale = 1; + ent->colormod[0] = ent->colormod[1] = ent->colormod[2] = 1; + ent->pose1 = ent->pose2 = -1; +} + +void +R_ClearEnts (void) +{ + r_numvisedicts = 0; +} + +entity_t ** +R_NewEntity (void) +{ + + if (r_numvisedicts == MAX_VISEDICTS) + return NULL; + return &r_visedicts[r_numvisedicts++]; +} diff --git a/qw/source/sw_rmain.c b/qw/source/sw_rmain.c index 93f5dc346..e2843d37d 100644 --- a/qw/source/sw_rmain.c +++ b/qw/source/sw_rmain.c @@ -495,8 +495,8 @@ R_DrawEntitiesOnList (void) return; } - for (i = 0; i < cl_numvisedicts; i++) { - currententity = cl_visedicts[i]; + for (i = 0; i < r_numvisedicts; i++) { + currententity = r_visedicts[i]; switch (currententity->model->type) { case mod_sprite: @@ -685,8 +685,8 @@ R_DrawBEntitiesOnList (void) insubmodel = true; r_dlightframecount = r_framecount; - for (i = 0; i < cl_numvisedicts; i++) { - currententity = cl_visedicts[i]; + for (i = 0; i < r_numvisedicts; i++) { + currententity = r_visedicts[i]; switch (currententity->model->type) { case mod_brush: