X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcl_client.qc;h=b7072849c59b9e9cd9dacf1d7cd5e9fedf2c620b;hb=a11e3217808e6c8f2c971401ba2bcc43578832b1;hp=89647d5be241eae4bb2d68944adea631942a16fc;hpb=bb80a6aba067167c6ef8d5f3465f03bd34142fa2;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 89647d5be..b7072849c 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1,29 +1,48 @@ +#include "cl_client.qh" + #include "waypointsprites.qh" +#include "anticheat.qh" #include "cl_impulse.qh" #include "cl_player.qh" #include "ent_cs.qh" -#include "g_subs.qh" #include "ipban.qh" #include "miscfunctions.qh" #include "portals.qh" #include "teamplay.qh" #include "playerdemo.qh" -#include "secret.qh" +#include "spawnpoints.qh" +#include "g_damage.qh" +#include "g_hook.qh" +#include "command/common.qh" +#include "cheats.qh" +#include "g_world.qh" +#include "race.qh" +#include "antilag.qh" +#include "campaign.qh" +#include "command/common.qh" #include "bot/bot.qh" #include "bot/navigation.qh" +#include "vehicles/vehicle.qh" + #include "weapons/hitplot.qh" #include "weapons/weaponsystem.qh" #include "../common/net_notice.qh" +#include "../common/physics.qh" + +#include "../common/triggers/subs.qh" +#include "../common/triggers/triggers.qh" +#include "../common/triggers/trigger/secret.qh" + +#include "../common/items/inventory.qh" #include "../common/monsters/sv_monsters.qh" #include "../warpzonelib/server.qh" -float c1, c2, c3, c4; void send_CSQC_teamnagger() { WriteByte(MSG_BROADCAST, SVC_TEMPENTITY); @@ -167,7 +186,7 @@ void PutObserverInServer (void) entity spot; self.hud = HUD_NORMAL; - if(IS_PLAYER(self)) { pointparticles(particleeffectnum("spawn_event_neutral"), self.origin, '0 0 0', 1); } + if(IS_PLAYER(self)) { Send_Effect("spawn_event_neutral", self.origin, '0 0 0', 1); } spot = SelectSpawnPoint (true); if(!spot) @@ -176,6 +195,7 @@ void PutObserverInServer (void) if(IS_REAL_CLIENT(self)) { + Item_ItemsTime_SetTimesForPlayer(self); msg_entity = self; WriteByte(MSG_ONE, SVC_SETVIEW); WriteEntity(MSG_ONE, self); @@ -207,7 +227,8 @@ void PutObserverInServer (void) if(self.killcount != -666) { Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_SPECTATE, self.netname); - if(autocvar_g_chat_nospectators == 1 || (cvar("g_warmup") && !(warmup_stage || gameover) && autocvar_g_chat_nospectators == 2)) + if(!intermission_running) + if(autocvar_g_chat_nospectators == 1 || (!(warmup_stage || gameover) && autocvar_g_chat_nospectators == 2)) Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CHAT_NOSPECTATORS); if(self.just_joined == false) { @@ -301,7 +322,7 @@ void FixPlayermodel() defaultskin = 0; chmdl = false; - if(autocvar_sv_defaultcharacter == 1) + if(autocvar_sv_defaultcharacter) { if(teamplay) { @@ -401,7 +422,7 @@ void PutClientInServer (void) // reset player keys self.itemkeys = 0; - MUTATOR_CALLHOOK(PutClientInServer); + MUTATOR_CALLHOOK(PutClientInServer, self); if(gameover) self.classname = "observer"; @@ -409,7 +430,6 @@ void PutClientInServer (void) if(IS_PLAYER(self)) { entity spot, oldself; - float j; accuracy_resend(self); @@ -488,6 +508,9 @@ void PutClientInServer (void) else self.superweapons_finished = 0; + if(!warmup_stage) + Item_ItemsTime_ResetTimesForPlayer(self); + if(g_weaponarena_random) // WEAPONTODO: more stuff that should be in a mutator. also: rename those cvars { if(g_weaponarena_random_with_blaster) @@ -516,7 +539,7 @@ void PutClientInServer (void) self.respawn_flags = 0; self.respawn_time = 0; self.stat_respawn_time = 0; - self.scale = 0; + self.scale = autocvar_sv_player_scale; self.fade_time = 0; self.pain_frame = 0; self.pain_finished = 0; @@ -598,13 +621,13 @@ void PutClientInServer (void) target_voicescript_clear(self); // reset fields the weapons may use - for (j = WEP_FIRST; j <= WEP_LAST; ++j) + for (int j = WEP_FIRST; j <= WEP_LAST; ++j) { WEP_ACTION(j, WR_RESETPLAYER); // all weapons must be fully loaded when we spawn entity e = get_weaponinfo(j); - if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars + if (e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars self.(weapon_load[j]) = e.reloading_ammo; } @@ -621,8 +644,7 @@ void PutClientInServer (void) Unfreeze(self); - spawn_spot = spot; - MUTATOR_CALLHOOK(PlayerSpawn); + MUTATOR_CALLHOOK(PlayerSpawn, spot); if(autocvar_spawn_debug) { @@ -651,7 +673,7 @@ void PutClientInServer (void) .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? -float ClientInit_SendEntity(entity to, float sf) +float ClientInit_SendEntity(entity to, int sf) { WriteByte(MSG_ENTITY, ENT_CLIENT_INIT); WriteByte(MSG_ENTITY, g_nexball_meter_period * 32); @@ -1000,7 +1022,7 @@ float PlayerInIDList(entity p, string idlist) float n, i; string s; - // NOTE: we do NOT check crypto_keyfp here, an unsigned ID is fine too for this + // NOTE: we do NOT check crypto_idfp_signed here, an unsigned ID is fine too for this if (!p.crypto_idfp) return 0; @@ -1082,6 +1104,7 @@ void ClientConnect (void) PlayerScore_Attach(self); ClientData_Attach(); accuracy_init(self); + Inventory_new(self); bot_clientconnect(); @@ -1249,7 +1272,14 @@ void ClientConnect (void) if(IS_REAL_CLIENT(self)) sv_notice_join(); - MUTATOR_CALLHOOK(ClientConnect); + for (entity e = world; (e = findfloat(e, init_for_player_needed, 1)); ) { + entity oldself = self; + self = e; + e.init_for_player(oldself); + self = oldself; + } + + MUTATOR_CALLHOOK(ClientConnect, self); } /* ============= @@ -1273,7 +1303,7 @@ void ClientDisconnect (void) PlayerStats_GameReport_FinalizePlayer(self); - if(IS_PLAYER(self)) { pointparticles(particleeffectnum("spawn_event_neutral"), self.origin, '0 0 0', 1); } + if(IS_PLAYER(self)) { Send_Effect("spawn_event_neutral", self.origin, '0 0 0', 1); } CheatShutdownClient(); @@ -1317,6 +1347,7 @@ void ClientDisconnect (void) bot_relinkplayerlist(); accuracy_free(self); + Inventory_delete(self); ClientData_Detach(); PlayerScore_Detach(self); @@ -1409,7 +1440,7 @@ void respawn(void) self.velocity = '0 0 1' * autocvar_g_respawn_ghosts_speed; self.avelocity = randomvec() * autocvar_g_respawn_ghosts_speed * 3 - randomvec() * autocvar_g_respawn_ghosts_speed * 3; self.effects |= CSQCMODEL_EF_RESPAWNGHOST; - pointparticles(particleeffectnum("respawn_ghost"), self.origin, '0 0 0', 1); + Send_Effect("respawn_ghost", self.origin, '0 0 0', 1); if(autocvar_g_respawn_ghosts_maxtime) SUB_SetFade (self, time + autocvar_g_respawn_ghosts_maxtime / 2 + random () * (autocvar_g_respawn_ghosts_maxtime - autocvar_g_respawn_ghosts_maxtime / 2), 1.5); } @@ -1431,7 +1462,7 @@ void play_countdown(float finished, string samp) void player_powerups (void) { // add a way to see what the items were BEFORE all of these checks for the mutator hook - olditems = self.items; + int items_prev = self.items; if((self.items & IT_USING_JETPACK) && !self.deadflag && !gameover) self.modelflags |= MF_ROCKET; @@ -1543,7 +1574,7 @@ void player_powerups (void) if (time < self.spawnshieldtime) self.effects = self.effects | (EF_ADDITIVE | EF_FULLBRIGHT); - MUTATOR_CALLHOOK(PlayerPowerups); + MUTATOR_CALLHOOK(PlayerPowerups, self, items_prev); } float CalcRegen(float current, float stable, float regenfactor, float regenframetime) @@ -1595,11 +1626,7 @@ void player_regen (void) { float max_mod, regen_mod, rot_mod, limit_mod; max_mod = regen_mod = rot_mod = limit_mod = 1; - regen_mod_max = max_mod; - regen_mod_regen = regen_mod; - regen_mod_rot = rot_mod; - regen_mod_limit = limit_mod; - if(!MUTATOR_CALLHOOK(PlayerRegen)) + if(!MUTATOR_CALLHOOK(PlayerRegen, max_mod, regen_mod, rot_mod, limit_mod)) if(!self.frozen) { float minh, mina, maxh, maxa, limith, limita; @@ -1654,55 +1681,17 @@ void SetZoomState(float z) void GetPressedKeys(void) { MUTATOR_CALLHOOK(GetPressedKeys); - if (self.movement.x > 0) // get if movement keys are pressed - { // forward key pressed - self.pressedkeys |= KEY_FORWARD; - self.pressedkeys &= ~KEY_BACKWARD; - } - else if (self.movement.x < 0) - { // backward key pressed - self.pressedkeys |= KEY_BACKWARD; - self.pressedkeys &= ~KEY_FORWARD; - } - else - { // no x input - self.pressedkeys &= ~KEY_FORWARD; - self.pressedkeys &= ~KEY_BACKWARD; - } - - if (self.movement.y > 0) - { // right key pressed - self.pressedkeys |= KEY_RIGHT; - self.pressedkeys &= ~KEY_LEFT; - } - else if (self.movement.y < 0) - { // left key pressed - self.pressedkeys |= KEY_LEFT; - self.pressedkeys &= ~KEY_RIGHT; - } - else - { // no y input - self.pressedkeys &= ~KEY_RIGHT; - self.pressedkeys &= ~KEY_LEFT; - } - - if (self.BUTTON_JUMP) // get if jump and crouch keys are pressed - self.pressedkeys |= KEY_JUMP; - else - self.pressedkeys &= ~KEY_JUMP; - if (self.BUTTON_CROUCH) - self.pressedkeys |= KEY_CROUCH; - else - self.pressedkeys &= ~KEY_CROUCH; - - if (self.BUTTON_ATCK) - self.pressedkeys |= KEY_ATCK; - else - self.pressedkeys &= ~KEY_ATCK; - if (self.BUTTON_ATCK2) - self.pressedkeys |= KEY_ATCK2; - else - self.pressedkeys &= ~KEY_ATCK2; + #define X(var,bit,flag) (flag ? var |= bit : var &= ~bit) + X(self.pressedkeys, KEY_FORWARD, self.movement_x > 0); + X(self.pressedkeys, KEY_BACKWARD, self.movement_x < 0); + X(self.pressedkeys, KEY_RIGHT, self.movement_y > 0); + X(self.pressedkeys, KEY_LEFT, self.movement_y < 0); + + X(self.pressedkeys, KEY_JUMP, PHYS_INPUT_BUTTON_JUMP(self)); + X(self.pressedkeys, KEY_CROUCH, PHYS_INPUT_BUTTON_CROUCH(self)); + X(self.pressedkeys, KEY_ATCK, PHYS_INPUT_BUTTON_ATCK(self)); + X(self.pressedkeys, KEY_ATCK2, PHYS_INPUT_BUTTON_ATCK2(self)); + #undef X } /* @@ -1712,8 +1701,7 @@ spectate mode routines */ void SpectateCopy(entity spectatee) { - other = spectatee; - MUTATOR_CALLHOOK(SpectateCopy); + MUTATOR_CALLHOOK(SpectateCopy, spectatee, self); self.armortype = spectatee.armortype; self.armorvalue = spectatee.armorvalue; self.ammo_cells = spectatee.ammo_cells; @@ -2237,6 +2225,8 @@ void PlayerPreThink (void) self.stat_allow_oldvortexbeam = autocvar_g_allow_oldvortexbeam; self.stat_leadlimit = autocvar_leadlimit; + self.weaponsinmap = weaponsInMap; + if(frametime) { // physics frames: update anticheat stuff @@ -2475,8 +2465,8 @@ void PlayerPreThink (void) if (!self.crouch) { self.crouch = true; - self.view_ofs = PL_CROUCH_VIEW_OFS; - setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX); + self.view_ofs = self.stat_pl_crouch_view_ofs; + setsize (self, self.stat_pl_crouch_min, self.stat_pl_crouch_max); // setanim(self, self.anim_duck, false, true, true); // this anim is BROKEN anyway } } @@ -2484,12 +2474,12 @@ void PlayerPreThink (void) { if (self.crouch) { - tracebox(self.origin, PL_MIN, PL_MAX, self.origin, false, self); + tracebox(self.origin, self.stat_pl_min, self.stat_pl_max, self.origin, false, self); if (!trace_startsolid) { self.crouch = false; - self.view_ofs = PL_VIEW_OFS; - setsize (self, PL_MIN, PL_MAX); + self.view_ofs = self.stat_pl_view_ofs; + setsize (self, self.stat_pl_min, self.stat_pl_max); } } }