mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fix some variable name's style
This commit is contained in:
parent
091db3df32
commit
7663641ed2
|
@ -66,7 +66,7 @@ void CRegister::RegisterSendFwcheckresponse(NETADDR *pAddr, SECURITY_TOKEN Respo
|
|||
|
||||
void CRegister::RegisterSendHeartbeat(NETADDR Addr, SECURITY_TOKEN ResponseToken)
|
||||
{
|
||||
static unsigned char aData[sizeof(SERVERBROWSE_HEARTBEAT) + 2];
|
||||
unsigned char aData[sizeof(SERVERBROWSE_HEARTBEAT) + 2];
|
||||
unsigned short Port = m_pNetServer->Address().port;
|
||||
CNetChunk Packet;
|
||||
|
||||
|
|
|
@ -763,9 +763,9 @@ int CServer::SendMsg(CMsgPacker *pMsg, int Flags, int ClientID)
|
|||
{
|
||||
if(m_aClients[i].m_State == CClient::STATE_INGAME)
|
||||
{
|
||||
CPacker *Pack = m_aClients[i].m_Sixup ? &Pack7 : &Pack6;
|
||||
Packet.m_pData = Pack->Data();
|
||||
Packet.m_DataSize = Pack->Size();
|
||||
CPacker *pPack = m_aClients[i].m_Sixup ? &Pack7 : &Pack6;
|
||||
Packet.m_pData = pPack->Data();
|
||||
Packet.m_DataSize = pPack->Size();
|
||||
Packet.m_ClientID = i;
|
||||
m_NetServer.Send(&Packet);
|
||||
}
|
||||
|
@ -859,8 +859,8 @@ void CServer::DoSnapshot()
|
|||
char aCompData[CSnapshot::MAX_SIZE];
|
||||
int SnapshotSize;
|
||||
int Crc;
|
||||
static CSnapshot EmptySnap;
|
||||
CSnapshot *pDeltashot = &EmptySnap;
|
||||
static CSnapshot s_EmptySnap;
|
||||
CSnapshot *pDeltashot = &s_EmptySnap;
|
||||
int DeltashotSize;
|
||||
int DeltaTick = -1;
|
||||
int DeltaSize;
|
||||
|
@ -892,7 +892,7 @@ void CServer::DoSnapshot()
|
|||
m_aClients[i].m_Snapshots.Add(m_CurrentGameTick, time_get(), SnapshotSize, pData, 0);
|
||||
|
||||
// find snapshot that we can perform delta against
|
||||
EmptySnap.Clear();
|
||||
s_EmptySnap.Clear();
|
||||
|
||||
{
|
||||
DeltashotSize = m_aClients[i].m_Snapshots.Get(m_aClients[i].m_LastAckedSnapshot, 0, &pDeltashot, 0);
|
||||
|
@ -1219,12 +1219,12 @@ void CServer::SendRconLine(int ClientID, const char *pLine)
|
|||
void CServer::SendRconLineAuthed(const char *pLine, void *pUser, bool Highlighted)
|
||||
{
|
||||
CServer *pThis = (CServer *)pUser;
|
||||
static volatile int ReentryGuard = 0;
|
||||
static volatile int s_ReentryGuard = 0;
|
||||
int i;
|
||||
|
||||
if(ReentryGuard)
|
||||
if(s_ReentryGuard)
|
||||
return;
|
||||
ReentryGuard++;
|
||||
s_ReentryGuard++;
|
||||
|
||||
const char *pStart = str_find(pLine, "<{");
|
||||
const char *pEnd = pStart == NULL ? NULL : str_find(pStart + 2, "}>");
|
||||
|
@ -1258,7 +1258,7 @@ void CServer::SendRconLineAuthed(const char *pLine, void *pUser, bool Highlighte
|
|||
pThis->SendRconLine(i, pThis->m_aClients[i].m_ShowIps ? pLine : pLineWithoutIps);
|
||||
}
|
||||
|
||||
ReentryGuard--;
|
||||
s_ReentryGuard--;
|
||||
}
|
||||
|
||||
void CServer::SendRconCmdAdd(const IConsole::CCommandInfo *pCommandInfo, int ClientID)
|
||||
|
@ -1758,7 +1758,7 @@ static inline int GetCacheIndex(int Type, bool SendClient)
|
|||
|
||||
CServer::CCache::CCache()
|
||||
{
|
||||
m_lCache.clear();
|
||||
m_Cache.clear();
|
||||
}
|
||||
|
||||
CServer::CCache::~CCache()
|
||||
|
@ -1774,12 +1774,12 @@ CServer::CCache::CCacheChunk::CCacheChunk(const void *pData, int Size)
|
|||
|
||||
void CServer::CCache::AddChunk(const void *pData, int Size)
|
||||
{
|
||||
m_lCache.emplace_back(pData, Size);
|
||||
m_Cache.emplace_back(pData, Size);
|
||||
}
|
||||
|
||||
void CServer::CCache::Clear()
|
||||
{
|
||||
m_lCache.clear();
|
||||
m_Cache.clear();
|
||||
}
|
||||
|
||||
void CServer::CacheServerInfo(CCache *pCache, int Type, bool SendClients)
|
||||
|
@ -1871,32 +1871,32 @@ void CServer::CacheServerInfo(CCache *pCache, int Type, bool SendClients)
|
|||
const void *pPrefix = p.Data();
|
||||
int PrefixSize = p.Size();
|
||||
|
||||
CPacker pp;
|
||||
CPacker q;
|
||||
int ChunksStored = 0;
|
||||
int PlayersStored = 0;
|
||||
|
||||
#define SAVE(size) \
|
||||
do \
|
||||
{ \
|
||||
pCache->AddChunk(pp.Data(), size); \
|
||||
pCache->AddChunk(q.Data(), size); \
|
||||
ChunksStored++; \
|
||||
} while(0)
|
||||
|
||||
#define RESET() \
|
||||
do \
|
||||
{ \
|
||||
pp.Reset(); \
|
||||
pp.AddRaw(pPrefix, PrefixSize); \
|
||||
q.Reset(); \
|
||||
q.AddRaw(pPrefix, PrefixSize); \
|
||||
} while(0)
|
||||
|
||||
RESET();
|
||||
|
||||
if(Type == SERVERINFO_64_LEGACY)
|
||||
pp.AddInt(PlayersStored); // offset
|
||||
q.AddInt(PlayersStored); // offset
|
||||
|
||||
if(!SendClients)
|
||||
{
|
||||
SAVE(pp.Size());
|
||||
SAVE(q.Size());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1931,9 +1931,9 @@ void CServer::CacheServerInfo(CCache *pCache, int Type, bool SendClients)
|
|||
break;
|
||||
|
||||
// Otherwise we're SERVERINFO_64_LEGACY.
|
||||
SAVE(pp.Size());
|
||||
SAVE(q.Size());
|
||||
RESET();
|
||||
pp.AddInt(PlayersStored); // offset
|
||||
q.AddInt(PlayersStored); // offset
|
||||
Remaining = 24;
|
||||
}
|
||||
if(Remaining > 0)
|
||||
|
@ -1941,27 +1941,27 @@ void CServer::CacheServerInfo(CCache *pCache, int Type, bool SendClients)
|
|||
Remaining--;
|
||||
}
|
||||
|
||||
int PreviousSize = pp.Size();
|
||||
int PreviousSize = q.Size();
|
||||
|
||||
pp.AddString(ClientName(i), MAX_NAME_LENGTH); // client name
|
||||
pp.AddString(ClientClan(i), MAX_CLAN_LENGTH); // client clan
|
||||
q.AddString(ClientName(i), MAX_NAME_LENGTH); // client name
|
||||
q.AddString(ClientClan(i), MAX_CLAN_LENGTH); // client clan
|
||||
|
||||
ADD_INT(pp, m_aClients[i].m_Country); // client country
|
||||
ADD_INT(pp, m_aClients[i].m_Score); // client score
|
||||
ADD_INT(pp, GameServer()->IsClientPlayer(i) ? 1 : 0); // is player?
|
||||
ADD_INT(q, m_aClients[i].m_Country); // client country
|
||||
ADD_INT(q, m_aClients[i].m_Score); // client score
|
||||
ADD_INT(q, GameServer()->IsClientPlayer(i) ? 1 : 0); // is player?
|
||||
if(Type == SERVERINFO_EXTENDED)
|
||||
pp.AddString("", 0); // extra info, reserved
|
||||
q.AddString("", 0); // extra info, reserved
|
||||
|
||||
if(Type == SERVERINFO_EXTENDED)
|
||||
{
|
||||
if(pp.Size() >= NET_MAX_PAYLOAD - 18) // 8 bytes for type, 10 bytes for the largest token
|
||||
if(q.Size() >= NET_MAX_PAYLOAD - 18) // 8 bytes for type, 10 bytes for the largest token
|
||||
{
|
||||
// Retry current player.
|
||||
i--;
|
||||
SAVE(PreviousSize);
|
||||
RESET();
|
||||
ADD_INT(pp, ChunksStored);
|
||||
pp.AddString("", 0); // extra info, reserved
|
||||
ADD_INT(q, ChunksStored);
|
||||
q.AddString("", 0); // extra info, reserved
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -1969,7 +1969,7 @@ void CServer::CacheServerInfo(CCache *pCache, int Type, bool SendClients)
|
|||
}
|
||||
}
|
||||
|
||||
SAVE(pp.Size());
|
||||
SAVE(q.Size());
|
||||
#undef SAVE
|
||||
#undef RESET
|
||||
#undef ADD_RAW
|
||||
|
@ -2044,7 +2044,7 @@ void CServer::SendServerInfo(const NETADDR *pAddr, int Token, int Type, bool Sen
|
|||
char aBuf[128];
|
||||
p.Reset();
|
||||
|
||||
CCache *pCache = &m_ServerInfoCache[GetCacheIndex(Type, SendClients)];
|
||||
CCache *pCache = &m_aServerInfoCache[GetCacheIndex(Type, SendClients)];
|
||||
|
||||
#define ADD_RAW(p, x) (p).AddRaw(x, sizeof(x))
|
||||
#define ADD_INT(p, x) \
|
||||
|
@ -2059,12 +2059,12 @@ void CServer::SendServerInfo(const NETADDR *pAddr, int Token, int Type, bool Sen
|
|||
Packet.m_Address = *pAddr;
|
||||
Packet.m_Flags = NETSENDFLAG_CONNLESS;
|
||||
|
||||
for(const auto &Chunk : pCache->m_lCache)
|
||||
for(const auto &Chunk : pCache->m_Cache)
|
||||
{
|
||||
p.Reset();
|
||||
if(Type == SERVERINFO_EXTENDED)
|
||||
{
|
||||
if(&Chunk == &pCache->m_lCache.front())
|
||||
if(&Chunk == &pCache->m_Cache.front())
|
||||
p.AddRaw(SERVERBROWSE_INFO_EXTENDED, sizeof(SERVERBROWSE_INFO_EXTENDED));
|
||||
else
|
||||
p.AddRaw(SERVERBROWSE_INFO_EXTENDED_MORE, sizeof(SERVERBROWSE_INFO_EXTENDED_MORE));
|
||||
|
@ -2103,7 +2103,7 @@ void CServer::GetServerInfoSixup(CPacker *pPacker, int Token, bool SendClients)
|
|||
|
||||
SendClients = SendClients && Token != -1;
|
||||
|
||||
CCache::CCacheChunk &FirstChunk = m_SixupServerInfoCache[SendClients].m_lCache.front();
|
||||
CCache::CCacheChunk &FirstChunk = m_aSixupServerInfoCache[SendClients].m_Cache.front();
|
||||
pPacker->AddRaw(FirstChunk.m_aData, FirstChunk.m_DataSize);
|
||||
}
|
||||
|
||||
|
@ -2119,10 +2119,10 @@ void CServer::UpdateServerInfo(bool Resend)
|
|||
|
||||
for(int i = 0; i < 3; i++)
|
||||
for(int j = 0; j < 2; j++)
|
||||
CacheServerInfo(&m_ServerInfoCache[i * 2 + j], i, j);
|
||||
CacheServerInfo(&m_aServerInfoCache[i * 2 + j], i, j);
|
||||
|
||||
for(int i = 0; i < 2; i++)
|
||||
CacheServerInfoSixup(&m_SixupServerInfoCache[i], i);
|
||||
CacheServerInfoSixup(&m_aSixupServerInfoCache[i], i);
|
||||
|
||||
if(Resend)
|
||||
{
|
||||
|
@ -3572,28 +3572,28 @@ const char *CServer::GetAnnouncementLine(char const *pFileName)
|
|||
if(!File)
|
||||
return 0;
|
||||
|
||||
std::vector<char *> v;
|
||||
std::vector<char *> Lines;
|
||||
char *pLine;
|
||||
CLineReader lr;
|
||||
lr.Init(File);
|
||||
while((pLine = lr.Get()))
|
||||
CLineReader Reader;
|
||||
Reader.Init(File);
|
||||
while((pLine = Reader.Get()))
|
||||
if(str_length(pLine))
|
||||
if(pLine[0] != '#')
|
||||
v.push_back(pLine);
|
||||
if(v.size() == 1)
|
||||
Lines.push_back(pLine);
|
||||
if(Lines.size() == 1)
|
||||
{
|
||||
m_AnnouncementLastLine = 0;
|
||||
}
|
||||
else if(!g_Config.m_SvAnnouncementRandom)
|
||||
{
|
||||
if(++m_AnnouncementLastLine >= v.size())
|
||||
m_AnnouncementLastLine %= v.size();
|
||||
if(++m_AnnouncementLastLine >= Lines.size())
|
||||
m_AnnouncementLastLine %= Lines.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned Rand;
|
||||
do
|
||||
Rand = rand() % v.size();
|
||||
Rand = rand() % Lines.size();
|
||||
while(Rand == m_AnnouncementLastLine);
|
||||
|
||||
m_AnnouncementLastLine = Rand;
|
||||
|
@ -3601,12 +3601,12 @@ const char *CServer::GetAnnouncementLine(char const *pFileName)
|
|||
|
||||
io_close(File);
|
||||
|
||||
return v[m_AnnouncementLastLine];
|
||||
return Lines[m_AnnouncementLastLine];
|
||||
}
|
||||
|
||||
int *CServer::GetIdMap(int ClientID)
|
||||
{
|
||||
return IdMap + VANILLA_MAX_CLIENTS * ClientID;
|
||||
return m_aIdMap + VANILLA_MAX_CLIENTS * ClientID;
|
||||
}
|
||||
|
||||
bool CServer::SetTimedOut(int ClientID, int OrigID)
|
||||
|
|
|
@ -195,7 +195,7 @@ public:
|
|||
};
|
||||
|
||||
CClient m_aClients[MAX_CLIENTS];
|
||||
int IdMap[MAX_CLIENTS * VANILLA_MAX_CLIENTS];
|
||||
int m_aIdMap[MAX_CLIENTS * VANILLA_MAX_CLIENTS];
|
||||
|
||||
CSnapshotDelta m_SnapshotDelta;
|
||||
CSnapshotBuilder m_SnapshotBuilder;
|
||||
|
@ -334,7 +334,7 @@ public:
|
|||
unsigned char m_aData[NET_MAX_PAYLOAD];
|
||||
};
|
||||
|
||||
std::list<CCacheChunk> m_lCache;
|
||||
std::list<CCacheChunk> m_Cache;
|
||||
|
||||
CCache();
|
||||
~CCache();
|
||||
|
@ -342,8 +342,8 @@ public:
|
|||
void AddChunk(const void *pData, int Size);
|
||||
void Clear();
|
||||
};
|
||||
CCache m_ServerInfoCache[3 * 2];
|
||||
CCache m_SixupServerInfoCache[2];
|
||||
CCache m_aServerInfoCache[3 * 2];
|
||||
CCache m_aSixupServerInfoCache[2];
|
||||
bool m_ServerInfoNeedsUpdate;
|
||||
|
||||
void ExpireServerInfo();
|
||||
|
@ -422,7 +422,7 @@ public:
|
|||
|
||||
void GetClientAddr(int ClientID, NETADDR *pAddr);
|
||||
int m_aPrevStates[MAX_CLIENTS];
|
||||
const char *GetAnnouncementLine(char const *FileName);
|
||||
const char *GetAnnouncementLine(char const *pFileName);
|
||||
unsigned m_AnnouncementLastLine;
|
||||
void RestrictRconOutput(int ClientID) { m_RconRestrict = ClientID; }
|
||||
|
||||
|
@ -464,7 +464,7 @@ public:
|
|||
CLOSE_SESSION = 2,
|
||||
};
|
||||
|
||||
void SendConnLoggingCommand(CONN_LOGGING_CMD cmd, const NETADDR *pAddr);
|
||||
void SendConnLoggingCommand(CONN_LOGGING_CMD Cmd, const NETADDR *pAddr);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -4,24 +4,24 @@
|
|||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
void sqlstr::FuzzyString(char *pString, int size)
|
||||
void sqlstr::FuzzyString(char *pString, int Size)
|
||||
{
|
||||
char *newString = new char[size * 4 - 1];
|
||||
int pos = 0;
|
||||
char *pNewString = new char[Size * 4 - 1];
|
||||
int OutPos = 0;
|
||||
|
||||
for(int i = 0; i < size; i++)
|
||||
for(int i = 0; i < Size; i++)
|
||||
{
|
||||
if(!pString[i])
|
||||
break;
|
||||
|
||||
newString[pos++] = pString[i];
|
||||
pNewString[OutPos++] = pString[i];
|
||||
if(pString[i] != '\\' && str_utf8_isstart(pString[i + 1]))
|
||||
newString[pos++] = '%';
|
||||
pNewString[OutPos++] = '%';
|
||||
}
|
||||
|
||||
newString[pos] = '\0';
|
||||
str_copy(pString, newString, size);
|
||||
delete[] newString;
|
||||
pNewString[OutPos] = '\0';
|
||||
str_copy(pString, pNewString, Size);
|
||||
delete[] pNewString;
|
||||
}
|
||||
|
||||
int sqlstr::EscapeLike(char *pDst, const char *pSrc, int DstSize)
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
namespace sqlstr {
|
||||
|
||||
void FuzzyString(char *pString, int size);
|
||||
void FuzzyString(char *pString, int Size);
|
||||
|
||||
// written number of added bytes
|
||||
int EscapeLike(char *pDst, const char *pSrc, int DstSize);
|
||||
|
||||
void AgoTimeToString(int agoTime, char *pAgoString, int Size);
|
||||
void AgoTimeToString(int AgoTime, char *pAgoString, int Size);
|
||||
|
||||
} // namespace sqlstr
|
||||
|
||||
|
|
|
@ -39,62 +39,62 @@ float CConsole::CResult::GetFloat(unsigned Index)
|
|||
|
||||
ColorHSLA CConsole::CResult::GetColor(unsigned Index, bool Light)
|
||||
{
|
||||
ColorHSLA hsl = ColorHSLA(0, 0, 0);
|
||||
ColorHSLA Hsla = ColorHSLA(0, 0, 0);
|
||||
if(Index >= m_NumArgs)
|
||||
return hsl;
|
||||
return Hsla;
|
||||
|
||||
const char *pStr = m_apArgs[Index];
|
||||
if(str_isallnum(pStr) || ((pStr[0] == '-' || pStr[0] == '+') && str_isallnum(pStr + 1))) // Teeworlds Color (Packed HSL)
|
||||
{
|
||||
hsl = ColorHSLA(str_toulong_base(pStr, 10), true);
|
||||
Hsla = ColorHSLA(str_toulong_base(pStr, 10), true);
|
||||
if(Light)
|
||||
hsl = hsl.UnclampLighting();
|
||||
Hsla = Hsla.UnclampLighting();
|
||||
}
|
||||
else if(*pStr == '$') // Hex RGB
|
||||
{
|
||||
ColorRGBA rgb = ColorRGBA(0, 0, 0, 1);
|
||||
ColorRGBA Rgba = ColorRGBA(0, 0, 0, 1);
|
||||
int Len = str_length(pStr);
|
||||
if(Len == 4)
|
||||
{
|
||||
unsigned Num = str_toulong_base(pStr + 1, 16);
|
||||
rgb.r = (((Num >> 8) & 0x0F) + ((Num >> 4) & 0xF0)) / 255.0f;
|
||||
rgb.g = (((Num >> 4) & 0x0F) + ((Num >> 0) & 0xF0)) / 255.0f;
|
||||
rgb.b = (((Num >> 0) & 0x0F) + ((Num << 4) & 0xF0)) / 255.0f;
|
||||
Rgba.r = (((Num >> 8) & 0x0F) + ((Num >> 4) & 0xF0)) / 255.0f;
|
||||
Rgba.g = (((Num >> 4) & 0x0F) + ((Num >> 0) & 0xF0)) / 255.0f;
|
||||
Rgba.b = (((Num >> 0) & 0x0F) + ((Num << 4) & 0xF0)) / 255.0f;
|
||||
}
|
||||
else if(Len == 7)
|
||||
{
|
||||
unsigned Num = str_toulong_base(pStr + 1, 16);
|
||||
rgb.r = ((Num >> 16) & 0xFF) / 255.0f;
|
||||
rgb.g = ((Num >> 8) & 0xFF) / 255.0f;
|
||||
rgb.b = ((Num >> 0) & 0xFF) / 255.0f;
|
||||
Rgba.r = ((Num >> 16) & 0xFF) / 255.0f;
|
||||
Rgba.g = ((Num >> 8) & 0xFF) / 255.0f;
|
||||
Rgba.b = ((Num >> 0) & 0xFF) / 255.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
return hsl;
|
||||
return Hsla;
|
||||
}
|
||||
|
||||
hsl = color_cast<ColorHSLA>(rgb);
|
||||
Hsla = color_cast<ColorHSLA>(Rgba);
|
||||
}
|
||||
else if(!str_comp_nocase(pStr, "red"))
|
||||
hsl = ColorHSLA(0.0f / 6.0f, 1, .5f);
|
||||
Hsla = ColorHSLA(0.0f / 6.0f, 1, .5f);
|
||||
else if(!str_comp_nocase(pStr, "yellow"))
|
||||
hsl = ColorHSLA(1.0f / 6.0f, 1, .5f);
|
||||
Hsla = ColorHSLA(1.0f / 6.0f, 1, .5f);
|
||||
else if(!str_comp_nocase(pStr, "green"))
|
||||
hsl = ColorHSLA(2.0f / 6.0f, 1, .5f);
|
||||
Hsla = ColorHSLA(2.0f / 6.0f, 1, .5f);
|
||||
else if(!str_comp_nocase(pStr, "cyan"))
|
||||
hsl = ColorHSLA(3.0f / 6.0f, 1, .5f);
|
||||
Hsla = ColorHSLA(3.0f / 6.0f, 1, .5f);
|
||||
else if(!str_comp_nocase(pStr, "blue"))
|
||||
hsl = ColorHSLA(4.0f / 6.0f, 1, .5f);
|
||||
Hsla = ColorHSLA(4.0f / 6.0f, 1, .5f);
|
||||
else if(!str_comp_nocase(pStr, "magenta"))
|
||||
hsl = ColorHSLA(5.0f / 6.0f, 1, .5f);
|
||||
Hsla = ColorHSLA(5.0f / 6.0f, 1, .5f);
|
||||
else if(!str_comp_nocase(pStr, "white"))
|
||||
hsl = ColorHSLA(0, 0, 1);
|
||||
Hsla = ColorHSLA(0, 0, 1);
|
||||
else if(!str_comp_nocase(pStr, "gray"))
|
||||
hsl = ColorHSLA(0, 0, .5f);
|
||||
Hsla = ColorHSLA(0, 0, .5f);
|
||||
else if(!str_comp_nocase(pStr, "black"))
|
||||
hsl = ColorHSLA(0, 0, 0);
|
||||
Hsla = ColorHSLA(0, 0, 0);
|
||||
|
||||
return hsl;
|
||||
return Hsla;
|
||||
}
|
||||
|
||||
const IConsole::CCommandInfo *CConsole::CCommand::NextCommandInfo(int AccessLevel, int FlagMask) const
|
||||
|
@ -456,7 +456,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, int ClientID, bo
|
|||
if(Result.m_pCommand[0] == '+')
|
||||
{
|
||||
// insert the stroke direction token
|
||||
Result.AddArgument(m_paStrokeStr[Stroke]);
|
||||
Result.AddArgument(m_apStrokeStr[Stroke]);
|
||||
IsStrokeCommand = 1;
|
||||
}
|
||||
|
||||
|
@ -590,13 +590,13 @@ void CConsole::ExecuteFile(const char *pFilename, int ClientID, bool LogFailure,
|
|||
if(File)
|
||||
{
|
||||
char *pLine;
|
||||
CLineReader lr;
|
||||
CLineReader Reader;
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "executing '%s'", pFilename);
|
||||
Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf);
|
||||
lr.Init(File);
|
||||
Reader.Init(File);
|
||||
|
||||
while((pLine = lr.Get()))
|
||||
while((pLine = Reader.Get()))
|
||||
ExecuteLine(pLine, ClientID);
|
||||
|
||||
io_close(File);
|
||||
|
@ -772,19 +772,19 @@ static void ColVariableCommand(IConsole::IResult *pResult, void *pUserData)
|
|||
str_format(aBuf, sizeof(aBuf), "Value: %u", *(pData->m_pVariable));
|
||||
pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf);
|
||||
|
||||
ColorHSLA hsl(*(pData->m_pVariable), true);
|
||||
ColorHSLA Hsla(*(pData->m_pVariable), true);
|
||||
if(pData->m_Light)
|
||||
hsl = hsl.UnclampLighting();
|
||||
str_format(aBuf, sizeof(aBuf), "H: %d°, S: %d%%, L: %d%%", round_truncate(hsl.h * 360), round_truncate(hsl.s * 100), round_truncate(hsl.l * 100));
|
||||
Hsla = Hsla.UnclampLighting();
|
||||
str_format(aBuf, sizeof(aBuf), "H: %d°, S: %d%%, L: %d%%", round_truncate(Hsla.h * 360), round_truncate(Hsla.s * 100), round_truncate(Hsla.l * 100));
|
||||
pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf);
|
||||
|
||||
ColorRGBA rgb = color_cast<ColorRGBA>(hsl);
|
||||
str_format(aBuf, sizeof(aBuf), "R: %d, G: %d, B: %d, #%06X", round_truncate(rgb.r * 255), round_truncate(rgb.g * 255), round_truncate(rgb.b * 255), rgb.Pack(false));
|
||||
ColorRGBA Rgba = color_cast<ColorRGBA>(Hsla);
|
||||
str_format(aBuf, sizeof(aBuf), "R: %d, G: %d, B: %d, #%06X", round_truncate(Rgba.r * 255), round_truncate(Rgba.g * 255), round_truncate(Rgba.b * 255), Rgba.Pack(false));
|
||||
pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf);
|
||||
|
||||
if(pData->m_Alpha)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "A: %d%%", round_truncate(hsl.a * 100));
|
||||
str_format(aBuf, sizeof(aBuf), "A: %d%%", round_truncate(Hsla.a * 100));
|
||||
pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf);
|
||||
}
|
||||
}
|
||||
|
@ -928,8 +928,8 @@ CConsole::CConsole(int FlagMask)
|
|||
m_pRecycleList = 0;
|
||||
m_TempCommands.Reset();
|
||||
m_StoreCommands = true;
|
||||
m_paStrokeStr[0] = "0";
|
||||
m_paStrokeStr[1] = "1";
|
||||
m_apStrokeStr[0] = "0";
|
||||
m_apStrokeStr[1] = "1";
|
||||
m_ExecutionQueue.Reset();
|
||||
m_pFirstCommand = 0;
|
||||
m_pFirstExec = 0;
|
||||
|
|
|
@ -35,7 +35,7 @@ class CConsole : public IConsole
|
|||
|
||||
int m_FlagMask;
|
||||
bool m_StoreCommands;
|
||||
const char *m_paStrokeStr[2];
|
||||
const char *m_apStrokeStr[2];
|
||||
CCommand *m_pFirstCommand;
|
||||
|
||||
class CExecFile
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
#include <base/system.h>
|
||||
|
||||
void CsvWrite(IOHANDLE File, int NumColumns, const char *const *pColumns);
|
||||
void CsvWrite(IOHANDLE File, int NumColumns, const char *const *ppColumns);
|
||||
|
||||
#endif // ENGINE_SHARED_CSV_H
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
~CDataFileWriter();
|
||||
void Init();
|
||||
bool OpenFile(class IStorage *pStorage, const char *pFilename, int StorageType = IStorage::TYPE_SAVE);
|
||||
bool Open(class IStorage *pStorage, const char *Filename, int StorageType = IStorage::TYPE_SAVE);
|
||||
bool Open(class IStorage *pStorage, const char *pFilename, int StorageType = IStorage::TYPE_SAVE);
|
||||
int AddData(int Size, void *pData);
|
||||
int AddDataSwapped(int Size, void *pData);
|
||||
int AddItem(int Type, int ID, int Size, void *pData);
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
#include "network.h"
|
||||
#include "snapshot.h"
|
||||
|
||||
static const unsigned char gs_aHeaderMarker[7] = {'T', 'W', 'D', 'E', 'M', 'O', 0};
|
||||
static const unsigned char gs_ActVersion = 6;
|
||||
static const unsigned char gs_OldVersion = 3;
|
||||
static const unsigned char gs_Sha256Version = 6;
|
||||
static const unsigned char gs_VersionTickCompression = 5; // demo files with this version or higher will use `CHUNKTICKFLAG_TICK_COMPRESSED`
|
||||
static const int gs_LengthOffset = 152;
|
||||
static const int gs_NumMarkersOffset = 176;
|
||||
static const unsigned char s_aHeaderMarker[7] = {'T', 'W', 'D', 'E', 'M', 'O', 0};
|
||||
static const unsigned char s_CurVersion = 6;
|
||||
static const unsigned char s_OldVersion = 3;
|
||||
static const unsigned char s_Sha256Version = 6;
|
||||
static const unsigned char s_VersionTickCompression = 5; // demo files with this version or higher will use `CHUNKTICKFLAG_TICK_COMPRESSED`
|
||||
static const int s_LengthOffset = 152;
|
||||
static const int s_NumMarkersOffset = 176;
|
||||
|
||||
CDemoRecorder::CDemoRecorder(class CSnapshotDelta *pSnapshotDelta, bool NoMapData)
|
||||
{
|
||||
|
@ -124,8 +124,8 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con
|
|||
|
||||
// write header
|
||||
mem_zero(&Header, sizeof(Header));
|
||||
mem_copy(Header.m_aMarker, gs_aHeaderMarker, sizeof(Header.m_aMarker));
|
||||
Header.m_Version = gs_ActVersion;
|
||||
mem_copy(Header.m_aMarker, s_aHeaderMarker, sizeof(Header.m_aMarker));
|
||||
Header.m_Version = s_CurVersion;
|
||||
str_copy(Header.m_aNetversion, pNetVersion, sizeof(Header.m_aNetversion));
|
||||
str_copy(Header.m_aMapName, pMap, sizeof(Header.m_aMapName));
|
||||
Header.m_aMapSize[0] = (MapSize >> 24) & 0xff;
|
||||
|
@ -346,7 +346,7 @@ int CDemoRecorder::Stop()
|
|||
return -1;
|
||||
|
||||
// add the demo length to the header
|
||||
io_seek(m_File, gs_LengthOffset, IOSEEK_START);
|
||||
io_seek(m_File, s_LengthOffset, IOSEEK_START);
|
||||
int DemoLength = Length();
|
||||
char aLength[4];
|
||||
aLength[0] = (DemoLength >> 24) & 0xff;
|
||||
|
@ -356,7 +356,7 @@ int CDemoRecorder::Stop()
|
|||
io_write(m_File, aLength, sizeof(aLength));
|
||||
|
||||
// add the timeline markers to the header
|
||||
io_seek(m_File, gs_NumMarkersOffset, IOSEEK_START);
|
||||
io_seek(m_File, s_NumMarkersOffset, IOSEEK_START);
|
||||
char aNumMarkers[4];
|
||||
aNumMarkers[0] = (m_NumTimelineMarkers >> 24) & 0xff;
|
||||
aNumMarkers[1] = (m_NumTimelineMarkers >> 16) & 0xff;
|
||||
|
@ -438,7 +438,7 @@ int CDemoPlayer::ReadChunkHeader(int *pType, int *pSize, int *pTick)
|
|||
int Tickdelta_legacy = Chunk & (CHUNKMASK_TICK_LEGACY); // compatibility
|
||||
*pType = Chunk & (CHUNKTYPEFLAG_TICKMARKER | CHUNKTICKFLAG_KEYFRAME);
|
||||
|
||||
if(m_Info.m_Header.m_Version < gs_VersionTickCompression && Tickdelta_legacy != 0)
|
||||
if(m_Info.m_Header.m_Version < s_VersionTickCompression && Tickdelta_legacy != 0)
|
||||
{
|
||||
*pTick += Tickdelta_legacy;
|
||||
}
|
||||
|
@ -542,9 +542,9 @@ void CDemoPlayer::ScanFile()
|
|||
|
||||
void CDemoPlayer::DoTick()
|
||||
{
|
||||
static char aCompresseddata[CSnapshot::MAX_SIZE];
|
||||
static char aDecompressed[CSnapshot::MAX_SIZE];
|
||||
static char aData[CSnapshot::MAX_SIZE];
|
||||
static char s_aCompresseddata[CSnapshot::MAX_SIZE];
|
||||
static char s_aDecompressed[CSnapshot::MAX_SIZE];
|
||||
static char s_aData[CSnapshot::MAX_SIZE];
|
||||
int ChunkType, ChunkTick, ChunkSize;
|
||||
int DataSize = 0;
|
||||
int GotSnapshot = 0;
|
||||
|
@ -579,7 +579,7 @@ void CDemoPlayer::DoTick()
|
|||
// read the chunk
|
||||
if(ChunkSize)
|
||||
{
|
||||
if(io_read(m_File, aCompresseddata, ChunkSize) != (unsigned)ChunkSize)
|
||||
if(io_read(m_File, s_aCompresseddata, ChunkSize) != (unsigned)ChunkSize)
|
||||
{
|
||||
// stop on error or eof
|
||||
if(m_pConsole)
|
||||
|
@ -588,7 +588,7 @@ void CDemoPlayer::DoTick()
|
|||
break;
|
||||
}
|
||||
|
||||
DataSize = CNetBase::Decompress(aCompresseddata, ChunkSize, aDecompressed, sizeof(aDecompressed));
|
||||
DataSize = CNetBase::Decompress(s_aCompresseddata, ChunkSize, s_aDecompressed, sizeof(s_aDecompressed));
|
||||
if(DataSize < 0)
|
||||
{
|
||||
// stop on error or eof
|
||||
|
@ -598,7 +598,7 @@ void CDemoPlayer::DoTick()
|
|||
break;
|
||||
}
|
||||
|
||||
DataSize = CVariableInt::Decompress(aDecompressed, DataSize, aData, sizeof(aData));
|
||||
DataSize = CVariableInt::Decompress(s_aDecompressed, DataSize, s_aData, sizeof(s_aData));
|
||||
|
||||
if(DataSize < 0)
|
||||
{
|
||||
|
@ -612,19 +612,19 @@ void CDemoPlayer::DoTick()
|
|||
if(ChunkType == CHUNKTYPE_DELTA)
|
||||
{
|
||||
// process delta snapshot
|
||||
static char aNewsnap[CSnapshot::MAX_SIZE];
|
||||
static char s_aNewsnap[CSnapshot::MAX_SIZE];
|
||||
|
||||
GotSnapshot = 1;
|
||||
|
||||
DataSize = m_pSnapshotDelta->UnpackDelta((CSnapshot *)m_aLastSnapshotData, (CSnapshot *)aNewsnap, aData, DataSize);
|
||||
DataSize = m_pSnapshotDelta->UnpackDelta((CSnapshot *)m_aLastSnapshotData, (CSnapshot *)s_aNewsnap, s_aData, DataSize);
|
||||
|
||||
if(DataSize >= 0)
|
||||
{
|
||||
if(m_pListener)
|
||||
m_pListener->OnDemoPlayerSnapshot(aNewsnap, DataSize);
|
||||
m_pListener->OnDemoPlayerSnapshot(s_aNewsnap, DataSize);
|
||||
|
||||
m_LastSnapshotDataSize = DataSize;
|
||||
mem_copy(m_aLastSnapshotData, aNewsnap, DataSize);
|
||||
mem_copy(m_aLastSnapshotData, s_aNewsnap, DataSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -642,9 +642,9 @@ void CDemoPlayer::DoTick()
|
|||
GotSnapshot = 1;
|
||||
|
||||
m_LastSnapshotDataSize = DataSize;
|
||||
mem_copy(m_aLastSnapshotData, aData, DataSize);
|
||||
mem_copy(m_aLastSnapshotData, s_aData, DataSize);
|
||||
if(m_pListener)
|
||||
m_pListener->OnDemoPlayerSnapshot(aData, DataSize);
|
||||
m_pListener->OnDemoPlayerSnapshot(s_aData, DataSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -664,7 +664,7 @@ void CDemoPlayer::DoTick()
|
|||
else if(ChunkType == CHUNKTYPE_MESSAGE)
|
||||
{
|
||||
if(m_pListener)
|
||||
m_pListener->OnDemoPlayerMessage(aData, DataSize);
|
||||
m_pListener->OnDemoPlayerMessage(s_aData, DataSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const
|
|||
|
||||
// read the header
|
||||
io_read(m_File, &m_Info.m_Header, sizeof(m_Info.m_Header));
|
||||
if(mem_comp(m_Info.m_Header.m_aMarker, gs_aHeaderMarker, sizeof(gs_aHeaderMarker)) != 0)
|
||||
if(mem_comp(m_Info.m_Header.m_aMarker, s_aHeaderMarker, sizeof(s_aHeaderMarker)) != 0)
|
||||
{
|
||||
if(m_pConsole)
|
||||
{
|
||||
|
@ -738,7 +738,7 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const
|
|||
return -1;
|
||||
}
|
||||
|
||||
if(m_Info.m_Header.m_Version < gs_OldVersion)
|
||||
if(m_Info.m_Header.m_Version < s_OldVersion)
|
||||
{
|
||||
if(m_pConsole)
|
||||
{
|
||||
|
@ -750,11 +750,11 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const
|
|||
m_File = 0;
|
||||
return -1;
|
||||
}
|
||||
else if(m_Info.m_Header.m_Version > gs_OldVersion)
|
||||
else if(m_Info.m_Header.m_Version > s_OldVersion)
|
||||
io_read(m_File, &m_Info.m_TimelineMarkers, sizeof(m_Info.m_TimelineMarkers));
|
||||
|
||||
SHA256_DIGEST Sha256 = SHA256_ZEROED;
|
||||
if(m_Info.m_Header.m_Version >= gs_Sha256Version)
|
||||
if(m_Info.m_Header.m_Version >= s_Sha256Version)
|
||||
{
|
||||
CUuid ExtensionUuid = {};
|
||||
io_read(m_File, &ExtensionUuid.m_aData, sizeof(ExtensionUuid.m_aData));
|
||||
|
@ -796,7 +796,7 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const
|
|||
m_MapInfo.m_Size = MapSize;
|
||||
str_copy(m_MapInfo.m_aName, m_Info.m_Header.m_aMapName, sizeof(m_MapInfo.m_aName));
|
||||
|
||||
if(m_Info.m_Header.m_Version > gs_OldVersion)
|
||||
if(m_Info.m_Header.m_Version > s_OldVersion)
|
||||
{
|
||||
// get timeline markers
|
||||
int Num = ((m_Info.m_TimelineMarkers.m_aNumTimelineMarkers[0] << 24) & 0xFF000000) | ((m_Info.m_TimelineMarkers.m_aNumTimelineMarkers[1] << 16) & 0xFF0000) |
|
||||
|
@ -836,7 +836,7 @@ bool CDemoPlayer::ExtractMap(class IStorage *pStorage)
|
|||
|
||||
// handle sha256
|
||||
SHA256_DIGEST Sha256 = SHA256_ZEROED;
|
||||
if(m_Info.m_Header.m_Version >= gs_Sha256Version)
|
||||
if(m_Info.m_Header.m_Version >= s_Sha256Version)
|
||||
Sha256 = m_MapInfo.m_Sha256;
|
||||
else
|
||||
{
|
||||
|
@ -1086,7 +1086,7 @@ bool CDemoPlayer::GetDemoInfo(class IStorage *pStorage, const char *pFilename, i
|
|||
pMapInfo->m_Crc = (pDemoHeader->m_aMapCrc[0] << 24) | (pDemoHeader->m_aMapCrc[1] << 16) | (pDemoHeader->m_aMapCrc[2] << 8) | (pDemoHeader->m_aMapCrc[3]);
|
||||
|
||||
SHA256_DIGEST Sha256 = SHA256_ZEROED;
|
||||
if(pDemoHeader->m_Version >= gs_Sha256Version)
|
||||
if(pDemoHeader->m_Version >= s_Sha256Version)
|
||||
{
|
||||
CUuid ExtensionUuid = {};
|
||||
io_read(File, &ExtensionUuid.m_aData, sizeof(ExtensionUuid.m_aData));
|
||||
|
@ -1107,7 +1107,7 @@ bool CDemoPlayer::GetDemoInfo(class IStorage *pStorage, const char *pFilename, i
|
|||
pMapInfo->m_Size = (pDemoHeader->m_aMapSize[0] << 24) | (pDemoHeader->m_aMapSize[1] << 16) | (pDemoHeader->m_aMapSize[2] << 8) | (pDemoHeader->m_aMapSize[3]);
|
||||
|
||||
io_close(File);
|
||||
return !(mem_comp(pDemoHeader->m_aMarker, gs_aHeaderMarker, sizeof(gs_aHeaderMarker)) || pDemoHeader->m_Version < gs_OldVersion);
|
||||
return !(mem_comp(pDemoHeader->m_aMarker, s_aHeaderMarker, sizeof(s_aHeaderMarker)) || pDemoHeader->m_Version < s_OldVersion);
|
||||
}
|
||||
|
||||
int CDemoPlayer::GetDemoType() const
|
||||
|
@ -1146,7 +1146,7 @@ void CDemoEditor::Slice(const char *pDemo, const char *pDst, int StartTick, int
|
|||
const CDemoPlayer::CPlaybackInfo *pInfo = m_pDemoPlayer->Info();
|
||||
|
||||
SHA256_DIGEST Sha256 = pMapInfo->m_Sha256;
|
||||
if(pInfo->m_Header.m_Version < gs_Sha256Version)
|
||||
if(pInfo->m_Header.m_Version < s_Sha256Version)
|
||||
{
|
||||
if(m_pDemoPlayer->ExtractMap(m_pStorage))
|
||||
Sha256 = pMapInfo->m_Sha256;
|
||||
|
|
|
@ -119,7 +119,7 @@ private:
|
|||
int64 m_Time;
|
||||
|
||||
public:
|
||||
CDemoPlayer(class CSnapshotDelta *m_pSnapshotDelta);
|
||||
CDemoPlayer(class CSnapshotDelta *pSnapshotDelta);
|
||||
|
||||
void SetListener(IListener *pListener);
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
static void Dilate(int w, int h, int BPP, unsigned char *pSrc, unsigned char *pDest, unsigned char AlphaThreshold = 30)
|
||||
{
|
||||
int ix, iy;
|
||||
const int xo[] = {0, -1, 1, 0};
|
||||
const int yo[] = {-1, 0, 0, 1};
|
||||
const int aDirX[] = {0, -1, 1, 0};
|
||||
const int aDirY[] = {-1, 0, 0, 1};
|
||||
|
||||
int AlphaCompIndex = BPP - 1;
|
||||
|
||||
|
@ -19,12 +19,12 @@ static void Dilate(int w, int h, int BPP, unsigned char *pSrc, unsigned char *pD
|
|||
if(pSrc[m + AlphaCompIndex] > AlphaThreshold)
|
||||
continue;
|
||||
|
||||
int SumOfOpaque[] = {0, 0, 0};
|
||||
int aSumOfOpaque[] = {0, 0, 0};
|
||||
int Counter = 0;
|
||||
for(int c = 0; c < 4; c++)
|
||||
{
|
||||
ix = clamp(x + xo[c], 0, w - 1);
|
||||
iy = clamp(y + yo[c], 0, h - 1);
|
||||
ix = clamp(x + aDirX[c], 0, w - 1);
|
||||
iy = clamp(y + aDirY[c], 0, h - 1);
|
||||
int k = iy * w * BPP + ix * BPP;
|
||||
if(pSrc[k + AlphaCompIndex] > AlphaThreshold)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ static void Dilate(int w, int h, int BPP, unsigned char *pSrc, unsigned char *pD
|
|||
// Seems safe for BPP = 3, 4 which we use. clang-analyzer seems to
|
||||
// asssume being called with larger value. TODO: Can make this
|
||||
// safer anyway.
|
||||
SumOfOpaque[p] += pSrc[k + p]; // NOLINT(clang-analyzer-core.uninitialized.Assign)
|
||||
aSumOfOpaque[p] += pSrc[k + p]; // NOLINT(clang-analyzer-core.uninitialized.Assign)
|
||||
++Counter;
|
||||
break;
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ static void Dilate(int w, int h, int BPP, unsigned char *pSrc, unsigned char *pD
|
|||
{
|
||||
for(int i = 0; i < BPP - 1; ++i)
|
||||
{
|
||||
SumOfOpaque[i] /= Counter;
|
||||
pDest[m + i] = (unsigned char)SumOfOpaque[i];
|
||||
aSumOfOpaque[i] /= Counter;
|
||||
pDest[m + i] = (unsigned char)aSumOfOpaque[i];
|
||||
}
|
||||
|
||||
pDest[m + AlphaCompIndex] = 255;
|
||||
|
@ -67,23 +67,23 @@ static void CopyColorValues(int w, int h, int BPP, unsigned char *pSrc, unsigned
|
|||
|
||||
void DilateImage(unsigned char *pImageBuff, int w, int h, int BPP)
|
||||
{
|
||||
unsigned char *pBuffer[2] = {NULL, NULL};
|
||||
unsigned char *apBuffer[2] = {NULL, NULL};
|
||||
|
||||
pBuffer[0] = (unsigned char *)malloc((size_t)w * h * sizeof(unsigned char) * BPP);
|
||||
pBuffer[1] = (unsigned char *)malloc((size_t)w * h * sizeof(unsigned char) * BPP);
|
||||
apBuffer[0] = (unsigned char *)malloc((size_t)w * h * sizeof(unsigned char) * BPP);
|
||||
apBuffer[1] = (unsigned char *)malloc((size_t)w * h * sizeof(unsigned char) * BPP);
|
||||
|
||||
unsigned char *pPixelBuff = (unsigned char *)pImageBuff;
|
||||
|
||||
Dilate(w, h, BPP, pPixelBuff, pBuffer[0]);
|
||||
Dilate(w, h, BPP, pPixelBuff, apBuffer[0]);
|
||||
|
||||
for(int i = 0; i < 5; i++)
|
||||
{
|
||||
Dilate(w, h, BPP, pBuffer[0], pBuffer[1]);
|
||||
Dilate(w, h, BPP, pBuffer[1], pBuffer[0]);
|
||||
Dilate(w, h, BPP, apBuffer[0], apBuffer[1]);
|
||||
Dilate(w, h, BPP, apBuffer[1], apBuffer[0]);
|
||||
}
|
||||
|
||||
CopyColorValues(w, h, BPP, pBuffer[0], pPixelBuff);
|
||||
CopyColorValues(w, h, BPP, apBuffer[0], pPixelBuff);
|
||||
|
||||
free(pBuffer[0]);
|
||||
free(pBuffer[1]);
|
||||
free(apBuffer[0]);
|
||||
free(apBuffer[1]);
|
||||
}
|
||||
|
|
|
@ -23,17 +23,17 @@ void CFifo::Init(IConsole *pConsole, char *pFifoFile, int Flag)
|
|||
|
||||
mkfifo(pFifoFile, 0600);
|
||||
|
||||
struct stat attribute;
|
||||
stat(pFifoFile, &attribute);
|
||||
struct stat Attribute;
|
||||
stat(pFifoFile, &Attribute);
|
||||
|
||||
if(!S_ISFIFO(attribute.st_mode))
|
||||
if(!S_ISFIFO(Attribute.st_mode))
|
||||
{
|
||||
dbg_msg("fifo", "'%s' is not a fifo, removing", pFifoFile);
|
||||
fs_remove(pFifoFile);
|
||||
mkfifo(pFifoFile, 0600);
|
||||
stat(pFifoFile, &attribute);
|
||||
stat(pFifoFile, &Attribute);
|
||||
|
||||
if(!S_ISFIFO(attribute.st_mode))
|
||||
if(!S_ISFIFO(Attribute.st_mode))
|
||||
{
|
||||
dbg_msg("fifo", "can't remove file '%s', quitting", pFifoFile);
|
||||
exit(2);
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual bool RegisterInterfaceImpl(const char *pName, IInterface *pInterface, bool destroy)
|
||||
virtual bool RegisterInterfaceImpl(const char *pName, IInterface *pInterface, bool Destroy)
|
||||
{
|
||||
// TODO: More error checks here
|
||||
if(!pInterface)
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
pInterface->m_pKernel = this;
|
||||
m_aInterfaces[m_NumInterfaces].m_pInterface = pInterface;
|
||||
str_copy(m_aInterfaces[m_NumInterfaces].m_aName, pName, sizeof(m_aInterfaces[m_NumInterfaces].m_aName));
|
||||
m_aInterfaces[m_NumInterfaces].m_AutoDestroy = destroy;
|
||||
m_aInterfaces[m_NumInterfaces].m_AutoDestroy = Destroy;
|
||||
m_NumInterfaces++;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
#include "linereader.h"
|
||||
|
||||
void CLineReader::Init(IOHANDLE io)
|
||||
void CLineReader::Init(IOHANDLE File)
|
||||
{
|
||||
m_BufferMaxSize = sizeof(m_aBuffer);
|
||||
m_BufferSize = 0;
|
||||
m_BufferPos = 0;
|
||||
m_IO = io;
|
||||
m_File = File;
|
||||
}
|
||||
|
||||
char *CLineReader::Get()
|
||||
|
@ -32,7 +32,7 @@ char *CLineReader::Get()
|
|||
m_BufferPos = Left;
|
||||
|
||||
// fill the buffer
|
||||
Read = io_read(m_IO, &m_aBuffer[m_BufferPos], m_BufferMaxSize - m_BufferPos);
|
||||
Read = io_read(m_File, &m_aBuffer[m_BufferPos], m_BufferMaxSize - m_BufferPos);
|
||||
m_BufferSize = Left + Read;
|
||||
LineStart = 0;
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ class CLineReader
|
|||
unsigned m_BufferPos;
|
||||
unsigned m_BufferSize;
|
||||
unsigned m_BufferMaxSize;
|
||||
IOHANDLE m_IO;
|
||||
IOHANDLE m_File;
|
||||
|
||||
public:
|
||||
void Init(IOHANDLE IoHandle);
|
||||
void Init(IOHANDLE File);
|
||||
char *Get();
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -62,11 +62,11 @@ typename CNetBan::CBan<T> *CNetBan::CBanPool<T, HashCount>::Add(const T *pData,
|
|||
m_pFirstFree = pBan->m_pNext;
|
||||
|
||||
// add it to the hash list
|
||||
if(m_paaHashList[pNetHash->m_HashIndex][pNetHash->m_Hash])
|
||||
m_paaHashList[pNetHash->m_HashIndex][pNetHash->m_Hash]->m_pHashPrev = pBan;
|
||||
if(m_aapHashList[pNetHash->m_HashIndex][pNetHash->m_Hash])
|
||||
m_aapHashList[pNetHash->m_HashIndex][pNetHash->m_Hash]->m_pHashPrev = pBan;
|
||||
pBan->m_pHashPrev = 0;
|
||||
pBan->m_pHashNext = m_paaHashList[pNetHash->m_HashIndex][pNetHash->m_Hash];
|
||||
m_paaHashList[pNetHash->m_HashIndex][pNetHash->m_Hash] = pBan;
|
||||
pBan->m_pHashNext = m_aapHashList[pNetHash->m_HashIndex][pNetHash->m_Hash];
|
||||
m_aapHashList[pNetHash->m_HashIndex][pNetHash->m_Hash] = pBan;
|
||||
|
||||
// insert it into the used list
|
||||
if(m_pFirstUsed)
|
||||
|
@ -120,7 +120,7 @@ int CNetBan::CBanPool<T, HashCount>::Remove(CBan<T> *pBan)
|
|||
if(pBan->m_pHashPrev)
|
||||
pBan->m_pHashPrev->m_pHashNext = pBan->m_pHashNext;
|
||||
else
|
||||
m_paaHashList[pBan->m_NetHash.m_HashIndex][pBan->m_NetHash.m_Hash] = pBan->m_pHashNext;
|
||||
m_aapHashList[pBan->m_NetHash.m_HashIndex][pBan->m_NetHash.m_Hash] = pBan->m_pHashNext;
|
||||
pBan->m_pHashNext = pBan->m_pHashPrev = 0;
|
||||
|
||||
// remove from used list
|
||||
|
@ -201,7 +201,7 @@ void CNetBan::UnbanAll()
|
|||
template<class T, int HashCount>
|
||||
void CNetBan::CBanPool<T, HashCount>::Reset()
|
||||
{
|
||||
mem_zero(m_paaHashList, sizeof(m_paaHashList));
|
||||
mem_zero(m_aapHashList, sizeof(m_aapHashList));
|
||||
mem_zero(m_aBans, sizeof(m_aBans));
|
||||
m_pFirstUsed = 0;
|
||||
m_CountUsed = 0;
|
||||
|
@ -394,13 +394,13 @@ int CNetBan::UnbanByIndex(int Index)
|
|||
|
||||
bool CNetBan::IsBanned(const NETADDR *pOrigAddr, char *pBuf, unsigned BufferSize) const
|
||||
{
|
||||
NETADDR addr;
|
||||
NETADDR Addr;
|
||||
const NETADDR *pAddr = pOrigAddr;
|
||||
if(pOrigAddr->type == NETTYPE_WEBSOCKET_IPV4)
|
||||
{
|
||||
mem_copy(&addr, pOrigAddr, sizeof(NETADDR));
|
||||
pAddr = &addr;
|
||||
addr.type = NETTYPE_IPV4;
|
||||
mem_copy(&Addr, pOrigAddr, sizeof(NETADDR));
|
||||
pAddr = &Addr;
|
||||
Addr.type = NETTYPE_IPV4;
|
||||
}
|
||||
CNetHash aHash[17];
|
||||
int Length = CNetHash::MakeHashArray(pAddr, aHash);
|
||||
|
|
|
@ -115,10 +115,10 @@ protected:
|
|||
bool IsFull() const { return m_CountUsed == MAX_BANS; }
|
||||
|
||||
CBan<CDataType> *First() const { return m_pFirstUsed; }
|
||||
CBan<CDataType> *First(const CNetHash *pNetHash) const { return m_paaHashList[pNetHash->m_HashIndex][pNetHash->m_Hash]; }
|
||||
CBan<CDataType> *First(const CNetHash *pNetHash) const { return m_aapHashList[pNetHash->m_HashIndex][pNetHash->m_Hash]; }
|
||||
CBan<CDataType> *Find(const CDataType *pData, const CNetHash *pNetHash) const
|
||||
{
|
||||
for(CBan<CDataType> *pBan = m_paaHashList[pNetHash->m_HashIndex][pNetHash->m_Hash]; pBan; pBan = pBan->m_pHashNext)
|
||||
for(CBan<CDataType> *pBan = m_aapHashList[pNetHash->m_HashIndex][pNetHash->m_Hash]; pBan; pBan = pBan->m_pHashNext)
|
||||
{
|
||||
if(NetComp(&pBan->m_Data, pData) == 0)
|
||||
return pBan;
|
||||
|
@ -134,7 +134,7 @@ protected:
|
|||
MAX_BANS = 1024,
|
||||
};
|
||||
|
||||
CBan<CDataType> *m_paaHashList[HashCount][256];
|
||||
CBan<CDataType> *m_aapHashList[HashCount][256];
|
||||
CBan<CDataType> m_aBans[MAX_BANS];
|
||||
CBan<CDataType> *m_pFirstFree;
|
||||
CBan<CDataType> *m_pFirstUsed;
|
||||
|
|
|
@ -191,7 +191,7 @@ void CNetBase::SendPacket(NETSOCKET Socket, NETADDR *pAddr, CNetPacketConstruct
|
|||
}
|
||||
|
||||
// TODO: rename this function
|
||||
int CNetBase::UnpackPacket(unsigned char *pBuffer, int Size, CNetPacketConstruct *pPacket, bool &Sixup, SECURITY_TOKEN *SecurityToken, SECURITY_TOKEN *ResponseToken)
|
||||
int CNetBase::UnpackPacket(unsigned char *pBuffer, int Size, CNetPacketConstruct *pPacket, bool &Sixup, SECURITY_TOKEN *pSecurityToken, SECURITY_TOKEN *pResponseToken)
|
||||
{
|
||||
// check the size
|
||||
if(Size < NET_PACKETHEADERSIZE || Size > NET_MAX_PACKETSIZE)
|
||||
|
@ -225,8 +225,8 @@ int CNetBase::UnpackPacket(unsigned char *pBuffer, int Size, CNetPacketConstruct
|
|||
|
||||
if(Sixup)
|
||||
{
|
||||
mem_copy(SecurityToken, &pBuffer[1], 4);
|
||||
mem_copy(ResponseToken, &pBuffer[5], 4);
|
||||
mem_copy(pSecurityToken, &pBuffer[1], 4);
|
||||
mem_copy(pResponseToken, &pBuffer[5], 4);
|
||||
}
|
||||
|
||||
pPacket->m_Flags = NET_PACKETFLAG_CONNLESS;
|
||||
|
@ -264,7 +264,7 @@ int CNetBase::UnpackPacket(unsigned char *pBuffer, int Size, CNetPacketConstruct
|
|||
Flags |= NET_PACKETFLAG_COMPRESSION;
|
||||
pPacket->m_Flags = Flags;
|
||||
|
||||
mem_copy(SecurityToken, &pBuffer[3], 4);
|
||||
mem_copy(pSecurityToken, &pBuffer[3], 4);
|
||||
}
|
||||
|
||||
if(pPacket->m_Flags & NET_PACKETFLAG_COMPRESSION)
|
||||
|
@ -317,27 +317,27 @@ void CNetBase::SendControlMsg(NETSOCKET Socket, NETADDR *pAddr, int Ack, int Con
|
|||
CNetBase::SendPacket(Socket, pAddr, &Construct, SecurityToken, Sixup, true);
|
||||
}
|
||||
|
||||
unsigned char *CNetChunkHeader::Pack(unsigned char *pData, int split)
|
||||
unsigned char *CNetChunkHeader::Pack(unsigned char *pData, int Split)
|
||||
{
|
||||
pData[0] = ((m_Flags & 3) << 6) | ((m_Size >> split) & 0x3f);
|
||||
pData[1] = (m_Size & ((1 << split) - 1));
|
||||
pData[0] = ((m_Flags & 3) << 6) | ((m_Size >> Split) & 0x3f);
|
||||
pData[1] = (m_Size & ((1 << Split) - 1));
|
||||
if(m_Flags & NET_CHUNKFLAG_VITAL)
|
||||
{
|
||||
pData[1] |= (m_Sequence >> 2) & (~((1 << split) - 1));
|
||||
pData[1] |= (m_Sequence >> 2) & (~((1 << Split) - 1));
|
||||
pData[2] = m_Sequence & 0xff;
|
||||
return pData + 3;
|
||||
}
|
||||
return pData + 2;
|
||||
}
|
||||
|
||||
unsigned char *CNetChunkHeader::Unpack(unsigned char *pData, int split)
|
||||
unsigned char *CNetChunkHeader::Unpack(unsigned char *pData, int Split)
|
||||
{
|
||||
m_Flags = (pData[0] >> 6) & 3;
|
||||
m_Size = ((pData[0] & 0x3f) << split) | (pData[1] & ((1 << split) - 1));
|
||||
m_Size = ((pData[0] & 0x3f) << Split) | (pData[1] & ((1 << Split) - 1));
|
||||
m_Sequence = -1;
|
||||
if(m_Flags & NET_CHUNKFLAG_VITAL)
|
||||
{
|
||||
m_Sequence = ((pData[1] & (~((1 << split) - 1))) << 2) | pData[2];
|
||||
m_Sequence = ((pData[1] & (~((1 << Split) - 1))) << 2) | pData[2];
|
||||
return pData + 3;
|
||||
}
|
||||
return pData + 2;
|
||||
|
@ -412,7 +412,7 @@ int CNetBase::Decompress(const void *pData, int DataSize, void *pOutput, int Out
|
|||
return ms_Huffman.Decompress(pData, DataSize, pOutput, OutputSize);
|
||||
}
|
||||
|
||||
static const unsigned gs_aFreqTable[256 + 1] = {
|
||||
static const unsigned s_aFreqTable[256 + 1] = {
|
||||
1 << 30, 4545, 2657, 431, 1950, 919, 444, 482, 2244, 617, 838, 542, 715, 1814, 304, 240, 754, 212, 647, 186,
|
||||
283, 131, 146, 166, 543, 164, 167, 136, 179, 859, 363, 113, 157, 154, 204, 108, 137, 180, 202, 176,
|
||||
872, 404, 168, 134, 151, 111, 113, 109, 120, 126, 129, 100, 41, 20, 16, 22, 18, 18, 17, 19,
|
||||
|
@ -429,5 +429,5 @@ static const unsigned gs_aFreqTable[256 + 1] = {
|
|||
|
||||
void CNetBase::Init()
|
||||
{
|
||||
ms_Huffman.Init(gs_aFreqTable);
|
||||
ms_Huffman.Init(s_aFreqTable);
|
||||
}
|
||||
|
|
|
@ -130,8 +130,8 @@ public:
|
|||
int m_Size;
|
||||
int m_Sequence;
|
||||
|
||||
unsigned char *Pack(unsigned char *pData, int split = 4);
|
||||
unsigned char *Unpack(unsigned char *pData, int split = 4);
|
||||
unsigned char *Pack(unsigned char *pData, int Split = 4);
|
||||
unsigned char *Unpack(unsigned char *pData, int Split = 4);
|
||||
};
|
||||
|
||||
class CNetChunkResend
|
||||
|
@ -175,13 +175,13 @@ private:
|
|||
bool m_BlockCloseMsg;
|
||||
bool m_UnknownSeq;
|
||||
|
||||
TStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> m_Buffer;
|
||||
CStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> m_Buffer;
|
||||
|
||||
int64 m_LastUpdateTime;
|
||||
int64 m_LastRecvTime;
|
||||
int64 m_LastSendTime;
|
||||
|
||||
char m_ErrorString[256];
|
||||
char m_aErrorString[256];
|
||||
|
||||
CNetPacketConstruct m_Construct;
|
||||
|
||||
|
@ -199,8 +199,6 @@ private:
|
|||
void ResendChunk(CNetChunkResend *pResend);
|
||||
void Resend();
|
||||
|
||||
bool HasSecurityToken;
|
||||
|
||||
public:
|
||||
bool m_TimeoutProtected;
|
||||
bool m_TimeoutSituation;
|
||||
|
@ -221,8 +219,8 @@ public:
|
|||
int State() const { return m_State; }
|
||||
const NETADDR *PeerAddress() const { return &m_PeerAddr; }
|
||||
|
||||
void ResetErrorString() { m_ErrorString[0] = 0; }
|
||||
const char *ErrorString() const { return m_ErrorString; }
|
||||
void ResetErrorString() { m_aErrorString[0] = 0; }
|
||||
const char *ErrorString() const { return m_aErrorString; }
|
||||
|
||||
// Needed for GotProblems in NetClient
|
||||
int64 LastRecvTime() const { return m_LastRecvTime; }
|
||||
|
@ -231,9 +229,9 @@ public:
|
|||
int AckSequence() const { return m_Ack; }
|
||||
int SeqSequence() const { return m_Sequence; }
|
||||
int SecurityToken() const { return m_SecurityToken; }
|
||||
TStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> *ResendBuffer() { return &m_Buffer; };
|
||||
CStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> *ResendBuffer() { return &m_Buffer; };
|
||||
|
||||
void SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack, SECURITY_TOKEN SecurityToken, TStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> *pResendBuffer, bool Sixup);
|
||||
void SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack, SECURITY_TOKEN SecurityToken, CStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> *pResendBuffer, bool Sixup);
|
||||
|
||||
// anti spoof
|
||||
void DirectInit(NETADDR &Addr, SECURITY_TOKEN SecurityToken, SECURITY_TOKEN Token, bool Sixup);
|
||||
|
@ -320,11 +318,11 @@ class CNetServer
|
|||
NETFUNC_NEWCLIENT_NOAUTH m_pfnNewClientNoAuth;
|
||||
NETFUNC_DELCLIENT m_pfnDelClient;
|
||||
NETFUNC_CLIENTREJOIN m_pfnClientRejoin;
|
||||
void *m_UserPtr;
|
||||
void *m_pUser;
|
||||
|
||||
int m_NumConAttempts; // log flooding attacks
|
||||
int64 m_TimeNumConAttempts;
|
||||
unsigned char m_SecurityTokenSeed[16];
|
||||
unsigned char m_aSecurityTokenSeed[16];
|
||||
|
||||
// vanilla connect flood detection
|
||||
int64 m_VConnFirst;
|
||||
|
@ -345,7 +343,7 @@ class CNetServer
|
|||
int TryAcceptClient(NETADDR &Addr, SECURITY_TOKEN SecurityToken, bool VanillaAuth = false, bool Sixup = false, SECURITY_TOKEN Token = 0);
|
||||
int NumClientsWithAddr(NETADDR Addr);
|
||||
bool Connlimit(NETADDR Addr);
|
||||
void SendMsgs(NETADDR &Addr, const CMsgPacker *Msgs[], int num);
|
||||
void SendMsgs(NETADDR &Addr, const CMsgPacker *apMsgs[], int Num);
|
||||
|
||||
public:
|
||||
int SetCallbacks(NETFUNC_NEWCLIENT pfnNewClient, NETFUNC_DELCLIENT pfnDelClient, void *pUser);
|
||||
|
@ -356,7 +354,7 @@ public:
|
|||
int Close();
|
||||
|
||||
//
|
||||
int Recv(CNetChunk *pChunk, SECURITY_TOKEN *ResponseToken);
|
||||
int Recv(CNetChunk *pChunk, SECURITY_TOKEN *pResponseToken);
|
||||
int Send(CNetChunk *pChunk);
|
||||
int Update();
|
||||
|
||||
|
@ -402,7 +400,7 @@ class CNetConsole
|
|||
|
||||
NETFUNC_NEWCLIENT_CON m_pfnNewClient;
|
||||
NETFUNC_DELCLIENT m_pfnDelClient;
|
||||
void *m_UserPtr;
|
||||
void *m_pUser;
|
||||
|
||||
CNetRecvUnpacker m_RecvUnpacker;
|
||||
|
||||
|
@ -441,12 +439,12 @@ public:
|
|||
int Close();
|
||||
|
||||
// connection state
|
||||
int Disconnect(const char *Reason);
|
||||
int Connect(NETADDR *Addr);
|
||||
int Disconnect(const char *pReason);
|
||||
int Connect(NETADDR *pAddr);
|
||||
|
||||
// communication
|
||||
int Recv(CNetChunk *Chunk);
|
||||
int Send(CNetChunk *Chunk);
|
||||
int Recv(CNetChunk *pChunk);
|
||||
int Send(CNetChunk *pChunk);
|
||||
|
||||
// pumping
|
||||
int Update();
|
||||
|
@ -481,7 +479,7 @@ public:
|
|||
static void SendPacketConnless(NETSOCKET Socket, NETADDR *pAddr, const void *pData, int DataSize, bool Extended, unsigned char aExtra[4]);
|
||||
static void SendPacket(NETSOCKET Socket, NETADDR *pAddr, CNetPacketConstruct *pPacket, SECURITY_TOKEN SecurityToken, bool Sixup = false, bool NoCompress = false);
|
||||
|
||||
static int UnpackPacket(unsigned char *pBuffer, int Size, CNetPacketConstruct *pPacket, bool &Sixup, SECURITY_TOKEN *SecurityToken = 0, SECURITY_TOKEN *ResponseToken = 0);
|
||||
static int UnpackPacket(unsigned char *pBuffer, int Size, CNetPacketConstruct *pPacket, bool &Sixup, SECURITY_TOKEN *pSecurityToken = 0, SECURITY_TOKEN *pResponseToken = 0);
|
||||
|
||||
// The backroom is ack-NET_MAX_SEQUENCE/2. Used for knowing if we acked a packet or not
|
||||
static int IsSeqInBackroom(int Seq, int Ack);
|
||||
|
|
|
@ -48,12 +48,12 @@ void CNetConnection::Reset(bool Rejoin)
|
|||
|
||||
const char *CNetConnection::ErrorString()
|
||||
{
|
||||
return m_ErrorString;
|
||||
return m_aErrorString;
|
||||
}
|
||||
|
||||
void CNetConnection::SetError(const char *pString)
|
||||
{
|
||||
str_copy(m_ErrorString, pString, sizeof(m_ErrorString));
|
||||
str_copy(m_aErrorString, pString, sizeof(m_aErrorString));
|
||||
}
|
||||
|
||||
void CNetConnection::Init(NETSOCKET Socket, bool BlockCloseMsg)
|
||||
|
@ -63,7 +63,7 @@ void CNetConnection::Init(NETSOCKET Socket, bool BlockCloseMsg)
|
|||
|
||||
m_Socket = Socket;
|
||||
m_BlockCloseMsg = BlockCloseMsg;
|
||||
mem_zero(m_ErrorString, sizeof(m_ErrorString));
|
||||
mem_zero(m_aErrorString, sizeof(m_aErrorString));
|
||||
}
|
||||
|
||||
void CNetConnection::AckChunks(int Ack)
|
||||
|
@ -189,7 +189,7 @@ int CNetConnection::Connect(NETADDR *pAddr)
|
|||
// init connection
|
||||
Reset();
|
||||
m_PeerAddr = *pAddr;
|
||||
mem_zero(m_ErrorString, sizeof(m_ErrorString));
|
||||
mem_zero(m_aErrorString, sizeof(m_aErrorString));
|
||||
m_State = NET_CONNSTATE_CONNECT;
|
||||
SendControl(NET_CTRLMSG_CONNECT, SECURITY_TOKEN_MAGIC, sizeof(SECURITY_TOKEN_MAGIC));
|
||||
return 0;
|
||||
|
@ -210,11 +210,11 @@ void CNetConnection::Disconnect(const char *pReason)
|
|||
SendControl(NET_CTRLMSG_CLOSE, 0, 0);
|
||||
}
|
||||
|
||||
if(pReason != m_ErrorString)
|
||||
if(pReason != m_aErrorString)
|
||||
{
|
||||
m_ErrorString[0] = 0;
|
||||
m_aErrorString[0] = 0;
|
||||
if(pReason)
|
||||
str_copy(m_ErrorString, pReason, sizeof(m_ErrorString));
|
||||
str_copy(m_aErrorString, pReason, sizeof(m_aErrorString));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ void CNetConnection::DirectInit(NETADDR &Addr, SECURITY_TOKEN SecurityToken, SEC
|
|||
m_State = NET_CONNSTATE_ONLINE;
|
||||
|
||||
m_PeerAddr = Addr;
|
||||
mem_zero(m_ErrorString, sizeof(m_ErrorString));
|
||||
mem_zero(m_aErrorString, sizeof(m_aErrorString));
|
||||
|
||||
int64 Now = time_get();
|
||||
m_LastSendTime = Now;
|
||||
|
@ -290,25 +290,25 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr, SECURITY_
|
|||
m_State = NET_CONNSTATE_ERROR;
|
||||
m_RemoteClosed = 1;
|
||||
|
||||
char Str[128] = {0};
|
||||
char aStr[128] = {0};
|
||||
if(pPacket->m_DataSize > 1)
|
||||
{
|
||||
// make sure to sanitize the error string form the other party
|
||||
if(pPacket->m_DataSize < 128)
|
||||
str_copy(Str, (char *)&pPacket->m_aChunkData[1], pPacket->m_DataSize);
|
||||
str_copy(aStr, (char *)&pPacket->m_aChunkData[1], pPacket->m_DataSize);
|
||||
else
|
||||
str_copy(Str, (char *)&pPacket->m_aChunkData[1], sizeof(Str));
|
||||
str_sanitize_strong(Str);
|
||||
str_copy(aStr, (char *)&pPacket->m_aChunkData[1], sizeof(aStr));
|
||||
str_sanitize_strong(aStr);
|
||||
}
|
||||
|
||||
if(!m_BlockCloseMsg)
|
||||
{
|
||||
// set the error string
|
||||
SetError(Str);
|
||||
SetError(aStr);
|
||||
}
|
||||
|
||||
if(g_Config.m_Debug)
|
||||
dbg_msg("conn", "closed reason='%s'", Str);
|
||||
dbg_msg("conn", "closed reason='%s'", aStr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr, SECURITY_
|
|||
Reset();
|
||||
m_State = NET_CONNSTATE_PENDING;
|
||||
m_PeerAddr = *pAddr;
|
||||
mem_zero(m_ErrorString, sizeof(m_ErrorString));
|
||||
mem_zero(m_aErrorString, sizeof(m_aErrorString));
|
||||
m_LastSendTime = Now;
|
||||
m_LastRecvTime = Now;
|
||||
m_LastUpdateTime = Now;
|
||||
|
@ -466,7 +466,7 @@ int CNetConnection::Update()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void CNetConnection::SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack, SECURITY_TOKEN SecurityToken, TStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> *pResendBuffer, bool Sixup)
|
||||
void CNetConnection::SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack, SECURITY_TOKEN SecurityToken, CStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> *pResendBuffer, bool Sixup)
|
||||
{
|
||||
int64 Now = time_get();
|
||||
|
||||
|
@ -476,7 +476,7 @@ void CNetConnection::SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack, SE
|
|||
|
||||
m_State = NET_CONNSTATE_ONLINE;
|
||||
m_PeerAddr = *pAddr;
|
||||
mem_zero(m_ErrorString, sizeof(m_ErrorString));
|
||||
mem_zero(m_aErrorString, sizeof(m_aErrorString));
|
||||
m_LastSendTime = Now;
|
||||
m_LastRecvTime = Now;
|
||||
m_LastUpdateTime = Now;
|
||||
|
@ -487,10 +487,10 @@ void CNetConnection::SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack, SE
|
|||
m_Buffer.Init();
|
||||
while(pResendBuffer->First())
|
||||
{
|
||||
CNetChunkResend *First = pResendBuffer->First();
|
||||
CNetChunkResend *pFirst = pResendBuffer->First();
|
||||
|
||||
CNetChunkResend *pResend = m_Buffer.Allocate(sizeof(CNetChunkResend) + First->m_DataSize);
|
||||
mem_copy(pResend, First, sizeof(CNetChunkResend) + First->m_DataSize);
|
||||
CNetChunkResend *pResend = m_Buffer.Allocate(sizeof(CNetChunkResend) + pFirst->m_DataSize);
|
||||
mem_copy(pResend, pFirst, sizeof(CNetChunkResend) + pFirst->m_DataSize);
|
||||
|
||||
pResendBuffer->PopFirst();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ void CNetConsole::SetCallbacks(NETFUNC_NEWCLIENT_CON pfnNewClient, NETFUNC_DELCL
|
|||
{
|
||||
m_pfnNewClient = pfnNewClient;
|
||||
m_pfnDelClient = pfnDelClient;
|
||||
m_UserPtr = pUser;
|
||||
m_pUser = pUser;
|
||||
}
|
||||
|
||||
int CNetConsole::Close()
|
||||
|
@ -50,7 +50,7 @@ int CNetConsole::Close()
|
|||
int CNetConsole::Drop(int ClientID, const char *pReason)
|
||||
{
|
||||
if(m_pfnDelClient)
|
||||
m_pfnDelClient(ClientID, pReason, m_UserPtr);
|
||||
m_pfnDelClient(ClientID, pReason, m_pUser);
|
||||
|
||||
m_aSlots[ClientID].m_Connection.Disconnect(pReason);
|
||||
|
||||
|
@ -82,7 +82,7 @@ int CNetConsole::AcceptClient(NETSOCKET Socket, const NETADDR *pAddr)
|
|||
{
|
||||
m_aSlots[FreeSlot].m_Connection.Init(Socket, pAddr);
|
||||
if(m_pfnNewClient)
|
||||
m_pfnNewClient(FreeSlot, m_UserPtr);
|
||||
m_pfnNewClient(FreeSlot, m_pUser);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ bool CNetServer::Open(NETADDR BindAddr, CNetBan *pNetBan, int MaxClients, int Ma
|
|||
m_VConnNum = 0;
|
||||
m_VConnFirst = 0;
|
||||
|
||||
secure_random_fill(m_SecurityTokenSeed, sizeof(m_SecurityTokenSeed));
|
||||
secure_random_fill(m_aSecurityTokenSeed, sizeof(m_aSecurityTokenSeed));
|
||||
|
||||
for(auto &Slot : m_aSlots)
|
||||
Slot.m_Connection.Init(m_Socket, true);
|
||||
|
@ -88,7 +88,7 @@ int CNetServer::SetCallbacks(NETFUNC_NEWCLIENT pfnNewClient, NETFUNC_DELCLIENT p
|
|||
{
|
||||
m_pfnNewClient = pfnNewClient;
|
||||
m_pfnDelClient = pfnDelClient;
|
||||
m_UserPtr = pUser;
|
||||
m_pUser = pUser;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ int CNetServer::SetCallbacks(NETFUNC_NEWCLIENT pfnNewClient, NETFUNC_NEWCLIENT_N
|
|||
m_pfnNewClientNoAuth = pfnNewClientNoAuth;
|
||||
m_pfnClientRejoin = pfnClientRejoin;
|
||||
m_pfnDelClient = pfnDelClient;
|
||||
m_UserPtr = pUser;
|
||||
m_pUser = pUser;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ int CNetServer::Drop(int ClientID, const char *pReason)
|
|||
pReason
|
||||
);*/
|
||||
if(m_pfnDelClient)
|
||||
m_pfnDelClient(ClientID, pReason, m_UserPtr);
|
||||
m_pfnDelClient(ClientID, pReason, m_pUser);
|
||||
|
||||
m_aSlots[ClientID].m_Connection.Disconnect(pReason);
|
||||
|
||||
|
@ -146,7 +146,7 @@ SECURITY_TOKEN CNetServer::GetToken(const NETADDR &Addr)
|
|||
{
|
||||
SHA256_CTX Sha256;
|
||||
sha256_init(&Sha256);
|
||||
sha256_update(&Sha256, (unsigned char *)m_SecurityTokenSeed, sizeof(m_SecurityTokenSeed));
|
||||
sha256_update(&Sha256, (unsigned char *)m_aSecurityTokenSeed, sizeof(m_aSecurityTokenSeed));
|
||||
sha256_update(&Sha256, (unsigned char *)&Addr, 20); // omit port, bad idea!
|
||||
|
||||
SECURITY_TOKEN SecurityToken = ToSecurityToken(sha256_finish(&Sha256).data);
|
||||
|
@ -218,15 +218,15 @@ int CNetServer::TryAcceptClient(NETADDR &Addr, SECURITY_TOKEN SecurityToken, boo
|
|||
{
|
||||
if(Sixup && !g_Config.m_SvSixup)
|
||||
{
|
||||
const char Msg[] = "0.7 connections are not accepted at this time";
|
||||
CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, Msg, sizeof(Msg), SecurityToken, Sixup);
|
||||
const char aMsg[] = "0.7 connections are not accepted at this time";
|
||||
CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, aMsg, sizeof(aMsg), SecurityToken, Sixup);
|
||||
return -1; // failed to add client?
|
||||
}
|
||||
|
||||
if(Connlimit(Addr))
|
||||
{
|
||||
const char Msg[] = "Too many connections in a short time";
|
||||
CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, Msg, sizeof(Msg), SecurityToken, Sixup);
|
||||
const char aMsg[] = "Too many connections in a short time";
|
||||
CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, aMsg, sizeof(aMsg), SecurityToken, Sixup);
|
||||
return -1; // failed to add client
|
||||
}
|
||||
|
||||
|
@ -251,8 +251,8 @@ int CNetServer::TryAcceptClient(NETADDR &Addr, SECURITY_TOKEN SecurityToken, boo
|
|||
|
||||
if(Slot == -1)
|
||||
{
|
||||
const char FullMsg[] = "This server is full";
|
||||
CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, FullMsg, sizeof(FullMsg), SecurityToken, Sixup);
|
||||
const char aFullMsg[] = "This server is full";
|
||||
CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, aFullMsg, sizeof(aFullMsg), SecurityToken, Sixup);
|
||||
|
||||
return -1; // failed to add client
|
||||
}
|
||||
|
@ -277,22 +277,22 @@ int CNetServer::TryAcceptClient(NETADDR &Addr, SECURITY_TOKEN SecurityToken, boo
|
|||
}
|
||||
|
||||
if(VanillaAuth)
|
||||
m_pfnNewClientNoAuth(Slot, m_UserPtr);
|
||||
m_pfnNewClientNoAuth(Slot, m_pUser);
|
||||
else
|
||||
m_pfnNewClient(Slot, m_UserPtr, Sixup);
|
||||
m_pfnNewClient(Slot, m_pUser, Sixup);
|
||||
|
||||
return Slot; // done
|
||||
}
|
||||
|
||||
void CNetServer::SendMsgs(NETADDR &Addr, const CMsgPacker *Msgs[], int num)
|
||||
void CNetServer::SendMsgs(NETADDR &Addr, const CMsgPacker *apMsgs[], int Num)
|
||||
{
|
||||
CNetPacketConstruct m_Construct;
|
||||
mem_zero(&m_Construct, sizeof(m_Construct));
|
||||
unsigned char *pChunkData = &m_Construct.m_aChunkData[m_Construct.m_DataSize];
|
||||
CNetPacketConstruct Construct;
|
||||
mem_zero(&Construct, sizeof(Construct));
|
||||
unsigned char *pChunkData = &Construct.m_aChunkData[Construct.m_DataSize];
|
||||
|
||||
for(int i = 0; i < num; i++)
|
||||
for(int i = 0; i < Num; i++)
|
||||
{
|
||||
const CMsgPacker *pMsg = Msgs[i];
|
||||
const CMsgPacker *pMsg = apMsgs[i];
|
||||
CNetChunkHeader Header;
|
||||
Header.m_Flags = NET_CHUNKFLAG_VITAL;
|
||||
Header.m_Size = pMsg->Size();
|
||||
|
@ -302,12 +302,12 @@ void CNetServer::SendMsgs(NETADDR &Addr, const CMsgPacker *Msgs[], int num)
|
|||
*pChunkData <<= 1;
|
||||
*pChunkData |= 1;
|
||||
pChunkData += pMsg->Size();
|
||||
m_Construct.m_NumChunks++;
|
||||
Construct.m_NumChunks++;
|
||||
}
|
||||
|
||||
//
|
||||
m_Construct.m_DataSize = (int)(pChunkData - m_Construct.m_aChunkData);
|
||||
CNetBase::SendPacket(m_Socket, &Addr, &m_Construct, NET_SECURITY_TOKEN_UNSUPPORTED);
|
||||
Construct.m_DataSize = (int)(pChunkData - Construct.m_aChunkData);
|
||||
CNetBase::SendPacket(m_Socket, &Addr, &Construct, NET_SECURITY_TOKEN_UNSUPPORTED);
|
||||
}
|
||||
|
||||
// connection-less msg packet without token-support
|
||||
|
@ -429,9 +429,9 @@ void CNetServer::OnPreConnMsg(NETADDR &Addr, CNetPacketConstruct &Packet)
|
|||
SnapEmptyMsg.AddInt(SecurityToken + 1);
|
||||
|
||||
// send all chunks/msgs in one packet
|
||||
const CMsgPacker *Msgs[] = {&MapChangeMsg, &MapDataMsg, &ConReadyMsg,
|
||||
const CMsgPacker *apMsgs[] = {&MapChangeMsg, &MapDataMsg, &ConReadyMsg,
|
||||
&SnapEmptyMsg, &SnapEmptyMsg, &SnapEmptyMsg};
|
||||
SendMsgs(Addr, Msgs, 6);
|
||||
SendMsgs(Addr, apMsgs, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -506,7 +506,7 @@ void CNetServer::OnConnCtrlMsg(NETADDR &Addr, int ClientID, int ControlMsg, cons
|
|||
|
||||
// reset netconn and process rejoin
|
||||
m_aSlots[ClientID].m_Connection.Reset(true);
|
||||
m_pfnClientRejoin(ClientID, m_UserPtr);
|
||||
m_pfnClientRejoin(ClientID, m_pUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ static bool IsDDNetControlMsg(const CNetPacketConstruct *pPacket)
|
|||
/*
|
||||
TODO: chopp up this function into smaller working parts
|
||||
*/
|
||||
int CNetServer::Recv(CNetChunk *pChunk, SECURITY_TOKEN *ResponseToken)
|
||||
int CNetServer::Recv(CNetChunk *pChunk, SECURITY_TOKEN *pResponseToken)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
|
@ -654,8 +654,8 @@ int CNetServer::Recv(CNetChunk *pChunk, SECURITY_TOKEN *ResponseToken)
|
|||
|
||||
SECURITY_TOKEN Token;
|
||||
bool Sixup = false;
|
||||
*ResponseToken = NET_SECURITY_TOKEN_UNKNOWN;
|
||||
if(CNetBase::UnpackPacket(pData, Bytes, &m_RecvUnpacker.m_Data, Sixup, &Token, ResponseToken) == 0)
|
||||
*pResponseToken = NET_SECURITY_TOKEN_UNKNOWN;
|
||||
if(CNetBase::UnpackPacket(pData, Bytes, &m_RecvUnpacker.m_Data, Sixup, &Token, pResponseToken) == 0)
|
||||
{
|
||||
if(m_RecvUnpacker.m_Data.m_Flags & NET_PACKETFLAG_CONNLESS)
|
||||
{
|
||||
|
@ -712,7 +712,7 @@ int CNetServer::Recv(CNetChunk *pChunk, SECURITY_TOKEN *ResponseToken)
|
|||
if(Sixup)
|
||||
{
|
||||
// got 0.7 control msg
|
||||
if(OnSixupCtrlMsg(Addr, pChunk, m_RecvUnpacker.m_Data.m_aChunkData[0], m_RecvUnpacker.m_Data, *ResponseToken, Token) == 1)
|
||||
if(OnSixupCtrlMsg(Addr, pChunk, m_RecvUnpacker.m_Data.m_aChunkData[0], m_RecvUnpacker.m_Data, *pResponseToken, Token) == 1)
|
||||
return 1;
|
||||
}
|
||||
else if(IsDDNetControlMsg(&m_RecvUnpacker.m_Data))
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
#ifndef ENGINE_SHARED_RINGBUFFER_H
|
||||
#define ENGINE_SHARED_RINGBUFFER_H
|
||||
|
||||
typedef struct RINGBUFFER RINGBUFFER;
|
||||
|
||||
class CRingBufferBase
|
||||
{
|
||||
class CItem
|
||||
|
@ -49,12 +47,12 @@ public:
|
|||
};
|
||||
|
||||
template<typename T, int TSIZE, int TFLAGS = 0>
|
||||
class TStaticRingBuffer : public CRingBufferBase
|
||||
class CStaticRingBuffer : public CRingBufferBase
|
||||
{
|
||||
unsigned char m_aBuffer[TSIZE];
|
||||
|
||||
public:
|
||||
TStaticRingBuffer() { Init(); }
|
||||
CStaticRingBuffer() { Init(); }
|
||||
|
||||
void Init() { CRingBufferBase::Init(m_aBuffer, TSIZE, TFLAGS); }
|
||||
|
||||
|
|
|
@ -178,13 +178,13 @@ CSnapshotDelta::CSnapshotDelta()
|
|||
mem_zero(&m_Empty, sizeof(m_Empty));
|
||||
}
|
||||
|
||||
CSnapshotDelta::CSnapshotDelta(const CSnapshotDelta &old)
|
||||
CSnapshotDelta::CSnapshotDelta(const CSnapshotDelta &Old)
|
||||
{
|
||||
mem_copy(m_aItemSizes, old.m_aItemSizes, sizeof(m_aItemSizes));
|
||||
mem_copy(m_aSnapshotDataRate, old.m_aSnapshotDataRate, sizeof(m_aSnapshotDataRate));
|
||||
mem_copy(m_aSnapshotDataUpdates, old.m_aSnapshotDataUpdates, sizeof(m_aSnapshotDataUpdates));
|
||||
mem_copy(&m_SnapshotCurrent, &old.m_SnapshotCurrent, sizeof(m_SnapshotCurrent));
|
||||
mem_copy(&m_Empty, &old.m_Empty, sizeof(m_Empty));
|
||||
mem_copy(m_aItemSizes, Old.m_aItemSizes, sizeof(m_aItemSizes));
|
||||
mem_copy(m_aSnapshotDataRate, Old.m_aSnapshotDataRate, sizeof(m_aSnapshotDataRate));
|
||||
mem_copy(m_aSnapshotDataUpdates, Old.m_aSnapshotDataUpdates, sizeof(m_aSnapshotDataUpdates));
|
||||
mem_copy(&m_SnapshotCurrent, &Old.m_SnapshotCurrent, sizeof(m_SnapshotCurrent));
|
||||
mem_copy(&m_Empty, &Old.m_Empty, sizeof(m_Empty));
|
||||
}
|
||||
|
||||
void CSnapshotDelta::SetStaticsize(int ItemType, int Size)
|
||||
|
@ -203,7 +203,7 @@ CSnapshotDelta::CData *CSnapshotDelta::EmptyDelta()
|
|||
int CSnapshotDelta::CreateDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pDstData)
|
||||
{
|
||||
CData *pDelta = (CData *)pDstData;
|
||||
int *pData = (int *)pDelta->m_pData;
|
||||
int *pData = (int *)pDelta->m_aData;
|
||||
int i, ItemSize, PastIndex;
|
||||
CSnapshotItem *pFromItem;
|
||||
CSnapshotItem *pCurItem;
|
||||
|
@ -215,14 +215,14 @@ int CSnapshotDelta::CreateDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pDstData
|
|||
pDelta->m_NumUpdateItems = 0;
|
||||
pDelta->m_NumTempItems = 0;
|
||||
|
||||
CItemList Hashlist[HASHLIST_SIZE];
|
||||
GenerateHash(Hashlist, pTo);
|
||||
CItemList aHashlist[HASHLIST_SIZE];
|
||||
GenerateHash(aHashlist, pTo);
|
||||
|
||||
// pack deleted stuff
|
||||
for(i = 0; i < pFrom->NumItems(); i++)
|
||||
{
|
||||
pFromItem = pFrom->GetItem(i);
|
||||
if(GetItemIndexHashed(pFromItem->Key(), Hashlist) == -1)
|
||||
if(GetItemIndexHashed(pFromItem->Key(), aHashlist) == -1)
|
||||
{
|
||||
// deleted
|
||||
pDelta->m_NumDeletedItems++;
|
||||
|
@ -231,7 +231,7 @@ int CSnapshotDelta::CreateDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pDstData
|
|||
}
|
||||
}
|
||||
|
||||
GenerateHash(Hashlist, pFrom);
|
||||
GenerateHash(aHashlist, pFrom);
|
||||
int aPastIndices[1024];
|
||||
|
||||
// fetch previous indices
|
||||
|
@ -240,7 +240,7 @@ int CSnapshotDelta::CreateDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pDstData
|
|||
for(i = 0; i < NumItems; i++)
|
||||
{
|
||||
pCurItem = pTo->GetItem(i); // O(1) .. O(n)
|
||||
aPastIndices[i] = GetItemIndexHashed(pCurItem->Key(), Hashlist); // O(n) .. O(n^n)
|
||||
aPastIndices[i] = GetItemIndexHashed(pCurItem->Key(), aHashlist); // O(n) .. O(n^n)
|
||||
}
|
||||
|
||||
for(i = 0; i < NumItems; i++)
|
||||
|
@ -322,7 +322,7 @@ int CSnapshotDelta::UnpackDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pSrcData
|
|||
{
|
||||
CSnapshotBuilder Builder;
|
||||
CData *pDelta = (CData *)pSrcData;
|
||||
int *pData = (int *)pDelta->m_pData;
|
||||
int *pData = (int *)pDelta->m_aData;
|
||||
int *pEnd = (int *)(((char *)pSrcData + DataSize));
|
||||
|
||||
CSnapshotItem *pFromItem;
|
||||
|
@ -564,11 +564,11 @@ int *CSnapshotBuilder::GetItemData(int Key)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CSnapshotBuilder::Finish(void *SpnapData)
|
||||
int CSnapshotBuilder::Finish(void *pSnapData)
|
||||
{
|
||||
//dbg_msg("snap", "---------------------------");
|
||||
// flattern and make the snapshot
|
||||
CSnapshot *pSnap = (CSnapshot *)SpnapData;
|
||||
CSnapshot *pSnap = (CSnapshot *)pSnapData;
|
||||
int OffsetSize = sizeof(int) * m_NumItems;
|
||||
pSnap->m_DataSize = m_DataSize;
|
||||
pSnap->m_NumItems = m_NumItems;
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
int m_NumDeletedItems;
|
||||
int m_NumUpdateItems;
|
||||
int m_NumTempItems; // needed?
|
||||
int m_pData[1];
|
||||
int m_aData[1];
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -82,7 +82,7 @@ private:
|
|||
public:
|
||||
static int DiffItem(int *pPast, int *pCurrent, int *pOut, int Size);
|
||||
CSnapshotDelta();
|
||||
CSnapshotDelta(const CSnapshotDelta &old);
|
||||
CSnapshotDelta(const CSnapshotDelta &Old);
|
||||
int GetDataRate(int Index) { return m_aSnapshotDataRate[Index]; }
|
||||
int GetDataUpdates(int Index) { return m_aSnapshotDataUpdates[Index]; }
|
||||
void SetStaticsize(int ItemType, int Size);
|
||||
|
@ -119,7 +119,7 @@ public:
|
|||
void PurgeAll();
|
||||
void PurgeUntil(int Tick);
|
||||
void Add(int Tick, int64 Tagtime, int DataSize, void *pData, int CreateAlt);
|
||||
int Get(int Tick, int64 *Tagtime, CSnapshot **pData, CSnapshot **ppAltData);
|
||||
int Get(int Tick, int64 *pTagtime, CSnapshot **ppData, CSnapshot **ppAltData);
|
||||
};
|
||||
|
||||
class CSnapshotBuilder
|
||||
|
@ -154,7 +154,7 @@ public:
|
|||
CSnapshotItem *GetItem(int Index);
|
||||
int *GetItemData(int Key);
|
||||
|
||||
int Finish(void *Snapdata);
|
||||
int Finish(void *pSnapdata);
|
||||
};
|
||||
|
||||
#endif // ENGINE_SNAPSHOT_H
|
||||
|
|
|
@ -215,7 +215,7 @@ public:
|
|||
#if defined(CONF_FAMILY_UNIX)
|
||||
// 4) check for all default locations
|
||||
{
|
||||
const char *aDirs[] = {
|
||||
const char *apDirs[] = {
|
||||
"/usr/share/ddnet",
|
||||
"/usr/share/games/ddnet",
|
||||
"/usr/local/share/ddnet",
|
||||
|
@ -223,16 +223,16 @@ public:
|
|||
"/usr/pkg/share/ddnet",
|
||||
"/usr/pkg/share/games/ddnet",
|
||||
"/opt/ddnet"};
|
||||
const int DirsCount = sizeof(aDirs) / sizeof(aDirs[0]);
|
||||
const int DirsCount = sizeof(apDirs) / sizeof(apDirs[0]);
|
||||
|
||||
int i;
|
||||
for(i = 0; i < DirsCount; i++)
|
||||
{
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "%s/data/mapres", aDirs[i]);
|
||||
str_format(aBuf, sizeof(aBuf), "%s/data/mapres", apDirs[i]);
|
||||
if(fs_is_dir(aBuf))
|
||||
{
|
||||
str_format(m_aDatadir, sizeof(m_aDatadir), "%s/data", aDirs[i]);
|
||||
str_format(m_aDatadir, sizeof(m_aDatadir), "%s/data", apDirs[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -393,11 +393,11 @@ public:
|
|||
|
||||
struct CFindCBData
|
||||
{
|
||||
CStorage *pStorage;
|
||||
const char *pFilename;
|
||||
const char *pPath;
|
||||
char *pBuffer;
|
||||
int BufferSize;
|
||||
CStorage *m_pStorage;
|
||||
const char *m_pFilename;
|
||||
const char *m_pPath;
|
||||
char *m_pBuffer;
|
||||
int m_BufferSize;
|
||||
};
|
||||
|
||||
static int FindFileCallback(const char *pName, int IsDir, int Type, void *pUser)
|
||||
|
@ -411,16 +411,16 @@ public:
|
|||
// search within the folder
|
||||
char aBuf[MAX_PATH_LENGTH];
|
||||
char aPath[MAX_PATH_LENGTH];
|
||||
str_format(aPath, sizeof(aPath), "%s/%s", Data.pPath, pName);
|
||||
Data.pPath = aPath;
|
||||
fs_listdir(Data.pStorage->GetPath(Type, aPath, aBuf, sizeof(aBuf)), FindFileCallback, Type, &Data);
|
||||
if(Data.pBuffer[0])
|
||||
str_format(aPath, sizeof(aPath), "%s/%s", Data.m_pPath, pName);
|
||||
Data.m_pPath = aPath;
|
||||
fs_listdir(Data.m_pStorage->GetPath(Type, aPath, aBuf, sizeof(aBuf)), FindFileCallback, Type, &Data);
|
||||
if(Data.m_pBuffer[0])
|
||||
return 1;
|
||||
}
|
||||
else if(!str_comp(pName, Data.pFilename))
|
||||
else if(!str_comp(pName, Data.m_pFilename))
|
||||
{
|
||||
// found the file = end
|
||||
str_format(Data.pBuffer, Data.BufferSize, "%s/%s", Data.pPath, Data.pFilename);
|
||||
str_format(Data.m_pBuffer, Data.m_BufferSize, "%s/%s", Data.m_pPath, Data.m_pFilename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -435,11 +435,11 @@ public:
|
|||
pBuffer[0] = 0;
|
||||
char aBuf[MAX_PATH_LENGTH];
|
||||
CFindCBData Data;
|
||||
Data.pStorage = this;
|
||||
Data.pFilename = pFilename;
|
||||
Data.pPath = pPath;
|
||||
Data.pBuffer = pBuffer;
|
||||
Data.BufferSize = BufferSize;
|
||||
Data.m_pStorage = this;
|
||||
Data.m_pFilename = pFilename;
|
||||
Data.m_pPath = pPath;
|
||||
Data.m_pBuffer = pBuffer;
|
||||
Data.m_BufferSize = BufferSize;
|
||||
|
||||
if(Type == TYPE_ALL)
|
||||
{
|
||||
|
@ -468,10 +468,10 @@ public:
|
|||
char aBuffer[MAX_PATH_LENGTH];
|
||||
GetPath(Type, pFilename, aBuffer, sizeof(aBuffer));
|
||||
|
||||
bool success = !fs_remove(aBuffer);
|
||||
if(!success)
|
||||
bool Success = !fs_remove(aBuffer);
|
||||
if(!Success)
|
||||
dbg_msg("storage", "failed to remove: %s", aBuffer);
|
||||
return success;
|
||||
return Success;
|
||||
}
|
||||
|
||||
virtual bool RemoveBinaryFile(const char *pFilename)
|
||||
|
@ -479,10 +479,10 @@ public:
|
|||
char aBuffer[MAX_PATH_LENGTH];
|
||||
GetBinaryPath(pFilename, aBuffer, sizeof(aBuffer));
|
||||
|
||||
bool success = !fs_remove(aBuffer);
|
||||
if(!success)
|
||||
bool Success = !fs_remove(aBuffer);
|
||||
if(!Success)
|
||||
dbg_msg("storage", "failed to remove: %s", aBuffer);
|
||||
return success;
|
||||
return Success;
|
||||
}
|
||||
|
||||
virtual bool RenameFile(const char *pOldFilename, const char *pNewFilename, int Type)
|
||||
|
@ -495,10 +495,10 @@ public:
|
|||
GetPath(Type, pOldFilename, aOldBuffer, sizeof(aOldBuffer));
|
||||
GetPath(Type, pNewFilename, aNewBuffer, sizeof(aNewBuffer));
|
||||
|
||||
bool success = !fs_rename(aOldBuffer, aNewBuffer);
|
||||
if(!success)
|
||||
bool Success = !fs_rename(aOldBuffer, aNewBuffer);
|
||||
if(!Success)
|
||||
dbg_msg("storage", "failed to rename: %s -> %s", aOldBuffer, aNewBuffer);
|
||||
return success;
|
||||
return Success;
|
||||
}
|
||||
|
||||
virtual bool RenameBinaryFile(const char *pOldFilename, const char *pNewFilename)
|
||||
|
@ -511,10 +511,10 @@ public:
|
|||
if(fs_makedir_rec_for(aNewBuffer) < 0)
|
||||
dbg_msg("storage", "cannot create folder for: %s", aNewBuffer);
|
||||
|
||||
bool success = !fs_rename(aOldBuffer, aNewBuffer);
|
||||
if(!success)
|
||||
bool Success = !fs_rename(aOldBuffer, aNewBuffer);
|
||||
if(!Success)
|
||||
dbg_msg("storage", "failed to rename: %s -> %s", aOldBuffer, aNewBuffer);
|
||||
return success;
|
||||
return Success;
|
||||
}
|
||||
|
||||
virtual bool CreateFolder(const char *pFoldername, int Type)
|
||||
|
@ -525,10 +525,10 @@ public:
|
|||
char aBuffer[MAX_PATH_LENGTH];
|
||||
GetPath(Type, pFoldername, aBuffer, sizeof(aBuffer));
|
||||
|
||||
bool success = !fs_makedir(aBuffer);
|
||||
if(!success)
|
||||
bool Success = !fs_makedir(aBuffer);
|
||||
if(!Success)
|
||||
dbg_msg("storage", "failed to create folder: %s", aBuffer);
|
||||
return success;
|
||||
return Success;
|
||||
}
|
||||
|
||||
virtual void GetCompletePath(int Type, const char *pDir, char *pBuffer, unsigned BufferSize)
|
||||
|
|
|
@ -109,10 +109,10 @@ const char *CUuidManager::GetName(int ID) const
|
|||
|
||||
int CUuidManager::LookupUuid(CUuid Uuid) const
|
||||
{
|
||||
sorted_array<CNameIndexed>::range it = ::find_binary(m_aNamesSorted.all(), Uuid);
|
||||
if(!it.empty())
|
||||
sorted_array<CNameIndexed>::range Pos = ::find_binary(m_aNamesSorted.all(), Uuid);
|
||||
if(!Pos.empty())
|
||||
{
|
||||
return GetID(it.front().m_ID);
|
||||
return GetID(Pos.front().m_ID);
|
||||
}
|
||||
return UUID_UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ extern "C" {
|
|||
// ddnet client opens two connections for whatever reason
|
||||
#define WS_CLIENTS (MAX_CLIENTS * 2)
|
||||
|
||||
typedef TStaticRingBuffer<unsigned char, WS_CLIENTS * 4 * 1024,
|
||||
typedef CStaticRingBuffer<unsigned char, WS_CLIENTS * 4 * 1024,
|
||||
CRingBufferBase::FLAG_RECYCLE>
|
||||
TRecvBuffer;
|
||||
typedef TStaticRingBuffer<unsigned char, 4 * 1024,
|
||||
typedef CStaticRingBuffer<unsigned char, 4 * 1024,
|
||||
CRingBufferBase::FLAG_RECYCLE>
|
||||
TSendBuffer;
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ class CChat : public CComponent
|
|||
char m_aText[1];
|
||||
};
|
||||
CHistoryEntry *m_pHistoryEntry;
|
||||
TStaticRingBuffer<CHistoryEntry, 64 * 1024, CRingBufferBase::FLAG_RECYCLE> m_History;
|
||||
CStaticRingBuffer<CHistoryEntry, 64 * 1024, CRingBufferBase::FLAG_RECYCLE> m_History;
|
||||
int m_PendingChatCounter;
|
||||
int64 m_LastChatSend;
|
||||
int64 m_aLastSoundPlayed[CHAT_NUM];
|
||||
|
|
|
@ -25,8 +25,8 @@ class CGameConsole : public CComponent
|
|||
bool m_Highlighted;
|
||||
char m_aText[1];
|
||||
};
|
||||
TStaticRingBuffer<CBacklogEntry, 64 * 1024, CRingBufferBase::FLAG_RECYCLE> m_Backlog;
|
||||
TStaticRingBuffer<char, 64 * 1024, CRingBufferBase::FLAG_RECYCLE> m_History;
|
||||
CStaticRingBuffer<CBacklogEntry, 64 * 1024, CRingBufferBase::FLAG_RECYCLE> m_Backlog;
|
||||
CStaticRingBuffer<char, 64 * 1024, CRingBufferBase::FLAG_RECYCLE> m_History;
|
||||
char *m_pHistoryEntry;
|
||||
|
||||
CLineInput m_Input;
|
||||
|
|
Loading…
Reference in a new issue