1 void race_send_recordtime(float msg);
2 void race_SendRankings(float pos, float prevpos, float del, float msg);
4 void send_CSQC_teamnagger() {
5 WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
6 WriteByte(MSG_BROADCAST, TE_CSQC_TEAMNAGGER);
9 void Announce(string snd) {
10 WriteByte(MSG_ALL, SVC_TEMPENTITY);
11 WriteByte(MSG_ALL, TE_CSQC_ANNOUNCE);
12 WriteString(MSG_ALL, snd);
15 void AnnounceTo(entity e, string snd) {
16 if (clienttype(e) == CLIENTTYPE_REAL)
19 WriteByte(MSG_ONE, SVC_TEMPENTITY);
20 WriteByte(MSG_ONE, TE_CSQC_ANNOUNCE);
21 WriteString(MSG_ONE, snd);
25 float ClientData_Send(entity to, float sf)
36 if(to.classname == "spectator")
42 sf |= 1; // forced scoreboard
43 if(to.spectatee_status)
44 sf |= 2; // spectator ent number follows
47 if(e.porto_v_angle_held)
48 sf |= 8; // angles held
50 WriteByte(MSG_ENTITY, ENT_CLIENT_CLIENTDATA);
51 WriteByte(MSG_ENTITY, sf);
54 WriteByte(MSG_ENTITY, to.spectatee_status);
58 WriteAngle(MSG_ENTITY, e.v_angle_x);
59 WriteAngle(MSG_ENTITY, e.v_angle_y);
65 void ClientData_Attach()
67 Net_LinkEntity(self.clientdata = spawn(), FALSE, 0, ClientData_Send);
68 self.clientdata.drawonlytoclient = self;
69 self.clientdata.owner = self;
72 void ClientData_Detach()
74 remove(self.clientdata);
75 self.clientdata = world;
78 void ClientData_Touch(entity e)
80 e.clientdata.SendFlags = 1;
82 // make it spectatable
84 FOR_EACH_REALCLIENT(e2)
87 if(e2.classname == "spectator")
89 e2.clientdata.SendFlags = 1;
94 .vector spawnpoint_score;
95 .string netname_previous;
97 void spawnfunc_info_player_survivor (void)
99 spawnfunc_info_player_deathmatch();
102 void spawnfunc_info_player_start (void)
104 spawnfunc_info_player_deathmatch();
107 void spawnfunc_info_player_deathmatch (void)
109 self.classname = "info_player_deathmatch";
110 relocate_spawnpoint();
113 void spawnpoint_use()
116 if(have_team_spawns > 0)
118 self.team = activator.team;
119 some_spawn_has_been_used = 1;
124 // _x: prio (-1 if unusable)
126 vector Spawn_Score(entity spot, entity playerlist, float teamcheck, float anypoint)
128 float shortest, thisdist;
134 // filter out spots for the wrong team
136 if(spot.team != teamcheck)
140 if(spot.target == "")
143 if(clienttype(self) == CLIENTTYPE_REAL)
145 if(spot.restriction == 1)
150 if(spot.restriction == 2)
154 // filter out spots for assault
155 if(spot.target != "") {
161 for(ent = world; (ent = find(ent, targetname, spot.target)); )
164 if(ent.classname == "target_objective")
166 if(ent.health < 0 || ent.health >= ASSAULT_VALUE_INACTIVE)
169 else if(ent.classname == "trigger_race_checkpoint")
171 if(!anypoint) // spectators may spawn everywhere
173 if(g_race_qualifying)
176 if(ent.race_checkpoint != 0)
178 if(spot.race_place != race_lowest_place_spawn)
183 if(ent.race_checkpoint != self.race_respawn_checkpoint)
185 // try reusing the previous spawn
186 if(ent == self.race_respawn_spotref || spot == self.race_respawn_spotref)
188 if(ent.race_checkpoint == 0)
191 pl = self.race_place;
192 if(pl > race_highest_place_spawn)
194 if(pl == 0 && !self.race_started)
195 pl = race_highest_place_spawn; // use last place if he has not even touched finish yet
196 if(spot.race_place != pl)
207 dprint("WARNING: spawnpoint at ", vtos(spot.origin), " could not find its target ", spot.target, "\n");
211 if(good < found) // at least one was bad
216 shortest = vlen(world.maxs - world.mins);
217 for(player = playerlist; player; player = player.chain)
220 thisdist = vlen(player.origin - spot.origin);
221 if (thisdist < shortest)
224 return prio * '1 0 0' + shortest * '0 1 0';
229 entity Spawn_FilterOutBadSpots(entity firstspot, entity playerlist, float mindist, float teamcheck, float anypoint)
231 entity spot, spotlist, spotlistend;
232 spawn_allgood = TRUE;
238 for(spot = firstspot; spot; spot = spot.chain)
240 spot.spawnpoint_score = Spawn_Score(spot, playerlist, teamcheck, anypoint);
242 if(autocvar_spawn_debugview)
244 setmodel(spot, "models/runematch/rune.mdl");
245 if(spot.spawnpoint_score_y < mindist)
247 spot.colormod = '1 0 0';
252 spot.colormod = '0 1 0';
253 spot.scale = spot.spawnpoint_score_y / mindist;
257 if(spot.spawnpoint_score_x >= 0) // spawning allowed here
259 if(spot.spawnpoint_score_y < mindist)
261 // too short distance
262 spawn_allgood = FALSE;
267 spawn_allbad = FALSE;
270 spotlistend.chain = spot;
277 if(spot.team != teamcheck)
278 error("invalid spawn added");
280 print("added ", etos(spot), "\n");
286 spotlistend.chain = world;
291 for(e = spotlist; e; e = e.chain)
293 print("seen ", etos(e), "\n");
294 if(e.team != teamcheck)
295 error("invalid spawn found");
302 entity Spawn_WeightedPoint(entity firstspot, float lower, float upper, float exponent)
304 // weight of a point: bound(lower, mindisttoplayer, upper)^exponent
305 // multiplied by spot.cnt (useful if you distribute many spawnpoints in a small area)
308 RandomSelection_Init();
309 for(spot = firstspot; spot; spot = spot.chain)
310 RandomSelection_Add(spot, 0, string_null, pow(bound(lower, spot.spawnpoint_score_y, upper), exponent) * spot.cnt, (spot.spawnpoint_score_y >= lower) * 0.5 + spot.spawnpoint_score_x);
312 return RandomSelection_chosen_ent;
319 Finds a point to respawn
322 entity SelectSpawnPoint (float anypoint)
325 entity firstspot_new;
326 entity spot, firstspot, playerlist;
328 spot = find (world, classname, "testplayerstart");
334 else if(have_team_spawns > 0)
336 if(have_team_spawns_forteam[self.team] == 0)
338 // we request a spawn for a team, and we have team
339 // spawns, but that team has no spawns?
340 if(have_team_spawns_forteam[0])
344 // if not, any spawn has to do
348 teamcheck = self.team; // MUST be team
350 else if(have_team_spawns == 0 && have_team_spawns_forteam[0])
351 teamcheck = 0; // MUST be noteam
354 // if we get here, we either require team spawns but have none, or we require non-team spawns and have none; use any spawn then
357 // get the list of players
358 playerlist = findchain(classname, "player");
359 // get the entire list of spots
360 firstspot = findchain(classname, "info_player_deathmatch");
361 // filter out the bad ones
362 // (note this returns the original list if none survived)
365 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
369 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, 100, teamcheck, anypoint);
371 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, -1, teamcheck, anypoint);
372 firstspot = firstspot_new;
374 // there is 50/50 chance of choosing a random spot or the furthest spot
375 // (this means that roughly every other spawn will be furthest, so you
376 // usually won't get fragged at spawn twice in a row)
377 if (arena_roundbased && !g_ca)
379 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, 800, teamcheck, anypoint);
381 firstspot = firstspot_new;
382 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
384 else if (random() > autocvar_g_spawn_furthest)
385 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
387 spot = Spawn_WeightedPoint(firstspot, 1, 5000, 5); // chooses a far far away spawnpoint
390 if(autocvar_spawn_debugview)
392 print("spot mindistance: ", vtos(spot.spawnpoint_score), "\n");
396 for(e = firstspot; e; e = e.chain)
397 if(e.team != teamcheck)
398 error("invalid spawn found");
403 if(autocvar_spawn_debug)
407 if(some_spawn_has_been_used)
408 return world; // team can't spawn any more, because of actions of other team
410 error("Cannot find a spawn point - please fix the map!");
421 Checks if the argument string can be a valid playermodel.
422 Returns a valid one in doubt.
425 string FallbackPlayerModel;
426 string CheckPlayerModel(string plyermodel) {
427 if(FallbackPlayerModel != cvar_defstring("_cl_playermodel"))
429 // note: we cannot summon Don Strunzone here, some player may
430 // still have the model string set. In case anyone manages how
431 // to change a cvar default, we'll have a small leak here.
432 FallbackPlayerModel = strzone(cvar_defstring("_cl_playermodel"));
434 if(strlen(plyermodel) < 4)
435 return FallbackPlayerModel;
436 if( substring(plyermodel,0,14) != "models/player/")
437 return FallbackPlayerModel;
438 else if(autocvar_sv_servermodelsonly)
440 if(substring(plyermodel,-4,4) != ".zym")
441 if(substring(plyermodel,-4,4) != ".dpm")
442 if(substring(plyermodel,-4,4) != ".iqm")
443 if(substring(plyermodel,-4,4) != ".md3")
444 if(substring(plyermodel,-4,4) != ".psk")
445 return FallbackPlayerModel;
446 // forbid the LOD models
447 if(substring(plyermodel, -9,5) == "_lod1")
448 return FallbackPlayerModel;
449 if(substring(plyermodel, -9,5) == "_lod2")
450 return FallbackPlayerModel;
451 if(plyermodel != strtolower(plyermodel))
452 return FallbackPlayerModel;
453 if(!fexists(plyermodel))
454 return FallbackPlayerModel;
461 Client_customizeentityforclient
466 void Client_uncustomizeentityforclient()
468 if(self.modelindex == 0) // no need to uncustomize then
470 self.modelindex = self.modelindex_lod0;
471 self.skin = self.skinindex;
474 float Client_customizeentityforclient()
478 if(self.modelindex == 0)
485 t0 = gettime(GETTIME_HIRES); // reference
490 #ifdef ALLOW_FORCEMODELS
491 if(other.cvar_cl_forceplayermodelsfromxonotic)
492 if not(self.modelindex_lod0_from_xonotic)
494 if(other.cvar_cl_forceplayermodels && sv_clforceplayermodels)
498 self.skin = modelsource.skinindex;
501 if(modelsource == self)
502 self.skin = modelsource.skinindex;
504 self.skin = mod(modelsource.skinindex, 3); // forbid the fbskins as forced skins
508 // other: the player viewing me
512 if(other.cvar_cl_playerdetailreduction <= 0)
514 if(other.cvar_cl_playerdetailreduction <= -2)
515 self.modelindex = modelsource.modelindex_lod2;
516 else if(other.cvar_cl_playerdetailreduction <= -1)
517 self.modelindex = modelsource.modelindex_lod1;
519 self.modelindex = modelsource.modelindex_lod0;
523 distance = vlen(self.origin - other.origin);
524 f = (distance + 100.0) * other.cvar_cl_playerdetailreduction;
525 if(f > sv_loddistance2)
526 self.modelindex = modelsource.modelindex_lod2;
527 else if(f > sv_loddistance1)
528 self.modelindex = modelsource.modelindex_lod1;
530 self.modelindex = modelsource.modelindex_lod0;
535 t1 = gettime(GETTIME_HIRES); // reference
536 client_cefc_accumulator += (t1 - t0);
542 void setmodel_lod(entity e, string modelname)
548 // FIXME: this only supports 3-letter extensions
549 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod1", substring(modelname, -4, 4));
552 setmodel(e, s); // players have high precision
553 self.modelindex_lod1 = self.modelindex;
556 self.modelindex_lod1 = -1;
558 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod2", substring(modelname, -4, 4));
561 setmodel(e, s); // players have high precision
562 self.modelindex_lod2 = self.modelindex;
565 self.modelindex_lod2 = -1;
567 precache_model(modelname);
568 setmodel(e, modelname); // players have high precision
569 self.modelindex_lod0 = self.modelindex;
571 if(self.modelindex_lod1 < 0)
572 self.modelindex_lod1 = self.modelindex;
574 if(self.modelindex_lod2 < 0)
575 self.modelindex_lod2 = self.modelindex;
579 precache_model(modelname);
580 setmodel(e, modelname); // players have high precision
581 self.modelindex_lod0 = self.modelindex;
582 // save it for possible player model forcing
585 s = whichpack(self.model);
586 self.modelindex_lod0_from_xonotic = ((s == "") || (substring(s, 0, 4) == "data"));
588 player_setupanimsformodel();
589 UpdatePlayerSounds();
596 putting a client as observer in the server
599 void FixPlayermodel();
600 void PutObserverInServer (void)
603 self.hud = HUD_NORMAL;
604 race_PreSpawnObserver();
606 spot = SelectSpawnPoint (TRUE);
608 error("No spawnpoints for observers?!?\n");
609 RemoveGrapplingHook(self); // Wazat's Grappling Hook
611 if(clienttype(self) == CLIENTTYPE_REAL)
614 WriteByte(MSG_ONE, SVC_SETVIEW);
615 WriteEntity(MSG_ONE, self);
619 MUTATOR_CALLHOOK(MakePlayerObserver);
622 minstagib_stop_countdown();
624 Portal_ClearAll(self);
628 PlayerStats_Event(self, PLAYERSTATS_ALIVETIME, time - self.alivetime);
633 vehicles_exit(VHEF_RELESE);
636 DropFlag(self.flagcarried, world, world);
638 if(self.ballcarried && g_nexball)
639 DropBall(self.ballcarried, self.origin + self.ballcarried.origin, self.velocity);
641 WaypointSprite_PlayerDead();
643 if not(g_ca) // don't reset teams when moving a ca player to the spectators
644 self.team = -1; // move this as it is needed to log the player spectating in eventlog
646 if(self.killcount != -666) {
648 if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0)
649 bprint ("^4", self.netname, "^4 has no more lives left\n");
651 bprint ("^4", self.netname, "^4 is spectating now\n"); // TODO turn this into a proper forfeit?
653 bprint ("^4", self.netname, "^4 is spectating now\n");
655 if(self.just_joined == FALSE) {
656 LogTeamchange(self.playerid, -1, 4);
658 self.just_joined = FALSE;
661 PlayerScore_Clear(self); // clear scores when needed
663 accuracy_resend(self);
665 self.spectatortime = time;
667 self.classname = "observer";
668 self.iscreature = FALSE;
669 self.damagedbycontents = FALSE;
671 self.takedamage = DAMAGE_NO;
672 self.solid = SOLID_NOT;
673 self.movetype = MOVETYPE_FLY_WORLDONLY; //(self.cvar_cl_clippedspectating ? MOVETYPE_NOCLIP : MOVETYPE_FLY); // it's too early for this anyway, lets just set it in playerprethink
674 self.flags = FL_CLIENT | FL_NOTARGET;
675 self.armorvalue = 666;
677 self.armorvalue = autocvar_g_balance_armor_start;
678 self.pauserotarmor_finished = 0;
679 self.pauserothealth_finished = 0;
680 self.pauseregen_finished = 0;
681 self.damageforcescale = 0;
688 self.pain_finished = 0;
689 self.strength_finished = 0;
690 self.invincible_finished = 0;
692 self.think = SUB_Null;
696 self.deadflag = DEAD_NO;
697 self.angles = spot.angles;
699 self.fixangle = TRUE;
702 self.view_ofs = '0 0 0'; // so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS"
703 setorigin (self, spot.origin);
704 setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX); // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
705 self.prevorigin = self.origin;
713 self.weaponname = "";
714 self.switchingweapon = 0;
715 self.weaponmodel = "";
716 self.weaponentity = world;
717 self.exteriorweaponentity = world;
718 self.killcount = -666;
719 self.velocity = '0 0 0';
720 self.avelocity = '0 0 0';
721 self.punchangle = '0 0 0';
722 self.punchvector = '0 0 0';
723 self.oldvelocity = self.velocity;
724 self.fire_endtime = -1;
727 SetCustomizer(self, Client_customizeentityforclient, Client_uncustomizeentityforclient);
731 if(self.version_mismatch)
733 Spawnqueue_Unmark(self);
734 Spawnqueue_Remove(self);
738 Spawnqueue_Insert(self);
743 // Only if the player cannot play at all
744 if(PlayerScore_Add(self, SP_LMS_RANK, 0) == 666)
745 self.frags = FRAGS_SPECTATOR;
747 self.frags = FRAGS_LMS_LOSER;
752 self.frags = FRAGS_LMS_LOSER;
754 self.frags = FRAGS_SPECTATOR;
757 self.frags = FRAGS_SPECTATOR;
760 void FixPlayermodel()
763 float defaultskin, chmdl, oldskin;
768 if(autocvar_sv_defaultcharacter == 1) {
774 s = Team_ColorNameLowerCase(self.team);
777 defaultmodel = cvar_string(strcat("sv_defaultplayermodel_", s));
778 defaultskin = cvar(strcat("sv_defaultplayerskin_", s));
782 if(defaultmodel == "")
784 defaultmodel = autocvar_sv_defaultplayermodel;
785 defaultskin = autocvar_sv_defaultplayerskin;
789 if(self.modelindex == 0 && self.deadflag == DEAD_NO)
792 bprint("\{1}^1Player ", self.netname, "^1 has a zero modelindex, trying to fix...\n");
793 self.model = ""; // force the != checks to return true
796 if(defaultmodel != "")
798 if (defaultmodel != self.model)
802 setmodel_lod (self, defaultmodel);
803 setsize (self, m1, m2);
807 oldskin = self.skinindex;
808 self.skinindex = defaultskin;
810 if (self.playermodel != self.model || self.playermodel == "")
812 self.playermodel = CheckPlayerModel(self.playermodel); // this is never "", so no endless loop
815 setmodel_lod (self, self.playermodel);
816 setsize (self, m1, m2);
820 oldskin = self.skinindex;
821 self.skinindex = stof(self.playerskin);
824 if(chmdl || oldskin != self.skinindex)
825 self.species = player_getspecies(); // model or skin has changed
828 if(strlen(autocvar_sv_defaultplayercolors))
829 if(self.clientcolors != stof(autocvar_sv_defaultplayercolors))
830 setcolor(self, stof(autocvar_sv_defaultplayercolors));
833 void PlayerTouchExplode(entity p1, entity p2)
836 org = (p1.origin + p2.origin) * 0.5;
837 org_z += (p1.mins_z + p2.mins_z) * 0.5;
844 RadiusDamage(e, world, g_touchexplode_damage, g_touchexplode_edgedamage, g_touchexplode_radius, world, g_touchexplode_force, DEATH_TOUCHEXPLODE, world);
852 Called when a client spawns in the server
855 //void() ctf_playerchanged;
856 void PutClientInServer (void)
858 if(clienttype(self) == CLIENTTYPE_BOT)
860 self.classname = "player";
862 else if(clienttype(self) == CLIENTTYPE_REAL)
865 WriteByte(MSG_ONE, SVC_SETVIEW);
866 WriteEntity(MSG_ONE, self);
872 // player is dead and becomes observer
873 // FIXME fix LMS scoring for new system
876 if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0)
877 self.classname = "observer";
880 if(g_arena || (g_ca && !allowed_to_spawn))
882 self.classname = "observer";
885 self.classname = "observer";
887 if(self.classname == "player" && (!g_ca || (g_ca && allowed_to_spawn))) {
888 entity spot, oldself;
891 accuracy_resend(self);
894 JoinBestTeam(self, FALSE, TRUE);
898 spot = SelectSpawnPoint (FALSE);
901 centerprint(self, "Sorry, no spawnpoints available!\nHope your team can fix it...");
902 return; // spawn failed
905 RemoveGrapplingHook(self); // Wazat's Grappling Hook
907 self.classname = "player";
908 self.wasplayer = TRUE;
909 self.iscreature = TRUE;
910 self.damagedbycontents = TRUE;
911 self.movetype = MOVETYPE_WALK;
912 self.solid = SOLID_SLIDEBOX;
913 self.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID;
914 if(autocvar_g_playerclip_collisions)
915 self.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP;
916 if(clienttype(self) == CLIENTTYPE_BOT && autocvar_g_botclip_collisions)
917 self.dphitcontentsmask |= DPCONTENTS_BOTCLIP;
918 self.frags = FRAGS_PLAYER;
919 if(INDEPENDENT_PLAYERS)
920 MAKE_INDEPENDENT_PLAYER(self);
921 self.flags = FL_CLIENT;
922 if(autocvar__notarget)
923 self.flags |= FL_NOTARGET;
924 self.takedamage = DAMAGE_AIM;
926 self.effects = EF_FULLBRIGHT;
929 self.air_finished = time + 12;
931 if(autocvar_g_balance_nex_charge)
933 if(autocvar_g_balance_nex_secondary_chargepool)
934 self.nex_chargepool_ammo = 1;
935 self.nex_charge = autocvar_g_balance_nex_charge_start;
940 self.ammo_shells = warmup_start_ammo_shells;
941 self.ammo_nails = warmup_start_ammo_nails;
942 self.ammo_rockets = warmup_start_ammo_rockets;
943 self.ammo_cells = warmup_start_ammo_cells;
944 self.ammo_fuel = warmup_start_ammo_fuel;
945 self.health = warmup_start_health;
946 self.armorvalue = warmup_start_armorvalue;
947 self.weapons = warmup_start_weapons;
951 self.ammo_shells = start_ammo_shells;
952 self.ammo_nails = start_ammo_nails;
953 self.ammo_rockets = start_ammo_rockets;
954 self.ammo_cells = start_ammo_cells;
955 self.ammo_fuel = start_ammo_fuel;
956 self.health = start_health;
957 self.armorvalue = start_armorvalue;
958 self.weapons = start_weapons;
961 if(g_weaponarena_random)
963 if(g_weaponarena_random_with_laser)
964 self.weapons &~= WEPBIT_LASER;
965 self.weapons = randombits(self.weapons, g_weaponarena_random, FALSE);
966 if(g_weaponarena_random_with_laser)
967 self.weapons |= WEPBIT_LASER;
970 self.items = start_items;
971 self.jump_interval = time;
973 self.spawnshieldtime = time + autocvar_g_spawnshieldtime;
974 self.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot_spawn;
975 self.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot_spawn;
976 self.pauserotfuel_finished = time + autocvar_g_balance_pause_fuel_rot_spawn;
977 self.pauseregen_finished = time + autocvar_g_balance_pause_health_regen_spawn;
978 //extend the pause of rotting if client was reset at the beginning of the countdown
979 if(!autocvar_sv_ready_restart_after_countdown && time < game_starttime) { // TODO why is this cvar NOTted?
980 self.spawnshieldtime += game_starttime - time;
981 self.pauserotarmor_finished += game_starttime - time;
982 self.pauserothealth_finished += game_starttime - time;
983 self.pauseregen_finished += game_starttime - time;
985 self.damageforcescale = 2;
992 self.pain_finished = 0;
993 self.strength_finished = 0;
994 self.invincible_finished = 0;
996 // players have no think function
997 self.think = SUB_Null;
1001 self.ballistics_density = autocvar_g_ballistics_density_player;
1007 self.deadflag = DEAD_NO;
1009 self.angles = spot.angles;
1011 self.angles_z = 0; // never spawn tilted even if the spot says to
1012 self.fixangle = TRUE; // turn this way immediately
1013 self.velocity = '0 0 0';
1014 self.avelocity = '0 0 0';
1015 self.punchangle = '0 0 0';
1016 self.punchvector = '0 0 0';
1017 self.oldvelocity = self.velocity;
1018 self.fire_endtime = -1;
1021 WRITESPECTATABLE_MSG_ONE({
1022 WriteByte(MSG_ONE, SVC_TEMPENTITY);
1023 WriteByte(MSG_ONE, TE_CSQC_SPAWN);
1027 SetCustomizer(self, Client_customizeentityforclient, Client_uncustomizeentityforclient);
1032 self.crouch = FALSE;
1033 self.view_ofs = PL_VIEW_OFS;
1034 setsize (self, PL_MIN, PL_MAX);
1035 self.spawnorigin = spot.origin;
1036 setorigin (self, spot.origin + '0 0 1' * (1 - self.mins_z - 24));
1037 // don't reset back to last position, even if new position is stuck in solid
1038 self.oldorigin = self.origin;
1039 self.prevorigin = self.origin;
1040 self.lastrocket = world; // stop rocket guiding, no revenge from the grave!
1041 self.lastteleporttime = time; // prevent insane speeds due to changing origin
1042 self.hud = HUD_NORMAL;
1046 Spawnqueue_Remove(self);
1047 Spawnqueue_Mark(self);
1053 self.event_damage = PlayerDamage;
1055 self.bot_attack = TRUE;
1057 self.statdraintime = time + 5;
1058 self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = 0;
1060 if(self.killcount == -666) {
1061 PlayerScore_Clear(self);
1065 CL_SpawnWeaponentity();
1066 self.alpha = default_player_alpha;
1067 self.colormod = '1 1 1' * autocvar_g_player_brightness;
1068 self.exteriorweaponentity.alpha = default_weapon_alpha;
1070 self.lms_nextcheck = time + autocvar_g_lms_campcheck_interval*2;
1071 self.lms_traveled_distance = 0;
1072 self.speedrunning = FALSE;
1074 race_PostSpawn(spot);
1076 if(autocvar_spawn_debug)
1078 sprint(self, strcat("spawnpoint origin: ", vtos(spot.origin), "\n"));
1079 remove(spot); // usefull for checking if there are spawnpoints, that let drop through the floor
1082 //stuffcmd(self, "chase_active 0");
1083 //stuffcmd(self, "set viewsize $tmpviewsize \n");
1085 if (autocvar_g_spawnsound)
1086 sound (self, CH_TRIGGER, "misc/spawn.wav", VOL_BASE, ATTN_NORM);
1089 if(self.team == assault_attacker_team)
1090 centerprint(self, "You are attacking!");
1092 centerprint(self, "You are defending!");
1095 target_voicescript_clear(self);
1097 // reset fields the weapons may use
1098 for (j = WEP_FIRST; j <= WEP_LAST; ++j)
1100 weapon_action(j, WR_RESETPLAYER);
1102 // all weapons must be fully loaded when we spawn
1104 e = get_weaponinfo(j);
1105 if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
1106 self.(weapon_load[j]) = cvar(strcat("g_balance_", e.netname, "_reload_ammo"));
1111 activator = oldself;
1114 self.target = string_null;
1120 MUTATOR_CALLHOOK(PlayerSpawn);
1122 self.switchweapon = w_getbestweapon(self);
1123 self.cnt = -1; // W_LastWeapon will not complain
1125 self.weaponname = "";
1126 self.switchingweapon = 0;
1129 self.alivetime = time;
1130 } else if(self.classname == "observer" || (g_ca && !allowed_to_spawn)) {
1131 PutObserverInServer ();
1135 // ctf_playerchanged();
1138 .float ebouncefactor, ebouncestop; // electro's values
1139 // TODO do we need all these fields, or should we stop autodetecting runtime
1140 // changes and just have a console command to update this?
1141 float ClientInit_SendEntity(entity to, float sf)
1143 WriteByte(MSG_ENTITY, ENT_CLIENT_INIT);
1144 WriteByte(MSG_ENTITY, g_nexball_meter_period * 32);
1145 WriteInt24_t(MSG_ENTITY, compressShotOrigin(hook_shotorigin[0]));
1146 WriteInt24_t(MSG_ENTITY, compressShotOrigin(hook_shotorigin[1]));
1147 WriteInt24_t(MSG_ENTITY, compressShotOrigin(hook_shotorigin[2]));
1148 WriteInt24_t(MSG_ENTITY, compressShotOrigin(hook_shotorigin[3]));
1149 WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[0]));
1150 WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[1]));
1151 WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[2]));
1152 WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[3]));
1153 WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[0]));
1154 WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[1]));
1155 WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[2]));
1156 WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[3]));
1157 if(sv_foginterval && world.fog != "")
1158 WriteString(MSG_ENTITY, world.fog);
1160 WriteString(MSG_ENTITY, "");
1161 WriteByte(MSG_ENTITY, self.count * 255.0); // g_balance_armor_blockpercent
1162 WriteByte(MSG_ENTITY, self.cnt * 255.0); // g_balance_weaponswitchdelay
1163 WriteCoord(MSG_ENTITY, self.bouncefactor); // g_balance_grenadelauncher_bouncefactor
1164 WriteCoord(MSG_ENTITY, self.bouncestop); // g_balance_grenadelauncher_bouncestop
1165 WriteCoord(MSG_ENTITY, self.ebouncefactor); // g_balance_grenadelauncher_bouncefactor
1166 WriteCoord(MSG_ENTITY, self.ebouncestop); // g_balance_grenadelauncher_bouncestop
1167 WriteByte(MSG_ENTITY, autocvar_g_balance_nex_secondary); // client has to know if it should zoom or not
1168 WriteByte(MSG_ENTITY, autocvar_g_balance_rifle_secondary); // client has to know if it should zoom or not
1169 WriteByte(MSG_ENTITY, serverflags); // client has to know if it should zoom or not
1170 WriteByte(MSG_ENTITY, autocvar_g_balance_minelayer_limit); // minelayer max mines
1171 WriteByte(MSG_ENTITY, autocvar_g_balance_hagar_secondary_load_max); // hagar max loadable rockets
1172 WriteCoord(MSG_ENTITY, autocvar_g_trueaim_minrange);
1176 void ClientInit_CheckUpdate()
1178 self.nextthink = time;
1179 if(self.count != autocvar_g_balance_armor_blockpercent)
1181 self.count = autocvar_g_balance_armor_blockpercent;
1182 self.SendFlags |= 1;
1184 if(self.cnt != autocvar_g_balance_weaponswitchdelay)
1186 self.cnt = autocvar_g_balance_weaponswitchdelay;
1187 self.SendFlags |= 1;
1189 if(self.bouncefactor != autocvar_g_balance_grenadelauncher_bouncefactor)
1191 self.bouncefactor = autocvar_g_balance_grenadelauncher_bouncefactor;
1192 self.SendFlags |= 1;
1194 if(self.bouncestop != autocvar_g_balance_grenadelauncher_bouncestop)
1196 self.bouncestop = autocvar_g_balance_grenadelauncher_bouncestop;
1197 self.SendFlags |= 1;
1199 if(self.ebouncefactor != autocvar_g_balance_electro_secondary_bouncefactor)
1201 self.ebouncefactor = autocvar_g_balance_electro_secondary_bouncefactor;
1202 self.SendFlags |= 1;
1204 if(self.ebouncestop != autocvar_g_balance_electro_secondary_bouncestop)
1206 self.ebouncestop = autocvar_g_balance_electro_secondary_bouncestop;
1207 self.SendFlags |= 1;
1211 void ClientInit_Spawn()
1216 e.classname = "clientinit";
1217 e.think = ClientInit_CheckUpdate;
1218 Net_LinkEntity(e, FALSE, 0, ClientInit_SendEntity);
1222 ClientInit_CheckUpdate();
1231 void SetNewParms (void)
1233 // initialize parms for a new player
1234 parm1 = -(86400 * 366);
1242 void SetChangeParms (void)
1244 // save parms for level change
1245 parm1 = self.parm_idlesince - time;
1253 void DecodeLevelParms (void)
1256 self.parm_idlesince = parm1;
1257 if(self.parm_idlesince == -(86400 * 366))
1258 self.parm_idlesince = time;
1260 // whatever happens, allow 60 seconds of idling directly after connect for map loading
1261 self.parm_idlesince = max(self.parm_idlesince, time - sv_maxidle + 60);
1268 Called when a client types 'kill' in the console
1272 .float clientkill_nexttime;
1273 void ClientKill_Now_TeamChange()
1275 if(self.killindicator_teamchange == -1)
1278 JoinBestTeam( self, FALSE, FALSE );
1280 else if(self.killindicator_teamchange == -2)
1285 sprint(self, strcat("^7You have to become a player within the next ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
1286 PutObserverInServer();
1289 SV_ChangeTeam(self.killindicator_teamchange - 1);
1292 void ClientKill_Now()
1296 vehicles_exit(VHEF_RELESE);
1297 if(!self.killindicator_teamchange)
1299 self.vehicle_health = -1;
1300 Damage(self, self, self, 1 , DEATH_KILL, self.origin, '0 0 0');
1304 if(self.killindicator && !wasfreed(self.killindicator))
1305 remove(self.killindicator);
1307 self.killindicator = world;
1309 if(self.killindicator_teamchange)
1310 ClientKill_Now_TeamChange();
1313 Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
1315 // now I am sure the player IS dead
1317 void KillIndicator_Think()
1321 self.owner.killindicator = world;
1326 if (!self.owner.modelindex)
1328 self.owner.killindicator = world;
1336 ClientKill_Now(); // no oldself needed
1339 else if(g_cts && self.health == 1) // health == 1 means that it's silent
1341 self.nextthink = time + 1;
1347 setmodel(self, strcat("models/sprites/", ftos(self.cnt), ".spr32"));
1348 if(clienttype(self.owner) == CLIENTTYPE_REAL)
1351 AnnounceTo(self.owner, strcat(ftos(self.cnt), ""));
1353 self.nextthink = time + 1;
1358 float clientkilltime;
1359 void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2 = spec
1368 killtime = autocvar_g_balance_kill_delay;
1370 if(g_race_qualifying || g_cts)
1373 if(g_cts && self.killindicator && self.killindicator.health == 1) // self.killindicator.health == 1 means that the kill indicator was spawned by CTS_ClientKill
1375 remove(self.killindicator);
1376 self.killindicator = world;
1378 ClientKill_Now(); // allow instant kill in this case
1382 self.killindicator_teamchange = targetteam;
1384 if(!self.killindicator)
1386 if(self.modelindex && self.deadflag == DEAD_NO)
1388 killtime = max(killtime, self.clientkill_nexttime - time);
1389 self.clientkill_nexttime = time + killtime + autocvar_g_balance_kill_antispam;
1392 if(killtime <= 0 || !self.modelindex || self.deadflag != DEAD_NO)
1398 starttime = max(time, clientkilltime);
1400 self.killindicator = spawn();
1401 self.killindicator.owner = self;
1402 self.killindicator.scale = 0.5;
1403 setattachment(self.killindicator, self, "");
1404 setorigin(self.killindicator, '0 0 52');
1405 self.killindicator.think = KillIndicator_Think;
1406 self.killindicator.nextthink = starttime + (self.lip) * 0.05;
1407 clientkilltime = max(clientkilltime, self.killindicator.nextthink + 0.05);
1408 self.killindicator.cnt = ceil(killtime);
1409 self.killindicator.count = bound(0, ceil(killtime), 10);
1410 //sprint(self, strcat("^1You'll be dead in ", ftos(self.killindicator.cnt), " seconds\n"));
1412 for(e = world; (e = find(e, classname, "body")) != world; )
1416 e.killindicator = spawn();
1417 e.killindicator.owner = e;
1418 e.killindicator.scale = 0.5;
1419 setattachment(e.killindicator, e, "");
1420 setorigin(e.killindicator, '0 0 52');
1421 e.killindicator.think = KillIndicator_Think;
1422 e.killindicator.nextthink = starttime + (e.lip) * 0.05;
1423 clientkilltime = max(clientkilltime, e.killindicator.nextthink + 0.05);
1424 e.killindicator.cnt = ceil(killtime);
1429 if(self.killindicator)
1431 if(targetteam == 0) // just die
1433 self.killindicator.colormod = '0 0 0';
1434 if(clienttype(self) == CLIENTTYPE_REAL)
1435 if(self.killindicator.cnt > 0)
1436 Send_CSQC_Centerprint_Generic(self, CPID_TEAMCHANGE, "^1Suicide in %d seconds", 1, self.killindicator.cnt);
1438 else if(targetteam == -1) // auto
1440 self.killindicator.colormod = '0 1 0';
1441 if(clienttype(self) == CLIENTTYPE_REAL)
1442 if(self.killindicator.cnt > 0)
1443 Send_CSQC_Centerprint_Generic(self, CPID_TEAMCHANGE, "Changing team in %d seconds", 1, self.killindicator.cnt);
1445 else if(targetteam == -2) // spectate
1447 self.killindicator.colormod = '0.5 0.5 0.5';
1448 if(clienttype(self) == CLIENTTYPE_REAL)
1449 if(self.killindicator.cnt > 0)
1450 Send_CSQC_Centerprint_Generic(self, CPID_TEAMCHANGE, "Spectating in %d seconds", 1, self.killindicator.cnt);
1454 self.killindicator.colormod = TeamColor(targetteam);
1455 if(clienttype(self) == CLIENTTYPE_REAL)
1456 if(self.killindicator.cnt > 0)
1457 Send_CSQC_Centerprint_Generic(self, CPID_TEAMCHANGE, strcat("Changing to ", ColoredTeamName(targetteam), " in %d seconds"), 1, self.killindicator.cnt);
1463 void ClientKill (void)
1468 if((g_arena || g_ca) && ((champion && champion.classname == "player" && player_count > 1) || player_count == 1)) // don't allow a kill in this case either
1472 else if(self.freezetag_frozen)
1477 ClientKill_TeamChange(0);
1480 void CTS_ClientKill (entity e) // silent version of ClientKill, used when player finishes a CTS run. Useful to prevent cheating by running back to the start line and starting out with more speed
1482 e.killindicator = spawn();
1483 e.killindicator.owner = e;
1484 e.killindicator.think = KillIndicator_Think;
1485 e.killindicator.nextthink = time + (e.lip) * 0.05;
1486 e.killindicator.cnt = ceil(autocvar_g_cts_finish_kill_delay);
1487 e.killindicator.health = 1; // this is used to indicate that it should be silent
1491 void FixClientCvars(entity e)
1493 // send prediction settings to the client
1494 stuffcmd(e, "\nin_bindmap 0 0\n");
1496 stuffcmd(e, "cl_cmd settemp cl_movecliptokeyboard 2\n");
1497 if(autocvar_g_antilag == 3) // client side hitscan
1498 stuffcmd(e, "cl_cmd settemp cl_prydoncursor_notrace 0\n");
1500 stuffcmd(e, "cl_cmd settemp cl_gentle 1\n");
1502 * we no longer need to stuff this. Remove this comment block if you feel
1503 * 2.3 and higher (or was it 2.2.3?) don't need these any more
1504 stuffcmd(e, strcat("cl_gravity ", ftos(autocvar_sv_gravity), "\n"));
1505 stuffcmd(e, strcat("cl_movement_accelerate ", ftos(autocvar_sv_accelerate), "\n"));
1506 stuffcmd(e, strcat("cl_movement_friction ", ftos(autocvar_sv_friction), "\n"));
1507 stuffcmd(e, strcat("cl_movement_maxspeed ", ftos(autocvar_sv_maxspeed), "\n"));
1508 stuffcmd(e, strcat("cl_movement_airaccelerate ", ftos(autocvar_sv_airaccelerate), "\n"));
1509 stuffcmd(e, strcat("cl_movement_maxairspeed ", ftos(autocvar_sv_maxairspeed), "\n"));
1510 stuffcmd(e, strcat("cl_movement_stopspeed ", ftos(autocvar_sv_stopspeed), "\n"));
1511 stuffcmd(e, strcat("cl_movement_jumpvelocity ", ftos(autocvar_sv_jumpvelocity), "\n"));
1512 stuffcmd(e, strcat("cl_movement_stepheight ", ftos(autocvar_sv_stepheight), "\n"));
1513 stuffcmd(e, strcat("set cl_movement_friction_on_land ", ftos(autocvar_sv_friction_on_land), "\n"));
1514 stuffcmd(e, strcat("set cl_movement_airaccel_qw ", ftos(autocvar_sv_airaccel_qw), "\n"));
1515 stuffcmd(e, strcat("set cl_movement_airaccel_sideways_friction ", ftos(autocvar_sv_airaccel_sideways_friction), "\n"));
1516 stuffcmd(e, "cl_movement_edgefriction 1\n");
1520 float PlayerInIDList(entity p, string idlist)
1525 // NOTE: we do NOT check crypto_keyfp here, an unsigned ID is fine too for this
1526 if not(p.crypto_idfp)
1529 // this function allows abbreviated player IDs too!
1530 n = tokenize_console(idlist);
1531 for(i = 0; i < n; ++i)
1534 if(s == substring(p.crypto_idfp, 0, strlen(s)))
1545 Called when a client connects to the server
1548 //void ctf_clientconnect();
1549 string ColoredTeamName(float t);
1550 void DecodeLevelParms (void);
1551 //void dom_player_join_team(entity pl);
1552 void set_dom_state(entity e);
1553 void ClientConnect (void)
1557 if(self.flags & FL_CLIENT)
1559 print("Warning: ClientConnect, but already connected!\n");
1563 if(Ban_MaybeEnforceBan(self))
1569 sprint(self, strcat("^4SVQC Build information: ^1", WATERMARK(), "\n"));
1572 self.classname = "player_joining";
1574 self.flags = FL_CLIENT;
1575 self.version_nagtime = time + 10 + random() * 10;
1579 dprint("BUG player count is lower than zero, this cannot happen!\n");
1583 PlayerScore_Attach(self);
1584 ClientData_Attach();
1585 accuracy_init(self);
1587 bot_clientconnect();
1593 race_PreSpawnObserver();
1596 // dom_player_join_team(self);
1598 // identify the right forced team
1599 if(autocvar_g_campaign)
1601 if(clienttype(self) == CLIENTTYPE_REAL) // only players, not bots
1603 switch(autocvar_g_campaign_forceteam)
1605 case 1: self.team_forced = COLOR_TEAM1; break;
1606 case 2: self.team_forced = COLOR_TEAM2; break;
1607 case 3: self.team_forced = COLOR_TEAM3; break;
1608 case 4: self.team_forced = COLOR_TEAM4; break;
1609 default: self.team_forced = 0;
1613 else if(PlayerInIDList(self, autocvar_g_forced_team_red))
1614 self.team_forced = COLOR_TEAM1;
1615 else if(PlayerInIDList(self, autocvar_g_forced_team_blue))
1616 self.team_forced = COLOR_TEAM2;
1617 else if(PlayerInIDList(self, autocvar_g_forced_team_yellow))
1618 self.team_forced = COLOR_TEAM3;
1619 else if(PlayerInIDList(self, autocvar_g_forced_team_pink))
1620 self.team_forced = COLOR_TEAM4;
1621 else if(autocvar_g_forced_team_otherwise == "red")
1622 self.team_forced = COLOR_TEAM1;
1623 else if(autocvar_g_forced_team_otherwise == "blue")
1624 self.team_forced = COLOR_TEAM2;
1625 else if(autocvar_g_forced_team_otherwise == "yellow")
1626 self.team_forced = COLOR_TEAM3;
1627 else if(autocvar_g_forced_team_otherwise == "pink")
1628 self.team_forced = COLOR_TEAM4;
1629 else if(autocvar_g_forced_team_otherwise == "spectate")
1630 self.team_forced = -1;
1631 else if(autocvar_g_forced_team_otherwise == "spectator")
1632 self.team_forced = -1;
1634 self.team_forced = 0;
1637 if(self.team_forced > 0)
1638 self.team_forced = 0;
1640 JoinBestTeam(self, FALSE, FALSE); // if the team number is valid, keep it
1642 if((autocvar_sv_spectate == 1 && !g_lms) || autocvar_g_campaign || self.team_forced < 0) {
1643 self.classname = "observer";
1647 if(autocvar_g_balance_teams || autocvar_g_balance_teams_force)
1649 self.classname = "player";
1650 campaign_bots_may_start = 1;
1654 self.classname = "observer"; // do it anyway
1659 self.classname = "player";
1660 campaign_bots_may_start = 1;
1664 self.playerid = (playerid_last = playerid_last + 1);
1666 PlayerStats_AddEvent(sprintf("kills-%d", self.playerid));
1668 if(clienttype(self) == CLIENTTYPE_BOT)
1669 PlayerStats_AddPlayer(self);
1671 if(autocvar_sv_eventlog)
1672 GameLogEcho(strcat(":join:", ftos(self.playerid), ":", ftos(num_for_edict(self)), ":", ((clienttype(self) == CLIENTTYPE_REAL) ? self.netaddress : "bot"), ":", self.netname));
1674 LogTeamchange(self.playerid, self.team, 1);
1676 self.just_joined = TRUE; // stop spamming the eventlog with additional lines when the client connects
1678 self.netname_previous = strzone(self.netname);
1680 bprint("^4", self.netname, "^4 connected");
1682 if(self.classname != "observer" && (g_domination || g_ctf))
1683 bprint(" and joined the ", ColoredTeamName(self.team));
1687 stuffcmd(self, strcat(clientstuff, "\n"));
1688 stuffcmd(self, "cl_particles_reloadeffects\n"); // TODO do we still need this?
1690 FixClientCvars(self);
1692 // spawnfunc_waypoint sprites
1693 WaypointSprite_InitClient(self);
1695 // Wazat's grappling hook
1696 SetGrappleHookBindings();
1698 // get version info from player
1699 stuffcmd(self, "cmd clientversion $gameversion\n");
1701 // get other cvars from player
1704 // notify about available teams
1707 CheckAllowedTeams(self);
1708 t = 0; if(c1 >= 0) t |= 1; if(c2 >= 0) t |= 2; if(c3 >= 0) t |= 4; if(c4 >= 0) t |= 8;
1709 stuffcmd(self, strcat("set _teams_available ", ftos(t), "\n"));
1712 stuffcmd(self, "set _teams_available 0\n");
1714 stuffcmd(self, strcat("set gametype ", ftos(game), "\n"));
1718 self.classname = "observer";
1720 Spawnqueue_Insert(self);
1724 ctf_clientconnect();
1729 bot_relinkplayerlist();
1731 self.spectatortime = time;
1734 sprint(self, strcat("^7You have to become a player within the next ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
1737 self.jointime = time;
1738 self.allowedTimeouts = autocvar_sv_timeout_number;
1740 if(clienttype(self) == CLIENTTYPE_REAL)
1742 if(autocvar_g_bugrigs || g_weaponarena == WEPBIT_TUBA)
1743 stuffcmd(self, "cl_cmd settemp chase_active 1\n");
1748 if(PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives()) <= 0)
1750 PlayerScore_Add(self, SP_LMS_RANK, 666);
1751 self.frags = FRAGS_SPECTATOR;
1755 if(!sv_foginterval && world.fog != "")
1756 stuffcmd(self, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n"));
1758 SoundEntity_Attach(self);
1760 if(autocvar_g_hitplots || strstrofs(strcat(" ", autocvar_g_hitplots_individuals, " "), strcat(" ", self.netaddress, " "), 0) >= 0)
1762 self.hitplotfh = fopen(strcat("hits-", matchid, "-", self.netaddress, "-", ftos(self.playerid), ".plot"), FILE_WRITE);
1763 fputs(self.hitplotfh, strcat("#name ", self.netname, "\n"));
1766 self.hitplotfh = -1;
1768 if(g_race || g_cts) {
1774 t = stof(db_get(ServerProgsDB, strcat(GetMapname(), rr, "time")));
1777 race_send_recordtime(MSG_ONE);
1778 race_send_speedaward(MSG_ONE);
1780 speedaward_alltimebest = stof(db_get(ServerProgsDB, strcat(GetMapname(), rr, "speed/speed")));
1781 speedaward_alltimebest_holder = uid2name(db_get(ServerProgsDB, strcat(GetMapname(), rr, "speed/crypto_idfp")));
1782 race_send_speedaward_alltimebest(MSG_ONE);
1785 for (i = 1; i <= RANKINGS_CNT; ++i) {
1786 race_SendRankings(i, 0, 0, MSG_ONE);
1789 else if(autocvar_sv_teamnagger && !(autocvar_bot_vs_human && (c3==-1 && c4==-1)) && !g_ca) // teamnagger is currently bad for ca
1790 send_CSQC_teamnagger();
1793 set_dom_state(self);
1797 if(!autocvar_g_campaign)
1798 Send_CSQC_Centerprint_Generic(self, CPID_MOTD, getwelcomemessage(), autocvar_welcome_message_time, 0);
1805 Called when a client disconnects from the server
1808 .entity chatbubbleentity;
1810 void ClientDisconnect (void)
1813 vehicles_exit(VHEF_RELESE);
1815 if not(self.flags & FL_CLIENT)
1817 print("Warning: ClientDisconnect without ClientConnect\n");
1821 PlayerStats_AddGlobalInfo(self);
1823 CheatShutdownClient();
1825 if(self.hitplotfh >= 0)
1827 fclose(self.hitplotfh);
1828 self.hitplotfh = -1;
1832 anticheat_shutdown();
1834 playerdemo_shutdown();
1836 bot_clientdisconnect();
1841 if(autocvar_sv_eventlog)
1842 GameLogEcho(strcat(":part:", ftos(self.playerid)));
1843 bprint ("^4",self.netname);
1844 bprint ("^4 disconnected\n");
1846 SoundEntity_Detach(self);
1849 MUTATOR_CALLHOOK(ClientDisconnect);
1851 Portal_ClearAll(self);
1853 RemoveGrapplingHook(self);
1854 if(self.flagcarried)
1855 DropFlag(self.flagcarried, world, world);
1856 if(self.ballcarried && g_nexball)
1857 DropBall(self.ballcarried, self.origin + self.ballcarried.origin, self.velocity);
1859 // Here, everything has been done that requires this player to be a client.
1861 self.flags &~= FL_CLIENT;
1863 if (self.chatbubbleentity)
1864 remove (self.chatbubbleentity);
1866 if (self.killindicator)
1867 remove (self.killindicator);
1869 WaypointSprite_PlayerGone();
1871 bot_relinkplayerlist();
1875 Spawnqueue_Unmark(self);
1876 Spawnqueue_Remove(self);
1879 accuracy_free(self);
1880 ClientData_Detach();
1881 PlayerScore_Detach(self);
1883 if(self.netname_previous)
1884 strunzone(self.netname_previous);
1885 if(self.clientstatus)
1886 strunzone(self.clientstatus);
1887 if(self.weaponorder_byimpulse)
1888 strunzone(self.weaponorder_byimpulse);
1890 ClearPlayerSounds();
1893 remove(self.personal);
1903 void ChatBubbleThink()
1905 self.nextthink = time;
1906 if (!self.owner.modelindex || self.owner.chatbubbleentity != self)
1908 if(self.owner) // but why can that ever be world?
1909 self.owner.chatbubbleentity = world;
1913 if ((self.owner.BUTTON_CHAT && !self.owner.deadflag)
1915 || self.owner.tetris_on
1918 self.model = self.mdl;
1923 void UpdateChatBubble()
1925 if (!self.modelindex)
1927 // spawn a chatbubble entity if needed
1928 if (!self.chatbubbleentity)
1930 self.chatbubbleentity = spawn();
1931 self.chatbubbleentity.owner = self;
1932 self.chatbubbleentity.exteriormodeltoclient = self;
1933 self.chatbubbleentity.think = ChatBubbleThink;
1934 self.chatbubbleentity.nextthink = time;
1935 setmodel(self.chatbubbleentity, "models/misc/chatbubble.spr"); // precision set below
1936 //setorigin(self.chatbubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
1937 setorigin(self.chatbubbleentity, '0 0 15' + self.maxs_z * '0 0 1');
1938 setattachment(self.chatbubbleentity, self, ""); // sticks to moving player better, also conserves bandwidth
1939 self.chatbubbleentity.mdl = self.chatbubbleentity.model;
1940 self.chatbubbleentity.model = "";
1941 self.chatbubbleentity.effects = EF_LOWPRECISION;
1946 // LordHavoc: this hack will be removed when proper _pants/_shirt layers are
1947 // added to the model skins
1948 /*void UpdateColorModHack()
1951 c = self.clientcolors & 15;
1952 // LordHavoc: only bothering to support white, green, red, yellow, blue
1953 if (!teamplay) self.colormod = '0 0 0';
1954 else if (c == 0) self.colormod = '1.00 1.00 1.00';
1955 else if (c == 3) self.colormod = '0.10 1.73 0.10';
1956 else if (c == 4) self.colormod = '1.73 0.10 0.10';
1957 else if (c == 12) self.colormod = '1.22 1.22 0.10';
1958 else if (c == 13) self.colormod = '0.10 0.10 1.73';
1959 else self.colormod = '1 1 1';
1965 if(self.modelindex != 0 && autocvar_g_respawn_ghosts)
1967 self.solid = SOLID_NOT;
1968 self.takedamage = DAMAGE_NO;
1969 self.movetype = MOVETYPE_FLY;
1970 self.velocity = '0 0 1' * autocvar_g_respawn_ghosts_speed;
1971 self.avelocity = randomvec() * autocvar_g_respawn_ghosts_speed * 3 - randomvec() * autocvar_g_respawn_ghosts_speed * 3;
1972 self.effects |= EF_ADDITIVE;
1973 self.oldcolormap = self.colormap;
1974 self.colormap = 0; // this originally was 512, but raises a warning in the engine, so get rid of it
1975 pointparticles(particleeffectnum("respawn_ghost"), self.origin, '0 0 0', 1);
1976 if(autocvar_g_respawn_ghosts_maxtime)
1977 SUB_SetFade (self, time + autocvar_g_respawn_ghosts_maxtime / 2 + random () * (autocvar_g_respawn_ghosts_maxtime - autocvar_g_respawn_ghosts_maxtime / 2), 1.5);
1981 self.effects |= EF_NODRAW; // prevent another CopyBody
1982 if(self.oldcolormap)
1984 self.colormap = self.oldcolormap;
1985 self.oldcolormap = 0;
1987 PutClientInServer();
1990 void play_countdown(float finished, string samp)
1992 if(clienttype(self) == CLIENTTYPE_REAL)
1993 if(floor(finished - time - frametime) != floor(finished - time))
1994 if(finished - time < 6)
1995 sound (self, CH_INFO, samp, VOL_BASE, ATTN_NORM);
1998 void player_powerups (void)
2000 // add a way to see what the items were BEFORE all of these checks for the mutator hook
2001 olditems = self.items;
2003 if((self.items & IT_USING_JETPACK) && !self.deadflag)
2005 SoundEntity_StartSound(self, CH_TRIGGER_SINGLE, "misc/jetpack_fly.wav", VOL_BASE, autocvar_g_jetpack_attenuation);
2006 self.modelflags |= MF_ROCKET;
2010 SoundEntity_StopSound(self, CH_TRIGGER_SINGLE);
2011 self.modelflags &~= MF_ROCKET;
2014 self.effects &~= (EF_DIMLIGHT | EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT | EF_FLAME | EF_NODEPTHTEST);
2016 if(!self.modelindex || self.deadflag) // don't apply the flags if the player is gibbed
2019 Fire_ApplyDamage(self);
2020 Fire_ApplyEffect(self);
2024 self.effects |= EF_FULLBRIGHT;
2026 if (self.items & IT_STRENGTH)
2028 play_countdown(self.strength_finished, "misc/poweroff.wav");
2029 if (time > self.strength_finished)
2031 self.alpha = default_player_alpha;
2032 self.exteriorweaponentity.alpha = default_weapon_alpha;
2033 self.items &~= IT_STRENGTH;
2034 sprint(self, "^3Invisibility has worn off\n");
2039 if (time < self.strength_finished)
2041 self.alpha = g_minstagib_invis_alpha;
2042 self.exteriorweaponentity.alpha = g_minstagib_invis_alpha;
2043 self.items |= IT_STRENGTH;
2044 sprint(self, "^3You are invisible\n");
2048 if (self.items & IT_INVINCIBLE)
2050 play_countdown(self.invincible_finished, "misc/poweroff.wav");
2051 if (time > self.invincible_finished && autocvar_g_balance_powerup_timer)
2053 self.items = self.items - (self.items & IT_INVINCIBLE);
2054 sprint(self, "^3Speed has worn off\n");
2059 if (time < self.invincible_finished)
2061 self.items = self.items | IT_INVINCIBLE;
2062 sprint(self, "^3You are on speed\n");
2066 else // if we're not in minstagib, continue. I added this else to replace the "return" which was here that broke the callhook for this function -- This code is nasty.
2068 if (self.items & IT_STRENGTH)
2070 play_countdown(self.strength_finished, "misc/poweroff.wav");
2071 self.effects = self.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
2072 if (time > self.strength_finished && autocvar_g_balance_powerup_timer)
2074 self.items = self.items - (self.items & IT_STRENGTH);
2075 sprint(self, "^3Strength has worn off\n");
2080 if (time < self.strength_finished)
2082 self.items = self.items | IT_STRENGTH;
2083 sprint(self, "^3Strength infuses your weapons with devastating power\n");
2086 if (self.items & IT_INVINCIBLE)
2088 play_countdown(self.invincible_finished, "misc/poweroff.wav");
2089 self.effects = self.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
2090 if (time > self.invincible_finished && autocvar_g_balance_powerup_timer)
2092 self.items = self.items - (self.items & IT_INVINCIBLE);
2093 sprint(self, "^3Shield has worn off\n");
2098 if (time < self.invincible_finished)
2100 self.items = self.items | IT_INVINCIBLE;
2101 sprint(self, "^3Shield surrounds you\n");
2105 if(autocvar_g_nodepthtestplayers)
2106 self.effects = self.effects | EF_NODEPTHTEST;
2108 if(autocvar_g_fullbrightplayers)
2109 self.effects = self.effects | EF_FULLBRIGHT;
2111 // midair gamemode: damage only while in the air
2112 // if in midair mode, being on ground grants temporary invulnerability
2113 // (this is so that multishot weapon don't clear the ground flag on the
2114 // first damage in the frame, leaving the player vulnerable to the
2115 // remaining hits in the same frame)
2116 if (self.flags & FL_ONGROUND)
2118 self.spawnshieldtime = max(self.spawnshieldtime, time + autocvar_g_midair_shieldtime);
2120 if (time >= game_starttime)
2121 if (time < self.spawnshieldtime)
2122 self.effects = self.effects | (EF_ADDITIVE | EF_FULLBRIGHT);
2125 MUTATOR_CALLHOOK(PlayerPowerups);
2128 float CalcRegen(float current, float stable, float regenfactor, float regenframetime)
2130 if(current > stable)
2132 else if(current > stable - 0.25) // when close enough, "snap"
2135 return min(stable, current + (stable - current) * regenfactor * regenframetime);
2138 float CalcRot(float current, float stable, float rotfactor, float rotframetime)
2140 if(current < stable)
2142 else if(current < stable + 0.25) // when close enough, "snap"
2145 return max(stable, current + (stable - current) * rotfactor * rotframetime);
2148 float CalcRotRegen(float current, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime, float limit)
2150 if(current > rotstable)
2152 if(rotframetime > 0)
2154 current = CalcRot(current, rotstable, rotfactor, rotframetime);
2155 current = max(rotstable, current - rotlinear * rotframetime);
2158 else if(current < regenstable)
2160 if(regenframetime > 0)
2162 current = CalcRegen(current, regenstable, regenfactor, regenframetime);
2163 current = min(regenstable, current + regenlinear * regenframetime);
2173 void player_regen (void)
2175 float minh, mina, minf, maxh, maxa, maxf, limith, limita, limitf, max_mod, regen_mod, rot_mod, limit_mod;
2176 maxh = autocvar_g_balance_health_rotstable;
2177 maxa = autocvar_g_balance_armor_rotstable;
2178 maxf = autocvar_g_balance_fuel_rotstable;
2179 minh = autocvar_g_balance_health_regenstable;
2180 mina = autocvar_g_balance_armor_regenstable;
2181 minf = autocvar_g_balance_fuel_regenstable;
2182 limith = autocvar_g_balance_health_limit;
2183 limita = autocvar_g_balance_armor_limit;
2184 limitf = autocvar_g_balance_fuel_limit;
2186 max_mod = regen_mod = rot_mod = limit_mod = 1;
2188 if (self.runes & RUNE_REGEN)
2190 if (self.runes & CURSE_VENOM) // do we have both rune/curse?
2192 regen_mod = autocvar_g_balance_rune_regen_combo_regenrate;
2193 max_mod = autocvar_g_balance_rune_regen_combo_hpmod;
2194 limit_mod = autocvar_g_balance_rune_regen_combo_limitmod;
2198 regen_mod = autocvar_g_balance_rune_regen_regenrate;
2199 max_mod = autocvar_g_balance_rune_regen_hpmod;
2200 limit_mod = autocvar_g_balance_rune_regen_limitmod;
2203 else if (self.runes & CURSE_VENOM)
2205 max_mod = autocvar_g_balance_curse_venom_hpmod;
2206 if (self.runes & RUNE_REGEN) // do we have both rune/curse?
2207 rot_mod = autocvar_g_balance_rune_regen_combo_rotrate;
2209 rot_mod = autocvar_g_balance_curse_venom_rotrate;
2210 limit_mod = autocvar_g_balance_curse_venom_limitmod;
2211 //if (!self.runes & RUNE_REGEN)
2212 // rot_mod = autocvar_g_balance_curse_venom_rotrate;
2214 maxh = maxh * max_mod;
2215 //maxa = maxa * max_mod;
2216 //maxf = maxf * max_mod;
2217 minh = minh * max_mod;
2218 //mina = mina * max_mod;
2219 //minf = minf * max_mod;
2220 limith = limith * limit_mod;
2221 limita = limita * limit_mod;
2222 //limitf = limitf * limit_mod;
2227 if (!g_minstagib && !g_ca && (!g_lms || autocvar_g_lms_regenerate))
2229 self.armorvalue = CalcRotRegen(self.armorvalue, mina, autocvar_g_balance_armor_regen, autocvar_g_balance_armor_regenlinear, regen_mod * frametime * (time > self.pauseregen_finished), maxa, autocvar_g_balance_armor_rot, autocvar_g_balance_armor_rotlinear, rot_mod * frametime * (time > self.pauserotarmor_finished), limita);
2230 self.health = CalcRotRegen(self.health, minh, autocvar_g_balance_health_regen, autocvar_g_balance_health_regenlinear, regen_mod * frametime * (time > self.pauseregen_finished), maxh, autocvar_g_balance_health_rot, autocvar_g_balance_health_rotlinear, rot_mod * frametime * (time > self.pauserothealth_finished), limith);
2232 // if player rotted to death... die!
2234 self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
2237 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
2238 self.ammo_fuel = CalcRotRegen(self.ammo_fuel, minf, autocvar_g_balance_fuel_regen, autocvar_g_balance_fuel_regenlinear, regen_mod * frametime * (time > self.pauseregen_finished) * (self.items & IT_FUEL_REGEN != 0), maxf, autocvar_g_balance_fuel_rot, autocvar_g_balance_fuel_rotlinear, rot_mod * frametime * (time > self.pauserotfuel_finished), limitf);
2241 float zoomstate_set;
2242 void SetZoomState(float z)
2244 if(z != self.zoomstate)
2247 ClientData_Touch(self);
2252 void GetPressedKeys(void) {
2253 MUTATOR_CALLHOOK(GetPressedKeys);
2254 if (self.movement_x > 0) // get if movement keys are pressed
2255 { // forward key pressed
2256 self.pressedkeys |= KEY_FORWARD;
2257 self.pressedkeys &~= KEY_BACKWARD;
2259 else if (self.movement_x < 0)
2260 { // backward key pressed
2261 self.pressedkeys |= KEY_BACKWARD;
2262 self.pressedkeys &~= KEY_FORWARD;
2266 self.pressedkeys &~= KEY_FORWARD;
2267 self.pressedkeys &~= KEY_BACKWARD;
2270 if (self.movement_y > 0)
2271 { // right key pressed
2272 self.pressedkeys |= KEY_RIGHT;
2273 self.pressedkeys &~= KEY_LEFT;
2275 else if (self.movement_y < 0)
2276 { // left key pressed
2277 self.pressedkeys |= KEY_LEFT;
2278 self.pressedkeys &~= KEY_RIGHT;
2282 self.pressedkeys &~= KEY_RIGHT;
2283 self.pressedkeys &~= KEY_LEFT;
2286 if (self.BUTTON_JUMP) // get if jump and crouch keys are pressed
2287 self.pressedkeys |= KEY_JUMP;
2289 self.pressedkeys &~= KEY_JUMP;
2290 if (self.BUTTON_CROUCH)
2291 self.pressedkeys |= KEY_CROUCH;
2293 self.pressedkeys &~= KEY_CROUCH;
2297 ======================
2298 spectate mode routines
2299 ======================
2302 void SpectateCopy(entity spectatee) {
2304 MUTATOR_CALLHOOK(SpectateCopy);
2305 self.armortype = spectatee.armortype;
2306 self.armorvalue = spectatee.armorvalue;
2307 self.ammo_cells = spectatee.ammo_cells;
2308 self.ammo_shells = spectatee.ammo_shells;
2309 self.ammo_nails = spectatee.ammo_nails;
2310 self.ammo_rockets = spectatee.ammo_rockets;
2311 self.ammo_fuel = spectatee.ammo_fuel;
2312 self.clip_load = spectatee.clip_load;
2313 self.clip_size = spectatee.clip_size;
2314 self.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
2315 self.health = spectatee.health;
2317 self.items = spectatee.items;
2318 self.last_pickup = spectatee.last_pickup;
2319 self.hit_time = spectatee.hit_time;
2320 self.metertime = spectatee.metertime;
2321 self.strength_finished = spectatee.strength_finished;
2322 self.invincible_finished = spectatee.invincible_finished;
2323 self.pressedkeys = spectatee.pressedkeys;
2324 self.weapons = spectatee.weapons;
2325 self.switchweapon = spectatee.switchweapon;
2326 self.switchingweapon = spectatee.switchingweapon;
2327 self.weapon = spectatee.weapon;
2328 self.nex_charge = spectatee.nex_charge;
2329 self.nex_chargepool_ammo = spectatee.nex_chargepool_ammo;
2330 self.hagar_load = spectatee.hagar_load;
2331 self.minelayer_mines = spectatee.minelayer_mines;
2332 self.punchangle = spectatee.punchangle;
2333 self.view_ofs = spectatee.view_ofs;
2334 self.v_angle = spectatee.v_angle;
2335 self.velocity = spectatee.velocity;
2336 self.dmg_take = spectatee.dmg_take;
2337 self.dmg_save = spectatee.dmg_save;
2338 self.dmg_inflictor = spectatee.dmg_inflictor;
2339 self.angles = spectatee.v_angle;
2340 if(!self.BUTTON_USE)
2341 self.fixangle = TRUE;
2342 setorigin(self, spectatee.origin);
2343 setsize(self, spectatee.mins, spectatee.maxs);
2344 SetZoomState(spectatee.zoomstate);
2346 anticheat_spectatecopy(spectatee);
2348 //self.vehicle = spectatee.vehicle;
2350 self.hud = spectatee.hud;
2351 if(spectatee.vehicle)
2353 setorigin(self, spectatee.origin);
2354 self.velocity = spectatee.vehicle.velocity;
2355 self.v_angle += spectatee.vehicle.angles;
2356 //self.v_angle_x *= -1;
2357 self.vehicle_health = spectatee.vehicle_health;
2358 self.vehicle_shield = spectatee.vehicle_shield;
2359 self.vehicle_energy = spectatee.vehicle_energy;
2360 self.vehicle_ammo1 = spectatee.vehicle_ammo1;
2361 self.vehicle_ammo2 = spectatee.vehicle_ammo2;
2362 self.vehicle_reload1 = spectatee.vehicle_reload1;
2363 self.vehicle_reload2 = spectatee.vehicle_reload2;
2366 WriteByte (MSG_ONE, SVC_SETVIEWPORT);
2367 WriteEntity(MSG_ONE, spectatee);
2368 //self.tur_head = spectatee.vehicle.vehicle_viewport;
2372 float SpectateUpdate() {
2376 if (self == self.enemy)
2379 if(self.enemy.classname != "player")
2382 SpectateCopy(self.enemy);
2388 // Returns next available player to spectate if g_ca_spectate_enemies == 0
2389 entity CA_SpectateNext(entity start) {
2390 if (start.team == self.team) {
2395 // continue from current player
2396 while(other && other.team != self.team) {
2397 other = find(other, classname, "player");
2401 // restart from begining
2402 other = find(other, classname, "player");
2403 while(other && other.team != self.team) {
2404 other = find(other, classname, "player");
2411 float SpectateNext() {
2412 other = find(self.enemy, classname, "player");
2413 if (g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer) {
2414 // CA and ca players when spectating enemies is forbidden
2415 other = CA_SpectateNext(other);
2417 // other modes and ca spectators or spectating enemies is allowed
2419 other = find(other, classname, "player");
2425 if(self.enemy.classname == "player") {
2426 if(self.enemy.vehicle)
2429 WriteByte(MSG_ONE, SVC_SETVIEWPORT);
2430 WriteEntity(MSG_ONE, self.enemy);
2431 //stuffcmd(self, "set viewsize $tmpviewsize \n");
2432 self.movetype = MOVETYPE_NONE;
2433 accuracy_resend(self);
2438 WriteByte(MSG_ONE, SVC_SETVIEW);
2439 WriteEntity(MSG_ONE, self.enemy);
2440 //stuffcmd(self, "set viewsize $tmpviewsize \n");
2441 self.movetype = MOVETYPE_NONE;
2442 accuracy_resend(self);
2444 if(!SpectateUpdate())
2445 PutObserverInServer();
2455 ShowRespawnCountdown()
2457 Update a respawn countdown display.
2460 void ShowRespawnCountdown()
2463 if(self.deadflag == DEAD_NO) // just respawned?
2467 number = ceil(self.death_time - time);
2470 if(number <= self.respawn_countdown)
2472 self.respawn_countdown = number - 1;
2473 if(ceil(self.death_time - (time + 0.5)) == number) // only say it if it is the same number even in 0.5s; to prevent overlapping sounds
2474 AnnounceTo(self, strcat(ftos(number), ""));
2479 .float prevent_join_msgtime;
2480 void LeaveSpectatorMode()
2482 if(nJoinAllowed(1)) {
2483 if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || (self.wasplayer && autocvar_g_changeteam_banned) || self.team_forced > 0) {
2484 self.classname = "player";
2486 if(autocvar_g_campaign || autocvar_g_balance_teams || autocvar_g_balance_teams_force)
2487 JoinBestTeam(self, FALSE, TRUE);
2489 if(autocvar_g_campaign)
2490 campaign_bots_may_start = 1;
2492 PutClientInServer();
2494 if(self.classname == "player")
2495 bprint ("^4", self.netname, "^4 is playing now\n");
2497 if(!autocvar_g_campaign)
2498 if (time < self.jointime + autocvar_welcome_message_time)
2499 Send_CSQC_Centerprint_Generic_Expire(self, CPID_MOTD); // clear MOTD
2501 if (self.prevent_join_msgtime)
2503 Send_CSQC_Centerprint_Generic_Expire(self, CPID_PREVENT_JOIN);
2504 self.prevent_join_msgtime = 0;
2509 if (g_ca && self.caplayer) {
2512 stuffcmd(self,"menu_showteamselect\n");
2517 //player may not join because of g_maxplayers is set
2518 if (time - self.prevent_join_msgtime > 2)
2520 Send_CSQC_Centerprint_Generic(self, CPID_PREVENT_JOIN, PREVENT_JOIN_TEXT, 0, 0);
2521 self.prevent_join_msgtime = time;
2527 * Determines whether the player is allowed to join. This depends on cvar
2528 * g_maxplayers, if it isn't used this function always return TRUE, otherwise
2529 * it checks whether the number of currently playing players exceeds g_maxplayers.
2530 * @return int number of free slots for players, 0 if none
2532 float nJoinAllowed(float includeMe) {
2533 if(self.team_forced < 0)
2534 return FALSE; // forced spectators can never join
2536 // TODO simplify this
2543 if (!autocvar_g_maxplayers)
2544 return maxclients - totalClients + includeMe;
2546 float currentlyPlaying;
2547 FOR_EACH_REALPLAYER(e)
2548 currentlyPlaying += 1;
2550 if(currentlyPlaying < autocvar_g_maxplayers)
2551 return min(maxclients - totalClients + includeMe, autocvar_g_maxplayers - currentlyPlaying);
2557 * Checks whether the client is an observer or spectator, if so, he will get kicked after
2558 * g_maxplayers_spectator_blocktime seconds
2560 void checkSpectatorBlock() {
2561 if(self.classname == "spectator" || self.classname == "observer") {
2562 if( time > (self.spectatortime + autocvar_g_maxplayers_spectator_blocktime) ) {
2563 sprint(self, "^7You were kicked from the server because you are spectator and spectators aren't allowed at the moment.\n");
2569 .float motd_actived_time; // used for both motd and campaign_message
2570 void PrintWelcomeMessage()
2572 if (self.motd_actived_time == 0) { // is there already a message showing?
2573 if (autocvar_g_campaign) {
2574 if ((self.classname == "player" && self.BUTTON_INFO) || (self.classname != "player")) {
2575 self.motd_actived_time = time;
2576 Send_CSQC_Centerprint_Generic(self, CPID_MOTD, campaign_message, -1, 0);
2579 if ((time - self.jointime > autocvar_welcome_message_time) && self.BUTTON_INFO) {
2580 self.motd_actived_time = time;
2581 Send_CSQC_Centerprint_Generic(self, CPID_MOTD, getwelcomemessage(), -1, 0);
2584 } else { // showing MOTD or campaign message
2585 if (autocvar_g_campaign) {
2586 if (self.BUTTON_INFO)
2587 self.motd_actived_time = time;
2588 else if ((time - self.motd_actived_time > 2) && self.classname == "player") { // hide it some seconds after BUTTON_INFO has been released
2589 self.motd_actived_time = 0;
2590 Send_CSQC_Centerprint_Generic_Expire(self, CPID_MOTD);
2593 if ((time - self.jointime) > autocvar_welcome_message_time) {
2594 if (self.BUTTON_INFO)
2595 self.motd_actived_time = time;
2596 else if (time - self.motd_actived_time > 2) { // hide it some seconds after BUTTON_INFO has been released
2597 self.motd_actived_time = 0;
2598 Send_CSQC_Centerprint_Generic_Expire(self, CPID_MOTD);
2605 void ObserverThink()
2607 float prefered_movetype;
2608 if (self.flags & FL_JUMPRELEASED) {
2609 if (self.BUTTON_JUMP && !self.version_mismatch) {
2610 self.flags &~= FL_JUMPRELEASED;
2611 self.flags |= FL_SPAWNING;
2612 } else if(self.BUTTON_ATCK && !self.version_mismatch) {
2613 self.flags &~= FL_JUMPRELEASED;
2614 if(SpectateNext() == 1) {
2615 self.classname = "spectator";
2618 prefered_movetype = ((!self.BUTTON_USE ? self.cvar_cl_clippedspectating : !self.cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP);
2619 if (self.movetype != prefered_movetype)
2620 self.movetype = prefered_movetype;
2623 if (!(self.BUTTON_ATCK || self.BUTTON_JUMP)) {
2624 self.flags |= FL_JUMPRELEASED;
2625 if(self.flags & FL_SPAWNING)
2627 self.flags &~= FL_SPAWNING;
2628 LeaveSpectatorMode();
2634 PrintWelcomeMessage();
2637 void SpectatorThink()
2639 if (self.flags & FL_JUMPRELEASED) {
2640 if (self.BUTTON_JUMP && !self.version_mismatch) {
2641 self.flags &~= FL_JUMPRELEASED;
2642 self.flags |= FL_SPAWNING;
2643 } else if(self.BUTTON_ATCK) {
2644 self.flags &~= FL_JUMPRELEASED;
2645 if(SpectateNext() == 1) {
2646 self.classname = "spectator";
2648 self.classname = "observer";
2649 PutClientInServer();
2651 } else if (self.BUTTON_ATCK2) {
2652 self.flags &~= FL_JUMPRELEASED;
2653 self.classname = "observer";
2654 PutClientInServer();
2656 if(!SpectateUpdate())
2657 PutObserverInServer();
2660 if (!(self.BUTTON_ATCK || self.BUTTON_ATCK2)) {
2661 self.flags |= FL_JUMPRELEASED;
2662 if(self.flags & FL_SPAWNING)
2664 self.flags &~= FL_SPAWNING;
2665 LeaveSpectatorMode();
2669 if(!SpectateUpdate())
2670 PutObserverInServer();
2673 PrintWelcomeMessage();
2674 self.flags |= FL_CLIENT | FL_NOTARGET;
2680 if(self.classname != "player")
2685 vehicles_exit(VHEF_NORMAL);
2689 // a use key was pressed; call handlers
2693 MUTATOR_CALLHOOK(PlayerUseKey);
2696 .float touchexplode_time;
2702 Called every frame for each client before the physics are run
2705 .float usekeypressed;
2706 void() ctf_setstatus;
2707 void() nexball_setstatus;
2709 void PlayerPreThink (void)
2711 WarpZone_PlayerPhysics_FixVAngle();
2713 self.stat_game_starttime = game_starttime;
2714 self.stat_allow_oldnexbeam = autocvar_g_allow_oldnexbeam;
2715 self.stat_leadlimit = autocvar_leadlimit;
2719 // physics frames: update anticheat stuff
2720 anticheat_prethink();
2723 if(blockSpectators && frametime)
2724 // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
2725 checkSpectatorBlock();
2729 if(self.netname_previous != self.netname)
2731 if(autocvar_sv_eventlog)
2732 GameLogEcho(strcat(":name:", ftos(self.playerid), ":", self.netname));
2733 if(self.netname_previous)
2734 strunzone(self.netname_previous);
2735 self.netname_previous = strzone(self.netname);
2739 if(self.version_nagtime)
2740 if(self.cvar_g_xonoticversion)
2741 if(time > self.version_nagtime)
2743 // don't notify git users
2744 if(strstr(self.cvar_g_xonoticversion, "git", 0) < 0 && strstr(self.cvar_g_xonoticversion, "autobuild", 0) < 0)
2746 if(strstr(autocvar_g_xonoticversion, "git", 0) >= 0 || strstr(autocvar_g_xonoticversion, "autobuild", 0) >= 0)
2748 // notify release users if connecting to git
2749 dprint("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Xonotic ", autocvar_g_xonoticversion, " (beta)^7, you have ^3Xonotic ", self.cvar_g_xonoticversion, "^1\n");
2750 sprint(self, strcat("\{1}^1NOTE: ^7the server is running ^3Xonotic ", autocvar_g_xonoticversion, " (beta)^7, you have ^3Xonotic ", self.cvar_g_xonoticversion, "^1\n"));
2755 r = vercmp(self.cvar_g_xonoticversion, autocvar_g_xonoticversion);
2758 // give users new version
2759 dprint("^1NOTE^7 to ", self.netname, "^7 - ^3Xonotic ", autocvar_g_xonoticversion, "^7 is out, and you still have ^3Xonotic ", self.cvar_g_xonoticversion, "^1 - get the update from ^4http://www.xonotic.org/^1!\n");
2760 sprint(self, strcat("\{1}^1NOTE: ^3Xonotic ", autocvar_g_xonoticversion, "^7 is out, and you still have ^3Xonotic ", self.cvar_g_xonoticversion, "^1 - get the update from ^4http://www.xonotic.org/^1!\n"));
2764 // notify users about old server version
2765 print("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Xonotic ", autocvar_g_xonoticversion, "^7, you have ^3Xonotic ", self.cvar_g_xonoticversion, "^1\n");
2766 sprint(self, strcat("\{1}^1NOTE: ^7the server is running ^3Xonotic ", autocvar_g_xonoticversion, "^7, you have ^3Xonotic ", self.cvar_g_xonoticversion, "^1\n"));
2770 self.version_nagtime = 0;
2774 if(!(self.flags & FL_GODMODE)) if(self.max_armorvalue)
2776 sprint(self, strcat("godmode saved you ", ftos(self.max_armorvalue), " units of damage, cheater!\n"));
2777 self.max_armorvalue = 0;
2781 if (TetrisPreFrame())
2785 MUTATOR_CALLHOOK(PlayerPreThink);
2787 if(!self.cvar_cl_newusekeysupported) // FIXME remove this - it was a stupid idea to begin with, we can JUST use the button
2789 if(self.BUTTON_USE && !self.usekeypressed)
2791 self.usekeypressed = self.BUTTON_USE;
2794 PrintWelcomeMessage();
2796 if(self.classname == "player") {
2797 // if(self.netname == "Wazat")
2798 // bprint(self.classname, "\n");
2800 CheckRules_Player();
2802 if (intermission_running)
2804 IntermissionThink (); // otherwise a button could be missed between
2805 return; // the think tics
2808 //don't allow the player to turn around while game is paused!
2809 if(timeoutStatus == 2) {
2810 // FIXME turn this into CSQC stuff
2811 self.v_angle = self.lastV_angle;
2812 self.angles = self.lastV_angle;
2813 self.fixangle = TRUE;
2818 if(self.health <= 0 && autocvar_g_deathglow)
2820 if(self.glowmod_x > 0)
2821 self.glowmod_x -= autocvar_g_deathglow * frametime;
2823 self.glowmod_x = -1;
2824 if(self.glowmod_y > 0)
2825 self.glowmod_y -= autocvar_g_deathglow * frametime;
2827 self.glowmod_y = -1;
2828 if(self.glowmod_z > 0)
2829 self.glowmod_z -= autocvar_g_deathglow * frametime;
2831 self.glowmod_z = -1;
2835 // set weapon and player glowmod
2836 self.glowmod = colormapPaletteColor(self.clientcolors & 0x0F, TRUE) * 2;
2838 if(self.weapon == WEP_NEX && autocvar_g_balance_nex_charge)
2840 self.weaponentity_glowmod_x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit);
2841 self.weaponentity_glowmod_y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit);
2842 self.weaponentity_glowmod_z = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit);
2844 if(self.nex_charge > autocvar_g_balance_nex_charge_animlimit)
2846 self.weaponentity_glowmod_x = self.weaponentity_glowmod_x + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit);
2847 self.weaponentity_glowmod_y = self.weaponentity_glowmod_y + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit);
2848 self.weaponentity_glowmod_z = self.weaponentity_glowmod_z + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit);
2852 self.weaponentity_glowmod = self.glowmod;
2858 minstagib_ammocheck();
2860 if (self.deadflag != DEAD_NO)
2862 float button_pressed, force_respawn;
2863 if(self.personal && g_race_qualifying)
2865 if(time > self.death_time)
2867 self.death_time = time + 1; // only retry once a second
2876 button_pressed = (self.BUTTON_ATCK || self.BUTTON_JUMP || self.BUTTON_ATCK2 || self.BUTTON_HOOK || self.BUTTON_USE);
2877 force_respawn = (g_lms || g_ca || g_cts || autocvar_g_forced_respawn);
2878 if (self.deadflag == DEAD_DYING)
2881 self.deadflag = DEAD_RESPAWNING;
2882 else if(!button_pressed)
2883 self.deadflag = DEAD_DEAD;
2885 else if (self.deadflag == DEAD_DEAD)
2888 self.deadflag = DEAD_RESPAWNABLE;
2890 else if (self.deadflag == DEAD_RESPAWNABLE)
2893 self.deadflag = DEAD_RESPAWNING;
2895 else if (self.deadflag == DEAD_RESPAWNING)
2897 if(time > self.death_time)
2899 self.death_time = time + 1; // only retry once a second
2903 ShowRespawnCountdown();
2907 // FIXME from now on self.deadflag is always 0 (and self.health is never < 1)
2908 // so (self.deadflag == DEAD_NO) is always true in the code below
2911 if(time > self.touchexplode_time)
2912 if(self.classname == "player")
2913 if(self.deadflag == DEAD_NO)
2914 if not(IS_INDEPENDENT_PLAYER(self))
2915 FOR_EACH_PLAYER(other) if(self != other)
2917 if(time > other.touchexplode_time)
2918 if(other.deadflag == DEAD_NO)
2919 if not(IS_INDEPENDENT_PLAYER(other))
2920 if(boxesoverlap(self.absmin, self.absmax, other.absmin, other.absmax))
2922 PlayerTouchExplode(self, other);
2923 self.touchexplode_time = other.touchexplode_time = time + 0.2;
2927 if(g_lms && !self.deadflag && autocvar_g_lms_campcheck_interval)
2931 // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
2932 dist = self.prevorigin - self.origin;
2934 self.lms_traveled_distance += fabs(vlen(dist));
2936 if((autocvar_g_campaign && !campaign_bots_may_start) || (time < game_starttime))
2938 self.lms_nextcheck = time + autocvar_g_lms_campcheck_interval*2;
2939 self.lms_traveled_distance = 0;
2942 if(time > self.lms_nextcheck)
2944 //sprint(self, "distance: ", ftos(self.lms_traveled_distance), "\n");
2945 if(self.lms_traveled_distance < autocvar_g_lms_campcheck_distance)
2947 centerprint(self, autocvar_g_lms_campcheck_message);
2948 // FIXME KadaverJack: gibbing player here causes playermodel to bounce around, instead of eye.md3
2949 // I wasn't able to find out WHY that happens, so I put a workaround in place that shall prevent players from being gibbed :(
2950 Damage(self, self, self, bound(0, autocvar_g_lms_campcheck_damage, self.health + self.armorvalue * autocvar_g_balance_armor_blockpercent + 5), DEATH_CAMP, self.origin, '0 0 0');
2952 self.lms_nextcheck = time + autocvar_g_lms_campcheck_interval;
2953 self.lms_traveled_distance = 0;
2957 self.prevorigin = self.origin;
2959 if (((self.BUTTON_CROUCH && !self.hook.state) || self.health <= g_bloodloss) && self.animstate_startframe != self.anim_melee_x) // prevent crouching if using melee attack
2964 self.view_ofs = PL_CROUCH_VIEW_OFS;
2965 setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX);
2966 // setanim(self, self.anim_duck, FALSE, TRUE, TRUE); // this anim is BROKEN anyway
2973 tracebox(self.origin, PL_MIN, PL_MAX, self.origin, FALSE, self);
2974 if (!trace_startsolid)
2976 self.crouch = FALSE;
2977 self.view_ofs = PL_VIEW_OFS;
2978 setsize (self, PL_MIN, PL_MAX);
2983 if(self.health <= g_bloodloss && self.deadflag == DEAD_NO)
2985 if(self.bloodloss_timer < time)
2987 self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
2988 self.bloodloss_timer = time + 0.5 + random() * 0.5;
2994 GrapplingHookFrame();
2996 // LordHavoc: allow firing on move frames (sub-ticrate), this gives better timing on slow servers
2999 self.items &~= self.items_added;
3003 self.items_added = 0;
3004 if(self.items & IT_JETPACK)
3005 if(self.items & IT_FUEL_REGEN || self.ammo_fuel >= 0.01)
3006 self.items_added |= IT_FUEL;
3008 self.items |= self.items_added;
3013 // rot nex charge to the charge limit
3014 if(autocvar_g_balance_nex_charge_rot_rate && self.nex_charge > autocvar_g_balance_nex_charge_limit && self.nex_charge_rottime < time)
3015 self.nex_charge = bound(autocvar_g_balance_nex_charge_limit, self.nex_charge - autocvar_g_balance_nex_charge_rot_rate * frametime / W_TICSPERFRAME, 1);
3024 nexball_setstatus();
3027 secrets_setstatus();
3029 self.dmg_team = max(0, self.dmg_team - autocvar_g_teamdamage_resetspeed * frametime);
3031 //self.angles_y=self.v_angle_y + 90; // temp
3032 } else if(gameover) {
3033 if (intermission_running)
3034 IntermissionThink (); // otherwise a button could be missed between
3036 } else if(self.classname == "observer") {
3038 } else if(self.classname == "spectator") {
3043 SetZoomState(self.BUTTON_ZOOM || self.BUTTON_ZOOMSCRIPT || (self.BUTTON_ATCK2 && self.weapon == WEP_NEX) || (self.BUTTON_ATCK2 && self.weapon == WEP_RIFLE && autocvar_g_balance_rifle_secondary == 0));
3045 float oldspectatee_status;
3046 oldspectatee_status = self.spectatee_status;
3047 if(self.classname == "spectator")
3048 self.spectatee_status = num_for_edict(self.enemy);
3049 else if(self.classname == "observer")
3050 self.spectatee_status = num_for_edict(self);
3052 self.spectatee_status = 0;
3053 if(self.spectatee_status != oldspectatee_status)
3055 ClientData_Touch(self);
3057 race_InitSpectator();
3060 if(self.teamkill_soundtime)
3061 if(time > self.teamkill_soundtime)
3063 self.teamkill_soundtime = 0;
3065 entity oldpusher, oldself;
3067 oldself = self; self = self.teamkill_soundsource;
3068 oldpusher = self.pusher; self.pusher = oldself;
3070 PlayerSound(playersound_teamshoot, CH_VOICE, VOICETYPE_LASTATTACKER_ONLY);
3072 self.pusher = oldpusher;
3076 if(self.taunt_soundtime)
3077 if(time > self.taunt_soundtime)
3079 self.taunt_soundtime = 0;
3080 PlayerSound(playersound_taunt, CH_VOICE, VOICETYPE_AUTOTAUNT);
3083 target_voicescript_next(self);
3085 // if a player goes unarmed after holding a loaded weapon, empty his clip size and remove the crosshair ammo ring
3087 self.clip_load = self.clip_size = 0;
3090 float isInvisibleString(string s)
3093 s = strdecolorize(s);
3094 for((i = 0), (n = strlen(s)); i < n; ++i)
3102 case 192: // charmap space
3103 if (!autocvar_utf8_enable)
3106 case 160: // space in unicode fonts
3107 case 0xE000 + 192: // utf8 charmap space
3108 if (autocvar_utf8_enable)
3121 Called every frame for each client after the physics are run
3124 .float idlekick_lasttimeleft;
3125 .entity showheadshotbbox;
3126 void showheadshotbbox_think()
3128 if(self.owner.showheadshotbbox != self)
3133 self.nextthink = time;
3134 setorigin(self, self.owner.origin);
3135 setsize(self, GetHeadshotMins(self.owner), GetHeadshotMaxs(self.owner));
3137 void PlayerPostThink (void)
3139 // Savage: Check for nameless players
3140 if (isInvisibleString(self.netname)) {
3141 self.netname = "Player";
3142 stuffcmd(self, strcat("name ", self.netname, substring(ftos(random()), 2, -1), "\n"));
3145 if(sv_maxidle && frametime)
3147 // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
3149 if (time - self.parm_idlesince < 1) // instead of (time == self.parm_idlesince) to support sv_maxidle <= 10
3151 if(self.idlekick_lasttimeleft)
3153 Send_CSQC_Centerprint_Generic_Expire(self, CPID_DISCONNECT_IDLING);
3154 self.idlekick_lasttimeleft = 0;
3158 timeleft = ceil(sv_maxidle - (time - self.parm_idlesince));
3159 if(timeleft == min(10, sv_maxidle - 1)) // - 1 to support sv_maxidle <= 10
3161 if(!self.idlekick_lasttimeleft)
3162 Send_CSQC_Centerprint_Generic(self, CPID_DISCONNECT_IDLING, "^3Stop idling!\n^3Disconnecting in %d seconds...", 1, timeleft);
3166 bprint("^3", self.netname, "^3 was kicked for idling.\n");
3167 AnnounceTo(self, "terminated");
3171 else if(timeleft <= 10)
3173 if(timeleft != self.idlekick_lasttimeleft)
3174 AnnounceTo(self, ftos(timeleft));
3175 self.idlekick_lasttimeleft = timeleft;
3180 if(self.impulse == 100)
3182 if (TetrisPostFrame())
3188 //CheckPlayerJump();
3190 if(self.classname == "player") {
3191 CheckRules_Player();
3195 if (intermission_running)
3196 return; // intermission or finale
3198 } else if (self.classname == "observer") {
3200 } else if (self.classname == "spectator") {
3206 for(i = 0; i < 1000; ++i)
3209 end = self.origin + '0 0 1024' + 512 * randomvec();
3210 tracebox(self.origin, self.mins, self.maxs, end, MOVE_NORMAL, self);
3211 if(trace_fraction < 1)
3212 if(!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
3214 print("I HIT SOLID: ", vtos(self.origin), " -> ", vtos(end), "\n");
3222 //pointparticles(particleeffectnum("machinegun_impact"), self.origin + self.view_ofs + '0 0 7', '0 0 0', 1);
3224 if(self.waypointsprite_attachedforcarrier)
3225 WaypointSprite_UpdateHealth(self.waypointsprite_attachedforcarrier, '1 0 0' * healtharmor_maxdamage(self.health, self.armorvalue, autocvar_g_balance_armor_blockpercent));
3227 if(self.classname == "player" && self.deadflag == DEAD_NO && autocvar_r_showbboxes)
3229 if(!self.showheadshotbbox)
3231 self.showheadshotbbox = spawn();
3232 self.showheadshotbbox.classname = "headshotbbox";
3233 self.showheadshotbbox.owner = self;
3234 self.showheadshotbbox.think = showheadshotbbox_think;
3235 self.showheadshotbbox.nextthink = time;
3236 self = self.showheadshotbbox;
3243 if(self.showheadshotbbox)
3244 if(self.showheadshotbbox && !wasfreed(self.showheadshotbbox))
3245 remove(self.showheadshotbbox);
3250 if((g_cts || g_race) && self.cvar_cl_allow_uidtracking == 1 && self.cvar_cl_allow_uid2name == 1)
3252 if(!self.stored_netname)
3253 self.stored_netname = strzone(uid2name(self.crypto_idfp));
3254 if(self.stored_netname != self.netname)
3256 db_put(ServerProgsDB, strcat("/uid2name/", self.crypto_idfp), self.netname);
3257 strunzone(self.stored_netname);
3258 self.stored_netname = strzone(self.netname);
3264 dprint(sprintf("%f %.6f\n", time, race_GetFractionalLapCount(self)));