Fix reading source in levelshot command

Fix using offset for source returned by RB_ReadPixels(). In practice
this shouldn't be an issue because Hunk_AllocateTempMemory() should
already be aligned to sizeof(intptr_t).
This commit is contained in:
Zack Middleton 2024-05-24 17:09:38 -05:00
parent 6fed956d95
commit c010b1ffee
2 changed files with 8 additions and 6 deletions

View file

@ -531,7 +531,7 @@ the menu system, sampled down from full screen distorted images
*/
void R_LevelShot( screenshotType_e type, const char *ext ) {
char fileName[MAX_OSPATH];
byte *source;
byte *source, *allsource;
byte *resample, *resamplestart;
size_t offset = 0, memcount;
int spadlen, rpadlen;
@ -559,7 +559,8 @@ void R_LevelShot( screenshotType_e type, const char *ext ) {
Com_sprintf(fileName, sizeof(fileName), "levelshots/%s%s", tr.world->baseName, ext);
source = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &spadlen);
allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &spadlen);
source = allsource + offset;
//
// Based on RB_ReadPixels
@ -613,7 +614,7 @@ void R_LevelShot( screenshotType_e type, const char *ext ) {
RE_SavePNG(fileName, width, height, resample + offset, rpadlen);
ri.Hunk_FreeTempMemory(resample);
ri.Hunk_FreeTempMemory(source);
ri.Hunk_FreeTempMemory(allsource);
ri.Printf( PRINT_ALL, "Wrote %s\n", fileName );
}

View file

@ -622,7 +622,7 @@ the menu system, sampled down from full screen distorted images
*/
void R_LevelShot( screenshotType_e type, const char *ext ) {
char fileName[MAX_OSPATH];
byte *source;
byte *source, *allsource;
byte *resample, *resamplestart;
size_t offset = 0, memcount;
int spadlen, rpadlen;
@ -650,7 +650,8 @@ void R_LevelShot( screenshotType_e type, const char *ext ) {
Com_sprintf(fileName, sizeof(fileName), "levelshots/%s%s", tr.world->baseName, ext);
source = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &spadlen);
allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &spadlen);
source = allsource + offset;
//
// Based on RB_ReadPixels
@ -704,7 +705,7 @@ void R_LevelShot( screenshotType_e type, const char *ext ) {
RE_SavePNG(fileName, width, height, resample + offset, rpadlen);
ri.Hunk_FreeTempMemory(resample);
ri.Hunk_FreeTempMemory(source);
ri.Hunk_FreeTempMemory(allsource);
ri.Printf( PRINT_ALL, "Wrote %s\n", fileName );
}