[8167] Use more consistence debug command handler names and move its code to debugcmds.cpp

This commit is contained in:
VladimirMangos 2009-07-12 15:47:38 +04:00
parent f84a68553c
commit 7f3f21ee1a
5 changed files with 199 additions and 199 deletions

View file

@ -148,18 +148,18 @@ ChatCommand * ChatHandler::getCommandTable()
{ "anim", SEC_GAMEMASTER, false, &ChatHandler::HandleDebugAnimCommand, "", NULL },
{ "arena", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugArenaCommand, "", NULL },
{ "bg", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugBattlegroundCommand, "", NULL },
{ "getitemstate", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugGetItemState, "", NULL },
{ "lootrecipient", SEC_GAMEMASTER, false, &ChatHandler::HandleDebugGetLootRecipient, "", NULL },
{ "getvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugGetValue, "", NULL },
{ "Mod32Value", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugMod32Value, "", NULL },
{ "getitemstate", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugGetItemStateCommand, "", NULL },
{ "lootrecipient", SEC_GAMEMASTER, false, &ChatHandler::HandleDebugGetLootRecipientCommand, "", NULL },
{ "getvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugGetValueCommand, "", NULL },
{ "Mod32Value", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugMod32ValueCommand, "", NULL },
{ "play", SEC_MODERATOR, false, NULL, "", debugPlayCommandTable },
{ "send", SEC_ADMINISTRATOR, false, NULL, "", debugSendCommandTable },
{ "setaurastate", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetAuraStateCommand, "", NULL },
{ "setitemflag", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetItemFlagCommand, "", NULL },
{ "setvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetValue, "", NULL },
{ "setvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetValueCommand, "", NULL },
{ "spawnvehicle", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSpawnVehicle, "", NULL },
{ "uws", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugUpdateWorldStateCommand, "", NULL },
{ "update", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugUpdate, "", NULL },
{ "update", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugUpdateCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
@ -1643,4 +1643,4 @@ LocaleConstant CliHandler::GetSessionDbcLocale() const
int CliHandler::GetSessionDbLocaleIndex() const
{
return objmgr.GetDBCLocaleIndex();
}
}

View file

@ -128,15 +128,15 @@ class ChatHandler
bool HandleDebugAnimCommand(const char* args);
bool HandleDebugArenaCommand(const char * args);
bool HandleDebugBattlegroundCommand(const char * args);
bool HandleDebugGetItemState(const char * args);
bool HandleDebugGetLootRecipient(const char * args);
bool HandleDebugGetValue(const char* args);
bool HandleDebugMod32Value(const char* args);
bool HandleDebugGetItemStateCommand(const char * args);
bool HandleDebugGetLootRecipientCommand(const char * args);
bool HandleDebugGetValueCommand(const char* args);
bool HandleDebugMod32ValueCommand(const char* args);
bool HandleDebugSetAuraStateCommand(const char * args);
bool HandleDebugSetItemFlagCommand(const char * args);
bool HandleDebugSetValue(const char* args);
bool HandleDebugSetValueCommand(const char* args);
bool HandleDebugSpawnVehicle(const char * args);
bool HandleDebugUpdate(const char* args);
bool HandleDebugUpdateCommand(const char* args);
bool HandleDebugUpdateWorldStateCommand(const char* args);
bool HandleDebugPlayCinematicCommand(const char* args);

View file

@ -4085,57 +4085,6 @@ bool ChatHandler::HandleHideAreaCommand(const char* args)
return true;
}
bool ChatHandler::HandleDebugUpdate(const char* args)
{
if(!*args)
return false;
uint32 updateIndex;
uint32 value;
char* pUpdateIndex = strtok((char*)args, " ");
Unit* chr = getSelectedUnit();
if (chr == NULL)
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true);
return false;
}
if(!pUpdateIndex)
{
return true;
}
updateIndex = atoi(pUpdateIndex);
//check updateIndex
if(chr->GetTypeId() == TYPEID_PLAYER)
{
if (updateIndex>=PLAYER_END) return true;
}
else
{
if (updateIndex>=UNIT_END) return true;
}
char* pvalue = strtok(NULL, " ");
if (!pvalue)
{
value=chr->GetUInt32Value(updateIndex);
PSendSysMessage(LANG_UPDATE, chr->GetGUIDLow(),updateIndex,value);
return true;
}
value=atoi(pvalue);
PSendSysMessage(LANG_UPDATE_CHANGE, chr->GetGUIDLow(),updateIndex,value);
chr->SetUInt32Value(updateIndex,value);
return true;
}
bool ChatHandler::HandleBankCommand(const char* /*args*/)
{
m_session->SendShowBank( m_session->GetPlayer()->GetGUID() );
@ -4185,106 +4134,6 @@ bool ChatHandler::HandleChangeWeather(const char* args)
return true;
}
bool ChatHandler::HandleDebugSetValue(const char* args)
{
if(!*args)
return false;
char* px = strtok((char*)args, " ");
char* py = strtok(NULL, " ");
char* pz = strtok(NULL, " ");
if (!px || !py)
return false;
Unit* target = getSelectedUnit();
if(!target)
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true);
return false;
}
uint64 guid = target->GetGUID();
uint32 Opcode = (uint32)atoi(px);
if(Opcode >= target->GetValuesCount())
{
PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount());
return false;
}
uint32 iValue;
float fValue;
bool isint32 = true;
if(pz)
isint32 = (bool)atoi(pz);
if(isint32)
{
iValue = (uint32)atoi(py);
sLog.outDebug(GetMangosString(LANG_SET_UINT), GUID_LOPART(guid), Opcode, iValue);
target->SetUInt32Value( Opcode , iValue );
PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode,iValue);
}
else
{
fValue = (float)atof(py);
sLog.outDebug(GetMangosString(LANG_SET_FLOAT), GUID_LOPART(guid), Opcode, fValue);
target->SetFloatValue( Opcode , fValue );
PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode,fValue);
}
return true;
}
bool ChatHandler::HandleDebugGetValue(const char* args)
{
if(!*args)
return false;
char* px = strtok((char*)args, " ");
char* pz = strtok(NULL, " ");
if (!px)
return false;
Unit* target = getSelectedUnit();
if(!target)
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true);
return false;
}
uint64 guid = target->GetGUID();
uint32 Opcode = (uint32)atoi(px);
if(Opcode >= target->GetValuesCount())
{
PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount());
return false;
}
uint32 iValue;
float fValue;
bool isint32 = true;
if(pz)
isint32 = (bool)atoi(pz);
if(isint32)
{
iValue = target->GetUInt32Value( Opcode );
sLog.outDebug(GetMangosString(LANG_GET_UINT), GUID_LOPART(guid), Opcode, iValue);
PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue);
}
else
{
fValue = target->GetFloatValue( Opcode );
sLog.outDebug(GetMangosString(LANG_GET_FLOAT), GUID_LOPART(guid), Opcode, fValue);
PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue);
}
return true;
}
bool ChatHandler::HandleSet32Bit(const char* args)
{
if(!*args)
@ -4309,38 +4158,6 @@ bool ChatHandler::HandleSet32Bit(const char* args)
return true;
}
bool ChatHandler::HandleDebugMod32Value(const char* args)
{
if(!*args)
return false;
char* px = strtok((char*)args, " ");
char* py = strtok(NULL, " ");
if (!px || !py)
return false;
uint32 Opcode = (uint32)atoi(px);
int Value = atoi(py);
if(Opcode >= m_session->GetPlayer()->GetValuesCount())
{
PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, m_session->GetPlayer()->GetGUIDLow(), m_session->GetPlayer( )->GetValuesCount());
return false;
}
sLog.outDebug(GetMangosString(LANG_CHANGE_32BIT), Opcode, Value);
int CurrentValue = (int)m_session->GetPlayer( )->GetUInt32Value( Opcode );
CurrentValue += Value;
m_session->GetPlayer( )->SetUInt32Value( Opcode , (uint32)CurrentValue );
PSendSysMessage(LANG_CHANGE_32BIT_FIELD, Opcode,CurrentValue);
return true;
}
bool ChatHandler::HandleTeleAddCommand(const char * args)
{
if(!*args)

View file

@ -336,7 +336,7 @@ bool ChatHandler::HandleDebugSendQuestPartyMsgCommand(const char* args)
return true;
}
bool ChatHandler::HandleDebugGetLootRecipient(const char* /*args*/)
bool ChatHandler::HandleDebugGetLootRecipientCommand(const char* /*args*/)
{
Creature* target = getSelectedCreature();
if (!target)
@ -353,7 +353,7 @@ bool ChatHandler::HandleDebugSendQuestInvalidMsgCommand(const char* args)
return true;
}
bool ChatHandler::HandleDebugGetItemState(const char* args)
bool ChatHandler::HandleDebugGetItemStateCommand(const char* args)
{
if (!*args)
return false;
@ -733,3 +733,186 @@ bool ChatHandler::HandleDebugSetAuraStateCommand(const char* args)
unit->ModifyAuraState(AuraState(abs(state)),state > 0);
return true;
}
bool ChatHandler::HandleDebugSetValueCommand(const char* args)
{
if(!*args)
return false;
char* px = strtok((char*)args, " ");
char* py = strtok(NULL, " ");
char* pz = strtok(NULL, " ");
if (!px || !py)
return false;
Unit* target = getSelectedUnit();
if(!target)
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true);
return false;
}
uint64 guid = target->GetGUID();
uint32 Opcode = (uint32)atoi(px);
if(Opcode >= target->GetValuesCount())
{
PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount());
return false;
}
uint32 iValue;
float fValue;
bool isint32 = true;
if(pz)
isint32 = (bool)atoi(pz);
if(isint32)
{
iValue = (uint32)atoi(py);
sLog.outDebug(GetMangosString(LANG_SET_UINT), GUID_LOPART(guid), Opcode, iValue);
target->SetUInt32Value( Opcode , iValue );
PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode,iValue);
}
else
{
fValue = (float)atof(py);
sLog.outDebug(GetMangosString(LANG_SET_FLOAT), GUID_LOPART(guid), Opcode, fValue);
target->SetFloatValue( Opcode , fValue );
PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode,fValue);
}
return true;
}
bool ChatHandler::HandleDebugGetValueCommand(const char* args)
{
if(!*args)
return false;
char* px = strtok((char*)args, " ");
char* pz = strtok(NULL, " ");
if (!px)
return false;
Unit* target = getSelectedUnit();
if(!target)
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true);
return false;
}
uint64 guid = target->GetGUID();
uint32 Opcode = (uint32)atoi(px);
if(Opcode >= target->GetValuesCount())
{
PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount());
return false;
}
uint32 iValue;
float fValue;
bool isint32 = true;
if(pz)
isint32 = (bool)atoi(pz);
if(isint32)
{
iValue = target->GetUInt32Value( Opcode );
sLog.outDebug(GetMangosString(LANG_GET_UINT), GUID_LOPART(guid), Opcode, iValue);
PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue);
}
else
{
fValue = target->GetFloatValue( Opcode );
sLog.outDebug(GetMangosString(LANG_GET_FLOAT), GUID_LOPART(guid), Opcode, fValue);
PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue);
}
return true;
}
bool ChatHandler::HandleDebugMod32ValueCommand(const char* args)
{
if(!*args)
return false;
char* px = strtok((char*)args, " ");
char* py = strtok(NULL, " ");
if (!px || !py)
return false;
uint32 Opcode = (uint32)atoi(px);
int Value = atoi(py);
if(Opcode >= m_session->GetPlayer()->GetValuesCount())
{
PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, m_session->GetPlayer()->GetGUIDLow(), m_session->GetPlayer( )->GetValuesCount());
return false;
}
sLog.outDebug(GetMangosString(LANG_CHANGE_32BIT), Opcode, Value);
int CurrentValue = (int)m_session->GetPlayer( )->GetUInt32Value( Opcode );
CurrentValue += Value;
m_session->GetPlayer( )->SetUInt32Value( Opcode , (uint32)CurrentValue );
PSendSysMessage(LANG_CHANGE_32BIT_FIELD, Opcode,CurrentValue);
return true;
}
bool ChatHandler::HandleDebugUpdateCommand(const char* args)
{
if(!*args)
return false;
uint32 updateIndex;
uint32 value;
char* pUpdateIndex = strtok((char*)args, " ");
Unit* chr = getSelectedUnit();
if (chr == NULL)
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true);
return false;
}
if(!pUpdateIndex)
{
return true;
}
updateIndex = atoi(pUpdateIndex);
//check updateIndex
if(chr->GetTypeId() == TYPEID_PLAYER)
{
if (updateIndex>=PLAYER_END) return true;
}
else
{
if (updateIndex>=UNIT_END) return true;
}
char* pvalue = strtok(NULL, " ");
if (!pvalue)
{
value=chr->GetUInt32Value(updateIndex);
PSendSysMessage(LANG_UPDATE, chr->GetGUIDLow(),updateIndex,value);
return true;
}
value=atoi(pvalue);
PSendSysMessage(LANG_UPDATE_CHANGE, chr->GetGUIDLow(),updateIndex,value);
chr->SetUInt32Value(updateIndex,value);
return true;
}

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8166"
#define REVISION_NR "8167"
#endif // __REVISION_NR_H__