From: Pasi Kallinen Date: Thu, 30 Dec 2021 16:46:30 +0000 (+0200) Subject: Make extended commands return defined flags X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d53cd28d467a3e792be15b28d26dcbfd586bc825;p=nethack Make extended commands return defined flags Instead of returning 0 or 1, we'll now use ECMD_OK or ECMD_TURN. These have the same meaning as the hardcoded numbers; ECMD_TURN means the command uses a turn. In future, could add eg. a flag denoting "user cancelled command" or "command failed", and should clear eg. the cmdq. Mostly this was simply replacing return values with the defines in the extended commands, so hopefully I didn't break anything. --- diff --git a/include/func_tab.h b/include/func_tab.h index ae4055f46..878b12817 100644 --- a/include/func_tab.h +++ b/include/func_tab.h @@ -18,7 +18,7 @@ struct ext_func_tab { uchar key; const char *ef_txt, *ef_desc; - int (*ef_funct)(void); + int (*ef_funct)(void); /* must return ECMD_foo flags */ int flags; const char *f_text; }; diff --git a/include/hack.h b/include/hack.h index 8d651f211..dba6bcc1b 100644 --- a/include/hack.h +++ b/include/hack.h @@ -537,6 +537,10 @@ enum bodypart_types { #define BRK_KNOWN2NOTBREAK 8 #define BRK_KNOWN_OUTCOME (BRK_KNOWN2BREAK | BRK_KNOWN2NOTBREAK) +/* extended command return values */ +#define ECMD_OK 0x00 /* cmd done successfully */ +#define ECMD_TIME 0x01 /* cmd took time, uses up a turn */ + /* values returned from getobj() callback functions */ enum getobj_callback_returns { /* generally invalid - can't be used for this purpose. will give a "silly diff --git a/src/apply.c b/src/apply.c index 424deb4f6..bca5a82e0 100644 --- a/src/apply.c +++ b/src/apply.c @@ -54,14 +54,14 @@ use_camera(struct obj *obj) if (Underwater) { pline("Using your camera underwater would void the warranty."); - return 0; + return ECMD_OK; } if (!getdir((char *) 0)) - return 0; + return ECMD_OK; if (obj->spe <= 0) { pline1(nothing_happens); - return 1; + return ECMD_TIME; } consume_obj_charge(obj, TRUE); @@ -86,7 +86,7 @@ use_camera(struct obj *obj) to be deferred until after flash_hits_mon() */ transient_light_cleanup(); } - return 1; + return ECMD_TIME; } static int @@ -96,10 +96,10 @@ use_towel(struct obj *obj) if (!freehand()) { You("have no free %s!", body_part(HAND)); - return 0; + return ECMD_OK; } else if (obj == ublindf) { You("cannot use it while you're wearing it!"); - return 0; + return ECMD_OK; } else if (obj->cursed) { long old; @@ -111,7 +111,7 @@ use_towel(struct obj *obj) (old ? "are filthier than ever" : "get slimy")); if (is_wet_towel(obj)) dry_a_towel(obj, -1, drying_feedback); - return 1; + return ECMD_TIME; case 1: if (!ublindf) { old = u.ucreamed; @@ -138,7 +138,7 @@ use_towel(struct obj *obj) } if (is_wet_towel(obj)) dry_a_towel(obj, -1, drying_feedback); - return 1; + return ECMD_TIME; case 0: break; } @@ -150,7 +150,7 @@ use_towel(struct obj *obj) !uarmg ? makeplural(body_part(HAND)) : gloves_simple_name(uarmg)); if (is_wet_towel(obj)) dry_a_towel(obj, -1, drying_feedback); - return 1; + return ECMD_TIME; } else if (u.ucreamed) { Blinded -= u.ucreamed; u.ucreamed = 0; @@ -165,13 +165,13 @@ use_towel(struct obj *obj) } if (is_wet_towel(obj)) dry_a_towel(obj, -1, drying_feedback); - return 1; + return ECMD_TIME; } Your("%s and %s are already clean.", body_part(FACE), makeplural(body_part(HAND))); - return 0; + return ECMD_OK; } /* maybe give a stethoscope message based on floor objects */ @@ -232,7 +232,7 @@ its_dead(int rx, int ry, int *resp) } /* variations on "He's dead, Jim." (Star Trek's Dr McCoy) */ You_hear("a voice say, \"%s, Jim.\"", buf); - *resp = 1; + *resp = ECMD_TIME; return TRUE; } else if (corpse) { @@ -307,18 +307,18 @@ use_stethoscope(struct obj *obj) if (nohands(g.youmonst.data)) { You("have no hands!"); /* not `body_part(HAND)' */ - return 0; + return ECMD_OK; } else if (Deaf) { You_cant("hear anything!"); - return 0; + return ECMD_OK; } else if (!freehand()) { You("have no free %s.", body_part(HAND)); - return 0; + return ECMD_OK; } if (!getdir((char *) 0)) - return 0; + return ECMD_OK; - res = (g.hero_seq == g.context.stethoscope_seq); + res = (g.hero_seq == g.context.stethoscope_seq) ? ECMD_TIME : ECMD_OK; g.context.stethoscope_seq = g.hero_seq; g.bhitpos.x = u.ux, g.bhitpos.y = u.uy; /* tentative, reset below */ @@ -363,7 +363,7 @@ use_stethoscope(struct obj *obj) ry = u.uy + u.dy; if (!isok(rx, ry)) { You_hear("a faint typing noise."); - return 0; + return ECMD_OK; } if ((mtmp = m_at(rx, ry)) != 0) { const char *mnm = x_monnam(mtmp, ARTICLE_A, (const char *) 0, @@ -618,15 +618,15 @@ use_leash(struct obj *obj) ? "unleash %s from inside." : "unleash anything from inside %s."), noit_mon_nam(u.ustuck)); - return 0; + return ECMD_OK; } if (!obj->leashmon && number_leashed() >= MAXLEASHED) { You("cannot leash any more pets."); - return 0; + return ECMD_OK; } if (!get_adjacent_loc((char *) 0, (char *) 0, u.ux, u.uy, &cc)) - return 0; + return ECMD_OK; if (cc.x == u.ux && cc.y == u.uy) { if (u.usteed && u.dz > 0) { @@ -635,7 +635,7 @@ use_leash(struct obj *obj) goto got_target; } pline("Leash yourself? Very funny..."); - return 0; + return ECMD_OK; } /* @@ -645,7 +645,7 @@ use_leash(struct obj *obj) if (!(mtmp = m_at(cc.x, cc.y))) { There("is no creature there."); (void) unmap_invisible(cc.x, cc.y); - return 1; + return ECMD_TIME; } spotmon = canspotmon(mtmp); @@ -704,7 +704,7 @@ use_leash(struct obj *obj) spotmon ? "your " : "", l_monnam(mtmp)); } } - return 1; + return ECMD_TIME; } /* assuming mtmp->mleashed has been checked */ @@ -853,7 +853,7 @@ use_mirror(struct obj *obj) boolean vis, invis_mirror, useeit, monable; if (!getdir((char *) 0)) - return 0; + return ECMD_OK; invis_mirror = Invis; useeit = !Blind && (!invis_mirror || See_invisible); uvisage = beautiful(); @@ -863,7 +863,7 @@ use_mirror(struct obj *obj) pline_The("%s fogs up and doesn't reflect!", mirror); else pline("Nothing seems to happen."); - return 1; + return ECMD_TIME; } if (!u.dx && !u.dy && !u.dz) { if (!useeit) { @@ -901,31 +901,31 @@ use_mirror(struct obj *obj) You("look as %s as ever.", uvisage); } } - return 1; + return ECMD_TIME; } if (u.uswallow) { if (useeit) You("reflect %s %s.", s_suffix(mon_nam(u.ustuck)), mbodypart(u.ustuck, STOMACH)); - return 1; + return ECMD_TIME; } if (Underwater) { if (useeit) You(Hallucination ? "give the fish a chance to fix their makeup." : "reflect the murky water."); - return 1; + return ECMD_TIME; } if (u.dz) { if (useeit) You("reflect the %s.", (u.dz > 0) ? surface(u.ux, u.uy) : ceiling(u.ux, u.uy)); - return 1; + return ECMD_TIME; } mtmp = bhit(u.dx, u.dy, COLNO, INVIS_BEAM, (int (*) (MONST_P, OBJ_P)) 0, (int (*) (OBJ_P, OBJ_P)) 0, &obj); if (!mtmp || !haseyes(mtmp->data) || g.notonhead) - return 1; + return ECMD_TIME; /* couldsee(mtmp->mx, mtmp->my) is implied by the fact that bhit() targetted it, so we can ignore possibility of X-ray vision */ @@ -959,7 +959,7 @@ use_mirror(struct obj *obj) pline("%s doesn't have a reflection.", Monnam(mtmp)); } else if (monable && mtmp->data == &mons[PM_MEDUSA]) { if (mon_reflects(mtmp, "The gaze is reflected away by %s %s!")) - return 1; + return ECMD_TIME; if (vis) pline("%s is turned to stone!", Monnam(mtmp)); g.stoned = TRUE; @@ -1021,7 +1021,7 @@ use_mirror(struct obj *obj) else pline("%s ignores %s reflection.", Monnam(mtmp), mhis(mtmp)); } - return 1; + return ECMD_TIME; } static void @@ -1559,6 +1559,7 @@ rub_ok(struct obj *obj) return GETOBJ_EXCLUDE; } +/* the #rub command */ int dorub(void) { @@ -1566,26 +1567,26 @@ dorub(void) if (nohands(g.youmonst.data)) { You("aren't able to rub anything without hands."); - return 0; + return ECMD_OK; } obj = getobj("rub", rub_ok, GETOBJ_NOFLAGS); if (!obj) { /* pline1(Never_mind); -- handled by getobj() */ - return 0; + return ECMD_OK; } if (obj->oclass == GEM_CLASS || obj->oclass == FOOD_CLASS) { if (is_graystone(obj)) { use_stone(obj); - return 1; + return ECMD_TIME; } else if (obj->otyp == LUMP_OF_ROYAL_JELLY) { return use_royal_jelly(obj); } else { pline("Sorry, I don't know how to use that."); - return 0; + return ECMD_OK; } } if (!wield_tool(obj, "rub")) - return 0; + return ECMD_OK; /* now uwep is obj */ if (uwep->otyp == MAGIC_LAMP) { @@ -1614,9 +1615,10 @@ dorub(void) pline("Anyway, nothing exciting happens."); } else pline1(nothing_happens); - return 1; + return ECMD_TIME; } +/* the #jump command */ int dojump(void) { @@ -1777,61 +1779,61 @@ jump(int magic) /* 0=Physical, otherwise skill level */ /* normally (nolimbs || slithy) implies !Jumping, but that isn't necessarily the case for knights */ You_cant("jump; you have no legs!"); - return 0; + return ECMD_OK; } else if (!magic && !Jumping) { You_cant("jump very far."); - return 0; + return ECMD_OK; /* if steed is immobile, can't do physical jump but can do spell one */ } else if (!magic && u.usteed && stucksteed(FALSE)) { /* stucksteed gave " won't move" message */ - return 0; + return ECMD_OK; } else if (u.uswallow) { if (magic) { You("bounce around a little."); - return 1; + return ECMD_TIME; } pline("You've got to be kidding!"); - return 0; + return ECMD_OK; } else if (u.uinwater) { if (magic) { You("swish around a little."); - return 1; + return ECMD_TIME; } pline("This calls for swimming, not jumping!"); - return 0; + return ECMD_OK; } else if (u.ustuck) { if (u.ustuck->mtame && !Conflict && !u.ustuck->mconf) { struct monst *mtmp = u.ustuck; set_ustuck((struct monst *) 0); You("pull free from %s.", mon_nam(mtmp)); - return 1; + return ECMD_TIME; } if (magic) { You("writhe a little in the grasp of %s!", mon_nam(u.ustuck)); - return 1; + return ECMD_TIME; } You("cannot escape from %s!", mon_nam(u.ustuck)); - return 0; + return ECMD_OK; } else if (Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)) { if (magic) { You("flail around a little."); - return 1; + return ECMD_TIME; } You("don't have enough traction to jump."); - return 0; + return ECMD_OK; } else if (!magic && near_capacity() > UNENCUMBERED) { You("are carrying too much to jump!"); - return 0; + return ECMD_OK; } else if (!magic && (u.uhunger <= 100 || ACURR(A_STR) < 6)) { You("lack the strength to jump!"); - return 0; + return ECMD_OK; } else if (!magic && Wounded_legs) { legs_in_no_shape("jumping", u.usteed != 0); - return 0; + return ECMD_OK; } else if (u.usteed && u.utrap) { pline("%s is stuck in a trap.", Monnam(u.usteed)); - return 0; + return ECMD_OK; } pline("Where do you want to jump?"); @@ -1840,9 +1842,9 @@ jump(int magic) /* 0=Physical, otherwise skill level */ g.jumping_is_magic = magic; getpos_sethilite(display_jump_positions, get_valid_jump_position); if (getpos(&cc, TRUE, "the desired position") < 0) - return 0; /* user pressed ESC */ + return ECMD_OK; /* user pressed ESC */ if (!is_valid_jump_pos(cc.x, cc.y, magic, TRUE)) { - return 0; + return ECMD_OK; } else { coord uc; int range, temp; @@ -1868,7 +1870,7 @@ jump(int magic) /* 0=Physical, otherwise skill level */ case TT_LAVA: You("pull yourself above the %s!", hliquid("lava")); reset_utrap(TRUE); - return 1; + return ECMD_TIME; case TT_BURIEDBALL: case TT_INFLOOR: You("strain your %s, but you're still %s.", @@ -1878,7 +1880,7 @@ jump(int magic) /* 0=Physical, otherwise skill level */ : "attached to the buried ball"); set_wounded_legs(LEFT_SIDE, rn1(10, 11)); set_wounded_legs(RIGHT_SIDE, rn1(10, 11)); - return 1; + return ECMD_TIME; } /* @@ -1907,7 +1909,7 @@ jump(int magic) /* 0=Physical, otherwise skill level */ g.multi_reason = "jumping around"; g.nomovemsg = ""; morehungry(rnd(25)); - return 1; + return ECMD_TIME; } } @@ -2693,14 +2695,14 @@ use_whip(struct obj *obj) char buf[BUFSZ]; struct monst *mtmp; struct obj *otmp; - int rx, ry, proficient, res = 0; + int rx, ry, proficient, res = ECMD_OK; const char *msg_slipsfree = "The bullwhip slips free."; const char *msg_snap = "Snap!"; if (obj != uwep) { if (!wield_tool(obj, "lash")) - return 0; - res = 1; + return ECMD_OK; + res = ECMD_TIME; } if (!getdir((char *) 0)) return res; @@ -2752,13 +2754,13 @@ use_whip(struct obj *obj) if (u.usteed && !rn2(proficient + 2)) { You("whip %s!", mon_nam(u.usteed)); kick_steed(); - return 1; + return ECMD_TIME; } if (is_pool_or_lava(u.ux, u.uy)) { You("cause a small splash."); if (is_lava(u.ux, u.uy)) (void) fire_damage(uwep, FALSE, u.ux, u.uy); - return 1; + return ECMD_TIME; } if (Levitation || u.usteed || Flying) { /* Have a shot at snaring something on the floor. A flyer @@ -2767,14 +2769,14 @@ use_whip(struct obj *obj) otmp = g.level.objects[u.ux][u.uy]; if (otmp && otmp->otyp == CORPSE && otmp->corpsenm == PM_HORSE) { pline("Why beat a dead horse?"); - return 1; + return ECMD_TIME; } if (otmp && proficient) { You("wrap your bullwhip around %s on the %s.", an(singular(otmp, xname)), surface(u.ux, u.uy)); if (rnl(6) || pickup_object(otmp, 1L, TRUE) < 1) pline1(msg_slipsfree); - return 1; + return ECMD_TIME; } } dam = rnd(2) + dbon() + obj->spe; @@ -2783,7 +2785,7 @@ use_whip(struct obj *obj) You("hit your %s with your bullwhip.", body_part(FOOT)); Sprintf(buf, "killed %sself with %s bullwhip", uhim(), uhis()); losehp(Maybe_Half_Phys(dam), buf, NO_KILLER_PREFIX); - return 1; + return ECMD_TIME; } else if ((Fumbling || Glib) && !rn2(5)) { pline_The("bullwhip slips out of your %s.", body_part(HAND)); @@ -2975,7 +2977,7 @@ use_whip(struct obj *obj) You("flick your bullwhip towards %s.", mon_nam(mtmp)); } if (proficient && force_attack(mtmp, FALSE)) - return 1; + return ECMD_TIME; if (do_snap) pline1(msg_snap); } @@ -2989,7 +2991,7 @@ use_whip(struct obj *obj) } else { pline1(msg_snap); } - return 1; + return ECMD_TIME; } static const char @@ -3079,7 +3081,7 @@ int use_pole(struct obj *obj, boolean autohit) { const char thump[] = "Thump! Your blow bounces harmlessly off the %s."; - int res = 0, typ, max_range, min_range, glyph; + int res = ECMD_OK, typ, max_range, min_range, glyph; coord cc; struct monst *mtmp; struct monst *hitm = g.context.polearm.hitmon; @@ -3087,12 +3089,12 @@ use_pole(struct obj *obj, boolean autohit) /* Are you allowed to use the pole? */ if (u.uswallow) { pline(not_enough_room); - return 0; + return ECMD_OK; } if (obj != uwep) { if (!wield_tool(obj, "swing")) - return 0; - res = 1; + return ECMD_OK; + res = ECMD_TIME; } /* assert(obj == uwep); */ @@ -3168,9 +3170,9 @@ use_pole(struct obj *obj, boolean autohit) res: 1 => polearm became wielded, 0 => already wielded; g.context.move: 1 => discovered hidden monster at target spot, 0 => answered 'n' to "Really attack?" prompt */ - return res || g.context.move; + return res | (g.context.move ? ECMD_TIME : ECMD_OK); if (overexertion()) - return 1; /* burn nutrition; maybe pass out */ + return ECMD_TIME; /* burn nutrition; maybe pass out */ g.context.polearm.hitmon = mtmp; check_caitiff(mtmp); g.notonhead = (g.bhitpos.x != mtmp->mx || g.bhitpos.y != mtmp->my); @@ -3215,7 +3217,7 @@ use_pole(struct obj *obj, boolean autohit) } } u_wipe_engr(2); /* same as for melee or throwing */ - return 1; + return ECMD_TIME; } static int @@ -3252,7 +3254,7 @@ use_cream_pie(struct obj *obj) costly_alteration(obj, COST_SPLAT); obj_extract_self(obj); delobj(obj); - return 0; + return ECMD_OK; } /* getobj callback for object to rub royal jelly on */ @@ -3284,7 +3286,7 @@ use_royal_jelly(struct obj *obj) addinv(obj); /* put the unused lump back; if it came from * a split, it should merge back */ /* pline1(Never_mind); -- getobj() took care of this */ - return 0; + return ECMD_OK; } You("smear royal jelly all over %s.", yname(eobj)); @@ -3326,13 +3328,13 @@ use_royal_jelly(struct obj *obj) /* not useup() because we've already done freeinv() */ setnotworn(obj); obfree(obj, (struct obj *) 0); - return 1; + return ECMD_TIME; } static int use_grapple(struct obj *obj) { - int res = 0, typ, max_range = 4, tohit; + int res = ECMD_OK, typ, max_range = 4, tohit; boolean save_confirm; coord cc; struct monst *mtmp; @@ -3341,13 +3343,13 @@ use_grapple(struct obj *obj) /* Are you allowed to use the hook? */ if (u.uswallow) { pline(not_enough_room); - return 0; + return ECMD_OK; } if (obj != uwep) { if (!wield_tool(obj, "cast")) - return 0; + return ECMD_OK; else - res = 1; + res = ECMD_TIME; } /* assert(obj == uwep); */ @@ -3424,7 +3426,7 @@ use_grapple(struct obj *obj) (void) pickup_object(otmp, 1L, FALSE); /* If pickup fails, leave it alone */ newsym(cc.x, cc.y); - return 1; + return ECMD_TIME; } break; case 2: /* Monster */ @@ -3442,7 +3444,7 @@ use_grapple(struct obj *obj) You("pull in %s!", mon_nam(mtmp)); mtmp->mundetected = 0; rloc_to(mtmp, cc.x, cc.y); - return 1; + return ECMD_TIME; } else if ((!bigmonst(mtmp->data) && !strongmonst(mtmp->data)) || rn2(4)) { flags.confirm = FALSE; @@ -3450,7 +3452,7 @@ use_grapple(struct obj *obj) flags.confirm = save_confirm; check_caitiff(mtmp); (void) thitmonst(mtmp, uwep); - return 1; + return ECMD_TIME; } /*FALLTHRU*/ case 3: /* Surface */ @@ -3461,18 +3463,18 @@ use_grapple(struct obj *obj) hurtle(sgn(cc.x - u.ux), sgn(cc.y - u.uy), 1, FALSE); spoteffects(TRUE); } - return 1; + return ECMD_TIME; default: /* Yourself (oops!) */ if (P_SKILL(typ) <= P_BASIC) { You("hook yourself!"); losehp(Maybe_Half_Phys(rn1(10, 10)), "a grappling hook", KILLED_BY); - return 1; + return ECMD_TIME; } break; } pline1(nothing_happens); - return 1; + return ECMD_TIME; } #define BY_OBJECT ((struct monst *) 0) @@ -3495,19 +3497,19 @@ do_break_wand(struct obj *obj) if (nohands(g.youmonst.data)) { You_cant("break %s without hands!", yname(obj)); - return 0; + return ECMD_OK; } else if (!freehand()) { Your("%s are occupied!", makeplural(body_part(HAND))); - return 0; + return ECMD_OK; } else if (ACURR(A_STR) < (is_fragile ? 5 : 10)) { You("don't have the strength to break %s!", yname(obj)); - return 0; + return ECMD_OK; } if (!paranoid_query(ParanoidBreakwand, safe_qbuf(confirm, "Are you really sure you want to break ", "?", obj, yname, ysimple_name, "the wand"))) - return 0; + return ECMD_OK; pline("Raising %s high above your %s, you %s it in two!", yname(obj), body_part(HEAD), is_fragile ? "snap" : "break"); @@ -3709,7 +3711,7 @@ do_break_wand(struct obj *obj) if (obj) delobj(obj); nomul(0); - return 1; + return ECMD_TIME; } /* getobj callback for object to apply - this is more complex than most other @@ -3768,27 +3770,27 @@ apply_ok(struct obj *obj) return GETOBJ_EXCLUDE_SELECTABLE; } -/* the 'a' command */ +/* the #apply command, 'a' */ int doapply(void) { struct obj *obj; - register int res = 1; + register int res = ECMD_TIME; if (nohands(g.youmonst.data)) { You("aren't able to use or apply tools in your current form."); - return 0; + return ECMD_OK; } if (check_capacity((char *) 0)) - return 0; + return ECMD_OK; obj = getobj("use or apply", apply_ok, GETOBJ_NOFLAGS); if (!obj) - return 0; + return ECMD_OK; if (!retouch_object(&obj, FALSE)) - return 1; /* evading your grasp costs a turn; just be - grateful that you don't drop it as well */ + return ECMD_TIME; /* evading your grasp costs a turn; just be + grateful that you don't drop it as well */ if (obj->oclass == WAND_CLASS) return do_break_wand(obj); @@ -3840,7 +3842,7 @@ doapply(void) case LOCK_PICK: case CREDIT_CARD: case SKELETON_KEY: - res = (pick_lock(obj, 0, 0, NULL) != 0); + res = (pick_lock(obj, 0, 0, NULL) != 0) ? ECMD_TIME : ECMD_OK; break; case PICK_AXE: case DWARVISH_MATTOCK: @@ -3961,9 +3963,9 @@ doapply(void) } pline("Sorry, I don't know how to use that."); nomul(0); - return 0; + return ECMD_OK; } - if (res && obj && obj->oartifact) + if ((res & ECMD_TIME) && obj && obj->oartifact) arti_speak(obj); nomul(0); return res; @@ -4017,7 +4019,7 @@ flip_through_book(struct obj *obj) { if (Underwater) { pline("You don't want to get the pages even more soggy, do you?"); - return 0; + return ECMD_OK; } You("flip through the pages of %s.", thesimpleoname(obj)); @@ -4059,7 +4061,7 @@ flip_through_book(struct obj *obj) fadeness[findx]); } - return 1; + return ECMD_TIME; } /*apply.c*/ diff --git a/src/artifact.c b/src/artifact.c index 413c8f6d2..3f680a118 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -1434,9 +1434,9 @@ doinvoke(void) obj = getobj("invoke", invoke_ok, GETOBJ_PROMPT); if (!obj) - return 0; + return ECMD_OK; if (!retouch_object(&obj, FALSE)) - return 1; + return ECMD_TIME; return arti_invoke(obj); } @@ -1446,14 +1446,14 @@ arti_invoke(struct obj *obj) register const struct artifact *oart = get_artifact(obj); if (!obj) { impossible("arti_invoke without obj"); - return 0; + return ECMD_OK; } if (!oart || !oart->inv_prop) { if (obj->otyp == CRYSTAL_BALL) use_crystal_ball(&obj); else pline1(nothing_happens); - return 1; + return ECMD_TIME; } if (oart->inv_prop > LAST_PROP) { @@ -1464,7 +1464,7 @@ arti_invoke(struct obj *obj) otense(obj, "are")); /* and just got more so; patience is essential... */ obj->age += (long) d(3, 10); - return 1; + return ECMD_TIME; } obj->age = g.moves + rnz(100); @@ -1521,7 +1521,7 @@ arti_invoke(struct obj *obj) case UNTRAP: { if (!untrap(TRUE)) { obj->age = 0; /* don't charge for changing their mind */ - return 0; + return ECMD_OK; } break; } @@ -1532,7 +1532,7 @@ arti_invoke(struct obj *obj) if (!otmp) { obj->age = 0; - return 0; + return ECMD_OK; } b_effect = (obj->blessed && (oart->role == Role_switch || oart->role == NON_PM)); @@ -1641,7 +1641,7 @@ arti_invoke(struct obj *obj) otense(obj, "are")); /* can't just keep repeatedly trying */ obj->age += (long) d(3, 10); - return 1; + return ECMD_TIME; } else if (!on) { /* when turning off property, determine downtime */ /* arbitrary for now until we can tune this -dlc */ @@ -1653,7 +1653,7 @@ arti_invoke(struct obj *obj) /* you had the property from some other source too */ if (carried(obj)) You_feel("a surge of power, but nothing seems to happen."); - return 1; + return ECMD_TIME; } switch (oart->inv_prop) { case CONFLICT: @@ -1682,7 +1682,7 @@ arti_invoke(struct obj *obj) } } - return 1; + return ECMD_TIME; } /* will freeing this object from inventory cause levitation to end? */ @@ -2053,7 +2053,7 @@ untouchable(struct obj *obj, boolean drop_untouchable) carried effect was turned off, else we leave that alone; we turn off invocation property here if still carried */ if (invoked && obj) - arti_invoke(obj); /* reverse #invoke */ + (void) arti_invoke(obj); /* reverse #invoke */ return TRUE; } } diff --git a/src/cmd.c b/src/cmd.c index 07fb22444..ac6938168 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -171,10 +171,12 @@ static const char unavailcmd[] = "Unavailable command '%s'."; /* for rejecting #if !SHELL, !SUSPEND */ static const char cmdnotavail[] = "'%s' command not available."; +/* the #prevmsg command */ static int doprev_message(void) { - return nh_doprev_message(); + (void) nh_doprev_message(); + return ECMD_OK; } /* Count down by decrementing multi */ @@ -379,7 +381,7 @@ doextcmd(void) do { idx = get_ext_cmd(); if (idx < 0) - return 0; /* quit */ + return ECMD_OK; /* quit */ func = extcmdlist[idx].ef_funct; if (!can_do_extcmd(&extcmdlist[idx])) @@ -608,7 +610,7 @@ doextlist(void) } } destroy_nhwindow(menuwin); - return 0; + return ECMD_OK; } #if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS) @@ -790,7 +792,7 @@ domonability(void) There("is no fountain here."); } else if (is_unicorn(g.youmonst.data)) { use_unicorn_horn((struct obj **) 0); - return 1; + return ECMD_TIME; } else if (g.youmonst.data->msound == MS_SHRIEK) { You("shriek."); if (u.uburied) @@ -804,7 +806,7 @@ domonability(void) } else { You("don't have a special ability in your normal form!"); } - return 0; + return ECMD_OK; } int @@ -821,7 +823,7 @@ enter_explore_mode(void) || !check_user_string(sysopt.explorers)) { if (!wizard) { You("cannot access explore mode."); - return 0; + return ECMD_OK; } else { pline( "Note: normally you wouldn't be allowed into explore mode."); @@ -843,10 +845,10 @@ enter_explore_mode(void) pline("Continuing with %s.", oldmode); } } - return 0; + return ECMD_OK; } -/* ^W command - wish for something */ +/* #wizwish command - wish for something */ static int wiz_wish(void) /* Unlimited wishes for debug mode by Paul Polderman */ { @@ -859,10 +861,10 @@ wiz_wish(void) /* Unlimited wishes for debug mode by Paul Polderman */ (void) encumber_msg(); } else pline(unavailcmd, visctrl((int) cmd_from_func(wiz_wish))); - return 0; + return ECMD_OK; } -/* ^I command - reveal and optionally identify hero's inventory */ +/* #wizidentify command - reveal and optionally identify hero's inventory */ static int wiz_identify(void) { @@ -879,7 +881,7 @@ wiz_identify(void) iflags.override_ID = 0; } else pline(unavailcmd, visctrl((int) cmd_from_func(wiz_identify))); - return 0; + return ECMD_OK; } void @@ -999,10 +1001,10 @@ wiz_makemap(void) } else { pline(unavailcmd, "#wizmakemap"); } - return 0; + return ECMD_OK; } -/* ^F command - reveal the level map and any traps on it */ +/* the #wizmap command - reveal the level map and any traps on it */ static int wiz_map(void) { @@ -1020,10 +1022,10 @@ wiz_map(void) HHallucination = save_Hhallu; } else pline(unavailcmd, visctrl((int) cmd_from_func(wiz_map))); - return 0; + return ECMD_OK; } -/* ^G command - generate monster(s); a count prefix will be honored */ +/* #wizgenesis - generate monster(s); a count prefix will be honored */ static int wiz_genesis(void) { @@ -1031,10 +1033,10 @@ wiz_genesis(void) (void) create_particular(); else pline(unavailcmd, visctrl((int) cmd_from_func(wiz_genesis))); - return 0; + return ECMD_OK; } -/* ^O command - display dungeon layout */ +/* #wizwhere command - display dungeon layout */ static int wiz_where(void) { @@ -1042,10 +1044,10 @@ wiz_where(void) (void) print_dungeon(FALSE, (schar *) 0, (xchar *) 0); else pline(unavailcmd, visctrl((int) cmd_from_func(wiz_where))); - return 0; + return ECMD_OK; } -/* ^E command - detect unseen (secret doors, traps, hidden monsters) */ +/* the #wizdetect command - detect secret doors, traps, hidden monsters */ static int wiz_detect(void) { @@ -1053,9 +1055,10 @@ wiz_detect(void) (void) findit(); else pline(unavailcmd, visctrl((int) cmd_from_func(wiz_detect))); - return 0; + return ECMD_OK; } +/* the #wizloadlua command - load an arbitrary lua file */ static int wiz_load_lua(void) { @@ -1071,9 +1074,10 @@ wiz_load_lua(void) (void) load_lua(buf); } else pline("Unavailable command 'wiz_load_lua'."); - return 0; + return ECMD_OK; } +/* the #wizloaddes command - load a special level lua file */ static int wiz_load_splua(void) { @@ -1093,10 +1097,10 @@ wiz_load_splua(void) } else pline("Unavailable command 'wiz_load_splua'."); - return 0; + return ECMD_OK; } -/* ^V command - level teleport */ +/* the #wizlevelport command - level teleport */ static int wiz_level_tele(void) { @@ -1104,7 +1108,7 @@ wiz_level_tele(void) level_tele(); else pline(unavailcmd, visctrl((int) cmd_from_func(wiz_level_tele))); - return 0; + return ECMD_OK; } /* #wizfliplevel - transpose the current level */ @@ -1138,7 +1142,7 @@ wiz_flip_level(void) pline("%s", Never_mind); } } - return 0; + return ECMD_OK; } /* #levelchange command - adjust hero's experience level */ @@ -1158,14 +1162,14 @@ wiz_level_change(void) if (ret != 1) { pline1(Never_mind); - return 0; + return ECMD_OK; } if (newlevel == u.ulevel) { You("are already that experienced."); } else if (newlevel < u.ulevel) { if (u.ulevel == 1) { You("are already as inexperienced as you can get."); - return 0; + return ECMD_OK; } if (newlevel < 1) newlevel = 1; @@ -1174,7 +1178,7 @@ wiz_level_change(void) } else { if (u.ulevel >= MAXULEV) { You("are already as experienced as you can get."); - return 0; + return ECMD_OK; } if (newlevel > MAXULEV) newlevel = MAXULEV; @@ -1182,7 +1186,7 @@ wiz_level_change(void) pluslvl(FALSE); } u.ulevelmax = u.ulevel; - return 0; + return ECMD_OK; } /* #panic command - test program's panic handling */ @@ -1192,12 +1196,12 @@ wiz_panic(void) if (iflags.debug_fuzzer) { u.uhp = u.uhpmax = 1000; u.uen = u.uenmax = 1000; - return 0; + return ECMD_OK; } if (paranoid_query(TRUE, "Do you want to call panic() and end your game?")) panic("Crash test."); - return 0; + return ECMD_OK; } /* #polyself command - change hero's form */ @@ -1205,7 +1209,7 @@ static int wiz_polyself(void) { polyself(1); - return 0; + return ECMD_OK; } /* #seenv command */ @@ -1249,7 +1253,7 @@ wiz_show_seenv(void) } display_nhwindow(win, TRUE); destroy_nhwindow(win); - return 0; + return ECMD_OK; } /* #vision command */ @@ -1284,7 +1288,7 @@ wiz_show_vision(void) } display_nhwindow(win, TRUE); destroy_nhwindow(win); - return 0; + return ECMD_OK; } /* #wmode command */ @@ -1320,7 +1324,7 @@ wiz_show_wmodes(void) } display_nhwindow(win, TRUE); destroy_nhwindow(win); - return 0; + return ECMD_OK; } /* wizard mode variant of #terrain; internal levl[][].typ values in base-36 */ @@ -1554,7 +1558,7 @@ wiz_smell(void) mndx = 0; /* gcc -Wall lint */ if (!olfaction(g.youmonst.data)) { You("are incapable of detecting odors in your present form."); - return 0; + return ECMD_OK; } pline("You can move the cursor to a monster that you want to smell."); @@ -1562,7 +1566,7 @@ wiz_smell(void) pline("Pick a monster to smell."); ans = getpos(&cc, TRUE, "a monster"); if (ans < 0 || cc.x < 0) { - return 0; /* done */ + return ECMD_OK; /* done */ } /* Convert the glyph at the selected position to a mndxbol. */ glyph = glyph_at(cc.x, cc.y); @@ -1577,7 +1581,7 @@ wiz_smell(void) } else pline("That is not a monster."); } while (TRUE); - return 0; + return ECMD_OK; } RESTORE_WARNING_CONDEXPR_IS_CONSTANT @@ -1735,7 +1739,7 @@ wiz_intrinsic(void) doredraw(); } else pline(unavailcmd, visctrl((int) cmd_from_func(wiz_intrinsic))); - return 0; + return ECMD_OK; } RESTORE_WARNING_FORMAT_NONLITERAL @@ -1745,7 +1749,7 @@ static int wiz_rumor_check(void) { rumor_check(); - return 0; + return ECMD_OK; } /* #terrain command -- show known map, inspired by crawl's '|' command */ @@ -1837,7 +1841,7 @@ doterrain(void) default: break; } - return 0; /* no time elapses */ + return ECMD_OK; /* no time elapses */ } /* extcmdlist: full command list, ordered by command name; @@ -2875,7 +2879,7 @@ misc_stats(winid win, long *total_count, long *total_size) } } -/* +/* the #stats command * Display memory usage of all monsters and objects on the level. */ static int @@ -2959,7 +2963,7 @@ wiz_show_stats(void) display_nhwindow(win, FALSE); destroy_nhwindow(win); - return 0; + return ECMD_OK; } RESTORE_WARNING_FORMAT_NONLITERAL @@ -2987,10 +2991,10 @@ wiz_migrate_mons(void) getlin("How many random monsters to migrate? [0]", inbuf); if (*inbuf == '\033') - return 0; + return ECMD_OK; mcount = atoi(inbuf); if (mcount < 0 || mcount > (COLNO * ROWNO) || Is_botlevel(&u.uz)) - return 0; + return ECMD_OK; while (mcount > 0) { if (Is_stronghold(&u.uz)) assign_level(&tolevel, &valley_level); @@ -3003,7 +3007,7 @@ wiz_migrate_mons(void) (coord *) 0); mcount--; } - return 0; + return ECMD_OK; } #endif @@ -3597,7 +3601,7 @@ rhack(char *cmd) /* current - use *cmd to directly index cmdlist array */ if (tlist != 0) { if (!can_do_extcmd(tlist)) { - res = 0; + res = ECMD_OK; cmdq_clear(); } else { /* we discard 'const' because some compilers seem to have @@ -3607,7 +3611,7 @@ rhack(char *cmd) set_occupation(func, tlist->f_text, g.multi); res = (*func)(); /* perform the command */ } - if (!res) { + if (!(res & ECMD_TIME)) { g.context.move = FALSE; g.multi = 0; } @@ -4033,7 +4037,7 @@ doherecmdmenu(void) { char ch = here_cmd_menu(TRUE); - return ch ? 1 : 0; + return ch ? ECMD_TIME : ECMD_OK; } /* #therecmdmenu command, a way to test there_cmd_menu without mouse */ @@ -4043,14 +4047,14 @@ dotherecmdmenu(void) char ch; if (!getdir((const char *) 0) || !isok(u.ux + u.dx, u.uy + u.dy)) - return 0; + return ECMD_OK; if (u.dx || u.dy) ch = there_cmd_menu(TRUE, u.ux + u.dx, u.uy + u.dy); else ch = here_cmd_menu(TRUE); - return ch ? 1 : 0; + return ch ? ECMD_TIME : ECMD_OK; } static void @@ -4695,7 +4699,7 @@ dotravel(void) if (!getpos_menu(&cc, GLOC_INTERESTING)) { iflags.getloc_filter = gf; iflags.getloc_travelmode = FALSE; - return 0; + return ECMD_OK; } iflags.getloc_filter = gf; } else { @@ -4703,7 +4707,7 @@ dotravel(void) if (getpos(&cc, TRUE, "the desired destination") < 0) { /* user pressed ESC */ iflags.getloc_travelmode = FALSE; - return 0; + return ECMD_OK; } } iflags.travelcc.x = u.tx = cc.x; @@ -4717,7 +4721,7 @@ static int dotravel_target(void) { if (!isok(iflags.travelcc.x, iflags.travelcc.y)) - return 0; + return ECMD_OK; iflags.getloc_travelmode = FALSE; @@ -4733,7 +4737,7 @@ dotravel_target(void) g.context.mv = TRUE; domove(); - return 1; + return ECMD_TIME; } /* mouse click look command */ @@ -4744,9 +4748,9 @@ doclicklook(void) return 0; g.context.move = FALSE; - do_look(2, &g.clicklook_cc); + (void) do_look(2, &g.clicklook_cc); - return 0; + return ECMD_OK; } /* @@ -4850,7 +4854,7 @@ dosuspend_core(void) } else #endif Norep(cmdnotavail, "#suspend"); - return 0; + return ECMD_OK; } /* '!' command, #shell */ @@ -4868,7 +4872,7 @@ dosh_core(void) #else Norep(cmdnotavail, "#shell"); #endif - return 0; + return ECMD_OK; } /*cmd.c*/ diff --git a/src/detect.c b/src/detect.c index 363056444..879407432 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1813,15 +1813,15 @@ dosearch0(int aflag) /* intrinsic autosearch vs explicit searching */ return 1; } -/* the 's' command -- explicit searching */ +/* the #search command -- explicit searching */ int dosearch(void) { if (cmd_safety_prevention("another search", "You already found a monster.", &g.already_found_flag)) - return 0; - return dosearch0(0); + return ECMD_OK; + return dosearch0(0) ? ECMD_TIME : ECMD_OK; } void diff --git a/src/dig.c b/src/dig.c index 3d4de6988..2f40f23a5 100644 --- a/src/dig.c +++ b/src/dig.c @@ -958,15 +958,15 @@ use_pick_axe(struct obj *obj) const char *verb; char *dsp, dirsyms[12], qbuf[BUFSZ]; boolean ispick; - int rx, ry, downok, res = 0; + int rx, ry, downok, res = ECMD_OK; int dir; /* Check tool */ if (obj != uwep) { if (!wield_tool(obj, "swing")) - return 0; + return ECMD_OK; else - res = 1; + res = ECMD_TIME; } ispick = is_pick(obj); verb = ispick ? "dig" : "chop"; @@ -1054,7 +1054,7 @@ use_pick_axe2(struct obj *obj) Sprintf(buf, "%s own %s", uhis(), OBJ_NAME(objects[obj->otyp])); losehp(Maybe_Half_Phys(dam), buf, KILLED_BY); g.context.botl = 1; - return 1; + return ECMD_TIME; } else if (u.dz == 0) { if (Stunned || (Confusion && !rn2(5))) confdir(); @@ -1062,11 +1062,11 @@ use_pick_axe2(struct obj *obj) ry = u.uy + u.dy; if (!isok(rx, ry)) { pline("Clash!"); - return 1; + return ECMD_TIME; } lev = &levl[rx][ry]; if (MON_AT(rx, ry) && do_attack(m_at(rx, ry))) - return 1; + return ECMD_TIME; dig_target = dig_typ(obj, rx, ry); if (dig_target == DIGTYP_UNDIGGABLE) { /* ACCESSIBLE or POOL */ @@ -1200,7 +1200,7 @@ use_pick_axe2(struct obj *obj) g.did_dig_msg = FALSE; set_occupation(dig, verbing, 0); } - return 1; + return ECMD_TIME; } /* @@ -2120,7 +2120,7 @@ struct obj *otmp; #endif /*0*/ #ifdef DEBUG -/* bury everything at your loc and around */ +/* the #wizbury command - bury everything at your loc and around */ int wiz_debug_cmd_bury(void) { @@ -2130,7 +2130,7 @@ wiz_debug_cmd_bury(void) for (y = u.uy - 1; y <= u.uy + 1; y++) if (isok(x, y)) bury_objs(x, y); - return 0; + return ECMD_OK; } #endif /* DEBUG */ diff --git a/src/display.c b/src/display.c index 6fe4becfd..f02e69930 100644 --- a/src/display.c +++ b/src/display.c @@ -1405,11 +1405,12 @@ curs_on_u(void) flush_screen(1); /* Flush waiting glyphs & put cursor on hero */ } +/* the #redraw command */ int doredraw(void) { docrt(); - return 0; + return ECMD_OK; } void diff --git a/src/do.c b/src/do.c index bcf8c8f0f..01a2a4c9e 100644 --- a/src/do.c +++ b/src/do.c @@ -21,7 +21,7 @@ static void final_level(void); /* static boolean badspot(xchar,xchar); */ -/* 'd' command: drop one inventory item */ +/* the #drop command: drop one inventory item */ int dodrop(void) { @@ -615,13 +615,13 @@ static int drop(struct obj *obj) { if (!obj) - return 0; + return ECMD_OK; if (!canletgo(obj, "drop")) - return 0; + return ECMD_OK; if (obj == uwep) { if (welded(uwep)) { weldmsg(obj); - return 0; + return ECMD_OK; } setuwep((struct obj *) 0); } @@ -647,7 +647,7 @@ drop(struct obj *obj) if ((obj->oclass == RING_CLASS || obj->otyp == MEAT_RING) && IS_SINK(levl[u.ux][u.uy].typ)) { dosinkring(obj); - return 1; + return ECMD_TIME; } if (!can_reach_floor(TRUE)) { /* we might be levitating due to #invoke Heart of Ahriman; @@ -663,13 +663,13 @@ drop(struct obj *obj) hitfloor(obj, TRUE); if (levhack) float_down(I_SPECIAL | TIMEOUT, W_ARTI | W_ART); - return 1; + return ECMD_TIME; } if (!IS_ALTAR(levl[u.ux][u.uy].typ) && flags.verbose) You("drop %s.", doname(obj)); } dropx(obj); - return 1; + return ECMD_TIME; } /* dropx - take dropped item out of inventory; @@ -810,15 +810,15 @@ obj_no_longer_held(struct obj *obj) } } -/* 'D' command: drop several things */ +/* the #droptype command: drop several things */ int doddrop(void) { - int result = 0; + int result = ECMD_OK; if (!g.invent) { You("have nothing to drop."); - return 0; + return ECMD_OK; } add_valid_menu_class(0); /* clear any classes already there */ if (*u.ushops) @@ -834,7 +834,7 @@ doddrop(void) return result; } -static int +static int /* check callers */ menudrop_split(struct obj *otmp, int cnt) { if (cnt && cnt < otmp->quan) { @@ -923,7 +923,7 @@ menu_drop(int retry) bypass_objlist(g.invent, FALSE); /* clear bypass bit for invent */ while ((otmp = nxt_unbypassed_obj(g.invent)) != 0) { if (drop_everything || all_categories || allow_category(otmp)) - n_dropped += drop(otmp); + n_dropped += ((drop(otmp) == ECMD_TIME) ? 1 : 0); } /* we might not have dropped everything (worn armor, welded weapon, cursed loadstones), so reset any remaining inventory to normal */ @@ -932,7 +932,7 @@ menu_drop(int retry) /* drop the just picked item automatically, if only one stack */ otmp = find_justpicked(g.invent); if (otmp) - n_dropped += menudrop_split(otmp, justpicked_quan); + n_dropped += ((menudrop_split(otmp, justpicked_quan) == ECMD_TIME) ? 1 : 0); } else { /* should coordinate with perm invent, maybe not show worn items */ n = query_objlist("What would you like to drop?", &g.invent, @@ -961,7 +961,7 @@ menu_drop(int retry) if (!otmp2 || !otmp2->bypass) continue; /* found next selected invent item */ - n_dropped += menudrop_split(otmp, pick_list[i].count); + n_dropped += ((menudrop_split(otmp, pick_list[i].count) == ECMD_TIME) ? 1 : 0); } bypass_objlist(g.invent, FALSE); /* reset g.invent to normal */ free((genericptr_t) pick_list); @@ -969,10 +969,10 @@ menu_drop(int retry) } drop_done: - return n_dropped; + return (n_dropped ? ECMD_TIME : ECMD_OK); } -/* the '>' command */ +/* the #down command */ int dodown(void) { @@ -982,10 +982,10 @@ dodown(void) ladder_down = (stway && !stway->up && stway->isladder); if (u_rooted()) - return 1; + return ECMD_TIME; if (stucksteed(TRUE)) { - return 0; + return ECMD_OK; } /* Levitation might be blocked, but player can still use '>' to turn off controlled levitation */ @@ -1005,10 +1005,10 @@ dodown(void) } } if (float_down(I_SPECIAL | TIMEOUT, W_ARTI)) { - return 1; /* came down, so moved */ + return ECMD_TIME; /* came down, so moved */ } else if (!HLevitation && !ELevitation) { Your("latent levitation ceases."); - return 1; /* did something, effectively moved */ + return ECMD_TIME; /* did something, effectively moved */ } } if (BLevitation) { @@ -1034,7 +1034,7 @@ dodown(void) floating_above(stairs_down ? "stairs" : ladder_down ? "ladder" : surface(u.ux, u.uy)); - return 0; /* didn't move */ + return ECMD_OK; /* didn't move */ } if (Upolyd && ceiling_hider(&mons[u.umonnum]) && u.uundetected) { @@ -1051,7 +1051,7 @@ dodown(void) dotrap(trap, TOOKPLUNGE); } } - return 1; /* came out of hiding; might need '>' again to go down */ + return ECMD_TIME; /* came out of hiding; might need '>' again to go down */ } if (u.ustuck) { @@ -1059,21 +1059,21 @@ dodown(void) !u.uswallow ? "being held" : is_animal(u.ustuck->data) ? "swallowed" : "engulfed"); - return 1; + return ECMD_TIME; } if (!stairs_down && !ladder_down) { trap = t_at(u.ux, u.uy); if (trap && (uteetering_at_seen_pit(trap) || uescaped_shaft(trap))) { dotrap(trap, TOOKPLUNGE); - return 1; + return ECMD_TIME; } else if (!trap || !is_hole(trap->ttyp) || !Can_fall_thru(&u.uz) || !trap->tseen) { if (flags.autodig && !g.context.nopick && uwep && is_pick(uwep)) { return use_pick_axe2(uwep); } else { You_cant("go down here."); - return 0; + return ECMD_OK; } } } @@ -1081,14 +1081,14 @@ dodown(void) You("are standing at the gate to Gehennom."); pline("Unspeakable cruelty and harm lurk down there."); if (yn("Are you sure you want to enter?") != 'y') - return 0; + return ECMD_OK; pline("So be it."); u.uevent.gehennom_entered = 1; /* don't ask again */ } if (!next_to_u()) { You("are held back by your pet!"); - return 0; + return ECMD_OK; } if (trap) { @@ -1108,10 +1108,10 @@ dodown(void) "contusion from a small passage", KILLED_BY); } else { You("were unable to fit %s.", down_or_thru); - return 0; + return ECMD_OK; } } else { - return 0; + return ECMD_OK; } } You("%s %s the %s.", actn, down_or_thru, @@ -1124,58 +1124,58 @@ dodown(void) next_level(!trap); g.at_ladder = FALSE; } - return 1; + return ECMD_TIME; } -/* the '<' command */ +/* the #up command - move up a staircase */ int doup(void) { stairway *stway = stairway_at(u.ux,u.uy); if (u_rooted()) - return 1; + return ECMD_TIME; /* "up" to get out of a pit... */ if (u.utrap && u.utraptype == TT_PIT) { climb_pit(); - return 1; + return ECMD_TIME; } if (!stway || (stway && !stway->up)) { You_cant("go up here."); - return 0; + return ECMD_OK; } if (stucksteed(TRUE)) { - return 0; + return ECMD_OK; } if (u.ustuck) { You("are %s, and cannot go up.", !u.uswallow ? "being held" : is_animal(u.ustuck->data) ? "swallowed" : "engulfed"); - return 1; + return ECMD_TIME; } if (near_capacity() > SLT_ENCUMBER) { /* No levitation check; inv_weight() already allows for it */ Your("load is too heavy to climb the %s.", levl[u.ux][u.uy].typ == STAIRS ? "stairs" : "ladder"); - return 1; + return ECMD_TIME; } if (ledger_no(&u.uz) == 1) { if (iflags.debug_fuzzer) - return 0; + return ECMD_OK; if (yn("Beware, there will be no return! Still climb?") != 'y') - return 0; + return ECMD_OK; } if (!next_to_u()) { You("are held back by your pet!"); - return 0; + return ECMD_OK; } g.at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER); prev_level(TRUE); g.at_ladder = FALSE; - return 1; + return ECMD_TIME; } /* check that we can write out the current level */ @@ -2062,8 +2062,8 @@ donull(void) if (cmd_safety_prevention("a no-op (to rest)", "Are you waiting to get hit?", &g.did_nothing_flag)) - return 0; - return 1; /* Do nothing, but let other things happen */ + return ECMD_OK; + return ECMD_TIME; /* Do nothing, but let other things happen */ } static int @@ -2092,6 +2092,7 @@ wipeoff(void) return 1; /* still busy */ } +/* the #wipe command - wipe off your face */ int dowipe(void) { @@ -2103,10 +2104,10 @@ dowipe(void) /* Not totally correct; what if they change back after now * but before they're finished wiping? */ - return 1; + return ECMD_TIME; } Your("%s is already clean.", body_part(FACE)); - return 1; + return ECMD_TIME; } /* common wounded legs feedback */ diff --git a/src/do_name.c b/src/do_name.c index 7a3cf7310..d1b92b435 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -1394,7 +1394,7 @@ call_ok(struct obj *obj) return GETOBJ_SUGGEST; } -/* C and #name commands - player can name monster or object or type of obj */ +/* #call / #name command - player can name monster or object or type of obj */ int docallcmd(void) { @@ -1485,7 +1485,7 @@ docallcmd(void) donamelevel(); break; } - return 0; + return ECMD_OK; } /* for use by safe_qbuf() */ diff --git a/src/do_wear.c b/src/do_wear.c index 890a7c1c6..b65a27105 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -1590,7 +1590,7 @@ armor_or_accessory_off(struct obj *obj) { if (!(obj->owornmask & (W_ARMOR | W_ACCESSORY))) { You("are not wearing that."); - return 0; + return ECMD_OK; } if (obj == uskin || ((obj == uarm) && uarmc) @@ -1612,13 +1612,13 @@ armor_or_accessory_off(struct obj *obj) Strcpy(why, "; it's embedded"); } You_cant("take that off%s.", why); - return 0; + return ECMD_OK; } reset_remarm(); /* clear context.takeoff.mask and context.takeoff.what */ (void) select_off(obj); if (!g.context.takeoff.mask) - return 0; + return ECMD_OK; /* none of armoroff()/Ring_/Amulet/Blindf_off() use context.takeoff.mask */ reset_remarm(); @@ -1643,10 +1643,10 @@ armor_or_accessory_off(struct obj *obj) if (obj->owornmask) remove_worn_item(obj, FALSE); } - return 1; + return ECMD_TIME; } -/* the 'T' command */ +/* the #takeoff command - remove worn armor */ int dotakeoff(void) { @@ -1662,17 +1662,17 @@ dotakeoff(void) : "dragon scale mail is"); else pline("Not wearing any armor or accessories."); - return 0; + return ECMD_OK; } if (Narmorpieces != 1 || ParanoidRemove) otmp = getobj("take off", takeoff_ok, GETOBJ_NOFLAGS); if (!otmp) - return 0; + return ECMD_OK; return armor_or_accessory_off(otmp); } -/* the 'R' command */ +/* the #remove command - take off ring or other accessory */ int doremring(void) { @@ -1681,12 +1681,12 @@ doremring(void) count_worn_stuff(&otmp, TRUE); if (!Naccessories && !Narmorpieces) { pline("Not wearing any accessories or armor."); - return 0; + return ECMD_OK; } if (Naccessories != 1 || ParanoidRemove) otmp = getobj("remove", remove_ok, GETOBJ_NOFLAGS); if (!otmp) - return 0; + return ECMD_OK; return armor_or_accessory_off(otmp); } @@ -2015,7 +2015,7 @@ accessory_or_armor_on(struct obj *obj) if (obj->owornmask & (W_ACCESSORY | W_ARMOR)) { already_wearing(c_that_); - return 0; + return ECMD_OK; } armor = (obj->oclass == ARMOR_CLASS); ring = (obj->oclass == RING_CLASS || obj->otyp == MEAT_RING); @@ -2024,7 +2024,7 @@ accessory_or_armor_on(struct obj *obj) /* checks which are performed prior to actually touching the item */ if (armor) { if (!canwearobj(obj, &mask, TRUE)) - return 0; + return ECMD_OK; if (obj->otyp == HELM_OF_OPPOSITE_ALIGNMENT && qstart_level.dnum == u.uz.dnum) { /* in quest */ @@ -2035,7 +2035,7 @@ accessory_or_armor_on(struct obj *obj) u.ublessed = 0; /* lose your god's protection */ makeknown(obj->otyp); g.context.botl = 1; /*for AC after zeroing u.ublessed */ - return 1; + return ECMD_TIME; } } else { /* @@ -2054,13 +2054,13 @@ accessory_or_armor_on(struct obj *obj) if (nolimbs(g.youmonst.data)) { You("cannot make the ring stick to your body."); - return 0; + return ECMD_OK; } if (uleft && uright) { There("are no more %s%s to fill.", humanoid(g.youmonst.data) ? "ring-" : "", fingers_or_gloves(FALSE)); - return 0; + return ECMD_OK; } if (uleft) { mask = RIGHT_RING; @@ -2075,7 +2075,7 @@ accessory_or_armor_on(struct obj *obj) switch (answer) { case '\0': case '\033': - return 0; + return ECMD_OK; case 'l': case 'L': mask = LEFT_RING; @@ -2091,13 +2091,14 @@ accessory_or_armor_on(struct obj *obj) Your( "%s are too slippery to remove, so you cannot put on the ring.", gloves_simple_name(uarmg)); - return 1; /* always uses move */ + return ECMD_TIME; /* always uses move */ } if (uarmg && uarmg->cursed) { res = !uarmg->bknown; set_bknown(uarmg, 1); You("cannot remove your %s to put on the ring.", c_gloves); - return res; /* uses move iff we learned gloves are cursed */ + /* uses move iff we learned gloves are cursed */ + return res ? ECMD_TIME : ECMD_OK; } if (uwep) { res = !uwep->bknown; /* check this before calling welded() */ @@ -2109,18 +2110,19 @@ accessory_or_armor_on(struct obj *obj) hand = makeplural(hand); You("cannot free your weapon %s to put on the ring.", hand); - return res; /* uses move iff we learned weapon is cursed */ + /* uses move iff we learned weapon is cursed */ + return res ? ECMD_TIME : ECMD_OK; } } } else if (obj->oclass == AMULET_CLASS) { if (uamul) { already_wearing("an amulet"); - return 0; + return ECMD_OK; } } else if (eyewear) { if (!has_head(g.youmonst.data)) { You("have no head to wear %s on.", ansimpleoname(obj)); - return 0; + return ECMD_OK; } if (ublindf) { @@ -2140,17 +2142,17 @@ accessory_or_armor_on(struct obj *obj) } else { already_wearing(something); /* ??? */ } - return 0; + return ECMD_OK; } } else { /* neither armor nor accessory */ You_cant("wear that!"); - return 0; + return ECMD_OK; } } if (!retouch_object(&obj, FALSE)) - return 1; /* costs a turn even though it didn't get worn */ + return ECMD_TIME; /* costs a turn even though it didn't get worn */ if (armor) { int delay; @@ -2220,10 +2222,10 @@ accessory_or_armor_on(struct obj *obj) if (give_feedback && is_worn(obj)) prinv((char *) 0, obj, 0L); } - return 1; + return ECMD_TIME; } -/* the 'W' command */ +/* the #wear command */ int dowear(void) { @@ -2233,19 +2235,19 @@ dowear(void) verysmall() or nohands() checks for shields, gloves, etc... */ if (verysmall(g.youmonst.data) || nohands(g.youmonst.data)) { pline("Don't even bother."); - return 0; + return ECMD_OK; } if (uarm && uarmu && uarmc && uarmh && uarms && uarmg && uarmf && uleft && uright && uamul && ublindf) { /* 'W' message doesn't mention accessories */ You("are already wearing a full complement of armor."); - return 0; + return ECMD_OK; } otmp = getobj("wear", wear_ok, GETOBJ_NOFLAGS); - return otmp ? accessory_or_armor_on(otmp) : 0; + return otmp ? accessory_or_armor_on(otmp) : ECMD_OK; } -/* the 'P' command */ +/* the #puton command */ int doputon(void) { @@ -2258,10 +2260,10 @@ doputon(void) humanoid(g.youmonst.data) ? "ring-" : "", fingers_or_gloves(FALSE), (ublindf->otyp == LENSES) ? "some lenses" : "a blindfold"); - return 0; + return ECMD_OK; } otmp = getobj("put on", puton_ok, GETOBJ_NOFLAGS); - return otmp ? accessory_or_armor_on(otmp) : 0; + return otmp ? accessory_or_armor_on(otmp) : ECMD_OK; } /* calculate current armor class */ @@ -2777,7 +2779,7 @@ reset_remarm(void) g.context.takeoff.disrobing[0] = '\0'; } -/* the 'A' command -- remove multiple worn items */ +/* the #takeoffall command -- remove multiple worn items */ int doddoremarm(void) { @@ -2786,11 +2788,11 @@ doddoremarm(void) if (g.context.takeoff.what || g.context.takeoff.mask) { You("continue %s.", g.context.takeoff.disrobing); set_occupation(take_off, g.context.takeoff.disrobing, 0); - return 0; + return ECMD_OK; } else if (!uwep && !uswapwep && !uquiver && !uamul && !ublindf && !uleft && !uright && !wearing_armor()) { You("are not wearing anything."); - return 0; + return ECMD_OK; } add_valid_menu_class(0); /* reset */ @@ -2813,7 +2815,7 @@ doddoremarm(void) * in take_off(); if we return 1, that would add an extra turn to each * disrobe. */ - return 0; + return ECMD_OK; } static int diff --git a/src/dokick.c b/src/dokick.c index 376e359d0..2d32bd992 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -759,6 +759,7 @@ kickstr(char *buf, const char *kickobjnam) return strcat(strcpy(buf, "kicking "), what); } +/* the #kick command */ int dokick(void) { @@ -780,9 +781,9 @@ dokick(void) if (yn_function("Kick your steed?", ynchars, 'y') == 'y') { You("kick %s.", mon_nam(u.usteed)); kick_steed(); - return 1; + return ECMD_TIME; } else { - return 0; + return ECMD_OK; } } else if (Wounded_legs) { legs_in_no_shape("kicking", FALSE); @@ -817,13 +818,13 @@ dokick(void) if (no_kick) { /* ignore direction typed before player notices kick failed */ display_nhwindow(WIN_MESSAGE, TRUE); /* --More-- */ - return 0; + return ECMD_OK; } if (!getdir((char *) 0)) - return 0; + return ECMD_OK; if (!u.dx && !u.dy) - return 0; + return ECMD_OK; x = u.ux + u.dx; y = u.uy + u.dy; @@ -849,11 +850,11 @@ dokick(void) Your("feeble kick has no effect."); break; } - return 1; + return ECMD_TIME; } else if (u.utrap && u.utraptype == TT_PIT) { /* must be Passes_walls */ You("kick at the side of the pit."); - return 1; + return ECMD_TIME; } if (Levitation) { int xx, yy; @@ -868,7 +869,7 @@ dokick(void) && !IS_DOOR(levl[xx][yy].typ) && (!Is_airlevel(&u.uz) || !OBJ_AT(xx, yy))) { You("have nothing to brace yourself against."); - return 0; + return ECMD_OK; } } @@ -880,7 +881,7 @@ dokick(void) if (mtmp) { oldglyph = glyph_at(x, y); if (!maybe_kick_monster(mtmp, x, y)) - return g.context.move; + return (g.context.move ? ECMD_TIME : ECMD_OK); } wake_nearby(); @@ -940,13 +941,13 @@ dokick(void) range = 1; hurtle(-u.dx, -u.dy, range, TRUE); } - return 1; + return ECMD_TIME; } (void) unmap_invisible(x, y); if (is_pool(x, y) ^ !!u.uinwater) { /* objects normally can't be removed from water by kicking */ You("splash some %s around.", hliquid("water")); - return 1; + return ECMD_TIME; } if (OBJ_AT(x, y) && (!Levitation || Is_airlevel(&u.uz) @@ -954,7 +955,7 @@ dokick(void) if (kick_object(x, y, kickobjnam)) { if (Is_airlevel(&u.uz)) hurtle(-u.dx, -u.dy, 1, TRUE); /* assume it's light */ - return 1; + return ECMD_TIME; } goto ouch; } @@ -980,7 +981,7 @@ dokick(void) if (g.maploc->doormask == D_ISOPEN || g.maploc->doormask == D_NODOOR) unblock_point(x, y); /* vision */ - return 1; + return ECMD_TIME; } else goto ouch; } @@ -991,7 +992,7 @@ dokick(void) g.maploc->typ = CORR; feel_newsym(x, y); /* we know it's gone */ unblock_point(x, y); /* vision */ - return 1; + return ECMD_TIME; } else goto ouch; } @@ -1010,7 +1011,7 @@ dokick(void) newsym(x, y); } exercise(A_DEX, TRUE); - return 1; + return ECMD_TIME; } else if (Luck > 0 && !rn2(3) && !g.maploc->looted) { (void) mkgold((long) rn1(201, 300), x, y); i = Luck + 1; @@ -1028,11 +1029,11 @@ dokick(void) } /* prevent endless milking */ g.maploc->looted = T_LOOTED; - return 1; + return ECMD_TIME; } else if (!rn2(4)) { if (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz)) { fall_through(FALSE, 0); - return 1; + return ECMD_TIME; } else goto ouch; } @@ -1046,7 +1047,7 @@ dokick(void) if (!rn2(3)) goto ouch; exercise(A_DEX, TRUE); - return 1; + return ECMD_TIME; } if (IS_FOUNTAIN(g.maploc->typ)) { if (Levitation) @@ -1061,7 +1062,7 @@ dokick(void) /* could cause short-lived fumbling here */ } exercise(A_DEX, TRUE); - return 1; + return ECMD_TIME; } if (IS_GRAVE(g.maploc->typ)) { if (Levitation) @@ -1083,7 +1084,7 @@ dokick(void) pline_The("headstone topples over and breaks!"); newsym(x, y); } - return 1; + return ECMD_TIME; } if (g.maploc->typ == IRONBARS) goto ouch; @@ -1121,7 +1122,7 @@ dokick(void) exercise(A_WIS, TRUE); /* discovered a new food source! */ newsym(x, y); g.maploc->looted |= TREE_LOOTED; - return 1; + return ECMD_TIME; } else if (!(g.maploc->looted & TREE_SWARM)) { int cnt = rnl(4) + 2; int made = 0; @@ -1140,7 +1141,7 @@ dokick(void) else You("smell stale honey."); g.maploc->looted |= TREE_SWARM; - return 1; + return ECMD_TIME; } goto ouch; } @@ -1155,7 +1156,7 @@ dokick(void) else pline("Klunk!"); exercise(A_DEX, TRUE); - return 1; + return ECMD_TIME; } else if (!(g.maploc->looted & S_LPUDDING) && !rn2(3) && !(g.mvitals[PM_BLACK_PUDDING].mvflags & G_GONE)) { if (Blind) @@ -1167,7 +1168,7 @@ dokick(void) exercise(A_DEX, TRUE); newsym(x, y); g.maploc->looted |= S_LPUDDING; - return 1; + return ECMD_TIME; } else if (!(g.maploc->looted & S_LDWASHER) && !rn2(3) && !(g.mvitals[PM_AMOROUS_DEMON].mvflags & G_GONE)) { /* can't resist... */ @@ -1178,7 +1179,7 @@ dokick(void) newsym(x, y); g.maploc->looted |= S_LDWASHER; exercise(A_DEX, TRUE); - return 1; + return ECMD_TIME; } else if (!rn2(3)) { if (Blind && Deaf) Sprintf(buf, " %s", body_part(FACE)); @@ -1199,7 +1200,7 @@ dokick(void) exercise(A_WIS, TRUE); /* a discovery! */ g.maploc->looted |= S_LRING; } - return 1; + return ECMD_TIME; } goto ouch; } @@ -1227,7 +1228,7 @@ dokick(void) losehp(Maybe_Half_Phys(dmg), kickstr(buf, kickobjnam), KILLED_BY); if (Is_airlevel(&u.uz) || Levitation) hurtle(-u.dx, -u.dy, rn1(2, 4), TRUE); /* assume it's heavy */ - return 1; + return ECMD_TIME; } goto dumb; } @@ -1247,7 +1248,7 @@ dokick(void) } if ((Is_airlevel(&u.uz) || Levitation) && rn2(2)) hurtle(-u.dx, -u.dy, 1, TRUE); - return 1; /* uses a turn */ + return ECMD_TIME; /* uses a turn */ } /* not enough leverage to kick open doors while levitating */ @@ -1314,7 +1315,7 @@ dokick(void) } } } - return 1; + return ECMD_TIME; } static void diff --git a/src/dothrow.c b/src/dothrow.c index 4e0ef19ed..ee851c6ef 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -98,7 +98,7 @@ throw_obj(struct obj *obj, int shotlimit) if (obj->o_id == g.context.objsplit.parent_oid || obj->o_id == g.context.objsplit.child_oid) (void) unsplitobj(obj); - return 0; /* no time passes */ + return ECMD_OK; /* no time passes */ } /* @@ -110,23 +110,23 @@ throw_obj(struct obj *obj, int shotlimit) * possibly using a sling. */ if (obj->oclass == COIN_CLASS && obj != uquiver) - return throw_gold(obj); + return throw_gold(obj); /* check */ if (!canletgo(obj, "throw")) { - return 0; + return ECMD_OK; } if (obj->oartifact == ART_MJOLLNIR && obj != uwep) { pline("%s must be wielded before it can be thrown.", The(xname(obj))); - return 0; + return ECMD_OK; } if ((obj->oartifact == ART_MJOLLNIR && ACURR(A_STR) < STR19(25)) || (obj->otyp == BOULDER && !throws_rocks(g.youmonst.data))) { pline("It's too heavy."); - return 1; + return ECMD_TIME; } if (!u.dx && !u.dy && !u.dz) { You("cannot throw an object at yourself."); - return 0; + return ECMD_OK; } u_wipe_engr(2); if (!uarmg && obj->otyp == CORPSE && touch_petrifies(&mons[obj->corpsenm]) @@ -141,7 +141,7 @@ throw_obj(struct obj *obj, int shotlimit) } if (welded(obj)) { weldmsg(obj); - return 1; + return ECMD_TIME; } if (is_wet_towel(obj)) dry_a_towel(obj, -1, FALSE); @@ -250,7 +250,7 @@ throw_obj(struct obj *obj, int shotlimit) g.m_shot.o = STRANGE_OBJECT; g.m_shot.s = FALSE; - return 1; + return ECMD_TIME; } /* common to dothrow() and dofire() */ @@ -308,7 +308,7 @@ throw_ok(struct obj *obj) return GETOBJ_DOWNPLAY; } -/* t command - throw */ +/* the #throw command */ int dothrow(void) { @@ -327,13 +327,13 @@ dothrow(void) * [3.6.0: shot count setup has been moved into ok_to_throw().] */ if (!ok_to_throw(&shotlimit)) - return 0; + return ECMD_OK; obj = getobj("throw", throw_ok, GETOBJ_PROMPT | GETOBJ_ALLOWCNT); /* it is also possible to throw food */ /* (or jewels, or iron balls... ) */ - return obj ? throw_obj(obj, shotlimit) : 0; + return obj ? throw_obj(obj, shotlimit) : ECMD_OK; } /* KMH -- Automatically fill quiver */ @@ -417,7 +417,7 @@ find_launcher(struct obj *ammo) return (struct obj *)0; } -/* f command -- fire: throw from the quiver or use wielded polearm */ +/* the #fire command -- throw from the quiver or use wielded polearm */ int dofire(void) { @@ -439,7 +439,7 @@ dofire(void) * aborted (ESC at the direction prompt).] */ if (!ok_to_throw(&shotlimit)) - return 0; + return ECMD_OK; if ((obj = uquiver) == 0) { if (!flags.autoquiver) { @@ -456,7 +456,7 @@ dofire(void) swap to it and retry */ cmdq_add_ec(doswapweapon); cmdq_add_ec(dofire); - return 0; + return ECMD_OK; } else You("have no ammunition readied."); } @@ -495,7 +495,7 @@ dofire(void) /* swap weapons and retry fire */ cmdq_add_ec(doswapweapon); cmdq_add_ec(dofire); - return 0; + return ECMD_OK; } else if ((olauncher = find_launcher(obj)) != 0) { /* wield launcher, retry fire */ if (uwep && !flags.pushweapon) @@ -503,11 +503,11 @@ dofire(void) cmdq_add_ec(dowield); cmdq_add_key(olauncher->invlet); cmdq_add_ec(dofire); - return 0; + return ECMD_OK; } } - return obj ? throw_obj(obj, shotlimit) : 0; + return obj ? throw_obj(obj, shotlimit) : ECMD_OK; } /* if in midst of multishot shooting/throwing, stop early */ @@ -2289,7 +2289,7 @@ throw_gold(struct obj *obj) if (obj->o_id == g.context.objsplit.parent_oid || obj->o_id == g.context.objsplit.child_oid) (void) unsplitobj(obj); - return 0; + return ECMD_OK; } freeinv(obj); if (u.uswallow) { @@ -2297,7 +2297,7 @@ throw_gold(struct obj *obj) : "%s into %s.", "The gold disappears", mon_nam(u.ustuck)); add_to_minv(u.ustuck, obj); - return 1; + return ECMD_TIME; } if (u.dz) { @@ -2327,19 +2327,19 @@ throw_gold(struct obj *obj) (int (*)(MONST_P, OBJ_P)) 0, (int (*)(OBJ_P, OBJ_P)) 0, &obj); if (!obj) - return 1; /* object is gone */ + return ECMD_TIME; /* object is gone */ if (mon) { if (ghitm(mon, obj)) /* was it caught? */ - return 1; + return ECMD_TIME; } else { if (ship_object(obj, g.bhitpos.x, g.bhitpos.y, FALSE)) - return 1; + return ECMD_TIME; } } } if (flooreffects(obj, g.bhitpos.x, g.bhitpos.y, "fall")) - return 1; + return ECMD_TIME; if (u.dz > 0) pline_The("gold hits the %s.", surface(g.bhitpos.x, g.bhitpos.y)); place_object(obj, g.bhitpos.x, g.bhitpos.y); @@ -2347,7 +2347,7 @@ throw_gold(struct obj *obj) sellobj(obj, g.bhitpos.x, g.bhitpos.y); stackobj(obj); newsym(g.bhitpos.x, g.bhitpos.y); - return 1; + return ECMD_TIME; } /*dothrow.c*/ diff --git a/src/dungeon.c b/src/dungeon.c index 68bc7e3f0..a7165b013 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -2431,7 +2431,7 @@ donamelevel(void) char nbuf[BUFSZ]; /* Buffer for response */ if (!(mptr = find_mapseen(&u.uz))) - return 0; + return ECMD_OK; nbuf[0] = '\0'; #ifdef EDIT_GETLIN @@ -2453,7 +2453,7 @@ donamelevel(void) /* empty input or ESC means don't add or change annotation; space-only means discard current annotation without adding new one */ if (!*nbuf || *nbuf == '\033') - return 0; + return ECMD_OK; /* strip leading and trailing spaces, compress out consecutive spaces */ (void) mungspaces(nbuf); @@ -2469,7 +2469,7 @@ donamelevel(void) mptr->custom = dupstr(nbuf); mptr->custom_lth = strlen(mptr->custom); } - return 0; + return ECMD_OK; } /* find the particular mapseen object in the chain; may return null */ @@ -3088,7 +3088,7 @@ int dooverview(void) { show_overview(0, 0); - return 0; + return ECMD_OK; } /* called for #overview or for end of game disclosure */ diff --git a/src/eat.c b/src/eat.c index e9bb086a7..b560b0621 100644 --- a/src/eat.c +++ b/src/eat.c @@ -2480,7 +2480,7 @@ edibility_prompts(struct obj *otmp) return 0; } -/* 'e' command */ +/* the #eat command */ int doeat(void) { @@ -2491,12 +2491,12 @@ doeat(void) if (Strangled) { pline("If you can't breathe air, how can you consume solids?"); - return 0; + return ECMD_OK; } if (!(otmp = floorfood("eat", 0))) - return 0; + return ECMD_OK; if (check_capacity((char *) 0)) - return 0; + return ECMD_OK; if (u.uedibility) { int res = edibility_prompts(otmp); @@ -2507,7 +2507,7 @@ doeat(void) body_part(NOSE)); u.uedibility = 0; if (res == 1) - return 0; + return ECMD_OK; } } @@ -2521,7 +2521,7 @@ doeat(void) bars so wouldn't know that more turns of eating are required */ You("pause to swallow."); } - return 1; + return ECMD_TIME; } /* We have to make non-foods take 1 move to eat, unless we want to * do ridiculous amounts of coding to deal with partly eaten plate @@ -2530,15 +2530,15 @@ doeat(void) */ if (!is_edible(otmp)) { You("cannot eat that!"); - return 0; + return ECMD_OK; } else if ((otmp->owornmask & (W_ARMOR | W_TOOL | W_AMUL | W_SADDLE)) != 0) { /* let them eat rings */ You_cant("eat %s you're wearing.", something); - return 0; + return ECMD_OK; } else if (!(carried(otmp) ? retouch_object(&otmp, FALSE) : touch_artifact(otmp, &g.youmonst))) { - return 1; /* got blasted so use a turn */ + return ECMD_TIME; /* got blasted so use a turn */ } if (is_metallic(otmp) && u.umonnum == PM_RUST_MONSTER && otmp->oerodeproof) { @@ -2573,7 +2573,7 @@ doeat(void) } stackobj(otmp); } - return 1; + return ECMD_TIME; } /* KMH -- Slow digestion is... indigestible */ if (otmp->otyp == RIN_SLOW_DIGESTION) { @@ -2582,7 +2582,7 @@ doeat(void) if (otmp->dknown && !objects[otmp->otyp].oc_name_known && !objects[otmp->otyp].oc_uname) docall(otmp); - return 1; + return ECMD_TIME; } if (otmp->oclass != FOOD_CLASS) { int material; @@ -2646,7 +2646,7 @@ doeat(void) : singular(otmp, xname)); } eatspecial(); - return 1; + return ECMD_TIME; } if (otmp == g.context.victual.piece) { @@ -2671,7 +2671,7 @@ doeat(void) You("%s your meal.", !one_bite_left ? "resume" : "consume the last bite of"); start_eating(g.context.victual.piece, FALSE); - return 1; + return ECMD_TIME; } /* nothing in progress - so try to find something. */ @@ -2679,7 +2679,7 @@ doeat(void) /* tins must also check conduct separately in case they're discarded */ if (otmp->otyp == TIN) { start_tin(otmp); - return 1; + return ECMD_TIME; } /* KMH, conduct */ @@ -2703,7 +2703,7 @@ doeat(void) /* used up */ g.context.victual.piece = (struct obj *) 0; g.context.victual.o_id = 0; - return 1; + return ECMD_TIME; } else if (tmp) dont_start = TRUE; /* if not used up, eatcorpse sets up reqtime and may modify oeaten */ @@ -2777,7 +2777,7 @@ doeat(void) if (!dont_start) start_eating(otmp, already_partly_eaten); - return 1; + return ECMD_TIME; } /* getobj callback for object to be opened with a tin opener */ @@ -2795,11 +2795,11 @@ int use_tin_opener(struct obj *obj) { struct obj *otmp; - int res = 0; + int res = ECMD_OK; if (!carrying(TIN)) { You("have no tin to open."); - return 0; + return ECMD_OK; } if (obj != uwep) { @@ -2808,11 +2808,11 @@ use_tin_opener(struct obj *obj) if (ynq(safe_qbuf(qbuf, "Really wield ", "?", obj, doname, thesimpleoname, "that")) != 'y') - return 0; + return ECMD_OK; } if (!wield_tool(obj, "use")) - return 0; - res = 1; + return ECMD_OK; + res = ECMD_TIME; } otmp = getobj("open", tinopen_ok, GETOBJ_NOFLAGS); @@ -2820,7 +2820,7 @@ use_tin_opener(struct obj *obj) return res; start_tin(otmp); - return 1; + return ECMD_TIME; } /* Take a single bite from a piece of food, checking for choking and diff --git a/src/end.c b/src/end.c index ad69bfe9e..c7384e14a 100644 --- a/src/end.c +++ b/src/end.c @@ -340,7 +340,7 @@ done2(void) u.uinvulnerable = FALSE; /* avoid ctrl-C bug -dlc */ u.usleep = 0; } - return 0; + return ECMD_OK; } #if (defined(UNIX) || defined(VMS) || defined(LATTICE)) if (wizard) { @@ -369,7 +369,7 @@ done2(void) #ifndef LINT done(QUIT); #endif - return 0; + return ECMD_OK; } #ifndef NO_SIGNAL diff --git a/src/engrave.c b/src/engrave.c index c9cb75092..68ffa0b81 100644 --- a/src/engrave.c +++ b/src/engrave.c @@ -513,7 +513,7 @@ u_can_engrave(void) * moonstone - 6 (orthoclase) * amber - 2-2.5 */ -/* return 1 if action took 1 (or more) moves, 0 if error or aborted */ +/* the #engrave command */ int doengrave(void) { @@ -554,7 +554,7 @@ doengrave(void) /* Can the adventurer engrave at all? */ if (!u_can_engrave()) - return 0; + return ECMD_OK; jello = (u.uswallow && !(is_animal(u.ustuck->data) || is_whirly(u.ustuck->data))); @@ -565,7 +565,7 @@ doengrave(void) otmp = getobj("write with", stylus_ok, GETOBJ_PROMPT); if (!otmp) /* otmp == cg.zeroobj if fingers */ - return 0; + return ECMD_OK; if (otmp == &cg.zeroobj) { Strcat(strcpy(fbuf, "your "), body_part(FINGERTIP)); @@ -579,34 +579,34 @@ doengrave(void) */ if (!freehand() && otmp != uwep && !otmp->owornmask) { You("have no free %s to write with!", body_part(HAND)); - return 0; + return ECMD_OK; } if (jello) { You("tickle %s with %s.", mon_nam(u.ustuck), writer); Your("message dissolves..."); - return 0; + return ECMD_OK; } if (otmp->oclass != WAND_CLASS && !can_reach_floor(TRUE)) { cant_reach_floor(u.ux, u.uy, FALSE, TRUE); - return 0; + return ECMD_OK; } if (IS_ALTAR(levl[u.ux][u.uy].typ)) { You("make a motion towards the altar with %s.", writer); altar_wrath(u.ux, u.uy); - return 0; + return ECMD_OK; } if (IS_GRAVE(levl[u.ux][u.uy].typ)) { if (otmp == &cg.zeroobj) { /* using only finger */ You("would only make a small smudge on the %s.", surface(u.ux, u.uy)); - return 0; + return ECMD_OK; } else if (!levl[u.ux][u.uy].disturbed) { You("disturb the undead!"); levl[u.ux][u.uy].disturbed = 1; (void) makemon(&mons[PM_GHOUL], u.ux, u.uy, NO_MM_FLAGS); exercise(A_WIS, FALSE); - return 1; + return ECMD_TIME; } } @@ -663,7 +663,7 @@ doengrave(void) check_unpaid(otmp); if (otmp->cursed && !rn2(WAND_BACKFIRE_CHANCE)) { wand_explode(otmp, 0); - return 1; + return ECMD_TIME; } zapwand = TRUE; if (!can_reach_floor(TRUE)) @@ -850,7 +850,7 @@ doengrave(void) if (otmp == ublindf) { pline( "That is a bit difficult to engrave with, don't you think?"); - return 0; + return ECMD_OK; } switch (otmp->otyp) { case MAGIC_MARKER: @@ -951,7 +951,7 @@ doengrave(void) if (!ptext) { if (otmp && otmp->oclass == WAND_CLASS && !can_reach_floor(TRUE)) cant_reach_floor(u.ux, u.uy, FALSE, TRUE); - return 1; + return ECMD_TIME; } /* * Special effects should have deleted the current engraving (if @@ -971,7 +971,7 @@ doengrave(void) ynqchars, 'y'); if (c == 'q') { pline1(Never_mind); - return 0; + return ECMD_OK; } } @@ -998,7 +998,7 @@ doengrave(void) ? (is_ice(u.ux, u.uy) ? "melted into" : "burned into") : "engraved in", surface(u.ux, u.uy)); - return 1; + return ECMD_TIME; } else if (type != oep->engr_type || c == 'n') { if (!Blind || can_reach_floor(TRUE)) You("will overwrite the current message."); @@ -1006,7 +1006,7 @@ doengrave(void) } } else if (oep && (int) strlen(oep->engr_txt) >= BUFSZ - 1) { There("is no room to add anything else here."); - return 1; + return ECMD_TIME; } } @@ -1063,10 +1063,10 @@ doengrave(void) if (!Blind) pline("%s, then %s.", Tobjnam(otmp, "glow"), otense(otmp, "fade")); - return 1; + return ECMD_TIME; } else { pline1(Never_mind); - return 0; + return ECMD_OK; } } @@ -1112,7 +1112,7 @@ doengrave(void) /* Engraving will always take at least one action via being run as an * occupation, so do not count this setup as taking time. */ - return 0; + return ECMD_OK; } /* occupation callback for engraving some text */ diff --git a/src/hack.c b/src/hack.c index 4942c4cdb..aab8e9cd0 100644 --- a/src/hack.c +++ b/src/hack.c @@ -910,7 +910,7 @@ test_move(int ux, int uy, int dx, int dy, int mode) if (flags.autoopen && !g.context.run && !Confusion && !Stunned && !Fumbling) { g.context.door_opened - = g.context.move = doopen_indir(x, y); + = g.context.move = (doopen_indir(x, y) == ECMD_TIME ? 1 : 0); } else if (x == ux || y == uy) { if (Blind || Stunned || ACURR(A_DEX) < 10 || Fumbling) { @@ -2894,7 +2894,7 @@ pickup_checks(void) return -1; /* can do normal pickup */ } -/* the ',' command */ +/* the #pickup command */ int dopickup(void) { @@ -2904,13 +2904,13 @@ dopickup(void) g.multi = 0; /* always reset */ if ((ret = pickup_checks()) >= 0) { - return ret; + return (ret ? ECMD_TIME : ECMD_OK); } else if (ret == -2) { tmpcount = -count; - return loot_mon(u.ustuck, &tmpcount, (boolean *) 0); + return (loot_mon(u.ustuck, &tmpcount, (boolean *) 0) ? ECMD_TIME : ECMD_OK); } /* else ret == -1 */ - return pickup(-count); + return (pickup(-count) ? ECMD_TIME : ECMD_OK); } /* stop running if we see something interesting next to us */ diff --git a/src/insight.c b/src/insight.c index 14d7f6597..50584fe3b 100644 --- a/src/insight.c +++ b/src/insight.c @@ -1829,7 +1829,7 @@ doattributes(void) mode |= MAGICENLIGHTENMENT; enlightenment(mode, ENL_GAMEINPROGRESS); - return 0; + return ECMD_OK; } void @@ -1895,7 +1895,7 @@ int doconduct(void) { show_conduct(0); - return 0; + return ECMD_OK; } /* display conducts; for doconduct(), also disclose() and dump_everything() */ @@ -2415,7 +2415,7 @@ int dovanquished(void) { list_vanquished('a', FALSE); - return 0; + return ECMD_OK; } DISABLE_WARNING_FORMAT_NONLITERAL @@ -2450,7 +2450,7 @@ doborn(void) display_nhwindow(datawin, FALSE); destroy_nhwindow(datawin); - return 0; + return ECMD_OK; } RESTORE_WARNING_FORMAT_NONLITERAL diff --git a/src/invent.c b/src/invent.c index f6bb20454..d8696c617 100644 --- a/src/invent.c +++ b/src/invent.c @@ -2363,7 +2363,7 @@ update_inventory(void) (*windowprocs.win_update_inventory)(0); } -/* '|' command - call interface's persistent inventory manipulation routine */ +/* the #perminv command - call interface's persistent inventory routine */ int doperminv(void) { @@ -2407,7 +2407,7 @@ doperminv(void) } /* iflags.perm_invent */ - return 0; + return ECMD_OK; } /* should of course only be called for things in invent */ @@ -2483,12 +2483,12 @@ xprname(struct obj *obj, RESTORE_WARNING_FORMAT_NONLITERAL -/* the 'i' command */ +/* the #inventory command */ int ddoinv(void) { (void) display_inventory((char *) 0, FALSE); - return 0; + return ECMD_OK; } /* @@ -3132,7 +3132,7 @@ this_type_only(struct obj *obj) return res; } -/* the 'I' command */ +/* the #inventtype command */ int dotypeinv(void) { @@ -3148,7 +3148,7 @@ dotypeinv(void) if (!g.invent && !billx) { You("aren't carrying anything."); - return 0; + return ECMD_OK; } unpaid_count = count_unpaid(g.invent); tally_BUCX(g.invent, FALSE, &bcnt, &ucnt, &ccnt, &xcnt, &ocnt, &jcnt); @@ -3173,7 +3173,7 @@ dotypeinv(void) i |= INCLUDE_VENOM; n = query_category(prompt, g.invent, i, &pick_list, PICK_ONE); if (!n) - return 0; + return ECMD_OK; g.this_type = c = pick_list[0].item.a_int; free((genericptr_t) pick_list); } @@ -3228,7 +3228,7 @@ dotypeinv(void) savech(c); if (c == '\0') { clear_nhwindow(WIN_MESSAGE); - return 0; + return ECMD_OK; } } else { /* only one thing to itemize */ @@ -3246,14 +3246,14 @@ dotypeinv(void) else pline("No used-up objects%s.", unpaid_count ? " on your shopping bill" : ""); - return 0; + return ECMD_OK; } if (c == 'u' || (c == 'U' && unpaid_count && !ucnt)) { if (unpaid_count) dounpaid(); else You("are not carrying any unpaid objects."); - return 0; + return ECMD_OK; } if (traditional) { if (index("BUCXP", c)) @@ -3294,7 +3294,7 @@ dotypeinv(void) break; } You("have no %sobjects%s.", before, after); - return 0; + return ECMD_OK; } g.this_type = oclass; } @@ -3303,7 +3303,7 @@ dotypeinv(void) | INVORDER_SORT | INCLUDE_VENOM), &pick_list, PICK_NONE, this_type_only) > 0) free((genericptr_t) pick_list); - return 0; + return ECMD_OK; } /* return a string describing the dungeon feature at if there @@ -3434,7 +3434,7 @@ look_here(int obj_cnt, /* obj_cnt > 0 implies that autopickup is in progress */ } else { You("%s no objects here.", verb); } - return !!Blind; + return (!!Blind ? ECMD_TIME : ECMD_OK); } if (!skip_objects && (trap = t_at(u.ux, u.uy)) && trap->tseen) There("is %s here.", an(trapname(trap->ttyp, FALSE))); @@ -3466,7 +3466,7 @@ look_here(int obj_cnt, /* obj_cnt > 0 implies that autopickup is in progress */ trap = t_at(u.ux, u.uy); if (!can_reach_floor(trap && is_pit(trap->ttyp))) { pline("But you can't reach it!"); - return 0; + return ECMD_OK; } } @@ -3480,7 +3480,7 @@ look_here(int obj_cnt, /* obj_cnt > 0 implies that autopickup is in progress */ read_engr_at(u.ux, u.uy); /* Eric Backus */ if (!skip_objects && (Blind || !dfeature)) You("%s no objects here.", verb); - return !!Blind; + return (!!Blind ? ECMD_TIME : ECMD_OK); } /* we know there is something here */ @@ -3550,10 +3550,10 @@ look_here(int obj_cnt, /* obj_cnt > 0 implies that autopickup is in progress */ feel_cockatrice(otmp, FALSE); read_engr_at(u.ux, u.uy); /* Eric Backus */ } - return !!Blind; + return (!!Blind ? ECMD_TIME : ECMD_OK); } -/* the ':' command - explicitly look at what is here, including all objects */ +/* #look command - explicitly look at what is here, including all objects */ int dolook(void) { @@ -3718,7 +3718,7 @@ mergable(register struct obj *otmp, register struct obj *obj) return FALSE; } -/* the '$' command */ +/* the #showgold command */ int doprgold(void) { @@ -3731,10 +3731,10 @@ doprgold(void) else Your("wallet contains %ld %s.", umoney, currency(umoney)); shopper_financial_report(); - return 0; + return ECMD_OK; } -/* the ')' command */ +/* the #seeweapon command */ int doprwep(void) { @@ -3745,7 +3745,7 @@ doprwep(void) if (u.twoweap) prinv((char *) 0, uswapwep, 0L); } - return 0; + return ECMD_OK; } /* caller is responsible for checking !wearing_armor() */ @@ -3771,7 +3771,7 @@ noarmor(boolean report_uskin) } } -/* the '[' command */ +/* the #seearmor command */ int doprarm(void) { @@ -3803,10 +3803,10 @@ doprarm(void) lets[ct] = 0; (void) display_inventory(lets, FALSE); } - return 0; + return ECMD_OK; } -/* the '=' command */ +/* the #seerings command */ int doprring(void) { @@ -3823,10 +3823,10 @@ doprring(void) lets[ct] = 0; (void) display_inventory(lets, FALSE); } - return 0; + return ECMD_OK; } -/* the '"' command */ +/* the #seeamulet command */ int dopramulet(void) { @@ -3834,7 +3834,7 @@ dopramulet(void) You("are not wearing an amulet."); else prinv((char *) 0, uamul, 0L); - return 0; + return ECMD_OK; } /* is 'obj' a tool that's in use? can't simply check obj->owornmask */ @@ -3849,7 +3849,7 @@ tool_being_used(struct obj *obj) || (obj->otyp == LEASH && obj->leashmon)); } -/* the '(' command */ +/* the #seetools command */ int doprtool(void) { @@ -3870,10 +3870,10 @@ doprtool(void) You("are not using any tools."); else (void) display_inventory(lets, FALSE); - return 0; + return ECMD_OK; } -/* '*' command; combines the ')' + '[' + '=' + '"' + '(' commands; +/* the #seeall command; combines the ')' + '[' + '=' + '"' + '(' commands; show inventory of all currently wielded, worn, or used objects */ int doprinuse(void) @@ -3895,7 +3895,7 @@ doprinuse(void) You("are not wearing or wielding anything."); else (void) display_inventory(lets, FALSE); - return 0; + return ECMD_OK; } /* @@ -4140,7 +4140,7 @@ doorganize(void) /* inventory organizer by Del Lamb */ && g.invent->invlet == GOLD_SYM && !g.invent->nobj)) { You("aren't carrying anything %s.", !g.invent ? "to adjust" : "adjustable"); - return 0; + return ECMD_OK; } if (!flags.invlet_constant) @@ -4152,7 +4152,7 @@ doorganize(void) /* inventory organizer by Del Lamb */ /* get object the user wants to organize (the 'from' slot) */ obj = getobj("adjust", adjust_filter, GETOBJ_PROMPT | GETOBJ_ALLOWCNT); if (!obj) - return 0; + return ECMD_OK; /* can only be gold if check_invent_gold() found a problem: multiple '$' stacks and/or gold in some other slot, otherwise (*adjust_filter)() won't allow gold to be picked; if player has picked any stack of gold @@ -4226,7 +4226,7 @@ doorganize(void) /* inventory organizer by Del Lamb */ (void) merged(&splitting, &obj); if (!ever_mind) pline1(Never_mind); - return 0; + return ECMD_OK; } else if (let == GOLD_SYM && obj->oclass != COIN_CLASS) { pline("Only gold coins may be moved into the '%c' slot.", GOLD_SYM); @@ -4303,7 +4303,7 @@ doorganize(void) /* inventory organizer by Del Lamb */ (void) merged(&splitting, &obj); /* undo split */ /* "knapsack cannot accommodate any more items" */ Your("pack is too full."); - return 0; + return ECMD_OK; } else { bumped = otmp; extract_nobj(bumped, &g.invent); @@ -4338,7 +4338,7 @@ doorganize(void) /* inventory organizer by Del Lamb */ if (splitting) clear_splitobjs(); /* reset splitobj context */ update_inventory(); - return 0; + return ECMD_OK; } /* common to display_minventory and display_cinventory */ diff --git a/src/light.c b/src/light.c index 0f9d740e1..591cc0e8a 100644 --- a/src/light.c +++ b/src/light.c @@ -825,6 +825,7 @@ arti_light_description(struct obj *obj) return "strangely"; } +/* the #lightsources command */ int wiz_light_sources(void) { @@ -834,7 +835,7 @@ wiz_light_sources(void) win = create_nhwindow(NHW_MENU); /* corner text window */ if (win == WIN_ERR) - return 0; + return ECMD_OK; Sprintf(buf, "Mobile light sources: hero @ (%2d,%2d)", u.ux, u.uy); putstr(win, 0, buf); @@ -865,7 +866,7 @@ wiz_light_sources(void) display_nhwindow(win, FALSE); destroy_nhwindow(win); - return 0; + return ECMD_OK; } /*light.c*/ diff --git a/src/lock.c b/src/lock.c index 3fa068325..c311cf03e 100644 --- a/src/lock.c +++ b/src/lock.c @@ -600,7 +600,7 @@ pick_lock(struct obj *pick, return PICKLOCK_DID_SOMETHING; } -/* try to force a chest with your weapon */ +/* the #force command - try to force a chest with your weapon */ int doforce(void) { @@ -610,7 +610,7 @@ doforce(void) if (u.uswallow) { You_cant("force anything from inside here."); - return 0; + return ECMD_OK; } if (!uwep /* proper type test */ || ((uwep->oclass == WEAPON_CLASS || is_weptool(uwep)) @@ -623,18 +623,18 @@ doforce(void) : (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep)) ? "without a proper" : "with that"); - return 0; + return ECMD_OK; } if (!can_reach_floor(TRUE)) { cant_reach_floor(u.ux, u.uy, FALSE, TRUE); - return 0; + return ECMD_OK; } picktyp = is_blade(uwep) && !is_pick(uwep); if (g.xlock.usedtime && g.xlock.box && picktyp == g.xlock.picktyp) { You("resume your attempt to force the lock."); set_occupation(forcelock, "forcing the lock", 0); - return 1; + return ECMD_TIME; } /* A lock is made only for the honest man, the thief will break it. */ @@ -658,7 +658,7 @@ doforce(void) c = ynq(qbuf); if (c == 'q') - return 0; + return ECMD_OK; if (c == 'n') continue; @@ -678,7 +678,7 @@ doforce(void) set_occupation(forcelock, "forcing the lock", 0); else You("decide not to force the issue."); - return 1; + return ECMD_TIME; } boolean @@ -694,7 +694,7 @@ stumble_on_door_mimic(int x, int y) return FALSE; } -/* the 'O' command - try to open a door */ +/* the #open command - try to open a door */ int doopen(void) { @@ -708,35 +708,35 @@ doopen_indir(int x, int y) coord cc; register struct rm *door; boolean portcullis; - int res = 0; + int res = ECMD_OK; if (nohands(g.youmonst.data)) { You_cant("open anything -- you have no hands!"); - return 0; + return ECMD_OK; } if (u.utrap && u.utraptype == TT_PIT) { You_cant("reach over the edge of the pit."); - return 0; + return ECMD_OK; } 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; + return ECMD_OK; /* open at yourself/up/down */ if ((cc.x == u.ux) && (cc.y == u.uy)) return doloot(); if (stumble_on_door_mimic(cc.x, cc.y)) - return 1; + return ECMD_TIME; /* when choosing a direction is impaired, use a turn regardless of whether a door is successfully targetted */ if (Confusion || Stunned) - res = 1; + res = ECMD_TIME; door = &levl[cc.x][cc.y]; portcullis = (is_drawbridge_wall(cc.x, cc.y) >= 0); @@ -747,7 +747,7 @@ doopen_indir(int x, int y) feel_location(cc.x, cc.y); if (door->glyph != oldglyph || g.lastseentyp[cc.x][cc.y] != oldlastseentyp) - res = 1; /* learned something */ + res = ECMD_TIME; /* learned something */ } if (portcullis || !IS_DOOR(door->typ)) { @@ -786,7 +786,7 @@ doopen_indir(int x, int y) } pline("This door%s.", mesg); if (locked && flags.autounlock && (unlocktool = autokey(TRUE)) != 0) { - res = pick_lock(unlocktool, cc.x, cc.y, (struct obj *) 0); + res = pick_lock(unlocktool, cc.x, cc.y, (struct obj *) 0) ? ECMD_TIME : ECMD_OK; } return res; } @@ -813,7 +813,7 @@ doopen_indir(int x, int y) pline_The("door resists!"); } - return 1; + return ECMD_TIME; } static boolean @@ -848,45 +848,45 @@ obstructed(register int x, register int y, boolean quietly) return FALSE; } -/* the 'C' command - try to close a door */ +/* the #close command - try to close a door */ int doclose(void) { register int x, y; register struct rm *door; boolean portcullis; - int res = 0; + int res = ECMD_OK; if (nohands(g.youmonst.data)) { You_cant("close anything -- you have no hands!"); - return 0; + return ECMD_OK; } if (u.utrap && u.utraptype == TT_PIT) { You_cant("reach over the edge of the pit."); - return 0; + return ECMD_OK; } if (!getdir((char *) 0)) - return 0; + return ECMD_OK; x = u.ux + u.dx; y = u.uy + u.dy; if ((x == u.ux) && (y == u.uy)) { You("are in the way!"); - return 1; + return ECMD_TIME; } if (!isok(x, y)) goto nodoor; if (stumble_on_door_mimic(x, y)) - return 1; + return ECMD_TIME; /* when choosing a direction is impaired, use a turn regardless of whether a door is successfully targetted */ if (Confusion || Stunned) - res = 1; + res = ECMD_TIME; door = &levl[x][y]; portcullis = (is_drawbridge_wall(x, y) >= 0); @@ -896,7 +896,7 @@ doclose(void) feel_location(x, y); if (door->glyph != oldglyph || g.lastseentyp[x][y] != oldlastseentyp) - res = 1; /* learned something */ + res = ECMD_TIME; /* learned something */ } if (portcullis || !IS_DOOR(door->typ)) { @@ -942,7 +942,7 @@ doclose(void) } } - return 1; + return ECMD_TIME; } /* box obj was hit with spell or wand effect otmp; diff --git a/src/music.c b/src/music.c index 8d372d38f..6cea749a5 100644 --- a/src/music.c +++ b/src/music.c @@ -693,13 +693,13 @@ do_play_instrument(struct obj* instr) if (Underwater) { You_cant("play music underwater!"); - return 0; + return ECMD_OK; } else if ((instr->otyp == WOODEN_FLUTE || instr->otyp == MAGIC_FLUTE || instr->otyp == TOOLED_HORN || instr->otyp == FROST_HORN || instr->otyp == FIRE_HORN || instr->otyp == BUGLE) && !can_blow(&g.youmonst)) { You("are incapable of playing %s.", the(distant_name(instr, xname))); - return 0; + return ECMD_OK; } if (instr->otyp != LEATHER_DRUM && instr->otyp != DRUM_OF_EARTHQUAKE && !(Stunned || Confusion || Hallucination)) { @@ -750,7 +750,7 @@ do_play_instrument(struct obj* instr) close_drawbridge(x, y); else open_drawbridge(x, y); - return 1; + return ECMD_TIME; } } else if (!Deaf) { if (u.uevent.uheard_tune < 1) @@ -807,13 +807,13 @@ do_play_instrument(struct obj* instr) } } } - return 1; + return ECMD_TIME; } else - return do_improvisation(instr); + return do_improvisation(instr) ? ECMD_TIME : ECMD_OK; nevermind: pline1(Never_mind); - return 0; + return ECMD_OK; } /*music.c*/ diff --git a/src/o_init.c b/src/o_init.c index 00d60427b..8a4a72b30 100644 --- a/src/o_init.c +++ b/src/o_init.c @@ -606,7 +606,7 @@ choose_disco_sort( return n; } -/* the '\' command - show discovered object types */ +/* the #known command - show discovered object types */ int dodiscovered(void) /* free after Robert Viduya */ { @@ -622,7 +622,7 @@ dodiscovered(void) /* free after Robert Viduya */ if (iflags.menu_requested) { if (choose_disco_sort(1) < 0) - return 0; + return ECMD_OK; } alphabyclass = (flags.discosort == 'c'); alphabetized = (flags.discosort == 'a' || alphabyclass); @@ -722,7 +722,7 @@ dodiscovered(void) /* free after Robert Viduya */ } destroy_nhwindow(tmpwin); - return 0; + return ECMD_OK; } /* lower case let_to_name() output, which differs from def_oc_syms[].name */ @@ -737,7 +737,7 @@ oclass_to_name(char oclass, char *buf) return buf; } -/* the '`' command - show discovered object types for one class */ +/* the #knownclass command - show discovered object types for one class */ int doclassdisco(void) { @@ -760,7 +760,7 @@ doclassdisco(void) if (iflags.menu_requested) { if (choose_disco_sort(2) < 0) - return 0; + return ECMD_OK; } alphabetized = (flags.discosort == 'a' || flags.discosort == 'c'); lootsort = (flags.discosort == 's'); @@ -827,7 +827,7 @@ doclassdisco(void) You(havent_discovered_any, "items"); if (tmpwin != WIN_ERR) destroy_nhwindow(tmpwin); - return 0; + return ECMD_OK; } /* have player choose a class */ @@ -868,7 +868,7 @@ doclassdisco(void) destroy_nhwindow(tmpwin); } if (!c) - return 0; /* player declined to make a selection */ + return ECMD_OK; /* player declined to make a selection */ /* * show discoveries for object class c @@ -935,7 +935,7 @@ doclassdisco(void) if (ct) display_nhwindow(tmpwin, TRUE); destroy_nhwindow(tmpwin); - return 0; + return ECMD_OK; } /* put up nameable subset of discoveries list as a menu */ diff --git a/src/options.c b/src/options.c index 6bcca1c89..864e85a17 100644 --- a/src/options.c +++ b/src/options.c @@ -7270,7 +7270,7 @@ longest_option_name(int startpass, int endpass) return longest_name_len; } -/* the 'O' command */ +/* the #options command */ int doset(void) /* changing options via menu by Per Liboriussen */ { @@ -7460,7 +7460,7 @@ doset(void) /* changing options via menu by Per Liboriussen */ if (g.context.botl || g.context.botlx) { bot(); } - return 0; + return ECMD_OK; } /* doset('O' command) menu entries for compound options */ @@ -7719,7 +7719,7 @@ dotogglepickup(void) Strcpy(buf, "OFF"); } pline("Autopickup: %s.", buf); - return 0; + return ECMD_OK; } int diff --git a/src/pager.c b/src/pager.c index 5038ae503..dece038e3 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1325,7 +1325,7 @@ do_look(int mode, coord *click_cc) switch (i) { default: case 'q': - return 0; + return ECMD_OK; case 'y': case '/': from_screen = TRUE; @@ -1340,7 +1340,7 @@ do_look(int mode, coord *click_cc) invlet = display_inventory((const char *) 0, TRUE); if (!invlet || invlet == '\033') - return 0; + return ECMD_OK; *out_str = '\0'; for (invobj = g.invent; invobj; invobj = invobj->nobj) if (invobj->invlet == invlet) { @@ -1349,7 +1349,7 @@ do_look(int mode, coord *click_cc) } if (*out_str) checkfile(out_str, pm, TRUE, TRUE, (char *) 0); - return 0; + return ECMD_OK; } case '?': from_screen = FALSE; @@ -1359,32 +1359,32 @@ do_look(int mode, coord *click_cc) condense consecutive internal whitespace */ mungspaces(out_str); if (out_str[0] == '\0' || out_str[0] == '\033') - return 0; + return ECMD_OK; if (out_str[1]) { /* user typed in a complete string */ checkfile(out_str, pm, TRUE, TRUE, (char *) 0); - return 0; + return ECMD_OK; } sym = out_str[0]; break; case 'm': look_all(TRUE, TRUE); /* list nearby monsters */ - return 0; + return ECMD_OK; case 'M': look_all(FALSE, TRUE); /* list all monsters */ - return 0; + return ECMD_OK; case 'o': look_all(TRUE, FALSE); /* list nearby objects */ - return 0; + return ECMD_OK; case 'O': look_all(FALSE, FALSE); /* list all objects */ - return 0; + return ECMD_OK; case '^': look_traps(TRUE); /* list nearby traps */ - return 0; + return ECMD_OK; case '\"': look_traps(FALSE); /* list all traps (visible or remembered) */ - return 0; + return ECMD_OK; } } else { /* clicklook */ cc.x = click_cc->x; @@ -1463,7 +1463,7 @@ do_look(int mode, coord *click_cc) } while (from_screen && !quick && ans != LOOK_ONCE && !clicklook); flags.verbose = save_verbose; - return 0; + return ECMD_OK; } DISABLE_WARNING_FORMAT_NONLITERAL /* RESTORE is after do_supplemental_info() */ @@ -1713,21 +1713,21 @@ do_supplemental_info(char *name, struct permonst *pm, boolean without_asking) RESTORE_WARNING_FORMAT_NONLITERAL -/* the '/' command */ +/* the #whatis command */ int dowhatis(void) { return do_look(0, (coord *) 0); } -/* the ';' command */ +/* the #glance command */ int doquickwhatis(void) { return do_look(1, (coord *) 0); } -/* the '^' command */ +/* the #showtrap command */ int doidtrap(void) { @@ -1735,7 +1735,7 @@ doidtrap(void) int x, y, tt, glyph; if (!getdir("^")) - return 0; + return ECMD_OK; x = u.ux + u.dx; y = u.uy + u.dy; @@ -1746,7 +1746,7 @@ doidtrap(void) if (chesttrap || trapped_door_at(tt, x, y)) { pline("That is a trapped %s.", chesttrap ? "chest" : "door"); - return 0; /* trap ID'd, but no time elapses */ + return ECMD_OK; /* trap ID'd, but no time elapses */ } } @@ -1772,10 +1772,10 @@ doidtrap(void) ? " dug" : " set", !trap->madeby_u ? "" : " by you"); - return 0; + return ECMD_OK; } pline("I can't see a trap there."); - return 0; + return ECMD_OK; } /* @@ -2042,6 +2042,7 @@ dowhatdoes_core(char q, char *cbuf) #endif /* 0 */ } +/* the whatdoes command */ int dowhatdoes(void) { @@ -2084,7 +2085,7 @@ dowhatdoes(void) pline("No such command '%s', char code %d (0%03o or 0x%02x).", visctrl(q), (uchar) q, (uchar) q, (uchar) q); } - return 0; + return ECMD_OK; } static void @@ -2213,7 +2214,7 @@ static const struct { DISABLE_WARNING_FORMAT_NONLITERAL -/* the '?' command */ +/* the #help command */ int dohelp(void) { @@ -2247,7 +2248,7 @@ dohelp(void) free((genericptr_t) selected); (void) (*help_menu_items[sel].f)(); } - return 0; + return ECMD_OK; } RESTORE_WARNING_FORMAT_NONLITERAL @@ -2257,7 +2258,7 @@ int dohistory(void) { display_file(HISTORY, TRUE); - return 0; + return ECMD_OK; } /*pager.c*/ diff --git a/src/pickup.c b/src/pickup.c index c0255f4cb..4da47d5c9 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1861,7 +1861,7 @@ do_loot_cont(struct obj **cobjp, struct obj *cobj = *cobjp; if (!cobj) - return 0; + return ECMD_OK; if (cobj->olocked) { struct obj *unlocktool; @@ -1878,7 +1878,7 @@ do_loot_cont(struct obj **cobjp, /* pass ox and oy to avoid direction prompt */ return (pick_lock(unlocktool, cobj->ox, cobj->oy, cobj) != 0); } - return 0; + return ECMD_OK; } cobj->lknown = 1; /* floor container, so no need for update_inventory() */ @@ -1891,7 +1891,7 @@ do_loot_cont(struct obj **cobjp, losehp(Maybe_Half_Phys(tmp), "carnivorous bag", KILLED_BY_AN); makeknown(BAG_OF_TRICKS); g.abort_looting = TRUE; - return 1; + return ECMD_TIME; } You("%sopen %s...", (!cobj->cknown || !cobj->lknown) ? "carefully " : "", @@ -1931,18 +1931,18 @@ doloot_core(void) if (check_capacity((char *) 0)) { /* "Can't do that while carrying so much stuff." */ - return 0; + return ECMD_OK; } if (nohands(g.youmonst.data)) { You("have no hands!"); /* not `body_part(HAND)' */ - return 0; + return ECMD_OK; } if (Confusion) { if (rn2(6) && reverse_loot()) - return 1; + return ECMD_TIME; if (rn2(2)) { pline("Being confused, you find nothing to loot."); - return 1; /* costs a turn */ + return ECMD_TIME; /* costs a turn */ } /* else fallthrough to normal looting */ } cc.x = u.ux; @@ -1956,7 +1956,7 @@ doloot_core(void) boolean anyfound = FALSE; if (!able_to_loot(cc.x, cc.y, TRUE)) - return 0; + return ECMD_OK; if (Blind && !uarmg) { /* if blind and without gloves, attempting to #loot at the @@ -1968,7 +1968,7 @@ doloot_core(void) feel_cockatrice(nobj, FALSE); /* if life-saved (or poly'd into stone golem), terminate attempt to loot */ - return 1; + return ECMD_TIME; } } @@ -2001,7 +2001,7 @@ doloot_core(void) if (g.abort_looting) { /* chest trap or magic bag explosion or */ free((genericptr_t) pick_list); - return timepassed; + return (timepassed ? ECMD_TIME : ECMD_OK); } } free((genericptr_t) pick_list); @@ -2017,7 +2017,7 @@ doloot_core(void) cobj, doname, ansimpleoname, "a container")); if (c == 'q') - return timepassed; + return (timepassed ? ECMD_TIME : ECMD_OK); if (c == 'n') continue; anyfound = TRUE; @@ -2025,7 +2025,7 @@ doloot_core(void) timepassed |= do_loot_cont(&cobj, 1, 1); if (g.abort_looting) /* chest trap or magic bag explosion or */ - return timepassed; + return (timepassed ? ECMD_TIME : ECMD_OK); } } if (anyfound) @@ -2042,7 +2042,7 @@ doloot_core(void) if (c != 'y' && mon_beside(u.ux, u.uy)) { if (!get_adjacent_loc("Loot in what direction?", "Invalid loot location", u.ux, u.uy, &cc)) - return 0; + return ECMD_OK; if (cc.x == u.ux && cc.y == u.uy) { underfoot = TRUE; if (container_at(cc.x, cc.y, FALSE)) @@ -2053,7 +2053,7 @@ doloot_core(void) You("%s to loot on the %s.", dont_find_anything, ceiling(cc.x, cc.y)); timepassed = 1; - return timepassed; + return (timepassed ? ECMD_TIME : ECMD_OK); } mtmp = m_at(cc.x, cc.y); if (mtmp) @@ -2073,21 +2073,21 @@ doloot_core(void) if (mtmp) { You_cant("loot anything %sthere with %s in the way.", prev_inquiry ? "else " : "", mon_nam(mtmp)); - return timepassed; + return (timepassed ? ECMD_TIME : ECMD_OK); } else { You("have to be at a container to loot it."); } } else { You("%s %sthere to loot.", dont_find_anything, (prev_inquiry || prev_loot) ? "else " : ""); - return timepassed; + return (timepassed ? ECMD_TIME : ECMD_OK); } } } else if (c != 'y' && c != 'n') { You("%s %s to loot.", dont_find_anything, underfoot ? "here" : "there"); } - return timepassed; + return (timepassed ? ECMD_TIME : ECMD_OK); } /* called when attempting to #loot while confused */ @@ -2703,14 +2703,14 @@ use_container(struct obj **objp, boolean quantum_cat, cursed_mbag, loot_out, loot_in, loot_in_first, stash_one, inokay, outokay, outmaybe; char c, emptymsg[BUFSZ], qbuf[QBUFSZ], pbuf[QBUFSZ], xbuf[QBUFSZ]; - int used = 0; + int used = ECMD_OK; long loss; g.abort_looting = FALSE; emptymsg[0] = '\0'; if (!u_handsy()) - return 0; + return ECMD_OK; if (!obj->lknown) { /* do this in advance */ obj->lknown = 1; @@ -2721,7 +2721,7 @@ use_container(struct obj **objp, pline("%s locked.", Tobjnam(obj, "are")); if (held) You("must put it down to unlock."); - return 0; + return ECMD_OK; } else if (obj->otrapped) { if (held) You("open %s...", the(xname(obj))); @@ -2733,7 +2733,7 @@ use_container(struct obj **objp, g.nomovemsg = ""; } g.abort_looting = TRUE; - return 1; + return ECMD_TIME; } g.current_container = obj; /* for use by in/out_container */ @@ -2745,7 +2745,7 @@ use_container(struct obj **objp, quantum_cat = SchroedingersBox(g.current_container); if (quantum_cat) { observe_quantum_cat(g.current_container, TRUE, TRUE); - used = 1; + used = ECMD_TIME; } cursed_mbag = Is_mbag(g.current_container) @@ -2753,7 +2753,7 @@ use_container(struct obj **objp, && Has_contents(g.current_container); if (cursed_mbag && (loss = boh_loss(g.current_container, held)) != 0) { - used = 1; + used = ECMD_TIME; You("owe %ld %s for lost merchandise.", loss, currency(loss)); g.current_container->owt = weight(g.current_container); } @@ -2814,7 +2814,7 @@ use_container(struct obj **objp, } else { c = in_or_out_menu(qbuf, g.current_container, outmaybe, inokay, - (boolean) (used != 0), more_containers); + (boolean) (used != ECMD_OK), more_containers); } } else { /* TRADITIONAL or COMBINATION */ xbuf[0] = '\0'; /* list of extra acceptable responses */ @@ -2841,7 +2841,7 @@ use_container(struct obj **objp, explain_container_prompt(more_containers); } else if (c == ':') { /* note: will set obj->cknown */ if (!g.current_container->cknown) - used = 1; /* gaining info */ + used = ECMD_TIME; /* gaining info */ container_contents(g.current_container, FALSE, FALSE, TRUE); } else break; @@ -2861,7 +2861,7 @@ use_container(struct obj **objp, if (!Has_contents(g.current_container)) { pline1(emptymsg); /* is empty. */ if (!g.current_container->cknown) - used = 1; + used = ECMD_TIME; g.current_container->cknown = 1; } else { add_valid_menu_class(0); /* reset */ @@ -2956,7 +2956,7 @@ traditional_loot(boolean put_in) char selection[MAXOCLASSES + 10]; /* +10: room for B,U,C,X plus slop */ const char *action; boolean one_by_one, allflag; - int used = 0, menu_on_request = 0; + int used = ECMD_OK, menu_on_request = 0; if (put_in) { action = "put in"; @@ -2974,7 +2974,7 @@ traditional_loot(boolean put_in) FALSE, &menu_on_request)) { if (askchain(objlist, (one_by_one ? (char *) 0 : selection), allflag, actionfunc, checkfunc, 0, action)) - used = 1; + used = ECMD_TIME; } else if (menu_on_request < 0) { used = (menu_loot(menu_on_request, put_in) > 0); } @@ -3005,7 +3005,7 @@ menu_loot(int retry, boolean put_in) n = query_category(buf, put_in ? g.invent : g.current_container->cobj, mflags, &pick_list, PICK_ANY); if (!n) - return 0; + return ECMD_OK; for (i = 0; i < n; i++) { if (pick_list[i].item.a_int == 'A') { loot_everything = autopick = TRUE; @@ -3099,7 +3099,7 @@ menu_loot(int retry, boolean put_in) free((genericptr_t) pick_list); } } - return n_looted; + return n_looted ? ECMD_TIME : ECMD_OK; } static char @@ -3273,10 +3273,10 @@ dotip(void) free((genericptr_t) pick_list); if (otmp && otmp != &dummyobj) { tipcontainer(otmp); - return 1; + return ECMD_TIME; } if (n == -1) - return 0; + return ECMD_OK; /* else pick-from-g.invent below */ } else { for (cobj = g.level.objects[cc.x][cc.y]; cobj; cobj = nobj) { @@ -3287,12 +3287,12 @@ dotip(void) cobj, doname, ansimpleoname, "container")); if (c == 'q') - return 0; + return ECMD_OK; if (c == 'n') continue; tipcontainer(cobj); /* can only tip one container at a time */ - return 1; + return ECMD_TIME; } } } @@ -3301,12 +3301,12 @@ dotip(void) /* either no floor container(s) or couldn't tip one or didn't tip any */ cobj = getobj("tip", tip_ok, GETOBJ_PROMPT); if (!cobj) - return 0; + return ECMD_OK; /* normal case */ if (Is_container(cobj) || cobj->otyp == HORN_OF_PLENTY) { tipcontainer(cobj); - return 1; + return ECMD_TIME; } /* assorted other cases */ if (Is_candle(cobj) && cobj->lamplit) { @@ -3340,18 +3340,18 @@ dotip(void) consume_obj_charge(cobj, TRUE); } /* something [useless] happened */ - return 1; + return ECMD_TIME; } /* anything not covered yet */ if (cobj->oclass == POTION_CLASS) /* can't pour potions... */ pline_The("%s %s securely sealed.", xname(cobj), otense(cobj, "are")); else if (uarmh && cobj == uarmh) - return tiphat(); + return tiphat() ? ECMD_TIME : ECMD_OK; else if (cobj->otyp == STATUE) pline("Nothing interesting happens."); else pline1(nothing_happens); - return 0; + return ECMD_OK; } static void diff --git a/src/polyself.c b/src/polyself.c index f8066b316..90fb451b0 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -1186,17 +1186,17 @@ dobreathe(void) if (Strangled) { You_cant("breathe. Sorry."); - return 0; + return ECMD_OK; } if (u.uen < 15) { You("don't have enough energy to breathe!"); - return 0; + return ECMD_OK; } u.uen -= 15; g.context.botl = 1; if (!getdir((char *) 0)) - return 0; + return ECMD_OK; mattk = attacktype_fordmg(g.youmonst.data, AT_BREA, AD_ANY); if (!mattk) @@ -1206,7 +1206,7 @@ dobreathe(void) else buzz((int) (20 + mattk->adtyp - 1), (int) mattk->damn, u.ux, u.uy, u.dx, u.dy); - return 1; + return ECMD_TIME; } int @@ -1216,7 +1216,7 @@ dospit(void) struct attack *mattk; if (!getdir((char *) 0)) - return 0; + return ECMD_OK; mattk = attacktype_fordmg(g.youmonst.data, AT_SPIT, AD_ANY); if (!mattk) { impossible("bad spit attack?"); @@ -1236,7 +1236,7 @@ dospit(void) otmp->spe = 1; /* to indicate it's yours */ throwit(otmp, 0L, FALSE, (struct obj *) 0); } - return 1; + return ECMD_TIME; } int @@ -1246,13 +1246,13 @@ doremove(void) if (u.utrap && u.utraptype == TT_BURIEDBALL) { pline_The("ball and chain are buried firmly in the %s.", surface(u.ux, u.uy)); - return 0; + return ECMD_OK; } You("are not chained to anything!"); - return 0; + return ECMD_OK; } unpunish(); - return 1; + return ECMD_TIME; } int @@ -1263,13 +1263,13 @@ dospinweb(void) if (Levitation || Is_airlevel(&u.uz) || Underwater || Is_waterlevel(&u.uz)) { You("must be on the ground to spin a web."); - return 0; + return ECMD_OK; } if (u.uswallow) { You("release web fluid inside %s.", mon_nam(u.ustuck)); if (is_animal(u.ustuck->data)) { expels(u.ustuck, u.ustuck->data, TRUE); - return 0; + return ECMD_OK; } if (is_whirly(u.ustuck->data)) { int i; @@ -1296,14 +1296,14 @@ dospinweb(void) } pline_The("web %sis swept away!", sweep); } - return 0; + return ECMD_OK; } /* default: a nasty jelly-like creature */ pline_The("web dissolves into %s.", mon_nam(u.ustuck)); - return 0; + return ECMD_OK; } if (u.utrap) { You("cannot spin webs while stuck in a trap."); - return 0; + return ECMD_OK; } exercise(A_DEX, TRUE); if (ttmp) { @@ -1314,33 +1314,33 @@ dospinweb(void) deltrap(ttmp); bury_objs(u.ux, u.uy); newsym(u.ux, u.uy); - return 1; + return ECMD_TIME; case SQKY_BOARD: pline_The("squeaky board is muffled."); deltrap(ttmp); newsym(u.ux, u.uy); - return 1; + return ECMD_TIME; case TELEP_TRAP: case LEVEL_TELEP: case MAGIC_PORTAL: case VIBRATING_SQUARE: Your("webbing vanishes!"); - return 0; + return ECMD_OK; case WEB: You("make the web thicker."); - return 1; + return ECMD_TIME; case HOLE: case TRAPDOOR: You("web over the %s.", (ttmp->ttyp == TRAPDOOR) ? "trap door" : "hole"); deltrap(ttmp); newsym(u.ux, u.uy); - return 1; + return ECMD_TIME; case ROLLING_BOULDER_TRAP: You("spin a web, jamming the trigger."); deltrap(ttmp); newsym(u.ux, u.uy); - return 1; + return ECMD_TIME; case ARROW_TRAP: case DART_TRAP: case BEAR_TRAP: @@ -1354,16 +1354,16 @@ dospinweb(void) case POLY_TRAP: You("have triggered a trap!"); dotrap(ttmp, 0); - return 1; + return ECMD_TIME; default: impossible("Webbing over trap type %d?", ttmp->ttyp); - return 0; + return ECMD_OK; } } else if (On_stairs(u.ux, u.uy)) { /* cop out: don't let them hide the stairs */ Your("web fails to impede access to the %s.", (levl[u.ux][u.uy].typ == STAIRS) ? "stairs" : "ladder"); - return 1; + return ECMD_TIME; } ttmp = maketrap(u.ux, u.uy, WEB); if (ttmp) { @@ -1372,7 +1372,7 @@ dospinweb(void) if (*in_rooms(u.ux, u.uy, SHOPBASE)) add_damage(u.ux, u.uy, SHOP_WEB_COST); } - return 1; + return ECMD_TIME; } int @@ -1381,7 +1381,7 @@ dosummon(void) int placeholder; if (u.uen < 10) { You("lack the energy to send forth a call for help!"); - return 0; + return ECMD_OK; } u.uen -= 10; g.context.botl = 1; @@ -1390,7 +1390,7 @@ dosummon(void) exercise(A_WIS, TRUE); if (!were_summon(g.youmonst.data, TRUE, &placeholder, (char *) 0)) pline("But none arrive."); - return 1; + return ECMD_TIME; } int @@ -1410,19 +1410,19 @@ dogaze(void) } if (adtyp != AD_CONF && adtyp != AD_FIRE) { impossible("gaze attack %d?", adtyp); - return 0; + return ECMD_OK; } if (Blind) { You_cant("see anything to gaze at."); - return 0; + return ECMD_OK; } else if (Hallucination) { You_cant("gaze at anything you can see."); - return 0; + return ECMD_OK; } if (u.uen < 15) { You("lack the energy to use your special gaze!"); - return 0; + return ECMD_OK; } u.uen -= 15; g.context.botl = 1; @@ -1503,7 +1503,7 @@ dogaze(void) : -200); g.multi_reason = "frozen by a monster's gaze"; g.nomovemsg = 0; - return 1; + return ECMD_TIME; } else You("stiffen momentarily under %s gaze.", s_suffix(mon_nam(mtmp))); @@ -1528,7 +1528,7 @@ dogaze(void) } if (!looked) You("gaze at no place in particular."); - return 1; + return ECMD_TIME; } int @@ -1553,7 +1553,7 @@ dohide(void) g.youmonst.m_ap_type = M_AP_NOTHING; newsym(u.ux, u.uy); } - return 0; + return ECMD_OK; } /* note: the eel and hides_under cases are hypothetical; such critters aren't offered the option of hiding via #monster */ @@ -1563,24 +1563,24 @@ dohide(void) else There("is no %s to hide in here.", hliquid("water")); u.uundetected = 0; - return 0; + return ECMD_OK; } if (hides_under(g.youmonst.data) && !g.level.objects[u.ux][u.uy]) { There("is nothing to hide under here."); u.uundetected = 0; - return 0; + return ECMD_OK; } /* Planes of Air and Water */ if (on_ceiling && !has_ceiling(&u.uz)) { There("is nowhere to hide above you."); u.uundetected = 0; - return 0; + return ECMD_OK; } if ((is_hider(g.youmonst.data) && !Flying) /* floor hider */ && (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz))) { There("is nowhere to hide beneath you."); u.uundetected = 0; - return 0; + return ECMD_OK; } /* TODO? inhibit floor hiding at furniture locations, or * else make youhiding() give smarter messages at such spots. @@ -1588,7 +1588,7 @@ dohide(void) if (u.uundetected || (ismimic && U_AP_TYPE != M_AP_NOTHING)) { youhiding(FALSE, 1); /* "you are already hiding" */ - return 0; + return ECMD_OK; } if (ismimic) { @@ -1599,7 +1599,7 @@ dohide(void) u.uundetected = 1; newsym(u.ux, u.uy); youhiding(FALSE, 0); /* "you are now hiding" */ - return 1; + return ECMD_TIME; } int @@ -1615,7 +1615,7 @@ dopoly(void) newsym(u.ux, u.uy); } } - return 1; + return ECMD_TIME; } /* #monster for hero-as-mind_flayer giving psychic blast */ @@ -1627,7 +1627,7 @@ domindblast(void) if (u.uen < 10) { You("concentrate but lack the energy to maintain doing so."); - return 0; + return ECMD_OK; } u.uen -= 10; g.context.botl = 1; @@ -1663,7 +1663,7 @@ domindblast(void) killed(mtmp); } } - return 1; + return ECMD_TIME; } void diff --git a/src/potion.c b/src/potion.c index 04b115b56..2e2ce4640 100644 --- a/src/potion.c +++ b/src/potion.c @@ -496,6 +496,7 @@ drink_ok(struct obj *obj) } /* "Quaffing is like drinking, except you spill more." - Terry Pratchett */ +/* the #quaff command */ int dodrink(void) { @@ -503,7 +504,7 @@ dodrink(void) if (Strangled) { pline("If you can't breathe air, how can you drink liquid?"); - return 0; + return ECMD_OK; } /* Is there a fountain to drink from here? */ if (IS_FOUNTAIN(levl[u.ux][u.uy].typ) @@ -511,7 +512,7 @@ dodrink(void) && can_reach_floor(FALSE)) { if (yn("Drink from the fountain?") == 'y') { drinkfountain(); - return 1; + return ECMD_TIME; } } /* Or a kitchen sink? */ @@ -520,20 +521,20 @@ dodrink(void) && can_reach_floor(FALSE)) { if (yn("Drink from the sink?") == 'y') { drinksink(); - return 1; + return ECMD_TIME; } } /* Or are you surrounded by water? */ if (Underwater && !u.uswallow) { if (yn("Drink the water around you?") == 'y') { pline("Do you know what lives in this water?"); - return 1; + return ECMD_TIME; } } otmp = getobj("drink", drink_ok, GETOBJ_NOFLAGS); if (!otmp) - return 0; + return ECMD_OK; /* quan > 1 used to be left to useup(), but we need to force the current potion to be unworn, and don't want to do @@ -556,13 +557,13 @@ dodrink(void) && !rn2(POTION_OCCUPANT_CHANCE(g.mvitals[PM_GHOST].born))) { ghost_from_bottle(); useup(otmp); - return 1; + return ECMD_TIME; } else if (objdescr_is(otmp, "smoky") && !(g.mvitals[PM_DJINNI].mvflags & G_GONE) && !rn2(POTION_OCCUPANT_CHANCE(g.mvitals[PM_DJINNI].born))) { djinni_from_bottle(otmp); useup(otmp); - return 1; + return ECMD_TIME; } return dopotion(otmp); } @@ -575,7 +576,7 @@ dopotion(struct obj *otmp) otmp->in_use = TRUE; g.potion_nothing = g.potion_unkn = 0; if ((retval = peffects(otmp)) >= 0) - return retval; + return retval ? ECMD_TIME : ECMD_OK; if (g.potion_nothing) { g.potion_unkn++; @@ -590,7 +591,7 @@ dopotion(struct obj *otmp) docall(otmp); } useup(otmp); - return 1; + return ECMD_TIME; } static void @@ -2133,9 +2134,9 @@ dodip(void) const char *shortestname; /* last resort obj name for prompt */ if (!(obj = getobj("dip", dip_ok, GETOBJ_PROMPT))) - return 0; + return ECMD_OK; if (inaccessible_equipment(obj, "dip", FALSE)) - return 0; + return ECMD_OK; shortestname = (is_plural(obj) || pair_of(obj)) ? "them" : "it"; /* @@ -2160,7 +2161,7 @@ dodip(void) /* "Dip into the fountain?" */ if (yn(qbuf) == 'y') { dipfountain(obj); - return 1; + return ECMD_TIME; } } else if (is_pool(u.ux, u.uy)) { const char *pooltype = waterbody_name(u.ux, u.uy); @@ -2180,7 +2181,7 @@ dodip(void) if (water_damage(obj, 0, TRUE) != ER_DESTROYED && obj->in_use) useup(obj); } - return 1; + return ECMD_TIME; } } @@ -2189,10 +2190,10 @@ dodip(void) flags.verbose ? obuf : shortestname); potion = getobj(qbuf, drink_ok, GETOBJ_NOFLAGS); if (!potion) - return 0; + return ECMD_OK; if (potion == obj && potion->quan == 1L) { pline("That is a potion bottle, not a Klein bottle!"); - return 0; + return ECMD_OK; } potion->in_use = TRUE; /* assume it will be used up */ if (potion->otyp == POT_WATER) { @@ -2220,19 +2221,19 @@ dodip(void) */ if (!obj) { makeknown(POT_POLYMORPH); - return 1; + return ECMD_TIME; } else if (obj->otyp != save_otyp) { makeknown(POT_POLYMORPH); useup(potion); prinv((char *) 0, obj, 0L); - return 1; + return ECMD_TIME; } else { pline("Nothing seems to happen."); goto poof; } } potion->in_use = FALSE; /* didn't go poof */ - return 1; + return ECMD_TIME; } else if (obj->oclass == POTION_CLASS && obj->otyp != potion->otyp) { int amt = (int) obj->quan; boolean magic; @@ -2278,7 +2279,7 @@ dodip(void) useupall(obj); losehp(amt + rnd(9), /* not physical damage */ "alchemic blast", KILLED_BY_AN); - return 1; + return ECMD_TIME; } obj->blessed = obj->cursed = obj->bknown = 0; @@ -2307,7 +2308,7 @@ dodip(void) useupall(obj); pline_The("mixture %sevaporates.", !Blind ? "glows brightly and " : ""); - return 1; + return ECMD_TIME; } } obj->odiluted = (obj->otyp != POT_WATER); @@ -2327,7 +2328,7 @@ dodip(void) as a consequence, mixing while Fumbling drops the mixture */ freeinv(obj); hold_potion(obj, "You drop %s!", doname(obj), (const char *) 0); - return 1; + return ECMD_TIME; } if (potion->otyp == POT_ACID && obj->otyp == CORPSE @@ -2341,7 +2342,7 @@ dodip(void) && !objects[potion->otyp].oc_name_known && !objects[potion->otyp].oc_uname) docall(potion); - return 1; + return ECMD_TIME; } if (potion->otyp == POT_WATER && obj->otyp == TOWEL) { @@ -2415,7 +2416,7 @@ dodip(void) if (potion->dknown) makeknown(potion->otyp); useup(potion); - return 1; + return ECMD_TIME; } more_dips: @@ -2427,7 +2428,7 @@ dodip(void) useup(potion); explode(u.ux, u.uy, 11, d(6, 6), 0, EXPL_FIERY); exercise(A_WIS, FALSE); - return 1; + return ECMD_TIME; } /* Adding oil to an empty magic lamp renders it into an oil lamp */ if ((obj->otyp == MAGIC_LAMP) && obj->spe == 0) { @@ -2453,7 +2454,7 @@ dodip(void) makeknown(POT_OIL); obj->spe = 1; update_inventory(); - return 1; + return ECMD_TIME; } potion->in_use = FALSE; /* didn't go poof */ @@ -2517,11 +2518,11 @@ dodip(void) with compatible ones; override 'pickup_burden' while doing so */ hold_potion(singlepotion, "You juggle and drop %s!", doname(singlepotion), (const char *) 0); - return 1; + return ECMD_TIME; } pline("Interesting..."); - return 1; + return ECMD_TIME; poof: if (potion->dknown @@ -2529,7 +2530,7 @@ dodip(void) && !objects[potion->otyp].oc_uname) docall(potion); useup(potion); - return 1; + return ECMD_TIME; } /* *monp grants a wish and then leaves the game */ diff --git a/src/pray.c b/src/pray.c index 65a4ce085..75ca2941e 100644 --- a/src/pray.c +++ b/src/pray.c @@ -1332,6 +1332,7 @@ consume_offering(struct obj *otmp) exercise(A_WIS, TRUE); } +/* the #offer command - sacrifice something to the gods */ int dosacrifice(void) { @@ -1344,14 +1345,14 @@ dosacrifice(void) if (!on_altar() || u.uswallow) { You("are not standing on an altar."); - return 0; + return ECMD_OK; } highaltar = ((Is_astralevel(&u.uz) || Is_sanctum(&u.uz)) && (levl[u.ux][u.uy].altarmask & AM_SHRINE)); otmp = floorfood("sacrifice", 1); if (!otmp) - return 0; + return ECMD_OK; /* * Was based on nutritional value and aging behavior (< 50 moves). * Sacrificing a food ration got you max luck instantly, making the @@ -1374,7 +1375,7 @@ dosacrifice(void) */ feel_cockatrice(otmp, TRUE); if (rider_corpse_revival(otmp, FALSE)) - return 1; + return ECMD_TIME; if (otmp->corpsenm == PM_ACID_BLOB || (g.moves <= peek_at_iced_corpse_age(otmp) + 50)) { @@ -1458,7 +1459,7 @@ dosacrifice(void) useup(otmp); else useupf(otmp, 1L); - return 1; + return ECMD_TIME; } else if (has_omonst(otmp) && (mtmp = get_mtraits(otmp, FALSE)) != 0 && mtmp->mtame) { @@ -1533,7 +1534,7 @@ dosacrifice(void) ? "an urge to return to the surface" /* else headed towards celestial disgrace */ : "ashamed"); - return 1; + return ECMD_TIME; } else { /* The final Test. Did you win? */ if (uamul == otmp) @@ -1598,7 +1599,7 @@ dosacrifice(void) Hallucination ? "boo-boo" : "mistake"); otmp->known = TRUE; change_luck(-1); - return 1; + return ECMD_TIME; } else { /* don't you dare try to fool the gods */ if (Deaf) @@ -1612,7 +1613,7 @@ dosacrifice(void) if (value == 0) { pline1(nothing_happens); - return 1; + return ECMD_TIME; } if (altaralign != u.ualign.type && highaltar) { @@ -1660,7 +1661,7 @@ dosacrifice(void) if (!Inhell) angrygods(u.ualign.type); } - return 1; + return ECMD_TIME; } else { consume_offering(otmp); You("sense a conflict between %s and %s.", u_gname(), @@ -1701,7 +1702,7 @@ dosacrifice(void) && rnd(u.ualign.record) > (7 * ALIGNLIM) / 8) summon_minion(altaralign, TRUE); } - return 1; + return ECMD_TIME; } } @@ -1790,7 +1791,7 @@ dosacrifice(void) makeknown(otmp->otyp); discover_artifact(otmp->oartifact); } - return 1; + return ECMD_TIME; } } change_luck((value * LUCKMAX) / (MAXVALUE * 2)); @@ -1808,7 +1809,7 @@ dosacrifice(void) } } } - return 1; + return ECMD_TIME; } /* determine prayer results in advance; also used for enlightenment */ @@ -1870,13 +1871,13 @@ dopray(void) { /* Confirm accidental slips of Alt-P */ if (ParanoidPray && yn("Are you sure you want to pray?") != 'y') - return 0; + return ECMD_OK; u.uconduct.gnostic++; /* set up p_type and p_alignment */ if (!can_pray(TRUE)) - return 0; + return ECMD_OK; if (wizard && g.p_type >= 0) { if (yn("Force the gods to be pleased?") == 'y') { @@ -1902,7 +1903,7 @@ dopray(void) u.uinvulnerable = TRUE; } - return 1; + return ECMD_TIME; } static int @@ -1999,7 +2000,7 @@ doturn(void) return spelleffects(sp_no, FALSE); } You("don't know how to turn undead!"); - return 0; + return ECMD_OK; } u.uconduct.gnostic++; Gname = halu_gname(u.ualign.type); @@ -2012,7 +2013,7 @@ doturn(void) /* violates agnosticism due to intent; conduct tracking is not supposed to affect play but we make an exception here: use a move if this is the first time agnostic conduct has been broken */ - return (u.uconduct.gnostic == 1); + return (u.uconduct.gnostic == 1) ? ECMD_TIME : ECMD_OK; } if ((u.ualign.type != A_CHAOTIC && (is_demon(g.youmonst.data) @@ -2021,7 +2022,7 @@ doturn(void) pline("For some reason, %s seems to ignore you.", Gname); aggravate(); exercise(A_WIS, FALSE); - return 1; + return ECMD_TIME; } if (Inhell) { pline("Since you are in Gehennom, %s %s help you.", @@ -2029,7 +2030,7 @@ doturn(void) phrasing anyway if hallucinatory feedback says it's him */ Gname, !strcmp(Gname, Moloch) ? "won't" : "can't"); aggravate(); - return 1; + return ECMD_TIME; } pline("Calling upon %s, you chant an arcane formula.", Gname); exercise(A_WIS, TRUE); @@ -2116,7 +2117,7 @@ doturn(void) nomul(-(5 - ((u.ulevel - 1) / 6))); /* -5 .. -1 */ g.multi_reason = "trying to turn the monsters"; g.nomovemsg = You_can_move_again; - return 1; + return ECMD_TIME; } int diff --git a/src/read.c b/src/read.c index ac503d3d8..cee7d22f0 100644 --- a/src/read.c +++ b/src/read.c @@ -324,7 +324,7 @@ read_ok(struct obj* obj) return GETOBJ_DOWNPLAY; } -/* the 'r' command; read a scroll or spell book or various other things */ +/* the #read command; read a scroll or spell book or various other things */ int doread(void) { @@ -352,11 +352,11 @@ doread(void) g.known = FALSE; if (check_capacity((char *) 0)) - return 0; + return ECMD_OK; scroll = getobj("read", read_ok, GETOBJ_PROMPT); if (!scroll) - return 0; + return ECMD_OK; otyp = scroll->otyp; /* outrumor has its own blindness check */ @@ -367,7 +367,7 @@ doread(void) if (!Blind) u.uconduct.literate++; useup(scroll); - return 1; + return ECMD_TIME; } else if (otyp == T_SHIRT || otyp == ALCHEMY_SMOCK || otyp == HAWAIIAN_SHIRT) { char buf[BUFSZ], *mesg; @@ -375,7 +375,7 @@ doread(void) if (Blind) { You_cant(find_any_braille); - return 0; + return ECMD_OK; } /* can't read shirt worn under suit (under cloak is ok though) */ if ((otyp == T_SHIRT || otyp == HAWAIIAN_SHIRT) && uarm @@ -383,12 +383,12 @@ doread(void) pline("%s shirt is obscured by %s%s.", scroll->unpaid ? "That" : "Your", shk_your(buf, uarm), suit_simple_name(uarm)); - return 0; + return ECMD_OK; } if (otyp == HAWAIIAN_SHIRT) { pline("%s features %s.", flags.verbose ? "The design" : "It", hawaiian_design(scroll, buf)); - return 1; + return ECMD_TIME; } u.uconduct.literate++; /* populate 'buf[]' */ @@ -404,7 +404,7 @@ doread(void) pline("It reads:"); } pline("\"%s\"%s", mesg, endpunct); - return 1; + return ECMD_TIME; } else if ((otyp == DUNCE_CAP || otyp == CORNUTHAUM) /* note: "DUNCE" isn't directly connected to tourists but if everyone could read it, they would always be able to @@ -424,7 +424,7 @@ doread(void) because it suggests that there might be something on others */ You_cant("find anything to read on this %s.", simpleonames(scroll)); - return 0; + return ECMD_OK; } pline("%s on the %s. It reads: %s.", !Blind ? "There is writing" : "You feel lettering", @@ -434,7 +434,7 @@ doread(void) the object type, don't make it become a discovery for hero */ if (!objects[otyp].oc_name_known && !objects[otyp].oc_uname) docall(scroll); - return 1; + return ECMD_TIME; } else if (otyp == CREDIT_CARD) { static const char *card_msgs[] = { "Leprechaun Gold Tru$t - Shamrock Card", @@ -473,20 +473,20 @@ doread(void) (((int) scroll->o_id * 7) % 10), (flags.verbose || Blind) ? "." : ""); u.uconduct.literate++; - return 1; + return ECMD_TIME; } else if (otyp == CAN_OF_GREASE) { pline("This %s has no label.", singular(scroll, xname)); - return 0; + return ECMD_OK; } else if (otyp == MAGIC_MARKER) { if (Blind) { You_cant(find_any_braille); - return 0; + return ECMD_OK; } if (flags.verbose) pline("It reads:"); pline("\"Magic Marker(TM) Red Ink Marker Pen. Water Soluble.\""); u.uconduct.literate++; - return 1; + return ECMD_TIME; } else if (scroll->oclass == COIN_CLASS) { if (Blind) You("feel the embossed words:"); @@ -494,7 +494,7 @@ doread(void) You("read:"); pline("\"1 Zorkmid. 857 GUE. In Frobs We Trust.\""); u.uconduct.literate++; - return 1; + return ECMD_TIME; } else if (scroll->oartifact == ART_ORB_OF_FATE) { if (Blind) You("feel the engraved signature:"); @@ -502,25 +502,25 @@ doread(void) pline("It is signed:"); pline("\"Odin.\""); u.uconduct.literate++; - return 1; + return ECMD_TIME; } else if (otyp == CANDY_BAR) { const char *wrapper = candy_wrapper_text(scroll); if (Blind) { You_cant(find_any_braille); - return 0; + return ECMD_OK; } if (!*wrapper) { pline("The candy bar's wrapper is blank."); - return 0; + return ECMD_OK; } pline("The wrapper reads: \"%s\".", wrapper); u.uconduct.literate++; - return 1; + return ECMD_TIME; } else if (scroll->oclass != SCROLL_CLASS && scroll->oclass != SPBOOK_CLASS) { pline(silly_thing_to, "read"); - return 0; + return ECMD_OK; } else if (Blind && otyp != SPE_BOOK_OF_THE_DEAD) { const char *what = 0; @@ -534,7 +534,7 @@ doread(void) what = "formula on the scroll"; if (what) { pline("Being blind, you cannot read the %s.", what); - return 0; + return ECMD_OK; } } @@ -553,7 +553,7 @@ doread(void) if (!scroll->spe && yn( "Reading mail will violate \"illiterate\" conduct. Read anyway?" ) != 'y') - return 0; + return ECMD_OK; } } #endif @@ -565,7 +565,7 @@ doread(void) u.uconduct.literate++; if (scroll->oclass == SPBOOK_CLASS) { - return study_book(scroll); + return study_book(scroll) ? ECMD_TIME : ECMD_OK; } scroll->in_use = TRUE; /* scroll, not spellbook, now being read */ if (otyp != SCR_BLANK_PAPER) { @@ -602,7 +602,7 @@ doread(void) if (otyp != SCR_BLANK_PAPER) useup(scroll); } - return 1; + return ECMD_TIME; } static void diff --git a/src/rumors.c b/src/rumors.c index e08c4a0d7..ce4694882 100644 --- a/src/rumors.c +++ b/src/rumors.c @@ -687,13 +687,13 @@ doconsult(struct monst *oracl) if (!oracl) { There("is no one here to consult."); - return 0; + return ECMD_OK; } else if (!oracl->mpeaceful) { pline("%s is in no mood for consultations.", Monnam(oracl)); - return 0; + return ECMD_OK; } else if (!umoney) { You("have no gold."); - return 0; + return ECMD_OK; } Sprintf(qbuf, "\"Wilt thou settle for a minor consultation?\" (%d %s)", @@ -701,22 +701,22 @@ doconsult(struct monst *oracl) switch (ynq(qbuf)) { default: case 'q': - return 0; + return ECMD_OK; case 'y': if (umoney < (long) minor_cost) { You("don't even have enough gold for that!"); - return 0; + return ECMD_OK; } u_pay = minor_cost; break; case 'n': if (umoney <= (long) minor_cost /* don't even ask */ || (g.oracle_cnt == 1 || g.oracle_flg < 0)) - return 0; + return ECMD_OK; Sprintf(qbuf, "\"Then dost thou desire a major one?\" (%d %s)", major_cost, currency((long) major_cost)); if (yn(qbuf) != 'y') - return 0; + return ECMD_OK; u_pay = (umoney < (long) major_cost) ? (int) umoney : major_cost; break; } @@ -745,7 +745,7 @@ doconsult(struct monst *oracl) more_experienced(add_xpts, u_pay / 50); newexplevel(); } - return 1; + return ECMD_TIME; } static void diff --git a/src/save.c b/src/save.c index 364423e90..3fa32a431 100644 --- a/src/save.c +++ b/src/save.c @@ -46,6 +46,7 @@ static void zerocomp_bputc(int); #define HUP #endif +/* the #save command */ int dosave(void) { @@ -69,7 +70,7 @@ dosave(void) } else (void) doredraw(); } - return 0; + return ECMD_OK; } /* returns 1 if save successful */ diff --git a/src/shk.c b/src/shk.c index cae3797ec..8d5b72092 100644 --- a/src/shk.c +++ b/src/shk.c @@ -1225,6 +1225,7 @@ cheapest_item(register struct monst* shkp) return gmin; } +/* the #pay command */ int dopay(void) { @@ -1260,12 +1261,12 @@ dopay(void) if ((!sk && (!Blind || Blind_telepat)) || (!Blind && !seensk)) { There("appears to be no shopkeeper here to receive your payment."); - return 0; + return ECMD_OK; } if (!seensk) { You_cant("see..."); - return 0; + return ECMD_OK; } /* The usual case. Allow paying at a distance when @@ -1284,7 +1285,7 @@ dopay(void) if (shkp != resident && distu(shkp->mx, shkp->my) > 2) { pline("%s is not near enough to receive your payment.", Shknam(shkp)); - return 0; + return ECMD_OK; } } else { struct monst *mtmp; @@ -1295,40 +1296,40 @@ dopay(void) cc.x = u.ux; cc.y = u.uy; if (getpos(&cc, TRUE, "the creature you want to pay") < 0) - return 0; /* player pressed ESC */ + return ECMD_OK; /* player pressed ESC */ cx = cc.x; cy = cc.y; if (cx < 0) { pline("Try again..."); - return 0; + return ECMD_OK; } if (u.ux == cx && u.uy == cy) { You("are generous to yourself."); - return 0; + return ECMD_OK; } mtmp = m_at(cx, cy); if (!cansee(cx, cy) && (!mtmp || !canspotmon(mtmp))) { You("can't %s anyone there.", !Blind ? "see" : "sense"); - return 0; + return ECMD_OK; } if (!mtmp) { There("is no one there to receive your payment."); - return 0; + return ECMD_OK; } if (!mtmp->isshk) { pline("%s is not interested in your payment.", Monnam(mtmp)); - return 0; + return ECMD_OK; } if (mtmp != resident && distu(mtmp->mx, mtmp->my) > 2) { pline("%s is too far to receive your payment.", Shknam(mtmp)); - return 0; + return ECMD_OK; } shkp = mtmp; } if (!shkp) { debugpline0("dopay: null shkp."); - return 0; + return ECMD_OK; } proceed: eshkp = ESHK(shkp); @@ -1341,7 +1342,7 @@ dopay(void) if (!shkp->mcanmove || shkp->msleeping) { /* still asleep/paralyzed */ pline("%s %s.", Shknam(shkp), rn2(2) ? "seems to be napping" : "doesn't respond"); - return 0; + return ECMD_OK; } if (shkp != resident && NOTANGRY(shkp)) { @@ -1370,7 +1371,7 @@ dopay(void) else make_happy_shk(shkp, FALSE); } - return 1; + return ECMD_TIME; } /* ltmp is still eshkp->robbed here */ @@ -1387,7 +1388,7 @@ dopay(void) pline(no_money, stashed_gold ? " seem to" : ""); else pline(not_enough_money, noit_mhim(shkp)); - return 1; + return ECMD_TIME; } pline("But since %s shop has been robbed recently,", noit_mhis(shkp)); @@ -1405,7 +1406,7 @@ dopay(void) pline(no_money, stashed_gold ? " seem to" : ""); else pline(not_enough_money, noit_mhim(shkp)); - return 1; + return ECMD_TIME; } You("try to appease %s by giving %s 1000 gold pieces.", canspotmon(shkp) @@ -1418,13 +1419,13 @@ dopay(void) else pline("But %s is as angry as ever.", shkname(shkp)); } - return 1; + return ECMD_TIME; } if (shkp != resident) { impossible("dopay: not to shopkeeper?"); if (resident) setpaid(resident); - return 0; + return ECMD_OK; } /* pay debt, if any, first */ if (eshkp->debit) { @@ -1448,7 +1449,7 @@ dopay(void) pline("But you don't%s have enough gold%s.", stashed_gold ? " seem to" : "", eshkp->credit ? " or credit" : ""); - return 1; + return ECMD_TIME; } else { if (eshkp->credit >= dtmp) { eshkp->credit -= dtmp; @@ -1483,14 +1484,14 @@ dopay(void) if (!umoney && !eshkp->credit) { You("%shave no gold or credit%s.", stashed_gold ? "seem to " : "", paid ? " left" : ""); - return 0; + return ECMD_OK; } if ((umoney + eshkp->credit) < cheapest_item(shkp)) { You("don't have enough gold to buy%s the item%s you picked.", eshkp->billct > 1 ? " any of" : "", plur(eshkp->billct)); if (stashed_gold) pline("Maybe you have some gold stashed away?"); - return 0; + return ECMD_OK; } /* this isn't quite right; it itemizes without asking if the @@ -1516,7 +1517,7 @@ dopay(void) } else { impossible("Shopkeeper administration out of order."); setpaid(shkp); /* be nice to the player */ - return 1; + return ECMD_TIME; } if (pass == bp->useup && otmp->quan == bp->bquan) { /* pay for used-up items on first pass and others @@ -1527,7 +1528,7 @@ dopay(void) } else { switch (dopayobj(shkp, bp, &otmp, pass, itemize)) { case PAY_CANT: - return 1; /*break*/ + return ECMD_TIME; /*break*/ case PAY_BROKE: paid = TRUE; goto thanks; /*break*/ @@ -1563,7 +1564,7 @@ dopay(void) Shknam(shkp), noit_mhis(shkp), shtypes[eshkp->shoptype - SHOPBASE].name); } - return 1; + return ECMD_TIME; } /* return 2 if used-up portion paid diff --git a/src/sit.c b/src/sit.c index f5813798f..3a652767d 100644 --- a/src/sit.c +++ b/src/sit.c @@ -40,7 +40,7 @@ dosit(void) if (u.usteed) { You("are already sitting on %s.", mon_nam(u.usteed)); - return 0; + return ECMD_OK; } if (u.uundetected && is_hider(g.youmonst.data) && u.umonnum != PM_TRAPPER) u.uundetected = 0; /* no longer on the ceiling */ @@ -52,7 +52,7 @@ dosit(void) You("tumble in place."); else You("are sitting on air."); - return 0; + return ECMD_OK; } else if (u.ustuck && !sticks(g.youmonst.data)) { /* holding monster is next to hero rather than beneath, but hero is in no condition to actually sit at has/her own spot */ @@ -60,7 +60,7 @@ dosit(void) pline("%s won't offer %s lap.", Monnam(u.ustuck), mhis(u.ustuck)); else pline("%s has no lap.", Monnam(u.ustuck)); - return 0; + return ECMD_OK; } else if (is_pool(u.ux, u.uy) && !Underwater) { /* water walking */ goto in_water; } @@ -150,7 +150,7 @@ dosit(void) burn_away_slime(); if (likes_lava(g.youmonst.data)) { pline_The("%s feels warm.", hliquid("lava")); - return 1; + return ECMD_TIME; } pline_The("%s burns you!", hliquid("lava")); losehp(d((Fire_resistance ? 2 : 10), 10), /* lava damage */ @@ -323,20 +323,20 @@ dosit(void) Hallucination ? "You may think you are a platypus, but a male still" : "Males"); - return 0; + return ECMD_OK; } else if (u.uhunger < (int) objects[EGG].oc_nutrition) { You("don't have enough energy to lay an egg."); - return 0; + return ECMD_OK; } else if (eggs_in_water(g.youmonst.data)) { if (!(Underwater || Is_waterlevel(&u.uz))) { pline("A splash tetra you are not."); - return 0; + return ECMD_OK; } if (Upolyd && (g.youmonst.data == &mons[PM_GIANT_EEL] || g.youmonst.data == &mons[PM_ELECTRIC_EEL])) { You("yearn for the Sargasso Sea."); - return 0; + return ECMD_OK; } } uegg = mksobj(EGG, FALSE, FALSE); @@ -353,7 +353,7 @@ dosit(void) } else { pline("Having fun sitting on the %s?", surface(u.ux, u.uy)); } - return 1; + return ECMD_TIME; } /* curse a few inventory items at random! */ diff --git a/src/sounds.c b/src/sounds.c index 8071aced6..f69224bea 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -550,7 +550,7 @@ mon_is_gecko(struct monst* mon) DISABLE_WARNING_FORMAT_NONLITERAL -static int +static int /* check calls to this */ domonnoise(register struct monst* mtmp) { char verbuf[BUFSZ]; @@ -562,9 +562,9 @@ domonnoise(register struct monst* mtmp) /* presumably nearness and sleep checks have already been made */ if (Deaf) - return 0; + return ECMD_OK; if (is_silent(ptr)) - return 0; + return ECMD_OK; /* leader might be poly'd; if he can still speak, give leader speech */ if (mtmp->m_id == g.quest_status.leader_m_id && msound > MS_ANIMAL) @@ -590,7 +590,7 @@ domonnoise(register struct monst* mtmp) switch (msound) { case MS_ORACLE: - return doconsult(mtmp); + return doconsult(mtmp); /* check this */ case MS_PRIEST: priest_talk(mtmp); break; @@ -749,7 +749,7 @@ domonnoise(register struct monst* mtmp) if (!mtmp->mpeaceful) pline_msg = "hisses!"; else - return 0; /* no sound */ + return ECMD_OK; /* no sound */ break; case MS_BUZZ: pline_msg = mtmp->mpeaceful ? "drones." : "buzzes angrily."; @@ -1047,7 +1047,7 @@ domonnoise(register struct monst* mtmp) verbalize1(verbl_msg); } } - return 1; + return ECMD_TIME; } RESTORE_WARNING_FORMAT_NONLITERAL @@ -1072,19 +1072,19 @@ dochat(void) if (is_silent(g.youmonst.data)) { pline("As %s, you cannot speak.", an(pmname(g.youmonst.data, flags.female ? FEMALE : MALE))); - return 0; + return ECMD_OK; } if (Strangled) { You_cant("speak. You're choking!"); - return 0; + return ECMD_OK; } if (u.uswallow) { pline("They won't hear you out there."); - return 0; + return ECMD_OK; } if (Underwater) { Your("speech is unintelligible underwater."); - return 0; + return ECMD_OK; } if (!Deaf && !Blind && (otmp = shop_object(u.ux, u.uy)) != (struct obj *) 0) { /* standing on something in a shop and chatting causes the shopkeeper @@ -1095,25 +1095,25 @@ dochat(void) contains any objects other than just gold. */ price_quote(otmp); - return 1; + return ECMD_TIME; } if (!getdir("Talk to whom? (in what direction)")) { /* decided not to chat */ - return 0; + return ECMD_OK; } if (u.usteed && u.dz > 0) { if (!u.usteed->mcanmove || u.usteed->msleeping) { pline("%s seems not to notice you.", Monnam(u.usteed)); - return 1; + return ECMD_TIME; } else return domonnoise(u.usteed); } if (u.dz) { pline("They won't hear you %s there.", u.dz < 0 ? "up" : "down"); - return 0; + return ECMD_OK; } if (u.dx == 0 && u.dy == 0) { @@ -1128,14 +1128,14 @@ dochat(void) } */ pline("Talking to yourself is a bad habit for a dungeoneer."); - return 0; + return ECMD_OK; } tx = u.ux + u.dx; ty = u.uy + u.dy; if (!isok(tx, ty)) - return 0; + return ECMD_OK; mtmp = m_at(tx, ty); @@ -1146,7 +1146,7 @@ dochat(void) pline_The("%s seems not to notice you.", /* if hallucinating, you can't tell it's a statue */ Hallucination ? rndmonnam((char *) 0) : "statue"); - return 0; + return ECMD_OK; } if (!Deaf && (IS_WALL(levl[tx][ty].typ) || levl[tx][ty].typ == SDOOR)) { /* Talking to a wall; secret door remains hidden by behaving @@ -1175,14 +1175,14 @@ dochat(void) idx = SIZE(walltalk) - 1; pline_The("wall %s", walltalk[idx]); } - return 0; + return ECMD_OK; } } if (!mtmp || mtmp->mundetected || M_AP_TYPE(mtmp) == M_AP_FURNITURE || M_AP_TYPE(mtmp) == M_AP_OBJECT) - return 0; + return ECMD_OK; /* sleeping monsters won't talk, except priests (who wake up) */ if ((!mtmp->mcanmove || mtmp->msleeping) && !mtmp->ispriest) { @@ -1190,7 +1190,7 @@ dochat(void) not noticing him and just not existing, so skip the message. */ if (canspotmon(mtmp)) pline("%s seems not to notice you.", Monnam(mtmp)); - return 0; + return ECMD_OK; } /* if this monster is waiting for something, prod it into action */ @@ -1200,7 +1200,7 @@ dochat(void) if (!canspotmon(mtmp)) map_invisible(mtmp->mx, mtmp->my); pline("%s is eating noisily.", Monnam(mtmp)); - return 0; + return ECMD_OK; } if (Deaf) { const char *xresponse = humanoid(g.youmonst.data) @@ -1211,7 +1211,7 @@ dochat(void) canspotmon(mtmp) ? " from " : "", canspotmon(mtmp) ? mon_nam(mtmp) : "", xresponse); - return 0; + return ECMD_OK; } return domonnoise(mtmp); } diff --git a/src/spell.c b/src/spell.c index 038873609..ae8c09921 100644 --- a/src/spell.c +++ b/src/spell.c @@ -732,7 +732,7 @@ getspell(int* spell_no) spell_no); } -/* the 'Z' command -- cast a spell */ +/* the #cast command -- cast a spell */ int docast(void) { @@ -740,7 +740,7 @@ docast(void) if (getspell(&spell_no)) return spelleffects(spell_no, FALSE); - return 0; + return ECMD_OK; } static const char * @@ -897,7 +897,7 @@ int spelleffects(int spell, boolean atme) { int energy, damage, chance, n, intell; - int otyp, skill, role_skill, res = 0; + int otyp, skill, role_skill, res = ECMD_OK; boolean confused = (Confusion != 0); boolean physical_damage = FALSE; struct obj *pseudo; @@ -913,7 +913,7 @@ spelleffects(int spell, boolean atme) * place in getspell(), we don't get called.) */ if (rejectcasting()) { - return 0; /* no time elapses */ + return ECMD_OK; /* no time elapses */ } /* @@ -924,7 +924,7 @@ spelleffects(int spell, boolean atme) Your("knowledge of this spell is twisted."); pline("It invokes nightmarish images in your mind..."); spell_backfire(spell); - return 1; + return ECMD_TIME; } else if (spellknow(spell) <= KEEN / 200) { /* 100 turns left */ You("strain to recall the spell."); } else if (spellknow(spell) <= KEEN / 40) { /* 500 turns left */ @@ -942,13 +942,13 @@ spelleffects(int spell, boolean atme) if (u.uhunger <= 10 && spellid(spell) != SPE_DETECT_FOOD) { You("are too hungry to cast that spell."); - return 0; + return ECMD_OK; } else if (ACURR(A_STR) < 4 && spellid(spell) != SPE_RESTORE_ABILITY) { You("lack the strength to cast spells."); - return 0; + return ECMD_OK; } else if (check_capacity( "Your concentration falters while carrying so much stuff.")) { - return 1; + return ECMD_TIME; } /* if the cast attempt is already going to fail due to insufficient @@ -968,7 +968,7 @@ spelleffects(int spell, boolean atme) if (u.uen < 0) u.uen = 0; g.context.botl = 1; - res = 1; /* time is going to elapse even if spell doesn't get cast */ + res = ECMD_TIME; /* time is used even if spell doesn't get cast */ } if (energy > u.uen) { @@ -1042,7 +1042,7 @@ spelleffects(int spell, boolean atme) You("fail to cast the spell correctly."); u.uen -= energy / 2; g.context.botl = 1; - return 1; + return ECMD_TIME; } u.uen -= energy; @@ -1219,20 +1219,20 @@ spelleffects(int spell, boolean atme) cast_protection(); break; case SPE_JUMPING: - if (!jump(max(role_skill, 1))) + if (!(jump(max(role_skill, 1)) & ECMD_TIME)) pline1(nothing_happens); break; default: impossible("Unknown spell %d attempted.", spell); obfree(pseudo, (struct obj *) 0); - return 0; + return ECMD_OK; } /* gain skill for successful cast */ use_skill(skill, spellev(spell)); obfree(pseudo, (struct obj *) 0); /* now, get rid of it */ - return 1; + return ECMD_TIME; } /*ARGSUSED*/ @@ -1610,7 +1610,7 @@ spellsortmenu(void) return FALSE; } -/* the '+' command -- view known spells */ +/* the #showspells command -- view known spells */ int dovspell(void) { @@ -1643,7 +1643,7 @@ dovspell(void) g.spl_orderindx = 0; } g.spl_sortmode = SORTBY_LETTER; /* 0 */ - return 0; + return ECMD_OK; } DISABLE_WARNING_FORMAT_NONLITERAL diff --git a/src/steed.c b/src/steed.c index f5c345763..7e1c0e5a9 100644 --- a/src/steed.c +++ b/src/steed.c @@ -40,28 +40,28 @@ use_saddle(struct obj* otmp) int chance; if (!u_handsy()) - return 0; + return ECMD_OK; /* Select an animal */ if (u.uswallow || Underwater || !getdir((char *) 0)) { pline1(Never_mind); - return 0; + return ECMD_OK; } if (!u.dx && !u.dy) { pline("Saddle yourself? Very funny..."); - return 0; + return ECMD_OK; } if (!isok(u.ux + u.dx, u.uy + u.dy) || !(mtmp = m_at(u.ux + u.dx, u.uy + u.dy)) || !canspotmon(mtmp)) { pline("I see nobody there."); - return 1; + return ECMD_TIME; } /* Is this a valid monster? */ if ((mtmp->misc_worn_check & W_SADDLE) != 0L || which_armor(mtmp, W_SADDLE)) { pline("%s doesn't need another one.", Monnam(mtmp)); - return 1; + return ECMD_TIME; } ptr = mtmp->data; if (touch_petrifies(ptr) && !uarmg && !Stone_resistance) { @@ -77,16 +77,16 @@ use_saddle(struct obj* otmp) if (ptr == &mons[PM_AMOROUS_DEMON]) { pline("Shame on you!"); exercise(A_WIS, FALSE); - return 1; + return ECMD_TIME; } if (mtmp->isminion || mtmp->isshk || mtmp->ispriest || mtmp->isgd || mtmp->iswiz) { pline("I think %s would mind.", mon_nam(mtmp)); - return 1; + return ECMD_TIME; } if (!can_saddle(mtmp)) { You_cant("saddle such a creature."); - return 1; + return ECMD_TIME; } /* Calculate your chance */ @@ -134,7 +134,7 @@ use_saddle(struct obj* otmp) put_saddle_on_mon(otmp, mtmp); } else pline("%s resists!", Monnam(mtmp)); - return 1; + return ECMD_TIME; } void @@ -161,6 +161,7 @@ can_ride(struct monst* mtmp) && (!Underwater || is_swimmer(mtmp->data))); } +/* the #ride command */ int doride(void) { @@ -171,11 +172,12 @@ doride(void) } else if (getdir((char *) 0) && isok(u.ux + u.dx, u.uy + u.dy)) { if (wizard && yn("Force the mount to succeed?") == 'y') forcemount = TRUE; - return (mount_steed(m_at(u.ux + u.dx, u.uy + u.dy), forcemount)); + return (mount_steed(m_at(u.ux + u.dx, u.uy + u.dy), forcemount) + ? ECMD_TIME : ECMD_OK); } else { - return 0; + return ECMD_OK; } - return 1; + return ECMD_TIME; } /* Start riding, with the given monster */ diff --git a/src/teleport.c b/src/teleport.c index 6a5e99104..4e4b38258 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -549,7 +549,7 @@ scrolltele(struct obj* scroll) (void) safe_teleds(TELEDS_TELEPORT); } -/* ^T command; 'm ^T' == choose among several teleport modes */ +/* the #teleport command; 'm ^T' == choose among several teleport modes */ int dotelecmd(void) { @@ -565,7 +565,7 @@ dotelecmd(void) /* normal mode; ignore 'm' prefix if it was given */ if (!wizard) - return dotele(FALSE); + return dotele(FALSE) ? ECMD_TIME : ECMD_OK; added = hidden = NOOP_SPELL; save_HTele = HTeleportation, save_ETele = ETeleportation; @@ -625,7 +625,7 @@ dotelecmd(void) /* preselected one was explicitly chosen and got toggled off */ tmode = 'w'; } else { /* ESC */ - return 0; + return ECMD_OK; } switch (tmode) { case 'n': @@ -657,7 +657,7 @@ dotelecmd(void) /* can't both be non-NOOP so addition will yield the non-NOOP one */ (void) tport_spell(added + hidden - NOOP_SPELL); - return res; + return res ? ECMD_TIME : ECMD_OK; } int @@ -758,7 +758,7 @@ dotele( if (castit) { /* energy cost is deducted in spelleffects() */ exercise(A_WIS, TRUE); - if (spelleffects(sp_no, TRUE)) + if ((spelleffects(sp_no, TRUE) & ECMD_TIME)) return 1; else if (!break_the_rules) return 0; diff --git a/src/timeout.c b/src/timeout.c index 0e435c86e..b1ef4cbba 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -1819,6 +1819,7 @@ print_queue(winid win, timer_element* base) } } +/* the #timeout command */ int wiz_timeout_queue(void) { @@ -1830,7 +1831,7 @@ wiz_timeout_queue(void) win = create_nhwindow(NHW_MENU); /* corner text window */ if (win == WIN_ERR) - return 0; + return ECMD_OK; Sprintf(buf, "Current time = %ld.", g.moves); putstr(win, 0, buf); @@ -1882,7 +1883,7 @@ wiz_timeout_queue(void) display_nhwindow(win, FALSE); destroy_nhwindow(win); - return 0; + return ECMD_OK; } void diff --git a/src/trap.c b/src/trap.c index af9795801..70187849c 100644 --- a/src/trap.c +++ b/src/trap.c @@ -4347,27 +4347,27 @@ drain_en(int n) } } -/* disarm a trap */ +/* the #untrap command - disarm a trap */ int dountrap(void) { if (near_capacity() >= HVY_ENCUMBER) { pline("You're too strained to do that."); - return 0; + return ECMD_OK; } if ((nohands(g.youmonst.data) && !webmaker(g.youmonst.data)) || !g.youmonst.data->mmove) { pline("And just how do you expect to do that?"); - return 0; + return ECMD_OK; } else if (u.ustuck && sticks(g.youmonst.data)) { pline("You'll have to let go of %s first.", mon_nam(u.ustuck)); - return 0; + return ECMD_OK; } if (u.ustuck || (welded(uwep) && bimanual(uwep))) { Your("%s seem to be too busy for that.", makeplural(body_part(HAND))); - return 0; + return ECMD_OK; } - return untrap(FALSE); + return untrap(FALSE) ? ECMD_TIME : ECMD_OK; } /* Probability of disabling a trap. Helge Hafting */ diff --git a/src/version.c b/src/version.c index 5dbd9617d..f33bfb42b 100644 --- a/src/version.c +++ b/src/version.c @@ -63,14 +63,14 @@ getversionstring(char *buf) return buf; } -/* the 'v' command */ +/* the #versionshort command */ int doversion(void) { char buf[BUFSZ]; pline("%s", getversionstring(buf)); - return 0; + return ECMD_OK; } /* the '#version' command; also a choice for '?' */ @@ -198,7 +198,7 @@ doextversion(void) (void) dlb_fclose(f); display_nhwindow(win, FALSE); destroy_nhwindow(win); - return 0; + return ECMD_OK; } void diff --git a/src/weapon.c b/src/weapon.c index 0be11a51c..4c4eebdc4 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -1289,7 +1289,7 @@ enhance_weapon_skill(void) } } } while (speedy && n > 0); - return 0; + return ECMD_OK; } /* diff --git a/src/wield.c b/src/wield.c index 4a9e3551c..0b4644f27 100644 --- a/src/wield.c +++ b/src/wield.c @@ -308,6 +308,7 @@ wield_ok(struct obj *obj) return GETOBJ_DOWNPLAY; } +/* the #wield command - wield a weapon */ int dowield(void) { @@ -321,7 +322,7 @@ dowield(void) if (cantwield(g.youmonst.data)) { pline("Don't be ridiculous!"); cmdq_clear(); - return 0; + return ECMD_OK; } /* Prompt for a new weapon */ @@ -329,14 +330,14 @@ dowield(void) if (!(wep = getobj("wield", wield_ok, GETOBJ_PROMPT | GETOBJ_ALLOWCNT))) { /* Cancelled */ cmdq_clear(); - return 0; + return ECMD_OK; } else if (wep == uwep) { already_wielded: You("are already wielding that!"); if (is_weptool(wep) || is_wet_towel(wep)) g.unweapon = FALSE; /* [see setuwep()] */ cmdq_clear(); - return 0; + return ECMD_OK; } else if (welded(uwep)) { weldmsg(uwep); /* previously interrupted armor removal mustn't be resumed */ @@ -345,7 +346,7 @@ dowield(void) if (wep->o_id && wep->o_id == g.context.objsplit.child_oid) unsplitobj(wep); cmdq_clear(); - return 0; + return ECMD_OK; } else if (wep->o_id && wep->o_id == g.context.objsplit.child_oid) { /* if wep is the result of supplying a count to getobj() we don't want to split something already wielded; for @@ -372,7 +373,7 @@ dowield(void) uquiver->quan, simpleonames(uquiver)); switch (ynq(qbuf)) { case 'q': - return 0; + return ECMD_OK; case 'y': /* leave N-1 quivered, split off 1 to wield */ wep = splitobj(uquiver, 1L); @@ -394,14 +395,14 @@ dowield(void) (void) Shk_Your(qbuf, uquiver); /* replace qbuf[] contents */ pline("%s%s %s readied.", qbuf, simpleonames(uquiver), otense(uquiver, "remain")); - return 0; + return ECMD_OK; } /* wielding whole readied stack, so no longer quivered */ setuqwep((struct obj *) 0); } else if (wep->owornmask & (W_ARMOR | W_ACCESSORY | W_SADDLE)) { You("cannot wield that!"); cmdq_clear(); - return 0; + return ECMD_OK; } wielding: @@ -420,9 +421,10 @@ dowield(void) setuswapwep(oldwep); untwoweapon(); - return result; + return result ? ECMD_TIME : ECMD_OK; } +/* the #swap command - swap wielded and secondary weapons */ int doswapweapon(void) { @@ -434,12 +436,12 @@ doswapweapon(void) if (cantwield(g.youmonst.data)) { pline("Don't be ridiculous!"); cmdq_clear(); - return 0; + return ECMD_OK; } if (welded(uwep)) { weldmsg(uwep); cmdq_clear(); - return 0; + return ECMD_OK; } /* Unwield your current secondary weapon */ @@ -465,9 +467,10 @@ doswapweapon(void) if (u.twoweap && !can_twoweapon()) untwoweapon(); - return result; + return result ? ECMD_TIME : ECMD_OK; } +/* the #quiver command */ int dowieldquiver(void) { @@ -488,7 +491,7 @@ dowieldquiver(void) if (!newquiver) { /* Cancelled */ - return 0; + return ECMD_OK; } else if (newquiver == &cg.zeroobj) { /* no object */ /* Explicitly nothing */ if (uquiver) { @@ -498,7 +501,7 @@ dowieldquiver(void) } else { You("already have no ammunition readied!"); } - return 0; + return ECMD_OK; } else if (newquiver->o_id == g.context.objsplit.child_oid) { /* if newquiver is the result of supplying a count to getobj() we don't want to split something already in the quiver; @@ -510,23 +513,23 @@ dowieldquiver(void) /* don't allow splitting a stack of coins into quiver */ You("can't ready only part of your gold."); unsplitobj(newquiver); - return 0; + return ECMD_OK; } finish_splitting = TRUE; } else if (newquiver == uquiver) { already_quivered: pline("That ammunition is already readied!"); - return 0; + return ECMD_OK; } else if (newquiver->owornmask & (W_ARMOR | W_ACCESSORY | W_SADDLE)) { You("cannot ready that!"); - return 0; + return ECMD_OK; } else if (newquiver == uwep) { int weld_res = !uwep->bknown; if (welded(uwep)) { weldmsg(uwep); reset_remarm(); /* same as dowield() */ - return weld_res; + return weld_res ? ECMD_TIME : ECMD_OK; } /* offer to split stack if wielding more than 1 */ if (uwep->quan > 1L && inv_cnt(FALSE) < 52 && splittable(uwep)) { @@ -534,7 +537,7 @@ dowieldquiver(void) uwep->quan, simpleonames(uwep), uwep->quan - 1L); switch (ynq(qbuf)) { case 'q': - return 0; + return ECMD_OK; case 'y': /* leave 1 wielded, split rest off and put into quiver */ newquiver = splitobj(uwep, uwep->quan - 1L); @@ -556,7 +559,7 @@ dowieldquiver(void) (void) Shk_Your(qbuf, uwep); /* replace qbuf[] contents */ pline("%s%s %s wielded.", qbuf, simpleonames(uwep), otense(uwep, "remain")); - return 0; + return ECMD_OK; } /* quivering main weapon, so no longer wielding it */ setuwep((struct obj *) 0); @@ -572,7 +575,7 @@ dowieldquiver(void) uswapwep->quan - 1L); switch (ynq(qbuf)) { case 'q': - return 0; + return ECMD_OK; case 'y': /* leave 1 alt-wielded, split rest off and put into quiver */ newquiver = splitobj(uswapwep, uswapwep->quan - 1L); @@ -596,7 +599,7 @@ dowieldquiver(void) pline("%s%s %s %s.", qbuf, simpleonames(uswapwep), otense(uswapwep, "remain"), u.twoweap ? "wielded" : "as secondary weapon"); - return 0; + return ECMD_OK; } /* quivering alternate weapon, so no more uswapwep */ setuswapwep((struct obj *) 0); @@ -628,7 +631,7 @@ dowieldquiver(void) You("%s.", are_no_longer_twoweap); res = 1; } - return res; + return res ? ECMD_TIME : ECMD_OK; } /* used for #rub and for applying pick-axe, whip, grappling hook or polearm */ @@ -774,6 +777,7 @@ set_twoweap(boolean on_off) u.twoweap = on_off; } +/* the #twoweapon command */ int dotwoweapon(void) { @@ -782,7 +786,7 @@ dotwoweapon(void) You("switch to your primary weapon."); set_twoweap(FALSE); /* u.twoweap = FALSE */ update_inventory(); - return 0; + return ECMD_OK; } /* May we use two weapons? */ @@ -791,9 +795,9 @@ dotwoweapon(void) You("begin two-weapon combat."); set_twoweap(TRUE); /* u.twoweap = TRUE */ update_inventory(); - return (rnd(20) > ACURR(A_DEX)); + return (rnd(20) > ACURR(A_DEX)) ? ECMD_TIME : ECMD_OK; } - return 0; + return ECMD_OK; } /*** Functions to empty a given slot ***/ diff --git a/src/write.c b/src/write.c index b9ad55c75..a4e72a13e 100644 --- a/src/write.c +++ b/src/write.c @@ -114,18 +114,18 @@ dowrite(struct obj *pen) if (nohands(g.youmonst.data)) { You("need hands to be able to write!"); - return 0; + return ECMD_OK; } else if (Glib) { pline("%s from your %s.", Tobjnam(pen, "slip"), fingers_or_gloves(FALSE)); dropx(pen); - return 1; + return ECMD_TIME; } /* get paper to write on */ paper = getobj("write on", write_ok, GETOBJ_NOFLAGS); if (!paper) - return 0; + return ECMD_OK; /* can't write on a novel (unless/until it's been converted into a blank spellbook), but we want messages saying so to avoid "spellbook" */ typeword = (paper->otyp == SPE_NOVEL) @@ -136,19 +136,19 @@ dowrite(struct obj *pen) if (Blind) { if (!paper->dknown) { You("don't know if that %s is blank or not.", typeword); - return 0; + return ECMD_OK; } else if (paper->oclass == SPBOOK_CLASS) { /* can't write a magic book while blind */ pline("%s can't create braille text.", upstart(ysimple_name(pen))); - return 0; + return ECMD_OK; } } paper->dknown = 1; if (paper->otyp != SCR_BLANK_PAPER && paper->otyp != SPE_BLANK_PAPER) { pline("That %s is not blank!", typeword); exercise(A_WIS, FALSE); - return 1; + return ECMD_TIME; } /* what to write */ @@ -156,7 +156,7 @@ dowrite(struct obj *pen) getlin(qbuf, namebuf); (void) mungspaces(namebuf); /* remove any excess whitespace */ if (namebuf[0] == '\033' || !namebuf[0]) - return 1; + return ECMD_TIME; nm = namebuf; if (!strncmpi(nm, "scroll ", 7)) nm += 7; @@ -213,21 +213,21 @@ dowrite(struct obj *pen) } There("is no such %s!", typeword); - return 1; + return ECMD_TIME; found: if (i == SCR_BLANK_PAPER || i == SPE_BLANK_PAPER) { You_cant("write that!"); pline("It's obscene!"); - return 1; + return ECMD_TIME; } else if (i == SPE_BOOK_OF_THE_DEAD) { pline("No mere dungeon adventurer could write that."); - return 1; + return ECMD_TIME; } else if (by_descr && paper->oclass == SPBOOK_CLASS && !objects[i].oc_name_known) { /* can't write unknown spellbooks by description */ pline("Unfortunately you don't have enough information to go on."); - return 1; + return ECMD_TIME; } /* KMH, conduct */ @@ -244,7 +244,7 @@ dowrite(struct obj *pen) if (pen->spe < basecost / 2) { Your("marker is too dry to write that!"); obfree(new_obj, (struct obj *) 0); - return 1; + return ECMD_TIME; } /* we're really going to write now, so calculate cost @@ -265,7 +265,7 @@ dowrite(struct obj *pen) useup(paper); } obfree(new_obj, (struct obj *) 0); - return 1; + return ECMD_TIME; } pen->spe -= actualcost; @@ -314,7 +314,7 @@ dowrite(struct obj *pen) useup(paper); } obfree(new_obj, (struct obj *) 0); - return 1; + return ECMD_TIME; } /* can write scrolls when blind, but requires luck too; attempts to write books when blind are caught above */ @@ -327,7 +327,7 @@ dowrite(struct obj *pen) You("fail to write the scroll correctly and it disappears."); useup(paper); obfree(new_obj, (struct obj *) 0); - return 1; + return ECMD_TIME; } /* useup old scroll / spellbook */ @@ -357,7 +357,7 @@ dowrite(struct obj *pen) The(aobjnam(new_obj, "slip")), (const char *) 0); nhUse(new_obj); /* try to avoid complaint about dead assignment */ - return 1; + return ECMD_TIME; } /* most book descriptions refer to cover appearance, so we can issue a diff --git a/src/zap.c b/src/zap.c index 5afd48f59..eee279770 100644 --- a/src/zap.c +++ b/src/zap.c @@ -2365,7 +2365,7 @@ zap_ok(struct obj *obj) return GETOBJ_EXCLUDE; } -/* 'z' command (or 'y' if numbed_pad==-1) */ +/* #zap command, 'z' (or 'y' if numbed_pad==-1) */ int dozap(void) { @@ -2374,13 +2374,13 @@ dozap(void) if (nohands(g.youmonst.data)) { You("aren't able to zap anything in your current form."); - return 0; + return ECMD_OK; } if (check_capacity((char *) 0)) - return 0; + return ECMD_OK; obj = getobj("zap", zap_ok, GETOBJ_NOFLAGS); if (!obj) - return 0; + return ECMD_OK; check_unpaid(obj); @@ -2392,7 +2392,7 @@ dozap(void) exercise(A_STR, FALSE); /* 'obj' is gone; skip update_inventory() because backfire() -> useupall() -> freeinv() did it */ - return 1; + return ECMD_TIME; } else if (need_dir && !getdir((char *) 0)) { if (!Blind) pline("%s glows and fades.", The(xname(obj))); @@ -2421,7 +2421,7 @@ dozap(void) useupall(obj); /* calls freeinv() -> update_inventory() */ } else update_inventory(); /* maybe used a charge */ - return 1; + return ECMD_TIME; } /* Lock or unlock all boxes in inventory */