ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.59k stars 599 forks source link

[GoldSource] .tga screenshots limit #777

Open ghost opened 11 years ago

ghost commented 11 years ago

When I take a screenshot, the game (HL/CS/CS:CZ) creates a HalfLifeXX.tga under the game mod folder (valve/cstrike/czero), where XX is a number from 00 to 99. After HalfLife99.tga the game cannot take screenshots

] screenshot 
SCR_ScreenShot_f: Couldn't create a TGA file

In addition, the counter is common for all mods. If I take a screenshot in Half-Life, I get HalfLife00.tga in Half-Life\valve folder. Then I take another screenshot in Counter-Strike, I get HalfLife01.tga in Half-Life\cstrike folder.

I think Snapshots naming system would fit. Snapshot0000.bmp - when viewing demo or in game menu, mapname0000.bmp (de_dust0000.bmp) when connected to a server.

SamVanheer commented 5 years ago

This happens because the command uses FS_FileExists, which calls through to: https://github.com/ValveSoftware/halflife/blob/5d761709a31ce1e71488f2668321de05f791b405/public/FileSystem.h#L92

Which checks all path ids for the given filename. This includes the base game directory (valve) so it will think that it has already created one with that name even if the file doesn't exist in the GAMECONFIG path id.

To fix this the interface needs a new overload that takes a path id. This should be possible without breaking backwards compatibility by exposing both the current and the new interface.

If the interface were to be updated it would be a good idea to port any other methods that could be useful from the current Source engine version. Some methods don't work properly, for example as noted: https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/public/filesystem.h#L663-L666

See also #1817

As far as the limited number of screenshots goes i'm sure the code from the snapshot command (CL_TakeSnapshot_f) can be re-purposed for this.