Change RelatedInt to IntList in InventoryActionPkt
This commit is contained in:
parent
6a48f0aa20
commit
c33f3b7d58
@ -56,17 +56,17 @@ namespace Cyber.Items {
|
||||
/// <param name="action">The <see cref="InventoryAction"/> to run</param>
|
||||
/// <param name="relatedInt">The item related to the action.</param>
|
||||
/// <returns>Weather the action failed or not.</returns>
|
||||
public bool HandleAction(InventoryAction action, int relatedInt) {
|
||||
public bool HandleAction(InventoryAction action, int[] intList) {
|
||||
switch (action) {
|
||||
case InventoryAction.Equip:
|
||||
Inventory.Drive.EquipItem(relatedInt);
|
||||
Inventory.Drive.EquipItem(intList[0]);
|
||||
return true;
|
||||
case InventoryAction.Unequip:
|
||||
EquipSlot Slot = (EquipSlot) relatedInt;
|
||||
EquipSlot Slot = (EquipSlot) intList[0];
|
||||
Inventory.Drive.UnequipSlot(Slot);
|
||||
return true;
|
||||
case InventoryAction.Use:
|
||||
EquipSlot UseSlot = (EquipSlot) relatedInt;
|
||||
EquipSlot UseSlot = (EquipSlot) intList[0];
|
||||
Item UseItem = Inventory.Drive.GetSlot(UseSlot);
|
||||
if (UseItem != null && UseItem.Action != null && Character != null &&
|
||||
(!Client.IsRunning() || Client.GetConnectedPlayer().Character != Character)) {
|
||||
|
@ -209,7 +209,7 @@ namespace Cyber.Networking.Clientside {
|
||||
case (PktType.MassIdentity):
|
||||
IntListPkt Identities = new IntListPkt();
|
||||
Identities.Deserialize(msg.reader);
|
||||
foreach (int currId in Identities.IdList) {
|
||||
foreach (int currId in Identities.IntList) {
|
||||
Players.Add(currId, new CConnectedPlayer(currId));
|
||||
}
|
||||
break;
|
||||
@ -268,7 +268,7 @@ namespace Cyber.Networking.Clientside {
|
||||
case (PktType.StaticObjectIds):
|
||||
IntListPkt StaticIds = new IntListPkt();
|
||||
StaticIds.Deserialize(msg.reader);
|
||||
Spawner.SyncDB.SetStaticObjectsIDs(StaticIds.IdList);
|
||||
Spawner.SyncDB.SetStaticObjectsIDs(StaticIds.IntList);
|
||||
break;
|
||||
case (PktType.Disconnect):
|
||||
DisconnectPkt Disconnect = new DisconnectPkt();
|
||||
@ -290,7 +290,7 @@ namespace Cyber.Networking.Clientside {
|
||||
break;
|
||||
}
|
||||
|
||||
Inventory.ActionHandler.HandleAction(InventoryActionPkt.Action, InventoryActionPkt.RelatedInt);
|
||||
Inventory.ActionHandler.HandleAction(InventoryActionPkt.Action, InventoryActionPkt.IntList);
|
||||
|
||||
break;
|
||||
default:
|
||||
|
@ -11,14 +11,14 @@ namespace Cyber.Networking.Messages {
|
||||
/// <summary>
|
||||
/// List of Integers.
|
||||
/// </summary>
|
||||
public int[] IdList;
|
||||
public int[] IntList;
|
||||
|
||||
/// <summary>
|
||||
/// Create a packet containing integers.
|
||||
/// </summary>
|
||||
/// <param name="idList"></param>
|
||||
public IntListPkt(int[] idList) {
|
||||
IdList = idList;
|
||||
IntList = idList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -38,7 +38,7 @@ namespace Cyber.Networking.Messages {
|
||||
ByteArray[1] = reader.ReadBytesAndSize();
|
||||
ByteArray[2] = reader.ReadBytesAndSize();
|
||||
ByteArray[3] = reader.ReadBytesAndSize();
|
||||
IdList = NetworkHelper.DeserializeIntArray(ByteArray);
|
||||
IntList = NetworkHelper.DeserializeIntArray(ByteArray);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -46,7 +46,7 @@ namespace Cyber.Networking.Messages {
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
public override void Serialize(NetworkWriter writer) {
|
||||
byte[][] ByteArray = NetworkHelper.SerializeIntArray(IdList);
|
||||
byte[][] ByteArray = NetworkHelper.SerializeIntArray(IntList);
|
||||
writer.WriteBytesFull(ByteArray[0]);
|
||||
writer.WriteBytesFull(ByteArray[1]);
|
||||
writer.WriteBytesFull(ByteArray[2]);
|
||||
|
@ -15,9 +15,9 @@ namespace Cyber.Networking.Messages {
|
||||
public InventoryAction Action;
|
||||
|
||||
/// <summary>
|
||||
/// The related int to the <see cref="InventoryAction"/>
|
||||
/// The related int list to the <see cref="InventoryAction"/>
|
||||
/// </summary>
|
||||
public int RelatedInt;
|
||||
public int[] IntList;
|
||||
|
||||
/// <summary>
|
||||
/// The inventory SyncBaseID this happened in. Only set by server.
|
||||
@ -29,9 +29,19 @@ namespace Cyber.Networking.Messages {
|
||||
/// </summary>
|
||||
/// <param name="action">The action done.</param>
|
||||
/// <param name="relatedInt"></param>
|
||||
public InventoryActionPkt(InventoryAction action, int[] intList) {
|
||||
Action = action;
|
||||
IntList = intList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an inventory packet containing only one int.
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="relatedInt"></param>
|
||||
public InventoryActionPkt(InventoryAction action, int relatedInt) {
|
||||
Action = action;
|
||||
RelatedInt = relatedInt;
|
||||
IntList = new int[1] { relatedInt };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -45,7 +55,7 @@ namespace Cyber.Networking.Messages {
|
||||
/// <param name="reader"></param>
|
||||
public override void Deserialize(NetworkReader reader) {
|
||||
Action = (InventoryAction) reader.ReadByte();
|
||||
RelatedInt = reader.ReadInt32();
|
||||
IntList = reader.ReadMessage<IntListPkt>().IntList;
|
||||
SyncBaseID = reader.ReadInt32();
|
||||
}
|
||||
|
||||
@ -55,7 +65,7 @@ namespace Cyber.Networking.Messages {
|
||||
/// <param name="writer"></param>
|
||||
public override void Serialize(NetworkWriter writer) {
|
||||
writer.Write((byte) Action);
|
||||
writer.Write(RelatedInt);
|
||||
writer.Write(new IntListPkt(IntList));
|
||||
writer.Write(SyncBaseID);
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ namespace Cyber.Networking.Serverside {
|
||||
case PktType.FailedChecksums:
|
||||
IntListPkt FailedSyncs = new IntListPkt();
|
||||
FailedSyncs.Deserialize(msg.reader);
|
||||
foreach (int SyncBaseId in FailedSyncs.IdList) {
|
||||
foreach (int SyncBaseId in FailedSyncs.IntList) {
|
||||
Syncer.DirtSyncBase(SyncBaseId);
|
||||
}
|
||||
break;
|
||||
@ -249,7 +249,7 @@ namespace Cyber.Networking.Serverside {
|
||||
Inventory CurrInventory = Character.GetComponent<Inventory>();
|
||||
InventoryActionPkt.SyncBaseID = CurrInventory.ID;
|
||||
|
||||
if (CurrInventory.ActionHandler.HandleAction(InventoryActionPkt.Action, InventoryActionPkt.RelatedInt)) {
|
||||
if (CurrInventory.ActionHandler.HandleAction(InventoryActionPkt.Action, InventoryActionPkt.IntList)) {
|
||||
SendToAll(PktType.InventoryAction, InventoryActionPkt);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user