summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-06 15:12:55 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-06 15:12:55 +0000
commit13c58cce0a44f607c96771d7014791eba1a57429 (patch)
tree3919a67f4a4357a544c8a77f714cd5d8524e5a0b /src/map/script.c
parent71392bc0305b06e18c99892d0a5b3fb4aaaf22c9 (diff)
downloadhercules-13c58cce0a44f607c96771d7014791eba1a57429.tar.gz
hercules-13c58cce0a44f607c96771d7014791eba1a57429.tar.bz2
hercules-13c58cce0a44f607c96771d7014791eba1a57429.tar.xz
hercules-13c58cce0a44f607c96771d7014791eba1a57429.zip
* Removed the attempts to recover from invalid syntax in npc_parsesrcfile since they can produce incorrect results (spaces in sscanf can match \n's and company).
* Made script_rid2sd report the script source directly and changed related return 1's to return 0's to avoid double script source reports. * Added missing return 0's after script_rid2sd is used and an extra error message in buildin_set/buildin_setd. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11860 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c306
1 files changed, 233 insertions, 73 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 8a479bac6..ec0c3494c 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -2092,6 +2092,7 @@ TBL_PC *script_rid2sd(struct script_state *st)
TBL_PC *sd=map_id2sd(st->rid);
if(!sd){
ShowError("script_rid2sd: fatal error ! player not attached!\n");
+ script_reportsrc(st);
st->state = END;
}
return sd;
@@ -2120,13 +2121,13 @@ int get_val(struct script_state* st, struct script_data* data)
{// needs player attached
if( postfix == '$' )
{// string variable
- ShowError("script:get_val: cannot access player variable '%s', defaulting to \"\"\n", name);
+ ShowWarning("script:get_val: cannot access player variable '%s', defaulting to \"\"\n", name);
data->type = C_CONSTSTR;
data->u.str = "";
}
else
{// integer variable
- ShowError("script:get_val: cannot access player variable '%s', defaulting to 0\n", name);
+ ShowWarning("script:get_val: cannot access player variable '%s', defaulting to 0\n", name);
data->type = C_INT;
data->u.num = 0;
}
@@ -3660,7 +3661,8 @@ BUILDIN_FUNC(mes)
{
TBL_PC* sd = script_rid2sd(st);
if( sd == NULL )
- return 1;
+ return 0;
+
clif_scriptmes(sd, st->oid, script_getstr(st, 2));
return 0;
}
@@ -3675,7 +3677,7 @@ BUILDIN_FUNC(next)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;
+ return 0;
st->state = STOP;
clif_scriptnext(sd, st->oid);
@@ -3692,7 +3694,7 @@ BUILDIN_FUNC(close)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;
+ return 0;
st->state = END;
clif_scriptclose(sd, st->oid);
@@ -3709,7 +3711,7 @@ BUILDIN_FUNC(close2)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;
+ return 0;
st->state = STOP;
clif_scriptclose(sd, st->oid);
@@ -3776,7 +3778,7 @@ BUILDIN_FUNC(menu)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;
+ return 0;
// TODO detect multiple scripts waiting for input at the same time, and what to do when that happens
if( sd->state.menu_or_input == 0 )
@@ -3880,7 +3882,7 @@ BUILDIN_FUNC(select)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;
+ return 0;
if( sd->state.menu_or_input == 0 )
{
@@ -3940,7 +3942,7 @@ BUILDIN_FUNC(prompt)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;
+ return 0;
if( sd->state.menu_or_input == 0 )
{
@@ -4218,9 +4220,11 @@ BUILDIN_FUNC(warp)
int ret;
int x,y;
const char* str;
- TBL_PC* sd = script_rid2sd(st);
+ TBL_PC* sd;
- nullpo_retr(0, sd);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
str = script_getstr(st,2);
x = script_getnum(st,3);
@@ -4445,6 +4449,9 @@ BUILDIN_FUNC(warpguild)
y=script_getnum(st,4);
g=script_getnum(st,5);
sd=script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
if(map[sd->bl.m].flag.noreturn || map[sd->bl.m].flag.nowarpto)
return 0;
@@ -4559,6 +4566,7 @@ BUILDIN_FUNC(itemheal)
BUILDIN_FUNC(percentheal)
{
int hp,sp;
+ TBL_PC* sd;
hp=script_getnum(st,2);
sp=script_getnum(st,3);
@@ -4569,7 +4577,11 @@ BUILDIN_FUNC(percentheal)
return 0;
}
- pc_percentheal(script_rid2sd(st),hp,sp);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
+ pc_percentheal(sd,hp,sp);
return 0;
}
@@ -4586,9 +4598,15 @@ BUILDIN_FUNC(jobchange)
if (pcdb_checkid(job))
{
- pc_jobchange(script_rid2sd(st),job, upper);
+ TBL_PC* sd;
+
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
+ pc_jobchange(sd, job, upper);
if(use_irc && irc_announce_jobchange_flag)
- irc_announce_jobchange(script_rid2sd(st));
+ irc_announce_jobchange(sd);
}
return 0;
@@ -4615,7 +4633,7 @@ BUILDIN_FUNC(input)
char *name=str_buf+str_data[num&0x00ffffff].str;
char postfix = name[strlen(name)-1];
- if (!sd) return 1;
+ if (!sd) return 0;
if( !data_isreference(data) ){
ShowError("script:input: not a variable\n");
@@ -4668,7 +4686,14 @@ BUILDIN_FUNC(set)
}
if(not_server_variable(prefix))
+ {
sd=script_rid2sd(st);
+ if( sd == NULL )
+ {
+ ShowError("script:set: no player attached for player variable '%s'\n", name);
+ return 0;
+ }
+ }
if( postfix=='$' ){
// •¶Žš—ñ
@@ -4751,7 +4776,7 @@ BUILDIN_FUNC(setarray)
{
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached
+ return 0;// no player attached
}
end = start + script_lastdata(st) - 2;
@@ -4815,7 +4840,7 @@ BUILDIN_FUNC(cleararray)
{
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached
+ return 0;// no player attached
}
if( is_string_variable(name) )
@@ -4890,7 +4915,7 @@ BUILDIN_FUNC(copyarray)
{
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached
+ return 0;// no player attached
}
count = script_getnum(st, 4);
@@ -4993,7 +5018,7 @@ BUILDIN_FUNC(deletearray)
{
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached
+ return 0;// no player attached
}
end = getarraysize(st, id, start, is_string_variable(name), reference_getref(data));
@@ -5086,11 +5111,16 @@ BUILDIN_FUNC(getelementofarray)
BUILDIN_FUNC(setlook)
{
int type,val;
+ TBL_PC* sd;
type=script_getnum(st,2);
val=script_getnum(st,3);
- pc_changelook(script_rid2sd(st),type,val);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
+ pc_changelook(sd,type,val);
return 0;
}
@@ -5100,7 +5130,13 @@ BUILDIN_FUNC(setlook)
*------------------------------------------*/
BUILDIN_FUNC(cutin)
{
- clif_cutin(script_rid2sd(st),script_getstr(st,2),script_getnum(st,3));
+ TBL_PC* sd;
+
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
+ clif_cutin(sd,script_getstr(st,2),script_getnum(st,3));
return 0;
}
@@ -5110,14 +5146,19 @@ BUILDIN_FUNC(cutin)
BUILDIN_FUNC(viewpoint)
{
int type,x,y,id,color;
+ TBL_PC* sd;
type=script_getnum(st,2);
x=script_getnum(st,3);
y=script_getnum(st,4);
id=script_getnum(st,5);
color=script_getnum(st,6);
+
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
- clif_viewpoint(script_rid2sd(st),st->oid,type,x,y,id,color);
+ clif_viewpoint(sd,st->oid,type,x,y,id,color);
return 0;
}
@@ -5232,6 +5273,8 @@ BUILDIN_FUNC(checkweight)
struct script_data *data;
sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
data=script_getdata(st,2);
get_val(st,data);
@@ -5354,6 +5397,8 @@ BUILDIN_FUNC(getitem2)
struct script_data *data;
sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
data=script_getdata(st,2);
get_val(st,data);
@@ -5577,6 +5622,8 @@ BUILDIN_FUNC(delitem)
struct script_data *data;
sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
data=script_getdata(st,2);
get_val(st,data);
@@ -5681,6 +5728,8 @@ BUILDIN_FUNC(delitem2)
struct script_data *data;
sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
data=script_getdata(st,2);
get_val(st,data);
@@ -6102,10 +6151,8 @@ BUILDIN_FUNC(getequipid)
sd=script_rid2sd(st);
if(sd == NULL)
- {
- ShowError("getequipid: sd == NULL\n");
return 0;
- }
+
num=script_getnum(st,2);
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
@@ -6133,8 +6180,11 @@ BUILDIN_FUNC(getequipname)
static char pos[11][100] = {"Head","Body","Left hand","Right hand","Robe","Shoes","Accessory 1","Accessory 2","Head 2","Head 3","Not Equipped"};
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
buf=(char *)aMallocA(64*sizeof(char));
- sd=script_rid2sd(st);
num=script_getnum(st,2);
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
@@ -6160,7 +6210,9 @@ BUILDIN_FUNC(getbrokenid)
int i,num,id=0,brokencounter=0;
TBL_PC *sd;
- sd=script_rid2sd(st);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
num=script_getnum(st,2);
for(i=0; i<MAX_INVENTORY; i++) {
@@ -6187,8 +6239,9 @@ BUILDIN_FUNC(repair)
int repaircounter=0;
TBL_PC *sd;
-
- sd=script_rid2sd(st);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
num=script_getnum(st,2);
for(i=0; i<MAX_INVENTORY; i++) {
@@ -6216,7 +6269,9 @@ BUILDIN_FUNC(getequipisequiped)
TBL_PC *sd;
num=script_getnum(st,2);
- sd=script_rid2sd(st);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
@@ -6237,7 +6292,10 @@ BUILDIN_FUNC(getequipisenableref)
TBL_PC *sd;
num=script_getnum(st,2);
- sd=script_rid2sd(st);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
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)
@@ -6259,7 +6317,10 @@ BUILDIN_FUNC(getequipisidentify)
TBL_PC *sd;
num=script_getnum(st,2);
- sd=script_rid2sd(st);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
if(i >= 0)
@@ -6279,7 +6340,10 @@ BUILDIN_FUNC(getequiprefinerycnt)
TBL_PC *sd;
num=script_getnum(st,2);
- sd=script_rid2sd(st);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
if(i >= 0)
@@ -6299,7 +6363,10 @@ BUILDIN_FUNC(getequipweaponlv)
TBL_PC *sd;
num=script_getnum(st,2);
- sd=script_rid2sd(st);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
if(i >= 0 && sd->inventory_data[i])
@@ -6319,7 +6386,10 @@ BUILDIN_FUNC(getequippercentrefinery)
TBL_PC *sd;
num=script_getnum(st,2);
- sd=script_rid2sd(st);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
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)
@@ -6339,7 +6409,10 @@ BUILDIN_FUNC(successrefitem)
TBL_PC *sd;
num=script_getnum(st,2);
- sd=script_rid2sd(st);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
if(i >= 0) {
@@ -6392,7 +6465,10 @@ BUILDIN_FUNC(failedrefitem)
TBL_PC *sd;
num=script_getnum(st,2);
- sd=script_rid2sd(st);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
if(i >= 0) {
@@ -6422,7 +6498,10 @@ BUILDIN_FUNC(statusup)
TBL_PC *sd;
type=script_getnum(st,2);
- sd=script_rid2sd(st);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
pc_statusup(sd,type);
return 0;
@@ -6437,7 +6516,10 @@ BUILDIN_FUNC(statusup2)
type=script_getnum(st,2);
val=script_getnum(st,3);
- sd=script_rid2sd(st);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
pc_statusup2(sd,type,val);
return 0;
@@ -6462,7 +6544,7 @@ BUILDIN_FUNC(bonus)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1; // no player attached
+ return 0; // no player attached
type = script_getnum(st,2);
switch( script_lastdata(st) ){
@@ -6513,7 +6595,7 @@ BUILDIN_FUNC(bonusautoscript)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
str = script_getstr(st,2);
rate = script_getnum(st,3);
@@ -6539,7 +6621,7 @@ BUILDIN_FUNC(bonusautoscript2)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
str = script_getstr(st,2);
rate = script_getnum(st,3);
@@ -6573,7 +6655,7 @@ BUILDIN_FUNC(skill)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
id = script_getnum(st,2);
level = script_getnum(st,3);
@@ -6600,7 +6682,7 @@ BUILDIN_FUNC(addtoskill)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
id = script_getnum(st,2);
level = script_getnum(st,3);
@@ -6623,7 +6705,7 @@ BUILDIN_FUNC(guildskill)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
id = script_getnum(st,2);
level = script_getnum(st,3);
@@ -6643,7 +6725,7 @@ BUILDIN_FUNC(getskilllv)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
id = script_getnum(st,2);
script_pushint(st, pc_checkskill(sd,id));
@@ -6691,7 +6773,7 @@ BUILDIN_FUNC(getgmlevel)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
script_pushint(st, pc_isGM(sd));
@@ -6717,7 +6799,7 @@ BUILDIN_FUNC(checkoption)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
option = script_getnum(st,2);
if( sd->sc.option&option )
@@ -6738,7 +6820,7 @@ BUILDIN_FUNC(checkoption1)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
opt1 = script_getnum(st,2);
if( sd->sc.opt1 == opt1 )
@@ -6759,7 +6841,7 @@ BUILDIN_FUNC(checkoption2)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
opt2 = script_getnum(st,2);
if( sd->sc.opt2&opt2 )
@@ -6785,7 +6867,7 @@ BUILDIN_FUNC(setoption)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
option = script_getnum(st,2);
if( script_hasdata(st,3) )
@@ -6815,7 +6897,7 @@ BUILDIN_FUNC(checkcart)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
if( pc_iscarton(sd) )
script_pushint(st, 1);
@@ -6843,7 +6925,7 @@ BUILDIN_FUNC(setcart)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
if( script_hasdata(st,2) )
type = script_getnum(st,2);
@@ -6863,7 +6945,7 @@ BUILDIN_FUNC(checkfalcon)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
if( pc_isfalcon(sd) )
script_pushint(st, 1);
@@ -6885,7 +6967,7 @@ BUILDIN_FUNC(setfalcon)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
if( script_hasdata(st,2) )
flag = script_getnum(st,2);
@@ -6906,7 +6988,7 @@ BUILDIN_FUNC(checkriding)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
if( pc_isriding(sd) )
script_pushint(st, 1);
@@ -6928,7 +7010,7 @@ BUILDIN_FUNC(setriding)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
if( script_hasdata(st,2) )
flag = script_getnum(st,2);
@@ -6951,7 +7033,7 @@ BUILDIN_FUNC(savepoint)
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;// no player attached, report source
+ return 0;// no player attached, report source
str = script_getstr(st, 2);
x = script_getnum(st,3);
@@ -7070,14 +7152,25 @@ BUILDIN_FUNC(gettimestr)
*------------------------------------------*/
BUILDIN_FUNC(openstorage)
{
- storage_storageopen(script_rid2sd(st));
+ TB_PC* sd;
+
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
+ storage_storageopen(sd);
return 0;
}
BUILDIN_FUNC(guildopenstorage)
{
- TBL_PC *sd=script_rid2sd(st);
+ TBL_PC* sd;
int ret;
+
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
ret = storage_guild_storageopen(sd);
script_pushint(st,ret);
return 0;
@@ -7108,7 +7201,11 @@ BUILDIN_FUNC(itemskill)
BUILDIN_FUNC(produce)
{
int trigger;
- TBL_PC *sd=script_rid2sd(st);
+ TBL_PC* sd;
+
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
trigger=script_getnum(st,2);
clif_skill_produce_mix_list(sd, trigger);
@@ -7119,10 +7216,13 @@ BUILDIN_FUNC(produce)
*------------------------------------------*/
BUILDIN_FUNC(makepet)
{
- TBL_PC *sd = script_rid2sd(st);
+ TBL_PC* sd;
int id,pet_id;
id=script_getnum(st,2);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
pet_id = search_petDB_index(id, PET_CLASS);
@@ -7144,11 +7244,13 @@ BUILDIN_FUNC(makepet)
*------------------------------------------*/
BUILDIN_FUNC(getexp)
{
- TBL_PC *sd = script_rid2sd(st);
+ TBL_PC* sd;;
int base=0,job=0;
double bonus;
- nullpo_retr(0, sd);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
base=script_getnum(st,2);
job =script_getnum(st,3);
@@ -7170,9 +7272,13 @@ BUILDIN_FUNC(getexp)
*------------------------------------------*/
BUILDIN_FUNC(guildgetexp)
{
- TBL_PC *sd = script_rid2sd(st);
+ TBL_PC* sd;
int exp;
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
exp = script_getnum(st,2);
if(exp < 0)
return 0;
@@ -7397,9 +7503,14 @@ BUILDIN_FUNC(addtimer)
{
int tick = script_getnum(st,2);
const char* event = script_getstr(st, 3);
+ TBL_PC* sd;
check_event(st, event);
- pc_addeventtimer(script_rid2sd(st),tick,event);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
+ pc_addeventtimer(sd,tick,event);
return 0;
}
/*==========================================
@@ -7408,9 +7519,15 @@ BUILDIN_FUNC(addtimer)
BUILDIN_FUNC(deltimer)
{
const char *event;
+ TBL_PC* sd;
+
event=script_getstr(st, 2);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
check_event(st, event);
- pc_deleventtimer(script_rid2sd(st),event);
+ pc_deleventtimer(sd,event);
return 0;
}
/*==========================================
@@ -7420,10 +7537,16 @@ BUILDIN_FUNC(addtimercount)
{
const char *event;
int tick;
+ TBL_PC* sd;
+
event=script_getstr(st, 2);
tick=script_getnum(st,3);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
check_event(st, event);
- pc_addeventtimercount(script_rid2sd(st),event,tick);
+ pc_addeventtimercount(sd,event,tick);
return 0;
}
@@ -7459,7 +7582,9 @@ BUILDIN_FUNC(initnpctimer)
if (!nd) return 0;
if (flag) { //Attach
TBL_PC* sd = script_rid2sd(st);
- if (sd) nd->u.scr.rid = sd->bl.id;
+ if( sd == NULL )
+ return 0;
+ nd->u.scr.rid = sd->bl.id;
}
npc_settimerevent_tick(nd,0);
@@ -7498,7 +7623,9 @@ BUILDIN_FUNC(startnpctimer)
if (!nd) return 0;
if (flag) { //Attach
TBL_PC* sd = script_rid2sd(st);
- if (sd) nd->u.scr.rid = sd->bl.id;
+ if( sd == NULL )
+ return 0;
+ nd->u.scr.rid = sd->bl.id;
}
npc_timerevent_start(nd, st->rid);
@@ -7661,6 +7788,8 @@ BUILDIN_FUNC(announce)
if(flag&0x0f){
struct block_list *bl=(flag&0x08)? map_id2bl(st->oid) :
(struct block_list *)script_rid2sd(st);
+ if( bl == NULL )
+ return 0;
if (color)
clif_announce(bl,str,(int)strlen(str)+1, strtol(color, (char **)NULL, 0),flag);
else
@@ -8124,8 +8253,12 @@ BUILDIN_FUNC(catchpet)
{
int pet_id;
TBL_PC *sd;
+
pet_id= script_getnum(st,2);
sd=script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
pet_catch_process1(sd,pet_id);
return 0;
}
@@ -8136,7 +8269,11 @@ BUILDIN_FUNC(catchpet)
BUILDIN_FUNC(homunculus_evolution)
{
TBL_PC *sd;
+
sd=script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
if(merc_is_hom_active(sd->hd))
{
if (sd->hd->homunculus.intimacy > 91000)
@@ -8151,7 +8288,11 @@ BUILDIN_FUNC(homunculus_evolution)
BUILDIN_FUNC(homunculus_shuffle)
{
TBL_PC *sd;
+
sd=script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
if(merc_is_hom_active(sd->hd))
merc_hom_shuffle(sd->hd);
@@ -8201,6 +8342,9 @@ BUILDIN_FUNC(birthpet)
{
TBL_PC *sd;
sd=script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
clif_sendegg(sd);
return 0;
}
@@ -8215,6 +8359,9 @@ BUILDIN_FUNC(resetlvl)
int type=script_getnum(st,2);
sd=script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
pc_resetlvl(sd,type);
return 0;
}
@@ -11482,11 +11629,18 @@ BUILDIN_FUNC(setd)
buffer = script_getstr(st, 2);
value = script_getstr(st, 3);
- if(sscanf(buffer, "%[^[][%d]", varname, &elem) < 2)
+ if(sscanf(buffer, "%99[^[][%d]", varname, &elem) < 2)
elem = 0;
- if(st->rid)
+ if( not_server_variable(*varname) )
+ {
sd = script_rid2sd(st);
+ if( sd == NULL )
+ {
+ ShowError("script:setd: no player attached for player variable '%s'\n", buffer);
+ return 0;
+ }
+ }
if(varname[strlen(varname)-1] != '$') {
setd_sub(st,sd, varname, elem, (void *)atoi(value),NULL);
@@ -12756,8 +12910,14 @@ BUILDIN_FUNC(warpportal)
BUILDIN_FUNC(openmail)
{
+ TBL_PC* sd;
+
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
#ifndef TXT_ONLY
- mail_openmail(script_rid2sd(st));
+ mail_openmail(sd);
#endif
return 0;
}