Skip to content

Commit

Permalink
Merge branch 'p2sr:master' into feature/novmshadows
Browse files Browse the repository at this point in the history
  • Loading branch information
hero622 committed Oct 22, 2023
2 parents 0b9104c + b762a47 commit 7dc7ec3
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 16 deletions.
5 changes: 3 additions & 2 deletions src/CrashHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
}

Expand Down
3 changes: 3 additions & 0 deletions src/Features/Demo/GhostRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Features/Demo/NetworkGhostPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Features/Hud/Hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <name> - 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 <name>\n");
return console->Print(sar_hud_order_top.ThisPtr()->m_pszHelpString);
}

auto elements = &vgui->elements;
Expand All @@ -335,7 +335,7 @@ CON_COMMAND_F_COMPLETION(sar_hud_order_top, "sar_hud_order_top <name> - orders h
}
CON_COMMAND_F_COMPLETION(sar_hud_order_bottom, "sar_hud_order_bottom <name> - 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;
Expand Down
6 changes: 4 additions & 2 deletions src/Features/Hud/PortalPlacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<true>(GET_SLOT(), camPos, angle);

float X = DEG2RAD(angle.x), Y = DEG2RAD(angle.y);
auto cosX = std::cos(X), cosY = std::cos(Y);
Expand Down
2 changes: 1 addition & 1 deletion src/Features/Hud/Watermark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Features/PlayerTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/Features/SegmentedTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ ON_EVENT(PRE_TICK) {

CON_COMMAND_F(hwait, "hwait <tick> <command> [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]);
Expand Down
2 changes: 1 addition & 1 deletion src/Features/Speedrun/Categories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <category> <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]);
Expand Down
13 changes: 13 additions & 0 deletions src/Features/Tas/TasParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Modules/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/Plugin.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 7dc7ec3

Please sign in to comment.