void GetAIInformation(ChatHandler& reader) override
 {
     if (m_lAssistList.empty())
         reader.PSendSysMessage("Anubisath Sentinel - group not assigned, will be assigned OnAggro");
     if (m_lAssistList.size() == MAX_BUDDY)
         reader.PSendSysMessage("Anubisath Sentinel - proper group found");
     else
         reader.PSendSysMessage("Anubisath Sentinel - not correct number of mobs for group found. Number found %u, should be %u", uint32(m_lAssistList.size()), MAX_BUDDY);
 }
    void GetAIInformation(ChatHandler& reader)
    {
        reader.PSendSysMessage("Thermaplugg, currently phase %s", m_bIsPhaseTwo ? "two" : "one");

        if (m_asBombFaces)
        {
            for (uint8 i = 0; i < MAX_GNOME_FACES; ++i)
                reader.PSendSysMessage("Bomb face %u is %s ", (uint32)i, m_asBombFaces[i].m_bActivated ? "activated" : "not activated");
        }
    }
std::string GmTicket::FormatMessageString(ChatHandler& handler, bool detailed) const
{
    time_t curTime = time(NULL);
    Player* player = GetPlayer();

    std::stringstream ss;
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTGUID, _ticketId);
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTNAME, player ? player->GetName().c_str() : "NULL");
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTAGECREATE, (secsToTimeString(curTime - _ticketCreateTime, true, false)).c_str());
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTAGE, (secsToTimeString(curTime - _lastModifiedTime, true, false)).c_str());

    std::string name;
    if (sObjectMgr->GetPlayerNameByGUID(_assignedTo, name))
        ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTASSIGNEDTO, name.c_str());

    if (detailed)
    {
        ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTMESSAGE, _message.c_str());
        if (!_comment.empty())
            ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTCOMMENT, _comment.c_str());
        if (!_response.empty())
            ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTRESPONSE, _response.c_str());
    }
    return ss.str();
}
    void GetAIInformation(ChatHandler& reader) override
    {
        if (m_pInstance)
        {
            if (m_pInstance->GetData(TYPE_BRUTALLUS) == SPECIAL)
            { reader.PSendSysMessage("Brutallus intro event is currently %s", m_bIsIntroInProgress ? "in progress" : "completed"); }
            else
            { reader.PSendSysMessage("Brutallus intro event is currently %s", m_pInstance->GetData(TYPE_BRUTALLUS) == NOT_STARTED ? "not started" : "completed"); }

            if (m_pInstance->GetData(TYPE_BRUTALLUS) != NOT_STARTED)
            {
                if (Creature* pMadrigosa = m_pInstance->GetSingleCreatureFromStorage(NPC_MADRIGOSA, true))
                { reader.PSendSysMessage("Madrigosa guid is %s and has %u health.", pMadrigosa->GetObjectGuid().GetString().c_str(), pMadrigosa->GetHealth()); }
            }
        }
    }
Beispiel #5
0
void npc_escortAI::GetAIInformation(ChatHandler& reader)
{
    std::ostringstream oss;

    oss << "EscortAI ";
    if (m_playerGuid)
    {
        oss << "started for " << m_playerGuid.GetString() << " ";
    }
    if (m_pQuestForEscort)
    {
        oss << "started with quest " << m_pQuestForEscort->GetQuestId();
    }

    if (HasEscortState(STATE_ESCORT_ESCORTING))
    {
        oss << "\nEscortFlags: Escorting" << (HasEscortState(STATE_ESCORT_RETURNING) ? ", Returning" : "") << (HasEscortState(STATE_ESCORT_PAUSED) ? ", Paused" : "");

        if (CurrentWP != WaypointList.end())
        {
            oss << "\nNext Waypoint Id = " << CurrentWP->uiId << " Position: " << CurrentWP->fX << " " << CurrentWP->fY << " " << CurrentWP->fZ;
        }
    }

    reader.PSendSysMessage(oss.str().c_str());
}
    void OnPlayerLeaveAll(Map* map, Player* player)
    {

        //if (GetValidDebugLevel() >= 3)
            //sLog->outInfo(LOG_FILTER_TSCR, "#### VAS_AutoBalance_AllMapScript - OnPlayerLeaveAll map=%s player=%s", map->GetMapName(),player->GetName());

        int instancePlayerCount = map->GetPlayersCountExceptGMs() - 1;

        if (instancePlayerCount >=1)
        {
            if (GetValidDebugLevel() >= 2)
            {
                //sLog->outInfo(LOG_FILTER_TSCR, "----------------------------------------------------");
                //sLog->outInfo(LOG_FILTER_TSCR, "## VAS_AutoBalance_AllMapScript - OnPlayerLeaveAll");
                //sLog->outInfo(LOG_FILTER_TSCR, "## For InsatanceID %u",map->GetInstanceId());
                //sLog->outInfo(LOG_FILTER_TSCR, "## IsDungeon= %u",map->GetEntry()->IsDungeon());
                //sLog->outInfo(LOG_FILTER_TSCR, "## For Map %u",player->GetMapId());
                //sLog->outInfo(LOG_FILTER_TSCR, "## PlayersInMap %u",instancePlayerCount);
                //sLog->outInfo(LOG_FILTER_TSCR, "----------------------------------------------------\n");
            }

            if (sWorld->getIntConfig(VAS_PlayerChangeNotify) >= 1)
            {
                if ((map->GetEntry()->IsDungeon()) && !player->IsGameMaster())
                {
                    Map::PlayerList const &playerList = map->GetPlayers();
                    if (!playerList.isEmpty())
                    {
                        for (Map::PlayerList::const_iterator playerIteration = playerList.begin(); playerIteration != playerList.end(); ++playerIteration)
                        {
                            if (Player* playerHandle = playerIteration->GetSource())
                            {
                                ChatHandler chatHandle = ChatHandler(playerHandle->GetSession());
                                chatHandle.PSendSysMessage("|cffFF0000 [VAS-AutoBalance]|r|cffFF8000 %s left the Instance %s. Auto setting player count to %u |r",player->GetName().c_str(),map->GetMapName(),instancePlayerCount);
                            }
                        }
                    }
                }
            }
        }
    }
    void OnPlayerEnterAll(Map* map, Player* player)
    {
        if (GetValidDebugLevel() >= 2)
        {
            //sLog->outInfo(LOG_FILTER_TSCR, "----------------------------------------------------");
            //sLog->outInfo(LOG_FILTER_TSCR, "## VAS_AutoBalance_AllMapScript - OnPlayerEnterAll");
            //sLog->outInfo(LOG_FILTER_TSCR, "## For InsatanceID %u",map->GetInstanceId());
            //sLog->outInfo(LOG_FILTER_TSCR, "## IsDungeon= %u",map->GetEntry()->IsDungeon());
            //sLog->outInfo(LOG_FILTER_TSCR, "## For Map %u",player->GetMapId());
            //sLog->outInfo(LOG_FILTER_TSCR, "## PlayersInMap %u",map->GetPlayersCountExceptGMs());
            //sLog->outInfo(LOG_FILTER_TSCR, "## pDifficulty %u",uint32(player->GetDifficulty(player->GetMap()->IsHeroic())));
            //sLog->outInfo(LOG_FILTER_TSCR, "## pGetDungeonDifficulty %u",uint32(player->GetDungeonDifficulty()));
            //sLog->outInfo(LOG_FILTER_TSCR, "## pGetRaidDifficulty %u",uint32(player->GetRaidDifficulty()));
            //sLog->outInfo(LOG_FILTER_TSCR, "## maxPlayers %u",((InstanceMap*)sMapMgr->FindMap(player->GetMapId(), player->GetInstanceId()))->GetMaxPlayers());
            //sLog->outInfo(LOG_FILTER_TSCR, "## IsHeroic=%s IsRaid=%s IsRegularDifficulty=%s IsRaidOrHeroicDungeon=%s IsNonRaidDungeon=%s",BOOL_TO_STRING(player->GetMap()->IsHeroic()),BOOL_TO_STRING(player->GetMap()->IsRaid()),BOOL_TO_STRING(player->GetMap()->IsRegularDifficulty()),BOOL_TO_STRING(player->GetMap()->IsRaidOrHeroicDungeon()),BOOL_TO_STRING(player->GetMap()->IsNonRaidDungeon()));
            //sLog->outInfo(LOG_FILTER_TSCR, "----------------------------------------------------\n");
        }

        if (sWorld->getIntConfig(VAS_PlayerChangeNotify) >= 1)
        {
            if ((map->GetEntry()->IsDungeon()) && !player->IsGameMaster() )
            {
                Map::PlayerList const &playerList = map->GetPlayers();
                if (!playerList.isEmpty())
                {
                    for (Map::PlayerList::const_iterator playerIteration = playerList.begin(); playerIteration != playerList.end(); ++playerIteration)
                    {
                        if (Player* playerHandle = playerIteration->GetSource())
                        {
                            ChatHandler chatHandle = ChatHandler(playerHandle->GetSession());
                            chatHandle.PSendSysMessage("|cffFF0000 [AutoBalance]|r|cffFF8000 %s entered the Instance %s. Auto setting player count to %u |r",player->GetName().c_str(),map->GetMapName(),map->GetPlayersCountExceptGMs());
                        }
                    }
                }
            }
        }
    }
void npc_escortAI::GetAIInformation(ChatHandler& reader)
{
    std::ostringstream oss;

    oss << "EscortAI ";
    if (m_playerGuid)
        oss << "started for " << m_playerGuid.GetString() << " ";
    if (m_pQuestForEscort)
        oss << "started with quest " << m_pQuestForEscort->GetQuestId();

    if (HasEscortState(STATE_ESCORT_ESCORTING))
    {
        oss << "\nEscortFlags: Escorting" << (HasEscortState(STATE_ESCORT_RETURNING) ? ", Returning" : "") << (HasEscortState(STATE_ESCORT_PAUSED) ? ", Paused" : "") << "\n";
        m_creature->GetMotionMaster()->GetWaypointPathInformation(oss);
    }

    reader.PSendSysMessage("%s", oss.str().c_str());
}
Beispiel #9
0
std::string GmTicket::FormatMessageString(ChatHandler& handler, const char* szClosedName, const char* szAssignedToName, const char* szUnassignedName, const char* szDeletedName, const char* szCompletedName) const
{
    std::stringstream ss;
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTGUID, _id);
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTNAME, _playerName.c_str());
    if (szClosedName)
        ss << handler.PGetParseString(LANG_COMMAND_TICKETCLOSED, szClosedName);
    if (szAssignedToName)
        ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTASSIGNEDTO, szAssignedToName);
    if (szUnassignedName)
        ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTUNASSIGNED, szUnassignedName);
    if (szDeletedName)
        ss << handler.PGetParseString(LANG_COMMAND_TICKETDELETED, szDeletedName);
    if (szCompletedName)
        ss << handler.PGetParseString(LANG_COMMAND_TICKETCOMPLETED, szCompletedName);
    return ss.str();
}
std::string Ticket::FormatViewMessageString(ChatHandler& handler, char const* closedName, char const* assignedToName, char const* unassignedName, char const* deletedName) const
{
    std::stringstream ss;
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTGUID, _id);
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTNAME, GetPlayerName().c_str());
    if (closedName)
        ss << handler.PGetParseString(LANG_COMMAND_TICKETCLOSED, closedName);
    if (assignedToName)
        ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTASSIGNEDTO, assignedToName);
    if (unassignedName)
        ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTUNASSIGNED, unassignedName);
    if (deletedName)
        ss << handler.PGetParseString(LANG_COMMAND_TICKETDELETED, deletedName);
    return ss.str();
}
std::string SuggestionTicket::FormatViewMessageString(ChatHandler& handler, bool detailed) const
{
    time_t curTime = time(nullptr);

    std::stringstream ss;
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTGUID, _id);
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTNAME, GetPlayerName().c_str());
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTAGECREATE, (secsToTimeString(curTime - _createTime, true, false)).c_str());

    if (!_assignedTo.IsEmpty())
        ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTASSIGNEDTO, GetAssignedToName().c_str());

    if (detailed)
    {
        ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTMESSAGE, _note.c_str());
        if (!_comment.empty())
            ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTCOMMENT, _comment.c_str());
    }
    return ss.str();
}
Beispiel #12
0
std::string GmTicket::FormatViewMessageString(ChatHandler& handler, bool detailed) const
{
    time_t curTime = time(nullptr);

    std::stringstream ss;
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTGUID, _id);
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTNAME, GetPlayer()->GetName().c_str());
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTAGECREATE, (secsToTimeString(curTime - _createTime, true, false)).c_str());
    ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTAGE, (secsToTimeString(curTime - _lastModifiedTime, true, false)).c_str());

    std::string name;
    if (ObjectMgr::GetPlayerNameByGUID(_assignedTo, name))
        ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTASSIGNEDTO, name.c_str());

    if (detailed)
    {
        ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTMESSAGE, _description.c_str());
        if (!_comment.empty())
            ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTCOMMENT, _comment.c_str());
        if (!_response.empty())
            ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTRESPONSE, _response.c_str());
    }
    return ss.str();
}
 void GetAIInformation(ChatHandler& reader) override
 {
     reader.PSendSysMessage("Kil'jaeden is currently in phase %u", m_uiPhase);
 }
void Scripted_NoMovementAI::GetAIInformation(ChatHandler& reader)
{
    reader.PSendSysMessage("ScriptedAI (no movement)");
}
Beispiel #15
0
void Scripted_NoMovementAI::GetAIInformation(ChatHandler& reader)
{
    reader.PSendSysMessage("Subclass of Scripted_NoMovementAI");
}
Beispiel #16
0
/// This function shows if combat movement is enabled, overwrite for more info
void ScriptedAI::GetAIInformation(ChatHandler& reader)
{
    reader.PSendSysMessage("ScriptedAI, combat movement is %s", reader.GetOnOffStr(IsCombatMovement()));
}
Beispiel #17
0
	void RagnarosEncounterStart(ChatHandler& reader)
	{
		if (b_RagnarosEventStart)
			reader.PSendSysMessage("Der Kampf mit Ragnaros beginnt in 10 Sekunden!");
	}
Beispiel #18
0
void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
{
    uint64 playerGuid = holder->GetGuid();

    Player* pCurrChar = new Player(this);
    pCurrChar->GetMotionMaster()->Initialize();
     // for send server info and strings (config)
    ChatHandler chH = ChatHandler(pCurrChar);

    // "GetAccountId()==db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools)
    if(!pCurrChar->LoadFromDB(GUID_LOPART(playerGuid), holder))
    {
        KickPlayer();                                       // disconnect client, player no set to session and it will not deleted or saved at kick
        delete pCurrChar;                                   // delete it manually
        delete holder;                                      // delete all unprocessed queries
        m_playerLoading = false;
        return;
    }

    SetPlayer(pCurrChar);

    pCurrChar->SendDungeonDifficulty(false);

    WorldPacket data( SMSG_LOGIN_VERIFY_WORLD, 20 );
    data << pCurrChar->GetMapId();
    data << pCurrChar->GetPositionX();
    data << pCurrChar->GetPositionY();
    data << pCurrChar->GetPositionZ();
    data << pCurrChar->GetOrientation();
    SendPacket(&data);

    data.Initialize( SMSG_ACCOUNT_DATA_TIMES, 128 );
    for(int i = 0; i < 32; i++)
        data << uint32(0);
    SendPacket(&data);

    data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2);         // added in 2.2.0
    data << uint8(2);                                       // unknown value
    data << uint8(0);                                       // enable(1)/disable(0) voice chat interface in client
    SendPacket(&data);

    // Send MOTD
    {
        data.Initialize(SMSG_MOTD, 50);                     // new in 2.0.1
        data << (uint32)0;

        uint32 linecount=0;
        std::string str_motd = sWorld.GetMotd();
        std::string::size_type pos, nextpos;

        pos = 0;
        while ( (nextpos= str_motd.find('@',pos)) != std::string::npos )
        {
            if (nextpos != pos)
            {
                data << str_motd.substr(pos,nextpos-pos);
                ++linecount;
            }
            pos = nextpos+1;
        }

        if (pos<str_motd.length())
        {
            data << str_motd.substr(pos);
            ++linecount;
        }

        data.put(0, linecount);

        SendPacket( &data );
        DEBUG_LOG( "WORLD: Sent motd (SMSG_MOTD)" );

        // send server info
        if(sWorld.getConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1)
            chH.PSendSysMessage(_FULLVERSION);

        DEBUG_LOG( "WORLD: Sent server info" );
    }

    //QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
    QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);

    if(resultGuild)
    {
        Field *fields = resultGuild->Fetch();
        pCurrChar->SetInGuild(fields[0].GetUInt32());
        pCurrChar->SetRank(fields[1].GetUInt32());
        delete resultGuild;
    }
    else if(pCurrChar->GetGuildId())                        // clear guild related fields in case wrong data about non existed membership
    {
        pCurrChar->SetInGuild(0);
        pCurrChar->SetRank(0);
    }

    if(pCurrChar->GetGuildId() != 0)
    {
        Guild* guild = objmgr.GetGuildById(pCurrChar->GetGuildId());
        if(guild)
        {
            data.Initialize(SMSG_GUILD_EVENT, (2+guild->GetMOTD().size()+1));
            data << (uint8)GE_MOTD;
            data << (uint8)1;
            data << guild->GetMOTD();
            SendPacket(&data);
            DEBUG_LOG( "WORLD: Sent guild-motd (SMSG_GUILD_EVENT)" );

            data.Initialize(SMSG_GUILD_EVENT, (5+10));      // we guess size
            data<<(uint8)GE_SIGNED_ON;
            data<<(uint8)1;
            data<<pCurrChar->GetName();
            data<<pCurrChar->GetGUID();
            guild->BroadcastPacket(&data);
            DEBUG_LOG( "WORLD: Sent guild-signed-on (SMSG_GUILD_EVENT)" );

            // Increment online members of the guild
            guild->IncOnlineMemberCount();
        }
        else
        {
            // remove wrong guild data
            sLog.outError("Player %s (GUID: %u) marked as member not existed guild (id: %u), removing guild membership for player.",pCurrChar->GetName(),pCurrChar->GetGUIDLow(),pCurrChar->GetGuildId());
            pCurrChar->SetInGuild(0);
        }
    }

    if(!pCurrChar->isAlive())
        pCurrChar->SendCorpseReclaimDelay(true);

    pCurrChar->SendInitialPacketsBeforeAddToMap();

    //Show cinematic at the first time that player login
    if( !pCurrChar->getCinematic() )
    {
        pCurrChar->setCinematic(1);

        ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(pCurrChar->getRace());
        if(rEntry)
        {
            data.Initialize( SMSG_TRIGGER_CINEMATIC,4 );
            data << uint32(rEntry->startmovie);
            SendPacket( &data );

            // send new char string if not empty
            if (!sWorld.GetNewCharString().empty())
                chH.PSendSysMessage(sWorld.GetNewCharString().c_str());
        }
    }

    if (!pCurrChar->GetMap()->Add(pCurrChar))
    {
        AreaTrigger const* at = objmgr.GetGoBackTrigger(pCurrChar->GetMapId());
        if(at)
            pCurrChar->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, pCurrChar->GetOrientation());
        else
            pCurrChar->TeleportTo(pCurrChar->m_homebindMapId, pCurrChar->m_homebindX, pCurrChar->m_homebindY, pCurrChar->m_homebindZ, pCurrChar->GetOrientation());
    }

    ObjectAccessor::Instance().AddObject(pCurrChar);
    //sLog.outDebug("Player %s added to Map.",pCurrChar->GetName());
    pCurrChar->GetSocial()->SendSocialList();

    pCurrChar->SendInitialPacketsAfterAddToMap();

    CharacterDatabase.PExecute("UPDATE characters SET online = 1 WHERE guid = '%u'", pCurrChar->GetGUIDLow());
    LoginDatabase.PExecute("UPDATE account SET online = 1 WHERE id = '%u'", GetAccountId());
    pCurrChar->SetInGameTime( getMSTime() );

    // announce group about member online (must be after add to player list to receive announce to self)
    if(Group *group = pCurrChar->GetGroup())
    {
        //pCurrChar->groupInfo.group->SendInit(this); // useless
        group->CheckLeader(pCurrChar->GetGUID(), false); //check leader login
        group->SendUpdate();
    }

    // friend status
    sSocialMgr.SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUIDLow(), true);

    // Place character in world (and load zone) before some object loading
    pCurrChar->LoadCorpse();

    // setting Ghost+speed if dead
    if (pCurrChar->m_deathState != ALIVE)
    {
        // not blizz like, we must correctly save and load player instead...
        if(pCurrChar->getRace() == RACE_NIGHTELF)
            pCurrChar->CastSpell(pCurrChar, 20584, true, 0);// auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form)
        pCurrChar->CastSpell(pCurrChar, 8326, true, 0);     // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?)

        //pCurrChar->SetUInt32Value(UNIT_FIELD_AURA+41, 8326);
        //pCurrChar->SetUInt32Value(UNIT_FIELD_AURA+42, 20584);
        //pCurrChar->SetUInt32Value(UNIT_FIELD_AURAFLAGS+6, 238);
        //pCurrChar->SetUInt32Value(UNIT_FIELD_AURALEVELS+11, 514);
        //pCurrChar->SetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS+11, 65535);
        //pCurrChar->SetUInt32Value(UNIT_FIELD_DISPLAYID, 1825);
        //if (pCurrChar->getRace() == RACE_NIGHTELF)
        //{
        //    pCurrChar->SetSpeed(MOVE_RUN,  1.5f*1.2f, true);
        //    pCurrChar->SetSpeed(MOVE_SWIM, 1.5f*1.2f, true);
        //}
        //else
        //{
        //    pCurrChar->SetSpeed(MOVE_RUN,  1.5f, true);
        //    pCurrChar->SetSpeed(MOVE_SWIM, 1.5f, true);
        //}
        pCurrChar->SetMovement(MOVE_WATER_WALK);
    }

    if(uint32 sourceNode = pCurrChar->m_taxi.GetTaxiSource())
    {

        sLog.outDebug( "WORLD: Restart character %u taxi flight", pCurrChar->GetGUIDLow() );

        uint32 MountId = objmgr.GetTaxiMount(sourceNode, pCurrChar->GetTeam());
        uint32 path = pCurrChar->m_taxi.GetCurrentTaxiPath();

        // search appropriate start path node
        uint32 startNode = 0;

        TaxiPathNodeList const& nodeList = sTaxiPathNodesByPath[path];

        float distPrev = MAP_SIZE*MAP_SIZE;
        float distNext =
            (nodeList[0].x-pCurrChar->GetPositionX())*(nodeList[0].x-pCurrChar->GetPositionX())+
            (nodeList[0].y-pCurrChar->GetPositionY())*(nodeList[0].y-pCurrChar->GetPositionY())+
            (nodeList[0].z-pCurrChar->GetPositionZ())*(nodeList[0].z-pCurrChar->GetPositionZ());

        for(uint32 i = 1; i < nodeList.size(); ++i)
        {
            TaxiPathNode const& node = nodeList[i];
            TaxiPathNode const& prevNode = nodeList[i-1];

            // skip nodes at another map
            if(node.mapid != pCurrChar->GetMapId())
                continue;

            distPrev = distNext;

            distNext =
                (node.x-pCurrChar->GetPositionX())*(node.x-pCurrChar->GetPositionX())+
                (node.y-pCurrChar->GetPositionY())*(node.y-pCurrChar->GetPositionY())+
                (node.z-pCurrChar->GetPositionZ())*(node.z-pCurrChar->GetPositionZ());

            float distNodes =
                (node.x-prevNode.x)*(node.x-prevNode.x)+
                (node.y-prevNode.y)*(node.y-prevNode.y)+
                (node.z-prevNode.z)*(node.z-prevNode.z);

            if(distNext + distPrev < distNodes)
            {
                startNode = i;
                break;
            }
        }

        SendDoFlight( MountId, path, startNode );
    }

    // Load pet if any and player is alive and not in taxi flight
    if(pCurrChar->isAlive() && pCurrChar->m_taxi.GetTaxiSource()==0)
        pCurrChar->LoadPet();

    // Set FFA PvP for non GM in non-rest mode
    if(sWorld.IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_RESTING) )
        pCurrChar->SetFlag(PLAYER_FLAGS,PLAYER_FLAGS_FFA_PVP);

    if(pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
        pCurrChar->SetContestedPvP();

    // Apply at_login requests
    if(pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS))
    {
        pCurrChar->resetSpells();
        SendNotification(LANG_RESET_SPELLS);
    }

    if(pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
    {
        pCurrChar->resetTalents(true);
        SendNotification(LANG_RESET_TALENTS);
    }

    // show time before shutdown if shutdown planned.
    if(sWorld.IsShutdowning())
        sWorld.ShutdownMsg(true,pCurrChar);

    if(sWorld.getConfig(CONFIG_ALL_TAXI_PATHS))
        pCurrChar->SetTaxiCheater(true);

    if(pCurrChar->isGameMaster())
        SendNotification(LANG_GM_ON);

    std::string IP_str = GetRemoteAddress();
    sLog.outChar("Account: %d (IP: %s) Login Character:[%s] (guid:%u)",
        GetAccountId(),IP_str.c_str(),pCurrChar->GetName() ,pCurrChar->GetGUIDLow());

    m_playerLoading = false;
    delete holder;
}
 void GetAIInformation(ChatHandler& reader) override
 {
     reader.PSendSysMessage("Simon Game Bunny, current game phase = %u, current level = %u", uint32(m_uiGamePhase), m_uiLevelCount);
 }
void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
{
    uint64 playerGuid = holder->GetGuid();

    Player* pCurrChar = new Player(this);
     // for send server info and strings (config)
    ChatHandler chH = ChatHandler(pCurrChar);

    // "GetAccountId() == db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools)
    if (!pCurrChar->LoadFromDB(GUID_LOPART(playerGuid), holder))
    {
        KickPlayer();                                       // disconnect client, player no set to session and it will not deleted or saved at kick
        delete pCurrChar;                                   // delete it manually
        delete holder;                                      // delete all unprocessed queries
        m_playerLoading = false;
        return;
    }

    pCurrChar->GetMotionMaster()->Initialize();

    SetPlayer(pCurrChar);

    pCurrChar->SendDungeonDifficulty(false);

    WorldPacket data(SMSG_LOGIN_VERIFY_WORLD, 20);
    data << pCurrChar->GetMapId();
    data << pCurrChar->GetPositionX();
    data << pCurrChar->GetPositionY();
    data << pCurrChar->GetPositionZ();
    data << pCurrChar->GetOrientation();
    SendPacket(&data);

    data.Initialize(SMSG_ACCOUNT_DATA_TIMES, 128);
    for (int i = 0; i < 32; i++)
        data << uint32(0);
    SendPacket(&data);

    data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2);         // added in 2.2.0
    data << uint8(2);                                       // unknown value
    data << uint8(0);                                       // enable(1)/disable(0) voice chat interface in client
    SendPacket(&data);

    // Send MOTD
    {
        data.Initialize(SMSG_MOTD, 50);                     // new in 2.0.1
        data << (uint32)0;

        uint32 linecount=0;
        std::string str_motd = sWorld.GetMotd();
        std::string::size_type pos, nextpos;

        pos = 0;
        while ((nextpos= str_motd.find('@',pos)) != std::string::npos)
        {
            if (nextpos != pos)
            {
                data << str_motd.substr(pos,nextpos-pos);
                ++linecount;
            }
            pos = nextpos+1;
        }

        if (pos<str_motd.length())
        {
            data << str_motd.substr(pos);
            ++linecount;
        }

        data.put(0, linecount);

        SendPacket(&data);
        DEBUG_LOG("WORLD: Sent motd (SMSG_MOTD)");

        // send server info
        if (sWorld.getConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1)
            chH.PSendSysMessage(_FULLVERSION);

        DEBUG_LOG("WORLD: Sent server info");
    }

    QueryResult_AutoPtr resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);

    if (resultGuild)
    {
        Field *fields = resultGuild->Fetch();
        pCurrChar->SetInGuild(fields[0].GetUInt32());
        pCurrChar->SetRank(fields[1].GetUInt32());
    }
    else if (pCurrChar->GetGuildId())                        // clear guild related fields in case wrong data about non existed membership
    {
        pCurrChar->SetInGuild(0);
        pCurrChar->SetRank(0);
    }

    if (pCurrChar->GetGuildId() != 0)
    {
        Guild* guild = objmgr.GetGuildById(pCurrChar->GetGuildId());
        if (guild)
        {
            data.Initialize(SMSG_GUILD_EVENT, (1+1+guild->GetMOTD().size()+1));
            data << uint8(GE_MOTD);
            data << uint8(1);
            data << guild->GetMOTD();
            SendPacket(&data);
            DEBUG_LOG("WORLD: Sent guild-motd (SMSG_GUILD_EVENT)");

            data.Initialize(SMSG_GUILD_EVENT, (5+10));      // we guess size
            data<<(uint8)GE_SIGNED_ON;
            data<<(uint8)1;
            data<<pCurrChar->GetName();
            data<<pCurrChar->GetGUID();
            guild->BroadcastPacket(&data);
            DEBUG_LOG("WORLD: Sent guild-signed-on (SMSG_GUILD_EVENT)");

            // Increment online members of the guild
            guild->IncOnlineMemberCount();
        }
        else
        {
            // remove wrong guild data
            sLog.outError("Player %s (GUID: %u) marked as member of invalid guild (id: %u), removing guild membership for player.",pCurrChar->GetName(),pCurrChar->GetGUIDLow(),pCurrChar->GetGuildId());
            pCurrChar->SetInGuild(0);
        }
    }

    if (!pCurrChar->isAlive())
        pCurrChar->SendCorpseReclaimDelay(true);

    pCurrChar->SendInitialPacketsBeforeAddToMap();

    //Show cinematic at the first time that player login
    if (!pCurrChar->getCinematic())
    {
        pCurrChar->setCinematic(1);

        if (ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(pCurrChar->getRace()))
        {
            pCurrChar->SendCinematicStart(rEntry->CinematicSequence);

            // send new char string if not empty
            if (!sWorld.GetNewCharString().empty())
                chH.PSendSysMessage("%s", sWorld.GetNewCharString().c_str());
        }
    }

    if (!pCurrChar->GetMap()->Add(pCurrChar))
    {
        // normal delayed teleport protection not applied (and this correct) for this case (Player object just created)
        AreaTrigger const* at = objmgr.GetGoBackTrigger(pCurrChar->GetMapId());
        if (at)
            pCurrChar->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, pCurrChar->GetOrientation());
        else
            pCurrChar->TeleportToHomebind();
    }

    ObjectAccessor::Instance().AddObject(pCurrChar);
    //sLog.outDebug("Player %s added to Map.",pCurrChar->GetName());
    pCurrChar->GetSocial()->SendSocialList();

    pCurrChar->SendInitialPacketsAfterAddToMap();

    CharacterDatabase.PExecute("UPDATE characters SET online = 1 WHERE guid = '%u'", pCurrChar->GetGUIDLow());
    //LoginDatabase.PExecute("UPDATE account SET active_realm_id = %d WHERE id = '%u'", realmID, GetAccountId());
    pCurrChar->SetInGameTime(getMSTime());

    // announce group about member online (must be after add to player list to receive announce to self)
    if (Group *group = pCurrChar->GetGroup())
        group->SendUpdate();

    // friend status
    sSocialMgr.SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUIDLow(), true);

    // Place character in world (and load zone) before some object loading
    pCurrChar->LoadCorpse();

    // setting Ghost+speed if dead
    if (pCurrChar->m_deathState != ALIVE)
    {
        // not blizz like, we must correctly save and load player instead...
        if (pCurrChar->getRace() == RACE_NIGHTELF)
        {
            pCurrChar->CastSpell(pCurrChar, 20584, true, 0);// auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form)
        }
        
            pCurrChar->CastSpell(pCurrChar, 8326, true, 0);     // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?)
            pCurrChar->SetMovement(MOVE_WATER_WALK);
    }

    pCurrChar->ContinueTaxiFlight();

    // Load pet if any and player is alive and not in taxi flight
    if (pCurrChar->isAlive() && pCurrChar->m_taxi.GetTaxiSource() == 0)
        pCurrChar->LoadPet();

    // Set FFA PvP for non GM in non-rest mode
    if (sWorld.IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_RESTING))
        pCurrChar->SetFFAPvP(true);

    if (pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
        pCurrChar->SetContestedPvP();

    // Apply at_login requests
    if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS))
    {
        pCurrChar->resetSpells();
        SendNotification(LANG_RESET_SPELLS);
    }

    if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
    {
        pCurrChar->resetTalents(true);
        SendNotification(LANG_RESET_TALENTS);
    }

    // show time before shutdown if shutdown planned.
    if (sWorld.IsShutdowning())
        sWorld.ShutdownMsg(true,pCurrChar);

    // ImpConfig - Max weapon skill when logging in
    if (sWorld.getConfig(CONFIG_ALWAYS_MAXSKILL))
        pCurrChar->UpdateSkillsToMaxSkillsForLevel();

    if (sWorld.getConfig(CONFIG_ALL_TAXI_PATHS))
        pCurrChar->SetTaxiCheater(true);

    //Reputations if "StartAllReputation" is enabled
    if (sWorld.getConfig(CONFIG_START_ALL_REP))
    {
        pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(942),42999);
        pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(935),42999);
        pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(936),42999);
        pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(1011),42999);
        pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(970),42999);
        pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(967),42999);
        pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(989),42999);
        pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(932),42999);
        pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(934),42999);
        pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(1038),42999);
        pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(1077),42999);
        pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(990),42999);

        // Factions depending on team, like cities and some more stuff
        switch(pCurrChar->GetTeam())
        {
        case ALLIANCE:
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(72),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(47),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(69),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(930),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(730),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(978),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(54),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(946),42999);
            break;
        case HORDE:
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(76),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(68),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(81),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(911),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(729),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(941),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(530),42999);
            pCurrChar->SetFactionReputation(sFactionStore.LookupEntry(947),42999);
            break;
        default:
                break;
        }
    }

    if (pCurrChar->isGameMaster())
        SendNotification(LANG_GM_ON);

    std::string IP_str = GetRemoteAddress();
    sLog.outChar("Account: %d (IP: %s) Login Character:[%s] (guid: %u)",
        GetAccountId(), IP_str.c_str(), pCurrChar->GetName(), pCurrChar->GetGUIDLow());

    m_playerLoading = false;

    //Hook for OnLogin Event
    sScriptMgr.OnLogin(pCurrChar);

    delete holder;
}
Beispiel #21
0
void FollowerAI::GetAIInformation(ChatHandler& reader)
{
    reader.PSendSysMessage("FollowerAI. Player %u [followDistance=%f]. State=0x%x", m_uiLeaderGUID, m_uiFollowDistance, m_uiFollowState);
    ScriptedAI::GetAIInformation(reader);
}
Beispiel #22
0
 void GetAIInformation(ChatHandler& reader)
 {
     reader.PSendSysMessage("Kael'thas is currently in phase %u", m_uiPhase);
 }
Beispiel #23
0
 void GetAIInformation(ChatHandler& reader)
 {
     ScriptedAI::GetAIInformation(reader);
     reader.PSendSysMessage("TYRION: Event running: [%s]", m_IsEventRunning ? "YES" : "NO");
 }
Beispiel #24
0
 void GetAIInformation(ChatHandler& reader) override
 {
     reader.PSendSysMessage("Kael'thas is currently in phase %u", uint32(m_uiPhase));
 }
Beispiel #25
0
void ItemHandler::HandleMsg (NetworkPacket & recv_data, GameClient *pClient)
{
    NetworkPacket data;
    char f[ 256 ];
    sprintf (f, "WORLDSERVER: Item Opcode 0x%.4X", recv_data.opcode);
    LOG.outString (f);
    switch (recv_data.opcode)
    {
        case CMSG_SWAP_INV_ITEM:
        {
            //ok i'm gonna do that a looootttt cleaner :/
            uint8 srcslot, destslot;
            recv_data >> srcslot >> destslot;
            int slot = destslot;

            //START OF LINA LVL REQUIREMENT SWAP PATCH
            int8 CharLvl, ItemLvl;
            //printf("ITEM: LVL TEST\n");
            CharLvl=pClient->getCurrentChar()->getLevel();
            ItemLvl=WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(srcslot))->RequiredLevel;
            //printf("ITEM: CharLvl %d, ItemLvl %d\n", CharLvl, ItemLvl);
            if (CharLvl < ItemLvl)
            {
                ChatHandler * MsgLvlItem = new ChatHandler;
                if(MsgLvlItem  !=NULL)
                {
                    //NEED TO PUT SOME CODE TO UNGRAY ITEM
                    uint8 buf[256];
                    NetworkPacket data;
                    sprintf((char*)buf,"You need the Lvl %d to equip that item.", ItemLvl);
                    MsgLvlItem->FillMessageData(&data, 0x09, pClient, buf);
                    pClient->SendMsg (&data);
                    delete(MsgLvlItem);
                }
                else printf("ITEM: CMSG_SWAP_INV_ITEM can't send message\n");
                return;
            }
            //END OF LINA LVL REQUIREMENT SWAP PATCH

            //these are the bags slots...ignore it for now
            if ((slot <= 22) && (slot >=19))
                destslot = srcslot;

            //check to make sure items are not being put in wrong spots
            if (((srcslot > 23) && (destslot < 19)) || ((srcslot < 23) && (destslot > 19)))
            {
                if ((pClient->getCurrentChar()->getGuidBySlot(destslot) != 0) && (pClient->getCurrentChar()->getGuidBySlot(srcslot) != 0))
                {
                    Item * tmpitem1 = WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(destslot));
                    Item * tmpitem2 = WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(srcslot));
                    if ((tmpitem1 != NULL) && (tmpitem2 != NULL))
                    {
                        if (tmpitem1->Inventorytype != tmpitem2->Inventorytype)
                        {
                            data.Initialize (18, SMSG_INVENTORY_CHANGE_FAILURE);
                            data << uint8(0x0c) ;
                            data << uint32(pClient->getCurrentChar()->getGuidBySlot(destslot));
                            data << uint32(0x00000040);
                            data << uint32(pClient->getCurrentChar()->getGuidBySlot(srcslot));
                            data << uint32(0x00000040);
                            data << uint8(0);
                            pClient->SendMsg (&data);
                            return;
                        }
                    }
                }
            }

            //swap items
            pClient->getCurrentChar()->SwapItemInSlot((int)srcslot, (int)destslot);
            UpdateMask updateMask;
            updateMask.SetLength (PLAYER_FIELDS);

            //error
            if (srcslot == destslot)
            {
                data.Initialize (18, SMSG_INVENTORY_CHANGE_FAILURE);
                data << uint8(0x0c) ;
                data << uint32(pClient->getCurrentChar()->getGuidBySlot(destslot));
                data << uint32(0x00000040);
                data << uint32(pClient->getCurrentChar()->getGuidBySlot(srcslot));
                data << uint32(0x00000040);
                data << uint8(0);
                pClient->SendMsg (&data);
                return;
            }
            pClient->getCurrentChar()->updateItemStats();
            //send to zone players...they don't need to know about the item if the slot is over 19
            if (destslot < 19)
            {
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2),
                    pClient->getCurrentChar()->getGuidBySlot(destslot),
                    updateMask.data);
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2)+1,
                    pClient->getCurrentChar()->getGuidBySlot(destslot) == 0 ? 0 : 0x00000040,
                    updateMask.data);
            }
            if (srcslot < 19)
            {
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (srcslot*2),
                    pClient->getCurrentChar()->getGuidBySlot(srcslot),
                    updateMask.data);
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (srcslot*2)+1,
                    pClient->getCurrentChar()->getGuidBySlot(srcslot) == 0 ? 0 : 0x00000040,
                    updateMask.data);
            }

            pClient->getCurrentChar ()->UpdateObject (&updateMask, &data);
            //              WORLDSERVERSERVER.SendZoneMessage(&data, pClient, 0);
            pClient->getCurrentChar()->SendMessageToSet(&data, false);

            //send update to the player
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2),
                pClient->getCurrentChar()->getGuidBySlot(destslot),
                updateMask.data);
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2)+1,
                pClient->getCurrentChar()->getGuidBySlot(destslot) == 0 ? 0 : 0x00000040,
                updateMask.data);
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (srcslot*2),
                pClient->getCurrentChar()->getGuidBySlot(srcslot),
                updateMask.data);
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (srcslot*2)+1,
                pClient->getCurrentChar()->getGuidBySlot(srcslot) == 0 ? 0 : 0x00000040,
                updateMask.data);
            pClient->getCurrentChar ()->UpdateObject (&updateMask, &data);
            pClient->SendMsg (&data);

            if ((srcslot < 19) && (destslot < 19))
                return;

            int invcount = srcslot;
            if ((pClient->getCurrentChar()->getGuidBySlot(invcount) != 0) && (srcslot < 19))
            {
                createItemUpdate(&data, pClient, invcount);
                //                  WORLDSERVER.SendZoneMessage(&data, pClient, 0);
                pClient->getCurrentChar()->SendMessageToSet(&data, false);
            }

            invcount = destslot;

            if ((pClient->getCurrentChar()->getGuidBySlot(invcount) != 0) && (destslot < 19))
            {
                createItemUpdate(&data, pClient, invcount);
                //                  WORLDSERVER.SendZoneMessage(&data, pClient, 0);
                pClient->getCurrentChar()->SendMessageToSet(&data, false);
            }
            break;
        }
        case CMSG_DESTROYITEM:
        {
            uint8 srcslot, destslot;
            uint32 itemguid;
            recv_data >> srcslot >> destslot;
            if (WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(destslot)) != NULL)
                srcslot = WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(destslot))->Inventorytype && 0xff;
            else
                return;
            if (pClient->getCurrentChar()->getGuidBySlot(destslot) == 0)
                return;
            itemguid = pClient->getCurrentChar()->getGuidBySlot(destslot);
            pClient->getCurrentChar()->AddItemToSlot(destslot,0,0);

            UpdateMask updateMask;
            updateMask.SetLength (PLAYER_FIELDS);

            if (destslot < 19)
            {
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2),
                    pClient->getCurrentChar()->getGuidBySlot (destslot),
                    updateMask.data);
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2)+1,
                    pClient->getCurrentChar()->getGuidBySlot(destslot) == 0 ? 0 : 0x00000040,
                    updateMask.data);
            }
            pClient->getCurrentChar ()->UpdateObject (&updateMask, &data);
            //              WORLDSERVERSERVER.SendZoneMessage(&data, pClient, 0);
            pClient->getCurrentChar()->SendMessageToSet(&data, false);

            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2),
                pClient->getCurrentChar()->getGuidBySlot(destslot),
                updateMask.data);
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2)+1,
                pClient->getCurrentChar()->getGuidBySlot(destslot) == 0 ? 0 : 0x00000040,
                updateMask.data);
            pClient->getCurrentChar ()->UpdateObject (&updateMask, &data);
            pClient->SendMsg (&data);

            data.Clear();
            data.Initialize(8, SMSG_DESTROY_OBJECT);
            data << itemguid << uint32(0x00000040);
            //              WORLDSERVER.SendZoneMessage(&data, pClient, 1);
            pClient->getCurrentChar()->SendMessageToSet(&data, true);
            break;
        }
        case CMSG_AUTOEQUIP_ITEM:
        {

            uint8 srcslot, destslot;
            recv_data >> srcslot >> destslot;

            int8 CharLvl, ItemLvl;
            //START OF LINA LVL REQUIREMENT AUTOEQUIP PATCH
            CharLvl=pClient->getCurrentChar()->getLevel();
            ItemLvl=WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(destslot))->RequiredLevel;
            //printf("ITEM: CharLvl %d, ItemLvl %d\n", CharLvl, ItemLvl);
            if (CharLvl < ItemLvl)
            {
                ChatHandler * MsgLvlItem = new ChatHandler;
                if (MsgLvlItem != NULL)
                {
                    //NEED TO PUT SOME CODE TO UNGRAY ITEM
                    uint8 buf[256];
                    NetworkPacket data;
                    sprintf((char*)buf,"You need the Lvl %d to equip that item.", ItemLvl);
                    MsgLvlItem->FillMessageData(&data, 0x09, pClient, buf);
                    pClient->SendMsg (&data);
                    delete(MsgLvlItem);
                }
                else printf("ITEM: CMSG_AUTOEQUIP_ITEM can't send message\n");
                return;
            }
            //END OF LINA LVL REQUIREMENT AUTOEQUIP PATCH

            if (WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(destslot)) != NULL)
                srcslot = uint8(WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(destslot))->Inventorytype);
            else
                return;

            if (WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(destslot))->Class == 4)
            {
                if (srcslot < 11)
                    srcslot--;
                else if (srcslot == 11)
                {
                    if (pClient->getCurrentChar()->getGuidBySlot(10) == 0)
                    {
                        srcslot = 10;
                    }
                    else if (pClient->getCurrentChar()->getGuidBySlot(11) == 0)
                    {

                        srcslot = 11;
                    }
                    else
                    {
                        srcslot = destslot;
                    }

                }
                else if (srcslot == 14)
                    srcslot += 2;
                else if (srcslot == 13)
                    srcslot += 2;
                else
                    srcslot = 4;
            }
            else if (WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(destslot))->Class == 2)
            {
                switch (WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(destslot))->SubClass)
                {
                    case 2: case 3: case 16: case 19:
                        srcslot = 17;
                        break;

                    default:
                        srcslot = 15;
                        break;
                }
            }
            else
            {
                srcslot = destslot;
            }

            if (srcslot == destslot)
            {
                data.Initialize (18, SMSG_INVENTORY_CHANGE_FAILURE);
                data << uint8(0x0c) ;
                data << uint32(pClient->getCurrentChar()->getGuidBySlot(destslot));
                data << uint32(0x00000040);
                data << uint32(0) << uint32(0) << uint8(0);
                pClient->SendMsg (&data);
                return;
            }

            pClient->getCurrentChar()->SwapItemInSlot((int)srcslot, (int)destslot);
            UpdateMask updateMask;
            updateMask.SetLength (PLAYER_FIELDS);
            if (destslot < 19)
            {
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2),
                    pClient->getCurrentChar()->getGuidBySlot(destslot),
                    updateMask.data);
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2)+1,
                    pClient->getCurrentChar()->getGuidBySlot(destslot) == 0 ? 0 : 0x00000040,
                    updateMask.data);
            }
            if (srcslot < 19)
            {
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (srcslot*2), pClient->getCurrentChar()->getGuidBySlot(srcslot),
                    updateMask.data);
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (srcslot*2)+1, pClient->getCurrentChar()->getGuidBySlot(srcslot) == 0 ? 0 : 0x00000040,
                    updateMask.data);
            }
            pClient->getCurrentChar ()->UpdateObject (&updateMask, &data);
            //              WORLDSERVERSERVER.SendZoneMessage(&data, pClient, 0);
            pClient->getCurrentChar()->SendMessageToSet(&data, false);

            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2),
                pClient->getCurrentChar()->getGuidBySlot(destslot),
                updateMask.data);
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2)+1,
                pClient->getCurrentChar()->getGuidBySlot(destslot) == 0 ? 0 : 0x00000040,
                updateMask.data);
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (srcslot*2),
                pClient->getCurrentChar()->getGuidBySlot(srcslot),
                updateMask.data);
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (srcslot*2)+1,
                pClient->getCurrentChar()->getGuidBySlot(srcslot) == 0 ? 0 : 0x00000040,
                updateMask.data);
            pClient->getCurrentChar ()->UpdateObject (&updateMask, &data);
            pClient->SendMsg (&data);

            Item *tempitem;
            UpdateMask invUpdateMask;
            int invcount = srcslot;
            invUpdateMask.SetLength (64);
            tempitem = new Item;
            if ((pClient->getCurrentChar()->getGuidBySlot(invcount) != 0) && (srcslot < 19))
            {
                createItemUpdate(&data, pClient, invcount);
                //                  WORLDSERVER.SendZoneMessage(&data, pClient, 0);
                pClient->getCurrentChar()->SendMessageToSet(&data, false);
                delete tempitem;
            }
            else
                delete tempitem;
            invcount = destslot;
            invUpdateMask.SetLength (64);
            tempitem = new Item;
            if (srcslot == destslot)
                return;
            if ((pClient->getCurrentChar()->getGuidBySlot(invcount) != 0) && (destslot < 19))
            {
                createItemUpdate(&data, pClient, invcount);
                //                  WORLDSERVER.SendZoneMessage(&data, pClient, 0);
                pClient->getCurrentChar()->SendMessageToSet(&data, false);

            }
            LOG.outString ("WORLDSERVER: Sent Updated Item slot Masks");
            break;
        }

        case CMSG_ITEM_QUERY_SINGLE:
        {

            int i;
            uint32 itemid, guid1, guid2;
            recv_data >> itemid >> guid1 >> guid2;          // guid is the guid of the ITEM OWNER - NO ITS NOT
            if (WORLDSERVER.GetItem(itemid) == NULL)
                return;
            sprintf (curopcodebuf, "WORLDSERVER: Recvd CMSG_ITEM_QUERY_SINGLE for item id 0x%.8X, guid 0x%.8X 0x%.8X", itemid, guid1, guid2);
            LOG.outString (curopcodebuf);

            Item *tempItem = WORLDSERVER.GetItem(itemid);

            //data.Initialize (413 + tempItem->name1.length() + tempItem->name2.length()  + tempItem->name3.length()  + tempItem->name4.length()  + tempItem->Description.length(), SMSG_ITEM_QUERY_SINGLE_RESPONSE);
            data.Initialize (413 + 12 + tempItem->name1.length() + tempItem->name2.length()  + tempItem->name3.length()  + tempItem->name4.length()  + tempItem->Description.length(), SMSG_ITEM_QUERY_SINGLE_RESPONSE);
            //printf("%d\n", data.length);
            //printf("%s\n%s\n", tempItem->name1.c_str(), tempItem->Description.c_str());
            data << itemid;
            data << tempItem->Class;
            data << tempItem->SubClass;
            data << tempItem->name1.c_str();
            data << tempItem->name2.c_str();
            data << tempItem->name3.c_str();
            data << tempItem->name4.c_str();
            data << tempItem->DisplayInfoID;
            data << tempItem->OverallQualityID;
            data << tempItem->Flags;
            data << tempItem->Buyprice;
            data << tempItem->Sellprice;
            data << tempItem->Inventorytype;
            data << tempItem->AllowableClass;
            data << tempItem->AllowableRace;
            data << tempItem->ItemLevel;
            data << tempItem->RequiredLevel;
            data << tempItem->RequiredSkill;
            data << tempItem->RequiredSkillRank;
            data << uint32(0);                              // other requirements here? - 10 = "Requires Blizzard"
            data << uint32(0);                              // ??? 10 = "Requires Knight"
            data << uint32(0);                              // ??? 10 = "Requires "
            data << tempItem->MaxCount;
            data << tempItem->Stackable;
            data << tempItem->ContainerSlots;
            for(i = 0; i<10; i++)
            {
                data << tempItem->BonusStat[i];
                data << tempItem->BonusAmount[i];
            }
            for(i = 0; i<5; i++)
            {
                data << (float)(tempItem->MinimumDamage[i]);
                data << (float)(tempItem->MaximumDamage[i]);
                data << tempItem->DamageType[i];
            }
            data << tempItem->Resistances[0];               // armor
            data << uint32(0);                              // unknown extra resistance
            data << tempItem->Resistances[2];               // fire
            data << tempItem->Resistances[3];               // nature
            data << tempItem->Resistances[4];               // frost
            data << tempItem->Resistances[5];               // shadow
            data << tempItem->Resistances[1];               // arcane at the end now
            //for(i = 0; i<6; i++)
            //{
            //  data << tempItem->Resistances[i];
            //}

            data << tempItem->Delay;
            data << tempItem->AmmunitionType;
            //data << tempItem->MaxDurability;
            for(i = 0; i<5; i++)
            {
                data << tempItem->SpellID[i];
                data << tempItem->SpellTrigger[i];
                data << tempItem->SpellCharges[i];
                data << tempItem->SpellCooldown[i];
                data << tempItem->SpellCategory[i];
                data << tempItem->SpellCategoryCooldown[i];
            }
            data << tempItem->Bonding;
            if (tempItem->Description.c_str()[0] != 48)
                data << tempItem->Description.c_str();
            else
                data << uint32(0);
            data << tempItem->Pagetext;
            data << tempItem->LanguageID;
            data << tempItem->PageMaterial;
            data << tempItem->StartQuestID;
            data << tempItem->LockID;
            data << tempItem->Material;
            data << tempItem->Sheathetype;
            data << tempItem->Unknown1;
            data << tempItem->Unknown2;

            pClient->SendMsg (&data);
            break;
        }
        case CMSG_SELL_ITEM:
        {
            LOG.outString ("WORLDSERVER: Recieved CMSG_SELL_ITEM");
            uint32 srcguid1, srcguid2, itemguid1, itemguid2,newmoney;
            uint8 amount;
            recv_data >> srcguid1 >> srcguid2;
            recv_data >> itemguid1 >> itemguid2;
            recv_data >> amount;

            if (itemguid1 == 0)
            {
                data.Clear();
                data.Initialize(17, SMSG_SELL_ITEM);
                data << srcguid1 << srcguid2 << itemguid1 << itemguid2 << uint8(0x01);
                pClient->SendMsg (&data);
                return;
            }
            int itemindex = -1,i,check = 0;
            Unit *tempunit;
            tempunit = WORLDSERVER.GetCreature(srcguid1);
            if (tempunit == NULL)
                return;

            for(i = 0; i< 39;i++)
            {
                if (pClient->getCurrentChar()->getGuidBySlot(i) == itemguid1)
                {
                    itemindex = i;
                    break;
                }
            }
            if (itemindex == -1)
            {
                data.Clear();
                data.Initialize(17, SMSG_SELL_ITEM);
                data << srcguid1 << srcguid2 << itemguid1 << itemguid2 << uint8(0x01);
                pClient->SendMsg (&data);
                return;                                     //our player doesn't have this item
            }

            /*****************************************************
             *   i will need to put some stack count check here  *
             *****************************************************/
            if (amount == 0)
                amount = 1;

            //adding this item to the vendor's item list
            for(i=0; i<tempunit->getItemCount();i++)
            {
                if (tempunit->getItemId(i) == pClient->getCurrentChar()->getItemIdBySlot(itemindex))
                {
                    tempunit->setItemAmount(i, tempunit->getItemAmount(i) + amount);
                    check = 1;
                }
            }
            if (check == 0)
            {
                if (tempunit->getItemCount() > 100)
                {
                    data.Clear();
                    data.Initialize(17, SMSG_SELL_ITEM);
                    data << srcguid1 << srcguid2 << itemguid1 << itemguid2 << uint8(0x02);
                    pClient->SendMsg (&data);
                    return;
                }
                else
                    tempunit->addItem(pClient->getCurrentChar()->getItemIdBySlot(itemindex), amount);
            }
            newmoney = WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(itemindex))->Sellprice + pClient->getCurrentChar()->getUpdateValue(PLAYER_FIELD_COINAGE);

            //removing the item from the char's inventory
            pClient->getCurrentChar()->AddItemToSlot(itemindex,0,0);
            //sending a player update
            UpdateMask updateMask;
            updateMask.SetLength (PLAYER_FIELDS);

            if (itemindex < 19)
            {
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (itemindex*2),
                    pClient->getCurrentChar()->getGuidBySlot(itemindex),
                    updateMask.data);
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (itemindex*2)+1,
                    pClient->getCurrentChar()->getGuidBySlot(itemindex) == 0 ? 0 : 0x00000040,
                    updateMask.data);
            }
            pClient->getCurrentChar ()->UpdateObject (&updateMask, &data);
            //WORLDSERVER.SendZoneMessage(&data, pClient, 0);
            pClient->getCurrentChar()->SendMessageToSet(&data, false);

            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_COINAGE, newmoney,
                updateMask.data);
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (itemindex*2),
                pClient->getCurrentChar()->getGuidBySlot(itemindex),
                updateMask.data);
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (itemindex*2)+1,
                pClient->getCurrentChar()->getGuidBySlot(itemindex) == 0 ? 0 : 0x00000040,
                updateMask.data);
            pClient->getCurrentChar ()->UpdateObject (&updateMask, &data);
            pClient->SendMsg (&data);

            //send an SMSG_SELL_ITEM
            data.Clear();
            data.Initialize(17, SMSG_SELL_ITEM);
            data << srcguid1 << srcguid2 << itemguid1 << itemguid2 << uint8(0x05);
            pClient->SendMsg (&data);

            //send an object destroy packet
            data.Clear();
            data.Initialize(8, SMSG_DESTROY_OBJECT);
            data << itemguid1 << uint32(0x00000040);
            //              WORLDSERVER.SendZoneMessage(&data, pClient, 1);
            pClient->getCurrentChar()->SendMessageToSet(&data, true);
            break;
        }

        case CMSG_BUY_ITEM_IN_SLOT:
        {
            LOG.outString ("WORLDSERVER: Recieved CMSG_BUY_ITEM_IN_SLOT");
            uint32 srcguid1, srcguid2, itemid, destguid1, destguid2;
            uint8 slot, amount;
            recv_data >> srcguid1 >> srcguid2 >> itemid;
            recv_data >> destguid1 >> destguid2;
            recv_data >> slot;
            recv_data >> amount;
            int itemindex,i,varify = 0;
            Unit *tempunit;
            tempunit = WORLDSERVER.GetCreature(srcguid1);
            if (tempunit == NULL)
                return;

            if (slot > 38)
                return;
            if (slot < 19)
                return;
            if ((slot <= 22) && (slot >=19))
                return;                                     //these are the bags slots...i'm not sure exactly how to use them
            if (pClient->getCurrentChar()->getGuidBySlot(slot) != 0)
                return;                                     //slot is not empty...i'll have to make code to check for other slots
            for(i = 0; i< tempunit->getItemCount();i++)
            {
                if (tempunit->getItemId(i) == itemid)
                {
                    varify = 1;
                    break;
                }
            }
            if (varify == 0)
                return;                                     //our vendor doesn't have this item
            itemindex = i;
            if (amount > tempunit->getItemAmount(i))
                return;                                     //our vendor doesn't have the required amount of that item
            tempunit->setItemAmountById(itemid,tempunit->getItemAmount(i) - amount);

            //START OF LINA BUY PATCH
                                                            //INFO
            printf("ARGENT: %d, COUT: %d\n", (pClient->getCurrentChar()->getUpdateValue(PLAYER_FIELD_COINAGE)), (WORLDSERVER.GetItem(tempunit->getItemId(itemindex))->Buyprice));
            int32 newmoney;
                                                            //LINA
            newmoney = ((pClient->getCurrentChar()->getUpdateValue(PLAYER_FIELD_COINAGE)) - (WORLDSERVER.GetItem(tempunit->getItemId(itemindex))->Buyprice));
            printf("DIF: %d\n",newmoney);                   //INFO
            if(newmoney < 0)
            {
                ChatHandler * MsgGold = new ChatHandler;
                if (MsgGold != NULL)
                {
                    uint8 buf[256];
                    NetworkPacket data;
                    sprintf((char*)buf,"You need %i to buy this item.", abs(newmoney));
                    MsgGold->FillMessageData(&data, 0x09, pClient, buf);
                    pClient->SendMsg (&data);
                    delete(MsgGold);
                }
                else printf("ITEM: CMSG_BUY_ITEM_IN_SLOT can't send message\n");
                return;
            }
            //END OF LINA BUY PATCH

            WORLDSERVER.m_hiItemGuid++;
            std::string templog;
            char tempiid[10];
            sprintf(tempiid,"%d",WORLDSERVER.m_hiItemGuid);
            templog = "Created Item. Guid: ";
            templog+= tempiid;

            LOG.outString (templog.c_str());

            pClient->getCurrentChar()->AddItemToSlot(slot,WORLDSERVER.m_hiItemGuid,itemid);

            data.Clear();
            data.Initialize(16, SMSG_BUY_ITEM);
            data << uint32(srcguid1) << uint32(srcguid2);
            data << uint32(itemid) << uint32(amount);
            pClient->SendMsg (&data);

            Item *tempitem;

            UpdateMask invUpdateMask;

            int invcount = slot;
            invUpdateMask.SetLength (64);
            tempitem = new Item;

            createItemUpdate(&data, pClient, invcount);

            if (slot > 23)
                pClient->SendMsg (&data);
            else
            {
                //                  WORLDSERVER.SendZoneMessage(&data, pClient, 0);
                pClient->getCurrentChar()->SendMessageToSet(&data, true);
                //                  pClient->SendMsg (&data);
            }
            delete tempitem;

            UpdateMask updateMask;
            updateMask.SetLength (PLAYER_FIELDS);
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_COINAGE, newmoney,
                updateMask.data);                           //LINA BUY PATCH NEXT
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (slot*2),
                pClient->getCurrentChar()->getGuidBySlot(slot),
                updateMask.data);
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (slot*2)+1,
                pClient->getCurrentChar()->getGuidBySlot(slot) == 0 ? 0 : 0x00000040,
                updateMask.data);
            pClient->getCurrentChar ()->UpdateObject (&updateMask, &data);
            if (slot > 23)
                pClient->SendMsg (&data);
            else
            {
                //                  WORLDSERVER.SendZoneMessage(&data, pClient, 0);
                pClient->getCurrentChar()->SendMessageToSet(&data, true);
                //                  pClient->SendMsg (&data);
            }
            break;
        }
        case CMSG_BUY_ITEM:                                 //right click
        {
            LOG.outString ("WORLDSERVER: Recieved CMSG_BUY_ITEM");
            uint32 srcguid1, srcguid2, itemid;
            uint8 slot, amount;
            recv_data >> srcguid1 >> srcguid2 >> itemid;
            recv_data >> amount >> slot;
            int itemindex,i,varify = 0;
            Unit *tempunit;
            tempunit = WORLDSERVER.GetCreature(srcguid1);
            if (tempunit == NULL)
                return;
            slot = 0;
            for(i = 23; i <= 38; i++)
            {
                if (pClient->getCurrentChar()->getGuidBySlot(i) == 0)
                {
                    slot = i;
                    break;
                }
            }
            if (slot == 0)
                return;
            for(i = 0; i< tempunit->getItemCount();i++)
            {
                if (tempunit->getItemId(i) == itemid)
                {
                    varify = 1;
                    break;
                }
            }
            if (varify == 0)
                return;                                     //our vendor doesn't have this item
            itemindex = i;
            if (amount > tempunit->getItemAmount(i))
                return;                                     //our vendor doesn't have the required amount of that item
            tempunit->setItemAmountById(itemid,tempunit->getItemAmount(i) - amount);

            //START OF LINA BUY PATCH
                                                            //INFO
            printf("ARGENT: %d, COUT: %d\n", (pClient->getCurrentChar()->getUpdateValue(PLAYER_FIELD_COINAGE)), (WORLDSERVER.GetItem(tempunit->getItemId(itemindex))->Buyprice));
            int32 newmoney;
                                                            //LINA
            newmoney = ((pClient->getCurrentChar()->getUpdateValue(PLAYER_FIELD_COINAGE)) - (WORLDSERVER.GetItem(tempunit->getItemId(itemindex))->Buyprice));
            printf("DIF: %d\n",newmoney);                   //INFO
            if(newmoney < 0)
            {
                //NEED TO PUT SOME CODE TO UNGRAY ITEM AND SEND A MESSAGE TO PLAYER
                ChatHandler * MsgGold = new ChatHandler;
                if (MsgGold != NULL)
                {
                    uint8 buf[256];
                    NetworkPacket data;
                    sprintf((char*)buf,"You need %i to buy this item.", abs(newmoney));
                    MsgGold->FillMessageData(&data, 0x09, pClient, buf);
                    pClient->SendMsg (&data);
                    delete(MsgGold);
                }
                else printf("ITEM: CMSG_BUY_ITEM can't send message\n");
                return;
            }
            //END OF LINA BUY PATCH

            WORLDSERVER.m_hiItemGuid++;
            std::string templog;
            char tempiid[10];
            sprintf(tempiid,"%d",WORLDSERVER.m_hiItemGuid);
            templog = "Created Item. Guid: ";
            templog+= tempiid;

            LOG.outString (templog.c_str());

            pClient->getCurrentChar()->AddItemToSlot(slot,WORLDSERVER.m_hiItemGuid,itemid);

            UpdateMask invUpdateMask;

            int invcount = slot;
            invUpdateMask.SetLength (64);

            createItemUpdate(&data, pClient, invcount);

            if (slot > 23)
                pClient->SendMsg (&data);
            else
            {
                //                  WORLDSERVER.SendZoneMessage(&data, pClient, 0);
                pClient->getCurrentChar()->SendMessageToSet(&data, true);
                //                  pClient->SendMsg (&data);
            }

            UpdateMask updateMask;
            updateMask.SetLength (PLAYER_FIELDS);
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_COINAGE, newmoney,
                updateMask.data);                           //LINA BUY PATCH NEXT
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (slot*2),
                pClient->getCurrentChar()->getGuidBySlot(slot),
                updateMask.data);
            pClient->getCurrentChar ()->setUpdateValue (
                PLAYER_FIELD_INV_SLOT_HEAD  + (slot*2)+1,
                pClient->getCurrentChar()->getGuidBySlot(slot) == 0 ? 0 : 0x00000040,
                updateMask.data);
            pClient->getCurrentChar ()->UpdateObject (&updateMask, &data);
            if (slot > 23)
                pClient->SendMsg (&data);
            else
            {
                //                  WORLDSERVER.SendZoneMessage(&data, pClient, 0);
                pClient->getCurrentChar()->SendMessageToSet(&data, false);
                //                  pClient->SendMsg (&data);
            }
            break;
        }

        case CMSG_LIST_INVENTORY:
        {
            LOG.outString ("WORLDSERVER: Recvd CMSG_LIST_INVENTORY Message");
            uint32 guid1, guid2;
            //guid1+guid2 = npc's full uint64 guid

            recv_data >> guid1 >> guid2;
            Unit *tempunit;
            tempunit = WORLDSERVER.GetCreature(guid1);
            if (tempunit == NULL)
                return;
            uint8 numitems = (uint8)tempunit->getItemCount();

            if (numitems == 0)
                return;

            data.Initialize (8 + 1 + numitems * 7 * 4, SMSG_LIST_INVENTORY);
            data << guid1 << guid2;
            data << uint8 (numitems);                       // num items

            // each item has seven uint32's
            Item * curItem;
            for(uint8 itemcount = 0; itemcount < numitems; itemcount ++)
            {
                curItem = WORLDSERVER.GetItem(tempunit->getItemId(itemcount));
                if (!curItem)
                {
                    LOG.outError ("Unit %i has nonexistant item %i!", guid1, tempunit->getItemId(itemcount));
                    LOG.outString ("WORLDSERVER: DID NOT Send SMSG_LIST_INVENTORY Message");
                    for (int a = 0; a < 7; a ++) data << uint32 (0);
                }
                else
                {
                    data << uint32 (itemcount + 1);         // index ? doesn't seem to affect anything
                                                            // item id
                    data << uint32 (tempunit->getItemId(itemcount));
                    data << uint32 (curItem->DisplayInfoID);// item icon
                                                            // number of items available, -1 works for infinity, although maybe just 'cause it's really big
                    data << uint32 (tempunit->getItemAmount(itemcount));
                    data << uint32 (curItem->Buyprice);     // price
                    data << uint32 (0);                     // ?
                    data << uint32 (0);                     // ?
                }
            }

            //data.WriteData (tdata, sizeof (tdata));
            pClient->SendMsg (&data);
            LOG.outString ("WORLDSERVER: Sent SMSG_LIST_INVENTORY Message");
            break;
        }
    }
}