当前位置: 首页>>代码示例>>C++>>正文


C++ MapCell类代码示例

本文整理汇总了C++中MapCell的典型用法代码示例。如果您正苦于以下问题:C++ MapCell类的具体用法?C++ MapCell怎么用?C++ MapCell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MapCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

void MoonInstanceScript::SetCellForcedStates(float pMinX, float pMaxX, float pMinY, float pMaxY, bool pActivate)
{
	if(pMinX == pMaxX || pMinY == pMaxY)
		return;

	float Y = pMinY;
	while(pMinX < pMaxX)
	{
		while(pMinY < pMaxY)
		{
			MapCell* CurrentCell = mInstance->GetCellByCoords(pMinX, pMinY);
			if(pActivate && CurrentCell == NULL)
			{
				CurrentCell = mInstance->CreateByCoords(pMinX, pMinY);
				if(CurrentCell != NULL)
					CurrentCell->Init(mInstance->GetPosX(pMinX), mInstance->GetPosY(pMinY), mInstance);
			}

			if(CurrentCell != NULL)
				pActivate ? mInstance->AddForcedCell(CurrentCell) : mInstance->RemoveForcedCell(CurrentCell);

			pMinY += 40.0f;
		}

		pMinY = Y;
		pMinX += 40.0f;
	}
}
开发者ID:Refuge89,项目名称:arcscripts2,代码行数:28,代码来源:MoonInstanceScript.cpp

示例2: GetPosX

void MapMgr::SendChatMessageToCellPlayers(Object * obj, WorldPacket * packet, uint32 cell_radius, uint32 langpos, int32 lang, WorldSession * originator)
{
	uint32 cellX = GetPosX(obj->GetPositionX());
	uint32 cellY = GetPosY(obj->GetPositionY());
	uint32 endX = ((cellX+cell_radius) <= _sizeX) ? cellX + cell_radius : (_sizeX-1);
	uint32 endY = ((cellY+cell_radius) <= _sizeY) ? cellY + cell_radius : (_sizeY-1);
	uint32 startX = (cellX-cell_radius) > 0 ? cellX - cell_radius : 0;
	uint32 startY = (cellY-cell_radius) > 0 ? cellY - cell_radius : 0;

	uint32 posX, posY;
	MapCell *cell;
	MapCell::ObjectSet::iterator iter, iend;
	for (posX = startX; posX <= endX; ++posX )
	{
		for (posY = startY; posY <= endY; ++posY )
		{
			cell = GetCell(posX, posY);
			if (cell && cell->HasPlayers() )
			{
				iter = cell->Begin();
				iend = cell->End();
				for(; iter != iend; ++iter)
				{
					if((*iter)->IsPlayer())
					{
						//static_cast< Player* >(*iter)->GetSession()->SendPacket(packet);
						static_cast< Player* >(*iter)->GetSession()->SendChatPacket(packet, langpos, lang, originator);
					}
				}
			}
		}
	}
}
开发者ID:Chero,项目名称:abcwow,代码行数:33,代码来源:MapMgr.cpp

示例3: _CellActive

bool MapMgr::_CellActive(uint32 x, uint32 y)
{
	uint32 endX = ((x+1) <= _sizeX) ? x + 1 : (_sizeX-1);
	uint32 endY = ((y+1) <= _sizeY) ? y + 1 : (_sizeY-1);
	uint32 startX = x > 0 ? x - 1 : 0;
	uint32 startY = y > 0 ? y - 1 : 0;
	uint32 posX, posY;

	MapCell *objCell;

	for (posX = startX; posX <= endX; posX++ )
	{
		for (posY = startY; posY <= endY; posY++ )
		{
			objCell = GetCell(posX, posY);

			if (objCell)
			{
				if (objCell->HasPlayers())
				{
					return true;
				}
			}
		}
	}

	return false;
}
开发者ID:Chero,项目名称:abcwow,代码行数:28,代码来源:MapMgr.cpp

示例4: Sql

void SystemManager::select_stage_code_map(int stage_id) {
	vector<MapCell>& map = Stage::GetInstance() -> m_Map;
	map.clear();
	try {
		Kompex::SQLiteDatabase *pDatabase = new Kompex::SQLiteDatabase(m_db_full_path.c_str(), SQLITE_OPEN_READWRITE, 0);
		Kompex::SQLiteStatement *pStmt = new Kompex::SQLiteStatement(pDatabase);

		pStmt -> Sql("SELECT * FROM stage_code_map WHERE stage_id = @stage_id");
		pStmt -> BindInt(1, stage_id);

		while (pStmt -> FetchRow()) {
			MapCell mc;
			CCPoint loc = Stage::GetInstance() -> idx2loc(pStmt -> GetColumnInt("cell_idx"));
			mc.setMapCell(loc, (enumMapCellCode)(pStmt -> GetColumnInt("cell_code")));
			mc.poll_code = (enumMapCellPollCode)(pStmt -> GetColumnInt("cell_poll_code"));
			//mc.setPollCode((enumMapCellPollCode)(pStmt -> GetColumnInt("cell_poll_code")));
			map.push_back(mc);
		}

		delete pStmt;
		delete pDatabase;

	} catch(Kompex::SQLiteException &exception) {
		//std::cerr << "\nException Occured" << std::endl;
		CCLOGERROR("\nException Occured: \n%s", exception.GetString().c_str());
		exception.Show();
	}
}
开发者ID:wang-yichun,项目名称:Gravity,代码行数:28,代码来源:SystemManager.cpp

示例5: GetCell

void MapMgr::UnloadCell(uint32 x,uint32 y)
{
	MapCell * c = GetCell(x,y);
	if(c == NULL || c->HasPlayers() || _CellActive(x,y) || !c->IsUnloadPending()) return;

	sLog.outDetail("Unloading Cell [%d][%d] on map %d (instance %d)...", 
		x,y,_mapId,m_instanceID);

	c->Unload();
}
开发者ID:Chero,项目名称:abcwow,代码行数:10,代码来源:MapMgr.cpp

示例6: GetCell

void MapMgr::UnloadCell(uint32 x, uint32 y)
{
	MapCell* c = GetCell(x, y);
	if(c == NULL || c->HasPlayers() || _CellActive(x, y) || !c->IsUnloadPending()) return;

	LOG_DETAIL("Unloading Cell [%u][%u] on map %u (instance %u)...",
	           x, y, _mapId, m_instanceID);

	c->Unload();
}
开发者ID:Thomas195,项目名称:arcemu,代码行数:10,代码来源:MapMgr.cpp

示例7: SetUInt64Value

void Corpse::SetOwner(uint64 guid)
{
	SetUInt64Value(CORPSE_FIELD_OWNER, guid);
	if(guid == 0)
	{
		//notify the MapCell that the Corpse has no more an owner so the MapCell can go idle (if there's nothing else)
		MapCell* cell = GetMapCell();
		if(cell != NULL)
			cell->CorpseGoneIdle(this);
	}
}
开发者ID:DebugProject,项目名称:Lua-Other,代码行数:11,代码来源:Corpse.cpp

示例8: LOG_DEBUG

// Spawns the object too, without which you can not interact with the object
GameObject* MapMgr::CreateAndSpawnGameObject(uint32 entryID, float x, float y, float z, float o, float scale)
{
	GameObjectInfo* goi = GameObjectNameStorage.LookupEntry(entryID);
	if(!goi)
	{
		LOG_DEBUG("Error looking up entry in CreateAndSpawnGameObject");
		return NULL;
	}

	LOG_DEBUG("CreateAndSpawnGameObject: By Entry '%u'", entryID);

	GameObject* go = CreateGameObject(entryID);

	//Player *chr = m_session->GetPlayer();
	uint32 mapid = GetMapId();
	// Setup game object
	go->CreateFromProto(entryID, mapid, x, y, z, o);
	go->SetScale(scale);
	go->InitAI();
	go->PushToWorld(this);

	// Create spawn instance
	GOSpawn* gs = new GOSpawn;
	gs->entry = go->GetEntry();
	gs->facing = go->GetOrientation();
	gs->faction = go->GetFaction();
	gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS);
	gs->id = objmgr.GenerateGameObjectSpawnID();
	gs->o = 0.0f;
	gs->o1 = go->GetParentRotation(0);
	gs->o2 = go->GetParentRotation(2);
	gs->o3 = go->GetParentRotation(3);
	gs->scale = go->GetScale();
	gs->x = go->GetPositionX();
	gs->y = go->GetPositionY();
	gs->z = go->GetPositionZ();
	gs->state = go->GetByte(GAMEOBJECT_BYTES_1, 0);
	//gs->stateNpcLink = 0;
	gs->overrides = go->GetOverrides();

	uint32 cx = GetPosX(x);
	uint32 cy = GetPosY(y);

	GetBaseMap()->GetSpawnsListAndCreate(cx, cy)->GOSpawns.push_back(gs);
	go->m_spawn = gs;

	MapCell* mCell = GetCell(cx, cy);

	if(mCell != NULL)
		mCell->SetLoaded();

	return go;
}
开发者ID:Thomas195,项目名称:arcemu,代码行数:54,代码来源:MapMgr.cpp

示例9: strtok

bool ChatHandler::HandleGOPhaseCommand(const char* args, WorldSession* m_session)
{
	char* sPhase = strtok((char*)args, " ");
	if(!sPhase)
		return false;

	uint32 newphase = atoi(sPhase);

	bool Save = false;
	char* pSave = strtok(NULL, " ");
	if(pSave)
		Save = (atoi(pSave) > 0 ? true : false);

	GameObject* go = m_session->GetPlayer()->GetSelectedGo();
	if(!go)
	{
		RedSystemMessage(m_session, "No selected GameObject...");
		return true;
	}

	go->Phase(PHASE_SET, newphase);

	GOSpawn* gs = go->m_spawn;
	if(gs == NULL)
	{
		RedSystemMessage(m_session, "The GameObject got no spawn, not saving and not logging...");
		return true;
	}
	//VLack: We have to have a spawn, or SaveToDB would write a 0 into the first column (ID), and would erroneously overwrite something in the DB.
	//The code which saves creatures is a bit more forgiving, as it creates a new spawn on-demand, but the gameobject code does not.

	gs->phase = go->GetPhase();

	uint32 cx = m_session->GetPlayer()->GetMapMgr()->GetPosX(m_session->GetPlayer()->GetPositionX());
	uint32 cy = m_session->GetPlayer()->GetMapMgr()->GetPosY(m_session->GetPlayer()->GetPositionY());

	MapCell* mCell = m_session->GetPlayer()->GetMapMgr()->GetCell(cx, cy);

	if(mCell != NULL)
		mCell->SetLoaded();

	if(Save == true)
	{
		// If we're saving, create template and add index
		go->SaveToDB();
		go->m_loadedFromDB = true;
	}
	sGMLog.writefromsession(m_session, "phased gameobject %s to %u, entry %u at %u %f %f %f%s", GameObjectNameStorage.LookupEntry(gs->entry)->Name, newphase, gs->entry, m_session->GetPlayer()->GetMapId(), gs->x, gs->y, gs->z, Save ? ", saved in DB" : "");
	return true;
}
开发者ID:Ikesters,项目名称:ArcPro,代码行数:50,代码来源:Level2.cpp

示例10: ASSERT

void MapMgr::RemoveObject(Object *obj)
{
    ASSERT(obj);
    ASSERT(obj->GetMapId() == _mapId);
    ASSERT(obj->GetPositionX() > _minX && obj->GetPositionX() < _maxX);
    ASSERT(obj->GetPositionY() > _minY && obj->GetPositionY() < _maxY);
    ASSERT(_cells);

    sLog.outDetail("Removing object "I64FMT" with type %i from the world.",
        obj->GetGUID(), obj->GetTypeId());

    // That object types are not map objects. TODO: add AI groups here?
    if(obj->GetTypeId() == TYPEID_ITEM || obj->GetTypeId() == TYPEID_CONTAINER)
    {
    // remove updatable flag and exit
        obj->RemoveFromWorld();
        return;
    }

    obj->RemoveFromWorld();

    ObjectMap::iterator itr = _objects.find(obj->GetGUID());
    _objects.erase(itr);

    // remove us from updated objects list
    ObjectSet::iterator updi = _updatedObjects.find(obj);
    if(updi != _updatedObjects.end())
        _updatedObjects.erase(updi);

    MapCell *objCell = obj->GetMapCell();

    obj->SetMapCell(0);
    objCell->RemoveObject(obj);

    for (Object::InRangeSet::iterator iter = obj->GetInRangeSetBegin();
        iter != obj->GetInRangeSetEnd(); iter++)
    {
        (*iter)->RemoveInRangeObject(obj);

        if((*iter)->GetTypeId() == TYPEID_PLAYER)
            obj->DestroyForPlayer( (Player*)*iter );
    }

    obj->ClearInRangeSet();
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:45,代码来源:MapMgr.cpp

示例11: LoadAllCells

void MapMgr::LoadAllCells()
{
	// eek
	MapCell * cellInfo;
	CellSpawns * spawns;

	for( uint32 x = 0 ; x < _sizeX ; x ++ )
	{
		for( uint32 y = 0 ; y < _sizeY ; y ++ )
		{
			cellInfo = GetCell( x , y );
			
			if( !cellInfo )
			{
				// Cell doesn't exist, create it.
				// There is no spoon. Err... cell.
				cellInfo = Create( x , y );
				cellInfo->Init( x , y , _mapId , this );
				sLog.outDetail( "Created cell [%u,%u] on map %d (instance %d)." , x , y , _mapId , m_instanceID );
				cellInfo->SetActivity( true );
				_map->CellGoneActive( x , y );
				ASSERT( !cellInfo->IsLoaded() );

				spawns = _map->GetSpawnsList( x , y );
				if( spawns )
					cellInfo->LoadObjects( spawns );
			}
			else
			{
				// Cell exists, but is inactive
				if ( !cellInfo->IsActive() )
				{
					sLog.outDetail("Activated cell [%u,%u] on map %d (instance %d).", x, y, _mapId, m_instanceID );
					_map->CellGoneActive( x , y );
					cellInfo->SetActivity( true );

					if (!cellInfo->IsLoaded())
					{
						//sLog.outDetail("Loading objects for Cell [%d][%d] on map %d (instance %d)...", 
						//	posX, posY, this->_mapId, m_instanceID);
						spawns = _map->GetSpawnsList( x , y );
						if( spawns )
							cellInfo->LoadObjects( spawns );
					}
				}
			}
		}
	}
}
开发者ID:Chero,项目名称:abcwow,代码行数:49,代码来源:MapMgr.cpp

示例12: GetPlayerCountInRadius

uint32 MapScriptInterface::GetPlayerCountInRadius(float x, float y, float z /* = 0.0f */, float radius /* = 5.0f */)
{
	// use a cell radius of 2
	uint32 PlayerCount = 0;
	uint32 cellX = mapMgr.GetPosX(x);
	uint32 cellY = mapMgr.GetPosY(y);

	uint32 endX = cellX < _sizeX ? cellX + 1 : _sizeX;
	uint32 endY = cellY < _sizeY ? cellY + 1 : _sizeY;
	uint32 startX = cellX > 0 ? cellX - 1 : 0;
	uint32 startY = cellY > 0 ? cellY - 1 : 0;
	MapCell* pCell;
	ObjectSet::iterator iter, iter_end;

	for(uint32 cx = startX; cx < endX; ++cx)
	{
		for(uint32 cy = startY; cy < endY; ++cy)
		{
			pCell = mapMgr.GetCell(cx, cy);
			if(pCell == 0 || pCell->GetPlayerCount() == 0)
				continue;

			iter = pCell->Begin();
			iter_end = pCell->End();

			for(; iter != iter_end; ++iter)
			{
				if((*iter)->IsPlayer() &&
				        (*iter)->CalcDistance(x, y, (z == 0.0f ? (*iter)->GetPositionZ() : z)) < radius)
				{
					++PlayerCount;
				}
			}
		}
	}

	return PlayerCount;
}
开发者ID:Selenah,项目名称:ArcEmu,代码行数:38,代码来源:MapScriptInterface.cpp

示例13: strtok

bool ChatHandler::HandleGOSpawn(const char *args, WorldSession *m_session)
{
	std::stringstream sstext;

	char* pEntryID = strtok((char*)args, " ");
	if (!pEntryID)
		return false;

	uint32 EntryID  = atoi(pEntryID);

	bool Save = false;
	char* pSave = strtok(NULL, " ");
	if (pSave)
		Save = (atoi(pSave)>0?true:false);

	GameObjectInfo* goi = GameObjectNameStorage.LookupEntry(EntryID);
	if(!goi)
	{
		sstext << "GameObject Info '" << EntryID << "' Not Found" << '\0';
		SystemMessage(m_session, sstext.str().c_str());
		return true;
	}

	sLog.outDebug("Spawning GameObject By Entry '%u'", EntryID);
	sstext << "Spawning GameObject By Entry '" << EntryID << "'" << '\0';
	SystemMessage(m_session, sstext.str().c_str());

	GameObject *go = m_session->GetPlayer()->GetMapMgr()->CreateGameObject(EntryID);

	Player *chr = m_session->GetPlayer();
	uint32 mapid = chr->GetMapId();
	float x = chr->GetPositionX();
	float y = chr->GetPositionY();
	float z = chr->GetPositionZ();
	float o = chr->GetOrientation();

	go->SetInstanceID(chr->GetInstanceID());
	go->CreateFromProto(EntryID,mapid,x,y,z,o);

	/* fuck blizz coordinate system */
	go->SetFloatValue(GAMEOBJECT_ROTATION_02, sinf(o / 2));
	go->SetFloatValue(GAMEOBJECT_ROTATION_03, cosf(o / 2));
	go->PushToWorld(m_session->GetPlayer()->GetMapMgr());

	// Create sapwn instance
	GOSpawn * gs = new GOSpawn;
	gs->entry = go->GetEntry();
	gs->facing = go->GetOrientation();
	gs->faction = go->GetUInt32Value(GAMEOBJECT_FACTION);
	gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS);
	gs->id = objmgr.GenerateGameObjectSpawnID();
	gs->o = go->GetFloatValue(GAMEOBJECT_ROTATION);
	gs->o1 = go->GetFloatValue(GAMEOBJECT_ROTATION_01);
	gs->o2 = go->GetFloatValue(GAMEOBJECT_ROTATION_02);
	gs->o3 = go->GetFloatValue(GAMEOBJECT_ROTATION_03);
	gs->scale = go->GetFloatValue(OBJECT_FIELD_SCALE_X);
	gs->x = go->GetPositionX();
	gs->y = go->GetPositionY();
	gs->z = go->GetPositionZ();
	gs->state = go->GetUInt32Value(GAMEOBJECT_STATE);
	//gs->stateNpcLink = 0;

	uint32 cx = m_session->GetPlayer()->GetMapMgr()->GetPosX(m_session->GetPlayer()->GetPositionX());
	uint32 cy = m_session->GetPlayer()->GetMapMgr()->GetPosY(m_session->GetPlayer()->GetPositionY());

	m_session->GetPlayer()->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cx,cy)->GOSpawns.push_back(gs);
	go->m_spawn = gs;

	MapCell * mCell = m_session->GetPlayer()->GetMapMgr()->GetCell( cx, cy );

	if( mCell != NULL )
		mCell->SetLoaded();

	if(Save == true)
	{
		// If we're saving, create template and add index
		go->SaveToDB();
		go->m_loadedFromDB = true;
	}
	sGMLog.writefromsession( m_session, "spawned gameobject %s, entry %u at %u %f %f %f%s", GameObjectNameStorage.LookupEntry(gs->entry)->Name, gs->entry, m_session->GetPlayer()->GetMapId(), gs->x, gs->y, gs->z, Save ? ", saved in DB" : "" );
	return true;
}
开发者ID:AegisEmu,项目名称:AegisEmu,代码行数:82,代码来源:Level2.cpp

示例14: ARCEMU_ASSERT

void MapMgr::PushObject(Object* obj)
{
	/////////////
	// Assertions
	/////////////
	ARCEMU_ASSERT(obj != NULL);

	// That object types are not map objects. TODO: add AI groups here?
	if(obj->IsItem() || obj->IsContainer())
	{
		// mark object as updatable and exit
		return;
	}

	if(obj->IsCorpse())
	{
		m_corpses.insert(TO< Corpse* >(obj));
	}

	obj->ClearInRangeSet();

	ARCEMU_ASSERT(obj->GetMapId() == _mapId);
	if(!(obj->GetPositionX() < _maxX && obj->GetPositionX() > _minX) ||
	        !(obj->GetPositionY() < _maxY && obj->GetPositionY() > _minY))
	{
		if(obj->IsPlayer())
		{
			Player* plr = TO< Player* >(obj);
			if(plr->GetBindMapId() != GetMapId())
			{
				plr->SafeTeleport(plr->GetBindMapId(), 0, plr->GetBindPositionX(), plr->GetBindPositionY(), plr->GetBindPositionZ(), 0);
				plr->GetSession()->SystemMessage("Teleported you to your hearthstone location as you were out of the map boundaries.");
				return;
			}
			else
			{
				obj->GetPositionV()->ChangeCoords(plr->GetBindPositionX(), plr->GetBindPositionY(), plr->GetBindPositionZ(), 0);
				plr->GetSession()->SystemMessage("Teleported you to your hearthstone location as you were out of the map boundaries.");
				plr->SendTeleportAckMsg(plr->GetPosition());
			}
		}
		else
		{
			obj->GetPositionV()->ChangeCoords(0, 0, 0, 0);
		}
	}

	ARCEMU_ASSERT(obj->GetPositionY() < _maxY && obj->GetPositionY() > _minY);
	ARCEMU_ASSERT(_cells != NULL);

	///////////////////////
	// Get cell coordinates
	///////////////////////

	uint32 x = GetPosX(obj->GetPositionX());
	uint32 y = GetPosY(obj->GetPositionY());

	if(x >= _sizeX || y >= _sizeY)
	{
		if(obj->IsPlayer())
		{
			Player* plr = TO< Player* >(obj);
			if(plr->GetBindMapId() != GetMapId())
			{
				plr->SafeTeleport(plr->GetBindMapId(), 0, plr->GetBindPositionX(), plr->GetBindPositionY(), plr->GetBindPositionZ(), 0);
				plr->GetSession()->SystemMessage("Teleported you to your hearthstone location as you were out of the map boundaries.");
				return;
			}
			else
			{
				obj->GetPositionV()->ChangeCoords(plr->GetBindPositionX(), plr->GetBindPositionY(), plr->GetBindPositionZ(), 0);
				plr->GetSession()->SystemMessage("Teleported you to your hearthstone location as you were out of the map boundaries.");
				plr->SendTeleportAckMsg(plr->GetPosition());
			}
		}
		else
		{
			obj->GetPositionV()->ChangeCoords(0, 0, 0, 0);
		}

		x = GetPosX(obj->GetPositionX());
		y = GetPosY(obj->GetPositionY());
	}

	MapCell* objCell = GetCell(x, y);
	if(objCell == NULL)
	{
		objCell = Create(x, y);
		objCell->Init(x, y, this);
	}
	ARCEMU_ASSERT(objCell != NULL);

	uint32 endX = (x <= _sizeX) ? x + 1 : (_sizeX - 1);
	uint32 endY = (y <= _sizeY) ? y + 1 : (_sizeY - 1);
	uint32 startX = x > 0 ? x - 1 : 0;
	uint32 startY = y > 0 ? y - 1 : 0;
	uint32 posX, posY;
	MapCell* cell;
	//MapCell::ObjectSet::iterator iter;

//.........这里部分代码省略.........
开发者ID:Thomas195,项目名称:arcemu,代码行数:101,代码来源:MapMgr.cpp

示例15: if


//.........这里部分代码省略.........
	{
		if(obj->IsPlayer())
		{
			Player* plr = static_cast< Player* >( obj );
			if(plr->GetBindMapId() != GetMapId())
			{
				plr->SafeTeleport(plr->GetBindMapId(),0,plr->GetBindPositionX(),plr->GetBindPositionY(),plr->GetBindPositionZ(),0);
				plr->GetSession()->SystemMessage("Teleported you to your hearthstone location as you were out of the map boundaries.");
				return;
			}
			else
			{
				obj->GetPositionV()->ChangeCoords(plr->GetBindPositionX(),plr->GetBindPositionY(),plr->GetBindPositionZ(),0);
				plr->GetSession()->SystemMessage("Teleported you to your hearthstone location as you were out of the map boundaries.");
				WorldPacket * data = plr->BuildTeleportAckMsg(plr->GetPosition());
				plr->GetSession()->SendPacket(data);
				delete data;
			}
		}
		else
		{
			obj->GetPositionV()->ChangeCoords(0,0,0,0);
		}
	}

	uint32 cellX = GetPosX(obj->GetPositionX());
	uint32 cellY = GetPosY(obj->GetPositionY());

	if(cellX >= _sizeX || cellY >= _sizeY)
	{
		return;
	}

	MapCell *objCell = GetCell(cellX, cellY);
	MapCell * pOldCell = obj->GetMapCell();
	if (!objCell)
	{
		objCell = Create(cellX,cellY);
		objCell->Init(cellX, cellY, _mapId, this);
	}

	// If object moved cell
	if (objCell != obj->GetMapCell())
	{
		// THIS IS A HACK!
		// Current code, if a creature on a long waypoint path moves from an active
		// cell into an inactive one, it will disable itself and will never return.
		// This is to prevent cpu leaks. I will think of a better solution very soon :P

		if(!objCell->IsActive() && !plObj && obj->Active)
			obj->Deactivate(this);

		if(obj->GetMapCell())
			obj->GetMapCell()->RemoveObject(obj);
	
		objCell->AddObject(obj);
		obj->SetMapCell(objCell);

		// if player we need to update cell activity
		// radius = 2 is used in order to update both
		// old and new cells
		if(obj->GetTypeId() == TYPEID_PLAYER)
		{
			// have to unlock/lock here to avoid a deadlock situation.
			UpdateCellActivity(cellX, cellY, 2);
			if( pOldCell != NULL )
开发者ID:Chero,项目名称:abcwow,代码行数:67,代码来源:MapMgr.cpp


注:本文中的MapCell类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。