ULTIMA8: Return area search items in same order as original

For most situations this should make no difference, but Crusader: No Remorse
has some behavior where it relies on the items being returned in x/y scan
order, not y/x.

Particularly, in Mission 2 there is a camera which searches for an event
trigger with qlo == 5.  There are 2 triggers on the map with that qlo, but the
code previously returned them in the wrong order so the correct event would not
be triggered and the game could not be continued.

This may have previously caused other subtle bugs too.
This commit is contained in:
Matthew Duggan 2021-05-07 12:41:51 +09:00
parent a00ec35068
commit dc8a9487ec

View File

@ -572,8 +572,8 @@ void CurrentMap::areaSearch(UCList *itemlist, const uint8 *loopscript,
int maxy = ((y + range) / _mapChunkSize) + 1;
clipMapChunks(minx, maxx, miny, maxy);
for (int cx = minx; cx <= maxx; cx++) {
for (int cy = miny; cy <= maxy; cy++) {
for (int cy = miny; cy <= maxy; cy++) {
for (int cx = minx; cx <= maxx; cx++) {
item_list::const_iterator iter;
for (iter = _items[cx][cy].begin();
iter != _items[cx][cy].end(); ++iter) {
@ -598,7 +598,7 @@ void CurrentMap::areaSearch(UCList *itemlist, const uint8 *loopscript,
// check item against loopscript
if (item->checkLoopScript(loopscript, scriptsize)) {
assert(itemlist->getElementSize() == 2);
uint16 objid = item->getObjId();
const uint16 objid = item->getObjId();
uint8 buf[2];
buf[0] = static_cast<uint8>(objid);
buf[1] = static_cast<uint8>(objid >> 8);
@ -641,8 +641,8 @@ void CurrentMap::surfaceSearch(UCList *itemlist, const uint8 *loopscript,
int maxy = ((origin[1]) / _mapChunkSize) + 1;
clipMapChunks(minx, maxx, miny, maxy);
for (int cx = minx; cx <= maxx; cx++) {
for (int cy = miny; cy <= maxy; cy++) {
for (int cy = miny; cy <= maxy; cy++) {
for (int cx = minx; cx <= maxx; cx++) {
item_list::const_iterator iter;
for (iter = _items[cx][cy].begin();
iter != _items[cx][cy].end(); ++iter) {