Skip to content

Commit 20a3df1

Browse files
committed
Remove excessive comments from screenshot implementation
1 parent 59d53b6 commit 20a3df1

File tree

10 files changed

+12
-56
lines changed

10 files changed

+12
-56
lines changed

Generals/Code/GameEngine/Include/Common/MessageStream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class GameMessage : public MemoryPoolObject
258258
MSG_META_END_PREFER_SELECTION, ///< The Shift key has been released.
259259

260260
MSG_META_TAKE_SCREENSHOT, ///< take screenshot
261-
MSG_META_TAKE_SCREENSHOT_COMPRESSED, ///< TheSuperHackers @bobtista take compressed screenshot (JPG/PNG) without stalling
261+
MSG_META_TAKE_SCREENSHOT_COMPRESSED, ///< take compressed screenshot without stalling
262262
MSG_META_ALL_CHEER, ///< Yay! :)
263263
MSG_META_TOGGLE_ATTACKMOVE, ///< enter attack-move mode
264264

Generals/Code/GameEngine/Include/GameClient/Display.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class Display : public SubsystemInterface
169169
virtual void preloadTextureAssets( AsciiString texture ) = 0; ///< preload texture asset
170170

171171
virtual void takeScreenShot(void) = 0; ///< saves screenshot to a file
172-
virtual void takeScreenShotCompressed(void) = 0; ///< TheSuperHackers @bobtista saves compressed screenshot (JPG/PNG) without stalling
172+
virtual void takeScreenShotCompressed(void) = 0; ///< saves compressed screenshot without stalling
173173
virtual void toggleMovieCapture(void) = 0; ///< starts saving frames to an avi or frame sequence
174174
virtual void toggleLetterBox(void) = 0; ///< enabled letter-boxed display
175175
virtual void enableLetterBox(Bool enable) = 0; ///< forces letter-boxed display on/off

Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3414,7 +3414,6 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
34143414
break;
34153415
}
34163416

3417-
// TheSuperHackers @bobtista 02/11/2025 Compressed screenshot (JPG/PNG) without stalling
34183417
case GameMessage::MSG_META_TAKE_SCREENSHOT_COMPRESSED:
34193418
{
34203419
if (TheDisplay)

Generals/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,6 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t)
795795
}
796796
}
797797
{
798-
// TheSuperHackers @bobtista 02/11/2025 Compressed screenshot (JPG/PNG) without stalling
799-
// Bind F11 to the new compressed screenshot function
800798
MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_TAKE_SCREENSHOT_COMPRESSED);
801799
if (map->m_key == MK_NONE)
802800
{

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ static void drawFramerateBar(void);
4242
#include <thread>
4343
#include <memory>
4444

45-
// TheSuperHackers @bobtista 02/11/2025 STB for image encoding
4645
#define STB_IMAGE_WRITE_IMPLEMENTATION
4746
#include <stb_image_write.h>
4847

@@ -3028,12 +3027,8 @@ void W3DDisplay::takeScreenShot(void)
30283027
TheInGameUI->message(TheGameText->fetch("GUI:ScreenCapture"), ufileName.str());
30293028
}
30303029

3031-
/// TheSuperHackers @bobtista 02/11/2025 Save compressed screenshot (JPEG/PNG) to file without stalling the game
3032-
/// This implementation captures the frame buffer on the main thread, then spawns a background thread
3033-
/// to compress and save the image, allowing the game to continue running smoothly.
30343030
void W3DDisplay::takeScreenShotCompressed(void)
30353031
{
3036-
// TheSuperHackers @bobtista 02/11/2025 Find next available filename
30373032
char leafname[256];
30383033
char pathname[1024];
30393034
static int frame_number = 1;
@@ -3047,7 +3042,6 @@ void W3DDisplay::takeScreenShotCompressed(void)
30473042
done = true;
30483043
}
30493044

3050-
// TheSuperHackers @bobtista 02/11/2025 Get the back buffer and create a copy
30513045
SurfaceClass* surface = DX8Wrapper::_Get_DX8_Back_Buffer();
30523046
SurfaceClass::SurfaceDescription surfaceDesc;
30533047
surface->Get_Description(surfaceDesc);
@@ -3075,51 +3069,38 @@ void W3DDisplay::takeScreenShotCompressed(void)
30753069
unsigned int width = surfaceDesc.Width;
30763070
unsigned int height = surfaceDesc.Height;
30773071

3078-
// TheSuperHackers @bobtista 02/11/2025 Allocate buffer for RGB image data
3079-
// Using shared_ptr for automatic cleanup in the background thread
30803072
std::shared_ptr<unsigned char> imageData(new unsigned char[3 * width * height],
30813073
std::default_delete<unsigned char[]>());
30823074
unsigned char* image = imageData.get();
30833075

3084-
// TheSuperHackers @bobtista 02/11/2025 Copy and convert BGRA to RGB
30853076
for (y = 0; y < height; y++)
30863077
{
30873078
for (x = 0; x < width; x++)
30883079
{
30893080
index = 3 * (x + y * width);
30903081
index2 = y * lrect.Pitch + 4 * x;
30913082

3092-
image[index] = *((unsigned char*)lrect.pBits + index2 + 2); // R
3093-
image[index + 1] = *((unsigned char*)lrect.pBits + index2 + 1); // G
3094-
image[index + 2] = *((unsigned char*)lrect.pBits + index2 + 0); // B
3083+
image[index] = *((unsigned char*)lrect.pBits + index2 + 2);
3084+
image[index + 1] = *((unsigned char*)lrect.pBits + index2 + 1);
3085+
image[index + 2] = *((unsigned char*)lrect.pBits + index2 + 0);
30953086
}
30963087
}
30973088

30983089
surfaceCopy->Unlock();
30993090
surfaceCopy->Release_Ref();
31003091
surfaceCopy = NULL;
31013092

3102-
// TheSuperHackers @bobtista 02/11/2025 Make a copy of the pathname for the background thread
31033093
std::string pathnameCopy(pathname);
31043094
std::string leafnameCopy(leafname);
31053095

3106-
// TheSuperHackers @bobtista 02/11/2025 Spawn background thread to compress and save the image
3107-
// This allows the game to continue running without freezing
31083096
std::thread([imageData, width, height, pathnameCopy, leafnameCopy]() {
3109-
// TheSuperHackers @bobtista 02/11/2025 Write JPEG with quality 90 (range: 1-100)
3110-
// stbi_write_jpg expects image data with Y-axis going down, which matches our data
31113097
int result = stbi_write_jpg(pathnameCopy.c_str(), width, height, 3, imageData.get(), 90);
31123098

31133099
if (!result) {
3114-
// TheSuperHackers @bobtista 02/11/2025 Log error if write failed
3115-
// Note: Can't show UI message from background thread
31163100
OutputDebugStringA("Failed to write screenshot JPEG\n");
31173101
}
3118-
3119-
// TheSuperHackers @bobtista 02/11/2025 imageData will be automatically cleaned up when shared_ptr goes out of scope
3120-
}).detach(); // TheSuperHackers @bobtista 02/11/2025 Detach thread to run independently
3102+
}).detach();
31213103

3122-
// TheSuperHackers @bobtista 02/11/2025 Show message to user immediately (file is being saved in background)
31233104
UnicodeString ufileName;
31243105
ufileName.translate(leafnameCopy.c_str());
31253106
TheInGameUI->message(TheGameText->fetch("GUI:ScreenCapture"), ufileName.str());

GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class GameMessage : public MemoryPoolObject
258258
MSG_META_END_PREFER_SELECTION, ///< The Shift key has been released.
259259

260260
MSG_META_TAKE_SCREENSHOT, ///< take screenshot
261-
MSG_META_TAKE_SCREENSHOT_COMPRESSED, ///< TheSuperHackers @bobtista take compressed screenshot (JPG/PNG) without stalling
261+
MSG_META_TAKE_SCREENSHOT_COMPRESSED, ///< take compressed screenshot without stalling
262262
MSG_META_ALL_CHEER, ///< Yay! :)
263263
MSG_META_TOGGLE_ATTACKMOVE, ///< enter attack-move mode
264264

GeneralsMD/Code/GameEngine/Include/GameClient/Display.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class Display : public SubsystemInterface
169169
virtual void preloadTextureAssets( AsciiString texture ) = 0; ///< preload texture asset
170170

171171
virtual void takeScreenShot(void) = 0; ///< saves screenshot to a file
172-
virtual void takeScreenShotCompressed(void) = 0; ///< TheSuperHackers @bobtista saves compressed screenshot (JPG/PNG) without stalling
172+
virtual void takeScreenShotCompressed(void) = 0; ///< saves compressed screenshot without stalling
173173
virtual void toggleMovieCapture(void) = 0; ///< starts saving frames to an avi or frame sequence
174174
virtual void toggleLetterBox(void) = 0; ///< enabled letter-boxed display
175175
virtual void enableLetterBox(Bool enable) = 0; ///< forces letter-boxed display on/off

GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3747,7 +3747,6 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
37473747
break;
37483748
}
37493749

3750-
// TheSuperHackers @bobtista 02/11/2025 Compressed screenshot (JPG/PNG) without stalling
37513750
case GameMessage::MSG_META_TAKE_SCREENSHOT_COMPRESSED:
37523751
{
37533752
if (TheDisplay)

GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,8 +853,6 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t)
853853
}
854854
}
855855
{
856-
// TheSuperHackers @bobtista 02/11/2025 Compressed screenshot (JPG/PNG) without stalling
857-
// Bind F11 to the new compressed screenshot function
858856
MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_TAKE_SCREENSHOT_COMPRESSED);
859857
if (map->m_key == MK_NONE)
860858
{

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ static void drawFramerateBar(void);
4242
#include <thread>
4343
#include <memory>
4444

45-
// TheSuperHackers @bobtista 02/11/2025 STB for image encoding
4645
#define STB_IMAGE_WRITE_IMPLEMENTATION
4746
#include <stb_image_write.h>
4847

@@ -3147,12 +3146,8 @@ void W3DDisplay::takeScreenShot(void)
31473146
TheInGameUI->message(TheGameText->fetch("GUI:ScreenCapture"), ufileName.str());
31483147
}
31493148

3150-
/// TheSuperHackers @bobtista 02/11/2025 Save compressed screenshot (JPEG/PNG) to file without stalling the game
3151-
/// This implementation captures the frame buffer on the main thread, then spawns a background thread
3152-
/// to compress and save the image, allowing the game to continue running smoothly.
31533149
void W3DDisplay::takeScreenShotCompressed(void)
31543150
{
3155-
// TheSuperHackers @bobtista 02/11/2025 Find next available filename
31563151
char leafname[256];
31573152
char pathname[1024];
31583153
static int frame_number = 1;
@@ -3166,7 +3161,6 @@ void W3DDisplay::takeScreenShotCompressed(void)
31663161
done = true;
31673162
}
31683163

3169-
// TheSuperHackers @bobtista 02/11/2025 Get the back buffer and create a copy
31703164
SurfaceClass* surface = DX8Wrapper::_Get_DX8_Back_Buffer();
31713165
SurfaceClass::SurfaceDescription surfaceDesc;
31723166
surface->Get_Description(surfaceDesc);
@@ -3194,51 +3188,38 @@ void W3DDisplay::takeScreenShotCompressed(void)
31943188
unsigned int width = surfaceDesc.Width;
31953189
unsigned int height = surfaceDesc.Height;
31963190

3197-
// TheSuperHackers @bobtista 02/11/2025 Allocate buffer for RGB image data
3198-
// Using shared_ptr for automatic cleanup in the background thread
31993191
std::shared_ptr<unsigned char> imageData(new unsigned char[3 * width * height],
32003192
std::default_delete<unsigned char[]>());
32013193
unsigned char* image = imageData.get();
32023194

3203-
// TheSuperHackers @bobtista 02/11/2025 Copy and convert BGRA to RGB
32043195
for (y = 0; y < height; y++)
32053196
{
32063197
for (x = 0; x < width; x++)
32073198
{
32083199
index = 3 * (x + y * width);
32093200
index2 = y * lrect.Pitch + 4 * x;
32103201

3211-
image[index] = *((unsigned char*)lrect.pBits + index2 + 2); // R
3212-
image[index + 1] = *((unsigned char*)lrect.pBits + index2 + 1); // G
3213-
image[index + 2] = *((unsigned char*)lrect.pBits + index2 + 0); // B
3202+
image[index] = *((unsigned char*)lrect.pBits + index2 + 2);
3203+
image[index + 1] = *((unsigned char*)lrect.pBits + index2 + 1);
3204+
image[index + 2] = *((unsigned char*)lrect.pBits + index2 + 0);
32143205
}
32153206
}
32163207

32173208
surfaceCopy->Unlock();
32183209
surfaceCopy->Release_Ref();
32193210
surfaceCopy = NULL;
32203211

3221-
// TheSuperHackers @bobtista 02/11/2025 Make a copy of the pathname for the background thread
32223212
std::string pathnameCopy(pathname);
32233213
std::string leafnameCopy(leafname);
32243214

3225-
// TheSuperHackers @bobtista 02/11/2025 Spawn background thread to compress and save the image
3226-
// This allows the game to continue running without freezing
32273215
std::thread([imageData, width, height, pathnameCopy, leafnameCopy]() {
3228-
// TheSuperHackers @bobtista 02/11/2025 Write JPEG with quality 90 (range: 1-100)
3229-
// stbi_write_jpg expects image data with Y-axis going down, which matches our data
32303216
int result = stbi_write_jpg(pathnameCopy.c_str(), width, height, 3, imageData.get(), 90);
32313217

32323218
if (!result) {
3233-
// TheSuperHackers @bobtista 02/11/2025 Log error if write failed
3234-
// Note: Can't show UI message from background thread
32353219
OutputDebugStringA("Failed to write screenshot JPEG\n");
32363220
}
3237-
3238-
// TheSuperHackers @bobtista 02/11/2025 imageData will be automatically cleaned up when shared_ptr goes out of scope
3239-
}).detach(); // TheSuperHackers @bobtista 02/11/2025 Detach thread to run independently
3221+
}).detach();
32403222

3241-
// TheSuperHackers @bobtista 02/11/2025 Show message to user immediately (file is being saved in background)
32423223
UnicodeString ufileName;
32433224
ufileName.translate(leafnameCopy.c_str());
32443225
TheInGameUI->message(TheGameText->fetch("GUI:ScreenCapture"), ufileName.str());

0 commit comments

Comments
 (0)