mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
Implement .instance open/close commands
Example: .instance open 631 10heroic to open ICC on 10man heroic mode Ty Lockness for the testing --HG-- branch : trunk
This commit is contained in:
3
sql/updates/8397_world_command.sql
Normal file
3
sql/updates/8397_world_command.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
INSERT INTO `command` (name, security, help) VALUES ('instance open', 3, 'Syntax: .instance open mapid [normal|heroic|10normal|10heroic|25normal|25heroic]');
|
||||
INSERT INTO `command` (name, security, help) VALUES ('instance close', 3, 'Syntax: .instance close mapid [normal|heroic|10normal|10heroic|25normal|25heroic]');
|
||||
|
||||
@@ -276,6 +276,8 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ "unbind", SEC_ADMINISTRATOR, false, &ChatHandler::HandleInstanceUnbindCommand, "", NULL },
|
||||
{ "stats", SEC_ADMINISTRATOR, true, &ChatHandler::HandleInstanceStatsCommand, "", NULL },
|
||||
{ "savedata", SEC_ADMINISTRATOR, false, &ChatHandler::HandleInstanceSaveDataCommand, "", NULL },
|
||||
{ "open", SEC_ADMINISTRATOR, true, &ChatHandler::HandleInstanceOpenCommand, "", NULL },
|
||||
{ "close", SEC_ADMINISTRATOR, true, &ChatHandler::HandleInstanceCloseCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
|
||||
@@ -234,6 +234,9 @@ class ChatHandler
|
||||
bool HandleInstanceUnbindCommand(const char* args);
|
||||
bool HandleInstanceStatsCommand(const char* args);
|
||||
bool HandleInstanceSaveDataCommand(const char * args);
|
||||
bool HandleInstanceOpenCommand(const char * args);
|
||||
bool HandleInstanceCloseCommand(const char * args);
|
||||
bool HandleInstanceOpenCloseCommand(const char * args, bool open);
|
||||
|
||||
bool HandleLearnCommand(const char* args);
|
||||
bool HandleLearnAllCommand(const char* args);
|
||||
|
||||
@@ -7031,6 +7031,61 @@ bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleInstanceOpenCommand(const char *args)
|
||||
{
|
||||
return HandleInstanceOpenCloseCommand(args,true);
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleInstanceCloseCommand(const char *args)
|
||||
{
|
||||
return HandleInstanceOpenCloseCommand(args,false);
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleInstanceOpenCloseCommand(const char *args,bool open)
|
||||
{
|
||||
char *mapIdStr;
|
||||
char *instanceModeStr;
|
||||
extractOptFirstArg((char*)args,&mapIdStr,&instanceModeStr);
|
||||
if (!mapIdStr || !instanceModeStr)
|
||||
return false;
|
||||
|
||||
uint32 mapid = atoi(mapIdStr);
|
||||
|
||||
InstanceTemplate const* instance = objmgr.GetInstanceTemplate(mapid);
|
||||
if (!instance)
|
||||
{
|
||||
PSendSysMessage("Invalid map id");
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8 status = objmgr.GetAccessRequirement(instance->access_id)->status;
|
||||
uint8 flag = 0;
|
||||
|
||||
if (strcmp(instanceModeStr,"normal") || strcmp(instanceModeStr,"10normal"))
|
||||
flag = DUNGEON_STATUSFLAG_NORMAL;
|
||||
else if (strcmp(instanceModeStr,"heroic") || strcmp(instanceModeStr,"25normal"))
|
||||
flag = DUNGEON_STATUSFLAG_HEROIC;
|
||||
else if (strcmp(instanceModeStr,"10heroic"))
|
||||
flag = RAID_STATUSFLAG_10MAN_HEROIC;
|
||||
else if (strcmp(instanceModeStr,"25heroic"))
|
||||
flag = RAID_STATUSFLAG_25MAN_HEROIC;
|
||||
else
|
||||
{
|
||||
PSendSysMessage("Unrecognized difficulty string");
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
if (open)
|
||||
status |= flag;
|
||||
else
|
||||
status &= ~flag;
|
||||
|
||||
WorldDatabase.PExecute("UPDATE access_requirement SET status = '%u' WHERE id = '%u'", status, instance->access_id);
|
||||
PSendSysMessage("Instance status changed. Don't forget to reload access_requirement table");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Display the list of GMs
|
||||
bool ChatHandler::HandleGMListFullCommand(const char* /*args*/)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user