diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 192 | ||||
-rw-r--r-- | src/map/itemdb.c | 25 | ||||
-rw-r--r-- | src/map/pc.c | 5 | ||||
-rw-r--r-- | src/map/pc.h | 4 | ||||
-rw-r--r-- | src/map/status.c | 6 | ||||
-rw-r--r-- | src/map/status.h | 2 |
6 files changed, 112 insertions, 122 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 14eab56e0..f28c24dcb 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -9800,143 +9800,124 @@ void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bo } /** - * Executes an at-command + * Executes an at-command. + * * @param fd fd associated to the invoking character * @param sd sd associated to the invoking character * @param message atcommand arguments * @param player_invoked true if the command was invoked by a player, false if invoked by the server (bypassing any restrictions) + * + * @retval true if the message was recognized as atcommand. + * @retval false if the message should be considered a non-command message. */ -bool atcommand_exec(const int fd, struct map_session_data *sd, const char *message, bool player_invoked) { - char charname[NAME_LENGTH], params[100]; - char charname2[NAME_LENGTH]; - char command[100]; +bool atcommand_exec(const int fd, struct map_session_data *sd, const char *message, bool player_invoked) +{ + char params[100], command[100]; char output[CHAT_SIZE_MAX]; - //Reconstructed message + // Reconstructed message char atcmd_msg[CHAT_SIZE_MAX]; struct map_session_data *ssd = NULL; //sd for target - AtCommandInfo * info; + AtCommandInfo *info; + + bool is_atcommand = true; // false if it's a charcommand nullpo_retr(false, sd); - //Shouldn't happen - if ( !message || !*message ) + // Shouldn't happen + if (message == NULL || *message == '\0') return false; - //Block NOCHAT but do not display it as a normal message + // Block NOCHAT but do not display it as a normal message if (pc_ismuted(&sd->sc, MANNER_NOCOMMAND)) return true; // skip 10/11-langtype's codepage indicator, if detected - if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand->at_symbol || message[3] == atcommand->char_symbol) ) + if (message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand->at_symbol || message[3] == atcommand->char_symbol)) message += 3; - //Should display as a normal message - if ( *message != atcommand->at_symbol && *message != atcommand->char_symbol ) + // Should display as a normal message + if (*message != atcommand->at_symbol && *message != atcommand->char_symbol) return false; if (player_invoked) { - //Commands are disabled on maps flagged as 'nocommand' - if ( map->list[sd->bl.m].nocommand && pc_get_group_level(sd) < map->list[sd->bl.m].nocommand ) { + // Commands are disabled on maps flagged as 'nocommand' + if (map->list[sd->bl.m].nocommand && pc_get_group_level(sd) < map->list[sd->bl.m].nocommand) { clif->message(fd, msg_fd(fd,143)); return false; } } - if (*message == atcommand->char_symbol) { - do { - char params2[100]; - int x, y, z; - - //Checks to see if #command has a name or a name + parameters. - x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params); - y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2); - - //z always has the value of the scan that was successful - z = ( x > 1 ) ? x : y; + if (*message == atcommand->char_symbol) + is_atcommand = false; - //#command + name means the sufficient target was used and anything else after - //can be looked at by the actual command function since most scan to see if the - //right parameters are used. - if ( x > 2 ) { - sprintf(atcmd_msg, "%s %s", command, params); - break; - } - else if ( y > 2 ) { - sprintf(atcmd_msg, "%s %s", command, params2); - break; - } - //Regardless of what style the #command is used, if it's correct, it will always have - //this value if there is no parameter. Send it as just the #command - else if ( z == 2 ) { - sprintf(atcmd_msg, "%s", command); - break; - } + if (is_atcommand) { // #command + sprintf(atcmd_msg, "%s", message); + ssd = sd; + } else { // @command + char charname[NAME_LENGTH]; + int n; + + // Checks to see if #command has a name or a name + parameters. + if ((n = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params)) < 2 + && (n = sscanf(message, "%99s %23s %99[^\n]", command, charname, params)) < 2 + ) { + if (pc_get_group_level(sd) == 0) { + if (n < 1) + return false; // no command found. Display as normal message - if( !pc_get_group_level(sd) ) { - if( x >= 1 || y >= 1 ) { /* we have command */ - info = atcommand->get_info_byname(atcommand->check_alias(command + 1)); - if( !info || info->char_groups[pcg->get_idx(sd->group)] == 0 ) /* if we can't use or doesn't exist: don't even display the command failed message */ - return false; - } else - return false;/* display as normal message */ + info = atcommand->get_info_byname(atcommand->check_alias(command + 1)); + if (info == NULL || info->char_groups[pcg->get_idx(sd->group)] == 0) { + /* if we can't use or doesn't exist: don't even display the command failed message */ + return false; + } } sprintf(output, msg_fd(fd,1388), atcommand->char_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>). clif->message(fd, output); return true; - } while(0); - } - else /*if (*message == atcommand->at_symbol)*/ { - //atcmd_msg is constructed above differently for charcommands - //it's copied from message if not a charcommand so it can - //pass through the rest of the code compatible with both symbols - sprintf(atcmd_msg, "%s", message); + } + + ssd = map->nick2sd(charname); + if (ssd == NULL) { + sprintf(output, msg_fd(fd,1389), command); // %s failed. Player not found. + clif->message(fd, output); + return true; + } + + if (n > 2) + sprintf(atcmd_msg, "%s %s", command, params); + else + sprintf(atcmd_msg, "%s", command); } pc->update_idle_time(sd, BCIDLE_ATCOMMAND); //Clearing these to be used once more. - memset(command, '\0', sizeof(command)); - memset(params, '\0', sizeof(params)); + memset(command, '\0', sizeof command); + memset(params, '\0', sizeof params); //check to see if any params exist within this command - if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 ) + if (sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2) params[0] = '\0'; // @commands (script based) - if(player_invoked && atcommand->binding_count > 0) { - struct atcmd_binding_data * binding; - + if (player_invoked && atcommand->binding_count > 0) { // Get atcommand binding - binding = atcommand->get_bind_byname(command); + struct atcmd_binding_data *binding = atcommand->get_bind_byname(command); // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera - if( binding != NULL - && binding->npc_event[0] + if (binding != NULL && binding->npc_event[0] != '\0' && ( - (*atcmd_msg == atcommand->at_symbol && pc_get_group_level(sd) >= binding->group_lv) - || (*atcmd_msg == atcommand->char_symbol && pc_get_group_level(sd) >= binding->group_lv_char) + (is_atcommand && pc_get_group_level(sd) >= binding->group_lv) + || (!is_atcommand && pc_get_group_level(sd) >= binding->group_lv_char) ) ) { - // Check if self or character invoking; if self == character invoked, then self invoke. - bool invokeFlag = ((*atcmd_msg == atcommand->at_symbol) ? 1 : 0); - - // Check if the command initiated is a character command - if (*message == atcommand->char_symbol - && (ssd = map->nick2sd(charname)) == NULL - && (ssd = map->nick2sd(charname2)) == NULL - ) { - sprintf(output, msg_fd(fd,1389), command); // %s failed. Player not found. - clif->message(fd, output); - return true; - } - - if( binding->log ) /* log only if this command should be logged [Ind/Hercules] */ + if (binding->log) /* log only if this command should be logged [Ind/Hercules] */ logs->atcommand(sd, atcmd_msg); - npc->do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event); + npc->do_atcmd_event(ssd, command, params, binding->npc_event); return true; } } @@ -9944,51 +9925,40 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa //Grab the command information and check for the proper GM level required to use it or if the command exists info = atcommand->get_info_byname(atcommand->check_alias(command + 1)); if (info == NULL) { - if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission - sprintf(output, msg_fd(fd,153), command); // "%s is Unknown Command." - clif->message(fd, output); - atcommand->get_suggestions(sd, command + 1, *message == atcommand->at_symbol); - return true; - } else + if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission return false; + + sprintf(output, msg_fd(fd,153), command); // "%s is Unknown Command." + clif->message(fd, output); + atcommand->get_suggestions(sd, command + 1, is_atcommand); + return true; } if (player_invoked) { int i; - if ((*command == atcommand->at_symbol && info->at_groups[pcg->get_idx(sd->group)] == 0) || - (*command == atcommand->char_symbol && info->char_groups[pcg->get_idx(sd->group)] == 0) ) { + if ((is_atcommand && info->at_groups[pcg->get_idx(sd->group)] == 0) + || (!is_atcommand && info->char_groups[pcg->get_idx(sd->group)] == 0)) return false; - } - if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) { + + if (pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD)) { clif->message(fd, msg_fd(fd,1393)); // You can't use commands while dead return true; } - for(i = 0; i < map->list[sd->bl.m].zone->disabled_commands_count; i++) { - if( info->func == map->list[sd->bl.m].zone->disabled_commands[i]->cmd ) { + for (i = 0; i < map->list[sd->bl.m].zone->disabled_commands_count; i++) { + if (info->func == map->list[sd->bl.m].zone->disabled_commands[i]->cmd) { if (pc_get_group_level(sd) < map->list[sd->bl.m].zone->disabled_commands[i]->group_lv) { clif->messagecolor_self(sd->fd, COLOR_RED, "This command is disabled in this area"); return true; - } else { - break;/* already found the matching command, no need to keep checking -- just go on */ } + break; /* already found the matching command, no need to keep checking -- just go on */ } } } - // Check if target is valid only if confirmed that player can use command. - if (*message == atcommand->char_symbol - && (ssd = map->nick2sd(charname)) == NULL - && (ssd = map->nick2sd(charname2)) == NULL - ) { - sprintf(output, msg_fd(fd,1389), command); // %s failed. Player not found. - clif->message(fd, output); - return true; - } - //Attempt to use the command - if ( (info->func(fd, (*atcmd_msg == atcommand->at_symbol) ? sd : ssd, command, params,info) != true) ) { + if ((info->func(fd, ssd, command, params,info) != true)) { #ifdef AUTOTRADE_PERSISTENCY - if( info->func == atcommand_autotrade ) /** autotrade deletes caster, so we got nothing more to do here **/ + if (info->func == atcommand_autotrade) /* autotrade deletes caster, so we got nothing more to do here */ return true; #endif sprintf(output,msg_fd(fd,154), command); // %s failed. @@ -9996,8 +9966,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] */ - logs->atcommand(sd, *atcmd_msg == atcommand->at_symbol ? atcmd_msg : message); + if (info->log) /* log only if this command should be logged [Ind/Hercules] */ + logs->atcommand(sd, is_atcommand ? atcmd_msg : message); return true; } diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 27adc387b..630bc4488 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1613,6 +1613,12 @@ int itemdb_validate_entry(struct item_data *entry, int n, const char *source) { memset(&entry->stack, '\0', sizeof(entry->stack)); } + if (entry->type == IT_WEAPON && (entry->look < 0 || entry->look >= MAX_SINGLE_WEAPON_TYPE)) { + ShowWarning("itemdb_validate_entry: Invalid View for weapon items. View value %d for item %d (%s) in '%s', defaulting to 1.\n", + entry->look, entry->nameid, entry->jname, source); + entry->look = 1; + } + entry->wlv = cap_value(entry->wlv, REFINE_TYPE_ARMOR, REFINE_TYPE_MAX); if( !entry->elvmax ) @@ -1666,14 +1672,21 @@ void itemdb_readdb_job_sub(struct item_data *id, struct config_setting_t *t) { int idx = 0; struct config_setting_t *it = NULL; + bool enable_all = false; + id->class_base[0] = id->class_base[1] = id->class_base[2] = 0; + + if (libconfig->setting_lookup_bool_real(t, "All", &enable_all) && enable_all) { + itemdb->jobmask2mapid(id->class_base, UINT64_MAX); + } while ((it = libconfig->setting_get_elem(t, idx++)) != NULL) { const char *job_name = config_setting_name(it); int job_id; - if (strcmp(job_name, "All") == 0) { - itemdb->jobmask2mapid(id->class_base, UINT64_MAX); - } else if ((job_id = pc->check_job_name(job_name)) == -1) { + if (strcmp(job_name, "All") == 0) + continue; + + if ((job_id = pc->check_job_name(job_name)) == -1) { ShowWarning("itemdb_readdb_job_sub: unknown job name '%s'!\n", job_name); } else { itemdb->jobid2mapid(id->class_base, job_id, libconfig->setting_get_bool(it)); @@ -1825,8 +1838,10 @@ int itemdb_readdb_libconfig_sub(struct config_setting_t *it, int n, const char * if ((t = libconfig->setting_get_member(it, "Job")) != NULL) { if (config_setting_is_group(t)) { itemdb->readdb_job_sub(&id, t); - } else if (itemdb->lookup_const(it, "Job", &i32) && i32 >= 0) { - itemdb->jobmask2mapid(id.class_base, i32); + } else if (itemdb->lookup_const(it, "Job", &i32)) { // This is an unsigned value, do not check for >= 0 + itemdb->jobmask2mapid(id.class_base, (uint64)i32); + } else if (!inherit) { + itemdb->jobmask2mapid(id.class_base, UINT64_MAX); } } else if (!inherit) { itemdb->jobmask2mapid(id.class_base, UINT64_MAX); diff --git a/src/map/pc.c b/src/map/pc.c index 51aba9509..7b4d47db2 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2885,6 +2885,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) { break; default: ShowWarning("pc_bonus: unknown type %d %d !\n",type,val); + Assert_report(0); break; } return 0; @@ -3677,6 +3678,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) #endif default: ShowWarning("pc_bonus2: unknown type %d %d %d!\n",type,type2,val); + Assert_report(0); break; } return 0; @@ -3849,6 +3851,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) default: ShowWarning("pc_bonus3: unknown type %d %d %d %d!\n",type,type2,type3,val); + Assert_report(0); break; } @@ -3943,6 +3946,7 @@ int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4 default: ShowWarning("pc_bonus4: unknown type %d %d %d %d %d!\n",type,type2,type3,type4,val); + Assert_report(0); break; } @@ -3970,6 +3974,7 @@ int pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type4 default: ShowWarning("pc_bonus5: unknown type %d %d %d %d %d %d!\n",type,type2,type3,type4,type5,val); + Assert_report(0); break; } diff --git a/src/map/pc.h b/src/map/pc.h index db1d7a9da..0d2bca84d 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -302,8 +302,8 @@ BEGIN_ZEROED_BLOCK; // this block will be globally zeroed at the beginning of st int reseff[SC_COMMON_MAX-SC_COMMON_MIN+1]; int weapon_coma_ele[ELE_MAX]; int weapon_coma_race[RC_MAX]; - int weapon_atk[16]; - int weapon_atk_rate[16]; + int weapon_atk[MAX_WEAPON_TYPE]; + int weapon_atk_rate[MAX_WEAPON_TYPE]; int arrow_addele[ELE_MAX]; int arrow_addrace[RC_MAX]; int arrow_addsize[3]; diff --git a/src/map/status.c b/src/map/status.c index d04e88e3c..82c427317 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -12826,7 +12826,7 @@ bool status_readdb_sizefix(char* fields[], int columns, int current) { unsigned int i; - for(i = 0; i < MAX_WEAPON_TYPE; i++) + for(i = 0; i < MAX_SINGLE_WEAPON_TYPE; i++) { status->dbs->atkmods[current][i] = atoi(fields[i]); } @@ -13008,7 +13008,7 @@ int status_readdb(void) // size_fix.txt for(i = 0; i < ARRAYLENGTH(status->dbs->atkmods); i++) - for(j = 0; j < MAX_WEAPON_TYPE; j++) + for(j = 0; j < MAX_SINGLE_WEAPON_TYPE; j++) status->dbs->atkmods[i][j] = 100; // refine_db.txt @@ -13023,7 +13023,7 @@ int status_readdb(void) // read databases // sv->readdb(map->db_path, "job_db2.txt", ',', 1, 1+MAX_LEVEL, -1, status->readdb_job2); - sv->readdb(map->db_path, DBPATH"size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(status->dbs->atkmods), status->readdb_sizefix); + sv->readdb(map->db_path, DBPATH"size_fix.txt", ',', MAX_SINGLE_WEAPON_TYPE, MAX_SINGLE_WEAPON_TYPE, ARRAYLENGTH(status->dbs->atkmods), status->readdb_sizefix); status->readdb_refine_libconfig(DBPATH"refine_db.conf"); sv->readdb(map->db_path, "sc_config.txt", ',', 2, 2, SC_MAX, status->readdb_scconfig); status->read_job_db(); diff --git a/src/map/status.h b/src/map/status.h index 296b5baae..4e2f1bdc0 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -2169,7 +2169,7 @@ BEGIN_ZEROED_BLOCK; /* Everything within this block will be memset to 0 when sta /* */ struct s_refine_info refine_info[REFINE_TYPE_MAX]; /* */ - int atkmods[3][MAX_WEAPON_TYPE];//ATK weapon modification for size (size_fix.txt) + int atkmods[3][MAX_SINGLE_WEAPON_TYPE];//ATK weapon modification for size (size_fix.txt) char job_bonus[CLASS_COUNT][MAX_LEVEL]; sc_conf_type sc_conf[SC_MAX]; END_ZEROED_BLOCK; /* End */ |