diff options
author | Evgeny Grechnikov | 2018-08-25 15:11:24 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-26 12:09:43 +0200 |
commit | f771fa40ad474d78d32ce5bff67afc937547e5de (patch) | |
tree | 483ee750c81169142fc58a68e87d5a321a4a96f3 /engines/lastexpress/game/savepoint.cpp | |
parent | f3cb1fcd84d7ca1dd25b7adb4b54f08c535008ac (diff) | |
download | scummvm-rg350-f771fa40ad474d78d32ce5bff67afc937547e5de.tar.gz scummvm-rg350-f771fa40ad474d78d32ce5bff67afc937547e5de.tar.bz2 scummvm-rg350-f771fa40ad474d78d32ce5bff67afc937547e5de.zip |
LASTEXPRESS: multiple fixes in NPC logic
Checked the logic against the original game
(to be precise, DOS English version from GOG, although I think
AI logic has no significant differences with other versions).
Fixed a *lot* of errors with varying visibility for the user.
Also, save+exit+load sometimes resulted in memory corruption like
((EntityParametersSSII*)(new EntityParametersIIII))->param8 = 0;
load operation did not restore the correct type of NPC logic context,
the default one was used (which also has the smallest sizeof).
Should be fixed now. Save+load is still unusable because it locks
everybody waiting for kActionEndSound (the sound state is not restored),
but, at least, it should not corrupt the memory. Hopefully.
Diffstat (limited to 'engines/lastexpress/game/savepoint.cpp')
-rw-r--r-- | engines/lastexpress/game/savepoint.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/engines/lastexpress/game/savepoint.cpp b/engines/lastexpress/game/savepoint.cpp index a8483e6d5c..bd134c637c 100644 --- a/engines/lastexpress/game/savepoint.cpp +++ b/engines/lastexpress/game/savepoint.cpp @@ -162,8 +162,8 @@ void SavePoints::call(EntityIndex entity2, EntityIndex entity1, ActionIndex acti point.action = action; point.entity2 = entity2; - assert(param.size() <= 5); - strncpy((char *)&point.param.charValue, param.c_str(), 5); + assert(param.size() <= 6); // "MUS%03d" + strncpy((char *)&point.param.charValue, param.c_str(), 6); Callback *callback = getCallback(entity1); if (callback != NULL && callback->isValid()) { @@ -230,6 +230,8 @@ bool SavePoints::updateEntityFromData(const SavePoint &savepoint) { void SavePoints::saveLoadWithSerializer(Common::Serializer &s) { // Serialize savepoint data + if (s.isLoading()) + _data.clear(); uint32 dataSize = (s.isLoading() ? _savePointsMaxSize : _data.size()); for (uint i = 0; i < dataSize; i++) { if (s.isLoading()) { |