mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 05:00:35 +00:00
More header and whitespace horror reduction.
This commit is contained in:
parent
57e98c89d2
commit
f4fd3178f4
15 changed files with 1074 additions and 1278 deletions
|
@ -39,16 +39,16 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#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 <name/userid> <text...>\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> <per # of seconds> <seconds to silence>\n");
|
||||
("Usage: floodprot <# of messages> <per # of seconds> <seconds to "
|
||||
"silence>\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
|
||||
}
|
||||
|
|
|
@ -32,10 +32,6 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_CURSES_H
|
||||
# include <curses.h>
|
||||
#endif
|
||||
|
@ -45,6 +41,11 @@
|
|||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,12 +36,14 @@
|
|||
# include <strings.h>
|
||||
#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)
|
||||
|
|
|
@ -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
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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)
|
||||
|
|
|
@ -30,40 +30,42 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 ();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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
|
||||
|
|
|
@ -32,19 +32,22 @@
|
|||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#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
|
||||
|
|
|
@ -36,12 +36,14 @@
|
|||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -30,17 +30,17 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <winsock.h>
|
||||
#include <conio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <winsock.h>
|
||||
|
||||
#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,
|
||||
|
|
Loading…
Reference in a new issue