diff options
author | Eugene Sandulenko | 2019-07-18 17:56:16 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:23 +0200 |
commit | bba1fa849bf88164f905ad5a017a9be51683610e (patch) | |
tree | 567b885d5aadf0f9197e7ec161c72ce06d584342 /engines/hdb | |
parent | ae1f4efeb58d195acde7185fa4f71100449966be (diff) | |
download | scummvm-rg350-bba1fa849bf88164f905ad5a017a9be51683610e.tar.gz scummvm-rg350-bba1fa849bf88164f905ad5a017a9be51683610e.tar.bz2 scummvm-rg350-bba1fa849bf88164f905ad5a017a9be51683610e.zip |
HDB: Fix loading
Diffstat (limited to 'engines/hdb')
-rw-r--r-- | engines/hdb/ai-init.cpp | 47 | ||||
-rw-r--r-- | engines/hdb/lua-script.cpp | 16 |
2 files changed, 38 insertions, 25 deletions
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp index 0471a05212..23cfe2d8e9 100644 --- a/engines/hdb/ai-init.cpp +++ b/engines/hdb/ai-init.cpp @@ -1677,24 +1677,29 @@ void AI::loadSaveFile(Common::InSaveFile *in) { } // Load AnimTargets - _animTargets.resize(in->readUint32LE()); - for (i = 0; (uint)i < _animTargets.size(); i++) { - _animTargets[i]->x = in->readUint16LE(); - _animTargets[i]->y = in->readUint16LE(); - _animTargets[i]->start = in->readUint16LE(); - _animTargets[i]->end = in->readUint16LE(); - _animTargets[i]->vel = in->readSint16LE(); - _animTargets[i]->animCycle = in->readUint16LE(); - _animTargets[i]->animFrame = in->readUint16LE(); - _animTargets[i]->killAuto = in->readByte(); - _animTargets[i]->inMap = in->readByte(); - memset(_animTargets[i]->gfxList, 0, kMaxAnimTFrames * sizeof(Tile *)); + uint32 animTsize = in->readUint32LE(); + _animTargets.clear(); + for (i = 0; i < animTsize; i++) { + AnimTarget *a = new AnimTarget; + + a->x = in->readUint16LE(); + a->y = in->readUint16LE(); + a->start = in->readUint16LE(); + a->end = in->readUint16LE(); + a->vel = in->readSint16LE(); + a->animCycle = in->readUint16LE(); + a->animFrame = in->readUint16LE(); + a->killAuto = in->readByte(); + a->inMap = in->readByte(); + memset(a->gfxList, 0, kMaxAnimTFrames * sizeof(Tile *)); + + _animTargets.push_back(a); } // Load ArrowPaths - uint32 arrowPathSIze = in->readUint32LE(); - for (i = 0; (uint)i < arrowPathSIze; i++) { + uint32 arrowPathSize = in->readUint32LE(); + for (i = 0; (uint)i < arrowPathSize; i++) { ArrowPath *arrowPath = new ArrowPath; arrowPath->type = in->readUint16LE(); @@ -1706,11 +1711,15 @@ void AI::loadSaveFile(Common::InSaveFile *in) { } // Load HereT List - _hereList->resize(in->readUint32LE()); - for (i = 0; (uint)i < _hereList->size(); i++) { - _hereList->operator[](i)->x = in->readUint16LE(); - _hereList->operator[](i)->y = in->readUint16LE(); - in->read(_hereList->operator[](i)->entName, 32); + uint32 hereSize = in->readUint32LE(); + _hereList->clear(); + for (i = 0; i < hereSize; i++) { + HereT *h = new HereT; + h->x = in->readUint16LE(); + h->y = in->readUint16LE(); + in->read(h->entName, 32); + + _hereList->push_back(h); } // Load Triggers diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp index 5c2906b6dc..f9e84520fa 100644 --- a/engines/hdb/lua-script.cpp +++ b/engines/hdb/lua-script.cpp @@ -182,12 +182,16 @@ void LuaScript::loadSaveFile(Common::InSaveFile *in, const char *fName) { _globals.clear(); // Start reading globals - _globals.resize(in->readUint32LE()); - for (uint i = 0; i < _globals.size(); i++) { - in->read(_globals[i]->global, 32); - _globals[i]->valueOrString = in->readSint32LE(); - _globals[i]->value = in->readDoubleLE(); - in->read(_globals[i]->string, 32); + uint32 globalsSize = in->readUint32LE(); + for (uint i = 0; i < globalsSize; i++) { + Global *g = new Global; + + in->read(g->global, 32); + g->valueOrString = in->readSint32LE(); + g->value = in->readDoubleLE(); + in->read(g->string, 32); + + _globals.push_back(g); } lua_getglobal(_state, "LoadState"); |