00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if (defined (__cplusplus) || defined (__MWERKS__))
00012 #define BMAP_BYTE char
00013 #else
00014 #define BMAP_BYTE unsigned char
00015 #endif
00016
00017 #define NUMPOWERS 8
00018
00019
00020 #define XFORM_UVIEW_LEGACY 0
00021 #define XFORM_UVIEW_PILES 1
00022 #define XFORM_UVIEW_ELLIPSIS 2
00023 #define XFORM_UVIEW_AS_TSPT 4
00024 #define XFORM_UVIEW_AS_OCC 8
00025 #define XFORM_UVIEW_DONT_PILE_ACP 16
00026 #define XFORM_UVIEW_DONT_PILE_HP 32
00027 #define XFORM_UVIEW_DONT_PILE_CP 64
00028 #define XFORM_UVIEW_DONT_PILE_OCC 128
00029 #define XFORM_UVIEW_DONT_DRAW (1 << 31)
00031
00032
00033 enum whattouse {
00034 dontdraw,
00035 useblocks,
00036 usepolygons,
00037 usepictures
00038 };
00039
00040 typedef struct a_vp {
00041 int sx, sy;
00042 int totsw, totsh;
00043 int sxmin, symin;
00044 int sxmax, symax;
00045 short pxw, pxh;
00046 short power;
00047 short mag;
00048 short vcx, vcy;
00049 short hw, hh;
00050 short hch;
00051 short uw, uh;
00052 short angle;
00053 int cellwidth;
00054 short vertscale;
00055 short isometric;
00056 short isodir;
00057 short scroll_beyond_dateline;
00058
00059
00060 short show_all;
00061
00062
00063
00064 short draw_terrain;
00065 short *draw_aux_terrain;
00066 short draw_grid;
00067 short draw_cell_pats;
00068 short draw_other_maps;
00069 short draw_units;
00070 short draw_names;
00071 short oldest_to_show;
00072 short age_to_fade;
00073 short draw_people;
00074 short draw_control;
00075 short draw_elevations;
00076 short num_contours;
00077 short contour_interval;
00078 short contour_interval_fixed;
00079 struct a_line_segment *linebuf;
00080 short *draw_materials;
00081 short num_materials_to_draw;
00082 short draw_lighting;
00083 short draw_temperature;
00084 short draw_winds;
00085 short draw_clouds;
00086 short draw_storms;
00087 short draw_plans;
00088 short draw_cover;
00089 short draw_feature_boundaries;
00090 short draw_shorelines;
00091 short draw_feature_names;
00092 short draw_meridians;
00093 short meridian_interval;
00094 short lat_label_lon_interval;
00095 short lon_label_lat_interval;
00096 short draw_ai;
00097 short draw_occupants;
00098 } VP;
00099
00100 typedef struct a_legend {
00101 int ox, oy;
00102 int dx, dy;
00103 float angle, dist;
00104 } Legend;
00105
00106 typedef struct a_line_segment {
00107 int sx1, sy1, sx2, sy2;
00108 } LineSegment;
00109
00110 #define REDRAW_CHAR '\001'
00111 #define ESCAPE_CHAR '\033'
00112
00113 #ifdef MAC_TCL
00114 #define BACKSPACE_CHAR 0x7B
00115 #define DELETE_CHAR 0x7B
00116 #else
00117 #define BACKSPACE_CHAR '\010'
00118 #define DELETE_CHAR 0x7f
00119 #endif
00120
00121 #define m_terrain_visible(vp, x, y) \
00122 ((vp)->show_all || terrain_visible(dside, (x), (y)))
00123
00124 #define m_seen_border(vp, x, y, b) \
00125 ((vp)->show_all || seen_border(dside, (x), (y), (b)))
00126
00127
00128
00129 #define cell_style(vp, x, y) \
00130 ((m_terrain_visible(vp, x, y) || unseen_image != NULL || !in_area(x, y)) \
00131 ? (vp->power >= 3 ? usepolygons : useblocks) \
00132 : dontdraw);
00133
00134 #define cell_overlay(vp, x, y) \
00135 ((dside->designer && !(vp)->show_all) \
00136 ? ((terrain_view(dside, x, y) == UNSEEN) ? -2 : 0) \
00137 : (!dside->see_all && (vp)->draw_cover \
00138 ? (cover(dside, x, y) == 0 \
00139 ? -1 \
00140 : ((vp)->draw_lighting ? (night_at(x, y) ? -2 : 0) : 0)) \
00141 : ((vp)->draw_lighting \
00142 ? (night_at(x, y) ? -2 : 0) \
00143 : 0)))
00144
00145 #define cell_terrain(vp, x, y) \
00146 ((!in_area(x, y)) ? BACKTTYPE : \
00147 (((vp)->show_all || dside->designer) \
00148 ? terrain_at(x, y) \
00149 : (m_terrain_visible(vp, x, y) \
00150 ? vterrain(terrain_view(dside, x, y)) \
00151 : NONTTYPE)))
00152
00153 extern Side *dside;
00154
00155 extern short mags[], hws[], hhs[], hcs[], halfsides[], uws[], uhs[];
00156
00157 extern short iws[], ihs[], ics[], ix1[], ix2[];
00158
00159 extern short bwid[], bwid2[], cwid[];
00160
00161 extern short bsx[NUMPOWERS][7], bsy[NUMPOWERS][7];
00162 extern short lsx[NUMPOWERS][6], lsy[NUMPOWERS][6];
00163
00164 extern short ibsx[NUMPOWERS][7], ibsy[NUMPOWERS][7];
00165 extern short ilsx[NUMPOWERS][6], ilsy[NUMPOWERS][6];
00166
00167 extern short qx[NUMPOWERS][7], qy[NUMPOWERS][7];
00168
00169 extern char *dirchars;
00170
00171
00172
00173
00174
00175 extern int min_w_for_unit_image;
00176 extern int min_h_for_unit_image;
00177
00178 extern int *numuimages;
00179
00180 extern ImageFamily **uimages;
00181 extern ImageFamily *unseen_image;
00182 extern ImageFamily *generic_transition;
00183 extern ImageFamily *generic_fuzz;
00184
00185 extern char *terrchars;
00186 extern char *unitchars;
00187 extern char unseen_char_1, unseen_char_2;
00188
00189 extern Module **possible_games;
00190
00191 extern int numgames;
00192
00193 extern void (*imf_describe_hook)(Side *side, Image *img);
00194
00195 extern int big_unit_images;
00196
00197
00198
00199 extern void collect_possible_games(void);
00200 extern void add_to_possible_games(Module *module);
00201
00202 extern VP *new_vp(void);
00203
00204 extern void xform_cell(VP *vp, int x, int y, int *sxp, int *syp);
00205 extern void xform_cell_top(VP *vp, int x, int y, int *sxp, int *syp);
00206 extern void xform_cell_fractional(VP *vp, int x, int y, int xf, int yf,
00207 int *sxp, int *syp);
00208 extern void xform_unit(VP *vp, Unit *unit,
00209 int *sxp, int *syp, int *swp, int *shp);
00210 extern void xform_unit_self(VP *vp, Unit *unit,
00211 int *sxp, int *syp, int *swp, int *shp);
00212 extern int xform_unit_self_view(Side *side, VP *vp, UnitView *uview,
00213 int *sxp, int *syp, int *swp, int *shp);
00214 extern void xform_occupant(VP *vp, Unit *transport, Unit *unit,
00215 int sx, int sy, int sw, int sh,
00216 int *sxp, int *syp, int *swp, int *shp);
00217 extern void xform_occupant_view(VP *vp, UnitView *traview, UnitView *uview,
00218 int sx, int sy, int sw, int sh,
00219 int *sxp, int *syp, int *swp, int *shp);
00220 #if (0)
00221 extern void xform_unit_view(Side *side, VP *vp, UnitView *uview,
00222 int *sxp, int *syp, int *swp, int *shp);
00223 #endif
00224 extern int xform_unit_view(Side *side, VP *vp, UnitView *uview,
00225 int *sxp, int *syp, int *swp, int *shp,
00226 int flags = XFORM_UVIEW_LEGACY,
00227 int *piles = NULL, int sxt = -1, int syt = -1,
00228 int swt = -1, int sht = -1);
00229 extern void xform_cell_flat(VP *vp, int x, int y, int *sxp, int *syp);
00230 extern void xform_cell_fractional_flat(VP *vp, int x, int y, int xf, int yf,
00231 int *sxp, int *syp);
00232 extern void scale_vp(VP *vp, VP *vp2, int *sxp, int *syp, int *swp, int *shp);
00233 extern void scale_point(VP *vp, VP *vp2, int sx, int sy, int *sx2p, int *sy2p);
00234
00235 extern int nearest_cell(VP *vp, int sx, int sy, int *xp, int *yp,
00236 int *xfp, int *yfp);
00237 extern int nearest_boundary(VP *vp, int sx, int sy, int *xp, int *yp,
00238 int *dirp);
00239 extern int nearest_unit(Side *side, VP *vp, int sx, int sy, Unit **unitp);
00240 extern int nearest_unit_view(Side *side, VP *vp, int sx, int sy,
00241 UnitView **uviewp);
00242
00243 extern int cell_is_visible(VP *vp, int x, int y);
00244 extern int cell_is_in_middle(VP *vp, int x, int y);
00245
00246 extern int set_view_size(VP *vp, int w, int h);
00247 extern int set_view_position(VP *vp, int sx, int sy);
00248 extern int set_view_power(VP *vp, int power);
00249 extern int set_view_angle(VP *vp, int angle);
00250 extern int set_view_isometric(VP *vp, int flag, int scale);
00251 extern int set_view_direction(VP *vp, int dir);
00252 extern int set_view_focus(VP *vp, int x, int y);
00253 extern void center_on_focus(VP *vp);
00254 extern void focus_on_center(VP *vp);
00255
00256 extern void free_vp(VP *vp);
00257
00258 extern int compute_x1_len(VP *vp, int vx, int vy, int y, int *x1p, int *lenp);
00259 extern int any_borders_in_dir(int x, int y, int dir);
00260 extern int any_coating_at(int x, int y);
00261 extern int compute_transition(Side *side, VP *vp, int x, int y, int dir,
00262 int *sxp, int *syp, int *swp, int *shp,
00263 int *offsetp);
00264
00265 extern void compute_fire_line_segment(int sx1, int sy1, int sx2, int sy2,
00266 int i, int n, int *xx, int *yy,
00267 int *dx, int *dy);
00268 extern void place_feature_legends(Legend *leg, int nf, Side *side,
00269 int orient, int block);
00270 extern void set_meridian_interval(VP *vp, int interval);
00271 extern void plot_meridians
00272 (VP *vp,
00273 void (*line_callback)(int x1, int y1, int x1f, int y1f,
00274 int x2, int y2, int x2f, int y2f),
00275 void (*text_callback)(int x1, int y1, int x1f, int y1f, char *str));
00276 extern void set_contour_interval(VP *vp, int n);
00277 extern void contour_lines_at(VP *vp, int x, int y, int sx, int sy,
00278 LineSegment **lines, int *numlinesp);
00279 extern int unit_visible(Side *side, VP *vp, Unit *unit);
00280 extern int draw_temperature_here(Side *side, int x, int y);
00281 extern int draw_winds_here(Side *side, int x, int y);
00282
00283 extern void oneliner(Side *side, VP *vp, int sx, int sy);
00284
00285 extern Unit *find_unit_or_occ(Side *side, VP *vp, Unit *unit,
00286 int usx, int usy, int usw, int ush,
00287 int sx, int sy);
00288 extern Unit *find_unit_at(Side *side, VP *vp, int x, int y, int sx, int sy);
00290 extern UnitView *find_uview_at_pixel(
00291 Side *side, VP *vp, UnitView *uview, int usx, int usy, int usw, int ush,
00292 int sx, int sy);
00294 extern UnitView *find_uview_at_pixel(
00295 Side *side, VP *vp, int x, int y, int sx, int sy);
00296
00297 extern void pick_a_focus(Side *side, int *xp, int *yp);
00298
00299 extern Unit *autonext_unit(Side *side, Unit *unit);
00300 extern Unit *autonext_unit_inbox(Side *side, Unit *unit, VP *vp);
00301 extern int could_be_next_unit(Unit *unit);
00302
00303 extern Unit *find_next_occupant(Unit *unit);
00304 extern Unit *embarkation_unit(Unit *unit);
00305 extern int find_units_matching(Side *side, char *name, Unit **unitp);
00306
00307 extern int num_active_displays(void);
00308
00309 extern int char_to_dir(int ch, int *dir1p, int *dir2p, int *modp);
00310 extern int advance_into_cell(Side *side, Unit *unit, int x, int y,
00311 Unit *other, HistEventType *reason);
00312
00313 extern int unit_could_attack(Unit *unit, int u2, Side *side2, int x, int y);
00314
00315 extern Unit *give_supplies(Unit *unit, short *amts, short *rslts);
00316 extern int take_supplies(Unit *unit, short *amts, short *rslts);
00317
00318 extern int impl_move_to(Side *side, Unit *unit, int x, int y, int dist);
00319 extern int impl_build(
00320 Side *side, Unit *unit, int u2, Unit *transport, int x, int y, int n);
00321 extern int impl_change_type(Side *side, Unit *unit, int u2);
00322 extern int favored_type(Unit *unit);
00323
00324 extern void set_unit_image(Unit *unit);
00325 extern void set_unit_view_image(UnitView *uview);
00326
00327 extern ImageFamily *get_unit_type_images(Side *side, int u);
00328 extern ImageFamily *get_material_type_images(Side *side, int m);
00329 extern ImageFamily *get_terrain_type_images(Side *side, int t);
00330 extern ImageFamily *get_unseen_images(Side *side);
00331 extern ImageFamily *get_emblem_images(Side *side, Side *side2);
00332
00333 extern void record_imf_get(ImageFamily *imf);
00334
00335 extern void describe_imf(Side *side, char *classname, char *imftype,
00336 ImageFamily *imf);
00337
00338 extern void init_ui_chars(void);
00339 extern void init_unit_images(Side *side);
00340 extern void dump_text_view(Side *side, int use_both);
00341
00342 extern int terrain_seen_at(Side *side, int x, int y);
00343 extern Unit *unit_seen_at(Side *side, int x, int y);
00344 extern int utype_seen_at(Side *side, int x, int y);
00345
00346
00347
00348 extern char *cmdargstr;
00349 extern char tmpkey;
00350
00351 extern HelpNode *key_commands_help_node;
00352 extern HelpNode *long_commands_help_node;
00353 extern HelpNode *map_help_node;
00354
00355
00356
00357 #undef DEF_CMD
00358 #define DEF_CMD(letter,name,FN,help) \
00359 void FN(Side *side);
00360
00361 #include "cmd.def"
00362
00363 extern void execute_command(Side *side, int ch);
00364 extern void execute_long_command(Side *side, char *cmdstr);
00365 extern void parse_long_name_command(char *cmdstr, int *prefixp,
00366 char **namep, char **argp, char *buf);
00367 extern void describe_key_commands(int arg, char *key, TextBuffer *buf);
00368 extern void describe_long_commands(int arg, char *key, TextBuffer *buf);