Sign in to follow this  
Cuddles

method mayDropTentOnTile

Recommended Posts

Posted (edited)
Spoiler

  public static boolean mayDropTentOnTile(Creature performer)
  {
    for (int x = performer.getTileX() - 1; x <= performer.getTileX() + 1; x++) {
      for (int y = performer.getTileY() - 1; y <= performer.getTileY() + 1; y++)
      {
        VolaTile t = Zones.getTileOrNull(Zones.safeTileX(x), Zones.safeTileY(y), performer.isOnSurface());
        if (t != null)
        {
          if ((t.getVillage() != null) && (t.getVillage() != performer.getCitizenVillage()))
          {
            return false;
          }
          if (Villages.getVillageWithPerimeterAt(Zones.safeTileX(x), Zones.safeTileY(y), true) != null)
          {
            return false;
          }
        }
        if (performer.isOnSurface())
        {
          int tile = Server.surfaceMesh.getTile(Zones.safeTileX(x), Zones.safeTileY(y));
          if (Tiles.decodeHeight(tile) < 1)
          {
            return false; }
        }
      }
    }
    return true;
  }

 

Ok bit of a curiosity here, first if statement checks if on a deed and also if you are a citizen, that would imply you should be able to drop tent on a deed you belong to. Next if statement checks for *perimeter* of a deed but that method returns the village if you are on deed as well as if you are in the perimeter, which means that if you are on your own deed it will return false making previous if statement useless.

I think the issue is either that someone assumed the method getVillageWithPerimeterAt only checks for perimeter or that it is only meant to check perimeter but it doesn't, it checks any tile inside perimeter which includes the deed itself.

 

I tested this by making a simple action that returns some details if getVillageWithPerimeterAt returns a village and then moved around using action over and over while checking if on perimeter and also on deed itself. While on perimeter and also while on deed it always printed details of the deed and while off deed it printed there was no deed.

Edited by Cuddles

Share this post


Link to post
Share on other sites

 

Posting video of my test, code for action in spoiler below.

Spoiler

			Village perimVillage = Villages.getVillageWithPerimeterAt(performer.getTileX(), performer.getTileY(), true);
			if (perimVillage != null) {
				String message = perimVillage.getName()+ " X:"+perimVillage.getStartX()+"-"+perimVillage.getEndX();
				message = message+" Y:"+perimVillage.getStartY()+"-"+perimVillage.getEndY();
				performer.getCommunicator().sendSafeServerMessage(message);
			}else {
				performer.getCommunicator().sendSafeServerMessage("No *perimeter* here");
			}

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this