1279 |
1279 |
1280 // Special houses that there can be only one of. |
1280 // Special houses that there can be only one of. |
1281 t->flags12 |= oneof; |
1281 t->flags12 |= oneof; |
1282 |
1282 |
1283 { |
1283 { |
1284 int m3lo,m5,eflags; |
1284 byte construction_counter = 0, construction_stage = 0, size_flags; |
1285 |
1285 |
1286 // ENDING_2 |
|
1287 m3lo = 0; |
|
1288 m5 = 0; |
|
1289 if (_generating_world) { |
1286 if (_generating_world) { |
1290 uint32 r = Random(); |
1287 uint32 r = Random(); |
1291 |
1288 |
1292 // Value for map3lo |
1289 construction_stage = 3; /* House is finished */ |
1293 m3lo = 0xC0; |
1290 if (CHANCE16(1, 7)) construction_stage = GB(r, 0, 2); |
1294 if (GB(r, 0, 8) >= 220) m3lo &= (r>>8); |
1291 |
1295 |
1292 if (construction_stage == 3) { |
1296 if (m3lo == 0xC0) |
|
1297 ChangePopulation(t, _housetype_population[house]); |
1293 ChangePopulation(t, _housetype_population[house]); |
1298 |
1294 } else { |
1299 // Initial value for map5. |
1295 construction_counter = GB(r, 2, 2); |
1300 m5 = GB(r, 16, 6); |
1296 } |
1301 } |
1297 } |
1302 |
1298 size_flags = GB(_housetype_extra_flags[house], 2, 3); |
1303 assert(IsTileType(tile, MP_CLEAR)); |
1299 MakeTownHouse(tile, t->index, construction_counter, construction_stage, size_flags, house); |
1304 |
|
1305 ModifyTile(tile, |
|
1306 MP_SETTYPE(MP_HOUSE) | MP_MAP3HI | MP_MAP3LO | MP_MAP2 | MP_MAP5 | MP_MAPOWNER, |
|
1307 t->index, |
|
1308 m3lo, /* map3_lo */ |
|
1309 house, /* map3_hi */ |
|
1310 0, /* map_owner */ |
|
1311 m5 /* map5 */ |
|
1312 ); |
|
1313 |
|
1314 eflags = _housetype_extra_flags[house]; |
|
1315 |
|
1316 if (eflags&0x18) { |
|
1317 assert(IsTileType(tile + TileDiffXY(0, 1), MP_CLEAR)); |
|
1318 ModifyTile(tile + TileDiffXY(0, 1), |
|
1319 MP_SETTYPE(MP_HOUSE) | MP_MAP2 | MP_MAP3LO | MP_MAP3HI | MP_MAP5 | MP_MAPOWNER, |
|
1320 t->index, |
|
1321 m3lo, /* map3_lo */ |
|
1322 ++house, /* map3_hi */ |
|
1323 0, /* map_owner */ |
|
1324 m5 /* map5 */ |
|
1325 ); |
|
1326 } |
|
1327 |
|
1328 if (eflags&0x14) { |
|
1329 assert(IsTileType(tile + TileDiffXY(1, 0), MP_CLEAR)); |
|
1330 ModifyTile(tile + TileDiffXY(1, 0), |
|
1331 MP_SETTYPE(MP_HOUSE) | MP_MAP2 | MP_MAP3LO | MP_MAP3HI | MP_MAP5 | MP_MAPOWNER, |
|
1332 t->index, |
|
1333 m3lo, /* map3_lo */ |
|
1334 ++house, /* map3_hi */ |
|
1335 0, /* map_owner */ |
|
1336 m5 /* map5 */ |
|
1337 ); |
|
1338 } |
|
1339 |
|
1340 if (eflags&0x10) { |
|
1341 assert(IsTileType(tile + TileDiffXY(1, 1), MP_CLEAR)); |
|
1342 ModifyTile(tile + TileDiffXY(1, 1), |
|
1343 MP_SETTYPE(MP_HOUSE) | MP_MAP2 | MP_MAP3LO | MP_MAP3HI | MP_MAP5 | MP_MAPOWNER, |
|
1344 t->index, |
|
1345 m3lo, /* map3_lo */ |
|
1346 ++house, /* map3_hi */ |
|
1347 0, /* map_owner */ |
|
1348 m5 /* map5 */ |
|
1349 ); |
|
1350 } |
|
1351 } |
1300 } |
1352 |
1301 |
1353 // ENDING |
1302 // ENDING |
1354 } |
1303 } |
1355 |
1304 |