mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04:00 
			
		
		
		
	Added all Console writes to the log. Put in "Max chars" for character list.
This commit is contained in:
		| @@ -103,7 +103,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|                     case 0x0F: |                     case 0x0F: | ||||||
|                         //Mod Retainers |                         //Mod Retainers | ||||||
|                     default: |                     default: | ||||||
|                         Debug.WriteLine("Unknown command 0x{0:X} received.", subpacket.header.opcode); |                         Log.debug(String.Format("Unknown command 0x{0:X} received.", subpacket.header.opcode)); | ||||||
|                         break; |                         break; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -117,7 +117,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|             byte[] blowfishKey = { 0xB4, 0xEE, 0x3F, 0x6C, 0x01, 0x6F, 0x5B, 0xD9, 0x71, 0x50, 0x0D, 0xB1, 0x85, 0xA2, 0xAB, 0x43}; |             byte[] blowfishKey = { 0xB4, 0xEE, 0x3F, 0x6C, 0x01, 0x6F, 0x5B, 0xD9, 0x71, 0x50, 0x0D, 0xB1, 0x85, 0xA2, 0xAB, 0x43}; | ||||||
|             client.blowfish = new Blowfish(blowfishKey); |             client.blowfish = new Blowfish(blowfishKey); | ||||||
|  |  | ||||||
|             Console.WriteLine("Received encryption key: 0x{0:X}", clientTime); |             Log.info(String.Format("Received encryption key: 0x{0:X}", clientTime)); | ||||||
|  |  | ||||||
|             //Respond with acknowledgment |             //Respond with acknowledgment | ||||||
|             BasePacket outgoingPacket = new BasePacket(HardCoded_Packets.g_secureConnectionAcknowledgment); |             BasePacket outgoingPacket = new BasePacket(HardCoded_Packets.g_secureConnectionAcknowledgment); | ||||||
| @@ -131,9 +131,9 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|             String sessionId = sessionPacket.session; |             String sessionId = sessionPacket.session; | ||||||
|             String clientVersion = sessionPacket.version; |             String clientVersion = sessionPacket.version; | ||||||
|  |  | ||||||
|             Console.WriteLine("Got acknowledgment for secure session."); |             Log.info(String.Format("Got acknowledgment for secure session.")); | ||||||
|             Console.WriteLine("SESSION ID: {0}", sessionId); |             Log.info(String.Format("SESSION ID: {0}", sessionId)); | ||||||
|             Console.WriteLine("CLIENT VERSION: {0}", clientVersion); |             Log.info(String.Format("CLIENT VERSION: {0}", clientVersion)); | ||||||
|  |  | ||||||
|             uint userId = Database.getUserIdFromSession(sessionId); |             uint userId = Database.getUserIdFromSession(sessionId); | ||||||
|             client.currentUserId = userId; |             client.currentUserId = userId; | ||||||
| @@ -141,10 +141,10 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|             if (userId == 0) |             if (userId == 0) | ||||||
|             { |             { | ||||||
|                 //client.disconnect(); |                 //client.disconnect(); | ||||||
|                 Console.WriteLine("Invalid session, kicking..."); |                 Log.info(String.Format("Invalid session, kicking...")); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             Console.WriteLine("USER ID: {0}", userId); |             Log.info(String.Format("USER ID: {0}", userId)); | ||||||
|             BasePacket outgoingPacket = new BasePacket("./packets/loginAck.bin"); |             BasePacket outgoingPacket = new BasePacket("./packets/loginAck.bin"); | ||||||
|             BasePacket.encryptPacket(client.blowfish, outgoingPacket); |             BasePacket.encryptPacket(client.blowfish, outgoingPacket); | ||||||
|             client.queuePacket(outgoingPacket); |             client.queuePacket(outgoingPacket); | ||||||
| @@ -152,12 +152,18 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|  |  | ||||||
|         private void ProcessGetCharacters(ClientConnection client, SubPacket packet) |         private void ProcessGetCharacters(ClientConnection client, SubPacket packet) | ||||||
|         {    |         {    | ||||||
| 	        Console.WriteLine("{0} => Get characters", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId); | 	        Log.info(String.Format("{0} => Get characters", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId)); | ||||||
|  |  | ||||||
|             sendWorldList(client, packet); |             sendWorldList(client, packet); | ||||||
|             sendImportList(client, packet); |             sendImportList(client, packet); | ||||||
|             sendRetainerList(client, packet); |             sendRetainerList(client, packet); | ||||||
|             sendCharacterList(client, packet); |             //sendCharacterList(client, packet); | ||||||
|  |  | ||||||
|  |             //BasePacket outgoingPacket = new BasePacket("./packets/getCharsPacket.bin"); | ||||||
|  |             BasePacket outgoingPacket = new BasePacket("./packets/getChars_GOOD.bin"); | ||||||
|  |             BasePacket.encryptPacket(client.blowfish, outgoingPacket); | ||||||
|  |             client.queuePacket(outgoingPacket); | ||||||
|  |  | ||||||
|  |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -171,7 +177,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|                 binReader.Close(); |                 binReader.Close(); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             Console.WriteLine("{0} => Select character id {1}", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId, characterId);	         |             Log.info(String.Format("{0} => Select character id {1}", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId, characterId));	         | ||||||
|  |  | ||||||
| 	        String serverIp = "141.117.162.99"; | 	        String serverIp = "141.117.162.99"; | ||||||
|             ushort port = 54992; |             ushort port = 54992; | ||||||
| @@ -221,7 +227,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|                 BasePacket.encryptPacket(client.blowfish, basePacket); |                 BasePacket.encryptPacket(client.blowfish, basePacket); | ||||||
|                 client.queuePacket(basePacket); |                 client.queuePacket(basePacket); | ||||||
|  |  | ||||||
|                 Console.WriteLine("User {0} => Error; invalid server id: \"{1}\"", client.currentUserId, worldId); |                 Log.info(String.Format("User {0} => Error; invalid server id: \"{1}\"", client.currentUserId, worldId)); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -325,9 +331,8 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|         { |         { | ||||||
|             List<Character> characterList = Database.getCharacters(client.currentUserId); |             List<Character> characterList = Database.getCharacters(client.currentUserId); | ||||||
|  |  | ||||||
|             CharacterListPacket characterlistPacket = new CharacterListPacket(2, characterList); |             CharacterListPacket characterlistPacket = new CharacterListPacket(2, characterList, 2); | ||||||
|             List<SubPacket> subPackets = characterlistPacket.buildPackets(); |             List<SubPacket> subPackets = characterlistPacket.buildPackets(); | ||||||
|             subPackets[0].debugPrintSubPacket(); |  | ||||||
|             BasePacket basePacket = BasePacket.createPacket(subPackets, true, false); |             BasePacket basePacket = BasePacket.createPacket(subPackets, true, false); | ||||||
|             BasePacket.encryptPacket(client.blowfish, basePacket); |             BasePacket.encryptPacket(client.blowfish, basePacket); | ||||||
|             client.queuePacket(basePacket); |             client.queuePacket(basePacket); | ||||||
|   | |||||||
| @@ -47,7 +47,7 @@ namespace FFXIVClassic_Lobby_Server.common | |||||||
|         public static void conn(String message) |         public static void conn(String message) | ||||||
|         { |         { | ||||||
|             Console.Write("[{0}]", DateTime.Now.ToString("dd/MMM HH:mm")); |             Console.Write("[{0}]", DateTime.Now.ToString("dd/MMM HH:mm")); | ||||||
|             Console.ForegroundColor = ConsoleColor.DarkGreen; |             Console.ForegroundColor = ConsoleColor.Green; | ||||||
|             Console.Write("[CONN] "); |             Console.Write("[CONN] "); | ||||||
|             Console.ForegroundColor = ConsoleColor.Gray; |             Console.ForegroundColor = ConsoleColor.Gray; | ||||||
|             Console.WriteLine(message); |             Console.WriteLine(message); | ||||||
|   | |||||||
| @@ -14,12 +14,14 @@ namespace FFXIVClassic_Lobby_Server.packets | |||||||
|         public const ushort MAXPERPACKET = 2; |         public const ushort MAXPERPACKET = 2; | ||||||
|  |  | ||||||
|         private ulong sequence; |         private ulong sequence; | ||||||
|  |         private ushort maxChars; | ||||||
|         private List<Character> characterList; |         private List<Character> characterList; | ||||||
|  |  | ||||||
|         public CharacterListPacket(ulong sequence, List<Character> characterList) |         public CharacterListPacket(ulong sequence, List<Character> characterList, ushort maxChars) | ||||||
|         { |         { | ||||||
|             this.sequence = sequence; |             this.sequence = sequence; | ||||||
|             this.characterList = characterList; |             this.characterList = characterList; | ||||||
|  |             this.maxChars = maxChars; | ||||||
|         }         |         }         | ||||||
|  |  | ||||||
|         public List<SubPacket> buildPackets() |         public List<SubPacket> buildPackets() | ||||||
| @@ -36,14 +38,14 @@ namespace FFXIVClassic_Lobby_Server.packets | |||||||
|             { |             { | ||||||
|                 if (totalCount == 0 || characterCount % MAXPERPACKET == 0) |                 if (totalCount == 0 || characterCount % MAXPERPACKET == 0) | ||||||
|                 { |                 { | ||||||
|                     memStream = new MemoryStream(0x3D0); |                     memStream = new MemoryStream(0x3B0); | ||||||
|                     binWriter = new BinaryWriter(memStream); |                     binWriter = new BinaryWriter(memStream); | ||||||
|  |  | ||||||
|                     //Write List Info |                     //Write List Info | ||||||
|                     binWriter.Write((UInt64)sequence); |                     binWriter.Write((UInt64)sequence); | ||||||
|                     binWriter.Write(characterList.Count - totalCount <= MAXPERPACKET ? (byte)(characterList.Count) : (byte)0); |                     binWriter.Write(maxChars - totalCount <= MAXPERPACKET ? (byte)(maxChars + 1) : (byte)0); | ||||||
|                     //binWriter.Write((byte)1); |                     //binWriter.Write((byte)1); | ||||||
|                     binWriter.Write(characterList.Count - totalCount <= MAXPERPACKET ? (UInt32)(characterList.Count - totalCount) : (UInt32)MAXPERPACKET); |                     binWriter.Write(maxChars - totalCount <= MAXPERPACKET ? (UInt32)(maxChars - totalCount) : (UInt32)MAXPERPACKET); | ||||||
|                     binWriter.Write((byte)0); |                     binWriter.Write((byte)0); | ||||||
|                     binWriter.Write((UInt16)0); |                     binWriter.Write((UInt16)0); | ||||||
|                 } |                 } | ||||||
| @@ -89,10 +91,53 @@ namespace FFXIVClassic_Lobby_Server.packets | |||||||
|  |  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             //If there is anything left that was missed or the list is empty |             //Keep creating empty slots until done max characters | ||||||
|             if (characterCount > 0 || characterList.Count == 0) |             while (maxChars - totalCount > 0) | ||||||
|             { |             { | ||||||
|                 if (characterList.Count == 0) |                 if (characterCount % MAXPERPACKET == 0) | ||||||
|  |                 { | ||||||
|  |                     memStream = new MemoryStream(0x3D0); | ||||||
|  |                     binWriter = new BinaryWriter(memStream); | ||||||
|  |  | ||||||
|  |                     //Write List Info | ||||||
|  |                     binWriter.Write((UInt64)sequence); | ||||||
|  |                     binWriter.Write(maxChars - totalCount <= MAXPERPACKET ? (byte)(maxChars + 1) : (byte)0); | ||||||
|  |                     //binWriter.Write((byte)1); | ||||||
|  |                     binWriter.Write(maxChars - totalCount <= MAXPERPACKET ? (UInt32)(maxChars - totalCount) : (UInt32)MAXPERPACKET); | ||||||
|  |                     binWriter.Write((byte)0); | ||||||
|  |                     binWriter.Write((UInt16)0); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 binWriter.Seek(0x10 + (0x1D0 * characterCount), SeekOrigin.Begin); | ||||||
|  |  | ||||||
|  |                 //Write Entries | ||||||
|  |                 binWriter.Write((uint)0); //??? | ||||||
|  |                 binWriter.Write((uint)0); //Character Id             | ||||||
|  |                 binWriter.Write((byte)(totalCount)); //Slot | ||||||
|  |  | ||||||
|  |                 binWriter.Write((byte)0); //Options (0x01: Service Account not active, 0x72: Change Chara Name)  | ||||||
|  |                 binWriter.Write((ushort)0); | ||||||
|  |                 binWriter.Write((uint)0); //Logged out zone | ||||||
|  |  | ||||||
|  |                 characterCount++; | ||||||
|  |                 totalCount++; | ||||||
|  |  | ||||||
|  |                 //Send this chunk of character list | ||||||
|  |                 if (characterCount >= MAXPERPACKET) | ||||||
|  |                 { | ||||||
|  |                     byte[] data = memStream.GetBuffer(); | ||||||
|  |                     binWriter.Dispose(); | ||||||
|  |                     memStream.Dispose(); | ||||||
|  |                     SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, 0xe0006868, data); | ||||||
|  |                     subPackets.Add(subpacket); | ||||||
|  |                     characterCount = 0; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             //If there is anything left that was missed or the list is empty | ||||||
|  |             if (characterCount > 0 || maxChars == 0) | ||||||
|  |             { | ||||||
|  |                 if (maxChars == 0) | ||||||
|                 { |                 { | ||||||
|                     memStream = new MemoryStream(0x3D0); |                     memStream = new MemoryStream(0x3D0); | ||||||
|                     binWriter = new BinaryWriter(memStream); |                     binWriter = new BinaryWriter(memStream); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user