コード例 #1
0
ファイル: MapCell.cpp プロジェクト: AscNHalf/AscNHalf
void MapCell::LoadObjects(CellSpawns * sp)
{
	_loaded = true;
	Instance * pInstance = _mapmgr->pInstance;

	if(sp->CreatureSpawns.size())//got creatures
	{
		Vehicle* v = NULLVEHICLE;
		Creature* c = NULLCREATURE;
		for(CreatureSpawnList::iterator i=sp->CreatureSpawns.begin();i!=sp->CreatureSpawns.end();i++)
		{
			if(pInstance)
			{
				if(pInstance->m_killedNpcs.find((*i)->id) != pInstance->m_killedNpcs.end())
					continue;

/*				if((*i)->respawnNpcLink && pInstance->m_killedNpcs.find((*i)->respawnNpcLink) != pInstance->m_killedNpcs.end())
					continue;*/
			}
			if(!(*i)->eventid)
			{
				if((*i)->vehicle != 0)
				{
				v =_mapmgr->CreateVehicle((*i)->entry);
				if(v == NULLVEHICLE)
					continue;

					v->SetMapId(_mapmgr->GetMapId());
					v->SetInstanceID(_mapmgr->GetInstanceID());
					v->m_loadedFromDB = true;

					if(v->Load(*i, _mapmgr->iInstanceMode, _mapmgr->GetMapInfo()))
					{
						if(!v->CanAddToWorld())
						{
							v->Destructor();
							v = NULLVEHICLE;
							continue;
						}

						v->PushToWorld(_mapmgr);
					}
					else
					{
						v->Destructor();
					}
				}
				else
				{
					c=_mapmgr->CreateCreature((*i)->entry);
					if(c == NULLCREATURE)
						continue;
	
					c->SetMapId(_mapmgr->GetMapId());
					c->SetInstanceID(_mapmgr->GetInstanceID());
					c->m_loadedFromDB = true;

					if(c->Load(*i, _mapmgr->iInstanceMode, _mapmgr->GetMapInfo()))
					{
						if(!c->CanAddToWorld())
						{
							c->Destructor();
							c = NULLCREATURE;
							continue;
						}

						c->PushToWorld(_mapmgr);
					}
					else
					{
						c->Destructor();
					}
				}
			}
		}
	}

	if(sp->GOSpawns.size())//got GOs
	{
		GameObject* go;
		for(GOSpawnList::iterator i=sp->GOSpawns.begin();i!=sp->GOSpawns.end();i++)
		{
			if(!(*i)->eventid)
			{
				go = _mapmgr->CreateGameObject((*i)->entry);
				if(go == NULL)
					continue;
				if(go->Load(*i))
				{
					go->m_loadedFromDB = true;
					go->PushToWorld(_mapmgr);
					CALL_GO_SCRIPT_EVENT(go, OnSpawn)();
				}
				else
				{
					go->Destructor();
				}
			}
		}
	}
}
コード例 #2
0
ファイル: INGEvents.cpp プロジェクト: AscNHalf/AscNHalf
void MapCell::LoadEventIdObjects(CellSpawns * sp, uint8 eventId)
{
	Instance * pInstance = _mapmgr->pInstance;

	if(sp)
	{
		if(sp->CreatureSpawns.size())//got creatures
		{
			Vehicle* v;
			Creature* c;
			for(CreatureSpawnList::iterator i = sp->CreatureSpawns.begin(); i != sp->CreatureSpawns.end(); ++i)
			{
				if(pInstance)
				{
					if(pInstance->m_killedNpcs.find((*i)->id) != pInstance->m_killedNpcs.end())
						continue;
				}
				if((*i)->eventid && (*i)->eventid == eventId)
				{
					if(!((*i)->eventinfo->eventchangesflag & EVENTID_FLAG_SPAWN))
						continue;

					if((*i)->vehicle != 0)
					{
						v=_mapmgr->CreateVehicle((*i)->entry);

						v->SetMapId(_mapmgr->GetMapId());
						v->SetInstanceID(_mapmgr->GetInstanceID());
						v->m_loadedFromDB = true;

						if(v->Load(*i, _mapmgr->iInstanceMode, _mapmgr->GetMapInfo()))
						{
							if(!v->CanAddToWorld())
							{
								v->Destructor();
								continue;
							}

							v->PushToWorld(_mapmgr);
						}
						else
						{
							v->Destructor();
						}
					}
					else
					{
						c = _mapmgr->CreateCreature((*i)->entry);

						c->SetMapId(_mapmgr->GetMapId());
						c->SetInstanceID(_mapmgr->GetInstanceID());
						c->m_loadedFromDB = true;

						if(c->Load(*i, _mapmgr->iInstanceMode, _mapmgr->GetMapInfo()))
						{
							if(!c->CanAddToWorld())
							{
								c->Destructor();
								continue;
							}

							c->PushToWorld(_mapmgr);
						}
						else
						{
							c->Destructor();
						}
					}
				}
			}
		}

		if(sp->GOSpawns.size())//got GOs
		{
			GameObject* go;
			for(GOSpawnList::iterator i = sp->GOSpawns.begin(); i != sp->GOSpawns.end(); ++i)
			{
				if((*i)->eventid && (*i)->eventid == eventId)
				{
					if(!((*i)->eventinfo->eventchangesflag & EVENTID_FLAG_SPAWN))
						continue;
					
					go = _mapmgr->CreateGameObject((*i)->entry);
					if(go == NULL)
						continue;

					if(go->Load(*i))
					{
						go->m_loadedFromDB = true;
						go->PushToWorld(_mapmgr);
						CALL_GO_SCRIPT_EVENT(go, OnSpawn)();
					}
					else
					{
						go->Destructor();
					}
				}
			}
		}
	}
}