From 79a925b31e371112ed2eb7810052f9ed75e9497f Mon Sep 17 00:00:00 2001 From: mjkzy Date: Sat, 25 Jun 2022 09:04:44 -0500 Subject: [PATCH 01/15] memoryfix for SP --- src/client/component/patches.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index 0c8fd8ae..a5cae4f8 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -250,6 +250,17 @@ namespace patches "Disable shader caching, lower graphic settings, free up RAM, or update your GPU drivers."); utils::hook::call(SELECT_VALUE(0x457BC9_b, 0x1D8E09_b), out_of_memory_text_stub); // "Out of memory. You are probably low on disk space." + // "fix" for rare 'Out of memory error' error + // this will *at least* generate the configs for mp/sp, which is the #1 issue + if (utils::flags::has_flag("memoryfix")) + { + utils::hook::jump(SELECT_VALUE(0x5110D0_b, 0x6200C0_b), malloc); + utils::hook::jump(SELECT_VALUE(0x510FF0_b, 0x61FFE0_b), _aligned_malloc); + utils::hook::jump(SELECT_VALUE(0x511130_b, 0x620120_b), free); + utils::hook::jump(SELECT_VALUE(0x511220_b, 0x620210_b), realloc); + utils::hook::jump(SELECT_VALUE(0x511050_b, 0x620040_b), _aligned_realloc); + } + if (!game::environment::is_sp()) { patch_mp(); @@ -333,16 +344,6 @@ namespace patches // Prevent clients from sending invalid reliableAcknowledge utils::hook::call(0x1CBD06_b, sv_execute_client_message_stub); - // "fix" for rare 'Out of memory error' error - if (utils::flags::has_flag("memoryfix")) - { - utils::hook::jump(0x6200C0_b, malloc); - utils::hook::jump(0x61FFE0_b, _aligned_malloc); - utils::hook::jump(0x620120_b, free); - utils::hook::jump(0x620210_b, realloc); - utils::hook::jump(0x620040_b, _aligned_realloc); - } - // Change default hostname and make it replicated dvars::override::register_string("sv_hostname", "^2H1-Mod^7 Default Server", game::DVAR_FLAG_REPLICATED); From b79f1ada09194c3660a913ef55e63a5bf69bf4af Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 25 Jun 2022 18:03:57 +0200 Subject: [PATCH 02/15] Fix images --- src/client/component/images.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/component/images.cpp b/src/client/component/images.cpp index 7b88c223..cad0cd1e 100644 --- a/src/client/component/images.cpp +++ b/src/client/component/images.cpp @@ -119,8 +119,8 @@ namespace images return; } - setup_texture_hook.create(SELECT_VALUE(0x55F870_b, 0x6829C0_b), setup_texture_stub); - load_texture_hook.create(SELECT_VALUE(0x83300_b, 0xA4AA0_b), load_texture_stub); + setup_texture_hook.create(SELECT_VALUE(0x83300_b, 0xA4AA0_b), setup_texture_stub); + load_texture_hook.create(SELECT_VALUE(0x82050_b, 0xA37A0_b), load_texture_stub); } }; } From d61c73a5dd822018849e1f5e9ee34167013b2e8c Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 25 Jun 2022 18:36:23 +0200 Subject: [PATCH 03/15] Always show updater errors --- src/client/component/updater.cpp | 3 ++- src/client/resources/ui_scripts/updater.lua | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/client/component/updater.cpp b/src/client/component/updater.cpp index 44d2b611..ab2c748a 100644 --- a/src/client/component/updater.cpp +++ b/src/client/component/updater.cpp @@ -27,6 +27,7 @@ #define DATA_PATH_DEV "data-dev/" #define ERR_UPDATE_CHECK_FAIL "Failed to check for updates" +#define ERR_UPDATE_CHECK_FAIL_BAD_RESPONSE "Bad response" #define ERR_DOWNLOAD_FAIL "Failed to download file " #define ERR_WRITE_FAIL "Failed to write file " @@ -345,7 +346,7 @@ namespace updater if (!j.IsArray()) { - set_update_check_status(true, false, ERR_UPDATE_CHECK_FAIL); + set_update_check_status(true, false, ERR_UPDATE_CHECK_FAIL_BAD_RESPONSE); return; } diff --git a/src/client/resources/ui_scripts/updater.lua b/src/client/resources/ui_scripts/updater.lua index 90008700..5054cd74 100644 --- a/src/client/resources/ui_scripts/updater.lua +++ b/src/client/resources/ui_scripts/updater.lua @@ -12,11 +12,6 @@ function startupdatecheck(popup, autoclose) end if (not updater.getupdatecheckstatus()) then - if (autoclose) then - LUI.FlowManager.RequestLeaveMenu(popup) - return - end - popup.text:setText("Error: " .. updater.getlasterror()) return end From 46c09265aada9f32f693c872db99531aa4d6e4e4 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 25 Jun 2022 18:46:55 +0200 Subject: [PATCH 04/15] Fix extra_gamemodes --- data/ui_scripts/extra_gamemodes/__init__.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/ui_scripts/extra_gamemodes/__init__.lua b/data/ui_scripts/extra_gamemodes/__init__.lua index 6bdadc82..5608b759 100644 --- a/data/ui_scripts/extra_gamemodes/__init__.lua +++ b/data/ui_scripts/extra_gamemodes/__init__.lua @@ -1,3 +1,7 @@ +if (game:issingleplayer() or not Engine.InFrontend()) then + return +end + Cac.GameModes.Data = { Standard = { Label = Engine.Localize("@MPUI_STANDARD_CAPS"), From fc72e1724e5badcf223d683001ee6c2dc85fb8df Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 25 Jun 2022 18:48:47 +0200 Subject: [PATCH 05/15] Fix master server dvars --- src/client/component/server_list.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/client/component/server_list.cpp b/src/client/component/server_list.cpp index 25db1248..3c9ce6c7 100644 --- a/src/client/component/server_list.cpp +++ b/src/client/component/server_list.cpp @@ -373,16 +373,22 @@ namespace server_list public: void post_unpack() override { - if (!game::environment::is_mp()) return; - - scheduler::once([]() + if (!game::environment::is_sp()) { - // add dvars to change destination master server ip/port - master_server_ip = dvars::register_string("masterServerIP", "master.h1.gg", game::DVAR_FLAG_NONE, - "IP of the destination master server to connect to"); - master_server_port = dvars::register_string("masterServerPort", "20810", game::DVAR_FLAG_NONE, - "Port of the destination master server to connect to"); - }, scheduler::pipeline::main); + scheduler::once([]() + { + // add dvars to change destination master server ip/port + master_server_ip = dvars::register_string("masterServerIP", "master.h1.gg", game::DVAR_FLAG_NONE, + "IP of the destination master server to connect to"); + master_server_port = dvars::register_string("masterServerPort", "20810", game::DVAR_FLAG_NONE, + "Port of the destination master server to connect to"); + }, scheduler::pipeline::main); + } + + if (!game::environment::is_mp()) + { + return; + } localized_strings::override("PLATFORM_SYSTEM_LINK_TITLE", "SERVER LIST"); From 517b3b2c59b45ea08f67e6628e644988f1daff89 Mon Sep 17 00:00:00 2001 From: mjkzy Date: Sat, 25 Jun 2022 12:30:35 -0500 Subject: [PATCH 06/15] heartbeat sending print [skip ci] --- src/client/component/dedicated.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/component/dedicated.cpp b/src/client/component/dedicated.cpp index 46843e64..2031788a 100644 --- a/src/client/component/dedicated.cpp +++ b/src/client/component/dedicated.cpp @@ -40,6 +40,7 @@ namespace dedicated game::netadr_s target{}; if (server_list::get_master_server(target)) { + console::info("Sending heartbeat"); network::send(target, "heartbeat", "H1"); } } From b43d73c0814640098b5b3da3b5d61cab686b8f83 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 25 Jun 2022 20:20:48 +0200 Subject: [PATCH 07/15] Add isPrivate to server info --- src/client/component/server_list.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client/component/server_list.cpp b/src/client/component/server_list.cpp index 3c9ce6c7..f5059e35 100644 --- a/src/client/component/server_list.cpp +++ b/src/client/component/server_list.cpp @@ -36,6 +36,7 @@ namespace server_list game::CodPlayMode play_mode; char in_game; game::netadr_s address; + bool is_private; }; struct @@ -156,6 +157,11 @@ namespace server_list return servers[i].game_type.empty() ? "" : utils::string::va("%i", servers[i].ping); } + if (column == 5) + { + return servers[i].is_private ? "1" : "0"; + } + return ""; } @@ -362,6 +368,7 @@ namespace server_list server.max_clients = atoi(info.get("sv_maxclients").data()); server.bots = atoi(info.get("bots").data()); server.ping = std::min(now - start_time, 999); + server.is_private = atoi(info.get("isPrivate").data()) == 1; server.in_game = 1; From affe3a604533a539b57e3a4de855ce5ba59598a9 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 25 Jun 2022 20:44:28 +0200 Subject: [PATCH 08/15] Show password protected servers --- data/ui_scripts/server_list/serverlist.lua | 52 ++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/data/ui_scripts/server_list/serverlist.lua b/data/ui_scripts/server_list/serverlist.lua index 568670ed..daed0300 100644 --- a/data/ui_scripts/server_list/serverlist.lua +++ b/data/ui_scripts/server_list/serverlist.lua @@ -10,7 +10,7 @@ game:addlocalizedstring("MENU_PING", "Ping") local columns = { { - offset = 10, + offset = 40, text = "@MENU_HOST_NAME", dataindex = 0 }, @@ -33,6 +33,28 @@ local columns = { offset = 1100, text = "@MENU_PING", dataindex = 4 + }, + { + offset = 10, + image = "s1_icon_locked", + customelement = function(value, offset) + return LUI.UIImage.new({ + leftAnchor = true, + topAnchor = true, + height = 20, + width = 20, + left = offset, + top = 2, + material = RegisterMaterial(CoD.Material.RestrictedIcon), + alpha = value == "1" and 1 or 0, + color = { + r = 1, + b = 1, + g = 1 + } + }) + end, + dataindex = 5 } } @@ -68,7 +90,20 @@ SystemLinkJoinMenu.AddHeaderButton = function(menu, f12_arg1, width) button.m_eventHandlers = {} for i = 1, #columns do - SystemLinkJoinMenu.MakeText(button.textHolder, columns[i].offset, Engine.Localize(columns[i].text), nil) + if (columns[i].text) then + SystemLinkJoinMenu.MakeText(button.textHolder, columns[i].offset, Engine.Localize(columns[i].text), nil) + elseif (columns[i].image) then + local image = LUI.UIImage.new({ + leftAnchor = true, + topAnchor = true, + height = 20, + width = 20, + top = 2, + left = columns[i].offset, + material = RegisterMaterial(columns[i].image) + }) + button.textHolder:addElement(image) + end end element:addElement(button) @@ -83,6 +118,9 @@ SystemLinkJoinMenu.AddServerButton = function(menu, controller, index) local gettext = function(i) local text = Lobby.GetServerData(controller, index, columns[i].dataindex) + if (columns[i].customelement) then + text = columns[i].customelement(text) + end local islast = not columns[i + 1] local end_ = islast and 1130 or columns[i + 1].offset @@ -100,7 +138,13 @@ SystemLinkJoinMenu.AddServerButton = function(menu, controller, index) end for i = 1, #columns do - SystemLinkJoinMenu.MakeText(button.textHolder, columns[i].offset, gettext(i), luiglobals.Colors.h1.medium_grey) + if (columns[i].customelement) then + local value = Lobby.GetServerData(controller, index, columns[i].dataindex) + local element = columns[i].customelement(value, columns[i].offset) + button.textHolder:addElement(element) + else + SystemLinkJoinMenu.MakeText(button.textHolder, columns[i].offset, gettext(i), luiglobals.Colors.h1.medium_grey) + end end menu.list:addElement(button) @@ -131,6 +175,8 @@ SystemLinkJoinMenu.MakeText = function(menu, f5_arg1, text, color) el:setText(text) menu:addElement(el) + + return el end function menu_systemlink_join(f19_arg0, f19_arg1) From 8fe481820ef1192f29c75a57501851ebb2eec782 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 25 Jun 2022 20:57:01 +0200 Subject: [PATCH 09/15] Add scrollbar to server list --- data/ui_scripts/server_list/serverlist.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/ui_scripts/server_list/serverlist.lua b/data/ui_scripts/server_list/serverlist.lua index daed0300..2bffdc1f 100644 --- a/data/ui_scripts/server_list/serverlist.lua +++ b/data/ui_scripts/server_list/serverlist.lua @@ -206,6 +206,10 @@ function menu_systemlink_join(f19_arg0, f19_arg1) side = "all" }) + LUI.Options.InitScrollingList(menu.list, nil, { + rows = 18, + }) + menu:AddHelp({ name = "add_button_helper_text", button_ref = "button_alt1", From 9b15e76bfc052d096d03cfae1e3b06a29fab8478 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 25 Jun 2022 21:06:14 +0200 Subject: [PATCH 10/15] Show this error too --- src/client/resources/ui_scripts/updater.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/client/resources/ui_scripts/updater.lua b/src/client/resources/ui_scripts/updater.lua index 5054cd74..fbb19d8b 100644 --- a/src/client/resources/ui_scripts/updater.lua +++ b/src/client/resources/ui_scripts/updater.lua @@ -66,11 +66,6 @@ function startupdatedownload(popup, autoclose) end if (not updater.getupdatedownloadstatus()) then - if (autoclose) then - LUI.FlowManager.RequestLeaveMenu(popup) - return - end - popup.text:setText("Error: " .. updater.getlasterror()) return end From 41baefc92312a0d40d8c446fda5268e1af08cbb6 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 25 Jun 2022 21:16:41 +0200 Subject: [PATCH 11/15] Revert "Add scrollbar to server list" This reverts commit 9eeb46f4295ac4b20460fcdff26d11af18eec019. --- data/ui_scripts/server_list/serverlist.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/data/ui_scripts/server_list/serverlist.lua b/data/ui_scripts/server_list/serverlist.lua index 2bffdc1f..daed0300 100644 --- a/data/ui_scripts/server_list/serverlist.lua +++ b/data/ui_scripts/server_list/serverlist.lua @@ -206,10 +206,6 @@ function menu_systemlink_join(f19_arg0, f19_arg1) side = "all" }) - LUI.Options.InitScrollingList(menu.list, nil, { - rows = 18, - }) - menu:AddHelp({ name = "add_button_helper_text", button_ref = "button_alt1", From 4377ececf646a03725bef92842ef834c70384b0e Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 25 Jun 2022 22:06:25 +0200 Subject: [PATCH 12/15] Workaround for #98 --- data/ui_scripts/server_list/lobby.lua | 5 +++++ src/client/component/ui_scripting.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/data/ui_scripts/server_list/lobby.lua b/data/ui_scripts/server_list/lobby.lua index 93e01a90..0b9eb5c5 100644 --- a/data/ui_scripts/server_list/lobby.lua +++ b/data/ui_scripts/server_list/lobby.lua @@ -63,6 +63,11 @@ function menu_xboxlive(f16_arg0, f16_arg1) Engine.ExecNow("eliteclan_refresh", Engine.GetFirstActiveController()) end + menu:addElement(LUI.UITimer.new(4000, "vl")) + menu:registerEventHandler("vl", function() + game:virtuallobbypresentable() + end) + return menu end diff --git a/src/client/component/ui_scripting.cpp b/src/client/component/ui_scripting.cpp index 0c03036f..ef8c58a7 100644 --- a/src/client/component/ui_scripting.cpp +++ b/src/client/component/ui_scripting.cpp @@ -337,6 +337,12 @@ namespace ui_scripting }; } + game_type["virtuallobbypresentable"] = [](const game&) + { + static const auto presentable = ::game::Dvar_FindVar("virtualLobbyPresentable"); + presentable->current.enabled = true; + }; + auto updater_table = table(); lua["updater"] = updater_table; From 1d56b0f62224e23b2b64e63c44a58ea26057a1d5 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 25 Jun 2022 22:40:37 +0200 Subject: [PATCH 13/15] Better fix --- data/ui_scripts/server_list/lobby.lua | 15 ++++++++++++--- src/client/component/ui_scripting.cpp | 3 +-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/data/ui_scripts/server_list/lobby.lua b/data/ui_scripts/server_list/lobby.lua index 0b9eb5c5..20027026 100644 --- a/data/ui_scripts/server_list/lobby.lua +++ b/data/ui_scripts/server_list/lobby.lua @@ -63,9 +63,18 @@ function menu_xboxlive(f16_arg0, f16_arg1) Engine.ExecNow("eliteclan_refresh", Engine.GetFirstActiveController()) end - menu:addElement(LUI.UITimer.new(4000, "vl")) - menu:registerEventHandler("vl", function() - game:virtuallobbypresentable() + local root = Engine.GetLuiRoot() + if (root.vltimer) then + root.vltimer:close() + end + + root.vltimer = LUI.UITimer.new(4000, "vl") + root:addElement(root.vltimer) + root:registerEventHandler("vl", function() + if (Engine.GetDvarBool("virtualLobbyReady")) then + root.vltimer:close() + game:virtuallobbypresentable() + end end) return menu diff --git a/src/client/component/ui_scripting.cpp b/src/client/component/ui_scripting.cpp index ef8c58a7..ec6418c3 100644 --- a/src/client/component/ui_scripting.cpp +++ b/src/client/component/ui_scripting.cpp @@ -339,8 +339,7 @@ namespace ui_scripting game_type["virtuallobbypresentable"] = [](const game&) { - static const auto presentable = ::game::Dvar_FindVar("virtualLobbyPresentable"); - presentable->current.enabled = true; + ::game::Dvar_SetFromStringByNameFromSource("virtualLobbyPresentable", "1", ::game::DvarSetSource::DVAR_SOURCE_INTERNAL); }; auto updater_table = table(); From f726a388d5dbf31fb095064e096eed22c32ed760 Mon Sep 17 00:00:00 2001 From: mjkzy Date: Sat, 25 Jun 2022 16:56:19 -0500 Subject: [PATCH 14/15] games log file --- data/scripts/logging/__init__.lua | 117 ++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 data/scripts/logging/__init__.lua diff --git a/data/scripts/logging/__init__.lua b/data/scripts/logging/__init__.lua new file mode 100644 index 00000000..33db4cfc --- /dev/null +++ b/data/scripts/logging/__init__.lua @@ -0,0 +1,117 @@ +-- modified version of https://github.com/Joelrau/S1x-IW6x-g_log-script (permission to use by author) + +if (game:getdvar("gamemode") ~= "mp") then + return +end + +-- setup dvars +game:setdvarifuninitialized("logfile", 1) +if (tonumber(game:getdvar("logfile")) < 1) then + return +end +game:setdvarifuninitialized("g_log", "logs/games_mp.log") + +start_time = 0 + +function get_time() + local seconds = math.floor((game:gettime() - start_time) / 1000) + local minutes = math.floor(seconds / 60) + time = string.format("%d:%02d", minutes, seconds - minutes * 60) + while (string.len(time) < 6) do + time = " " .. time + end + time = time .. " " + return time +end + +function create_path(path) + local dir = path:gsub("%/", "\\"):match("(.*[\\])") + os.execute("if not exist " .. dir .. " mkdir " .. dir) +end + +function log_print(message) + local path = game:getdvar("g_log") + local file = io.open(path, "a") + if (file == nil) then + create_path(path) + file = assert(io.open(path, "a")) + end + file:write(get_time() .. message .. "\n") + file:close() +end + +function init() + start_time = game:gettime() + + log_print("------------------------------------------------------------") + log_print("InitGame") + + -- player callbacks + level:onnotify("connected", function(player) + player:player_connected() + end) + level:onnotify("say", function(player, message, hidden) + player:say(message) + end) + level:onnotify("say_team", function(player, message, hidden) + player:say(message, "say_team") + end) + + -- damage/killed hooks + game:onplayerdamage(player_damage) + game:onplayerkilled(player_killed) + + -- other level notifies for log + level:onnotify("exitLevel_called", function() + log_print("ExitLevel: executed") + end) + level:onnotify("shutdownGame_called", function() + log_print("ShutdownGame:") + log_print("------------------------------------------------------------") + end) +end + +function entity:player_connected() + log_print(string.format("J;%s;%i;%s", self:getguid(), self:getentitynumber(), self.name)) + + self:onnotifyonce("disconnect", function() + self:disconnect() + end) +end + +function entity:disconnect() + log_print(string.format("Q;%s;%i;%s", self:getguid(), self:getentitynumber(), self.name)) +end + +function player_damage(self_, inflictor, attacker, damage, dflags, mod, weapon, vPoint, vDir, hitLoc) + if (game:isplayer(attacker) == 1) then + log_print(string.format("D;%s;%i;%s;%s;%s;%i;%s;%s;%s;%i;%s;%s", self_:getguid(), self_:getentitynumber(), + self_.team, self_.name, attacker:getguid(), attacker:getentitynumber(), attacker.team, attacker.name, + weapon, damage, mod, hitLoc)) + else + log_print(string.format("D;%s;%i;%s;%s;%s;%i;%s;%s;%s;%i;%s;%s", self_:getguid(), self_:getentitynumber(), + self_.team, self_.name, "", "-1", "world", "", weapon, damage, mod, hitLoc)) + end +end + +function player_killed(self_, inflictor, attacker, damage, mod, weapon, vDir, hitLoc, psTimeOffset, deathAnimDuration) + if (game:isplayer(attacker) == 1) then + log_print(string.format("K;%s;%i;%s;%s;%s;%i;%s;%s;%s;%i;%s;%s", self_:getguid(), self_:getentitynumber(), + self_.team, self_.name, attacker:getguid(), attacker:getentitynumber(), attacker.team, attacker.name, + weapon, damage, mod, hitLoc)) + else + log_print(string.format("K;%s;%i;%s;%s;%s;%i;%s;%s;%s;%i;%s;%s", self_:getguid(), self_:getentitynumber(), + self_.team, self_.name, "", "-1", "world", "", weapon, damage, mod, hitLoc)) + end +end + +-- this function handles 'say' and 'say_team' +function entity:say(message, mode) + if (not mode) then + mode = "say" + end + + log_print(string.format("%s;%s;%i;%s;%s", mode, self:getguid(), self:getentitynumber(), self.name, message)) +end + +init() From fa410358ef5dd681c2e229adfd8fc144642c5ddd Mon Sep 17 00:00:00 2001 From: Skull <86374920+skkuull@users.noreply.github.com> Date: Sun, 26 Jun 2022 02:07:55 +0300 Subject: [PATCH 15/15] vector add also removes a dummy duplicate, nice catch Diamante --- src/client/game/scripting/lua/context.cpp | 5 ----- src/common/utils/vector.cpp | 7 +++++++ src/common/utils/vector.hpp | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/client/game/scripting/lua/context.cpp b/src/client/game/scripting/lua/context.cpp index 396b3837..42140a86 100644 --- a/src/client/game/scripting/lua/context.cpp +++ b/src/client/game/scripting/lua/context.cpp @@ -156,11 +156,6 @@ namespace scripting::lua return normalize_vector(a); }; - vector_type["normalize"] = [](const vector& a) - { - return normalize_vector(a); - }; - vector_type["toangles"] = [](const vector& a) { return call("vectortoangles", {a}).as(); diff --git a/src/common/utils/vector.cpp b/src/common/utils/vector.cpp index aa0357ef..81f4eff2 100644 --- a/src/common/utils/vector.cpp +++ b/src/common/utils/vector.cpp @@ -46,6 +46,13 @@ namespace utils::vector out[1] = veca[1] - vecb[1]; out[2] = veca[2] - vecb[2]; } + + void add(const float* veca, const float* vecb, float* out) + { + out[0] = veca[0] + vecb[0]; + out[1] = veca[1] + vecb[1]; + out[2] = veca[2] + vecb[2]; + } float length(float* v) { diff --git a/src/common/utils/vector.hpp b/src/common/utils/vector.hpp index 6bf74ae1..5700c5a3 100644 --- a/src/common/utils/vector.hpp +++ b/src/common/utils/vector.hpp @@ -7,6 +7,7 @@ namespace utils::vector void scale(const float* in, float scale, float* out); void ma(const float* v1, float scale, const float* v2, float* out); void subtract(const float* veca, const float* vecb, float* out); + void add(const float* veca, const float* vecb, float* out); float length(float* v); float product(const float* v1, const float* v2); }