imgui-frontend-engineer: harden C API room loader
This commit is contained in:
18
src/yaze.cc
18
src/yaze.cc
@@ -233,14 +233,22 @@ zelda3_overworld* yaze_load_overworld(const zelda3_rom* rom) {
|
|||||||
return overworld;
|
return overworld;
|
||||||
}
|
}
|
||||||
|
|
||||||
zelda3_dungeon_room* yaze_load_all_rooms(const zelda3_rom* rom, int* room_count) {
|
zelda3_dungeon_room* yaze_load_all_rooms(const zelda3_rom* rom,
|
||||||
if (rom->impl == nullptr) {
|
int* room_count) {
|
||||||
|
if (room_count != nullptr) {
|
||||||
|
*room_count = 0;
|
||||||
|
}
|
||||||
|
if (rom == nullptr || rom->impl == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
yaze::Rom* internal_rom = static_cast<yaze::Rom*>(rom->impl);
|
|
||||||
zelda3_dungeon_room* rooms = new zelda3_dungeon_room[256];
|
constexpr int kRoomCount = 256;
|
||||||
|
auto* rooms = new zelda3_dungeon_room[kRoomCount]();
|
||||||
|
for (int i = 0; i < kRoomCount; ++i) {
|
||||||
|
rooms[i].id = static_cast<uint16_t>(i);
|
||||||
|
}
|
||||||
if (room_count != nullptr) {
|
if (room_count != nullptr) {
|
||||||
*room_count = 256;
|
*room_count = kRoomCount;
|
||||||
}
|
}
|
||||||
return rooms;
|
return rooms;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user