Skip to content

Commit afd6900

Browse files
authored
Scripts/Commands: Use localized names for .additem (#31270)
1 parent b64567f commit afd6900

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/server/database/Database/Implementation/WorldDatabase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ void WorldDatabaseConnection::DoPrepareStatements()
8080
PrepareStatement(WORLD_SEL_CREATURE_TEMPLATE, "SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction, npcflag, speed_walk, speed_run, scale, `rank`, dmgschool, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, dynamicflags, family, type, type_flags, lootid, pickpocketloot, skinloot, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, ctm.Chase, ctm.Random, ctm.InteractionPauseTimer, HoverHeight, HealthModifier, ManaModifier, ArmorModifier, DamageModifier, ExperienceModifier, RacialLeader, movementId, RegenHealth, mechanic_immune_mask, spell_school_immune_mask, flags_extra, ScriptName, StringId FROM creature_template ct LEFT JOIN creature_template_movement ctm ON ct.entry = ctm.CreatureId WHERE entry = ?", CONNECTION_SYNCH);
8181
PrepareStatement(WORLD_SEL_WAYPOINT_SCRIPT_BY_ID, "SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = ?", CONNECTION_SYNCH);
8282
PrepareStatement(WORLD_SEL_ITEM_TEMPLATE_BY_NAME, "SELECT entry FROM item_template WHERE name = ?", CONNECTION_SYNCH);
83+
PrepareStatement(WORLD_SEL_ITEM_TEMPLATE_LOCALE_BY_NAME, "SELECT ID FROM item_template_locale WHERE Name = ?", CONNECTION_SYNCH);
8384
PrepareStatement(WORLD_SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id = ?", CONNECTION_SYNCH);
8485
PrepareStatement(WORLD_SEL_GAMEOBJECT_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM gameobject WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_", CONNECTION_SYNCH);
8586
PrepareStatement(WORLD_SEL_CREATURE_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM creature WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_", CONNECTION_SYNCH);

src/server/database/Database/Implementation/WorldDatabase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ enum WorldDatabaseStatements : uint32
8585
WORLD_SEL_CREATURE_TEMPLATE,
8686
WORLD_SEL_WAYPOINT_SCRIPT_BY_ID,
8787
WORLD_SEL_ITEM_TEMPLATE_BY_NAME,
88+
WORLD_SEL_ITEM_TEMPLATE_LOCALE_BY_NAME,
8889
WORLD_SEL_CREATURE_BY_ID,
8990
WORLD_SEL_GAMEOBJECT_NEAREST,
9091
WORLD_SEL_CREATURE_NEAREST,

src/server/scripts/Commands/cs_misc.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,13 @@ class misc_commandscript : public CommandScript
11751175
stmt->setString(0, itemName);
11761176
PreparedQueryResult result = WorldDatabase.Query(stmt);
11771177

1178+
if (!result)
1179+
{
1180+
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_ITEM_TEMPLATE_LOCALE_BY_NAME);
1181+
stmt->setString(0, itemName);
1182+
result = WorldDatabase.Query(stmt);
1183+
}
1184+
11781185
if (!result)
11791186
{
11801187
handler->PSendSysMessage(LANG_COMMAND_COULDNOTFIND, itemNameStr+1);
@@ -1315,6 +1322,13 @@ class misc_commandscript : public CommandScript
13151322
stmt->setString(0, itemName);
13161323
PreparedQueryResult result = WorldDatabase.Query(stmt);
13171324

1325+
if (!result)
1326+
{
1327+
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_ITEM_TEMPLATE_LOCALE_BY_NAME);
1328+
stmt->setString(0, itemName);
1329+
result = WorldDatabase.Query(stmt);
1330+
}
1331+
13181332
if (!result)
13191333
{
13201334
handler->PSendSysMessage(LANG_COMMAND_COULDNOTFIND, itemNameStr + 1);

0 commit comments

Comments
 (0)