[Patch] Possible to Show ban in the world?

Hello, i wonder if it is possible to show bans in the world like kick in the world.

So someone got a idea how to do that?

[CODE]# HG changeset patch

User chaosua

Date 1281569247 -10800

Branch trunk

Node ID d7db98fb74fed827b4d9ea720d2d3a991d88f68e

Parent 5330a30aeeb3e63b30f728175c7f12a37c5563a5

MOD ban mute kick announce

diff -r 5330a30aeeb3 -r d7db98fb74fe src/server/game/Chat/Commands/Level2.cpp

— a/src/server/game/Chat/Commands/Level2.cpp Fri Jul 23 00:51:40 2010 +0300

+++ b/src/server/game/Chat/Commands/Level2.cpp Thu Aug 12 02:27:27 2010 +0300

@@ -51,6 +51,8 @@

//mute player for some times

bool ChatHandler::HandleMuteCommand(const char* args)

{

  • std::string announce;

 char* nameStr;

 char* delayStr;

 extractOptFirstArg((char*)args,&nameStr,&delayStr);

@@ -60,7 +62,14 @@

 char *mutereason = strtok(NULL, "\r");

 std::string mutereasonstr = "No reason";

 if (mutereason != NULL)
  •     mutereasonstr = mutereason;
    
  •    mutereasonstr = mutereason;
    
  • if(!mutereason)

  • {

  •    PSendSysMessage("You must enter a reason of mute");
    
  •    SetSentErrorMessage(true);
    
  •    return false;
    
  • }

    Player* target;

    uint64 target_guid;

@@ -95,6 +104,16 @@

 PSendSysMessage(LANG_YOU_DISABLE_CHAT, nameLink.c_str(), notspeaktime, mutereasonstr.c_str());
  • announce = “The character '”;

  • announce += nameStr;

  • announce += "’ was muted for ";

  • announce += delayStr;

  • announce += " minutes by the character '";

  • announce += m_session->GetPlayerName();

  • announce += "'. The reason is: ";

  • announce += mutereason;

  • HandleAnnounceCommand(announce.c_str());

 return true;

}

@@ -2108,6 +2127,9 @@

     }

 }*/

 Player* target;
  • std::string announce;

 if (!extractPlayerTarget((char*)args,&target))

     return false;

@@ -2125,6 +2147,14 @@

 // send before target pointer invalidate

 PSendSysMessage(LANG_COMMAND_KICKMESSAGE,GetNameLink(target).c_str());

 target->GetSession()->KickPlayer();
  • announce = “The character '”;

  • announce += target->GetName();

  • announce += “’ was kicked by the character '”;

  • announce += m_session->GetPlayerName();

  • announce += “'.”;

  • HandleAnnounceCommand(announce.c_str());

 return true;

}

diff -r 5330a30aeeb3 -r d7db98fb74fe src/server/game/Chat/Commands/Level3.cpp

— a/src/server/game/Chat/Commands/Level3.cpp Fri Jul 23 00:51:40 2010 +0300

+++ b/src/server/game/Chat/Commands/Level3.cpp Thu Aug 12 02:27:27 2010 +0300

@@ -5449,6 +5449,8 @@

 if (!*args)

     return false;
  • std::string announce;

 char* cnameOrIP = strtok ((char*)args, " ");

 if (!cnameOrIP)

     return false;

@@ -5514,6 +5516,21 @@

         return false;

 }
  • if (mode == BAN_CHARACTER)

  •    announce = "The character '";
    
  • else if (mode == BAN_IP)

  •    announce = "The IP '";
    
  • else

  • announce = “Account '”;

  • announce += nameOrIP.c_str();

  • announce += "’ was banned for ";

  • announce += duration;

  • announce += " by the character '";

  • announce += m_session->GetPlayerName();

  • announce += "'. The reason is: ";

  • announce += reason;

  • HandleAnnounceCommand(announce.c_str());

 return true;

}[/CODE]

Ban, Kick, Mute patch - maybe old so apply it manual … NOT MY WORK!

EDIT - It is for HG /emoticons/default_biggrin.png

where is the handlemute command stored? cant find it in level 2 or 3 0.0

nvm lol found it

could someone update this patch for the latest? im unable to add it manually /;

Here i rewrote, only ban announce(freeze & mute is unnessasery i think)

[CODE]diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp

index a10f809…bb42364 100755

— a/src/server/game/Chat/Commands/Level3.cpp

+++ b/src/server/game/Chat/Commands/Level3.cpp

@@ -2991,6 +2991,28 @@ bool ChatHandler::HandleBanHelper(BanMode mode, const char *args)

         SetSentErrorMessage(true);

         return false;

 }
  • //custom

  • std::string announce;

  • switch(mode)

  • {

  •    case BAN_ACCOUNT:
    
  •        announce = "Account '";
    
  •        break;
    
  •    case BAN_CHARACTER:
    
  •        announce = "The character '";
    
  •        break;
    
  •    case BAN_IP:
    
  •        announce = "The IP '";
    
  •        break;       
    
  • }

  • announce += nameOrIP.c_str();

  • announce += "’ was banned for ";

  • announce += duration;

  • announce += ". The reason is: ";

  • announce += reason;

  • HandleAnnounceCommand(announce.c_str());

    return true;

}

[/CODE]

Is that tested, and working?

Suggestion;

Announce: Kicks and bans.

For kicks:

%Player% has been kicked by %Player% for %Reason%

For Banned:

%Player% has been banned by %Player% for %Reason% for %Duration%

it doesnt announce when i ban a character.

Ye kinda weird :S, im gonna watch it /emoticons/default_sad.png )

@Shadow, kick already exist to show in world, check config

EDIT: here is a patch for .ban char

[CODE]diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp

index bb42364…2c75d2c 100755

— a/src/server/game/Chat/Commands/Level3.cpp

+++ b/src/server/game/Chat/Commands/Level3.cpp

@@ -2914,6 +2914,15 @@ bool ChatHandler::HandleBanCharacterCommand(const char *args)

         break;

 }
  • std::string announce;

  • announce = “Character: '”;

  • announce += name.c_str();

  • announce += "’ was banned for ";

  • announce += duration;

  • announce += ". The reason is: ";

  • announce += reason;

  • HandleAnnounceCommand(announce.c_str());

 return true;

}

[/CODE]

I dunno if you know, but there is an Option for this in worldserver.conf.

[CODE]#

ShowKickInWorld

Description: Determines whether a message is broadcasted to the entire server when a

player gets kicked

Default: 0 - (Disabled)

1 - (Enabled)

ShowKickInWorld = 0[/CODE]

also i dunno if it’s working, but with that you don’t need any patch.

There exists simpler way, without ugly string leak…

[CODE]diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp

— a/src/server/game/Chat/Commands/Level2.cpp

+++ b/src/server/game/Chat/Commands/Level2.cpp

@@ -47,7 +47,6 @@

//mute player for some times

bool ChatHandler::HandleMuteCommand(const char* args)

{

  • std::string announce;

    char* nameStr;

    char* delayStr;

@@ -98,5 +97,4 @@

 std::string nameLink = playerLink(target_name);
  • PSendSysMessage(LANG_YOU_DISABLE_CHAT, nameLink.c_str(), notspeaktime, mutereasonstr.c_str());

@@ -102,14 +100,8 @@

  • announce = “The character '”;

  • announce += nameStr;

  • announce += "’ was muted for ";

  • announce += delayStr;

  • announce += " minutes by the GM '";

  • announce += m_session->GetPlayerName();

  • announce += "'. The reason is: ";

  • announce += mutereason;

  • HandleAnnounceCommand(announce.c_str());

  • if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD))

  •    sWorld->SendWorldText(LANG_YOU_DISABLE_CHAT, nameLink.c_str(), notspeaktime, mutereasonstr.c_str());
    
  • else

  •    PSendSysMessage(LANG_YOU_DISABLE_CHAT, nameLink.c_str(), notspeaktime, mutereasonstr.c_str());
    

    return true;

}

@@ -226,8 +218,6 @@

//kick player

bool ChatHandler::HandleKickPlayerCommand(const char *args)

{

  • std::string announce;

 const char* kickName = strtok((char*)args, " ");

 Player* target = NULL;

 std::string playerName;

@@ -252,13 +242,6 @@

 target->GetSession()->KickPlayer();
  • announce = “The character '”;

  • announce += target->GetName();

  • announce += “’ was kicked by the GM '”;

  • announce += m_session->GetPlayerName();

  • announce += “'.”;

  • HandleAnnounceCommand(announce.c_str());

 return true;

}

@@ -267,8 +250,6 @@

{

 Player* target;
  • std::string announce;

 uint64 target_guid;

 std::string target_name;

 if (!extractPlayerTarget((char*)args,&target,&target_guid,&target_name))

diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp

— a/src/server/game/Chat/Commands/Level3.cpp

+++ b/src/server/game/Chat/Commands/Level3.cpp

@@ -2969,9 +2969,17 @@

 {

     case BAN_SUCCESS:

         if (atoi(duration)>0)
  •            PSendSysMessage(LANG_BAN_YOUBANNED,nameOrIP.c_str(),secsToTimeString(TimeStringToSecs(duration),true).c_str(),reason);
    
  •        else
    
  •            PSendSysMessage(LANG_BAN_YOUPERMBANNED,nameOrIP.c_str(),reason);
    
  •        {
    
  •            if (CONFIG_SHOW_BAN_IN_WORLD)
    
  •                sWorld->SendWorldText(LANG_BAN_YOUBANNED,nameOrIP.c_str(),secsToTimeString(TimeStringToSecs(duration),true).c_str(),reason);
    
  •            else
    
  •                PSendSysMessage(LANG_BAN_YOUBANNED,nameOrIP.c_str(),secsToTimeString(TimeStringToSecs(duration),true).c_str(),reason);
    
  •        } else {
    
  •            if (CONFIG_SHOW_BAN_IN_WORLD)
    
  •                sWorld->SendWorldText(LANG_BAN_YOUPERMBANNED,nameOrIP.c_str(),reason);
    
  •            else
    
  •                PSendSysMessage(LANG_BAN_YOUPERMBANNED,nameOrIP.c_str(),reason);
    
  •        }
    
           break;
    
       case BAN_SYNTAX_ERROR:
    
           return false;
    

@@ -2992,23 +3000,6 @@

         return false;

 }
  • std::string announce;

  • if (mode == BAN_CHARACTER)

  •    announce = "The character '";
    
  • else if (mode == BAN_IP)

  •    announce = "The IP '";
    
  • else

  • announce = “Account '”;

  • announce += nameOrIP.c_str();

  • announce += "’ was banned for ";

  • announce += duration;

  • announce += " by the GM '";

  • announce += m_session->GetPlayerName();

  • announce += "'. The reason is: ";

  • announce += reason;

  • HandleAnnounceCommand(announce.c_str());

 return true;

}

diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp

— a/src/server/game/World/World.cpp

+++ b/src/server/game/World/World.cpp

@@ -1166,6 +1166,8 @@

 m_bool_configs[CONFIG_NO_RESET_TALENT_COST] = sConfig->GetBoolDefault("NoResetTalentsCost", false);

 m_bool_configs[CONFIG_SHOW_KICK_IN_WORLD] = sConfig->GetBoolDefault("ShowKickInWorld", false);
  • m_bool_configs[CONFIG_SHOW_MUTE_IN_WORLD] = sConfig->GetBoolDefault(“ShowMuteInWorld”, false);

  • m_bool_configs[CONFIG_SHOW_BAN_IN_WORLD] = sConfig->GetBoolDefault(“ShowBanInWorld”, false);

    m_int_configs[CONFIG_INTERVAL_LOG_UPDATE] = sConfig->GetIntDefault(“RecordUpdateTimeDiffInterval”, 60000);

    m_int_configs[CONFIG_MIN_LOG_UPDATE] = sConfig->GetIntDefault(“MinRecordUpdateTimeDiff”, 100);

    m_int_configs[CONFIG_NUMTHREADS] = sConfig->GetIntDefault(“MapUpdate.Threads”, 1);

diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h

— a/src/server/game/World/World.h

+++ b/src/server/game/World/World.h

@@ -149,6 +149,8 @@

 CONFIG_PVP_TOKEN_ENABLE,

 CONFIG_NO_RESET_TALENT_COST,

 CONFIG_SHOW_KICK_IN_WORLD,
  • CONFIG_SHOW_MUTE_IN_WORLD,

  • CONFIG_SHOW_BAN_IN_WORLD,

    CONFIG_CHATLOG_CHANNEL,

    CONFIG_CHATLOG_WHISPER,

    CONFIG_CHATLOG_SYSCHAN,

diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist

— a/src/server/worldserver/worldserver.conf.dist

+++ b/src/server/worldserver/worldserver.conf.dist

@@ -2693,6 +2693,24 @@

ShowKickInWorld = 0

+# ShowMuteInWorld

+# Description: Determines whether a message is broadcasted to the entire server when a

+# player gets muted

+# Default: 0 - (Disabled)

+# 1 - (Enabled)

+ShowMuteInWorld = 0

+#

+# ShowBanInWorld

+# Description: Determines whether a message is broadcasted to the entire server when a

+# player gets banned

+# Default: 0 - (Disabled)

+# 1 - (Enabled)

+ShowBanInWorld = 0

+#

RecordUpdateTimeDiffInterval

Description: Time (in milliseconds) update time diff is written to the log file.

Update diff can be used as a performance indicator. Diff < 300: good

[/CODE]

Added: Fix some stupid typo.

Added: Another typo…

^ will try it

I want describe why such code

[CODE]- std::string announce;

  • if (mode == BAN_CHARACTER)

  •    announce = "The character '";
    
  • else if (mode == BAN_IP)

  •    announce = "The IP '";
    
  • else

  • announce = “Account '”;

  • announce += nameOrIP.c_str();

  • announce += "’ was banned for ";

  • announce += duration;

  • announce += " by the GM '";

  • announce += m_session->GetPlayerName();

  • announce += "'. The reason is: ";

  • announce += reason;

  • HandleAnnounceCommand(announce.c_str());

[/CODE] is shitty.

string is a static massive of characters in such way at every += it create a new one string. So in that way at HandleAnnounceCommand we create 10 strings.

In other words:

[CODE]string operator +=(string incStr)

{

char* buff = new char[this->Length + incStr.Length + 1];

… there is adding symbols from current and incoming strings

return string(buff);

}[/CODE]
Smth like that.

Then improve on it, instead of shooting it down?

See this post for improvements.

how does this look like ingame when you ban an account or char?

It will show an ordinary message in red. Colours you can configure via DB trinity_string.

What about iostream? Would that be better or the same as the string +=?

It’s still be a bad way. Anyway if you want use that way use stringbuilder, it would be not so bad.

But why you don’t use trinity_string to store string view and just get it from the table instead forming it in the function?