Skip to content

Instantly share code, notes, and snippets.

@iorlas
Created March 22, 2011 04:32
Show Gist options
  • Save iorlas/880777 to your computer and use it in GitHub Desktop.
Save iorlas/880777 to your computer and use it in GitHub Desktop.
WoW Mangos patch for WoW Armory. Ported from 3.* to 2.4.3 for OregonCore
diff -r 1c6f961459fb src/game/Item.cpp
--- a/src/game/Item.cpp Mon Mar 14 23:22:30 2011 +0100
+++ b/src/game/Item.cpp Tue Mar 22 06:49:45 2011 +0300
@@ -891,6 +891,15 @@
Item *pItem = NewItemOrBag(pProto);
if (pItem->Create(objmgr.GenerateLowGuid(HIGHGUID_ITEM), item, player))
{
+ /** World of Warcraft Armory **/
+ if (pProto->Quality > 2 && pProto->Flags != 2048 && (pProto->Class == ITEM_CLASS_WEAPON || pProto->Class == ITEM_CLASS_ARMOR) && player)
+ {
+ std::ostringstream ss;
+ sLog.outDebug("WoWArmory: write feed log (guid: %u, type: 2, data: %u)", player->GetGUIDLow(), item);
+ ss << "REPLACE INTO character_feed_log (guid, type, data, date, counter, item_guid) VALUES (" << player->GetGUIDLow() << ", 2, " << item << ", UNIX_TIMESTAMP(NOW()), 1," << pItem->GetGUIDLow() << ")";
+ CharacterDatabase.PExecute( ss.str().c_str() );
+ }
+ /** World of Warcraft Armory **/
pItem->SetCount(count);
return pItem;
}
diff -r 1c6f961459fb src/game/Player.cpp
--- a/src/game/Player.cpp Mon Mar 14 23:22:30 2011 +0100
+++ b/src/game/Player.cpp Tue Mar 22 06:49:45 2011 +0300
@@ -16238,6 +16238,17 @@
std::string sql_name = m_name;
CharacterDatabase.escape_string(sql_name);
+ /** World of Warcraft Armory **/
+ std::ostringstream ps;
+ ps << "REPLACE INTO armory_character_stats (guid,data) VALUES ('" << GetGUIDLow() << "', '";
+ for(uint16 i = 0; i < m_valuesCount; ++i )
+ {
+ ps << GetUInt32Value(i) << " ";
+ }
+ ps << "')";
+ CharacterDatabase.Execute( ps.str().c_str() );
+ /** World of Warcraft Armory **/
+
std::ostringstream ss;
ss << "REPLACE INTO characters (guid,account,name,race,class,gender,level,xp,money,playerBytes,playerBytes2,playerFlags,"
"map, instance_id, dungeon_difficulty, position_x, position_y, position_z, orientation, data, "
@@ -20546,3 +20557,40 @@
m_mapRef.link(map, this);
}
+/** World of Warcraft Armory **/
+void Player::WriteWowArmoryDatabaseLog(uint32 type, uint32 data)
+{
+ uint32 pGuid = GetGUIDLow();
+ sLog.outDebug("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.
+ {
+ /* So, currently it doesnt matter: difficulty or spawn mode, cuz it's the same:
+ "_currently_ spawnmode == difficulty, but this can be changes later,
+ so use appropriate spawmmode/difficult functions"
+
+ See comments on functions set in 3722be02457dfb8a2352 commit on original mangos github page:
+ https://github.com/mangos/mangos/blob/master/src/game/Map.h
+ */
+ //uint8 Difficulty = GetMap()->GetDifficulty();
+ uint8 Difficulty = GetMap()->GetSpawnMode();
+ QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT counter FROM character_feed_log WHERE guid='%u' AND type=3 AND data='%u' AND difficulty='%u' LIMIT 1", pGuid, data, Difficulty);
+ if (result)
+ {
+ CharacterDatabase.PExecute("UPDATE character_feed_log SET counter=counter+1, date=UNIX_TIMESTAMP(NOW()) WHERE guid='%u' AND type=3 AND data='%u' AND difficulty='%u' LIMIT 1", pGuid, data, Difficulty);
+ }
+ else
+ {
+ CharacterDatabase.PExecute("INSERT INTO character_feed_log (guid, type, data, date, counter, difficulty) VALUES('%u', '%d', '%u', UNIX_TIMESTAMP(NOW()), 1, '%u')", pGuid, type, data, Difficulty);
+ }
+ }
+ else
+ {
+ CharacterDatabase.PExecute("REPLACE INTO character_feed_log (guid, type, data, date, counter) VALUES('%u', '%d', '%u', UNIX_TIMESTAMP(NOW()), 1)", pGuid, type, data);
+ }
+}
+/** World of Warcraft Armory **/
\ No newline at end of file
diff -r 1c6f961459fb src/game/Player.h
--- a/src/game/Player.h Mon Mar 14 23:22:30 2011 +0100
+++ b/src/game/Player.h Tue Mar 22 06:49:45 2011 +0300
@@ -1661,6 +1661,8 @@
void learnSkillRewardedSpells(uint32 id);
void learnSkillRewardedSpells();
+ void WriteWowArmoryDatabaseLog(uint32 type, uint32 data); /** World of Warcraft Armory **/
+
WorldLocation& GetTeleportDest() { return m_teleport_dest; }
bool IsBeingTeleported() const { return mSemaphoreTeleport_Near || mSemaphoreTeleport_Far; }
bool IsBeingTeleportedNear() const { return mSemaphoreTeleport_Near; }
diff -r 1c6f961459fb src/game/Unit.cpp
--- a/src/game/Unit.cpp Mon Mar 14 23:22:30 2011 +0100
+++ b/src/game/Unit.cpp Tue Mar 22 06:49:45 2011 +0300
@@ -11604,6 +11604,9 @@
{
if (creature->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
((InstanceMap *)m)->PermBindAllPlayers(creditedPlayer);
+ /** World of Warcraft Armory **/
+ creditedPlayer->WriteWowArmoryDatabaseLog(3, creature->GetCreatureInfo()->Entry);
+ /** World of Warcraft Armory **/
}
else
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment