[10324] Implement new basic functions for chat command parsing.

* Now can be used as quotes any strings with symbols ' " [] around.
  For example can be used: .additem [Tourch] or .additem "Tourch".
  And in similar cases wher before [] or "" only canbe used in commands.

* New functions support propertly extraction shift-links as optional first args
* Also added more safe functions for extraction int32/uint32/float values.

For more wide use new functuons specialized extraction functions also need chnaged to same way work.
This is goal for future work at this part code.
This commit is contained in:
VladimirMangos 2010-08-06 06:14:18 +04:00
parent 373f607a44
commit edace1948e
7 changed files with 365 additions and 126 deletions

View file

@ -53,11 +53,7 @@ static uint32 ReputationRankStrIndex[MAX_REPUTATION_RANK] =
//mute player for some times
bool ChatHandler::HandleMuteCommand(char* args)
{
char* nameStr;
char* delayStr;
extractOptFirstArg(args, &nameStr, &delayStr);
if (!delayStr)
return false;
char* nameStr = ExtractOptArg(&args);
Player* target;
uint64 target_guid;
@ -65,6 +61,10 @@ bool ChatHandler::HandleMuteCommand(char* args)
if (!extractPlayerTarget(nameStr, &target, &target_guid, &target_name))
return false;
uint32 notspeaktime;
if (!ExtractUInt32(&args, notspeaktime))
return false;
uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr.GetPlayerAccountIdByGUID(target_guid);
// find only player from same account if any
@ -74,8 +74,6 @@ bool ChatHandler::HandleMuteCommand(char* args)
target = session->GetPlayer();
}
uint32 notspeaktime = (uint32) atoi(delayStr);
// must have strong lesser security level
if (HasLowerSecurity(target, target_guid, true))
return false;