characters.
FIXME conditional compilation is a last resort
-FIXME s_char
-
Robustness
----------
#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 */
#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 */
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;
int size;
int nbytes;
int offset;
- s_char *data;
+ char *data;
};
struct ioqueue {
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? */
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 */
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 */
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
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 */
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];
};
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 */
};
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 */
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 */
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 */
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 */
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 */
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);
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 */
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 */
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
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 */
};
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) */
int nsect;
int n;
struct nstr_sect nstr;
- s_char dirstr[20];
+ char dirstr[20];
if (!snxtsct(&nstr, player->argp[1]))
return RET_SYN;
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 */
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') {
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;
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;
{
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? ");
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;
}
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;
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)
#if !defined(_WIN32)
struct iovec iov[16];
#else
- s_char buf[IO_BUFSIZE];
+ char buf[IO_BUFSIZE];
#endif
int cc;
int n;
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;
{
struct io *io;
int len;
- s_char *ptr;
+ char *ptr;
int avail;
/* determine if any space is left */
int nbytes;
int nleft;
int ncopied;
- s_char *offset;
+ char *offset;
ncopied = 0;
nleft = nBufLen;
int eff;
struct shpstr ship;
struct lndstr land;
- /* s_char *sprintf(); already in misc.h [JFW] */
natid plane_owner;
disp = 0;
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,
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);
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);
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))
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;
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)
* 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;
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;
int nowhere_to_go = 0;
struct sctstr rsect;
double mobcost;
- s_char orig;
+ signed char orig;
int mob;
taken = lnd_getmil(&llp->land);
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!",
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
int
mission_pln_equip(struct plist *plp, struct ichrstr *ip, int flags,
- s_char mission)
+ char mission)
{
struct plchrstr *pcp;
struct plnstr *pp;
#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.
}
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;
/* 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;
* 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,
}
}
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];
int n;
int changed = 0;
long crackle;
- s_char noise[100];
+ signed char noise[100];
char selection[1024];
if (!eff)
int shell, gun;
int dam;
int totdam = 0;
- s_char notified[MAXNOC];
+ signed char notified[MAXNOC];
int i;
/* Inform neutral and worse */
}
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 = ' ';
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);
}
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))
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++;
# 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
}
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);