Even more optimizations

This commit is contained in:
momo5502 2016-06-26 20:46:02 +02:00
parent 3746bceec4
commit 123d62e1eb
12 changed files with 29 additions and 28 deletions

View File

@ -240,7 +240,7 @@ namespace Components
return bits; return bits;
} }
bits++; ++bits;
} }
} }

View File

@ -65,15 +65,16 @@ namespace Components
char index = *(in + 1); char index = *(in + 1);
if (*in == '^' && (Colors::ColorIndex(index) != 7 || index == '7')) if (*in == '^' && (Colors::ColorIndex(index) != 7 || index == '7'))
{ {
in++; ++in;
} }
else else
{ {
*out = *in; *out = *in;
out++; ++out;
current++; ++current;
} }
in++;
++in;
} }
*out = '\0'; *out = '\0';
} }

View File

@ -56,7 +56,7 @@ namespace Components
{ {
if (Game::svs_clients[i].state >= 3) if (Game::svs_clients[i].state >= 3)
{ {
clientCount++; ++clientCount;
} }
} }
} }
@ -344,21 +344,21 @@ namespace Components
if (*p == '^') if (*p == '^')
{ {
char color; char color;
p++; ++p;
color = (*p - '0'); color = (*p - '0');
if (color < 9 && color > 0) if (color < 9 && color > 0)
{ {
wattron(Console::OutputWindow, COLOR_PAIR(color + 2)); wattron(Console::OutputWindow, COLOR_PAIR(color + 2));
p++; ++p;
continue; continue;
} }
} }
waddch(Console::OutputWindow, *p); waddch(Console::OutputWindow, *p);
p++; ++p;
} }
wattron(Console::OutputWindow, COLOR_PAIR(9)); wattron(Console::OutputWindow, COLOR_PAIR(9));

View File

@ -90,7 +90,7 @@ namespace Components
else command.append(Utils::VA("wait 500;", mapname)); // Test direct map switch else command.append(Utils::VA("wait 500;", mapname)); // Test direct map switch
command.append(Utils::VA("map %s;", mapname)); command.append(Utils::VA("map %s;", mapname));
i++, current++; ++i, ++current;
if (current >= max) break; if (current >= max) break;
} }

View File

@ -33,7 +33,7 @@ namespace Components
if (this->ReconnectAttempt < IPC_MAX_RECONNECTS) if (this->ReconnectAttempt < IPC_MAX_RECONNECTS)
{ {
Logger::Print("Attempting to reconnect to the pipe.\n"); Logger::Print("Attempting to reconnect to the pipe.\n");
this->ReconnectAttempt++; ++this->ReconnectAttempt;
std::this_thread::sleep_for(500ms); std::this_thread::sleep_for(500ms);
return this->Connect(name); return this->Connect(name);

View File

@ -269,7 +269,7 @@ namespace Components
// Register when unregistered and in UNKNOWN state (I doubt it's possible to be unregistered and in VALID state) // Register when unregistered and in UNKNOWN state (I doubt it's possible to be unregistered and in VALID state)
if (!node.registered && (node.state != Node::STATE_NEGOTIATING && node.state != Node::STATE_INVALID)) if (!node.registered && (node.state != Node::STATE_NEGOTIATING && node.state != Node::STATE_INVALID))
{ {
registerCount++; ++registerCount;
node.state = Node::STATE_NEGOTIATING; node.state = Node::STATE_NEGOTIATING;
Node::PerformRegistration(node.address); Node::PerformRegistration(node.address);
} }
@ -284,7 +284,7 @@ namespace Components
// Nvm, this is required for clients, as nodes don't send registration requests to clients. // 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::Com_Milliseconds() - node.lastTime) > NODE_QUERY_INTERVAL)
{ {
registerCount++; ++registerCount;
Node::PerformRegistration(node.address); Node::PerformRegistration(node.address);
} }
} }
@ -293,7 +293,7 @@ namespace Components
{ {
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::Com_Milliseconds() - node.lastListQuery) > NODE_QUERY_INTERVAL))
{ {
listQueryCount++; ++listQueryCount;
node.state = Node::STATE_NEGOTIATING; node.state = Node::STATE_NEGOTIATING;
node.lastTime = Game::Com_Milliseconds(); node.lastTime = Game::Com_Milliseconds();
node.lastListQuery = Game::Com_Milliseconds(); node.lastListQuery = Game::Com_Milliseconds();
@ -698,7 +698,7 @@ namespace Components
Network::Address _addr(list.address(i)); Network::Address _addr(list.address(i));
// Version 0 sends port in the wrong byte order! // Version 0 sends port in the wrong byte order!
if (entry->version <= 0) if (entry->version == 0)
{ {
_addr.SetPort(ntohs(_addr.GetPort())); _addr.SetPort(ntohs(_addr.GetPort()));
} }
@ -845,7 +845,7 @@ namespace Components
std::string signature = Utils::Cryptography::ECC::SignMessage(Node::SignatureKey, message); std::string signature = Utils::Cryptography::ECC::SignMessage(Node::SignatureKey, message);
// Invalidate the message... // Invalidate the message...
message[Utils::Cryptography::Rand::GenerateInt() % message.size()]++; ++message[Utils::Cryptography::Rand::GenerateInt() % message.size()];
if (Utils::Cryptography::ECC::VerifyMessage(Node::SignatureKey, message, signature)) if (Utils::Cryptography::ECC::VerifyMessage(Node::SignatureKey, message, signature))
{ {

View File

@ -267,7 +267,7 @@ namespace Components
{ {
if (Game::svs_clients[i].state >= 3) if (Game::svs_clients[i].state >= 3)
{ {
clientCount++; ++clientCount;
} }
} }
} }

View File

@ -49,7 +49,7 @@ namespace Components
if (!Dedicated::IsDedicated()) return; if (!Dedicated::IsDedicated()) return;
// Load public key // Load public key
uint8_t publicKey[] = static uint8_t publicKey[] =
{ {
0x04, 0x01, 0x9D, 0x18, 0x7F, 0x57, 0xD8, 0x95, 0x4C, 0xEE, 0xD0, 0x21, 0x04, 0x01, 0x9D, 0x18, 0x7F, 0x57, 0xD8, 0x95, 0x4C, 0xEE, 0xD0, 0x21,
0xB5, 0x00, 0x53, 0xEC, 0xEB, 0x54, 0x7C, 0x4C, 0x37, 0x18, 0x53, 0x89, 0xB5, 0x00, 0x53, 0xEC, 0xEB, 0x54, 0x7C, 0x4C, 0x37, 0x18, 0x53, 0x89,

View File

@ -359,14 +359,14 @@ namespace Components
{ {
if (server.Addr == container.Target) if (server.Addr == container.Target)
{ {
ServerList::RefreshContainer.SendCount--; --ServerList::RefreshContainer.SendCount;
ServerList::RefreshContainer.SentCount--; --ServerList::RefreshContainer.SentCount;
break; break;
} }
} }
} }
ServerList::RefreshContainer.SendCount++; ++ServerList::RefreshContainer.SendCount;
} }
if (acquireMutex) ServerList::RefreshContainer.Mutex.unlock(); if (acquireMutex) ServerList::RefreshContainer.Mutex.unlock();
@ -542,7 +542,7 @@ namespace Components
server->SendTime = Game::Com_Milliseconds(); server->SendTime = Game::Com_Milliseconds();
server->Challenge = Utils::VA("%X", Utils::Cryptography::Rand::GenerateInt()); server->Challenge = Utils::VA("%X", Utils::Cryptography::Rand::GenerateInt());
ServerList::RefreshContainer.SentCount++; ++ServerList::RefreshContainer.SentCount;
Network::SendCommand(server->Target, "getinfo", server->Challenge); Network::SendCommand(server->Target, "getinfo", server->Challenge);

View File

@ -13,7 +13,7 @@ namespace Components
{ {
hash = tolower(*data) + (31 * hash); hash = tolower(*data) + (31 * hash);
data++; ++data;
} }
return hash; return hash;

View File

@ -368,7 +368,7 @@ namespace Game
while (*string) while (*string)
{ {
hash = (*string | 0x20) ^ (33 * hash); hash = (*string | 0x20) ^ (33 * hash);
string++; ++string;
} }
return hash; return hash;

View File

@ -35,7 +35,7 @@ namespace Utils
} }
else else
{ {
this->TokenString[i]++; ++this->TokenString[i];
break; break;
} }
} }
@ -47,7 +47,7 @@ namespace Utils
Token operator++ (int) Token operator++ (int)
{ {
Token result = *this; Token result = *this;
++(*this); this->operator++();
return result; return result;
} }
@ -149,7 +149,7 @@ namespace Utils
public: public:
Key() : KeyStorage(new ecc_key) Key() : KeyStorage(new ecc_key)
{ {
ZeroMemory(this->KeyStorage.get(), sizeof(*this->GetKeyPtr())); ZeroMemory(this->GetKeyPtr(), sizeof(*this->GetKeyPtr()));
}; };
Key(ecc_key* key) : Key() { if(key) std::memmove(this->GetKeyPtr(), key, sizeof(*key)); }; Key(ecc_key* key) : Key() { if(key) std::memmove(this->GetKeyPtr(), key, sizeof(*key)); };
Key(ecc_key key) : Key(&key) {}; Key(ecc_key key) : Key(&key) {};
@ -244,7 +244,7 @@ namespace Utils
public: public:
Key() : KeyStorage(new rsa_key) Key() : KeyStorage(new rsa_key)
{ {
ZeroMemory(this->KeyStorage.get(), sizeof(*this->GetKeyPtr())); ZeroMemory(this->GetKeyPtr(), sizeof(*this->GetKeyPtr()));
}; };
Key(rsa_key* key) : Key() { if (key) std::memmove(this->GetKeyPtr(), key, sizeof(*key)); }; Key(rsa_key* key) : Key() { if (key) std::memmove(this->GetKeyPtr(), key, sizeof(*key)); };
Key(rsa_key key) : Key(&key) {}; Key(rsa_key key) : Key(&key) {};