コード例 #1
0
ファイル: Claims.cs プロジェクト: deranon/StarryboundServer
        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
ファイル: Claims.cs プロジェクト: deranon/StarryboundServer
 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
ファイル: Claims.cs プロジェクト: deranon/StarryboundServer
 public static String GetStakeOwner(Extensions.WorldCoordinate loc)
 {
     if (_SystemToPlayer.ContainsKey(loc))
     {
         return(_SystemToPlayer[loc]);
     }
     return(null);
 }
コード例 #4
0
 public static void Write(this BinaryWriter write, WorldCoordinate coord)
 {
     write.Write(coord._syscoord);
     write.WriteBE(coord._planet);
     write.WriteBE(coord._satellite);
 }
コード例 #5
0
 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);
 }