本文整理汇总了C#中Packet.ReadUInt64方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.ReadUInt64方法的具体用法?C# Packet.ReadUInt64怎么用?C# Packet.ReadUInt64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.ReadUInt64方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleBRSFriendNotify
private void HandleBRSFriendNotify(TcpSession session, Packet p)
{
var accID = p.ReadUInt64();
var accepted = p.ReadInt32() > 0;
var nickname = p.ReadCStringBuffer(31);
//_logger.Debug("-C_ADD_FRIEND_REQ- ID: {0} Nickname: {1}", accID, nickname);
Player plr;
if (!_players.TryGetValue(session.Guid, out plr))
{
session.StopListening();
return;
}
Packet ack;
var plrFromRequest = _players.GetPlayerByID(accID);
if (plrFromRequest == null) return;
if (accepted)
{
SendBRSFriendNotify(plr, plrFromRequest, EFriendNotify.Accepted);
SendBRSFriendNotify(plrFromRequest, plr, EFriendNotify.Accepted);
}
else
{
SendBRSFriendNotify(plr, plrFromRequest, EFriendNotify.Denied);
SendBRSFriendNotify(plr, plrFromRequest, EFriendNotify.DeleteRelation);
SendBRSFriendNotify(plrFromRequest, plr, EFriendNotify.DeleteRelation);
}
var friend = plrFromRequest.FriendList.FirstOrDefault(f => f.ID == plr.AccountID);
if (friend == null) return;
if (accepted)
{
friend.Accepted = true;
GameDatabase.Instance.UpdateFriend(plrFromRequest.AccountID, friend.ID, friend.Accepted);
var newFriend = new Friend()
{
ID = plrFromRequest.AccountID,
Nickname = plrFromRequest.Nickname,
Accepted = true
};
plr.FriendList.Add(newFriend);
GameDatabase.Instance.AddFriend(plr.AccountID, newFriend.ID, newFriend.Nickname, newFriend.Accepted);
}
else
{
plrFromRequest.FriendList.Remove(friend);
GameDatabase.Instance.RemoveFriend(plrFromRequest.AccountID, friend.ID);
}
}
示例2: HandleGetData
private void HandleGetData(TcpSession session, Packet p)
{
var accID = p.ReadUInt64();
//_logger.Debug("-C_GET_DATA_REQ- ID: {0}", accID);
var ack = new Packet(EChatPacket.SGetDataAck);
ack.Write(accID); // accid
Player sender;
if (!_players.TryGetValue(session.Guid, out sender))
{
session.StopListening();
return;
}
var plr = _players.GetPlayerByID(accID);
if(plr == null)
{
ack.Write((byte)0x01);
session.Send(ack);
return;
}
ack.Write((byte)0x00); // result code
ack.WriteChatUserData(plr, true);
session.Send(ack);
}
示例3: HandleRepairItem
private void HandleRepairItem(TcpSession session, Packet p)
{
var itemID = p.ReadUInt64();
Player player;
if (!Players.TryGetValue(session.Guid, out player))
{
session.StopListening();
return;
}
var itm = player.Inventory.FirstOrDefault(i => i.ID == itemID);
if (itm == null)
{
session.StopListening();
return;
}
itm.Energy = itm.MaxEnergy;
var ack = new Packet(EGamePacket.SRepairItemAck);
ack.Write((byte)0);
ack.Write(itemID);
session.Send(ack);
player.PEN -= 0; // repair cost
player.UpdateMoney();
}
示例4: HandleAddFriend
private void HandleAddFriend(TcpSession session, Packet p)
{
var accID = p.ReadUInt64();
var nickname = p.ReadCStringBuffer(31);
//_logger.Debug("-C_ADD_FRIEND_REQ- ID: {0} Nickname: {1}", accID, nickname);
Player plr;
if (!_players.TryGetValue(session.Guid, out plr))
{
session.StopListening();
return;
}
var ack = new Packet(EChatPacket.SAddFriendAck);
ack.Write(accID);
var plrToRequest = _players.GetPlayerByID(accID);
if (plrToRequest == null)
{
ack.Write((byte)EAddFriendResult.DoenstExist);
}
else
{
var friend = plr.FriendList.FirstOrDefault(f => f.ID == accID);
if (friend == null)
{
plr.FriendList.Add(new Friend() { ID = accID, Nickname = nickname, Accepted = false });
GameDatabase.Instance.AddFriend(plr.AccountID, accID, nickname);
SendBRSFriendNotify(plr, plrToRequest, EFriendNotify.Request);
ack.Write((byte)EAddFriendResult.MadeRequest);
}
else
{
if (friend.Accepted)
ack.Write((byte)EAddFriendResult.AlreadyInList);
else
ack.Write((byte)EAddFriendResult.AlreadyRequested);
}
}
ack.WriteStringBuffer(nickname, 31);
session.Send(ack);
}
示例5: HandleEventMessage
private void HandleEventMessage(TcpSession session, Packet p)
{
var eventID = p.ReadByte();
var accID = p.ReadUInt64();
var unk1 = p.ReadUInt32();
var unk2 = p.ReadUInt16();
var strLen = p.ReadUInt32();
var str = (strLen > 0) ? p.ReadCString() : string.Empty;
//_logger.Debug("-C_EVENTMESSAGE_REQ- EventID: {0} AccID: {1} Unk1: {2} Unk2: {3} String: {4}", eventID, accID, unk1, unk2, str);
var player = Players.GetPlayerByID(accID);
Player sender;
if (!Players.TryGetValue(session.Guid, out sender))
{
session.StopListening();
return;
}
if (sender.Room == null)
return;
var room = sender.Room;
if (player != null && player.State == EPlayerState.Lobby && eventID == (byte)EPlayerEventMessage.StartGame && room.State != EGameRuleState.Waiting)
{
player.State = player.GameMode == EPlayerGameMode.Normal ? EPlayerState.Alive : EPlayerState.Spectating;
player.GameScore.JoinTime = DateTime.Now;
room.BroadcastBriefing();
}
var ack = new Packet(EGamePacket.SEventMessageAck);
ack.Write(eventID);
ack.Write(accID);
ack.Write(unk1);
ack.Write(unk2);
ack.Write(strLen);
if (strLen > 0)
ack.Write(str);
room.Broadcast(ack);
}
示例6: HandleRefundItem
private void HandleRefundItem(TcpSession session, Packet p)
{
var itemID = p.ReadUInt64();
Player player;
if (!Players.TryGetValue(session.Guid, out player))
{
session.StopListening();
return;
}
var itm = player.Inventory.FirstOrDefault(i => i.ID == itemID);
if (itm == null)
{
session.StopListening();
return;
}
player.Inventory.Remove(itm);
GameDatabase.Instance.RemoveItem(itemID);
var ack = new Packet(EGamePacket.SRefundItemAck);
ack.Write((byte)0);
ack.Write(itemID);
session.Send(ack);
player.PEN += itm.SellPrice;
player.UpdateMoney();
}
示例7: HandleRoomKick
private void HandleRoomKick(TcpSession session, Packet p)
{
var accID = p.ReadUInt64();
//_logger.Debug("-C_ROOM_KICK_REQ- ID: {0}", accID);
Player master;
if (!Players.TryGetValue(session.Guid, out master))
{
session.StopListening();
return;
}
var target = Players.GetPlayerByID(accID);
if (master.Room == null || target.Room == null || master.Room.TunnelID != target.Room.TunnelID)
return;
var room = master.Room;
if (master.AccountID != room.MasterID || master.State != EPlayerState.Lobby) // kick hack...
return;
room.Leave(target, 1);
}
示例8: HandleSetDataRequest
private void HandleSetDataRequest(TcpSession session, Packet p)
{
//_logger.Debug("-C_SETDATA_REQ-");
Player plr;
if (!_players.TryGetValue(session.Guid, out plr))
{
session.StopListening();
return;
}
p.ReadUInt16(); // unk
p.ReadUInt64(); // accID
plr.ServerID = p.ReadUInt16();
var channelID = p.ReadInt16();
var roomID = p.ReadInt32();
if(roomID == -1)
roomID = 0;
if (channelID == -1)
channelID = 0;
plr.Room = new Room(null, EServerType.Chat) { ID = (uint)roomID };
plr.CommunityByte = p.ReadByte();
p.ReadUInt32(); // total exp
p.ReadBytes(32); // td/dm info
plr.AllowCombiRequest = (EAllowCommunityRequest)p.ReadByte();
plr.AllowFriendRequest = (EAllowCommunityRequest)p.ReadByte();
plr.AllowInvite = (EAllowCommunityRequest)p.ReadByte();
plr.AllowInfoRequest = (EAllowCommunityRequest)p.ReadByte();
plr.CommunityData = p.ReadBytes(41);
Channel channel;
if (!_channels.TryGetValue((ushort)channelID, out channel))
return;
if (plr.Channel == null && channelID > 0) // join
{
var ack = new Packet(EChatPacket.SChannelPlayerListInfoAck);
ack.Write((uint)channel.ID);
ack.Write(channel.Players.Count);
foreach (var player in channel.Players.Values)
ack.WriteChatUserData(player);
session.Send(ack);
channel.Join(plr);
}
else if(channelID == 0) // leave
{
if(plr.Channel != null)
plr.Channel.Leave(plr);
}
else // update
{
var ack = new Packet(EChatPacket.SChannelPlayerListInfoAck);
ack.Write((uint)channel.ID);
ack.Write(channel.Players.Count);
foreach (var player in channel.Players.Values)
ack.WriteChatUserData(player);
channel.Broadcast(ack);
}
}
示例9: HandleSuicide
private void HandleSuicide(TcpSession session, Packet p)
{
var accID = p.ReadUInt64();
var unk1 = p.ReadUInt64(); // not sure
var unk2 = p.ReadUInt32(); // weapon id?? makes no sense for suicide oO
//_logger.Debug("-C_SCORE_SUICIDE_REQ- ID: {0} Unk1: {1} Unk2: {2}", accID, unk1, unk2);
var player = Players.GetPlayerByID(accID);
if (player == null || player.Room == null)
return;
var room = player.Room;
if (room.TDWaiting || room.TimeState == EGameTimeState.HalfTime)
return;
if (room.GameRule == EGameRule.Deathmatch)
((DMGameScore)player.GameScore).Deaths++;
var ack = new Packet(EGamePacket.SScoreSuicideAck);
ack.Write(accID);
ack.Write(unk1);
ack.Write(unk2);
room.Broadcast(ack);
}
示例10: HandleTouchdown
async private void HandleTouchdown(TcpSession session, Packet p)
{
var accID = p.ReadUInt64();
//_logger.Debug("-SC_TOUCHDOWN- ID: {0}", accID);
var player = Players.GetPlayerByID(accID);
if (player == null)
return;
Player sender;
if (!Players.TryGetValue(session.Guid, out sender))
{
session.StopListening();
return;
}
if (sender.Room == null || player.Room == null || sender.Room.TunnelID != player.Room.TunnelID || sender.Room.GameRule != EGameRule.Touchdown)
return;
var room = sender.Room;
var team = player.Team;
Player assist = null;
switch (team)
{
case ETeam.Alpha:
{
room.LastAlphaTD = DateTime.Now;
var ts = DateTime.Now - room.LastAlphaFumbi;
if (ts.TotalSeconds < 10) // 10 seconds timer for td assist?
assist = room.Players.GetPlayerByID(room.LastAlphaFumbiID);
}
break;
case ETeam.Beta:
{
room.LastBetaTD = DateTime.Now;
var ts = DateTime.Now - room.LastBetaFumbi;
if (ts.TotalSeconds < 10) // 10 seconds timer for td assist?
assist = room.Players.GetPlayerByID(room.LastBetaFumbiID);
}
break;
}
var tdGame = (TDGameScore)player.GameScore;
tdGame.TotalPoints += 10;
tdGame.TDScore++;
var ack = new Packet(EGamePacket.SCTouchdown);
ack.Write((byte)0x00); // unk | 0 - 3
room.Broadcast(ack);
if (assist == null)
{
ack = new Packet(EGamePacket.SScoreTouchdownAck);
ack.Write(accID);
room.Broadcast(ack);
}
else
{
tdGame = (TDGameScore)assist.GameScore;
tdGame.TotalPoints += 5;
tdGame.TDAssists++;
ack = new Packet(EGamePacket.SScoreTouchdownAssistAck);
ack.Write((uint)0); // unk
ack.Write(player.AccountID);
ack.Write(assist.AccountID);
room.Broadcast(ack);
}
room.TDWaiting = true;
if (player.Team == ETeam.Alpha)
{
room.ScoreAlpha++;
room.BroadcastEventMessage(EPlayerEventMessage.TouchdownAlpha);
}
else
{
room.ScoreBeta++;
room.BroadcastEventMessage(EPlayerEventMessage.TouchdownBeta);
}
await Task.Delay(10000); // wait 10 seconds after touchdown
room.TDWaiting = false;
if (room.TimeState == EGameTimeState.HalfTime || room.State != EGameRuleState.Playing)
return;
room.BroadcastEventMessage(EPlayerEventMessage.ResetRound);
}
示例11: HandleReboundFumbi
private void HandleReboundFumbi(TcpSession session, Packet p)
{
var newAccID = p.ReadUInt64();
var oldAccID = p.ReadUInt64();
//_logger.Debug("-C_REBOUND_FUMBI_REQ- New ID: {0} Old ID: {1}", newAccID, oldAccID);
var ack = new Packet(EGamePacket.SReboundFumbiAck);
Player sender;
if (!Players.TryGetValue(session.Guid, out sender))
{
session.StopListening();
return;
}
if (sender.Room == null)
return;
var room = sender.Room;
if (room.GameRule != EGameRule.Touchdown)
return;
var newPlr = Players.GetPlayerByID(newAccID);
var oldPlr = Players.GetPlayerByID(oldAccID);
if (newPlr == null || newPlr.Room == null || room.TDWaiting || sender.Room.TunnelID != newPlr.Room.TunnelID)
return;
if (oldAccID != 0 && (oldPlr == null || oldPlr.Room == null || oldPlr.Room.TunnelID != sender.Room.TunnelID))
return;
newPlr.GameScore.TotalPoints += 2;
if (oldAccID != 0 && oldPlr.Team == ETeam.Alpha)
{
room.LastAlphaFumbi = DateTime.Now;
room.LastAlphaFumbiID = oldAccID;
}
else if (oldAccID != 0 && oldPlr.Team == ETeam.Beta)
{
room.LastBetaFumbi = DateTime.Now;
room.LastBetaFumbiID = oldAccID;
}
ack.Write(newAccID);
ack.Write(oldAccID);
room.Broadcast(ack);
}
示例12: HandleScoreDefenseAssist
private void HandleScoreDefenseAssist(TcpSession session, Packet p)
{
var murderAccID = p.ReadUInt64();
var unk1 = p.ReadUInt64(); // not sure
var assistAccID = p.ReadUInt64();
var unk2 = p.ReadUInt64(); // not sure
var weaponID = p.ReadUInt32();
var victimAccID = p.ReadUInt64();
var unk3 = p.ReadUInt64(); // not sure
//_logger.Debug("-C_SCORE_DEFENSE_ASSIST_REQ- Murder: {0} Assist: {1} Target: {2} Weapon: {3}", murderAccID, assistAccID, victimAccID, weaponID);
var murder = Players.GetPlayerByID(murderAccID);
var assist = Players.GetPlayerByID(assistAccID);
var victim = Players.GetPlayerByID(victimAccID);
if (murder == null || victim == null || murder.Room == null || victim.Room == null || assist == null || assist.Room == null)
return;
if (murder.Room.TunnelID != victim.Room.TunnelID || murder.Room.TunnelID != assist.Room.TunnelID)
return;
var room = murder.Room;
if (room.TDWaiting || room.TimeState == EGameTimeState.HalfTime)
return;
if (room.GameRule != EGameRule.Touchdown)
return;
var tdGame = (TDGameScore)murder.GameScore;
tdGame.TotalPoints += 4;
tdGame.Offense++;
tdGame = (TDGameScore)assist.GameScore;
tdGame.TotalPoints += 2;
tdGame.OffenseAssists++;
var ack = new Packet(EGamePacket.SScoreDefenseAssistAck);
ack.Write(murderAccID);
ack.Write(unk1);
ack.Write(assistAccID);
ack.Write(unk2);
ack.Write(weaponID);
ack.Write(victimAccID);
ack.Write(unk3);
ack.Write((byte)0x00);
room.Broadcast(ack);
}
示例13: HandleScoreKillAssist
private void HandleScoreKillAssist(TcpSession session, Packet p)
{
var murderAccID = p.ReadUInt64();
var unk1 = p.ReadUInt64(); // not sure
var assistAccID = p.ReadUInt64();
var unk2 = p.ReadUInt64(); // not sure
var weaponID = p.ReadUInt32();
var victimAccID = p.ReadUInt64();
var unk3 = p.ReadUInt64(); // not sure
//_logger.Debug("-C_SCORE_KILL_ASSIST- Murder: {0} Assist: {1} Target: {2} Weapon: {3}", murderAccID, assistAccID, victimAccID, weaponID);
var murder = Players.GetPlayerByID(murderAccID);
var assist = Players.GetPlayerByID(assistAccID);
var victim = Players.GetPlayerByID(victimAccID);
if (murder == null || victim == null || murder.Room == null || victim.Room == null || assist == null || assist.Room == null)
return;
if (murder.Room.TunnelID != victim.Room.TunnelID || murder.Room.TunnelID != assist.Room.TunnelID)
return;
var room = murder.Room;
if (room.TDWaiting || room.TimeState == EGameTimeState.HalfTime)
return;
switch (room.GameRule)
{
case EGameRule.Touchdown:
var tdGame = (TDGameScore)murder.GameScore;
tdGame.TotalPoints += 2;
tdGame.Kills++;
tdGame = (TDGameScore)assist.GameScore;
tdGame.TotalPoints += 1;
tdGame.KillAssists++;
break;
case EGameRule.Deathmatch:
var dmGame = (DMGameScore)murder.GameScore;
dmGame.TotalPoints += 2;
dmGame.Kills++;
dmGame = (DMGameScore)assist.GameScore;
dmGame.TotalPoints += 1;
dmGame.KillAssists++;
((DMGameScore)victim.GameScore).Deaths++;
if (murder.Team == ETeam.Alpha)
room.ScoreAlpha++;
else
room.ScoreBeta++;
break;
}
var ack = new Packet(EGamePacket.SScoreKillAssistAck);
ack.Write(murderAccID);
ack.Write(unk1);
ack.Write(assistAccID);
ack.Write(unk2);
ack.Write(weaponID);
ack.Write(victimAccID);
ack.Write(unk3);
ack.Write((byte)0x00);
room.Broadcast(ack);
}
示例14: HandleLoginRequest
private void HandleLoginRequest(TcpSession session, Packet p)
{
var ip = session.Client.Client.RemoteEndPoint as IPEndPoint;
var accID = p.ReadUInt64();
var nickname = p.ReadCString();
_logger.Info("-CLoginReq- User: {0} ID: {1}", nickname, accID);
var ack = new Packet(EChatPacket.SLoginAck);
if (accID == 0 || !ValidateSession(accID, nickname, ip.Address) || _players.GetPlayerByID(accID) != null /* prevent multiple logins! */)
{
ack.Write((uint)1); // error code
session.Send(ack);
session.StopListening();
return;
}
var plr = GameDatabase.Instance.GetPlayer(accID);
plr.Session = session;
_players.TryAdd(session.Guid, plr);
ack.Write((uint)0); // error code
session.Send(ack);
}
示例15: HandleRoomChangeItems
private void HandleRoomChangeItems(TcpSession session, Packet p)
{
var accID = p.ReadUInt64();
var skill = p.ReadUInt32();
var skill2 = p.ReadUInt32(); // alpha thing -> removed in beta
var weapon1 = p.ReadUInt32();
var weapon2 = p.ReadUInt32();
var weapon3 = p.ReadUInt32();
var unk = p.ReadBytes(27);
//_logger.Debug("-C_ROOM_CHANGE_ITEMS_REQ-");
Player plr;
if (!Players.TryGetValue(session.Guid, out plr))
{
session.StopListening();
return;
}
var room = plr.Room;
if (room == null)
return;
// Slot freeze bug fix
if (skill2 != 0)
skill = skill2;
var ack = new Packet(EGamePacket.SRoomChangeItemsAck);
ack.Write(accID);
ack.Write(skill);
ack.Write(0);
ack.Write(weapon1);
ack.Write(weapon2);
ack.Write(weapon3);
ack.Write(unk);
room.Broadcast(ack, plr.AccountID);
}