summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-06 21:17:37 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-06 22:28:06 +0300
commit4f6b2ebd825282937015efabbd35fc2cc6d992db (patch)
tree3818430c8548c96e3ee9b9c84161449bb1e1b01d
parent4a2c0e09bf758b57a52d9714d5306fee587544cd (diff)
downloadhercules-4f6b2ebd825282937015efabbd35fc2cc6d992db.tar.gz
hercules-4f6b2ebd825282937015efabbd35fc2cc6d992db.tar.bz2
hercules-4f6b2ebd825282937015efabbd35fc2cc6d992db.tar.xz
hercules-4f6b2ebd825282937015efabbd35fc2cc6d992db.zip
Check allowed range for "View" field in item_db for weapon items.
Also fix some array sizes.
-rw-r--r--src/common/mmo.h3
-rw-r--r--src/map/itemdb.c6
-rw-r--r--src/map/pc.h4
-rw-r--r--src/map/status.c6
-rw-r--r--src/map/status.h2
5 files changed, 14 insertions, 7 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 77b9abab6..8818ea9df 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -971,7 +971,7 @@ enum weapon_type {
W_GRENADE, //21
W_HUUMA, //22
W_2HSTAFF, //23
- MAX_WEAPON_TYPE,
+ MAX_SINGLE_WEAPON_TYPE,
// dual-wield constants
W_DOUBLE_DD, ///< 2 daggers
W_DOUBLE_SS, ///< 2 swords
@@ -979,6 +979,7 @@ enum weapon_type {
W_DOUBLE_DS, ///< dagger + sword
W_DOUBLE_DA, ///< dagger + axe
W_DOUBLE_SA, ///< sword + axe
+ MAX_WEAPON_TYPE,
};
enum ammo_type {
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 */