Files
mbEditorPro/mbEditorPro2.0/arcane/zones/mobile/MerchantInfo.py
T
MagicBotandClaude Opus 5.5 876484947c Read client signed int32 zone fields as signed
Use read_long/write_long for every CZone value the client loads with
ResStream_ReadInt32: basic zone level/room/dungeon indexes (default -1),
zone width/material thresholds and indexes, sea level index, pattern
and texture ints, terrain octaves and seeds, terrain object ints, goal
delay and points, mobile group size/level/exp, shopkeeper gold, buy and
sell list values, prop light ints, city prop rank/funds and container
lock/bar/trap values. Hash, enum, flag and count fields stay unsigned.

The binary is unchanged; on the sample cache JSON only changes from
4294967295 to -1 in the five basic zone index fields. Older dumps still
pack because write_long accepts the unsigned form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 11:02:34 -04:00

76 lines
4.0 KiB
Python

# • ▌ ▄ ·. ▄▄▄▄· ▄▄▄ .·▄▄▄▄ ▪ ▄▄▄▄▄ ▄▄▄ ▄▄▄·▄▄▄
# ·██ ▐███▪▐█ ▀█▪ ▀▄.▀·██▪ ██ ██ •██ ▪ ▀▄ █· ▐█ ▄█▀▄ █·▪
# ▐█ ▌▐▌▐█·▐█▀▀█▄ ▐▀▀▪▄▐█· ▐█▌▐█· ▐█.▪ ▄█▀▄ ▐▀▀▄ ██▀·▐▀▀▄ ▄█▀▄
# ██ ██▌▐█▌██▄▪▐█ ▐█▄▄▌██. ██ ▐█▌ ▐█▌·▐█▌.▐▌▐█•█▌ ▐█▪·•▐█•█▌▐█▌.▐▌
# ▀▀ █▪▀▀▀·▀▀▀▀ ▀▀▀ ▀▀▀▀▀• ▀▀▀ ▀▀▀ ▀█▄▀▪.▀ ▀ .▀ .▀ ▀ ▀█▄▀▪
# Magicbane Emulator Project © 2013 - 2022
# www.magicbane.com
from arcane.util import ResStream
from .MobileInfo import MobileInfo
class MerchantInfo(MobileInfo):
def load_binary(self, stream: ResStream):
super().load_binary(stream)
self.merchant_trade_type = stream.read_dword()
self.merchant_std_buy_margin = stream.read_float()
self.merchant_std_sell_margin = stream.read_float()
self.merchant_guild_buy_margin = stream.read_float()
self.merchant_guild_sell_margin = stream.read_float()
self.merchant_nation_buy_margin = stream.read_float()
self.merchant_nation_sell_margin = stream.read_float()
num_buy_list = stream.read_dword()
self.merchant_buy_list = [[
stream.read_qword(),
stream.read_long(),
] for _ in range(num_buy_list)]
num_sell_list = stream.read_dword()
self.merchant_sell_list = [[
stream.read_qword(),
stream.read_long(),
] for _ in range(num_sell_list)]
def save_binary(self, stream: ResStream):
super().save_binary(stream)
stream.write_dword(self.merchant_trade_type)
stream.write_float(self.merchant_std_buy_margin)
stream.write_float(self.merchant_std_sell_margin)
stream.write_float(self.merchant_guild_buy_margin)
stream.write_float(self.merchant_guild_sell_margin)
stream.write_float(self.merchant_nation_buy_margin)
stream.write_float(self.merchant_nation_sell_margin)
stream.write_dword(len(self.merchant_buy_list))
for l in self.merchant_buy_list:
stream.write_qword(l[0])
stream.write_long(l[1])
stream.write_dword(len(self.merchant_sell_list))
for l in self.merchant_sell_list:
stream.write_qword(l[0])
stream.write_long(l[1])
def save_json(self):
data = super().save_json()
data['merchant_trade_type'] = self.merchant_trade_type
data['merchant_std_buy_margin'] = self.merchant_std_buy_margin
data['merchant_std_sell_margin'] = self.merchant_std_sell_margin
data['merchant_guild_buy_margin'] = self.merchant_guild_buy_margin
data['merchant_guild_sell_margin'] = self.merchant_guild_sell_margin
data['merchant_nation_buy_margin'] = self.merchant_nation_buy_margin
data['merchant_nation_sell_margin'] = self.merchant_nation_sell_margin
data['merchant_buy_list'] = self.merchant_buy_list
data['merchant_sell_list'] = self.merchant_sell_list
return data
def load_json(self, data):
super().load_json(data)
self.merchant_trade_type = data['merchant_trade_type']
self.merchant_std_buy_margin = data['merchant_std_buy_margin']
self.merchant_std_sell_margin = data['merchant_std_sell_margin']
self.merchant_guild_buy_margin = data['merchant_guild_buy_margin']
self.merchant_guild_sell_margin = data['merchant_guild_sell_margin']
self.merchant_nation_buy_margin = data['merchant_nation_buy_margin']
self.merchant_nation_sell_margin = data['merchant_nation_sell_margin']
self.merchant_buy_list = data['merchant_buy_list']
self.merchant_sell_list = data['merchant_sell_list']