* Creation of a drawbridge at pos x,y. * dir is the direction. * flag must be put to TRUE if we want the drawbridge to be opened. */
| 232 | * flag must be put to TRUE if we want the drawbridge to be opened. |
| 233 | */ |
| 234 | boolean |
| 235 | create_drawbridge(coordxy x, coordxy y, int dir, boolean flag) |
| 236 | { |
| 237 | coordxy x2, y2; |
| 238 | boolean horiz; |
| 239 | boolean lava = levl[x][y].typ == LAVAPOOL; /* assume initialized map */ |
| 240 | |
| 241 | x2 = x; |
| 242 | y2 = y; |
| 243 | switch (dir) { |
| 244 | case DB_NORTH: |
| 245 | horiz = TRUE; |
| 246 | y2--; |
| 247 | break; |
| 248 | case DB_SOUTH: |
| 249 | horiz = TRUE; |
| 250 | y2++; |
| 251 | break; |
| 252 | case DB_EAST: |
| 253 | horiz = FALSE; |
| 254 | x2++; |
| 255 | break; |
| 256 | default: |
| 257 | impossible("bad direction in create_drawbridge"); |
| 258 | FALLTHROUGH; |
| 259 | /*FALLTHRU*/ |
| 260 | case DB_WEST: |
| 261 | horiz = FALSE; |
| 262 | x2--; |
| 263 | break; |
| 264 | } |
| 265 | if (!IS_WALL(levl[x2][y2].typ)) |
| 266 | return FALSE; |
| 267 | if (flag) { /* We want the bridge open */ |
| 268 | levl[x][y].typ = DRAWBRIDGE_DOWN; |
| 269 | levl[x2][y2].typ = DOOR; |
| 270 | levl[x2][y2].doormask = D_NODOOR; |
| 271 | } else { |
| 272 | levl[x][y].typ = DRAWBRIDGE_UP; |
| 273 | levl[x2][y2].typ = DBWALL; |
| 274 | /* Drawbridges are non-diggable. */ |
| 275 | levl[x2][y2].wall_info = W_NONDIGGABLE; |
| 276 | } |
| 277 | levl[x][y].horizontal = !horiz; |
| 278 | levl[x2][y2].horizontal = horiz; |
| 279 | levl[x][y].drawbridgemask = dir; |
| 280 | if (lava) |
| 281 | levl[x][y].drawbridgemask |= DB_LAVA; |
| 282 | return TRUE; |
| 283 | } |
| 284 | |
| 285 | staticfn struct entity * |
| 286 | e_at(coordxy x, coordxy y) |
no test coverage detected