Skip to content
Open
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
51 changes: 51 additions & 0 deletions Core/GameEngine/Include/GameClient/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,5 +331,56 @@ class ViewLocation
}
};

// TheSuperHackers @feature bobtista 31/01/2026
// View that does nothing. Used for Headless Mode.
class ViewDummy : public View
{
public:
virtual Drawable *pickDrawable( const ICoord2D *screen, Bool forceAttack, PickType pickType )
{
return nullptr;
}
virtual Int iterateDrawablesInRegion( IRegion2D *screenRegion, Bool (*callback)( Drawable *draw, void *userData ), void *userData )
{
return 0;
}
virtual void forceRedraw()
{
}
virtual const Coord3D& get3DCameraPosition() const
{
static Coord3D zero = {0,0,0};
return zero;
}
virtual WorldToScreenReturn worldToScreenTriReturn(const Coord3D *w, ICoord2D *s )
{
return WTS_INVALID;
}
virtual void screenToWorld( const ICoord2D *s, Coord3D *w )
{
}
virtual void screenToTerrain( const ICoord2D *screen, Coord3D *world )
{
}
virtual void screenToWorldAtZ( const ICoord2D *s, Coord3D *w, Real z )
{
}
virtual void drawView( void )
{
}
virtual void updateView(void)
{
}
virtual void stepView()
{
}
virtual void setGuardBandBias( const Coord2D *gb )
{
}
Comment on lines +339 to +379
Copy link

Choose a reason for hiding this comment

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

Several method bodies are on the same line as their signatures, which prevents placing breakpoints on the function body separately from the declaration. Per project conventions, expand these to multi-line format:

Suggested change
virtual Drawable *pickDrawable( const ICoord2D *screen, Bool forceAttack, PickType pickType )
{
return nullptr;
}
virtual Int iterateDrawablesInRegion( IRegion2D *screenRegion, Bool (*callback)( Drawable *draw, void *userData ), void *userData )
{
return 0;
}
virtual void forceRedraw()
{
}
virtual const Coord3D& get3DCameraPosition() const
{
static Coord3D zero = {0,0,0};
return zero;
}
virtual WorldToScreenReturn worldToScreenTriReturn(const Coord3D *w, ICoord2D *s )
{
return WTS_INVALID;
}
virtual void screenToWorld( const ICoord2D *s, Coord3D *w )
{
}
virtual void screenToTerrain( const ICoord2D *screen, Coord3D *world )
{
}
virtual void screenToWorldAtZ( const ICoord2D *s, Coord3D *w, Real z )
{
}
virtual void drawView( void )
{
}
virtual void updateView(void)
{
}
virtual void stepView()
{
}
virtual void setGuardBandBias( const Coord2D *gb )
{
}
virtual Drawable *pickDrawable( const ICoord2D *screen, Bool forceAttack, PickType pickType )
{
return nullptr;
}
virtual Int iterateDrawablesInRegion( IRegion2D *screenRegion, Bool (*callback)( Drawable *draw, void *userData ), void *userData )
{
return 0;
}
virtual void forceRedraw()
{
}
virtual const Coord3D& get3DCameraPosition() const
{
static Coord3D zero = {0,0,0};
return zero;
}
virtual WorldToScreenReturn worldToScreenTriReturn(const Coord3D *w, ICoord2D *s )
{
return WTS_INVALID;
}
virtual void screenToWorld( const ICoord2D *s, Coord3D *w )
{
}
virtual void screenToTerrain( const ICoord2D *screen, Coord3D *world )
{
}
virtual void screenToWorldAtZ( const ICoord2D *s, Coord3D *w, Real z )
{
}
virtual void drawView( void )
{
}
virtual void updateView(void)
{
}
virtual void stepView()
{
}
virtual void setGuardBandBias( const Coord2D *gb )
{
}

Context Used: Rule from dashboard - Always place if/else/for/while statement bodies on separate lines from the condition to allow precis... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: Core/GameEngine/Include/GameClient/View.h
Line: 339-379

Comment:
Several method bodies are on the same line as their signatures, which prevents placing breakpoints on the function body separately from the declaration. Per project conventions, expand these to multi-line format:

```suggestion
	virtual Drawable *pickDrawable( const ICoord2D *screen, Bool forceAttack, PickType pickType )
	{
		return nullptr;
	}
	virtual Int iterateDrawablesInRegion( IRegion2D *screenRegion, Bool (*callback)( Drawable *draw, void *userData ), void *userData )
	{
		return 0;
	}
	virtual void forceRedraw()
	{
	}
	virtual const Coord3D& get3DCameraPosition() const
	{
		static Coord3D zero = {0,0,0};
		return zero;
	}
	virtual WorldToScreenReturn worldToScreenTriReturn(const Coord3D *w, ICoord2D *s )
	{
		return WTS_INVALID;
	}
	virtual void screenToWorld( const ICoord2D *s, Coord3D *w )
	{
	}
	virtual void screenToTerrain( const ICoord2D *screen, Coord3D *world )
	{
	}
	virtual void screenToWorldAtZ( const ICoord2D *s, Coord3D *w, Real z )
	{
	}
	virtual void drawView( void )
	{
	}
	virtual void updateView(void)
	{
	}
	virtual void stepView()
	{
	}
	virtual void setGuardBandBias( const Coord2D *gb )
	{
	}
```

**Context Used:** Rule from `dashboard` - Always place if/else/for/while statement bodies on separate lines from the condition to allow precis... ([source](https://app.greptile.com/review/custom-context?memory=16b9b669-b823-49be-ba5b-2bd30ff3ba6d))

How can I resolve this? If you propose a fix, please make it concise.


// TheSuperHackers @bugfix bobtista 03/02/2026 Do not override View::xfer(). The base
// implementation must run to serialize valid view state for save file compatibility.
};

// EXTERNALS //////////////////////////////////////////////////////////////////////////////////////
extern View *TheTacticalView; ///< the main tactical interface to the game world
6 changes: 3 additions & 3 deletions Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,17 +1337,17 @@ void InGameUI::init()
been moved to where all the other translators are attached in game client */

// create the tactical view
if (TheDisplay)
TheTacticalView = createView();
if (TheTacticalView && TheDisplay)
{
TheTacticalView = createView();
TheTacticalView->init();
TheDisplay->attachView( TheTacticalView );

// make the tactical display the full screen width and height
TheTacticalView->setWidth( TheDisplay->getWidth() );
TheTacticalView->setHeight( TheDisplay->getHeight() );
TheTacticalView->setDefaultView(0.0f, 0.0f, 1.0f);
}
TheTacticalView->setDefaultView(0.0f, 0.0f, 1.0f);

/** @todo this may be the wrong place to create the sidebar, but for now
this is where it lives */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////

// USER INCLUDES //////////////////////////////////////////////////////////////
#include "Common/GlobalData.h"
#include "GameClient/InGameUI.h"
#include "GameClient/View.h"
#include "W3DDevice/GameClient/W3DView.h"
Expand Down Expand Up @@ -69,7 +70,11 @@ class W3DInGameUI : public InGameUI
protected:

/// factory for views
virtual View *createView() { return NEW W3DView; }
// TheSuperHackers @fix bobtista 31/01/2026 Return dummy in headless mode
virtual View *createView()
{
return TheGlobalData->m_headless ? static_cast<View*>(NEW ViewDummy) : NEW W3DView;
Copy link

Choose a reason for hiding this comment

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

Dereferences TheGlobalData without null check; if createView() is called before global data initialization, this will crash

Suggested change
return TheGlobalData->m_headless ? static_cast<View*>(NEW ViewDummy) : NEW W3DView;
return (TheGlobalData && TheGlobalData->m_headless) ? static_cast<View*>(NEW ViewDummy) : NEW W3DView;
Prompt To Fix With AI
This is a comment left during a code review.
Path: Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h
Line: 76

Comment:
Dereferences `TheGlobalData` without null check; if `createView()` is called before global data initialization, this will crash

```suggestion
		return (TheGlobalData && TheGlobalData->m_headless) ? static_cast<View*>(NEW ViewDummy) : NEW W3DView;
```

How can I resolve this? If you propose a fix, please make it concise.

}

virtual void drawSelectionRegion(); ///< draw the selection region on screen
virtual void drawMoveHints( View *view ); ///< draw move hint visual feedback
Expand Down
6 changes: 3 additions & 3 deletions GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,17 +1367,17 @@ void InGameUI::init()
been moved to where all the other translators are attached in game client */

// create the tactical view
if (TheDisplay)
TheTacticalView = createView();
if (TheTacticalView && TheDisplay)
{
TheTacticalView = createView();
TheTacticalView->init();
TheDisplay->attachView( TheTacticalView );

// make the tactical display the full screen width and height
TheTacticalView->setWidth( TheDisplay->getWidth() );
TheTacticalView->setHeight( TheDisplay->getHeight() );
TheTacticalView->setDefaultView(0.0f, 0.0f, 1.0f);
}
TheTacticalView->setDefaultView(0.0f, 0.0f, 1.0f);

/** @todo this may be the wrong place to create the sidebar, but for now
this is where it lives */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////

// USER INCLUDES //////////////////////////////////////////////////////////////
#include "Common/GlobalData.h"
#include "GameClient/InGameUI.h"
#include "GameClient/View.h"
#include "W3DDevice/GameClient/W3DView.h"
Expand Down Expand Up @@ -69,7 +70,11 @@ class W3DInGameUI : public InGameUI
protected:

/// factory for views
virtual View *createView() { return NEW W3DView; }
// TheSuperHackers @fix bobtista 31/01/2026 Return dummy in headless mode
virtual View *createView()
{
return TheGlobalData->m_headless ? static_cast<View*>(NEW ViewDummy) : NEW W3DView;
Copy link

Choose a reason for hiding this comment

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

Dereferences TheGlobalData without null check; if createView() is called before global data initialization, this will crash

Suggested change
return TheGlobalData->m_headless ? static_cast<View*>(NEW ViewDummy) : NEW W3DView;
return (TheGlobalData && TheGlobalData->m_headless) ? static_cast<View*>(NEW ViewDummy) : NEW W3DView;
Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h
Line: 76

Comment:
Dereferences `TheGlobalData` without null check; if `createView()` is called before global data initialization, this will crash

```suggestion
		return (TheGlobalData && TheGlobalData->m_headless) ? static_cast<View*>(NEW ViewDummy) : NEW W3DView;
```

How can I resolve this? If you propose a fix, please make it concise.

}

virtual void drawSelectionRegion(); ///< draw the selection region on screen
virtual void drawMoveHints( View *view ); ///< draw move hint visual feedback
Expand Down
Loading