summaryrefslogtreecommitdiffhomepage
path: root/src/sst.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-05-16 22:15:53 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2022-05-19 12:54:33 +0100
commitfb9720610488c2d8da1bd77739b01d8275735b49 (patch)
tree421bed3a0a1487557fef9e61ec38c93099b8ef65 /src/sst.c
parent278b61bc3f2018515e26fd6b45410aded8b6417e (diff)
Add a quick stopgap hack for Portal purposes
People want to be able to write a scheduled-release passphrase to demos to prove that said demos were recorded during a timeboxed event. Ideally this is something that'd be part of the custom demo data and general RTA run management stuff that's planned, but of course that doesn't exist yet. When it does exist, we'd probably want rid of this nonsense, so it's marked hidden and I don't plan to document it anywhere "official." It's just here for people who really need it in the short term.
Diffstat (limited to 'src/sst.c')
-rw-r--r--src/sst.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/sst.c b/src/sst.c
index edd083f..3ad48cc 100644
--- a/src/sst.c
+++ b/src/sst.c
@@ -385,11 +385,35 @@ static const char *VCALLCONV GetPluginDescription(void *this) {
return LONGNAME " v" VERSION;
}
+DECL_VFUNC_DYN(void, ServerCommand, const char *)
+
+// XXX: quick hack requested by Portal people for some timeboxed IL grind
+// challenge they want to do. I think this is a terribly sad way to do this but
+// at the same time it's easy and low-impact so put it in as hidden for now
+// until we come up with something better later.
+DEF_CVAR(_sst_onload_echo, "EXPERIMENTAL! Don't rely on this existing!", "",
+ CON_HIDDEN)
+
static void VCALLCONV ClientActive(void *this, struct edict *player) {
// XXX: it's kind of dumb that we get handed the edict here then go look it
// up again in fov.c but I can't be bothered refactoring any further now
// that this finally works, do something later lol
if (has_fov) fov_onload();
+
+ // continuing dumb portal hack. didn't even seem worth adding a feature for
+ if (has_vtidx_ServerCommand && con_getvarstr(_sst_onload_echo)[0]) {
+ char *s = malloc(8 + _sst_onload_echo->strlen); // dumb lol
+ if (s) { // if not, game probably exploded already
+ memcpy(s, "echo \"", 6);
+ // note: assume there's no quotes in the variable, because there
+ // should be no way to do this at least via console
+ memcpy(s + 6, con_getvarstr(_sst_onload_echo),
+ _sst_onload_echo->strlen);
+ memcpy(s + 6 + _sst_onload_echo->strlen - 1, "\"\n", 3);
+ VCALL(engserver, ServerCommand, s);
+ free(s);
+ }
+ }
}
#define MAX_VTABLE_FUNCS 21