X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fclient.qc;h=d706f8107313d65e8951fb674b9799186bd18fc7;hb=bc50c2d7ca3e0a44ed1712400ef8e170e6df8210;hp=f64935330a9567f19b29485ff5ebbfa835e1f5e7;hpb=15a474a8dd9705bfb43f00cbef66f4ab49e76aa8;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index f64935330..d706f8107 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -152,10 +152,15 @@ void ClientData_Detach(entity this) void ClientData_Touch(entity e) { - CS(e).clientdata.SendFlags = 1; + entity cd = CS(e).clientdata; + if (cd) { cd.SendFlags = 1; } // make it spectatable - FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != e && IS_SPEC(it) && it.enemy == e, { CS(it).clientdata.SendFlags = 1; }); + FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != e && IS_SPEC(it) && it.enemy == e, + { + entity cd = CS(it).clientdata; + if (cd) { cd.SendFlags = 1; } + }); } void SetSpectatee(entity this, entity spectatee); @@ -308,6 +313,9 @@ void PutObserverInServer(entity this) if(this.bot_attack) IL_REMOVE(g_bot_targets, this); this.bot_attack = false; + if(this.monster_attack) + IL_REMOVE(g_monster_targets, this); + this.monster_attack = false; STAT(HUD, this) = HUD_NORMAL; TRANSMUTE(Observer, this); this.iscreature = false; @@ -340,6 +348,7 @@ void PutObserverInServer(entity this) this.strength_finished = 0; this.invincible_finished = 0; this.superweapons_finished = 0; + this.dphitcontentsmask = 0; this.pushltime = 0; this.istypefrag = 0; setthink(this, func_null); @@ -1094,6 +1103,8 @@ void FixClientCvars(entity e) stuffcmd(e, sprintf("\ncl_jumpspeedcap_min \"%s\"\n", autocvar_sv_jumpspeedcap_min)); stuffcmd(e, sprintf("\ncl_jumpspeedcap_max \"%s\"\n", autocvar_sv_jumpspeedcap_max)); + stuffcmd(e, sprintf("\ncl_shootfromfixedorigin \"%s\"\n", autocvar_g_shootfromfixedorigin)); + MUTATOR_CALLHOOK(FixClientCvars, e); } @@ -1213,16 +1224,7 @@ void ClientConnect(entity this) JoinBestTeam(this, false); // if the team number is valid, keep it this.playerid = playerid_save; - if (autocvar_sv_spectate || autocvar_g_campaign || this.team_forced < 0) { - TRANSMUTE(Observer, this); - } else { - if (!teamplay || autocvar_g_balance_teams) { - TRANSMUTE(Player, this); - campaign_bots_may_start = true; - } else { - TRANSMUTE(Observer, this); // do it anyway - } - } + TRANSMUTE(Observer, this); PlayerStats_GameReport_AddEvent(sprintf("kills-%d", this.playerid)); @@ -1346,7 +1348,8 @@ void ClientDisconnect(entity this) MUTATOR_CALLHOOK(ClientDisconnect, this); - if (CS(this).netname_previous) strunzone(CS(this).netname_previous); // needs to be before the CS entity is removed! + strfree(CS(this).netname_previous); // needs to be before the CS entity is removed! + strfree(CS(this).weaponorder_byimpulse); ClientState_detach(this); Portal_ClearAll(this); @@ -1366,8 +1369,7 @@ void ClientDisconnect(entity this) bot_relinkplayerlist(); - if (this.clientstatus) strunzone(this.clientstatus); - if (this.weaponorder_byimpulse) strunzone(this.weaponorder_byimpulse); + strfree(this.clientstatus); if (this.personal) delete(this.personal); this.playerid = 0; @@ -1490,7 +1492,7 @@ void player_powerups(entity this) Fire_ApplyDamage(this); Fire_ApplyEffect(this); - if (!g_instagib) + if (!autocvar_g_instagib) { if (this.items & ITEM_Strength.m_itemid) { @@ -2133,9 +2135,11 @@ void PrintWelcomeMessage(entity this) } } +const int MIN_SPEC_TIME = 1; bool joinAllowed(entity this) { if (CS(this).version_mismatch) return false; + if (time < CS(this).jointime + MIN_SPEC_TIME) return false; if (!nJoinAllowed(this, this)) return false; if (teamplay && lockteams) return false; if (ShowTeamSelection(this)) return false; @@ -2144,6 +2148,7 @@ bool joinAllowed(entity this) } .int items_added; +.string shootfromfixedorigin; bool PlayerThink(entity this) { if (game_stopped || intermission_running) { @@ -2239,45 +2244,13 @@ bool PlayerThink(entity this) return false; } - 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 (have_hook) { - do_crouch = false; - } else if (this.waterlevel >= WATERLEVEL_SWIMMING) { - do_crouch = false; - } else if (this.vehicle) { - do_crouch = false; - } else if (STAT(FROZEN, this)) { - do_crouch = false; - } + FixPlayermodel(this); - if (do_crouch) { - if (!this.crouch) { - this.crouch = true; - this.view_ofs = STAT(PL_CROUCH_VIEW_OFS, this); - setsize(this, STAT(PL_CROUCH_MIN, this), STAT(PL_CROUCH_MAX, this)); - // setanim(this, this.anim_duck, false, true, true); // this anim is BROKEN anyway - } - } else if (this.crouch) { - tracebox(this.origin, STAT(PL_MIN, this), STAT(PL_MAX, this), this.origin, false, this); - if (!trace_startsolid) { - this.crouch = false; - this.view_ofs = STAT(PL_VIEW_OFS, this); - setsize(this, STAT(PL_MIN, this), STAT(PL_MAX, this)); - } + if (this.shootfromfixedorigin != autocvar_g_shootfromfixedorigin) { + this.shootfromfixedorigin = autocvar_g_shootfromfixedorigin; + stuffcmd(this, sprintf("\ncl_shootfromfixedorigin \"%s\"\n", autocvar_g_shootfromfixedorigin)); } - FixPlayermodel(this); - // LordHavoc: allow firing on move frames (sub-ticrate), this gives better timing on slow servers //if(frametime) { @@ -2506,8 +2479,7 @@ void PlayerPreThink (entity this) } if (!assume_unchanged && autocvar_sv_eventlog) GameLogEcho(strcat(":name:", ftos(this.playerid), ":", playername(this, false))); - if (CS(this).netname_previous) strunzone(CS(this).netname_previous); - CS(this).netname_previous = strzone(this.netname); + strcpy(CS(this).netname_previous, this.netname); } // version nagging @@ -2598,6 +2570,8 @@ void PlayerPreThink (entity this) PrintWelcomeMessage(this); if (IS_PLAYER(this)) { + if (IS_REAL_CLIENT(this) && time < CS(this).jointime + MIN_SPEC_TIME) + error("Client can't be spawned as player on connection!"); if(!PlayerThink(this)) return; } @@ -2606,6 +2580,20 @@ void PlayerPreThink (entity this) IntermissionThink(this); return; } + else if (IS_REAL_CLIENT(this) && !CS(this).autojoin_checked && time >= CS(this).jointime + MIN_SPEC_TIME) + { + CS(this).autojoin_checked = true; + // don't do this in ClientConnect + // many things can go wrong if a client is spawned as player on connection + if (MUTATOR_CALLHOOK(AutoJoinOnConnection, this) + || (!(autocvar_sv_spectate || autocvar_g_campaign || this.team_forced < 0) + && (!teamplay || autocvar_g_balance_teams))) + { + campaign_bots_may_start = true; + Join(this); + return; + } + } else if (IS_OBSERVER(this)) { ObserverThink(this); } @@ -2758,6 +2746,13 @@ void PlayerPostThink (entity this) } if (IS_PLAYER(this)) { + if(this.death_time == time && IS_DEAD(this)) + { + // player's bbox gets resized now, instead of in the damage event that killed the player, + // once all the damage events of this frame have been processed with normal size + this.maxs.z = 5; + setsize(this, this.mins, this.maxs); + } DrownPlayer(this); UpdateChatBubble(this); if (CS(this).impulse) ImpulseCommands(this); @@ -2786,11 +2781,14 @@ void PM_UpdateButtons(entity this, entity store) store.impulse = this.impulse; this.impulse = 0; - store.button0 = this.button0; - store.button2 = this.button2; - store.button3 = this.button3; + bool typing = this.buttonchat; + + store.button0 = (typing) ? 0 : this.button0; + //button1?! + store.button2 = (typing) ? 0 : this.button2; + store.button3 = (typing) ? 0 : this.button3; store.button4 = this.button4; - store.button5 = this.button5; + store.button5 = (typing) ? 0 : this.button5; store.button6 = this.button6; store.button7 = this.button7; store.button8 = this.button8; @@ -2816,5 +2814,12 @@ void PM_UpdateButtons(entity this, entity store) store.ping_movementloss = this.ping_movementloss; store.v_angle = this.v_angle; - store.movement = this.movement; + store.movement = (typing) ? '0 0 0' : this.movement; +} + +NET_HANDLE(fpsreport, bool) +{ + int fps = ReadShort(); + PlayerScore_Set(sender, SP_FPS, fps); + return true; }