Skip to content

Commit 0f2c4e6

Browse files
committed
fix: allow time portal placement in TAS
1 parent ac87466 commit 0f2c4e6

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/Features/ReloadedFix.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "Modules/Server.hpp"
44
#include "Modules/Engine.hpp"
55
#include "Modules/Client.hpp"
6+
#include "Event.hpp"
67
#include "Utils/SDK.hpp"
78
#include "SAR.hpp"
89

@@ -39,6 +40,12 @@ void ReloadedFix::OverrideInput(const char *className, const char *inputName, va
3940
std::string new_cmd = Utils::ssprintf("sv_cheats 1; %s; sv_cheats %s", paramStr.c_str(), sv_cheats.GetString());
4041
engine->Cbuf_AddText(2, new_cmd.c_str(), 0); // cbuf 2 = CBUF_SERVER; this is what a point_servercommand normally does
4142
}
43+
}
44+
// the game is using "+attack" inputs for detecting and placing time portals. Let TAS player know we actually want to use them!
45+
else if (paramStr.find("+attack") == 0) {
46+
isPlacingTimePortal = true;
47+
} else if (paramStr.find("-attack") == 0) {
48+
isPlacingTimePortal = false;
4249
}
4350
}
4451

@@ -49,6 +56,10 @@ void ReloadedFix::OverrideInput(const char *className, const char *inputName, va
4956
}
5057
}
5158

59+
ON_EVENT(SESSION_START) {
60+
reloadedFix->isPlacingTimePortal = false;
61+
}
62+
5263

5364
// this is a rewrite of a vscript function implemented in Reloaded with "fixed" change_portalgun_linkage_id
5465
void ReloadedFix::CustomSetPortalID() {

src/Features/ReloadedFix.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
class ReloadedFix : public Feature {
88
public:
99
bool inMapCheatsEnabled = false;
10+
bool isPlacingTimePortal = false;
1011
public:
1112
ReloadedFix();
1213
void OverrideInput(const char *className, const char *inputName, variant_t* parameter);

src/Modules/Server.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ DETOUR(Server::PlayerRunCommand, CUserCmd *cmd, void *moveHelper) {
227227

228228
Cheats::PatchBhop(thisptr, cmd);
229229

230+
// TAS playback overrides inputs, even if they're made by the map.
231+
// Allow Reloaded's +attack input for time portal.
232+
if (tasPlayer->IsActive() && reloadedFix->isPlacingTimePortal) {
233+
cmd->buttons |= IN_ATTACK;
234+
}
235+
230236
g_playerRunCommandHook.Disable();
231237
auto ret = Server::PlayerRunCommand(thisptr, cmd, moveHelper);
232238
g_playerRunCommandHook.Enable();

0 commit comments

Comments
 (0)