1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-17 20:09:35 +00:00

Revert "added partial VFS support - enough to read static data from any source"

This reverts commit fa3e9e7329.
This commit is contained in:
fgenesis 2011-09-15 19:18:53 +02:00
commit 56c6833220
56 changed files with 608 additions and 4023 deletions

View file

@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ScriptedEntity.h"
#include "AutoMap.h"
#include "GridRender.h"
#include <VFSFile.h>
#include "tinyxml.h"
@ -871,7 +870,7 @@ void Continuity::loadTreasureData()
std::string line, gfx;
int num, use;
float sz;
VFSTextStdStreamIn in2("data/treasures.txt");
std::ifstream in2("data/treasures.txt");
while (std::getline(in2, line))
{
std::istringstream is(line);
@ -904,7 +903,7 @@ void Continuity::loadIngredientData()
/*
int num;
VFSTextStreamIn in2("data/ingredientdescriptions.txt");
std::ifstream in2("data/ingredientdescriptions.txt");
while (std::getline(in2, line))
{
IngredientDescription desc;
@ -917,7 +916,7 @@ void Continuity::loadIngredientData()
clearIngredientData();
recipes.clear();
VFSTextStdStreamIn in("data/ingredients.txt");
std::ifstream in("data/ingredients.txt");
bool recipes = false;
while (std::getline(in, line))
@ -1242,7 +1241,7 @@ void Continuity::loadEatBank()
{
eats.clear();
VFSTextStdStreamIn inf("data/eats.txt");
std::ifstream inf("data/eats.txt");
EatData curData;
std::string read;
@ -2182,7 +2181,7 @@ void Continuity::setActivePet(int flag)
void Continuity::loadPetData()
{
petData.clear();
VFSTextStdStreamIn in("data/pets.txt");
std::ifstream in("data/pets.txt");
std::string read;
while (std::getline(in, read))
{
@ -3260,7 +3259,7 @@ void Continuity::reset()
health = maxHealth;
speedTypes.clear();
VFSTextStreamIn inFile("data/speedtypes.txt");
std::ifstream inFile("data/speedtypes.txt");
int n, spd;
while (inFile >> n)
{

View file

@ -172,6 +172,28 @@ DSQ::DSQ(std::string fileSystem) : Core(fileSystem, LR_MAX, APPNAME, PARTICLE_AM
almb = armb = 0;
bar_left = bar_right = bar_up = bar_down = barFade_left = barFade_right = 0;
// do copy stuff
#ifdef BBGE_BUILD_UNIX
std::string fn;
fn = getPreferencesFolder() + "/" + userSettingsFilename;
if (!exists(fn))
Linux_CopyTree(core->adjustFilenameCase(userSettingsFilename).c_str(), core->adjustFilenameCase(fn).c_str());
fn = getUserDataFolder() + "/_mods";
if (!exists(fn))
Linux_CopyTree(core->adjustFilenameCase("_mods").c_str(), core->adjustFilenameCase(fn).c_str());
#endif
#if defined(BBGE_BUILD_UNIX)
std::string p1 = getUserDataFolder();
std::string p2 = getUserDataFolder() + "/save";
mkdir(p1.c_str(), S_IRWXU);
mkdir(p2.c_str(), S_IRWXU);
//debugLogPath = ;
#endif
difficulty = DIFF_NORMAL;
/*
@ -209,6 +231,9 @@ DSQ::DSQ(std::string fileSystem) : Core(fileSystem, LR_MAX, APPNAME, PARTICLE_AM
achievement_box = 0;
#endif
vars = &v;
v.load();
#ifdef AQUARIA_BUILD_CONSOLE
console = 0;
#endif
@ -230,6 +255,25 @@ DSQ::DSQ(std::string fileSystem) : Core(fileSystem, LR_MAX, APPNAME, PARTICLE_AM
for (int i = 0; i < 16; i++)
firstElementOnLayer[i] = 0;
addStateInstance(game = new Game);
addStateInstance(new GameOver);
#ifdef AQUARIA_BUILD_SCENEEDITOR
addStateInstance(new AnimationEditor);
#endif
addStateInstance(new Intro2);
addStateInstance(new BitBlotLogo);
#ifdef AQUARIA_BUILD_SCENEEDITOR
addStateInstance(new ParticleEditor);
#endif
addStateInstance(new Credits);
addStateInstance(new Intro);
addStateInstance(new Nag);
//addStateInstance(new Logo);
//addStateInstance(new SCLogo);
//addStateInstance(new IntroText);
//addStateInstance(new Intro);
//stream = 0;
}
@ -299,7 +343,7 @@ void DSQ::newGame()
void DSQ::loadElementEffects()
{
VFSTextStdStreamIn inFile("data/elementeffects.txt");
std::ifstream inFile("data/elementeffects.txt");
elementEffects.clear();
std::string line;
while (std::getline(inFile, line))
@ -871,55 +915,6 @@ static bool sdlVideoModeOK(const int w, const int h, const int bpp)
void DSQ::init()
{
setupVFS(getenv("AQUARIA_DATA_PATH"));
// FG: TODO: do the moving & copying below with VFS code, and leave the original file system alone!
// do copy stuff
#ifdef BBGE_BUILD_UNIX
std::string fn;
fn = getPreferencesFolder() + "/" + userSettingsFilename;
if (!exists(fn))
Linux_CopyTree(core->adjustFilenameCase(userSettingsFilename).c_str(), core->adjustFilenameCase(fn).c_str());
fn = getUserDataFolder() + "/_mods";
if (!exists(fn))
Linux_CopyTree(core->adjustFilenameCase("_mods").c_str(), core->adjustFilenameCase(fn).c_str());
#endif
#if defined(BBGE_BUILD_UNIX)
std::string p1 = getUserDataFolder();
std::string p2 = getUserDataFolder() + "/save";
mkdir(p1.c_str(), S_IRWXU);
mkdir(p2.c_str(), S_IRWXU);
//debugLogPath = ;
#endif
vars = &v;
v.load();
addStateInstance(game = new Game);
addStateInstance(new GameOver);
#ifdef AQUARIA_BUILD_SCENEEDITOR
addStateInstance(new AnimationEditor);
#endif
addStateInstance(new Intro2);
addStateInstance(new BitBlotLogo);
#ifdef AQUARIA_BUILD_SCENEEDITOR
addStateInstance(new ParticleEditor);
#endif
addStateInstance(new Credits);
addStateInstance(new Intro);
addStateInstance(new Nag);
//addStateInstance(new Logo);
//addStateInstance(new SCLogo);
//addStateInstance(new IntroText);
//addStateInstance(new Intro);
core->settings.runInBackground = true;
weird = 0;
@ -2170,13 +2165,6 @@ ModEntry* DSQ::getSelectedModEntry()
void DSQ::loadMods()
{
modEntries.clear();
// force VFS to reload _mods dir
if(ttvfs::VFSDir *vd = vfs.GetDir("_mods"))
{
vd->load();
vfs.Reload();
}
forEachFile(mod.getBaseModPath(), ".xml", loadModsCallback, 0);
selectedMod = 0;
@ -3687,7 +3675,7 @@ void DSQ::onPlayVoice()
if (user.audio.subtitles)
{
std::string fn = "scripts/vox/" + sound->lastVoice + ".txt";
VFSTextStdStreamIn inf(fn.c_str());
std::ifstream inf(fn.c_str());
if (inf.is_open())
{
std::string dia;
@ -3780,6 +3768,31 @@ std::string DSQ::getDialogueFilename(const std::string &f)
return "dialogue/" + languagePack + "/" + f + ".txt";
}
void DSQ::jumpToSection(std::ifstream &inFile, const std::string &section)
{
if (section.empty()) return;
std::string file = dsq->getDialogueFilename(dialogueFile);
if (!exists(file))
{
debugLog("Could not find dialogue [" + file + "]");
return;
}
inFile.open(core->adjustFilenameCase(file).c_str());
std::string s;
while (std::getline(inFile, s))
{
if (!s.empty())
{
if (s.find("[")!=std::string::npos && s.find(section) != std::string::npos)
{
return;
}
}
}
debugLog("could not find section [" + section + "]");
}
void DSQ::runGesture(const std::string &line)
{
std::istringstream is(line);

View file

@ -1395,6 +1395,8 @@ public:
void takeScreenshot();
void takeScreenshotKey();
void jumpToSection(std::ifstream &inFile, const std::string &section);
PathFinding pathFinding;
void runGesture(const std::string &line);
void generateCollisionMask(RenderObject *r);

View file

@ -31,7 +31,7 @@ Emote::Emote()
void Emote::load(const std::string &file)
{
emotes.clear();
VFSTextStdStreamIn in(file.c_str());
std::ifstream in(file.c_str());
std::string line;
while (std::getline(in, line))

View file

@ -39,7 +39,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "StatsAndAchievements.h"
#include "ToolTip.h"
#include <VFSFile.h>
std::vector<std::string> allowedMaps;
@ -254,7 +253,7 @@ void FoodHolder::setIngredient(IngredientData *i, bool effects)
if (effects)
{
core->sound->playSfx("Wok");
ing->scale.ensureData();
ing->scale.data->path.clear();
ing->scale.data->path.addPathNode(Vector(1,1),0);
@ -2517,7 +2516,7 @@ void Game::loadEntityTypeList()
// and group list!
{
entityTypeList.clear();
VFSTextStdStreamIn in("scripts/entities/entities.txt");
std::ifstream in("scripts/entities/entities.txt");
std::string line;
if(!in)
{
@ -2550,7 +2549,7 @@ void Game::loadEntityTypeList()
fn = dsq->mod.getPath() + "entitygroups.txt";
}
VFSTextStdStreamIn in2(fn.c_str());
std::ifstream in2(fn.c_str());
int curGroup=0;
while (std::getline(in2, line))
@ -5404,7 +5403,7 @@ void Game::findMaxCameraValues()
void Game::setWarpAreaSceneName(WarpArea &warpArea)
{
VFSTextStdStreamIn in("data/warpAreas.txt");
std::ifstream in("data/warpAreas.txt");
std::string color, area1, dir1, area2, dir2;
std::string line;
while (std::getline(in, line))
@ -7934,9 +7933,9 @@ void Game::onFlipTest()
void appendFileToString(std::string &string, const std::string &file)
{
VFSTextStdStreamIn inf(file.c_str());
std::ifstream inf(file.c_str());
if (inf)
if (inf.is_open())
{
while (!inf.eof())
{
@ -10946,7 +10945,7 @@ void Game::loadElementTemplates(std::string pack)
tileCache.clean();
}
VFSTextStdStreamIn in(fn.c_str());
std::ifstream in(fn.c_str());
std::string line;
while (std::getline(in, line))
{

View file

@ -24,13 +24,12 @@ GameplayVariables *vars = 0;
void GameplayVariables::load()
{
VFSTextStreamIn inFile("data/variables.txt");
std::ifstream inFile("data/variables.txt");
if(!inFile)
{
core->messageBox("error", "Variables data not found! Aborting...");
exit(1);
}
std::string s;
inFile >> s >> maxSlowSwimSpeed;
inFile >> s >> maxSwimSpeed;

View file

@ -41,10 +41,10 @@ static void StartAQConfig()
{
#if defined(BBGE_BUILD_WINDOWS)
#if defined(AQUARIA_DEMO) || defined(AQUARIA_FULL)
if (!exists("ran", false, true))
if (!exists("ran", false))
{
MakeRan();
if(exists("aqconfig.exe", false, true))
if(exists("aqconfig.exe", false))
{
ShellExecute(NULL, "open", "aqconfig.exe", NULL, NULL, SW_SHOWNORMAL);
exit(0);
@ -58,7 +58,7 @@ static void StartAQConfig()
static void CheckConfig(void)
{
#ifdef BBGE_BUILD_WINDOWS
bool hasCfg = exists("usersettings.xml", false, true);
bool hasCfg = exists("usersettings.xml", false);
if(!hasCfg)
StartAQConfig();
#endif

View file

@ -529,7 +529,7 @@ luaFunc(indexWarnGlobal)
std::ostringstream os;
os << "WARNING: " << ar.short_src << ":" << ar.currentline
<< ": script tried to get/call undefined global variable "
<< varname;
<< lua_tostring(L, -2);
errorLog(os.str());
}
@ -614,19 +614,7 @@ luaFunc(dofile_caseinsensitive)
// This is Lua's dofile(), with some tweaks. --ryan.
std::string fname(core->adjustFilenameCase(luaL_checkstring(L, 1)));
int n = lua_gettop(L);
int result = -1;
ttvfs::VFSFile *vf = core->vfs.GetFile(fname.c_str());
if(vf)
{
const char *buf = (const char*)vf->getBuf();
result = luaL_loadbuffer(L, buf, vf->size(), fname.c_str());
vf->dropBuf(true);
}
if(result)
lua_error(L);
if (luaL_loadfile(L, fname.c_str()) != 0) lua_error(L);
lua_call(L, 0, LUA_MULTRET);
return lua_gettop(L) - n;
}
@ -8953,20 +8941,11 @@ Script *ScriptInterface::openScript(const std::string &file)
lua_getglobal(baseState, "v");
// Load the file itself. This leaves the Lua chunk on the stack.
int result = -1;
ttvfs::VFSFile *vf = core->vfs.GetFile(realFile.c_str());
if(vf)
{
const char *buf = (const char*)vf->getBuf();
result = luaL_loadbuffer(baseState, buf, vf->size(), realFile.c_str());
vf->dropBuf(true);
}
int result = luaL_loadfile(baseState, realFile.c_str());
if (result != 0)
{
const char *msg = lua_tostring(baseState, -1);
debugLog("Error loading script [" + realFile + "]: " + (msg ? msg : "unk error")); // loading from buffer does not push a string on the stack
//lua_pop(baseState, 2);
debugLog("Error loading script [" + realFile + "]: " + lua_tostring(baseState, -1));
lua_pop(baseState, 2);
return NULL;
}

View file

@ -25,8 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../BBGE/MathFunctions.h"
#include <VFSFile.h>
Shot::Shots Shot::shots;
Shot::ShotBank Shot::shotBank;
@ -66,7 +64,7 @@ ShotData::ShotData()
ignoreShield = false;
}
template <typename T> void readEquals2(T &in)
void readEquals2(std::ifstream &in)
{
std::string temp;
in >> temp;
@ -95,7 +93,7 @@ void ShotData::bankLoad(const std::string &file, const std::string &path)
}
debugLog(usef);
VFSTextStreamIn inf(usef.c_str());
std::ifstream inf(usef.c_str());
std::string token;
while (inf >> token)
{

View file

@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Game.h"
#include "Avatar.h"
#include "StatsAndAchievements.h"
#include <VFSFile.h>
#ifndef ARRAYSIZE
#define ARRAYSIZE(x) (sizeof (x) / sizeof ((x)[0]))
@ -172,50 +171,46 @@ void StatsAndAchievements::RunFrame()
requestedStats = true;
const size_t max_achievements = ARRAYSIZE(g_rgAchievements);
FILE *io = NULL;
char *achtxt = "";
VFSTextStdStreamIn in("data/achievements.txt");
std::string line;
// Get generic achievement data...
io = fopen("data/achievements.txt", "r");
char line[1024];
for (size_t i = 0; i < max_achievements; i++)
{
if (!io || (fgets(line, sizeof (line), io) == NULL))
snprintf(line, sizeof (line), "Achievement #%d", (int) i);
else
{
for (char *ptr = (line + strlen(line)) - 1; (ptr >= line) && ((*ptr == '\r') || (*ptr == '\n')); ptr--)
*ptr = '\0';
}
line[sizeof (g_rgAchievements[i].name) - 1] = '\0'; // just in case.
strcpy(g_rgAchievements[i].name, line);
// HACK: prepare fields in case data are missing
for(int i = 0; i < max_achievements; ++i)
{
g_rgAchievements[i].iconImage = 0;
g_rgAchievements[i].name[sizeof (g_rgAchievements[i].name) - 1] = '\0'; // just in case.
g_rgAchievements[i].desc[sizeof (g_rgAchievements[i].desc) - 1] = '\0';
snprintf(g_rgAchievements[i].name, sizeof(g_rgAchievements[i].name), "Achievement #%d", i);
snprintf(g_rgAchievements[i].desc, sizeof(g_rgAchievements[i].desc), "[Description of Achievement #%d is missing!]", i);
}
if (!io || (fgets(line, sizeof (line), io) == NULL))
snprintf(line, sizeof (line), "[Description of Achievement #%d is missing!]", (int) i);
else
{
for (char *ptr = (line + strlen(line)) - 1; (ptr >= line) && ((*ptr == '\r') || (*ptr == '\n')); ptr--)
*ptr = '\0';
}
line[sizeof (g_rgAchievements[i].desc) - 1] = '\0'; // just in case.
strcpy(g_rgAchievements[i].desc, line);
// read 2 lines per achievement
int x = 0;
int ach = 0;
while(std::getline(in, line))
{
for (char *ptr = const_cast<char*>(line.c_str() + line.length()) - 1; (ptr >= line) && ((*ptr == '\r') || (*ptr == '\n')); ptr--)
*ptr = '\0';
// unsupported at the moment.
g_rgAchievements[i].iconImage = 0;
}
switch(x)
{
case 0:
strncpy(g_rgAchievements[ach].name, line.c_str(), sizeof(g_rgAchievements[ach].name) - 1);
++x;
break;
case 1:
strncpy(g_rgAchievements[ach].desc, line.c_str(), sizeof(g_rgAchievements[ach].desc) - 1);
x = 0;
++ach;
}
}
if (io != NULL)
fclose(io);
// See what this specific player has achieved...
// FG: TODO: use VFS here!
unsigned char *buf = new unsigned char[max_achievements];
size_t br = 0;
const std::string fname(core->getUserDataFolder() + "/achievements.bin");
FILE *io = fopen(fname.c_str(), "rb");
io = fopen(fname.c_str(), "rb");
if (io == NULL)
statsValid = true; // nothing to report.
else

View file

@ -29,7 +29,7 @@ void StringBank::load(const std::string &file)
//debugLog("StringBank::load("+file+")");
stringMap.clear();
VFSTextStdStreamIn in(file.c_str());
std::ifstream in(file.c_str());
std::string line;
int idx;

View file

@ -61,7 +61,7 @@ void SubtitlePlayer::go(const std::string &subs)
}
}
VFSTextStdStreamIn in(f.c_str());
std::ifstream in(f.c_str());
std::string line;
while (std::getline(in, line))
{

View file

@ -246,7 +246,7 @@ void WorldMap::load(const std::string &file)
std::string line;
VFSTextStdStreamIn in(file.c_str());
std::ifstream in(file.c_str());
while (std::getline(in, line))
{
@ -261,7 +261,6 @@ void WorldMap::load(const std::string &file)
void WorldMap::save(const std::string &file)
{
// FG: TODO: use VFS here!
std::ofstream out(file.c_str());
for (int i = 0; i < worldMapTiles.size(); i++)