Sdk: Add server-side module

Former-commit-id: 4df27d1e44d791aad234d095af08ae3c19660fba
This commit is contained in:
Lynix 2015-12-13 16:36:38 +01:00
parent 4c72e27784
commit cfe7c79991
3 changed files with 97 additions and 33 deletions

View File

@ -13,64 +13,80 @@
#include <Nazara/Utility/Utility.hpp> #include <Nazara/Utility/Utility.hpp>
#include <NDK/Algorithm.hpp> #include <NDK/Algorithm.hpp>
#include <NDK/BaseSystem.hpp> #include <NDK/BaseSystem.hpp>
#include <NDK/Components/CameraComponent.hpp>
#include <NDK/Components/CollisionComponent.hpp> #include <NDK/Components/CollisionComponent.hpp>
#include <NDK/Components/LightComponent.hpp>
#include <NDK/Components/ListenerComponent.hpp>
#include <NDK/Components/GraphicsComponent.hpp>
#include <NDK/Components/NodeComponent.hpp> #include <NDK/Components/NodeComponent.hpp>
#include <NDK/Components/PhysicsComponent.hpp> #include <NDK/Components/PhysicsComponent.hpp>
#include <NDK/Components/VelocityComponent.hpp> #include <NDK/Components/VelocityComponent.hpp>
#include <NDK/Systems/ListenerSystem.hpp>
#include <NDK/Systems/PhysicsSystem.hpp> #include <NDK/Systems/PhysicsSystem.hpp>
#include <NDK/Systems/RenderSystem.hpp>
#include <NDK/Systems/VelocitySystem.hpp> #include <NDK/Systems/VelocitySystem.hpp>
#ifndef NDK_SERVER
#include <NDK/Components/CameraComponent.hpp>
#include <NDK/Components/LightComponent.hpp>
#include <NDK/Components/ListenerComponent.hpp>
#include <NDK/Components/GraphicsComponent.hpp>
#include <NDK/Systems/ListenerSystem.hpp>
#include <NDK/Systems/RenderSystem.hpp>
#endif
namespace Ndk namespace Ndk
{ {
bool Sdk::Initialize() bool Sdk::Initialize()
{ {
if (s_referenceCounter++ > 0) if (s_referenceCounter++ > 0)
return true; // Déjà initialisé return true; // Already initialized
try try
{ {
Nz::ErrorFlags errFlags(Nz::ErrorFlag_ThrowException, true); Nz::ErrorFlags errFlags(Nz::ErrorFlag_ThrowException, true);
// Initialisation du moteur // Initialize the engine first
// Modules clients // Shared modules
Nz::Audio::Initialize();
Nz::Graphics::Initialize();
// Modules serveurs
Nz::Lua::Initialize(); Nz::Lua::Initialize();
Nz::Noise::Initialize(); Nz::Noise::Initialize();
Nz::Physics::Initialize(); Nz::Physics::Initialize();
Nz::Utility::Initialize(); Nz::Utility::Initialize();
// Initialisation du SDK #ifndef NDK_SERVER
// Client modules
Nz::Audio::Initialize();
Nz::Graphics::Initialize();
#endif
// Initialisation des composants et systèmes // SDK Initialization
// Components
BaseComponent::Initialize(); BaseComponent::Initialize();
BaseSystem::Initialize();
// Composants // Shared components
InitializeComponent<CameraComponent>("NdkCam");
InitializeComponent<CollisionComponent>("NdkColli"); InitializeComponent<CollisionComponent>("NdkColli");
InitializeComponent<LightComponent>("NdkLight");
InitializeComponent<ListenerComponent>("NdkList");
InitializeComponent<GraphicsComponent>("NdkGfx");
InitializeComponent<NodeComponent>("NdkNode"); InitializeComponent<NodeComponent>("NdkNode");
InitializeComponent<PhysicsComponent>("NdkPhys"); InitializeComponent<PhysicsComponent>("NdkPhys");
InitializeComponent<VelocityComponent>("NdkVeloc"); InitializeComponent<VelocityComponent>("NdkVeloc");
// Systèmes #ifndef NDK_SERVER
InitializeSystem<ListenerSystem>(); // Client components
InitializeComponent<CameraComponent>("NdkCam");
InitializeComponent<LightComponent>("NdkLight");
InitializeComponent<ListenerComponent>("NdkList");
InitializeComponent<GraphicsComponent>("NdkGfx");
#endif
// Systems
BaseSystem::Initialize();
// Shared systems
InitializeSystem<PhysicsSystem>(); InitializeSystem<PhysicsSystem>();
InitializeSystem<RenderSystem>();
InitializeSystem<VelocitySystem>(); InitializeSystem<VelocitySystem>();
#ifndef NDK_SERVER
// Client systems
InitializeSystem<ListenerSystem>();
InitializeSystem<RenderSystem>();
#endif
NazaraNotice("Initialized: SDK"); NazaraNotice("Initialized: SDK");
return true; return true;
} }
@ -86,23 +102,25 @@ namespace Ndk
{ {
if (s_referenceCounter != 1) if (s_referenceCounter != 1)
{ {
// Le module est soit encore utilisé, soit pas initialisé // Either the module is not initialized, either it was initialized multiple times
if (s_referenceCounter > 1) if (s_referenceCounter > 1)
s_referenceCounter--; s_referenceCounter--;
return; return;
} }
// Libération du SDK // Uninitialize the SDK
s_referenceCounter = 0; s_referenceCounter = 0;
// Libération du moteur // Uninitialize the engine
// Modules clients #ifndef NDK_SERVER
// Client modules
Nz::Audio::Uninitialize(); Nz::Audio::Uninitialize();
Nz::Graphics::Uninitialize(); Nz::Graphics::Uninitialize();
#endif
// Modules serveurs // Shared modules
Nz::Lua::Uninitialize(); Nz::Lua::Uninitialize();
Nz::Noise::Uninitialize(); Nz::Noise::Uninitialize();
Nz::Physics::Uninitialize(); Nz::Physics::Uninitialize();

View File

@ -4,11 +4,14 @@
#include <NDK/World.hpp> #include <NDK/World.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
#include <NDK/Systems/ListenerSystem.hpp>
#include <NDK/Systems/PhysicsSystem.hpp> #include <NDK/Systems/PhysicsSystem.hpp>
#include <NDK/Systems/RenderSystem.hpp>
#include <NDK/Systems/VelocitySystem.hpp> #include <NDK/Systems/VelocitySystem.hpp>
#ifndef NDK_SERVER
#include <NDK/Systems/ListenerSystem.hpp>
#include <NDK/Systems/RenderSystem.hpp>
#endif
namespace Ndk namespace Ndk
{ {
World::~World() World::~World()
@ -19,10 +22,13 @@ namespace Ndk
void World::AddDefaultSystems() void World::AddDefaultSystems()
{ {
AddSystem<ListenerSystem>();
AddSystem<PhysicsSystem>(); AddSystem<PhysicsSystem>();
AddSystem<RenderSystem>();
AddSystem<VelocitySystem>(); AddSystem<VelocitySystem>();
#ifndef NDK_SERVER
AddSystem<ListenerSystem>();
AddSystem<RenderSystem>();
#endif
} }
const EntityHandle& World::CreateEntity() const EntityHandle& World::CreateEntity()

View File

@ -0,0 +1,40 @@
TOOL.Name = "SDKServer"
TOOL.Directory = "../SDK/lib"
TOOL.Kind = "Library"
TOOL.Defines = {
"NDK_BUILD",
"NDK_SERVER"
}
TOOL.Includes = {
"../SDK/include"
}
TOOL.Files = {
"../SDK/include/NDK/**.hpp",
"../SDK/include/NDK/**.inl",
"../SDK/src/NDK/**.hpp",
"../SDK/src/NDK/**.inl",
"../SDK/src/NDK/**.cpp"
}
-- Exlude client-only files
TOOL.FilesExclusion = {
"../SDK/**/CameraComponent.*",
"../SDK/**/GraphicsComponent.*",
"../SDK/**/LightComponent.*",
"../SDK/**/ListenerComponent.*",
"../SDK/**/ListenerSystem.*",
"../SDK/**/RenderSystem.*",
"../SDK/**/LuaInterface_Audio.*"
}
TOOL.Libraries = {
"NazaraCore",
"NazaraLua",
"NazaraNoise",
"NazaraPhysics",
"NazaraUtility"
}