From eacb83a2443ee5a7fe6f597095ce94a31fe023c2 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Fri, 26 Feb 2021 23:46:30 -0500 Subject: [PATCH 1/5] Allow using pulseaudio for SDL audio capture Pulseaudio audio capture didn't stop when paused on Debian 8 but works on Debian 9 when using the same manual SDL build. So it seems to have been an issue in pulseaudio, not SDL. --- code/sdl/sdl_snd.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/code/sdl/sdl_snd.c b/code/sdl/sdl_snd.c index eb0dd58f..7696a515 100644 --- a/code/sdl/sdl_snd.c +++ b/code/sdl/sdl_snd.c @@ -281,12 +281,7 @@ qboolean SNDDMA_Init(void) #ifdef USE_SDL_AUDIO_CAPTURE // !!! FIXME: some of these SDL_OpenAudioDevice() values should be cvars. s_sdlCapture = Cvar_Get( "s_sdlCapture", "1", CVAR_ARCHIVE | CVAR_LATCH ); - // !!! FIXME: pulseaudio capture records audio the entire time the program is running. https://bugzilla.libsdl.org/show_bug.cgi?id=4087 - if (Q_stricmp(SDL_GetCurrentAudioDriver(), "pulseaudio") == 0) - { - Com_Printf("SDL audio capture support disabled for pulseaudio (https://bugzilla.libsdl.org/show_bug.cgi?id=4087)\n"); - } - else if (!s_sdlCapture->integer) + if (!s_sdlCapture->integer) { Com_Printf("SDL audio capture support disabled by user ('+set s_sdlCapture 1' to enable)\n"); } From 359db19619417117d5cd5cb8fada93e694198767 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sat, 27 Feb 2021 00:09:15 -0500 Subject: [PATCH 2/5] Restore bots crushing unseen player on q3tourney6 in non-CTF The affect of my 2017 commit c3e64d380685419f96f71035c961907b9dc09a9a "Make bots only use q3tourney6 crusher to kill their enemy" made it easier to beat the last map of the Quake 3 single player campaign. It was mainly intended for CTF and Team Arena gametypes variants of the map. (Team deathmatch is usually treated as deathmatch with teams rather than an actual team based gametype.) Restore original difficulty for non-CTF/Team Arena gametypes; bot will crush player even if bot hasn't seen the player since either they or player respawned. [This is not good in CTF where all five bots on the team suddenly flip around and shoot at the crusher trigger.] Team deathmatch still uses my added behavior of not triggering crusher if there is a teammate under the crusher. --- code/game/ai_dmq3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/ai_dmq3.c b/code/game/ai_dmq3.c index 30df7acb..3ecaccb7 100644 --- a/code/game/ai_dmq3.c +++ b/code/game/ai_dmq3.c @@ -3733,7 +3733,7 @@ void BotMapScripts(bot_state_t *bs) { shootbutton = qfalse; break; } - else if (bs->enemy == i) { + else if (gametype < GT_CTF || bs->enemy == i) { shootbutton = qtrue; } } From 4003a5b78c217588ab2cb23243e693f35d90aba0 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Wed, 17 Mar 2021 12:22:13 -0400 Subject: [PATCH 3/5] Fix the number of weights in the IQM model calculation [The fourth bone influence of each vertex was ignored. --zturtleman] Patch by Romulo Fernandes (razor85). --- code/renderergl1/tr_model_iqm.c | 2 +- code/renderergl2/tr_model_iqm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/renderergl1/tr_model_iqm.c b/code/renderergl1/tr_model_iqm.c index fe205ff4..5050eb10 100644 --- a/code/renderergl1/tr_model_iqm.c +++ b/code/renderergl1/tr_model_iqm.c @@ -1346,7 +1346,7 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { vtxMat[10] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 10]; vtxMat[11] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 11]; - for( j = 1; j < 3; j++ ) { + for( j = 1; j < 4; j++ ) { if ( blendWeights[j] <= 0.0f ) { break; } diff --git a/code/renderergl2/tr_model_iqm.c b/code/renderergl2/tr_model_iqm.c index fc345a32..cc12faf4 100644 --- a/code/renderergl2/tr_model_iqm.c +++ b/code/renderergl2/tr_model_iqm.c @@ -1528,7 +1528,7 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { vtxMat[10] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 10]; vtxMat[11] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 11]; - for( j = 1; j < 3; j++ ) { + for( j = 1; j < 4; j++ ) { if ( blendWeights[j] <= 0.0f ) { break; } From 60a20004193f000a6bcc35d1237dabbcc4229143 Mon Sep 17 00:00:00 2001 From: Ch40zz Date: Wed, 19 May 2021 18:55:58 +0200 Subject: [PATCH 4/5] Fixes a crash when compiling the project on windows in 64 bit mode. Not all non-volatile registers were actually saved and restored, leading to a few registers being trashed after calling the vm instructions. All non-volatile registers have been added. --- code/asm/vm_x86_64.asm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/code/asm/vm_x86_64.asm b/code/asm/vm_x86_64.asm index 87e04f4d..f39289ec 100644 --- a/code/asm/vm_x86_64.asm +++ b/code/asm/vm_x86_64.asm @@ -30,9 +30,15 @@ ; uint8_t qvmcall64(int *programStack, int *opStack, intptr_t *instructionPointers, byte *dataBase); qvmcall64 PROC - push rsi ; push non-volatile registers to stack + push r12 ; push all non-volatile registers to stack + push r13 + push r14 + push r15 push rdi + push rsi push rbx + push rbp + ; need to save pointer in rcx so we can write back the programData value to caller push rcx @@ -48,9 +54,14 @@ qvmcall64 PROC mov dword ptr [rcx], esi ; write back the programStack value mov al, bl ; return opStack offset + pop rbp ; restore all non-volatile registers after the call pop rbx - pop rdi pop rsi + pop rdi + pop r15 + pop r14 + pop r13 + pop r12 ret qvmcall64 ENDP From bc7842e301f39df5cbe1bbb1da29831021fd7a7f Mon Sep 17 00:00:00 2001 From: Ch40zz Date: Wed, 23 Jun 2021 18:17:36 +0200 Subject: [PATCH 5/5] Allow unwinding of qvmcall64 call-stub for msvc/masm qvmcall64 has its own custom calling convention due to pushing all non-volatile registers to the stack. The game uses set/longjmp which on Windows uses "RtlUnwindEx" to unwind the callstack. qvmcall64 cannot be unwound by default due to the custom calling convention. To allow unwinding, we need to add custom SEH unwind data to the function. --- code/asm/vm_x86_64.asm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/code/asm/vm_x86_64.asm b/code/asm/vm_x86_64.asm index f39289ec..f84eb8f8 100644 --- a/code/asm/vm_x86_64.asm +++ b/code/asm/vm_x86_64.asm @@ -28,19 +28,35 @@ ; Call to compiled code after setting up the register environment for the VM ; prototype: ; uint8_t qvmcall64(int *programStack, int *opStack, intptr_t *instructionPointers, byte *dataBase); +; +; This call-stub has its own custom calling convention due to pushing all non-volatile registers +; to the stack. The game uses set/longjmp which on Windows uses "RtlUnwindEx" to unwind the callstack. +; This function cannot be unwound by default due to the custom calling convention. +; To allow unwinding, we need to add custom SEH unwind data to the function. -qvmcall64 PROC +qvmcall64 PROC FRAME push r12 ; push all non-volatile registers to stack + .pushreg r12 push r13 + .pushreg r13 push r14 + .pushreg r14 push r15 + .pushreg r15 push rdi + .pushreg rdi push rsi + .pushreg rsi push rbx + .pushreg rbx push rbp + .pushreg rbp ; need to save pointer in rcx so we can write back the programData value to caller push rcx + .pushreg rcx + + .endprolog ; custom unwind data ends here ; registers r8 and r9 have correct value already thanx to __fastcall xor rbx, rbx ; opStackOfs starts out being 0