summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 2bcb22738..9deed0098 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -7872,7 +7872,6 @@ ACMD(cash)
{
char output[128];
int value;
- int ret=0;
if (!*message || (value = atoi(message)) == 0) {
clif->message(fd, msg_fd(fd,1322)); // Please enter an amount.
@@ -7880,38 +7879,38 @@ ACMD(cash)
}
if (!strcmpi(info->command,"cash")) {
- if( value > 0 ) {
- if( (ret=pc->getcash(sd, value, 0)) >= 0){
+ if (value > 0) {
+ if ((pc->getcash(sd, value, 0)) >= 0) {
// If this option is set, the message is already sent by pc function
- if( !battle_config.cashshop_show_points ){
- sprintf(output, msg_fd(fd,505), ret, sd->cashPoints);
+ if (!battle_config.cashshop_show_points) {
+ sprintf(output, msg_fd(fd,505), value, sd->cashPoints);
clif_disp_onlyself(sd, output);
clif->message(fd, output);
}
} else
clif->message(fd, msg_fd(fd,149)); // Unable to decrease the number/value.
} else {
- if( (ret=pc->paycash(sd, -value, 0)) >= 0){
- sprintf(output, msg_fd(fd,410), ret, sd->cashPoints);
+ if ((pc->paycash(sd, -value, 0)) >= 0) {
+ sprintf(output, msg_fd(fd,410), -value, sd->cashPoints);
clif_disp_onlyself(sd, output);
clif->message(fd, output);
} else
clif->message(fd, msg_fd(fd,41)); // Unable to decrease the number/value.
}
} else { // @points
- if( value > 0 ) {
- if( (ret=pc->getcash(sd, 0, value)) >= 0) {
+ if (value > 0) {
+ if ((pc->getcash(sd, 0, value)) >= 0) {
// If this option is set, the message is already sent by pc function
- if( !battle_config.cashshop_show_points ){
- sprintf(output, msg_fd(fd,506), ret, sd->kafraPoints);
+ if (!battle_config.cashshop_show_points) {
+ sprintf(output, msg_fd(fd,506), value, sd->kafraPoints);
clif_disp_onlyself(sd, output);
clif->message(fd, output);
}
} else
clif->message(fd, msg_fd(fd,149)); // Unable to decrease the number/value.
} else {
- if( (ret=pc->paycash(sd, -value, -value)) >= 0){
- sprintf(output, msg_fd(fd,411), ret, sd->kafraPoints);
+ if ((pc->paycash(sd, -value, -value)) >= 0) {
+ sprintf(output, msg_fd(fd,411), -value, sd->kafraPoints);
clif_disp_onlyself(sd, output);
clif->message(fd, output);
} else
@@ -10056,6 +10055,7 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa
{
char params[100], command[100];
char output[CHAT_SIZE_MAX];
+ bool logCommand;
// Reconstructed message
char atcmd_msg[CHAT_SIZE_MAX];
@@ -10199,6 +10199,7 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa
}
}
+ logCommand = info->log;
//Attempt to use the command
if ((info->func(fd, ssd, command, params,info) != true)) {
#ifdef AUTOTRADE_PERSISTENCY
@@ -10210,7 +10211,8 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa
return true;
}
- if (info->log) /* log only if this command should be logged [Ind/Hercules] */
+ // info->log cant be used here, because info can be freed [4144]
+ if (logCommand) /* log only if this command should be logged [Ind/Hercules] */
logs->atcommand(sd, is_atcommand ? atcmd_msg : message);
return true;