]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move client setup to ClientState_attach
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 9 Mar 2016 22:50:18 +0000 (09:50 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 10 Mar 2016 02:04:51 +0000 (13:04 +1100)
qcsrc/common/physics/player.qh
qcsrc/common/state.qh
qcsrc/server/anticheat.qc
qcsrc/server/anticheat.qh
qcsrc/server/cheats.qc
qcsrc/server/cheats.qh
qcsrc/server/cl_client.qc
qcsrc/server/scores.qc

index ea318c5b013f540801aa5fa2d196c5e5a8e9ea0a..252b157cdf0f8dfd9c22d873db7630275c57a796 100644 (file)
@@ -99,6 +99,15 @@ bool IsFlying(entity a);
 #define PHYS_INPUT_BUTTON_ZOOM(s)           PHYS_INPUT_BUTTON_BUTTON4(s)
 #define PHYS_INPUT_BUTTON_CROUCH(s)         PHYS_INPUT_BUTTON_BUTTON5(s)
 #define PHYS_INPUT_BUTTON_HOOK(s)           PHYS_INPUT_BUTTON_BUTTON6(s)
+
+#ifdef CSQC
+STATIC_INIT(PHYS_INPUT_BUTTON_HOOK)
+{
+       localcmd("alias +hook +button6\n");
+       localcmd("alias -hook -button6\n");
+}
+#endif
+
 #define PHYS_INPUT_BUTTON_INFO(s)           PHYS_INPUT_BUTTON_BUTTON7(s)
 #define PHYS_INPUT_BUTTON_DRAG(s)           PHYS_INPUT_BUTTON_BUTTON8(s)
 #define PHYS_INPUT_BUTTON_USE(s)            PHYS_INPUT_BUTTON_BUTTON_USE(s)
@@ -107,6 +116,14 @@ bool IsFlying(entity a);
 #define PHYS_INPUT_BUTTON_ZOOMSCRIPT(s)     PHYS_INPUT_BUTTON_BUTTON9(s)
 #define PHYS_INPUT_BUTTON_JETPACK(s)        PHYS_INPUT_BUTTON_BUTTON10(s)
 
+#ifdef CSQC
+STATIC_INIT(PHYS_INPUT_BUTTON_JETPACK)
+{
+       localcmd("alias +jetpack +button10\n");
+    localcmd("alias -jetpack -button10\n");
+}
+#endif
+
 // if more buttons are needed, start using impulse bits as buttons
 
 #define PHYS_INPUT_BUTTON_BACKWARD(s)       (PHYS_INPUT_MOVEVALUES(s).x < 0)
index e2ba5f3858b1dcef031e5009b4fcab9d7d7cde76..fcc3656b8dcd710c76305925e1868e18bef0777b 100644 (file)
@@ -30,18 +30,25 @@ ENDCLASS(PlayerState)
        PlayerState PS(entity this) { assert(IS_CLIENT(this)); return this._ps; }
 #endif
 
+void Inventory_new(entity this);
+void Inventory_delete(entity this);
+
+// TODO: renew on death
+
 void PlayerState_attach(entity this)
 {
-       // TODO: dynamic
-       // this._ps = NEW(PlayerState, this);
+       this._ps = NEW(PlayerState, this);
+
+       Inventory_new(this);
 }
 
 void PlayerState_detach(entity this)
 {
-       // TODO: dynamic
-       // if (!PS(this)) return;  // initial connect
-       // remove(PS(this));
-       // this._ps = NULL;
+       if (!PS(this)) return;  // initial connect
+       remove(PS(this));
+       this._ps = NULL;
+
+    Inventory_delete(self);
 }
 
 /**
@@ -66,15 +73,64 @@ ENDCLASS(ClientState)
        ClientState CS(entity this) { assert(IS_CLIENT(this)); assert(this._cs); return this._cs; }
 #endif
 
+void GetCvars(int);
+void DecodeLevelParms(entity this);
+void PlayerScore_Attach(entity this);
+void ClientData_Attach(entity this);
+void accuracy_init(entity this);
+void entcs_attach(entity this);
+void playerdemo_init(entity this);
+void anticheat_init(entity this);
+void W_HitPlotOpen(entity this);
+void bot_clientconnect(entity this);
+
 void ClientState_attach(entity this)
 {
        this._cs = NEW(ClientState, this);
-       this._ps = NEW(PlayerState, this);  // TODO: dynamic
+
+    GetCvars(0);  // get other cvars from player
+
+       // TODO: xonstat elo.txt support, until then just 404s
+       if (false && IS_REAL_CLIENT(this)) { PlayerStats_PlayerBasic_CheckUpdate(this); }
+
+       // TODO: fold all of these into ClientState
+
+       DecodeLevelParms(this);
+
+       PlayerScore_Attach(this);
+       ClientData_Attach(this);
+       accuracy_init(this);
+       entcs_attach(this);
+       playerdemo_init(this);
+       anticheat_init(this);
+       W_HitPlotOpen(this);
+
+       bot_clientconnect(this);
 }
 
+void bot_clientdisconnect();
+void W_HitPlotClose(entity this);
+void anticheat_report();
+void playerdemo_shutdown();
+void entcs_detach(entity this);
+void accuracy_free(entity this);
+void ClientData_Detach(entity this);
+void PlayerScore_Detach(entity this);
+
 void ClientState_detach(entity this)
 {
        remove(CS(this));
        this._cs = NULL;
-       this._ps = NULL;  // TODO: dynamic
+
+    GetCvars(-1);  // free cvars
+
+    bot_clientdisconnect();
+
+    W_HitPlotClose(this);
+    anticheat_report();
+    playerdemo_shutdown();
+    entcs_detach(this);
+    accuracy_free(self);
+    ClientData_Detach(this);
+    PlayerScore_Detach(self);
 }
index 865010ff5c5a6d8afdfbd0f2280c4dbb1f46edef..982a426068517c811b6b91ad03bb3be4b3e3d3db 100644 (file)
@@ -244,7 +244,3 @@ void anticheat_init(entity this)
        this.anticheat_speedhack_offset = 0;
        this.anticheat_jointime = servertime;
 }
-
-void anticheat_shutdown()
-{
-}
index 5e6599b7e01730b7ce82a2948d0fb951e790a7eb..3bb5d251e95c1765ad20d0a6623ae578fbf03160 100644 (file)
@@ -3,7 +3,6 @@
 
 void anticheat_init(entity this);
 void anticheat_report();
-void anticheat_shutdown();
 
 void anticheat_physics(entity this);
 void anticheat_spectatecopy(entity spectatee);
index b6ed06d676d0c7ccf64236c47c3f40b7178b61f4..b82b19a4a7f3a9593e20c556a41ccc27c14562df 100644 (file)
@@ -36,7 +36,6 @@ float CheatCommand(float argc) { return 0; }
 float CheatFrame() { return 0; }
 void CheatInit() { cheatcount_total = world.cheatcount; }
 void CheatShutdown() { }
-void CheatShutdownClient() { }
 void Drag_MoveDrag(entity from, entity to) { }
 
 #else
@@ -55,10 +54,6 @@ void CheatShutdown()
 {
 }
 
-void CheatShutdownClient()
-{
-}
-
 float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as argument for possible future ACL checking
 {SELFPARAM();
        // dead people cannot cheat
index 7301df4a0968b1142b71d549ec5b408cf4771f28..4ead519eb0ff563390abf8afaf409c1288e79872 100644 (file)
@@ -9,7 +9,6 @@ float cheatcount_total;
 .float cheatcount;
 void CheatInit();
 void CheatShutdown();
-void CheatShutdownClient();
 float CheatImpulse(int imp);
 float CheatCommand(float argc);
 float CheatFrame();
index 67b1dbe99b060c43f5eee9572cc7a4b7ea4fcb54..3bc33a92c12189ae2bc5a8c91f82d7b8b2d803fd 100644 (file)
@@ -285,9 +285,7 @@ void PutObserverInServer()
        setsize (self, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL)); // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
        self.view_ofs = '0 0 0'; // so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS"
 
-       PS(self).m_weapon = WEP_Null;
        self.weaponname = "";
-       PS(self).m_switchingweapon = WEP_Null;
        self.weaponmodel = "";
        for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
@@ -996,22 +994,7 @@ void ClientConnect()
 #endif
        this.version_nagtime = time + 10 + random() * 10;
 
-       // TODO: xonstat elo.txt support, until then just 404s
-       if (false && IS_REAL_CLIENT(this)) { PlayerStats_PlayerBasic_CheckUpdate(this); }
-
        ClientState_attach(this);
-       // TODO: fold all of these into ClientState
-       DecodeLevelParms(this);
-       PlayerScore_Attach(this);
-       ClientData_Attach(this);
-       accuracy_init(this);
-       Inventory_new(this);
-       playerdemo_init(this);
-       anticheat_init(this);
-       entcs_attach(this);
-       W_HitPlotOpen(this);
-
-       bot_clientconnect(this);
 
        // identify the right forced team
        if (autocvar_g_campaign)
@@ -1085,20 +1068,9 @@ void ClientConnect()
 
        FixClientCvars(this);
 
-       // Grappling hook
-       stuffcmd(this, "alias +hook +button6\n");
-       stuffcmd(this, "alias -hook -button6\n");
-
-       // Jetpack binds
-       stuffcmd(this, "alias +jetpack +button10\n");
-       stuffcmd(this, "alias -jetpack -button10\n");
-
        // get version info from player
        stuffcmd(this, "cmd clientversion $gameversion\n");
 
-       // get other cvars from player
-       GetCvars(0);
-
        // notify about available teams
        if (teamplay)
        {
@@ -1167,45 +1139,24 @@ Called when a client disconnects from the server
 */
 .entity chatbubbleentity;
 void ReadyCount();
-void ClientDisconnect ()
+void ClientDisconnect()
 {
        SELFPARAM();
-       ClientState_detach(this);
-       if(self.vehicle)
-           vehicles_exit(VHEF_RELEASE);
+       assert(IS_CLIENT(this), return);
 
-       if (!IS_CLIENT(self))
-       {
-               LOG_INFO("Warning: ClientDisconnect without ClientConnect\n");
-               return;
-       }
-
-       PlayerStats_GameReport_FinalizePlayer(self);
-
-       if ( self.active_minigame )
-               part_minigame(self);
-
-       if(IS_PLAYER(self)) { Send_Effect(EFFECT_SPAWN_NEUTRAL, self.origin, '0 0 0', 1); }
+       PlayerStats_GameReport_FinalizePlayer(this);
+       if (this.vehicle) vehicles_exit(VHEF_RELEASE);
+       if (this.active_minigame) part_minigame(this);
+       if (IS_PLAYER(this)) Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
 
-       CheatShutdownClient();
-
-       W_HitPlotClose(self);
-
-       anticheat_report();
-       anticheat_shutdown();
-
-       playerdemo_shutdown();
-
-       bot_clientdisconnect();
-
-       entcs_detach(self);
+       if (autocvar_sv_eventlog)
+               GameLogEcho(strcat(":part:", ftos(this.playerid)));
 
-       if(autocvar_sv_eventlog)
-               GameLogEcho(strcat(":part:", ftos(self.playerid)));
+       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_DISCONNECT, this.netname);
 
-       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_DISCONNECT, self.netname);
+    MUTATOR_CALLHOOK(ClientDisconnect);
 
-       MUTATOR_CALLHOOK(ClientDisconnect);
+       ClientState_detach(this);
 
        Portal_ClearAll(self);
 
@@ -1217,39 +1168,21 @@ void ClientDisconnect ()
 
        self.flags &= ~FL_CLIENT;
 
-       if (self.chatbubbleentity)
-               remove (self.chatbubbleentity);
-
-       if (self.killindicator)
-               remove (self.killindicator);
+       if (this.chatbubbleentity) remove(this.chatbubbleentity);
+       if (this.killindicator) remove(this.killindicator);
 
        WaypointSprite_PlayerGone();
 
        bot_relinkplayerlist();
 
-       accuracy_free(self);
-       Inventory_delete(self);
-       ClientData_Detach(this);
-       PlayerScore_Detach(self);
-
-       if(self.netname_previous)
-               strunzone(self.netname_previous);
-       if(self.clientstatus)
-               strunzone(self.clientstatus);
-       if(self.weaponorder_byimpulse)
-               strunzone(self.weaponorder_byimpulse);
+       if (self.netname_previous) strunzone(self.netname_previous);
+       if (self.clientstatus) strunzone(self.clientstatus);
+       if (self.weaponorder_byimpulse) strunzone(self.weaponorder_byimpulse);
+       if (self.personal) remove(self.personal);
 
-       if(self.personal)
-               remove(self.personal);
-
-       self.playerid = 0;
+       this.playerid = 0;
        ReadyCount();
-       if(vote_called)
-       if(IS_REAL_CLIENT(self))
-               VoteCount(false);
-
-       // free cvars
-       GetCvars(-1);
+       if (vote_called && IS_REAL_CLIENT(this)) VoteCount(false);
 }
 
 void ChatBubbleThink()
index e01a9904f5186c9aee8e4335914b107b9e42e77d..4e4d69b0663aa3344c9ae8682cd702eeb2a612a1 100644 (file)
@@ -349,7 +349,7 @@ float PlayerScore_Add(entity player, float scorefield, float score)
        {
                if(gameover)
                        return 0;
-               backtrace("Adding score to unknown player!");
+               LOG_WARNING("Adding score to unknown player!");
                return 0;
        }
        if(score)