DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ OnInventoryJunctureFailureFromServer()

override void OnInventoryJunctureFailureFromServer ( ParamsReadContext ctx)
protected

Function and setup is still messy due to the switch statement and relation with reading.

It could be cleaner if we used classes to handle each inventory command type, but that comes at a performance cost and will also probably require making a fair amount of changes elsewhere.

The downsides with this system right now:

  1. It makes it hard to track what is written/read from the serializer
  2. It makes this file very very large

The new changes at least remove the massive switch block and allow for all inventory commands to respond back to the client if something goes wrong

См. определение в файле DayZPlayerInventory.c строка 581

582 {
595
596 if (GetGame().IsDedicatedServer())
597 {
598 return;
599 }
600
601 int udtIdentifier = -1;
602 if (!ctx.Read(udtIdentifier) || udtIdentifier != INPUT_UDT_INVENTORY)
603 {
604 return;
605 }
606
610
611 InventoryCommandType type = -1;
612 if (!ctx.Read(type))
613 {
614 return;
615 }
616
617 switch (type)
618 {
619 case InventoryCommandType.SYNC_MOVE:
620 {
621 src.ReadFromContext(ctx);
622 dst.ReadFromContext(ctx);
623 ClearInventoryReservationEx(dst.GetItem(), dst);
624 break;
625 }
626 case InventoryCommandType.HAND_EVENT:
627 {
628 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
629 src = e.GetSrc();
630 dst = e.GetDst();
632 break;
633 }
634 case InventoryCommandType.SWAP:
635 {
636 src.ReadFromContext(ctx);
637 temp.ReadFromContext(ctx);
638 dst.ReadFromContext(ctx);
639 temp.ReadFromContext(ctx);
640
641 ClearInventoryReservationEx(dst.GetItem(), dst);
642 ClearInventoryReservationEx(temp.GetItem(), temp);
643 break;
644 }
645 case InventoryCommandType.FORCESWAP:
646 {
647 break;
648 }
649 case InventoryCommandType.DESTROY:
650 {
651 src.ReadFromContext(ctx);
652 break;
653 }
654 }
655
657 if (!ctx.Read(reason))
658 {
659 reason = InventoryValidationReason.UNKNOWN;
660 }
661
662 OnInventoryFailure(type, reason, src, dst);
663 }
InventoryCommandType
Определения Inventory.c:3
InventoryValidationReason
Определения Inventory.c:37
const int INPUT_UDT_INVENTORY
Определения _constants.c:9
override void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:665
override InventoryLocation GetDst()
Определения Hand_Events.c:212
override void ClearInventoryReservation()
Определения Hand_Events.c:671
Abstracted event, not to be used, only inherited.
Определения Hand_Events.c:209
bool ReadFromContext(ParamsReadContext ctx)
Определения InventoryLocation.c:296
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
proto bool Read(void value_in)
proto native CGame GetGame()

Перекрестные ссылки HandEventBase::ClearInventoryReservation(), HandEventBase::GetDst(), GetGame(), InventoryLocation::GetItem(), INPUT_UDT_INVENTORY, OnInventoryFailure(), Serializer::Read() и InventoryLocation::ReadFromContext().