Skip to content

Conversation

@xezon
Copy link

@xezon xezon commented Sep 29, 2025

This change removes obsolete pragma optimize directives.

TODO

  • Replicate in Generals

@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing labels Sep 29, 2025


// This routine fails to draw poly triggers in some cases when optimized.
// So just shut it off for now. The failure case was new doc, add a poly trigger.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this with VS2022 Release build and was unable to reproduce it.

}

#ifdef RTS_DEBUG
#pragma optimize("", off) // We get an odd error when using optimized in the debug.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decoupled RTS_DEBUG from optimization already anyway, so this must go. This is called when hovering units, sometimes. I do not know what the error would have been. We do not care.

@xezon
Copy link
Author

xezon commented Sep 30, 2025

Replicated in Generals with conflicts

D:\Projects\TheSuperHackers\GeneralsGameCode>FOR /F "delims=" %b IN ('git merge-base --fork-point main') DO git diff %b  1>changes.patch

D:\Projects\TheSuperHackers\GeneralsGameCode>git diff 2bbf90241e2bb30ef9deff234e495a65baf24796  1>changes.patch

D:\Projects\TheSuperHackers\GeneralsGameCode>git apply -p2 --directory=Generals --reject --whitespace=fix changes.patch
Checking patch Generals/Libraries/Source/WWVegas/WW3D2/aabtree.cpp...
error: Generals/Libraries/Source/WWVegas/WW3D2/aabtree.cpp: No such file or directory
Checking patch Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp...
Hunk #1 succeeded at 59 (offset -3 lines).
Checking patch Generals/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp...
error: while searching for:
#include "wwmemlog.h"
#include "assetmgr.h"

//#pragma optimize("", off)
//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")

RectClass                                                       Render2DClass::ScreenResolution( 0,0,0,0 );



error: patch failed: Generals/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp:58
Checking patch Generals/Code/Libraries/Source/WWVegas/WW3D2/texture.cpp...
error: while searching for:
#include "texturethumbnail.h"
#include "wwprofile.h"

//#pragma optimize("", off)
//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")

const unsigned DEFAULT_INACTIVATION_TIME=20000;

/*

error: patch failed: Generals/Code/Libraries/Source/WWVegas/WW3D2/texture.cpp:59
Checking patch Generals/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp...
error: while searching for:
#include "bitmaphandler.h"
#include "wwprofile.h"

//#pragma optimize("", off)
//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")

bool TextureLoader::TextureLoadSuspended;
int TextureLoader::TextureInactiveOverrideTime = 0;


error: patch failed: Generals/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp:62
Checking patch Generals/Code/Tools/WorldBuilder/src/DrawObject.cpp...
error: while searching for:
}


// This routine fails to draw poly triggers in some cases when optimized.
// So just shut it off for now.  The failure case was new doc, add a poly trigger.
// Adding any other object fixed the problem.   jba

#pragma optimize("", off)

bool _skip_drawobject_render = false;

/** Render draws into the current 3d context. */

error: patch failed: Generals/Code/Tools/WorldBuilder/src/DrawObject.cpp:2056
error: while searching for:
                m_lineRenderer->Reset();
        }
}
#pragma optimize("", on)

void BuildRectFromSegmentAndWidth(const Coord3D* start, const Coord3D* end, Real width,

                        Coord3D* outBL, Coord3D* outTL, Coord3D* outBR, Coord3D* outTR)

error: patch failed: Generals/Code/Tools/WorldBuilder/src/DrawObject.cpp:2457
Applied patch Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp cleanly.
Applying patch Generals/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp with 1 reject...
Rejected hunk #1.
Applying patch Generals/Code/Libraries/Source/WWVegas/WW3D2/texture.cpp with 1 reject...
Rejected hunk #1.
Applying patch Generals/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp with 1 reject...
Rejected hunk #1.
Applying patch Generals/Code/Tools/WorldBuilder/src/DrawObject.cpp with 2 rejects...
Rejected hunk #1.
Rejected hunk #2.

@xezon xezon merged commit c830b3b into TheSuperHackers:main Sep 30, 2025
17 checks passed
@xezon xezon deleted the xezon/refactor-pragma-optimize branch September 30, 2025 17:52
fbraz3 pushed a commit to fbraz3/GeneralsX that referenced this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants