From fb5638603d5fb14033bb41a99dbaba135b5e7985 Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 29 Oct 2002 15:36:49 +0000 Subject: [PATCH] changed how QC interpreter handles edict field access - the entvars struct is now a pointer - yes this changed that many files... discovered gcc 2.95.3 is the sole cause of map change crashs in the QC interpreter - it does not compile pr_exec.c correctly somehow (I think OP_ADDRESS is the only place it has a problem), makefile now refers to gcc-3.1 (maybe this should be changed, but oh well for now) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2580 d7cf8633-e32d-0410-b094-e92efae38249 --- host_cmd.c | 134 ++++++------- makefile | 2 +- net_dgrm.c | 2 +- pr_cmds.c | 148 +++++++------- pr_edict.c | 83 +++++--- pr_exec.c | 10 +- pr_execprogram.h | 95 +++------ progs.h | 25 ++- server.h | 2 + sv_main.c | 229 ++++++++++----------- sv_move.c | 84 ++++---- sv_phys.c | 506 +++++++++++++++++++++++------------------------ sv_user.c | 78 ++++---- world.c | 128 ++++++------ 14 files changed, 751 insertions(+), 775 deletions(-) diff --git a/host_cmd.c b/host_cmd.c index da2705a4..bd079b02 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -89,7 +89,7 @@ void Host_Status_f (void) } else hours = 0; - print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->v.frags, hours, minutes, seconds); + print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->v->frags, hours, minutes, seconds); print (" %s\n", client->netconnection->address); } } @@ -113,8 +113,8 @@ void Host_God_f (void) if (pr_global_struct->deathmatch) return; - sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE; - if (!((int)sv_player->v.flags & FL_GODMODE) ) + sv_player->v->flags = (int)sv_player->v->flags ^ FL_GODMODE; + if (!((int)sv_player->v->flags & FL_GODMODE) ) SV_ClientPrintf ("godmode OFF\n"); else SV_ClientPrintf ("godmode ON\n"); @@ -131,8 +131,8 @@ void Host_Notarget_f (void) if (pr_global_struct->deathmatch) return; - sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET; - if (!((int)sv_player->v.flags & FL_NOTARGET) ) + sv_player->v->flags = (int)sv_player->v->flags ^ FL_NOTARGET; + if (!((int)sv_player->v->flags & FL_NOTARGET) ) SV_ClientPrintf ("notarget OFF\n"); else SV_ClientPrintf ("notarget ON\n"); @@ -151,16 +151,16 @@ void Host_Noclip_f (void) if (pr_global_struct->deathmatch) return; - if (sv_player->v.movetype != MOVETYPE_NOCLIP) + if (sv_player->v->movetype != MOVETYPE_NOCLIP) { noclip_anglehack = true; - sv_player->v.movetype = MOVETYPE_NOCLIP; + sv_player->v->movetype = MOVETYPE_NOCLIP; SV_ClientPrintf ("noclip ON\n"); } else { noclip_anglehack = false; - sv_player->v.movetype = MOVETYPE_WALK; + sv_player->v->movetype = MOVETYPE_WALK; SV_ClientPrintf ("noclip OFF\n"); } } @@ -183,14 +183,14 @@ void Host_Fly_f (void) if (pr_global_struct->deathmatch) return; - if (sv_player->v.movetype != MOVETYPE_FLY) + if (sv_player->v->movetype != MOVETYPE_FLY) { - sv_player->v.movetype = MOVETYPE_FLY; + sv_player->v->movetype = MOVETYPE_FLY; SV_ClientPrintf ("flymode ON\n"); } else { - sv_player->v.movetype = MOVETYPE_WALK; + sv_player->v->movetype = MOVETYPE_WALK; SV_ClientPrintf ("flymode OFF\n"); } } @@ -207,7 +207,7 @@ void Host_Ping_f (void) int i, j; float total; client_t *client; - + if (cmd_source == src_command) { Cmd_ForwardToServer (); @@ -418,7 +418,7 @@ void Host_Savegame_f (void) for (i=0 ; iv.health <= 0) ) + if (svs.clients[i].active && (svs.clients[i].edict->v->health <= 0) ) { Con_Printf ("Can't savegame with a dead player\n"); return; @@ -600,7 +600,7 @@ void Host_PerformLoadGame(char *name) { // parse an edict ent = EDICT_NUM(entnum); - memset (&ent->v, 0, progs->entityfields * 4); + memset (ent->v, 0, progs->entityfields * 4); ent->free = false; ED_ParseEdict (start, ent); @@ -664,7 +664,7 @@ void Host_Name_f (void) if (strcmp(host_client->name, newName) != 0) Con_Printf ("%s renamed to %s\n", host_client->name, newName); strcpy (host_client->name, newName); - host_client->edict->v.netname = host_client->name - pr_strings; + host_client->edict->v->netname = host_client->name - pr_strings; // send notification to all clients @@ -739,7 +739,7 @@ void Host_Say(qboolean teamonly) { if (!client || !client->active || !client->spawned) continue; - if (teamplay.integer && teamonly && client->edict->v.team != save->edict->v.team) + if (teamplay.integer && teamonly && client->edict->v->team != save->edict->v->team) continue; host_client = client; SV_ClientPrintf("%s", text); @@ -888,7 +888,7 @@ void Host_Color_f(void) else { host_client->colors = playercolor; - host_client->edict->v.team = bottom + 1; + host_client->edict->v->team = bottom + 1; // send notification to all clients MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors); @@ -910,7 +910,7 @@ void Host_Kill_f (void) return; } - if (sv_player->v.health <= 0) + if (sv_player->v->health <= 0) { SV_ClientPrintf ("Can't suicide -- already dead!\n"); return; @@ -929,7 +929,7 @@ Host_Pause_f */ void Host_Pause_f (void) { - + if (cmd_source == src_command) { Cmd_ForwardToServer (); @@ -943,11 +943,11 @@ void Host_Pause_f (void) if (sv.paused) { - SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v.netname); + SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v->netname); } else { - SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v.netname); + SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v->netname); } // send notification to all clients @@ -977,7 +977,7 @@ void Host_PreSpawn_f (void) Con_Printf ("prespawn not valid -- already spawned\n"); return; } - + SZ_Write (&host_client->message, sv.signon.data, sv.signon.cursize); MSG_WriteByte (&host_client->message, svc_signonnum); MSG_WriteByte (&host_client->message, 2); @@ -1035,10 +1035,10 @@ void Host_Spawn_f (void) // set up the edict ent = host_client->edict; - memset (&ent->v, 0, progs->entityfields * 4); - ent->v.colormap = NUM_FOR_EDICT(ent); - ent->v.team = (host_client->colors & 15) + 1; - ent->v.netname = host_client->name - pr_strings; + memset (ent->v, 0, progs->entityfields * 4); + ent->v->colormap = NUM_FOR_EDICT(ent); + ent->v->team = (host_client->colors & 15) + 1; + ent->v->netname = host_client->name - pr_strings; if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel))) val->_float = host_client->pmodel; @@ -1112,7 +1112,7 @@ void Host_Spawn_f (void) ent = EDICT_NUM( 1 + (host_client - svs.clients) ); MSG_WriteByte (&host_client->message, svc_setangle); for (i=0 ; i < 2 ; i++) - MSG_WriteAngle (&host_client->message, ent->v.angles[i] ); + MSG_WriteAngle (&host_client->message, ent->v->angles[i] ); MSG_WriteAngle (&host_client->message, 0 ); SV_WriteClientdataToMessage (sv_player, &host_client->message); @@ -1279,21 +1279,21 @@ void Host_Give_f (void) if (t[0] == '6') { if (t[1] == 'a') - sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN; + sv_player->v->items = (int)sv_player->v->items | HIT_PROXIMITY_GUN; else - sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER; + sv_player->v->items = (int)sv_player->v->items | IT_GRENADE_LAUNCHER; } else if (t[0] == '9') - sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON; + sv_player->v->items = (int)sv_player->v->items | HIT_LASER_CANNON; else if (t[0] == '0') - sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR; + sv_player->v->items = (int)sv_player->v->items | HIT_MJOLNIR; else if (t[0] >= '2') - sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2')); + sv_player->v->items = (int)sv_player->v->items | (IT_SHOTGUN << (t[0] - '2')); } else { if (t[0] >= '2') - sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2')); + sv_player->v->items = (int)sv_player->v->items | (IT_SHOTGUN << (t[0] - '2')); } break; @@ -1304,7 +1304,7 @@ void Host_Give_f (void) val->_float = v; } - sv_player->v.ammo_shells = v; + sv_player->v->ammo_shells = v; break; case 'n': if (gamemode == GAME_ROGUE) @@ -1312,13 +1312,13 @@ void Host_Give_f (void) if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1))) { val->_float = v; - if (sv_player->v.weapon <= IT_LIGHTNING) - sv_player->v.ammo_nails = v; + if (sv_player->v->weapon <= IT_LIGHTNING) + sv_player->v->ammo_nails = v; } } else { - sv_player->v.ammo_nails = v; + sv_player->v->ammo_nails = v; } break; case 'l': @@ -1328,8 +1328,8 @@ void Host_Give_f (void) if (val) { val->_float = v; - if (sv_player->v.weapon > IT_LIGHTNING) - sv_player->v.ammo_nails = v; + if (sv_player->v->weapon > IT_LIGHTNING) + sv_player->v->ammo_nails = v; } } break; @@ -1340,13 +1340,13 @@ void Host_Give_f (void) if (val) { val->_float = v; - if (sv_player->v.weapon <= IT_LIGHTNING) - sv_player->v.ammo_rockets = v; + if (sv_player->v->weapon <= IT_LIGHTNING) + sv_player->v->ammo_rockets = v; } } else { - sv_player->v.ammo_rockets = v; + sv_player->v->ammo_rockets = v; } break; case 'm': @@ -1356,13 +1356,13 @@ void Host_Give_f (void) if (val) { val->_float = v; - if (sv_player->v.weapon > IT_LIGHTNING) - sv_player->v.ammo_rockets = v; + if (sv_player->v->weapon > IT_LIGHTNING) + sv_player->v->ammo_rockets = v; } } break; case 'h': - sv_player->v.health = v; + sv_player->v->health = v; break; case 'c': if (gamemode == GAME_ROGUE) @@ -1371,13 +1371,13 @@ void Host_Give_f (void) if (val) { val->_float = v; - if (sv_player->v.weapon <= IT_LIGHTNING) - sv_player->v.ammo_cells = v; + if (sv_player->v->weapon <= IT_LIGHTNING) + sv_player->v->ammo_cells = v; } } else { - sv_player->v.ammo_cells = v; + sv_player->v->ammo_cells = v; } break; case 'p': @@ -1387,8 +1387,8 @@ void Host_Give_f (void) if (val) { val->_float = v; - if (sv_player->v.weapon > IT_LIGHTNING) - sv_player->v.ammo_cells = v; + if (sv_player->v->weapon > IT_LIGHTNING) + sv_player->v->ammo_cells = v; } } break; @@ -1403,7 +1403,7 @@ edict_t *FindViewthing (void) for (i=0 ; iv.classname, "viewthing") ) + if ( !strcmp (pr_strings + e->v->classname, "viewthing") ) return e; } Con_Printf ("No viewthing on map\n"); @@ -1430,9 +1430,9 @@ void Host_Viewmodel_f (void) Con_Printf ("Can't load %s\n", Cmd_Argv(1)); return; } - - e->v.frame = 0; - cl.model_precache[(int)e->v.modelindex] = m; + + e->v->frame = 0; + cl.model_precache[(int)e->v->modelindex] = m; } /* @@ -1449,13 +1449,13 @@ void Host_Viewframe_f (void) e = FindViewthing (); if (!e) return; - m = cl.model_precache[(int)e->v.modelindex]; + m = cl.model_precache[(int)e->v->modelindex]; f = atoi(Cmd_Argv(1)); if (f >= m->numframes) f = m->numframes-1; - e->v.frame = f; + e->v->frame = f; } @@ -1476,17 +1476,17 @@ void Host_Viewnext_f (void) { edict_t *e; model_t *m; - + e = FindViewthing (); if (!e) return; - m = cl.model_precache[(int)e->v.modelindex]; + m = cl.model_precache[(int)e->v->modelindex]; - e->v.frame = e->v.frame + 1; - if (e->v.frame >= m->numframes) - e->v.frame = m->numframes - 1; + e->v->frame = e->v->frame + 1; + if (e->v->frame >= m->numframes) + e->v->frame = m->numframes - 1; - PrintFrameName (m, e->v.frame); + PrintFrameName (m, e->v->frame); } /* @@ -1503,13 +1503,13 @@ void Host_Viewprev_f (void) if (!e) return; - m = cl.model_precache[(int)e->v.modelindex]; + m = cl.model_precache[(int)e->v->modelindex]; - e->v.frame = e->v.frame - 1; - if (e->v.frame < 0) - e->v.frame = 0; + e->v->frame = e->v->frame - 1; + if (e->v->frame < 0) + e->v->frame = 0; - PrintFrameName (m, e->v.frame); + PrintFrameName (m, e->v->frame); } /* diff --git a/makefile b/makefile index 5502b27d..9e7802ac 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,7 @@ ##### Variables that you may want to modify ##### #choose the compiler you want to use -CC=gcc +CC=gcc-3.1 #recommended for: anyone not using ALSA 0.5 OBJ_SND=snd_oss.o snd_dma.o snd_mix.o snd_mem.o diff --git a/net_dgrm.c b/net_dgrm.c index ede95806..fe34fba0 100644 --- a/net_dgrm.c +++ b/net_dgrm.c @@ -918,7 +918,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void) MSG_WriteByte(&net_message, playerNumber); MSG_WriteString(&net_message, client->name); MSG_WriteLong(&net_message, client->colors); - MSG_WriteLong(&net_message, (int)client->edict->v.frags); + MSG_WriteLong(&net_message, (int)client->edict->v->frags); MSG_WriteLong(&net_message, (int)(net_time - client->netconnection->connecttime)); MSG_WriteString(&net_message, client->netconnection->address); *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK)); diff --git a/pr_cmds.c b/pr_cmds.c index c37b456e..304773cc 100644 --- a/pr_cmds.c +++ b/pr_cmds.c @@ -215,10 +215,10 @@ void PF_setorigin (void) { edict_t *e; float *org; - + e = G_EDICT(OFS_PARM0); org = G_VECTOR(OFS_PARM1); - VectorCopy (org, e->v.origin); + VectorCopy (org, e->v->origin); SV_LinkEdict (e, false); } @@ -232,9 +232,9 @@ void SetMinMaxSize (edict_t *e, float *min, float *max, qboolean rotate) Host_Error ("backwards mins/maxs"); // set derived values - VectorCopy (min, e->v.mins); - VectorCopy (max, e->v.maxs); - VectorSubtract (max, min, e->v.size); + VectorCopy (min, e->v->mins); + VectorCopy (max, e->v->maxs); + VectorSubtract (max, min, e->v->size); SV_LinkEdict (e, false); } @@ -287,10 +287,10 @@ void PF_setmodel (void) Host_Error ("no precache: %s\n", m); - e->v.model = m - pr_strings; - e->v.modelindex = i; + e->v->model = m - pr_strings; + e->v->modelindex = i; - mod = sv.models[ (int)e->v.modelindex]; + mod = sv.models[ (int)e->v->modelindex]; if (mod) SetMinMaxSize (e, mod->normalmins, mod->normalmaxs, true); @@ -405,7 +405,7 @@ void PF_normalize (void) newvalue[2] = value1[2] * new; } - VectorCopy (newvalue, G_VECTOR(OFS_RETURN)); + VectorCopy (newvalue, G_VECTOR(OFS_RETURN)); } /* @@ -809,9 +809,9 @@ int PF_newcheckclient (int check) if (ent->free) continue; - if (ent->v.health <= 0) + if (ent->v->health <= 0) continue; - if ((int)ent->v.flags & FL_NOTARGET) + if ((int)ent->v->flags & FL_NOTARGET) continue; // anything that is a client, or has a client as an enemy @@ -819,7 +819,7 @@ int PF_newcheckclient (int check) } // get the PVS for the entity - VectorAdd (ent->v.origin, ent->v.view_ofs, org); + VectorAdd (ent->v->origin, ent->v->view_ofs, org); leaf = Mod_PointInLeaf (org, sv.worldmodel); pvs = Mod_LeafPVS (leaf, sv.worldmodel); memcpy (checkpvs, pvs, (sv.worldmodel->numleafs+7)>>3 ); @@ -859,7 +859,7 @@ void PF_checkclient (void) // return check if it might be visible ent = EDICT_NUM(sv.lastcheck); - if (ent->free || ent->v.health <= 0) + if (ent->free || ent->v->health <= 0) { RETURN_EDICT(sv.edicts); return; @@ -867,7 +867,7 @@ void PF_checkclient (void) // if current entity can't possibly see the check entity, return 0 self = PROG_TO_EDICT(pr_global_struct->self); - VectorAdd (self->v.origin, self->v.view_ofs, view); + VectorAdd (self->v->origin, self->v->view_ofs, view); leaf = Mod_PointInLeaf (view, sv.worldmodel); if (leaf) { @@ -983,7 +983,7 @@ void PF_findradius (void) int i; chain = (edict_t *)sv.edicts; - + org = G_VECTOR(OFS_PARM0); radius = G_FLOAT(OFS_PARM1); radius2 = radius * radius; @@ -993,18 +993,18 @@ void PF_findradius (void) { if (ent->free) continue; - if (ent->v.solid == SOLID_NOT) + if (ent->v->solid == SOLID_NOT) continue; // LordHavoc: compare against bounding box rather than center, // and use DotProduct instead of Length, major speedup - eorg[0] = (org[0] - ent->v.origin[0]) - bound(ent->v.mins[0], (org[0] - ent->v.origin[0]), ent->v.maxs[0]); - eorg[1] = (org[1] - ent->v.origin[1]) - bound(ent->v.mins[1], (org[1] - ent->v.origin[1]), ent->v.maxs[1]); - eorg[2] = (org[2] - ent->v.origin[2]) - bound(ent->v.mins[2], (org[2] - ent->v.origin[2]), ent->v.maxs[2]); + eorg[0] = (org[0] - ent->v->origin[0]) - bound(ent->v->mins[0], (org[0] - ent->v->origin[0]), ent->v->maxs[0]); + eorg[1] = (org[1] - ent->v->origin[1]) - bound(ent->v->mins[1], (org[1] - ent->v->origin[1]), ent->v->maxs[1]); + eorg[2] = (org[2] - ent->v->origin[2]) - bound(ent->v->mins[2], (org[2] - ent->v->origin[2]), ent->v->maxs[2]); if (DotProduct(eorg, eorg) > radius2) continue; - - ent->v.chain = EDICT_TO_PROG(chain); + + ent->v->chain = EDICT_TO_PROG(chain); chain = ent; } @@ -1129,7 +1129,7 @@ void PF_Find (void) // LordHavoc: added this for searching float, int, and entity reference fields void PF_FindFloat (void) { - int e; + int e; int f; float s; edict_t *ed; @@ -1137,7 +1137,7 @@ void PF_FindFloat (void) e = G_EDICTNUM(OFS_PARM0); f = G_INT(OFS_PARM1); s = G_FLOAT(OFS_PARM2); - + for (e++ ; e < sv.num_edicts ; e++) { ed = EDICT_NUM(e); @@ -1157,7 +1157,7 @@ void PF_FindFloat (void) // entity(.string field, string match) findchain = #402; void PF_findchain (void) { - int i; + int i; int f; char *s, *t; edict_t *ent, *chain; @@ -1171,7 +1171,7 @@ void PF_findchain (void) RETURN_EDICT(sv.edicts); return; } - + ent = NEXT_EDICT(sv.edicts); for (i = 1;i < sv.num_edicts;i++, ent = NEXT_EDICT(ent)) { @@ -1183,7 +1183,7 @@ void PF_findchain (void) if (strcmp(t,s)) continue; - ent->v.chain = EDICT_TO_PROG(chain); + ent->v->chain = EDICT_TO_PROG(chain); chain = ent; } @@ -1194,7 +1194,7 @@ void PF_findchain (void) // entity(.string field, float match) findchainfloat = #403; void PF_findchainfloat (void) { - int i; + int i; int f; float s; edict_t *ent, *chain; @@ -1203,7 +1203,7 @@ void PF_findchainfloat (void) f = G_INT(OFS_PARM0); s = G_FLOAT(OFS_PARM1); - + ent = NEXT_EDICT(sv.edicts); for (i = 1;i < sv.num_edicts;i++, ent = NEXT_EDICT(ent)) { @@ -1212,7 +1212,7 @@ void PF_findchainfloat (void) if (E_FLOAT(ent,f) != s) continue; - ent->v.chain = EDICT_TO_PROG(chain); + ent->v->chain = EDICT_TO_PROG(chain); chain = ent; } @@ -1241,7 +1241,7 @@ void PF_precache_sound (void) s = G_STRING(OFS_PARM0); G_INT(OFS_RETURN) = G_INT(OFS_PARM0); PR_CheckEmptyString (s); - + for (i=0 ; iself); yaw = G_FLOAT(OFS_PARM0); dist = G_FLOAT(OFS_PARM1); - - if ( !( (int)ent->v.flags & (FL_ONGROUND|FL_FLY|FL_SWIM) ) ) + + if ( !( (int)ent->v->flags & (FL_ONGROUND|FL_FLY|FL_SWIM) ) ) { G_FLOAT(OFS_RETURN) = 0; return; } yaw = yaw*M_PI*2 / 360; - + move[0] = cos(yaw)*dist; move[1] = sin(yaw)*dist; move[2] = 0; @@ -1338,10 +1338,10 @@ void PF_walkmove (void) // save program state, because SV_movestep may call other progs oldf = pr_xfunction; oldself = pr_global_struct->self; - + G_FLOAT(OFS_RETURN) = SV_movestep(ent, move, true); - - + + // restore program state pr_xfunction = oldf; pr_global_struct->self = oldself; @@ -1362,19 +1362,19 @@ void PF_droptofloor (void) ent = PROG_TO_EDICT(pr_global_struct->self); - VectorCopy (ent->v.origin, end); + VectorCopy (ent->v->origin, end); end[2] -= 256; - trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, end, MOVE_NORMAL, ent); + trace = SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, end, MOVE_NORMAL, ent); if (trace.fraction == 1 || trace.allsolid) G_FLOAT(OFS_RETURN) = 0; else { - VectorCopy (trace.endpos, ent->v.origin); + VectorCopy (trace.endpos, ent->v->origin); SV_LinkEdict (ent, false); - ent->v.flags = (int)ent->v.flags | FL_ONGROUND; - ent->v.groundentity = EDICT_TO_PROG(trace.ent); + ent->v->flags = (int)ent->v->flags | FL_ONGROUND; + ent->v->groundentity = EDICT_TO_PROG(trace.ent); G_FLOAT(OFS_RETURN) = 1; // if support is destroyed, keep suspended (gross hack for floating items in various maps) ent->suspendedinairflag = true; @@ -1503,15 +1503,15 @@ void PF_aim (void) ent = G_EDICT(OFS_PARM0); speed = G_FLOAT(OFS_PARM1); - VectorCopy (ent->v.origin, start); + VectorCopy (ent->v->origin, start); start[2] += 20; // try sending a trace straight VectorCopy (pr_global_struct->v_forward, dir); VectorMA (start, 2048, dir, end); tr = SV_Move (start, vec3_origin, vec3_origin, end, MOVE_NORMAL, ent); - if (tr.ent && ((edict_t *)tr.ent)->v.takedamage == DAMAGE_AIM - && (!teamplay.integer || ent->v.team <=0 || ent->v.team != ((edict_t *)tr.ent)->v.team) ) + if (tr.ent && ((edict_t *)tr.ent)->v->takedamage == DAMAGE_AIM + && (!teamplay.integer || ent->v->team <=0 || ent->v->team != ((edict_t *)tr.ent)->v->team) ) { VectorCopy (pr_global_struct->v_forward, G_VECTOR(OFS_RETURN)); return; @@ -1526,15 +1526,15 @@ void PF_aim (void) check = NEXT_EDICT(sv.edicts); for (i=1 ; iv.takedamage != DAMAGE_AIM) + if (check->v->takedamage != DAMAGE_AIM) continue; if (check == ent) continue; - if (teamplay.integer && ent->v.team > 0 && ent->v.team == check->v.team) + if (teamplay.integer && ent->v->team > 0 && ent->v->team == check->v->team) continue; // don't aim at teammate for (j=0 ; j<3 ; j++) - end[j] = check->v.origin[j] - + 0.5*(check->v.mins[j] + check->v.maxs[j]); + end[j] = check->v->origin[j] + + 0.5*(check->v->mins[j] + check->v->maxs[j]); VectorSubtract (end, start, dir); VectorNormalize (dir); dist = DotProduct (dir, pr_global_struct->v_forward); @@ -1550,7 +1550,7 @@ void PF_aim (void) if (bestent) { - VectorSubtract (bestent->v.origin, ent->v.origin, dir); + VectorSubtract (bestent->v->origin, ent->v->origin, dir); dist = DotProduct (dir, pr_global_struct->v_forward); VectorScale (pr_global_struct->v_forward, dist, end); end[2] = dir[2]; @@ -1576,9 +1576,9 @@ void PF_changeyaw (void) float ideal, current, move, speed; ent = PROG_TO_EDICT(pr_global_struct->self); - current = ANGLEMOD(ent->v.angles[1]); - ideal = ent->v.ideal_yaw; - speed = ent->v.yaw_speed; + current = ANGLEMOD(ent->v->angles[1]); + ideal = ent->v->ideal_yaw; + speed = ent->v->yaw_speed; if (current == ideal) return; @@ -1604,7 +1604,7 @@ void PF_changeyaw (void) move = -speed; } - ent->v.angles[1] = ANGLEMOD (current + move); + ent->v->angles[1] = ANGLEMOD (current + move); } /* @@ -1619,7 +1619,7 @@ void PF_changepitch (void) eval_t *val; ent = G_EDICT(OFS_PARM0); - current = ANGLEMOD( ent->v.angles[0] ); + current = ANGLEMOD( ent->v->angles[0] ); if ((val = GETEDICTFIELDVALUE(ent, eval_idealpitch))) ideal = val->_float; else @@ -1659,7 +1659,7 @@ void PF_changepitch (void) move = -speed; } - ent->v.angles[0] = ANGLEMOD (current + move); + ent->v->angles[0] = ANGLEMOD (current + move); } /* @@ -1759,28 +1759,28 @@ void PF_makestatic (void) ent = G_EDICT(OFS_PARM0); large = false; - if (ent->v.modelindex >= 256 || ent->v.frame >= 256) + if (ent->v->modelindex >= 256 || ent->v->frame >= 256) large = true; if (large) { MSG_WriteByte (&sv.signon,svc_spawnstatic2); - MSG_WriteShort (&sv.signon, ent->v.modelindex); - MSG_WriteShort (&sv.signon, ent->v.frame); + MSG_WriteShort (&sv.signon, ent->v->modelindex); + MSG_WriteShort (&sv.signon, ent->v->frame); } else { MSG_WriteByte (&sv.signon,svc_spawnstatic); - MSG_WriteByte (&sv.signon, ent->v.modelindex); - MSG_WriteByte (&sv.signon, ent->v.frame); + MSG_WriteByte (&sv.signon, ent->v->modelindex); + MSG_WriteByte (&sv.signon, ent->v->frame); } - MSG_WriteByte (&sv.signon, ent->v.colormap); - MSG_WriteByte (&sv.signon, ent->v.skin); + MSG_WriteByte (&sv.signon, ent->v->colormap); + MSG_WriteByte (&sv.signon, ent->v->skin); for (i=0 ; i<3 ; i++) { - MSG_WriteDPCoord(&sv.signon, ent->v.origin[i]); - MSG_WriteAngle(&sv.signon, ent->v.angles[i]); + MSG_WriteDPCoord(&sv.signon, ent->v->origin[i]); + MSG_WriteAngle(&sv.signon, ent->v->angles[i]); } // throw the entity away now @@ -2022,7 +2022,7 @@ void PF_copyentity (void) edict_t *in, *out; in = G_EDICT(OFS_PARM0); out = G_EDICT(OFS_PARM1); - memcpy(&out->v, &in->v, progs->entityfields * 4); + memcpy(out->v, in->v, progs->entityfields * 4); } /* @@ -2050,7 +2050,7 @@ void PF_setcolor (void) client = &svs.clients[entnum-1]; client->colors = i; - client->edict->v.team = (i & 15) + 1; + client->edict->v->team = (i & 15) + 1; MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors); MSG_WriteByte (&sv.reliable_datagram, entnum - 1); @@ -2496,7 +2496,7 @@ static msurface_t *getsurface(edict_t *ed, int surfnum) model_t *model; if (!ed || ed->free) return NULL; - modelindex = ed->v.modelindex; + modelindex = ed->v->modelindex; if (modelindex < 1 || modelindex >= MAX_MODELS) return NULL; model = sv.models[modelindex]; @@ -2537,7 +2537,7 @@ void PF_getsurfacepoint(void) if (pointnum < 0 || pointnum >= surf->poly_numverts) return; // FIXME: implement rotation/scaling - VectorAdd(&surf->poly_verts[pointnum * 3], ed->v.origin, G_VECTOR(OFS_RETURN)); + VectorAdd(&surf->poly_verts[pointnum * 3], ed->v->origin, G_VECTOR(OFS_RETURN)); } //PF_getsurfacenormal, // #436 vector(entity e, float s) getsurfacenormal = #436; void PF_getsurfacenormal(void) @@ -2577,7 +2577,7 @@ void PF_getsurfacenearpoint(void) if (!ed || ed->free) return; - modelindex = ed->v.modelindex; + modelindex = ed->v->modelindex; if (modelindex < 1 || modelindex >= MAX_MODELS) return; model = sv.models[modelindex]; @@ -2585,7 +2585,7 @@ void PF_getsurfacenearpoint(void) return; // FIXME: implement rotation/scaling - VectorSubtract(point, ed->v.origin, p); + VectorSubtract(point, ed->v->origin, p); best = -1; bestdist = 1000000000; for (surfnum = 0;surfnum < model->nummodelsurfaces;surfnum++) @@ -2620,10 +2620,10 @@ void PF_getsurfaceclippedpoint(void) if (!(surf = getsurface(ed, G_FLOAT(OFS_PARM1)))) return; // FIXME: implement rotation/scaling - VectorSubtract(G_VECTOR(OFS_PARM2), ed->v.origin, p); + VectorSubtract(G_VECTOR(OFS_PARM2), ed->v->origin, p); clippointtosurface(surf, p, out); // FIXME: implement rotation/scaling - VectorAdd(out, ed->v.origin, G_VECTOR(OFS_RETURN)); + VectorAdd(out, ed->v->origin, G_VECTOR(OFS_RETURN)); } void PF_Fixme (void) diff --git a/pr_edict.c b/pr_edict.c index 54e25b50..3d4553a4 100644 --- a/pr_edict.c +++ b/pr_edict.c @@ -184,7 +184,7 @@ Sets everything to NULL */ void ED_ClearEdict (edict_t *e) { - memset (&e->v, 0, progs->entityfields * 4); + memset (e->v, 0, progs->entityfields * 4); e->free = false; } @@ -239,16 +239,16 @@ void ED_Free (edict_t *ed) SV_UnlinkEdict (ed); // unlink from world bsp ed->free = true; - ed->v.model = 0; - ed->v.takedamage = 0; - ed->v.modelindex = 0; - ed->v.colormap = 0; - ed->v.skin = 0; - ed->v.frame = 0; - VectorClear(ed->v.origin); - VectorClear(ed->v.angles); - ed->v.nextthink = -1; - ed->v.solid = 0; + ed->v->model = 0; + ed->v->takedamage = 0; + ed->v->modelindex = 0; + ed->v->colormap = 0; + ed->v->skin = 0; + ed->v->frame = 0; + VectorClear(ed->v->origin); + VectorClear(ed->v->angles); + ed->v->nextthink = -1; + ed->v->solid = 0; ed->freetime = sv.time; } @@ -572,7 +572,7 @@ void ED_Print (edict_t *ed) if (name[strlen(name)-2] == '_') continue; // skip _x, _y, _z vars - v = (int *)((char *)&ed->v + d->ofs*4); + v = (int *)((char *)ed->v + d->ofs*4); // if the value is still all 0, skip the field type = d->type & ~DEF_SAVEGLOBAL; @@ -645,7 +645,7 @@ void ED_Write (QFile *f, edict_t *ed) if (name[strlen(name)-2] == '_') continue; // skip _x, _y, _z vars - v = (int *)((char *)&ed->v + d->ofs*4); + v = (int *)((char *)ed->v + d->ofs*4); // if the value is still all 0, skip the field type = d->type & ~DEF_SAVEGLOBAL; @@ -723,11 +723,11 @@ void ED_Count (void) if (ent->free) continue; active++; - if (ent->v.solid) + if (ent->v->solid) solid++; - if (ent->v.model) + if (ent->v->model) models++; - if (ent->v.movetype == MOVETYPE_STEP) + if (ent->v->movetype == MOVETYPE_STEP) step++; } @@ -949,7 +949,7 @@ const char *ED_ParseEdict (const char *data, edict_t *ent) // clear it if (ent != sv.edicts) // hack - memset (&ent->v, 0, progs->entityfields * 4); + memset (ent->v, 0, progs->entityfields * 4); // go through all the dictionary pairs while (1) @@ -1012,7 +1012,7 @@ const char *ED_ParseEdict (const char *data, edict_t *ent) sprintf (com_token, "0 %s 0", temp); } - if (!ED_ParseEpair ((void *)&ent->v, key, com_token)) + if (!ED_ParseEpair ((void *)ent->v, key, com_token)) Host_Error ("ED_ParseEdict: parse error"); } @@ -1066,18 +1066,18 @@ void ED_LoadFromFile (const char *data) // remove things from different skill levels or deathmatch if (deathmatch.integer) { - if (((int)ent->v.spawnflags & SPAWNFLAG_NOT_DEATHMATCH)) + if (((int)ent->v->spawnflags & SPAWNFLAG_NOT_DEATHMATCH)) { ED_Free (ent); inhibit++; continue; } } - else if ((current_skill == 0 && ((int)ent->v.spawnflags & SPAWNFLAG_NOT_EASY )) - || (current_skill == 1 && ((int)ent->v.spawnflags & SPAWNFLAG_NOT_MEDIUM)) - || (current_skill >= 2 && ((int)ent->v.spawnflags & SPAWNFLAG_NOT_HARD ))) + else if ((current_skill == 0 && ((int)ent->v->spawnflags & SPAWNFLAG_NOT_EASY )) + || (current_skill == 1 && ((int)ent->v->spawnflags & SPAWNFLAG_NOT_MEDIUM)) + || (current_skill >= 2 && ((int)ent->v->spawnflags & SPAWNFLAG_NOT_HARD ))) { - ED_Free (ent); + ED_Free (ent); inhibit++; continue; } @@ -1085,7 +1085,7 @@ void ED_LoadFromFile (const char *data) // // immediately call spawn function // - if (!ent->v.classname) + if (!ent->v->classname) { Con_Printf ("No classname for:\n"); ED_Print (ent); @@ -1094,7 +1094,7 @@ void ED_LoadFromFile (const char *data) } // look for the spawn function - func = ED_FindFunction ( pr_strings + ent->v.classname ); + func = ED_FindFunction ( pr_strings + ent->v->classname ); if (!func) { @@ -1271,8 +1271,8 @@ void PR_LoadProgs (void) ((int *)pr_globals)[i] = LittleLong (((int *)pr_globals)[i]); // moved edict_size calculation down here, below field adding code - pr_edict_size = progs->entityfields * 4 + sizeof (edict_t) - sizeof(entvars_t); - + // LordHavoc: this no longer includes the edict_t header + pr_edict_size = progs->entityfields * 4; pr_edictareasize = pr_edict_size * MAX_EDICTS; // LordHavoc: bounds check anything static @@ -1404,7 +1404,7 @@ void PR_Fields_f (void) name = pr_strings + d->s_name; if (name[strlen(name)-2] == '_') continue; // skip _x, _y, _z vars - v = (int *)((char *)&ed->v + d->ofs*4); + v = (int *)((char *)ed->v + d->ofs*4); // if the value is still all 0, skip the field for (j = 0;j < type_size[d->type & ~DEF_SAVEGLOBAL];j++) { @@ -1556,13 +1556,34 @@ edict_t *EDICT_NUM_ERROR(int n) int NUM_FOR_EDICT(edict_t *e) { - if ((qbyte *)e < (qbyte *)sv.edicts || (qbyte *)e > (qbyte *)sv.edicts + pr_edictareasize) + int n; + n = e - sv.edicts; + if ((unsigned int)n >= MAX_EDICTS) Host_Error ("NUM_FOR_EDICT: bad pointer"); - return e->number; + return n; } int NoCrash_NUM_FOR_EDICT(edict_t *e) { - return e->number; + return e - sv.edicts; +} + +//#define EDICT_TO_PROG(e) ((qbyte *)(((edict_t *)e)->v) - (qbyte *)(sv.edictsfields)) +//#define PROG_TO_EDICT(e) (sv.edictstable[(e) / (progs->entityfields * 4)]) +int EDICT_TO_PROG(edict_t *e) +{ + int n; + n = e - sv.edicts; + if ((unsigned int)n >= sv.max_edicts) + Host_Error("EDICT_TO_PROG: invalid edict %8p (number %i compared to world at %8p)\n", e, n, sv.edicts); + return n;// EXPERIMENTAL + //return (qbyte *)e->v - (qbyte *)sv.edictsfields; +} +edict_t *PROG_TO_EDICT(int n) +{ + if ((unsigned int)n >= sv.max_edicts) + Host_Error("PROG_TO_EDICT: invalid edict number %i\n", n); + return sv.edictstable[n]; // EXPERIMENTAL + //return sv.edictstable[(n) / (progs->entityfields * 4)]; } diff --git a/pr_exec.c b/pr_exec.c index 7e5388fe..ee35aa16 100644 --- a/pr_exec.c +++ b/pr_exec.c @@ -146,7 +146,7 @@ PR_PrintStatement void PR_PrintStatement (dstatement_t *s) { int i; - + if ( (unsigned)s->op < sizeof(pr_opnames)/sizeof(pr_opnames[0])) { Con_Printf ("%s ", pr_opnames[s->op]); @@ -154,7 +154,7 @@ void PR_PrintStatement (dstatement_t *s) for ( ; i<10 ; i++) Con_Printf (" "); } - + if (s->op == OP_IF || s->op == OP_IFNOT) Con_Printf ("%sbranch %i",PR_GlobalString((unsigned short) s->a),s->b); else if (s->op == OP_GOTO) @@ -163,15 +163,15 @@ void PR_PrintStatement (dstatement_t *s) } else if ( (unsigned)(s->op - OP_STORE_F) < 6) { - Con_Printf ("%s",PR_GlobalString((unsigned short) s->a)); + Con_Printf ("%s", PR_GlobalString((unsigned short) s->a)); Con_Printf ("%s", PR_GlobalStringNoContents((unsigned short) s->b)); } else { if (s->a) - Con_Printf ("%s",PR_GlobalString((unsigned short) s->a)); + Con_Printf ("%s", PR_GlobalString((unsigned short) s->a)); if (s->b) - Con_Printf ("%s",PR_GlobalString((unsigned short) s->b)); + Con_Printf ("%s", PR_GlobalString((unsigned short) s->b)); if (s->c) Con_Printf ("%s", PR_GlobalStringNoContents((unsigned short) s->c)); } diff --git a/pr_execprogram.h b/pr_execprogram.h index 05e86103..f41a4c59 100644 --- a/pr_execprogram.h +++ b/pr_execprogram.h @@ -88,7 +88,7 @@ OPC->_float = !OPA->function; break; case OP_NOT_ENT: - OPC->_float = (PROG_TO_EDICT(OPA->edict) == sv.edicts); + OPC->_float = (OPA->edict == 0); break; case OP_EQ_F: OPC->_float = OPA->_float == OPB->_float; @@ -144,17 +144,11 @@ if (OPB->_int < 0 || OPB->_int + 4 > pr_edictareasize) { pr_xstatement = st - pr_statements; - Host_Error("Progs attempted to write to an out of bounds edict\n"); - return; - } - if (OPB->_int % pr_edict_size < ((qbyte *)&sv.edicts->v - (qbyte *)sv.edicts)) - { - pr_xstatement = st - pr_statements; - Host_Error("Progs attempted to write to an engine edict field\n"); + Host_Error("Progs attempted to write to an out of bounds edict (%i)\n", OPB->_int); return; } #endif - ptr = (eval_t *)((qbyte *)sv.edicts + OPB->_int); + ptr = (eval_t *)((qbyte *)sv.edictsfields + OPB->_int); ptr->_int = OPA->_int; break; case OP_STOREP_V: @@ -162,55 +156,32 @@ if (OPB->_int < 0 || OPB->_int + 12 > pr_edictareasize) { pr_xstatement = st - pr_statements; - Host_Error("Progs attempted to write to an out of bounds edict\n"); + Host_Error("Progs attempted to write to an out of bounds edict (%i)\n", OPB->_int); return; } #endif - ptr = (eval_t *)((qbyte *)sv.edicts + OPB->_int); + ptr = (eval_t *)((qbyte *)sv.edictsfields + OPB->_int); ptr->vector[0] = OPA->vector[0]; ptr->vector[1] = OPA->vector[1]; ptr->vector[2] = OPA->vector[2]; break; case OP_ADDRESS: + pr_xstatement = st - pr_statements; #if PRBOUNDSCHECK - if (OPA->edict <= 0) - { - if (OPA->edict == 0 && sv.state == ss_active) - { - pr_xstatement = st - pr_statements; - Host_Error ("assignment to world entity"); - return; - } - else - { - pr_xstatement = st - pr_statements; - Host_Error("Progs attempted to address an out of bounds edict\n"); - return; - } - } - else if (OPA->edict >= pr_edictareasize) + if ((unsigned int)OPB->_int >= progs->entityfields) { - pr_xstatement = st - pr_statements; - Host_Error("Progs attempted to address an out of bounds edict\n"); + Host_Error("Progs attempted to address an invalid field (%i) in an edict\n", OPB->_int); return; } - if (OPB->_int < 0 || OPB->_int >= progs->entityfields) - { - pr_xstatement = st - pr_statements; - Host_Error("Progs attempted to address an invalid field in an edict\n"); - return; - } -#else +#endif if (OPA->edict == 0 && sv.state == ss_active) { - pr_xstatement = st - pr_statements; Host_Error ("assignment to world entity"); return; } -#endif ed = PROG_TO_EDICT(OPA->edict); - OPC->_int = (qbyte *)((int *)&ed->v + OPB->_int) - (qbyte *)sv.edicts; + OPC->_int = (qbyte *)((int *)ed->v + OPB->_int) - (qbyte *)sv.edictsfields; break; case OP_LOAD_F: @@ -218,43 +189,31 @@ case OP_LOAD_ENT: case OP_LOAD_S: case OP_LOAD_FNC: + pr_xstatement = st - pr_statements; #if PRBOUNDSCHECK - if (OPA->edict < 0 || OPA->edict >= pr_edictareasize) + if ((unsigned int)OPB->_int >= progs->entityfields) { - pr_xstatement = st - pr_statements; - Host_Error("Progs attempted to read an out of bounds edict number\n"); - return; - } - if (OPB->_int < 0 || OPB->_int >= progs->entityfields) - { - pr_xstatement = st - pr_statements; - Host_Error("Progs attempted to read an invalid field in an edict\n"); + Host_Error("Progs attempted to read an invalid field in an edict (%i)\n", OPB->_int); return; } #endif ed = PROG_TO_EDICT(OPA->edict); - OPC->_int = ((eval_t *)((int *)&ed->v + OPB->_int))->_int; + OPC->_int = ((eval_t *)((int *)ed->v + OPB->_int))->_int; break; case OP_LOAD_V: + pr_xstatement = st - pr_statements; #if PRBOUNDSCHECK - if (OPA->edict < 0 || OPA->edict >= pr_edictareasize) - { - pr_xstatement = st - pr_statements; - Host_Error("Progs attempted to read an out of bounds edict number\n"); - return; - } if (OPB->_int < 0 || OPB->_int + 2 >= progs->entityfields) { - pr_xstatement = st - pr_statements; - Host_Error("Progs attempted to read an invalid field in an edict\n"); + Host_Error("Progs attempted to read an invalid field in an edict (%i)\n", OPB->_int); return; } #endif ed = PROG_TO_EDICT(OPA->edict); - OPC->vector[0] = ((eval_t *)((int *)&ed->v + OPB->_int))->vector[0]; - OPC->vector[1] = ((eval_t *)((int *)&ed->v + OPB->_int))->vector[1]; - OPC->vector[2] = ((eval_t *)((int *)&ed->v + OPB->_int))->vector[2]; + OPC->vector[0] = ((eval_t *)((int *)ed->v + OPB->_int))->vector[0]; + OPC->vector[1] = ((eval_t *)((int *)ed->v + OPB->_int))->vector[1]; + OPC->vector[2] = ((eval_t *)((int *)ed->v + OPB->_int))->vector[2]; break; //================== @@ -317,9 +276,9 @@ case OP_STATE: ed = PROG_TO_EDICT(pr_global_struct->self); - ed->v.nextthink = pr_global_struct->time + 0.1; - ed->v.frame = OPA->_float; - ed->v.think = OPB->function; + ed->v->nextthink = pr_global_struct->time + 0.1; + ed->v->frame = OPA->_float; + ed->v->think = OPB->function; break; // LordHavoc: to be enabled when Progs version 7 (or whatever it will be numbered) is finalized @@ -483,14 +442,8 @@ Host_Error("Progs attempted to write to an out of bounds edict\n"); return; } - if (OPB->_int % pr_edict_size < ((qbyte *)&sv.edicts->v - (qbyte *)sv.edicts)) - { - pr_xstatement = st - pr_statements; - Host_Error("Progs attempted to write to an engine edict field\n"); - return; - } #endif - ptr = (eval_t *)((qbyte *)sv.edicts + OPB->_int); + ptr = (eval_t *)((qbyte *)sv.edictsfields + OPB->_int); ptr->_int = OPA->_int; break; case OP_LOAD_I: @@ -509,7 +462,7 @@ } #endif ed = PROG_TO_EDICT(OPA->edict); - OPC->_int = ((eval_t *)((int *)&ed->v + OPB->_int))->_int; + OPC->_int = ((eval_t *)((int *)ed->v + OPB->_int))->_int; break; case OP_GSTOREP_I: diff --git a/progs.h b/progs.h index a50b7af9..85a0e3a9 100644 --- a/progs.h +++ b/progs.h @@ -45,7 +45,6 @@ typedef struct edict_s { qboolean free; // true if this edict is unused link_t area; // physics area this edict is linked into - int number; // number of this edict #ifdef QUAKEENTITIES entity_state_t baseline; // baseline values @@ -54,8 +53,7 @@ typedef struct edict_s int suspendedinairflag; // LordHavoc: gross hack to make floating items still work float freetime; // sv.time when the object was freed - entvars_t v; // C exported fields from progs -// other fields from progs come immediately after + entvars_t *v; // edict fields } edict_t; // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue... see pr_edict.c for the functions which use these. @@ -94,7 +92,7 @@ extern int eval_pmodel; extern int eval_punchvector; extern int eval_viewzoom; -#define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t*)((char*)&ed->v + fieldoffset) : NULL) +#define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t *)((qbyte *)ed->v + fieldoffset) : NULL) extern dfunction_t *SV_PlayerPhysicsQC; @@ -145,25 +143,26 @@ edict_t *EDICT_NUM_ERROR(int n); int NUM_FOR_EDICT(edict_t *e); -#define NEXT_EDICT(e) ((edict_t *)( (qbyte *)e + pr_edict_size)) +#define NEXT_EDICT(e) ((e) + 1) -#define EDICT_TO_PROG(e) ((qbyte *)e - (qbyte *)sv.edicts) -#define PROG_TO_EDICT(e) ((edict_t *)((qbyte *)sv.edicts + e)) +int EDICT_TO_PROG(edict_t *e); +edict_t *PROG_TO_EDICT(int n); //============================================================================ #define G_FLOAT(o) (pr_globals[o]) #define G_INT(o) (*(int *)&pr_globals[o]) -#define G_EDICT(o) ((edict_t *)((qbyte *)sv.edicts+ *(int *)&pr_globals[o])) +#define G_EDICT(o) (PROG_TO_EDICT(*(int *)&pr_globals[o])) #define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o)) #define G_VECTOR(o) (&pr_globals[o]) #define G_STRING(o) (pr_strings + *(string_t *)&pr_globals[o]) -#define G_FUNCTION(o) (*(func_t *)&pr_globals[o]) +//#define G_FUNCTION(o) (*(func_t *)&pr_globals[o]) -#define E_FLOAT(e,o) (((float*)&e->v)[o]) -#define E_INT(e,o) (*(int *)&((float*)&e->v)[o]) -#define E_VECTOR(e,o) (&((float*)&e->v)[o]) -#define E_STRING(e,o) (pr_strings + *(string_t *)&((float*)&e->v)[o]) +// FIXME: make these go away? +#define E_FLOAT(e,o) (((float*)e->v)[o]) +//#define E_INT(e,o) (((int*)e->v)[o]) +//#define E_VECTOR(e,o) (&((float*)e->v)[o]) +#define E_STRING(e,o) (pr_strings + *(string_t *)&((float*)e->v)[o]) extern int type_size[8]; diff --git a/server.h b/server.h index 4887aa13..5ee45a31 100644 --- a/server.h +++ b/server.h @@ -71,6 +71,8 @@ typedef struct edict_t *edicts; // can be array indexed edict_t **edictstable; + // array of QC edict field variables + void *edictsfields; // some actions are only valid during load server_state_t state; diff --git a/sv_main.c b/sv_main.c index 7f250b0d..82318441 100644 --- a/sv_main.c +++ b/sv_main.c @@ -219,7 +219,7 @@ void SV_StartSound (edict_t *entity, int channel, char *sample, int volume, else MSG_WriteByte (&sv.datagram, sound_num); for (i=0 ; i<3 ; i++) - MSG_WriteDPCoord (&sv.datagram, entity->v.origin[i]+0.5*(entity->v.mins[i]+entity->v.maxs[i])); + MSG_WriteDPCoord (&sv.datagram, entity->v->origin[i]+0.5*(entity->v->mins[i]+entity->v->maxs[i])); } /* @@ -260,7 +260,7 @@ void SV_SendServerinfo (client_t *client) else MSG_WriteByte (&client->message, GAME_COOP); - sprintf (message, pr_strings+sv.edicts->v.message); + sprintf (message, pr_strings+sv.edicts->v->message); MSG_WriteString (&client->message,message); @@ -274,8 +274,8 @@ void SV_SendServerinfo (client_t *client) // send music MSG_WriteByte (&client->message, svc_cdtrack); - MSG_WriteByte (&client->message, sv.edicts->v.sounds); - MSG_WriteByte (&client->message, sv.edicts->v.sounds); + MSG_WriteByte (&client->message, sv.edicts->v->sounds); + MSG_WriteByte (&client->message, sv.edicts->v->sounds); // set view MSG_WriteByte (&client->message, svc_setview); @@ -533,7 +533,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) Mod_CheckLoaded(sv.worldmodel); // find the client's PVS - VectorAdd (clent->v.origin, clent->v.view_ofs, testeye); + VectorAdd (clent->v->origin, clent->v->view_ofs, testeye); pvs = SV_FatPVS (testeye); culled_pvs = 0; @@ -586,9 +586,9 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) if (val->_float != 0) bits |= U_GLOWTRAIL; - if (ent->v.modelindex >= 0 && ent->v.modelindex < MAX_MODELS && pr_strings[ent->v.model]) + if (ent->v->modelindex >= 0 && ent->v->modelindex < MAX_MODELS && pr_strings[ent->v->model]) { - model = sv.models[(int)ent->v.modelindex]; + model = sv.models[(int)ent->v->modelindex]; Mod_CheckLoaded(model); } else @@ -599,17 +599,17 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) continue; } - VectorCopy(ent->v.angles, angles); - if (DotProduct(ent->v.velocity, ent->v.velocity) >= 1.0f) + VectorCopy(ent->v->angles, angles); + if (DotProduct(ent->v->velocity, ent->v->velocity) >= 1.0f) { - VectorMA(ent->v.origin, host_client->latency, ent->v.velocity, origin); + VectorMA(ent->v->origin, host_client->latency, ent->v->velocity, origin); // LordHavoc: trace predicted movement to avoid putting things in walls - trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, origin, MOVE_NORMAL, ent); + trace = SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, origin, MOVE_NORMAL, ent); VectorCopy(trace.endpos, origin); } else { - VectorCopy(ent->v.origin, origin); + VectorCopy(ent->v->origin, origin); } // ent has survived every check so far, check if it is visible @@ -625,12 +625,12 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) // using the model's bounding box to ensure things are visible regardless of their physics box if (model) { - if (ent->v.angles[0] || ent->v.angles[2]) // pitch and roll + if (ent->v->angles[0] || ent->v->angles[2]) // pitch and roll { VectorAdd(entmins, model->rotatedmins, entmins); VectorAdd(entmaxs, model->rotatedmaxs, entmaxs); } - else if (ent->v.angles[1]) + else if (ent->v->angles[1]) { VectorAdd(entmins, model->yawmins, entmins); VectorAdd(entmaxs, model->yawmaxs, entmaxs); @@ -694,7 +694,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) alphaf = 255.0f; scale = 16; glowcolor = 254; - effects = ent->v.effects; + effects = ent->v->effects; if ((val = GETEDICTFIELDVALUE(ent, eval_alpha))) if (val->_float != 0) @@ -755,7 +755,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) // send an update baseline = &ent->baseline; - if (((int)ent->v.effects & EF_DELTA) && sv_deltacompress.integer) + if (((int)ent->v->effects & EF_DELTA) && sv_deltacompress.integer) { // every half second a full update is forced if (realtime < client->nextfullupdate[e]) @@ -775,7 +775,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) if (e >= 256) bits |= U_LONGENTITY; - if (ent->v.movetype == MOVETYPE_STEP) + if (ent->v->movetype == MOVETYPE_STEP) bits |= U_STEP; // LordHavoc: old stuff, but rewritten to have more exact tolerances @@ -785,29 +785,29 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) if (((int)(angles[0]*(256.0/360.0)) & 255) != ((int)(baseline->angles[0]*(256.0/360.0)) & 255)) bits |= U_ANGLE1; if (((int)(angles[1]*(256.0/360.0)) & 255) != ((int)(baseline->angles[1]*(256.0/360.0)) & 255)) bits |= U_ANGLE2; if (((int)(angles[2]*(256.0/360.0)) & 255) != ((int)(baseline->angles[2]*(256.0/360.0)) & 255)) bits |= U_ANGLE3; - if (baseline->colormap != (qbyte) ent->v.colormap) bits |= U_COLORMAP; - if (baseline->skin != (qbyte) ent->v.skin) bits |= U_SKIN; - if ((baseline->frame & 0x00FF) != ((int) ent->v.frame & 0x00FF)) bits |= U_FRAME; - if ((baseline->effects & 0x00FF) != ((int) ent->v.effects & 0x00FF)) bits |= U_EFFECTS; - if ((baseline->modelindex & 0x00FF) != ((int) ent->v.modelindex & 0x00FF)) bits |= U_MODEL; + if (baseline->colormap != (qbyte) ent->v->colormap) bits |= U_COLORMAP; + if (baseline->skin != (qbyte) ent->v->skin) bits |= U_SKIN; + if ((baseline->frame & 0x00FF) != ((int) ent->v->frame & 0x00FF)) bits |= U_FRAME; + if ((baseline->effects & 0x00FF) != ((int) ent->v->effects & 0x00FF)) bits |= U_EFFECTS; + if ((baseline->modelindex & 0x00FF) != ((int) ent->v->modelindex & 0x00FF)) bits |= U_MODEL; // LordHavoc: new stuff if (baseline->alpha != alpha) bits |= U_ALPHA; if (baseline->scale != scale) bits |= U_SCALE; - if (((int) baseline->effects & 0xFF00) != ((int) ent->v.effects & 0xFF00)) bits |= U_EFFECTS2; + if (((int) baseline->effects & 0xFF00) != ((int) ent->v->effects & 0xFF00)) bits |= U_EFFECTS2; if (baseline->glowsize != glowsize) bits |= U_GLOWSIZE; if (baseline->glowcolor != glowcolor) bits |= U_GLOWCOLOR; - if (((int) baseline->frame & 0xFF00) != ((int) ent->v.frame & 0xFF00)) bits |= U_FRAME2; - if (((int) baseline->frame & 0xFF00) != ((int) ent->v.modelindex & 0xFF00)) bits |= U_MODEL2; + if (((int) baseline->frame & 0xFF00) != ((int) ent->v->frame & 0xFF00)) bits |= U_FRAME2; + if (((int) baseline->frame & 0xFF00) != ((int) ent->v->modelindex & 0xFF00)) bits |= U_MODEL2; // update delta baseline - VectorCopy(ent->v.origin, ent->deltabaseline.origin); - VectorCopy(ent->v.angles, ent->deltabaseline.angles); - ent->deltabaseline.colormap = ent->v.colormap; - ent->deltabaseline.skin = ent->v.skin; - ent->deltabaseline.frame = ent->v.frame; - ent->deltabaseline.effects = ent->v.effects; - ent->deltabaseline.modelindex = ent->v.modelindex; + VectorCopy(ent->v->origin, ent->deltabaseline.origin); + VectorCopy(ent->v->angles, ent->deltabaseline.angles); + ent->deltabaseline.colormap = ent->v->colormap; + ent->deltabaseline.skin = ent->v->skin; + ent->deltabaseline.frame = ent->v->frame; + ent->deltabaseline.effects = ent->v->effects; + ent->deltabaseline.modelindex = ent->v->modelindex; ent->deltabaseline.alpha = alpha; ent->deltabaseline.scale = scale; ent->deltabaseline.glowsize = glowsize; @@ -836,11 +836,11 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) MSG_WriteShort (msg,e); else MSG_WriteByte (msg,e); - if (bits & U_MODEL) MSG_WriteByte (msg, ent->v.modelindex); - if (bits & U_FRAME) MSG_WriteByte (msg, ent->v.frame); - if (bits & U_COLORMAP) MSG_WriteByte (msg, ent->v.colormap); - if (bits & U_SKIN) MSG_WriteByte (msg, ent->v.skin); - if (bits & U_EFFECTS) MSG_WriteByte (msg, ent->v.effects); + if (bits & U_MODEL) MSG_WriteByte (msg, ent->v->modelindex); + if (bits & U_FRAME) MSG_WriteByte (msg, ent->v->frame); + if (bits & U_COLORMAP) MSG_WriteByte (msg, ent->v->colormap); + if (bits & U_SKIN) MSG_WriteByte (msg, ent->v->skin); + if (bits & U_EFFECTS) MSG_WriteByte (msg, ent->v->effects); if (bits & U_ORIGIN1) MSG_WriteDPCoord (msg, origin[0]); if (bits & U_ANGLE1) MSG_WriteAngle(msg, angles[0]); if (bits & U_ORIGIN2) MSG_WriteDPCoord (msg, origin[1]); @@ -851,11 +851,11 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) // LordHavoc: new stuff if (bits & U_ALPHA) MSG_WriteByte(msg, alpha); if (bits & U_SCALE) MSG_WriteByte(msg, scale); - if (bits & U_EFFECTS2) MSG_WriteByte(msg, (int)ent->v.effects >> 8); + if (bits & U_EFFECTS2) MSG_WriteByte(msg, (int)ent->v->effects >> 8); if (bits & U_GLOWSIZE) MSG_WriteByte(msg, glowsize); if (bits & U_GLOWCOLOR) MSG_WriteByte(msg, glowcolor); - if (bits & U_FRAME2) MSG_WriteByte(msg, (int)ent->v.frame >> 8); - if (bits & U_MODEL2) MSG_WriteByte(msg, (int)ent->v.modelindex >> 8); + if (bits & U_FRAME2) MSG_WriteByte(msg, (int)ent->v->frame >> 8); + if (bits & U_MODEL2) MSG_WriteByte(msg, (int)ent->v->modelindex >> 8); } if (sv_cullentities_stats.integer) @@ -883,14 +883,14 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) // find the client's PVS // the real place being tested from - VectorAdd (clent->v.origin, clent->v.view_ofs, testeye); + VectorAdd (clent->v->origin, clent->v->view_ofs, testeye); pvs = SV_FatPVS (testeye); // the place being reported (to consider the fact the client still // applies the view_ofs[2], so we have to only send the fractional part // of view_ofs[2], undoing what the client will redo) VectorCopy (testeye, testorigin); - e = (int) clent->v.view_ofs[2] & 255; + e = (int) clent->v->view_ofs[2] & 255; if (e >= 128) e -= 256; testorigin[2] -= (float) e; @@ -932,7 +932,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) } glowsize = 0; - effects = ent->v.effects; + effects = ent->v->effects; if ((val = GETEDICTFIELDVALUE(ent, eval_glow_size))) glowsize = (int) val->_float >> 2; glowsize = bound(0, glowsize, 255); @@ -968,10 +968,10 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) } modelindex = 0; - if (ent->v.modelindex >= 0 && ent->v.modelindex < MAX_MODELS && pr_strings[ent->v.model]) + if (ent->v->modelindex >= 0 && ent->v->modelindex < MAX_MODELS && pr_strings[ent->v->model]) { - modelindex = ent->v.modelindex; - model = sv.models[(int)ent->v.modelindex]; + modelindex = ent->v->modelindex; + model = sv.models[(int)ent->v->modelindex]; Mod_CheckLoaded(model); } else @@ -982,17 +982,17 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) continue; } - VectorCopy(ent->v.angles, angles); - if (DotProduct(ent->v.velocity, ent->v.velocity) >= 1.0f && host_client->latency >= 0.01f) + VectorCopy(ent->v->angles, angles); + if (DotProduct(ent->v->velocity, ent->v->velocity) >= 1.0f && host_client->latency >= 0.01f) { - VectorMA(ent->v.origin, host_client->latency, ent->v.velocity, origin); + VectorMA(ent->v->origin, host_client->latency, ent->v->velocity, origin); // LordHavoc: trace predicted movement to avoid putting things in walls - trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, origin, MOVE_NORMAL, ent); + trace = SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, origin, MOVE_NORMAL, ent); VectorCopy(trace.endpos, origin); } else { - VectorCopy(ent->v.origin, origin); + VectorCopy(ent->v->origin, origin); } // ent has survived every check so far, check if it is visible @@ -1009,12 +1009,12 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) // using the model's bounding box to ensure things are visible regardless of their physics box if (model) { - if (ent->v.angles[0] || ent->v.angles[2]) // pitch and roll + if (ent->v->angles[0] || ent->v->angles[2]) // pitch and roll { VectorAdd(entmins, model->rotatedmins, entmins); VectorAdd(entmaxs, model->rotatedmaxs, entmaxs); } - else if (ent->v.angles[1]) + else if (ent->v->angles[1]) { VectorAdd(entmins, model->yawmins, entmins); VectorAdd(entmaxs, model->yawmaxs, entmaxs); @@ -1103,7 +1103,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) alphaf = 255.0f; scale = 16; glowcolor = 254; - effects = ent->v.effects; + effects = ent->v->effects; if ((val = GETEDICTFIELDVALUE(ent, eval_alpha))) if (val->_float != 0) @@ -1149,7 +1149,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) if ((val = GETEDICTFIELDVALUE(ent, eval_exteriormodeltoclient)) && val->edict == clentnum) flags |= RENDER_EXTERIORMODEL; - if (ent->v.movetype == MOVETYPE_STEP) + if (ent->v->movetype == MOVETYPE_STEP) flags |= RENDER_STEP; // don't send an entity if it's coordinates would wrap around if ((effects & EF_LOWPRECISION) && origin[0] >= -32768 && origin[1] >= -32768 && origin[2] >= -32768 && origin[0] <= 32767 && origin[1] <= 32767 && origin[2] <= 32767) @@ -1161,11 +1161,11 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) break; VectorCopy(origin, s->origin); VectorCopy(angles, s->angles); - if (ent->v.colormap >= 1024) + if (ent->v->colormap >= 1024) flags |= RENDER_COLORMAPPED; - s->colormap = ent->v.colormap; - s->skin = ent->v.skin; - s->frame = ent->v.frame; + s->colormap = ent->v->colormap; + s->skin = ent->v->skin; + s->frame = ent->v->frame; s->modelindex = modelindex; s->effects = effects; s->alpha = alpha; @@ -1195,7 +1195,7 @@ void SV_CleanupEnts (void) ent = NEXT_EDICT(sv.edicts); for (e=1 ; ev.effects = (int)ent->v.effects & ~EF_MUZZLEFLASH; + ent->v->effects = (int)ent->v->effects & ~EF_MUZZLEFLASH; } /* @@ -1217,17 +1217,17 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) // // send a damage message // - if (ent->v.dmg_take || ent->v.dmg_save) + if (ent->v->dmg_take || ent->v->dmg_save) { - other = PROG_TO_EDICT(ent->v.dmg_inflictor); + other = PROG_TO_EDICT(ent->v->dmg_inflictor); MSG_WriteByte (msg, svc_damage); - MSG_WriteByte (msg, ent->v.dmg_save); - MSG_WriteByte (msg, ent->v.dmg_take); + MSG_WriteByte (msg, ent->v->dmg_save); + MSG_WriteByte (msg, ent->v->dmg_take); for (i=0 ; i<3 ; i++) - MSG_WriteDPCoord (msg, other->v.origin[i] + 0.5*(other->v.mins[i] + other->v.maxs[i])); + MSG_WriteDPCoord (msg, other->v->origin[i] + 0.5*(other->v->mins[i] + other->v->maxs[i])); - ent->v.dmg_take = 0; - ent->v.dmg_save = 0; + ent->v->dmg_take = 0; + ent->v->dmg_save = 0; } // @@ -1236,20 +1236,20 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) SV_SetIdealPitch (); // how much to look up / down ideally // a fixangle might get lost in a dropped packet. Oh well. - if ( ent->v.fixangle ) + if ( ent->v->fixangle ) { MSG_WriteByte (msg, svc_setangle); for (i=0 ; i < 3 ; i++) - MSG_WriteAngle (msg, ent->v.angles[i] ); - ent->v.fixangle = 0; + MSG_WriteAngle (msg, ent->v->angles[i] ); + ent->v->fixangle = 0; } bits = 0; - if (ent->v.view_ofs[2] != DEFAULT_VIEWHEIGHT) + if (ent->v->view_ofs[2] != DEFAULT_VIEWHEIGHT) bits |= SU_VIEWHEIGHT; - if (ent->v.idealpitch) + if (ent->v->idealpitch) bits |= SU_IDEALPITCH; // stuff the sigil bits into the high bits of items for sbar, or else @@ -1257,16 +1257,16 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) val = GETEDICTFIELDVALUE(ent, eval_items2); if (val) - items = (int)ent->v.items | ((int)val->_float << 23); + items = (int)ent->v->items | ((int)val->_float << 23); else - items = (int)ent->v.items | ((int)pr_global_struct->serverflags << 28); + items = (int)ent->v->items | ((int)pr_global_struct->serverflags << 28); bits |= SU_ITEMS; - if ( (int)ent->v.flags & FL_ONGROUND) + if ( (int)ent->v->flags & FL_ONGROUND) bits |= SU_ONGROUND; - if ( ent->v.waterlevel >= 2) + if ( ent->v->waterlevel >= 2) bits |= SU_INWATER; // dpprotocol @@ -1290,18 +1290,18 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) for (i=0 ; i<3 ; i++) { - if (ent->v.punchangle[i]) + if (ent->v->punchangle[i]) bits |= (SU_PUNCH1<v.velocity[i]) + if (ent->v->velocity[i]) bits |= (SU_VELOCITY1<v.weaponframe) + if (ent->v->weaponframe) bits |= SU_WEAPONFRAME; - if (ent->v.armorvalue) + if (ent->v->armorvalue) bits |= SU_ARMOR; bits |= SU_WEAPON; @@ -1321,43 +1321,43 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) MSG_WriteByte(msg, bits >> 24); if (bits & SU_VIEWHEIGHT) - MSG_WriteChar (msg, ent->v.view_ofs[2]); + MSG_WriteChar (msg, ent->v->view_ofs[2]); if (bits & SU_IDEALPITCH) - MSG_WriteChar (msg, ent->v.idealpitch); + MSG_WriteChar (msg, ent->v->idealpitch); for (i=0 ; i<3 ; i++) { if (bits & (SU_PUNCH1<v.punchangle[i]); // dpprotocol + MSG_WritePreciseAngle(msg, ent->v->punchangle[i]); // dpprotocol if (bits & (SU_PUNCHVEC1<v.velocity[i]/16); + MSG_WriteChar (msg, ent->v->velocity[i]/16); } // [always sent] if (bits & SU_ITEMS) MSG_WriteLong (msg, items); if (bits & SU_WEAPONFRAME) - MSG_WriteByte (msg, ent->v.weaponframe); + MSG_WriteByte (msg, ent->v->weaponframe); if (bits & SU_ARMOR) - MSG_WriteByte (msg, ent->v.armorvalue); + MSG_WriteByte (msg, ent->v->armorvalue); if (bits & SU_WEAPON) - MSG_WriteByte (msg, SV_ModelIndex(pr_strings+ent->v.weaponmodel)); + MSG_WriteByte (msg, SV_ModelIndex(pr_strings+ent->v->weaponmodel)); - MSG_WriteShort (msg, ent->v.health); - MSG_WriteByte (msg, ent->v.currentammo); - MSG_WriteByte (msg, ent->v.ammo_shells); - MSG_WriteByte (msg, ent->v.ammo_nails); - MSG_WriteByte (msg, ent->v.ammo_rockets); - MSG_WriteByte (msg, ent->v.ammo_cells); + MSG_WriteShort (msg, ent->v->health); + MSG_WriteByte (msg, ent->v->currentammo); + MSG_WriteByte (msg, ent->v->ammo_shells); + MSG_WriteByte (msg, ent->v->ammo_nails); + MSG_WriteByte (msg, ent->v->ammo_rockets); + MSG_WriteByte (msg, ent->v->ammo_cells); if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE) { for(i=0;i<32;i++) { - if ( ((int)ent->v.weapon) & (1<v->weapon) & (1<v.weapon); + MSG_WriteByte (msg, ent->v->weapon); } if (bits & SU_VIEWZOOM) @@ -1425,7 +1425,7 @@ void SV_UpdateToReliableMessages (void) // check for changes to be sent over the reliable streams for (i=0, host_client = svs.clients ; iold_frags != host_client->edict->v.frags) + if (host_client->old_frags != host_client->edict->v->frags) { for (j=0, client = svs.clients ; jmessage, svc_updatefrags); MSG_WriteByte (&client->message, i); - MSG_WriteShort (&client->message, host_client->edict->v.frags); + MSG_WriteShort (&client->message, host_client->edict->v->frags); } - host_client->old_frags = host_client->edict->v.frags; + host_client->old_frags = host_client->edict->v->frags; } } @@ -1607,14 +1607,14 @@ void SV_CreateBaseline (void) if (svent->free) continue; - if (entnum > svs.maxclients && !svent->v.modelindex) + if (entnum > svs.maxclients && !svent->v->modelindex) continue; // create entity baseline - VectorCopy (svent->v.origin, svent->baseline.origin); - VectorCopy (svent->v.angles, svent->baseline.angles); - svent->baseline.frame = svent->v.frame; - svent->baseline.skin = svent->v.skin; + VectorCopy (svent->v->origin, svent->baseline.origin); + VectorCopy (svent->v->angles, svent->baseline.angles); + svent->baseline.frame = svent->v->frame; + svent->baseline.skin = svent->v->skin; if (entnum > 0 && entnum <= svs.maxclients) { svent->baseline.colormap = entnum; @@ -1623,7 +1623,7 @@ void SV_CreateBaseline (void) else { svent->baseline.colormap = 0; - svent->baseline.modelindex = svent->v.modelindex; + svent->baseline.modelindex = svent->v->modelindex; } large = false; @@ -1678,7 +1678,7 @@ void SV_SendReconnect (void) MSG_WriteChar (&msg, svc_stufftext); MSG_WriteString (&msg, "reconnect\n"); NET_SendToAll (&msg, 5); - + if (cls.state != ca_dedicated) Cmd_ExecuteString ("reconnect\n", src_command); } @@ -1765,12 +1765,13 @@ void SV_SpawnServer (const char *server) // clear the edict memory pool Mem_EmptyPool(sv_edicts_mempool); - sv.edicts = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * pr_edict_size); + sv.edicts = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * sizeof(edict_t)); + sv.edictsfields = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * pr_edict_size); sv.edictstable = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * sizeof(edict_t *)); for (i = 0;i < MAX_EDICTS;i++) { - ent = (edict_t *)((qbyte *)sv.edicts + (i * pr_edict_size)); - ent->number = i; + ent = sv.edicts + i; + ent->v = (void *)((qbyte *)sv.edictsfields + i * pr_edict_size); sv.edictstable[i] = ent; } @@ -1831,12 +1832,12 @@ void SV_SpawnServer (const char *server) // load the rest of the entities // ent = EDICT_NUM(0); - memset (&ent->v, 0, progs->entityfields * 4); + memset (ent->v, 0, progs->entityfields * 4); ent->free = false; - ent->v.model = sv.worldmodel->name - pr_strings; - ent->v.modelindex = 1; // world model - ent->v.solid = SOLID_BSP; - ent->v.movetype = MOVETYPE_PUSH; + ent->v->model = sv.worldmodel->name - pr_strings; + ent->v->modelindex = 1; // world model + ent->v->solid = SOLID_BSP; + ent->v->movetype = MOVETYPE_PUSH; if (coop.integer) pr_global_struct->coop = coop.integer; @@ -1850,7 +1851,7 @@ void SV_SpawnServer (const char *server) ED_LoadFromFile (sv.worldmodel->entities); // LordHavoc: clear world angles (to fix e3m3.bsp) - VectorClear(sv.edicts->v.angles); + VectorClear(sv.edicts->v->angles); sv.active = true; diff --git a/sv_move.c b/sv_move.c index 5645c540..6fcff3c3 100644 --- a/sv_move.c +++ b/sv_move.c @@ -39,8 +39,8 @@ qboolean SV_CheckBottom (edict_t *ent) int x, y; float mid, bottom; - VectorAdd (ent->v.origin, ent->v.mins, mins); - VectorAdd (ent->v.origin, ent->v.maxs, maxs); + VectorAdd (ent->v->origin, ent->v->mins, mins); + VectorAdd (ent->v->origin, ent->v->maxs, maxs); // if all of the points under the corners are solid world, don't bother // with the tougher checks @@ -114,34 +114,34 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink) edict_t *enemy; // try the move - VectorCopy (ent->v.origin, oldorg); - VectorAdd (ent->v.origin, move, neworg); + VectorCopy (ent->v->origin, oldorg); + VectorAdd (ent->v->origin, move, neworg); // flying monsters don't step up - if ( (int)ent->v.flags & (FL_SWIM | FL_FLY) ) + if ( (int)ent->v->flags & (FL_SWIM | FL_FLY) ) { // try one move with vertical motion, then one without for (i=0 ; i<2 ; i++) { - VectorAdd (ent->v.origin, move, neworg); - enemy = PROG_TO_EDICT(ent->v.enemy); + VectorAdd (ent->v->origin, move, neworg); + enemy = PROG_TO_EDICT(ent->v->enemy); if (i == 0 && enemy != sv.edicts) { - dz = ent->v.origin[2] - PROG_TO_EDICT(ent->v.enemy)->v.origin[2]; + dz = ent->v->origin[2] - PROG_TO_EDICT(ent->v->enemy)->v->origin[2]; if (dz > 40) neworg[2] -= 8; if (dz < 30) neworg[2] += 8; } - trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, neworg, MOVE_NORMAL, ent); + trace = SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, neworg, MOVE_NORMAL, ent); if (trace.fraction == 1) { VectorCopy(trace.endpos, traceendpos); - if ( ((int)ent->v.flags & FL_SWIM) && Mod_PointContents(traceendpos, sv.worldmodel) == CONTENTS_EMPTY ) + if ( ((int)ent->v->flags & FL_SWIM) && Mod_PointContents(traceendpos, sv.worldmodel) == CONTENTS_EMPTY ) return false; // swim monster left water - VectorCopy (traceendpos, ent->v.origin); + VectorCopy (traceendpos, ent->v->origin); if (relink) SV_LinkEdict (ent, true); return true; @@ -159,7 +159,7 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink) VectorCopy (neworg, end); end[2] -= sv_stepheight.value*2; - trace = SV_Move (neworg, ent->v.mins, ent->v.maxs, end, MOVE_NORMAL, ent); + trace = SV_Move (neworg, ent->v->mins, ent->v->maxs, end, MOVE_NORMAL, ent); if (trace.allsolid) return false; @@ -167,19 +167,19 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink) if (trace.startsolid) { neworg[2] -= sv_stepheight.value; - trace = SV_Move (neworg, ent->v.mins, ent->v.maxs, end, MOVE_NORMAL, ent); + trace = SV_Move (neworg, ent->v->mins, ent->v->maxs, end, MOVE_NORMAL, ent); if (trace.allsolid || trace.startsolid) return false; } if (trace.fraction == 1) { // if monster had the ground pulled out, go ahead and fall - if ( (int)ent->v.flags & FL_PARTIALGROUND ) + if ( (int)ent->v->flags & FL_PARTIALGROUND ) { - VectorAdd (ent->v.origin, move, ent->v.origin); + VectorAdd (ent->v->origin, move, ent->v->origin); if (relink) SV_LinkEdict (ent, true); - ent->v.flags = (int)ent->v.flags & ~FL_ONGROUND; + ent->v->flags = (int)ent->v->flags & ~FL_ONGROUND; return true; } @@ -187,25 +187,25 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink) } // check point traces down for dangling corners - VectorCopy (trace.endpos, ent->v.origin); - + VectorCopy (trace.endpos, ent->v->origin); + if (!SV_CheckBottom (ent)) { - if ( (int)ent->v.flags & FL_PARTIALGROUND ) + if ( (int)ent->v->flags & FL_PARTIALGROUND ) { // entity had floor mostly pulled out from underneath it // and is trying to correct if (relink) SV_LinkEdict (ent, true); return true; } - VectorCopy (oldorg, ent->v.origin); + VectorCopy (oldorg, ent->v->origin); return false; } - if ( (int)ent->v.flags & FL_PARTIALGROUND ) - ent->v.flags = (int)ent->v.flags & ~FL_PARTIALGROUND; + if ( (int)ent->v->flags & FL_PARTIALGROUND ) + ent->v->flags = (int)ent->v->flags & ~FL_PARTIALGROUND; - ent->v.groundentity = EDICT_TO_PROG(trace.ent); + ent->v->groundentity = EDICT_TO_PROG(trace.ent); // the move is ok if (relink) @@ -230,28 +230,28 @@ qboolean SV_StepDirection (edict_t *ent, float yaw, float dist) { vec3_t move, oldorigin; float delta; - - ent->v.ideal_yaw = yaw; + + ent->v->ideal_yaw = yaw; PF_changeyaw(); - + yaw = yaw*M_PI*2 / 360; move[0] = cos(yaw)*dist; move[1] = sin(yaw)*dist; move[2] = 0; - VectorCopy (ent->v.origin, oldorigin); + VectorCopy (ent->v->origin, oldorigin); if (SV_movestep (ent, move, false)) { - delta = ent->v.angles[YAW] - ent->v.ideal_yaw; + delta = ent->v->angles[YAW] - ent->v->ideal_yaw; if (delta > 45 && delta < 315) { // not turned far enough, so don't take the step - VectorCopy (oldorigin, ent->v.origin); + VectorCopy (oldorigin, ent->v->origin); } SV_LinkEdict (ent, true); return true; } SV_LinkEdict (ent, true); - + return false; } @@ -263,7 +263,7 @@ SV_FixCheckBottom */ void SV_FixCheckBottom (edict_t *ent) { - ent->v.flags = (int)ent->v.flags | FL_PARTIALGROUND; + ent->v->flags = (int)ent->v->flags | FL_PARTIALGROUND; } @@ -281,11 +281,11 @@ void SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist) float d[3]; float tdir, olddir, turnaround; - olddir = ANGLEMOD((int)(actor->v.ideal_yaw/45)*45); + olddir = ANGLEMOD((int)(actor->v->ideal_yaw/45)*45); turnaround = ANGLEMOD(olddir - 180); - deltax = enemy->v.origin[0] - actor->v.origin[0]; - deltay = enemy->v.origin[1] - actor->v.origin[1]; + deltax = enemy->v->origin[0] - actor->v->origin[0]; + deltay = enemy->v->origin[1] - actor->v->origin[1]; if (deltax>10) d[1]= 0; else if (deltax<-10) @@ -306,7 +306,7 @@ void SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist) tdir = d[2] == 90 ? 45 : 315; else tdir = d[2] == 90 ? 135 : 215; - + if (tdir != turnaround && SV_StepDirection(actor, tdir, dist)) return; } @@ -348,7 +348,7 @@ void SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist) if (turnaround != DI_NODIR && SV_StepDirection(actor, turnaround, dist) ) return; - actor->v.ideal_yaw = olddir; // can't move + actor->v->ideal_yaw = olddir; // can't move // if a bridge was pulled out from underneath a monster, it may not have // a valid standing position at all @@ -370,9 +370,9 @@ qboolean SV_CloseEnough (edict_t *ent, edict_t *goal, float dist) for (i=0 ; i<3 ; i++) { - if (goal->v.absmin[i] > ent->v.absmax[i] + dist) + if (goal->v->absmin[i] > ent->v->absmax[i] + dist) return false; - if (goal->v.absmax[i] < ent->v.absmin[i] - dist) + if (goal->v->absmax[i] < ent->v->absmin[i] - dist) return false; } return true; @@ -390,22 +390,22 @@ void SV_MoveToGoal (void) float dist; ent = PROG_TO_EDICT(pr_global_struct->self); - goal = PROG_TO_EDICT(ent->v.goalentity); + goal = PROG_TO_EDICT(ent->v->goalentity); dist = G_FLOAT(OFS_PARM0); - if ( !( (int)ent->v.flags & (FL_ONGROUND|FL_FLY|FL_SWIM) ) ) + if ( !( (int)ent->v->flags & (FL_ONGROUND|FL_FLY|FL_SWIM) ) ) { G_FLOAT(OFS_RETURN) = 0; return; } // if the next step hits the enemy, return immediately - if ( PROG_TO_EDICT(ent->v.enemy) != sv.edicts && SV_CloseEnough (ent, goal, dist) ) + if ( PROG_TO_EDICT(ent->v->enemy) != sv.edicts && SV_CloseEnough (ent, goal, dist) ) return; // bump around... if ( (rand()&3)==1 || - !SV_StepDirection (ent, ent->v.ideal_yaw, dist)) + !SV_StepDirection (ent, ent->v->ideal_yaw, dist)) { SV_NewChaseDir (ent, goal, dist); } diff --git a/sv_phys.c b/sv_phys.c index 99605cc2..0e465d1e 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -75,10 +75,10 @@ void SV_CheckAllEnts (void) { if (check->free) continue; - if (check->v.movetype == MOVETYPE_PUSH - || check->v.movetype == MOVETYPE_NONE - || check->v.movetype == MOVETYPE_FOLLOW - || check->v.movetype == MOVETYPE_NOCLIP) + if (check->v->movetype == MOVETYPE_PUSH + || check->v->movetype == MOVETYPE_NONE + || check->v->movetype == MOVETYPE_FOLLOW + || check->v->movetype == MOVETYPE_NOCLIP) continue; if (SV_TestEntityPosition (check)) @@ -101,26 +101,26 @@ void SV_CheckVelocity (edict_t *ent) // for (i=0 ; i<3 ; i++) { - if (IS_NAN(ent->v.velocity[i])) + if (IS_NAN(ent->v->velocity[i])) { - Con_Printf ("Got a NaN velocity on %s\n", pr_strings + ent->v.classname); - ent->v.velocity[i] = 0; + Con_Printf ("Got a NaN velocity on %s\n", pr_strings + ent->v->classname); + ent->v->velocity[i] = 0; } - if (IS_NAN(ent->v.origin[i])) + if (IS_NAN(ent->v->origin[i])) { - Con_Printf ("Got a NaN origin on %s\n", pr_strings + ent->v.classname); - ent->v.origin[i] = 0; + Con_Printf ("Got a NaN origin on %s\n", pr_strings + ent->v->classname); + ent->v->origin[i] = 0; } } // LordHavoc: max velocity fix, inspired by Maddes's source fixes, but this is faster - wishspeed = DotProduct(ent->v.velocity, ent->v.velocity); + wishspeed = DotProduct(ent->v->velocity, ent->v->velocity); if (wishspeed > sv_maxvelocity.value * sv_maxvelocity.value) { wishspeed = sv_maxvelocity.value / sqrt(wishspeed); - ent->v.velocity[0] *= wishspeed; - ent->v.velocity[1] *= wishspeed; - ent->v.velocity[2] *= wishspeed; + ent->v->velocity[0] *= wishspeed; + ent->v->velocity[1] *= wishspeed; + ent->v->velocity[2] *= wishspeed; } } @@ -138,7 +138,7 @@ qboolean SV_RunThink (edict_t *ent) { float thinktime; - thinktime = ent->v.nextthink; + thinktime = ent->v->nextthink; if (thinktime <= 0 || thinktime > sv.time + sv.frametime) return true; @@ -147,11 +147,11 @@ qboolean SV_RunThink (edict_t *ent) if (thinktime < sv.time) thinktime = sv.time; - ent->v.nextthink = 0; + ent->v->nextthink = 0; pr_global_struct->time = thinktime; pr_global_struct->self = EDICT_TO_PROG(ent); pr_global_struct->other = EDICT_TO_PROG(sv.edicts); - PR_ExecuteProgram (ent->v.think, "NULL think function"); + PR_ExecuteProgram (ent->v->think, "NULL think function"); return !ent->free; } @@ -170,18 +170,18 @@ void SV_Impact (edict_t *e1, edict_t *e2) old_other = pr_global_struct->other; pr_global_struct->time = sv.time; - if (e1->v.touch && e1->v.solid != SOLID_NOT) + if (e1->v->touch && e1->v->solid != SOLID_NOT) { pr_global_struct->self = EDICT_TO_PROG(e1); pr_global_struct->other = EDICT_TO_PROG(e2); - PR_ExecuteProgram (e1->v.touch, ""); + PR_ExecuteProgram (e1->v->touch, ""); } - if (e2->v.touch && e2->v.solid != SOLID_NOT) + if (e2->v->touch && e2->v->solid != SOLID_NOT) { pr_global_struct->self = EDICT_TO_PROG(e2); pr_global_struct->other = EDICT_TO_PROG(e1); - PR_ExecuteProgram (e2->v.touch, ""); + PR_ExecuteProgram (e2->v->touch, ""); } pr_global_struct->self = old_self; @@ -249,35 +249,35 @@ int SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) numbumps = 4; blocked = 0; - VectorCopy (ent->v.velocity, original_velocity); - VectorCopy (ent->v.velocity, primal_velocity); + VectorCopy (ent->v->velocity, original_velocity); + VectorCopy (ent->v->velocity, primal_velocity); numplanes = 0; time_left = time; for (bumpcount=0 ; bumpcountv.velocity[0] && !ent->v.velocity[1] && !ent->v.velocity[2]) + if (!ent->v->velocity[0] && !ent->v->velocity[1] && !ent->v->velocity[2]) break; for (i=0 ; i<3 ; i++) - end[i] = ent->v.origin[i] + time_left * ent->v.velocity[i]; + end[i] = ent->v->origin[i] + time_left * ent->v->velocity[i]; - trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, end, MOVE_NORMAL, ent); + trace = SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, end, MOVE_NORMAL, ent); if (trace.allsolid) { // LordHavoc: note: this code is what makes entities stick in place if embedded in another object (which can be the world) // entity is trapped in another solid - VectorClear(ent->v.velocity); + VectorClear(ent->v->velocity); return 3; } if (trace.fraction > 0) { // actually covered some distance - VectorCopy (trace.endpos, ent->v.origin); - VectorCopy (ent->v.velocity, original_velocity); + VectorCopy (trace.endpos, ent->v->origin); + VectorCopy (ent->v->velocity, original_velocity); numplanes = 0; } @@ -288,13 +288,13 @@ int SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) if (!trace.ent) Host_Error ("SV_FlyMove: !trace.ent"); - if ((int) ent->v.flags & FL_ONGROUND) + if ((int) ent->v->flags & FL_ONGROUND) { - if (ent->v.groundentity == EDICT_TO_PROG(trace.ent)) + if (ent->v->groundentity == EDICT_TO_PROG(trace.ent)) impact = false; else { - ent->v.flags = (int)ent->v.flags & ~FL_ONGROUND; + ent->v->flags = (int)ent->v->flags & ~FL_ONGROUND; impact = true; } } @@ -305,8 +305,8 @@ int SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) { // floor blocked |= 1; - ent->v.flags = (int)ent->v.flags | FL_ONGROUND; - ent->v.groundentity = EDICT_TO_PROG(trace.ent); + ent->v->flags = (int)ent->v->flags | FL_ONGROUND; + ent->v->groundentity = EDICT_TO_PROG(trace.ent); } if (!trace.plane.normal[2]) { @@ -334,7 +334,7 @@ int SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) if (numplanes >= MAX_CLIP_PLANES) { // this shouldn't really happen - VectorClear(ent->v.velocity); + VectorClear(ent->v->velocity); return 3; } @@ -359,28 +359,28 @@ int SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) if (i != numplanes) { // go along this plane - VectorCopy (new_velocity, ent->v.velocity); + VectorCopy (new_velocity, ent->v->velocity); } else { // go along the crease if (numplanes != 2) { - VectorClear(ent->v.velocity); + VectorClear(ent->v->velocity); return 7; } CrossProduct (planes[0], planes[1], dir); // LordHavoc: thanks to taniwha of QuakeForge for pointing out this fix for slowed falling in corners VectorNormalize(dir); - d = DotProduct (dir, ent->v.velocity); - VectorScale (dir, d, ent->v.velocity); + d = DotProduct (dir, ent->v->velocity); + VectorScale (dir, d, ent->v->velocity); } // if original velocity is against the original velocity, // stop dead to avoid tiny occilations in sloping corners - if (DotProduct (ent->v.velocity, primal_velocity) <= 0) + if (DotProduct (ent->v->velocity, primal_velocity) <= 0) { - VectorClear(ent->v.velocity); + VectorClear(ent->v->velocity); return blocked; } } @@ -405,7 +405,7 @@ void SV_AddGravity (edict_t *ent) ent_gravity = val->_float; else ent_gravity = 1.0; - ent->v.velocity[2] -= ent_gravity * sv_gravity.value * sv.frametime; + ent->v->velocity[2] -= ent_gravity * sv_gravity.value * sv.frametime; } @@ -429,22 +429,22 @@ trace_t SV_PushEntity (edict_t *ent, vec3_t push, vec3_t pushangles) trace_t trace; vec3_t end; - VectorAdd (ent->v.origin, push, end); + VectorAdd (ent->v->origin, push, end); - if (ent->v.movetype == MOVETYPE_FLYMISSILE) - trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, end, MOVE_MISSILE, ent); - else if (ent->v.solid == SOLID_TRIGGER || ent->v.solid == SOLID_NOT) + if (ent->v->movetype == MOVETYPE_FLYMISSILE) + trace = SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, end, MOVE_MISSILE, ent); + else if (ent->v->solid == SOLID_TRIGGER || ent->v->solid == SOLID_NOT) // only clip against bmodels - trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, end, MOVE_NOMONSTERS, ent); + trace = SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, end, MOVE_NOMONSTERS, ent); else - trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, end, MOVE_NORMAL, ent); + trace = SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, end, MOVE_NORMAL, ent); - VectorCopy (trace.endpos, ent->v.origin); + VectorCopy (trace.endpos, ent->v->origin); // FIXME: turn players specially - ent->v.angles[1] += trace.fraction * pushangles[1]; + ent->v->angles[1] += trace.fraction * pushangles[1]; SV_LinkEdict (ent, true); - if (trace.ent && (!((int)ent->v.flags & FL_ONGROUND) || ent->v.groundentity != EDICT_TO_PROG(trace.ent))) + if (trace.ent && (!((int)ent->v->flags & FL_ONGROUND) || ent->v->groundentity != EDICT_TO_PROG(trace.ent))) SV_Impact (ent, trace.ent); return trace; } @@ -469,7 +469,7 @@ void SV_PushMove (edict_t *pusher, float movetime) model_t *pushermodel; trace_t trace; - switch ((int) pusher->v.solid) + switch ((int) pusher->v->solid) { // LordHavoc: valid pusher types case SOLID_BSP: @@ -480,40 +480,40 @@ void SV_PushMove (edict_t *pusher, float movetime) // LordHavoc: no collisions case SOLID_NOT: case SOLID_TRIGGER: - VectorMA (pusher->v.origin, movetime, pusher->v.velocity, pusher->v.origin); - VectorMA (pusher->v.angles, movetime, pusher->v.avelocity, pusher->v.angles); - pusher->v.ltime += movetime; + VectorMA (pusher->v->origin, movetime, pusher->v->velocity, pusher->v->origin); + VectorMA (pusher->v->angles, movetime, pusher->v->avelocity, pusher->v->angles); + pusher->v->ltime += movetime; SV_LinkEdict (pusher, false); return; default: - Host_Error("SV_PushMove: unrecognized solid type %f\n", pusher->v.solid); + Host_Error("SV_PushMove: unrecognized solid type %f\n", pusher->v->solid); } - if (!pusher->v.velocity[0] && !pusher->v.velocity[1] && !pusher->v.velocity[2] && !pusher->v.avelocity[0] && !pusher->v.avelocity[1] && !pusher->v.avelocity[2]) + if (!pusher->v->velocity[0] && !pusher->v->velocity[1] && !pusher->v->velocity[2] && !pusher->v->avelocity[0] && !pusher->v->avelocity[1] && !pusher->v->avelocity[2]) { - pusher->v.ltime += movetime; + pusher->v->ltime += movetime; return; } - index = (int) pusher->v.modelindex; + index = (int) pusher->v->modelindex; if (index < 1 || index >= MAX_MODELS) - Host_Error("SV_PushMove: invalid modelindex %f\n", pusher->v.modelindex); + Host_Error("SV_PushMove: invalid modelindex %f\n", pusher->v->modelindex); pushermodel = sv.models[index]; movetime2 = movetime; - VectorScale(pusher->v.velocity, movetime2, move1); - VectorScale(pusher->v.avelocity, movetime2, moveangle); + VectorScale(pusher->v->velocity, movetime2, move1); + VectorScale(pusher->v->avelocity, movetime2, moveangle); if (moveangle[0] || moveangle[2]) { for (i = 0;i < 3;i++) { if (move1[i] > 0) { - mins[i] = pushermodel->rotatedmins[i] + pusher->v.origin[i] - 1; - maxs[i] = pushermodel->rotatedmaxs[i] + move1[i] + pusher->v.origin[i] + 1; + mins[i] = pushermodel->rotatedmins[i] + pusher->v->origin[i] - 1; + maxs[i] = pushermodel->rotatedmaxs[i] + move1[i] + pusher->v->origin[i] + 1; } else { - mins[i] = pushermodel->rotatedmins[i] + move1[i] + pusher->v.origin[i] - 1; - maxs[i] = pushermodel->rotatedmaxs[i] + pusher->v.origin[i] + 1; + mins[i] = pushermodel->rotatedmins[i] + move1[i] + pusher->v->origin[i] - 1; + maxs[i] = pushermodel->rotatedmaxs[i] + pusher->v->origin[i] + 1; } } } @@ -523,13 +523,13 @@ void SV_PushMove (edict_t *pusher, float movetime) { if (move1[i] > 0) { - mins[i] = pushermodel->yawmins[i] + pusher->v.origin[i] - 1; - maxs[i] = pushermodel->yawmaxs[i] + move1[i] + pusher->v.origin[i] + 1; + mins[i] = pushermodel->yawmins[i] + pusher->v->origin[i] - 1; + maxs[i] = pushermodel->yawmaxs[i] + move1[i] + pusher->v->origin[i] + 1; } else { - mins[i] = pushermodel->yawmins[i] + move1[i] + pusher->v.origin[i] - 1; - maxs[i] = pushermodel->yawmaxs[i] + pusher->v.origin[i] + 1; + mins[i] = pushermodel->yawmins[i] + move1[i] + pusher->v->origin[i] - 1; + maxs[i] = pushermodel->yawmaxs[i] + pusher->v->origin[i] + 1; } } } @@ -539,13 +539,13 @@ void SV_PushMove (edict_t *pusher, float movetime) { if (move1[i] > 0) { - mins[i] = pushermodel->normalmins[i] + pusher->v.origin[i] - 1; - maxs[i] = pushermodel->normalmaxs[i] + move1[i] + pusher->v.origin[i] + 1; + mins[i] = pushermodel->normalmins[i] + pusher->v->origin[i] - 1; + maxs[i] = pushermodel->normalmaxs[i] + move1[i] + pusher->v->origin[i] + 1; } else { - mins[i] = pushermodel->normalmins[i] + move1[i] + pusher->v.origin[i] - 1; - maxs[i] = pushermodel->normalmaxs[i] + pusher->v.origin[i] + 1; + mins[i] = pushermodel->normalmins[i] + move1[i] + pusher->v->origin[i] - 1; + maxs[i] = pushermodel->normalmaxs[i] + pusher->v->origin[i] + 1; } } } @@ -553,18 +553,18 @@ void SV_PushMove (edict_t *pusher, float movetime) VectorNegate (moveangle, a); AngleVectorsFLU (a, forward, left, up); - VectorCopy (pusher->v.origin, pushorig); - VectorCopy (pusher->v.angles, pushang); - pushltime = pusher->v.ltime; + VectorCopy (pusher->v->origin, pushorig); + VectorCopy (pusher->v->angles, pushang); + pushltime = pusher->v->ltime; // move the pusher to it's final position - VectorMA (pusher->v.origin, movetime, pusher->v.velocity, pusher->v.origin); - VectorMA (pusher->v.angles, movetime, pusher->v.avelocity, pusher->v.angles); - pusher->v.ltime += movetime; + VectorMA (pusher->v->origin, movetime, pusher->v->velocity, pusher->v->origin); + VectorMA (pusher->v->angles, movetime, pusher->v->avelocity, pusher->v->angles); + pusher->v->ltime += movetime; SV_LinkEdict (pusher, false); - savesolid = pusher->v.solid; + savesolid = pusher->v->solid; // see if any solid entities are inside the final position num_moved = 0; @@ -573,31 +573,31 @@ void SV_PushMove (edict_t *pusher, float movetime) { if (check->free) continue; - if (check->v.movetype == MOVETYPE_PUSH - || check->v.movetype == MOVETYPE_NONE - || check->v.movetype == MOVETYPE_FOLLOW - || check->v.movetype == MOVETYPE_NOCLIP) + if (check->v->movetype == MOVETYPE_PUSH + || check->v->movetype == MOVETYPE_NONE + || check->v->movetype == MOVETYPE_FOLLOW + || check->v->movetype == MOVETYPE_NOCLIP) continue; // if the entity is standing on the pusher, it will definitely be moved - if (!(((int)check->v.flags & FL_ONGROUND) && PROG_TO_EDICT(check->v.groundentity) == pusher)) + if (!(((int)check->v->flags & FL_ONGROUND) && PROG_TO_EDICT(check->v->groundentity) == pusher)) { - if (check->v.absmin[0] >= maxs[0] - || check->v.absmax[0] <= mins[0] - || check->v.absmin[1] >= maxs[1] - || check->v.absmax[1] <= mins[1] - || check->v.absmin[2] >= maxs[2] - || check->v.absmax[2] <= mins[2]) + if (check->v->absmin[0] >= maxs[0] + || check->v->absmax[0] <= mins[0] + || check->v->absmin[1] >= maxs[1] + || check->v->absmax[1] <= mins[1] + || check->v->absmin[2] >= maxs[2] + || check->v->absmax[2] <= mins[2]) continue; - trace = SV_ClipMoveToEntity (pusher, check->v.origin, check->v.mins, check->v.maxs, check->v.origin); + trace = SV_ClipMoveToEntity (pusher, check->v->origin, check->v->mins, check->v->maxs, check->v->origin); if (!trace.startsolid) continue; } if (forward[0] < 0.999f) // quick way to check if any rotation is used { - VectorSubtract (check->v.origin, pusher->v.origin, org); + VectorSubtract (check->v->origin, pusher->v->origin, org); org2[0] = DotProduct (org, forward); org2[1] = DotProduct (org, left); org2[2] = DotProduct (org, up); @@ -608,60 +608,60 @@ void SV_PushMove (edict_t *pusher, float movetime) VectorCopy (move1, move); // remove the onground flag for non-players - if (check->v.movetype != MOVETYPE_WALK) - check->v.flags = (int)check->v.flags & ~FL_ONGROUND; + if (check->v->movetype != MOVETYPE_WALK) + check->v->flags = (int)check->v->flags & ~FL_ONGROUND; - VectorCopy (check->v.origin, moved_from[num_moved]); - VectorCopy (check->v.angles, moved_fromangles[num_moved]); + VectorCopy (check->v->origin, moved_from[num_moved]); + VectorCopy (check->v->angles, moved_fromangles[num_moved]); moved_edict[num_moved++] = check; // try moving the contacted entity - pusher->v.solid = SOLID_NOT; + pusher->v->solid = SOLID_NOT; trace = SV_PushEntity (check, move, moveangle); - pusher->v.solid = savesolid; // was SOLID_BSP + pusher->v->solid = savesolid; // was SOLID_BSP // if it is still inside the pusher, block if (SV_TestEntityPosition (check)) { // try moving the contacted entity a tiny bit further to account for precision errors - pusher->v.solid = SOLID_NOT; + pusher->v->solid = SOLID_NOT; VectorScale(move, 0.1, move); trace = SV_PushEntity (check, move, vec3_origin); - pusher->v.solid = savesolid; + pusher->v->solid = savesolid; if (SV_TestEntityPosition (check)) { // still inside pusher, so it's really blocked // fail the move - if (check->v.mins[0] == check->v.maxs[0]) + if (check->v->mins[0] == check->v->maxs[0]) continue; - if (check->v.solid == SOLID_NOT || check->v.solid == SOLID_TRIGGER) + if (check->v->solid == SOLID_NOT || check->v->solid == SOLID_TRIGGER) { // corpse - check->v.mins[0] = check->v.mins[1] = 0; - VectorCopy (check->v.mins, check->v.maxs); + check->v->mins[0] = check->v->mins[1] = 0; + VectorCopy (check->v->mins, check->v->maxs); continue; } - VectorCopy (pushorig, pusher->v.origin); - VectorCopy (pushang, pusher->v.angles); - pusher->v.ltime = pushltime; + VectorCopy (pushorig, pusher->v->origin); + VectorCopy (pushang, pusher->v->angles); + pusher->v->ltime = pushltime; SV_LinkEdict (pusher, false); // move back any entities we already moved for (i=0 ; iv.origin); - VectorCopy (moved_fromangles[i], moved_edict[i]->v.angles); + VectorCopy (moved_from[i], moved_edict[i]->v->origin); + VectorCopy (moved_fromangles[i], moved_edict[i]->v->angles); SV_LinkEdict (moved_edict[i], false); } // if the pusher has a "blocked" function, call it, otherwise just stay in place until the obstacle is gone - if (pusher->v.blocked) + if (pusher->v->blocked) { pr_global_struct->self = EDICT_TO_PROG(pusher); pr_global_struct->other = EDICT_TO_PROG(check); - PR_ExecuteProgram (pusher->v.blocked, ""); + PR_ExecuteProgram (pusher->v->blocked, ""); } return; } @@ -679,12 +679,12 @@ void SV_Physics_Pusher (edict_t *ent) { float thinktime, oldltime, movetime; - oldltime = ent->v.ltime; + oldltime = ent->v->ltime; - thinktime = ent->v.nextthink; - if (thinktime < ent->v.ltime + sv.frametime) + thinktime = ent->v->nextthink; + if (thinktime < ent->v->ltime + sv.frametime) { - movetime = thinktime - ent->v.ltime; + movetime = thinktime - ent->v->ltime; if (movetime < 0) movetime = 0; } @@ -692,16 +692,16 @@ void SV_Physics_Pusher (edict_t *ent) movetime = sv.frametime; if (movetime) - // advances ent->v.ltime if not blocked + // advances ent->v->ltime if not blocked SV_PushMove (ent, movetime); - if (thinktime > oldltime && thinktime <= ent->v.ltime) + if (thinktime > oldltime && thinktime <= ent->v->ltime) { - ent->v.nextthink = 0; + ent->v->nextthink = 0; pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(ent); pr_global_struct->other = EDICT_TO_PROG(sv.edicts); - PR_ExecuteProgram (ent->v.think, "NULL think function"); + PR_ExecuteProgram (ent->v->think, "NULL think function"); if (ent->free) return; } @@ -732,12 +732,12 @@ void SV_CheckStuck (edict_t *ent) if (!SV_TestEntityPosition(ent)) { - VectorCopy (ent->v.origin, ent->v.oldorigin); + VectorCopy (ent->v->origin, ent->v->oldorigin); return; } - VectorCopy (ent->v.origin, org); - VectorCopy (ent->v.oldorigin, ent->v.origin); + VectorCopy (ent->v->origin, org); + VectorCopy (ent->v->oldorigin, ent->v->origin); if (!SV_TestEntityPosition(ent)) { Con_DPrintf ("Unstuck.\n"); @@ -749,9 +749,9 @@ void SV_CheckStuck (edict_t *ent) for (i=-1 ; i <= 1 ; i++) for (j=-1 ; j <= 1 ; j++) { - ent->v.origin[0] = org[0] + i; - ent->v.origin[1] = org[1] + j; - ent->v.origin[2] = org[2] + z; + ent->v->origin[0] = org[0] + i; + ent->v->origin[1] = org[1] + j; + ent->v->origin[2] = org[2] + z; if (!SV_TestEntityPosition(ent)) { Con_DPrintf ("Unstuck.\n"); @@ -760,7 +760,7 @@ void SV_CheckStuck (edict_t *ent) } } - VectorCopy (org, ent->v.origin); + VectorCopy (org, ent->v->origin); Con_DPrintf ("player is stuck.\n"); } @@ -775,30 +775,30 @@ qboolean SV_CheckWater (edict_t *ent) int cont; vec3_t point; - point[0] = ent->v.origin[0]; - point[1] = ent->v.origin[1]; - point[2] = ent->v.origin[2] + ent->v.mins[2] + 1; + point[0] = ent->v->origin[0]; + point[1] = ent->v->origin[1]; + point[2] = ent->v->origin[2] + ent->v->mins[2] + 1; - ent->v.waterlevel = 0; - ent->v.watertype = CONTENTS_EMPTY; + ent->v->waterlevel = 0; + ent->v->watertype = CONTENTS_EMPTY; cont = Mod_PointContents(point, sv.worldmodel); if (cont <= CONTENTS_WATER) { - ent->v.watertype = cont; - ent->v.waterlevel = 1; - point[2] = ent->v.origin[2] + (ent->v.mins[2] + ent->v.maxs[2])*0.5; + ent->v->watertype = cont; + ent->v->waterlevel = 1; + point[2] = ent->v->origin[2] + (ent->v->mins[2] + ent->v->maxs[2])*0.5; cont = Mod_PointContents(point, sv.worldmodel); if (cont <= CONTENTS_WATER) { - ent->v.waterlevel = 2; - point[2] = ent->v.origin[2] + ent->v.view_ofs[2]; + ent->v->waterlevel = 2; + point[2] = ent->v->origin[2] + ent->v->view_ofs[2]; cont = Mod_PointContents(point, sv.worldmodel); if (cont <= CONTENTS_WATER) - ent->v.waterlevel = 3; + ent->v->waterlevel = 3; } } - return ent->v.waterlevel > 1; + return ent->v->waterlevel > 1; } /* @@ -812,7 +812,7 @@ void SV_WallFriction (edict_t *ent, trace_t *trace) float d, i; vec3_t forward, into, side; - AngleVectors (ent->v.v_angle, forward, NULL, NULL); + AngleVectors (ent->v->v_angle, forward, NULL, NULL); d = DotProduct (trace->plane.normal, forward); d += 0.5; @@ -820,12 +820,12 @@ void SV_WallFriction (edict_t *ent, trace_t *trace) return; // cut the tangential velocity - i = DotProduct (trace->plane.normal, ent->v.velocity); + i = DotProduct (trace->plane.normal, ent->v->velocity); VectorScale (trace->plane.normal, i, into); - VectorSubtract (ent->v.velocity, into, side); + VectorSubtract (ent->v->velocity, into, side); - ent->v.velocity[0] = side[0] * (1 + d); - ent->v.velocity[1] = side[1] * (1 + d); + ent->v->velocity[0] = side[0] * (1 + d); + ent->v->velocity[1] = side[1] * (1 + d); } /* @@ -846,7 +846,7 @@ int SV_TryUnstick (edict_t *ent, vec3_t oldvel) vec3_t oldorg, dir; trace_t steptrace; - VectorCopy (ent->v.origin, oldorg); + VectorCopy (ent->v->origin, oldorg); VectorClear (dir); for (i=0 ; i<8 ; i++) @@ -867,21 +867,21 @@ int SV_TryUnstick (edict_t *ent, vec3_t oldvel) SV_PushEntity (ent, dir, vec3_origin); // retry the original move - ent->v.velocity[0] = oldvel[0]; - ent->v.velocity[1] = oldvel[1]; - ent->v.velocity[2] = 0; + ent->v->velocity[0] = oldvel[0]; + ent->v->velocity[1] = oldvel[1]; + ent->v->velocity[2] = 0; clip = SV_FlyMove (ent, 0.1, &steptrace); - if (fabs(oldorg[1] - ent->v.origin[1]) > 4 - || fabs(oldorg[0] - ent->v.origin[0]) > 4) + if (fabs(oldorg[1] - ent->v->origin[1]) > 4 + || fabs(oldorg[0] - ent->v->origin[0]) > 4) return clip; // go back to the original pos and try again - VectorCopy (oldorg, ent->v.origin); + VectorCopy (oldorg, ent->v->origin); } // still not moving - VectorClear (ent->v.velocity); + VectorClear (ent->v->velocity); return 7; } @@ -899,11 +899,11 @@ void SV_WalkMove (edict_t *ent) trace_t steptrace, downtrace; // do a regular slide move unless it looks like you ran into a step - oldonground = (int)ent->v.flags & FL_ONGROUND; - ent->v.flags = (int)ent->v.flags & ~FL_ONGROUND; + oldonground = (int)ent->v->flags & FL_ONGROUND; + ent->v->flags = (int)ent->v->flags & ~FL_ONGROUND; - VectorCopy (ent->v.origin, oldorg); - VectorCopy (ent->v.velocity, oldvel); + VectorCopy (ent->v->origin, oldorg); + VectorCopy (ent->v->velocity, oldvel); clip = SV_FlyMove (ent, sv.frametime, &steptrace); @@ -911,13 +911,13 @@ void SV_WalkMove (edict_t *ent) if ( !(clip & 2) ) return; - if (ent->v.movetype != MOVETYPE_FLY) + if (ent->v->movetype != MOVETYPE_FLY) { - if (!oldonground && ent->v.waterlevel == 0 && !sv_jumpstep.integer) + if (!oldonground && ent->v->waterlevel == 0 && !sv_jumpstep.integer) // don't stair up while jumping return; - if (ent->v.movetype != MOVETYPE_WALK) + if (ent->v->movetype != MOVETYPE_WALK) // gibbed by a trigger return; } @@ -925,15 +925,15 @@ void SV_WalkMove (edict_t *ent) if (sv_nostep.integer) return; - if ( (int)sv_player->v.flags & FL_WATERJUMP ) + if ( (int)sv_player->v->flags & FL_WATERJUMP ) return; - VectorCopy (ent->v.origin, nosteporg); - VectorCopy (ent->v.velocity, nostepvel); + VectorCopy (ent->v->origin, nosteporg); + VectorCopy (ent->v->velocity, nostepvel); // try moving up and forward to go up a step // back to start pos - VectorCopy (oldorg, ent->v.origin); + VectorCopy (oldorg, ent->v->origin); VectorClear (upmove); VectorClear (downmove); @@ -945,17 +945,17 @@ void SV_WalkMove (edict_t *ent) SV_PushEntity (ent, upmove, vec3_origin); // move forward - ent->v.velocity[0] = oldvel[0]; - ent->v.velocity[1] = oldvel[1]; - ent->v.velocity[2] = 0; + ent->v->velocity[0] = oldvel[0]; + ent->v->velocity[1] = oldvel[1]; + ent->v->velocity[2] = 0; clip = SV_FlyMove (ent, sv.frametime, &steptrace); - ent->v.velocity[2] += oldvel[2]; + ent->v->velocity[2] += oldvel[2]; // check for stuckness, possibly due to the limited precision of floats // in the clipping hulls if (clip - && fabs(oldorg[1] - ent->v.origin[1]) < 0.03125 - && fabs(oldorg[0] - ent->v.origin[0]) < 0.03125) + && fabs(oldorg[1] - ent->v->origin[1]) < 0.03125 + && fabs(oldorg[0] - ent->v->origin[0]) < 0.03125) // stepping up didn't make any progress clip = SV_TryUnstick (ent, oldvel); @@ -970,10 +970,10 @@ void SV_WalkMove (edict_t *ent) if (downtrace.plane.normal[2] > 0.7) { // LordHavoc: disabled this so you can walk on monsters/players - //if (ent->v.solid == SOLID_BSP) + //if (ent->v->solid == SOLID_BSP) { - ent->v.flags = (int)ent->v.flags | FL_ONGROUND; - ent->v.groundentity = EDICT_TO_PROG(downtrace.ent); + ent->v->flags = (int)ent->v->flags | FL_ONGROUND; + ent->v->groundentity = EDICT_TO_PROG(downtrace.ent); } } else @@ -981,8 +981,8 @@ void SV_WalkMove (edict_t *ent) // if the push down didn't end up on good ground, use the move without // the step up. This happens near wall / slope combinations, and can // cause the player to hop up higher on a slope too steep to climb - VectorCopy (nosteporg, ent->v.origin); - VectorCopy (nostepvel, ent->v.velocity); + VectorCopy (nosteporg, ent->v->origin); + VectorCopy (nostepvel, ent->v->velocity); } } @@ -1008,7 +1008,7 @@ void SV_Physics_Client (edict_t *ent, int num) SV_CheckVelocity (ent); // decide which move function to call - switch ((int)ent->v.movetype) + switch ((int)ent->v->movetype) { case MOVETYPE_NONE: if (!SV_RunThink (ent)) @@ -1018,7 +1018,7 @@ void SV_Physics_Client (edict_t *ent, int num) case MOVETYPE_WALK: if (!SV_RunThink (ent)) return; - if (!SV_CheckWater (ent) && ! ((int)ent->v.flags & FL_WATERJUMP) ) + if (!SV_CheckWater (ent) && ! ((int)ent->v->flags & FL_WATERJUMP) ) SV_AddGravity (ent); SV_CheckStuck (ent); SV_WalkMove (ent); @@ -1041,12 +1041,12 @@ void SV_Physics_Client (edict_t *ent, int num) if (!SV_RunThink (ent)) return; SV_CheckWater (ent); - VectorMA (ent->v.origin, sv.frametime, ent->v.velocity, ent->v.origin); - VectorMA (ent->v.angles, sv.frametime, ent->v.avelocity, ent->v.angles); + VectorMA (ent->v->origin, sv.frametime, ent->v->velocity, ent->v->origin); + VectorMA (ent->v->angles, sv.frametime, ent->v->avelocity, ent->v->angles); break; default: - Host_Error ("SV_Physics_client: bad movetype %i", (int)ent->v.movetype); + Host_Error ("SV_Physics_client: bad movetype %i", (int)ent->v->movetype); } // call standard player post-think @@ -1076,30 +1076,30 @@ void SV_Physics_Follow (edict_t *ent) return; // LordHavoc: implemented rotation on MOVETYPE_FOLLOW objects - e = PROG_TO_EDICT(ent->v.aiment); - if (e->v.angles[0] == ent->v.punchangle[0] && e->v.angles[1] == ent->v.punchangle[1] && e->v.angles[2] == ent->v.punchangle[2]) + e = PROG_TO_EDICT(ent->v->aiment); + if (e->v->angles[0] == ent->v->punchangle[0] && e->v->angles[1] == ent->v->punchangle[1] && e->v->angles[2] == ent->v->punchangle[2]) { // quick case for no rotation - VectorAdd(e->v.origin, ent->v.view_ofs, ent->v.origin); + VectorAdd(e->v->origin, ent->v->view_ofs, ent->v->origin); } else { - angles[0] = -ent->v.punchangle[0]; - angles[1] = ent->v.punchangle[1]; - angles[2] = ent->v.punchangle[2]; + angles[0] = -ent->v->punchangle[0]; + angles[1] = ent->v->punchangle[1]; + angles[2] = ent->v->punchangle[2]; AngleVectors (angles, vf, vr, vu); - v[0] = ent->v.view_ofs[0] * vf[0] + ent->v.view_ofs[1] * vr[0] + ent->v.view_ofs[2] * vu[0]; - v[1] = ent->v.view_ofs[0] * vf[1] + ent->v.view_ofs[1] * vr[1] + ent->v.view_ofs[2] * vu[1]; - v[2] = ent->v.view_ofs[0] * vf[2] + ent->v.view_ofs[1] * vr[2] + ent->v.view_ofs[2] * vu[2]; - angles[0] = -e->v.angles[0]; - angles[1] = e->v.angles[1]; - angles[2] = e->v.angles[2]; + v[0] = ent->v->view_ofs[0] * vf[0] + ent->v->view_ofs[1] * vr[0] + ent->v->view_ofs[2] * vu[0]; + v[1] = ent->v->view_ofs[0] * vf[1] + ent->v->view_ofs[1] * vr[1] + ent->v->view_ofs[2] * vu[1]; + v[2] = ent->v->view_ofs[0] * vf[2] + ent->v->view_ofs[1] * vr[2] + ent->v->view_ofs[2] * vu[2]; + angles[0] = -e->v->angles[0]; + angles[1] = e->v->angles[1]; + angles[2] = e->v->angles[2]; AngleVectors (angles, vf, vr, vu); - ent->v.origin[0] = v[0] * vf[0] + v[1] * vf[1] + v[2] * vf[2] + e->v.origin[0]; - ent->v.origin[1] = v[0] * vr[0] + v[1] * vr[1] + v[2] * vr[2] + e->v.origin[1]; - ent->v.origin[2] = v[0] * vu[0] + v[1] * vu[1] + v[2] * vu[2] + e->v.origin[2]; + ent->v->origin[0] = v[0] * vf[0] + v[1] * vf[1] + v[2] * vf[2] + e->v->origin[0]; + ent->v->origin[1] = v[0] * vr[0] + v[1] * vr[1] + v[2] * vr[2] + e->v->origin[1]; + ent->v->origin[2] = v[0] * vu[0] + v[1] * vu[1] + v[2] * vu[2] + e->v->origin[2]; } - VectorAdd (e->v.angles, ent->v.v_angle, ent->v.angles); + VectorAdd (e->v->angles, ent->v->v_angle, ent->v->angles); SV_LinkEdict (ent, true); } @@ -1116,8 +1116,8 @@ void SV_Physics_Noclip (edict_t *ent) if (!SV_RunThink (ent)) return; - VectorMA (ent->v.angles, sv.frametime, ent->v.avelocity, ent->v.angles); - VectorMA (ent->v.origin, sv.frametime, ent->v.velocity, ent->v.origin); + VectorMA (ent->v->angles, sv.frametime, ent->v->avelocity, ent->v->angles); + VectorMA (ent->v->origin, sv.frametime, ent->v->velocity, ent->v->origin); SV_LinkEdict (ent, false); } @@ -1139,32 +1139,32 @@ SV_CheckWaterTransition void SV_CheckWaterTransition (edict_t *ent) { int cont; - cont = Mod_PointContents(ent->v.origin, sv.worldmodel); - if (!ent->v.watertype) + cont = Mod_PointContents(ent->v->origin, sv.worldmodel); + if (!ent->v->watertype) { // just spawned here - ent->v.watertype = cont; - ent->v.waterlevel = 1; + ent->v->watertype = cont; + ent->v->waterlevel = 1; return; } if (cont <= CONTENTS_WATER) { - if (ent->v.watertype == CONTENTS_EMPTY && cont != CONTENTS_LAVA) + if (ent->v->watertype == CONTENTS_EMPTY && cont != CONTENTS_LAVA) // just crossed into water SV_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1); - ent->v.watertype = cont; - ent->v.waterlevel = 1; + ent->v->watertype = cont; + ent->v->waterlevel = 1; } else { - if (ent->v.watertype != CONTENTS_EMPTY && ent->v.watertype != CONTENTS_LAVA) + if (ent->v->watertype != CONTENTS_EMPTY && ent->v->watertype != CONTENTS_LAVA) // just crossed into water SV_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1); - ent->v.watertype = CONTENTS_EMPTY; - ent->v.waterlevel = cont; + ent->v->watertype = CONTENTS_EMPTY; + ent->v->waterlevel = cont; } } @@ -1186,15 +1186,15 @@ void SV_Physics_Toss (edict_t *ent) return; // if onground, return without moving - if ((int)ent->v.flags & FL_ONGROUND) + if ((int)ent->v->flags & FL_ONGROUND) { - VectorClear(ent->v.velocity); - if (ent->v.groundentity == 0) + VectorClear(ent->v->velocity); + if (ent->v->groundentity == 0) return; // if ent was supported by a brush model on previous frame, // and groundentity is now freed, set groundentity to 0 (floating) - groundentity = PROG_TO_EDICT(ent->v.groundentity); - if (groundentity->v.solid == SOLID_BSP) + groundentity = PROG_TO_EDICT(ent->v->groundentity); + if (groundentity->v->solid == SOLID_BSP) { ent->suspendedinairflag = true; return; @@ -1202,7 +1202,7 @@ void SV_Physics_Toss (edict_t *ent) else if (ent->suspendedinairflag && groundentity->free) { // leave it suspended in the air - ent->v.groundentity = 0; + ent->v->groundentity = 0; ent->suspendedinairflag = false; return; } @@ -1212,51 +1212,51 @@ void SV_Physics_Toss (edict_t *ent) SV_CheckVelocity (ent); // add gravity - if (ent->v.movetype == MOVETYPE_TOSS || ent->v.movetype == MOVETYPE_BOUNCE) + if (ent->v->movetype == MOVETYPE_TOSS || ent->v->movetype == MOVETYPE_BOUNCE) SV_AddGravity (ent); // move angles - VectorMA (ent->v.angles, sv.frametime, ent->v.avelocity, ent->v.angles); + VectorMA (ent->v->angles, sv.frametime, ent->v->avelocity, ent->v->angles); // move origin - VectorScale (ent->v.velocity, sv.frametime, move); + VectorScale (ent->v->velocity, sv.frametime, move); trace = SV_PushEntity (ent, move, vec3_origin); if (ent->free) return; if (trace.fraction < 1) { - if (ent->v.movetype == MOVETYPE_BOUNCEMISSILE) + if (ent->v->movetype == MOVETYPE_BOUNCEMISSILE) { - ClipVelocity (ent->v.velocity, trace.plane.normal, ent->v.velocity, 2.0); - ent->v.flags = (int)ent->v.flags & ~FL_ONGROUND; + ClipVelocity (ent->v->velocity, trace.plane.normal, ent->v->velocity, 2.0); + ent->v->flags = (int)ent->v->flags & ~FL_ONGROUND; } - else if (ent->v.movetype == MOVETYPE_BOUNCE) + else if (ent->v->movetype == MOVETYPE_BOUNCE) { - ClipVelocity (ent->v.velocity, trace.plane.normal, ent->v.velocity, 1.5); + ClipVelocity (ent->v->velocity, trace.plane.normal, ent->v->velocity, 1.5); // LordHavoc: fixed grenades not bouncing when fired down a slope - if (trace.plane.normal[2] > 0.7 && DotProduct(trace.plane.normal, ent->v.velocity) < 60) + if (trace.plane.normal[2] > 0.7 && DotProduct(trace.plane.normal, ent->v->velocity) < 60) { - ent->v.flags = (int)ent->v.flags | FL_ONGROUND; - ent->v.groundentity = EDICT_TO_PROG(trace.ent); - VectorClear (ent->v.velocity); - VectorClear (ent->v.avelocity); + ent->v->flags = (int)ent->v->flags | FL_ONGROUND; + ent->v->groundentity = EDICT_TO_PROG(trace.ent); + VectorClear (ent->v->velocity); + VectorClear (ent->v->avelocity); } else - ent->v.flags = (int)ent->v.flags & ~FL_ONGROUND; + ent->v->flags = (int)ent->v->flags & ~FL_ONGROUND; } else { - ClipVelocity (ent->v.velocity, trace.plane.normal, ent->v.velocity, 1.0); + ClipVelocity (ent->v->velocity, trace.plane.normal, ent->v->velocity, 1.0); if (trace.plane.normal[2] > 0.7) { - ent->v.flags = (int)ent->v.flags | FL_ONGROUND; - ent->v.groundentity = EDICT_TO_PROG(trace.ent); - VectorClear (ent->v.velocity); - VectorClear (ent->v.avelocity); + ent->v->flags = (int)ent->v->flags | FL_ONGROUND; + ent->v->groundentity = EDICT_TO_PROG(trace.ent); + VectorClear (ent->v->velocity); + VectorClear (ent->v->avelocity); } else - ent->v.flags = (int)ent->v.flags & ~FL_ONGROUND; + ent->v->flags = (int)ent->v->flags & ~FL_ONGROUND; } } @@ -1289,20 +1289,20 @@ void SV_Physics_Step (edict_t *ent) // freefall if not fly/swim fall = true; - flags = (int)ent->v.flags; + flags = (int)ent->v->flags; if (flags & (FL_FLY | FL_SWIM)) { if (flags & FL_FLY) fall = false; - else if ((flags & FL_SWIM) && Mod_PointContents(ent->v.origin, sv.worldmodel) != CONTENTS_EMPTY) + else if ((flags & FL_SWIM) && Mod_PointContents(ent->v->origin, sv.worldmodel) != CONTENTS_EMPTY) fall = false; } - if (fall && (flags & FL_ONGROUND) && ent->v.groundentity == 0) + if (fall && (flags & FL_ONGROUND) && ent->v->groundentity == 0) fall = false; if (fall) { - if (ent->v.velocity[2] < sv_gravity.value*-0.1) + if (ent->v->velocity[2] < sv_gravity.value*-0.1) { hitsound = true; if (flags & FL_ONGROUND) @@ -1317,9 +1317,9 @@ void SV_Physics_Step (edict_t *ent) SV_LinkEdict (ent, false); // just hit ground - if ((int)ent->v.flags & FL_ONGROUND) + if ((int)ent->v->flags & FL_ONGROUND) { - VectorClear(ent->v.velocity); + VectorClear(ent->v->velocity); if (hitsound) SV_StartSound (ent, 0, "demon/dland2.wav", 255, 1); } @@ -1368,14 +1368,14 @@ void SV_Physics (void) continue; } - switch ((int) ent->v.movetype) + switch ((int) ent->v->movetype) { case MOVETYPE_PUSH: SV_Physics_Pusher (ent); break; case MOVETYPE_NONE: // LordHavoc: manually inlined the thinktime check here because MOVETYPE_NONE is used on so many objects - if (ent->v.nextthink > 0 && ent->v.nextthink <= sv.time + sv.frametime) + if (ent->v->nextthink > 0 && ent->v->nextthink <= sv.time + sv.frametime) SV_RunThink (ent); break; case MOVETYPE_FOLLOW: @@ -1391,7 +1391,7 @@ void SV_Physics (void) case MOVETYPE_WALK: if (SV_RunThink (ent)) { - if (!SV_CheckWater (ent) && ! ((int)ent->v.flags & FL_WATERJUMP) ) + if (!SV_CheckWater (ent) && ! ((int)ent->v->flags & FL_WATERJUMP) ) SV_AddGravity (ent); SV_CheckStuck (ent); SV_WalkMove (ent); @@ -1406,7 +1406,7 @@ void SV_Physics (void) SV_Physics_Toss (ent); break; default: - Host_Error ("SV_Physics: bad movetype %i", (int)ent->v.movetype); + Host_Error ("SV_Physics: bad movetype %i", (int)ent->v->movetype); break; } } @@ -1438,8 +1438,8 @@ trace_t SV_Trace_Toss (edict_t *tossent, edict_t *ignore) memcpy(&tempent, tossent, sizeof(edict_t)); tent = &tempent; - savesolid = tossent->v.solid; - tossent->v.solid = SOLID_NOT; + savesolid = tossent->v->solid; + tossent->v->solid = SOLID_NOT; // this has to fetch the field from the original edict, since our copy is truncated val = GETEDICTFIELDVALUE(tossent, eval_gravity); @@ -1452,18 +1452,18 @@ trace_t SV_Trace_Toss (edict_t *tossent, edict_t *ignore) for (i = 0;i < 200;i++) // LordHavoc: sanity check; never trace more than 10 seconds { SV_CheckVelocity (tent); - tent->v.velocity[2] -= gravity; - VectorMA (tent->v.angles, 0.05, tent->v.avelocity, tent->v.angles); - VectorScale (tent->v.velocity, 0.05, move); - VectorAdd (tent->v.origin, move, end); - trace = SV_Move (tent->v.origin, tent->v.mins, tent->v.maxs, end, MOVE_NORMAL, tent); - VectorCopy (trace.endpos, tent->v.origin); + tent->v->velocity[2] -= gravity; + VectorMA (tent->v->angles, 0.05, tent->v->avelocity, tent->v->angles); + VectorScale (tent->v->velocity, 0.05, move); + VectorAdd (tent->v->origin, move, end); + trace = SV_Move (tent->v->origin, tent->v->mins, tent->v->maxs, end, MOVE_NORMAL, tent); + VectorCopy (trace.endpos, tent->v->origin); if (trace.fraction < 1 && trace.ent) if (trace.ent != ignore) break; } - tossent->v.solid = savesolid; + tossent->v->solid = savesolid; trace.fraction = 0; // not relevant return trace; } diff --git a/sv_user.c b/sv_user.c index 1213e6f1..135a6d50 100644 --- a/sv_user.c +++ b/sv_user.c @@ -60,18 +60,18 @@ void SV_SetIdealPitch (void) int i, j; int step, dir, steps; - if (!((int)sv_player->v.flags & FL_ONGROUND)) + if (!((int)sv_player->v->flags & FL_ONGROUND)) return; - angleval = sv_player->v.angles[YAW] * M_PI*2 / 360; + angleval = sv_player->v->angles[YAW] * M_PI*2 / 360; sinval = sin(angleval); cosval = cos(angleval); for (i=0 ; iv.origin[0] + cosval*(i+3)*12; - top[1] = sv_player->v.origin[1] + sinval*(i+3)*12; - top[2] = sv_player->v.origin[2] + sv_player->v.view_ofs[2]; + top[0] = sv_player->v->origin[0] + cosval*(i+3)*12; + top[1] = sv_player->v->origin[1] + sinval*(i+3)*12; + top[2] = sv_player->v->origin[2] + sv_player->v->view_ofs[2]; bottom[0] = top[0]; bottom[1] = top[1]; @@ -107,13 +107,13 @@ void SV_SetIdealPitch (void) if (!dir) { - sv_player->v.idealpitch = 0; + sv_player->v->idealpitch = 0; return; } if (steps < 2) return; - sv_player->v.idealpitch = -dir * sv_idealpitchscale.value; + sv_player->v->idealpitch = -dir * sv_idealpitchscale.value; } @@ -138,7 +138,7 @@ void SV_UserFriction (void) // if the leading edge is over a dropoff, increase friction start[0] = stop[0] = origin[0] + vel[0]/speed*16; start[1] = stop[1] = origin[1] + vel[1]/speed*16; - start[2] = origin[2] + sv_player->v.mins[2]; + start[2] = origin[2] + sv_player->v->mins[2]; stop[2] = start[2] - 34; trace = SV_Move (start, vec3_origin, vec3_origin, stop, MOVE_NOMONSTERS, sv_player); @@ -210,12 +210,12 @@ void DropPunchAngle (void) float len; eval_t *val; - len = VectorNormalizeLength (sv_player->v.punchangle); + len = VectorNormalizeLength (sv_player->v->punchangle); len -= 10*sv.frametime; if (len < 0) len = 0; - VectorScale (sv_player->v.punchangle, len, sv_player->v.punchangle); + VectorScale (sv_player->v->punchangle, len, sv_player->v->punchangle); if ((val = GETEDICTFIELDVALUE(sv_player, eval_punchvector))) { @@ -238,7 +238,7 @@ void SV_FreeMove (void) int i; float wishspeed; - AngleVectors (sv_player->v.v_angle, forward, right, up); + AngleVectors (sv_player->v->v_angle, forward, right, up); for (i = 0; i < 3; i++) velocity[i] = forward[i] * cmd.forwardmove + right[i] * cmd.sidemove; @@ -266,7 +266,7 @@ void SV_WaterMove (void) float speed, newspeed, wishspeed, addspeed, accelspeed, temp; // user intentions - AngleVectors (sv_player->v.v_angle, forward, right, up); + AngleVectors (sv_player->v->v_angle, forward, right, up); for (i=0 ; i<3 ; i++) wishvel[i] = forward[i]*cmd.forwardmove + right[i]*cmd.sidemove; @@ -317,13 +317,13 @@ void SV_WaterMove (void) void SV_WaterJump (void) { - if (sv.time > sv_player->v.teleport_time || !sv_player->v.waterlevel) + if (sv.time > sv_player->v->teleport_time || !sv_player->v->waterlevel) { - sv_player->v.flags = (int)sv_player->v.flags & ~FL_WATERJUMP; - sv_player->v.teleport_time = 0; + sv_player->v->flags = (int)sv_player->v->flags & ~FL_WATERJUMP; + sv_player->v->teleport_time = 0; } - sv_player->v.velocity[0] = sv_player->v.movedir[0]; - sv_player->v.velocity[1] = sv_player->v.movedir[1]; + sv_player->v->velocity[0] = sv_player->v->movedir[0]; + sv_player->v->velocity[1] = sv_player->v->movedir[1]; } @@ -341,20 +341,20 @@ void SV_AirMove (void) // LordHavoc: correct quake movement speed bug when looking up/down wishvel[0] = wishvel[2] = 0; - wishvel[1] = sv_player->v.angles[1]; + wishvel[1] = sv_player->v->angles[1]; AngleVectors (wishvel, forward, right, up); fmove = cmd.forwardmove; smove = cmd.sidemove; // hack to not let you back into teleporter - if (sv.time < sv_player->v.teleport_time && fmove < 0) + if (sv.time < sv_player->v->teleport_time && fmove < 0) fmove = 0; for (i=0 ; i<3 ; i++) wishvel[i] = forward[i]*fmove + right[i]*smove; - if ((int)sv_player->v.movetype != MOVETYPE_WALK) + if ((int)sv_player->v->movetype != MOVETYPE_WALK) wishvel[2] += cmd.upmove; VectorCopy (wishvel, wishdir); @@ -366,7 +366,7 @@ void SV_AirMove (void) wishspeed = sv_maxspeed.value; } - if (sv_player->v.movetype == MOVETYPE_NOCLIP) + if (sv_player->v->movetype == MOVETYPE_NOCLIP) { // noclip VectorCopy (wishvel, velocity); @@ -395,38 +395,38 @@ void SV_ClientThink (void) { vec3_t v_angle; - if (sv_player->v.movetype == MOVETYPE_NONE) + if (sv_player->v->movetype == MOVETYPE_NONE) return; - onground = (int)sv_player->v.flags & FL_ONGROUND; + onground = (int)sv_player->v->flags & FL_ONGROUND; - origin = sv_player->v.origin; - velocity = sv_player->v.velocity; + origin = sv_player->v->origin; + velocity = sv_player->v->velocity; DropPunchAngle (); // if dead, behave differently - if (sv_player->v.health <= 0) + if (sv_player->v->health <= 0) return; // angles // show 1/3 the pitch angle and all the roll angle cmd = host_client->cmd; - angles = sv_player->v.angles; + angles = sv_player->v->angles; - VectorAdd (sv_player->v.v_angle, sv_player->v.punchangle, v_angle); - angles[ROLL] = V_CalcRoll (sv_player->v.angles, sv_player->v.velocity)*4; - if (!sv_player->v.fixangle) + VectorAdd (sv_player->v->v_angle, sv_player->v->punchangle, v_angle); + angles[ROLL] = V_CalcRoll (sv_player->v->angles, sv_player->v->velocity)*4; + if (!sv_player->v->fixangle) { // LordHavoc: pitch was ugly to begin with... removed except in water - if (sv_player->v.waterlevel >= 2) + if (sv_player->v->waterlevel >= 2) angles[PITCH] = -v_angle[PITCH]/3; else angles[PITCH] = 0; angles[YAW] = v_angle[YAW]; } - if ( (int)sv_player->v.flags & FL_WATERJUMP ) + if ( (int)sv_player->v->flags & FL_WATERJUMP ) { SV_WaterJump (); return; @@ -434,15 +434,15 @@ void SV_ClientThink (void) // Player is (somehow) outside of the map, or flying, or noclipping if (SV_TestEntityPosition (sv_player) - || sv_player->v.movetype == MOVETYPE_FLY - || sv_player->v.movetype == MOVETYPE_NOCLIP) + || sv_player->v->movetype == MOVETYPE_FLY + || sv_player->v->movetype == MOVETYPE_NOCLIP) { SV_FreeMove (); return; } // walk - if ((sv_player->v.waterlevel >= 2) && (sv_player->v.movetype != MOVETYPE_NOCLIP)) + if ((sv_player->v->waterlevel >= 2) && (sv_player->v->movetype != MOVETYPE_NOCLIP)) { SV_WaterMove (); return; @@ -484,7 +484,7 @@ void SV_ReadClientMove (usercmd_t *move) for (i = 0;i < 3;i++) angle[i] = MSG_ReadFloat (); - VectorCopy (angle, host_client->edict->v.v_angle); + VectorCopy (angle, host_client->edict->v->v_angle); // read movement move->forwardmove = MSG_ReadShort (); @@ -499,8 +499,8 @@ void SV_ReadClientMove (usercmd_t *move) // read buttons bits = MSG_ReadByte (); - host_client->edict->v.button0 = bits & 1; - host_client->edict->v.button2 = (bits & 2)>>1; + host_client->edict->v->button0 = bits & 1; + host_client->edict->v->button2 = (bits & 2)>>1; // LordHavoc: added 6 new buttons if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button3))) val->_float = ((bits >> 2) & 1); if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button4))) val->_float = ((bits >> 3) & 1); @@ -511,7 +511,7 @@ void SV_ReadClientMove (usercmd_t *move) i = MSG_ReadByte (); if (i) - host_client->edict->v.impulse = i; + host_client->edict->v->impulse = i; } /* diff --git a/world.c b/world.c index 0dbcb29f..4fab85e1 100644 --- a/world.c +++ b/world.c @@ -221,14 +221,14 @@ loc0: touch = EDICT_FROM_AREA(l); if (touch == ent) continue; - if (!touch->v.touch || touch->v.solid != SOLID_TRIGGER) + if (!touch->v->touch || touch->v->solid != SOLID_TRIGGER) continue; - if (ent->v.absmin[0] > touch->v.absmax[0] - || ent->v.absmin[1] > touch->v.absmax[1] - || ent->v.absmin[2] > touch->v.absmax[2] - || ent->v.absmax[0] < touch->v.absmin[0] - || ent->v.absmax[1] < touch->v.absmin[1] - || ent->v.absmax[2] < touch->v.absmin[2]) + if (ent->v->absmin[0] > touch->v->absmax[0] + || ent->v->absmin[1] > touch->v->absmax[1] + || ent->v->absmin[2] > touch->v->absmax[2] + || ent->v->absmax[0] < touch->v->absmin[0] + || ent->v->absmax[1] < touch->v->absmin[1] + || ent->v->absmax[2] < touch->v->absmin[2]) continue; old_self = pr_global_struct->self; old_other = pr_global_struct->other; @@ -236,7 +236,7 @@ loc0: pr_global_struct->self = EDICT_TO_PROG(touch); pr_global_struct->other = EDICT_TO_PROG(ent); pr_global_struct->time = sv.time; - PR_ExecuteProgram (touch->v.touch, ""); + PR_ExecuteProgram (touch->v->touch, ""); pr_global_struct->self = old_self; pr_global_struct->other = old_other; @@ -246,16 +246,16 @@ loc0: if (node->axis == -1) return; - if (ent->v.absmax[node->axis] > node->dist) + if (ent->v->absmax[node->axis] > node->dist) { - if (ent->v.absmin[node->axis] < node->dist) + if (ent->v->absmin[node->axis] < node->dist) SV_TouchLinks(ent, node->children[1]); // order reversed to reduce code node = node->children[0]; goto loc0; } else { - if (ent->v.absmin[node->axis] < node->dist) + if (ent->v->absmin[node->axis] < node->dist) { node = node->children[1]; goto loc0; @@ -286,71 +286,71 @@ void SV_LinkEdict (edict_t *ent, qboolean touch_triggers) // set the abs box - if (ent->v.solid == SOLID_BSP) + if (ent->v->solid == SOLID_BSP) { - if (ent->v.modelindex < 0 || ent->v.modelindex > MAX_MODELS) + if (ent->v->modelindex < 0 || ent->v->modelindex > MAX_MODELS) Host_Error("SOLID_BSP with invalid modelindex!\n"); - model = sv.models[(int) ent->v.modelindex]; + model = sv.models[(int) ent->v->modelindex]; if (model != NULL) { if (model->type != mod_brush) Host_Error("SOLID_BSP with non-BSP model\n"); - if (ent->v.angles[0] || ent->v.angles[2] || ent->v.avelocity[0] || ent->v.avelocity[2]) + if (ent->v->angles[0] || ent->v->angles[2] || ent->v->avelocity[0] || ent->v->avelocity[2]) { - VectorAdd(ent->v.origin, model->rotatedmins, ent->v.absmin); - VectorAdd(ent->v.origin, model->rotatedmaxs, ent->v.absmax); + VectorAdd(ent->v->origin, model->rotatedmins, ent->v->absmin); + VectorAdd(ent->v->origin, model->rotatedmaxs, ent->v->absmax); } - else if (ent->v.angles[1] || ent->v.avelocity[1]) + else if (ent->v->angles[1] || ent->v->avelocity[1]) { - VectorAdd(ent->v.origin, model->yawmins, ent->v.absmin); - VectorAdd(ent->v.origin, model->yawmaxs, ent->v.absmax); + VectorAdd(ent->v->origin, model->yawmins, ent->v->absmin); + VectorAdd(ent->v->origin, model->yawmaxs, ent->v->absmax); } else { - VectorAdd(ent->v.origin, model->normalmins, ent->v.absmin); - VectorAdd(ent->v.origin, model->normalmaxs, ent->v.absmax); + VectorAdd(ent->v->origin, model->normalmins, ent->v->absmin); + VectorAdd(ent->v->origin, model->normalmaxs, ent->v->absmax); } } else { // SOLID_BSP with no model is valid, mainly because some QC setup code does so temporarily - VectorAdd (ent->v.origin, ent->v.mins, ent->v.absmin); - VectorAdd (ent->v.origin, ent->v.maxs, ent->v.absmax); + VectorAdd (ent->v->origin, ent->v->mins, ent->v->absmin); + VectorAdd (ent->v->origin, ent->v->maxs, ent->v->absmax); } } else { - VectorAdd (ent->v.origin, ent->v.mins, ent->v.absmin); - VectorAdd (ent->v.origin, ent->v.maxs, ent->v.absmax); + VectorAdd (ent->v->origin, ent->v->mins, ent->v->absmin); + VectorAdd (ent->v->origin, ent->v->maxs, ent->v->absmax); } // // to make items easier to pick up and allow them to be grabbed off // of shelves, the abs sizes are expanded // - if ((int)ent->v.flags & FL_ITEM) + if ((int)ent->v->flags & FL_ITEM) { - ent->v.absmin[0] -= 15; - ent->v.absmin[1] -= 15; - ent->v.absmin[2] -= 1; - ent->v.absmax[0] += 15; - ent->v.absmax[1] += 15; - ent->v.absmax[2] += 1; + ent->v->absmin[0] -= 15; + ent->v->absmin[1] -= 15; + ent->v->absmin[2] -= 1; + ent->v->absmax[0] += 15; + ent->v->absmax[1] += 15; + ent->v->absmax[2] += 1; } else { // because movement is clipped an epsilon away from an actual edge, // we must fully check even when bounding boxes don't quite touch - ent->v.absmin[0] -= 1; - ent->v.absmin[1] -= 1; - ent->v.absmin[2] -= 1; - ent->v.absmax[0] += 1; - ent->v.absmax[1] += 1; - ent->v.absmax[2] += 1; + ent->v->absmin[0] -= 1; + ent->v->absmin[1] -= 1; + ent->v->absmin[2] -= 1; + ent->v->absmax[0] += 1; + ent->v->absmax[1] += 1; + ent->v->absmax[2] += 1; } - if (ent->v.solid == SOLID_NOT) + if (ent->v->solid == SOLID_NOT) return; // find the first node that the ent's box crosses @@ -359,9 +359,9 @@ void SV_LinkEdict (edict_t *ent, qboolean touch_triggers) { if (node->axis == -1) break; - if (ent->v.absmin[node->axis] > node->dist) + if (ent->v->absmin[node->axis] > node->dist) node = node->children[0]; - else if (ent->v.absmax[node->axis] < node->dist) + else if (ent->v->absmax[node->axis] < node->dist) node = node->children[1]; else break; // crosses the node @@ -369,7 +369,7 @@ void SV_LinkEdict (edict_t *ent, qboolean touch_triggers) // link it in - if (ent->v.solid == SOLID_TRIGGER) + if (ent->v->solid == SOLID_TRIGGER) InsertLinkBefore (&ent->area, &node->trigger_edicts); else InsertLinkBefore (&ent->area, &node->solid_edicts); @@ -398,7 +398,7 @@ This could be a lot more efficient... */ int SV_TestEntityPosition (edict_t *ent) { - return SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, ent->v.origin, MOVE_NORMAL, ent).startsolid; + return SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, ent->v->origin, MOVE_NORMAL, ent).startsolid; } @@ -424,14 +424,14 @@ trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t max trace_t trace; model_t *model; - i = ent->v.modelindex; + i = ent->v->modelindex; if ((unsigned int) i >= MAX_MODELS) Host_Error("SV_ClipMoveToEntity: invalid modelindex\n"); model = sv.models[i]; if (i != 0 && model == NULL) Host_Error("SV_ClipMoveToEntity: invalid modelindex\n"); - if ((int) ent->v.solid == SOLID_BSP) + if ((int) ent->v->solid == SOLID_BSP) { Mod_CheckLoaded(model); if (model->type != mod_brush) @@ -440,11 +440,11 @@ trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t max ED_Print (ent); Host_Error ("SV_ClipMoveToEntity: SOLID_BSP with a non bsp model\n"); } - if (ent->v.movetype != MOVETYPE_PUSH) + if (ent->v->movetype != MOVETYPE_PUSH) Host_Error ("SV_ClipMoveToEntity: SOLID_BSP without MOVETYPE_PUSH"); } - Collision_ClipTrace(&trace, ent, model, ent->v.origin, ent->v.angles, ent->v.mins, ent->v.maxs, start, mins, maxs, end); + Collision_ClipTrace(&trace, ent, model, ent->v->origin, ent->v->angles, ent->v->mins, ent->v->maxs, start, mins, maxs, end); return trace; } @@ -472,46 +472,46 @@ loc0: { next = l->next; touch = EDICT_FROM_AREA(l); - if (touch->v.solid == SOLID_NOT) + if (touch->v->solid == SOLID_NOT) continue; if (touch == clip->passedict) continue; - if (touch->v.solid == SOLID_TRIGGER) + if (touch->v->solid == SOLID_TRIGGER) { ED_Print(touch); Host_Error ("Trigger in clipping list"); } - if (clip->type == MOVE_NOMONSTERS && touch->v.solid != SOLID_BSP) + if (clip->type == MOVE_NOMONSTERS && touch->v->solid != SOLID_BSP) continue; - if (clip->boxmins[0] > touch->v.absmax[0] - || clip->boxmaxs[0] < touch->v.absmin[0] - || clip->boxmins[1] > touch->v.absmax[1] - || clip->boxmaxs[1] < touch->v.absmin[1] - || clip->boxmins[2] > touch->v.absmax[2] - || clip->boxmaxs[2] < touch->v.absmin[2]) + if (clip->boxmins[0] > touch->v->absmax[0] + || clip->boxmaxs[0] < touch->v->absmin[0] + || clip->boxmins[1] > touch->v->absmax[1] + || clip->boxmaxs[1] < touch->v->absmin[1] + || clip->boxmins[2] > touch->v->absmax[2] + || clip->boxmaxs[2] < touch->v->absmin[2]) continue; if (clip->passedict) { - if (clip->passedict->v.size[0] && !touch->v.size[0]) + if (clip->passedict->v->size[0] && !touch->v->size[0]) continue; // points never interact - if (PROG_TO_EDICT(touch->v.owner) == clip->passedict) + if (PROG_TO_EDICT(touch->v->owner) == clip->passedict) continue; // don't clip against own missiles - if (PROG_TO_EDICT(clip->passedict->v.owner) == touch) + if (PROG_TO_EDICT(clip->passedict->v->owner) == touch) continue; // don't clip against owner // LordHavoc: corpse code - if (clip->passedict->v.solid == SOLID_CORPSE && (touch->v.solid == SOLID_SLIDEBOX || touch->v.solid == SOLID_CORPSE)) + if (clip->passedict->v->solid == SOLID_CORPSE && (touch->v->solid == SOLID_SLIDEBOX || touch->v->solid == SOLID_CORPSE)) continue; - if (clip->passedict->v.solid == SOLID_SLIDEBOX && touch->v.solid == SOLID_CORPSE) + if (clip->passedict->v->solid == SOLID_SLIDEBOX && touch->v->solid == SOLID_CORPSE) continue; } // might interact, so do an exact clip - if (touch->v.solid == SOLID_BSP) + if (touch->v->solid == SOLID_BSP) trace = SV_ClipMoveToEntity (touch, clip->start, clip->hullmins, clip->hullmaxs, clip->end); - else if ((int)touch->v.flags & FL_MONSTER) + else if ((int)touch->v->flags & FL_MONSTER) trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end); else trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins, clip->maxs, clip->end); -- 2.39.2