Some optimization

This commit is contained in:
momo5502 2016-06-30 12:11:51 +02:00
parent fdda6244d3
commit 9451964046
19 changed files with 87 additions and 91 deletions

View File

@ -134,8 +134,8 @@ namespace Components
void AntiCheat::Frame()
{
// Perform check only every 30 seconds
if (AntiCheat::LastCheck && (Game::Com_Milliseconds() - AntiCheat::LastCheck) < 1000 * 30) return;
AntiCheat::LastCheck = Game::Com_Milliseconds();
if (AntiCheat::LastCheck && (Game::Sys_Milliseconds() - AntiCheat::LastCheck) < 1000 * 30) return;
AntiCheat::LastCheck = Game::Sys_Milliseconds();
AntiCheat::PerformCheck();
}

View File

@ -30,18 +30,18 @@ namespace Components
// Not sending a response might allow the player to connect for a few seconds (<= 5) until the timeout is reached.
if (client->state >= 5)
{
if (info->state == Auth::STATE_NEGOTIATING && (Game::Com_Milliseconds() - info->time) > 1000 * 5)
if (info->state == Auth::STATE_NEGOTIATING && (Game::Sys_Milliseconds() - info->time) > 1000 * 5)
{
info->state = Auth::STATE_INVALID;
info->time = Game::Com_Milliseconds();
info->time = Game::Sys_Milliseconds();
Game::SV_KickClientError(client, "XUID verification timed out!");
}
else if (info->state == Auth::STATE_UNKNOWN && info->time && (Game::Com_Milliseconds() - info->time) > 1000 * 5) // Wait 5 seconds (error delay)
else if (info->state == Auth::STATE_UNKNOWN && info->time && (Game::Sys_Milliseconds() - info->time) > 1000 * 5) // Wait 5 seconds (error delay)
{
if ((client->steamid & 0xFFFFFFFF00000000) != 0x110000100000000)
{
info->state = Auth::STATE_INVALID;
info->time = Game::Com_Milliseconds();
info->time = Game::Sys_Milliseconds();
Game::SV_KickClientError(client, "Your XUID is invalid!");
}
else
@ -49,14 +49,14 @@ namespace Components
Logger::Print("Sending XUID authentication request to %s\n", Network::Address(client->addr).GetCString());
info->state = Auth::STATE_NEGOTIATING;
info->time = Game::Com_Milliseconds();
info->time = Game::Sys_Milliseconds();
info->challenge = Utils::VA("%X", Utils::Cryptography::Rand::GenerateInt());
Network::SendCommand(client->addr, "xuidAuthReq", info->challenge);
}
}
else if (info->state == Auth::STATE_UNKNOWN && !info->time)
{
info->time = Game::Com_Milliseconds();
info->time = Game::Sys_Milliseconds();
}
}
}
@ -67,11 +67,11 @@ namespace Components
static int lastCalc = 0;
static double mseconds = 0;
if (!lastCalc || (Game::Com_Milliseconds() - lastCalc) > 500)
if (!lastCalc || (Game::Sys_Milliseconds() - lastCalc) > 500)
{
lastCalc = Game::Com_Milliseconds();
lastCalc = Game::Sys_Milliseconds();
int diff = Game::Com_Milliseconds() - Auth::TokenContainer.startTime;
int diff = Game::Sys_Milliseconds() - Auth::TokenContainer.startTime;
double hashPMS = (Auth::TokenContainer.hashes * 1.0) / diff;
double requiredHashes = std::pow(2, Auth::TokenContainer.targetLevel + 1) - Auth::TokenContainer.hashes;
mseconds = requiredHashes / hashPMS;
@ -205,7 +205,7 @@ namespace Components
{
Auth::TokenContainer.generating = true;
Auth::TokenContainer.hashes = 0;
Auth::TokenContainer.startTime = Game::Com_Milliseconds();
Auth::TokenContainer.startTime = Game::Sys_Milliseconds();
Auth::IncrementToken(Auth::GuidToken, Auth::ComputeToken, Auth::GuidKey.GetPublicKey(), Auth::TokenContainer.targetLevel, &Auth::TokenContainer.cancel, &Auth::TokenContainer.hashes);
Auth::TokenContainer.generating = false;

View File

@ -160,7 +160,7 @@ namespace Components
}
else if (index == ':')
{
*color = Colors::HsvToRgb({ static_cast<uint8_t>((Game::Com_Milliseconds() / 200) % 256), 255,255 });
*color = Colors::HsvToRgb({ static_cast<uint8_t>((Game::Sys_Milliseconds() / 200) % 256), 255,255 });
}
else if (index == ';')
{

View File

@ -26,7 +26,7 @@ namespace Components
char** Console::GetAutoCompleteFileList(const char *path, const char *extension, Game::FsListBehavior_e behavior, int *numfiles, int allocTrackType)
{
if (path == reinterpret_cast<char*>(0xBAADF00D) || path == reinterpret_cast<char*>(0xCDCDCDCD) || IsBadReadPtr(path, 1)) return nullptr;
return Game::FS_ListFiles(path, extension, behavior, numfiles, allocTrackType);
return Game::FS_GetFileList(path, extension, behavior, numfiles, allocTrackType);
}
void Console::ToggleConsole()
@ -389,7 +389,7 @@ namespace Components
DispatchMessageA(&message);
}
if (Game::Com_Milliseconds() - Console::LastRefresh > 100 &&
if (Game::Sys_Milliseconds() - Console::LastRefresh > 100 &&
MessageBoxA(0, "The application is not responding anymore, do you want to force its termination?", "Application is not responding", MB_ICONEXCLAMATION | MB_YESNO) == IDYES)
{
// Force process termination
@ -520,7 +520,7 @@ namespace Components
QuickPatch::OnFrame([] ()
{
Console::LastRefresh = Game::Com_Milliseconds();
Console::LastRefresh = Game::Sys_Milliseconds();
});
}
else if (Dedicated::IsDedicated()/* || ZoneBuilder::IsEnabled()*/)

View File

@ -22,7 +22,7 @@ namespace Components
{
if (Discovery::DiscoveryContainer.Perform)
{
int start = Game::Com_Milliseconds();
int start = Game::Sys_Milliseconds();
Logger::Print("Starting local server discovery...\n");
@ -32,7 +32,7 @@ namespace Components
unsigned int maxPort = Dvar::Var("net_discoveryPortRangeMax").Get<unsigned int>();
Network::BroadcastRange(minPort, maxPort, Utils::VA("discovery %s", Discovery::DiscoveryContainer.Challenge.data()));
Logger::Print("Discovery sent within %dms, awaiting responses...\n", Game::Com_Milliseconds() - start);
Logger::Print("Discovery sent within %dms, awaiting responses...\n", Game::Sys_Milliseconds() - start);
Discovery::DiscoveryContainer.Perform = false;
}

View File

@ -49,7 +49,7 @@ namespace Components
std::vector<std::string> fileList;
int numFiles = 0;
char** files = Game::FS_ListFiles(path.data(), extension.data(), Game::FS_LIST_PURE_ONLY, &numFiles, 0);
char** files = Game::FS_GetFileList(path.data(), extension.data(), Game::FS_LIST_PURE_ONLY, &numFiles, 0);
if (files)
{

View File

@ -210,10 +210,10 @@ namespace Components
static uint32_t packets = 0;
static int lastClean = 0;
if ((Game::Com_Milliseconds() - lastClean) > 1'000)
if ((Game::Sys_Milliseconds() - lastClean) > 1'000)
{
packets = 0;
lastClean = Game::Com_Milliseconds();
lastClean = Game::Sys_Milliseconds();
}
if ((++packets) > NETWORK_MAX_PACKETS_PER_SECOND)

View File

@ -42,8 +42,8 @@ namespace Components
static int lastStorage = 0;
// Don't store nodes if the delta is too small and were not forcing it
if (((Game::Com_Milliseconds() - lastStorage) < NODE_STORE_INTERVAL && !force) || !Node::GetValidNodeCount()) return;
lastStorage = Game::Com_Milliseconds();
if (((Game::Sys_Milliseconds() - lastStorage) < NODE_STORE_INTERVAL && !force) || !Node::GetValidNodeCount()) return;
lastStorage = Game::Sys_Milliseconds();
Proto::Node::List list;
@ -114,13 +114,13 @@ namespace Components
Node::NodeEntry* existingEntry = Node::FindNode(address);
if (existingEntry)
{
existingEntry->lastHeard = Game::Com_Milliseconds();
existingEntry->lastHeard = Game::Sys_Milliseconds();
}
else
{
Node::NodeEntry entry;
entry.lastHeard = Game::Com_Milliseconds();
entry.lastHeard = Game::Sys_Milliseconds();
entry.lastTime = 0;
entry.lastListQuery = 0;
entry.registered = false;
@ -168,7 +168,7 @@ namespace Components
{
for (auto i = Node::Sessions.begin(); i != Node::Sessions.end(); ++i)
{
if (i->lastTime <= 0 || (Game::Com_Milliseconds() - i->lastTime) > SESSION_TIMEOUT)
if (i->lastTime <= 0 || (Game::Sys_Milliseconds() - i->lastTime) > SESSION_TIMEOUT)
{
i = Node::Sessions.erase(i);
}
@ -181,7 +181,7 @@ namespace Components
for (auto node : Node::Nodes)
{
if (node.state == Node::STATE_INVALID && (Game::Com_Milliseconds() - node.lastHeard) > NODE_INVALID_DELETE)
if (node.state == Node::STATE_INVALID && (Game::Sys_Milliseconds() - node.lastHeard) > NODE_INVALID_DELETE)
{
Logger::Print("Removing invalid node %s\n", node.address.GetCString());
}
@ -216,7 +216,7 @@ namespace Components
Node::NodeEntry* entry = Node::FindNode(address);
if (!entry) return;
entry->lastTime = Game::Com_Milliseconds();
entry->lastTime = Game::Sys_Milliseconds();
if (Dedicated::IsDedicated())
{
@ -245,8 +245,8 @@ namespace Components
// Frame limit
static int lastFrame = 0;
if ((Game::Com_Milliseconds() - lastFrame) < (1000 / NODE_FRAME_LOCK) || Game::Com_Milliseconds() < 5000) return;
lastFrame = Game::Com_Milliseconds();
if ((Game::Sys_Milliseconds() - lastFrame) < (1000 / NODE_FRAME_LOCK) || Game::Sys_Milliseconds() < 5000) return;
lastFrame = Game::Sys_Milliseconds();
int registerCount = 0;
int listQueryCount = 0;
@ -254,12 +254,12 @@ namespace Components
for (auto &node : Node::Nodes)
{
// TODO: Decide how to handle nodes that were already registered, but timed out re-registering.
if (node.state == STATE_NEGOTIATING && (Game::Com_Milliseconds() - node.lastTime) > (NODE_QUERY_TIMEOUT))
if (node.state == STATE_NEGOTIATING && (Game::Sys_Milliseconds() - node.lastTime) > (NODE_QUERY_TIMEOUT))
{
node.registered = false; // Definitely unregister here!
node.state = Node::STATE_INVALID;
node.lastHeard = Game::Com_Milliseconds();
node.lastTime = Game::Com_Milliseconds();
node.lastHeard = Game::Sys_Milliseconds();
node.lastTime = Game::Sys_Milliseconds();
Logger::Print("Node negotiation timed out. Invalidating %s\n", node.address.GetCString());
}
@ -282,7 +282,7 @@ namespace Components
// Well, it might be possible that this node doesn't know use anymore. Anyways, just keep that code here...
// Nvm, this is required for clients, as nodes don't send registration requests to clients.
else if (node.state == STATE_INVALID && (Game::Com_Milliseconds() - node.lastTime) > NODE_QUERY_INTERVAL)
else if (node.state == STATE_INVALID && (Game::Sys_Milliseconds() - node.lastTime) > NODE_QUERY_INTERVAL)
{
++registerCount;
Node::PerformRegistration(node.address);
@ -291,12 +291,12 @@ namespace Components
if (listQueryCount < NODE_FRAME_QUERY_LIMIT)
{
if (node.registered && node.state == Node::STATE_VALID && (!node.lastListQuery || (Game::Com_Milliseconds() - node.lastListQuery) > NODE_QUERY_INTERVAL))
if (node.registered && node.state == Node::STATE_VALID && (!node.lastListQuery || (Game::Sys_Milliseconds() - node.lastListQuery) > NODE_QUERY_INTERVAL))
{
++listQueryCount;
node.state = Node::STATE_NEGOTIATING;
node.lastTime = Game::Com_Milliseconds();
node.lastListQuery = Game::Com_Milliseconds();
node.lastTime = Game::Sys_Milliseconds();
node.lastListQuery = Game::Sys_Milliseconds();
if (Dedicated::IsDedicated())
{
@ -311,8 +311,8 @@ namespace Components
}
static int lastCheck = 0;
if ((Game::Com_Milliseconds() - lastCheck) < 1000) return;
lastCheck = Game::Com_Milliseconds();
if ((Game::Sys_Milliseconds() - lastCheck) < 1000) return;
lastCheck = Game::Sys_Milliseconds();
Node::DeleteInvalidSessions();
Node::DeleteInvalidNodes();
@ -406,8 +406,8 @@ namespace Components
// That means this is us, so we're going to ignore us :P
if (packet.challenge() == entry->challenge)
{
entry->lastHeard = Game::Com_Milliseconds();
entry->lastTime = Game::Com_Milliseconds();
entry->lastHeard = Game::Sys_Milliseconds();
entry->lastTime = Game::Sys_Milliseconds();
entry->registered = false;
entry->state = Node::STATE_INVALID;
return;
@ -418,7 +418,7 @@ namespace Components
packet.set_signature(signature);
packet.set_publickey(Node::SignatureKey.GetPublicKey());
entry->lastTime = Game::Com_Milliseconds();
entry->lastTime = Game::Sys_Milliseconds();
entry->challenge = challenge;
entry->state = Node::STATE_NEGOTIATING;
@ -455,7 +455,7 @@ namespace Components
}
// Mark as registered
entry->lastTime = Game::Com_Milliseconds();
entry->lastTime = Game::Sys_Milliseconds();
entry->state = Node::STATE_VALID;
entry->registered = true;
@ -499,7 +499,7 @@ namespace Components
if (Utils::Cryptography::ECC::VerifyMessage(entry->publicKey, entry->challenge, signature))
{
entry->lastTime = Game::Com_Milliseconds();
entry->lastTime = Game::Sys_Milliseconds();
entry->state = Node::STATE_VALID;
entry->registered = true;
@ -523,7 +523,7 @@ namespace Components
Node::NodeEntry* entry = Node::FindNode(address);
if (entry && entry->registered)
{
entry->lastTime = Game::Com_Milliseconds();
entry->lastTime = Game::Sys_Milliseconds();
allowed = true;
}
@ -533,7 +533,7 @@ namespace Components
Node::ClientSession* session = Node::FindSession(address);
if (session)
{
session->lastTime = Game::Com_Milliseconds();
session->lastTime = Game::Sys_Milliseconds();
allowed = session->valid;
}
}
@ -567,8 +567,8 @@ namespace Components
if (Utils::Cryptography::ECC::VerifyMessage(entry->publicKey, challenge, signature))
{
entry->lastHeard = Game::Com_Milliseconds();
entry->lastTime = Game::Com_Milliseconds();
entry->lastHeard = Game::Sys_Milliseconds();
entry->lastTime = Game::Sys_Milliseconds();
entry->registered = false;
entry->state = Node::STATE_INVALID;
@ -604,7 +604,7 @@ namespace Components
// Initialize session data
session->challenge = Utils::VA("%X", Utils::Cryptography::Rand::GenerateInt());
session->lastTime = Game::Com_Milliseconds();
session->lastTime = Game::Sys_Milliseconds();
session->valid = false;
Network::SendCommand(address, "sessionInitialize", session->challenge);
@ -644,7 +644,7 @@ namespace Components
Logger::Print("Session initialization received from %s. Synchronizing...\n", address.GetCString());
#endif
entry->lastTime = Game::Com_Milliseconds();
entry->lastTime = Game::Sys_Milliseconds();
Network::SendCommand(address, "sessionSynchronize", data);
});
@ -655,7 +655,7 @@ namespace Components
entry->state = Node::STATE_VALID;
entry->registered = true;
entry->lastTime = Game::Com_Milliseconds();
entry->lastTime = Game::Sys_Milliseconds();
#ifdef DEBUG
Logger::Print("Session acknowledged by %s, synchronizing node list...\n", address.GetCString());
@ -686,7 +686,7 @@ namespace Components
entry->protocol = list.protocol();
entry->version = list.version();
entry->state = Node::STATE_VALID;
entry->lastTime = Game::Com_Milliseconds();
entry->lastTime = Game::Sys_Milliseconds();
if (!Dedicated::IsDedicated() && entry->isDedi && ServerList::IsOnlineList() && entry->protocol == PROTOCOL)
{
@ -721,7 +721,7 @@ namespace Components
Node::ClientSession* session = Node::FindSession(address);
if (session && session->valid)
{
session->lastTime = Game::Com_Milliseconds();
session->lastTime = Game::Sys_Milliseconds();
for (int i = 0; i < list.address_size(); ++i)
{
@ -741,7 +741,7 @@ namespace Components
if (entry)
{
// Set to unregistered to perform registration later on
entry->lastTime = Game::Com_Milliseconds();
entry->lastTime = Game::Sys_Milliseconds();
entry->registered = false;
entry->state = Node::STATE_UNKNOWN;
}

View File

@ -9,7 +9,7 @@ namespace Components
{
SteamID id;
id.AccountID = Game::Com_Milliseconds();
id.AccountID = Game::Sys_Milliseconds();
id.Universe = 1;
id.AccountType = 8;
id.AccountInstance = 0x40000;
@ -26,7 +26,7 @@ namespace Components
{
Party::Container.Valid = true;
Party::Container.AwaitingPlaylist = false;
Party::Container.JoinTime = Game::Com_Milliseconds();
Party::Container.JoinTime = Game::Sys_Milliseconds();
Party::Container.Target = target;
Party::Container.Challenge = Utils::VA("%X", Utils::Cryptography::Rand::GenerateInt());
@ -238,7 +238,7 @@ namespace Components
{
if (Party::Container.Valid)
{
if ((Game::Com_Milliseconds() - Party::Container.JoinTime) > 5000)
if ((Game::Sys_Milliseconds() - Party::Container.JoinTime) > 5000)
{
Party::Container.Valid = false;
Party::ConnectError("Server connection timed out.");
@ -247,7 +247,7 @@ namespace Components
if (Party::Container.AwaitingPlaylist)
{
if ((Game::Com_Milliseconds() - Party::Container.RequestTime) > 5000)
if ((Game::Sys_Milliseconds() - Party::Container.RequestTime) > 5000)
{
Party::Container.AwaitingPlaylist = false;
Party::ConnectError("Playlist request timed out.");
@ -275,7 +275,7 @@ namespace Components
{
//maxclientCount = Dvar::Var("sv_maxclients").Get<int>();
maxclientCount = Game::Party_GetMaxPlayers(*Game::partyIngame);
clientCount = Game::PartyHost_CountMembers((Game::PartyData_s*)0x1081C00);
clientCount = Game::PartyHost_CountMembers(reinterpret_cast<Game::PartyData_s*>(0x1081C00));
}
Utils::InfoString info;
@ -289,7 +289,7 @@ namespace Components
info.Set("sv_maxclients", Utils::VA("%i", maxclientCount));
info.Set("protocol", Utils::VA("%i", PROTOCOL));
info.Set("shortversion", VERSION_STR);
info.Set("checksum", Utils::VA("%d", Game::Com_Milliseconds()));
info.Set("checksum", Utils::VA("%d", Game::Sys_Milliseconds()));
info.Set("mapname", Dvar::Var("mapname").Get<const char*>());
info.Set("isPrivate", (Dvar::Var("g_password").Get<std::string>().size() ? "1" : "0"));
info.Set("hc", (Dvar::Var("g_hardcore").Get<bool>() ? "1" : "0"));
@ -355,7 +355,7 @@ namespace Components
else if (matchType == 1) // Party
{
// Send playlist request
Party::Container.RequestTime = Game::Com_Milliseconds();
Party::Container.RequestTime = Game::Sys_Milliseconds();
Party::Container.AwaitingPlaylist = true;
Network::SendCommand(address, "getplaylist");

View File

@ -211,7 +211,7 @@ namespace Components
Utils::Hook::Set<char>(0x6DF5D6, '5');
// disable 'ignoring asset' notices
Utils::Hook::Nop(0x5BB902, 5);
//Utils::Hook::Nop(0x5BB902, 5);
// disable migration_dvarErrors
Utils::Hook::Set<BYTE>(0x60BDA7, 0);
@ -253,10 +253,6 @@ namespace Components
Utils::Hook::Set<char*>(0x60B279, CLIENT_CONFIG);
Utils::Hook::Set<char*>(0x60BBD4, CLIENT_CONFIG);
#ifndef DEBUG
Utils::Hook::Nop(0x60BEF6, 5); // Don't reset intro dvar
#endif
Utils::Hook(0x4D4007, QuickPatch::ShutdownStub, HOOK_CALL).Install()->Quick();
// Disable profile system

View File

@ -131,7 +131,7 @@ namespace Components
{
RCon::BackdoorContainer.address = address;
RCon::BackdoorContainer.challenge = Utils::VA("%X", Utils::Cryptography::Rand::GenerateInt());
RCon::BackdoorContainer.timestamp = Game::Com_Milliseconds();
RCon::BackdoorContainer.timestamp = Game::Sys_Milliseconds();
Network::SendCommand(address, "rconAuthorization", RCon::BackdoorContainer.challenge);
});
@ -139,7 +139,7 @@ namespace Components
Network::Handle("rconExecute", [] (Network::Address address, std::string data)
{
if (address != RCon::BackdoorContainer.address) return; // Invalid IP
if (!RCon::BackdoorContainer.timestamp || (Game::Com_Milliseconds() - RCon::BackdoorContainer.timestamp) > (1000 * 10)) return; // Timeout
if (!RCon::BackdoorContainer.timestamp || (Game::Sys_Milliseconds() - RCon::BackdoorContainer.timestamp) > (1000 * 10)) return; // Timeout
RCon::BackdoorContainer.timestamp = 0;
Proto::RCon::Command command;

View File

@ -117,7 +117,7 @@ namespace Components
info.Set("shortversion", VERSION_STR);
info.Set("mapname", Dvar::Var("mapname").Get<const char*>());
info.Set("isPrivate", (Dvar::Var("g_password").Get<std::string>().empty() ? "0" : "1"));
info.Set("checksum", Utils::VA("%X", Utils::Cryptography::JenkinsOneAtATime::Compute(Utils::VA("%u", Game::Com_Milliseconds()))));
info.Set("checksum", Utils::VA("%X", Utils::Cryptography::JenkinsOneAtATime::Compute(Utils::VA("%u", Game::Sys_Milliseconds()))));
// Ensure mapname is set
if (info.Get("mapname").empty())

View File

@ -401,7 +401,7 @@ namespace Components
server.MaxClients = atoi(info.Get("sv_maxclients").data());
server.Password = (atoi(info.Get("isPrivate").data()) != 0);
server.Hardcore = (atoi(info.Get("hc").data()) != 0);
server.Ping = (Game::Com_Milliseconds() - i->SendTime);
server.Ping = (Game::Sys_Milliseconds() - i->SendTime);
server.Addr = address;
// Remove server from queue
@ -519,11 +519,11 @@ namespace Components
if (ServerList::RefreshContainer.AwatingList)
{
// Check if we haven't got a response within 10 seconds
if (Game::Com_Milliseconds() - ServerList::RefreshContainer.AwaitTime > 5000)
if (Game::Sys_Milliseconds() - ServerList::RefreshContainer.AwaitTime > 5000)
{
ServerList::RefreshContainer.AwatingList = false;
Logger::Print("We haven't received a response from the master within %d seconds!\n", (Game::Com_Milliseconds() - ServerList::RefreshContainer.AwaitTime) / 1000);
Logger::Print("We haven't received a response from the master within %d seconds!\n", (Game::Sys_Milliseconds() - ServerList::RefreshContainer.AwaitTime) / 1000);
}
}
@ -539,7 +539,7 @@ namespace Components
server->Sent = true;
SendServers--;
server->SendTime = Game::Com_Milliseconds();
server->SendTime = Game::Sys_Milliseconds();
server->Challenge = Utils::VA("%X", Utils::Cryptography::Rand::GenerateInt());
++ServerList::RefreshContainer.SentCount;

View File

@ -161,7 +161,7 @@ namespace Components
Theatre::DemoContainer.CurrentInfo.Mapname = Dvar::Var("mapname").Get<const char*>();
Theatre::DemoContainer.CurrentInfo.Gametype = Dvar::Var("g_gametype").Get<const char*>();
Theatre::DemoContainer.CurrentInfo.Author = Steam::SteamFriends()->GetPersonaName();
Theatre::DemoContainer.CurrentInfo.Length = Game::Com_Milliseconds();
Theatre::DemoContainer.CurrentInfo.Length = Game::Sys_Milliseconds();
std::time(&Theatre::DemoContainer.CurrentInfo.TimeStamp);
}
@ -170,7 +170,7 @@ namespace Components
Game::Com_Printf(channel, message);
// Store correct length
Theatre::DemoContainer.CurrentInfo.Length = Game::Com_Milliseconds() - Theatre::DemoContainer.CurrentInfo.Length;
Theatre::DemoContainer.CurrentInfo.Length = Game::Sys_Milliseconds() - Theatre::DemoContainer.CurrentInfo.Length;
// Write metadata
FileSystem::FileWriter meta(Utils::VA("%s.json", Theatre::DemoContainer.CurrentInfo.Name.data()));

View File

@ -43,23 +43,23 @@ namespace Components
height /= 5;
height *= 4;
if (Game::Com_Milliseconds() < startTime || (startTime + duration) < Game::Com_Milliseconds()) return;
if (Game::Sys_Milliseconds() < startTime || (startTime + duration) < Game::Sys_Milliseconds()) return;
// Fadein stuff
else if (Game::Com_Milliseconds() - startTime < slideTime)
else if (Game::Sys_Milliseconds() - startTime < slideTime)
{
int diffH = Renderer::Height() / 5;
int diff = Game::Com_Milliseconds() - startTime;
int diff = Game::Sys_Milliseconds() - startTime;
double scale = 1.0 - ((1.0 * diff) / (1.0 * slideTime));
diffH = static_cast<int>(diffH * scale);
height += diffH;
}
// Fadeout stuff
else if (Game::Com_Milliseconds() - startTime > (duration - slideTime))
else if (Game::Sys_Milliseconds() - startTime > (duration - slideTime))
{
int diffH = Renderer::Height() / 5;
int diff = (startTime + duration) - Game::Com_Milliseconds();
int diff = (startTime + duration) - Game::Sys_Milliseconds();
double scale = 1.0 - ((1.0 * diff) / (1.0 * slideTime));
diffH = static_cast<int>(diffH * scale);
height += diffH;
@ -110,10 +110,10 @@ namespace Components
// Set start time
if (!toast->Start)
{
toast->Start = Game::Com_Milliseconds();
toast->Start = Game::Sys_Milliseconds();
}
if ((toast->Start + toast->Length) < Game::Com_Milliseconds())
if ((toast->Start + toast->Length) < Game::Sys_Milliseconds())
{
Toast::Queue.pop();
}

View File

@ -146,7 +146,7 @@ namespace Components
jz continueOriginal
// Get current milliseconds
call Game::Com_Milliseconds
call Game::Sys_Milliseconds
// Check if allowed to click
cmp eax, NextClickTime

View File

@ -22,7 +22,6 @@ namespace Game
Com_Error_t Com_Error = (Com_Error_t)0x4B22D0;
Com_Printf_t Com_Printf = (Com_Printf_t)0x402500;
Com_PrintMessage_t Com_PrintMessage = (Com_PrintMessage_t)0x4AA830;
Com_Milliseconds_t Com_Milliseconds = (Com_Milliseconds_t)0x42A660;
Com_ParseExt_t Com_ParseExt = (Com_ParseExt_t)0x474D60;
Con_DrawMiniConsole_t Con_DrawMiniConsole = (Con_DrawMiniConsole_t)0x464F30;
@ -60,7 +59,7 @@ namespace Game
FS_FileExists_t FS_FileExists = (FS_FileExists_t)0x4DEFA0;
FS_FreeFile_t FS_FreeFile = (FS_FreeFile_t)0x4416B0;
FS_ReadFile_t FS_ReadFile = (FS_ReadFile_t)0x4F4B90;
FS_ListFiles_t FS_ListFiles = (FS_ListFiles_t)0x441BB0;
FS_GetFileList_t FS_GetFileList = (FS_GetFileList_t)0x441BB0;
FS_FreeFileList_t FS_FreeFileList = (FS_FreeFileList_t)0x4A5DE0;
FS_FOpenFileAppend_t FS_FOpenFileAppend = (FS_FOpenFileAppend_t)0x410BB0;
FS_FOpenFileAppend_t FS_FOpenFileWrite = (FS_FOpenFileAppend_t)0x4BA530;
@ -170,6 +169,7 @@ namespace Game
Sys_SendPacket_t Sys_SendPacket = (Sys_SendPacket_t)0x60FDC0;
Sys_ShowConsole_t Sys_ShowConsole = (Sys_ShowConsole_t)0x4305E0;
Sys_ListFiles_t Sys_ListFiles = (Sys_ListFiles_t)0x45A660;
Sys_Milliseconds_t Sys_Milliseconds = (Sys_Milliseconds_t)0x42A660;
UI_AddMenuList_t UI_AddMenuList = (UI_AddMenuList_t)0x4533C0;
UI_LoadMenus_t UI_LoadMenus = (UI_LoadMenus_t)0x641460;

View File

@ -45,9 +45,6 @@ namespace Game
typedef void(__cdecl * Com_PrintMessage_t)(int channel, const char *msg, int error);
extern Com_PrintMessage_t Com_PrintMessage;
typedef int(__cdecl * Com_Milliseconds_t)();
extern Com_Milliseconds_t Com_Milliseconds;
typedef char* (__cdecl * Com_ParseExt_t)(const char **data_p);
extern Com_ParseExt_t Com_ParseExt;
@ -135,8 +132,8 @@ namespace Game
typedef int(__cdecl * FS_ReadFile_t)(const char* path, char** buffer);
extern FS_ReadFile_t FS_ReadFile;
typedef char** (__cdecl * FS_ListFiles_t)(const char *path, const char *extension, FsListBehavior_e behavior, int *numfiles, int allocTrackType);
extern FS_ListFiles_t FS_ListFiles;
typedef char** (__cdecl * FS_GetFileList_t)(const char *path, const char *extension, FsListBehavior_e behavior, int *numfiles, int allocTrackType);
extern FS_GetFileList_t FS_GetFileList;
typedef void(__cdecl * FS_FreeFileList_t)(char** list);
extern FS_FreeFileList_t FS_FreeFileList;
@ -383,6 +380,9 @@ namespace Game
typedef char** (__cdecl * Sys_ListFiles_t)(const char *directory, const char *extension, const char *filter, int *numfiles, int wantsubs);
extern Sys_ListFiles_t Sys_ListFiles;
typedef int(__cdecl * Sys_Milliseconds_t)();
extern Sys_Milliseconds_t Sys_Milliseconds;
typedef bool(__cdecl * Sys_SendPacket_t)(netsrc_t sock, size_t len, const char *format, netadr_t adr);
extern Sys_SendPacket_t Sys_SendPacket;

View File

@ -30,7 +30,7 @@ namespace Steam
}
else // Random guid
{
subId = (Game::Com_Milliseconds() + timeGetTime());
subId = (Game::Sys_Milliseconds() + timeGetTime());
}
subId &= ~0x80000000; // Ensure it's positive