aboutsummaryrefslogtreecommitdiff
path: root/taipan.c
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-01-06 17:38:48 -0500
committerB. Watson <yalhcru@gmail.com>2016-01-06 17:38:48 -0500
commit7ac76fb4e4117887f6fd80ca7d6659be88209313 (patch)
treebdeccf1a267ee836c8ceacc50052f4f206cc9a22 /taipan.c
parent1b5919c1c68a379cdc20a56dcb6dfa650f3eac87 (diff)
downloadtaipan-7ac76fb4e4117887f6fd80ca7d6659be88209313.tar.gz
finishing touches of compression, attempt to fix damage calc issue
Diffstat (limited to 'taipan.c')
-rw-r--r--taipan.c50
1 files changed, 40 insertions, 10 deletions
diff --git a/taipan.c b/taipan.c
index af755e4..f3f0c87 100644
--- a/taipan.c
+++ b/taipan.c
@@ -18,6 +18,10 @@
damage and capacity numbers directly */
// #define MCHENRY_TEST
+/* define this to start the game in the year 1869, with
+ 1000 capacity, 20 guns, and 1 billion cash and bank. */
+// #define TIMEWARP
+
/**** atari-specific stuff */
/* values returned by cgetc() for backspace & enter keys */
@@ -223,10 +227,10 @@ int hkw_[4],
hold_[4];
int hold = 0,
- capacity = 60,
+ // capacity = 60,
guns = 0,
bp = 0,
- damage = 0,
+ // damage = 0,
month = 1,
year = 1860,
li = 0,
@@ -234,13 +238,15 @@ int hold = 0,
wu_warn = 0,
wu_bailout = 0;
-int newdamage;
+// these need to be longs to avoid int overflow when
+// displaying ship status.
+long damage = 0, capacity = 60, newdamage;
// fancy_numbers() will get replaced sooner or later.
// void cprintfancy(unsigned long ul) {
// }
-/* print an int or long as a string, conio-style */
+/* print an int or long as a string, conio-style */
void cprintulong(unsigned long ul) {
cputs(ultoa(ul, fancy_num, 10));
}
@@ -514,7 +520,7 @@ int sea_battle(int id, int num_ships) {
fight_stats(num_ships, orders);
while(num_ships > 0) {
- status = 100 - ((damage * 100 / capacity));
+ status = 100L - ((damage * 100L / capacity));
if(status <= 0) {
return 4;
}
@@ -932,8 +938,8 @@ int sea_battle(int id, int num_ships) {
// if ((guns > 0) && ((randi()%100 < (((float) damage / capacity) * 100)) ||
// ((((float) damage / capacity) * 100) > 80)))
- if((guns > 0) && ((randi()%100 < ((damage * 100) / capacity)) ||
- (((damage * 100) / capacity)) > 80))
+ if((guns > 0) && ((randi()%100 < ((damage * 100L) / capacity)) ||
+ (((damage * 100L) / capacity)) > 80))
{
i = 1;
guns--;
@@ -966,8 +972,18 @@ int sea_battle(int id, int num_ships) {
damage += newdamage;
if(damage > capacity) damage = capacity; /* just in case */
+ /* the above is still somehow broken. When fighting lots of
+ ships, late in the game, we still get ship status over 100%
+ in the fight screen, and mchenry says we're 4 billion percent
+ damaged (and memory gets all kinds of corrupted after that).
+ I do NOT understand what's going on here. It looks like
+ damage is still somehow going negative, but that shouldn't
+ be possible. */
+ if(damage < 0) damage = capacity; /* band-aid! */
+
#ifdef DAMAGE_TEST
gotoxy(0, 23);
+ clrtoeol();
cprintulong(ed);
cputc(' ');
cprintulong(i);
@@ -1169,12 +1185,26 @@ void cash_or_guns(void)
li = 0;
bp = 10;
} else {
+#ifdef TIMEWARP
+ year = 1869;
+ cash = 1000000000L;
+ bank = 1000000000L;
+ debt = 0;
+ capacity = 1000;
+ hold = 800;
+ guns = 20;
+ li = 1;
+ bp = 7;
+ ed = 9;
+ ec = 90;
+#else
cash = 0;
debt = 0;
hold = 10;
guns = 5;
li = 1;
bp = 7;
+#endif
}
return;
@@ -1194,7 +1224,7 @@ void port_stats(void)
{
static int firmpos = 0;
int i, in_use,
- status = 100 - ((damage * 100) / capacity);
+ status = 100 - ((damage * 100L) / capacity);
/* all the static text that used to be in port_stats() has
been moved to mkportstats.c, which creates a .xex file which
@@ -1381,7 +1411,7 @@ void mchenry(void)
static int percent, time;
static long br, repair_price, amount;
// int percent = ((float) damage / capacity) * 100,
- percent = (damage * 100 / capacity);
+ percent = (damage * 100L / capacity);
time = ((year - 1860) * 12) + month;
/*
@@ -1836,7 +1866,7 @@ void quit(void)
// you have no chance of sinking. If you're 34%-66% damaged, you
// have a 1 in 3 chance. If you're over 66%, you have a 2 in
// 3 chance.
- damagepct = damage * 100 / capacity;
+ damagepct = damage * 100L / capacity;
if(damagepct < 34)
sunk = 0;
else if(damagepct < 67)