reverted all src changes from rev95 commit (because all old work was just removed)
git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@107 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
@@ -6,29 +6,31 @@
|
||||
*/
|
||||
|
||||
#include "CExeFile.h"
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "../StringUtils.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
CExeFile::CExeFile(int episode, char *datadirectory) {
|
||||
CExeFile::CExeFile(int episode, const std::string& datadirectory) {
|
||||
m_episode = episode;
|
||||
m_datadirectory = datadirectory;
|
||||
m_data = NULL;
|
||||
}
|
||||
|
||||
CExeFile::~CExeFile() {
|
||||
if(m_data) delete [] m_data;
|
||||
if(m_data) delete m_data;
|
||||
}
|
||||
|
||||
bool CExeFile::readData()
|
||||
{
|
||||
char filename[256];
|
||||
unsigned char *m_data_temp;
|
||||
|
||||
sprintf(filename, "data/%skeen%d.exe", m_datadirectory, m_episode);
|
||||
std::string filename = "data/" + m_datadirectory + "keen" + itoa(m_episode) + ".exe";
|
||||
|
||||
ifstream File(filename,ios::binary);
|
||||
std::ifstream File(filename.c_str(),ios::binary);
|
||||
|
||||
if(!File) return false;
|
||||
|
||||
@@ -55,7 +57,7 @@ bool CExeFile::readData()
|
||||
m_data = new unsigned char[m_datasize];
|
||||
memcpy(m_data, m_data_temp+512,m_datasize);
|
||||
}
|
||||
delete [] m_data_temp;
|
||||
delete m_data_temp;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
#define CEXEFILE_H_
|
||||
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
#include <string>
|
||||
|
||||
class CExeFile {
|
||||
public:
|
||||
CExeFile(int episode, char *datadirectory);
|
||||
CExeFile(int episode, const std::string& datadirectory);
|
||||
virtual ~CExeFile();
|
||||
|
||||
bool readData();
|
||||
@@ -27,10 +27,10 @@ private:
|
||||
int m_datasize;
|
||||
int m_episode;
|
||||
unsigned char *m_data;
|
||||
char *m_datadirectory;
|
||||
std::string m_datadirectory;
|
||||
|
||||
int get_bit(int *p_bit_count, unsigned char *fin, int *posin);
|
||||
int unlzexe(unsigned char *fin, vector<unsigned char> *outbuffer);
|
||||
int unlzexe(unsigned char *fin, std::vector<unsigned char> *outbuffer);
|
||||
};
|
||||
|
||||
#endif /* CEXEFILE_H_ */
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
|
||||
CPatcher::CPatcher(int episode, int version,unsigned char *data, char *datadir) {
|
||||
CPatcher::CPatcher(int episode, int version,unsigned char *data, const std::string& datadir) {
|
||||
m_episode = episode;
|
||||
m_version = version;
|
||||
m_data = data;
|
||||
strcpy(m_datadirectory, datadir);
|
||||
m_datadirectory = datadir;
|
||||
}
|
||||
|
||||
CPatcher::~CPatcher() {
|
||||
@@ -35,7 +35,7 @@ void CPatcher::patchMemory()
|
||||
|
||||
// change to the proper directory
|
||||
chdir("data");
|
||||
chdir(m_datadirectory);
|
||||
chdir(m_datadirectory.c_str());
|
||||
|
||||
// TODO: Extend this part further with more commands
|
||||
while(!m_TextList.empty())
|
||||
@@ -80,7 +80,6 @@ void CPatcher::patchMemory()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!m_TextList.empty())
|
||||
@@ -109,7 +108,7 @@ bool CPatcher::loadPatchfile()
|
||||
{
|
||||
bool ret = false;
|
||||
chdir("data");
|
||||
chdir(m_datadirectory);
|
||||
chdir(m_datadirectory.c_str());
|
||||
// Detect the patchfile
|
||||
DIR *dir = opendir(".");
|
||||
struct dirent *dp;
|
||||
@@ -121,8 +120,9 @@ bool CPatcher::loadPatchfile()
|
||||
if(strstr(dp->d_name,".pat"))
|
||||
{
|
||||
// The file was found! now read it into the memory!
|
||||
|
||||
char* buf;
|
||||
ifstream Patchfile(dp->d_name);
|
||||
std::ifstream Patchfile(dp->d_name);
|
||||
|
||||
while(!Patchfile.eof())
|
||||
{
|
||||
@@ -157,12 +157,12 @@ bool CPatcher::loadPatchfile()
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CPatcher::patchMemfromFile(const char *patch_file_name, int offset)
|
||||
void CPatcher::patchMemfromFile(const std::string& patch_file_name, int offset)
|
||||
{
|
||||
unsigned char *buf_to_patch;
|
||||
unsigned char byte;
|
||||
|
||||
ifstream Patchfile(patch_file_name, ios::binary);
|
||||
std::ifstream Patchfile(patch_file_name.c_str(), std::ios::binary);
|
||||
|
||||
if(!Patchfile) return;
|
||||
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
#define CPATCHER_H_
|
||||
|
||||
#include <list>
|
||||
using namespace std;
|
||||
#include <string>
|
||||
|
||||
class CPatcher {
|
||||
public:
|
||||
CPatcher(int episode, int version,unsigned char *data, char *datadir);
|
||||
CPatcher(int episode, int version,unsigned char *data, const std::string& datadir);
|
||||
virtual ~CPatcher();
|
||||
|
||||
void patchMemory();
|
||||
void patchMemfromFile(const char *patch_file_name, int offset);
|
||||
void patchMemfromFile(const std::string& patch_file_name, int offset);
|
||||
|
||||
private:
|
||||
|
||||
@@ -26,9 +26,9 @@ private:
|
||||
int m_episode;
|
||||
int m_version;
|
||||
unsigned char *m_data;
|
||||
char m_datadirectory[256];
|
||||
|
||||
list<char*> m_TextList;
|
||||
std::string m_datadirectory;
|
||||
|
||||
std::list<char*> m_TextList;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -12,24 +12,19 @@
|
||||
#include "../include/fileio.h"
|
||||
#include "../fileio/CExeFile.h"
|
||||
#include "../CLogFile.h"
|
||||
#include "../StringUtils.h"
|
||||
|
||||
int readStoryText(char **ptext, int episode, char *path)
|
||||
int readStoryText(char **ptext, int episode, const std::string& path)
|
||||
{
|
||||
std::string buf2 = formatPathString(path);
|
||||
std::string buf = buf2 + "storytxt.ck" + itoa(episode);
|
||||
|
||||
FILE *fp;
|
||||
char buf[256];
|
||||
char buf2[256];
|
||||
|
||||
memset(buf,0,256*sizeof(char));
|
||||
|
||||
formatPathString(buf2,path);
|
||||
|
||||
sprintf(buf,"%sstorytxt.ck%d",buf2,episode);
|
||||
|
||||
if((fp=fopen(buf,"rt"))==NULL)
|
||||
if((fp=fopen(buf.c_str(),"rt"))==NULL)
|
||||
{
|
||||
sprintf(buf,"%skeen%d.exe",buf2,episode);
|
||||
buf = buf2 + "keen" + itoa(episode) + ".exe";
|
||||
|
||||
if((fp=fopen(buf,"rb"))!=NULL)
|
||||
if((fp=fopen(buf.c_str(),"rb"))!=NULL)
|
||||
{
|
||||
unsigned char *filebuf;
|
||||
int startflag=0, endflag=0; // where story begins and ends!
|
||||
|
||||
Reference in New Issue
Block a user