Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make IDs easier to edit #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions data/sql/db-world/2024_04_07_01_guildhouse_spawns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ CREATE TABLE IF NOT EXISTS `guild_house_spawns` (
`comment` varchar(500) DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `entry` (`entry`)
) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- !!! NOTE: set these before running the queries in order to avoid conflicts !!!
SET @C_TEMPLATE = 500030;
SET @GO_TEMPLATE = 500000;

REPLACE INTO `guild_house_spawns` (`id`, `entry`, `posX`, `posY`, `posZ`, `orientation`, `comment`) VALUES
(1, 26327, 16216.5, 16279.4, 20.9306, 0.552869, 'Paladin Trainer'),
Expand All @@ -20,7 +24,7 @@ REPLACE INTO `guild_house_spawns` (`id`, `entry`, `posX`, `posY`, `posZ`, `orien
(7, 26330, 16235.5, 16280.8, 20.9257, 2.18652, 'Shaman Trainer'),
(8, 26331, 16240.8, 16283.3, 20.9299, 1.86843, 'Warlock Trainer'),
(9, 26332, 16246.6, 16284.5, 20.9301, 1.68975, 'Warrior Trainer'),
(10, 500032, 16218.9, 16284.5, 13.1761, 6.18533, 'Innkeeper'),
(10, @C_TEMPLATE + 2, 16218.9, 16284.5, 13.1761, 6.18533, 'Innkeeper'),
(11, 30605, 16228.0, 16280.5, 13.1761, 2.98877, 'Banker'),
(12, 29195, 16252.3, 16284.9, 20.9324, 1.79537, 'Death Knight Trainer'),
(13, 2836, 16220.5, 16302.3, 13.176, 6.14647, 'Blacksmithing Trainer'),
Expand All @@ -45,16 +49,16 @@ REPLACE INTO `guild_house_spawns` (`id`, `entry`, `posX`, `posY`, `posZ`, `orien
(32, 184137, 16220.3, 16272, 12.9736, 4.45592, 'Mailbox (Object)'),
(33, 1685, 16253.8, 16294.3, 13.1758, 6.11938, 'Forge (Object)'),
(34, 4087, 16254.4, 16298.7, 13.1758, 3.36027, 'Anvil (Object)'),
(35, 500000, 16232.9, 16264.1, 13.55570, 3.028813, 'Portal: Stormwind (Object)'),
(36, 500001, 16232.8, 16257.1, 13.93456, 3.028813, 'Portal: Darnassus (Object)'),
(37, 500002, 16231.3, 16254.2, 13.65647, 3.028813, 'Portal: Exodar (Object)'),
(38, 500003, 16233.4, 16260.6, 13.84770, 3.028813, 'Portal: Ironforge (Object)'),
(39, 500004, 16232.9, 16264.1, 13.55570, 3.028813, 'Portal: Orgrimmar (Object)'),
(40, 500005, 16231.3, 16254.2, 13.65647, 3.028813, 'Portal: Silvermoon (Object)'),
(41, 500006, 16233.4, 16260.6, 13.84770, 3.028813, 'Portal: Thunder Bluff (Object)'),
(42, 500007, 16232.8, 16257.1, 13.93456, 3.028813, 'Portal: Undercity (Object)'),
(43, 500008, 16211.1, 16266.9, 13.7458, 5.6724, 'Portal: Shattrath (Object)'),
(44, 500009, 16213.9, 16270.5, 13.1378, 5.4996, 'Portal: Dalaran (Object)'),
(35, @GO_TEMPLATE + 0, 16232.9, 16264.1, 13.55570, 3.028813, 'Portal: Stormwind (Object)'),
(36, @GO_TEMPLATE + 1, 16232.8, 16257.1, 13.93456, 3.028813, 'Portal: Darnassus (Object)'),
(37, @GO_TEMPLATE + 2, 16231.3, 16254.2, 13.65647, 3.028813, 'Portal: Exodar (Object)'),
(38, @GO_TEMPLATE + 3, 16233.4, 16260.6, 13.84770, 3.028813, 'Portal: Ironforge (Object)'),
(39, @GO_TEMPLATE + 4, 16232.9, 16264.1, 13.55570, 3.028813, 'Portal: Orgrimmar (Object)'),
(40, @GO_TEMPLATE + 5, 16231.3, 16254.2, 13.65647, 3.028813, 'Portal: Silvermoon (Object)'),
(41, @GO_TEMPLATE + 6, 16233.4, 16260.6, 13.84770, 3.028813, 'Portal: Thunder Bluff (Object)'),
(42, @GO_TEMPLATE + 7, 16232.8, 16257.1, 13.93456, 3.028813, 'Portal: Undercity (Object)'),
(43, @GO_TEMPLATE + 8, 16211.1, 16266.9, 13.7458, 5.6724, 'Portal: Shattrath (Object)'),
(44, @GO_TEMPLATE + 9, 16213.9, 16270.5, 13.1378, 5.4996, 'Portal: Dalaran (Object)'),
(45, 187293, 16230.5, 16283.5, 13.9061, 3, 'Guild Vault (Object)'),
(46, 28692, 16236.2, 16315.7, 20.8454, 4.64365, 'Trade Supplies'),
(47, 28776, 16223.7, 16297.9, 20.8454, 6.17044, 'Tabard Vendor'),
Expand Down
11 changes: 11 additions & 0 deletions src/guildhouse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

// Offsets from creatures_objects.sql
constexpr uint32 GetCreatureEntry(uint32 offset)
{
return 500030 + offset;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but what if I set @C_TEMPLATE = 40050, then everything would break.

Copy link
Author

@dedmen dedmen Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before.
But now you can easily change it in this one (four) place(s).
If you change it in SQL script, you need to change it here too.

But atleast there are only 4 places to change, instead of two dozen as before

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well then put it into the config. Hardcoded stuff are bad.

}

constexpr uint32 GetGameObjectEntry(uint32 offset)
{
return 500000 + offset;
}
11 changes: 6 additions & 5 deletions src/mod_guildhouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "GameObject.h"
#include "Transport.h"
#include "Maps/MapMgr.h"
#include "guildhouse.h"

class GuildData : public DataMap::Base
{
Expand Down Expand Up @@ -329,12 +330,12 @@ class GuildHouseSeller : public CreatureScript
if (player->GetTeamId() == TEAM_ALLIANCE)
{
// Portal to Stormwind
entry = 500000;
entry = GetGameObjectEntry(0);
}
else
{
// Portal to Orgrimmar
entry = 500004;
entry = GetGameObjectEntry(4);
}

if (entry == 0)
Expand Down Expand Up @@ -414,7 +415,7 @@ class GuildHouseSeller : public CreatureScript

void SpawnButlerNPC(Player* player)
{
uint32 entry = 500031;
uint32 entry = GetCreatureEntry(1);
float posX = 16202.185547f;
float posY = 16255.916992f;
float posZ = 21.160221f;
Expand Down Expand Up @@ -652,7 +653,7 @@ class GuildHouseCommand : public CommandScript
return false;
}

if (player->FindNearestCreature(500031, VISIBLE_RANGE, true))
if (player->FindNearestCreature(GetCreatureEntry(1), VISIBLE_RANGE, true))
{
handler->SendSysMessage("You already have the Guild House Butler!");
handler->SetSentErrorMessage(true);
Expand All @@ -665,7 +666,7 @@ class GuildHouseCommand : public CommandScript
float ori = 6.195375f;

Creature* creature = new Creature();
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, GetGuildPhase(player), 500031, 0, posX, posY, posZ, ori))
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, GetGuildPhase(player), GetCreatureEntry(1), 0, posX, posY, posZ, ori))
{
handler->SendSysMessage("You already have the Guild House Butler!");
handler->SetSentErrorMessage(true);
Expand Down
37 changes: 19 additions & 18 deletions src/mod_guildhouse_butler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "GameObject.h"
#include "Transport.h"
#include "CreatureAI.h"
#include "guildhouse.h"

int cost, GuildHouseInnKeeper, GuildHouseBank, GuildHouseMailBox, GuildHouseAuctioneer, GuildHouseTrainer, GuildHouseVendor, GuildHouseObject, GuildHousePortal, GuildHouseSpirit, GuildHouseProf, GuildHouseBuyRank;

Expand Down Expand Up @@ -57,7 +58,7 @@ class GuildHouseSpawner : public CreatureScript
}

ClearGossipMenuFor(player);
AddGossipItemFor(player, GOSSIP_ICON_TALK, "Spawn Innkeeper", GOSSIP_SENDER_MAIN, 500032, "Add an Innkeeper?", GuildHouseInnKeeper, false);
AddGossipItemFor(player, GOSSIP_ICON_TALK, "Spawn Innkeeper", GOSSIP_SENDER_MAIN, GetCreatureEntry(2), "Add an Innkeeper?", GuildHouseInnKeeper, false);
AddGossipItemFor(player, GOSSIP_ICON_TALK, "Spawn Mailbox", GOSSIP_SENDER_MAIN, 184137, "Spawn a Mailbox?", GuildHouseMailBox, false);
AddGossipItemFor(player, GOSSIP_ICON_TALK, "Spawn Stable Master", GOSSIP_SENDER_MAIN, 28690, "Spawn a Stable Master?", GuildHouseVendor, false);
AddGossipItemFor(player, GOSSIP_ICON_TALK, "Spawn Class Trainer", GOSSIP_SENDER_MAIN, 2);
Expand Down Expand Up @@ -114,21 +115,21 @@ class GuildHouseSpawner : public CreatureScript
if (player->GetTeamId() == TEAM_ALLIANCE)
{
// ALLIANCE players get these options
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Ironforge", GOSSIP_SENDER_MAIN, 500003, "Add Ironforge Portal?", GuildHousePortal, false);
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Darnassus", GOSSIP_SENDER_MAIN, 500001, "Add Darnassus Portal?", GuildHousePortal, false);
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Exodar", GOSSIP_SENDER_MAIN, 500002, "Add Exodar Portal?", GuildHousePortal, false);
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Ironforge", GOSSIP_SENDER_MAIN, GetGameObjectEntry(3), "Add Ironforge Portal?", GuildHousePortal, false);
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Darnassus", GOSSIP_SENDER_MAIN, GetGameObjectEntry(1), "Add Darnassus Portal?", GuildHousePortal, false);
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Exodar", GOSSIP_SENDER_MAIN, GetGameObjectEntry(2), "Add Exodar Portal?", GuildHousePortal, false);
}
else
{
// HORDE players get these options
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Undercity", GOSSIP_SENDER_MAIN, 500007, "Add Undercity Portal?", GuildHousePortal, false);
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Thunderbluff", GOSSIP_SENDER_MAIN, 500006, "Add Thunderbuff Portal?", GuildHousePortal, false);
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Silvermoon", GOSSIP_SENDER_MAIN, 500005, "Add Silvermoon Portal?", GuildHousePortal, false);
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Undercity", GOSSIP_SENDER_MAIN, GetGameObjectEntry(7), "Add Undercity Portal?", GuildHousePortal, false);
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Thunderbluff", GOSSIP_SENDER_MAIN, GetGameObjectEntry(6), "Add Thunderbuff Portal?", GuildHousePortal, false);
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Silvermoon", GOSSIP_SENDER_MAIN, GetGameObjectEntry(5), "Add Silvermoon Portal?", GuildHousePortal, false);
}

// These two portals work for either Team
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Shattrath", GOSSIP_SENDER_MAIN, 500008, "Add Shattrath Portal?", GuildHousePortal, false);
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Dalaran", GOSSIP_SENDER_MAIN, 500009, "Add Dalaran Portal?", GuildHousePortal, false);
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Shattrath", GOSSIP_SENDER_MAIN, GetGameObjectEntry(8), "Add Shattrath Portal?", GuildHousePortal, false);
AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Dalaran", GOSSIP_SENDER_MAIN, GetGameObjectEntry(9), "Add Dalaran Portal?", GuildHousePortal, false);

AddGossipItemFor(player, GOSSIP_ICON_CHAT, "Go Back!", GOSSIP_SENDER_MAIN, 9);
SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
Expand Down Expand Up @@ -190,7 +191,7 @@ class GuildHouseSpawner : public CreatureScript
cost = GuildHouseBank;
SpawnNPC(action, player);
break;
case 500032: // Innkeeper
case GetCreatureEntry(2): // Innkeeper
cost = GuildHouseInnKeeper;
SpawnNPC(action, player);
break;
Expand Down Expand Up @@ -255,14 +256,14 @@ class GuildHouseSpawner : public CreatureScript
cost = GuildHouseObject;
SpawnObject(action, player);
break;
case 500001: // Darnassus Portal
case 500002: // Exodar Portal
case 500003: // Ironforge Portal
case 500005: // Silvermoon Portal
case 500006: // Thunder Bluff Portal
case 500007: // Undercity Portal
case 500008: // Shattrath Portal
case 500009: // Dalaran Portal
case GetGameObjectEntry(1): // Darnassus Portal
case GetGameObjectEntry(2): // Exodar Portal
case GetGameObjectEntry(3): // Ironforge Portal
case GetGameObjectEntry(5): // Silvermoon Portal
case GetGameObjectEntry(6): // Thunder Bluff Portal
case GetGameObjectEntry(7): // Undercity Portal
case GetGameObjectEntry(8): // Shattrath Portal
case GetGameObjectEntry(9): // Dalaran Portal
cost = GuildHousePortal;
SpawnObject(action, player);
break;
Expand Down
Loading