Skip to content

Commit f2a83e8

Browse files
authored
Core/Commands: Improve wp event command (#30226)
* Fixed crash by handling null arg_id in .wp event add * Fixed incorrect data type conversion in .wp event listid
1 parent 3e9f8a7 commit f2a83e8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/server/scripts/Commands/cs_wp.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ class wp_commandscript : public CommandScript
302302

303303
if (show == "add")
304304
{
305-
if (Optional<uint32> id = Trinity::StringTo<uint32>(arg_id))
305+
Optional<uint32> id;
306+
if (arg_id)
307+
id = Trinity::StringTo<uint32>(arg_id);
308+
309+
if (id)
306310
{
307311
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID);
308312
stmt->setUInt32(0, *id);
@@ -344,9 +348,8 @@ class wp_commandscript : public CommandScript
344348

345349
uint32 id = Trinity::StringTo<uint32>(arg_id).value_or(0);
346350

347-
uint32 a2, a3, a4, a5, a6;
351+
uint32 a2, a3, a4, a5, a6, a7;
348352
float a8, a9, a10, a11;
349-
char const* a7;
350353

351354
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_BY_ID);
352355
stmt->setUInt32(0, id);
@@ -368,13 +371,13 @@ class wp_commandscript : public CommandScript
368371
a4 = fields[2].GetUInt32();
369372
a5 = fields[3].GetUInt32();
370373
a6 = fields[4].GetUInt32();
371-
a7 = fields[5].GetCString();
374+
a7 = fields[5].GetUInt32();
372375
a8 = fields[6].GetFloat();
373376
a9 = fields[7].GetFloat();
374377
a10 = fields[8].GetFloat();
375378
a11 = fields[9].GetFloat();
376379

377-
handler->PSendSysMessage("|cffff33ffid:|r|cff00ffff %u|r|cff00ff00, guid: |r|cff00ffff%u|r|cff00ff00, delay: |r|cff00ffff%u|r|cff00ff00, command: |r|cff00ffff%u|r|cff00ff00, datalong: |r|cff00ffff%u|r|cff00ff00, datalong2: |r|cff00ffff%u|r|cff00ff00, datatext: |r|cff00ffff%s|r|cff00ff00, posx: |r|cff00ffff%f|r|cff00ff00, posy: |r|cff00ffff%f|r|cff00ff00, posz: |r|cff00ffff%f|r|cff00ff00, orientation: |r|cff00ffff%f|r", id, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
380+
handler->PSendSysMessage("|cffff33ffid:|r|cff00ffff %u|r|cff00ff00, guid: |r|cff00ffff%u|r|cff00ff00, delay: |r|cff00ffff%u|r|cff00ff00, command: |r|cff00ffff%u|r|cff00ff00, datalong: |r|cff00ffff%u|r|cff00ff00, datalong2: |r|cff00ffff%u|r|cff00ff00, dataint: |r|cff00ffff%u|r|cff00ff00, posx: |r|cff00ffff%f|r|cff00ff00, posy: |r|cff00ffff%f|r|cff00ff00, posz: |r|cff00ffff%f|r|cff00ff00, orientation: |r|cff00ffff%f|r", id, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
378381
}
379382
while (result->NextRow());
380383
}

0 commit comments

Comments
 (0)