5 Commits

Author SHA1 Message Date
3564f4d653 chore: update 2025-11-16 21:30:39 +01:00
f273adabf6 chore: update 2025-07-28 15:55:44 +02:00
03f70b0a80 fix: remove last patch as it causes a crash 2025-07-15 06:13:17 +00:00
2e62c51809 chore: reallocate assets 2025-07-02 16:22:06 +02:00
189cca6a80 mods: add missing patch
Co-authored-by: mjkzy <mjkzyalt@gmail.com>
2025-06-20 11:01:01 +02:00
16 changed files with 61 additions and 70 deletions

2
deps/GSL vendored

Submodule deps/GSL updated: 466e4ebaa5...543d0dd3fe

2
deps/asmjit vendored

2
deps/gsc-tool vendored

2
deps/minhook vendored

View File

@@ -1,32 +0,0 @@
wintoast = {
source = path.join(dependencies.basePath, "WinToast"),
}
function wintoast.import()
links { "WinToast" }
wintoast.includes()
end
function wintoast.includes()
includedirs {
path.join(wintoast.source, "include"),
}
end
function wintoast.project()
project "WinToast"
language "C++"
wintoast.includes()
rapidjson.import();
files {
path.join(wintoast.source, "include/wintoastlib.h"),
path.join(wintoast.source, "src/wintoastlib.cpp"),
}
warnings "Off"
kind "StaticLib"
end
table.insert(dependencies, wintoast)

View File

@@ -117,7 +117,7 @@ namespace demonware
{ {
hostent* WINAPI gethostbyname_stub(const char* name) hostent* WINAPI gethostbyname_stub(const char* name)
{ {
#ifdef DEBUG #ifdef DW_DEBUG
printf("[ network ]: [gethostbyname]: \"%s\"\n", name); printf("[ network ]: [gethostbyname]: \"%s\"\n", name);
#endif #endif

View File

@@ -6,9 +6,9 @@
#include "command.hpp" #include "command.hpp"
#include "console.hpp" #include "console.hpp"
#include <utils/concurrency.hpp>
#include <utils/hook.hpp> #include <utils/hook.hpp>
#include <utils/io.hpp> #include <utils/io.hpp>
#include <utils/concurrency.hpp>
namespace fastfiles namespace fastfiles
{ {
@@ -115,7 +115,7 @@ namespace fastfiles
char* reallocate_asset_pool() char* reallocate_asset_pool()
{ {
constexpr auto element_size = get_asset_type_size(Type); constexpr auto element_size = get_asset_type_size(Type);
static char new_pool[element_size * Size] = {0}; static char new_pool[element_size * Size]{0};
assert(get_asset_type_size(Type) == game::DB_GetXAssetTypeSize(Type)); assert(get_asset_type_size(Type) == game::DB_GetXAssetTypeSize(Type));
std::memmove(new_pool, game::DB_XAssetPool[Type], game::g_poolSize[Type] * element_size); std::memmove(new_pool, game::DB_XAssetPool[Type], game::g_poolSize[Type] * element_size);
@@ -167,8 +167,30 @@ namespace fastfiles
utils::hook::inject(0x14027463C, xmodel_pool + 8); utils::hook::inject(0x14027463C, xmodel_pool + 8);
utils::hook::inject(0x140274689, xmodel_pool + 8); utils::hook::inject(0x140274689, xmodel_pool + 8);
// Reallocate asset pools
// Disabled because it causes a crash in the main menu once you rejoin a server after
// disconnecting and waiting for the server to map rotating.
#if 0
reallocate_asset_pool<game::ASSET_TYPE_LUA_FILE, 768>();
reallocate_asset_pool<game::ASSET_TYPE_WEAPON, 1400>();
reallocate_asset_pool<game::ASSET_TYPE_LOCALIZE_ENTRY, 27200>();
reallocate_asset_pool<game::ASSET_TYPE_XANIMPARTS, 11600>();
reallocate_asset_pool<game::ASSET_TYPE_ATTACHMENT, 256>();
reallocate_asset_pool<game::ASSET_TYPE_FONT, 96>();
reallocate_asset_pool<game::ASSET_TYPE_SNDDRIVER_GLOBALS, 4>();
reallocate_asset_pool<game::ASSET_TYPE_EQUIPMENT_SND_TABLE, 4>();
reallocate_asset_pool<game::ASSET_TYPE_SOUND, 32000>();
reallocate_asset_pool<game::ASSET_TYPE_LOADED_SOUND, 14000>();
reallocate_asset_pool<game::ASSET_TYPE_VERTEXDECL, 3072>();
reallocate_asset_pool<game::ASSET_TYPE_COMPUTESHADER, 1024>();
reallocate_asset_pool<game::ASSET_TYPE_REVERB_PRESET, 128>();
reallocate_asset_pool<game::ASSET_TYPE_IMPACT_FX, 40>();
#endif
// Fix compressor type on streamed file load // Fix compressor type on streamed file load
db_read_stream_file_hook.create(0x14027AA70, db_read_stream_file_stub); db_read_stream_file_hook.create(0x14027AA70, db_read_stream_file_stub);
// Allow loading of unsigned fastfiles
utils::hook::nop(0x1402427A5, 2); // DB_InflateInit
} }
} }
}; };

View File

@@ -89,7 +89,7 @@ namespace demonware
std::memcpy(data.m_dec_key, &out_3[40], 16); std::memcpy(data.m_dec_key, &out_3[40], 16);
std::memcpy(data.m_enc_key, &out_3[56], 16); std::memcpy(data.m_enc_key, &out_3[56], 16);
#ifdef DEBUG #ifdef DW_DEBUG
printf("[DW] Response id: %s\n", utils::string::dump_hex(std::string(&out_2[8], 8)).data()); printf("[DW] Response id: %s\n", utils::string::dump_hex(std::string(&out_2[8], 8)).data());
printf("[DW] Hash verify: %s\n", utils::string::dump_hex(std::string(&out_3[20], 20)).data()); printf("[DW] Hash verify: %s\n", utils::string::dump_hex(std::string(&out_3[20], 20)).data());
printf("[DW] AES dec key: %s\n", utils::string::dump_hex(std::string(&out_3[40], 16)).data()); printf("[DW] AES dec key: %s\n", utils::string::dump_hex(std::string(&out_3[40], 16)).data());

View File

@@ -38,7 +38,7 @@ namespace demonware
{ {
if (packet.starts_with("POST /auth/")) if (packet.starts_with("POST /auth/"))
{ {
#ifdef DEBUG #ifdef DW_DEBUG
printf("[DW]: [auth]: user requested authentication.\n"); printf("[DW]: [auth]: user requested authentication.\n");
#endif #endif
return; return;
@@ -81,7 +81,7 @@ namespace demonware
} }
} }
#ifdef DEBUG #ifdef DW_DEBUG
printf("[DW]: [auth]: authenticating user %s\n", token.data() + 64); printf("[DW]: [auth]: authenticating user %s\n", token.data() + 64);
#endif #endif
@@ -160,7 +160,7 @@ namespace demonware
raw_reply reply(result); raw_reply reply(result);
this->send_reply(&reply); this->send_reply(&reply);
#ifdef DEBUG #ifdef DW_DEBUG
printf("[DW]: [auth]: user successfully authenticated.\n"); printf("[DW]: [auth]: user successfully authenticated.\n");
#endif #endif
} }

View File

@@ -56,7 +56,7 @@ namespace demonware
} }
else if (size == 0xC8) else if (size == 0xC8)
{ {
#ifdef DEBUG #ifdef DW_DEBUG
printf("[DW]: [lobby]: received client_header_ack.\n"); printf("[DW]: [lobby]: received client_header_ack.\n");
#endif #endif
@@ -72,7 +72,7 @@ namespace demonware
raw_reply reply(packet_2); raw_reply reply(packet_2);
this->send_reply(&reply); this->send_reply(&reply);
#ifdef DEBUG #ifdef DW_DEBUG
printf("[DW]: [lobby]: sending server_header_ack.\n"); printf("[DW]: [lobby]: sending server_header_ack.\n");
#endif #endif
return; return;
@@ -89,7 +89,7 @@ namespace demonware
if (type == 0x82) if (type == 0x82)
{ {
#ifdef DEBUG #ifdef DW_DEBUG
printf("[DW]: [lobby]: received client_auth.\n"); printf("[DW]: [lobby]: received client_auth.\n");
#endif #endif
std::string packet_3(packet.data(), packet.size() - 8); // this 8 are client hash check? std::string packet_3(packet.data(), packet.size() - 8); // this 8 are client hash check?
@@ -104,7 +104,7 @@ namespace demonware
raw_reply reply(response); raw_reply reply(response);
this->send_reply(&reply); this->send_reply(&reply);
#ifdef DEBUG #ifdef DW_DEBUG
printf("[DW]: [lobby]: sending server_auth_done.\n"); printf("[DW]: [lobby]: sending server_auth_done.\n");
#endif #endif
return; return;
@@ -163,8 +163,9 @@ namespace demonware
} }
else else
{ {
#ifdef DW_DEBUG
printf("[DW]: [lobby]: missing service '%s'\n", utils::string::va("%d", id)); printf("[DW]: [lobby]: missing service '%s'\n", utils::string::va("%d", id));
#endif
// return no error // return no error
byte_buffer buffer(data); byte_buffer buffer(data);
uint8_t task_id; uint8_t task_id;

View File

@@ -51,7 +51,7 @@ namespace demonware
if (it != this->tasks_.end()) if (it != this->tasks_.end())
{ {
#ifdef DEBUG #ifdef DW_DEBUG
printf("[DW] %s: executing task '%d'\n", name_.data(), this->task_id_); printf("[DW] %s: executing task '%d'\n", name_.data(), this->task_id_);
#endif #endif

View File

@@ -15,7 +15,7 @@ namespace demonware
{ {
std::string get_motd_text() std::string get_motd_text()
{ {
return "This is not a copy & pasted client"; return "Did you know aiming down sights increases accuracy? Online Interactions Not Rated by the ESRB.";
} }
} }
@@ -75,7 +75,7 @@ namespace demonware
} }
} }
#ifdef DEBUG #ifdef DW_DEBUG
printf("[DW]: [bdStorage]: missing publisher file: %s\n", name.data()); printf("[DW]: [bdStorage]: missing publisher file: %s\n", name.data());
#endif #endif
@@ -118,7 +118,7 @@ namespace demonware
std::string filename; std::string filename;
buffer->read_string(&filename); buffer->read_string(&filename);
#ifdef DEBUG #ifdef DW_DEBUG
printf("[DW]: [bdStorage]: loading publisher file: %s\n", filename.data()); printf("[DW]: [bdStorage]: loading publisher file: %s\n", filename.data());
#endif #endif
@@ -126,7 +126,7 @@ namespace demonware
if (this->load_publisher_resource(filename, data)) if (this->load_publisher_resource(filename, data))
{ {
#ifdef DEBUG #ifdef DW_DEBUG
printf("[DW]: [bdStorage]: sending publisher file: %s, size: %lld\n", filename.data(), data.size()); printf("[DW]: [bdStorage]: sending publisher file: %s, size: %lld\n", filename.data(), data.size());
#endif #endif
@@ -185,7 +185,7 @@ namespace demonware
buffer->read_uint64(&owner); buffer->read_uint64(&owner);
buffer->read_string(&platform); buffer->read_string(&platform);
#ifdef DEBUG #ifdef DW_DEBUG
printf("[DW]: [bdStorage]: user file: %s, %s, %s\n", game.data(), filename.data(), platform.data()); printf("[DW]: [bdStorage]: user file: %s, %s, %s\n", game.data(), filename.data(), platform.data());
#endif #endif

View File

@@ -1 +1 @@
Welcome to s1-mod. This is not a copy & pasted project. Welcome to s1-mod. Did you know aiming down sights increases accuracy? Online Interactions Not Rated by the ESRB.

View File

@@ -22,54 +22,54 @@ namespace utils::string
++this->current_buffer_ %= ARRAY_COUNT(this->string_pool_); ++this->current_buffer_ %= ARRAY_COUNT(this->string_pool_);
auto entry = &this->string_pool_[this->current_buffer_]; auto entry = &this->string_pool_[this->current_buffer_];
if (!entry->size || !entry->buffer) if (!entry->size_ || !entry->buffer_)
{ {
throw std::runtime_error("String pool not initialized"); throw std::runtime_error("String pool not initialized");
} }
while (true) while (true)
{ {
const int res = vsnprintf_s(entry->buffer, entry->size, _TRUNCATE, format, ap); const auto res = vsnprintf_s(entry->buffer_, entry->size_, _TRUNCATE, format, ap);
if (res > 0) break; // Success if (res > 0) break; // Success
if (res == 0) return nullptr; // Error if (res == 0) return nullptr; // Error
entry->double_size(); entry->double_size();
} }
return entry->buffer; return entry->buffer_;
} }
private: private:
class entry final class entry final
{ {
public: public:
explicit entry(const size_t _size = MinBufferSize) : size(_size), buffer(nullptr) explicit entry(const size_t size = MinBufferSize) : size_(size), buffer_(nullptr)
{ {
if (this->size < MinBufferSize) this->size = MinBufferSize; if (this->size_ < MinBufferSize) this->size_ = MinBufferSize;
this->allocate(); this->allocate();
} }
~entry() ~entry()
{ {
if (this->buffer) memory::get_allocator()->free(this->buffer); if (this->buffer_) memory::get_allocator()->free(this->buffer_);
this->size = 0; this->size_ = 0;
this->buffer = nullptr; this->buffer_ = nullptr;
} }
void allocate() void allocate()
{ {
if (this->buffer) memory::get_allocator()->free(this->buffer); if (this->buffer_) memory::get_allocator()->free(this->buffer_);
this->buffer = memory::get_allocator()->allocate_array<char>(this->size + 1); this->buffer_ = memory::get_allocator()->allocate_array<char>(this->size_ + 1);
} }
void double_size() void double_size()
{ {
this->size *= 2; this->size_ *= 2;
this->allocate(); this->allocate();
} }
size_t size; size_t size_;
char* buffer; char* buffer_;
}; };
size_t current_buffer_; size_t current_buffer_;