AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
{
    QueryResult_AutoPtr result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid);
    if (!result)
        return AOR_NAME_NOT_EXIST;                          // account doesn't exist

    // existed characters list
    result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE account='%d'",accid);
    if (result)
    {
        do
        {
            Field *fields = result->Fetch();
            uint32 guidlo = fields[0].GetUInt32();
            uint64 guid = MAKE_NEW_GUID(guidlo, 0, HIGHGUID_PLAYER);

            // kick if player currently
            if (Player* p = ObjectAccessor::GetObjectInWorld(guid, (Player*)NULL))
            {
                WorldSession* s = p->GetSession();
                s->KickPlayer();                            // mark session to remove at next session list update
                s->LogoutPlayer(false);                     // logout player without waiting next session list update
            }

            Player::DeleteFromDB(guid, accid, false);       // no need to update realm characters
        } while (result->NextRow());
    }

    // table realm specific but common for all characters of account for realm
    CharacterDatabase.PExecute("DELETE FROM character_tutorial WHERE account = '%u'",accid);

    LoginDatabase.BeginTransaction();

    bool res =
        LoginDatabase.PExecute("DELETE FROM account WHERE id='%d'", accid) &&
        LoginDatabase.PExecute("DELETE FROM account_access WHERE id ='%d'", accid) &&
        LoginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid='%d'", accid);

    LoginDatabase.CommitTransaction();

    if (!res)
        return AOR_DB_INTERNAL_ERROR;                       // unexpected error;

    return AOR_OK;
}
Exemple #2
0
AccountOpResult DeleteAccount(uint32 accountId)
{
    QueryResult result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accountId);
    if (!result)
        return AOR_NAME_NOT_EXIST;                          // account doesn't exist

    // existed characters list
    result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE account='%d'", accountId);
    if (result)
    {
        do
        {
            uint32 guidLow = (*result)[0].GetUInt32();
            uint64 guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);

            // kick if player is online
            if (Player* p = ObjectAccessor::FindPlayer(guid))
            {
                WorldSession* s = p->GetSession();
                s->KickPlayer();                            // mark session to remove at next session list update
                s->LogoutPlayer(false);                     // logout player without waiting next session list update
            }

            Player::DeleteFromDB(guid, accountId, false);       // no need to update realm characters
        } while (result->NextRow());
    }

    // table realm specific but common for all characters of account for realm
    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_TUTORIALS);
    stmt->setUInt32(0, accountId);
    CharacterDatabase.Execute(stmt);
    stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ACCOUNT_DATA);
    stmt->setUInt32(0, accountId);
    CharacterDatabase.Execute(stmt);

    SQLTransaction trans = LoginDatabase.BeginTransaction();

    trans->PAppend("DELETE FROM account WHERE id='%d'", accountId);
    trans->PAppend("DELETE FROM account_access WHERE id ='%d'", accountId);
    trans->PAppend("DELETE FROM realmcharacters WHERE acctid='%d'", accountId);

    LoginDatabase.CommitTransaction(trans);

    return AOR_OK;
}
Exemple #3
0
int AccountMgr::DeleteAccount(uint32 accid)
{
    QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid);
    if(!result)
        return 1;                                           // account doesn't exist
    delete result;

    result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE account='%d'",accid);
    if (result)
    {
        do
        {
            Field *fields = result->Fetch();
            uint32 guidlo = fields[0].GetUInt32();
            uint64 guid = MAKE_GUID(guidlo, HIGHGUID_PLAYER);

            // kick if player currently
            if(Player* p = objmgr.GetPlayer(guid))
            {
                WorldSession* s = p->GetSession();
                s->KickPlayer();                            // mark session to remove at next session list update
                s->LogoutPlayer(false);                     // logout player without waiting next session list update
            }

            Player::DeleteFromDB(guid, accid, false);       // no need to update realm characters
        } while (result->NextRow());

        delete result;
    }

    loginDatabase.BeginTransaction();

    bool res =  loginDatabase.PExecute("DELETE FROM account WHERE id='%d'", accid) &&
        loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid='%d'", accid);

    loginDatabase.CommitTransaction();

    if(!res)
        return -1;                                          // unexpected error;

    return 0;
}
Exemple #4
0
AccountOpResult DeleteAccount(uint32 accountId)
{
    // Check if accounts exists
    PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_ID);
    stmt->setUInt32(0, accountId);
    PreparedQueryResult result = LoginDatabase.Query(stmt);

    if (!result)
        return AOR_NAME_NOT_EXIST;

    // Obtain accounts characters
    stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID);

    stmt->setUInt32(0, accountId);

    result = CharacterDatabase.Query(stmt);

    if (result)
    {
        do
        {
            uint32 guidLow = (*result)[0].GetUInt32();
            uint64 guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);

            // Kick if player is online
            if (Player* p = ObjectAccessor::FindPlayer(guid))
            {
                WorldSession* s = p->GetSession();
                s->KickPlayer();                            // mark session to remove at next session list update
                s->LogoutPlayer(false);                     // logout player without waiting next session list update
            }

            Player::DeleteFromDB(guid, accountId, false);       // no need to update realm characters
        } while (result->NextRow());
    }

    // table realm specific but common for all characters of account for realm
    stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_TUTORIALS);
    stmt->setUInt32(0, accountId);
    CharacterDatabase.Execute(stmt);

    stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ACCOUNT_DATA);
    stmt->setUInt32(0, accountId);
    CharacterDatabase.Execute(stmt);

    stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_BAN);
    stmt->setUInt32(0, accountId);
    CharacterDatabase.Execute(stmt);

    SQLTransaction trans = LoginDatabase.BeginTransaction();

    stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT);
    stmt->setUInt32(0, accountId);
    trans->Append(stmt);

    stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS);
    stmt->setUInt32(0, accountId);
    trans->Append(stmt);

    stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS);
    stmt->setUInt32(0, accountId);
    trans->Append(stmt);

    stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_BANNED);
    stmt->setUInt32(0, accountId);
    trans->Append(stmt);

    LoginDatabase.CommitTransaction(trans);

    return AOR_OK;
}
Exemple #5
0
void AnticheatMgr::SpeedHackDetection(Player* player,MovementInfo movementInfo)
{
    if ((sWorld->getIntConfig(CONFIG_ANTICHEAT_DETECTIONS_ENABLED) & SPEED_HACK_DETECTION) == 0)
        return;

    uint32 key = player->GetGUIDLow();
		
    // We also must check the map because the movementFlag can be modified by the client.
    // If we just check the flag, they could always add that flag and always skip the speed hacking detection.
    // 369 == DEEPRUN TRAM
	// 607 == Strand of The Ancients
    if (m_Players[key].GetLastMovementInfo().HasMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY) && (player->GetMapId() == 369 || player->GetMapId() == 607))
        return;

	if (player->GetSession()->GetSecurity() > 0)
	    return;

	if (!player->isAlive())
	    return;

    uint32 distance2D = (uint32)movementInfo.pos.GetExactDist2d(&m_Players[key].GetLastMovementInfo().pos);

	if (distance2D > 500)
	    return;

	if (distance2D < 100 && player->getClass() == CLASS_PRIEST && player->isInCombat())
	    return;

	if (player->GetAreaId() == 4281 || player->GetAreaId() == 4342 || player->GetAreaId() == 5154 || player->GetAreaId() == 4395 ||
	player->GetAreaId() == 5926 || player->GetAreaId() == 5738 || player->GetAreaId() == 5535 || player->GetAreaId() == 5004 ||
	player->GetAreaId() == 5088 || player->GetAreaId() == 5303 || player->GetAreaId() == 4753 || player->GetAreaId() == 4752)
	    return;

	if (player->HasAura(66601))
	    return;

	if (player->HasAura(66602))
	{
	    player->RemoveAura(66602);
	}

	if (player->HasAura(605))
	    return;

	if (player->HasAura(51690))
	{
	    player->CastSpell(player, 66601, true);
	    return;
	}

    float x, y, z;
    player->GetPosition(x, y, z);
    float ground_Z = player->GetMap()->GetHeight(x, y, z);
    float z_diff = fabs(ground_Z - z);	
	WorldSession* s = player->GetSession();
	if ( player->GetMap()->IsDungeon() || player->GetMap()->IsRaid() || player->GetMap()->IsBattlegroundOrArena())
	    if ((distance2D > 50 && player->GetMapId() == 566) || (distance2D > 40 && player->GetMapId() != 566))
	        if (z_diff > 1.0f && !player->isGameMaster())
	            if (!player->HasUnitMovementFlag(MOVEMENTFLAG_FALLING) && player->isAlive())
		            s->KickPlayer("Player::Update");			

	if ((player->GetMap()->IsDungeon() || player->GetMap()->IsRaid() || player->GetMap()->IsBattlegroundOrArena() || player->GetMapId() == 732 || player->GetMapId() == 861) && (player->HasAura(33943) || player->HasAura(40120)))
	{
	    player->RemoveAura(33943);
		player->RemoveAura(40120);
	}

    uint8 moveType = 0;
	uint32 maxSpeed = 0;

    // we need to know HOW is the player moving
    // TO-DO: Should we check the incoming movement flags?
    if (player->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING))
    {
        moveType = MOVE_SWIM;
        maxSpeed = 11;
        if (player->HasAura(8326) || player->HasAura(20584)) //Ghost
            maxSpeed += 5;

        if (player->HasAura(86510)) //Epic Swimming Mount
            maxSpeed += 20;

        if (player->HasAura(95664)) //Advanced Swimming Mount
            maxSpeed += 15;

        if (player->HasAura(73701)) //Sea Legs
            maxSpeed += 5;

        if (player->HasAura(98718)) //Subdued Seahorse
            maxSpeed = 41;

        if (player->HasAura(75207)) //Abyssal Seahorse
            maxSpeed = 56;
    }
    else if (player->IsFlying() && player->HasAuraType(SPELL_AURA_MOUNTED))
    {
        moveType = MOVE_FLIGHT;

        if (player->HasSpell(90265)) //master riding
            maxSpeed = 40;
        else if (player->HasSpell(34091)) //artisan riding
            maxSpeed = 33;
        else if (player->HasSpell(34090))
            maxSpeed = 20;

        //extra checks
        if (maxSpeed < 25)
        {
            if (player->HasAura(86459)) //Mount Speed Mod: Standard Flying Mount
                maxSpeed = 36;

            if (player->HasAura(86460)) //Mount Speed Mod: Epic Flying Mount
                maxSpeed = 49;
        }

        if (player->HasAura(32223)) //Crusader Aura
            maxSpeed += 9;

        if (player->HasAura(51983)) //On a Pale Horse Rank 1
            maxSpeed += 5;
        if (player->HasAura(51986)) //On a Pale Horse Rank 2
            maxSpeed += 9;
        
        if (player->HasAura(26023) || player->HasAura(26022)) //Pursuit of Justice
            maxSpeed += 19;
    }
 	else if (player->IsFlying() && !player->HasAuraType(SPELL_AURA_MOUNTED))
	{
	    maxSpeed = 1;

        if (player->HasAura(98619)) //Wings of Flame
            maxSpeed += 11;

        if (player->HasAura(33943)) //Flight Form
            maxSpeed += 20;

        if (player->HasAura(40120)) //Swift Flight Form
            maxSpeed += 35;
			
        if (player->HasAura(59640)) //Underbelly Elixir
            maxSpeed += 20;			
	}
    else if (player->HasAuraType(SPELL_AURA_MOUNTED))
    {
        if (player->HasSpell(33391)) //journeyman riding
            maxSpeed = 25;
        else if (player->HasSpell(33388)) //apprentice riding
            maxSpeed = 21;

        //extra checks
        if (maxSpeed < 17)
        {
            if (player->HasAura(86458)) //Mount Speed Mod: Epic Ground Mount
                maxSpeed = 21;

            if (player->HasAura(86457)) //Mount Speed Mod: Standard Ground Mount
                maxSpeed = 17;
        }

        if (player->HasAura(32223)) //Crusader Aura
            maxSpeed += 5;

        if (player->HasAura(51983)) //On a Pale Horse Rank 1
            maxSpeed += 3;
        if (player->HasAura(51986)) //On a Pale Horse Rank 2
            maxSpeed += 5;
        
        if (player->HasAura(26023) || player->HasAura(26022)) //Pursuit of Justice
            maxSpeed += 5;			
    }
    else if (player->HasUnitMovementFlag(MOVEMENTFLAG_WALKING))
    {
        moveType = MOVE_WALK;
        maxSpeed = 6;
    }
    else
    {
        moveType = MOVE_RUN;
        maxSpeed = 16;
			
		if (z_diff > 1.0f)
		    maxSpeed = 40;
		
        if (player->HasAura(33943)) //Flight Form
            maxSpeed += 20;

        if (player->HasAura(40120)) //Swift Flight Form
            maxSpeed += 33;

        if (player->HasAura(8326) || player->HasAura(20584)) //Ghost
            maxSpeed += 5;

        if (player->HasAura(26023) || player->HasAura(26022)) //Pursuit of Justice
            maxSpeed += 5;

        if (player->HasAura(51721) || player->HasAura(54055)) //Dominion over Acherus
            maxSpeed += 8;

        if (player->HasAura(48265)) //Unholy Presence
            maxSpeed += 2;

        if (player->HasAura(23451) || player->HasAura(23978)) //Speed
            maxSpeed += 10;

        if (player->HasAura(68992)) //Dark flight
            maxSpeed += 4;

        if (player->HasAura(2983) || player->HasAura(1850)) //Sprint, Dash
            maxSpeed += 7;
			
        if (player->HasAura(36554)) //Shadowstep
            maxSpeed += 8;			
    }
    
    if (player->HasUnitMovementFlag(MOVEMENTFLAG_FALLING))
    {
        maxSpeed = 60;
    }
			
    // how many yards the player can do in one sec.

    // how long the player took to move to here.
    uint32 timeDiff = getMSTimeDiff(m_Players[key].GetLastMovementInfo().time,movementInfo.time);
			
    if (!timeDiff)
        timeDiff = 1;
		
    // this is the distance doable by the player in 1 sec, using the time done to move to this point.
    uint32 clientSpeedRate = distance2D * 1000 / timeDiff;

    // we did the (uint32) cast to accept a margin of tolerance
    if (clientSpeedRate > maxSpeed)
    {
		WorldSession* s = player->GetSession();
	    s->KickPlayer("AnticheatMgr::SpeedHackDetection");
        //BuildReport(player,SPEED_HACK_REPORT);
        sLog->outInfo(LOG_FILTER_CHARACTER, "AnticheatMgr:: Speed-Hack detected player GUID (low) %u",player->GetGUIDLow());
    }				
}