DayZ 1.29
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 строка 556

557 {
570
571 if (g_Game.IsDedicatedServer())
572 {
573 return;
574 }
575
576 int udtIdentifier = -1;
577 if (!ctx.Read(udtIdentifier) || udtIdentifier != INPUT_UDT_INVENTORY)
578 {
579 return;
580 }
581
585
586 InventoryCommandType type = -1;
587 if (!ctx.Read(type))
588 {
589 return;
590 }
591
592 switch (type)
593 {
594 case InventoryCommandType.SYNC_MOVE:
595 {
596 src.ReadFromContext(ctx);
597 dst.ReadFromContext(ctx);
598 ClearInventoryReservationEx(dst.GetItem(), dst);
599 break;
600 }
601 case InventoryCommandType.HAND_EVENT:
602 {
603 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
604 src = e.GetSrc();
605 dst = e.GetDst();
607 break;
608 }
609 case InventoryCommandType.SWAP:
610 {
611 src.ReadFromContext(ctx);
612 temp.ReadFromContext(ctx);
613 dst.ReadFromContext(ctx);
614 temp.ReadFromContext(ctx);
615
616 ClearInventoryReservationEx(dst.GetItem(), dst);
617 ClearInventoryReservationEx(temp.GetItem(), temp);
618 break;
619 }
620 case InventoryCommandType.FORCESWAP:
621 {
622 break;
623 }
624 case InventoryCommandType.DESTROY:
625 {
626 src.ReadFromContext(ctx);
627 break;
628 }
629 }
630
632 if (!ctx.Read(reason))
633 {
634 reason = InventoryValidationReason.UNKNOWN;
635 }
636
637 OnInventoryFailure(type, reason, src, dst);
638 }
InventoryCommandType
InventoryValidationReason
const int INPUT_UDT_INVENTORY
DayZGame g_Game
Определения DayZGame.c:3942
override void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:640
override InventoryLocation GetDst()
Определения Hand_Events.c:215
override void ClearInventoryReservation()
Определения Hand_Events.c:718
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(), g_Game, HandEventBase::GetDst(), InventoryLocation::GetItem(), INPUT_UDT_INVENTORY, OnInventoryFailure(), Serializer::Read() и InventoryLocation::ReadFromContext().