1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 //-------------------------------------------------------------------------
20 // Includes & namespaces
23 #include "ai_share/ai_spawn_commands.h"
26 using namespace NLMISC
;
30 //-------------------------------------------------------------------------
31 // The CAISpawnCtrl sub-class
33 //class CAISSpawnCtrl: public CAISpawnCtrl
36 // virtual bool _spawn (int aiInstance, const std::string &name);
37 // virtual bool _spawnMap (int aiInstance, const std::string &name);
38 // virtual bool _spawnMgr (int aiInstance, const std::string &name);
39 // virtual bool _spawnGrp (int aiInstance, const std::string &name);
40 // virtual bool _spawnAll (int aiInstance);
42 // virtual bool _despawn (int aiInstance, const std::string &name);
43 // virtual bool _despawnMap (int aiInstance, const std::string &name);
44 // virtual bool _despawnMgr (int aiInstance, const std::string &name);
45 // virtual bool _despawnGrp (int aiInstance, const std::string &name);
46 // virtual bool _despawnAll (int aiInstance);
48 //} AIServiceSpawnCtrl;
51 //-------------------------------------------------------------------------
52 // The CAISpawnCtrl singleton data
53 //CAISpawnCtrl *CAISpawnCtrl::_instance=&AIServiceSpawnCtrl;
56 //-------------------------------------------------------------------------
59 //bool CAISSpawnCtrl::_spawn(int aiInstance, const std::string &name)
61 // if (_spawnMap(aiInstance, name)) return true;
62 // if (_spawnMgr(aiInstance, name)) return true;
63 // if (_spawnGrp(aiInstance, name)) return true;
67 //bool CAISSpawnCtrl::_spawnGrp(int aiInstance, const std::string &name)
69 // bool returnVal=false;
71 // if (aiInstance==-1) // all aiInstance are concerned.
73 // CCont<CAIInstance>::iterator instanceIt=CAIS::instance().AIList().begin(), instanceItEnd=CAIS::instance().AIList().end();
74 // while (instanceIt!=instanceItEnd)
76 // CGroup* grpPtr=(*instanceIt)->tryToGetGroup(name.c_str());
79 // grpPtr->spawn (); // check error only if not a npc group.
88 // if (CAIS::instance().AIList()[aiInstance])
90 // CGroup* grpPtr=CAIS::instance().AIList()[aiInstance]->tryToGetGroup(name.c_str());
93 // grpPtr->spawn (); // check error only if not a npc group.
103 // nlinfo("Failed to identify groupe from id: %s",name.c_str());
108 //bool CAISSpawnCtrl::_spawnMgr(int aiInstance, const std::string &name)
110 // bool returnVal=false;
112 // if (aiInstance==-1) // all aiInstance are concerned.
114 // CCont<CAIInstance>::iterator instanceIt=CAIS::instance().AIList().begin(), instanceItEnd=CAIS::instance().AIList().end();
115 // while (instanceIt!=instanceItEnd)
117 // CManager* mgrPtr=(*instanceIt)->tryToGetManager(name.c_str());
120 // mgrPtr->spawn (); // check error only if not a npc group.
129 // if (CAIS::instance().AIList()[aiInstance])
131 // CManager* mgrPtr=CAIS::instance().AIList()[aiInstance]->tryToGetManager(name.c_str());
134 // mgrPtr->spawn (); // check error only if not a npc group.
144 // nlinfo("Failed to identify mgr from id: %s",name.c_str());
149 //bool CAISSpawnCtrl::_spawnMap(int aiInstance, const std::string &name)
154 //// // for each manager if map's name found in the command arguments then spawn()
155 //// for (CAIEntityId it=CAIEntityId::firstMgr();!it.isInvalid();it=it.nextMgr())
156 //// if (it.mgrPtr()->getMap()->Name==name)
157 //// it.mgrPtr()->spawn();
161 //bool CAISSpawnCtrl::_spawnAll (int aiInstance)
163 // if (aiInstance==-1) // all aiInstance are concerned.
165 // CCont<CAIInstance>::iterator instanceIt=CAIS::instance().AIList().begin(), instanceItEnd=CAIS::instance().AIList().end();
166 // while (instanceIt!=instanceItEnd)
168 // (*instanceIt)->spawnAll();
175 // if (CAIS::instance().AIList()[aiInstance])
177 // CAIS::instance().AIList()[aiInstance]->spawnAll();
185 ////-------------------------------------------------------------------------
188 //bool CAISSpawnCtrl::_despawn(int aiInstance, const std::string &name)
190 // if (_despawnMap(aiInstance, name)) return true;
191 // if (_despawnMgr(aiInstance, name)) return true;
192 // if (_despawnGrp(aiInstance, name)) return true;
196 //bool CAISSpawnCtrl::_despawnGrp(int aiInstance, const std::string &name)
199 // bool returnVal=false;
201 // if (aiInstance==-1) // all aiInstance are concerned.
203 // CCont<CAIInstance>::iterator instanceIt=CAIS::instance().AIList().begin(), instanceItEnd=CAIS::instance().AIList().end();
204 // while (instanceIt!=instanceItEnd)
206 // CGroup* grpPtr=(*instanceIt)->tryToGetGroup(name.c_str());
209 // grpPtr->despawnGrp (); // check error only if not a npc group.
218 // if (CAIS::instance().AIList()[aiInstance])
220 // CGroup* grpPtr=CAIS::instance().AIList()[aiInstance]->tryToGetGroup(name.c_str());
223 // grpPtr->despawnGrp (); // check error only if not a npc group.
233 // nlinfo("Failed to identify groupe from id: %s",name.c_str());
238 //bool CAISSpawnCtrl::_despawnMgr(int aiInstance, const std::string &name)
240 // bool returnVal=false;
242 // if (aiInstance==-1) // all aiInstance are concerned.
244 // CCont<CAIInstance>::iterator instanceIt=CAIS::instance().AIList().begin(), instanceItEnd=CAIS::instance().AIList().end();
245 // while (instanceIt!=instanceItEnd)
247 // CManager* mgrPtr=(*instanceIt)->tryToGetManager(name.c_str());
250 // mgrPtr->despawnMgr(); // check error only if not a npc group.
259 // if (CAIS::instance().AIList()[aiInstance])
261 // CManager* mgrPtr=CAIS::instance().AIList()[aiInstance]->tryToGetManager(name.c_str());
264 // mgrPtr->despawnMgr(); // check error only if not a npc group.
274 // nlinfo("Failed to identify mgr from id: %s",name.c_str());
279 //bool CAISSpawnCtrl::_despawnMap(int aiInstance, const std::string &name)
282 // nlwarning("Not Implemented");
285 //// // for each manager if map's name found in the command arguments then spawn()
286 //// for (CAIEntityId it=CAIEntityId::firstMgr();!it.isInvalid();it=it.nextMgr())
287 //// if (it.mgrPtr()->getMap()->Name==name)
288 //// it.mgrPtr()->despawn();
293 //bool CAISSpawnCtrl::_despawnAll(int aiInstance)
295 // if (aiInstance==-1) // all aiInstance are concerned.
297 // CCont<CAIInstance>::iterator instanceIt=CAIS::instance().AIList().begin(), instanceItEnd=CAIS::instance().AIList().end();
298 // while (instanceIt!=instanceItEnd)
300 //// NLMEMORY::CheckHeap(true);
301 // (*instanceIt)->despawnAll();
308 // if (CAIS::instance().AIList()[aiInstance])
310 // CAIS::instance().AIList()[aiInstance]->despawnAll();