2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef GAME_SERVER_PLAYER_H
|
|
|
|
#define GAME_SERVER_PLAYER_H
|
|
|
|
|
2021-01-09 13:40:30 +00:00
|
|
|
#include "alloc.h"
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// this include should perhaps be removed
|
2020-05-26 21:22:16 +00:00
|
|
|
#include "score.h"
|
2020-06-10 16:12:10 +00:00
|
|
|
#include "teeinfo.h"
|
2020-05-26 21:22:16 +00:00
|
|
|
|
2021-01-09 14:06:11 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
WEAPON_GAME = -3, // team switching etc
|
|
|
|
WEAPON_SELF = -2, // console kill command
|
|
|
|
WEAPON_WORLD = -1, // death tiles etc
|
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// player object
|
|
|
|
class CPlayer
|
|
|
|
{
|
|
|
|
MACRO_ALLOC_POOL_ID()
|
2015-07-09 00:08:14 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
2011-02-12 10:40:36 +00:00
|
|
|
CPlayer(CGameContext *pGameServer, int ClientID, int Team);
|
2010-05-29 07:25:38 +00:00
|
|
|
~CPlayer();
|
|
|
|
|
2014-08-09 12:50:51 +00:00
|
|
|
void Reset();
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
void TryRespawn();
|
2016-03-04 21:55:12 +00:00
|
|
|
void Respawn(bool WeakHook = false); // with WeakHook == true the character will be spawned after all calls of Tick from other Players
|
2020-09-26 19:41:58 +00:00
|
|
|
CCharacter *ForceSpawn(vec2 Pos); // required for loading savegames
|
|
|
|
void SetTeam(int Team, bool DoChatMsg = true);
|
2022-03-08 19:01:26 +00:00
|
|
|
int GetTeam() const { return m_Team; }
|
|
|
|
int GetCID() const { return m_ClientID; }
|
2020-05-22 15:58:41 +00:00
|
|
|
int GetClientVersion() const;
|
2022-01-22 13:12:59 +00:00
|
|
|
bool SetTimerType(int TimerType);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void Tick();
|
2011-03-10 09:08:14 +00:00
|
|
|
void PostTick();
|
2016-03-04 21:55:12 +00:00
|
|
|
|
|
|
|
// will be called after all Tick and PostTick calls from other players
|
|
|
|
void PostPostTick();
|
2010-05-29 07:25:38 +00:00
|
|
|
void Snap(int SnappingClient);
|
2016-09-20 19:40:40 +00:00
|
|
|
void FakeSnap();
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
void OnDirectInput(CNetObj_PlayerInput *NewInput);
|
|
|
|
void OnPredictedInput(CNetObj_PlayerInput *NewInput);
|
2019-01-29 19:32:11 +00:00
|
|
|
void OnPredictedEarlyInput(CNetObj_PlayerInput *NewInput);
|
2021-01-12 20:03:20 +00:00
|
|
|
void OnDisconnect();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void KillCharacter(int Weapon = WEAPON_GAME);
|
|
|
|
CCharacter *GetCharacter();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2017-09-18 17:12:01 +00:00
|
|
|
void SpectatePlayerName(const char *pName);
|
2013-12-31 05:13:57 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// this is used for snapping so we know how we can clip the view for the player
|
|
|
|
vec2 m_ViewPos;
|
2014-03-12 23:56:39 +00:00
|
|
|
int m_TuneZone;
|
|
|
|
int m_TuneZoneOld;
|
2011-03-01 17:31:20 +00:00
|
|
|
|
|
|
|
// states if the client is chatting, accessing a menu etc.
|
|
|
|
int m_PlayerFlags;
|
|
|
|
|
|
|
|
// used for snapping to just update latency if the scoreboard is active
|
2022-04-01 16:32:51 +00:00
|
|
|
int m_aCurLatency[MAX_CLIENTS];
|
2011-03-10 09:08:14 +00:00
|
|
|
|
|
|
|
// used for spectator mode
|
|
|
|
int m_SpectatorID;
|
2011-03-15 08:58:57 +00:00
|
|
|
|
|
|
|
bool m_IsReady;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
//
|
|
|
|
int m_Vote;
|
|
|
|
int m_VotePos;
|
|
|
|
//
|
2011-03-10 09:08:14 +00:00
|
|
|
int m_LastVoteCall;
|
|
|
|
int m_LastVoteTry;
|
|
|
|
int m_LastChat;
|
|
|
|
int m_LastSetTeam;
|
|
|
|
int m_LastSetSpectatorMode;
|
|
|
|
int m_LastChangeInfo;
|
|
|
|
int m_LastEmote;
|
|
|
|
int m_LastKill;
|
2013-08-10 02:21:20 +00:00
|
|
|
int m_LastCommands[4];
|
|
|
|
int m_LastCommandPos;
|
2013-10-18 09:42:35 +00:00
|
|
|
int m_LastWhisperTo;
|
2017-04-24 12:04:50 +00:00
|
|
|
int m_LastInvited;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2014-10-26 18:39:42 +00:00
|
|
|
int m_SendVoteIndex;
|
|
|
|
|
2020-06-10 16:12:10 +00:00
|
|
|
CTeeInfo m_TeeInfos;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_DieTick;
|
2019-06-07 09:44:19 +00:00
|
|
|
int m_PreviousDieTick;
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_Score;
|
2016-01-27 01:14:46 +00:00
|
|
|
int m_JoinTick;
|
2010-05-29 07:25:38 +00:00
|
|
|
bool m_ForceBalanced;
|
2010-10-09 17:14:42 +00:00
|
|
|
int m_LastActionTick;
|
2011-05-23 11:06:38 +00:00
|
|
|
int m_TeamChangeTick;
|
2017-01-03 13:01:51 +00:00
|
|
|
bool m_SentSemicolonTip;
|
2011-03-10 09:08:14 +00:00
|
|
|
|
2011-04-13 18:37:12 +00:00
|
|
|
// network latency calculations
|
2011-03-10 09:08:14 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
int m_Accum;
|
|
|
|
int m_AccumMin;
|
|
|
|
int m_AccumMax;
|
|
|
|
int m_Avg;
|
|
|
|
int m_Min;
|
2011-04-13 18:37:12 +00:00
|
|
|
int m_Max;
|
2011-03-10 09:08:14 +00:00
|
|
|
} m_Latency;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
private:
|
2011-04-19 08:42:48 +00:00
|
|
|
CCharacter *m_pCharacter;
|
2014-11-25 19:33:21 +00:00
|
|
|
int m_NumInputs;
|
2010-05-29 07:25:38 +00:00
|
|
|
CGameContext *m_pGameServer;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CGameContext *GameServer() const { return m_pGameServer; }
|
|
|
|
IServer *Server() const;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
//
|
|
|
|
bool m_Spawning;
|
2016-03-04 21:55:12 +00:00
|
|
|
bool m_WeakHookSpawn;
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_ClientID;
|
|
|
|
int m_Team;
|
|
|
|
|
2017-04-08 22:20:41 +00:00
|
|
|
int m_Paused;
|
2021-06-23 05:05:49 +00:00
|
|
|
int64_t m_ForcePauseTime;
|
|
|
|
int64_t m_LastPause;
|
2011-01-29 00:59:50 +00:00
|
|
|
|
2021-01-12 19:25:25 +00:00
|
|
|
int m_DefEmote;
|
|
|
|
int m_OverrideEmote;
|
|
|
|
int m_OverrideEmoteReset;
|
|
|
|
bool m_Halloween;
|
|
|
|
|
2011-01-29 00:59:50 +00:00
|
|
|
public:
|
2011-12-29 13:58:39 +00:00
|
|
|
enum
|
2011-01-29 00:59:50 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
PAUSE_NONE = 0,
|
2017-04-08 22:20:41 +00:00
|
|
|
PAUSE_PAUSED,
|
|
|
|
PAUSE_SPEC
|
2011-12-29 13:58:39 +00:00
|
|
|
};
|
2019-10-13 15:13:03 +00:00
|
|
|
|
2017-02-27 22:10:19 +00:00
|
|
|
enum
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
TIMERTYPE_DEFAULT = -1,
|
|
|
|
TIMERTYPE_GAMETIMER = 0,
|
2017-02-27 22:10:19 +00:00
|
|
|
TIMERTYPE_BROADCAST,
|
|
|
|
TIMERTYPE_GAMETIMER_AND_BROADCAST,
|
2020-06-21 14:13:58 +00:00
|
|
|
TIMERTYPE_SIXUP,
|
2017-02-27 22:10:19 +00:00
|
|
|
TIMERTYPE_NONE,
|
|
|
|
};
|
2011-12-29 13:58:39 +00:00
|
|
|
|
2013-12-22 17:30:13 +00:00
|
|
|
bool m_DND;
|
2021-06-23 05:05:49 +00:00
|
|
|
int64_t m_FirstVoteTick;
|
2021-09-13 09:47:47 +00:00
|
|
|
char m_aTimeoutCode[64];
|
2011-12-29 13:58:39 +00:00
|
|
|
|
|
|
|
void ProcessPause();
|
2017-04-08 23:16:48 +00:00
|
|
|
int Pause(int State, bool Force);
|
2017-04-08 22:20:41 +00:00
|
|
|
int ForcePause(int Time);
|
|
|
|
int IsPaused();
|
|
|
|
|
2011-06-06 19:24:27 +00:00
|
|
|
bool IsPlaying();
|
2021-06-23 05:05:49 +00:00
|
|
|
int64_t m_Last_KickVote;
|
|
|
|
int64_t m_Last_Team;
|
2020-09-20 10:16:25 +00:00
|
|
|
int m_ShowOthers;
|
2014-02-02 18:56:10 +00:00
|
|
|
bool m_ShowAll;
|
2020-06-28 09:48:25 +00:00
|
|
|
vec2 m_ShowDistance;
|
2014-08-09 17:53:38 +00:00
|
|
|
bool m_SpecTeam;
|
2014-01-11 12:59:20 +00:00
|
|
|
bool m_NinjaJetpack;
|
2013-08-18 01:27:30 +00:00
|
|
|
bool m_Afk;
|
2017-07-05 21:01:57 +00:00
|
|
|
bool m_HasFinishScore;
|
2011-02-02 10:49:19 +00:00
|
|
|
|
2011-02-08 12:44:59 +00:00
|
|
|
int m_ChatScore;
|
|
|
|
|
2018-01-05 11:04:06 +00:00
|
|
|
bool m_Moderating;
|
|
|
|
|
2021-08-30 14:51:28 +00:00
|
|
|
bool AfkTimer(CNetObj_PlayerInput *pNewTarget); // returns true if kicked
|
2020-10-07 21:24:48 +00:00
|
|
|
void UpdatePlaytime();
|
2021-08-30 14:51:28 +00:00
|
|
|
void AfkVoteTimer(CNetObj_PlayerInput *pNewTarget);
|
2021-06-23 05:05:49 +00:00
|
|
|
int64_t m_LastPlaytime;
|
|
|
|
int64_t m_LastEyeEmote;
|
|
|
|
int64_t m_LastBroadcast;
|
2018-03-07 16:22:41 +00:00
|
|
|
bool m_LastBroadcastImportance;
|
2021-08-30 14:51:28 +00:00
|
|
|
|
2019-10-13 15:13:03 +00:00
|
|
|
CNetObj_PlayerInput *m_pLastTarget;
|
2022-01-17 11:58:12 +00:00
|
|
|
bool m_LastTargetInit;
|
2021-08-30 14:51:28 +00:00
|
|
|
/*
|
|
|
|
afk timer's 1st warning after 50% of sv_max_afk_time
|
|
|
|
2nd warning after 90%
|
|
|
|
kick after reaching 100% of sv_max_afk_time
|
|
|
|
*/
|
2021-08-30 15:08:18 +00:00
|
|
|
bool m_SentAfkWarning[2];
|
2021-08-30 14:51:28 +00:00
|
|
|
|
2021-01-12 19:11:42 +00:00
|
|
|
bool m_EyeEmoteEnabled;
|
2012-02-14 20:38:06 +00:00
|
|
|
int m_TimerType;
|
2021-01-12 19:15:10 +00:00
|
|
|
|
|
|
|
int GetDefaultEmote() const;
|
|
|
|
void OverrideDefaultEmote(int Emote, int Tick);
|
|
|
|
bool CanOverrideDefaultEmote() const;
|
|
|
|
|
2014-10-12 09:33:36 +00:00
|
|
|
bool m_FirstPacket;
|
2021-06-23 05:05:49 +00:00
|
|
|
int64_t m_LastSQLQuery;
|
2020-06-24 21:14:09 +00:00
|
|
|
void ProcessScoreResult(CScorePlayerResult &Result);
|
|
|
|
std::shared_ptr<CScorePlayerResult> m_ScoreQueryResult;
|
|
|
|
std::shared_ptr<CScorePlayerResult> m_ScoreFinishResult;
|
2018-12-17 13:55:58 +00:00
|
|
|
bool m_NotEligibleForFinish;
|
2021-06-23 05:05:49 +00:00
|
|
|
int64_t m_EligibleForFinishCheck;
|
2020-05-22 21:59:47 +00:00
|
|
|
bool m_VotedForPractice;
|
2021-03-20 16:08:54 +00:00
|
|
|
int m_SwapTargetsClientID; //Client ID of the swap target for the given player
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|