Fix corrupt item cache crashes, bot whispers, trade crashes

This commit is contained in:
郑佩茹 2022-03-22 11:04:21 -06:00
parent b952636f0d
commit a7f412b428
21 changed files with 91 additions and 78 deletions

View File

@ -1,14 +1,14 @@
DROP TABLE IF EXISTS `playerbot_arena_team_names`; DROP TABLE IF EXISTS `playerbots_arena_team_names`;
CREATE TABLE `playerbot_arena_team_names` ( CREATE TABLE `playerbots_arena_team_names` (
`name_id` mediumint(8) NOT NULL AUTO_INCREMENT UNIQUE, `name_id` mediumint(8) NOT NULL AUTO_INCREMENT UNIQUE,
`name` varchar(24) NOT NULL UNIQUE, `name` varchar(24) NOT NULL UNIQUE,
`type` TINYINT(3) NOT NULL, `type` TINYINT(3) NOT NULL,
PRIMARY KEY (`name_id`) PRIMARY KEY (`name_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Playerbot arena team names'; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Playerbot arena team names';
DELETE FROM `playerbot_arena_team_names`; DELETE FROM `playerbots_arena_team_names`;
INSERT INTO `playerbot_arena_team_names` (`name_id`,`name`, `type`) VALUES INSERT INTO `playerbots_arena_team_names` (`name_id`,`name`, `type`) VALUES
(NULL, 'out of coverage',2), (NULL, 'out of coverage',2),
(NULL, 'Dead or Alive',2), (NULL, 'Dead or Alive',2),
(NULL, 'Noßrain',2), (NULL, 'Noßrain',2),

View File

@ -1,11 +1,11 @@
DROP TABLE IF EXISTS `playerbot_guild_names`; DROP TABLE IF EXISTS `playerbots_guild_names`;
CREATE TABLE `playerbot_guild_names` ( CREATE TABLE `playerbots_guild_names` (
`name_id` INT(11) NOT NULL AUTO_INCREMENT UNIQUE, `name_id` INT(11) NOT NULL AUTO_INCREMENT UNIQUE,
`name` varchar(24) NOT NULL UNIQUE, `name` varchar(24) NOT NULL UNIQUE,
PRIMARY KEY (`name_id`) PRIMARY KEY (`name_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Playerbot guild names'; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Playerbot guild names';
INSERT INTO `playerbot_guild_names` VALUES INSERT INTO `playerbots_guild_names` VALUES
(NULL, 'Black Guard'), (NULL, 'Black Guard'),
(NULL, 'Abyssal Kingdoms'), (NULL, 'Abyssal Kingdoms'),
(NULL, 'Acid Evil'), (NULL, 'Acid Evil'),

View File

@ -1,12 +1,12 @@
DROP TABLE IF EXISTS `playerbot_names`; DROP TABLE IF EXISTS `playerbots_names`;
CREATE TABLE `playerbot_names` ( CREATE TABLE `playerbots_names` (
`name_id` INT(11) NOT NULL UNIQUE, `name_id` INT(11) NOT NULL UNIQUE,
`name` varchar(255) NOT NULL, `name` varchar(255) NOT NULL,
`gender` tinyint(3) unsigned NOT NULL, `gender` tinyint(3) unsigned NOT NULL,
PRIMARY KEY (`name_id`) PRIMARY KEY (`name_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Playerbot RandomBot names'; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Playerbot RandomBot names';
INSERT INTO `playerbot_names` VALUES INSERT INTO `playerbots_names` VALUES
(1,'Aalart',0), (1,'Aalart',0),
(2,'Aalef',0), (2,'Aalef',0),
(3,'Aalot',0), (3,'Aalot',0),
@ -10687,5 +10687,5 @@ INSERT INTO `playerbot_names` VALUES
(10678,'Zuzene',1), (10678,'Zuzene',1),
(10679,'Zwaante',1); (10679,'Zwaante',1);
DELETE FROM `playerbot_names` WHERE LENGTH(`name`) > 12; DELETE FROM `playerbots_names` WHERE LENGTH(`name`) > 12;
ALTER TABLE `playerbot_names` MODIFY `name` varchar(12); ALTER TABLE `playerbots_names` MODIFY `name` varchar(12);

View File

@ -1,45 +1,48 @@
DROP TABLE IF EXISTS `playerbots_item_info_cache`; DROP TABLE IF EXISTS `playerbots_item_info_cache`;
CREATE TABLE IF NOT EXISTS `playerbots_item_info_cache` ( CREATE TABLE IF NOT EXISTS `playerbots_item_info_cache`
`id` int(11) NOT NULL, (
`quality` int(11) DEFAULT NULL, `id` int(11) NOT NULL,
`slot` int(11) DEFAULT NULL, `quality` int(11) DEFAULT NULL,
`source` mediumint(8) DEFAULT NULL, `slot` int(11) DEFAULT NULL,
`sourceId` mediumint(8) DEFAULT NULL, `source` bigint(20) DEFAULT NULL,
`team` mediumint(8) DEFAULT NULL, `sourceId` bigint(20) DEFAULT NULL,
`faction` mediumint(8) DEFAULT NULL, `team` bigint(20) DEFAULT NULL,
`factionRepRank` mediumint(8) DEFAULT NULL, `faction` bigint(20) DEFAULT NULL,
`minLevel` mediumint(8) DEFAULT NULL, `factionRepRank` bigint(20) DEFAULT NULL,
`scale_1` mediumint(8) DEFAULT NULL, `minLevel` bigint(20) DEFAULT NULL,
`scale_2` mediumint(8) DEFAULT NULL, `scale_1` bigint(20) DEFAULT NULL,
`scale_3` mediumint(8) DEFAULT NULL, `scale_2` bigint(20) DEFAULT NULL,
`scale_4` mediumint(8) DEFAULT NULL, `scale_3` bigint(20) DEFAULT NULL,
`scale_5` mediumint(8) DEFAULT NULL, `scale_4` bigint(20) DEFAULT NULL,
`scale_6` mediumint(8) DEFAULT NULL, `scale_5` bigint(20) DEFAULT NULL,
`scale_7` mediumint(8) DEFAULT NULL, `scale_6` bigint(20) DEFAULT NULL,
`scale_8` mediumint(8) DEFAULT NULL, `scale_7` bigint(20) DEFAULT NULL,
`scale_9` mediumint(8) DEFAULT NULL, `scale_8` bigint(20) DEFAULT NULL,
`scale_10` mediumint(8) DEFAULT NULL, `scale_9` bigint(20) DEFAULT NULL,
`scale_11` mediumint(8) DEFAULT NULL, `scale_10` bigint(20) DEFAULT NULL,
`scale_12` mediumint(8) DEFAULT NULL, `scale_11` bigint(20) DEFAULT NULL,
`scale_13` mediumint(8) DEFAULT NULL, `scale_12` bigint(20) DEFAULT NULL,
`scale_14` mediumint(8) DEFAULT NULL, `scale_13` bigint(20) DEFAULT NULL,
`scale_15` mediumint(8) DEFAULT NULL, `scale_14` bigint(20) DEFAULT NULL,
`scale_16` mediumint(8) DEFAULT NULL, `scale_15` bigint(20) DEFAULT NULL,
`scale_17` mediumint(8) DEFAULT NULL, `scale_16` bigint(20) DEFAULT NULL,
`scale_18` mediumint(8) DEFAULT NULL, `scale_17` bigint(20) DEFAULT NULL,
`scale_19` mediumint(8) DEFAULT NULL, `scale_18` bigint(20) DEFAULT NULL,
`scale_20` mediumint(8) DEFAULT NULL, `scale_19` bigint(20) DEFAULT NULL,
`scale_21` mediumint(8) DEFAULT NULL, `scale_20` bigint(20) DEFAULT NULL,
`scale_22` mediumint(8) DEFAULT NULL, `scale_21` bigint(20) DEFAULT NULL,
`scale_23` mediumint(8) DEFAULT NULL, `scale_22` bigint(20) DEFAULT NULL,
`scale_24` mediumint(8) DEFAULT NULL, `scale_23` bigint(20) DEFAULT NULL,
`scale_25` mediumint(8) DEFAULT NULL, `scale_24` bigint(20) DEFAULT NULL,
`scale_26` mediumint(8) DEFAULT NULL, `scale_25` bigint(20) DEFAULT NULL,
`scale_27` mediumint(8) DEFAULT NULL, `scale_26` bigint(20) DEFAULT NULL,
`scale_28` mediumint(8) DEFAULT NULL, `scale_27` bigint(20) DEFAULT NULL,
`scale_29` mediumint(8) DEFAULT NULL, `scale_28` bigint(20) DEFAULT NULL,
`scale_30` mediumint(8) DEFAULT NULL, `scale_29` bigint(20) DEFAULT NULL,
`scale_31` mediumint(8) DEFAULT NULL, `scale_30` bigint(20) DEFAULT NULL,
`scale_32` mediumint(8) DEFAULT NULL, `scale_31` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`) `scale_32` bigint(20) DEFAULT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='PlayerbotAI item info Cache'; PRIMARY KEY (`id`)
) ENGINE = MyISAM
DEFAULT CHARSET = utf8
ROW_FORMAT = FIXED COMMENT ='PlayerbotAI item info Cache';

View File

@ -11,4 +11,4 @@ CREATE TABLE `charsections_dbc` (
`Type` INT NOT NULL DEFAULT '0', `Type` INT NOT NULL DEFAULT '0',
`Color` INT NOT NULL DEFAULT '0', `Color` INT NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`) USING BTREE PRIMARY KEY (`ID`) USING BTREE
) ENGINE=MYISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC; ) ENGINE=MYISAM DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

View File

@ -6,4 +6,4 @@ CREATE TABLE `emotetextsound_dbc` (
`SexId` INT NOT NULL DEFAULT '0', `SexId` INT NOT NULL DEFAULT '0',
`SoundId` INT NOT NULL DEFAULT '0', `SoundId` INT NOT NULL DEFAULT '0',
PRIMARY KEY (`Id`) USING BTREE PRIMARY KEY (`Id`) USING BTREE
) ENGINE=MYISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC; ) ENGINE=MYISAM DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

View File

@ -13,6 +13,8 @@
#include <cctype> #include <cctype>
#include <locale> #include <locale>
#include <sstream> #include <sstream>
#include <stdio.h>
#include <string>
void split(std::vector<std::string>& dest, std::string const str, char const* delim) void split(std::vector<std::string>& dest, std::string const str, char const* delim)
{ {

View File

@ -1259,7 +1259,7 @@ bool PlayerbotAI::TellMasterNoFacing(std::string const text, PlayerbotSecurityLe
type = currentChat.first; type = currentChat.first;
WorldPacket data; WorldPacket data;
ChatHandler::BuildChatPacket(data, type == CHAT_MSG_ADDON ? CHAT_MSG_PARTY : type, type == CHAT_MSG_ADDON ? LANG_ADDON : LANG_UNIVERSAL, nullptr, bot, text.c_str()); ChatHandler::BuildChatPacket(data, type == CHAT_MSG_ADDON ? CHAT_MSG_PARTY : type, type == CHAT_MSG_ADDON ? LANG_ADDON : LANG_UNIVERSAL, bot, nullptr, text.c_str());
master->SendDirectMessage(&data); master->SendDirectMessage(&data);
} }

View File

@ -7,7 +7,7 @@
#include "Common.h" #include "Common.h"
#include "SharedDefines.h" #include "SharedDefines.h"
#include "TalentSpec.h" #include "Talentspec.h"
#include <mutex> #include <mutex>

View File

@ -2350,7 +2350,9 @@ void PlayerbotFactory::InitInventoryTrade()
break; break;
case ITEM_QUALITY_UNCOMMON: case ITEM_QUALITY_UNCOMMON:
stacks = 1; stacks = 1;
count = urand(1, proto->GetMaxStackSize() / 2); int maxStackSize = proto->GetMaxStackSize()/2;
uint32 max = std::max(1, maxStackSize);
count = urand(1, max);
break; break;
} }

View File

@ -6,6 +6,7 @@
#include "Playerbots.h" #include "Playerbots.h"
#include "PlayerbotDbStore.h" #include "PlayerbotDbStore.h"
#include "PlayerbotFactory.h" #include "PlayerbotFactory.h"
#include "WorldSession.h"
PlayerbotHolder::PlayerbotHolder() : PlayerbotAIBase(false) PlayerbotHolder::PlayerbotHolder() : PlayerbotAIBase(false)
{ {

View File

@ -2108,7 +2108,7 @@ void RandomItemMgr::BuildEquipCache()
stmt->SetData(1, level); stmt->SetData(1, level);
stmt->SetData(2, slot); stmt->SetData(2, slot);
stmt->SetData(3, quality); stmt->SetData(3, quality);
stmt->SetData(4, quality); stmt->SetData(4, proto->ItemId);
PlayerbotsDatabase.Execute(stmt); PlayerbotsDatabase.Execute(stmt);
} }

View File

@ -9,6 +9,7 @@
#include <map> #include <map>
#include <unordered_map> #include <unordered_map>
#include <vector>
class Player; class Player;
class WorldSession; class WorldSession;

View File

@ -12,6 +12,9 @@
#include "Trigger.h" #include "Trigger.h"
#include "Value.h" #include "Value.h"
#include <sstream>
#include <string>
class PlayerbotAI; class PlayerbotAI;
class AiObjectContext : public PlayerbotAIAware class AiObjectContext : public PlayerbotAIAware

View File

@ -97,7 +97,7 @@ void CustomStrategy::LoadActionLines(uint32 owner)
do do
{ {
Field* fields = result->Fetch(); Field* fields = result->Fetch();
std::string const action = fields[0].Get<std::string>(); std::string const action = fields[1].Get<std::string>();
actionLines.push_back(action); actionLines.push_back(action);
} }
while (result->NextRow()); while (result->NextRow());

View File

@ -8,8 +8,8 @@
#include "AddLootAction.h" #include "AddLootAction.h"
#include "AttackAction.h" #include "AttackAction.h"
#include "AutoLearnSpellAction.h" #include "AutoLearnSpellAction.h"
#include "BattlegroundTactics.h" #include "BattleGroundTactics.h"
#include "BattlegroundJoinAction.h" #include "BattleGroundJoinAction.h"
#include "BuyAction.h" #include "BuyAction.h"
#include "CastCustomSpellAction.h" #include "CastCustomSpellAction.h"
#include "ChangeStrategyAction.h" #include "ChangeStrategyAction.h"

View File

@ -2,7 +2,7 @@
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
*/ */
#include "BattlegroundJoinAction.h" #include "BattleGroundJoinAction.h"
#include "ArenaTeam.h" #include "ArenaTeam.h"
#include "ArenaTeamMgr.h" #include "ArenaTeamMgr.h"
#include "BattlegroundMgr.h" #include "BattlegroundMgr.h"
@ -939,7 +939,7 @@ bool BGStatusAction::Execute(Event event)
{ {
if (ginfo.IsInvitedToBGInstanceGUID && !bot->InBattleground()) if (ginfo.IsInvitedToBGInstanceGUID && !bot->InBattleground())
{ {
Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID); Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, _bgTypeId);
if (bg) if (bg)
{ {
if (isArena) if (isArena)
@ -1038,7 +1038,7 @@ bool BGStatusAction::Execute(Event event)
if (ginfo.IsInvitedToBGInstanceGUID) if (ginfo.IsInvitedToBGInstanceGUID)
{ {
Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID); Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, _bgTypeId);
if (!bg) if (!bg)
{ {
LOG_ERROR("playerbots", "Bot {} {}:{} <{}>: Missing QueueInfo for {} {}", LOG_ERROR("playerbots", "Bot {} {}:{} <{}>: Missing QueueInfo for {} {}",

View File

@ -2,7 +2,7 @@
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
*/ */
#include "BattlegroundTactics.h" #include "BattleGroundTactics.h"
#include "ArenaTeam.h" #include "ArenaTeam.h"
#include "ArenaTeamMgr.h" #include "ArenaTeamMgr.h"
#include "BattlegroundMgr.h" #include "BattlegroundMgr.h"

View File

@ -46,7 +46,7 @@
#include "ReviveFromCorpseAction.h" #include "ReviveFromCorpseAction.h"
#include "RewardAction.h" #include "RewardAction.h"
#include "RtiAction.h" #include "RtiAction.h"
#include "RTSCAction.h" #include "RtscAction.h"
#include "SaveManaAction.h" #include "SaveManaAction.h"
#include "SellAction.h" #include "SellAction.h"
#include "SetCraftAction.h" #include "SetCraftAction.h"

View File

@ -12,7 +12,7 @@
#include "AcceptResurrectAction.h" #include "AcceptResurrectAction.h"
#include "AreaTriggerAction.h" #include "AreaTriggerAction.h"
#include "ArenaTeamActions.h" #include "ArenaTeamActions.h"
#include "BattlegroundTactics.h" #include "BattleGroundTactics.h"
#include "CheckMountStateAction.h" #include "CheckMountStateAction.h"
#include "GuildAcceptAction.h" #include "GuildAcceptAction.h"
#include "GuildCreateActions.h" #include "GuildCreateActions.h"

View File

@ -9,6 +9,7 @@
#include "LootValues.h" #include "LootValues.h"
#include "PvpValues.h" #include "PvpValues.h"
#include "QuestValues.h" #include "QuestValues.h"
#include "Playerbots.h"
class PlayerbotAI; class PlayerbotAI;