Image *img;
if (buffer == NULL)
- buffer = xmalloc(PSBUFSIZE + 4);
+ buffer = (char *)xmalloc(PSBUFSIZE + 4);
if (unit_icon == NULL)
unit_icon = (PsImage *)
xmalloc (numutypes * sizeof(PsImage));
xmalloc (numttypes * sizeof(PsImage));
if (side_icon == NULL)
side_icon = (PsImage *)
- xmalloc (MAXSIDES * sizeof(PsImage));
+ xmalloc ((MAXSIDES + 1) * sizeof(PsImage));
/* pick the images we need */
for_all_unit_types(i) {
unit_icon[i].imf = NULL;
/* first choice */
if (utypes[i].imagename) {
- unit_icon[i].name = utypes[i].imagename;
- unit_icon[i].imf = find_imf(utypes[i].imagename);
+ unit_icon[i].name = get_string(utypes[i].imagename);
+ unit_icon[i].imf = find_imf(get_string(utypes[i].imagename));
}
/* second choice */
if (!unit_icon[i].imf && utypes[i].name) {
}
static void
-ps_initialize_imf(psim)
-PsImage *psim;
+ps_initialize_imf(PsImage *psim)
{
/* checks & cleanup */
if (!psim)
}
static char *
-ps_hex_dump(data, w, h)
-Obj *data;
-int w, h;
+ps_hex_dump(Obj *data, int w, int h)
{
int i, numbytes;
unsigned int u;
numbytes = h * ((w + 7) / 8);
interp_bytes(data, numbytes, buffer, 0);
- c = hexdata = xmalloc(2*numbytes+2);
+ c = hexdata = (char *)xmalloc(2*numbytes+2);
for (i = 0; i < numbytes; ++i) {
u = buffer[i] & 0xff;
sprintf(c, "%2.2x", u);
/* Should use two symbolic constants instead of 8 ? */
static char *
-img_untile(tiled, w, h, istile, dither, scale, gray)
-char *tiled;
-int w, h, istile, dither, scale, gray;
+img_untile(char *tiled, int w, int h, int istile, int dither, int scale, int gray)
{
int dx, dy, x, y, xo, yo, xi, yi, tw, th;
unsigned int u;
'\' to '\\', '(' to '\(', ')' to '\)'. */
static char *
-add_esc_string(str)
-char *str;
+add_esc_string(char *str)
{
char *ps, *pb;
if (escbuf == NULL)
- escbuf = xmalloc(BUFSIZE);
+ escbuf = (char *)xmalloc(BUFSIZE);
for (ps = str, pb = escbuf; *ps && pb < escbuf + BUFSIZE - 2; ps++, pb++) {
if (*ps == '(' || *ps == ')' || *ps == '\\')
*pb++ = '\\';
/* all length are in PostScript units (1/72 in) */
void
-init_ps_print(ipp)
-PrintParameters *ipp;
+init_ps_print(PrintParameters *ipp)
{
double in, cm;
misc_init()
{
if (pp->terrain_dither) {
- terr_gray = GRAY_SCALE*pp->terrain_gray + 0.5;
+ terr_gray = (int)(GRAY_SCALE*pp->terrain_gray + 0.5);
terr_scale = (pp->terrain_double && terr_gray>0 &&
terr_gray<GRAY_SCALE) ? 2 : 1;
} else {
connection_width = pp->connection_width * hex_w/pp->cell_size;
/* rows per page and cells per row */
- height = (pp->page_height - pp->top_margin - pp->bottom_margin)
- * 2 / (sqrt3 * pp->cell_size);
- width = (pp->page_width - pp->left_margin - pp->right_margin)
- / pp->cell_size;
+ height = (int)((pp->page_height - pp->top_margin - pp->bottom_margin)
+ * 2 / (sqrt3 * pp->cell_size));
+ width = (int)((pp->page_width - pp->left_margin - pp->right_margin) / pp->cell_size);
}
/* Write prolog and macro definitions to view file. */
static void
-ps_initialize(fp)
-FILE *fp;
+ps_initialize(FILE *fp)
{
int i;
Image *img;
/* Initialize a page. */
static void
-page_init(fp, page, i, j, stime)
-FILE *fp;
-int page, i, j;
-char *stime;
+page_init(FILE *fp, int page, int i, int j, char *stime)
{
int x, xx, y, y0, nx, ny;
char *gametitle;
}
static int
-nearest_valid_x(x, y)
-int x, y;
+nearest_valid_x(int x, int y)
{
int xlo, xhi;
}
static int
-sideno_of_seen_unit_at(x, y, side)
-int x, y;
-Side *side;
+sideno_of_seen_unit_at(int x, int y, Side *side)
{
Unit *unit;
UnitView *uview;
return side_number(unit->side);
uview = unit_view_at(side, x, y);
if (uview != NULL)
- return view_side(uview)->id;
+ return uview->siden;
return indepside->id;
}
static char *
-name_of_seen_unit_at(x, y, side)
-int x, y;
-Side *side;
+name_of_seen_unit_at(int x, int y, Side *side)
{
Unit *unit;
}
static char *
-summary_of_seen_units_at(x, y, side)
-int x, y;
-Side *side;
+summary_of_seen_units_at(int x, int y, Side *side)
{
Unit *mainunit, *other, *occ;
- int i, nums[MAXUTYPES];
+ int i;
if (!in_area(x, y) || !pp->cell_summary)
return NULL;
return NULL;
for_all_unit_types(i) {
- nums[i] = 0;
+ tmp_u_array[i] = 0;
}
for_all_stack(x, y, other) {
- nums[other->type]++;
+ tmp_u_array[other->type]++;
for_all_occupants(other, occ) {
- nums[occ->type]++;
+ tmp_u_array[occ->type]++;
}
}
- nums[mainunit->type]--;
+ tmp_u_array[mainunit->type]--;
strcpy(buffer, "(+");
for_all_unit_types(i) {
- if (nums[i] != 0) {
- tprintf(buffer, " %d %1s,", nums[i], utype_name_n(i, 1));
+ if (tmp_u_array[i] != 0) {
+ tprintf(buffer, " %d %1s,", tmp_u_array[i], utype_name_n(i, 1));
}
}
i = strlen(buffer);
int f, nf, tw, th, font, named_unit_max=100, xmin, ymin, xmin1;
int l, l1, x1, y1, x2, y2, d1, mvalue, nvalue, pad;
FILE *fp;
- char stime[42], *name, *summary, tmpbuf[BUFSIZE];
+ char stime[42], *name, *summary, tmppsbuf[BUFSIZE];
char *name_layer, *name_position;
time_t tnow;
Legend *legs = NULL, *lp;
- double length, magnif;
+ double dlength, magnif;
if (ipp) {
*pp = *ipp;
nx = min(width, area.width - xmin);
for (xx = xmin; xx < xmin + nx; xx++) {
x = xx - (y + 1) / 2 + x0;
- x = wrapx(x);
-
if ((terrain_seen_at(side, x, y) != NONTTYPE)
|| (utype_seen_at(side, x, y) != NONUTYPE)) {
skip = FALSE;
nx = min(width, area.width - xmin);
nsp = 0;
for (xx = xmin; xx < xmin + nx; xx++) {
- x = xx - (y + 1) / 2 + x0;
- x = wrapx(x);
-
if ((t = terrain_seen_at(side, x, y)) != NONTTYPE) {
if (nsp > 1) {
fprintf(fp, "%d msp ", nsp);
for (xx = xmin; xx < xmin + nx; xx++) {
cx += hex_w;
x = xx - (y + 1) / 2 + x0;
- x = wrapx(x);
if (!in_area(x, y))
continue;
for (xx = xmin; xx < xmin + nx; xx++) {
cx += hex_w;
x = xx - (y + 1) / 2 + x0;
- x = wrapx(x);
if (!in_area(x, y))
continue;
for_all_connection_types(t) {
cy = -hex_h / 2 - hex_c * (area.height - 1 - i * height - lp->oy) +
lp->dy * hex_c / 2;
- length = hex_w * (lp->dist + 1);
- magnif = (1000 * length) / ps_string_width(name, 2);
+ dlength = hex_w * (lp->dist + 1);
+ magnif = (1000 * dlength) / ps_string_width(name, 2);
/* tweak these parameters: */
magnif *= 0.9;
} else {
/* keep magnif near 20 */
font = 2;
- pad = ps_string_width(name, 2)
+ pad = (int)(ps_string_width(name, 2)
* (magnif / 20.0 - 1.0)
- / (strlen(name) * ps_string_width(" ", 2)) + 0.5;
+ / (strlen(name) * ps_string_width(" ", 2)) + 0.5);
name = pad_blanks(name, pad);
magnif =
- (1000 * length) / ps_string_width(name, 2) * 0.9;
+ (1000 * dlength) / ps_string_width(name, 2) * 0.9;
}
/* comment containing debugging info */
x = xx - (y + 1) / 2 + x0;
/* we don't need the string here, so can overwrite */
- name = name_of_seen_unit_at(wrapx(x), y, side);
- summary = summary_of_seen_units_at(wrapx(x), y, side);
+ name = name_of_seen_unit_at(x, y, side);
+ summary = summary_of_seen_units_at(x, y, side);
if (!name && !summary)
continue;
for (l1 = 0; l1 < NUMDIRS; l1++) {
d = name_dir[l1];
point_in_dir(x, y, d, &x1, &y1);
- if ((unit_seen_at(side, wrapx(x1), y1)
+ if ((unit_seen_at(side, x1, y1)
&& on_page(x1 - xmin1, y1 - ymin))
|| (name_at(x1 - xmin1, y1 - ymin) & N_BK))
continue;
mvalue = 0;
for_all_directions(d1) {
point_in_dir(x1, y1, d1, &x2, &y2);
- if ((name_of_seen_unit_at(wrapx(x2), y2, side)
- || summary_of_seen_units_at(wrapx(x2),
- y2, side))
+ if ((name_of_seen_unit_at(x2, y2, side)
+ || summary_of_seen_units_at(x2, y2, side))
&& on_page(x2 - xmin1, y2 - ymin))
mvalue++;
}
name_at(x1 - xmin1, y1 - ymin) |= N_BK;
/* comment containing debugging info */
fprintf(fp, "%% found pos for %s in (%d,%d) at (%d,%d), %s\n",
- name_of_seen_unit_at(wrapx(x), y, side), x, y,
- x1, y1, dirnames[d]);
+ name_of_seen_unit_at(x, y, side), x, y, x1, y1, dirnames[d]);
}
}
}
cx += hex_w;
x = xx - (y + 1) / 2 + x0;
- name = name_of_seen_unit_at(wrapx(x), y, side);
+ name = name_of_seen_unit_at(x, y, side);
/* free buffer */
if (name) {
- strcpy(tmpbuf,name);
- name = tmpbuf;
+ strcpy(tmppsbuf,name);
+ name = tmppsbuf;
}
- summary = summary_of_seen_units_at(wrapx(x), y, side);
+ summary = summary_of_seen_units_at(x, y, side);
if (!name && !summary)
continue;
for (xx = xmin; xx < xmin + nx; xx++) {
cx += hex_w;
x = xx - (y + 1) / 2 + x0;
- x = wrapx(x);
-
name = name_of_seen_unit_at(x, y, side);
/* free buffer */
if (name) {
- strcpy(tmpbuf,name);
- name = tmpbuf;
+ strcpy(tmppsbuf,name);
+ name = tmppsbuf;
}
summary = summary_of_seen_units_at(x, y, side);
if (!name)
for (xx = xmin; xx < xmin + nx; xx++) {
cx += hex_w;
x = xx - (y + 1) / 2 + x0;
- x = wrapx(x);
if (!in_area(x, y))
continue;
"nominal size". */
static int
-ps_string_width(str, font)
-char *str;
-int font;
+ps_string_width(char *str, int font)
{
int ch, i = 0, esc = 0;
}
static int
-print_unit_legends(fp, name, summary, m, dir, cx, cy)
-FILE *fp;
-char *name, *summary, *m;
-int dir, cx, cy;
+print_unit_legends(FILE *fp, char *name, char *summary, char *m, int dir, int cx, int cy)
{
int left, wide_name, wide_summ, down;