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:
- It makes it hard to track what is written/read from the serializer
- 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;
578 {
579 return;
580 }
581
585
588 {
589 return;
590 }
591
592 switch (type)
593 {
595 {
598 ClearInventoryReservationEx(dst.
GetItem(), dst);
599 break;
600 }
602 {
604 src = e.GetSrc();
607 break;
608 }
610 {
615
616 ClearInventoryReservationEx(dst.
GetItem(), dst);
617 ClearInventoryReservationEx(temp.
GetItem(), temp);
618 break;
619 }
621 {
622 break;
623 }
625 {
627 break;
628 }
629 }
630
632 if (!ctx.
Read(reason))
633 {
635 }
636
638 }
InventoryValidationReason
override void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
override InventoryLocation GetDst()
override void ClearInventoryReservation()
Abstracted event, not to be used, only inherited.
bool ReadFromContext(ParamsReadContext ctx)
proto native EntityAI GetItem()
returns item of current inventory location
proto bool Read(void value_in)
Перекрестные ссылки HandEventBase::ClearInventoryReservation(), g_Game, HandEventBase::GetDst(), InventoryLocation::GetItem(), INPUT_UDT_INVENTORY, OnInventoryFailure(), Serializer::Read() и InventoryLocation::ReadFromContext().