Manual preparation for cleaner clang-format

Also include what you use explicitly
This commit is contained in:
def 2020-09-25 18:11:59 +02:00
parent a5cf31040b
commit 0bac9f0de8
23 changed files with 178 additions and 172 deletions

View File

@ -2,12 +2,16 @@
Language: Cpp
AccessModifierOffset: -8
AlignAfterOpenBracket: DontAlign
AlignEscapedNewlines: DontAlign
AlignTrailingComments: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AlwaysBreakTemplateDeclarations: true
BasedOnStyle: LLVM
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
BreakStringLiterals: true
BraceWrapping:
AfterCaseLabel: true

View File

@ -30,9 +30,9 @@ struct CAntibotInputData
// Defined by the network protocol, unlikely to change.
//enum
//{
//TEAM_SPECTATORS=-1,
//TEAM_RED=0,
//TEAM_BLUE=1,
// TEAM_SPECTATORS=-1,
// TEAM_RED=0,
// TEAM_BLUE=1,
//};
struct CAntibotCharacterData

View File

@ -22,18 +22,18 @@ void AntibotDump(void)
{
g_pData->m_pfnLog("null antibot", g_pData->m_pUser);
}
void AntibotOnPlayerInit(int ClientID) { (void)ClientID; }
void AntibotOnPlayerDestroy(int ClientID) { (void)ClientID; }
void AntibotOnSpawn(int ClientID) { (void)ClientID; }
void AntibotOnHammerFireReloading(int ClientID) { (void)ClientID; }
void AntibotOnHammerFire(int ClientID) { (void)ClientID; }
void AntibotOnHammerHit(int ClientID) { (void)ClientID; }
void AntibotOnDirectInput(int ClientID) { (void)ClientID; }
void AntibotOnCharacterTick(int ClientID) { (void)ClientID; }
void AntibotOnHookAttach(int ClientID, bool Player) { (void)ClientID; (void)Player; }
void AntibotOnEngineTick(void) { }
void AntibotOnEngineClientJoin(int ClientID, bool Sixup) { (void)ClientID; (void)Sixup; }
void AntibotOnEngineClientDrop(int ClientID, const char *pReason) { (void)ClientID; (void)pReason; }
void AntibotOnEngineClientMessage(int ClientID, const void *pData, int Size, int Flags) { (void)ClientID; (void)pData; (void)Size; (void)Flags; }
void AntibotOnPlayerInit(int /*ClientID*/) {}
void AntibotOnPlayerDestroy(int /*ClientID*/) {}
void AntibotOnSpawn(int /*ClientID*/) {}
void AntibotOnHammerFireReloading(int /*ClientID*/) {}
void AntibotOnHammerFire(int /*ClientID*/) {}
void AntibotOnHammerHit(int /*ClientID*/) {}
void AntibotOnDirectInput(int /*ClientID*/) {}
void AntibotOnCharacterTick(int /*ClientID*/) {}
void AntibotOnHookAttach(int /*ClientID*/, bool /*Player*/) {}
void AntibotOnEngineTick(void) {}
void AntibotOnEngineClientJoin(int /*ClientID*/, bool /*Sixup*/) {}
void AntibotOnEngineClientDrop(int /*ClientID*/, const char * /*pReason*/) {}
void AntibotOnEngineClientMessage(int /*ClientID*/, const void * /*pData*/, int /*Size*/, int /*Flags*/) {}
}

View File

@ -52,6 +52,7 @@
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <fcntl.h>
#include <direct.h>
#include <errno.h>
@ -3335,8 +3336,8 @@ int os_is_winxp_or_lower(void)
mem_zero(&ver, sizeof(OSVERSIONINFO));
ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&ver);
return ver.dwMajorVersion < WINXP_MAJOR
|| (ver.dwMajorVersion == WINXP_MAJOR && ver.dwMinorVersion <= WINXP_MINOR);
return ver.dwMajorVersion < WINXP_MAJOR ||
(ver.dwMajorVersion == WINXP_MAJOR && ver.dwMinorVersion <= WINXP_MINOR);
#else
return 0;
#endif

View File

@ -3651,7 +3651,7 @@ static void ParseVersionString(const GLubyte* pStr, int& VersionMajor, int& Vers
char aCurNumberStr[32];
size_t CurNumberStrLen = 0;
size_t TotalNumbersPassed = 0;
int aNumbers[3] = { 0, };
int aNumbers[3] = { 0 };
bool LastWasNumber = false;
while(*pStr && TotalNumbersPassed < 3)
{

View File

@ -1380,8 +1380,8 @@ void CClient::ProcessServerInfo(int RawType, NETADDR *pFrom, const void *pData,
CServerInfo Info = {0};
int SavedType = SavedServerInfoType(RawType);
if((SavedType == SERVERINFO_64_LEGACY || SavedType == SERVERINFO_EXTENDED)
&& pEntry && pEntry->m_GotInfo && SavedType == pEntry->m_Info.m_Type)
if((SavedType == SERVERINFO_64_LEGACY || SavedType == SERVERINFO_EXTENDED) &&
pEntry && pEntry->m_GotInfo && SavedType == pEntry->m_Info.m_Type)
{
Info = pEntry->m_Info;
}
@ -2527,8 +2527,8 @@ void CClient::PumpNetwork()
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf);
}
if(State() != IClient::STATE_OFFLINE && State() < IClient::STATE_QUITING && m_DummyConnected
&& m_NetClient[CLIENT_DUMMY].State() == NETSTATE_OFFLINE)
if(State() != IClient::STATE_OFFLINE && State() < IClient::STATE_QUITING && m_DummyConnected &&
m_NetClient[CLIENT_DUMMY].State() == NETSTATE_OFFLINE)
{
DummyDisconnect(0);
char aBuf[256];
@ -3219,9 +3219,9 @@ void CClient::Run()
bool IsRenderActive = (g_Config.m_GfxBackgroundRender || m_pGraphics->WindowOpen());
if(IsRenderActive
&& (!g_Config.m_GfxAsyncRenderOld || m_pGraphics->IsIdle())
&& (!g_Config.m_GfxRefreshRate || (time_freq() / (int64)g_Config.m_GfxRefreshRate) <= Now - LastRenderTime))
if(IsRenderActive &&
(!g_Config.m_GfxAsyncRenderOld || m_pGraphics->IsIdle()) &&
(!g_Config.m_GfxRefreshRate || (time_freq() / (int64)g_Config.m_GfxRefreshRate) <= Now - LastRenderTime))
{
m_RenderFrames++;

View File

@ -2,6 +2,8 @@
#define ENGINE_CLIENT_DEMOEDIT_H
#include <engine/client/http.h>
#include <engine/shared/demo.h>
#include <engine/shared/snapshot.h>
#define CONNECTLINK "ddnet:"

View File

@ -2091,8 +2091,7 @@ int CGraphics_Threaded::Init()
0xff,0x00,0x00,0xff, 0xff,0x00,0x00,0xff, 0x00,0xff,0x00,0xff, 0x00,0xff,0x00,0xff,
0xff,0x00,0x00,0xff, 0xff,0x00,0x00,0xff, 0x00,0xff,0x00,0xff, 0x00,0xff,0x00,0xff,
0x00,0x00,0xff,0xff, 0x00,0x00,0xff,0xff, 0xff,0xff,0x00,0xff, 0xff,0xff,0x00,0xff,
0x00,0x00,0xff,0xff, 0x00,0x00,0xff,0xff, 0xff,0xff,0x00,0xff, 0xff,0xff,0x00,0xff,
};
0x00,0x00,0xff,0xff, 0x00,0x00,0xff,0xff, 0xff,0xff,0x00,0xff, 0xff,0xff,0x00,0xff};
m_InvalidTexture = LoadTextureRaw(4,4,CImageInfo::FORMAT_RGBA,s_aNullTextureData,CImageInfo::FORMAT_RGBA,TEXLOAD_NORESAMPLE);
return 0;

View File

@ -18,12 +18,11 @@ const double g_aSpeeds[] = {0.1, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0, 4.0,
typedef bool (*DEMOFUNC_FILTER)(const void *pData, int DataSize, void *pUser);
// TODO: Properly extend demo format using uuids
// "6be6da4a-cebd-380c-9b5b-1289c842d780"
// "demoitem-sha256@ddnet.tw"
static const CUuid SHA256_EXTENSION = {{
// "6be6da4a-cebd-380c-9b5b-1289c842d780"
// "demoitem-sha256@ddnet.tw"
0x6b, 0xe6, 0xda, 0x4a, 0xce, 0xbd, 0x38, 0x0c,
0x9b, 0x5b, 0x12, 0x89, 0xc8, 0x42, 0xd7, 0x80
}};
0x9b, 0x5b, 0x12, 0x89, 0xc8, 0x42, 0xd7, 0x80}};
struct CDemoHeader
{

3
src/engine/external/.clang-format vendored Normal file
View File

@ -0,0 +1,3 @@
DisableFormat: true
# clang-format bug: still sorts includes even if disabled
SortIncludes: false

View File

@ -18,9 +18,6 @@ protected:
public:
IInterface() : m_pKernel(0) {}
virtual ~IInterface() {}
//virtual unsigned InterfaceID() = 0;
//virtual const char *InterfaceName() = 0;
};
#define MACRO_INTERFACE(Name, ver) \
@ -28,10 +25,6 @@ public:
static const char *InterfaceName() { return Name; } \
private:
//virtual unsigned InterfaceID() { return INTERFACE_ID; }
//virtual const char *InterfaceName() { return name; }
// This kernel thingie makes the structure very flat and basiclly singletons.
// I'm not sure if this is a good idea but it works for now.
class IKernel

View File

@ -6,23 +6,23 @@ void IDbConnection::FormatCreateRace(char *aBuf, unsigned int BufferSize)
{
str_format(aBuf, BufferSize,
"CREATE TABLE IF NOT EXISTS %s_race ("
"Map VARCHAR(128) COLLATE %s NOT NULL, "
"Name VARCHAR(%d) COLLATE %s NOT NULL, "
"Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
"Time FLOAT DEFAULT 0, "
"Server CHAR(4), "
"cp1 FLOAT DEFAULT 0, cp2 FLOAT DEFAULT 0, cp3 FLOAT DEFAULT 0, "
"cp4 FLOAT DEFAULT 0, cp5 FLOAT DEFAULT 0, cp6 FLOAT DEFAULT 0, "
"cp7 FLOAT DEFAULT 0, cp8 FLOAT DEFAULT 0, cp9 FLOAT DEFAULT 0, "
"cp10 FLOAT DEFAULT 0, cp11 FLOAT DEFAULT 0, cp12 FLOAT DEFAULT 0, "
"cp13 FLOAT DEFAULT 0, cp14 FLOAT DEFAULT 0, cp15 FLOAT DEFAULT 0, "
"cp16 FLOAT DEFAULT 0, cp17 FLOAT DEFAULT 0, cp18 FLOAT DEFAULT 0, "
"cp19 FLOAT DEFAULT 0, cp20 FLOAT DEFAULT 0, cp21 FLOAT DEFAULT 0, "
"cp22 FLOAT DEFAULT 0, cp23 FLOAT DEFAULT 0, cp24 FLOAT DEFAULT 0, "
"cp25 FLOAT DEFAULT 0, "
"GameID VARCHAR(64), "
"DDNet7 BOOL DEFAULT FALSE, "
"PRIMARY KEY (Map, Name, Time, Timestamp, Server)"
" Map VARCHAR(128) COLLATE %s NOT NULL, "
" Name VARCHAR(%d) COLLATE %s NOT NULL, "
" Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
" Time FLOAT DEFAULT 0, "
" Server CHAR(4), "
" cp1 FLOAT DEFAULT 0, cp2 FLOAT DEFAULT 0, cp3 FLOAT DEFAULT 0, "
" cp4 FLOAT DEFAULT 0, cp5 FLOAT DEFAULT 0, cp6 FLOAT DEFAULT 0, "
" cp7 FLOAT DEFAULT 0, cp8 FLOAT DEFAULT 0, cp9 FLOAT DEFAULT 0, "
" cp10 FLOAT DEFAULT 0, cp11 FLOAT DEFAULT 0, cp12 FLOAT DEFAULT 0, "
" cp13 FLOAT DEFAULT 0, cp14 FLOAT DEFAULT 0, cp15 FLOAT DEFAULT 0, "
" cp16 FLOAT DEFAULT 0, cp17 FLOAT DEFAULT 0, cp18 FLOAT DEFAULT 0, "
" cp19 FLOAT DEFAULT 0, cp20 FLOAT DEFAULT 0, cp21 FLOAT DEFAULT 0, "
" cp22 FLOAT DEFAULT 0, cp23 FLOAT DEFAULT 0, cp24 FLOAT DEFAULT 0, "
" cp25 FLOAT DEFAULT 0, "
" GameID VARCHAR(64), "
" DDNet7 BOOL DEFAULT FALSE, "
" PRIMARY KEY (Map, Name, Time, Timestamp, Server)"
");",
GetPrefix(), BinaryCollate(), MAX_NAME_LENGTH, BinaryCollate());
}
@ -31,14 +31,14 @@ void IDbConnection::FormatCreateTeamrace(char *aBuf, unsigned int BufferSize, co
{
str_format(aBuf, BufferSize,
"CREATE TABLE IF NOT EXISTS %s_teamrace ("
"Map VARCHAR(128) COLLATE %s NOT NULL, "
"Name VARCHAR(%d) COLLATE %s NOT NULL, "
"Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
"Time FLOAT DEFAULT 0, "
"ID %s NOT NULL, " // VARBINARY(16) for MySQL and BLOB for SQLite
"GameID VARCHAR(64), "
"DDNet7 BOOL DEFAULT FALSE, "
"PRIMARY KEY (ID, Name)"
" Map VARCHAR(128) COLLATE %s NOT NULL, "
" Name VARCHAR(%d) COLLATE %s NOT NULL, "
" Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
" Time FLOAT DEFAULT 0, "
" ID %s NOT NULL, " // VARBINARY(16) for MySQL and BLOB for SQLite
" GameID VARCHAR(64), "
" DDNet7 BOOL DEFAULT FALSE, "
" PRIMARY KEY (ID, Name)"
");",
GetPrefix(), BinaryCollate(), MAX_NAME_LENGTH, BinaryCollate(), pIdType);
}
@ -47,13 +47,13 @@ void IDbConnection::FormatCreateMaps(char *aBuf, unsigned int BufferSize)
{
str_format(aBuf, BufferSize,
"CREATE TABLE IF NOT EXISTS %s_maps ("
"Map VARCHAR(128) COLLATE %s NOT NULL, "
"Server VARCHAR(32) COLLATE %s NOT NULL, "
"Mapper VARCHAR(128) COLLATE %s NOT NULL, "
"Points INT DEFAULT 0, "
"Stars INT DEFAULT 0, "
"Timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, "
"PRIMARY KEY (Map)"
" Map VARCHAR(128) COLLATE %s NOT NULL, "
" Server VARCHAR(32) COLLATE %s NOT NULL, "
" Mapper VARCHAR(128) COLLATE %s NOT NULL, "
" Points INT DEFAULT 0, "
" Stars INT DEFAULT 0, "
" Timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, "
" PRIMARY KEY (Map)"
");",
GetPrefix(), BinaryCollate(), BinaryCollate(), BinaryCollate());
}
@ -62,14 +62,14 @@ void IDbConnection::FormatCreateSaves(char *aBuf, unsigned int BufferSize)
{
str_format(aBuf, BufferSize,
"CREATE TABLE IF NOT EXISTS %s_saves ("
"Savegame TEXT COLLATE %s NOT NULL, "
"Map VARCHAR(128) COLLATE %s NOT NULL, "
"Code VARCHAR(128) COLLATE %s NOT NULL, "
"Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
"Server CHAR(4), "
"DDNet7 BOOL DEFAULT FALSE, "
"SaveID VARCHAR(36) DEFAULT NULL, "
"PRIMARY KEY (Map, Code)"
" Savegame TEXT COLLATE %s NOT NULL, "
" Map VARCHAR(128) COLLATE %s NOT NULL, "
" Code VARCHAR(128) COLLATE %s NOT NULL, "
" Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
" Server CHAR(4), "
" DDNet7 BOOL DEFAULT FALSE, "
" SaveID VARCHAR(36) DEFAULT NULL, "
" PRIMARY KEY (Map, Code)"
");",
GetPrefix(), BinaryCollate(), BinaryCollate(), BinaryCollate());
}
@ -78,9 +78,9 @@ void IDbConnection::FormatCreatePoints(char *aBuf, unsigned int BufferSize)
{
str_format(aBuf, BufferSize,
"CREATE TABLE IF NOT EXISTS %s_points ("
"Name VARCHAR(%d) COLLATE %s NOT NULL, "
"Points INT DEFAULT 0, "
"PRIMARY KEY (Name)"
" Name VARCHAR(%d) COLLATE %s NOT NULL, "
" Points INT DEFAULT 0, "
" PRIMARY KEY (Name)"
");",
GetPrefix(), MAX_NAME_LENGTH, BinaryCollate());
}

View File

@ -4,6 +4,7 @@
#define ENGINE_SERVER_REGISTER_H
#include <engine/masterserver.h>
#include <engine/shared/network.h>
class CRegister
{

View File

@ -3,6 +3,8 @@
#ifndef GAME_CLIENT_ANIMSTATE_H
#define GAME_CLIENT_ANIMSTATE_H
#include <game/generated/client_data.h>
class CAnimState
{
CAnimKeyframe m_Body;

View File

@ -4,6 +4,7 @@
#define GAME_CLIENT_COMPONENTS_GHOST_H
#include <game/client/component.h>
#include <game/client/components/menus.h>
enum
{

View File

@ -3,6 +3,8 @@
#ifndef GAME_EXTRAINFO_H
#define GAME_EXTRAINFO_H
#include <game/generated/protocol.h>
#include <base/vmath.h>
bool UseExtraInfo(const CNetObj_Projectile *pProj);

View File

@ -117,9 +117,9 @@ void CGun::Snap(int SnappingClient)
CCharacter *Char = GameServer()->GetPlayerChar(SnappingClient);
if(SnappingClient > -1 && (GameServer()->m_apPlayers[SnappingClient]->GetTeam() == -1
|| GameServer()->m_apPlayers[SnappingClient]->IsPaused())
&& GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID != SPEC_FREEVIEW)
if(SnappingClient > -1 && (GameServer()->m_apPlayers[SnappingClient]->GetTeam() == -1 ||
GameServer()->m_apPlayers[SnappingClient]->IsPaused()) &&
GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID != SPEC_FREEVIEW)
Char = GameServer()->GetPlayerChar(GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID);
int Tick = (Server()->Tick()%Server()->TickSpeed())%11;

View File

@ -3,6 +3,8 @@
#ifndef GAME_SERVER_ENTITIES_PROJECTILE_H
#define GAME_SERVER_ENTITIES_PROJECTILE_H
#include <game/server/entity.h>
class CProjectile : public CEntity
{
public:

View File

@ -21,6 +21,8 @@
#include "player.h"
#include "teehistorian.h"
#include <memory>
#ifdef _MSC_VER
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;

View File

@ -213,8 +213,8 @@ bool CScore::LoadPlayerDataThread(IDbConnection *pSqlServer, const ISqlData *pGa
// get best race time
str_format(aBuf, sizeof(aBuf),
"SELECT Time, cp1, cp2, cp3, cp4, cp5, cp6, cp7, cp8, cp9, cp10, "
"cp11, cp12, cp13, cp14, cp15, cp16, cp17, cp18, cp19, cp20, "
"cp21, cp22, cp23, cp24, cp25 "
" cp11, cp12, cp13, cp14, cp15, cp16, cp17, cp18, cp19, cp20, "
" cp21, cp22, cp23, cp24, cp25 "
"FROM %s_race "
"WHERE Map = ? AND Name = ? "
"ORDER BY Time ASC "
@ -293,9 +293,9 @@ bool CScore::MapVoteThread(IDbConnection *pSqlServer, const ISqlData *pGameData)
"FROM %s_maps "
"WHERE Map LIKE %s "
"ORDER BY "
"CASE WHEN Map = ? THEN 0 ELSE 1 END, "
"CASE WHEN Map LIKE ? THEN 0 ELSE 1 END, "
"LENGTH(Map), Map "
" CASE WHEN Map = ? THEN 0 ELSE 1 END, "
" CASE WHEN Map LIKE ? THEN 0 ELSE 1 END, "
" LENGTH(Map), Map "
"LIMIT 1;",
pSqlServer->GetPrefix(), pSqlServer->CollateNocase());
pSqlServer->PrepareStatement(aBuf);
@ -354,21 +354,21 @@ bool CScore::MapInfoThread(IDbConnection *pSqlServer, const ISqlData *pGameData)
char aBuf[1024];
str_format(aBuf, sizeof(aBuf),
"SELECT l.Map, l.Server, Mapper, Points, Stars, "
"(SELECT COUNT(Name) FROM %s_race WHERE Map = l.Map) AS Finishes, "
"(SELECT COUNT(DISTINCT Name) FROM %s_race WHERE Map = l.Map) AS Finishers, "
"(SELECT ROUND(AVG(Time)) FROM %s_race WHERE Map = l.Map) AS Average, "
"%s AS Stamp, "
"%s-%s AS Ago, "
"(SELECT MIN(Time) FROM %s_race WHERE Map = l.Map AND Name = ?) AS OwnTime "
" (SELECT COUNT(Name) FROM %s_race WHERE Map = l.Map) AS Finishes, "
" (SELECT COUNT(DISTINCT Name) FROM %s_race WHERE Map = l.Map) AS Finishers, "
" (SELECT ROUND(AVG(Time)) FROM %s_race WHERE Map = l.Map) AS Average, "
" %s AS Stamp, "
" %s-%s AS Ago, "
" (SELECT MIN(Time) FROM %s_race WHERE Map = l.Map AND Name = ?) AS OwnTime "
"FROM ("
"SELECT * FROM %s_maps "
"WHERE Map LIKE %s "
"ORDER BY "
"CASE WHEN Map = ? THEN 0 ELSE 1 END, "
"CASE WHEN Map LIKE ? THEN 0 ELSE 1 END, "
"LENGTH(Map), "
"Map "
"LIMIT 1"
" SELECT * FROM %s_maps "
" WHERE Map LIKE %s "
" ORDER BY "
" CASE WHEN Map = ? THEN 0 ELSE 1 END, "
" CASE WHEN Map LIKE ? THEN 0 ELSE 1 END, "
" LENGTH(Map), "
" Map "
" LIMIT 1"
") as l;",
pSqlServer->GetPrefix(), pSqlServer->GetPrefix(), pSqlServer->GetPrefix(),
aTimestamp, aCurrentTimestamp, aTimestamp,
@ -579,9 +579,9 @@ bool CScore::SaveTeamScoreThread(IDbConnection *pSqlServer, const ISqlData *pGam
str_format(aBuf, sizeof(aBuf),
"SELECT l.ID, Name, Time "
"FROM (" // preselect teams with first name in team
"SELECT ID "
"FROM %s_teamrace "
"WHERE Map = ? AND Name = ? AND DDNet7 = false"
" SELECT ID "
" FROM %s_teamrace "
" WHERE Map = ? AND Name = ? AND DDNet7 = false"
") as l INNER JOIN %s_teamrace AS r ON l.ID = r.ID "
"ORDER BY l.ID, Name COLLATE %s;",
pSqlServer->GetPrefix(), pSqlServer->GetPrefix(), pSqlServer->BinaryCollate());
@ -663,11 +663,11 @@ bool CScore::ShowRankThread(IDbConnection *pSqlServer, const ISqlData *pGameData
str_format(aBuf, sizeof(aBuf),
"SELECT Rank, Name, Time "
"FROM ("
"SELECT RANK() OVER w AS Rank, Name, MIN(Time) AS Time "
"FROM %s_race "
"WHERE Map = ? "
"GROUP BY Name "
"WINDOW w AS (ORDER BY Time)"
" SELECT RANK() OVER w AS Rank, Name, MIN(Time) AS Time "
" FROM %s_race "
" WHERE Map = ? "
" GROUP BY Name "
" WINDOW w AS (ORDER BY Time)"
") as a "
"WHERE Name = ?;",
pSqlServer->GetPrefix());
@ -721,17 +721,17 @@ bool CScore::ShowTeamRankThread(IDbConnection *pSqlServer, const ISqlData *pGame
str_format(aBuf, sizeof(aBuf),
"SELECT l.ID, Name, Time, Rank "
"FROM (" // teamrank score board
"SELECT RANK() OVER w AS Rank, ID "
"FROM %s_teamrace "
"WHERE Map = ? "
"GROUP BY ID "
"WINDOW w AS (ORDER BY Time)"
" SELECT RANK() OVER w AS Rank, ID "
" FROM %s_teamrace "
" WHERE Map = ? "
" GROUP BY ID "
" WINDOW w AS (ORDER BY Time)"
") AS TeamRank INNER JOIN (" // select rank with Name in team
"SELECT ID "
"FROM %s_teamrace "
"WHERE Map = ? AND Name = ? "
"ORDER BY Time "
"LIMIT 1"
" SELECT ID "
" FROM %s_teamrace "
" WHERE Map = ? AND Name = ? "
" ORDER BY Time "
" LIMIT 1"
") AS l ON TeamRank.ID = l.ID "
"INNER JOIN %s_teamrace AS r ON l.ID = r.ID ",
pSqlServer->GetPrefix(), pSqlServer->GetPrefix(), pSqlServer->GetPrefix());
@ -799,11 +799,11 @@ bool CScore::ShowTop5Thread(IDbConnection *pSqlServer, const ISqlData *pGameData
str_format(aBuf, sizeof(aBuf),
"SELECT Name, Time, Rank "
"FROM ("
"SELECT RANK() OVER w AS Rank, Name, MIN(Time) AS Time "
"FROM %s_race "
"WHERE Map = ? "
"GROUP BY Name "
"WINDOW w AS (ORDER BY Time)"
" SELECT RANK() OVER w AS Rank, Name, MIN(Time) AS Time "
" FROM %s_race "
" WHERE Map = ? "
" GROUP BY Name "
" WINDOW w AS (ORDER BY Time)"
") as a "
"ORDER BY Rank %s "
"LIMIT %d, 5;",
@ -856,16 +856,16 @@ bool CScore::ShowTeamTop5Thread(IDbConnection *pSqlServer, const ISqlData *pGame
str_format(aBuf, sizeof(aBuf),
"SELECT Name, Time, Rank, TeamSize "
"FROM (" // limit to 5
"SELECT TeamSize, Rank, ID "
"FROM (" // teamrank score board
"SELECT RANK() OVER w AS Rank, ID, COUNT(*) AS Teamsize "
"FROM %s_teamrace "
"WHERE Map = ? "
"GROUP BY Id "
"WINDOW w AS (ORDER BY Time)"
") as l1 "
"ORDER BY Rank %s "
"LIMIT %d, 5"
" SELECT TeamSize, Rank, ID "
" FROM (" // teamrank score board
" SELECT RANK() OVER w AS Rank, ID, COUNT(*) AS Teamsize "
" FROM %s_teamrace "
" WHERE Map = ? "
" GROUP BY Id "
" WINDOW w AS (ORDER BY Time)"
" ) as l1 "
" ORDER BY Rank %s "
" LIMIT %d, 5"
") as l2 "
"INNER JOIN %s_teamrace as r ON l2.ID = r.ID "
"ORDER BY Rank %s, r.ID, Name ASC;",
@ -1045,8 +1045,8 @@ bool CScore::ShowPointsThread(IDbConnection *pSqlServer, const ISqlData *pGameDa
char aBuf[512];
str_format(aBuf, sizeof(aBuf),
"SELECT ("
"SELECT COUNT(Name) + 1 FROM %s_points WHERE Points > ("
"SELECT points FROM %s_points WHERE Name = ?"
" SELECT COUNT(Name) + 1 FROM %s_points WHERE Points > ("
" SELECT points FROM %s_points WHERE Name = ?"
")) as Rank, Points, Name "
"FROM %s_points WHERE Name = ?;",
pSqlServer->GetPrefix(), pSqlServer->GetPrefix(), pSqlServer->GetPrefix());
@ -1094,9 +1094,9 @@ bool CScore::ShowTopPointsThread(IDbConnection *pSqlServer, const ISqlData *pGam
str_format(aBuf, sizeof(aBuf),
"SELECT Rank, Points, Name "
"FROM ("
"SELECT RANK() OVER w AS Rank, Points, Name "
"FROM %s_points "
"WINDOW w as (ORDER BY Points DESC)"
" SELECT RANK() OVER w AS Rank, Points, Name "
" FROM %s_points "
" WINDOW w as (ORDER BY Points DESC)"
") as a "
"ORDER BY Rank %s "
"LIMIT ?, 5;",
@ -1203,9 +1203,9 @@ bool CScore::RandomUnfinishedMapThread(IDbConnection *pSqlServer, const ISqlData
"SELECT Map "
"FROM %s_maps "
"WHERE Server = ? AND Map != ? AND Stars = ? AND Map NOT IN ("
"SELECT Map "
"FROM %s_race "
"WHERE Name = ?"
" SELECT Map "
" FROM %s_race "
" WHERE Name = ?"
") ORDER BY RAND() "
"LIMIT 1;",
pSqlServer->GetPrefix(), pSqlServer->GetPrefix());
@ -1221,9 +1221,9 @@ bool CScore::RandomUnfinishedMapThread(IDbConnection *pSqlServer, const ISqlData
"SELECT Map "
"FROM %s_maps AS maps "
"WHERE Server = ? AND Map != ? AND Map NOT IN ("
"SELECT Map "
"FROM %s_race as race "
"WHERE Name = ?"
" SELECT Map "
" FROM %s_race as race "
" WHERE Name = ?"
") ORDER BY RAND() "
"LIMIT 1;",
pSqlServer->GetPrefix(), pSqlServer->GetPrefix());

View File

@ -1,15 +1,15 @@
#include "teehistorian.h"
#include <engine/shared/config.h>
#include <engine/shared/snapshot.h>
#include <engine/shared/json.h>
#include <engine/shared/snapshot.h>
#include <game/gamecore.h>
static const char TEEHISTORIAN_NAME[] = "teehistorian@ddnet.tw";
static const CUuid TEEHISTORIAN_UUID = CalculateUuid(TEEHISTORIAN_NAME);
static const char TEEHISTORIAN_VERSION[] = "2";
#define UUID(id, name) static const CUuid UUID_ ## id = CalculateUuid(name);
#define UUID(id, name) static const CUuid UUID_##id = CalculateUuid(name);
#include <engine/shared/teehistorian_ex_chunks.h>
#undef UUID
@ -84,7 +84,7 @@ void CTeeHistorian::WriteHeader(const CGameInfo *pGameInfo)
char aJson[2048];
#define E(buf, str) EscapeJson(buf, sizeof(buf), str)
#define E(buf, str) EscapeJson(buf, sizeof(buf), str)
str_format(aJson, sizeof(aJson), "{\"comment\":\"%s\",\"version\":\"%s\",\"game_uuid\":\"%s\",\"server_version\":\"%s\",\"start_time\":\"%s\",\"server_name\":\"%s\",\"server_port\":\"%d\",\"game_type\":\"%s\",\"map_name\":\"%s\",\"map_size\":\"%d\",\"map_sha256\":\"%s\",\"map_crc\":\"%08x\",\"prng_description\":\"%s\",\"config\":{",
E(aCommentBuffer, TEEHISTORIAN_NAME),
@ -106,7 +106,7 @@ void CTeeHistorian::WriteHeader(const CGameInfo *pGameInfo)
char aBuffer2[1024];
bool First = true;
#define MACRO_CONFIG_INT(Name,ScriptName,Def,Min,Max,Flags,Desc) \
#define MACRO_CONFIG_INT(Name, ScriptName, Def, Min, Max, Flags, Desc) \
if((Flags)&CFGFLAG_SERVER && !((Flags)&CFGFLAG_NONTEEHISTORIC) && pGameInfo->m_pConfig->m_##Name != (Def)) \
{ \
str_format(aJson, sizeof(aJson), "%s\"%s\":\"%d\"", \
@ -117,9 +117,9 @@ void CTeeHistorian::WriteHeader(const CGameInfo *pGameInfo)
First = false; \
}
#define MACRO_CONFIG_COL(Name,ScriptName,Def,Save,Desc) MACRO_CONFIG_INT(Name,ScriptName,Def,0,0,Save,Desc)
#define MACRO_CONFIG_COL(Name, ScriptName, Def, Save, Desc) MACRO_CONFIG_INT(Name, ScriptName, Def, 0, 0, Save, Desc)
#define MACRO_CONFIG_STR(Name,ScriptName,Len,Def,Flags,Desc) \
#define MACRO_CONFIG_STR(Name, ScriptName, Len, Def, Flags, Desc) \
if((Flags)&CFGFLAG_SERVER && !((Flags)&CFGFLAG_NONTEEHISTORIC) && str_comp(pGameInfo->m_pConfig->m_##Name, (Def)) != 0) \
{ \
str_format(aJson, sizeof(aJson), "%s\"%s\":\"%s\"", \
@ -130,11 +130,11 @@ void CTeeHistorian::WriteHeader(const CGameInfo *pGameInfo)
First = false; \
}
#include <engine/shared/config_variables.h>
#include <engine/shared/config_variables.h>
#undef MACRO_CONFIG_INT
#undef MACRO_CONFIG_COL
#undef MACRO_CONFIG_STR
#undef MACRO_CONFIG_INT
#undef MACRO_CONFIG_COL
#undef MACRO_CONFIG_STR
str_format(aJson, sizeof(aJson), "},\"tuning\":{");
Write(aJson, str_length(aJson));
@ -142,7 +142,7 @@ void CTeeHistorian::WriteHeader(const CGameInfo *pGameInfo)
First = true;
static const float TicksPerSecond = 50.0f;
#define MACRO_TUNING_PARAM(Name,ScriptName,Value,Description) \
#define MACRO_TUNING_PARAM(Name, ScriptName, Value, Description) \
if(pGameInfo->m_pTuning->m_##Name.Get() != (int)((Value)*100)) \
{ \
str_format(aJson, sizeof(aJson), "%s\"%s\":\"%d\"", \
@ -152,8 +152,8 @@ void CTeeHistorian::WriteHeader(const CGameInfo *pGameInfo)
Write(aJson, str_length(aJson)); \
First = false; \
}
#include <game/tuning.h>
#undef MACRO_TUNING_PARAM
#include <game/tuning.h>
#undef MACRO_TUNING_PARAM
str_format(aJson, sizeof(aJson), "},\"uuids\":[");
Write(aJson, str_length(aJson));
@ -184,7 +184,6 @@ void CTeeHistorian::WriteExtra(CUuid Uuid, const void *pData, int DataSize)
Write(pData, DataSize);
}
void CTeeHistorian::BeginTick(int Tick)
{
dbg_assert(m_State == STATE_START || m_State == STATE_BEFORE_TICK, "invalid teehistorian state");

View File

@ -49,8 +49,7 @@ protected:
0x01, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, 0x45, 0x67, 0x89,
0x01, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, 0x45, 0x67, 0x89,
0x01, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, 0x45, 0x67, 0x89,
0x01, 0x23,
}};
0x01, 0x23}};
mem_zero(&m_GameInfo, sizeof(m_GameInfo));
@ -349,8 +348,7 @@ TEST_F(TeeHistorian, DDNetVersion)
};
CUuid ConnectionID = {
0xfb, 0x13, 0xa5, 0x76, 0xd3, 0x5f, 0x48, 0x93,
0xb8, 0x15, 0xee, 0xdc, 0x6d, 0x98, 0x01, 0x5b,
};
0xb8, 0x15, 0xee, 0xdc, 0x6d, 0x98, 0x01, 0x5b};
m_TH.RecordDDNetVersion(0, ConnectionID, 13010, "DDNet 13.1 (3623f5e4cd184556)");
m_TH.RecordDDNetVersionOld(1, 13010);
Finish();
@ -456,8 +454,7 @@ TEST_F(TeeHistorian, SaveSuccess)
CUuid SaveID = {
0xfb, 0x13, 0xa5, 0x76, 0xd3, 0x5f, 0x48, 0x93,
0xb8, 0x15, 0xee, 0xdc, 0x6d, 0x98, 0x01, 0x5b,
};
0xb8, 0x15, 0xee, 0xdc, 0x6d, 0x98, 0x01, 0x5b};
const char *pTeamSave = "2\tH.\nll0";
m_TH.RecordTeamSaveSuccess(21, SaveID, pTeamSave);
Finish();
@ -503,8 +500,7 @@ TEST_F(TeeHistorian, LoadSuccess)
CUuid SaveID = {
0xfb, 0x13, 0xa5, 0x76, 0xd3, 0x5f, 0x48, 0x93,
0xb8, 0x15, 0xee, 0xdc, 0x6d, 0x98, 0x01, 0x5b,
};
0xb8, 0x15, 0xee, 0xdc, 0x6d, 0x98, 0x01, 0x5b};
const char *pTeamSave = "2\tH.\nll0";
m_TH.RecordTeamLoadSuccess(21, SaveID, pTeamSave);
Finish();

View File

@ -31,7 +31,7 @@ struct CPingConfig
};
static CPingConfig m_aConfigPings[] = {
// base flux spike loss delay delayfreq
// base flux spike loss delay delayfreq
{0, 0, 0, 0, 0, 0},
{40, 20, 100, 0, 0, 0},
{140, 40, 200, 0, 0, 0},