C# Class fCraft.FlatfilePlayerDBProvider

Exibir arquivo Open project: fragmer/fCraft Class Usage Examples

Public Methods

Method Description
AddPlayer ( string name, Rank startingRank, RankChangeType rankChangeType, IPAddress address ) : PlayerInfo

Adds a new PlayerInfo entry for an actual, logged-in player.

AddUnrecognizedPlayer ( string name, Rank startingRank, RankChangeType rankChangeType ) : PlayerInfo

Adds a new PlayerInfo entry for a player who has never been online, by name.

FindByIP ( IPAddress address, int limit ) : IEnumerable

Finds players by IP address.

FindByPartialName ( string partialName, int limit ) : IEnumerable

Finds players by partial name (prefix).

FindByPattern ( string pattern, int limit ) : IEnumerable

Finds player by name pattern.

FindExact ( string fullName ) : PlayerInfo

Finds player by exact name.

FindOneByPartialName ( string partialName, PlayerInfo &result ) : bool

Searches for player names starting with namePart, returning just one or none of the matches.

Import ( IEnumerable playerInfos ) : void

Inserts all data from given PlayerInfo list directly into the database.

Import ( PlayerInfo playerInfo ) : void

Inserts all data from given playerInfo directly into the database.

Load ( ) : IEnumerable

Initializes the provider, and allocates PlayerInfo objects for all players.

MassRankChange ( Player player, Rank from, Rank to, string reason ) : void

Changes ranks of all players in one transaction.

Remove ( PlayerInfo playerInfo ) : bool

Removes a PlayerInfo entry from the database.

Save ( ) : void

Saves the whole database.

SwapInfo ( PlayerInfo player1, PlayerInfo player2 ) : void

Swaps records of two players in one transaction.

ToDateTimeLegacy ( long timestamp ) : System.DateTime
ToDateTimeLegacy ( [ str, System.DateTime &result ) : bool
ToTimeSpanLegacy ( [ str, System.TimeSpan &result ) : bool
ToUnixTimeLegacy ( System.DateTime date ) : long
TryParseLocalDate ( [ dateString, System.DateTime &date ) : bool

Tries to parse a data in a culture-specific ways. This method is, unfortunately, necessary because in versions 0.520-0.522, fCraft saved dates in a culture-specific format. This means that if the server's culture settings were changed, or if the PlayerDB and IPBanList files were moved between machines, all dates became unparseable.

Unescape ( [ str ) : string
UnescapeOldFormat ( [ str ) : string

Private Methods

Method Description
GetNextID ( ) : int
GetRankByIndex ( int index ) : Rank
GuessRankChangeType ( [ info ) : void
IdentifyFormatVersion ( [ header ) : int
LoadBinary ( ) : void
LoadBinaryFormat0 ( [ reader ) : PlayerInfo
LoadFormat0 ( [ fields ) : PlayerInfo
LoadFormat1 ( [ fields ) : PlayerInfo
LoadFormat2 ( [ fields ) : PlayerInfo
OpenRead ( [ fileName ) : FileStream
OpenWrite ( [ fileName ) : FileStream
ParseBandwidthUseMode ( [ info, [ field ) : void
Read7BitEncodedInt ( [ reader ) : int
ReadDate ( [ reader ) : System.DateTime
ReadIPAddress ( [ reader ) : IPAddress
ReadString ( [ reader ) : string
ReadTimeSpan ( [ reader ) : System.TimeSpan
SaveBinaryFormat0 ( PlayerInfo info, [ writer ) : void
Write7BitEncodedInt ( [ writer, int value ) : void
WriteDate ( [ writer, System.DateTime dateTime ) : void
WriteString ( [ writer, [ str ) : void

Method Details

AddPlayer() public method

Adds a new PlayerInfo entry for an actual, logged-in player.
public AddPlayer ( string name, Rank startingRank, RankChangeType rankChangeType, IPAddress address ) : PlayerInfo
name string
startingRank Rank
rankChangeType RankChangeType
address System.Net.IPAddress
return PlayerInfo

AddUnrecognizedPlayer() public method

Adds a new PlayerInfo entry for a player who has never been online, by name.
public AddUnrecognizedPlayer ( string name, Rank startingRank, RankChangeType rankChangeType ) : PlayerInfo
name string
startingRank Rank
rankChangeType RankChangeType
return PlayerInfo

FindByIP() public method

Finds players by IP address.
public FindByIP ( IPAddress address, int limit ) : IEnumerable
address System.Net.IPAddress Player's IP address.
limit int Maximum number of results to return.
return IEnumerable

FindByPartialName() public method

Finds players by partial name (prefix).
public FindByPartialName ( string partialName, int limit ) : IEnumerable
partialName string Full or partial name of the player.
limit int Maximum number of results to return.
return IEnumerable

FindByPattern() public method

Finds player by name pattern.
public FindByPattern ( string pattern, int limit ) : IEnumerable
pattern string Pattern to search for. /// Asterisk (*) matches zero or more characters. /// Question mark (?) matches exactly one character.
limit int Maximum number of results to return.
return IEnumerable

FindExact() public method

Finds player by exact name.
public FindExact ( string fullName ) : PlayerInfo
fullName string Full, case-insensitive name of the player.
return PlayerInfo

FindOneByPartialName() public method

Searches for player names starting with namePart, returning just one or none of the matches.
public FindOneByPartialName ( string partialName, PlayerInfo &result ) : bool
partialName string Partial or full player name.
result PlayerInfo PlayerInfo to output (will be set to null if no single match was found).
return bool

Import() public method

Inserts all data from given PlayerInfo list directly into the database.
public Import ( IEnumerable playerInfos ) : void
playerInfos IEnumerable List of player record to import.
return void

Import() public method

Inserts all data from given playerInfo directly into the database.
public Import ( PlayerInfo playerInfo ) : void
playerInfo PlayerInfo Player record to import.
return void

Load() public method

Initializes the provider, and allocates PlayerInfo objects for all players.
public Load ( ) : IEnumerable
return IEnumerable

MassRankChange() public method

Changes ranks of all players in one transaction.
public MassRankChange ( Player player, Rank from, Rank to, string reason ) : void
player Player
from Rank
to Rank
reason string
return void

Remove() public method

Removes a PlayerInfo entry from the database.
public Remove ( PlayerInfo playerInfo ) : bool
playerInfo PlayerInfo
return bool

Save() public method

Saves the whole database.
public Save ( ) : void
return void

SwapInfo() public method

Swaps records of two players in one transaction.
public SwapInfo ( PlayerInfo player1, PlayerInfo player2 ) : void
player1 PlayerInfo
player2 PlayerInfo
return void

ToDateTimeLegacy() public static method

public static ToDateTimeLegacy ( long timestamp ) : System.DateTime
timestamp long
return System.DateTime

ToDateTimeLegacy() public static method

public static ToDateTimeLegacy ( [ str, System.DateTime &result ) : bool
str [
result System.DateTime
return bool

ToTimeSpanLegacy() public static method

public static ToTimeSpanLegacy ( [ str, System.TimeSpan &result ) : bool
str [
result System.TimeSpan
return bool

ToUnixTimeLegacy() public static method

public static ToUnixTimeLegacy ( System.DateTime date ) : long
date System.DateTime
return long

TryParseLocalDate() public static method

Tries to parse a data in a culture-specific ways. This method is, unfortunately, necessary because in versions 0.520-0.522, fCraft saved dates in a culture-specific format. This means that if the server's culture settings were changed, or if the PlayerDB and IPBanList files were moved between machines, all dates became unparseable.
public static TryParseLocalDate ( [ dateString, System.DateTime &date ) : bool
dateString [ String to parse.
date System.DateTime Date to output.
return bool

Unescape() public static method

public static Unescape ( [ str ) : string
str [
return string

UnescapeOldFormat() public static method

public static UnescapeOldFormat ( [ str ) : string
str [
return string