yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_validator.cc
Go to the documentation of this file.
1#include "dungeon_validator.h"
2
3#include "absl/strings/str_format.h"
4
5namespace yaze {
6namespace zelda3 {
7
9 ValidationResult result;
10
11 // Check object count
12 size_t object_count = room.GetTileObjects().size();
13 if (object_count > kMaxObjects) {
14 result.warnings.push_back(absl::StrFormat(
15 "High object count (%zu > %d). May cause lag or memory issues.",
16 object_count, kMaxObjects));
17 }
18
19 // Check sprite count
20 size_t sprite_count = room.GetSprites().size();
21 if (sprite_count > kMaxTotalSprites) {
22 result.warnings.push_back(absl::StrFormat(
23 "Too many sprites (%zu > %d). Game limit is strict.", sprite_count,
25 }
26
27 // Check chest count (approximate, based on object ID)
28 int chest_count = 0;
29 for (const auto& obj : room.GetTileObjects()) {
30 // Check for Big Chest (0xE4?? No, let's trust standard ranges)
31 // ZScream logic for chests:
32 // 0xF9 = Small Key Chest
33 // 0xFA = Big Key Chest
34 // 0xFB = Map Chest
35 // 0xFC = Compass Chest
36 // 0xFD = Big Chest
37 // But simple chest objects are also common.
38 // Let's count objects in the 0xF9-0xFD range as chests for now.
39 if (obj.id_ >= 0xF9 && obj.id_ <= 0xFD) {
40 chest_count++;
41 }
42 }
43
44 if (chest_count > kMaxChests) {
45 result.errors.push_back(absl::StrFormat(
46 "Too many chests (%d > %d). Item collection flags will conflict.",
47 chest_count, kMaxChests));
48 result.is_valid = false;
49 }
50
51 // Check bounds
52 for (const auto& obj : room.GetTileObjects()) {
53 if (obj.x_ < 0 || obj.x_ >= 64 || obj.y_ < 0 || obj.y_ >= 64) {
54 result.errors.push_back(absl::StrFormat(
55 "Object 0x%02X out of bounds at (%d, %d)", obj.id_, obj.x_, obj.y_));
56 result.is_valid = false;
57 }
58 }
59
60 return result;
61}
62
63} // namespace zelda3
64} // namespace yaze
ValidationResult ValidateRoom(const Room &room)
static constexpr int kMaxTotalSprites
const std::vector< zelda3::Sprite > & GetSprites() const
Definition room.h:246
const std::vector< RoomObject > & GetTileObjects() const
Definition room.h:346
std::vector< std::string > errors
std::vector< std::string > warnings