rustrogueliketutorial icon indicating copy to clipboard operation
rustrogueliketutorial copied to clipboard

Town buildings are populated in wrong order

Open smokku opened this issue 5 years ago • 1 comments

My Player got spawned in a building so small, that it didn't even fit Barkeep, so I started investigating.

Code in town.rs/building_factory is incorrect. It iterates over original buildings array, and uses its index to pick build_type form building_index array, which was sorted and has different indexing:

for (i, building) in buildings.iter().enumerate() {
    let build_type = &building_index[i].2;
    match build_type {

It should be changed to something like this:

for (i, _size, build_type) in building_index.iter() {
    let building = &buildings[*i];
    match build_type {

smokku avatar Jul 23 '20 09:07 smokku

Much better, makes sense! Thank you!

MasterDrake avatar May 02 '24 12:05 MasterDrake