22.Jul.2009

git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@95 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
gerstrong
2009-07-22 16:38:10 +00:00
parent b45ce76900
commit 531ce04fa1
53 changed files with 7040 additions and 5553 deletions
+19 -18
View File
@@ -12,14 +12,11 @@
#endif
#include <fstream>
#include <vector>
#include "../StringUtils.h"
using namespace std;
CEGAGraphics::CEGAGraphics(short episode, const std::string& path) {
CEGAGraphics::CEGAGraphics(short episode, const char *path) {
m_episode = episode;
m_path = path;
strcpy(m_path, path);
// EGAHEAD Structure
LatchPlaneSize = 0;
@@ -54,15 +51,15 @@ CEGAGraphics::~CEGAGraphics() {
bool CEGAGraphics::loadData()
{
std::string buf;
char buf[256];
vector<char> databuf;
chdir("data"); // TODO: You must be able to use another directory
if(m_path == "")
buf = "egahead.ck" + itoa(m_episode);
if(m_path[0] == 0)
sprintf(buf,"egahead.ck%hd",m_episode);
else
buf = m_path + "/egahead.ck" + itoa(m_episode);
std::ifstream HeadFile(buf.c_str(),ios::binary);
sprintf(buf,"%s/egahead.ck%hd",m_path,m_episode);
ifstream HeadFile(buf,ios::binary);
if(!HeadFile)
return false;
@@ -75,8 +72,10 @@ bool CEGAGraphics::loadData()
}
HeadFile.close();
char *data = new char[databuf.size()];
memcpy(data, &databuf[0], databuf.size());
char *data;
data = new char[databuf.size()];
memcpy(data, databuf.data(), databuf.size());
// Now copy the data to the EGAHEAD Structure
memcpy(&LatchPlaneSize,data,4);
@@ -109,10 +108,10 @@ bool CEGAGraphics::loadData()
m_Latch->loadHead(data);
if(m_path == "")
buf = "egalatch.ck" + itoa(m_episode);
if(m_path[0] == 0)
sprintf(buf,"egalatch.ck%hd",m_episode);
else
buf = m_path + "/egalatch.ck" + itoa(m_episode);
sprintf(buf,"%s/egalatch.ck%hd",m_path,m_episode);
m_Latch->loadData(buf,(compressed>>1)); // The second bit tells, if latch is compressed.
@@ -122,14 +121,16 @@ bool CEGAGraphics::loadData()
SpriteLocation);
m_Sprit->loadHead(data);
if(m_path == "")
buf = "egasprit.ck" + itoa(m_episode);
if(m_path[0] == 0)
sprintf(buf,"egasprit.ck%hd",m_episode);
else
buf = m_path + "/egasprit.ck" + itoa(m_episode);
sprintf(buf,"%s/egasprit.ck%hd",m_path,m_episode);
m_Sprit->loadData(buf,(compressed>>1));
chdir("../");
delete [] data;
return true;
}