Skip to content

Commit

Permalink
Fixed some bugs related to the order that plugins load in.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gohla committed Jul 19, 2011
1 parent 633807c commit c970036
Show file tree
Hide file tree
Showing 15 changed files with 144 additions and 79 deletions.
3 changes: 3 additions & 0 deletions Build/VC10/DSLTypeExtrctor.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<AdditionalOptions>-Zm311 %(AdditionalOptions)</AdditionalOptions>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>DSLTypeExtractor\Platform\StableHeaders.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\DSLTypeExtractor\source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ProjectReference />
<Link>
Expand All @@ -85,6 +86,7 @@
<AdditionalOptions>-Zm311 %(AdditionalOptions)</AdditionalOptions>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>DSLTypeExtractor\Platform\StableHeaders.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\DSLTypeExtractor\source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>LibUtil.lib;LibObject.lib;LibShared.lib;LibClient.lib;LibOgreClient.lib;BulletCollision.lib;BulletDynamics.lib;BulletFileLoader.lib;BulletWorldImporter.lib;caelum.lib;cAudio.lib;camp-lua.lib;dbghelp.lib;freetype2311.lib;libcurl.lib;LinearMath.lib;lua.lib;MyGUI.OgrePlatform.lib;MyGUIEngine.lib;OgreMain.lib;OgreProcedural.lib;OgreRTShaderSystem.lib;OgreTerrain.lib;OpenAL32.lib;OIS.lib;RakNetDLL.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand All @@ -96,6 +98,7 @@
<AdditionalOptions>-Zm311 %(AdditionalOptions)</AdditionalOptions>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>DSLTypeExtractor\Platform\StableHeaders.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\DSLTypeExtractor\source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>LibUtil_rd.lib;LibObject_rd.lib;LibShared_rd.lib;LibClient_rd.lib;LibOgreClient_rd.lib;BulletCollision.lib;BulletDynamics.lib;BulletFileLoader.lib;BulletWorldImporter.lib;caelum.lib;cAudio.lib;camp-lua.lib;dbghelp.lib;freetype2311.lib;libcurl.lib;LinearMath.lib;lua.lib;MyGUI.OgrePlatform.lib;MyGUIEngine.lib;OgreMain.lib;OgreProcedural.lib;OgreRTShaderSystem.lib;OgreTerrain.lib;OpenAL32.lib;OIS.lib;RakNetDLL.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand Down
4 changes: 1 addition & 3 deletions Build/VC10/Diversia application.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
<TargetExt>.exe</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\$(ProjectName)\source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ClCompile />
</ItemDefinitionGroup>
<ItemGroup />
</Project>
3 changes: 3 additions & 0 deletions Build/VC10/OgreClient.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<AdditionalOptions>-Zm310 %(AdditionalOptions)</AdditionalOptions>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>DefaultClient\Platform\StableHeaders.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\DefaultClient\source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ProjectReference />
<Link>
Expand All @@ -86,6 +87,7 @@
<AdditionalOptions>-Zm310 %(AdditionalOptions)</AdditionalOptions>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>DefaultClient\Platform\StableHeaders.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\DefaultClient\source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -98,6 +100,7 @@
<AdditionalOptions>-Zm310 %(AdditionalOptions)</AdditionalOptions>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>DefaultClient\Platform\StableHeaders.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\DefaultClient\source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down
108 changes: 54 additions & 54 deletions Build/VC10/QtOgreEditor.vcxproj

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Framework/Client/Communication/GridManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ ServerAbstract& GridManager::createOfflineServer()
mActiveServer = server;
server->connect( sigc::mem_fun( this, &GridManager::serverStateChanged ) );
mServerChangeSignal( *server, true );
server->create();
return *server;
}

Expand All @@ -80,6 +81,8 @@ ServerAbstract& GridManager::createServer( const GridPosition& rGridPosition,
{
Server* server = new Server( rGridPosition, rServerInfo, rUserInfo, mUpdateSignal );
mServerGrid.insert( std::make_pair( rGridPosition, server ) );
mServerChangeSignal( *server, true );
server->create();

// If the active server hasn't been set, set the first created server to the active server.
if( !mActiveServer )
Expand All @@ -90,7 +93,6 @@ ServerAbstract& GridManager::createServer( const GridPosition& rGridPosition,

server->connect( sigc::mem_fun( this, &GridManager::serverStateChanged ) );
mLoadingServers.insert( rGridPosition );
mServerChangeSignal( *server, true );
return *server;
}
else
Expand Down
5 changes: 5 additions & 0 deletions Framework/Client/Communication/OfflineServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ void OfflineServer::pluginLoadingComplete()
mLoadingConnection.disconnect();
}

void OfflineServer::create()
{
mPluginManager->autoCreatePlugins();
}

//------------------------------------------------------------------------------
} // Namespace Client
} // Namespace Diversia
2 changes: 2 additions & 0 deletions Framework/Client/Communication/OfflineServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class DIVERSIA_CLIENT_API OfflineServer : public ServerAbstract
**/
inline ClientPluginManager& getPluginManager() { return *mPluginManager; }

void create();

/**
Connects a slot to the server state changed signal.
Expand Down
5 changes: 5 additions & 0 deletions Framework/Client/Communication/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ void Server::pluginLoadingComplete()
}
}

void Server::create()
{
mPluginManager->autoCreatePlugins();
}

//------------------------------------------------------------------------------
} // Namespace Client
} // Namespace Diversia
2 changes: 2 additions & 0 deletions Framework/Client/Communication/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class DIVERSIA_CLIENT_API Server : public ServerAbstract, public sigc::trackable
**/
inline bool isConnecting() { return mServerState == CONNECTING; }

void create();

/**
Connects a slot to the server state changed signal.
Expand Down
42 changes: 40 additions & 2 deletions Framework/OgreClient/Resource/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,37 @@ namespace OgreClient
{
//------------------------------------------------------------------------------

boost::filesystem::path naive_uncomplete(boost::filesystem::path const path,
boost::filesystem::path const base) {
if (path.has_root_path()){
if (path.root_path() != base.root_path()) {
return path;
} else {
return naive_uncomplete(path.relative_path(), base.relative_path());
}
} else {
if (base.has_root_path()) {
throw "cannot uncomplete a path relative path from a rooted base";
} else {
typedef boost::filesystem::path::const_iterator path_iterator;
path_iterator path_it = path.begin();
path_iterator base_it = base.begin();
while ( path_it != path.end() && base_it != base.end() ) {
if (*path_it != *base_it) break;
++path_it; ++base_it;
}
boost::filesystem::path result;
for (; base_it != base.end(); ++base_it) {
result /= "..";
}
for (; path_it != path.end(); ++path_it) {
result /= *path_it;
}
return result;
}
}
}

ResourceManager::ResourcesLoader::ResourcesLoader()
{

Expand Down Expand Up @@ -101,7 +132,11 @@ void ResourceManager::setResourceLocation( const String& rResourceLocation )
if( mResourceLocation != rResourceLocation && !rResourceLocation.empty() )
{
mResourceLocation = rResourceLocation;
if( mCreated ) ResourceManager::load();
if( mCreated )
{
ResourceManager::destroy();
ResourceManager::load();
}
}
}

Expand Down Expand Up @@ -314,7 +349,10 @@ void ResourceManager::load()
mResourcePath;
}

mRGM.addResourceLocation( mResourcePath.string(), "FileSystem", mGroup, true );
mResourcePath = naive_uncomplete( mResourcePath, boost::filesystem::current_path() );
mResourceLocation = mResourcePath.string();

mRGM.addResourceLocation( mResourceLocation, "FileSystem", mGroup, true );
break;
}
case RESOURCELOCATIONTYPE_URL:
Expand Down
27 changes: 15 additions & 12 deletions Framework/Shared/Plugin/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ PluginManager::PluginManager( Mode mode, PluginState state,
{
mUpdateConnection = mUpdateSignal.connect( sigc::mem_fun( this,
&PluginManager::update ) );

// Create auto create plugins.
for( PluginTypes::iterator i = mAutoCreatePlugins.begin();
i != mAutoCreatePlugins.end(); ++i )
{
PluginManager::createPlugin( *i );
}
}

PluginManager::~PluginManager()
Expand Down Expand Up @@ -149,6 +142,11 @@ void PluginManager::addAutoCreatePlugin( PluginTypeEnum type )
mAutoCreatePlugins.insert( type );
}

bool PluginManager::hasAutoCreatePlugin( PluginTypeEnum type )
{
return mAutoCreatePlugins.find( type ) != mAutoCreatePlugins.end();
}

void PluginManager::setState( PluginState state )
{
if( state == mPluginState ) return;
Expand Down Expand Up @@ -199,6 +197,16 @@ void PluginManager::unloadAll()
i->second->unload();
}

void PluginManager::autoCreatePlugins()
{
// Create auto create plugins.
for( PluginTypes::iterator i = mAutoCreatePlugins.begin();
i != mAutoCreatePlugins.end(); ++i )
{
PluginManager::createPlugin( *i );
}
}

void PluginManager::update()
{
SLOGD << "PluginManager::update";
Expand Down Expand Up @@ -228,10 +236,5 @@ void PluginManager::update()
mUpdateConnection.block( true );
}

bool PluginManager::hasAutoCreatePlugin( PluginTypeEnum type )
{
return mAutoCreatePlugins.find( type ) != mAutoCreatePlugins.end();
}

//------------------------------------------------------------------------------
} // Namespace Diversia
5 changes: 5 additions & 0 deletions Framework/Shared/Plugin/PluginManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ class DIVERSIA_SHARED_API PluginManager : public boost::noncopyable
return mPluginStateChange.connect( rSlot );
}

/**
Create all plugins in the auto create plugins list.
**/
void autoCreatePlugins();

protected:
/**
Gets the map of client-server plugins.
Expand Down
5 changes: 5 additions & 0 deletions QtOgreEditor/source/EditorApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,16 @@ void EditorApplication::init( int argc, char* argv[] )
// Add plugin factories, get camp class to ensure that the class is registered.
TemplatePluginFactory<PermissionManager, ClientPluginManager>::registerFactory();
camp::classByType<PermissionManager>();
PluginManager::addAutoCreatePlugin<PermissionManager>();
TemplatePluginFactory<ResourceManager, ClientPluginManager>::registerFactory();
camp::classByType<ResourceManager>();
PluginManager::addAutoCreatePlugin<ResourceManager>();
TemplatePluginFactory<ClientObjectTemplateManager, ClientPluginManager>::registerFactory();
camp::classByType<ClientObjectTemplateManager>();
PluginManager::addAutoCreatePlugin<ClientObjectTemplateManager>();
ObjectManagerFactory<EditorObjectManager, ClientPluginManager>::registerFactory( mUpdateSignal, mLateUpdateSignal );
camp::classByType<EditorObjectManager>();
PluginManager::addAutoCreatePlugin<EditorObjectManager>();
TemplatePluginFactory<ServerNeighborsPlugin, ClientPluginManager>::registerFactory();
camp::classByType<ServerNeighborsPlugin>();
TemplatePluginFactory<SkyPlugin, ClientPluginManager>::registerFactory();
Expand All @@ -186,6 +190,7 @@ void EditorApplication::init( int argc, char* argv[] )
TemplatePluginFactory<GameModePlugin, ClientPluginManager>::registerFactory();
camp::classByType<GameModePlugin>();
GameModePlugin::setDefaultSlot( sigc::ptr_fun( &EditorGameMode::createGameMode ) );
PluginManager::addAutoCreatePlugin<GameModePlugin>();

// Initialize graphics
mGraphicsManager.reset( new GraphicsManager() );
Expand Down
3 changes: 0 additions & 3 deletions QtOgreEditor/source/UI/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,6 @@ void MainWindow::_loadGame( const QString& rFile )
EditorGlobals::mGrid->createOfflineServer();
EditorGlobals::mState->pushState( new LoadingState() );
ClientPluginManager& pluginManager = EditorGlobals::mGrid->getActiveServer().getPluginManager();
pluginManager.createPlugin<PermissionManager>();
pluginManager.createPlugin<ClientObjectTemplateManager>();
pluginManager.createPlugin<ClientObjectManager>();

try
{
Expand Down
5 changes: 1 addition & 4 deletions QtOgreEditor/source/UI/NewGameDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ void NewGameDialog::accept()
{
EditorGlobals::mGrid->createOfflineServer();
ClientPluginManager& pluginManager = EditorGlobals::mGrid->getActiveServer().getPluginManager();
pluginManager.createPlugin<PermissionManager>();
pluginManager.createPlugin<ClientObjectTemplateManager>();
pluginManager.createPlugin<ClientObjectManager>();
ResourceManager& resourceManager = pluginManager.createPlugin<ResourceManager>();
ResourceManager& resourceManager = pluginManager.getPlugin<ResourceManager>();
resourceManager.set( "ResourceLocation", mUI.editResourceLocation->text() );
resourceManager.set( "Type", mUI.comboResourceType->currentText() );
EditorGlobals::mCurrentGame = mUI.editGameFile->text();
Expand Down

0 comments on commit c970036

Please sign in to comment.