smile@mhuxd.UUCP (Edward Barlow) (03/21/88)
*** oldcombat.c Fri Mar 18 17:27:00 1988 --- combat.c Fri Mar 18 17:27:23 1988 *************** *** 342,352 PAloss = 120; PDloss = 0; } - sprintf(tempstr,"%s%d",msgfile,country); - if ((fpmsg=fopen(tempstr,"a+"))==NULL) { - printf("\n\tERROR OPENING %s",tempstr); - exit(1); - } /*divisor is the smallest combat bonus*/ divisor = 100; --- 342,347 ----- PAloss = 120; PDloss = 0; } /*divisor is the smallest combat bonus*/ divisor = 100; *************** *** 411,416 for(i=0;i<j;i++) if(owner[j]==owner[i]) done=1; if((done==0)&&(ntn[owner[j]].active==1)) { fprintf(fpmsg,"%s BATTLE SUMMARY for sector %d, %d\n",ntn[owner[j]].name,ntn[owner[0]].arm[unit[0]].xloc, ntn[owner[0]].arm[unit[0]].yloc); --- 406,416 ----- for(i=0;i<j;i++) if(owner[j]==owner[i]) done=1; if((done==0)&&(ntn[owner[j]].active==1)) { + sprintf(tempstr,"%s%d",msgfile,owner[j]); + if ((fpmsg=fopen(tempstr,"a+"))==NULL) { + printf("\n\tERROR OPENING %s",tempstr); + exit(1); + } fprintf(fpmsg,"%s BATTLE SUMMARY for sector %d, %d\n",ntn[owner[j]].name,ntn[owner[0]].arm[unit[0]].xloc, ntn[owner[0]].arm[unit[0]].yloc); *************** *** 428,433 fprintf(fpmsg,"%s ODDS are %d to 100\n",ntn[owner[j]].name,odds); fprintf(fpmsg,"%s RESULT: Attackers lose %d men, Defenders lose %d men\n",ntn[owner[j]].name,Aloss, Dloss); fprintf(fpmsg,"%s\n","END"); } } fclose(fpmsg); --- 428,434 ----- fprintf(fpmsg,"%s ODDS are %d to 100\n",ntn[owner[j]].name,odds); fprintf(fpmsg,"%s RESULT: Attackers lose %d men, Defenders lose %d men\n",ntn[owner[j]].name,Aloss, Dloss); fprintf(fpmsg,"%s\n","END"); + fclose(fpmsg); } } } *************** *** 430,436 fprintf(fpmsg,"%s\n","END"); } } - fclose(fpmsg); } /*Subroutine to determine combat bonuses for unit i in matrix*/ --- 431,436 ----- fclose(fpmsg); } } } /*Subroutine to determine combat bonuses for unit i in matrix*/ *************** *** 617,623 ntn[owner[i]].nvy[unit[i]].warships=0; amsunk = asunk - aship; } else { ! ntn[owner[i]].nvy[unit[i]].warships -= asunk / aship * ntn[owner[i]].nvy[unit[i]].warships; } } else if((dsunk>0)&&(side[i]==DFND)){ --- 617,623 ----- ntn[owner[i]].nvy[unit[i]].warships=0; amsunk = asunk - aship; } else { ! ntn[owner[i]].nvy[unit[i]].warships -= asunk * ntn[owner[i]].nvy[unit[i]].warships/aship; } } else if((dsunk>0)&&(side[i]==DFND)){ *************** *** 625,631 ntn[owner[i]].nvy[unit[i]].warships=0; dmsunk = dsunk -dship; } else { ! ntn[owner[i]].nvy[unit[i]].warships -= dsunk / dship * ntn[owner[i]].nvy[unit[i]].warships; } } } --- 625,631 ----- ntn[owner[i]].nvy[unit[i]].warships=0; dmsunk = dsunk -dship; } else { ! ntn[owner[i]].nvy[unit[i]].warships -= dsunk * ntn[owner[i]].nvy[unit[i]].warships/dship; } } } *** oldcommands.c Fri Mar 18 17:27:00 1988 --- commands.c Fri Mar 18 17:27:23 1988 *************** *** 643,648 /* then move temp to msgfile*/ rmessage() { FILE *mesgfp; FILE *fptemp; int i; --- 643,649 ----- /* then move temp to msgfile*/ rmessage() { + int unlink(); FILE *mesgfp; FILE *fptemp; int i; *************** *** 666,671 sprintf(mesgfile,"%s%d",msgfile,country); if ((mesgfp=fopen(mesgfile,"r"))==NULL) { mvprintw(0,0,"no messages in %s, hit return",mesgfile); refresh(); getch(); --- 667,673 ----- sprintf(mesgfile,"%s%d",msgfile,country); if ((mesgfp=fopen(mesgfile,"r"))==NULL) { + (void) unlink (tempfile) ; mvprintw(0,0,"no messages in %s, hit return",mesgfile); refresh(); getch(); *** oldcexecute.c Fri Mar 18 17:27:01 1988 --- cexecute.c Fri Mar 18 17:27:23 1988 *************** *** 131,137 case CHG_MGK: ntn[country].powers|=long2var; if(ntn[country].powers!=longvar){ ! printf("\nERROR ON MAGIC READ %ld != %d (or of %d)",longvar,ntn[country].powers,long2var); getchar(); } exenewmgk(long2var); --- 131,137 ----- case CHG_MGK: ntn[country].powers|=long2var; if(ntn[country].powers!=longvar){ ! printf("\nERROR ON MAGIC READ %ld != %ld (or of %ld)",longvar,ntn[country].powers,long2var); getchar(); } exenewmgk(long2var); *************** *** 145,148 if(execed==1) return(1); else return(0); } - --- 145,147 ----- if(execed==1) return(1); else return(0); } *** oldforms.c Fri Mar 18 17:26:41 1988 --- forms.c Fri Mar 18 17:27:23 1988 *************** *** 62,68 mvprintw(6,position,"%s",*(races+i)); if(ntn[nationid].active>=2) mvprintw(7,position,"NPC"); else mvprintw(7,position,"%s",*(Class+ntn[nationid].class)); ! mvprintw(8,position,"%d",ntn[nationid].score); mvprintw(9,position,"%ld",ntn[nationid].tgold); mvprintw(10,position,"%ld",ntn[nationid].tmil); mvprintw(11,position,"%ld",ntn[nationid].tciv); --- 62,68 ----- mvprintw(6,position,"%s",*(races+i)); if(ntn[nationid].active>=2) mvprintw(7,position,"NPC"); else mvprintw(7,position,"%s",*(Class+ntn[nationid].class)); ! mvprintw(8,position,"%ld",ntn[nationid].score); mvprintw(9,position,"%ld",ntn[nationid].tgold); mvprintw(10,position,"%ld",ntn[nationid].tmil); mvprintw(11,position,"%ld",ntn[nationid].tciv); *************** *** 122,128 } standout(); mvaddstr(17,0,"HIT RETURN KEY TO CHANGE STATUS"); ! mvprintw(18,0,"HIT 'B' KEY TO BRIBE WARRING NPC NATION (%d GOLD/level)",BRIBE); mvaddstr(19,0,"ANY OTHER KEY TO CONTINUE:"); standend(); refresh(); --- 122,128 ----- } standout(); mvaddstr(17,0,"HIT RETURN KEY TO CHANGE STATUS"); ! mvprintw(18,0,"HIT 'B' KEY TO BRIBE WARRING NPC NATION (%ld GOLD/level)",BRIBE); mvaddstr(19,0,"ANY OTHER KEY TO CONTINUE:"); standend(); refresh(); *************** *** 270,276 mvprintw(16,0,"nations mark is...%c ",ntn[country].mark); for(i=1;i<8;i++) if(ntn[country].race==*(races+i)[0]) mvprintw(17,0, "nation race is....%s ",*(races+i)); ! mvprintw(18,0,"score currently...%d",ntn[country].score); mvprintw(4,(COLS/2), "attack bonus...........+%2d",ntn[country].aplus); mvprintw(5,(COLS/2), "defense bonus..........+%2d",ntn[country].dplus); --- 270,276 ----- mvprintw(16,0,"nations mark is...%c ",ntn[country].mark); for(i=1;i<8;i++) if(ntn[country].race==*(races+i)[0]) mvprintw(17,0, "nation race is....%s ",*(races+i)); ! mvprintw(18,0,"score currently...%ld",ntn[country].score); mvprintw(4,(COLS/2), "attack bonus...........+%2d",ntn[country].aplus); mvprintw(5,(COLS/2), "defense bonus..........+%2d",ntn[country].dplus); *************** *** 293,298 mvaddstr(20,(COLS/2)-15,"HIT 1 or 2 TO CHANGE NAME or PASSWD"); if(magic(country,VAMPIRE)!=1) mvaddstr(21,(COLS/2)-14,"HIT 3 TO ADD TO YOUR COMBAT BONUS"); if(isgod==1) mvaddstr(22,(COLS/2)-9,"HIT 4 TO DESTROY NATION"); standend(); --- 293,299 ----- mvaddstr(20,(COLS/2)-15,"HIT 1 or 2 TO CHANGE NAME or PASSWD"); if(magic(country,VAMPIRE)!=1) mvaddstr(21,(COLS/2)-14,"HIT 3 TO ADD TO YOUR COMBAT BONUS"); + else mvaddstr(21,(COLS/2)-17,"( VAMPIRES MAY NOT ADD TO COMBAT BONUS )"); if(isgod==1) mvaddstr(22,(COLS/2)-9,"HIT 4 TO DESTROY NATION"); standend(); *************** *** 379,384 mvaddstr(0,0,"VAMPIRES CAN'T ADD TO COMBAT BONUS (hit return)"); refresh(); getch(); } if(magic(country,WARLORD)==1) cbonus=30; else if(magic(country,CAPTAIN)==1) cbonus=20; --- 380,386 ----- mvaddstr(0,0,"VAMPIRES CAN'T ADD TO COMBAT BONUS (hit return)"); refresh(); getch(); + break; } if(magic(country,WARLORD)==1) cbonus=30; else if(magic(country,CAPTAIN)==1) cbonus=20; *** oldio.c Fri Mar 18 17:26:44 1988 --- io.c Fri Mar 18 17:27:23 1988 *************** *** 496,502 printf(" %s",*(races+i)); if(ntn[nationid].active>=2) printf(" NPC"); else printf(" %s",*(Class+ntn[nationid].class)); ! printf(" %d %d %d %d %d", ntn[nationid].score ,ntn[nationid].tgold ,ntn[nationid].tmil ,ntn[nationid].tciv ,ntn[nationid].tsctrs ); --- 496,502 ----- printf(" %s",*(races+i)); if(ntn[nationid].active>=2) printf(" NPC"); else printf(" %s",*(Class+ntn[nationid].class)); ! printf(" %ld %ld %ld %ld %d", ntn[nationid].score ,ntn[nationid].tgold ,ntn[nationid].tmil ,ntn[nationid].tciv ,ntn[nationid].tsctrs ); *** oldmain.c Fri Mar 18 17:27:03 1988 --- main.c Fri Mar 18 17:27:23 1988 *************** *** 18,23 #include <fcntl.h> #include <pwd.h> /*initialization data*/ /*Movement costs*/ char *ele= "#^%-~"; --- 18,24 ----- #include <fcntl.h> #include <pwd.h> + char *getpass(); /*initialization data*/ /*Movement costs*/ char *ele= "#^%-~"; *************** *** 106,111 int argc; char **argv; { register int i; char *name; void srand(); --- 107,113 ----- int argc; char **argv; { + int geteuid(), getuid(), setuid(); register int i; char *name; void srand(); *************** *** 218,224 printscore(); exit(0); } else if (xflag) { /* update the game */ ! uid=geteuid(); if ( uid != (getpwnam(LOGIN))->pw_uid ){ printf("sorry -- your uid is invalid for updating\n"); printf("you need to be logged in as %s\n",LOGIN); --- 220,226 ----- printscore(); exit(0); } else if (xflag) { /* update the game */ ! uid=getuid(); /* use the real user id */ if ( uid != (getpwnam(LOGIN))->pw_uid ){ printf("sorry -- your uid is invalid for updating\n"); printf("you need to be logged in as %s\n",LOGIN); *************** *** 228,234 writedata(); exit(1); } ! /* must be a normal interactive game */ armornvy=AORN; --- 230,242 ----- writedata(); exit(1); } ! /* ! * Set the real uid to the effective. This will avoid a ! * number of problems involving file protection if the ! * executable is setuid. ! */ ! (void) setuid (geteuid ()) ; ! /* must be a normal interactive game */ armornvy=AORN; *************** *** 368,374 else { mvprintw(LINES-3,COLS-20,"nation...%s",ntn[country].name); mvprintw(LINES-2,COLS-20,"treasury.%ld",ntn[country].tgold); ! mvprintw(LINES-1,COLS-20,"score....%d",ntn[country].score); } } --- 376,382 ----- else { mvprintw(LINES-3,COLS-20,"nation...%s",ntn[country].name); mvprintw(LINES-2,COLS-20,"treasury.%ld",ntn[country].tgold); ! mvprintw(LINES-1,COLS-20,"score....%ld",ntn[country].score); } } *** oldmakeworld.c Fri Mar 18 17:27:03 1988 --- makeworld.c Fri Mar 18 17:27:23 1988 *************** *** 596,602 AXLOC=x; AYLOC=y; ASTAT=GARRISON; ! ASOLD=750+100*rand()%10; ATYPE=A_INFANTRY; armynum++; AMOVE=8; --- 596,602 ----- AXLOC=x; AYLOC=y; ASTAT=GARRISON; ! ASOLD=750+100*(rand()%10); ATYPE=A_INFANTRY; armynum++; AMOVE=8; *************** *** 603,609 AXLOC=x; AYLOC=y; ASTAT=ATTACK; ! ASOLD=750+100*rand()%10; ATYPE=A_INFANTRY; armynum++; } --- 603,609 ----- AXLOC=x; AYLOC=y; ASTAT=ATTACK; ! ASOLD=750+100*(rand()%10); ATYPE=A_INFANTRY; armynum++; } *************** *** 694,700 AXLOC=x; AYLOC=y; ASTAT=ATTACK; ! ASOLD=200+100*rand()%10; ATYPE=A_INFANTRY; if(armynum<MAXARM-1) armynum++; } --- 694,700 ----- AXLOC=x; AYLOC=y; ASTAT=ATTACK; ! ASOLD=200+100*(rand()%10); ATYPE=A_INFANTRY; if(armynum<MAXARM-1) armynum++; } *************** *** 703,709 ntn[NNOMAD].arm[army2num].xloc=x; ntn[NNOMAD].arm[army2num].yloc=y; ntn[NNOMAD].arm[army2num].stat=ATTACK; ! ntn[NNOMAD].arm[army2num].sold=100+100*rand()%15; ntn[NNOMAD].arm[army2num].unittyp=A_CAVALRY; if(army2num<MAXARM-1) army2num++; } --- 703,709 ----- ntn[NNOMAD].arm[army2num].xloc=x; ntn[NNOMAD].arm[army2num].yloc=y; ntn[NNOMAD].arm[army2num].stat=ATTACK; ! ntn[NNOMAD].arm[army2num].sold=100+100*(rand()%15); ntn[NNOMAD].arm[army2num].unittyp=A_CAVALRY; if(army2num<MAXARM-1) army2num++; } *** oldmove.c Fri Mar 18 17:27:03 1988 --- move.c Fri Mar 18 17:27:23 1988 *************** *** 695,700 int count=0; int i,j; /*flee*/ /*check if next to anybody of the sectors owners race*/ for(i=x-2;i<=x+2;i++) for(j=y-2;j<=y+2;j++) if(i>=0&&i<MAPX&&j>=0&&j<MAPY --- 695,702 ----- int count=0; int i,j; /*flee*/ + sct[x][y].people*=6; + sct[x][y].people/=10; /*check if next to anybody of the sectors owners race*/ for(i=x-2;i<=x+2;i++) for(j=y-2;j<=y+2;j++) if(i>=0&&i<MAPX&&j>=0&&j<MAPY *************** *** 737,740 if(z==0) SADJDES2; } } - --- 739,741 ----- if(z==0) SADJDES2; } } *** oldnewlogin.c Fri Mar 18 17:27:00 1988 --- newlogin.c Fri Mar 18 17:27:24 1988 *************** *** 29,35 int temp; int more=0; /*0 if add another player*/ int loop; ! int x; char tempo[8]; char passwd[8]; register i; --- 29,35 ----- int temp; int more=0; /*0 if add another player*/ int loop; ! long x,getmagic(); char tempo[8]; char passwd[8]; register i; *************** *** 143,149 ntn[country].jewels=10000; /*0 pts*/ ntn[country].tiron=10000; /*0 pts*/ ntn[country].tciv= 6000; /*6 pts*/ ! ntn[country].tmil= 1500; /*1.5 pts*/ ntn[country].repro= 4; /*4 pts*/ ntn[country].maxmove= 6; /*1.5 pts*/ ntn[country].aplus= 20; /*2 pts*/ --- 143,149 ----- ntn[country].jewels=10000; /*0 pts*/ ntn[country].tiron=10000; /*0 pts*/ ntn[country].tciv= 6000; /*6 pts*/ ! ntn[country].tmil= 1350; /*1.5 pts*/ ntn[country].repro= 4; /*4 pts*/ ntn[country].maxmove= 6; /*1.5 pts*/ ntn[country].aplus= 20; /*2 pts*/ *************** *** 186,192 ntn[country].jewels=10000; ntn[country].tiron=10000; ntn[country].tciv=4000; /*4 pts*/ ! ntn[country].tmil=2500; /*2.5 pts*/ ntn[country].repro=8; /*10 pts*/ ntn[country].maxmove=6; /*1.5 pts*/ ntn[country].aplus=00; /*0 pts*/ --- 186,192 ----- ntn[country].jewels=10000; ntn[country].tiron=10000; ntn[country].tciv=4000; /*4 pts*/ ! ntn[country].tmil=2250; /*2.5 pts*/ ntn[country].repro=8; /*10 pts*/ ntn[country].maxmove=6; /*1.5 pts*/ ntn[country].aplus=00; /*0 pts*/ *************** *** 208,214 ntn[country].jewels=10000; /*0 pts*/ ntn[country].tiron=10000; /*0 pts*/ ntn[country].tciv=6000; /*6 pts*/ ! ntn[country].tmil=1000; /*1 pts*/ ntn[country].repro=5; /*5 pts*/ ntn[country].maxmove=10; /*2.5 pts*/ ntn[country].aplus=10; /*1 pts*/ --- 208,214 ----- ntn[country].jewels=10000; /*0 pts*/ ntn[country].tiron=10000; /*0 pts*/ ntn[country].tciv=6000; /*6 pts*/ ! ntn[country].tmil=900; /*1 pts*/ ntn[country].repro=5; /*5 pts*/ ntn[country].maxmove=10; /*2.5 pts*/ ntn[country].aplus=10; /*1 pts*/ *************** *** 264,270 printf("\t1. population (1000/pt):\t\tnow have %ld civilians\n",ntn[country].tciv); printf("\t2. more gold ($100000/pt):\t\tnow have %ld gold pieces\n",ntn[country].tgold); printf("\t3. better location:\t\t\tlocation is now is %c\n",ntn[country].location); ! printf("\t4. more soldiers (1000/pt):\t\tnow have %ld soldiers\n",ntn[country].tmil); printf("\t5. better attack (10%%/pt):\t\tnow is +%d\n ",ntn[country].aplus); printf("\t6. better defence (10%%/pt):\t\tnow is +%d\n",ntn[country].dplus); printf("\t7. higher reproduction (2%%/pt):\t\trate is now %d%%\n",ntn[country].repro); --- 264,270 ----- printf("\t1. population (1000/pt):\t\tnow have %ld civilians\n",ntn[country].tciv); printf("\t2. more gold ($100000/pt):\t\tnow have %ld gold pieces\n",ntn[country].tgold); printf("\t3. better location:\t\t\tlocation is now is %c\n",ntn[country].location); ! printf("\t4. more soldiers (900/pt):\t\tnow have %ld soldiers\n",ntn[country].tmil); printf("\t5. better attack (10%%/pt):\t\tnow is +%d\n ",ntn[country].aplus); printf("\t6. better defence (10%%/pt):\t\tnow is +%d\n",ntn[country].dplus); printf("\t7. higher reproduction (2%%/pt):\t\trate is now %d%%\n",ntn[country].repro); *************** *** 276,283 printf("\nWhat option to buy:"); ! scanf("%d",&n); ! switch(n) { case 1: printf("additional population costs 1 pt per 1000\n"); --- 276,282 ----- printf("\nWhat option to buy:"); ! if(scanf("%d",&n)==1) switch(n) { case 1: printf("additional population costs 1 pt per 1000\n"); *************** *** 353,359 break; case 4: printf("you start with %ld soldiers\n",ntn[country].tmil); ! printf("additional military costs 1 / 1000\n"); printf("how many points you wish:"); scanf("%d",&temp); putchar('\n'); --- 352,358 ----- break; case 4: printf("you start with %ld soldiers\n",ntn[country].tmil); ! printf("additional military costs 1 / 900 men\n"); printf("how many points you wish:"); scanf("%d",&temp); putchar('\n'); *************** *** 359,365 putchar('\n'); if(points >= temp) { points -= temp; ! ntn[country].tmil+=temp*1000; } else printf("You dont have enough points left"); break; --- 358,364 ----- putchar('\n'); if(points >= temp) { points -= temp; ! ntn[country].tmil+=temp*900; } else printf("You dont have enough points left"); break; *************** *** 407,413 printf("you have the maximum rate"); break; } ! printf("how many points you wish:"); scanf("%d",&temp); putchar('\n'); if(points >= (temp*2)) { --- 406,412 ----- printf("you have the maximum rate"); break; } ! printf("how many points of repro to buy:"); scanf("%d",&temp); putchar('\n'); if(points >= (temp*2)) { *** oldupdate.c Fri Mar 18 17:27:03 1988 --- update.c Fri Mar 18 17:27:24 1988 *************** *** 29,35 register int i, j; register int x,y; int moved,armynum,nvynum,done,finis=0, number=0; ! int food,iron; char command[80]; int execed[MAXNTN]; long city_pop, cap_pop; --- 29,35 ----- register int i, j; register int x,y; int moved,armynum,nvynum,done,finis=0, number=0; ! long food,iron,xx; char command[80]; int execed[MAXNTN]; long city_pop, cap_pop; *************** *** 286,292 if(magic(sptr->owner,MINER)==1) iron*=2; if(magic(sptr->owner,STEEL)==1) iron*=2; nptr->tiron += iron; ! nptr->tgold += iron*TAXIRON/100; } /*harvest food*/ else if(sptr->designation==DFARM) { --- 286,292 ----- if(magic(sptr->owner,MINER)==1) iron*=2; if(magic(sptr->owner,STEEL)==1) iron*=2; nptr->tiron += iron; ! nptr->tgold += iron*TAXIRON/100L; } /*harvest food*/ else if(sptr->designation==DFARM) { *************** *** 290,296 } /*harvest food*/ else if(sptr->designation==DFARM) { ! food= todigit(sptr->vegetation)*sptr->people; nptr->tfood += food; nptr->tgold += food*TAXFOOD/100; } --- 290,296 ----- } /*harvest food*/ else if(sptr->designation==DFARM) { ! food= (long) todigit(sptr->vegetation)* (long)sptr->people; nptr->tfood += food; nptr->tgold += food*TAXFOOD/100L; } *************** *** 292,298 else if(sptr->designation==DFARM) { food= todigit(sptr->vegetation)*sptr->people; nptr->tfood += food; ! nptr->tgold += food*TAXFOOD/100; } /*gold mines produce gold*/ else if(sptr->designation==DGOLDMINE) { --- 292,298 ----- else if(sptr->designation==DFARM) { food= (long) todigit(sptr->vegetation)* (long)sptr->people; nptr->tfood += food; ! nptr->tgold += food*TAXFOOD/100L; } /*gold mines produce gold*/ else if(sptr->designation==DGOLDMINE) { *************** *** 297,304 /*gold mines produce gold*/ else if(sptr->designation==DGOLDMINE) { if(magic(sptr->owner,MINER)==1){ ! nptr->tgold += 2*sptr->gold * sptr->people * TAXGOLD/100; ! nptr->jewels += 2*sptr->gold * sptr->people; } else { nptr->tgold += sptr->gold * sptr->people * TAXGOLD/100; --- 297,304 ----- /*gold mines produce gold*/ else if(sptr->designation==DGOLDMINE) { if(magic(sptr->owner,MINER)==1){ ! nptr->tgold += 2*sptr->gold * (long)sptr->people * TAXGOLD/100L; ! nptr->jewels += 2*sptr->gold * (long)sptr->people; } else { nptr->tgold += sptr->gold * (long)sptr->people * TAXGOLD/100L; *************** *** 301,308 nptr->jewels += 2*sptr->gold * sptr->people; } else { ! nptr->tgold += sptr->gold * sptr->people * TAXGOLD/100; ! nptr->jewels += sptr->gold * sptr->people; } } else if(sptr->designation==DCAPITOL) { --- 301,308 ----- nptr->jewels += 2*sptr->gold * (long)sptr->people; } else { ! nptr->tgold += sptr->gold * (long)sptr->people * TAXGOLD/100L; ! nptr->jewels += sptr->gold * (long)sptr->people; } } else if(sptr->designation==DCAPITOL) { *************** *** 316,323 } if( magic(sptr->owner, ARCHITECT ) ) { ! city_pop *= 2; ! cap_pop *= 2; } nptr->tgold += (long) city_pop * TAXCITY / 100; --- 316,323 ----- } if( magic(sptr->owner, ARCHITECT ) ) { ! city_pop *= 2L; ! cap_pop *= 2L; } nptr->tgold += (long) city_pop * TAXCITY / 100L; *************** *** 320,327 cap_pop *= 2; } ! nptr->tgold += (long) city_pop * TAXCITY / 100; ! nptr->tgold += (long) cap_pop * TAXCAP / 100; } else if(sptr->designation==DCITY) { city_pop = sptr->people; --- 320,327 ----- cap_pop *= 2L; } ! nptr->tgold += (long) city_pop * TAXCITY / 100L; ! nptr->tgold += (long) cap_pop * TAXCAP / 100L; } else if(sptr->designation==DCITY) { city_pop = sptr->people; *************** *** 326,333 else if(sptr->designation==DCITY) { city_pop = sptr->people; if( magic(sptr->owner, ARCHITECT ) ) ! city_pop *= 2; ! nptr->tgold += (long) city_pop * TAXCITY / 100; } else if(((magic(country,DERVISH)==1) ||(magic(country,DESTROYER)==1)) --- 326,333 ----- else if(sptr->designation==DCITY) { city_pop = sptr->people; if( magic(sptr->owner, ARCHITECT ) ) ! city_pop *= 2L; ! nptr->tgold += (long) city_pop * TAXCITY / 100L; } else if(((magic(country,DERVISH)==1) ||(magic(country,DESTROYER)==1)) *************** *** 334,340 &&((sptr->vegetation==ICE) ||(sptr->vegetation==DESERT)) &&(sptr->people>0)) { ! food=6*sptr->people; nptr->tfood += food; nptr->tgold += food*TAXFOOD/100; } --- 334,340 ----- &&((sptr->vegetation==ICE) ||(sptr->vegetation==DESERT)) &&(sptr->people>0)) { ! food=6L*sptr->people; nptr->tfood += food; nptr->tgold += food*TAXFOOD/100L; } *************** *** 336,342 &&(sptr->people>0)) { food=6*sptr->people; nptr->tfood += food; ! nptr->tgold += food*TAXFOOD/100; } } --- 336,342 ----- &&(sptr->people>0)) { food=6L*sptr->people; nptr->tfood += food; ! nptr->tgold += food*TAXFOOD/100L; } } *************** *** 436,442 printf("error opening %s\n",command); } else { fprintf(fpmsg,"%s notice from program\n%s\n",ntn[country].name,ntn[country].name); ! fprintf(fpmsg,"%s famine hits city at %d,%d in %s.-> %d people reduced by %d\n%s\n",ntn[country].name,x,y,ntn[country].name,sptr->people,city_pop,ntn[country].name); fprintf(fpmsg,"END\n"); fclose(fpmsg); } --- 436,442 ----- printf("error opening %s\n",command); } else { fprintf(fpmsg,"%s notice from program\n%s\n",ntn[country].name,ntn[country].name); ! fprintf(fpmsg,"%s famine hits city at %d,%d in %s.-> %ld people reduced by %ld\n%s\n",ntn[country].name,x,y,ntn[country].name,sptr->people,city_pop,ntn[country].name); fprintf(fpmsg,"END\n"); fclose(fpmsg); } *************** *** 444,450 } /*this state can occur if few people live in cities*/ if(ntn[country].tfood<0) { ! ntn[country].tfood=0; } else if(ntn[country].tfood>FOODTHRESH*ntn[country].tciv) { ntn[country].tgold+=ntn[country].tfood-FOODTHRESH*ntn[country].tciv; --- 444,450 ----- } /*this state can occur if few people live in cities*/ if(ntn[country].tfood<0) { ! ntn[country].tfood=0L; } else if(ntn[country].tfood>FOODTHRESH*ntn[country].tciv) { ntn[country].tgold+=ntn[country].tfood-FOODTHRESH*ntn[country].tciv; *************** *** 452,460 } if(ntn[country].tgold>GOLDTHRESH*ntn[country].jewels){ ! x=ntn[country].tgold-GOLDTHRESH*ntn[country].jewels; ! ntn[country].jewels += x/GOLDTHRESH; ! ntn[country].tgold -= x; } else if(ntn[country].tgold > JEWELTHRESH * ntn[country].jewels){ fprintf(fnews,"3.\tTAX REVOLT IN NATION %s\n",ntn[country].name); --- 452,460 ----- } if(ntn[country].tgold>GOLDTHRESH*ntn[country].jewels){ ! xx=ntn[country].tgold-GOLDTHRESH*ntn[country].jewels; ! ntn[country].jewels += xx/GOLDTHRESH; ! ntn[country].tgold -= xx; } else if(ntn[country].tgold > JEWELTHRESH * ntn[country].jewels){ fprintf(fnews,"3.\tTAX REVOLT IN NATION %s\n",ntn[country].name); *************** *** 459,464 else if(ntn[country].tgold > JEWELTHRESH * ntn[country].jewels){ fprintf(fnews,"3.\tTAX REVOLT IN NATION %s\n",ntn[country].name); } } fclose(fnews); --- 459,482 ----- else if(ntn[country].tgold > JEWELTHRESH * ntn[country].jewels){ fprintf(fnews,"3.\tTAX REVOLT IN NATION %s\n",ntn[country].name); } + + /* fix overflow problems */ + if(ntn[country].tgold < -500000000) { + fprintf(fnews,"2.\tVariable Overflow - gold in nation %s\n",ntn[country].name); + ntn[country].tgold=500000000; + } + if(ntn[country].tfood < -500000000) { + fprintf(fnews,"2.\tVariable Overflow - food in nation %s\n",ntn[country].name); + ntn[country].tfood=500000000; + } + if(ntn[country].jewels < -500000000) { + fprintf(fnews,"2.\tVariable Overflow - jewels in nation %s\n",ntn[country].name); + ntn[country].jewels=500000000; + } + if(ntn[country].tiron < -500000000) { + fprintf(fnews,"2.\tVariable Overflow - iron in nation %s\n",ntn[country].name); + ntn[country].tiron=500000000; + } } fclose(fnews); *************** *** 462,467 } fclose(fnews); score(); sprintf(command,"rm %s*",exefile); --- 480,486 ----- } fclose(fnews); + cheat(); score(); sprintf(command,"rm %s*",exefile); *************** *** 629,632 int x; printf("\nupdating scores for all nations\n"); for(x=1;x<MAXNTN;x++) if(ntn[x].active!=0) ntn[x].score += score_one(x); } --- 648,682 ----- int x; printf("\nupdating scores for all nations\n"); for(x=1;x<MAXNTN;x++) if(ntn[x].active!=0) ntn[x].score += score_one(x); + } + + /* this routine cheats in favor of npc nations */ + cheat() + { + int x,y; + int bonus=0, count=0, npcavg, pcavg; + for(x=1;x<MAXNTN;x++) if(ntn[x].active!=0) + if(ntn[x].active==1) { + bonus+=ntn[x].aplus+ntn[x].dplus; + count++; + } + if(count==0) return; + pcavg = bonus / count; + + bonus=0; + count=0; + for(x=1;x<MAXNTN;x++) if(ntn[x].active!=0) + if(ntn[x].active!=1) { + bonus+=ntn[x].aplus+ntn[x].dplus; + count++; + } + if(count==0) return; + npcavg = bonus / count; + for(x=1;x<MAXNTN;x++) if(ntn[x].active>1) { + if(rand()%100 < (pcavg-npcavg)) { + if(ntn[x].aplus>ntn[x].dplus) ntn[x].dplus+=5; + else ntn[x].aplus+=5; + printf("npc cheat routine - add 5%% to nation %s combat skill\n",ntn[x].name); + } + } } *** oldmagic.c Fri Mar 18 17:26:58 1988 --- magic.c Fri Mar 18 17:27:24 1988 *************** *** 24,29 /*do nothing if that player has that power or it is not permitted*/ /*getmagic() returns the value of the power gained, and stores it in power*/ getmagic() { int newpower; --- 24,30 ----- /*do nothing if that player has that power or it is not permitted*/ /*getmagic() returns the value of the power gained, and stores it in power*/ + long getmagic() { long newpower; *************** *** 26,37 getmagic() { ! int newpower; ! newpower=1<<rand()%MAXPOWER; ! switch(newpower){ ! case WARRIOR: ! case CAPTAIN: ! case WARLORD: if(magic(country,WARRIOR)!=1){ ntn[country].powers|=WARRIOR; return(WARRIOR); --- 27,35 ----- long getmagic() { ! long newpower; ! newpower=1L<<(rand()%MAXPOWER); ! if((newpower==WARRIOR)||(newpower==CAPTAIN)||(newpower==WARLORD)){ if(magic(country,WARRIOR)!=1){ ntn[country].powers|=WARRIOR; return(WARRIOR); *************** *** 44,54 ntn[country].powers|=WARLORD; return(WARLORD); } ! break; ! case MI_MONST: ! case AV_MONST: ! case MA_MONST: ! if(ntn[country].race!=ORC) return(0); if(magic(country,MI_MONST)!=1){ ntn[country].powers|=MI_MONST; return(MI_MONST); --- 42,50 ----- ntn[country].powers|=WARLORD; return(WARLORD); } ! else return(0L); ! }else if((newpower==MI_MONST) ||(newpower==AV_MONST) ||(newpower==MA_MONST)){ ! if(ntn[country].race!=ORC) return(0L); if(magic(country,MI_MONST)!=1){ ntn[country].powers|=MI_MONST; return(MI_MONST); *************** *** 61,78 ntn[country].powers|=MA_MONST; return(MA_MONST); } ! break; ! case SPY: ! case KNOWALL: ! case DERVISH: ! case HIDDEN: ! case ARCHITECT: ! case URBAN: ! case THE_VOID: ! case HEALER: ! case ARCHER: ! case CAVALRY: ! if(magic(country,newpower)==1) return(0); ntn[country].powers|=newpower; return(newpower); case DESTROYER: --- 57,74 ----- ntn[country].powers|=MA_MONST; return(MA_MONST); } ! else return(0L); ! }else if((newpower==SPY) ! ||(newpower==KNOWALL) ! ||(newpower==DERVISH) ! ||(newpower==HIDDEN) ! ||(newpower==ARCHITECT) ! ||(newpower==URBAN) ! ||(newpower==THE_VOID) ! ||(newpower==HEALER) ! ||(newpower==ARCHER) ! ||(newpower==CAVALRY)){ ! if(magic(country,newpower)==1) return(0L); ntn[country].powers|=newpower; return(newpower); }else if(newpower==DESTROYER){ *************** *** 75,81 if(magic(country,newpower)==1) return(0); ntn[country].powers|=newpower; return(newpower); ! case DESTROYER: if((ntn[country].race!=ELF)&&(magic(country,DESTROYER)!=1)){ ntn[country].powers|=DESTROYER; return(DESTROYER); --- 71,77 ----- if(magic(country,newpower)==1) return(0L); ntn[country].powers|=newpower; return(newpower); ! }else if(newpower==DESTROYER){ if((ntn[country].race!=ELF)&&(magic(country,DESTROYER)!=1)){ ntn[country].powers|=DESTROYER; return(DESTROYER); *************** *** 80,87 ntn[country].powers|=DESTROYER; return(DESTROYER); } ! break; ! case VAMPIRE: if((ntn[country].race!=ELF)&&(magic(country,VAMPIRE)!=1)){ ntn[country].powers|=VAMPIRE; return(VAMPIRE); --- 76,83 ----- ntn[country].powers|=DESTROYER; return(DESTROYER); } ! return(0L); ! }else if(newpower==VAMPIRE){ if((ntn[country].race!=ELF)&&(magic(country,VAMPIRE)!=1)){ ntn[country].powers|=VAMPIRE; return(VAMPIRE); *************** *** 86,93 ntn[country].powers|=VAMPIRE; return(VAMPIRE); } ! break; ! case MINER: if((ntn[country].race!=ELF)&&(ntn[country].race!=DWARF)&&(magic(country,MINER)!=1)){ ntn[country].powers|=MINER; return(MINER); --- 82,89 ----- ntn[country].powers|=VAMPIRE; return(VAMPIRE); } ! return(0L); ! }else if(newpower==MINER){ if((ntn[country].race!=ELF)&&(ntn[country].race!=DWARF)&&(magic(country,MINER)!=1)){ ntn[country].powers|=MINER; return(MINER); *************** *** 92,101 ntn[country].powers|=MINER; return(MINER); } ! break; ! case STEEL: ! if(magic(country,STEEL)==1) return(0); ! if(magic(country,MINER)!=1) return(0); ntn[country].powers|=STEEL; return(STEEL); case BREEDER: --- 88,97 ----- ntn[country].powers|=MINER; return(MINER); } ! return(0L); ! }else if(newpower==STEEL){ ! if(magic(country,STEEL)==1) return(0L); ! if(magic(country,MINER)!=1) return(0L); ntn[country].powers|=STEEL; return(STEEL); }else if(newpower==BREEDER){ *************** *** 98,106 if(magic(country,MINER)!=1) return(0); ntn[country].powers|=STEEL; return(STEEL); ! case BREEDER: ! if(magic(country,BREEDER)==1) return(0); ! if(ntn[country].race!=ORC) return(0); ntn[country].powers|=BREEDER; return(BREEDER); } --- 94,102 ----- if(magic(country,MINER)!=1) return(0L); ntn[country].powers|=STEEL; return(STEEL); ! }else if(newpower==BREEDER){ ! if(magic(country,BREEDER)==1) return(0L); ! if(ntn[country].race!=ORC) return(0L); ntn[country].powers|=BREEDER; return(BREEDER); } *************** *** 104,110 ntn[country].powers|=BREEDER; return(BREEDER); } ! return(0); } /*form to interactively get a magic power*/ --- 100,106 ----- ntn[country].powers|=BREEDER; return(BREEDER); } ! return(0L); } /*form to interactively get a magic power*/ *************** *** 110,117 /*form to interactively get a magic power*/ domagic() { ! int x, count, done=0, loop=0, i, chance; ! long price; short isgod=0; if(country==0) { isgod=1; --- 106,113 ----- /*form to interactively get a magic power*/ domagic() { ! int count, done=0, loop=0, i, chance; ! long price,x; short isgod=0; if(country==0) { isgod=1; *************** *** 184,190 for (i=1; i<count-3; i++) { price <<= 1; if (price > 500000000) ! break; } if((ntn[country].race==ORC)&& ntn[country].jewels>=100000L){ --- 180,186 ----- for (i=1; i<count-3; i++) { price <<= 1; if (price > 500000000) ! return(0); } if((ntn[country].race==ORC)&& ntn[country].jewels>=100000L){ *************** *** 228,234 CHGMGK; exenewmgk(x); refresh(); ! break; } if (loop >= 500) mvaddstr(count++,0,"You have too many powers!"); --- 224,230 ----- CHGMGK; exenewmgk(x); refresh(); ! return(0); } if (loop >= 500) mvaddstr(count++,0,"You have too many powers!"); *************** *** 271,277 printf("nation %s taken over by %s\n",ntn[country].name,ntn[save].name); fprintf(fnews,"1.\tnation %s taken over by %s\n",ntn[country].name,ntn[save].name); } ! else DESTROY; destroy(); y=country; country=save; --- 267,279 ----- printf("nation %s taken over by %s\n",ntn[country].name,ntn[save].name); fprintf(fnews,"1.\tnation %s taken over by %s\n",ntn[country].name,ntn[save].name); } ! else { ! DESTROY; ! if ((fnews=fopen(newsfile,"w"))==NULL){ ! printf("error opening newsfile"); ! exit(1); ! } ! } destroy(); if(isupdate!=1) fclose(fnews); y=country; *************** *** 273,278 } else DESTROY; destroy(); y=country; country=save; return(y); --- 275,281 ----- } } destroy(); + if(isupdate!=1) fclose(fnews); y=country; country=save; return(y); *************** *** 283,288 /*execute new magic*/ exenewmgk(newpower) { short x,y; switch(newpower){ --- 286,292 ----- /*execute new magic*/ exenewmgk(newpower) + long newpower; { short x,y; if(newpower==WARRIOR) { *************** *** 285,293 exenewmgk(newpower) { short x,y; ! switch(newpower){ ! case WARRIOR: ! ntn[country].aplus+=10; ntn[country].dplus+=10; break; case CAPTAIN: --- 289,323 ----- long newpower; { short x,y; ! if(newpower==WARRIOR) { ! ntn[country].aplus+=10; ! ntn[country].dplus+=10; ! return(0L); ! } ! if(newpower==CAPTAIN) { ! ntn[country].aplus+=10; ! ntn[country].dplus+=10; ! return(0L); ! } ! if(newpower==WARLORD) { ! ntn[country].aplus+=10; ! ntn[country].dplus+=10; ! return(0L); ! } ! if(newpower==HEALER) { ! if(ntn[country].race==ORC) { ! if(ntn[country].repro<=11) ! ntn[country].repro+=2; ! else ntn[country].repro=13; ! } ! else if(ntn[country].repro<=8){ ! ntn[country].repro=10; ! } ! else if(ntn[country].repro==9){ ! ntn[country].repro=10; ! ntn[country].dplus+=5; ! } ! else if(ntn[country].repro>=10){ ntn[country].dplus+=10; } return(0L); *************** *** 289,329 case WARRIOR: ntn[country].aplus+=10; ntn[country].dplus+=10; ! break; ! case CAPTAIN: ! ntn[country].aplus+=10; ! ntn[country].dplus+=10; ! break; ! case WARLORD: ! ntn[country].aplus+=10; ! ntn[country].dplus+=10; ! break; ! case HEALER: ! if(ntn[country].race==ORC) { ! if(ntn[country].repro<=11) ! ntn[country].repro+=2; ! else ntn[country].repro=13; ! } ! else if(ntn[country].repro<=8){ ! ntn[country].repro=10; ! } ! else if(ntn[country].repro==9){ ! ntn[country].repro=10; ! ntn[country].dplus+=5; ! } ! else if(ntn[country].repro>=10){ ! ntn[country].dplus+=10; ! } ! break; ! case DESTROYER: ! for(x=ntn[country].capx-3;x<=ntn[country].capx+3;x++) { ! for(y=ntn[country].capy-3;y<=ntn[country].capy+3;y++){ ! if((ONMAP) ! &&(sct[x][y].altitude!=WATER) ! &&(isdigit(sct[x][y].vegetation)!=0)){ ! sct[x][y].vegetation=DESERT; ! sct[x][y].designation=DESERT; ! } } } updmove(ntn[country].race); --- 319,335 ----- } else if(ntn[country].repro>=10){ ntn[country].dplus+=10; ! } ! return(0L); ! } ! if(newpower==DESTROYER) { ! for(x=ntn[country].capx-3;x<=ntn[country].capx+3;x++) { ! for(y=ntn[country].capy-3;y<=ntn[country].capy+3;y++){ ! if((ONMAP) ! &&(sct[x][y].altitude!=WATER) ! &&(isdigit(sct[x][y].vegetation)!=0)){ ! sct[x][y].vegetation=DESERT; ! sct[x][y].designation=DESERT; } } } *************** *** 326,358 } } } ! updmove(ntn[country].race); ! break; ! case DERVISH: ! updmove(ntn[country].race); ! break; ! case MI_MONST: ! case AV_MONST: ! case MA_MONST: ! case SPY: ! case KNOWALL: ! case HIDDEN: ! case THE_VOID: ! case ARCHITECT: ! case MINER: ! break; ! case VAMPIRE: ! ntn[country].aplus-=35; ! ntn[country].dplus-=35; ! ntn[country].maxmove-=2; ! break; ! case URBAN: ! if(ntn[country].race==ORC) { ! ntn[country].repro+=3; ! if(ntn[country].repro>=13){ ! ntn[country].maxmove+=2*(ntn[country].repro-13); ! ntn[country].repro=13; ! } } else if(ntn[country].repro<=9){ ntn[country].repro+=3; --- 332,367 ----- sct[x][y].designation=DESERT; } } ! } ! updmove(ntn[country].race); ! return(0L); ! } ! if(newpower==DERVISH) { ! updmove(ntn[country].race); ! return(0L); ! } ! if((newpower==MI_MONST) ! ||(newpower==AV_MONST) ! ||(newpower==MA_MONST) ! ||(newpower==SPY) ! ||(newpower==KNOWALL) ! ||(newpower==HIDDEN) ! ||(newpower==THE_VOID) ! ||(newpower==ARCHITECT) ! ||(newpower==MINER)) ! return(0L); ! if(newpower==VAMPIRE) { ! ntn[country].aplus-=35; ! ntn[country].dplus-=35; ! ntn[country].maxmove-=2; ! return(0L); ! } ! if(newpower==URBAN) { ! if(ntn[country].race==ORC) { ! ntn[country].repro+=3; ! if(ntn[country].repro>=13){ ! ntn[country].maxmove+=2*(ntn[country].repro-13); ! ntn[country].repro=13; } } else if(ntn[country].repro<=9){ *************** *** 354,377 ntn[country].repro=13; } } ! else if(ntn[country].repro<=9){ ! ntn[country].repro+=3; ! } ! else { ! ntn[country].maxmove+=2*(ntn[country].repro-9); ! ntn[country].repro=12; ! } ! break; ! case STEEL: ! break; ! case ARCHER: ! ntn[country].dplus+=10; ! break; ! case CAVALRY: ! ntn[country].aplus+=10; ! ntn[country].maxmove+=6; ! break; ! case BREEDER: ntn[country].repro+=3; ntn[country].dplus-=10; ntn[country].dplus-=10; --- 363,370 ----- ntn[country].maxmove+=2*(ntn[country].repro-13); ntn[country].repro=13; } ! } ! else if(ntn[country].repro<=9){ ntn[country].repro+=3; } else { *************** *** 373,380 break; case BREEDER: ntn[country].repro+=3; ! ntn[country].dplus-=10; ! ntn[country].dplus-=10; ! break; } } --- 366,394 ----- } else if(ntn[country].repro<=9){ ntn[country].repro+=3; ! } ! else { ! ntn[country].maxmove+=2*(ntn[country].repro-9); ! ntn[country].repro=12; ! } ! return(0L); ! } ! if(newpower==STEEL) { ! return(0L); ! } ! if(newpower==ARCHER) { ! ntn[country].dplus+=10; ! return(0L); ! } ! if(newpower==CAVALRY) { ! ntn[country].aplus+=10; ! ntn[country].maxmove+=6; ! return(0L); ! } ! if(newpower==BREEDER) { ! ntn[country].repro+=3; ! ntn[country].dplus-=10; ! ntn[country].dplus-=10; ! return(0L); } }