# HG changeset patch # User Wuzzy # Date 1557600192 -7200 # Node ID 9ab78e08a34c70fb51a418265c74164d4961fb18 # Parent 68e1783762bcb236624206acc326838d599b0dcf Fix Pas2C unable to compile with VIDEOREC diff -r 68e1783762bc -r 9ab78e08a34c hedgewars/uVideoRec.pas --- a/hedgewars/uVideoRec.pas Sat May 11 20:31:51 2019 +0200 +++ b/hedgewars/uVideoRec.pas Sat May 11 20:43:12 2019 +0200 @@ -69,6 +69,7 @@ var RGB_Buffer: PByte; cameraFile: File; + cameraFileName: shortstring; audioFile: File; numPixels: LongWord; startTime, numFrames, curTime, progress, maxProgress: LongWord; @@ -78,18 +79,19 @@ function BeginVideoRecording: Boolean; var filename, desc: shortstring; + filenameA, descA, soundFilePathA, cAVFormatA, cVideoCodecA, cAudioCodecA: ansistring; begin AddFileLog('BeginVideoRecording'); {$IOCHECKS OFF} // open file with prerecorded camera positions - filename:= shortstring(UserPathPrefix) + '/VideoTemp/' + shortstring(RecPrefix) + '.txtin'; - Assign(cameraFile, filename); + cameraFileName:= shortstring(UserPathPrefix) + '/VideoTemp/' + shortstring(RecPrefix) + '.txtin'; + Assign(cameraFile, cameraFileName); Reset(cameraFile, SizeOf(TFrame)); maxProgress:= FileSize(cameraFile); if IOResult <> 0 then begin - AddFileLog('Error: Could not read from ' + filename); + AddFileLog('Error: Could not read from ' + cameraFileName); exit(false); end; {$IOCHECKS ON} @@ -121,13 +123,19 @@ else soundFilePath:= ''; + filenameA:= ansistring(filename); + descA:= ansistring(desc); + soundFilePathA:= ansistring(soundFilePath); + cAVFormatA:= ansistring(cAVFormat); + cVideoCodecA:= ansistring(cVideoCodec); + cAudioCodecA:= ansistring(cAudioCodec); if checkFails(AVWrapper_Init(@AddFileLogRaw - , PChar(ansistring(filename)) - , PChar(ansistring(desc)) - , PChar(ansistring(soundFilePath)) - , PChar(ansistring(cAVFormat)) - , PChar(ansistring(cVideoCodec)) - , PChar(ansistring(cAudioCodec)) + , PChar(filenameA) + , PChar(descA) + , PChar(soundFilePathA) + , PChar(cAVFormatA) + , PChar(cVideoCodecA) + , PChar(cAudioCodecA) , cScreenWidth, cScreenHeight, cVideoFramerateNum, cVideoFramerateDen, cVideoQuality) >= 0, 'AVWrapper_Init failed', true) then exit(false); @@ -158,10 +166,8 @@ halt(HaltVideoRec); end; {$IOCHECKS OFF} - // Provoke IOResult to be set - FileSize(cameraFile); - if IOResult = 0 then - Erase(cameraFile) + if FileExists(cameraFileName) then + DeleteFile(cameraFileName) else AddFileLog('Warning: Tried to delete the cameraFile but it was already deleted'); {$IOCHECKS ON} @@ -192,14 +198,16 @@ function LoadNextCameraPosition(var newRealTicks, newGameTicks: LongInt): Boolean; var frame: TFrame = (realTicks: 0; gameTicks: 0; CamX: 0; CamY: 0; zoom: 0); + res: LongInt; begin // we need to skip or duplicate frames to match target framerate while Int64(curTime)*cVideoFramerateNum <= Int64(numFrames)*cVideoFramerateDen*1000 do begin + res:= 0; {$IOCHECKS OFF} if eof(cameraFile) then exit(false); - BlockRead(cameraFile, frame, 1); + BlockRead(cameraFile, frame, 1, res); {$IOCHECKS ON} curTime:= frame.realTicks; WorldDx:= frame.CamX; @@ -216,10 +224,12 @@ // Callback which records sound. // This procedure may be called from different thread. procedure RecordPostMix(udata: pointer; stream: PByte; len: LongInt); cdecl; +var result: LongInt; begin + result:= 0; // avoid warning udata:= udata; // avoid warning {$IOCHECKS OFF} - BlockWrite(audioFile, stream^, len); + BlockWrite(audioFile, stream^, len, result); {$IOCHECKS ON} end; @@ -238,11 +248,12 @@ procedure CopyFile(src, dest: shortstring); var inF, outF: file; buffer: array[0..1023] of byte; - result: LongInt; + result, result2: LongInt; i: integer; begin {$IOCHECKS OFF} result:= 0; // avoid compiler hint and warning + result2:= 0; // avoid compiler hint and warning for i:= 0 to 1023 do buffer[i]:= 0; @@ -264,7 +275,7 @@ repeat BlockRead(inF, buffer, 1024, result); - BlockWrite(outF, buffer, result); + BlockWrite(outF, buffer, result, result2); until result < 1024; {$IOCHECKS ON} end; @@ -273,11 +284,13 @@ var format: word; filename: shortstring; frequency, channels: LongInt; + result: LongInt; begin + result:= 0; AddFileLog('BeginPreRecording'); thumbnailSaved:= false; - RecPrefix:= 'hw-' + FormatDateTime('YYYY-MM-DD_HH-mm-ss-z', Now()); + RecPrefix:= 'hw-' + FormatDateTime('YYYY-MM-DD_HH-mm-ss-z', TDateTime(Now())); // If this video is recorded from demo executed directly (without frontend) // then we need to copy demo so that frontend will be able to find it later. @@ -324,8 +337,8 @@ if cIsSoundEnabled then begin // save audio parameters in sound file - BlockWrite(audioFile, frequency, 4); - BlockWrite(audioFile, channels, 4); + BlockWrite(audioFile, frequency, 4, result); + BlockWrite(audioFile, channels, 4, result); {$IOCHECKS ON} // register callback for actual audio recording @@ -360,7 +373,9 @@ procedure SaveCameraPosition; var frame: TFrame; + result: LongInt; begin + result:= 0; if (not thumbnailSaved) and (ScreenFade = sfNone) then SaveThumbnail(); @@ -369,7 +384,7 @@ frame.CamX:= WorldDx; frame.CamY:= WorldDy - cScreenHeight div 2; frame.zoom:= zoom/cScreenWidth; - BlockWrite(cameraFile, frame, 1); + BlockWrite(cameraFile, frame, 1, result); end; procedure initModule; diff -r 68e1783762bc -r 9ab78e08a34c hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Sat May 11 20:31:51 2019 +0200 +++ b/hedgewars/uWorld.pas Sat May 11 20:43:12 2019 +0200 @@ -1841,7 +1841,8 @@ end; DrawTexture( -(cScreenWidth shr 1) + 50, 20, recTexture); - a:= Byte(min(255, abs(-255 + ((RealTicks div 2) and 511)))); + t:= -255 + ((RealTicks div 2) and 511); + a:= Byte(min(255, abs(t))); // draw red circle DrawCircleFilled(-(cScreenWidth shr 1) + 30, 35, 10, $FF, $00, $00, a);