diff --git a/src/apply.c b/src/apply.c index 65482c337..10bfdfd23 100644 --- a/src/apply.c +++ b/src/apply.c @@ -37,6 +37,8 @@ STATIC_DCL boolean FDECL(figurine_location_checks, (struct obj *, coord *, BOOLEAN_P)); STATIC_DCL void FDECL(add_class, (char *, CHAR_P)); STATIC_DCL void FDECL(setapplyclasses, (char *)); +STATIC_DCL boolean FDECL(is_valid_jump_pos, (int, int, int, BOOLEAN_P)); +STATIC_DCL boolean FDECL(find_poleable_mon, (coord *, int, int)); #ifdef AMIGA void FDECL( amii_speaker, ( struct obj *, char *, int ) ); @@ -1401,7 +1403,8 @@ int state; for (dy = -4; dy <= 4; dy++) { x = dx + (int)u.ux; y = dy + (int)u.uy; - if (isok(x,y) && is_valid_jump_pos(x,y, jumping_is_magic, FALSE)) + if (isok(x,y) && ACCESSIBLE(levl[x][y].typ) && + is_valid_jump_pos(x,y, jumping_is_magic, FALSE)) tmp_at(x,y); } } else { @@ -2609,7 +2612,7 @@ int state; for (dy = -4; dy <= 4; dy++) { x = dx + (int)u.ux; y = dy + (int)u.uy; - if (isok(x, y) && + if (isok(x, y) && ACCESSIBLE(levl[x][y].typ) && distu(x, y) >= polearm_range_min && distu(x, y) <= polearm_range_max) { tmp_at(x, y); diff --git a/src/makemon.c b/src/makemon.c index 799438c2e..cb466220e 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -122,13 +122,15 @@ register int x, y, n; */ if (enexto(&mm, mm.x, mm.y, mtmp->data)) { mon = makemon(mtmp->data, mm.x, mm.y, NO_MM_FLAGS); - mon->mpeaceful = FALSE; - mon->mavenge = 0; - set_malign(mon); - /* Undo the second peace_minded() check in makemon(); if the - * monster turned out to be peaceful the first time we - * didn't create it at all; we don't want a second check. - */ + if (mon) { + mon->mpeaceful = FALSE; + mon->mavenge = 0; + set_malign(mon); + /* Undo the second peace_minded() check in makemon(); if the + * monster turned out to be peaceful the first time we + * didn't create it at all; we don't want a second check. + */ + } } } } diff --git a/src/mhitu.c b/src/mhitu.c index 9ec602895..8450ad12e 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -2558,6 +2558,7 @@ cloneu() if (u.mh <= 1) return(struct monst *)0; if (mvitals[mndx].mvflags & G_EXTINCT) return(struct monst *)0; mon = makemon(youmonst.data, u.ux, u.uy, NO_MINVENT|MM_EDOG); + if (!mon) return NULL; mon->mcloned = 1; mon = christen_monst(mon, plname); initedog(mon); diff --git a/src/sp_lev.c b/src/sp_lev.c index ed1b782c2..5efdb6e16 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -15,6 +15,8 @@ #include "sp_lev.h" +typedef void (*select_iter_func)(int, int, genericptr_t); + extern void FDECL(mkmap, (lev_init *)); STATIC_DCL void FDECL(get_room_loc, (schar *, schar *, struct mkroom *)); @@ -35,6 +37,94 @@ STATIC_DCL boolean FDECL(create_subroom, (struct mkroom *, XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P)); long FDECL(opvar_array_length, (struct sp_coder *)); +STATIC_DCL void NDECL(solidify_map); +STATIC_DCL void FDECL(splev_stack_init, (struct splevstack *)); +STATIC_DCL void FDECL(splev_stack_done, (struct splevstack *)); +STATIC_DCL void FDECL(splev_stack_push, (struct splevstack *, struct opvar *)); +STATIC_DCL struct opvar * FDECL(splev_stack_pop, (struct splevstack *)); +STATIC_DCL struct splevstack * FDECL(splev_stack_reverse, (struct splevstack *)); +STATIC_DCL struct opvar * FDECL(opvar_new_str, (char *)); +STATIC_DCL struct opvar * FDECL(opvar_new_int, (long)); +STATIC_DCL struct opvar * FDECL(opvar_new_coord, (int, int)); +STATIC_DCL struct opvar * FDECL(opvar_new_region, (int,int, int,int)); +STATIC_DCL void FDECL(opvar_free_x, (struct opvar *)); +STATIC_DCL struct opvar * FDECL(opvar_clone, (struct opvar *)); +STATIC_DCL struct opvar * FDECL(opvar_var_conversion, (struct sp_coder *, struct opvar *)); +STATIC_DCL struct splev_var * FDECL(opvar_var_defined, (struct sp_coder *, char *)); +STATIC_DCL struct opvar * FDECL(splev_stack_getdat, (struct sp_coder *, XCHAR_P)); +STATIC_DCL struct opvar * FDECL(splev_stack_getdat_any, (struct sp_coder *)); +STATIC_DCL void FDECL(variable_list_del, (struct splev_var *)); +STATIC_DCL void FDECL(lvlfill_maze_grid, (int,int, int,int, SCHAR_P)); +STATIC_DCL void FDECL(lvlfill_solid, (SCHAR_P, SCHAR_P)); +STATIC_DCL void NDECL(remove_boundary_syms); +STATIC_DCL void FDECL(maybe_add_door, (int,int, struct mkroom *)); +STATIC_DCL void NDECL(link_doors_rooms); +STATIC_DCL void NDECL(fill_rooms); +STATIC_DCL unpacked_coord FDECL(get_unpacked_coord, (long, int)); +STATIC_DCL void FDECL(replace_terrain, (replaceterrain *, struct mkroom *)); +STATIC_DCL void FDECL(wallify_map, (int,int, int,int)); +STATIC_DCL void FDECL(splev_initlev, (lev_init *)); +STATIC_DCL struct sp_frame * FDECL(frame_new, (long)); +STATIC_DCL void FDECL(frame_del, (struct sp_frame *)); +STATIC_DCL void FDECL(spo_frame_push, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_frame_pop, (struct sp_coder *)); +STATIC_DCL long FDECL(sp_code_jmpaddr, (long, long)); +STATIC_DCL void FDECL(spo_call, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_return, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_end_moninvent, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_pop_container, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_message, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_monster, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_object, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_level_flags, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_initlevel, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_engraving, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_mineralize, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_room, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_endroom, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_stair, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_ladder, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_grave, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_altar, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_trap, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_gold, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_corridor, (struct sp_coder *)); +STATIC_DCL struct opvar * FDECL(selection_opvar, (char *)); +STATIC_DCL xchar FDECL(selection_getpoint, (int,int, struct opvar *)); +STATIC_DCL void FDECL(selection_setpoint, (int,int, struct opvar *, XCHAR_P)); +STATIC_DCL struct opvar * FDECL(selection_not, (struct opvar *)); +STATIC_DCL struct opvar * FDECL(selection_logical_oper, (struct opvar *, struct opvar *, CHAR_P)); +STATIC_DCL struct opvar * FDECL(selection_filter_mapchar, (struct opvar *, struct opvar *)); +STATIC_DCL void FDECL(selection_filter_percent, (struct opvar *, int)); +STATIC_DCL int FDECL(selection_rndcoord, (struct opvar *, schar *, schar *)); +STATIC_DCL void FDECL(selection_do_grow, (struct opvar *, int)); +STATIC_DCL void FDECL(selection_floodfill, (struct opvar *, int,int)); +STATIC_DCL void FDECL(selection_do_ellipse, (struct opvar *, int,int, int,int, int)); +STATIC_DCL long FDECL(line_dist_coord, (long,long, long,long, long,long)); +STATIC_DCL void FDECL(selection_do_gradient, (struct opvar *, long,long, long,long, long,long,long,long)); +STATIC_DCL void FDECL(selection_do_line, (SCHAR_P,SCHAR_P, SCHAR_P,SCHAR_P, struct opvar *)); +STATIC_DCL void FDECL(selection_do_randline, (SCHAR_P,SCHAR_P, SCHAR_P,SCHAR_P, SCHAR_P,SCHAR_P, struct opvar *)); +STATIC_DCL void FDECL(selection_iterate, (struct opvar *, select_iter_func, genericptr_t)); +STATIC_DCL void FDECL(sel_set_ter, (int,int, genericptr_t)); +STATIC_DCL void FDECL(sel_set_feature, (int,int, genericptr_t)); +STATIC_DCL void FDECL(sel_set_door, (int,int, genericptr_t)); +STATIC_DCL void FDECL(spo_door, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_feature, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_terrain, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_replace_terrain, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_levregion, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_region, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_drawbridge, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_mazewalk, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_wall_property, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_room_door, (struct sp_coder *)); +STATIC_DCL void FDECL(sel_set_wallify, (int,int, genericptr_t)); +STATIC_DCL void FDECL(spo_wallify, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_map, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_jmp, (struct sp_coder *, sp_lev *)); +STATIC_DCL void FDECL(spo_conditional_jump, (struct sp_coder *, sp_lev *)); +STATIC_DCL void FDECL(spo_var_init, (struct sp_coder *)); +STATIC_DCL void FDECL(spo_shuffle_array, (struct sp_coder *)); #define LEFT 1 #define H_LEFT 2 @@ -3208,7 +3298,7 @@ selection_opvar(nbuf) return ov; } -char +xchar selection_getpoint(x,y,ov) int x,y; struct opvar *ov; @@ -3223,12 +3313,12 @@ void selection_setpoint(x,y,ov, c) int x,y; struct opvar *ov; - char c; + xchar c; { if (!ov || ov->spovartyp != SPOVAR_SEL) return; if (x < 0 || y < 0 || x >= COLNO || y >= ROWNO) return; - ov->vardata.str[COLNO*y + x] = (c + 1); + ov->vardata.str[COLNO*y + x] = (char)(c + 1); } struct opvar * @@ -3482,16 +3572,16 @@ line_dist_coord(x1,y1, x2,y2, x3,y3) long py = y2-y1; long s = px*px + py*py; long x, y, dx, dy, dist = 0; - float u = 0; + float lu = 0; if (x1 == x2 && y1 == y2) return isqrt(dist2(x1,y1, x3,y3)); - u = ((x3 - x1) * px + (y3 - y1) * py) / (float)s; - if (u > 1) u = 1; - else if (u < 0) u = 0; + lu = ((x3 - x1) * px + (y3 - y1) * py) / (float)s; + if (lu > 1) lu = 1; + else if (lu < 0) lu = 0; - x = x1 + u * px; - y = y1 + u * py; + x = x1 + lu * px; + y = y1 + lu * py; dx = x - x3; dy = y - y3; dist = isqrt(dx*dx + dy*dy); @@ -3648,7 +3738,7 @@ selection_do_randline(x1,y1,x2,y2,rough, rec, ov) void selection_iterate(ov, func, arg) struct opvar *ov; - void FDECL((*func), (int,int,genericptr_t)); + select_iter_func func; genericptr_t arg; { int x,y; diff --git a/util/lev_main.c b/util/lev_main.c index 2268c9fc3..88fe73ed3 100644 --- a/util/lev_main.c +++ b/util/lev_main.c @@ -119,7 +119,29 @@ static void NDECL(init_obj_classes); static int FDECL(case_insensitive_comp, (const char *, const char *)); void VDECL(lc_error, (const char *, ...)); +void VDECL(lc_warning, (const char *, ...)); +char * FDECL(decode_parm_chr, (CHAR_P)); +char * FDECL(decode_parm_str, (char *)); +struct opvar * FDECL(set_opvar_int, (struct opvar *, long)); +struct opvar * FDECL(set_opvar_coord, (struct opvar *, long)); +struct opvar * FDECL(set_opvar_region, (struct opvar *, long)); +struct opvar * FDECL(set_opvar_mapchar, (struct opvar *, long)); +struct opvar * FDECL(set_opvar_monst, (struct opvar *, long)); +struct opvar * FDECL(set_opvar_obj, (struct opvar *, long)); +struct opvar * FDECL(set_opvar_str, (struct opvar *, char *)); +struct opvar * FDECL(set_opvar_var, (struct opvar *, char *)); void VDECL(add_opvars, (sp_lev *, const char *, ...)); +void NDECL(break_stmt_start); +void FDECL(break_stmt_end, (sp_lev *)); +void FDECL(break_stmt_new, (sp_lev *, long)); +char *FDECL(funcdef_paramtypes, (struct lc_funcdefs *)); +const char *FDECL(spovar2str, (long)); +void FDECL(vardef_used, (struct lc_vardefs *, char *)); +void FDECL(check_vardef_type, (struct lc_vardefs *, char *, long)); +struct lc_vardefs * FDECL(add_vardef_type, (struct lc_vardefs *, char *, long)); +int FDECL(reverse_jmp_opcode, (int)); +struct opvar * FDECL(opvar_clone, (struct opvar *)); +void FDECL(start_level_def, (sp_lev **, char *)); static struct { @@ -897,15 +919,15 @@ splev_add_from(splev, from_splev) void -start_level_def(splev, fname) +start_level_def(splev, ldfname) sp_lev **splev; -char *fname; +char *ldfname; { struct lc_funcdefs *f; - if (index(fname, '.')) - lc_error("Invalid dot ('.') in level name '%s'.", fname); - if ((int) strlen(fname) > 14) - lc_error("Level names limited to 14 characters ('%s').", fname); + if (index(ldfname, '.')) + lc_error("Invalid dot ('.') in level name '%s'.", ldfname); + if ((int) strlen(ldfname) > 14) + lc_error("Level names limited to 14 characters ('%s').", ldfname); f = function_definitions; while (f) { f->n_called = 0;