Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
Radar Class Referenceabstract

#include <Radar.h>

Inherits Snapshot, and SubsystemInterface.

Inherited by W3DRadar.

Classes

struct  RadarEvent
 

Public Member Functions

 Radar (void)
 
virtual ~Radar (void)
 
virtual void init (void)
 subsystem initialization
 
virtual void reset (void)
 subsystem reset
 
virtual void update (void)
 subsystem per frame update
 
Bool isRadarWindow (GameWindow *window)
 
Bool radarToWorld (const ICoord2D *radar, Coord3D *world)
 radar point to world point on terrain
 
Bool radarToWorld2D (const ICoord2D *radar, Coord3D *world)
 radar point to world point (x,y only!)
 
Bool worldToRadar (const Coord3D *world, ICoord2D *radar)
 translate world point to radar (x,y)
 
Bool localPixelToRadar (const ICoord2D *pixel, ICoord2D *radar)
 translate pixel (with UL of radar being (0,0)) to logical radar coords
 
Bool screenPixelToWorld (const ICoord2D *pixel, Coord3D *world)
 translate pixel (with UL of the screen being (0,0)) to world position in the world
 
ObjectobjectUnderRadarPixel (const ICoord2D *pixel)
 return the object (if any) represented by the pixel coords passed in
 
void findDrawPositions (Int startX, Int startY, Int width, Int height, ICoord2D *ul, ICoord2D *lr)
 make translation for screen area of radar square to scaled aspect ratio preserving points inside the radar area
 
Bool isPriorityVisible (RadarPriorityType priority) const
 is the priority passed in a "visible" one on the radar
 
void createEvent (const Coord3D *world, RadarEventType type, Real secondsToLive=4.0f)
 create radar event at location in world
 
void createPlayerEvent (Player *player, const Coord3D *world, RadarEventType type, Real secondsToLive=4.0f)
 create radar event using player colors
 
Bool getLastEventLoc (Coord3D *eventPos)
 get last event loc (if any)
 
void tryUnderAttackEvent (const Object *obj)
 try to make an "under attack" event if it's the proper time
 
void tryInfiltrationEvent (const Object *obj)
 try to make an "infiltration" event if it's the proper time
 
Bool tryEvent (RadarEventType event, const Coord3D *pos)
 try to make a "stealth" event
 
void addObject (Object *obj)
 add object to radar
 
void removeObject (Object *obj)
 remove object from radar
 
void examineObject (Object *obj)
 re-examine object and resort if needed
 
void hide (Bool hide)
 hide/unhide the radar
 
Bool isRadarHidden (void)
 is radar hidden
 
void forceOn (Bool force)
 force the radar to be on
 
Bool isRadarForced (void)
 is radar forced on?
 
virtual void refreshTerrain (TerrainLogic *terrain)
 refresh the water values for the radar
 
virtual void queueTerrainRefresh (void)
 queue a refresh of the terran at the next available time
 
virtual void newMap (TerrainLogic *terrain)
 reset radar for new map
 
virtual void draw (Int pixelX, Int pixelY, Int width, Int height)=0
 draw the radar
 
virtual void clearShroud ()=0
 empty the entire shroud
 
virtual void setShroudLevel (Int x, Int y, CellShroudStatus setting)=0
 set the shroud level at shroud cell x,y
 
- Public Member Functions inherited from Snapshot
 Snapshot (void)
 
 ~Snapshot (void)
 
- Public Member Functions inherited from SubsystemInterface
 SubsystemInterface ()
 
virtual ~SubsystemInterface ()
 
virtual void postProcessLoad ()
 
virtual void draw (void)
 
void UPDATE (void)
 
void DRAW (void)
 
AsciiString getName (void)
 
void setName (AsciiString name)
 

Protected Types

enum  { MAX_RADAR_EVENTS = 64 }
 

Protected Member Functions

virtual void crc (Xfer *xfer)
 
virtual void xfer (Xfer *xfer)
 
virtual void loadPostProcess (void)
 
void internalCreateEvent (const Coord3D *world, RadarEventType type, Real secondsToLive, const RGBAColorInt *color1, const RGBAColorInt *color2)
 internal method for creating a radar event with specific colors
 
void deleteListResources (void)
 delete list radar resources used
 
Bool deleteFromList (Object *obj, RadarObject **list)
 try to remove object from specific list
 
Real getTerrainAverageZ () const
 
Real getWaterAverageZ () const
 
const RadarObjectgetObjectList () const
 
const RadarObjectgetLocalObjectList () const
 
void clearAllEvents (void)
 remove all radar events in progress
 
ObjectsearchListForRadarLocationMatch (RadarObject *listHead, ICoord2D *radarMatch)
 

Protected Attributes

Bool m_radarHidden
 true when radar is not visible
 
Bool m_radarForceOn
 true when radar is forced to be on
 
RadarObjectm_objectList
 list of objects in the radar
 
RadarObjectm_localObjectList
 
Real m_terrainAverageZ
 average Z for terrain samples
 
Real m_waterAverageZ
 average Z for water samples
 
Real m_xSample
 
Real m_ySample
 
RadarEvent m_event [MAX_RADAR_EVENTS]
 our radar events
 
Int m_nextFreeRadarEvent
 index into m_event for where to store the next event
 
Int m_lastRadarEvent
 index of the most recent radar event
 
GameWindowm_radarWindow
 window we display the radar in
 
Region3D m_mapExtent
 extents of the current map
 
UnsignedInt m_queueTerrainRefreshFrame
 frame we requested the last terrain refresh on
 
- Protected Attributes inherited from SubsystemInterface
AsciiString m_name
 

Detailed Description

Interface for the radar

Definition at line 155 of file Radar.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
MAX_RADAR_EVENTS 

Definition at line 267 of file Radar.h.

Constructor & Destructor Documentation

◆ Radar()

Radar::Radar ( void )

Definition at line 208 of file Radar.cpp.

◆ ~Radar()

Radar::~Radar ( void )
virtual

Definition at line 235 of file Radar.cpp.

Member Function Documentation

◆ addObject()

void Radar::addObject ( Object * obj)

add object to radar

Add an object to the radar list. The object will be sorted in the list to be grouped using it's radar priority

Definition at line 400 of file Radar.cpp.

◆ clearAllEvents()

void Radar::clearAllEvents ( void )
protected

remove all radar events in progress

Clear all radar events

Definition at line 246 of file Radar.cpp.

◆ clearShroud()

virtual void Radar::clearShroud ( )
pure virtual

empty the entire shroud

Implemented in W3DRadar.

◆ crc()

void Radar::crc ( Xfer * xfer)
protectedvirtual

CRC

Implements Snapshot.

Definition at line 1376 of file Radar.cpp.

◆ createEvent()

void Radar::createEvent ( const Coord3D * world,
RadarEventType type,
Real secondsToLive = 4.0f )

create radar event at location in world

Create a new radar event

Definition at line 1019 of file Radar.cpp.

◆ createPlayerEvent()

void Radar::createPlayerEvent ( Player * player,
const Coord3D * world,
RadarEventType type,
Real secondsToLive = 4.0f )

create radar event using player colors

Create radar event using a specific colors from the player

Definition at line 1062 of file Radar.cpp.

◆ deleteFromList()

Bool Radar::deleteFromList ( Object * obj,
RadarObject ** list )
protected

try to remove object from specific list

Try to delete an object from a specific list

Definition at line 555 of file Radar.cpp.

◆ deleteListResources()

void Radar::deleteListResources ( void )
protected

delete list radar resources used

Delete list resources used by the radar and return them to the memory pools

Definition at line 71 of file Radar.cpp.

◆ draw()

virtual void Radar::draw ( Int pixelX,
Int pixelY,
Int width,
Int height )
pure virtual

draw the radar

Implemented in W3DRadar.

◆ examineObject()

void Radar::examineObject ( Object * obj)

re-examine object and resort if needed

◆ findDrawPositions()

void Radar::findDrawPositions ( Int startX,
Int startY,
Int width,
Int height,
ICoord2D * ul,
ICoord2D * lr )

make translation for screen area of radar square to scaled aspect ratio preserving points inside the radar area

Given the RELATIVE SCREEN start X and Y, the width and height of the area to draw the whole radar in, compute what the upper left (ul) and lower right (lr) local coordinates are that represent the actual terrain image part of the radar that will preserve the aspect ratio of the map

Definition at line 901 of file Radar.cpp.

◆ forceOn()

void Radar::forceOn ( Bool force)
inline

force the radar to be on

Definition at line 204 of file Radar.h.

◆ getLastEventLoc()

Bool Radar::getLastEventLoc ( Coord3D * eventPos)

get last event loc (if any)

Get the last event position, if any. Returns TRUE if event was found Returns FALSE if there is no "last event"

Definition at line 1148 of file Radar.cpp.

◆ getLocalObjectList()

const RadarObject * Radar::getLocalObjectList ( ) const
inlineprotected

Definition at line 240 of file Radar.h.

◆ getObjectList()

const RadarObject * Radar::getObjectList ( ) const
inlineprotected

Definition at line 239 of file Radar.h.

◆ getTerrainAverageZ()

Real Radar::getTerrainAverageZ ( ) const
inlineprotected

Definition at line 237 of file Radar.h.

◆ getWaterAverageZ()

Real Radar::getWaterAverageZ ( ) const
inlineprotected

Definition at line 238 of file Radar.h.

◆ hide()

void Radar::hide ( Bool hide)
inline

hide/unhide the radar

Definition at line 198 of file Radar.h.

◆ init()

virtual void Radar::init ( void )
inlinevirtual

subsystem initialization

Implements SubsystemInterface.

Reimplemented in W3DRadar.

Definition at line 164 of file Radar.h.

◆ internalCreateEvent()

void Radar::internalCreateEvent ( const Coord3D * world,
RadarEventType type,
Real secondsToLive,
const RGBAColorInt * color1,
const RGBAColorInt * color2 )
protected

internal method for creating a radar event with specific colors

Create a new radar event

< this many seconds before we hit the die frame we start to fade away

Definition at line 1104 of file Radar.cpp.

◆ isPriorityVisible()

Bool Radar::isPriorityVisible ( RadarPriorityType priority) const

is the priority passed in a "visible" one on the radar

Is the priority type passed in a "visible" one that can show up on the radar

Definition at line 1553 of file Radar.cpp.

◆ isRadarForced()

Bool Radar::isRadarForced ( void )
inline

is radar forced on?

Definition at line 205 of file Radar.h.

◆ isRadarHidden()

Bool Radar::isRadarHidden ( void )
inline

is radar hidden

Definition at line 199 of file Radar.h.

◆ isRadarWindow()

Bool Radar::isRadarWindow ( GameWindow * window)
inline

Definition at line 169 of file Radar.h.

◆ loadPostProcess()

void Radar::loadPostProcess ( void )
protectedvirtual

Load post process

Implements Snapshot.

Definition at line 1539 of file Radar.cpp.

◆ localPixelToRadar()

Bool Radar::localPixelToRadar ( const ICoord2D * pixel,
ICoord2D * radar )

translate pixel (with UL of radar being (0,0)) to logical radar coords

Translate an actual pixel location (relative pixel with (0,0) being the top left of the radar area) to the "logical" radar coords that would cover the entire area of display on the screen. This is needed because some maps are "long" or "tall" and need a translation to any radar image that has been scaled to preserve the map aspect ratio

Definition at line 716 of file Radar.cpp.

◆ newMap()

void Radar::newMap ( TerrainLogic * terrain)
virtual

reset radar for new map

Reset the radar for the new map data being given to it

Reimplemented in W3DRadar.

Definition at line 333 of file Radar.cpp.

◆ objectUnderRadarPixel()

Object * Radar::objectUnderRadarPixel ( const ICoord2D * pixel)

return the object (if any) represented by the pixel coords passed in

Given the pixel coordinates, see if there is an object that is exactly in this spot represented on the radar

Definition at line 818 of file Radar.cpp.

◆ queueTerrainRefresh()

void Radar::queueTerrainRefresh ( void )
virtual

queue a refresh of the terran at the next available time

Queue a refresh of the radar terrain, we have this so that if there is code that rapidly needs to refresh the radar, it should use this so we aren't continually rebuilding the radar graphic because that process is slow. If you need to update the terrain on the radar immediately use refreshTerrain()

Definition at line 1358 of file Radar.cpp.

◆ radarToWorld()

Bool Radar::radarToWorld ( const ICoord2D * radar,
Coord3D * world )

radar point to world point on terrain

Translate a 2D spot on the radar (from (0,0) to (RADAR_CELL_WIDTH,RADAR_CELL_HEIGHT) to a 3D spot in the world on the terrain Return TRUE if the radar points translates to a valid world position Return FALSE if the radar point is not a valid world position

Definition at line 658 of file Radar.cpp.

◆ radarToWorld2D()

Bool Radar::radarToWorld2D ( const ICoord2D * radar,
Coord3D * world )

radar point to world point (x,y only!)

Translate a 2D spot on the radar (from (0,0) to (RADAR_CELL_WIDTH,RADAR_CELL_HEIGHT) to a 3D spot in the world. Does not determine Z value! Return TRUE if the radar points translates to a valid world position Return FALSE if the radar point is not a valid world position

Definition at line 624 of file Radar.cpp.

◆ refreshTerrain()

void Radar::refreshTerrain ( TerrainLogic * terrain)
virtual

refresh the water values for the radar

Reimplemented in W3DRadar.

Definition at line 1344 of file Radar.cpp.

◆ removeObject()

void Radar::removeObject ( Object * obj)

remove object from radar

Remove an object from the radar, the object may reside in any list

Definition at line 596 of file Radar.cpp.

◆ reset()

void Radar::reset ( void )
virtual

subsystem reset

Reset radar data

Implements SubsystemInterface.

Reimplemented in W3DRadar.

Definition at line 282 of file Radar.cpp.

◆ screenPixelToWorld()

Bool Radar::screenPixelToWorld ( const ICoord2D * pixel,
Coord3D * world )

translate pixel (with UL of the screen being (0,0)) to world position in the world

Translate a screen mouse position to world coords if the screen position is within the radar window and that spot in the radar corresponds to a point in the world

Definition at line 786 of file Radar.cpp.

◆ searchListForRadarLocationMatch()

Object * Radar::searchListForRadarLocationMatch ( RadarObject * listHead,
ICoord2D * radarMatch )
protected

Search the object list for an object that maps to the given logical radar coords

Definition at line 853 of file Radar.cpp.

◆ setShroudLevel()

virtual void Radar::setShroudLevel ( Int x,
Int y,
CellShroudStatus setting )
pure virtual

set the shroud level at shroud cell x,y

Implemented in W3DRadar.

◆ tryEvent()

Bool Radar::tryEvent ( RadarEventType event,
const Coord3D * pos )

try to make a "stealth" event

Definition at line 1293 of file Radar.cpp.

◆ tryInfiltrationEvent()

void Radar::tryInfiltrationEvent ( const Object * obj)

try to make an "infiltration" event if it's the proper time

Try to create a radar event for "infiltration". This happens whenever a unit is hijacked, defected, converted to carbomb, hacked, or otherwise snuck into

Todo
Should make an INI data driven table for radar event strings, and audio events

Definition at line 1257 of file Radar.cpp.

◆ tryUnderAttackEvent()

void Radar::tryUnderAttackEvent ( const Object * obj)

try to make an "under attack" event if it's the proper time

Try to create a radar event for "we're under attack". This will be called every time actual damage is dealt to an object that the player owns that shows up on the radar. We don't want to create under attack events every time we are damaged and we also want to limit them based on time and local area of other recent attack events

Todo
Should make an INI data driven table for radar event strings, and audio events

Definition at line 1171 of file Radar.cpp.

◆ update()

void Radar::update ( void )
virtual

subsystem per frame update

Radar per frame update

Implements SubsystemInterface.

Reimplemented in W3DRadar.

Definition at line 299 of file Radar.cpp.

◆ worldToRadar()

Bool Radar::worldToRadar ( const Coord3D * world,
ICoord2D * radar )

translate world point to radar (x,y)

Translate a point in the world to the 2D radar (x,y) Return TRUE if the world point successfully translates to a radar point Return FALSE if world point is a bogus off the map position

Definition at line 675 of file Radar.cpp.

◆ xfer()

void Radar::xfer ( Xfer * xfer)
protectedvirtual

Xfer Method Version Info: 1: Initial version

Implements Snapshot.

Definition at line 1479 of file Radar.cpp.

Member Data Documentation

◆ m_event

RadarEvent Radar::m_event[MAX_RADAR_EVENTS]
protected

our radar events

Definition at line 281 of file Radar.h.

◆ m_lastRadarEvent

Int Radar::m_lastRadarEvent
protected

index of the most recent radar event

Definition at line 283 of file Radar.h.

◆ m_localObjectList

RadarObject* Radar::m_localObjectList
protected

Definition at line 250 of file Radar.h.

◆ m_mapExtent

Region3D Radar::m_mapExtent
protected

extents of the current map

Definition at line 287 of file Radar.h.

◆ m_nextFreeRadarEvent

Int Radar::m_nextFreeRadarEvent
protected

index into m_event for where to store the next event

Definition at line 282 of file Radar.h.

◆ m_objectList

RadarObject* Radar::m_objectList
protected

list of objects in the radar

Definition at line 249 of file Radar.h.

◆ m_queueTerrainRefreshFrame

UnsignedInt Radar::m_queueTerrainRefreshFrame
protected

frame we requested the last terrain refresh on

Definition at line 289 of file Radar.h.

◆ m_radarForceOn

Bool Radar::m_radarForceOn
protected

true when radar is forced to be on

Definition at line 248 of file Radar.h.

◆ m_radarHidden

Bool Radar::m_radarHidden
protected

true when radar is not visible

Definition at line 247 of file Radar.h.

◆ m_radarWindow

GameWindow* Radar::m_radarWindow
protected

window we display the radar in

Definition at line 285 of file Radar.h.

◆ m_terrainAverageZ

Real Radar::m_terrainAverageZ
protected

average Z for terrain samples

list of objects for the local player, sorted in exactly the same priority as the regular object list for all other objects

Definition at line 256 of file Radar.h.

◆ m_waterAverageZ

Real Radar::m_waterAverageZ
protected

average Z for water samples

Definition at line 257 of file Radar.h.

◆ m_xSample

Real Radar::m_xSample
protected

Definition at line 264 of file Radar.h.

◆ m_ySample

Real Radar::m_ySample
protected

Definition at line 265 of file Radar.h.


The documentation for this class was generated from the following files: