set map terrain type, handling lava lit, ice melt timers, etc */
| 74 | |
| 75 | /* set map terrain type, handling lava lit, ice melt timers, etc */ |
| 76 | boolean |
| 77 | set_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 */ |
| 124 | boolean |
no test coverage detected