From 44b36e4d6b9d780d824192208806140deae70974 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 3 Dec 2001 05:36:39 +0000 Subject: [PATCH] sadly, I have to revert my low-copy code. it doesn't gain /enough/ to be worth the bugs it's introduced (it's extremely difficult to do both low-copy /and/ correct entity updates). --- qw/include/cl_parse.h | 5 - qw/include/cl_tent.h | 2 - qw/include/client.h | 2 +- qw/include/protocol.h | 2 +- qw/source/cl_cam.c | 8 +- qw/source/cl_ents.c | 290 +++++++++++++++++++----------------------- qw/source/cl_main.c | 9 +- qw/source/cl_parse.c | 27 ++-- qw/source/cl_skin.c | 32 +---- qw/source/sbar.c | 22 ++-- 10 files changed, 172 insertions(+), 227 deletions(-) diff --git a/qw/include/cl_parse.h b/qw/include/cl_parse.h index ee842eb0e..c4be728ea 100644 --- a/qw/include/cl_parse.h +++ b/qw/include/cl_parse.h @@ -35,8 +35,6 @@ #define NET_TIMINGSMASK 255 struct skin_s; -struct entity_s; -struct entity_state_s; extern int packet_latency[NET_TIMINGS]; extern int parsecountmod; @@ -53,13 +51,10 @@ extern int cl_gib3index; int CL_CalcNet (void); void CL_ParseServerMessage (void); void CL_NewTranslation (int slot, struct skin_s *skin); -void CL_SetColormap (struct entity_s *ent, int slot); qboolean CL_CheckOrDownloadFile (const char *filename); qboolean CL_IsUploading(void); void CL_NextUpload(void); void CL_StartUpload (byte *data, int size); void CL_StopUpload(void); -void CL_EntFromBaseline (struct entity_state_s *es, struct entity_s *ent, - int ind); #endif diff --git a/qw/include/cl_tent.h b/qw/include/cl_tent.h index 09b63a281..8e59a05f9 100644 --- a/qw/include/cl_tent.h +++ b/qw/include/cl_tent.h @@ -29,8 +29,6 @@ #ifndef _CL_TENT_H #define _CL_TENT_H -extern struct entity_s cl_entities[MAX_EDICTS]; - void CL_TEnts_Init (void); void CL_ClearEnts (void); void CL_ClearTEnts (void); diff --git a/qw/include/client.h b/qw/include/client.h index ec8a9f37a..3bf62a8a7 100644 --- a/qw/include/client.h +++ b/qw/include/client.h @@ -78,7 +78,7 @@ typedef struct player_info_s struct info_s *userinfo; // scoreboard information - struct info_key_s *name; + char name[MAX_SCOREBOARDNAME]; float entertime; int frags; int ping; diff --git a/qw/include/protocol.h b/qw/include/protocol.h index b73b086b0..b6c24765c 100644 --- a/qw/include/protocol.h +++ b/qw/include/protocol.h @@ -266,7 +266,7 @@ // entity_state_t is the information conveyed from the server // in an update message -typedef struct entity_state_s +typedef struct { int number; // edict index diff --git a/qw/source/cl_cam.c b/qw/source/cl_cam.c index 54c5d3efd..b0503340e 100644 --- a/qw/source/cl_cam.c +++ b/qw/source/cl_cam.c @@ -355,7 +355,7 @@ Cam_CheckHighTarget (void) j = -1; for (i = 0, max = -9999; i < MAX_CLIENTS; i++) { s = &cl.players[i]; - if (s->name && !s->spectator && s->frags > max) { + if (s->name[0] && !s->spectator && s->frags > max) { max = s->frags; j = i; } @@ -389,7 +389,7 @@ Cam_Track (usercmd_t *cmd) return; if (locked - && (!cl.players[spec_track].name + && (!cl.players[spec_track].name[0] || cl.players[spec_track].spectator)) { locked = false; if (cl_hightrack->int_val) @@ -604,7 +604,7 @@ Cam_FinishMove (usercmd_t *cmd) i = end; do { s = &cl.players[i]; - if (s->name && !s->spectator) { + if (s->name[0] && !s->spectator) { Cam_Lock (i); return; } @@ -613,7 +613,7 @@ Cam_FinishMove (usercmd_t *cmd) // stay on same guy? i = spec_track; s = &cl.players[i]; - if (s->name && !s->spectator) { + if (s->name[0] && !s->spectator) { Cam_Lock (i); return; } diff --git a/qw/source/cl_ents.c b/qw/source/cl_ents.c index 1ea1d8633..38fe80aa0 100644 --- a/qw/source/cl_ents.c +++ b/qw/source/cl_ents.c @@ -68,27 +68,23 @@ static struct predicted_player { #define MAX_PROJECTILES 32 int cl_num_projectiles; +entity_t cl_player_ents[MAX_CLIENTS]; entity_t cl_flag_ents[MAX_CLIENTS]; entity_t cl_projectiles[MAX_PROJECTILES]; -entity_t cl_entities[MAX_EDICTS]; +entity_t cl_packet_ents[512]; // FIXME: magic number -int cl_last_sequence; -int cl_entity_sequence[MAX_EDICTS]; - -struct { - model_t *model; - int skinnum; -} cl_entity_model_states[MAX_EDICTS]; void CL_ClearEnts () { int i; - for (i = 0; i < sizeof (cl_entities) / sizeof (cl_entities[0]); i++) - CL_Init_Entity (&cl_entities[i]); + for (i = 0; i < sizeof (cl_packet_ents) / sizeof (cl_packet_ents[0]); i++) + CL_Init_Entity (&cl_packet_ents[i]); for (i = 0; i < sizeof (cl_flag_ents) / sizeof (cl_flag_ents[0]); i++) CL_Init_Entity (&cl_flag_ents[i]); + for (i = 0; i < sizeof (cl_player_ents) / sizeof (cl_player_ents[0]); i++) + CL_Init_Entity (&cl_player_ents[i]); } void @@ -133,44 +129,13 @@ CL_NewDlight (int key, vec3_t org, int effects) int bitcounts[32]; // / just for protocol profiling -void -CL_EntFromBaseline (entity_state_t *es, entity_t *ent, int ind) -{ - ent->model = cl.model_precache[es->modelindex]; - ent->frame = es->frame; - ent->skinnum = es->skinnum; - VectorCopy (es->origin, ent->origin); - VectorCopy (es->origin, ent->old_origin); - VectorCopy (es->angles, ent->angles); - ent->alpha = es->alpha / 255.0; - ent->scale = es->scale / 16.0; - ent->glow_color = es->glow_color; - ent->glow_size = (char)es->glow_size / 8.0; - if (es->colormod == 255) { - ent->colormod[0] = ent->colormod[1] = ent->colormod[2] = 1; - } else { - ent->colormod[0] = ((es->colormod >> 5) & 7) / 7.0; - ent->colormod[1] = ((es->colormod >> 2) & 7) / 7.0; - ent->colormod[2] = ((es->colormod >> 0) & 3) / 3.0; - } - if (ind >= 0 && ind < MAX_EDICTS) { - cl_entity_model_states[ind].model = ent->model; - cl_entity_model_states[ind].skinnum = ent->skinnum; - CL_SetColormap (ent, es->colormap - 1); - } else { - ent->colormap = vid.colormap8; - ent->skin = NULL; - } -} - /* CL_ParseDelta Can go from either a baseline or a previous packet_entity */ void -CL_ParseDelta (entity_state_t *from, entity_state_t *to, entity_t *ent, - int bits, int do_colormap) +CL_ParseDelta (entity_state_t *from, entity_state_t *to, int bits) { int i; @@ -199,116 +164,67 @@ CL_ParseDelta (entity_state_t *from, entity_state_t *to, entity_t *ent, to->flags = bits; - if (bits & U_MODEL) { + if (bits & U_MODEL) to->modelindex = MSG_ReadByte (net_message); - ent->model = cl.model_precache[to->modelindex]; - } - if (bits & U_FRAME) { + if (bits & U_FRAME) to->frame = MSG_ReadByte (net_message); - ent->frame = to->frame; - } if (bits & U_COLORMAP) to->colormap = MSG_ReadByte (net_message); - if (bits & U_SKIN) { + if (bits & U_SKIN) to->skinnum = MSG_ReadByte (net_message); - ent->skinnum = to->skinnum; - } if (bits & U_EFFECTS) to->effects = MSG_ReadByte (net_message); - VectorCopy (ent->origin, ent->old_origin); - - if (bits & U_ORIGIN1) { + if (bits & U_ORIGIN1) to->origin[0] = MSG_ReadCoord (net_message); - ent->origin[0] = to->origin[0]; - } - if (bits & U_ANGLE1) { + if (bits & U_ANGLE1) to->angles[0] = MSG_ReadAngle (net_message); - ent->angles[0] = to->angles[0]; - } - if (bits & U_ORIGIN2) { + if (bits & U_ORIGIN2) to->origin[1] = MSG_ReadCoord (net_message); - ent->origin[1] = to->origin[1]; - } - if (bits & U_ANGLE2) { + if (bits & U_ANGLE2) to->angles[1] = MSG_ReadAngle (net_message); - ent->angles[1] = to->angles[1]; - } - if (bits & U_ORIGIN3) { + if (bits & U_ORIGIN3) to->origin[2] = MSG_ReadCoord (net_message); - ent->origin[2] = to->origin[2]; - } - if (bits & U_ANGLE3) { + if (bits & U_ANGLE3) to->angles[2] = MSG_ReadAngle (net_message); - ent->angles[2] = to->angles[2]; - } if (bits & U_SOLID) { // FIXME } - if (do_colormap) { - int ind = ent - cl_entities; - if (cl_entity_model_states[ind].model != ent->model - || cl_entity_model_states[ind].skinnum != ent->skinnum) { - cl_entity_model_states[ind].model = ent->model; - cl_entity_model_states[ind].skinnum = ent->skinnum; - CL_SetColormap (ent, to->colormap - 1); - } - } - if (!(bits & U_EXTEND1)) return; // LordHavoc: Endy neglected to mark this as being part of the QSG // version 2 stuff... rearranged it and implemented missing effects // Ender (QSG - Begin) - if (bits & U_ALPHA) { + if (bits & U_ALPHA) to->alpha = MSG_ReadByte (net_message); - ent->alpha = to->alpha / 255.0; - } - if (bits & U_SCALE) { + if (bits & U_SCALE) to->scale = MSG_ReadByte (net_message); - ent->scale = to->scale / 16.0; - } - if (bits & U_EFFECTS2) { + if (bits & U_EFFECTS2) to->effects = (to->effects & 0xFF) | (MSG_ReadByte (net_message) << 8); - } - if (bits & U_GLOWSIZE) { + if (bits & U_GLOWSIZE) to->glow_size = MSG_ReadByte (net_message); - ent->glow_size = (char)to->glow_size * 8.0; - } - if (bits & U_GLOWCOLOR) { + if (bits & U_GLOWCOLOR) to->glow_color = MSG_ReadByte (net_message); - ent->glow_color = to->glow_color; - } - if (bits & U_COLORMOD) { + if (bits & U_COLORMOD) to->colormod = MSG_ReadByte (net_message); - if (to->colormod == 255) { - ent->colormod[0] = ent->colormod[1] = ent->colormod[2] = 1; - } else { - ent->colormod[0] = ((to->colormod >> 5) & 7) / 7.0; - ent->colormod[1] = ((to->colormod >> 2) & 7) / 7.0; - ent->colormod[2] = ((to->colormod >> 0) & 3) / 3.0; - } - } if (!(bits & U_EXTEND2)) return; - if (bits & U_FRAME2) { + if (bits & U_FRAME2) to->frame = (to->frame & 0xFF) | (MSG_ReadByte (net_message) << 8); - ent->frame = to->frame; - } // Ender (QSG - End) } @@ -316,7 +232,6 @@ void FlushEntityPacket (void) { entity_state_t olde, newe; - entity_t fakee; int word; Con_DPrintf ("FlushEntityPacket\n"); @@ -337,7 +252,7 @@ FlushEntityPacket (void) if (!word) break; // done - CL_ParseDelta (&olde, &newe, &fakee, word, 0); + CL_ParseDelta (&olde, &newe, word); } } @@ -445,12 +360,8 @@ CL_ParsePacketEntities (qboolean delta) if (newindex >= MAX_PACKET_ENTITIES) Host_Error ("CL_ParsePacketEntities: newindex == " "MAX_PACKET_ENTITIES"); - if (cl_entity_sequence[newnum] != cl_last_sequence) - CL_EntFromBaseline (&cl_baselines[newnum], &cl_entities[newnum], - newnum); CL_ParseDelta (&cl_baselines[newnum], &newp->entities[newindex], - &cl_entities[newnum], word, 1); - cl_entity_sequence[newnum] = cls.netchan.incoming_sequence; + word); newindex++; continue; } @@ -461,21 +372,20 @@ CL_ParsePacketEntities (qboolean delta) Con_Printf ("WARNING: delta on full update"); } if (word & U_REMOVE) { // Clear the entity + entity_t *ent = &cl_packet_ents[newnum]; + memset (ent, 0, sizeof (entity_t)); oldindex++; continue; } // Con_Printf ("delta %i\n", newnum); CL_ParseDelta (&oldp->entities[oldindex], - &newp->entities[newindex], &cl_entities[newnum], - word, 1); - cl_entity_sequence[newnum] = cls.netchan.incoming_sequence; + &newp->entities[newindex], word); newindex++; oldindex++; } } newp->num_entities = newindex; - cl_last_sequence = cls.netchan.incoming_sequence; } void @@ -487,6 +397,7 @@ CL_LinkPacketEntities (void) entity_state_t *s1; model_t *model; packet_entities_t *pack; + player_info_t *info; pack = &cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK].packet_entities; @@ -518,23 +429,76 @@ CL_LinkPacketEntities (void) if (!ent) break; // object list is full - *ent = &cl_entities[s1->number]; + *ent = &cl_packet_ents[s1->number]; - model = (*ent)->model; + (*ent)->model = model = cl.model_precache[s1->modelindex]; - if (!model) { - Con_Printf ("WARNING: null model: %d %s\n", s1->number, - cl.model_precache[s1->modelindex]->name); - model = (*ent)->model = cl.model_precache[s1->modelindex]; - cl_entity_model_states[s1->number].model = model; + // set colormap + if (s1->colormap && (s1->colormap <= MAX_CLIENTS) + && cl.players[s1->colormap - 1].name[0] + && !strcmp ((*ent)->model->name, "progs/player.mdl")) { + (*ent)->colormap = cl.players[s1->colormap - 1].translations; + info = &cl.players[s1->colormap - 1]; + } else { + (*ent)->colormap = vid.colormap8; + info = NULL; } + if (info && !info->skin) + Skin_Find (info); + if (info && info->skin) { + (*ent)->skin = Skin_NewTempSkin (); + if ((*ent)->skin) { + i = s1->colormap - 1; + CL_NewTranslation (i, (*ent)->skin); + } + } else { + (*ent)->skin = NULL; + } + + // LordHavoc: cleaned up Endy's coding style, and fixed Endy's bugs + // Ender: Extend (Colormod) [QSG - Begin] + // N.B: All messy code below is the sole fault of LordHavoc and + // his futile attempts to save bandwidth. :) + (*ent)->glow_size = s1->glow_size < 128 ? s1->glow_size * 8.0 : + (s1->glow_size - 256) * 8.0; + (*ent)->glow_color = s1->glow_color; + (*ent)->alpha = s1->alpha / 255.0; + (*ent)->scale = s1->scale / 16.0; + + if (s1->colormod == 255) { + (*ent)->colormod[0] = (*ent)->colormod[1] = + (*ent)->colormod[2] = 1; + } else { + (*ent)->colormod[0] = (float) ((s1->colormod >> 5) & 7) * (1.0 / + 7.0); + (*ent)->colormod[1] = (float) ((s1->colormod >> 2) & 7) * (1.0 / + 7.0); + (*ent)->colormod[2] = (float) (s1->colormod & 3) * (1.0 / 3.0); + } + // Ender: Extend (Colormod) [QSG - End] + + // set skin + (*ent)->skinnum = s1->skinnum; + + // set frame + (*ent)->frame = s1->frame; + if ((*ent)->visframe != r_framecount - 1) { + (*ent)->pose1 = (*ent)->pose2 = -1; + } + (*ent)->visframe = r_framecount; + if (model->flags & EF_ROTATE) { // rotate binary objects locally (*ent)->angles[0] = 0; (*ent)->angles[1] = anglemod (100 * cl.time); (*ent)->angles[2] = 0; + } else { + VectorCopy(s1->angles, (*ent)->angles); } + VectorCopy ((*ent)->origin, (*ent)->old_origin); + VectorCopy (s1->origin, (*ent)->origin); + // add automatic particle trails if (!model->flags) continue; @@ -635,14 +599,12 @@ CL_ParsePlayerinfo (void) { int flags, msec, num, i; player_state_t *state; - entity_t *ent; num = MSG_ReadByte (net_message); - if (num >= MAX_CLIENTS) + if (num > MAX_CLIENTS) Host_Error ("CL_ParsePlayerinfo: bad num"); state = &cl.frames[parsecountmod].playerstate[num]; - ent = &cl_entities[num + 1]; state->number = num; flags = state->flags = MSG_ReadShort (net_message); @@ -651,10 +613,8 @@ CL_ParsePlayerinfo (void) state->origin[0] = MSG_ReadCoord (net_message); state->origin[1] = MSG_ReadCoord (net_message); state->origin[2] = MSG_ReadCoord (net_message); - VectorCopy (state->origin, ent->origin); state->frame = MSG_ReadByte (net_message); - ent->frame = state->frame; // the other player's last move was likely some time // before the packet was sent out, so accurately track @@ -679,13 +639,11 @@ CL_ParsePlayerinfo (void) else i = cl_playerindex; state->modelindex = i; - ent->model = cl.model_precache[i]; if (flags & PF_SKINNUM) state->skinnum = MSG_ReadByte (net_message); else state->skinnum = 0; - ent->skinnum = state->skinnum; if (flags & PF_EFFECTS) state->effects = MSG_ReadByte (net_message); @@ -698,14 +656,6 @@ CL_ParsePlayerinfo (void) state->weaponframe = 0; VectorCopy (state->command.angles, state->viewangles); - - if (cl_entity_model_states[ent - cl_entities].model != ent->model - || cl_entity_model_states[ent - cl_entities].skinnum != ent->skinnum) { - cl_entity_model_states[ent - cl_entities].model = ent->model; - cl_entity_model_states[ent - cl_entities].skinnum = ent->skinnum; - CL_SetColormap (ent, num); - } - //FIXME: players don't have extend stuff } /* @@ -815,7 +765,7 @@ CL_LinkPlayers (void) // spawn light flashes, even ones coming from invisible objects if (j == cl.playernum) { VectorCopy (cl.simorg, org); - r_player_entity = &cl_entities[j + 1]; + r_player_entity = &cl_player_ents[j]; } else VectorCopy (state->origin, org); @@ -845,7 +795,35 @@ CL_LinkPlayers (void) _ent = R_NewEntity (); if (!_ent) // object list is full break; - ent = *_ent = &cl_entities[j + 1]; + ent = *_ent = &cl_player_ents[j]; + + ent->frame = state->frame; + ent->model = cl.model_precache[state->modelindex]; + ent->skinnum = state->skinnum; + ent->colormap = info->translations; + if (state->modelindex == cl_playerindex) { //XXX + // use custom skin + if (!info->skin) + Skin_Find (info); + if (info && info->skin) { + ent->skin = Skin_NewTempSkin (); + if (ent->skin) { + CL_NewTranslation (j, ent->skin); + } + } else { + ent->skin = NULL; + } + } else { + ent->skin = NULL; + } + + // LordHavoc: more QSG VERSION 2 stuff, FIXME: players don't have + // extend stuff + ent->glow_size = 0; + ent->glow_color = 254; + ent->alpha = 1; + ent->scale = 1; + ent->colormod[0] = ent->colormod[1] = ent->colormod[2] = 1; // angles if (j == cl.playernum) @@ -861,19 +839,18 @@ CL_LinkPlayers (void) ent->angles[ROLL] = 0; ent->angles[ROLL] = V_CalcRoll (ent->angles, state->velocity) * 4; - if (cl_predict_players->int_val) { - // only predict half the move to minimize overruns - msec = 500 * (playertime - state->state_time); - if (msec > 0) { - // predict players movement - state->command.msec = msec = min (msec, 255); + // only predict half the move to minimize overruns + msec = 500 * (playertime - state->state_time); + if (msec <= 0 || (!cl_predict_players->int_val)) { + VectorCopy (state->origin, ent->origin); + } else { // predict players movement + state->command.msec = msec = min (msec, 255); - oldphysent = pmove.numphysent; - CL_SetSolidPlayers (j); - CL_PredictUsercmd (state, &exact, &state->command, false); - pmove.numphysent = oldphysent; - VectorCopy (exact.origin, ent->origin); - } + oldphysent = pmove.numphysent; + CL_SetSolidPlayers (j); + CL_PredictUsercmd (state, &exact, &state->command, false); + pmove.numphysent = oldphysent; + VectorCopy (exact.origin, ent->origin); } if (state->effects & EF_FLAG1) @@ -1056,6 +1033,7 @@ CL_EmitEntities (void) return; R_ClearEnts (); + Skin_ClearTempSkins (); CL_LinkPlayers (); CL_LinkPacketEntities (); @@ -1068,10 +1046,6 @@ CL_Ents_Init (void) { int i; - for (i = 0; i < MAX_CLIENTS; i++) - CL_Init_Entity (&cl_flag_ents[i]); for (i = 0; i < MAX_PROJECTILES; i++) CL_Init_Entity (&cl_projectiles[i]); - for (i = 0; i < MAX_EDICTS; i++) - CL_Init_Entity (&cl_entities[i]); } diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 48c0c7711..10f47660d 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -417,7 +417,6 @@ CL_ClearState (void) CL_ClearEnts (); CL_ClearTEnts (); - Skin_ClearTempSkins (); R_ClearEfrags (); R_ClearDlights (); @@ -530,10 +529,10 @@ CL_User_f (void) uid = atoi (Cmd_Argv (1)); for (i = 0; i < MAX_CLIENTS; i++) { - if (!cl.players[i].name) + if (!cl.players[i].name[0]) continue; if (cl.players[i].userid == uid - || !strcmp (cl.players[i].name->value, Cmd_Argv (1))) { + || !strcmp (cl.players[i].name, Cmd_Argv (1))) { Info_Print (cl.players[i].userinfo); return; } @@ -555,9 +554,9 @@ CL_Users_f (void) Con_Printf ("userid frags name\n"); Con_Printf ("------ ----- ----\n"); for (i = 0; i < MAX_CLIENTS; i++) { - if (cl.players[i].name) { + if (cl.players[i].name[0]) { Con_Printf ("%6i %4i %s\n", cl.players[i].userid, - cl.players[i].frags, cl.players[i].name->value); + cl.players[i].frags, cl.players[i].name); c++; } } diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index ebc923633..e397cb026 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -800,7 +800,7 @@ CL_ParseModellist (void) } void -CL_ParseBaseline (entity_state_t *es, entity_t *ent) +CL_ParseBaseline (entity_state_t *es) { int i; @@ -819,7 +819,6 @@ CL_ParseBaseline (entity_state_t *es, entity_t *ent) es->glow_color = 254; es->glow_size = 0; es->colormod = 255; - CL_EntFromBaseline (es, ent, ent - cl_entities); } /* @@ -834,11 +833,20 @@ CL_ParseStatic (void) entity_t *ent; entity_state_t es; + CL_ParseBaseline (&es); + if (cl.num_statics >= MAX_STATIC_ENTITIES) Host_Error ("Too many static entities"); ent = &cl_static_entities[cl.num_statics++]; + CL_Init_Entity (ent); - CL_ParseBaseline (&es, ent); + // copy it to the current state + ent->model = cl.model_precache[es.modelindex]; + ent->frame = es.frame; + ent->skinnum = es.skinnum; + + VectorCopy (es.origin, ent->origin); + VectorCopy (es.angles, ent->angles); R_AddEfrags (ent); } @@ -942,12 +950,13 @@ CL_ProcessUserInfo (int slot, player_info_t *player) COM_StripExtension (s, skin); // FIXME buffer overflow if (!strequal (s, skin)) Info_SetValueForKey (player->userinfo, "skin", skin, 1); + strncpy (player->name, Info_ValueForKey (player->userinfo, "name"), + sizeof (player->name) - 1); player->_topcolor = player->_bottomcolor = -1; player->topcolor = atoi (Info_ValueForKey (player->userinfo, "topcolor")); player->bottomcolor = atoi (Info_ValueForKey (player->userinfo, "bottomcolor")); - player->name = Hash_Find (player->userinfo->tab, "name"); while (!(player->team = Hash_Find (player->userinfo->tab, "team"))) Info_SetValueForKey (player->userinfo, "team", "", 1); while (!(player->skinname = Hash_Find (player->userinfo->tab, "skin"))) @@ -962,9 +971,7 @@ CL_ProcessUserInfo (int slot, player_info_t *player) Skin_Find (player); Sbar_Changed (); - if (!player->name) - return; - CL_SetColormap (&cl_entities[slot + 1], slot); + //XXX CL_NewTranslation (slot); } void @@ -1007,9 +1014,7 @@ CL_SetInfo (void) strncpy (value, MSG_ReadString (net_message), sizeof (value) - 1); key[sizeof (value) - 1] = 0; - Con_DPrintf ("SETINFO %s: %s=%s\n", player->name ? player->name->value - : "", - key, value); + Con_DPrintf ("SETINFO %s: %s=%s\n", player->name, key, value); if (!player->userinfo) player->userinfo = Info_ParseString ("", MAX_INFO_STRING); @@ -1271,7 +1276,7 @@ CL_ParseServerMessage (void) case svc_spawnbaseline: i = MSG_ReadShort (net_message); - CL_ParseBaseline (&cl_baselines[i], &cl_entities[i]); + CL_ParseBaseline (&cl_baselines[i]); break; case svc_spawnstatic: CL_ParseStatic (); diff --git a/qw/source/cl_skin.c b/qw/source/cl_skin.c index 7797f3d5f..1ca8dd529 100644 --- a/qw/source/cl_skin.c +++ b/qw/source/cl_skin.c @@ -44,10 +44,8 @@ static const char rcsid[] = #include "QF/screen.h" #include "QF/va.h" -#include "bothdefs.h" #include "cl_parse.h" #include "cl_skin.h" -#include "cl_tent.h" #include "client.h" #include "compat.h" #include "host.h" @@ -73,7 +71,7 @@ Skin_NextDownload (void) for (; cls.downloadnumber != MAX_CLIENTS; cls.downloadnumber++) { sc = &cl.players[cls.downloadnumber]; - if (!sc->name) + if (!sc->name[0]) continue; Skin_Find (sc); if (noskins->int_val) //XXX FIXME @@ -90,7 +88,7 @@ Skin_NextDownload (void) // now load them in for real for (i = 0; i < MAX_CLIENTS; i++) { sc = &cl.players[i]; - if (!sc->name) + if (!sc->name[0]) continue; Skin_Find (sc); Skin_Cache (sc->skin); @@ -211,7 +209,7 @@ CL_NewTranslation (int slot, skin_t *skin) Host_Error ("CL_NewTranslation: slot > MAX_CLIENTS"); player = &cl.players[slot]; - if (!player->name) + if (!player->name[0]) return; if (player->skin && !strequal (player->skinname->value, player->skin->name)) @@ -237,27 +235,3 @@ CL_NewTranslation (int slot, skin_t *skin) // FIXME: breaks cache ownership } } - -skin_t cl_skins[MAX_EDICTS]; - -void -CL_SetColormap (entity_t *ent, int slot) -{ - player_info_t *info = &cl.players[slot]; - - if ((unsigned int)slot <= MAX_CLIENTS && info->name - && ent->model && strequal (ent->model->name, "progs/player.mdl")) { - if (!info->skin) - Skin_Find (info); - if (info->skin) { - ent->skin = &cl_skins[ent - cl_entities]; - CL_NewTranslation (slot, ent->skin); - } else { - ent->skin = NULL; - } - ent->colormap = info->translations; - } else { - ent->colormap = vid.colormap8; - ent->skin = NULL; - } -} diff --git a/qw/source/sbar.c b/qw/source/sbar.c index d649f17e8..5ada26369 100644 --- a/qw/source/sbar.c +++ b/qw/source/sbar.c @@ -366,7 +366,7 @@ Sbar_SortFrags (qboolean includespec) // sort by frags scoreboardlines = 0; for (i = 0; i < MAX_CLIENTS; i++) { - if (cl.players[i].name && (!cl.players[i].spectator || includespec)) { + if (cl.players[i].name[0] && (!cl.players[i].spectator || includespec)) { fragsort[scoreboardlines] = i; scoreboardlines++; if (cl.players[i].spectator) @@ -404,7 +404,7 @@ Sbar_SortTeams (void) for (i = 0; i < MAX_CLIENTS; i++) { s = &cl.players[i]; - if (!s->name) + if (!s->name[0]) continue; if (s->spectator) continue; @@ -589,7 +589,7 @@ Sbar_DrawFrags (void) for (i = 0; i < l; i++) { k = fragsort[i]; s = &cl.players[k]; - if (!s->name) + if (!s->name[0]) continue; if (s->spectator) continue; @@ -739,7 +739,7 @@ Sbar_Draw (int swap) // Sbar_DrawString (160-14*8+4,4, "SPECTATOR MODE - TRACK CAMERA"); snprintf (st, sizeof (st), "Tracking %-.13s, [JUMP] for next", - cl.players[spec_track].name->value); + cl.players[spec_track].name); Sbar_DrawString (0, -8, st); } } else if (sb_showscores || cl.stats[STAT_HEALTH] <= 0) @@ -957,7 +957,7 @@ Sbar_DeathmatchOverlay (int start) for (i = 0; i < l && y <= vid.height - 10; i++) { k = fragsort[i]; s = &cl.players[k]; - if (!s->name) + if (!s->name[0]) continue; // draw ping @@ -983,9 +983,9 @@ Sbar_DeathmatchOverlay (int start) Draw_String (x + 40, y, "(spectator)"); // draw name if (cl.teamplay) - Draw_String (x + 152 + 40, y, s->name->value); + Draw_String (x + 152 + 40, y, s->name); else - Draw_String (x + 152, y, s->name->value); + Draw_String (x + 152, y, s->name); y += skip; continue; } @@ -1031,9 +1031,9 @@ Sbar_DeathmatchOverlay (int start) } // draw name if (cl.teamplay) - Draw_String (x + 152 + 40, y, s->name->value); + Draw_String (x + 152 + 40, y, s->name); else - Draw_String (x + 152, y, s->name->value); + Draw_String (x + 152, y, s->name); y += skip; } @@ -1098,7 +1098,7 @@ Sbar_MiniDeathmatchOverlay (void) for ( /* */ ; i < scoreboardlines && y < vid.height - 8 + 1; i++) { k = fragsort[i]; s = &cl.players[k]; - if (!s->name) + if (!s->name[0]) continue; // draw ping @@ -1130,7 +1130,7 @@ Sbar_MiniDeathmatchOverlay (void) } // draw name name[16] = 0; - strncpy (name, s->name->value, 16); + strncpy (name, s->name, 16); if (cl.teamplay) Draw_String (x + 48 + 40, y, name); else