2
0

CObjectHandler.cpp 844 B

12345678910111213141516171819202122232425262728293031
  1. #include "stdafx.h"
  2. #include "CObjectHandler.h"
  3. void CObjectHandler::loadObjects()
  4. {
  5. std::ifstream inp("H3bitmap.lod\\OBJNAMES.TXT", std::ios::in | std::ios::binary);
  6. inp.seekg(0,std::ios::end); // na koniec
  7. int andame = inp.tellg(); // read length
  8. inp.seekg(0,std::ios::beg); // wracamy na poczatek
  9. char * bufor = new char[andame]; // allocate memory
  10. inp.read((char*)bufor, andame); // read map file to buffer
  11. inp.close();
  12. std::string buf = std::string(bufor);
  13. delete [andame] bufor;
  14. int i = 0; //buf iterator
  15. while(!inp.eof())
  16. {
  17. if(objects.size()>200 && buf.substr(i, buf.size()-i).find('\r')==std::string::npos)
  18. break;
  19. CObject nobj;
  20. int befi=i;
  21. for(i; i<andame; ++i)
  22. {
  23. if(buf[i]=='\r')
  24. break;
  25. }
  26. nobj.name = buf.substr(befi, i-befi);
  27. i+=2;
  28. objects.push_back(nobj);
  29. }
  30. }