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

Method handleConsoleCommand

source/network/ODServer.cpp:276–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276void ODServer::handleConsoleCommand(Player* player, GameMap* gameMap, const std::vector<std::string>& args)
277{
278 if(args.empty())
279 {
280 OD_LOG_WRN("Invalid empty console command");
281 return;
282 }
283
284 if(mConsoleInterface.tryExecuteServerCommand(args, *gameMap) != Command::Result::SUCCESS)
285 {
286 std::string msg = "Cannot execute console command";
287 for(const std::string& str : args)
288 {
289 msg += " " + str;
290 }
291 OD_LOG_WRN(msg);
292 return;
293 }
294
295 // We notify all players that a console command has been executed
296 ServerNotification *serverNotification = new ServerNotification(
297 ServerNotificationType::chatServer, nullptr);
298
299 std::string msg = "Console cmd launched: " + args[0];
300 serverNotification->mPacket << msg << EventShortNoticeType::genericGameInfo;
301 ODServer::getSingleton().queueServerNotification(serverNotification);
302}
303
304void ODServer::startNewTurn(double timeSinceLastTurn)
305{

Callers

nothing calls this directly

Calls 2

Tested by

no test coverage detected