MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / cSrvAddCreature

Function cSrvAddCreature

source/modes/ConsoleCommands.cpp:153–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153Command::Result cSrvAddCreature(const Command::ArgumentList_t& args, ConsoleInterface& c, GameMap& gameMap)
154{
155 if (args.size() < 6)
156 {
157 c.print("Invalid number of arguments\n");
158 return Command::Result::INVALID_ARGUMENT;
159 }
160
161 // We remove the first argument (the console command)
162 Command::ArgumentList_t tmp = args;
163 tmp.erase(tmp.begin());
164 std::string str = boost::algorithm::join(tmp, "\t");
165 std::stringstream ss(str);
166 Creature* creature = Creature::getCreatureFromStream(&gameMap, ss);
167 if(creature == nullptr)
168 {
169 OD_LOG_INF("Cannot creature proper creature from string=" + str);
170 return Command::Result::FAILED;
171 }
172
173 creature->addToGameMap();
174 //Set up definition for creature. This was previously done in createMesh for some reason.
175 creature->setupDefinition(gameMap, *ConfigManager::getSingleton().getCreatureDefinitionDefaultWorker());
176 //Set position to update info on what tile the creature is in.
177 creature->setPosition(creature->getPosition());
178
179 return Command::Result::SUCCESS;
180}
181
182Command::Result cList(const Command::ArgumentList_t& args, ConsoleInterface& c, AbstractModeManager& mm)
183{

Callers

nothing calls this directly

Calls 5

setupDefinitionMethod · 0.80
printMethod · 0.45
addToGameMapMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected