X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcl_client.qh;h=337c4db838c3e73ed0b95b60fd58658d22315cb2;hb=c0da80fe6125a43ee99a90808ac6f9d0ddcf88c8;hp=213a02945905db6e2ff65ab856cc236e3807ad74;hpb=6f37a8f8076a572097afb13de2c367a72717c927;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_client.qh b/qcsrc/server/cl_client.qh index 213a02945..337c4db83 100644 --- a/qcsrc/server/cl_client.qh +++ b/qcsrc/server/cl_client.qh @@ -1,13 +1,109 @@ -#ifndef CL_CLIENT_H -#define CL_CLIENT_H +#pragma once + +void ClientState_attach(entity this); + +CLASS(Client, Object) + /** Client name */ + ATTRIB(Client, netname, string, this.netname) + ATTRIB(Client, colormap, int, this.colormap) + ATTRIB(Client, team, int, this.team) + ATTRIB(Client, clientcolors, int, this.clientcolors) + /** Client IP */ + ATTRIB(Client, netaddress, string, this.netaddress) + ATTRIB(Client, playermodel, string, this.playermodel) + ATTRIB(Client, playerskin, int, this.playerskin) + + /** fingerprint of CA key the player used to authenticate */ + ATTRIB(Client, crypto_keyfp, string, this.crypto_keyfp) + /** fingerprint of CA key the server used to authenticate to the player */ + ATTRIB(Client, crypto_mykeyfp, string, this.crypto_mykeyfp) + /** fingerprint of ID used by the player entity, or string_null if not identified */ + ATTRIB(Client, crypto_idfp, string, this.crypto_idfp) + /** set if the player's ID has been signed */ + ATTRIB(Client, crypto_idfp_signed, bool, this.crypto_idfp_signed) + /** the string "AES128" if encrypting, and string_null if plaintext */ + ATTRIB(Client, crypto_encryptmethod, string, this.crypto_encryptmethod) + /** the string "HMAC-SHA256" if signing, and string_null if plaintext */ + ATTRIB(Client, crypto_signmethod, string, this.crypto_signmethod) + + // custom + + ATTRIB(Client, playerid, int, this.playerid) + + METHOD(Client, m_unwind, bool(Client this)); + + STATIC_METHOD(Client, Add, void(Client this, int _team)); + STATIC_METHOD(Client, Remove, void(Client this)); + + INIT(Client) { + if (this.m_unwind(this)) return this; + make_impure(this); + this.classname = "player_joining"; + static int playerid_last; + this.playerid = ++playerid_last; + ClientState_attach(this); + } + DESTRUCTOR(Client) { + Client_Remove(this); + } + CONSTRUCTOR(Client, string name) { + CONSTRUCT(Client); + this.netname = name; + this.netaddress = "local"; + this.playermodel = "models/player/megaerebus.iqm"; + } +ENDCLASS(Client) + +CLASS(Observer, Client) + INIT(Observer) { + this.classname = STR_OBSERVER; + } + DESTRUCTOR(Observer) { } +ENDCLASS(Observer) + +CLASS(Spectator, Client) + INIT(Spectator) { + this.classname = STR_SPECTATOR; + } + DESTRUCTOR(Spectator) { } +ENDCLASS(Spectator) + +CLASS(Player, Client) + INIT(Player) { + this.classname = STR_PLAYER; + } + DESTRUCTOR(Player) { } +ENDCLASS(Player) + +METHOD(Client, m_unwind, bool(Client this)) +{ + TC(Client, this); + #define UNWIND(class) MACRO_BEGIN if (this.instanceOf##class) { METHOD_REFERENCE(class, dtorimpl)(this); } MACRO_END + switch (this.classname) { + case "Observer": + UNWIND(Spectator); + UNWIND(Player); + return true; + case "Spectator": + UNWIND(Observer); + UNWIND(Player); + return true; + case "Player": + UNWIND(Observer); + UNWIND(Spectator); + return true; + } + #undef UNWIND + return false; +} + float c1, c2, c3, c4; -void play_countdown(float finished, string samp); +void play_countdown(float finished, Sound samp); float CalcRotRegen(float current, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime, float limit); float Spectate(entity pl); -void CTS_ClientKill (entity e); - -#endif +#define SPECTATE_COPY() [[accumulate]] void SpectateCopy(entity this, entity spectatee) +#define SPECTATE_COPYFIELD(fld) SPECTATE_COPY() { this.(fld) = spectatee.(fld); }