您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ DETAIL_LOG函数代码示例

51自学网 2021-06-01 20:21:02
  C++
这篇教程C++ DETAIL_LOG函数代码示例写得很实用,希望能帮到您。

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

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

示例1: main

//.........这里部分代码省略.........        return 1;    }#ifndef WIN32                                               // posix daemon commands need apply after config read    switch (serviceDaemonMode)    {        case 'r':            startDaemon();            break;        case 's':            stopDaemon();            break;    }#endif    sLog.Initialize();    sLog.outString("%s [realm-daemon]", _FULLVERSION(REVISION_DATE, REVISION_TIME, REVISION_ID));    sLog.outString("<Ctrl-C> to stop./n");    sLog.outString("Using configuration file %s.", cfg_file);    ///- Check the version of the configuration file    uint32 confVersion = sConfig.GetIntDefault("ConfVersion", 0);    if (confVersion < _REALMDCONFVERSION)    {        sLog.outError("*****************************************************************************");        sLog.outError(" WARNING: Your realmd.conf version indicates your conf file is out of date!");        sLog.outError("          Please check for updates, as your current default values may cause");        sLog.outError("          strange behavior.");        sLog.outError("*****************************************************************************");        Log::WaitBeforeContinueIfNeed();    }    DETAIL_LOG("%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));    if (SSLeay() < 0x009080bfL)    {        DETAIL_LOG("WARNING: Outdated version of OpenSSL lib. Logins to server may not work!");        DETAIL_LOG("WARNING: Minimal required version [OpenSSL 0.9.8k]");    }    DETAIL_LOG("Using ACE: %s", ACE_VERSION);#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)    ACE_Reactor::instance(new ACE_Reactor(new ACE_Dev_Poll_Reactor(ACE::max_handles(), 1), 1), true);#else    ACE_Reactor::instance(new ACE_Reactor(new ACE_TP_Reactor(), true), true);#endif    sLog.outBasic("Max allowed open files is %d", ACE::max_handles());    /// realmd PID file creation    std::string pidfile = sConfig.GetStringDefault("PidFile", "");    if (!pidfile.empty())    {        uint32 pid = CreatePIDFile(pidfile);        if (!pid)        {            sLog.outError("Cannot create PID file %s./n", pidfile.c_str());            Log::WaitBeforeContinueIfNeed();            return 1;        }        sLog.outString("Daemon PID: %u/n", pid);    }    ///- Initialize the database connection
开发者ID:AlexHjelm,项目名称:Core,代码行数:67,


示例2: guard

//.........这里部分代码省略.........                        m_playerRecentlyLogout = false;                    ExecuteOpcode(opHandle, *packet);                    break;                case STATUS_NEVER:                    sLog.outError("SESSION: received not allowed opcode %s (0x%.4X)",                                  packet->GetOpcodeName(),                                  packet->GetOpcode());                    break;                case STATUS_UNHANDLED:                    DEBUG_LOG("SESSION: received not handled opcode %s (0x%.4X)",                              packet->GetOpcodeName(),                              packet->GetOpcode());                    break;                default:                    sLog.outError("SESSION: received wrong-status-req opcode %s (0x%.4X)",                                  packet->GetOpcodeName(),                                  packet->GetOpcode());                    break;            }        }        catch (ByteBufferException&)        {            sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.",                          packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());            if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))            {                DEBUG_LOG("Dumping error causing packet:");                packet->hexlike();            }            if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET))            {                DETAIL_LOG("Disconnecting session [account id %u / address %s] for badly formatted packet.",                           GetAccountId(), GetRemoteAddress().c_str());                KickPlayer();            }        }    }#ifdef BUILD_PLAYERBOT    // Process player bot packets    // The PlayerbotAI class adds to the packet queue to simulate a real player    // since Playerbots are known to the World obj only by its master's WorldSession object    // we need to process all master's bot's packets.    if (GetPlayer() && GetPlayer()->GetPlayerbotMgr())    {        for (PlayerBotMap::const_iterator itr = GetPlayer()->GetPlayerbotMgr()->GetPlayerBotsBegin();                itr != GetPlayer()->GetPlayerbotMgr()->GetPlayerBotsEnd(); ++itr)        {            Player* const botPlayer = itr->second;            WorldSession* const pBotWorldSession = botPlayer->GetSession();            if (botPlayer->IsBeingTeleported())                botPlayer->GetPlayerbotAI()->HandleTeleportAck();            else if (botPlayer->IsInWorld())            {                while (!pBotWorldSession->m_recvQueue.empty())                {                    auto const botpacket = std::move(pBotWorldSession->m_recvQueue.front());                    pBotWorldSession->m_recvQueue.pop_front();                    OpcodeHandler const& opHandle = opcodeTable[botpacket->GetOpcode()];                    pBotWorldSession->ExecuteOpcode(opHandle, *botpacket);                };                pBotWorldSession->m_recvQueue.clear();
开发者ID:MantisLord,项目名称:mangos-tbc,代码行数:67,


示例3: GetPlayer

void WorldSession::HandleMoveWorldportAckOpcode(){    // ignore unexpected far teleports    if (!GetPlayer()->IsBeingTeleportedFar())        return;    // get start teleport coordinates (will used later in fail case)    WorldLocation old_loc;    GetPlayer()->GetPosition(old_loc);    // get the teleport destination    WorldLocation& loc = GetPlayer()->GetTeleportDest();    // possible errors in the coordinate validity check (only cheating case possible)    if (!MapManager::IsValidMapCoord(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation))    {        sLog.outError("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far to a not valid location "                      "(map:%u, x:%f, y:%f, z:%f) We port him to his homebind instead..",                      GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);        // stop teleportation else we would try this again and again in LogoutPlayer...        GetPlayer()->SetSemaphoreTeleportFar(false);        // and teleport the player to a valid place        GetPlayer()->TeleportToHomebind();        return;    }    // get the destination map entry, not the current one, this will fix homebind and reset greeting    MapEntry const* mEntry = sMapStore.LookupEntry(loc.mapid);    Map* map = NULL;    // prevent crash at attempt landing to not existed battleground instance    if (mEntry->IsBattleGroundOrArena())    {        if (GetPlayer()->GetBattleGroundId())            map = sMapMgr.FindMap(loc.mapid, GetPlayer()->GetBattleGroundId());        if (!map)        {            DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far to nonexisten battleground instance "                       " (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..",                       GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);            GetPlayer()->SetSemaphoreTeleportFar(false);            // Teleport to previous place, if cannot be ported back TP to homebind place            if (!GetPlayer()->TeleportTo(old_loc))            {                DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s cannot be ported to his previous place, teleporting him to his homebind place...",                           GetPlayer()->GetGuidStr().c_str());                GetPlayer()->TeleportToHomebind();            }            return;        }    }    InstanceTemplate const* mInstance = ObjectMgr::GetInstanceTemplate(loc.mapid);    // reset instance validity, except if going to an instance inside an instance    if (GetPlayer()->m_InstanceValid == false && !mInstance)        GetPlayer()->m_InstanceValid = true;    GetPlayer()->SetSemaphoreTeleportFar(false);    // relocate the player to the teleport destination    if (!map)        map = sMapMgr.CreateMap(loc.mapid, GetPlayer());    GetPlayer()->SetMap(map);    GetPlayer()->Relocate(loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation);    GetPlayer()->SendInitialPacketsBeforeAddToMap();    // the CanEnter checks are done in TeleporTo but conditions may change    // while the player is in transit, for example the map may get full    if (!GetPlayer()->GetMap()->Add(GetPlayer()))    {        // if player wasn't added to map, reset his map pointer!        GetPlayer()->ResetMap();        DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far but couldn't be added to map "                   " (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..",                   GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);        // Teleport to previous place, if cannot be ported back TP to homebind place        if (!GetPlayer()->TeleportTo(old_loc))        {            DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s cannot be ported to his previous place, teleporting him to his homebind place...",                       GetPlayer()->GetGuidStr().c_str());            GetPlayer()->TeleportToHomebind();        }        return;    }    // battleground state prepare (in case join to BG), at relogin/tele player not invited    // only add to bg group and object, if the player was invited (else he entered through command)    if (_player->InBattleGround())    {        // cleanup setting if outdated        if (!mEntry->IsBattleGroundOrArena())        {//.........这里部分代码省略.........
开发者ID:begemot-amp,项目名称:mangos-wotlk,代码行数:101,


示例4: DETAIL_LOG

void WorldSession::HandleNpcTextQueryOpcode(WorldPacket& recv_data){    uint32 textID;    ObjectGuid guid;    recv_data >> textID;    recv_data >> guid;    DETAIL_LOG("WORLD: CMSG_NPC_TEXT_QUERY ID '%u'", textID);    _player->SetTargetGuid(guid);    GossipText const* pGossip = sObjectMgr.GetGossipText(textID);    WorldPacket data(SMSG_NPC_TEXT_UPDATE, 100);            // guess size    data << textID;    if (!pGossip)    {        for (uint32 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)        {            data << float(0);            data << "Greetings $N";            data << "Greetings $N";            data << uint32(0);            data << uint32(0);            data << uint32(0);            data << uint32(0);            data << uint32(0);            data << uint32(0);            data << uint32(0);        }    }    else    {        std::string Text_0[MAX_GOSSIP_TEXT_OPTIONS], Text_1[MAX_GOSSIP_TEXT_OPTIONS];        for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)        {            Text_0[i] = pGossip->Options[i].Text_0;            Text_1[i] = pGossip->Options[i].Text_1;        }        int loc_idx = GetSessionDbLocaleIndex();        sObjectMgr.GetNpcTextLocaleStringsAll(textID, loc_idx, &Text_0, &Text_1);        for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)        {            data << pGossip->Options[i].Probability;            if (Text_0[i].empty())                data << Text_1[i];            else                data << Text_0[i];            if (Text_1[i].empty())                data << Text_0[i];            else                data << Text_1[i];            data << pGossip->Options[i].Language;            for (int j = 0; j < 3; ++j)            {                data << pGossip->Options[i].Emotes[j]._Delay;                data << pGossip->Options[i].Emotes[j]._Emote;            }        }    }    SendPacket(&data);    DEBUG_LOG("WORLD: Sent SMSG_NPC_TEXT_UPDATE");}
开发者ID:AwkwardDev,项目名称:mangos-d3,代码行数:74,


示例5: DETAIL_LOG

void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ){    uint32 textID;    ObjectGuid guid;    recv_data >> textID;    recv_data >> guid;    DETAIL_LOG("WORLD: CMSG_NPC_TEXT_QUERY ID '%u'", textID);    _player->SetTargetGuid(guid);    GossipText const* pGossip = sObjectMgr.GetGossipText(textID);    WorldPacket data( SMSG_NPC_TEXT_UPDATE, 100 );         // guess size    data << textID;    if (!pGossip)    {        // multi-language support        std::string Text_0[8],Text_1[8];        int loc_idx = GetSessionDbLocaleIndex();        if (loc_idx >= 0)        {            NpcTextLocale const *nl = sObjectMgr.GetNpcTextLocale(68); // standard text            if (nl)            {                for (int i = 0; i < 8; ++i)                {                    if (nl->Text_0[i].size() > size_t(loc_idx) && !nl->Text_0[i][loc_idx].empty())                        Text_0[i]=nl->Text_0[i][loc_idx];                    if (nl->Text_1[i].size() > size_t(loc_idx) && !nl->Text_1[i][loc_idx].empty())                        Text_1[i]=nl->Text_1[i][loc_idx];                }            }        }        else // no locales        {            for (int i = 0; i < 8; ++i)            {                Text_0[i] = "Greetings, $N";                Text_1[i] = "Greetings, $N";            }        }        for (int i = 0; i < 8; ++i)        {            data << float(0);            if ( Text_0[i].empty() )                data << Text_1[i];            else                data << Text_0[i];            if ( Text_1[i].empty() )                data << Text_0[i];            else                data << Text_1[i];            data << uint32(0);            data << uint32(0);            data << uint32(0);            data << uint32(0);            data << uint32(0);            data << uint32(0);            data << uint32(0);        }    }    else    {        std::string Text_0[8], Text_1[8];        for (int i = 0; i < 8; ++i)        {            Text_0[i]=pGossip->Options[i].Text_0;            Text_1[i]=pGossip->Options[i].Text_1;        }        int loc_idx = GetSessionDbLocaleIndex();        if (loc_idx >= 0)        {            NpcTextLocale const *nl = sObjectMgr.GetNpcTextLocale(textID);            if (nl)            {                for (int i = 0; i < 8; ++i)                {                    if (nl->Text_0[i].size() > size_t(loc_idx) && !nl->Text_0[i][loc_idx].empty())                        Text_0[i]=nl->Text_0[i][loc_idx];                    if (nl->Text_1[i].size() > size_t(loc_idx) && !nl->Text_1[i][loc_idx].empty())                        Text_1[i]=nl->Text_1[i][loc_idx];                }            }        }        for (int i = 0; i < 8; ++i)        {            data << pGossip->Options[i].Probability;            if ( Text_0[i].empty() )                data << Text_1[i];            else//.........这里部分代码省略.........
开发者ID:GlassFace,项目名称:core-1,代码行数:101,


示例6: BLIZZLIKE_ASSERT

int WorldSocket::ProcessIncoming(WorldPacket* new_pct){    BLIZZLIKE_ASSERT(new_pct);    // manage memory ;)    ACE_Auto_Ptr<WorldPacket> aptr(new_pct);    const ACE_UINT16 opcode = new_pct->GetOpcode();    if (opcode >= NUM_MSG_TYPES)    {        sLog.outError("SESSION: received nonexistent opcode 0x%.4X", opcode);        return -1;    }    if (closing_)        return -1;    // Dump received packet.    sLog.outWorldPacketDump(uint32(get_handle()), new_pct->GetOpcode(), new_pct->GetOpcodeName(), new_pct, true);    try    {        switch (opcode)        {            case CMSG_PING:                return HandlePing(*new_pct);            case CMSG_AUTH_SESSION:                if (m_Session)                {                    sLog.outError("WorldSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again");                    return -1;                }                return HandleAuthSession(*new_pct);            case CMSG_KEEP_ALIVE:                DEBUG_LOG("CMSG_KEEP_ALIVE ,size: " SIZEFMTD " ", new_pct->size());                return 0;            default:            {                ACE_GUARD_RETURN(LockType, Guard, m_SessionLock, -1);                if (m_Session != NULL)                {                    // OK ,give the packet to WorldSession                    aptr.release();                    // WARNING here we call it with locks held.                    // Its possible to cause deadlock if QueuePacket calls back                    m_Session->QueuePacket(new_pct);                    return 0;                }                else                {                    sLog.outError("WorldSocket::ProcessIncoming: Client not authed opcode = %u", uint32(opcode));                    return -1;                }            }        }    }    catch (ByteBufferException&)    {        sLog.outError("WorldSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i.",                      opcode, GetRemoteAddress().c_str(), m_Session ? m_Session->GetAccountId() : -1);        if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))        {            DEBUG_LOG("Dumping error-causing packet:");            new_pct->hexlike();        }        if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET))        {            DETAIL_LOG("Disconnecting session [account id %i / address %s] for badly formatted packet.",                       m_Session ? m_Session->GetAccountId() : -1, GetRemoteAddress().c_str());            return -1;        }        else            return 0;    }    ACE_NOTREACHED(return 0);}
开发者ID:madbhr,项目名称:blizzlikecore,代码行数:83,


示例7: GetPlayer

/// Send a packet to the clientvoid WorldSession::SendPacket(WorldPacket const* packet){#ifdef ENABLE_PLAYERBOTS    if (GetPlayer()) {        if (GetPlayer()->GetPlayerbotAI())            GetPlayer()->GetPlayerbotAI()->HandleBotOutgoingPacket(*packet);        else if (GetPlayer()->GetPlayerbotMgr())            GetPlayer()->GetPlayerbotMgr()->HandleMasterOutgoingPacket(*packet);    }#endif    if (!m_Socket)        { return; }    if (opcodeTable[packet->GetOpcode()].status == STATUS_UNHANDLED)    {        sLog.outError("SESSION: tried to send an unhandled opcode 0x%.4X", packet->GetOpcode());        return;    }    const_cast<WorldPacket*>(packet)->FlushBits();#ifdef MANGOS_DEBUG    // Code for network use statistic    static uint64 sendPacketCount = 0;    static uint64 sendPacketBytes = 0;    static time_t firstTime = time(NULL);    static time_t lastTime = firstTime;                     // next 60 secs start time    static uint64 sendLastPacketCount = 0;    static uint64 sendLastPacketBytes = 0;    time_t cur_time = time(NULL);    if ((cur_time - lastTime) < 60)    {        sendPacketCount += 1;        sendPacketBytes += packet->size();        sendLastPacketCount += 1;        sendLastPacketBytes += packet->size();    }    else    {        uint64 minTime = uint64(cur_time - lastTime);        uint64 fullTime = uint64(lastTime - firstTime);        DETAIL_LOG("Send all time packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f time: %u", sendPacketCount, sendPacketBytes, float(sendPacketCount) / fullTime, float(sendPacketBytes) / fullTime, uint32(fullTime));        DETAIL_LOG("Send last min packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f", sendLastPacketCount, sendLastPacketBytes, float(sendLastPacketCount) / minTime, float(sendLastPacketBytes) / minTime);        lastTime = cur_time;        sendLastPacketCount = 1;        sendLastPacketBytes = packet->wpos();               // wpos is real written size    }#endif                                                  // !MANGOS_DEBUG    if (m_Socket->SendPacket(*packet) == -1)        { m_Socket->CloseSocket(); }}
开发者ID:mangosthree,项目名称:server,代码行数:62,


示例8: while

/// Update the WorldSession (triggered by World update)bool WorldSession::Update(PacketFilter& updater){    ///- Retrieve packets from the receive queue and call the appropriate handlers    /// not process packets if socket already closed    WorldPacket* packet = NULL;    while (m_Socket && !m_Socket->IsClosed() && _recvQueue.next(packet, updater))    {        /*#if 1        sLog.outError( "MOEP: %s (0x%.4X)",                        packet->GetOpcodeName(),                        packet->GetOpcode());        #endif*/        OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()];        try        {            switch (opHandle.status)            {                case STATUS_LOGGEDIN:                    if (!_player)                    {                        // skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets                        if (!m_playerRecentlyLogout)                            LogUnexpectedOpcode(packet, "the player has not logged in yet");                    }                    else if (_player->IsInWorld())                        ExecuteOpcode(opHandle, packet);                    // lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer                    break;                case STATUS_LOGGEDIN_OR_RECENTLY_LOGGEDOUT:                    if (!_player && !m_playerRecentlyLogout)                    {                        LogUnexpectedOpcode(packet, "the player has not logged in yet and not recently logout");                    }                    else                        // not expected _player or must checked in packet hanlder                        ExecuteOpcode(opHandle, packet);                    break;                case STATUS_TRANSFER:                    if (!_player)                        LogUnexpectedOpcode(packet, "the player has not logged in yet");                    else if (_player->IsInWorld())                        LogUnexpectedOpcode(packet, "the player is still in world");                    else                        ExecuteOpcode(opHandle, packet);                    break;                case STATUS_AUTHED:                    // prevent cheating with skip queue wait                    if (m_inQueue)                    {                        LogUnexpectedOpcode(packet, "the player not pass queue yet");                        break;                    }                    // single from authed time opcodes send in to after logout time                    // and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.                    if (packet->GetOpcode() != CMSG_SET_ACTIVE_VOICE_CHANNEL)                        m_playerRecentlyLogout = false;                    ExecuteOpcode(opHandle, packet);                    break;                case STATUS_NEVER:                    sLog.outError("SESSION: received not allowed opcode %s (0x%.4X)",                                  packet->GetOpcodeName(),                                  packet->GetOpcode());                    break;                case STATUS_UNHANDLED:                    DEBUG_LOG("SESSION: received not handled opcode %s (0x%.4X)",                              packet->GetOpcodeName(),                              packet->GetOpcode());                    break;                default:                    sLog.outError("SESSION: received wrong-status-req opcode %s (0x%.4X)",                                  packet->GetOpcodeName(),                                  packet->GetOpcode());                    break;            }        }        catch (ByteBufferException&)        {            sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.",                          packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());            if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))            {                DEBUG_LOG("Dumping error causing packet:");                packet->hexlike();            }            if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET))            {                DETAIL_LOG("Disconnecting session [account id %u / address %s] for badly formatted packet.",                           GetAccountId(), GetRemoteAddress().c_str());                KickPlayer();            }        }        delete packet;//.........这里部分代码省略.........
开发者ID:Blutban,项目名称:OneServer,代码行数:101,


示例9: DETAIL_LOG

void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ){    DETAIL_LOG("WORLD: CMSG_PET_CAST_SPELL");    uint64 guid;    uint32 spellid;    uint8  cast_count;    uint8  unk_flags;                                       // flags (if 0x02 - some additional data are received)    recvPacket >> guid >> cast_count >> spellid >> unk_flags;    DEBUG_LOG("WORLD: CMSG_PET_CAST_SPELL, cast_count: %u, spellid %u, unk_flags %u", cast_count, spellid, unk_flags);    if (!_player->GetPet() && !_player->GetCharm())        return;    Creature* pet = _player->GetMap()->GetAnyTypeCreature(guid);    if (!pet || (pet != _player->GetPet() && pet!= _player->GetCharm()))    {        sLog.outError( "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() );        return;    }    if (pet->GetGlobalCooldown() > 0)        return;    SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid);    if (!spellInfo)    {        sLog.outError("WORLD: unknown PET spell id %i", spellid);        return;    }    // do not cast not learned spells    if (!pet->HasSpell(spellid) || IsPassiveSpell(spellInfo))        return;    SpellCastTargets targets;    recvPacket >> targets.ReadForCaster(pet);    pet->clearUnitState(UNIT_STAT_MOVING);    Spell *spell = new Spell(pet, spellInfo, false);    spell->m_cast_count = cast_count;                       // probably pending spell cast    spell->m_targets = targets;    SpellCastResult result = spell->CheckPetCast(NULL);    if (result == SPELL_CAST_OK)    {        pet->AddCreatureSpellCooldown(spellid);        if (pet->isPet())        {            //10% chance to play special pet attack talk, else growl            //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell            if(((Pet*)pet)->getPetType() == SUMMON_PET && (urand(0, 100) < 10))                pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL);            else                pet->SendPetAIReaction(guid);        }        spell->prepare(&(spell->m_targets));    }    else    {        pet->SendPetCastFail(spellid, result);        if (!pet->HasSpellCooldown(spellid))            GetPlayer()->SendClearCooldown(spellid, pet);        spell->finish(false);        delete spell;    }}
开发者ID:Freakstorm,项目名称:mangos,代码行数:74,


示例10: ObjectGuid

/** * Handles the packet sent by the client when he copies the body a mail to his inventory. * * When a player copies the body of a mail to his inventory this method is called. It will create * a new item with the text of the mail and store it in the players inventory (if possible). * */void WorldSession::HandleMailCreateTextItem(WorldPacket& recv_data){    ObjectGuid mailboxGuid;    uint32 mailId;    recv_data >> mailboxGuid;    recv_data >> mailId;    if (!CheckMailBox(mailboxGuid))        return;    Player* pl = _player;    Mail* m = pl->GetMail(mailId);    if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))    {        pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR);        return;    }    Item* bodyItem = new Item;                              // This is not bag and then can be used new Item.    if (!bodyItem->Create(sObjectMgr.GenerateItemLowGuid(), MAIL_BODY_ITEM_TEMPLATE, pl))    {        delete bodyItem;        return;    }    // in mail template case we need create new item text    if (m->mailTemplateId)    {        MailTemplateEntry const* mailTemplateEntry = sMailTemplateStore.LookupEntry(m->mailTemplateId);        if (!mailTemplateEntry)        {            pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR);            return;        }        bodyItem->SetText(mailTemplateEntry->content[GetSessionDbcLocale()]);    }    else        bodyItem->SetText(m->body);    bodyItem->SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid(HIGHGUID_PLAYER, m->sender));    bodyItem->SetFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_READABLE | ITEM_DYNFLAG_UNK15 | ITEM_DYNFLAG_UNK16);    DETAIL_LOG("HandleMailCreateTextItem mailid=%u", mailId);    ItemPosCountVec dest;    InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, bodyItem, false);    if (msg == EQUIP_ERR_OK)    {        m->checked = m->checked | MAIL_CHECK_MASK_COPIED;        m->state = MAIL_STATE_CHANGED;        pl->m_mailsUpdated = true;        pl->StoreItem(dest, bodyItem, true);        pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_OK);    }    else    {        pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_EQUIP_ERROR, msg);        delete bodyItem;    }}
开发者ID:Sar777,项目名称:mangos,代码行数:72,


示例11: UNIT_ACTION_BUTTON_ACTION

void WorldSession::HandlePetAction( WorldPacket & recv_data ){    uint64 guid1;    uint32 data;    uint64 guid2;    recv_data >> guid1;                                     //pet guid    recv_data >> data;    recv_data >> guid2;                                     //tag guid    uint32 spellid = UNIT_ACTION_BUTTON_ACTION(data);    uint8 flag = UNIT_ACTION_BUTTON_TYPE(data);             //delete = 0x07 CastSpell = C1    // used also for charmed creature/player    Unit* pet = _player->GetMap()->GetUnit(guid1);    DETAIL_LOG("HandlePetAction.Pet %u flag is %u, spellid is %u, target %u.", uint32(GUID_LOPART(guid1)), uint32(flag), spellid, uint32(GUID_LOPART(guid2)) );    if (!pet)    {        sLog.outError( "Pet %u not exist.", uint32(GUID_LOPART(guid1)) );        return;    }    if (pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharm())    {        sLog.outError("HandlePetAction.Pet %u isn't pet of player %s.", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName() );        return;    }    if (!pet->isAlive())        return;    if (pet->GetTypeId() == TYPEID_PLAYER)    {        // controller player can only do melee attack        if (!(flag == ACT_COMMAND && spellid == COMMAND_ATTACK))            return;    }    else if (((Creature*)pet)->isPet())    {        // pet can have action bar disabled        if(((Pet*)pet)->GetModeFlags() & PET_MODE_DISABLE_ACTIONS)            return;    }    CharmInfo *charmInfo = pet->GetCharmInfo();    if(!charmInfo)    {        sLog.outError("WorldSession::HandlePetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId());        return;    }    switch(flag)    {        case ACT_COMMAND:                                   //0x07            switch(spellid)            {                case COMMAND_STAY:                          //flat=1792  //STAY                    pet->StopMoving();                    pet->GetMotionMaster()->Clear(false);                    pet->GetMotionMaster()->MoveIdle();                    charmInfo->SetCommandState( COMMAND_STAY );                    break;                case COMMAND_FOLLOW:                        //spellid=1792  //FOLLOW                    pet->AttackStop();                    pet->GetMotionMaster()->MoveFollow(_player,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE);                    charmInfo->SetCommandState( COMMAND_FOLLOW );                    break;                case COMMAND_ATTACK:                        //spellid=1792  //ATTACK                {                    const uint64& selguid = _player->GetSelection();                    Unit *TargetUnit = _player->GetMap()->GetUnit(selguid);                    if(!TargetUnit)                        return;                    // not let attack friendly units.                    if(GetPlayer()->IsFriendlyTo(TargetUnit))                        return;                    // Not let attack through obstructions                    if(!pet->IsWithinLOSInMap(TargetUnit))                        return;                    // This is true if pet has no target or has target but targets differs.                    if(pet->getVictim() != TargetUnit)                    {                        if (pet->getVictim())                            pet->AttackStop();                        if(pet->GetTypeId() != TYPEID_PLAYER)                        {                            pet->GetMotionMaster()->Clear();                            if (((Creature*)pet)->AI())                                ((Creature*)pet)->AI()->AttackStart(TargetUnit);                            //10% chance to play special pet attack talk, else growl                            if(((Creature*)pet)->isPet() && ((Pet*)pet)->getPetType() == SUMMON_PET && pet != TargetUnit && urand(0, 100) < 10)                                pet->SendPetTalk((uint32)PET_TALK_ATTACK);                            else                            {                                // 90% chance for pet and 100% chance for charmed creature                                pet->SendPetAIReaction(guid1);                            }//.........这里部分代码省略.........
开发者ID:Freakstorm,项目名称:mangos,代码行数:101,


示例12: DETAIL_LOG

void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket){    DETAIL_LOG("WORLD: CMSG_PET_CAST_SPELL");    ObjectGuid guid;    uint32 spellid;    recvPacket >> guid >> spellid;    DEBUG_LOG("WORLD: CMSG_PET_CAST_SPELL, %s, spellid %u", guid.GetString().c_str(), spellid);    Creature* pet = _player->GetMap()->GetAnyTypeCreature(guid);    if (!pet || (guid != _player->GetPetGuid() && guid != _player->GetCharmGuid()))    {        sLog.outError("HandlePetCastSpellOpcode: %s isn't pet of %s .", guid.GetString().c_str(), GetPlayer()->GetGuidStr().c_str());        return;    }    SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid);    if (!spellInfo)    {        sLog.outError("WORLD: unknown PET spell id %i", spellid);        return;    }    if (pet->GetCharmInfo() && pet->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))        return;    // do not cast not learned spells    if (!pet->HasSpell(spellid) || IsPassiveSpell(spellInfo))        return;    SpellCastTargets targets;    recvPacket >> targets.ReadForCaster(pet);    pet->clearUnitState(UNIT_STAT_MOVING);    Spell* spell = new Spell(pet, spellInfo, false);    spell->m_targets = targets;    SpellCastResult result = spell->CheckPetCast(nullptr);    if (result == SPELL_CAST_OK)    {        pet->AddCreatureSpellCooldown(spellid);        if (pet->IsPet())        {            ((Pet*)pet)->CheckLearning(spellid);            // 10% chance to play special pet attack talk, else growl            // actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell            if (((Pet*)pet)->getPetType() == SUMMON_PET && (urand(0, 100) < 10))                pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL);            else                pet->SendPetAIReaction();        }        spell->prepare(&(spell->m_targets));    }    else    {        Unit* owner = pet->GetCharmerOrOwner();        if (owner && owner->GetTypeId() == TYPEID_PLAYER)            Spell::SendCastResult((Player*)owner, spellInfo, 0, result, true);        if (!pet->HasSpellCooldown(spellid))            GetPlayer()->SendClearCooldown(spellid, pet);        spell->finish(false);        delete spell;    }}
开发者ID:Leadballoon2000,项目名称:mangos-tbc,代码行数:74,


示例13: DETAIL_LOG

// Only _static_ data send in this packet !!!void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data ){    //DEBUG_LOG("WORLD: CMSG_ITEM_QUERY_SINGLE");    uint32 item;    recv_data >> item;    recv_data.read_skip<uint64>();                          // guid    DETAIL_LOG("STORAGE: Item Query = %u", item);    ItemPrototype const *pProto = ObjectMgr::GetItemPrototype( item );    if( pProto )    {        std::string Name        = pProto->Name1;        std::string Description = pProto->Description;        int loc_idx = GetSessionDbLocaleIndex();        if ( loc_idx >= 0 )        {            ItemLocale const *il = sObjectMgr.GetItemLocale(pProto->ItemId);            if (il)            {                if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())                    Name = il->Name[loc_idx];                if (il->Description.size() > size_t(loc_idx) && !il->Description[loc_idx].empty())                    Description = il->Description[loc_idx];            }        }                                                            // guess size        WorldPacket data( SMSG_ITEM_QUERY_SINGLE_RESPONSE, 600);        data << pProto->ItemId;        data << pProto->Class;        // client known only 0 subclass (and 1-2 obsolute subclasses)        data << (pProto->Class==ITEM_CLASS_CONSUMABLE ? uint32(0) : pProto->SubClass);        data << Name;        data << uint8(0x00);                                //pProto->Name2; // blizz not send name there, just uint8(0x00); <-- /0 = empty string = empty name...        data << uint8(0x00);                                //pProto->Name3; // blizz not send name there, just uint8(0x00);        data << uint8(0x00);                                //pProto->Name4; // blizz not send name there, just uint8(0x00);        data << pProto->DisplayInfoID;        data << pProto->Quality;        data << pProto->Flags;        data << pProto->BuyPrice;        data << pProto->SellPrice;        data << pProto->InventoryType;        data << pProto->AllowableClass;        data << pProto->AllowableRace;        data << pProto->ItemLevel;        data << pProto->RequiredLevel;        data << pProto->RequiredSkill;        data << pProto->RequiredSkillRank;        data << pProto->RequiredSpell;        data << pProto->RequiredHonorRank;        data << pProto->RequiredCityRank;        data << pProto->RequiredReputationFaction;        data << (pProto->RequiredReputationFaction > 0  ? pProto->RequiredReputationRank : 0 );  // send value only if reputation faction id setted ( needed for some items)        data << pProto->MaxCount;        data << pProto->Stackable;        data << pProto->ContainerSlots;        for(int i = 0; i < MAX_ITEM_PROTO_STATS; ++i)        {            data << pProto->ItemStat[i].ItemStatType;            data << pProto->ItemStat[i].ItemStatValue;        }        for(int i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)        {            data << pProto->Damage[i].DamageMin;            data << pProto->Damage[i].DamageMax;            data << pProto->Damage[i].DamageType;        }        // resistances (7)        data << pProto->Armor;        data << pProto->HolyRes;        data << pProto->FireRes;        data << pProto->NatureRes;        data << pProto->FrostRes;        data << pProto->ShadowRes;        data << pProto->ArcaneRes;        data << pProto->Delay;        data << pProto->AmmoType;        data << (float)pProto->RangedModRange;        for(int s = 0; s < MAX_ITEM_PROTO_SPELLS; ++s)        {            // send DBC data for cooldowns in same way as it used in Spell::SendSpellCooldown            // use `item_template` or if not set then only use spell cooldowns            SpellEntry const* spell = sSpellStore.LookupEntry(pProto->Spells[s].SpellId);            if(spell)            {                bool db_data = pProto->Spells[s].SpellCooldown >= 0 || pProto->Spells[s].SpellCategoryCooldown >= 0;                data << pProto->Spells[s].SpellId;                data << pProto->Spells[s].SpellTrigger;                data << uint32(-abs(pProto->Spells[s].SpellCharges));                if(db_data)                {                    data << uint32(pProto->Spells[s].SpellCooldown);                    data << uint32(pProto->Spells[s].SpellCategory);//.........这里部分代码省略.........
开发者ID:yyhhrr,项目名称:mangospriv,代码行数:101,


示例14: DETAIL_LOG

void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket){    DETAIL_LOG("WORLD: CMSG_PET_CAST_SPELL");    ObjectGuid guid;    uint32 spellid;    uint8  cast_count;    uint8  unk_flags;                                       // flags (if 0x02 - some additional data are received)    recvPacket >> guid >> cast_count >> spellid >> unk_flags;    DEBUG_LOG("WORLD: CMSG_PET_CAST_SPELL, %s, cast_count: %u, spellid %u, unk_flags %u", guid.GetString().c_str(), cast_count, spellid, unk_flags);    Creature* pet = _player->GetMap()->GetAnyTypeCreature(guid);    if (!pet || (guid != _player->GetPetGuid() && guid != _player->GetCharmGuid()))    {        sLog.outError("HandlePetCastSpellOpcode: %s isn't pet of %s .", guid.GetString().c_str(), _player->GetGuidStr().c_str());        return;    }    SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid);    if (!spellInfo)    {        sLog.outError("WORLD: unknown PET spell id %i", spellid);        return;    }    if (pet->GetCharmInfo() && pet->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))        return;    Aura* triggeredByAura = pet->GetTriggeredByClientAura(spellid);    // do not cast not learned spells    if ((!triggeredByAura && !pet->HasSpell(spellid)) || IsPassiveSpell(spellInfo))        return;    SpellCastTargets targets;    recvPacket >> targets.ReadForCaster(pet);    pet->clearUnitState(UNIT_STAT_MOVING);    Spell* spell = new Spell(pet, spellInfo, triggeredByAura ? true : false, pet->GetObjectGuid(), triggeredByAura ? triggeredByAura->GetSpellProto() : nullptr);    spell->m_cast_count = cast_count;                       // probably pending spell cast    spell->m_targets = targets;    SpellCastResult result = triggeredByAura ? SPELL_CAST_OK : spell->CheckPetCast(nullptr);    if (result == SPELL_CAST_OK)    {        pet->AddCreatureSpellCooldown(spellid);        spell->SpellStart(&(spell->m_targets), triggeredByAura);    }    else    {        Unit* owner = pet->GetCharmerOrOwner();        if (owner && owner->GetTypeId() == TYPEID_PLAYER && !triggeredByAura)            Spell::SendCastResult((Player*)owner, spellInfo, 0, result, true);        if (!pet->HasSpellCooldown(spellid) && !triggeredByAura)            GetPlayer()->SendClearCooldown(spellid, pet);        spell->finish(false);        delete spell;    }}
开发者ID:HerrTrigger,项目名称:mangos-wotlk,代码行数:66,


示例15: DETAIL_LOG

bool Transport::RemovePassenger(Player* passenger){    if (m_passengers.erase(passenger))        DETAIL_LOG("Player %s removed from transport %s.", passenger->GetName(), GetName());    return true;}
开发者ID:120239197a,项目名称:SingleCore,代码行数:6,


示例16: GetSessionDbLocaleIndex

/// Only _static_ data send in this packet !!!void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ){    uint32 entry;    recv_data >> entry;    ObjectGuid guid;    recv_data >> guid;    CreatureInfo const *ci = ObjectMgr::GetCreatureTemplate(entry);    if (ci)    {        std::string Name, SubName;        Name = ci->Name;        SubName = ci->SubName;        int loc_idx = GetSessionDbLocaleIndex();        if (loc_idx >= 0)        {            CreatureLocale const *cl = sObjectMgr.GetCreatureLocale(entry);            if (cl)            {                if (cl->Name.size() > size_t(loc_idx) && !cl->Name[loc_idx].empty())                    Name = cl->Name[loc_idx];                if (cl->SubName.size() > size_t(loc_idx) && !cl->SubName[loc_idx].empty())                    SubName = cl->SubName[loc_idx];            }        }        DETAIL_LOG("WORLD: CMSG_CREATURE_QUERY '%s' - Entry: %u.", ci->Name, entry);                                                            // guess size        WorldPacket data( SMSG_CREATURE_QUERY_RESPONSE, 100 );        data << uint32(entry);                              // creature entry        data << Name;        data << uint8(0) << uint8(0) << uint8(0);           // name2, name3, name4, always empty        data << SubName;        data << ci->IconName;                               // "Directions" for guard, string for Icons 2.3.0        data << uint32(ci->type_flags);                     // flags        data << uint32(ci->type);                           // CreatureType.dbc        data << uint32(ci->family);                         // CreatureFamily.dbc        data << uint32(ci->rank);                           // Creature Rank (elite, boss, etc)        data << uint32(ci->KillCredit[0]);                  // new in 3.1, kill credit        data << uint32(ci->KillCredit[1]);                  // new in 3.1, kill credit        for(int i = 0; i < MAX_CREATURE_MODEL; ++i)            data << uint32(ci->ModelId[i]);        data << float(ci->unk16);                           // health modifier        data << float(ci->power_mod);                           // power modifier        data << uint8(ci->RacialLeader);        for(uint32 i = 0; i < 6; ++i)            data << uint32(ci->questItems[i]);              // itemId[6], quest drop        data << uint32(ci->movementId);                     // CreatureMovementInfo.dbc        SendPacket( &data );        DEBUG_LOG( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE" );    }    else    {        DEBUG_LOG("WORLD: CMSG_CREATURE_QUERY - Guid: %s Entry: %u NO CREATURE INFO!",            guid.GetString().c_str(), entry);        WorldPacket data( SMSG_CREATURE_QUERY_RESPONSE, 4 );        data << uint32(entry | 0x80000000);        SendPacket( &data );        DEBUG_LOG( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE" );    }}
开发者ID:GlassFace,项目名称:core-1,代码行数:64,


示例17: main

/// Launch the mangos serverextern int main(int argc, char **argv){    // - Construct Memory Manager Instance    MaNGOS::Singleton<MemoryManager>::Instance();    //char *leak = new char[1000];                          // test leak detection    ///- Command line parsing to get the configuration file name    char const* cfg_file = _MANGOSD_CONFIG;    int c=1;    while( c < argc )    {        if( strcmp(argv[c],"-c") == 0)        {            if( ++c >= argc )            {                sLog.outError("Runtime-Error: -c option requires an input argument");                usage(argv[0]);                return 1;            }            else                cfg_file = argv[c];        }        if( strcmp(argv[c],"--version") == 0)        {            printf("%s/n", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID));            return 0;        }        #ifdef WIN32        ////////////        //Services//        ////////////        if( strcmp(argv[c],"-s") == 0)        {            if( ++c >= argc )            {                sLog.outError("Runtime-Error: -s option requires an input argument");                usage(argv[0]);                Log::WaitBeforeContinueIfNeed();                return 1;            }            if( strcmp(argv[c],"install") == 0)            {                if (WinServiceInstall())                    sLog.outString("Installing service");                return 1;            }            else if( strcmp(argv[c],"uninstall") == 0)            {                if(WinServiceUninstall())                    sLog.outString("Uninstalling service");                return 1;            }            else            {                sLog.outError("Runtime-Error: unsupported option %s",argv[c]);                usage(argv[0]);                Log::WaitBeforeContinueIfNeed();                return 1;            }        }        if( strcmp(argv[c],"--service") == 0)        {            WinServiceRun();        }        ////        #endif        ++c;    }    if (!sConfig.SetSource(cfg_file))    {        sLog.outError("Could not find configuration file %s.", cfg_file);        Log::WaitBeforeContinueIfNeed();        return 1;    }    sLog.outString( "%s [world-daemon]", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID) );    sLog.outString( "<Ctrl-C> to stop./n/n" );    sLog.outTitle( "MM   MM         MM   MM  MMMMM   MMMM   MMMMM");    sLog.outTitle( "MM   MM         MM   MM MMM MMM MM  MM MMM MMM");    sLog.outTitle( "MMM MMM         MMM  MM MMM MMM MM  MM MMM");    sLog.outTitle( "MM M MM         MMMM MM MMM     MM  MM  MMM");    sLog.outTitle( "MM M MM  MMMMM  MM MMMM MMM     MM  MM   MMM");    sLog.outTitle( "MM M MM M   MMM MM  MMM MMMMMMM MM  MM    MMM");    sLog.outTitle( "MM   MM     MMM MM   MM MM  MMM MM  MM     MMM");    sLog.outTitle( "MM   MM MMMMMMM MM   MM MMM MMM MM  MM MMM MMM");    sLog.outTitle( "MM   MM MM  MMM MM   MM  MMMMMM  MMMM   MMMMM");    sLog.outTitle( "        MM  MMM http://getmangos.com");    sLog.outTitle( "        MMMMMM/n/n");    sLog.outString("Using configuration file %s.", cfg_file);    DETAIL_LOG("%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));    if (SSLeay() < 0x009080bfL )    {//.........这里部分代码省略.........
开发者ID:Funner,项目名称:mangoszero,代码行数:101,


示例18: DETAIL_LOG

/** * Handles the Packet sent by the client when sending a mail. * * This methods takes the packet sent by the client and performs the following actions: * - Checks whether the mail is valid: i.e. can he send the selected items, *   does he have enough money, etc. * - Creates a MailDraft and adds the needed items, money, cost data. * - Sends the mail. * * Depending on the outcome of the checks performed the player will recieve a different * MailResponseResult. * * @see MailResponseResult * @see SendMailResult() * * @param recv_data the WorldPacket containing the data sent by the client. */void WorldSession::HandleSendMail(WorldPacket& recv_data){    ObjectGuid mailboxGuid;    ObjectGuid itemGuid;    uint64 unk3;    std::string receiver, subject, body;    uint32 unk1, unk2, money, COD;    uint8 unk4;    recv_data >> mailboxGuid;    recv_data >> receiver;    recv_data >> subject;    recv_data >> body;    recv_data >> unk1;                                      // stationery?    recv_data >> unk2;                                      // 0x00000000    recv_data >> itemGuid;    recv_data >> money >> COD;                              // money and cod    recv_data >> unk3;                                      // const 0    recv_data >> unk4;                                      // const 0    // packet read complete, now do check    if (!CheckMailBox(mailboxGuid))        return;    if (receiver.empty())        return;    Player* pl = _player;    ObjectGuid rc;    if (normalizePlayerName(receiver))        rc = sObjectMgr.GetPlayerGuidByName(receiver);    if (!rc)    {        DETAIL_LOG("%s is sending mail to %s (GUID: nonexistent!) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u",                   pl->GetGuidStr().c_str(), receiver.c_str(), subject.c_str(), body.c_str(), itemGuid ? 1 : 0, money, COD, unk1, unk2);        pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND);        return;    }    DETAIL_LOG("%s is sending mail to %s with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u",               pl->GetGuidStr().c_str(), rc.GetString().c_str(), subject.c_str(), body.c_str(), itemGuid ? 1 : 0, money, COD, unk1, unk2);    if (pl->GetObjectGuid() == rc)    {        pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANNOT_SEND_TO_SELF);        return;    }    uint32 reqmoney = money + 30;    if (pl->GetMoney() < reqmoney)    {        pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY);        return;    }    Player* receive = sObjectMgr.GetPlayer(rc);    Team rc_team;    uint8 mails_count = 0;                                  // do not allow to send to one player more than 100 mails    if (receive)    {        rc_team = receive->GetTeam();        mails_count = receive->GetMailSize();    }    else    {        rc_team = sObjectMgr.GetPlayerTeamByGUID(rc);        if (QueryResult* result = CharacterDatabase.PQuery("SELECT COUNT(*) FROM mail WHERE receiver = '%u'", rc.GetCounter()))        {            Field* fields = result->Fetch();            mails_count = fields[0].GetUInt32();            delete result;        }    }//.........这里部分代码省略.........
开发者ID:cala,项目名称:mangos-classic,代码行数:101,


示例19: main

/// Launch the mangos serverextern int main(int argc, char **argv){    // - Construct Memory Manager Instance    MaNGOS::Singleton<MemoryManager>::Instance();    //char *leak = new char[1000];                          // test leak detection    ///- Command line parsing    char const* cfg_file = _MANGOSD_CONFIG;#ifdef WIN32    char const *options = ":c:s:";#else    char const *options = ":c:";#endif    ACE_Get_Opt cmd_opts(argc, argv, options);    cmd_opts.long_option("version", 'v');    int option;    while ((option = cmd_opts()) != EOF)    {        switch (option)        {            case 'c':                cfg_file = cmd_opts.opt_arg();                break;            case 'v':                printf("%s/n", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID));                return 0;#ifdef WIN32            case 's':            {                const char *mode = cmd_opts.opt_arg();                if (!strcmp(mode, "install"))                {                    if (WinServiceInstall())                        sLog.outString("Installing service");                    return 1;                }                else if (!strcmp(mode, "uninstall"))                {                    if (WinServiceUninstall())                        sLog.outString("Uninstalling service");                    return 1;                }                else if (!strcmp(mode, "run"))                    WinServiceRun();                else                {                    sLog.outError("Runtime-Error: -%c unsupported argument %s", cmd_opts.opt_opt(), mode);                    usage(argv[0]);                    Log::WaitBeforeContinueIfNeed();                    return 1;                }                break;            }#endif            case ':':                sLog.outError("Runtime-Error: -%c option requires an input argument", cmd_opts.opt_opt());                usage(argv[0]);                Log::WaitBeforeContinueIfNeed();                return 1;            default:                sLog.outError("Runtime-Error: bad format of commandline arguments");                usage(argv[0]);                Log::WaitBeforeContinueIfNeed();                return 1;        }    }    if (!sConfig.SetSource(cfg_file))    {        sLog.outError("Could not find configuration file %s.", cfg_file);        Log::WaitBeforeContinueIfNeed();        return 1;    }    sLog.outString( "%s [world-daemon]", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID) );    sLog.outString( "<Ctrl-C> to stop./n/n" );    sLog.outTitle( "___  ___          _            _              ___ ");    sLog.outTitle( "|  ///  |         | |          (_)            /   |");    sLog.outTitle( "| .  . |_   _ ___| |_ ___ _ __ _  __ _      / /| |");    sLog.outTitle( "| |///| | | | / __| __/ _ // '__| |/ _` |    / /_| |");    sLog.outTitle( "| |  | | |_| //__ // ||  __/ |  | | (_| |    //___  |");    sLog.outTitle( "//_|  |_///__, |___///__//___|_|  |_|//__,_|        |_/");    sLog.outTitle( "         __/ |                                    ");    sLog.outTitle( "        |___/  http://www.mysteriaserver.sk/wow/  ");    sLog.outTitle( "");    sLog.outString("Using configuration file %s.", cfg_file);    DETAIL_LOG("%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));    if (SSLeay() < 0x009080bfL )    {        DETAIL_LOG("WARNING: Outdated version of OpenSSL lib. Logins to server may not work!");        DETAIL_LOG("WARNING: Minimal required version [OpenSSL 0.9.8k]");//.........这里部分代码省略.........
开发者ID:Nedj,项目名称:Mysteria4,代码行数:101,


示例20: DEBUG_LOG

// this void creates new auction and adds auction to some auctionhousevoid WorldSession::HandleAuctionSellItem(WorldPacket& recv_data){    DEBUG_LOG("WORLD: HandleAuctionSellItem");    ObjectGuid auctioneerGuid;    ObjectGuid itemGuid;    uint32 etime, bid, buyout;    recv_data >> auctioneerGuid;    recv_data >> itemGuid;    recv_data >> bid;    recv_data >> buyout;    recv_data >> etime;    if (!bid || !etime)        return;                                             // check for cheaters    Player* pl = GetPlayer();    AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);    if (!auctionHouseEntry)        return;    // always return pointer    AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);    // client send time in minutes, convert to common used sec time    etime *= MINUTE;    // client understand only 3 auction time    switch (etime)    {        case 1*MIN_AUCTION_TIME:        case 2*MIN_AUCTION_TIME:        case 4*MIN_AUCTION_TIME:            break;        default:            return;    }    // remove fake death    if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))        GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);    if (!itemGuid)        return;    Item* it = pl->GetItemByGuid(itemGuid);    // do not allow to sell already auctioned items    if (sAuctionMgr.GetAItem(itemGuid.GetCounter()))    {        sLog.outError("AuctionError, %s is sending %s, but item is already in another auction", pl->GetGuidStr().c_str(), itemGuid.GetString().c_str());        SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_ITEM_NOT_FOUND);        return;    }    // prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to auction)    if (!it)    {        SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_ITEM_NOT_FOUND);        return;    }    if (!it->CanBeTraded())    {        SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_CANNOT_TRADE_THAT);        return;    }    if ((it->GetProto()->Flags & ITEM_FLAG_CONJURED) || it->GetUInt32Value(ITEM_FIELD_DURATION))    {        SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_CANNOT_TRADE_THAT);        return;    }    // check money for deposit    uint32 deposit = AuctionHouseMgr::GetAuctionDeposit(auctionHouseEntry, etime, it);    if (pl->GetMoney() < deposit)    {        SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_NOT_ENOUGH_MONEY);        return;    }    if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE))    {        sLog.outCommand(GetAccountId(), "GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",                        GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount());    }    pl->ModifyMoney(-int32(deposit));    AuctionEntry* AH = auctionHouse->AddAuction(auctionHouseEntry, it, etime, bid, buyout, deposit, pl);    DETAIL_LOG("selling %s to auctioneer %s with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u",               itemGuid.GetString().c_str(), auctioneerGuid.GetString().c_str(), bid, buyout, etime, auctionHouseEntry->houseId);    SendAuctionCommandResult(AH, AUCTION_STARTED, AUCTION_OK);}
开发者ID:akos1898,项目名称:mangos-tbc,代码行数:100,


示例21: main

//.........这里部分代码省略.........                else if (!strcmp(mode, "install"))                    serviceDaemonMode = 'i';                else if (!strcmp(mode, "uninstall"))                    serviceDaemonMode = 'u';#else                else if (!strcmp(mode, "stop"))                    serviceDaemonMode = 's';#endif                else                {                    sLog.outError("Runtime-Error: -%c unsupported argument %s", cmd_opts.opt_opt(), mode);                    usage(argv[0]);                    Log::WaitBeforeContinueIfNeed();                    return 1;                }                break;            }            case ':':                sLog.outError("Runtime-Error: -%c option requires an input argument", cmd_opts.opt_opt());                usage(argv[0]);                Log::WaitBeforeContinueIfNeed();                return 1;            default:                sLog.outError("Runtime-Error: bad format of commandline arguments");                usage(argv[0]);                Log::WaitBeforeContinueIfNeed();                return 1;        }    }#ifdef WIN32                                                // windows service command need execute before config read    switch (serviceDaemonMode)    {        case 'i':            if (WinServiceInstall())                sLog.outString("Installing service");            return 1;        case 'u':            if (WinServiceUninstall())                sLog.outString("Uninstalling service");            return 1;        case 'r':            WinServiceRun();            break;    }#endif    if (!sConfig.SetSource(cfg_file))    {        sLog.outError("Could not find configuration file %s.", cfg_file);        Log::WaitBeforeContinueIfNeed();        return 1;    }#ifndef WIN32                                               // posix daemon commands need apply after config read    switch (serviceDaemonMode)    {        case 'r':            startDaemon();            break;        case 's':            stopDaemon();            break;    }#endif    sLog.outString("%s [world-daemon]", _FULLVERSION(REVISION_DATE, REVISION_TIME, REVISION_NR, REVISION_ID));    sLog.outString("<Ctrl-C> to stop.");    sLog.outString("/n/n"        "       _____     __  __       _   _  _____  ____   _____ /n"        "      / ____|   |  ///  |     | // | |/ ____|/ __ // / ____|/n"        "     | |        | //  / |     |  //| | |  __  |  | | (___  /n"        "     | |ontinued| |///| | __ _| . ` | | |_ | |  | |//___ // /n"        "     | |____    | |  | |/ _` | |//  | |__| | |__| |____) |/n"        "      //_____|   |_|  |_| (_| |_| //_|//_____|//____/ //____/ /n"        "      http://cmangos.net//__,_|     Doing things right!/n/n");    sLog.outString("Using configuration file %s.", cfg_file);    DETAIL_LOG("%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));    if (SSLeay() < 0x009080bfL)    {        DETAIL_LOG("WARNING: Outdated version of OpenSSL lib. Logins to server may not work!");        DETAIL_LOG("WARNING: Minimal required version [OpenSSL 0.9.8k]");    }    DETAIL_LOG("Using ACE: %s", ACE_VERSION);    ///- Set progress bars show mode    BarGoLink::SetOutputState(sConfig.GetBoolDefault("ShowProgressBars", true));    ///- and run the 'Master'    /// /todo Why do we need this 'Master'? Can't all of this be in the Main as for Realmd?    return sMaster.Run();    // at sMaster return function exist with codes    // 0 - normal shutdown    // 1 - shutdown at error    // 2 - restart command used, this code can be used by restarter for restart mangosd}
开发者ID:249CAAFE40,项目名称:mangos-wotlk,代码行数:101,


示例22: UNIT_ACTION_BUTTON_ACTION

void WorldSession::HandlePetAction(WorldPacket& recv_data){    ObjectGuid petGuid;    uint32 data;    ObjectGuid targetGuid;    recv_data >> petGuid;    recv_data >> data;    recv_data >> targetGuid;    uint32 spellid = UNIT_ACTION_BUTTON_ACTION(data);    uint8 flag = UNIT_ACTION_BUTTON_TYPE(data);             // delete = 0x07 CastSpell = C1    DETAIL_LOG("HandlePetAction: %s flag is %u, spellid is %u, target %s.", petGuid.GetString().c_str(), uint32(flag), spellid, targetGuid.GetString().c_str());    // used also for charmed creature/player    Unit* petUnit = _player->GetMap()->GetUnit(petGuid);    if (!petUnit)    {        sLog.outError("HandlePetAction: %s not exist.", petGuid.GetString().c_str());        return;    }    if (_player->GetObjectGuid() != petUnit->GetCharmerOrOwnerGuid())    {        sLog.outError("HandlePetAction: %s isn't controlled by %s.", petGuid.GetString().c_str(), _player->GetGuidStr().c_str());        return;    }    if (!petUnit->isAlive())        return;    CharmInfo* charmInfo = petUnit->GetCharmInfo();    if (!charmInfo)    {        sLog.outError("WorldSession::HandlePetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", petUnit->GetGUIDLow(), petUnit->GetTypeId());        return;    }    Pet* pet = nullptr;    Creature* creature = nullptr;    if (petUnit->GetTypeId() == TYPEID_UNIT)    {        creature = static_cast<Creature*>(petUnit);        if (creature->IsPet())        {            pet = static_cast<Pet*>(petUnit);            if (pet->GetModeFlags() & PET_MODE_DISABLE_ACTIONS)                return;        }    }    if (!pet && petUnit->hasUnitState(UNIT_STAT_CONTROLLED))    {        // possess case        if (flag != uint8(ACT_COMMAND))        {            sLog.outError("PetHAndler: unknown PET flag Action %i and spellid %i. For possessed %s", uint32(flag), spellid, petUnit->GetGuidStr().c_str());            return;        }        switch (spellid)        {            case COMMAND_STAY:            case COMMAND_FOLLOW:                charmInfo->SetCommandState(CommandStates(spellid));                break;            case COMMAND_ATTACK:            {                Unit* targetUnit = targetGuid ? _player->GetMap()->GetUnit(targetGuid) : nullptr;                if (targetUnit && targetUnit != petUnit && targetUnit->isTargetableForAttack())                {                    _player->SetInCombatState(true, targetUnit);                    // This is true if pet has no target or has target but targets differs.                    if (petUnit->getVictim() != targetUnit)                        petUnit->Attack(targetUnit, true);                }                break;            }            case COMMAND_ABANDON:                _player->Uncharm();                break;            default:                sLog.outError("PetHandler: Not allowed action %i and spellid %i. Pet %s owner is %s", uint32(flag), spellid, petUnit->GetGuidStr().c_str(), _player->GetGuidStr().c_str());                break;        }        return;    }        // only real pet should go there    if (!pet)    {        sLog.outError("PetHandler: A not pet trying to do unknown Action %i and spellid %i. Pet %s owner is %s", uint32(flag), spellid, petUnit->GetGuidStr().c_str(), _player->GetGuidStr().c_str());        return;    }//.........这里部分代码省略.........
开发者ID:HerrTrigger,项目名称:mangos-wotlk,代码行数:101,


示例23: mysql_init

bool MySQLConnection::Initialize(const char* infoString){    MYSQL* mysqlInit = mysql_init(NULL);    if (!mysqlInit)    {        sLog.outError("Could not initialize Mysql connection");        return false;    }    Tokens tokens = StrSplit(infoString, ";");    Tokens::iterator iter;    std::string host, port_or_socket, user, password, database;    int port;    char const* unix_socket;    iter = tokens.begin();    if (iter != tokens.end())        host = *iter++;    if (iter != tokens.end())        port_or_socket = *iter++;    if (iter != tokens.end())        user = *iter++;    if (iter != tokens.end())        password = *iter++;    if (iter != tokens.end())        database = *iter++;    mysql_options(mysqlInit, MYSQL_SET_CHARSET_NAME, "utf8");#ifdef WIN32    if (host == ".")                                        // named pipe use option (Windows)    {        unsigned int opt = MYSQL_PROTOCOL_PIPE;        mysql_options(mysqlInit, MYSQL_OPT_PROTOCOL, (char const*)&opt);        port = 0;        unix_socket = 0;    }    else                                                    // generic case    {        port = atoi(port_or_socket.c_str());        unix_socket = 0;    }#else    if (host == ".")                                        // socket use option (Unix/Linux)    {        unsigned int opt = MYSQL_PROTOCOL_SOCKET;        mysql_options(mysqlInit, MYSQL_OPT_PROTOCOL, (char const*)&opt);        host = "localhost";        port = 0;        unix_socket = port_or_socket.c_str();    }    else                                                    // generic case    {        port = atoi(port_or_socket.c_str());        unix_socket = 0;    }#endif    mMysql = mysql_real_connect(mysqlInit, host.c_str(), user.c_str(),                                password.c_str(), database.c_str(), port, unix_socket, 0);    if (!mMysql)    {        sLog.outError("Could not connect to MySQL database at %s: %s/n",                      host.c_str(), mysql_error(mysqlInit));        mysql_close(mysqlInit);        return false;    }    DETAIL_LOG("Connected to MySQL database %[email
C++ DETATCHSTATUSPTR函数代码示例
C++ DES_set_odd_parity函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。