Payday and Missing Credit

A place to post suggestions for new features, new bugs, and comments about the existing code.
madpeople
Posts: 4787
Joined: Tue Dec 16, 2003 8:00 am
Location: England

Post by madpeople »

Code: Select all

int startMoney;     // the ammount of money we are meant to be sharing out
int players;        // the number of players on the team
Player [] player;    // an array of players on the team
int moneyToGive = startMoney/players; //how much each player gets

for(int i = 0; i< players;i++){
    player[i].giveMoney(moneyToGive);
    startMoney-= moneyToGive;
}

player[0].giveMoney(startMoney); //give the comm what is left (player[0] is the comm)
...
Last edited by madpeople on Thu Nov 13, 2008 1:48 pm, edited 1 time in total.
TurkeyXIII
Posts: 1460
Joined: Thu Dec 06, 2007 3:18 am
Location: Melbourne, Aus

Post by TurkeyXIII »

Code: Select all

            m_rgMoney[sideID] -= delta * np;
It looks like the game tracks how much the team is paid each time.

A quick test reveals that extra money not paid due to rounding error stays in the budget and is given out in later paychecks when there's enough to go around.

So the bug is not so much missing credits as delayed credits.


Code: Select all

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

    int np = GetCountOfPlayers(pside, true);
    if (np != 0)
    {
        int delta = m_rgMoney[sideID] / np;
        if (delta > 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);

            m_rgMoney[sideID] -= delta * 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);
                }
                if (pfsShip->IsCommander()) //Or whatever designates the commander's ship
                {
                    pfsShip->SetMoney(pfsShip->GetMoney() + m_rgMoney[sideID]);
                    m_rgMoney[sideID] = 0;
                }
            }
        }
    }
}
That might add the surplus to the comm's wallet, but there's probably a better way to include it in the donations.
QUOTE (Randall Munroe)14.2: Turkey consumption rate of the average American in milligrams per minute[/quote]
Image
Gleipnir
Posts: 39
Joined: Tue Oct 09, 2007 7:45 pm
Location: Farawaynistan

Post by Gleipnir »

The missing credits are taxes owed to his royal magnificence, the illustrious Overlord Pook.
I took the cadet course, and all i got was this lousy bitmap.Image
pkk
Posts: 5419
Joined: Tue Jul 01, 2003 7:00 am
Location: Germany, Munich

Post by pkk »

After looking into code and wasting a few of Imagos hours, I found out that there will be no missing credits...

Credits which will not given out on current payday, will be used for next payday.

Fixing the "problem" gets more complicated, the deeper you look into code.

PS:
Payday uses the same function like minerloads and starting money.
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.
Dogbones
Posts: 2721
Joined: Mon Nov 24, 2003 8:00 am
Location: Virginia

Post by Dogbones »

TurkeyXIII wrote:QUOTE (TurkeyXIII @ Nov 14 2008, 06:06 AM) A quick test reveals that extra money not paid due to rounding error stays in the budget and is given out in later paychecks when there's enough to go around.

So the bug is not so much missing credits as delayed credits.
:doh:
Image
DOG PROPERTY LAWS:
2. If it's in my mouth, it's mine.
[unless it tastes bad, then it is yours.]
Andon
Posts: 5453
Joined: Sun Jun 03, 2007 8:29 pm
Location: Maryland, USA
Contact:

Post by Andon »

It's a conspiracy!
Image
ImageImage
MrChaos
Posts: 8352
Joined: Tue Mar 21, 2006 8:00 am

Post by MrChaos »

*jingles a big bag o'credits*

why do you think we named it Solap :lol:
Ssssh
Post Reply