| 436 | } |
| 437 | |
| 438 | staticfn void |
| 439 | join(int a, int b, boolean nxcor) |
| 440 | { |
| 441 | coord cc, tt, org, dest; |
| 442 | coordxy tx, ty, xx, yy; |
| 443 | struct mkroom *croom, *troom; |
| 444 | int dx, dy; |
| 445 | int npoints; |
| 446 | boolean dig_result; |
| 447 | |
| 448 | croom = &svr.rooms[a]; |
| 449 | troom = &svr.rooms[b]; |
| 450 | |
| 451 | if (!croom->needjoining || !troom->needjoining) |
| 452 | return; |
| 453 | |
| 454 | /* find positions cc and tt for doors in croom and troom |
| 455 | and direction for a corridor between them */ |
| 456 | |
| 457 | if (troom->hx < 0 || croom->hx < 0) |
| 458 | return; |
| 459 | if (troom->lx > croom->hx) { |
| 460 | dx = 1; |
| 461 | dy = 0; |
| 462 | if (!finddpos(&cc, DIR_E, croom)) |
| 463 | return; |
| 464 | if (!finddpos(&tt, DIR_W, troom)) |
| 465 | return; |
| 466 | } else if (troom->hy < croom->ly) { |
| 467 | dy = -1; |
| 468 | dx = 0; |
| 469 | if (!finddpos(&cc, DIR_N, croom)) |
| 470 | return; |
| 471 | if (!finddpos(&tt, DIR_S, troom)) |
| 472 | return; |
| 473 | } else if (troom->hx < croom->lx) { |
| 474 | dx = -1; |
| 475 | dy = 0; |
| 476 | if (!finddpos(&cc, DIR_W, croom)) |
| 477 | return; |
| 478 | if (!finddpos(&tt, DIR_E, troom)) |
| 479 | return; |
| 480 | } else { |
| 481 | dy = 1; |
| 482 | dx = 0; |
| 483 | if (!finddpos(&cc, DIR_S, croom)) |
| 484 | return; |
| 485 | if (!finddpos(&tt, DIR_N, troom)) |
| 486 | return; |
| 487 | } |
| 488 | xx = cc.x; |
| 489 | yy = cc.y; |
| 490 | tx = tt.x - dx; |
| 491 | ty = tt.y - dy; |
| 492 | if (nxcor && levl[xx + dx][yy + dy].typ != STONE) |
| 493 | return; |
| 494 | |
| 495 | org.x = xx + dx; |
no test coverage detected