I found some weird code in islands.c and rewrote it accordingly:
@Levis, can you think of ANY reason why that old code was doing all those things?
It seems quite complex, yet doesn't make much sense to me.
And there is one line that was DEFINITELY wrong because it ended up looking at a different island than the one for the location you're asking about.
EDIT: Probably better to reverse the logic on this one and check first if you are at sea.
Code:
string FindIslandByLocation(string locID)//MAXIMUS
{
// PB: Simplified -->
if(locID != "")
{
int ind = FindIsland(locID);
if (ind >= 0) // If location is an existing island
{
return locID; // Return that
}
else
{
ind = FindLocation(locID);
if (ind >= 0) // You are in a valid location ashore
{
ref lcn = &locations[ind];
if(CheckAttribute(lcn,"island")) return lcn.island; // Return location island
if(CheckAttribute(lcn,"townsack")) return GetIslandIDFromTown(lcn.townsack); // If missing, return town's island
}
}
}
return "";
// PB: Simplified <--
/* if(locID=="" || FindLocation(locID)==-1)
{
if(CheckAttribute(&characters[GetMainCharacterIndex()],"location.from_sea")) return Islands[FindIslandBySeaLocation(characters[GetMainCharacterIndex()].location.from_sea)].id;
return "";
}
if(CheckAttribute(&locations[FindLocation(locID)],"townsack")) return GetIslandIDFromTown(GetCurrentTownID()); // PB: This is DEFINITELY wrong!
if(CheckAttribute(&locations[FindLocation(locID)],"island")) return locations[FindLocation(locID)].island;
if(FindIslandBySeaLocation(FindSeaShoreForLocation(locID))!=-1) return Islands[FindIslandBySeaLocation(FindSeaShoreForLocation(locID))].id;
return "";*/
}
It seems quite complex, yet doesn't make much sense to me.
And there is one line that was DEFINITELY wrong because it ended up looking at a different island than the one for the location you're asking about.

EDIT: Probably better to reverse the logic on this one and check first if you are at sea.
Last edited: