Files
mbEditorPro/mbEditorPro2.0/arcane/objects/ArcDeed.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

84 lines
4.1 KiB
Python

# • ▌ ▄ ·. ▄▄▄▄· ▄▄▄ .·▄▄▄▄ ▪ ▄▄▄▄▄ ▄▄▄ ▄▄▄·▄▄▄
# ·██ ▐███▪▐█ ▀█▪ ▀▄.▀·██▪ ██ ██ •██ ▪ ▀▄ █· ▐█ ▄█▀▄ █·▪
# ▐█ ▌▐▌▐█·▐█▀▀█▄ ▐▀▀▪▄▐█· ▐█▌▐█· ▐█.▪ ▄█▀▄ ▐▀▀▄ ██▀·▐▀▀▄ ▄█▀▄
# ██ ██▌▐█▌██▄▪▐█ ▐█▄▄▌██. ██ ▐█▌ ▐█▌·▐█▌.▐▌▐█•█▌ ▐█▪·•▐█•█▌▐█▌.▐▌
# ▀▀ █▪▀▀▀·▀▀▀▀ ▀▀▀ ▀▀▀▀▀• ▀▀▀ ▀▀▀ ▀█▄▀▪.▀ ▀ .▀ .▀ ▀ ▀█▄▀▪
# Magicbane Emulator Project © 2013 - 2022
# www.magicbane.com
from arcane.util import ResStream
from .ArcItem import ArcItem
class ArcDeed(ArcItem):
def load_binary(self, stream: ResStream):
super().load_binary(stream)
self.deed_type = stream.read_long()
self.deed_furniture_id = stream.read_qword()
self.deed_target_id = stream.read_qword()
self.deed_employment = stream.read_long()
self.deed_start_rank = stream.read_long()
self.deed_name_lookup = stream.read_long()
self.deed_indoors = stream.read_bool()
self.deed_is_fortress = stream.read_bool()
self.deed_namelookup_val = stream.read_float()
self.deed_custom_city = stream.read_bool()
if self.deed_custom_city:
set_length = stream.read_dword()
self.deed_custom_city_set = [
stream.read_dword() for _ in range(set_length)
]
self.deed_structure_id = stream.read_qword()
def save_binary(self, stream: ResStream):
super().save_binary(stream)
stream.write_long(self.deed_type)
stream.write_qword(self.deed_furniture_id)
stream.write_qword(self.deed_target_id)
stream.write_long(self.deed_employment)
stream.write_long(self.deed_start_rank)
stream.write_long(self.deed_name_lookup)
stream.write_bool(self.deed_indoors)
stream.write_bool(self.deed_is_fortress)
stream.write_float(self.deed_namelookup_val)
stream.write_bool(self.deed_custom_city)
if self.deed_custom_city:
stream.write_dword(len(self.deed_custom_city_set))
for city in self.deed_custom_city_set:
stream.write_dword(city)
stream.write_qword(self.deed_structure_id)
def load_json(self, data):
super().load_json(data)
self.deed_type = data['deed_type']
self.deed_furniture_id = data['deed_furniture_id']
self.deed_target_id = data['deed_target_id']
self.deed_employment = data['deed_employment']
self.deed_start_rank = data['deed_start_rank']
self.deed_name_lookup = data['deed_name_lookup']
self.deed_indoors = data['deed_indoors']
self.deed_is_fortress = data['deed_is_fortress']
self.deed_namelookup_val = data['deed_namelookup_val']
self.deed_custom_city = data['deed_custom_city']
if self.deed_custom_city:
self.deed_custom_city_set = data['deed_custom_city_set']
self.deed_structure_id = data['deed_structure_id']
def save_json(self):
data = super().save_json()
data['deed_type'] = self.deed_type
data['deed_furniture_id'] = self.deed_furniture_id
data['deed_target_id'] = self.deed_target_id
data['deed_employment'] = self.deed_employment
data['deed_start_rank'] = self.deed_start_rank
data['deed_name_lookup'] = self.deed_name_lookup
data['deed_indoors'] = self.deed_indoors
data['deed_is_fortress'] = self.deed_is_fortress
data['deed_namelookup_val'] = self.deed_namelookup_val
data['deed_custom_city'] = self.deed_custom_city
if self.deed_custom_city:
data['deed_custom_city_set'] = self.deed_custom_city_set
data['deed_structure_id'] = self.deed_structure_id
return data