# HG changeset patch # User Wuzzy # Date 1563816418 -7200 # Node ID 22f2fd8a3d2c9f6d35cf72bae101fcd5809ba352 # Parent b58f98bbc120ac3c35319e645e7c8608a9ec53f9 VideoRec: Stop prerecording when /lua activates diff -r b58f98bbc120 -r 22f2fd8a3d2c hedgewars/uChat.pas --- a/hedgewars/uChat.pas Thu Jul 25 16:29:14 2019 +0300 +++ b/hedgewars/uChat.pas Mon Jul 22 19:26:58 2019 +0200 @@ -35,7 +35,8 @@ procedure TextInput(var event: TSDL_TextInputEvent); implementation -uses uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO, uScript, uRenderUtils, uLocale; +uses uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO, uScript, uRenderUtils, uLocale + {$IFDEF USE_VIDEO_RECORDING}, uVideoRec{$ENDIF}; const MaxStrIndex = 27; MaxInputStrLen = 200; @@ -548,7 +549,15 @@ if (copy(s, 2, 3) = 'lua') then begin + LuaCmdUsed:= true; AddFileLog('/lua issued'); +{$IFDEF USE_VIDEO_RECORDING} + if flagPrerecording then + begin + AddFileLog('Force-stopping prerecording! Lua commands can not be recorded'); + StopPreRecording; + end; +{$ENDIF} if gameType <> gmtNet then begin liveLua:= (not liveLua); diff -r b58f98bbc120 -r 22f2fd8a3d2c hedgewars/uVariables.pas --- a/hedgewars/uVariables.pas Thu Jul 25 16:29:14 2019 +0300 +++ b/hedgewars/uVariables.pas Mon Jul 22 19:26:58 2019 +0200 @@ -280,6 +280,9 @@ // whether Lua requested to pause the clock LuaClockPaused: boolean; + // whether /lua command was used + LuaCmdUsed: boolean; + MaskedSounds : array[TSound] of boolean; LastVoice : TVoice; @@ -3007,6 +3010,8 @@ LuaEndTurnRequested:= false; LuaNoEndTurnTaunts:= false; + LuaCmdUsed:= false; + for t:= Low(TSound) to High(TSound) do MaskedSounds[t]:= false; diff -r b58f98bbc120 -r 22f2fd8a3d2c hedgewars/uVideoRec.pas --- a/hedgewars/uVideoRec.pas Thu Jul 25 16:29:14 2019 +0300 +++ b/hedgewars/uVideoRec.pas Mon Jul 22 19:26:58 2019 +0200 @@ -48,7 +48,7 @@ procedure freeModule; implementation -uses uVariables, GLunit, SDLh, SysUtils, uUtils, uIO, uMisc, uTypes, uDebug; +uses uVariables, GLunit, SDLh, SysUtils, uUtils, uSound, uIO, uMisc, uTypes, uDebug; type TAddFileLogRaw = procedure (s: pchar); cdecl; const AvwrapperLibName = 'libavwrapper'; @@ -286,6 +286,14 @@ begin result:= 0; AddFileLog('BeginPreRecording'); + // Videos don't work if /lua command was used, so we forbid them + if luaCmdUsed then + begin + // TODO: Show message to player + PlaySound(sndDenied); + AddFileLog('Pre-recording prevented; /lua command was used before'); + exit; + end; thumbnailSaved:= false; RecPrefix:= 'hw-' + FormatDateTime('YYYY-MM-DD_HH-mm-ss-z', TDateTime(Now()));