From 065be44621cf2bdb6d0bd5ac89693324daf77937 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 22 Aug 2013 23:43:56 -0400 Subject: [PATCH] Limit exposure of the curses API. --- Makefile | 2 +- NEWS | 2 +- compmove.c | 5 ++--- display.c | 10 ++++++++++ empire.c | 3 +-- extern.h | 1 + game.c | 3 +-- usermove.c | 27 +++++++++++++-------------- 8 files changed, 30 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 09f5780..c53dee3 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ VERS=1.10 # Use -g to compile the program for debugging. #DEBUG = -g -DDEBUG -Wall -DEBUG = -O2 +DEBUG = -O2 -Wall # Use -p to profile the program. #PROFILE = -p -DPROFILE diff --git a/NEWS b/NEWS index c5b182e..c5244b2 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ vms-empire news 1.10: - Fix core dump wehen a satellite bounced off the world edge. + Fix core dump when a satellite bounced off the world edge. Full ANSIfication of function prototypes (which fixed the sat bug - the code appeasrs to have been tickling some obscure bug in the compilation of function calls with K&R-style prototypes). diff --git a/compmove.c b/compmove.c index 303fa61..e2b6bcf 100644 --- a/compmove.c +++ b/compmove.c @@ -16,7 +16,6 @@ For each move the user wants us to make, we do the following: */ #include -#include /* Ugh...shouldn't be needed here */ #include #include "empire.h" #include "extern.h" @@ -60,7 +59,7 @@ comp_move(int nmoves) check_endgame (); /* see if game is over */ topini (); - (void) refresh (); + (void) redisplay (); } } @@ -488,7 +487,7 @@ army_move(piece_info_t *obj) loc_t new_loc; path_map_t path_map2[MAP_SIZE]; loc_t new_loc2; - int cross_cost; /* cost to enter water */ + int cross_cost = 0; /* cost to enter water */ obj->func = 0; /* army doesn't want a tt */ if (vmap_at_sea (comp_map, obj->loc)) { /* army can't move? */ diff --git a/display.c b/display.c index 0970c58..5ae63bc 100644 --- a/display.c +++ b/display.c @@ -599,6 +599,16 @@ clear_screen(void) kill_display (); } +/* +Audible complaint. +*/ + +void +complain(void) +{ + (void) beep (); +} + /* Redraw the screen. */ diff --git a/empire.c b/empire.c index ca51828..5c65935 100644 --- a/empire.c +++ b/empire.c @@ -11,7 +11,6 @@ parser, and the simple commands. */ #include -#include /* Ugh...shouldn't be needed here */ #include "empire.h" #include "extern.h" @@ -39,7 +38,7 @@ empire(void) { clear_screen (); /* nothing on screen */ pos_str (7, 0, "EMPIRE, Version 5.00 site Amdahl 1-Apr-1988",0,0,0,0,0,0,0,0); pos_str (8, 0, "Detailed directions are in EMPIRE.DOC\n",0,0,0,0,0,0,0,0); - (void) refresh (); + (void) redisplay (); if (!restore_game ()) /* try to restore previous game */ init_game (); /* otherwise init a new game */ diff --git a/extern.h b/extern.h index 5bea08b..be12308 100644 --- a/extern.h +++ b/extern.h @@ -157,6 +157,7 @@ void init_colors (void); #endif /* A_COLOR */ void redraw (void); void clear_screen (void); +void complain (void); void delay (void); void close_disp (void); void pos_str (int row, int col, char *str, int a, int b, int c, int d, int e, int f, int g, int h); diff --git a/game.c b/game.c index 77ba1b5..30c694a 100644 --- a/game.c +++ b/game.c @@ -13,7 +13,6 @@ game.c -- Routines to initialize, save, and restore a game. #include #include #include -#include /* Ugh...shouldn't be needed here */ #include "empire.h" #include "extern.h" @@ -764,7 +763,7 @@ replay_movie(void) for (c = 0; c < MAP_WIDTH; c += col_inc) print_movie_cell (mapbuf, r, c, row_inc, col_inc); - (void) refresh (); + (void) redisplay (); delay (); } (void) fclose (f); diff --git a/usermove.c b/usermove.c index ec131a9..1f66472 100644 --- a/usermove.c +++ b/usermove.c @@ -12,7 +12,6 @@ usermove.c -- Let the user move her troops. #include #include #include -#include /* Ugh...shouldn't be needed here */ #include "empire.h" #include "extern.h" @@ -88,7 +87,7 @@ user_move(void) { } if (cur_sector () == sec) { /* is sector displayed? */ print_sector_u (sec); /* make screen up-to-date */ - (void) refresh (); /* show it to the user */ + redisplay (); /* show it to the user */ } } if (save_movie) save_movie_screen (); @@ -135,7 +134,7 @@ piece_move(piece_info_t *obj) ask_user (obj); topini (); /* clear info lines */ display_loc_u (obj->loc); /* let user see result */ - (void) refresh (); + (void) redisplay (); need_input = FALSE; /* we got it */ } @@ -553,7 +552,7 @@ void ask_user(piece_info_t *obj) case 'P': user_redraw (); break; case '?': describe_obj (obj); break; - default: (void) beep (); + default: complain (); } } } @@ -601,7 +600,7 @@ or carrier. If not, we beep at the user. void user_fill(piece_info_t *obj) { - if (obj->type != TRANSPORT && obj->type != CARRIER) (void) beep (); + if (obj->type != TRANSPORT && obj->type != CARRIER) complain (); else obj->func = FILL; } @@ -638,7 +637,7 @@ user_set_dir(piece_info_t *obj) case 'X': obj->func = MOVE_S ; break; case 'Z': obj->func = MOVE_SW; break; case 'A': obj->func = MOVE_W ; break; - default: (void) beep (); break; + default: complain (); break; } } @@ -679,7 +678,7 @@ Set a fighter's function to land at the nearest city. void user_land(piece_info_t *obj) { - if (obj->type != FIGHTER) (void) beep (); + if (obj->type != FIGHTER) complain (); else obj->func = LAND; } @@ -700,7 +699,7 @@ Set an army's function to WFTRANSPORT. void user_transport(piece_info_t *obj) { - if (obj->type != ARMY) (void) beep (); + if (obj->type != ARMY) complain (); else obj->func = WFTRANSPORT; } @@ -711,7 +710,7 @@ Set an army's function to ARMYATTACK. void user_armyattack(piece_info_t *obj) { - if (obj->type != ARMY) (void) beep (); + if (obj->type != ARMY) complain (); else obj->func = ARMYATTACK; } @@ -722,7 +721,7 @@ Set a ship's function to REPAIR. void user_repair(piece_info_t *obj) { - if (obj->type == ARMY || obj->type == FIGHTER) (void) beep (); + if (obj->type == ARMY || obj->type == FIGHTER) complain (); else obj->func = REPAIR; } @@ -743,13 +742,13 @@ user_set_city_func(piece_info_t *obj) cityp = find_city (obj->loc); if (!cityp || cityp->owner != USER) { - (void) beep (); + complain (); return; } type = get_piece_name(); if (type == NOPIECE) { - (void) beep (); + complain (); return; } @@ -778,7 +777,7 @@ user_set_city_func(piece_info_t *obj) e_city_attack (cityp, type); break; default: /* bad command? */ - (void) beep (); + complain (); break; } } @@ -793,7 +792,7 @@ user_build(piece_info_t *obj) city_info_t *cityp; if (user_map[obj->loc].contents != 'O') { /* no user city here? */ - (void) beep (); + complain (); return; } cityp = find_city (obj->loc); -- 2.43.0