mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
various portability improvements
This commit is contained in:
parent
f0c03f8331
commit
9d0320cc89
6 changed files with 17 additions and 20 deletions
|
@ -111,7 +111,6 @@ ED_ClearEdict (progs_t * pr, edict_t *e, int val)
|
|||
Sys_Printf("clearing reserved edict %d\n", NUM_FOR_EDICT(pr,e));
|
||||
for (i=0; i < pr->progs->entityfields; i++)
|
||||
e->v[i].integer_var = val;
|
||||
//memset (&e->v, 0, pr->progs->entityfields * 4);
|
||||
e->free = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -259,8 +259,8 @@ check_branch (progs_t *pr, dstatement_t *st, opcode_t *op, short offset)
|
|||
|
||||
address += offset;
|
||||
if (address < 0 || address >= pr->progs->numstatements)
|
||||
PR_Error (pr, "PR_Check_Opcodes: invalid branch (statement %d: %s)\n",
|
||||
(int)(st - pr->pr_statements), op->opname);
|
||||
PR_Error (pr, "PR_Check_Opcodes: invalid branch (statement %ld: %s)\n",
|
||||
(long)(st - pr->pr_statements), op->opname);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -269,9 +269,9 @@ check_global (progs_t *pr, dstatement_t *st, opcode_t *op, etype_t type,
|
|||
{
|
||||
if (type == ev_void && operand) {
|
||||
if (st->op != OP_RETURN && st->op != OP_DONE) //FIXME need better "not used flags"
|
||||
PR_Error (pr, "PR_Check_Opcodes: non-zero global index in void operand (statement %d: %s)\n", (int)(st - pr->pr_statements), op->opname);
|
||||
PR_Error (pr, "PR_Check_Opcodes: non-zero global index in void operand (statement %ld: %s)\n", (long)(st - pr->pr_statements), op->opname);
|
||||
} else if (operand >= pr->progs->numglobals) {
|
||||
PR_Error (pr, "PR_Check_Opcodes: out of bounds global index (statement %d: %s)\n", (int)(st - pr->pr_statements), op->opname);
|
||||
PR_Error (pr, "PR_Check_Opcodes: out of bounds global index (statement %ld: %s)\n", (long)(st - pr->pr_statements), op->opname);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,8 +287,8 @@ PR_Check_Opcodes (progs_t *pr)
|
|||
op = PR_Opcode (st->op);
|
||||
if (!op) {
|
||||
PR_Error (pr,
|
||||
"PR_Check_Opcodes: unknown opcode %d at statement %d\n",
|
||||
st->op, (int)(st - pr->pr_statements));
|
||||
"PR_Check_Opcodes: unknown opcode %d at statement %ld\n",
|
||||
st->op, (long)(st - pr->pr_statements));
|
||||
}
|
||||
switch (st->op) {
|
||||
case OP_IF:
|
||||
|
|
|
@ -548,7 +548,7 @@ COM_LoadFile (const char *path, int usehunk)
|
|||
if (!buf)
|
||||
Sys_Error ("COM_LoadFile: not enough space for %s", path);
|
||||
|
||||
((byte *) buf)[len] = 0;
|
||||
buf[len] = 0;
|
||||
Qread (h, buf, len);
|
||||
Qclose (h);
|
||||
|
||||
|
|
|
@ -98,8 +98,8 @@ SZ_Print (sizebuf_t *buf, const char *data)
|
|||
|
||||
if (!buf->cursize || buf->data[buf->cursize - 1])
|
||||
// no trailing 0
|
||||
memcpy ((byte *) SZ_GetSpace (buf, len), data, len);
|
||||
memcpy (SZ_GetSpace (buf, len), data, len);
|
||||
else
|
||||
// write over trailing 0
|
||||
memcpy ((byte *) SZ_GetSpace (buf, len - 1) - 1, data, len);
|
||||
memcpy (SZ_GetSpace (buf, len - 1) - 1, data, len);
|
||||
}
|
||||
|
|
|
@ -208,20 +208,17 @@ SL_InsB (server_entry_t *start, server_entry_t *place, char *ip, char *desc)
|
|||
void
|
||||
SL_Swap (server_entry_t *swap1, server_entry_t *swap2)
|
||||
{
|
||||
int i;
|
||||
server_entry_t *next1, *next2, *prev1, *prev2;
|
||||
server_entry_t temp;
|
||||
|
||||
next1 = swap1->next;
|
||||
next2 = swap2->next;
|
||||
prev1 = swap1->prev;
|
||||
prev2 = swap2->prev;
|
||||
|
||||
for (i = 0; i < sizeof(server_entry_t); i++)
|
||||
{
|
||||
((char *)swap1)[i] ^= ((char *)swap2)[i];
|
||||
((char *)swap2)[i] ^= ((char *)swap1)[i];
|
||||
((char *)swap1)[i] ^= ((char *)swap2)[i];
|
||||
}
|
||||
temp = *swap1;
|
||||
*swap1 = *swap2;
|
||||
*swap2 = temp;
|
||||
|
||||
swap1->next = next1;
|
||||
swap2->next = next2;
|
||||
|
|
|
@ -122,7 +122,7 @@ NetadrToSockadr (netadr_t *a, struct sockaddr_in *s)
|
|||
void
|
||||
SockadrToNetadr (struct sockaddr_in *s, netadr_t *a)
|
||||
{
|
||||
*(int *) &a->ip = *(int *) &s->sin_addr;
|
||||
memcpy (&a->ip, &s->sin_addr, 4);
|
||||
a->port = s->sin_port;
|
||||
}
|
||||
|
||||
|
@ -195,11 +195,12 @@ NET_StringToAdr (const char *s, netadr_t *a)
|
|||
}
|
||||
|
||||
if (copy[0] >= '0' && copy[0] <= '9') {
|
||||
*(int *) &sadr.sin_addr = inet_addr (copy);
|
||||
int addr = inet_addr (copy);
|
||||
memcpy (&sadr.sin_addr, &addr, 4);
|
||||
} else {
|
||||
if (!(h = gethostbyname (copy)))
|
||||
return 0;
|
||||
*(int *) &sadr.sin_addr = *(int *) h->h_addr_list[0];
|
||||
memcpy (&sadr.sin_addr, h->h_addr_list[0], 4);
|
||||
}
|
||||
|
||||
SockadrToNetadr (&sadr, a);
|
||||
|
|
Loading…
Reference in a new issue