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