@@ -1213,15 +1213,66 @@ namespace Maps
1213
1213
auto sortObjects = []( const IndexedObjectInfo & left, const IndexedObjectInfo & right ) { return left.info ->id < right.info ->id ; };
1214
1214
std::multiset<IndexedObjectInfo, decltype ( sortObjects )> sortedObjects ( sortObjects );
1215
1215
1216
+ #if defined( WITH_DEBUG )
1217
+ std::map<uint32_t , IndexedObjectInfo> objectsUIDs;
1218
+ std::multiset<IndexedObjectInfo, decltype ( sortObjects )> incorrectObjects ( sortObjects );
1219
+ #endif
1220
+
1216
1221
for ( size_t i = 0 ; i < tilesConut; ++i ) {
1217
1222
for ( const auto & object : map.tiles [i].objects ) {
1218
1223
IndexedObjectInfo info;
1219
1224
info.tileIndex = static_cast <int32_t >( i );
1220
1225
info.info = &object;
1221
1226
sortedObjects.emplace ( info );
1227
+
1228
+ #if defined( WITH_DEBUG )
1229
+ if ( object.group != Maps::ObjectGroup::LANDSCAPE_TOWN_BASEMENTS && object.group != Maps::ObjectGroup::LANDSCAPE_FLAGS ) {
1230
+ const auto [iter, inserted] = objectsUIDs.try_emplace ( object.id , info );
1231
+ if ( !inserted ) {
1232
+ incorrectObjects.emplace ( iter->second );
1233
+ incorrectObjects.emplace ( info );
1234
+ }
1235
+ }
1236
+ #endif
1222
1237
}
1223
1238
}
1224
1239
1240
+ #if defined( WITH_DEBUG )
1241
+ uint32_t uid = 0 ;
1242
+ for ( const IndexedObjectInfo & info : incorrectObjects ) {
1243
+ if ( info.info ->id != uid ) {
1244
+ uid = info.info ->id ;
1245
+ if ( map.standardMetadata .find ( uid ) != map.standardMetadata .end () ) {
1246
+ VERBOSE_LOG ( " `standardMetadata` belongs to many objects with same UID: " << uid )
1247
+ }
1248
+ if ( map.castleMetadata .find ( uid ) != map.castleMetadata .end () ) {
1249
+ VERBOSE_LOG ( " `castleMetadata` belongs to many objects with same UID: " << uid )
1250
+ }
1251
+ if ( map.heroMetadata .find ( uid ) != map.heroMetadata .end () ) {
1252
+ VERBOSE_LOG ( " `heroMetadata` belongs to many objects with same UID: " << uid )
1253
+ }
1254
+ if ( map.sphinxMetadata .find ( uid ) != map.sphinxMetadata .end () ) {
1255
+ VERBOSE_LOG ( " `sphinxMetadata` belongs to many objects with same UID: " << uid )
1256
+ }
1257
+ if ( map.signMetadata .find ( uid ) != map.signMetadata .end () ) {
1258
+ VERBOSE_LOG ( " `signMetadata` belongs to many objects with same UID: " << uid )
1259
+ }
1260
+ if ( map.adventureMapEventMetadata .find ( uid ) != map.adventureMapEventMetadata .end () ) {
1261
+ VERBOSE_LOG ( " `adventureMapEventMetadata` belongs to many objects with same UID: " << uid )
1262
+ }
1263
+ if ( map.selectionObjectMetadata .find ( uid ) != map.selectionObjectMetadata .end () ) {
1264
+ VERBOSE_LOG ( " `selectionObjectMetadata` belongs to many objects with same UID: " << uid )
1265
+ }
1266
+ if ( map.capturableObjectsMetadata .find ( uid ) != map.capturableObjectsMetadata .end () ) {
1267
+ VERBOSE_LOG ( " `capturableObjectsMetadata` belongs to many objects with same UID: " << uid )
1268
+ }
1269
+ }
1270
+
1271
+ VERBOSE_LOG ( " Non-unique UID " << info.info ->id << " at " << info.tileIndex << " (" << info.tileIndex % map.size << " , " << info.tileIndex / map.size
1272
+ << " ) tile for object type: " << MP2::StringObject ( getObjectInfo ( info.info ->group , info.info ->index ).objectType ) )
1273
+ }
1274
+ #endif
1275
+
1225
1276
for ( const auto & info : sortedObjects ) {
1226
1277
assert ( info.info != nullptr );
1227
1278
if ( !readTileObject ( world.getTile ( info.tileIndex ), *info.info ) ) {
0 commit comments