cumulated casualties number overflow in long campaign?

SPWaW is a tactical squad-level World War II game on single platoon or up to an entire battalion through Europe and the Pacific (1939 to 1945).

Moderator: MOD_SPWaW

Post Reply
deadcat
Posts: 9
Joined: Mon Sep 25, 2006 10:44 am

cumulated casualties number overflow in long campaign?

Post by deadcat »

hello,

playing 8.4 long campaign, german side.
the result screen after each scenario shows, as i understood, cumulated casualties for my and the enemy side for the entire campaign.
now, the number of casualties i incurred on the oponent went over 32.767 and the number switched negative and subsequent casualties incurred on the oponent are being now substracted from -32.767 (or 32.768?).

anyone else noticed this?
cheers
Procrustes
Posts: 347
Joined: Sun Mar 30, 2003 3:52 am
Location: Upstate

RE: cumulated casualties number overflow in long campaign?

Post by Procrustes »


Cool - the number of casualties must be stored in a two-byte var (2^15=32768) - when you went over it switched the sign bit.  I expect it will keep working - let us know.
deadcat
Posts: 9
Joined: Mon Sep 25, 2006 10:44 am

RE: cumulated casualties number overflow in long campaign?

Post by deadcat »

yeah i thought that the data type for the casualties variable is a "short int" ("unsigned short int" would've made more sense tho).
it does work in subsequent scenarios. by now, i have to calculate the overall casualties with the formula 32767 + modulo(32767 - modulo(shown_total)).
i was a bit perplexed when i first noticed the - in front of the figure, but then i remembered 2^15 is a *magic* number, hehehe.
would've made sense to make the variable an unsigned int, i guess, as it should't ever be negative.
Riun T
Posts: 1848
Joined: Sat Jul 31, 2004 4:22 pm

RE: cumulated casualties number overflow in long campaign?

Post by Riun T »

Congradulations deadcat, for joining the ranks of fellow "score wrappers", that takes some doin!!
Post Reply

Return to “Steel Panthers World At War & Mega Campaigns”