integrated searchpath system
git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@149 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
#include "keen.h"
|
||||
#include "keenext.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include "FindFile.h"
|
||||
#include "CLogFile.h"
|
||||
//#include "vorticon/CEGAGraphics.h"
|
||||
|
||||
@@ -77,7 +77,7 @@ char CLatch::loadHeader(int episode, const char *path)
|
||||
|
||||
delete EGAGraphics;*/
|
||||
|
||||
headfile = fopen(fname.c_str(), "rb");
|
||||
headfile = OpenGameFile(fname.c_str(), "rb");
|
||||
if (!headfile)
|
||||
{
|
||||
g_pLogFile->ftextOut("latch_loadheader(): unable to open '%s'.<br>", fname.c_str());
|
||||
@@ -217,7 +217,7 @@ unsigned long RawDataSize;
|
||||
|
||||
g_pLogFile->ftextOut("latch_loadlatch(): Opening file '%s'.<br>", fname.c_str());
|
||||
|
||||
latchfile = fopen(fname.c_str(), "rb");
|
||||
latchfile = OpenGameFile(fname.c_str(), "rb");
|
||||
if (!latchfile)
|
||||
{
|
||||
g_pLogFile->ftextOut("latch_loadlatch(): Unable to open '%s'!<br>", fname.c_str());
|
||||
@@ -426,7 +426,7 @@ CPlanes *Planes;
|
||||
|
||||
g_pLogFile->ftextOut("latch_loadsprites(): Opening file '%s'.<br>", fname.c_str());
|
||||
|
||||
spritfile = fopen(fname.c_str(), "rb");
|
||||
spritfile = OpenGameFile(fname.c_str(), "rb");
|
||||
if (!spritfile)
|
||||
{
|
||||
g_pLogFile->ftextOut("latch_loadsprites(): Unable to open '%s'!<br>", fname.c_str());
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <string.h>
|
||||
#include "CLogFile.h"
|
||||
#include <fstream>
|
||||
#include "FindFile.h"
|
||||
|
||||
CLogFile::CLogFile() {}
|
||||
|
||||
@@ -22,7 +23,7 @@ CLogFile::~CLogFile() {
|
||||
void CLogFile::CreateLogfile(const char *LogName)
|
||||
{
|
||||
// Open and empty the log file
|
||||
m_Logfile = fopen(LogName, "wt");
|
||||
m_Logfile = OpenGameFile(LogName, "wt");
|
||||
|
||||
// Write the head
|
||||
textOut("<html><head><title>LogFile</title></head>");
|
||||
@@ -50,7 +51,7 @@ void CLogFile::CreateLogfile(const char *LogName)
|
||||
textOut("Send E-Mail to me</a><br><br>");
|
||||
|
||||
fclose(m_Logfile);
|
||||
m_Logfile = fopen(LogName, "at");
|
||||
m_Logfile = OpenGameFile(LogName, "at");
|
||||
}
|
||||
|
||||
// Function for writing the topic
|
||||
|
||||
@@ -204,7 +204,7 @@ static bool GetString(const std::string& filename, const std::string& section, c
|
||||
return false;
|
||||
|
||||
if(abs_fn) {
|
||||
config = fopen(filename.c_str(), "rt");
|
||||
config = OpenGameFile(filename.c_str(), "rt");
|
||||
} else
|
||||
config = OpenGameFile(filename,"rt");
|
||||
if(!config)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <dirent.h>
|
||||
#include "StringUtils.h"
|
||||
#include "Debug.h"
|
||||
#include "FindFile.h"
|
||||
|
||||
extern CPlayer *Player;
|
||||
|
||||
@@ -147,7 +148,7 @@ short checkConsistencyofGameData(stGameData *p_GameData)
|
||||
buf += "/";
|
||||
buf += p_GameData->FileList[c];
|
||||
|
||||
if((fp = fopen(buf.c_str(),"r")) != NULL)
|
||||
if((fp = OpenGameFile(buf.c_str(),"r")) != NULL)
|
||||
{
|
||||
fclose(fp);
|
||||
}
|
||||
@@ -538,7 +539,7 @@ int resetcnt, resetpt;
|
||||
|
||||
std::string buffer = formatPathString(path);
|
||||
std::string fname = buffer + filename;
|
||||
fp = fopen(fname.c_str(), "rb");
|
||||
fp = OpenGameFile(fname.c_str(), "rb");
|
||||
if (!fp)
|
||||
{
|
||||
// only record this error message on build platforms that log errors
|
||||
@@ -632,7 +633,7 @@ int resetcnt, resetpt;
|
||||
// HQ Sounds. Load Music for a level if you have HQP
|
||||
g_pMusicPlayer->stop();
|
||||
|
||||
if((fp=fopen("data/hqp/music/table.cfg","rt")) != NULL)
|
||||
if((fp=OpenGameFile("data/hqp/music/table.cfg","rt")) != NULL)
|
||||
{
|
||||
static const int MAX_STRING_LENGTH = 256;
|
||||
char buf1[MAX_STRING_LENGTH];
|
||||
@@ -770,7 +771,7 @@ char highlight;
|
||||
#define STSTATE_READATTR 3
|
||||
|
||||
g_pLogFile->ftextOut("loadstrings(): Opening string file '%s'.<br>", fname.c_str());
|
||||
fp = fopen(fname.c_str(), "rb");
|
||||
fp = OpenGameFile(fname.c_str(), "rb");
|
||||
if (!fp)
|
||||
{
|
||||
g_pLogFile->ftextOut("loadstrings(): String file unable to open.<br>");
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "../CLogFile.h"
|
||||
#include "../StringUtils.h"
|
||||
#include "../sdl/CSettings.h"
|
||||
#include "../FindFile.h"
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
@@ -41,7 +42,7 @@ bool CParser::loadParseFile() // Open, read the list and close the file
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if((fp=fopen(m_configfile.c_str(),"rt")))
|
||||
if((fp=OpenGameFile(m_configfile.c_str(),"rt")))
|
||||
{
|
||||
while(!feof(fp))
|
||||
{
|
||||
@@ -62,7 +63,7 @@ bool CParser::saveParseFile() // open, write on the file and close
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if((fp=fopen(m_configfile.c_str(),"wt")))
|
||||
if((fp=OpenGameFile(m_configfile.c_str(),"wt")))
|
||||
{
|
||||
for(std::list<std::string>::iterator i=m_filebuffer.begin() ; i != m_filebuffer.end() ; ++i )
|
||||
fprintf(fp,"%s\n",i->c_str());
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
#include "CTileLoader.h"
|
||||
#include "../CLogFile.h"
|
||||
|
||||
#include "../StringUtils.h"
|
||||
#include "../FindFile.h"
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include "../StringUtils.h"
|
||||
|
||||
extern stTile tiles[MAX_TILES+1];
|
||||
|
||||
@@ -153,7 +153,7 @@ bool CTileLoader::load()
|
||||
fname = "ep" + itoa(m_episode) + "attr.dat";
|
||||
|
||||
FILE *fp;
|
||||
fp = fopen(fname.c_str(), "rb");
|
||||
fp = OpenGameFile(fname.c_str(), "rb");
|
||||
if (!fp)
|
||||
{
|
||||
g_pLogFile->textOut(RED,"TileLoader: Cannot open tile attribute file!<br>");
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "../fileio/CExeFile.h"
|
||||
#include "../CLogFile.h"
|
||||
#include "../StringUtils.h"
|
||||
#include "../FindFile.h"
|
||||
|
||||
|
||||
int readStoryText(char **ptext, int episode, const std::string& path)
|
||||
{
|
||||
@@ -20,11 +22,11 @@ int readStoryText(char **ptext, int episode, const std::string& path)
|
||||
std::string buf = buf2 + "storytxt.ck" + itoa(episode);
|
||||
|
||||
FILE *fp;
|
||||
if((fp=fopen(buf.c_str(),"rt"))==NULL)
|
||||
if((fp=OpenGameFile(buf.c_str(),"rt"))==NULL)
|
||||
{
|
||||
buf = buf2 + "keen" + itoa(episode) + ".exe";
|
||||
|
||||
if((fp=fopen(buf.c_str(),"rb"))!=NULL)
|
||||
if((fp=OpenGameFile(buf.c_str(),"rb"))!=NULL)
|
||||
{
|
||||
unsigned char *filebuf;
|
||||
int startflag=0, endflag=0; // where story begins and ends!
|
||||
@@ -84,5 +86,7 @@ int readStoryText(char **ptext, int episode, const std::string& path)
|
||||
|
||||
return filesize;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "keen.h"
|
||||
#include "include/fileio.h"
|
||||
#include "CGraphics.h"
|
||||
#include "FindFile.h"
|
||||
|
||||
int finale_x;
|
||||
int finale_y;
|
||||
@@ -84,7 +85,7 @@ int i;
|
||||
map_unregister_all_animtiles();
|
||||
|
||||
std::string fname = buffer + filename;
|
||||
fp = fopen(fname.c_str(), "rb");
|
||||
fp = OpenGameFile(fname.c_str(), "rb");
|
||||
if (!fp)
|
||||
{
|
||||
crashflag = 1;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
#include "CHQBitmap.h"
|
||||
#include "../CLogFile.h"
|
||||
#include <stdlib.h>
|
||||
#include "../FindFile.h"
|
||||
#include <cstdlib>
|
||||
|
||||
CHQBitmap::CHQBitmap(SDL_Rect screenrect) {
|
||||
m_scrimg = NULL;
|
||||
@@ -24,10 +25,14 @@ CHQBitmap::~CHQBitmap() {
|
||||
|
||||
bool CHQBitmap::loadImage(const std::string& pFilename, int wsize, int hsize)
|
||||
{
|
||||
SDL_Surface *BitmapSurface = SDL_LoadBMP(pFilename.c_str());
|
||||
|
||||
m_active = false;
|
||||
|
||||
std::string fullfname = GetFullFileName(pFilename);
|
||||
if(fullfname.size() == 0)
|
||||
return false;
|
||||
|
||||
SDL_Surface *BitmapSurface = SDL_LoadBMP(Utf8ToSystemNative(fullfname).c_str());
|
||||
|
||||
if(BitmapSurface)
|
||||
{
|
||||
if((m_scrimg = SDL_DisplayFormat(BitmapSurface)))
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "../hqp/hq_sound.h"
|
||||
#include "../CLogFile.h"
|
||||
#include "../include/vorbis/oggsupport.h"
|
||||
#include "../FindFile.h"
|
||||
|
||||
CMusic::CMusic() {
|
||||
playmode = PLAY_MODE_STOP;
|
||||
@@ -37,7 +38,7 @@ int CMusic::load(SDL_AudioSpec AudioSpec, char *musicfile)
|
||||
pOggAudio.sound_pos=0;
|
||||
|
||||
FILE *fp;
|
||||
if((fp = fopen(musicfile,"rb")) == NULL)
|
||||
if((fp = OpenGameFile(musicfile,"rb")) == NULL)
|
||||
{
|
||||
g_pLogFile->textOut(PURPLE,"Music Driver(): \"%s\". File does not exist!<br>", musicfile);
|
||||
return -1;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "../sdl/CVideoDriver.h"
|
||||
#include "../include/vorbis/oggsupport.h"
|
||||
#include "../CLogFile.h"
|
||||
#include "../FindFile.h"
|
||||
|
||||
short HQSndDrv_Load(SDL_AudioSpec *AudioSpec, stHQSound *psound, const std::string& soundfile)
|
||||
{
|
||||
@@ -21,7 +22,7 @@ short HQSndDrv_Load(SDL_AudioSpec *AudioSpec, stHQSound *psound, const std::stri
|
||||
FILE *fp;
|
||||
|
||||
buf = "data/hqp/snd/" + soundfile + ".OGG"; // Start with OGG
|
||||
if((fp = fopen(buf.c_str(),"rb")) != NULL)
|
||||
if((fp = OpenGameFile(buf.c_str(),"rb")) != NULL)
|
||||
{
|
||||
#ifdef BUILD_WITH_OGG
|
||||
if(openOGGSound(fp, &AudioFileSpec, AudioSpec->format, psound) != 0)
|
||||
@@ -52,8 +53,12 @@ short HQSndDrv_Load(SDL_AudioSpec *AudioSpec, stHQSound *psound, const std::stri
|
||||
{
|
||||
buf = "data/hqp/snd/" + soundfile + ".WAV";
|
||||
|
||||
// Check, if it is a wav file or go back to classic sounds
|
||||
if (SDL_LoadWAV (buf.c_str(), &AudioFileSpec, &(psound->sound_buffer), &(psound->sound_len)) == NULL)
|
||||
std::string fullfname = GetFullFileName(buf);
|
||||
if(fullfname.size() == 0)
|
||||
return 1;
|
||||
|
||||
// Check, if it is a wav file or go back to classic sounds
|
||||
if (SDL_LoadWAV (Utf8ToSystemNative(fullfname).c_str(), &AudioFileSpec, &(psound->sound_buffer), &(psound->sound_len)) == NULL)
|
||||
{
|
||||
g_pLogFile->textOut(PURPLE,"Wave file could not be opened: \"%s\". Trying to load the classical sounds<br>", buf.c_str());
|
||||
return 1;
|
||||
|
||||
@@ -510,7 +510,7 @@ char SaveOptions[NUM_OPTIONS];
|
||||
|
||||
// open the demo file
|
||||
sprintf(filename, "ep%ddemo%d.dat", p_levelcontrol->episode, demonum);
|
||||
demofile = fopen(filename, "rb");
|
||||
demofile = OpenGameFile(filename, "rb");
|
||||
if (!demofile)
|
||||
{
|
||||
return DEMO_RESULT_FILE_BAD;
|
||||
|
||||
16
src/misc.cpp
16
src/misc.cpp
@@ -25,6 +25,8 @@
|
||||
#include "CLogFile.h"
|
||||
#include "CGraphics.h"
|
||||
#include "StringUtils.h"
|
||||
#include "FindFile.h"
|
||||
|
||||
|
||||
void banner(void)
|
||||
{
|
||||
@@ -625,7 +627,7 @@ void showinventory(int p, stCloneKeenPlus *pCKP)
|
||||
FILE *fp;
|
||||
int x,y;
|
||||
|
||||
fp = fopen(visiblefile, "wb");
|
||||
fp = OpenGameFile(visiblefile, "wb");
|
||||
if (!fp) return;<
|
||||
|
||||
for(y=0;y<200;y++)
|
||||
@@ -634,7 +636,7 @@ int x,y;
|
||||
|
||||
fclose(fp);
|
||||
|
||||
fp = fopen(scrollfile, "wb");
|
||||
fp = OpenGameFile(scrollfile, "wb");
|
||||
if (!fp) return;
|
||||
|
||||
for(y=0;y<512;y++)
|
||||
@@ -733,7 +735,7 @@ void game_save(char *fname, stCloneKeenPlus *pCKP)
|
||||
unsigned int i;
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen(fname, "wb");
|
||||
fp = OpenGameFile(fname, "wb");
|
||||
|
||||
// save the header/version check
|
||||
fputc('S', fp);
|
||||
@@ -766,7 +768,7 @@ int savegameiswm(char *fname)
|
||||
FILE *fp;
|
||||
int i;
|
||||
|
||||
fp = fopen(fname, "rb");
|
||||
fp = OpenGameFile(fname, "rb");
|
||||
if (!fp) return 0; // file didn't exist, don't try to go further
|
||||
|
||||
fgetc(fp); fgetc(fp);
|
||||
@@ -785,7 +787,7 @@ long i;
|
||||
unsigned long scrx;
|
||||
int scry;
|
||||
|
||||
fp = fopen(fname, "rb");
|
||||
fp = OpenGameFile(fname, "rb");
|
||||
if (!fp) return 1;
|
||||
|
||||
// do the header and version check
|
||||
@@ -828,7 +830,7 @@ unsigned int scry;
|
||||
stLevelControl *p_levelcontrol;
|
||||
p_levelcontrol = &(pCKP->Control.levelcontrol);
|
||||
|
||||
fp = fopen(fname, "rb");
|
||||
fp = OpenGameFile(fname, "rb");
|
||||
if (!fp) return 1;
|
||||
|
||||
// do the header and version check
|
||||
@@ -936,7 +938,7 @@ top: ;
|
||||
fname += saveslot+'0';
|
||||
fname += ".dat";
|
||||
slotexists = 0;
|
||||
fp = fopen(fname.c_str(), "rb");
|
||||
fp = OpenGameFile(fname.c_str(), "rb");
|
||||
if (fp)
|
||||
{
|
||||
fclose(fp);
|
||||
|
||||
@@ -9,9 +9,10 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CInput.h"
|
||||
#include "../CLogFile.h"
|
||||
#include "CVideoDriver.h"
|
||||
#include "CTimer.h"
|
||||
#include "../CLogFile.h"
|
||||
#include "../FindFile.h"
|
||||
|
||||
#ifdef WIZ
|
||||
#include "gp2x.h"
|
||||
@@ -89,7 +90,7 @@ void CInput::resetControls() {
|
||||
short CInput::loadControlconfig(void)
|
||||
{
|
||||
FILE *fp;
|
||||
if((fp=fopen("controls.dat","rb")) != NULL)
|
||||
if((fp=OpenGameFile("controls.dat","rb")) != NULL)
|
||||
{
|
||||
if(fread(InputCommand, sizeof(stInputCommand),NUMBER_OF_COMMANDS*NUM_INPUTS, fp) == 0 )
|
||||
{
|
||||
@@ -105,7 +106,7 @@ short CInput::loadControlconfig(void)
|
||||
short CInput::saveControlconfig(void)
|
||||
{
|
||||
FILE *fp;
|
||||
if((fp=fopen("controls.dat","wb")) != NULL)
|
||||
if((fp=OpenGameFile("controls.dat","wb")) != NULL)
|
||||
{
|
||||
fwrite(InputCommand, sizeof(stInputCommand),NUMBER_OF_COMMANDS*NUM_INPUTS, fp);
|
||||
fclose(fp);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "../../vorticon/sounds.h"
|
||||
#include "../../fileio/CExeFile.h"
|
||||
#include "../../StringUtils.h"
|
||||
#include "../../FindFile.h"
|
||||
|
||||
#define SAFE_DELETE_ARRAY(x) if(x) delete[] x; x=NULL
|
||||
|
||||
@@ -323,7 +324,7 @@ bool CSound::loadSoundData(unsigned short Episode, const std::string& DataDirect
|
||||
|
||||
FILE *p_file;
|
||||
|
||||
if( ( p_file = fopen(soundfile.c_str(),"rb") ) == NULL )
|
||||
if( ( p_file = OpenGameFile(soundfile.c_str(),"rb") ) == NULL )
|
||||
{
|
||||
|
||||
buf = "keen" + itoa(Episode) + ".exe";
|
||||
@@ -444,7 +445,7 @@ char CSound::extractOfExeFile(const std::string& inputpath, int episode)
|
||||
if( *(buffer.end()) != '/') buffer += "/";
|
||||
buffer += outputfname;
|
||||
|
||||
if(!(fout = fopen(buffer.c_str(),"wb"))) ret = 1;
|
||||
if(!(fout = OpenGameFile(buffer.c_str(),"wb"))) ret = 1;
|
||||
else
|
||||
{
|
||||
fwrite( ExeFile->getData()+sounds_start, 1, (sounds_end-sounds_start), fout);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "CSoundSlot.h"
|
||||
#include "../../CLogFile.h"
|
||||
#include "../../fileio.h"
|
||||
#include "../../FindFile.h"
|
||||
|
||||
CSoundSlot::CSoundSlot() {
|
||||
m_priority = 0;
|
||||
@@ -57,7 +58,7 @@ bool CSoundSlot::loadSound(const std::string& fname, const std::string& searchna
|
||||
for(i=0;i<12;i++)
|
||||
name[i] = 0;
|
||||
|
||||
fp = fopen(fname.c_str(), "rb");
|
||||
fp = OpenGameFile(fname.c_str(), "rb");
|
||||
if (!fp)
|
||||
{
|
||||
g_pLogFile->ftextOut("loadSound : Sounds file '%s' unopenable attempting load of '%s'<br>", fname.c_str(), searchname.c_str());
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "../funcdefs.h"
|
||||
#include "../keen.h"
|
||||
#include "../keenext.h"
|
||||
#include "../FindFile.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -69,7 +70,7 @@ bool CEGALatch::loadData(const std::string& filename, bool compresseddata)
|
||||
{
|
||||
char *RawData;
|
||||
|
||||
FILE* latchfile = fopen(filename.c_str(),"rb");
|
||||
FILE* latchfile = OpenGameFile(filename.c_str(),"rb");
|
||||
|
||||
if(!latchfile)
|
||||
return false;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "CEGASprit.h"
|
||||
#include "CPlanes.h"
|
||||
#include "../keen.h"
|
||||
#include "../FindFile.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -75,7 +76,7 @@ bool CEGASprit::loadData(const std::string& filename, bool compresseddata)
|
||||
{
|
||||
char *RawData;
|
||||
|
||||
FILE* latchfile = fopen(filename.c_str(),"rb");
|
||||
FILE* latchfile = OpenGameFile(filename.c_str(),"rb");
|
||||
|
||||
if(!latchfile)
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user