diff --git a/nq/source/net_udp.c b/nq/source/net_udp.c index 6f9eb19bd..1f7ab6b31 100644 --- a/nq/source/net_udp.c +++ b/nq/source/net_udp.c @@ -35,8 +35,6 @@ #ifdef HAVE_STRINGS_H # include #endif - -#include #ifdef HAVE_SYS_SOCKET_H # include #endif @@ -61,27 +59,26 @@ #ifdef HAVE_WINSOCK_H # include #endif +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef __sun__ +# include +#endif +#ifdef NeXT +# include +#endif + #include #include +#include -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef __sun__ -#include -#endif - -#ifdef NeXT -#include -#endif - -#include "compat.h" #include "QF/cvar.h" #include "QF/qargs.h" #include "QF/sys.h" #include "QF/console.h" +#include "compat.h" #include "net.h" #ifdef _WIN32 @@ -97,9 +94,9 @@ #ifndef HAVE_SOCKLEN_T # ifdef HAVE_SIZE - typedef size_t socklen_t; + typedef size_t socklen_t; # else - typedef unsigned int socklen_t; + typedef unsigned int socklen_t; # endif #endif @@ -107,7 +104,6 @@ extern int close (int); static int net_acceptsocket = -1; // socket for fielding new - // connections static int net_controlsocket; static int net_broadcastsocket = 0; @@ -117,7 +113,6 @@ static unsigned long myAddr; #include "net_udp.h" -//============================================================================= int UDP_Init (void) @@ -148,7 +143,8 @@ UDP_Init (void) Sys_Error ("UDP_Init: Unable to open control socket\n"); ((struct sockaddr_in *) &broadcastaddr)->sin_family = AF_INET; - ((struct sockaddr_in *) &broadcastaddr)->sin_addr.s_addr = INADDR_BROADCAST; + ((struct sockaddr_in *) &broadcastaddr)->sin_addr.s_addr = + INADDR_BROADCAST; ((struct sockaddr_in *) &broadcastaddr)->sin_port = htons (net_hostport); UDP_GetSocketAddr (net_controlsocket, &addr); @@ -163,8 +159,6 @@ UDP_Init (void) return net_controlsocket; } -//============================================================================= - void UDP_Shutdown (void) { @@ -172,8 +166,6 @@ UDP_Shutdown (void) UDP_CloseSocket (net_controlsocket); } -//============================================================================= - void UDP_Listen (qboolean state) { @@ -192,8 +184,6 @@ UDP_Listen (qboolean state) net_acceptsocket = -1; } -//============================================================================= - int UDP_OpenSocket (int port) { @@ -225,8 +215,6 @@ UDP_OpenSocket (int port) return -1; } -//============================================================================= - int UDP_CloseSocket (int socket) { @@ -235,26 +223,18 @@ UDP_CloseSocket (int socket) return close (socket); } - -//============================================================================= /* -============ -PartialIPAddress + PartialIPAddress -this lets you type only as much of the net address as required, using -the local network components to fill in the rest -============ + this lets you type only as much of the net address as required, using + the local network components to fill in the rest */ static int PartialIPAddress (const char *in, struct qsockaddr *hostaddr) { char buff[256]; char *b; - int addr; - int num; - int mask; - int run; - int port; + int addr, mask, num, port, run; buff[0] = '.'; b = buff; @@ -294,7 +274,6 @@ PartialIPAddress (const char *in, struct qsockaddr *hostaddr) return 0; } -//============================================================================= int UDP_Connect (int socket, struct qsockaddr *addr) @@ -302,8 +281,6 @@ UDP_Connect (int socket, struct qsockaddr *addr) return 0; } -//============================================================================= - int UDP_CheckNewConnections (void) { @@ -324,8 +301,6 @@ UDP_CheckNewConnections (void) return -1; } -//============================================================================= - int UDP_Read (int socket, byte * buf, int len, struct qsockaddr *addr) { @@ -338,23 +313,20 @@ UDP_Read (int socket, byte * buf, int len, struct qsockaddr *addr) return ret; } -//============================================================================= - int UDP_MakeSocketBroadcastCapable (int socket) { int i = 1; // make this socket broadcast capable - if (setsockopt (socket, SOL_SOCKET, SO_BROADCAST, (char *) &i, sizeof (i)) < - 0) return -1; + if (setsockopt (socket, SOL_SOCKET, SO_BROADCAST, (char *) &i, + sizeof (i)) < 0) + return -1; net_broadcastsocket = socket; return 0; } -//============================================================================= - int UDP_Broadcast (int socket, byte * buf, int len) { @@ -373,24 +345,18 @@ UDP_Broadcast (int socket, byte * buf, int len) return UDP_Write (socket, buf, len, &broadcastaddr); } -//============================================================================= - int UDP_Write (int socket, byte * buf, int len, struct qsockaddr *addr) { int ret; - ret = - - sendto (socket, buf, len, 0, (struct sockaddr *) addr, - sizeof (struct qsockaddr)); + ret = sendto (socket, buf, len, 0, (struct sockaddr *) addr, + sizeof (struct qsockaddr)); if (ret == -1 && errno == EWOULDBLOCK) return 0; return ret; } -//============================================================================= - const char * UDP_AddrToString (struct qsockaddr *addr) { @@ -404,13 +370,10 @@ UDP_AddrToString (struct qsockaddr *addr) return buffer; } -//============================================================================= - int UDP_StringToAddr (const char *string, struct qsockaddr *addr) { - int ha1, ha2, ha3, ha4, hp; - int ipaddr; + int ha1, ha2, ha3, ha4, hp, ipaddr; sscanf (string, "%d.%d.%d.%d:%d", &ha1, &ha2, &ha3, &ha4, &hp); ipaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4; @@ -421,13 +384,11 @@ UDP_StringToAddr (const char *string, struct qsockaddr *addr) return 0; } -//============================================================================= - int UDP_GetSocketAddr (int socket, struct qsockaddr *addr) { - int addrlen = sizeof (struct qsockaddr); unsigned int a; + int addrlen = sizeof (struct qsockaddr); memset (addr, 0, sizeof (struct qsockaddr)); @@ -439,8 +400,6 @@ UDP_GetSocketAddr (int socket, struct qsockaddr *addr) return 0; } -//============================================================================= - int UDP_GetNameFromAddr (struct qsockaddr *addr, char *name) { @@ -459,8 +418,6 @@ UDP_GetNameFromAddr (struct qsockaddr *addr, char *name) return 0; } -//============================================================================= - int UDP_GetAddrFromName (const char *name, struct qsockaddr *addr) { @@ -482,8 +439,6 @@ UDP_GetAddrFromName (const char *name, struct qsockaddr *addr) return 0; } -//============================================================================= - int UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2) { @@ -501,20 +456,15 @@ UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2) return 0; } -//============================================================================= - int UDP_GetSocketPort (struct qsockaddr *addr) { return ntohs (((struct sockaddr_in *) addr)->sin_port); } - int UDP_SetSocketPort (struct qsockaddr *addr, int port) { ((struct sockaddr_in *) addr)->sin_port = htons (port); return 0; } - -//============================================================================= diff --git a/nq/source/sv_cvar.c b/nq/source/sv_cvar.c index 4da0bb079..db1d5d8a2 100644 --- a/nq/source/sv_cvar.c +++ b/nq/source/sv_cvar.c @@ -33,6 +33,7 @@ #endif #include "QF/cvar.h" + #include "server.h" void diff --git a/nq/source/sv_ded.c b/nq/source/sv_ded.c index 847887e3a..0ace60872 100644 --- a/nq/source/sv_ded.c +++ b/nq/source/sv_ded.c @@ -36,21 +36,24 @@ #include "QF/cvar.h" #include "QF/host.h" #include "QF/keys.h" + #include "client.h" int m_return_state; qboolean m_return_onerror; char m_return_reason[32]; enum { m_none, m_main, m_singleplayer, m_load, m_save, m_multiplayer, m_setup, - m_net, m_options, m_video, m_keys, m_help, m_quit, m_serialconfig, - m_modemconfig, m_lanconfig, m_gameoptions, m_search, m_slist + m_net, m_options, m_video, m_keys, m_help, m_quit, m_serialconfig, + m_modemconfig, m_lanconfig, m_gameoptions, m_search, m_slist } m_state; + keydest_t key_dest; client_static_t cls; client_state_t cl; vec3_t vright, vup, vleft, vpn; float scr_centertime_off; + void Con_Printf (char *fmt, ...) { diff --git a/nq/source/sv_main.c b/nq/source/sv_main.c index c32d8ac99..6e556e5e6 100644 --- a/nq/source/sv_main.c +++ b/nq/source/sv_main.c @@ -30,12 +30,13 @@ # include "config.h" #endif +#include "QF/console.h" +#include "QF/cmd.h" #include "QF/cvar.h" #include "QF/msg.h" -#include "compat.h" -#include "QF/console.h" #include "QF/sys.h" -#include "QF/cmd.h" + +#include "compat.h" #include "host.h" #include "server.h" #include "sv_progs.h" @@ -48,31 +49,25 @@ char localmodels[MAX_MODELS][5]; // inline model names for precache entity_state_t baselines[MAX_EDICTS]; -//============================================================================ -/* -=============== -SV_Init -=============== -*/ void SV_Init (void) { int i; sv_maxvelocity = Cvar_Get ("sv_maxvelocity", "2000", CVAR_NONE, NULL, - "None"); + "None"); sv_gravity = Cvar_Get ("sv_gravity", "800", CVAR_SERVERINFO, Cvar_Info, - "None"); + "None"); sv_friction = Cvar_Get ("sv_friction", "4", CVAR_SERVERINFO, Cvar_Info, - "None"); + "None"); sv_edgefriction = Cvar_Get ("edgefriction", "2", CVAR_NONE, NULL, "None"); sv_stopspeed = Cvar_Get ("sv_stopspeed", "100", CVAR_NONE, NULL, "None"); sv_maxspeed = Cvar_Get ("sv_maxspeed", "320", CVAR_SERVERINFO, Cvar_Info, - "None"); + "None"); sv_accelerate = Cvar_Get ("sv_accelerate", "10", CVAR_NONE, NULL, "None"); - sv_idealpitchscale = - Cvar_Get ("sv_idealpitchscale", "0.8", CVAR_NONE, NULL, "None"); + sv_idealpitchscale = Cvar_Get ("sv_idealpitchscale", "0.8", CVAR_NONE, + NULL, "None"); sv_aim = Cvar_Get ("sv_aim", "0.93", CVAR_NONE, NULL, "None"); sv_nostep = Cvar_Get ("sv_nostep", "0", CVAR_NONE, NULL, "None"); @@ -80,20 +75,12 @@ SV_Init (void) snprintf (localmodels[i], sizeof (localmodels[i]), "*%i", i); } -/* -============================================================================= - -EVENT MESSAGES - -============================================================================= -*/ +// EVENT MESSAGES ============================================================= /* -================== -SV_StartParticle + SV_StartParticle -Make sure the event gets sent to all clients -================== + Make sure the event gets sent to all clients */ void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count) @@ -119,28 +106,22 @@ SV_StartParticle (vec3_t org, vec3_t dir, int color, int count) } /* -================== -SV_StartSound + SV_StartSound -Each entity can have eight independant sound sources, like voice, -weapon, feet, etc. + Each entity can have eight independant sound sources, like voice, + weapon, feet, etc. -Channel 0 is an auto-allocate channel, the others override anything -already running on that entity/channel pair. + Channel 0 is an auto-allocate channel, the others override anything + already running on that entity/channel pair. -An attenuation of 0 will play full volume everywhere in the level. -Larger attenuations will drop off. (max 4 attenuation) - -================== + An attenuation of 0 will play full volume everywhere in the level. + Larger attenuations will drop off. (max 4 attenuation) */ void SV_StartSound (edict_t *entity, int channel, const char *sample, int volume, float attenuation) { - int sound_num; - int field_mask; - int i; - int ent; + int ent, field_mask, sound_num, i; if (volume < 0 || volume > 255) Sys_Error ("SV_StartSound: volume = %i", volume); @@ -154,7 +135,7 @@ SV_StartSound (edict_t *entity, int channel, const char *sample, int volume, if (sv.datagram.cursize > MAX_DATAGRAM - 16) return; -// find precache number for sound + // find precache number for sound for (sound_num = 1; sound_num < MAX_SOUNDS && sv.sound_precache[sound_num]; sound_num++) if (!strcmp (sample, sv.sound_precache[sound_num])) @@ -175,7 +156,7 @@ SV_StartSound (edict_t *entity, int channel, const char *sample, int volume, if (attenuation != DEFAULT_SOUND_PACKET_ATTENUATION) field_mask |= SND_ATTENUATION; -// directed messages go only to the entity the are targeted on + // directed messages go only to the entity the are targeted on MSG_WriteByte (&sv.datagram, svc_sound); MSG_WriteByte (&sv.datagram, field_mask); if (field_mask & SND_VOLUME) @@ -185,26 +166,18 @@ SV_StartSound (edict_t *entity, int channel, const char *sample, int volume, MSG_WriteShort (&sv.datagram, channel); MSG_WriteByte (&sv.datagram, sound_num); for (i = 0; i < 3; i++) - MSG_WriteCoord (&sv.datagram, - SVvector (entity, origin)[i] + 0.5 * (SVvector (entity, mins)[i] + - SVvector (entity, maxs)[i])); + MSG_WriteCoord (&sv.datagram, SVvector (entity, origin)[i] + 0.5 * + (SVvector (entity, mins)[i] + + SVvector (entity, maxs)[i])); } -/* -============================================================================== - -CLIENT SPAWNING - -============================================================================== -*/ +// CLIENT SPAWNING ============================================================ /* -================ -SV_SendServerinfo + SV_SendServerinfo -Sends the first message from the server to a connected client. -This will be sent on the initial connection and upon each server load. -================ + Sends the first message from the server to a connected client. + This will be sent on the initial connection and upon each server load. */ void SV_SendServerinfo (client_t *client) @@ -239,12 +212,12 @@ SV_SendServerinfo (client_t *client) MSG_WriteString (&client->message, *s); MSG_WriteByte (&client->message, 0); -// send music + // send music MSG_WriteByte (&client->message, svc_cdtrack); MSG_WriteByte (&client->message, SVfloat (sv.edicts, sounds)); MSG_WriteByte (&client->message, SVfloat (sv.edicts, sounds)); -// set view + // set view MSG_WriteByte (&client->message, svc_setview); MSG_WriteShort (&client->message, NUM_FOR_EDICT (&sv_pr_state, client->edict)); @@ -257,12 +230,10 @@ SV_SendServerinfo (client_t *client) } /* -================ -SV_ConnectClient + SV_ConnectClient -Initializes a client_t for a new net connection. This will only be called -once for a player each game, not once for each level change. -================ + Initializes a client_t for a new net connection. This will only be called + once for a player each game, not once for each level change. */ void SV_ConnectClient (int clientnum) @@ -282,7 +253,7 @@ SV_ConnectClient (int clientnum) ent = EDICT_NUM (&sv_pr_state, edictnum); -// set up the client_t + // set up the client_t netconnection = client->netconnection; if (sv.loadgame) @@ -313,30 +284,19 @@ SV_ConnectClient (int clientnum) SV_SendServerinfo (client); } - -/* -=================== -SV_CheckForNewClients - -=================== -*/ void SV_CheckForNewClients (void) { - struct qsocket_s *ret; int i; + struct qsocket_s *ret; -// -// check for new connections -// + // check for new connections while (1) { ret = NET_CheckNewConnections (); if (!ret) break; - // // init a new client structure - // for (i = 0; i < svs.maxclients; i++) if (!svs.clients[i].active) break; @@ -350,22 +310,8 @@ SV_CheckForNewClients (void) } } +// FRAME UPDATES ============================================================== - -/* -=============================================================================== - -FRAME UPDATES - -=============================================================================== -*/ - -/* -================== -SV_ClearDatagram - -================== -*/ void SV_ClearDatagram (void) { @@ -373,14 +319,10 @@ SV_ClearDatagram (void) } /* -============================================================================= - -The PVS must include a small area around the client to allow head bobbing -or other small motion on the client side. Otherwise, a bob might cause an -entity that should be visible to not show up, especially when the bob -crosses a waterline. - -============================================================================= + The PVS must include a small area around the client to allow head bobbing + or other small motion on the client side. Otherwise, a bob might cause an + entity that should be visible to not show up, especially when the bob + crosses a waterline. */ int fatbytes; @@ -390,9 +332,9 @@ void SV_AddToFatPVS (vec3_t org, mnode_t *node) { int i; + float d; byte *pvs; mplane_t *plane; - float d; while (1) { // if this is a leaf, accumulate the pvs bits @@ -419,12 +361,10 @@ SV_AddToFatPVS (vec3_t org, mnode_t *node) } /* -============= -SV_FatPVS + SV_FatPVS -Calculates a PVS that is the inclusive or of all leafs within 8 pixels of the -given point. -============= + Calculates a PVS that is the inclusive or of all leafs within 8 pixels of the + given point. */ byte * SV_FatPVS (vec3_t org) @@ -437,28 +377,20 @@ SV_FatPVS (vec3_t org) //============================================================================= - -/* -============= -SV_WriteEntitiesToClient - -============= -*/ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) { - int e, i; - int bits; + int bits, e, i; byte *pvs; - vec3_t org; float miss; + vec3_t org; edict_t *ent; -// find the client's PVS + // find the client's PVS VectorAdd (SVvector (clent, origin), SVvector (clent, view_ofs), org); pvs = SV_FatPVS (org); -// send over all entities (excpet the client) that touch the pvs + // send over all entities (excpet the client) that touch the pvs ent = NEXT_EDICT (&sv_pr_state, sv.edicts); for (e = 1; e < sv.num_edicts; e++, ent = NEXT_EDICT (&sv_pr_state, ent)) { #ifdef QUAKE2 @@ -467,11 +399,12 @@ SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) continue; #endif -// ignore if not touching a PV leaf + // ignore if not touching a PV leaf if (ent != clent) // clent is ALLWAYS sent { -// ignore ents without visible models - if (!SVfloat (ent, modelindex) || !*PR_GetString (&sv_pr_state, SVstring (ent, model))) + // ignore ents without visible models + if (!SVfloat (ent, modelindex) || + !*PR_GetString (&sv_pr_state, SVstring (ent, model))) continue; for (i = 0; i < ent->num_leafs; i++) @@ -486,22 +419,26 @@ SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) Con_Printf ("packet overflow\n"); return; } -// send an update + // send an update bits = 0; for (i = 0; i < 3; i++) { - miss = SVvector (ent, origin)[i] - ((entity_state_t*)ent->data)->origin[i]; + miss = SVvector (ent, origin)[i] - + ((entity_state_t*)ent->data)->origin[i]; if (miss < -0.1 || miss > 0.1) bits |= U_ORIGIN1 << i; } - if (SVvector (ent, angles)[0] != ((entity_state_t*)ent->data)->angles[0]) + if (SVvector (ent, angles)[0] != + ((entity_state_t*)ent->data)->angles[0]) bits |= U_ANGLE1; - if (SVvector (ent, angles)[1] != ((entity_state_t*)ent->data)->angles[1]) + if (SVvector (ent, angles)[1] != + ((entity_state_t*)ent->data)->angles[1]) bits |= U_ANGLE2; - if (SVvector (ent, angles)[2] != ((entity_state_t*)ent->data)->angles[2]) + if (SVvector (ent, angles)[2] != + ((entity_state_t*)ent->data)->angles[2]) bits |= U_ANGLE3; if (SVfloat (ent, movetype) == MOVETYPE_STEP) @@ -519,7 +456,8 @@ SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) if (((entity_state_t*)ent->data)->effects != SVfloat (ent, effects)) bits |= U_EFFECTS; - if (((entity_state_t*)ent->data)->modelindex != SVfloat (ent, modelindex)) + if (((entity_state_t*)ent->data)->modelindex != SVfloat (ent, + modelindex)) bits |= U_MODEL; if (e >= 256) @@ -528,9 +466,7 @@ SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) if (bits >= 256) bits |= U_MOREBITS; - // // write the message - // MSG_WriteByte (msg, bits | U_SIGNAL); if (bits & U_MOREBITS) @@ -565,12 +501,6 @@ SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) } } -/* -============= -SV_CleanupEnts - -============= -*/ void SV_CleanupEnts (void) { @@ -579,51 +509,41 @@ SV_CleanupEnts (void) ent = NEXT_EDICT (&sv_pr_state, sv.edicts); for (e = 1; e < sv.num_edicts; e++, ent = NEXT_EDICT (&sv_pr_state, ent)) { - SVfloat (ent, effects) = (int) SVfloat (ent, effects) & ~EF_MUZZLEFLASH; + SVfloat (ent, effects) = (int) SVfloat (ent, effects) & + ~EF_MUZZLEFLASH; } } -/* -================== -SV_WriteClientdataToMessage - -================== -*/ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) { - int bits; - int i; + int bits, items, i; edict_t *other; - int items; #ifndef QUAKE2 pr_type_t *val; #endif -// -// send a damage message -// + // send a damage message if (SVfloat (ent, dmg_take) || SVfloat (ent, dmg_save)) { other = PROG_TO_EDICT (&sv_pr_state, SVentity (ent, dmg_inflictor)); MSG_WriteByte (msg, svc_damage); MSG_WriteByte (msg, SVfloat (ent, dmg_save)); MSG_WriteByte (msg, SVfloat (ent, dmg_take)); for (i = 0; i < 3; i++) - MSG_WriteCoord (msg, - SVvector (other, origin)[i] + 0.5 * (SVvector (other, mins)[i] + - SVvector (other, maxs)[i])); + MSG_WriteCoord (msg, SVvector (other, origin)[i] + 0.5 * + (SVvector (other, mins)[i] + + SVvector (other, maxs)[i])); SVfloat (ent, dmg_take) = 0; SVfloat (ent, dmg_save) = 0; } -// -// send the current viewpos offset from the view entity -// + + // send the current viewpos offset from the view entity 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 (SVfloat (ent, fixangle)) { MSG_WriteByte (msg, svc_setangle); for (i = 0; i < 3; i++) @@ -639,8 +559,8 @@ SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) if (SVfloat (ent, idealpitch)) bits |= SU_IDEALPITCH; -// stuff the sigil bits into the high bits of items for sbar, or else -// mix in items2 + // stuff the sigil bits into the high bits of items for sbar, or else + // mix in items2 #ifdef QUAKE2 items = (int) SVfloat (ent, items) | ((int) SVfloat (ent, items2) << 23); #else @@ -649,8 +569,8 @@ SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) if (val) items = (int) SVfloat (ent, items) | ((int) val->float_var << 23); else - items = - (int) SVfloat (ent, items) | ((int) *sv_globals.serverflags << 28); + items = (int) SVfloat (ent, items) | ((int) *sv_globals.serverflags << + 28); #endif bits |= SU_ITEMS; @@ -674,10 +594,10 @@ SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) if (SVfloat (ent, armorvalue)) bits |= SU_ARMOR; -// if (SVfloat (ent, weapon)) +// if (SVfloat (ent, weapon)) bits |= SU_WEAPON; -// send the data + // send the data MSG_WriteByte (msg, svc_clientdata); MSG_WriteShort (msg, bits); @@ -695,7 +615,7 @@ SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) MSG_WriteChar (msg, SVvector (ent, velocity)[i] / 16); } -// [always sent] if (bits & SU_ITEMS) + // [always sent] if (bits & SU_ITEMS) MSG_WriteLong (msg, items); if (bits & SU_WEAPONFRAME) @@ -704,8 +624,8 @@ SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) MSG_WriteByte (msg, SVfloat (ent, armorvalue)); if (bits & SU_WEAPON) MSG_WriteByte (msg, - SV_ModelIndex (PR_GetString (&sv_pr_state, - SVstring (ent, weaponmodel)))); + SV_ModelIndex (PR_GetString (&sv_pr_state, SVstring + (ent, weaponmodel)))); MSG_WriteShort (msg, SVfloat (ent, health)); MSG_WriteByte (msg, SVfloat (ent, currentammo)); @@ -726,11 +646,6 @@ SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) } } -/* -======================= -SV_SendClientDatagram -======================= -*/ qboolean SV_SendClientDatagram (client_t *client) { @@ -744,42 +659,36 @@ SV_SendClientDatagram (client_t *client) MSG_WriteByte (&msg, svc_time); MSG_WriteFloat (&msg, sv.time); -// add the client specific data to the datagram + // add the client specific data to the datagram SV_WriteClientdataToMessage (client->edict, &msg); SV_WriteEntitiesToClient (client->edict, &msg); -// copy the server datagram if there is space + // copy the server datagram if there is space if (msg.cursize + sv.datagram.cursize < msg.maxsize) SZ_Write (&msg, sv.datagram.data, sv.datagram.cursize); -// send the datagram + // send the datagram if (NET_SendUnreliableMessage (client->netconnection, &msg) == -1) { - SV_DropClient (true); // if the message couldn't send, kick - // - // off + SV_DropClient (true); // if the message couldn't send, kick off return false; } return true; } -/* -======================= -SV_UpdateToReliableMessages -======================= -*/ void SV_UpdateToReliableMessages (void) { int i, j; client_t *client; -// 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++) { if (host_client->old_frags != SVfloat (host_client->edict, frags)) { - for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++) { + for (j = 0, client = svs.clients; j < svs.maxclients; j++, + client++) { if (!client->active) continue; MSG_WriteByte (&client->message, svc_updatefrags); @@ -802,14 +711,11 @@ SV_UpdateToReliableMessages (void) SZ_Clear (&sv.reliable_datagram); } - /* -======================= -SV_SendNop + SV_SendNop -Send a nop message without trashing or sending the accumulated client -message buffer -======================= + Send a nop message without trashing or sending the accumulated client + message buffer */ void SV_SendNop (client_t *client) @@ -824,26 +730,19 @@ SV_SendNop (client_t *client) MSG_WriteChar (&msg, svc_nop); if (NET_SendUnreliableMessage (client->netconnection, &msg) == -1) - SV_DropClient (true); // if the message couldn't send, kick - // - // off + SV_DropClient (true); // if the message couldn't send, kick off client->last_message = realtime; } -/* -======================= -SV_SendClientMessages -======================= -*/ void SV_SendClientMessages (void) { int i; -// update frags, names, etc + // update frags, names, etc SV_UpdateToReliableMessages (); -// build individual updates + // build individual updates for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++) { if (!host_client->active) @@ -877,7 +776,7 @@ SV_SendClientMessages (void) if (host_client->message.cursize || host_client->dropasap) { if (!NET_CanSendMessage (host_client->netconnection)) { -// I_Printf ("can't write\n"); +// I_Printf ("can't write\n"); continue; } @@ -887,7 +786,7 @@ SV_SendClientMessages (void) if (NET_SendMessage (host_client->netconnection, &host_client->message) == -1) SV_DropClient (true); // if the message couldn't send, - // kick off + // kick off SZ_Clear (&host_client->message); host_client->last_message = realtime; host_client->sendsignon = false; @@ -895,26 +794,12 @@ SV_SendClientMessages (void) } } - -// clear muzzle flashes + // clear muzzle flashes SV_CleanupEnts (); } +// SERVER SPAWNING ============================================================ -/* -============================================================================== - -SERVER SPAWNING - -============================================================================== -*/ - -/* -================ -SV_ModelIndex - -================ -*/ int SV_ModelIndex (const char *name) { @@ -931,18 +816,11 @@ SV_ModelIndex (const char *name) return i; } -/* -================ -SV_CreateBaseline - -================ -*/ void SV_CreateBaseline (void) { - int i; + int entnum, i; edict_t *svent; - int entnum; for (entnum = 0; entnum < sv.num_edicts; entnum++) { // get the current server version @@ -952,25 +830,25 @@ SV_CreateBaseline (void) if (entnum > svs.maxclients && !SVfloat (svent, modelindex)) continue; - // // create entity baseline - // - VectorCopy (SVvector (svent, origin), ((entity_state_t*)svent->data)->origin); - VectorCopy (SVvector (svent, angles), ((entity_state_t*)svent->data)->angles); + VectorCopy (SVvector (svent, origin), + ((entity_state_t*)svent->data)->origin); + VectorCopy (SVvector (svent, angles), + ((entity_state_t*)svent->data)->angles); ((entity_state_t*)svent->data)->frame = SVfloat (svent, frame); ((entity_state_t*)svent->data)->skin = SVfloat (svent, skin); if (entnum > 0 && entnum <= svs.maxclients) { ((entity_state_t*)svent->data)->colormap = entnum; - ((entity_state_t*)svent->data)->modelindex = SV_ModelIndex ("progs/player.mdl"); + ((entity_state_t*)svent->data)->modelindex = SV_ModelIndex + ("progs/player.mdl"); } else { ((entity_state_t*)svent->data)->colormap = 0; ((entity_state_t*)svent->data)->modelindex = - SV_ModelIndex (PR_GetString (&sv_pr_state,SVstring (svent, model))); + SV_ModelIndex (PR_GetString (&sv_pr_state,SVstring (svent, + model))); } - // // add to the message - // MSG_WriteByte (&sv.signon, svc_spawnbaseline); MSG_WriteShort (&sv.signon, entnum); @@ -979,19 +857,19 @@ SV_CreateBaseline (void) MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->colormap); MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->skin); for (i = 0; i < 3; i++) { - MSG_WriteCoord (&sv.signon, ((entity_state_t*)svent->data)->origin[i]); - MSG_WriteAngle (&sv.signon, ((entity_state_t*)svent->data)->angles[i]); + MSG_WriteCoord (&sv.signon, + ((entity_state_t*)svent->data)->origin[i]); + MSG_WriteAngle (&sv.signon, + ((entity_state_t*)svent->data)->angles[i]); } } } /* -================ -SV_SendReconnect + SV_SendReconnect -Tell all the clients that the server is changing levels -================ + Tell all the clients that the server is changing levels */ void SV_SendReconnect (void) @@ -1015,14 +893,11 @@ SV_SendReconnect (void) #endif } - /* -================ -SV_SaveSpawnparms + SV_SaveSpawnparms -Grabs the current state of each client for saving across the -transition to another level -================ + Grabs the current state of each client for saving across the + transition to another level */ void SV_SaveSpawnparms (void) @@ -1047,16 +922,13 @@ SV_SaveSpawnparms (void) } } - -/* -================ -SV_SpawnServer - -This is called at the start of each level -================ -*/ extern float scr_centertime_off; +/* + SV_SpawnServer + + This is called at the start of each level +*/ #ifdef QUAKE2 void SV_SpawnServer (const char *server, const char *startspot) @@ -1065,8 +937,8 @@ void SV_SpawnServer (const char *server) #endif { - edict_t *ent; int i; + edict_t *ent; // let's not have any servers with no name if (hostname->string[0] == 0) @@ -1076,15 +948,12 @@ SV_SpawnServer (const char *server) Con_DPrintf ("SpawnServer: %s\n", server); svs.changelevel_issued = false; // now safe to issue another -// -// tell all connected clients that we are going to a new level -// + // tell all connected clients that we are going to a new level if (sv.active) { SV_SendReconnect (); } -// -// make cvars consistant -// + + // make cvars consistant if (coop->int_val) Cvar_SetValue (deathmatch, 0); current_skill = skill->int_val; @@ -1095,9 +964,7 @@ SV_SpawnServer (const char *server) Cvar_SetValue (skill, (float) current_skill); -// -// set up the new server -// + // set up the new server Host_ClearMemory (); memset (&sv, 0, sizeof (sv)); @@ -1108,10 +975,10 @@ SV_SpawnServer (const char *server) strcpy (sv.startspot, startspot); #endif -// load progs to get entity field count + // load progs to get entity field count SV_LoadProgs (); -// allocate server memory + // allocate server memory sv.max_edicts = MAX_EDICTS; sv.edicts = PR_InitEdicts (&sv_pr_state, sv.max_edicts); @@ -1133,7 +1000,7 @@ SV_SpawnServer (const char *server) sv.signon.cursize = 0; sv.signon.data = sv.signon_buf; -// leave slots at start for clients only + // leave slots at start for clients only sv.num_edicts = svs.maxclients + 1; for (i = 0; i < svs.maxclients; i++) { ent = EDICT_NUM (&sv_pr_state, i + 1); @@ -1155,9 +1022,7 @@ SV_SpawnServer (const char *server) } sv.models[1] = sv.worldmodel; -// -// clear world interaction links -// + // clear world interaction links SV_ClearWorld (); sv.sound_precache[0] = sv_pr_state.pr_strings; @@ -1169,9 +1034,7 @@ SV_SpawnServer (const char *server) sv.models[i + 1] = Mod_ForName (localmodels[i], false); } -// -// load the rest of the entities -// + // load the rest of the entities ent = EDICT_NUM (&sv_pr_state, 0); memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4); ent->free = false; @@ -1191,25 +1054,25 @@ SV_SpawnServer (const char *server) PR_SetString (&sv_pr_state, sv.startspot); #endif -// serverflags are for cross level information (sigils) + // serverflags are for cross level information (sigils) *sv_globals.serverflags = svs.serverflags; ED_LoadFromFile (&sv_pr_state, sv.worldmodel->entities); sv.active = true; -// all setup is completed, any further precache statements are errors + // all setup is completed, any further precache statements are errors sv.state = ss_active; -// run two frames to allow everything to settle + // run two frames to allow everything to settle host_frametime = 0.1; SV_Physics (); SV_Physics (); -// create a baseline for more efficient communications + // create a baseline for more efficient communications SV_CreateBaseline (); -// send serverinfo to all connected clients + // send serverinfo to all connected clients for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++) if (host_client->active) diff --git a/nq/source/sv_move.c b/nq/source/sv_move.c index 36ded4ea0..fe4b0873b 100644 --- a/nq/source/sv_move.c +++ b/nq/source/sv_move.c @@ -36,14 +36,15 @@ #define STEPSIZE 18 +int c_yes, c_no; + + /* SV_CheckBottom Returns false if any part of the bottom of the entity is off an edge that is not a staircase. */ -int c_yes, c_no; - qboolean SV_CheckBottom (edict_t *ent) { @@ -55,9 +56,10 @@ SV_CheckBottom (edict_t *ent) VectorAdd (SVvector (ent, origin), SVvector (ent, mins), mins); VectorAdd (SVvector (ent, origin), SVvector (ent, maxs), maxs); -// if all of the points under the corners are solid world, don't bother -// with the tougher checks -// the corners must be within 16 of the midpoint + // if all of the points under the corners are solid world, don't bother + // with the tougher checks + + // the corners must be within 16 of the midpoint start[2] = mins[2] - 1; for (x = 0; x <= 1; x++) for (y = 0; y <= 1; y++) { @@ -72,12 +74,11 @@ SV_CheckBottom (edict_t *ent) realcheck: c_no++; -// -// check it for real... -// + + // check it for real... start[2] = mins[2]; -// the midpoint must be within 16 of the bottom + // the midpoint must be within 16 of the bottom start[0] = stop[0] = (mins[0] + maxs[0]) * 0.5; start[1] = stop[1] = (mins[1] + maxs[1]) * 0.5; stop[2] = start[2] - 2 * STEPSIZE; @@ -87,7 +88,7 @@ SV_CheckBottom (edict_t *ent) return false; mid = bottom = trace.endpos[2]; -// the corners must be within 16 of the midpoint + // the corners must be within 16 of the midpoint for (x = 0; x <= 1; x++) for (y = 0; y <= 1; y++) { start[0] = stop[0] = x ? maxs[0] : mins[0]; @@ -105,7 +106,6 @@ SV_CheckBottom (edict_t *ent) return true; } - /* SV_movestep @@ -117,32 +117,31 @@ SV_CheckBottom (edict_t *ent) qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink) { + int i; float dz; vec3_t oldorg, neworg, end; trace_t trace; - int i; edict_t *enemy; -// try the move + // try the move VectorCopy (SVvector (ent, origin), oldorg); VectorAdd (SVvector (ent, origin), move, neworg); -// flying monsters don't step up + // flying monsters don't step up if ((int) SVfloat (ent, flags) & (FL_SWIM | FL_FLY)) { // try one move with vertical motion, then one without for (i = 0; i < 2; i++) { VectorAdd (SVvector (ent, origin), move, neworg); enemy = PROG_TO_EDICT (&sv_pr_state, SVentity (ent, enemy)); if (i == 0 && enemy != sv.edicts) { - dz = - SVvector (ent, origin)[2] - SVvector (enemy, origin)[2]; + dz = SVvector (ent, origin)[2] - SVvector (enemy, origin)[2]; if (dz > 40) neworg[2] -= 8; if (dz < 30) neworg[2] += 8; } - trace = - SV_Move (SVvector (ent, origin), SVvector (ent, mins), SVvector (ent, maxs), neworg, false, ent); + trace = SV_Move (SVvector (ent, origin), SVvector (ent, mins), + SVvector (ent, maxs), neworg, false, ent); if (trace.fraction == 1) { if (((int) SVfloat (ent, flags) & FL_SWIM) @@ -161,19 +160,22 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink) return false; } -// push down from a step height above the wished position + + // push down from a step height above the wished position neworg[2] += STEPSIZE; VectorCopy (neworg, end); end[2] -= STEPSIZE * 2; - trace = SV_Move (neworg, SVvector (ent, mins), SVvector (ent, maxs), end, false, ent); + trace = SV_Move (neworg, SVvector (ent, mins), SVvector (ent, maxs), end, + false, ent); if (trace.allsolid) return false; if (trace.startsolid) { neworg[2] -= STEPSIZE; - trace = SV_Move (neworg, SVvector (ent, mins), SVvector (ent, maxs), end, false, ent); + trace = SV_Move (neworg, SVvector (ent, mins), SVvector (ent, maxs), + end, false, ent); if (trace.allsolid || trace.startsolid) return false; } @@ -184,20 +186,19 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink) if (relink) SV_LinkEdict (ent, true); SVfloat (ent, flags) = (int) SVfloat (ent, flags) & ~FL_ONGROUND; -// Con_Printf ("fall down\n"); +// Con_Printf ("fall down\n"); return true; } return false; // walked off an edge } -// check point traces down for dangling corners + // check point traces down for dangling corners VectorCopy (trace.endpos, SVvector (ent, origin)); if (!SV_CheckBottom (ent)) { - if ((int) SVfloat (ent, flags) & FL_PARTIALGROUND) { // entity had floor - // mostly pulled out - // from underneath it - // and is trying to correct + if ((int) SVfloat (ent, flags) & FL_PARTIALGROUND) { + // entity had floor mostly pulled out from underneath it and is + // trying to correct if (relink) SV_LinkEdict (ent, true); return true; @@ -207,31 +208,28 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink) } if ((int) SVfloat (ent, flags) & FL_PARTIALGROUND) { -// Con_Printf ("back on ground\n"); +// Con_Printf ("back on ground\n"); SVfloat (ent, flags) = (int) SVfloat (ent, flags) & ~FL_PARTIALGROUND; } SVentity (ent, groundentity) = EDICT_TO_PROG (&sv_pr_state, trace.ent); -// the move is ok + // the move is ok if (relink) SV_LinkEdict (ent, true); return true; } - -//============================================================================ - /* - SV_StepDirection + SV_StepDirection - Turns to the movement direction, and walks the current distance if - facing it. + Turns to the movement direction, and walks the current distance if + facing it. */ qboolean SV_StepDirection (edict_t *ent, float yaw, float dist) { - vec3_t move, oldorigin; float delta; + vec3_t move, oldorigin; SVfloat (ent, ideal_yaw) = yaw; PF_changeyaw (&sv_pr_state); @@ -256,29 +254,21 @@ SV_StepDirection (edict_t *ent, float yaw, float dist) return false; } -/* - SV_FixCheckBottom -*/ void SV_FixCheckBottom (edict_t *ent) { -// Con_Printf ("SV_FixCheckBottom\n"); +// Con_Printf ("SV_FixCheckBottom\n"); SVfloat (ent, flags) = (int) SVfloat (ent, flags) | FL_PARTIALGROUND; } - - -/* - SV_NewChaseDir -*/ #define DI_NODIR -1 + void SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist) { - float deltax, deltay; + float deltax, deltay, olddir, tdir, turnaround; float d[3]; - float tdir, olddir, turnaround; olddir = anglemod ((int) (SVfloat (actor, ideal_yaw) / 45) * 45); turnaround = anglemod (olddir - 180); @@ -298,7 +288,7 @@ SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist) else d[2] = DI_NODIR; -// try direct route + // try direct route if (d[1] != DI_NODIR && d[2] != DI_NODIR) { if (d[1] == 0) tdir = d[2] == 90 ? 45 : 315; @@ -308,7 +298,7 @@ SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist) if (tdir != turnaround && SV_StepDirection (actor, tdir, dist)) return; } -// try other directions + // try other directions if (((rand () & 3) & 1) || abs (deltay) > abs (deltax)) { tdir = d[1]; d[1] = d[2]; @@ -321,13 +311,11 @@ SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist) if (d[2] != DI_NODIR && d[2] != turnaround && SV_StepDirection (actor, d[2], dist)) return; -/* there is no direct path to the player, so pick another direction */ - + /* there is no direct path to the player, so pick another direction */ if (olddir != DI_NODIR && SV_StepDirection (actor, olddir, dist)) return; - if (rand () & 1) { /* randomly determine direction of - search */ + if (rand () & 1) { /* randomly determine direction of search */ for (tdir = 0; tdir <= 315; tdir += 45) if (tdir != turnaround && SV_StepDirection (actor, tdir, dist)) return; @@ -342,17 +330,13 @@ SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist) SVfloat (actor, ideal_yaw) = olddir; // can't move -// if a bridge was pulled out from underneath a monster, it may not have -// a valid standing position at all + // if a bridge was pulled out from underneath a monster, it may not have + // a valid standing position at all if (!SV_CheckBottom (actor)) SV_FixCheckBottom (actor); - } -/* - SV_CloseEnough -*/ qboolean SV_CloseEnough (edict_t *ent, edict_t *goal, float dist) { @@ -367,14 +351,11 @@ SV_CloseEnough (edict_t *ent, edict_t *goal, float dist) return true; } -/* - SV_MoveToGoal -*/ void SV_MoveToGoal (progs_t *pr) { - edict_t *ent, *goal; float dist; + edict_t *ent, *goal; ent = PROG_TO_EDICT (pr, *pr->globals.self); goal = PROG_TO_EDICT (pr, SVentity (ent, goalentity)); @@ -384,13 +365,14 @@ SV_MoveToGoal (progs_t *pr) G_FLOAT (pr, OFS_RETURN) = 0; return; } -// if the next step hits the enemy, return immediately + // if the next step hits the enemy, return immediately if (PROG_TO_EDICT (pr, SVentity (ent, enemy)) != sv.edicts && SV_CloseEnough (ent, goal, dist)) return; -// bump around... - if ((rand () & 3) == 1 || !SV_StepDirection (ent, SVfloat (ent, ideal_yaw), dist)) { + // bump around... + if ((rand () & 3) == 1 || !SV_StepDirection (ent, SVfloat + (ent, ideal_yaw), dist)) { SV_NewChaseDir (ent, goal, dist); } } diff --git a/nq/source/sv_phys.c b/nq/source/sv_phys.c index aed824db7..7826661b4 100644 --- a/nq/source/sv_phys.c +++ b/nq/source/sv_phys.c @@ -34,27 +34,24 @@ #include "QF/cvar.h" #include "QF/sys.h" -#include "server.h" #include "host.h" -#include "world.h" +#include "server.h" #include "sv_progs.h" +#include "world.h" /* + pushmove objects do not obey gravity, and do not interact with each other or trigger fields, but block normal movement and push normal objects when they move. + onground is set for toss objects when they come to a complete rest. it is set for steping or walking objects -pushmove objects do not obey gravity, and do not interact with each other or trigger fields, but block normal movement and push normal objects when they move. - -onground is set for toss objects when they come to a complete rest. it is set for steping or walking objects - -doors, plats, etc are SOLID_BSP, and MOVETYPE_PUSH -bonus items are SOLID_TRIGGER touch, and MOVETYPE_TOSS -corpses are SOLID_NOT and MOVETYPE_TOSS -crates are SOLID_BBOX and MOVETYPE_TOSS -walking monsters are SOLID_SLIDEBOX and MOVETYPE_STEP -flying/floating monsters are SOLID_SLIDEBOX and MOVETYPE_FLY - -solid_edge items only clip against bsp models. + doors, plats, etc are SOLID_BSP, and MOVETYPE_PUSH + bonus items are SOLID_TRIGGER touch, and MOVETYPE_TOSS + corpses are SOLID_NOT and MOVETYPE_TOSS + crates are SOLID_BBOX and MOVETYPE_TOSS + walking monsters are SOLID_SLIDEBOX and MOVETYPE_STEP + flying/floating monsters are SOLID_SLIDEBOX and MOVETYPE_FLY + solid_edge items only clip against bsp models. */ cvar_t *sv_friction; @@ -71,18 +68,14 @@ static vec3_t vec_origin = { 0.0, 0.0, 0.0 }; void SV_Physics_Toss (edict_t *ent); -/* -================ -SV_CheckAllEnts -================ -*/ + void SV_CheckAllEnts (void) { int e; edict_t *check; -// see if any solid entities are inside the final position + // see if any solid entities are inside the final position check = NEXT_EDICT (&sv_pr_state, sv.edicts); for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) { @@ -101,28 +94,23 @@ SV_CheckAllEnts (void) } } -/* -================ -SV_CheckVelocity -================ -*/ void SV_CheckVelocity (edict_t *ent) { int i; -// -// bound velocity -// + // bound velocity for (i = 0; i < 3; i++) { if (IS_NAN (SVvector (ent, velocity)[i])) { Con_Printf ("Got a NaN velocity on %s\n", - PR_GetString (&sv_pr_state, SVstring (ent, classname))); + PR_GetString (&sv_pr_state, SVstring (ent, + classname))); SVvector (ent, velocity)[i] = 0; } if (IS_NAN (SVvector (ent, origin)[i])) { Con_Printf ("Got a NaN origin on %s\n", - PR_GetString (&sv_pr_state, SVstring (ent, classname))); + PR_GetString (&sv_pr_state, SVstring (ent, + classname))); SVvector (ent, origin)[i] = 0; } if (SVvector (ent, velocity)[i] > sv_maxvelocity->value) @@ -133,14 +121,12 @@ SV_CheckVelocity (edict_t *ent) } /* -============= -SV_RunThink + SV_RunThink -Runs thinking code if time. There is some play in the exact time the think -function will be called, because it is called before any movement is done -in a frame. Not used for pushmove objects, because they must be exact. -Returns false if the entity removed itself. -============= + Runs thinking code if time. There is some play in the exact time the think + function will be called, because it is called before any movement is done + in a frame. Not used for pushmove objects, because they must be exact. + Returns false if the entity removed itself. */ qboolean SV_RunThink (edict_t *ent) @@ -153,8 +139,8 @@ SV_RunThink (edict_t *ent) if (thinktime < sv.time) thinktime = sv.time; // don't let things stay in the past. - // it is possible to start that way - // by a trigger with a local time. + // it is possible to start that way + // by a trigger with a local time. SVfloat (ent, nextthink) = 0; *sv_globals.time = thinktime; *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent); @@ -165,11 +151,9 @@ SV_RunThink (edict_t *ent) } /* -================== -SV_Impact + SV_Impact -Two entities have touched, so run their touch functions -================== + Two entities have touched, so run their touch functions */ void SV_Impact (edict_t *e1, edict_t *e2) @@ -196,17 +180,14 @@ SV_Impact (edict_t *e1, edict_t *e2) *sv_globals.other = old_other; } - -/* -================== -ClipVelocity - -Slide off of the impacting object -returns the blocked flags (1 = floor, 2 = step / wall) -================== -*/ #define STOP_EPSILON 0.1 +/* + ClipVelocity + + Slide off of the impacting object + returns the blocked flags (1 = floor, 2 = step / wall) +*/ int ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce) { @@ -232,34 +213,26 @@ ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce) return blocked; } +#define MAX_CLIP_PLANES 5 /* -============ -SV_FlyMove + SV_FlyMove -The basic solid body movement clip that slides along multiple planes -Returns the clipflags if the velocity was modified (hit something solid) -1 = floor -2 = wall / step -4 = dead stop -If steptrace is not NULL, the trace of any vertical wall hit will be stored -============ + The basic solid body movement clip that slides along multiple planes + Returns the clipflags if the velocity was modified (hit something solid) + 1 = floor + 2 = wall / step + 4 = dead stop + If steptrace is not NULL, the trace of any vertical wall hit will be stored */ -#define MAX_CLIP_PLANES 5 int SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) { - int bumpcount, numbumps; - vec3_t dir; - float d; - int numplanes; + int blocked, bumpcount, numbumps, numplanes, i, j; + float d, time_left; + vec3_t dir, end, primal_velocity, original_velocity, new_velocity; vec3_t planes[MAX_CLIP_PLANES]; - vec3_t primal_velocity, original_velocity, new_velocity; - int i, j; trace_t trace; - vec3_t end; - float time_left; - int blocked; numbumps = 4; @@ -276,11 +249,11 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) break; for (i = 0; i < 3; i++) - end[i] = SVvector (ent, origin)[i] + time_left * SVvector (ent, velocity)[i]; + end[i] = SVvector (ent, origin)[i] + time_left * + SVvector (ent, velocity)[i]; - trace = - SV_Move (SVvector (ent, origin), SVvector (ent, mins), SVvector (ent, maxs), end, false, - ent); + trace = SV_Move (SVvector (ent, origin), SVvector (ent, mins), + SVvector (ent, maxs), end, false, ent); if (trace.allsolid) { // entity is trapped in another solid VectorCopy (vec3_origin, SVvector (ent, velocity)); @@ -302,8 +275,10 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) if (trace.plane.normal[2] > 0.7) { blocked |= 1; // floor if (SVfloat (trace.ent, solid) == SOLID_BSP) { - SVfloat (ent, flags) = (int) SVfloat (ent, flags) | FL_ONGROUND; - SVentity (ent, groundentity) = EDICT_TO_PROG (&sv_pr_state, trace.ent); + SVfloat (ent, flags) = (int) SVfloat (ent, flags) | + FL_ONGROUND; + SVentity (ent, groundentity) = EDICT_TO_PROG (&sv_pr_state, + trace.ent); } } if (!trace.plane.normal[2]) { @@ -311,14 +286,11 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) if (steptrace) *steptrace = trace; // save for player extrafriction } -// -// run the impact function -// + // run the impact function SV_Impact (ent, trace.ent); if (ent->free) break; // removed by the impact function - time_left -= time_left * trace.fraction; // cliped to another plane @@ -330,9 +302,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) VectorCopy (trace.plane.normal, planes[numplanes]); numplanes++; -// -// modify original_velocity so it parallels all of the clip planes -// + // modify original_velocity so it parallels all of the clip planes for (i = 0; i < numplanes; i++) { ClipVelocity (original_velocity, planes[i], new_velocity, 1); for (j = 0; j < numplanes; j++) @@ -348,7 +318,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) VectorCopy (new_velocity, SVvector (ent, velocity)); } else { // go along the crease if (numplanes != 2) { -// Con_Printf ("clip velocity, numplanes == %i\n",numplanes); +// Con_Printf ("clip velocity, numplanes == %i\n",numplanes); VectorCopy (vec3_origin, SVvector (ent, velocity)); return 7; } @@ -357,10 +327,8 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) VectorScale (dir, d, SVvector (ent, velocity)); } -// -// if original velocity is against the original velocity, stop dead -// to avoid tiny occilations in sloping corners -// + // if original velocity is against the original velocity, stop dead + // to avoid tiny occilations in sloping corners if (DotProduct (SVvector (ent, velocity), primal_velocity) <= 0) { VectorCopy (vec3_origin, SVvector (ent, velocity)); return blocked; @@ -370,13 +338,6 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) return blocked; } - -/* -============ -SV_AddGravity - -============ -*/ void SV_AddGravity (edict_t *ent) { @@ -399,43 +360,32 @@ SV_AddGravity (edict_t *ent) SVvector (ent, velocity)[2] -= ent_gravity * sv_gravity->value * host_frametime; } +// PUSHMOVE =================================================================== /* -=============================================================================== + SV_PushEntity -PUSHMOVE - -=============================================================================== -*/ - -/* -============ -SV_PushEntity - -Does not change the entities velocity at all -============ + Does not change the entities velocity at all */ trace_t SV_PushEntity (edict_t *ent, vec3_t push) { - trace_t trace; vec3_t end; + trace_t trace; VectorAdd (SVvector (ent, origin), push, end); if (SVfloat (ent, movetype) == MOVETYPE_FLYMISSILE) - trace = - SV_Move (SVvector (ent, origin), SVvector (ent, mins), SVvector (ent, maxs), end, - MOVE_MISSILE, ent); - else if (SVfloat (ent, solid) == SOLID_TRIGGER || SVfloat (ent, solid) == SOLID_NOT) + trace = SV_Move (SVvector (ent, origin), SVvector (ent, mins), + SVvector (ent, maxs), end, MOVE_MISSILE, ent); + else if (SVfloat (ent, solid) == SOLID_TRIGGER || SVfloat (ent, solid) == + SOLID_NOT) // only clip against bmodels - trace = - SV_Move (SVvector (ent, origin), SVvector (ent, mins), SVvector (ent, maxs), end, - MOVE_NOMONSTERS, ent); + trace = SV_Move (SVvector (ent, origin), SVvector (ent, mins), + SVvector (ent, maxs), end, MOVE_NOMONSTERS, ent); else - trace = - SV_Move (SVvector (ent, origin), SVvector (ent, mins), SVvector (ent, maxs), end, - MOVE_NORMAL, ent); + trace = SV_Move (SVvector (ent, origin), SVvector (ent, mins), + SVvector (ent, maxs), end, MOVE_NORMAL, ent); VectorCopy (trace.endpos, SVvector (ent, origin)); SV_LinkEdict (ent, true); @@ -446,22 +396,13 @@ SV_PushEntity (edict_t *ent, vec3_t push) return trace; } - -/* -============ -SV_PushMove - -============ -*/ void SV_PushMove (edict_t *pusher, float movetime) { - int i, e; + int i, e, num_moved; edict_t *check, *block; - vec3_t mins, maxs, move; - vec3_t entorig, pushorig; - int num_moved; edict_t *moved_edict[MAX_EDICTS]; + vec3_t entorig, pushorig, mins, maxs, move; vec3_t moved_from[MAX_EDICTS]; if (!SVvector (pusher, velocity)[0] && !SVvector (pusher, velocity)[1] @@ -478,14 +419,12 @@ SV_PushMove (edict_t *pusher, float movetime) VectorCopy (SVvector (pusher, origin), pushorig); -// move the pusher to it's final position - + // move the pusher to it's final position VectorAdd (SVvector (pusher, origin), move, SVvector (pusher, origin)); SVfloat (pusher, ltime) += movetime; SV_LinkEdict (pusher, false); - -// see if any solid entities are inside the final position + // 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; @@ -500,8 +439,7 @@ SV_PushMove (edict_t *pusher, float movetime) || SVfloat (check, movetype) == MOVETYPE_NOCLIP) 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 (!(((int) SVfloat (check, flags) & FL_ONGROUND) && PROG_TO_EDICT (&sv_pr_state, SVentity (check, groundentity)) == pusher)) { @@ -519,7 +457,8 @@ SV_PushMove (edict_t *pusher, float movetime) } // remove the onground flag for non-players if (SVfloat (check, movetype) != MOVETYPE_WALK) - SVfloat (check, flags) = (int) SVfloat (check, flags) & ~FL_ONGROUND; + SVfloat (check, flags) = (int) SVfloat (check, flags) & + ~FL_ONGROUND; VectorCopy (SVvector (check, origin), entorig); VectorCopy (SVvector (check, origin), moved_from[num_moved]); @@ -536,7 +475,8 @@ SV_PushMove (edict_t *pusher, float movetime) if (block) { // fail the move if (SVvector (check, mins)[0] == SVvector (check, maxs)[0]) continue; - if (SVfloat (check, solid) == SOLID_NOT || SVfloat (check, solid) == SOLID_TRIGGER) { // corpse + if (SVfloat (check, solid) == SOLID_NOT || SVfloat (check, solid) + == SOLID_TRIGGER) { // corpse SVvector (check, mins)[0] = SVvector (check, mins)[1] = 0; VectorCopy (SVvector (check, mins), SVvector (check, maxs)); continue; @@ -571,12 +511,6 @@ SV_PushMove (edict_t *pusher, float movetime) } #ifdef QUAKE2 -/* -============ -SV_PushRotate - -============ -*/ void SV_PushRotate (edict_t *pusher, float movetime) { @@ -604,14 +538,12 @@ SV_PushRotate (edict_t *pusher, float movetime) VectorCopy (SVfloat (pusher, angles), pushorig); -// move the pusher to it's final position - + // move the pusher to it's final position VectorAdd (SVfloat (pusher, angles), amove, SVfloat (pusher, angles)); SVfloat (pusher, ltime) += movetime; SV_LinkEdict (pusher, false); - -// see if any solid entities are inside the final position + // 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; @@ -623,8 +555,7 @@ SV_PushRotate (edict_t *pusher, float movetime) || SVfloat (check, movetype) == MOVETYPE_FOLLOW || SVfloat (check, movetype) == MOVETYPE_NOCLIP) 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 (!(((int) SVfloat (check, flags) & FL_ONGROUND) && PROG_TO_EDICT (&sv_pr_state, SVfloat (check, groundentity)) == pusher)) { @@ -642,7 +573,8 @@ SV_PushRotate (edict_t *pusher, float movetime) } // remove the onground flag for non-players if (SVfloat (check, movetype) != MOVETYPE_WALK) - SVfloat (check, flags) = (int) SVfloat (check, flags) & ~FL_ONGROUND; + SVfloat (check, flags) = (int) SVfloat (check, flags) & + ~FL_ONGROUND; VectorCopy (SVfloat (check, origin), entorig); VectorCopy (SVfloat (check, origin), moved_from[num_moved]); @@ -650,7 +582,8 @@ SV_PushRotate (edict_t *pusher, float movetime) num_moved++; // calculate destination position - VectorSubtract (SVfloat (check, origin), SVfloat (pusher, origin), org); + VectorSubtract (SVfloat (check, origin), SVfloat (pusher, origin), + org); org2[0] = DotProduct (org, forward); org2[1] = -DotProduct (org, right); org2[2] = DotProduct (org, up); @@ -666,7 +599,8 @@ SV_PushRotate (edict_t *pusher, float movetime) if (block) { // fail the move if (SVfloat (check, mins)[0] == SVfloat (check, maxs)[0]) continue; - if (SVfloat (check, solid) == SOLID_NOT || SVfloat (check, solid) == SOLID_TRIGGER) { // corpse + if (SVfloat (check, solid) == SOLID_NOT || SVfloat (check, solid) + == SOLID_TRIGGER) { // corpse SVfloat (check, mins)[0] = SVfloat (check, mins)[1] = 0; VectorCopy (SVfloat (check, mins), SVfloat (check, maxs)); continue; @@ -697,7 +631,8 @@ SV_PushRotate (edict_t *pusher, float movetime) } return; } else { - VectorAdd (SVfloat (check, angles), amove, SVfloat (check, angles)); + VectorAdd (SVfloat (check, angles), amove, SVfloat (check, + angles)); } } @@ -705,18 +640,10 @@ SV_PushRotate (edict_t *pusher, float movetime) } #endif -/* -================ -SV_Physics_Pusher - -================ -*/ void SV_Physics_Pusher (edict_t *ent) { - float thinktime; - float oldltime; - float movetime; + float movetime, oldltime, thinktime; oldltime = SVfloat (ent, ltime); @@ -735,9 +662,8 @@ SV_Physics_Pusher (edict_t *ent) SV_PushRotate (ent, movetime); else #endif - SV_PushMove (ent, movetime); // advances SVfloat (ent, ltime) if not - // - // blocked + SV_PushMove (ent, movetime); // advances SVfloat (ent, ltime) + // if not blocked } if (thinktime > oldltime && thinktime <= SVfloat (ent, ltime)) { @@ -753,28 +679,18 @@ SV_Physics_Pusher (edict_t *ent) } +// CLIENT MOVEMENT ============================================================ /* -=============================================================================== + SV_CheckStuck -CLIENT MOVEMENT - -=============================================================================== -*/ - -/* -============= -SV_CheckStuck - -This is a big hack to try and fix the rare case of getting stuck in the world -clipping hull. -============= + This is a big hack to try and fix the rare case of getting stuck in the world + clipping hull. */ void SV_CheckStuck (edict_t *ent) { - int i, j; - int z; + int i, j, z; vec3_t org; if (!SV_TestEntityPosition (ent)) { @@ -807,17 +723,11 @@ SV_CheckStuck (edict_t *ent) Con_DPrintf ("player is stuck.\n"); } - -/* -============= -SV_CheckWater -============= -*/ qboolean SV_CheckWater (edict_t *ent) { - vec3_t point; int cont; + vec3_t point; #ifdef QUAKE2 int truecont; @@ -836,8 +746,8 @@ SV_CheckWater (edict_t *ent) #endif SVfloat (ent, watertype) = cont; SVfloat (ent, waterlevel) = 1; - point[2] = - SVvector (ent, origin)[2] + (SVvector (ent, mins)[2] + SVvector (ent, maxs)[2]) * 0.5; + point[2] = SVvector (ent, origin)[2] + (SVvector (ent, mins)[2] + + SVvector (ent, maxs)[2]) * 0.5; cont = SV_PointContents (point); if (cont <= CONTENTS_WATER) { SVfloat (ent, waterlevel) = 2; @@ -847,7 +757,8 @@ SV_CheckWater (edict_t *ent) SVfloat (ent, waterlevel) = 3; } #ifdef QUAKE2 - if (truecont <= CONTENTS_CURRENT_0 && truecont >= CONTENTS_CURRENT_DOWN) { + if (truecont <= CONTENTS_CURRENT_0 && truecont >= + CONTENTS_CURRENT_DOWN) { static vec3_t current_table[] = { {1, 0, 0}, {0, 1, 0}, @@ -857,7 +768,8 @@ SV_CheckWater (edict_t *ent) {0, 0, -1} }; - VectorMA (SVfloat (ent, basevelocity), 150.0 * SVfloat (ent, waterlevel) / 3.0, + VectorMA (SVfloat (ent, basevelocity), 150.0 * + SVfloat (ent, waterlevel) / 3.0, current_table[CONTENTS_CURRENT_0 - truecont], SVfloat (ent, basevelocity)); } @@ -867,18 +779,11 @@ SV_CheckWater (edict_t *ent) return SVfloat (ent, waterlevel) > 1; } -/* -============ -SV_WallFriction - -============ -*/ void SV_WallFriction (edict_t *ent, trace_t *trace) { - vec3_t forward, right, up; float d, i; - vec3_t into, side; + vec3_t forward, right, up, into, side; AngleVectors (SVvector (ent, v_angle), forward, right, up); d = DotProduct (trace->plane.normal, forward); @@ -887,7 +792,7 @@ SV_WallFriction (edict_t *ent, trace_t *trace) if (d >= 0) return; -// cut the tangential velocity + // cut the tangential velocity i = DotProduct (trace->plane.normal, SVvector (ent, velocity)); VectorScale (trace->plane.normal, i, into); VectorSubtract (SVvector (ent, velocity), into, side); @@ -897,61 +802,57 @@ SV_WallFriction (edict_t *ent, trace_t *trace) } /* -===================== -SV_TryUnstick + SV_TryUnstick -Player has come to a dead stop, possibly due to the problem with limited -float precision at some angle joins in the BSP hull. + Player has come to a dead stop, possibly due to the problem with limited + float precision at some angle joins in the BSP hull. -Try fixing by pushing one pixel in each direction. + Try fixing by pushing one pixel in each direction. -This is a hack, but in the interest of good gameplay... -====================== + This is a hack, but in the interest of good gameplay... */ int SV_TryUnstick (edict_t *ent, vec3_t oldvel) { - int i; - vec3_t oldorg; - vec3_t dir; - int clip; + int i, clip; + vec3_t dir, oldorg; trace_t steptrace; VectorCopy (SVvector (ent, origin), oldorg); VectorCopy (vec3_origin, dir); for (i = 0; i < 8; i++) { -// try pushing a little in an axial direction + // try pushing a little in an axial direction switch (i) { - case 0: + case 0: dir[0] = 2; dir[1] = 0; break; - case 1: + case 1: dir[0] = 0; dir[1] = 2; break; - case 2: + case 2: dir[0] = -2; dir[1] = 0; break; - case 3: + case 3: dir[0] = 0; dir[1] = -2; break; - case 4: + case 4: dir[0] = 2; dir[1] = 2; break; - case 5: + case 5: dir[0] = -2; dir[1] = 2; break; - case 6: + case 6: dir[0] = 2; dir[1] = -2; break; - case 7: + case 7: dir[0] = -2; dir[1] = -2; break; @@ -959,7 +860,7 @@ SV_TryUnstick (edict_t *ent, vec3_t oldvel) SV_PushEntity (ent, dir); -// retry the original move + // retry the original move SVvector (ent, velocity)[0] = oldvel[0]; SVvector (ent, velocity)[1] = oldvel[1]; SVvector (ent, velocity)[2] = 0; @@ -967,10 +868,10 @@ SV_TryUnstick (edict_t *ent, vec3_t oldvel) if (fabs (oldorg[1] - SVvector (ent, origin)[1]) > 4 || fabs (oldorg[0] - SVvector (ent, origin)[0]) > 4) { -//Con_DPrintf ("unstuck!\n"); +// Con_DPrintf ("unstuck!\n"); return clip; } -// go back to the original pos and try again + // go back to the original pos and try again VectorCopy (oldorg, SVvector (ent, origin)); } @@ -978,27 +879,21 @@ SV_TryUnstick (edict_t *ent, vec3_t oldvel) return 7; // still not moving } -/* -===================== -SV_WalkMove - -Only used by players -====================== -*/ #define STEPSIZE 18 + +/* + SV_WalkMove + + Only used by players +*/ void SV_WalkMove (edict_t *ent) { - vec3_t upmove, downmove; - vec3_t oldorg, oldvel; - vec3_t nosteporg, nostepvel; - int clip; - int oldonground; + int clip, oldonground; + vec3_t upmove, downmove, nosteporg, nostepvel, oldorg, oldvel; trace_t steptrace, downtrace; -// -// 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 = (int) SVfloat (ent, flags) & FL_ONGROUND; SVfloat (ent, flags) = (int) SVfloat (ent, flags) & ~FL_ONGROUND; @@ -1025,67 +920,57 @@ SV_WalkMove (edict_t *ent) VectorCopy (SVvector (ent, origin), nosteporg); VectorCopy (SVvector (ent, velocity), nostepvel); -// -// try moving up and forward to go up a step -// + // try moving up and forward to go up a step VectorCopy (oldorg, SVvector (ent, origin)); // back to start pos - VectorCopy (vec3_origin, upmove); VectorCopy (vec3_origin, downmove); upmove[2] = STEPSIZE; downmove[2] = -STEPSIZE + oldvel[2] * host_frametime; -// move up + // move up SV_PushEntity (ent, upmove); // FIXME: don't link? -// move forward + // move forward SVvector (ent, velocity)[0] = oldvel[0]; SVvector (ent, velocity)[1] = oldvel[1]; SVvector (ent, velocity)[2] = 0; clip = SV_FlyMove (ent, host_frametime, &steptrace); -// check for stuckness, possibly due to the limited precision of floats -// in the clipping hulls + // check for stuckness, possibly due to the limited precision of floats + // in the clipping hulls if (clip) { if (fabs (oldorg[1] - SVvector (ent, origin)[1]) < 0.03125 - && fabs (oldorg[0] - SVvector (ent, origin)[0]) < 0.03125) { // stepping - // - // up - // didn't - // make - // any - // progress + && fabs (oldorg[0] - SVvector (ent, origin)[0]) < 0.03125) { + // stepping up didn't make any progress clip = SV_TryUnstick (ent, oldvel); } } -// extra friction based on view angle + // extra friction based on view angle if (clip & 2) SV_WallFriction (ent, &steptrace); -// move down + // move down downtrace = SV_PushEntity (ent, downmove); // FIXME: don't link? if (downtrace.plane.normal[2] > 0.7) { if (SVfloat (ent, solid) == SOLID_BSP) { SVfloat (ent, flags) = (int) SVfloat (ent, flags) | FL_ONGROUND; - SVfloat (ent, groundentity) = EDICT_TO_PROG (&sv_pr_state, downtrace.ent); + SVfloat (ent, groundentity) = EDICT_TO_PROG (&sv_pr_state, + downtrace.ent); } } else { -// if the push down didn't end up on good ground, use the move without -// the step up. This happens near wall / slope combinations, and can -// cause the player to hop up higher on a slope too steep to climb + // if the push down didn't end up on good ground, use the move without + // the step up. This happens near wall / slope combinations, and can + // cause the player to hop up higher on a slope too steep to climb VectorCopy (nosteporg, SVvector (ent, origin)); VectorCopy (nostepvel, SVvector (ent, velocity)); } } - /* -================ -SV_Physics_Client + SV_Physics_Client -Player character actions -================ + Player character actions */ void SV_Physics_Client (edict_t *ent, int num) @@ -1093,36 +978,32 @@ SV_Physics_Client (edict_t *ent, int num) if (!svs.clients[num - 1].active) return; // unconnected slot -// -// call standard client pre-think -// + // call standard client pre-think *sv_globals.time = sv.time; *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent); PR_ExecuteProgram (&sv_pr_state, sv_funcs.PlayerPreThink); -// -// do a move -// + // do a move SV_CheckVelocity (ent); -// -// decide which move function to call -// + // decide which move function to call switch ((int) SVfloat (ent, movetype)) { - case MOVETYPE_NONE: + case MOVETYPE_NONE: if (!SV_RunThink (ent)) return; break; - case MOVETYPE_WALK: + case MOVETYPE_WALK: if (!SV_RunThink (ent)) return; - if (!SV_CheckWater (ent) && !((int) SVfloat (ent, flags) & FL_WATERJUMP)) + if (!SV_CheckWater (ent) && !((int) SVfloat (ent, flags) & + FL_WATERJUMP)) SV_AddGravity (ent); SV_CheckStuck (ent); #ifdef QUAKE2 - VectorAdd (SVfloat (ent, velocity), SVfloat (ent, basevelocity), SVfloat (ent, velocity)); + VectorAdd (SVfloat (ent, velocity), SVfloat (ent, basevelocity), + SVfloat (ent, velocity)); #endif SV_WalkMove (ent); @@ -1132,32 +1013,30 @@ SV_Physics_Client (edict_t *ent, int num) #endif break; - case MOVETYPE_TOSS: - case MOVETYPE_BOUNCE: + case MOVETYPE_TOSS: + case MOVETYPE_BOUNCE: SV_Physics_Toss (ent); break; - case MOVETYPE_FLY: + case MOVETYPE_FLY: if (!SV_RunThink (ent)) return; SV_FlyMove (ent, host_frametime, NULL); break; - case MOVETYPE_NOCLIP: + case MOVETYPE_NOCLIP: if (!SV_RunThink (ent)) return; VectorMA (SVvector (ent, origin), host_frametime, SVvector (ent, velocity), SVvector (ent, origin)); break; - default: + default: Sys_Error ("SV_Physics_client: bad movetype %i", (int) SVfloat (ent, movetype)); } -// -// call standard player post-think -// + // call standard player post-think SV_LinkEdict (ent, true); *sv_globals.time = sv.time; @@ -1166,78 +1045,57 @@ SV_Physics_Client (edict_t *ent, int num) sv_funcs.PlayerPostThink); } -//============================================================================ - /* -============= -SV_Physics_None + SV_Physics_None -Non moving objects can only think -============= + Non moving objects can only think */ void SV_Physics_None (edict_t *ent) { -// regular thinking +// regular thinking SV_RunThink (ent); } #ifdef QUAKE2 /* -============= -SV_Physics_Follow + SV_Physics_Follow -Entities that are "stuck" to another entity -============= + Entities that are "stuck" to another entity */ void SV_Physics_Follow (edict_t *ent) { -// regular thinking + // regular thinking SV_RunThink (ent); VectorAdd (PROG_TO_EDICT (&sv_pr_state, SVfloat (ent, aiment))->v.v.origin, SVfloat (ent, v_angle), SVfloat (ent, origin)); SV_LinkEdict (ent, true); } - #endif /* -============= -SV_Physics_Noclip + SV_Physics_Noclip -A moving object that doesn't obey physics -============= + A moving object that doesn't obey physics */ void SV_Physics_Noclip (edict_t *ent) { -// regular thinking + // regular thinking if (!SV_RunThink (ent)) return; - VectorMA (SVvector (ent, angles), host_frametime, SVvector (ent, avelocity), - SVvector (ent, angles)); + VectorMA (SVvector (ent, angles), host_frametime, + SVvector (ent, avelocity), SVvector (ent, angles)); VectorMA (SVvector (ent, origin), host_frametime, SVvector (ent, velocity), SVvector (ent, origin)); SV_LinkEdict (ent, false); } -/* -============================================================================== +// TOSS / BOUNCE ============================================================== -TOSS / BOUNCE - -============================================================================== -*/ - -/* -============= -SV_CheckWaterTransition - -============= -*/ void SV_CheckWaterTransition (edict_t *ent) { @@ -1253,6 +1111,7 @@ SV_CheckWaterTransition (edict_t *ent) #else cont = SV_PointContents (SVvector (ent, origin)); #endif + if (!SVfloat (ent, watertype)) { // just spawned here SVfloat (ent, watertype) = cont; SVfloat (ent, waterlevel) = 1; @@ -1260,15 +1119,15 @@ SV_CheckWaterTransition (edict_t *ent) } if (cont <= CONTENTS_WATER) { - if (SVfloat (ent, watertype) == CONTENTS_EMPTY) { // just crossed into - // water + if (SVfloat (ent, watertype) == CONTENTS_EMPTY) { + // just crossed into water SV_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1); } SVfloat (ent, watertype) = cont; SVfloat (ent, waterlevel) = 1; } else { - if (SVfloat (ent, watertype) != CONTENTS_EMPTY) { // just crossed into - // water + if (SVfloat (ent, watertype) != CONTENTS_EMPTY) { + // just crossed into water SV_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1); } SVfloat (ent, watertype) = CONTENTS_EMPTY; @@ -1277,25 +1136,24 @@ SV_CheckWaterTransition (edict_t *ent) } /* -============= -SV_Physics_Toss + SV_Physics_Toss -Toss, bounce, and fly movement. When onground, do nothing. -============= + Toss, bounce, and fly movement. When onground, do nothing. */ void SV_Physics_Toss (edict_t *ent) { + float backoff; trace_t trace; vec3_t move; - float backoff; #ifdef QUAKE2 edict_t *groundentity; groundentity = PROG_TO_EDICT (&sv_pr_state, SVentity (ent, groundentity)); if ((int) SVfloat (groundentity, flags) & FL_CONVEYOR) - VectorScale (SVfloat (groundentity, movedir), SVfloat (groundentity, speed), + VectorScale (SVfloat (groundentity, movedir), + SVfloat (groundentity, speed), SVfloat (ent, basevelocity)); else VectorCopy (vec_origin, SVfloat (ent, basevelocity)); @@ -1316,31 +1174,31 @@ SV_Physics_Toss (edict_t *ent) SV_CheckVelocity (ent); -// add gravity + // add gravity if (!((int) SVfloat (ent, flags) & FL_ONGROUND) && SVfloat (ent, movetype) != MOVETYPE_FLY && SVfloat (ent, movetype) != MOVETYPE_BOUNCEMISSILE && SVfloat (ent, movetype) != MOVETYPE_FLYMISSILE) SV_AddGravity (ent); - #else -// if onground, return without moving + // if onground, return without moving if (((int) SVfloat (ent, flags) & FL_ONGROUND)) return; SV_CheckVelocity (ent); -// add gravity + // add gravity if (SVfloat (ent, movetype) != MOVETYPE_FLY && SVfloat (ent, movetype) != MOVETYPE_FLYMISSILE) SV_AddGravity (ent); #endif -// move angles - VectorMA (SVvector (ent, angles), host_frametime, SVvector (ent, avelocity), - SVvector (ent, angles)); + // move angles + VectorMA (SVvector (ent, angles), host_frametime, + SVvector (ent, avelocity), SVvector (ent, angles)); -// move origin + // move origin #ifdef QUAKE2 - VectorAdd (SVvector (ent, velocity), SVvector (ent, basevelocity), SVvector (ent, velocity)); + VectorAdd (SVvector (ent, velocity), SVvector (ent, basevelocity), + SVvector (ent, velocity)); #endif VectorScale (SVvector (ent, velocity), host_frametime, move); trace = SV_PushEntity (ent, move); @@ -1362,63 +1220,56 @@ SV_Physics_Toss (edict_t *ent) else backoff = 1; - ClipVelocity (SVvector (ent, velocity), trace.plane.normal, SVvector (ent, velocity), - backoff); + ClipVelocity (SVvector (ent, velocity), trace.plane.normal, + SVvector (ent, velocity), backoff); -// stop if on ground + // stop if on ground if (trace.plane.normal[2] > 0.7) { #ifdef QUAKE2 if (SVvector (ent, velocity)[2] < 60 || (SVfloat (ent, movetype) != MOVETYPE_BOUNCE && SVfloat (ent, movetype) != MOVETYPE_BOUNCEMISSILE)) #else - if (SVvector (ent, velocity)[2] < 60 || SVfloat (ent, movetype) != MOVETYPE_BOUNCE) + if (SVvector (ent, velocity)[2] < 60 || SVfloat (ent, movetype) != + MOVETYPE_BOUNCE) #endif { SVfloat (ent, flags) = (int) SVfloat (ent, flags) | FL_ONGROUND; - SVentity (ent, groundentity) = EDICT_TO_PROG (&sv_pr_state, trace.ent); + SVentity (ent, groundentity) = EDICT_TO_PROG (&sv_pr_state, + trace.ent); VectorCopy (vec3_origin, SVvector (ent, velocity)); VectorCopy (vec3_origin, SVvector (ent, avelocity)); } } -// check for in water + // check for in water SV_CheckWaterTransition (ent); } -/* -=============================================================================== - -STEPPING MOVEMENT - -=============================================================================== -*/ +// STEPPING MOVEMENT ========================================================== /* -============= -SV_Physics_Step + SV_Physics_Step -Monsters freefall when they don't have a ground entity, otherwise -all movement is done with discrete steps. + Monsters freefall when they don't have a ground entity, otherwise + all movement is done with discrete steps. -This is also used for objects that have become still on the ground, but -will fall if the floor is pulled out from under them. -============= + This is also used for objects that have become still on the ground, but + will fall if the floor is pulled out from under them. */ #ifdef QUAKE2 void SV_Physics_Step (edict_t *ent) { - qboolean wasonground; - qboolean inwater; - qboolean hitsound = false; + float control, friction, speed, newspeed; float *vel; - float speed, newspeed, control; - float friction; edict_t *groundentity; + qboolean wasonground, inwater; + qboolean hitsound = false; groundentity = PROG_TO_EDICT (&sv_pr_state, SVfloat (ent, groundentity)); if ((int) SVfloat (groundentity, flags) & FL_CONVEYOR) - VectorScale (SVfloat (groundentity, movedir), SVfloat (groundentity, speed), + VectorScale (SVfloat (groundentity, movedir), + SVfloat (groundentity, speed), SVfloat (ent, basevelocity)); else VectorCopy (vec_origin, SVfloat (ent, basevelocity)); @@ -1430,11 +1281,10 @@ SV_Physics_Step (edict_t *ent) SV_CheckVelocity (ent); wasonground = (int) SVfloat (ent, flags) & FL_ONGROUND; -// SVfloat (ent, flags) = (int)SVfloat (ent, flags) & ~FL_ONGROUND; +// SVfloat (ent, flags) = (int)SVfloat (ent, flags) & ~FL_ONGROUND; // add gravity except: - // flying monsters - // swimming monsters who are in the water + // flying monsters and swimming monsters who are in the water inwater = SV_CheckWater (ent); if (!wasonground) if (!((int) SVfloat (ent, flags) & FL_FLY)) @@ -1458,9 +1308,8 @@ SV_Physics_Step (edict_t *ent) if (speed) { friction = sv_friction->value; - control = - speed < - sv_stopspeed->value ? sv_stopspeed->value : speed; + control = speed value ? + sv_stopspeed->value : speed; newspeed = speed - host_frametime * control * friction; if (newspeed < 0) @@ -1472,15 +1321,16 @@ SV_Physics_Step (edict_t *ent) } } - VectorAdd (SVfloat (ent, velocity), SVfloat (ent, basevelocity), SVfloat (ent, velocity)); + VectorAdd (SVfloat (ent, velocity), SVfloat (ent, basevelocity), + SVfloat (ent, velocity)); SV_FlyMove (ent, host_frametime, NULL); VectorSubtract (SVfloat (ent, velocity), SVfloat (ent, basevelocity), SVfloat (ent, velocity)); // determine if it's on solid ground at all { - vec3_t mins, maxs, point; int x, y; + vec3_t mins, maxs, point; VectorAdd (SVfloat (ent, origin), SVfloat (ent, mins), mins); VectorAdd (SVfloat (ent, origin), SVfloat (ent, maxs), maxs); @@ -1491,11 +1341,11 @@ SV_Physics_Step (edict_t *ent) point[0] = x ? maxs[0] : mins[0]; point[1] = y ? maxs[1] : mins[1]; if (SV_PointContents (point) == CONTENTS_SOLID) { - SVfloat (ent, flags) = (int) SVfloat (ent, flags) | FL_ONGROUND; + SVfloat (ent, flags) = (int) SVfloat (ent, flags) | + FL_ONGROUND; break; } } - } SV_LinkEdict (ent, true); @@ -1505,7 +1355,7 @@ SV_Physics_Step (edict_t *ent) if (hitsound) SV_StartSound (ent, 0, "demon/dland2.wav", 255, 1); } -// regular thinking + // regular thinking SV_RunThink (ent); SV_CheckWaterTransition (ent); } @@ -1515,7 +1365,7 @@ SV_Physics_Step (edict_t *ent) { qboolean hitsound; -// freefall if not onground + // freefall if not onground if (!((int) SVfloat (ent, flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) { if (SVvector (ent, velocity)[2] < sv_gravity->value * -0.1) hitsound = true; @@ -1533,28 +1383,20 @@ SV_Physics_Step (edict_t *ent) SV_StartSound (ent, 0, "demon/dland2.wav", 255, 1); } } -// regular thinking + // regular thinking SV_RunThink (ent); SV_CheckWaterTransition (ent); } #endif -//============================================================================ - -/* -================ -SV_Physics - -================ -*/ void SV_Physics (void) { int i; edict_t *ent; -// let the progs know that a new frame has started + // let the progs know that a new frame has started *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv.edicts); *sv_globals.other = @@ -1562,11 +1404,9 @@ SV_Physics (void) *sv_globals.time = sv.time; PR_ExecuteProgram (&sv_pr_state, sv_funcs.StartFrame); -//SV_CheckAllEnts (); +// SV_CheckAllEnts (); -// -// treat each object in turn -// + // treat each object in turn ent = sv.edicts; for (i = 0; i < sv.num_edicts; i++, ent = NEXT_EDICT (&sv_pr_state, ent)) { if (ent->free) @@ -1599,7 +1439,8 @@ SV_Physics (void) || SVfloat (ent, movetype) == MOVETYPE_FLYMISSILE) SV_Physics_Toss (ent); else - Sys_Error ("SV_Physics: bad movetype %i", (int) SVfloat (ent, movetype)); + Sys_Error ("SV_Physics: bad movetype %i", + (int) SVfloat (ent, movetype)); } if (*sv_globals.force_retouch) @@ -1608,20 +1449,17 @@ SV_Physics (void) sv.time += host_frametime; } - #ifdef QUAKE2 trace_t SV_Trace_Toss (edict_t *ent, edict_t *ignore) { + double save_frametime; + vec3_t end, move; edict_t tempent, *tent; trace_t trace; - vec3_t move; - vec3_t end; - double save_frametime; - -// extern particle_t *active_particles, *free_particles; -// particle_t *p; +// extern particle_t *active_particles, *free_particles; +// particle_t *p; save_frametime = host_frametime; host_frametime = 0.05; @@ -1633,8 +1471,8 @@ SV_Trace_Toss (edict_t *ent, edict_t *ignore) while (1) { SV_CheckVelocity (tent); SV_AddGravity (tent); - VectorMA (SVfloat (tent, angles), host_frametime, SVfloat (tent, avelocity), - SVfloat (tent, angles)); + VectorMA (SVfloat (tent, angles), host_frametime, + SVfloat (tent, avelocity), SVfloat (tent, angles)); VectorScale (SVfloat (tent, velocity), host_frametime, move); VectorAdd (SVfloat (tent, origin), move, end); trace = @@ -1642,25 +1480,25 @@ SV_Trace_Toss (edict_t *ent, edict_t *ignore) MOVE_NORMAL, tent); VectorCopy (trace.endpos, SVfloat (tent, origin)); -// p = free_particles; -// if (p) -// { -// free_particles = p->next; -// p->next = active_particles; -// active_particles = p; +// p = free_particles; +// if (p) +// { +// free_particles = p->next; +// p->next = active_particles; +// active_particles = p; // -// p->die = 256; -// p->color = 15; -// p->type = pt_static; -// VectorCopy (vec3_origin, p->vel); -// VectorCopy (SVfloat (tent, origin), p->org); -// } +// p->die = 256; +// p->color = 15; +// p->type = pt_static; +// VectorCopy (vec3_origin, p->vel); +// VectorCopy (SVfloat (tent, origin), p->org); +// } if (trace.ent) if (trace.ent != ignore) break; } -// p->color = 224; +// p->color = 224; host_frametime = save_frametime; return trace; } diff --git a/nq/source/sv_progs.c b/nq/source/sv_progs.c index 0e50e7da6..5bc1fa3a2 100644 --- a/nq/source/sv_progs.c +++ b/nq/source/sv_progs.c @@ -29,12 +29,11 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif - #ifdef HAVE_STRING_H -#include "string.h" +# include "string.h" #endif #ifdef HAVE_STRINGS_H -#include "strings.h" +# include "strings.h" #endif #include "QF/cmd.h" @@ -42,10 +41,10 @@ #include "QF/cvar.h" #include "host.h" +#include "progdefs.h" #include "server.h" #include "sv_progs.h" #include "world.h" -#include "progdefs.h" progs_t sv_pr_state; sv_globals_t sv_globals; @@ -98,9 +97,9 @@ ED_PrintEdicts_f (void) } /* - ED_PrintEdict_f + ED_PrintEdict_f - For debugging, prints a single edicy + For debugging, prints a single edicy */ void ED_PrintEdict_f (void) @@ -144,42 +143,70 @@ SV_LoadProgs (void) (void *) sv_globals.other = PR_GetGlobalPointer (&sv_pr_state, "other"); (void *) sv_globals.world = PR_GetGlobalPointer (&sv_pr_state, "world"); (void *) sv_globals.time = PR_GetGlobalPointer (&sv_pr_state, "time"); - (void *) sv_globals.frametime = PR_GetGlobalPointer (&sv_pr_state, "frametime"); - (void *) sv_globals.force_retouch = PR_GetGlobalPointer (&sv_pr_state, "force_retouch"); - (void *) sv_globals.mapname = PR_GetGlobalPointer (&sv_pr_state, "mapname"); - (void *) sv_globals.deathmatch = PR_GetGlobalPointer (&sv_pr_state, "deathmatch"); + (void *) sv_globals.frametime = PR_GetGlobalPointer (&sv_pr_state, + "frametime"); + (void *) sv_globals.force_retouch = PR_GetGlobalPointer (&sv_pr_state, + "force_retouch"); + (void *) sv_globals.mapname = PR_GetGlobalPointer (&sv_pr_state, + "mapname"); + (void *) sv_globals.deathmatch = PR_GetGlobalPointer (&sv_pr_state, + "deathmatch"); (void *) sv_globals.coop = PR_GetGlobalPointer (&sv_pr_state, "coop"); - (void *) sv_globals.teamplay = PR_GetGlobalPointer (&sv_pr_state, "teamplay"); - (void *) sv_globals.serverflags = PR_GetGlobalPointer (&sv_pr_state, "serverflags"); - (void *) sv_globals.total_secrets = PR_GetGlobalPointer (&sv_pr_state, "total_secrets"); - (void *) sv_globals.total_monsters = PR_GetGlobalPointer (&sv_pr_state, "total_monsters"); - (void *) sv_globals.found_secrets = PR_GetGlobalPointer (&sv_pr_state, "found_secrets"); - (void *) sv_globals.killed_monsters = PR_GetGlobalPointer (&sv_pr_state, "killed_monsters"); + (void *) sv_globals.teamplay = PR_GetGlobalPointer (&sv_pr_state, + "teamplay"); + (void *) sv_globals.serverflags = PR_GetGlobalPointer (&sv_pr_state, + "serverflags"); + (void *) sv_globals.total_secrets = PR_GetGlobalPointer (&sv_pr_state, + "total_secrets"); + (void *) sv_globals.total_monsters = PR_GetGlobalPointer + (&sv_pr_state, "total_monsters"); + (void *) sv_globals.found_secrets = PR_GetGlobalPointer (&sv_pr_state, + "found_secrets"); + (void *) sv_globals.killed_monsters = PR_GetGlobalPointer + (&sv_pr_state, "killed_monsters"); (void *) sv_globals.parms = PR_GetGlobalPointer (&sv_pr_state, "parm1"); - (void *) sv_globals.v_forward = PR_GetGlobalPointer (&sv_pr_state, "v_forward"); + (void *) sv_globals.v_forward = PR_GetGlobalPointer (&sv_pr_state, + "v_forward"); (void *) sv_globals.v_up = PR_GetGlobalPointer (&sv_pr_state, "v_up"); - (void *) sv_globals.v_right = PR_GetGlobalPointer (&sv_pr_state, "v_right"); - (void *) sv_globals.trace_allsolid = PR_GetGlobalPointer (&sv_pr_state, "trace_allsolid"); - (void *) sv_globals.trace_startsolid = PR_GetGlobalPointer (&sv_pr_state, "trace_startsolid"); - (void *) sv_globals.trace_fraction = PR_GetGlobalPointer (&sv_pr_state, "trace_fraction"); - (void *) sv_globals.trace_endpos = PR_GetGlobalPointer (&sv_pr_state, "trace_endpos"); - (void *) sv_globals.trace_plane_normal = PR_GetGlobalPointer (&sv_pr_state, "trace_plane_normal"); - (void *) sv_globals.trace_plane_dist = PR_GetGlobalPointer (&sv_pr_state, "trace_plane_dist"); - (void *) sv_globals.trace_ent = PR_GetGlobalPointer (&sv_pr_state, "trace_ent"); - (void *) sv_globals.trace_inopen = PR_GetGlobalPointer (&sv_pr_state, "trace_inopen"); - (void *) sv_globals.trace_inwater = PR_GetGlobalPointer (&sv_pr_state, "trace_inwater"); - (void *) sv_globals.msg_entity = PR_GetGlobalPointer (&sv_pr_state, "msg_entity"); + (void *) sv_globals.v_right = PR_GetGlobalPointer (&sv_pr_state, + "v_right"); + (void *) sv_globals.trace_allsolid = PR_GetGlobalPointer + (&sv_pr_state, "trace_allsolid"); + (void *) sv_globals.trace_startsolid = PR_GetGlobalPointer + (&sv_pr_state, "trace_startsolid"); + (void *) sv_globals.trace_fraction = PR_GetGlobalPointer + (&sv_pr_state, "trace_fraction"); + (void *) sv_globals.trace_endpos = PR_GetGlobalPointer (&sv_pr_state, + "trace_endpos"); + (void *) sv_globals.trace_plane_normal = PR_GetGlobalPointer + (&sv_pr_state, "trace_plane_normal"); + (void *) sv_globals.trace_plane_dist = PR_GetGlobalPointer + (&sv_pr_state, "trace_plane_dist"); + (void *) sv_globals.trace_ent = PR_GetGlobalPointer (&sv_pr_state, + "trace_ent"); + (void *) sv_globals.trace_inopen = PR_GetGlobalPointer (&sv_pr_state, + "trace_inopen"); + (void *) sv_globals.trace_inwater = PR_GetGlobalPointer (&sv_pr_state, + "trace_inwater"); + (void *) sv_globals.msg_entity = PR_GetGlobalPointer (&sv_pr_state, + "msg_entity"); sv_funcs.main = PR_GetFunctionIndex (&sv_pr_state, "main"); sv_funcs.StartFrame = PR_GetFunctionIndex (&sv_pr_state, "StartFrame"); - sv_funcs.PlayerPreThink = PR_GetFunctionIndex (&sv_pr_state, "PlayerPreThink"); - sv_funcs.PlayerPostThink = PR_GetFunctionIndex (&sv_pr_state, "PlayerPostThink"); + sv_funcs.PlayerPreThink = PR_GetFunctionIndex (&sv_pr_state, + "PlayerPreThink"); + sv_funcs.PlayerPostThink = PR_GetFunctionIndex (&sv_pr_state, + "PlayerPostThink"); sv_funcs.ClientKill = PR_GetFunctionIndex (&sv_pr_state, "ClientKill"); - sv_funcs.ClientConnect = PR_GetFunctionIndex (&sv_pr_state, "ClientConnect"); - sv_funcs.PutClientInServer = PR_GetFunctionIndex (&sv_pr_state, "PutClientInServer"); - sv_funcs.ClientDisconnect = PR_GetFunctionIndex (&sv_pr_state, "ClientDisconnect"); + sv_funcs.ClientConnect = PR_GetFunctionIndex (&sv_pr_state, + "ClientConnect"); + sv_funcs.PutClientInServer = PR_GetFunctionIndex (&sv_pr_state, + "PutClientInServer"); + sv_funcs.ClientDisconnect = PR_GetFunctionIndex (&sv_pr_state, + "ClientDisconnect"); sv_funcs.SetNewParms = PR_GetFunctionIndex (&sv_pr_state, "SetNewParms"); - sv_funcs.SetChangeParms = PR_GetFunctionIndex (&sv_pr_state, "SetChangeParms"); + sv_funcs.SetChangeParms = PR_GetFunctionIndex (&sv_pr_state, + "SetChangeParms"); sv_fields.modelindex = PR_GetFieldOffset (&sv_pr_state, "modelindex"); sv_fields.absmin = PR_GetFieldOffset (&sv_pr_state, "absmin"); @@ -235,7 +262,8 @@ SV_LoadProgs (void) sv_fields.colormap = PR_GetFieldOffset (&sv_pr_state, "colormap"); sv_fields.team = PR_GetFieldOffset (&sv_pr_state, "team"); sv_fields.max_health = PR_GetFieldOffset (&sv_pr_state, "max_health"); - sv_fields.teleport_time = PR_GetFieldOffset (&sv_pr_state, "teleport_time"); + sv_fields.teleport_time = PR_GetFieldOffset (&sv_pr_state, + "teleport_time"); sv_fields.armortype = PR_GetFieldOffset (&sv_pr_state, "armortype"); sv_fields.armorvalue = PR_GetFieldOffset (&sv_pr_state, "armorvalue"); sv_fields.waterlevel = PR_GetFieldOffset (&sv_pr_state, "waterlevel"); @@ -249,7 +277,8 @@ SV_LoadProgs (void) sv_fields.targetname = PR_GetFieldOffset (&sv_pr_state, "targetname"); sv_fields.dmg_take = PR_GetFieldOffset (&sv_pr_state, "dmg_take"); sv_fields.dmg_save = PR_GetFieldOffset (&sv_pr_state, "dmg_save"); - sv_fields.dmg_inflictor = PR_GetFieldOffset (&sv_pr_state, "dmg_inflictor"); + sv_fields.dmg_inflictor = PR_GetFieldOffset (&sv_pr_state, + "dmg_inflictor"); sv_fields.owner = PR_GetFieldOffset (&sv_pr_state, "owner"); sv_fields.movedir = PR_GetFieldOffset (&sv_pr_state, "movedir"); sv_fields.message = PR_GetFieldOffset (&sv_pr_state, "message"); @@ -264,7 +293,8 @@ SV_LoadProgs (void) sv_fields.dmgtime = ED_GetFieldIndex (&sv_pr_state, "dmgtime"); sv_fields.air_finished = ED_GetFieldIndex (&sv_pr_state, "air_finished"); sv_fields.pain_finished = ED_GetFieldIndex (&sv_pr_state, "pain_finished"); - sv_fields.radsuit_finished = ED_GetFieldIndex (&sv_pr_state, "radsuit_finished"); + sv_fields.radsuit_finished = ED_GetFieldIndex (&sv_pr_state, + "radsuit_finished"); sv_fields.speed = ED_GetFieldIndex (&sv_pr_state, "speed"); sv_fields.basevelocity = ED_GetFieldIndex (&sv_pr_state, "basevelocity"); sv_fields.drawPercent = ED_GetFieldIndex (&sv_pr_state, "drawPercent"); @@ -290,21 +320,21 @@ SV_Progs_Init (void) SV_PR_Cmds_Init (); - Cmd_AddCommand ("edict", ED_PrintEdict_f, - "Report information on a given edict in the game. (edict (edict number))"); + Cmd_AddCommand ("edict", ED_PrintEdict_f, "Report information on a given " + "edict in the game. (edict (edict number))"); Cmd_AddCommand ("edicts", ED_PrintEdicts_f, "Display information on all edicts in the game."); Cmd_AddCommand ("edictcount", ED_Count_f, "Display summary information on the edicts in the game."); - Cmd_AddCommand ("profile", PR_Profile_f, - "FIXME: Report information about QuakeC Stuff (\?\?\?) No Description"); + Cmd_AddCommand ("profile", PR_Profile_f, "FIXME: Report information " + "about QuakeC Stuff (\?\?\?) No Description"); } void SV_Progs_Init_Cvars (void) { r_skyname = Cvar_Get ("r_skyname", "", CVAR_SERVERINFO, Cvar_Info, - "name of skybox"); + "name of skybox"); sv_progs = Cvar_Get ("sv_progs", "progs.dat", CVAR_ROM, NULL, "Allows selectable game progs if you have several " "of them in the gamedir"); @@ -313,14 +343,14 @@ SV_Progs_Init_Cvars (void) "checkextentions qc function"); nomonsters = Cvar_Get ("nomonsters", "0", CVAR_NONE, NULL, - "No Description"); + "No Description"); gamecfg = Cvar_Get ("gamecfg", "0", CVAR_NONE, NULL, "No Description"); scratch1 = Cvar_Get ("scratch1", "0", CVAR_NONE, NULL, "No Description"); scratch2 = Cvar_Get ("scratch2", "0", CVAR_NONE, NULL, "No Description"); scratch3 = Cvar_Get ("scratch3", "0", CVAR_NONE, NULL, "No Description"); scratch4 = Cvar_Get ("scratch4", "0", CVAR_NONE, NULL, "No Description"); savedgamecfg = Cvar_Get ("savedgamecfg", "0", CVAR_ARCHIVE, NULL, - "No Description"); + "No Description"); saved1 = Cvar_Get ("saved1", "0", CVAR_ARCHIVE, NULL, "No Description"); saved2 = Cvar_Get ("saved2", "0", CVAR_ARCHIVE, NULL, "No Description"); saved3 = Cvar_Get ("saved3", "0", CVAR_ARCHIVE, NULL, "No Description"); diff --git a/nq/source/sv_user.c b/nq/source/sv_user.c index e2328a1d1..f7e8a24ca 100644 --- a/nq/source/sv_user.c +++ b/nq/source/sv_user.c @@ -31,18 +31,19 @@ # include "config.h" #endif -#include "server.h" -#include "QF/cvar.h" -#include "QF/msg.h" #include "QF/console.h" -#include "world.h" -#include "QF/keys.h" -#include "view.h" #include "QF/cmd.h" -#include "host.h" -#include "sv_progs.h" +#include "QF/cvar.h" +#include "QF/keys.h" +#include "QF/msg.h" #include "QF/sys.h" +#include "host.h" +#include "server.h" +#include "sv_progs.h" +#include "view.h" +#include "world.h" + edict_t *sv_player; cvar_t *sv_edgefriction; @@ -65,21 +66,17 @@ cvar_t *sv_idealpitchscale; cvar_t *cl_rollspeed; cvar_t *cl_rollangle; -/* -=============== -SV_SetIdealPitch -=============== -*/ #define MAX_FORWARD 6 + + void SV_SetIdealPitch (void) { + int dir, step, steps, i, j; float angleval, sinval, cosval; + float z[MAX_FORWARD]; trace_t tr; vec3_t top, bottom; - float z[MAX_FORWARD]; - int i, j; - int step, dir, steps; if (!((int) SVfloat (sv_player, flags) & FL_ONGROUND)) return; @@ -91,8 +88,8 @@ SV_SetIdealPitch (void) for (i = 0; i < MAX_FORWARD; i++) { top[0] = SVvector (sv_player, origin)[0] + cosval * (i + 3) * 12; top[1] = SVvector (sv_player, origin)[1] + sinval * (i + 3) * 12; - top[2] = SVvector (sv_player, origin)[2] + SVvector (sv_player, view_ofs)[2]; - + top[2] = SVvector (sv_player, origin)[2] + SVvector (sv_player, + view_ofs)[2]; bottom[0] = top[0]; bottom[1] = top[1]; bottom[2] = top[2] - 160; @@ -100,9 +97,7 @@ SV_SetIdealPitch (void) tr = SV_Move (top, vec3_origin, vec3_origin, bottom, 1, sv_player); if (tr.allsolid) return; // looking at a wall, leave ideal the - // - // way is was - + // way it was if (tr.fraction == 1) return; // near a dropoff @@ -133,20 +128,12 @@ SV_SetIdealPitch (void) SVfloat (sv_player, idealpitch) = -dir * sv_idealpitchscale->value; } - -/* -================== -SV_UserFriction - -================== -*/ void SV_UserFriction (void) { float *vel; - float speed, newspeed, control; + float control, friction, speed, newspeed; vec3_t start, stop; - float friction; trace_t trace; vel = velocity; @@ -155,7 +142,7 @@ SV_UserFriction (void) if (!speed) return; -// 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[1] = stop[1] = origin[1] + vel[1] / speed * 16; start[2] = origin[2] + SVvector (sv_player, mins)[2]; @@ -168,7 +155,7 @@ SV_UserFriction (void) else friction = sv_friction->value; -// apply friction + // apply friction control = speed < sv_stopspeed->value ? sv_stopspeed->value : speed; newspeed = speed - host_frametime * control * friction; @@ -181,11 +168,6 @@ SV_UserFriction (void) vel[2] = vel[2] * newspeed; } -/* -============== -SV_Accelerate -============== -*/ cvar_t *sv_maxspeed; cvar_t *sv_accelerate; @@ -211,6 +193,7 @@ SV_Accelerate (vec3_t wishvel) velocity[i] += accelspeed * pushvec[i]; } #endif + void SV_Accelerate (void) { @@ -242,7 +225,7 @@ SV_AirAccelerate (vec3_t wishveloc) addspeed = wishspd - currentspeed; if (addspeed <= 0) return; -// accelspeed = sv_accelerate->value * host_frametime; +// accelspeed = sv_accelerate->value * host_frametime; accelspeed = sv_accelerate->value * wishspeed * host_frametime; if (accelspeed > addspeed) accelspeed = addspeed; @@ -251,7 +234,6 @@ SV_AirAccelerate (vec3_t wishveloc) velocity[i] += accelspeed * wishveloc[i]; } - void DropPunchAngle (void) { @@ -262,25 +244,18 @@ DropPunchAngle (void) len -= 10 * host_frametime; if (len < 0) len = 0; - VectorScale (SVvector (sv_player, punchangle), len, SVvector (sv_player, punchangle)); + VectorScale (SVvector (sv_player, punchangle), len, SVvector (sv_player, + punchangle)); } -/* -=================== -SV_WaterMove - -=================== -*/ void SV_WaterMove (void) { int i; - vec3_t wishvel; float speed, newspeed, wishspeed, addspeed, accelspeed; + vec3_t wishvel; -// -// user intentions -// + // user intentions AngleVectors (SVvector (sv_player, v_angle), forward, right, up); for (i = 0; i < 3; i++) @@ -298,9 +273,7 @@ SV_WaterMove (void) } wishspeed *= 0.7; -// -// water friction -// + // water friction speed = Length (velocity); if (speed) { newspeed = speed - host_frametime * speed * sv_friction->value; @@ -310,9 +283,7 @@ SV_WaterMove (void) } else newspeed = 0; -// -// water acceleration -// + // water acceleration if (!wishspeed) return; @@ -332,34 +303,29 @@ SV_WaterMove (void) void SV_WaterJump (void) { - if (sv.time > SVfloat (sv_player, teleport_time) || !SVfloat (sv_player, waterlevel)) { - SVfloat (sv_player, flags) = (int) SVfloat (sv_player, flags) & ~FL_WATERJUMP; + if (sv.time > SVfloat (sv_player, teleport_time) || + !SVfloat (sv_player, waterlevel)) { + SVfloat (sv_player, flags) = (int) SVfloat (sv_player, flags) & + ~FL_WATERJUMP; SVfloat (sv_player, teleport_time) = 0; } SVvector (sv_player, velocity)[0] = SVvector (sv_player, movedir)[0]; SVvector (sv_player, velocity)[1] = SVvector (sv_player, movedir)[1]; } - -/* -=================== -SV_AirMove - -=================== -*/ void SV_AirMove (void) { int i; - vec3_t wishvel; float fmove, smove; + vec3_t wishvel; AngleVectors (SVvector (sv_player, angles), forward, right, up); fmove = cmd.forwardmove; smove = cmd.sidemove; -// hack to not let you back into teleporter + // hack to not let you back into teleporter if (sv.time < SVfloat (sv_player, teleport_time) && fmove < 0) fmove = 0; @@ -383,20 +349,16 @@ SV_AirMove (void) } else if (onground) { SV_UserFriction (); SV_Accelerate (); - } else { // not on ground, so little effect on - // - // velocity + } else { // not on ground, so little effect on velocity SV_AirAccelerate (wishvel); } } /* -=================== -SV_ClientThink + SV_ClientThink -the move fields specify an intended velocity in pix/sec -the angle fields specify an exact angular motion in degrees -=================== + the move fields specify an intended velocity in pix/sec + the angle fields specify an exact angular motion in degrees */ void SV_ClientThink (void) @@ -413,21 +375,19 @@ SV_ClientThink (void) DropPunchAngle (); -// -// if dead, behave differently -// + // if dead, behave differently if (SVfloat (sv_player, health) <= 0) return; -// -// angles -// show 1/3 the pitch angle and all the roll angle + // angles + // show 1/3 the pitch angle and all the roll angle cmd = host_client->cmd; angles = SVvector (sv_player, angles); - VectorAdd (SVvector (sv_player, v_angle), SVvector (sv_player, punchangle), v_angle); - angles[ROLL] = - V_CalcRoll (SVvector (sv_player, angles), SVvector (sv_player, velocity)) * 4; + VectorAdd (SVvector (sv_player, v_angle), SVvector (sv_player, + punchangle), v_angle); + angles[ROLL] = V_CalcRoll (SVvector (sv_player, angles), + SVvector (sv_player, velocity)) * 4; if (!SVfloat (sv_player, fixangle)) { angles[PITCH] = -v_angle[PITCH] / 3; angles[YAW] = v_angle[YAW]; @@ -437,9 +397,7 @@ SV_ClientThink (void) SV_WaterJump (); return; } -// -// walk -// + // walk if ((SVfloat (sv_player, waterlevel) >= 2) && (SVfloat (sv_player, movetype) != MOVETYPE_NOCLIP)) { SV_WaterMove (); @@ -449,36 +407,29 @@ SV_ClientThink (void) SV_AirMove (); } - -/* -=================== -SV_ReadClientMove -=================== -*/ void SV_ReadClientMove (usercmd_t *move) { - int i; + int i, bits; vec3_t angle; - int bits; -// read ping time + // read ping time host_client->ping_times[host_client->num_pings % NUM_PING_TIMES] = sv.time - MSG_ReadFloat (net_message); host_client->num_pings++; -// read current angles + // read current angles for (i = 0; i < 3; i++) angle[i] = MSG_ReadAngle (net_message); VectorCopy (angle, SVvector (host_client->edict, v_angle)); -// read movement + // read movement move->forwardmove = MSG_ReadShort (net_message); move->sidemove = MSG_ReadShort (net_message); move->upmove = MSG_ReadShort (net_message); -// read buttons + // read buttons bits = MSG_ReadByte (net_message); SVfloat (host_client->edict, button0) = bits & 1; SVfloat (host_client->edict, button2) = (bits & 2) >> 1; @@ -488,23 +439,20 @@ SV_ReadClientMove (usercmd_t *move) SVfloat (host_client->edict, impulse) = i; #ifdef QUAKE2 -// read light level + // read light level SVfloat (host_client->edict, light_level) = MSG_ReadByte (net_message); #endif } /* -=================== -SV_ReadClientMessage + SV_ReadClientMessage -Returns false if the client should be killed -=================== + Returns false if the client should be killed */ qboolean SV_ReadClientMessage (void) { - int ret; - int cmd; + int cmd, ret; char *s; do { @@ -531,18 +479,18 @@ SV_ReadClientMessage (void) cmd = MSG_ReadChar (net_message); switch (cmd) { - case -1: + case -1: goto nextmsg; // end of message - default: + default: Sys_Printf ("SV_ReadClientMessage: unknown command char\n"); return false; - case clc_nop: -// Sys_Printf ("clc_nop\n"); + case clc_nop: +// Sys_Printf ("clc_nop\n"); break; - case clc_stringcmd: + case clc_stringcmd: s = MSG_ReadString (net_message); if (host_client->privileged) ret = 2; @@ -594,11 +542,11 @@ SV_ReadClientMessage (void) Con_DPrintf ("%s tried to %s\n", host_client->name, s); break; - case clc_disconnect: -// Sys_Printf ("SV_ReadClientMessage: client disconnected\n"); + case clc_disconnect: +// Sys_Printf ("SV_ReadClientMessage: client disconnected\n"); return false; - case clc_move: + case clc_move: SV_ReadClientMove (&host_client->cmd); break; } @@ -608,12 +556,6 @@ SV_ReadClientMessage (void) return true; } - -/* -================== -SV_RunClients -================== -*/ void SV_RunClients (void) { @@ -636,26 +578,21 @@ SV_RunClients (void) memset (&host_client->cmd, 0, sizeof (host_client->cmd)); continue; } -// always pause in single player if in console or menus + // always pause in single player if in console or menus if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game)) SV_ClientThink (); } } /* -=============== -V_CalcRoll + V_CalcRoll -Used by view and sv_user -=============== + Used by view and sv_user */ - float V_CalcRoll (vec3_t angles, vec3_t velocity) { - float sign; - float side; - float value; + float side, sign, value; AngleVectors (angles, forward, right, up); side = DotProduct (velocity, right); @@ -663,8 +600,8 @@ V_CalcRoll (vec3_t angles, vec3_t velocity) side = fabs (side); value = cl_rollangle->value; -// if (cl.inwater) -// value *= 6; +// if (cl.inwater) +// value *= 6; if (side < cl_rollspeed->value) side = side * value / cl_rollspeed->value; @@ -672,5 +609,4 @@ V_CalcRoll (vec3_t angles, vec3_t velocity) side = value; return side * sign; - } diff --git a/nq/source/sys_null.c b/nq/source/sys_null.c index 2c0b48f91..1305d9d97 100644 --- a/nq/source/sys_null.c +++ b/nq/source/sys_null.c @@ -1,7 +1,7 @@ /* sys_null.c - @description@ + (description) Copyright (C) 1996-1997 Id Software, Inc. @@ -32,17 +32,13 @@ #include "errno.h" -/* -=============================================================================== - -VFile IO - -=============================================================================== -*/ - #define MAX_HANDLES 10 + VFile *sys_handles[MAX_HANDLES]; + +// VFile IO =================================================================== + int findhandle (void) { @@ -55,16 +51,10 @@ findhandle (void) return -1; } -/* -================ -filelength -================ -*/ int filelength (VFile *f) { - int pos; - int end; + int pos, end; pos = ftell (f); fseek (f, 0, SEEK_END); @@ -153,15 +143,7 @@ Sys_mkdir (char *path) { } - -/* -=============================================================================== - -SYSTEM IO - -=============================================================================== -*/ - +// SYSTEM IO ================================================================== void Sys_Error (char *error, ...) diff --git a/nq/source/sys_sdl.c b/nq/source/sys_sdl.c index c8299a9a8..34434efbc 100644 --- a/nq/source/sys_sdl.c +++ b/nq/source/sys_sdl.c @@ -29,38 +29,43 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif - -#include -#include -#include -#include -#include -#ifdef HAVE_IO_H -# include -#endif #ifdef HAVE_CONIO_H # include #endif +#ifdef HAVE_IO_H +# include +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif + +#include +#include +#include +#include +#include #ifndef _WIN32 -# include -# include -# include # include -# include # include -# include -# include +# include # include +# include #endif #include #include #include "QF/cvar.h" +#include "QF/qargs.h" +#include "QF/qargs.h" #include "QF/sys.h" -#include "QF/qargs.h" -#include "QF/qargs.h" #include "client.h" #include "compat.h" @@ -74,8 +79,7 @@ int noconinput; #ifdef _WIN32 # include "winquake.h" - // FIXME: minimized is not currently supported under - // SDL +// FIXME: minimized is not currently supported under SDL qboolean Minimized = false; void MaskExceptions (void); #endif @@ -110,8 +114,7 @@ Sys_Init (void) #endif #ifdef _WIN32 - // make sure the timer is high precision, otherwise - // NT gets 18ms resolution + // make sure the timer is high precision, otherwise NT gets 18ms resolution timeBeginPeriod (1); vinfo.dwOSVersionInfoSize = sizeof (vinfo); @@ -127,9 +130,6 @@ Sys_Init (void) #endif } -/* - Sys_Quit -*/ void Sys_Quit (void) { @@ -137,9 +137,6 @@ Sys_Quit (void) exit (0); } -/* - Sys_Error -*/ void Sys_Error (const char *error, ...) { @@ -189,14 +186,12 @@ Sys_ConsoleInput (void) return NULL; } - #ifndef USE_INTEL_ASM void Sys_HighFPPrecision (void) { } - void Sys_LowFPPrecision (void) { @@ -215,8 +210,8 @@ Sys_Sleep (void) int SDL_main (int c, char **v) { - double time, oldtime, newtime; int j; + double time, oldtime, newtime; #ifndef WIN32 signal (SIGFPE, SIG_IGN); @@ -249,7 +244,7 @@ SDL_main (int c, char **v) oldtime = Sys_DoubleTime (); while (1) { -// find time spent rendering last frame + // find time spent rendering last frame newtime = Sys_DoubleTime (); time = newtime - oldtime; diff --git a/nq/source/sys_unix.c b/nq/source/sys_unix.c index 5bce6cc98..e9b6646fd 100644 --- a/nq/source/sys_unix.c +++ b/nq/source/sys_unix.c @@ -36,23 +36,26 @@ #ifdef HAVE_STRINGS_H # include #endif +#ifdef HAVE_UNISTD_H +# include +#endif +#include +#include +#include #include #include -#include -#include +#include +#include #include #include -#include -#include -#include -#include #include "QF/sys.h" #include "QF/qargs.h" #include "QF/cvar.h" -#include "server.h" + #include "host.h" +#include "server.h" qboolean isDedicated; @@ -72,9 +75,6 @@ Sys_Init (void) #endif } -/* - Sys_Quit -*/ void Sys_Quit (void) { @@ -84,16 +84,13 @@ Sys_Quit (void) exit (0); } -/* - Sys_Error -*/ void Sys_Error (const char *error, ...) { va_list argptr; char string[1024]; -// change stdin to non blocking + // change stdin to non blocking fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY); va_start (argptr, error); @@ -125,7 +122,7 @@ Sys_DebugLog (const char *file, const char *fmt, ...) void floating_point_exception_handler (int whatever) { -// Sys_Warn("floating point exception\n"); +// Sys_Warn("floating point exception\n"); signal (SIGFPE, floating_point_exception_handler); } @@ -171,7 +168,6 @@ void Sys_LowFPPrecision (void) { } - #endif int @@ -200,8 +196,8 @@ main (int c, const char *v[]) parms.membase = malloc (parms.memsize); parms.basedir = basedir; -// caching is disabled by default, use -cachedir to enable -// parms.cachedir = cachedir; + // caching is disabled by default, use -cachedir to enable +// parms.cachedir = cachedir; fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY); @@ -220,15 +216,14 @@ main (int c, const char *v[]) oldtime = Sys_DoubleTime () - 0.1; while (1) { -// find time spent rendering last frame + // find time spent rendering last frame newtime = Sys_DoubleTime (); time = newtime - oldtime; if (cls.state == ca_dedicated) { // play vcrfiles at max speed if (time < sys_ticrate->value && (!vcrFile || recording)) { usleep (1); - continue; // not time to run a server only tic - // yet + continue; // not time to run a server only tic yet } time = sys_ticrate->value; } @@ -239,8 +234,5 @@ main (int c, const char *v[]) oldtime += time; Host_Frame (time); - } - } - diff --git a/nq/source/sys_unixd.c b/nq/source/sys_unixd.c index c97f36852..cf0f81894 100644 --- a/nq/source/sys_unixd.c +++ b/nq/source/sys_unixd.c @@ -35,30 +35,33 @@ #ifdef HAVE_STRINGS_H # include #endif +#ifdef HAVE_UNISTD_H +# include +#endif -#include -#include -#include -#include -#include -#include +#include +#include #include +#include +#include #include #include +#include +#include #include +#include #include #include -#include +#include +#include #include -#include -#include -#include + +#include "QF/qargs.h" +#include "QF/qtypes.h" +#include "QF/sys.h" #include "client.h" -#include "QF/sys.h" #include "host.h" -#include "QF/qtypes.h" -#include "QF/qargs.h" qboolean isDedicated; @@ -71,6 +74,7 @@ cvar_t *sys_linerefresh; cvar_t *timestamps; cvar_t *timeformat; + int Sys_FileOpenRead (char *path, int *handle) { @@ -187,7 +191,7 @@ Sys_Error (char *error, ...) va_list argptr; char string[1024]; -// change stdin to non blocking + // change stdin to non blocking fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY); va_start (argptr, error); @@ -234,7 +238,6 @@ Sys_DoubleTime (void) return (tp.tv_sec - secbase) + tp.tv_usec / 1000000.0; } - char * Sys_ConsoleInput (void) { @@ -329,4 +332,3 @@ main (int argc, char *argv[]) } return true; // return success } - diff --git a/nq/source/sys_win.c b/nq/source/sys_win.c index 593cd61d3..38889441f 100644 --- a/nq/source/sys_win.c +++ b/nq/source/sys_win.c @@ -82,20 +82,15 @@ void Sys_PopFPCW (void); volatile int sys_checksum; -/* -================ -Sys_PageIn -================ -*/ void Sys_PageIn (void *ptr, int size) { byte *x; int m, n; -// touch all the memory to make sure it's there. The 16-page skip is to -// keep Win 95 from thinking we're trying to page ourselves in (we are -// doing that, of course, but there's no reason we shouldn't) + // touch all the memory to make sure it's there. The 16-page skip is to + // keep Win 95 from thinking we're trying to page ourselves in (we are + // doing that, of course, but there's no reason we shouldn't) x = (byte *) ptr; for (n = 0; n < 4; n++) { @@ -106,14 +101,7 @@ Sys_PageIn (void *ptr, int size) } } - -/* -=============================================================================== - -FILE IO - -=============================================================================== -*/ +// FILE IO ==================================================================== #define MAX_HANDLES 10 VFile *sys_handles[MAX_HANDLES]; @@ -130,15 +118,7 @@ findhandle (void) return -1; } - -/* -=============================================================================== - -SYSTEM IO - -=============================================================================== -*/ - +// SYSTEM IO ================================================================== #ifndef USE_INTEL_ASM @@ -164,11 +144,6 @@ MaskExceptions (void) #endif -/* -================ -Sys_Init -================ -*/ void Sys_Init (void) { @@ -182,8 +157,8 @@ Sys_Init (void) if (!QueryPerformanceFrequency (&PerformanceFreq)) Sys_Error ("No hardware timer available"); -// get 32 out of the 64 time bits such that we have around -// 1 microsecond resolution + // get 32 out of the 64 time bits such that we have around + // 1 microsecond resolution lowpart = (unsigned int) PerformanceFreq.LowPart; highpart = (unsigned int) PerformanceFreq.HighPart; lowshift = 0; @@ -215,7 +190,6 @@ Sys_Init (void) WinNT = false; } - void Sys_Error (const char *error, ...) { @@ -252,7 +226,6 @@ Sys_Error (const char *error, ...) WriteFile (houtput, text3, strlen (text3), &dummy, NULL); WriteFile (houtput, text4, strlen (text4), &dummy, NULL); - starttime = Sys_DoubleTime (); sc_return_on_enter = true; // so Enter will get us out of here @@ -261,8 +234,7 @@ Sys_Error (const char *error, ...) } } else { // switch to windowed so the message box is visible, unless we - // already - // tried that and failed + // already tried that and failed if (!in_sys_error0) { in_sys_error0 = 1; VID_SetDefaultMode (); @@ -278,7 +250,7 @@ Sys_Error (const char *error, ...) in_sys_error1 = 1; Host_Shutdown (); } -// shut down QHOST hooks if necessary + // shut down QHOST hooks if necessary if (!in_sys_error2) { in_sys_error2 = 1; DeinitConProc (); @@ -287,7 +259,6 @@ Sys_Error (const char *error, ...) exit (1); } - void Sys_Quit (void) { @@ -302,18 +273,12 @@ Sys_Quit (void) if (isDedicated) FreeConsole (); -// shut down QHOST hooks if necessary + // shut down QHOST hooks if necessary DeinitConProc (); exit (0); } - -/* -================ -Sys_InitFloatTime -================ -*/ void Sys_InitFloatTime (void) { @@ -332,7 +297,6 @@ Sys_InitFloatTime (void) lastcurtime = curtime; } - const char * Sys_ConsoleInput (void) { @@ -347,7 +311,6 @@ Sys_ConsoleInput (void) if (!isDedicated) return NULL; - for (;;) { if (!GetNumberOfConsoleInputEvents (hinput, &numevents)) Sys_Error ("Error getting # of console events"); @@ -366,7 +329,7 @@ Sys_ConsoleInput (void) ch = recs[0].Event.KeyEvent.uChar.AsciiChar; switch (ch) { - case '\r': + case '\r': WriteFile (houtput, "\r\n", 2, &dummy, NULL); if (len) { @@ -383,14 +346,14 @@ Sys_ConsoleInput (void) break; - case '\b': + case '\b': WriteFile (houtput, "\b \b", 3, &dummy, NULL); if (len) { len--; } break; - default: + default: if (ch >= ' ') { WriteFile (houtput, &ch, 1, &dummy, NULL); text[len] = ch; @@ -413,41 +376,20 @@ Sys_Sleep (void) Sleep (1); } +// WINDOWS CRAP =============================================================== -/* -============================================================================== - - WINDOWS CRAP - -============================================================================== -*/ - - -/* -================== -WinMain -================== -*/ void SleepUntilInput (int time) { - MsgWaitForMultipleObjects (1, &tevent, FALSE, time, QS_ALLINPUT); } - -/* -================== -WinMain -================== -*/ HINSTANCE global_hInstance; int global_nCmdShow; char *argv[MAX_NUM_ARGVS]; static char *empty_string = ""; HWND hwnd_dialog; - int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) @@ -496,7 +438,6 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, *lpCmdLine = 0; lpCmdLine++; } - } } @@ -510,8 +451,8 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, isDedicated = (COM_CheckParm ("-dedicated") != 0); if (!isDedicated) { - hwnd_dialog = - CreateDialog (hInstance, MAKEINTRESOURCE (IDD_DIALOG1), NULL, NULL); + hwnd_dialog = CreateDialog (hInstance, MAKEINTRESOURCE (IDD_DIALOG1), + NULL, NULL); if (hwnd_dialog) { if (GetWindowRect (hwnd_dialog, &rect)) { @@ -528,9 +469,9 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, SetForegroundWindow (hwnd_dialog); } } -// take the greater of all the available memory or half the total memory, -// but at least 8 Mb and no more than 16 Mb, unless they explicitly -// request otherwise + // take the greater of all the available memory or half the total memory, + // but at least 8 Mb and no more than 16 Mb, unless they explicitly + // request otherwise parms.memsize = lpBuffer.dwAvailPhys; if (parms.memsize < MINIMUM_WIN_MEMORY) diff --git a/nq/source/sys_wind.c b/nq/source/sys_wind.c index 5de28c183..3218538e0 100644 --- a/nq/source/sys_wind.c +++ b/nq/source/sys_wind.c @@ -30,23 +30,18 @@ # include "config.h" #endif -#include "winquake.h" -#include "errno.h" #include #include +#include "winquake.h" +#include "errno.h" -/* -=============================================================================== - -FILE IO - -=============================================================================== -*/ +// FILE IO ==================================================================== #define MAX_HANDLES 10 VFile *sys_handles[MAX_HANDLES]; + int findhandle (void) { @@ -59,11 +54,6 @@ findhandle (void) return -1; } -/* -================ -filelength -================ -*/ int filelength (VFile *f) { @@ -157,15 +147,7 @@ Sys_mkdir (char *path) { } - -/* -=============================================================================== - -SYSTEM IO - -=============================================================================== -*/ - +// SYSTEM IO ================================================================== void Sys_DebugLog (char *file, char *fmt, ...) @@ -182,7 +164,7 @@ Sys_Error (char *error, ...) vsnprintf (text, sizeof (text), error, argptr); va_end (argptr); -// MessageBox(NULL, text, "Error", 0 /* MB_OK */ ); +// MessageBox(NULL, text, "Error", 0 /* MB_OK */ ); printf ("ERROR: %s\n", text); exit (1); @@ -225,7 +207,6 @@ Sys_Sleep (void) { } - void IN_SendKeyEvents (void) { @@ -278,14 +259,6 @@ Sys_ConsoleInput (void) return NULL; } - - -/* -================== -main - -================== -*/ char *newargv[256]; int @@ -305,7 +278,7 @@ main (int argc, char **argv) if (cwd[Q_strlen (cwd) - 1] == '\\') cwd[Q_strlen (cwd) - 1] = 0; parms.basedir = cwd; // "f:/quake"; -// parms.basedir = "f:\\quake"; +// parms.basedir = "f:\\quake"; COM_InitArgv (argc, argv); diff --git a/nq/source/world.c b/nq/source/world.c index 3ed114caa..107d991ad 100644 --- a/nq/source/world.c +++ b/nq/source/world.c @@ -39,14 +39,10 @@ #include "world.h" /* - -entities never clip against themselves, or their owner - -line of sight checks trace->crosscontent, but bullets don't - + entities never clip against themselves, or their owner + line of sight checks trace->crosscontent, but bullets don't */ - typedef struct { vec3_t boxmins, boxmaxs; // enclose the test object along // entire move @@ -59,12 +55,9 @@ typedef struct { edict_t *passedict; } moveclip_t; - int SV_HullPointContents (hull_t *hull, int num, vec3_t p); -/* - HULL BOXES -*/ +/* HULL BOXES */ static hull_t box_hull; static dclipnode_t box_clipnodes[6]; @@ -105,7 +98,6 @@ SV_InitBoxHull (void) } - /* SV_HullForBox @@ -125,7 +117,6 @@ SV_HullForBox (vec3_t mins, vec3_t maxs) return &box_hull; } - /* SV_HullForEntity @@ -175,10 +166,7 @@ SV_HullForEntity (edict_t *ent, vec3_t mins, vec3_t maxs, vec3_t offset) return hull; } - -/* - ENTITY AREA CHECKING -*/ +/* ENTITY AREA CHECKING */ typedef struct areanode_s { int axis; // -1 = leaf node @@ -194,7 +182,6 @@ typedef struct areanode_s { static areanode_t sv_areanodes[AREA_NODES]; static int sv_numareanodes; - areanode_t * SV_CreateAreaNode (int depth, vec3_t mins, vec3_t maxs) { @@ -234,7 +221,6 @@ SV_CreateAreaNode (int depth, vec3_t mins, vec3_t maxs) return anode; } - void SV_ClearWorld (void) { @@ -245,7 +231,6 @@ SV_ClearWorld (void) SV_CreateAreaNode (0, sv.worldmodel->mins, sv.worldmodel->maxs); } - void SV_UnlinkEdict (edict_t *ent) { @@ -255,7 +240,6 @@ SV_UnlinkEdict (edict_t *ent) ent->area.prev = ent->area.next = NULL; } - void SV_TouchLinks (edict_t *ent, areanode_t *node) { @@ -302,7 +286,6 @@ SV_TouchLinks (edict_t *ent, areanode_t *node) SV_TouchLinks (ent, node->children[1]); } - void SV_FindTouchedLeafs (edict_t *ent, mnode_t *node) { @@ -340,7 +323,6 @@ SV_FindTouchedLeafs (edict_t *ent, mnode_t *node) SV_FindTouchedLeafs (ent, node->children[1]); } - void SV_LinkEdict (edict_t *ent, qboolean touch_triggers) { @@ -410,11 +392,7 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers) SV_TouchLinks (ent, sv_areanodes); } - -/* - POINT TESTING IN HULLS -*/ - +/* POINT TESTING IN HULLS */ #ifndef USE_INTEL_ASM int @@ -445,7 +423,6 @@ SV_HullPointContents (hull_t *hull, int num, vec3_t p) } #endif // !USE_INTEL_ASM - int SV_PointContents (vec3_t p) { @@ -457,14 +434,12 @@ SV_PointContents (vec3_t p) return cont; } - int SV_TruePointContents (vec3_t p) { return SV_HullPointContents (&sv.worldmodel->hulls[0], 0, p); } - /* SV_TestEntityPosition @@ -486,15 +461,11 @@ SV_TestEntityPosition (edict_t *ent) return NULL; } - -/* - LINE TESTING IN HULLS -*/ +/* LINE TESTING IN HULLS */ // 1/32 epsilon to keep floating point happy #define DIST_EPSILON (0.03125) - qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace) @@ -619,7 +590,6 @@ SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, return false; } - /* SV_ClipMoveToEntity @@ -663,7 +633,6 @@ SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, return trace; } - /* SV_ClipToLinks @@ -743,7 +712,6 @@ SV_ClipToLinks (areanode_t *node, moveclip_t * clip) SV_ClipToLinks (node->children[1], clip); } - void SV_MoveBounds (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, vec3_t boxmins, vec3_t boxmaxs) @@ -767,7 +735,6 @@ SV_MoveBounds (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, #endif } - trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, edict_t *passedict)