diff --git a/qw/source/sv_ccmds.c b/qw/source/sv_ccmds.c index c059cba08..3c3fa283b 100644 --- a/qw/source/sv_ccmds.c +++ b/qw/source/sv_ccmds.c @@ -39,16 +39,16 @@ #include #include "QF/cmd.h" -#include "compat.h" #include "QF/cvar.h" #include "QF/msg.h" #include "QF/qargs.h" #include "QF/qendian.h" -#include "QF/vfs.h" #include "QF/sys.h" #include "QF/va.h" +#include "QF/vfs.h" #include "bothdefs.h" +#include "compat.h" #include "server.h" #include "sv_progs.h" @@ -59,6 +59,7 @@ char fp_msg[255] = { 0 }; extern cvar_t *cl_warncmd; extern redirect_t sv_redirected; + qboolean SV_Match_User (const char *substr, int *uidp) { @@ -147,10 +148,6 @@ SV_SetMaster_f (void) svs.last_heartbeat = -99999; } - -/* - SV_Quit_f -*/ void SV_Quit_f (void) { @@ -160,9 +157,6 @@ SV_Quit_f (void) Sys_Quit (); } -/* - SV_Logfile_f -*/ void SV_Logfile_f (void) { @@ -182,10 +176,6 @@ SV_Logfile_f (void) SV_Printf ("failed.\n"); } - -/* - SV_Fraglogfile_f -*/ void SV_Fraglogfile_f (void) { @@ -219,7 +209,6 @@ SV_Fraglogfile_f (void) SV_Printf ("Logging frags to %s.\n", name); } - /* SV_SetPlayer @@ -229,8 +218,7 @@ qboolean SV_SetPlayer (void) { client_t *cl; - int i; - int idnum; + int i, idnum; idnum = atoi (Cmd_Argv (1)); @@ -247,7 +235,6 @@ SV_SetPlayer (void) return false; } - /* SV_God_f @@ -272,7 +259,6 @@ SV_God_f (void) SV_ClientPrintf (host_client, PRINT_HIGH, "godmode ON\n"); } - void SV_Noclip_f (void) { @@ -294,10 +280,6 @@ SV_Noclip_f (void) } } - -/* - SV_Give_f -*/ void SV_Give_f (void) { @@ -399,7 +381,6 @@ SV_Map_f (void) SV_BroadcastCommand ("reconnect\n"); } - /* SV_Kick_f @@ -439,10 +420,6 @@ SV_Kick_f (void) SV_Printf ("Couldn't find user number %i\n", uid); } - -/* - SV_Status_f -*/ void SV_Status_f (void) { @@ -463,7 +440,7 @@ SV_Status_f (void) SV_Printf ("avg response time: %i ms\n", (int) avg); SV_Printf ("packets/frame : %5.2f\n", pak); -// min fps lat drp + // min fps lat drp if (sv_redirected != RD_NONE) { // most remote clients are 40 columns // 0123456789012345678901234567890123456789 @@ -499,14 +476,15 @@ SV_Status_f (void) cl->netchan.incoming_sequence); } } else { - SV_Printf - ("frags userid address name rate ping drop qport\n"); - SV_Printf - ("----- ------ --------------- --------------- ---- ---- ----- -----\n"); + SV_Printf ("frags userid address name rate ping " + "drop qport\n"); + SV_Printf ("----- ------ --------------- --------------- ---- ---- " + "----- -----\n"); for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) { if (!cl->state) continue; - SV_Printf ("%5i %6i ", (int) SVfloat (cl->edict, frags), cl->userid); + SV_Printf ("%5i %6i ", (int) SVfloat (cl->edict, frags), + cl->userid); s = NET_BaseAdrToString (cl->netchan.remote_address); @@ -531,8 +509,6 @@ SV_Status_f (void) SV_Printf (" (s)\n"); else SV_Printf ("\n"); - - } } SV_Printf ("\n"); @@ -541,11 +517,10 @@ SV_Status_f (void) void SV_Tell (const char *prefix) { - int i; - int uid; - client_t *cl; char *p; char text[512]; + client_t *cl; + int i, uid; if (Cmd_Argc () < 3) { SV_Printf ("usage: tell \n"); @@ -587,10 +562,10 @@ SV_Tell (const char *prefix) void SV_ConSay (const char *prefix) { - client_t *client; - int j; char *p; char text[1024]; + client_t *client; + int j; if (Cmd_Argc () < 2) return; @@ -617,9 +592,6 @@ SV_ConSay (const char *prefix) } } -/* - SV_Tell_f -*/ void SV_Tell_f (void) { @@ -629,9 +601,6 @@ SV_Tell_f (void) SV_Tell("Console"); } -/* - SV_ConSay_f -*/ void SV_ConSay_f (void) { @@ -647,10 +616,6 @@ SV_ConSay_Info_f (void) SV_ConSay("Info"); } - -/* - SV_Heartbeat_f -*/ void SV_Heartbeat_f (void) { @@ -707,7 +672,6 @@ SV_Serverinfo_f (void) SV_SendServerInfoChange (Cmd_Argv (1), Cmd_Argv (2)); } - /* SV_Serverinfo_f @@ -736,7 +700,6 @@ SV_Localinfo_f (void) MAX_LOCALINFO_STRING, !sv_highchars->int_val); } - /* SV_User_f @@ -794,7 +757,6 @@ SV_Gamedir (void) Sets the gamedir and path to a different directory. */ - void SV_Floodprot_f (void) { @@ -803,7 +765,8 @@ SV_Floodprot_f (void) if (Cmd_Argc () == 1) { if (fp_messages) { SV_Printf - ("Current floodprot settings: \nAfter %d msgs per %d seconds, silence for %d seconds\n", + ("Current floodprot settings: \nAfter %d msgs per %d seconds, " + "silence for %d seconds\n", fp_messages, fp_persecond, fp_secondsdead); return; } else @@ -812,9 +775,11 @@ SV_Floodprot_f (void) if (Cmd_Argc () != 4) { SV_Printf - ("Usage: floodprot <# of messages> \n"); + ("Usage: floodprot <# of messages> \n"); SV_Printf - ("Use floodprotmsg to set a custom message to say to the flooder.\n"); + ("Use floodprotmsg to set a custom message to say to the " + "flooder.\n"); return; } @@ -850,15 +815,12 @@ SV_Floodprotmsg_f (void) snprintf (fp_msg, sizeof (fp_msg), "%s", Cmd_Argv (1)); } -/* - SV_Snap -*/ void SV_Snap (int uid) { - client_t *cl; char pcxname[80]; char checkname[MAX_OSPATH]; + client_t *cl; int i; for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) { @@ -902,9 +864,6 @@ SV_Snap (int uid) SV_Printf ("Requesting snap from user %d...\n", uid); } -/* - SV_Snap_f -*/ void SV_Snap_f (void) { @@ -920,9 +879,6 @@ SV_Snap_f (void) SV_Snap (uid); } -/* - SV_Snap -*/ void SV_SnapAll_f (void) { @@ -936,9 +892,6 @@ SV_SnapAll_f (void) } } -/* - SV_InitOperatorCommands -*/ void SV_InitOperatorCommands (void) { @@ -948,83 +901,114 @@ SV_InitOperatorCommands (void) MAX_SERVERINFO_STRING, 0); } - Cmd_AddCommand ("logfile", SV_Logfile_f, "Toggles logging of console text to qconsole.log"); - Cmd_AddCommand ("fraglogfile", SV_Fraglogfile_f, "Enables logging of kills to frag_##.log"); + Cmd_AddCommand ("logfile", SV_Logfile_f, "Toggles logging of console text " + "to qconsole.log"); + Cmd_AddCommand ("fraglogfile", SV_Fraglogfile_f, "Enables logging of kills " + "to frag_##.log"); - Cmd_AddCommand ("snap", SV_Snap_f, "FIXME: Take a screenshot of userid? No Description"); + Cmd_AddCommand ("snap", SV_Snap_f, "FIXME: Take a screenshot of userid? No " + "Description"); Cmd_AddCommand ("snapall", SV_SnapAll_f, "FIXME: No Description"); - Cmd_AddCommand ("kick", SV_Kick_f, "Remove a user from the server (kick userid)"); - Cmd_AddCommand ("status", SV_Status_f, "Report information on the current connected clients and the server - displays userids"); + Cmd_AddCommand ("kick", SV_Kick_f, "Remove a user from the server (kick " + "userid)"); + Cmd_AddCommand ("status", SV_Status_f, "Report information on the current " + "connected clients and the server - displays userids"); Cmd_AddCommand ("map", SV_Map_f, "Change to a new map (map mapname)"); - Cmd_AddCommand ("setmaster", SV_SetMaster_f, "Lists the server with up to eight masters.\n" - "When a server is listed with a master, the master is aware of the server's IP address and port and it is added to the\n" - "list of current servers connected to a master. A heartbeat is sent to the master from the server to indicated that the\n" - "server is still running and alive.\n" - "\n" - "Examples:\n" - "setmaster 192.246.40.12:27002\n" - "setmaster 192.246.40.12:27002 192.246.40.12:27004"); - - Cmd_AddCommand ("heartbeat", SV_Heartbeat_f, "Force a heartbeat to be sent to the master server.\n" - "A heartbeat tells the Master the server's IP address and that it is still alive."); + Cmd_AddCommand ("setmaster", SV_SetMaster_f, "Lists the server with up to " + "eight masters.\n" + "When a server is listed with a master, the master is " + "aware of the server's IP address and port and it is added " + "to the\n" + "list of current servers connected to a master. A " + "heartbeat is sent to the master from the server to " + "indicated that the\n" + "server is still running and alive.\n\n" + "Examples:\n" + "setmaster 192.246.40.12:27002\n" + "setmaster 192.246.40.12:27002 192.246.40.12:27004"); + Cmd_AddCommand ("heartbeat", SV_Heartbeat_f, "Force a heartbeat to be sent " + "to the master server.\n" + "A heartbeat tells the Master the server's IP address and " + "that it is still alive."); Cmd_AddCommand ("quit", SV_Quit_f, "Shut down the server"); - Cmd_AddCommand ("god", SV_God_f, "Toggle god cheat to userid (god userid) Requires cheats are enabled"); + Cmd_AddCommand ("god", SV_God_f, "Toggle god cheat to userid (god userid) " + "Requires cheats are enabled"); Cmd_AddCommand ("give", SV_Give_f, "Give userid items, or health.\n" - "Items: 1 Axe, 2 Shotgun, 3 Double-Barrelled Shotgun, 4 Nailgun, 5 Super Nailgun, 6 Grenade Launcher, 7 Rocket Launcher,\n" - "8 ThunderBolt, C Cells, H Health, N Nails, R Rockets, S Shells. Requires cheats are enabled. (give userid item amount)"); - Cmd_AddCommand ("noclip", SV_Noclip_f, "Toggle no clipping cheat for userid. Requires cheats are enabled. (noclip userid)"); - Cmd_AddCommand ("serverinfo", SV_Serverinfo_f, "Reports or sets information about server.\n" - "The information stored in this space is broadcast on the network to all players.\n" - "Values:\n" - "dq - Drop Quad Damage when a player dies.\n" - "dr - Drop Ring of Shadows when a player dies.\n" - "rj - Sets the multiplier rate for splash damage kick.\n" - "needpass - Displays the passwords enabled on the server.\n" - "watervis - Toggle the use of r_watervis by OpenGL clients.\n" - "Note: Keys with (*) in front cannot be changed. Maximum key size cannot exceed 64-bytes.\n" - "Maximum size for all keys cannot exceed 512-bytes.\n" - "(serverinfo key value)"); - - Cmd_AddCommand ("localinfo", SV_Localinfo_f, "Shows or sets localinfo variables.\n" - "Useful for mod programmers who need to allow the admin to change settings.\n" - "This is an alternative storage space to the serverinfo space for mod variables.\n" - "The variables stored in this space are not broadcast on the network.\n" - "This space also has a 32-kilobyte limit which is much greater then the 512-byte limit on the serverinfo space.\n" - "Special Keys: (current map) (next map) - Using this combination will allow the creation of a custom map cycle without editing code.\n" - "\n" - "Example:\n" - "localinfo dm2 dm4\n" - "localinfo dm4 dm6\n" - "localinfo dm6 dm2\n" - "(localinfo key value)"); - - Cmd_AddCommand ("user", SV_User_f, "Report information about the user (user userid)"); - Cmd_AddCommand ("sv_gamedir", SV_Gamedir, "Displays or determines the value of the serverinfo *gamedir variable.\n" - "Note: Useful when the physical gamedir directory has a different name than the widely accepted gamedir directory.\n" - "Example:\n" - "gamedir tf2_5; sv_gamedir fortress\n" - "gamedir ctf4_2; sv_gamedir ctf\n" - "(sv_gamedir dirname)"); - - Cmd_AddCommand ("floodprot", SV_Floodprot_f, "Sets the options for flood protection.\n" - "Default: 4 4 10\n" - "(floodprot (number of messages) (number of seconds) (silence time in seconds))"); - - Cmd_AddCommand ("floodprotmsg", SV_Floodprotmsg_f, "Sets the message displayed after flood protection is invoked (floodprotmsg message)"); - + "Items: 1 Axe, 2 Shotgun, 3 Double-Barrelled Shotgun, 4 " + "Nailgun, 5 Super Nailgun, 6 Grenade Launcher, 7 Rocket " + "Launcher,\n" + "8 ThunderBolt, C Cells, H Health, N Nails, R Rockets, S " + "Shells. Requires cheats to be enabled. (give userid item " + "amount)"); + Cmd_AddCommand ("noclip", SV_Noclip_f, "Toggle no clipping cheat for " + "userid. Requires cheats to be enabled. (noclip userid)"); + Cmd_AddCommand ("serverinfo", SV_Serverinfo_f, "Reports or sets " + "information about server.\n" + "The information stored in this space is broadcast on the " + "network to all players.\n" + "Values:\n" + "dq - Drop Quad Damage when a player dies.\n" + "dr - Drop Ring of Shadows when a player dies.\n" + "rj - Sets the multiplier rate for splash damage kick.\n" + "needpass - Displays the passwords enabled on the server.\n" + "watervis - Toggle the use of r_watervis by OpenGL " + "clients.\n" + "Note: Keys with (*) in front cannot be changed. Maximum " + "key size cannot exceed 64-bytes.\n" + "Maximum size for all keys cannot exceed 512-bytes.\n" + "(serverinfo key value)"); + Cmd_AddCommand ("localinfo", SV_Localinfo_f, "Shows or sets localinfo " + "variables.\n" + "Useful for mod programmers who need to allow the admin to " + "change settings.\n" + "This is an alternative storage space to the serverinfo " + "space for mod variables.\n" + "The variables stored in this space are not broadcast on " + "the network.\n" + "This space also has a 32-kilobyte limit which is much " + "greater then the 512-byte limit on the serverinfo space.\n" + "Special Keys: (current map) (next map) - Using this " + "combination will allow the creation of a custom map cycle " + "without editing code.\n\n" + "Example:\n" + "localinfo dm2 dm4\n" + "localinfo dm4 dm6\n" + "localinfo dm6 dm2\n" + "(localinfo key value)"); + Cmd_AddCommand ("user", SV_User_f, "Report information about the user " + "(user userid)"); + Cmd_AddCommand ("sv_gamedir", SV_Gamedir, "Displays or determines the " + "value of the serverinfo *gamedir variable.\n" + "Note: Useful when the physical gamedir directory has a " + "different name than the widely accepted gamedir " + "directory.\n" + "Example:\n" + "gamedir tf2_5; sv_gamedir fortress\n" + "gamedir ctf4_2; sv_gamedir ctf\n" + "(sv_gamedir dirname)"); + Cmd_AddCommand ("floodprot", SV_Floodprot_f, "Sets the options for flood " + "protection.\n" + "Default: 4 4 10\n" + "(floodprot (number of messages) (number of seconds) " + "(silence time in seconds))"); + Cmd_AddCommand ("floodprotmsg", SV_Floodprotmsg_f, "Sets the message " + "displayed after flood protection is invoked (floodprotmsg " + "message)"); Cmd_AddCommand ("maplist", COM_Maplist_f, "List all maps on the server"); - - Cmd_AddCommand ("say", SV_ConSay_f, "Say something to everyone on the server. Will show up as the name 'Console' (or 'Admin') in game"); - Cmd_AddCommand ("sayinfo", SV_ConSay_Info_f, "Say something to everyone on the server. Will show up as the name 'Info' in game"); - Cmd_AddCommand ("tell", SV_Tell_f, "Say something to a specific user on the server. Will show up as the name 'Console' (or 'Admin') in game"); + Cmd_AddCommand ("say", SV_ConSay_f, "Say something to everyone on the " + "server. Will show up as the name 'Console' (or 'Admin') " + "in game"); + Cmd_AddCommand ("sayinfo", SV_ConSay_Info_f, "Say something to everyone on " + "the server. Will show up as the name 'Info' in game"); + Cmd_AddCommand ("tell", SV_Tell_f, "Say something to a specific user on " + "the server. Will show up as the name 'Console' (or " + "'Admin') in game"); //XXX Cmd_AddCommand ("ban", SV_Ban_f); //XXX Cmd_AddCommand ("cuff", SV_Cuff_f); //XXX Cmd_AddCommand ("mute", SV_Mute_f); - cl_warncmd = - Cvar_Get ("cl_warncmd", "1", CVAR_NONE, NULL, - "Toggles the display of error messages for unknown commands"); - // poor - // description + cl_warncmd = Cvar_Get ("cl_warncmd", "1", CVAR_NONE, NULL, "Toggles the " + "display of error messages for unknown commands"); + // poor description } diff --git a/qw/source/sv_console.c b/qw/source/sv_console.c index 23381b766..e9ff9728b 100644 --- a/qw/source/sv_console.c +++ b/qw/source/sv_console.c @@ -32,10 +32,6 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include -#ifdef HAVE_UNISTD_H -# include -#endif #ifdef HAVE_CURSES_H # include #endif @@ -45,6 +41,11 @@ #ifdef HAVE_STRINGS_H # include #endif +#ifdef HAVE_UNISTD_H +# include +#endif + +#include #include "QF/cmd.h" #include "QF/console.h" @@ -93,6 +94,7 @@ static const byte attr_map[256] = { }; #endif + void Con_Init (const char *plugin_name) { diff --git a/qw/source/sv_cvar.c b/qw/source/sv_cvar.c index cba81ed5b..b6cc4990a 100644 --- a/qw/source/sv_cvar.c +++ b/qw/source/sv_cvar.c @@ -31,10 +31,12 @@ #endif #include "QF/cvar.h" + #include "server.h" void SV_SendServerInfoChange (const char *key, const char *value); + /* Cvar_Info @@ -43,7 +45,6 @@ void SV_SendServerInfoChange (const char *key, const char *value); high char filtering is performed according to sv_highchars.value */ - void Cvar_Info (cvar_t *var) { @@ -68,6 +69,6 @@ Cvar_Info (cvar_t *var) (sv_highchars && !sv_highchars->int_val)); SV_SendServerInfoChange (var->name, var->string); -// SV_BroadcastCommand ("fullserverinfo \"%s\"\n", svs.info); +// SV_BroadcastCommand ("fullserverinfo \"%s\"\n", svs.info); } } diff --git a/qw/source/sv_ents.c b/qw/source/sv_ents.c index fe8c06482..ea667e3c5 100644 --- a/qw/source/sv_ents.c +++ b/qw/source/sv_ents.c @@ -36,12 +36,14 @@ # include #endif -#include "compat.h" #include "QF/msg.h" +#include "QF/sys.h" + +#include "compat.h" #include "msg_ucmd.h" #include "server.h" #include "sv_progs.h" -#include "QF/sys.h" + /* The PVS must include a small area around the client to allow head @@ -50,16 +52,17 @@ when the bob crosses a waterline. */ -int fatbytes; byte fatpvs[MAX_MAP_LEAFS / 8]; +int fatbytes; + void SV_AddToFatPVS (vec3_t org, mnode_t *node) { - int i; byte *pvs; - mplane_t *plane; + int i; float d; + mplane_t *plane; while (1) { // if this is a leaf, accumulate the pvs bits @@ -100,10 +103,7 @@ SV_FatPVS (vec3_t org) return fatpvs; } -//============================================================================= - -// because there can be a lot of nails, there is a special -// network protocol for them +// nails are plentiful, so there is a special network protocol for them #define MAX_NAILS 32 edict_t *nails[MAX_NAILS]; int numnails; @@ -126,9 +126,8 @@ void SV_EmitNailUpdate (sizebuf_t *msg) { byte bits[6]; // [48 bits] xyzpy 12 12 12 4 8 - int n, i; + int i, n, p, x, y, z, yaw; edict_t *ent; - int x, y, z, p, yaw; if (!numnails) return; @@ -156,9 +155,6 @@ SV_EmitNailUpdate (sizebuf_t *msg) } } -//============================================================================= - - /* SV_WriteDelta @@ -169,11 +165,10 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, int stdver) { - int bits; - int i; + int bits, i; float miss; -// send an update + // send an update bits = 0; for (i = 0; i < 3; i++) { @@ -237,9 +232,7 @@ SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, if (to->flags & U_SOLID) bits |= U_SOLID; - // // write the message - // if (!to->number) SV_Error ("Unset entity number"); if (to->number >= 512) @@ -314,12 +307,10 @@ SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, void SV_EmitPacketEntities (client_t *client, packet_entities_t *to, sizebuf_t *msg) { + int newindex, oldindex, newnum, oldnum, oldmax; edict_t *ent; client_frame_t *fromframe; packet_entities_t *from; - int oldindex, newindex; - int oldnum, newnum; - int oldmax; // this is the frame that we are going to delta update from if (client->delta_sequence != -1) { @@ -338,15 +329,16 @@ SV_EmitPacketEntities (client_t *client, packet_entities_t *to, sizebuf_t *msg) newindex = 0; oldindex = 0; -//SV_Printf ("---%i to %i ----\n", client->delta_sequence & UPDATE_MASK -// , client->netchan.outgoing_sequence & UPDATE_MASK); +// SV_Printf ("---%i to %i ----\n", client->delta_sequence & UPDATE_MASK, +// client->netchan.outgoing_sequence & UPDATE_MASK); while (newindex < to->num_entities || oldindex < oldmax) { newnum = - newindex >= to->num_entities ? 9999 : to->entities[newindex].number; + newindex >= to->num_entities ? 9999 : + to->entities[newindex].number; oldnum = oldindex >= oldmax ? 9999 : from->entities[oldindex].number; if (newnum == oldnum) { // delta update from old position -//SV_Printf ("delta %i\n", newnum); +// SV_Printf ("delta %i\n", newnum); SV_WriteDelta (&from->entities[oldindex], &to->entities[newindex], msg, false, client->stdver); oldindex++; @@ -357,7 +349,7 @@ SV_EmitPacketEntities (client_t *client, packet_entities_t *to, sizebuf_t *msg) if (newnum < oldnum) { // this is a new entity, send it from // the baseline ent = EDICT_NUM (&sv_pr_state, newnum); -//SV_Printf ("baseline %i\n", newnum); +// SV_Printf ("baseline %i\n", newnum); SV_WriteDelta (ent->data, &to->entities[newindex], msg, true, client->stdver); newindex++; @@ -366,7 +358,7 @@ SV_EmitPacketEntities (client_t *client, packet_entities_t *to, sizebuf_t *msg) if (newnum > oldnum) { // the old entity isn't present in // the new message -//SV_Printf ("remove %i\n", oldnum); +// SV_Printf ("remove %i\n", oldnum); MSG_WriteShort (msg, oldnum | U_REMOVE); oldindex++; continue; @@ -376,19 +368,14 @@ SV_EmitPacketEntities (client_t *client, packet_entities_t *to, sizebuf_t *msg) MSG_WriteShort (msg, 0); // end of packetentities } -/* - SV_WritePlayersToClient -*/ void SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs, sizebuf_t *msg) { - int i, j; + int i, j, msec, pflags; client_t *cl; edict_t *ent; - int msec; usercmd_t cmd; - int pflags; for (j = 0, cl = svs.clients; j < MAX_CLIENTS; j++, cl++) { if (cl->state != cs_spawned) @@ -458,8 +445,8 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs, if (pflags & PF_COMMAND) { cmd = cl->lastcmd; - if (SVfloat (ent, health) <= 0) { // don't show the corpse looking - // around... + if (SVfloat (ent, health) <= 0) { // don't show the corpse + // looking around... cmd.angles[0] = 0; cmd.angles[1] = SVvector (ent, angles)[1]; cmd.angles[0] = 0; @@ -489,7 +476,6 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs, } } - /* SV_WriteEntitiesToClient @@ -501,14 +487,13 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs, void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg) { - int e, i; byte *pvs; + int e, i; vec3_t org; - edict_t *ent; - packet_entities_t *pack; - edict_t *clent; client_frame_t *frame; + edict_t *clent, *ent; entity_state_t *state; + packet_entities_t *pack; // this is the frame we are creating frame = &client->frames[client->netchan.incoming_sequence & UPDATE_MASK]; @@ -528,13 +513,14 @@ SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg) numnails = 0; - for (e = MAX_CLIENTS + 1, ent = EDICT_NUM (&sv_pr_state, e); e < sv.num_edicts; - e++, ent = NEXT_EDICT (&sv_pr_state, ent)) { + for (e = MAX_CLIENTS + 1, ent = EDICT_NUM (&sv_pr_state, e); e < + sv.num_edicts; e++, ent = NEXT_EDICT (&sv_pr_state, ent)) { if (ent->free) continue; // ignore ents without visible models - if (!SVfloat (ent, modelindex) || !*PR_GetString (&sv_pr_state, SVstring (ent, model))) + if (!SVfloat (ent, modelindex) || !*PR_GetString + (&sv_pr_state, SVstring (ent, model))) continue; // ignore if not touching a PV leaf @@ -582,7 +568,8 @@ SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg) state->scale = bound (0, SVfloat (ent, scale), 15.9375) * 16.0; if (sv_fields.glow_size != -1 && SVfloat (ent, glow_size)) - state->glow_size = bound (-1024, (int) SVfloat (ent, glow_size), 1016) >> 3; + state->glow_size = bound (-1024, (int) SVfloat + (ent, glow_size), 1016) >> 3; if (sv_fields.glow_color != -1 && SVvector (ent, glow_color)) state->glow_color = (int) SVvector (ent, glow_color); @@ -592,8 +579,10 @@ SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg) && SVvector (ent, colormod)[1] && SVvector (ent, colormod)[2]) state->colormod = - ((int) (bound (0, SVvector (ent, colormod)[0], 1) * 7.0) << 5) | - ((int) (bound (0, SVvector (ent, colormod)[1], 1) * 7.0) << 2) | + ((int) (bound (0, SVvector (ent, colormod)[0], 1) * 7.0) + << 5) | + ((int) (bound (0, SVvector (ent, colormod)[1], 1) * 7.0) + << 2) | (int) (bound (0, SVvector (ent, colormod)[2], 1) * 3.0); } // Ender: EXTEND (QSG - End) diff --git a/qw/source/sv_init.c b/qw/source/sv_init.c index 5e2a26cae..f88046341 100644 --- a/qw/source/sv_init.c +++ b/qw/source/sv_init.c @@ -43,22 +43,19 @@ #include "QF/vfs.h" #include "compat.h" +#include "crudefile.h" #include "server.h" #include "sv_progs.h" #include "world.h" -#include "crudefile.h" - -server_t sv; // local server - -char localmodels[MAX_MODELS][5]; // inline model names for precache char localinfo[MAX_LOCALINFO_STRING + 1]; // local game info +char localmodels[MAX_MODELS][5]; // inline model names for precache entity_state_t baselines[MAX_EDICTS]; -/* - SV_ModelIndex -*/ +server_t sv; // local server + + int SV_ModelIndex (const char *name) { @@ -105,9 +102,8 @@ SV_FlushSignon (void) void SV_CreateBaseline (void) { - int i; + int i, entnum; edict_t *svent; - int entnum; for (entnum = 0; entnum < sv.num_edicts; entnum++) { svent = EDICT_NUM (&sv_pr_state, entnum); @@ -118,16 +114,17 @@ SV_CreateBaseline (void) if (entnum > MAX_CLIENTS && !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)->skinnum = SVfloat (svent, skin); if (entnum > 0 && entnum <= MAX_CLIENTS) { ((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 = @@ -140,15 +137,10 @@ SV_CreateBaseline (void) ((entity_state_t*)svent->data)->glow_color = 254; ((entity_state_t*)svent->data)->colormod = 255; - // - // flush the signon message out to a seperate buffer if - // nearly full - // + // flush the signon message out to a seperate buffer if nearly full SV_FlushSignon (); - // // add to the message - // MSG_WriteByte (&sv.signon, svc_spawnbaseline); MSG_WriteShort (&sv.signon, entnum); @@ -157,13 +149,14 @@ SV_CreateBaseline (void) MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->colormap); MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->skinnum); 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_SaveSpawnparms @@ -182,7 +175,8 @@ SV_SaveSpawnparms (void) // serverflags is the only game related thing maintained svs.serverflags = *sv_globals.serverflags; - for (i = 0, host_client = svs.clients; i < MAX_CLIENTS; i++, host_client++) { + for (i = 0, host_client = svs.clients; i < MAX_CLIENTS; i++, host_client++) + { if (host_client->state != cs_spawned) continue; @@ -206,12 +200,10 @@ SV_SaveSpawnparms (void) void SV_CalcPHS (void) { - int rowbytes, rowwords; - int i, j, k, l, index, num; - int bitbyte; - unsigned int *dest, *src; byte *scan; - int count, vcount; + int bitbyte, count, index, num, rowbytes, rowwords, vcount, i, j, + k, l; + unsigned int *dest, *src; SV_Printf ("Building PHS...\n"); @@ -234,7 +226,6 @@ SV_CalcPHS (void) } } - sv.phs = Hunk_Alloc (rowbytes * num); count = 0; scan = sv.pvs; @@ -277,7 +268,7 @@ SV_CheckModel (const char *mdl) byte *buf; unsigned short crc = 0; -// int len; +// int len; buf = (byte *) COM_LoadStackFile (mdl, stackbuf, sizeof (stackbuf)); if (buf) { @@ -308,8 +299,7 @@ SV_SpawnServer (const char *server) SV_SaveSpawnparms (); svs.spawncount++; // any partially connected client - // will be - // restarted + // will be restarted sv.state = ss_dead; sv_pr_state.null_bad = 0; @@ -339,8 +329,8 @@ SV_SpawnServer (const char *server) strcpy (sv.name, server); - // load progs to get entity field count - // which determines how big each edict is + // load progs to get entity field count which determines how big each + // edict is SV_LoadProgs (); Info_SetValueForStarKey (svs.info, "*progs", va ("%i", sv_pr_state.crc), MAX_SERVERINFO_STRING, !sv_highchars->int_val); @@ -359,7 +349,7 @@ SV_SpawnServer (const char *server) for (i = 0; i < MAX_CLIENTS; i++) { ent = EDICT_NUM (&sv_pr_state, i + 1); svs.clients[i].edict = ent; -//ZOID - make sure we update frags right +// ZOID - make sure we update frags right svs.clients[i].old_frags = 0; } @@ -370,9 +360,7 @@ SV_SpawnServer (const char *server) sv.worldmodel = Mod_ForName (sv.modelname, true); SV_CalcPHS (); - // // clear physics interaction links - // SV_ClearWorld (); sv.sound_precache[0] = sv_pr_state.pr_strings; @@ -389,9 +377,7 @@ SV_SpawnServer (const char *server) sv.model_player_checksum = SV_CheckModel ("progs/player.mdl"); sv.eyes_player_checksum = SV_CheckModel ("progs/eyes.mdl"); - // // spawn the rest of the entities on the map - // // precache and static commands can be issued during // map initialization diff --git a/qw/source/sv_main.c b/qw/source/sv_main.c index f85d16172..06eade64f 100644 --- a/qw/source/sv_main.c +++ b/qw/source/sv_main.c @@ -56,17 +56,15 @@ #include "buildnum.h" #include "compat.h" #include "client.h" //FIXME needed by cls below (for netchan) +#include "crudefile.h" #include "game.h" #include "net.h" #include "pmove.h" #include "server.h" #include "sv_progs.h" -#include "crudefile.h" -quakeparms_t host_parms; -qboolean host_initialized; // true if into command execution - -qboolean rcon_from_user; +client_t *host_client; // current client +client_static_t cls; //FIXME needed by netchan :/ double sv_frametime; double realtime; // without any filtering or bounding @@ -75,8 +73,10 @@ int host_hunklevel; netadr_t master_adr[MAX_MASTERS]; // address of group servers -client_t *host_client; // current client -client_static_t cls; //FIXME needed by netchan :/ +quakeparms_t host_parms; + +qboolean host_initialized; // true if into command execution +qboolean rcon_from_user; // DoS protection // FLOOD_PING, FLOOD_LOG, FLOOD_CONNECT, FLOOD_STATUS, FLOOD_RCON, FLOOD_BAN @@ -85,31 +85,27 @@ client_static_t cls; //FIXME needed by netchan :/ double netdosexpire[DOSFLOODCMDS] = { 1, 1, 2, 0.9, 1, 5 }; double netdosvalues[DOSFLOODCMDS] = { 12, 1, 3, 1, 1, 1 }; -cvar_t *sv_netdosprotect; // tone down DoS from quake servers +cvar_t *fs_globalcfg; +cvar_t *fs_usercfg; cvar_t *sv_allow_status; cvar_t *sv_allow_log; cvar_t *sv_allow_ping; -cvar_t *fs_globalcfg; -cvar_t *fs_usercfg; - cvar_t *sv_mintic; // bound the size of the cvar_t *sv_maxtic; // physics time tic +cvar_t *sv_netdosprotect; // tone down DoS from quake servers + cvar_t *timeout; // seconds without any message cvar_t *zombietime; // seconds to sink messages after - // disconnect cvar_t *rcon_password; // password for remote server -cvar_t *admin_password; // password for admin - - // commands +cvar_t *admin_password; // password for admin commands cvar_t *password; // password for entering the game cvar_t *spectator_password; // password for entering as a - // spectator cvar_t *allow_download; @@ -119,7 +115,6 @@ cvar_t *allow_download_sounds; cvar_t *allow_download_maps; cvar_t *sv_highchars; - cvar_t *sv_phs; cvar_t *pausable; @@ -129,18 +124,14 @@ extern cvar_t *sv_timekick_fuzz; extern cvar_t *sv_timekick_interval; cvar_t *sv_minqfversion; // Minimum QF version allowed to - // connect cvar_t *sv_maxrate; // Maximum allowable rate (silently - // capped) cvar_t *sv_timestamps; cvar_t *sv_timefmt; -// // game rules mirrored in svs.info -// cvar_t *fraglimit; cvar_t *timelimit; cvar_t *teamplay; @@ -163,7 +154,6 @@ int pr_gc_count = 0; void SV_AcceptClient (netadr_t adr, int userid, char *userinfo); void Master_Shutdown (void); -//============================================================================ qboolean ServerPaused (void) @@ -234,8 +224,8 @@ SV_Error (const char *error, ...) void SV_FinalMessage (const char *message) { - int i; client_t *cl; + int i; SZ_Clear (net_message->message); MSG_WriteByte (net_message->message, svc_print); @@ -302,18 +292,11 @@ SV_DropClient (client_t *drop) SV_FullClientUpdate (drop, &sv.reliable_datagram); } - -//==================================================================== - -/* - SV_CalcPing -*/ int SV_CalcPing (client_t *cl) { float ping; - int i; - int count; + int count, i; register client_frame_t *frame; ping = 0; @@ -339,12 +322,12 @@ SV_CalcPing (client_t *cl) void SV_FullClientUpdate (client_t *client, sizebuf_t *buf) { - int i; char info[MAX_INFO_STRING]; + int i; i = client - svs.clients; -// SV_Printf("SV_FullClientUpdate: Updated frags for client %d\n", i); +// SV_Printf("SV_FullClientUpdate: Updated frags for client %d\n", i); MSG_WriteByte (buf, svc_updatefrags); MSG_WriteByte (buf, i); @@ -387,10 +370,7 @@ SV_FullClientUpdateToClient (client_t *client, client_t *cl) SV_FullClientUpdate (client, &cl->netchan.message); } - -/* - CONNECTIONLESS COMMANDS -*/ +/* CONNECTIONLESS COMMANDS */ /* CheckForFlood :: EXPERIMENTAL @@ -400,18 +380,15 @@ SV_FullClientUpdateToClient (client_t *client, client_t *cl) Bad sides: affects gamespy and spytools somewhat... */ - int CheckForFlood (flood_enum_t cmdtype) { - static qboolean firsttime = true; - static flood_t floodstatus[DOSFLOODCMDS][DOSFLOODIP]; - - int i; double currenttime; double oldestTime; static double lastmessagetime = 0; - int oldest; + static flood_t floodstatus[DOSFLOODCMDS][DOSFLOODIP]; + int oldest, i; + static qboolean firsttime = true; if (!sv_netdosprotect->int_val) return 0; @@ -476,10 +453,8 @@ CheckForFlood (flood_enum_t cmdtype) void SVC_Status (void) { - int i; client_t *cl; - int ping; - int top, bottom; + int ping, bottom, top, i; extern int con_printf_no_log; @@ -512,11 +487,10 @@ SVC_Status (void) con_printf_no_log = 0; } -/* - SV_CheckLog -*/ +/* SV_CheckLog */ #define LOG_HIGHWATER 4096 #define LOG_FLUSH 10*60 + void SV_CheckLog (void) { @@ -549,8 +523,8 @@ SV_CheckLog (void) void SVC_Log (void) { - int seq; char data[MAX_DATAGRAM + 64]; + int seq; if (!sv_allow_log->int_val) return; @@ -562,11 +536,8 @@ SVC_Log (void) else seq = -1; - if (seq == svs.logsequence - 1 || !sv_fraglogfile) { // they already - // have this - // data, or we - // aren't logging - // frags + if (seq == svs.logsequence - 1 || !sv_fraglogfile) { + // they already have this data, or we aren't logging frags data[0] = A2A_NACK; NET_SendPacket (1, data, net_from); return; @@ -575,9 +546,9 @@ SVC_Log (void) Con_DPrintf ("sending log %i to %s\n", svs.logsequence - 1, NET_AdrToString (net_from)); - // snprintf (data, sizeof (data), "stdlog %i\n", svs.logsequence-1); - // strncat (data, (char *)svs.log_buf[((svs.logsequence-1)&1)], - // sizeof(data) - strlen (data)); +// snprintf (data, sizeof (data), "stdlog %i\n", svs.logsequence-1); +// strncat (data, (char *)svs.log_buf[((svs.logsequence-1)&1)], +// sizeof(data) - strlen (data)); snprintf (data, sizeof (data), "stdlog %i\n%s", svs.logsequence - 1, (char *) svs.log_buf[((svs.logsequence - 1) & 1)]); @@ -617,9 +588,7 @@ SVC_Ping (void) void SVC_GetChallenge (void) { - int i; - int oldest; - int oldestTime; + int oldest, oldestTime, i; oldest = 0; oldestTime = 0x7fffffff; @@ -655,19 +624,14 @@ void SVC_DirectConnect (void) { char userinfo[1024]; - static int userid; - netadr_t adr; - int i; + const char *s; client_t *cl, *newcl; client_t temp; edict_t *ent; - int edictnum; - const char *s; - int clients, spectators; + int challenge, clients, edictnum, qport, spectators, version, i; + static int userid; + netadr_t adr; qboolean spectator; - int qport; - int version; - int challenge; if (CheckForFlood (FLOOD_CONNECT)) return; @@ -715,11 +679,13 @@ SVC_DirectConnect (void) if ((!s[0]) || sv_minqfversion->string[0]) { // kick old clients? if (ver_compare (s, sv_minqfversion->string) < 0) { SV_Printf ("%s: Version %s is less than minimum version %s.\n", - NET_AdrToString (net_from), s, sv_minqfversion->string); + NET_AdrToString (net_from), s, + sv_minqfversion->string); - Netchan_OutOfBandPrint (net_from, - "%c\nserver requires QuakeForge v%s or greater. Get it from http://www.quakeforge.net/\n", - A2C_PRINT, sv_minqfversion->string); + Netchan_OutOfBandPrint (net_from, "%c\nserver requires QuakeForge " + "v%s or greater. Get it from " + "http://www.quakeforge.net/\n", A2C_PRINT, + sv_minqfversion->string); return; } } @@ -899,8 +865,8 @@ Rcon_Validate (cvar_t *pass) char * Name_of_sender (void) { - int i; client_t *cl; + int i; for (i=0, cl=svs.clients ; istate == cs_free) @@ -914,13 +880,12 @@ Name_of_sender (void) return NULL; } - /* - SVC_RemoteCommand + SVC_RemoteCommand - A client issued an rcon command. - Shift down the remaining args - Redirect all printfs + A client issued an rcon command. + Shift down the remaining args + Redirect all printfs */ void SVC_RemoteCommand (void) @@ -929,8 +894,8 @@ SVC_RemoteCommand (void) int len = 0; char remaining[1024]; char *name; - qboolean do_cmd = false; qboolean admin_cmd = false; + qboolean do_cmd = false; if (CheckForFlood (FLOOD_RCON)) return; @@ -995,20 +960,18 @@ SVC_RemoteCommand (void) SV_EndRedirect (); } - /* - SV_ConnectionlessPacket + SV_ConnectionlessPacket - A connectionless packet has four leading 0xff - characters to distinguish it from a game channel. - Clients that are in the game can still send - connectionless packets. + A connectionless packet has four leading 0xff + characters to distinguish it from a game channel. + Clients that are in the game can still send + connectionless packets. */ void SV_ConnectionlessPacket (void) { - const char *s; - const char *c; + const char *c, *s; MSG_BeginReading (net_message); MSG_ReadLong (net_message); // skip the -1 marker @@ -1049,7 +1012,6 @@ SV_ConnectionlessPacket (void) /* PACKET FILTERING - You can add or remove addresses from the filter list with: addip @@ -1080,7 +1042,6 @@ SV_ConnectionlessPacket (void) from your local network. */ - typedef struct { unsigned int mask; unsigned int compare; @@ -1088,21 +1049,16 @@ typedef struct { #define MAX_IPFILTERS 1024 -ipfilter_t ipfilters[MAX_IPFILTERS]; -int numipfilters; - cvar_t *filterban; +int numipfilters; +ipfilter_t ipfilters[MAX_IPFILTERS]; -/* - StringToFilter -*/ qboolean StringToFilter (const char *s, ipfilter_t * f) { + byte b[4], m[4]; char num[128]; int i, j; - byte b[4]; - byte m[4]; for (i = 0; i < 4; i++) { b[i] = 0; @@ -1135,9 +1091,6 @@ StringToFilter (const char *s, ipfilter_t * f) return true; } -/* - SV_AddIP_f -*/ void SV_AddIP_f (void) { @@ -1158,14 +1111,11 @@ SV_AddIP_f (void) ipfilters[i].compare = 0xffffffff; } -/* - SV_RemoveIP_f -*/ void SV_RemoveIP_f (void) { - ipfilter_t f; int i, j; + ipfilter_t f; if (!StringToFilter (Cmd_Argv (1), &f)) return; @@ -1180,14 +1130,11 @@ SV_RemoveIP_f (void) SV_Printf ("Didn't find %s.\n", Cmd_Argv (1)); } -/* - SV_ListIP_f -*/ void SV_ListIP_f (void) { - int i; byte b[4]; + int i; SV_Printf ("Filter list:\n"); for (i = 0; i < numipfilters; i++) { @@ -1196,16 +1143,13 @@ SV_ListIP_f (void) } } -/* - SV_WriteIP_f -*/ void SV_WriteIP_f (void) { - VFile *f; - char name[MAX_OSPATH]; byte b[4]; + char name[MAX_OSPATH]; int i; + VFile *f; snprintf (name, sizeof (name), "%s/listip.cfg", com_gamedir); @@ -1225,14 +1169,10 @@ SV_WriteIP_f (void) Qclose (f); } -/* - netDoSexpire_f -*/ void SV_netDoSexpire_f (void) { - int arg1; - int i; + int arg1, i; if (Cmd_Argc () == 1) { SV_Printf ("Current DoS prot. expire settings: "); @@ -1245,8 +1185,8 @@ SV_netDoSexpire_f (void) } if (Cmd_Argc () != DOSFLOODCMDS + 1) { - SV_Printf - ("Usage: netdosexpire \n"); + SV_Printf ("Usage: netdosexpire " + " \n"); return; } @@ -1258,14 +1198,10 @@ SV_netDoSexpire_f (void) return; } -/* - DoSvalues_f -*/ void SV_netDoSvalues_f (void) { - int arg1; - int i; + int arg1, i; if (Cmd_Argc () == 1) { SV_Printf ("Current DoS prot. value settings: "); @@ -1278,8 +1214,8 @@ SV_netDoSvalues_f (void) } if (Cmd_Argc () != DOSFLOODCMDS + 1) { - SV_Printf - ("Usage: netdosvalues \n"); + SV_Printf ("Usage: netdosvalues " + " \n"); return; } @@ -1291,9 +1227,6 @@ SV_netDoSvalues_f (void) return; } -/* - SV_SendBan -*/ void SV_SendBan (void) { @@ -1310,9 +1243,6 @@ SV_SendBan (void) NET_SendPacket (strlen (data), data, net_from); } -/* - SV_FilterPacket -*/ qboolean SV_FilterPacket (void) { @@ -1328,18 +1258,12 @@ SV_FilterPacket (void) return !filterban->int_val; // FIXME eh? } -//============================================================================ - -/* - SV_ReadPackets -*/ void SV_ReadPackets (void) { - int i; client_t *cl; + int qport, i; qboolean good; - int qport; good = false; while (NET_GetPacket ()) { @@ -1392,28 +1316,27 @@ SV_ReadPackets (void) continue; // packet is not from a known client - // SV_Printf ("%s:sequenced packet without connection\n" - // ,NET_AdrToString(net_from)); +// SV_Printf ("%s:sequenced packet without connection\n", +// NET_AdrToString(net_from)); } } /* - SV_CheckTimeouts + SV_CheckTimeouts - If a packet has not been received from a client in timeout.value - seconds, drop the conneciton. + If a packet has not been received from a client in timeout.value + seconds, drop the conneciton. - When a client is normally dropped, the client_t goes into a zombie - state for a few seconds to make sure any final reliable message gets - resent if necessary + When a client is normally dropped, the client_t goes into a zombie + state for a few seconds to make sure any final reliable message gets + resent if necessary */ void SV_CheckTimeouts (void) { - int i; client_t *cl; float droptime; - int nclients; + int nclients, i; droptime = realtime - timeout->value; nclients = 0; @@ -1442,9 +1365,9 @@ SV_CheckTimeouts (void) } /* - SV_GetConsoleCommands + SV_GetConsoleCommands - Add them exactly as if they had been typed at the console + Add them exactly as if they had been typed at the console */ void SV_GetConsoleCommands (void) @@ -1503,9 +1426,6 @@ SV_GarbageCollect () } } -/* - SV_Frame -*/ void SV_Frame (float time) { @@ -1566,9 +1486,6 @@ SV_Frame (float time) Con_ProcessInput (0, 0); //XXX evil hack to get the cursor in the right place } -/* - SV_InitLocal -*/ void SV_InitLocal (void) { @@ -1586,153 +1503,170 @@ SV_InitLocal (void) SV_UserInit (); - rcon_password = Cvar_Get ("rcon_password", "", CVAR_NONE, NULL, "Set the password for rcon 'root' commands"); - admin_password = Cvar_Get ("admin_password", "", CVAR_NONE, NULL, "Set the password for rcon admin commands"); - password = Cvar_Get ("password", "", CVAR_NONE, NULL, "Set the server password for players"); - spectator_password = Cvar_Get ("spectator_password", "", CVAR_NONE, NULL, "Set the spectator password"); - - sv_mintic = Cvar_Get ("sv_mintic", "0.03", CVAR_NONE, NULL, - "The minimum amount of time the server will wait before sending packets to a client. Set to .5 to make modem users happy"); - sv_maxtic = Cvar_Get ("sv_maxtic", "0.1", CVAR_NONE, NULL, - "The maximum amount of time in seconds before a client a receives an update from the server"); - fraglimit = Cvar_Get ("fraglimit", "0", CVAR_SERVERINFO, Cvar_Info, "Amount of frags a player must attain in order to exit the level"); - timelimit = Cvar_Get ("timelimit", "0", CVAR_SERVERINFO, Cvar_Info, - "Sets the amount of time in minutes that is needed before advancing to the next level"); - teamplay = Cvar_Get ("teamplay", "0", CVAR_SERVERINFO, Cvar_Info, - "Determines teamplay rules. 0 off, 1 You cannot hurt yourself nor your teammates, " - "2 You can hurt yourself, your teammates, and you will lose one frag for killing a teammate" - "3 You can hurt yourself but you cannot hurt your teammates"); - samelevel = Cvar_Get ("samelevel", "0", CVAR_SERVERINFO, Cvar_Info, - "Determines the rules for level changing and exiting. 0 Allows advancing to the next level," - "1 The same level will be played until someone exits," - "2 The same level will be played and the exit will kill anybody that tries to exit," - "3 The same level will be played and the exit will kill anybody that tries to exit, except on the Start map."); - maxclients = Cvar_Get ("maxclients", "8", CVAR_SERVERINFO, Cvar_Info, - "Sets how many clients can connect to your server, this includes spectators and players"); - maxspectators = Cvar_Get ("maxspectators", "8", CVAR_SERVERINFO, Cvar_Info, - "Sets how many spectators can connect to your server. The maxclients value takes precidence over this value so this" - " value should always be equal-to or less-then the maxclients value"); + rcon_password = Cvar_Get ("rcon_password", "", CVAR_NONE, NULL, "Set the " + "password for rcon 'root' commands"); + admin_password = Cvar_Get ("admin_password", "", CVAR_NONE, NULL, "Set " + "the password for rcon admin commands"); + password = Cvar_Get ("password", "", CVAR_NONE, NULL, "Set the server " + "password for players"); + spectator_password = Cvar_Get ("spectator_password", "", CVAR_NONE, NULL, + "Set the spectator password"); + sv_mintic = Cvar_Get ("sv_mintic", "0.03", CVAR_NONE, NULL, "The minimum " + "amount of time the server will wait before sending " + "packets to a client. Set to .5 to make modem users " + "happy"); + sv_maxtic = Cvar_Get ("sv_maxtic", "0.1", CVAR_NONE, NULL, "The maximum " + "amount of time in seconds before a client a " + "receives an update from the server"); + fraglimit = Cvar_Get ("fraglimit", "0", CVAR_SERVERINFO, Cvar_Info, + "Amount of frags a player must attain in order to " + "exit the level"); + timelimit = Cvar_Get ("timelimit", "0", CVAR_SERVERINFO, Cvar_Info, + "Sets the amount of time in minutes that is needed " + "before advancing to the next level"); + teamplay = Cvar_Get ("teamplay", "0", CVAR_SERVERINFO, Cvar_Info, + "Determines teamplay rules. 0 off, 1 You cannot hurt " + "yourself nor your teammates, 2 You can hurt " + "yourself, your teammates, and you will lose one " + "frag for killing a teammate, 3 You can hurt " + "yourself but you cannot hurt your teammates"); + samelevel = Cvar_Get ("samelevel", "0", CVAR_SERVERINFO, Cvar_Info, + "Determines the rules for level changing and " + "exiting. 0 Allows advancing to the next level," + "1 The same level will be played until someone " + "exits, 2 The same level will be played and the " + "exit will kill anybody that tries to exit, 3 The " + "same level will be played and the exit will kill " + "anybody that tries to exit, except on the Start " + "map."); + maxclients = Cvar_Get ("maxclients", "8", CVAR_SERVERINFO, Cvar_Info, + "Sets how many clients can connect to your " + "server, this includes spectators and players"); + maxspectators = Cvar_Get ("maxspectators", "8", CVAR_SERVERINFO, Cvar_Info, + "Sets how many spectators can connect to your " + "server. The maxclients value takes precedence " + "over this value so this value should always be " + "equal-to or less-then the maxclients value"); hostname = Cvar_Get ("hostname", "unnamed", CVAR_SERVERINFO, Cvar_Info, - "Report or sets the server name"); + "Report or sets the server name"); deathmatch = Cvar_Get ("deathmatch", "1", CVAR_SERVERINFO, Cvar_Info, - "Sets the rules for weapon and item respawning. " - "1 Does not leave weapons on the map. You can pickup weapons and items and they will respawn," - "2 Leaves weapons on the map. You can only pick up a weapon once. Picked up items will not respawn," - "3 Leaves weapons on the map. You can only pick up a weapon once. Picked up items will respawn."); + "Sets the rules for weapon and item respawning. " + "1 Does not leave weapons on the map. You can " + "pickup weapons and items and they will respawn, " + "2 Leaves weapons on the map. You can only pick up " + "a weapon once. Picked up items will not respawn, " + "3 Leaves weapons on the map. You can only pick up " + "a weapon once. Picked up items will respawn."); spawn = Cvar_Get ("spawn", "0", CVAR_SERVERINFO, Cvar_Info, - "Spawn the player entity"); + "Spawn the player entity"); watervis = Cvar_Get ("watervis", "0", CVAR_SERVERINFO, Cvar_Info, - "Toggle the use of r_watervis by OpenGL clients"); - - timeout = Cvar_Get ("timeout", "65", CVAR_NONE, NULL, - "Sets the amount of time in seconds before a client is considered disconnected if the server does not receive a packet"); - zombietime = Cvar_Get ("zombietime", "2", CVAR_NONE, NULL, - "The number of seconds that the server will keep the character of a player on the map who seems to have disconnected"); - + "Toggle the use of r_watervis by OpenGL clients"); + timeout = Cvar_Get ("timeout", "65", CVAR_NONE, NULL, "Sets the amount of " + "time in seconds before a client is considered " + "disconnected if the server does not receive a " + "packet"); + zombietime = Cvar_Get ("zombietime", "2", CVAR_NONE, NULL, "The number of " + "seconds that the server will keep the character " + "of a player on the map who seems to have " + "disconnected"); sv_maxvelocity = Cvar_Get ("sv_maxvelocity", "2000", CVAR_NONE, NULL, - "Sets the maximum velocity an object can travel"); + "Sets the maximum velocity an object can " + "travel"); sv_gravity = Cvar_Get ("sv_gravity", "800", CVAR_NONE, NULL, - "Sets the global value for the amount of gravity"); + "Sets the global value for the amount of gravity"); sv_stopspeed = Cvar_Get ("sv_stopspeed", "100", CVAR_NONE, NULL, - "Sets the value that determines how fast the player should come to a complete stop"); + "Sets the value that determines how fast the " + "player should come to a complete stop"); sv_maxspeed = Cvar_Get ("sv_maxspeed", "320", CVAR_NONE, NULL, - "Sets the maximum speed a player can move"); - sv_spectatormaxspeed = - Cvar_Get ("sv_spectatormaxspeed", "500", CVAR_NONE, NULL, - "Sets the maximum speed a spectator can move"); + "Sets the maximum speed a player can move"); + sv_spectatormaxspeed = Cvar_Get ("sv_spectatormaxspeed", "500", CVAR_NONE, + NULL, "Sets the maximum speed a " + "spectator can move"); sv_accelerate = Cvar_Get ("sv_accelerate", "10", CVAR_NONE, NULL, - "Sets the acceleration value for the players"); + "Sets the acceleration value for the players"); sv_airaccelerate = Cvar_Get ("sv_airaccelerate", "0.7", CVAR_NONE, NULL, - "Sets how quickly the players accelerate in air"); - sv_wateraccelerate = - Cvar_Get ("sv_wateraccelerate", "10", CVAR_NONE, NULL, - "Sets the water acceleration value"); + "Sets how quickly the players accelerate in " + "air"); + sv_wateraccelerate = Cvar_Get ("sv_wateraccelerate", "10", CVAR_NONE, NULL, + "Sets the water acceleration value"); sv_friction = Cvar_Get ("sv_friction", "4", CVAR_NONE, NULL, - "Sets the friction value for the players"); + "Sets the friction value for the players"); sv_waterfriction = Cvar_Get ("sv_waterfriction", "4", CVAR_NONE, NULL, - "Sets the water friction value"); - + "Sets the water friction value"); sv_aim = Cvar_Get ("sv_aim", "2", CVAR_NONE, NULL, - "Sets the value for auto-aiming leniency"); - - sv_timekick = - Cvar_Get ("sv_timekick", "3", CVAR_SERVERINFO, Cvar_Info, - "Time cheat protection"); - sv_timekick_fuzz = - Cvar_Get ("sv_timekick_fuzz", "15", CVAR_NONE, NULL, - "Time cheat \"fuzz factor\""); - sv_timekick_interval = - Cvar_Get ("sv_timekick_interval", "30", CVAR_NONE, NULL, - "Time cheat check interval"); - - sv_minqfversion = - Cvar_Get ("sv_minqfversion", "0", CVAR_SERVERINFO, Cvar_Info, - "Minimum QF version on client"); - - sv_maxrate = - Cvar_Get ("sv_maxrate", "0", CVAR_SERVERINFO, Cvar_Info, - "Maximum allowable rate"); - - sv_allow_log = - Cvar_Get ("sv_allow_log", "1", CVAR_NONE, NULL, "Allow remote logging"); - sv_allow_status = - Cvar_Get ("sv_allow_status", "1", CVAR_NONE, NULL, - "Allow remote status queries (qstat etc)"); - sv_allow_ping = - Cvar_Get ("sv_allow_pings", "1", CVAR_NONE, NULL, - "Allow remote pings (qstat etc)"); - sv_netdosprotect = - Cvar_Get ("sv_netdosprotect", "0", CVAR_NONE, NULL, - "DoS flood attack protection"); - - sv_timestamps = - Cvar_Get ("sv_timestamps", "0", CVAR_NONE, NULL, - "Time/date stamps in log entries"); - sv_timefmt = - Cvar_Get ("sv_timefmt", "[%b %e %X] ", CVAR_NONE, NULL, - "Time/date format to use"); - + "Sets the value for auto-aiming leniency"); + sv_timekick = Cvar_Get ("sv_timekick", "3", CVAR_SERVERINFO, Cvar_Info, + "Time cheat protection"); + sv_timekick_fuzz = Cvar_Get ("sv_timekick_fuzz", "15", CVAR_NONE, NULL, + "Time cheat \"fuzz factor\""); + sv_timekick_interval = Cvar_Get ("sv_timekick_interval", "30", CVAR_NONE, + NULL, "Time cheat check interval"); + sv_minqfversion = Cvar_Get ("sv_minqfversion", "0", CVAR_SERVERINFO, + Cvar_Info, "Minimum QF version on client"); + sv_maxrate = Cvar_Get ("sv_maxrate", "0", CVAR_SERVERINFO, Cvar_Info, + "Maximum allowable rate"); + sv_allow_log = Cvar_Get ("sv_allow_log", "1", CVAR_NONE, NULL, + "Allow remote logging"); + sv_allow_status = Cvar_Get ("sv_allow_status", "1", CVAR_NONE, NULL, + "Allow remote status queries (qstat etc)"); + sv_allow_ping = Cvar_Get ("sv_allow_pings", "1", CVAR_NONE, NULL, + "Allow remote pings (qstat etc)"); + sv_netdosprotect = Cvar_Get ("sv_netdosprotect", "0", CVAR_NONE, NULL, + "DoS flood attack protection"); + sv_timestamps = Cvar_Get ("sv_timestamps", "0", CVAR_NONE, NULL, + "Time/date stamps in log entries"); + sv_timefmt = Cvar_Get ("sv_timefmt", "[%b %e %X] ", CVAR_NONE, NULL, + "Time/date format to use"); filterban = Cvar_Get ("filterban", "1", CVAR_NONE, NULL, - "Determines the rules for the IP list " - "0 Only IP addresses on the Ban list will be allowed onto the server, " - "1 Only IP addresses NOT on the Ban list will be allowed onto the server"); - + "Determines the rules for the IP list " + "0 Only IP addresses on the Ban list will be " + "allowed onto the server, 1 Only IP addresses NOT " + "on the Ban list will be allowed onto the server"); allow_download = Cvar_Get ("allow_download", "1", CVAR_NONE, NULL, - "Toggle if clients can download game data from the server"); - allow_download_skins = - Cvar_Get ("allow_download_skins", "1", CVAR_NONE, NULL, - "Toggle if clients can download skins from the server"); - allow_download_models = - Cvar_Get ("allow_download_models", "1", CVAR_NONE, NULL, - "Toggle if clients can download models from the server"); - allow_download_sounds = - Cvar_Get ("allow_download_sounds", "1", CVAR_NONE, NULL, - "Toggle if clients can download sounds from the server"); - allow_download_maps = - Cvar_Get ("allow_download_maps", "1", CVAR_NONE, NULL, - "Toggle if clients can download maps from the server"); - + "Toggle if clients can download game data from " + "the server"); + allow_download_skins = Cvar_Get ("allow_download_skins", "1", CVAR_NONE, + NULL, "Toggle if clients can download " + "skins from the server"); + allow_download_models = Cvar_Get ("allow_download_models", "1", CVAR_NONE, + NULL, "Toggle if clients can download " + "models from the server"); + allow_download_sounds = Cvar_Get ("allow_download_sounds", "1", CVAR_NONE, + NULL, "Toggle if clients can download " + "sounds from the server"); + allow_download_maps = Cvar_Get ("allow_download_maps", "1", CVAR_NONE, + NULL, "Toggle if clients can download " + "maps from the server"); sv_highchars = Cvar_Get ("sv_highchars", "1", CVAR_NONE, NULL, - "Toggle the use of high character color names for players"); - - sv_phs = Cvar_Get ("sv_phs", "1", CVAR_NONE, NULL, - "Possibly Hearable Set. If set to zero, the server calculates sound hearability in realtime"); - - pausable = Cvar_Get ("pausable", "1", CVAR_NONE, NULL, - "Toggle if server can be paused 1 is on, 0 is off"); - - pr_gc = Cvar_Get ("pr_gc", "2", CVAR_NONE, NULL, "Enable/disable the garbage collector. 0 is off, 1 is on, 2 is auto (on for newer qfcc progs, off otherwise)"); - pr_gc_interval = Cvar_Get ("pr_gc_interval", "50", CVAR_NONE, NULL, "Number of frames to wait before running string garbage collector."); - + "Toggle the use of high character color names " + "for players"); + sv_phs = Cvar_Get ("sv_phs", "1", CVAR_NONE, NULL, "Possibly Hearable " + "Set. If set to zero, the server calculates sound " + "hearability in realtime"); + pausable = Cvar_Get ("pausable", "1", CVAR_NONE, NULL, + "Toggle if server can be paused 1 is on, 0 is off"); + pr_gc = Cvar_Get ("pr_gc", "2", CVAR_NONE, NULL, "Enable/disable the " + "garbage collector. 0 is off, 1 is on, 2 is auto (on " + "for newer qfcc progs, off otherwise)"); + pr_gc_interval = Cvar_Get ("pr_gc_interval", "50", CVAR_NONE, NULL, + "Number of frames to wait before running " + "string garbage collector."); // DoS protection - Cmd_AddCommand ("netdosexpire", SV_netDoSexpire_f, "FIXME: part of DoS protection obviously, but I don't know what it does. No Description"); - Cmd_AddCommand ("netdosvalues", SV_netDoSvalues_f, "FIXME: part of DoS protection obviously, but I don't know what it does. No Description"); - - Cmd_AddCommand ("addip", SV_AddIP_f, "Add a single IP or a domain of IPs to the IP list of the server.\n" - "Useful for banning people. (addip (ipnumber))"); - Cmd_AddCommand ("removeip", SV_RemoveIP_f, "Remove an IP address from the server IP list. (removeip (ipnumber))"); - Cmd_AddCommand ("listip", SV_ListIP_f, "Print out the current list of IPs on the server list."); - Cmd_AddCommand ("writeip", SV_WriteIP_f, "Record all IP addresses on the server IP list. The file name is listip.cfg"); + Cmd_AddCommand ("netdosexpire", SV_netDoSexpire_f, "FIXME: part of DoS " + "protection obviously, but I don't know what it does. No " + "Description"); + Cmd_AddCommand ("netdosvalues", SV_netDoSvalues_f, "FIXME: part of DoS " + "protection obviously, but I don't know what it does. No " + "Description"); + Cmd_AddCommand ("addip", SV_AddIP_f, "Add a single IP or a domain of IPs " + "to the IP list of the server.\n" + "Useful for banning people. (addip (ipnumber))"); + Cmd_AddCommand ("removeip", SV_RemoveIP_f, "Remove an IP address from the " + "server IP list. (removeip (ipnumber))"); + Cmd_AddCommand ("listip", SV_ListIP_f, "Print out the current list of IPs " + "on the server list."); + Cmd_AddCommand ("writeip", SV_WriteIP_f, "Record all IP addresses on the " + "server IP list. The file name is listip.cfg"); for (i = 0; i < MAX_MODELS; i++) snprintf (localmodels[i], sizeof (localmodels[i]), "*%i", i); @@ -1761,9 +1695,6 @@ SV_InitLocal (void) svs.log[1].allowoverflow = true; } - -//============================================================================ - /* Master_Heartbeat @@ -1775,17 +1706,14 @@ void Master_Heartbeat (void) { char string[2048]; - int active; - int i; + int active, i; if (realtime - svs.last_heartbeat < HEARTBEAT_SECONDS) return; // not time to send yet svs.last_heartbeat = realtime; - // // count active users - // active = 0; for (i = 0; i < MAX_CLIENTS; i++) if (svs.clients[i].state == cs_connected || @@ -1838,10 +1766,10 @@ SV_ExtractFromUserinfo (client_t *cl) { const char *val; char *q, *p; - int i; - client_t *client; - int dupc = 1; char newname[80]; + client_t *client; + int i; + int dupc = 1; // name for C code @@ -1899,14 +1827,13 @@ SV_ExtractFromUserinfo (client_t *cl) MAX_INFO_STRING, !sv_highchars->int_val); val = Info_ValueForKey (cl->userinfo, "name"); - // If the new name was not set (due to the info string - // being too long), drop the client to prevent an infinite - // loop. + // If the new name was not set (due to the info string being too + // long), drop the client to prevent an infinite loop. if(strcmp(val, newname)) { - Netchan_OutOfBandPrint (net_from, - "%c\nPlease choose a different name.\n", A2C_PRINT); - SV_ClientPrintf (cl, PRINT_HIGH, - "Please choose a different name.\n"); + Netchan_OutOfBandPrint (net_from, "%c\nPlease choose a " + "different name.\n", A2C_PRINT); + SV_ClientPrintf (cl, PRINT_HIGH, "Please choose a different " + "name.\n"); SV_Printf("Client %d kicked for invalid name\n", cl->userid); SV_DropClient (cl); return; @@ -1922,18 +1849,18 @@ SV_ExtractFromUserinfo (client_t *cl) cl->lastnamecount = 0; cl->lastnametime = realtime; } else if (cl->lastnamecount++ > 4) { - SV_BroadcastPrintf (PRINT_HIGH, "%s was kicked for name spam\n", - cl->name); - SV_ClientPrintf (cl, PRINT_HIGH, - "You were kicked from the game for name spamming\n"); + SV_BroadcastPrintf (PRINT_HIGH, "%s was kicked for name " + "spam\n", cl->name); + SV_ClientPrintf (cl, PRINT_HIGH, "You were kicked from the " + "game for name spamming\n"); SV_DropClient (cl); return; } } if (cl->state >= cs_spawned && !cl->spectator) - SV_BroadcastPrintf (PRINT_HIGH, "%s changed name to %s\n", cl->name, - val); + SV_BroadcastPrintf (PRINT_HIGH, "%s changed name to %s\n", + cl->name, val); } @@ -1960,17 +1887,10 @@ SV_ExtractFromUserinfo (client_t *cl) cl->stdver = atoi (Info_ValueForKey (cl->userinfo, "stdver")); } - -//============================================================================ - -/* - SV_InitNet -*/ void SV_InitNet (void) { - int port; - int p; + int port, p; port = PORT_SERVER; p = COM_CheckParm ("-port"); @@ -1989,16 +1909,12 @@ SV_InitNet (void) // NET_StringToAdr ("192.246.40.70:27000", &idmaster_adr); } - -/* - SV_Init -*/ void SV_Init (void) { COM_InitArgv (host_parms.argc, (const char**)host_parms.argv); - // COM_AddParm ("-game"); - // COM_AddParm ("qw"); +// COM_AddParm ("-game"); +// COM_AddParm ("qw"); if (COM_CheckParm ("-minmemory")) host_parms.memsize = MINIMUM_MEMORY; @@ -2081,7 +1997,7 @@ SV_Init (void) host_initialized = true; -// SV_Printf ("Exe: "__TIME__" "__DATE__"\n"); +// SV_Printf ("Exe: "__TIME__" "__DATE__"\n"); SV_Printf ("%4.1f megabyte heap\n", host_parms.memsize / (1024 * 1024.0)); SV_Printf ("\n"); diff --git a/qw/source/sv_model.c b/qw/source/sv_model.c index c9f40defa..1fd1dcbd1 100644 --- a/qw/source/sv_model.c +++ b/qw/source/sv_model.c @@ -37,7 +37,8 @@ const int mod_lightmap_bytes = 1; cvar_t *gl_sky_divide; // not used but needed for linking -void Mod_LoadBrushModel (model_t *mod, void *buffer); +void Mod_LoadBrushModel (model_t *mod, void *buffer); + void Mod_LoadLighting (lump_t *l) diff --git a/qw/source/sv_move.c b/qw/source/sv_move.c index 59bf3799b..0633ea951 100644 --- a/qw/source/sv_move.c +++ b/qw/source/sv_move.c @@ -30,40 +30,42 @@ # include "config.h" #endif -#include #include +#include #include "QF/qtypes.h" + #include "pmove.h" #include "server.h" -#include "sv_pr_cmds.h" #include "sv_progs.h" +#include "sv_pr_cmds.h" #include "world.h" #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) { - vec3_t mins, maxs, start, stop; - trace_t trace; - int x, y; float mid, bottom; + int x, y; + trace_t trace; + vec3_t mins, maxs, start, stop; 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++) { @@ -78,12 +80,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; @@ -93,7 +94,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]; @@ -111,7 +112,6 @@ SV_CheckBottom (edict_t *ent) return true; } - /* SV_movestep @@ -123,17 +123,17 @@ SV_CheckBottom (edict_t *ent) qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink) { - float dz; - vec3_t oldorg, neworg, end; - trace_t trace; - int i; edict_t *enemy; + float dz; + int i; + trace_t trace; + vec3_t oldorg, neworg, end; -// 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++) { @@ -150,8 +150,8 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink) 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) @@ -170,19 +170,21 @@ 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; } @@ -193,20 +195,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; -// SV_Printf ("fall down\n"); +// SV_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; @@ -216,20 +217,17 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink) } if ((int) SVfloat (ent, flags) & FL_PARTIALGROUND) { -// SV_Printf ("back on ground\n"); +// SV_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 @@ -265,29 +263,21 @@ SV_StepDirection (edict_t *ent, float yaw, float dist) return false; } -/* - SV_FixCheckBottom -*/ void SV_FixCheckBottom (edict_t *ent) { -// SV_Printf ("SV_FixCheckBottom\n"); +// SV_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); @@ -307,7 +297,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; @@ -317,7 +307,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]; @@ -330,13 +320,12 @@ 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; @@ -351,17 +340,12 @@ 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) { @@ -376,9 +360,6 @@ SV_CloseEnough (edict_t *ent, edict_t *goal, float dist) return true; } -/* - SV_MoveToGoal -*/ void SV_MoveToGoal (progs_t *pr) { @@ -393,13 +374,14 @@ SV_MoveToGoal (progs_t *pr) G_FLOAT (&sv_pr_state, 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 (&sv_pr_state, 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/qw/source/sv_nchan.c b/qw/source/sv_nchan.c index 90fd4de04..47ee3f77d 100644 --- a/qw/source/sv_nchan.c +++ b/qw/source/sv_nchan.c @@ -37,8 +37,10 @@ #endif #include "QF/msg.h" + #include "server.h" + void PushBackbuf (client_t *cl) { @@ -50,12 +52,14 @@ PushBackbuf (client_t *cl) cl->num_backbuf++; } + // check to see if client block will fit, if not, rotate buffers void ClientReliableCheckBlock (client_t *cl, int maxsize) { if (cl->num_backbuf || - cl->netchan.message.cursize > cl->netchan.message.maxsize - maxsize - 1) { + cl->netchan.message.cursize > cl->netchan.message.maxsize - maxsize - + 1) { // we would probably overflow the buffer, save it for next if (!cl->num_backbuf) { PushBackbuf (cl); diff --git a/qw/source/sv_phys.c b/qw/source/sv_phys.c index b8ac9716d..0dff65eee 100644 --- a/qw/source/sv_phys.c +++ b/qw/source/sv_phys.c @@ -31,13 +31,13 @@ #endif #include "QF/cvar.h" + #include "pmove.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. @@ -53,14 +53,12 @@ flying/floating monsters are SOLID_SLIDEBOX and MOVETYPE_FLY solid_edge items only clip against bsp models. - */ -cvar_t *sv_maxvelocity; - cvar_t *sv_gravity; cvar_t *sv_stopspeed; cvar_t *sv_maxspeed; +cvar_t *sv_maxvelocity; cvar_t *sv_spectatormaxspeed; cvar_t *sv_accelerate; cvar_t *sv_airaccelerate; @@ -68,23 +66,20 @@ cvar_t *sv_wateraccelerate; cvar_t *sv_friction; cvar_t *sv_waterfriction; - #define MOVE_EPSILON 0.01 void SV_Physics_Toss (edict_t *ent); -/* - SV_CheckAllEnts -*/ void SV_CheckAllEnts (void) { - int e; edict_t *check; + int e; -// 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)) { + for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, + check)) { if (check->free) continue; if (SVfloat (check, movetype) == MOVETYPE_PUSH @@ -96,27 +91,24 @@ SV_CheckAllEnts (void) } } -/* - SV_CheckVelocity -*/ void SV_CheckVelocity (edict_t *ent) { + float wishspeed; // 1999-10-18 SV_MAXVELOCITY fix by Maddes int i; - float wishspeed; // 1999-10-18 SV_MAXVELOCITY fix by Maddes -// -// bound velocity -// + // bound velocity for (i = 0; i < 3; i++) { if (IS_NAN (SVvector (ent, velocity)[i])) { SV_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])) { SV_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; } } @@ -124,20 +116,20 @@ SV_CheckVelocity (edict_t *ent) // 1999-10-18 SV_MAXVELOCITY fix by Maddes start wishspeed = Length (SVvector (ent, velocity)); if (wishspeed > sv_maxvelocity->value) { - VectorScale (SVvector (ent, velocity), sv_maxvelocity->value / wishspeed, - SVvector (ent, velocity)); + VectorScale (SVvector (ent, velocity), sv_maxvelocity->value / + wishspeed, SVvector (ent, velocity)); } // 1999-10-18 SV_MAXVELOCITY fix by Maddes end } /* - 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) { @@ -197,18 +189,16 @@ SV_Impact (edict_t *e1, edict_t *e2) *sv_globals.other = old_other; } - /* - ClipVelocity + ClipVelocity - Slide off of the impacting object - returns the blocked flags (1 = floor, 2 = step / wall) - */ + 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) { - float backoff; - float change; + float backoff, change; int i, blocked; blocked = 0; @@ -229,32 +219,27 @@ 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; + float time_left, d; + int blocked, bumpcount, numbumps, numplanes, i, j; + trace_t trace; + vec3_t dir, end; 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; @@ -267,10 +252,11 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) for (bumpcount = 0; bumpcount < numbumps; bumpcount++) { 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)); @@ -293,8 +279,10 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) blocked |= 1; // floor if ((SVfloat (trace.ent, solid) == SOLID_BSP) || (SVfloat (trace.ent, movetype) == MOVETYPE_PPUSH)) { - 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]) { @@ -302,14 +290,12 @@ 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 @@ -321,9 +307,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++) @@ -339,7 +323,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) { -// SV_Printf ("clip velocity, numplanes == %i\n",numplanes); +// SV_Printf ("clip velocity, numplanes == %i\n",numplanes); VectorCopy (vec3_origin, SVvector (ent, velocity)); return 7; } @@ -348,10 +332,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; @@ -361,19 +343,13 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) return blocked; } - -/* - SV_AddGravity -*/ void SV_AddGravity (edict_t *ent, float scale) { SVvector (ent, velocity)[2] -= scale * movevars.gravity * sv_frametime; } -/* - PUSHMOVE -*/ +/* PUSHMOVE */ /* SV_PushEntity @@ -389,18 +365,16 @@ SV_PushEntity (edict_t *ent, vec3_t push) 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); @@ -411,23 +385,15 @@ SV_PushEntity (edict_t *ent, vec3_t push) return trace; } - -/* - SV_Push -*/ qboolean SV_Push (edict_t *pusher, vec3_t move) { - int i, e; + float solid_save; // for Lord Havoc's SOLID_BSP fix --KB + int num_moved, i, e; edict_t *check, *block; - vec3_t mins, maxs; - vec3_t pushorig; - int num_moved; edict_t *moved_edict[MAX_EDICTS]; + vec3_t mins, maxs, pushorig; vec3_t moved_from[MAX_EDICTS]; - float solid_save; // for Lord Havoc's SOLID_BSP fix - - // --KB for (i = 0; i < 3; i++) { mins[i] = SVvector (pusher, absmin)[i] + move[i]; @@ -436,15 +402,15 @@ SV_Push (edict_t *pusher, vec3_t move) 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)); 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; e++, check = NEXT_EDICT (&sv_pr_state, check)) { + for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, + check)) { if (check->free) continue; if (SVfloat (check, movetype) == MOVETYPE_PUSH @@ -461,10 +427,10 @@ SV_Push (edict_t *pusher, vec3_t move) if (block) 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)) { + && PROG_TO_EDICT (&sv_pr_state, SVentity (check, groundentity)) + == pusher)) { if (SVvector (check, absmin)[0] >= maxs[0] || SVvector (check, absmin)[1] >= maxs[1] || SVvector (check, absmin)[2] >= maxs[2] @@ -490,7 +456,8 @@ SV_Push (edict_t *pusher, vec3_t move) continue; } // if it is ok to leave in the old position, do it - VectorSubtract (SVvector (check, origin), move, SVvector (check, origin)); + VectorSubtract (SVvector (check, origin), move, SVvector (check, + origin)); block = SV_TestEntityPosition (check); if (!block) { num_moved--; @@ -501,7 +468,8 @@ SV_Push (edict_t *pusher, vec3_t move) SV_LinkEdict (check, false); 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)); SV_LinkEdict (check, false); @@ -529,9 +497,6 @@ SV_Push (edict_t *pusher, vec3_t move) return true; } -/* - SV_PushMove -*/ void SV_PushMove (edict_t *pusher, float movetime) { @@ -551,18 +516,11 @@ SV_PushMove (edict_t *pusher, float movetime) SVfloat (pusher, ltime) += movetime; } - -/* - SV_Physics_Pusher -*/ void SV_Physics_Pusher (edict_t *ent) { - float thinktime; - float oldltime; - float movetime; + float movetime, oldltime, thinktime, l; vec3_t oldorg, move; - float l; oldltime = SVfloat (ent, ltime); @@ -592,14 +550,13 @@ SV_Physics_Pusher (edict_t *ent) l = Length (move); if (l > 1.0 / 64) { -// SV_Printf ("**** snap: %f\n", Length (l)); +// SV_Printf ("**** snap: %f\n", Length (l)); VectorCopy (oldorg, SVvector (ent, origin)); SV_Push (ent, move); } } } - /* SV_Physics_None @@ -608,7 +565,7 @@ SV_Physics_Pusher (edict_t *ent) void SV_Physics_None (edict_t *ent) { -// regular thinking + // regular thinking SV_RunThink (ent); SV_LinkEdict (ent, false); } @@ -625,19 +582,16 @@ SV_Physics_Noclip (edict_t *ent) if (!SV_RunThink (ent)) return; - VectorMA (SVvector (ent, angles), sv_frametime, SVvector (ent, avelocity), SVvector (ent, angles)); - VectorMA (SVvector (ent, origin), sv_frametime, SVvector (ent, velocity), SVvector (ent, origin)); + VectorMA (SVvector (ent, angles), sv_frametime, SVvector (ent, avelocity), + SVvector (ent, angles)); + VectorMA (SVvector (ent, origin), sv_frametime, SVvector (ent, velocity), + SVvector (ent, origin)); SV_LinkEdict (ent, false); } -/* - TOSS / BOUNCE -*/ +/* TOSS / BOUNCE */ -/* - SV_CheckWaterTransition -*/ void SV_CheckWaterTransition (edict_t *ent) { @@ -651,15 +605,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; @@ -675,31 +629,32 @@ SV_CheckWaterTransition (edict_t *ent) void SV_Physics_Toss (edict_t *ent) { + float backoff; trace_t trace; vec3_t move; - float backoff; -// regular thinking + // regular thinking if (!SV_RunThink (ent)) return; if (SVvector (ent, velocity)[2] > 0) SVfloat (ent, flags) = (int) SVfloat (ent, flags) & ~FL_ONGROUND; -// if onground, return without moving + // if onground, return without moving if (((int) SVfloat (ent, flags) & FL_ONGROUND)) return; SV_CheckVelocity (ent); -// add gravity - if (SVfloat (ent, movetype) != MOVETYPE_FLY - && SVfloat (ent, movetype) != MOVETYPE_FLYMISSILE) SV_AddGravity (ent, 1.0); + // add gravity + if (SVfloat (ent, movetype) != MOVETYPE_FLY && SVfloat (ent, movetype) != + MOVETYPE_FLYMISSILE) SV_AddGravity (ent, 1.0); -// move angles - VectorMA (SVvector (ent, angles), sv_frametime, SVvector (ent, avelocity), SVvector (ent, angles)); + // move angles + VectorMA (SVvector (ent, angles), sv_frametime, SVvector (ent, avelocity), + SVvector (ent, angles)); -// move origin + // move origin VectorScale (SVvector (ent, velocity), sv_frametime, move); trace = SV_PushEntity (ent, move); if (trace.fraction == 1) @@ -712,25 +667,25 @@ 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) { - if (SVvector (ent, velocity)[2] < 60 || SVfloat (ent, movetype) != MOVETYPE_BOUNCE) { + if (SVvector (ent, velocity)[2] < 60 || SVfloat (ent, movetype) != + MOVETYPE_BOUNCE) { 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 @@ -747,7 +702,7 @@ SV_Physics_Step (edict_t *ent) { qboolean hitsound; -// freefall if not on ground + // freefall if not on ground if (!((int) SVfloat (ent, flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) { if (SVvector (ent, velocity)[2] < movevars.gravity * -0.1) hitsound = true; @@ -765,7 +720,7 @@ 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); @@ -774,11 +729,10 @@ SV_Physics_Step (edict_t *ent) void SV_PPushMove (edict_t *pusher, float movetime) // player push { - int i, e; + int oldsolid, e, i; edict_t *check; - vec3_t mins, maxs, move; - int oldsolid; trace_t trace; + vec3_t maxs, mins, move; SV_CheckVelocity (pusher); for (i = 0; i < 3; i++) { @@ -793,19 +747,22 @@ SV_PPushMove (edict_t *pusher, float movetime) // player push MOVE_NOMONSTERS, pusher); if (trace.fraction == 1) { - VectorCopy (SVvector (pusher, origin), SVvector (pusher, oldorigin)); // Revert + VectorCopy (SVvector (pusher, origin), SVvector (pusher, oldorigin)); + // Revert return; } - VectorAdd (SVvector (pusher, origin), move, SVvector (pusher, origin)); // Move + VectorAdd (SVvector (pusher, origin), move, SVvector (pusher, origin)); + // Move SV_LinkEdict (pusher, false); SVfloat (pusher, ltime) += movetime; oldsolid = SVfloat (pusher, solid); check = NEXT_EDICT (&sv_pr_state, sv.edicts); - for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) { + for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, + check)) { if (check->free) // What entity? continue; @@ -824,11 +781,13 @@ SV_PPushMove (edict_t *pusher, float movetime) // player push // Stage 3: No.. Is it something that blocks us? if (SVvector (check, mins)[0] == SVvector (check, maxs)[0]) continue; - if (SVfloat (check, solid) == SOLID_NOT || SVfloat (check, solid) == SOLID_TRIGGER) + if (SVfloat (check, solid) == SOLID_NOT || SVfloat (check, solid) == + SOLID_TRIGGER) continue; // Stage 4: Yes, it must be. Fail the move. - VectorCopy (SVvector (pusher, origin), SVvector (pusher, oldorigin)); // Revert + VectorCopy (SVvector (pusher, origin), SVvector (pusher, oldorigin)); + // Revert if (SVfunc (pusher, blocked)) { // Blocked func? *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, pusher); *sv_globals.other = EDICT_TO_PROG (&sv_pr_state, check); @@ -842,11 +801,8 @@ SV_PPushMove (edict_t *pusher, float movetime) // player push void SV_Physics_PPusher (edict_t *ent) { - float thinktime; - float oldltime; - float movetime; - -// float l; + float movetime, oldltime, thinktime; +// float l; oldltime = SVfloat (ent, ltime); @@ -858,11 +814,10 @@ SV_Physics_PPusher (edict_t *ent) } else movetime = sv_frametime; -// if (movetime) -// { - SV_PPushMove (ent, 0.0009); // advances SVfloat (ent, ltime) if not - // blocked -// } +// if (movetime) +// { + SV_PPushMove (ent, 0.0009); // advances SVfloat (ent, ltime) if not blocked +// } if (thinktime > oldltime && thinktime <= SVfloat (ent, ltime)) { SVfloat (ent, nextthink) = 0; @@ -875,21 +830,16 @@ SV_Physics_PPusher (edict_t *ent) } } -//============================================================================ - void SV_ProgStartFrame (void) { -// 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 = EDICT_TO_PROG (&sv_pr_state, sv.edicts); *sv_globals.time = sv.time; PR_ExecuteProgram (&sv_pr_state, sv_funcs.StartFrame); } -/* - SV_RunEntity -*/ void SV_RunEntity (edict_t *ent) { @@ -898,35 +848,33 @@ SV_RunEntity (edict_t *ent) SVfloat (ent, lastruntime) = (float) realtime; switch ((int) SVfloat (ent, movetype)) { - case MOVETYPE_PUSH: - SV_Physics_Pusher (ent); - break; - case MOVETYPE_PPUSH: - SV_Physics_PPusher (ent); - break; - case MOVETYPE_NONE: - SV_Physics_None (ent); - break; - case MOVETYPE_NOCLIP: - SV_Physics_Noclip (ent); - break; - case MOVETYPE_STEP: - SV_Physics_Step (ent); - break; - case MOVETYPE_TOSS: - case MOVETYPE_BOUNCE: - case MOVETYPE_FLY: - case MOVETYPE_FLYMISSILE: - SV_Physics_Toss (ent); - break; - default: - SV_Error ("SV_Physics: bad movetype %i", (int) SVfloat (ent, movetype)); + case MOVETYPE_PUSH: + SV_Physics_Pusher (ent); + break; + case MOVETYPE_PPUSH: + SV_Physics_PPusher (ent); + break; + case MOVETYPE_NONE: + SV_Physics_None (ent); + break; + case MOVETYPE_NOCLIP: + SV_Physics_Noclip (ent); + break; + case MOVETYPE_STEP: + SV_Physics_Step (ent); + break; + case MOVETYPE_TOSS: + case MOVETYPE_BOUNCE: + case MOVETYPE_FLY: + case MOVETYPE_FLYMISSILE: + SV_Physics_Toss (ent); + break; + default: + SV_Error ("SV_Physics: bad movetype %i", (int) SVfloat (ent, + movetype)); } } -/* - SV_RunNewmis -*/ void SV_RunNewmis (void) { @@ -941,17 +889,14 @@ SV_RunNewmis (void) SV_RunEntity (ent); } -/* - SV_Physics -*/ void SV_Physics (void) { - int i; - edict_t *ent; static double old_time; + edict_t *ent; + int i; -// don't bother running a frame if sys_ticrate seconds haven't passed + // don't bother running a frame if sys_ticrate seconds haven't passed sv_frametime = realtime - old_time; if (sv_frametime < sv_mintic->value) return; @@ -963,10 +908,8 @@ SV_Physics (void) SV_ProgStartFrame (); -// -// treat each object in turn -// even the world gets a chance to think -// + // treat each object in turn + // even the world gets a chance to think ent = sv.edicts; for (i = 0; i < sv.num_edicts; i++, ent = NEXT_EDICT (&sv_pr_state, ent)) { if (ent->free) @@ -976,8 +919,7 @@ SV_Physics (void) SV_LinkEdict (ent, true); // force retouch even for stationary if (i > 0 && i <= MAX_CLIENTS) - continue; // clients are run directly from - // packets + continue; // clients are run directly from packets SV_RunEntity (ent); SV_RunNewmis (); diff --git a/qw/source/sv_pr_cmds.c b/qw/source/sv_pr_cmds.c index 24a621501..019861b67 100644 --- a/qw/source/sv_pr_cmds.c +++ b/qw/source/sv_pr_cmds.c @@ -32,6 +32,9 @@ #ifdef HAVE_STRING_H # include #endif +#ifdef HAVE_STRINGS_H +# include +#endif #include "QF/clip_hull.h" #include "QF/cmd.h" @@ -49,9 +52,7 @@ #define RETURN_EDICT(p, e) ((p)->pr_globals[OFS_RETURN].integer_var = EDICT_TO_PROG(p, e)) #define RETURN_STRING(p, s) ((p)->pr_globals[OFS_RETURN].integer_var = PR_SetString((p), s)) -/* - BUILT-IN FUNCTIONS -*/ +/* BUILT-IN FUNCTIONS */ /* @@ -101,8 +102,6 @@ PF_objerror (progs_t *pr) SV_Error ("Program error"); } - - /* PF_makevectors @@ -135,7 +134,6 @@ PF_setorigin (progs_t *pr) SV_LinkEdict (e, false); } - /* PF_setsize @@ -158,7 +156,6 @@ PF_setsize (progs_t *pr) SV_LinkEdict (e, false); } - /* PF_setmodel @@ -170,13 +167,13 @@ PF_setmodel (progs_t *pr) { edict_t *e; const char *m, **check; - model_t *mod; int i; + model_t *mod; e = G_EDICT (pr, OFS_PARM0); m = G_STRING (pr, OFS_PARM1); -// check to see if model was properly precached + // check to see if model was properly precached for (i = 0, check = sv.model_precache; *check; i++, check++) if (!strcmp (*check, m)) break; @@ -187,7 +184,7 @@ PF_setmodel (progs_t *pr) SVstring (e, model) = PR_SetString (pr, m); SVfloat (e, modelindex) = i; -// if it is an inline model, get the size information for it + // if it is an inline model, get the size information for it if (m[0] == '*') { mod = Mod_ForName (m, true); VectorCopy (mod->mins, SVvector (e, mins)); @@ -195,7 +192,6 @@ PF_setmodel (progs_t *pr) VectorSubtract (mod->maxs, mod->mins, SVvector (e, size)); SV_LinkEdict (e, false); } - } /* @@ -229,8 +225,7 @@ PF_sprint (progs_t *pr) { const char *s; client_t *client; - int entnum; - int level; + int entnum, level; entnum = G_EDICTNUM (pr, OFS_PARM0); level = G_FLOAT (pr, OFS_PARM1); @@ -247,7 +242,6 @@ PF_sprint (progs_t *pr) SV_ClientPrintf (client, level, "%s", s); } - /* PF_centerprint @@ -259,8 +253,8 @@ void PF_centerprint (progs_t *pr) { const char *s; - int entnum; client_t *cl; + int entnum; entnum = G_EDICTNUM (pr, OFS_PARM0); s = PF_VarString (pr, 1); @@ -276,7 +270,6 @@ PF_centerprint (progs_t *pr) ClientReliableWrite_String (cl, s); } - /* PF_ambientsound */ @@ -294,7 +287,7 @@ PF_ambientsound (progs_t *pr) vol = G_FLOAT (pr, OFS_PARM2); attenuation = G_FLOAT (pr, OFS_PARM3); -// check to see if samp was properly precached + // check to see if samp was properly precached for (soundnum = 0, check = sv.sound_precache; *check; check++, soundnum++) if (!strcmp (*check, samp)) break; @@ -303,8 +296,8 @@ PF_ambientsound (progs_t *pr) SV_Printf ("no precache: %s\n", samp); return; } -// add an svc_spawnambient command to the level signon packet + // add an svc_spawnambient command to the level signon packet MSG_WriteByte (&sv.signon, svc_spawnstaticsound); for (i = 0; i < 3; i++) MSG_WriteCoord (&sv.signon, pos[i]); @@ -332,10 +325,9 @@ void PF_sound (progs_t *pr) { const char *sample; - int channel; edict_t *entity; - int volume; float attenuation; + int channel, volume; entity = G_EDICT (pr, OFS_PARM0); channel = G_FLOAT (pr, OFS_PARM1); @@ -346,7 +338,6 @@ PF_sound (progs_t *pr) SV_StartSound (entity, channel, sample, volume, attenuation); } - /* PF_traceline @@ -360,9 +351,9 @@ void PF_traceline (progs_t *pr) { float *v1, *v2; - trace_t trace; - int nomonsters; edict_t *ent; + int nomonsters; + trace_t trace; v1 = G_VECTOR (pr, OFS_PARM0); v2 = G_VECTOR (pr, OFS_PARM1); @@ -386,20 +377,18 @@ PF_traceline (progs_t *pr) } /* - PF_checkmove + PF_checkmove - Wrapper around SV_Move, this makes PF_movetoground and PF_traceline - redundant. - - checkmove (start, mins, maxs, end, type, passent) + Wrapper around SV_Move, this makes PF_movetoground and PF_traceline + redundant. */ void PF_checkmove (progs_t *pr) { - float *start, *end, *mins, *maxs; - trace_t trace; - int type; edict_t *ent; + float *start, *end, *mins, *maxs; + int type; + trace_t trace; start = G_VECTOR (pr, OFS_PARM0); mins = G_VECTOR (pr, OFS_PARM1); @@ -425,33 +414,30 @@ PF_checkmove (progs_t *pr) } /* - PF_checkpos + PF_checkpos - Returns true if the given entity can move to the given position from it's - current position by walking or rolling. - FIXME: make work... - scalar checkpos (entity, vector) + Returns true if the given entity can move to the given position from it's + current position by walking or rolling. + FIXME: make work... + scalar checkpos (entity, vector) */ void PF_checkpos (progs_t *pr) { } -//============================================================================ - byte checkpvs[MAX_MAP_LEAFS / 8]; int PF_newcheckclient (progs_t *pr, int check) { - int i; byte *pvs; edict_t *ent; + int i; mleaf_t *leaf; vec3_t org; -// cycle to the next one - + // cycle to the next one if (check < 1) check = 1; if (check > MAX_CLIENTS) @@ -482,7 +468,7 @@ PF_newcheckclient (progs_t *pr, int check) break; } -// get the PVS for the entity + // get the PVS for the entity VectorAdd (SVvector (ent, origin), SVvector (ent, view_ofs), org); leaf = Mod_PointInLeaf (org, sv.worldmodel); pvs = Mod_LeafPVS (leaf, sv.worldmodel); @@ -491,41 +477,40 @@ PF_newcheckclient (progs_t *pr, int check) return i; } -/* - PF_checkclient - - Returns a client (or object that has a client enemy) that would be a - valid target. - - If there are more than one valid options, they are cycled each frame - - If (self.origin + self.viewofs) is not in the PVS of the current target, - it is not returned at all. - - name checkclient () -*/ #define MAX_CHECK 16 int c_invis, c_notvis; + +/* + PF_checkclient + + Returns a client (or object that has a client enemy) that would be a valid + target. + + If there are more than one valid options, they are cycled each frame + + If (self.origin + self.viewofs) is not in the PVS of the current target, it + is not returned at all. +*/ void PF_checkclient (progs_t *pr) { edict_t *ent, *self; - mleaf_t *leaf; int l; + mleaf_t *leaf; vec3_t view; -// find a new check if on a new frame + // find a new check if on a new frame if (sv.time - sv.lastchecktime >= 0.1) { sv.lastcheck = PF_newcheckclient (pr, sv.lastcheck); sv.lastchecktime = sv.time; } -// return check if it might be visible + // return check if it might be visible ent = EDICT_NUM (pr, sv.lastcheck); if (ent->free || SVfloat (ent, health) <= 0) { RETURN_EDICT (pr, sv.edicts); return; } -// if current entity can't possibly see the check entity, return 0 + // if current entity can't possibly see the check entity, return 0 self = PROG_TO_EDICT (pr, *sv_globals.self); VectorAdd (SVvector (self, origin), SVvector (self, view_ofs), view); leaf = Mod_PointInLeaf (view, sv.worldmodel); @@ -535,14 +520,11 @@ PF_checkclient (progs_t *pr) RETURN_EDICT (pr, sv.edicts); return; } -// might be able to see it + // might be able to see it c_invis++; RETURN_EDICT (pr, ent); } -//============================================================================ - - /* PF_stuffcmd @@ -553,11 +535,10 @@ PF_checkclient (progs_t *pr) void PF_stuffcmd (progs_t *pr) { - int entnum; const char *str; + char *buf, *p; client_t *cl; - char *buf; - char *p; + int entnum; entnum = G_EDICTNUM (pr, OFS_PARM0); if (entnum < 1 || entnum > MAX_CLIENTS) @@ -619,8 +600,8 @@ PF_findradius (progs_t *pr) edict_t *ent, *chain; float rad; float *org, *eorigin, *emins, *emaxs; - vec3_t eorg; int i, j; + vec3_t eorg; chain = (edict_t *) sv.edicts; @@ -650,7 +631,6 @@ PF_findradius (progs_t *pr) RETURN_EDICT (pr, chain); } - void PF_Spawn (progs_t *pr) { @@ -669,7 +649,6 @@ PF_Remove (progs_t *pr) ED_Free (pr, ed); } - void PR_CheckEmptyString (progs_t *pr, const char *s) { @@ -691,8 +670,8 @@ PF_precache_sound (progs_t *pr) int i; if (sv.state != ss_loading) - PR_RunError - (pr, "PF_Precache_*: Precache can only be done in spawn functions"); + PR_RunError (pr, "PF_Precache_*: Precache can only be done in spawn " + "functions"); s = G_STRING (pr, OFS_PARM0); G_INT (pr, OFS_RETURN) = G_INT (pr, OFS_PARM0); @@ -712,12 +691,13 @@ PF_precache_sound (progs_t *pr) void PF_precache_model (progs_t *pr) { - const char *s; + const char *s; int i; if (sv.state != ss_loading) PR_RunError - (pr, "PF_Precache_*: Precache can only be done in spawn functions"); + (pr, "PF_Precache_*: Precache can only be done in spawn " + "functions"); s = G_STRING (pr, OFS_PARM0); G_INT (pr, OFS_RETURN) = G_INT (pr, OFS_PARM0); @@ -734,7 +714,6 @@ PF_precache_model (progs_t *pr) PR_RunError (pr, "PF_precache_model: overflow"); } - /* PF_walkmove @@ -743,11 +722,11 @@ PF_precache_model (progs_t *pr) void PF_walkmove (progs_t *pr) { + dfunction_t *oldf; edict_t *ent; float yaw, dist; - vec3_t move; - dfunction_t *oldf; int oldself; + vec3_t move; ent = PROG_TO_EDICT (pr, *sv_globals.self); yaw = G_FLOAT (pr, OFS_PARM0); @@ -764,14 +743,13 @@ PF_walkmove (progs_t *pr) move[1] = sin (yaw) * dist; move[2] = 0; -// save program state, because SV_movestep may call other progs + // save program state, because SV_movestep may call other progs oldf = pr->pr_xfunction; oldself = *sv_globals.self; G_FLOAT (pr, OFS_RETURN) = SV_movestep (ent, move, true); - -// restore program state + // restore program state pr->pr_xfunction = oldf; *sv_globals.self = oldself; } @@ -785,15 +763,16 @@ void PF_droptofloor (progs_t *pr) { edict_t *ent; - vec3_t end; trace_t trace; + vec3_t end; ent = PROG_TO_EDICT (pr, *sv_globals.self); VectorCopy (SVvector (ent, origin), end); end[2] -= 256; - 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.fraction == 1 || trace.allsolid) G_FLOAT (pr, OFS_RETURN) = 0; @@ -814,18 +793,17 @@ PF_droptofloor (progs_t *pr) void PF_lightstyle (progs_t *pr) { - int style; const char *val; client_t *client; - int j; + int style, j; style = G_FLOAT (pr, OFS_PARM0); val = G_STRING (pr, OFS_PARM1); -// change the string in sv + // change the string in sv sv.lightstyles[style] = val; -// send message to all clients on this server + // send message to all clients on this server if (sv.state != ss_active) return; @@ -851,9 +829,6 @@ PF_checkbottom (progs_t *pr) G_FLOAT (pr, OFS_RETURN) = SV_CheckBottom (ent); } -/* - PF_pointcontents -*/ void PF_pointcontents (progs_t *pr) { @@ -864,13 +839,14 @@ PF_pointcontents (progs_t *pr) G_FLOAT (pr, OFS_RETURN) = SV_PointContents (v); } +cvar_t *sv_aim; + /* PF_aim Pick a vector for the player to shoot along vector aim(entity, missilespeed) */ -cvar_t *sv_aim; void PF_aim (progs_t *pr) { @@ -888,7 +864,7 @@ PF_aim (progs_t *pr) VectorCopy (SVvector (ent, origin), start); start[2] += 20; -// noaim option + // noaim option i = NUM_FOR_EDICT (pr, ent); if (i > 0 && i < MAX_CLIENTS) { noaim = Info_ValueForKey (svs.clients[i - 1].userinfo, "noaim"); @@ -897,7 +873,7 @@ PF_aim (progs_t *pr) return; } } -// try sending a trace straight + // try sending a trace straight VectorCopy (*sv_globals.v_forward, dir); VectorMA (start, 2048, dir, end); tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent); @@ -908,7 +884,7 @@ PF_aim (progs_t *pr) return; } -// try all possible entities + // try all possible entities VectorCopy (dir, bestdir); bestdist = sv_aim->value; bestent = NULL; @@ -920,11 +896,11 @@ PF_aim (progs_t *pr) if (check == ent) continue; if (teamplay->int_val && SVfloat (ent, team) > 0 - && SVfloat (ent, team) == SVfloat (check, team)) continue; // don't aim at - // teammate + && SVfloat (ent, team) == SVfloat (check, team)) continue; + // don't aim at teammate for (j = 0; j < 3; j++) - end[j] = SVvector (check, origin)[j] - + 0.5 * (SVvector (check, mins)[j] + SVvector (check, maxs)[j]); + end[j] = SVvector (check, origin)[j] + 0.5 * + (SVvector (check, mins)[j] + SVvector (check, maxs)[j]); VectorSubtract (end, start, dir); VectorNormalize (dir); dist = DotProduct (dir, *sv_globals.v_forward); @@ -938,7 +914,8 @@ PF_aim (progs_t *pr) } if (bestent) { - VectorSubtract (SVvector (bestent, origin), SVvector (ent, origin), dir); + VectorSubtract (SVvector (bestent, origin), SVvector (ent, origin), + dir); dist = DotProduct (dir, *sv_globals.v_forward); VectorScale (*sv_globals.v_forward, dist, end); end[2] = dir[2]; @@ -986,9 +963,7 @@ PF_changeyaw (progs_t *pr) SVvector (ent, angles)[1] = anglemod (current + move); } -/* - MESSAGE WRITING -*/ +/* MESSAGE WRITING */ #define MSG_BROADCAST 0 // unreliable to all #define MSG_ONE 1 // reliable to one (msg_entity) @@ -1003,34 +978,34 @@ WriteDest (progs_t *pr) dest = G_FLOAT (pr, OFS_PARM0); switch (dest) { - case MSG_BROADCAST: - return &sv.datagram; + case MSG_BROADCAST: + return &sv.datagram; - case MSG_ONE: - SV_Error ("Shouldn't be at MSG_ONE"); + case MSG_ONE: + SV_Error ("Shouldn't be at MSG_ONE"); #if 0 - ent = PROG_TO_EDICT (pr, *sv_globals.msg_entity); - entnum = NUM_FOR_EDICT (pr, ent); - if (entnum < 1 || entnum > MAX_CLIENTS) - PR_RunError (pr, "WriteDest: not a client"); - return &svs.clients[entnum - 1].netchan.message; + ent = PROG_TO_EDICT (pr, *sv_globals.msg_entity); + entnum = NUM_FOR_EDICT (pr, ent); + if (entnum < 1 || entnum > MAX_CLIENTS) + PR_RunError (pr, "WriteDest: not a client"); + return &svs.clients[entnum - 1].netchan.message; #endif - case MSG_ALL: - return &sv.reliable_datagram; + case MSG_ALL: + return &sv.reliable_datagram; - case MSG_INIT: - if (sv.state != ss_loading) - PR_RunError - (pr, "PF_Write_*: MSG_INIT can only be written in spawn functions"); - return &sv.signon; + case MSG_INIT: + if (sv.state != ss_loading) + PR_RunError (pr, "PF_Write_*: MSG_INIT can only be written in " + "spawn functions"); + return &sv.signon; - case MSG_MULTICAST: - return &sv.multicast; + case MSG_MULTICAST: + return &sv.multicast; - default: - PR_RunError (pr, "WriteDest: bad destination"); - break; + default: + PR_RunError (pr, "WriteDest: bad destination"); + break; } return NULL; @@ -1039,8 +1014,8 @@ WriteDest (progs_t *pr) static client_t * Write_GetClient (progs_t *pr) { - int entnum; edict_t *ent; + int entnum; ent = PROG_TO_EDICT (pr, *sv_globals.msg_entity); entnum = NUM_FOR_EDICT (pr, ent); @@ -1049,7 +1024,6 @@ Write_GetClient (progs_t *pr) return &svs.clients[entnum - 1]; } - void PF_WriteByte (progs_t *pr) { @@ -1134,7 +1108,6 @@ PF_WriteString (progs_t *pr) MSG_WriteString (WriteDest (pr), G_STRING (pr, OFS_PARM1)); } - void PF_WriteEntity (progs_t *pr) { @@ -1147,23 +1120,21 @@ PF_WriteEntity (progs_t *pr) MSG_WriteShort (WriteDest (pr), G_EDICTNUM (pr, OFS_PARM1)); } -//============================================================================= - int SV_ModelIndex (const char *name); void PF_makestatic (progs_t *pr) { + const char *model; edict_t *ent; int i; - const char *model; ent = G_EDICT (pr, OFS_PARM0); MSG_WriteByte (&sv.signon, svc_spawnstatic); model = PR_GetString (pr, SVstring (ent, model)); -//SV_Printf ("Model: %d %s\n", SVstring (ent, model), model); +// SV_Printf ("Model: %d %s\n", SVstring (ent, model), model); MSG_WriteByte (&sv.signon, SV_ModelIndex (model)); MSG_WriteByte (&sv.signon, SVfloat (ent, frame)); @@ -1174,21 +1145,16 @@ PF_makestatic (progs_t *pr) MSG_WriteAngle (&sv.signon, SVvector (ent, angles)[i]); } -// throw the entity away now + // throw the entity away now ED_Free (pr, ent); } -//============================================================================= - -/* - PF_setspawnparms -*/ void PF_setspawnparms (progs_t *pr) { + client_t *client; edict_t *ent; int i; - client_t *client; ent = G_EDICT (pr, OFS_PARM0); i = NUM_FOR_EDICT (pr, ent); @@ -1202,16 +1168,13 @@ PF_setspawnparms (progs_t *pr) sv_globals.parms[i] = client->spawn_parms[i]; } -/* - PF_changelevel -*/ void PF_changelevel (progs_t *pr) { const char *s; static int last_spawncount; -// make sure we don't issue two changelevels + // make sure we don't issue two changelevels if (svs.spawncount == last_spawncount) return; last_spawncount = svs.spawncount; @@ -1220,7 +1183,6 @@ PF_changelevel (progs_t *pr) Cbuf_AddText (va ("map %s\n", s)); } - /* PF_logfrag @@ -1229,9 +1191,9 @@ PF_changelevel (progs_t *pr) void PF_logfrag (progs_t *pr) { + const char *s; edict_t *ent1, *ent2; int e1, e2; - const char *s; ent1 = G_EDICT (pr, OFS_PARM0); ent2 = G_EDICT (pr, OFS_PARM1); @@ -1242,7 +1204,8 @@ PF_logfrag (progs_t *pr) if (e1 < 1 || e1 > MAX_CLIENTS || e2 < 1 || e2 > MAX_CLIENTS) return; - s = va ("\\%s\\%s\\\n", svs.clients[e1 - 1].name, svs.clients[e2 - 1].name); + s = va ("\\%s\\%s\\\n", svs.clients[e1 - 1].name, + svs.clients[e2 - 1].name); SZ_Print (&svs.log[svs.logsequence & 1], s); if (sv_fraglogfile) { @@ -1251,7 +1214,6 @@ PF_logfrag (progs_t *pr) } } - /* PF_infokey @@ -1260,11 +1222,10 @@ PF_logfrag (progs_t *pr) void PF_infokey (progs_t *pr) { + const char *key, *value; + static char ov[256]; edict_t *e; int e1; - const char *value; - const char *key; - static char ov[256]; e = G_EDICT (pr, OFS_PARM0); e1 = NUM_FOR_EDICT (pr, e); @@ -1317,7 +1278,8 @@ PF_multicast (progs_t *pr) void PF_cfopen (progs_t *pr) { - G_FLOAT (pr, OFS_RETURN) = CF_Open (G_STRING (pr, OFS_PARM0), G_STRING (pr, OFS_PARM1)); + G_FLOAT (pr, OFS_RETURN) = CF_Open (G_STRING (pr, OFS_PARM0), + G_STRING (pr, OFS_PARM1)); } /* @@ -1350,7 +1312,8 @@ PF_cfread (progs_t *pr) void PF_cfwrite (progs_t *pr) { - G_FLOAT (pr, OFS_RETURN) = CF_Write((int) G_FLOAT(pr, OFS_PARM0), G_STRING (pr, OFS_PARM1)); + G_FLOAT (pr, OFS_RETURN) = CF_Write((int) G_FLOAT(pr, OFS_PARM0), + G_STRING (pr, OFS_PARM1)); } /* @@ -1375,7 +1338,6 @@ PF_cfquota (progs_t *pr) G_FLOAT (pr, OFS_RETURN) = CF_Quota(); } - void PF_setinfokey (progs_t *pr) { @@ -1399,7 +1361,6 @@ PF_setinfokey (progs_t *pr) } } - static void PF_testentitypos (progs_t *pr) { @@ -1408,7 +1369,6 @@ PF_testentitypos (progs_t *pr) RETURN_EDICT (pr, ent ? ent : sv.edicts); } - #define MAX_PF_HULLS 64 // FIXME make dynamic? clip_hull_t *pf_hull_list[MAX_PF_HULLS]; @@ -1430,8 +1390,8 @@ PF_hullpointcontents (progs_t *pr) static void PF_getboxbounds (progs_t *pr) { - int h = G_INT (pr, OFS_PARM0) - 1; clip_hull_t *ch; + int h = G_INT (pr, OFS_PARM0) - 1; if (h < 0 || h > MAX_PF_HULLS - 1 || !(ch = pf_hull_list[h])) PR_RunError (pr, "PF_freeboxhull: invalid box hull handle\n"); @@ -1447,7 +1407,7 @@ static void PF_getboxhull (progs_t *pr) { clip_hull_t *ch = 0; - int i; + int i; for (i = 0; i < MAX_PF_HULLS; i++) { if (!pf_hull_list[i]) { @@ -1470,7 +1430,7 @@ PF_getboxhull (progs_t *pr) static void PF_freeboxhull (progs_t *pr) { - int h = G_INT (pr, OFS_PARM0) - 1; + int h = G_INT (pr, OFS_PARM0) - 1; clip_hull_t *ch; if (h < 0 || h > MAX_PF_HULLS - 1 || !(ch = pf_hull_list[h])) @@ -1482,9 +1442,9 @@ PF_freeboxhull (progs_t *pr) static vec_t calc_dist (vec3_t p, vec3_t n, vec3_t *offsets) { + int i; vec_t d = DotProduct (p, n); vec3_t s, v; - int i; VectorScale (n, d, s); for (i = 0; i < 3; i++) @@ -1499,28 +1459,28 @@ calc_dist (vec3_t p, vec3_t n, vec3_t *offsets) static void PF_rotate_bbox (progs_t *pr) { - int h = G_INT (pr, OFS_PARM0) - 1; + clip_hull_t *ch; + float l; + float *mi = G_VECTOR (pr, OFS_PARM4); + float *ma = G_VECTOR (pr, OFS_PARM5); float *dir[3] = { G_VECTOR (pr, OFS_PARM1), G_VECTOR (pr, OFS_PARM2), G_VECTOR (pr, OFS_PARM3), }; - float *mi = G_VECTOR (pr, OFS_PARM4); - float *ma = G_VECTOR (pr, OFS_PARM5); - vec3_t mins, maxs; + hull_t *hull; + int i, j; + int h = G_INT (pr, OFS_PARM0) - 1; + + vec3_t mins, maxs, d; float *verts[6] = {maxs, mins, maxs, mins, maxs, mins}; - + vec3_t v[8]; vec3_t offsets[3][2] = { { { 0, 0, 0 }, { 0, 0, 0} }, { { -16, -16, -32 }, { 16, 16, 24} }, { { -32, -32, -64 }, { 32, 32, 24} }, }; - vec3_t v[8], d; - hull_t *hull; - clip_hull_t *ch; - int i, j; - float l; if (h < 0 || h > MAX_PF_HULLS - 1 || !(ch = pf_hull_list[h])) PR_RunError (pr, "PF_freeboxhull: invalid box hull handle\n"); @@ -1567,18 +1527,18 @@ PF_rotate_bbox (progs_t *pr) VectorScale (offsets[j][0], -1, hull->clip_maxs); // set up the clip planes for (i = 0; i < 6; i++) { - hull->planes[i].dist = calc_dist (verts[i], dir[i / 2], offsets[j]); + hull->planes[i].dist = calc_dist (verts[i], dir[i / 2], + offsets[j]); hull->planes[i].type = 4; VectorCopy (dir[i / 2], hull->planes[i].normal); - //Con_Printf ("%f %f %f %f\n", - // hull->planes[i].dist, - // hull->planes[i].normal[0], hull->planes[i].normal[1], - // hull->planes[i].normal[2]); +// Con_Printf ("%f %f %f %f\n", +// hull->planes[i].dist, +// hull->planes[i].normal[0], hull->planes[i].normal[1], +// hull->planes[i].normal[2]); } } } - void PF_Fixme (progs_t *pr) { @@ -1596,47 +1556,79 @@ SV_PR_Cmds_Init () { PR_Cmds_Init (&sv_pr_state); - PR_AddBuiltin (&sv_pr_state, "makevectors", PF_makevectors, 1); // void(entity e) makevectors = #1 - PR_AddBuiltin (&sv_pr_state, "setorigin", PF_setorigin, 2); // void(entity e, vector o) setorigin = #2 - PR_AddBuiltin (&sv_pr_state, "setmodel", PF_setmodel, 3); // void(entity e, string m) setmodel = #3 - PR_AddBuiltin (&sv_pr_state, "setsize", PF_setsize, 4); // void(entity e, vector min, vector max) setsize = #4 - PR_AddBuiltin (&sv_pr_state, "fixme", PF_Fixme, 5); // void(entity e, vector min, vector max) setabssize = #5 - PR_AddBuiltin (&sv_pr_state, "sound", PF_sound, 8); // void(entity e, float chan, string samp) sound = #8 - PR_AddBuiltin (&sv_pr_state, "error", PF_error, 10); // void(string e) error = #10 - PR_AddBuiltin (&sv_pr_state, "objerror", PF_objerror, 11); // void(string e) objerror = #11 - PR_AddBuiltin (&sv_pr_state, "spawn", PF_Spawn, 14); // entity() spawn = #14 - PR_AddBuiltin (&sv_pr_state, "remove", PF_Remove, 15); // void(entity e) remove = #15 - PR_AddBuiltin (&sv_pr_state, "traceline", PF_traceline, 16); // float(vector v1, vector v2, float tryents) traceline = #16 - PR_AddBuiltin (&sv_pr_state, "checkclient", PF_checkclient, 17); // entity() clientlist = #17 - PR_AddBuiltin (&sv_pr_state, "precache_sound", PF_precache_sound, 19); // void(string s) precache_sound = #19 - PR_AddBuiltin (&sv_pr_state, "precache_model", PF_precache_model, 20); // void(string s) precache_model = #20 - PR_AddBuiltin (&sv_pr_state, "stuffcmd", PF_stuffcmd, 21); // void(entity client, string s) stuffcmd = #21 - PR_AddBuiltin (&sv_pr_state, "findradius", PF_findradius, 22); // entity(vector org, float rad) findradius = #22 - PR_AddBuiltin (&sv_pr_state, "bprint", PF_bprint, 23); // void(string s) bprint = #23 - PR_AddBuiltin (&sv_pr_state, "sprint", PF_sprint, 24); // void(entity client, string s) sprint = #24 - PR_AddBuiltin (&sv_pr_state, "walkmove", PF_walkmove, 32); // float(float yaw, float dist) walkmove = #32 - // no 33 - PR_AddBuiltin (&sv_pr_state, "droptofloor", PF_droptofloor, 34); // float() droptofloor = #34 - PR_AddBuiltin (&sv_pr_state, "lightstyle", PF_lightstyle, 35); // void(float style, string value) lightstyle = #35 - // no 39 - PR_AddBuiltin (&sv_pr_state, "checkbottom", PF_checkbottom, 40); // float(entity e) checkbottom = #40 - PR_AddBuiltin (&sv_pr_state, "pointcontents", PF_pointcontents, 41); // float(vector v) pointcontents = #41 - // no 42 - PR_AddBuiltin (&sv_pr_state, "aim", PF_aim, 44); // vector(entity e, float speed) aim = #44 - PR_AddBuiltin (&sv_pr_state, "localcmd", PF_localcmd, 46); // void(string s) localcmd = #46 - // no 48 - PR_AddBuiltin (&sv_pr_state, "changeyaw", PF_changeyaw, 49); // void() ChangeYaw = #49 - // no 50 - - PR_AddBuiltin (&sv_pr_state, "writebyte", PF_WriteByte, 52); // void(float to, float f) WriteByte = #52 - PR_AddBuiltin (&sv_pr_state, "writechar", PF_WriteChar, 53); // void(float to, float f) WriteChar = #53 - PR_AddBuiltin (&sv_pr_state, "writeshort", PF_WriteShort, 54); // void(float to, float f) WriteShort = #54 - PR_AddBuiltin (&sv_pr_state, "writelong", PF_WriteLong, 55); // void(float to, float f) WriteLong = #55 - PR_AddBuiltin (&sv_pr_state, "writecoord", PF_WriteCoord, 56); // void(float to, float f) WriteCoord = #56 - PR_AddBuiltin (&sv_pr_state, "writeangle", PF_WriteAngle, 57); // void(float to, float f) WriteAngle = #57 - PR_AddBuiltin (&sv_pr_state, "writestring", PF_WriteString, 58); // void(float to, string s) WriteString = #58 - PR_AddBuiltin (&sv_pr_state, "writeentity", PF_WriteEntity, 59); // void(float to, entity s) WriteEntity = #59 - + PR_AddBuiltin (&sv_pr_state, "makevectors", PF_makevectors, 1); + // void (entity e) makevectors = #1 + PR_AddBuiltin (&sv_pr_state, "setorigin", PF_setorigin, 2); + // void (entity e, vector o) setorigin = #2 + PR_AddBuiltin (&sv_pr_state, "setmodel", PF_setmodel, 3); + // void(entity e, string m) setmodel = #3 + PR_AddBuiltin (&sv_pr_state, "setsize", PF_setsize, 4); + // void (entity e, vector min, vector max) setsize = #4 + PR_AddBuiltin (&sv_pr_state, "fixme", PF_Fixme, 5); + // void (entity e, vector min, vector max) setabssize = #5 + PR_AddBuiltin (&sv_pr_state, "sound", PF_sound, 8); + // void (entity e, float chan, string samp) sound = #8 + PR_AddBuiltin (&sv_pr_state, "error", PF_error, 10); + // void (string e) error = #10 + PR_AddBuiltin (&sv_pr_state, "objerror", PF_objerror, 11); + // void (string e) objerror = #11 + PR_AddBuiltin (&sv_pr_state, "spawn", PF_Spawn, 14); + // entity () spawn = #14 + PR_AddBuiltin (&sv_pr_state, "remove", PF_Remove, 15); + // void (entity e) remove = #15 + PR_AddBuiltin (&sv_pr_state, "traceline", PF_traceline, 16); + // float (vector v1, vector v2, float tryents) traceline = #16 + PR_AddBuiltin (&sv_pr_state, "checkclient", PF_checkclient, 17); + // entity () clientlist = #17 + PR_AddBuiltin (&sv_pr_state, "precache_sound", PF_precache_sound, 19); + // void (string s) precache_sound = #19 + PR_AddBuiltin (&sv_pr_state, "precache_model", PF_precache_model, 20); + // void (string s) precache_model = #20 + PR_AddBuiltin (&sv_pr_state, "stuffcmd", PF_stuffcmd, 21); + // void (entity client, string s) stuffcmd = #21 + PR_AddBuiltin (&sv_pr_state, "findradius", PF_findradius, 22); + // entity (vector org, float rad) findradius = #22 + PR_AddBuiltin (&sv_pr_state, "bprint", PF_bprint, 23); + // void (string s) bprint = #23 + PR_AddBuiltin (&sv_pr_state, "sprint", PF_sprint, 24); + // void (entity client, string s) sprint = #24 + PR_AddBuiltin (&sv_pr_state, "walkmove", PF_walkmove, 32); + // float (float yaw, float dist) walkmove = #32 + // no #33 + PR_AddBuiltin (&sv_pr_state, "droptofloor", PF_droptofloor, 34); + // float () droptofloor = #34 + PR_AddBuiltin (&sv_pr_state, "lightstyle", PF_lightstyle, 35); + // void (float style, string value) lightstyle = #35 + // no #39 + PR_AddBuiltin (&sv_pr_state, "checkbottom", PF_checkbottom, 40); + // float (entity e) checkbottom = #40 + PR_AddBuiltin (&sv_pr_state, "pointcontents", PF_pointcontents, 41); + // float (vector v) pointcontents = #41 + // no #42 + PR_AddBuiltin (&sv_pr_state, "aim", PF_aim, 44); + // vector (entity e, float speed) aim = #44 + PR_AddBuiltin (&sv_pr_state, "localcmd", PF_localcmd, 46); + // void (string s) localcmd = #46 + // no #48 + PR_AddBuiltin (&sv_pr_state, "changeyaw", PF_changeyaw, 49); + // void () ChangeYaw = #49 + // no #50 + PR_AddBuiltin (&sv_pr_state, "writebyte", PF_WriteByte, 52); + // void (float to, float f) WriteByte = #52 + PR_AddBuiltin (&sv_pr_state, "writechar", PF_WriteChar, 53); + // void (float to, float f) WriteChar = #53 + PR_AddBuiltin (&sv_pr_state, "writeshort", PF_WriteShort, 54); + // void (float to, float f) WriteShort = #54 + PR_AddBuiltin (&sv_pr_state, "writelong", PF_WriteLong, 55); + // void(float to, float f) WriteLong = #55 + PR_AddBuiltin (&sv_pr_state, "writecoord", PF_WriteCoord, 56); + // void(float to, float f) WriteCoord = #56 + PR_AddBuiltin (&sv_pr_state, "writeangle", PF_WriteAngle, 57); + // void(float to, float f) WriteAngle = #57 + PR_AddBuiltin (&sv_pr_state, "writestring", PF_WriteString, 58); + // void(float to, string s) WriteString = #58 + PR_AddBuiltin (&sv_pr_state, "writeentity", PF_WriteEntity, 59); + // void(float to, entity s) WriteEntity = #59 // 60 // 61 // 62 @@ -1644,29 +1636,35 @@ SV_PR_Cmds_Init () // 64 // 65 // 66 - - PR_AddBuiltin (&sv_pr_state, "movetogoal", SV_MoveToGoal, 67); // void(float step) movetogoal = #67 - PR_AddBuiltin (&sv_pr_state, "precache_file", PF_precache_file, 68); // string(string s) precache_file = #68 - PR_AddBuiltin (&sv_pr_state, "makestatic", PF_makestatic, 69); // void(entity e) makestatic = #69 - - PR_AddBuiltin (&sv_pr_state, "changelevel", PF_changelevel, 70); // void(string s) changelevel = #70 + PR_AddBuiltin (&sv_pr_state, "movetogoal", SV_MoveToGoal, 67); + // void (float step) movetogoal = #67 + PR_AddBuiltin (&sv_pr_state, "precache_file", PF_precache_file, 68); + // string (string s) precache_file = #68 + PR_AddBuiltin (&sv_pr_state, "makestatic", PF_makestatic, 69); + // void (entity e) makestatic = #69 + PR_AddBuiltin (&sv_pr_state, "changelevel", PF_changelevel, 70); + // void (string s) changelevel = #70 // 71 - - PR_AddBuiltin (&sv_pr_state, "centerprint", PF_centerprint, 73); // void(...) centerprint = #73 - - PR_AddBuiltin (&sv_pr_state, "ambientsound", PF_ambientsound, 74); // void(vector pos, string samp, float vol, float atten) ambientsound = #74 - - PR_AddBuiltin (&sv_pr_state, "precache_model", PF_precache_model, 75); // string(string s) precache_model2 = #75 - PR_AddBuiltin (&sv_pr_state, "precache_sound", PF_precache_sound, 76); // string(string s) precache_sound2 = #76 precache_sound2 is different only for qcc - PR_AddBuiltin (&sv_pr_state, "precache_file", PF_precache_file, 77); // string(string s) precache_file2 = #77 - - PR_AddBuiltin (&sv_pr_state, "setspawnparms", PF_setspawnparms, 78); // void(entity e) setspawnparms = #78 - - PR_AddBuiltin (&sv_pr_state, "logfrag", PF_logfrag, 79); // void(entity killer, entity killee) logfrag = #79 - - PR_AddBuiltin (&sv_pr_state, "infokey", PF_infokey, 80); // string(entity e, string key) infokey = #80 - PR_AddBuiltin (&sv_pr_state, "multicast", PF_multicast, 82); // void(vector where, float set) multicast = #82 - + PR_AddBuiltin (&sv_pr_state, "centerprint", PF_centerprint, 73); + // void (...) centerprint = #73 + PR_AddBuiltin (&sv_pr_state, "ambientsound", PF_ambientsound, 74); + // void (vector pos, string samp, float vol, float atten) + // ambientsound = #74 + PR_AddBuiltin (&sv_pr_state, "precache_model", PF_precache_model, 75); + // string (string s) precache_model2 = #75 + PR_AddBuiltin (&sv_pr_state, "precache_sound", PF_precache_sound, 76); + // string (string s) precache_sound2 = #76 precache_sound2 is different + // only for qcc + PR_AddBuiltin (&sv_pr_state, "precache_file", PF_precache_file, 77); + // string (string s) precache_file2 = #77 + PR_AddBuiltin (&sv_pr_state, "setspawnparms", PF_setspawnparms, 78); + // void (entity e) setspawnparms = #78 + PR_AddBuiltin (&sv_pr_state, "logfrag", PF_logfrag, 79); + // void (entity killer, entity killee) logfrag = #79 + PR_AddBuiltin (&sv_pr_state, "infokey", PF_infokey, 80); + // string (entity e, string key) infokey = #80 + PR_AddBuiltin (&sv_pr_state, "multicast", PF_multicast, 82); + // void (vector where, float set) multicast = #82 // 83 // 84 // 85 @@ -1676,19 +1674,37 @@ SV_PR_Cmds_Init () // 89 // 90 // 91 - PR_AddBuiltin (&sv_pr_state, "testentitypos", PF_testentitypos, 92); // entity (entity ent) testentitypos = #92 - PR_AddBuiltin (&sv_pr_state, "hullpointcontents", PF_hullpointcontents, 93); // integer (entity ent, vector point) hullpointcontents = #93 - PR_AddBuiltin (&sv_pr_state, "getboxbounds", PF_getboxbounds, 94); // vector (integer hull, integer max) getboxbounds = #94 - PR_AddBuiltin (&sv_pr_state, "getboxhull", PF_getboxhull, 95); // integer () getboxhull = #95 - PR_AddBuiltin (&sv_pr_state, "freeboxhull", PF_freeboxhull, 96); // void (integer hull) freeboxhull = #96 - PR_AddBuiltin (&sv_pr_state, "rotate_bbox", PF_rotate_bbox, 97); // void (integer hull, vector right, vector forward, vector up, vector mins, vector maxs) rotate_bbox = #97 - PR_AddBuiltin (&sv_pr_state, "checkmove", PF_checkmove, 98); // void (vector start, vector mins, vector maxs, vector end, float type, entity passent) checkmove = #98 - PR_AddBuiltin (&sv_pr_state, "checkextension", PF_Checkextension, 99); // = #99 - PR_AddBuiltin (&sv_pr_state, "setinfokey", PF_setinfokey, 102); // void (entity ent, string key, string value) setinfokey = #102 - PR_AddBuiltin (&sv_pr_state, "cfopen", PF_cfopen, 103); // float (string path, string mode) cfopen = #103 - PR_AddBuiltin (&sv_pr_state, "cfclose", PF_cfclose, 104); // void (float desc) cfclose = #104 - PR_AddBuiltin (&sv_pr_state, "cfread", PF_cfread, 105); // string (float desc) cfread = #105 - PR_AddBuiltin (&sv_pr_state, "cfwrite", PF_cfwrite, 106); // float (float desc, string buf) cfwrite = #106 - PR_AddBuiltin (&sv_pr_state, "cfeof", PF_cfeof, 107); // float (float desc) cfeof = #107 - PR_AddBuiltin (&sv_pr_state, "cfquota", PF_cfquota, 108); // float () cfquota = #108 + PR_AddBuiltin (&sv_pr_state, "testentitypos", PF_testentitypos, 92); + // entity (entity ent) testentitypos = #92 + PR_AddBuiltin (&sv_pr_state, "hullpointcontents", PF_hullpointcontents, + 93); // integer (entity ent, vector point) + // hullpointcontents = #93 + PR_AddBuiltin (&sv_pr_state, "getboxbounds", PF_getboxbounds, 94); + // vector (integer hull, integer max) getboxbounds = #94 + PR_AddBuiltin (&sv_pr_state, "getboxhull", PF_getboxhull, 95); + // integer () getboxhull = #95 + PR_AddBuiltin (&sv_pr_state, "freeboxhull", PF_freeboxhull, 96); + // void (integer hull) freeboxhull = #96 + PR_AddBuiltin (&sv_pr_state, "rotate_bbox", PF_rotate_bbox, 97); + // void (integer hull, vector right, vector forward, vector up, + // vector mins, vector maxs) rotate_bbox = #97 + PR_AddBuiltin (&sv_pr_state, "checkmove", PF_checkmove, 98); + // void (vector start, vector mins, vector maxs, vector end, + // float type, entity passent) checkmove = #98 + PR_AddBuiltin (&sv_pr_state, "checkextension", PF_Checkextension, 99); + // = #99 + PR_AddBuiltin (&sv_pr_state, "setinfokey", PF_setinfokey, 102); + // void (entity ent, string key, string value) setinfokey = #102 + PR_AddBuiltin (&sv_pr_state, "cfopen", PF_cfopen, 103); + // float (string path, string mode) cfopen = #103 + PR_AddBuiltin (&sv_pr_state, "cfclose", PF_cfclose, 104); + // void (float desc) cfclose = #104 + PR_AddBuiltin (&sv_pr_state, "cfread", PF_cfread, 105); + // string (float desc) cfread = #105 + PR_AddBuiltin (&sv_pr_state, "cfwrite", PF_cfwrite, 106); + // float (float desc, string buf) cfwrite = #106 + PR_AddBuiltin (&sv_pr_state, "cfeof", PF_cfeof, 107); + // float (float desc) cfeof = #107 + PR_AddBuiltin (&sv_pr_state, "cfquota", PF_cfquota, 108); + // float () cfquota = #108 }; diff --git a/qw/source/sv_progs.c b/qw/source/sv_progs.c index f2e11653d..8a108b621 100644 --- a/qw/source/sv_progs.c +++ b/qw/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" @@ -63,6 +62,7 @@ func_t UserInfoCallback; static int reserved_edicts = MAX_CLIENTS; + static void free_edict (progs_t *pr, edict_t *ent) { @@ -98,8 +98,9 @@ prune_edict (progs_t *pr, edict_t *ent) (*sv_globals.current_skill == 0 && ((int) SVfloat (ent, spawnflags) & SPAWNFLAG_NOT_EASY)) || (*sv_globals.current_skill == 1 - && ((int) SVfloat (ent, spawnflags) & SPAWNFLAG_NOT_MEDIUM)) - || (*sv_globals.current_skill >= 2 + && ((int) SVfloat (ent, spawnflags) & + SPAWNFLAG_NOT_MEDIUM)) || + (*sv_globals.current_skill >= 2 && ((int) SVfloat (ent, spawnflags) & SPAWNFLAG_NOT_HARD))) { return 1; } @@ -162,8 +163,8 @@ parse_field (progs_t *pr, const char *key, const char *value) void SV_LoadProgs (void) { - dfunction_t *f; ddef_t *def; + dfunction_t *f; PR_LoadProgs (&sv_pr_state, sv_progs->string); if (!sv_pr_state.progs) @@ -174,40 +175,66 @@ 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.frametime = PR_GetGlobalPointer (&sv_pr_state, "frametime"); + (void *) sv_globals.frametime = PR_GetGlobalPointer (&sv_pr_state, + "frametime"); (void *) sv_globals.newmis = PR_GetGlobalPointer (&sv_pr_state, "newmis"); - (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.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.force_retouch = PR_GetGlobalPointer (&sv_pr_state, + "force_retouch"); + (void *) sv_globals.mapname = PR_GetGlobalPointer (&sv_pr_state, + "mapname"); + (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"); @@ -259,7 +286,8 @@ SV_LoadProgs (void) sv_fields.flags = PR_GetFieldOffset (&sv_pr_state, "flags"); sv_fields.colormap = PR_GetFieldOffset (&sv_pr_state, "colormap"); sv_fields.team = PR_GetFieldOffset (&sv_pr_state, "team"); - sv_fields.teleport_time = PR_GetFieldOffset (&sv_pr_state, "teleport_time"); + sv_fields.teleport_time = PR_GetFieldOffset (&sv_pr_state, + "teleport_time"); sv_fields.armorvalue = PR_GetFieldOffset (&sv_pr_state, "armorvalue"); sv_fields.waterlevel = PR_GetFieldOffset (&sv_pr_state, "waterlevel"); sv_fields.watertype = PR_GetFieldOffset (&sv_pr_state, "watertype"); @@ -269,7 +297,8 @@ SV_LoadProgs (void) sv_fields.spawnflags = PR_GetFieldOffset (&sv_pr_state, "spawnflags"); 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.message = PR_GetFieldOffset (&sv_pr_state, "message"); sv_fields.sounds = PR_GetFieldOffset (&sv_pr_state, "sounds"); @@ -323,14 +352,14 @@ 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 diff --git a/qw/source/sv_send.c b/qw/source/sv_send.c index a30b4c4f2..f2cd4dc4e 100644 --- a/qw/source/sv_send.c +++ b/qw/source/sv_send.c @@ -32,19 +32,22 @@ #ifdef HAVE_STRING_H # include #endif +#ifdef HAVE_STRINGS_H +# include +#endif #include #include #include -#include "compat.h" #include "QF/console.h" #include "QF/cvar.h" #include "QF/msg.h" -#include "QF/sys.h" #include "QF/sound.h" // FIXME: DEFAULT_SOUND_PACKET_* +#include "QF/sys.h" #include "bothdefs.h" +#include "compat.h" #include "server.h" #include "sv_progs.h" @@ -54,22 +57,16 @@ #define CHAN_ITEM 3 #define CHAN_BODY 4 -/* - SV_Printf redirection -*/ +/* SV_Printf redirection */ char outputbuf[8000]; - -redirect_t sv_redirected; int con_printf_no_log; +redirect_t sv_redirected; extern cvar_t *sv_phs; extern cvar_t *sv_timestamps; extern cvar_t *sv_timefmt; -/* - SV_FlushRedirect -*/ void SV_FlushRedirect (void) { @@ -94,7 +91,6 @@ SV_FlushRedirect (void) outputbuf[0] = 0; } - /* SV_BeginRedirect @@ -115,14 +111,13 @@ SV_EndRedirect (void) sv_redirected = RD_NONE; } +#define MAXPRINTMSG 4096 /* SV_Printf Handles cursor positioning, line wrapping, etc */ -#define MAXPRINTMSG 4096 - void SV_Printf (const char *fmt, ...) { @@ -172,9 +167,7 @@ SV_Printf (const char *fmt, ...) } } -/* - EVENT MESSAGES -*/ +/* EVENT MESSAGES */ static void SV_PrintToClient (client_t *cl, int level, const char *string) @@ -184,7 +177,6 @@ SV_PrintToClient (client_t *cl, int level, const char *string) ClientReliableWrite_String (cl, string); } - /* SV_ClientPrintf @@ -193,8 +185,8 @@ SV_PrintToClient (client_t *cl, int level, const char *string) void SV_ClientPrintf (client_t *cl, int level, const char *fmt, ...) { - va_list argptr; char string[1024]; + va_list argptr; if (level < cl->messagelevel) return; @@ -214,10 +206,10 @@ SV_ClientPrintf (client_t *cl, int level, const char *fmt, ...) void SV_BroadcastPrintf (int level, const char *fmt, ...) { - va_list argptr; char string[1024]; client_t *cl; int i; + va_list argptr; va_start (argptr, fmt); vsnprintf (string, sizeof (string), fmt, argptr); @@ -243,8 +235,8 @@ SV_BroadcastPrintf (int level, const char *fmt, ...) void SV_BroadcastCommand (const char *fmt, ...) { - va_list argptr; char string[1024]; + va_list argptr; if (!sv.state) return; @@ -256,7 +248,6 @@ SV_BroadcastCommand (const char *fmt, ...) MSG_WriteString (&sv.reliable_datagram, string); } - /* SV_Multicast @@ -270,11 +261,10 @@ SV_BroadcastCommand (const char *fmt, ...) void SV_Multicast (vec3_t origin, int to) { - client_t *client; byte *mask; + client_t *client; + int leafnum, j; mleaf_t *leaf; - int leafnum; - int j; qboolean reliable; leaf = Mod_PointInLeaf (origin, sv.worldmodel); @@ -286,27 +276,27 @@ SV_Multicast (vec3_t origin, int to) reliable = false; switch (to) { - case MULTICAST_ALL_R: - reliable = true; // intentional fallthrough - case MULTICAST_ALL: - mask = sv.pvs; // leaf 0 is everything; - break; + case MULTICAST_ALL_R: + reliable = true; // intentional fallthrough + case MULTICAST_ALL: + mask = sv.pvs; // leaf 0 is everything; + break; - case MULTICAST_PHS_R: - reliable = true; // intentional fallthrough - case MULTICAST_PHS: - mask = sv.phs + leafnum * 4 * ((sv.worldmodel->numleafs + 31) >> 5); - break; + case MULTICAST_PHS_R: + reliable = true; // intentional fallthrough + case MULTICAST_PHS: + mask = sv.phs + leafnum * 4 * ((sv.worldmodel->numleafs + 31) >> 5); + break; - case MULTICAST_PVS_R: - reliable = true; // intentional fallthrough - case MULTICAST_PVS: - mask = sv.pvs + leafnum * 4 * ((sv.worldmodel->numleafs + 31) >> 5); - break; + case MULTICAST_PVS_R: + reliable = true; // intentional fallthrough + case MULTICAST_PVS: + mask = sv.pvs + leafnum * 4 * ((sv.worldmodel->numleafs + 31) >> 5); + break; - default: - mask = NULL; - SV_Error ("SV_Multicast: bad to:%i", to); + default: + mask = NULL; + SV_Error ("SV_Multicast: bad to:%i", to); } // send the data to all relevent clients @@ -322,12 +312,13 @@ SV_Multicast (vec3_t origin, int to) goto inrange; } - leaf = Mod_PointInLeaf (SVvector (client->edict, origin), sv.worldmodel); + leaf = Mod_PointInLeaf (SVvector (client->edict, origin), + sv.worldmodel); if (leaf) { // -1 is because pvs rows are 1 based, not 0 based like leafs leafnum = leaf - sv.worldmodel->leafs - 1; if (!(mask[leafnum >> 3] & (1 << (leafnum & 7)))) { -// SV_Printf ("supressed multicast\n"); +// SV_Printf ("supressed multicast\n"); continue; } } @@ -345,7 +336,6 @@ SV_Multicast (vec3_t origin, int to) SZ_Clear (&sv.multicast); } - /* SV_StartSound @@ -362,13 +352,10 @@ 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; - vec3_t origin; + int ent, field_mask, sound_num, i; qboolean use_phs; qboolean reliable = false; + vec3_t origin; if (volume < 0 || volume > 255) SV_Error ("SV_StartSound: volume = %i", volume); @@ -379,7 +366,7 @@ SV_StartSound (edict_t *entity, int channel, const char *sample, int volume, if (channel < 0 || channel > 15) SV_Error ("SV_StartSound: channel = %i", channel); -// 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])) @@ -402,8 +389,8 @@ SV_StartSound (edict_t *entity, int channel, const char *sample, int volume, } else use_phs = true; -// if (channel == CHAN_BODY || channel == CHAN_VOICE) -// reliable = true; +// if (channel == CHAN_BODY || channel == CHAN_VOICE) +// reliable = true; channel = (ent << 3) | channel; @@ -416,9 +403,8 @@ SV_StartSound (edict_t *entity, int channel, const char *sample, int volume, // use the entity origin unless it is a bmodel if (SVfloat (entity, solid) == SOLID_BSP) { for (i = 0; i < 3; i++) - origin[i] = - SVvector (entity, origin)[i] + 0.5 * (SVvector (entity, mins)[i] + - SVvector (entity, maxs)[i]); + origin[i] = SVvector (entity, origin)[i] + 0.5 * + (SVvector (entity, mins)[i] + SVvector (entity, maxs)[i]); } else { VectorCopy (SVvector (entity, origin), origin); } @@ -439,10 +425,7 @@ SV_StartSound (edict_t *entity, int channel, const char *sample, int volume, SV_Multicast (origin, reliable ? MULTICAST_ALL_R : MULTICAST_ALL); } - -/* - FRAME UPDATES -*/ +/* FRAME UPDATES */ int sv_nailmodel, sv_supernailmodel, sv_playermodel; @@ -467,16 +450,11 @@ SV_FindModelNumbers (void) } } - -/* - SV_WriteClientdataToMessage -*/ void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg) { + edict_t *ent, *other; int i; - edict_t *other; - edict_t *ent; ent = client->edict; @@ -493,9 +471,9 @@ SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg) 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; @@ -519,8 +497,8 @@ void SV_UpdateClientStats (client_t *client) { edict_t *ent; - int stats[MAX_CL_STATS]; int i; + int stats[MAX_CL_STATS]; ent = client->edict; memset (stats, 0, sizeof (stats)); @@ -531,7 +509,8 @@ SV_UpdateClientStats (client_t *client) ent = svs.clients[client->spec_track - 1].edict; stats[STAT_HEALTH] = SVfloat (ent, health); - stats[STAT_WEAPON] = SV_ModelIndex (PR_GetString (&sv_pr_state, SVstring (ent, weaponmodel))); + stats[STAT_WEAPON] = SV_ModelIndex + (PR_GetString (&sv_pr_state, SVstring (ent, weaponmodel))); stats[STAT_AMMO] = SVfloat (ent, currentammo); stats[STAT_ARMOR] = SVfloat (ent, armorvalue); stats[STAT_SHELLS] = SVfloat (ent, ammo_shells); @@ -554,7 +533,6 @@ SV_UpdateClientStats (client_t *client) stats[STAT_FLYMODE] = (SVfloat (ent, movetype) == MOVETYPE_FLY); - for (i = 0; i < MAX_CL_STATS; i++) if (stats[i] != client->stats[i]) { client->stats[i] = stats[i]; @@ -570,9 +548,6 @@ SV_UpdateClientStats (client_t *client) } } -/* - SV_SendClientDatagram -*/ qboolean SV_SendClientDatagram (client_t *client) { @@ -615,18 +590,15 @@ SV_SendClientDatagram (client_t *client) return true; } -/* - SV_UpdateToReliableMessages -*/ void SV_UpdateToReliableMessages (void) { - int i, j; client_t *client; - pr_type_t *val; edict_t *ent; + int i, j; + pr_type_t *val; -// check for changes to be sent over the reliable streams to all clients + // check for changes to be sent over the reliable streams to all clients for (i = 0, host_client = svs.clients; i < MAX_CLIENTS; i++, host_client++) { if (host_client->state != cs_spawned) continue; @@ -640,7 +612,8 @@ SV_UpdateToReliableMessages (void) continue; ClientReliableWrite_Begin (client, svc_updatefrags, 4); ClientReliableWrite_Byte (client, i); - ClientReliableWrite_Short (client, SVfloat (host_client->edict, frags)); + ClientReliableWrite_Short (client, SVfloat (host_client->edict, + frags)); } host_client->old_frags = SVfloat (host_client->edict, frags); @@ -660,7 +633,6 @@ SV_UpdateToReliableMessages (void) ClientReliableWrite_Begin (host_client, svc_maxspeed, 5); ClientReliableWrite_Float (host_client, host_client->maxspeed); } - } if (sv.datagram.overflowed) @@ -686,24 +658,19 @@ SV_UpdateToReliableMessages (void) } #if defined(_WIN32) && !defined(__GNUC__) -#pragma optimize( "", off ) +# pragma optimize( "", off ) #endif - - -/* - SV_SendClientMessages -*/ void SV_SendClientMessages (void) { - int i, j; client_t *c; + int i, j; -// update frags, names, etc + // update frags, names, etc SV_UpdateToReliableMessages (); -// build individual updates + // build individual updates for (i = 0, c = svs.clients; i < MAX_CLIENTS; i++, c++) { if (!c->state) continue; @@ -743,8 +710,7 @@ SV_SendClientMessages (void) } } } - // if the reliable message overflowed, - // drop the client + // if the reliable message overflowed, drop the client if (c->netchan.message.overflowed) { extern void Analyze_Server_Packet (byte *data, int len); byte *data = Hunk_TempAlloc (c->netchan.message.cursize + 8); @@ -778,16 +744,13 @@ SV_SendClientMessages (void) else Netchan_Transmit (&c->netchan, 0, NULL); // just update // reliable - } } #if defined(_WIN32) && !defined(__GNUC__) -#pragma optimize( "", on ) +# pragma optimize( "", on ) #endif - - /* SV_SendMessagesToAll @@ -796,8 +759,8 @@ SV_SendClientMessages (void) void SV_SendMessagesToAll (void) { - int i; client_t *c; + int i; for (i = 0, c = svs.clients; i < MAX_CLIENTS; i++, c++) if (c->state) // FIXME: should this only send to diff --git a/qw/source/sv_sys_unix.c b/qw/source/sv_sys_unix.c index 8a231bf99..6f1a4061b 100644 --- a/qw/source/sv_sys_unix.c +++ b/qw/source/sv_sys_unix.c @@ -36,12 +36,14 @@ #ifdef HAVE_STRINGS_H # include #endif +#ifdef HAVE_UNISTD_H +# include +#endif +#include #include #include #include -#include -#include #include #include @@ -75,12 +77,15 @@ Sys_Init_Cvars (void) { sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, NULL, "Toggles console screen output"); - sys_extrasleep = Cvar_Get ("sys_extrasleep", "0", CVAR_NONE, NULL, - "Set to cause whatever amount delay in microseconds you want. Mostly useful to generate simulated bad connections."); + sys_extrasleep = Cvar_Get ("sys_extrasleep", "0", CVAR_NONE, NULL, + "Set to cause whatever amount delay in microseconds you want. Mostly " + "useful to generate simulated bad " + "connections."); sys_dead_sleep = Cvar_Get ("sys_dead_sleep", "1", CVAR_NONE, NULL, - "When set, the server gets NO cpu if no clients are connected" - "and there's no other activity. *MIGHT* cause problems with" - "some mods."); + "When set, the server gets NO cpu if no " + "clients are connected and there's no other " + "activity. *MIGHT* cause problems with some " + "mods."); } void @@ -91,9 +96,6 @@ Sys_Init (void) #endif } -/* - Sys_Quit -*/ void Sys_Quit (void) { @@ -103,14 +105,11 @@ Sys_Quit (void) exit (0); } -/* - Sys_Error -*/ void Sys_Error (const char *error, ...) { - va_list argptr; char string[1024]; + va_list argptr; va_start (argptr, error); vsnprintf (string, sizeof (string), error, argptr); @@ -120,7 +119,6 @@ Sys_Error (const char *error, ...) exit (1); } - static int do_stdin = 1; /* @@ -152,16 +150,13 @@ Sys_ConsoleInput (void) return text; } -/* - main -*/ int main (int argc, const char *argv[]) { double time, oldtime, newtime; fd_set fdset; - extern int net_socket; int j; + extern int net_socket; memset (&host_parms, 0, sizeof (host_parms)); @@ -182,9 +177,7 @@ main (int argc, const char *argv[]) // run one frame immediately for first heartbeat SV_Frame (0.1); - // // main loop - // oldtime = Sys_DoubleTime () - 0.1; while (1) { struct timeval _timeout; diff --git a/qw/source/sv_sys_win.c b/qw/source/sv_sys_win.c index d54d799f5..db7051db0 100644 --- a/qw/source/sv_sys_win.c +++ b/qw/source/sv_sys_win.c @@ -30,17 +30,17 @@ # include "config.h" #endif -#include -#include -#include #include +#include +#include +#include -#include "compat.h" -#include "QF/qargs.h" #include "QF/cvar.h" -#include "server.h" +#include "QF/qargs.h" #include "QF/sys.h" +#include "compat.h" +#include "server.h" qboolean is_server = true; qboolean WinNT; @@ -61,9 +61,10 @@ void Sys_Init_Cvars (void) { sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, NULL, - "Toggle console output"); - sys_sleep = Cvar_Get ("sys_sleep", "8", CVAR_NONE, NULL, - "Sleep how long in seconds between checking for connections. minimum is 0, maximum is 13"); + "Toggle console output"); + sys_sleep = Cvar_Get ("sys_sleep", "8", CVAR_NONE, NULL, "Sleep how long " + "in seconds between checking for connections. " + "Minimum is 0, maximum is 13"); } void @@ -74,8 +75,7 @@ Sys_Init (void) #ifdef USE_INTEL_ASM Sys_SetFPCW (); #endif - // 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); @@ -94,9 +94,6 @@ Sys_Init (void) WinNT = false; } -/* - Sys_Quit -*/ void Sys_Quit (void) { @@ -104,20 +101,17 @@ Sys_Quit (void) exit (0); } -/* - Sys_Error -*/ void Sys_Error (const char *error, ...) { - va_list argptr; char text[1024]; + va_list argptr; va_start (argptr, 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); @@ -166,19 +160,15 @@ Sys_ConsoleInput (void) return NULL; } -/* - main -*/ char *newargv[256]; int main (int argc, const char **argv) { double newtime, time, oldtime; - struct timeval timeout; fd_set fdset; - int t; - int sleep_msec; + int sleep_msec, t; + struct timeval timeout; COM_InitArgv (argc, argv); @@ -213,12 +203,10 @@ main (int argc, const char **argv) if (WinNT) Cvar_Set (sys_sleep, "0"); -// run one frame immediately for first heartbeat + // run one frame immediately for first heartbeat SV_Frame (0.1); -// -// main loop -// + // main loop oldtime = Sys_DoubleTime () - 0.1; while (1) { // Now we want to give some processing time to other applications,