diff options
author | Paul Gilbert | 2011-10-27 19:32:27 +1100 |
---|---|---|
committer | Paul Gilbert | 2011-10-27 19:32:27 +1100 |
commit | 44e4e16819186d45e3a1adeed311218b92bbf283 (patch) | |
tree | 224ebf5f9f2306dba61ae0e0fdee22c32d4d2820 /engines/tsage/core.cpp | |
parent | f4ea6a8435c807518b2c785c28dbe898fe6ba460 (diff) | |
download | scummvm-rg350-44e4e16819186d45e3a1adeed311218b92bbf283.tar.gz scummvm-rg350-44e4e16819186d45e3a1adeed311218b92bbf283.tar.bz2 scummvm-rg350-44e4e16819186d45e3a1adeed311218b92bbf283.zip |
TSAGE: Implemented walk regions enabling/disabling for Blue Force
Diffstat (limited to 'engines/tsage/core.cpp')
-rw-r--r-- | engines/tsage/core.cpp | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 455550f6a4..5a51a9c9ef 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -896,24 +896,28 @@ int PlayerMover::calculateRestOfRoute(int *routeList, int srcRegion, int destReg // Check every connected region until we find a route to the destination (or we have no more to check). int bestDistance = 31990; while (((currDest = g_globals->_walkRegions._idxList[srcWalkRegion._idxListIndex + foundIndex]) != 0) && (!foundRoute)) { - int newDistance = calculateRestOfRoute(tempList, currDest, destRegion, foundRoute); + // Only check the region if it isn't in the list of explicitly disabled regions + if (!contains(g_globals->_walkRegions._disabledRegions, (int)currDest)) { + int newDistance = calculateRestOfRoute(tempList, currDest, destRegion, foundRoute); - if ((newDistance <= bestDistance) || foundRoute) { - // We found a shorter possible route, or one leading to the destination. + if ((newDistance <= bestDistance) || foundRoute) { + // We found a shorter possible route, or one leading to the destination. - // Overwrite the route with this new one. - routeList[0] = ourListSize - 1; + // Overwrite the route with this new one. + routeList[0] = ourListSize - 1; - for (int i = ourListSize; i <= tempList[0]; ++i) { - routeList[i] = tempList[i]; - ++routeList[0]; + for (int i = ourListSize; i <= tempList[0]; ++i) { + routeList[i] = tempList[i]; + ++routeList[0]; + } + + bestDistance = newDistance; } - bestDistance = newDistance; + // Truncate our local list to the size it was before the call. + tempList[0] = ourListSize; } - // Truncate our local list to the size it was before the call. - tempList[0] = ourListSize; ++foundIndex; } @@ -3626,6 +3630,39 @@ int WalkRegions::indexOf(const Common::Point &pt, const Common::List<int> *index return -1; } +void WalkRegions::synchronize(Serializer &s) { + // Synchronise the list of disabled regions as a list of values terminated with a '-1' + int regionId; + if (s.isLoading()) { + _disabledRegions.clear(); + + s.syncAsSint16LE(regionId); + while (regionId != -1) { + _disabledRegions.push_back(regionId); + s.syncAsSint16LE(regionId); + } + } else { + Common::List<int>::iterator i; + for (i = _disabledRegions.begin(); i != _disabledRegions.end(); ++i) { + regionId = *i; + s.syncAsSint16LE(regionId); + } + + regionId = -1; + s.syncAsSint16LE(regionId); + } +} + +void WalkRegions::disableRegion(int regionId) { + if (!contains(_disabledRegions, regionId)) + _disabledRegions.push_back(regionId); +} + +void WalkRegions::enableRegion(int regionId) { + _disabledRegions.remove(regionId); +} + + /*--------------------------------------------------------------------------*/ void ScenePriorities::load(int resNum) { |