Browse Source

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.
Lemongrass3110 7 years ago
parent
commit
f86ba2b6b8
4 changed files with 12 additions and 1 deletions
  1. 3 1
      conf/msg_conf/map_msg.conf
  2. 6 0
      src/map/atcommand.c
  3. 2 0
      src/map/clif.c
  4. 1 0
      src/map/pc.h

+ 3 - 1
conf/msg_conf/map_msg.conf

@@ -1491,7 +1491,9 @@
 1373: %s value is now: %d
 1373: %s value is now: %d
 1374: %s value is now: %s
 1374: %s value is now: %s
 1375: %s is blank.
 1375: %s is blank.
-//1376: free
+
+// @cash/@points
+1376: Please close the cashshop before using this command.
 
 
 // @reloadquestdb
 // @reloadquestdb
 1377: Quest database has been reloaded.
 1377: Quest database has been reloaded.

+ 6 - 0
src/map/atcommand.c

@@ -8407,6 +8407,12 @@ ACMD_FUNC(cash)
 	int ret=0;
 	int ret=0;
 	nullpo_retr(-1, sd);
 	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 ) {
 	if( !message || !*message || (value = atoi(message)) == 0 ) {
 		clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
 		clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
 		return -1;
 		return -1;

+ 2 - 0
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 ){
 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
 	sd->npc_shopid = -1; // Set npc_shopid when using cash shop from "cash shop" button [Aelys|Susu] bugreport:96
 	clif_cashshop_open( sd );
 	clif_cashshop_open( sd );
 }
 }
 
 
 void clif_parse_cashshop_close( int fd, struct map_session_data* 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
 	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
 	// No need to do anything here
 }
 }

+ 1 - 0
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 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 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 mail_writing; // Whether the player is currently writing a mail in RODEX or not
+		bool cashshop_open;
 	} state;
 	} state;
 	struct {
 	struct {
 		unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
 		unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;