From de0cd8796d835061898edb3ea89d9a3c84df859f Mon Sep 17 00:00:00 2001 From: Matthew Wozniak Date: Sun, 10 Nov 2024 22:40:14 -0500 Subject: Small code changes; add ability to find audio functions and data. Audio is weird. I've been working for a few days to figure out how to correctly render the audio but in that time I've done some other minor refactors so I figured I migth as well just push those. Audio should be coming soon, but no promises. --- main.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 4775b48..440e9c3 100644 --- a/main.c +++ b/main.c @@ -35,6 +35,7 @@ struct { int qvs; const char *out; const char **demo; + int demo_count; bool combine; } args = {0}; @@ -42,13 +43,14 @@ void (*orig_cbuf_addtext)(char *); void hook_cbuf_addtext(char *str) { orig_cbuf_addtext(str); // this is the last thing that happens when the game is opened - if (!strcmp(str, "exec modsettings.cfg mod\n")) { - bool use_bitrate = !!args.bitrate; - if (!render_init(args.width, args.height, args.fps, use_bitrate, - use_bitrate ? args.bitrate : args.quality, args.out, args.qvs)) + if (!strcmp(str, "exec valve.rc\n")) { + // after sound has been init'd, we can finish this + if (!api_find_snd_recordbuffer()) + die("couldn't find SND_RecordBuffer"); + if (!render_init()) die("couldn't init render"); - // play the demo demoplayer->vt->start_playback(demoplayer, args.demo[0], false); + orig_cbuf_addtext("exec prerender"); } } @@ -69,7 +71,7 @@ void WINAPI *hook_LoadLibraryExA(const char *filename, void *hfile, int flags) { for (const char *p = filename; *p; p++) if (*p == '\\') basename = p + 1; - if (!strcmp(basename, "engine.dll")) { + if (!strcmp(basename, "gameui.dll")) { if (!api_init()) die("couldn't get apis"); orig_cbuf_addtext = (void (*)(char *)) hook_inline((void *)cbuf_addtext, (void *)hook_cbuf_addtext); @@ -146,6 +148,7 @@ int main(int argc, const char **argv) { } args.out = argv[0]; args.demo = argv + 1; + args.demo_count = argc - 2; sprintf(cmdline, "hl2.exe -game %s -w %d -h %d -window -console", args.game, args.width, args.height); -- cgit v1.2.3-54-g00ecf