// Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . // Nel Misc #include "nel/net/service.h" #include "nel/misc/command.h" // Game share #include "game_share/macro_manager.h" // locals #include "ai_files.h" #include "ai_manager.h" #include "ai_service.h" using namespace NLMISC; using namespace NLNET; using namespace std; //------------------------------------------------------------------------- // utility routines static void argsToManagerVector(const vector &args, vector &theManagers) { if(args.size()==0) { for (uint i=0;i theManagers; argsToManagerVector(args,theManagers); // do the work for (uint i=0;ineedCompile()) { //nlinfo("Compiling manager: %04d: %s",theManagers[i]->id(),theManagers[i]->name()); theManagers[i]->compile(); } else nlinfo("Manager is up to date: %04d: %s",theManagers[i]->id(),theManagers[i]->name().c_str()); } return true; } NLMISC_COMMAND(aiClean,"delete all generated files on the hard disk (next 'make' will rebuild everything)","") { COMMAND_MACRO_RECORD_TEST // rescan the source and object directories for files CAIFiles::scan(); // build the list of ai managers to act on vector theManagers; argsToManagerVector(args,theManagers); // do the work for (uint i=0;iid(),theManagers[i]->name().c_str()); theManagers[i]->clean(); } return true; } //------------------------------------------------------------------------- NLMISC_COMMAND(aiDisplayServices,"list the ai services, their parameters and their lists of running managers","[[...]]") { if(args.size()!=0) return false; COMMAND_MACRO_RECORD_TEST return true; } NLMISC_COMMAND(aiDisplayManagers,"Display the known ai manager list","[[...]]") { COMMAND_MACRO_RECORD_TEST // build the list of ai managers to act on vector theManagers; argsToManagerVector(args,theManagers); // do the work for (uint i=0;idisplay(); return true; } //------------------------------------------------------------------------- NLMISC_COMMAND(aiOpenAllManagers,"Open all managers and automatically assign to ai services","") { if(args.size()!=0) return false; COMMAND_MACRO_RECORD_TEST for (uint i=0;iisOpen()) CAIManager::getManagerByIdx(i)->open(); return true; } NLMISC_COMMAND(aiOpenManagers,"Open managers and automatically assign to ai services","[...]") { if(args.size()<1) return false; COMMAND_MACRO_RECORD_TEST for (uint i=0;iopen(); } return true; } NLMISC_COMMAND(aiAssignManagers,"Open managers and assign to specified ai service","[...]") { if(args.size()<2) return false; COMMAND_MACRO_RECORD_TEST // convert args[0] to service id and verify existance in services list NLNET::TServiceId service(atoi(args[0].c_str())); if (service.get()==0 && args[0]!="0") { nlwarning("Invalid service id: %s",args[0].c_str()); return false; } // iterate through args assigning managers to service for (uint i=1;iassign(service); } return true; } NLMISC_COMMAND(aiReassignManagers,"Save & close managers on existing services and open on specified ai service","[...]") { if(args.size()<2) return false; COMMAND_MACRO_RECORD_TEST // convert args[0] to service id and verify existance in services list NLNET::TServiceId service(atoi(args[0].c_str())); if (service.get()==0 && args[0]!="0") { nlwarning("Invalid service id: %s",args[0].c_str()); return false; } // iterate through args reassigning managers to service for (uint i=1;ireassign(service); } return true; } //------------------------------------------------------------------------- NLMISC_COMMAND(aiCloseAllManagers,"Close all managers across all ai services on the shard","") { if(args.size()!=0) return false; COMMAND_MACRO_RECORD_TEST for (uint i=0;iisOpen()) CAIManager::getManagerByIdx(i)->close(); return true; } NLMISC_COMMAND(aiCloseManagers,"Close listed managers","[...]") { if(args.size()<1) return false; COMMAND_MACRO_RECORD_TEST for (uint i=0;iclose(); } return true; } //-------------------------------------------------------------------------