public static ClaimResult StakeClaim(PlayerData player, Extensions.WorldCoordinate loc) { stakeClaimMutex.WaitOne(); if (!_playerToSystem.ContainsKey(player.name)) { _playerToSystem.Add(player.name, new List <Extensions.WorldCoordinate>()); } var currPlyClaims = _playerToSystem[player.name]; if (_SystemToPlayer.ContainsKey(loc)) { stakeClaimMutex.ReleaseMutex(); if (_SystemToPlayer[loc] == player.name) { return(ClaimResult.LocationAlreadyClaimedByPlayer); } return(ClaimResult.LocationAlreadyClaimedByOther); } if (currPlyClaims.Count >= player.MaxClaims) { stakeClaimMutex.ReleaseMutex(); return(ClaimResult.MaxClaimsExceeded); } _playerToSystem[player.name].Add(loc); _SystemToPlayer.Add(loc, player.name); SaveClaims(); stakeClaimMutex.ReleaseMutex(); return(ClaimResult.OK); }
public static bool ReleaseClaim(PlayerData player, Extensions.WorldCoordinate loc) { try { stakeClaimMutex.WaitOne(); if (_SystemToPlayer.ContainsKey(loc)) { if (_SystemToPlayer[loc] == player.name) { _SystemToPlayer.Remove(loc); _playerToSystem[player.name].Remove(loc); SaveClaims(); stakeClaimMutex.ReleaseMutex(); return(true); } } } catch (Exception e) { StarryboundServer.logException("Could not release claim to location {0} for player {1}", loc, player.uuid); stakeClaimMutex.ReleaseMutex(); return(false); } return(false); }
public static String GetStakeOwner(Extensions.WorldCoordinate loc) { if (_SystemToPlayer.ContainsKey(loc)) { return(_SystemToPlayer[loc]); } return(null); }
public static void Write(this BinaryWriter write, WorldCoordinate coord) { write.Write(coord._syscoord); write.WriteBE(coord._planet); write.WriteBE(coord._satellite); }
public bool Equals(WorldCoordinate test) { return this.ToString() == test.ToString(); }
public bool Equals(WorldCoordinate test) { return(this.ToString() == test.ToString()); }