Skip to content

Commit

Permalink
Core/Commands: Implement .debug moveflags command. With params you ca…
Browse files Browse the repository at this point in the history
…n set MoveFlags and MoveFlagsExtra for targeted unit. Without params it will display the current MoveFlags and MoveFlagsExtra. Useful for debugging upcoming changes.
  • Loading branch information
Machiavell1 committed Mar 3, 2012
1 parent a08fe16 commit d1e4eb0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
9 changes: 9 additions & 0 deletions sql/updates/world/2012_03_03_00_world_command.sql
@@ -0,0 +1,9 @@
DELETE FROM `command` WHERE `name` LIKE 'debug moveflags';
INSERT INTO `command` (`name`,`security`,`help`) VALUES
('debug moveflags',3,'Syntax: .debug moveflags [$newMoveFlags [$newMoveFlags2]]\r\nNo params given will output the current moveflags of the target');

DELETE FROM `trinity_string` WHERE `entry` IN(1143,1144);
INSERT INTO `trinity_string` (`entry`,`content_default`) VALUES
(1143,'Target''s moveFlags: %u, moveFlagsExtra: %u.'),
(1144,'Target''s moveFlags set to: %u, moveFlagsExtra to: %u');

4 changes: 3 additions & 1 deletion src/server/game/Miscellaneous/Language.h
Expand Up @@ -811,7 +811,9 @@ enum TrinityStrings
LANG_MOVEGENS_FOLLOW_CREATURE = 1140,
LANG_MOVEGENS_FOLLOW_NULL = 1141,
LANG_MOVEGENS_EFFECT = 1142,
// Room for more level 3 1143-1199 not used
LANG_MOVEFLAGS_GET = 1143,
LANG_MOVEFLAGS_SET = 1144,
// Room for more level 3 1144-1199 not used

// Debug commands
LANG_CINEMATIC_NOT_EXIST = 1200,
Expand Down
34 changes: 34 additions & 0 deletions src/server/scripts/Commands/cs_debug.cpp
Expand Up @@ -89,6 +89,7 @@ class debug_commandscript : public CommandScript
{ "itemexpire", SEC_ADMINISTRATOR, false, &HandleDebugItemExpireCommand, "", NULL },
{ "areatriggers", SEC_ADMINISTRATOR, false, &HandleDebugAreaTriggersCommand, "", NULL },
{ "los", SEC_MODERATOR, false, &HandleDebugLoSCommand, "", NULL },
{ "moveflags", SEC_ADMINISTRATOR, false, &HandleDebugMoveflagsCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
Expand Down Expand Up @@ -1283,6 +1284,39 @@ class debug_commandscript : public CommandScript
handler->PSendSysMessage(LANG_SET_32BIT_FIELD, opcode, value);
return true;
}

static bool HandleDebugMoveflagsCommand(ChatHandler* handler, char const* args)
{
Unit* target = handler->getSelectedUnit();
if (!target)
target = handler->GetSession()->GetPlayer();

if (!*args)
{
//! Display case
handler->PSendSysMessage(LANG_MOVEFLAGS_GET, target->GetUnitMovementFlags(), target->GetExtraUnitMovementFlags());
}
else
{
char* mask1 = strtok((char*)args, " ");
if (!mask1)
return false;

char* mask2 = strtok(NULL, " \n");

uint32 moveFlags = (uint32)atoi(mask1);
target->SetUnitMovementFlags(moveFlags);

if (mask2)
{
uint32 moveFlagsExtra = uint32(atoi(mask2));
target->SetExtraUnitMovementFlags(moveFlagsExtra);
}

target->SendMovementFlagUpdate();
handler->PSendSysMessage(LANG_MOVEFLAGS_SET, target->GetUnitMovementFlags(), target->GetExtraUnitMovementFlags());
}
}
};

void AddSC_debug_commandscript()
Expand Down

1 comment on commit d1e4eb0

@Kretol
Copy link
Contributor

@Kretol Kretol commented on d1e4eb0 Mar 4, 2012

Choose a reason for hiding this comment

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

Awesome!

Please sign in to comment.