FULLPIPE: Refactored pascal style string reader

This commit is contained in:
Eugene Sandulenko 2013-06-02 22:52:37 +03:00
parent fa30dcef15
commit 82cbf508b5
2 changed files with 13 additions and 17 deletions

View File

@ -67,7 +67,7 @@ class SceneTagList {
CPtrList list;
public:
SceneTagList(Common::File &file);
SceneTagList(CFile &file);
};
class GameProject {
@ -78,7 +78,8 @@ class GameProject {
int _field_10;
public:
GameProject(Common::File &file);
GameProject(CFile &file);
~GameProject();
};
class CInteractionController {

View File

@ -24,6 +24,7 @@
#include "common/file.h"
#include "fullpipe/utils.h"
#include "fullpipe/objects.h"
namespace Fullpipe {
@ -40,17 +41,12 @@ bool FullpipeEngine::loadGam(const char *fname) {
}
bool CGameLoader::loadFile(const char *fname) {
Common::File file;
CFile file;
if (!file.open(fname))
return false;
char *tmp;
int len = file.readByte();
tmp = (char *)calloc(len + 1, 1);
file.read(tmp, len);
_gameName = tmp;
_gameName = file.readPascalString();
_gameProject = new GameProject(file);
@ -61,7 +57,7 @@ CGameLoader::~CGameLoader() {
free(_gameName);
}
GameProject::GameProject(Common::File &file) {
GameProject::GameProject(CFile &file) {
_field_4 = 0;
_headerFilename = 0;
_field_10 = 12;
@ -71,12 +67,7 @@ GameProject::GameProject(Common::File &file) {
int _gameProjectValue = file.readUint16LE();
int _scrollSpeed = file.readUint32LE();
char *tmp;
int len = file.readByte();
tmp = (char *)calloc(len + 1, 1);
file.read(tmp, len);
_headerFilename = tmp;
_headerFilename = file.readPascalString();
_sceneTagList = new SceneTagList(file);
@ -94,7 +85,11 @@ GameProject::GameProject(Common::File &file) {
}
}
SceneTagList::SceneTagList(Common::File &file) {
GameProject::~GameProject() {
free(_headerFilename);
}
SceneTagList::SceneTagList(CFile &file) {
}
} // End of namespace Fullpipe