(s_char): Remove. Use signed char for small integers, plain char for

characters.
This commit is contained in:
Markus Armbruster 2006-04-29 16:25:17 +00:00
parent 0a3a73cf3d
commit 0c8c169f88
41 changed files with 86 additions and 100 deletions

View file

@ -334,8 +334,6 @@ FIXME reserved names
FIXME conditional compilation is a last resort
FIXME s_char
Robustness
----------

View file

@ -35,7 +35,7 @@
#define COMMON_H
#include <stdio.h> /* FILE */
#include "misc.h" /* s_char coord natid */
#include "misc.h"
#include "sect.h" /* struct sctstr */
#include "ship.h" /* struct shpstr */
#include "land.h" /* struct lndstr */

View file

@ -35,7 +35,7 @@
#define GEN_H
#include <stdlib.h> /* atoi etc. */
#include "misc.h" /* s_char etc */
#include "misc.h"
#include "xy.h" /* struct range */
#include "prototypes.h" /* must come at end, after defines and typedefs */

View file

@ -47,11 +47,11 @@ struct genitem {
short uid;
coord x;
coord y;
s_char type;
s_char effic;
s_char mobil;
signed char type;
signed char effic;
signed char mobil;
short tech;
s_char group;
char group;
coord opx, opy;
short mission;
short radius;

View file

@ -39,7 +39,7 @@ struct io {
int size;
int nbytes;
int offset;
s_char *data;
char *data;
};
struct ioqueue {

View file

@ -54,18 +54,18 @@ struct lndstr {
short lnd_uid; /* unit id (land unit) */
coord lnd_x; /* x location in abs coords */
coord lnd_y; /* y location in abs coords */
s_char lnd_type; /* index in lchr[] */
s_char lnd_effic; /* 0% to 100% */
s_char lnd_mobil; /* mobility units made int for RS/6000 */
signed char lnd_type; /* index in lchr[] */
signed char lnd_effic; /* 0% to 100% */
signed char lnd_mobil; /* mobility units */
short lnd_tech; /* tech level ship was built at */
s_char lnd_army; /* group membership */
char lnd_army; /* group membership */
coord lnd_opx, lnd_opy; /* Op sector coords */
short lnd_mission; /* mission code */
short lnd_radius; /* mission radius */
/* end of part matching struct genitem */
s_char lnd_flags; /* unit flags (unused) */
signed char lnd_flags; /* unit flags (unused) */
short lnd_ship; /* pointer to transporting ship */
s_char lnd_harden; /* for missiles */
signed char lnd_harden; /* fortification */
short lnd_retreat; /* retreat percentage */
unsigned char lnd_fuel; /* How much fuel do we have */
unsigned char lnd_nxlight; /* How many xlight planes on board? */

View file

@ -42,7 +42,7 @@ struct lonstr {
natid l_loner; /* loan shark */
short l_uid;
natid l_lonee; /* sucker */
s_char l_status; /* loan status */
signed char l_status; /* loan status */
short l_sell; /* pointer to trade file (unused) */
int l_irate; /* interest rate */
int l_ldur; /* intended duration */

View file

@ -41,7 +41,7 @@
extern void blankfill(char *, struct range *, int);
/* src/lib/subs/border.c */
extern int map_set(natid, coord, coord, s_char, int);
extern int map_set(natid, coord, coord, char, int);
extern void writebmap(natid);
extern void writemap(natid);
/* src/lib/subs/border.c */

View file

@ -87,16 +87,6 @@ struct mob_acc_globals {
typedef unsigned char natid; /* NSC_NATID must match this */
/*
* TODO s_char has to go. Use plain char for characters and strings,
* signed char for small integers.
*/
#ifdef __CHAR_UNSIGNED__
typedef signed char s_char;
#else
typedef char s_char;
#endif
typedef short coord;
#ifndef bit

View file

@ -98,8 +98,8 @@ struct natstr {
char nat_userid[32]; /* userid of last user, may be empty */
coord nat_xcap, nat_ycap; /* cap location in abs coords */
coord nat_xorg, nat_yorg; /* origin location in abs coords */
s_char nat_dayno; /* day of the year mod 128 */
s_char nat_update; /* Want an update or not. */
signed char nat_dayno; /* day of the year mod 128 */
signed char nat_update; /* Want an update or not. */
unsigned char nat_missed; /* How many updates missed */
unsigned short nat_tgms; /* # of telegrams to be announced */
unsigned short nat_ann; /* # of annos pending */
@ -115,7 +115,7 @@ struct natstr {
short nat_relate[MAXNOC];
unsigned char nat_contact[MAXNOC];
short nat_rejects[(MAXNOC + 3) / 4]; /* four bits for each country */
s_char nat_priorities[PRI_MAX+1]; /* budget priority */
signed char nat_priorities[PRI_MAX+1]; /* budget priority */
long nat_flags; /* nation flags */
char nat_spare[15];
};

View file

@ -47,9 +47,9 @@ struct nwsstr {
short ef_type;
natid nws_ano; /* "actor" country # */
short nws_uid; /* unused */
s_char nws_vrb; /* action (verb) */
signed char nws_vrb; /* action (verb) */
natid nws_vno; /* "victim" country # */
s_char nws_ntm; /* number of times */
signed char nws_ntm; /* number of times */
time_t nws_when; /* time of action */
};

View file

@ -45,7 +45,7 @@ struct nukstr {
coord nuk_x; /* current loc of device */
coord nuk_y;
/* end of part matching struct genitem */
s_char nuk_n; /* number of nukes in list */
signed char nuk_n; /* number of nukes in list */
short nuk_ship; /* currently aboard ship (unused) */
short nuk_trade; /* index into trade file (unused) */
short nuk_types[N_MAXNUKE]; /* # of nukes in sector of given type */

View file

@ -53,11 +53,11 @@ struct plnstr {
short pln_uid; /* plane unit id */
coord pln_x; /* plane x-y */
coord pln_y;
s_char pln_type; /* index in plchr[] */
s_char pln_effic; /* actually "training" */
s_char pln_mobil; /* plane mobility */
signed char pln_type; /* index in plchr[] */
signed char pln_effic; /* actually "training" */
signed char pln_mobil; /* plane mobility */
short pln_tech; /* plane's tech level */
s_char pln_wing; /* like fleet */
char pln_wing; /* like fleet */
coord pln_opx; /* Op sector coords */
coord pln_opy; /* Op sector coords */
short pln_mission; /* mission code */
@ -72,9 +72,9 @@ struct plnstr {
int pln_acc;
int pln_load;
int pln_fuel; /* (unused) */
s_char pln_harden; /* for missiles */
s_char pln_nuketype; /* type of nuclear armament (if any) */
s_char pln_flags; /* State of the plane */
signed char pln_harden; /* for missiles */
signed char pln_nuketype; /* type of nuclear armament (if any) */
signed char pln_flags; /* State of the plane */
time_t pln_access; /* Last time mob was updated (MOB_ACCESS) */
time_t pln_timestamp; /* Last time this plane was touched */
float pln_theta; /* position in orbital sine wave */

View file

@ -309,8 +309,8 @@ extern void loginit(char *);
extern void logerror(char *, ...) ATTRIBUTE((format (printf, 1, 2)));
/* more in misc.h */
/* maps.c */
extern int draw_map(int, s_char, int, struct nstr_sect *);
extern int unit_map(int, int, struct nstr_sect *, s_char *);
extern int draw_map(int, char, int, struct nstr_sect *);
extern int unit_map(int, int, struct nstr_sect *, char *);
extern int bmaps_intersect(natid, natid);
extern int share_bmap(natid, natid, struct nstr_sect *, char, char *);
/* move.c */
@ -340,7 +340,7 @@ extern void snxtitem_area(struct nstr_item *, int,
extern void snxtitem_dist(struct nstr_item *, int, int, int, int);
extern void snxtitem_xy(struct nstr_item *, int, coord, coord);
extern void snxtitem_all(struct nstr_item *, int);
extern void snxtitem_group(struct nstr_item *, int, s_char);
extern void snxtitem_group(struct nstr_item *, int, char);
extern void snxtitem_rewind(struct nstr_item *);
extern int snxtitem_list(struct nstr_item *, int, int *, int);
/* snxtsect_subs.c */
@ -510,8 +510,7 @@ extern int islist(char *);
extern char *mission_name(short);
extern char *nameofitem(struct genitem *, int);
extern int collateral_damage(coord, coord, int, struct emp_qelem *);
extern int mission_pln_equip(struct plist *, struct ichrstr *, int,
s_char);
extern int mission_pln_equip(struct plist *, struct ichrstr *, int, char);
extern int ground_interdict(coord, coord, natid, char *);
extern int unit_interdict(coord, coord, natid, char *, int, int);
extern int off_support(coord, coord, natid, natid);
@ -589,7 +588,7 @@ extern void count_land_planes(struct lndstr *);
extern int count_sect_planes(struct sctstr *);
extern int put_plane_on_land(struct plnstr *, struct lndstr *);
extern int pln_hitchance(struct plnstr *, int, int);
extern int pln_damage(struct plnstr *, coord, coord, s_char, int *, int);
extern int pln_damage(struct plnstr *, coord, coord, char, int *, int);
extern int pln_identchance(struct plnstr *, int, int);
extern void pln_set_tech(struct plnstr *, int);
/* pr.c */

View file

@ -66,11 +66,11 @@ struct shpstr {
short shp_uid; /* unit id (ship #) */
coord shp_x; /* x location in abs coords */
coord shp_y; /* y location in abs coords */
s_char shp_type; /* index in mchr[] */
s_char shp_effic; /* 0% to 100% */
s_char shp_mobil; /* mobility units */
signed char shp_type; /* index in mchr[] */
signed char shp_effic; /* 0% to 100% */
signed char shp_mobil; /* mobility units */
short shp_tech; /* tech level ship was built at */
s_char shp_fleet; /* group membership */
char shp_fleet; /* group membership */
coord shp_opx, shp_opy; /* Op sector coords */
short shp_mission; /* mission code */
short shp_radius; /* mission radius */
@ -117,7 +117,7 @@ struct fltelemstr {
struct fltheadstr {
int leader;
s_char real_q;
signed char real_q;
/* defines for the real_q member */
#define LEADER_VIRTUAL 0
#define LEADER_REAL 1

View file

@ -46,7 +46,7 @@
struct telstr {
natid tel_from; /* sender */
s_char tel_type;
signed char tel_type;
long tel_length; /* how long */
time_t tel_date; /* when sent */
};

View file

@ -39,8 +39,8 @@ struct trtstr {
natid trt_cna; /* proposer */
short trt_uid;
natid trt_cnb; /* acceptor */
s_char trt_status; /* treaty status */
s_char trt_fill;
signed char trt_status; /* treaty status */
char trt_fill;
short trt_acond; /* conditions for proposer */
short trt_bcond; /* conditions for accepter */
float trt_bond; /* amount of bond involved (unused) */

View file

@ -47,7 +47,7 @@ cens(void)
int nsect;
int n;
struct nstr_sect nstr;
s_char dirstr[20];
char dirstr[20];
if (!snxtsct(&nstr, player->argp[1]))
return RET_SYN;

View file

@ -56,7 +56,7 @@ struct ltcomstr {
natid proposer; /* country offering */
natid proposee; /* country offered to */
natid mailee; /* who gets mail about it */
s_char op; /* 'a', 'd', or 'p' */
char op; /* 'a', 'd', or 'p' */
union {
struct lonstr l; /* the loan */
struct trtstr t; /* the treaty */

View file

@ -53,7 +53,7 @@ map(void)
int unit_type = 0;
int bmap = 0;
struct nstr_sect ns;
s_char origin = '\0';
char origin = '\0';
int map_flags = 0;
if (**player->argp != 'm') {

View file

@ -57,7 +57,7 @@ march(void)
char *cp = 0;
struct lndstr *lnd = 0; /* leader */
struct nstr_sect ns;
s_char origin;
char origin;
int dir;
int stopping = 0;
int skip = 0;

View file

@ -59,7 +59,7 @@ navi(void)
char *cp = 0;
struct shpstr *shp = 0; /* flagship */
struct nstr_sect ns;
s_char origin;
char origin;
int dir;
int stopping = 0;
int skip = 0;

View file

@ -45,7 +45,7 @@ shar(void)
{
int to;
struct nstr_sect ns;
s_char des = 0;
char des = 0;
int n;
to = natarg(player->argp[1], "Share bmap with which country? ");

View file

@ -54,7 +54,7 @@ static int bmnxtsct(struct nstr_sect *);
static char map_char(unsigned char type, natid own, int owner_or_god);
int
draw_map(int bmap, s_char origin, int map_flags, struct nstr_sect *nsp)
draw_map(int bmap, char origin, int map_flags, struct nstr_sect *nsp)
{
struct natstr *np;
struct range range;
@ -302,7 +302,7 @@ map_char(unsigned char type, natid own, int owner_or_god)
}
int
unit_map(int unit_type, int uid, struct nstr_sect *nsp, s_char *originp)
unit_map(int unit_type, int uid, struct nstr_sect *nsp, char *originp)
{
struct shpstr origs;
struct lndstr origl;
@ -339,8 +339,8 @@ unit_map(int unit_type, int uid, struct nstr_sect *nsp, s_char *originp)
int
bmaps_intersect(natid a, natid b)
{
s_char *mapa = ef_ptr(EF_MAP, a);
s_char *mapb = ef_ptr(EF_MAP, b);
char *mapa = ef_ptr(EF_MAP, a);
char *mapb = ef_ptr(EF_MAP, b);
int i;
for (i = 0; i < WORLD_X * WORLD_Y / 2; ++i, ++mapa, ++mapb)

View file

@ -194,7 +194,7 @@ io_output(struct iop *iop, int waitforoutput)
#if !defined(_WIN32)
struct iovec iov[16];
#else
s_char buf[IO_BUFSIZE];
char buf[IO_BUFSIZE];
#endif
int cc;
int n;

View file

@ -225,9 +225,9 @@ ioqtobuf(struct ioqueue *ioq, char *buf, int cc)
static int
ioqtocbuf(struct ioqueue *ioq, char *buf, int cc, register int stopc)
{
register int nbytes;
register s_char *p;
register int n;
int nbytes;
char *p;
int n;
struct io *io;
struct emp_qelem *qp;
struct emp_qelem *head;
@ -298,7 +298,7 @@ appendcc(struct ioqueue *ioq, char *buf, int cc)
{
struct io *io;
int len;
s_char *ptr;
char *ptr;
int avail;
/* determine if any space is left */
@ -389,7 +389,7 @@ ioq_makebuf(struct ioqueue *ioq, char *pBuf, int nBufLen)
int nbytes;
int nleft;
int ncopied;
s_char *offset;
char *offset;
ncopied = 0;
nleft = nBufLen;

View file

@ -702,7 +702,6 @@ ac_planedamage(struct plist *plp, natid from, int dam, natid other,
int eff;
struct shpstr ship;
struct lndstr land;
/* s_char *sprintf(); already in misc.h [JFW] */
natid plane_owner;
disp = 0;

View file

@ -58,7 +58,7 @@
static void ask_olist(int combat_mode, struct combat *off,
struct combat *def, struct emp_qelem *olist,
s_char *land_answer, int *a_spyp, int *a_engineerp);
char *land_answer, int *a_spyp, int *a_engineerp);
static void take_move_in_mob(int combat_mode, struct llist *llp,
struct combat *off, struct combat *def);
static void move_in_land(int combat_mode, struct combat *off,
@ -382,7 +382,7 @@ put_combat(struct combat *com)
if (com->mob - com->mobcost < -127)
land.lnd_mobil = -127;
else
land.lnd_mobil = (s_char)(com->mob - com->mobcost);
land.lnd_mobil = (signed char)(com->mob - com->mobcost);
}
makelost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
land.lnd_y);
@ -410,7 +410,7 @@ put_combat(struct combat *com)
if (com->mob - com->mobcost < -127)
ship.shp_mobil = -127;
else
ship.shp_mobil = (s_char)(com->mob - com->mobcost);
ship.shp_mobil = (signed char)(com->mob - com->mobcost);
}
makelost(EF_SHIP, ship.shp_own, ship.shp_uid, ship.shp_x,
ship.shp_y);
@ -766,7 +766,7 @@ att_ask_offense(int combat_mode, struct combat *off, struct combat *def,
struct emp_qelem *olist, int *a_spyp, int *a_engineerp)
{
int n;
s_char land_answer[1024];
char land_answer[1024];
emp_initque(olist);
if (att_abort(combat_mode, off, def))
@ -947,7 +947,7 @@ att_prompt(char *prompt, char army)
static void
ask_olist(int combat_mode, struct combat *off, struct combat *def,
struct emp_qelem *olist, s_char *land_answer, int *a_spyp,
struct emp_qelem *olist, char *land_answer, int *a_spyp,
int *a_engineerp)
{
struct nstr_item ni;
@ -2283,8 +2283,8 @@ ask_move_in(struct combat *off, struct emp_qelem *olist,
struct llist *llp;
char buf[512];
char prompt[512];
s_char land_answer[1024];
s_char *answerp;
char land_answer[1024];
char *answerp;
for (n = 0; n <= off->last; ++n)
if (off[n].type != EF_BAD && off[n].troops > 0)

View file

@ -45,10 +45,10 @@
* 2 = update only bmap with force
*/
static int do_map_set(s_char *map, coord x, coord y, s_char t, int force);
static int do_map_set(char *map, coord x, coord y, char t, int force);
int
map_set(natid cnum, coord x, coord y, s_char t, int only_bmap)
map_set(natid cnum, coord x, coord y, char t, int only_bmap)
{
int set = 0;
@ -63,10 +63,10 @@ map_set(natid cnum, coord x, coord y, s_char t, int only_bmap)
static int
do_map_set(s_char *map, coord x, coord y, s_char t, int force)
do_map_set(char *map, coord x, coord y, char t, int force)
{
int id;
s_char ot;
char ot;
if ((id = sctoff(x, y)) < 0)
return 0;

View file

@ -187,7 +187,7 @@ lnd_take_casualty(int combat_mode, struct llist *llp, int cas)
int nowhere_to_go = 0;
struct sctstr rsect;
double mobcost;
s_char orig;
signed char orig;
int mob;
taken = lnd_getmil(&llp->land);
@ -272,7 +272,7 @@ lnd_take_casualty(int combat_mode, struct llist *llp, int cas)
if (mob < -127)
mob = -127;
orig = llp->land.lnd_mobil;
llp->land.lnd_mobil = (s_char)mob;
llp->land.lnd_mobil = (signed char)mob;
if (llp->land.lnd_mobil > orig)
llp->land.lnd_mobil = -127;
sprintf(buf, "retreats at %d%% efficiency to %s!",
@ -326,7 +326,7 @@ lnd_takemob(struct emp_qelem *list, double loss)
new = llp->land.lnd_mobil - mcost;
if (new < -127)
new = -127;
llp->land.lnd_mobil = (s_char)new;
llp->land.lnd_mobil = (signed char)new;
}
}
int

View file

@ -1219,7 +1219,7 @@ mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
int
mission_pln_equip(struct plist *plp, struct ichrstr *ip, int flags,
s_char mission)
char mission)
{
struct plchrstr *pcp;
struct plnstr *pp;

View file

@ -52,7 +52,7 @@
#include "prototypes.h"
#include "optlist.h"
static int pln_equip(struct plist *, struct ichrstr *, int, s_char);
static int pln_equip(struct plist *, struct ichrstr *, int, char);
/*
* Get assembly point argument.
@ -605,7 +605,7 @@ pln_arm(struct emp_qelem *list, int dist, int mission, struct ichrstr *ip,
}
static int
pln_equip(struct plist *plp, struct ichrstr *ip, int flags, s_char mission)
pln_equip(struct plist *plp, struct ichrstr *ip, int flags, char mission)
{
struct plchrstr *pcp;
struct plnstr *pp;
@ -1159,7 +1159,7 @@ pln_hitchance(struct plnstr *pp, int hardtarget, int type)
/* return 0 if there was a nuclear detonation */
int
pln_damage(struct plnstr *pp, coord x, coord y, s_char type, int *nukedamp,
pln_damage(struct plnstr *pp, coord x, coord y, char type, int *nukedamp,
int noisy)
{
struct plchrstr *pcp = plchr + pp->pln_type;

View file

@ -70,8 +70,8 @@ radmapupd(int own, int cx, int cy, int eff, int range, double seesub)
* want to do this in other places too where it doesn't matter. */
static char **rad;
static char *radbuf;
static s_char **vis;
static s_char *visbuf;
static signed char **vis;
static signed char *visbuf;
static void
radmap2(int owner,
@ -100,7 +100,7 @@ radmap2(int owner,
}
}
if (!vis) {
vis = malloc(WORLD_Y * sizeof(s_char *));
vis = malloc(WORLD_Y * sizeof(signed char *));
if (vis && visbuf) {
for (x = 0; x < WORLD_Y; x++)
vis[x] = &visbuf[(WORLD_X + 1) * x];

View file

@ -64,7 +64,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
int n;
int changed = 0;
long crackle;
s_char noise[100];
signed char noise[100];
char selection[1024];
if (!eff)

View file

@ -636,7 +636,7 @@ shp_fort_interdiction(struct emp_qelem *list, coord newx, coord newy,
int shell, gun;
int dam;
int totdam = 0;
s_char notified[MAXNOC];
signed char notified[MAXNOC];
int i;
/* Inform neutral and worse */

View file

@ -192,7 +192,7 @@ snxtitem_all(struct nstr_item *np, int type)
}
void
snxtitem_group(struct nstr_item *np, int type, s_char group)
snxtitem_group(struct nstr_item *np, int type, char group)
{
if (group == '~')
group = ' ';

View file

@ -340,7 +340,7 @@ landrepair(struct lndstr *land, struct natstr *np,
logerror("land unit %d building %d ! \n", land->lnd_uid, build);
np->nat_money -= mult * lp->l_cost * build / 100.0;
if (!player->simulation) {
land->lnd_effic += (s_char)build;
land->lnd_effic += (signed char)build;
putsect(sp);
}

View file

@ -310,7 +310,7 @@ do_mob_ship(struct shpstr *sp, int etus)
value = sp->shp_mobil + ((float)etus * ship_mob_scale);
if (value > ship_mob_max)
value = ship_mob_max;
sp->shp_mobil = (s_char)value;
sp->shp_mobil = (signed char)value;
} else {
can_add = ship_mob_max - sp->shp_mobil;
if (can_add > ((float)etus * ship_mob_scale))

View file

@ -257,7 +257,7 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
air_money[pp->pln_own] += np->nat_money - start_money;
if (!player->simulation)
pp->pln_effic += (s_char)build;
pp->pln_effic += (signed char)build;
else
np->nat_money = start_money;
k++;

View file

@ -2,7 +2,7 @@
# indent needs to know type names do to a proper job.
# Type names located with grep typedef, then extracted by hand:
types="coord empth_sem_t empth_t i_packing i_type loc_Sem_t loc_Thread_t natid ns_seltype nsc_cat nsc_flags nsc_type packed_nsc_cat packed_nsc_type s_char stkalign_t"
types="coord empth_sem_t empth_t i_packing i_type loc_Sem_t loc_Thread_t natid ns_seltype nsc_cat nsc_flags nsc_type packed_nsc_cat packed_nsc_type stkalign_t"
opts="-kr -cdw -cp8 -ncs -psl -ss"
for t in $types

View file

@ -159,7 +159,7 @@ update_wait(void *unused)
}
stacksize = 100000 +
/* finish_sects */ WORLD_X * WORLD_Y * (2 * sizeof(double) +
sizeof(s_char *));
sizeof(char *));
empth_create(PP_UPDATE, update_main, stacksize, 0,
"UpdateRun", "Updates the world", dp);