Merge branch 'development' of https://github.com/GarageGames/Torque3D into andOrMaybe

Conflicts:
	Engine/source/T3D/staticShape.cpp
This commit is contained in:
Azaezel 2016-12-20 22:50:28 -06:00
commit dd071484da
517 changed files with 87707 additions and 178465 deletions

View file

@ -91,9 +91,9 @@ ConsoleSetType(TypeComponentAssetPtr)
//-----------------------------------------------------------------------------
ComponentAsset::ComponentAsset() :
mAcquireReferenceCount(0),
mpOwningAssetManager(NULL),
mAssetInitialized(false)
mAssetInitialized(false),
mAcquireReferenceCount(0)
{
// Generate an asset definition.
mpAssetDefinition = new AssetDefinition();

View file

@ -91,9 +91,9 @@ ConsoleSetType(TypeExampleAssetPtr)
//-----------------------------------------------------------------------------
ExampleAsset::ExampleAsset() :
mAcquireReferenceCount(0),
mpOwningAssetManager(NULL),
mAssetInitialized(false)
mAssetInitialized(false),
mAcquireReferenceCount(0)
{
// Generate an asset definition.
mpAssetDefinition = new AssetDefinition();

View file

@ -91,9 +91,9 @@ ConsoleSetType(TypeGameObjectAssetPtr)
//-----------------------------------------------------------------------------
GameObjectAsset::GameObjectAsset() :
mAcquireReferenceCount(0),
mpOwningAssetManager(NULL),
mAssetInitialized(false)
mAssetInitialized(false),
mAcquireReferenceCount(0)
{
// Generate an asset definition.
mpAssetDefinition = new AssetDefinition();

View file

@ -45,9 +45,6 @@
// Debug Profiling.
#include "platform/profiler.h"
static U32 execDepth = 0;
static U32 journalDepth = 1;
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT(ShapeAsset);
@ -96,9 +93,9 @@ ConsoleSetType(TypeShapeAssetPtr)
//-----------------------------------------------------------------------------
ShapeAsset::ShapeAsset() :
mAcquireReferenceCount(0),
mpOwningAssetManager(NULL),
mAssetInitialized(false)
mAssetInitialized(false),
mAcquireReferenceCount(0)
{
}

View file

@ -39,14 +39,14 @@ class WaterObject;
struct ContainerQueryInfo
{
ContainerQueryInfo()
: waterCoverage(0.0f),
: box(-1,-1,-1,1,1,1),
mass(1.0f),
waterCoverage(0.0f),
waterHeight(0.0f),
waterDensity(0.0f),
waterViscosity(0.0f),
gravityScale(1.0f),
appliedForce(0,0,0),
box(-1,-1,-1,1,1,1),
mass(1.0f),
waterObject(NULL)
{
}

View file

@ -227,12 +227,12 @@ bool ConvexShape::protectedSetSurface( void *object, const char *index, const ch
ConvexShape::ConvexShape()
: mMaterialInst( NULL ),
mNormalLength( 0.3f ),
: mMaterialName( "Grid512_OrangeLines_Mat" ),
mMaterialInst( NULL ),
mVertCount( 0 ),
mPrimCount( 0 ),
mMaterialName( "Grid512_OrangeLines_Mat" ),
mPhysicsRep( NULL )
mPhysicsRep( NULL ),
mNormalLength( 0.3f )
{
mNetFlags.set( Ghostable | ScopeAlways );
@ -1102,8 +1102,6 @@ void ConvexShape::_updateGeometry( bool updateCollision )
const Vector< ConvexShape::Triangle > &triangles = face.triangles;
const ColorI &faceColor = sgConvexFaceColors[ i % sgConvexFaceColorCount ];
const Point3F binormal = mCross( face.normal, face.tangent );
for ( S32 j = 0; j < triangles.size(); j++ )
{
for ( S32 k = 0; k < 3; k++ )

View file

@ -43,9 +43,6 @@
const U32 csmStaticCollisionMask = TerrainObjectType | StaticShapeObjectType | StaticObjectType;
const U32 csmDynamicCollisionMask = StaticShapeObjectType;
IMPLEMENT_CO_DATABLOCK_V1(DebrisData);
ConsoleDocClass( DebrisData,

View file

@ -62,8 +62,8 @@ struct DebrisData : public GameBaseData
F32 elasticity;
F32 lifetime;
F32 lifetimeVariance;
U32 numBounces;
U32 bounceVariance;
S32 numBounces;
S32 bounceVariance;
F32 minSpinSpeed;
F32 maxSpinSpeed;
bool explodeOnMaxBounce; // explodes after it has bounced max times

View file

@ -43,6 +43,7 @@ class GuiHealthBarHud : public GuiControl
bool mShowFrame;
bool mShowFill;
bool mDisplayEnergy;
bool mFlip;
ColorF mFillColor;
ColorF mFrameColor;
@ -105,6 +106,8 @@ GuiHealthBarHud::GuiHealthBarHud()
mPulseRate = 0;
mPulseThreshold = 0.3f;
mValue = 0.2f;
mFlip = false;
}
void GuiHealthBarHud::initPersistFields()
@ -124,6 +127,7 @@ void GuiHealthBarHud::initPersistFields()
addField( "showFill", TypeBool, Offset( mShowFill, GuiHealthBarHud ), "If true, we draw the background color of the control." );
addField( "showFrame", TypeBool, Offset( mShowFrame, GuiHealthBarHud ), "If true, we draw the frame of the control." );
addField( "displayEnergy", TypeBool, Offset( mDisplayEnergy, GuiHealthBarHud ), "If true, display the energy value rather than the damage value." );
addField( "flip", TypeBool, Offset( mFlip, GuiHealthBarHud), "If true, will fill bar in opposite direction.");
endGroup("Misc");
Parent::initPersistFields();
@ -163,6 +167,7 @@ void GuiHealthBarHud::onRender(Point2I offset, const RectI &updateRect)
// Pulse the damage fill if it's below the threshold
if (mPulseRate != 0)
{
if (mValue < mPulseThreshold)
{
U32 time = Platform::getVirtualMilliseconds();
@ -171,16 +176,25 @@ void GuiHealthBarHud::onRender(Point2I offset, const RectI &updateRect)
}
else
mDamageFillColor.alpha = 1;
}
// Render damage fill %
RectI rect(updateRect);
if(getWidth() > getHeight())
{
rect.extent.x = (S32)(rect.extent.x * mValue);
if(mFlip)
rect.point.x = (S32)(updateRect.point.x + (updateRect.extent.x - rect.extent.x));
}
else
{
S32 bottomY = rect.point.y + rect.extent.y;
rect.extent.y = (S32)(rect.extent.y * mValue);
rect.point.y = bottomY - rect.extent.y;
if(mFlip)
rect.extent.y = (S32)(updateRect.extent.y - (updateRect.extent.y - rect.extent.y));
else
rect.point.y = bottomY - rect.extent.y;
}
GFX->getDrawUtil()->drawRectFill(rect, mDamageFillColor);

View file

@ -110,9 +110,6 @@ ConsoleDocClass( GuiShapeNameHud,
"@ingroup GuiGame\n"
);
/// Default distance for object's information to be displayed.
static const F32 cDefaultVisibleDistance = 500.0f;
GuiShapeNameHud::GuiShapeNameHud()
{
mFillColor.set( 0.25f, 0.25f, 0.25f, 0.25f );

View file

@ -132,7 +132,6 @@ ConsoleDocClass( fxFoliageReplicator,
// Trig Table Lookups.
//
//------------------------------------------------------------------------------
const F32 PeriodLen = (F32) 2.0f * (F32) M_PI;
const F32 PeriodLenMinus = (F32) (2.0f * M_PI) - 0.01f;
//------------------------------------------------------------------------------

View file

@ -60,14 +60,14 @@ GFXImplementVertexFormat( GCVertex )
};
GroundCoverShaderConstHandles::GroundCoverShaderConstHandles()
: mTypeRectsSC( NULL ),
: mGroundCover( NULL ),
mTypeRectsSC( NULL ),
mFadeSC( NULL ),
mWindDirSC( NULL ),
mGustInfoSC( NULL ),
mTurbInfoSC( NULL ),
mCamRightSC( NULL ),
mCamUpSC( NULL ),
mGroundCover( NULL )
mCamUpSC( NULL )
{
}

View file

@ -87,7 +87,7 @@ class ParticleEmitterData : public GameBaseData
/// of the ambient color on the particle.
F32 ambientFactor;
U32 lifetimeMS; ///< Lifetime of particles
S32 lifetimeMS; ///< Lifetime of particles
U32 lifetimeVarianceMS; ///< Varience in lifetime from 0 to n
bool overrideAdvance; ///<

View file

@ -354,7 +354,7 @@ void Ribbon::addSegmentPoint(Point3F &point, MatrixF &mat) {
U32 segmentsToDelete = checkRibbonDistance(mDataBlock->segmentsPerUpdate);
for (U32 i = 0; i < segmentsToDelete; i++) {
U32 last = mSegmentPoints.size() - 1;
S32 last = mSegmentPoints.size() - 1;
if (last < 0)
break;
mTravelledDistance += last ? (mSegmentPoints[last] - mSegmentPoints[last-1]).len() : 0;

View file

@ -97,14 +97,14 @@ IMPLEMENT_CALLBACK( GameBaseData, onRemove, void, ( GameBase* obj ), ( obj ),
"@param obj the GameBase object\n\n"
"@see onAdd for an example\n" );
IMPLEMENT_CALLBACK( GameBaseData, onMount, void, ( GameBase* obj, SceneObject* mountObj, S32 node ), ( obj, mountObj, node ),
IMPLEMENT_CALLBACK( GameBaseData, onMount, void, ( SceneObject* obj, SceneObject* mountObj, S32 node ), ( obj, mountObj, node ),
"@brief Called when the object is mounted to another object in the scene.\n\n"
"@param obj the GameBase object being mounted\n"
"@param mountObj the object we are mounted to\n"
"@param node the mountObj node we are mounted to\n\n"
"@see onAdd for an example\n" );
IMPLEMENT_CALLBACK( GameBaseData, onUnmount, void, ( GameBase* obj, SceneObject* mountObj, S32 node ), ( obj, mountObj, node ),
IMPLEMENT_CALLBACK( GameBaseData, onUnmount, void, ( SceneObject* obj, SceneObject* mountObj, S32 node ), ( obj, mountObj, node ),
"@brief Called when the object is unmounted from another object in the scene.\n\n"
"@param obj the GameBase object being unmounted\n"
"@param mountObj the object we are unmounted from\n"

View file

@ -110,8 +110,8 @@ public:
DECLARE_CALLBACK( void, onAdd, ( GameBase* obj ) );
DECLARE_CALLBACK( void, onRemove, ( GameBase* obj ) );
DECLARE_CALLBACK( void, onNewDataBlock, ( GameBase* obj ) );
DECLARE_CALLBACK( void, onMount, ( GameBase* obj, SceneObject* mountObj, S32 node ) );
DECLARE_CALLBACK( void, onUnmount, ( GameBase* obj, SceneObject* mountObj, S32 node ) );
DECLARE_CALLBACK( void, onMount, ( SceneObject* obj, SceneObject* mountObj, S32 node ) );
DECLARE_CALLBACK( void, onUnmount, ( SceneObject* obj, SceneObject* mountObj, S32 node ) );
/// @}
};

View file

@ -36,7 +36,12 @@ class BitStream;
struct Move
{
enum { ChecksumBits = 16, ChecksumMask = ((1<<ChecksumBits)-1), ChecksumMismatch = U32(-1) };
enum : U32
{
ChecksumBits = 16,
ChecksumMask = ((1<<ChecksumBits)-1),
ChecksumMismatch = U32(-1)
};
// packed storage rep, set in clamp
S32 px, py, pz;

View file

@ -69,9 +69,9 @@ GroundPlane::GroundPlane()
mScaleU( 1.0f ),
mScaleV( 1.0f ),
mMaterial( NULL ),
mPhysicsRep( NULL ),
mMin( 0.0f, 0.0f ),
mMax( 0.0f, 0.0f ),
mPhysicsRep( NULL )
mMax( 0.0f, 0.0f )
{
mTypeMask |= StaticObjectType | StaticShapeObjectType;
mNetFlags.set( Ghostable | ScopeAlways );

View file

@ -36,15 +36,15 @@
// GuiMaterialPreview
GuiMaterialPreview::GuiMaterialPreview()
: mMaxOrbitDist(5.0f),
mMinOrbitDist(0.0f),
mOrbitDist(5.0f),
mMouseState(None),
: mMouseState(None),
mModel(NULL),
mLastMousePoint(0, 0),
lastRenderTime(0),
runThread(0),
mFakeSun(NULL)
lastRenderTime(0),
mLastMousePoint(0, 0),
mFakeSun(NULL),
mMaxOrbitDist(5.0f),
mMinOrbitDist(0.0f),
mOrbitDist(5.0f)
{
mActive = true;
mCameraMatrix.identity();

View file

@ -89,21 +89,21 @@ IMPLEMENT_CALLBACK( GuiObjectView, onMouseLeave, void, (),(),
//------------------------------------------------------------------------------
GuiObjectView::GuiObjectView()
: mMaxOrbitDist( 5.0f ),
mMinOrbitDist( 0.0f ),
mOrbitDist( 5.0f ),
mMouseState( None ),
mModel( NULL ),
mMountedModel( NULL ),
: mMouseState( None ),
mLastMousePoint( 0, 0 ),
mLastRenderTime( 0 ),
mRunThread( NULL ),
mLight( NULL ),
mAnimationSeq( -1 ),
mMountNodeName( "mount0" ),
mMountNode( -1 ),
mModel( NULL ),
mMaxOrbitDist( 5.0f ),
mMinOrbitDist( 0.0f ),
mCameraRotation( 0.0f, 0.0f, 0.0f ),
mOrbitDist( 5.0f ),
mCameraSpeed( 0.01f ),
mCameraRotation( 0.0f, 0.0f, 0.0f ),
mMountNode( -1 ),
mMountNodeName( "mount0" ),
mMountedModel( NULL ),
mAnimationSeq( -1 ),
mRunThread( NULL ),
mLastRenderTime( 0 ),
mLight( NULL ),
mLightColor( 1.0f, 1.0f, 1.0f ),
mLightAmbient( 0.5f, 0.5f, 0.5f ),
mLightDirection( 0.f, 0.707f, -0.707f )

View file

@ -79,16 +79,16 @@ static SFXAmbience sDefaultAmbience;
//-----------------------------------------------------------------------------
LevelInfo::LevelInfo()
: mNearClip( 0.1f ),
: mWorldSize( 10000.0f ),
mNearClip( 0.1f ),
mVisibleDistance( 1000.0f ),
mVisibleGhostDistance ( 0 ),
mDecalBias( 0.0015f ),
mCanvasClearColor( 255, 0, 255, 255 ),
mAmbientLightBlendPhase( 1.f ),
mSoundAmbience( NULL ),
mSoundscape( NULL ),
mSoundDistanceModel( SFXDistanceModelLinear ),
mWorldSize( 10000.0f ),
mAmbientLightBlendPhase( 1.f )
mSoundscape( NULL )
{
mFogData.density = 0.0f;
mFogData.densityOffset = 0.0f;

View file

@ -93,7 +93,7 @@ void LightBase::initPersistFields()
addField( "brightness", TypeF32, Offset( mBrightness, LightBase ), "Adjusts the lights power, 0 being off completely." );
addField( "castShadows", TypeBool, Offset( mCastShadows, LightBase ), "Enables/disabled shadow casts by this light." );
addField( "staticRefreshFreq", TypeS32, Offset( mStaticRefreshFreq, LightBase ), "static shadow refresh rate (milliseconds)" );
addField( "dynamicRefreshFreq", TypeS32, Offset( mDynamicRefreshFreq, LightBase ), "dynamic shadow refresh rate (milliseconds)" );
addField( "dynamicRefreshFreq", TypeS32, Offset( mDynamicRefreshFreq, LightBase ), "dynamic shadow refresh rate (milliseconds)", AbstractClassRep::FieldFlags::FIELD_HideInInspectors);
addField( "priority", TypeF32, Offset( mPriority, LightBase ), "Used for sorting of lights by the light manager. "
"Priority determines if a light has a stronger effect than, those with a lower value" );

View file

@ -97,7 +97,7 @@ void LightDescription::initPersistFields()
addField( "range", TypeF32, Offset( range, LightDescription ), "Controls the size (radius) of the light" );
addField( "castShadows", TypeBool, Offset( castShadows, LightDescription ), "Enables/disabled shadow casts by this light." );
addField( "staticRefreshFreq", TypeS32, Offset( mStaticRefreshFreq, LightDescription ), "static shadow refresh rate (milliseconds)" );
addField( "dynamicRefreshFreq", TypeS32, Offset( mDynamicRefreshFreq, LightDescription ), "dynamic shadow refresh rate (milliseconds)" );
addField( "dynamicRefreshFreq", TypeS32, Offset( mDynamicRefreshFreq, LightDescription ), "dynamic shadow refresh rate (milliseconds)", AbstractClassRep::FieldFlags::FIELD_HideInInspectors);
endGroup( "Light" );

View file

@ -118,11 +118,11 @@ ConsoleDocClass( LightFlareData,
);
LightFlareData::LightFlareData()
: mFlareEnabled( true ),
mElementCount( 0 ),
mScale( 1.0f ),
: mScale( 1.0f ),
mFlareEnabled( true ),
mOcclusionRadius( 0.0f ),
mRenderReflectPass( true )
mRenderReflectPass( true ),
mElementCount( 0 )
{
dMemset( mElementRect, 0, sizeof( RectF ) * MAX_ELEMENTS );
dMemset( mElementScale, 0, sizeof( F32 ) * MAX_ELEMENTS );

View file

@ -151,7 +151,7 @@ enum SceneObjectTypes
/// @}
};
enum SceneObjectTypeMasks
enum SceneObjectTypeMasks : U32
{
STATIC_COLLISION_TYPEMASK = (StaticShapeObjectType |
EntityObjectType),

View file

@ -46,9 +46,9 @@ struct PhysicsState
momentum( Point3F::Zero ),
orientation( QuatF::Identity ),
angularMomentum( Point3F::Zero ),
sleeping( false ),
linVelocity( Point3F::Zero ),
angVelocity( Point3F::Zero ),
sleeping( false )
angVelocity( Point3F::Zero )
{
}

View file

@ -312,11 +312,11 @@ PhysicsDebris* PhysicsDebris::create( PhysicsDebrisData *datablock,
}
PhysicsDebris::PhysicsDebris()
: mDataBlock( NULL ),
mLifetime( 0.0f ),
: mLifetime( 0.0f ),
mInitialLinVel( Point3F::Zero ),
mDataBlock( NULL ),
mShapeInstance( NULL ),
mWorld( NULL ),
mInitialLinVel( Point3F::Zero )
mWorld( NULL )
{
mTypeMask |= DebrisObjectType | DynamicShapeObjectType;

View file

@ -41,9 +41,10 @@ ConsoleDocClass( PhysicsForce,
PhysicsForce::PhysicsForce()
: mWorld( NULL ),
mBody( NULL ),
mPhysicsTick( false )
:
mWorld( NULL ),
mPhysicsTick( false ),
mBody( NULL )
{
}

View file

@ -401,12 +401,12 @@ ConsoleDocClass( PhysicsShape,
PhysicsShape::PhysicsShape()
: mPhysicsRep( NULL ),
mWorld( NULL ),
mShapeInst( NULL ),
mResetPos( MatrixF::Identity ),
mShapeInst( NULL ),
mDestroyed( false ),
mPlayAmbient( false ),
mAmbientThread( NULL ),
mAmbientSeq( -1 )
mAmbientSeq( -1 ),
mAmbientThread( NULL )
{
mNetFlags.set( Ghostable | ScopeAlways );
mTypeMask |= DynamicShapeObjectType;

View file

@ -55,11 +55,12 @@ public:
/// The constructor.
PhysicsUserData()
: mObject( NULL ),
:
#ifdef TORQUE_DEBUG
mTypeId( smTypeName ),
#endif
mObject( NULL ),
mBody( NULL )
#ifdef TORQUE_DEBUG
, mTypeId( smTypeName )
#endif
{}
/// The destructor.
@ -117,4 +118,4 @@ protected:
PhysicsBody *mBody;
};
#endif // _PHYSICS_PHYSICSUSERDATA_H_
#endif // _PHYSICS_PHYSICSUSERDATA_H_

View file

@ -109,8 +109,6 @@ static S32 sMaxPredictionTicks = 30; // Number of ticks to predict
S32 Player::smExtendedMoveHeadPosRotIndex = 0; // The ExtendedMove position/rotation index used for head movements
// Anchor point compression
const F32 sAnchorMaxDistance = 32.0f;
//
static U32 sCollisionMoveMask = TerrainObjectType |
@ -3835,11 +3833,13 @@ void Player::updateActionThread()
// Select an action animation sequence, this assumes that
// this function is called once per tick.
if(mActionAnimation.action != PlayerData::NullAnimation)
{
if (mActionAnimation.forward)
mActionAnimation.atEnd = mShapeInstance->getPos(mActionAnimation.thread) == 1;
else
mActionAnimation.atEnd = mShapeInstance->getPos(mActionAnimation.thread) == 0;
}
// Only need to deal with triggers on the client
if( isGhost() )
{
@ -4514,7 +4514,7 @@ void Player::onImageAnimThreadUpdate(U32 imageSlot, S32 imageShapeIndex, F32 dt)
}
}
void Player::onUnmount( ShapeBase *obj, S32 node )
void Player::onUnmount( SceneObject *obj, S32 node )
{
// Reset back to root position during dismount.
setActionThread(PlayerData::RootAnim,true,false,false);
@ -4581,6 +4581,7 @@ void Player::updateAnimationTree(bool firstPerson)
{
S32 mode = 0;
if (firstPerson)
{
if (mActionAnimation.firstPerson)
mode = 0;
// TSShapeInstance::MaskNodeRotation;
@ -4588,7 +4589,7 @@ void Player::updateAnimationTree(bool firstPerson)
// TSShapeInstance::MaskNodePosY;
else
mode = TSShapeInstance::MaskNodeAllButBlend;
}
for (U32 i = 0; i < PlayerData::NumSpineNodes; i++)
if (mDataBlock->spineNode[i] != -1)
mShapeInstance->setNodeAnimationState(mDataBlock->spineNode[i],mode);

View file

@ -484,7 +484,7 @@ protected:
/// @{
struct ActionAnimation {
U32 action;
S32 action;
TSThread* thread;
S32 delayTicks; // before picking another.
bool forward;
@ -628,7 +628,7 @@ protected:
/// @name Mounted objects
/// @{
virtual void onUnmount( ShapeBase *obj, S32 node );
virtual void onUnmount( SceneObject *obj, S32 node );
virtual void unmount();
/// @}

View file

@ -525,6 +525,19 @@ bool Prefab::isValidChild( SimObject *simobj, bool logWarnings )
return true;
}
bool Prefab::buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F &box, const SphereF& sphere)
{
Vector<SceneObject*> foundObjects;
mChildGroup->findObjectByType(foundObjects);
for (S32 i = 0; i < foundObjects.size(); i++)
{
foundObjects[i]->buildPolyList(context, polyList, box, sphere);
}
return true;
}
ExplodePrefabUndoAction::ExplodePrefabUndoAction( Prefab *prefab )
: UndoAction( "Explode Prefab" )
{

View file

@ -96,6 +96,8 @@ public:
/// which is added to the MissionGroup and returned to the caller.
SimGroup* explode();
bool buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F &box, const SphereF& sphere);
protected:
void _closeFile( bool removeFileNotify );

View file

@ -551,14 +551,14 @@ S32 ProjectileData::scaleValue( S32 value, bool down )
Projectile::Projectile()
: mPhysicsWorld( NULL ),
mDataBlock( NULL ),
mParticleEmitter( NULL ),
mParticleWaterEmitter( NULL ),
mSound( NULL ),
mCurrPosition( 0, 0, 0 ),
mCurrVelocity( 0, 0, 1 ),
mSourceObjectId( -1 ),
mSourceObjectSlot( -1 ),
mCurrTick( 0 ),
mParticleEmitter( NULL ),
mParticleWaterEmitter( NULL ),
mSound( NULL ),
mProjectileShape( NULL ),
mActivateThread( NULL ),
mMaintainThread( NULL ),

View file

@ -187,8 +187,6 @@ IMPLEMENT_CALLBACK( RigidShape, onLeaveLiquid, void, ( const char* objId, const
namespace {
const U32 sMoveRetryCount = 3;
// Client prediction
const S32 sMaxWarpTicks = 3; // Max warp duration in ticks
const S32 sMaxPredictionTicks = 30; // Number of ticks to predict

View file

@ -95,9 +95,9 @@ SFXEmitter::SFXEmitter()
: SceneObject(),
mSource( NULL ),
mTrack( NULL ),
mUseTrackDescriptionOnly( false ),
mLocalProfile( &mDescription ),
mPlayOnAdd( true ),
mUseTrackDescriptionOnly( false )
mPlayOnAdd( true )
{
mTypeMask |= MarkerObjectType;
mNetFlags.set( Ghostable | ScopeAlways );

View file

@ -168,12 +168,9 @@ ShapeBaseData::ShapeBaseData()
density( 1.0f ),
maxEnergy( 0.0f ),
maxDamage( 1.0f ),
destroyedLevel( 1.0f ),
disabledLevel( 1.0f ),
repairRate( 0.0033f ),
eyeNode( -1 ),
earNode( -1 ),
cameraNode( -1 ),
disabledLevel( 1.0f ),
destroyedLevel( 1.0f ),
cameraMaxDist( 0.0f ),
cameraMinDist( 0.2f ),
cameraDefaultFov( 75.0f ),
@ -181,6 +178,11 @@ ShapeBaseData::ShapeBaseData()
cameraMaxFov( 120.f ),
cameraCanBank( false ),
mountedImagesBank( false ),
mCRC( 0 ),
computeCRC( false ),
eyeNode( -1 ),
earNode( -1 ),
cameraNode( -1 ),
debrisDetail( -1 ),
damageSequence( -1 ),
hulkSequence( -1 ),
@ -189,9 +191,7 @@ ShapeBaseData::ShapeBaseData()
useEyePoint( false ),
isInvincible( false ),
renderWhenDestroyed( true ),
computeCRC( false ),
inheritEnergyFromMount( false ),
mCRC( 0 )
inheritEnergyFromMount( false )
{
dMemset( mountPointNode, -1, sizeof( S32 ) * SceneObject::NumMountPoints );
}

View file

@ -491,8 +491,8 @@ struct ShapeBaseImageData: public GameBaseData {
/// @name Callbacks
/// @{
DECLARE_CALLBACK( void, onMount, ( ShapeBase* obj, S32 slot, F32 dt ) );
DECLARE_CALLBACK( void, onUnmount, ( ShapeBase* obj, S32 slot, F32 dt ) );
DECLARE_CALLBACK( void, onMount, ( SceneObject* obj, S32 slot, F32 dt ) );
DECLARE_CALLBACK( void, onUnmount, ( SceneObject* obj, S32 slot, F32 dt ) );
/// @}
};

View file

@ -97,14 +97,14 @@ ConsoleDocClass( ShapeBaseImageData,
"@ingroup gameObjects\n"
);
IMPLEMENT_CALLBACK( ShapeBaseImageData, onMount, void, ( ShapeBase* obj, S32 slot, F32 dt ), ( obj, slot, dt ),
IMPLEMENT_CALLBACK( ShapeBaseImageData, onMount, void, ( SceneObject* obj, S32 slot, F32 dt ), ( obj, slot, dt ),
"@brief Called when the Image is first mounted to the object.\n\n"
"@param obj object that this Image has been mounted to\n"
"@param slot Image mount slot on the object\n"
"@param dt time remaining in this Image update\n" );
IMPLEMENT_CALLBACK( ShapeBaseImageData, onUnmount, void, ( ShapeBase* obj, S32 slot, F32 dt ), ( obj, slot, dt ),
IMPLEMENT_CALLBACK( ShapeBaseImageData, onUnmount, void, ( SceneObject* obj, S32 slot, F32 dt ), ( obj, slot, dt ),
"@brief Called when the Image is unmounted from the object.\n\n"
"@param obj object that this Image has been unmounted from\n"

View file

@ -56,7 +56,7 @@ class StaticShape: public ShapeBase
StaticShapeData* mDataBlock;
bool mPowered;
void onUnmount(ShapeBase* obj,S32 node);
void onUnmount(SceneObject* obj,S32 node);
protected:
enum MaskBits {

View file

@ -228,6 +228,7 @@ public:
Resource<TSShape> getShape() const { return mShape; }
StringTableEntry getShapeFileName() { return mShapeName; }
void setShapeFileName(StringTableEntry shapeName) { mShapeName = shapeName; }
TSShapeInstance* getShapeInstance() const { return mShapeInstance; }

View file

@ -36,15 +36,6 @@
//----------------------------------------------------------------------------
// Client prediction
static F32 sMinWarpTicks = 0.5 ; // Fraction of tick at which instant warp occures
static S32 sMaxWarpTicks = 3; // Max warp duration in ticks
const U32 sClientCollisionMask = (TerrainObjectType |
StaticShapeObjectType |
VehicleObjectType);
const U32 sServerCollisionMask = (sClientCollisionMask);
// Trigger objects that are not normally collided with.
static U32 sTriggerMask = ItemObjectType |
TriggerObjectType |
@ -69,7 +60,7 @@ ConsoleDocClass( TurretShapeData,
"@ingroup gameObjects\n"
);
IMPLEMENT_CALLBACK( TurretShapeData, onMountObject, void, ( TurretShape* turret, SceneObject* obj, S32 node ),( turret, obj, node ),
IMPLEMENT_CALLBACK( TurretShapeData, onMountObject, void, ( SceneObject* turret, SceneObject* obj, S32 node ),( turret, obj, node ),
"@brief Informs the TurretShapeData object that a player is mounting it.\n\n"
"@param turret The TurretShape object.\n"
"@param obj The player that is mounting.\n"
@ -77,7 +68,7 @@ IMPLEMENT_CALLBACK( TurretShapeData, onMountObject, void, ( TurretShape* turret,
"@note Server side only.\n"
);
IMPLEMENT_CALLBACK( TurretShapeData, onUnmountObject, void, ( TurretShape* turret, SceneObject* obj ),( turret, obj ),
IMPLEMENT_CALLBACK( TurretShapeData, onUnmountObject, void, ( SceneObject* turret, SceneObject* obj ),( turret, obj ),
"@brief Informs the TurretShapeData object that a player is unmounting it.\n\n"
"@param turret The TurretShape object.\n"
"@param obj The player that is unmounting.\n"
@ -933,7 +924,7 @@ void TurretShape::unmountObject( SceneObject *obj )
}
}
void TurretShape::onUnmount(ShapeBase*,S32)
void TurretShape::onUnmount(SceneObject*,S32)
{
// Make sure the client get's the final server pos of this turret.
setMaskBits(PositionMask);

View file

@ -93,8 +93,8 @@ public:
virtual bool preload(bool server, String &errorStr);
DECLARE_CALLBACK( void, onMountObject, ( TurretShape* turret, SceneObject* obj, S32 node ) );
DECLARE_CALLBACK( void, onUnmountObject, ( TurretShape* turret, SceneObject* obj ) );
DECLARE_CALLBACK( void, onMountObject, ( SceneObject* turret, SceneObject* obj, S32 node ) );
DECLARE_CALLBACK( void, onUnmountObject, ( SceneObject* turret, SceneObject* obj ) );
DECLARE_CALLBACK( void, onStickyCollision, ( TurretShape* obj ) );
};
@ -150,7 +150,7 @@ protected:
void _applyLimits(Point3F& rot);
bool _outsideLimits(Point3F& rot); ///< Return true if any angle is outside of the limits
void onUnmount(ShapeBase* obj,S32 node);
void onUnmount(SceneObject* obj,S32 node);
// Script level control
bool allowManualRotation;

View file

@ -69,8 +69,6 @@ ConsoleDocClass( HoverVehicle,
);
namespace {
const U32 sIntergrationsPerTick = 1;
const F32 sHoverVehicleGravity = -20;
const U32 sCollisionMoveMask = (TerrainObjectType | PlayerObjectType |

View file

@ -63,8 +63,6 @@ static F32 sWorkingQueryBoxSizeMultiplier = 2.0f; // How much larger should the
// will be updated due to motion, but any non-static shape
// that moves into the query box will not be noticed.
const U32 sMoveRetryCount = 3;
// Client prediction
const S32 sMaxWarpTicks = 3; // Max warp duration in ticks
const S32 sMaxPredictionTicks = 30; // Number of ticks to predict

View file

@ -162,6 +162,13 @@ DefineConsoleFunction( setNetPort, bool, (int port, bool bind), (true), "(int po
return Net::openPort((S32)port, bind);
}
DefineConsoleFunction(isAddressTypeAvailable, bool, (int addressType), , "(protocol id)"
"@brief Determines if a specified address type can be reached.\n\n"
"@ingroup Networking")
{
return Net::isAddressTypeAvailable((NetAddress::Type)addressType);
}
DefineConsoleFunction( closeNetPort, void, (), , "()"
"@brief Closes the current network port\n\n"
"@ingroup Networking")

View file

@ -320,7 +320,7 @@ void StandardMainLoop::init()
Sampler::init();
// Hook in for UDP notification
Net::smPacketReceive.notify(GNet, &NetInterface::processPacketReceiveEvent);
Net::getPacketReceiveEvent().notify(GNet, &NetInterface::processPacketReceiveEvent);
#ifdef TORQUE_DEBUG_GUARD
Memory::flagCurrentAllocs( Memory::FLAG_Static );
@ -604,15 +604,11 @@ bool StandardMainLoop::doMainLoop()
lastFocus = newFocus;
}
#ifndef TORQUE_OS_MAC
// under the web plugin do not sleep the process when the child window loses focus as this will cripple the browser perfomance
if (!Platform::getWebDeployment())
tm->setBackground(!newFocus);
else
tm->setBackground(false);
#else
tm->setBackground(false);
#endif
}
else
{

View file

@ -177,7 +177,7 @@ static Vector<Ping> gQueryList(__FILE__, __LINE__);
struct PacketStatus
{
U8 index;
U16 index;
S32 key;
U32 time;
U32 tryCount;
@ -191,6 +191,9 @@ struct PacketStatus
time = _time;
tryCount = gPacketRetryCount;
}
inline U8 getOldIndex() { return (U8)index; }
inline U16 getIndex() { return index; }
};
static Vector<PacketStatus> gPacketStatusList(__FILE__, __LINE__);
@ -212,6 +215,7 @@ struct ServerFilter
OnlineQuery = 0, // Authenticated with master
OfflineQuery = BIT(0), // On our own
NoStringCompress = BIT(1),
NewStyleResponse = BIT(2), // Include IPV6 servers
};
enum // Filter flags:
@ -222,6 +226,14 @@ struct ServerFilter
CurrentVersion = BIT(7),
NotXenon = BIT(6)
};
enum // Region mask flags
{
RegionIsIPV4Address = BIT(30),
RegionIsIPV6Address = BIT(31),
RegionAddressMask = RegionIsIPV4Address | RegionIsIPV6Address
};
//Rearranging the fields according to their sizes
char* gameType;
@ -241,7 +253,7 @@ struct ServerFilter
ServerFilter()
{
type = Normal;
queryFlags = 0;
queryFlags = NewStyleResponse;
gameType = NULL;
missionType = NULL;
minPlayers = 0;
@ -401,10 +413,17 @@ void queryLanServers(U32 port, U8 flags, const char* gameType, const char* missi
NetAddress addr;
char addrText[256];
// IPV4
dSprintf( addrText, sizeof( addrText ), "IP:BROADCAST:%d", port );
Net::stringToAddress( addrText, &addr );
pushPingBroadcast( &addr );
// IPV6
dSprintf(addrText, sizeof(addrText), "IP6:MULTICAST:%d", port);
Net::stringToAddress(addrText, &addr);
pushPingBroadcast(&addr);
Con::executef("onServerQueryStatus", "start", "Querying LAN servers", "0");
processPingsAndQueries( gPingSession );
}
@ -502,7 +521,7 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
dStrcpy( sActiveFilter.missionType, missionType );
}
sActiveFilter.queryFlags = flags;
sActiveFilter.queryFlags = flags | ServerFilter::NewStyleResponse;
sActiveFilter.minPlayers = minPlayers;
sActiveFilter.maxPlayers = maxPlayers;
sActiveFilter.maxBots = maxBots;
@ -519,6 +538,7 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
sActiveFilter.type = ServerFilter::Buddy;
sActiveFilter.buddyCount = buddyCount;
sActiveFilter.buddyList = (U32*) dRealloc( sActiveFilter.buddyList, buddyCount * 4 );
sActiveFilter.queryFlags = ServerFilter::NewStyleResponse;
dMemcpy( sActiveFilter.buddyList, buddyList, buddyCount * 4 );
clearServerList();
}
@ -775,7 +795,7 @@ Vector<MasterInfo>* getMasterServerList()
U32 region = 1; // needs to default to something > 0
dSscanf(master,"%d:",&region);
const char* madd = dStrchr(master,':') + 1;
if (region && Net::stringToAddress(madd,&address)) {
if (region && Net::stringToAddress(madd,&address) == Net::NoError) {
masterList.increment();
MasterInfo& info = masterList.last();
info.address = address;
@ -1171,10 +1191,13 @@ static void processMasterServerQuery( U32 session )
// Send a request to the master server for the server list:
BitStream *out = BitStream::getPacketStream();
out->clearStringBuffer();
out->write( U8( NetInterface::MasterServerListRequest ) );
out->write( U8( sActiveFilter.queryFlags) );
out->write( ( gMasterServerPing.session << 16 ) | ( gMasterServerPing.key & 0xFFFF ) );
out->write( U8( 255 ) );
writeCString( out, sActiveFilter.gameType );
writeCString( out, sActiveFilter.missionType );
out->write( sActiveFilter.minPlayers );
@ -1359,23 +1382,35 @@ static void processServerListPackets( U32 session )
if ( !p.tryCount )
{
// Packet timed out :(
Con::printf( "Server list packet #%d timed out.", p.index + 1 );
Con::printf( "Server list packet #%d timed out.", p.getIndex() + 1 );
gPacketStatusList.erase( i );
}
else
{
// Try again...
Con::printf( "Rerequesting server list packet #%d...", p.index + 1 );
Con::printf( "Rerequesting server list packet #%d...", p.getIndex() + 1 );
p.tryCount--;
p.time = currentTime;
p.key = gKey++;
BitStream *out = BitStream::getPacketStream();
bool extendedPacket = (sActiveFilter.queryFlags & ServerFilter::NewStyleResponse) != 0;
out->clearStringBuffer();
out->write( U8( NetInterface::MasterServerListRequest ) );
if ( extendedPacket )
out->write( U8( NetInterface::MasterServerExtendedListRequest ) );
else
out->write( U8( NetInterface::MasterServerListRequest ) );
out->write( U8( sActiveFilter.queryFlags ) ); // flags
out->write( ( session << 16) | ( p.key & 0xFFFF ) );
out->write( p.index ); // packet index
if ( extendedPacket )
out->write( p.getOldIndex() ); // packet index
else
out->write( p.getIndex() ); // packet index
out->write( U8( 0 ) ); // game type
out->write( U8( 0 ) ); // mission type
out->write( U8( 0 ) ); // minPlayers
@ -1569,6 +1604,98 @@ static void handleMasterServerListResponse( BitStream* stream, U32 key, U8 /*fla
//-----------------------------------------------------------------------------
static void handleExtendedMasterServerListResponse(BitStream* stream, U32 key, U8 /*flags*/)
{
U16 packetIndex, packetTotal;
U32 i;
U16 serverCount, port;
U8 netNum[16];
char addressBuffer[256];
NetAddress addr;
stream->read(&packetIndex);
// Validate the packet key:
U32 packetKey = gMasterServerPing.key;
if (gGotFirstListPacket)
{
for (i = 0; i < gPacketStatusList.size(); i++)
{
if (gPacketStatusList[i].index == packetIndex)
{
packetKey = gPacketStatusList[i].key;
break;
}
}
}
U32 testKey = (gPingSession << 16) | (packetKey & 0xFFFF);
if (testKey != key)
return;
stream->read(&packetTotal);
stream->read(&serverCount);
Con::printf("Received server list packet %d of %d from the master server (%d servers).", (packetIndex + 1), packetTotal, serverCount);
// Enter all of the servers in this packet into the ping list:
for (i = 0; i < serverCount; i++)
{
U8 type;
stream->read(&type);
dMemset(&addr, '\0', sizeof(NetAddress));
if (type == 0)
{
// IPV4
addr.type = NetAddress::IPAddress;
stream->read(4, &addr.address.ipv4.netNum[0]);
stream->read(&addr.port);
}
else
{
// IPV6
addr.type = NetAddress::IPV6Address;
stream->read(16, &addr.address.ipv6.netNum[0]);
stream->read(&addr.port);
}
pushPingRequest(&addr);
}
// If this is the first list packet we have received, fill the packet status list
// and start processing:
if (!gGotFirstListPacket)
{
gGotFirstListPacket = true;
gMasterServerQueryAddress = gMasterServerPing.address;
U32 currentTime = Platform::getVirtualMilliseconds();
for (i = 0; i < packetTotal; i++)
{
if (i != packetIndex)
{
PacketStatus* p = new PacketStatus(i, gMasterServerPing.key, currentTime);
gPacketStatusList.push_back(*p);
}
}
processServerListPackets(gPingSession);
}
else
{
// Remove the packet we just received from the status list:
for (i = 0; i < gPacketStatusList.size(); i++)
{
if (gPacketStatusList[i].index == packetIndex)
{
gPacketStatusList.erase(i);
break;
}
}
}
}
//-----------------------------------------------------------------------------
static void handleGameMasterInfoRequest( const NetAddress* address, U32 key, U8 flags )
{
if ( GNet->doesAllowConnections() )
@ -1585,7 +1712,7 @@ static void handleGameMasterInfoRequest( const NetAddress* address, U32 key, U8
for(U32 i = 0; i < masterList->size(); i++)
{
masterAddr = &(*masterList)[i].address;
if (*(U32*)(masterAddr->netNum) == *(U32*)(address->netNum))
if (masterAddr->isSameAddress(*address))
{
fromMaster = true;
break;
@ -2098,6 +2225,10 @@ void DemoNetInterface::handleInfoPacket( const NetAddress* address, U8 packetTyp
case GameMasterInfoRequest:
handleGameMasterInfoRequest( address, key, flags );
break;
case MasterServerExtendedListResponse:
handleExtendedMasterServerListResponse(stream, key, flags);
break;
}
}

View file

@ -170,8 +170,8 @@ IMPLEMENT_CALLBACK(TCPObject, onDisconnect, void, (),(),
TCPObject *TCPObject::find(NetSocket tag)
{
for(TCPObject *walk = table[U32(tag) & TableMask]; walk; walk = walk->mNext)
if(walk->mTag == tag)
for(TCPObject *walk = table[tag.getHash() & TableMask]; walk; walk = walk->mNext)
if(walk->mTag.getHash() == tag.getHash())
return walk;
return NULL;
}
@ -180,13 +180,13 @@ void TCPObject::addToTable(NetSocket newTag)
{
removeFromTable();
mTag = newTag;
mNext = table[U32(mTag) & TableMask];
table[U32(mTag) & TableMask] = this;
mNext = table[mTag.getHash() & TableMask];
table[mTag.getHash() & TableMask] = this;
}
void TCPObject::removeFromTable()
{
for(TCPObject **walk = &table[U32(mTag) & TableMask]; *walk; walk = &((*walk)->mNext))
for(TCPObject **walk = &table[mTag.getHash() & TableMask]; *walk; walk = &((*walk)->mNext))
{
if(*walk == this)
{
@ -207,7 +207,7 @@ TCPObject::TCPObject()
mBuffer = NULL;
mBufferSize = 0;
mPort = 0;
mTag = InvalidSocket;
mTag = NetSocket::INVALID;
mNext = NULL;
mState = Disconnected;
@ -215,9 +215,9 @@ TCPObject::TCPObject()
if(gTCPCount == 1)
{
Net::smConnectionAccept.notify(processConnectedAcceptEvent);
Net::smConnectionReceive.notify(processConnectedReceiveEvent);
Net::smConnectionNotify.notify(processConnectedNotifyEvent);
Net::getConnectionAcceptedEvent().notify(processConnectedAcceptEvent);
Net::getConnectionReceiveEvent().notify(processConnectedReceiveEvent);
Net::getConnectionNotifyEvent().notify(processConnectedNotifyEvent);
}
}
@ -230,9 +230,9 @@ TCPObject::~TCPObject()
if(gTCPCount == 0)
{
Net::smConnectionAccept.remove(processConnectedAcceptEvent);
Net::smConnectionReceive.remove(processConnectedReceiveEvent);
Net::smConnectionNotify.remove(processConnectedNotifyEvent);
Net::getConnectionAcceptedEvent().remove(processConnectedAcceptEvent);
Net::getConnectionReceiveEvent().remove(processConnectedReceiveEvent);
Net::getConnectionNotifyEvent().remove(processConnectedNotifyEvent);
}
}
@ -242,7 +242,7 @@ bool TCPObject::processArguments(S32 argc, ConsoleValueRef *argv)
return true;
else if(argc == 1)
{
addToTable(U32(dAtoi(argv[0])));
addToTable(NetSocket::fromHandle(dAtoi(argv[0])));
return true;
}
return false;
@ -406,7 +406,7 @@ void TCPObject::onDisconnect()
void TCPObject::listen(U16 port)
{
mState = Listening;
U32 newTag = Net::openListenPort(port);
NetSocket newTag = Net::openListenPort(port);
addToTable(newTag);
}
@ -418,7 +418,7 @@ void TCPObject::connect(const char *address)
void TCPObject::disconnect()
{
if( mTag != InvalidSocket ) {
if( mTag != NetSocket::INVALID ) {
Net::closeConnectTo(mTag);
}
removeFromTable();
@ -592,7 +592,7 @@ void processConnectedAcceptEvent(NetSocket listeningPort, NetSocket newConnectio
if(!tcpo)
return;
tcpo->onConnectionRequest(&originatingAddress, newConnection);
tcpo->onConnectionRequest(&originatingAddress, (U32)newConnection.getHandle());
}
void processConnectedNotifyEvent( NetSocket sock, U32 state )

View file

@ -41,10 +41,10 @@
/// code version, the game name, and which type of game it is (TGB, TGE, TGEA, etc.).
///
/// Version number is major * 1000 + minor * 100 + revision * 10.
#define TORQUE_GAME_ENGINE 3630
#define TORQUE_GAME_ENGINE 3900
/// Human readable engine version string.
#define TORQUE_GAME_ENGINE_VERSION_STRING "3.6.3"
#define TORQUE_GAME_ENGINE_VERSION_STRING "3.9.0"
/// Gets the engine version number. The version number is specified as a global in version.cc
U32 getVersionNumber();

View file

@ -96,9 +96,9 @@ U32 ClippedPolyList::addPointAndNormal(const Point3F& p, const Point3F& normal)
AssertFatal(mNormalList.size() == mVertexList.size(), "Normals count does not match vertex count!");
// Build the plane mask
register U32 mask = 1;
register S32 count = mPlaneList.size();
register PlaneF * plane = mPlaneList.address();
U32 mask = 1;
S32 count = mPlaneList.size();
PlaneF * plane = mPlaneList.address();
v.mask = 0;
while(--count >= 0) {

View file

@ -531,7 +531,7 @@ void Convex::updateStateList(const MatrixF& mat, const Point3F& scale, const Poi
// Add collision states for new overlapping objects
for (CollisionWorkingList* itr0 = mWorking.wLink.mNext; itr0 != &mWorking; itr0 = itr0->wLink.mNext) {
register Convex* cv = itr0->mConvex;
Convex* cv = itr0->mConvex;
if (cv->mTag != sTag && box1.isOverlapped(cv->getBoundingBox())) {
CollisionState* state = new GjkCollisionState;
state->set(this,cv,mat,cv->getTransform());

View file

@ -87,9 +87,9 @@ class OptimizedPolyList : public AbstractPolyList
Poly()
: plane( -1 ),
object( NULL ),
vertexCount( 0 ),
material( NULL ),
vertexCount( 0 ),
object( NULL ),
type( TriangleFan )
{
}

View file

@ -39,7 +39,7 @@
#include "console/engineAPI.h"
#include <stdarg.h>
#include "platform/threads/mutex.h"
#include "core/util/journal/journal.h"
extern StringStack STR;
extern ConsoleValueStack CSTK;
@ -1138,6 +1138,321 @@ void addCommand( const char *name,BoolCallback cb,const char *usage, S32 minArgs
Namespace::global()->addCommand( StringTable->insert(name), cb, usage, minArgs, maxArgs, isToolOnly, header );
}
bool executeFile(const char* fileName, bool noCalls, bool journalScript)
{
bool journal = false;
char scriptFilenameBuffer[1024];
U32 execDepth = 0;
U32 journalDepth = 1;
execDepth++;
if (journalDepth >= execDepth)
journalDepth = execDepth + 1;
else
journal = true;
bool ret = false;
if (journalScript && !journal)
{
journal = true;
journalDepth = execDepth;
}
// Determine the filename we actually want...
Con::expandScriptFilename(scriptFilenameBuffer, sizeof(scriptFilenameBuffer), fileName);
// since this function expects a script file reference, if it's a .dso
// lets terminate the string before the dso so it will act like a .cs
if (dStrEndsWith(scriptFilenameBuffer, ".dso"))
{
scriptFilenameBuffer[dStrlen(scriptFilenameBuffer) - dStrlen(".dso")] = '\0';
}
// Figure out where to put DSOs
StringTableEntry dsoPath = Con::getDSOPath(scriptFilenameBuffer);
const char *ext = dStrrchr(scriptFilenameBuffer, '.');
if (!ext)
{
// We need an extension!
Con::errorf(ConsoleLogEntry::Script, "exec: invalid script file name %s.", scriptFilenameBuffer);
execDepth--;
return false;
}
// Check Editor Extensions
bool isEditorScript = false;
// If the script file extension is '.ed.cs' then compile it to a different compiled extension
if (dStricmp(ext, ".cs") == 0)
{
const char* ext2 = ext - 3;
if (dStricmp(ext2, ".ed.cs") == 0)
isEditorScript = true;
}
else if (dStricmp(ext, ".gui") == 0)
{
const char* ext2 = ext - 3;
if (dStricmp(ext2, ".ed.gui") == 0)
isEditorScript = true;
}
StringTableEntry scriptFileName = StringTable->insert(scriptFilenameBuffer);
#ifndef TORQUE_OS_XENON
// Is this a file we should compile? (anything in the prefs path should not be compiled)
StringTableEntry prefsPath = Platform::getPrefsPath();
bool compiled = dStricmp(ext, ".mis") && !journal && !Con::getBoolVariable("Scripts::ignoreDSOs");
// [tom, 12/5/2006] stripBasePath() fucks up if the filename is not in the exe
// path, current directory or prefs path. Thus, getDSOFilename() will also screw
// up and so this allows the scripts to still load but without a DSO.
if (Platform::isFullPath(Platform::stripBasePath(scriptFilenameBuffer)))
compiled = false;
// [tom, 11/17/2006] It seems to make sense to not compile scripts that are in the
// prefs directory. However, getDSOPath() can handle this situation and will put
// the dso along with the script to avoid name clashes with tools/game dsos.
if ((dsoPath && *dsoPath == 0) || (prefsPath && prefsPath[0] && dStrnicmp(scriptFileName, prefsPath, dStrlen(prefsPath)) == 0))
compiled = false;
#else
bool compiled = false; // Don't try to compile things on the 360, ignore DSO's when debugging
// because PC prefs will screw up stuff like SFX.
#endif
// If we're in a journaling mode, then we will read the script
// from the journal file.
if (journal && Journal::IsPlaying())
{
char fileNameBuf[256];
bool fileRead = false;
U32 fileSize;
Journal::ReadString(fileNameBuf);
Journal::Read(&fileRead);
if (!fileRead)
{
Con::errorf(ConsoleLogEntry::Script, "Journal script read (failed) for %s", fileNameBuf);
execDepth--;
return false;
}
Journal::Read(&fileSize);
char *script = new char[fileSize + 1];
Journal::Read(fileSize, script);
script[fileSize] = 0;
Con::printf("Executing (journal-read) %s.", scriptFileName);
CodeBlock *newCodeBlock = new CodeBlock();
newCodeBlock->compileExec(scriptFileName, script, noCalls, 0);
delete[] script;
execDepth--;
return true;
}
// Ok, we let's try to load and compile the script.
Torque::FS::FileNodeRef scriptFile = Torque::FS::GetFileNode(scriptFileName);
Torque::FS::FileNodeRef dsoFile;
// ResourceObject *rScr = gResourceManager->find(scriptFileName);
// ResourceObject *rCom = NULL;
char nameBuffer[512];
char* script = NULL;
U32 version;
Stream *compiledStream = NULL;
Torque::Time scriptModifiedTime, dsoModifiedTime;
// Check here for .edso
bool edso = false;
if (dStricmp(ext, ".edso") == 0 && scriptFile != NULL)
{
edso = true;
dsoFile = scriptFile;
scriptFile = NULL;
dsoModifiedTime = dsoFile->getModifiedTime();
dStrcpy(nameBuffer, scriptFileName);
}
// If we're supposed to be compiling this file, check to see if there's a DSO
if (compiled && !edso)
{
const char *filenameOnly = dStrrchr(scriptFileName, '/');
if (filenameOnly)
++filenameOnly;
else
filenameOnly = scriptFileName;
char pathAndFilename[1024];
Platform::makeFullPathName(filenameOnly, pathAndFilename, sizeof(pathAndFilename), dsoPath);
if (isEditorScript)
dStrcpyl(nameBuffer, sizeof(nameBuffer), pathAndFilename, ".edso", NULL);
else
dStrcpyl(nameBuffer, sizeof(nameBuffer), pathAndFilename, ".dso", NULL);
dsoFile = Torque::FS::GetFileNode(nameBuffer);
if (scriptFile != NULL)
scriptModifiedTime = scriptFile->getModifiedTime();
if (dsoFile != NULL)
dsoModifiedTime = dsoFile->getModifiedTime();
}
// Let's do a sanity check to complain about DSOs in the future.
//
// MM: This doesn't seem to be working correctly for now so let's just not issue
// the warning until someone knows how to resolve it.
//
//if(compiled && rCom && rScr && Platform::compareFileTimes(comModifyTime, scrModifyTime) < 0)
//{
//Con::warnf("exec: Warning! Found a DSO from the future! (%s)", nameBuffer);
//}
// If we had a DSO, let's check to see if we should be reading from it.
//MGT: fixed bug with dsos not getting recompiled correctly
//Note: Using Nathan Martin's version from the forums since its easier to read and understand
if (compiled && dsoFile != NULL && (scriptFile == NULL || (dsoModifiedTime >= scriptModifiedTime)))
{ //MGT: end
compiledStream = FileStream::createAndOpen(nameBuffer, Torque::FS::File::Read);
if (compiledStream)
{
// Check the version!
compiledStream->read(&version);
if (version != Con::DSOVersion)
{
Con::warnf("exec: Found an old DSO (%s, ver %d < %d), ignoring.", nameBuffer, version, Con::DSOVersion);
delete compiledStream;
compiledStream = NULL;
}
}
}
// If we're journalling, let's write some info out.
if (journal && Journal::IsRecording())
Journal::WriteString(scriptFileName);
if (scriptFile != NULL && !compiledStream)
{
// If we have source but no compiled version, then we need to compile
// (and journal as we do so, if that's required).
void *data;
U32 dataSize = 0;
Torque::FS::ReadFile(scriptFileName, data, dataSize, true);
if (journal && Journal::IsRecording())
Journal::Write(bool(data != NULL));
if (data == NULL)
{
Con::errorf(ConsoleLogEntry::Script, "exec: invalid script file %s.", scriptFileName);
execDepth--;
return false;
}
else
{
if (!dataSize)
{
execDepth--;
return false;
}
script = (char *)data;
if (journal && Journal::IsRecording())
{
Journal::Write(dataSize);
Journal::Write(dataSize, data);
}
}
#ifndef TORQUE_NO_DSO_GENERATION
if (compiled)
{
// compile this baddie.
#ifdef TORQUE_DEBUG
Con::printf("Compiling %s...", scriptFileName);
#endif
CodeBlock *code = new CodeBlock();
code->compile(nameBuffer, scriptFileName, script);
delete code;
code = NULL;
compiledStream = FileStream::createAndOpen(nameBuffer, Torque::FS::File::Read);
if (compiledStream)
{
compiledStream->read(&version);
}
else
{
// We have to exit out here, as otherwise we get double error reports.
delete[] script;
execDepth--;
return false;
}
}
#endif
}
else
{
if (journal && Journal::IsRecording())
Journal::Write(bool(false));
}
if (compiledStream)
{
// Delete the script object first to limit memory used
// during recursive execs.
delete[] script;
script = 0;
// We're all compiled, so let's run it.
#ifdef TORQUE_DEBUG
Con::printf("Loading compiled script %s.", scriptFileName);
#endif
CodeBlock *code = new CodeBlock;
code->read(scriptFileName, *compiledStream);
delete compiledStream;
code->exec(0, scriptFileName, NULL, 0, NULL, noCalls, NULL, 0);
ret = true;
}
else
if (scriptFile)
{
// No compiled script, let's just try executing it
// directly... this is either a mission file, or maybe
// we're on a readonly volume.
#ifdef TORQUE_DEBUG
Con::printf("Executing %s.", scriptFileName);
#endif
CodeBlock *newCodeBlock = new CodeBlock();
StringTableEntry name = StringTable->insert(scriptFileName);
newCodeBlock->compileExec(name, script, noCalls, 0);
ret = true;
}
else
{
// Don't have anything.
Con::warnf(ConsoleLogEntry::Script, "Missing file: %s!", scriptFileName);
ret = false;
}
delete[] script;
execDepth--;
return ret;
}
ConsoleValueRef evaluate(const char* string, bool echo, const char *fileName)
{
ConsoleStackFrameSaver stackSaver;
@ -2014,6 +2329,64 @@ void ensureTrailingSlash(char* pDstPath, const char* pSrcPath)
//-----------------------------------------------------------------------------
StringTableEntry getDSOPath(const char *scriptPath)
{
#ifndef TORQUE2D_TOOLS_FIXME
// [tom, 11/17/2006] Force old behavior for the player. May not want to do this.
const char *slash = dStrrchr(scriptPath, '/');
if (slash != NULL)
return StringTable->insertn(scriptPath, slash - scriptPath, true);
slash = dStrrchr(scriptPath, ':');
if (slash != NULL)
return StringTable->insertn(scriptPath, (slash - scriptPath) + 1, true);
return "";
#else
char relPath[1024], dsoPath[1024];
bool isPrefs = false;
// [tom, 11/17/2006] Prefs are handled slightly differently to avoid dso name clashes
StringTableEntry prefsPath = Platform::getPrefsPath();
if (dStrnicmp(scriptPath, prefsPath, dStrlen(prefsPath)) == 0)
{
relPath[0] = 0;
isPrefs = true;
}
else
{
StringTableEntry strippedPath = Platform::stripBasePath(scriptPath);
dStrcpy(relPath, strippedPath);
char *slash = dStrrchr(relPath, '/');
if (slash)
*slash = 0;
}
const char *overridePath;
if (!isPrefs)
overridePath = Con::getVariable("$Scripts::OverrideDSOPath");
else
overridePath = prefsPath;
if (overridePath && *overridePath)
Platform::makeFullPathName(relPath, dsoPath, sizeof(dsoPath), overridePath);
else
{
char t[1024];
dSprintf(t, sizeof(t), "compiledScripts/%s", relPath);
Platform::makeFullPathName(t, dsoPath, sizeof(dsoPath), Platform::getPrefsPath());
}
return StringTable->insert(dsoPath);
#endif
}
//-----------------------------------------------------------------------------
bool stripRepeatSlashes(char* pDstPath, const char* pSrcPath, S32 dstSize)
{
// Note original destination.

View file

@ -491,6 +491,7 @@ namespace Con
bool isBasePath(const char* SrcPath, const char* pBasePath);
void ensureTrailingSlash(char* pDstPath, const char* pSrcPath);
bool stripRepeatSlashes(char* pDstPath, const char* pSrcPath, S32 dstSize);
StringTableEntry getDSOPath(const char *scriptPath);
void addPathExpando(const char* pExpandoName, const char* pPath);
void removePathExpando(const char* pExpandoName);
@ -802,6 +803,16 @@ namespace Con
ConsoleValueRef execute(SimObject *object, S32 argc, const char* argv[], bool thisCallOnly = false);
ConsoleValueRef execute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool thisCallOnly = false);
/// Executes a script file and compiles it for use in script.
///
/// @param string File name that is the script to be executed and compiled.
/// @param fileName Path to the file to execute
/// @param noCalls Deprecated
/// @param journalScript Deprecated
///
/// @return True if the script was successfully executed, false if not.
bool executeFile(const char* fileName, bool noCalls, bool journalScript);
/// Evaluate an arbitrary chunk of code.
///
/// @param string Buffer containing code to execute.

View file

@ -2251,63 +2251,6 @@ ConsoleFunction( call, const char *, 2, 0, "( string functionName, string args..
static U32 execDepth = 0;
static U32 journalDepth = 1;
static StringTableEntry getDSOPath(const char *scriptPath)
{
#ifndef TORQUE2D_TOOLS_FIXME
// [tom, 11/17/2006] Force old behavior for the player. May not want to do this.
const char *slash = dStrrchr(scriptPath, '/');
if(slash != NULL)
return StringTable->insertn(scriptPath, slash - scriptPath, true);
slash = dStrrchr(scriptPath, ':');
if(slash != NULL)
return StringTable->insertn(scriptPath, (slash - scriptPath) + 1, true);
return "";
#else
char relPath[1024], dsoPath[1024];
bool isPrefs = false;
// [tom, 11/17/2006] Prefs are handled slightly differently to avoid dso name clashes
StringTableEntry prefsPath = Platform::getPrefsPath();
if(dStrnicmp(scriptPath, prefsPath, dStrlen(prefsPath)) == 0)
{
relPath[0] = 0;
isPrefs = true;
}
else
{
StringTableEntry strippedPath = Platform::stripBasePath(scriptPath);
dStrcpy(relPath, strippedPath);
char *slash = dStrrchr(relPath, '/');
if(slash)
*slash = 0;
}
const char *overridePath;
if(! isPrefs)
overridePath = Con::getVariable("$Scripts::OverrideDSOPath");
else
overridePath = prefsPath;
if(overridePath && *overridePath)
Platform::makeFullPathName(relPath, dsoPath, sizeof(dsoPath), overridePath);
else
{
char t[1024];
dSprintf(t, sizeof(t), "compiledScripts/%s", relPath);
Platform::makeFullPathName(t, dsoPath, sizeof(dsoPath), Platform::getPrefsPath());
}
return StringTable->insert(dsoPath);
#endif
}
DefineConsoleFunction( getDSOPath, const char*, ( const char* scriptFileName ),,
"Get the absolute path to the file in which the compiled code for the given script file will be stored.\n"
"@param scriptFileName %Path to the .cs script file.\n"
@ -2320,7 +2263,7 @@ DefineConsoleFunction( getDSOPath, const char*, ( const char* scriptFileName ),,
{
Con::expandScriptFilename( scriptFilenameBuffer, sizeof(scriptFilenameBuffer), scriptFileName );
const char* filename = getDSOPath(scriptFilenameBuffer);
const char* filename = Con::getDSOPath(scriptFilenameBuffer);
if(filename == NULL || *filename == 0)
return "";
@ -2347,7 +2290,7 @@ DefineEngineFunction( compile, bool, ( const char* fileName, bool overrideNoDSO
Con::expandScriptFilename( scriptFilenameBuffer, sizeof( scriptFilenameBuffer ), fileName );
// Figure out where to put DSOs
StringTableEntry dsoPath = getDSOPath(scriptFilenameBuffer);
StringTableEntry dsoPath = Con::getDSOPath(scriptFilenameBuffer);
if(dsoPath && *dsoPath == 0)
return false;
@ -2419,313 +2362,7 @@ DefineEngineFunction( exec, bool, ( const char* fileName, bool noCalls, bool jou
"@see eval\n"
"@ingroup Scripting" )
{
bool journal = false;
execDepth++;
if(journalDepth >= execDepth)
journalDepth = execDepth + 1;
else
journal = true;
bool ret = false;
if( journalScript && !journal )
{
journal = true;
journalDepth = execDepth;
}
// Determine the filename we actually want...
Con::expandScriptFilename( scriptFilenameBuffer, sizeof( scriptFilenameBuffer ), fileName );
// since this function expects a script file reference, if it's a .dso
// lets terminate the string before the dso so it will act like a .cs
if(dStrEndsWith(scriptFilenameBuffer, ".dso"))
{
scriptFilenameBuffer[dStrlen(scriptFilenameBuffer) - dStrlen(".dso")] = '\0';
}
// Figure out where to put DSOs
StringTableEntry dsoPath = getDSOPath(scriptFilenameBuffer);
const char *ext = dStrrchr(scriptFilenameBuffer, '.');
if(!ext)
{
// We need an extension!
Con::errorf(ConsoleLogEntry::Script, "exec: invalid script file name %s.", scriptFilenameBuffer);
execDepth--;
return false;
}
// Check Editor Extensions
bool isEditorScript = false;
// If the script file extension is '.ed.cs' then compile it to a different compiled extension
if( dStricmp( ext, ".cs" ) == 0 )
{
const char* ext2 = ext - 3;
if( dStricmp( ext2, ".ed.cs" ) == 0 )
isEditorScript = true;
}
else if( dStricmp( ext, ".gui" ) == 0 )
{
const char* ext2 = ext - 3;
if( dStricmp( ext2, ".ed.gui" ) == 0 )
isEditorScript = true;
}
StringTableEntry scriptFileName = StringTable->insert(scriptFilenameBuffer);
#ifndef TORQUE_OS_XENON
// Is this a file we should compile? (anything in the prefs path should not be compiled)
StringTableEntry prefsPath = Platform::getPrefsPath();
bool compiled = dStricmp(ext, ".mis") && !journal && !Con::getBoolVariable("Scripts::ignoreDSOs");
// [tom, 12/5/2006] stripBasePath() fucks up if the filename is not in the exe
// path, current directory or prefs path. Thus, getDSOFilename() will also screw
// up and so this allows the scripts to still load but without a DSO.
if(Platform::isFullPath(Platform::stripBasePath(scriptFilenameBuffer)))
compiled = false;
// [tom, 11/17/2006] It seems to make sense to not compile scripts that are in the
// prefs directory. However, getDSOPath() can handle this situation and will put
// the dso along with the script to avoid name clashes with tools/game dsos.
if( (dsoPath && *dsoPath == 0) || (prefsPath && prefsPath[ 0 ] && dStrnicmp(scriptFileName, prefsPath, dStrlen(prefsPath)) == 0) )
compiled = false;
#else
bool compiled = false; // Don't try to compile things on the 360, ignore DSO's when debugging
// because PC prefs will screw up stuff like SFX.
#endif
// If we're in a journaling mode, then we will read the script
// from the journal file.
if(journal && Journal::IsPlaying())
{
char fileNameBuf[256];
bool fileRead = false;
U32 fileSize;
Journal::ReadString(fileNameBuf);
Journal::Read(&fileRead);
if(!fileRead)
{
Con::errorf(ConsoleLogEntry::Script, "Journal script read (failed) for %s", fileNameBuf);
execDepth--;
return false;
}
Journal::Read(&fileSize);
char *script = new char[fileSize + 1];
Journal::Read(fileSize, script);
script[fileSize] = 0;
Con::printf("Executing (journal-read) %s.", scriptFileName);
CodeBlock *newCodeBlock = new CodeBlock();
newCodeBlock->compileExec(scriptFileName, script, noCalls, 0);
delete [] script;
execDepth--;
return true;
}
// Ok, we let's try to load and compile the script.
Torque::FS::FileNodeRef scriptFile = Torque::FS::GetFileNode(scriptFileName);
Torque::FS::FileNodeRef dsoFile;
// ResourceObject *rScr = gResourceManager->find(scriptFileName);
// ResourceObject *rCom = NULL;
char nameBuffer[512];
char* script = NULL;
U32 version;
Stream *compiledStream = NULL;
Torque::Time scriptModifiedTime, dsoModifiedTime;
// Check here for .edso
bool edso = false;
if( dStricmp( ext, ".edso" ) == 0 && scriptFile != NULL )
{
edso = true;
dsoFile = scriptFile;
scriptFile = NULL;
dsoModifiedTime = dsoFile->getModifiedTime();
dStrcpy( nameBuffer, scriptFileName );
}
// If we're supposed to be compiling this file, check to see if there's a DSO
if(compiled && !edso)
{
const char *filenameOnly = dStrrchr(scriptFileName, '/');
if(filenameOnly)
++filenameOnly;
else
filenameOnly = scriptFileName;
char pathAndFilename[1024];
Platform::makeFullPathName(filenameOnly, pathAndFilename, sizeof(pathAndFilename), dsoPath);
if( isEditorScript )
dStrcpyl(nameBuffer, sizeof(nameBuffer), pathAndFilename, ".edso", NULL);
else
dStrcpyl(nameBuffer, sizeof(nameBuffer), pathAndFilename, ".dso", NULL);
dsoFile = Torque::FS::GetFileNode(nameBuffer);
if(scriptFile != NULL)
scriptModifiedTime = scriptFile->getModifiedTime();
if(dsoFile != NULL)
dsoModifiedTime = dsoFile->getModifiedTime();
}
// Let's do a sanity check to complain about DSOs in the future.
//
// MM: This doesn't seem to be working correctly for now so let's just not issue
// the warning until someone knows how to resolve it.
//
//if(compiled && rCom && rScr && Platform::compareFileTimes(comModifyTime, scrModifyTime) < 0)
//{
//Con::warnf("exec: Warning! Found a DSO from the future! (%s)", nameBuffer);
//}
// If we had a DSO, let's check to see if we should be reading from it.
//MGT: fixed bug with dsos not getting recompiled correctly
//Note: Using Nathan Martin's version from the forums since its easier to read and understand
if(compiled && dsoFile != NULL && (scriptFile == NULL|| (dsoModifiedTime >= scriptModifiedTime)))
{ //MGT: end
compiledStream = FileStream::createAndOpen( nameBuffer, Torque::FS::File::Read );
if (compiledStream)
{
// Check the version!
compiledStream->read(&version);
if(version != Con::DSOVersion)
{
Con::warnf("exec: Found an old DSO (%s, ver %d < %d), ignoring.", nameBuffer, version, Con::DSOVersion);
delete compiledStream;
compiledStream = NULL;
}
}
}
// If we're journalling, let's write some info out.
if(journal && Journal::IsRecording())
Journal::WriteString(scriptFileName);
if(scriptFile != NULL && !compiledStream)
{
// If we have source but no compiled version, then we need to compile
// (and journal as we do so, if that's required).
void *data;
U32 dataSize = 0;
Torque::FS::ReadFile(scriptFileName, data, dataSize, true);
if(journal && Journal::IsRecording())
Journal::Write(bool(data != NULL));
if( data == NULL )
{
Con::errorf(ConsoleLogEntry::Script, "exec: invalid script file %s.", scriptFileName);
execDepth--;
return false;
}
else
{
if( !dataSize )
{
execDepth --;
return false;
}
script = (char *)data;
if(journal && Journal::IsRecording())
{
Journal::Write(dataSize);
Journal::Write(dataSize, data);
}
}
#ifndef TORQUE_NO_DSO_GENERATION
if(compiled)
{
// compile this baddie.
#ifdef TORQUE_DEBUG
Con::printf("Compiling %s...", scriptFileName);
#endif
CodeBlock *code = new CodeBlock();
code->compile(nameBuffer, scriptFileName, script);
delete code;
code = NULL;
compiledStream = FileStream::createAndOpen( nameBuffer, Torque::FS::File::Read );
if(compiledStream)
{
compiledStream->read(&version);
}
else
{
// We have to exit out here, as otherwise we get double error reports.
delete [] script;
execDepth--;
return false;
}
}
#endif
}
else
{
if(journal && Journal::IsRecording())
Journal::Write(bool(false));
}
if(compiledStream)
{
// Delete the script object first to limit memory used
// during recursive execs.
delete [] script;
script = 0;
// We're all compiled, so let's run it.
#ifdef TORQUE_DEBUG
Con::printf("Loading compiled script %s.", scriptFileName);
#endif
CodeBlock *code = new CodeBlock;
code->read(scriptFileName, *compiledStream);
delete compiledStream;
code->exec(0, scriptFileName, NULL, 0, NULL, noCalls, NULL, 0);
ret = true;
}
else
if(scriptFile)
{
// No compiled script, let's just try executing it
// directly... this is either a mission file, or maybe
// we're on a readonly volume.
#ifdef TORQUE_DEBUG
Con::printf("Executing %s.", scriptFileName);
#endif
CodeBlock *newCodeBlock = new CodeBlock();
StringTableEntry name = StringTable->insert(scriptFileName);
newCodeBlock->compileExec(name, script, noCalls, 0);
ret = true;
}
else
{
// Don't have anything.
Con::warnf(ConsoleLogEntry::Script, "Missing file: %s!", scriptFileName);
ret = false;
}
delete [] script;
execDepth--;
return ret;
return Con::executeFile(fileName, noCalls, journalScript);
}
DefineConsoleFunction( eval, const char*, ( const char* consoleString ), , "eval(consoleString)" )

View file

@ -1413,7 +1413,6 @@ ConsoleValueRef Namespace::Entry::execute(S32 argc, ConsoleValueRef *argv, ExprE
return ConsoleValueRef();
}
static char returnBuffer[32];
switch(mType)
{
case StringCallbackType:

View file

@ -441,7 +441,7 @@ public:
/// @see addGroup, endGroup
/// @see addGroup, endGroup
/// @see addDeprecatedField
enum ACRFieldTypes
enum ACRFieldTypes : U32
{
/// The first custom field type... all fields
/// types greater or equal to this one are not

View file

@ -62,4 +62,4 @@ namespace Con {
/// @}
#endif _CONSOLEXMLEXPORT_H_
#endif //_CONSOLEXMLEXPORT_H_

View file

@ -36,8 +36,8 @@ static VectorPtr< ConsoleBaseType* > gConsoleTypeTable( __FILE__, __LINE__ );
//-----------------------------------------------------------------------------
ConsoleBaseType::ConsoleBaseType( const S32 size, S32 *idPtr, const char *aTypeName )
: mInspectorFieldType( NULL ),
mTypeSize( size ),
: mTypeSize( size ),
mInspectorFieldType( NULL ),
mTypeInfo( NULL )
{
mTypeName = StringTable->insert( aTypeName );

View file

@ -43,13 +43,13 @@ EngineFunctionInfo::EngineFunctionInfo( const char* name,
void* address,
U32 flags )
: SuperType( name, EngineExportKindFunction, scope, docString ),
mBindingName( bindingName ),
mFunctionFlags( flags ),
mFunctionType( functionType ),
mDefaultArgumentValues( defaultArgs ),
mFunctionFlags( flags ),
mBindingName( bindingName ),
mPrototypeString( prototypeString ),
mNextFunction( smFirstFunction ),
mAddress( address )
mAddress( address ),
mNextFunction( smFirstFunction )
{
AssertFatal( functionType, "EngineFunctionInfo - Function cannot have void type!" );
smFirstFunction = this;

View file

@ -55,11 +55,11 @@ EngineTypeInfo::EngineTypeInfo( const char* typeName, EngineExportScope* scope,
: SuperType( typeName, scope, docString ),
mTypeKind( kind ),
mInstanceSize( instanceSize ),
mNext( smFirst ),
mEnumTable( NULL ),
mFieldTable( NULL ),
mPropertyTable( NULL ),
mSuperType( NULL )
mSuperType( NULL ),
mNext( smFirst )
{
mExportKind = EngineExportKindType;

View file

@ -61,7 +61,7 @@ typedef U32 SimObjectId;
/// The RootGroupId is assigned to gRootGroup, in which most SimObjects
/// are addded as child members. See simManager.cc for details, particularly
/// Sim::initRoot() and following.
enum SimObjectsConstants
enum SimObjectsConstants : U32
{
DataBlockObjectIdFirst = 3,
DataBlockObjectIdBitSize = 14,

View file

@ -84,7 +84,7 @@ TelnetConsole::TelnetConsole()
{
Con::addConsumer(telnetCallback);
mAcceptSocket = InvalidSocket;
mAcceptSocket = NetSocket::INVALID;
mAcceptPort = -1;
mClientList = NULL;
mRemoteEchoEnabled = false;
@ -93,13 +93,13 @@ TelnetConsole::TelnetConsole()
TelnetConsole::~TelnetConsole()
{
Con::removeConsumer(telnetCallback);
if(mAcceptSocket != InvalidSocket)
if(mAcceptSocket != NetSocket::INVALID)
Net::closeSocket(mAcceptSocket);
TelnetClient *walk = mClientList, *temp;
while(walk)
{
temp = walk->nextClient;
if(walk->socket != InvalidSocket)
if(walk->socket != NetSocket::INVALID)
Net::closeSocket(walk->socket);
delete walk;
walk = temp;
@ -113,16 +113,20 @@ void TelnetConsole::setTelnetParameters(S32 port, const char *telnetPassword, co
mRemoteEchoEnabled = remoteEcho;
if(mAcceptSocket != InvalidSocket)
if(mAcceptSocket != NetSocket::INVALID)
{
Net::closeSocket(mAcceptSocket);
mAcceptSocket = InvalidSocket;
mAcceptSocket = NetSocket::INVALID;
}
mAcceptPort = port;
if(mAcceptPort != -1 && mAcceptPort != 0)
{
NetAddress address;
Net::getIdealListenAddress(&address);
address.port = mAcceptPort;
mAcceptSocket = Net::openSocket();
Net::bind(mAcceptSocket, mAcceptPort);
Net::bindAddress(address, mAcceptSocket);
Net::listen(mAcceptSocket, 4);
Net::setBlocking(mAcceptSocket, false);
@ -151,16 +155,17 @@ void TelnetConsole::process()
{
NetAddress address;
if(mAcceptSocket != InvalidSocket)
if(mAcceptSocket != NetSocket::INVALID)
{
// ok, see if we have any new connections:
NetSocket newConnection;
newConnection = Net::accept(mAcceptSocket, &address);
if(newConnection != InvalidSocket)
if(newConnection != NetSocket::INVALID)
{
Con::printf ("Telnet connection from %i.%i.%i.%i",
address.netNum[0], address.netNum[1], address.netNum[2], address.netNum[3]);
char buffer[256];
Net::addressToString(&address, buffer);
Con::printf("Telnet connection from %s", buffer);
TelnetClient *cl = new TelnetClient;
cl->socket = newConnection;
@ -201,7 +206,7 @@ void TelnetConsole::process()
if((err != Net::NoError && err != Net::WouldBlock) || numBytes == 0)
{
Net::closeSocket(client->socket);
client->socket = InvalidSocket;
client->socket = NetSocket::INVALID;
continue;
}
@ -274,7 +279,7 @@ void TelnetConsole::process()
if(client->state == DisconnectThisDude)
{
Net::closeSocket(client->socket);
client->socket = InvalidSocket;
client->socket = NetSocket::INVALID;
}
}
}
@ -312,7 +317,7 @@ void TelnetConsole::process()
TelnetClient *cl;
while((cl = *walk) != NULL)
{
if(cl->socket == InvalidSocket)
if(cl->socket == NetSocket::INVALID)
{
*walk = cl->nextClient;
delete cl;

View file

@ -151,8 +151,8 @@ TelnetDebugger::TelnetDebugger()
Con::addConsumer(debuggerConsumer);
mAcceptPort = -1;
mAcceptSocket = InvalidSocket;
mDebugSocket = InvalidSocket;
mAcceptSocket = NetSocket::INVALID;
mDebugSocket = NetSocket::INVALID;
mState = NotConnected;
mCurPos = 0;
@ -189,9 +189,9 @@ TelnetDebugger::~TelnetDebugger()
{
Con::removeConsumer(debuggerConsumer);
if(mAcceptSocket != InvalidSocket)
if(mAcceptSocket != NetSocket::INVALID)
Net::closeSocket(mAcceptSocket);
if(mDebugSocket != InvalidSocket)
if(mDebugSocket != NetSocket::INVALID)
Net::closeSocket(mDebugSocket);
}
@ -217,10 +217,10 @@ void TelnetDebugger::send(const char *str)
void TelnetDebugger::disconnect()
{
if ( mDebugSocket != InvalidSocket )
if ( mDebugSocket != NetSocket::INVALID )
{
Net::closeSocket(mDebugSocket);
mDebugSocket = InvalidSocket;
mDebugSocket = NetSocket::INVALID;
}
removeAllBreakpoints();
@ -236,16 +236,20 @@ void TelnetDebugger::setDebugParameters(S32 port, const char *password, bool wai
// if(port == mAcceptPort)
// return;
if(mAcceptSocket != InvalidSocket)
if(mAcceptSocket != NetSocket::INVALID)
{
Net::closeSocket(mAcceptSocket);
mAcceptSocket = InvalidSocket;
mAcceptSocket = NetSocket::INVALID;
}
mAcceptPort = port;
if(mAcceptPort != -1 && mAcceptPort != 0)
{
NetAddress address;
Net::getIdealListenAddress(&address);
address.port = mAcceptPort;
mAcceptSocket = Net::openSocket();
Net::bind(mAcceptSocket, mAcceptPort);
Net::bindAddress(address, mAcceptSocket);
Net::listen(mAcceptSocket, 4);
Net::setBlocking(mAcceptSocket, false);
@ -279,32 +283,33 @@ void TelnetDebugger::process()
{
NetAddress address;
if(mAcceptSocket != InvalidSocket)
if(mAcceptSocket != NetSocket::INVALID)
{
// ok, see if we have any new connections:
NetSocket newConnection;
newConnection = Net::accept(mAcceptSocket, &address);
if(newConnection != InvalidSocket && mDebugSocket == InvalidSocket)
if(newConnection != NetSocket::INVALID && mDebugSocket == NetSocket::INVALID)
{
Con::printf ("Debugger connection from %i.%i.%i.%i",
address.netNum[0], address.netNum[1], address.netNum[2], address.netNum[3]);
char buffer[256];
Net::addressToString(&address, buffer);
Con::printf("Debugger connection from %s", buffer);
mState = PasswordTry;
mDebugSocket = newConnection;
Net::setBlocking(newConnection, false);
}
else if(newConnection != InvalidSocket)
else if(newConnection != NetSocket::INVALID)
Net::closeSocket(newConnection);
}
// see if we have any input to process...
if(mDebugSocket == InvalidSocket)
if(mDebugSocket == NetSocket::INVALID)
return;
checkDebugRecv();
if(mDebugSocket == InvalidSocket)
if(mDebugSocket == NetSocket::INVALID)
removeAllBreakpoints();
}
@ -434,7 +439,7 @@ void TelnetDebugger::breakProcess()
{
Platform::sleep(10);
checkDebugRecv();
if(mDebugSocket == InvalidSocket)
if(mDebugSocket == NetSocket::INVALID)
{
mProgramPaused = false;
removeAllBreakpoints();

View file

@ -101,8 +101,8 @@ bool OggDecoder::_nextPacket()
//-----------------------------------------------------------------------------
OggInputStream::OggInputStream( Stream* stream )
: mStream( stream ),
mIsAtEnd( false )
: mIsAtEnd( false ),
mStream( stream )
{
ogg_sync_init( &mOggSyncState );

View file

@ -95,12 +95,12 @@ static inline S32 sampleG( U8* pCb, U8* pCr )
OggTheoraDecoder::OggTheoraDecoder( const ThreadSafeRef< OggInputStream >& stream )
: Parent( stream ),
#ifdef TORQUE_DEBUG
mLock( 0 ),
#endif
mTheoraSetup( NULL ),
mTheoraDecoder( NULL ),
mTranscoder( TRANSCODER_Auto )
#ifdef TORQUE_DEBUG
,mLock( 0 )
#endif
{
// Initialize.

View file

@ -33,7 +33,7 @@
class FileStream : public Stream
{
public:
enum
enum : U32
{
BUFFER_SIZE = 8 * 1024, // this can be changed to anything appropriate [in k]
BUFFER_INVALID = 0xffffffff // file offsets must all be less than this

View file

@ -300,16 +300,7 @@ bool Stream::write(const NetAddress &na)
{
bool success = write(na.type);
success &= write(na.port);
success &= write(na.netNum[0]);
success &= write(na.netNum[1]);
success &= write(na.netNum[2]);
success &= write(na.netNum[3]);
success &= write(na.nodeNum[0]);
success &= write(na.nodeNum[1]);
success &= write(na.nodeNum[2]);
success &= write(na.nodeNum[3]);
success &= write(na.nodeNum[4]);
success &= write(na.nodeNum[5]);
success &= write(sizeof(na.address), &na.address);
return success;
}
@ -317,16 +308,20 @@ bool Stream::read(NetAddress *na)
{
bool success = read(&na->type);
success &= read(&na->port);
success &= read(&na->netNum[0]);
success &= read(&na->netNum[1]);
success &= read(&na->netNum[2]);
success &= read(&na->netNum[3]);
success &= read(&na->nodeNum[0]);
success &= read(&na->nodeNum[1]);
success &= read(&na->nodeNum[2]);
success &= read(&na->nodeNum[3]);
success &= read(&na->nodeNum[4]);
success &= read(&na->nodeNum[5]);
success &= read(sizeof(na->address), &na->address);
return success;
}
bool Stream::write(const NetSocket &so)
{
return write(so.getHandle());
}
bool Stream::read(NetSocket* so)
{
S32 handle = -1;
bool success = read(&handle);
*so = NetSocket::fromHandle(handle);
return success;
}

View file

@ -45,6 +45,7 @@ class ColorF;
struct NetAddress;
class RawData;
class String;
class NetSocket;
namespace Torque {
class ByteBuffer;
@ -165,6 +166,11 @@ public:
/// Read a network address from the stream.
bool read(NetAddress*);
/// Write a network socket to the stream.
bool write(const NetSocket &);
/// Read a network socket from the stream.
bool read(NetSocket*);
/// Write some raw data onto the stream.
bool write(const RawData &);
/// Read some raw data from the stream.

View file

@ -25,13 +25,7 @@
#include "core/stream/stream.h"
namespace {
const char TAG_ASCII_ID[] = "[TAG]";
const char TAG_ASCII_END[] = "[END]";
const char TAG_ASCII_HEADER[] = "// Auto-Generated by TagDictionary class";
const S32 sg_tagDictAsciiUser = 1;
} // namespace
TagDictionary tagDictionary;

View file

@ -104,9 +104,9 @@ acceptable. Do NOT use for cryptographic purposes.
--------------------------------------------------------------------
*/
U32 hash(register const U8 *k, register U32 length, register U32 initval)
U32 hash(const U8 *k, U32 length, U32 initval)
{
register U32 a,b,c,len;
U32 a,b,c,len;
/* Set up the internal state */
len = length;
@ -211,9 +211,9 @@ is acceptable. Do NOT use for cryptographic purposes.
--------------------------------------------------------------------
*/
U64 hash64( register const U8 *k, register U32 length, register U64 initval )
U64 hash64( const U8 *k, U32 length, U64 initval )
{
register U64 a,b,c,len;
U64 a,b,c,len;
/* Set up the internal state */
len = length;

View file

@ -177,7 +177,7 @@ void MD5Final( unsigned char digest[16], MD5Context* ctx)
*/
void MD5Transform( int buf[4], int in[16])
{
register int a, b, c, d;
int a, b, c, d;
a = buf[0];
b = buf[1];

View file

@ -41,7 +41,7 @@ protected:
StrTest() : mData( 0 ), mUTF16( 0 ), mLength( 0 ) {}
StrTest( const char* str )
: mData( str ), mLength( str ? dStrlen( str ) : 0 ), mUTF16( NULL )
: mData( str ), mUTF16( NULL ), mLength( str ? dStrlen( str ) : 0 )
{
if( str )
mUTF16 = createUTF16string( mData );

View file

@ -167,7 +167,7 @@ static void create_uuid_state(uuid_state *st)
*/
static void format_token(char *target, const xuuid_t *u)
{
sprintf(target, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
sprintf(target, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
u->time_low, u->time_mid, u->time_hi_and_version,
u->clock_seq_hi_and_reserved, u->clock_seq_low,
u->node[0], u->node[1], u->node[2],

View file

@ -272,11 +272,11 @@ SimObjectPtr<SimSet> DecalRoad::smServerDecalRoadSet = NULL;
// Constructors
DecalRoad::DecalRoad()
: mLoadRenderData( true ),
mBreakAngle( 3.0f ),
: mBreakAngle( 3.0f ),
mSegmentsPerBatch( 10 ),
mTextureLength( 5.0f ),
mRenderPriority( 10 ),
mLoadRenderData( true ),
mMaterial( NULL ),
mMatInst( NULL ),
mUpdateEventId( -1 ),
@ -1580,8 +1580,6 @@ void DecalRoad::_captureVerts()
box.intersect( batch.bounds );
}
Point3F pos = getPosition();
mWorldBox = box;
resetObjectBox();

View file

@ -59,29 +59,28 @@ GuiMeshRoadEditorCtrl::GuiMeshRoadEditorCtrl()
// tool palette
mSelectMeshRoadMode("MeshRoadEditorSelectMode"),
mAddMeshRoadMode("MeshRoadEditorAddRoadMode"),
mMovePointMode("MeshRoadEditorMoveMode"),
mRotatePointMode("MeshRoadEditorRotateMode"),
mScalePointMode("MeshRoadEditorScaleMode"),
mAddNodeMode("MeshRoadEditorAddNodeMode"),
mInsertPointMode("MeshRoadEditorInsertPointMode"),
mRemovePointMode("MeshRoadEditorRemovePointMode"),
mMode(mSelectMeshRoadMode),
mHasCopied( false ),
mIsDirty( false ),
mRoadSet( NULL ),
mSelNode( -1 ),
mSelRoad( NULL ),
mHoverRoad( NULL ),
mHoverNode( -1 ),
mDefaultWidth( 10.0f ),
mDefaultDepth( 5.0f ),
mDefaultNormal( 0,0,1 ),
mAddNodeIdx( 0 ),
mNodeHalfSize( 4,4 ),
mHoverSplineColor( 255,0,0,255 ),
mSelectedSplineColor( 0,255,0,255 ),
mHoverNodeColor( 255,255,255,255 )
mMovePointMode("MeshRoadEditorMoveMode"),
mScalePointMode("MeshRoadEditorScaleMode"),
mRotatePointMode("MeshRoadEditorRotateMode"),
mIsDirty( false ),
mRoadSet( NULL ),
mSelNode( -1 ),
mHoverNode( -1 ),
mAddNodeIdx( 0 ),
mSelRoad( NULL ),
mHoverRoad( NULL ),
mMode(mSelectMeshRoadMode),
mDefaultWidth( 10.0f ),
mDefaultDepth( 5.0f ),
mDefaultNormal( 0,0,1 ),
mNodeHalfSize( 4,4 ),
mHoverSplineColor( 255,0,0,255 ),
mSelectedSplineColor( 0,255,0,255 ),
mHoverNodeColor( 255,255,255,255 ),
mHasCopied( false )
{
mMaterialName[Top] = StringTable->insert("DefaultRoadMaterialTop");
mMaterialName[Bottom] = StringTable->insert("DefaultRoadMaterialOther");

View file

@ -52,9 +52,9 @@ ConsoleDocClass( GuiRiverEditorCtrl,
);
GuiRiverEditorCtrl::GuiRiverEditorCtrl()
: mDefaultNormal( 0, 0, 1 ),
mDefaultWidth( 10.0f ),
mDefaultDepth( 5.0f )
: mDefaultWidth( 10.0f ),
mDefaultDepth( 5.0f ),
mDefaultNormal( 0, 0, 1 )
{
// Each of the mode names directly correlates with the River Editor's
// tool palette

View file

@ -1713,8 +1713,6 @@ void MeshRoad::_generateSlices()
}
}
Point3F pos = getPosition();
mWorldBox = box;
resetObjectBox();

View file

@ -593,14 +593,14 @@ IMPLEMENT_CO_NETOBJECT_V1(River);
River::River()
: mMetersPerSegment(10.0f),
mSegmentsPerBatch(10),
: mSegmentsPerBatch(10),
mMetersPerSegment(10.0f),
mDepthScale(1.0f),
mFlowMagnitude(1.0f),
mLodDistance( 50.0f ),
mMaxDivisionSize(2.5f),
mMinDivisionSize(0.25f),
mColumnCount(5),
mFlowMagnitude(1.0f),
mLodDistance( 50.0f )
mColumnCount(5)
{
mNetFlags.set( Ghostable | ScopeAlways );
@ -1592,8 +1592,6 @@ void River::_generateSlices()
}
}
Point3F pos = getPosition();
mWorldBox = box;
//mObjBox.minExtents -= pos;
//mObjBox.maxExtents -= pos;

View file

@ -379,7 +379,7 @@ void ScatterSky::initPersistFields()
"Enables/disables shadows cast by objects due to ScatterSky light." );
addField("staticRefreshFreq", TypeS32, Offset(mStaticRefreshFreq, ScatterSky), "static shadow refresh rate (milliseconds)");
addField("dynamicRefreshFreq", TypeS32, Offset(mDynamicRefreshFreq, ScatterSky), "dynamic shadow refresh rate (milliseconds)");
addField("dynamicRefreshFreq", TypeS32, Offset(mDynamicRefreshFreq, ScatterSky), "dynamic shadow refresh rate (milliseconds)", AbstractClassRep::FieldFlags::FIELD_HideInInspectors);
addField( "brightness", TypeF32, Offset( mBrightness, ScatterSky ),
"The brightness of the ScatterSky's light object." );

View file

@ -168,7 +168,7 @@ void Sun::initPersistFields()
"Enables/disables shadows cast by objects due to Sun light");
addField("staticRefreshFreq", TypeS32, Offset(mStaticRefreshFreq, Sun), "static shadow refresh rate (milliseconds)");
addField("dynamicRefreshFreq", TypeS32, Offset(mDynamicRefreshFreq, Sun), "dynamic shadow refresh rate (milliseconds)");
addField("dynamicRefreshFreq", TypeS32, Offset(mDynamicRefreshFreq, Sun), "dynamic shadow refresh rate (milliseconds)", AbstractClassRep::FieldFlags::FIELD_HideInInspectors);
endGroup( "Lighting" );

View file

@ -189,7 +189,6 @@ void WaterBlock::setupVBIB()
//-----------------------------------------------------------------------------
void WaterBlock::setupVertexBlock( U32 width, U32 height, U32 rowOffset )
{
Point3F pos = getPosition();
RayInfo rInfo;
VectorF sunVector(-0.61f, 0.354f, 0.707f);
@ -592,9 +591,6 @@ void WaterBlock::setTransform( const MatrixF &mat )
// If our transform changes we need to recalculate the
// per vertex depth/shadow info. Would be nice if this could
// be done independently of generating the whole VBIB...
MatrixF oldMat = mObjToWorld;
Parent::setTransform( mat );
// We don't need to regen our vb anymore since we aren't calculating

View file

@ -179,23 +179,24 @@ ConsoleDocClass( WaterObject,
WaterObject::WaterObject()
: mViscosity( 1.0f ),
mDensity( 1.0f ),
mReflectivity( 0.5f ),
mReflectNormalUp( true ),
mLiquidType( "Water" ),
mFresnelBias( 0.3f ),
mFresnelPower( 6.0f ),
mReflectNormalUp( true ),
mReflectivity( 0.5f ),
mDistortStartDist( 0.1f ),
mDistortEndDist( 20.0f ),
mDistortFullDepth( 3.5f ),
mUndulateMaxDist(50.0f),
mOverallFoamOpacity( 1.0f ),
mFoamMaxDepth( 2.0f ),
mFoamAmbientLerp( 0.5f ),
mFoamRippleInfluence( 0.05f ),
mUnderwaterPostFx( NULL ),
mLiquidType( "Water" ),
mFresnelBias( 0.3f ),
mFresnelPower( 6.0f ),
mClarity( 0.5f ),
mBasicLighting( false ),
mUnderwaterColor(9, 6, 5, 240),
mUndulateMaxDist(50.0f),
mMiscParamW( 0.0f ),
mUnderwaterPostFx( NULL ),
mBasicLighting( false ),
mOverallWaveMagnitude( 1.0f ),
mOverallRippleMagnitude( 0.1f ),
mCubemap( NULL ),
@ -203,8 +204,7 @@ WaterObject::WaterObject()
mSpecularPower( 48.0f ),
mSpecularColor( 1.0f, 1.0f, 1.0f, 1.0f ),
mDepthGradientMax( 50.0f ),
mEmissive( false ),
mUnderwaterColor(9, 6, 5, 240)
mEmissive( false )
{
mTypeMask = WaterObjectType;

View file

@ -49,8 +49,8 @@ ForestBrushElement::ForestBrushElement()
mSinkMin( 0.0f ),
mSinkMax( 0.0f ),
mSinkRadius( 1 ),
mSlopeMax( 90.0f ),
mSlopeMin( 0.0f ),
mSlopeMax( 90.0f ),
mElevationMin( -10000.0f ),
mElevationMax( 10000.0f )
{

View file

@ -78,16 +78,16 @@ EndImplementEnumType;
ForestBrushTool::ForestBrushTool()
: mSize( 5.0f ),
: mRandom( Platform::getRealMilliseconds() + 1 ),
mSize( 5.0f ),
mPressure( 0.1f ),
mHardness( 1.0f ),
mDrawBrush( false ),
mCurrAction( NULL ),
mStrokeEvent( 0 ),
mBrushDown( false ),
mColor( ColorI::WHITE ),
mMode( Paint ),
mRandom( Platform::getRealMilliseconds() + 1 )
mColor( ColorI::WHITE ),
mBrushDown( false ),
mDrawBrush( false ),
mStrokeEvent( 0 ),
mCurrAction( NULL )
{
}

View file

@ -31,8 +31,8 @@ ForestUndoAction::ForestUndoAction( const Resource<ForestData> &data,
ForestEditorCtrl *editor,
const char *description )
: UndoAction( description ),
mData( data ),
mEditor( editor )
mEditor( editor ),
mData( data )
{
}

View file

@ -77,8 +77,6 @@ void ForestWindAccumulator::updateWind( const VectorF &windForce, F32 timeDelta
// an infinite mass.
mParticles[0].position = target;
Point2F relVel = target * timeDelta;
Point2F diff( 0, 0 );
Point2F springForce( 0, 0 );

View file

@ -176,7 +176,6 @@ bool GFXD3D9ShaderBufferLayout::setMatrix(const ParamDesc& pd, const GFXShaderCo
}
else if (pd.constType == GFXSCT_Float4x3)
{
F32 buffer[4*4];
const U32 csize = 48;
// Loop through and copy

View file

@ -88,7 +88,7 @@ class GFXOcclusionQueryHandle
public:
GFXOcclusionQueryHandle()
: mLastStatus(GFXOcclusionQuery::Unset), mLastData(0), mQuery(NULL), mWaiting(false)
: mLastStatus(GFXOcclusionQuery::Unset), mLastData(0), mWaiting(false) , mQuery(NULL)
{}
~GFXOcclusionQueryHandle()

View file

@ -64,11 +64,11 @@ public:
const GFXVertexFormat *vertexFormat,
U32 vertexSize,
GFXBufferType bufferType )
: mDevice( device ),
mVolatileStart( 0 ),
mNumVerts( numVerts ),
: mNumVerts( numVerts ),
mVertexSize( vertexSize ),
mBufferType( bufferType )
mBufferType( bufferType ),
mDevice( device ),
mVolatileStart( 0 )
{
if ( vertexFormat )
{

View file

@ -84,6 +84,10 @@ void loadGLExtensions(void *context)
void STDCALL glDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
const GLchar *message, const void *userParam)
{
// JTH [11/24/2016]: This is a temporary fix so that we do not get spammed for redundant fbo changes.
// This only happens on Intel cards. This should be looked into sometime in the near future.
if (dStrStartsWith(message, "API_ID_REDUNDANT_FBO"))
return;
if (severity == GL_DEBUG_SEVERITY_HIGH)
Con::errorf("OPENGL: %s", message);
else if (severity == GL_DEBUG_SEVERITY_MEDIUM)
@ -113,7 +117,8 @@ void GFXGLDevice::initGLState()
mCardProfiler = new GFXGLCardProfiler();
mCardProfiler->init();
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, (GLint*)&mMaxShaderTextures);
glGetIntegerv(GL_MAX_TEXTURE_UNITS, (GLint*)&mMaxFFTextures);
// JTH: Needs removed, ffp
//glGetIntegerv(GL_MAX_TEXTURE_UNITS, (GLint*)&mMaxFFTextures);
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, (GLint*)&mMaxTRColors);
mMaxTRColors = getMin( mMaxTRColors, (U32)(GFXTextureTarget::MaxRenderSlotId-1) );
@ -175,8 +180,10 @@ void GFXGLDevice::initGLState()
GFXGLDevice::GFXGLDevice(U32 adapterIndex) :
mAdapterIndex(adapterIndex),
mNeedUpdateVertexAttrib(false),
mCurrentPB(NULL),
mDrawInstancesCount(0),
mCurrentShader( NULL ),
m_mCurrentWorld(true),
m_mCurrentView(true),
mContext(NULL),
@ -186,8 +193,6 @@ GFXGLDevice::GFXGLDevice(U32 adapterIndex) :
mMaxFFTextures(2),
mMaxTRColors(1),
mClip(0, 0, 0, 0),
mCurrentShader( NULL ),
mNeedUpdateVertexAttrib(false),
mWindowRT(NULL),
mUseGlMap(true)
{
@ -617,7 +622,7 @@ void GFXGLDevice::setLightMaterialInternal(const GFXLightMaterial mat)
void GFXGLDevice::setGlobalAmbientInternal(ColorF color)
{
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, (GLfloat*)&color);
// ONLY NEEDED ON FFP
}
void GFXGLDevice::setTextureInternal(U32 textureUnit, const GFXTextureObject*texture)
@ -673,12 +678,12 @@ void GFXGLDevice::setClipRect( const RectI &inRect )
const F32 right = mClip.point.x + mClip.extent.x;
const F32 bottom = mClip.extent.y;
const F32 top = 0.0f;
const F32 near = 0.0f;
const F32 far = 1.0f;
const F32 nearPlane = 0.0f;
const F32 farPlane = 1.0f;
const F32 tx = -(right + left)/(right - left);
const F32 ty = -(top + bottom)/(top - bottom);
const F32 tz = -(far + near)/(far - near);
const F32 tz = -(farPlane + nearPlane)/(farPlane - nearPlane);
static Point4F pt;
pt.set(2.0f / (right - left), 0.0f, 0.0f, 0.0f);
@ -687,7 +692,7 @@ void GFXGLDevice::setClipRect( const RectI &inRect )
pt.set(0.0f, 2.0f/(top - bottom), 0.0f, 0.0f);
mProjectionMatrix.setColumn(1, pt);
pt.set(0.0f, 0.0f, -2.0f/(far - near), 0.0f);
pt.set(0.0f, 0.0f, -2.0f/(farPlane - nearPlane), 0.0f);
mProjectionMatrix.setColumn(2, pt);
pt.set(tx, ty, tz, 1.0f);

View file

@ -58,7 +58,7 @@ public:
glGenQueries(1, &mQueryId);
}
GLTimer() : mName(NULL), mQueryId(0), mData(NULL)
GLTimer() : mName(NULL), mData(NULL), mQueryId(0)
{
}

View file

@ -41,10 +41,11 @@ GFXGLVertexBuffer::GFXGLVertexBuffer( GFXDevice *device,
const GFXVertexFormat *vertexFormat,
U32 vertexSize,
GFXBufferType bufferType )
: GFXVertexBuffer( device, numVerts, vertexFormat, vertexSize, bufferType ),
mZombieCache(NULL),
: GFXVertexBuffer( device, numVerts, vertexFormat, vertexSize, bufferType ),
mBufferOffset(0),
mBufferVertexOffset(0)
mBufferVertexOffset(0),
mZombieCache(NULL)
{
if( mBufferType == GFXBufferTypeVolatile )
{

View file

@ -106,6 +106,10 @@ void GFXGLDevice::enumerateAdapters( Vector<GFXAdapter*> &adapterList )
AssertFatal(0, err );
}
// Init GL
loadGLCore();
loadGLExtensions(tempContext);
//check minimun Opengl 3.2
int major, minor;
glGetIntegerv(GL_MAJOR_VERSION, &major);
@ -114,8 +118,6 @@ void GFXGLDevice::enumerateAdapters( Vector<GFXAdapter*> &adapterList )
{
return;
}
loadGLCore();
GFXAdapter *toAdd = new GFXAdapter;
toAdd->mIndex = 0;
@ -163,7 +165,7 @@ void GFXGLDevice::init( const GFXVideoMode &mode, PlatformWindow *window )
PlatformGL::MakeCurrentGL( sdlWindow, mContext );
loadGLCore();
loadGLExtensions(0);
loadGLExtensions(mContext);
// It is very important that extensions be loaded before we call initGLState()
initGLState();

View file

@ -33,11 +33,10 @@ namespace GL
{
void gglPerformBinds()
{
// JTH: epoxy has one oddity with windows. You need to bind the context
// after creating the context to udpate the internals of epoxy.
#ifdef TORQUE_OS_WIN
epoxy_handle_external_wglMakeCurrent();
#endif
if (!gladLoadGL())
{
AssertFatal(false, "Unable to load GLAD. Make sure your OpenGL drivers are up to date!");
}
}
void gglPerformExtensionBinds(void *context)

View file

@ -23,11 +23,10 @@
#ifndef T_GL_H
#define T_GL_H
#include <epoxy/gl.h>
#include <glad/glad.h>
// JTH: This is slow, we should probably check extensions once and cache them
// directly inside of some compatability table.
#define gglHasExtension(EXTENSION) epoxy_has_gl_extension("GL_" #EXTENSION)
// JTH: When we use glad, extensions are chached into simple booleans (ints)
#define gglHasExtension(EXTENSION) GLAD_GL_##EXTENSION
#endif

View file

@ -28,9 +28,9 @@
#ifdef TORQUE_OPENGL
#include "tGL.h"
#include <epoxy/wgl.h>
#include <glad/glad_wgl.h>
#define gglHasWExtension(window, EXTENSION) epoxy_has_wgl_extension(window, "WGL_" # EXTENSION)
#define gglHasWExtension(window, EXTENSION) GLAD_WGL_##EXTENSION
#endif //TORQUE_OPENGL

View file

@ -28,9 +28,9 @@
#ifdef TORQUE_OS_LINUX
#include "tGL.h"
#include <epoxy/glx.h>
#include <glad/glad_glx.h>
#define gglHasXExtension(display, screen, EXTENSION) epoxy_has_glx_extension(display, screen, "GLX_" # EXTENSION)
#define gglHasXExtension(display, screen, EXTENSION) GLAD_GLX_##EXTENSION
#endif //TORQUE_OS_LINUX

Some files were not shown because too many files have changed in this diff Show more