From 0828184055a4b94776810ba8e3994132fae72321 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 5 Nov 2022 12:11:36 +0100 Subject: [PATCH] - did some cleanup on the statistics code. --- src/d_anonstats.cpp | 33 ++++++++++++++++----------------- src/playsim/p_local.h | 1 - 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/d_anonstats.cpp b/src/d_anonstats.cpp index 6d3da51ec4..d99e7a89cb 100644 --- a/src/d_anonstats.cpp +++ b/src/d_anonstats.cpp @@ -39,13 +39,12 @@ extern int sys_ostype; #include "gl_interface.h" #include "printf.h" -CVAR(Int, sys_statsenabled47, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOSET) +CVAR(Int, sys_statsenabled49, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOSET) CVAR(String, sys_statshost, "gzstats.drdteam.org", CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOSET) CVAR(Int, sys_statsport, 80, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOSET) -// Each machine will only send two reports, one when started with hardware rendering and one when started with software rendering. -#define CHECKVERSION 470 -#define CHECKVERSIONSTR "470" +#define CHECKVERSION 490 +#define CHECKVERSIONSTR "490" CVAR(Int, sentstats_hwr_done, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOSET) std::pair gl_getInfo(); @@ -75,7 +74,7 @@ FString URLencode(const char *s) bool I_HTTPRequest(const char* request) { - if (sys_statshost.GetHumanString() == NULL) + if ((*sys_statshost)[0] == 0) return false; // no host, disable WSADATA wsaData; @@ -86,7 +85,7 @@ bool I_HTTPRequest(const char* request) } SOCKET Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); struct hostent *host; - host = gethostbyname(sys_statshost.GetHumanString()); + host = gethostbyname(sys_statshost); if (host == nullptr) { DPrintf(DMSG_ERROR, "Error looking up hostname.\n"); @@ -96,10 +95,10 @@ bool I_HTTPRequest(const char* request) SockAddr.sin_port = htons(sys_statsport); SockAddr.sin_family = AF_INET; SockAddr.sin_addr.s_addr = *((uint32_t*)host->h_addr); - DPrintf(DMSG_NOTIFY, "Connecting to host %s\n", sys_statshost.GetHumanString()); + DPrintf(DMSG_NOTIFY, "Connecting to host %s\n", *sys_statshost); if (connect(Socket, (SOCKADDR*)(&SockAddr), sizeof(SockAddr)) != 0) { - DPrintf(DMSG_ERROR, "Connection to host %s failed!\n", sys_statshost.GetHumanString()); + DPrintf(DMSG_ERROR, "Connection to host %s failed!\n", *sys_statshost); return false; } send(Socket, request, (int)strlen(request), 0); @@ -121,8 +120,8 @@ bool I_HTTPRequest(const char* request) #else bool I_HTTPRequest(const char* request) { - if (sys_statshost.GetHumanString() == NULL || sys_statshost.GetHumanString()[0] == 0) - return false; // no host, disable + if ((*sys_statshost)[0] == 0) + actor-> return false; // no host, disable int sockfd, portno, n; struct sockaddr_in serv_addr; @@ -137,7 +136,7 @@ bool I_HTTPRequest(const char* request) return false; } - server = gethostbyname(sys_statshost.GetHumanString()); + server = gethostbyname(sys_statshost); if (server == NULL) { DPrintf(DMSG_ERROR, "Error looking up hostname.\n"); @@ -150,10 +149,10 @@ bool I_HTTPRequest(const char* request) server->h_length); serv_addr.sin_port = htons(portno); - DPrintf(DMSG_NOTIFY, "Connecting to host %s\n", sys_statshost.GetHumanString()); + DPrintf(DMSG_NOTIFY, "Connecting to host %s\n", *sys_statshost); if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { - DPrintf(DMSG_ERROR, "Connection to host %s failed!\n", sys_statshost.GetHumanString()); + DPrintf(DMSG_ERROR, "Connection to host %s failed!\n", *sys_statshost); return false; } @@ -296,7 +295,7 @@ void D_DoAnonStats() { #ifndef _DEBUG // Do not repeat if already sent. - if (sys_statsenabled47 != 1 || sentstats_hwr_done >= CHECKVERSION) + if (sys_statsenabled49 != 1 || sentstats_hwr_done >= CHECKVERSION) { return; } @@ -309,7 +308,7 @@ void D_DoAnonStats() static char requeststring[1024]; mysnprintf(requeststring, sizeof requeststring, "GET /stats_202109.py?render=%i&cores=%i&os=%i&glversion=%i&vendor=%s&model=%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nUser-Agent: %s %s\r\n\r\n", - GetRenderInfo(), GetCoreInfo(), GetOSVersion(), GetGLVersion(), URLencode(screen->vendorstring).GetChars(), URLencode(screen->DeviceName()).GetChars(), sys_statshost.GetHumanString(), GAMENAME, VERSIONSTR); + GetRenderInfo(), GetCoreInfo(), GetOSVersion(), GetGLVersion(), URLencode(screen->vendorstring).GetChars(), URLencode(screen->DeviceName()).GetChars(), *sys_statshost, GAMENAME, VERSIONSTR); DPrintf(DMSG_NOTIFY, "Sending %s", requeststring); #if 1//ndef _DEBUG // Don't send info in debug builds @@ -322,7 +321,7 @@ void D_DoAnonStats() void D_ConfirmSendStats() { - if (sys_statsenabled47 >= 0) + if (sys_statsenabled49 >= 0) { return; } @@ -378,7 +377,7 @@ void D_ConfirmSendStats() enabled.Int = SDL_ShowMessageBox(&messageboxdata, &buttonid) == 0 && buttonid == 0; #endif // _WIN32 - sys_statsenabled47.ForceSet(enabled, CVAR_Int); + sys_statsenabled49->ForceSet(enabled, CVAR_Int); } #endif // NO_SEND_STATS diff --git a/src/playsim/p_local.h b/src/playsim/p_local.h index cc48c4259e..9ea6202ce8 100644 --- a/src/playsim/p_local.h +++ b/src/playsim/p_local.h @@ -92,7 +92,6 @@ void P_PredictionLerpReset(); #define SPF_TEMPPLAYER 1 // spawning a short-lived dummy player #define SPF_WEAPONFULLYUP 2 // spawn with weapon already raised -int P_FaceMobj (AActor *source, AActor *target, DAngle *delta); bool P_SeekerMissile (AActor *actor, DAngle thresh, DAngle turnMax, bool precise = false, bool usecurspeed=false); enum EPuffFlags