Преглед на файлове

Merge pull request #1585 from Azaezel/alpha41/miscFixes11.13.25

misc fixes
Brian Roberts преди 2 месеца
родител
ревизия
8c0e7492f6

+ 6 - 2
Engine/source/T3D/debris.cpp

@@ -206,14 +206,18 @@ bool DebrisData::onAdd()
          if( Sim::findObject( emitterIDList[i], emitterList[i] ) == false)
          {
             Con::errorf( ConsoleLogEntry::General, "DebrisData::onAdd: Invalid packet, bad datablockId(emitter): 0x%x", emitterIDList[i]);
+            return false;
          }
       }
    }
 
    if (!explosion && explosionId != 0)
    {
-      if (!Sim::findObject( SimObjectId( explosionId ), explosion ))
-            Con::errorf( ConsoleLogEntry::General, "DebrisData::onAdd: Invalid packet, bad datablockId(particle emitter): 0x%x", explosionId);
+      if (!Sim::findObject(SimObjectId(explosionId), explosion))
+      {
+         Con::errorf(ConsoleLogEntry::General, "DebrisData::onAdd: Invalid packet, bad datablockId(particle emitter): 0x%x", explosionId);
+         return false;
+      }
    }
 
    // validate data

+ 20 - 3
Engine/source/T3D/fx/explosion.cpp

@@ -637,6 +637,7 @@ bool ExplosionData::onAdd()
          if( !Sim::findObject( debrisIDList[i], debrisList[i] ) )
          {
             Con::errorf( ConsoleLogEntry::General, "ExplosionData::onAdd: Invalid packet, bad datablockId(debris): 0x%x", debrisIDList[i] );
+            return false;
          }
       }
    }
@@ -648,6 +649,7 @@ bool ExplosionData::onAdd()
          if( Sim::findObject( emitterIDList[i], emitterList[i] ) == false)
          {
             Con::errorf( ConsoleLogEntry::General, "ExplosionData::onAdd: Invalid packet, bad datablockId(particle emitter): 0x%x", emitterIDList[i] );
+            return false;
          }
       }
    }
@@ -659,6 +661,7 @@ bool ExplosionData::onAdd()
          if( Sim::findObject( explosionIDList[k], explosionList[k] ) == false)
          {
             Con::errorf( ConsoleLogEntry::General, "ExplosionData::onAdd: Invalid packet, bad datablockId(explosion): 0x%x", explosionIDList[k] );
+            return false;
          }
       }
    }
@@ -880,20 +883,34 @@ bool ExplosionData::preload(bool server, String &errorStr)
    if (Parent::preload(server, errorStr) == false)
       return false;
 
-   if( !server )
+   if (!server)
    {
 
       if (!isSoundValid())
       {
          //return false; -TODO: trigger asset download
       }
-
       if (!particleEmitter && particleEmitterId != 0)
+      {
          if (Sim::findObject(particleEmitterId, particleEmitter) == false)
          {
-            Con::errorf(ConsoleLogEntry::General, "Error, unable to load particle emitter for explosion datablock");
+            errorStr = String::ToString("Error, unable to load particle emitter for explosion datablock");
             return false;
          }
+      }
+
+      U32 i;
+      for (i = 0; i < EC_NUM_EMITTERS; i++)
+      {
+         if (!emitterList[i] && emitterIDList[i] != 0)
+         {
+            if (Sim::findObject(emitterIDList[i], emitterList[i]) == false)
+            {
+               errorStr = String::ToString("Error, unable to load emitter[%i] for explosion datablock 0x%x", i, emitterIDList[i]);
+               return false;
+            }
+         }
+      }
    }
 
    if (getExplosionShape()) {

+ 5 - 1
Engine/source/T3D/fx/particleEmitter.cpp

@@ -704,7 +704,10 @@ bool ParticleEmitterData::preload(bool server, String &errorStr)
    {
       ParticleData* pData = NULL;
       if (Sim::findObject(dataBlockIds[i], pData) == false)
-         Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) unable to find particle datablock: %d", getName(), dataBlockIds[i]);
+      {
+         errorStr = String::ToString("ParticleEmitterData(%s) unable to find particle datablock: %d", getName(), dataBlockIds[i]);
+         return false;
+      }
       else
          particleDataBlocks.push_back(pData);
    }
@@ -749,6 +752,7 @@ bool ParticleEmitterData::preload(bool server, String &errorStr)
               if (particleDataBlocks[i]->getTextureAsset()->getImageFile() != txr_name)
               {
                  Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) particles reference different textures.", getName());
+                 return false;
                  break;
               }
            }

+ 16 - 2
Engine/source/T3D/fx/splash.cpp

@@ -149,6 +149,18 @@ bool SplashData::onAdd()
    if (Parent::onAdd() == false)
       return false;
 
+   S32 i;
+   for (i = 0; i < NUM_EMITTERS; i++)
+   {
+      if (!emitterList[i] && emitterIDList[i] != 0)
+      {
+         if (Sim::findObject(emitterIDList[i], emitterList[i]) == false)
+         {
+            Con::errorf(ConsoleLogEntry::General, "ExplosionData::onAdd: Invalid packet, bad datablockId(particle emitter): 0x%x", emitterIDList[i]);
+            return false;
+         }
+      }
+   }
    return true;
 }
 
@@ -281,7 +293,8 @@ bool SplashData::preload(bool server, String &errorStr)
          {
             if( Sim::findObject( emitterIDList[i], emitterList[i] ) == false)
             {
-               Con::errorf( ConsoleLogEntry::General, "SplashData::onAdd: Invalid packet, bad datablockId(particle emitter): 0x%x", emitterIDList[i] );
+               errorStr = String::ToString("SplashData::onAdd: Invalid packet, bad datablockId(particle emitter): 0x%x", emitterIDList[i]);
+               return false;
             }
          }
       }
@@ -299,7 +312,8 @@ bool SplashData::preload(bool server, String &errorStr)
    {
       if( !Sim::findObject(explosionId, explosion) )
       {
-         Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Invalid packet, bad datablockId(explosion): %d", explosionId);
+         errorStr = String::ToString("SplashData::preload: Invalid packet, bad datablockId(explosion): %d", explosionId);
+         return false;
       }
    }
 

+ 41 - 0
Engine/source/T3D/projectile.cpp

@@ -336,6 +336,47 @@ bool ProjectileData::onAdd()
    if(!Parent::onAdd())
       return false;
 
+   if (!particleEmitter && particleEmitterId != 0)
+   {
+      if (Sim::findObject(particleEmitterId, particleEmitter) == false)
+      {
+         Con::errorf(ConsoleLogEntry::General, "ProjectileData::onAdd: Invalid packet, bad datablockId(particleEmitter): 0x%x", particleEmitterId);
+         return false;
+      }
+   }
+   if (!explosion && explosionId != 0)
+   {
+      if (Sim::findObject(explosionId, explosion) == false)
+      {
+         Con::errorf(ConsoleLogEntry::General, "ProjectileData::onAdd: Invalid packet, bad datablockId(explosion): 0x%x", explosionId);
+         return false;
+      }
+   }
+   if (!waterExplosion && waterExplosionId != 0)
+   {
+      if (Sim::findObject(waterExplosionId, waterExplosion) == false)
+      {
+         Con::errorf(ConsoleLogEntry::General, "ProjectileData::onAdd: Invalid packet, bad datablockId(waterExplosion): 0x%x", waterExplosionId);
+         return false;
+      }
+   }
+   if (!splash && splashId != 0)
+   {
+      if (Sim::findObject(splashId, splash) == false)
+      {
+         Con::errorf(ConsoleLogEntry::General, "ProjectileData::onAdd: Invalid packet, bad datablockId(waterExplosion): 0x%x", splashId);
+         return false;
+      }
+   }
+   if (!decal && decalId != 0)
+   {
+      if (Sim::findObject(decalId, decal) == false)
+      {
+         Con::errorf(ConsoleLogEntry::General, "ProjectileData::onAdd: Invalid packet, bad datablockId(waterExplosion): 0x%x", decalId);
+         return false;
+      }
+   }
+      
    return true;
 }
 

+ 36 - 3
Engine/source/T3D/rigidShape.cpp

@@ -297,6 +297,36 @@ bool RigidShapeData::onAdd()
    if(!Parent::onAdd())
       return false;
 
+   for (S32 i = 0; i < VC_NUM_SPLASH_EMITTERS; i++)
+   {
+      if (!splashEmitterList[i] && splashEmitterIDList[i] != 0)
+      {
+         if (Sim::findObject(splashEmitterIDList[i], splashEmitterList[i]) == false)
+         {
+            Con::errorf(ConsoleLogEntry::General, "ExplosionData::onAdd: Invalid packet, bad datablockId(explosion): 0x%x", splashEmitterIDList[i]);
+            return false;
+         }
+      }
+   }
+
+   if (!dustTrailEmitter && dustTrailID != 0)
+   {
+      if (Sim::findObject(dustID, dustEmitter) == false)
+      {
+         Con::errorf(ConsoleLogEntry::General, "RigidShapeData::onAdd: Invalid packet, bad datablockId(dustEmitter): 0x%x", dustID);
+         return false;
+      }
+   }
+
+   if (!dustTrailEmitter && dustTrailID != 0)
+   {
+      if (Sim::findObject(dustTrailID, dustTrailEmitter) == false)
+      {
+         Con::errorf(ConsoleLogEntry::General, "RigidShapeData::onAdd: Invalid packet, bad datablockId(dustTrailEmitter): 0x%x", dustTrailID);
+         return false;
+      }
+   }
+
    return true;
 }
 
@@ -338,7 +368,8 @@ bool RigidShapeData::preload(bool server, String &errorStr)
    {
       if( !Sim::findObject( dustID, dustEmitter ) )
       {
-         Con::errorf( ConsoleLogEntry::General, "RigidShapeData::preload Invalid packet, bad datablockId(dustEmitter): 0x%x", dustID );
+         errorStr = String::ToString("RigidShapeData::preload Invalid packet, bad datablockId(dustEmitter): 0x%x", dustID);
+         return false;
       }
    }
 
@@ -349,7 +380,8 @@ bool RigidShapeData::preload(bool server, String &errorStr)
       {
          if( !Sim::findObject( splashEmitterIDList[i], splashEmitterList[i] ) )
          {
-            Con::errorf( ConsoleLogEntry::General, "RigidShapeData::preload Invalid packet, bad datablockId(splashEmitter): 0x%x", splashEmitterIDList[i] );
+            errorStr = String::ToString("RigidShapeData::preload Invalid packet, bad datablockId(splashEmitter): 0x%x", splashEmitterIDList[i] );
+            return false;
          }
       }
    }
@@ -370,7 +402,8 @@ bool RigidShapeData::preload(bool server, String &errorStr)
    {
       if( !Sim::findObject( dustTrailID, dustTrailEmitter ) )
       {
-         Con::errorf( ConsoleLogEntry::General, "RigidShapeData::preload Invalid packet, bad datablockId(dustTrailEmitter): 0x%x", dustTrailID );
+         errorStr = String::ToString("RigidShapeData::preload Invalid packet, bad datablockId(dustTrailEmitter): 0x%x", dustTrailID );
+         return false;
       }
    }
 

+ 9 - 2
Engine/source/T3D/shapeBase.cpp

@@ -320,7 +320,8 @@ bool ShapeBaseData::preload(bool server, String &errorStr)
       {
          if( Sim::findObject( explosionID, explosion ) == false)
          {
-            Con::errorf( ConsoleLogEntry::General, "ShapeBaseData::preload: Invalid packet, bad datablockId(explosion): 0x%x", explosionID );
+            errorStr = String::ToString("ShapeBaseData::preload: Invalid packet, bad datablockId(explosion): 0x%x", explosionID );
+            return false;
          }
          AssertFatal(!(explosion && ((explosionID < DataBlockObjectIdFirst) || (explosionID > DataBlockObjectIdLast))),
             "ShapeBaseData::preload: invalid explosion data");
@@ -330,7 +331,8 @@ bool ShapeBaseData::preload(bool server, String &errorStr)
       {
          if( Sim::findObject( underwaterExplosionID, underwaterExplosion ) == false)
          {
-            Con::errorf( ConsoleLogEntry::General, "ShapeBaseData::preload: Invalid packet, bad datablockId(underwaterExplosion): 0x%x", underwaterExplosionID );
+            errorStr = String::ToString("ShapeBaseData::preload: Invalid packet, bad datablockId(underwaterExplosion): 0x%x", underwaterExplosionID );
+            return false;
          }
          AssertFatal(!(underwaterExplosion && ((underwaterExplosionID < DataBlockObjectIdFirst) || (underwaterExplosionID > DataBlockObjectIdLast))),
             "ShapeBaseData::preload: invalid underwaterExplosion data");
@@ -339,6 +341,11 @@ bool ShapeBaseData::preload(bool server, String &errorStr)
       if( !debris && debrisID != 0 )
       {
          Sim::findObject( debrisID, debris );
+         if (Sim::findObject(debrisID, debris) == false)
+         {
+            errorStr = String::ToString("ShapeBaseData::preload: Invalid packet, bad datablockId(debris): 0x%x", debrisID);
+            return false;
+         }
          AssertFatal(!(debris && ((debrisID < DataBlockObjectIdFirst) || (debrisID > DataBlockObjectIdLast))),
             "ShapeBaseData::preload: invalid debris data");
       }

+ 2 - 1
Engine/source/T3D/shapeImage.cpp

@@ -553,7 +553,8 @@ bool ShapeBaseImageData::preload(bool server, String &errorStr)
    {
       if( !Sim::findObject( SimObjectId( casingID ), casing ) )
       {
-         Con::errorf( ConsoleLogEntry::General, "ShapeBaseImageData::preload: Invalid packet, bad datablockId(casing): 0x%x", casingID );
+         errorStr = String::ToString("ShapeBaseImageData::preload: Invalid packet, bad datablockId(casing): 0x%x", casingID );
+         return false;
       }
    }
 

+ 2 - 1
Engine/source/T3D/vehicles/hoverVehicle.cpp

@@ -327,7 +327,8 @@ bool HoverVehicleData::preload(bool server, String &errorStr)
    {
       if( !Sim::findObject( dustTrailID, dustTrailEmitter ) )
       {
-         Con::errorf( ConsoleLogEntry::General, "HoverVehicleData::preload Invalid packet, bad datablockId(dustTrailEmitter): 0x%x", dustTrailID );
+         errorStr = String::ToString("HoverVehicleData::preload Invalid packet, bad datablockId(dustTrailEmitter): 0x%x", dustTrailID );
+         return false;
       }
    }
    // Resolve jet nodes

+ 2 - 1
Engine/source/T3D/vehicles/vehicle.cpp

@@ -174,7 +174,8 @@ bool VehicleData::preload(bool server, String &errorStr)
       {
          if( !Sim::findObject( damageEmitterIDList[i], damageEmitterList[i] ) )
          {
-            Con::errorf( ConsoleLogEntry::General, "VehicleData::preload Invalid packet, bad datablockId(damageEmitter): 0x%x", damageEmitterIDList[i] );
+            errorStr = String::ToString("VehicleData::preload Invalid packet, bad datablockId(damageEmitter): 0x%x", damageEmitterIDList[i] );
+            return false;
          }
       }
    }

+ 3 - 2
Engine/source/console/torquescript/compiledEval.cpp

@@ -917,8 +917,7 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi
                {
                   if (Con::gObjectCopyFailures == -1)
                      Con::errorf(ConsoleLogEntry::General, "%s: Unable to find parent object %s for %s.", getFileLine(ip - 1), objParent, callArgv[1].getString());
-                  else
-                     ++Con::gObjectCopyFailures;
+                  ++Con::gObjectCopyFailures;
 
                   delete object;
                   currentNewObject = NULL;
@@ -1033,6 +1032,7 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi
             {
                // This error is usually caused by failing to call Parent::initPersistFields in the class' initPersistFields().
                Con::warnf(ConsoleLogEntry::General, "%s: Register object failed for object %s of class %s.", getFileLine(ip - 2), currentNewObject->getName(), currentNewObject->getClassName());
+               ++Con::gObjectCopyFailures;
                delete currentNewObject;
                currentNewObject = NULL;
                ip = failJump;
@@ -1049,6 +1049,7 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi
          {
             Con::errorf(ConsoleLogEntry::General, "%s: preload failed for %s: %s.", getFileLine(ip - 2),
                currentNewObject->getName(), errorStr.c_str());
+            ++Con::gObjectCopyFailures;
             dataBlock->deleteObject();
             currentNewObject = NULL;
             ip = failJump;

+ 1 - 1
Engine/source/gui/controls/guiPopUpCtrlEx.cpp

@@ -1427,7 +1427,7 @@ bool GuiPopUpMenuCtrlEx::onKeyDown(const GuiEvent &event)
 //------------------------------------------------------------------------------
 void GuiPopUpMenuCtrlEx::onAction()
 {
-   if (!mActive)
+   if (!mActive || dynamic_cast<GuiPopupTextListCtrlEx*>(mTl) == NULL )
       return;
 
    GuiControl *canCtrl = getParent();

+ 2 - 13
Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript

@@ -20,17 +20,6 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-
-//------------------------------------------------------------------------------
-// Check if a script file exists, compiled or not.
-function isScriptFile(%path)
-{
-   if( isFile(%path @ ".dso") || isFile(%path) )
-      return true;
-   
-   return false;
-}
-
 function loadMaterials()
 {
    loadModuleMaterials();
@@ -77,7 +66,7 @@ function loadDatablockFiles( %datablockFiles, %recurse )
    for ( %i=0; %i < %count; %i++ )
    {
       %file = %datablockFiles.getKey( %i );
-      if (!isFile(%file) && !isFile(%file @ ".dso") && !isFile(%file @"."@ $TorqueScriptFileExtension @ ".dso") && !isFile(%file @"."@ $TorqueScriptFileExtension))
+      if (!isScriptFile(%file))
          continue;
                   
       exec( %file );
@@ -100,7 +89,7 @@ function recursiveLoadDatablockFiles( %datablockFiles, %previousErrors )
    for ( %i=0; %i < %count; %i++ )
    {      
       %file = %datablockFiles.getKey( %i );
-      if (!isFile(%file) && !isFile(%file @ ".dso") && !isFile(%file @"."@ $TorqueScriptFileExtension @ ".dso") && !isFile(%file @"."@ $TorqueScriptFileExtension))
+      if (!isScriptFile(%file))
          continue;
          
       // Start counting copy constructor creation errors.

+ 1 - 1
Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/module.tscript.template

@@ -20,11 +20,11 @@ function @@::onCreateGameServer(%this)
     //These are common managed data files. For any datablock-based stuff that gets generated by the editors
     //(that doesn't have a specific associated file, like data for a player class) will go into these.
     //So we'll register them now if they exist.
-    %this.registerDatablock("./scripts/managedData/managedDatablocks");
     %this.registerDatablock("./scripts/managedData/managedForestItemData");
     %this.registerDatablock("./scripts/managedData/managedForestBrushData");
     %this.registerDatablock("./scripts/managedData/managedParticleData");
     %this.registerDatablock("./scripts/managedData/managedParticleEmitterData");
+    %this.registerDatablock("./scripts/managedData/managedDatablocks");
     //--DATABLOCK EXEC END--
 }