mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04:00 
			
		
		
		
	implemented sendpacket and speed commands
- fixed data race on logging in - todo: implement reloadzones, reloaditems, property, property2
This commit is contained in:
		| @@ -35,25 +35,6 @@ namespace FFXIVClassic_Map_Server | ||||
|             mConnectedPlayerList = playerList; | ||||
|         } | ||||
|  | ||||
|         public void SendPacket(ConnectedPlayer client, string path) | ||||
|         { | ||||
|             BasePacket packet = new BasePacket(path); | ||||
|  | ||||
|             if (client != null) | ||||
|             { | ||||
|                 packet.ReplaceActorID(client.actorID); | ||||
|                 client.QueuePacket(packet); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList) | ||||
|                 { | ||||
|                     packet.ReplaceActorID(entry.Value.actorID); | ||||
|                     entry.Value.QueuePacket(packet); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public void ChangeProperty(uint id, uint value, string target) | ||||
|         { | ||||
|             SetActorPropetyPacket ChangeProperty = new SetActorPropetyPacket(target); | ||||
| @@ -87,7 +68,7 @@ namespace FFXIVClassic_Map_Server | ||||
|  | ||||
|         internal bool DoCommand(string input, ConnectedPlayer client) | ||||
|         { | ||||
|             if (!input.Any()) | ||||
|             if (!input.Any() || input.Equals("")) | ||||
|                 return false; | ||||
|  | ||||
|             input.Trim(); | ||||
| @@ -102,7 +83,7 @@ namespace FFXIVClassic_Map_Server | ||||
|  | ||||
|             split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands | ||||
|  | ||||
|             var cmd = split?.ElementAt(0); | ||||
|             var cmd = split[0]; | ||||
|  | ||||
|             if (cmd.Any()) | ||||
|             { | ||||
| @@ -138,6 +119,8 @@ namespace FFXIVClassic_Map_Server | ||||
|             if (split.Length >= 1) | ||||
|             { | ||||
|              | ||||
|                 // TODO: reloadzones | ||||
|  | ||||
|             #region !reloaditems | ||||
|             if (split[0].Equals("reloaditems")) | ||||
|                 { | ||||
| @@ -151,24 +134,6 @@ namespace FFXIVClassic_Map_Server | ||||
|                 } | ||||
|                 #endregion | ||||
|  | ||||
|                 #region !sendpacket | ||||
|                 else if (split[0].Equals("sendpacket")) | ||||
|                 { | ||||
|                     if (split.Length < 2) | ||||
|                         return false; | ||||
|  | ||||
|                     try | ||||
|                     { | ||||
|                         SendPacket(client, "./packets/" + split[1]); | ||||
|                         return true; | ||||
|                     } | ||||
|                     catch (Exception e) | ||||
|                     { | ||||
|                         Program.Log.Error("Could not load packet: " + e); | ||||
|                     } | ||||
|                 } | ||||
|                 #endregion | ||||
|  | ||||
|                 #region !property | ||||
|                 else if (split[0].Equals("property")) | ||||
|                 { | ||||
|   | ||||
| @@ -419,6 +419,8 @@ namespace FFXIVClassic_Map_Server | ||||
|                             player.oldRotation = player.rotation = reader.GetFloat(4); | ||||
|                             player.currentMainState = reader.GetUInt16(5); | ||||
|                             player.zoneId = reader.GetUInt32(6); | ||||
|                             player.isZoning = true; | ||||
|                             player.zone = Server.GetWorldManager().GetZone(player.zoneId); | ||||
|                             player.gcCurrent = reader.GetByte(7); | ||||
|                             player.gcRankLimsa = reader.GetByte(8); | ||||
|                             player.gcRankGridania = reader.GetByte(9); | ||||
|   | ||||
| @@ -112,7 +112,7 @@ namespace FFXIVClassic_Map_Server | ||||
|  | ||||
|                     if (packet.header.connectionType == BasePacket.TYPE_ZONE) | ||||
|                     { | ||||
|                         while (!mPlayers.ContainsKey(client.owner)) | ||||
|                         while (mPlayers != null && !mPlayers.ContainsKey(client.owner)) | ||||
|                         { } | ||||
|                         player = mPlayers[client.owner]; | ||||
|                     } | ||||
| @@ -127,9 +127,9 @@ namespace FFXIVClassic_Map_Server | ||||
|                     player.SetConnection(packet.header.connectionType, client); | ||||
|  | ||||
|                     if (packet.header.connectionType == BasePacket.TYPE_ZONE) | ||||
|                         Program.Log.Debug("Got {0} connection for ActorID {1} @ {2}.", "zone", actorID, client.GetAddress()); | ||||
|                         Program.Log.Info("Got {0} connection for ActorID {1} @ {2}.", "zone", actorID, client.GetAddress()); | ||||
|                     else if (packet.header.connectionType == BasePacket.TYPE_CHAT) | ||||
|                         Program.Log.Debug("Got {0} connection for ActorID {1} @ {2}.", "chat", actorID, client.GetAddress()); | ||||
|                         Program.Log.Info("Got {0} connection for ActorID {1} @ {2}.", "chat", actorID, client.GetAddress()); | ||||
|  | ||||
|                     //Create player actor | ||||
|                     reply1.DebugPrintPacket(); | ||||
| @@ -139,12 +139,14 @@ namespace FFXIVClassic_Map_Server | ||||
|                 } | ||||
|                 else if (subpacket.header.type == 0x07) | ||||
|                 { | ||||
|                     BasePacket init = Login0x7ResponsePacket.BuildPacket(BitConverter.ToUInt32(packet.data, 0x10), Utils.UnixTimeStampUTC()); | ||||
|                     BasePacket init = Login0x7ResponsePacket.BuildPacket(BitConverter.ToUInt32(packet.data, 0x10), Utils.UnixTimeStampUTC(), 0x08); | ||||
|                     //client.QueuePacket(init); | ||||
|                 } | ||||
|                 else if (subpacket.header.type == 0x08) | ||||
|                 { | ||||
|                     //Response, client's current [actorID][time] | ||||
|                 { | ||||
|                     //Response, client's current [actorID][time] | ||||
|                     //BasePacket init = Login0x7ResponsePacket.BuildPacket(BitConverter.ToUInt32(packet.data, 0x10), Utils.UnixTimeStampUTC(), 0x07); | ||||
|                     //client.QueuePacket(init); | ||||
|                     packet.DebugPrintPacket(); | ||||
|                 } | ||||
|                 else if (subpacket.header.type == 0x03) | ||||
| @@ -154,7 +156,7 @@ namespace FFXIVClassic_Map_Server | ||||
|                     if(mPlayers.ContainsKey(client.owner)) | ||||
|                         player = mPlayers[client.owner]; | ||||
|  | ||||
|                     if (player == null) | ||||
|                     if (player == null || !player.IsClientConnectionsReady()) | ||||
|                         return; | ||||
|  | ||||
|                     //Normal Game Opcode | ||||
|   | ||||
| @@ -70,7 +70,7 @@ namespace FFXIVClassic_Map_Server | ||||
|                 { | ||||
|                     String input = Console.ReadLine(); | ||||
|                     Log.Info("[Console Input] " + input); | ||||
|                     cp.DoCommand(input, null);   | ||||
|                     cp.DoCommand(input, null); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|   | ||||
| @@ -601,6 +601,21 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|                 playerSession.QueuePacket(subpacket, true, false); | ||||
|         } | ||||
|  | ||||
|         public void SendPacket(string path) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 BasePacket packet = new BasePacket(path); | ||||
|  | ||||
|                 packet.ReplaceActorID(actorId); | ||||
|                 QueuePacket(packet); | ||||
|             } | ||||
|             catch (Exception e) | ||||
|             { | ||||
|                 this.SendMessage(SendMessagePacket.MESSAGE_TYPE_SYSTEM_ERROR, "[SendPacket]", "Unable to send packet."); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public void BroadcastPacket(SubPacket packet, bool sendToSelf) | ||||
|         { | ||||
|             if (sendToSelf)             | ||||
| @@ -749,26 +764,6 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|             //zone.BroadcastPacketAroundActor(this, worldMasterMessage); | ||||
|         } | ||||
|  | ||||
|         public void ChangeProperty(uint id, uint value, string target) | ||||
|         { | ||||
|             SetActorPropetyPacket ChangeProperty = new SetActorPropetyPacket(target); | ||||
|  | ||||
|             ChangeProperty.SetTarget(target); | ||||
|             ChangeProperty.AddInt(id, value); | ||||
|             ChangeProperty.AddTarget(); | ||||
|  | ||||
|           /*foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList) | ||||
|             { | ||||
|                 SubPacket ChangePropertyPacket = ChangeProperty.BuildPacket((entry.Value.actorID), (entry.Value.actorID)); | ||||
|  | ||||
|                 BasePacket packet = BasePacket.CreatePacket(ChangePropertyPacket, true, false); | ||||
|                 packet.DebugPrintPacket(); | ||||
|  | ||||
|                 entry.Value.QueuePacket(packet); | ||||
|             } | ||||
|           */ | ||||
|         } | ||||
|  | ||||
|         public void GraphicChange(uint slot, uint graphicId) | ||||
|         { | ||||
|             appearanceIds[slot] = graphicId;            | ||||
|   | ||||
| @@ -70,8 +70,8 @@ namespace FFXIVClassic_Map_Server.dataobjects | ||||
|         } | ||||
|  | ||||
|         public void QueuePacket(SubPacket subPacket, bool isAuthed, bool isEncrypted) | ||||
|         { | ||||
|                 zoneConnection.QueuePacket(subPacket, isAuthed, isEncrypted); | ||||
|         { | ||||
|             zoneConnection.QueuePacket(subPacket, isAuthed, isEncrypted); | ||||
|         } | ||||
|  | ||||
|         public Player GetActor() | ||||
| @@ -97,7 +97,7 @@ namespace FFXIVClassic_Map_Server.dataobjects | ||||
|         } | ||||
|  | ||||
|         public void UpdatePlayerActorPosition(float x, float y, float z, float rot, ushort moveState) | ||||
|         {             | ||||
|         { | ||||
|             playerActor.oldPositionX = playerActor.positionX; | ||||
|             playerActor.oldPositionY = playerActor.positionY; | ||||
|             playerActor.oldPositionZ = playerActor.positionZ; | ||||
|   | ||||
| @@ -5,7 +5,7 @@ namespace FFXIVClassic_Map_Server.packets.send.login | ||||
| { | ||||
|     class Login0x7ResponsePacket | ||||
|     { | ||||
|         public static BasePacket BuildPacket(uint actorID, uint time) | ||||
|         public static BasePacket BuildPacket(uint actorID, uint time, uint type) | ||||
|         { | ||||
|             byte[] data = new byte[0x18]; | ||||
|  | ||||
| @@ -16,7 +16,7 @@ namespace FFXIVClassic_Map_Server.packets.send.login | ||||
|                     try | ||||
|                     { | ||||
|                         binWriter.Write((short)0x18); | ||||
|                         binWriter.Write((short)0x8); | ||||
|                         binWriter.Write((short)type); | ||||
|                         binWriter.Write((uint)0); | ||||
|                         binWriter.Write((uint)0); | ||||
|                         binWriter.Write((uint)0xFFFFFD7F); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user