From f06d1020a56c6d7602cbf5176c1ba3d3525b4c3e Mon Sep 17 00:00:00 2001 From: mc_cameri Date: Tue, 23 Nov 2004 10:35:02 +0000 Subject: git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/athena@334 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/charcommand.c | 163 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 142 insertions(+), 21 deletions(-) (limited to 'src/map/charcommand.c') diff --git a/src/map/charcommand.c b/src/map/charcommand.c index c2e091302..e2aa67424 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -32,10 +32,13 @@ static char command_symbol = '#'; static char msg_table[1000][1024]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others) -#define CHARCOMMAND_FUNC(x) int charcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message) +#define CCMD_FUNC(x) int charcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message) -CHARCOMMAND_FUNC(jobchange); -CHARCOMMAND_FUNC(petrename); +CCMD_FUNC(jobchange); +CCMD_FUNC(petrename); +CCMD_FUNC(petfriendly); +CCMD_FUNC(stats); +CCMD_FUNC(option); #ifdef TXT_ONLY /* TXT_ONLY */ @@ -58,6 +61,9 @@ static CharCommandInfo charcommand_info[] = { { CharCommandJobChange, "#job", 60, charcommand_jobchange }, { CharCommandJobChange, "#jobchange", 60, charcommand_jobchange }, { CharCommandPetRename, "#petrename", 50, charcommand_petrename }, + { CharCommandPetFriendly, "#petfriendly", 50, charcommand_petfriendly }, + { CharCommandStats, "#stats", 40, charcommand_stats }, + { CharCommandOption, "#option", 60, charcommand_option }, #ifdef TXT_ONLY /* TXT_ONLY */ @@ -126,12 +132,12 @@ is_charcommand(const int fd, struct map_session_data* sd, const char* message, i p++; if (type == CharCommand_Unknown || info.proc == NULL) { - sprintf(output, msg_table[153], command); // %s is Unknown Command. + snprintf(output, sizeof(output),msg_txt(153), command); // %s is Unknown Command. clif_displaymessage(fd, output); } else { if (info.proc(fd, sd, command, p) != 0) { // Command can not be executed - sprintf(output, msg_table[154], command); // %s failed. + snprintf(output, sizeof(output), msg_txt(154), command); // %s failed. clif_displaymessage(fd, output); } } @@ -213,7 +219,7 @@ int charcommand_config_read(const char *cfgName) { FILE* fp; if ((fp = fopen(cfgName, "r")) == NULL) { - printf("Char commands configuration file not found: %s\n", cfgName); + printf("CharCommands configuration file not found: %s\n", cfgName); return 1; } @@ -245,19 +251,6 @@ int charcommand_config_read(const char *cfgName) { return 0; } - - -/*========================================== -// # command processing functions - *------------------------------------------ - */ -int -charcommand_test (const int fd, struct map_session_data* sd, - const char* command, const char* message) { - clif_displaymessage(fd,"Works!"); - return 0; -} - /*========================================== * 対象キャラクターを転職させる upper指定で転生や養子も可能 *------------------------------------------ @@ -373,7 +366,7 @@ int charcommand_petrename( return -1; } } else { - clif_displaymessage(fd, msg_table[3]); // Character not found. + clif_displaymessage(fd, msg_txt(3)); // Character not found. return -1; } @@ -398,7 +391,7 @@ int charcommand_petfriendly( if (!message || !*message || sscanf(message,"%d %s",&friendly,character) < 2) { clif_displaymessage(fd, "Please, enter a valid value (usage: " "#petfriendly <0-1000> )."); - return 0; + return -1; } if (((pl_sd = map_nick2sd(character)) != NULL) && pc_isGM(sd)>pc_isGM(pl_sd)) { @@ -431,6 +424,64 @@ int charcommand_petfriendly( } else { return -1; } + } else { + clif_displaymessage(fd, msg_txt(3)); // Character not found. + return -1; + } + + return 0; +} + +/*========================================== + * + *------------------------------------------ + */ +int charcommand_stats( + const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + char character[100]; + char job_jobname[100]; + char output[200]; + struct map_session_data *pl_sd; + int i; + + memset(character, '\0', sizeof(character)); + memset(job_jobname, '\0', sizeof(job_jobname)); + memset(output, '\0', sizeof(output)); + + if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) { + clif_displaymessage(fd, "Please, enter a player name (usage: #stats )."); + return -1; + } + + if ((pl_sd = map_nick2sd(character)) != NULL) { + struct { + const char* format; + int value; + } output_table[] = { + { "Base Level - %d", pl_sd->status.base_level }, + { job_jobname, pl_sd->status.job_level }, + { "Hp - %d", pl_sd->status.hp }, + { "MaxHp - %d", pl_sd->status.max_hp }, + { "Sp - %d", pl_sd->status.sp }, + { "MaxSp - %d", pl_sd->status.max_sp }, + { "Str - %3d", pl_sd->status.str }, + { "Agi - %3d", pl_sd->status.agi }, + { "Vit - %3d", pl_sd->status.vit }, + { "Int - %3d", pl_sd->status.int_ }, + { "Dex - %3d", pl_sd->status.dex }, + { "Luk - %3d", pl_sd->status.luk }, + { "Zeny - %d", pl_sd->status.zeny }, + { NULL, 0 } + }; + sprintf(job_jobname, "Job - %s %s", job_name(pl_sd->status.class), "(level %d)"); + sprintf(output, msg_table[53], pl_sd->status.name); // '%s' stats: + clif_displaymessage(fd, output); + for (i = 0; output_table[i].format != NULL; i++) { + sprintf(output, output_table[i].format, output_table[i].value); + clif_displaymessage(fd, output); + } } else { clif_displaymessage(fd, msg_table[3]); // Character not found. return -1; @@ -439,3 +490,73 @@ int charcommand_petfriendly( return 0; } +/*========================================== + * + *------------------------------------------ + */ +int charcommand_option( + const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + char character[100]; + int opt1 = 0, opt2 = 0, opt3 = 0; + struct map_session_data* pl_sd; + + memset(character, '\0', sizeof(character)); + + if (!message || !*message || + sscanf(message, "%d %d %d %99[^\n]", &opt1, &opt2, &opt3, character) < 4 || + opt1 < 0 || opt2 < 0 || opt3 < 0) { + clif_displaymessage(fd, "Please, enter valid options and a player name (usage: #option )."); + return -1; + } + + if ((pl_sd = map_nick2sd(character)) != NULL) { + if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change option only to lower or same level + pl_sd->opt1 = opt1; + pl_sd->opt2 = opt2; + pl_sd->status.option = opt3; + // fix pecopeco display + if (pl_sd->status.class == 13 || pl_sd->status.class == 21 || pl_sd->status.class == 4014 || pl_sd->status.class == 4022) { + if (!pc_isriding(pl_sd)) { // pl_sd have the new value... + if (pl_sd->status.class == 13) + pl_sd->status.class = pl_sd->view_class = 7; + else if (pl_sd->status.class == 21) + pl_sd->status.class = pl_sd->view_class = 14; + else if (pl_sd->status.class == 4014) + pl_sd->status.class = pl_sd->view_class = 4008; + else if (pl_sd->status.class == 4022) + pl_sd->status.class = pl_sd->view_class = 4015; + } + } else { + if (pc_isriding(pl_sd)) { // pl_sd have the new value... + if (pl_sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor]) + pl_sd->status.option &= ~0x0020; + } else { + if (pl_sd->status.class == 7) + pl_sd->status.class = pl_sd->view_class = 13; + else if (pl_sd->status.class == 14) + pl_sd->status.class = pl_sd->view_class = 21; + else if (pl_sd->status.class == 4008) + pl_sd->status.class = pl_sd->view_class = 4014; + else if (pl_sd->status.class == 4015) + pl_sd->status.class = pl_sd->view_class = 4022; + else + pl_sd->status.option &= ~0x0020; + } + } + } + clif_changeoption(&pl_sd->bl); + pc_calcstatus(pl_sd, 0); + clif_displaymessage(fd, msg_table[58]); // Character's options changed. + } else { + clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + return -1; + } + } else { + clif_displaymessage(fd, msg_table[3]); // Character not found. + return -1; + } + + return 0; +} -- cgit v1.2.3-70-g09d2