Properly initialize all CClient member variables

Additionally, ensure snapshots are cleared and dummy is disconnected when disconnecting programatically with `DisconnectWithReason`.

Add `NETADDR_ZEROED` and `UUID_ZEROED` for more convenient initialization without using `mem_zero`.
This commit is contained in:
Robert Müller 2023-11-27 22:29:14 +01:00
parent b352545621
commit d70fc84e38
9 changed files with 119 additions and 199 deletions

View file

@ -963,6 +963,9 @@ int64_t time_freq()
} }
/* ----- network ----- */ /* ----- network ----- */
const NETADDR NETADDR_ZEROED = {NETTYPE_INVALID, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0};
static void netaddr_to_sockaddr_in(const NETADDR *src, struct sockaddr_in *dest) static void netaddr_to_sockaddr_in(const NETADDR *src, struct sockaddr_in *dest)
{ {
mem_zero(dest, sizeof(struct sockaddr_in)); mem_zero(dest, sizeof(struct sockaddr_in));

View file

@ -777,6 +777,8 @@ typedef struct NETADDR
bool operator!=(const NETADDR &other) const { return !(*this == other); } bool operator!=(const NETADDR &other) const { return !(*this == other); }
} NETADDR; } NETADDR;
extern const NETADDR NETADDR_ZEROED;
#ifdef CONF_FAMILY_UNIX #ifdef CONF_FAMILY_UNIX
/** /**
* @ingroup Network-General * @ingroup Network-General

View file

@ -69,31 +69,30 @@ public:
protected: protected:
// quick access to state of the client // quick access to state of the client
EClientState m_State; EClientState m_State = IClient::STATE_OFFLINE;
ELoadingStateDetail m_LoadingStateDetail; ELoadingStateDetail m_LoadingStateDetail = LOADING_STATE_DETAIL_INITIAL;
int64_t m_StateStartTime; int64_t m_StateStartTime;
// quick access to time variables // quick access to time variables
int m_aPrevGameTick[NUM_DUMMIES]; int m_aPrevGameTick[NUM_DUMMIES] = {0, 0};
int m_aCurGameTick[NUM_DUMMIES]; int m_aCurGameTick[NUM_DUMMIES] = {0, 0};
float m_aGameIntraTick[NUM_DUMMIES]; float m_aGameIntraTick[NUM_DUMMIES] = {0.0f, 0.0f};
float m_aGameTickTime[NUM_DUMMIES]; float m_aGameTickTime[NUM_DUMMIES] = {0.0f, 0.0f};
float m_aGameIntraTickSincePrev[NUM_DUMMIES]; float m_aGameIntraTickSincePrev[NUM_DUMMIES] = {0.0f, 0.0f};
int m_aPredTick[NUM_DUMMIES]; int m_aPredTick[NUM_DUMMIES] = {0, 0};
float m_aPredIntraTick[NUM_DUMMIES]; float m_aPredIntraTick[NUM_DUMMIES] = {0.0f, 0.0f};
float m_LocalTime; float m_LocalTime = 0.0f;
float m_GlobalTime; float m_GlobalTime = 0.0f;
float m_RenderFrameTime; float m_RenderFrameTime = 0.0001f;
float m_FrameTimeAvg = 0.0001f;
float m_FrameTimeAvg; TMapLoadingCallbackFunc m_MapLoadingCBFunc = nullptr;
TMapLoadingCallbackFunc m_MapLoadingCBFunc; char m_aNews[3000] = "";
int m_Points = -1;
char m_aNews[3000]; int64_t m_ReconnectTime = 0;
int m_Points;
int64_t m_ReconnectTime;
public: public:
class CSnapItem class CSnapItem

View file

@ -77,104 +77,21 @@ static const ColorRGBA gs_ClientNetworkErrPrintColor{1.0f, 0.25f, 0.25f, 1.0f};
CClient::CClient() : CClient::CClient() :
m_DemoPlayer(&m_SnapshotDelta, true, [&]() { UpdateDemoIntraTimers(); }) m_DemoPlayer(&m_SnapshotDelta, true, [&]() { UpdateDemoIntraTimers(); })
{ {
m_StateStartTime = time_get();
for(auto &DemoRecorder : m_aDemoRecorder) for(auto &DemoRecorder : m_aDemoRecorder)
DemoRecorder = CDemoRecorder(&m_SnapshotDelta); DemoRecorder = CDemoRecorder(&m_SnapshotDelta);
m_RenderFrameTime = 0.0001f;
m_LastRenderTime = time_get(); m_LastRenderTime = time_get();
m_SnapCrcErrors = 0;
m_AutoScreenshotRecycle = false;
m_AutoStatScreenshotRecycle = false;
m_AutoCSVRecycle = false;
m_EditorActive = false;
m_aAckGameTick[0] = -1;
m_aAckGameTick[1] = -1;
m_aCurrentRecvTick[0] = 0;
m_aCurrentRecvTick[1] = 0;
m_aRconAuthed[0] = 0;
m_aRconAuthed[1] = 0;
m_aRconUsername[0] = '\0';
m_aRconPassword[0] = '\0';
m_aPassword[0] = '\0';
// version-checking
m_aVersionStr[0] = '0';
m_aVersionStr[1] = '\0';
// pinging
m_PingStartTime = 0;
m_aCurrentMap[0] = 0;
m_aCmdConnect[0] = 0;
// map download
m_aMapdownloadFilename[0] = 0;
m_aMapdownloadFilenameTemp[0] = 0;
m_aMapdownloadName[0] = 0;
m_pMapdownloadTask = NULL;
m_MapdownloadFileTemp = 0;
m_MapdownloadChunk = 0;
m_MapdownloadSha256Present = false;
m_MapdownloadSha256 = SHA256_ZEROED;
m_MapdownloadCrc = 0;
m_MapdownloadAmount = -1;
m_MapdownloadTotalsize = -1;
m_MapDetailsPresent = false;
m_aMapDetailsName[0] = 0;
m_MapDetailsSha256 = SHA256_ZEROED;
m_MapDetailsCrc = 0;
m_aMapDetailsUrl[0] = 0;
IStorage::FormatTmpPath(m_aDDNetInfoTmp, sizeof(m_aDDNetInfoTmp), DDNET_INFO_FILE); IStorage::FormatTmpPath(m_aDDNetInfoTmp, sizeof(m_aDDNetInfoTmp), DDNET_INFO_FILE);
m_pDDNetInfoTask = NULL; mem_zero(m_aInputs, sizeof(m_aInputs));
m_aNews[0] = '\0';
m_aMapDownloadUrl[0] = '\0';
m_Points = -1;
m_CurrentServerInfoRequestTime = -1;
m_CurrentServerPingInfoType = -1;
m_CurrentServerPingBasicToken = -1;
m_CurrentServerPingToken = -1;
mem_zero(&m_CurrentServerPingUuid, sizeof(m_CurrentServerPingUuid));
m_CurrentServerCurrentPingTime = -1;
m_CurrentServerNextPingTime = -1;
m_aCurrentInput[0] = 0;
m_aCurrentInput[1] = 0;
m_LastDummy = false;
mem_zero(&m_aInputs, sizeof(m_aInputs));
m_State = IClient::STATE_OFFLINE;
m_StateStartTime = time_get();
m_aConnectAddressStr[0] = 0;
mem_zero(m_aapSnapshots, sizeof(m_aapSnapshots)); mem_zero(m_aapSnapshots, sizeof(m_aapSnapshots));
m_aSnapshotStorage[0].Init(); for(auto &SnapshotStorage : m_aSnapshotStorage)
m_aSnapshotStorage[1].Init(); SnapshotStorage.Init();
m_aReceivedSnapshots[0] = 0; mem_zero(m_aDemorecSnapshotHolders, sizeof(m_aDemorecSnapshotHolders));
m_aReceivedSnapshots[1] = 0; mem_zero(&m_CurrentServerInfo, sizeof(m_CurrentServerInfo));
m_aSnapshotParts[0] = 0;
m_aSnapshotParts[1] = 0;
m_VersionInfo.m_State = CVersionInfo::STATE_INIT;
if(g_Config.m_ClDummy == 0)
m_LastDummyConnectTime = 0;
m_ReconnectTime = 0;
m_GenerateTimeoutSeed = true;
m_FrameTimeAvg = 0.0001f;
m_BenchmarkFile = 0;
m_BenchmarkStopTime = 0;
mem_zero(&m_Checksum, sizeof(m_Checksum)); mem_zero(&m_Checksum, sizeof(m_Checksum));
for(auto &GameTime : m_aGameTime)
GameTime.Init(0);
m_PredictedTime.Init(0);
} }
// ----- send functions ----- // ----- send functions -----
@ -610,6 +527,8 @@ void CClient::DisconnectWithReason(const char *pReason)
if(pReason != nullptr && pReason[0] == '\0') if(pReason != nullptr && pReason[0] == '\0')
pReason = nullptr; pReason = nullptr;
DummyDisconnect(pReason);
char aBuf[512]; char aBuf[512];
str_format(aBuf, sizeof(aBuf), "disconnecting. reason='%s'", pReason ? pReason : "unknown"); str_format(aBuf, sizeof(aBuf), "disconnecting. reason='%s'", pReason ? pReason : "unknown");
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, gs_ClientNetworkPrintColor); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, gs_ClientNetworkPrintColor);
@ -657,16 +576,14 @@ void CClient::DisconnectWithReason(const char *pReason)
mem_zero(&m_CurrentServerInfo, sizeof(m_CurrentServerInfo)); mem_zero(&m_CurrentServerInfo, sizeof(m_CurrentServerInfo));
// clear snapshots // clear snapshots
m_aapSnapshots[g_Config.m_ClDummy][SNAP_CURRENT] = 0; m_aapSnapshots[0][SNAP_CURRENT] = 0;
m_aapSnapshots[g_Config.m_ClDummy][SNAP_PREV] = 0; m_aapSnapshots[0][SNAP_PREV] = 0;
m_aReceivedSnapshots[g_Config.m_ClDummy] = 0; m_aReceivedSnapshots[0] = 0;
} }
void CClient::Disconnect() void CClient::Disconnect()
{ {
m_ButtonRender = false; m_ButtonRender = false;
if(m_DummyConnected)
DummyDisconnect(0);
if(m_State != IClient::STATE_OFFLINE) if(m_State != IClient::STATE_OFFLINE)
DisconnectWithReason(0); DisconnectWithReason(0);
@ -2273,7 +2190,6 @@ void CClient::LoadDDNetInfo()
NETADDR Addr; NETADDR Addr;
if(!net_addr_from_str(&Addr, ConnectingIp)) if(!net_addr_from_str(&Addr, ConnectingIp))
{ {
m_HaveGlobalTcpAddr = true;
m_GlobalTcpAddr = Addr; m_GlobalTcpAddr = Addr;
log_debug("info", "got global tcp ip address: %s", (const char *)ConnectingIp); log_debug("info", "got global tcp ip address: %s", (const char *)ConnectingIp);
} }
@ -4735,7 +4651,7 @@ int CClient::UdpConnectivity(int NetType)
break; break;
case CONNECTIVITY::ADDRESS_KNOWN: case CONNECTIVITY::ADDRESS_KNOWN:
GlobalUdpAddr.port = 0; GlobalUdpAddr.port = 0;
if(m_HaveGlobalTcpAddr && NetType == (int)m_GlobalTcpAddr.type && net_addr_comp(&m_GlobalTcpAddr, &GlobalUdpAddr) != 0) if(NetType == (int)m_GlobalTcpAddr.type && net_addr_comp(&m_GlobalTcpAddr, &GlobalUdpAddr) != 0)
{ {
NewConnectivity = CONNECTIVITY_DIFFERING_UDP_TCP_IP_ADDRESSES; NewConnectivity = CONNECTIVITY_DIFFERING_UDP_TCP_IP_ADDRESSES;
break; break;

View file

@ -48,11 +48,11 @@ class IUpdater;
class CServerCapabilities class CServerCapabilities
{ {
public: public:
bool m_ChatTimeoutCode; bool m_ChatTimeoutCode = false;
bool m_AnyPlayerFlag; bool m_AnyPlayerFlag = false;
bool m_PingEx; bool m_PingEx = false;
bool m_AllowDummy; bool m_AllowDummy = false;
bool m_SyncWeaponInput; bool m_SyncWeaponInput = false;
}; };
class CClient : public IClient, public CDemoPlayer::IListener class CClient : public IClient, public CDemoPlayer::IListener
@ -86,78 +86,76 @@ class CClient : public IClient, public CDemoPlayer::IListener
CFriends m_Friends; CFriends m_Friends;
CFriends m_Foes; CFriends m_Foes;
char m_aConnectAddressStr[MAX_SERVER_ADDRESSES * NETADDR_MAXSTRSIZE]; char m_aConnectAddressStr[MAX_SERVER_ADDRESSES * NETADDR_MAXSTRSIZE] = "";
CUuid m_ConnectionID; CUuid m_ConnectionID = UUID_ZEROED;
bool m_HaveGlobalTcpAddr = false; NETADDR m_GlobalTcpAddr = NETADDR_ZEROED;
NETADDR m_GlobalTcpAddr;
uint64_t m_aSnapshotParts[NUM_DUMMIES]; uint64_t m_aSnapshotParts[NUM_DUMMIES] = {0, 0};
int64_t m_LocalStartTime; int64_t m_LocalStartTime = 0;
int64_t m_GlobalStartTime; int64_t m_GlobalStartTime = 0;
IGraphics::CTextureHandle m_DebugFont; IGraphics::CTextureHandle m_DebugFont;
int64_t m_LastRenderTime; int64_t m_LastRenderTime;
int m_SnapCrcErrors; int m_SnapCrcErrors = 0;
bool m_AutoScreenshotRecycle; bool m_AutoScreenshotRecycle = false;
bool m_AutoStatScreenshotRecycle; bool m_AutoStatScreenshotRecycle = false;
bool m_AutoCSVRecycle; bool m_AutoCSVRecycle = false;
bool m_EditorActive; bool m_EditorActive = false;
bool m_SoundInitFailed; bool m_SoundInitFailed = false;
int m_aAckGameTick[NUM_DUMMIES]; int m_aAckGameTick[NUM_DUMMIES] = {-1, -1};
int m_aCurrentRecvTick[NUM_DUMMIES]; int m_aCurrentRecvTick[NUM_DUMMIES] = {0, 0};
int m_aRconAuthed[NUM_DUMMIES]; int m_aRconAuthed[NUM_DUMMIES] = {0, 0};
char m_aRconUsername[32]; char m_aRconUsername[32] = "";
char m_aRconPassword[sizeof(g_Config.m_SvRconPassword)]; char m_aRconPassword[sizeof(g_Config.m_SvRconPassword)] = "";
int m_UseTempRconCommands; int m_UseTempRconCommands = 0;
char m_aPassword[sizeof(g_Config.m_Password)]; char m_aPassword[sizeof(g_Config.m_Password)] = "";
bool m_SendPassword; bool m_SendPassword = false;
bool m_ButtonRender = false; bool m_ButtonRender = false;
// version-checking // version-checking
char m_aVersionStr[10]; char m_aVersionStr[10] = "0";
// pinging // pinging
int64_t m_PingStartTime; int64_t m_PingStartTime = 0;
char m_aCurrentMap[IO_MAX_PATH_LENGTH]; char m_aCurrentMap[IO_MAX_PATH_LENGTH] = "";
char m_aCurrentMapPath[IO_MAX_PATH_LENGTH]; char m_aCurrentMapPath[IO_MAX_PATH_LENGTH] = "";
char m_aTimeoutCodes[NUM_DUMMIES][32]; char m_aTimeoutCodes[NUM_DUMMIES][32] = {"", ""};
bool m_aCodeRunAfterJoin[NUM_DUMMIES]; bool m_aCodeRunAfterJoin[NUM_DUMMIES] = {false, false};
bool m_GenerateTimeoutSeed; bool m_GenerateTimeoutSeed = true;
// char m_aCmdConnect[256] = "";
char m_aCmdConnect[256]; char m_aCmdPlayDemo[IO_MAX_PATH_LENGTH] = "";
char m_aCmdPlayDemo[IO_MAX_PATH_LENGTH]; char m_aCmdEditMap[IO_MAX_PATH_LENGTH] = "";
char m_aCmdEditMap[IO_MAX_PATH_LENGTH];
// map download // map download
char m_aMapDownloadUrl[256]; char m_aMapDownloadUrl[256] = "";
std::shared_ptr<CHttpRequest> m_pMapdownloadTask; std::shared_ptr<CHttpRequest> m_pMapdownloadTask = nullptr;
char m_aMapdownloadFilename[256]; char m_aMapdownloadFilename[256] = "";
char m_aMapdownloadFilenameTemp[256]; char m_aMapdownloadFilenameTemp[256] = "";
char m_aMapdownloadName[256]; char m_aMapdownloadName[256] = "";
IOHANDLE m_MapdownloadFileTemp; IOHANDLE m_MapdownloadFileTemp = 0;
int m_MapdownloadChunk; int m_MapdownloadChunk = 0;
int m_MapdownloadCrc; int m_MapdownloadCrc = 0;
int m_MapdownloadAmount; int m_MapdownloadAmount = -1;
int m_MapdownloadTotalsize; int m_MapdownloadTotalsize = -1;
bool m_MapdownloadSha256Present; bool m_MapdownloadSha256Present = false;
SHA256_DIGEST m_MapdownloadSha256; SHA256_DIGEST m_MapdownloadSha256 = SHA256_ZEROED;
bool m_MapDetailsPresent; bool m_MapDetailsPresent = false;
char m_aMapDetailsName[256]; char m_aMapDetailsName[256] = "";
int m_MapDetailsCrc; int m_MapDetailsCrc = 0;
SHA256_DIGEST m_MapDetailsSha256; SHA256_DIGEST m_MapDetailsSha256 = SHA256_ZEROED;
char m_aMapDetailsUrl[256]; char m_aMapDetailsUrl[256] = "";
char m_aDDNetInfoTmp[64]; char m_aDDNetInfoTmp[64];
std::shared_ptr<CHttpRequest> m_pDDNetInfoTask; std::shared_ptr<CHttpRequest> m_pDDNetInfoTask = nullptr;
// time // time
CSmoothTime m_aGameTime[NUM_DUMMIES]; CSmoothTime m_aGameTime[NUM_DUMMIES];
@ -173,9 +171,11 @@ class CClient : public IClient, public CDemoPlayer::IListener
int64_t m_Time; int64_t m_Time;
} m_aInputs[NUM_DUMMIES][200]; } m_aInputs[NUM_DUMMIES][200];
int m_aCurrentInput[NUM_DUMMIES]; int m_aCurrentInput[NUM_DUMMIES] = {0, 0};
bool m_LastDummy; bool m_LastDummy = false;
bool m_DummySendConnInfo; bool m_DummySendConnInfo = false;
bool m_DummyConnected = false;
int m_LastDummyConnectTime = 0;
// graphs // graphs
CGraph m_InputtimeMarginGraph; CGraph m_InputtimeMarginGraph;
@ -186,9 +186,9 @@ class CClient : public IClient, public CDemoPlayer::IListener
CSnapshotStorage m_aSnapshotStorage[NUM_DUMMIES]; CSnapshotStorage m_aSnapshotStorage[NUM_DUMMIES];
CSnapshotStorage::CHolder *m_aapSnapshots[NUM_DUMMIES][NUM_SNAPSHOT_TYPES]; CSnapshotStorage::CHolder *m_aapSnapshots[NUM_DUMMIES][NUM_SNAPSHOT_TYPES];
int m_aReceivedSnapshots[NUM_DUMMIES]; int m_aReceivedSnapshots[NUM_DUMMIES] = {0, 0};
char m_aaSnapshotIncomingData[NUM_DUMMIES][CSnapshot::MAX_SIZE]; char m_aaSnapshotIncomingData[NUM_DUMMIES][CSnapshot::MAX_SIZE];
int m_aSnapshotIncomingDataSize[NUM_DUMMIES]; int m_aSnapshotIncomingDataSize[NUM_DUMMIES] = {0, 0};
CSnapshotStorage::CHolder m_aDemorecSnapshotHolders[NUM_SNAPSHOT_TYPES]; CSnapshotStorage::CHolder m_aDemorecSnapshotHolders[NUM_SNAPSHOT_TYPES];
char m_aaaDemorecSnapshotData[NUM_SNAPSHOT_TYPES][2][CSnapshot::MAX_SIZE]; char m_aaaDemorecSnapshotData[NUM_SNAPSHOT_TYPES][2][CSnapshot::MAX_SIZE];
@ -198,19 +198,19 @@ class CClient : public IClient, public CDemoPlayer::IListener
std::deque<std::shared_ptr<CDemoEdit>> m_EditJobs; std::deque<std::shared_ptr<CDemoEdit>> m_EditJobs;
// //
bool m_CanReceiveServerCapabilities; bool m_CanReceiveServerCapabilities = false;
bool m_ServerSentCapabilities; bool m_ServerSentCapabilities = false;
CServerCapabilities m_ServerCapabilities; CServerCapabilities m_ServerCapabilities;
CServerInfo m_CurrentServerInfo; CServerInfo m_CurrentServerInfo;
int64_t m_CurrentServerInfoRequestTime; // >= 0 should request, == -1 got info int64_t m_CurrentServerInfoRequestTime = -1; // >= 0 should request, == -1 got info
int m_CurrentServerPingInfoType; int m_CurrentServerPingInfoType = -1;
int m_CurrentServerPingBasicToken; int m_CurrentServerPingBasicToken = -1;
int m_CurrentServerPingToken; int m_CurrentServerPingToken = -1;
CUuid m_CurrentServerPingUuid; CUuid m_CurrentServerPingUuid = UUID_ZEROED;
int64_t m_CurrentServerCurrentPingTime; // >= 0 request running int64_t m_CurrentServerCurrentPingTime = -1; // >= 0 request running
int64_t m_CurrentServerNextPingTime; // >= 0 should request int64_t m_CurrentServerNextPingTime = -1; // >= 0 should request
// version info // version info
struct CVersionInfo struct CVersionInfo
@ -222,19 +222,19 @@ class CClient : public IClient, public CDemoPlayer::IListener
STATE_READY, STATE_READY,
}; };
int m_State; int m_State = STATE_INIT;
} m_VersionInfo; } m_VersionInfo;
std::vector<SWarning> m_vWarnings; std::vector<SWarning> m_vWarnings;
CFifo m_Fifo; CFifo m_Fifo;
IOHANDLE m_BenchmarkFile; IOHANDLE m_BenchmarkFile = 0;
int64_t m_BenchmarkStopTime; int64_t m_BenchmarkStopTime = 0;
CChecksum m_Checksum; CChecksum m_Checksum;
int m_OwnExecutableSize = 0; int m_OwnExecutableSize = 0;
IOHANDLE m_OwnExecutable; IOHANDLE m_OwnExecutable = 0;
// favorite command handling // favorite command handling
bool m_FavoritesGroup = false; bool m_FavoritesGroup = false;
@ -310,8 +310,6 @@ public:
bool DummyConnected() override; bool DummyConnected() override;
bool DummyConnecting() override; bool DummyConnecting() override;
bool DummyAllowed() override; bool DummyAllowed() override;
int m_DummyConnected;
int m_LastDummyConnectTime;
void GetServerInfo(CServerInfo *pServerInfo) const override; void GetServerInfo(CServerInfo *pServerInfo) const override;
void ServerInfoRequest(); void ServerInfoRequest();

View file

@ -57,17 +57,10 @@ CServerBrowser::CServerBrowser() :
m_ppServerlist = nullptr; m_ppServerlist = nullptr;
m_pSortedServerlist = nullptr; m_pSortedServerlist = nullptr;
m_pFirstReqServer = nullptr; // request list
m_pLastReqServer = nullptr;
m_NumRequests = 0;
m_NeedResort = false; m_NeedResort = false;
m_Sorthash = 0; m_Sorthash = 0;
m_NumSortedServers = 0;
m_NumSortedServersCapacity = 0; m_NumSortedServersCapacity = 0;
m_NumSortedPlayers = 0;
m_NumServers = 0;
m_NumServerCapacity = 0; m_NumServerCapacity = 0;
m_ServerlistType = 0; m_ServerlistType = 0;
@ -76,6 +69,8 @@ CServerBrowser::CServerBrowser() :
m_pDDNetInfo = nullptr; m_pDDNetInfo = nullptr;
m_DDNetInfoUpdateTime = 0; m_DDNetInfoUpdateTime = 0;
CleanUp();
} }
CServerBrowser::~CServerBrowser() CServerBrowser::~CServerBrowser()

View file

@ -13,6 +13,7 @@ void CSmoothTime::Init(int64_t Target)
m_Current = Target; m_Current = Target;
m_Target = Target; m_Target = Target;
m_Margin = 0; m_Margin = 0;
m_SpikeCounter = 0;
m_aAdjustSpeed[ADJUSTDIRECTION_DOWN] = 0.3f; m_aAdjustSpeed[ADJUSTDIRECTION_DOWN] = 0.3f;
m_aAdjustSpeed[ADJUSTDIRECTION_UP] = 0.3f; m_aAdjustSpeed[ADJUSTDIRECTION_UP] = 0.3f;
} }

View file

@ -10,6 +10,10 @@ static const CUuid TEEWORLDS_NAMESPACE = {{// "e05ddaaa-c4e6-4cfb-b642-5d48e80c0
0xe0, 0x5d, 0xda, 0xaa, 0xc4, 0xe6, 0x4c, 0xfb, 0xe0, 0x5d, 0xda, 0xaa, 0xc4, 0xe6, 0x4c, 0xfb,
0xb6, 0x42, 0x5d, 0x48, 0xe8, 0x0c, 0x00, 0x29}}; 0xb6, 0x42, 0x5d, 0x48, 0xe8, 0x0c, 0x00, 0x29}};
const CUuid UUID_ZEROED = {{// "00000000-0000-0000-0000-000000000000"
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
CUuid RandomUuid() CUuid RandomUuid()
{ {
CUuid Result; CUuid Result;

View file

@ -24,6 +24,8 @@ struct CUuid
bool operator<(const CUuid &Other) const { return mem_comp(m_aData, Other.m_aData, sizeof(m_aData)) < 0; } bool operator<(const CUuid &Other) const { return mem_comp(m_aData, Other.m_aData, sizeof(m_aData)) < 0; }
}; };
extern const CUuid UUID_ZEROED;
CUuid RandomUuid(); CUuid RandomUuid();
CUuid CalculateUuid(const char *pName); CUuid CalculateUuid(const char *pName);
// The buffer length should be at least UUID_MAXSTRSIZE. // The buffer length should be at least UUID_MAXSTRSIZE.