Add Dungeon Room and Object Selection Features

- Introduced new classes for DungeonRoomSelector and DungeonObjectSelector to enhance room and object management within the dungeon editor.
- Implemented UI components for selecting rooms and entrances, allowing users to easily navigate and manage dungeon layouts.
- Added functionality for rendering room graphics and object previews, improving the visual editing experience.
- Updated the DungeonEditor class to integrate the new selectors, streamlining the overall editing workflow.
- Enhanced error handling and validation in room and object management processes to ensure robust functionality.
This commit is contained in:
scawful
2025-09-24 23:39:50 -04:00
parent 4ae9dc9e0c
commit a71f1e02c9
11 changed files with 1819 additions and 245 deletions

View File

@@ -873,9 +873,24 @@ void Sprite::DrawSpriteTile(int x, int y, int srcx, int srcy, int pal,
return;
}
// Validate input parameters
if (sizex <= 0 || sizey <= 0) {
return;
}
if (srcx < 0 || srcy < 0 || pal < 0) {
return;
}
x += 16;
y += 16;
int drawid_ = (srcx + (srcy * 16)) + 512;
// Validate drawid_ is within reasonable bounds
if (drawid_ < 0 || drawid_ > 4096) {
return;
}
for (auto yl = 0; yl < sizey * 8; yl++) {
for (auto xl = 0; xl < (sizex * 8) / 2; xl++) {
int mx = xl;
@@ -893,12 +908,21 @@ void Sprite::DrawSpriteTile(int x, int y, int srcx, int srcy, int pal,
int tx = ((drawid_ / 0x10) * 0x400) +
((drawid_ - ((drawid_ / 0x10) * 0x10)) * 8);
auto pixel = current_gfx_[tx + (yl * 0x80) + xl];
// Validate graphics buffer access
int gfx_index = tx + (yl * 0x80) + xl;
if (gfx_index < 0 || gfx_index >= static_cast<int>(current_gfx_.size())) {
continue; // Skip this pixel if out of bounds
}
auto pixel = current_gfx_[gfx_index];
// nx,ny = object position, xx,yy = tile position, xl,yl = pixel
// position
int index = (x) + (y * 64) + (mx + (my * 0x80));
if (index >= 0 && index <= 4096) {
// Validate preview buffer access
if (index >= 0 && index < static_cast<int>(preview_gfx_.size()) &&
index <= 4096) {
preview_gfx_[index] = (uint8_t)((pixel & 0x0F) + 112 + (pal * 8));
}
}