Jump to content

forageSystem.isValidSquare, missing return keyword.


Hugo Qwerty

Recommended Posts

I saw this earlier when looking into spawning a forage item on a water square, but only when next to a land square.

 

function forageSystem.isValidSquare(_square, _itemDef, _catDef)
	if (not _square) then return false; end;
	if _square:Is(IsoFlagType.solid) then return false; end;
	if _square:Is(IsoFlagType.solidtrans) then return false; end;
	if (not _square:isNotBlocked(false)) then return false; end;
	if _itemDef.forceOutside and (not _square:Is(IsoFlagType.exterior)) then return false; end;
	if _itemDef.forceOnWater and not (_square:Is(IsoFlagType.water)) then return false; end;
	if _square:HasTree() and (not _itemDef.canBeOnTreeSquare) then return false; end;
	if _catDef.validFunc then
		_catDef.validFunc(_square, _itemDef, _catDef);  -- missing 'return'
	else
		return forageSystem.isValidFloor(_square, _itemDef, _catDef);
	end;
	return false;
end

 

 

Copied from: \media\lua\shared\Foraging\forageSystem.lua, line 1248 onwards.

If the _catDef has a validFunc, it will be called - but the return value is ignored, so any square that gets to that point will drop down to the 'return false' at the end of the function.


This doesn't have any negative impact in vanilla, as no forage cat defs use the validFunc mechanic, but any mods that attempt to use this functionality won't work as intended.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...