EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Archive::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=621)
-   -   Implemented Split and Autosplit (https://www.eqemulator.org/forums/showthread.php?t=15289)

fathernitwit 08-11-2004 06:41 AM

Implemented Split and Autosplit
 
Hey,

I have implemented the /split and /autosplit functions.

http://eqemu.psend.com/split_with_auto.diff

Patch in the zone directory against 7-31 CVS... applies clean, havent tried to run it with just this patch, but it works in my server repository.

let me know if anybody has success or failure with this.

Scorpious2k 08-11-2004 01:36 PM

What about those of us not usibg that version? :-)

fathernitwit 08-11-2004 03:08 PM

the changes are pretty straight forward... you can prolly just read the patch file and copy as needed... but I really have no idea what any code more than about 2 weeks looks like :), and I know yours is rather old

cofruben 08-11-2004 11:49 PM

not sure if works,but try this code(didnt test):

in groups.h:
Code:

void    SplitMoney(uint32 platinum,uint32 gold,uint32 silver,uint32 copper) ;
in groups.cpp:
Code:

void Group::SplitMoney(uint32 platinum,uint32 gold,uint32 silver,uint32 copper)
{
        APPLAYER* outapp = new APPLAYER(OP_MoneyOnCorpse, sizeof(moneyOnCorpseStruct));
        moneyOnCorpseStruct* d = (moneyOnCorpseStruct*) outapp->pBuffer;
        d->copper=0;
        d->silver=0;
        d->platinum=0;
        d->gold=0;
        d->response      = 1;
        d->unknown1      = 0x5a;
        d->unknown2      = 0x40;
        d->unknown3      = 0;
      int i;
      int8 membercount = 0;
      for (i = 0; i < MAX_GROUP_MEMBERS; i++)
        if (members[i] != NULL)
                        membercount++;
          d->platinum=(int)(platinum/membercount);
          d->gold=(int)(gold/membercount);
          d->silver=(int)(silver/membercount);
          d->copper=(int)(copper/membercount);

      if (membercount == 0)
        return;
          if(d->platinum<0)
                  d->platinum=0;
          if(d->gold<0)
                  d->gold=0;
          if(d->silver<0)
                  d->silver=0;
          if(d->copper<0)
                  d->copper=0;
      for (i = 0; i < MAX_GROUP_MEMBERS; i++)
      {
        if (members[i] != NULL && members[i]->IsClient()) // If Group Member is Client
                {
                        members[i]->CastToClient()->AddMoneyToPP(d->copper,d->gold,d->silver,d->platinum,true);
                        members[i]->CastToClient()->QueuePacket(outapp);
                        members[i]->CastToClient()->Message(0,"You receive %i platinum,%i gold,%i silver and %i copper for the split.",d->platinum,d->gold,d->silver,d->copper);
                }
      }
          safe_delete(outapp);
}

in client.cpp,replace existant op_split:
Code:

                                case OP_Split: {
                                        // solar: the client removes the money on its own, but we have to
                                        // update our state anyway, and make sure they had enough to begin
                                        // with.
                                        Split_Struct *split = (Split_Struct *)app->pBuffer;
                                        Group* group;
                                        uint32 pp=split->platinum;
                                        uint32 gold=split->gold;
                                        uint32 silver=split->silver;
                                        uint32 copper=split->copper;
                                        if(!TakeMoneyFromPP((copper+(silver*10)+(gold*100)+(pp*1000))))
                                        {
                                                Message(0,"You haven't got enough money!");
                                                break;
                                        }
                                        group = entity_list.GetGroupByClient(this);
                                        group->SplitMoney(pp,gold,silver,copper);
                                        break;
                                }

Let me know if works

fathernitwit 08-12-2004 01:20 AM

im not trying to be a dick or anything, but there is a lot wrong with that code... my solution is much more complete and does most things very similarly... just some examples:
1. *edit* didnt see the takemoneyfrompp, nevermind.
2. it dosent handle rounding at all.. so everything rounds down (money disappears)
3. dosent send any money updates so nobody will see their splits
4. a uint* can never be negative :)

cofruben 08-12-2004 05:10 AM

I'll merge your autosplit code later fathernitwit.

fathernitwit 08-12-2004 05:23 AM

Cool,

Have you actually tested with the OP_MoneyOnCorpse, instead of a full money update? I wasnt able to get it to work, it didnt seem to do anything... also a little cleanup might be to call SendClientMoneyUpdate (just found it) instead of building the money update packet in the split routine...

cofruben 08-12-2004 10:17 AM

it worked for me,I have seen something wrong in your code btw.
where it says AT_AUTOSPLIT or something like that,you are sending that packet to other people,and no one want to know that you have auto split on,except the server.I have tested all stuff and works.

fathernitwit 08-12-2004 11:42 AM

Quote:

Originally Posted by cofruben
where it says AT_AUTOSPLIT or something like that,you are sending that packet to other people,and no one want to know that you have auto split on,except the server.

lol, oops... copy paste error from whatever block was directly above it :)

patch has been updated.

cofruben 08-12-2004 12:03 PM

nice...i am going to work in ldon adventure system...would you help me,fathernitwit?it requires a lot of work and things to be collected,so the help of people are very good accepted.

sotonin 08-12-2004 12:18 PM

lord of the rings adventure system? huh?

cofruben 08-12-2004 12:22 PM

lotr system?what?you should go to the occulist...lol ,joke :).
Yeah I was thinking about lotr at that moment,but I tried to say ldon :).Like adventures and so.


All times are GMT -4. The time now is 12:21 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.