mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 22:18:19 +00:00
Merge pull request #7575 from Robyt3/Client-MemZero-Fix
Properly initialize all `CClient` member variables, improve integration test script
This commit is contained in:
commit
e0d0daaae0
|
@ -7,14 +7,14 @@ for arg in "$@"
|
|||
do
|
||||
if [ "$arg" == "-h" ] || [ "$arg" == "--help" ]
|
||||
then
|
||||
echo "usage: $(basename "$0") [OPTION..] [build dir]"
|
||||
echo "usage: $(basename "$0") [OPTION..]"
|
||||
echo "description:"
|
||||
echo " Runs a simple integration test of the client and server"
|
||||
echo " binaries from the given build dir"
|
||||
echo " binaries from the current build directory."
|
||||
echo "options:"
|
||||
echo " --help|-h show this help"
|
||||
echo " --verbose|-v verbose output"
|
||||
echo " --valgrind-memcheck use valgrind's memcheck to run server and client"
|
||||
echo " --help|-h show this help"
|
||||
echo " --verbose|-v verbose output"
|
||||
echo " --valgrind-memcheck use valgrind's memcheck to run server and client"
|
||||
exit 0
|
||||
elif [ "$arg" == "-v" ] || [ "$arg" == "--verbose" ]
|
||||
then
|
||||
|
@ -23,22 +23,23 @@ do
|
|||
then
|
||||
arg_valgrind_memcheck=1
|
||||
else
|
||||
echo "Error: unknown arg '$arg'"
|
||||
echo "Error: unknown argument '$arg'"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -f DDNet ]
|
||||
then
|
||||
echo "Error: client binary not found DDNet' not found"
|
||||
echo "[-] Error: client binary 'DDNet' not found"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f DDNet-Server ]
|
||||
then
|
||||
echo "Error: server binary not found DDNet-Server' not found"
|
||||
echo "[-] Error: server binary 'DDNet-Server' not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[*] Setup"
|
||||
got_killed=0
|
||||
|
||||
function kill_all() {
|
||||
|
@ -51,24 +52,27 @@ function kill_all() {
|
|||
|
||||
if [ "$arg_verbose" == "1" ]
|
||||
then
|
||||
echo "[*] shutting down test clients and server ..."
|
||||
echo "[*] Shutting down test clients and server"
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
|
||||
if [[ ! -f fail_server.txt ]]
|
||||
then
|
||||
echo "[*] shutting down server"
|
||||
echo "[*] Shutting down server"
|
||||
echo "shutdown" > server.fifo
|
||||
fi
|
||||
sleep 1
|
||||
|
||||
local i
|
||||
for ((i=1;i<3;i++))
|
||||
do
|
||||
if [[ ! -f fail_client$i.txt ]]
|
||||
then
|
||||
echo "[*] shutting down client$i"
|
||||
echo "[*] Shutting down client$i"
|
||||
echo "quit" > "client$i.fifo"
|
||||
fi
|
||||
done
|
||||
sleep 1
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
|
@ -85,8 +89,8 @@ function fail()
|
|||
echo "[-] $1 exited with code $2"
|
||||
}
|
||||
|
||||
# TODO: check for open ports instead
|
||||
port=17822
|
||||
# Get unused port from the system by binding to port 0 and immediately closing the socket again
|
||||
port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()');
|
||||
|
||||
if [[ $OSTYPE == 'darwin'* ]]; then
|
||||
DETECT_LEAKS=0
|
||||
|
@ -100,13 +104,18 @@ export LSAN_OPTIONS=suppressions=../lsan.supp:print_suppressions=0
|
|||
|
||||
function print_results() {
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||
if grep "ERROR SUMMARY" server.log client1.log client2.log | grep -q -v "ERROR SUMMARY: 0"; then
|
||||
grep "^==" server.log client1.log client2.log
|
||||
# Wait to ensure that the error summary was written to the stderr files because valgrind takes some time
|
||||
# TODO: Instead wait for all started processes to finish
|
||||
sleep 20
|
||||
if grep "== ERROR SUMMARY: " stderr_server.txt stderr_client1.txt stderr_client2.txt | grep -q -v "ERROR SUMMARY: 0"; then
|
||||
echo "[-] Error: Valgrind has detected the following errors:"
|
||||
grep "^==" stderr_server.txt stderr_client1.txt stderr_client2.txt
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
if test -n "$(find . -maxdepth 1 -name 'SAN.*' -print -quit)"
|
||||
then
|
||||
echo "[-] Error: ASAN has detected the following errors:"
|
||||
cat SAN.*
|
||||
return 1
|
||||
fi
|
||||
|
@ -127,39 +136,54 @@ cd integration_test || exit 1
|
|||
echo $'add_path ../data'
|
||||
} > storage.cfg
|
||||
|
||||
tool=""
|
||||
client_args="cl_download_skins 0;
|
||||
gfx_fullscreen 0;
|
||||
snd_enable 0;"
|
||||
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||
tool="valgrind --tool=memcheck --gen-suppressions=all --suppressions=../memcheck.supp --track-origins=yes"
|
||||
client_args="cl_menu_map \"\";"
|
||||
else
|
||||
tool=""
|
||||
client_args=""
|
||||
client_args="$client_args cl_menu_map \"\";"
|
||||
fi
|
||||
|
||||
function wait_for_fifo() {
|
||||
local fifo="$1"
|
||||
local tries="$2"
|
||||
local fails=0
|
||||
# give the client time to launch and create the fifo file
|
||||
# but assume after X secs that the client crashed before
|
||||
# give the server/client time to launch and create the fifo file
|
||||
# but assume after X secs that the server/client crashed before
|
||||
# being able to create the file
|
||||
while [[ ! -p "$fifo" ]]
|
||||
do
|
||||
fails="$((fails+1))"
|
||||
if [ "$arg_verbose" == "1" ]
|
||||
then
|
||||
echo "[!] client fifos not found (attempts $fails/$tries)"
|
||||
echo "[!] Note: $fifo not found (attempts $fails/$tries)"
|
||||
fi
|
||||
if [ "$fails" -gt "$tries" ]
|
||||
then
|
||||
echo "[-] Error: $(basename "$fifo" .fifo) possibly crashed on launch"
|
||||
kill_all
|
||||
print_results
|
||||
echo "[-] Error: client possibly crashed on launch"
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
echo "[*] launch server"
|
||||
function wait_for_launch() {
|
||||
local fifo="$1"
|
||||
local baseDuration="$2"
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||
wait_for_fifo "$fifo" $((40 * baseDuration))
|
||||
sleep $((8 * baseDuration))
|
||||
else
|
||||
wait_for_fifo "$fifo" $((10 * baseDuration))
|
||||
sleep "$baseDuration"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "[*] Launch server"
|
||||
$tool ../DDNet-Server \
|
||||
"sv_input_fifo server.fifo;
|
||||
sv_rcon_password rcon;
|
||||
|
@ -169,50 +193,34 @@ $tool ../DDNet-Server \
|
|||
sv_register 0;
|
||||
sv_port $port" > stdout_server.txt 2> stderr_server.txt || fail server "$?" &
|
||||
|
||||
echo "[*] launch client 1"
|
||||
wait_for_launch server.fifo 1
|
||||
|
||||
echo "[*] Launch client 1"
|
||||
$tool ../DDNet \
|
||||
"cl_input_fifo client1.fifo;
|
||||
player_name client1;
|
||||
cl_download_skins 0;
|
||||
gfx_fullscreen 0;
|
||||
snd_enable 0;
|
||||
logfile client1.log;
|
||||
$client_args
|
||||
connect localhost:$port" > stdout_client1.txt 2> stderr_client1.txt || fail client1 "$?" &
|
||||
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||
wait_for_fifo client1.fifo 180
|
||||
sleep 40
|
||||
else
|
||||
wait_for_fifo client1.fifo 50
|
||||
sleep 1
|
||||
fi
|
||||
wait_for_launch client1.fifo 5
|
||||
|
||||
echo "[*] start demo recording"
|
||||
echo "[*] Start demo recording"
|
||||
echo "record server" > server.fifo
|
||||
echo "record client1" > client1.fifo
|
||||
sleep 1
|
||||
|
||||
echo "[*] launch client 2"
|
||||
echo "[*] Launch client 2"
|
||||
$tool ../DDNet \
|
||||
"cl_input_fifo client2.fifo;
|
||||
player_name client2;
|
||||
cl_download_skins 0;
|
||||
gfx_fullscreen 0;
|
||||
snd_enable 0;
|
||||
logfile client2.log;
|
||||
$client_args
|
||||
connect localhost:$port" > stdout_client2.txt 2> stderr_client2.txt || fail client2 "$?" &
|
||||
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||
wait_for_fifo client2.fifo 180
|
||||
sleep 40
|
||||
else
|
||||
wait_for_fifo client2.fifo 50
|
||||
sleep 2
|
||||
fi
|
||||
wait_for_launch client2.fifo 5
|
||||
|
||||
echo "[*] test chat and chat commands"
|
||||
echo "[*] Test chat and chat commands"
|
||||
echo "say hello world" > client1.fifo
|
||||
echo "rcon_auth rcon" > client1.fifo
|
||||
sleep 1
|
||||
|
@ -236,7 +244,7 @@ say "/mc
|
|||
EOF
|
||||
sleep 1
|
||||
|
||||
echo "[*] test rcon commands"
|
||||
echo "[*] Test rcon commands"
|
||||
tr -d '\n' > client1.fifo << EOF
|
||||
rcon say hello from admin;
|
||||
rcon broadcast test;
|
||||
|
@ -247,12 +255,12 @@ unban_all;
|
|||
EOF
|
||||
sleep 1
|
||||
|
||||
echo "[*] stop demo recording"
|
||||
echo "[*] Stop demo recording"
|
||||
echo "stoprecord" > server.fifo
|
||||
echo "stoprecord" > client1.fifo
|
||||
sleep 1
|
||||
|
||||
echo "[*] test map change"
|
||||
echo "[*] Test map change"
|
||||
echo "rcon sv_map Tutorial" > client1.fifo
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||
sleep 60
|
||||
|
@ -260,7 +268,7 @@ else
|
|||
sleep 15
|
||||
fi
|
||||
|
||||
echo "[*] play demos"
|
||||
echo "[*] Play demos"
|
||||
echo "play demos/server.demo" > client1.fifo
|
||||
echo "play demos/client1.demo" > client2.fifo
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||
|
@ -271,8 +279,6 @@ fi
|
|||
|
||||
# Kill all processes first so all outputs are fully written
|
||||
kill_all
|
||||
wait
|
||||
sleep 1
|
||||
|
||||
if ! grep -qE '^[0-9]{4}-[0-9]{2}-[0-9]{2} ([0-9]{2}:){2}[0-9]{2} I chat: 0:-2:client1: hello world$' server.log
|
||||
then
|
||||
|
@ -331,7 +337,7 @@ do
|
|||
fi
|
||||
if [ ! -f "$logfile" ]
|
||||
then
|
||||
echo "[-] Error: logfile '$logfile' not found."
|
||||
echo "[-] Error: logfile '$logfile' not found"
|
||||
touch fail_logs.txt
|
||||
continue
|
||||
fi
|
||||
|
@ -366,10 +372,9 @@ then
|
|||
cat "$fail"
|
||||
done
|
||||
print_results
|
||||
echo "[-] Test failed. See errors above."
|
||||
echo "[-] Test failed. See errors above"
|
||||
exit 1
|
||||
else
|
||||
echo "[*] all tests passed"
|
||||
fi
|
||||
|
||||
echo "[*] All tests passed"
|
||||
print_results || exit 1
|
||||
|
|
|
@ -963,6 +963,9 @@ int64_t time_freq()
|
|||
}
|
||||
|
||||
/* ----- 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)
|
||||
{
|
||||
mem_zero(dest, sizeof(struct sockaddr_in));
|
||||
|
|
|
@ -777,6 +777,8 @@ typedef struct NETADDR
|
|||
bool operator!=(const NETADDR &other) const { return !(*this == other); }
|
||||
} NETADDR;
|
||||
|
||||
extern const NETADDR NETADDR_ZEROED;
|
||||
|
||||
#ifdef CONF_FAMILY_UNIX
|
||||
/**
|
||||
* @ingroup Network-General
|
||||
|
|
|
@ -69,31 +69,30 @@ public:
|
|||
|
||||
protected:
|
||||
// quick access to state of the client
|
||||
EClientState m_State;
|
||||
ELoadingStateDetail m_LoadingStateDetail;
|
||||
EClientState m_State = IClient::STATE_OFFLINE;
|
||||
ELoadingStateDetail m_LoadingStateDetail = LOADING_STATE_DETAIL_INITIAL;
|
||||
int64_t m_StateStartTime;
|
||||
|
||||
// quick access to time variables
|
||||
int m_aPrevGameTick[NUM_DUMMIES];
|
||||
int m_aCurGameTick[NUM_DUMMIES];
|
||||
float m_aGameIntraTick[NUM_DUMMIES];
|
||||
float m_aGameTickTime[NUM_DUMMIES];
|
||||
float m_aGameIntraTickSincePrev[NUM_DUMMIES];
|
||||
int m_aPrevGameTick[NUM_DUMMIES] = {0, 0};
|
||||
int m_aCurGameTick[NUM_DUMMIES] = {0, 0};
|
||||
float m_aGameIntraTick[NUM_DUMMIES] = {0.0f, 0.0f};
|
||||
float m_aGameTickTime[NUM_DUMMIES] = {0.0f, 0.0f};
|
||||
float m_aGameIntraTickSincePrev[NUM_DUMMIES] = {0.0f, 0.0f};
|
||||
|
||||
int m_aPredTick[NUM_DUMMIES];
|
||||
float m_aPredIntraTick[NUM_DUMMIES];
|
||||
int m_aPredTick[NUM_DUMMIES] = {0, 0};
|
||||
float m_aPredIntraTick[NUM_DUMMIES] = {0.0f, 0.0f};
|
||||
|
||||
float m_LocalTime;
|
||||
float m_GlobalTime;
|
||||
float m_RenderFrameTime;
|
||||
float m_LocalTime = 0.0f;
|
||||
float m_GlobalTime = 0.0f;
|
||||
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;
|
||||
int64_t m_ReconnectTime;
|
||||
char m_aNews[3000] = "";
|
||||
int m_Points = -1;
|
||||
int64_t m_ReconnectTime = 0;
|
||||
|
||||
public:
|
||||
class CSnapItem
|
||||
|
|
|
@ -77,104 +77,21 @@ static const ColorRGBA gs_ClientNetworkErrPrintColor{1.0f, 0.25f, 0.25f, 1.0f};
|
|||
CClient::CClient() :
|
||||
m_DemoPlayer(&m_SnapshotDelta, true, [&]() { UpdateDemoIntraTimers(); })
|
||||
{
|
||||
m_StateStartTime = time_get();
|
||||
for(auto &DemoRecorder : m_aDemoRecorder)
|
||||
DemoRecorder = CDemoRecorder(&m_SnapshotDelta);
|
||||
|
||||
m_RenderFrameTime = 0.0001f;
|
||||
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);
|
||||
m_pDDNetInfoTask = NULL;
|
||||
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_aInputs, sizeof(m_aInputs));
|
||||
mem_zero(m_aapSnapshots, sizeof(m_aapSnapshots));
|
||||
m_aSnapshotStorage[0].Init();
|
||||
m_aSnapshotStorage[1].Init();
|
||||
m_aReceivedSnapshots[0] = 0;
|
||||
m_aReceivedSnapshots[1] = 0;
|
||||
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;
|
||||
|
||||
for(auto &SnapshotStorage : m_aSnapshotStorage)
|
||||
SnapshotStorage.Init();
|
||||
mem_zero(m_aDemorecSnapshotHolders, sizeof(m_aDemorecSnapshotHolders));
|
||||
mem_zero(&m_CurrentServerInfo, sizeof(m_CurrentServerInfo));
|
||||
mem_zero(&m_Checksum, sizeof(m_Checksum));
|
||||
for(auto &GameTime : m_aGameTime)
|
||||
GameTime.Init(0);
|
||||
m_PredictedTime.Init(0);
|
||||
}
|
||||
|
||||
// ----- send functions -----
|
||||
|
@ -610,6 +527,8 @@ void CClient::DisconnectWithReason(const char *pReason)
|
|||
if(pReason != nullptr && pReason[0] == '\0')
|
||||
pReason = nullptr;
|
||||
|
||||
DummyDisconnect(pReason);
|
||||
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "disconnecting. reason='%s'", pReason ? pReason : "unknown");
|
||||
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));
|
||||
|
||||
// clear snapshots
|
||||
m_aapSnapshots[g_Config.m_ClDummy][SNAP_CURRENT] = 0;
|
||||
m_aapSnapshots[g_Config.m_ClDummy][SNAP_PREV] = 0;
|
||||
m_aReceivedSnapshots[g_Config.m_ClDummy] = 0;
|
||||
m_aapSnapshots[0][SNAP_CURRENT] = 0;
|
||||
m_aapSnapshots[0][SNAP_PREV] = 0;
|
||||
m_aReceivedSnapshots[0] = 0;
|
||||
}
|
||||
|
||||
void CClient::Disconnect()
|
||||
{
|
||||
m_ButtonRender = false;
|
||||
if(m_DummyConnected)
|
||||
DummyDisconnect(0);
|
||||
if(m_State != IClient::STATE_OFFLINE)
|
||||
DisconnectWithReason(0);
|
||||
|
||||
|
@ -2273,7 +2190,6 @@ void CClient::LoadDDNetInfo()
|
|||
NETADDR Addr;
|
||||
if(!net_addr_from_str(&Addr, ConnectingIp))
|
||||
{
|
||||
m_HaveGlobalTcpAddr = true;
|
||||
m_GlobalTcpAddr = Addr;
|
||||
log_debug("info", "got global tcp ip address: %s", (const char *)ConnectingIp);
|
||||
}
|
||||
|
@ -4735,7 +4651,7 @@ int CClient::UdpConnectivity(int NetType)
|
|||
break;
|
||||
case CONNECTIVITY::ADDRESS_KNOWN:
|
||||
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;
|
||||
break;
|
||||
|
|
|
@ -48,11 +48,11 @@ class IUpdater;
|
|||
class CServerCapabilities
|
||||
{
|
||||
public:
|
||||
bool m_ChatTimeoutCode;
|
||||
bool m_AnyPlayerFlag;
|
||||
bool m_PingEx;
|
||||
bool m_AllowDummy;
|
||||
bool m_SyncWeaponInput;
|
||||
bool m_ChatTimeoutCode = false;
|
||||
bool m_AnyPlayerFlag = false;
|
||||
bool m_PingEx = false;
|
||||
bool m_AllowDummy = false;
|
||||
bool m_SyncWeaponInput = false;
|
||||
};
|
||||
|
||||
class CClient : public IClient, public CDemoPlayer::IListener
|
||||
|
@ -86,78 +86,76 @@ class CClient : public IClient, public CDemoPlayer::IListener
|
|||
CFriends m_Friends;
|
||||
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 m_GlobalTcpAddr = NETADDR_ZEROED;
|
||||
|
||||
uint64_t m_aSnapshotParts[NUM_DUMMIES];
|
||||
int64_t m_LocalStartTime;
|
||||
int64_t m_GlobalStartTime;
|
||||
uint64_t m_aSnapshotParts[NUM_DUMMIES] = {0, 0};
|
||||
int64_t m_LocalStartTime = 0;
|
||||
int64_t m_GlobalStartTime = 0;
|
||||
|
||||
IGraphics::CTextureHandle m_DebugFont;
|
||||
|
||||
int64_t m_LastRenderTime;
|
||||
|
||||
int m_SnapCrcErrors;
|
||||
bool m_AutoScreenshotRecycle;
|
||||
bool m_AutoStatScreenshotRecycle;
|
||||
bool m_AutoCSVRecycle;
|
||||
bool m_EditorActive;
|
||||
bool m_SoundInitFailed;
|
||||
int m_SnapCrcErrors = 0;
|
||||
bool m_AutoScreenshotRecycle = false;
|
||||
bool m_AutoStatScreenshotRecycle = false;
|
||||
bool m_AutoCSVRecycle = false;
|
||||
bool m_EditorActive = false;
|
||||
bool m_SoundInitFailed = false;
|
||||
|
||||
int m_aAckGameTick[NUM_DUMMIES];
|
||||
int m_aCurrentRecvTick[NUM_DUMMIES];
|
||||
int m_aRconAuthed[NUM_DUMMIES];
|
||||
char m_aRconUsername[32];
|
||||
char m_aRconPassword[sizeof(g_Config.m_SvRconPassword)];
|
||||
int m_UseTempRconCommands;
|
||||
char m_aPassword[sizeof(g_Config.m_Password)];
|
||||
bool m_SendPassword;
|
||||
int m_aAckGameTick[NUM_DUMMIES] = {-1, -1};
|
||||
int m_aCurrentRecvTick[NUM_DUMMIES] = {0, 0};
|
||||
int m_aRconAuthed[NUM_DUMMIES] = {0, 0};
|
||||
char m_aRconUsername[32] = "";
|
||||
char m_aRconPassword[sizeof(g_Config.m_SvRconPassword)] = "";
|
||||
int m_UseTempRconCommands = 0;
|
||||
char m_aPassword[sizeof(g_Config.m_Password)] = "";
|
||||
bool m_SendPassword = false;
|
||||
bool m_ButtonRender = false;
|
||||
|
||||
// version-checking
|
||||
char m_aVersionStr[10];
|
||||
char m_aVersionStr[10] = "0";
|
||||
|
||||
// pinging
|
||||
int64_t m_PingStartTime;
|
||||
int64_t m_PingStartTime = 0;
|
||||
|
||||
char m_aCurrentMap[IO_MAX_PATH_LENGTH];
|
||||
char m_aCurrentMapPath[IO_MAX_PATH_LENGTH];
|
||||
char m_aCurrentMap[IO_MAX_PATH_LENGTH] = "";
|
||||
char m_aCurrentMapPath[IO_MAX_PATH_LENGTH] = "";
|
||||
|
||||
char m_aTimeoutCodes[NUM_DUMMIES][32];
|
||||
bool m_aCodeRunAfterJoin[NUM_DUMMIES];
|
||||
bool m_GenerateTimeoutSeed;
|
||||
char m_aTimeoutCodes[NUM_DUMMIES][32] = {"", ""};
|
||||
bool m_aCodeRunAfterJoin[NUM_DUMMIES] = {false, false};
|
||||
bool m_GenerateTimeoutSeed = true;
|
||||
|
||||
//
|
||||
char m_aCmdConnect[256];
|
||||
char m_aCmdPlayDemo[IO_MAX_PATH_LENGTH];
|
||||
char m_aCmdEditMap[IO_MAX_PATH_LENGTH];
|
||||
char m_aCmdConnect[256] = "";
|
||||
char m_aCmdPlayDemo[IO_MAX_PATH_LENGTH] = "";
|
||||
char m_aCmdEditMap[IO_MAX_PATH_LENGTH] = "";
|
||||
|
||||
// map download
|
||||
char m_aMapDownloadUrl[256];
|
||||
std::shared_ptr<CHttpRequest> m_pMapdownloadTask;
|
||||
char m_aMapdownloadFilename[256];
|
||||
char m_aMapdownloadFilenameTemp[256];
|
||||
char m_aMapdownloadName[256];
|
||||
IOHANDLE m_MapdownloadFileTemp;
|
||||
int m_MapdownloadChunk;
|
||||
int m_MapdownloadCrc;
|
||||
int m_MapdownloadAmount;
|
||||
int m_MapdownloadTotalsize;
|
||||
bool m_MapdownloadSha256Present;
|
||||
SHA256_DIGEST m_MapdownloadSha256;
|
||||
char m_aMapDownloadUrl[256] = "";
|
||||
std::shared_ptr<CHttpRequest> m_pMapdownloadTask = nullptr;
|
||||
char m_aMapdownloadFilename[256] = "";
|
||||
char m_aMapdownloadFilenameTemp[256] = "";
|
||||
char m_aMapdownloadName[256] = "";
|
||||
IOHANDLE m_MapdownloadFileTemp = 0;
|
||||
int m_MapdownloadChunk = 0;
|
||||
int m_MapdownloadCrc = 0;
|
||||
int m_MapdownloadAmount = -1;
|
||||
int m_MapdownloadTotalsize = -1;
|
||||
bool m_MapdownloadSha256Present = false;
|
||||
SHA256_DIGEST m_MapdownloadSha256 = SHA256_ZEROED;
|
||||
|
||||
bool m_MapDetailsPresent;
|
||||
char m_aMapDetailsName[256];
|
||||
int m_MapDetailsCrc;
|
||||
SHA256_DIGEST m_MapDetailsSha256;
|
||||
char m_aMapDetailsUrl[256];
|
||||
bool m_MapDetailsPresent = false;
|
||||
char m_aMapDetailsName[256] = "";
|
||||
int m_MapDetailsCrc = 0;
|
||||
SHA256_DIGEST m_MapDetailsSha256 = SHA256_ZEROED;
|
||||
char m_aMapDetailsUrl[256] = "";
|
||||
|
||||
char m_aDDNetInfoTmp[64];
|
||||
std::shared_ptr<CHttpRequest> m_pDDNetInfoTask;
|
||||
std::shared_ptr<CHttpRequest> m_pDDNetInfoTask = nullptr;
|
||||
|
||||
// time
|
||||
CSmoothTime m_aGameTime[NUM_DUMMIES];
|
||||
|
@ -173,9 +171,11 @@ class CClient : public IClient, public CDemoPlayer::IListener
|
|||
int64_t m_Time;
|
||||
} m_aInputs[NUM_DUMMIES][200];
|
||||
|
||||
int m_aCurrentInput[NUM_DUMMIES];
|
||||
bool m_LastDummy;
|
||||
bool m_DummySendConnInfo;
|
||||
int m_aCurrentInput[NUM_DUMMIES] = {0, 0};
|
||||
bool m_LastDummy = false;
|
||||
bool m_DummySendConnInfo = false;
|
||||
bool m_DummyConnected = false;
|
||||
int m_LastDummyConnectTime = 0;
|
||||
|
||||
// graphs
|
||||
CGraph m_InputtimeMarginGraph;
|
||||
|
@ -186,9 +186,9 @@ class CClient : public IClient, public CDemoPlayer::IListener
|
|||
CSnapshotStorage m_aSnapshotStorage[NUM_DUMMIES];
|
||||
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];
|
||||
int m_aSnapshotIncomingDataSize[NUM_DUMMIES];
|
||||
int m_aSnapshotIncomingDataSize[NUM_DUMMIES] = {0, 0};
|
||||
|
||||
CSnapshotStorage::CHolder m_aDemorecSnapshotHolders[NUM_SNAPSHOT_TYPES];
|
||||
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;
|
||||
|
||||
//
|
||||
bool m_CanReceiveServerCapabilities;
|
||||
bool m_ServerSentCapabilities;
|
||||
bool m_CanReceiveServerCapabilities = false;
|
||||
bool m_ServerSentCapabilities = false;
|
||||
CServerCapabilities m_ServerCapabilities;
|
||||
|
||||
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_CurrentServerPingBasicToken;
|
||||
int m_CurrentServerPingToken;
|
||||
CUuid m_CurrentServerPingUuid;
|
||||
int64_t m_CurrentServerCurrentPingTime; // >= 0 request running
|
||||
int64_t m_CurrentServerNextPingTime; // >= 0 should request
|
||||
int m_CurrentServerPingInfoType = -1;
|
||||
int m_CurrentServerPingBasicToken = -1;
|
||||
int m_CurrentServerPingToken = -1;
|
||||
CUuid m_CurrentServerPingUuid = UUID_ZEROED;
|
||||
int64_t m_CurrentServerCurrentPingTime = -1; // >= 0 request running
|
||||
int64_t m_CurrentServerNextPingTime = -1; // >= 0 should request
|
||||
|
||||
// version info
|
||||
struct CVersionInfo
|
||||
|
@ -222,19 +222,19 @@ class CClient : public IClient, public CDemoPlayer::IListener
|
|||
STATE_READY,
|
||||
};
|
||||
|
||||
int m_State;
|
||||
int m_State = STATE_INIT;
|
||||
} m_VersionInfo;
|
||||
|
||||
std::vector<SWarning> m_vWarnings;
|
||||
|
||||
CFifo m_Fifo;
|
||||
|
||||
IOHANDLE m_BenchmarkFile;
|
||||
int64_t m_BenchmarkStopTime;
|
||||
IOHANDLE m_BenchmarkFile = 0;
|
||||
int64_t m_BenchmarkStopTime = 0;
|
||||
|
||||
CChecksum m_Checksum;
|
||||
int m_OwnExecutableSize = 0;
|
||||
IOHANDLE m_OwnExecutable;
|
||||
IOHANDLE m_OwnExecutable = 0;
|
||||
|
||||
// favorite command handling
|
||||
bool m_FavoritesGroup = false;
|
||||
|
@ -310,8 +310,6 @@ public:
|
|||
bool DummyConnected() override;
|
||||
bool DummyConnecting() override;
|
||||
bool DummyAllowed() override;
|
||||
int m_DummyConnected;
|
||||
int m_LastDummyConnectTime;
|
||||
|
||||
void GetServerInfo(CServerInfo *pServerInfo) const override;
|
||||
void ServerInfoRequest();
|
||||
|
|
|
@ -57,17 +57,10 @@ CServerBrowser::CServerBrowser() :
|
|||
m_ppServerlist = nullptr;
|
||||
m_pSortedServerlist = nullptr;
|
||||
|
||||
m_pFirstReqServer = nullptr; // request list
|
||||
m_pLastReqServer = nullptr;
|
||||
m_NumRequests = 0;
|
||||
|
||||
m_NeedResort = false;
|
||||
m_Sorthash = 0;
|
||||
|
||||
m_NumSortedServers = 0;
|
||||
m_NumSortedServersCapacity = 0;
|
||||
m_NumSortedPlayers = 0;
|
||||
m_NumServers = 0;
|
||||
m_NumServerCapacity = 0;
|
||||
|
||||
m_ServerlistType = 0;
|
||||
|
@ -76,6 +69,8 @@ CServerBrowser::CServerBrowser() :
|
|||
|
||||
m_pDDNetInfo = nullptr;
|
||||
m_DDNetInfoUpdateTime = 0;
|
||||
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
CServerBrowser::~CServerBrowser()
|
||||
|
|
|
@ -13,6 +13,7 @@ void CSmoothTime::Init(int64_t Target)
|
|||
m_Current = Target;
|
||||
m_Target = Target;
|
||||
m_Margin = 0;
|
||||
m_SpikeCounter = 0;
|
||||
m_aAdjustSpeed[ADJUSTDIRECTION_DOWN] = 0.3f;
|
||||
m_aAdjustSpeed[ADJUSTDIRECTION_UP] = 0.3f;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@ static const CUuid TEEWORLDS_NAMESPACE = {{// "e05ddaaa-c4e6-4cfb-b642-5d48e80c0
|
|||
0xe0, 0x5d, 0xda, 0xaa, 0xc4, 0xe6, 0x4c, 0xfb,
|
||||
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 Result;
|
||||
|
|
|
@ -24,6 +24,8 @@ struct CUuid
|
|||
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 CalculateUuid(const char *pName);
|
||||
// The buffer length should be at least UUID_MAXSTRSIZE.
|
||||
|
|
Loading…
Reference in a new issue