X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fclient.qc;h=95f28752714a9c322ebfb08ba67cf0ffbcb930e6;hb=595b8c7a015b8c41a8180c8d08b1a0a2cdb89ecd;hp=085756e18b045b4e8fcc7d8db152aff7fbfcd58a;hpb=1d4a1688f09d4192f8b783d0c081e22d292af761;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 085756e18..95f287527 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -23,10 +23,12 @@ #include "bot/api.qh" #include "../common/ent_cs.qh" +#include "../common/wepent.qh" #include #include +#include "../common/triggers/func/conveyor.qh" #include "../common/triggers/teleporters.qh" #include "../common/vehicles/all.qh" @@ -35,6 +37,7 @@ #include "weapons/weaponsystem.qh" #include "../common/net_notice.qh" +#include "../common/net_linked.qh" #include "../common/physics/player.qh" #include "../common/items/_mod.qh" @@ -110,7 +113,6 @@ bool ClientData_Send(entity this, entity to, int sf) if (e.race_completed) sf |= 1; // forced scoreboard if (to.spectatee_status) sf |= 2; // spectator ent number follows if (e.zoomstate) sf |= 4; // zoomed - if (e.porto_v_angle_held) sf |= 8; // angles held if (autocvar_sv_showspectators) sf |= 16; // show spectators WriteHeader(MSG_ENTITY, ENT_CLIENT_CLIENTDATA); @@ -120,11 +122,6 @@ bool ClientData_Send(entity this, entity to, int sf) { WriteByte(MSG_ENTITY, to.spectatee_status); } - if (sf & 8) - { - WriteAngle(MSG_ENTITY, e.v_angle.x); - WriteAngle(MSG_ENTITY, e.v_angle.y); - } if(sf & 16) { @@ -234,7 +231,7 @@ void PutObserverInServer(entity this) this.angles_z = 0; this.fixangle = true; // offset it so that the spectator spawns higher off the ground, looks better this way - setorigin(this, spot.origin + STAT(PL_VIEW_OFS, NULL)); + setorigin(this, spot.origin + STAT(PL_VIEW_OFS, this)); this.prevorigin = this.origin; if (IS_REAL_CLIENT(this)) { @@ -251,11 +248,11 @@ void PutObserverInServer(entity this) FixPlayermodel(this); } setmodel(this, MDL_Null); - setsize(this, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL)); + setsize(this, STAT(PL_CROUCH_MIN, this), STAT(PL_CROUCH_MAX, this)); this.view_ofs = '0 0 0'; } - RemoveGrapplingHook(this); + RemoveGrapplingHooks(this); Portal_ClearAll(this); Unfreeze(this); SetSpectatee(this, NULL); @@ -282,8 +279,8 @@ void PutObserverInServer(entity this) if (this.killcount != FRAGS_SPECTATOR) { Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, this.netname); - if(!intermission_running) - if(autocvar_g_chat_nospectators == 1 || (!(warmup_stage || gameover) && autocvar_g_chat_nospectators == 2)) + if(!game_stopped) + if(autocvar_g_chat_nospectators == 1 || (!warmup_stage && autocvar_g_chat_nospectators == 2)) Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CHAT_NOSPECTATORS); if(this.just_joined == false) { @@ -295,6 +292,8 @@ void PutObserverInServer(entity this) accuracy_resend(this); this.spectatortime = time; + if(this.bot_attack) + IL_REMOVE(g_bot_targets, this); this.bot_attack = false; this.hud = HUD_NORMAL; TRANSMUTE(Observer, this); @@ -332,16 +331,16 @@ void PutObserverInServer(entity this) this.istypefrag = 0; setthink(this, func_null); this.nextthink = 0; - this.hook_time = 0; this.deadflag = DEAD_NO; this.crouch = false; + this.revive_progress = 0; this.revival_time = 0; this.items = 0; this.weapons = '0 0 0'; + this.dual_weapons = '0 0 0'; this.drawonlytoclient = this; - this.weaponname = ""; this.weaponmodel = ""; for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { @@ -357,9 +356,14 @@ void PutObserverInServer(entity this) this.fire_endtime = -1; this.event_damage = func_null; - STAT(ACTIVEWEAPON, this) = WEP_Null.m_id; - STAT(SWITCHINGWEAPON, this) = WEP_Null.m_id; - STAT(SWITCHWEAPON, this) = WEP_Null.m_id; + for(int slot = 0; slot < MAX_AXH; ++slot) + { + entity axh = this.(AuxiliaryXhair[slot]); + this.(AuxiliaryXhair[slot]) = NULL; + + if(axh.owner == this && axh != NULL && !wasfreed(axh)) + delete(axh); + } } int player_getspecies(entity this) @@ -380,11 +384,12 @@ void FixPlayermodel(entity player) { if(teamplay) { - string s = Static_Team_ColorName_Lower(player.team); - if (s != "neutral") + switch(player.team) { - defaultmodel = cvar_string(strcat("sv_defaultplayermodel_", s)); - defaultskin = cvar(strcat("sv_defaultplayerskin_", s)); + case NUM_TEAM_1: defaultmodel = autocvar_sv_defaultplayermodel_red; defaultskin = autocvar_sv_defaultplayerskin_red; break; + case NUM_TEAM_2: defaultmodel = autocvar_sv_defaultplayermodel_blue; defaultskin = autocvar_sv_defaultplayerskin_blue; break; + case NUM_TEAM_3: defaultmodel = autocvar_sv_defaultplayermodel_yellow; defaultskin = autocvar_sv_defaultplayerskin_yellow; break; + case NUM_TEAM_4: defaultmodel = autocvar_sv_defaultplayermodel_pink; defaultskin = autocvar_sv_defaultplayerskin_pink; break; } } @@ -415,9 +420,13 @@ void FixPlayermodel(entity player) { if(teamplay) { - string s = Static_Team_ColorName_Lower(player.team); - if (s != "neutral") - defaultskin = cvar(strcat("sv_defaultplayerskin_", s)); + switch(player.team) + { + case NUM_TEAM_1: defaultskin = autocvar_sv_defaultplayerskin_red; break; + case NUM_TEAM_2: defaultskin = autocvar_sv_defaultplayerskin_blue; break; + case NUM_TEAM_3: defaultskin = autocvar_sv_defaultplayerskin_yellow; break; + case NUM_TEAM_4: defaultskin = autocvar_sv_defaultplayerskin_pink; break; + } } if(!defaultskin) @@ -490,9 +499,8 @@ void PutClientInServer(entity this) WriteByte(MSG_ONE, SVC_SETVIEW); WriteEntity(MSG_ONE, this); } - if (gameover) { + if (game_stopped) TRANSMUTE(Observer, this); - } SetSpectatee(this, NULL); @@ -565,6 +573,8 @@ void PutClientInServer(entity this) } SetSpectatee_status(this, 0); + this.dual_weapons = '0 0 0'; + this.superweapons_finished = (this.weapons & WEPSET_SUPERWEAPONS) ? time + autocvar_g_balance_superweapons_time : 0; this.items = start_items; @@ -612,6 +622,7 @@ void PutClientInServer(entity this) this.strength_finished = 0; this.invincible_finished = 0; this.fire_endtime = -1; + this.revive_progress = 0; this.revival_time = 0; this.air_finished = time + 12; @@ -626,22 +637,29 @@ void PutClientInServer(entity this) FixPlayermodel(this); this.drawonlytoclient = NULL; + this.viewloc = NULL; + this.crouch = false; - this.view_ofs = STAT(PL_VIEW_OFS, NULL); - setsize(this, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL)); + this.view_ofs = STAT(PL_VIEW_OFS, this); + setsize(this, STAT(PL_MIN, this), STAT(PL_MAX, this)); this.spawnorigin = spot.origin; setorigin(this, spot.origin + '0 0 1' * (1 - this.mins.z - 24)); // don't reset back to last position, even if new position is stuck in solid this.oldorigin = this.origin; this.prevorigin = this.origin; this.lastteleporttime = time; // prevent insane speeds due to changing origin + if(this.conveyor) + IL_REMOVE(g_conveyed, this); this.conveyor = NULL; // prevent conveyors at the previous location from moving a freshly spawned player this.hud = HUD_NORMAL; this.event_damage = PlayerDamage; + if(!this.bot_attack) + IL_PUSH(g_bot_targets, this); this.bot_attack = true; this.monster_attack = true; + navigation_dynamicgoal_init(this, false); PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_JUMP(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false; @@ -652,7 +670,11 @@ void PutClientInServer(entity this) for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { - CL_SpawnWeaponentity(this, weaponentities[slot]); + .entity weaponentity = weaponentities[slot]; + entity oldwep = this.(weaponentity); + CL_SpawnWeaponentity(this, weaponentity); + if(oldwep && oldwep.owner == this) + this.(weaponentity).m_gunalign = oldwep.m_gunalign; } this.alpha = default_player_alpha; this.colormod = '1 1 1' * autocvar_g_player_brightness; @@ -667,7 +689,11 @@ void PutClientInServer(entity this) it.wr_resetplayer(it, this); // reload all reloadable weapons if (it.spawnflags & WEP_FLAG_RELOADABLE) { - this.weapon_load[it.m_id] = it.reloading_ammo; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + this.(weaponentity).weapon_load[it.m_id] = it.reloading_ammo; + } } )); @@ -688,11 +714,20 @@ void PutClientInServer(entity this) delete(spot); // usefull for checking if there are spawnpoints, that let drop through the floor } - PS(this).m_switchweapon = w_getbestweapon(this); - this.cnt = -1; // W_LastWeapon will not complain - PS(this).m_weapon = WEP_Null; - this.weaponname = ""; - PS(this).m_switchingweapon = WEP_Null; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(slot == 0 || autocvar_g_weaponswitch_debug == 1) + this.(weaponentity).m_switchweapon = w_getbestweapon(this, weaponentity); + else + this.(weaponentity).m_switchweapon = WEP_Null; + this.(weaponentity).m_weapon = WEP_Null; + this.(weaponentity).weaponname = ""; + this.(weaponentity).m_switchingweapon = WEP_Null; + this.(weaponentity).cnt = -1; + } + + MUTATOR_CALLHOOK(PlayerWeaponSelect, this); if (!warmup_stage && !this.alivetime) this.alivetime = time; @@ -703,7 +738,6 @@ void PutClientInServer(entity this) void ClientInit_misc(entity this); -.float ebouncefactor, ebouncestop; // electro's values // TODO do we need all these fields, or should we stop autodetecting runtime // changes and just have a console command to update this? bool ClientInit_SendEntity(entity this, entity to, int sf) @@ -857,7 +891,7 @@ void ClientKill_Now(entity this) } void KillIndicator_Think(entity this) { - if (gameover) + if (game_stopped) { this.owner.killindicator = NULL; delete(this); @@ -901,7 +935,7 @@ void ClientKill_TeamChange (entity this, float targetteam) // 0 = don't change, float killtime; float starttime; - if (gameover) + if (game_stopped) return; killtime = autocvar_g_balance_kill_delay; @@ -942,10 +976,8 @@ void ClientKill_TeamChange (entity this, float targetteam) // 0 = don't change, this.killindicator.count = bound(0, ceil(killtime), 10); //sprint(this, strcat("^1You'll be dead in ", ftos(this.killindicator.cnt), " seconds\n")); - FOREACH_ENTITY_ENT(enemy, this, + IL_EACH(g_clones, it.enemy == this && !(it.effects & CSQCMODEL_EF_RESPAWNGHOST), { - if(it.classname != "body") - continue; it.killindicator = spawn(); it.killindicator.owner = it; it.killindicator.scale = 0.5; @@ -995,7 +1027,7 @@ void ClientKill_TeamChange (entity this, float targetteam) // 0 = don't change, void ClientKill (entity this) { - if(gameover) return; + if(game_stopped) return; if(this.player_blocked) return; if(STAT(FROZEN, this)) return; @@ -1043,8 +1075,8 @@ ClientPreConnect Called once (not at each match start) when a client begins a connection to the server ============= */ -void ClientPreConnect () -{ENGINE_EVENT(); +void ClientPreConnect(entity this) +{ if(autocvar_sv_eventlog) { GameLogEcho(sprintf(":connect:%d:%d:%s", @@ -1133,7 +1165,7 @@ void ClientConnect(entity this) if (IS_BOT_CLIENT(this)) PlayerStats_GameReport_AddPlayer(this); if (autocvar_sv_eventlog) - GameLogEcho(strcat(":join:", ftos(this.playerid), ":", ftos(etof(this)), ":", ((IS_REAL_CLIENT(this)) ? this.netaddress : "bot"), ":", this.netname)); + GameLogEcho(strcat(":join:", ftos(this.playerid), ":", ftos(etof(this)), ":", ((IS_REAL_CLIENT(this)) ? this.netaddress : "bot"), ":", playername(this, false))); LogTeamchange(this.playerid, this.team, 1); @@ -1141,7 +1173,10 @@ void ClientConnect(entity this) this.netname_previous = strzone(this.netname); - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && IS_PLAYER(this)) ? APP_TEAM_ENT(this, INFO_JOIN_CONNECT_TEAM) : INFO_JOIN_CONNECT), this.netname); + if(teamplay && IS_PLAYER(this)) + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_JOIN_CONNECT_TEAM), this.netname); + else + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_JOIN_CONNECT, this.netname); stuffcmd(this, clientstuff, "\n"); stuffcmd(this, "cl_particles_reloadeffects\n"); // TODO do we still need this? @@ -1180,12 +1215,6 @@ void ClientConnect(entity this) if (IS_REAL_CLIENT(this)) { - if (!autocvar_g_campaign) - { - this.motd_actived_time = -1; - Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage(this)); - } - if (g_weaponarena_weapons == WEPSET(TUBA)) stuffcmd(this, "cl_cmd settemp chase_active 1\n"); } @@ -1194,7 +1223,7 @@ void ClientConnect(entity this) stuffcmd(this, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n")); if (autocvar_sv_teamnagger && !(autocvar_bot_vs_human && AvailableTeams() == 2)) - if (!g_ca && !g_cts && !g_race) // teamnagger is currently bad for ca, race & cts + if(!MUTATOR_CALLHOOK(HideTeamNagger, this)) send_CSQC_teamnagger(); CSQCMODEL_AUTOINIT(this); @@ -1204,11 +1233,25 @@ void ClientConnect(entity this) if (IS_REAL_CLIENT(this)) sv_notice_join(this); - FOREACH_ENTITY_FLOAT(init_for_player_needed, true, { + // update physics stats (players can spawn before physics runs) + STAT(MOVEVARS_HIGHSPEED, this) = autocvar_g_movement_highspeed; + MUTATOR_CALLHOOK(PlayerPhysics_UpdateStats, this); // do it BEFORE the function so we can modify highspeed! + Physics_UpdateStats(this, PHYS_HIGHSPEED(this)); + + IL_EACH(g_initforplayer, it.init_for_player, { it.init_for_player(it, this); }); MUTATOR_CALLHOOK(ClientConnect, this); + + if (IS_REAL_CLIENT(this)) + { + if (!autocvar_g_campaign && !IS_PLAYER(this)) + { + this.motd_actived_time = -1; + Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage(this)); + } + } } /* ============= @@ -1233,7 +1276,8 @@ void ClientDisconnect(entity this) Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_DISCONNECT, this.netname); - SetSpectatee(this, NULL); + if(IS_SPEC(this)) + SetSpectatee(this, NULL); MUTATOR_CALLHOOK(ClientDisconnect, this); @@ -1243,7 +1287,7 @@ void ClientDisconnect(entity this) Unfreeze(this); - RemoveGrapplingHook(this); + RemoveGrapplingHooks(this); // Here, everything has been done that requires this player to be a client. @@ -1264,6 +1308,8 @@ void ClientDisconnect(entity this) this.playerid = 0; ReadyCount(); if (vote_called && IS_REAL_CLIENT(this)) VoteCount(false); + + ONREMOVE(this); } void ChatBubbleThink(entity this) @@ -1366,7 +1412,7 @@ void player_powerups(entity this) // add a way to see what the items were BEFORE all of these checks for the mutator hook int items_prev = this.items; - if((this.items & IT_USING_JETPACK) && !IS_DEAD(this) && !gameover) + if((this.items & IT_USING_JETPACK) && !IS_DEAD(this) && !game_stopped) this.modelflags |= MF_ROCKET; else this.modelflags &= ~MF_ROCKET; @@ -1397,7 +1443,8 @@ void player_powerups(entity this) if (time < this.strength_finished) { this.items = this.items | ITEM_Strength.m_itemid; - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERUP_STRENGTH, this.netname); + if(!g_cts) + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERUP_STRENGTH, this.netname); Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_POWERUP_STRENGTH); } } @@ -1417,7 +1464,8 @@ void player_powerups(entity this) if (time < this.invincible_finished) { this.items = this.items | ITEM_Shield.m_itemid; - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERUP_SHIELD, this.netname); + if(!g_cts) + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERUP_SHIELD, this.netname); Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_POWERUP_SHIELD); } } @@ -1451,7 +1499,8 @@ void player_powerups(entity this) if (time < this.superweapons_finished || (this.items & IT_UNLIMITED_SUPERWEAPONS)) { this.items = this.items | IT_SUPERWEAPON; - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_SUPERWEAPON_PICKUP, this.netname); + if(!g_cts) + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_SUPERWEAPON_PICKUP, this.netname); Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_SUPERWEAPON_PICKUP); } else @@ -1590,11 +1639,11 @@ void player_regen(entity this) } bool zoomstate_set; -void SetZoomState(entity this, float z) +void SetZoomState(entity this, float newzoom) { - if(z != this.zoomstate) + if(newzoom != this.zoomstate) { - this.zoomstate = z; + this.zoomstate = newzoom; ClientData_Touch(this); } zoomstate_set = true; @@ -1603,7 +1652,7 @@ void SetZoomState(entity this, float z) void GetPressedKeys(entity this) { MUTATOR_CALLHOOK(GetPressedKeys, this); - int keys = this.pressedkeys; + int keys = STAT(PRESSED_KEYS, this); keys = BITSET(keys, KEY_FORWARD, this.movement.x > 0); keys = BITSET(keys, KEY_BACKWARD, this.movement.x < 0); keys = BITSET(keys, KEY_RIGHT, this.movement.y > 0); @@ -1613,7 +1662,9 @@ void GetPressedKeys(entity this) keys = BITSET(keys, KEY_CROUCH, PHYS_INPUT_BUTTON_CROUCH(this)); keys = BITSET(keys, KEY_ATCK, PHYS_INPUT_BUTTON_ATCK(this)); keys = BITSET(keys, KEY_ATCK2, PHYS_INPUT_BUTTON_ATCK2(this)); - this.pressedkeys = keys; + this.pressedkeys = keys; // store for other users + + STAT(PRESSED_KEYS, this) = keys; } /* @@ -1646,8 +1697,10 @@ void SpectateCopy(entity this, entity spectatee) this.hit_time = spectatee.hit_time; this.strength_finished = spectatee.strength_finished; this.invincible_finished = spectatee.invincible_finished; - this.pressedkeys = spectatee.pressedkeys; + this.superweapons_finished = spectatee.superweapons_finished; + STAT(PRESSED_KEYS, this) = STAT(PRESSED_KEYS, spectatee); this.weapons = spectatee.weapons; + this.dual_weapons = spectatee.dual_weapons; this.vortex_charge = spectatee.vortex_charge; this.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo; this.hagar_load = spectatee.hagar_load; @@ -1663,12 +1716,24 @@ void SpectateCopy(entity this, entity spectatee) this.angles = spectatee.v_angle; STAT(FROZEN, this) = STAT(FROZEN, spectatee); this.revive_progress = spectatee.revive_progress; + this.viewloc = spectatee.viewloc; if(!PHYS_INPUT_BUTTON_USE(this) && STAT(CAMERA_SPECTATOR, this) != 2) this.fixangle = true; setorigin(this, spectatee.origin); setsize(this, spectatee.mins, spectatee.maxs); SetZoomState(this, spectatee.zoomstate); + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + this.(weaponentity) = spectatee.(weaponentity); + } + + for(int slot = 0; slot < MAX_AXH; ++slot) + { + this.(AuxiliaryXhair[slot]) = spectatee.(AuxiliaryXhair[slot]); + } + anticheat_spectatecopy(this, spectatee); this.hud = spectatee.hud; if(spectatee.vehicle) @@ -1702,7 +1767,7 @@ void SpectateCopy(entity this, entity spectatee) bool SpectateUpdate(entity this) { if(!this.enemy) - return false; + return false; if(!IS_PLAYER(this.enemy) || this == this.enemy) { @@ -1748,6 +1813,9 @@ void SetSpectatee_status(entity this, int spectatee_num) void SetSpectatee(entity this, entity spectatee) { + if(IS_BOT_CLIENT(this)) + return; // bots abuse .enemy, this code is useless to them + entity old_spectatee = this.enemy; this.enemy = spectatee; @@ -1865,40 +1933,35 @@ void ShowRespawnCountdown(entity this) } } -.float caplayer; - -void LeaveSpectatorMode(entity this) +.bool team_selected; +bool ShowTeamSelection(entity this) { - if(this.caplayer) - return; - if(nJoinAllowed(this, this)) - { - if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || (this.wasplayer && autocvar_g_changeteam_banned) || this.team_forced > 0) - { - TRANSMUTE(Player, this); - - SetSpectatee(this, NULL); + if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || this.team_selected || (this.wasplayer && autocvar_g_changeteam_banned) || this.team_forced > 0) + return false; + stuffcmd(this, "menu_showteamselect\n"); + return true; +} +void Join(entity this) +{ + TRANSMUTE(Player, this); - if(autocvar_g_campaign || autocvar_g_balance_teams) - { JoinBestTeam(this, false, true); } + if(!this.team_selected) + if(autocvar_g_campaign || autocvar_g_balance_teams) + JoinBestTeam(this, false, true); - if(autocvar_g_campaign) - { campaign_bots_may_start = true; } + if(autocvar_g_campaign) + campaign_bots_may_start = true; - Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_PREVENT_JOIN); + Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_PREVENT_JOIN); - PutClientInServer(this); + PutClientInServer(this); - if(IS_PLAYER(this)) { Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT(this, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), this.netname); } - } - else - stuffcmd(this, "menu_showteamselect\n"); - } + if(IS_PLAYER(this)) + if(teamplay && this.team != -1) + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_JOIN_PLAY_TEAM), this.netname); else - { - // Player may not join because g_maxplayers is set - Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_PREVENT); - } + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_JOIN_PLAY, this.netname); + this.team_selected = false; } /** @@ -1907,20 +1970,20 @@ void LeaveSpectatorMode(entity this) * it checks whether the number of currently playing players exceeds g_maxplayers. * @return int number of free slots for players, 0 if none */ -bool nJoinAllowed(entity this, entity ignore) +int nJoinAllowed(entity this, entity ignore) { if(!ignore) // this is called that way when checking if anyone may be able to join (to build qcstatus) // so report 0 free slots if restricted { if(autocvar_g_forced_team_otherwise == "spectate") - return false; + return 0; if(autocvar_g_forced_team_otherwise == "spectator") - return false; + return 0; } - if(this.team_forced < 0) - return false; // forced spectators can never join + if(this && this.team_forced < 0) + return 0; // forced spectators can never join // TODO simplify this int totalClients = 0; @@ -1933,13 +1996,20 @@ bool nJoinAllowed(entity this, entity ignore) ++currentlyPlaying; )); + float free_slots = 0; if (!autocvar_g_maxplayers) - return maxclients - totalClients; + free_slots = maxclients - totalClients; + else if(currentlyPlaying < autocvar_g_maxplayers) + free_slots = min(maxclients - totalClients, autocvar_g_maxplayers - currentlyPlaying); - if(currentlyPlaying < autocvar_g_maxplayers) - return min(maxclients - totalClients, autocvar_g_maxplayers - currentlyPlaying); + static float join_prevent_msg_time = 0; + if(this && ignore && !free_slots && time > join_prevent_msg_time) + { + Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_PREVENT); + join_prevent_msg_time = time + 3; + } - return false; + return free_slots; } /** @@ -2006,6 +2076,16 @@ void PrintWelcomeMessage(entity this) } } +bool joinAllowed(entity this) +{ + if (this.version_mismatch) return false; + if (!nJoinAllowed(this, this)) return false; + if (teamplay && lockteams) return false; + if (ShowTeamSelection(this)) return false; + if (MUTATOR_CALLHOOK(ForbidSpawn, this)) return false; + return true; +} + void ObserverThink(entity this) { if ( this.impulse ) @@ -2013,8 +2093,9 @@ void ObserverThink(entity this) MinigameImpulse(this, this.impulse); this.impulse = 0; } + if (this.flags & FL_JUMPRELEASED) { - if (PHYS_INPUT_BUTTON_JUMP(this) && !this.version_mismatch) { + if (PHYS_INPUT_BUTTON_JUMP(this) && joinAllowed(this)) { this.flags &= ~FL_JUMPRELEASED; this.flags |= FL_SPAWNING; } else if(PHYS_INPUT_BUTTON_ATCK(this) && !this.version_mismatch) { @@ -2032,7 +2113,7 @@ void ObserverThink(entity this) if(this.flags & FL_SPAWNING) { this.flags &= ~FL_SPAWNING; - LeaveSpectatorMode(this); + Join(this); return; } } @@ -2053,8 +2134,9 @@ void SpectatorThink(entity this) return; } } + if (this.flags & FL_JUMPRELEASED) { - if (PHYS_INPUT_BUTTON_JUMP(this) && !this.version_mismatch) { + if (PHYS_INPUT_BUTTON_JUMP(this) && joinAllowed(this)) { this.flags &= ~FL_JUMPRELEASED; this.flags |= FL_SPAWNING; } else if(PHYS_INPUT_BUTTON_ATCK(this) || this.impulse == 10 || this.impulse == 15 || this.impulse == 18 || (this.impulse >= 200 && this.impulse <= 209)) { @@ -2089,7 +2171,7 @@ void SpectatorThink(entity this) if(this.flags & FL_SPAWNING) { this.flags &= ~FL_SPAWNING; - LeaveSpectatorMode(this); + Join(this); return; } } @@ -2108,7 +2190,7 @@ void PlayerUseKey(entity this) if(this.vehicle) { - if(!gameover) + if(!game_stopped) { vehicles_exit(this.vehicle, VHEF_NORMAL); return; @@ -2118,7 +2200,7 @@ void PlayerUseKey(entity this) { if(!STAT(FROZEN, this)) if(!IS_DEAD(this)) - if(!gameover) + if(!game_stopped) { entity head, closest_target = NULL; head = WarpZone_FindRadius(this.origin, autocvar_g_vehicles_enter_radius, true); @@ -2191,7 +2273,7 @@ void PlayerPreThink (entity this) } if (this.netname != this.netname_previous) { if (autocvar_sv_eventlog) { - GameLogEcho(strcat(":name:", ftos(this.playerid), ":", this.netname)); + GameLogEcho(strcat(":name:", ftos(this.playerid), ":", playername(this, false))); } if (this.netname_previous) strunzone(this.netname_previous); this.netname_previous = strzone(this.netname); @@ -2249,7 +2331,7 @@ void PlayerPreThink (entity this) MUTATOR_CALLHOOK(PlayerPreThink, this); - if(autocvar_g_vehicles_enter && (time > this.last_vehiclecheck) && !gameover && !this.vehicle) + if(autocvar_g_vehicles_enter && (time > this.last_vehiclecheck) && !game_stopped && !this.vehicle) if(IS_PLAYER(this) && !STAT(FROZEN, this) && !IS_DEAD(this)) { FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_vehicles_enter_radius, IS_VEHICLE(it), @@ -2284,8 +2366,10 @@ void PlayerPreThink (entity this) if (IS_PLAYER(this)) { CheckRules_Player(this); - if (intermission_running) { - IntermissionThink(this); + if (game_stopped || intermission_running) { + this.modelflags &= ~MF_ROCKET; + if(intermission_running) + IntermissionThink(this); return; } @@ -2308,6 +2392,13 @@ void PlayerPreThink (entity this) } } else { if (frametime) player_anim(this); + + if (this.respawn_flags & RESPAWN_DENY) + { + STAT(RESPAWN_TIME, this) = 0; + return; + } + bool button_pressed = (PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_ATCK2(this) || PHYS_INPUT_BUTTON_HOOK(this) || PHYS_INPUT_BUTTON_USE(this)); switch(this.deadflag) @@ -2316,7 +2407,7 @@ void PlayerPreThink (entity this) { if ((this.respawn_flags & RESPAWN_FORCE) && !(this.respawn_time < this.respawn_time_max)) this.deadflag = DEAD_RESPAWNING; - else if (!button_pressed || (this.respawn_flags & RESPAWN_FORCE)) + else if (!button_pressed || (time >= this.respawn_time_max && (this.respawn_flags & RESPAWN_FORCE))) this.deadflag = DEAD_DEAD; break; } @@ -2370,8 +2461,18 @@ void PlayerPreThink (entity this) this.prevorigin = this.origin; + bool have_hook = false; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(this.(weaponentity).hook.state) + { + have_hook = true; + break; + } + } bool do_crouch = PHYS_INPUT_BUTTON_CROUCH(this); - if (this.hook.state) { + if (have_hook) { do_crouch = false; } else if (this.waterlevel >= WATERLEVEL_SWIMMING) { do_crouch = false; @@ -2404,13 +2505,17 @@ void PlayerPreThink (entity this) { this.items &= ~this.items_added; - //for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) - //{ - //.entity weaponentity = weaponentities[slot]; - //W_WeaponFrame(this, weaponentity); - //} - .entity weaponentity = weaponentities[0]; // TODO - W_WeaponFrame(this, weaponentity); + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + W_WeaponFrame(this, weaponentity); + + if(slot == 0) + { + this.clip_load = this.(weaponentity).clip_load; + this.clip_size = this.(weaponentity).clip_size; + } + } this.items_added = 0; if (this.items & ITEM_Jetpack.m_itemid && (this.items & ITEM_JetpackRegen.m_itemid || this.ammo_fuel >= 0.01)) @@ -2423,8 +2528,12 @@ void PlayerPreThink (entity this) // WEAPONTODO: Add a weapon request for this // rot vortex charge to the charge limit - if (WEP_CVAR(vortex, charge_rot_rate) && this.vortex_charge > WEP_CVAR(vortex, charge_limit) && this.vortex_charge_rottime < time) - this.vortex_charge = bound(WEP_CVAR(vortex, charge_limit), this.vortex_charge - WEP_CVAR(vortex, charge_rot_rate) * frametime / W_TICSPERFRAME, 1); + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if (WEP_CVAR(vortex, charge_rot_rate) && this.(weaponentity).vortex_charge > WEP_CVAR(vortex, charge_limit) && this.(weaponentity).vortex_charge_rottime < time) + this.(weaponentity).vortex_charge = bound(WEP_CVAR(vortex, charge_limit), this.(weaponentity).vortex_charge - WEP_CVAR(vortex, charge_rot_rate) * frametime / W_TICSPERFRAME, 1); + } if (frametime) player_anim(this); @@ -2436,8 +2545,9 @@ void PlayerPreThink (entity this) this.dmg_team = max(0, this.dmg_team - autocvar_g_teamdamage_resetspeed * frametime); } - else if (gameover) { - if (intermission_running) IntermissionThink(this); + else if (game_stopped || intermission_running) { + if(intermission_running) + IntermissionThink(this); return; } else if (IS_OBSERVER(this)) { @@ -2449,11 +2559,15 @@ void PlayerPreThink (entity this) // WEAPONTODO: Add weapon request for this if (!zoomstate_set) { - SetZoomState(this, - PHYS_INPUT_BUTTON_ZOOM(this) || PHYS_INPUT_BUTTON_ZOOMSCRIPT(this) - || (PHYS_INPUT_BUTTON_ATCK2(this) && PS(this).m_weapon == WEP_VORTEX) - || (PHYS_INPUT_BUTTON_ATCK2(this) && PS(this).m_weapon == WEP_RIFLE && WEP_CVAR(rifle, secondary) == 0) - ); + bool wep_zoomed = false; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + Weapon thiswep = this.(weaponentity).m_weapon; + if(thiswep != WEP_Null && thiswep.wr_zoom) + wep_zoomed += thiswep.wr_zoom(thiswep, this); + } + SetZoomState(this, PHYS_INPUT_BUTTON_ZOOM(this) || PHYS_INPUT_BUTTON_ZOOMSCRIPT(this) || wep_zoomed); } if (this.teamkill_soundtime && time > this.teamkill_soundtime) @@ -2476,8 +2590,12 @@ void PlayerPreThink (entity this) // WEAPONTODO: Move into weaponsystem somehow // if a player goes unarmed after holding a loaded weapon, empty his clip size and remove the crosshair ammo ring - if (PS(this).m_weapon == WEP_Null) - this.clip_load = this.clip_size = 0; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(this.(weaponentity).m_weapon == WEP_Null) + this.(weaponentity).clip_load = this.(weaponentity).clip_size = 0; + } } void DrownPlayer(entity this) @@ -2506,20 +2624,11 @@ void DrownPlayer(entity this) void Player_Physics(entity this) { - set_movetype(this, ((this.move_qcphysics) ? MOVETYPE_NONE : this.move_movetype)); + set_movetype(this, this.move_movetype); if(!this.move_qcphysics) return; - int mt = this.move_movetype; - - if(mt == MOVETYPE_PUSH || mt == MOVETYPE_FAKEPUSH || mt == MOVETYPE_PHYSICS) - { - this.move_qcphysics = false; - set_movetype(this, mt); - return; - } - if(!frametime && !this.pm_frametime) return; @@ -2588,13 +2697,23 @@ void PlayerPostThink (entity this) CheatFrame(this); //CheckPlayerJump(); + if (game_stopped) + { + this.solid = SOLID_NOT; + this.takedamage = DAMAGE_NO; + set_movetype(this, MOVETYPE_NONE); + } if (IS_PLAYER(this)) { DrownPlayer(this); CheckRules_Player(this); UpdateChatBubble(this); if (this.impulse) ImpulseCommands(this); - if (intermission_running) return; // intermission or finale + if (game_stopped) + { + CSQCMODEL_AUTOUPDATE(this); + return; + } GetPressedKeys(this); }