diff --git a/src/CrashHandler.cpp b/src/CrashHandler.cpp index b73c0c059..f57b13c67 100644 --- a/src/CrashHandler.cpp +++ b/src/CrashHandler.cpp @@ -172,10 +172,11 @@ static void handler(int signal, siginfo_t *info, void *ucontext) } #ifdef _WIN32 +static PVOID g_handle = nullptr; void CrashHandler::Init() { g_isMainThread = true; - AddVectoredExceptionHandler(1, &handler); + g_handle = AddVectoredExceptionHandler(1, &handler); HANDLE process = GetCurrentProcess(); SymInitialize(process, 0, true); @@ -189,7 +190,7 @@ void CrashHandler::Cleanup() { HANDLE process = GetCurrentProcess(); SymGetModuleInfo(process, (DWORD)&Utils::GetSARPath, &info); SymUnloadModule(process, info.BaseOfImage); - RemoveVectoredExceptionHandler(&handler); + RemoveVectoredExceptionHandler(g_handle); SymCleanup(GetCurrentProcess()); } diff --git a/src/Features/Demo/GhostRenderer.cpp b/src/Features/Demo/GhostRenderer.cpp index 74a54ff95..330ba3485 100644 --- a/src/Features/Demo/GhostRenderer.cpp +++ b/src/Features/Demo/GhostRenderer.cpp @@ -116,6 +116,9 @@ void GhostRenderer::UpdateAnimatedVerts() { localPos.x * yawSin + localPos.y * yawCos, localPos.z }; + if (ghost->name == "Dinnerbone") { + localPos.z = 72 - localPos.z; + } // transform it to global coordinates Vector globalPos = ghost->data.position + localPos; diff --git a/src/Features/Demo/NetworkGhostPlayer.cpp b/src/Features/Demo/NetworkGhostPlayer.cpp index 18841c9bd..1c5312c73 100644 --- a/src/Features/Demo/NetworkGhostPlayer.cpp +++ b/src/Features/Demo/NetworkGhostPlayer.cpp @@ -272,8 +272,8 @@ sf::Packet &operator<<(sf::Packet &packet, const Color &col) { return packet << col.r << col.g << col.b; } -Variable ghost_TCP_only("ghost_TCP_only", "0", "Lathil's special command :).\n"); -Variable ghost_update_rate("ghost_update_rate", "50", 1, "Adjust the update rate. For people with lathil's internet.\n"); +Variable ghost_TCP_only("ghost_TCP_only", "0", "Uses only TCP for ghost servers. For people with unreliable internet.\n"); +Variable ghost_update_rate("ghost_update_rate", "50", 1, "Milliseconds between ghost updates. For people with slow/metered internet.\n"); Variable ghost_net_dump("ghost_net_dump", "0", "Dump all ghost network activity to a file for debugging.\n"); static FILE *g_dumpFile; diff --git a/src/Features/Hud/Hud.cpp b/src/Features/Hud/Hud.cpp index 59e1d270b..957c1dd8b 100644 --- a/src/Features/Hud/Hud.cpp +++ b/src/Features/Hud/Hud.cpp @@ -309,7 +309,7 @@ DECL_AUTO_COMMAND_COMPLETION(sar_hud_order_bottom, (elementOrder)) CON_COMMAND_F_COMPLETION(sar_hud_order_top, "sar_hud_order_top - orders hud element to top\n", FCVAR_DONTRECORD, AUTOCOMPLETION_FUNCTION(sar_hud_order_top)) { if (args.ArgC() != 2) { - return console->Print("Orders hud element to top: sar_hud_order_top \n"); + return console->Print(sar_hud_order_top.ThisPtr()->m_pszHelpString); } auto elements = &vgui->elements; @@ -335,7 +335,7 @@ CON_COMMAND_F_COMPLETION(sar_hud_order_top, "sar_hud_order_top - orders h } CON_COMMAND_F_COMPLETION(sar_hud_order_bottom, "sar_hud_order_bottom - orders hud element to bottom\n", FCVAR_DONTRECORD, AUTOCOMPLETION_FUNCTION(sar_hud_order_bottom)) { if (args.ArgC() != 2) { - return console->Print("Set!\n"); + return console->Print(sar_hud_order_bottom.ThisPtr()->m_pszHelpString); } auto elements = &vgui->elements; diff --git a/src/Features/Hud/PortalPlacement.cpp b/src/Features/Hud/PortalPlacement.cpp index 797e25466..b215c61d4 100644 --- a/src/Features/Hud/PortalPlacement.cpp +++ b/src/Features/Hud/PortalPlacement.cpp @@ -3,6 +3,7 @@ #include "Command.hpp" #include "Variable.hpp" #include "Event.hpp" +#include "Features/Camera.hpp" #include "Features/OverlayRender.hpp" #include "Features/Session.hpp" #include "Modules/Client.hpp" @@ -101,8 +102,9 @@ ON_EVENT(PRE_TICK) { if (player == nullptr || (int)player == -1) return; - Vector camPos = server->GetAbsOrigin(player) + server->GetViewOffset(player); - QAngle angle = engine->GetAngles(GET_SLOT()); + Vector camPos; + QAngle angle; + camera->GetEyePos(GET_SLOT(), camPos, angle); float X = DEG2RAD(angle.x), Y = DEG2RAD(angle.y); auto cosX = std::cos(X), cosY = std::cos(Y); diff --git a/src/Features/Hud/Watermark.cpp b/src/Features/Hud/Watermark.cpp index 01f08aa53..accae5d98 100644 --- a/src/Features/Hud/Watermark.cpp +++ b/src/Features/Hud/Watermark.cpp @@ -33,7 +33,7 @@ class WatermarkHud : public Hud { int fontSize = surface->GetFontHeight(headerFont); - int xPos = screenWidth - surface->GetFontLength(subTextFont, "%s", WATERMARK_MSG_HELPTEXT) - fontSize * 2; + int xPos = screenWidth - std::max(surface->GetFontLength(headerFont, "%s", WATERMARK_MSG_HEADER), surface->GetFontLength(subTextFont, "%s", WATERMARK_MSG_HELPTEXT)) - fontSize * 2; surface->DrawTxt(headerFont, xPos, screenHeight - fontSize * 3, Color{255, 255, 255, 100}, "%s", WATERMARK_MSG_HEADER); surface->DrawTxt(subTextFont, xPos, screenHeight - fontSize * 2, Color{255, 255, 255, 100}, "%s", WATERMARK_MSG_HELPTEXT); diff --git a/src/Features/PlayerTrace.cpp b/src/Features/PlayerTrace.cpp index e9e9a78bb..3c115ebf6 100644 --- a/src/Features/PlayerTrace.cpp +++ b/src/Features/PlayerTrace.cpp @@ -133,7 +133,7 @@ void PlayerTrace::AddPoint(std::string trace_name, void *player, int slot, bool // update this bad boy every tick because it doesn't like being tinkered with at the // very beginning of the level. fussy guy, lemme tell ya if (tasPlayer->IsRunning()) { - int ticksSinceStartup = (int)trace.positions[0].size() + 1; // include point we're about to add + int ticksSinceStartup = (int)trace.positions[0].size() + (int)(tasPlayer->GetTick() == 0); // include point we're about to add traces[trace_name].startTasTick = tasPlayer->GetTick() - ticksSinceStartup; } @@ -255,7 +255,7 @@ void PlayerTrace::DrawInWorld() const { float speed = trace.velocities[slot][0].Length2D(); unsigned groundframes = trace.grounded[slot][0]; - for (size_t i = 1; i < trace.positions[slot].size(); i++) { + for (size_t i = 0; i < trace.positions[slot].size(); i++) { Vector new_pos = trace.positions[slot][i]; speed = trace.velocities[slot][i].Length2D(); diff --git a/src/Features/SegmentedTools.cpp b/src/Features/SegmentedTools.cpp index 66ed6d281..b54e17a33 100644 --- a/src/Features/SegmentedTools.cpp +++ b/src/Features/SegmentedTools.cpp @@ -83,7 +83,7 @@ ON_EVENT(PRE_TICK) { CON_COMMAND_F(hwait, "hwait [args...] - run a command after the given number of host ticks\n", FCVAR_DONTRECORD) { if (args.ArgC() < 3) { - return console->Print(waitCmd.ThisPtr()->m_pszHelpString); + return console->Print(hwait.ThisPtr()->m_pszHelpString); } int ticks = std::atoi(args[1]); diff --git a/src/Features/Speedrun/Categories.cpp b/src/Features/Speedrun/Categories.cpp index 09da630e4..47e8b3c7e 100644 --- a/src/Features/Speedrun/Categories.cpp +++ b/src/Features/Speedrun/Categories.cpp @@ -465,7 +465,7 @@ static int _sar_speedrun_category_remove_rule_completion(const char *partial, ch CON_COMMAND_F_COMPLETION(sar_speedrun_category_remove_rule, "sar_speedrun_category_remove_rule - remove a rule from a speedrun category\n", 0, &_sar_speedrun_category_remove_rule_completion) { if (args.ArgC() != 3) { - return console->Print(sar_speedrun_category_add_rule.ThisPtr()->m_pszHelpString); + return console->Print(sar_speedrun_category_remove_rule.ThisPtr()->m_pszHelpString); } auto cat = lookupMap(g_categories, args[1]); diff --git a/src/Features/Tas/TasParser.cpp b/src/Features/Tas/TasParser.cpp index 5a65c684d..65bb6a381 100644 --- a/src/Features/Tas/TasParser.cpp +++ b/src/Features/Tas/TasParser.cpp @@ -384,6 +384,19 @@ static Vector parseVector(const Line &line, size_t idx) { else if (t1.type == TasToken::FLOAT) vec.y = t1.f; else throw TasParserException(Utils::ssprintf("expected vector B %d '%s'", (int)t1.type, t1.tok.c_str())); + if (idx + 2 < line.tokens.size()) { + auto &t3 = line.tokens[idx + 2]; + switch (t3.type) { + case TasToken::PIPE: + break; + case TasToken::INTEGER: + case TasToken::FLOAT: + throw TasParserException("invalid vector param count"); + default: + throw TasParserException(Utils::ssprintf("expected end of vector, found '%s'", t3.tok.c_str())); + } + } + return vec; } diff --git a/src/Modules/Server.cpp b/src/Modules/Server.cpp index c02ab7a2c..5af602351 100644 --- a/src/Modules/Server.cpp +++ b/src/Modules/Server.cpp @@ -923,7 +923,7 @@ CON_COMMAND(sar_give_fly, "sar_give_fly [n] - gives the player in slot n (0 by d } } CON_COMMAND(sar_give_betsrighter, "sar_give_betsrighter [n] - gives the player in slot n (0 by default) betsrighter.\n") { - if (args.ArgC() > 2) return console->Print(sar_give_fly.ThisPtr()->m_pszHelpString); + if (args.ArgC() > 2) return console->Print(sar_give_betsrighter.ThisPtr()->m_pszHelpString); if (!sv_cheats.GetBool()) return console->Print("sar_give_betsrighter requires sv_cheats.\n"); int slot = args.ArgC() == 2 ? atoi(args[1]) : 0; ServerEnt *player = server->GetPlayer(slot + 1); diff --git a/src/Plugin.hpp b/src/Plugin.hpp index 89e823fe9..6ff793f15 100644 --- a/src/Plugin.hpp +++ b/src/Plugin.hpp @@ -1,8 +1,7 @@ #pragma once #include "Utils.hpp" -#define SAR_PLUGIN_SIGNATURE \ - new char[26] { 65, 114, 101, 32, 121, 111, 117, 32, 104, 97, 112, 112, 121, 32, 110, 111, 119, 44, 32, 74, 97, 109, 101, 114, 63, 00 } +#define SAR_PLUGIN_SIGNATURE "SourceAutoRecord v" SAR_VERSION // CServerPlugin #define CServerPlugin_m_Size 16