Payday and Missing Credit
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);
}
}
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);
}
}
Last edited by pkk on Tue Sep 30, 2008 3:45 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.
-
Dark_Sponge
- Posts: 386
- Joined: Sun Dec 23, 2007 4:43 am
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 codepkk 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)



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
i've had games where i do need that extra 3 to be able to open, and i hate have 19999 money



Get over yourselves, don't try to win arguments on the internet where the option of a punch in the mouth is unavailable
"It is not that I cannot create anything good, but that I will not." And to prove this, he created the peacock.
-
badpazzword
- Posts: 3627
- Joined: Thu Jan 12, 2006 8:00 am
- Contact:
Can't you cast delta to float, then use a rounding function on it (ceiling e.g.)?
Nevermind my post.
Nevermind my post.
Last edited by badpazzword on Tue Sep 30, 2008 5:32 pm, edited 1 time in total.
Have gaming questions? Get expert answers!


-
CronoDroid
- Posts: 4606
- Joined: Sun Nov 06, 2005 8:00 am
- Contact:


