Payday and Missing Credit

A place to post suggestions for new features, new bugs, and comments about the existing code.
TurkeyXIII
Posts: 1460
Joined: Thu Dec 06, 2007 3:18 am
Location: Melbourne, Aus

Post by TurkeyXIII »

Or just give it all to the investor in the first place? If you want stopping donating to still be an option, the check for that should be made before the cash is split, not after.
QUOTE (Randall Munroe)14.2: Turkey consumption rate of the average American in milligrams per minute[/quote]
Image
Psychosis
Posts: 4218
Joined: Wed Oct 27, 2004 7:00 am
Location: California

Post by Psychosis »

Ramaglor wrote:QUOTE (Ramaglor @ Oct 1 2008, 06:58 PM) The fudging only goes one way...... "int" always rounds down
so add on $4to starting money
pkk
Posts: 5419
Joined: Tue Jul 01, 2003 7:00 am
Location: Germany, Munich

Post by pkk »

Psychosis wrote:QUOTE (Psychosis @ Oct 3 2008, 12:45 AM) so add on $4to starting money
+4 doesn't help. /doh.gif" style="vertical-align:middle" emoid=":doh:" border="0" alt="doh.gif" />

Just calculate it with eleven players, still missing credits. /wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" />
The Escapist (Justin Emerson) @ Dec 21 2010, 02:33 PM:
The history of open-source Allegiance is paved with the bodies of dead code branches, forum flame wars, and personal vendettas. But a community remains because people still love the game.
Ramaglor
Posts: 687
Joined: Sun Aug 28, 2005 7:00 am
Location: Seattle

Post by Ramaglor »

why not give the commander the modulus of the division?


*would someone please move this to code bugs and suggestions?*
Last edited by Ramaglor on Fri Oct 03, 2008 12:02 am, edited 1 time in total.
Spidey's tactical advice on TS during Tourny game
QUOTE We don't need to save our thingy.[/quote]
Clay_Pigeon
Posts: 3211
Joined: Tue Mar 29, 2005 8:00 am
Location: my pod

Post by Clay_Pigeon »

change

int delta = m_rgMoney[sideID] / np;

to

int delta = m_rgMoney[sideID] / np +1;

?

Team sizes will occasionally result in a slightly larger payday, but I don't think it's enough to worry about, especially since now we can have slightly smaller paydays.
Last edited by Clay_Pigeon on Fri Oct 03, 2008 10:29 am, edited 1 time in total.
Image
"Therefore I will boast all the more gladly about my weaknesses, so that Christ's power may rest on me." -2 Cor 12:9
"Never know how long I've waited, anticipated your smile pressed against mine." -Running
doofus
Posts: 109
Joined: Wed Jul 02, 2003 7:00 am

Post by doofus »

Ramaglor wrote:QUOTE (Ramaglor @ Oct 3 2008, 12:58 AM) why not give the commander the modulus of the division?
+1
Save the whales. Collect the whole set.
Image
Raveen
Posts: 9104
Joined: Wed Mar 16, 2005 8:00 am
Location: Birmingham, UK
Contact:

Post by Raveen »

What about:

int delta = (m_rgMoney[sideID] / np) + 0.5;
ImageImage
Spidey: Can't think of a reason I'd need to know anything
Vlymoxyd
Posts: 985
Joined: Fri Jul 04, 2003 7:00 am
Location: Québec, Canada
Contact:

Post by Vlymoxyd »

I think a logical way would be:

1:Split the money like now.

2: Add the Total money received by each players of the team and substract it from the total money that the team should have received

3: give the reminder to the comm

I don't see why we should bother giving extra cash to the teams when it's so easy to give them exactly what they should receive.

I'm actually pretty sure there are probably much easier way what than what I suggested without ending up with wrong results.
"Désolé pour les skieurs, moi je veux voir mes fleurs!"
-German teacher

Image
http://www.steelfury.org/
pkk
Posts: 5419
Joined: Tue Jul 01, 2003 7:00 am
Location: Germany, Munich

Post by pkk »

IMO this will fix the bug:

Code: Select all

void CFSMission::DoPayday(IsideIGC* pside)
{
    SideID  sideID = pside->GetObjectID();

    int np = GetCountOfPlayers(pside, true);
    if (np != 0)
    {
        // pkk: delta is now double
        double ddelta = double(m_rgMoney[sideID]) / double(np);
        int delta = int(ddelta);
        if (delta > 0.0)
        {
            BEGIN_PFM_CREATE(g.fm, pfmPayday, S, PAYDAY)
            END_PFM_CREATE
            pfmPayday->dMoney = Money(delta);
            g.fm.SendMessages(CFSSide::FromIGC(pside)->GetGroup(), FM_GUARANTEED, FM_FLUSH);

            // pkk: convert double back to int
            m_rgMoney[sideID] -= int(ddelta * double(np));

            const ShipListIGC * plistShip = pside->GetShips();
            for(ShipLinkIGC * plinkShip = plistShip->first(); plinkShip; plinkShip = plinkShip->next())
            {
                CFSShip * pfsShip = (CFSShip *) plinkShip->data()->GetPrivateData();
                if (pfsShip->IsPlayer())
                {
                    CFSPlayer*  pfsDonate = pfsShip->GetPlayer()->GetAutoDonate();
                    if (pfsDonate)
                        pfsDonate->SetMoney(pfsDonate->GetMoney() + delta);
                    else
                        pfsShip->SetMoney(pfsShip->GetMoney() + delta);
                }
            }
        }
    }
}
Maybe I'm wrong, my C/C++ skills suck. ;)
Last edited by pkk on Thu Oct 09, 2008 4:40 pm, edited 1 time in total.
The Escapist (Justin Emerson) @ Dec 21 2010, 02:33 PM:
The history of open-source Allegiance is paved with the bodies of dead code branches, forum flame wars, and personal vendettas. But a community remains because people still love the game.
cashto
Posts: 3165
Joined: Mon Sep 10, 2007 5:40 am
Location: Seattle

Post by cashto »

It won't work. "double z = double(x) / double(y); int zz = int(z);" will give identical results as "int zz = x / y;"

I like vly's idea. Bump the comm's payday by "m_rgMoney[sideID] - delta * np".

Also, if you want a division x / y that always rounds up (for positive x, y), you may consider (x + y - 1) / x.
Globemaster_III wrote:QUOTE (Globemaster_III @ Jan 11 2018, 11:27 PM) as you know i think very little of cashto, cashto alway a flying low pilot, he alway flying a trainer airplane and he rented
Post Reply