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 ENGINE_CLIENT_CLIENT_H
|
|
|
|
#define ENGINE_CLIENT_CLIENT_H
|
2009-10-29 12:14:31 +00:00
|
|
|
|
Make sure headers compile standalone
Not planning to do this automatically, but at least cleaning it up once
provides some benefit. Every header should include what it uses.
$ for i in src/**/*.h; do j=${i#"src/"}; echo $j; echo "#include <$j>\nint main() { return 0; }" | /usr/bin/c++ -DCONF_OPENSSL -DCONF_SQL -DCONF_VIDEORECORDER -DCONF_WAVPACK_CLOSE_FILE -DCONF_WAVPACK_OPEN_FILE_INPUT_EX -DGAME_RELEASE_VERSION=\"15.0.5\" -DGLEW_STATIC -D_FORTIFY_SOURCE=2 -I/usr/include/freetype2 -I/usr/include/opus -I/usr/include/SDL2 -I/usr/include/wavpack -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -Isrc -I/usr/include/mysql -I/home/deen/sys/include/ -O2 -g -DNDEBUG -fdiagnostics-color=always -fstack-protector-all -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wformat=2 -Wno-nullability-completeness -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -std=gnu++11 -o /dev/null -x c++ -; done
Ignored: tuning.h, variables.h, config_common.h, mapitems_ex_types.h, mapbugs_list.h, protocol7.h, teehistorian_ex_chunks.h, protocol_ex_msgs.h, config.h, config_variables.h, external, keynames.h
2020-09-26 08:23:33 +00:00
|
|
|
#include <list>
|
2017-11-23 14:47:38 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2018-06-05 19:22:40 +00:00
|
|
|
#include <base/hash.h>
|
Make sure headers compile standalone
Not planning to do this automatically, but at least cleaning it up once
provides some benefit. Every header should include what it uses.
$ for i in src/**/*.h; do j=${i#"src/"}; echo $j; echo "#include <$j>\nint main() { return 0; }" | /usr/bin/c++ -DCONF_OPENSSL -DCONF_SQL -DCONF_VIDEORECORDER -DCONF_WAVPACK_CLOSE_FILE -DCONF_WAVPACK_OPEN_FILE_INPUT_EX -DGAME_RELEASE_VERSION=\"15.0.5\" -DGLEW_STATIC -D_FORTIFY_SOURCE=2 -I/usr/include/freetype2 -I/usr/include/opus -I/usr/include/SDL2 -I/usr/include/wavpack -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -Isrc -I/usr/include/mysql -I/home/deen/sys/include/ -O2 -g -DNDEBUG -fdiagnostics-color=always -fstack-protector-all -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wformat=2 -Wno-nullability-completeness -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -std=gnu++11 -o /dev/null -x c++ -; done
Ignored: tuning.h, variables.h, config_common.h, mapitems_ex_types.h, mapbugs_list.h, protocol7.h, teehistorian_ex_chunks.h, protocol_ex_msgs.h, config.h, config_variables.h, external, keynames.h
2020-09-26 08:23:33 +00:00
|
|
|
#include <engine/client.h>
|
|
|
|
#include <engine/client/demoedit.h>
|
2020-09-10 18:14:47 +00:00
|
|
|
#include <engine/client/friends.h>
|
2020-10-10 21:01:57 +00:00
|
|
|
#include <engine/client/ghost.h>
|
2018-12-12 08:59:42 +00:00
|
|
|
#include <engine/client/http.h>
|
Make sure headers compile standalone
Not planning to do this automatically, but at least cleaning it up once
provides some benefit. Every header should include what it uses.
$ for i in src/**/*.h; do j=${i#"src/"}; echo $j; echo "#include <$j>\nint main() { return 0; }" | /usr/bin/c++ -DCONF_OPENSSL -DCONF_SQL -DCONF_VIDEORECORDER -DCONF_WAVPACK_CLOSE_FILE -DCONF_WAVPACK_OPEN_FILE_INPUT_EX -DGAME_RELEASE_VERSION=\"15.0.5\" -DGLEW_STATIC -D_FORTIFY_SOURCE=2 -I/usr/include/freetype2 -I/usr/include/opus -I/usr/include/SDL2 -I/usr/include/wavpack -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -Isrc -I/usr/include/mysql -I/home/deen/sys/include/ -O2 -g -DNDEBUG -fdiagnostics-color=always -fstack-protector-all -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wformat=2 -Wno-nullability-completeness -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -std=gnu++11 -o /dev/null -x c++ -; done
Ignored: tuning.h, variables.h, config_common.h, mapitems_ex_types.h, mapbugs_list.h, protocol7.h, teehistorian_ex_chunks.h, protocol_ex_msgs.h, config.h, config_variables.h, external, keynames.h
2020-09-26 08:23:33 +00:00
|
|
|
#include <engine/client/serverbrowser.h>
|
2020-09-03 12:08:26 +00:00
|
|
|
#include <engine/client/updater.h>
|
2021-01-17 23:52:58 +00:00
|
|
|
#include <engine/discord.h>
|
Make sure headers compile standalone
Not planning to do this automatically, but at least cleaning it up once
provides some benefit. Every header should include what it uses.
$ for i in src/**/*.h; do j=${i#"src/"}; echo $j; echo "#include <$j>\nint main() { return 0; }" | /usr/bin/c++ -DCONF_OPENSSL -DCONF_SQL -DCONF_VIDEORECORDER -DCONF_WAVPACK_CLOSE_FILE -DCONF_WAVPACK_OPEN_FILE_INPUT_EX -DGAME_RELEASE_VERSION=\"15.0.5\" -DGLEW_STATIC -D_FORTIFY_SOURCE=2 -I/usr/include/freetype2 -I/usr/include/opus -I/usr/include/SDL2 -I/usr/include/wavpack -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -Isrc -I/usr/include/mysql -I/home/deen/sys/include/ -O2 -g -DNDEBUG -fdiagnostics-color=always -fstack-protector-all -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wformat=2 -Wno-nullability-completeness -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -std=gnu++11 -o /dev/null -x c++ -; done
Ignored: tuning.h, variables.h, config_common.h, mapitems_ex_types.h, mapbugs_list.h, protocol7.h, teehistorian_ex_chunks.h, protocol_ex_msgs.h, config.h, config_variables.h, external, keynames.h
2020-09-26 08:23:33 +00:00
|
|
|
#include <engine/editor.h>
|
|
|
|
#include <engine/engine.h>
|
|
|
|
#include <engine/graphics.h>
|
|
|
|
#include <engine/input.h>
|
|
|
|
#include <engine/map.h>
|
|
|
|
#include <engine/masterserver.h>
|
|
|
|
#include <engine/shared/config.h>
|
|
|
|
#include <engine/shared/demo.h>
|
|
|
|
#include <engine/shared/fifo.h>
|
|
|
|
#include <engine/shared/network.h>
|
|
|
|
#include <engine/sound.h>
|
|
|
|
#include <engine/steam.h>
|
2020-10-02 13:43:52 +00:00
|
|
|
#include <engine/warning.h>
|
2017-11-23 14:47:38 +00:00
|
|
|
|
2018-12-13 18:57:32 +00:00
|
|
|
#define CONNECTLINK "ddnet:"
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CGraph
|
2009-10-29 12:14:31 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-05-29 07:25:38 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
// restrictions: Must be power of two
|
2020-09-26 19:41:58 +00:00
|
|
|
MAX_VALUES = 128,
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
float m_Min, m_Max;
|
|
|
|
float m_aValues[MAX_VALUES];
|
|
|
|
float m_aColors[MAX_VALUES][3];
|
|
|
|
int m_Index;
|
|
|
|
|
|
|
|
void Init(float Min, float Max);
|
|
|
|
|
|
|
|
void ScaleMax();
|
|
|
|
void ScaleMin();
|
|
|
|
|
|
|
|
void Add(float v, float r, float g, float b);
|
2012-08-12 10:41:50 +00:00
|
|
|
void Render(IGraphics *pGraphics, IGraphics::CTextureHandle FontTexture, float x, float y, float w, float h, const char *pDescription);
|
2009-10-29 12:14:31 +00:00
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CSmoothTime
|
2009-10-29 12:14:31 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
int64 m_Snap;
|
|
|
|
int64 m_Current;
|
|
|
|
int64 m_Target;
|
|
|
|
|
|
|
|
CGraph m_Graph;
|
|
|
|
|
|
|
|
int m_SpikeCounter;
|
|
|
|
|
|
|
|
float m_aAdjustSpeed[2]; // 0 = down, 1 = up
|
2009-10-29 12:14:31 +00:00
|
|
|
public:
|
2010-05-29 07:25:38 +00:00
|
|
|
void Init(int64 Target);
|
|
|
|
void SetAdjustSpeed(int Direction, float Value);
|
|
|
|
|
|
|
|
int64 Get(int64 Now);
|
|
|
|
|
|
|
|
void UpdateInt(int64 Target);
|
|
|
|
void Update(CGraph *pGraph, int64 Target, int TimeLeft, int AdjustDirection);
|
2009-10-29 12:14:31 +00:00
|
|
|
};
|
|
|
|
|
2019-06-03 19:52:14 +00:00
|
|
|
class CServerCapabilities
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool m_ChatTimeoutCode;
|
2021-01-10 16:23:00 +00:00
|
|
|
bool m_AnyPlayerFlag;
|
2021-04-23 21:29:01 +00:00
|
|
|
bool m_PingEx;
|
2019-06-03 19:52:14 +00:00
|
|
|
};
|
|
|
|
|
2016-04-27 15:05:30 +00:00
|
|
|
class CClient : public IClient, public CDemoPlayer::IListener
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
|
|
|
// needed interfaces
|
2011-02-27 14:03:57 +00:00
|
|
|
IEngine *m_pEngine;
|
2010-05-29 07:25:38 +00:00
|
|
|
IEditor *m_pEditor;
|
|
|
|
IEngineInput *m_pInput;
|
|
|
|
IEngineGraphics *m_pGraphics;
|
|
|
|
IEngineSound *m_pSound;
|
|
|
|
IGameClient *m_pGameClient;
|
|
|
|
IEngineMap *m_pMap;
|
2021-01-10 12:47:07 +00:00
|
|
|
IConfigManager *m_pConfigManager;
|
|
|
|
CConfig *m_pConfig;
|
2010-05-29 07:25:38 +00:00
|
|
|
IConsole *m_pConsole;
|
|
|
|
IStorage *m_pStorage;
|
2015-04-18 19:17:27 +00:00
|
|
|
IUpdater *m_pUpdater;
|
2021-01-17 23:52:58 +00:00
|
|
|
IDiscord *m_pDiscord;
|
2020-08-20 10:17:44 +00:00
|
|
|
ISteam *m_pSteam;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
NUM_SNAPSHOT_TYPES = 2,
|
|
|
|
PREDICTION_MARGIN = 1000 / 50 / 2, // magic network prediction value
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
2019-11-10 12:38:10 +00:00
|
|
|
enum
|
|
|
|
{
|
2020-10-18 14:51:26 +00:00
|
|
|
CLIENT_MAIN = 0,
|
2019-11-10 12:38:10 +00:00
|
|
|
CLIENT_DUMMY,
|
|
|
|
CLIENT_CONTACT,
|
|
|
|
NUM_CLIENTS,
|
|
|
|
};
|
|
|
|
|
|
|
|
class CNetClient m_NetClient[NUM_CLIENTS];
|
2011-02-27 14:03:57 +00:00
|
|
|
class CDemoPlayer m_DemoPlayer;
|
2014-10-16 15:42:13 +00:00
|
|
|
class CDemoRecorder m_DemoRecorder[RECORDER_MAX];
|
2014-08-12 14:21:06 +00:00
|
|
|
class CDemoEditor m_DemoEditor;
|
2017-09-09 15:04:19 +00:00
|
|
|
class CGhostRecorder m_GhostRecorder;
|
|
|
|
class CGhostLoader m_GhostLoader;
|
2011-02-27 14:03:57 +00:00
|
|
|
class CServerBrowser m_ServerBrowser;
|
2015-04-18 19:17:27 +00:00
|
|
|
class CUpdater m_Updater;
|
2011-03-23 12:06:35 +00:00
|
|
|
class CFriends m_Friends;
|
2015-07-22 20:16:49 +00:00
|
|
|
class CFriends m_Foes;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
char m_aServerAddressStr[256];
|
|
|
|
|
2020-05-22 15:58:41 +00:00
|
|
|
CUuid m_ConnectionID;
|
|
|
|
|
2020-10-18 14:51:26 +00:00
|
|
|
unsigned m_SnapshotParts[NUM_DUMMIES];
|
2010-05-29 07:25:38 +00:00
|
|
|
int64 m_LocalStartTime;
|
|
|
|
|
2012-08-12 10:41:50 +00:00
|
|
|
IGraphics::CTextureHandle m_DebugFont;
|
2019-06-05 17:17:55 +00:00
|
|
|
int m_DebugSoundIndex = 0;
|
2015-07-09 00:08:14 +00:00
|
|
|
|
2012-01-01 12:38:46 +00:00
|
|
|
int64 m_LastRenderTime;
|
|
|
|
float m_RenderFrameTimeLow;
|
|
|
|
float m_RenderFrameTimeHigh;
|
|
|
|
int m_RenderFrames;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
NETADDR m_ServerAddress;
|
|
|
|
int m_SnapCrcErrors;
|
2010-12-12 15:48:13 +00:00
|
|
|
bool m_AutoScreenshotRecycle;
|
2015-05-19 22:51:02 +00:00
|
|
|
bool m_AutoStatScreenshotRecycle;
|
2017-04-26 03:10:31 +00:00
|
|
|
bool m_AutoCSVRecycle;
|
2011-01-17 11:28:37 +00:00
|
|
|
bool m_EditorActive;
|
2011-01-17 12:28:15 +00:00
|
|
|
bool m_SoundInitFailed;
|
2011-03-18 18:03:13 +00:00
|
|
|
bool m_ResortServerBrowser;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2020-10-18 14:51:26 +00:00
|
|
|
int m_AckGameTick[NUM_DUMMIES];
|
|
|
|
int m_CurrentRecvTick[NUM_DUMMIES];
|
|
|
|
int m_RconAuthed[NUM_DUMMIES];
|
2014-08-22 11:54:13 +00:00
|
|
|
char m_RconPassword[32];
|
2011-07-14 20:07:21 +00:00
|
|
|
int m_UseTempRconCommands;
|
2017-07-15 15:29:20 +00:00
|
|
|
char m_Password[32];
|
2018-06-15 23:44:24 +00:00
|
|
|
bool m_SendPassword;
|
2020-09-26 19:41:58 +00:00
|
|
|
bool m_ButtonRender = false;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
// version-checking
|
|
|
|
char m_aVersionStr[10];
|
|
|
|
|
|
|
|
// pinging
|
|
|
|
int64 m_PingStartTime;
|
|
|
|
|
2019-03-12 17:43:03 +00:00
|
|
|
char m_aCurrentMap[MAX_PATH_LENGTH];
|
|
|
|
char m_aCurrentMapPath[MAX_PATH_LENGTH];
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2020-10-18 14:51:26 +00:00
|
|
|
char m_aTimeoutCodes[NUM_DUMMIES][32];
|
|
|
|
bool m_aTimeoutCodeSent[NUM_DUMMIES];
|
2016-10-02 09:31:11 +00:00
|
|
|
bool m_GenerateTimeoutSeed;
|
2014-08-17 17:19:40 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
//
|
|
|
|
char m_aCmdConnect[256];
|
2019-04-08 19:42:49 +00:00
|
|
|
char m_aCmdPlayDemo[MAX_PATH_LENGTH];
|
2020-08-02 11:00:01 +00:00
|
|
|
char m_aCmdEditMap[MAX_PATH_LENGTH];
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
// map download
|
2018-06-19 12:45:53 +00:00
|
|
|
std::shared_ptr<CGetFile> m_pMapdownloadTask;
|
2010-05-29 07:25:38 +00:00
|
|
|
char m_aMapdownloadFilename[256];
|
|
|
|
char m_aMapdownloadName[256];
|
|
|
|
IOHANDLE m_MapdownloadFile;
|
|
|
|
int m_MapdownloadChunk;
|
|
|
|
int m_MapdownloadCrc;
|
|
|
|
int m_MapdownloadAmount;
|
|
|
|
int m_MapdownloadTotalsize;
|
2018-06-05 19:22:40 +00:00
|
|
|
bool m_MapdownloadSha256Present;
|
|
|
|
SHA256_DIGEST m_MapdownloadSha256;
|
|
|
|
|
|
|
|
bool m_MapDetailsPresent;
|
|
|
|
char m_aMapDetailsName[256];
|
|
|
|
int m_MapDetailsCrc;
|
|
|
|
SHA256_DIGEST m_MapDetailsSha256;
|
2017-09-03 15:36:51 +00:00
|
|
|
|
2020-02-12 21:39:37 +00:00
|
|
|
char m_aDDNetInfoTmp[64];
|
2018-06-19 12:45:53 +00:00
|
|
|
std::shared_ptr<CGetFile> m_pDDNetInfoTask;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
// time
|
2020-10-18 14:51:26 +00:00
|
|
|
CSmoothTime m_GameTime[NUM_DUMMIES];
|
2014-05-03 21:28:48 +00:00
|
|
|
CSmoothTime m_PredictedTime;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
// input
|
|
|
|
struct // TODO: handle input better
|
|
|
|
{
|
|
|
|
int m_aData[MAX_INPUT_SIZE]; // the input data
|
|
|
|
int m_Tick; // the tick that the input is for
|
|
|
|
int64 m_PredictedTime; // prediction latency when we sent this input
|
|
|
|
int64 m_Time;
|
2020-10-18 14:51:26 +00:00
|
|
|
} m_aInputs[NUM_DUMMIES][200];
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2020-10-18 14:51:26 +00:00
|
|
|
int m_CurrentInput[NUM_DUMMIES];
|
2014-04-28 18:43:08 +00:00
|
|
|
bool m_LastDummy;
|
2017-02-28 09:08:14 +00:00
|
|
|
bool m_DummySendConnInfo;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
// graphs
|
|
|
|
CGraph m_InputtimeMarginGraph;
|
|
|
|
CGraph m_GametimeMarginGraph;
|
|
|
|
CGraph m_FpsGraph;
|
|
|
|
|
|
|
|
// the game snapshots are modifiable by the game
|
2020-10-18 14:51:26 +00:00
|
|
|
class CSnapshotStorage m_SnapshotStorage[NUM_DUMMIES];
|
|
|
|
CSnapshotStorage::CHolder *m_aSnapshots[NUM_DUMMIES][NUM_SNAPSHOT_TYPES];
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2020-10-18 14:51:26 +00:00
|
|
|
int m_ReceivedSnapshots[NUM_DUMMIES];
|
2016-01-23 20:44:45 +00:00
|
|
|
char m_aSnapshotIncomingData[CSnapshot::MAX_SIZE];
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-02-27 14:03:57 +00:00
|
|
|
class CSnapshotStorage::CHolder m_aDemorecSnapshotHolders[NUM_SNAPSHOT_TYPES];
|
2010-05-29 07:25:38 +00:00
|
|
|
char *m_aDemorecSnapshotData[NUM_SNAPSHOT_TYPES][2][CSnapshot::MAX_SIZE];
|
|
|
|
|
2011-02-27 14:03:57 +00:00
|
|
|
class CSnapshotDelta m_SnapshotDelta;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2019-05-28 11:24:55 +00:00
|
|
|
std::list<std::shared_ptr<CDemoEdit>> m_EditJobs;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
//
|
2019-06-13 22:24:50 +00:00
|
|
|
bool m_CanReceiveServerCapabilities;
|
2019-06-03 19:52:14 +00:00
|
|
|
bool m_ServerSentCapabilities;
|
|
|
|
CServerCapabilities m_ServerCapabilities;
|
|
|
|
|
|
|
|
bool ShouldSendChatTimeoutCodeHeuristic();
|
|
|
|
|
2011-02-27 14:03:57 +00:00
|
|
|
class CServerInfo m_CurrentServerInfo;
|
2010-05-29 07:25:38 +00:00
|
|
|
int64 m_CurrentServerInfoRequestTime; // >= 0 should request, == -1 got info
|
|
|
|
|
2021-04-23 21:12:16 +00:00
|
|
|
int m_CurrentServerPingInfoType;
|
|
|
|
int m_CurrentServerPingBasicToken;
|
|
|
|
int m_CurrentServerPingToken;
|
2021-04-24 12:23:35 +00:00
|
|
|
CUuid m_CurrentServerPingUuid;
|
2021-04-23 21:12:16 +00:00
|
|
|
int64 m_CurrentServerCurrentPingTime; // >= 0 request running
|
|
|
|
int64 m_CurrentServerNextPingTime; // >= 0 should request
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// version info
|
2011-03-17 16:41:57 +00:00
|
|
|
struct CVersionInfo
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
2011-03-17 16:41:57 +00:00
|
|
|
enum
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
STATE_INIT = 0,
|
2011-03-17 16:41:57 +00:00
|
|
|
STATE_START,
|
|
|
|
STATE_READY,
|
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_State;
|
2011-02-27 14:03:57 +00:00
|
|
|
class CHostLookup m_VersionServeraddr;
|
2010-05-29 07:25:38 +00:00
|
|
|
} m_VersionInfo;
|
2011-02-27 14:03:57 +00:00
|
|
|
|
2011-12-30 15:02:22 +00:00
|
|
|
volatile int m_GfxState;
|
2020-09-26 19:41:58 +00:00
|
|
|
static void GraphicsThreadProxy(void *pThis) { ((CClient *)pThis)->GraphicsThread(); }
|
2011-12-30 15:02:22 +00:00
|
|
|
void GraphicsThread();
|
|
|
|
|
2020-10-02 13:43:52 +00:00
|
|
|
std::vector<SWarning> m_Warnings;
|
|
|
|
|
2016-05-02 21:36:21 +00:00
|
|
|
#if defined(CONF_FAMILY_UNIX)
|
|
|
|
CFifo m_Fifo;
|
|
|
|
#endif
|
|
|
|
|
2020-11-19 15:15:07 +00:00
|
|
|
IOHANDLE m_BenchmarkFile;
|
|
|
|
int64 m_BenchmarkStopTime;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
2011-02-27 14:03:57 +00:00
|
|
|
IEngine *Engine() { return m_pEngine; }
|
2010-05-29 07:25:38 +00:00
|
|
|
IEngineGraphics *Graphics() { return m_pGraphics; }
|
|
|
|
IEngineInput *Input() { return m_pInput; }
|
|
|
|
IEngineSound *Sound() { return m_pSound; }
|
|
|
|
IGameClient *GameClient() { return m_pGameClient; }
|
2021-01-10 12:47:07 +00:00
|
|
|
IConfigManager *ConfigManager() { return m_pConfigManager; }
|
|
|
|
CConfig *Config() { return m_pConfig; }
|
2010-05-29 07:25:38 +00:00
|
|
|
IStorage *Storage() { return m_pStorage; }
|
2015-04-18 19:17:27 +00:00
|
|
|
IUpdater *Updater() { return m_pUpdater; }
|
2021-01-17 23:52:58 +00:00
|
|
|
IDiscord *Discord() { return m_pDiscord; }
|
2020-08-20 10:17:44 +00:00
|
|
|
ISteam *Steam() { return m_pSteam; }
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
CClient();
|
|
|
|
|
|
|
|
// ----- send functions -----
|
|
|
|
virtual int SendMsg(CMsgPacker *pMsg, int Flags);
|
2020-09-26 19:41:58 +00:00
|
|
|
virtual int SendMsgY(CMsgPacker *pMsg, int Flags, int NetClient = 1);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
void SendInfo();
|
|
|
|
void SendEnterGame();
|
|
|
|
void SendReady();
|
2014-10-29 12:37:38 +00:00
|
|
|
void SendMapRequest();
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2021-02-08 21:26:26 +00:00
|
|
|
virtual bool RconAuthed() const { return m_RconAuthed[g_Config.m_ClDummy] != 0; }
|
|
|
|
virtual bool UseTempRconCommands() const { return m_UseTempRconCommands != 0; }
|
2010-05-29 07:25:38 +00:00
|
|
|
void RconAuth(const char *pName, const char *pPassword);
|
|
|
|
virtual void Rcon(const char *pCmd);
|
|
|
|
|
2021-02-08 21:26:26 +00:00
|
|
|
virtual bool ConnectionProblems() const;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2021-02-08 21:26:26 +00:00
|
|
|
virtual bool SoundInitFailed() const { return m_SoundInitFailed; }
|
2011-01-17 12:28:15 +00:00
|
|
|
|
2021-02-08 21:26:26 +00:00
|
|
|
virtual IGraphics::CTextureHandle GetDebugFont() const { return m_DebugFont; }
|
2011-02-18 10:41:27 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void DirectInput(int *pInput, int Size);
|
|
|
|
void SendInput();
|
|
|
|
|
2018-02-04 15:00:47 +00:00
|
|
|
// TODO: OPT: do this a lot smarter!
|
2021-02-08 21:26:26 +00:00
|
|
|
virtual int *GetInput(int Tick, int IsDummy) const;
|
|
|
|
virtual int *GetDirectInput(int Tick, int IsDummy) const;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2021-02-08 21:26:26 +00:00
|
|
|
const char *LatestVersion() const;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
// ------ state handling -----
|
|
|
|
void SetState(int s);
|
|
|
|
|
|
|
|
// called when the map is loaded and we should init for a new round
|
|
|
|
void OnEnterGame();
|
|
|
|
virtual void EnterGame();
|
|
|
|
|
2017-07-15 15:29:20 +00:00
|
|
|
virtual void Connect(const char *pAddress, const char *pPassword = NULL);
|
2010-05-29 07:25:38 +00:00
|
|
|
void DisconnectWithReason(const char *pReason);
|
|
|
|
virtual void Disconnect();
|
|
|
|
|
2014-04-26 18:29:42 +00:00
|
|
|
virtual void DummyDisconnect(const char *pReason);
|
2014-04-28 13:19:57 +00:00
|
|
|
virtual void DummyConnect();
|
2014-04-26 18:29:42 +00:00
|
|
|
virtual bool DummyConnected();
|
2015-04-19 12:40:05 +00:00
|
|
|
virtual bool DummyConnecting();
|
2014-04-26 18:29:42 +00:00
|
|
|
int m_DummyConnected;
|
|
|
|
int m_LastDummyConnectTime;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2021-02-08 21:26:26 +00:00
|
|
|
virtual void GetServerInfo(CServerInfo *pServerInfo) const;
|
2010-05-29 07:25:38 +00:00
|
|
|
void ServerInfoRequest();
|
|
|
|
|
|
|
|
int LoadData();
|
|
|
|
|
|
|
|
// ---
|
|
|
|
|
2016-05-05 16:07:00 +00:00
|
|
|
int GetPredictionTime();
|
2021-02-08 21:26:26 +00:00
|
|
|
void *SnapGetItem(int SnapID, int Index, CSnapItem *pItem) const;
|
|
|
|
int SnapItemSize(int SnapID, int Index) const;
|
2011-02-12 10:40:36 +00:00
|
|
|
void SnapInvalidateItem(int SnapID, int Index);
|
2021-02-08 21:26:26 +00:00
|
|
|
void *SnapFindItem(int SnapID, int Type, int ID) const;
|
|
|
|
int SnapNumItems(int SnapID) const;
|
2010-05-29 07:25:38 +00:00
|
|
|
void SnapSetStaticsize(int ItemType, int Size);
|
|
|
|
|
|
|
|
void Render();
|
|
|
|
void DebugRender();
|
|
|
|
|
2014-12-31 14:35:49 +00:00
|
|
|
virtual void Restart();
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void Quit();
|
|
|
|
|
2021-02-08 21:26:26 +00:00
|
|
|
virtual const char *PlayerName() const;
|
|
|
|
virtual const char *DummyName() const;
|
|
|
|
virtual const char *ErrorString() const;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2018-06-05 19:22:40 +00:00
|
|
|
const char *LoadMap(const char *pName, const char *pFilename, SHA256_DIGEST *pWantedSha256, unsigned WantedCrc);
|
|
|
|
const char *LoadMapSearch(const char *pMapName, SHA256_DIGEST *pWantedSha256, int WantedCrc);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-03-17 16:41:57 +00:00
|
|
|
void ProcessConnlessPacket(CNetChunk *pPacket);
|
2017-03-29 10:56:13 +00:00
|
|
|
void ProcessServerInfo(int Type, NETADDR *pFrom, const void *pData, int DataSize);
|
2011-03-17 16:41:57 +00:00
|
|
|
void ProcessServerPacket(CNetChunk *pPacket);
|
2014-05-03 00:30:05 +00:00
|
|
|
void ProcessServerPacketDummy(CNetChunk *pPacket);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2014-10-29 12:37:38 +00:00
|
|
|
void ResetMapDownload();
|
|
|
|
void FinishMapDownload();
|
2017-09-03 15:36:51 +00:00
|
|
|
|
|
|
|
void RequestDDNetInfo();
|
|
|
|
void ResetDDNetInfo();
|
2020-09-09 15:49:29 +00:00
|
|
|
bool IsDDNetInfoChanged();
|
2017-09-03 15:36:51 +00:00
|
|
|
void FinishDDNetInfo();
|
|
|
|
void LoadDDNetInfo();
|
2014-10-29 12:37:38 +00:00
|
|
|
|
2021-02-08 21:26:26 +00:00
|
|
|
virtual const char *MapDownloadName() const { return m_aMapdownloadName; }
|
|
|
|
virtual int MapDownloadAmount() const { return !m_pMapdownloadTask ? m_MapdownloadAmount : (int)m_pMapdownloadTask->Current(); }
|
|
|
|
virtual int MapDownloadTotalsize() const { return !m_pMapdownloadTask ? m_MapdownloadTotalsize : (int)m_pMapdownloadTask->Size(); }
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
void PumpNetwork();
|
|
|
|
|
|
|
|
virtual void OnDemoPlayerSnapshot(void *pData, int Size);
|
|
|
|
virtual void OnDemoPlayerMessage(void *pData, int Size);
|
|
|
|
|
|
|
|
void Update();
|
|
|
|
|
|
|
|
void RegisterInterfaces();
|
|
|
|
void InitInterfaces();
|
|
|
|
|
|
|
|
void Run();
|
|
|
|
|
2014-01-31 00:41:57 +00:00
|
|
|
bool CtrlShiftKey(int Key, bool &Last);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
static void Con_Connect(IConsole::IResult *pResult, void *pUserData);
|
|
|
|
static void Con_Disconnect(IConsole::IResult *pResult, void *pUserData);
|
2014-04-26 18:29:42 +00:00
|
|
|
|
|
|
|
static void Con_DummyConnect(IConsole::IResult *pResult, void *pUserData);
|
|
|
|
static void Con_DummyDisconnect(IConsole::IResult *pResult, void *pUserData);
|
2021-03-17 15:09:39 +00:00
|
|
|
static void Con_DummyResetInput(IConsole::IResult *pResult, void *pUserData);
|
2014-04-26 18:29:42 +00:00
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
static void Con_Quit(IConsole::IResult *pResult, void *pUserData);
|
2015-08-12 12:26:48 +00:00
|
|
|
static void Con_DemoPlay(IConsole::IResult *pResult, void *pUserData);
|
2016-04-27 15:21:40 +00:00
|
|
|
static void Con_DemoSpeed(IConsole::IResult *pResult, void *pUserData);
|
2011-08-13 00:11:06 +00:00
|
|
|
static void Con_Minimize(IConsole::IResult *pResult, void *pUserData);
|
|
|
|
static void Con_Ping(IConsole::IResult *pResult, void *pUserData);
|
|
|
|
static void Con_Screenshot(IConsole::IResult *pResult, void *pUserData);
|
2016-08-27 19:10:27 +00:00
|
|
|
|
|
|
|
#if defined(CONF_VIDEORECORDER)
|
2019-09-27 03:06:02 +00:00
|
|
|
static void StartVideo(IConsole::IResult *pResult, void *pUserData, const char *pVideName);
|
2016-08-27 15:51:23 +00:00
|
|
|
static void Con_StartVideo(IConsole::IResult *pResult, void *pUserData);
|
|
|
|
static void Con_StopVideo(IConsole::IResult *pResult, void *pUserData);
|
2019-09-28 04:18:38 +00:00
|
|
|
const char *DemoPlayer_Render(const char *pFilename, int StorageType, const char *pVideoName, int SpeedIndex);
|
2016-08-27 19:10:27 +00:00
|
|
|
#endif
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
static void Con_Rcon(IConsole::IResult *pResult, void *pUserData);
|
|
|
|
static void Con_RconAuth(IConsole::IResult *pResult, void *pUserData);
|
2017-03-06 09:31:05 +00:00
|
|
|
static void Con_RconLogin(IConsole::IResult *pResult, void *pUserData);
|
2011-08-13 00:11:06 +00:00
|
|
|
static void Con_AddFavorite(IConsole::IResult *pResult, void *pUserData);
|
|
|
|
static void Con_RemoveFavorite(IConsole::IResult *pResult, void *pUserData);
|
|
|
|
static void Con_Play(IConsole::IResult *pResult, void *pUserData);
|
|
|
|
static void Con_Record(IConsole::IResult *pResult, void *pUserData);
|
|
|
|
static void Con_StopRecord(IConsole::IResult *pResult, void *pUserData);
|
2012-01-10 22:13:19 +00:00
|
|
|
static void Con_AddDemoMarker(IConsole::IResult *pResult, void *pUserData);
|
2020-11-19 15:15:07 +00:00
|
|
|
static void Con_BenchmarkQuit(IConsole::IResult *pResult, void *pUserData);
|
2011-03-18 18:03:13 +00:00
|
|
|
static void ConchainServerBrowserUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
2016-04-29 22:34:12 +00:00
|
|
|
static void ConchainFullscreen(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
|
|
|
static void ConchainWindowBordered(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
|
|
|
static void ConchainWindowScreen(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
|
|
|
static void ConchainWindowVSync(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
2016-10-02 09:31:11 +00:00
|
|
|
static void ConchainTimeoutSeed(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
2018-06-20 06:36:10 +00:00
|
|
|
static void ConchainPassword(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
2019-06-05 17:17:55 +00:00
|
|
|
static void ConchainReplays(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
2019-04-21 16:20:53 +00:00
|
|
|
|
2014-08-12 14:21:06 +00:00
|
|
|
static void Con_DemoSlice(IConsole::IResult *pResult, void *pUserData);
|
2014-08-13 14:35:15 +00:00
|
|
|
static void Con_DemoSliceBegin(IConsole::IResult *pResult, void *pUserData);
|
2014-08-12 14:21:06 +00:00
|
|
|
static void Con_DemoSliceEnd(IConsole::IResult *pResult, void *pUserData);
|
2019-05-20 21:55:40 +00:00
|
|
|
static void Con_SaveReplay(IConsole::IResult *pResult, void *pUserData);
|
2014-08-12 14:21:06 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void RegisterCommands();
|
|
|
|
|
2010-10-06 21:07:35 +00:00
|
|
|
const char *DemoPlayer_Play(const char *pFilename, int StorageType);
|
2014-10-16 15:42:13 +00:00
|
|
|
void DemoRecorder_Start(const char *pFilename, bool WithTimestamp, int Recorder);
|
2010-12-08 00:42:32 +00:00
|
|
|
void DemoRecorder_HandleAutoStart();
|
2019-05-21 15:21:53 +00:00
|
|
|
void DemoRecorder_StartReplayRecorder();
|
|
|
|
void DemoRecorder_Stop(int Recorder, bool RemoveFile = false);
|
2014-10-16 15:42:13 +00:00
|
|
|
void DemoRecorder_AddDemoMarker(int Recorder);
|
|
|
|
class IDemoRecorder *DemoRecorder(int Recorder);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2010-12-12 15:48:13 +00:00
|
|
|
void AutoScreenshot_Start();
|
2015-05-19 22:51:02 +00:00
|
|
|
void AutoStatScreenshot_Start();
|
2010-12-12 15:48:13 +00:00
|
|
|
void AutoScreenshot_Cleanup();
|
2015-05-19 22:51:02 +00:00
|
|
|
void AutoStatScreenshot_Cleanup();
|
2010-12-12 15:48:13 +00:00
|
|
|
|
2017-04-26 03:10:31 +00:00
|
|
|
void AutoCSV_Start();
|
|
|
|
void AutoCSV_Cleanup();
|
|
|
|
|
2011-03-18 18:03:13 +00:00
|
|
|
void ServerBrowserUpdate();
|
2011-02-13 05:35:13 +00:00
|
|
|
|
2020-09-06 11:37:48 +00:00
|
|
|
void HandleConnectAddress(const NETADDR *pAddr);
|
2018-12-13 18:57:32 +00:00
|
|
|
void HandleConnectLink(const char *pLink);
|
2019-04-10 06:56:20 +00:00
|
|
|
void HandleDemoPath(const char *pPath);
|
2020-08-02 11:00:01 +00:00
|
|
|
void HandleMapPath(const char *pPath);
|
2018-12-13 18:57:32 +00:00
|
|
|
|
2016-04-29 22:34:12 +00:00
|
|
|
// gfx
|
2021-01-31 20:54:04 +00:00
|
|
|
virtual void SwitchWindowScreen(int Index);
|
|
|
|
virtual void SetWindowParams(int FullscreenMode, bool IsBorderless);
|
|
|
|
virtual void ToggleWindowVSync();
|
|
|
|
virtual void LoadFont();
|
|
|
|
virtual void Notify(const char *pTitle, const char *pMessage);
|
2020-11-19 15:15:07 +00:00
|
|
|
void BenchmarkQuit(int Seconds, const char *pFilename);
|
2016-04-29 22:34:12 +00:00
|
|
|
|
2011-02-13 05:35:13 +00:00
|
|
|
// DDRace
|
2011-04-09 06:41:31 +00:00
|
|
|
|
2020-10-02 13:43:52 +00:00
|
|
|
virtual void GenerateTimeoutSeed();
|
2016-10-02 09:31:11 +00:00
|
|
|
void GenerateTimeoutCodes();
|
|
|
|
|
2019-03-25 19:02:50 +00:00
|
|
|
virtual int GetCurrentRaceTime();
|
|
|
|
|
2021-02-08 21:26:26 +00:00
|
|
|
virtual const char *GetCurrentMap() const;
|
|
|
|
virtual const char *GetCurrentMapPath() const;
|
|
|
|
virtual SHA256_DIGEST GetCurrentMapSha256() const;
|
|
|
|
virtual unsigned GetCurrentMapCrc() const;
|
2017-09-09 21:10:42 +00:00
|
|
|
|
2020-10-02 13:43:52 +00:00
|
|
|
virtual void RaceRecord_Start(const char *pFilename);
|
|
|
|
virtual void RaceRecord_Stop();
|
|
|
|
virtual bool RaceRecord_IsRecording();
|
2014-08-13 14:35:15 +00:00
|
|
|
|
|
|
|
virtual void DemoSliceBegin();
|
|
|
|
virtual void DemoSliceEnd();
|
2017-02-28 09:08:14 +00:00
|
|
|
virtual void DemoSlice(const char *pDstPath, CLIENTFUNC_FILTER pfnFilter, void *pUser);
|
2019-06-02 13:34:01 +00:00
|
|
|
virtual void SaveReplay(const int Length);
|
2014-09-19 22:36:22 +00:00
|
|
|
|
2021-02-08 21:26:26 +00:00
|
|
|
virtual bool EditorHasUnsavedData() const { return m_pEditor->HasUnsavedData(); }
|
2015-07-22 20:16:49 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
virtual IFriends *Foes() { return &m_Foes; }
|
2019-04-11 22:46:54 +00:00
|
|
|
|
2020-10-02 13:43:52 +00:00
|
|
|
virtual void GetSmoothTick(int *pSmoothTick, float *pSmoothIntraTick, float MixAmount);
|
|
|
|
|
|
|
|
virtual SWarning *GetCurWarning();
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
2019-05-24 22:24:13 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#endif
|