summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-02-13 18:58:14 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-02-13 18:58:14 +0000
commit44ade8dfd6c775c9c2c0e47f049e2b99807ed3c1 (patch)
tree8e45d475ad540ecfa2fc4591213c477e9bacbf68 /src
parent7751fc21990d18f215dff82669a470b7c3660b11 (diff)
downloadhercules-44ade8dfd6c775c9c2c0e47f049e2b99807ed3c1.tar.gz
hercules-44ade8dfd6c775c9c2c0e47f049e2b99807ed3c1.tar.bz2
hercules-44ade8dfd6c775c9c2c0e47f049e2b99807ed3c1.tar.xz
hercules-44ade8dfd6c775c9c2c0e47f049e2b99807ed3c1.zip
- Made Land Protector Block Hammerfall.
- More signed/unsigned comparison fixes. - Added dummy_item variable to itemdb. It will be used on all itemdb_searches that do not yield a valid item from the db. - Added itemdb_load, which is the one used for item_db loading (if the item does not exists, it'll be created) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5270 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/atcommand.c8
-rw-r--r--src/map/itemdb.c93
-rw-r--r--src/map/itemdb.h1
-rw-r--r--src/map/map.h2
-rw-r--r--src/map/mob.c23
-rw-r--r--src/map/mob.h2
-rw-r--r--src/map/pc.c2
-rw-r--r--src/map/skill.c3
8 files changed, 83 insertions, 51 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 4527ae42e..911cada4a 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -2680,7 +2680,7 @@ int atcommand_baselevelup(
clif_displaymessage(fd, msg_table[47]); /* Base level can't go any higher. */
return -1;
} /* End Addition */
- if (level > pc_maxbaselv(sd) || level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
+ if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
level = pc_maxbaselv(sd) - sd->status.base_level;
for (i = 1; i <= level; i++)
sd->status.status_point += (sd->status.base_level + i + 14) / 5;
@@ -2698,7 +2698,7 @@ int atcommand_baselevelup(
return -1;
}
level*=-1;
- if (level >= sd->status.base_level)
+ if ((unsigned int)level >= sd->status.base_level)
level = sd->status.base_level-1;
if (sd->status.status_point > 0) {
for (i = 0; i > -level; i--)
@@ -2739,7 +2739,7 @@ int atcommand_joblevelup(
clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
return -1;
}
- if (level > pc_maxjoblv(sd) || level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
+ if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
level = pc_maxjoblv(sd) - sd->status.job_level;
sd->status.job_level += level;
clif_updatestatus(sd, SP_JOBLEVEL);
@@ -2755,7 +2755,7 @@ int atcommand_joblevelup(
return -1;
}
level *=-1;
- if (level >= sd->status.job_level) // fix negativ overflow
+ if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
level = sd->status.job_level-1;
sd->status.job_level -= level;
clif_updatestatus(sd, SP_JOBLEVEL);
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 667ab10af..ccc3b49d4 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -29,6 +29,8 @@ static int blue_box_default=0, violet_box_default=0, card_album_default=0, gift_
static struct item_group itemgroup_db[MAX_ITEMGROUP];
+struct item_data *dummy_item=NULL; //This is the default dummy item used for non-existant items. [Skotlex]
+
/*==========================================
* 名前で検索用
*------------------------------------------
@@ -198,52 +200,52 @@ static void itemdb_jobid2mapid(unsigned short *bclass, int jobmask)
bclass[2] |= 1<<MAPID_TAEKWON;
}
+static void create_dummy_data(void) {
+ if (dummy_item)
+ aFree(dummy_item);
+
+ dummy_item=(struct item_data *)aCalloc(1,sizeof(struct item_data));
+ dummy_item->nameid=500;
+ dummy_item->weight=1;
+ dummy_item->type=3; //Etc item
+ strncpy(dummy_item->name,"UNKNOWN_ITEM",ITEM_NAME_LENGTH);
+ strncpy(dummy_item->jname,"UNKNOWN_ITEM",ITEM_NAME_LENGTH);
+ dummy_item->view_id = 512; //Use apple sprite.
+}
+
static void* create_item_data(DBKey key, va_list args) {
struct item_data *id;
- int nameid = key.i;
-
id=(struct item_data *)aCalloc(1,sizeof(struct item_data));
- id->nameid=nameid;
- id->value_buy=10;
- id->value_sell=id->value_buy/2;
- id->weight=10;
- id->sex=2;
- id->class_base[0]=0xff;
- id->class_base[1]=0xff;
- id->class_base[2]=0xff;
- id->class_upper=5;
-
- if(nameid>500 && nameid<600)
- id->type=0; //heal item
- else if(nameid>600 && nameid<700)
- id->type=2; //use item
- else if((nameid>700 && nameid<1100) ||
- (nameid>7000 && nameid<8000))
- id->type=3; //correction
- else if(nameid>=1750 && nameid<1771)
- id->type=10; //arrow
- else if(nameid>1100 && nameid<2000)
- id->type=4; //weapon
- else if((nameid>2100 && nameid<3000) ||
- (nameid>5000 && nameid<6000))
- id->type=5; //armor
- else if(nameid>4000 && nameid<5000)
- id->type=6; //card
- else if(nameid>9000 && nameid<10000)
- id->type=7; //egg
- else if(nameid>10000)
- id->type=8; //petequip
+ id->nameid = key.i;
+ id->weight=1;
+ id->type=3; //Etc item
return id;
}
+
/*==========================================
- * DBの検索
+ * Loads (and creates if not found) an item from the db.
*------------------------------------------
*/
-struct item_data* itemdb_search(int nameid)
+struct item_data* itemdb_load(int nameid)
{
return idb_ensure(item_db,nameid,create_item_data);
}
+static void* return_dummy_data(DBKey key, va_list args) {
+ if (battle_config.error_log)
+ ShowWarning("itemdb_search: Item ID %d does not exists in the item_db. Using dummy data.\n", key.i);
+ return dummy_item;
+}
+
+/*==========================================
+ * Loads an item from the db. If not found, it will return the dummy item.
+ *------------------------------------------
+ */
+struct item_data* itemdb_search(int nameid)
+{
+ return idb_ensure(item_db,nameid,return_dummy_data);
+}
+
/*==========================================
*
*------------------------------------------
@@ -812,10 +814,10 @@ static int itemdb_read_sqldb(void)
ln++;
// ----------
- id = itemdb_search(nameid);
+ id = itemdb_load(nameid);
- memcpy(id->name, sql_row[1], ITEM_NAME_LENGTH-1);
- memcpy(id->jname, sql_row[2], ITEM_NAME_LENGTH-1);
+ memcpy(id->name, sql_row[1], ITEM_NAME_LENGTH);
+ memcpy(id->jname, sql_row[2], ITEM_NAME_LENGTH);
id->type = atoi(sql_row[3]);
if (id->type == 11)
@@ -956,9 +958,9 @@ static int itemdb_readdb(void)
ln++;
//ID,Name,Jname,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Job Upper,Gender,Loc,wLV,eLV,refineable,View
- id=itemdb_search(nameid);
- memcpy(id->name, str[1], ITEM_NAME_LENGTH-1);
- memcpy(id->jname, str[2], ITEM_NAME_LENGTH-1);
+ id=itemdb_load(nameid);
+ memcpy(id->name, str[1], ITEM_NAME_LENGTH);
+ memcpy(id->jname, str[2], ITEM_NAME_LENGTH);
id->type=atoi(str[3]);
if (id->type == 11)
{ //Items that are consumed upon target confirmation
@@ -1075,8 +1077,8 @@ static int itemdb_final_sub (DBKey key,void *data,va_list ap)
aFree(id->script);
id->script = NULL;
}
- // Whether to clear the item data
- if (flag)
+ // Whether to clear the item data (exception: do not clear the dummy item data
+ if (flag && id != dummy_item)
aFree(id);
return 0;
@@ -1092,11 +1094,18 @@ void itemdb_reload(void)
void do_final_itemdb(void)
{
item_db->destroy(item_db, itemdb_final_sub, 1);
+ if (dummy_item) {
+ if (dummy_item->script)
+ aFree(dummy_item->script);
+ aFree(dummy_item);
+ dummy_item = NULL;
+ }
}
int do_init_itemdb(void)
{
item_db = db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int));
+ create_dummy_data(); //Dummy data item.
itemdb_read();
return 0;
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 3de337c67..2c2422128 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -55,6 +55,7 @@ struct item_group {
};
struct item_data* itemdb_searchname(const char *name);
+struct item_data* itemdb_load(int nameid);
struct item_data* itemdb_search(int nameid);
struct item_data* itemdb_exists(int nameid);
#define itemdb_type(n) itemdb_search(n)->type
diff --git a/src/map/map.h b/src/map/map.h
index ea1f85bbd..da04f6d0b 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -853,8 +853,8 @@ struct mob_data {
short speed;
short attacked_count;
short target_lv;
+ unsigned short level;
unsigned long tdmg; //Stores total damage given to the mob, for exp calculations. [Skotlex]
- unsigned int level;
int timer;
int hp, max_hp;
int target_id,attacked_id;
diff --git a/src/map/mob.c b/src/map/mob.c
index 7400bbc77..ac53f77c2 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -4310,6 +4310,11 @@ static int mob_readdb(void)
int rate = 0,rate_adjust,type,ratemin,ratemax;
struct item_data *id;
mob_db_data[class_]->dropitem[i].nameid=atoi(str[29+i*2]);
+ if (!mob_db_data[class_]->dropitem[i].nameid) {
+ //No drop.
+ mob_db_data[class_]->dropitem[i].p = 0;
+ continue;
+ }
type = itemdb_type(mob_db_data[class_]->dropitem[i].nameid);
rate = atoi(str[30+i*2]);
if (class_ >= 1324 && class_ <= 1363)
@@ -4378,9 +4383,13 @@ static int mob_readdb(void)
// MVP Drops: MVP1id,MVP1per,MVP2id,MVP2per,MVP3id,MVP3per
for(i=0;i<3;i++){
struct item_data *id;
- int rate=atoi(str[52+i*2]);
mob_db_data[class_]->mvpitem[i].nameid=atoi(str[51+i*2]);
- mob_db_data[class_]->mvpitem[i].p= mob_drop_adjust(rate, battle_config.item_rate_mvp,
+ if (!mob_db_data[class_]->mvpitem[i].nameid) {
+ //No item....
+ mob_db_data[class_]->mvpitem[i].p = 0;
+ continue;
+ }
+ mob_db_data[class_]->mvpitem[i].p= mob_drop_adjust(atoi(str[52+i*2]), battle_config.item_rate_mvp,
battle_config.item_drop_mvp_min, battle_config.item_drop_mvp_max);
//calculate and store Max available drop chance of the MVP item
@@ -4892,6 +4901,11 @@ static int mob_read_sqldb(void)
int rate = 0, rate_adjust, type, ratemin, ratemax;
struct item_data *id;
mob_db_data[class_]->dropitem[i].nameid=TO_INT(29+i*2);
+ if (!mob_db_data[class_]->dropitem[i].nameid) {
+ //No drop.
+ mob_db_data[class_]->dropitem[i].p = 0;
+ continue;
+ }
type = itemdb_type(mob_db_data[class_]->dropitem[i].nameid);
rate = TO_INT(30+i*2);
if (class_ >= 1324 && class_ <= 1363)
@@ -4961,6 +4975,11 @@ static int mob_read_sqldb(void)
for (i=0; i<3; i++) {
struct item_data *id;
mob_db_data[class_]->mvpitem[i].nameid = TO_INT(51+i*2);
+ if (!mob_db_data[class_]->mvpitem[i].nameid) {
+ //No item....
+ mob_db_data[class_]->mvpitem[i].p = 0;
+ continue;
+ }
mob_db_data[class_]->mvpitem[i].p = mob_drop_adjust(TO_INT(52+i*2),
battle_config.item_rate_mvp, battle_config.item_drop_mvp_min, battle_config.item_drop_mvp_max);
diff --git a/src/map/mob.h b/src/map/mob.h
index 2a084f082..7e011beac 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -29,7 +29,7 @@ struct mob_skill {
struct mob_db {
char name[NAME_LENGTH],jname[NAME_LENGTH];
- short lv;
+ unsigned short lv;
int max_hp,max_sp;
unsigned int base_exp,job_exp;
int atk1,atk2;
diff --git a/src/map/pc.c b/src/map/pc.c
index 1800c74ea..a19ff6538 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -5783,7 +5783,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val)
if ((unsigned int)val > pc_maxbaselv(sd)) //Capping to max
val = pc_maxbaselv(sd);
if ((unsigned int)val > sd->status.base_level) {
- for (i = 1; i <= ((unsigned int)val - sd->status.base_level); i++)
+ for (i = 1; i <= (int)((unsigned int)val - sd->status.base_level); i++)
sd->status.status_point += (sd->status.base_level + i + 14) / 5 ;
}
sd->status.base_level = (unsigned int)val;
diff --git a/src/map/skill.c b/src/map/skill.c
index cd44beabb..df195df00 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -3949,6 +3949,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
clif_skill_nodamage(src,bl,skillid,skilllv,0);
break;
}
+ if(map_getcell(bl->m,bl->x,bl->y,CELL_CHKLANDPROTECTOR))
+ break; //Land Protector blocks Hammer Fall [Skotlex]
+
clif_skill_nodamage(src,bl,skillid,skilllv,
status_change_start(bl,SC_STAN,(20 + 10 * skilllv),
skilllv,0,0,0,skill_get_time2(skillid,skilllv),0));