Skip to content

Commit

Permalink
Fix #4445: Removing worldspawn from the map prevents new brushes from…
Browse files Browse the repository at this point in the history
… being drag-created

Was a regression introduced by the changes in the Map class
  • Loading branch information
codereader committed Dec 21, 2016
1 parent d583ce1 commit 8568fc4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
17 changes: 17 additions & 0 deletions radiant/map/Map.cpp
Expand Up @@ -151,6 +151,15 @@ bool Map::isUnnamed() const {
return _mapName == _(MAP_UNNAMED_STRING);
}

void Map::onSceneNodeErase(const scene::INodePtr& node)
{
// Detect when worldspawn is removed from the map
if (node == _worldSpawnNode)
{
_worldSpawnNode.reset();
}
}

void Map::setWorldspawn(const scene::INodePtr& node)
{
_worldSpawnNode = node;
Expand Down Expand Up @@ -966,6 +975,7 @@ const StringSet& Map::getDependencies() const
{
_dependencies.insert(MODULE_RADIANT);
_dependencies.insert(MODULE_GAMEMANAGER);
_dependencies.insert(MODULE_SCENEGRAPH);
}

return _dependencies;
Expand All @@ -984,6 +994,8 @@ void Map::initialiseModule(const ApplicationContext& ctx)
sigc::mem_fun(*_startupMapLoader, &StartupMapLoader::onRadiantShutdown)
);

GlobalSceneGraph().addSceneObserver(this);

// Add the Map-related commands to the EventManager
registerCommands();

Expand All @@ -993,6 +1005,11 @@ void Map::initialiseModule(const ApplicationContext& ctx)
MapFileManager::registerFileTypes();
}

void Map::shutdownModule()
{
GlobalSceneGraph().removeSceneObserver(this);
}

// Creates the static module instance
module::StaticModule<Map> staticMapModule;

Expand Down
8 changes: 7 additions & 1 deletion radiant/map/Map.h
Expand Up @@ -5,6 +5,7 @@
#include "imapformat.h"
#include "inamespace.h"
#include "imapresource.h"
#include "iscenegraph.h"
#include "icommandsystem.h"
#include "imodule.h"
#include "math/Vector3.h"
Expand All @@ -19,7 +20,8 @@ class TextInputStream;
namespace map {

class Map :
public IMap
public IMap,
public scene::Graph::Observer
{
// The map name
std::string _mapName;
Expand Down Expand Up @@ -60,6 +62,10 @@ class Map :
virtual const std::string& getName() const override;
virtual const StringSet& getDependencies() const override;
virtual void initialiseModule(const ApplicationContext& ctx) override;
virtual void shutdownModule() override;

// Gets called when a node is removed from the scenegraph
virtual void onSceneNodeErase(const scene::INodePtr& node) override;

/** greebo: Returns true if the map has not been named yet.
*/
Expand Down

0 comments on commit 8568fc4

Please sign in to comment.