[gamecode] Use unsigned for entity values

I don't know why they were ever signed (oversight at id and just
propagated?). Anyway, this resulted in "unsigned" spreading a bit, but
all to reasonable places.
This commit is contained in:
Bill Currie 2022-01-16 22:15:18 +09:00
parent 2b82533526
commit 0bd05c71ac
28 changed files with 117 additions and 128 deletions

View file

@ -276,8 +276,8 @@ void PR_BoundsCheck (progs_t *pr, int addr, etype_t type);
struct edict_s {
qboolean free;
progs_t *pr; ///< progs owning this edict
int entnum; ///< number of this entity
int edict; ///< offset of this entity in pr_edict_area
pr_uint_t entnum; ///< number of this entity
pr_uint_t edict; ///< offset of this entity in pr_edict_area
float freetime; ///< sv.time when the object was freed
void *edata; ///< external per-edict data
};
@ -286,8 +286,8 @@ struct edict_s {
void ED_ClearEdict (progs_t *pr, edict_t *e, int val);
edict_t *ED_Alloc (progs_t *pr);
void ED_Free (progs_t *pr, edict_t *ed);
edict_t *ED_EdictNum(progs_t *pr, pr_int_t n) __attribute__((pure));
pr_int_t ED_NumForEdict(progs_t *pr, edict_t *e) __attribute__((pure));
edict_t *ED_EdictNum(progs_t *pr, pr_uint_t n) __attribute__((pure));
pr_uint_t ED_NumForEdict(progs_t *pr, edict_t *e) __attribute__((pure));
void ED_Count (progs_t *pr);
qboolean PR_EdictValid (progs_t *pr, pr_uint_t e) __attribute__((pure));
@ -1896,9 +1896,9 @@ struct progs_s {
/// \todo FIXME should this be outside the VM?
///@{
edict_t **pr_edicts;
int max_edicts; ///< set by user
int *num_edicts;
int *reserved_edicts; ///< alloc will start at reserved_edicts+1
pr_uint_t max_edicts; ///< set by user
pr_uint_t *num_edicts;
pr_uint_t *reserved_edicts; ///< alloc will start at reserved_edicts+1
void (*unlink) (edict_t *ent);
void (*flush) (void);
int (*prune_edict) (progs_t *pr, edict_t *ent);
@ -1964,7 +1964,7 @@ struct progs_s {
struct {
double *dtime; ///< required for OP_STATE d
float *ftime; ///< required for OP_STATE f
pr_int_t *self; ///< required for OP_STATE
pr_uint_t *self; ///< required for OP_STATE
pointer_t *stack; ///< required for OP_(PUSH|POP)*
} globals;
struct {

View file

@ -537,7 +537,7 @@ typedef union pr_type_u {
float float_var;
string_t string_var;
func_t func_var;
pr_int_t entity_var;
pr_uint_t entity_var;
float vector_var; // really [3], but this structure must be 32 bits
float quat_var; // really [4], but this structure must be 32 bits
pr_int_t integer_var;

View file

@ -268,7 +268,7 @@ void NET_AddCachedHost (const char *name, const char *map, const char *cname,
extern double net_time;
extern struct msg_s *net_message;
extern int net_activeconnections;
extern unsigned net_activeconnections;
/** Initialize the networking sub-system.
*/

View file

@ -1266,7 +1266,7 @@ pr_debug_entity_view (qfot_type_t *type, pr_type_t *value, void *_data)
progs_t *pr = data->pr;
dstring_t *dstr = data->dstr;
if (pr->pr_edicts && value->entity_var >= 0
if (pr->pr_edicts
&& value->entity_var < pr->max_edicts
&& !(value->entity_var % pr->pr_edict_size)) {
edict_t *edict = PROG_TO_EDICT (pr, value->entity_var);

View file

@ -68,7 +68,7 @@ ED_ClearEdict (progs_t *pr, edict_t *e, int val)
VISIBLE edict_t *
ED_Alloc (progs_t *pr)
{
pr_int_t i;
pr_uint_t i;
edict_t *e;
int start = pr->reserved_edicts ? *pr->reserved_edicts : 0;
@ -149,7 +149,7 @@ ED_PrintNum (progs_t *pr, pr_int_t ent, const char *fieldname)
VISIBLE void
ED_PrintEdicts (progs_t *pr, const char *fieldval)
{
pr_int_t i;
pr_uint_t i;
int count;
pr_def_t *def;
@ -183,7 +183,6 @@ ED_PrintEdicts (progs_t *pr, const char *fieldval)
VISIBLE void
ED_Count (progs_t *pr)
{
pr_int_t i;
int active, models, solid, step, zombie;
pr_def_t *solid_def;
pr_def_t *model_def;
@ -196,7 +195,7 @@ ED_Count (progs_t *pr)
solid_def = PR_FindField (pr, "solid");
model_def = PR_FindField (pr, "model");
active = models = solid = step = zombie = 0;
for (i = 0; i < *pr->num_edicts; i++) {
for (pr_uint_t i = 0; i < *pr->num_edicts; i++) {
ent = EDICT_NUM (pr, i);
if (ent->free) {
if (pr->globals.ftime && *pr->globals.ftime - ent->freetime <= 0.5)//FIXME double time
@ -218,22 +217,22 @@ ED_Count (progs_t *pr)
}
edict_t *
ED_EdictNum (progs_t *pr, pr_int_t n)
ED_EdictNum (progs_t *pr, pr_uint_t n)
{
if (n < 0 || n >= *pr->num_edicts)
if (n >= *pr->num_edicts)
PR_RunError (pr, "EDICT_NUM: bad number %d", n);
return PR_edicts(pr) + n;
}
pr_int_t
pr_uint_t
ED_NumForEdict (progs_t *pr, edict_t *e)
{
pr_int_t b;
pr_uint_t b;
b = NUM_FOR_BAD_EDICT (pr, e);
if (b && (b < 0 || b >= *pr->num_edicts))
if (b && b >= *pr->num_edicts)
PR_RunError (pr, "NUM_FOR_EDICT: bad pointer %d %p %p", b, e,
pr->pr_edicts);

View file

@ -150,7 +150,7 @@ PR_ResolveGlobals (progs_t *pr)
if (!pr->globals.self) {
if ((def = PR_FindGlobal (pr, ".self"))
|| (def = PR_FindGlobal (pr, "self")))
pr->globals.self = &G_INT (pr, def->ofs);
pr->globals.self = &G_UINT (pr, def->ofs);
}
if (!pr->globals.stack) {
if ((def = PR_FindGlobal (pr, ".stack"))

View file

@ -78,7 +78,7 @@ PollProcedure slistPollProcedure = { NULL, 0.0, Slist_Poll };
static sizebuf_t _net_message_message;
static qmsg_t _net_message = { 0, 0, &_net_message_message };
qmsg_t *net_message = &_net_message;
int net_activeconnections = 0;
unsigned net_activeconnections = 0;
int messagesSent = 0;
int messagesReceived = 0;
@ -197,7 +197,7 @@ NET_Listen_f (void)
static void
MaxPlayers_f (void)
{
int n;
unsigned n;
if (Cmd_Argc () != 2) {
Sys_Printf ("\"maxplayers\" is \"%u\"\n", svs.maxclients);
@ -710,7 +710,7 @@ int
NET_SendToAll (sizebuf_t *data, double blocktime)
{
double start;
int i;
unsigned i;
int count = 0;
qboolean state1[MAX_SCOREBOARD]; /* can we send */
qboolean state2[MAX_SCOREBOARD]; /* did we send */

View file

@ -652,7 +652,7 @@ _Datagram_CheckNewConnections (void)
if (command == CCREQ_PLAYER_INFO) {
int playerNumber;
int activeNumber;
int clientNumber;
unsigned clientNumber;
client_t *client;
playerNumber = MSG_ReadByte (net_message);

View file

@ -253,7 +253,7 @@ PF_Find (progs_t *pr)
{
const char *s = 0, *t; // ev_string
int i; // ev_vector
int e, f;
pr_uint_t e, f;
etype_t type;
pr_def_t *field_def;
edict_t *ed;
@ -394,7 +394,7 @@ PF_ceil (progs_t *pr)
static void
PF_nextent (progs_t *pr)
{
int i;
pr_uint_t i;
edict_t *ent;
i = P_EDICTNUM (pr, 0);

View file

@ -44,8 +44,8 @@ extern progs_t sv_pr_state;
typedef struct
{
int maxclients;
int maxclientslimit;
unsigned maxclients;
unsigned maxclientslimit;
struct client_s *clients; // [maxclients]
void (*phys_client) (struct edict_s *ent, int num);
int serverflags; // episode completion information
@ -75,7 +75,7 @@ typedef struct
struct model_s *models[MAX_MODELS];
const char *sound_precache[MAX_SOUNDS]; // NULL terminated
const char *lightstyles[MAX_LIGHTSTYLES];
int num_edicts;
unsigned num_edicts;
int max_edicts;
edict_t *edicts; // can NOT be array indexed, because
// edict_t is variable sized, but can

View file

@ -38,9 +38,9 @@
#include "sv_pr_cmds.h"
typedef struct {
pr_int_t *self;
pr_int_t *other;
pr_int_t *world;
pr_uint_t *self;
pr_uint_t *other;
pr_uint_t *world;
float *time;
float *frametime;
float *force_retouch;
@ -64,13 +64,13 @@ typedef struct {
vec3_t *trace_endpos;
vec3_t *trace_plane_normal;
float *trace_plane_dist;
pr_int_t *trace_ent;
pr_uint_t *trace_ent;
float *trace_inopen;
float *trace_inwater;
pr_int_t *msg_entity;
pr_uint_t *msg_entity;
string_t *null;
pr_int_t *newmis;
pr_uint_t *newmis;
} sv_globals_t;
extern sv_globals_t sv_globals;

View file

@ -323,7 +323,6 @@ void
SV_BroadcastPrintf (const char *fmt, ...)
{
static dstring_t *str;
int i;
va_list argptr;
if (!str)
@ -333,7 +332,7 @@ SV_BroadcastPrintf (const char *fmt, ...)
dvsprintf (str, fmt, argptr);
va_end (argptr);
for (i = 0; i < svs.maxclients; i++)
for (unsigned i = 0; i < svs.maxclients; i++)
if (svs.clients[i].active && svs.clients[i].spawned) {
MSG_WriteByte (&svs.clients[i].message, svc_print);
MSG_WriteString (&svs.clients[i].message, str->str);
@ -372,7 +371,8 @@ void
SV_DropClient (qboolean crash)
{
client_t *client;
int saveSelf, i;
unsigned i;
pr_uint_t saveSelf;
if (!crash) {
// send any final messages (don't check for errors)
@ -406,7 +406,8 @@ SV_DropClient (qboolean crash)
net_activeconnections--;
// send notification to all clients
for (i = 0, client = svs.clients; i < svs.maxclients; i++, client++) {
for (i = 0, client = svs.clients; i < svs.maxclients;
i++, client++) {
if (!client->active)
continue;
MSG_WriteByte (&client->message, svc_updatename);
@ -431,7 +432,7 @@ Host_ShutdownServer (qboolean crash)
{
byte message[4];
double start;
int count, i;
unsigned count, i;
sizebuf_t buf;
if (!sv.active)
@ -711,7 +712,7 @@ Host_Frame (float time)
{
double time1, time2;
static double timetotal;
int i, c, m;
int c, m;
static int timecount;
if (!serverprofile->int_val) {
@ -733,7 +734,7 @@ Host_Frame (float time)
timecount = 0;
timetotal = 0;
c = 0;
for (i = 0; i < svs.maxclients; i++) {
for (unsigned i = 0; i < svs.maxclients; i++) {
if (svs.clients[i].active)
c++;
}

View file

@ -78,7 +78,7 @@ Host_Status_f (void)
int seconds;
int minutes;
int hours = 0;
int j;
unsigned j;
__attribute__((format(PRINTF, 1, 2))) void (*print) (const char *fmt, ...);
if (cmd_source == src_command) {
@ -210,7 +210,7 @@ Host_Fly_f (void)
static void
Host_Ping_f (void)
{
int i, j;
unsigned i, j;
float total;
client_t *client;
@ -421,7 +421,7 @@ static plitem_t *
entities_array (void)
{
plitem_t *entities = PL_NewArray ();
int i;
pr_uint_t i;
for (i = 0; i < sv.num_edicts; i++) {
PL_A_AddObject (entities,
@ -517,7 +517,6 @@ Host_Savegame_f (void)
const char *save_name;
char *save_text;
QFile *f;
int i;
char *bup1, *bup2 = 0;
@ -549,7 +548,7 @@ Host_Savegame_f (void)
return;
}
for (i = 0; i < svs.maxclients; i++) {
for (unsigned i = 0; i < svs.maxclients; i++) {
if (svs.clients[i].active && (SVfloat (svs.clients[i].edict, health)
<= 0)) {
Sys_Printf ("Can't savegame with a dead player\n");
@ -562,7 +561,7 @@ Host_Savegame_f (void)
if (strcmp (save_name, "quick") == 0) {
bup2 = nva ("%s/%s%d.sav", qfs_gamedir->dir.def, save_name, MAX_QUICK);
QFS_Remove (bup2);
for (i = MAX_QUICK - 1; i > 0; i--) {
for (int i = MAX_QUICK - 1; i > 0; i--) {
bup1 = nva ("%s/%s%d.sav", qfs_gamedir->dir.def, save_name, i);
QFS_Rename (bup1, bup2);
free (bup2);
@ -783,7 +782,7 @@ Host_Say (qboolean teamonly)
{
client_t *client;
client_t *save;
int j;
unsigned j;
char *p;
char text[64];
qboolean fromServer = false;
@ -817,7 +816,7 @@ Host_Say (qboolean teamonly)
snprintf (text, sizeof (text), "%c<%s> ", 1, hostname->string);
j = sizeof (text) - 2 - strlen (text); // -2 for /n and null terminator
if ((int) strlen (p) > j)
if (strlen (p) > j)
p[j] = 0;
strcat (text, p);
@ -854,7 +853,7 @@ Host_Tell_f (void)
{
client_t *client;
client_t *save;
int j;
unsigned j;
char *p;
char text[64];
@ -879,7 +878,7 @@ Host_Tell_f (void)
}
// check length & truncate if necessary
j = sizeof (text) - 2 - strlen (text); // -2 for /n and null terminator
if ((int) strlen (p) > j)
if (strlen (p) > j)
p[j] = 0;
strcat (text, p);
@ -969,7 +968,7 @@ Host_PreSpawn_f (void)
static void
Host_Spawn_f (void)
{
int i;
unsigned i;
client_t *client;
edict_t *ent;
float *sendangles;
@ -1099,7 +1098,7 @@ Host_Kick_f (void)
const char *who;
const char *message = NULL;
client_t *save;
int i;
unsigned i;
qboolean byNumber = false;
if (cmd_source == src_command) {
@ -1115,7 +1114,7 @@ Host_Kick_f (void)
if (Cmd_Argc () > 2 && strcmp (Cmd_Argv (1), "#") == 0) {
i = atof (Cmd_Argv (2)) - 1;
if (i < 0 || i >= svs.maxclients)
if (i >= svs.maxclients)
return;
if (!svs.clients[i].active)
return;
@ -1291,7 +1290,7 @@ Host_Give_f (void)
static edict_t *
FindViewthing (void)
{
int i;
pr_uint_t i;
edict_t *e;
for (i = 0; i < sv.num_edicts; i++) {

View file

@ -351,7 +351,7 @@ SV_ConnectClient (int clientnum)
void
SV_CheckForNewClients (void)
{
int i;
unsigned i;
struct qsocket_s *ret;
// check for new connections
@ -443,7 +443,7 @@ SV_FatPVS (vec3_t org)
static void
SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
{
int bits, e, i;
pr_uint_t bits, e;
set_t *pvs;
float miss;
vec3_t org;
@ -489,7 +489,7 @@ SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
bits = 0;
for (i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
miss = SVvector (ent, origin)[i] - baseline->origin[i];
if (miss < -0.1 || miss > 0.1)
bits |= U_ORIGIN1 << i;
@ -603,7 +603,7 @@ SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
static void
SV_CleanupEnts (void)
{
int e;
pr_uint_t e;
edict_t *ent;
ent = NEXT_EDICT (&sv_pr_state, sv.edicts);
@ -826,7 +826,7 @@ SV_SendClientDatagram (client_t *client)
static void
SV_UpdateToReliableMessages (void)
{
int i, j;
unsigned i, j;
client_t *client;
// check for changes to be sent over the reliable streams
@ -884,7 +884,7 @@ SV_SendNop (client_t *client)
void
SV_SendClientMessages (void)
{
int i;
unsigned i;
// update frags, names, etc
SV_UpdateToReliableMessages ();
@ -964,7 +964,7 @@ SV_ModelIndex (const char *name)
static void
SV_CreateBaseline (void)
{
int entnum;
pr_uint_t entnum;
edict_t *svent;
entity_state_t *baseline;
int bits;
@ -1077,7 +1077,7 @@ SV_SendReconnect (void)
void
SV_SaveSpawnparms (void)
{
int i, j;
unsigned i, j;
svs.serverflags = *sv_globals.serverflags;
@ -1161,7 +1161,7 @@ SV_SpawnServer (const char *server)
// leave slots at start for only clients
sv.num_edicts = svs.maxclients + 1;
for (int i = 0; i < svs.maxclients; i++) {
for (unsigned i = 0; i < svs.maxclients; i++) {
ent = EDICT_NUM (&sv_pr_state, i + 1);
svs.clients[i].edict = ent;
}
@ -1243,7 +1243,7 @@ SV_SpawnServer (const char *server)
sv.signon.cursize);
// send serverinfo to all connected clients
for (int i = 0; i < svs.maxclients; i++) {
for (unsigned i = 0; i < svs.maxclients; i++) {
host_client = svs.clients + i;
if (host_client->active) {
SV_SendServerinfo (host_client);

View file

@ -414,7 +414,7 @@ static qboolean
SV_Push (edict_t *pusher, const vec3_t tmove, const vec3_t amove)
{
float solid_save;
int num_moved, i, e;
int num_moved, i;
edict_t *check, *block;
edict_t **moved_edict;
vec3_t move, org, org2;
@ -455,7 +455,7 @@ SV_Push (edict_t *pusher, const vec3_t tmove, const vec3_t amove)
// see if any solid entities are inside the final position
num_moved = 0;
check = NEXT_EDICT (&sv_pr_state, sv.edicts);
for (e = 1; e < sv.num_edicts;
for (unsigned e = 1; e < sv.num_edicts;
e++, check = NEXT_EDICT (&sv_pr_state, check)) {
if (check->free)
continue;
@ -854,14 +854,14 @@ void
SV_Physics (void)
{
edict_t *ent;
int i;
SV_ProgStartFrame ();
// treat each object in turn
// even the world gets a chance to think
ent = sv.edicts;
for (i = 0; i < sv.num_edicts; i++, ent = NEXT_EDICT (&sv_pr_state, ent)) {
for (unsigned i = 0; i < sv.num_edicts;
i++, ent = NEXT_EDICT (&sv_pr_state, ent)) {
if (ent->free)
continue;

View file

@ -304,7 +304,7 @@ PF_sprint (progs_t *pr)
{
const char *s;
client_t *client;
int entnum;
unsigned entnum;
entnum = P_EDICTNUM (pr, 0);
s = PF_VarString (pr, 1);
@ -333,7 +333,7 @@ PF_centerprint (progs_t *pr)
{
const char *s;
client_t *cl;
int entnum;
unsigned entnum;
entnum = P_EDICTNUM (pr, 0);
s = PF_VarString (pr, 1);
@ -542,11 +542,11 @@ PF_checkpos (progs_t *pr)
static set_t *checkpvs;
static int
PF_newcheckclient (progs_t *pr, int check)
static unsigned
PF_newcheckclient (progs_t *pr, unsigned check)
{
edict_t *ent;
int i;
unsigned i;
mleaf_t *leaf;
vec3_t org;
@ -656,7 +656,7 @@ PF_stuffcmd (progs_t *pr)
{
const char *str;
client_t *old;
int entnum;
pr_uint_t entnum;
entnum = P_EDICTNUM (pr, 0);
if (entnum < 1 || entnum > svs.maxclients)
@ -700,7 +700,7 @@ PF_findradius (progs_t *pr)
edict_t *ent, *chain;
float rsqr;
vec_t *emins, *emaxs, *org;
int i, j;
pr_uint_t i;
vec3_t eorg;
chain = (edict_t *) sv.edicts;
@ -717,7 +717,7 @@ PF_findradius (progs_t *pr)
continue;
emins = SVvector (ent, absmin);
emaxs = SVvector (ent, absmax);
for (j = 0; j < 3; j++)
for (int j = 0; j < 3; j++)
eorg[j] = org[j] - 0.5 * (emins[j] + emaxs[j]);
if (DotProduct (eorg, eorg) > rsqr)
continue;
@ -903,7 +903,8 @@ PF_lightstyle (progs_t *pr)
{
const char *val;
client_t *cl;
int style, j;
int style;
unsigned j;
style = P_FLOAT (pr, 0);
val = P_GSTRING (pr, 1);
@ -960,7 +961,7 @@ PF_aim (progs_t *pr)
edict_t *ent, *check, *bestent;
float dist, bestdist, speed;
float *mins, *maxs, *org;
int i, j;
pr_uint_t i;
trace_t tr;
vec3_t start, dir, end, bestdir;
@ -1000,7 +1001,7 @@ PF_aim (progs_t *pr)
mins = SVvector (check, mins);
maxs = SVvector (check, maxs);
org = SVvector (check, origin);
for (j = 0; j < 3; j++)
for (int j = 0; j < 3; j++)
end[j] = org[j] + 0.5 * (mins[j] + maxs[j]);
VectorSubtract (end, start, dir);
VectorNormalize (dir);
@ -1075,7 +1076,7 @@ PF_changeyaw (progs_t *pr)
static __attribute__((pure)) sizebuf_t *
WriteDest (progs_t *pr)
{
int entnum;
pr_uint_t entnum;
int dest;
edict_t *ent;
@ -1256,7 +1257,7 @@ PF_setspawnparms (progs_t *pr)
{
client_t *client;
edict_t *ent;
int i;
unsigned i;
ent = P_EDICT (pr, 0);
i = NUM_FOR_EDICT (pr, ent);

View file

@ -584,7 +584,7 @@ SV_ReadClientMessage (void)
void
SV_RunClients (void)
{
int i;
unsigned i;
for (i = 0, host_client = svs.clients; i < svs.maxclients;
i++, host_client++) {

View file

@ -780,11 +780,10 @@ SV_ClipToLinks (areanode_t *node, moveclip_t *clip)
edict_t *touch;
link_t *l, *next;
trace_t trace;
int i;
if (clip->type == TL_EVERYTHING) {
touch = NEXT_EDICT (&sv_pr_state, sv.edicts);
for (i = 1; i < sv.num_edicts; i++,
for (unsigned i = 1; i < sv.num_edicts; i++,
touch = NEXT_EDICT (&sv_pr_state, touch)) {
if (clip->trace.allsolid)
return;
@ -897,7 +896,6 @@ SV_Move (const vec3_t start, const vec3_t mins, const vec3_t maxs,
edict_t *
SV_TestPlayerPosition (edict_t *ent, const vec3_t origin)
{
int e;
edict_t *check;
hull_t *hull;
vec3_t boxmins, boxmaxs, offset;
@ -912,8 +910,8 @@ SV_TestPlayerPosition (edict_t *ent, const vec3_t origin)
VectorAdd (origin, SVvector (ent, maxs), boxmaxs);
check = NEXT_EDICT (&sv_pr_state, sv.edicts);
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state,
check)) {
for (unsigned e = 1; e < sv.num_edicts;
e++, check = NEXT_EDICT (&sv_pr_state, check)) {
if (check->free)
continue;
if (check == ent)

View file

@ -81,7 +81,7 @@ typedef struct {
const char *lightstyles[MAX_LIGHTSTYLES];
struct model_s *models[MAX_MODELS];
int num_edicts; // increases towards MAX_EDICTS
unsigned num_edicts; // increases towards MAX_EDICTS
struct edict_s *edicts; // can NOT be array indexed, because
// struct edict_s is variable sized, but can
// be used to reference the world ent
@ -304,8 +304,8 @@ typedef struct {
int spawncount; // number of servers spawned since start,
// used to check late spawns
client_t clients[MAX_CLIENTS];
int maxclients;
int num_clients;
unsigned maxclients;
unsigned num_clients;
int serverflags; // episode completion information
void (*phys_client) (struct edict_s *ent, int num);

View file

@ -38,12 +38,12 @@
#include "sv_pr_cmds.h"
typedef struct {
pr_int_t *self;
pr_int_t *other;
pr_int_t *world;
pr_uint_t *self;
pr_uint_t *other;
pr_uint_t *world;
float *time;
float *frametime;
pr_int_t *newmis;
pr_uint_t *newmis;
float *force_retouch;
string_t *mapname;
float *serverflags;
@ -61,10 +61,10 @@ typedef struct {
vec3_t *trace_endpos;
vec3_t *trace_plane_normal;
float *trace_plane_dist;
pr_int_t *trace_ent;
pr_uint_t *trace_ent;
float *trace_inopen;
float *trace_inwater;
pr_int_t *msg_entity;
pr_uint_t *msg_entity;
float *skill;
} sv_globals_t;

View file

@ -122,11 +122,8 @@ SV_FlushSignon (void)
static void
SV_CreateBaseline (void)
{
int entnum;
edict_t *svent;
for (entnum = 0; entnum < sv.num_edicts; entnum++) {
svent = EDICT_NUM (&sv_pr_state, entnum);
for (unsigned entnum = 0; entnum < sv.num_edicts; entnum++) {
edict_t *svent = EDICT_NUM (&sv_pr_state, entnum);
if (svent->free)
continue;
// create baselines for all player slots,

View file

@ -417,7 +417,7 @@ static qboolean
SV_Push (edict_t *pusher, const vec3_t tmove, const vec3_t amove)
{
float solid_save;
int num_moved, i, e;
int num_moved, i;
edict_t *check, *block;
edict_t **moved_edict;
vec3_t move, org, org2;
@ -458,7 +458,7 @@ SV_Push (edict_t *pusher, const vec3_t tmove, const vec3_t amove)
// see if any solid entities are inside the final position
num_moved = 0;
check = NEXT_EDICT (&sv_pr_state, sv.edicts);
for (e = 1; e < sv.num_edicts;
for (unsigned e = 1; e < sv.num_edicts;
e++, check = NEXT_EDICT (&sv_pr_state, check)) {
if (check->free)
continue;
@ -862,14 +862,14 @@ void
SV_Physics (void)
{
edict_t *ent;
int i;
SV_ProgStartFrame ();
// treat each object in turn
// even the world gets a chance to think
ent = sv.edicts;
for (i = 0; i < sv.num_edicts; i++, ent = NEXT_EDICT (&sv_pr_state, ent)) {
for (unsigned i = 0; i < sv.num_edicts;
i++, ent = NEXT_EDICT (&sv_pr_state, ent)) {
if (ent->free)
continue;

View file

@ -653,7 +653,6 @@ PF_findradius (progs_t *pr)
edict_t *ent, *chain;
float rsqr;
vec_t *emins, *emaxs, *org;
int i, j;
vec3_t eorg;
chain = (edict_t *) sv.edicts;
@ -663,7 +662,7 @@ PF_findradius (progs_t *pr)
rsqr *= rsqr; // Square early, sqrt never
ent = NEXT_EDICT (pr, sv.edicts);
for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT (pr, ent)) {
for (unsigned i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT (pr, ent)) {
if (ent->free)
continue;
if (SVfloat (ent, solid) == SOLID_NOT
@ -671,7 +670,7 @@ PF_findradius (progs_t *pr)
continue;
emins = SVvector (ent, absmin);
emaxs = SVvector (ent, absmax);
for (j = 0; j < 3; j++)
for (int j = 0; j < 3; j++)
eorg[j] = org[j] - 0.5 * (emins[j] + emaxs[j]);
if (DotProduct (eorg, eorg) > rsqr)
continue;
@ -936,7 +935,7 @@ PF_aim (progs_t *pr)
edict_t *ent, *check, *bestent;
float dist, bestdist, speed;
float *mins, *maxs, *org;
int i, j;
unsigned i, j;
trace_t tr;
vec3_t start, dir, end, bestdir;

View file

@ -65,7 +65,7 @@ cvar_t *pr_checkextensions;
cvar_t *sv_old_entity_free;
cvar_t *sv_hide_version_info;
static int reserved_edicts = MAX_CLIENTS;
static pr_uint_t reserved_edicts = MAX_CLIENTS;
static int sv_range;

View file

@ -491,16 +491,13 @@ SV_Spawn_f (void *unused)
static void
SV_SpawnSpectator (void)
{
int i;
edict_t *e;
VectorZero (SVvector (sv_player, origin));
VectorZero (SVvector (sv_player, view_ofs));
SVvector (sv_player, view_ofs)[2] = 22;
// search for an info_playerstart to spawn the spectator at
for (i = MAX_CLIENTS - 1; i < sv.num_edicts; i++) {
e = EDICT_NUM (&sv_pr_state, i);
for (unsigned i = MAX_CLIENTS - 1; i < sv.num_edicts; i++) {
edict_t *e = EDICT_NUM (&sv_pr_state, i);
if (!strcmp (PR_GetString (&sv_pr_state, SVstring (e, classname)),
"info_player_start")) {
VectorCopy (SVvector (e, origin), SVvector (sv_player, origin));
@ -1516,7 +1513,7 @@ static void
AddLinksToPmove (areanode_t *node)
{
edict_t *check;
int pl, i;
pr_uint_t pl, i;
link_t *l, *next;
physent_t *pe;

View file

@ -818,11 +818,10 @@ SV_ClipToLinks (areanode_t *node, moveclip_t *clip)
edict_t *touch;
link_t *l, *next;
trace_t trace;
int i;
if (clip->type & MOVE_EVERYTHING) {
touch = NEXT_EDICT (&sv_pr_state, sv.edicts);
for (i = 1; i < sv.num_edicts; i++,
for (unsigned i = 1; i < sv.num_edicts; i++,
touch = NEXT_EDICT (&sv_pr_state, touch)) {
if (clip->trace.allsolid)
return;
@ -985,7 +984,6 @@ SV_Move (const vec3_t start, const vec3_t mins, const vec3_t maxs,
edict_t *
SV_TestPlayerPosition (edict_t *ent, const vec3_t origin)
{
int e;
edict_t *check;
hull_t *hull;
vec3_t boxmins, boxmaxs, offset;
@ -1000,8 +998,8 @@ SV_TestPlayerPosition (edict_t *ent, const vec3_t origin)
VectorAdd (origin, SVvector (ent, maxs), boxmaxs);
check = NEXT_EDICT (&sv_pr_state, sv.edicts);
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state,
check)) {
for (unsigned e = 1; e < sv.num_edicts;
e++, check = NEXT_EDICT (&sv_pr_state, check)) {
if (check->free)
continue;
if (check == ent)

View file

@ -126,8 +126,8 @@ static const char *short_options =
;
static edict_t *edicts;
static int num_edicts;
static int reserved_edicts = 1;
static pr_uint_t num_edicts;
static pr_uint_t reserved_edicts = 1;
static progs_t pr;
static qfo_t *qfo;

View file

@ -75,8 +75,8 @@ static const char *short_options =
static edict_t test_edicts[MAX_EDICTS];
static edict_t *edicts;
static int num_edicts;
static int reserved_edicts;
static pr_uint_t num_edicts;
static pr_uint_t reserved_edicts;
static progs_t test_pr;
static const char *this_program;