Skip to content

Commit 563485a

Browse files
committed
Fix map-crash when floating npc use *npcspeed()
- script command *npcspeed() are not applicable for floating npc (without coordinate/location).
1 parent ab81d40 commit 563485a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/map/script.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15910,20 +15910,22 @@ static BUILDIN(npctalk)
1591015910
// change npc walkspeed [Valaris]
1591115911
static BUILDIN(npcspeed)
1591215912
{
15913-
struct npc_data* nd;
15914-
int speed;
15915-
15916-
speed = script_getnum(st,2);
15917-
nd = map->id2nd(st->oid);
15913+
struct npc_data *nd = map->id2nd(st->oid);
15914+
int speed = script_getnum(st, 2);
1591815915

1591915916
if (nd != NULL) {
1592015917
unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit
15918+
if (nd->ud == NULL) {
15919+
ShowWarning("buildin_npcspeed: floating NPC don't have unit data.\n");
15920+
return false;
15921+
}
1592115922
nd->speed = speed;
1592215923
nd->ud->state.speed_changed = 1;
1592315924
}
1592415925

1592515926
return true;
1592615927
}
15928+
1592715929
// make an npc walk to a position [Valaris]
1592815930
static BUILDIN(npcwalkto)
1592915931
{

0 commit comments

Comments
 (0)