mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
Implement banned_addons (#647)
This commit is contained in:
committed by
Francesco Borzì
parent
cf627d8327
commit
2c9b2542d6
24
data/sql/base/db_characters/banned_addons.sql
Normal file
24
data/sql/base/db_characters/banned_addons.sql
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||||
|
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||||
|
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||||
|
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||||
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||||
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||||
|
DROP TABLE IF EXISTS `banned_addons`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `banned_addons` (
|
||||||
|
`Id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
`Name` varchar(255) NOT NULL,
|
||||||
|
`Version` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
`Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`Id`),
|
||||||
|
UNIQUE KEY `idx_name_ver` (`Name`, `Version`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||||
|
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||||
|
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||||
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
INSERT INTO version_db_characters (`sql_rev`) VALUES ('1505652328111029300');
|
||||||
|
|
||||||
|
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||||
|
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||||
|
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||||
|
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||||
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||||
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||||
|
DROP TABLE IF EXISTS `banned_addons`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `banned_addons` (
|
||||||
|
`Id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
`Name` varchar(255) NOT NULL,
|
||||||
|
`Version` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
`Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`Id`),
|
||||||
|
UNIQUE KEY `idx_name_ver` (`Name`, `Version`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||||
|
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||||
|
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||||
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <openssl/md5.h>
|
||||||
|
|
||||||
namespace AddonMgr
|
namespace AddonMgr
|
||||||
{
|
{
|
||||||
@@ -22,6 +23,7 @@ namespace
|
|||||||
typedef std::list<SavedAddon> SavedAddonsList;
|
typedef std::list<SavedAddon> SavedAddonsList;
|
||||||
|
|
||||||
SavedAddonsList m_knownAddons;
|
SavedAddonsList m_knownAddons;
|
||||||
|
BannedAddonList m_bannedAddons;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadFromDB()
|
void LoadFromDB()
|
||||||
@@ -52,7 +54,36 @@ void LoadFromDB()
|
|||||||
while (result->NextRow());
|
while (result->NextRow());
|
||||||
|
|
||||||
sLog->outString(">> Loaded %u known addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
sLog->outString(">> Loaded %u known addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||||
sLog->outString();
|
|
||||||
|
oldMSTime = getMSTime();
|
||||||
|
result = CharacterDatabase.Query("SELECT id, name, version, UNIX_TIMESTAMP(timestamp) FROM banned_addons");
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
uint32 count = 0;
|
||||||
|
uint32 offset = 102;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Field* fields = result->Fetch();
|
||||||
|
|
||||||
|
BannedAddon addon;
|
||||||
|
addon.Id = fields[0].GetUInt32() + offset;
|
||||||
|
addon.Timestamp = uint32(fields[3].GetUInt64());
|
||||||
|
|
||||||
|
std::string name = fields[1].GetString();
|
||||||
|
std::string version = fields[2].GetString();
|
||||||
|
|
||||||
|
MD5(reinterpret_cast<uint8 const*>(name.c_str()), name.length(), addon.NameMD5);
|
||||||
|
MD5(reinterpret_cast<uint8 const*>(version.c_str()), version.length(), addon.VersionMD5);
|
||||||
|
|
||||||
|
m_bannedAddons.push_back(addon);
|
||||||
|
|
||||||
|
++count;
|
||||||
|
} while (result->NextRow());
|
||||||
|
|
||||||
|
sLog->outString(">> Loaded %u banned addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||||
|
sLog->outString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveAddon(AddonInfo const& addon)
|
void SaveAddon(AddonInfo const& addon)
|
||||||
@@ -81,4 +112,9 @@ SavedAddon const* GetAddonInfo(const std::string& name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BannedAddonList const* GetBannedAddons()
|
||||||
|
{
|
||||||
|
return &m_bannedAddons;
|
||||||
|
}
|
||||||
|
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
struct AddonInfo
|
struct AddonInfo
|
||||||
{
|
{
|
||||||
@@ -33,6 +34,14 @@ struct SavedAddon
|
|||||||
uint32 CRC;
|
uint32 CRC;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BannedAddon
|
||||||
|
{
|
||||||
|
uint32 Id;
|
||||||
|
uint8 NameMD5[16];
|
||||||
|
uint8 VersionMD5[16];
|
||||||
|
uint32 Timestamp;
|
||||||
|
};
|
||||||
|
|
||||||
#define STANDARD_ADDON_CRC 0x4c1c776d
|
#define STANDARD_ADDON_CRC 0x4c1c776d
|
||||||
|
|
||||||
namespace AddonMgr
|
namespace AddonMgr
|
||||||
@@ -40,6 +49,9 @@ namespace AddonMgr
|
|||||||
void LoadFromDB();
|
void LoadFromDB();
|
||||||
void SaveAddon(AddonInfo const& addon);
|
void SaveAddon(AddonInfo const& addon);
|
||||||
SavedAddon const* GetAddonInfo(const std::string& name);
|
SavedAddon const* GetAddonInfo(const std::string& name);
|
||||||
|
|
||||||
|
typedef std::list<BannedAddon> BannedAddonList;
|
||||||
|
BannedAddonList const* GetBannedAddons();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1077,7 +1077,16 @@ void WorldSession::SendAddonsInfo()
|
|||||||
|
|
||||||
m_addonsList.clear();
|
m_addonsList.clear();
|
||||||
|
|
||||||
data << uint32(0); // count for an unknown for loop
|
AddonMgr::BannedAddonList const* bannedAddons = AddonMgr::GetBannedAddons();
|
||||||
|
data << uint32(bannedAddons->size());
|
||||||
|
for (AddonMgr::BannedAddonList::const_iterator itr = bannedAddons->begin(); itr != bannedAddons->end(); ++itr)
|
||||||
|
{
|
||||||
|
data << uint32(itr->Id);
|
||||||
|
data.append(itr->NameMD5, sizeof(itr->NameMD5));
|
||||||
|
data.append(itr->VersionMD5, sizeof(itr->VersionMD5));
|
||||||
|
data << uint32(itr->Timestamp);
|
||||||
|
data << uint32(1); // IsBanned
|
||||||
|
}
|
||||||
|
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user