diff --git a/.gitignore b/.gitignore index a0575b2b4..a4bfbe1de 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ TAGS .make.state .nse_depinfo *~ -#* +\#* .#* ,* _$* diff --git a/DEVEL/hooksdir/nhsub b/DEVEL/hooksdir/nhsub index 2dbc97800..c169609be 100644 --- a/DEVEL/hooksdir/nhsub +++ b/DEVEL/hooksdir/nhsub @@ -267,6 +267,8 @@ my $count = s/\$$PREFIX-(([A-Za-z][A-Za-z0-9_]*)(: ([^\x24]+))?)\$/&handlevar($2 rename $ofile, $file or die "Can't rename $ofile to $file"; } +# XXX docs for --fixup and --squash are wrong in synopsis. --file missing +# --message --template -t sub cmdparse { my(@in) = @_; @@ -315,6 +317,21 @@ sub cmdparse { if($opt{cmd} eq 'add' && $single eq 'n'){ exit 0; } +#need to deal with options that eat a following element (-m, -F etc etc) +#add: nothing? +#commit: -c -C -F -m +# -u mode is optional +# -S keyid is optional + if($opt{cmd} eq 'commit'){ + if($single =~ m/[uS]/){ + last; + } + if($single =~ m/[cCFm]/){ +#XXX this will be a mess if the argument is wrong, but can we tell? No. + shift @in; + last; + } + } } } shift @in; diff --git a/dat/.gitignore b/dat/.gitignore index caece5a59..c2fecbb7c 100644 --- a/dat/.gitignore +++ b/dat/.gitignore @@ -9,6 +9,7 @@ bogusmon engrave epitaph x11tiles +nhtiles.bmp *.lev spec_levs quest_levs diff --git a/dat/opthelp b/dat/opthelp index ce1d743cc..1cffdeb73 100644 --- a/dat/opthelp +++ b/dat/opthelp @@ -3,6 +3,7 @@ Boolean options not under specific compile flags (with default values in []): option setting, which is reached via the 'O' cmd.) autodig dig if moving and wielding digging tool [FALSE] +autoopen walking into a door attempts to open it [TRUE] autopickup automatically pick up objects you move over [TRUE] autoquiver when firing with an empty quiver, select some suitable inventory weapon to fill the quiver [FALSE] diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index a62cfd02a..8b32a50aa 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -1905,6 +1905,8 @@ Cannot be set with the `O' command. .lp autodig Automatically dig if you are wielding a digging tool and moving into a place that can be dug (default false). +.lp autoopen +Walking into a door attempts to open it (default true). .lp "autopickup " Automatically pick up things onto which you move (default on). See diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index d31fa52aa..057fbc8e9 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -2306,6 +2306,9 @@ Cannot be set with the `{\tt O}' command. Automatically dig if you are wielding a digging tool and moving into a place that can be dug (default false). %.lp +\item[\ib{autoopen}] +Walking into a door attempts to open it (default true). +%.lp \item[\ib{autopickup}] Automatically pick up things onto which you move (default on). See ``{\it pickup\_types\/}'' to refine the behavior. diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 27c9aca0d..36894c697 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -897,6 +897,11 @@ allow showing legal positions for stinking cloud, jumping and polearms cloned creatures (of any type) don't deathdrop items pudding corpses behave somewhat differently than before mithril armor should have silver color +lichen corpse is an acid indicator +camera may contain a picture-painting demon +some monsters can eat through iron bars +inaccessible niches occasionally have iron bars in front +sinks may teleport or polymorph Platform- and/or Interface-Specific Fixes @@ -1161,6 +1166,7 @@ Aardvark Joe's Extended Logfile Michael Deutschmann's use_darkgray Clive Crous' dark_room sortloot by Jeroen Demeyer and Jukka Lahtinen +Auto open doors by Stefano Busti Code Cleanup and Reorganization diff --git a/include/context.h b/include/context.h index a544f6ae0..dfacbb5ad 100644 --- a/include/context.h +++ b/include/context.h @@ -110,6 +110,7 @@ struct context_info { boolean bypasses; /* bypass flag is set on at least one fobj */ boolean botl; /* partially redo status line */ boolean botlx; /* print an entirely new bottom line */ + boolean door_opened; /* set to true if door was opened during test_move */ struct dig_info digging; struct victual_info victual; struct tin_info tin; diff --git a/include/decl.h b/include/decl.h index abdc5261a..fbdfebc19 100644 --- a/include/decl.h +++ b/include/decl.h @@ -265,7 +265,7 @@ E NEARDATA struct c_color_names { const char *const c_black, *const c_amber, *const c_golden, *const c_light_blue,*const c_red, *const c_green, *const c_silver, *const c_blue, *const c_purple, - *const c_white; + *const c_white, *const c_orange; } c_color_names; #define NH_BLACK c_color_names.c_black #define NH_AMBER c_color_names.c_amber @@ -277,6 +277,7 @@ E NEARDATA struct c_color_names { #define NH_BLUE c_color_names.c_blue #define NH_PURPLE c_color_names.c_purple #define NH_WHITE c_color_names.c_white +#define NH_ORANGE c_color_names.c_orange /* The names of the colors used for gems, etc. */ E const char *c_obj_colors[]; diff --git a/include/extern.h b/include/extern.h index bec672979..9b77f0d2e 100644 --- a/include/extern.h +++ b/include/extern.h @@ -39,6 +39,7 @@ E void FDECL(m_unleash, (struct monst *,BOOLEAN_P)); E void NDECL(unleash_all); E boolean NDECL(next_to_u); E struct obj *FDECL(get_mleash, (struct monst *)); +E const char *NDECL(beautiful); E void FDECL(check_leash, (XCHAR_P,XCHAR_P)); E boolean FDECL(um_dist, (XCHAR_P,XCHAR_P,XCHAR_P)); E boolean FDECL(snuff_candle, (struct obj *)); @@ -497,6 +498,7 @@ E int FDECL(omon_adj, (struct monst *,struct obj *,BOOLEAN_P)); E int FDECL(thitmonst, (struct monst *,struct obj *)); E int FDECL(hero_breaks, (struct obj *,XCHAR_P,XCHAR_P,BOOLEAN_P)); E int FDECL(breaks, (struct obj *,XCHAR_P,XCHAR_P)); +E void FDECL(release_camera_demon, (struct obj *, XCHAR_P,XCHAR_P)); E void FDECL(breakobj, (struct obj *,XCHAR_P,XCHAR_P,BOOLEAN_P,BOOLEAN_P)); E boolean FDECL(breaktest, (struct obj *)); E boolean FDECL(walk_path, (coord *, coord *, boolean (*)(genericptr_t,int,int), genericptr_t)); @@ -979,6 +981,7 @@ E int NDECL(doforce); E boolean FDECL(boxlock, (struct obj *,struct obj *)); E boolean FDECL(doorlock, (struct obj *,int,int)); E int NDECL(doopen); +E int FDECL(doopen_indir, (int,int)); E int NDECL(doclose); #ifdef MAC @@ -1366,6 +1369,7 @@ E boolean FDECL(onscary, (int,int,struct monst *)); E void FDECL(monflee, (struct monst *, int, BOOLEAN_P, BOOLEAN_P)); E int FDECL(dochug, (struct monst *)); E int FDECL(m_move, (struct monst *,int)); +E void FDECL(dissolve_bars, (int,int)); E boolean FDECL(closed_door, (int,int)); E boolean FDECL(accessible, (int,int)); E void FDECL(set_apparxy, (struct monst *)); diff --git a/include/flag.h b/include/flag.h index 9f44bd06f..1bbf5ff2a 100644 --- a/include/flag.h +++ b/include/flag.h @@ -18,6 +18,7 @@ struct flag { boolean acoustics; /* allow dungeon sound messages */ boolean autodig; /* MRKR: Automatically dig */ boolean autoquiver; /* Automatically fill quiver */ + boolean autoopen; /* open doors by walking into them */ boolean beginner; boolean biff; /* enable checking for mail */ boolean bones; /* allow saving/loading bones */ diff --git a/include/hack.h b/include/hack.h index 7b530e0a7..ec5698ac7 100644 --- a/include/hack.h +++ b/include/hack.h @@ -57,6 +57,15 @@ #define EXT_ENCUMBER 4 /* Overtaxed */ #define OVERLOADED 5 /* Overloaded */ +/* hunger states - see hu_stat in eat.c */ +#define SATIATED 0 +#define NOT_HUNGRY 1 +#define HUNGRY 2 +#define WEAK 3 +#define FAINTING 4 +#define FAINTED 5 +#define STARVED 6 + /* Macros for how a rumor was delivered in outrumor() */ #define BY_ORACLE 0 #define BY_COOKIE 1 diff --git a/include/patchlevel.h b/include/patchlevel.h index 76d514afa..0665df6fe 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -14,7 +14,7 @@ * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. */ -#define EDITLEVEL 60 +#define EDITLEVEL 61 #define COPYRIGHT_BANNER_A \ "NetHack, Copyright 1985-2015" diff --git a/src/allmain.c b/src/allmain.c index 7a2ebe675..a1330f89f 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -61,10 +61,15 @@ boolean resuming; set_wear((struct obj *)0); /* for side-effects of worn starting gear */ (void) pickup(1); /* autopickup at initial location */ } else { /* restore old game */ +#ifndef WIN32 update_inventory(); /* for perm_invent */ +#endif read_engr_at(u.ux, u.uy); /* subset of pickup() */ } - +#ifdef WIN32 + update_inventory(); /* for perm_invent */ +#endif + (void) encumber_msg(); /* in case they auto-picked up something */ if (defer_see_monsters) { defer_see_monsters = FALSE; diff --git a/src/apply.c b/src/apply.c index 40249be1f..e8b0bfea4 100644 --- a/src/apply.c +++ b/src/apply.c @@ -703,6 +703,14 @@ register xchar x, y; } } +const char * +beautiful() +{ + return (ACURR(A_CHA) > 14) ? + (poly_gender() == 1 ? "beautiful" : "handsome") : "ugly"; +} + + #define WEAK 3 /* from eat.c */ static const char look_str[] = "look %s."; @@ -720,8 +728,7 @@ struct obj *obj; if(!getdir((char *)0)) return 0; invis_mirror = Invis; useeit = !Blind && (!invis_mirror || See_invisible); - uvisage = (ACURR(A_CHA) > 14) ? - (poly_gender() == 1 ? "beautiful" : "handsome") : "ugly"; + uvisage = beautiful(); mirror = simpleonames(obj); /* "mirror" or "looking glass" */ if(obj->cursed && !rn2(2)) { if (!Blind) diff --git a/src/attrib.c b/src/attrib.c index 940467c98..25712cf94 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -371,15 +371,6 @@ boolean inc_or_dec; if (moves > 0 && (i == A_STR || i == A_CON)) (void)encumber_msg(); } -/* hunger values - from eat.c */ -#define SATIATED 0 -#define NOT_HUNGRY 1 -#define HUNGRY 2 -#define WEAK 3 -#define FAINTING 4 -#define FAINTED 5 -#define STARVED 6 - STATIC_OVL void exerper() { diff --git a/src/decl.c b/src/decl.c index d9429dbcf..3508b2621 100644 --- a/src/decl.c +++ b/src/decl.c @@ -216,7 +216,7 @@ NEARDATA struct c_color_names c_color_names = { "black", "amber", "golden", "light blue", "red", "green", "silver", "blue", "purple", - "white" + "white", "orange" }; struct menucoloring *menu_colorings = NULL; diff --git a/src/do.c b/src/do.c index 9a797ef06..27255d030 100644 --- a/src/do.c +++ b/src/do.c @@ -8,6 +8,8 @@ #include "lev.h" STATIC_DCL void FDECL(trycall, (struct obj *)); +STATIC_DCL void NDECL(polymorph_sink); +STATIC_DCL boolean NDECL(teleport_sink); STATIC_DCL void FDECL(dosinkring, (struct obj *)); STATIC_PTR int FDECL(drop, (struct obj *)); @@ -259,6 +261,72 @@ register struct obj *obj; docall(obj); } +/** Transforms the sink at the player's position into + * a fountain, throne, altar or grave. */ +STATIC_DCL +void +polymorph_sink() +{ + if (levl[u.ux][u.uy].typ != SINK) return; + + level.flags.nsinks--; + levl[u.ux][u.uy].doormask = 0; + switch(rn2(4)) { + default: + case 0: + levl[u.ux][u.uy].typ = FOUNTAIN; + level.flags.nfountains++; + break; + case 1: + levl[u.ux][u.uy].typ = THRONE; + break; + case 2: + levl[u.ux][u.uy].typ = ALTAR; + levl[u.ux][u.uy].altarmask = Align2amask(rn2((int)A_LAWFUL+2) - 1); + break; + case 3: + levl[u.ux][u.uy].typ = ROOM; + make_grave(u.ux, u.uy, (char *) 0); + break; + } + pline_The("sink transforms into %s!", + (levl[u.ux][u.uy].typ == THRONE) ? + "a throne" : an(surface(u.ux, u.uy))); + newsym(u.ux,u.uy); +} + +/** Teleports the sink at the player's position. + * @return TRUE if sink teleported */ +STATIC_DCL +boolean +teleport_sink() +{ + int cx, cy; + int cnt = 0; + struct trap *trp; + struct engr *eng; + do { + cx = rnd(COLNO-1); + cy = rn2(ROWNO); + trp = t_at(cx,cy); + eng = engr_at(cx,cy); + } while (((levl[cx][cy].typ != ROOM) || (trp) || (eng) || + cansee(cx,cy)) && (cnt++ < 200)); + if ((levl[cx][cy].typ == ROOM) && !trp && !eng) { + /* create sink at new position */ + levl[cx][cy].typ = SINK; + levl[cx][cy].looted = levl[u.ux][u.uy].looted; + newsym(cx,cy); + /* remove old sink */ + levl[u.ux][u.uy].typ = ROOM; + levl[u.ux][u.uy].looted = 0; + newsym(u.ux,u.uy); + return TRUE; + } + return FALSE; +} + + STATIC_OVL void dosinkring(obj) /* obj is a ring being dropped over a kitchen sink */ @@ -266,6 +334,7 @@ register struct obj *obj; { register struct obj *otmp,*otmp2; register boolean ideed = TRUE; + boolean nosink = FALSE; You("drop %s down the drain.", doname(obj)); obj->in_use = TRUE; /* block free identification via interrupt */ @@ -288,8 +357,9 @@ giveback: You("smell rotten %s.", makeplural(fruitname(FALSE))); break; case RIN_AGGRAVATE_MONSTER: - pline("Several flies buzz angrily around the sink."); - break; + pline("Several %s buzz angrily around the sink.", + Hallucination ? makeplural(rndmonnam(NULL)) : "flies"); + break; case RIN_SHOCK_RESISTANCE: pline("Static electricity surrounds the sink."); break; @@ -354,7 +424,8 @@ giveback: You_see("the ring slide right down the drain!"); break; case RIN_SEE_INVISIBLE: - You_see("some air in the sink."); + You_see("some %s in the sink.", + Hallucination ? "oxygen molecules" : "air"); break; case RIN_STEALTH: pline_The("sink seems to blend into the floor for a moment."); @@ -376,13 +447,15 @@ giveback: pline_The("sink glows %s for a moment.", hcolor(NH_WHITE)); break; case RIN_TELEPORTATION: - pline_The("sink momentarily vanishes."); + nosink = teleport_sink(); + pline_The("sink %svanishes.", nosink ? "" : "momentarily "); break; case RIN_TELEPORT_CONTROL: pline_The("sink looks like it is being beamed aboard somewhere."); break; case RIN_POLYMORPH: - pline_The("sink momentarily looks like a fountain."); + polymorph_sink(); + nosink = TRUE; break; case RIN_POLYMORPH_CONTROL: pline_The("sink momentarily looks like a regularly erupting geyser."); @@ -391,9 +464,9 @@ giveback: } if(ideed) trycall(obj); - else + else if (!nosink) You_hear("the ring bouncing down the drainpipe."); - if (!rn2(20)) { + if (!rn2(20) && !nosink) { pline_The("sink backs up, leaving %s.", doname(obj)); obj->in_use = FALSE; dropx(obj); diff --git a/src/do_name.c b/src/do_name.c index 11ad9a805..df4eabcf2 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -420,10 +420,7 @@ do_mname() mtmp = u.usteed; else { pline("This %s creature is called %s and cannot be renamed.", - ACURR(A_CHA) > 14 ? - (flags.female ? "beautiful" : "handsome") : - "ugly", - plname); + beautiful(), plname); return; } } else diff --git a/src/dothrow.c b/src/dothrow.c index ab4b96497..679d49a6e 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -1665,6 +1665,21 @@ xchar x, y; /* object location (ox, oy may not be right) */ return 1; } +void +release_camera_demon(obj, x,y) +struct obj *obj; +xchar x,y; +{ + struct monst *mtmp; + if (!rn2(3) && (mtmp = makemon(&mons[rn2(3) ? PM_HOMUNCULUS : PM_IMP],x,y, NO_MM_FLAGS)) != 0) { + if (canspotmon(mtmp)) + pline("%s is released!", Hallucination ? + An(rndmonnam(NULL)) : "The picture-painting demon"); + mtmp->mpeaceful = !obj->cursed; + set_malign(mtmp); + } +} + /* * Unconditionally break an object. Assumes all resistance checks * and break messages have been delivered prior to getting here. @@ -1707,6 +1722,9 @@ boolean from_invent; } /* monster breathing isn't handled... [yet?] */ break; + case EXPENSIVE_CAMERA: + release_camera_demon(obj, x,y); + break; case EGG: /* breaking your own eggs is bad luck */ if (hero_caused && obj->spe && obj->corpsenm >= LOW_PM) diff --git a/src/eat.c b/src/eat.c index bd0c55c33..27eb04d72 100644 --- a/src/eat.c +++ b/src/eat.c @@ -39,15 +39,6 @@ STATIC_DCL boolean FDECL(maybe_cannibal, (int,BOOLEAN_P)); char msgbuf[BUFSZ]; -/* hunger texts used on bottom line (each 8 chars long) */ -#define SATIATED 0 -#define NOT_HUNGRY 1 -#define HUNGRY 2 -#define WEAK 3 -#define FAINTING 4 -#define FAINTED 5 -#define STARVED 6 - /* also used to see if you're allowed to eat cats and dogs */ #define CANNIBAL_ALLOWED() (Role_if(PM_CAVEMAN) || Race_if(PM_ORC)) @@ -75,6 +66,7 @@ STATIC_OVL NEARDATA const char allobj[] = { STATIC_OVL boolean force_save_hs = FALSE; +/* see hunger states in hack.h - texts used on bottom line */ const char *hu_stat[] = { "Satiated", " ", diff --git a/src/files.c b/src/files.c index 5ac1e67a0..6310aabef 100644 --- a/src/files.c +++ b/src/files.c @@ -3352,10 +3352,8 @@ int tribpassage; char *endp; char line[BUFSZ]; - int scopes[4] = {0, SECTIONSCOPE, TITLESCOPE, PASSAGESCOPE}; - int scope = 0, section = 0, passage = 0, book = 0; - int linect = 0, passagecnt = 0, targetpassage = 0, textcnt = 0; - char *sectionnm = "", *booknm = ""; + int scope = 0; + int linect = 0, passagecnt = 0, targetpassage = 0; const char *badtranslation = "an incomprehensible foreign translation"; boolean matchedsection = FALSE, matchedtitle = FALSE; winid tribwin = WIN_ERR; diff --git a/src/hack.c b/src/hack.c index 976735600..f87f672bb 100644 --- a/src/hack.c +++ b/src/hack.c @@ -347,7 +347,7 @@ still_chewing(x,y) if (!boulder && IS_ROCK(lev->typ) && !may_dig(x,y)) { You("hurt your teeth on the %s.", - IS_TREE(lev->typ) ? "tree" : "hard stone"); + lev->typ == IRONBARS ? "bars" : (IS_TREE(lev->typ) ? "tree" : "hard stone")); nomul(0); return 1; } else if (context.digging.pos.x != x || context.digging.pos.y != y || @@ -362,9 +362,10 @@ still_chewing(x,y) context.digging.effort = (IS_ROCK(lev->typ) && !IS_TREE(lev->typ) ? 30 : 60) + u.udaminc; You("start chewing %s %s.", - (boulder || IS_TREE(lev->typ)) ? "on a" : "a hole in the", + (boulder || IS_TREE(lev->typ) || lev->typ == IRONBARS) ? "on a" : "a hole in the", boulder ? "boulder" : - IS_TREE(lev->typ) ? "tree" : IS_ROCK(lev->typ) ? "rock" : "door"); + IS_TREE(lev->typ) ? "tree" : IS_ROCK(lev->typ) ? "rock" : + lev->typ == IRONBARS ? "bar" : "door"); watch_dig((struct monst *)0, x, y, FALSE); return 1; } else if ((context.digging.effort += (30 + u.udaminc)) <= 100) { @@ -373,7 +374,8 @@ still_chewing(x,y) context.digging.chew ? "continue" : "begin", boulder ? "boulder" : IS_TREE(lev->typ) ? "tree" : - IS_ROCK(lev->typ) ? "rock" : "door"); + IS_ROCK(lev->typ) ? "rock" : + lev->typ == IRONBARS ? "bars" : "door"); context.digging.chew = TRUE; watch_dig((struct monst *)0, x, y, FALSE); return 1; @@ -418,6 +420,9 @@ still_chewing(x,y) } else if (IS_TREE(lev->typ)) { digtxt = "chew through the tree."; lev->typ = ROOM; + } else if (lev->typ == IRONBARS) { + digtxt = "eat through the bars."; + dissolve_bars(x,y); } else if (lev->typ == SDOOR) { if (lev->doormask & D_TRAPPED) { lev->doormask = D_NODOOR; @@ -622,6 +627,7 @@ int mode; register struct rm *tmpr = &levl[x][y]; register struct rm *ust; + context.door_opened = FALSE; /* * Check for physical obstacles. First, the place we are going. */ @@ -630,10 +636,15 @@ int mode; if (Passes_walls && may_passwall(x,y)) { ; /* do nothing */ } else if (tmpr->typ == IRONBARS) { + if ((dmgtype(youmonst.data, AD_RUST) || + dmgtype(youmonst.data, AD_CORR)) && + mode == DO_MOVE && still_chewing(x,y)) { + return FALSE; + } if (!(Passes_walls || passes_bars(youmonst.data))) { if (iflags.mention_walls) You("cannot pass through the bars."); - return FALSE; + return FALSE; } } else if (tunnels(youmonst.data) && !needspick(youmonst.data)) { /* Eat the rock. */ @@ -670,8 +681,10 @@ int mode; if (mode == DO_MOVE) { if (amorphous(youmonst.data)) You("try to ooze under the door, but can't squeeze your possessions through."); - else if (x == ux || y == uy) { - if (Blind || Stunned || ACURR(A_DEX) < 10 || Fumbling) { + if (flags.autoopen && !context.run && !Confusion && !Stunned && !Fumbling) { + context.door_opened = context.move = doopen_indir(x, y); + } else if (x == ux || y == uy) { + if (Blind || Stunned || ACURR(A_DEX) < 10 || Fumbling) { if (u.usteed) { You_cant("lead %s through that closed door.", y_monnam(u.usteed)); @@ -1395,9 +1408,11 @@ domove() } if (!test_move(u.ux, u.uy, x-u.ux, y-u.uy, DO_MOVE)) { - context.move = 0; - nomul(0); - return; + if (!context.door_opened) { + context.move = 0; + nomul(0); + } + return; } /* Move ball and chain. */ diff --git a/src/invent.c b/src/invent.c index 9e4041603..c66129cf0 100644 --- a/src/invent.c +++ b/src/invent.c @@ -2540,6 +2540,7 @@ mergable(otmp, obj) /* returns TRUE if obj & otmp can be merged */ register struct obj *otmp, *obj; { int objnamelth = 0, otmpnamelth = 0; + if (obj == otmp) return FALSE; /* already the same object */ if (obj->otyp != otmp->otyp) return FALSE; /* coins of the same kind will always merge */ if (obj->oclass == COIN_CLASS) return TRUE; diff --git a/src/lock.c b/src/lock.c index 3de76fe66..c29be8549 100644 --- a/src/lock.c +++ b/src/lock.c @@ -523,6 +523,14 @@ doforce() /* try to force a chest with your weapon */ int doopen() /* try to open a door */ { + return doopen_indir(0, 0); +} + +int +doopen_indir(x, y) /* try to open a door in direction u.dx/u.dy */ +int x, y; +{ + coord cc; register struct rm *door; struct monst *mtmp; @@ -539,7 +547,10 @@ doopen() /* try to open a door */ return 0; } - if(!get_adjacent_loc((char *)0, (char *)0, u.ux, u.uy, &cc)) return(0); + if (x > 0 && y > 0) { + cc.x = x; + cc.y = y; + } else if(!get_adjacent_loc((char *)0, (char *)0, u.ux, u.uy, &cc)) return(0); if((cc.x == u.ux) && (cc.y == u.uy)) return(0); diff --git a/src/mklev.c b/src/mklev.c index a2cc4e12a..b7cfc8e90 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -492,6 +492,15 @@ int trap_type; if(rn2(7)) dosdoor(xx, yy, aroom, rn2(5) ? SDOOR : DOOR); else { + /* inaccessible niches occasionally have iron bars */ + if (!rn2(5) && IS_WALL(levl[xx][yy].typ)) { + levl[xx][yy].typ = IRONBARS; + if (rn2(3)) + (void) mkcorpstat(CORPSE, + (struct monst *)0, + mkclass(S_HUMAN, 0), + xx, yy+dy, TRUE); + } if (!level.flags.noteleport) (void) mksobj_at(SCR_TELEPORTATION, xx, yy+dy, TRUE, FALSE); diff --git a/src/mondata.c b/src/mondata.c index 98c3244f5..0c26a6005 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -285,6 +285,7 @@ struct permonst *mptr; { return (boolean) (passes_walls(mptr) || amorphous(mptr) || unsolid(mptr) || is_whirly(mptr) || verysmall(mptr) || + dmgtype(mptr, AD_CORR) || dmgtype(mptr, AD_RUST) || (slithy(mptr) && !bigmonst(mptr))); } diff --git a/src/monmove.c b/src/monmove.c index 81eb563d3..a7a3ca46f 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -1180,7 +1180,14 @@ postmov: add_damage(mtmp->mx, mtmp->my, 0L); } } else if (levl[mtmp->mx][mtmp->my].typ == IRONBARS) { - if (flags.verbose && canseemon(mtmp)) + if (may_dig(mtmp->mx,mtmp->my) && + (dmgtype(ptr, AD_RUST) || dmgtype(ptr, AD_CORR))) { + if (canseemon(mtmp)) + pline("%s eats through the iron bars.", + Monnam(mtmp)); + dissolve_bars(mtmp->mx, mtmp->my); + return(3); + } else if (flags.verbose && canseemon(mtmp)) Norep("%s %s %s the iron bars.", Monnam(mtmp), /* pluralization fakes verb conjugation */ makeplural(locomotion(ptr, "pass")), @@ -1266,6 +1273,14 @@ postmov: return(mmoved); } +void +dissolve_bars(x, y) +register int x, y; +{ + levl[x][y].typ = (Is_special(&u.uz) || *in_rooms(x,y,0)) ? ROOM : CORR; + newsym(x, y); +} + boolean closed_door(x, y) register int x, y; diff --git a/src/music.c b/src/music.c index 24a7b75bd..3fabfec06 100644 --- a/src/music.c +++ b/src/music.c @@ -453,7 +453,7 @@ struct obj *instr; if (do_spec && instr->spe > 0) { consume_obj_charge(instr, TRUE); - You("produce soft music."); + You("produce %s music.", Hallucination ? "piped" : "soft"); put_monsters_to_sleep(u.ulevel * 5); exercise(A_DEX, TRUE); break; diff --git a/src/options.c b/src/options.c index 755c9e754..2354f1b03 100644 --- a/src/options.c +++ b/src/options.c @@ -77,6 +77,7 @@ static struct Bool_Opt {"asksavedisk", (boolean *)0, FALSE, SET_IN_FILE}, #endif {"autodig", &flags.autodig, FALSE, SET_IN_GAME}, + {"autoopen", &flags.autoopen, TRUE, SET_IN_GAME}, {"autopickup", &flags.pickup, TRUE, SET_IN_GAME}, {"autoquiver", &flags.autoquiver, FALSE, SET_IN_GAME}, #if defined(MICRO) && !defined(AMIGA) diff --git a/src/potion.c b/src/potion.c index d95395083..05bf99a3c 100644 --- a/src/potion.c +++ b/src/potion.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 potion.c $NHDT-Date: 1426953330 2015/03/21 15:55:30 $ $NHDT-Branch: master $:$NHDT-Revision: 1.99 $ */ +/* NetHack 3.5 potion.c $NHDT-Date: 1428972597 2015/04/14 00:49:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.111 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1818,6 +1818,15 @@ dodip() return 1; } + if(potion->otyp == POT_ACID && obj->otyp == CORPSE && + obj->corpsenm == PM_LICHEN && !Blind) { + pline("%s %s %s around the edges.", The(cxname(obj)), + otense(obj, "turn"), potion->odiluted ? + hcolor(NH_ORANGE) : hcolor(NH_RED)); + potion->in_use = FALSE; /* didn't go poof */ + return(1); + } + if(is_poisonable(obj)) { if(potion->otyp == POT_SICKNESS && !obj->opoisoned) { char buf[BUFSZ]; diff --git a/src/pray.c b/src/pray.c index e78d37a89..99cbf2841 100644 --- a/src/pray.c +++ b/src/pray.c @@ -148,16 +148,6 @@ in_trouble() struct obj *otmp; int i, j, count=0; -/* Borrowed from eat.c */ - -#define SATIATED 0 -#define NOT_HUNGRY 1 -#define HUNGRY 2 -#define WEAK 3 -#define FAINTING 4 -#define FAINTED 5 -#define STARVED 6 - /* * major troubles */ @@ -1369,7 +1359,7 @@ dosacrifice() a_gname(), u_gname()); pline("%s is enraged...", u_gname()); pline("Fortunately, %s permits you to live...", a_gname()); - pline(cloud_of_smoke, hcolor("orange")); + pline(cloud_of_smoke, hcolor(NH_ORANGE)); done(ESCAPED); } else { /* super big win */ adjalign(10); diff --git a/src/sit.c b/src/sit.c index 19cd63471..fd4207af5 100644 --- a/src/sit.c +++ b/src/sit.c @@ -67,9 +67,14 @@ dosit() register struct obj *obj; obj = level.objects[u.ux][u.uy]; - You("sit on %s.", the(xname(obj))); - if (!(Is_box(obj) || objects[obj->otyp].oc_material == CLOTH)) - pline("It's not very comfortable..."); + if (youmonst.data->mlet == S_DRAGON && obj->oclass == COIN_CLASS) { + You("coil up around your %shoard.", + (obj->quan + money_cnt(invent) < u.ulevel*1000) ? "meager " : ""); + } else { + You("sit on %s.", the(xname(obj))); + if (!(Is_box(obj) || objects[obj->otyp].oc_material == CLOTH)) + pline("It's not very comfortable..."); + } } else if (trap != 0 || (u.utrap && (u.utraptype >= TT_LAVA))) { if (u.utrap) { exercise(A_WIS, FALSE); /* you're getting stuck longer */ diff --git a/src/sp_lev.c b/src/sp_lev.c index f268e9348..bb3c416f1 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -407,7 +407,7 @@ opvar_clone(ov) case SPOVAR_VARIABLE: case SPOVAR_STRING: case SPOVAR_SEL: - tmpov->vardata.str = strdup(ov->vardata.str); + tmpov->vardata.str = dupstr(ov->vardata.str); break; default: impossible("Unknown push value type (%i)!", ov->spovartyp); } @@ -2677,7 +2677,7 @@ spo_monster(coder) case SP_M_V_NAME: if ((OV_typ(parm) == SPOVAR_STRING) && !tmpmons.name.str) - tmpmons.name.str = strdup(OV_s(parm)); + tmpmons.name.str = dupstr(OV_s(parm)); break; case SP_M_V_APPEAR: if ((OV_typ(parm) == SPOVAR_INT) && @@ -2685,7 +2685,7 @@ spo_monster(coder) tmpmons.appear = OV_i(parm); opvar_free(parm); OV_pop(parm); - tmpmons.appear_as.str = strdup(OV_s(parm)); + tmpmons.appear_as.str = dupstr(OV_s(parm)); } break; case SP_M_V_ASLEEP: @@ -2820,7 +2820,7 @@ spo_object(coder) case SP_O_V_NAME: if ((OV_typ(parm) == SPOVAR_STRING) && !tmpobj.name.str) - tmpobj.name.str = strdup(OV_s(parm)); + tmpobj.name.str = dupstr(OV_s(parm)); break; case SP_O_V_CORPSENM: if (OV_typ(parm) == SPOVAR_MONST) { @@ -3925,7 +3925,7 @@ spo_levregion(coder) tmplregion->del_islev = OV_i(del_islev); tmplregion->rtype = OV_i(rtype); tmplregion->padding = OV_i(padding); - tmplregion->rname.str = strdup(OV_s(rname)); + tmplregion->rname.str = dupstr(OV_s(rname)); if(!tmplregion->in_islev) { get_location(&tmplregion->inarea.x1, &tmplregion->inarea.y1, @@ -4494,7 +4494,7 @@ spo_var_init(coder) tmpvar = (struct splev_var *)malloc(sizeof(struct splev_var)); if (!tmpvar) panic("newvar tmpvar alloc"); tmpvar->next = coder->frame->variables; - tmpvar->name = strdup(OV_s(vname)); + tmpvar->name = dupstr(OV_s(vname)); coder->frame->variables = tmpvar; if (OV_i(arraylen) < 0) { diff --git a/src/uhitm.c b/src/uhitm.c index 2bf963c94..50c0523f6 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -741,6 +741,7 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */ case EXPENSIVE_CAMERA: You("succeed in destroying %s. Congratulations!", ysimple_name(obj)); + release_camera_demon(obj, u.ux, u.uy); useup(obj); return(TRUE); /*NOTREACHED*/ diff --git a/sys/share/posixregex.c b/sys/share/posixregex.c index 17cb2841e..3540d3b4c 100644 --- a/sys/share/posixregex.c +++ b/sys/share/posixregex.c @@ -1,8 +1,8 @@ -/* NetHack 3.5 posixregex.c $NHDT-Date: 1428590280 2015/04/09 14:38:00 $ $NHDT-Branch: scshunt-regex $:$NHDT-Revision: 1.0 $ */ +/* NetHack 3.5 posixregex.c $NHDT-Date: 1428970913 2015/04/14 00:21:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.0 $ */ /* Copyright (c) Sean Hunt 2015. */ /* NetHack may be freely redistributed. See license for details. */ -#include +#include "hack.h" #include @@ -50,7 +50,7 @@ struct nhregex { }; struct nhregex *regex_init() { - return malloc (sizeof (struct nhregex)); + return (struct nhregex *)alloc(sizeof (struct nhregex)); } boolean regex_compile(const char *s, struct nhregex *re) { @@ -65,7 +65,7 @@ const char *regex_error_desc(struct nhregex *re) { static char buf[BUFSZ]; if (!re || !re->err) - return NULL; + return (const char *)0; /* FIXME: Using a static buffer here is not ideal, but avoids memory * leaks. Consider the allocation more carefully. */ @@ -75,11 +75,12 @@ const char *regex_error_desc(struct nhregex *re) { } boolean regex_match(const char *s, struct nhregex *re) { + int result; + if (!re) return FALSE; - int result; - if ((result = regexec(&re->re, s, 0, NULL, 0))) { + if ((result = regexec(&re->re, s, 0, (genericptr_t)0, 0))) { if (result != REG_NOMATCH) re->err = result; return FALSE; diff --git a/sys/winnt/Makefile.gcc b/sys/winnt/Makefile.gcc index eb436fbf2..7aed22a50 100644 --- a/sys/winnt/Makefile.gcc +++ b/sys/winnt/Makefile.gcc @@ -1,6 +1,6 @@ # NetHack 3.5 Makefile.gcc $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ # NetHack 3.5 Makefile.gcc $Date: 2011/10/11 02:37:22 $ $Revision: 1.38 $ -# Copyright (c) NetHack PC Development Team 1993-2010 +# Copyright (c) NetHack PC Development Team 1993-2015 # # NetHack 3.5.x Makefile for MinGW # @@ -89,7 +89,7 @@ SRC = ../src # Shared system files SSYS = ../sys/share # NT Win32 specific files -NTSYS = ../sys/winnt +MSWSYS = ../sys/winnt # window port files (tty) TTY = ../win/tty # window port files (Win32) @@ -262,14 +262,17 @@ $(OBJ)/%.o : $(SRC)/%.c $(OBJ)/%.o : $(SSYS)/%.c $(cc) $(CFLAGS) -o$@ $< +$(OBJ)/%.o : $(SSYS)/%.cpp + g++ $(CFLAGS) -std=c++11 -o$@ $< + #========================================== # Rules for files in sys/winnt #========================================== -$(OBJ)/%.o : $(NTSYS)/%.c +$(OBJ)/%.o : $(MSWSYS)/%.c $(cc) $(CFLAGS) -o$@ $< -$(INCL)/%.h : $(NTSYS)/%.h +$(INCL)/%.h : $(MSWSYS)/%.h @copy $< $@ #========================================== @@ -313,7 +316,7 @@ $(OBJ)/%.o : $(WIN32)/%.c # referenced later on in the Makefile. # -DEFFILE = $(NTSYS)/$(GAME).def +DEFFILE = $(MSWSYS)/$(GAME).def # # Shorten up the location for some files @@ -394,6 +397,8 @@ VOBJ27 = $(O)worm.o $(O)worn.o $(O)write.o $(O)zap.o DLBOBJ = $(O)dlb.o +REGEX = $(O)cppregex.o + TTYOBJ = $(O)topl.o $(O)getline.o $(O)wintty.o SOBJ = $(O)winnt.o $(O)pcsys.o $(O)pcunix.o \ @@ -404,7 +409,7 @@ OBJS = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \ $(VOBJ11) $(VOBJ12) $(VOBJ13) $(VOBJ14) $(VOBJ15) \ $(VOBJ16) $(VOBJ17) $(VOBJ18) $(VOBJ19) $(VOBJ20) \ $(VOBJ21) $(VOBJ22) $(VOBJ23) $(VOBJ24) $(VOBJ25) \ - $(VOBJ26) $(VOBJ27) + $(VOBJ26) $(VOBJ27) $(REGEX) WINPOBJ = $(WINPORT) @@ -437,7 +442,7 @@ HACK_H = $(INCL)/hack.h $(CONFIG_H) $(INCL)/align.h $(INCL)/context.h \ $(INCL)/wintype.h $(INCL)/decl.h $(INCL)/quest.h \ $(INCL)/spell.h $(INCL)/color.h $(INCL)/obj.h \ $(INCL)/you.h $(INCL)/attrib.h $(INCL)/monst.h \ - $(INCL)/mextra.h $(INCL)/skills.h $(INCL)/onames.h + $(INCL)/mextra.h $(INCL)/skills.h $(INCL)/onames.h \ $(INCL)/timeout.h $(INCL)/trap.h $(INCL)/flag.h $(INCL)/rm.h \ $(INCL)/vision.h $(INCL)/display.h $(INCL)/engrave.h \ $(INCL)/rect.h $(INCL)/region.h $(INCL)/winprocs.h \ @@ -506,13 +511,14 @@ else $(subst /,\,copy $(DAT)/*.lev $(GAMEDIR)) $(subst /,\,if exist $(GAMEDIR)/makefile del $(GAMEDIR)/makefile) endif + $(subst /,\,if not exist $(GAMEDIR)/sysconf copy $(MSWSYS)/sysconf $(GAMEDIR)) $(subst /,\,if exist $(DAT)/symbols copy $(DAT)/symbols $(GAMEDIR)) $(subst /,\,if exist $(DOC)/guidebook.txt copy $(DOC)/guidebook.txt $(GAMEDIR)/Guidebook.txt) $(subst /,\,if exist $(DOC)/nethack.txt copy $(DOC)/nethack.txt $(GAMEDIR)/NetHack.txt) - $(subst /,\,copy $(NTSYS)/defaults.nh $(GAMEDIR)/defaults.nh) + $(subst /,\,copy $(MSWSYS)/defaults.nh $(GAMEDIR)/defaults.nh) $(subst /,\,echo install done > $@) -# copy $(NTSYS)/winnt.hlp $(GAMEDIR) +# copy $(MSWSYS)/winnt.hlp $(GAMEDIR) recover: $(U)recover.exe $(subst /,\,if exist $(U)recover.exe copy $(U)recover.exe $(GAMEDIR)) @@ -570,8 +576,8 @@ $(NHRES): $(TILEBMP16) $(WIN32)/winhack.rc $(WIN32)/mnsel.bmp \ $(WIN32)/splash.bmp @$(rc) -o$@ --include-dir $(WIN32) -i $(WIN32)/winhack.rc else -$(NHRES): $(NTSYS)/console.rc $(NTSYS)/NetHack.ico - @$(rc) -o$@ --include-dir $(NTSYS) -i $(NTSYS)/console.rc +$(NHRES): $(MSWSYS)/console.rc $(MSWSYS)/NetHack.ico + @$(rc) -o$@ --include-dir $(MSWSYS) -i $(MSWSYS)/console.rc endif #========================================== @@ -589,12 +595,12 @@ $(GAMEFILE) : $(ALLOBJ) $(NHRES) $(O)gamedir.tag \ $(GAMEDIR)/nhdefkey.dll $(GAMEDIR)/nh340key.dll $(GAMEDIR)/nhraykey.dll endif @echo Linking.... - @$(link) $(lflags) -o$@ $(ALLOBJ) $(NHRES) $(WINPLIBS) + $(link) $(lflags) -o$@ $(ALLOBJ) $(NHRES) $(WINPLIBS) -lstdc++ $(subst /,\,@if exist $(O)install.tag del $(O)install.tag) $(O)nhdefkey.o: - $(cc) $(CFLAGS) -DBUILD_DLL -o$@ $(NTSYS)/nhdefkey.c + $(cc) $(CFLAGS) -DBUILD_DLL -o$@ $(MSWSYS)/nhdefkey.c $(GAMEDIR)/nhdefkey.dll : $(O)nhdefkey.o $(O)gamedir.tag @echo Linking $@ @@ -602,7 +608,7 @@ $(GAMEDIR)/nhdefkey.dll : $(O)nhdefkey.o $(O)gamedir.tag -Wl,--add-stdcall-alias -o $@ $< $(O)nh340key.o: - $(cc) $(CFLAGS) -DBUILD_DLL -o$@ $(NTSYS)/nh340key.c + $(cc) $(CFLAGS) -DBUILD_DLL -o$@ $(MSWSYS)/nh340key.c $(GAMEDIR)/nh340key.dll : $(O)nh340key.o $(O)gamedir.tag @echo Linking $@ @@ -610,15 +616,15 @@ $(GAMEDIR)/nh340key.dll : $(O)nh340key.o $(O)gamedir.tag -Wl,--add-stdcall-alias -o $@ $< $(O)nhraykey.o: - $(cc) $(CFLAGS) -DBUILD_DLL -o$@ $(NTSYS)/nhraykey.c + $(cc) $(CFLAGS) -DBUILD_DLL -o$@ $(MSWSYS)/nhraykey.c $(GAMEDIR)/nhraykey.dll : $(O)nhraykey.o $(O)gamedir.tag @echo Linking $@ $(cc) -shared -Wl,--export-all-symbols \ -Wl,--add-stdcall-alias -o $@ $< -$(GAME)_.ico : $(NTSYS)/$(GAME).ico - $(subst /,\,@copy $(NTSYS)/$(GAME).ico $@) +$(GAME)_.ico : $(MSWSYS)/$(GAME).ico + $(subst /,\,@copy $(MSWSYS)/$(GAME).ico $@) #========================================== # Create directory for holding object files @@ -677,6 +683,17 @@ $(INCL)/vis_tab.h: $(U)makedefs.exe $(SRC)/vis_tab.c: $(U)makedefs.exe $(subst /,\,$(U)makedefs -z) +$(DAT)/engrave: $(DAT)/engrave.txt $(U)makedefs.exe + $(subst /,\,$(U)makedefs -s) + +$(DAT)\epitaph: $(DAT)/epitaph.txt $(U)makedefs.exe + $(subst /,\,$(U)makedefs -s) + +$(DAT)\bogusmon: $(DAT)/bogusmon.txt $(U)makedefs.exe + $(subst /,\,$(U)makedefs -s) + + + #========================================== # uudecode utility and uuencoded targets #========================================== @@ -686,12 +703,12 @@ $(U)uudecode.exe: $(O)uudecode.o $(O)uudecode.o: $(SSYS)/uudecode.c -$(NTSYS)/NetHack.ico : $(U)uudecode.exe $(NTSYS)/nhico.uu - $(subst /,\,$(U)uudecode.exe $(NTSYS)/nhico.uu) +$(MSWSYS)/NetHack.ico : $(U)uudecode.exe $(MSWSYS)/nhico.uu + $(subst /,\,$(U)uudecode.exe $(MSWSYS)/nhico.uu) $(subst /,\,copy NetHack.ico $@) del NetHack.ico -$(WIN32)/NetHack.ico : $(NTSYS)/NetHack.ico +$(WIN32)/NetHack.ico : $(MSWSYS)/NetHack.ico $(subst /,\,copy $< $@) $(WIN32)/mnsel.bmp: $(U)uudecode.exe $(WIN32)/mnsel.uu @@ -850,8 +867,8 @@ $(O)obj.tag: # Header files NOT distributed in ../include #=========================================== -$(INCL)/win32api.h: $(NTSYS)/win32api.h - $(subst /,\,copy $(NTSYS)/win32api.h $@) +$(INCL)/win32api.h: $(MSWSYS)/win32api.h + $(subst /,\,copy $(MSWSYS)/win32api.h $@) #========================================== @@ -868,13 +885,13 @@ $(O)dlb.o: $(O)dlb_main.o $(O)alloc.o $(O)panic.o $(INCL)/dlb.h $(O)dlb_main.o: $(UTIL)/dlb_main.c $(INCL)/config.h $(INCL)/dlb.h $(cc) $(CFLAGS) -o$@ $(UTIL)/dlb_main.c -$(DAT)/porthelp: $(NTSYS)/porthelp - $(subst /,\,@copy $(NTSYS)/porthelp $@ >nul) +$(DAT)/porthelp: $(MSWSYS)/porthelp + $(subst /,\,@copy $(MSWSYS)/porthelp $@ >nul) nhdat: $(U)dlb_main.exe $(DAT)/data $(DAT)/oracles $(OPTIONS_FILE) \ $(DAT)/quest.dat $(DAT)/rumors $(DAT)/help $(DAT)/hh $(DAT)/cmdhelp \ $(DAT)/history $(DAT)/opthelp $(DAT)/wizhelp $(DAT)/dungeon \ - $(DAT)/porthelp $(DAT)/license $(O)sp_lev.tag + $(DAT)/porthelp $(DAT)/license $(DAT)/engrave $(DAT)/epitaph $(DAT)/bogusmon $(DAT)/tribute $(O)sp_lev.tag $(subst /,\,echo data >$(DAT)/dlb.lst) $(subst /,\,echo oracles >>$(DAT)/dlb.lst) $(subst /,\,if exist $(DAT)/options echo options >>$(DAT)/dlb.lst) @@ -891,6 +908,10 @@ nhdat: $(U)dlb_main.exe $(DAT)/data $(DAT)/oracles $(OPTIONS_FILE) \ $(subst /,\,echo wizhelp >>$(DAT)/dlb.lst) $(subst /,\,echo dungeon >>$(DAT)/dlb.lst) $(subst /,\,echo license >>$(DAT)/dlb.lst) + $(subst /,\,echo engrave >>$(DAT)/dlb.lst) + $(subst /,\,echo epitaph >>$(DAT)/dlb.lst) + $(subst /,\,echo bogusmon >>$(DAT)/dlb.lst) + $(subst /,\,echo tribute >>$(DAT)/dlb.lst) dir /l /b /-p $(subst /,\,$(DAT)/*.lev >>$(DAT)/dlb.lst) $(subst /,\,$(U)dlb_main CcIf $(DAT) dlb.lst $(SRC)/nhdat) @@ -1085,12 +1106,19 @@ $(DAT)/dungeon: $(O)utility.tag $(DAT)/dungeon.def # NT dependencies # -$(O)nttty.o: $(HACK_H) $(TILE_H) $(INCL)/win32api.h $(NTSYS)/nttty.c - $(cc) $(CFLAGS) -I$(WSHR) -o$@ $(NTSYS)/nttty.c -$(O)winnt.o: $(HACK_H) $(INCL)/win32api.h $(NTSYS)/winnt.c - $(cc) $(CFLAGS) -o$@ $(NTSYS)/winnt.c -$(O)ntsound.o: $(HACK_H) $(NTSYS)/ntsound.c - $(cc) $(CFLAGS) -o$@ $(NTSYS)/ntsound.c +$(O)nttty.o: $(HACK_H) $(TILE_H) $(INCL)/win32api.h $(MSWSYS)/nttty.c + $(cc) $(CFLAGS) -I$(WSHR) -o$@ $(MSWSYS)/nttty.c +$(O)winnt.o: $(HACK_H) $(INCL)/win32api.h $(MSWSYS)/winnt.c + $(cc) $(CFLAGS) -o$@ $(MSWSYS)/winnt.c +$(O)ntsound.o: $(HACK_H) $(MSWSYS)/ntsound.c + $(cc) $(CFLAGS) -o$@ $(MSWSYS)/ntsound.c + +# +# sys/share dependencies +# + +(O)cppregex.o: $(O)cppregex.cpp $(HACK_H) + @$(CC) $(CFLAGS) -Fo$@ ../sys/share/cppregex.cpp # # util dependencies diff --git a/sys/winnt/Makefile.msc b/sys/winnt/Makefile.msc index e71770a3b..49e0872f3 100644 --- a/sys/winnt/Makefile.msc +++ b/sys/winnt/Makefile.msc @@ -142,63 +142,6 @@ rc=Rc TARGET_CPU=x86 !ENDIF -# Common compiler flags: -# -c - compile without linking -# -W3 - Set warning level to level 3 (-W4 for 64-bit compilations) -# -Zi - generate debugging information -# -Od - disable all optimizations -# -Ox - use maximum optimizations -# -Zd - generate only public symbols and line numbers for debugging -# -GS - enable security checks -# -ccommon=-c -Zi -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -c -lflags=/INCREMENTAL:NO /NOLOGO - -!IF "$(TARGET_CPU)" == "x86" -cflags = $(ccommon) -D_X86_=1 -DWIN32 -D_WIN32 -W3 -scall = -Gz - -!ELSEIF "$(TARGET_CPU)" == "x64" -cflags = $(ccommon) -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -cflags = $(cflags) -W4 -scall = -!ENDIF - -# declarations for use on Intel x86 systems -!IF "$(TARGET_CPU)" == "x86" -DLLENTRY = @12 -!ENDIF - -# declarations for use on AMD64 systems -!IF "$(TARGET_CPU)" == "x64" -DLLENTRY = -!ENDIF - -# for Windows applications -conlflags = $(lflags) -subsystem:console,$(EXEVER) -guilflags = $(lflags) -subsystem:windows,$(EXEVER) -dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll - -# basic subsystem specific libraries, less the C Run-Time -baselibs = kernel32.lib $(optlibs) $(winsocklibs) advapi32.lib -winlibs = $(baselibs) user32.lib gdi32.lib comdlg32.lib winspool.lib - -# for Windows applications that use the C Run-Time libraries -conlibs = $(baselibs) -guilibs = $(winlibs) -# -# End of VS2013 and greater stuff -#============================================= - -# -#============================================= -# Visual Studio versions >= 2013 specific stuff -#============================================= - -!IF "$(TARGET_CPU)" == "" -TARGET_CPU=x86 -!ENDIF - # Common compiler flags: # -c - compile without linking # -W3 - Set warning level to level 3 (-W4 for 64-bit compilations) @@ -413,7 +356,7 @@ lflagsUtil = $(lflags) $(conlibs) # - Game build #========================================== -GAMEPDBFILE= /DEBUG /PDB:"$(O)$(GAME).PDB" +GAMEPDBFILE= /PDB:"$(O)$(GAME).PDB" GAMEMAPFILE= /MAP:"$(O)$(GAME).MAP" LIBS= user32.lib winmm.lib $(ZLIB) @@ -588,7 +531,6 @@ VOBJ24 = $(O)track.o $(O)trap.o $(O)u_init.o $(O)uhitm.o VOBJ25 = $(O)vault.o $(O)vis_tab.o $(O)vision.o $(O)weapon.o VOBJ26 = $(O)were.o $(O)wield.o $(O)windows.o $(O)wizard.o VOBJ27 = $(O)worm.o $(O)worn.o $(O)write.o $(O)zap.o - DLBOBJ = $(O)dlb.o REGEX = $(O)cppregex.o diff --git a/util/.gitignore b/util/.gitignore index 98b003527..22139b7ab 100644 --- a/util/.gitignore +++ b/util/.gitignore @@ -8,5 +8,6 @@ lev_yacc.c tile2x11 lev_comp tileedit +tile2bmp dlb recover diff --git a/win/win32/mhaskyn.c b/win/win32/mhaskyn.c index db682be28..d3a9b3a68 100644 --- a/win/win32/mhaskyn.c +++ b/win/win32/mhaskyn.c @@ -10,6 +10,9 @@ int mswin_yes_no_dialog( const char *question, const char *choices, int def) { + UNREFERENCED_PARAMETER(question); + UNREFERENCED_PARAMETER(choices); + UNREFERENCED_PARAMETER(def); return '\032'; } diff --git a/win/win32/mhdlg.c b/win/win32/mhdlg.c index dc871aed7..4eb5af132 100644 --- a/win/win32/mhdlg.c +++ b/win/win32/mhdlg.c @@ -19,7 +19,7 @@ struct getlin_data { size_t result_size; }; -BOOL CALLBACK GetlinDlgProc(HWND, UINT, WPARAM, LPARAM); +INT_PTR CALLBACK GetlinDlgProc(HWND, UINT, WPARAM, LPARAM); int mswin_getlin_window ( const char *question, @@ -27,7 +27,7 @@ int mswin_getlin_window ( size_t result_size ) { - int ret; + INT_PTR ret; struct getlin_data data; /* initilize dialog data */ @@ -46,10 +46,10 @@ int mswin_getlin_window ( ); if( ret==-1 ) panic("Cannot create getlin window"); - return ret; + return (int)ret; } -BOOL CALLBACK GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { struct getlin_data* data; RECT main_rt, dlg_rt; @@ -69,7 +69,7 @@ BOOL CALLBACK GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara case WM_INITDIALOG: data = (struct getlin_data*)lParam; SetWindowText(hWnd, NH_A2W(data->question, wbuf, sizeof(wbuf))); - SetWindowLong(hWnd, GWL_USERDATA, lParam); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)data); /* center dialog in the main window */ GetWindowRect(hWnd, &dlg_rt); @@ -143,7 +143,7 @@ BOOL CALLBACK GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara { /* OK button was pressed */ case IDOK: - data = (struct getlin_data*)GetWindowLong(hWnd, GWL_USERDATA); + data = (struct getlin_data*)GetWindowLongPtr(hWnd, GWLP_USERDATA); SendDlgItemMessage(hWnd, IDC_GETLIN_EDIT, WM_GETTEXT, (WPARAM)sizeof(wbuf), (LPARAM)wbuf ); NH_W2A(wbuf, data->result, data->result_size); @@ -167,11 +167,11 @@ struct extcmd_data { int* selection; }; -BOOL CALLBACK ExtCmdDlgProc(HWND, UINT, WPARAM, LPARAM); +INT_PTR CALLBACK ExtCmdDlgProc(HWND, UINT, WPARAM, LPARAM); int mswin_ext_cmd_window (int* selection) { - int ret; + INT_PTR ret; struct extcmd_data data; /* init dialog data */ @@ -188,23 +188,22 @@ int mswin_ext_cmd_window (int* selection) (LPARAM)&data ); if( ret==-1 ) panic("Cannot create extcmd window"); - return ret; + return (int)ret; } -BOOL CALLBACK ExtCmdDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK ExtCmdDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { struct extcmd_data* data; RECT main_rt, dlg_rt; SIZE dlg_sz; int i; - const char *ptr; TCHAR wbuf[255]; switch (message) { case WM_INITDIALOG: data = (struct extcmd_data*)lParam; - SetWindowLong(hWnd, GWL_USERDATA, lParam); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)data); /* center dialog in the main window */ GetWindowRect(GetNHApp()->hMainWnd, &main_rt); @@ -224,8 +223,8 @@ BOOL CALLBACK ExtCmdDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara TRUE ); /* fill combobox with extended commands */ - for(i=0; (ptr=extcmdlist[i].ef_txt); i++) { - SendDlgItemMessage(hWnd, IDC_EXTCMD_LIST, LB_ADDSTRING, (WPARAM)0, (LPARAM)NH_A2W(ptr, wbuf, sizeof(wbuf)) ); + for(i=0; extcmdlist[i].ef_txt; i++) { + SendDlgItemMessage(hWnd, IDC_EXTCMD_LIST, LB_ADDSTRING, (WPARAM)0, (LPARAM)NH_A2W(extcmdlist[i].ef_txt, wbuf, sizeof(wbuf)) ); } /* set focus to the list control */ @@ -236,12 +235,12 @@ BOOL CALLBACK ExtCmdDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara break; case WM_COMMAND: - data = (struct extcmd_data*)GetWindowLong(hWnd, GWL_USERDATA); + data = (struct extcmd_data*)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch (LOWORD(wParam)) { /* OK button ws clicked */ case IDOK: - *data->selection = SendDlgItemMessage(hWnd, IDC_EXTCMD_LIST, LB_GETCURSEL, (WPARAM)0, (LPARAM)0 ); + *data->selection = (int)SendDlgItemMessage(hWnd, IDC_EXTCMD_LIST, LB_GETCURSEL, (WPARAM)0, (LPARAM)0 ); if( *data->selection==LB_ERR ) *data->selection = -1; /* Fall through. */ @@ -263,7 +262,7 @@ BOOL CALLBACK ExtCmdDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara lParam Handle to the list box */ - *data->selection = SendMessage((HWND)lParam, LB_GETCURSEL, (WPARAM)0, (LPARAM)0); + *data->selection = (int)SendMessage((HWND)lParam, LB_GETCURSEL, (WPARAM)0, (LPARAM)0); if( *data->selection==LB_ERR ) *data->selection = -1; EndDialog(hWnd, IDOK); @@ -281,14 +280,14 @@ struct plsel_data { int* selection; }; -BOOL CALLBACK PlayerSelectorDlgProc(HWND, UINT, WPARAM, LPARAM); +INT_PTR CALLBACK PlayerSelectorDlgProc(HWND, UINT, WPARAM, LPARAM); static void plselInitDialog(HWND hWnd); static void plselAdjustLists(HWND hWnd, int changed_opt); static int plselFinalSelection(HWND hWnd, int* selection); int mswin_player_selection_window ( int* selection ) { - int ret; + INT_PTR ret; struct plsel_data data; /* init dialog data */ @@ -305,10 +304,10 @@ int mswin_player_selection_window ( int* selection ) ); if( ret==-1 ) panic("Cannot create getlin window"); - return ret; + return (int)ret; } -BOOL CALLBACK PlayerSelectorDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK PlayerSelectorDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { struct plsel_data* data; RECT main_rt, dlg_rt; @@ -318,7 +317,7 @@ BOOL CALLBACK PlayerSelectorDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPAR { case WM_INITDIALOG: data = (struct plsel_data*)lParam; - SetWindowLong(hWnd, GWL_USERDATA, lParam); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)data); /* center dialog in the main window */ GetWindowRect(GetNHApp()->hMainWnd, &main_rt); @@ -348,7 +347,7 @@ BOOL CALLBACK PlayerSelectorDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPAR break; case WM_COMMAND: - data = (struct plsel_data*)GetWindowLong(hWnd, GWL_USERDATA); + data = (struct plsel_data*)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch (LOWORD(wParam)) { /* OK button was clicked */ @@ -442,7 +441,7 @@ BOOL CALLBACK PlayerSelectorDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPAR void setComboBoxValue(HWND hWnd, int combo_box, int value) { - int index_max = SendDlgItemMessage(hWnd, combo_box, CB_GETCOUNT, 0, 0); + int index_max = (int)SendDlgItemMessage(hWnd, combo_box, CB_GETCOUNT, 0, 0); int index; int value_to_set = LB_ERR; for (index = 0; index < index_max; index++) { @@ -531,7 +530,7 @@ void plselAdjustLists(HWND hWnd, int changed_sel) HWND control_role, control_race, control_gender, control_align; int initrole, initrace, initgend, initalign; int i; - int ind; + LRESULT ind; int valid_opt; TCHAR wbuf[255]; @@ -543,16 +542,16 @@ void plselAdjustLists(HWND hWnd, int changed_sel) /* get current selections */ ind = SendMessage(control_role, CB_GETCURSEL, 0, 0); - initrole = (ind==LB_ERR)? flags.initrole : SendMessage(control_role, CB_GETITEMDATA, ind, 0); + initrole = (ind==LB_ERR)? flags.initrole : (int)SendMessage(control_role, CB_GETITEMDATA, ind, 0); ind = SendMessage(control_race, CB_GETCURSEL, 0, 0); - initrace = (ind==LB_ERR)? flags.initrace : SendMessage(control_race, CB_GETITEMDATA, ind, 0); + initrace = (ind==LB_ERR)? flags.initrace : (int)SendMessage(control_race, CB_GETITEMDATA, ind, 0); ind = SendMessage(control_gender, CB_GETCURSEL, 0, 0); - initgend = (ind==LB_ERR)? flags.initgend : SendMessage(control_gender, CB_GETITEMDATA, ind, 0); + initgend = (ind==LB_ERR)? flags.initgend : (int)SendMessage(control_gender, CB_GETITEMDATA, ind, 0); ind = SendMessage(control_align, CB_GETCURSEL, 0, 0); - initalign = (ind==LB_ERR)? flags.initalign : SendMessage(control_align, CB_GETITEMDATA, ind, 0); + initalign = (ind==LB_ERR)? flags.initalign : (int)SendMessage(control_align, CB_GETITEMDATA, ind, 0); /* intialize roles list */ if( changed_sel==-1 ) { @@ -672,35 +671,37 @@ void plselAdjustLists(HWND hWnd, int changed_sel) /* player made up his mind - get final selection here */ int plselFinalSelection(HWND hWnd, int* selection) { - int ind; + UNREFERENCED_PARAMETER(selection); + + LRESULT ind; /* get current selections */ if( SendDlgItemMessage(hWnd, IDC_PLSEL_ROLE_RANDOM, BM_GETCHECK, 0, 0)==BST_CHECKED ) { flags.initrole = ROLE_RANDOM; } else { ind = SendDlgItemMessage(hWnd, IDC_PLSEL_ROLE_LIST, CB_GETCURSEL, 0, 0); - flags.initrole = (ind==LB_ERR)? ROLE_RANDOM : SendDlgItemMessage(hWnd, IDC_PLSEL_ROLE_LIST, CB_GETITEMDATA, ind, 0); + flags.initrole = (ind==LB_ERR)? ROLE_RANDOM : (int)SendDlgItemMessage(hWnd, IDC_PLSEL_ROLE_LIST, CB_GETITEMDATA, ind, 0); } if( SendDlgItemMessage(hWnd, IDC_PLSEL_RACE_RANDOM, BM_GETCHECK, 0, 0)==BST_CHECKED ) { flags.initrace = ROLE_RANDOM; } else { ind = SendDlgItemMessage(hWnd, IDC_PLSEL_RACE_LIST, CB_GETCURSEL, 0, 0); - flags.initrace = (ind==LB_ERR)? ROLE_RANDOM : SendDlgItemMessage(hWnd, IDC_PLSEL_RACE_LIST, CB_GETITEMDATA, ind, 0); + flags.initrace = (ind==LB_ERR)? ROLE_RANDOM : (int)SendDlgItemMessage(hWnd, IDC_PLSEL_RACE_LIST, CB_GETITEMDATA, ind, 0); } if( SendDlgItemMessage(hWnd, IDC_PLSEL_GENDER_RANDOM, BM_GETCHECK, 0, 0)==BST_CHECKED ) { flags.initgend = ROLE_RANDOM; } else { ind = SendDlgItemMessage(hWnd, IDC_PLSEL_GENDER_LIST, CB_GETCURSEL, 0, 0); - flags.initgend = (ind==LB_ERR)? ROLE_RANDOM : SendDlgItemMessage(hWnd, IDC_PLSEL_GENDER_LIST, CB_GETITEMDATA, ind, 0); + flags.initgend = (ind==LB_ERR)? ROLE_RANDOM : (int)SendDlgItemMessage(hWnd, IDC_PLSEL_GENDER_LIST, CB_GETITEMDATA, ind, 0); } if( SendDlgItemMessage(hWnd, IDC_PLSEL_ALIGN_RANDOM, BM_GETCHECK, 0, 0)==BST_CHECKED ) { flags.initalign = ROLE_RANDOM; } else { ind = SendDlgItemMessage(hWnd, IDC_PLSEL_ALIGN_LIST, CB_GETCURSEL, 0, 0); - flags.initalign = (ind==LB_ERR)? ROLE_RANDOM : SendDlgItemMessage(hWnd, IDC_PLSEL_ALIGN_LIST, CB_GETITEMDATA, ind, 0); + flags.initalign = (ind==LB_ERR)? ROLE_RANDOM : (int)SendDlgItemMessage(hWnd, IDC_PLSEL_ALIGN_LIST, CB_GETITEMDATA, ind, 0); } diff --git a/win/win32/mhfont.c b/win/win32/mhfont.c index cfbec944e..7cebb921b 100644 --- a/win/win32/mhfont.c +++ b/win/win32/mhfont.c @@ -25,7 +25,6 @@ static void __cdecl font_table_cleanup(void); void mswin_init_splashfonts(HWND hWnd) { HDC hdc = GetDC(hWnd); - HFONT fnt = NULL; LOGFONT lgfnt; ZeroMemory( &lgfnt, sizeof(lgfnt) ); lgfnt.lfHeight = -80; // height of font diff --git a/win/win32/mhmain.c b/win/win32/mhmain.c index 4373d58aa..bf13b22da 100644 --- a/win/win32/mhmain.c +++ b/win/win32/mhmain.c @@ -188,7 +188,7 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar if( !data ) panic("out of memory"); ZeroMemory(data, sizeof(NHMainWindow)); data->mapAcsiiModeSave = MAP_MODE_ASCII12x16; - SetWindowLong(hWnd, GWL_USERDATA, (LONG)data); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)data); /* update menu items */ CheckMenuItem( @@ -214,7 +214,7 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar case WM_KEYDOWN: { - data = (PNHMainWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMainWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); /* translate arrow keys into nethack commands */ switch (wParam) @@ -525,8 +525,8 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar WM_QUIT somehow */ /* clean up */ - free( (PNHMainWindow)GetWindowLong(hWnd, GWL_USERDATA) ); - SetWindowLong(hWnd, GWL_USERDATA, (LONG)0); + free( (PNHMainWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA) ); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)0); // PostQuitMessage(0); exit(1); @@ -540,6 +540,10 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { + UNREFERENCED_PARAMETER(hWnd); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + switch(wParam) { /* new window was just added */ @@ -585,7 +589,7 @@ void mswin_layout_main_window(HWND changed_child) if( GetNHApp()->bAutoLayout ) { GetClientRect(GetNHApp()->hMainWnd, &client_rt); - data = (PNHMainWindow)GetWindowLong(GetNHApp()->hMainWnd, GWL_USERDATA); + data = (PNHMainWindow)GetWindowLongPtr(GetNHApp()->hMainWnd, GWLP_USERDATA); /* get sizes of child windows */ wnd_status = mswin_hwnd_from_winid(WIN_STATUS); @@ -752,10 +756,12 @@ void mswin_layout_main_window(HWND changed_child) LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { + UNREFERENCED_PARAMETER(lParam); + int wmId, wmEvent; PNHMainWindow data; - data = (PNHMainWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMainWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); @@ -972,6 +978,8 @@ LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) // Mesage handler for about box. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { + UNREFERENCED_PARAMETER(lParam); + char buf[BUFSZ]; TCHAR wbuf[BUFSZ]; RECT main_rt, dlg_rt; @@ -1040,7 +1048,7 @@ void mswin_select_map_mode(int mode) winid map_id; map_id = WIN_MAP; - data = (PNHMainWindow)GetWindowLong(GetNHApp()->hMainWnd, GWL_USERDATA); + data = (PNHMainWindow)GetWindowLongPtr(GetNHApp()->hMainWnd, GWLP_USERDATA); /* override for Rogue level */ if( Is_rogue_level(&u.uz) && !IS_MAP_ASCII(mode) ) return; diff --git a/win/win32/mhmap.c b/win/win32/mhmap.c index 5a3c2e1b2..c9073d03a 100644 --- a/win/win32/mhmap.c +++ b/win/win32/mhmap.c @@ -106,7 +106,7 @@ void mswin_map_stretch(HWND hWnd, LPSIZE lpsz, BOOL redraw) wnd_size.cy = client_rt.bottom - client_rt.top; /* set new screen tile size */ - data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMapWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); data->xScrTile = max(1, (data->bFitToScreenMode? wnd_size.cx : lpsz->cx) / COLNO); data->yScrTile = @@ -200,7 +200,7 @@ int mswin_map_mode(HWND hWnd, int mode) int oldMode; SIZE mapSize; - data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMapWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); if( mode == data->mapMode ) return mode; oldMode = data->mapMode; @@ -302,6 +302,8 @@ int mswin_map_mode(HWND hWnd, int mode) mswin_map_stretch(hWnd, &mapSize, TRUE); + mswin_update_inventory(); /* for perm_invent to hide/show tiles */ + return oldMode; } @@ -333,7 +335,7 @@ LRESULT CALLBACK MapWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara { PNHMapWindow data; - data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMapWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch (message) { case WM_CREATE: @@ -412,7 +414,7 @@ LRESULT CALLBACK MapWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara case WM_DESTROY: if( data->hMapFont ) DeleteObject(data->hMapFont); free(data); - SetWindowLong(hWnd, GWL_USERDATA, (LONG)0); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)0); break; default: @@ -427,7 +429,7 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) PNHMapWindow data; RECT rt; - data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMapWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch(wParam) { case MSNH_MSG_PRINT_GLYPH: { @@ -557,6 +559,9 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) /* on WM_CREATE */ void onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam) { + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + PNHMapWindow data; int i,j; @@ -575,7 +580,7 @@ void onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam) data->xScrTile = GetNHApp()->mapTile_X; data->yScrTile = GetNHApp()->mapTile_Y; - SetWindowLong(hWnd, GWL_USERDATA, (LONG)data); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)data); } /* on WM_PAINT */ @@ -590,7 +595,7 @@ void onPaint(HWND hWnd) int i, j; /* get window data */ - data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMapWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); hDC = BeginPaint(hWnd, &ps); @@ -740,13 +745,15 @@ void onPaint(HWND hWnd) /* on WM_VSCROLL */ void onMSNH_VScroll(HWND hWnd, WPARAM wParam, LPARAM lParam) { + UNREFERENCED_PARAMETER(lParam); + PNHMapWindow data; SCROLLINFO si; int yNewPos; int yDelta; /* get window data */ - data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMapWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch(LOWORD (wParam)) { @@ -798,13 +805,15 @@ void onMSNH_VScroll(HWND hWnd, WPARAM wParam, LPARAM lParam) /* on WM_HSCROLL */ void onMSNH_HScroll(HWND hWnd, WPARAM wParam, LPARAM lParam) { + UNREFERENCED_PARAMETER(lParam); + PNHMapWindow data; SCROLLINFO si; int xNewPos; int xDelta; /* get window data */ - data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMapWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch(LOWORD (wParam)) { diff --git a/win/win32/mhmenu.c b/win/win32/mhmenu.c index c9c64f08b..5665b09a6 100644 --- a/win/win32/mhmenu.c +++ b/win/win32/mhmenu.c @@ -75,7 +75,7 @@ static WNDPROC editControlWndProc = NULL; #define NHMENU_IS_SELECTED(item) ((item).count!=0) #define NHMENU_HAS_GLYPH(item) ((item).glyph!=NO_GLYPH) -BOOL CALLBACK MenuWndProc(HWND, UINT, WPARAM, LPARAM); +INT_PTR CALLBACK MenuWndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK NHMenuListWndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK NHMenuTextWndProc(HWND, UINT, WPARAM, LPARAM); static void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam); @@ -144,7 +144,7 @@ int mswin_menu_window_select_menu (HWND hWnd, int how, MENU_ITEM_P ** _selected, *_selected = NULL; ret_val = -1; - data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMenuWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); /* force activate for certain menu types */ if( data->type == MENU_TYPE_MENU && @@ -247,7 +247,7 @@ int mswin_menu_window_select_menu (HWND hWnd, int how, MENU_ITEM_P ** _selected, return ret_val; } /*-----------------------------------------------------------------------------*/ -BOOL CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PNHMenuWindow data; HWND control; @@ -255,7 +255,7 @@ BOOL CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) TCHAR title[MAX_LOADSTRING]; - data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMenuWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch (message) { case WM_INITDIALOG: @@ -269,7 +269,7 @@ BOOL CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) data->bmpCheckedCount = LoadBitmap(GetNHApp()->hApp, MAKEINTRESOURCE(IDB_MENU_SEL_COUNT)); data->bmpNotChecked = LoadBitmap(GetNHApp()->hApp, MAKEINTRESOURCE(IDB_MENU_UNSEL)); data->is_active = FALSE; - SetWindowLong(hWnd, GWL_USERDATA, (LONG)data); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)data); /* set font for the text cotrol */ control = GetDlgItem(hWnd, IDC_MENU_TEXT); @@ -278,8 +278,8 @@ BOOL CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ReleaseDC(control, hdc); /* subclass edit control */ - editControlWndProc = (WNDPROC)GetWindowLong(control, GWL_WNDPROC); - SetWindowLong(control, GWL_WNDPROC, (LONG)NHMenuTextWndProc); + editControlWndProc = (WNDPROC)GetWindowLongPtr(control, GWLP_WNDPROC); + SetWindowLongPtr(control, GWLP_WNDPROC, (LONG_PTR)NHMenuTextWndProc); /* Even though the dialog has no caption, you can still set the title which shows on Alt-Tab */ @@ -491,7 +491,7 @@ BOOL CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if( data->text.text ) free(data->text.text); } free(data); - SetWindowLong(hWnd, GWL_USERDATA, (LONG)0); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)0); } return TRUE; } @@ -502,7 +502,7 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { PNHMenuWindow data; - data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMenuWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch( wParam ) { case MSNH_MSG_PUTSTR: { @@ -660,7 +660,7 @@ void LayoutMenu(HWND hWnd) POINT pt_elem, pt_ok, pt_cancel; SIZE sz_elem, sz_ok, sz_cancel; - data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMenuWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); menu_ok = GetDlgItem(hWnd, IDOK); menu_cancel = GetDlgItem(hWnd, IDCANCEL); @@ -730,7 +730,7 @@ void SetMenuType(HWND hWnd, int type) PNHMenuWindow data; HWND list, text; - data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMenuWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); data->type = type; @@ -765,7 +765,7 @@ void SetMenuListType(HWND hWnd, int how) LVCOLUMN lvcol; LRESULT fnt; - data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMenuWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); if( data->type != MENU_TYPE_MENU ) return; data->how = how; @@ -808,8 +808,8 @@ void SetMenuListType(HWND hWnd, int how) if( !control ) panic( "cannot create menu control" ); /* install the hook for the control window procedure */ - wndProcListViewOrig = (WNDPROC)GetWindowLong(control, GWL_WNDPROC); - SetWindowLong(control, GWL_WNDPROC, (LONG)NHMenuListWndProc); + wndProcListViewOrig = (WNDPROC)GetWindowLongPtr(control, GWLP_WNDPROC); + SetWindowLongPtr(control, GWLP_WNDPROC, (LONG_PTR)NHMenuListWndProc); /* set control colors */ ListView_SetBkColor(control, @@ -842,7 +842,7 @@ void SetMenuListType(HWND hWnd, int how) lvitem.state = data->menu.items[i].presel? LVIS_SELECTED : 0; lvitem.pszText = NH_A2W(buf, wbuf, BUFSZ); lvitem.lParam = (LPARAM)&data->menu.items[i]; - nItem = SendMessage(control, LB_ADDSTRING, (WPARAM)0, (LPARAM) buf); + nItem = (int)SendMessage(control, LB_ADDSTRING, (WPARAM)0, (LPARAM) buf); if( ListView_InsertItem(control, &lvitem)==-1 ) { panic("cannot insert menu item"); } @@ -854,7 +854,7 @@ HWND GetMenuControl(HWND hWnd) { PNHMenuWindow data; - data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMenuWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(data->type==MENU_TYPE_TEXT) { return GetDlgItem(hWnd, IDC_MENU_TEXT); @@ -865,6 +865,8 @@ HWND GetMenuControl(HWND hWnd) /*-----------------------------------------------------------------------------*/ BOOL onMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam) { + UNREFERENCED_PARAMETER(wParam); + LPMEASUREITEMSTRUCT lpmis; TEXTMETRIC tm; HGDIOBJ saveFont; @@ -874,7 +876,7 @@ BOOL onMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam) int i; lpmis = (LPMEASUREITEMSTRUCT) lParam; - data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMenuWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); GetClientRect(GetMenuControl(hWnd), &list_rect); hdc = GetDC(GetMenuControl(hWnd)); @@ -900,6 +902,8 @@ BOOL onMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam) /*-----------------------------------------------------------------------------*/ BOOL onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam) { + UNREFERENCED_PARAMETER(wParam); + LPDRAWITEMSTRUCT lpdis; PNHMenuItem item; PNHMenuWindow data; @@ -924,7 +928,7 @@ BOOL onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam) /* If there are no list box items, skip this message. */ if (lpdis->itemID == -1) return FALSE; - data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMenuWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); item = &data->menu.items[lpdis->itemID]; @@ -1128,7 +1132,7 @@ BOOL onListChar(HWND hWnd, HWND hwndList, WORD ch) int curIndex, topIndex, pageSize; boolean is_accelerator = FALSE; - data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMenuWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch( ch ) { case MENU_FIRST_PAGE: @@ -1445,7 +1449,7 @@ void mswin_menu_window_size (HWND hWnd, LPSIZE sz) RECT rt, wrt; int extra_cx; - data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMenuWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(data) { control = GetMenuControl(hWnd); @@ -1459,10 +1463,10 @@ void mswin_menu_window_size (HWND hWnd, LPSIZE sz) extra_cx = (wrt.right-wrt.left) - sz->cx; if( data->type==MENU_TYPE_MENU ) { - sz->cx = max(sz->cx, data->menu.menu_cx + GetSystemMetrics(SM_CXVSCROLL) ); + sz->cx = data->menu.menu_cx + GetSystemMetrics(SM_CXVSCROLL); } else { /* Use the width of the text box */ - sz->cx = max( sz->cx, data->text.text_box_size.cx + 2*GetSystemMetrics(SM_CXVSCROLL)); + sz->cx = data->text.text_box_size.cx + 2*GetSystemMetrics(SM_CXVSCROLL); } sz->cx += extra_cx; } else { diff --git a/win/win32/mhmsg.h b/win/win32/mhmsg.h index 8030b4391..8e48a3b01 100644 --- a/win/win32/mhmsg.h +++ b/win/win32/mhmsg.h @@ -28,9 +28,9 @@ typedef struct mswin_nhmsg_add_wnd { } MSNHMsgAddWnd, *PMSNHMsgAddWnd; typedef struct mswin_nhmsg_putstr { - int attr; - const char* text; - boolean append; + int attr; + const char* text; + int append; } MSNHMsgPutstr, *PMSNHMsgPutstr; typedef struct mswin_nhmsg_print_glyph { diff --git a/win/win32/mhmsgwnd.c b/win/win32/mhmsgwnd.c index a718db959..6522be6c4 100644 --- a/win/win32/mhmsgwnd.c +++ b/win/win32/mhmsgwnd.c @@ -161,9 +161,9 @@ LRESULT CALLBACK NHMessageWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM case WM_DESTROY: { PNHMessageWindow data; - data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMessageWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); free(data); - SetWindowLong(hWnd, GWL_USERDATA, (LONG)0); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)0); } break; case WM_SIZE: @@ -174,7 +174,7 @@ LRESULT CALLBACK NHMessageWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM PNHMessageWindow data; RECT rt; - data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMessageWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); xNewSize = LOWORD(lParam); yNewSize = HIWORD(lParam); @@ -239,7 +239,7 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { PNHMessageWindow data; - data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMessageWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch( wParam ) { case MSNH_MSG_PUTSTR: { @@ -273,7 +273,7 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) /* get the input */ while (!okkey) { - char c = mswin_nhgetch(); + int c = mswin_nhgetch(); switch (c) { @@ -378,12 +378,14 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) void onMSNH_VScroll(HWND hWnd, WPARAM wParam, LPARAM lParam) { + UNREFERENCED_PARAMETER(lParam); + PNHMessageWindow data; SCROLLINFO si; int yInc; /* get window data */ - data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMessageWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); ZeroMemory(&si, sizeof(si)); si.cbSize = sizeof(si); @@ -460,7 +462,7 @@ void onMSNH_HScroll(HWND hWnd, WPARAM wParam, LPARAM lParam) int xInc; /* get window data */ - data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMessageWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); ZeroMemory(&si, sizeof(si)); si.cbSize = sizeof(si); @@ -564,14 +566,13 @@ void onPaint(HWND hWnd) TCHAR wbuf[MAXWINDOWTEXT+2]; size_t wlen; COLORREF OldBg, OldFg; - int do_more = 0; hdc = BeginPaint(hWnd, &ps); OldBg = SetBkColor(hdc, message_bg_brush ? message_bg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_BG_MSG)); OldFg = setMsgTextColor(hdc, 0); - data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMessageWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); GetClientRect(hWnd, &client_rt); @@ -652,6 +653,9 @@ void onPaint(HWND hWnd) void onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam) { + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + PNHMessageWindow data; SIZE dummy; @@ -660,7 +664,7 @@ void onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam) if( !data ) panic("out of memory"); ZeroMemory(data, sizeof(NHMessageWindow)); data->max_text = MAXWINDOWTEXT; - SetWindowLong(hWnd, GWL_USERDATA, (LONG)data); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)data); /* re-calculate window size (+ font size) */ mswin_message_window_size(hWnd, &dummy); @@ -674,7 +678,7 @@ void mswin_message_window_size (HWND hWnd, LPSIZE sz) PNHMessageWindow data; RECT rt, client_rt; - data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMessageWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); if( !data ) return; /* -- Calculate the font size -- */ @@ -715,7 +719,7 @@ BOOL can_append_text(HWND hWnd, int attr, const char* text ) RECT draw_rt; BOOL retval = FALSE; - data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMessageWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); /* cannot append if lines_not_seen is 0 (beginning of the new turn */ if( data->lines_not_seen==0 ) return FALSE; @@ -760,13 +764,11 @@ BOOL more_prompt_check(HWND hWnd) HDC hdc; HGDIOBJ saveFont; RECT client_rt, draw_rt; - BOOL retval = FALSE; - int visible_lines = 0; int i; int remaining_height; char tmptext[MAXWINDOWTEXT+1]; - data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHMessageWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); if( data->lines_not_seen==0 ) return FALSE; /* don't bother checking - nothig to "more" */ if( data->lines_not_seen>=MSG_LINES ) return TRUE; /* history size exceeded - always more */ diff --git a/win/win32/mhrip.c b/win/win32/mhrip.c index 38dd0a520..990b3fed3 100644 --- a/win/win32/mhrip.c +++ b/win/win32/mhrip.c @@ -28,7 +28,7 @@ typedef struct mswin_nethack_text_window { TCHAR* rip_text; } NHRIPWindow, *PNHRIPWindow; -BOOL CALLBACK NHRIPWndProc(HWND, UINT, WPARAM, LPARAM); +INT_PTR CALLBACK NHRIPWndProc(HWND, UINT, WPARAM, LPARAM); static void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam); HWND mswin_init_RIP_window () { @@ -47,7 +47,7 @@ HWND mswin_init_RIP_window () { if( !data ) panic("out of memory"); ZeroMemory(data, sizeof(NHRIPWindow)); - SetWindowLong(ret, GWL_USERDATA, (LONG)data); + SetWindowLongPtr(ret, GWLP_USERDATA, (LONG_PTR)data); return ret; } @@ -63,7 +63,7 @@ void mswin_display_RIP_window (HWND hWnd) HDC hdc; HFONT OldFont; - data = (PNHRIPWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHRIPWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); GetNHApp()->hPopupWnd = hWnd; mapWnd = mswin_hwnd_from_winid(WIN_MAP); @@ -118,12 +118,12 @@ void mswin_display_RIP_window (HWND hWnd) GetNHApp()->hPopupWnd = NULL; } -BOOL CALLBACK NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PNHRIPWindow data; - data = (PNHRIPWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHRIPWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch (message) { case WM_INITDIALOG: @@ -218,7 +218,7 @@ BOOL CALLBACK NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam if( data->rip_text ) free(data->rip_text); if (data->rip_bmp != NULL) DeleteObject(data->rip_bmp); free(data); - SetWindowLong(hWnd, GWL_USERDATA, (LONG)0); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)0); } break; @@ -230,7 +230,7 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { PNHRIPWindow data; static int InRipText = 1; - data = (PNHRIPWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHRIPWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch( wParam ) { case MSNH_MSG_PUTSTR: { PMSNHMsgPutstr msg_data = (PMSNHMsgPutstr)lParam; diff --git a/win/win32/mhsplash.c b/win/win32/mhsplash.c index 76345dd64..9ad8f5e78 100644 --- a/win/win32/mhsplash.c +++ b/win/win32/mhsplash.c @@ -16,7 +16,7 @@ PNHWinApp GetNHApp(void); -BOOL CALLBACK NHSplashWndProc(HWND, UINT, WPARAM, LPARAM); +INT_PTR CALLBACK NHSplashWndProc(HWND, UINT, WPARAM, LPARAM); #define SPLASH_WIDTH 440 #define SPLASH_HEIGHT 322 @@ -177,8 +177,10 @@ void mswin_display_splash_window (BOOL show_ver) mswin_destroy_splashfonts(); } -BOOL CALLBACK NHSplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK NHSplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + UNREFERENCED_PARAMETER(lParam); + HDC hdc; switch (message) { diff --git a/win/win32/mhstatus.c b/win/win32/mhstatus.c index b81988ad5..05a4c57e8 100644 --- a/win/win32/mhstatus.c +++ b/win/win32/mhstatus.c @@ -64,7 +64,7 @@ HWND mswin_init_status_window () { if( !data ) panic("out of memory"); ZeroMemory(data, sizeof(NHStatusWindow)); - SetWindowLong(ret, GWL_USERDATA, (LONG)data); + SetWindowLongPtr(ret, GWLP_USERDATA, (LONG_PTR)data); return ret; } @@ -96,7 +96,7 @@ LRESULT CALLBACK StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP HDC hdc; PNHStatusWindow data; - data = (PNHStatusWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHStatusWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch (message) { case WM_MSNH_COMMAND: { @@ -174,7 +174,7 @@ LRESULT CALLBACK StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP case WM_DESTROY: free(data); - SetWindowLong(hWnd, GWL_USERDATA, (LONG)0); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)0); break; case WM_SETFOCUS: @@ -194,20 +194,24 @@ void mswin_status_window_size (HWND hWnd, LPSIZE sz) HDC hdc; PNHStatusWindow data; RECT rt; - GetWindowRect(hWnd, &rt); - sz->cx = rt.right - rt.left; - sz->cy = rt.bottom - rt.top; + SIZE text_sz; + + GetClientRect(hWnd, &rt); - data = (PNHStatusWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHStatusWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(data) { hdc = GetDC(hWnd); saveFont = SelectObject(hdc, mswin_get_font(NHW_STATUS, ATR_NONE, hdc, FALSE)); + GetTextExtentPoint32(hdc, _T("W"), 1, &text_sz); GetTextMetrics(hdc, &tm); - sz->cy = tm.tmHeight * NHSW_LINES + 2*GetSystemMetrics(SM_CYSIZEFRAME); + rt.bottom = rt.top + text_sz.cy*NHSW_LINES; SelectObject(hdc, saveFont); ReleaseDC(hWnd, hdc); } + AdjustWindowRect(&rt, GetWindowLong(hWnd, GWL_STYLE), FALSE); + sz->cx = rt.right - rt.left; + sz->cy = rt.bottom - rt.top; } diff --git a/win/win32/mhtext.c b/win/win32/mhtext.c index 03b01132d..ab4853834 100644 --- a/win/win32/mhtext.c +++ b/win/win32/mhtext.c @@ -19,7 +19,7 @@ static WNDPROC editControlWndProc = 0; #define DEFAULT_COLOR_BG_TEXT COLOR_WINDOW #define DEFAULT_COLOR_FG_TEXT COLOR_WINDOWTEXT -BOOL CALLBACK NHTextWndProc(HWND, UINT, WPARAM, LPARAM); +INT_PTR CALLBACK NHTextWndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK NHEditHookWndProc(HWND, UINT, WPARAM, LPARAM); static void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam); static void LayoutText(HWND hwnd); @@ -64,7 +64,7 @@ HWND mswin_init_text_window () { data = (PNHTextWindow)malloc(sizeof(NHTextWindow)); if( !data ) panic("out of memory"); ZeroMemory(data, sizeof(NHTextWindow)); - SetWindowLong(ret, GWL_USERDATA, (LONG)data); + SetWindowLongPtr(ret, GWLP_USERDATA, (LONG_PTR)data); return ret; } @@ -72,7 +72,7 @@ void mswin_display_text_window (HWND hWnd) { PNHTextWindow data; - data = (PNHTextWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHTextWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); if( data && data->window_text ) { HWND control; control = GetDlgItem(hWnd, IDC_TEXT_CONTROL); @@ -84,14 +84,14 @@ void mswin_display_text_window (HWND hWnd) mswin_popup_destroy(hWnd); } -BOOL CALLBACK NHTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK NHTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HWND control; HDC hdc; PNHTextWindow data; TCHAR title[MAX_LOADSTRING]; - data = (PNHTextWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHTextWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch (message) { case WM_INITDIALOG: @@ -106,8 +106,8 @@ BOOL CALLBACK NHTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara ReleaseDC(control, hdc); /* subclass edit control */ - editControlWndProc = (WNDPROC)GetWindowLong(control, GWL_WNDPROC); - SetWindowLong(control, GWL_WNDPROC, (LONG)NHEditHookWndProc); + editControlWndProc = (WNDPROC)GetWindowLongPtr(control, GWLP_WNDPROC); + SetWindowLongPtr(control, GWLP_WNDPROC, (LONG_PTR)NHEditHookWndProc); SetFocus(control); @@ -180,7 +180,7 @@ BOOL CALLBACK NHTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara if( data ) { if( data->window_text ) free(data->window_text); free(data); - SetWindowLong(hWnd, GWL_USERDATA, (LONG)0); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)0); } break; @@ -192,7 +192,7 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { PNHTextWindow data; - data = (PNHTextWindow)GetWindowLong(hWnd, GWL_USERDATA); + data = (PNHTextWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch( wParam ) { case MSNH_MSG_PUTSTR: { PMSNHMsgPutstr msg_data = (PMSNHMsgPutstr)lParam; diff --git a/win/win32/mswproc.c b/win/win32/mswproc.c index 7d2177286..b612f79aa 100644 --- a/win/win32/mswproc.c +++ b/win/win32/mswproc.c @@ -31,6 +31,8 @@ extern winid WIN_STATUS; +#define NHTRACE_LOG "nhtrace.log" + #ifdef _DEBUG extern void logDebug(const char *fmt, ...); #else @@ -155,12 +157,16 @@ init_nhwindows(int* argcp, char** argv) */ void mswin_init_nhwindows(int* argc, char** argv) { + UNREFERENCED_PARAMETER(argc); + UNREFERENCED_PARAMETER(argv); + logDebug("mswin_init_nhwindows()\n"); #ifdef _DEBUG + if (showdebug(NHTRACE_LOG)) { /* truncate trace file */ - FILE *dfp = fopen("nhtrace.log", "w"); + FILE *dfp = fopen(NHTRACE_LOG, "w"); fclose(dfp); } #endif @@ -1966,6 +1972,8 @@ char *mswin_getmsghistory(BOOLEAN_P init) void mswin_putmsghistory(const char * msg, BOOLEAN_P restoring) { + UNREFERENCED_PARAMETER(restoring); + BOOL save_sound_opt; if (!msg) return; /* end of message history restore */ @@ -2147,8 +2155,11 @@ void mswin_popup_destroy(HWND hWnd) void logDebug(const char *fmt, ...) { - FILE *dfp = fopen("nhtrace.log", "a"); + FILE *dfp; + if (!showdebug(NHTRACE_LOG)) return; + + dfp = fopen(NHTRACE_LOG, "a"); if (dfp) { va_list args; diff --git a/win/win32/vs2010/NetHackW.vcxproj b/win/win32/vs2010/NetHackW.vcxproj index c90ff1112..3919d8cc7 100644 --- a/win/win32/vs2010/NetHackW.vcxproj +++ b/win/win32/vs2010/NetHackW.vcxproj @@ -637,6 +637,15 @@ copy ..\sys\winnt\defaults.nh ..\binary\defaults.nh %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories) diff --git a/win/win32/winhack.c b/win/win32/winhack.c index dd0f6c14a..c8498f08f 100644 --- a/win/win32/winhack.c +++ b/win/win32/winhack.c @@ -74,6 +74,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) { + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + UNREFERENCED_PARAMETER(nCmdShow); + INITCOMMONCONTROLSEX InitCtrls; int argc; char* argv[MAX_CMDLINE_PARAM];