Browse Source

Merge pull request #908 from Azaezel/alpha401/dediserverfixes

dedicated server cleanups
Brian Roberts 2 years ago
parent
commit
ea7ca63301

+ 6 - 2
Engine/source/T3D/assets/ImageAsset.h

@@ -48,6 +48,8 @@
 
 #include <string>
 #include "assetMacroHelpers.h"
+
+#include "gfx/gfxDevice.h"
 //-----------------------------------------------------------------------------
 class ImageAsset : public AssetBase
 {
@@ -250,7 +252,8 @@ public: \
       }\
       else if (!m##name)\
       {\
-         Con::errorf("%s(%s)::_set%s() - Couldn't load image \"%s\"", macroText(className), getName(), macroText(name), _in);\
+         if (GFX->getAdapterType() != NullDevice)\
+            Con::errorf("%s(%s)::_set%s() - Couldn't load image \"%s\"", macroText(className), getName(), macroText(name), _in);\
          return false;\
       }\
       return true;\
@@ -392,7 +395,8 @@ public: \
       }\
       else if (!m##name[index])\
       {\
-         Con::errorf("%s(%s)::_set%s(%i) - Couldn't load image \"%s\"", macroText(className), getName(), macroText(name), index, _in);\
+         if (GFX->getAdapterType() != NullDevice)\
+            Con::errorf("%s(%s)::_set%s(%i) - Couldn't load image \"%s\"", macroText(className), getName(), macroText(name), index, _in);\
          return false; \
       }\
       return true;\

+ 3 - 2
Engine/source/T3D/assets/ShapeAsset.cpp

@@ -358,8 +358,9 @@ bool ShapeAsset::loadShape()
       mLoadedState = BadFileReference;
       return false; //if it failed to load, bail out
    }
-
-   mShape->setupBillboardDetails(mFilePath, mDiffuseImposterPath, mNormalImposterPath);
+   // Construct billboards if not done already
+   if (GFXDevice::devicePresent())
+      mShape->setupBillboardDetails(mFilePath, mDiffuseImposterPath, mNormalImposterPath);
 
    //If they exist, grab our imposters here and bind them to our shapeAsset
 

+ 9 - 1
Engine/source/gfx/Null/gfxNullDevice.cpp

@@ -87,8 +87,16 @@ GFXNullTextureObject::GFXNullTextureObject(GFXDevice * aDevice, GFXTextureProfil
 
 class GFXNullTextureManager : public GFXTextureManager
 {
+public:
+   GFXTextureObject* createTexture(GBitmap* bmp, const String& resourceName, GFXTextureProfile* profile, bool deleteBmp) { return nullptr; } // _createNullTextureObject();}
+   GFXTextureObject* createTexture(DDSFile* dds, GFXTextureProfile* profile, bool deleteDDS) { return nullptr; }
+   GFXTextureObject* createTexture(const Torque::Path& path, GFXTextureProfile* profile) { return nullptr; }
+   GFXTextureObject* createTexture(U32 width, U32 height, void* pixels, GFXFormat format, GFXTextureProfile* profile) { return nullptr; }
+   GFXTextureObject* createTexture(U32 width, U32 height, U32 depth, GFXFormat format, GFXTextureProfile* profile, U32 numMipLevels = 1) { return nullptr; }
+   GFXTextureObject* createTexture(U32 width, U32 height, GFXFormat format, GFXTextureProfile* profile, U32 numMipLevels, S32 antialiasLevel) { return nullptr; }
+   GFXTextureObject* createCompositeTexture(GBitmap* bmp[4], U32 inputKey[4], const String& resourceName, GFXTextureProfile* profile, bool deleteBmp) { return nullptr; }
 protected:
-      virtual GFXTextureObject *_createTextureObject( U32 height, 
+      GFXTextureObject *_createTextureObject( U32 height, 
                                                       U32 width, 
                                                       U32 depth, 
                                                       GFXFormat format, 

+ 1 - 0
Engine/source/materials/processedShaderMaterial.cpp

@@ -295,6 +295,7 @@ void ProcessedShaderMaterial::_determineFeatures(  U32 stageNum,
                                                    MaterialFeatureData &fd, 
                                                    const FeatureSet &features )
 {
+   if (GFX->getAdapterType() == NullDevice) return;
    PROFILE_SCOPE( ProcessedShaderMaterial_DetermineFeatures );
 
    const F32 shaderVersion = GFX->getPixelShaderVersion();

+ 1 - 0
Engine/source/renderInstance/renderDeferredMgr.cpp

@@ -593,6 +593,7 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum,
                                                    MaterialFeatureData &fd,
                                                    const FeatureSet &features )
 {
+   if (GFX->getAdapterType() == NullDevice) return;
    Parent::_determineFeatures( stageNum, fd, features );
    if (fd.features.hasFeature(MFT_ForwardShading))
       return;

+ 3 - 2
Engine/source/sfx/null/sfxNullProvider.cpp

@@ -77,7 +77,8 @@ SFXNullProvider::~SFXNullProvider()
 void SFXNullProvider::addDeviceDesc( const String& name, const String& desc )
 {
    SFXDeviceInfo* info = new SFXDeviceInfo;
-   info->name = desc;
+   info->internalName = desc;
+   info->name = "Null Device";
    info->driver = name;
    info->hasHardware = false;
    info->maxBuffers = 8;
@@ -91,7 +92,7 @@ SFXDevice* SFXNullProvider::createDevice( const String& deviceName, bool useHard
 
    // Do we find one to create?
    if ( info )
-      return new SFXNullDevice( this, info->name, useHardware, maxBuffers );
+      return new SFXNullDevice( this, info->internalName, useHardware, maxBuffers );
 
    return NULL;
 }

+ 6 - 0
Templates/BaseGame/game/core/sfx/scripts/audio.tscript

@@ -149,6 +149,12 @@ function sfxInit()
    if( sfxGetDeviceInfo() !$= "" )
       sfxShutdown();
       
+   if ($isDedicated)
+   {
+      sfxCreateDevice("Null","Null Device", false, 8);
+      return true;
+   }
+   
    // Start it up!
    %maxBuffers = $pref::SFX::useHardware ? -1 : $pref::SFX::maxSoftwareBuffers;
    if ( !sfxCreateDevice( $pref::SFX::provider, $pref::SFX::device, $pref::SFX::useHardware, %maxBuffers ) )

+ 18 - 12
Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript

@@ -499,18 +499,24 @@ function displayHelp()
    // (flushing the write buffer) after every write.
    // -log 2 overwrites any existing logfile; it also only closes
    // the logfile when the application shuts down.  (default)
-
-   error(
-      "Torque Demo command line options:\n"@
-      "  -log <logmode>         Logging behavior; see main." @ $TorqueScriptFileExtension @ " comments for details\n"@
-      "  -game <game_name>      Reset list of mods to only contain <game_name>\n"@
-      "  <game_name>            Works like the -game argument\n"@
-      "  -dir <dir_name>        Add <dir_name> to list of directories\n"@
-      "  -console               Open a separate console\n"@
-      "  -jSave  <file_name>    Record a journal\n"@
-      "  -jPlay  <file_name>    Play back a journal\n"@
-      "  -help                  Display this help message\n"
-   );
+   
+     %helpstring = "Torque Demo command line options:\n";
+     %helpstring =%helpstring @ "  -log <logmode>         Logging behavior; see main." @ $TorqueScriptFileExtension @ " comments for details\n";
+     %helpstring =%helpstring @ "  -game <game_name>      Reset list of mods to only contain <game_name>\n";
+     %helpstring =%helpstring @ "  <game_name>            Works like the -game argument\n";
+     %helpstring =%helpstring @ "  -dir <dir_name>        Add <dir_name> to list of directories\n";
+     %helpstring =%helpstring @ "  -console               Open a separate console\n";
+     %helpstring =%helpstring @ "  -jSave  <file_name>    Record a journal\n";
+     %helpstring =%helpstring @ "  -jPlay  <file_name>    Play back a journal\n";
+     %helpstring =%helpstring @ "  -help                  Display this help message\n";
+      
+   error(%helpstring);
+   
+   %file = new FileObject();
+   if(%file.openForWrite("help.txt"))
+      %file.writeLine(%helpstring);
+   %file.close();
+   %file.delete();
 }
 
 // Execute startup scripts for each mod, starting at base and working up

+ 4 - 4
Templates/BaseGame/game/core/utility/scripts/parseArgs.tscript

@@ -55,7 +55,7 @@ function parseArgs()
       {
          $userDirs = $defaultGame;
          $dirCount = 1;
-         %isDedicated = true;
+         $isDedicated = true;
       }*/
 
       switch$ ($arg)
@@ -64,7 +64,7 @@ function parseArgs()
          case "-dedicated":
             $userDirs = $defaultGame;
             $dirCount = 1;
-            %isDedicated = true;
+            $isDedicated = true;
             $Server::Dedicated = true;
             enableWinConsole(true);
             $argUsed[%i]++;
@@ -138,7 +138,7 @@ function parseArgs()
             {
                // Set the selected dir --NOTE: we no longer allow tools with this argument
                /*
-               if( %isDedicated )
+               if( $isDedicated )
                {
                   $userDirs = $nextArg;
                   $dirCount = 1;
@@ -311,7 +311,7 @@ function parseArgs()
          case "-help":
             $displayHelp = true;
             $argUsed[%i]++;
-
+            displayHelp();
          //-------------------
          case "-compileAll":
             $compileAll = true;

+ 2 - 2
Templates/BaseGame/game/main.tscript.in

@@ -44,7 +44,7 @@ if(isFunction("loadStartup"))
 else
 {
    //If nothing else set a main menu, try to do so now
-   if(!isObject(Canvas.getContent()))
+   if(isObject(Canvas) && !isObject(Canvas.getContent()))
    {
       if (isObject( ProjectSettings.value("UI/mainMenuName") ))
          Canvas.setContent( ProjectSettings.value("UI/mainMenuName") );
@@ -54,4 +54,4 @@ else
 if ( ($Server::Dedicated == false) && ($platform $= "windows") )
     closeSplashWindow();
 
-echo("Engine initialized...");
+echo("Engine initialized...");