Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix screenshot not saving properly #62

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion releases/v4/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This release contains:
* MI6 Stealth
* MI6 Suit
* MI6 Tux
* Six weapons:
* Eight weapons:
* Fists
* Frinesi (shotgun)
* Militek (grenade launcher)
Expand Down
2 changes: 1 addition & 1 deletion releases/v5/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This release contains:
* MI6 Stealth
* MI6 Suit
* MI6 Tux
* Six weapons:
* Eight weapons:
* Fists
* Frinesi (shotgun)
* Militek (grenade launcher)
Expand Down
10 changes: 8 additions & 2 deletions xash3d_engine/engine/ref/gl/src/gl_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,14 @@ const envmap_t r_skyBoxInfo[6] = {
{{0, 180, 180}, IMAGE_FLIP_X},
};

const envmap_t r_envMapInfo[6] =
{{{0, 0, 90}, 0}, {{0, 180, -90}, 0}, {{0, 90, 0}, 0}, {{0, 270, 180}, 0}, {{-90, 180, -90}, 0}, {{90, 0, 90}, 0}};
const envmap_t r_envMapInfo[6] = {
{{0, 0, 90}, 0},
{{0, 180, -90}, 0},
{{0, 90, 0}, 0},
{{0, 270, 180}, 0},
{{-90, 180, -90}, 0},
{{90, 0, 90}, 0},
};

qboolean VID_ScreenShot(const char* filename, int shot_type)
{
Expand Down
30 changes: 21 additions & 9 deletions xash3d_engine/engine/src/client/cl_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ void CL_PlayCDTrack_f(void)
CL_ScreenshotGetName
==================
*/
qboolean CL_ScreenshotGetName(int lastnum, char* filename, size_t bufferSize)
static qboolean CL_ScreenshotGetName(int lastnum, char* filename, size_t bufferSize)
{
if ( lastnum < 0 || lastnum > 9999 )
{
Con_Printf(S_ERROR "Unable to write screenshot: index %d was out of range\n", lastnum);
return false;
}

Q_snprintf(filename, bufferSize, "scrshots/%s_shot%04d.png", clgame.mapname, lastnum);
Q_snprintf(filename, bufferSize, "scrshots/%s_screenshot%04d.png", clgame.mapname, lastnum);

return true;
}
Expand All @@ -172,16 +172,19 @@ qboolean CL_ScreenshotGetName(int lastnum, char* filename, size_t bufferSize)
CL_SnapshotGetName
==================
*/
qboolean CL_SnapshotGetName(int lastnum, char* filename, size_t bufferSize)
static qboolean CL_SnapshotGetName(int lastnum, char* filename, size_t bufferSize)
{
if ( lastnum < 0 || lastnum > 9999 )
{
Con_Printf(S_ERROR "Unable to write snapshot: index %d was out of range\n", lastnum);
FS_AllowDirectPaths(false);
return false;
}

Q_snprintf(filename, bufferSize, "../%s_%04d.png", clgame.mapname, lastnum);
// This used to go up one directory and save there,
// but the search path functions don't support going
// out past their root. Instead, we use the screenshots
// directory and just name our images differently.
Q_snprintf(filename, bufferSize, "scrshots/%s_snapshot%04d.png", clgame.mapname, lastnum);

return true;
}
Expand Down Expand Up @@ -217,10 +220,14 @@ void CL_ScreenShot_f(void)
for ( i = 0; i < 9999; i++ )
{
if ( !CL_ScreenshotGetName(i, checkname, sizeof(checkname)) )
{
return; // no namespace
}

if ( !FS_FileExists(checkname, false) )
{
break;
}
}

Q_strncpy(cls.shotname, checkname, sizeof(cls.shotname));
Expand Down Expand Up @@ -251,19 +258,20 @@ void CL_SnapShot_f(void)
}
else
{
FS_AllowDirectPaths(true);

// scan for a free filename
for ( i = 0; i < 9999; i++ )
{
if ( !CL_SnapshotGetName(i, checkname, sizeof(checkname)) )
{
return; // no namespace
}

if ( !FS_FileExists(checkname, false) )
{
break;
}
}

FS_AllowDirectPaths(false);
Q_strncpy(cls.shotname, checkname, sizeof(cls.shotname));
cls.scrshot_action = scrshot_snapshot; // build new frame for screenshot
}
Expand Down Expand Up @@ -344,16 +352,20 @@ void CL_LevelShot_f(void)
{
Q_snprintf(cls.shotname, sizeof(cls.shotname), "levelshots/%s_%s.bmp", clgame.mapname, refState.wideScreen ? "16x9" : "4x3");

// make sure what levelshot is newer than bsp
// make sure that levelshot is newer than bsp
ft1 = FS_FileTime(cl.worldmodel->name, false);
ft2 = FS_FileTime(cls.shotname, true);
}

// missing levelshot or level never than levelshot
if ( ft2 == (size_t)-1 || ft1 > ft2 )
{
cls.scrshot_action = scrshot_plaque; // build new frame for levelshot
}
else
{
cls.scrshot_action = scrshot_inactive; // disable - not needs
}
}

/*
Expand Down
2 changes: 1 addition & 1 deletion xash3d_engine/engine/src/common/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void Sys_PrintUsage(void)
#endif

#if !XASH_DEDICATED()
" -toconsole run engine witn console open\n"
" -toconsole run engine with console open\n"
" -width <n> set window width\n"
" -height <n> set window height\n"
" -oldfont enable unused Quake font in Half-Life\n"
Expand Down
Loading