Restrict the teleportation notification to actual teleportations

teleds() is used for more than just teleportations, the teleportation message
was also given when mounting a steed.

Trying out a new bit flags method parameter design pattern.
This commit is contained in:
Patric Mueller
2020-01-11 12:24:02 +01:00
parent 7c3ae74c27
commit 38fa93df73
9 changed files with 31 additions and 24 deletions

View File

@@ -144,7 +144,7 @@ E void FDECL(Lift_covet_and_placebc, (int, const char *, int));
#define unplacebc_and_covet_placebc() \
Unplacebc_and_covet_placebc(__FUNCTION__, __LINE__)
#define lift_covet_and_placebc(x) \
Lift_covet_and_placebc(x, __FUNCTION__, __LINE__)
Lift_covet_and_placebc(x, __FUNCTION__, __LINE__)
#endif
E void FDECL(set_bc, (int));
E void FDECL(move_bc, (int, int, XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P));
@@ -2530,8 +2530,8 @@ E boolean FDECL(goodpos, (int, int, struct monst *, unsigned));
E boolean FDECL(enexto, (coord *, XCHAR_P, XCHAR_P, struct permonst *));
E boolean FDECL(enexto_core, (coord *, XCHAR_P, XCHAR_P,
struct permonst *, unsigned));
E void FDECL(teleds, (int, int, BOOLEAN_P));
E boolean FDECL(safe_teleds, (BOOLEAN_P));
E void FDECL(teleds, (int, int, int));
E boolean FDECL(safe_teleds, (int));
E boolean FDECL(teleport_pet, (struct monst *, BOOLEAN_P));
E void NDECL(tele);
E boolean FDECL(scrolltele, (struct obj *));

View File

@@ -143,7 +143,7 @@ struct cross_target_s {
unsigned long build_time;
};
extern struct cross_target_s cross_target;
#if defined(CROSSCOMPILE_TARGET) && !defined(MAKEDEFS_C)
#if defined(CROSSCOMPILE_TARGET) && !defined(MAKEDEFS_C)
#define BUILD_DATE cross_target.build_date /* "Wed Apr 1 00:00:01 2020" */
#define COPYRIGHT_BANNER_C cross_target.copyright_banner_c
#define NETHACK_GIT_SHA cross_target.git_sha

View File

@@ -490,6 +490,11 @@ enum bodypart_types {
#define MENU_FULL 2
#define MENU_PARTIAL 3
/* flags to control teleds() */
#define TELEDS_NO_FLAGS 0
#define TELEDS_ALLOW_DRAG 1
#define TELEDS_TELEPORT 2
/*
* Option flags
* Each higher number includes the characteristics of the numbers

View File

@@ -1807,7 +1807,7 @@ int magic; /* 0=Physical, otherwise skill level */
* and usually moves the ball if punished, but does not handle all
* the effects of landing on the final position.
*/
teleds(cc.x, cc.y, FALSE);
teleds(cc.x, cc.y, TELEDS_NO_FLAGS);
nomul(-1);
g.multi_reason = "jumping around";
g.nomovemsg = "";
@@ -2755,7 +2755,7 @@ struct obj *obj;
if (proficient && rn2(proficient + 2)) {
if (!mtmp || enexto(&cc, rx, ry, g.youmonst.data)) {
You("yank yourself out of the pit!");
teleds(cc.x, cc.y, TRUE);
teleds(cc.x, cc.y, TELEDS_ALLOW_DRAG);
reset_utrap(TRUE);
g.vision_full_recalc = 1;
}

View File

@@ -435,7 +435,7 @@ int xkill_flags, how;
if (enexto(&xy, etmp->ex, etmp->ey, etmp->edata)) {
pline("A %s force teleports you away...",
Hallucination ? "normal" : "strange");
teleds(xy.x, xy.y, FALSE);
teleds(xy.x, xy.y, TELEDS_NO_FLAGS);
}
/* otherwise on top of the drawbridge is the
* only viable spot in the dungeon, so stay there

View File

@@ -453,7 +453,7 @@ register struct monst *mtmp;
if (m_at(cc.x, cc.y))
(void) enexto(&cc, u.ux, u.uy, g.youmonst.data);
}
teleds(cc.x, cc.y, TRUE); /* move hero */
teleds(cc.x, cc.y, TELEDS_ALLOW_DRAG); /* move hero */
set_apparxy(mtmp);
newsym(u.ux, u.uy);

View File

@@ -353,7 +353,7 @@ boolean force; /* Quietly force this animal */
g.unweapon = FALSE;
u.usteed = mtmp;
remove_monster(mtmp->mx, mtmp->my);
teleds(mtmp->mx, mtmp->my, TRUE);
teleds(mtmp->mx, mtmp->my, TELEDS_ALLOW_DRAG);
g.context.botl = TRUE;
return TRUE;
}
@@ -645,7 +645,7 @@ int reason; /* Player was thrown off etc. */
* teleds() clears u.utrap
*/
g.in_steed_dismounting = TRUE;
teleds(cc.x, cc.y, TRUE);
teleds(cc.x, cc.y, TELEDS_ALLOW_DRAG);
g.in_steed_dismounting = FALSE;
/* Put your steed in your trap */

View File

@@ -277,11 +277,13 @@ boolean trapok;
}
void
teleds(nux, nuy, allow_drag)
register int nux, nuy;
boolean allow_drag;
teleds(nux, nuy, teleds_flags)
int nux, nuy;
int teleds_flags;
{
boolean ball_active, ball_still_in_range;
boolean allow_drag = teleds_flags & TELEDS_ALLOW_DRAG;
boolean is_teleport = teleds_flags & TELEDS_TELEPORT;
struct monst *vault_guard = vault_occupied(u.urooms) ? findgd() : 0;
if (u.utraptype == TT_BURIEDBALL) {
@@ -356,7 +358,7 @@ boolean allow_drag;
}
}
if (flags.verbose)
if (is_teleport && flags.verbose)
You("materialize in %s location!",
(nux == u.ux0 && nuy == u.uy0) ? "the same" : "a different");
@@ -415,8 +417,8 @@ boolean allow_drag;
}
boolean
safe_teleds(allow_drag)
boolean allow_drag;
safe_teleds(teleds_flags)
int teleds_flags;
{
register int nux, nuy, tcnt = 0;
@@ -426,7 +428,7 @@ boolean allow_drag;
} while (!teleok(nux, nuy, (boolean) (tcnt > 200)) && ++tcnt <= 400);
if (tcnt <= 400) {
teleds(nux, nuy, allow_drag);
teleds(nux, nuy, teleds_flags);
return TRUE;
} else
return FALSE;
@@ -439,7 +441,7 @@ vault_tele()
coord c;
if (croom && somexy(croom, &c) && teleok(c.x, c.y, FALSE)) {
teleds(c.x, c.y, FALSE);
teleds(c.x, c.y, TELEDS_TELEPORT);
return;
}
tele();
@@ -529,7 +531,7 @@ struct obj *scroll;
/* for scroll, discover it regardless of destination */
if (scroll)
learnscroll(scroll);
teleds(cc.x, cc.y, FALSE);
teleds(cc.x, cc.y, TELEDS_TELEPORT);
return TRUE;
}
pline("Sorry...");
@@ -543,7 +545,7 @@ struct obj *scroll;
}
g.telescroll = scroll;
(void) safe_teleds(FALSE);
(void) safe_teleds(TELEDS_TELEPORT);
/* teleds() will leave g.telescroll intact iff random destination
is far enough away for scroll discovery to be warranted */
if (g.telescroll)

View File

@@ -3858,7 +3858,7 @@ drown()
You("dump some of your gear to lose weight...");
if (succ) {
pline("Pheew! That was close.");
teleds(x, y, TRUE);
teleds(x, y, TELEDS_ALLOW_DRAG);
return TRUE;
}
/* still too much weight */
@@ -3877,7 +3877,7 @@ drown()
Strcpy(g.killer.name, pool_of_water);
done(DROWNING);
/* oops, we're still alive. better get out of the water. */
if (safe_teleds(TRUE))
if (safe_teleds(TELEDS_ALLOW_DRAG | TELEDS_TELEPORT))
break; /* successful life-save */
/* nowhere safe to land; repeat drowning loop... */
pline("You're still drowning.");
@@ -5348,7 +5348,7 @@ lava_effects()
Strcpy(g.killer.name, lava_killer);
You("%s...", boil_away ? "boil away" : "burn to a crisp");
done(BURNING);
if (safe_teleds(TRUE))
if (safe_teleds(TELEDS_ALLOW_DRAG | TELEDS_TELEPORT))
break; /* successful life-save */
/* nowhere safe to land; repeat burning loop */
pline("You're still burning.");
@@ -5408,7 +5408,7 @@ sink_into_lava()
reset_utrap(TRUE);
/* levitation or flight have become unblocked, otherwise Tport */
if (!Levitation && !Flying)
(void) safe_teleds(TRUE);
(void) safe_teleds(TELEDS_ALLOW_DRAG | TELEDS_TELEPORT);
} else if (!u.umoved) {
/* can't fully turn into slime while in lava, but might not
have it be burned away until you've come awfully close */