DayZ 1.30
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 строка 559

560 {
573
574 if (g_Game.IsDedicatedServer())
575 {
576 return;
577 }
578
579 int udtIdentifier = -1;
580 if (!ctx.Read(udtIdentifier) || udtIdentifier != INPUT_UDT_INVENTORY)
581 {
582 return;
583 }
584
588
589 InventoryCommandType type = -1;
590 if (!ctx.Read(type))
591 {
592 return;
593 }
594
595 switch (type)
596 {
597 case InventoryCommandType.SYNC_MOVE:
598 {
599 src.ReadFromContext(ctx);
600 dst.ReadFromContext(ctx);
602 break;
603 }
604 case InventoryCommandType.HAND_EVENT:
605 {
606 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
607 src = e.GetSrc();
608 dst = e.GetDst();
610 break;
611 }
612 case InventoryCommandType.SWAP:
613 {
614 src.ReadFromContext(ctx);
615 temp.ReadFromContext(ctx);
616 dst.ReadFromContext(ctx);
617 temp.ReadFromContext(ctx);
618
621 break;
622 }
623 case InventoryCommandType.FORCESWAP:
624 {
625 break;
626 }
627 case InventoryCommandType.DESTROY:
628 {
629 src.ReadFromContext(ctx);
630 break;
631 }
632 }
633
635 if (!ctx.Read(reason))
636 {
637 reason = InventoryValidationReason.UNKNOWN;
638 }
639
640 OnInventoryFailure(type, reason, src, dst);
641 }
InventoryCommandType
InventoryValidationReason
const int INPUT_UDT_INVENTORY
void ClearInventoryReservationEx(ActionData action_data)
Определения ActionBase.c:1120
DayZGame g_Game
Определения DayZGame.c:4074
override void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:643
override InventoryLocation GetDst()
Определения Hand_Events.c:215
override void ClearInventoryReservation()
Определения Hand_Events.c:724
Abstracted event, not to be used, only inherited.
Определения Hand_Events.c:212
bool ReadFromContext(ParamsReadContext ctx)
Определения InventoryLocation.c:310
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
proto bool Read(void value_in)

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