/
wowarmory_feed_9519.patch
112 lines (107 loc) · 5.17 KB
/
wowarmory_feed_9519.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp
index 0c27304..c65ff84 100644
--- a/src/game/AchievementMgr.cpp
+++ b/src/game/AchievementMgr.cpp
@@ -1776,6 +1776,8 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry,
void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement)
{
sLog.outDetail("AchievementMgr::CompletedAchievement(%u)", achievement->ID);
+ /* WoWArmory Feed Log */
+ GetPlayer()->WriteWowArmoryDatabaseLog(1, achievement->ID);
if(achievement->flags & ACHIEVEMENT_FLAG_COUNTER || m_completedAchievements.find(achievement->ID)!=m_completedAchievements.end())
return;
diff --git a/src/game/Item.cpp b/src/game/Item.cpp
index b460b57..7fa5153 100644
--- a/src/game/Item.cpp
+++ b/src/game/Item.cpp
@@ -953,6 +953,24 @@ Item* Item::CreateItem( uint32 item, uint32 count, Player const* player )
if ( count > pProto->GetMaxStackSize())
count = pProto->GetMaxStackSize();
+ if (pProto->Quality > 2 && pProto->Flags != 2048 && (pProto->Class == ITEM_CLASS_WEAPON || pProto->Class == ITEM_CLASS_ARMOR) && player)
+ {
+ /* WoWArmory Feed Log */
+ std::ostringstream ss;
+ QueryResult *result = CharacterDatabase.PQuery("SELECT counter FROM character_feed_log WHERE guid='%u' AND type=2 AND data='%u' LIMIT 1", player->GetGUIDLow(), item);
+ if(result)
+ {
+ sLog.outDetail("WoWArmory: write feed log (guid: %u, type: 2, data: %u", player->GetGUIDLow(), item);
+ ss << "UPDATE character_feed_log SET counter=counter+1, date=NOW() WHERE guid=" << player->GetGUIDLow() << " AND type=2 AND data=" << item << " LIMIT 1";
+ CharacterDatabase.PExecute( ss.str().c_str() );
+ }
+ else
+ {
+ sLog.outDetail("WoWArmory: write feed log (guid: %u, type: 2, data: %u", player->GetGUIDLow(), item);
+ ss << "INSERT INTO character_feed_log (guid, type, data, counter) VALUES (" << player->GetGUIDLow() << ", 2, " << item << ", 1)";
+ CharacterDatabase.PExecute( ss.str().c_str() );
+ }
+ delete result;
+ }
assert(count !=0 && "pProto->Stackable==0 but checked at loading already");
Item *pItem = NewItemOrBag( pProto );
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 893b803..f37ccd3 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -21688,4 +21688,29 @@ void Player::SetHomebindToLocation(WorldLocation const& loc, uint32 area_id)
m_homebindMapId, m_homebindAreaId, m_homebindX, m_homebindY, m_homebindZ, GetGUIDLow());
}
-
+void Player::WriteWowArmoryDatabaseLog(uint32 type, uint32 data)
+{
+ uint32 pGuid = GetGUIDLow();
+ sLog.outDetail("WoWArmory: write feed log (guid: %u, type: %u, data: %u", pGuid, type, data);
+ if (type <= 0) // Unknown type
+ {
+ sLog.outError("WoWArmory: unknown type id: %d, ignore.", type);
+ return;
+ }
+ if (type == 3) // Do not write same bosses many times - just update counter.
+ {
+ QueryResult *result = CharacterDatabase.PQuery("SELECT counter FROM character_feed_log WHERE guid='%u' AND type=3 AND data='%u' LIMIT 1", pGuid, data);
+ if (result)
+ {
+ CharacterDatabase.PExecute("UPDATE character_feed_log SET counter=counter+1, date=NOW() WHERE guid='%u' AND type=3 AND data='%u' LIMIT 1", pGuid, data);
+ }
+ else
+ {
+ CharacterDatabase.PExecute("INSERT INTO character_feed_log (guid, type, data, counter) VALUES('%u', %d, '%u', 1)", pGuid, type, data);
+ }
+ delete result;
+ }
+ else
+ {
+ CharacterDatabase.PExecute("INSERT IGNORE INTO character_feed_log (guid, type, data, counter) VALUES('%u', %d, '%u', 1)", pGuid, type, data);
+ }
+}
diff --git a/src/game/Player.h b/src/game/Player.h
index 3de8ea8..0998ca2 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -2174,6 +2174,9 @@ class MANGOS_DLL_SPEC Player : public Unit
void SetHomebindToLocation(WorldLocation const& loc, uint32 area_id);
void RelocateToHomebind() { SetLocationMapId(m_homebindMapId); Relocate(m_homebindX, m_homebindY, m_homebindZ); }
bool TeleportToHomebind(uint32 options = 0) { return TeleportTo(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, GetOrientation(), options); }
+
+ // WoWArmory
+ void WriteWowArmoryDatabaseLog(uint32 type, uint32 data);
// currently visible objects at player client
typedef std::set<uint64> ClientGUIDs;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 4a9f340..313075e 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -866,8 +866,12 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
{
if (m->IsRaidOrHeroicDungeon())
{
- if(cVictim->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
- ((InstanceMap *)m)->PermBindAllPlayers(creditedPlayer);
+ if(cVictim->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
+ {
+ ((InstanceMap *)m)->PermBindAllPlayers(creditedPlayer);
+ /* WoWArmory Feed Log */
+ player->WriteWowArmoryDatabaseLog(3, cVictim->GetCreatureInfo()->Entry);
+ }
}
else
{