Sign in to follow this  
Cuddles

method mayDropTentOnTile

Recommended Posts

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

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
Sign in to follow this