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;
}
forwardInt = std::clamp(forwardInt, -128, 127);
rightInt = std::clamp(rightInt, -128, 127);
forwardInt = std::clamp<int>(forwardInt, std::numeric_limits<char>::min(), std::numeric_limits<char>::max());
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].right = static_cast<int8_t>(rightInt);

View File

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

View File

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