curiousdannii-testing / inform7-imported-bugs

0 stars 0 forks source link

[I7-1946] [Mantis 1982] Regional-containment doesn't relate regions correctly #138

Closed curiousdannii-testing closed 2 years ago

curiousdannii-testing commented 2 years ago

Reported by : dfremont

Description :

WI 6.11 states that regional-containment allows regions to be "in" regions, but testing the relation between two regions always fails (see the example below). This occurs regardless of how the test is done, using the verbs "in" or "regionally in", or with "R relates X to Y".

The Index does correctly mention one region as being in the other (as long as the inner region contains a room).

Steps to reproduce :

Blorp is a region. Zorp is a region in Blorp.
Foo is a room in Zorp.
When play begins: if Zorp is [regionally] in Blorp, say "hooray!"

Additional information :

imported from: [Mantis 1982] Regional-containment doesn't relate regions correctly
  • status: Closed
  • resolution: Resolved
  • resolved: 2022-04-12T08:35:47+10:00
  • imported: 2022/01/10
curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by zarf :
Confirmed.

The TestRegionalContainment() routine has no logic to support the case where obj is a region. It reaches the line

if (~~(obj ofclass K1_room)) obj = LocationOf(obj);

...and LocationOf() always returns "nothing" for regions. Thus the test always returns false.

curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by zarf :
I thought this might have been fallout from http://inform7.com/mantis/view.php?id=1501 in 6L38. Nope – while TestRegionalContainment changed in that fix, this example failed before that.

curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by zarf :
Quick cut at a fix:


[ TestRegionalContainment obj region o;
if ((obj == nothing) || (region == nothing)) rfalse;
if (obj ofclass K7_backdrop or K4_door)

{ if (obj has absent) rfalse; objectloop (o ofclass K1_room) if (TestRegionalContainment(o, region)) if (BackdropLocation(obj, o)) rtrue; rfalse; }

if (obj ofclass K9_region)

{ o = obj; }

else

{ if (~~(obj ofclass K1_room)) obj = LocationOf(obj); if (obj == nothing) rfalse; o = obj.map_region; }

while (o)

{ if (o == region) rtrue; o = parent(o); }

rfalse;
];

curiousdannii-testing commented 2 years ago

61eedb62875fc10070240916:

Fixed via this commit: https://github.com/ganelson/inform/commit/8af83ace5a954d42dc6c8dc91a49395810fa6911