shithub: duke3d

Download patch

ref: ae7d809837d788a32a28c4ce50ece3e037c4d069
parent: b844bf5d93d962c5db583fe342c3c1f80130fe44
author: Tanguy Fautre <[email protected]>
date: Sat Feb 22 13:19:19 EST 2020

Fix screenshots not working.

--- a/Engine/src/display.c
+++ b/Engine/src/display.c
@@ -690,15 +690,17 @@
 }
 
 // Capture BMP of the current frame
-int screencapture(char  *filename, uint8_t  inverseit)
+void screencapture(char  *filename)
 {
 //  FIX_00006: better naming system for screenshots + message when pic is taken. 
 //  Use ./screenshots folder. Screenshot code rerwritten. Faster and
 //  makes smaller files. Doesn't freeze or lag the game anymore.
   
-	SDL_SaveBMP(surface, filename);  
-	return 0;
-} /* screencapture */
+	if (SDL_SaveBMP(surface, filename))
+	{
+		printf("SDL failed to save screenshot '%s' (%s)\n", filename, SDL_GetError());
+	}
+}
 
 
 void setvmode(int mode)
--- a/Engine/src/engine.h
+++ b/Engine/src/engine.h
@@ -69,7 +69,7 @@
 void plotpixel(int32_t x, int32_t y, uint8_t  col);
 uint8_t  getpixel(int32_t x, int32_t y);
 void setbrightness(uint8_t  dabrightness, uint8_t  *dapal);
-int screencapture(char  *filename, uint8_t  inverseit);
+void screencapture(char  *filename);
 void getmousevalues(int16_t *mousx, int16_t *mousy, int16_t *bstatus);
 int clipmove (int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t xvect,int32_t yvect, int32_t walldist, int32_t ceildist,int32_t flordist, uint32_t  cliptype);
 void getzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum,int32_t *ceilz, int32_t *ceilhit, int32_t *florz, int32_t *florhit,int32_t walldist, uint32_t  cliptype);
--- a/Game/src/game.c
+++ b/Game/src/game.c
@@ -10597,7 +10597,7 @@
 			else
 				strcat(text, " vs ");
 		}	
-		tempbuf[strlen(text)-4]=0; // remove last vs
+        text[strlen(text)-4]=0; // remove last vs
 		strcat(text, "]");
 	}
 	strcat(text, ".bmp");
@@ -10608,23 +10608,23 @@
 	{
 		sprintf(szFilename, "%s\\%s", getGameDir(), SCREENSHOTPATH);
 		mkdir(szFilename);
-		sprintf(szFilename, "%s\\%s\\%s", getGameDir(), SCREENSHOTPATH, tempbuf);
+		sprintf(szFilename, "%s\\%s\\%s", getGameDir(), SCREENSHOTPATH, text);
 	}
 	// otherwise let's save it to the root.
 	else
 	{
 		mkdir(SCREENSHOTPATH);
-		sprintf(szFilename, "%s\\%s", SCREENSHOTPATH, tempbuf);
+		sprintf(szFilename, "%s\\%s", SCREENSHOTPATH, text);
 	}
 
 	if(SafeFileExists(szFilename) == 0)
 	{
-		screencapture(szFilename,0);
+		screencapture(szFilename);
 		sprintf(fta_quotes[103],"SCREEN SAVED");  
 		sound(EXITMENUSOUND);
 	}
 	else
-		sprintf(fta_quotes[103],"CAN'T WRITE FILE!");
+		sprintf(fta_quotes[103],"CAN'T WRITE FILE! FILE ALREADY EXISTS!");
 
 	FTA(103,&ps[screenpeek],1);