示例#1
0
uint8 AcctContainer::GetNumChar(uint32 realmid, uint32 accid)
{
    CharactersList::const_iterator itr = m_realmcharacters.find(MAKE_PAIR64(accid,realmid));
    if(itr != m_realmcharacters.end())
        return itr->second;

    return 0;
}
示例#2
0
uint32 GarrisonMgr::GetGarrBuildingPlotInst(uint32 garrBuildingId, uint32 garrSiteLevelPlotInstId) const
{
    auto itr = _garrisonBuildingPlotInstances.find(MAKE_PAIR64(garrBuildingId, garrSiteLevelPlotInstId));
    if (itr != _garrisonBuildingPlotInstances.end())
        return itr->second;

    return 0;
}
示例#3
0
void WorldSession::SendBattlenetResponse(uint32 serviceHash, uint32 methodId, uint32 token, uint32 status)
{
    WorldPackets::Battlenet::Response bnetResponse;
    bnetResponse.BnetStatus = BattlenetRpcErrorCode(status);
    bnetResponse.Method.Type = MAKE_PAIR64(methodId, serviceHash);
    bnetResponse.Method.ObjectId = 1;
    bnetResponse.Method.Token = token;

    SendPacket(bnetResponse.Write());
}
示例#4
0
void WorldSession::SendBattlenetRequest(uint32 serviceHash, uint32 methodId, pb::Message const* request)
{
    WorldPackets::Battlenet::Notification notification;
    notification.Method.Type = MAKE_PAIR64(methodId, serviceHash);
    notification.Method.ObjectId = 1;
    notification.Method.Token = _battlenetRequestToken++;

    if (request->ByteSize())
    {
        notification.Data.resize(request->ByteSize());
        request->SerializePartialToArray(notification.Data.contents(), request->ByteSize());
    }

    SendPacket(notification.Write());
}
示例#5
0
void WorldSession::SendBattlenetResponse(uint32 serviceHash, uint32 methodId, uint32 token, pb::Message const* response)
{
    WorldPackets::Battlenet::Response bnetResponse;
    bnetResponse.BnetStatus = ERROR_OK;
    bnetResponse.Method.Type = MAKE_PAIR64(methodId, serviceHash);
    bnetResponse.Method.ObjectId = 1;
    bnetResponse.Method.Token = token;

    if (response->ByteSize())
    {
        bnetResponse.Data.resize(response->ByteSize());
        response->SerializePartialToArray(bnetResponse.Data.contents(), response->ByteSize());
    }

    SendPacket(bnetResponse.Write());
}
示例#6
0
void GarrisonMgr::Initialize()
{
    for (GarrSiteLevelPlotInstEntry const* plotInstance : sGarrSiteLevelPlotInstStore)
        _garrisonPlotInstBySiteLevel[plotInstance->GarrSiteLevelID].push_back(plotInstance);

    for (GameObjectsEntry const* gameObject : sGameObjectsStore)
        if (gameObject->Type == GAMEOBJECT_TYPE_GARRISON_PLOT)
            _garrisonPlots[gameObject->MapID][gameObject->Data[0]] = gameObject;

    for (GarrPlotBuildingEntry const* plotBuilding : sGarrPlotBuildingStore)
        _garrisonBuildingsByPlot[plotBuilding->GarrPlotID].insert(plotBuilding->GarrBuildingID);

    for (GarrBuildingPlotInstEntry const* buildingPlotInst : sGarrBuildingPlotInstStore)
        _garrisonBuildingPlotInstances[MAKE_PAIR64(buildingPlotInst->GarrBuildingID, buildingPlotInst->GarrSiteLevelPlotInstID)] = buildingPlotInst->ID;

    for (GarrBuildingEntry const* building : sGarrBuildingStore)
        _garrisonBuildingsByType[building->Type].push_back(building);

    for (GarrFollowerXAbilityEntry const* followerAbility : sGarrFollowerXAbilityStore)
    {
        if (GarrAbilityEntry const* ability = sGarrAbilityStore.LookupEntry(followerAbility->GarrAbilityID))
        {
            if (ability->FollowerTypeID != FOLLOWER_TYPE_GARRISON)
                continue;

            if (!(ability->Flags & GARRISON_ABILITY_CANNOT_ROLL) && ability->Flags & GARRISON_ABILITY_FLAG_TRAIT)
                _garrisonFollowerRandomTraits.insert(ability);

            if (followerAbility->FactionIndex < 2)
            {
                if (ability->Flags & GARRISON_ABILITY_FLAG_TRAIT)
                    _garrisonFollowerAbilities[followerAbility->FactionIndex][followerAbility->GarrFollowerID].Traits.insert(ability);
                else
                    _garrisonFollowerAbilities[followerAbility->FactionIndex][followerAbility->GarrFollowerID].Counters.insert(ability);
            }
        }
    }

    InitializeDbIdSequences();
    LoadPlotFinalizeGOInfo();
    LoadFollowerClassSpecAbilities();
}
示例#7
0
void InstanceSaveManager::SetResetTimeFor(uint32 mapid, Difficulty d, time_t t)
{
    ResetTimeByMapDifficultyMap::iterator itr = m_resetTimeByMapDifficulty.find(MAKE_PAIR64(mapid, d));
    ASSERT(itr != m_resetTimeByMapDifficulty.end());
    itr->second = t;
}
示例#8
0
void AcctContainer::LoadAll()
{
    // Load accounts
    QueryResult* result = dbRealmServer.PQuery("SELECT id,username,sha_pass_hash,gmlevel,last_ip,locked,expansion,locale FROM account ORDER BY id");
    uint32 count = 0;

    if(!result)
        return;

    //temp set for banned accid to avoid many sql querys
    std::set<uint32> BannedAcc;

    QueryResult* banresult = dbRealmServer.PQuery("SELECT id FROM account_banned WHERE active = 1");
    if(banresult)
    {
        do
        {
            Field *fields = banresult->Fetch();

            //check exist if exist skip;
            if (BannedAcc.find(fields[0].GetUInt32()) != BannedAcc.end())
                continue;
            BannedAcc.insert(fields[0].GetUInt32());

        } while (banresult->NextRow());

        delete banresult;
    }

    sLog.outString("Loading Accounts In Progress...");
    barGoLink bar( result->GetRowCount());

    // Periodic Database Update ...
    dbRealmServer.PExecute("UPDATE account_banned SET active = 0 WHERE unbandate <= UNIX_TIMESTAMP() AND unbandate <> bandate");
    dbRealmServer.PExecute("DELETE FROM ip_banned WHERE unbandate <= UNIX_TIMESTAMP() AND unbandate <> bandate");

    Account *acc;
    do
    {
        Field *fields = result->Fetch();

        bar.step();

        // Create the account by id
        acc = new Account();
        bool banned = false;
        if (BannedAcc.find(fields[0].GetUInt32()) != BannedAcc.end())
            banned = true;

        FillAccount(acc, fields[0].GetUInt32(), fields[3].GetUInt8(), fields[7].GetUInt8(), fields[6].GetUInt8(), banned, fields[5].GetUInt8(), fields[2].GetCppString(), fields[4].GetCppString());
        m_accounts[fields[1].GetCppString()] = acc;
        count++;

    } while (result->NextRow());

    sLog.outString();
    sLog.outString(">> Loaded %u accounts", count);

    //clean up set
    BannedAcc.clear();

    delete result;

    // Now load ip bans

    result = dbRealmServer.PQuery("SELECT ip FROM ip_banned");

    // If there is no ban don't load
    if(result)
    {
        sLog.outString();
        count = 0;

        sLog.outString("Loading Ban Ip In Progress...");

        barGoLink bar( result->GetRowCount());

        do
        {
            Field *fields = result->Fetch();
            bar.step();

            m_banips.insert(fields[0].GetCppString());
            count++;

        }while (result->NextRow());

        delete result;
        sLog.outString();

        sLog.outString(">> Loaded %u ip banned", count);

        count = 0;
    }

    // Now load Realm Characters

    result = dbRealmServer.PQuery("SELECT acctid, realmid, numchars FROM realmcharacters ORDER BY acctid");

    // If there is no ban don't load
    if(result)
    {
        sLog.outString();

        count = 0;

        sLog.outString("Loading Realm Characters In Progress...");

        barGoLink bar( result->GetRowCount());

        do
        {
            Field *fields = result->Fetch();

            bar.step();

            m_realmcharacters[MAKE_PAIR64(fields[0].GetUInt32(),fields[1].GetUInt32())] = fields[2].GetUInt8();
            count++;

        }while (result->NextRow());

        delete result;

        sLog.outString();

        sLog.outString(">> Loaded %u realm characters", count);
    }

}