Page 1 of 3
Posted: Tue Sep 30, 2008 1:27 pm
by fufi
...
Posted: Tue Sep 30, 2008 3:17 pm
by pkk
IMO it's a rounding error:
Payday = ( [Payday] / [Number of Players] ) * [Number of Players]
Payday is donated to each player, before the credits go the the investor (commander).
EDIT:
It's like I said, a rounding problem.
Example:
500 credits / 3 = 166.67 credits
166.67 will be rounded to 166, because delta is INT.
All three player get 166 credits and the investor/commander (because of auto donating) gets 498 credits.
The code (src/FedSrv/fsmission.cpp):
CODEvoid 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);
}
}
}
}
}
EDIT2:
Alleg is using the same function for starting money, so starting money is also effected by this rounding error.
CODEvoid CFSMission::GiveSideMoney(IsideIGC * pside, Money money)
{
assert (money >= 0);
if (money != 0)
{
SideID sideID = pside->GetObjectID();
m_rgMoney[sideID] += money;
DoPayday(pside);
}
}
Posted: Tue Sep 30, 2008 4:25 pm
by Dark_Sponge
pkk wrote:QUOTE (pkk @ Sep 30 2008, 08:17 AM) IMO it's a rounding error:
Oh sure, a rounding error /rolleyes.gif" style="vertical-align:middle" emoid=":roll:" border="0" alt="rolleyes.gif" />
Sounds like Gigacorp's accountants are embezzling again.
Posted: Tue Sep 30, 2008 4:47 pm
by Andon
pkk wrote:QUOTE (pkk @ Sep 30 2008, 11:17 AM) IMO it's a rounding error:
Payday = ( [Payday] / [Number of Players] ) * [Number of Players]
Payday is donated to each player, before the credits go the the investor (commander).
EDIT:
It's like I said, a rounding problem.
Example:
500 credits / 3 = 166.67 credits
166.67 will be rounded to 166, because delta is INT.
All three player get 166 credits and the investor/commander (because of auto donating) gets 498 credits.
The code (src/FedSrv/fsmission.cpp):
(codesnip)
How hard would it be to change delta to a double instead of an int? Seems like a pretty straightforward change to me, but then again, this IS the alleg code
Posted: Tue Sep 30, 2008 4:48 pm
by DasSmiter
can we switch it to double or something so that we get the full 500?
i've had games where i do need that extra 3 to be able to open, and i hate have 19999 money
Posted: Tue Sep 30, 2008 5:30 pm
by badpazzword
Can't you cast delta to float, then use a rounding function on it (ceiling e.g.)?
Nevermind my post.
Posted: Tue Sep 30, 2008 7:38 pm
by CronoDroid
Yeah that needs to be changed. I hate it when you're missing those two credits to hand out an extra SR!
Posted: Wed Oct 01, 2008 6:46 am
by Psychosis
can we make that fudge the other way? I'd rather it was 2 extra credits then 2 credits short
Posted: Wed Oct 01, 2008 11:58 pm
by Ramaglor
The fudging only goes one way...... "int" always rounds down
Posted: Thu Oct 02, 2008 12:18 am
by Andon
I don't know how simple it would be, but perhaps do something where it finds the difference between the original payday and the actual payday, and gives that to the investor