Skip to content

Commit 251dbf8

Browse files
author
Conquer
committed
Conquer v4.07, from usenet
1 parent 74d49ba commit 251dbf8

21 files changed

Lines changed: 716 additions & 400 deletions

cexecute.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,21 +293,24 @@ hangup()
293293
}
294294
/*close file*/
295295
fclose(fexe);
296-
/*send a message to God*/
297-
if(mailopen( 0 )!=(-1)) {
298-
fprintf(fm,"WARNING: Nation %s hungup on me.\n",curntn->name);
299-
mailclose(0);
300-
}
301296

302-
/* remove the lock file */
303-
unlink(fison);
304297
/* remove any existing mail reading/writing file */
305298
if (mailok!=DONEMAIL) {
306299
extern char tmp_mail_name[];
307300
unlink(tmp_mail_name);
308301
}
302+
303+
/* remove the lock file */
304+
unlink(fison);
309305
sprintf(line,"%s%hd.tmp",msgfile,country);
310306
unlink(line);
307+
308+
/*send a message to God*/
309+
if(mailopen( 0 )!=(-1)) {
310+
fprintf(fm,"WARNING: Nation %s hungup on me.\n",curntn->name);
311+
mailclose(0);
312+
}
313+
311314
/* exit program */
312315
exit(FAIL);
313316
}

check.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ int __line__;
5050
__file__, __line__, country, i, a->yloc );
5151
a->yloc = 0;
5252
}
53-
if( sct[a->xloc][a->yloc].altitude==PEAK ) {
54-
fprintf( stderr, "file %s: line %d: nation[%d] army[%d] loc=%d,%d (peak)\n",
55-
__file__,__line__,country,i,a->xloc,a->yloc);
56-
a->sold = 0;
57-
}
5853
if( a->stat != ONBOARD && sct[a->xloc][a->yloc].altitude==WATER ) {
5954
fprintf( stderr, "file %s: line %d: nation[%d] army[%d] loc=%d,%d (water) men=%d\n",
6055
__file__,__line__,country,i,a->xloc,a->yloc,a->sold);
6156
a->sold = 0;
6257
}
58+
if( a->stat == ONBOARD && a->smove > 0) {
59+
/* don't echo since this is still getting */
60+
/* set some place someplace I can't find yet */
61+
a->smove = 0;
62+
}
6363
} /* for */
6464

6565
for( i = 0; i < NTOTAL; i++ ) {
@@ -147,8 +147,8 @@ checkout(file,line)
147147
int line;
148148
char *file;
149149
{
150-
/* fprintf(stderr,"file %s line %d\n",file,line); */
151-
/* verifydata(file,line); */
150+
fprintf(stderr,"file %s line %d\n",file,line);
151+
verifydata(file,line);
152152
}
153153
#endif DEBUG
154154

@@ -158,6 +158,7 @@ char *file;
158158
# include <unistd.h>
159159
# define do_lock(fd) lockf(fd,F_TLOCK,0)
160160
#else
161+
# include <sys/types.h>
161162
# include <sys/file.h>
162163
# define do_lock(fd) flock(fd,LOCK_EX|LOCK_NB)
163164
#endif
@@ -192,8 +193,17 @@ check_lock(filename,keeplock)
192193
exit(FAIL);
193194
}
194195
#else
195-
if( access( filename, 00 ) == 0 ) {
196-
hold=TRUE;
196+
struct stat fst;
197+
198+
if( stat( filename, &fst ) == 0 ) {
199+
long now;
200+
now = time(0);
201+
if (now - fst.st_mtime < TIME_DEAD*3) {
202+
hold=TRUE;
203+
} else {
204+
/* remove useless file */
205+
unlink(filename);
206+
}
197207
}
198208
if (hold==FALSE && keeplock==TRUE) {
199209
/* create lock file */

combat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,8 @@ printf("I AM VERY CONFUSED - PLEASE HELP... combat.c\n");
633633
if((ntn[UOWNER(k)].arm[unit[k]].unittyp >= MINLEADER)
634634
&&( ntn[UOWNER(k)].arm[unit[k]].sold == 0))
635635
fprintf(fm," (killed)\n");
636-
else if((ntn[owner[k]].arm[unit[k]].unittyp == A_MILITIA)
637-
&&( ntn[owner[k]].arm[unit[k]].sold == 0))
636+
else if((ntn[UOWNER(k)].arm[unit[k]].unittyp == A_MILITIA)
637+
&&( ntn[UOWNER(k)].arm[unit[k]].sold == 0))
638638
fprintf(fm," (disbanded)\n");
639639
else fputc('\n',fm);
640640
}

commands.c

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
#include "header.h"
1414
#include "data.h"
1515
#include <ctype.h>
16-
17-
#ifdef SYSMAIL
16+
#ifdef CONQUER
1817
#include <sys/types.h>
19-
#endif SYSMAIL
18+
#include <sys/stat.h>
19+
#endif /*CONQUER*/
20+
2021
extern long conq_mail_size;
2122

2223
extern FILE *fexe; /*execute file pointer*/
@@ -93,16 +94,6 @@ desg_ok(prtflag, desg, sptr)
9394
}
9495
}
9596

96-
/* have this for now... may be too harsh */
97-
if (desg==DMILL || desg==DGRANARY) {
98-
if((sptr->tradegood != TG_none)
99-
&&(*(tg_stype + sptr->tradegood) != DFARM)
100-
&&(*(tg_stype + sptr->tradegood) != 'x')) {
101-
if(prtflag) errormsg("You can't have one of those here!");
102-
return(FALSE);
103-
}
104-
}
105-
10697
if (desg==DUNIVERSITY || desg==DLUMBERYD) {
10798
if((sptr->tradegood != TG_none)
10899
&&(*(tg_stype + sptr->tradegood) != desg)
@@ -149,7 +140,7 @@ redesignate()
149140
curntn= &ntn[country];
150141

151142
clear_bottom(0);
152-
mvaddstr(LINES-4,0,"SUPER USER: CHANGE (v)egetation, (e)levation, (d)esig, (o)wner, (t)radegood");
143+
mvaddstr(LINES-4,0,"SUPER USER: CHANGE (v)eg, (e)lev, (d)esig, (o)wner, (p)op, (t)radegood");
153144
refresh();
154145
switch(getch()){
155146
case 'd':
@@ -190,8 +181,8 @@ redesignate()
190181
}
191182
sptr->vegetation=newdes;
192183
if( tofood(sptr,0) < DESFOOD )
193-
sptr->designation=DNODESIG;
194-
else sptr->designation=newdes;
184+
sptr->designation=newdes;
185+
else sptr->designation=DNODESIG;
195186
reset_god();
196187
return;
197188
case 'o':
@@ -201,6 +192,17 @@ redesignate()
201192
if (x<NTOTAL) sptr->owner=x;
202193
reset_god();
203194
return;
195+
case 'p':
196+
if (sptr->altitude == WATER) {
197+
errormsg("Trying to build a colony of mermen?");
198+
reset_god();
199+
return;
200+
}
201+
mvaddstr(LINES-3,7,"new population for sector: ");
202+
refresh();
203+
sptr->people = (long) get_number();
204+
reset_god();
205+
return;
204206
case 't':
205207
x=TRUE;
206208
while(x==TRUE) {
@@ -635,7 +637,7 @@ construct()
635637
return;
636638
}
637639

638-
if( sct[XREAL][YREAL].people < amount * SHIPCREW ){
640+
if( sct[XREAL][YREAL].people < amount * (shipsize+1) * SHIPCREW ){
639641
errormsg("NOT ENOUGH CIVILIANS IN SECTOR");
640642
if(isgod==TRUE) reset_god();
641643
return;
@@ -699,13 +701,15 @@ construct()
699701
/* construct fortification points*/
700702
else if(type=='f'){
701703
/* can only go into debt as much as the nation has jewels */
702-
if ((curntn->tgold - cost) >= ((-1)*10*curntn->jewels)) {
704+
if (sct[XREAL][YREAL].fortress>11) {
705+
errormsg("That sector is as impregnable as you can make it");
706+
} else if ((curntn->tgold - cost) >= ((-1)*10*curntn->jewels)) {
703707
mvprintw(LINES-2,5,"you build +%d%% fort points for %ld gold",armbonus,cost);
704708
curntn->tgold-=cost;
705709
sct[XREAL][YREAL].fortress++;
706710
INCFORT;
707711
errormsg("");
708-
} else errormsg("you are broke");
712+
} else errormsg("you may not spend that much");
709713
}
710714
else errormsg("invalid input error");
711715

@@ -1038,6 +1042,7 @@ rmessage()
10381042
char mesgfile[FILELTH];
10391043
char line[LINELTH+1], inpch;
10401044
char save[LINELTH][LINELTH+1];
1045+
struct stat fst;
10411046

10421047
/*open file; used in mailopen() as well */
10431048
sprintf(tempfile,"%s%hd.tmp",msgfile,country);
@@ -1062,14 +1067,21 @@ rmessage()
10621067

10631068
/* check for people sending mail */
10641069
sprintf(line,"send.%s%hd",msgfile,country);
1065-
if (access(line,00)==0) {
1066-
/* someone is sending mail to the country */
1067-
(void) unlink (tempfile) ;
1068-
clear_bottom(0);
1069-
errormsg("Someone is sending you mail... please wait.");
1070-
makebottom();
1071-
redraw=DONE;
1072-
return;
1070+
if (stat(line,&fst)==0) {
1071+
long now;
1072+
now = time(0);
1073+
if (now - fst.st_mtime < TIME_DEAD) {
1074+
/* someone is sending mail to the country */
1075+
(void) unlink (tempfile) ;
1076+
clear_bottom(0);
1077+
errormsg("Someone is sending you mail... please wait.");
1078+
makebottom();
1079+
redraw=DONE;
1080+
return;
1081+
} else {
1082+
/* remove useless file */
1083+
(void) unlink(line);
1084+
}
10731085
}
10741086

10751087
/*read in file a line at at time*/
@@ -1142,27 +1154,29 @@ wmessage()
11421154
char line[BIGLTH];
11431155

11441156
/*what nation to send to*/
1145-
clear();
1146-
mvaddstr(0,0,"To send a message to the administrator, send to 'god';");
1147-
mvaddstr(1,0,"To post to the news, send to 'news':");
1148-
mvaddstr(2,0,"Enter the name of the country to send to: ");
1157+
clear_bottom(0);
1158+
mvaddstr(LINES-4,0,"The Conquer Administrator is 'god'; To send to the News use 'news';");
1159+
mvaddstr(LINES-3,0,"Send mail to what nation? ");
11491160
refresh();
11501161
temp=get_country();
11511162

11521163
if( temp == NEWSMAIL ) {
11531164
strcpy(name,"news");
11541165
} else {
11551166
/* quick return on bad input */
1156-
if(temp==(-1) || temp>=NTOTAL
1157-
|| (!isntn(ntn[temp].active) && temp!=0))
1158-
return;
1167+
if(temp==(-1) || temp>=NTOTAL
1168+
|| (!isntn(ntn[temp].active) && temp!=0)) {
1169+
makebottom();
1170+
return;
1171+
}
11591172
strcpy(name,ntn[temp].name); /* find nation name */
11601173
}
11611174

11621175
if(mailopen( temp )==(-1)) {
1176+
makebottom();
11631177
return;
11641178
}
1165-
1179+
redraw=FULL;
11661180

11671181
if(temp != -2) {
11681182
if (country==0)

data.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/*--------I DO NOT BELIEVE IT IS NECESSARY TO ALTER THIS FILE----------------*/
44
#define FAIL 1 /* fail return to shell */
55
#define SUCCESS 0 /* successful return to shell */
6+
#define TIME_DEAD 3600 /* number of seconds for file aging */
67
#define BIG 500000000L /* BIGGER THAN ANYTHING SHOULD BE */
78
/* this is used to protect against overflow */
89
#define SCRARM ((LINES-14)/2) /* number of armies to fit on screen */
@@ -203,7 +204,7 @@ struct s_sector
203204
long people; /* civilians in sector */
204205
short i_people; /* initial civilians in sector */
205206
unsigned char jewels; /* jewel production ability */
206-
unsigned char fortress; /* fortification level (0 to 9) */
207+
unsigned char fortress; /* fortification level; 0 to 12 */
207208
unsigned char metal; /* metal produced by sector */
208209
unsigned char tradegood; /* exotic trade goods in sector */
209210
/* unsigned char region; /* index of region */

display.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
/*conquer : Copyright (c) 1988 by Ed Barlow.
44
* I spent a long time writing this code & I hope that you respect this.
55
* I give permission to alter the code, but not to copy or redistribute
6-
* it without my explicit permission. If you alter the code,
6+
* it without my explicit permission. If you alter the code,
77
* please document changes and send me a copy, so all can have it.
8-
* This code, to the best of my knowledge works well, but it is my first
8+
* This code, to the best of my knowledge works well, but it is my first
99
* 'C' program and should be treated as such. I disclaim any
10-
* responsibility for the codes actions (use at your own risk). I guess
10+
* responsibility for the codes actions (use at your own risk). I guess
1111
* I am saying "Happy gaming", and am trying not to get sued in the process.
12-
* Ed
12+
* Ed
1313
*/
1414

1515
/*include files*/
@@ -410,7 +410,10 @@ coffmap()
410410
{
411411
if((xcurs<=0)||(ycurs<=0)||(xcurs>=SCREEN_X_SIZE-1)
412412
||((ycurs>=SCREEN_Y_SIZE-1))||((XREAL)>=MAPX)
413-
||((YREAL)>=MAPY)) offmap();
413+
||((YREAL)>=MAPY)) {
414+
centermap();
415+
redraw=PART;
416+
}
414417

415418
if(redraw!=DONE) {
416419
if (redraw==FULL) {

0 commit comments

Comments
 (0)