From: terencehill Date: Sun, 1 Sep 2019 13:14:46 +0000 (+0200) Subject: Optimize bandwidth and memory usage of item stats networking X-Git-Tag: xonotic-v0.8.5~1331 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7f08a396e92c71a2baf9aca2fdba9ca60d6137c0;p=xonotic%2Fxonotic-data.pk3dir.git Optimize bandwidth and memory usage of item stats networking --- diff --git a/qcsrc/common/items/inventory.qh b/qcsrc/common/items/inventory.qh index ed6c7355d..017ada75c 100644 --- a/qcsrc/common/items/inventory.qh +++ b/qcsrc/common/items/inventory.qh @@ -15,8 +15,8 @@ ENDCLASS(Inventory) REGISTER_NET_LINKED(ENT_CLIENT_INVENTORY) -const int Inventory_groups_major = 16; -const int Inventory_groups_minor = 8; // ceil(Items_MAX / Inventory_groups_major) +const int Inventory_groups_minor = 8; // exactly 1 byte +const int Inventory_groups_major = 3; // ceil(Items_MAX / Inventory_groups_minor) #define G_MAJOR(id) (floor((id) / Inventory_groups_minor)) #define G_MINOR(id) ((id) % Inventory_groups_minor) @@ -28,7 +28,7 @@ NET_HANDLE(ENT_CLIENT_INVENTORY, bool isnew) { make_pure(this); g_inventory = this; - const int majorBits = ReadShort(); + const int majorBits = ReadByte(); for (int i = 0; i < Inventory_groups_major; ++i) { if (!(majorBits & BIT(i))) { continue; @@ -72,7 +72,7 @@ void Inventory_Write(Inventory data) minorBitsArr[maj] = BITSET(minorBitsArr[maj], BIT(G_MINOR(it.m_id)), true); } }); - WriteShort(MSG_ENTITY, majorBits); + WriteByte(MSG_ENTITY, majorBits); for (int i = 0; i < Inventory_groups_major; ++i) { diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index a0321c244..5c916866f 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -1,6 +1,6 @@ #pragma once -const int AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel +const int AMMO_COUNT = 4; // amount of ammo types to show in the ammo panel // item networking const int ISF_LOCATION = BIT(1);