From: DeaDDooMER Date: Sat, 2 Nov 2019 19:47:05 +0000 (+0300) Subject: flush screenshot after writing X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=9158232a5a7a8915e2d74eed386dacd01c7addd6;p=d2df-sdl.git flush screenshot after writing --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index ec7f8f2..63fc317 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -7249,16 +7249,24 @@ begin end; procedure g_TakeScreenShot; - var s: TStream; t: TDateTime; date, name: String; + var s: TStream; t: TDateTime; dir, date, name: String; begin if e_NoGraphics then Exit; - t := Now; - DateTimeToString(date, 'yyyy-mm-dd-hh-nn-ss', t); - name := 'screenshot-' + date + '.png'; try - s := e_CreateResource(ScreenshotDirs, name); - e_MakeScreenshot(s, gScreenWidth, gScreenHeight); - g_Console_Add(Format(_lc[I_CONSOLE_SCREENSHOT], [name])) + t := Now; + dir := e_GetWriteableDir(ScreenshotDirs); + DateTimeToString(date, 'yyyy-mm-dd-hh-nn-ss', t); + name := e_CatPath(dir, 'screenshot-' + date + '.png'); + s := createDiskFile(name); + try + e_MakeScreenshot(s, gScreenWidth, gScreenHeight); + s.Free; + g_Console_Add(Format(_lc[I_CONSOLE_SCREENSHOT], [name])) + except + g_Console_Add(Format(_lc[I_CONSOLE_ERROR_WRITE], [name])); + s.Free; + DeleteFile(name) + end except g_Console_Add('oh shit, i can''t create screenshot!') end