1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Wczytywanie kilku dodatkowych tekstów, zamykanie strumieni plikowych, naprawienie drobnego błędu w czytaniu nagłówka mapy.

This commit is contained in:
mateuszb 2007-06-22 13:50:16 +00:00
parent 1a01585af8
commit e060988289
12 changed files with 55 additions and 5 deletions

View File

@ -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')

View File

@ -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]<<std::endl;
}
of->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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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: "<<tmh.getDif()<<std::endl;

View File

@ -9,6 +9,7 @@ void CObjectHandler::loadObjects()
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

View File

@ -348,6 +348,7 @@ void CPreGame::showAskBox (std::string data, void(*f1)(),void(*f2)())
delete cmh;
delete przyciski;
delete btnspos;
}
void CPreGame::hideBox ()
{

View File

@ -27,6 +27,7 @@ void CPreGameTextHandler::loadTexts()
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
@ -395,6 +396,34 @@ void CPreGameTextHandler::loadTexts()
loadToIt(singleStartingTownHeaderWConfluxID, buf, i, 0);
loadToIt(singleStartingHeroHeaderID, buf, i, 0);
loadToIt(singleStartingBonusHeaderID, buf, i, 0);
hmcr = 0;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
++hmcr;
if(hmcr==3)
break;
}
i+=2;
loadToIt(multiOnlineService, buf, i, 0);
loadToIt(multiHotSeat, buf, i, 0);
loadToIt(multiIPX, buf, i, 0);
loadToIt(multiTCPIP, buf, i, 0);
loadToIt(multiModem, buf, i, 0);
loadToIt(multiDirectConnection, buf, i, 0);
loadToIt(multiHostGame, buf, i, 0);
loadToIt(multiJoinGame, buf, i, 1);
loadToIt(multiSearchGame, buf, i, 1);
for(int vv=0; vv<12; ++vv)
{
loadToIt(multiGameNo[vv], buf, i, 1);
}
loadToIt(multiScrollGames, buf, i, 1);
std::string dump;
loadToIt(dump, buf, i, 1);
loadToIt(multiCancel, buf, i, 0);
}
void CPreGameTextHandler::loadToIt(std::string &dest, std::string &src, int &iter, int mode)

View File

@ -25,6 +25,11 @@ public:
std::string singleConstNComputerTeams[6];
std::string singleConstRandomComputerTeams, singleConstWaterLabel, singleConstNoWater, singleConstNormalWater, singleConstIslands, singleConstRandomWater, singleConstMonsterStrengthLabel, singleConstWeakMonsters, singleConstNormalMonsters, singleConstStrongMonsters, singleConstRandomMonsters, singleConstShowSavedRandomMaps, singleSliderChatWindow, singleSliderFileMenu, singleSliderDuration;
std::string singlePlayerHandicapHeaderID, singleTurnDurationHeaderID, singleStartingTownHeaderID, singleStartingTownHeaderWConfluxID, singleStartingHeroHeaderID, singleStartingBonusHeaderID;
std::string multiOnlineService, multiHotSeat, multiIPX, multiTCPIP, multiModem, multiDirectConnection, multiHostGame, multiJoinGame, multiSearchGame;
std::string multiGameNo [12];
std::string multiScrollGames, multiCancel;
std::string getTitle(std::string text);
std::string getDescr(std::string text);
void loadTexts();

View File

@ -9,6 +9,7 @@ void CSpellHandler::loadSpells()
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

View File

@ -15,7 +15,7 @@ int readNormalNr (unsigned char * bufor, int pos, int bytCon = 4)
CMapHeader::CMapHeader(unsigned char *map)
{
this->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;