MCPcopy Index your code
hub / github.com/NetHack/NetHack / switch_terrain

Function switch_terrain

src/hack.c:3177–3217  ·  view source on GitHub ↗

moving onto different terrain; might be going into solid rock, inhibiting levitation or flight, or coming back out of such, reinstating levitation/flying */

Source from the content-addressed store, hash-verified

3175 might be going into solid rock, inhibiting levitation or flight,
3176 or coming back out of such, reinstating levitation/flying */
3177void
3178switch_terrain(void)
3179{
3180 struct rm *lev = &levl[u.ux][u.uy];
3181 boolean blocklev = (IS_OBSTRUCTED(lev->typ) || closed_door(u.ux, u.uy)
3182 || IS_WATERWALL(lev->typ)
3183 || lev->typ == LAVAWALL),
3184 was_levitating = !!Levitation, was_flying = !!Flying;
3185
3186 if (blocklev) {
3187 /* called from spoteffects(), stop levitating but skip float_down() */
3188 if (Levitation)
3189 You_cant("levitate in here.");
3190 BLevitation |= FROMOUTSIDE;
3191 } else if (BLevitation) {
3192 BLevitation &= ~FROMOUTSIDE;
3193 /* we're probably levitating now; if not, we must be chained
3194 to a buried iron ball so get float_up() feedback for that */
3195 if (Levitation || BLevitation)
3196 float_up();
3197 }
3198 /* the same terrain that blocks levitation also blocks flight */
3199 if (blocklev) {
3200 if (Flying)
3201 You_cant("fly in here.");
3202 BFlying |= FROMOUTSIDE;
3203 } else if (BFlying) {
3204 BFlying &= ~FROMOUTSIDE;
3205 float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */
3206 /* [minor bug: we don't know whether this is beginning flight or
3207 resuming it; that could be tracked so that this message could
3208 be adjusted to "resume flying", but isn't worth the effort...] */
3209 if (Flying)
3210 You("start flying.");
3211 }
3212 if ((!!Levitation ^ was_levitating) || (!!Flying ^ was_flying))
3213 disp.botl = TRUE; /* update Lev/Fly status condition */
3214
3215 if (flags.terrainstatus)
3216 classify_terrain();
3217}
3218
3219/* set or clear u.uinwater */
3220void

Callers 8

teledsFunction · 0.85
wizterrainwishFunction · 0.85
set_uinwaterFunction · 0.85
spoteffectsFunction · 0.85
digactualholeFunction · 0.85
hurtle_stepFunction · 0.85
u_on_rndspotFunction · 0.85
dissolve_barsFunction · 0.85

Calls 6

closed_doorFunction · 0.85
You_cantFunction · 0.85
float_upFunction · 0.85
float_vs_flightFunction · 0.85
YouFunction · 0.85
classify_terrainFunction · 0.85

Tested by

no test coverage detected