With the introduction of themed rooms, there are certain room shapes that * may generate a door, the square just inside the door, and only one other * ROOM square touching that one. E.g. * --- * ---.. * +.... * ---.. * --- * This means that if the room becomes a shop, the shopkeeper will move * between those two squares nearest the door without ever allowing the * player to get past
| 1047 | * already being chosen. It's quite possible that if the door were somewhere |
| 1048 | * else on the perimeter of this room, it would work fine as a shop.*/ |
| 1049 | staticfn boolean |
| 1050 | invalid_shop_shape(struct mkroom *sroom) |
| 1051 | { |
| 1052 | coordxy x, y; |
| 1053 | coordxy doorx = svd.doors[sroom->fdoor].x; |
| 1054 | coordxy doory = svd.doors[sroom->fdoor].y; |
| 1055 | coordxy insidex = 0, insidey = 0, insidect = 0; |
| 1056 | |
| 1057 | /* First, identify squares inside the room and next to the door. */ |
| 1058 | for (x = max(doorx - 1, sroom->lx); |
| 1059 | x <= min(doorx + 1, sroom->hx); x++) { |
| 1060 | for (y = max(doory - 1, sroom->ly); |
| 1061 | y <= min(doory + 1, sroom->hy); y++) { |
| 1062 | if (levl[x][y].typ == ROOM) { |
| 1063 | insidex = x; |
| 1064 | insidey = y; |
| 1065 | insidect++; |
| 1066 | } |
| 1067 | } |
| 1068 | } |
| 1069 | if (insidect < 1) { |
| 1070 | impossible("invalid_shop_shape: no squares inside door?"); |
| 1071 | return TRUE; |
| 1072 | } |
| 1073 | /* if insidect > 1, then the shopkeeper already has alternate |
| 1074 | * squares to move to so we don't need to check further. */ |
| 1075 | if (insidect == 1) { |
| 1076 | /* But if it is 1, scan all adjacent squares for other squares |
| 1077 | * that are part of this room. */ |
| 1078 | insidect = 0; |
| 1079 | for (x = max(insidex - 1, sroom->lx); |
| 1080 | x <= min(insidex + 1, sroom->hx); x++) { |
| 1081 | for (y = max(insidey - 1, sroom->ly); |
| 1082 | y <= min(insidey + 1, sroom->hy); y++) { |
| 1083 | if (x == insidex && y == insidey) |
| 1084 | continue; |
| 1085 | if (levl[x][y].typ == ROOM) |
| 1086 | insidect++; |
| 1087 | } |
| 1088 | } |
| 1089 | if (insidect == 1) { |
| 1090 | /* shopkeeper standing just inside the door can only move |
| 1091 | * to one other square; this cannot be a shop. */ |
| 1092 | return TRUE; |
| 1093 | } |
| 1094 | } |
| 1095 | return FALSE; |
| 1096 | } |
| 1097 | #endif /* !SFCTOOL */ |
| 1098 | |
| 1099 | /*mkroom.c*/ |