diff options
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r-- | src/map/atcommand.c | 93 |
1 files changed, 46 insertions, 47 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index beeccaddd..ff88f2c63 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -41,7 +41,7 @@ #include "common/cbasetypes.h" #include "common/conf.h" #include "common/core.h" -#include "common/malloc.h" +#include "common/memmgr.h" #include "common/mmo.h" // MAX_CARTS #include "common/nullpo.h" #include "common/random.h" @@ -242,16 +242,16 @@ ACMD(send) }\ } while(0) //define GET_VALUE - if (type > 0 && type < MAX_PACKET_DB) { + if (type >= MIN_PACKET_DB && type <= MAX_PACKET_DB) { int off = 2; if (len) { // show packet length - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,904), type, packet_db[type].len); // Packet 0x%x length: %d + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,904), type, clif->packet(type)->len); // Packet 0x%x length: %d clif->message(fd, atcmd_output); return true; } - len=packet_db[type].len; + len = clif->packet(type)->len; if (len == 0) { // unknown packet - ERROR safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,905), type); // Unknown packet: 0x%x @@ -402,7 +402,7 @@ ACMD(send) SKIP_VALUE(message); } - if(packet_db[type].len == -1) {// send dynamic packet + if (clif->packet(type)->len == -1) { // send dynamic packet WFIFOW(sd->fd,2)=TOW(off); WFIFOSET(sd->fd,off); } else {// send static packet @@ -967,65 +967,64 @@ ACMD(hide) { /*========================================== * Changes a character's class *------------------------------------------*/ -ACMD(jobchange) { +ACMD(jobchange) +{ int job = 0, upper = 0; - const char* text; - - if (!*message || sscanf(message, "%12d %12d", &job, &upper) < 1) { - upper = 0; - - if (*message) { - int i; - bool found = false; + bool found = false; - // Normal Jobs - for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) { - if (strncmpi(message, pc->job_name(i), 16) == 0) { - job = i; - found = true; - } - } + if (*message == '\0') { // No message, just show the list + found = false; + } else if (sscanf(message, "%12d %12d", &job, &upper) >= 1) { // Numeric job ID + found = true; + } else { // Job name + int i; - // High Jobs, Babies and Third - for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ){ - if (strncmpi(message, pc->job_name(i), 16) == 0) { - job = i; - found = true; - } + // Normal Jobs + for (i = JOB_NOVICE; !found && i < JOB_MAX_BASIC; i++) { + if (strncmpi(message, pc->job_name(i), 16) == 0) { + job = i; + found = true; + break; } + } - if (!found) { - text = atcommand_help_string(info); - if (text) - clif->messageln(fd, text); - return false; + // High Jobs, Babies and Third + for (i = JOB_NOVICE_HIGH; !found && i < JOB_MAX; i++) { + if (strncmpi(message, pc->job_name(i), 16) == 0) { + job = i; + found = true; + break; } } } - /* WHY DO WE LIST THEM THEN? */ + + if (!found || !pc->db_checkid(job)) { + const char *text = atcommand_help_string(info); + if (text) + clif->messageln(fd, text); + return false; + } + // Deny direct transformation into dummy jobs - if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER - || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2 - || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2) + if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 + || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER + || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 + || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 + || job == JOB_STAR_GLADIATOR2 + || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) + || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2) ) { + /* WHY DO WE LIST THEM THEN? */ clif->message(fd, msg_fd(fd,923)); //"You can not change to this job by command." return true; } - if (pc->db_checkid(job)) { - if (pc->jobchange(sd, job, upper) == 0) - clif->message(fd, msg_fd(fd,12)); // Your job has been changed. - else { - clif->message(fd, msg_fd(fd,155)); // You are unable to change your job. - return false; - } - } else { - text = atcommand_help_string(info); - if (text) - clif->messageln(fd, text); + if (pc->jobchange(sd, job, upper) != 0) { + clif->message(fd, msg_fd(fd,155)); // You are unable to change your job. return false; } + clif->message(fd, msg_fd(fd,12)); // Your job has been changed. return true; } |