diff --git a/SetupThrive.rb b/SetupThrive.rb index 0ad9c4be211..7147d4b20e2 100755 --- a/SetupThrive.rb +++ b/SetupThrive.rb @@ -78,7 +78,7 @@ def parseExtraArgs leviathan = Leviathan.new( # Use this if you always want the latest commit # version: "develop", - version: "e6c7f7f82be32fe48f92c11a21d91d4fde44da1a", + version: "5f3f3d1b3ef74b27f3ae7e1fb5f32a740dfcd813", # Doesn't actually work, but leviathan doesn't install with sudo by # default, or install at all for that matter noInstallSudo: true diff --git a/scripts/microbe_stage/setup.as b/scripts/microbe_stage/setup.as index ae63d195160..d6c312049e0 100644 --- a/scripts/microbe_stage/setup.as +++ b/scripts/microbe_stage/setup.as @@ -17,6 +17,14 @@ void setupScriptsForWorld(CellStageWorld@ world) setupSpawnSystem(world); } +//! Server variant of setupScriptsForWorld +void setupScriptsForWorld_Server(CellStageWorld@ world) +{ + setupSpecies(world); + setupSystemsForWorld_Server(world); + // setupSpawnSystem_Server(world); +} + // This function should be the entry point for all player initial-species generation // For now, it can go through the XML and instantiate all the species, but later this // would be all procedural. @@ -75,6 +83,23 @@ void setupSystemsForWorld(CellStageWorld@ world) world.RegisterScriptSystem("MicrobeAISystem", MicrobeAISystem()); } +//! Server variant of setupSystemsForWorld +void setupSystemsForWorld_Server(CellStageWorld@ world) +{ + // Fail if compound registry is empty // + assert(SimulationParameters::compoundRegistry().getSize() > 0, + "Compound registry is empty"); + + world.RegisterScriptComponentType("MicrobeComponent", @MicrobeComponentFactory); + world.RegisterScriptComponentType("MicrobeAIControllerComponent", + @MicrobeAIControllerComponentFactory); + + // Add any new systems and component types that are defined in scripts here + world.RegisterScriptSystem("MicrobeSystem", MicrobeSystem()); + world.RegisterScriptSystem("SpeciesSystem", SpeciesSystem()); + world.RegisterScriptSystem("MicrobeAISystem", MicrobeAISystem()); +} + //! This spawns the player void setupPlayer(CellStageWorld@ world) diff --git a/src/microbe_stage/compound_cloud_system.cpp b/src/microbe_stage/compound_cloud_system.cpp index bffc929cf6a..b200065693d 100644 --- a/src/microbe_stage/compound_cloud_system.cpp +++ b/src/microbe_stage/compound_cloud_system.cpp @@ -277,7 +277,10 @@ void { m_position = newPosition; - m_sceneNode->setPosition(m_position.X, CLOUD_Y_COORDINATE, m_position.Z); + // This check is for non-graphical mode + if(m_sceneNode) + m_sceneNode->setPosition( + m_position.X, CLOUD_Y_COORDINATE, m_position.Z); // Clear data. Maybe there is a faster way for(size_t x = 0; x < m_density1.size(); ++x) { @@ -317,6 +320,9 @@ void // field. createVelocityField(); + // Skip if no graphics + if(!Ogre::Root::getSingletonPtr()) + return; // Create a background plane on which the fluid clouds will be drawn. Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 1.0); @@ -363,6 +369,10 @@ void world.DestroyEntity(m_managedClouds.begin()->first); } + // Skip if no graphics + if(!Ogre::Root::getSingletonPtr()) + return; + // Destroy the shared mesh Ogre::MeshManager::getSingleton().remove(m_planeMesh); } @@ -831,18 +841,6 @@ void { LOG_INFO("Initializing a new compound cloud entity"); - // Create where the eventually created plane object will be attached - cloud.m_sceneNode = scene->getRootSceneNode()->createChildSceneNode(); - - // set the position properly - cloud.m_sceneNode->setPosition( - cloud.m_position.X, CLOUD_Y_COORDINATE, cloud.m_position.Z); - - // Because of the way Ogre generates the UVs for a plane we need to rotate - // the plane to match up with world coordinates - cloud.m_sceneNode->setOrientation( - Ogre::Quaternion(Ogre::Degree(90), Ogre::Vector3::UNIT_Y)); - // All the densities if(cloud.m_compoundId1 != NULL_COMPOUND) { cloud.m_density1.resize(CLOUD_SIMULATION_WIDTH, @@ -869,6 +867,24 @@ void std::vector(CLOUD_SIMULATION_HEIGHT, 0)); } + cloud.m_initialized = true; + + // Skip if no graphics + if(!Ogre::Root::getSingletonPtr()) + return; + + // Create where the eventually created plane object will be attached + cloud.m_sceneNode = scene->getRootSceneNode()->createChildSceneNode(); + + // set the position properly + cloud.m_sceneNode->setPosition( + cloud.m_position.X, CLOUD_Y_COORDINATE, cloud.m_position.Z); + + // Because of the way Ogre generates the UVs for a plane we need to rotate + // the plane to match up with world coordinates + cloud.m_sceneNode->setOrientation( + Ogre::Quaternion(Ogre::Degree(90), Ogre::Vector3::UNIT_Y)); + // Create a modified material that uses cloud.m_planeMaterial = Ogre::MaterialManager::getSingleton().create( cloud.m_textureName + "_material", "Generated"); @@ -981,8 +997,6 @@ void // currently initializing one so it is fine cloud.m_compoundCloudsPlane->setMaterialName( cloud.m_planeMaterial->getName()); - - cloud.m_initialized = true; } // ------------------------------------ // void @@ -1032,6 +1046,10 @@ void advect(cloud.m_oldDens4, cloud.m_density4, renderTime); } + // No graphics check + if(!cloud.m_texture) + return; + // Store the pixel data in a hardware buffer for quick access. auto pixelBuffer = cloud.m_texture->getBuffer(); diff --git a/src/server/ThriveServer.cpp b/src/server/ThriveServer.cpp index df88689902d..9253e00db15 100644 --- a/src/server/ThriveServer.cpp +++ b/src/server/ThriveServer.cpp @@ -39,14 +39,6 @@ class ThriveServer::Implementation { std::shared_ptr m_cellStage; // std::shared_ptr m_microbeEditor; - // This contains all the microbe_stage AngelScript code - Leviathan::GameModule::pointer m_microbeScripts; - - // This is "temporarily" merged with the microbe scripts as this needs to - // share some types - // // This contains all the microbe_editor AngelScript code - // Leviathan::GameModule::pointer m_MicrobeEditorScripts; - // std::shared_ptr m_cellStageKeys; }; @@ -64,7 +56,7 @@ ThriveServer::~ThriveServer() std::string ThriveServer::GenerateWindowTitle() { - return "Thrive " GAME_VERSIONS; + return "Thrive Server " GAME_VERSIONS; } ThriveServer* @@ -137,14 +129,14 @@ void // Let the script do setup // // This registers all the script defined systems to run and be // available from the world - LEVIATHAN_ASSERT(m_impl->m_microbeScripts, "microbe scripts not loaded"); + LEVIATHAN_ASSERT(getMicrobeScripts(), "microbe scripts not loaded"); LOG_INFO("Calling world setup script setupScriptsForWorld_Server"); ScriptRunningSetup setup; setup.SetEntrypoint("setupScriptsForWorld_Server"); - auto result = m_impl->m_microbeScripts->ExecuteOnModule( + auto result = getMicrobeScripts()->ExecuteOnModule( setup, false, m_impl->m_cellStage.get()); if(result.Result != SCRIPT_RUN_RESULT::Success) { @@ -160,7 +152,7 @@ void // // Spawn player // // setup = ScriptRunningSetup("setupPlayer"); - // result = m_impl->m_microbeScripts->ExecuteOnModule( + // result = getMicrobeScripts()->ExecuteOnModule( // setup, false, m_impl->m_cellStage.get()); // if(result.Result != SCRIPT_RUN_RESULT::Success) {