~ubuntu-branches/ubuntu/vivid/empire/vivid-proposed

« back to all changes in this revision

Viewing changes to edit.c

  • Committer: Package Import Robot
  • Author(s): Markus Koschany
  • Date: 2014-01-12 10:41:53 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20140112104153-iawyc84mk4v5qs6n
Tags: 1.11-1
* New maintainer Debian Games Team.
  - Add myself to Uploaders. (Closes: #733320)
* Imported Upstream version 1.11.
  - Fix several spelling errors in empire.6. Thanks to Bjarnig Ingi Gislason.
    (LP: #1070946)
  - Fix a typo in object.c that made a single city stop producing output.
    Thanks to the anonymous reporter. (Closes: #593434)
* Switch to source format 3.0 (quilt).
* Bump compat level to 9 and require debhelper >= 9. Add compat file.
* Drop lintian.override.
* Switch to dh-sequencer. Pass default build flags to upstream's Makefile.
* Add manpages file.
* debian/control:
  - Set priority from extra to optional.
  - Update package to Standards-Version 3.9.5.
  - Add VCS fields.
  - Add Homepage field.
  - Add ${misc:Depends} substvar.
  - Fix typo "they" in package description. (Closes: #668614)
  - Fix description-synopsis-starts-with-article.
* Use install file to install the binary, icons and desktop file.
* Drop dirs file. Not needed.
* Add watch file. Thanks to Bart Martens.
* Update debian/copyright to copyright format 1.0.
* Add icon entry to menu file.
* Install icons to /usr/share/pixmaps.
  - Convert to empire-logo.xpm with imagemagick at build time.
* Add empire.desktop file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* %W% %G% %U% - (c) Copyright 1987, 1988 Chuck Simmons */
2
 
 
3
1
/*
4
2
 *    Copyright (C) 1987, 1988 Chuck Simmons
5
3
 * 
11
9
edit.c -- Routines to handle edit mode commands.
12
10
*/
13
11
 
14
 
#ifdef SYSV
 
12
#include <stdio.h>
15
13
#include <string.h>
16
 
#else
17
 
#include <strings.h>
18
 
#endif
19
 
 
20
14
#include <curses.h>
21
15
#include <ctype.h>
22
16
#include "empire.h"
23
17
#include "extern.h"
24
18
 
25
 
void e_move(long *path_start, long loc);
26
 
extern int get_piece_name();
 
19
void e_move(loc_t *path_start, loc_t loc);
 
20
extern int get_piece_name(void);
27
21
 
28
22
void
29
 
edit(edit_cursor)
30
 
long edit_cursor;
 
23
edit(loc_t edit_cursor)
31
24
{
32
 
        char e_cursor();
33
 
        void e_leave(), e_print(), e_random();
34
 
        void e_stasis(), e_end(), e_wake(), e_sleep();
35
 
        void e_info(), e_prod(), e_help(), e_explore();
36
 
        void e_fill(), e_land(), e_city_func(), e_transport();
37
 
        void e_attack(), e_repair();
38
 
 
39
 
        long path_start;
40
 
        int path_type;
41
 
        char e;
42
 
        
43
 
        path_start = -1; /* not building a path yet */
44
 
        
45
 
        for (;;) { /* until user gives command to leave */
46
 
                display_loc_u (edit_cursor); /* position cursor */
47
 
                e = e_cursor (&edit_cursor); /* handle cursor movement */
48
 
 
49
 
                switch (e) {
50
 
                case 'B': /* change city production */
51
 
                        e_prod (edit_cursor);
52
 
                        break;
53
 
                case 'F': /* fill */
54
 
                        e_fill (edit_cursor);
55
 
                        break;
56
 
                case 'G': /* explore */
57
 
                        e_explore (edit_cursor);
58
 
                        break;
59
 
                case 'H': /* help */
60
 
                        e_help ();
61
 
                        break;
62
 
                case 'I': /* directional stasis */
63
 
                        e_stasis (edit_cursor);
64
 
                        break;
65
 
                case 'K': /* wake up anything and everything */
66
 
                        e_wake (edit_cursor);
67
 
                        break;
68
 
                case 'L': /* land plane */
69
 
                        e_land (edit_cursor);
70
 
                        break;
71
 
                case 'M': /* start move to location */
72
 
                        path_type = NOPIECE;
73
 
                        e_move (&path_start, edit_cursor);
74
 
                        break;
75
 
                case 'N': /* end move to location */
76
 
                        e_end (&path_start, edit_cursor, path_type);
77
 
                        break;
78
 
                case 'O': /* leave display mode */
79
 
                        e_leave ();
80
 
                        return;
81
 
                case 'P': /* print new sector */
82
 
                        e_print (&edit_cursor);
83
 
                        break;
84
 
                case 'R': /* make piece move randomly */
85
 
                        e_random (edit_cursor);
86
 
                        break;
87
 
                case 'S': /* sleep */
88
 
                        e_sleep (edit_cursor);
89
 
                        break;
90
 
                case 'T': /* transport army */
91
 
                        e_transport (edit_cursor);
92
 
                        break;
93
 
                case 'U': /* repair ship */
94
 
                        e_repair (edit_cursor);
95
 
                        break;
96
 
                case 'V': /* set city function */
97
 
                        e_city_func (&path_start, edit_cursor, &path_type);
98
 
                        break;
99
 
                case 'Y': /* set army func to attack */
100
 
                        e_attack (edit_cursor);
101
 
                        break;
102
 
                case '?': /* request info */
103
 
                        e_info (edit_cursor);
104
 
                        break;
105
 
                case '\014': /* control-L */
106
 
                        redraw ();
107
 
                        break;
108
 
                default: /* bad command? */
109
 
                        huh ();
110
 
                        break;
111
 
                }
 
25
    char e_cursor();
 
26
    void e_leave(), e_print(), e_random();
 
27
    void e_stasis(), e_end(), e_wake(), e_sleep();
 
28
    void e_info(), e_prod(), e_help(), e_explore();
 
29
    void e_fill(), e_land(), e_city_func(), e_transport();
 
30
    void e_attack(), e_repair();
 
31
 
 
32
    loc_t path_start;
 
33
    int path_type;
 
34
    char e;
 
35
        
 
36
    path_start = -1; /* not building a path yet */
 
37
        
 
38
    for (;;) { /* until user gives command to leave */
 
39
        display_loc_u (edit_cursor); /* position cursor */
 
40
        e = e_cursor (&edit_cursor); /* handle cursor movement */
 
41
 
 
42
        switch (e) {
 
43
        case 'B': /* change city production */
 
44
            e_prod (edit_cursor);
 
45
            break;
 
46
        case 'F': /* fill */
 
47
            e_fill (edit_cursor);
 
48
            break;
 
49
        case 'G': /* explore */
 
50
            e_explore (edit_cursor);
 
51
            break;
 
52
        case 'H': /* help */
 
53
            e_help ();
 
54
            break;
 
55
        case 'I': /* directional stasis */
 
56
            e_stasis (edit_cursor);
 
57
            break;
 
58
        case 'K': /* wake up anything and everything */
 
59
            e_wake (edit_cursor);
 
60
            break;
 
61
        case 'L': /* land plane */
 
62
            e_land (edit_cursor);
 
63
            break;
 
64
        case 'M': /* start move to location */
 
65
            path_type = NOPIECE;
 
66
            e_move (&path_start, edit_cursor);
 
67
            break;
 
68
        case 'N': /* end move to location */
 
69
            e_end (&path_start, edit_cursor, path_type);
 
70
            break;
 
71
        case 'O': /* leave display mode */
 
72
            e_leave ();
 
73
            return;
 
74
        case 'P': /* print new sector */
 
75
            e_print (&edit_cursor);
 
76
            break;
 
77
        case 'R': /* make piece move randomly */
 
78
            e_random (edit_cursor);
 
79
            break;
 
80
        case 'S': /* sleep */
 
81
            e_sleep (edit_cursor);
 
82
            break;
 
83
        case 'T': /* transport army */
 
84
            e_transport (edit_cursor);
 
85
            break;
 
86
        case 'U': /* repair ship */
 
87
            e_repair (edit_cursor);
 
88
            break;
 
89
        case 'V': /* set city function */
 
90
            e_city_func (&path_start, edit_cursor, &path_type);
 
91
            break;
 
92
        case 'Y': /* set army func to attack */
 
93
            e_attack (edit_cursor);
 
94
            break;
 
95
        case '?': /* request info */
 
96
            e_info (edit_cursor);
 
97
            break;
 
98
        case '\014': /* control-L */
 
99
            redraw ();
 
100
            break;
 
101
        default: /* bad command? */
 
102
            huh ();
 
103
            break;
112
104
        }
 
105
    }
113
106
}
114
107
 
115
108
/*
118
111
fast.
119
112
*/
120
113
 
121
 
static char dirchars[] = "WwEeDdCcXxZzAaQq";
122
 
 
123
114
char
124
 
e_cursor (edit_cursor)
125
 
long *edit_cursor;
 
115
e_cursor(loc_t *edit_cursor)
126
116
{
127
 
        char e;
128
 
        char *p;
 
117
    chtype e;
 
118
    int p;
129
119
        
130
 
        /* set up terminal */
131
 
        (void) crmode ();
 
120
    /* set up terminal */
 
121
    (void) crmode ();
 
122
    (void) refresh ();
 
123
    e = getch ();
 
124
    topini (); /* clear any error messages */
 
125
 
 
126
    for (;;) {
 
127
        p = direction (e);
 
128
        if (p == -1) break;
 
129
 
 
130
        if (!move_cursor (edit_cursor, dir_offset[p]))
 
131
            (void) beep ();
 
132
                
132
133
        (void) refresh ();
133
134
        e = getch ();
134
 
        topini (); /* clear any error messages */
135
 
 
136
 
        for (;;) {
137
 
                p = strchr (dirchars, e);
138
 
                if (!p) break;
139
 
 
140
 
                if (!move_cursor (edit_cursor, dir_offset[(p-dirchars) / 2]))
141
 
                        (void) beep ();
142
 
                
143
 
                (void) refresh ();
144
 
                e = getch ();
145
 
        }
146
 
        (void) nocrmode (); /* reset terminal */
147
 
        if (islower (e)) e = upper (e);
148
 
        return e;
 
135
    }
 
136
    (void) nocrmode (); /* reset terminal */
 
137
    return toupper(e);
149
138
}
150
139
 
151
140
/*
153
142
*/
154
143
 
155
144
void
156
 
e_leave () {
 
145
e_leave(void)
 
146
{
157
147
}
158
148
 
159
149
/*
161
151
*/
162
152
 
163
153
void
164
 
e_print (edit_cursor)
165
 
long *edit_cursor;
 
154
e_print(loc_t *edit_cursor)
166
155
{
167
 
        int sector;
 
156
    int sector;
168
157
        
169
 
        sector = get_range ("New Sector? ", 0, NUM_SECTORS-1);
 
158
    sector = get_range ("New Sector? ", 0, NUM_SECTORS-1);
170
159
 
171
 
        /* position cursor at center of sector */
172
 
        *edit_cursor = sector_loc (sector);
173
 
        sector_change (); /* allow change of sector */
 
160
    /* position cursor at center of sector */
 
161
    *edit_cursor = sector_loc (sector);
 
162
    sector_change (); /* allow change of sector */
174
163
}
175
164
 
176
165
/*
178
167
*/
179
168
 
180
169
void
181
 
e_set_func (loc, func)
182
 
long loc;
183
 
long func;
 
170
e_set_func(loc_t loc, long func)
184
171
{
185
 
        piece_info_t *obj;
186
 
        obj = find_obj_at_loc (loc);
187
 
        if (obj != NULL && obj->owner == USER) {
188
 
                obj->func = func;
189
 
                return;
190
 
        }
191
 
        huh (); /* no object here */
 
172
    piece_info_t *obj;
 
173
    obj = find_obj_at_loc (loc);
 
174
    if (obj != NULL && obj->owner == USER) {
 
175
        obj->func = func;
 
176
        return;
 
177
    }
 
178
    huh (); /* no object here */
192
179
}
193
180
        
194
181
/* Set the function of a city for some piece. */
195
182
 
196
183
void
197
 
e_set_city_func (cityp, type, func)
198
 
city_info_t *cityp;
199
 
int type;
200
 
long func;
 
184
e_set_city_func(city_info_t *cityp, int type, long func)
201
185
{
202
 
        cityp->func[type] = func;
 
186
    cityp->func[type] = func;
203
187
}
204
188
 
205
189
/*
207
191
*/
208
192
 
209
193
void
210
 
e_random (loc)
211
 
long loc;
 
194
e_random(loc_t loc)
212
195
{
213
 
        e_set_func (loc, RANDOM);
 
196
    e_set_func (loc, RANDOM);
214
197
}
215
198
 
216
199
void
217
 
e_city_random (cityp, type)
218
 
city_info_t *cityp;
219
 
int type;
 
200
e_city_random(city_info_t *cityp, int type)
220
201
{
221
 
        e_set_city_func (cityp, type, RANDOM);
 
202
    e_set_city_func (cityp, type, RANDOM);
222
203
}
223
204
 
224
205
/*
226
207
*/
227
208
 
228
209
void
229
 
e_fill (loc)
230
 
long loc;
 
210
e_fill(loc_t loc)
231
211
{
232
 
        if (user_map[loc].contents == 'T' || user_map[loc].contents == 'C')
233
 
                e_set_func (loc, FILL);
234
 
        else huh ();
 
212
    if (user_map[loc].contents == 'T' || user_map[loc].contents == 'C')
 
213
        e_set_func (loc, FILL);
 
214
    else huh ();
235
215
}
236
216
 
237
217
void
238
 
e_city_fill (cityp, type)
239
 
city_info_t *cityp;
240
 
int type;
 
218
e_city_fill(city_info_t *cityp, int type)
241
219
{
242
 
        if (type == TRANSPORT || type == CARRIER)
243
 
                e_set_city_func (cityp, type, FILL);
244
 
        else huh ();
 
220
    if (type == TRANSPORT || type == CARRIER)
 
221
        e_set_city_func (cityp, type, FILL);
 
222
    else huh ();
245
223
}
246
224
 
247
225
/*
249
227
*/
250
228
 
251
229
void
252
 
e_explore (loc)
253
 
long loc;
 
230
e_explore(loc_t loc)
254
231
{
255
 
        e_set_func (loc, EXPLORE);
 
232
    e_set_func (loc, EXPLORE);
256
233
}
257
234
 
258
235
void
259
 
e_city_explore (cityp, type)
260
 
city_info_t *cityp;
261
 
int type;
 
236
e_city_explore(city_info_t *cityp, loc_t type)
262
237
{
263
 
        e_set_city_func (cityp, type, EXPLORE);
 
238
    e_set_city_func (cityp, type, EXPLORE);
264
239
}
265
240
 
266
241
/*
268
243
*/
269
244
 
270
245
void
271
 
e_land (loc)
272
 
long loc;
 
246
e_land(loc_t loc)
273
247
{
274
 
        if (user_map[loc].contents == 'F')
275
 
                e_set_func (loc, LAND);
276
 
        else huh ();
 
248
    if (user_map[loc].contents == 'F')
 
249
        e_set_func (loc, LAND);
 
250
    else huh ();
277
251
}
 
252
 
278
253
/*
279
254
Set an army's function to TRANSPORT.
280
255
*/
281
256
 
282
257
void
283
 
e_transport (loc)
284
 
long loc;
 
258
e_transport(loc_t loc)
285
259
{
286
 
        if (user_map[loc].contents == 'A')
287
 
                e_set_func (loc, WFTRANSPORT);
288
 
        else huh ();
 
260
    if (user_map[loc].contents == 'A')
 
261
        e_set_func (loc, WFTRANSPORT);
 
262
    else huh ();
289
263
}
290
264
 
291
265
/*
293
267
*/
294
268
 
295
269
void
296
 
e_attack (loc)
297
 
long loc;
 
270
e_attack(loc_t loc)
298
271
{
299
 
        if (user_map[loc].contents == 'A')
300
 
                e_set_func (loc, ARMYATTACK);
301
 
        else huh ();
 
272
    if (user_map[loc].contents == 'A')
 
273
        e_set_func (loc, ARMYATTACK);
 
274
    else huh ();
302
275
}
303
276
 
304
277
void
305
 
e_city_attack (cityp, type)
306
 
city_info_t *cityp;
307
 
int type;
 
278
e_city_attack(city_info_t *cityp, int type)
308
279
{
309
 
        if (type == ARMY)
310
 
                e_set_city_func (cityp, type, ARMYATTACK);
311
 
        else huh ();
 
280
    if (type == ARMY)
 
281
        e_set_city_func (cityp, type, ARMYATTACK);
 
282
    else huh ();
312
283
}
313
284
 
314
285
/*
316
287
*/
317
288
 
318
289
void
319
 
e_repair (loc)
320
 
long loc;
 
290
e_repair(loc_t loc)
321
291
{
322
 
        if (strchr ("PDSTBC", user_map[loc].contents))
323
 
                e_set_func (loc, REPAIR);
324
 
        else huh ();
 
292
    if (strchr ("PDSTBC", user_map[loc].contents))
 
293
        e_set_func (loc, REPAIR);
 
294
    else huh ();
325
295
}
326
296
 
327
297
void
328
 
e_city_repair (cityp, type)
329
 
city_info_t *cityp;
330
 
int type;
 
298
e_city_repair(city_info_t *cityp, int type)
331
299
{
332
300
        if (type == ARMY || type == FIGHTER || type == SATELLITE)
333
301
                huh ();
341
309
static char dirs[] = "WEDCXZAQ";
342
310
 
343
311
void
344
 
e_stasis (loc)
345
 
long loc;
 
312
e_stasis(loc_t loc)
346
313
{
347
 
        char e;
348
 
        char *p;
349
 
        
350
 
        if (!isupper (user_map[loc].contents)) huh (); /* no object here */
351
 
        else if (user_map[loc].contents == 'X') huh ();
352
 
        else {
353
 
                e = get_chx(); /* get a direction */
354
 
                p = strchr (dirs, e);
 
314
    if (!isupper (user_map[loc].contents))
 
315
        huh (); /* no object here */
 
316
    else if (user_map[loc].contents == 'X')
 
317
        huh ();
 
318
    else {
 
319
        char e = get_chx(); /* get a direction */
 
320
        char *p = strchr (dirs, e);
355
321
 
356
 
                if (p == NULL) huh ();
357
 
                else e_set_func (loc, (long)(MOVE_N - (p - dirs)));
358
 
        }
 
322
        if (p == NULL)
 
323
            huh ();
 
324
        else
 
325
            e_set_func (loc, (long)(MOVE_N - (p - dirs)));
 
326
    }
359
327
}
360
328
 
361
329
void
362
 
e_city_stasis (cityp, type)
363
 
city_info_t *cityp;
364
 
int type;
 
330
e_city_stasis(city_info_t *cityp, int type)
365
331
{
366
 
        char e;
367
 
        char *p;
 
332
    char e;
 
333
    char *p;
368
334
        
369
 
        e = get_chx(); /* get a direction */
370
 
        p = strchr (dirs, e);
 
335
    e = get_chx(); /* get a direction */
 
336
    p = strchr (dirs, e);
371
337
 
372
 
        if (p == NULL) huh ();
373
 
        else e_set_city_func (cityp, type, (long)(MOVE_N - (p - dirs)));
 
338
    if (p == NULL)
 
339
        huh ();
 
340
    else
 
341
        e_set_city_func (cityp, type, (long)(MOVE_N - (p - dirs)));
374
342
}
375
343
 
376
344
/*
378
346
*/
379
347
 
380
348
void
381
 
e_wake (loc)
382
 
long loc;
 
349
e_wake(loc_t loc)
383
350
{
384
 
        city_info_t *cityp;
385
 
        piece_info_t *obj;
386
 
        int i;
 
351
    city_info_t *cityp;
 
352
    piece_info_t *obj;
 
353
    int i;
387
354
 
388
 
        cityp = find_city (loc);
389
 
        if (cityp != NULL) {
390
 
                for (i = 0; i < NUM_OBJECTS; i++)
391
 
                        cityp->func[i] = NOFUNC;
392
 
        }
393
 
        for (obj = map[loc].objp; obj != NULL; obj = obj->loc_link.next)
394
 
                obj->func = NOFUNC;
 
355
    cityp = find_city (loc);
 
356
    if (cityp != NULL) {
 
357
        for (i = 0; i < NUM_OBJECTS; i++)
 
358
            cityp->func[i] = NOFUNC;
 
359
    }
 
360
    for (obj = map[loc].objp; obj != NULL; obj = obj->loc_link.next)
 
361
        obj->func = NOFUNC;
395
362
}
396
363
 
397
364
void
398
 
e_city_wake (cityp, type)
399
 
city_info_t *cityp;
400
 
int type;
 
365
e_city_wake(city_info_t *cityp, int type)
401
366
{
402
 
        e_set_city_func (cityp, type, NOFUNC);
 
367
    e_set_city_func (cityp, type, NOFUNC);
403
368
}
404
369
 
405
370
/*
408
373
*/
409
374
 
410
375
void
411
 
e_city_func (path_start, loc, path_type)
412
 
long *path_start;
413
 
long loc;
414
 
int *path_type;
 
376
e_city_func(loc_t *path_start, loc_t loc, int *path_type)
415
377
{
416
 
        int type;
417
 
        char e;
418
 
        city_info_t *cityp;
419
 
 
420
 
        cityp = find_city (loc);
421
 
        if (!cityp || cityp->owner != USER) {
422
 
                huh ();
423
 
                return;
424
 
        }
425
 
 
426
 
        type = get_piece_name();
427
 
        if (type == NOPIECE) {
428
 
                huh ();
429
 
                return;
430
 
        }
431
 
        
432
 
        e = get_chx ();
433
 
        
434
 
        switch (e) {
435
 
        case 'F': /* fill */
436
 
                e_city_fill (cityp, type);
437
 
                break;
438
 
        case 'G': /* explore */
439
 
                e_city_explore (cityp, type);
440
 
                break;
441
 
        case 'I': /* directional stasis */
442
 
                e_city_stasis (cityp, type);
443
 
                break;
444
 
        case 'K': /* turn off function */
445
 
                e_city_wake (cityp, type);
446
 
                break;
447
 
        case 'M': /* start move to location */
448
 
                *path_type = type;
449
 
                e_move (path_start, loc);
450
 
                break;
451
 
        case 'R': /* make piece move randomly */
452
 
                e_city_random (cityp, type);
453
 
                break;
454
 
        case 'U': /* repair ship */
455
 
                e_city_repair (cityp, type);
456
 
                break;
457
 
        case 'Y': /* set army func to attack */
458
 
                e_city_attack (cityp, type);
459
 
                break;
460
 
        default: /* bad command? */
461
 
                huh ();
462
 
                break;
463
 
        }
 
378
    int type;
 
379
    char e;
 
380
    city_info_t *cityp;
 
381
 
 
382
    cityp = find_city (loc);
 
383
    if (!cityp || cityp->owner != USER) {
 
384
        huh ();
 
385
        return;
 
386
    }
 
387
 
 
388
    type = get_piece_name();
 
389
    if (type == NOPIECE) {
 
390
        huh ();
 
391
        return;
 
392
    }
 
393
        
 
394
    e = get_chx ();
 
395
        
 
396
    switch (e) {
 
397
    case 'F': /* fill */
 
398
        e_city_fill (cityp, type);
 
399
        break;
 
400
    case 'G': /* explore */
 
401
        e_city_explore (cityp, type);
 
402
        break;
 
403
    case 'I': /* directional stasis */
 
404
        e_city_stasis (cityp, type);
 
405
        break;
 
406
    case 'K': /* turn off function */
 
407
        e_city_wake (cityp, type);
 
408
        break;
 
409
    case 'M': /* start move to location */
 
410
        *path_type = type;
 
411
        e_move (path_start, loc);
 
412
        break;
 
413
    case 'R': /* make piece move randomly */
 
414
        e_city_random (cityp, type);
 
415
        break;
 
416
    case 'U': /* repair ship */
 
417
        e_city_repair (cityp, type);
 
418
        break;
 
419
    case 'Y': /* set army func to attack */
 
420
        e_city_attack (cityp, type);
 
421
        break;
 
422
    default: /* bad command? */
 
423
        huh ();
 
424
        break;
 
425
    }
464
426
}
465
427
 
466
428
/*
468
430
*/
469
431
 
470
432
void
471
 
e_move (path_start, loc)
472
 
long *path_start;
473
 
long loc;
 
433
e_move(loc_t *path_start, loc_t loc)
474
434
{
475
 
        if (!isupper(user_map[loc].contents)) huh (); /* nothing there? */
476
 
        else if (user_map[loc].contents == 'X') huh (); /* enemy city? */
477
 
        else *path_start = loc;
 
435
    if (!isupper(user_map[loc].contents)) huh (); /* nothing there? */
 
436
    else if (user_map[loc].contents == 'X') huh (); /* enemy city? */
 
437
    else *path_start = loc;
478
438
}
479
439
 
480
440
/*
482
442
*/
483
443
 
484
444
void
485
 
e_end (path_start, loc, path_type)
486
 
long *path_start;
487
 
long loc;
488
 
int path_type;
489
 
{
490
 
        city_info_t *cityp;
491
 
        
492
 
        if (*path_start == -1) huh (); /* no path started? */
493
 
        else if (path_type == NOPIECE) e_set_func (*path_start, loc);
494
 
        else {
495
 
                cityp = find_city (*path_start);
496
 
                ASSERT (cityp);
497
 
                e_set_city_func (cityp, path_type, loc);
498
 
        }
 
445
e_end(loc_t *path_start, loc_t loc, int path_type)
 
446
{       
 
447
    if (*path_start == -1)
 
448
        huh (); /* no path started? */
 
449
    else if (path_type == NOPIECE)
 
450
        e_set_func (*path_start, loc);
 
451
    else {
 
452
        city_info_t *cityp = find_city (*path_start);
 
453
        ASSERT (cityp);
 
454
        e_set_city_func (cityp, path_type, loc);
 
455
    }
499
456
 
500
 
        *path_start = -1; /* remember no path in progress */
 
457
    *path_start = -1; /* remember no path in progress */
501
458
}
502
459
 
503
460
/*
505
462
*/
506
463
 
507
464
void
508
 
e_sleep (loc)
509
 
long loc;
 
465
e_sleep(loc_t loc)
510
466
{
511
 
        if (user_map[loc].contents == 'O') huh (); /* can't sleep a city */
512
 
        else e_set_func (loc, SENTRY);
 
467
    if (user_map[loc].contents == 'O') huh (); /* can't sleep a city */
 
468
    else e_set_func (loc, SENTRY);
513
469
}
514
470
 
515
471
/*
517
473
*/
518
474
 
519
475
void
520
 
e_info (edit_cursor)
521
 
long edit_cursor;
 
476
e_info(loc_t edit_cursor)
522
477
{
523
 
        void e_city_info(), e_piece_info();
524
 
 
525
 
        char ab;
526
 
 
527
 
        ab = user_map[edit_cursor].contents;
528
 
 
529
 
        if (ab == 'O') e_city_info (edit_cursor);
530
 
        else if (ab == 'X' && debug) e_city_info (edit_cursor);
531
 
        else if ((ab >= 'A') && (ab <= 'T'))
532
 
                e_piece_info (edit_cursor, ab);
533
 
        else if ((ab >= 'a') && (ab <= 't') && (debug))
534
 
                e_piece_info (edit_cursor, ab);
535
 
        else huh ();
 
478
    void e_city_info(loc_t), e_piece_info(loc_t edit_cursor, char ab);
 
479
 
 
480
    char ab;
 
481
 
 
482
    ab = user_map[edit_cursor].contents;
 
483
 
 
484
    if (ab == 'O')
 
485
        e_city_info (edit_cursor);
 
486
    else if (ab == 'X' && debug)
 
487
        e_city_info (edit_cursor);
 
488
    else if ((ab >= 'A') && (ab <= 'T'))
 
489
        e_piece_info (edit_cursor, ab);
 
490
    else if ((ab >= 'a') && (ab <= 't') && (debug))
 
491
        e_piece_info (edit_cursor, ab);
 
492
    else
 
493
        huh ();
536
494
}
537
495
 
538
496
/*
540
498
*/
541
499
 
542
500
void
543
 
e_piece_info (edit_cursor, ab)
544
 
long edit_cursor;
545
 
char ab;
 
501
e_piece_info(loc_t edit_cursor, char ab)
546
502
{
547
 
        piece_info_t *obj;
548
 
        int type;
549
 
        char *p;
550
 
 
551
 
        ab = upper (ab);
552
 
        p = strchr (type_chars, ab);
553
 
        type = p - type_chars;
554
 
 
555
 
        obj = find_obj (type, edit_cursor);
556
 
        ASSERT (obj != NULL);
557
 
        describe_obj (obj);
 
503
    piece_info_t *obj;
 
504
    int type;
 
505
    char *p;
 
506
 
 
507
    ab = toupper (ab);
 
508
    p = strchr (type_chars, ab);
 
509
    type = p - type_chars;
 
510
 
 
511
    obj = find_obj (type, edit_cursor);
 
512
    ASSERT (obj != NULL);
 
513
    describe_obj (obj);
558
514
}
559
515
 
560
516
/*
562
518
*/
563
519
 
564
520
void
565
 
e_city_info (edit_cursor)
566
 
long edit_cursor;
 
521
e_city_info(loc_t edit_cursor)
567
522
{
568
 
        piece_info_t *obj;
569
 
        city_info_t *cityp;
570
 
        int f, s;
571
 
        char func_buf[STRSIZE];
572
 
        char temp_buf[STRSIZE];
573
 
        char junk_buf2[STRSIZE];
574
 
 
575
 
        error (0,0,0,0,0,0,0,0,0); /* clear line */
576
 
 
577
 
        f = 0; /* no fighters counted yet */
578
 
        for (obj = map[edit_cursor].objp; obj != NULL;
579
 
                obj = obj->loc_link.next)
580
 
                        if (obj->type == FIGHTER) f++;
581
 
 
582
 
        s = 0; /* no ships counted yet */
583
 
        for (obj = map[edit_cursor].objp; obj != NULL;
584
 
                obj = obj->loc_link.next)
585
 
                        if (obj->type >= DESTROYER) s++;
586
 
 
587
 
        if (f == 1 && s == 1) 
588
 
                (void) sprintf (jnkbuf, "1 fighter landed, 1 ship docked");
589
 
        else if (f == 1)
590
 
                (void) sprintf (jnkbuf, "1 fighter landed, %d ships docked", s);
591
 
        else if (s == 1)
592
 
                (void) sprintf (jnkbuf, "%d fighters landed, 1 ship docked", f);
593
 
        else (void) sprintf (jnkbuf, "%d fighters landed, %d ships docked", f, s);
594
 
 
595
 
        cityp = find_city (edit_cursor);
596
 
        ASSERT (cityp != NULL);
597
 
 
598
 
        *func_buf = 0; /* nothing in buffer */
599
 
        for (s = 0; s < NUM_OBJECTS; s++) { /* for each piece */
600
 
                if (cityp->func[s] < 0)
601
 
                        (void) sprintf (temp_buf, "%c:%s; ",
602
 
                                piece_attr[s].sname,
603
 
                                func_name[FUNCI(cityp->func[s])]);
604
 
                else (void) sprintf (temp_buf, "%c: %ld;",
605
 
                                piece_attr[s].sname,
606
 
                                cityp->func[s]);
 
523
    piece_info_t *obj;
 
524
    city_info_t *cityp;
 
525
    int f, s;
 
526
    char func_buf[STRSIZE];
 
527
    char temp_buf[STRSIZE];
 
528
    char junk_buf2[STRSIZE];
 
529
 
 
530
    error (""); /* clear line */
 
531
 
 
532
    f = 0; /* no fighters counted yet */
 
533
    for (obj = map[edit_cursor].objp; obj != NULL;
 
534
         obj = obj->loc_link.next)
 
535
        if (obj->type == FIGHTER) f++;
 
536
 
 
537
    s = 0; /* no ships counted yet */
 
538
    for (obj = map[edit_cursor].objp; obj != NULL;
 
539
         obj = obj->loc_link.next)
 
540
        if (obj->type >= DESTROYER) s++;
 
541
 
 
542
    if (f == 1 && s == 1) 
 
543
        (void) sprintf (jnkbuf, "1 fighter landed, 1 ship docked");
 
544
    else if (f == 1)
 
545
        (void) sprintf (jnkbuf, "1 fighter landed, %d ships docked", s);
 
546
    else if (s == 1)
 
547
        (void) sprintf (jnkbuf, "%d fighters landed, 1 ship docked", f);
 
548
    else
 
549
        (void) sprintf (jnkbuf, "%d fighters landed, %d ships docked", f, s);
 
550
 
 
551
    cityp = find_city (edit_cursor);
 
552
    ASSERT (cityp != NULL);
 
553
 
 
554
    *func_buf = 0; /* nothing in buffer */
 
555
    for (s = 0; s < NUM_OBJECTS; s++) { /* for each piece */
 
556
        if (cityp->func[s] < 0)
 
557
            (void) sprintf (temp_buf, "%c:%s; ",
 
558
                            piece_attr[s].sname,
 
559
                            func_name[FUNCI(cityp->func[s])]);
 
560
        else (void) sprintf (temp_buf, "%c: %d;",
 
561
                             piece_attr[s].sname,
 
562
                             loc_disp(cityp->func[s]));
607
563
                
608
 
                (void) strcat (func_buf, temp_buf);
609
 
        }
610
 
 
611
 
        (void) sprintf (junk_buf2,
612
 
                "City at location %ld will complete %s on round %ld",
613
 
                cityp->loc,
614
 
                piece_attr[(int)cityp->prod].article,
615
 
                date + piece_attr[(int)cityp->prod].build_time - cityp->work);
616
 
 
617
 
        info (junk_buf2, jnkbuf, func_buf);
 
564
        (void) strcat (func_buf, temp_buf);
 
565
    }
 
566
 
 
567
    (void) sprintf (junk_buf2,
 
568
                    "City at location %d will complete %s on round %ld",
 
569
                    loc_disp(cityp->loc),
 
570
                    piece_attr[(int)cityp->prod].article,
 
571
                    date + piece_attr[(int)cityp->prod].build_time - cityp->work);
 
572
 
 
573
    info (junk_buf2, jnkbuf, func_buf);
618
574
}
619
575
 
620
576
/*
622
578
*/
623
579
 
624
580
void
625
 
e_prod (loc)
626
 
long loc;
 
581
e_prod(loc_t loc)
627
582
{
628
 
        city_info_t *cityp;
 
583
    city_info_t *cityp;
629
584
        
630
 
        cityp = find_city (loc);
 
585
    cityp = find_city (loc);
631
586
 
632
 
        if (cityp == NULL) huh (); /* no city? */
633
 
        else set_prod (cityp);
 
587
    if (cityp == NULL) huh (); /* no city? */
 
588
    else set_prod (cityp);
634
589
}
635
590
 
636
591
/*
638
593
*/
639
594
 
640
595
void
641
 
e_help () {
642
 
        help (help_edit, edit_lines);
643
 
        prompt ("Press any key to continue: ",0,0,0,0,0,0,0,0);
644
 
        (void) get_chx ();
 
596
e_help(void)
 
597
{
 
598
    help (help_edit, edit_lines);
 
599
    prompt ("Press any key to continue: ");
 
600
    (void) get_chx ();
645
601
}
 
602
 
 
603
/* end */