Files
mbEditorPro/mbEditorPro2.0/arcane/objects/ArcContainerObject.py
T
MagicBotandClaude Opus 5.5 0adbfe0d99 Read client signed int32 fields as signed
Add ResStream.read_long/write_long and use them for every CObjects
field the client loads with ResStream_ReadInt32 (sb.exe 0x7E1700)
as a value: rank info, attribute/skill/resource amounts, requirements,
door/deed/container/key fields, natural attacks, hardpoints, sound
event types and sparse VAL_LONG (LoadSaveBehavior<long>). Hash/enum
fields, list counts and flag words keep unsigned reads.

The binary is unchanged; JSON now shows e.g. -1 instead of 4294967295
(rank_hirelings, rank_rank) and -10 instead of 4294967286 (attr_adj).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:55:04 -04:00

70 lines
3.7 KiB
Python

# • ▌ ▄ ·. ▄▄▄▄· ▄▄▄ .·▄▄▄▄ ▪ ▄▄▄▄▄ ▄▄▄ ▄▄▄·▄▄▄
# ·██ ▐███▪▐█ ▀█▪ ▀▄.▀·██▪ ██ ██ •██ ▪ ▀▄ █· ▐█ ▄█▀▄ █·▪
# ▐█ ▌▐▌▐█·▐█▀▀█▄ ▐▀▀▪▄▐█· ▐█▌▐█· ▐█.▪ ▄█▀▄ ▐▀▀▄ ██▀·▐▀▀▄ ▄█▀▄
# ██ ██▌▐█▌██▄▪▐█ ▐█▄▄▌██. ██ ▐█▌ ▐█▌·▐█▌.▐▌▐█•█▌ ▐█▪·•▐█•█▌▐█▌.▐▌
# ▀▀ █▪▀▀▀·▀▀▀▀ ▀▀▀ ▀▀▀▀▀• ▀▀▀ ▀▀▀ ▀█▄▀▪.▀ ▀ .▀ .▀ ▀ ▀█▄▀▪
# Magicbane Emulator Project © 2013 - 2022
# www.magicbane.com
from arcane.util import ResStream
from .ArcItem import ArcItem
from .common.Inventory import Inventory
class ArcContainerObject(ArcItem):
def load_binary(self, stream: ResStream):
super().load_binary(stream)
self.container_open = stream.read_long()
self.container_locked = stream.read_long()
self.container_locked_rank = stream.read_long()
self.container_barred = stream.read_long()
self.container_barred_rank = stream.read_long()
self.container_trapped = stream.read_long()
self.container_trappe_rank = stream.read_long()
num_contents = stream.read_dword()
self.container_inventory_contents = [Inventory() for _ in range(num_contents)]
for content in self.container_inventory_contents:
content.load_binary(stream)
def save_binary(self, stream: ResStream):
super().save_binary(stream)
stream.write_long(self.container_open)
stream.write_long(self.container_locked)
stream.write_long(self.container_locked_rank)
stream.write_long(self.container_barred)
stream.write_long(self.container_barred_rank)
stream.write_long(self.container_trapped)
stream.write_long(self.container_trappe_rank)
stream.write_dword(len(self.container_inventory_contents))
for content in self.container_inventory_contents:
content.save_binary(stream)
def load_json(self, data):
super().load_json(data)
self.container_open = data['container_open']
self.container_locked = data['container_locked']
self.container_locked_rank = data['container_locked_rank']
self.container_barred = data['container_barred']
self.container_barred_rank = data['container_barred_rank']
self.container_trapped = data['container_trapped']
self.container_trappe_rank = data['container_trappe_rank']
self.container_inventory_contents = []
for content_data in data['container_inventory_contents']:
content = Inventory()
content.load_json(content_data)
self.container_inventory_contents.append(content)
def save_json(self):
data = super().save_json()
data['container_open'] = self.container_open
data['container_locked'] = self.container_locked
data['container_locked_rank'] = self.container_locked_rank
data['container_barred'] = self.container_barred
data['container_barred_rank'] = self.container_barred_rank
data['container_trapped'] = self.container_trapped
data['container_trappe_rank'] = self.container_trappe_rank
data['container_inventory_contents'] = []
for content in self.container_inventory_contents:
data['container_inventory_contents'].append(content.save_json())
return data