diff --git a/CAbilityHandler.cpp b/CAbilityHandler.cpp index 5fefc154b..036727bcc 100644 --- a/CAbilityHandler.cpp +++ b/CAbilityHandler.cpp @@ -21,6 +21,7 @@ void CAbilityHandler::loadAbilities() base = std::string(tab); if(base.size()<2) //ended, but some rubbish could still stay end we have something useless { + inp.close(); return; //add counter } while(base[iit]!='\t') diff --git a/CAmbarCendamo.cpp b/CAmbarCendamo.cpp index 916b220b3..0b5c52fc5 100644 --- a/CAmbarCendamo.cpp +++ b/CAmbarCendamo.cpp @@ -23,6 +23,7 @@ CAmbarCendamo::CAmbarCendamo (const char * tie) is->seekg(0,std::ios::beg); // wracamy na poczatek bufor = new unsigned char[andame]; // allocate memory is->read((char*)bufor, andame); // read map file to buffer + is->close(); delete is; } CAmbarCendamo::~CAmbarCendamo () @@ -41,6 +42,7 @@ void CAmbarCendamo::teceDef() { (*of) << map.defy[i].bytes[j]<close(); delete of; } } @@ -48,7 +50,7 @@ void CAmbarCendamo::deh3m() { THC timeHandler th; map.version = (Eformat)bufor[0]; //wersja mapy - map.areAnyPLayers = bufor[4]; + map.areAnyPLayers = bufor[4]; //invalid on some maps map.height = map.width = bufor[5]; // wymiary mapy map.twoLevel = bufor[9]; //czy sa lochy map.terrain = new TerrainTile*[map.width]; // allocate memory @@ -74,7 +76,7 @@ void CAmbarCendamo::deh3m() { map.players[pom].canHumanPlay = bufor[i++]; map.players[pom].canComputerPlay = bufor[i++]; - if ((!(map.players[pom].canHumanPlay || map.players[pom].canComputerPlay)) || (!map.areAnyPLayers)) + if ((!(map.players[pom].canHumanPlay || map.players[pom].canComputerPlay))) { i+=13; continue; diff --git a/CBuildingHandler.cpp b/CBuildingHandler.cpp index c7aa14127..173da82ad 100644 --- a/CBuildingHandler.cpp +++ b/CBuildingHandler.cpp @@ -9,6 +9,7 @@ void CBuildingHandler::loadBuildings() inp.seekg(0,std::ios::beg); // wracamy na poczatek char * bufor = new char[andame]; // allocate memory inp.read((char*)bufor, andame); // read map file to buffer + inp.close(); std::string buf = std::string(bufor); delete [andame] bufor; int i=0; //buf iterator @@ -260,6 +261,7 @@ void CBuildingHandler::loadNames() inp.seekg(0,std::ios::beg); // wracamy na poczatek char * bufor = new char[andame]; // allocate memory inp.read((char*)bufor, andame); // read map file to buffer + inp.close(); std::string buf = std::string(bufor); delete [andame] bufor; int i=0; //buf iterator @@ -523,6 +525,7 @@ void CBuildingHandler::loadNeutNames() inp.seekg(0,std::ios::beg); // wracamy na poczatek char * bufor = new char[andame]; // allocate memory inp.read((char*)bufor, andame); // read map file to buffer + inp.close(); std::string buf = std::string(bufor); delete [andame] bufor; int i=0; //buf iterator @@ -646,6 +649,7 @@ void CBuildingHandler::loadDwellingNames() inp.seekg(0,std::ios::beg); // wracamy na poczatek char * bufor = new char[andame]; // allocate memory inp.read((char*)bufor, andame); // read map file to buffer + inp.close(); std::string buf = std::string(bufor); delete [andame] bufor; int i = 0; //buf iterator diff --git a/CCreatureHandler.cpp b/CCreatureHandler.cpp index dd4de3e7f..d23a33ef1 100644 --- a/CCreatureHandler.cpp +++ b/CCreatureHandler.cpp @@ -272,6 +272,7 @@ void CCreatureHandler::loadAnimationInfo() inp.seekg(0,std::ios::beg); // wracamy na poczatek char * bufor = new char[andame]; // allocate memory inp.read((char*)bufor, andame); // read map file to buffer + inp.close(); std::string buf = std::string(bufor); delete [andame] bufor; int i=0; //buf iterator diff --git a/CHeroHandler.cpp b/CHeroHandler.cpp index 8a402addc..f9aafc836 100644 --- a/CHeroHandler.cpp +++ b/CHeroHandler.cpp @@ -25,6 +25,7 @@ void CHeroHandler::loadHeroes() loadSpecialAbilities(); loadBiographies(); loadHeroClasses(); + inp.close(); return; } while(base[iit]!='\t') @@ -128,6 +129,7 @@ void CHeroHandler::loadSpecialAbilities() base = std::string(tab); if(base.size()<2) //ended, but some rubbish could still stay end we have something useless { + inp.close(); return; //add counter } while(base[iit]!='\t') @@ -162,6 +164,7 @@ void CHeroHandler::loadSpecialAbilities() ++whHero; delete [500] tab; } + inp.close(); } void CHeroHandler::loadBiographies() @@ -172,6 +175,7 @@ void CHeroHandler::loadBiographies() inp.seekg(0,std::ios::beg); // wracamy na poczatek char * bufor = new char[andame]; // allocate memory inp.read((char*)bufor, andame); // read map file to buffer + inp.close(); std::string buf = std::string(bufor); delete [andame] bufor; int i = 0; //buf iterator @@ -196,6 +200,7 @@ void CHeroHandler::loadHeroClasses() inp.seekg(0,std::ios::beg); // wracamy na poczatek char * bufor = new char[andame]; // allocate memory inp.read((char*)bufor, andame); // read map file to buffer + inp.close(); std::string buf = std::string(bufor); delete [andame] bufor; int i = 0; //buf iterator diff --git a/CMT.cpp b/CMT.cpp index 4f7ca2cee..728649997 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -280,7 +280,7 @@ int _tmain(int argc, _TCHAR* argv[]) CObjectHandler * objh = new CObjectHandler; objh->loadObjects(); cgi->objh = objh; - CAmbarCendamo * ac = new CAmbarCendamo("Arrogance"); //4gryf + CAmbarCendamo * ac = new CAmbarCendamo("Cave of Gerfrex"); //4gryf CMapHeader * mmhh = new CMapHeader(ac->bufor); //czytanie nagłówka cgi->ac = ac; THC std::cout<<"Wczytywanie pliku: "<version = (Eformat)map[0]; //wersja mapy - this->areAnyPLayers = map[4]; + this->areAnyPLayers = map[4]; //seems to be invalid this->height = this->width = map[5]; // wymiary mapy this->twoLevel = map[9]; //czy sa lochy @@ -33,7 +33,7 @@ CMapHeader::CMapHeader(unsigned char *map) { this->players[pom].canHumanPlay = map[i++]; this->players[pom].canComputerPlay = map[i++]; - if ((!(this->players[pom].canHumanPlay || this->players[pom].canComputerPlay)) || (!this->areAnyPLayers)) + if ((!(this->players[pom].canHumanPlay || this->players[pom].canComputerPlay))) { i+=13; continue;