Fixed a bug in (init/start/stop)npctimer

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12619 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
toms 2008-04-19 15:37:18 +00:00
parent ba5c9df29d
commit 443c56e21f
2 changed files with 47 additions and 28 deletions

View File

@ -3,6 +3,8 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2008/04/19
* Fixed a bug in (init/start/stop)npctimer [Toms]
2008/04/18 2008/04/18
* Fixed a bug when unloading a npc near a shop. * Fixed a bug when unloading a npc near a shop.
* Fixed npc_buylist not giving/checking the good item when it was an * Fixed npc_buylist not giving/checking the good item when it was an

View File

@ -7605,26 +7605,32 @@ BUILDIN_FUNC(initnpctimer)
{ //Two arguments: NPC name and attach flag. { //Two arguments: NPC name and attach flag.
nd = npc_name2id(script_getstr(st, 2)); nd = npc_name2id(script_getstr(st, 2));
flag = script_getnum(st,3); flag = script_getnum(st,3);
} else }
if( script_hasdata(st,2) ) else if( script_hasdata(st,2) )
{ //Check if argument is numeric (flag) or string (npc name) { //Check if argument is numeric (flag) or string (npc name)
struct script_data *data; struct script_data *data;
data = script_getdata(st,2); data = script_getdata(st,2);
get_val(st,data); get_val(st,data);
if( data_isstring(data) ) //NPC name if( data_isstring(data) ) //NPC name
nd = npc_name2id(script_getstr(st, 2)); nd = npc_name2id(conv_str(st, data));
else if( data_isint(data) ) { //Flag else if( data_isint(data) ) //Flag
{
nd = (struct npc_data *)map_id2bl(st->oid); nd = (struct npc_data *)map_id2bl(st->oid);
flag = script_getnum(st,3); flag = conv_num(st,data);
} else { }
else
{
ShowError("initnpctimer: invalid argument type #1 (needs be int or string)).\n"); ShowError("initnpctimer: invalid argument type #1 (needs be int or string)).\n");
return 1; return 1;
} }
} else }
else
nd=(struct npc_data *)map_id2bl(st->oid); nd=(struct npc_data *)map_id2bl(st->oid);
if (!nd) return 0; if (!nd)
if (flag) { //Attach return 0;
if (flag) //Attach
{
TBL_PC* sd = script_rid2sd(st); TBL_PC* sd = script_rid2sd(st);
if( sd == NULL ) if( sd == NULL )
return 0; return 0;
@ -7646,26 +7652,32 @@ BUILDIN_FUNC(startnpctimer)
{ //Two arguments: NPC name and attach flag. { //Two arguments: NPC name and attach flag.
nd = npc_name2id(script_getstr(st, 2)); nd = npc_name2id(script_getstr(st, 2));
flag = script_getnum(st,3); flag = script_getnum(st,3);
} else }
if( script_hasdata(st,2) ) else if( script_hasdata(st,2) )
{ //Check if argument is numeric (flag) or string (npc name) { //Check if argument is numeric (flag) or string (npc name)
struct script_data *data; struct script_data *data;
data = script_getdata(st,2); data = script_getdata(st,2);
get_val(st,data); get_val(st,data);
if( data_isstring(data) ) //NPC name if( data_isstring(data) ) //NPC name
nd = npc_name2id(script_getstr(st, 2)); nd = npc_name2id(conv_str(st, data));
else if( data_isint(data) ) { //Flag else if( data_isint(data) ) //Flag
{
nd = (struct npc_data *)map_id2bl(st->oid); nd = (struct npc_data *)map_id2bl(st->oid);
flag = script_getnum(st,3); flag = conv_num(st,data);
} else { }
ShowError("startnpctimer: invalid argument type #1 (needs be int or string)).\n"); else
{
ShowError("initnpctimer: invalid argument type #1 (needs be int or string)).\n");
return 1; return 1;
} }
} else }
else
nd=(struct npc_data *)map_id2bl(st->oid); nd=(struct npc_data *)map_id2bl(st->oid);
if (!nd) return 0; if (!nd)
if (flag) { //Attach return 0;
if (flag) //Attach
{
TBL_PC* sd = script_rid2sd(st); TBL_PC* sd = script_rid2sd(st);
if( sd == NULL ) if( sd == NULL )
return 0; return 0;
@ -7686,25 +7698,30 @@ BUILDIN_FUNC(stopnpctimer)
{ //Two arguments: NPC name and attach flag. { //Two arguments: NPC name and attach flag.
nd = npc_name2id(script_getstr(st, 2)); nd = npc_name2id(script_getstr(st, 2));
flag = script_getnum(st,3); flag = script_getnum(st,3);
} else }
if( script_hasdata(st,2) ) else if( script_hasdata(st,2) )
{ //Check if argument is numeric (flag) or string (npc name) { //Check if argument is numeric (flag) or string (npc name)
struct script_data *data; struct script_data *data;
data = script_getdata(st,2); data = script_getdata(st,2);
get_val(st,data); get_val(st,data);
if( data_isstring(data) ) //NPC name if( data_isstring(data) ) //NPC name
nd = npc_name2id(script_getstr(st, 2)); nd = npc_name2id(conv_str(st, data));
else if( data_isint(data) ) { //Flag else if( data_isint(data) ) //Flag
{
nd = (struct npc_data *)map_id2bl(st->oid); nd = (struct npc_data *)map_id2bl(st->oid);
flag = script_getnum(st,3); flag = conv_num(st,data);
} else { }
ShowError("stopnpctimer: invalid argument type #1 (needs be int or string)).\n"); else
{
ShowError("initnpctimer: invalid argument type #1 (needs be int or string)).\n");
return 1; return 1;
} }
} else }
else
nd=(struct npc_data *)map_id2bl(st->oid); nd=(struct npc_data *)map_id2bl(st->oid);
if (!nd) return 0; if (!nd)
return 0;
if (flag) //Detach if (flag) //Detach
nd->u.scr.rid = 0; nd->u.scr.rid = 0;