2007-06-11 20:21:27 +03:00
|
|
|
#include "stdafx.h"
|
2007-06-12 12:33:20 +03:00
|
|
|
#include "CObjectHandler.h"
|
2007-06-11 20:21:27 +03:00
|
|
|
|
|
|
|
void CObjectHandler::loadObjects()
|
|
|
|
{
|
|
|
|
std::ifstream inp("H3bitmap.lod\\OBJNAMES.TXT", std::ios::in | std::ios::binary);
|
|
|
|
inp.seekg(0,std::ios::end); // na koniec
|
|
|
|
int andame = inp.tellg(); // read length
|
|
|
|
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
|
2007-06-22 16:50:16 +03:00
|
|
|
inp.close();
|
2007-06-11 20:21:27 +03:00
|
|
|
std::string buf = std::string(bufor);
|
|
|
|
delete [andame] bufor;
|
|
|
|
int i = 0; //buf iterator
|
|
|
|
while(!inp.eof())
|
|
|
|
{
|
|
|
|
if(objects.size()>200 && buf.substr(i, buf.size()-i).find('\r')==std::string::npos)
|
|
|
|
break;
|
|
|
|
CObject nobj;
|
|
|
|
int befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nobj.name = buf.substr(befi, i-befi);
|
|
|
|
i+=2;
|
|
|
|
objects.push_back(nobj);
|
|
|
|
}
|
|
|
|
}
|