added openLocation as loader for location scripts resources

svn-id: r25933
This commit is contained in:
Nicola Mettifogo 2007-03-02 22:02:19 +00:00
parent 43f802ef5f
commit f124c22bc5
3 changed files with 37 additions and 33 deletions

View File

@ -55,5 +55,39 @@ void openTalk(const char *name, Cnv *cnv) {
}
void openLocation(const char *name, char* script) {
char archivefile[PATH_LEN];
if (_vm->_characterName[0] == 'm') {
sprintf(archivefile, "%s%s", _vm->_characterName+4, _vm->_languageDir);
} else {
if (_vm->_characterName[0] == 'D') strcpy(archivefile, _vm->_languageDir);
else {
sprintf(archivefile, "%s%s", _vm->_characterName, _vm->_languageDir);
}
}
strcat(archivefile, name);
strcat(archivefile, ".loc");
_vm->_archive.close();
_vm->_languageDir[2] = '\0';
_vm->_archive.open(_vm->_languageDir);
_vm->_languageDir[2] = '/';
if (!_vm->_archive.openArchivedFile(archivefile)) {
sprintf(archivefile, "%s%s.loc", _vm->_languageDir, name);
if (!_vm->_archive.openArchivedFile(archivefile))
error("can't find location file '%s'", name);
}
uint32 count = _vm->_archive.size();
_vm->_archive.read(script, count);
_vm->_archive.closeArchivedFile();
_vm->_archive.close();
}
} // namespace Parallaction

View File

@ -72,6 +72,7 @@ public:
uint32 read(void *dataPtr, uint32 dataSize);
};
void openLocation(const char *name, char* script);
void openTalk(const char *name, Cnv *cnv);
} // namespace Parallaction

View File

@ -48,40 +48,10 @@ void Parallaction::parseLocation(const char *filename) {
_vm->_graphics->_proportionalFont = false;
_vm->_graphics->setFont("topazcnv");
char archivefile[PATH_LEN];
if (_characterName[0] == 'm') {
sprintf(archivefile, "%s%s", _characterName+4, _languageDir);
} else {
if (_characterName[0] == 'D') strcpy(archivefile, _languageDir);
else {
sprintf(archivefile, "%s%s", _characterName, _languageDir);
}
}
strcat(archivefile, filename);
strcat(archivefile, ".loc");
if (strcmp(_disk, "null")) _archive.close();
_languageDir[2] = '\0';
_archive.open(_languageDir);
_languageDir[2] = '/';
if (!_archive.openArchivedFile(archivefile)) {
sprintf(archivefile, "%s%s.loc", _languageDir, filename);
if (!_archive.openArchivedFile(archivefile))
errorFileNotFound(filename);
}
uint32 count = _archive.size();
location_src = (char*)memAlloc(0x4000);
openLocation(filename, location_src);
_locationScript = new Script(location_src);
_archive.read(location_src, count);
_archive.closeArchivedFile();
_archive.close();
fillBuffers(*_locationScript, true);
while (scumm_stricmp(_tokens[0], "ENDLOCATION")) {
// printf("token[0] = %s", _tokens[0]);
@ -133,8 +103,7 @@ void Parallaction::parseLocation(const char *filename) {
}
if (!scumm_stricmp(_tokens[0], "DISK")) {
strcpy(_disk, _tokens[1]);
strcpy(archivefile, _disk);
_archive.open(archivefile);
_archive.open(_disk);
}
if (!scumm_stricmp(_tokens[0], "LOCALFLAGS")) {
_si = 1; // _localFlagNames[0] = 'visited'