// Request private static bool SFOnDataWritePatch(ref IMessage __0) { ISFSObject raw = __0.Content; bool log = true; // System if (raw.GetByte("c") == 0) { } // Game else if (raw.GetByte("c") == 1) { ISFSObject p = raw.GetSFSObject("p"); // Player movements string c = p.GetUtfString("c"); if (c == "spawnMonster") { ISFSObject p2 = p.GetSFSObject("p"); p2.PutBool("sp", true); } if (c == "UPP" || c == "playerAction.CM") { log = false; } } if (log) { Logger.LogLine($"Sending request (ID {Convert.ToInt32(raw.GetShort("a"))}):\n{raw.GetDump()}", ConsoleColor.Green); } return(true); }
public static CombatQuad newFromSFSObject(ISFSObject sfso) { CombatQuad combatQuad = new CombatQuad(sfso.GetByte("id")); combatQuad.posx = sfso.GetShort("px"); combatQuad.posy = sfso.GetShort("py"); combatQuad.energyLevel = sfso.GetByte("el"); combatQuad.bulletCount = sfso.GetByte("bc"); return(combatQuad); }
// Response private static bool SFDispatchRequestPatch(ref ISFSObject __0) { ISFSObject raw = __0; bool log = true; // System if (raw.GetByte("c") == 0) { ISFSObject p = raw.GetSFSObject("p"); // Player movements int a = Convert.ToInt32(raw.GetShort("a")); if (a == 1000 || a == 1002 || a == 1004 || a == 11 || a == 12) { log = false; } } // Game else if (raw.GetByte("c") == 1) { ISFSObject p = raw.GetSFSObject("p"); if (p.GetUtfString("c") == "GameStart") { ISFSObject p2 = p.GetSFSObject("p"); //NetworkMonster monster1 = p2.GetSFSArray("teamMonsters").GetClass(0) as NetworkMonster; //monster1.luma = true; //monster1.Nickname = "gay"; //p2.PutUtfString("nck", "nitro."); //p2.PutInt("tid", 1337); } // Player movements int a = Convert.ToInt32(raw.GetShort("a")); //if (a == 1000 || a == 1002 || a == 1004 || a == 11) log = false; if (a == 13) { string c = p.GetUtfString("c"); if (c == "UPP" || c.StartsWith("PA.")) { log = false; } } } if (log) { Logger.LogLine($"Receiving message (ID {Convert.ToInt32(raw.GetShort("a"))}):\n{raw.GetDump()}", ConsoleColor.Cyan); } return(true); }
private void DispatchRequest(ISFSObject requestObject) { IMessage message = new Message(); if (requestObject.IsNull(CONTROLLER_ID)) { throw new SFSCodecError("Request rejected: No Controller ID in request!"); } if (requestObject.IsNull(ACTION_ID)) { throw new SFSCodecError("Request rejected: No Action ID in request!"); } message.Id = Convert.ToInt32(requestObject.GetShort(ACTION_ID)); message.Content = requestObject.GetSFSObject(PARAM_ID); message.IsUDP = requestObject.ContainsKey(UDP_PACKET_ID); if (message.IsUDP) { message.PacketId = requestObject.GetLong(UDP_PACKET_ID); } int @byte = requestObject.GetByte(CONTROLLER_ID); IController controller = bitSwarm.GetController(@byte); if (controller == null) { throw new SFSError("Cannot handle server response. Unknown controller, id: " + @byte); } controller.HandleMessage(message); }
public static VoiceChatPacket GetVoicePacketFromMsg(ISFSObject msgObj) { VoiceChatPacket packet = new VoiceChatPacket(); packet.Compression = (VoiceChatCompression)msgObj.GetByte("c"); packet.Length = msgObj.GetInt("l"); Sfs2X.Util.ByteArray t = msgObj.GetByteArray("d"); packet.Data = t.Bytes; packet.NetworkId = msgObj.GetInt("i"); return(packet); }
private LocomotionActionEvent locomotionActionEventFromProps(int playerId, ISFSObject props) { LocomotionActionEvent result = default(LocomotionActionEvent); result.SessionId = getSessionId(playerId); result.Type = (LocomotionAction)props.GetByte("a"); result.Position = SmartFoxGameServerClientShared.deserializeVec3(props, "p"); result.Timestamp = props.GetLong("t"); if (props.ContainsKey("d")) { result.Direction = SmartFoxGameServerClientShared.deserializeVec3(props, "d"); } if (props.ContainsKey("v")) { result.Velocity = SmartFoxGameServerClientShared.deserializeVec3(props, "v"); } if (props.ContainsKey("o")) { result.Object = mt.JsonService.Deserialize <ActionedObject>(props.GetUtfString("o")); } return(result); }