MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / LoadMapObjects

Function LoadMapObjects

Source/objects.cpp:651–681  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

649}
650
651void LoadMapObjects(const char *path, Point start, WorldTileRectangle mapRange = {}, int leveridx = 0)
652{
653 LoadingMapObjects = true;
654
655 auto dunData = LoadFileInMem<uint16_t>(path);
656
657 int width = SDL_SwapLE16(dunData[0]);
658 int height = SDL_SwapLE16(dunData[1]);
659
660 int layer2Offset = 2 + width * height;
661
662 // The rest of the layers are at dPiece scale
663 width *= 2;
664 height *= 2;
665
666 const uint16_t *objectLayer = &dunData[layer2Offset + width * height * 2];
667
668 for (int j = 0; j < height; j++) {
669 for (int i = 0; i < width; i++) {
670 auto objectId = static_cast<uint8_t>(SDL_SwapLE16(objectLayer[j * width + i]));
671 if (objectId != 0) {
672 Point mapPos = start + Displacement { i, j };
673 Object *mapObject = AddObject(ObjTypeConv[objectId], mapPos);
674 if (leveridx > 0 && mapObject != nullptr)
675 mapObject->InitializeLoadedObject(mapRange, leveridx);
676 }
677 }
678 }
679
680 LoadingMapObjects = false;
681}
682
683void AddDiabObjs()
684{

Callers 4

AddDiabObjsFunction · 0.85
OperatePedestalFunction · 0.85
SyncPedestalFunction · 0.85
InitObjectsFunction · 0.85

Calls 2

AddObjectFunction · 0.85

Tested by

no test coverage detected