Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gameengine): hash model contents, free the cannon from its beam drawable

Olcay Seygandb3dcab72d2b
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Module.h b/GeneralsMD/Code/GameEngine/Include/Common/Module.h
index b50da8840..5c8773dba 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/Module.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/Module.h
@@ -122,7 +122,11 @@ public:
* ask through ExitInterface. Both points are relative to the model origin. */
virtual Bool getProductionExitPointsInModelSpace( Coord3D& unitCreatePoint, Coord3D& naturalRallyPoint ) const { return FALSE; }
- static void buildFieldParse(MultiIniFieldParse& p)
+ /** A laser draw module's half width, read off the template rather than a drawable, so a
+ * Particle Cannon's damage radius does not depend on its beam being drawn. */
+ virtual Bool getLaserTemplateWidth( Real &width ) const { return FALSE; }
+
+ static void buildFieldParse(MultiIniFieldParse& p)
{
// nothing
}
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/LaserUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/LaserUpdate.h
index fb30f6ea5..e718824ac 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/LaserUpdate.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/LaserUpdate.h
@@ -81,8 +81,6 @@ public:
const Coord3D* getStartPos() { return &m_startPos; }
const Coord3D* getEndPos() { return &m_endPos; }
- Real getCurrentLaserRadius() const;
-
void setDirty( Bool dirty ) { m_dirty = dirty; }
Bool isDirty() { return m_dirty; }
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h
index 3a30fb171..ad0b668f0 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h
@@ -179,6 +179,9 @@ public:
void createOrbitToTargetLaser( UnsignedInt growthFrames );
void createGroundHitParticleSystem( IntensityTypes intensity );
+ Bool findOrbitBeamRadius( Real &radius ) const; ///< the beam template's half width, FALSE without a beam
+ Real computeOrbitBeamWidthScalar( UnsignedInt frame ) const;
+
Bool calculateDefaultInformation();
Bool calculateUpBonePositions();
@@ -228,6 +231,8 @@ protected:
UnsignedInt m_nextDamagePulseFrame;
UnsignedInt m_startAttackFrame;
UnsignedInt m_startDecayFrame;
+ UnsignedInt m_orbitBeamWidenFrame; ///< logic frame the orbit beam was born and began to widen
+ UnsignedInt m_orbitBeamDecayFrame; ///< logic frame it began to narrow
UnsignedInt m_lastDrivingClickFrame;
UnsignedInt m_2ndLastDrivingClickFrame;
UnsignedInt m_nextDestWaypointID;
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
index 723fd617e..ae77b7032 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
@@ -32,6 +32,7 @@
#include "Common/AudioAffect.h"
#include "Common/BuildAssistant.h"
#include "Common/CRCDebug.h"
+#include "Common/crc.h"
#include "Common/Radar.h"
#include "Common/PlayerTemplate.h"
#include "Common/Team.h"
@@ -204,27 +205,138 @@ static void checksumFileContents( XferCRC &xferCRC, const char *path )
delete [] contents;
}
+//-------------------------------------------------------------------------------------------------
+/** What a model's bytes hashed to, and the size and write time of the file they were read out of:
+ * the archive the model resolved to, or the loose model itself. */
+//-------------------------------------------------------------------------------------------------
+struct ModelChecksum
+{
+ FileInfo source;
+ UnsignedInt crc;
+};
+typedef std::map<std::string, ModelChecksum> ModelChecksumMap; ///< keyed "source|model"
+
+static const char *MODEL_CHECKSUM_CACHE = "ModelChecksums.txt";
+static const Int MODEL_CHECKSUM_LINE_LENGTH = 1024;
+
+static AsciiString modelChecksumCachePath( void )
+{
+ AsciiString path = TheGlobalData->getPath_UserData();
+ path.concat( MODEL_CHECKSUM_CACHE );
+ return path;
+}
+
+static ModelChecksumMap readModelChecksumCache( void )
+{
+ ModelChecksumMap cache;
+ FILE *cacheFile = fopen( modelChecksumCachePath().str(), "r" );
+ if (cacheFile == NULL)
+ return cache; // the first start on this machine, or the file was deleted
+
+ char line[MODEL_CHECKSUM_LINE_LENGTH];
+ while (fgets( line, sizeof( line ), cacheFile ))
+ {
+ ModelChecksum entry;
+ Int keyOffset = 0;
+ if (sscanf( line, "%x %d %d %d %d %n", &entry.crc, &entry.source.sizeHigh, &entry.source.sizeLow,
+ &entry.source.timestampHigh, &entry.source.timestampLow, &keyOffset ) != 5)
+ continue; // a torn line from a copy killed mid-write reads again from the model
+
+ std::string key( line + keyOffset );
+ key.erase( key.find_last_not_of( "\r\n" ) + 1 );
+ cache[key] = entry;
+ }
+ fclose( cacheFile );
+ return cache;
+}
+
+/** Written beside and moved over the old one, so a second copy starting at the same moment reads
+ * one whole file or the other and never half of each. */
+static void writeModelChecksumCache( const ModelChecksumMap &cache )
+{
+ AsciiString finalPath = modelChecksumCachePath();
+ AsciiString scratchPath;
+ scratchPath.format( "%s.%u", finalPath.str(), (UnsignedInt)GetCurrentProcessId() );
+
+ FILE *cacheFile = fopen( scratchPath.str(), "w" );
+ if (cacheFile == NULL)
+ return; // a read-only user folder costs the next start a full read, nothing else
+
+ for( ModelChecksumMap::const_iterator it = cache.begin(); it != cache.end(); ++it )
+ {
+ const ModelChecksum &entry = it->second;
+ fprintf( cacheFile, "%08X %d %d %d %d %s\n", entry.crc, entry.source.sizeHigh, entry.source.sizeLow,
+ entry.source.timestampHigh, entry.source.timestampLow, it->first.c_str() );
+ }
+ fclose( cacheFile );
+ if (!MoveFileExA( scratchPath.str(), finalPath.str(), MOVEFILE_REPLACE_EXISTING ))
+ DeleteFileA( scratchPath.str() ); // another copy holds it open; its own write will do
+}
+
+static Bool isSameFile( const FileInfo &left, const FileInfo &right )
+{
+ return left.sizeHigh == right.sizeHigh && left.sizeLow == right.sizeLow
+ && left.timestampHigh == right.timestampHigh && left.timestampLow == right.timestampLow;
+}
+
//-------------------------------------------------------------------------------------------------
/** Every model's bones place fire points, turret pivots and dock positions in logic, so a model
- * that differs between two machines splits their match. Hashing 190 MB of models on every start
- * costs seconds; the name and size of each model as it resolved catches a different patch
- * archive or a loose model, which are the two ways an install ends up with another one. */
+ * that differs between two machines splits their match. Each model's bytes go into the checksum
+ * as it resolved: a loose model beats every archive, and a later patch archive beats an earlier
+ * one. Reading all of them is about 375 MB, so what a model hashed to is kept in the user folder
+ * against the size and write time of the file it came from, and read again only when that file
+ * changes. */
//-------------------------------------------------------------------------------------------------
-static void checksumModelIndex( XferCRC &xferCRC )
+static void checksumModels( XferCRC &xferCRC )
{
FilenameList models;
TheFileSystem->getFileListInDirectory( AsciiString( "Art\\W3D\\" ), AsciiString( "*.w3d" ), models, TRUE );
+ const ModelChecksumMap cache = readModelChecksumCache();
+ ModelChecksumMap current;
+ Int modelsRead = 0;
+
for( FilenameListIter it = models.begin(); it != models.end(); ++it )
{
- AsciiString name = *it;
- name.toLower();
- FileInfo info;
- TheFileSystem->getFileInfo( *it, &info );
- xferCRC.xferUser( const_cast<char *>( name.str() ), name.getLength() );
- xferCRC.xferInt( &info.sizeLow );
+ AsciiString model = *it;
+ model.toLower();
+
+ AsciiString source = TheLocalFileSystem->doesFileExist( model.str() )
+ ? model : TheArchiveFileSystem->getArchiveFilenameForFile( model );
+
+ ModelChecksum entry;
+ const Bool sourceKnown = TheLocalFileSystem->getFileInfo( source, &entry.source );
+
+ std::string key( source.str() );
+ key.append( "|" );
+ key.append( model.str() );
+
+ ModelChecksumMap::const_iterator cached = cache.find( key );
+ if (sourceKnown && cached != cache.end() && isSameFile( cached->second.source, entry.source ))
+ {
+ entry.crc = cached->second.crc;
+ }
+ else
+ {
+ File *file = TheFileSystem->openFile( model.str(), File::READ );
+ Int fileSize = file->size();
+ char *contents = file->readEntireAndClose();
+ CRC modelCRC;
+ modelCRC.computeCRC( contents, fileSize );
+ delete [] contents;
+ entry.crc = modelCRC.get();
+ ++modelsRead;
+ }
+ if (sourceKnown)
+ current[key] = entry;
+
+ xferCRC.xferUser( const_cast<char *>( model.str() ), model.getLength() );
+ xferCRC.xferUnsignedInt( &entry.crc );
}
- DEBUG_LOG(( "INI CRC covers %d models\n", (Int)models.size() ));
+
+ if (modelsRead > 0)
+ writeModelChecksumCache( current );
+ DEBUG_LOG(( "INI CRC covers %d models, %d of them read this start\n", (Int)models.size(), modelsRead ));
}
Int GameEngine::getFramesPerSecondLimit( void )
@@ -1050,7 +1162,7 @@ void GameEngine::init( int argc, char *argv[] )
checksumFileContents( xferCRC, "Data\\INI\\Default\\CommandButton.ini" );
checksumFileContents( xferCRC, "Data\\INI\\CommandButton.ini" );
checksumFileContents( xferCRC, "Data\\INI\\CommandSet.ini" );
- checksumModelIndex( xferCRC );
+ checksumModels( xferCRC );
xferCRC.close();
TheWritableGlobalData->m_iniCRC = xferCRC.getCRC();
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/LaserUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/LaserUpdate.cpp
index 07b00112f..bc3806189 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/LaserUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/LaserUpdate.cpp
@@ -212,10 +212,9 @@ void LaserUpdate::clientUpdate( void )
}
//-------------------------------------------------------------------------------------------------
-/** The width on a given logic frame, worked out from the frames alone. The Particle Cannon damages
- * with this width, so it cannot come from m_currentWidthScalar: that one moves only when the client
- * updates, and a network game that catches up runs several logic ticks with no client pass between
- * them, which left the catching-up machine damaging with a width a few frames old. */
+/** The width on a given logic frame, worked out from the frames alone. The Particle Cannon's damage
+ * radius runs the same arithmetic on its own frames (ParticleUplinkCannonUpdate::
+ * computeOrbitBeamWidthScalar), so the picture and the damage agree without logic reading this. */
//-------------------------------------------------------------------------------------------------
Real LaserUpdate::computeWidthScalar( UnsignedInt frame ) const
{
@@ -393,26 +392,6 @@ void LaserUpdate::initLaser( const Object *parent, const Object *target, const C
m_dirty = true;
}
-//-------------------------------------------------------------------------------------------------
-Real LaserUpdate::getCurrentLaserRadius() const
-{
- const Drawable *draw = getDrawable();
- const LaserDrawInterface* ldi = NULL;
- for( const DrawModule** d = draw->getDrawModules(); *d; ++d )
- {
- ldi = (*d)->getLaserDrawInterface();
- if( ldi )
- {
- //***NOTE***
- //While it appears the logic is accessing client data, it is actually accessing template module
- //data from the client. This value is INI constant thus can't change. It's grouped with other
- //laser defining attributes and having it there makes it easier for artists.
- return ldi->getLaserTemplateWidth() * computeWidthScalar( TheGameLogic->getFrame() );
- }
- }
- return 0.0f;
-}
-
// ------------------------------------------------------------------------------------------------
/** CRC */
// ------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp
index 28538baee..241c74da0 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp
@@ -200,6 +200,8 @@ ParticleUplinkCannonUpdate::ParticleUplinkCannonUpdate( Thing *thing, const Modu
m_nextDamagePulseFrame = 0;
m_startAttackFrame = 0;
m_startDecayFrame = 0;
+ m_orbitBeamWidenFrame = 0;
+ m_orbitBeamDecayFrame = 0;
m_lastDrivingClickFrame = 0;
m_2ndLastDrivingClickFrame = 0;
m_clientShroudedLastFrame = FALSE;
@@ -456,6 +458,7 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
if( orbitalBirthFrame <= now )
{
createOrbitToTargetLaser( data->m_widthGrowFrames );
+ m_orbitBeamWidenFrame = now;
m_laserStatus = LASERSTATUS_BORN;
m_scorchMarksMade = 0;
m_nextScorchMarkFrame = now;
@@ -463,13 +466,15 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
m_nextDamagePulseFrame = now;
}
break;
+ /* The beam drawable is only the picture: the state below moves on the logic's frames
+ whether or not it exists, because a machine that culled or never made it would
+ otherwise keep a cannon firing that every other machine has stopped. */
case LASERSTATUS_BORN:
{
- Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
- if( beam )
+ if( orbitalDecayStart <= now )
{
- //m_annihilationSound.setPosition( beam->getPosition() );
- if( orbitalDecayStart <= now )
+ Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
+ if( beam )
{
static NameKeyType nameKeyClientUpdate = NAMEKEY( "LaserUpdate" );
LaserUpdate *update = (LaserUpdate*)beam->findClientUpdateModule( nameKeyClientUpdate );
@@ -477,8 +482,9 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
{
update->setDecayFrames( data->m_widthGrowFrames );
}
- m_laserStatus = LASERSTATUS_DECAYING;
}
+ m_orbitBeamDecayFrame = now;
+ m_laserStatus = LASERSTATUS_DECAYING;
}
break;
}
@@ -487,16 +493,18 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
if( beam )
{
- //m_annihilationSound.setPosition( beam->getPosition() );
TheAudio->removeAudioEvent( m_annihilationSound.getPlayingHandle() );
- if( orbitalDeathFrame <= now )
+ }
+ if( orbitalDeathFrame <= now )
+ {
+ if( beam )
{
TheGameClient->destroyDrawable( beam );
- m_orbitToTargetBeamID = INVALID_DRAWABLE_ID;
- m_laserStatus = LASERSTATUS_DEAD;
- m_startAttackFrame = 0;
- setLogicalStatus( STATUS_IDLE );
}
+ m_orbitToTargetBeamID = INVALID_DRAWABLE_ID;
+ m_laserStatus = LASERSTATUS_DEAD;
+ m_startAttackFrame = 0;
+ setLogicalStatus( STATUS_IDLE );
}
break;
}
@@ -506,9 +514,12 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
}
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
- if( beam && orbitalBirthFrame <= now && now <= orbitalDeathFrame )
+ Real beamRadius = 0.0f;
+ const Bool beamLive = (m_laserStatus == LASERSTATUS_BORN || m_laserStatus == LASERSTATUS_DECAYING)
+ && findOrbitBeamRadius( beamRadius );
+ if( beamLive && orbitalBirthFrame <= now && now <= orbitalDeathFrame )
{
-
+
if( !m_manualTargetMode && !m_scriptedWaypointMode )
{
//Calculate the position of the beam because it swaths -- a nice S curve centering at the target location!
@@ -617,23 +628,25 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
orbitPosition.set( &m_currentTargetPosition );
orbitPosition.z += ORBITAL_BEAM_Z_OFFSET;
- Real scorchRadius = 0.0f;
- Real damageRadius = 0.0f;
+ const Real laserRadius = beamRadius * computeOrbitBeamWidthScalar( now );
+ const Real scorchRadius = laserRadius * data->m_scorchMarkScalar;
+ const Real damageRadius = laserRadius * data->m_damageRadiusScalar;
- //Reset the laser position
- static NameKeyType nameKeyClientUpdate = NAMEKEY( "LaserUpdate" );
- LaserUpdate *update = (LaserUpdate*)beam->findClientUpdateModule( nameKeyClientUpdate );
- if( update )
+ if( beam )
{
- update->initLaser( NULL, NULL, &orbitPosition, &m_currentTargetPosition, "" );
- scorchRadius = update->getCurrentLaserRadius() * data->m_scorchMarkScalar;
- damageRadius = update->getCurrentLaserRadius() * data->m_damageRadiusScalar;
- }
+ //Reset the laser position
+ static NameKeyType nameKeyClientUpdate = NAMEKEY( "LaserUpdate" );
+ LaserUpdate *update = (LaserUpdate*)beam->findClientUpdateModule( nameKeyClientUpdate );
+ if( update )
+ {
+ update->initLaser( NULL, NULL, &orbitPosition, &m_currentTargetPosition, "" );
+ }
- // Keep the emitter where it used to be, near the ground the beam is hitting.
- Coord3D audioPos = m_currentTargetPosition;
- audioPos.z += ORBITAL_BEAM_AUDIO_Z_OFFSET;
- beam->setPosition( &audioPos );
+ // Keep the emitter where it used to be, near the ground the beam is hitting.
+ Coord3D audioPos = m_currentTargetPosition;
+ audioPos.z += ORBITAL_BEAM_AUDIO_Z_OFFSET;
+ beam->setPosition( &audioPos );
+ }
//Create scorch marks periodically
if( m_nextScorchMarkFrame <= now )
@@ -1079,6 +1092,49 @@ void ParticleUplinkCannonUpdate::removeAllEffects()
//Remove all sound hooks
}
+//-------------------------------------------------------------------------------------------------
+/** The orbit beam's half width, off its template's laser draw module: what LaserUpdate read off the
+ * beam drawable, without needing the drawable. FALSE when there is no beam to fire, which is when
+ * createOrbitToTargetLaser makes none either. */
+//-------------------------------------------------------------------------------------------------
+Bool ParticleUplinkCannonUpdate::findOrbitBeamRadius( Real &radius ) const
+{
+ const ParticleUplinkCannonUpdateModuleData *data = getParticleUplinkCannonUpdateModuleData();
+ if( data->m_particleBeamLaserName.isEmpty() )
+ return FALSE;
+
+ const ThingTemplate *beamTemplate = TheThingFactory->findTemplate( data->m_particleBeamLaserName );
+ if( beamTemplate == NULL )
+ return FALSE;
+
+ const ModuleInfo &drawModules = beamTemplate->getDrawModuleInfo();
+ for( Int i = 0; i < drawModules.getCount(); ++i )
+ {
+ if( drawModules.getNthData( i )->getLaserTemplateWidth( radius ) )
+ return TRUE;
+ }
+ radius = 0.0f;
+ return TRUE;
+}
+
+//-------------------------------------------------------------------------------------------------
+/** LaserUpdate::computeWidthScalar on the cannon's own frames: wider from birth over WidthGrowTime,
+ * narrower from the decay over the same time, the same arithmetic so the radius is the same float. */
+//-------------------------------------------------------------------------------------------------
+Real ParticleUplinkCannonUpdate::computeOrbitBeamWidthScalar( UnsignedInt frame ) const
+{
+ const UnsignedInt growFrames = getParticleUplinkCannonUpdateModuleData()->m_widthGrowFrames;
+ if( growFrames == 0 )
+ return 1.0f;
+
+ if( m_laserStatus == LASERSTATUS_DECAYING )
+ {
+ Real scalar = 1.0f - (Real)(frame - m_orbitBeamDecayFrame) / (Real)growFrames;
+ return scalar <= 0.0f ? 0.0f : scalar;
+ }
+ Real scalar = (Real)(frame - m_orbitBeamWidenFrame) / (Real)growFrames;
+ return scalar >= 1.0f ? 1.0f : scalar;
+}
//-------------------------------------------------------------------------------------------------
Bool ParticleUplinkCannonUpdate::calculateDefaultInformation()
@@ -1370,14 +1426,15 @@ void ParticleUplinkCannonUpdate::crc( Xfer *xfer )
// ------------------------------------------------------------------------------------------------
/** Xfer method
* Version Info:
- * 1: Initial version */
+ * 1: Initial version
+ * 4: the orbit beam's widen and decay frames, which the damage radius is worked out from */
// ------------------------------------------------------------------------------------------------
void ParticleUplinkCannonUpdate::xfer( Xfer *xfer )
{
const ParticleUplinkCannonUpdateModuleData *data = getParticleUplinkCannonUpdateModuleData();
// version
- XferVersion currentVersion = 3;
+ XferVersion currentVersion = 4;
XferVersion version = currentVersion;
xfer->xferVersion( &version, currentVersion );
@@ -1485,6 +1542,18 @@ void ParticleUplinkCannonUpdate::xfer( Xfer *xfer )
xfer->xferUnsignedInt( &m_nextDestWaypointID );
}
+ if( version >= 4 )
+ {
+ xfer->xferUnsignedInt( &m_orbitBeamWidenFrame );
+ xfer->xferUnsignedInt( &m_orbitBeamDecayFrame );
+ }
+ else
+ {
+ // an older save fired on schedule, and the beam changed state on these frames
+ m_orbitBeamWidenFrame = m_startAttackFrame + data->m_beamTravelFrames;
+ m_orbitBeamDecayFrame = m_startDecayFrame + data->m_beamTravelFrames;
+ }
+
} // end xfer
// ------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DLaserDraw.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DLaserDraw.h
index 2dbc25047..c8f34729e 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DLaserDraw.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DLaserDraw.h
@@ -62,6 +62,8 @@ public:
W3DLaserDrawModuleData();
~W3DLaserDrawModuleData();
static void buildFieldParse(MultiIniFieldParse& p);
+
+ virtual Bool getLaserTemplateWidth( Real &width ) const { width = m_outerBeamWidth * 0.5f; return TRUE; }
};
//-------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp
index 76d38ad6e..eae9b249e 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp
@@ -243,8 +243,9 @@ W3DLaserDraw::~W3DLaserDraw( void )
//-------------------------------------------------------------------------------------------------
Real W3DLaserDraw::getLaserTemplateWidth() const
{
- const W3DLaserDrawModuleData *data = getW3DLaserDrawModuleData();
- return data->m_outerBeamWidth * 0.5f;
+ Real width = 0.0f;
+ getW3DLaserDrawModuleData()->getLaserTemplateWidth( width );
+ return width;
}
//-------------------------------------------------------------------------------------------------