1 /* 2 This program is free software; you can redistribute it and/or 3 modify it under the terms of the GNU General Public License 4 as published by the Free Software Foundation; either version 2 5 of the License, or (at your option) any later version. 6 7 This program is distributed in the hope that it will be useful, 8 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 11 See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License 14 along with this program; if not, write to the Free Software 15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 17 */ 18 19 // server.h 20 #ifndef __SERVER_H__ 21 #define __SERVER_H__ 22 23 #include "progs.h" 24 #ifdef USE_PR2 25 #include "pr2_vm.h" 26 #include "pr2.h" 27 #include "g_public.h" 28 #endif 29 #ifndef SERVERONLY 30 #include "qtv.h" 31 #endif 32 33 #define CHAT_ICON_EXPERIMENTAL 1 34 35 #define MAX_MASTERS 8 // max recipients for heartbeat packets 36 37 #define MAX_SIGNON_BUFFERS 16 38 39 // sv_specprint stuff 40 #define SPECPRINT_CENTERPRINT 0x1 41 #define SPECPRINT_SPRINT 0x2 42 #define SPECPRINT_STUFFCMD 0x4 43 44 typedef enum { 45 ss_dead, // no map loaded 46 ss_loading, // spawning level edicts 47 ss_active // actively running 48 } server_state_t; 49 // some qc commands are only valid before the server has finished 50 // initializing (precache commands, static sounds / objects, etc) 51 52 typedef struct packet_s 53 { 54 double time; 55 sizebuf_t msg; 56 byte buf[MSG_BUF_SIZE]; // ?MAX_MSGLEN? 57 struct packet_s *next; 58 } packet_t; 59 60 #define MAX_DELAYED_PACKETS 1024 // maxclients 32 * 77fps * max minping 0.3 = 739.2 61 #define MAP_NAME_LEN 64 62 typedef struct 63 { 64 server_state_t state; // precache commands are only valid during load 65 66 double time; 67 double old_time; // bumped by SV_Physics 68 double old_bot_time; // bumped by SV_RunBots 69 70 double physicstime; // last time physics was run 71 72 int lastcheck; // used by PF_checkclient 73 double lastchecktime; // for monster ai 74 75 qbool paused; // are we paused? 76 double pausedsince; // Sys_DoubleTime() when pause started 77 78 qbool loadgame; // handle connections specially 79 80 //check player/eyes models for hacks 81 unsigned model_player_checksum; 82 unsigned model_newplayer_checksum; 83 unsigned eyes_player_checksum; 84 85 char mapname[MAP_NAME_LEN]; // map name 86 char modelname[MAX_QPATH]; // maps/<name>.bsp, for model_precache[0] 87 unsigned map_checksum; 88 unsigned map_checksum2; 89 cmodel_t *worldmodel; 90 char *model_precache[MAX_MODELS]; // NULL terminated 91 char *vw_model_name[MAX_VWEP_MODELS]; // NULL terminated 92 char *sound_precache[MAX_SOUNDS]; // NULL terminated 93 char *lightstyles[MAX_LIGHTSTYLES]; 94 cmodel_t *models[MAX_MODELS]; 95 96 int num_edicts; // increases towards MAX_EDICTS 97 int num_baseline_edicts;// number of entities that have baselines 98 edict_t *edicts; // can NOT be array indexed, because 99 // edict_t is variable sized, but can 100 // be used to reference the world ent 101 sv_edict_t sv_edicts[MAX_EDICTS]; // part of the edict_t 102 int max_edicts; // might not MAX_EDICTS if mod allocates memory 103 104 byte *pvs, *phs; // fully expanded and decompressed 105 106 // added to every client's unreliable buffer each frame, then cleared 107 sizebuf_t datagram; 108 byte datagram_buf[MAX_DATAGRAM]; 109 110 // added to every client's reliable buffer each frame, then cleared 111 sizebuf_t reliable_datagram; 112 byte reliable_datagram_buf[MAX_MSGLEN]; 113 114 // the multicast buffer is used to send a message to a set of clients 115 sizebuf_t multicast; 116 byte multicast_buf[MAX_MSGLEN]; 117 118 // the signon buffer will be sent to each client as they connect 119 // includes the entity baselines, the static entities, etc 120 // large levels will have >MAX_DATAGRAM sized signons, so 121 // multiple signon messages are kept 122 sizebuf_t signon; 123 unsigned int num_signon_buffers; 124 int signon_buffer_size[MAX_SIGNON_BUFFERS]; 125 byte signon_buffers[MAX_SIGNON_BUFFERS][MAX_DATAGRAM]; 126 127 qbool mvdrecording; 128 129 entity_state_t static_entities[512]; 130 int static_entity_count; 131 } server_t; 132 133 #define NUM_SPAWN_PARMS 16 134 135 // { sv_antilag related 136 typedef struct 137 { 138 qbool present; 139 vec3_t laggedpos; 140 } laggedentinfo_t; 141 // } 142 143 typedef enum 144 { 145 cs_free, // can be reused for a new connection 146 cs_zombie, // client has been disconnected, but don't reuse 147 // connection for a couple seconds 148 cs_preconnected, // has been assigned, but login/realip not settled yet 149 cs_connected, // has been assigned to a client_t, but not in game yet 150 cs_spawned // client is fully in game 151 } sv_client_state_t; // FIXME 152 153 typedef struct 154 { 155 // received from client 156 157 // reply 158 double senttime; 159 float ping_time; 160 161 // { sv_antilag 162 double sv_time; 163 // } 164 165 packet_entities_t entities; 166 } client_frame_t; 167 168 typedef struct 169 { 170 double localtime; 171 vec3_t origin; 172 } antilag_position_t; 173 174 #define MAX_ANTILAG_POSITIONS 128 175 #define MAX_BACK_BUFFERS 128 176 #define MAX_STUFFTEXT 256 177 #define CLIENT_LOGIN_LEN 16 178 #define CLIENT_NAME_LEN 32 179 #define LOGIN_CHALLENGE_LENGTH 128 180 #define LOGIN_FLAG_LENGTH 8 181 #define LOGIN_MIN_RETRY_TIME 5 // 1 login attempt per x seconds 182 183 #ifdef MVD_PEXT1_SERVERSIDEWEAPON 184 #define MAX_WEAPONSWITCH_OPTIONS 10 185 #endif 186 187 typedef struct client_s 188 { 189 sv_client_state_t state; 190 191 int extensions; // what ZQuake extensions the client supports 192 int spectator; // non-interactive 193 int vip; 194 195 qbool sendinfo; // at end of frame, send info to all 196 // this prevents malicious multiple broadcasts 197 float lastnametime; // time of last name change 198 int lastnamecount; // time of last name change 199 unsigned checksum; // checksum for calcs 200 qbool drop; // lose this guy next opportunity 201 int lossage; // loss percentage 202 203 int userid; // identifying number 204 ctxinfo_t _userinfo_ctx_; // infostring 205 ctxinfo_t _userinfoshort_ctx_; // infostring 206 207 antilag_position_t antilag_positions[MAX_ANTILAG_POSITIONS]; 208 int antilag_position_next; 209 210 usercmd_t lastcmd; // for filling in big drops and partial predictions 211 double localtime; // of last message 212 qbool jump_held; 213 214 float maxspeed; // localized maxspeed 215 float entgravity; // localized ent gravity 216 217 edict_t *edict; // EDICT_NUM(clientnum+1) 218 #ifdef USE_PR2 219 int isBot; 220 usercmd_t botcmd; // bot movment 221 #endif 222 char name[CLIENT_NAME_LEN]; // for printing to other people 223 224 char team[CLIENT_NAME_LEN]; 225 // extracted from userinfo 226 int messagelevel; // for filtering printed messages 227 228 // the datagram is written to after every frame, but only cleared 229 // when it is sent out to the client. overflow is tolerated. 230 sizebuf_t datagram; 231 byte datagram_buf[MAX_DATAGRAM]; 232 233 // back buffers for client reliable data 234 sizebuf_t backbuf; 235 int num_backbuf; 236 int backbuf_size[MAX_BACK_BUFFERS]; 237 byte backbuf_data[MAX_BACK_BUFFERS][MAX_MSGLEN]; 238 239 char stufftext_buf[MAX_STUFFTEXT]; 240 241 // Use SV_ClientConnectedTime & SV_ClientGameTime instead 242 double connection_started_realtime; // or time of disconnect for zombies 243 double connection_started_curtime; // like connection_started but curtime (not affected by pause) 244 qbool send_message; // set on frames a datagram arrived on 245 246 // { sv_antilag related 247 laggedentinfo_t laggedents[MAX_CLIENTS]; 248 unsigned int laggedents_count; 249 float laggedents_frac; 250 float laggedents_time; 251 // } 252 253 // spawn parms are carried from level to level 254 float spawn_parms[NUM_SPAWN_PARMS]; 255 256 // client known data for deltas 257 int old_frags; 258 259 int stats[MAX_CL_STATS]; 260 261 double lastservertimeupdate; // last realtime we sent STAT_TIME to the client 262 263 client_frame_t frames[UPDATE_BACKUP]; // updates can be deltad from here 264 265 vfsfile_t *download; // file being downloaded 266 int dupe; // duplicate packets requested 267 #ifdef PROTOCOL_VERSION_FTE 268 #ifdef FTE_PEXT_CHUNKEDDOWNLOADS 269 int download_chunks_perframe; 270 #endif 271 #endif 272 int downloadsize; // total bytes 273 int downloadcount; // bytes sent 274 275 // demo download list for internal cmd dl function 276 // Added by VVD { 277 int demonum[MAX_ARGS]; 278 qbool demolist; 279 // } Added by VVD 280 281 int spec_track; // entnum of player tracking 282 283 double whensaid[10]; // JACK: For floodprots 284 int whensaidhead; // Head value for floodprots 285 double lockedtill; 286 287 FILE *upload; 288 char uploadfn[MAX_QPATH]; 289 netadr_t snap_from; 290 qbool remote_snap; 291 292 char login[CLIENT_LOGIN_LEN]; 293 char login_alias[CLIENT_NAME_LEN]; 294 char login_flag[LOGIN_FLAG_LENGTH]; 295 char login_confirmation[LOGIN_CHALLENGE_LENGTH]; 296 char login_challenge[LOGIN_CHALLENGE_LENGTH]; 297 int logged; 298 qbool logged_in_via_web; 299 double login_request_time; 300 301 int spawncount; // for tracking map changes during downloading 302 303 //bliP: additional -> 304 int file_percent; 305 qbool special; 306 int logincount; 307 float lasttoptime; // time of last topcolor change 308 int lasttopcount; // count of last topcolor change 309 int spec_print; 310 double cuff_time; 311 //bliP: 24/9 anti speed -> 312 int msecs; 313 double last_check; 314 //<- 315 //<- 316 float lastuserinfotime; // time of last userinfo change 317 int lastuserinfocount; // count of last userinfo change 318 319 #ifdef PROTOCOL_VERSION_FTE 320 unsigned int fteprotocolextensions; 321 #endif // PROTOCOL_VERSION_FTE 322 323 #ifdef PROTOCOL_VERSION_FTE2 324 unsigned int fteprotocolextensions2; 325 #endif // PROTOCOL_VERSION_FTE2 326 327 #ifdef PROTOCOL_VERSION_MVD1 328 unsigned int mvdprotocolextensions1; 329 #endif 330 331 #ifdef FTE_PEXT2_VOICECHAT 332 unsigned int voice_read; /*place in ring*/ 333 unsigned char voice_mute[MAX_CLIENTS/8]; 334 qbool voice_active; 335 enum 336 { 337 /*note - when recording an mvd, only 'all' will be received by non-spectating viewers. all other chat will only be heard when spectating the receiver(or sender) of said chat*/ 338 339 /*should we add one to respond to the last speaker? or should that be an automagic +voip_reply instead?*/ 340 VT_TEAM, 341 VT_ALL, 342 VT_NONMUTED, /*cheap, but allows custom private channels with no external pesters*/ 343 VT_PLAYERSLOT0 344 /*player0+...*/ 345 } voice_target; 346 #endif 347 348 //===== NETWORK ============ 349 qbool process_pext; // true if we wait for reply from client on "cmd pext" command. 350 int chokecount; 351 int delta_sequence; // -1 = no compression 352 netchan_t netchan; 353 netadr_t realip; // client's ip, not latest proxy's 354 int realip_num; // random value 355 int realip_count; 356 int rip_vip; 357 double delay; 358 double disable_updates_stop; // Vladis 359 qbool maxping_met; // set if user meets maxping requirements 360 packet_t *packets, *last_packet; 361 362 #ifdef MVD_PEXT1_HIGHLAGTELEPORT 363 // lagged-teleport extension 364 qbool lastteleport_teleport; // true if teleport, otherwise it was spawn 365 int lastteleport_outgoingseq; // outgoing sequence# when the player teleported 366 int lastteleport_incomingseq; // incoming sequence# when the player teleported 367 float lastteleport_teleportyaw; // new yaw angle, post-teleport 368 #endif 369 370 #ifdef MVD_PEXT1_SERVERSIDEWEAPON 371 // server-side weapons extension 372 int weaponswitch_sequence_set; // need to remember what packet current choices were sent in for forgetorder 373 qbool weaponswitch_pending; 374 qbool weaponswitch_hide; // automatically flick back when not firing 375 qbool weaponswitch_hide_on_death;// switch back to 2 1 when dying 376 qbool weaponswitch_wasfiring; // fire pressed on previous frame (will only hide if so) 377 378 qbool weaponswitch_enabled; // allow user to disable while connected 379 int weaponswitch_mode; // user preference 380 qbool weaponswitch_forgetorder; // if set, decide best weapon immediately and don't rank on fire 381 byte weaponswitch_priority[MAX_WEAPONSWITCH_OPTIONS]; 382 #endif 383 384 qbool mvd_write_usercmds; 385 } client_t; 386 387 // a client can leave the server in one of four ways: 388 // dropping properly by quiting or disconnecting 389 // timing out if no valid messages are received for timeout.value seconds 390 // getting kicked off by the server operator 391 // a program error, like an overflowed reliable buffer 392 393 typedef struct 394 { 395 int parsecount; 396 397 vec3_t origin; 398 vec3_t angles; 399 int weaponframe; 400 int frame; 401 int skinnum; 402 int model; 403 int effects; 404 int flags; 405 406 qbool fixangle; 407 408 float sec; 409 410 } demo_client_t; 411 412 typedef struct 413 { 414 demo_client_t clients[MAX_CLIENTS]; 415 double time; 416 qbool paused; 417 byte pause_duration; 418 419 // { reset each time frame wroten with SV_MVDWritePackets() 420 sizebuf_t _buf_; 421 // !!! OUCH OUCH OUCH, 64 frames, so it about 2mb !!! 422 // here data with mvd headers, so it up to 4 mvd msg with maximum size, however basically here alot of small msgs, 423 // so this size pathetic 424 byte _buf__data[(MAX_MVD_SIZE + 10) * 4]; 425 426 int lastto; 427 int lasttype; 428 int lastsize; 429 int lastsize_offset; // this is tricky 430 // } 431 432 } demo_frame_t; 433 434 //qtv proxies are meant to send a small header now, bit like http 435 //this header gives supported version numbers and stuff 436 typedef struct mvdpendingdest_s 437 { 438 qbool error; //disables writers, quit ASAP. 439 int socket; 440 441 char inbuffer[2048]; 442 char outbuffer[2048]; 443 444 char challenge[64]; 445 qbool hasauthed; 446 447 int insize; 448 int outsize; 449 450 qbool must_be_qizmo_tcp_connect; // HACK, this stream should not be allowed but just checked ONLY AND ONLY for qizmo tcp connection 451 452 double io_time; // when last IO occur on socket, so we can timeout this dest 453 netadr_t na; 454 455 struct mvdpendingdest_s *nextdest; 456 } mvdpendingdest_t; 457 458 typedef enum {DEST_NONE, DEST_FILE, DEST_BUFFEREDFILE, DEST_STREAM} desttype_t; 459 460 #define MAX_PROXY_INBUFFER 4096 /* qqshka: too small??? */ 461 462 typedef struct mvddest_s 463 { 464 qbool error; //disables writers, quit ASAP. 465 466 desttype_t desttype; 467 468 int socket; 469 FILE *file; 470 471 char name[MAX_QPATH]; 472 char path[MAX_QPATH]; 473 474 char *cache; 475 int cacheused; 476 int maxcachesize; 477 478 unsigned int totalsize; 479 480 // { used by QTV 481 double io_time; // when last IO occur on socket, so we can timeout this dest 482 int id; // dest id, used by QTV only 483 netadr_t na; 484 485 char inbuffer[MAX_PROXY_INBUFFER]; 486 int inbuffersize; 487 488 char qtvname[64]; 489 490 qtvuser_t *qtvuserlist; 491 492 char qtvaddress[128]; 493 int qtvstreamid; 494 // } 495 496 struct mvddest_s *nextdest; 497 } mvddest_t; 498 499 typedef struct 500 { 501 sizebuf_t datagram; 502 byte datagram_data[MAX_MVD_SIZE]; // data without mvd header 503 504 double time; // sv.time 505 double curtime; // curtime 506 double pingtime; // compare to curtime 507 508 // Something like time of last mvd message, so we can guess delta milliseconds for next message. 509 // you better not relay on this variable... 510 double prevtime; 511 512 client_t recorder; 513 514 qbool fixangle[MAX_CLIENTS]; 515 516 int stats[MAX_CLIENTS][MAX_CL_STATS]; 517 518 int parsecount; // current frame, to which we add demo data 519 int lastwritten; // lastwriten frame 520 521 demo_frame_t frames[UPDATE_BACKUP]; // here we store all previous frames 522 demo_client_t clients[MAX_CLIENTS]; // we store here what we wrote last time so we can delta 523 524 // ===================================== 525 char mem_set_point; // fields below, like ->dest and ->pendingdest must not be memset to 0 526 // ===================================== 527 528 struct mvddest_s *dest; 529 struct mvdpendingdest_s *pendingdest; 530 531 // last recorded demo's names for command "cmd dl . .." (maximum 15 dots) 532 char *lastdemosname[16]; 533 int lastdemospos; 534 } demo_t; 535 536 //============================================================================= 537 538 539 #define STATFRAMES 100 540 typedef struct 541 { 542 double active; 543 double idle; 544 double demo; 545 int count; 546 int packets; 547 548 double latched_active; 549 double latched_idle; 550 double latched_demo; 551 int latched_packets; 552 } svstats_t; 553 554 // MAX_CHALLENGES is made large to prevent a denial 555 // of service attack that could cycle all of them 556 // out before legitimate users connected 557 #define MAX_CHALLENGES 1024 558 559 typedef struct 560 { 561 netadr_t adr; 562 int challenge; 563 int time; 564 } challenge_t; 565 566 // TCPCONNECT --> 567 typedef struct svtcpstream_s 568 { 569 int socketnum; // socket 570 qbool waitingforprotocolconfirmation; // wait for "qizmo\n", first 6 bytes before confirming that is tcpconnection 571 int inlen; // how much bytes we have in inbuffer 572 char inbuffer[1500]; // recv buffer 573 int outlen; // how much bytes we have in outbuffer 574 char outbuffer[1500 * 5]; // send buffer 575 qbool drop; // do we need drop that connection ASAP 576 float timeouttime; // I/O timeout 577 netadr_t remoteaddr; // peer remoter addr 578 struct svtcpstream_s *next; // next tcpconnection in list 579 } svtcpstream_t; 580 // <-- TCPCONNECT 581 582 typedef struct 583 { 584 int spawncount; // number of servers spawned since start, 585 // used to check late spawns 586 int lastuserid; // userid of last spawned client 587 588 socket_t socketip; // main server UDP socket. 589 590 // TCPCONNECT --> 591 int sockettcp; // server TCP socket, used for QTV/TCPCONNECT. 592 svtcpstream_t * tcpstreams; 593 // <-- TCPCONNECT 594 595 client_t clients[MAX_CLIENTS]; 596 int serverflags; // episode completion information 597 598 double last_heartbeat; 599 int heartbeat_sequence; 600 svstats_t stats; 601 602 char info[MAX_SERVERINFO_STRING]; 603 604 #ifdef PROTOCOL_VERSION_FTE 605 unsigned int fteprotocolextensions; 606 #endif // PROTOCOL_VERSION_FTE 607 608 #ifdef PROTOCOL_VERSION_FTE2 609 unsigned int fteprotocolextensions2; 610 #endif // PROTOCOL_VERSION_FTE2 611 612 #ifdef PROTOCOL_VERSION_MVD1 613 unsigned int mvdprotocolextension1; 614 #endif 615 616 // log messages are used so that fraglog processes can get stats 617 int logsequence; // the message currently being filled 618 double logtime; // time of last swap 619 sizebuf_t log[2]; 620 byte log_buf[2][MAX_DATAGRAM]; 621 622 challenge_t challenges[MAX_CHALLENGES]; // to prevent invalid IPs from connecting 623 624 packet_t *free_packets; 625 } server_static_t; 626 627 //============================================================================= 628 629 // edict->movetype values 630 #define MOVETYPE_NONE 0 // never moves 631 #define MOVETYPE_ANGLENOCLIP 1 632 #define MOVETYPE_ANGLECLIP 2 633 #define MOVETYPE_WALK 3 // gravity 634 #define MOVETYPE_STEP 4 // gravity, special edge handling 635 #define MOVETYPE_FLY 5 636 #define MOVETYPE_TOSS 6 // gravity 637 #define MOVETYPE_PUSH 7 // no clip to world, push and crush 638 #define MOVETYPE_NOCLIP 8 639 #define MOVETYPE_FLYMISSILE 9 // extra size to monsters 640 #define MOVETYPE_BOUNCE 10 641 #define MOVETYPE_LOCK 15 // server controls view angles 642 643 // edict->solid values 644 #define SOLID_NOT 0 // no interaction with other objects 645 #define SOLID_TRIGGER 1 // touch on edge, but not blocking 646 #define SOLID_BBOX 2 // touch on edge, block 647 #define SOLID_SLIDEBOX 3 // touch on edge, but not an onground 648 #define SOLID_BSP 4 // bsp clip, touch on edge, block 649 650 // edict->deadflag values 651 #define DAMAGE_NO 0 652 #define DAMAGE_YES 1 653 #define DAMAGE_AIM 2 654 655 // edict->flags 656 #define FL_FLY 1 657 #define FL_SWIM 2 658 #define FL_GLIMPSE 4 659 #define FL_CLIENT 8 660 #define FL_INWATER 16 661 #define FL_MONSTER 32 662 #define FL_GODMODE 64 663 #define FL_NOTARGET 128 664 #define FL_ITEM 256 665 #define FL_ONGROUND 512 666 #define FL_PARTIALGROUND 1024 // not all corners are valid 667 #define FL_WATERJUMP 2048 // player jumping out of water 668 669 // { sv_antilag 670 #define FL_LAGGEDMOVE (1<<16) 671 // } 672 673 #define SPAWNFLAG_NOT_EASY 256 674 #define SPAWNFLAG_NOT_MEDIUM 512 675 #define SPAWNFLAG_NOT_HARD 1024 676 #define SPAWNFLAG_NOT_DEATHMATCH 2048 677 678 #define MULTICAST_ALL 0 679 #define MULTICAST_PHS 1 680 #define MULTICAST_PVS 2 681 682 #define MULTICAST_ALL_R 3 683 #define MULTICAST_PHS_R 4 684 #define MULTICAST_PVS_R 5 685 686 #define MULTICAST_KTX1_EXT 6 // Only send to those using ktx1 protocol extension (todo) 687 #define MULTICAST_MVD_HIDDEN 7 // Insert into MVD stream only, as dem_multiple(0) 688 689 #define MAX_LOCALINFOS 10000 690 // maps in localinfo { 691 #define LOCALINFO_MAPS_LIST_START 1000 692 #define LOCALINFO_MAPS_LIST_END 4999 693 // } 694 695 #define MAX_REDIRECTMESSAGES 128 696 #define OUTPUTBUF_SIZE 8000 697 698 // { server flags 699 700 // force player enter server as spectator if all players's slots are busy and 701 // if there are empty slots for spectators and sv_forcespec_onfull == 2 702 #define SVF_SPEC_ONFULL (1<<0) 703 // do not join server as spectator if server full and sv_forcespec_onfull == 1 704 #define SVF_NO_SPEC_ONFULL (1<<1) 705 706 // } server flags 707 708 //============================================================================ 709 710 extern cvar_t sv_paused; // 1 - normal, 2 - auto (single player), 3 - both 711 extern cvar_t sv_maxspeed; 712 extern cvar_t sv_mintic, sv_maxtic, sv_maxfps; 713 extern cvar_t sv_antilag, sv_antilag_no_pred, sv_antilag_projectiles; 714 715 extern int current_skill; 716 717 extern cvar_t spawn; 718 extern cvar_t teamplay; 719 extern cvar_t serverdemo; 720 extern cvar_t deathmatch; 721 extern cvar_t fraglimit; 722 extern cvar_t timelimit; 723 extern cvar_t skill; 724 extern cvar_t coop; 725 extern cvar_t maxclients; 726 727 extern cvar_t sv_specprint; //bliP: spectator print 728 729 extern server_static_t svs; // persistant server info 730 extern server_t sv; // local server 731 extern demo_t demo; // server demo struct 732 733 extern client_t *sv_client; 734 extern edict_t *sv_player; 735 736 #define MODEL_NAME_LEN 5 737 extern char localmodels[MAX_MODELS][MODEL_NAME_LEN]; // inline model names for precache 738 //extern char localinfo[MAX_LOCALINFO_STRING+1]; 739 extern ctxinfo_t _localinfo_; 740 741 extern qbool sv_error; 742 743 extern char master_rcon_password[128]; 744 745 //=========================================================== 746 747 // 748 // sv_main.c 749 // 750 751 extern double realtime; // not bounded in any way, changed at start of every frame, never reset 752 753 typedef enum { 754 ipft_ban, 755 ipft_safe 756 } ipfiltertype_t; 757 758 typedef struct 759 { 760 unsigned mask; 761 unsigned compare; 762 int level; 763 double time; // for ban expiration 764 ipfiltertype_t type; 765 } ipfilter_t; 766 767 //bliP: penalty filters -> 768 typedef enum { 769 ft_mute, 770 ft_cuff 771 } filtertype_t; 772 773 typedef struct 774 { 775 byte ip[4]; 776 double time; 777 filtertype_t type; 778 } penfilter_t; 779 //<- 780 781 void SV_Frame (double time); 782 void SV_FinalMessage (const char *message); 783 void SV_DropClient (client_t *drop); 784 785 int SV_CalcPing (client_t *cl); 786 void SV_FullClientUpdate (client_t *client, sizebuf_t *buf); 787 void SV_FullClientUpdateToClient (client_t *client, client_t *cl); 788 789 qbool SV_CheckBottom (edict_t *ent); 790 qbool SV_movestep (edict_t *ent, vec3_t move, qbool relink); 791 792 qbool SV_CloseEnough (edict_t *ent, edict_t *goal, float dist); 793 qbool SV_StepDirection (edict_t *ent, float yaw, float dist); 794 void SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist); 795 796 void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg); 797 798 void SV_MoveToGoal (void); 799 800 void SV_InitOperatorCommands (void); 801 802 void SV_SendServerinfo (client_t *client); 803 void SV_ExtractFromUserinfo (client_t *cl, qbool namechanged); 804 int SV_BoundRate (qbool dl, int rate); 805 806 typedef struct 807 { 808 int sec; 809 int min; 810 int hour; 811 int day; 812 int mon; 813 int year; 814 char str[128]; 815 } date_t; 816 817 void SV_TimeOfDay(date_t *date, char *timeformat); 818 819 820 //bliP: init -> 821 void SV_ListFiles_f (void); 822 void SV_RemoveFile_f (void); 823 void SV_RemoveDirectory_f (void); 824 825 #define MAX_PENFILTERS 512 826 void SV_RemoveIPFilter (int i); 827 //static qbool SV_IPCompare (byte *a, byte *b); 828 //static void SV_IPCopy (byte *dest, byte *src); 829 void SV_SavePenaltyFilter (client_t *cl, filtertype_t type, double pentime); 830 double SV_RestorePenaltyFilter (client_t *cl, filtertype_t type); 831 832 qbool SV_FilterPacket (void); 833 void SV_SendBan (void); 834 qbool GameStarted(void); 835 //<- 836 void SV_Script_f (void); 837 int SV_GenerateUserID (void); 838 839 // 840 // sv_init.c 841 // 842 int SV_ModelIndex (char *name); 843 void SV_FlushSignon (void); 844 void SV_SpawnServer (char *server, qbool devmap, char* entityfile, qbool loading_savegame); 845 846 847 // 848 // sv_phys.c 849 // 850 void SV_ProgStartFrame (qbool isBotFrame); 851 void SV_Physics (void); 852 void SV_CheckVelocity (edict_t *ent); 853 void SV_AddGravity (edict_t *ent, float scale); 854 qbool SV_RunThink (edict_t *ent); 855 void SV_Physics_Toss (edict_t *ent); 856 void SV_RunNewmis (void); 857 void SV_RunNQNewmis (void); 858 void SV_Impact (edict_t *e1, edict_t *e2); 859 void SV_SetMoveVars(void); 860 #ifdef USE_PR2 861 void SV_RunBots(void); 862 #endif 863 864 // 865 // sv_send.c 866 // 867 typedef enum {RD_NONE, RD_CLIENT, RD_PACKET, RD_MOD} redirect_t; 868 void SV_BeginRedirect (redirect_t rd); 869 void SV_EndRedirect (void); 870 qbool SV_AddToRedirect(char *msg); 871 872 void SV_Multicast(vec3_t origin, int to); 873 void SV_MulticastEx(vec3_t origin, int to, const char *cl_reliable_key); 874 void SV_StartParticle(vec3_t org, vec3_t dir, int color, int count, int replacement_te, int replacement_count); 875 void SV_StartSound(edict_t *entity, int channel, char *sample, int volume, float attenuation); 876 void SV_ClientPrintf(client_t *cl, int level, char *fmt, ...); 877 void SV_ClientPrintf2(client_t *cl, int level, char *fmt, ...); 878 void SV_BroadcastPrintf(int level, char *fmt, ...); 879 #define BPRINT_IGNOREINDEMO (1<<0) // broad cast print will be not put in demo 880 #define BPRINT_IGNORECLIENTS (1<<1) // broad cast print will not be seen by clients, but may be seen in demo 881 #define BPRINT_QTVONLY (1<<2) // if broad cast print goes to demo, then it will be only qtv sream, but not file 882 #define BPRINT_IGNORECONSOLE (1<<3) // broad cast print will not be put in server console 883 void SV_BroadcastPrintfEx (int level, int flags, char *fmt, ...); 884 void SV_BroadcastCommand (char *fmt, ...); 885 void SV_SendClientMessages (void); 886 void SV_SendDemoMessage(void); 887 void SV_SendMessagesToAll (void); 888 void SV_FindModelNumbers (void); 889 890 891 // 892 // sv_user.c 893 // 894 void SV_ExecuteClientMessage (client_t *cl); 895 void SV_UserInit (void); 896 void SV_TogglePause (const char *msg, int bit); 897 void ProcessUserInfoChange (client_t* sv_client, const char* key, const char* old_value); 898 void SV_RotateCmd(client_t* cl, usercmd_t* cmd); 899 900 #ifdef FTE_PEXT2_VOICECHAT 901 void SV_VoiceInitClient(client_t *client); 902 void SV_VoiceSendPacket(client_t *client, sizebuf_t *buf); 903 #endif 904 905 // 906 // sv_ccmds.c 907 // 908 void SV_Status_f (void); 909 void SV_ServerinfoChanged (char *key, char *string); 910 void SV_SendServerInfoChange (char *key, char *value); 911 void SV_KickClient(client_t* client, const char* reason); 912 913 // 914 // sv_ents.c 915 // 916 void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qbool recorder); 917 void SV_SetVisibleEntitiesForBot (client_t* client); 918 919 // 920 // sv_nchan.c 921 // 922 void ClientReliableCheckBlock(client_t *cl, int maxsize); 923 void ClientReliable_FinishWrite(client_t *cl); 924 void ClientReliableWrite_Begin(client_t *cl, int c, int maxsize); 925 void ClientReliableWrite_Angle(client_t *cl, float f); 926 void ClientReliableWrite_Angle16(client_t *cl, float f); 927 void ClientReliableWrite_Byte(client_t *cl, int c); 928 void ClientReliableWrite_Char(client_t *cl, int c); 929 void ClientReliableWrite_Float(client_t *cl, float f); 930 void ClientReliableWrite_Coord(client_t *cl, float f); 931 void ClientReliableWrite_Long(client_t *cl, int c); 932 void ClientReliableWrite_Short(client_t *cl, int c); 933 void ClientReliableWrite_String(client_t *cl, char *s); 934 void ClientReliableWrite_SZ(client_t *cl, void *data, int len); 935 void SV_ClearReliable (client_t *cl); // clear cl->netchan.message and backbuf 936 937 // 938 // sv_demo.c 939 // 940 941 void MVD_MSG_WriteChar (const int c); 942 void MVD_MSG_WriteByte (const int c); 943 void MVD_MSG_WriteShort (const int c); 944 void MVD_MSG_WriteLong (const int c); 945 void MVD_MSG_WriteFloat (const float f); 946 void MVD_MSG_WriteString (const char *s); 947 void MVD_MSG_WriteCoord (const float f); 948 void MVD_MSG_WriteAngle (const float f); 949 void MVD_SZ_Write (const void *data, int length); 950 951 qbool MVDWrite_Begin(byte type, int to, int size); 952 qbool MVDWrite_HiddenBlockBegin(int length); 953 qbool MVDWrite_HiddenBlock(const void* data, int length); 954 955 void SV_MVD_Record_f (void); 956 void SV_MVDEasyRecord_f (void); 957 958 void SV_MVDStop (int reason, qbool mvdonly); 959 void SV_MVDStop_f (void); 960 qbool SV_MVDWritePackets (int num); 961 void SV_MVD_SendInitialGamestate(mvddest_t *dest); 962 qbool SV_MVD_Record (mvddest_t *dest, qbool mapchange); 963 964 mvddest_t *DestByName (char *name); 965 void DestClose (mvddest_t *d, qbool destroyfiles); 966 967 int DemoWriteDest (void *data, int len, mvddest_t *d); 968 969 extern demo_t demo; // server demo struct 970 971 extern cvar_t sv_demoUseCache; 972 extern cvar_t sv_demoCacheSize; 973 extern cvar_t sv_demoMaxDirSize; 974 extern cvar_t sv_demoClearOld; 975 extern cvar_t sv_demoDir; 976 extern cvar_t sv_demoDirAlt; 977 extern cvar_t sv_demofps; 978 extern cvar_t sv_demoPings; 979 extern cvar_t sv_demoMaxSize; 980 extern cvar_t sv_demoExtraNames; 981 982 extern cvar_t sv_demoPrefix; 983 extern cvar_t sv_demoSuffix; 984 extern cvar_t sv_demotxt; 985 extern cvar_t sv_onrecordfinish; 986 987 extern cvar_t sv_ondemoremove; 988 extern cvar_t sv_demoRegexp; 989 990 extern cvar_t sv_silentrecord; 991 992 void SV_MVDInit (void); 993 char *SV_MVDNum(int num); 994 995 // 996 // sv_demo_misc.c 997 // 998 999 char *SV_PrintTeams (void); 1000 void Run_sv_demotxt_and_sv_onrecordfinish (const char *dest_name, const char *dest_path, qbool destroyfiles); 1001 qbool SV_DirSizeCheck (void); 1002 char *SV_CleanName (unsigned char *name); 1003 int Dem_CountPlayers (void); 1004 char *Dem_Team (int num); 1005 char *Dem_PlayerName (int num); 1006 char *Dem_PlayerNameTeam (char *t); 1007 int Dem_CountTeamPlayers (char *t); 1008 char *quote (char *str); 1009 void CleanName_Init (void); 1010 void SV_LastScores_f (void); 1011 void SV_DemoList_f (void); 1012 void SV_DemoListRegex_f (void); 1013 void SV_MVDRemove_f (void); 1014 void SV_MVDRemoveNum_f (void); 1015 void SV_MVDInfoAdd_f (void); 1016 void SV_MVDInfoRemove_f (void); 1017 void SV_MVDInfo_f (void); 1018 void SV_LastScores_f (void); 1019 char* SV_MVDName2Txt (const char *name); 1020 void SV_MVDEmbedInfo_f(void); 1021 1022 // 1023 // sv_demo_qtv.c 1024 // 1025 1026 extern cvar_t qtv_streamtimeout; 1027 1028 1029 void SV_MVDStream_Poll(void); 1030 void SV_MVDCloseStreams(void); 1031 void SV_QTV_Init(void); 1032 1033 void DemoWriteQTV (sizebuf_t *msg); 1034 void QTVsv_FreeUserList(mvddest_t *d); 1035 void QTV_Streams_List (void); 1036 void QTV_Streams_UserList (void); 1037 const char* SV_MVDDemoName(void); 1038 1039 // 1040 // sv_login.c 1041 // 1042 1043 void SV_LoadAccounts(void); 1044 void SV_CreateAccount_f(void); 1045 void SV_RemoveAccount_f(void); 1046 void SV_ListAccount_f (void); 1047 void Login_Init (void); 1048 qbool SV_Login(client_t *cl); 1049 void SV_Logout(client_t *cl); 1050 void SV_ParseWebLogin(client_t* cl); 1051 void SV_ParseLogin(client_t *cl); 1052 void SV_LoginCheckTimeOut(client_t *cl); 1053 void SV_LoginWebCheck(client_t* cl); 1054 void SV_LoginWebFailed(client_t* cl); 1055 qbool SV_LoginRequired(client_t* cl); 1056 qbool SV_LoginBlockJoinRequest(client_t* cl); 1057 1058 // sv_master.c 1059 void SV_SetMaster_f (void); 1060 void SV_Heartbeat_f (void); 1061 void Master_Shutdown (void); 1062 void Master_Heartbeat (void); 1063 1064 // sv_save.c 1065 void SV_SaveGame_f (void); 1066 void SV_LoadGame_f (void); 1067 1068 // 1069 void SV_WriteDelta(client_t* client, entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qbool force); 1070 qbool SV_SkipCommsBotMessage(client_t* client); 1071 1072 // 1073 #ifdef SERVERONLY 1074 #include "central.h" 1075 #else 1076 extern qbool server_cfg_done; 1077 #endif 1078 1079 // These functions tell us how much time has passed since the client connected 1080 // Sometimes this should be affected by pause (scoreboards) and sometimes not (spam, networking) 1081 // GameTime() stops while game is paused, Connected() continues as normal 1082 // Both return 0 if client hasn't connected yet 1083 double SV_ClientConnectedTime(client_t* client); // real-world time passed 1084 double SV_ClientGameTime(client_t* client); // affected by pause 1085 void SV_SetClientConnectionTime(client_t* client); 1086 1087 #ifdef SERVERONLY 1088 // mvdsv not changed over to enums yet, which was more about documentation 1089 #define SV_CommandLineEnableCheats() (COM_CheckParm("-cheats")) 1090 #define SV_CommandLineEnableLocalCommand() (COM_CheckParm("-enablelocalcommand")) 1091 #define SV_CommandLineDemoCacheArgument() (COM_CheckParm("-democache")) 1092 #define SV_CommandLineProgTypeArgument() (COM_CheckParm("-progtype")) 1093 #define SV_CommandLineUseMinimumMemory() (COM_CheckParm("-minmemory")) 1094 #define SV_CommandLineHeapSizeMemoryKB() (COM_CheckParm("-heapsize")) 1095 #define SV_CommandLineHeapSizeMemoryMB() (COM_CheckParm("-mem")) 1096 #else 1097 #define SV_CommandLineEnableCheats() (COM_CheckParm(cmdline_param_server_enablecheats)) 1098 #define SV_CommandLineEnableLocalCommand() (COM_CheckParm(cmdline_param_server_enablelocalcommand)) 1099 #define SV_CommandLineDemoCacheArgument() (COM_CheckParm(cmdline_param_server_democache_kb)) 1100 #define SV_CommandLineProgTypeArgument() (COM_CheckParm(cmdline_param_server_progtype)) 1101 #define SV_CommandLineUseMinimumMemory() (COM_CheckParm(cmdline_param_host_memory_minimum)) 1102 #define SV_CommandLineHeapSizeMemoryKB() (COM_CheckParm(cmdline_param_host_memory_kb)) 1103 #define SV_CommandLineHeapSizeMemoryMB() (COM_CheckParm(cmdline_param_host_memory_mb)) 1104 #endif 1105 1106 #endif /* !__SERVER_H__ */ 1107