forgot to use diamond operators for std::clamp

This commit is contained in:
FutureRave 2022-02-15 17:41:30 +00:00
parent 457475961b
commit 74579be0b1
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955
4 changed files with 24 additions and 3 deletions

View File

@ -243,8 +243,8 @@ namespace Components
return; return;
} }
forwardInt = std::clamp(forwardInt, -128, 127); forwardInt = std::clamp<int>(forwardInt, std::numeric_limits<char>::min(), std::numeric_limits<char>::max());
rightInt = std::clamp(rightInt, -128, 127); rightInt = std::clamp<int>(rightInt, std::numeric_limits<char>::min(), std::numeric_limits<char>::max());
g_botai[entref.entnum].forward = static_cast<int8_t>(forwardInt); g_botai[entref.entnum].forward = static_cast<int8_t>(forwardInt);
g_botai[entref.entnum].right = static_cast<int8_t>(rightInt); g_botai[entref.entnum].right = static_cast<int8_t>(rightInt);

View File

@ -11,6 +11,7 @@ namespace Components
std::uint8_t padding3[4]; std::uint8_t padding3[4];
std::int32_t tableColumn; std::int32_t tableColumn;
}; };
struct playercarddata_s struct playercarddata_s
{ {
std::uint32_t padding; std::uint32_t padding;

View File

@ -10,48 +10,59 @@ namespace Components
{ {
Game::NET_StringToAdr(addrString.data(), &this->address); Game::NET_StringToAdr(addrString.data(), &this->address);
} }
Network::Address::Address(sockaddr* addr) Network::Address::Address(sockaddr* addr)
{ {
Game::SockadrToNetadr(addr, &this->address); Game::SockadrToNetadr(addr, &this->address);
} }
bool Network::Address::operator==(const Network::Address& obj) const bool Network::Address::operator==(const Network::Address& obj) const
{ {
return Game::NET_CompareAdr(this->address, obj.address); return Game::NET_CompareAdr(this->address, obj.address);
} }
void Network::Address::setPort(unsigned short port) void Network::Address::setPort(unsigned short port)
{ {
this->address.port = htons(port); this->address.port = htons(port);
} }
unsigned short Network::Address::getPort() unsigned short Network::Address::getPort()
{ {
return ntohs(this->address.port); return ntohs(this->address.port);
} }
void Network::Address::setIP(DWORD ip) void Network::Address::setIP(DWORD ip)
{ {
this->address.ip.full = ip; this->address.ip.full = ip;
} }
void Network::Address::setIP(Game::netIP_t ip) void Network::Address::setIP(Game::netIP_t ip)
{ {
this->address.ip = ip; this->address.ip = ip;
} }
Game::netIP_t Network::Address::getIP() Game::netIP_t Network::Address::getIP()
{ {
return this->address.ip; return this->address.ip;
} }
void Network::Address::setType(Game::netadrtype_t type) void Network::Address::setType(Game::netadrtype_t type)
{ {
this->address.type = type; this->address.type = type;
} }
Game::netadrtype_t Network::Address::getType() Game::netadrtype_t Network::Address::getType()
{ {
return this->address.type; return this->address.type;
} }
sockaddr Network::Address::getSockAddr() sockaddr Network::Address::getSockAddr()
{ {
sockaddr addr; sockaddr addr;
this->toSockAddr(&addr); this->toSockAddr(&addr);
return addr; return addr;
} }
void Network::Address::toSockAddr(sockaddr* addr) void Network::Address::toSockAddr(sockaddr* addr)
{ {
if (addr) if (addr)
@ -59,22 +70,27 @@ namespace Components
Game::NetadrToSockadr(&this->address, addr); Game::NetadrToSockadr(&this->address, addr);
} }
} }
void Network::Address::toSockAddr(sockaddr_in* addr) void Network::Address::toSockAddr(sockaddr_in* addr)
{ {
this->toSockAddr(reinterpret_cast<sockaddr*>(addr)); this->toSockAddr(reinterpret_cast<sockaddr*>(addr));
} }
Game::netadr_t* Network::Address::get() Game::netadr_t* Network::Address::get()
{ {
return &this->address; return &this->address;
} }
const char* Network::Address::getCString() const const char* Network::Address::getCString() const
{ {
return Game::NET_AdrToString(this->address); return Game::NET_AdrToString(this->address);
} }
std::string Network::Address::getString() const std::string Network::Address::getString() const
{ {
return this->getCString(); return this->getCString();
} }
bool Network::Address::isLocal() bool Network::Address::isLocal()
{ {
// According to: https://en.wikipedia.org/wiki/Private_network // According to: https://en.wikipedia.org/wiki/Private_network
@ -95,6 +111,7 @@ namespace Components
return false; return false;
} }
bool Network::Address::isSelf() bool Network::Address::isSelf()
{ {
if (Game::NET_IsLocalAddress(this->address)) return true; // Loopback if (Game::NET_IsLocalAddress(this->address)) return true; // Loopback
@ -110,6 +127,7 @@ namespace Components
return false; return false;
} }
bool Network::Address::isLoopback() bool Network::Address::isLoopback()
{ {
if (this->getIP().full == 0x100007f) // 127.0.0.1 if (this->getIP().full == 0x100007f) // 127.0.0.1
@ -119,10 +137,12 @@ namespace Components
return Game::NET_IsLocalAddress(this->address); return Game::NET_IsLocalAddress(this->address);
} }
bool Network::Address::isValid() bool Network::Address::isValid()
{ {
return (this->getType() != Game::netadrtype_t::NA_BAD && this->getType() >= Game::netadrtype_t::NA_BOT && this->getType() <= Game::netadrtype_t::NA_IP); return (this->getType() != Game::netadrtype_t::NA_BAD && this->getType() >= Game::netadrtype_t::NA_BOT && this->getType() <= Game::netadrtype_t::NA_IP);
} }
void Network::Handle(const std::string& packet, Utils::Slot<Network::Callback> callback) void Network::Handle(const std::string& packet, Utils::Slot<Network::Callback> callback)
{ {
Network::PacketHandlers[Utils::String::ToLower(packet)] = callback; Network::PacketHandlers[Utils::String::ToLower(packet)] = callback;

View File

@ -558,7 +558,7 @@ namespace Game
typedef bool(__cdecl * NET_IsLocalAddress_t)(netadr_t adr); typedef bool(__cdecl * NET_IsLocalAddress_t)(netadr_t adr);
extern NET_IsLocalAddress_t NET_IsLocalAddress; extern NET_IsLocalAddress_t NET_IsLocalAddress;
typedef bool(__cdecl * NET_StringToAdr_t)(const char *s, netadr_t *a); typedef int(__cdecl * NET_StringToAdr_t)(const char *s, netadr_t *a);
extern NET_StringToAdr_t NET_StringToAdr; extern NET_StringToAdr_t NET_StringToAdr;
typedef void(__cdecl * NET_OutOfBandPrint_t)(netsrc_t sock, netadr_t adr, const char *data); typedef void(__cdecl * NET_OutOfBandPrint_t)(netsrc_t sock, netadr_t adr, const char *data);