made loadScript and loadLocation benefit from Script's ability to dispose of its input buffer
svn-id: r25976
This commit is contained in:
parent
1c00cc5dc5
commit
20da7f80f1
4 changed files with 17 additions and 26 deletions
|
@ -251,14 +251,10 @@ void jobEraseAnimations(void *arg_0, Job *j) {
|
|||
void Parallaction::loadProgram(Animation *a, char *filename) {
|
||||
// printf("loadProgram(%s)\n", filename);
|
||||
|
||||
// the largest script in Nippon Safes is 3,668 bytes, so 4 kb is well enough
|
||||
char* src = (char*)malloc(0x1000);
|
||||
_disk->loadScript(filename, src);
|
||||
Script *script = _disk->loadScript(filename);
|
||||
|
||||
_numLocals = 0;
|
||||
|
||||
Script *script = new Script(src);
|
||||
|
||||
fillBuffers(*script);
|
||||
|
||||
a->_program = (Program*)malloc(sizeof(Program));
|
||||
|
@ -284,7 +280,6 @@ void Parallaction::loadProgram(Animation *a, char *filename) {
|
|||
addNode(vD0, &vCC->_node);
|
||||
|
||||
delete script;
|
||||
free(src);
|
||||
|
||||
a->_program->_ip = (Instruction*)a->_program->_node._next;
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ void Disk::loadTalk(const char *name, Cnv *cnv) {
|
|||
|
||||
}
|
||||
|
||||
void Disk::loadLocation(const char *name, char* script) {
|
||||
Script* Disk::loadLocation(const char *name) {
|
||||
|
||||
char archivefile[PATH_LEN];
|
||||
|
||||
|
@ -232,14 +232,16 @@ void Disk::loadLocation(const char *name, char* script) {
|
|||
error("can't find location file '%s'", name);
|
||||
}
|
||||
|
||||
uint32 count = _archive.size();
|
||||
_archive.read(script, count);
|
||||
_archive.closeArchivedFile();
|
||||
_archive.close();
|
||||
uint32 size = _archive.size();
|
||||
char *buf = (char*)malloc(size+1);
|
||||
_archive.read(buf, size);
|
||||
buf[size] = '\0';
|
||||
|
||||
return new Script(buf, true);
|
||||
|
||||
}
|
||||
|
||||
void Disk::loadScript(const char* name, char *script) {
|
||||
Script* Disk::loadScript(const char* name) {
|
||||
|
||||
char vC8[PATH_LEN];
|
||||
|
||||
|
@ -249,12 +251,11 @@ void Disk::loadScript(const char* name, char *script) {
|
|||
errorFileNotFound(vC8);
|
||||
|
||||
uint32 size = _archive.size();
|
||||
char *buf = (char*)malloc(size+1);
|
||||
_archive.read(buf, size);
|
||||
buf[size] = '\0';
|
||||
|
||||
_archive.read(script, size);
|
||||
script[size] = '\0';
|
||||
|
||||
_archive.closeArchivedFile();
|
||||
|
||||
return new Script(buf, true);
|
||||
}
|
||||
|
||||
void Disk::loadHead(const char* name, StaticCnv* cnv) {
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace Parallaction {
|
|||
|
||||
class Parallaction;
|
||||
class Graphics;
|
||||
class Script;
|
||||
|
||||
class Archive : public Common::SeekableReadStream {
|
||||
|
||||
|
@ -98,8 +99,8 @@ public:
|
|||
|
||||
void selectArchive(const char *name);
|
||||
|
||||
void loadLocation(const char *name, char* script);
|
||||
void loadScript(const char* name, char *script);
|
||||
Script* loadLocation(const char *name);
|
||||
Script* loadScript(const char* name);
|
||||
void loadTalk(const char *name, Cnv *cnv);
|
||||
void loadObjects(const char *name, Cnv *cnv);
|
||||
void loadPointer(StaticCnv* cnv);
|
||||
|
|
|
@ -41,15 +41,11 @@ void Parallaction::parseLocation(const char *filename) {
|
|||
// printf("parseLocation(%s)", filename);
|
||||
debugC(1, kDebugLocation, "parseLocation('%s')", filename);
|
||||
|
||||
char *location_src = NULL;
|
||||
|
||||
uint16 _si = 1;
|
||||
_vm->_graphics->_proportionalFont = false;
|
||||
_vm->_graphics->setFont("topaz");
|
||||
|
||||
location_src = (char*)malloc(0x4000);
|
||||
_disk->loadLocation(filename, location_src);
|
||||
_locationScript = new Script(location_src);
|
||||
_locationScript = _disk->loadLocation(filename);
|
||||
|
||||
fillBuffers(*_locationScript, true);
|
||||
while (scumm_stricmp(_tokens[0], "ENDLOCATION")) {
|
||||
|
@ -164,8 +160,6 @@ void Parallaction::parseLocation(const char *filename) {
|
|||
delete _locationScript;
|
||||
_locationScript = NULL;
|
||||
|
||||
free(location_src);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue