From f86ba2b6b89a20888adae31a5f3a379cd9c9984c Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Mon, 3 Jul 2017 22:14:34 +0200 Subject: [PATCH] Added a state check for the cash shop If the cash shop is open you can not use the atcommands cash and points. This is because no update packet exists and the cash shop only gets the current amount when you open the cash shop. The second way to update the cash shop values is on a successful purchase. --- conf/msg_conf/map_msg.conf | 4 +++- src/map/atcommand.c | 6 ++++++ src/map/clif.c | 2 ++ src/map/pc.h | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/conf/msg_conf/map_msg.conf b/conf/msg_conf/map_msg.conf index 402ac1a38c..6b7ca3235c 100644 --- a/conf/msg_conf/map_msg.conf +++ b/conf/msg_conf/map_msg.conf @@ -1491,7 +1491,9 @@ 1373: %s value is now: %d 1374: %s value is now: %s 1375: %s is blank. -//1376: free + +// @cash/@points +1376: Please close the cashshop before using this command. // @reloadquestdb 1377: Quest database has been reloaded. diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 5b1708044b..df3d32b915 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -8407,6 +8407,12 @@ ACMD_FUNC(cash) int ret=0; nullpo_retr(-1, sd); + // Since there is no cashpoint update packet we need to force updating like this + if( sd->state.cashshop_open ){ + clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command. + return -1; + } + if( !message || !*message || (value = atoi(message)) == 0 ) { clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount. return -1; diff --git a/src/map/clif.c b/src/map/clif.c index bba7eee554..dddc4a4b6c 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -16078,11 +16078,13 @@ void clif_cashshop_open( struct map_session_data* sd ){ } void clif_parse_cashshop_open_request( int fd, struct map_session_data* sd ){ + sd->state.cashshop_open = true; sd->npc_shopid = -1; // Set npc_shopid when using cash shop from "cash shop" button [Aelys|Susu] bugreport:96 clif_cashshop_open( sd ); } void clif_parse_cashshop_close( int fd, struct map_session_data* sd ){ + sd->state.cashshop_open = false; sd->npc_shopid = 0; // Reset npc_shopid when using cash shop from "cash shop" button [Aelys|Susu] bugreport:96 // No need to do anything here } diff --git a/src/map/pc.h b/src/map/pc.h index 4feb563720..3853d8294d 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -267,6 +267,7 @@ struct map_session_data { bool pc_loaded; // Ensure inventory data and status data is loaded before we calculate player stats bool keepshop; // Whether shop data should be removed when the player disconnects bool mail_writing; // Whether the player is currently writing a mail in RODEX or not + bool cashshop_open; } state; struct { unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;