From 4f6b2ebd825282937015efabbd35fc2cc6d992db Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 6 Mar 2016 21:17:37 +0300 Subject: Check allowed range for "View" field in item_db for weapon items. Also fix some array sizes. --- src/map/itemdb.c | 6 ++++++ src/map/pc.h | 4 ++-- src/map/status.c | 6 +++--- src/map/status.h | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/map') diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 27adc387b..73da34df1 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 ) 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 */ -- cgit v1.2.3-60-g2f50