本文整理汇总了C#中System.IO.BinaryWriter.WriteStarString方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryWriter.WriteStarString方法的具体用法?C# BinaryWriter.WriteStarString怎么用?C# BinaryWriter.WriteStarString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryWriter
的用法示例。
在下文中一共展示了BinaryWriter.WriteStarString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: doProcess
public override bool doProcess(string[] args)
{
if (!hasPermission()) { permissionError(); return false; }
this.client.sendCommandMessage("Teleporting to your home planet.");
MemoryStream packetWarp = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packetWarp);
uint warp = (uint)WarpType.WarpToHomePlanet;
string sector = "";
int x = 0;
int y = 0;
int z = 0;
int planet = 0;
int satellite = 0;
string player = "";
packetWrite.WriteBE(warp);
packetWrite.WriteStarString(sector);
packetWrite.WriteBE(x);
packetWrite.WriteBE(y);
packetWrite.WriteBE(z);
packetWrite.WriteBE(planet);
packetWrite.WriteBE(satellite);
packetWrite.WriteStarString(player);
client.sendServerPacket(Packet.WarpCommand, packetWarp.ToArray());
return true;
}
示例2: doProcess
public override bool doProcess(string[] args)
{
if (this.client.playerData.freeFuel)
{
client.sendCommandMessage("Sorry, you have already received free starter fuel on this server.");
return false;
}
else if (!StarryboundServer.config.freeFuelForNewPlayers)
{
client.sendCommandMessage("Sorry, this server does not provide free starter fuel.");
return false;
}
MemoryStream packet = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packet);
packetWrite.WriteStarString("solariumore");
packetWrite.WriteVarUInt32(31); // Seems like it always gives 1 less than the amount entered, so we need 31 to give 30.
packetWrite.Write((byte)0); //0 length Star::Variant
client.sendClientPacket(Packet.GiveItem, packet.ToArray());
client.sendCommandMessage("You have received 30 Solarium Ore as free starter fuel!");
this.client.playerData.freeFuel = true;
Users.SaveUser(this.client.playerData);
return true;
}
示例3: doProcess
public override bool doProcess(string[] args)
{
if (player.receivedStarterKit)
{
client.sendCommandMessage("You have already received your starting items.");
return false;
}
if (StarryboundServer.config.starterItems == null || StarryboundServer.config.starterItems.Length <= 0)
{
client.sendCommandMessage("Sorry! This server does not provide any starting items.");
return false;
}
int awardedItems = 0;
foreach (string item in StarryboundServer.config.starterItems)
{
if (String.IsNullOrEmpty(item) || String.IsNullOrWhiteSpace(item))
{
continue;
}
string name;
uint amount;
if (item.Contains('*'))
{
name = item.Split('*')[0];
amount = uint.Parse(item.Split('*')[1]);
if (amount <= 0) { continue; }
}
else
{
name = item;
amount = 1;
}
MemoryStream packet = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packet);
packetWrite.WriteStarString(name);
packetWrite.WriteVarUInt32(amount+1);
packetWrite.Write((byte)0);
client.sendClientPacket(Packet.GiveItem, packet.ToArray());
awardedItems++;
}
if (awardedItems == 0)
{
client.sendCommandMessage("Sorry! This server does not provide any starting items.");
return false;
}
client.sendCommandMessage("You have been given a few starting items to help you on your journey. Good luck!");
this.client.playerData.receivedStarterKit = true;
Users.SaveUser(this.client.playerData);
return true;
}
示例4: onSend
public override void onSend()
{
MemoryStream packet = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packet);
packetWrite.Write(false);
packetWrite.WriteVarUInt32(0);
packetWrite.WriteStarString((string)tmpArray["rejectReason"]);
this.mClient.sendClientPacket(Packet.ConnectResponse, packet.ToArray());
}
示例5: doProcess
public override bool doProcess(string[] args)
{
if (!hasPermission()) { permissionError(); return false; }
this.client.sendCommandMessage("Teleporting to orbited planet.");
MemoryStream packetWarp = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packetWarp);
uint warp = (uint)WarpType.WarpToOrbitedPlanet;
string player = "";
packetWrite.WriteBE(warp);
packetWrite.Write(new WorldCoordinate());
packetWrite.WriteStarString(player);
client.sendServerPacket(Packet.WarpCommand, packetWarp.ToArray());
return true;
}
示例6: doProcess
public override bool doProcess(string[] args)
{
if (!hasPermission()) { permissionError(); return false; }
string player = string.Join(" ", args).Trim();
uint warp;
if (player == null || player.Length < 1)
{
this.client.sendCommandMessage("Teleporting to your ship.");
player = "";
warp = (uint)WarpType.WarpToOwnShip;
}
else
{
if (!hasPermission(true)) { permissionError(2); return false; }
this.client.sendCommandMessage("Teleporting to " + player + " ship!");
warp = (uint)WarpType.WarpToPlayerShip;
}
MemoryStream packetWarp = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packetWarp);
string sector = "";
int x = 0;
int y = 0;
int z = 0;
int planet = 0;
int satellite = 0;
packetWrite.WriteBE(warp);
packetWrite.WriteStarString(sector);
packetWrite.WriteBE(x);
packetWrite.WriteBE(y);
packetWrite.WriteBE(z);
packetWrite.WriteBE(planet);
packetWrite.WriteBE(satellite);
packetWrite.WriteStarString(player);
client.sendServerPacket(Packet.WarpCommand, packetWarp.ToArray());
return true;
}
示例7: doProcess
public override bool doProcess(string[] args)
{
if (!hasPermission()) { permissionError(); return false; }
if (StarryboundServer.serverConfig.useDefaultWorldCoordinate && StarryboundServer.spawnPlanet != null)
{
MemoryStream packetWarp = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packetWarp);
packetWrite.WriteBE((uint)WarpType.MoveShip);
packetWrite.Write(StarryboundServer.spawnPlanet);
packetWrite.WriteStarString("");
client.sendServerPacket(Packet.WarpCommand, packetWarp.ToArray());
this.client.sendCommandMessage("Teleporting your ship to the spawn planet.");
return true;
}
this.client.sendCommandMessage("Spawn planet not enabled.");
return false;
}
示例8: doProcess
public override bool doProcess(string[] args)
{
if (!hasPermission()) { permissionError(); return false; }
string player = string.Join(" ", args).Trim();
WorldCoordinate loc = this.player.loc;
if (player == null || player.Length < 1)
{
showHelpText();
return false;
}
else
{
Client target = StarryboundServer.getClient(player);
if (target != null)
{
loc = target.playerData.loc;
if (loc == null)
{
this.client.sendCommandMessage("Unable to find an exact location for " + player + ".");
return false;
}
this.client.sendCommandMessage("Warping ship to " + player + " [" + loc.ToString() + "]");
}
else
{
this.client.sendCommandMessage("Player '" + player + "' not found.");
return false;
}
}
MemoryStream packetWarp = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packetWarp);
packetWrite.WriteBE((uint)WarpType.MoveShip);
packetWrite.Write(loc);
packetWrite.WriteStarString("");
client.sendServerPacket(Packet.WarpCommand, packetWarp.ToArray());
return true;
}
示例9: doProcess
public override bool doProcess(string[] args)
{
if (!hasPermission()) { permissionError(); return false; }
if (args.Length < 2) { showHelpText(); return false; }
string item = args[0];
uint count = Convert.ToUInt32(args[1]) + 1;
if (String.IsNullOrEmpty(item) || count < 1) { showHelpText(); return false; }
MemoryStream packet = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packet);
packetWrite.WriteStarString(item);
packetWrite.WriteVarUInt32(count);
packetWrite.Write((byte)0); //0 length Star::Variant
client.sendClientPacket(Packet.GiveItem, packet.ToArray());
client.sendCommandMessage("Gave you " + (count - 1) + " " + item);
return true;
}
示例10: onSend
public override void onSend()
{
if (tmpArray.Count < 5) return;
MemoryStream packet = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packet);
ChatReceiveContext sContext = (ChatReceiveContext)tmpArray["context"];
string sWorld = (string)tmpArray["world"];
uint sClientID = (uint)tmpArray["entityID"]; // Player entity ID
string sName = (string)tmpArray["name"]; // Name
string sMessage = (string)tmpArray["message"]; // Message
packetWrite.Write((byte)sContext);
packetWrite.WriteStarString(sWorld);
packetWrite.WriteBE(sClientID);
packetWrite.WriteStarString(sName);
packetWrite.WriteStarString(sMessage);
this.client.sendClientPacket(Packet.ChatReceive, packet.ToArray());
}
示例11: run
//.........这里部分代码省略.........
else if (curState == ClientState.PendingAuthentication && packetID != Packet.HandshakeResponse)
{
this.client.rejectPreConnected("Violated PendingAuthentication protocol state with " + packetID);
return;
}
else if (curState == ClientState.PendingConnectResponse)
{
int startTime = Utils.getTimestamp();
while (true)
{
if (this.client.state == ClientState.Connected) break;
if (Utils.getTimestamp() > startTime + StarryboundServer.config.connectTimeout)
{
this.client.rejectPreConnected("Connection Failed: Server did not respond in time.");
return;
}
}
}
}
#endregion
if (packetID == Packet.ChatSend)
{
returnData = new Packet11ChatSend(this.client, packetData, this.direction).onReceive();
}
else if (packetID == Packet.ClientConnect)
{
this.client.state = ClientState.PendingAuthentication;
returnData = new Packet7ClientConnect(this.client, packetData, this.direction).onReceive();
MemoryStream packet = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packet);
passwordSalt = Utils.GenerateSecureSalt();
packetWrite.WriteStarString("");
packetWrite.WriteStarString(passwordSalt);
packetWrite.WriteBE(StarryboundServer.config.passwordRounds);
this.client.sendClientPacket(Packet.HandshakeChallenge, packet.ToArray());
}
else if (packetID == Packet.HandshakeResponse)
{
string claimResponse = packetData.ReadStarString();
string passwordHash = packetData.ReadStarString();
string verifyHash = Utils.StarHashPassword(StarryboundServer.config.proxyPass, this.client.playerData.account + passwordSalt, StarryboundServer.config.passwordRounds);
if (passwordHash != verifyHash)
{
this.client.rejectPreConnected("Your password was incorrect.");
return;
}
this.client.state = ClientState.PendingConnectResponse;
returnData = false;
}
else if (packetID == Packet.WarpCommand)
{
WarpType cmd = (WarpType)packetData.ReadUInt32BE();
WorldCoordinate coord = packetData.ReadStarWorldCoordinate();
string player = packetData.ReadStarString();
if (cmd == WarpType.WarpToPlayerShip)
{
Client target = StarryboundServer.getClient(player);
if (target != null)
{
if (!this.client.playerData.canAccessShip(target.playerData))
{
this.client.sendChatMessage("^#5dc4f4;You cannot access this player's ship due to their ship access settings.");
示例12: run
//.........这里部分代码省略.........
#region Handle Client Packets
{
#region Protocol State Security
ClientState curState = this.mParent.clientState;
if (curState != ClientState.Connected)
{
if (curState == ClientState.PendingConnect && packetID != Packet.ClientConnect)
{
this.mParent.forceDisconnect("Violated PendingConnect protocol state with " + packetID);
}
else if (curState == ClientState.PendingAuthentication && packetID != Packet.HandshakeResponse)
{
this.mParent.forceDisconnect("Violated PendingAuthentication protocol state with " + packetID);
}
else if (curState == ClientState.PendingConnectResponse)
{
this.mParent.forceDisconnect("Violated PendingConnectResponse protocol state with " + packetID);
}
}
#endregion
if (packetID == Packet.ChatSend)
{
returnData = new Packet11ChatSend(this.mParent, packetData, this.mDirection).onReceive();
}
else if (packetID == Packet.ClientConnect)
{
this.mParent.clientState = ClientState.PendingAuthentication;
returnData = new Packet7ClientConnect(this.mParent, packetData, this.mDirection).onReceive();
MemoryStream packet = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packet);
passwordSalt = Utils.GenerateSecureSalt();
packetWrite.WriteStarString("");
packetWrite.WriteStarString(passwordSalt);
packetWrite.WriteBE(StarryboundServer.config.passwordRounds);
this.mParent.sendClientPacket(Packet.HandshakeChallenge, packet.ToArray());
}
else if (packetID == Packet.HandshakeResponse)
{
string claimResponse = packetData.ReadStarString();
string passwordHash = packetData.ReadStarString();
string verifyHash = Utils.StarHashPassword(StarryboundServer.config.proxyPass, this.mParent.playerData.account + passwordSalt, StarryboundServer.config.passwordRounds);
if (passwordHash != verifyHash)
{
this.mParent.rejectPreConnected("Your password was incorrect.");
}
this.mParent.clientState = ClientState.PendingConnectResponse;
returnData = false;
}
else if (packetID == Packet.WarpCommand)
{
uint warp = packetData.ReadUInt32BE();
WorldCoordinate coord = packetData.ReadStarWorldCoordinate();
string player = packetData.ReadStarString();
WarpType cmd = (WarpType)warp;
if (cmd == WarpType.WarpToHomePlanet)
{
this.mParent.playerData.inPlayerShip = false;
}
else if (cmd == WarpType.WarpToOrbitedPlanet)
{
this.mParent.playerData.inPlayerShip = false;
}
示例13: doProcess
public override bool doProcess(string[] args)
{
if (!hasPermission()) { permissionError(); return false; }
string player = string.Join(" ", args).Trim();
uint warp;
if (player == null || player.Length < 1)
{
this.client.sendCommandMessage("Teleporting to your ship.");
player = "";
warp = (uint)WarpType.WarpToOwnShip;
}
else
{
if (!hasPermission(true)) { permissionError(2); return false; }
Client target = StarryboundServer.getClient(player);
if (target != null)
{
PlayerData targetPlayer = target.playerData;
if (!this.player.canAccessShip(targetPlayer))
{
this.client.sendCommandMessage("You cannot access this player's ship due to their ship's access settings.");
return false;
}
this.client.sendCommandMessage("Teleporting to " + player + " ship!");
warp = (uint)WarpType.WarpToPlayerShip;
}
else
{
this.client.sendCommandMessage("Player '" + player + "' not found.");
return false;
}
}
MemoryStream packetWarp = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packetWarp);
packetWrite.WriteBE(warp);
packetWrite.Write(new WorldCoordinate());
packetWrite.WriteStarString(player);
client.sendServerPacket(Packet.WarpCommand, packetWarp.ToArray());
return true;
}