From 8092feb787614052ec31df3538f2f79b966f6b67 Mon Sep 17 00:00:00 2001 From: ErikasKontenis Date: Fri, 20 Nov 2020 11:57:13 +0200 Subject: [PATCH] introduce saving house walls and saving all hangables including hangables which transforms --- src/iomapserialize.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/iomapserialize.cpp b/src/iomapserialize.cpp index a6a5b9d..ef6183f 100644 --- a/src/iomapserialize.cpp +++ b/src/iomapserialize.cpp @@ -99,6 +99,27 @@ bool IOMapSerialize::saveHouseItems() } stream.clear(); } + + static const Direction directions[] = { DIRECTION_EAST, DIRECTION_WEST, DIRECTION_NORTH, DIRECTION_SOUTH }; + for (Direction direction : directions) { + Position position = getNextPosition(direction, tile->getPosition()); + Tile* nextTile = g_game.map.getTile(position); + if (nextTile && nextTile->hasFlag(TILESTATE_BLOCKSOLID) && !nextTile->hasFlag(TILESTATE_PROTECTIONZONE)) { + saveTile(stream, nextTile); + + size_t attributesSize; + const char* attributes = stream.getStream(attributesSize); + if (attributesSize > 0) { + query << house->getId() << ',' << db->escapeBlob(attributes, attributesSize); + if (!stmt.addRow(query)) { + return false; + } + stream.clear(); + } + + nextTile->setFlag(TILESTATE_PROTECTIONZONE); + } + } } } @@ -177,6 +198,9 @@ bool IOMapSerialize::loadItem(PropStream& propStream, Cylinder* parent) } else if (iType.isBed() && findItem->getBed()) { item = findItem; break; + } else if (!iType.moveable && iType.changeUse && findItem->getID() == iType.transformToOnUse) { + item = findItem; + break; } } } @@ -247,7 +271,7 @@ void IOMapSerialize::saveTile(PropWriteStream& stream, const Tile* tile) const ItemType& it = Item::items[item->getID()]; // Note that these are NEGATED, ie. these are the items that will be saved. - if (!(it.moveable || item->getDoor() || (item->getContainer() && !item->getContainer()->empty()) || it.canWriteText || item->getBed())) { + if (!(it.moveable || item->getDoor() || (item->getContainer() && !item->getContainer()->empty()) || it.canWriteText || it.isHangable || item->getBed())) { continue; }