Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mangosone/server
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1arm committed Aug 29, 2024
2 parents 148d873 + 821445d commit ad3c8ef
Show file tree
Hide file tree
Showing 14 changed files with 1,170 additions and 1,075 deletions.
4 changes: 2 additions & 2 deletions src/game/ChatCommands/DebugCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/)
return false;
}

WorldPacket data(Opcodes(opcode), 0);
WorldPacket data(OpcodesList(opcode), 0);

std::string type;
while (stream >> type)
Expand Down Expand Up @@ -1392,7 +1392,7 @@ bool ChatHandler::HandleDebugSpellModsCommand(char* args)
return false;
}

Opcodes opcode;
OpcodesList opcode;
if (strncmp(typeStr, "flat", strlen(typeStr)) == 0)
{
opcode = SMSG_SET_FLAT_SPELL_MODIFIER;
Expand Down
2 changes: 1 addition & 1 deletion src/game/Object/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20359,7 +20359,7 @@ bool Player::IsAffectedBySpellmod(SpellEntry const* spellInfo, SpellModifier* mo

void Player::AddSpellMod(SpellModifier* mod, bool apply)
{
Opcodes opcode = (mod->type == SPELLMOD_FLAT) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER;
OpcodesList opcode = (mod->type == SPELLMOD_FLAT) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER;

for (int eff = 0; eff < 64; ++eff)
{
Expand Down
2,145 changes: 1,084 additions & 1,061 deletions src/game/Server/Opcodes.cpp

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/game/Server/Opcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define MANGOS_H_OPCODES

#include "Common.h"
#include "Policies/Singleton.h"

// Note: this include need for be sure have full definition of class WorldSession
// if this class definition not complite then VS for x64 release use different size for
Expand All @@ -49,7 +50,7 @@
* \see WorldPacket
* \todo Replace the Pack GUID part with a packed GUID, ie: it's shorter than usual?
*/
enum Opcodes
enum OpcodesList
{
MSG_NULL_ACTION = 0x000,
CMSG_BOOTME = 0x001,
Expand Down Expand Up @@ -521,7 +522,7 @@ enum Opcodes
CMSG_WRAP_ITEM = 0x1D3,
SMSG_LEVELUP_INFO = 0x1D4,
MSG_MINIMAP_PING = 0x1D5,
SMSG_RESISTLOG = 0x1D6,
SMSG_RESISTLOG = 0x1D6,// GUID, GUID, int32, float, float, int32, int32
SMSG_ENCHANTMENTLOG = 0x1D7,
CMSG_SET_SKILL_CHEAT = 0x1D8,
SMSG_START_MIRROR_TIMER = 0x1D9,
Expand Down Expand Up @@ -1116,6 +1117,8 @@ enum Opcodes
// Don't forget to change this value and add opcode name to Opcodes.cpp when you add new opcode!
#define NUM_MSG_TYPES 0x424

extern void InitializeOpcodes();

/// Player state
enum SessionStatus
{
Expand Down
6 changes: 6 additions & 0 deletions src/game/Server/WorldSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ void WorldSession::SendPacket(WorldPacket const* packet)
return;
}

if (opcodeTable[packet->GetOpcode()].status == STATUS_UNHANDLED)
{
sLog.outError("SESSION: tried to send an unhandled opcode 0x%.4X", packet->GetOpcode());
return;
}

#ifdef MANGOS_DEBUG

// Code for network use statistic
Expand Down
2 changes: 1 addition & 1 deletion src/game/Server/WorldSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ int WorldSocket::handle_input_header(void)

header.size -= 4;

ACE_NEW_RETURN(m_RecvWPct, WorldPacket(Opcodes(header.cmd), header.size), -1);
ACE_NEW_RETURN(m_RecvWPct, WorldPacket(OpcodesList(header.cmd), header.size), -1);

if (header.size > 0)
{
Expand Down
2 changes: 2 additions & 0 deletions src/game/Server/WorldSocketMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "Config/Config.h"
#include "WorldSocket.h"
#include "WorldSocketMgr.h"
#include "Opcodes.h"

#include <ace/ACE.h>
#include <ace/TP_Reactor.h>
Expand All @@ -46,6 +47,7 @@ WorldSocketMgr::WorldSocketMgr()
: m_SockOutKBuff(-1), m_SockOutUBuff(65536), m_UseNoDelay(true),
reactor_(NULL), acceptor_(NULL)
{
InitializeOpcodes();
}

WorldSocketMgr::~WorldSocketMgr()
Expand Down
4 changes: 4 additions & 0 deletions src/modules/Bots/ahbot/Category.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@ namespace ahbot
public:
virtual bool Contains(ItemPrototype const* proto)
{
#if defined(CLASSIC)
return proto->Class == ITEM_CLASS_TRADE_GOODS;
#else
return proto->Class == ITEM_CLASS_TRADE_GOODS ||
proto->Class == ITEM_CLASS_MISC ||
proto->Class == ITEM_CLASS_REAGENT;
#endif
}
virtual string GetName() { return "trade"; }

Expand Down
2 changes: 2 additions & 0 deletions src/modules/Bots/playerbot/ChatHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ ChatHelper::ChatHelper(PlayerbotAI* ai) : PlayerbotAIAware(ai)
races[RACE_ORC] = "Orc";
races[RACE_TAUREN] = "Tauren";
races[RACE_TROLL] = "Troll";
#if !defined(CLASSIC)
races[RACE_DRAENEI] = "Draenei";
races[RACE_BLOODELF] = "Blood Elf";
#endif
races[RACE_UNDEAD] = "Undead";
}

Expand Down
7 changes: 5 additions & 2 deletions src/modules/Bots/playerbot/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1311,8 +1311,11 @@ bool PlayerbotAI::canDispel(const SpellEntry* entry, uint32 dispelType)

bool IsAlliance(uint8 race)
{
return race == RACE_HUMAN || race == RACE_DWARF || race == RACE_NIGHTELF || race == RACE_DRAENEI ||
race == RACE_GNOME;
return race == RACE_HUMAN || race == RACE_DWARF || race == RACE_NIGHTELF
#if !defined(CLASSIC)
|| race == RACE_DRAENEI
#endif
|| race == RACE_GNOME;
}

bool PlayerbotAI::IsOpposing(Player* player)
Expand Down
6 changes: 6 additions & 0 deletions src/modules/Bots/playerbot/PlayerbotFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ uint32 PlayerbotFactory::tradeSkills[] =
SKILL_ENCHANTING,
SKILL_SKINNING,
SKILL_TAILORING,
#if !defined(CLASSIC)
SKILL_JEWELCRAFTING,
#endif
SKILL_LEATHERWORKING,
SKILL_ENGINEERING,
SKILL_HERBALISM,
Expand Down Expand Up @@ -1128,7 +1130,9 @@ void PlayerbotFactory::InitTradeSkills()
break;
case 2:
SetRandomSkill(SKILL_MINING);
#if !defined(CLASSIC)
SetRandomSkill(SKILL_JEWELCRAFTING);
#endif
break;
case 3:
SetRandomSkill(firstSkills[urand(0, firstSkills.size() - 1)]);
Expand Down Expand Up @@ -1750,11 +1754,13 @@ void PlayerbotFactory::InitInventorySkill()
{
StoreItem(2901, 1); // Mining Pick
}
#if !defined(CLASSIC)
if (bot->HasSkill(SKILL_JEWELCRAFTING))
{
StoreItem(20815, 1); // Jeweler's Kit
StoreItem(20824, 1); // Simple Grinder
}
#endif
if (bot->HasSkill(SKILL_BLACKSMITHING) || bot->HasSkill(SKILL_ENGINEERING))
{
StoreItem(5956, 1); // Blacksmith Hammer
Expand Down
28 changes: 25 additions & 3 deletions src/modules/Bots/playerbot/RandomPlayerbotFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,54 +24,72 @@ RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(acc
availableRaces[CLASS_WARRIOR].push_back(RACE_UNDEAD);
availableRaces[CLASS_WARRIOR].push_back(RACE_TAUREN);
availableRaces[CLASS_WARRIOR].push_back(RACE_TROLL);
#if !defined(CLASSIC)
availableRaces[CLASS_WARRIOR].push_back(RACE_DRAENEI);
#endif

availableRaces[CLASS_PALADIN].push_back(RACE_HUMAN);
availableRaces[CLASS_PALADIN].push_back(RACE_DWARF);
#if !defined(CLASSIC)
availableRaces[CLASS_PALADIN].push_back(RACE_DRAENEI);
availableRaces[CLASS_PALADIN].push_back(RACE_BLOODELF);
#endif

availableRaces[CLASS_ROGUE].push_back(RACE_HUMAN);
availableRaces[CLASS_ROGUE].push_back(RACE_DWARF);
availableRaces[CLASS_ROGUE].push_back(RACE_NIGHTELF);
availableRaces[CLASS_ROGUE].push_back(RACE_GNOME);
availableRaces[CLASS_ROGUE].push_back(RACE_ORC);
availableRaces[CLASS_ROGUE].push_back(RACE_TROLL);
#if !defined(CLASSIC)
availableRaces[CLASS_ROGUE].push_back(RACE_BLOODELF);

#endif
availableRaces[CLASS_PRIEST].push_back(RACE_HUMAN);
availableRaces[CLASS_PRIEST].push_back(RACE_DWARF);
availableRaces[CLASS_PRIEST].push_back(RACE_NIGHTELF);
#if !defined(CLASSIC)
availableRaces[CLASS_PRIEST].push_back(RACE_DRAENEI);
#endif
availableRaces[CLASS_PRIEST].push_back(RACE_TROLL);
availableRaces[CLASS_PRIEST].push_back(RACE_UNDEAD);
#if !defined(CLASSIC)
availableRaces[CLASS_PRIEST].push_back(RACE_BLOODELF);

#endif
availableRaces[CLASS_MAGE].push_back(RACE_HUMAN);
availableRaces[CLASS_MAGE].push_back(RACE_GNOME);
#if !defined(CLASSIC)
availableRaces[CLASS_MAGE].push_back(RACE_DRAENEI);
#endif
availableRaces[CLASS_MAGE].push_back(RACE_UNDEAD);
availableRaces[CLASS_MAGE].push_back(RACE_TROLL);
#if !defined(CLASSIC)
availableRaces[CLASS_MAGE].push_back(RACE_BLOODELF);
#endif

availableRaces[CLASS_WARLOCK].push_back(RACE_HUMAN);
availableRaces[CLASS_WARLOCK].push_back(RACE_GNOME);
availableRaces[CLASS_WARLOCK].push_back(RACE_UNDEAD);
availableRaces[CLASS_WARLOCK].push_back(RACE_ORC);
#if !defined(CLASSIC)
availableRaces[CLASS_WARLOCK].push_back(RACE_BLOODELF);
#endif

#if !defined(CLASSIC)
availableRaces[CLASS_SHAMAN].push_back(RACE_DRAENEI);
#endif
availableRaces[CLASS_SHAMAN].push_back(RACE_ORC);
availableRaces[CLASS_SHAMAN].push_back(RACE_TAUREN);
availableRaces[CLASS_SHAMAN].push_back(RACE_TROLL);

availableRaces[CLASS_HUNTER].push_back(RACE_DWARF);
availableRaces[CLASS_HUNTER].push_back(RACE_NIGHTELF);
availableRaces[CLASS_HUNTER].push_back(RACE_DRAENEI);
availableRaces[CLASS_HUNTER].push_back(RACE_ORC);
availableRaces[CLASS_HUNTER].push_back(RACE_TAUREN);
availableRaces[CLASS_HUNTER].push_back(RACE_TROLL);
#if !defined(CLASSIC)
availableRaces[CLASS_HUNTER].push_back(RACE_DRAENEI);
availableRaces[CLASS_HUNTER].push_back(RACE_BLOODELF);
#endif

availableRaces[CLASS_DRUID].push_back(RACE_NIGHTELF);
availableRaces[CLASS_DRUID].push_back(RACE_TAUREN);
Expand All @@ -97,7 +115,11 @@ bool RandomPlayerbotFactory::CreateRandomBot(uint8 cls)
uint8 facialHair = urand(0, 7);
uint8 outfitId = 0;

#if !defined(CLASSIC)
WorldSession* session = new WorldSession(accountId, NULL, SEC_PLAYER, MAX_EXPANSION, 0, LOCALE_enUS);
#else
WorldSession* session = new WorldSession(accountId, NULL, SEC_PLAYER, 0, LOCALE_enUS);
#endif
if (!session)
{
sLog.outError("Couldn't create session for random bot account %d", accountId);
Expand Down
24 changes: 23 additions & 1 deletion src/modules/Bots/playerbot/strategy/actions/LootRollAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ bool LootRollAction::Execute(Event event)
}

RollVote vote = ROLL_PASS;
#if defined(CLASSIC)
ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(guid.GetEntry());
if (proto)
{
switch (proto->Class)
{
case ITEM_CLASS_WEAPON:
case ITEM_CLASS_ARMOR:
if (QueryItemUsage(proto))
{
vote = ROLL_NEED;
}
break;
default:
if (IsLootAllowed(guid.GetEntry()))
{
vote = ROLL_NEED;
}
break;
}
}
#else
for (vector<Roll*>::iterator i = group->GetRolls().begin(); i != group->GetRolls().end(); ++i)
{
if ((*i)->isValid() && (*i)->lootedTargetGUID == guid && (*i)->itemSlot == slot)
Expand All @@ -43,7 +65,7 @@ bool LootRollAction::Execute(Event event)
}
}
}

#endif
switch (group->GetLootMethod())
{
case MASTER_LOOT:
Expand Down
6 changes: 4 additions & 2 deletions src/modules/Bots/playerbot/strategy/actions/UseItemAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget)

if (itemTarget)
{
#if !defined(CLASSIC)
if (item->GetProto()->Class == ITEM_CLASS_GEM)
{
bool fit = SocketItem(itemTarget, item) || SocketItem(itemTarget, item, true);
Expand All @@ -148,6 +149,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget)
return fit;
}
else
#endif
{
uint32 targetFlag = TARGET_FLAG_ITEM;
*packet << targetFlag << itemTarget->GetPackGUID();
Expand Down Expand Up @@ -279,6 +281,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget)
bot->GetSession()->QueuePacket(packet);
return true;
}
#if !defined(CLASSIC)
bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
{
WorldPacket* const packet = new WorldPacket(CMSG_SOCKET_GEMS);
Expand Down Expand Up @@ -335,8 +338,7 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
}
return fits;
}


#endif

bool UseItemAction::isPossible()
{
Expand Down

0 comments on commit ad3c8ef

Please sign in to comment.