#include "stdafx.h" #include "CArtHandler.h" void CArtHandler::loadArtifacts() { std::ifstream inp("H3bitmap.lod\\ARTRAITS.TXT", std::ios::in); std::string dump; for(int i=0; i<44; ++i) { inp>>dump; } inp.ignore(); int numberlet = 0; //numer of artifact while(!inp.eof()) { CArtifact nart; nart.number = numberlet++; char * read = new char[10000]; //here we'll have currently read character inp.getline(read, 10000); int eol=0; //end of looking std::string ss = std::string(read); if(ss==std::string("") && inp.eof()) { delete [10000] read; loadArtEvents(); return; } for(int i=0; i<200; ++i) { if(ss[i]=='\t') { nart.name = ss.substr(0, i); eol=i+1; break; } } if(nart.name==std::string("-1") || nart.name==std::string("-2")) { artifacts.push_back(nart); continue; } for(int i=eol; iartifacts.push_back(nart); delete[10000] read; } loadArtEvents(); } bool CArtHandler::loadArtEvents() { std::ifstream inp("H3bitmap.lod\\ARTEVENT.TXT", std::ios::in); if(!inp.is_open()) { return false; } for(int i=0; iartifacts.size(); ++i) { char * tab = new char[1000]; inp.getline(tab, 1000); std::string spo = std::string("\42-1\42"); if(std::string(tab).substr(0, std::string(tab).size()-1)==std::string("\42-1\42") || std::string(tab).substr(0, std::string(tab).size()-1)==std::string("\"-2\"")) { continue; } artifacts[i].eventText = std::string(tab).substr(0, std::string(tab).size()-1); delete[1000] tab; } return true; }