This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [C++] Trinity Announce System  (Read 4915 times)

Everon Mightbane

  • Registred Member
  • Loreweaver
  • *****
  • Posts: 89
    • View Profile
Re: [C++] Trinity Announce System
« Reply #15 on: August 27, 2011, 10:00:47 pm »
Meh. Well that sucks. Thanks anyway.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Everon Mightbane

  • Registred Member
  • Loreweaver
  • *****
  • Posts: 89
    • View Profile
Re: [C++] Trinity Announce System
« Reply #16 on: August 28, 2011, 08:10:35 pm »
Sorry for double posting, but could someone take a look at this and tell me why its not working, it compiles just fine, however when I use .announce my worldserver.exe crashes.: [spoiler:2mi2ysll]
Code: [Select]
#include "Chat.h"
#include "ScriptPCH.h"
class ann_commandscript : public CommandScript
{
public:
    ann_commandscript() : CommandScript("ann_commandscript") { }
    ChatCommand* GetCommands() const
    {
        static ChatCommand commandTable[] =
        {
            { "announce",                              SEC_PLAYER,  true, &HandleAnnounceCommand,                                  "", NULL },
{ NULL,                                             0, false, NULL,                                                    "", NULL }
        };
        return commandTable;
    };
static bool HandleAnnounceCommand(ChatHandler* handler, const char* args)
{
    std::string rank("");
    uint32 gmlevel;
    WorldPacket data;
    std::string name("Console");
    if (WorldSession* session = handler->GetSession())
    {
Player* player = session->GetPlayer();
gmlevel = player->GetSession()->GetSecurity();
    switch (gmlevel)
{
    case 0:
      rank = "|cff0051FFPlayer|r"; break;
    case 1:
      rank = "|cff88DC51Voter|r"; break;
    case 2:
      rank = "|cffF28A00Donator|r"; break;
    case 3:
      rank = "|cffAD01B0Moderator|r"; break;
  case 4:
      rank = "|cffAD01B0Administrator|r"; break;
}  
    }
   
    if (!*args)
        return false;
    if (WorldSession* session = handler->GetSession())
        name = session->GetPlayer()->GetName();
    sWorld->SendWorldText(LANG_CUSTOM_ANNOUNCE, rank, name, args);
    return true;
    }
};
void AddSC_ann_commandscript()
{
    new ann_commandscript();
};
[/spoiler:2mi2ysll]

LANG_CUSTOM_ANNOUNCE is linked up in language.h and has the correct reference in my trinity_string table and the script compiles without issue.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Steff

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 4551
    • View Profile
Re: [C++] Trinity Announce System
« Reply #17 on: September 01, 2011, 12:08:11 am »
Please use pastbin!
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
Please mark as solved if solved.
Don't ask if you could ask a question... JUST ask the Question.
You can send me also offline messages. I will answer if I get online.
Skype: project.modcraft
Discord: steff#6954

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [C++] Trinity Announce System
« Reply #18 on: September 01, 2011, 12:09:33 am »
Player* player = session->GetPlayer();
> Not checked for player == NULL.
   gmlevel = player->GetSession()->GetSecurity();
> Not checked for GetSessin() == NULL, also this should be the same as session already retrieved earlier.
    if (!*args)
> You should check that right away on the top, before doing anything else.
    if (WorldSession* session = handler->GetSession())
        name = session->GetPlayer()->GetName();
> You're getting the session another time. Also, not checking for player being NULL.
    sWorld->SendWorldText(LANG_CUSTOM_ANNOUNCE, rank, name, args);
> sWorld is NULL? Idk.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Everon Mightbane

  • Registred Member
  • Loreweaver
  • *****
  • Posts: 89
    • View Profile
Re: [C++] Trinity Announce System
« Reply #19 on: September 01, 2011, 12:44:00 am »
Still not working heres my updated code: http://pastebin.com/FV1rtUP7
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [C++] Trinity Announce System
« Reply #20 on: September 01, 2011, 01:31:54 am »
Quote from: "Everon Mightbane"
Still not working heres my updated code: http://pastebin.com/FV1rtUP7
When Trinity is crashing, it produces a crash dump containing information for MSVC++. this even contains the line where it crashed and maybe indicators, why.
Have a look at that.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Everon Mightbane

  • Registred Member
  • Loreweaver
  • *****
  • Posts: 89
    • View Profile
Re: [C++] Trinity Announce System
« Reply #21 on: September 01, 2011, 01:49:04 pm »
Mine says this:
Code: [Select]
C:UsersSamDesktopGlorious-WoW CoresrcserverworldserverMaster.cpp:105 in FreezeDetectorRunnable::run ASSERTION FAILED:
  false
[0x2dc430]
?invoke@ACE_OS_Thread_Adapter@@UAEKXZ()+0x74 [0x0]
_endthreadex()+0x3a [0x0]
_endthreadex()+0xe4 [0x0]
BaseThreadInitThunk()+0x12 [0x0]
RtlInitializeExceptionChain()+0x63 [0x0]
RtlInitializeExceptionChain()+0x36 [0x0]
« Last Edit: January 01, 1970, 01:00:00 am by Admin »