Skip to content

Commit 7eb109d

Browse files
committed
Change return value from 0 into -1 when *getunitdata return error
1 parent d496d89 commit 7eb109d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

doc/script_commands.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10159,7 +10159,7 @@ Applicable Data types (available as constants) -
1015910159
UDT_LIFETIME: LifeTime (int) - for summons.
1016010160
UDT_MERC_KILLCOUNT: Kill count for mercenaries (int).
1016110161

10162-
returns 0 if value could not be retrieved.
10162+
returns -1 if value could not be retrieved.
1016310163

1016410164
---------------------------------------
1016510165

src/map/script.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19767,7 +19767,7 @@ static BUILDIN(getunitdata)
1976719767

1976819768
if (bl == NULL) {
1976919769
ShowWarning("buildin_getunitdata: Error in finding object with given GID %d!\n", script_getnum(st, 2));
19770-
script_pushint(st, 0);
19770+
script_pushint(st, -1);
1977119771
return false;
1977219772
}
1977319773

@@ -19776,15 +19776,15 @@ static BUILDIN(getunitdata)
1977619776
/* Type check */
1977719777
if (type < UDT_TYPE || type >= UDT_MAX) {
1977819778
ShowError("buildin_getunitdata: Invalid unit data type %d provided.\n", type);
19779-
script_pushint(st, 0);
19779+
script_pushint(st, -1);
1978019780
return false;
1978119781
}
1978219782

1978319783
/* Argument checks */
1978419784
if (type == UDT_MAPIDXY) {
1978519785
if (data == NULL || !data_isreference(data)) {
1978619786
ShowWarning("buildin_getunitdata: Error in argument 3. Please provide a reference variable to store values in.\n");
19787-
script_pushint(st, 0);
19787+
script_pushint(st, -1);
1978819788
return false;
1978919789
}
1979019790

@@ -19794,7 +19794,7 @@ static BUILDIN(getunitdata)
1979419794
sd = script->rid2sd(st);
1979519795
if (sd == NULL) {
1979619796
ShowWarning("buildin_getunitdata: Player not attached! Cannot use player variable %s.\n",name);
19797-
script_pushint(st, 0);
19797+
script_pushint(st, -1);
1979819798
return true;// no player attached
1979919799
}
1980019800
}
@@ -19864,7 +19864,7 @@ static BUILDIN(getunitdata)
1986419864
case UDT_DMOTION: script_pushint(st, md->status.dmotion); break;
1986519865
default:
1986619866
ShowWarning("buildin_getunitdata: Invalid data type '%s' for Mob unit.\n", udtype);
19867-
script_pushint(st, 0);
19867+
script_pushint(st, -1);
1986819868
return false;
1986919869
}
1987019870
}
@@ -19921,7 +19921,7 @@ static BUILDIN(getunitdata)
1992119921
case UDT_INTIMACY: script_pushint(st, hd->homunculus.intimacy); break;
1992219922
default:
1992319923
ShowWarning("buildin_getunitdata: Invalid data type '%s' for Homunculus unit.\n", udtype);
19924-
script_pushint(st, 0);
19924+
script_pushint(st, -1);
1992519925
return false;
1992619926
}
1992719927
}
@@ -19978,7 +19978,7 @@ static BUILDIN(getunitdata)
1997819978
case UDT_INTIMACY: script_pushint(st, pd->pet.intimate); break;
1997919979
default:
1998019980
ShowWarning("buildin_getunitdata: Invalid data type '%s' for Pet unit.\n", udtype);
19981-
script_pushint(st, 0);
19981+
script_pushint(st, -1);
1998219982
return false;
1998319983
}
1998419984
}
@@ -20034,7 +20034,7 @@ static BUILDIN(getunitdata)
2003420034
case UDT_LIFETIME: script_pushint(st, mc->mercenary.life_time); break;
2003520035
default:
2003620036
ShowWarning("buildin_getunitdata: Invalid data type '%s' for Mercenary unit.\n", udtype);
20037-
script_pushint(st, 0);
20037+
script_pushint(st, -1);
2003820038
return false;
2003920039
}
2004020040
}
@@ -20088,7 +20088,7 @@ static BUILDIN(getunitdata)
2008820088
case UDT_MASTERCID: script_pushint(st, ed->elemental.char_id); break;
2008920089
default:
2009020090
ShowWarning("buildin_getunitdata: Invalid data type '%s' for Elemental unit.\n", udtype);
20091-
script_pushint(st, 0);
20091+
script_pushint(st, -1);
2009220092
return false;
2009320093
}
2009420094
}
@@ -20153,14 +20153,14 @@ static BUILDIN(getunitdata)
2015320153
case UDT_BODY2: script_pushint(st, nd->vd.body_style); break;
2015420154
default:
2015520155
ShowWarning("buildin_getunitdata: Invalid data type '%s' for NPC unit.\n", udtype);
20156-
script_pushint(st, 0);
20156+
script_pushint(st, -1);
2015720157
return false;
2015820158
}
2015920159
}
2016020160
break;
2016120161
default:
2016220162
ShowError("buildin_getunitdata: Unknown object!\n");
20163-
script_pushint(st, 0);
20163+
script_pushint(st, -1);
2016420164
return false;
2016520165
} // end of bl->type switch
2016620166

0 commit comments

Comments
 (0)