MCPcopy Create free account
hub / github.com/NetHack/NetHack / set_levltyp

Function set_levltyp

src/mkmaze.c:76–121  ·  view source on GitHub ↗

set map terrain type, handling lava lit, ice melt timers, etc */

Source from the content-addressed store, hash-verified

74
75/* set map terrain type, handling lava lit, ice melt timers, etc */
76boolean
77set_levltyp(coordxy x, coordxy y, schar newtyp)
78{
79 if (isok(x, y) && newtyp >= STONE && newtyp < MAX_TYPE) {
80 schar oldtyp = levl[x][y].typ;
81
82 /* hack for secret doors in garden theme rooms */
83 if (oldtyp == SDOOR && newtyp == AIR) {
84 /* levl[][].typ stays SDOOR rather than change to AIR */
85 levl[x][y].arboreal_sdoor = 1;
86 return TRUE;
87 }
88
89 if (CAN_OVERWRITE_TERRAIN(oldtyp)) {
90 /* typ==ICE || (typ==DRAWBRIDGE_UP && drawbridgemask==DB_ICE) */
91 boolean was_ice = is_ice(x, y);
92
93 levl[x][y].typ = newtyp;
94 /* TODO?
95 * if oldtyp used flags or horizontal differently from
96 * the way newtyp will use them, clear them.
97 */
98
99 if (IS_LAVA(newtyp)) /* [what about IS_LAVA(oldtyp)=>.lit = 0?] */
100 levl[x][y].lit = 1;
101 if (was_ice && newtyp != ICE) {
102 /* frozen corpses resume rotting, no more ice to melt away */
103 obj_ice_effects(x, y, TRUE);
104 spot_stop_timers(x, y, MELT_ICE_AWAY);
105 }
106 if ((IS_FOUNTAIN(oldtyp) != IS_FOUNTAIN(newtyp))
107 || (IS_SINK(oldtyp) != IS_SINK(newtyp)))
108 count_level_features(); /* level.flags.nfountains,nsinks */
109
110 return TRUE;
111 }
112#ifdef EXTRA_SANITY_CHECKS
113 } else {
114 impossible("set_levltyp(%d,%d,%d)%s%s",
115 (int) x, (int) y, (int) newtyp,
116 !isok(x, y) ? " not isok()" : "",
117 (newtyp < STONE || newtyp >= MAX_TYPE) ? " bad type" : "");
118#endif /*EXTRA_SANITY_CHECKS*/
119 }
120 return FALSE;
121}
122
123/* set map terrain type and light state */
124boolean

Callers 15

polymorph_sinkFunction · 0.85
teleport_sinkFunction · 0.85
make_graveFunction · 0.85
do_pitFunction · 0.85
maketrapFunction · 0.85
makenicheFunction · 0.85
place_branchFunction · 0.85
mkstairsFunction · 0.85
mkfountFunction · 0.85
mksinkFunction · 0.85
mkaltarFunction · 0.85
set_levltyp_litFunction · 0.85

Calls 6

isokFunction · 0.85
is_iceFunction · 0.85
obj_ice_effectsFunction · 0.85
spot_stop_timersFunction · 0.85
count_level_featuresFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected