Merge branch 'main' of https://github.com/skkuull/h1-mod
This commit is contained in:
commit
514f6cd310
@ -1,7 +1,6 @@
|
||||
# H1-Mod 1.4
|
||||
|
||||
- *This project supports only singleplayer for now*
|
||||
- ***YOU CAN'T** get in multiplayer, networking development is slow.*
|
||||
- *Note: Multiplayer support is in progress!*
|
||||
|
||||
<p align="center">
|
||||
<img alig src="https://cdn.discordapp.com/attachments/895680402142941194/938488726391242842/splash.png"/>
|
||||
|
@ -129,19 +129,43 @@ namespace demonware
|
||||
server = udp_servers.find(name);
|
||||
}
|
||||
|
||||
const auto result = getaddrinfo(name, service, hints, res);
|
||||
|
||||
if (!server)
|
||||
{
|
||||
return result;
|
||||
return getaddrinfo(name, service, hints, res);
|
||||
}
|
||||
|
||||
auto address = reinterpret_cast<sockaddr_in*>(res[0]->ai_addr);
|
||||
address->sin_addr.s_addr = server->get_address();
|
||||
const auto address = utils::memory::get_allocator()->allocate<sockaddr>();
|
||||
const auto ai = utils::memory::get_allocator()->allocate<addrinfo>();
|
||||
|
||||
auto in_addr = reinterpret_cast<sockaddr_in*>(address);
|
||||
in_addr->sin_addr.s_addr = server->get_address();
|
||||
in_addr->sin_family = AF_INET;
|
||||
|
||||
ai->ai_family = AF_INET;
|
||||
ai->ai_socktype = SOCK_STREAM;
|
||||
ai->ai_addr = address;
|
||||
ai->ai_addrlen = sizeof(sockaddr);
|
||||
ai->ai_next = nullptr;
|
||||
ai->ai_flags = 0;
|
||||
ai->ai_protocol = 0;
|
||||
ai->ai_canonname = const_cast<char*>(name);
|
||||
|
||||
*res = ai;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void freeaddrinfo_stub(addrinfo* ai)
|
||||
{
|
||||
if (!utils::memory::get_allocator()->find(ai))
|
||||
{
|
||||
return freeaddrinfo(ai);
|
||||
}
|
||||
|
||||
utils::memory::get_allocator()->free(ai->ai_addr);
|
||||
utils::memory::get_allocator()->free(ai);
|
||||
}
|
||||
|
||||
int getpeername_stub(const SOCKET s, sockaddr* addr, socklen_t* addrlen)
|
||||
{
|
||||
auto* server = find_server(s);
|
||||
@ -500,6 +524,7 @@ namespace demonware
|
||||
if (function == "#20") return io::sendto_stub;
|
||||
if (function == "#52") return io::gethostbyname_stub;
|
||||
if (function == "getaddrinfo") return io::getaddrinfo_stub;
|
||||
if (function == "freeaddrinfo") return io::freeaddrinfo_stub;
|
||||
}
|
||||
|
||||
if (function == "InternetGetConnectedState")
|
||||
|
@ -190,7 +190,7 @@ namespace game_console
|
||||
for (const auto& dvar : dvars::dvar_list)
|
||||
{
|
||||
auto name = utils::string::to_lower(dvar);
|
||||
if (match_compare(input, name, exact))
|
||||
if (game::Dvar_FindVar(name.data()) && match_compare(input, name, exact))
|
||||
{
|
||||
suggestions.push_back(dvar);
|
||||
}
|
||||
@ -245,9 +245,6 @@ namespace game_console
|
||||
con.globals.y + con.globals.font_height, 1.0f, 1.0f, 0, color_white, 0,
|
||||
con.cursor, '|');
|
||||
|
||||
game::R_AddCmdDrawText(con.buffer, 0x7FFF, console_font, con.globals.x,
|
||||
con.globals.y + con.globals.font_height, 1.0f, 1.0f, 0.0f, color_white, 0);
|
||||
|
||||
// check if using a prefixed '/' or not
|
||||
const auto input = con.buffer[1] && (con.buffer[0] == '/' || con.buffer[0] == '\\')
|
||||
? std::string(con.buffer).substr(1)
|
||||
|
@ -62,6 +62,14 @@ namespace utils
|
||||
return data;
|
||||
}
|
||||
|
||||
bool memory::allocator::find(const void* data)
|
||||
{
|
||||
std::lock_guard _(this->mutex_);
|
||||
|
||||
const auto j = std::find(this->pool_.begin(), this->pool_.end(), data);
|
||||
return j != this->pool_.end();
|
||||
}
|
||||
|
||||
void* memory::allocate(const size_t length)
|
||||
{
|
||||
return calloc(length, 1);
|
||||
|
@ -37,6 +37,8 @@ namespace utils
|
||||
|
||||
char* duplicate_string(const std::string& string);
|
||||
|
||||
bool find(const void* data);
|
||||
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
std::vector<void*> pool_;
|
||||
|
Loading…
Reference in New Issue
Block a user