Command stuff

This commit is contained in:
momo5502 2016-08-13 16:39:05 +02:00
parent e0bdf9a23a
commit d8486422ea
2 changed files with 6 additions and 13 deletions

View File

@ -2,7 +2,7 @@
namespace Components
{
std::vector<Game::cmd_function_t*> Command::Functions;
Utils::Memory::Allocator Command::MemAllocator;
std::map<std::string, wink::slot<Command::Callback>> Command::FunctionMap;
std::map<std::string, wink::slot<Command::Callback>> Command::FunctionMapSV;
@ -105,10 +105,7 @@ namespace Components
Game::cmd_function_t* Command::Allocate()
{
Game::cmd_function_t* cmd = new Game::cmd_function_t;
Command::Functions.push_back(cmd);
return cmd;
return Command::MemAllocator.Allocate<Game::cmd_function_t>();
}
void Command::MainCallback()
@ -142,12 +139,7 @@ namespace Components
Command::~Command()
{
for (auto command : Command::Functions)
{
delete command;
}
Command::Functions.clear();
Command::MemAllocator.Clear();
Command::FunctionMap.clear();
Command::FunctionMapSV.clear();
}

View File

@ -36,10 +36,11 @@ namespace Components
static Game::cmd_function_t* Find(std::string command);
private:
static Game::cmd_function_t* Allocate();
static std::vector<Game::cmd_function_t*> Functions;
static Utils::Memory::Allocator MemAllocator;
static std::map<std::string, wink::slot<Callback>> FunctionMap;
static std::map<std::string, wink::slot<Callback>> FunctionMapSV;
static Game::cmd_function_t* Allocate();
static void MainCallback();
static void MainCallbackSV();
};