diff --git a/client/CMT.cpp b/client/CMT.cpp index 095ab489e..2476a7ca3 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -735,6 +735,12 @@ void dispose() { if (console) delete console; + + // cleanup, mostly to remove false leaks from analyzer + CResourceHandler::clear(); + CCS->musich->release(); + CCS->soundh->release(); + CMessage::dispose(); } //used only once during initialization diff --git a/client/CMusicHandler.cpp b/client/CMusicHandler.cpp index 44dbacdc8..76b4ae77a 100644 --- a/client/CMusicHandler.cpp +++ b/client/CMusicHandler.cpp @@ -501,8 +501,8 @@ void MusicEntry::load(std::string musicURI) logGlobal->traceStream()<<"Loading music file "<load(ResourceID(musicURI, EResType::MUSIC))->readAll(); - musicFile = SDL_RWFromConstMem(data.first.release(), data.second); + data = CResourceHandler::get()->load(ResourceID(musicURI, EResType::MUSIC))->readAll(); + musicFile = SDL_RWFromConstMem(data.first.get(), data.second); music = Mix_LoadMUS_RW(musicFile); if(!music) diff --git a/client/CMusicHandler.h b/client/CMusicHandler.h index 9960901cc..b5d314e20 100644 --- a/client/CMusicHandler.h +++ b/client/CMusicHandler.h @@ -85,6 +85,7 @@ class CMusicHandler; //Class for handling one music file class MusicEntry { + std::pair, size_t> data; CMusicHandler *owner; Mix_Music *music; SDL_RWops *musicFile; diff --git a/config/factions/conflux.json b/config/factions/conflux.json index c1be3d022..ca9712775 100644 --- a/config/factions/conflux.json +++ b/config/factions/conflux.json @@ -160,7 +160,7 @@ "shipyard": { "id" : 6 }, "fort": { "id" : 7 }, "citadel": { "id" : 8, "upgrades" : "fort" }, - "castle": { "id" : 9, "upgrades" : "castle" }, + "castle": { "id" : 9, "upgrades" : "citadel" }, "villageHall": { "id" : 10, "mode" : "auto" }, "townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] }, "cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] }, diff --git a/config/factions/dungeon.json b/config/factions/dungeon.json index 99c81debd..a95a9b0a3 100644 --- a/config/factions/dungeon.json +++ b/config/factions/dungeon.json @@ -154,7 +154,7 @@ "tavern": { "id" : 5 }, "fort": { "id" : 7 }, "citadel": { "id" : 8, "upgrades" : "fort" }, - "castle": { "id" : 9, "upgrades" : "castle" }, + "castle": { "id" : 9, "upgrades" : "citadel" }, "villageHall": { "id" : 10, "mode" : "auto" }, "townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] }, "cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] }, diff --git a/config/factions/fortress.json b/config/factions/fortress.json index 7b5137b14..66a899c1e 100644 --- a/config/factions/fortress.json +++ b/config/factions/fortress.json @@ -153,7 +153,7 @@ "shipyard": { "id" : 6 }, "fort": { "id" : 7 }, "citadel": { "id" : 8, "upgrades" : "fort" }, - "castle": { "id" : 9, "upgrades" : "castle" }, + "castle": { "id" : 9, "upgrades" : "citadel" }, "villageHall": { "id" : 10, "mode" : "auto" }, "townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] }, "cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] }, diff --git a/config/factions/inferno.json b/config/factions/inferno.json index d62555fc0..8e130bc3d 100644 --- a/config/factions/inferno.json +++ b/config/factions/inferno.json @@ -155,7 +155,7 @@ "tavern": { "id" : 5 }, "fort": { "id" : 7 }, "citadel": { "id" : 8, "upgrades" : "fort" }, - "castle": { "id" : 9, "upgrades" : "castle" }, + "castle": { "id" : 9, "upgrades" : "citadel" }, "villageHall": { "id" : 10, "mode" : "auto" }, "townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] }, "cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] }, diff --git a/config/factions/necropolis.json b/config/factions/necropolis.json index c1096de3c..92fd6a217 100644 --- a/config/factions/necropolis.json +++ b/config/factions/necropolis.json @@ -159,7 +159,7 @@ "shipyard": { "id" : 6 }, "fort": { "id" : 7 }, "citadel": { "id" : 8, "upgrades" : "fort" }, - "castle": { "id" : 9, "upgrades" : "castle" }, + "castle": { "id" : 9, "upgrades" : "citadel" }, "villageHall": { "id" : 10, "mode" : "auto" }, "townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] }, "cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] }, diff --git a/config/factions/rampart.json b/config/factions/rampart.json index a7fa6726c..4e8fd7e22 100644 --- a/config/factions/rampart.json +++ b/config/factions/rampart.json @@ -159,7 +159,7 @@ "tavern": { "id" : 5 }, "fort": { "id" : 7 }, "citadel": { "id" : 8, "upgrades" : "fort" }, - "castle": { "id" : 9, "upgrades" : "castle" }, + "castle": { "id" : 9, "upgrades" : "citadel" }, "villageHall": { "id" : 10, "mode" : "auto" }, "townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] }, "cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] }, diff --git a/config/factions/stronghold.json b/config/factions/stronghold.json index 6b577bb75..c74b834e4 100644 --- a/config/factions/stronghold.json +++ b/config/factions/stronghold.json @@ -150,7 +150,7 @@ "tavern": { "id" : 5 }, "fort": { "id" : 7 }, "citadel": { "id" : 8, "upgrades" : "fort" }, - "castle": { "id" : 9, "upgrades" : "castle" }, + "castle": { "id" : 9, "upgrades" : "citadel" }, "villageHall": { "id" : 10, "mode" : "auto" }, "townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] }, "cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] }, diff --git a/config/factions/tower.json b/config/factions/tower.json index 06880ba07..151b02101 100644 --- a/config/factions/tower.json +++ b/config/factions/tower.json @@ -154,7 +154,7 @@ "tavern": { "id" : 5 }, "fort": { "id" : 7 }, "citadel": { "id" : 8, "upgrades" : "fort" }, - "castle": { "id" : 9, "upgrades" : "castle" }, + "castle": { "id" : 9, "upgrades" : "citadel" }, "villageHall": { "id" : 10, "mode" : "auto" }, "townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] }, "cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] }, diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index bcf7da482..c0bd329f3 100644 --- a/lib/CTownHandler.cpp +++ b/lib/CTownHandler.cpp @@ -311,18 +311,18 @@ void CTownHandler::loadBuilding(CTown &town, const std::string & stringID, const ret->upgrade = BuildingID(source["upgrades"].Float()); else { + // building id and upgrades can't be the same + if(stringID == source["upgrades"].String()) + { + throw std::runtime_error(boost::str(boost::format("Building with ID '%s' of town '%s' can't be an upgrade of the same building.") % + stringID % town.faction->name)); + } + VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, source["upgrades"], [=](si32 identifier) { ret->upgrade = BuildingID(identifier); }); } - - // building id and upgrades can't be the same - if(ret->upgrade == ret->bid) - { - throw std::runtime_error(boost::str(boost::format("Building with ID '%s' of town '%s' can't be an upgrade of the same building.") % - stringID % town.faction->name)); - } } else ret->upgrade = BuildingID::NONE; diff --git a/lib/filesystem/CCompressedStream.cpp b/lib/filesystem/CCompressedStream.cpp index 0f1a1834c..0830fae9d 100644 --- a/lib/filesystem/CCompressedStream.cpp +++ b/lib/filesystem/CCompressedStream.cpp @@ -102,7 +102,8 @@ CCompressedStream::CCompressedStream(std::unique_ptr stream, bool CCompressedStream::~CCompressedStream() { - delete inflateState; + inflateEnd(inflateState); + //delete inflateState; } si64 CCompressedStream::readMore(ui8 *data, si64 size) @@ -163,7 +164,7 @@ si64 CCompressedStream::readMore(ui8 *data, si64 size) if (fileEnded) { inflateEnd(inflateState); - vstd::clear_pointer(inflateState); + //vstd::clear_pointer(inflateState); } return decompressed; }