Ejemplo n.º 1
0
bool ChatHandler::HandleGODelete(const char *args, WorldSession *m_session)
{
    GameObject* GObj = m_session->GetPlayer()->m_GM_SelectedGO;
    if( !GObj )
    {
        RedSystemMessage(m_session, "No selected GameObject...");
        return true;
    }

    bool foundonmap = true;
    if(GObj->m_spawn && GObj->m_spawn->entry == GObj->GetEntry() && GObj->IsInWorld())
    {
        uint32 cellx = GObj->GetMapMgr()->GetPosX(GObj->m_spawn->x);
        uint32 celly = GObj->GetMapMgr()->GetPosY(GObj->m_spawn->y);

        if(cellx < _sizeX && celly < _sizeY)
        {
            foundonmap = false;
            GOSpawnList::iterator itr;
            ASSERT(GObj->GetMapMgr()->GetBaseMap() != NULL)
            CellSpawns *c = GObj->GetMapMgr()->GetBaseMap()->GetSpawnsList(cellx, celly);
            if(c != NULL)
            {
                for(itr = c->GOSpawns.begin(); itr != c->GOSpawns.end(); itr++)
                {
                    if((*itr) == GObj->m_spawn)
                    {
                        foundonmap = true;
                        c->GOSpawns.erase(itr);
                        break;
                    }
                }
            }
        }

        GObj->DeleteFromDB();

        if(foundonmap)
        {
            delete GObj->m_spawn;
            GObj->m_spawn = NULL;
        }
    }
    GObj->Despawn(0, 0); // Deleted through ExpireAndDelete
    GObj = NULLGOB;
    if(foundonmap)
        BlueSystemMessage(m_session, "Deleted selected object and erased it from spawn map.");
    else
        BlueSystemMessage(m_session, "Deleted selected object.");

    m_session->GetPlayer()->m_GM_SelectedGO = NULLGOB;
    return true;
}
Ejemplo n.º 2
0
bool ChatHandler::HandleGODelete(const char *args, WorldSession *m_session)
{
	GameObject *GObj = m_session->GetPlayer()->m_GM_SelectedGO;
	if( !GObj )
	{
		RedSystemMessage(m_session, "No selected GameObject...");
		return true;
	}
	
    if (GObj->m_spawn != NULL && GObj->m_spawn->entry == GObj->GetEntry())
    {
        uint32 cellx = uint32(((_maxX - GObj->m_spawn->x) / _cellSize));
        uint32 celly = uint32(((_maxY - GObj->m_spawn->y) / _cellSize));

        if (cellx < _sizeX && celly < _sizeY)
        {
            CellSpawns* sp = GObj->GetMapMgr()->GetBaseMap()->GetSpawnsList(cellx, celly);
            if (sp != NULL)
            {
                for (GOSpawnList::iterator itr = sp->GOSpawns.begin(); itr != sp->GOSpawns.end(); ++itr)
                    if ((*itr) == GObj->m_spawn)
                    {
                        sp->GOSpawns.erase(itr);
                        break;
                    }
            }
            GObj->DeleteFromDB();
            delete GObj->m_spawn;
            GObj->m_spawn = NULL;
        }
    }

	GObj->DeleteFromDB();
	GObj->Despawn(0);
	
	delete GObj;

	m_session->GetPlayer()->m_GM_SelectedGO = 0;
  /*  std::stringstream sstext;

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

	GObj->GetMapMgr()->GetBaseMap()->GetTemplate()->RemoveIndex<GameObject>(GObj);	// remove index
	GObj->Despawn(3600000);
	GObj->DeleteFromDB();
	sObjHolder.Delete<GameObject>(GObj);

	m_session->GetPlayer()->m_GM_SelectedGO = NULL;

	GreenSystemMessage(m_session, "GameObject successfully deleted from world and database !");
*/
	return true;
}
Ejemplo n.º 3
0
bool ChatHandler::HandleGODelete(const char *args, WorldSession *m_session)
{
	GameObject *GObj = m_session->GetPlayer()->GetSelectedGo();
	if( !GObj )
	{
		RedSystemMessage(m_session, "No selected GameObject...");
		return true;
	}

	if(GObj->m_spawn != 0 && GObj->m_spawn->entry == GObj->GetEntry())
	{
		uint32 cellx=float2int32(((_maxX-GObj->m_spawn->x)/_cellSize));
		uint32 celly=float2int32(((_maxY-GObj->m_spawn->y)/_cellSize));

		if(cellx < _sizeX && celly < _sizeY)
		{
			//m_session->GetPlayer()->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cellx,celly)->GOSpawns.erase(GObj->m_spawn);
			CellSpawns * c = GObj->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cellx, celly);
			for(GOSpawnList::iterator itr = c->GOSpawns.begin(); itr != c->GOSpawns.end(); ++itr)
				if((*itr) == GObj->m_spawn)
				{
					c->GOSpawns.erase(itr);
					break;
				}
			GObj->DeleteFromDB();
			delete GObj->m_spawn;
		}
	}
	GObj->Despawn(0);

	sGMLog.writefromsession( m_session, "deleted gameobject %s, entry %u", GameObjectNameStorage.LookupEntry(GObj->GetEntry())->Name, GObj->GetEntry() );

	delete GObj;

	m_session->GetPlayer()->m_GM_SelectedGO = 0;

  /*  std::stringstream sstext;

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

	GObj->GetMapMgr()->GetBaseMap()->GetTemplate()->RemoveIndex<GameObject>(GObj);	// remove index
	GObj->Despawn(3600000);
	GObj->DeleteFromDB();
	sObjHolder.Delete<GameObject>(GObj);

	m_session->GetPlayer()->m_GM_SelectedGO = NULL;

	GreenSystemMessage(m_session, "GameObject successfully deleted from world and database !");
*/
	return true;
}
Ejemplo n.º 4
0
bool ChatHandler::HandleGODelete(const char *args, WorldSession *m_session)
{
	GameObject *GObj = m_session->GetPlayer()->GetSelectedGo();
	if( GObj == NULL )
	{
		RedSystemMessage(m_session, "No selected GameObject...");
		return true;
	}

	if( GObj->m_spawn != NULL && GObj->m_spawn->entry == GObj->GetEntry() )
	{
		uint32 cellx = uint32(((_maxX-GObj->m_spawn->x)/_cellSize));
		uint32 celly = uint32(((_maxY-GObj->m_spawn->y)/_cellSize));

		if( cellx < _sizeX && celly < _sizeY )
		{
			CellSpawns * sp = GObj->GetMapMgr()->GetBaseMap()->GetSpawnsList( cellx, celly );
			if( sp != NULL )
			{
				for( GOSpawnList::iterator itr = sp->GOSpawns.begin(); itr != sp->GOSpawns.end(); ++itr )
					if( (*itr) == GObj->m_spawn )
					{
						sp->GOSpawns.erase( itr );
						break;
					}
			}
			GObj->DeleteFromDB();
			delete GObj->m_spawn;
			GObj->m_spawn = NULL;
		}
	}
	GObj->Despawn(0, 0); // We do not need to delete the object because GameObject::Despawn with no time => ExpireAndDelete() => _Expire() => delete GObj;
	sGMLog.writefromsession(m_session,"deleted game object entry %u on map %u at X:%f Y:%f Z:%f Name %s", GObj->GetEntry(),GObj->GetMapId(),GObj->GetPositionX(),GObj->GetPositionY(),GObj->GetPositionZ(),GameObjectNameStorage.LookupEntry(GObj->GetEntry())->Name);

	m_session->GetPlayer()->m_GM_SelectedGO = 0;

  /*  std::stringstream sstext;

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

	GObj->GetMapMgr()->GetBaseMap()->GetTemplate()->RemoveIndex<GameObject>(GObj);	// remove index
	GObj->Despawn(3600000);
	GObj->DeleteFromDB();
	sObjHolder.Delete<GameObject>(GObj);

	m_session->GetPlayer()->m_GM_SelectedGO = NULL;

	GreenSystemMessage(m_session, "GameObject successfully deleted from world and database !");
*/
	return true;
}
Ejemplo n.º 5
0
bool ChatHandler::HandleGODelete(const char* args, WorldSession* m_session)
{
	GameObject* GObj = m_session->GetPlayer()->GetSelectedGo();
	if(!GObj)
	{
		RedSystemMessage(m_session, "No selected GameObject...");
		return false;
	}

	if(GObj->IsInBg())
	{
		RedSystemMessage(m_session, "GameObjects can't be deleted in Battlegrounds");
		return false;
	}

	if(GObj->m_spawn && GObj->m_spawn->entry == GObj->GetEntry())
	{
		uint32 cellx = uint32(((_maxX - GObj->m_spawn->x) / _cellSize));
		uint32 celly = uint32(((_maxY - GObj->m_spawn->y) / _cellSize));

		if(cellx < _sizeX && celly < _sizeY)
		{
			CellSpawns* sp = GObj->GetMapMgr()->GetBaseMap()->GetSpawnsList(cellx, celly);
			if(sp)
			{
				for(GOSpawnList::iterator itr = sp->GOSpawns.begin(); itr != sp->GOSpawns.end(); ++itr)
				{
					if((*itr) == GObj->m_spawn)
					{
						sp->GOSpawns.erase(itr);
						break;
					}
				}
			}
			GObj->DeleteFromDB();
			delete GObj->m_spawn;
			GObj->m_spawn = NULL;
		}
	}
	sGMLog.writefromsession(m_session, "deleted game object entry %u on map %u at X:%f Y:%f Z:%f Name %s", GObj->GetEntry(), GObj->GetMapId(), GObj->GetPositionX(), GObj->GetPositionY(), GObj->GetPositionZ(), GameObjectNameStorage.LookupEntry(GObj->GetEntry())->Name);
	GObj->Despawn(0, 0); // We do not need to delete the object because GameObject::Despawn with no time => ExpireAndDelete() => _Expire() => delete GObj;

	m_session->GetPlayer()->m_GM_SelectedGO = 0;

	return true;
}
Ejemplo n.º 6
0
bool ChatHandler::HandleGODelete(const char *args, WorldSession *m_session)
{
	GameObject* GObj = m_session->GetPlayer()->m_GM_SelectedGO;
	if( !GObj )
	{
		RedSystemMessage(m_session, "No selected GameObject...");
		return true;
	}

	if(GObj->m_spawn != 0 && GObj->m_spawn->entry == GObj->GetEntry())
	{
		uint32 cellx=float2int32(((_maxX-GObj->m_spawn->x)/_cellSize));
		uint32 celly=float2int32(((_maxY-GObj->m_spawn->y)/_cellSize));

		GObj->DeleteFromDB();

		if(cellx < _sizeX && celly < _sizeY)
		{
			CellSpawns * c = GObj->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cellx, celly);
			GOSpawnList::iterator itr,itr2;
			for(itr = c->GOSpawns.begin(); itr != c->GOSpawns.end();)
			{
				itr2 = itr;
				itr++;
				if((*itr2) == GObj->m_spawn)
				{
					c->GOSpawns.erase(itr2);
					break;
				}
			}
			delete GObj->m_spawn;
			GObj->m_spawn = NULL;
		}
	}
	GObj->Despawn(0);
	GObj->Destructor();
	GObj = NULL;

	m_session->GetPlayer()->m_GM_SelectedGO = NULL;
	return true;
}
Ejemplo n.º 7
0
void GameObject::UseFishingNode(Player *player)
{
	sEventMgr.RemoveEvents( this );
	if( GetUInt32Value( GAMEOBJECT_FLAGS ) != 32 ) // Clicking on the bobber before something is hooked
	{
		player->GetSession()->OutPacket( SMSG_FISH_NOT_HOOKED );
		EndFishing( player, true );
		return;
	}
	
	/* Unused code: sAreaStore.LookupEntry(GetMapMgr()->GetAreaID(GetPositionX(),GetPositionY()))->ZoneId*/
	uint32 zone = player->GetAreaID();
	if( zone == 0 ) // If the player's area ID is 0, use the zone ID instead
		zone = player->GetZoneId();

	FishingZoneEntry *entry = FishingZoneStorage.LookupEntry( zone );
	if( entry == NULL ) // No fishing information found for area or zone, log an error, and end fishing
	{
		sLog.outError( "ERROR: Fishing zone information for zone %d not found!", zone );
		EndFishing( player, true );
		return;
	}
	uint32 maxskill = entry->MaxSkill;
	uint32 minskill = entry->MinSkill;

	if( player->_GetSkillLineCurrent( SKILL_FISHING, false ) < maxskill )	
		player->_AdvanceSkillLine( SKILL_FISHING, float2int32( 1.0f * sWorld.getRate( RATE_SKILLRATE ) ) );

	GameObject * school = NULL;
	this->AquireInrangeLock(); //make sure to release lock before exit function !
	for ( InRangeSet::iterator it = GetInRangeSetBegin(); it != GetInRangeSetEnd(); ++it )
	{
		if ( (*it) == NULL || (*it)->GetTypeId() != TYPEID_GAMEOBJECT || (*it)->GetUInt32Value(GAMEOBJECT_TYPE_ID) != GAMEOBJECT_TYPE_FISHINGHOLE)
			continue;
		school = static_cast<GameObject *>( *it );
		if ( !isInRange( school, (float)school->GetInfo()->sound1 ) )
		{
			school = NULL;
			continue;
		}
		else
			break;
	}
	this->ReleaseInrangeLock();

	if ( school != NULL ) // open school loot if school exists
	{
		lootmgr.FillGOLoot( &school->loot, school->GetEntry(), school->GetMapMgr() ? ( school->GetMapMgr()->iInstanceMode ? true : false ) : false );
		player->SendLoot( school->GetGUID(), LOOT_FISHING );
		EndFishing( player, false );
		school->CatchFish();
		if ( !school->CanFish() )
			sEventMgr.AddEvent( school, &GameObject::Despawn, ( 1800000 + RandomUInt( 3600000 ) ), EVENT_GAMEOBJECT_EXPIRE, 10000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT ); // respawn in 30 - 90 minutes
	}
	else if( Rand( ( ( player->_GetSkillLineCurrent( SKILL_FISHING, true ) - minskill ) * 100 ) / maxskill ) ) // Open loot on success, otherwise FISH_ESCAPED.
	{
		lootmgr.FillFishingLoot( &loot, zone );
		player->SendLoot( GetGUID(), LOOT_FISHING );
		EndFishing( player, false );
	}
	else // Failed
	{
		player->GetSession()->OutPacket( SMSG_FISH_ESCAPED );
		EndFishing( player, true );
	}

}