Bgames
Olá visitante! Seja bem vindo ao nosso fórum!

Para você ter total acesso ao nosso fórum é preciso que você se cadastre.

Cadastre-se Aqui!


PARA VER LINKS E IMAGENS É PRECISO SE REGISTRAR!

Script C++

Ver o tópico anterior Ver o tópico seguinte Ir em baixo

Script C++

Mensagem por FooFKnight em Sex 14 Dez 2012 - 13:33

Ola,
Gostaria que alguém pudesse atualizar este Script C++ pra mim !
Ficaria muito Grato
Código:
From e1e162eafe122eda49b31b93e91596550ec139db Mon Sep 17 00:00:00 2001
From: unknown <Poison@NTI-dator.(none)>
Date: Mon, 9 Apr 2012 20:53:04 +0200
Subject: [PATCH] Armory Patch

---
 src/server/game/Achievements/AchievementMgr.cpp |    6 ++
 src/server/game/Battlegrounds/Battleground.cpp  |  52 +++++++++++++++
 src/server/game/Battlegrounds/Battleground.h    |    8 +++
 src/server/game/Entities/Item/Item.cpp          |  11 +++
 src/server/game/Entities/Player/Player.cpp      |  76 +++++++++++++++++++++++
 src/server/game/Entities/Player/Player.h        |  21 ++++++
 src/server/game/Entities/Unit/Unit.cpp          |  20 ++++++
 src/server/game/World/World.cpp                |    4 +
 src/server/game/World/World.h                  |    1 +
 src/server/worldserver/worldserver.conf.dist    |    7 ++
 10 files changed, 206 insertions(+), 0 deletions(-)

diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp
index 2a9f421..9837cf3 100755
--- a/src/server/game/Achievements/AchievementMgr.cpp
+++ b/src/server/game/Achievements/AchievementMgr.cpp
@@ -2039,6 +2039,12 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement)
        return;
 
    SendAchievementEarned(achievement);
+
+   /** World of Warcraft Armory **/
+    if (sWorld->getBoolConfig(CONFIG_ARMORY_ENABLE))
+        GetPlayer()->CreateWowarmoryFeed(1, achievement->ID, 0, 0);
+    /** World of Warcraft Armory **/
+
    CompletedAchievementData& ca = m_completedAchievements[achievement->ID];
    ca.date = time(NULL);
    ca.changed = true;
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index f3c393e..6b1d680 100755
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -746,6 +746,50 @@ void Battleground::EndBattleground(uint32 winner)
                SetArenaMatchmakerRating(GetOtherTeam(winner), loser_matchmaker_rating + loser_matchmaker_change);
                SetArenaTeamRatingChangeForTeam(winner, winner_change);
                SetArenaTeamRatingChangeForTeam(GetOtherTeam(winner), loser_change);
+                            /** World of Warcraft Armory **/
+                if (sWorld->getBoolConfig(CONFIG_ARMORY_ENABLE))
+                {
+                    uint32 maxChartID;
+                    QueryResult result = CharacterDatabase.PQuery("SELECT MAX(gameid) FROM armory_game_chart");
+                    if(!result)
+                        maxChartID = 0;
+                    else
+                    {
+                        maxChartID = (*result)[0].GetUInt32();
+                        [Você precisa estar registrado e conectado para ver este link.]
+                    }
+                    uint32 gameID = maxChartID+1;
+                    for(BattlegroundScoreMap::const_iterator itr = PlayerScores.begin(); itr != PlayerScores.end(); ++itr)
+                    {
+                        Player* player = ObjectAccessor::FindPlayer(itr->first);
+                        if (!player)
+                            continue;
+                        uint32 plTeamID = player->GetArenaTeamId(winner_arena_team->GetSlot());
+                        int changeType;
+                        uint32 resultRating;
+                        uint32 resultTeamID;
+                        int32 ratingChange;
+                        if (plTeamID == winner_arena_team->GetId())
+                        {
+                            changeType = 1; //win
+                            resultRating = winner_team_rating;
+                            resultTeamID = plTeamID;
+                            ratingChange = winner_change;
+                        }
+                        else
+                        {
+                            changeType = 2; //lose
+                            resultRating = loser_team_rating;
+                            resultTeamID = loser_arena_team->GetId();
+                            ratingChange = loser_change;
+                        }
+                        std::ostringstream sql_query;
+                        //                                                        gameid,              teamid,                    guid,                    changeType,            ratingChange,              teamRating,                  damageDone,                          deaths,                          healingDone,                          damageTaken,,                          healingTaken,                        killingBlows,                      mapId,                start,                  end
+                        sql_query << "INSERT INTO armory_game_chart VALUES ('" << gameID << "', '" << resultTeamID << "', '" << player->GetGUID() << "', '" << changeType << "', '" << ratingChange  << "', '" << resultRating << "', '" << itr->second->DamageDone << "', '" << itr->second->Deaths << "', '" << itr->second->HealingDone << "', '" << itr->second->DamageTaken << "', '" << itr->second->HealingTaken << "', '" << itr->second->KillingBlows << "', '" << m_MapId << "', '" << m_StartTime << "', '" << m_EndTime << "')";
+                        CharacterDatabase.Execute(sql_query.str().c_str());
+                    }
+                }
+                /** World of Warcraft Armory **/
                sLog->outArena("Arena match Type: %u for Team1Id: %u - Team2Id: %u ended. WinnerTeamId: %u. Winner rating: +%d, Loser rating: %d", m_ArenaType, m_ArenaTeamIds[BG_TEAM_ALLIANCE], m_ArenaTeamIds[BG_TEAM_HORDE], winner_arena_team->GetId(), winner_change, loser_change);
                if (sWorld->getBoolConfig(CONFIG_ARENA_LOG_EXTENDED_INFO))
                    for (Battleground::BattlegroundScoreMap::const_iterator itr = GetPlayerScoresBegin(); itr != GetPlayerScoresEnd(); ++itr)
@@ -1361,6 +1405,14 @@ void Battleground::UpdatePlayerScore(Player* Source, uint32 type, uint32 value,
        case SCORE_HEALING_DONE:                            // Healing Done
            itr->second->HealingDone += value;
            break;
+                 /** World of Warcraft Armory **/
+        case SCORE_DAMAGE_TAKEN:
+            itr->second->DamageTaken += value;              // Damage Taken
+            break;
+        case SCORE_HEALING_TAKEN:
+            itr->second->HealingTaken += value;            // Healing Taken
+            break;
+        /** World of Warcraft Armory **/
        default:
            sLog->outError("Battleground::UpdatePlayerScore: unknown score type (%u) for BG (map: %u, instance id: %u)!",
                type, m_MapId, m_InstanceID);
diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h
index 32f6ebc..107617e 100755
--- a/src/server/game/Battlegrounds/Battleground.h
+++ b/src/server/game/Battlegrounds/Battleground.h
@@ -210,6 +210,10 @@ enum ScoreType
    //SOTA
    SCORE_DESTROYED_DEMOLISHER  = 18,
    SCORE_DESTROYED_WALL        = 19,
+       /** World of Warcraft Armory **/
+    SCORE_DAMAGE_TAKEN          = 20,
+    SCORE_HEALING_TAKEN        = 21
+    /** World of Warcraft Armory **/
 };
 
 enum ArenaType
@@ -292,6 +296,10 @@ class BattlegroundScore
        uint32 BonusHonor;
        uint32 DamageDone;
        uint32 HealingDone;
+      /** World of Warcraft Armory **/
+        uint32 DamageTaken;
+        uint32 HealingTaken;
+        /** World of Warcraft Armory **/
 };
 
 enum BGHonorMode
diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp
index f2b8938..8d3f66f 100755
--- a/src/server/game/Entities/Item/Item.cpp
+++ b/src/server/game/Entities/Item/Item.cpp
@@ -276,6 +276,17 @@ bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
 
    SetUInt32Value(ITEM_FIELD_DURATION, abs(itemProto->Duration));
    SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, 0);
+   /** World of Warcraft Armory **/
+    if (sWorld->getBoolConfig(CONFIG_ARMORY_ENABLE))
+    {
+        if (itemProto->Quality > 2 && itemProto->Flags != 2048 && (itemProto->Class == ITEM_CLASS_WEAPON || itemProto->Class == ITEM_CLASS_ARMOR))
+        {
+            if (!GetOwner())
+                return true;
+            GetOwner()->CreateWowarmoryFeed(2, itemid, guidlow, itemProto->Quality);
+        }
+    }
+    /** World of Warcraft Armory **/
    return true;
 }
 
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 1fa88ce..78b6e63 100755
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -5064,6 +5064,12 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
            stmt->setUInt32(0, guid);
            trans->Append(stmt);
 
+         /* World of Warcraft Armory */
+            trans->PAppend("DELETE FROM armory_character_stats WHERE guid = '%u'",guid);
+            trans->PAppend("DELETE FROM character_feed_log WHERE guid = '%u'",guid);
+            /* World of Warcraft Armory */
+
+
            CharacterDatabase.CommitTransaction(trans);
            break;
        }
@@ -16801,6 +16807,8 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
 
        return false;
    }
+   // Cleanup old Wowarmory feeds
+    InitWowarmoryFeeds();
 
    // overwrite possible wrong/corrupted guid
    SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER));
@@ -18918,6 +18926,33 @@ void Player::SaveToDB(bool create /*=false*/)
 
    CharacterDatabase.CommitTransaction(trans);
 
+       /* World of Warcraft Armory */
+    // Place this code AFTER CharacterDatabase.CommitTransaction(); to avoid some character saving errors.
+    // Wowarmory feeds
+    if (sWorld->getBoolConfig(CONFIG_ARMORY_ENABLE))
+    {
+        std::ostringstream sWowarmory;
+        for (WowarmoryFeeds::iterator iter = m_wowarmory_feeds.begin(); iter < m_wowarmory_feeds.end(); ++iter) {
+            sWowarmory << "INSERT IGNORE INTO character_feed_log (guid,type,data,date,counter,difficulty,item_guid,item_quality) VALUES ";
+            //                      guid                    type                        data                    date                            counter                  difficulty                        item_guid                      item_quality
+            sWowarmory << "(" << (*iter).guid << ", " << (*iter).type << ", " << (*iter).data << ", " << uint64((*iter).date) << ", " << (*iter).counter << ", " << uint32((*iter).difficulty) << ", " << (*iter).item_guid << ", " << (*iter).item_quality <<  ");";
+            CharacterDatabase.PExecute(sWowarmory.str().c_str());
+            sWowarmory.str("");
+        }
+        // Clear old saved feeds from storage - they are not required for server core.
+        InitWowarmoryFeeds();
+        // Character stats
+        std::ostringstream ps;
+        time_t t = time(NULL);
+        CharacterDatabase.PExecute("DELETE FROM armory_character_stats WHERE guid = %u", GetGUIDLow());
+        ps << "INSERT INTO armory_character_stats (guid, data, save_date) VALUES (" << GetGUIDLow() << ", '";
+        for (uint16 i = 0; i < m_valuesCount; ++i)
+            ps << GetUInt32Value(i) << " ";
+        ps << "', " << uint64(t) << ");";
+        CharacterDatabase.PExecute(ps.str().c_str());
+    }
+    /* World of Warcraft Armory */
+
    // save pet (hunter pet level and experience and all type pets health/mana).
    if (Pet* pet = GetPet())
        pet->SavePetToDB(PET_SAVE_AS_CURRENT);
@@ -25515,6 +25550,47 @@ void Player::_SaveInstanceTimeRestrictions(SQLTransaction& trans)
    }
 }
 
+/** World of Warcraft Armory **/
+void Player::InitWowarmoryFeeds() {
+    // Clear feeds
+    m_wowarmory_feeds.clear();
+}
+
+void Player::CreateWowarmoryFeed(uint32 type, uint32 data, uint32 item_guid, uint32 item_quality) {
+    /*
+        1 - TYPE_ACHIEVEMENT_FEED
+        2 - TYPE_ITEM_FEED
+        3 - TYPE_BOSS_FEED
+    */
+    if (GetGUIDLow() == 0)
+    {
+        sLog->outError("[Wowarmory]: player is not initialized, unable to create log entry!");
+        return;
+    }
+    if (type <= 0 || type > 3)
+    {
+        sLog->outError("[Wowarmory]: unknown feed type: %d, ignore.", type);
+        return;
+    }
+    if (data == 0)
+    {
+        sLog->outError("[Wowarmory]: empty data (GUID: %u), ignore.", GetGUIDLow());
+        return;
+    }
+    WowarmoryFeedEntry feed;
+    feed.guid = GetGUIDLow();
+    feed.type = type;
+    feed.data = data;
+    feed.difficulty = type == 3 ? GetMap()->GetDifficulty() : 0;
+    feed.item_guid  = item_guid;
+    feed.item_quality = item_quality;
+    feed.counter = 0;
+    feed.date = time(NULL);
+    sLog->outDebug(LOG_FILTER_UNITS, "[Wowarmory]: create wowarmory feed (GUID: %u, type: %d, data: %u).", feed.guid, feed.type, feed.data);
+    m_wowarmory_feeds.push_back(feed);
+}
+/** World of Warcraft Armory **/
+
 bool Player::IsInWhisperWhiteList(uint64 guid)
 {
    for (WhisperListContainer::const_iterator itr = WhisperList.begin(); itr != WhisperList.end(); ++itr)
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 1b80b68..7be0d58 100755
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1057,6 +1057,21 @@ private:
    bool _isPvP;
 };
 
+/* World of Warcraft Armory */
+struct WowarmoryFeedEntry {
+    uint32 guid;        // Player GUID
+    time_t date;        // Log date
+    uint32 type;        // TYPE_ACHIEVEMENT_FEED, TYPE_ITEM_FEED, TYPE_BOSS_FEED
+    uint32 data;        // TYPE_ITEM_FEED: item_entry, TYPE_BOSS_FEED: creature_entry
+    uint32 item_guid;    // Can be 0
+    uint32 item_quality; // Can be 0
+    uint8  difficulty;  // Can be 0
+    int    counter;      // Can be 0
+};
+
+typedef std::vector<WowarmoryFeedEntry> WowarmoryFeeds;
+/* World of Warcraft Armory */
+
 class Player : public Unit, public GridObject<Player>
 {
    friend class WorldSession;
@@ -2357,6 +2372,10 @@ class Player : public Unit, public GridObject<Player>
        void SendCinematicStart(uint32 CinematicSequenceId);
        void SendMovieStart(uint32 MovieId);
 
+       /* World of Warcraft Armory */
+        void CreateWowarmoryFeed(uint32 type, uint32 data, uint32 item_guid, uint32 item_quality);
+        void InitWowarmoryFeeds();
+        /* World of Warcraft Armory */
        /*********************************************************/
        /***                INSTANCE SYSTEM                  ***/
        /*********************************************************/
@@ -2856,6 +2875,8 @@ class Player : public Unit, public GridObject<Player>
        uint32 m_timeSyncTimer;
        uint32 m_timeSyncClient;
        uint32 m_timeSyncServer;
+      // World of Warcraft Armory Feeds
+        WowarmoryFeeds m_wowarmory_feeds;
 
        InstanceTimeMap _instanceResetTimes;
        uint32 _pendingBindId;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 5226919..5ac1770 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -699,8 +699,17 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
 
        // in bg, count dmg if victim is also a player
        if (victim->GetTypeId() == TYPEID_PLAYER)
+      {
            if (Battleground* bg = killer->GetBattleground())
+         {
                bg->UpdatePlayerScore(killer, SCORE_DAMAGE_DONE, damage);
+      /** World of Warcraft Armory **/
+                if (sWorld->getBoolConfig(CONFIG_ARMORY_ENABLE))
+                    if (Battleground *bgV = ((Player*)victim)->GetBattleground())
+                        bgV->UpdatePlayerScore(((Player*)victim), SCORE_DAMAGE_TAKEN, damage);
+                /** World of Warcraft Armory **/
+            }
+        }
 
        killer->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, damage, 0, victim);
        killer->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT, damage);
@@ -10103,6 +10112,11 @@ int32 Unit::DealHeal(Unit* victim, uint32 addhealth)
    {
        player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED, gain);
        player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED, addhealth);
+      /** World of Warcraft Armory **/
+        if (sWorld->getBoolConfig(CONFIG_ARMORY_ENABLE))
+            if (Battleground *bgV = victim->ToPlayer()->GetBattleground())
+                bgV->UpdatePlayerScore((Player*)victim, SCORE_HEALING_TAKEN, gain);
+        /** World of Warcraft Armory **/
    }
 
    return gain;
@@ -15646,7 +15660,13 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
                if (instanceMap->IsRaidOrHeroicDungeon())
                {
                    if (creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
+               {
                        ((InstanceMap*)instanceMap)->PermBindAllPlayers(creditedPlayer);
+               /** World of Warcraft Armory **/
+                        if (sWorld->getBoolConfig(CONFIG_ARMORY_ENABLE))
+                            creditedPlayer->CreateWowarmoryFeed(3, creature->GetCreatureTemplate()->Entry, 0, 0);
+                        /** World of Warcraft Armory **/
+                    }
                }
                else
                {
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 6e32d33..a3ed8e9 100755
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -1193,6 +1193,10 @@ void World::LoadConfigSettings(bool reload)
    m_int_configs[CONFIG_AUTOBROADCAST_CENTER] = ConfigMgr::GetIntDefault("AutoBroadcast.Center", 0);
    m_int_configs[CONFIG_AUTOBROADCAST_INTERVAL] = ConfigMgr::GetIntDefault("AutoBroadcast.Timer", 60000);
 
+   /** World of Warcraft Armory **/
+    m_bool_configs[CONFIG_ARMORY_ENABLE] = ConfigMgr::GetBoolDefault("Armory.Enable", true);
+    /** World of Warcraft Armory **/
+
    // MySQL ping time interval
    m_int_configs[CONFIG_DB_PING_INTERVAL] = ConfigMgr::GetIntDefault("MaxPingTime", 30);
 
diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
index 95e9fbd..5896839 100755
--- a/src/server/game/World/World.h
+++ b/src/server/game/World/World.h
@@ -159,6 +159,7 @@ enum WorldBoolConfigs
    CONFIG_ALLOW_TICKETS,
    CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES,
    CONFIG_PRESERVE_CUSTOM_CHANNELS,
+   CONFIG_ARMORY_ENABLE,
    CONFIG_PDUMP_NO_PATHS,
    CONFIG_PDUMP_NO_OVERWRITE,
    CONFIG_QUEST_IGNORE_AUTO_ACCEPT,
diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
index 5d83710..d858118 100644
--- a/src/server/worldserver/worldserver.conf.dist
+++ b/src/server/worldserver/worldserver.conf.dist
@@ -2878,5 +2878,12 @@ PlayerDump.DisallowPaths = 1
 
 PlayerDump.DisallowOverwrite = 1
 
+#    Armory.Enable
+#        Description: Activates the WowArmory.
+#        Default:    0 - (Disable)
+#                    1 - (Enable)
+
+Armory.Enable = 1
+
 #
 ###################################################################################################
--
1.7.8.msysgit.0

FooFKnight


Mensagens : 679
Pontos : 679
Evolução : 2


Ver perfil do usuário http://www.hostbrazill.com/

Voltar ao Topo Ir em baixo

Ver o tópico anterior Ver o tópico seguinte Voltar ao Topo


 
Permissão deste fórum:
Você não pode responder aos tópicos neste fórum