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

Function SetMapObjects

Source/objects.cpp:4061–4098  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4059}
4060
4061void SetMapObjects(const uint16_t *dunData, int startx, int starty)
4062{
4063 uint16_t filesWidths[65] = {};
4064
4065 ClrAllObjects();
4066
4067 int width = SDL_SwapLE16(dunData[0]);
4068 int height = SDL_SwapLE16(dunData[1]);
4069
4070 int layer2Offset = 2 + width * height;
4071
4072 // The rest of the layers are at dPiece scale
4073 width *= 2;
4074 height *= 2;
4075
4076 const uint16_t *objectLayer = &dunData[layer2Offset + width * height * 2];
4077
4078 for (int j = 0; j < height; j++) {
4079 for (int i = 0; i < width; i++) {
4080 auto objectId = static_cast<uint8_t>(SDL_SwapLE16(objectLayer[j * width + i]));
4081 if (objectId != 0) {
4082 const ObjectData &objectData = AllObjects[ObjTypeConv[objectId]];
4083 filesWidths[objectData.ofindex] = objectData.animWidth;
4084 }
4085 }
4086 }
4087
4088 LoadLevelObjects(filesWidths);
4089
4090 for (int j = 0; j < height; j++) {
4091 for (int i = 0; i < width; i++) {
4092 auto objectId = static_cast<uint8_t>(SDL_SwapLE16(objectLayer[j * width + i]));
4093 if (objectId != 0) {
4094 AddObject(ObjTypeConv[objectId], { startx + 16 + i, starty + 16 + j });
4095 }
4096 }
4097 }
4098}
4099
4100Object *AddObject(_object_id objType, Point objPos)
4101{

Callers 1

LoadDungeonBaseFunction · 0.85

Calls 3

ClrAllObjectsFunction · 0.85
LoadLevelObjectsFunction · 0.85
AddObjectFunction · 0.85

Tested by

no test coverage detected