Jump to content

[PATCH] External Mail from SQL


Recommended Posts

my suggested modifications:

DROP TABLE IF EXISTS `mail_external`;
CREATE TABLE `mail_external` (
 `id` int(20) unsigned NOT NULL auto_increment,
 `receiver` bigint(20) unsigned NOT NULL,
 `subject` varchar(200) default 'Support Message',
 `message` varchar(500) default 'Support Message',
 `money` int(20) unsigned NOT NULL default '0',
 `item` int(20) unsigned NOT NULL default '0',
 `item_count` int(20) unsigned NOT NULL default '1',
 PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

void WorldSession::SendExternalMails()
{
   sLog.outString("EXTERNAL MAIL> Send Mails from Queue...");
   QueryResult *result = CharacterDatabase.Query("SELECT id,receiver,subject,message,money,item,item_count FROM mail_external");
   if(!result)
   {
       sLog.outString("EXTERNAL MAIL> No Mails in Queue.");
       delete result;
       return;
   }

   do
   {
       Field *fields = result->Fetch();
       uint32 id = fields[0].GetUInt32();
       uint64 receiver_guid = fields[1].GetUInt64();
       std::string subject = fields[2].GetString();
       std::string message = fields[3].GetString();
       uint32 money = fields[4].GetUInt32();
       uint32 ItemID = fields[5].GetUInt32();
       uint32 ItemCount = fields[6].GetUInt32();

       if (Player *receiver = sObjectMgr.GetPlayer(receiver_guid))
       {
           sLog.outString("EXTERNAL MAIL> Sending mail to %u, Item: %u", receiver_guid, ItemID);

           uint32 itemTextId = !message.empty() ? sObjectMgr.CreateItemText(message) : 0;

           if (ItemID && ItemCount < 1)
           {
               sLog.outString("EXTERNAL MAIL> Warning: invalid ItemCount of %u, setting to 1", ItemCount);
               ItemCount = 1;
           }
           Item* ToMailItem = ItemID ? Item::CreateItem(ItemID, ItemCount, receiver) : NULL;

           if (ToMailItem)
           {
               ToMailItem->SaveToDB();

               MailDraft(subject, itemTextId)
                   .AddItem(ToMailItem)
                   .AddMoney(money)
                   .SendMailTo(MailReceiver(receiver), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_RETURNED);
           }
           else
           {
               MailDraft(subject, itemTextId)
                   .AddMoney(money)
                   .SendMailTo(MailReceiver(receiver), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_RETURNED);
           }
           CharacterDatabase.PExecute("DELETE FROM mail_external WHERE id=%u", id);
       }
       else
           sLog.outString("EXTERNAL MAIL> Player %u not in game, skip mail!", receiver_guid);
   } while(result->NextRow());

   delete result;
   sLog.outString("EXTERNAL MAIL> All Mails Sent.");
}

Link to comment
Share on other sites

  • Replies 104
  • Created
  • Last Reply

Top Posters In This Topic

  • 3 weeks later...

Error on LInux :

../../../src/game/World.h:82: error: expected `}' before 'WUPDATE_EXT_MAIL'

../../../src/game/World.h:82: error: invalid conversion from 'int' to 'WorldTimers'

../../../src/game/World.h:85: error: expected unqualified-id before '}' token

../../../src/game/World.h:85: error: expected declaration before '}' token

make[3]: *** [AggressorAI.o] Erreur 1

make[3]: *** Attente des tâches non terminées....

In file included from ../../../src/game/AchievementMgr.cpp:28:

../../../src/game/World.h:82: error: expected `}' before 'WUPDATE_EXT_MAIL'

../../../src/game/World.h:82: error: invalid conversion from 'int' to 'WorldTimers'

../../../src/game/World.h:85: error: expected unqualified-id before '}' token

../../../src/game/World.h:85: error: expected declaration before '}' token

mv -f .deps/AccountMgr.Tpo .deps/AccountMgr.Po

In file included from ../../../src/game/ArenaTeam.cpp:23:

../../../src/game/World.h:82: error: expected `}' before 'WUPDATE_EXT_MAIL'

../../../src/game/World.h:82: error: invalid conversion from 'int' to 'WorldTimers'

../../../src/game/World.h:85: error: expected unqualified-id before '}' token

../../../src/game/World.h:85: error: expected declaration before '}' token

make[3]: *** [AchievementMgr.o] Erreur 1

make[3]: *** [ArenaTeam.o] Erreur 1

make[3]: quittant le répertoire « /home/tibec/Desktop/dev2/objdir/src/game »

make[2]: *** [all-recursive] Erreur 1

make[2]: quittant le répertoire « /home/tibec/Desktop/dev2/objdir/src »

make[1]: *** [all-recursive] Erreur 1

make[1]: quittant le répertoire « /home/tibec/Desktop/dev2/objdir »

make: *** [all] Erreur 2

ks364402:/home/tibec/Desktop/dev2/objdir#

Link to comment
Share on other sites

I tried to do this: git diff master ExternalMail

Inside my MaNGOS root folder. Now this is what i got back:

fatal: ambiguous argument `ExternalMail`: unknown revision or path not in the working tree.

Use `--` to separate paths from revisions

I have really no idea how i can fix this (again i know little of GIT unfortunately) is there a way you can release a .patch or help me on this quest hehe ^^

Link to comment
Share on other sites

Stupid question, why don't you just merge his branch? Or, since it's even only a single commit so far, just cherry pick that commit. No need to extract a patch and re-apply it...

For example, to get http://github.com/xeross/mangos/commit/5e4351fcb07dd35fb0cebafe6377704dfed59a99 you can do:

git remote add -f xeross git://github.com/xeross/mangos.git

git cherry-pick 5e4351fcb07dd35fb0cebafe6377704dfed59a99

Voila, you got new commit "External mail, initial commit" in your branch.

Link to comment
Share on other sites

for example: Instead of having 3 or 4 standard ranks which MaNGOS normally has. I replaced it with 8 ranks. Also we have different settings for .gm on and .gm off (when you do .gm on, the GM Chat icon goes on, and off virse versa). Also I have the permission per realm patch applied on my core. And since I run a funserver i have to int64's in stead of int32's because some int's dont fit in the standard mangos. And I have a lot more but i forgot lol ^^.

Ontopic: The crashes i had before seem not to be caused by the External Mail system but by the AutoBroadcast system I had. I am trying to implement your AutoBroadcast now :)

EDIT: I tried to apply your Broadcaster.patch which i extracted from your repo (i found the commands on the broadcaster topic). I get a lot of errors. I wonder if you have .patch files for all of your custom made stuff. Since the patches i extract are full of extra stuff which doesn't have anything to do with the broadcaster system). I would be gratefull

Thanks on the forhand ^^

EDIT2: git stash apply broadcaster.patch gave me this:

broadcaster.patch: no valid stashed state found

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use