Ejemplo n.º 1
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client)
        {
            int    callBackID = 0, playerID = 0;
            String section, entry;

            stream.Read(out callBackID);
            stream.Read(out playerID);
            stream.Read(out section);
            stream.Read(out entry);

            String value = "";

            try
            {
                value = zCOption.GetOption(Process.ThisProcess()).getEntryValue(section, entry);
            }
            catch (Exception ex) {}

            stream.Reset();
            stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM);
            stream.Write((byte)NetworkID.ReadIniEntryMessage);
            stream.Write(callBackID);
            stream.Write(playerID);
            stream.Write(section);
            stream.Write(entry);
            stream.Write(value);

            Program.client.client.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS, true);
        }
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int casterID = 0;

            stream.Read(out casterID);


            Vob      casterVob = null;
            NPCProto caster    = null;

            sWorld.VobDict.TryGetValue(casterID, out casterVob);


            if (casterVob == null)
            {
                throw new Exception("Caster was not found!");
            }
            if (!(casterVob is NPCProto))
            {
                throw new Exception("Caster was not a npcproto " + casterVob);
            }
            caster = (NPCProto)casterVob;



            Write(caster, packet.guid);
        }
        private void OnDisconnection(RakNet.Packet packet, RakPeerInterface server, string reason)
        {
            logger.Trace("Disconnected from endpoint {0}", packet.systemAddress);
            var c = RemoveConnection(packet.guid);

            server.DeallocatePacket(packet);

            _handler.CloseConnection(c, reason);

            var action = ConnectionClosed;

            if (action != null)
            {
                action(c);
            }

            if (c != null)
            {
                var a = c.ConnectionClosed;
                if (a != null)
                {
                    a(reason);
                }
            }
        }
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int vobCount = 0;

            stream.Read(out vobCount);

            List <Vob> vobList = new List <Vob>();

            for (int i = 0; i < vobCount; i++)
            {
                int   vobID = 0;
                Vec3f pos, dir;

                stream.Read(out vobID);
                stream.Read(out pos);
                stream.Read(out dir);

                if (vobID == 0 || !sWorld.VobDict.ContainsKey(vobID))
                {
                    throw new Exception("Vob not found!");
                }
                Vob vob = sWorld.VobDict[vobID];
                vob.Position  = pos;
                vob.Direction = dir;

                vobList.Add(vob);
            }


            Write(vobList, packet.systemAddress);
        }
Ejemplo n.º 5
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int   plID = 0;
            short anim = 0;

            stream.Read(out plID);
            stream.Read(out anim);

            if (plID == 0 || !sWorld.VobDict.ContainsKey(plID))
            {
                throw new Exception("Vob not found!");
            }
            Vob vob = sWorld.VobDict[plID];

            if (!(vob is NPCProto))
            {
                throw new Exception("Vob is not an NPC!");
            }

            short oldAnim = ((NPCProto)vob).Animation;

            ((NPCProto)vob).Animation = anim;


            Write((NPCProto)vob, packet.guid);

            Scripting.Objects.Character.NPCProto.isOnAnimation(((NPCProto)vob).ScriptingNPC, anim, oldAnim);
        }
        private IConnection OnConnection(RakNet.Packet packet, RakPeerInterface server)
        {
            logger.Trace("Connected to endpoint {0}", packet.systemAddress);

            IConnection c   = CreateNewConnection(packet.guid, server);
            var         ctx = new PeerConnectedContext {
                Connection = c
            };
            var pconnected = _connectionHandler.PeerConnected;

            if (pconnected != null)
            {
                pconnected(ctx);
            }

            c = ctx.Connection;
            server.DeallocatePacket(packet);
            _handler.NewConnection(c);
            var action = ConnectionOpened;

            if (action != null)
            {
                action(c);
            }

            c.SendSystem((byte)MessageIDTypes.ID_CONNECTION_RESULT, s => s.Write(BitConverter.GetBytes(c.Id), 0, 8));
            return(c);
        }
Ejemplo n.º 7
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            String heroName    = "";
            String driveString = "";
            String macString   = "";


            Vec3f pos = new Vec3f();

            stream.Read(out heroName);
            stream.Read(out driveString);
            stream.Read(out macString);
            stream.Read(out pos);


            Player player = new Player(packet.guid, heroName);

            player.DriveString = driveString;
            player.MacString   = macString;
            player.Position    = pos;
            sWorld.addVob(player);

            Write(player);
            CreateVobMessage.Write(player, packet.guid);

            Scripting.GUI.View.SendToPlayer(player);
            Scripting.Objects.Character.Player.isOnPlayerConnect((GUC.Server.Scripting.Objects.Character.Player)player.ScriptingNPC);
        }
Ejemplo n.º 8
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client)
        {
            int    callBackID = 0, playerID = 0;
            String md5File;

            stream.Read(out callBackID);
            stream.Read(out playerID);
            stream.Read(out md5File);

            String value = "";

            try
            {
                md5File = Path.GetFullPath(md5File);
                String minName = new DirectoryInfo(StartupState.getSystemPath()).Parent.FullName;
                if (md5File.StartsWith(minName))
                {
                    if (File.Exists(md5File))
                    {
                        value = FileMd5(md5File);
                    }
                }
            }
            catch (Exception ex) {}

            stream.Reset();
            stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM);
            stream.Write((byte)NetworkID.ReadMd5Message);
            stream.Write(callBackID);
            stream.Write(playerID);
            stream.Write(md5File);
            stream.Write(value);

            Program.client.client.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS, true);
        }
Ejemplo n.º 9
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int itemID = 0;
            int amount = 0;

            stream.Read(out itemID);
            stream.Read(out amount);


            if (itemID == 0 || !sWorld.VobDict.ContainsKey(itemID))
            {
                throw new Exception("Vob not found!");
            }
            Vob vob = sWorld.VobDict[itemID];

            if (!(vob is Item))
            {
                throw new Exception("Vob is not an item");
            }

            Item item = (Item)vob;

            if (item.Container is NPCProto)
            {
                NPCProto proto = (NPCProto)item.Container;
                proto.removeItem(item, amount);

                Scripting.Objects.Character.NPCProto.isOnUseItem(proto.ScriptingNPC, item.ScriptingProto, -1, -2);
            }

            Write(item, packet.systemAddress);
        }
Ejemplo n.º 10
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client)
        {
            int callBackID = 0, npcID = 0, vobID = 0;

            stream.Read(out callBackID);
            stream.Read(out npcID);
            stream.Read(out vobID);

            if (!sWorld.VobDict.ContainsKey(npcID) || !sWorld.VobDict.ContainsKey(vobID))
            {
                throw new Exception("Vob or NPC weren't in the List!");
            }

            NPCProto proto = (NPCProto)sWorld.VobDict[npcID];
            Vob      vob   = (Vob)sWorld.VobDict[vobID];

            bool canSee = false;

            if (proto.Address != 0 && vob.Address == 0)
            {
                canSee = (new oCNpc(Process.ThisProcess(), proto.Address).CanSee(new zCVob(Process.ThisProcess(), vob.Address), 0) == 1) ? true : false;
            }

            stream.Reset();
            stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM);
            stream.Write((byte)NetworkID.CallbackNPCCanSee);
            stream.Write(callBackID);
            stream.Write(proto.ID);
            stream.Write(vob.ID);
            stream.Write(canSee);

            Program.client.client.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS, true);
        }
Ejemplo n.º 11
0
  internal static HandleRef getCPtr(Packet obj)
  {
     if (obj != null)
     {
        if (obj.dataIsCached)
        {
           obj.SetPacketData(obj.data, obj.data.Length); //If an individual index was modified we need to copy the data before passing to C++
        }
	obj.dataIsCached=false;
     }
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }
Ejemplo n.º 12
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int    plID      = 0;
            String levelName = "";

            stream.Read(out plID);
            stream.Read(out levelName);

            Vob pl = sWorld.VobDict[plID];

            sWorld.getWorld(levelName).addVob(pl);

            stream.ResetReadPointer();
            Program.server.ServerInterface.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, packet.guid, true);
        }
Ejemplo n.º 13
0
        private void OnMessageReceived(RakNet.Packet packet)
        {
            var connection = GetConnection(packet.guid);
            var buffer     = new byte[packet.data.Length];

            packet.data.CopyTo(buffer, 0);
            _peer.DeallocatePacket(packet);
            var p = new Stormancer.Core.Packet(
                connection,
                new MemoryStream(buffer));

            _logger.Trace("transports.raknet", "message with id {0} arrived", buffer[0]);

            this.PacketReceived(p);
        }
Ejemplo n.º 14
0
        private void OnConnection(RakNet.Packet packet, RakPeerInterface server)
        {
            logger.Trace("Connected to endpoint {0}", packet.systemAddress);

            var c = CreateNewConnection(packet.guid, server);

            server.DeallocatePacket(packet);
            _handler.NewConnection(c);
            var action = ConnectionOpened;

            if (action != null)
            {
                action(c);
            }

            c.SendSystem((byte)MessageIDTypes.ID_CONNECTION_RESULT, s => s.Write(BitConverter.GetBytes(c.Id), 0, 8));
        }
Ejemplo n.º 15
0
        private void OnDisconnection(RakNet.Packet packet, RakPeerInterface server, string reason)
        {
            _logger.Trace("transports.raknet", "{0} disconnected", packet.systemAddress);

            var c = RemoveConnection(packet.guid);

            server.DeallocatePacket(packet);
            _handler.CloseConnection(c, reason);
            c.RaiseConnectionClosed(reason);

            var action = ConnectionClosed;

            if (action != null)
            {
                action(c);
            }
        }
        private void OnMessageReceived(RakNet.Packet packet)
        {
            //var messageId = packet.data[0];
            var connection = GetConnection(packet.guid);
            var stream     = new MemoryStream((int)packet.length);

            //var buffer = new byte[packet.data.Length];
            stream.Write(packet.data, 0, (int)packet.length);
            stream.Seek(0, SeekOrigin.Begin);
            _peer.DeallocatePacket(packet);
            //logger.Trace("message arrived: [{0}]", string.Join(", ", buffer.Select(b => b.ToString()).ToArray()));

            var p = new Stormancer.Core.Packet(
                connection,
                stream);


            this.PacketReceived(p);
        }
Ejemplo n.º 17
0
        private void OnMessageReceived(RakNet.Packet packet)
        {
            var messageId  = packet.data[0];
            var connection = GetConnection(packet.guid);
            var stream     = new MemoryStream((int)packet.length);

            //var buffer = new byte[packet.data.Length];
            stream.Write(packet.data, 0, (int)packet.length);
            stream.Seek(0, SeekOrigin.Begin);
            logger.Log(Stormancer.Diagnostics.LogLevel.Trace, "transport", "message received  at " + DateTime.Now + "." + DateTime.Now.Millisecond + ": " + string.Join(";", packet.data.Select(b => b.ToString()).ToArray()));
            _peer.DeallocatePacket(packet);
            //logger.Trace("message arrived: [{0}]", string.Join(", ", buffer.Select(b => b.ToString()).ToArray()));

            var p = new Stormancer.Core.Packet(
                connection,
                stream);


            this.PacketReceived(p);
        }
Ejemplo n.º 18
0
        void _RunRead()
        {
            while (!_RequestReadThreadStop)
            {
                _packet = _peer.Receive();
                while (_packet != null)
                {
                    ProcessMessage(_packet);
                    _peer.DeallocatePacket(_packet);
                    _packet = _peer.Receive();
                }
                Thread.Sleep(10);
            }
            Log.Debug("Thread Stop!");

            if (_peer != null && ClientState == RakNetClientState.ConnectOK)
            {
                _peer.Shutdown(300);
            }
        }
Ejemplo n.º 19
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client)
        {
            int    plID;
            String levelName;
            Vec3f  pos, dir;

            stream.Read(out plID);
            stream.Read(out levelName);
            stream.Read(out pos);
            stream.Read(out dir);

            if (plID == 0 || !sWorld.VobDict.ContainsKey(plID))
            {
                throw new Exception("Vob not found!");
            }
            Vob vob = sWorld.VobDict[plID];

            if (!(vob is NPCProto))
            {
                throw new Exception("Vob is not an NPC!");
            }

            NPCProto playerVob = (NPCProto)vob;

            Process process = Process.ThisProcess();
            oCNpc   npc     = new oCNpc(process, vob.Address);

            if (vob is Player && vob == Player.Hero)
            {
                ((Player)vob).spawned();
                playerVob.Map = levelName;
                zString level = zString.Create(process, playerVob.Map);
                oCGame.Game(process).ChangeLevel(level, level);
                level.Dispose();


                vob.setDirection(dir);
                vob.setPosition(pos);
                Program._state = new GameState();
            }
        }
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client)
        {
            int   plID = 0;
            short anim = 0;

            stream.Read(out plID);
            stream.Read(out anim);

            if (plID == 0 || !sWorld.VobDict.ContainsKey(plID))
            {
                throw new Exception("Vob not found!");
            }
            Vob vob = sWorld.VobDict[plID];

            if (!(vob is NPCProto))
            {
                throw new Exception("Vob is not an NPC!");
            }

            short oldAni = ((NPCProto)vob).Animation;

            ((NPCProto)vob).Animation          = anim;
            ((NPCProto)vob).AnimationStartTime = Program.Now;

            if (vob.Address == 0)
            {
                return;
            }

            Process process = Process.ThisProcess();
            oCNpc   npc     = new oCNpc(process, vob.Address);

            if (oldAni != short.MaxValue)
            {
                npc.GetModel().StopAni(oldAni);
            }
            npc.GetModel().StartAni(anim, 0);

            //npc.GetModel().GetAniFromAniID(anim).AniName.Value;
        }
Ejemplo n.º 21
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int   vobID = 0;
            Vec3f pos, dir;

            stream.Read(out vobID);
            stream.Read(out pos);
            stream.Read(out dir);

            if (vobID == 0 || !sWorld.VobDict.ContainsKey(vobID))
            {
                throw new Exception("Vob not found!");
            }
            Vob vob = sWorld.VobDict[vobID];

            vob.Position  = pos;
            vob.Direction = dir;



            Write(vob, packet.systemAddress);
        }
Ejemplo n.º 22
0
        static void ProcessMessage(RakPeerInterface peer, RakNet.Packet packet)
        {
            if (packet != null)
            {
                if (packet.data[0] == (byte)(FT_MessageTypes.ID_SERVER_LOGIN))
                {
                    BitStream receiveBitStream = new BitStream();
                    receiveBitStream.Write(packet.data, packet.length);
                    receiveBitStream.IgnoreBytes(2);
                    FT_UnitData data = new FT_UnitData();
                    data.Serialize(false, receiveBitStream);
                    Log.Debug(" data.nGrid_x: " + data.nGrid_x);

                    BitStream writeBitStream = new BitStream();
                    writeBitStream.Write((byte)FT_MessageTypes.ID_SERVER_LOGIN);
                    writeBitStream.Write((byte)FT_MessageTypesNode.NODE_FT_TEST1);
                    data.Serialize(true, writeBitStream);
                    uint sendLength = peer.Send(writeBitStream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, packet.systemAddress, false);
                    Log.Debug("SendLength = " + sendLength);
                }
            }
        }
Ejemplo n.º 23
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int plID = 0, itemID = 0;

            stream.Read(out plID);
            stream.Read(out itemID);

            if (plID == 0 || !sWorld.VobDict.ContainsKey(plID))
            {
                throw new Exception("Vob not found!");
            }
            Vob vob = sWorld.VobDict[plID];

            if (!(vob is NPCProto))
            {
                throw new Exception("Vob is not an NPC!");
            }

            if (itemID == 0 || !sWorld.VobDict.ContainsKey(itemID))
            {
                throw new Exception("Item not found!");
            }
            Vob item = sWorld.VobDict[itemID];

            if (!(item is Item))
            {
                throw new Exception("Vob is not an Item!");
            }

            int amount = ((Item)item).Amount;

            NPCProto proto = (NPCProto)vob;

            item = proto.TakeItem((Item)item);

            Scripting.Objects.Character.NPCProto.OnItemTakes(proto.ScriptingNPC, (Scripting.Objects.Item)item.ScriptingVob, amount);

            Write(proto, (Item)item, packet.guid);
        }
Ejemplo n.º 24
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int plID = 0, itemID = 0;

            stream.Read(out plID);
            stream.Read(out itemID);

            if (plID == 0 || !sWorld.VobDict.ContainsKey(plID))
            {
                throw new Exception("Vob not found! ID:" + plID);
            }
            Vob vob = sWorld.VobDict[plID];

            if (!(vob is NPCProto))
            {
                throw new Exception("Vob is not an NPC!");
            }

            if (itemID == 0 || !sWorld.VobDict.ContainsKey(itemID))
            {
                throw new Exception("Item not found! ID:" + itemID);
            }
            Vob item = sWorld.VobDict[itemID];

            if (!(item is Item))
            {
                throw new Exception("Vob is not an Item!");
            }

            NPCProto proto = (NPCProto)vob;
            Item     itm   = (Item)item;

            proto.DropItem(itm);

            Scripting.Objects.Character.NPCProto.isOnDropItem(proto.ScriptingNPC, (Scripting.Objects.Item)itm.ScriptingProto, itm.Amount);

            Write(proto, itm, packet.guid);
        }
Ejemplo n.º 25
0
 public virtual void RespondOnVerifiedJoinCapable(Packet packet, bool accept, BitStream additionalData)
 {
     RakNetPINVOKE.FullyConnectedMesh2_RespondOnVerifiedJoinCapable(swigCPtr, Packet.getCPtr(packet), accept, BitStream.getCPtr(additionalData));
 }
Ejemplo n.º 26
0
 public virtual void GetVerifiedJoinRejectedAdditionalData(Packet packet, BitStream additionalData)
 {
     RakNetPINVOKE.FullyConnectedMesh2_GetVerifiedJoinRejectedAdditionalData(swigCPtr, Packet.getCPtr(packet), BitStream.getCPtr(additionalData));
 }
Ejemplo n.º 27
0
 public virtual void GetVerifiedJoinAcceptedAdditionalData(Packet packet, SWIGTYPE_p_bool thisSystemAccepted, RakNetListRakNetGUID systemsAccepted, BitStream additionalData)
 {
     RakNetPINVOKE.FullyConnectedMesh2_GetVerifiedJoinAcceptedAdditionalData(swigCPtr, Packet.getCPtr(packet), SWIGTYPE_p_bool.getCPtr(thisSystemAccepted), RakNetListRakNetGUID.getCPtr(systemsAccepted), BitStream.getCPtr(additionalData));
     if (RakNetPINVOKE.SWIGPendingException.Pending) throw RakNetPINVOKE.SWIGPendingException.Retrieve();
 }
Ejemplo n.º 28
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int casterID = 0, targetID = 0, spellID = 0, itemID = 0, castLevel = 0;

            stream.Read(out itemID);
            stream.Read(out casterID);
            stream.Read(out targetID);
            stream.Read(out spellID);
            stream.Read(out castLevel);

            Vob  itemVob = null;
            Item item    = null;

            Vob   casterVob = null;
            Spell spell     = null;

            NPCProto caster = null;
            Vob      target = null;

            sWorld.VobDict.TryGetValue(casterID, out casterVob);
            sWorld.VobDict.TryGetValue(itemID, out itemVob);

            if (casterVob == null)
            {
                throw new Exception("Caster was not found!");
            }
            if (!(casterVob is NPCProto))
            {
                throw new Exception("Caster was not a npcproto " + casterVob);
            }
            caster = (NPCProto)casterVob;
            if (targetID != 0)
            {
                sWorld.VobDict.TryGetValue(targetID, out target);
            }

            Spell.SpellDict.TryGetValue(spellID, out spell);
            if (spell == null)
            {
                throw new Exception("Spell can not be null!");
            }


            Scripting.Objects.Vob sT = (target == null) ? null : target.ScriptingVob;


            if (itemVob != null)
            {
                item = (Item)itemVob;
                if (item.ItemInstance.Flags.HasFlag(Flags.ITEM_MULTI))
                {
                    item.Amount -= 1;
                }
            }

            int manaInvested = 0;
            int realLevel    = (spell.processMana.Length > castLevel + 1) ? castLevel : spell.processMana.Length - 1;

            for (int i = 0; i <= realLevel; i++)
            {
                manaInvested += spell.processMana[i];
            }
            caster.ScriptingNPC.MP -= manaInvested;

            Scripting.Objects.Character.NPCProto.isOnCastSpell(
                caster.ScriptingNPC, spell.ScriptingProto, sT);



            Write(caster, item, target, spell, packet.guid);
        }
Ejemplo n.º 29
0
 public override void PushBackPacket(Packet packet, bool pushAtHead) {
   RakNetPINVOKE.RakPeer_PushBackPacket(swigCPtr, Packet.getCPtr(packet), pushAtHead);
 }
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int playerID = 0, cF = 0;

            stream.Read(out playerID);
            stream.Read(out cF);

            NPCProto proto = (NPCProto)sWorld.VobDict[playerID];

            NPCChangedFlags changeFlags = (NPCChangedFlags)cF;

            //Equipment:
            if (changeFlags.HasFlag(NPCChangedFlags.EQUIP_ARMOR))
            {
                proto.Armor = UpdateItem(stream);
            }

            if (changeFlags.HasFlag(NPCChangedFlags.EQUIP_NW))
            {
                proto.Weapon = UpdateItem(stream);
            }

            if (changeFlags.HasFlag(NPCChangedFlags.EQUIP_RW))
            {
                proto.RangeWeapon = UpdateItem(stream);
            }

            if (changeFlags.HasFlag(NPCChangedFlags.WeaponMode))
            {
                int weaponMode = 0;
                stream.Read(out weaponMode);
                proto.WeaponMode = weaponMode;
            }

            for (int i = 0; i < 9; i++)
            {
                if (changeFlags.HasFlag((NPCChangedFlags)((int)NPCChangedFlags.SLOT1 << i)))
                {
                    int slotItemID = 0;
                    stream.Read(out slotItemID);

                    if (slotItemID > 0)
                    {
                        Item slotItem = (Item)sWorld.VobDict[slotItemID];
                        //Item oldSlotItem = proto.Slots[i];

                        proto.Slots[i] = slotItem;
                    }
                    else
                    {
                        proto.Slots[i] = null;
                    }
                }
            }

            if (changeFlags.HasFlag(NPCChangedFlags.VOBFOCUS))
            {
                proto.FocusVob = UpdateVob(stream);
            }

            if (changeFlags.HasFlag(NPCChangedFlags.ENEMYFOCUS))
            {
                proto.Enemy = (NPCProto)UpdateVob(stream);
            }

            if (changeFlags.HasFlag(NPCChangedFlags.MOBINTERACT))
            {
                proto.MobInter = (MobInter)UpdateVob(stream);
            }

            if (changeFlags.HasFlag(NPCChangedFlags.ISDEAD))
            {
                proto.IsDead = UpdateState(stream);
            }

            if (changeFlags.HasFlag(NPCChangedFlags.ISUNCONSCIOUS))
            {
                proto.IsUnconcious = UpdateState(stream);
            }

            if (changeFlags.HasFlag(NPCChangedFlags.ISSWIMMING))
            {
                proto.IsSwimming = UpdateState(stream);
            }

            if (changeFlags.HasFlag(NPCChangedFlags.PORTALROOM))
            {
                String portalRoom = "";
                stream.Read(out portalRoom);
                proto.PortalRoom = portalRoom;
            }

            if (changeFlags.HasFlag(NPCChangedFlags.ACTIVE_SPELL))
            {
                int vobID = 0;
                stream.Read(out vobID);

                if (vobID == 0)
                {
                    proto.ActiveSpell = null;
                }
                else
                {
                    proto.ActiveSpell = (Item)sWorld.VobDict[vobID];
                }
            }

            //Sending back:
            stream.ResetReadPointer();

            Program.server.ServerInterface.Send(stream, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, packet.guid, true);
        }
Ejemplo n.º 31
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            Vec3f locHit = null, flydir = null;
            int   victim = 0, attacker = 0, weaponMode = 0, spellID = 0, weapon = 0;
            float fallDownDistanceY = 0.0f;

            byte sendFlags, damageMode;

            stream.Read(out victim);
            stream.Read(out damageMode);
            stream.Read(out sendFlags);

            if ((sendFlags & 1) == 1)
            {
                stream.Read(out locHit);
            }
            if ((sendFlags & 2) == 2)
            {
                stream.Read(out flydir);
            }
            if ((sendFlags & 4) == 4)
            {
                stream.Read(out attacker);
            }
            if ((sendFlags & 8) == 8)
            {
                stream.Read(out weaponMode);
            }
            if ((sendFlags & 16) == 16)
            {
                stream.Read(out spellID);
            }
            if ((sendFlags & 32) == 32)
            {
                stream.Read(out weapon);
            }
            if ((sendFlags & 64) == 64)
            {
                stream.Read(out fallDownDistanceY);
            }

            NPCProto vicProto = (NPCProto)sWorld.VobDict[victim];
            Vob      attProto = null;

            Scripting.Objects.Vob attackerScriptProto = null;

            if (attacker != 0)
            {
                attProto            = sWorld.VobDict[attacker];
                attackerScriptProto = attProto.ScriptingVob;
            }

            Item weaponIt = null;

            Scripting.Objects.Item weaponScriptItem = null;
            if (weapon != 0)
            {
                weaponIt         = (Item)sWorld.VobDict[weapon];
                weaponScriptItem = weaponIt.ScriptingProto;
            }


            Spell spell = null;

            Scripting.Objects.Spell scriptSpell = null;
            if (spellID > 100)
            {
                Spell.SpellDict.TryGetValue(spellID, out spell);
                if (spell != null)
                {
                    scriptSpell = spell.ScriptingProto;
                }
            }

            Scripting.Objects.Character.NPCProto.isOnDamage(vicProto.ScriptingNPC, (DamageTypes)damageMode, locHit, flydir, attackerScriptProto, weaponMode, scriptSpell, weaponScriptItem, fallDownDistanceY);
            Write(vicProto, (DamageTypes)damageMode, locHit, flydir, attProto, weaponMode, spell, weaponIt, fallDownDistanceY, packet.guid);
        }
Ejemplo n.º 32
0
 public void DecodeTeamCancelled(Packet packet, SWIGTYPE_p_p_RakNet__TM_World world, SWIGTYPE_p_p_RakNet__TM_TeamMember teamMember, SWIGTYPE_p_p_RakNet__TM_Team teamCancelled)
 {
     RakNetPINVOKE.TeamManager_DecodeTeamCancelled(swigCPtr, Packet.getCPtr(packet), SWIGTYPE_p_p_RakNet__TM_World.getCPtr(world), SWIGTYPE_p_p_RakNet__TM_TeamMember.getCPtr(teamMember), SWIGTYPE_p_p_RakNet__TM_Team.getCPtr(teamCancelled));
 }
Ejemplo n.º 33
0
 public void DecomposeTeamLocked(Packet packet, SWIGTYPE_p_p_RakNet__TM_World world, SWIGTYPE_p_p_RakNet__TM_TeamMember teamMember, SWIGTYPE_p_p_RakNet__TM_Team team, SWIGTYPE_p_unsigned_short currentMembers, SWIGTYPE_p_unsigned_short memberLimitIncludingBalancing, SWIGTYPE_p_bool balancingIsActive, SWIGTYPE_p_unsigned_char joinPermissions)
 {
     RakNetPINVOKE.TeamManager_DecomposeTeamLocked(swigCPtr, Packet.getCPtr(packet), SWIGTYPE_p_p_RakNet__TM_World.getCPtr(world), SWIGTYPE_p_p_RakNet__TM_TeamMember.getCPtr(teamMember), SWIGTYPE_p_p_RakNet__TM_Team.getCPtr(team), SWIGTYPE_p_unsigned_short.getCPtr(currentMembers), SWIGTYPE_p_unsigned_short.getCPtr(memberLimitIncludingBalancing), SWIGTYPE_p_bool.getCPtr(balancingIsActive), SWIGTYPE_p_unsigned_char.getCPtr(joinPermissions));
     if (RakNetPINVOKE.SWIGPendingException.Pending) throw RakNetPINVOKE.SWIGPendingException.Retrieve();
 }
Ejemplo n.º 34
0
 public override void DeallocatePacket(Packet packet) {
   RakNetPINVOKE.RakPeer_DeallocatePacket(swigCPtr, Packet.getCPtr(packet));
 }
Ejemplo n.º 35
0
 public AddressOrGUID(Packet packet) : this(RakNetPINVOKE.new_AddressOrGUID__SWIG_3(Packet.getCPtr(packet)), true) {
 }
Ejemplo n.º 36
0
    void ProcessInboundPackets()
    {
        RakNet.Packet cRnPacket = null;

        // Iterate through queued packets
        while ((cRnPacket = m_cRnPeer.Receive()) != null)
        {
            // Extract packet id
            int iPacketId = cRnPacket.data[0];


            // Process message
            switch ((RakNet.DefaultMessageIDTypes)iPacketId)
            {
            case RakNet.DefaultMessageIDTypes.ID_CONNECTION_REQUEST_ACCEPTED:
            {
                HandleConnectionAccepted(cRnPacket.systemAddress);
            }
            break;

            case RakNet.DefaultMessageIDTypes.ID_NO_FREE_INCOMING_CONNECTIONS:
            {
                Logger.WriteError("No free incoming connects");
            }
            break;

            case RakNet.DefaultMessageIDTypes.ID_DISCONNECTION_NOTIFICATION:
            {
                HandleDisconnect(EDisconnectType.Kicked);
            }
            break;

            case RakNet.DefaultMessageIDTypes.ID_CONNECTION_LOST:
            {
                HandleDisconnect(EDisconnectType.Timedout);
            }
            break;

            case RakNet.DefaultMessageIDTypes.ID_CONNECTION_ATTEMPT_FAILED:
            {
                Logger.WriteError("Failed to connect to server");
            }
            break;

            case (RakNet.DefaultMessageIDTypes)EPacketId.NetworkView:
            {
                Logger.WriteError("This method should not have been called.");
            }
            break;

            case (RakNet.DefaultMessageIDTypes)EPacketId.MicrophoneAudio:
            {
                HandleMicrophoneAudio(cRnPacket.data);
            }
            break;

            case RakNet.DefaultMessageIDTypes.ID_TIMESTAMP:
            {
                // Get actual subject of message, dismissing RakNet.DefaultMessageIDTypes.ID_TIMESTAMP
                // and the following 8 byte timestamp value
                switch (cRnPacket.data[sizeof(byte) + sizeof(ulong)])
                {
                case (byte)EPacketId.NetworkView:
                    HandleNetworkViewPacket(cRnPacket.data);
                    break;

                default:
                    Logger.WriteError("Receieved unknown network message id ({0})");
                    break;
                }
            }
            break;

            default:
                Logger.WriteError("Receieved unknown network message id ({0})", cRnPacket.data[0]);
                break;
            }


            m_tInboundRateData.uiBytes      += (uint)cRnPacket.data.Length;
            m_tInboundRateData.uiNumEntries += 1;


            m_cRnPeer.DeallocatePacket(cRnPacket);
        }
    }
Ejemplo n.º 37
0
 public virtual void DeallocatePacket(Packet packet) {
   RakNetPINVOKE.RakPeerInterface_DeallocatePacket(swigCPtr, Packet.getCPtr(packet));
 }
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int  playerID = 0, itemID = 0;
            bool equip = false;

            stream.Read(out playerID);
            stream.Read(out itemID);
            stream.Read(out equip);

            if (!sWorld.VobDict.ContainsKey(playerID))
            {
                throw new Exception("Player-ID was not found: " + playerID + " Equipped: " + equip);
            }
            if (!sWorld.VobDict.ContainsKey(itemID))
            {
                throw new Exception("Item-ID was not found: " + itemID + " Equipped: " + equip + " playerID: " + playerID);
            }


            NPCProto player = (NPCProto)sWorld.VobDict[playerID];
            Item     item   = (Item)sWorld.VobDict[itemID];

            if (equip)
            {
                if (item.ItemInstance.MainFlags.HasFlag(MainFlags.ITEM_KAT_ARMOR))
                {
                    player.Armor = item;
                }
                else if (item.ItemInstance.MainFlags.HasFlag(MainFlags.ITEM_KAT_NF))
                {
                    player.Weapon = item;
                }
                else if (item.ItemInstance.MainFlags.HasFlag(MainFlags.ITEM_KAT_FF))
                {
                    player.RangeWeapon = item;
                }

                player.EquippedList.Add(item);
                Scripting.Objects.Character.NPCProto.isOnEquip(player.ScriptingNPC, item.ScriptingProto);
            }
            else
            {
                if (item.ItemInstance.MainFlags.HasFlag(MainFlags.ITEM_KAT_ARMOR))
                {
                    player.Armor = null;
                }
                else if (item.ItemInstance.MainFlags.HasFlag(MainFlags.ITEM_KAT_NF))
                {
                    player.Weapon = null;
                }
                else if (item.ItemInstance.MainFlags.HasFlag(MainFlags.ITEM_KAT_FF))
                {
                    player.RangeWeapon = null;
                }

                player.EquippedList.Remove(item);
                Scripting.Objects.Character.NPCProto.isOnUnEquip(player.ScriptingNPC, item.ScriptingProto);
            }


            stream.ResetReadPointer();
            Program.server.ServerInterface.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, packet.guid, true);
        }
Ejemplo n.º 39
0
 public virtual void PushBackPacket(Packet packet, bool pushAtHead) {
   RakNetPINVOKE.RakPeerInterface_PushBackPacket(swigCPtr, Packet.getCPtr(packet), pushAtHead);
 }
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client)
        {
            int id = 0;

            stream.Read(out id);
            Player.Hero.ID = id;

            sWorld.addVob(Player.Hero);

            using (BitStream stream2 = new BitStream())
            {
                Zip.Decompress(stream, stream2);
                stream = stream2;



                stream.Read(out Player.EnableStatusMenu);
                stream.Read(out Player.EnableLogMenu);

                //Player-Defaults:
                if (Player.EnableStatusMenu)
                {
                    Gothic.mClasses.InputHooked.deactivateStatusScreen(Process.ThisProcess(), true);
                }
                if (Player.EnableLogMenu)
                {
                    Gothic.mClasses.InputHooked.deactivateLogScreen(Process.ThisProcess(), true);
                }



                stream.Read(out Player.sSendAllKeys);
                int playerKeyCount = 0;
                stream.Read(out playerKeyCount);
                for (int i = 0; i < playerKeyCount; i++)
                {
                    byte key = 0;
                    stream.Read(out key);
                    Player.sSendKeys.Add(key);
                }


                int  day = 0;
                byte hour = 0, minute = 0;
                stream.Read(out day);
                stream.Read(out hour);
                stream.Read(out minute);

                sWorld.Day    = day;
                sWorld.Hour   = hour;
                sWorld.Minute = minute;


                byte wt = 0, starthour = 0, startminute = 0, endhour = 0, endminute;

                stream.Read(out wt);
                stream.Read(out starthour);
                stream.Read(out startminute);
                stream.Read(out endhour);
                stream.Read(out endminute);

                sWorld.WeatherType     = wt;
                sWorld.StartRainHour   = starthour;
                sWorld.StartRainMinute = startminute;
                sWorld.EndRainHour     = endhour;
                sWorld.EndRainMinute   = endminute;


                short spellCount = 0;
                stream.Read(out spellCount);
                for (int i = 0; i < spellCount; i++)
                {
                    Spell spell = new Spell();
                    spell.Read(stream);
                    Spell.addItemInstance(spell);
                }

                short itemInstancesCount = 0;
                stream.Read(out itemInstancesCount);
                for (int i = 0; i < itemInstancesCount; i++)
                {
                    ItemInstance ii = new ItemInstance();
                    ii.Read(stream);


                    ItemInstance.addItemInstance(ii);
                }
                CreateItems();

                //ItemList:
                int iLC = 0;
                stream.Read(out iLC);
                for (int i = 0; i < iLC; i++)
                {
                    Item item = new Item();
                    item.Read(stream);
                    sWorld.addVob(item);
                }

                //Vob-List:
                int vLC = 0;
                stream.Read(out vLC);
                for (int i = 0; i < vLC; i++)
                {
                    int vobType = 0;
                    stream.Read(out vobType);
                    Vob vob = Vob.createVob((VobType)vobType);
                    vob.Read(stream);
                    sWorld.addVob(vob);
                }

                //NPC-List:
                int nLC = 0;
                stream.Read(out nLC);
                for (int i = 0; i < nLC; i++)
                {
                    NPC npc = new NPC();
                    npc.Read(stream);
                    sWorld.addVob(npc);
                }

                //Player-List:
                int pLC = 0;
                stream.Read(out pLC);
                for (int i = 0; i < pLC; i++)
                {
                    Player player = new Player(false, "");
                    player.Read(stream);

                    if (player.ID == id)
                    {
                        continue;
                    }
                    sWorld.addVob(player);
                }

                //WorldSpawnList:
                int worldListCount = 0;
                stream.Read(out worldListCount);
                for (int i = 0; i < worldListCount; i++)
                {
                    World w = new World();
                    w.Read(stream);

                    sWorld.WorldDict.Add(w.Map, w);
                }
            }
        }
Ejemplo n.º 41
0
 public void ConnectToRemoteNewIncomingConnections(Packet packet) {
   RakNetPINVOKE.FullyConnectedMesh2_ConnectToRemoteNewIncomingConnections(swigCPtr, Packet.getCPtr(packet));
 }
Ejemplo n.º 42
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int  vobID = 0, playerID = 0;
            byte mobInterTypeInt = 0;
            char mobInterKey     = '0';

            stream.Read(out mobInterTypeInt);
            stream.Read(out playerID);
            stream.Read(out vobID);

            MobInterNetwork mobInterFlags = (MobInterNetwork)mobInterTypeInt;

            if (mobInterFlags.HasFlag(MobInterNetwork.PickLock))
            {
                stream.Read(out mobInterKey);
            }


            if (playerID == 0 || !sWorld.VobDict.ContainsKey(playerID))
            {
                throw new Exception("Player not found!");
            }
            Vob plVob = sWorld.VobDict[playerID];

            if (!(plVob is NPCProto))
            {
                throw new Exception("PlayerVob was not from type Player: " + plVob);
            }
            NPCProto player = (NPCProto)plVob;

            if (vobID == 0 || !sWorld.VobDict.ContainsKey(vobID))
            {
                throw new Exception("Vob not found!");
            }
            Vob vob = sWorld.VobDict[vobID];

            if (!(vob is MobInter))
            {
                throw new Exception("Vob was not from type MobInter: " + vob);
            }

            stream.ResetReadPointer();
            Program.server.ServerInterface.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, packet.guid, true);


            MobInter mob = (MobInter)vob;

            if (mobInterFlags == MobInterNetwork.PickLock)
            {
                if (!(vob is MobLockable))
                {
                    throw new Exception("Vob was not from type MobLockable: " + vob);
                }
                MobLockable mobLock = (MobLockable)mob;
                Scripting.Objects.Mob.MobLockable.OnContainerPickLock((Scripting.Objects.Mob.MobLockable)mobLock.ScriptingVob, player.ScriptingNPC, mobInterKey);
            }
            else if (mobInterFlags == MobInterNetwork.OnTrigger)
            {
                mob.State = 1;
                Scripting.Objects.Mob.MobInter.isOnTrigger((Scripting.Objects.Mob.MobInter)mob.ScriptingVob, player.ScriptingNPC);
            }
            else if (mobInterFlags == MobInterNetwork.OnUnTrigger)
            {
                mob.State = 0;
                Scripting.Objects.Mob.MobInter.isOnUnTrigger((Scripting.Objects.Mob.MobInter)mob.ScriptingVob, player.ScriptingNPC);
            }
            else if (mobInterFlags == MobInterNetwork.StartInteraction)
            {
                Scripting.Objects.Mob.MobInter.isOnStartInteraction((Scripting.Objects.Mob.MobInter)mob.ScriptingVob, player.ScriptingNPC);
            }
            else if (mobInterFlags == MobInterNetwork.StopInteraction)
            {
                Scripting.Objects.Mob.MobInter.isOnStopInteraction((Scripting.Objects.Mob.MobInter)mob.ScriptingVob, player.ScriptingNPC);
            }
        }