示例#1
0
        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);
        }
示例#2
0
 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);
 }
示例#3
0
 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();
 }
示例#6
0
 public bool Equals(WorldCoordinate test)
 {
     return(this.ToString() == test.ToString());
 }
示例#7
0
 public static void Write(this BinaryWriter write, WorldCoordinate coord)
 {
     write.Write(coord._syscoord);
     write.WriteBE(coord._planet);
     write.WriteBE(coord._satellite);
 }