diff options
author | Dipesh Amin <yaypunkrock@gmail.com> | 2011-09-04 13:40:46 +0100 |
---|---|---|
committer | Dipesh Amin <yaypunkrock@gmail.com> | 2011-09-04 13:40:46 +0100 |
commit | aa872a3bf3a9db6733a40f030259a03d8b894488 (patch) | |
tree | b01e51c360c6939ee93aaedaca1e884bde7fbbb2 | |
parent | e21a71fbb12bee8e82868989f1f1b0dd0e8c314e (diff) | |
download | manamarket-aa872a3bf3a9db6733a40f030259a03d8b894488.tar.gz manamarket-aa872a3bf3a9db6733a40f030259a03d8b894488.tar.bz2 manamarket-aa872a3bf3a9db6733a40f030259a03d8b894488.tar.xz manamarket-aa872a3bf3a9db6733a40f030259a03d8b894488.zip |
Add stricter checking for the !money action.
I've added an inventory_check call to the end of the "Trade complete" packet,
to make sure the trader state is consistent after each transaction!
-rwxr-xr-x | main.py | 12 | ||||
-rw-r--r-- | player.py | 2 |
2 files changed, 11 insertions, 3 deletions
@@ -820,6 +820,7 @@ def main(): isclean = player_node.check_inventory(user_tree, sale_tree) if isclean: logging.info(isclean) + shop_broadcaster.stop() exit(0) else: logging.info("Inventory Check Passed.") @@ -862,7 +863,6 @@ def main(): mapserv.sendall(trade_add_item(0-inventory_offset, amount)) mapserv.sendall(str(PacketOut(CMSG_TRADE_ADD_COMPLETE))) mapserv.sendall(str(PacketOut(CMSG_TRADE_OK))) - trader_state.complete = 1 else: logging.info("Trade response: Trade cancelled") @@ -918,7 +918,10 @@ def main(): logging.info("Remove item: %s, Amount: %s, Index: %s", ItemDB.getItem(player_node.inventory[index].itemId).name, str(amount),str(index)) player_node.remove_item(index, amount) else: - logging.info("Trade: Money Added: %s", str(amount)) + # The money amount isn't actually sent by the server - odd?!?!?. + if trader_state.money: + logging.info("Trade: Money Added.") + trader_state.complete = 1 elif response == 1: logging.info("Trade item add response: Failed - player overweight.") @@ -990,6 +993,11 @@ def main(): trader_state.reset() logging.info("Trade Complete.") + + if isclean: + logging.info(isclean) + shop_broadcaster.stop() + exit(0) else: pass @@ -61,7 +61,7 @@ class Player: for user in user_tree.root: total_money += int(user.get('money')) - if total_money > self.MONEY: + if total_money != self.MONEY: return "Server and client money out of sync." return 0 |