mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04:00 
			
		
		
		
	Implemented item packets, did some fixes with one of the conns going null.
This commit is contained in:
		| @@ -33,17 +33,21 @@ | |||||||
|     <WarningLevel>4</WarningLevel> |     <WarningLevel>4</WarningLevel> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Reference Include="Cyotek.Collections.Generic.CircularBuffer"> |     <Reference Include="Cyotek.Collections.Generic.CircularBuffer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=58daa28b0b2de221, processorArchitecture=MSIL"> | ||||||
|       <HintPath>..\packages\Cyotek.CircularBuffer.1.0.0.0\lib\net20\Cyotek.Collections.Generic.CircularBuffer.dll</HintPath> |       <HintPath>..\packages\Cyotek.CircularBuffer.1.0.0.0\lib\net20\Cyotek.Collections.Generic.CircularBuffer.dll</HintPath> | ||||||
|  |       <Private>True</Private> | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="Dapper"> |     <Reference Include="Dapper, Version=1.40.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||||||
|       <HintPath>..\packages\Dapper.1.42\lib\net45\Dapper.dll</HintPath> |       <HintPath>..\packages\Dapper.1.42\lib\net45\Dapper.dll</HintPath> | ||||||
|  |       <Private>True</Private> | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="MySql.Data"> |     <Reference Include="MySql.Data, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL"> | ||||||
|       <HintPath>..\packages\MySql.Data.6.9.7\lib\net45\MySql.Data.dll</HintPath> |       <HintPath>..\packages\MySql.Data.6.9.7\lib\net45\MySql.Data.dll</HintPath> | ||||||
|  |       <Private>True</Private> | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="Newtonsoft.Json"> |     <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||||||
|       <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> |       <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> | ||||||
|  |       <Private>True</Private> | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="System" /> |     <Reference Include="System" /> | ||||||
|     <Reference Include="System.Core" /> |     <Reference Include="System.Core" /> | ||||||
| @@ -65,11 +69,16 @@ | |||||||
|     <Compile Include="dataobjects\Actor.cs" /> |     <Compile Include="dataobjects\Actor.cs" /> | ||||||
|     <Compile Include="dataobjects\Character.cs" /> |     <Compile Include="dataobjects\Character.cs" /> | ||||||
|     <Compile Include="dataobjects\CharaInfo.cs" /> |     <Compile Include="dataobjects\CharaInfo.cs" /> | ||||||
|  |     <Compile Include="dataobjects\Item.cs" /> | ||||||
|     <Compile Include="dataobjects\Player.cs" /> |     <Compile Include="dataobjects\Player.cs" /> | ||||||
|     <Compile Include="dataobjects\World.cs" /> |     <Compile Include="dataobjects\World.cs" /> | ||||||
|     <Compile Include="PacketProcessor.cs" /> |     <Compile Include="PacketProcessor.cs" /> | ||||||
|     <Compile Include="packets\BasePacket.cs" /> |     <Compile Include="packets\BasePacket.cs" /> | ||||||
|     <Compile Include="packets\receive\HandshakePacket.cs" /> |     <Compile Include="packets\receive\HandshakePacket.cs" /> | ||||||
|  |     <Compile Include="packets\send\Actor\inventory\InventoryItemEndPacket.cs" /> | ||||||
|  |     <Compile Include="packets\send\Actor\inventory\InventoryItemPacket.cs" /> | ||||||
|  |     <Compile Include="packets\send\Actor\inventory\InventorySetBeginPacket.cs" /> | ||||||
|  |     <Compile Include="packets\send\Actor\inventory\InventorySetEndPacket.cs" /> | ||||||
|     <Compile Include="packets\send\login\0x2Packet.cs" /> |     <Compile Include="packets\send\login\0x2Packet.cs" /> | ||||||
|     <Compile Include="packets\send\Actor\AddActorPacket.cs" /> |     <Compile Include="packets\send\Actor\AddActorPacket.cs" /> | ||||||
|     <Compile Include="packets\send\Actor\MoveActorToPositionPacket.cs" /> |     <Compile Include="packets\send\Actor\MoveActorToPositionPacket.cs" /> | ||||||
|   | |||||||
| @@ -14,17 +14,19 @@ using FFXIVClassic_Map_Server.packets; | |||||||
| using FFXIVClassic_Map_Server.packets.receive; | using FFXIVClassic_Map_Server.packets.receive; | ||||||
| using FFXIVClassic_Map_Server.packets.send; | using FFXIVClassic_Map_Server.packets.send; | ||||||
| using FFXIVClassic_Map_Server.packets.send.login; | using FFXIVClassic_Map_Server.packets.send.login; | ||||||
|  | using FFXIVClassic_Map_Server.packets.send.Actor.inventory; | ||||||
|  |  | ||||||
| namespace FFXIVClassic_Lobby_Server | namespace FFXIVClassic_Lobby_Server | ||||||
| { | { | ||||||
|     class PacketProcessor |     class PacketProcessor | ||||||
|     { |     { | ||||||
|         Dictionary<uint, Player> mPlayers = new Dictionary<uint, Player>(); |         Dictionary<uint, Player> mPlayers; | ||||||
|         List<ClientConnection> mConnections; |         List<ClientConnection> mConnections; | ||||||
|         Boolean isAlive = true; |         Boolean isAlive = true; | ||||||
|  |  | ||||||
|         public PacketProcessor(List<ClientConnection> connectionList) |         public PacketProcessor(Dictionary<uint, Player> playerList, List<ClientConnection> connectionList) | ||||||
|         { |         { | ||||||
|  |             mPlayers = playerList; | ||||||
|             mConnections = connectionList; |             mConnections = connectionList; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -131,6 +133,10 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|                         if (actorID == 0) |                         if (actorID == 0) | ||||||
|                             break; |                             break; | ||||||
|  |  | ||||||
|  |                         //Second connection | ||||||
|  |                         if (mPlayers.ContainsKey(actorID)) | ||||||
|  |                             player = mPlayers[actorID]; | ||||||
|  |  | ||||||
|                         using (MemoryStream mem = new MemoryStream(reply2.data)) |                         using (MemoryStream mem = new MemoryStream(reply2.data)) | ||||||
|                         { |                         { | ||||||
|                             using (BinaryWriter binReader = new BinaryWriter(mem)) |                             using (BinaryWriter binReader = new BinaryWriter(mem)) | ||||||
| @@ -164,7 +170,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|                         break; |                         break; | ||||||
|                     //Ping |                     //Ping | ||||||
|                     case 0x0001: |                     case 0x0001: | ||||||
|                         subpacket.debugPrintSubPacket(); |                         //subpacket.debugPrintSubPacket(); | ||||||
|                         PingPacket pingPacket = new PingPacket(subpacket.data); |                         PingPacket pingPacket = new PingPacket(subpacket.data); | ||||||
|                         client.queuePacket(BasePacket.createPacket(PongPacket.buildPacket(player.actorID, pingPacket.time), true, false)); |                         client.queuePacket(BasePacket.createPacket(PongPacket.buildPacket(player.actorID, pingPacket.time), true, false)); | ||||||
|                         break; |                         break; | ||||||
| @@ -175,22 +181,79 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|                         BasePacket setMapPacket = BasePacket.createPacket(SetMapPacket.buildPacket(player.actorID, 0xD1), true, false); |                         BasePacket setMapPacket = BasePacket.createPacket(SetMapPacket.buildPacket(player.actorID, 0xD1), true, false); | ||||||
|                         BasePacket setPlayerActorPacket = BasePacket.createPacket(_0x2Packet.buildPacket(player.actorID), true, false); |                         BasePacket setPlayerActorPacket = BasePacket.createPacket(_0x2Packet.buildPacket(player.actorID), true, false); | ||||||
|               |               | ||||||
|                         BasePacket reply5 = new BasePacket("./packets/asd/login5.bin"); |                         BasePacket reply5 = new BasePacket("./packets/login/login5.bin"); | ||||||
|                         BasePacket reply6 = new BasePacket("./packets/asd/login6_data.bin"); |                         BasePacket reply6 = new BasePacket("./packets/login/login6_data.bin"); | ||||||
|                         BasePacket reply7 = new BasePacket("./packets/asd/login7_data.bin"); |                         BasePacket reply7 = new BasePacket("./packets/login/login7_data.bin"); | ||||||
|                         BasePacket reply8 = new BasePacket("./packets/asd/login8_data.bin"); |                         BasePacket reply8 = new BasePacket("./packets/login/login8_data.bin"); | ||||||
|                         BasePacket reply9 = new BasePacket("./packets/asd/login9_zonesetup.bin"); |                         BasePacket reply9 = new BasePacket("./packets/login/login9_zonesetup.bin"); | ||||||
|                         BasePacket reply10 = new BasePacket("./packets/asd/login10.bin"); |                         BasePacket reply10 = new BasePacket("./packets/login/login10.bin"); | ||||||
|  |  | ||||||
|  |                         BasePacket setinv = new BasePacket("./packets/login/inventory_backup.bin"); | ||||||
|  |                         BasePacket keyitems = new BasePacket("./packets/login/keyitems.bin"); | ||||||
|  |                         BasePacket currancy = new BasePacket("./packets/login/currancy.bin"); | ||||||
|  |  | ||||||
|  |                         setinv.replaceActorID(player.actorID); | ||||||
|  |                         currancy.replaceActorID(player.actorID); | ||||||
|  |                         keyitems.replaceActorID(player.actorID); | ||||||
|  |  | ||||||
|  |                         reply5.replaceActorID(player.actorID); | ||||||
|  |                         reply6.replaceActorID(player.actorID); | ||||||
|  |                         reply7.replaceActorID(player.actorID); | ||||||
|  |                         reply8.replaceActorID(player.actorID); | ||||||
|  |                         reply9.replaceActorID(player.actorID); | ||||||
|  |  | ||||||
|                         client.sendPacketQueue.Add(setMapPacket); |                         client.sendPacketQueue.Add(setMapPacket); | ||||||
|                         client.sendPacketQueue.Add(setPlayerActorPacket); |                         client.sendPacketQueue.Add(setPlayerActorPacket); | ||||||
|                         client.sendPacketQueue.Add(reply5); |                         client.sendPacketQueue.Add(reply5); | ||||||
|                         client.sendPacketQueue.Add(reply6); |                         client.sendPacketQueue.Add(reply6); | ||||||
|  |  | ||||||
|  |                          | ||||||
|  |                         //TEST | ||||||
|  |                         List<Item> items = new List<Item>(); | ||||||
|  |                         items.Add(new Item(1337, 8030920, 0)); //Leather Jacket | ||||||
|  |                         items.Add(new Item(1338, 8013626, 1)); //Chocobo Mask | ||||||
|  |                         items.Add(new Item(1339, 5030402, 2)); //Thyrus | ||||||
|  |                         items.Add(new Item(1340, 8013635, 3)); //Dalamud Horn | ||||||
|  |                         items.Add(new Item(1341, 10100132, 4)); //Savage Might 4 | ||||||
|  |  | ||||||
|  |                         int count = 0; | ||||||
|  |                          | ||||||
|  |                         items[2].isHighQuality = true; | ||||||
|  |                         items[0].durability = 9999; | ||||||
|  |                         items[0].spiritbind = 10000; | ||||||
|  |                         items[0].materia1 = 6; | ||||||
|  |                         items[0].materia2 = 7; | ||||||
|  |                         items[0].materia3 = 8; | ||||||
|  |                         items[0].materia4 = 9; | ||||||
|  |                         items[0].materia5 = 10; | ||||||
|  |                         items[1].durability = 9999; | ||||||
|  |                         items[2].durability = 0xFFFFFFF; | ||||||
|  |                         items[3].durability = 9999; | ||||||
|  |                         items[4].quantity = 99; | ||||||
|  |  | ||||||
|  |                         //Reused | ||||||
|  |                         SubPacket endInventory = InventorySetEndPacket.buildPacket(player.actorID); | ||||||
|  |                         SubPacket beginInventory = InventorySetBeginPacket.buildPacket(player.actorID, 200, 00); | ||||||
|  |                         SubPacket setInventory = InventoryItemPacket.buildPacket(player.actorID, items, ref count); | ||||||
|  |  | ||||||
|  |                         List<SubPacket> setinvPackets = new List<SubPacket>(); | ||||||
|  |                         setinvPackets.Add(beginInventory); | ||||||
|  |                         setinvPackets.Add(setInventory); | ||||||
|  |                         setinvPackets.Add(endInventory); | ||||||
|  |  | ||||||
|  |                         BasePacket setInvBasePacket = BasePacket.createPacket(setinvPackets, true, false); | ||||||
|  |                         client.sendPacketQueue.Add(setInvBasePacket); | ||||||
|  |                          | ||||||
|  |  | ||||||
|  |                         //client.sendPacketQueue.Add(setinv); | ||||||
|  |                         //client.sendPacketQueue.Add(currancy); | ||||||
|  |                         //client.sendPacketQueue.Add(keyitems); | ||||||
|  |  | ||||||
|  |  | ||||||
|                         client.sendPacketQueue.Add(reply7); |                         client.sendPacketQueue.Add(reply7); | ||||||
|                         client.sendPacketQueue.Add(reply8); |                         client.sendPacketQueue.Add(reply8); | ||||||
|                         client.sendPacketQueue.Add(reply9); |                         client.sendPacketQueue.Add(reply9); | ||||||
|                         //client.sendPacketQueue.Add(reply10); |                         client.sendPacketQueue.Add(reply10); | ||||||
|  |  | ||||||
|                         break; |                         break; | ||||||
|                     //Chat Received |                     //Chat Received | ||||||
| @@ -212,8 +275,17 @@ namespace FFXIVClassic_Lobby_Server | |||||||
| 				        break; | 				        break; | ||||||
|                     case 0x012E: |                     case 0x012E: | ||||||
|                         subpacket.debugPrintSubPacket(); |                         subpacket.debugPrintSubPacket(); | ||||||
| 				        //ProcessScriptResult(subPacket);				     | 				        processScriptResult(subpacket);				     | ||||||
| 				        break; | 				        break; | ||||||
|  |                     case 0x012F: | ||||||
|  |                         subpacket.debugPrintSubPacket(); | ||||||
|  |                         BasePacket scriptReply = new BasePacket("./packets/charawork2"); | ||||||
|  |                         BasePacket scriptReply2 = new BasePacket("./packets/charawork3"); | ||||||
|  |                         BasePacket scriptReply3 = new BasePacket("./packets/charawork4");                         | ||||||
|  |                         client.queuePacket(scriptReply); | ||||||
|  |                         client.queuePacket(scriptReply2); | ||||||
|  |                         client.queuePacket(scriptReply3); | ||||||
|  |                         break; | ||||||
|                     default: |                     default: | ||||||
|                         Log.debug(String.Format("Unknown command 0x{0:X} received.", subpacket.header.opcode)); |                         Log.debug(String.Format("Unknown command 0x{0:X} received.", subpacket.header.opcode)); | ||||||
|                         subpacket.debugPrintSubPacket(); |                         subpacket.debugPrintSubPacket(); | ||||||
| @@ -222,5 +294,183 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         public void sendPacket(string path, int conn) | ||||||
|  |         { | ||||||
|  |             if (mPlayers.Count == 0) | ||||||
|  |                 return; | ||||||
|  |  | ||||||
|  |             BasePacket packet = new BasePacket(path); | ||||||
|  |  | ||||||
|  |             foreach (KeyValuePair<uint, Player> entry in mPlayers) | ||||||
|  |             { | ||||||
|  |                 packet.replaceActorID(entry.Value.actorID); | ||||||
|  |                 if (conn == 1 || conn == 3) | ||||||
|  |                     entry.Value.getConnection1().sendPacketQueue.Add(packet); | ||||||
|  |                 if (conn == 2 || conn == 3) | ||||||
|  |                     entry.Value.getConnection2().sendPacketQueue.Add(packet); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public void processScriptResult(SubPacket subpacket) | ||||||
|  |         { | ||||||
|  |             uint someId1 = 0; | ||||||
|  | 	        uint someId2 = 0; | ||||||
|  | 	        uint someId3 = 0; | ||||||
|  |  | ||||||
|  |             using (MemoryStream mem = new MemoryStream(subpacket.data)) | ||||||
|  |             { | ||||||
|  |                 using (BinaryReader binReader = new BinaryReader(mem)) | ||||||
|  |                 { | ||||||
|  |                     binReader.BaseStream.Seek(0x2C, SeekOrigin.Begin); | ||||||
|  |                     someId1 = binReader.ReadUInt32(); | ||||||
|  |                     someId2 = binReader.ReadUInt32(); | ||||||
|  |                     someId3 = binReader.ReadUInt32(); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |  | ||||||
|  | 	        Log.info(String.Format("ProcessScriptResult: Id1 = {0}, Id2 = {1}, Id3 = {2}", someId1, someId2, someId3)); | ||||||
|  |  | ||||||
|  | 	         | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /* | ||||||
|  |         public void sendTeleportSequence(ClientConnection client, uint levelId, float x, float y, float z, float angle) | ||||||
|  |         { | ||||||
|  | 	        BasePacket reply1 = new BasePacket("./packets/move/move1.bin"); | ||||||
|  |             BasePacket reply2 = new BasePacket("./packets/move/move2.bin"); | ||||||
|  |             BasePacket reply3 = new BasePacket("./packets/move/move3.bin"); | ||||||
|  |             BasePacket reply4 = new BasePacket("./packets/move/move4.bin"); | ||||||
|  |             BasePacket reply5 = new BasePacket("./packets/move/move5.bin"); | ||||||
|  |             BasePacket reply6 = new BasePacket("./packets/move/move6.bin"); | ||||||
|  |             BasePacket reply7 = new BasePacket("./packets/move/move7.bin"); | ||||||
|  |             BasePacket reply8 = new BasePacket("./packets/move/move8.bin"); | ||||||
|  |             BasePacket reply9 = new BasePacket("./packets/move/move9.bin"); | ||||||
|  |  | ||||||
|  |             client.queuePacket(reply1); | ||||||
|  |             client.queuePacket(reply2); | ||||||
|  |             client.queuePacket(reply3); | ||||||
|  |             client.queuePacket(reply4); | ||||||
|  |             client.queuePacket(reply5); | ||||||
|  |             client.queuePacket(reply6); | ||||||
|  |             client.queuePacket(reply7); | ||||||
|  |             client.queuePacket(reply8); | ||||||
|  |             client.queuePacket(reply9); | ||||||
|  |          | ||||||
|  | 	         | ||||||
|  | 	        { | ||||||
|  | 		        CCompositePacket result; | ||||||
|  |  | ||||||
|  | 		        { | ||||||
|  | 			        CSetMusicPacket packet; | ||||||
|  | 			        packet.SetSourceId(PLAYER_ID); | ||||||
|  | 			        packet.SetTargetId(PLAYER_ID); | ||||||
|  | 			        packet.SetMusicId(zone->backgroundMusicId); | ||||||
|  | 			        result.AddPacket(packet.ToPacketData()); | ||||||
|  | 		        } | ||||||
|  |  | ||||||
|  | 		        { | ||||||
|  | 			        CSetWeatherPacket packet; | ||||||
|  | 			        packet.SetSourceId(PLAYER_ID); | ||||||
|  | 			        packet.SetTargetId(PLAYER_ID); | ||||||
|  | 			        packet.SetWeatherId(CSetWeatherPacket::WEATHER_CLEAR); | ||||||
|  | 			        result.AddPacket(packet.ToPacketData()); | ||||||
|  | 		        } | ||||||
|  |  | ||||||
|  | 		        { | ||||||
|  | 			        CSetMapPacket packet; | ||||||
|  | 			        packet.SetSourceId(PLAYER_ID); | ||||||
|  | 			        packet.SetTargetId(PLAYER_ID); | ||||||
|  | 			        packet.SetMapId(levelId); | ||||||
|  | 			        result.AddPacket(packet.ToPacketData()); | ||||||
|  | 		        } | ||||||
|  |  | ||||||
|  | 		        QueuePacket(0, result.ToPacketData()); | ||||||
|  | 	        } | ||||||
|  |  | ||||||
|  | 	        QueuePacket(0, PacketData(std::begin(g_client0_moor11), std::end(g_client0_moor11))); | ||||||
|  | 	        QueuePacket(0, PacketData(std::begin(g_client0_moor12), std::end(g_client0_moor12))); | ||||||
|  |  | ||||||
|  | 	        { | ||||||
|  | 		        PacketData outgoingPacket(std::begin(g_client0_moor13), std::end(g_client0_moor13)); | ||||||
|  |  | ||||||
|  | 		        { | ||||||
|  | 			        const uint32 setInitialPositionBase = 0x360; | ||||||
|  |  | ||||||
|  | 			        CSetInitialPositionPacket setInitialPosition; | ||||||
|  | 			        setInitialPosition.SetSourceId(PLAYER_ID); | ||||||
|  | 			        setInitialPosition.SetTargetId(PLAYER_ID); | ||||||
|  | 			        setInitialPosition.SetX(x); | ||||||
|  | 			        setInitialPosition.SetY(y); | ||||||
|  | 			        setInitialPosition.SetZ(z); | ||||||
|  | 			        setInitialPosition.SetAngle(angle); | ||||||
|  | 			        auto setInitialPositionPacket = setInitialPosition.ToPacketData(); | ||||||
|  |  | ||||||
|  | 			        memcpy(outgoingPacket.data() + setInitialPositionBase, setInitialPositionPacket.data(), setInitialPositionPacket.size()); | ||||||
|  | 		        } | ||||||
|  |  | ||||||
|  | 		        QueuePacket(0, outgoingPacket); | ||||||
|  | 	        } | ||||||
|  |  | ||||||
|  | 	        QueuePacket(0, GetInventoryInfo()); | ||||||
|  | 	        QueuePacket(0, PacketData(std::begin(g_client0_moor21), std::end(g_client0_moor21))); | ||||||
|  | 	        //QueuePacket(0, PacketData(std::begin(g_client0_moor22), std::end(g_client0_moor22))); | ||||||
|  | 	 | ||||||
|  | 	        if(!m_zoneMasterCreated) | ||||||
|  | 	        { | ||||||
|  | 		        //Zone Master | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor23), std::end(g_client0_moor23))); | ||||||
|  |  | ||||||
|  | 	        /* | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor24), std::end(g_client0_moor24))); | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor25), std::end(g_client0_moor25))); | ||||||
|  |  | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor26), std::end(g_client0_moor26))); | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor27), std::end(g_client0_moor27))); | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor28), std::end(g_client0_moor28))); | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor29), std::end(g_client0_moor29))); | ||||||
|  |  | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor30), std::end(g_client0_moor30))); | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor31), std::end(g_client0_moor31))); | ||||||
|  |  | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor32), std::end(g_client0_moor32))); | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor33), std::end(g_client0_moor33))); | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor34), std::end(g_client0_moor34))); | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor35), std::end(g_client0_moor35))); | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor36), std::end(g_client0_moor36))); | ||||||
|  | 		        QueuePacket(0, PacketData(std::begin(g_client0_moor37), std::end(g_client0_moor37))); | ||||||
|  | 	        */ | ||||||
|  | 		        //Enables chat? | ||||||
|  | 	        //	QueuePacket(0, PacketData(std::begin(g_client0_moor38), std::end(g_client0_moor38))); | ||||||
|  |         /* | ||||||
|  | 		        { | ||||||
|  | 			        CCompositePacket packet; | ||||||
|  | 			        packet.AddPacket(PacketData(std::begin(g_client0_moor38), std::end(g_client0_moor38))); | ||||||
|  | 			        QueuePacket(0, packet.ToPacketData()); | ||||||
|  | 		        } | ||||||
|  |  | ||||||
|  | 	        //	QueuePacket(0, PacketData(std::begin(g_client0_moor39), std::end(g_client0_moor39))); | ||||||
|  |  | ||||||
|  | 	        //	QueuePacket(0, PacketData(std::begin(g_client0_moor40), std::end(g_client0_moor40))); | ||||||
|  |  | ||||||
|  | 		 | ||||||
|  |  | ||||||
|  | 		        m_zoneMasterCreated = true; | ||||||
|  | 	        } | ||||||
|  |  | ||||||
|  | 	        if(zone != nullptr) | ||||||
|  | 	        { | ||||||
|  | 		        for(const auto& actorInfo : zone->actors) | ||||||
|  | 		        { | ||||||
|  | 			        SpawnNpc(actorInfo.id, actorInfo.baseModelId, actorInfo.nameStringId,  | ||||||
|  | 				        std::get<0>(actorInfo.pos), std::get<1>(actorInfo.pos), std::get<2>(actorInfo.pos), 0); | ||||||
|  | 		        } | ||||||
|  | 	        } | ||||||
|  |  | ||||||
|  | 	        m_curMap = levelId; | ||||||
|  | 	        m_posX = x; | ||||||
|  | 	        m_posY = y; | ||||||
|  | 	        m_posZ = z; | ||||||
|  |         }*/ | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ using System.Runtime.InteropServices; | |||||||
| using MySql.Data.MySqlClient; | using MySql.Data.MySqlClient; | ||||||
| using System.Reflection; | using System.Reflection; | ||||||
| using FFXIVClassic_Lobby_Server.dataobjects; | using FFXIVClassic_Lobby_Server.dataobjects; | ||||||
|  | using System.IO; | ||||||
|  |  | ||||||
| namespace FFXIVClassic_Lobby_Server | namespace FFXIVClassic_Lobby_Server | ||||||
| { | { | ||||||
| @@ -69,7 +70,26 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|                 Server server = new Server(); |                 Server server = new Server(); | ||||||
|                 server.startServer(); |                 server.startServer(); | ||||||
|  |  | ||||||
|                 while (true) Thread.Sleep(10000); |                 while (true) | ||||||
|  |                 { | ||||||
|  |                     String input = Console.ReadLine(); | ||||||
|  |                     String[] split = input.Split(' '); | ||||||
|  |  | ||||||
|  |                     if (split.Length >= 3) | ||||||
|  |                     { | ||||||
|  |                         if (split[0].Equals("sendpacket")) | ||||||
|  |                         { | ||||||
|  |                             try{ | ||||||
|  |                                 server.sendPacket("./packets/" + split[1], Int32.Parse(split[2])); | ||||||
|  |                             } | ||||||
|  |                             catch (Exception e) | ||||||
|  |                             { | ||||||
|  |                                 Log.error("Could not load packet"); | ||||||
|  |                             } | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                     Thread.Sleep(1000); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             Console.WriteLine("Press any key to continue..."); |             Console.WriteLine("Press any key to continue..."); | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ using System.Threading.Tasks; | |||||||
| using System.Threading; | using System.Threading; | ||||||
| using FFXIVClassic_Lobby_Server.common; | using FFXIVClassic_Lobby_Server.common; | ||||||
| using FFXIVClassic_Map_Server.dataobjects; | using FFXIVClassic_Map_Server.dataobjects; | ||||||
|  | using FFXIVClassic_Lobby_Server.packets; | ||||||
|  |  | ||||||
| namespace FFXIVClassic_Lobby_Server | namespace FFXIVClassic_Lobby_Server | ||||||
| { | { | ||||||
| @@ -19,7 +20,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|  |  | ||||||
|         private Socket mServerSocket; |         private Socket mServerSocket; | ||||||
|  |  | ||||||
|         private List<Player> mConnectedPlayerList = new List<Player>(); |         private Dictionary<uint,Player> mConnectedPlayerList = new Dictionary<uint,Player>(); | ||||||
|         private List<ClientConnection> mConnectionList = new List<ClientConnection>(); |         private List<ClientConnection> mConnectionList = new List<ClientConnection>(); | ||||||
|         private PacketProcessor mProcessor; |         private PacketProcessor mProcessor; | ||||||
|         private Thread mProcessorThread; |         private Thread mProcessorThread; | ||||||
| @@ -59,7 +60,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|             Console.WriteLine("{0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port); |             Console.WriteLine("{0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port); | ||||||
|             Console.ForegroundColor = ConsoleColor.Gray; |             Console.ForegroundColor = ConsoleColor.Gray; | ||||||
|  |  | ||||||
|             mProcessor = new PacketProcessor(mConnectionList); |             mProcessor = new PacketProcessor(mConnectedPlayerList, mConnectionList); | ||||||
|             mProcessorThread = new Thread(new ThreadStart(mProcessor.update)); |             mProcessorThread = new Thread(new ThreadStart(mProcessor.update)); | ||||||
|             mProcessorThread.Start(); |             mProcessorThread.Start(); | ||||||
|             return true; |             return true; | ||||||
| @@ -117,16 +118,16 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|         { |         { | ||||||
|             lock (mConnectedPlayerList) |             lock (mConnectedPlayerList) | ||||||
|             { |             { | ||||||
|                 foreach (Player p in mConnectedPlayerList) |                 foreach (KeyValuePair<uint,Player> p in mConnectedPlayerList) | ||||||
|                 { |                 { | ||||||
|                     if ((p.getConnection1().socket.RemoteEndPoint as IPEndPoint).Address.Equals((s.RemoteEndPoint as IPEndPoint).Address)) |                     if ((p.Value.getConnection1().socket.RemoteEndPoint as IPEndPoint).Address.Equals((s.RemoteEndPoint as IPEndPoint).Address)) | ||||||
|                     { |                     { | ||||||
|                         return p; |                         return p.Value; | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     if ((p.getConnection2().socket.RemoteEndPoint as IPEndPoint).Address.Equals((s.RemoteEndPoint as IPEndPoint).Address)) |                     if ((p.Value.getConnection2().socket.RemoteEndPoint as IPEndPoint).Address.Equals((s.RemoteEndPoint as IPEndPoint).Address)) | ||||||
|                     { |                     { | ||||||
|                         return p; |                         return p.Value; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -179,5 +180,10 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|  |  | ||||||
|         #endregion |         #endregion | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         public void sendPacket(string path, int conn) | ||||||
|  |         { | ||||||
|  |             mProcessor.sendPacket(path, conn); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,10 +1,10 @@ | |||||||
| [General] | [General] | ||||||
| server_ip=141.117.161.40 | server_ip=127.0.0.1 | ||||||
| showtimestamp = true | showtimestamp = true | ||||||
|  |  | ||||||
| [Database] | [Database] | ||||||
| worldid=1 | worldid=3 | ||||||
| host="141.117.162.99" | host=162.243.47.196 | ||||||
| port=3306 | port=3306 | ||||||
| database="ffxiv_server" | database="ffxiv_server" | ||||||
| username="root" | username="root" | ||||||
|   | |||||||
| @@ -52,6 +52,7 @@ namespace FFXIVClassic_Lobby_Server.common | |||||||
|             DateTime zuluTime = currentTime.ToUniversalTime(); |             DateTime zuluTime = currentTime.ToUniversalTime(); | ||||||
|             DateTime unixEpoch = new DateTime(1970, 1, 1); |             DateTime unixEpoch = new DateTime(1970, 1, 1); | ||||||
|             unixTimeStamp = (UInt32)(zuluTime.Subtract(unixEpoch)).TotalSeconds; |             unixTimeStamp = (UInt32)(zuluTime.Subtract(unixEpoch)).TotalSeconds; | ||||||
|  |  | ||||||
|             return unixTimeStamp; |             return unixTimeStamp; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -12,3 +12,17 @@ c:\users\filip\documents\visual studio 2013\Projects\FFXIVClassic Map Server\FFX | |||||||
| c:\users\filip\documents\visual studio 2013\Projects\FFXIVClassic Map Server\FFXIVClassic Map Server\bin\Debug\Newtonsoft.Json.xml | c:\users\filip\documents\visual studio 2013\Projects\FFXIVClassic Map Server\FFXIVClassic Map Server\bin\Debug\Newtonsoft.Json.xml | ||||||
| c:\users\filip\documents\visual studio 2013\Projects\FFXIVClassic Map Server\FFXIVClassic Map Server\obj\Debug\FFXIVClassic Map Server.exe | c:\users\filip\documents\visual studio 2013\Projects\FFXIVClassic Map Server\FFXIVClassic Map Server\obj\Debug\FFXIVClassic Map Server.exe | ||||||
| c:\users\filip\documents\visual studio 2013\Projects\FFXIVClassic Map Server\FFXIVClassic Map Server\obj\Debug\FFXIVClassic Map Server.pdb | c:\users\filip\documents\visual studio 2013\Projects\FFXIVClassic Map Server\FFXIVClassic Map Server\obj\Debug\FFXIVClassic Map Server.pdb | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\bin\Debug\FFXIVClassic Map Server.exe.config | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\obj\Debug\FFXIVClassic Map Server.csprojResolveAssemblyReference.cache | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\bin\Debug\FFXIVClassic Map Server.exe | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\bin\Debug\FFXIVClassic Map Server.pdb | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\bin\Debug\Cyotek.Collections.Generic.CircularBuffer.dll | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\bin\Debug\Dapper.dll | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\bin\Debug\MySql.Data.dll | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\bin\Debug\Newtonsoft.Json.dll | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\bin\Debug\Cyotek.Collections.Generic.CircularBuffer.xml | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\bin\Debug\Dapper.pdb | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\bin\Debug\Dapper.xml | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\bin\Debug\Newtonsoft.Json.xml | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\obj\Debug\FFXIVClassic Map Server.exe | ||||||
|  | C:\Users\Filip\coding\ffxiv-classic-map-server\FFXIVClassic Map Server\obj\Debug\FFXIVClassic Map Server.pdb | ||||||
|   | |||||||
| @@ -28,6 +28,7 @@ namespace FFXIVClassic_Lobby_Server.packets | |||||||
|         public BasePacketHeader header; |         public BasePacketHeader header; | ||||||
|         public byte[]           data; |         public byte[]           data; | ||||||
|  |  | ||||||
|  |         //Loads a sniffed packet from a file | ||||||
|         public unsafe BasePacket(String path) |         public unsafe BasePacket(String path) | ||||||
|         { |         { | ||||||
|             byte[] bytes = File.ReadAllBytes(path); |             byte[] bytes = File.ReadAllBytes(path); | ||||||
| @@ -49,6 +50,7 @@ namespace FFXIVClassic_Lobby_Server.packets | |||||||
|             Array.Copy(bytes, BASEPACKET_SIZE, data, 0, packetSize - BASEPACKET_SIZE); |             Array.Copy(bytes, BASEPACKET_SIZE, data, 0, packetSize - BASEPACKET_SIZE); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         //Loads a sniffed packet from a byte array | ||||||
|         public unsafe BasePacket(byte[] bytes) |         public unsafe BasePacket(byte[] bytes) | ||||||
|         { |         { | ||||||
|             if (bytes.Length < BASEPACKET_SIZE) |             if (bytes.Length < BASEPACKET_SIZE) | ||||||
| @@ -141,6 +143,29 @@ namespace FFXIVClassic_Lobby_Server.packets | |||||||
|             return outBytes; |             return outBytes; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         //Replaces all instances of the sniffed actorID with the given one | ||||||
|  |         public void replaceActorID(uint actorID) | ||||||
|  |         { | ||||||
|  |             using (MemoryStream mem = new MemoryStream(data)) | ||||||
|  |             { | ||||||
|  |                 using (BinaryWriter binWriter = new BinaryWriter(mem)) | ||||||
|  |                 { | ||||||
|  |                     using (BinaryReader binreader = new BinaryReader(mem)) | ||||||
|  |                     { | ||||||
|  |                         while (binreader.BaseStream.Position + 4 < data.Length) | ||||||
|  |                         { | ||||||
|  |                             uint read = binreader.ReadUInt32(); | ||||||
|  |                             if (read == 0x029B2941) //Original ID | ||||||
|  |                             { | ||||||
|  |                                 binWriter.BaseStream.Seek(binreader.BaseStream.Position - 0x4, SeekOrigin.Begin); | ||||||
|  |                                 binWriter.Write(actorID); | ||||||
|  |                             } | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         #region Utility Functions |         #region Utility Functions | ||||||
|         public static BasePacket createPacket(List<SubPacket> subpackets, bool isAuthed, bool isEncrypted) |         public static BasePacket createPacket(List<SubPacket> subpackets, bool isAuthed, bool isEncrypted) | ||||||
|         { |         { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user