summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/pc.c2
-rw-r--r--src/map/script.c105
-rw-r--r--src/map/skill.c16
3 files changed, 75 insertions, 48 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 00662e91c..3dd2289c3 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3071,8 +3071,6 @@ int pc_useitem(struct map_session_data *sd,int n)
sd->sc.data[SC_BERSERK].timer!=-1 ||
sd->sc.data[SC_MARIONETTE].timer!=-1 ||
(sd->sc.data[SC_GRAVITATION].timer!=-1 && sd->sc.data[SC_GRAVITATION].val3 == BCT_SELF) ||
- //Cannot use Potions/Healing items while under Gospel.
- (sd->sc.data[SC_GOSPEL].timer!=-1 && sd->sc.data[SC_GOSPEL].val4 == BCT_SELF && sd->inventory_data[n]->type == IT_HEALING) ||
sd->sc.data[SC_TRICKDEAD].timer != -1 ||
sd->sc.data[SC_BLADESTOP].timer != -1 ||
(sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOITEM)
diff --git a/src/map/script.c b/src/map/script.c
index a754aca14..d423d433e 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -6776,7 +6776,7 @@ unsigned int equip[10]={EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_GARMENT
*------------------------------------------*/
BUILDIN_FUNC(getequipid)
{
- int i,num;
+ int i=-1,num;
TBL_PC *sd;
struct item_data* item;
@@ -6787,7 +6787,8 @@ BUILDIN_FUNC(getequipid)
return 0;
}
num=script_getnum(st,2);
- i=pc_checkequip(sd,equip[num-1]);
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
if(i >= 0){
item=sd->inventory_data[i];
if(item)
@@ -6805,7 +6806,7 @@ BUILDIN_FUNC(getequipid)
*------------------------------------------*/
BUILDIN_FUNC(getequipname)
{
- int i,num;
+ int i=-1,num;
TBL_PC *sd;
struct item_data* item;
char *buf;
@@ -6815,7 +6816,8 @@ BUILDIN_FUNC(getequipname)
buf=(char *)aMallocA(64*sizeof(char));
sd=script_rid2sd(st);
num=script_getnum(st,2);
- i=pc_checkequip(sd,equip[num-1]);
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
if(i >= 0){
item=sd->inventory_data[i];
if(item)
@@ -6890,22 +6892,19 @@ BUILDIN_FUNC(repair)
*------------------------------------------*/
BUILDIN_FUNC(getequipisequiped)
{
- int i,num;
+ int i=-1,num;
TBL_PC *sd;
num=script_getnum(st,2);
sd=script_rid2sd(st);
- if ((num - 1) >= (sizeof(equip) / sizeof(equip[0])))
- i = -1;
- else
+ if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
- if(i >= 0)
- script_pushint(st,1);
- else
- script_pushint(st,0);
-
+ if(i >= 0)
+ script_pushint(st,1);
+ else
+ script_pushint(st,0);
return 0;
}
@@ -6914,12 +6913,13 @@ BUILDIN_FUNC(getequipisequiped)
*------------------------------------------*/
BUILDIN_FUNC(getequipisenableref)
{
- int i,num;
+ int i=-1,num;
TBL_PC *sd;
num=script_getnum(st,2);
sd=script_rid2sd(st);
- i=pc_checkequip(sd,equip[num-1]);
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
if(i >= 0 && sd->inventory_data[i] && !sd->inventory_data[i]->flag.no_refine)
{
script_pushint(st,1);
@@ -6935,12 +6935,13 @@ BUILDIN_FUNC(getequipisenableref)
*------------------------------------------*/
BUILDIN_FUNC(getequipisidentify)
{
- int i,num;
+ int i=-1,num;
TBL_PC *sd;
num=script_getnum(st,2);
sd=script_rid2sd(st);
- i=pc_checkequip(sd,equip[num-1]);
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
if(i >= 0)
script_pushint(st,sd->status.inventory[i].identify);
else
@@ -6954,12 +6955,13 @@ BUILDIN_FUNC(getequipisidentify)
*------------------------------------------*/
BUILDIN_FUNC(getequiprefinerycnt)
{
- int i,num;
+ int i=-1,num;
TBL_PC *sd;
num=script_getnum(st,2);
sd=script_rid2sd(st);
- i=pc_checkequip(sd,equip[num-1]);
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
if(i >= 0)
script_pushint(st,sd->status.inventory[i].refine);
else
@@ -6973,12 +6975,13 @@ BUILDIN_FUNC(getequiprefinerycnt)
*------------------------------------------*/
BUILDIN_FUNC(getequipweaponlv)
{
- int i,num;
+ int i=-1,num;
TBL_PC *sd;
num=script_getnum(st,2);
sd=script_rid2sd(st);
- i=pc_checkequip(sd,equip[num-1]);
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
if(i >= 0 && sd->inventory_data[i])
script_pushint(st,sd->inventory_data[i]->wlv);
else
@@ -6992,12 +6995,13 @@ BUILDIN_FUNC(getequipweaponlv)
*------------------------------------------*/
BUILDIN_FUNC(getequippercentrefinery)
{
- int i,num;
+ int i=-1,num;
TBL_PC *sd;
num=script_getnum(st,2);
sd=script_rid2sd(st);
- i=pc_checkequip(sd,equip[num-1]);
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
if(i >= 0 && sd->status.inventory[i].nameid && sd->status.inventory[i].refine < MAX_REFINE)
script_pushint(st,percentrefinery[itemdb_wlv(sd->status.inventory[i].nameid)][(int)sd->status.inventory[i].refine]);
else
@@ -7011,12 +7015,13 @@ BUILDIN_FUNC(getequippercentrefinery)
*------------------------------------------*/
BUILDIN_FUNC(successrefitem)
{
- int i,num,ep;
+ int i=-1,num,ep;
TBL_PC *sd;
num=script_getnum(st,2);
sd=script_rid2sd(st);
- i=pc_checkequip(sd,equip[num-1]);
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
if(i >= 0) {
ep=sd->status.inventory[i].equip;
@@ -7063,12 +7068,13 @@ BUILDIN_FUNC(successrefitem)
*------------------------------------------*/
BUILDIN_FUNC(failedrefitem)
{
- int i,num;
+ int i=-1,num;
TBL_PC *sd;
num=script_getnum(st,2);
sd=script_rid2sd(st);
- i=pc_checkequip(sd,equip[num-1]);
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
if(i >= 0) {
//Logs items, got from (N)PC scripts [Lupus]
if(log_config.enable_logs&0x40)
@@ -9749,13 +9755,20 @@ BUILDIN_FUNC(requestguildinfo)
* ---------------------------------------------------------------------*/
BUILDIN_FUNC(getequipcardcnt)
{
- int i,num;
+ int i=-1,num;
TBL_PC *sd;
int c=MAX_SLOTS;
num=script_getnum(st,2);
sd=script_rid2sd(st);
- i=pc_checkequip(sd,equip[num-1]);
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
+
+ if (i < 0) {
+ script_pushint(st,0);
+ return 0;
+ }
+
if(itemdb_isspecial(sd->status.inventory[i].card[0]))
{
script_pushint(st,0);
@@ -9777,14 +9790,21 @@ BUILDIN_FUNC(getequipcardcnt)
* ----------------------------------------------------------------*/
BUILDIN_FUNC(successremovecards)
{
- int i,j,num,cardflag=0,flag;
+ int i=-1,j,num,cardflag=0,flag;
TBL_PC *sd;
struct item item_tmp;
int c=MAX_SLOTS;
num=script_getnum(st,2);
sd=script_rid2sd(st);
- i=pc_checkequip(sd,equip[num-1]);
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
+
+ if (i < 0) {
+ script_pushint(st,0);
+ return 0;
+ }
+
if(itemdb_isspecial(sd->status.inventory[i].card[0]))
return 0;
@@ -9844,7 +9864,7 @@ BUILDIN_FUNC(successremovecards)
* ----------------------------------------------------------------*/
BUILDIN_FUNC(failedremovecards)
{
- int i,j,num,cardflag=0,flag,typefail;
+ int i=-1,j,num,cardflag=0,flag,typefail;
TBL_PC *sd;
struct item item_tmp;
int c=MAX_SLOTS;
@@ -9852,7 +9872,14 @@ BUILDIN_FUNC(failedremovecards)
num=script_getnum(st,2);
typefail=script_getnum(st,3);
sd=script_rid2sd(st);
- i=pc_checkequip(sd,equip[num-1]);
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
+
+ if (i < 0) {
+ script_pushint(st,0);
+ return 0;
+ }
+
if(itemdb_isspecial(sd->status.inventory[i].card[0]))
return 0;
@@ -10403,13 +10430,14 @@ BUILDIN_FUNC(setiteminfo)
*------------------------------------------*/
BUILDIN_FUNC(getequipcardid)
{
- int i,num,slot;
+ int i=-1,num,slot;
TBL_PC *sd;
num=script_getnum(st,2);
slot=script_getnum(st,3);
sd=script_rid2sd(st);
- i=pc_checkequip(sd,equip[num-1]);
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
if(i >= 0 && slot>=0 && slot<4)
script_pushint(st,sd->status.inventory[i].card[slot]);
else
@@ -11893,10 +11921,11 @@ BUILDIN_FUNC(unequip)
num = script_getnum(st,2) - 1;
sd=script_rid2sd(st);
- if(sd!=NULL && num<10)
+ if(sd!=NULL && num > 0 && num <= ARRAYLENGTH(equip))
{
- i=pc_checkequip(sd,equip[num]);
- pc_unequipitem(sd,i,2);
+ i=pc_checkequip(sd,equip[num-1]);
+ if (i >= 0)
+ pc_unequipitem(sd,i,2);
return 0;
}
return 0;
diff --git a/src/map/skill.c b/src/map/skill.c
index c81aa3aaf..f3464be83 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -1890,13 +1890,13 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in
}
-//Checks if there should be magic reflection.
+//Checks if bl should reflect back a spell.
//type is the type of magic attack: 0: indirect (aoe), 1: direct (targetted)
-static int skill_magic_reflect(struct block_list *src, struct block_list *target, int type)
+static int skill_magic_reflect(struct block_list *bl, int type)
{
- struct status_change *sc = status_get_sc(target);
+ struct status_change *sc = status_get_sc(bl);
struct map_session_data *sd;
- BL_CAST(BL_PC, src, sd);
+ BL_CAST(BL_PC, bl, sd);
if(sd && sd->magic_damage_return && type && rand()%100 < sd->magic_damage_return)
return 1;
@@ -1906,11 +1906,11 @@ static int skill_magic_reflect(struct block_list *src, struct block_list *target
if(sc->data[SC_MAGICMIRROR].timer != -1 && rand()%100 < sc->data[SC_MAGICMIRROR].val2)
return 1;
- if(sc->data[SC_KAITE].timer != -1 && (sd || status_get_lv(src) <= 80))
+ if(sc->data[SC_KAITE].timer != -1 && (sd || status_get_lv(bl) <= 80))
{ //Works on players or mobs with level under 80.
- clif_specialeffect(target, 438, AREA);
+ clif_specialeffect(bl, 438, AREA);
if (--sc->data[SC_KAITE].val2 <= 0)
- status_change_end(target, SC_KAITE, -1);
+ status_change_end(bl, SC_KAITE, -1);
return 1;
}
}
@@ -1994,7 +1994,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
if (attack_type&BF_MAGIC) {
if (!(sstatus->mode&MD_BOSS) && (dmg.damage || dmg.damage2) &&
- skill_magic_reflect(src, bl, src==dsrc))
+ skill_magic_reflect(bl, src==dsrc))
{ //Magic reflection, switch caster/target
struct block_list *tbl = bl;
bl = src;