mirror of
https://github.com/rehlds/rehlds.git
synced 2025-02-27 05:51:10 +03:00
Reversed CIPRateLimit
Minor refactoring
This commit is contained in:
parent
5e2bd82b00
commit
f5784be364
@ -81,7 +81,7 @@ extern unsigned short *host_basepal;
|
|||||||
NOXREF void Host_EndGame(const char *message, ...);
|
NOXREF void Host_EndGame(const char *message, ...);
|
||||||
void NORETURN Host_Error(const char *error, ...);
|
void NORETURN Host_Error(const char *error, ...);
|
||||||
void Host_InitLocal(void);
|
void Host_InitLocal(void);
|
||||||
NOBODY void Info_WriteVars(FileHandle_t fp);
|
NOXREF void Info_WriteVars(FileHandle_t fp);
|
||||||
void Host_WriteConfiguration(void);
|
void Host_WriteConfiguration(void);
|
||||||
void Host_WriteCustomConfig(void);
|
void Host_WriteCustomConfig(void);
|
||||||
void SV_ClientPrintf(const char *fmt, ...);
|
void SV_ClientPrintf(const char *fmt, ...);
|
||||||
|
@ -28,51 +28,123 @@
|
|||||||
|
|
||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
|
|
||||||
//bool (__fastcall *pCIPRateLimit__CheckIP)(CIPRateLimit *obj, int none, netadr_t adr);
|
CIPRateLimit rateChecker;
|
||||||
|
|
||||||
NOBODY bool CIPRateLimit::CheckIP(netadr_t adr)
|
cvar_t max_queries_sec = { "max_queries_sec", "3.0", FCVAR_SERVER | FCVAR_PROTECTED, 0.0f, nullptr };
|
||||||
|
cvar_t max_queries_sec_global = { "max_queries_sec_global", "30", FCVAR_SERVER | FCVAR_PROTECTED, 0.0f, nullptr };
|
||||||
|
cvar_t max_queries_window = { "max_queries_window", "60", FCVAR_SERVER | FCVAR_PROTECTED, 0.0f, nullptr };
|
||||||
|
cvar_t sv_logblocks = { "sv_logblocks", "0", FCVAR_SERVER, 0.0f, nullptr };
|
||||||
|
|
||||||
|
CIPRateLimit::CIPRateLimit() : m_IPTree(0, START_TREE_SIZE, LessIP)
|
||||||
{
|
{
|
||||||
// TODO: Reverse me
|
m_iGlobalCount = 0;
|
||||||
//{
|
m_lLastTime = -1;
|
||||||
// long curTime; // 29
|
}
|
||||||
// ip_t clientIP; // 32
|
|
||||||
// class iprate_s findEntry; // 56
|
CIPRateLimit::~CIPRateLimit()
|
||||||
// ip_t entry; // 57
|
{
|
||||||
// {
|
}
|
||||||
// ip_t tmp; // 37
|
|
||||||
// int i; // 38
|
// Sort func for rb tree
|
||||||
// LastInorder(const class CUtlRBTree<CIPRateLimit::iprate_s, int> *const this); /* size=169106148, low_pc=0 */ // 37
|
bool CIPRateLimit::LessIP(const iprate_t &lhs, const iprate_t &rhs)
|
||||||
// IsValidIndex(const class CUtlRBTree<CIPRateLimit::iprate_s, int> *const this,
|
{
|
||||||
// int i); /* size=524288, low_pc=0 */ // 41
|
return (lhs.ip < rhs.ip);
|
||||||
// operator[](class CUtlRBTree<CIPRateLimit::iprate_s, int> *const this,
|
}
|
||||||
// int i); /* size=169107280, low_pc=0 */ // 42
|
|
||||||
// {
|
// Return false if this IP has exceeded limits
|
||||||
// ip_t removeIPT; // 45
|
bool CIPRateLimit::CheckIP(netadr_t adr)
|
||||||
// PrevInorder(const class CUtlRBTree<CIPRateLimit::iprate_s, int> *const this,
|
{
|
||||||
// int i); /* size=0, low_pc=0 */ // 46
|
time_t curTime = CRehldsPlatformHolder::get()->time(nullptr);
|
||||||
// }
|
|
||||||
// PrevInorder(const class CUtlRBTree<CIPRateLimit::iprate_s, int> *const this,
|
// check the per ip rate (do this first, so one person dosing doesn't add to the global max rate
|
||||||
// int i); /* size=2019913216, low_pc=0 */ // 51
|
ip_t clientIP;
|
||||||
// }
|
Q_memcpy(&clientIP, adr.ip, sizeof(ip_t));
|
||||||
// Find(const class CUtlRBTree<CIPRateLimit::iprate_s, int> *const this,
|
|
||||||
// const class iprate_s &const search); /* size=1967350639, low_pc=0 */ // 57
|
// if we have stored too many items
|
||||||
// IsValidIndex(const class CUtlRBTree<CIPRateLimit::iprate_s, int> *const this,
|
if (m_IPTree.Count() > MAX_TREE_SIZE)
|
||||||
// int i); /* size=7626612, low_pc=0 */ // 59
|
{
|
||||||
// operator[](class CUtlRBTree<CIPRateLimit::iprate_s, int> *const this,
|
ip_t tmp = m_IPTree.LastInorder(); // we step BACKWARD's through the tree
|
||||||
// int i); /* size=1936875856, low_pc=0 */ // 61
|
int i = m_IPTree.FirstInorder();
|
||||||
// operator[](class CUtlRBTree<CIPRateLimit::iprate_s, int> *const this,
|
|
||||||
// int i); /* size=1869898597, low_pc=0 */ // 63
|
// trim 1/3 the entries from the tree and only traverse the max nodes
|
||||||
// {
|
while ((m_IPTree.Count() > (2 * MAX_TREE_SIZE) / 3) && i < m_IPTree.MaxElement())
|
||||||
// float query_rate; // 70
|
{
|
||||||
// }
|
if (m_IPTree.IsValidIndex(tmp) &&
|
||||||
// {
|
(curTime - m_IPTree[tmp].lastTime) > FLUSH_TIMEOUT &&
|
||||||
// class iprate_s newEntry; // 80
|
m_IPTree[tmp].ip != clientIP)
|
||||||
// Insert(class CUtlRBTree<CIPRateLimit::iprate_s, int> *const this,
|
{
|
||||||
// const class iprate_s &const insert); /* size=1399744112, low_pc=0 */ // 84
|
ip_t removeIPT = tmp;
|
||||||
// }
|
tmp = m_IPTree.PrevInorder(tmp);
|
||||||
// {
|
m_IPTree.RemoveAt(removeIPT);
|
||||||
// float query_rate; // 97
|
continue;
|
||||||
// }
|
}
|
||||||
//}
|
|
||||||
|
i++;
|
||||||
|
tmp = m_IPTree.PrevInorder(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// now find the entry and check if its within our rate limits
|
||||||
|
iprate_t findEntry;
|
||||||
|
findEntry.ip = clientIP;
|
||||||
|
|
||||||
|
ip_t entry = m_IPTree.Find(findEntry);
|
||||||
|
if (m_IPTree.IsValidIndex(entry))
|
||||||
|
{
|
||||||
|
m_IPTree[entry].count++; // a new hit
|
||||||
|
|
||||||
|
if ((curTime - m_IPTree[entry].lastTime) > max_queries_window.value)
|
||||||
|
{
|
||||||
|
m_IPTree[entry].lastTime = curTime;
|
||||||
|
m_IPTree[entry].count = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float query_rate = static_cast<float>(m_IPTree[entry].count) / max_queries_window.value; // add one so the bottom is never zero
|
||||||
|
if (query_rate > max_queries_sec.value)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// not found, insert this new guy
|
||||||
|
iprate_t newEntry;
|
||||||
|
newEntry.count = 1;
|
||||||
|
newEntry.lastTime = curTime;
|
||||||
|
newEntry.ip = clientIP;
|
||||||
|
m_IPTree.Insert(newEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// now check the global rate
|
||||||
|
m_iGlobalCount++;
|
||||||
|
|
||||||
|
if ((curTime - m_lLastTime) > max_queries_window.value)
|
||||||
|
{
|
||||||
|
m_lLastTime = curTime;
|
||||||
|
m_iGlobalCount = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float query_rate = static_cast<float>(m_iGlobalCount) / max_queries_window.value; // add one so the bottom is never zero
|
||||||
|
if (query_rate > max_queries_sec_global.value)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return false if this IP exceeds rate limits
|
||||||
|
bool SV_CheckConnectionLessRateLimits(netadr_t &adr)
|
||||||
|
{
|
||||||
|
bool ret = rateChecker.CheckIP(adr);
|
||||||
|
if (!ret && sv_logblocks.value)
|
||||||
|
{
|
||||||
|
Log_Printf("Traffic from %s was blocked for exceeding rate limits\n", NET_AdrToString(adr));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -35,9 +35,10 @@
|
|||||||
class CIPRateLimit
|
class CIPRateLimit
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CIPRateLimit() {}
|
CIPRateLimit();
|
||||||
~CIPRateLimit() {}
|
~CIPRateLimit();
|
||||||
|
|
||||||
|
// updates an ip entry, return true if the ip is allowed, false otherwise
|
||||||
bool CheckIP(netadr_t adr);
|
bool CheckIP(netadr_t adr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -48,21 +49,25 @@ private:
|
|||||||
FLUSH_TIMEOUT = 120,
|
FLUSH_TIMEOUT = 120,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct iprate_s
|
using ip_t = int;
|
||||||
|
struct iprate_t
|
||||||
{
|
{
|
||||||
typedef int ip_t;
|
|
||||||
ip_t ip;
|
ip_t ip;
|
||||||
|
|
||||||
long lastTime;
|
long lastTime;
|
||||||
int count;
|
int count;
|
||||||
} iprate_t;
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class CUtlRBTree<CIPRateLimit::iprate_s, int> m_IPTree;
|
CUtlRBTree<iprate_t, int> m_IPTree;
|
||||||
int m_iGlobalCount;
|
int m_iGlobalCount;
|
||||||
long m_lLastTime;
|
long m_lLastTime;
|
||||||
|
|
||||||
bool LessIP(const struct iprate_s &, const struct iprate_s &);
|
static bool LessIP(const iprate_t &lhs, const iprate_t &rhs);
|
||||||
};
|
};
|
||||||
|
|
||||||
//extern bool (__fastcall *pCIPRateLimit__CheckIP)(CIPRateLimit *obj, int none, netadr_t adr);
|
extern cvar_t max_queries_sec;
|
||||||
|
extern cvar_t max_queries_sec_global;
|
||||||
|
extern cvar_t max_queries_window;
|
||||||
|
extern cvar_t sv_logblocks;
|
||||||
|
|
||||||
|
bool SV_CheckConnectionLessRateLimits(netadr_t &adr);
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation; either version 2 of the License, or (at
|
|
||||||
* your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* In addition, as a special exception, the author gives permission to
|
|
||||||
* link the code of this program with the Half-Life Game Engine ("HL
|
|
||||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
|
||||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
|
||||||
* respects for all of the code used other than the HL Engine and MODs
|
|
||||||
* from Valve. If you modify this file, you may extend this exception
|
|
||||||
* to your version of the file, but you are not obligated to do so. If
|
|
||||||
* you do not wish to do so, delete this exception statement from your
|
|
||||||
* version.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "precompiled.h"
|
|
||||||
|
|
||||||
class CIPRateLimit rateChecker;
|
|
||||||
|
|
||||||
int CheckIP(netadr_t adr)
|
|
||||||
{
|
|
||||||
CRehldsPlatformHolder::get()->time(NULL); // time() is called inside IpRateLimiter
|
|
||||||
return 1;
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation; either version 2 of the License, or (at
|
|
||||||
* your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* In addition, as a special exception, the author gives permission to
|
|
||||||
* link the code of this program with the Half-Life Game Engine ("HL
|
|
||||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
|
||||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
|
||||||
* respects for all of the code used other than the HL Engine and MODs
|
|
||||||
* from Valve. If you modify this file, you may extend this exception
|
|
||||||
* to your version of the file, but you are not obligated to do so. If
|
|
||||||
* you do not wish to do so, delete this exception statement from your
|
|
||||||
* version.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "maintypes.h"
|
|
||||||
#include "net.h"
|
|
||||||
#include "ipratelimit.h"
|
|
||||||
|
|
||||||
extern class CIPRateLimit rateChecker;
|
|
||||||
|
|
||||||
int CheckIP(netadr_t adr);
|
|
@ -362,10 +362,6 @@ extern cvar_t sv_allow_upload;
|
|||||||
extern cvar_t sv_max_upload;
|
extern cvar_t sv_max_upload;
|
||||||
extern cvar_t hpk_maxsize;
|
extern cvar_t hpk_maxsize;
|
||||||
extern cvar_t sv_visiblemaxplayers;
|
extern cvar_t sv_visiblemaxplayers;
|
||||||
extern cvar_t max_queries_sec;
|
|
||||||
extern cvar_t max_queries_sec_global;
|
|
||||||
extern cvar_t max_queries_window;
|
|
||||||
extern cvar_t sv_logblocks;
|
|
||||||
extern cvar_t sv_downloadurl;
|
extern cvar_t sv_downloadurl;
|
||||||
extern cvar_t sv_allow_dlfile;
|
extern cvar_t sv_allow_dlfile;
|
||||||
extern cvar_t sv_version;
|
extern cvar_t sv_version;
|
||||||
@ -535,8 +531,6 @@ void SV_ProcessFile(client_t *cl, char *filename);
|
|||||||
qboolean SV_FilterPacket(void);
|
qboolean SV_FilterPacket(void);
|
||||||
void SV_SendBan(void);
|
void SV_SendBan(void);
|
||||||
void SV_ReadPackets(void);
|
void SV_ReadPackets(void);
|
||||||
//NOBODY int ntohl(void);
|
|
||||||
//NOBODY int htons(void);
|
|
||||||
void SV_CheckTimeouts(void);
|
void SV_CheckTimeouts(void);
|
||||||
int SV_CalcPing(client_t *cl);
|
int SV_CalcPing(client_t *cl);
|
||||||
void SV_SendFullClientUpdateForAll(client_t *client);
|
void SV_SendFullClientUpdateForAll(client_t *client);
|
||||||
|
@ -174,10 +174,6 @@ cvar_t sv_max_upload = { "sv_uploadmax", "0.5", FCVAR_SERVER, 0.0f, NULL };
|
|||||||
cvar_t hpk_maxsize = { "hpk_maxsize", "4", FCVAR_ARCHIVE, 0.0f, NULL };
|
cvar_t hpk_maxsize = { "hpk_maxsize", "4", FCVAR_ARCHIVE, 0.0f, NULL };
|
||||||
cvar_t sv_visiblemaxplayers = { "sv_visiblemaxplayers", "-1", 0, 0.0f, NULL };
|
cvar_t sv_visiblemaxplayers = { "sv_visiblemaxplayers", "-1", 0, 0.0f, NULL };
|
||||||
|
|
||||||
cvar_t max_queries_sec = { "max_queries_sec", "3.0", FCVAR_SERVER | FCVAR_PROTECTED, 0.0f, NULL };
|
|
||||||
cvar_t max_queries_sec_global = { "max_queries_sec_global", "30", FCVAR_SERVER | FCVAR_PROTECTED, 0.0f, NULL };
|
|
||||||
cvar_t max_queries_window = { "max_queries_window", "60", FCVAR_SERVER | FCVAR_PROTECTED, 0.0f, NULL };
|
|
||||||
cvar_t sv_logblocks = { "sv_logblocks", "0", FCVAR_SERVER, 0.0f, NULL };
|
|
||||||
cvar_t sv_downloadurl = { "sv_downloadurl", "", FCVAR_PROTECTED, 0.0f, NULL };
|
cvar_t sv_downloadurl = { "sv_downloadurl", "", FCVAR_PROTECTED, 0.0f, NULL };
|
||||||
cvar_t sv_allow_dlfile = { "sv_allow_dlfile", "1", 0, 0.0f, NULL };
|
cvar_t sv_allow_dlfile = { "sv_allow_dlfile", "1", 0, 0.0f, NULL };
|
||||||
#ifdef REHLDS_FIXES
|
#ifdef REHLDS_FIXES
|
||||||
@ -3571,15 +3567,12 @@ void SV_ReadPackets(void)
|
|||||||
if (*(uint32 *)net_message.data == 0xFFFFFFFF)
|
if (*(uint32 *)net_message.data == 0xFFFFFFFF)
|
||||||
{
|
{
|
||||||
// Connectionless packet
|
// Connectionless packet
|
||||||
if (CheckIP(net_from))
|
if (SV_CheckConnectionLessRateLimits(net_from))
|
||||||
{
|
{
|
||||||
Steam_HandleIncomingPacket(net_message.data, net_message.cursize, ntohl(*(u_long *)&net_from.ip[0]), htons(net_from.port));
|
Steam_HandleIncomingPacket(net_message.data, net_message.cursize, ntohl(*(u_long *)&net_from.ip[0]), htons(net_from.port));
|
||||||
SV_ConnectionlessPacket();
|
SV_ConnectionlessPacket();
|
||||||
}
|
}
|
||||||
else if (sv_logblocks.value != 0.0f)
|
|
||||||
{
|
|
||||||
Log_Printf("Traffic from %s was blocked for exceeding rate limits\n", NET_AdrToString(net_from));
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +172,6 @@ void CSteam3Server::OnGSClientApprove(GSClientApprove_t *pGSClientSteam2Accept)
|
|||||||
if (!cl)
|
if (!cl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
if (SV_FilterUser(&cl->network_userid))
|
if (SV_FilterUser(&cl->network_userid))
|
||||||
{
|
{
|
||||||
char msg[256];
|
char msg[256];
|
||||||
@ -519,7 +518,6 @@ void CSteam3Server::SendUpdatedServerDetails()
|
|||||||
CRehldsPlatformHolder::get()->SteamGameServer()->SetMapName(g_psv.name);
|
CRehldsPlatformHolder::get()->SteamGameServer()->SetMapName(g_psv.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSteam3Client::Shutdown()
|
void CSteam3Client::Shutdown()
|
||||||
{
|
{
|
||||||
if (m_bLoggedOn)
|
if (m_bLoggedOn)
|
||||||
|
@ -50,7 +50,7 @@ protected:
|
|||||||
virtual ~CSteam3() {}
|
virtual ~CSteam3() {}
|
||||||
virtual void Shutdown() = 0;
|
virtual void Shutdown() = 0;
|
||||||
|
|
||||||
void GSSendUserStatusResponse(CSteamID &, int, int);
|
void GSSendUserStatusResponse(CSteamID &steamID, int nSecondsConnected, int nSecondsSinceLast);
|
||||||
bool InitModule();
|
bool InitModule();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,11 +75,11 @@ public:
|
|||||||
|
|
||||||
NOBODY void SetServerType();
|
NOBODY void SetServerType();
|
||||||
NOBODY void SetSpawnCount(int count);
|
NOBODY void SetSpawnCount(int count);
|
||||||
NOBODY bool BSecure();
|
|
||||||
NOBODY bool BLanOnly();
|
|
||||||
|
|
||||||
bool BWantsSecure() { return m_bWantToBeSecure; }
|
bool BSecure() const { return m_bWantToBeSecure; }
|
||||||
bool BLoggedOn() { return m_bLoggedOn; }
|
bool BLanOnly() const { return m_bLanOnly; };
|
||||||
|
bool BWantsSecure() const { return m_bWantToBeSecure; }
|
||||||
|
bool BLoggedOn() const { return m_bLoggedOn; }
|
||||||
|
|
||||||
uint64 GetSteamID();
|
uint64 GetSteamID();
|
||||||
|
|
||||||
|
@ -28,22 +28,15 @@
|
|||||||
|
|
||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
|
|
||||||
#ifndef Z_Functions_region
|
// ZONE MEMORY ALLOCATION
|
||||||
|
//
|
||||||
/*
|
// There is never any space between memblocks, and there will never be two
|
||||||
==============================================================================
|
// contiguous free memblocks.
|
||||||
|
//
|
||||||
ZONE MEMORY ALLOCATION
|
// The rover can be left pointing at a non-empty block
|
||||||
|
//
|
||||||
There is never any space between memblocks, and there will never be two
|
// The zone calls are pretty much only used for small strings and structures,
|
||||||
contiguous free memblocks.
|
// all big things are allocated on the hunk.
|
||||||
|
|
||||||
The rover can be left pointing at a non-empty block
|
|
||||||
|
|
||||||
The zone calls are pretty much only used for small strings and structures,
|
|
||||||
all big things are allocated on the hunk.
|
|
||||||
==============================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define ZONEID 0x001d4a11
|
#define ZONEID 0x001d4a11
|
||||||
const int MINFRAGMENT = 64;
|
const int MINFRAGMENT = 64;
|
||||||
@ -242,7 +235,7 @@ NOXREF void Z_Print(memzone_t *zone)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Z_CheckHeap(void)
|
void Z_CheckHeap()
|
||||||
{
|
{
|
||||||
memblock_t *block;
|
memblock_t *block;
|
||||||
|
|
||||||
@ -270,10 +263,6 @@ void Z_CheckHeap(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // Z_Functions_region
|
|
||||||
|
|
||||||
#ifndef Hunk_Functions_region
|
|
||||||
|
|
||||||
const int HUNK_NAME_LEN = 64;
|
const int HUNK_NAME_LEN = 64;
|
||||||
#define HUNK_SENTINEL 0x1df001ed
|
#define HUNK_SENTINEL 0x1df001ed
|
||||||
|
|
||||||
@ -293,15 +282,8 @@ int hunk_high_used;
|
|||||||
qboolean hunk_tempactive;
|
qboolean hunk_tempactive;
|
||||||
int hunk_tempmark;
|
int hunk_tempmark;
|
||||||
|
|
||||||
/*
|
// Run consistency and sentinel trashing checks
|
||||||
==============
|
void Hunk_Check()
|
||||||
Hunk_Check
|
|
||||||
|
|
||||||
Run consistency and sentinel trashing checks
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
|
|
||||||
void Hunk_Check(void)
|
|
||||||
{
|
{
|
||||||
hunk_t *h;
|
hunk_t *h;
|
||||||
|
|
||||||
@ -319,15 +301,8 @@ void Hunk_Check(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// If "all" is specified, every single allocation is printed.
|
||||||
==============
|
// Otherwise, allocations with the same name will be totaled up before printing.
|
||||||
Hunk_Print
|
|
||||||
|
|
||||||
If "all" is specified, every single allocation is printed.
|
|
||||||
Otherwise, allocations with the same name will be totaled up before printing.
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
|
|
||||||
NOXREF void Hunk_Print(qboolean all)
|
NOXREF void Hunk_Print(qboolean all)
|
||||||
{
|
{
|
||||||
NOXREFCHECK;
|
NOXREFCHECK;
|
||||||
@ -352,9 +327,7 @@ NOXREF void Hunk_Print(qboolean all)
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
// skip to the high hunk if done with low hunk
|
// skip to the high hunk if done with low hunk
|
||||||
//
|
|
||||||
if (h == endlow)
|
if (h == endlow)
|
||||||
{
|
{
|
||||||
Con_Printf("-------------------------\n");
|
Con_Printf("-------------------------\n");
|
||||||
@ -363,15 +336,11 @@ NOXREF void Hunk_Print(qboolean all)
|
|||||||
h = starthigh;
|
h = starthigh;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// if totally done, break
|
// if totally done, break
|
||||||
//
|
|
||||||
if (h == endhigh)
|
if (h == endhigh)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//
|
|
||||||
// run consistancy checks
|
// run consistancy checks
|
||||||
//
|
|
||||||
if (h->sentinel != HUNK_SENTINEL)
|
if (h->sentinel != HUNK_SENTINEL)
|
||||||
Sys_Error("%s: trahsed sentinal", __func__);
|
Sys_Error("%s: trahsed sentinal", __func__);
|
||||||
if (h->size < 16 || h->size + (byte *)h - hunk_base > hunk_size)
|
if (h->size < 16 || h->size + (byte *)h - hunk_base > hunk_size)
|
||||||
@ -382,16 +351,12 @@ NOXREF void Hunk_Print(qboolean all)
|
|||||||
totalblocks++;
|
totalblocks++;
|
||||||
sum += h->size;
|
sum += h->size;
|
||||||
|
|
||||||
//
|
|
||||||
// print the single block
|
// print the single block
|
||||||
//
|
|
||||||
Q_memcpy(name, h->name, HUNK_NAME_LEN);
|
Q_memcpy(name, h->name, HUNK_NAME_LEN);
|
||||||
if (all)
|
if (all)
|
||||||
Con_Printf("%8p :%8i %8s\n", h, h->size, name);
|
Con_Printf("%8p :%8i %8s\n", h, h->size, name);
|
||||||
|
|
||||||
//
|
|
||||||
// print the total
|
// print the total
|
||||||
//
|
|
||||||
if (next == endlow || next == endhigh ||
|
if (next == endlow || next == endhigh ||
|
||||||
Q_strncmp(h->name, next->name, HUNK_NAME_LEN))
|
Q_strncmp(h->name, next->name, HUNK_NAME_LEN))
|
||||||
{
|
{
|
||||||
@ -408,12 +373,6 @@ NOXREF void Hunk_Print(qboolean all)
|
|||||||
Con_Printf("%8i total blocks\n", totalblocks);
|
Con_Printf("%8i total blocks\n", totalblocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
===================
|
|
||||||
Hunk_AllocName
|
|
||||||
===================
|
|
||||||
*/
|
|
||||||
|
|
||||||
void *Hunk_AllocName(int size, const char *name)
|
void *Hunk_AllocName(int size, const char *name)
|
||||||
{
|
{
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
@ -447,7 +406,7 @@ void *Hunk_Alloc(int size)
|
|||||||
return Hunk_AllocName(size, "unknown");
|
return Hunk_AllocName(size, "unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
int Hunk_LowMark(void)
|
int Hunk_LowMark()
|
||||||
{
|
{
|
||||||
return hunk_low_used;
|
return hunk_low_used;
|
||||||
}
|
}
|
||||||
@ -462,7 +421,7 @@ void Hunk_FreeToLowMark(int mark)
|
|||||||
hunk_low_used = mark;
|
hunk_low_used = mark;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Hunk_HighMark(void)
|
int Hunk_HighMark()
|
||||||
{
|
{
|
||||||
if (hunk_tempactive)
|
if (hunk_tempactive)
|
||||||
{
|
{
|
||||||
@ -489,12 +448,6 @@ void Hunk_FreeToHighMark(int mark)
|
|||||||
hunk_high_used = mark;
|
hunk_high_used = mark;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
===================
|
|
||||||
Hunk_HighAllocName
|
|
||||||
===================
|
|
||||||
*/
|
|
||||||
|
|
||||||
void *Hunk_HighAllocName(int size, const char *name)
|
void *Hunk_HighAllocName(int size, const char *name)
|
||||||
{
|
{
|
||||||
hunk_t *h;
|
hunk_t *h;
|
||||||
@ -528,17 +481,10 @@ void *Hunk_HighAllocName(int size, const char *name)
|
|||||||
Q_strncpy(h->name, name, HUNK_NAME_LEN - 1);
|
Q_strncpy(h->name, name, HUNK_NAME_LEN - 1);
|
||||||
h->name[HUNK_NAME_LEN - 1] = 0;
|
h->name[HUNK_NAME_LEN - 1] = 0;
|
||||||
|
|
||||||
return (void*)(h + 1);
|
return (void *)(h + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Return space from the top of the hunk
|
||||||
=================
|
|
||||||
Hunk_TempAlloc
|
|
||||||
|
|
||||||
Return space from the top of the hunk
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
|
|
||||||
void *Hunk_TempAlloc(int size)
|
void *Hunk_TempAlloc(int size)
|
||||||
{
|
{
|
||||||
void *buf;
|
void *buf;
|
||||||
@ -556,18 +502,7 @@ void *Hunk_TempAlloc(int size)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // Hunk_Functions_region
|
// CACHE MEMORY
|
||||||
|
|
||||||
#ifndef Cache_Functions_region
|
|
||||||
|
|
||||||
/*
|
|
||||||
===============================================================================
|
|
||||||
|
|
||||||
CACHE MEMORY
|
|
||||||
|
|
||||||
===============================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
const int CACHE_NAME_LEN = 64;
|
const int CACHE_NAME_LEN = 64;
|
||||||
|
|
||||||
typedef struct cache_system_s
|
typedef struct cache_system_s
|
||||||
@ -583,12 +518,6 @@ typedef struct cache_system_s
|
|||||||
|
|
||||||
cache_system_t cache_head;
|
cache_system_t cache_head;
|
||||||
|
|
||||||
/*
|
|
||||||
===========
|
|
||||||
Cache_Move
|
|
||||||
===========
|
|
||||||
*/
|
|
||||||
|
|
||||||
void Cache_Move(cache_system_t *c)
|
void Cache_Move(cache_system_t *c)
|
||||||
{
|
{
|
||||||
cache_system_t *newmem = Cache_TryAlloc(c->size, 1);
|
cache_system_t *newmem = Cache_TryAlloc(c->size, 1);
|
||||||
@ -607,14 +536,7 @@ void Cache_Move(cache_system_t *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Throw things out until the hunk can be expanded to the given point
|
||||||
============
|
|
||||||
Cache_FreeLow
|
|
||||||
|
|
||||||
Throw things out until the hunk can be expanded to the given point
|
|
||||||
============
|
|
||||||
*/
|
|
||||||
|
|
||||||
void Cache_FreeLow(int new_low_hunk)
|
void Cache_FreeLow(int new_low_hunk)
|
||||||
{
|
{
|
||||||
cache_system_t *c;
|
cache_system_t *c;
|
||||||
@ -630,14 +552,7 @@ void Cache_FreeLow(int new_low_hunk)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Throw things out until the hunk can be expanded to the given point
|
||||||
============
|
|
||||||
Cache_FreeHigh
|
|
||||||
|
|
||||||
Throw things out until the hunk can be expanded to the given point
|
|
||||||
============
|
|
||||||
*/
|
|
||||||
|
|
||||||
void Cache_FreeHigh(int new_high_hunk)
|
void Cache_FreeHigh(int new_high_hunk)
|
||||||
{
|
{
|
||||||
cache_system_t *c, *prev;
|
cache_system_t *c, *prev;
|
||||||
@ -685,15 +600,8 @@ void Cache_MakeLRU(cache_system_t *cs)
|
|||||||
cache_head.lru_next = cs;
|
cache_head.lru_next = cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Looks for a free block of memory between the high and low hunk marks
|
||||||
============
|
// Size should already include the header and padding
|
||||||
Cache_TryAlloc
|
|
||||||
|
|
||||||
Looks for a free block of memory between the high and low hunk marks
|
|
||||||
Size should already include the header and padding
|
|
||||||
============
|
|
||||||
*/
|
|
||||||
|
|
||||||
cache_system_t *Cache_TryAlloc(int size, qboolean nobottom)
|
cache_system_t *Cache_TryAlloc(int size, qboolean nobottom)
|
||||||
{
|
{
|
||||||
cache_system_t *cs;
|
cache_system_t *cs;
|
||||||
@ -758,15 +666,8 @@ cache_system_t *Cache_TryAlloc(int size, qboolean nobottom)
|
|||||||
return newmem;
|
return newmem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Throw everything out, so new data will be demand cached
|
||||||
============
|
void Cache_Force_Flush()
|
||||||
Cache_Flush
|
|
||||||
|
|
||||||
Throw everything out, so new data will be demand cached
|
|
||||||
============
|
|
||||||
*/
|
|
||||||
|
|
||||||
void Cache_Force_Flush(void)
|
|
||||||
{
|
{
|
||||||
cache_system_t *i;
|
cache_system_t *i;
|
||||||
|
|
||||||
@ -776,7 +677,7 @@ void Cache_Force_Flush(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cache_Flush(void)
|
void Cache_Flush()
|
||||||
{
|
{
|
||||||
if (g_pcl.maxclients <= 1 || allow_cheats)
|
if (g_pcl.maxclients <= 1 || allow_cheats)
|
||||||
{
|
{
|
||||||
@ -788,15 +689,8 @@ void Cache_Flush(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Compares the names of two cache_system_t structs.
|
||||||
============
|
// Used with qsort()
|
||||||
CacheSystemCompare
|
|
||||||
|
|
||||||
Compares the names of two cache_system_t structs.
|
|
||||||
Used with qsort()
|
|
||||||
============
|
|
||||||
*/
|
|
||||||
|
|
||||||
NOXREF int CacheSystemCompare(const void *ppcs1, const void *ppcs2)
|
NOXREF int CacheSystemCompare(const void *ppcs1, const void *ppcs2)
|
||||||
{
|
{
|
||||||
NOXREFCHECK;
|
NOXREFCHECK;
|
||||||
@ -807,14 +701,7 @@ NOXREF int CacheSystemCompare(const void *ppcs1, const void *ppcs2)
|
|||||||
return Q_stricmp(pcs1->name, pcs2->name);
|
return Q_stricmp(pcs1->name, pcs2->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
NOXREF void Cache_Print()
|
||||||
============
|
|
||||||
Cache_Print
|
|
||||||
|
|
||||||
============
|
|
||||||
*/
|
|
||||||
|
|
||||||
NOXREF void Cache_Print(void)
|
|
||||||
{
|
{
|
||||||
NOXREFCHECK;
|
NOXREFCHECK;
|
||||||
|
|
||||||
@ -826,15 +713,8 @@ NOXREF void Cache_Print(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// compares the first directory of two paths...
|
||||||
============
|
// (so "foo/bar" will match "foo/fred"
|
||||||
ComparePath1
|
|
||||||
|
|
||||||
compares the first directory of two paths...
|
|
||||||
(so "foo/bar" will match "foo/fred"
|
|
||||||
============
|
|
||||||
*/
|
|
||||||
|
|
||||||
NOXREF int ComparePath1(char *path1, char *path2)
|
NOXREF int ComparePath1(char *path1, char *path2)
|
||||||
{
|
{
|
||||||
NOXREFCHECK;
|
NOXREFCHECK;
|
||||||
@ -851,19 +731,12 @@ NOXREF int ComparePath1(char *path1, char *path2)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Takes a number, and creates a string of that with commas in the appropriate places.
|
||||||
============
|
|
||||||
CommatizeNumber
|
|
||||||
|
|
||||||
takes a number, and creates a string of that with commas in the
|
|
||||||
appropriate places.
|
|
||||||
============
|
|
||||||
*/
|
|
||||||
|
|
||||||
NOXREF char *CommatizeNumber(int num, char *pout)
|
NOXREF char *CommatizeNumber(int num, char *pout)
|
||||||
{
|
{
|
||||||
NOXREFCHECK;
|
NOXREFCHECK;
|
||||||
//this is probably more complex than it needs to be.
|
|
||||||
|
// this is probably more complex than it needs to be.
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int i;
|
int i;
|
||||||
char outbuf[50];
|
char outbuf[50];
|
||||||
@ -880,51 +753,30 @@ NOXREF char *CommatizeNumber(int num, char *pout)
|
|||||||
|
|
||||||
len = Q_strlen(outbuf);
|
len = Q_strlen(outbuf);
|
||||||
|
|
||||||
for (i = 0; i < len; i++) //find first significant digit
|
for (i = 0; i < len; i++) // find first significant digit
|
||||||
if (outbuf[i] != '0' && outbuf[i] != ',')
|
if (outbuf[i] != '0' && outbuf[i] != ',')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (i == len)
|
if (i == len)
|
||||||
Q_strcpy(pout, "0");
|
Q_strcpy(pout, "0");
|
||||||
else
|
else
|
||||||
Q_strcpy(pout, &outbuf[i]); //copy from i to get rid of the first comma and leading zeros
|
Q_strcpy(pout, &outbuf[i]); // copy from i to get rid of the first comma and leading zeros
|
||||||
|
|
||||||
return pout;
|
return pout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
NOXREF void Cache_Report()
|
||||||
============
|
|
||||||
Cache_Report
|
|
||||||
|
|
||||||
============
|
|
||||||
*/
|
|
||||||
|
|
||||||
NOXREF void Cache_Report(void)
|
|
||||||
{
|
{
|
||||||
NOXREFCHECK;
|
NOXREFCHECK;
|
||||||
Con_DPrintf("%4.1f megabyte data cache\n", (hunk_size - hunk_low_used - hunk_high_used) / (float)(1024 * 1024));
|
Con_DPrintf("%4.1f megabyte data cache\n", (hunk_size - hunk_low_used - hunk_high_used) / (float)(1024 * 1024));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
NOXREF void Cache_Compact()
|
||||||
============
|
|
||||||
Cache_Compact
|
|
||||||
|
|
||||||
============
|
|
||||||
*/
|
|
||||||
|
|
||||||
NOXREF void Cache_Compact(void)
|
|
||||||
{
|
{
|
||||||
NOXREFCHECK;
|
NOXREFCHECK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void Cache_Init()
|
||||||
============
|
|
||||||
Cache_Init
|
|
||||||
|
|
||||||
============
|
|
||||||
*/
|
|
||||||
|
|
||||||
void Cache_Init(void)
|
|
||||||
{
|
{
|
||||||
cache_head.next = cache_head.prev = &cache_head;
|
cache_head.next = cache_head.prev = &cache_head;
|
||||||
cache_head.lru_next = cache_head.lru_prev = &cache_head;
|
cache_head.lru_next = cache_head.lru_prev = &cache_head;
|
||||||
@ -932,14 +784,7 @@ void Cache_Init(void)
|
|||||||
Cmd_AddCommand("flush", Cache_Flush);
|
Cmd_AddCommand("flush", Cache_Flush);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Frees the memory and removes it from the LRU list
|
||||||
==============
|
|
||||||
Cache_Free
|
|
||||||
|
|
||||||
Frees the memory and removes it from the LRU list
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
|
|
||||||
void Cache_Free(cache_user_t *c)
|
void Cache_Free(cache_user_t *c)
|
||||||
{
|
{
|
||||||
if (!c->data)
|
if (!c->data)
|
||||||
@ -956,7 +801,7 @@ void Cache_Free(cache_user_t *c)
|
|||||||
Cache_UnlinkLRU(cs);
|
Cache_UnlinkLRU(cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
NOXREF int Cache_TotalUsed(void)
|
NOXREF int Cache_TotalUsed()
|
||||||
{
|
{
|
||||||
NOXREFCHECK;
|
NOXREFCHECK;
|
||||||
|
|
||||||
@ -968,12 +813,6 @@ NOXREF int Cache_TotalUsed(void)
|
|||||||
return Total;
|
return Total;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
==============
|
|
||||||
Cache_Check
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
|
|
||||||
void* EXT_FUNC Cache_Check(cache_user_t *c)
|
void* EXT_FUNC Cache_Check(cache_user_t *c)
|
||||||
{
|
{
|
||||||
cache_system_t *cs;
|
cache_system_t *cs;
|
||||||
@ -989,12 +828,6 @@ void* EXT_FUNC Cache_Check(cache_user_t *c)
|
|||||||
return c->data;
|
return c->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
==============
|
|
||||||
Cache_Alloc
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
|
|
||||||
void *Cache_Alloc(cache_user_t *c, int size, char *name)
|
void *Cache_Alloc(cache_user_t *c, int size, char *name)
|
||||||
{
|
{
|
||||||
cache_system_t *cs;
|
cache_system_t *cs;
|
||||||
@ -1034,12 +867,6 @@ void *Cache_Alloc(cache_user_t *c, int size, char *name)
|
|||||||
return Cache_Check(c);
|
return Cache_Check(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
========================
|
|
||||||
Memory_Init
|
|
||||||
========================
|
|
||||||
*/
|
|
||||||
|
|
||||||
void Memory_Init(void *buf, int size)
|
void Memory_Init(void *buf, int size)
|
||||||
{
|
{
|
||||||
int zonesize = ZONE_DYNAMIC_SIZE;
|
int zonesize = ZONE_DYNAMIC_SIZE;
|
||||||
@ -1069,7 +896,7 @@ void Memory_Init(void *buf, int size)
|
|||||||
Z_ClearZone(mainzone, zonesize);
|
Z_ClearZone(mainzone, zonesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
NOXREF void Cache_Print_Models_And_Totals(void)
|
NOXREF void Cache_Print_Models_And_Totals()
|
||||||
{
|
{
|
||||||
NOXREFCHECK;
|
NOXREFCHECK;
|
||||||
char buf[50];
|
char buf[50];
|
||||||
@ -1086,7 +913,7 @@ NOXREF void Cache_Print_Models_And_Totals(void)
|
|||||||
|
|
||||||
Q_memset(sortarray, 0, sizeof(cache_system_t *) * 512);
|
Q_memset(sortarray, 0, sizeof(cache_system_t *) * 512);
|
||||||
|
|
||||||
//pack names into the array.
|
// pack names into the array.
|
||||||
for (cd = cache_head.next; cd != &cache_head; cd = cd->next)
|
for (cd = cache_head.next; cd != &cache_head; cd = cd->next)
|
||||||
{
|
{
|
||||||
if (Q_strstr(cd->name,".mdl"))
|
if (Q_strstr(cd->name,".mdl"))
|
||||||
@ -1096,7 +923,7 @@ NOXREF void Cache_Print_Models_And_Totals(void)
|
|||||||
qsort(sortarray, i, sizeof(cache_system_t *), CacheSystemCompare);
|
qsort(sortarray, i, sizeof(cache_system_t *), CacheSystemCompare);
|
||||||
FS_FPrintf(file, "\nCACHED MODELS:\n");
|
FS_FPrintf(file, "\nCACHED MODELS:\n");
|
||||||
|
|
||||||
//now process the sorted list.
|
// now process the sorted list.
|
||||||
for (j = 0; j < i; j++)
|
for (j = 0; j < i; j++)
|
||||||
{
|
{
|
||||||
FS_FPrintf(file, "\t%16.16s : %s\n", CommatizeNumber(sortarray[j]->size, buf), sortarray[j]->name);
|
FS_FPrintf(file, "\t%16.16s : %s\n", CommatizeNumber(sortarray[j]->size, buf), sortarray[j]->name);
|
||||||
@ -1109,7 +936,7 @@ NOXREF void Cache_Print_Models_And_Totals(void)
|
|||||||
|
|
||||||
const int MAX_SFX = 1024;
|
const int MAX_SFX = 1024;
|
||||||
|
|
||||||
NOXREF void Cache_Print_Sounds_And_Totals(void)
|
NOXREF void Cache_Print_Sounds_And_Totals()
|
||||||
{
|
{
|
||||||
NOXREFCHECK;
|
NOXREFCHECK;
|
||||||
char buf[50];
|
char buf[50];
|
||||||
@ -1127,7 +954,7 @@ NOXREF void Cache_Print_Sounds_And_Totals(void)
|
|||||||
|
|
||||||
Q_memset(sortarray, 0, sizeof(cache_system_t *) * MAX_SFX);
|
Q_memset(sortarray, 0, sizeof(cache_system_t *) * MAX_SFX);
|
||||||
|
|
||||||
//pack names into the array.
|
// pack names into the array.
|
||||||
for (cd = cache_head.next; cd != &cache_head; cd = cd->next)
|
for (cd = cache_head.next; cd != &cache_head; cd = cd->next)
|
||||||
{
|
{
|
||||||
if (Q_strstr(cd->name,".wav"))
|
if (Q_strstr(cd->name,".wav"))
|
||||||
@ -1137,7 +964,7 @@ NOXREF void Cache_Print_Sounds_And_Totals(void)
|
|||||||
qsort(sortarray, i, sizeof(cache_system_t *), CacheSystemCompare);
|
qsort(sortarray, i, sizeof(cache_system_t *), CacheSystemCompare);
|
||||||
FS_FPrintf(file, "\nCACHED SOUNDS:\n");
|
FS_FPrintf(file, "\nCACHED SOUNDS:\n");
|
||||||
|
|
||||||
//now process the sorted list. (totals by directory)
|
// now process the sorted list. (totals by directory)
|
||||||
for (j = 0; j < i; j++)
|
for (j = 0; j < i; j++)
|
||||||
{
|
{
|
||||||
FS_FPrintf(file, "\t%16.16s : %s\n", CommatizeNumber(sortarray[j]->size, buf), sortarray[j]->name);
|
FS_FPrintf(file, "\t%16.16s : %s\n", CommatizeNumber(sortarray[j]->size, buf), sortarray[j]->name);
|
||||||
@ -1154,5 +981,3 @@ NOXREF void Cache_Print_Sounds_And_Totals(void)
|
|||||||
FS_FPrintf(file, "Total bytes in cache used by sound: %s\n", CommatizeNumber(totalsndbytes, buf));
|
FS_FPrintf(file, "Total bytes in cache used by sound: %s\n", CommatizeNumber(totalsndbytes, buf));
|
||||||
FS_Close(file);
|
FS_Close(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // Cache_Functions_region
|
|
||||||
|
@ -53,15 +53,15 @@ void Z_Free(void *ptr);
|
|||||||
void *Z_Malloc(int size);
|
void *Z_Malloc(int size);
|
||||||
void *Z_TagMalloc(int size, int tag);
|
void *Z_TagMalloc(int size, int tag);
|
||||||
NOXREF void Z_Print(memzone_t *zone);
|
NOXREF void Z_Print(memzone_t *zone);
|
||||||
void Z_CheckHeap(void);
|
void Z_CheckHeap();
|
||||||
|
|
||||||
void Hunk_Check(void);
|
void Hunk_Check();
|
||||||
NOXREF void Hunk_Print(qboolean all);
|
NOXREF void Hunk_Print(qboolean all);
|
||||||
void *Hunk_AllocName(int size, const char *name);
|
void *Hunk_AllocName(int size, const char *name);
|
||||||
void *Hunk_Alloc(int size);
|
void *Hunk_Alloc(int size);
|
||||||
int Hunk_LowMark(void);
|
int Hunk_LowMark();
|
||||||
void Hunk_FreeToLowMark(int mark);
|
void Hunk_FreeToLowMark(int mark);
|
||||||
int Hunk_HighMark(void);
|
int Hunk_HighMark();
|
||||||
void Hunk_FreeToHighMark(int mark);
|
void Hunk_FreeToHighMark(int mark);
|
||||||
void *Hunk_HighAllocName(int size, const char *name);
|
void *Hunk_HighAllocName(int size, const char *name);
|
||||||
void *Hunk_TempAlloc(int size);
|
void *Hunk_TempAlloc(int size);
|
||||||
@ -72,19 +72,19 @@ void Cache_FreeHigh(int new_high_hunk);
|
|||||||
void Cache_UnlinkLRU(cache_system_t *cs);
|
void Cache_UnlinkLRU(cache_system_t *cs);
|
||||||
void Cache_MakeLRU(cache_system_t *cs);
|
void Cache_MakeLRU(cache_system_t *cs);
|
||||||
cache_system_t *Cache_TryAlloc(int size, qboolean nobottom);
|
cache_system_t *Cache_TryAlloc(int size, qboolean nobottom);
|
||||||
void Cache_Force_Flush(void);
|
void Cache_Force_Flush();
|
||||||
void Cache_Flush(void);
|
void Cache_Flush();
|
||||||
NOXREF int CacheSystemCompare(const void *ppcs1, const void *ppcs2);
|
NOXREF int CacheSystemCompare(const void *ppcs1, const void *ppcs2);
|
||||||
NOXREF void Cache_Print(void);
|
NOXREF void Cache_Print();
|
||||||
NOXREF int ComparePath1(char *path1, char *path2);
|
NOXREF int ComparePath1(char *path1, char *path2);
|
||||||
NOXREF char *CommatizeNumber(int num, char *pout);
|
NOXREF char *CommatizeNumber(int num, char *pout);
|
||||||
NOXREF void Cache_Report(void);
|
NOXREF void Cache_Report();
|
||||||
NOXREF void Cache_Compact(void);
|
NOXREF void Cache_Compact();
|
||||||
void Cache_Init(void);
|
void Cache_Init();
|
||||||
void Cache_Free(cache_user_t *c);
|
void Cache_Free(cache_user_t *c);
|
||||||
NOXREF int Cache_TotalUsed(void);
|
NOXREF int Cache_TotalUsed();
|
||||||
void *Cache_Check(cache_user_t *c);
|
void *Cache_Check(cache_user_t *c);
|
||||||
void *Cache_Alloc(cache_user_t *c, int size, char *name);
|
void *Cache_Alloc(cache_user_t *c, int size, char *name);
|
||||||
void Memory_Init(void *buf, int size);
|
void Memory_Init(void *buf, int size);
|
||||||
NOXREF NOBODY void Cache_Print_Models_And_Totals(void);
|
NOXREF void Cache_Print_Models_And_Totals();
|
||||||
NOXREF NOBODY void Cache_Print_Sounds_And_Totals(void);
|
NOXREF void Cache_Print_Sounds_And_Totals();
|
||||||
|
@ -49,7 +49,6 @@
|
|||||||
<ClCompile Include="..\engine\host_cmd.cpp" />
|
<ClCompile Include="..\engine\host_cmd.cpp" />
|
||||||
<ClCompile Include="..\engine\info.cpp" />
|
<ClCompile Include="..\engine\info.cpp" />
|
||||||
<ClCompile Include="..\engine\ipratelimit.cpp" />
|
<ClCompile Include="..\engine\ipratelimit.cpp" />
|
||||||
<ClCompile Include="..\engine\ipratelimitWrapper.cpp" />
|
|
||||||
<ClCompile Include="..\engine\l_studio.cpp" />
|
<ClCompile Include="..\engine\l_studio.cpp" />
|
||||||
<ClCompile Include="..\engine\mathlib.cpp" />
|
<ClCompile Include="..\engine\mathlib.cpp" />
|
||||||
<ClCompile Include="..\engine\mathlib_sse.cpp" />
|
<ClCompile Include="..\engine\mathlib_sse.cpp" />
|
||||||
@ -316,7 +315,6 @@
|
|||||||
<ClInclude Include="..\engine\info.h" />
|
<ClInclude Include="..\engine\info.h" />
|
||||||
<ClInclude Include="..\engine\inst_baseline.h" />
|
<ClInclude Include="..\engine\inst_baseline.h" />
|
||||||
<ClInclude Include="..\engine\ipratelimit.h" />
|
<ClInclude Include="..\engine\ipratelimit.h" />
|
||||||
<ClInclude Include="..\engine\ipratelimitWrapper.h" />
|
|
||||||
<ClInclude Include="..\engine\keys.h" />
|
<ClInclude Include="..\engine\keys.h" />
|
||||||
<ClInclude Include="..\engine\l_studio.h" />
|
<ClInclude Include="..\engine\l_studio.h" />
|
||||||
<ClInclude Include="..\engine\mathlib_e.h" />
|
<ClInclude Include="..\engine\mathlib_e.h" />
|
||||||
|
@ -242,9 +242,6 @@
|
|||||||
<ClCompile Include="..\engine\ipratelimit.cpp">
|
<ClCompile Include="..\engine\ipratelimit.cpp">
|
||||||
<Filter>engine\server</Filter>
|
<Filter>engine\server</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\engine\ipratelimitWrapper.cpp">
|
|
||||||
<Filter>engine\server</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\engine\decals.cpp">
|
<ClCompile Include="..\engine\decals.cpp">
|
||||||
<Filter>engine\common</Filter>
|
<Filter>engine\common</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -784,9 +781,6 @@
|
|||||||
<ClInclude Include="..\engine\ipratelimit.h">
|
<ClInclude Include="..\engine\ipratelimit.h">
|
||||||
<Filter>engine\server</Filter>
|
<Filter>engine\server</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\engine\ipratelimitWrapper.h">
|
|
||||||
<Filter>engine\server</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\public\savegame_version.h">
|
<ClInclude Include="..\public\savegame_version.h">
|
||||||
<Filter>public</Filter>
|
<Filter>public</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -78,7 +78,6 @@
|
|||||||
#include "com_custom.h"
|
#include "com_custom.h"
|
||||||
#include "hashpak.h"
|
#include "hashpak.h"
|
||||||
#include "ipratelimit.h"
|
#include "ipratelimit.h"
|
||||||
#include "ipratelimitWrapper.h"
|
|
||||||
#include "savegame_version.h"
|
#include "savegame_version.h"
|
||||||
#include "sys_linuxwnd.h"
|
#include "sys_linuxwnd.h"
|
||||||
#include "SystemWrapper.h"
|
#include "SystemWrapper.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user