Some fixes

This commit is contained in:
fed 2023-07-06 00:55:01 +02:00
parent d10a101fec
commit 6f639c8a9b
3 changed files with 28 additions and 5 deletions

View File

@ -50,7 +50,7 @@ namespace fastfiles
auto result = db_find_xasset_header_hook.invoke<game::XAssetHeader>(type, name, allow_create_default); auto result = db_find_xasset_header_hook.invoke<game::XAssetHeader>(type, name, allow_create_default);
const auto diff = game::Sys_Milliseconds() - start; const auto diff = game::Sys_Milliseconds() - start;
if (result.rawfile) if (type == game::ASSET_TYPE_RAWFILE && result.rawfile)
{ {
const std::string override_rawfile_name = "override/"s + name; const std::string override_rawfile_name = "override/"s + name;
const auto override_rawfile = db_find_xasset_header_hook.invoke<game::XAssetHeader>(type, override_rawfile_name.data(), 0); const auto override_rawfile = db_find_xasset_header_hook.invoke<game::XAssetHeader>(type, override_rawfile_name.data(), 0);

View File

@ -63,6 +63,8 @@ namespace game_console
float color_white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; float color_white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
float color_h2[4] = {0.9f, 0.9f, 0.5f, 1.0f}; float color_h2[4] = {0.9f, 0.9f, 0.5f, 1.0f};
bool is_initialized{};
void clear() void clear()
{ {
strncpy_s(con.buffer, "", 256); strncpy_s(con.buffer, "", 256);
@ -82,7 +84,7 @@ namespace game_console
con.display_line_offset++; con.display_line_offset++;
} }
output.push_back(data); output.emplace_back(data);
if (output.size() > 512) if (output.size() > 512)
{ {
output.pop_front(); output.pop_front();
@ -548,6 +550,11 @@ namespace game_console
void add(const std::string& cmd) void add(const std::string& cmd)
{ {
if (!is_initialized)
{
return;
}
execute(cmd.data()); execute(cmd.data());
history.push_front(cmd); history.push_front(cmd);
@ -702,7 +709,7 @@ namespace game_console
auto name = utils::string::to_lower(dvar.name); auto name = utils::string::to_lower(dvar.name);
if (game::Dvar_FindVar(name.data()) && match_compare(input, name, exact)) if (game::Dvar_FindVar(name.data()) && match_compare(input, name, exact))
{ {
suggestions.push_back(dvar); suggestions.emplace_back(dvar);
} }
if (exact && suggestions.size() > 1) if (exact && suggestions.size() > 1)
@ -713,7 +720,7 @@ namespace game_console
if (suggestions.size() == 0 && game::Dvar_FindVar(input.data())) if (suggestions.size() == 0 && game::Dvar_FindVar(input.data()))
{ {
suggestions.push_back({ input, "" }); suggestions.emplace_back(input, "");
} }
game::cmd_function_s* cmd = (*game::cmd_functions); game::cmd_function_s* cmd = (*game::cmd_functions);
@ -725,7 +732,7 @@ namespace game_console
if (match_compare(input, name, exact)) if (match_compare(input, name, exact))
{ {
suggestions.push_back({cmd->name, ""}); suggestions.emplace_back(cmd->name, "");
} }
if (exact && suggestions.size() > 1) if (exact && suggestions.size() > 1)
@ -757,6 +764,11 @@ namespace game_console
{ {
scheduler::loop(draw_console, scheduler::pipeline::renderer); scheduler::loop(draw_console, scheduler::pipeline::renderer);
scheduler::once([]
{
is_initialized = true;
}, scheduler::main);
con.cursor = 0; con.cursor = 0;
con.visible_line_count = 0; con.visible_line_count = 0;
con.output_visible = false; con.output_visible = false;

View File

@ -359,6 +359,15 @@ namespace gsc
reinterpret_cast<size_t>(&func_map)); reinterpret_cast<size_t>(&func_map));
func_map_->insert(std::make_pair(name_, id)); func_map_->insert(std::make_pair(name_, id));
} }
void add_method_name(const std::string& name, const std::uint16_t id)
{
const std::string_view name_ = utils::memory::get_allocator()->duplicate_string(name);
auto& func_map = gsc_ctx->meth_map();
auto func_map_ = reinterpret_cast<std::unordered_map<std::string_view, uint16_t>*>(
reinterpret_cast<size_t>(&func_map));
func_map_->insert(std::make_pair(name_, id));
}
} }
game::ScriptFile* find_script(game::XAssetType type, const char* name, int allow_create_default) game::ScriptFile* find_script(game::XAssetType type, const char* name, int allow_create_default)
@ -409,6 +418,8 @@ namespace gsc
add_function_name("isusinghdr", 0x242); add_function_name("isusinghdr", 0x242);
add_function_name("tablegetrowcount", 0x2A6); add_function_name("tablegetrowcount", 0x2A6);
add_function_name("setshaderconstant", 0x2F1);
add_method_name("setclutforplayer", 0x849F);
scripting::on_shutdown([](bool free_scripts, bool post_shutdown) scripting::on_shutdown([](bool free_scripts, bool post_shutdown)
{ {