Compare commits

...

2 Commits

Author SHA1 Message Date
an 586d1cef9b remove entvars_t 2019-12-06 10:53:56 -05:00
an c6536dddd3 fix odd lvalue use 2019-12-06 09:52:25 -05:00
18 changed files with 709 additions and 729 deletions

View File

@ -93,7 +93,6 @@ set(srcs
source/pr_exec.c source/pr_exec.c
source/pr_load.c source/pr_load.c
source/pr_string.c source/pr_string.c
source/progdefs.h
source/progs.h source/progs.h
source/protocol.h source/protocol.h
source/q_ctype.h source/q_ctype.h

View File

@ -753,16 +753,16 @@ void R_ShowBoundingBoxes(void)
// if (!SV_VisibleToClient (sv_player, ed, sv.worldmodel)) // if (!SV_VisibleToClient (sv_player, ed, sv.worldmodel))
// continue; //don't draw if not in pvs // continue; //don't draw if not in pvs
if(ed->v.mins[0] == ed->v.maxs[0] && ed->v.mins[1] == ed->v.maxs[1] && ed->v.mins[2] == ed->v.maxs[2]) if(ED_VECTOR(ed, ED_mins)[0] == ED_VECTOR(ed, ED_maxs)[0] && ED_VECTOR(ed, ED_mins)[1] == ED_VECTOR(ed, ED_maxs)[1] && ED_VECTOR(ed, ED_mins)[2] == ED_VECTOR(ed, ED_maxs)[2])
{ {
//point entity //point entity
R_EmitWirePoint(ed->v.origin); R_EmitWirePoint(ED_VECTOR(ed, ED_origin));
} }
else else
{ {
//box entity //box entity
VectorAdd(ed->v.mins, ed->v.origin, mins); VectorAdd(ED_VECTOR(ed, ED_mins), ED_VECTOR(ed, ED_origin), mins);
VectorAdd(ed->v.maxs, ed->v.origin, maxs); VectorAdd(ED_VECTOR(ed, ED_maxs), ED_VECTOR(ed, ED_origin), maxs);
R_EmitWireBox(mins, maxs); R_EmitWireBox(mins, maxs);
} }
} }

View File

@ -470,7 +470,7 @@ void Host_Status_f(void)
} }
else else
hours = 0; hours = 0;
print_fn("#%-2" PRIu32 " %-16.16s %3" PRIi32 " %2" PRIi32 ":%02" PRIi32 ":%02" PRIi32 "n", j + 1, client->name, (int32_t)client->edict->v.frags, hours, minutes, seconds); print_fn("#%-2" PRIu32 " %-16.16s %3" PRIi32 " %2" PRIi32 ":%02" PRIi32 ":%02" PRIi32 "n", j + 1, client->name, (int32_t)ED_FLOAT(client->edict, ED_frags), hours, minutes, seconds);
print_fn(" %s\n", NET_QSocketGetAddressString(client->netconnection)); print_fn(" %s\n", NET_QSocketGetAddressString(client->netconnection));
} }
} }
@ -497,8 +497,8 @@ void Host_God_f(void)
switch(Cmd_Argc()) switch(Cmd_Argc())
{ {
case 1: case 1:
sv_player->v.flags = (int32_t)sv_player->v.flags ^ FL_GODMODE; ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) ^ FL_GODMODE;
if(!((int32_t)sv_player->v.flags & FL_GODMODE)) if(!((int32_t)ED_FLOAT(sv_player, ED_flags) & FL_GODMODE))
SV_ClientPrintf("godmode OFF\n"); SV_ClientPrintf("godmode OFF\n");
else else
SV_ClientPrintf("godmode ON\n"); SV_ClientPrintf("godmode ON\n");
@ -506,12 +506,12 @@ void Host_God_f(void)
case 2: case 2:
if(Q_atof(Cmd_Argv(1))) if(Q_atof(Cmd_Argv(1)))
{ {
sv_player->v.flags = (int32_t)sv_player->v.flags | FL_GODMODE; ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) | FL_GODMODE;
SV_ClientPrintf("godmode ON\n"); SV_ClientPrintf("godmode ON\n");
} }
else else
{ {
sv_player->v.flags = (int32_t)sv_player->v.flags & ~FL_GODMODE; ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) & ~FL_GODMODE;
SV_ClientPrintf("godmode OFF\n"); SV_ClientPrintf("godmode OFF\n");
} }
break; break;
@ -542,8 +542,8 @@ void Host_Notarget_f(void)
switch(Cmd_Argc()) switch(Cmd_Argc())
{ {
case 1: case 1:
sv_player->v.flags = (int32_t)sv_player->v.flags ^ FL_NOTARGET; ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) ^ FL_NOTARGET;
if(!((int32_t)sv_player->v.flags & FL_NOTARGET)) if(!((int32_t)ED_FLOAT(sv_player, ED_flags) & FL_NOTARGET))
SV_ClientPrintf("notarget OFF\n"); SV_ClientPrintf("notarget OFF\n");
else else
SV_ClientPrintf("notarget ON\n"); SV_ClientPrintf("notarget ON\n");
@ -551,12 +551,12 @@ void Host_Notarget_f(void)
case 2: case 2:
if(Q_atof(Cmd_Argv(1))) if(Q_atof(Cmd_Argv(1)))
{ {
sv_player->v.flags = (int32_t)sv_player->v.flags | FL_NOTARGET; ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) | FL_NOTARGET;
SV_ClientPrintf("notarget ON\n"); SV_ClientPrintf("notarget ON\n");
} }
else else
{ {
sv_player->v.flags = (int32_t)sv_player->v.flags & ~FL_NOTARGET; ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) & ~FL_NOTARGET;
SV_ClientPrintf("notarget OFF\n"); SV_ClientPrintf("notarget OFF\n");
} }
break; break;
@ -589,16 +589,16 @@ void Host_Noclip_f(void)
switch(Cmd_Argc()) switch(Cmd_Argc())
{ {
case 1: case 1:
if(sv_player->v.movetype != MOVETYPE_NOCLIP) if(ED_FLOAT(sv_player, ED_movetype) != MOVETYPE_NOCLIP)
{ {
noclip_anglehack = true; noclip_anglehack = true;
sv_player->v.movetype = MOVETYPE_NOCLIP; ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_NOCLIP;
SV_ClientPrintf("noclip ON\n"); SV_ClientPrintf("noclip ON\n");
} }
else else
{ {
noclip_anglehack = false; noclip_anglehack = false;
sv_player->v.movetype = MOVETYPE_WALK; ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_WALK;
SV_ClientPrintf("noclip OFF\n"); SV_ClientPrintf("noclip OFF\n");
} }
break; break;
@ -606,13 +606,13 @@ void Host_Noclip_f(void)
if(Q_atof(Cmd_Argv(1))) if(Q_atof(Cmd_Argv(1)))
{ {
noclip_anglehack = true; noclip_anglehack = true;
sv_player->v.movetype = MOVETYPE_NOCLIP; ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_NOCLIP;
SV_ClientPrintf("noclip ON\n"); SV_ClientPrintf("noclip ON\n");
} }
else else
{ {
noclip_anglehack = false; noclip_anglehack = false;
sv_player->v.movetype = MOVETYPE_WALK; ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_WALK;
SV_ClientPrintf("noclip OFF\n"); SV_ClientPrintf("noclip OFF\n");
} }
break; break;
@ -648,37 +648,37 @@ void Host_SetPos_f(void)
SV_ClientPrintf(" setpos <x> <y> <z> <pitch> <yaw> <roll>\n"); SV_ClientPrintf(" setpos <x> <y> <z> <pitch> <yaw> <roll>\n");
SV_ClientPrintf("current values:\n"); SV_ClientPrintf("current values:\n");
SV_ClientPrintf(" %" PRIi32 " %" PRIi32 " %" PRIi32 " %" PRIi32 " %" PRIi32 " %" PRIi32 "\n", SV_ClientPrintf(" %" PRIi32 " %" PRIi32 " %" PRIi32 " %" PRIi32 " %" PRIi32 " %" PRIi32 "\n",
(int32_t)sv_player->v.origin[0], (int32_t)ED_VECTOR(sv_player, ED_origin)[0],
(int32_t)sv_player->v.origin[1], (int32_t)ED_VECTOR(sv_player, ED_origin)[1],
(int32_t)sv_player->v.origin[2], (int32_t)ED_VECTOR(sv_player, ED_origin)[2],
(int32_t)sv_player->v.v_angle[0], (int32_t)ED_VECTOR(sv_player, ED_v_angle)[0],
(int32_t)sv_player->v.v_angle[1], (int32_t)ED_VECTOR(sv_player, ED_v_angle)[1],
(int32_t)sv_player->v.v_angle[2]); (int32_t)ED_VECTOR(sv_player, ED_v_angle)[2]);
return; return;
} }
if(sv_player->v.movetype != MOVETYPE_NOCLIP) if(ED_FLOAT(sv_player, ED_movetype) != MOVETYPE_NOCLIP)
{ {
noclip_anglehack = true; noclip_anglehack = true;
sv_player->v.movetype = MOVETYPE_NOCLIP; ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_NOCLIP;
SV_ClientPrintf("noclip ON\n"); SV_ClientPrintf("noclip ON\n");
} }
//make sure they're not going to whizz away from it //make sure they're not going to whizz away from it
sv_player->v.velocity[0] = 0; ED_VECTOR(sv_player, ED_velocity)[0] = 0;
sv_player->v.velocity[1] = 0; ED_VECTOR(sv_player, ED_velocity)[1] = 0;
sv_player->v.velocity[2] = 0; ED_VECTOR(sv_player, ED_velocity)[2] = 0;
sv_player->v.origin[0] = atof(Cmd_Argv(1)); ED_VECTOR(sv_player, ED_origin)[0] = atof(Cmd_Argv(1));
sv_player->v.origin[1] = atof(Cmd_Argv(2)); ED_VECTOR(sv_player, ED_origin)[1] = atof(Cmd_Argv(2));
sv_player->v.origin[2] = atof(Cmd_Argv(3)); ED_VECTOR(sv_player, ED_origin)[2] = atof(Cmd_Argv(3));
if(Cmd_Argc() == 7) if(Cmd_Argc() == 7)
{ {
sv_player->v.angles[0] = atof(Cmd_Argv(4)); ED_VECTOR(sv_player, ED_angles)[0] = atof(Cmd_Argv(4));
sv_player->v.angles[1] = atof(Cmd_Argv(5)); ED_VECTOR(sv_player, ED_angles)[1] = atof(Cmd_Argv(5));
sv_player->v.angles[2] = atof(Cmd_Argv(6)); ED_VECTOR(sv_player, ED_angles)[2] = atof(Cmd_Argv(6));
sv_player->v.fixangle = 1; ED_FLOAT(sv_player, ED_fixangle) = 1;
} }
SV_LinkEdict(sv_player, false); SV_LinkEdict(sv_player, false);
@ -706,26 +706,26 @@ void Host_Fly_f(void)
switch(Cmd_Argc()) switch(Cmd_Argc())
{ {
case 1: case 1:
if(sv_player->v.movetype != MOVETYPE_FLY) if(ED_FLOAT(sv_player, ED_movetype) != MOVETYPE_FLY)
{ {
sv_player->v.movetype = MOVETYPE_FLY; ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_FLY;
SV_ClientPrintf("flymode ON\n"); SV_ClientPrintf("flymode ON\n");
} }
else else
{ {
sv_player->v.movetype = MOVETYPE_WALK; ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_WALK;
SV_ClientPrintf("flymode OFF\n"); SV_ClientPrintf("flymode OFF\n");
} }
break; break;
case 2: case 2:
if(Q_atof(Cmd_Argv(1))) if(Q_atof(Cmd_Argv(1)))
{ {
sv_player->v.movetype = MOVETYPE_FLY; ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_FLY;
SV_ClientPrintf("flymode ON\n"); SV_ClientPrintf("flymode ON\n");
} }
else else
{ {
sv_player->v.movetype = MOVETYPE_WALK; ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_WALK;
SV_ClientPrintf("flymode OFF\n"); SV_ClientPrintf("flymode OFF\n");
} }
break; break;
@ -1069,7 +1069,7 @@ void Host_Savegame_f(void)
for(i = 0 ; i < svs.maxclients ; i++) for(i = 0 ; i < svs.maxclients ; i++)
{ {
if(svs.clients[i].active && (svs.clients[i].edict->v.health <= 0)) if(svs.clients[i].active && ED_FLOAT(svs.clients[i].edict, ED_health) <= 0)
{ {
Con_Printf("Can't savegame with a dead player\n"); Con_Printf("Can't savegame with a dead player\n");
return; return;
@ -1241,7 +1241,7 @@ void Host_Loadgame_f(void)
if(entnum < sv.num_edicts) if(entnum < sv.num_edicts)
{ {
ent->free = false; ent->free = false;
memset(&ent->v, 0, progs.entityfields * 4); memset(ent->fields, 0, progs.entityfields * 4);
} }
else else
{ {
@ -1311,7 +1311,7 @@ void Host_Name_f(void)
Con_Printf("%s renamed to %s\n", host_client->name, newName); Con_Printf("%s renamed to %s\n", host_client->name, newName);
} }
Q_strcpy(host_client->name, newName); Q_strcpy(host_client->name, newName);
host_client->edict->v.netname = PR_SetEngineString(host_client->name); ED_RSTRING(host_client->edict, ED_netname) = PR_SetEngineString(host_client->name);
// send notification to all clients // send notification to all clients
@ -1386,7 +1386,7 @@ void Host_Say(bool teamonly)
{ {
if(!client || !client->active || !client->spawned) if(!client || !client->active || !client->spawned)
continue; continue;
if(teamplay.value && teamonly && client->edict->v.team != save->edict->v.team) if(teamplay.value && teamonly && ED_FLOAT(client->edict, ED_team) != ED_FLOAT(save->edict, ED_team))
continue; continue;
host_client = client; host_client = client;
SV_ClientPrintf("%s", text); SV_ClientPrintf("%s", text);
@ -1518,7 +1518,7 @@ void Host_Color_f(void)
} }
host_client->colors = playercolor; host_client->colors = playercolor;
host_client->edict->v.team = bottom + 1; ED_FLOAT(host_client->edict, ED_team) = bottom + 1;
// send notification to all clients // send notification to all clients
MSG_WriteByte(&sv.reliable_datagram, svc_updatecolors); MSG_WriteByte(&sv.reliable_datagram, svc_updatecolors);
@ -1539,7 +1539,7 @@ void Host_Kill_f(void)
return; return;
} }
if(sv_player->v.health <= 0) if(ED_FLOAT(sv_player, ED_health) <= 0)
{ {
SV_ClientPrintf("Can't suicide -- allready dead!\n"); SV_ClientPrintf("Can't suicide -- allready dead!\n");
return; return;
@ -1579,11 +1579,11 @@ void Host_Pause_f(void)
if(sv.paused) if(sv.paused)
{ {
SV_BroadcastPrintf("%s paused the game\n", PR_GetString(sv_player->v.netname)); SV_BroadcastPrintf("%s paused the game\n", PR_GetString(ED_RSTRING(sv_player, ED_netname)));
} }
else else
{ {
SV_BroadcastPrintf("%s unpaused the game\n", PR_GetString(sv_player->v.netname)); SV_BroadcastPrintf("%s unpaused the game\n", PR_GetString(ED_RSTRING(sv_player, ED_netname)));
} }
// send notification to all clients // send notification to all clients
@ -1655,10 +1655,10 @@ void Host_Spawn_f(void)
// set up the edict // set up the edict
ent = host_client->edict; ent = host_client->edict;
memset(&ent->v, 0, progs.entityfields * 4); memset(ent->fields, 0, progs.entityfields * 4);
ent->v.colormap = NUM_FOR_EDICT(ent); ED_FLOAT(ent, ED_colormap) = NUM_FOR_EDICT(ent);
ent->v.team = (host_client->colors & 15) + 1; ED_FLOAT(ent, ED_team) = (host_client->colors & 15) + 1;
ent->v.netname = PR_SetEngineString(host_client->name); ED_RSTRING(ent, ED_netname) = PR_SetEngineString(host_client->name);
// copy spawn parms out of the client_t // copy spawn parms out of the client_t
for(i = 0 ; i < NUM_SPAWN_PARMS ; i++) for(i = 0 ; i < NUM_SPAWN_PARMS ; i++)
@ -1731,7 +1731,7 @@ void Host_Spawn_f(void)
ent = EDICT_NUM(1 + (host_client - svs.clients)); ent = EDICT_NUM(1 + (host_client - svs.clients));
MSG_WriteByte(&host_client->message, svc_setangle); MSG_WriteByte(&host_client->message, svc_setangle);
for(i = 0; i < 2; i++) for(i = 0; i < 2; i++)
MSG_WriteAngle(&host_client->message, ent->v.angles[i], sv.protocolflags); MSG_WriteAngle(&host_client->message, ED_VECTOR(ent, ED_angles)[i], sv.protocolflags);
MSG_WriteAngle(&host_client->message, 0, sv.protocolflags); MSG_WriteAngle(&host_client->message, 0, sv.protocolflags);
SV_WriteClientdataToMessage(sv_player, &host_client->message); SV_WriteClientdataToMessage(sv_player, &host_client->message);
@ -1895,21 +1895,21 @@ void Host_Give_f(void)
if(t[0] == '6') if(t[0] == '6')
{ {
if(t[1] == 'a') if(t[1] == 'a')
sv_player->v.items = (int32_t)sv_player->v.items | HIT_PROXIMITY_GUN; ED_FLOAT(sv_player, ED_items) = (int32_t)ED_FLOAT(sv_player, ED_items) | HIT_PROXIMITY_GUN;
else else
sv_player->v.items = (int32_t)sv_player->v.items | IT_GRENADE_LAUNCHER; ED_FLOAT(sv_player, ED_items) = (int32_t)ED_FLOAT(sv_player, ED_items) | IT_GRENADE_LAUNCHER;
} }
else if(t[0] == '9') else if(t[0] == '9')
sv_player->v.items = (int32_t)sv_player->v.items | HIT_LASER_CANNON; ED_FLOAT(sv_player, ED_items) = (int32_t)ED_FLOAT(sv_player, ED_items) | HIT_LASER_CANNON;
else if(t[0] == '0') else if(t[0] == '0')
sv_player->v.items = (int32_t)sv_player->v.items | HIT_MJOLNIR; ED_FLOAT(sv_player, ED_items) = (int32_t)ED_FLOAT(sv_player, ED_items) | HIT_MJOLNIR;
else if(t[0] >= '2') else if(t[0] >= '2')
sv_player->v.items = (int32_t)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2')); ED_FLOAT(sv_player, ED_items) = (int32_t)ED_FLOAT(sv_player, ED_items) | (IT_SHOTGUN << (t[0] - '2'));
} }
else else
{ {
if(t[0] >= '2') if(t[0] >= '2')
sv_player->v.items = (int32_t)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2')); ED_FLOAT(sv_player, ED_items) = (int32_t)ED_FLOAT(sv_player, ED_items) | (IT_SHOTGUN << (t[0] - '2'));
} }
break; break;
@ -1920,7 +1920,7 @@ void Host_Give_f(void)
if(val) if(val)
val->_float = v; val->_float = v;
} }
sv_player->v.ammo_shells = v; ED_FLOAT(sv_player, ED_ammo_shells) = v;
break; break;
case 'n': case 'n':
@ -1930,13 +1930,13 @@ void Host_Give_f(void)
if(val) if(val)
{ {
val->_float = v; val->_float = v;
if(sv_player->v.weapon <= IT_LIGHTNING) if(ED_FLOAT(sv_player, ED_weapon) <= IT_LIGHTNING)
sv_player->v.ammo_nails = v; ED_FLOAT(sv_player, ED_ammo_nails) = v;
} }
} }
else else
{ {
sv_player->v.ammo_nails = v; ED_FLOAT(sv_player, ED_ammo_nails) = v;
} }
break; break;
@ -1947,8 +1947,8 @@ void Host_Give_f(void)
if(val) if(val)
{ {
val->_float = v; val->_float = v;
if(sv_player->v.weapon > IT_LIGHTNING) if(ED_FLOAT(sv_player, ED_weapon) > IT_LIGHTNING)
sv_player->v.ammo_nails = v; ED_FLOAT(sv_player, ED_ammo_nails) = v;
} }
} }
break; break;
@ -1960,13 +1960,13 @@ void Host_Give_f(void)
if(val) if(val)
{ {
val->_float = v; val->_float = v;
if(sv_player->v.weapon <= IT_LIGHTNING) if(ED_FLOAT(sv_player, ED_weapon) <= IT_LIGHTNING)
sv_player->v.ammo_rockets = v; ED_FLOAT(sv_player, ED_ammo_rockets) = v;
} }
} }
else else
{ {
sv_player->v.ammo_rockets = v; ED_FLOAT(sv_player, ED_ammo_rockets) = v;
} }
break; break;
@ -1977,14 +1977,14 @@ void Host_Give_f(void)
if(val) if(val)
{ {
val->_float = v; val->_float = v;
if(sv_player->v.weapon > IT_LIGHTNING) if(ED_FLOAT(sv_player, ED_weapon) > IT_LIGHTNING)
sv_player->v.ammo_rockets = v; ED_FLOAT(sv_player, ED_ammo_rockets) = v;
} }
} }
break; break;
case 'h': case 'h':
sv_player->v.health = v; ED_FLOAT(sv_player, ED_health) = v;
break; break;
case 'c': case 'c':
@ -1994,13 +1994,13 @@ void Host_Give_f(void)
if(val) if(val)
{ {
val->_float = v; val->_float = v;
if(sv_player->v.weapon <= IT_LIGHTNING) if(ED_FLOAT(sv_player, ED_weapon) <= IT_LIGHTNING)
sv_player->v.ammo_cells = v; ED_FLOAT(sv_player, ED_ammo_cells) = v;
} }
} }
else else
{ {
sv_player->v.ammo_cells = v; ED_FLOAT(sv_player, ED_ammo_cells) = v;
} }
break; break;
@ -2011,8 +2011,8 @@ void Host_Give_f(void)
if(val) if(val)
{ {
val->_float = v; val->_float = v;
if(sv_player->v.weapon > IT_LIGHTNING) if(ED_FLOAT(sv_player, ED_weapon) > IT_LIGHTNING)
sv_player->v.ammo_cells = v; ED_FLOAT(sv_player, ED_ammo_cells) = v;
} }
} }
break; break;
@ -2021,26 +2021,26 @@ void Host_Give_f(void)
case 'a': case 'a':
if(v > 150) if(v > 150)
{ {
sv_player->v.armortype = 0.8; ED_FLOAT(sv_player, ED_armortype) = 0.8;
sv_player->v.armorvalue = v; ED_FLOAT(sv_player, ED_armorvalue) = v;
sv_player->v.items = sv_player->v.items - ED_FLOAT(sv_player, ED_items) = ED_FLOAT(sv_player, ED_items) -
((int32_t)(sv_player->v.items) & (int32_t)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + ((int32_t)(ED_FLOAT(sv_player, ED_items)) & (int32_t)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) +
IT_ARMOR3; IT_ARMOR3;
} }
else if(v > 100) else if(v > 100)
{ {
sv_player->v.armortype = 0.6; ED_FLOAT(sv_player, ED_armortype) = 0.6;
sv_player->v.armorvalue = v; ED_FLOAT(sv_player, ED_armorvalue) = v;
sv_player->v.items = sv_player->v.items - ED_FLOAT(sv_player, ED_items) = ED_FLOAT(sv_player, ED_items) -
((int32_t)(sv_player->v.items) & (int32_t)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + ((int32_t)(ED_FLOAT(sv_player, ED_items)) & (int32_t)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) +
IT_ARMOR2; IT_ARMOR2;
} }
else if(v >= 0) else if(v >= 0)
{ {
sv_player->v.armortype = 0.3; ED_FLOAT(sv_player, ED_armortype) = 0.3;
sv_player->v.armorvalue = v; ED_FLOAT(sv_player, ED_armorvalue) = v;
sv_player->v.items = sv_player->v.items - ED_FLOAT(sv_player, ED_items) = ED_FLOAT(sv_player, ED_items) -
((int32_t)(sv_player->v.items) & (int32_t)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + ((int32_t)(ED_FLOAT(sv_player, ED_items)) & (int32_t)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) +
IT_ARMOR1; IT_ARMOR1;
} }
break; break;
@ -2048,37 +2048,37 @@ void Host_Give_f(void)
} }
//johnfitz -- update currentammo to match new ammo (so statusbar updates correctly) //johnfitz -- update currentammo to match new ammo (so statusbar updates correctly)
switch((int32_t)(sv_player->v.weapon)) switch((int32_t)(ED_FLOAT(sv_player, ED_weapon)))
{ {
case IT_SHOTGUN: case IT_SHOTGUN:
case IT_SUPER_SHOTGUN: case IT_SUPER_SHOTGUN:
sv_player->v.currentammo = sv_player->v.ammo_shells; ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_shells);
break; break;
case IT_NAILGUN: case IT_NAILGUN:
case IT_SUPER_NAILGUN: case IT_SUPER_NAILGUN:
case RIT_LAVA_SUPER_NAILGUN: case RIT_LAVA_SUPER_NAILGUN:
sv_player->v.currentammo = sv_player->v.ammo_nails; ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_nails);
break; break;
case IT_GRENADE_LAUNCHER: case IT_GRENADE_LAUNCHER:
case IT_ROCKET_LAUNCHER: case IT_ROCKET_LAUNCHER:
case RIT_MULTI_GRENADE: case RIT_MULTI_GRENADE:
case RIT_MULTI_ROCKET: case RIT_MULTI_ROCKET:
sv_player->v.currentammo = sv_player->v.ammo_rockets; ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_rockets);
break; break;
case IT_LIGHTNING: case IT_LIGHTNING:
case HIT_LASER_CANNON: case HIT_LASER_CANNON:
case HIT_MJOLNIR: case HIT_MJOLNIR:
sv_player->v.currentammo = sv_player->v.ammo_cells; ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_cells);
break; break;
case RIT_LAVA_NAILGUN: //same as IT_AXE case RIT_LAVA_NAILGUN: //same as IT_AXE
if(rogue) if(rogue)
sv_player->v.currentammo = sv_player->v.ammo_nails; ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_nails);
break; break;
case RIT_PLASMA_GUN: //same as HIT_PROXIMITY_GUN case RIT_PLASMA_GUN: //same as HIT_PROXIMITY_GUN
if(rogue) if(rogue)
sv_player->v.currentammo = sv_player->v.ammo_cells; ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_cells);
if(hipnotic) if(hipnotic)
sv_player->v.currentammo = sv_player->v.ammo_rockets; ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_rockets);
break; break;
} }
//johnfitz //johnfitz
@ -2092,7 +2092,7 @@ edict_t *FindViewthing(void)
for(i = 0 ; i < sv.num_edicts ; i++) for(i = 0 ; i < sv.num_edicts ; i++)
{ {
e = EDICT_NUM(i); e = EDICT_NUM(i);
if(!strcmp(PR_GetString(e->v.classname), "viewthing")) if(!strcmp(PR_GetString(ED_RSTRING(e, ED_classname)), "viewthing"))
return e; return e;
} }
Con_Printf("No viewthing on map\n"); Con_Printf("No viewthing on map\n");
@ -2120,8 +2120,8 @@ void Host_Viewmodel_f(void)
return; return;
} }
e->v.frame = 0; ED_FLOAT(e, ED_frame) = 0;
cl.model_precache[(int32_t)e->v.modelindex] = m; cl.model_precache[(int32_t)ED_FLOAT(e, ED_modelindex)] = m;
} }
/* /*
@ -2138,13 +2138,13 @@ void Host_Viewframe_f(void)
e = FindViewthing(); e = FindViewthing();
if(!e) if(!e)
return; return;
m = cl.model_precache[(int32_t)e->v.modelindex]; m = cl.model_precache[(int32_t)ED_FLOAT(e, ED_modelindex)];
f = atoi(Cmd_Argv(1)); f = atoi(Cmd_Argv(1));
if(f >= m->numframes) if(f >= m->numframes)
f = m->numframes - 1; f = m->numframes - 1;
e->v.frame = f; ED_FLOAT(e, ED_frame) = f;
} }
@ -2174,13 +2174,13 @@ void Host_Viewnext_f(void)
e = FindViewthing(); e = FindViewthing();
if(!e) if(!e)
return; return;
m = cl.model_precache[(int32_t)e->v.modelindex]; m = cl.model_precache[(int32_t)ED_FLOAT(e, ED_modelindex)];
e->v.frame = e->v.frame + 1; ED_FLOAT(e, ED_frame) = ED_FLOAT(e, ED_frame) + 1;
if(e->v.frame >= m->numframes) if(ED_FLOAT(e, ED_frame) >= m->numframes)
e->v.frame = m->numframes - 1; ED_FLOAT(e, ED_frame) = m->numframes - 1;
PrintFrameName(m, e->v.frame); PrintFrameName(m, ED_FLOAT(e, ED_frame));
} }
/* /*
@ -2197,13 +2197,13 @@ void Host_Viewprev_f(void)
if(!e) if(!e)
return; return;
m = cl.model_precache[(int32_t)e->v.modelindex]; m = cl.model_precache[(int32_t)ED_FLOAT(e, ED_modelindex)];
e->v.frame = e->v.frame - 1; ED_FLOAT(e, ED_frame) = ED_FLOAT(e, ED_frame) - 1;
if(e->v.frame < 0) if(ED_FLOAT(e, ED_frame) < 0)
e->v.frame = 0; ED_FLOAT(e, ED_frame) = 0;
PrintFrameName(m, e->v.frame); PrintFrameName(m, ED_FLOAT(e, ED_frame));
} }
/* /*

View File

@ -945,7 +945,7 @@ static qsocket_t *_Datagram_CheckNewConnections(void)
MSG_WriteByte(&net_message, playerNumber); MSG_WriteByte(&net_message, playerNumber);
MSG_WriteString(&net_message, client->name); MSG_WriteString(&net_message, client->name);
MSG_WriteLong(&net_message, client->colors); MSG_WriteLong(&net_message, client->colors);
MSG_WriteLong(&net_message, (int32_t)client->edict->v.frags); MSG_WriteLong(&net_message, (int32_t)ED_FLOAT(client->edict, ED_frags));
MSG_WriteLong(&net_message, (int32_t)(net_time - client->netconnection->connecttime)); MSG_WriteLong(&net_message, (int32_t)(net_time - client->netconnection->connecttime));
MSG_WriteString(&net_message, client->netconnection->address); MSG_WriteString(&net_message, client->netconnection->address);
*((int32_t *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK)); *((int32_t *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));

View File

@ -161,7 +161,7 @@ static void PF_setorigin(void)
e = G_EDICT(GBL_PARM0); e = G_EDICT(GBL_PARM0);
org = G_VECTOR(GBL_PARM1); org = G_VECTOR(GBL_PARM1);
VectorCopy(org, e->v.origin); VectorCopy(org, ED_VECTOR(e, ED_origin));
SV_LinkEdict(e, false); SV_LinkEdict(e, false);
} }
@ -190,7 +190,7 @@ static void SetMinMaxSize(edict_t *e, float *minvec, float *maxvec, bool rotate)
else else
{ {
// find min / max for rotations // find min / max for rotations
angles = e->v.angles; angles = ED_VECTOR(e, ED_angles);
a = angles[1] / 180 * PI; a = angles[1] / 180 * PI;
@ -233,9 +233,9 @@ static void SetMinMaxSize(edict_t *e, float *minvec, float *maxvec, bool rotate)
} }
// set derived values // set derived values
VectorCopy(rmin, e->v.mins); VectorCopy(rmin, ED_VECTOR(e, ED_mins));
VectorCopy(rmax, e->v.maxs); VectorCopy(rmax, ED_VECTOR(e, ED_maxs));
VectorSubtract(maxvec, minvec, e->v.size); VectorSubtract(maxvec, minvec, ED_VECTOR(e, ED_size));
SV_LinkEdict(e, false); SV_LinkEdict(e, false);
} }
@ -289,10 +289,10 @@ static void PF_setmodel(void)
{ {
PR_RunError("no precache: %s", m); PR_RunError("no precache: %s", m);
} }
e->v.model = PR_SetEngineString(*check); ED_RSTRING(e, ED_model) = PR_SetEngineString(*check);
e->v.modelindex = i; //SV_ModelIndex (m); ED_FLOAT(e, ED_modelindex) = i; //SV_ModelIndex (m);
mod = sv.models[(int32_t)e->v.modelindex]; // Mod_ForName (m, true); mod = sv.models[(int32_t)ED_FLOAT(e, ED_modelindex)]; // Mod_ForName (m, true);
if(mod) if(mod)
//johnfitz -- correct physics cullboxes for bmodels //johnfitz -- correct physics cullboxes for bmodels
@ -757,9 +757,9 @@ static int32_t PF_newcheckclient(int32_t check)
if(ent->free) if(ent->free)
continue; continue;
if(ent->v.health <= 0) if(ED_FLOAT(ent, ED_health) <= 0)
continue; continue;
if((int32_t)ent->v.flags & FL_NOTARGET) if((int32_t)ED_FLOAT(ent, ED_flags) & FL_NOTARGET)
continue; continue;
// anything that is a client, or has a client as an enemy // anything that is a client, or has a client as an enemy
@ -767,7 +767,7 @@ static int32_t PF_newcheckclient(int32_t check)
} }
// get the PVS for the entity // get the PVS for the entity
VectorAdd(ent->v.origin, ent->v.view_ofs, org); VectorAdd(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_view_ofs), org);
leaf = Mod_PointInLeaf(org, sv.worldmodel); leaf = Mod_PointInLeaf(org, sv.worldmodel);
pvs = Mod_LeafPVS(leaf, sv.worldmodel); pvs = Mod_LeafPVS(leaf, sv.worldmodel);
@ -817,7 +817,7 @@ static void PF_checkclient(void)
// return check if it might be visible // return check if it might be visible
ent = EDICT_NUM(sv.lastcheck); ent = EDICT_NUM(sv.lastcheck);
if(ent->free || ent->v.health <= 0) if(ent->free || ED_FLOAT(ent, ED_health) <= 0)
{ {
RETURN_EDICT(sv.edicts); RETURN_EDICT(sv.edicts);
return; return;
@ -825,7 +825,7 @@ static void PF_checkclient(void)
// if current entity can't possibly see the check entity, return 0 // if current entity can't possibly see the check entity, return 0
self = PROG_TO_EDICT(G_INT(GBL_self)); self = PROG_TO_EDICT(G_INT(GBL_self));
VectorAdd(self->v.origin, self->v.view_ofs, view); VectorAdd(ED_VECTOR(self, ED_origin), ED_VECTOR(self, ED_view_ofs), view);
leaf = Mod_PointInLeaf(view, sv.worldmodel); leaf = Mod_PointInLeaf(view, sv.worldmodel);
l = (leaf - sv.worldmodel->leafs) - 1; l = (leaf - sv.worldmodel->leafs) - 1;
if((l < 0) || !(checkpvs[l >> 3] & (1 << (l & 7)))) if((l < 0) || !(checkpvs[l >> 3] & (1 << (l & 7))))
@ -946,14 +946,14 @@ static void PF_findradius(void)
{ {
if(ent->free) if(ent->free)
continue; continue;
if(ent->v.solid == SOLID_NOT) if(ED_FLOAT(ent, ED_solid) == SOLID_NOT)
continue; continue;
for(j = 0; j < 3; j++) for(j = 0; j < 3; j++)
eorg[j] = org[j] - (ent->v.origin[j] + (ent->v.mins[j] + ent->v.maxs[j]) * 0.5); eorg[j] = org[j] - (ED_VECTOR(ent, ED_origin)[j] + (ED_VECTOR(ent, ED_mins)[j] + ED_VECTOR(ent, ED_maxs)[j]) * 0.5);
if(VectorLength(eorg) > rad) if(VectorLength(eorg) > rad)
continue; continue;
ent->v.chain = EDICT_TO_PROG(chain); ED_INT(ent, ED_chain) = EDICT_TO_PROG(chain);
chain = ent; chain = ent;
} }
@ -1037,7 +1037,7 @@ static void PF_find(void)
ed = EDICT_NUM(e); ed = EDICT_NUM(e);
if(ed->free) if(ed->free)
continue; continue;
t = PR_GetString(((string_t *)&ed->v)[f]); t = PR_GetString(ED_RSTRING(ed, f));
if(!t) if(!t)
continue; continue;
if(!strcmp(t, s)) if(!strcmp(t, s))
@ -1153,7 +1153,7 @@ static void PF_walkmove(void)
yaw = G_FLOAT(GBL_PARM0); yaw = G_FLOAT(GBL_PARM0);
dist = G_FLOAT(GBL_PARM1); dist = G_FLOAT(GBL_PARM1);
if(!((int32_t)ent->v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) if(!((int32_t)ED_FLOAT(ent, ED_flags) & (FL_ONGROUND | FL_FLY | FL_SWIM)))
{ {
G_FLOAT(GBL_RETURN) = 0; G_FLOAT(GBL_RETURN) = 0;
return; return;
@ -1192,19 +1192,19 @@ static void PF_droptofloor(void)
ent = PROG_TO_EDICT(G_INT(GBL_self)); ent = PROG_TO_EDICT(G_INT(GBL_self));
VectorCopy(ent->v.origin, end); VectorCopy(ED_VECTOR(ent, ED_origin), end);
end[2] -= 256; end[2] -= 256;
trace = SV_Move(ent->v.origin, ent->v.mins, ent->v.maxs, end, false, ent); trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, false, ent);
if(trace.fraction == 1 || trace.allsolid) if(trace.fraction == 1 || trace.allsolid)
G_FLOAT(GBL_RETURN) = 0; G_FLOAT(GBL_RETURN) = 0;
else else
{ {
VectorCopy(trace.endpos, ent->v.origin); VectorCopy(trace.endpos, ED_VECTOR(ent, ED_origin));
SV_LinkEdict(ent, false); SV_LinkEdict(ent, false);
ent->v.flags = (int32_t)ent->v.flags | FL_ONGROUND; ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) | FL_ONGROUND;
ent->v.groundentity = EDICT_TO_PROG(trace.ent); ED_INT(ent, ED_groundentity) = EDICT_TO_PROG(trace.ent);
G_FLOAT(GBL_RETURN) = 1; G_FLOAT(GBL_RETURN) = 1;
} }
} }
@ -1352,15 +1352,14 @@ static void PF_aim(void)
speed = G_FLOAT(GBL_PARM1); speed = G_FLOAT(GBL_PARM1);
(void) speed; /* variable set but not used */ (void) speed; /* variable set but not used */
VectorCopy(ent->v.origin, start); VectorCopy(ED_VECTOR(ent, ED_origin), start);
start[2] += 20; start[2] += 20;
// try sending a trace straight // try sending a trace straight
VectorCopy(G_VECTOR(GBL_v_forward), dir); VectorCopy(G_VECTOR(GBL_v_forward), dir);
VectorMA(start, 2048, dir, end); VectorMA(start, 2048, dir, end);
tr = SV_Move(start, vec3_origin, vec3_origin, end, false, ent); tr = SV_Move(start, vec3_origin, vec3_origin, end, false, ent);
if(tr.ent && tr.ent->v.takedamage == DAMAGE_AIM if(tr.ent && ED_FLOAT(tr.ent, ED_takedamage) == DAMAGE_AIM && (!teamplay.value || ED_FLOAT(ent, ED_team) <= 0 || ED_FLOAT(ent, ED_team) != ED_FLOAT(tr.ent, ED_team)))
&& (!teamplay.value || ent->v.team <= 0 || ent->v.team != tr.ent->v.team))
{ {
VectorCopy(G_VECTOR(GBL_v_forward), G_VECTOR(GBL_RETURN)); VectorCopy(G_VECTOR(GBL_v_forward), G_VECTOR(GBL_RETURN));
return; return;
@ -1374,14 +1373,14 @@ static void PF_aim(void)
check = NEXT_EDICT(sv.edicts); check = NEXT_EDICT(sv.edicts);
for(i = 1; i < sv.num_edicts; i++, check = NEXT_EDICT(check)) for(i = 1; i < sv.num_edicts; i++, check = NEXT_EDICT(check))
{ {
if(check->v.takedamage != DAMAGE_AIM) if(ED_FLOAT(check, ED_takedamage) != DAMAGE_AIM)
continue; continue;
if(check == ent) if(check == ent)
continue; continue;
if(teamplay.value && ent->v.team > 0 && ent->v.team == check->v.team) if(teamplay.value && ED_FLOAT(ent, ED_team) > 0 && ED_FLOAT(ent, ED_team) == ED_FLOAT(check, ED_team))
continue; // don't aim at teammate continue; // don't aim at teammate
for(j = 0; j < 3; j++) for(j = 0; j < 3; j++)
end[j] = check->v.origin[j] + 0.5 * (check->v.mins[j] + check->v.maxs[j]); end[j] = ED_VECTOR(check, ED_origin)[j] + 0.5 * (ED_VECTOR(check, ED_mins)[j] + ED_VECTOR(check, ED_maxs)[j]);
VectorSubtract(end, start, dir); VectorSubtract(end, start, dir);
VectorNormalize(dir); VectorNormalize(dir);
dist = DotProduct(dir, G_VECTOR(GBL_v_forward)); dist = DotProduct(dir, G_VECTOR(GBL_v_forward));
@ -1398,7 +1397,7 @@ static void PF_aim(void)
if(bestent) if(bestent)
{ {
VectorSubtract(bestent->v.origin, ent->v.origin, dir); VectorSubtract(ED_VECTOR(bestent, ED_origin), ED_VECTOR(ent, ED_origin), dir);
dist = DotProduct(dir, G_VECTOR(GBL_v_forward)); dist = DotProduct(dir, G_VECTOR(GBL_v_forward));
VectorScale(G_VECTOR(GBL_v_forward), dist, end); VectorScale(G_VECTOR(GBL_v_forward), dist, end);
end[2] = dir[2]; end[2] = dir[2];
@ -1424,9 +1423,9 @@ void PF_changeyaw(void)
float ideal, current, move, speed; float ideal, current, move, speed;
ent = PROG_TO_EDICT(G_INT(GBL_self)); ent = PROG_TO_EDICT(G_INT(GBL_self));
current = anglemod(ent->v.angles[1]); current = anglemod(ED_VECTOR(ent, ED_angles)[1]);
ideal = ent->v.ideal_yaw; ideal = ED_FLOAT(ent, ED_ideal_yaw);
speed = ent->v.yaw_speed; speed = ED_FLOAT(ent, ED_yaw_speed);
if(current == ideal) if(current == ideal)
return; return;
@ -1452,7 +1451,7 @@ void PF_changeyaw(void)
move = -speed; move = -speed;
} }
ent->v.angles[1] = anglemod(current + move); ED_VECTOR(ent, ED_angles)[1] = anglemod(current + move);
} }
/* /*
@ -1557,7 +1556,7 @@ static void PF_makestatic(void)
//johnfitz -- PROTOCOL_FITZQUAKE //johnfitz -- PROTOCOL_FITZQUAKE
if(sv.protocol == PROTOCOL_NETQUAKE) if(sv.protocol == PROTOCOL_NETQUAKE)
{ {
if(SV_ModelIndex(PR_GetString(ent->v.model)) & 0xFF00 || (int32_t)(ent->v.frame) & 0xFF00) if(SV_ModelIndex(PR_GetString(ED_RSTRING(ent, ED_model))) & 0xFF00 || (int32_t)(ED_FLOAT(ent, ED_frame)) & 0xFF00)
{ {
ED_Free(ent); ED_Free(ent);
return; //can't display the correct model & frame, so don't show it at all return; //can't display the correct model & frame, so don't show it at all
@ -1565,9 +1564,9 @@ static void PF_makestatic(void)
} }
else else
{ {
if(SV_ModelIndex(PR_GetString(ent->v.model)) & 0xFF00) if(SV_ModelIndex(PR_GetString(ED_RSTRING(ent, ED_model))) & 0xFF00)
bits |= B_LARGEMODEL; bits |= B_LARGEMODEL;
if((int32_t)(ent->v.frame) & 0xFF00) if((int32_t)(ED_FLOAT(ent, ED_frame)) & 0xFF00)
bits |= B_LARGEFRAME; bits |= B_LARGEFRAME;
if(ent->alpha != ENTALPHA_DEFAULT) if(ent->alpha != ENTALPHA_DEFAULT)
bits |= B_ALPHA; bits |= B_ALPHA;
@ -1582,22 +1581,22 @@ static void PF_makestatic(void)
MSG_WriteByte(&sv.signon, svc_spawnstatic); MSG_WriteByte(&sv.signon, svc_spawnstatic);
if(bits & B_LARGEMODEL) if(bits & B_LARGEMODEL)
MSG_WriteShort(&sv.signon, SV_ModelIndex(PR_GetString(ent->v.model))); MSG_WriteShort(&sv.signon, SV_ModelIndex(PR_GetString(ED_RSTRING(ent, ED_model))));
else else
MSG_WriteByte(&sv.signon, SV_ModelIndex(PR_GetString(ent->v.model))); MSG_WriteByte(&sv.signon, SV_ModelIndex(PR_GetString(ED_RSTRING(ent, ED_model))));
if(bits & B_LARGEFRAME) if(bits & B_LARGEFRAME)
MSG_WriteShort(&sv.signon, ent->v.frame); MSG_WriteShort(&sv.signon, ED_FLOAT(ent, ED_frame));
else else
MSG_WriteByte(&sv.signon, ent->v.frame); MSG_WriteByte(&sv.signon, ED_FLOAT(ent, ED_frame));
//johnfitz //johnfitz
MSG_WriteByte(&sv.signon, ent->v.colormap); MSG_WriteByte(&sv.signon, ED_FLOAT(ent, ED_colormap));
MSG_WriteByte(&sv.signon, ent->v.skin); MSG_WriteByte(&sv.signon, ED_FLOAT(ent, ED_skin));
for(i = 0; i < 3; i++) for(i = 0; i < 3; i++)
{ {
MSG_WriteCoord(&sv.signon, ent->v.origin[i], sv.protocolflags); MSG_WriteCoord(&sv.signon, ED_VECTOR(ent, ED_origin)[i], sv.protocolflags);
MSG_WriteAngle(&sv.signon, ent->v.angles[i], sv.protocolflags); MSG_WriteAngle(&sv.signon, ED_VECTOR(ent, ED_angles)[i], sv.protocolflags);
} }
//johnfitz -- PROTOCOL_FITZQUAKE //johnfitz -- PROTOCOL_FITZQUAKE

View File

@ -91,6 +91,87 @@ enum
GBL_SYSTEM_END, GBL_SYSTEM_END,
}; };
enum
{
ED_modelindex,
ED_absmin,
ED_absmax = ED_absmin + 3,
ED_ltime = ED_absmax + 3,
ED_movetype,
ED_solid,
ED_origin,
ED_oldorigin = ED_origin + 3,
ED_velocity = ED_oldorigin + 3,
ED_angles = ED_velocity + 3,
ED_avelocity = ED_angles + 3,
ED_punchangle = ED_avelocity + 3,
ED_classname = ED_punchangle + 3,
ED_model,
ED_frame,
ED_skin,
ED_effects,
ED_mins,
ED_maxs = ED_mins + 3,
ED_size = ED_maxs + 3,
ED_touch = ED_size + 3,
ED_use,
ED_think,
ED_blocked,
ED_nextthink,
ED_groundentity,
ED_health,
ED_frags,
ED_weapon,
ED_weaponmodel,
ED_weaponframe,
ED_currentammo,
ED_ammo_shells,
ED_ammo_nails,
ED_ammo_rockets,
ED_ammo_cells,
ED_items,
ED_takedamage,
ED_chain,
ED_deadflag,
ED_view_ofs,
ED_button0 = ED_view_ofs + 3,
ED_button1,
ED_button2,
ED_impulse,
ED_fixangle,
ED_v_angle,
ED_idealpitch = ED_v_angle + 3,
ED_netname,
ED_enemy,
ED_flags,
ED_colormap,
ED_team,
ED_max_health,
ED_teleport_time,
ED_armortype,
ED_armorvalue,
ED_waterlevel,
ED_watertype,
ED_ideal_yaw,
ED_yaw_speed,
ED_aiment,
ED_goalentity,
ED_spawnflags,
ED_target,
ED_targetname,
ED_dmg_take,
ED_dmg_save,
ED_dmg_inflictor,
ED_owner,
ED_movedir,
ED_message = ED_movedir + 3,
ED_sounds,
ED_noise,
ED_noise1,
ED_noise2,
ED_noise3,
};
#define DEF_SAVEGLOBAL (1 << 15) #define DEF_SAVEGLOBAL (1 << 15)
#define PROG_VERSION 6 #define PROG_VERSION 6

View File

@ -71,7 +71,7 @@ Sets everything to NULL
*/ */
void ED_ClearEdict(edict_t *e) void ED_ClearEdict(edict_t *e)
{ {
memset(&e->v, 0, progs.entityfields * 4); memset(e->fields, 0, progs.entityfields * 4);
e->free = false; e->free = false;
} }
@ -126,16 +126,16 @@ void ED_Free(edict_t *ed)
SV_UnlinkEdict(ed); // unlink from world bsp SV_UnlinkEdict(ed); // unlink from world bsp
ed->free = true; ed->free = true;
ed->v.model = 0; ED_RSTRING(ed, ED_model) = 0;
ed->v.takedamage = 0; ED_FLOAT(ed, ED_takedamage) = 0;
ed->v.modelindex = 0; ED_FLOAT(ed, ED_modelindex) = 0;
ed->v.colormap = 0; ED_FLOAT(ed, ED_colormap) = 0;
ed->v.skin = 0; ED_FLOAT(ed, ED_skin) = 0;
ed->v.frame = 0; ED_FLOAT(ed, ED_frame) = 0;
VectorCopy(vec3_origin, ed->v.origin); VectorCopy(vec3_origin, ED_VECTOR(ed, ED_origin));
VectorCopy(vec3_origin, ed->v.angles); VectorCopy(vec3_origin, ED_VECTOR(ed, ED_angles));
ed->v.nextthink = -1; ED_FLOAT(ed, ED_nextthink) = -1;
ed->v.solid = 0; ED_FLOAT(ed, ED_solid) = 0;
ed->alpha = ENTALPHA_DEFAULT; //johnfitz -- reset alpha for next entity ed->alpha = ENTALPHA_DEFAULT; //johnfitz -- reset alpha for next entity
ed->freetime = sv.time; ed->freetime = sv.time;
@ -273,7 +273,7 @@ Done:
if(!def) if(!def)
return NULL; return NULL;
return (eval_t *)((char *)&ed->v + def->ofs * 4); return ED_EVAL(ed, def->ofs);
} }
@ -307,7 +307,7 @@ void ED_Print(edict_t *ed)
if(l > 1 && name[l - 2] == '_') if(l > 1 && name[l - 2] == '_')
continue; // skip _x, _y, _z vars continue; // skip _x, _y, _z vars
v = (int32_t *)((char *)&ed->v + d->ofs * 4); v = &ED_INT(ed, d->ofs);
// if the value is still all 0, skip the field // if the value is still all 0, skip the field
type = d->type & ~DEF_SAVEGLOBAL; type = d->type & ~DEF_SAVEGLOBAL;
@ -359,7 +359,7 @@ void ED_Write(FILE *f, edict_t *ed)
if(j > 1 && name[j - 2] == '_') if(j > 1 && name[j - 2] == '_')
continue; // skip _x, _y, _z vars continue; // skip _x, _y, _z vars
v = (int32_t *)((char *)&ed->v + d->ofs * 4); v = &ED_INT(ed, d->ofs);
// if the value is still all 0, skip the field // if the value is still all 0, skip the field
type = d->type & ~DEF_SAVEGLOBAL; type = d->type & ~DEF_SAVEGLOBAL;
@ -452,11 +452,11 @@ static void ED_Count(void)
if(ent->free) if(ent->free)
continue; continue;
active++; active++;
if(ent->v.solid) if(ED_FLOAT(ent, ED_solid))
solid++; solid++;
if(ent->v.model) if(ED_RSTRING(ent, ED_model))
models++; models++;
if(ent->v.movetype == MOVETYPE_STEP) if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_STEP)
step++; step++;
} }
@ -692,7 +692,7 @@ const char *ED_ParseEdict(const char *data, edict_t *ent)
// clear it // clear it
if(ent != sv.edicts) // hack if(ent != sv.edicts) // hack
memset(&ent->v, 0, progs.entityfields * 4); memset(ent->fields, 0, progs.entityfields * 4);
// go through all the dictionary pairs // go through all the dictionary pairs
while(1) while(1)
@ -764,7 +764,7 @@ const char *ED_ParseEdict(const char *data, edict_t *ent)
sprintf(com_token, "0 %s 0", temp); sprintf(com_token, "0 %s 0", temp);
} }
if(!ED_ParseEpair(&ent->v, key, com_token)) if(!ED_ParseEpair(ent->fields, key, com_token))
Host_Error("ED_ParseEdict: parse error"); Host_Error("ED_ParseEdict: parse error");
} }
@ -817,16 +817,16 @@ void ED_LoadFromFile(const char *data)
// remove things from different skill levels or deathmatch // remove things from different skill levels or deathmatch
if(deathmatch.value) if(deathmatch.value)
{ {
if(((int32_t)ent->v.spawnflags & SPAWNFLAG_NOT_DEATHMATCH)) if(((int32_t)ED_FLOAT(ent, ED_spawnflags) & SPAWNFLAG_NOT_DEATHMATCH))
{ {
ED_Free(ent); ED_Free(ent);
inhibit++; inhibit++;
continue; continue;
} }
} }
else if((current_skill == 0 && ((int32_t)ent->v.spawnflags & SPAWNFLAG_NOT_EASY)) else if((current_skill == 0 && ((int32_t)ED_FLOAT(ent, ED_spawnflags) & SPAWNFLAG_NOT_EASY))
|| (current_skill == 1 && ((int32_t)ent->v.spawnflags & SPAWNFLAG_NOT_MEDIUM)) || (current_skill == 1 && ((int32_t)ED_FLOAT(ent, ED_spawnflags) & SPAWNFLAG_NOT_MEDIUM))
|| (current_skill >= 2 && ((int32_t)ent->v.spawnflags & SPAWNFLAG_NOT_HARD))) || (current_skill >= 2 && ((int32_t)ED_FLOAT(ent, ED_spawnflags) & SPAWNFLAG_NOT_HARD)))
{ {
ED_Free(ent); ED_Free(ent);
inhibit++; inhibit++;
@ -836,7 +836,7 @@ void ED_LoadFromFile(const char *data)
// //
// immediately call spawn function // immediately call spawn function
// //
if(!ent->v.classname) if(!ED_RSTRING(ent, ED_classname))
{ {
Con_SafePrintf("No classname for:\n"); //johnfitz -- was Con_Printf Con_SafePrintf("No classname for:\n"); //johnfitz -- was Con_Printf
ED_Print(ent); ED_Print(ent);
@ -845,7 +845,7 @@ void ED_LoadFromFile(const char *data)
} }
// look for the spawn function // look for the spawn function
func = ED_FindFunction(PR_GetString(ent->v.classname)); func = ED_FindFunction(PR_GetString(ED_RSTRING(ent, ED_classname)));
if(!func) if(!func)
{ {

View File

@ -542,7 +542,7 @@ void PR_ExecuteProgram(func_t fnum)
pr_xstatement = st - pr_statements; pr_xstatement = st - pr_statements;
PR_RunError("assignment to world entity"); PR_RunError("assignment to world entity");
} }
OPC->_int = (byte *)((int32_t *)&ed->v + OPB->_int) - (byte *)sv.edicts; OPC->_int = (byte *)&ED_INT(ed, OPB->_int) - (byte *)sv.edicts;
break; break;
case OP_LOAD_F: case OP_LOAD_F:
@ -554,7 +554,7 @@ void PR_ExecuteProgram(func_t fnum)
#if defined(PARANOID) #if defined(PARANOID)
NUM_FOR_EDICT(ed); // Make sure it's in range NUM_FOR_EDICT(ed); // Make sure it's in range
#endif #endif
OPC->_int = ((eval_t *)((int32_t *)&ed->v + OPB->_int))->_int; OPC->_int = ED_EVAL(ed, OPB->_int)->_int;
break; break;
case OP_LOAD_V: case OP_LOAD_V:
@ -562,7 +562,7 @@ void PR_ExecuteProgram(func_t fnum)
#if defined(PARANOID) #if defined(PARANOID)
NUM_FOR_EDICT(ed); // Make sure it's in range NUM_FOR_EDICT(ed); // Make sure it's in range
#endif #endif
ptr = (eval_t *)((int32_t *)&ed->v + OPB->_int); ptr = ED_EVAL(ed, OPB->_int);
OPC->vector[0] = ptr->vector[0]; OPC->vector[0] = ptr->vector[0];
OPC->vector[1] = ptr->vector[1]; OPC->vector[1] = ptr->vector[1];
OPC->vector[2] = ptr->vector[2]; OPC->vector[2] = ptr->vector[2];
@ -619,9 +619,9 @@ void PR_ExecuteProgram(func_t fnum)
case OP_STATE: case OP_STATE:
ed = PROG_TO_EDICT(G_INT(GBL_self)); ed = PROG_TO_EDICT(G_INT(GBL_self));
ed->v.nextthink = G_FLOAT(GBL_time) + 0.1; ED_FLOAT(ed, ED_nextthink) = G_FLOAT(GBL_time) + 0.1;
ed->v.frame = OPA->_float; ED_FLOAT(ed, ED_frame) = OPA->_float;
ed->v.think = OPB->function; ED_FUNC(ed, ED_think) = OPB->function;
break; break;
default: default:

View File

@ -65,7 +65,7 @@ static void PR_LoadProgHeader(byte const *data)
/* round off to next highest whole word address (esp for Alpha) this ensures /* round off to next highest whole word address (esp for Alpha) this ensures
* that pointers in the engine data area are always properly aligned * that pointers in the engine data area are always properly aligned
*/ */
pr_edict_size = progs.entityfields * 4 + sizeof(edict_t) - sizeof(entvars_t); pr_edict_size = progs.entityfields * 4 + sizeof(edict_t);
pr_edict_size += sizeof(void *) - 1; pr_edict_size += sizeof(void *) - 1;
pr_edict_size &= ~(sizeof(void *) - 1); pr_edict_size &= ~(sizeof(void *) - 1);
@ -73,7 +73,7 @@ static void PR_LoadProgHeader(byte const *data)
Host_Error("PR_LoadProgHeader: has wrong version number (%" PRIi32 " should be %" PRIi32 ")", progs.version, PROG_VERSION); Host_Error("PR_LoadProgHeader: has wrong version number (%" PRIi32 " should be %" PRIi32 ")", progs.version, PROG_VERSION);
if(progs.crc != PROGHEADER_CRC) if(progs.crc != PROGHEADER_CRC)
Host_Error("PR_LoadProgHeader: system vars have been modified, progdefs.h is out of date"); Host_Error("PR_LoadProgHeader: system vars are modified\n");
if(progs.ofs_strings + progs.numstrings >= com_filesize) if(progs.ofs_strings + progs.numstrings >= com_filesize)
Host_Error("PR_LoadProgHeader: strings go past end of file\n"); Host_Error("PR_LoadProgHeader: strings go past end of file\n");

View File

@ -1,108 +0,0 @@
/*
Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2002-2009 John Fitzgibbons and others
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef spingle__progdefs_h
#define spingle__progdefs_h
typedef struct
{
float modelindex;
vec3_t absmin;
vec3_t absmax;
float ltime;
float movetype;
float solid;
vec3_t origin;
vec3_t oldorigin;
vec3_t velocity;
vec3_t angles;
vec3_t avelocity;
vec3_t punchangle;
string_t classname;
string_t model;
float frame;
float skin;
float effects;
vec3_t mins;
vec3_t maxs;
vec3_t size;
func_t touch;
func_t use;
func_t think;
func_t blocked;
float nextthink;
int32_t groundentity;
float health;
float frags;
float weapon;
string_t weaponmodel;
float weaponframe;
float currentammo;
float ammo_shells;
float ammo_nails;
float ammo_rockets;
float ammo_cells;
float items;
float takedamage;
int32_t chain;
float deadflag;
vec3_t view_ofs;
float button0;
float button1;
float button2;
float impulse;
float fixangle;
vec3_t v_angle;
float idealpitch;
string_t netname;
int32_t enemy;
float flags;
float colormap;
float team;
float max_health;
float teleport_time;
float armortype;
float armorvalue;
float waterlevel;
float watertype;
float ideal_yaw;
float yaw_speed;
int32_t aiment;
int32_t goalentity;
float spawnflags;
string_t target;
string_t targetname;
float dmg_take;
float dmg_save;
int32_t dmg_inflictor;
int32_t owner;
vec3_t movedir;
string_t message;
float sounds;
string_t noise;
string_t noise1;
string_t noise2;
string_t noise3;
} entvars_t;
#define PROGHEADER_CRC 5927
#endif

View File

@ -24,7 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define spingle__progs_h #define spingle__progs_h
#include "pr_comp.h" /* defs shared with qcc */ #include "pr_comp.h" /* defs shared with qcc */
#include "progdefs.h" /* generated by program cdefs */
#define PROGHEADER_CRC 5927
typedef union eval_s typedef union eval_s
{ {
@ -46,16 +47,23 @@ typedef struct edict_s
int32_t leafnums[MAX_ENT_LEAFS]; int32_t leafnums[MAX_ENT_LEAFS];
entity_state_t baseline; entity_state_t baseline;
uint8_t alpha; /* johnfitz -- hack to support alpha since it's not part of entvars_t */ uint8_t alpha;
bool sendinterval; /* johnfitz -- send time until nextthink to client for better lerp timing */ bool sendinterval; /* johnfitz -- send time until nextthink to client for better lerp timing */
float freetime; /* sv.time when the object was freed */ float freetime; /* sv.time when the object was freed */
entvars_t v; /* C exported fields from progs */
byte fields[]; byte fields[];
} edict_t; } edict_t;
#define EDICT_FROM_AREA(l) (edict_t *)((byte *)(l) - offsetof(edict_t, area)) #define EDICT_FROM_AREA(l) (edict_t *)((byte *)(l) - offsetof(edict_t, area))
#define ED_VARS(e) ((entvars_t *)e->fields)
#define ED_FLOAT(e, o) (((float *)e->fields)[o])
#define ED_INT(e, o) (((int32_t *)e->fields)[o])
#define ED_VECTOR(e, o) (&ED_FLOAT(e, o))
#define ED_EVAL(e, o) ((eval_t *)&ED_FLOAT(e, o))
#define ED_RSTRING(e, o) (*(string_t *)&ED_INT(e, o))
#define ED_FUNC(e, o) (*(func_t *)&ED_INT(e, o))
//============================================================================ //============================================================================
@ -120,8 +128,9 @@ int32_t NUM_FOR_EDICT(edict_t *e);
#define G_EDICT(o) ((edict_t *)(&((byte *)sv.edicts)[G_INT(o)])) #define G_EDICT(o) ((edict_t *)(&((byte *)sv.edicts)[G_INT(o)]))
#define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o)) #define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
#define G_VECTOR(o) (&G_FLOAT(o)) #define G_VECTOR(o) (&G_FLOAT(o))
#define G_STRING(o) (PR_GetString((string_t)G_INT(o))) #define G_STRING(o) (PR_GetString(G_RSTRING(o)))
#define G_FUNC(o) ((func_t)G_INT(o)) #define G_RSTRING(o) (*(string_t *)&G_INT(o))
#define G_FUNC(o) (*(func_t *)&G_INT(o))
#define G_EVAL(o) ((eval_t *)&G_FLOAT(o)) #define G_EVAL(o) ((eval_t *)&G_FLOAT(o))
#define G_VOID(o) ((void *)&G_FLOAT(o)) #define G_VOID(o) ((void *)&G_FLOAT(o))

View File

@ -60,7 +60,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define U_ALPHA (1<<16) // 1 byte, uses ENTALPHA_ENCODE, not sent if equal to baseline #define U_ALPHA (1<<16) // 1 byte, uses ENTALPHA_ENCODE, not sent if equal to baseline
#define U_FRAME2 (1<<17) // 1 byte, this is .frame & 0xFF00 (second byte) #define U_FRAME2 (1<<17) // 1 byte, this is .frame & 0xFF00 (second byte)
#define U_MODEL2 (1<<18) // 1 byte, this is .modelindex & 0xFF00 (second byte) #define U_MODEL2 (1<<18) // 1 byte, this is .modelindex & 0xFF00 (second byte)
#define U_LERPFINISH (1<<19) // 1 byte, 0.0-1.0 maps to 0-255, not sent if exactly 0.1, this is ent->v.nextthink - sv.time, used for lerping #define U_LERPFINISH (1<<19) // 1 byte, 0.0-1.0 maps to 0-255, not sent if exactly 0.1, this is ED_FLOAT(ent, ED_nextthink) - sv.time, used for lerping
#define U_SCALE (1<<20) // 1 byte, for PROTOCOL_RMQ PRFL_EDICTSCALE, currently read but ignored #define U_SCALE (1<<20) // 1 byte, for PROTOCOL_RMQ PRFL_EDICTSCALE, currently read but ignored
#define U_UNUSED21 (1<<21) #define U_UNUSED21 (1<<21)
#define U_UNUSED22 (1<<22) #define U_UNUSED22 (1<<22)

View File

@ -261,7 +261,7 @@ void SV_StartSound(edict_t *entity, int32_t channel, const char *sample, int32_t
//johnfitz //johnfitz
for(i = 0; i < 3; i++) for(i = 0; i < 3; i++)
MSG_WriteCoord(&sv.datagram, entity->v.origin[i] + 0.5 * (entity->v.mins[i] + entity->v.maxs[i]), sv.protocolflags); MSG_WriteCoord(&sv.datagram, ED_VECTOR(entity, ED_origin)[i] + 0.5 * (ED_VECTOR(entity, ED_mins)[i] + ED_VECTOR(entity, ED_maxs)[i]), sv.protocolflags);
} }
/* /*
@ -306,7 +306,7 @@ void SV_SendServerinfo(client_t *client)
else else
MSG_WriteByte(&client->message, GAME_COOP); MSG_WriteByte(&client->message, GAME_COOP);
MSG_WriteString(&client->message, PR_GetString(sv.edicts->v.message)); MSG_WriteString(&client->message, PR_GetString(ED_RSTRING(sv.edicts, ED_message)));
//johnfitz -- only send the first 256 model and sound precaches if protocol is 15 //johnfitz -- only send the first 256 model and sound precaches if protocol is 15
for(i = 0, s = sv.model_precache + 1 ; *s; s++, i++) for(i = 0, s = sv.model_precache + 1 ; *s; s++, i++)
@ -322,8 +322,8 @@ void SV_SendServerinfo(client_t *client)
// send music // send music
MSG_WriteByte(&client->message, svc_cdtrack); MSG_WriteByte(&client->message, svc_cdtrack);
MSG_WriteByte(&client->message, sv.edicts->v.sounds); MSG_WriteByte(&client->message, ED_FLOAT(sv.edicts, ED_sounds));
MSG_WriteByte(&client->message, sv.edicts->v.sounds); MSG_WriteByte(&client->message, ED_FLOAT(sv.edicts, ED_sounds));
// set view // set view
MSG_WriteByte(&client->message, svc_setview); MSG_WriteByte(&client->message, svc_setview);
@ -535,7 +535,7 @@ bool SV_VisibleToClient(edict_t *client, edict_t *test, qmodel_t *worldmodel)
vec3_t org; vec3_t org;
int32_t i; int32_t i;
VectorAdd(client->v.origin, client->v.view_ofs, org); VectorAdd(ED_VECTOR(client, ED_origin), ED_VECTOR(client, ED_view_ofs), org);
pvs = SV_FatPVS(org, worldmodel); pvs = SV_FatPVS(org, worldmodel);
for(i = 0 ; i < test->num_leafs ; i++) for(i = 0 ; i < test->num_leafs ; i++)
@ -563,7 +563,7 @@ void SV_WriteEntitiesToClient(edict_t *clent, sizebuf_t *msg)
edict_t *ent; edict_t *ent;
// find the client's PVS // find the client's PVS
VectorAdd(clent->v.origin, clent->v.view_ofs, org); VectorAdd(ED_VECTOR(clent, ED_origin), ED_VECTOR(clent, ED_view_ofs), org);
pvs = SV_FatPVS(org, sv.worldmodel); pvs = SV_FatPVS(org, sv.worldmodel);
// send over all entities (excpet the client) that touch the pvs // send over all entities (excpet the client) that touch the pvs
@ -574,11 +574,11 @@ void SV_WriteEntitiesToClient(edict_t *clent, sizebuf_t *msg)
if(ent != clent) // clent is ALLWAYS sent if(ent != clent) // clent is ALLWAYS sent
{ {
// ignore ents without visible models // ignore ents without visible models
if(!ent->v.modelindex || !PR_GetString(ent->v.model)[0]) if(!ED_FLOAT(ent, ED_modelindex) || !PR_GetString(ED_RSTRING(ent, ED_model))[0])
continue; continue;
//johnfitz -- don't send model>255 entities if protocol is 15 //johnfitz -- don't send model>255 entities if protocol is 15
if(sv.protocol == PROTOCOL_NETQUAKE && (int32_t)ent->v.modelindex & 0xFF00) if(sv.protocol == PROTOCOL_NETQUAKE && (int32_t)ED_FLOAT(ent, ED_modelindex) & 0xFF00)
continue; continue;
// ignore if not touching a PV leaf // ignore if not touching a PV leaf
@ -615,36 +615,36 @@ void SV_WriteEntitiesToClient(edict_t *clent, sizebuf_t *msg)
for(i = 0 ; i < 3 ; i++) for(i = 0 ; i < 3 ; i++)
{ {
miss = ent->v.origin[i] - ent->baseline.origin[i]; miss = ED_VECTOR(ent, ED_origin)[i] - ent->baseline.origin[i];
if(miss < -0.1 || miss > 0.1) if(miss < -0.1 || miss > 0.1)
bits |= U_ORIGIN1 << i; bits |= U_ORIGIN1 << i;
} }
if(ent->v.angles[0] != ent->baseline.angles[0]) if(ED_VECTOR(ent, ED_angles)[0] != ent->baseline.angles[0])
bits |= U_ANGLE1; bits |= U_ANGLE1;
if(ent->v.angles[1] != ent->baseline.angles[1]) if(ED_VECTOR(ent, ED_angles)[1] != ent->baseline.angles[1])
bits |= U_ANGLE2; bits |= U_ANGLE2;
if(ent->v.angles[2] != ent->baseline.angles[2]) if(ED_VECTOR(ent, ED_angles)[2] != ent->baseline.angles[2])
bits |= U_ANGLE3; bits |= U_ANGLE3;
if(ent->v.movetype == MOVETYPE_STEP) if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_STEP)
bits |= U_STEP; // don't mess up the step animation bits |= U_STEP; // don't mess up the step animation
if(ent->baseline.colormap != ent->v.colormap) if(ent->baseline.colormap != ED_FLOAT(ent, ED_colormap))
bits |= U_COLORMAP; bits |= U_COLORMAP;
if(ent->baseline.skin != ent->v.skin) if(ent->baseline.skin != ED_FLOAT(ent, ED_skin))
bits |= U_SKIN; bits |= U_SKIN;
if(ent->baseline.frame != ent->v.frame) if(ent->baseline.frame != ED_FLOAT(ent, ED_frame))
bits |= U_FRAME; bits |= U_FRAME;
if(ent->baseline.effects != ent->v.effects) if(ent->baseline.effects != ED_FLOAT(ent, ED_effects))
bits |= U_EFFECTS; bits |= U_EFFECTS;
if(ent->baseline.modelindex != ent->v.modelindex) if(ent->baseline.modelindex != ED_FLOAT(ent, ED_modelindex))
bits |= U_MODEL; bits |= U_MODEL;
//johnfitz -- alpha //johnfitz -- alpha
@ -658,7 +658,7 @@ void SV_WriteEntitiesToClient(edict_t *clent, sizebuf_t *msg)
} }
//don't send invisible entities unless they have effects //don't send invisible entities unless they have effects
if(ent->alpha == ENTALPHA_ZERO && !ent->v.effects) if(ent->alpha == ENTALPHA_ZERO && !ED_FLOAT(ent, ED_effects))
continue; continue;
//johnfitz //johnfitz
@ -667,8 +667,8 @@ void SV_WriteEntitiesToClient(edict_t *clent, sizebuf_t *msg)
{ {
if(ent->baseline.alpha != ent->alpha) bits |= U_ALPHA; if(ent->baseline.alpha != ent->alpha) bits |= U_ALPHA;
if(bits & U_FRAME && (int32_t)ent->v.frame & 0xFF00) bits |= U_FRAME2; if(bits & U_FRAME && (int32_t)ED_FLOAT(ent, ED_frame) & 0xFF00) bits |= U_FRAME2;
if(bits & U_MODEL && (int32_t)ent->v.modelindex & 0xFF00) bits |= U_MODEL2; if(bits & U_MODEL && (int32_t)ED_FLOAT(ent, ED_modelindex) & 0xFF00) bits |= U_MODEL2;
if(ent->sendinterval) bits |= U_LERPFINISH; if(ent->sendinterval) bits |= U_LERPFINISH;
if(bits >= 65536) bits |= U_EXTEND1; if(bits >= 65536) bits |= U_EXTEND1;
if(bits >= 16777216) bits |= U_EXTEND2; if(bits >= 16777216) bits |= U_EXTEND2;
@ -702,37 +702,37 @@ void SV_WriteEntitiesToClient(edict_t *clent, sizebuf_t *msg)
MSG_WriteByte(msg, e); MSG_WriteByte(msg, e);
if(bits & U_MODEL) if(bits & U_MODEL)
MSG_WriteByte(msg, ent->v.modelindex); MSG_WriteByte(msg, ED_FLOAT(ent, ED_modelindex));
if(bits & U_FRAME) if(bits & U_FRAME)
MSG_WriteByte(msg, ent->v.frame); MSG_WriteByte(msg, ED_FLOAT(ent, ED_frame));
if(bits & U_COLORMAP) if(bits & U_COLORMAP)
MSG_WriteByte(msg, ent->v.colormap); MSG_WriteByte(msg, ED_FLOAT(ent, ED_colormap));
if(bits & U_SKIN) if(bits & U_SKIN)
MSG_WriteByte(msg, ent->v.skin); MSG_WriteByte(msg, ED_FLOAT(ent, ED_skin));
if(bits & U_EFFECTS) if(bits & U_EFFECTS)
MSG_WriteByte(msg, ent->v.effects); MSG_WriteByte(msg, ED_FLOAT(ent, ED_effects));
if(bits & U_ORIGIN1) if(bits & U_ORIGIN1)
MSG_WriteCoord(msg, ent->v.origin[0], sv.protocolflags); MSG_WriteCoord(msg, ED_VECTOR(ent, ED_origin)[0], sv.protocolflags);
if(bits & U_ANGLE1) if(bits & U_ANGLE1)
MSG_WriteAngle(msg, ent->v.angles[0], sv.protocolflags); MSG_WriteAngle(msg, ED_VECTOR(ent, ED_angles)[0], sv.protocolflags);
if(bits & U_ORIGIN2) if(bits & U_ORIGIN2)
MSG_WriteCoord(msg, ent->v.origin[1], sv.protocolflags); MSG_WriteCoord(msg, ED_VECTOR(ent, ED_origin)[1], sv.protocolflags);
if(bits & U_ANGLE2) if(bits & U_ANGLE2)
MSG_WriteAngle(msg, ent->v.angles[1], sv.protocolflags); MSG_WriteAngle(msg, ED_VECTOR(ent, ED_angles)[1], sv.protocolflags);
if(bits & U_ORIGIN3) if(bits & U_ORIGIN3)
MSG_WriteCoord(msg, ent->v.origin[2], sv.protocolflags); MSG_WriteCoord(msg, ED_VECTOR(ent, ED_origin)[2], sv.protocolflags);
if(bits & U_ANGLE3) if(bits & U_ANGLE3)
MSG_WriteAngle(msg, ent->v.angles[2], sv.protocolflags); MSG_WriteAngle(msg, ED_VECTOR(ent, ED_angles)[2], sv.protocolflags);
//johnfitz -- PROTOCOL_FITZQUAKE //johnfitz -- PROTOCOL_FITZQUAKE
if(bits & U_ALPHA) if(bits & U_ALPHA)
MSG_WriteByte(msg, ent->alpha); MSG_WriteByte(msg, ent->alpha);
if(bits & U_FRAME2) if(bits & U_FRAME2)
MSG_WriteByte(msg, (int32_t)ent->v.frame >> 8); MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_frame) >> 8);
if(bits & U_MODEL2) if(bits & U_MODEL2)
MSG_WriteByte(msg, (int32_t)ent->v.modelindex >> 8); MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_modelindex) >> 8);
if(bits & U_LERPFINISH) if(bits & U_LERPFINISH)
MSG_WriteByte(msg, (byte)(Q_rint((ent->v.nextthink - sv.time) * 255))); MSG_WriteByte(msg, (byte)(Q_rint((ED_FLOAT(ent, ED_nextthink) - sv.time) * 255)));
//johnfitz //johnfitz
} }
@ -759,7 +759,7 @@ void SV_CleanupEnts(void)
ent = NEXT_EDICT(sv.edicts); ent = NEXT_EDICT(sv.edicts);
for(e = 1 ; e < sv.num_edicts ; e++, ent = NEXT_EDICT(ent)) for(e = 1 ; e < sv.num_edicts ; e++, ent = NEXT_EDICT(ent))
{ {
ent->v.effects = (int32_t)ent->v.effects & ~EF_MUZZLEFLASH; ED_FLOAT(ent, ED_effects) = (int32_t)ED_FLOAT(ent, ED_effects) & ~EF_MUZZLEFLASH;
} }
} }
@ -780,17 +780,17 @@ void SV_WriteClientdataToMessage(edict_t *ent, sizebuf_t *msg)
// //
// send a damage message // send a damage message
// //
if(ent->v.dmg_take || ent->v.dmg_save) if(ED_FLOAT(ent, ED_dmg_take) || ED_FLOAT(ent, ED_dmg_save))
{ {
other = PROG_TO_EDICT(ent->v.dmg_inflictor); other = PROG_TO_EDICT(ED_INT(ent, ED_dmg_inflictor));
MSG_WriteByte(msg, svc_damage); MSG_WriteByte(msg, svc_damage);
MSG_WriteByte(msg, ent->v.dmg_save); MSG_WriteByte(msg, ED_FLOAT(ent, ED_dmg_save));
MSG_WriteByte(msg, ent->v.dmg_take); MSG_WriteByte(msg, ED_FLOAT(ent, ED_dmg_take));
for(i = 0 ; i < 3 ; i++) for(i = 0 ; i < 3 ; i++)
MSG_WriteCoord(msg, other->v.origin[i] + 0.5 * (other->v.mins[i] + other->v.maxs[i]), sv.protocolflags); MSG_WriteCoord(msg, ED_VECTOR(other, ED_origin)[i] + 0.5 * (ED_VECTOR(other, ED_mins)[i] + ED_VECTOR(other, ED_maxs)[i]), sv.protocolflags);
ent->v.dmg_take = 0; ED_FLOAT(ent, ED_dmg_take) = 0;
ent->v.dmg_save = 0; ED_FLOAT(ent, ED_dmg_save) = 0;
} }
// //
@ -799,20 +799,20 @@ void SV_WriteClientdataToMessage(edict_t *ent, sizebuf_t *msg)
SV_SetIdealPitch(); // how much to look up / down ideally SV_SetIdealPitch(); // how much to look up / down ideally
// a fixangle might get lost in a dropped packet. Oh well. // a fixangle might get lost in a dropped packet. Oh well.
if(ent->v.fixangle) if(ED_FLOAT(ent, ED_fixangle))
{ {
MSG_WriteByte(msg, svc_setangle); MSG_WriteByte(msg, svc_setangle);
for(i = 0 ; i < 3 ; i++) for(i = 0 ; i < 3 ; i++)
MSG_WriteAngle(msg, ent->v.angles[i], sv.protocolflags); MSG_WriteAngle(msg, ED_VECTOR(ent, ED_angles)[i], sv.protocolflags);
ent->v.fixangle = 0; ED_FLOAT(ent, ED_fixangle) = 0;
} }
bits = 0; bits = 0;
if(ent->v.view_ofs[2] != DEFAULT_VIEWHEIGHT) if(ED_VECTOR(ent, ED_view_ofs)[2] != DEFAULT_VIEWHEIGHT)
bits |= SU_VIEWHEIGHT; bits |= SU_VIEWHEIGHT;
if(ent->v.idealpitch) if(ED_FLOAT(ent, ED_idealpitch))
bits |= SU_IDEALPITCH; bits |= SU_IDEALPITCH;
// stuff the sigil bits into the high bits of items for sbar, or else // stuff the sigil bits into the high bits of items for sbar, or else
@ -820,46 +820,46 @@ void SV_WriteClientdataToMessage(edict_t *ent, sizebuf_t *msg)
val = GetEdictFieldValue(ent, "items2"); val = GetEdictFieldValue(ent, "items2");
if(val) if(val)
items = (int32_t)ent->v.items | ((int32_t)val->_float << 23); items = (int32_t)ED_FLOAT(ent, ED_items) | ((int32_t)val->_float << 23);
else else
items = (int32_t)ent->v.items | ((int32_t)G_FLOAT(GBL_serverflags) << 28); items = (int32_t)ED_FLOAT(ent, ED_items) | ((int32_t)G_FLOAT(GBL_serverflags) << 28);
bits |= SU_ITEMS; bits |= SU_ITEMS;
if((int32_t)ent->v.flags & FL_ONGROUND) if((int32_t)ED_FLOAT(ent, ED_flags) & FL_ONGROUND)
bits |= SU_ONGROUND; bits |= SU_ONGROUND;
if(ent->v.waterlevel >= 2) if(ED_FLOAT(ent, ED_waterlevel) >= 2)
bits |= SU_INWATER; bits |= SU_INWATER;
for(i = 0 ; i < 3 ; i++) for(i = 0 ; i < 3 ; i++)
{ {
if(ent->v.punchangle[i]) if(ED_VECTOR(ent, ED_punchangle)[i])
bits |= (SU_PUNCH1 << i); bits |= (SU_PUNCH1 << i);
if(ent->v.velocity[i]) if(ED_VECTOR(ent, ED_velocity)[i])
bits |= (SU_VELOCITY1 << i); bits |= (SU_VELOCITY1 << i);
} }
if(ent->v.weaponframe) if(ED_FLOAT(ent, ED_weaponframe))
bits |= SU_WEAPONFRAME; bits |= SU_WEAPONFRAME;
if(ent->v.armorvalue) if(ED_FLOAT(ent, ED_armorvalue))
bits |= SU_ARMOR; bits |= SU_ARMOR;
// if (ent->v.weapon) // if (ED_FLOAT(ent, ED_weapon))
bits |= SU_WEAPON; bits |= SU_WEAPON;
//johnfitz -- PROTOCOL_FITZQUAKE //johnfitz -- PROTOCOL_FITZQUAKE
if(sv.protocol != PROTOCOL_NETQUAKE) if(sv.protocol != PROTOCOL_NETQUAKE)
{ {
if(bits & SU_WEAPON && SV_ModelIndex(PR_GetString(ent->v.weaponmodel)) & 0xFF00) bits |= SU_WEAPON2; if(bits & SU_WEAPON && SV_ModelIndex(PR_GetString(ED_RSTRING(ent, ED_weaponmodel))) & 0xFF00) bits |= SU_WEAPON2;
if((int32_t)ent->v.armorvalue & 0xFF00) bits |= SU_ARMOR2; if((int32_t)ED_FLOAT(ent, ED_armorvalue) & 0xFF00) bits |= SU_ARMOR2;
if((int32_t)ent->v.currentammo & 0xFF00) bits |= SU_AMMO2; if((int32_t)ED_FLOAT(ent, ED_currentammo) & 0xFF00) bits |= SU_AMMO2;
if((int32_t)ent->v.ammo_shells & 0xFF00) bits |= SU_SHELLS2; if((int32_t)ED_FLOAT(ent, ED_ammo_shells) & 0xFF00) bits |= SU_SHELLS2;
if((int32_t)ent->v.ammo_nails & 0xFF00) bits |= SU_NAILS2; if((int32_t)ED_FLOAT(ent, ED_ammo_nails) & 0xFF00) bits |= SU_NAILS2;
if((int32_t)ent->v.ammo_rockets & 0xFF00) bits |= SU_ROCKETS2; if((int32_t)ED_FLOAT(ent, ED_ammo_rockets) & 0xFF00) bits |= SU_ROCKETS2;
if((int32_t)ent->v.ammo_cells & 0xFF00) bits |= SU_CELLS2; if((int32_t)ED_FLOAT(ent, ED_ammo_cells) & 0xFF00) bits |= SU_CELLS2;
if(bits & SU_WEAPONFRAME && (int32_t)ent->v.weaponframe & 0xFF00) bits |= SU_WEAPONFRAME2; if(bits & SU_WEAPONFRAME && (int32_t)ED_FLOAT(ent, ED_weaponframe) & 0xFF00) bits |= SU_WEAPONFRAME2;
if(bits & SU_WEAPON && ent->alpha != ENTALPHA_DEFAULT) bits |= SU_WEAPONALPHA; //for now, weaponalpha = client entity alpha if(bits & SU_WEAPON && ent->alpha != ENTALPHA_DEFAULT) bits |= SU_WEAPONALPHA; //for now, weaponalpha = client entity alpha
if(bits >= 65536) bits |= SU_EXTEND1; if(bits >= 65536) bits |= SU_EXTEND1;
if(bits >= 16777216) bits |= SU_EXTEND2; if(bits >= 16777216) bits |= SU_EXTEND2;
@ -877,45 +877,45 @@ void SV_WriteClientdataToMessage(edict_t *ent, sizebuf_t *msg)
//johnfitz //johnfitz
if(bits & SU_VIEWHEIGHT) if(bits & SU_VIEWHEIGHT)
MSG_WriteChar(msg, ent->v.view_ofs[2]); MSG_WriteChar(msg, ED_VECTOR(ent, ED_view_ofs)[2]);
if(bits & SU_IDEALPITCH) if(bits & SU_IDEALPITCH)
MSG_WriteChar(msg, ent->v.idealpitch); MSG_WriteChar(msg, ED_FLOAT(ent, ED_idealpitch));
for(i = 0 ; i < 3 ; i++) for(i = 0 ; i < 3 ; i++)
{ {
if(bits & (SU_PUNCH1 << i)) if(bits & (SU_PUNCH1 << i))
MSG_WriteChar(msg, ent->v.punchangle[i]); MSG_WriteChar(msg, ED_VECTOR(ent, ED_punchangle)[i]);
if(bits & (SU_VELOCITY1 << i)) if(bits & (SU_VELOCITY1 << i))
MSG_WriteChar(msg, ent->v.velocity[i] / 16); MSG_WriteChar(msg, ED_VECTOR(ent, ED_velocity)[i] / 16);
} }
// [always sent] if (bits & SU_ITEMS) // [always sent] if (bits & SU_ITEMS)
MSG_WriteLong(msg, items); MSG_WriteLong(msg, items);
if(bits & SU_WEAPONFRAME) if(bits & SU_WEAPONFRAME)
MSG_WriteByte(msg, ent->v.weaponframe); MSG_WriteByte(msg, ED_FLOAT(ent, ED_weaponframe));
if(bits & SU_ARMOR) if(bits & SU_ARMOR)
MSG_WriteByte(msg, ent->v.armorvalue); MSG_WriteByte(msg, ED_FLOAT(ent, ED_armorvalue));
if(bits & SU_WEAPON) if(bits & SU_WEAPON)
MSG_WriteByte(msg, SV_ModelIndex(PR_GetString(ent->v.weaponmodel))); MSG_WriteByte(msg, SV_ModelIndex(PR_GetString(ED_RSTRING(ent, ED_weaponmodel))));
MSG_WriteShort(msg, ent->v.health); MSG_WriteShort(msg, ED_FLOAT(ent, ED_health));
MSG_WriteByte(msg, ent->v.currentammo); MSG_WriteByte(msg, ED_FLOAT(ent, ED_currentammo));
MSG_WriteByte(msg, ent->v.ammo_shells); MSG_WriteByte(msg, ED_FLOAT(ent, ED_ammo_shells));
MSG_WriteByte(msg, ent->v.ammo_nails); MSG_WriteByte(msg, ED_FLOAT(ent, ED_ammo_nails));
MSG_WriteByte(msg, ent->v.ammo_rockets); MSG_WriteByte(msg, ED_FLOAT(ent, ED_ammo_rockets));
MSG_WriteByte(msg, ent->v.ammo_cells); MSG_WriteByte(msg, ED_FLOAT(ent, ED_ammo_cells));
if(standard_quake) if(standard_quake)
{ {
MSG_WriteByte(msg, ent->v.weapon); MSG_WriteByte(msg, ED_FLOAT(ent, ED_weapon));
} }
else else
{ {
for(i = 0; i < 32; i++) for(i = 0; i < 32; i++)
{ {
if(((int32_t)ent->v.weapon) & (1 << i)) if(((int32_t)ED_FLOAT(ent, ED_weapon)) & (1 << i))
{ {
MSG_WriteByte(msg, i); MSG_WriteByte(msg, i);
break; break;
@ -925,21 +925,21 @@ void SV_WriteClientdataToMessage(edict_t *ent, sizebuf_t *msg)
//johnfitz -- PROTOCOL_FITZQUAKE //johnfitz -- PROTOCOL_FITZQUAKE
if(bits & SU_WEAPON2) if(bits & SU_WEAPON2)
MSG_WriteByte(msg, SV_ModelIndex(PR_GetString(ent->v.weaponmodel)) >> 8); MSG_WriteByte(msg, SV_ModelIndex(PR_GetString(ED_RSTRING(ent, ED_weaponmodel))) >> 8);
if(bits & SU_ARMOR2) if(bits & SU_ARMOR2)
MSG_WriteByte(msg, (int32_t)ent->v.armorvalue >> 8); MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_armorvalue) >> 8);
if(bits & SU_AMMO2) if(bits & SU_AMMO2)
MSG_WriteByte(msg, (int32_t)ent->v.currentammo >> 8); MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_currentammo) >> 8);
if(bits & SU_SHELLS2) if(bits & SU_SHELLS2)
MSG_WriteByte(msg, (int32_t)ent->v.ammo_shells >> 8); MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_ammo_shells) >> 8);
if(bits & SU_NAILS2) if(bits & SU_NAILS2)
MSG_WriteByte(msg, (int32_t)ent->v.ammo_nails >> 8); MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_ammo_nails) >> 8);
if(bits & SU_ROCKETS2) if(bits & SU_ROCKETS2)
MSG_WriteByte(msg, (int32_t)ent->v.ammo_rockets >> 8); MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_ammo_rockets) >> 8);
if(bits & SU_CELLS2) if(bits & SU_CELLS2)
MSG_WriteByte(msg, (int32_t)ent->v.ammo_cells >> 8); MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_ammo_cells) >> 8);
if(bits & SU_WEAPONFRAME2) if(bits & SU_WEAPONFRAME2)
MSG_WriteByte(msg, (int32_t)ent->v.weaponframe >> 8); MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_weaponframe) >> 8);
if(bits & SU_WEAPONALPHA) if(bits & SU_WEAPONALPHA)
MSG_WriteByte(msg, ent->alpha); //for now, weaponalpha = client entity alpha MSG_WriteByte(msg, ent->alpha); //for now, weaponalpha = client entity alpha
//johnfitz //johnfitz
@ -999,7 +999,7 @@ void SV_UpdateToReliableMessages(void)
// check for changes to be sent over the reliable streams // check for changes to be sent over the reliable streams
for(i = 0, host_client = svs.clients ; i < svs.maxclients ; i++, host_client++) for(i = 0, host_client = svs.clients ; i < svs.maxclients ; i++, host_client++)
{ {
if(host_client->old_frags != host_client->edict->v.frags) if(host_client->old_frags != ED_FLOAT(host_client->edict, ED_frags))
{ {
for(j = 0, client = svs.clients ; j < svs.maxclients ; j++, client++) for(j = 0, client = svs.clients ; j < svs.maxclients ; j++, client++)
{ {
@ -1007,10 +1007,10 @@ void SV_UpdateToReliableMessages(void)
continue; continue;
MSG_WriteByte(&client->message, svc_updatefrags); MSG_WriteByte(&client->message, svc_updatefrags);
MSG_WriteByte(&client->message, i); MSG_WriteByte(&client->message, i);
MSG_WriteShort(&client->message, host_client->edict->v.frags); MSG_WriteShort(&client->message, ED_FLOAT(host_client->edict, ED_frags));
} }
host_client->old_frags = host_client->edict->v.frags; host_client->old_frags = ED_FLOAT(host_client->edict, ED_frags);
} }
} }
@ -1172,16 +1172,16 @@ void SV_CreateBaseline(void)
svent = EDICT_NUM(entnum); svent = EDICT_NUM(entnum);
if(svent->free) if(svent->free)
continue; continue;
if(entnum > svs.maxclients && !svent->v.modelindex) if(entnum > svs.maxclients && !ED_FLOAT(svent, ED_modelindex))
continue; continue;
// //
// create entity baseline // create entity baseline
// //
VectorCopy(svent->v.origin, svent->baseline.origin); VectorCopy(ED_VECTOR(svent, ED_origin), svent->baseline.origin);
VectorCopy(svent->v.angles, svent->baseline.angles); VectorCopy(ED_VECTOR(svent, ED_angles), svent->baseline.angles);
svent->baseline.frame = svent->v.frame; svent->baseline.frame = ED_FLOAT(svent, ED_frame);
svent->baseline.skin = svent->v.skin; svent->baseline.skin = ED_FLOAT(svent, ED_skin);
if(entnum > 0 && entnum <= svs.maxclients) if(entnum > 0 && entnum <= svs.maxclients)
{ {
svent->baseline.colormap = entnum; svent->baseline.colormap = entnum;
@ -1191,7 +1191,7 @@ void SV_CreateBaseline(void)
else else
{ {
svent->baseline.colormap = 0; svent->baseline.colormap = 0;
svent->baseline.modelindex = SV_ModelIndex(PR_GetString(svent->v.model)); svent->baseline.modelindex = SV_ModelIndex(PR_GetString(ED_RSTRING(svent, ED_model)));
svent->baseline.alpha = svent->alpha; //johnfitz -- alpha support svent->baseline.alpha = svent->alpha; //johnfitz -- alpha support
} }
@ -1436,19 +1436,19 @@ void SV_SpawnServer(const char *server)
// load the rest of the entities // load the rest of the entities
// //
ent = EDICT_NUM(0); ent = EDICT_NUM(0);
memset(&ent->v, 0, progs.entityfields * 4); memset(ent->fields, 0, progs.entityfields * 4);
ent->free = false; ent->free = false;
ent->v.model = PR_SetEngineString(sv.worldmodel->name); ED_RSTRING(ent, ED_model) = PR_SetEngineString(sv.worldmodel->name);
ent->v.modelindex = 1; // world model ED_FLOAT(ent, ED_modelindex) = 1; // world model
ent->v.solid = SOLID_BSP; ED_FLOAT(ent, ED_solid) = SOLID_BSP;
ent->v.movetype = MOVETYPE_PUSH; ED_FLOAT(ent, ED_movetype) = MOVETYPE_PUSH;
if(coop.value) if(coop.value)
G_FLOAT(GBL_coop) = coop.value; G_FLOAT(GBL_coop) = coop.value;
else else
G_FLOAT(GBL_deathmatch) = deathmatch.value; G_FLOAT(GBL_deathmatch) = deathmatch.value;
G_INT(GBL_mapname) = PR_SetEngineString(sv.name); G_RSTRING(GBL_mapname) = PR_SetEngineString(sv.name);
// serverflags are for cross level information (sigils) // serverflags are for cross level information (sigils)
G_FLOAT(GBL_serverflags) = svs.serverflags; G_FLOAT(GBL_serverflags) = svs.serverflags;

View File

@ -43,8 +43,8 @@ bool SV_CheckBottom(edict_t *ent)
int32_t x, y; int32_t x, y;
float mid, bottom; float mid, bottom;
VectorAdd(ent->v.origin, ent->v.mins, mins); VectorAdd(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), mins);
VectorAdd(ent->v.origin, ent->v.maxs, maxs); VectorAdd(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_maxs), maxs);
// if all of the points under the corners are solid world, don't bother // if all of the points under the corners are solid world, don't bother
// with the tougher checks // with the tougher checks
@ -118,33 +118,33 @@ bool SV_movestep(edict_t *ent, vec3_t move, bool relink)
edict_t *enemy; edict_t *enemy;
// try the move // try the move
VectorCopy(ent->v.origin, oldorg); VectorCopy(ED_VECTOR(ent, ED_origin), oldorg);
VectorAdd(ent->v.origin, move, neworg); VectorAdd(ED_VECTOR(ent, ED_origin), move, neworg);
// flying monsters don't step up // flying monsters don't step up
if((int32_t)ent->v.flags & (FL_SWIM | FL_FLY)) if((int32_t)ED_FLOAT(ent, ED_flags) & (FL_SWIM | FL_FLY))
{ {
// try one move with vertical motion, then one without // try one move with vertical motion, then one without
for(i = 0 ; i < 2 ; i++) for(i = 0 ; i < 2 ; i++)
{ {
VectorAdd(ent->v.origin, move, neworg); VectorAdd(ED_VECTOR(ent, ED_origin), move, neworg);
enemy = PROG_TO_EDICT(ent->v.enemy); enemy = PROG_TO_EDICT(ED_INT(ent, ED_enemy));
if(i == 0 && enemy != sv.edicts) if(i == 0 && enemy != sv.edicts)
{ {
dz = ent->v.origin[2] - PROG_TO_EDICT(ent->v.enemy)->v.origin[2]; dz = ED_VECTOR(ent, ED_origin)[2] - ED_VECTOR(PROG_TO_EDICT(ED_INT(ent, ED_enemy)), ED_origin)[2];
if(dz > 40) if(dz > 40)
neworg[2] -= 8; neworg[2] -= 8;
if(dz < 30) if(dz < 30)
neworg[2] += 8; neworg[2] += 8;
} }
trace = SV_Move(ent->v.origin, ent->v.mins, ent->v.maxs, neworg, false, ent); trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), neworg, false, ent);
if(trace.fraction == 1) if(trace.fraction == 1)
{ {
if(((int32_t)ent->v.flags & FL_SWIM) && SV_PointContents(trace.endpos) == CONTENTS_EMPTY) if(((int32_t)ED_FLOAT(ent, ED_flags) & FL_SWIM) && SV_PointContents(trace.endpos) == CONTENTS_EMPTY)
return false; // swim monster left water return false; // swim monster left water
VectorCopy(trace.endpos, ent->v.origin); VectorCopy(trace.endpos, ED_VECTOR(ent, ED_origin));
if(relink) if(relink)
SV_LinkEdict(ent, true); SV_LinkEdict(ent, true);
return true; return true;
@ -162,7 +162,7 @@ bool SV_movestep(edict_t *ent, vec3_t move, bool relink)
VectorCopy(neworg, end); VectorCopy(neworg, end);
end[2] -= STEPSIZE * 2; end[2] -= STEPSIZE * 2;
trace = SV_Move(neworg, ent->v.mins, ent->v.maxs, end, false, ent); trace = SV_Move(neworg, ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, false, ent);
if(trace.allsolid) if(trace.allsolid)
return false; return false;
@ -170,19 +170,19 @@ bool SV_movestep(edict_t *ent, vec3_t move, bool relink)
if(trace.startsolid) if(trace.startsolid)
{ {
neworg[2] -= STEPSIZE; neworg[2] -= STEPSIZE;
trace = SV_Move(neworg, ent->v.mins, ent->v.maxs, end, false, ent); trace = SV_Move(neworg, ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, false, ent);
if(trace.allsolid || trace.startsolid) if(trace.allsolid || trace.startsolid)
return false; return false;
} }
if(trace.fraction == 1) if(trace.fraction == 1)
{ {
// if monster had the ground pulled out, go ahead and fall // if monster had the ground pulled out, go ahead and fall
if((int32_t)ent->v.flags & FL_PARTIALGROUND) if((int32_t)ED_FLOAT(ent, ED_flags) & FL_PARTIALGROUND)
{ {
VectorAdd(ent->v.origin, move, ent->v.origin); VectorAdd(ED_VECTOR(ent, ED_origin), move, ED_VECTOR(ent, ED_origin));
if(relink) if(relink)
SV_LinkEdict(ent, true); SV_LinkEdict(ent, true);
ent->v.flags = (int32_t)ent->v.flags & ~FL_ONGROUND; ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) & ~FL_ONGROUND;
// Con_Printf ("fall down\n"); // Con_Printf ("fall down\n");
return true; return true;
} }
@ -191,11 +191,11 @@ bool SV_movestep(edict_t *ent, vec3_t move, bool relink)
} }
// check point traces down for dangling corners // check point traces down for dangling corners
VectorCopy(trace.endpos, ent->v.origin); VectorCopy(trace.endpos, ED_VECTOR(ent, ED_origin));
if(!SV_CheckBottom(ent)) if(!SV_CheckBottom(ent))
{ {
if((int32_t)ent->v.flags & FL_PARTIALGROUND) if((int32_t)ED_FLOAT(ent, ED_flags) & FL_PARTIALGROUND)
{ {
// entity had floor mostly pulled out from underneath it // entity had floor mostly pulled out from underneath it
// and is trying to correct // and is trying to correct
@ -203,16 +203,16 @@ bool SV_movestep(edict_t *ent, vec3_t move, bool relink)
SV_LinkEdict(ent, true); SV_LinkEdict(ent, true);
return true; return true;
} }
VectorCopy(oldorg, ent->v.origin); VectorCopy(oldorg, ED_VECTOR(ent, ED_origin));
return false; return false;
} }
if((int32_t)ent->v.flags & FL_PARTIALGROUND) if((int32_t)ED_FLOAT(ent, ED_flags) & FL_PARTIALGROUND)
{ {
// Con_Printf ("back on ground\n"); // Con_Printf ("back on ground\n");
ent->v.flags = (int32_t)ent->v.flags & ~FL_PARTIALGROUND; ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) & ~FL_PARTIALGROUND;
} }
ent->v.groundentity = EDICT_TO_PROG(trace.ent); ED_INT(ent, ED_groundentity) = EDICT_TO_PROG(trace.ent);
// the move is ok // the move is ok
if(relink) if(relink)
@ -238,7 +238,7 @@ bool SV_StepDirection(edict_t *ent, float yaw, float dist)
vec3_t move, oldorigin; vec3_t move, oldorigin;
float delta; float delta;
ent->v.ideal_yaw = yaw; ED_FLOAT(ent, ED_ideal_yaw) = yaw;
PF_changeyaw(); PF_changeyaw();
yaw = yaw * PI * 2 / 360; yaw = yaw * PI * 2 / 360;
@ -246,14 +246,14 @@ bool SV_StepDirection(edict_t *ent, float yaw, float dist)
move[1] = sin(yaw) * dist; move[1] = sin(yaw) * dist;
move[2] = 0; move[2] = 0;
VectorCopy(ent->v.origin, oldorigin); VectorCopy(ED_VECTOR(ent, ED_origin), oldorigin);
if(SV_movestep(ent, move, false)) if(SV_movestep(ent, move, false))
{ {
delta = ent->v.angles[YAW] - ent->v.ideal_yaw; delta = ED_VECTOR(ent, ED_angles)[YAW] - ED_FLOAT(ent, ED_ideal_yaw);
if(delta > 45 && delta < 315) if(delta > 45 && delta < 315)
{ {
// not turned far enough, so don't take the step // not turned far enough, so don't take the step
VectorCopy(oldorigin, ent->v.origin); VectorCopy(oldorigin, ED_VECTOR(ent, ED_origin));
} }
SV_LinkEdict(ent, true); SV_LinkEdict(ent, true);
return true; return true;
@ -273,7 +273,7 @@ void SV_FixCheckBottom(edict_t *ent)
{ {
// Con_Printf ("SV_FixCheckBottom\n"); // Con_Printf ("SV_FixCheckBottom\n");
ent->v.flags = (int32_t)ent->v.flags | FL_PARTIALGROUND; ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) | FL_PARTIALGROUND;
} }
@ -291,11 +291,11 @@ void SV_NewChaseDir(edict_t *actor, edict_t *enemy, float dist)
float d[3]; float d[3];
float tdir, olddir, turnaround; float tdir, olddir, turnaround;
olddir = anglemod((int32_t)(actor->v.ideal_yaw / 45) * 45); olddir = anglemod((int32_t)(ED_FLOAT(actor, ED_ideal_yaw) / 45) * 45);
turnaround = anglemod(olddir - 180); turnaround = anglemod(olddir - 180);
deltax = enemy->v.origin[0] - actor->v.origin[0]; deltax = ED_VECTOR(enemy, ED_origin)[0] - ED_VECTOR(actor, ED_origin)[0];
deltay = enemy->v.origin[1] - actor->v.origin[1]; deltay = ED_VECTOR(enemy, ED_origin)[1] - ED_VECTOR(actor, ED_origin)[1];
if(deltax > 10) if(deltax > 10)
d[1] = 0; d[1] = 0;
else if(deltax < -10) else if(deltax < -10)
@ -358,7 +358,7 @@ void SV_NewChaseDir(edict_t *actor, edict_t *enemy, float dist)
if(turnaround != DI_NODIR && SV_StepDirection(actor, turnaround, dist)) if(turnaround != DI_NODIR && SV_StepDirection(actor, turnaround, dist))
return; return;
actor->v.ideal_yaw = olddir; // can't move ED_FLOAT(actor, ED_ideal_yaw) = olddir; // can't move
// if a bridge was pulled out from underneath a monster, it may not have // if a bridge was pulled out from underneath a monster, it may not have
// a valid standing position at all // a valid standing position at all
@ -380,9 +380,9 @@ bool SV_CloseEnough(edict_t *ent, edict_t *goal, float dist)
for(i = 0 ; i < 3 ; i++) for(i = 0 ; i < 3 ; i++)
{ {
if(goal->v.absmin[i] > ent->v.absmax[i] + dist) if(ED_VECTOR(goal, ED_absmin)[i] > ED_VECTOR(ent, ED_absmax)[i] + dist)
return false; return false;
if(goal->v.absmax[i] < ent->v.absmin[i] - dist) if(ED_VECTOR(goal, ED_absmax)[i] < ED_VECTOR(ent, ED_absmin)[i] - dist)
return false; return false;
} }
return true; return true;
@ -400,22 +400,22 @@ void SV_MoveToGoal(void)
float dist; float dist;
ent = PROG_TO_EDICT(G_INT(GBL_self)); ent = PROG_TO_EDICT(G_INT(GBL_self));
goal = PROG_TO_EDICT(ent->v.goalentity); goal = PROG_TO_EDICT(ED_INT(ent, ED_goalentity));
dist = G_FLOAT(GBL_PARM0); dist = G_FLOAT(GBL_PARM0);
if(!((int32_t)ent->v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) if(!((int32_t)ED_FLOAT(ent, ED_flags) & (FL_ONGROUND | FL_FLY | FL_SWIM)))
{ {
G_FLOAT(GBL_RETURN) = 0; G_FLOAT(GBL_RETURN) = 0;
return; return;
} }
// if the next step hits the enemy, return immediately // 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(ED_INT(ent, ED_enemy)) != sv.edicts && SV_CloseEnough(ent, goal, dist))
return; return;
// bump around... // bump around...
if((rand() & 3) == 1 || if((rand() & 3) == 1 ||
!SV_StepDirection(ent, ent->v.ideal_yaw, dist)) !SV_StepDirection(ent, ED_FLOAT(ent, ED_ideal_yaw), dist))
{ {
SV_NewChaseDir(ent, goal, dist); SV_NewChaseDir(ent, goal, dist);
} }

View File

@ -69,9 +69,9 @@ void SV_CheckAllEnts(void)
{ {
if(check->free) if(check->free)
continue; continue;
if(check->v.movetype == MOVETYPE_PUSH if(ED_FLOAT(check, ED_movetype) == MOVETYPE_PUSH
|| check->v.movetype == MOVETYPE_NONE || ED_FLOAT(check, ED_movetype) == MOVETYPE_NONE
|| check->v.movetype == MOVETYPE_NOCLIP) || ED_FLOAT(check, ED_movetype) == MOVETYPE_NOCLIP)
continue; continue;
if(SV_TestEntityPosition(check)) if(SV_TestEntityPosition(check))
@ -93,20 +93,20 @@ void SV_CheckVelocity(edict_t *ent)
// //
for(i = 0 ; i < 3 ; i++) for(i = 0 ; i < 3 ; i++)
{ {
if(isnan(ent->v.velocity[i])) if(isnan(ED_VECTOR(ent, ED_velocity)[i]))
{ {
Con_Printf("Got a NaN velocity on %s\n", PR_GetString(ent->v.classname)); Con_Printf("Got a NaN velocity on %s\n", PR_GetString(ED_RSTRING(ent, ED_classname)));
ent->v.velocity[i] = 0; ED_VECTOR(ent, ED_velocity)[i] = 0;
} }
if(isnan(ent->v.origin[i])) if(isnan(ED_VECTOR(ent, ED_origin)[i]))
{ {
Con_Printf("Got a NaN origin on %s\n", PR_GetString(ent->v.classname)); Con_Printf("Got a NaN origin on %s\n", PR_GetString(ED_RSTRING(ent, ED_classname)));
ent->v.origin[i] = 0; ED_VECTOR(ent, ED_origin)[i] = 0;
} }
if(ent->v.velocity[i] > sv_maxvelocity.value) if(ED_VECTOR(ent, ED_velocity)[i] > sv_maxvelocity.value)
ent->v.velocity[i] = sv_maxvelocity.value; ED_VECTOR(ent, ED_velocity)[i] = sv_maxvelocity.value;
else if(ent->v.velocity[i] < -sv_maxvelocity.value) else if(ED_VECTOR(ent, ED_velocity)[i] < -sv_maxvelocity.value)
ent->v.velocity[i] = -sv_maxvelocity.value; ED_VECTOR(ent, ED_velocity)[i] = -sv_maxvelocity.value;
} }
} }
@ -126,7 +126,7 @@ bool SV_RunThink(edict_t *ent)
float oldframe; //johnfitz float oldframe; //johnfitz
int32_t i; //johnfitz int32_t i; //johnfitz
thinktime = ent->v.nextthink; thinktime = ED_FLOAT(ent, ED_nextthink);
if(thinktime <= 0 || thinktime > sv.time + host_frametime) if(thinktime <= 0 || thinktime > sv.time + host_frametime)
return true; return true;
@ -135,21 +135,21 @@ bool SV_RunThink(edict_t *ent)
// it is possible to start that way // it is possible to start that way
// by a trigger with a local time. // by a trigger with a local time.
oldframe = ent->v.frame; //johnfitz oldframe = ED_FLOAT(ent, ED_frame); //johnfitz
ent->v.nextthink = 0; ED_FLOAT(ent, ED_nextthink) = 0;
G_FLOAT(GBL_time) = thinktime; G_FLOAT(GBL_time) = thinktime;
G_INT(GBL_self) = EDICT_TO_PROG(ent); G_INT(GBL_self) = EDICT_TO_PROG(ent);
G_INT(GBL_other) = EDICT_TO_PROG(sv.edicts); G_INT(GBL_other) = EDICT_TO_PROG(sv.edicts);
PR_ExecuteProgram(ent->v.think); PR_ExecuteProgram(ED_FUNC(ent, ED_think));
//johnfitz -- PROTOCOL_FITZQUAKE //johnfitz -- PROTOCOL_FITZQUAKE
//capture interval to nextthink here and send it to client for better //capture interval to nextthink here and send it to client for better
//lerp timing, but only if interval is not 0.1 (which client assumes) //lerp timing, but only if interval is not 0.1 (which client assumes)
ent->sendinterval = false; ent->sendinterval = false;
if(!ent->free && ent->v.nextthink && (ent->v.movetype == MOVETYPE_STEP || ent->v.frame != oldframe)) if(!ent->free && ED_FLOAT(ent, ED_nextthink) && (ED_FLOAT(ent, ED_movetype) == MOVETYPE_STEP || ED_FLOAT(ent, ED_frame) != oldframe))
{ {
i = Q_rint((ent->v.nextthink - thinktime) * 255); i = Q_rint((ED_FLOAT(ent, ED_nextthink) - thinktime) * 255);
if(i >= 0 && i < 256 && i != 25 && i != 26) //25 and 26 are close enough to 0.1 to not send if(i >= 0 && i < 256 && i != 25 && i != 26) //25 and 26 are close enough to 0.1 to not send
ent->sendinterval = true; ent->sendinterval = true;
} }
@ -173,18 +173,18 @@ void SV_Impact(edict_t *e1, edict_t *e2)
old_other = G_INT(GBL_other); old_other = G_INT(GBL_other);
G_FLOAT(GBL_time) = sv.time; G_FLOAT(GBL_time) = sv.time;
if(e1->v.touch && e1->v.solid != SOLID_NOT) if(ED_FUNC(e1, ED_touch) && ED_FLOAT(e1, ED_solid) != SOLID_NOT)
{ {
G_INT(GBL_self) = EDICT_TO_PROG(e1); G_INT(GBL_self) = EDICT_TO_PROG(e1);
G_INT(GBL_other) = EDICT_TO_PROG(e2); G_INT(GBL_other) = EDICT_TO_PROG(e2);
PR_ExecuteProgram(e1->v.touch); PR_ExecuteProgram(ED_FUNC(e1, ED_touch));
} }
if(e2->v.touch && e2->v.solid != SOLID_NOT) if(ED_FUNC(e2, ED_touch) && ED_FLOAT(e2, ED_solid) != SOLID_NOT)
{ {
G_INT(GBL_self) = EDICT_TO_PROG(e2); G_INT(GBL_self) = EDICT_TO_PROG(e2);
G_INT(GBL_other) = EDICT_TO_PROG(e1); G_INT(GBL_other) = EDICT_TO_PROG(e1);
PR_ExecuteProgram(e2->v.touch); PR_ExecuteProgram(ED_FUNC(e2, ED_touch));
} }
G_INT(GBL_self) = old_self; G_INT(GBL_self) = old_self;
@ -258,34 +258,34 @@ int32_t SV_FlyMove(edict_t *ent, float time, trace_t *steptrace)
numbumps = 4; numbumps = 4;
blocked = 0; blocked = 0;
VectorCopy(ent->v.velocity, original_velocity); VectorCopy(ED_VECTOR(ent, ED_velocity), original_velocity);
VectorCopy(ent->v.velocity, primal_velocity); VectorCopy(ED_VECTOR(ent, ED_velocity), primal_velocity);
numplanes = 0; numplanes = 0;
time_left = time; time_left = time;
for(bumpcount = 0 ; bumpcount < numbumps ; bumpcount++) for(bumpcount = 0 ; bumpcount < numbumps ; bumpcount++)
{ {
if(!ent->v.velocity[0] && !ent->v.velocity[1] && !ent->v.velocity[2]) if(!ED_VECTOR(ent, ED_velocity)[0] && !ED_VECTOR(ent, ED_velocity)[1] && !ED_VECTOR(ent, ED_velocity)[2])
break; break;
for(i = 0 ; i < 3 ; i++) for(i = 0 ; i < 3 ; i++)
end[i] = ent->v.origin[i] + time_left * ent->v.velocity[i]; end[i] = ED_VECTOR(ent, ED_origin)[i] + time_left * ED_VECTOR(ent, ED_velocity)[i];
trace = SV_Move(ent->v.origin, ent->v.mins, ent->v.maxs, end, false, ent); trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, false, ent);
if(trace.allsolid) if(trace.allsolid)
{ {
// entity is trapped in another solid // entity is trapped in another solid
VectorCopy(vec3_origin, ent->v.velocity); VectorCopy(vec3_origin, ED_VECTOR(ent, ED_velocity));
return 3; return 3;
} }
if(trace.fraction > 0) if(trace.fraction > 0)
{ {
// actually covered some distance // actually covered some distance
VectorCopy(trace.endpos, ent->v.origin); VectorCopy(trace.endpos, ED_VECTOR(ent, ED_origin));
VectorCopy(ent->v.velocity, original_velocity); VectorCopy(ED_VECTOR(ent, ED_velocity), original_velocity);
numplanes = 0; numplanes = 0;
} }
@ -298,10 +298,10 @@ int32_t SV_FlyMove(edict_t *ent, float time, trace_t *steptrace)
if(trace.plane.normal[2] > 0.7) if(trace.plane.normal[2] > 0.7)
{ {
blocked |= 1; // floor blocked |= 1; // floor
if(trace.ent->v.solid == SOLID_BSP) if(ED_FLOAT(trace.ent, ED_solid) == SOLID_BSP)
{ {
ent->v.flags = (int32_t)ent->v.flags | FL_ONGROUND; ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) | FL_ONGROUND;
ent->v.groundentity = EDICT_TO_PROG(trace.ent); ED_INT(ent, ED_groundentity) = EDICT_TO_PROG(trace.ent);
} }
} }
if(!trace.plane.normal[2]) if(!trace.plane.normal[2])
@ -325,7 +325,7 @@ int32_t SV_FlyMove(edict_t *ent, float time, trace_t *steptrace)
if(numplanes >= MAX_CLIP_PLANES) if(numplanes >= MAX_CLIP_PLANES)
{ {
// this shouldn't really happen // this shouldn't really happen
VectorCopy(vec3_origin, ent->v.velocity); VectorCopy(vec3_origin, ED_VECTOR(ent, ED_velocity));
return 3; return 3;
} }
@ -351,7 +351,7 @@ int32_t SV_FlyMove(edict_t *ent, float time, trace_t *steptrace)
if(i != numplanes) if(i != numplanes)
{ {
// go along this plane // go along this plane
VectorCopy(new_velocity, ent->v.velocity); VectorCopy(new_velocity, ED_VECTOR(ent, ED_velocity));
} }
else else
{ {
@ -359,21 +359,21 @@ int32_t SV_FlyMove(edict_t *ent, float time, trace_t *steptrace)
if(numplanes != 2) if(numplanes != 2)
{ {
// Con_Printf ("clip velocity, numplanes == %" PRIi32 "\n",numplanes); // Con_Printf ("clip velocity, numplanes == %" PRIi32 "\n",numplanes);
VectorCopy(vec3_origin, ent->v.velocity); VectorCopy(vec3_origin, ED_VECTOR(ent, ED_velocity));
return 7; return 7;
} }
CrossProduct(planes[0], planes[1], dir); CrossProduct(planes[0], planes[1], dir);
d = DotProduct(dir, ent->v.velocity); d = DotProduct(dir, ED_VECTOR(ent, ED_velocity));
VectorScale(dir, d, ent->v.velocity); VectorScale(dir, d, ED_VECTOR(ent, ED_velocity));
} }
// //
// if original velocity is against the original velocity, stop dead // if original velocity is against the original velocity, stop dead
// to avoid tiny occilations in sloping corners // to avoid tiny occilations in sloping corners
// //
if(DotProduct(ent->v.velocity, primal_velocity) <= 0) if(DotProduct(ED_VECTOR(ent, ED_velocity), primal_velocity) <= 0)
{ {
VectorCopy(vec3_origin, ent->v.velocity); VectorCopy(vec3_origin, ED_VECTOR(ent, ED_velocity));
return blocked; return blocked;
} }
} }
@ -399,7 +399,7 @@ void SV_AddGravity(edict_t *ent)
else else
ent_gravity = 1.0; ent_gravity = 1.0;
ent->v.velocity[2] -= ent_gravity * sv_gravity.value * host_frametime; ED_VECTOR(ent, ED_velocity)[2] -= ent_gravity * sv_gravity.value * host_frametime;
} }
@ -423,17 +423,17 @@ trace_t SV_PushEntity(edict_t *ent, vec3_t push)
trace_t trace; trace_t trace;
vec3_t end; vec3_t end;
VectorAdd(ent->v.origin, push, end); VectorAdd(ED_VECTOR(ent, ED_origin), push, end);
if(ent->v.movetype == MOVETYPE_FLYMISSILE) if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_FLYMISSILE)
trace = SV_Move(ent->v.origin, ent->v.mins, ent->v.maxs, end, MOVE_MISSILE, ent); trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, MOVE_MISSILE, ent);
else if(ent->v.solid == SOLID_TRIGGER || ent->v.solid == SOLID_NOT) else if(ED_FLOAT(ent, ED_solid) == SOLID_TRIGGER || ED_FLOAT(ent, ED_solid) == SOLID_NOT)
// only clip against bmodels // only clip against bmodels
trace = SV_Move(ent->v.origin, ent->v.mins, ent->v.maxs, end, MOVE_NOMONSTERS, ent); trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, MOVE_NOMONSTERS, ent);
else else
trace = SV_Move(ent->v.origin, ent->v.mins, ent->v.maxs, end, MOVE_NORMAL, ent); trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, MOVE_NORMAL, ent);
VectorCopy(trace.endpos, ent->v.origin); VectorCopy(trace.endpos, ED_VECTOR(ent, ED_origin));
SV_LinkEdict(ent, true); SV_LinkEdict(ent, true);
if(trace.ent) if(trace.ent)
@ -459,25 +459,25 @@ void SV_PushMove(edict_t *pusher, float movetime)
vec3_t *moved_from; //johnfitz -- dynamically allocate vec3_t *moved_from; //johnfitz -- dynamically allocate
int32_t mark; //johnfitz int32_t mark; //johnfitz
if(!pusher->v.velocity[0] && !pusher->v.velocity[1] && !pusher->v.velocity[2]) if(!ED_VECTOR(pusher, ED_velocity)[0] && !ED_VECTOR(pusher, ED_velocity)[1] && !ED_VECTOR(pusher, ED_velocity)[2])
{ {
pusher->v.ltime += movetime; ED_FLOAT(pusher, ED_ltime) += movetime;
return; return;
} }
for(i = 0 ; i < 3 ; i++) for(i = 0 ; i < 3 ; i++)
{ {
move[i] = pusher->v.velocity[i] * movetime; move[i] = ED_VECTOR(pusher, ED_velocity)[i] * movetime;
mins[i] = pusher->v.absmin[i] + move[i]; mins[i] = ED_VECTOR(pusher, ED_absmin)[i] + move[i];
maxs[i] = pusher->v.absmax[i] + move[i]; maxs[i] = ED_VECTOR(pusher, ED_absmax)[i] + move[i];
} }
VectorCopy(pusher->v.origin, pushorig); VectorCopy(ED_VECTOR(pusher, ED_origin), pushorig);
// move the pusher to it's final position // move the pusher to it's final position
VectorAdd(pusher->v.origin, move, pusher->v.origin); VectorAdd(ED_VECTOR(pusher, ED_origin), move, ED_VECTOR(pusher, ED_origin));
pusher->v.ltime += movetime; ED_FLOAT(pusher, ED_ltime) += movetime;
SV_LinkEdict(pusher, false); SV_LinkEdict(pusher, false);
//johnfitz -- dynamically allocate //johnfitz -- dynamically allocate
@ -493,21 +493,21 @@ void SV_PushMove(edict_t *pusher, float movetime)
{ {
if(check->free) if(check->free)
continue; continue;
if(check->v.movetype == MOVETYPE_PUSH if(ED_FLOAT(check, ED_movetype) == MOVETYPE_PUSH
|| check->v.movetype == MOVETYPE_NONE || ED_FLOAT(check, ED_movetype) == MOVETYPE_NONE
|| check->v.movetype == MOVETYPE_NOCLIP) || ED_FLOAT(check, ED_movetype) == MOVETYPE_NOCLIP)
continue; continue;
// if the entity is standing on the pusher, it will definately be moved // if the entity is standing on the pusher, it will definately be moved
if(!(((int32_t)check->v.flags & FL_ONGROUND) if(!(((int32_t)ED_FLOAT(check, ED_flags) & FL_ONGROUND)
&& PROG_TO_EDICT(check->v.groundentity) == pusher)) && PROG_TO_EDICT(ED_INT(check, ED_groundentity)) == pusher))
{ {
if(check->v.absmin[0] >= maxs[0] if(ED_VECTOR(check, ED_absmin)[0] >= maxs[0]
|| check->v.absmin[1] >= maxs[1] || ED_VECTOR(check, ED_absmin)[1] >= maxs[1]
|| check->v.absmin[2] >= maxs[2] || ED_VECTOR(check, ED_absmin)[2] >= maxs[2]
|| check->v.absmax[0] <= mins[0] || ED_VECTOR(check, ED_absmax)[0] <= mins[0]
|| check->v.absmax[1] <= mins[1] || ED_VECTOR(check, ED_absmax)[1] <= mins[1]
|| check->v.absmax[2] <= mins[2]) || ED_VECTOR(check, ED_absmax)[2] <= mins[2])
continue; continue;
// see if the ent's bbox is inside the pusher's final position // see if the ent's bbox is inside the pusher's final position
@ -516,54 +516,54 @@ void SV_PushMove(edict_t *pusher, float movetime)
} }
// remove the onground flag for non-players // remove the onground flag for non-players
if(check->v.movetype != MOVETYPE_WALK) if(ED_FLOAT(check, ED_movetype) != MOVETYPE_WALK)
check->v.flags = (int32_t)check->v.flags & ~FL_ONGROUND; ED_FLOAT(check, ED_flags) = (int32_t)ED_FLOAT(check, ED_flags) & ~FL_ONGROUND;
VectorCopy(check->v.origin, entorig); VectorCopy(ED_VECTOR(check, ED_origin), entorig);
VectorCopy(check->v.origin, moved_from[num_moved]); VectorCopy(ED_VECTOR(check, ED_origin), moved_from[num_moved]);
moved_edict[num_moved] = check; moved_edict[num_moved] = check;
num_moved++; num_moved++;
// try moving the contacted entity // try moving the contacted entity
pusher->v.solid = SOLID_NOT; ED_FLOAT(pusher, ED_solid) = SOLID_NOT;
SV_PushEntity(check, move); SV_PushEntity(check, move);
pusher->v.solid = SOLID_BSP; ED_FLOAT(pusher, ED_solid) = SOLID_BSP;
// if it is still inside the pusher, block // if it is still inside the pusher, block
block = SV_TestEntityPosition(check); block = SV_TestEntityPosition(check);
if(block) if(block)
{ {
// fail the move // fail the move
if(check->v.mins[0] == check->v.maxs[0]) if(ED_VECTOR(check, ED_mins)[0] == ED_VECTOR(check, ED_maxs)[0])
continue; continue;
if(check->v.solid == SOLID_NOT || check->v.solid == SOLID_TRIGGER) if(ED_FLOAT(check, ED_solid) == SOLID_NOT || ED_FLOAT(check, ED_solid) == SOLID_TRIGGER)
{ {
// corpse // corpse
check->v.mins[0] = check->v.mins[1] = 0; ED_VECTOR(check, ED_mins)[0] = ED_VECTOR(check, ED_mins)[1] = 0;
VectorCopy(check->v.mins, check->v.maxs); VectorCopy(ED_VECTOR(check, ED_mins), ED_VECTOR(check, ED_maxs));
continue; continue;
} }
VectorCopy(entorig, check->v.origin); VectorCopy(entorig, ED_VECTOR(check, ED_origin));
SV_LinkEdict(check, true); SV_LinkEdict(check, true);
VectorCopy(pushorig, pusher->v.origin); VectorCopy(pushorig, ED_VECTOR(pusher, ED_origin));
SV_LinkEdict(pusher, false); SV_LinkEdict(pusher, false);
pusher->v.ltime -= movetime; ED_FLOAT(pusher, ED_ltime) -= movetime;
// if the pusher has a "blocked" function, call it // if the pusher has a "blocked" function, call it
// otherwise, just stay in place until the obstacle is gone // otherwise, just stay in place until the obstacle is gone
if(pusher->v.blocked) if(ED_FUNC(pusher, ED_blocked))
{ {
G_INT(GBL_self) = EDICT_TO_PROG(pusher); G_INT(GBL_self) = EDICT_TO_PROG(pusher);
G_INT(GBL_other) = EDICT_TO_PROG(check); G_INT(GBL_other) = EDICT_TO_PROG(check);
PR_ExecuteProgram(pusher->v.blocked); PR_ExecuteProgram(ED_FUNC(pusher, ED_blocked));
} }
// move back any entities we already moved // move back any entities we already moved
for(i = 0 ; i < num_moved ; i++) for(i = 0 ; i < num_moved ; i++)
{ {
VectorCopy(moved_from[i], moved_edict[i]->v.origin); VectorCopy(moved_from[i], ED_VECTOR(moved_edict[i], ED_origin));
SV_LinkEdict(moved_edict[i], false); SV_LinkEdict(moved_edict[i], false);
} }
Hunk_FreeToLowMark(mark); //johnfitz Hunk_FreeToLowMark(mark); //johnfitz
@ -587,12 +587,12 @@ void SV_Physics_Pusher(edict_t *ent)
float oldltime; float oldltime;
float movetime; float movetime;
oldltime = ent->v.ltime; oldltime = ED_FLOAT(ent, ED_ltime);
thinktime = ent->v.nextthink; thinktime = ED_FLOAT(ent, ED_nextthink);
if(thinktime < ent->v.ltime + host_frametime) if(thinktime < ED_FLOAT(ent, ED_ltime) + host_frametime)
{ {
movetime = thinktime - ent->v.ltime; movetime = thinktime - ED_FLOAT(ent, ED_ltime);
if(movetime < 0) if(movetime < 0)
movetime = 0; movetime = 0;
} }
@ -601,16 +601,16 @@ void SV_Physics_Pusher(edict_t *ent)
if(movetime) if(movetime)
{ {
SV_PushMove(ent, movetime); // advances ent->v.ltime if not blocked SV_PushMove(ent, movetime); // advances ED_FLOAT(ent, ED_ltime) if not blocked
} }
if(thinktime > oldltime && thinktime <= ent->v.ltime) if(thinktime > oldltime && thinktime <= ED_FLOAT(ent, ED_ltime))
{ {
ent->v.nextthink = 0; ED_FLOAT(ent, ED_nextthink) = 0;
G_FLOAT(GBL_time) = sv.time; G_FLOAT(GBL_time) = sv.time;
G_INT(GBL_self) = EDICT_TO_PROG(ent); G_INT(GBL_self) = EDICT_TO_PROG(ent);
G_INT(GBL_other) = EDICT_TO_PROG(sv.edicts); G_INT(GBL_other) = EDICT_TO_PROG(sv.edicts);
PR_ExecuteProgram(ent->v.think); PR_ExecuteProgram(ED_FUNC(ent, ED_think));
if(ent->free) if(ent->free)
return; return;
} }
@ -642,12 +642,12 @@ void SV_CheckStuck(edict_t *ent)
if(!SV_TestEntityPosition(ent)) if(!SV_TestEntityPosition(ent))
{ {
VectorCopy(ent->v.origin, ent->v.oldorigin); VectorCopy(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_oldorigin));
return; return;
} }
VectorCopy(ent->v.origin, org); VectorCopy(ED_VECTOR(ent, ED_origin), org);
VectorCopy(ent->v.oldorigin, ent->v.origin); VectorCopy(ED_VECTOR(ent, ED_oldorigin), ED_VECTOR(ent, ED_origin));
if(!SV_TestEntityPosition(ent)) if(!SV_TestEntityPosition(ent))
{ {
Con_DPrintf("Unstuck.\n"); Con_DPrintf("Unstuck.\n");
@ -659,9 +659,9 @@ void SV_CheckStuck(edict_t *ent)
for(i = -1 ; i <= 1 ; i++) for(i = -1 ; i <= 1 ; i++)
for(j = -1 ; j <= 1 ; j++) for(j = -1 ; j <= 1 ; j++)
{ {
ent->v.origin[0] = org[0] + i; ED_VECTOR(ent, ED_origin)[0] = org[0] + i;
ent->v.origin[1] = org[1] + j; ED_VECTOR(ent, ED_origin)[1] = org[1] + j;
ent->v.origin[2] = org[2] + z; ED_VECTOR(ent, ED_origin)[2] = org[2] + z;
if(!SV_TestEntityPosition(ent)) if(!SV_TestEntityPosition(ent))
{ {
Con_DPrintf("Unstuck.\n"); Con_DPrintf("Unstuck.\n");
@ -670,7 +670,7 @@ void SV_CheckStuck(edict_t *ent)
} }
} }
VectorCopy(org, ent->v.origin); VectorCopy(org, ED_VECTOR(ent, ED_origin));
Con_DPrintf("player is stuck.\n"); Con_DPrintf("player is stuck.\n");
} }
@ -685,30 +685,30 @@ bool SV_CheckWater(edict_t *ent)
vec3_t point; vec3_t point;
int32_t cont; int32_t cont;
point[0] = ent->v.origin[0]; point[0] = ED_VECTOR(ent, ED_origin)[0];
point[1] = ent->v.origin[1]; point[1] = ED_VECTOR(ent, ED_origin)[1];
point[2] = ent->v.origin[2] + ent->v.mins[2] + 1; point[2] = ED_VECTOR(ent, ED_origin)[2] + ED_VECTOR(ent, ED_mins)[2] + 1;
ent->v.waterlevel = 0; ED_FLOAT(ent, ED_waterlevel) = 0;
ent->v.watertype = CONTENTS_EMPTY; ED_FLOAT(ent, ED_watertype) = CONTENTS_EMPTY;
cont = SV_PointContents(point); cont = SV_PointContents(point);
if(cont <= CONTENTS_WATER) if(cont <= CONTENTS_WATER)
{ {
ent->v.watertype = cont; ED_FLOAT(ent, ED_watertype) = cont;
ent->v.waterlevel = 1; ED_FLOAT(ent, ED_waterlevel) = 1;
point[2] = ent->v.origin[2] + (ent->v.mins[2] + ent->v.maxs[2]) * 0.5; point[2] = ED_VECTOR(ent, ED_origin)[2] + (ED_VECTOR(ent, ED_mins)[2] + ED_VECTOR(ent, ED_maxs)[2]) * 0.5;
cont = SV_PointContents(point); cont = SV_PointContents(point);
if(cont <= CONTENTS_WATER) if(cont <= CONTENTS_WATER)
{ {
ent->v.waterlevel = 2; ED_FLOAT(ent, ED_waterlevel) = 2;
point[2] = ent->v.origin[2] + ent->v.view_ofs[2]; point[2] = ED_VECTOR(ent, ED_origin)[2] + ED_VECTOR(ent, ED_view_ofs)[2];
cont = SV_PointContents(point); cont = SV_PointContents(point);
if(cont <= CONTENTS_WATER) if(cont <= CONTENTS_WATER)
ent->v.waterlevel = 3; ED_FLOAT(ent, ED_waterlevel) = 3;
} }
} }
return ent->v.waterlevel > 1; return ED_FLOAT(ent, ED_waterlevel) > 1;
} }
/* /*
@ -723,7 +723,7 @@ void SV_WallFriction(edict_t *ent, trace_t *trace)
float d, i; float d, i;
vec3_t into, side; vec3_t into, side;
AngleVectors(ent->v.v_angle, forward, right, up); AngleVectors(ED_VECTOR(ent, ED_v_angle), forward, right, up);
d = DotProduct(trace->plane.normal, forward); d = DotProduct(trace->plane.normal, forward);
d += 0.5; d += 0.5;
@ -731,12 +731,12 @@ void SV_WallFriction(edict_t *ent, trace_t *trace)
return; return;
// cut the tangential velocity // cut the tangential velocity
i = DotProduct(trace->plane.normal, ent->v.velocity); i = DotProduct(trace->plane.normal, ED_VECTOR(ent, ED_velocity));
VectorScale(trace->plane.normal, i, into); VectorScale(trace->plane.normal, i, into);
VectorSubtract(ent->v.velocity, into, side); VectorSubtract(ED_VECTOR(ent, ED_velocity), into, side);
ent->v.velocity[0] = side[0] * (1 + d); ED_VECTOR(ent, ED_velocity)[0] = side[0] * (1 + d);
ent->v.velocity[1] = side[1] * (1 + d); ED_VECTOR(ent, ED_velocity)[1] = side[1] * (1 + d);
} }
/* /*
@ -759,7 +759,7 @@ int32_t SV_TryUnstick(edict_t *ent, vec3_t oldvel)
int32_t clip; int32_t clip;
trace_t steptrace; trace_t steptrace;
VectorCopy(ent->v.origin, oldorg); VectorCopy(ED_VECTOR(ent, ED_origin), oldorg);
VectorCopy(vec3_origin, dir); VectorCopy(vec3_origin, dir);
for(i = 0 ; i < 8 ; i++) for(i = 0 ; i < 8 ; i++)
@ -804,23 +804,23 @@ int32_t SV_TryUnstick(edict_t *ent, vec3_t oldvel)
SV_PushEntity(ent, dir); SV_PushEntity(ent, dir);
// retry the original move // retry the original move
ent->v.velocity[0] = oldvel[0]; ED_VECTOR(ent, ED_velocity)[0] = oldvel[0];
ent->v. velocity[1] = oldvel[1]; ED_VECTOR(ent, ED_velocity)[1] = oldvel[1];
ent->v. velocity[2] = 0; ED_VECTOR(ent, ED_velocity)[2] = 0;
clip = SV_FlyMove(ent, 0.1, &steptrace); clip = SV_FlyMove(ent, 0.1, &steptrace);
if(fabs(oldorg[1] - ent->v.origin[1]) > 4 if(fabs(oldorg[1] - ED_VECTOR(ent, ED_origin)[1]) > 4
|| fabs(oldorg[0] - ent->v.origin[0]) > 4) || fabs(oldorg[0] - ED_VECTOR(ent, ED_origin)[0]) > 4)
{ {
//Con_DPrintf ("unstuck!\n"); //Con_DPrintf ("unstuck!\n");
return clip; return clip;
} }
// go back to the original pos and try again // go back to the original pos and try again
VectorCopy(oldorg, ent->v.origin); VectorCopy(oldorg, ED_VECTOR(ent, ED_origin));
} }
VectorCopy(vec3_origin, ent->v.velocity); VectorCopy(vec3_origin, ED_VECTOR(ent, ED_velocity));
return 7; // still not moving return 7; // still not moving
} }
@ -844,36 +844,36 @@ void SV_WalkMove(edict_t *ent)
// //
// do a regular slide move unless it looks like you ran into a step // do a regular slide move unless it looks like you ran into a step
// //
oldonground = (int32_t)ent->v.flags & FL_ONGROUND; oldonground = (int32_t)ED_FLOAT(ent, ED_flags) & FL_ONGROUND;
ent->v.flags = (int32_t)ent->v.flags & ~FL_ONGROUND; ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) & ~FL_ONGROUND;
VectorCopy(ent->v.origin, oldorg); VectorCopy(ED_VECTOR(ent, ED_origin), oldorg);
VectorCopy(ent->v.velocity, oldvel); VectorCopy(ED_VECTOR(ent, ED_velocity), oldvel);
clip = SV_FlyMove(ent, host_frametime, &steptrace); clip = SV_FlyMove(ent, host_frametime, &steptrace);
if(!(clip & 2)) if(!(clip & 2))
return; // move didn't block on a step return; // move didn't block on a step
if(!oldonground && ent->v.waterlevel == 0) if(!oldonground && ED_FLOAT(ent, ED_waterlevel) == 0)
return; // don't stair up while jumping return; // don't stair up while jumping
if(ent->v.movetype != MOVETYPE_WALK) if(ED_FLOAT(ent, ED_movetype) != MOVETYPE_WALK)
return; // gibbed by a trigger return; // gibbed by a trigger
if(sv_nostep.value) if(sv_nostep.value)
return; return;
if((int32_t)sv_player->v.flags & FL_WATERJUMP) if((int32_t)ED_FLOAT(sv_player, ED_flags) & FL_WATERJUMP)
return; return;
VectorCopy(ent->v.origin, nosteporg); VectorCopy(ED_VECTOR(ent, ED_origin), nosteporg);
VectorCopy(ent->v.velocity, nostepvel); VectorCopy(ED_VECTOR(ent, ED_velocity), nostepvel);
// //
// try moving up and forward to go up a step // try moving up and forward to go up a step
// //
VectorCopy(oldorg, ent->v.origin); // back to start pos VectorCopy(oldorg, ED_VECTOR(ent, ED_origin)); // back to start pos
VectorCopy(vec3_origin, upmove); VectorCopy(vec3_origin, upmove);
VectorCopy(vec3_origin, downmove); VectorCopy(vec3_origin, downmove);
@ -884,17 +884,17 @@ void SV_WalkMove(edict_t *ent)
SV_PushEntity(ent, upmove); // FIXME: don't link? SV_PushEntity(ent, upmove); // FIXME: don't link?
// move forward // move forward
ent->v.velocity[0] = oldvel[0]; ED_VECTOR(ent, ED_velocity)[0] = oldvel[0];
ent->v. velocity[1] = oldvel[1]; ED_VECTOR(ent, ED_velocity)[1] = oldvel[1];
ent->v. velocity[2] = 0; ED_VECTOR(ent, ED_velocity)[2] = 0;
clip = SV_FlyMove(ent, host_frametime, &steptrace); clip = SV_FlyMove(ent, host_frametime, &steptrace);
// check for stuckness, possibly due to the limited precision of floats // check for stuckness, possibly due to the limited precision of floats
// in the clipping hulls // in the clipping hulls
if(clip) if(clip)
{ {
if(fabs(oldorg[1] - ent->v.origin[1]) < 0.03125 if(fabs(oldorg[1] - ED_VECTOR(ent, ED_origin)[1]) < 0.03125
&& fabs(oldorg[0] - ent->v.origin[0]) < 0.03125) && fabs(oldorg[0] - ED_VECTOR(ent, ED_origin)[0]) < 0.03125)
{ {
// stepping up didn't make any progress // stepping up didn't make any progress
clip = SV_TryUnstick(ent, oldvel); clip = SV_TryUnstick(ent, oldvel);
@ -910,10 +910,10 @@ void SV_WalkMove(edict_t *ent)
if(downtrace.plane.normal[2] > 0.7) if(downtrace.plane.normal[2] > 0.7)
{ {
if(ent->v.solid == SOLID_BSP) if(ED_FLOAT(ent, ED_solid) == SOLID_BSP)
{ {
ent->v.flags = (int32_t)ent->v.flags | FL_ONGROUND; ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) | FL_ONGROUND;
ent->v.groundentity = EDICT_TO_PROG(downtrace.ent); ED_INT(ent, ED_groundentity) = EDICT_TO_PROG(downtrace.ent);
} }
} }
else else
@ -921,8 +921,8 @@ void SV_WalkMove(edict_t *ent)
// if the push down didn't end up on good ground, use the move without // 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 // 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 // cause the player to hop up higher on a slope too steep to climb
VectorCopy(nosteporg, ent->v.origin); VectorCopy(nosteporg, ED_VECTOR(ent, ED_origin));
VectorCopy(nostepvel, ent->v.velocity); VectorCopy(nostepvel, ED_VECTOR(ent, ED_velocity));
} }
} }
@ -954,7 +954,7 @@ void SV_Physics_Client(edict_t *ent, int32_t num)
// //
// decide which move function to call // decide which move function to call
// //
switch((int32_t)ent->v.movetype) switch((int32_t)ED_FLOAT(ent, ED_movetype))
{ {
case MOVETYPE_NONE: case MOVETYPE_NONE:
if(!SV_RunThink(ent)) if(!SV_RunThink(ent))
@ -964,7 +964,7 @@ void SV_Physics_Client(edict_t *ent, int32_t num)
case MOVETYPE_WALK: case MOVETYPE_WALK:
if(!SV_RunThink(ent)) if(!SV_RunThink(ent))
return; return;
if(!SV_CheckWater(ent) && !((int32_t)ent->v.flags & FL_WATERJUMP)) if(!SV_CheckWater(ent) && !((int32_t)ED_FLOAT(ent, ED_flags) & FL_WATERJUMP))
SV_AddGravity(ent); SV_AddGravity(ent);
SV_CheckStuck(ent); SV_CheckStuck(ent);
SV_WalkMove(ent); SV_WalkMove(ent);
@ -984,11 +984,11 @@ void SV_Physics_Client(edict_t *ent, int32_t num)
case MOVETYPE_NOCLIP: case MOVETYPE_NOCLIP:
if(!SV_RunThink(ent)) if(!SV_RunThink(ent))
return; return;
VectorMA(ent->v.origin, host_frametime, ent->v.velocity, ent->v.origin); VectorMA(ED_VECTOR(ent, ED_origin), host_frametime, ED_VECTOR(ent, ED_velocity), ED_VECTOR(ent, ED_origin));
break; break;
default: default:
Sys_Error("SV_Physics_client: bad movetype %" PRIi32 "", (int32_t)ent->v.movetype); Sys_Error("SV_Physics_client: bad movetype %" PRIi32 "", (int32_t)ED_FLOAT(ent, ED_movetype));
} }
// //
@ -1029,8 +1029,8 @@ void SV_Physics_Noclip(edict_t *ent)
if(!SV_RunThink(ent)) if(!SV_RunThink(ent))
return; return;
VectorMA(ent->v.angles, host_frametime, ent->v.avelocity, ent->v.angles); VectorMA(ED_VECTOR(ent, ED_angles), host_frametime, ED_VECTOR(ent, ED_avelocity), ED_VECTOR(ent, ED_angles));
VectorMA(ent->v.origin, host_frametime, ent->v.velocity, ent->v.origin); VectorMA(ED_VECTOR(ent, ED_origin), host_frametime, ED_VECTOR(ent, ED_velocity), ED_VECTOR(ent, ED_origin));
SV_LinkEdict(ent, false); SV_LinkEdict(ent, false);
} }
@ -1053,35 +1053,35 @@ void SV_CheckWaterTransition(edict_t *ent)
{ {
int32_t cont; int32_t cont;
cont = SV_PointContents(ent->v.origin); cont = SV_PointContents(ED_VECTOR(ent, ED_origin));
if(!ent->v.watertype) if(!ED_FLOAT(ent, ED_watertype))
{ {
// just spawned here // just spawned here
ent->v.watertype = cont; ED_FLOAT(ent, ED_watertype) = cont;
ent->v.waterlevel = 1; ED_FLOAT(ent, ED_waterlevel) = 1;
return; return;
} }
if(cont <= CONTENTS_WATER) if(cont <= CONTENTS_WATER)
{ {
if(ent->v.watertype == CONTENTS_EMPTY) if(ED_FLOAT(ent, ED_watertype) == CONTENTS_EMPTY)
{ {
// just crossed into water // just crossed into water
SV_StartSound(ent, 0, "misc/h2ohit1.wav", 255, 1); SV_StartSound(ent, 0, "misc/h2ohit1.wav", 255, 1);
} }
ent->v.watertype = cont; ED_FLOAT(ent, ED_watertype) = cont;
ent->v.waterlevel = 1; ED_FLOAT(ent, ED_waterlevel) = 1;
} }
else else
{ {
if(ent->v.watertype != CONTENTS_EMPTY) if(ED_FLOAT(ent, ED_watertype) != CONTENTS_EMPTY)
{ {
// just crossed into water // just crossed into water
SV_StartSound(ent, 0, "misc/h2ohit1.wav", 255, 1); SV_StartSound(ent, 0, "misc/h2ohit1.wav", 255, 1);
} }
ent->v.watertype = CONTENTS_EMPTY; ED_FLOAT(ent, ED_watertype) = CONTENTS_EMPTY;
ent->v.waterlevel = cont; ED_FLOAT(ent, ED_waterlevel) = cont;
} }
} }
@ -1103,43 +1103,43 @@ void SV_Physics_Toss(edict_t *ent)
return; return;
// if onground, return without moving // if onground, return without moving
if(((int32_t)ent->v.flags & FL_ONGROUND)) if(((int32_t)ED_FLOAT(ent, ED_flags) & FL_ONGROUND))
return; return;
SV_CheckVelocity(ent); SV_CheckVelocity(ent);
// add gravity // add gravity
if(ent->v.movetype != MOVETYPE_FLY if(ED_FLOAT(ent, ED_movetype) != MOVETYPE_FLY
&& ent->v.movetype != MOVETYPE_FLYMISSILE) && ED_FLOAT(ent, ED_movetype) != MOVETYPE_FLYMISSILE)
SV_AddGravity(ent); SV_AddGravity(ent);
// move angles // move angles
VectorMA(ent->v.angles, host_frametime, ent->v.avelocity, ent->v.angles); VectorMA(ED_VECTOR(ent, ED_angles), host_frametime, ED_VECTOR(ent, ED_avelocity), ED_VECTOR(ent, ED_angles));
// move origin // move origin
VectorScale(ent->v.velocity, host_frametime, move); VectorScale(ED_VECTOR(ent, ED_velocity), host_frametime, move);
trace = SV_PushEntity(ent, move); trace = SV_PushEntity(ent, move);
if(trace.fraction == 1) if(trace.fraction == 1)
return; return;
if(ent->free) if(ent->free)
return; return;
if(ent->v.movetype == MOVETYPE_BOUNCE) if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_BOUNCE)
backoff = 1.5; backoff = 1.5;
else else
backoff = 1; backoff = 1;
ClipVelocity(ent->v.velocity, trace.plane.normal, ent->v.velocity, backoff); ClipVelocity(ED_VECTOR(ent, ED_velocity), trace.plane.normal, ED_VECTOR(ent, ED_velocity), backoff);
// stop if on ground // stop if on ground
if(trace.plane.normal[2] > 0.7) if(trace.plane.normal[2] > 0.7)
{ {
if(ent->v.velocity[2] < 60 || ent->v.movetype != MOVETYPE_BOUNCE) if(ED_VECTOR(ent, ED_velocity)[2] < 60 || ED_FLOAT(ent, ED_movetype) != MOVETYPE_BOUNCE)
{ {
ent->v.flags = (int32_t)ent->v.flags | FL_ONGROUND; ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) | FL_ONGROUND;
ent->v.groundentity = EDICT_TO_PROG(trace.ent); ED_INT(ent, ED_groundentity) = EDICT_TO_PROG(trace.ent);
VectorCopy(vec3_origin, ent->v.velocity); VectorCopy(vec3_origin, ED_VECTOR(ent, ED_velocity));
VectorCopy(vec3_origin, ent->v.avelocity); VectorCopy(vec3_origin, ED_VECTOR(ent, ED_avelocity));
} }
} }
@ -1171,9 +1171,9 @@ void SV_Physics_Step(edict_t *ent)
bool hitsound; bool hitsound;
// freefall if not onground // freefall if not onground
if(!((int32_t)ent->v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) if(!((int32_t)ED_FLOAT(ent, ED_flags) & (FL_ONGROUND | FL_FLY | FL_SWIM)))
{ {
if(ent->v.velocity[2] < sv_gravity.value * -0.1) if(ED_VECTOR(ent, ED_velocity)[2] < sv_gravity.value * -0.1)
hitsound = true; hitsound = true;
else else
hitsound = false; hitsound = false;
@ -1183,7 +1183,7 @@ void SV_Physics_Step(edict_t *ent)
SV_FlyMove(ent, host_frametime, NULL); SV_FlyMove(ent, host_frametime, NULL);
SV_LinkEdict(ent, true); SV_LinkEdict(ent, true);
if((int32_t)ent->v.flags & FL_ONGROUND) // just hit ground if((int32_t)ED_FLOAT(ent, ED_flags) & FL_ONGROUND) // just hit ground
{ {
if(hitsound) if(hitsound)
SV_StartSound(ent, 0, "demon/dland2.wav", 255, 1); SV_StartSound(ent, 0, "demon/dland2.wav", 255, 1);
@ -1242,21 +1242,21 @@ void SV_Physics(void)
if(i > 0 && i <= svs.maxclients) if(i > 0 && i <= svs.maxclients)
SV_Physics_Client(ent, i); SV_Physics_Client(ent, i);
else if(ent->v.movetype == MOVETYPE_PUSH) else if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_PUSH)
SV_Physics_Pusher(ent); SV_Physics_Pusher(ent);
else if(ent->v.movetype == MOVETYPE_NONE) else if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_NONE)
SV_Physics_None(ent); SV_Physics_None(ent);
else if(ent->v.movetype == MOVETYPE_NOCLIP) else if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_NOCLIP)
SV_Physics_Noclip(ent); SV_Physics_Noclip(ent);
else if(ent->v.movetype == MOVETYPE_STEP) else if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_STEP)
SV_Physics_Step(ent); SV_Physics_Step(ent);
else if(ent->v.movetype == MOVETYPE_TOSS else if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_TOSS
|| ent->v.movetype == MOVETYPE_BOUNCE || ED_FLOAT(ent, ED_movetype) == MOVETYPE_BOUNCE
|| ent->v.movetype == MOVETYPE_FLY || ED_FLOAT(ent, ED_movetype) == MOVETYPE_FLY
|| ent->v.movetype == MOVETYPE_FLYMISSILE) || ED_FLOAT(ent, ED_movetype) == MOVETYPE_FLYMISSILE)
SV_Physics_Toss(ent); SV_Physics_Toss(ent);
else else
Sys_Error("SV_Physics: bad movetype %" PRIi32 "", (int32_t)ent->v.movetype); Sys_Error("SV_Physics: bad movetype %" PRIi32 "", (int32_t)ED_FLOAT(ent, ED_movetype));
} }
if(G_FLOAT(GBL_force_retouch)) if(G_FLOAT(GBL_force_retouch))

View File

@ -58,18 +58,18 @@ void SV_SetIdealPitch(void)
int32_t i, j; int32_t i, j;
int32_t step, dir, steps; int32_t step, dir, steps;
if(!((int32_t)sv_player->v.flags & FL_ONGROUND)) if(!((int32_t)ED_FLOAT(sv_player, ED_flags) & FL_ONGROUND))
return; return;
angleval = sv_player->v.angles[YAW] * PI * 2 / 360; angleval = ED_VECTOR(sv_player, ED_angles)[YAW] * PI * 2 / 360;
sinval = sin(angleval); sinval = sin(angleval);
cosval = cos(angleval); cosval = cos(angleval);
for(i = 0 ; i < MAX_FORWARD ; i++) for(i = 0 ; i < MAX_FORWARD ; i++)
{ {
top[0] = sv_player->v.origin[0] + cosval * (i + 3) * 12; top[0] = ED_VECTOR(sv_player, ED_origin)[0] + cosval * (i + 3) * 12;
top[1] = sv_player->v.origin[1] + sinval * (i + 3) * 12; top[1] = ED_VECTOR(sv_player, ED_origin)[1] + sinval * (i + 3) * 12;
top[2] = sv_player->v.origin[2] + sv_player->v.view_ofs[2]; top[2] = ED_VECTOR(sv_player, ED_origin)[2] + ED_VECTOR(sv_player, ED_view_ofs)[2];
bottom[0] = top[0]; bottom[0] = top[0];
bottom[1] = top[1]; bottom[1] = top[1];
@ -102,13 +102,13 @@ void SV_SetIdealPitch(void)
if(!dir) if(!dir)
{ {
sv_player->v.idealpitch = 0; ED_FLOAT(sv_player, ED_idealpitch) = 0;
return; return;
} }
if(steps < 2) if(steps < 2)
return; return;
sv_player->v.idealpitch = -dir * sv_idealpitchscale.value; ED_FLOAT(sv_player, ED_idealpitch) = -dir * sv_idealpitchscale.value;
} }
@ -135,7 +135,7 @@ void SV_UserFriction(void)
// if the leading edge is over a dropoff, increase friction // if the leading edge is over a dropoff, increase friction
start[0] = stop[0] = origin[0] + vel[0] / speed * 16; start[0] = stop[0] = origin[0] + vel[0] / speed * 16;
start[1] = stop[1] = origin[1] + vel[1] / 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] + ED_VECTOR(sv_player, ED_mins)[2];
stop[2] = start[2] - 34; stop[2] = start[2] - 34;
trace = SV_Move(start, vec3_origin, vec3_origin, stop, true, sv_player); trace = SV_Move(start, vec3_origin, vec3_origin, stop, true, sv_player);
@ -208,12 +208,12 @@ void DropPunchAngle(void)
{ {
float len; float len;
len = VectorNormalize(sv_player->v.punchangle); len = VectorNormalize(ED_VECTOR(sv_player, ED_punchangle));
len -= 10 * host_frametime; len -= 10 * host_frametime;
if(len < 0) if(len < 0)
len = 0; len = 0;
VectorScale(sv_player->v.punchangle, len, sv_player->v.punchangle); VectorScale(ED_VECTOR(sv_player, ED_punchangle), len, ED_VECTOR(sv_player, ED_punchangle));
} }
/* /*
@ -231,7 +231,7 @@ void SV_WaterMove(void)
// //
// user intentions // user intentions
// //
AngleVectors(sv_player->v.v_angle, forward, right, up); AngleVectors(ED_VECTOR(sv_player, ED_v_angle), forward, right, up);
for(i = 0 ; i < 3 ; i++) for(i = 0 ; i < 3 ; i++)
wishvel[i] = forward[i] * cmd.forwardmove + right[i] * cmd.sidemove; wishvel[i] = forward[i] * cmd.forwardmove + right[i] * cmd.sidemove;
@ -284,14 +284,14 @@ void SV_WaterMove(void)
void SV_WaterJump(void) void SV_WaterJump(void)
{ {
if(sv.time > sv_player->v.teleport_time if(sv.time > ED_FLOAT(sv_player, ED_teleport_time)
|| !sv_player->v.waterlevel) || !ED_FLOAT(sv_player, ED_waterlevel))
{ {
sv_player->v.flags = (int32_t)sv_player->v.flags & ~FL_WATERJUMP; ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) & ~FL_WATERJUMP;
sv_player->v.teleport_time = 0; ED_FLOAT(sv_player, ED_teleport_time) = 0;
} }
sv_player->v.velocity[0] = sv_player->v.movedir[0]; ED_VECTOR(sv_player, ED_velocity)[0] = ED_VECTOR(sv_player, ED_movedir)[0];
sv_player->v.velocity[1] = sv_player->v.movedir[1]; ED_VECTOR(sv_player, ED_velocity)[1] = ED_VECTOR(sv_player, ED_movedir)[1];
} }
/* /*
@ -303,7 +303,7 @@ new, alternate noclip. old noclip is still handled in SV_AirMove
*/ */
void SV_NoclipMove(void) void SV_NoclipMove(void)
{ {
AngleVectors(sv_player->v.v_angle, forward, right, up); AngleVectors(ED_VECTOR(sv_player, ED_v_angle), forward, right, up);
velocity[0] = forward[0] * cmd.forwardmove + right[0] * cmd.sidemove; velocity[0] = forward[0] * cmd.forwardmove + right[0] * cmd.sidemove;
velocity[1] = forward[1] * cmd.forwardmove + right[1] * cmd.sidemove; velocity[1] = forward[1] * cmd.forwardmove + right[1] * cmd.sidemove;
@ -329,19 +329,19 @@ void SV_AirMove(void)
float wishspeed; float wishspeed;
float fmove, smove; float fmove, smove;
AngleVectors(sv_player->v.angles, forward, right, up); AngleVectors(ED_VECTOR(sv_player, ED_angles), forward, right, up);
fmove = cmd.forwardmove; fmove = cmd.forwardmove;
smove = cmd.sidemove; smove = cmd.sidemove;
// hack to not let you back into teleporter // hack to not let you back into teleporter
if(sv.time < sv_player->v.teleport_time && fmove < 0) if(sv.time < ED_FLOAT(sv_player, ED_teleport_time) && fmove < 0)
fmove = 0; fmove = 0;
for(i = 0 ; i < 3 ; i++) for(i = 0 ; i < 3 ; i++)
wishvel[i] = forward[i] * fmove + right[i] * smove; wishvel[i] = forward[i] * fmove + right[i] * smove;
if((int32_t)sv_player->v.movetype != MOVETYPE_WALK) if((int32_t)ED_FLOAT(sv_player, ED_movetype) != MOVETYPE_WALK)
wishvel[2] = cmd.upmove; wishvel[2] = cmd.upmove;
else else
wishvel[2] = 0; wishvel[2] = 0;
@ -354,7 +354,7 @@ void SV_AirMove(void)
wishspeed = sv_maxspeed.value; wishspeed = sv_maxspeed.value;
} }
if(sv_player->v.movetype == MOVETYPE_NOCLIP) if(ED_FLOAT(sv_player, ED_movetype) == MOVETYPE_NOCLIP)
{ {
// noclip // noclip
VectorCopy(wishvel, velocity); VectorCopy(wishvel, velocity);
@ -383,37 +383,37 @@ void SV_ClientThink(void)
{ {
vec3_t v_angle; vec3_t v_angle;
if(sv_player->v.movetype == MOVETYPE_NONE) if(ED_FLOAT(sv_player, ED_movetype) == MOVETYPE_NONE)
return; return;
onground = (int32_t)sv_player->v.flags & FL_ONGROUND; onground = (int32_t)ED_FLOAT(sv_player, ED_flags) & FL_ONGROUND;
origin = sv_player->v.origin; origin = ED_VECTOR(sv_player, ED_origin);
velocity = sv_player->v.velocity; velocity = ED_VECTOR(sv_player, ED_velocity);
DropPunchAngle(); DropPunchAngle();
// //
// if dead, behave differently // if dead, behave differently
// //
if(sv_player->v.health <= 0) if(ED_FLOAT(sv_player, ED_health) <= 0)
return; return;
// //
// angles // angles
// show 1/3 the pitch angle and all the roll angle // show 1/3 the pitch angle and all the roll angle
cmd = host_client->cmd; cmd = host_client->cmd;
angles = sv_player->v.angles; angles = ED_VECTOR(sv_player, ED_angles);
VectorAdd(sv_player->v.v_angle, sv_player->v.punchangle, v_angle); VectorAdd(ED_VECTOR(sv_player, ED_v_angle), ED_VECTOR(sv_player, ED_punchangle), v_angle);
angles[ROLL] = V_CalcRoll(sv_player->v.angles, sv_player->v.velocity) * 4; angles[ROLL] = V_CalcRoll(ED_VECTOR(sv_player, ED_angles), ED_VECTOR(sv_player, ED_velocity)) * 4;
if(!sv_player->v.fixangle) if(!ED_FLOAT(sv_player, ED_fixangle))
{ {
angles[PITCH] = -v_angle[PITCH] / 3; angles[PITCH] = -v_angle[PITCH] / 3;
angles[YAW] = v_angle[YAW]; angles[YAW] = v_angle[YAW];
} }
if((int32_t)sv_player->v.flags & FL_WATERJUMP) if((int32_t)ED_FLOAT(sv_player, ED_flags) & FL_WATERJUMP)
{ {
SV_WaterJump(); SV_WaterJump();
return; return;
@ -422,9 +422,9 @@ void SV_ClientThink(void)
// walk // walk
// //
//johnfitz -- alternate noclip //johnfitz -- alternate noclip
if(sv_player->v.movetype == MOVETYPE_NOCLIP && sv_altnoclip.value) if(ED_FLOAT(sv_player, ED_movetype) == MOVETYPE_NOCLIP && sv_altnoclip.value)
SV_NoclipMove(); SV_NoclipMove();
else if(sv_player->v.waterlevel >= 2 && sv_player->v.movetype != MOVETYPE_NOCLIP) else if(ED_FLOAT(sv_player, ED_waterlevel) >= 2 && ED_FLOAT(sv_player, ED_movetype) != MOVETYPE_NOCLIP)
SV_WaterMove(); SV_WaterMove();
else else
SV_AirMove(); SV_AirMove();
@ -457,7 +457,7 @@ void SV_ReadClientMove(usercmd_t *move)
angle[i] = MSG_ReadAngle16(sv.protocolflags); angle[i] = MSG_ReadAngle16(sv.protocolflags);
//johnfitz //johnfitz
VectorCopy(angle, host_client->edict->v.v_angle); VectorCopy(angle, ED_VECTOR(host_client->edict, ED_v_angle));
// read movement // read movement
move->forwardmove = MSG_ReadShort(); move->forwardmove = MSG_ReadShort();
@ -466,12 +466,12 @@ void SV_ReadClientMove(usercmd_t *move)
// read buttons // read buttons
bits = MSG_ReadByte(); bits = MSG_ReadByte();
host_client->edict->v.button0 = bits & 1; ED_FLOAT(host_client->edict, ED_button0) = bits & 1;
host_client->edict->v.button2 = (bits & 2) >> 1; ED_FLOAT(host_client->edict, ED_button2) = (bits & 2) >> 1;
i = MSG_ReadByte(); i = MSG_ReadByte();
if(i) if(i)
host_client->edict->v.impulse = i; ED_FLOAT(host_client->edict, ED_impulse) = i;
} }
/* /*

View File

@ -137,18 +137,18 @@ hull_t *SV_HullForEntity(edict_t *ent, vec3_t mins, vec3_t maxs, vec3_t offset)
hull_t *hull; hull_t *hull;
// decide which clipping hull to use, based on the size // decide which clipping hull to use, based on the size
if(ent->v.solid == SOLID_BSP) if(ED_FLOAT(ent, ED_solid) == SOLID_BSP)
{ {
// explicit hulls in the BSP model // explicit hulls in the BSP model
if(ent->v.movetype != MOVETYPE_PUSH) if(ED_FLOAT(ent, ED_movetype) != MOVETYPE_PUSH)
Host_Error("SOLID_BSP without MOVETYPE_PUSH (%s at %f %f %f)", Host_Error("SOLID_BSP without MOVETYPE_PUSH (%s at %f %f %f)",
PR_GetString(ent->v.classname), ent->v.origin[0], ent->v.origin[1], ent->v.origin[2]); PR_GetString(ED_RSTRING(ent, ED_classname)), ED_VECTOR(ent, ED_origin)[0], ED_VECTOR(ent, ED_origin)[1], ED_VECTOR(ent, ED_origin)[2]);
model = sv.models[(int32_t)ent->v.modelindex ]; model = sv.models[(int32_t)ED_FLOAT(ent, ED_modelindex) ];
if(!model || model->type != mod_brush) if(!model || model->type != mod_brush)
Host_Error("SOLID_BSP with a non bsp model (%s at %f %f %f)", Host_Error("SOLID_BSP with a non bsp model (%s at %f %f %f)",
PR_GetString(ent->v.classname), ent->v.origin[0], ent->v.origin[1], ent->v.origin[2]); PR_GetString(ED_RSTRING(ent, ED_classname)), ED_VECTOR(ent, ED_origin)[0], ED_VECTOR(ent, ED_origin)[1], ED_VECTOR(ent, ED_origin)[2]);
VectorSubtract(maxs, mins, size); VectorSubtract(maxs, mins, size);
if(size[0] < 3) if(size[0] < 3)
@ -160,17 +160,17 @@ hull_t *SV_HullForEntity(edict_t *ent, vec3_t mins, vec3_t maxs, vec3_t offset)
// calculate an offset value to center the origin // calculate an offset value to center the origin
VectorSubtract(hull->clip_mins, mins, offset); VectorSubtract(hull->clip_mins, mins, offset);
VectorAdd(offset, ent->v.origin, offset); VectorAdd(offset, ED_VECTOR(ent, ED_origin), offset);
} }
else else
{ {
// create a temp hull from bounding box sizes // create a temp hull from bounding box sizes
VectorSubtract(ent->v.mins, maxs, hullmins); VectorSubtract(ED_VECTOR(ent, ED_mins), maxs, hullmins);
VectorSubtract(ent->v.maxs, mins, hullmaxs); VectorSubtract(ED_VECTOR(ent, ED_maxs), mins, hullmaxs);
hull = SV_HullForBox(hullmins, hullmaxs); hull = SV_HullForBox(hullmins, hullmaxs);
VectorCopy(ent->v.origin, offset); VectorCopy(ED_VECTOR(ent, ED_origin), offset);
} }
@ -297,14 +297,14 @@ SV_AreaTriggerEdicts(edict_t *ent, areanode_t *node, edict_t **list, int32_t *li
touch = EDICT_FROM_AREA(l); touch = EDICT_FROM_AREA(l);
if(touch == ent) if(touch == ent)
continue; continue;
if(!touch->v.touch || touch->v.solid != SOLID_TRIGGER) if(!ED_FUNC(touch, ED_touch) || ED_FLOAT(touch, ED_solid) != SOLID_TRIGGER)
continue; continue;
if(ent->v.absmin[0] > touch->v.absmax[0] if(ED_VECTOR(ent, ED_absmin)[0] > ED_VECTOR(touch, ED_absmax)[0]
|| ent->v.absmin[1] > touch->v.absmax[1] || ED_VECTOR(ent, ED_absmin)[1] > ED_VECTOR(touch, ED_absmax)[1]
|| ent->v.absmin[2] > touch->v.absmax[2] || ED_VECTOR(ent, ED_absmin)[2] > ED_VECTOR(touch, ED_absmax)[2]
|| ent->v.absmax[0] < touch->v.absmin[0] || ED_VECTOR(ent, ED_absmax)[0] < ED_VECTOR(touch, ED_absmin)[0]
|| ent->v.absmax[1] < touch->v.absmin[1] || ED_VECTOR(ent, ED_absmax)[1] < ED_VECTOR(touch, ED_absmin)[1]
|| ent->v.absmax[2] < touch->v.absmin[2]) || ED_VECTOR(ent, ED_absmax)[2] < ED_VECTOR(touch, ED_absmin)[2])
continue; continue;
if(*listcount == listspace) if(*listcount == listspace)
@ -318,9 +318,9 @@ SV_AreaTriggerEdicts(edict_t *ent, areanode_t *node, edict_t **list, int32_t *li
if(node->axis == -1) if(node->axis == -1)
return; return;
if(ent->v.absmax[node->axis] > node->dist) if(ED_VECTOR(ent, ED_absmax)[node->axis] > node->dist)
SV_AreaTriggerEdicts(ent, node->children[0], list, listcount, listspace); SV_AreaTriggerEdicts(ent, node->children[0], list, listcount, listspace);
if(ent->v.absmin[node->axis] < node->dist) if(ED_VECTOR(ent, ED_absmin)[node->axis] < node->dist)
SV_AreaTriggerEdicts(ent, node->children[1], list, listcount, listspace); SV_AreaTriggerEdicts(ent, node->children[1], list, listcount, listspace);
} }
@ -355,14 +355,14 @@ void SV_TouchLinks(edict_t *ent)
// edicts later in the list no longer touch // edicts later in the list no longer touch
if(touch == ent) if(touch == ent)
continue; continue;
if(!touch->v.touch || touch->v.solid != SOLID_TRIGGER) if(!ED_FUNC(touch, ED_touch) || ED_FLOAT(touch, ED_solid) != SOLID_TRIGGER)
continue; continue;
if(ent->v.absmin[0] > touch->v.absmax[0] if(ED_VECTOR(ent, ED_absmin)[0] > ED_VECTOR(touch, ED_absmax)[0]
|| ent->v.absmin[1] > touch->v.absmax[1] || ED_VECTOR(ent, ED_absmin)[1] > ED_VECTOR(touch, ED_absmax)[1]
|| ent->v.absmin[2] > touch->v.absmax[2] || ED_VECTOR(ent, ED_absmin)[2] > ED_VECTOR(touch, ED_absmax)[2]
|| ent->v.absmax[0] < touch->v.absmin[0] || ED_VECTOR(ent, ED_absmax)[0] < ED_VECTOR(touch, ED_absmin)[0]
|| ent->v.absmax[1] < touch->v.absmin[1] || ED_VECTOR(ent, ED_absmax)[1] < ED_VECTOR(touch, ED_absmin)[1]
|| ent->v.absmax[2] < touch->v.absmin[2]) || ED_VECTOR(ent, ED_absmax)[2] < ED_VECTOR(touch, ED_absmin)[2])
continue; continue;
old_self = G_INT(GBL_self); old_self = G_INT(GBL_self);
old_other = G_INT(GBL_other); old_other = G_INT(GBL_other);
@ -370,7 +370,7 @@ void SV_TouchLinks(edict_t *ent)
G_INT(GBL_self) = EDICT_TO_PROG(touch); G_INT(GBL_self) = EDICT_TO_PROG(touch);
G_INT(GBL_other) = EDICT_TO_PROG(ent); G_INT(GBL_other) = EDICT_TO_PROG(ent);
G_FLOAT(GBL_time) = sv.time; G_FLOAT(GBL_time) = sv.time;
PR_ExecuteProgram(touch->v.touch); PR_ExecuteProgram(ED_FUNC(touch, ED_touch));
G_INT(GBL_self) = old_self; G_INT(GBL_self) = old_self;
G_INT(GBL_other) = old_other; G_INT(GBL_other) = old_other;
@ -415,7 +415,7 @@ void SV_FindTouchedLeafs(edict_t *ent, mnode_t *node)
// NODE_MIXED // NODE_MIXED
splitplane = node->plane; splitplane = node->plane;
sides = BOX_ON_PLANE_SIDE(ent->v.absmin, ent->v.absmax, splitplane); sides = BOX_ON_PLANE_SIDE(ED_VECTOR(ent, ED_absmin), ED_VECTOR(ent, ED_absmax), splitplane);
// recurse down the contacted sides // recurse down the contacted sides
if(sides & 1) if(sides & 1)
@ -445,38 +445,38 @@ void SV_LinkEdict(edict_t *ent, bool touch_triggers)
return; return;
// set the abs box // set the abs box
VectorAdd(ent->v.origin, ent->v.mins, ent->v.absmin); VectorAdd(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_absmin));
VectorAdd(ent->v.origin, ent->v.maxs, ent->v.absmax); VectorAdd(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_maxs), ED_VECTOR(ent, ED_absmax));
// //
// to make items easier to pick up and allow them to be grabbed off // to make items easier to pick up and allow them to be grabbed off
// of shelves, the abs sizes are expanded // of shelves, the abs sizes are expanded
// //
if((int32_t)ent->v.flags & FL_ITEM) if((int32_t)ED_FLOAT(ent, ED_flags) & FL_ITEM)
{ {
ent->v.absmin[0] -= 15; ED_VECTOR(ent, ED_absmin)[0] -= 15;
ent->v.absmin[1] -= 15; ED_VECTOR(ent, ED_absmin)[1] -= 15;
ent->v.absmax[0] += 15; ED_VECTOR(ent, ED_absmax)[0] += 15;
ent->v.absmax[1] += 15; ED_VECTOR(ent, ED_absmax)[1] += 15;
} }
else else
{ {
// because movement is clipped an epsilon away from an actual edge, // because movement is clipped an epsilon away from an actual edge,
// we must fully check even when bounding boxes don't quite touch // we must fully check even when bounding boxes don't quite touch
ent->v.absmin[0] -= 1; ED_VECTOR(ent, ED_absmin)[0] -= 1;
ent->v.absmin[1] -= 1; ED_VECTOR(ent, ED_absmin)[1] -= 1;
ent->v.absmin[2] -= 1; ED_VECTOR(ent, ED_absmin)[2] -= 1;
ent->v.absmax[0] += 1; ED_VECTOR(ent, ED_absmax)[0] += 1;
ent->v.absmax[1] += 1; ED_VECTOR(ent, ED_absmax)[1] += 1;
ent->v.absmax[2] += 1; ED_VECTOR(ent, ED_absmax)[2] += 1;
} }
// link to PVS leafs // link to PVS leafs
ent->num_leafs = 0; ent->num_leafs = 0;
if(ent->v.modelindex) if(ED_FLOAT(ent, ED_modelindex))
SV_FindTouchedLeafs(ent, sv.worldmodel->nodes); SV_FindTouchedLeafs(ent, sv.worldmodel->nodes);
if(ent->v.solid == SOLID_NOT) if(ED_FLOAT(ent, ED_solid) == SOLID_NOT)
return; return;
// find the first node that the ent's box crosses // find the first node that the ent's box crosses
@ -485,9 +485,9 @@ void SV_LinkEdict(edict_t *ent, bool touch_triggers)
{ {
if(node->axis == -1) if(node->axis == -1)
break; break;
if(ent->v.absmin[node->axis] > node->dist) if(ED_VECTOR(ent, ED_absmin)[node->axis] > node->dist)
node = node->children[0]; node = node->children[0];
else if(ent->v.absmax[node->axis] < node->dist) else if(ED_VECTOR(ent, ED_absmax)[node->axis] < node->dist)
node = node->children[1]; node = node->children[1];
else else
break; // crosses the node break; // crosses the node
@ -495,7 +495,7 @@ void SV_LinkEdict(edict_t *ent, bool touch_triggers)
// link it in // link it in
if(ent->v.solid == SOLID_TRIGGER) if(ED_FLOAT(ent, ED_solid) == SOLID_TRIGGER)
InsertLinkBefore(&ent->area, &node->trigger_edicts); InsertLinkBefore(&ent->area, &node->trigger_edicts);
else else
InsertLinkBefore(&ent->area, &node->solid_edicts); InsertLinkBefore(&ent->area, &node->solid_edicts);
@ -583,7 +583,7 @@ edict_t *SV_TestEntityPosition(edict_t *ent)
{ {
trace_t trace; trace_t trace;
trace = SV_Move(ent->v.origin, ent->v.mins, ent->v.maxs, ent->v.origin, 0, ent); trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), ED_VECTOR(ent, ED_origin), 0, ent);
if(trace.startsolid) if(trace.startsolid)
return sv.edicts; return sv.edicts;
@ -794,25 +794,25 @@ void SV_ClipToLinks(areanode_t *node, moveclip_t *clip)
{ {
next = l->next; next = l->next;
touch = EDICT_FROM_AREA(l); touch = EDICT_FROM_AREA(l);
if(touch->v.solid == SOLID_NOT) if(ED_FLOAT(touch, ED_solid) == SOLID_NOT)
continue; continue;
if(touch == clip->passedict) if(touch == clip->passedict)
continue; continue;
if(touch->v.solid == SOLID_TRIGGER) if(ED_FLOAT(touch, ED_solid) == SOLID_TRIGGER)
Sys_Error("Trigger in clipping list"); Sys_Error("Trigger in clipping list");
if(clip->type == MOVE_NOMONSTERS && touch->v.solid != SOLID_BSP) if(clip->type == MOVE_NOMONSTERS && ED_FLOAT(touch, ED_solid) != SOLID_BSP)
continue; continue;
if(clip->boxmins[0] > touch->v.absmax[0] if(clip->boxmins[0] > ED_VECTOR(touch, ED_absmax)[0]
|| clip->boxmins[1] > touch->v.absmax[1] || clip->boxmins[1] > ED_VECTOR(touch, ED_absmax)[1]
|| clip->boxmins[2] > touch->v.absmax[2] || clip->boxmins[2] > ED_VECTOR(touch, ED_absmax)[2]
|| clip->boxmaxs[0] < touch->v.absmin[0] || clip->boxmaxs[0] < ED_VECTOR(touch, ED_absmin)[0]
|| clip->boxmaxs[1] < touch->v.absmin[1] || clip->boxmaxs[1] < ED_VECTOR(touch, ED_absmin)[1]
|| clip->boxmaxs[2] < touch->v.absmin[2]) || clip->boxmaxs[2] < ED_VECTOR(touch, ED_absmin)[2])
continue; continue;
if(clip->passedict && clip->passedict->v.size[0] && !touch->v.size[0]) if(clip->passedict && ED_VECTOR(clip->passedict, ED_size)[0] && !ED_VECTOR(touch, ED_size)[0])
continue; // points never interact continue; // points never interact
// might intersect, so do an exact clip // might intersect, so do an exact clip
@ -820,13 +820,13 @@ void SV_ClipToLinks(areanode_t *node, moveclip_t *clip)
return; return;
if(clip->passedict) if(clip->passedict)
{ {
if(PROG_TO_EDICT(touch->v.owner) == clip->passedict) if(PROG_TO_EDICT(ED_INT(touch, ED_owner)) == clip->passedict)
continue; // don't clip against own missiles continue; // don't clip against own missiles
if(PROG_TO_EDICT(clip->passedict->v.owner) == touch) if(PROG_TO_EDICT(ED_INT(clip->passedict, ED_owner)) == touch)
continue; // don't clip against owner continue; // don't clip against owner
} }
if((int32_t)touch->v.flags & FL_MONSTER) if((int32_t)ED_FLOAT(touch, ED_flags) & FL_MONSTER)
trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins2, clip->maxs2, clip->end); trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins2, clip->maxs2, clip->end);
else else
trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins, clip->maxs, clip->end); trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins, clip->maxs, clip->end);

View File

@ -57,7 +57,7 @@ void SV_UnlinkEdict(edict_t *ent);
void SV_LinkEdict(edict_t *ent, bool touch_triggers); void SV_LinkEdict(edict_t *ent, bool touch_triggers);
// Needs to be called any time an entity changes origin, mins, maxs, or solid // Needs to be called any time an entity changes origin, mins, maxs, or solid
// flags ent->v.modified // flags ent->v.modified
// sets ent->v.absmin and ent->v.absmax // sets ED_VECTOR(ent, ED_absmin) and ED_VECTOR(ent, ED_absmax)
// if touchtriggers, calls prog functions for the intersected triggers // if touchtriggers, calls prog functions for the intersected triggers
int32_t SV_PointContents(vec3_t p); int32_t SV_PointContents(vec3_t p);