chucky91
Intermediate OT User
- Joined
- Apr 8, 2010
- Messages
- 267
- Solutions
- 9
- Reaction score
- 145
I'm adapting this to save the items on the floor. because of rollback,
but it's not even reaching this line: > Saved map items in: "
and jumps to house save.
I had to change and put this i don't know if it's the case. maxViewportY.
Can someone clear my doubts?
but it's not even reaching this line: > Saved map items in: "
and jumps to house save.
I had to change and put this i don't know if it's the case. maxViewportY.
Can someone clear my doubts?
C++:
bool IOMapSerialize::saveMapItems()
{
int64_t start = OTSYS_TIME();
Database* db = Database::getInstance();
std::ostringstream query;
//Start the transaction
DBTransaction transaction;
if (!transaction.begin()) {
return false;
}
//clear old tile data
if (!db->executeQuery("DELETE FROM `tile_store`")) {
return false;
}
DBInsert stmt("INSERT INTO `tile_store` (`x`, `y`, `z`, `data`) VALUES ");
PropWriteStream stream;
for (int32_t z = 0; z < MAP_MAX_LAYERS; ++z) {
for (int32_t y = 0; y < g_game.map.maxViewportY; ++y) {
for (int32_t x = 0; x < g_game.map.maxViewportX; ++x) {
Tile* tile = g_game.map.getTile(x, y, z);
saveTile(stream, tile);
size_t attributesSize;
const char* attributes = stream.getStream(attributesSize);
if (attributesSize > 0) {
query << x << ',' << y << ',' << z << ',' << db->escapeBlob(attributes, attributesSize);
if (!stmt.addRow(query)) {
return false;
}
stream.clear();
}
}
}
}
if (!stmt.execute()) {
return false;
}
//End the transaction
bool success = transaction.commit();
std::cout << "> Saved map items in: " <<
(OTSYS_TIME() - start) / (1000.) << " s" << std::endl;
return success;
}