1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00

* fixed reading .defs

* new system for handling objects and their behaviors, most functionalities don't work now but will be restored soon
* more serialization code, savegame/loadgame bit closer :)
CHANGES IN PROJECT FILES:
* removed CLua.h and CLua.cpp (server)
* removed CScriptCallback.h and CScriptCallback.cpp (server)
* added IGameCallback.h header (lib)
This commit is contained in:
Michał W. Urbańczyk
2008-12-22 17:48:41 +00:00
parent 633b0007ba
commit ae48e73fe7
29 changed files with 1840 additions and 2691 deletions

View File

@ -6,7 +6,15 @@
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <fstream>
#include <sstream>
std::string readTo(std::string &in, unsigned int &it, char end)
{
int pom = it;
int last = in.find_first_of(end,it);
it+=(1+last-it);
return in.substr(pom,last-pom);
}
void CGeneralTextHandler::load()
{
std::string buf = bitmaph->getTextFile("GENRLTXT.TXT"), tmp;
@ -165,4 +173,99 @@ void CGeneralTextHandler::loadTexts()
{
loadToIt(hTxts[iii].biography,buf,i,3);
}
unsigned it;
buf = bitmaph->getTextFile("BLDGNEUT.TXT");
andame = buf.size(), it=0;
for(int b=0;b<15;b++)
{
std::string name = readTo(buf,it,'\t'),
description = readTo(buf,it,'\n');
for(int fi=0;fi<F_NUMBER;fi++)
{
buildings[fi][b].first = name;
buildings[fi][b].second = description;
}
}
buf1 = readTo(buf,it,'\n');buf1 = readTo(buf,it,'\n');buf1 = readTo(buf,it,'\n');//silo,blacksmith,moat - useless???
//shipyard with the ship
std::string name = readTo(buf,it,'\t'),
description = readTo(buf,it,'\n');
for(int fi=0;fi<F_NUMBER;fi++)
{
buildings[fi][20].first = name;
buildings[fi][20].second = description;
}
for(int fi=0;fi<F_NUMBER;fi++)
{
buildings[fi][16].first = readTo(buf,it,'\t'),
buildings[fi][16].second = readTo(buf,it,'\n');
}
/////done reading "BLDGNEUT.TXT"******************************
buf = bitmaph->getTextFile("BLDGSPEC.TXT");
andame = buf.size(), it=0;
for(int f=0;f<F_NUMBER;f++)
{
for(int b=0;b<9;b++)
{
buildings[f][17+b].first = readTo(buf,it,'\t');
buildings[f][17+b].second = readTo(buf,it,'\n');
}
buildings[f][26].first = readTo(buf,it,'\t');
buildings[f][26].second = readTo(buf,it,'\n');
buildings[f][15].first = readTo(buf,it,'\t'); //resource silo
buildings[f][15].second = readTo(buf,it,'\n');//resource silo
}
/////done reading BLDGSPEC.TXT*********************************
buf = bitmaph->getTextFile("DWELLING.TXT");
andame = buf.size(), it=0;
for(int f=0;f<F_NUMBER;f++)
{
for(int b=0;b<14;b++)
{
buildings[f][30+b].first = readTo(buf,it,'\t');
buildings[f][30+b].second = readTo(buf,it,'\n');
}
}
buf = bitmaph->getTextFile("TCOMMAND.TXT");
itr=0;
while(itr<buf.length()-1)
{
std::string tmp;
loadToIt(tmp, buf, itr, 3);
tcommands.push_back(tmp);
}
buf = bitmaph->getTextFile("HALLINFO.TXT");
itr=0;
while(itr<buf.length()-1)
{
std::string tmp;
loadToIt(tmp, buf, itr, 3);
hcommands.push_back(tmp);
}
std::istringstream ins, names;
ins.str(bitmaph->getTextFile("TOWNTYPE.TXT"));
names.str(bitmaph->getTextFile("TOWNNAME.TXT"));
int si=0;
char bufname[75];
while (!ins.eof())
{
ins.getline(bufname,50);
townTypes.push_back(std::string(bufname).substr(0,strlen(bufname)-1));
townNames.resize(si+1);
for (int i=0; i<NAMES_PER_TOWN; i++)
{
names.getline(bufname,50);
townNames[si].push_back(std::string(bufname).substr(0,strlen(bufname)-1));
}
si++;
}
}