Fix object search when loading game in combat mode
This commit is contained in:
parent
5a47f74023
commit
52af5cfc1f
|
@ -2171,7 +2171,9 @@ int combatLoad(File* stream)
|
||||||
if (a2 == -1) {
|
if (a2 == -1) {
|
||||||
aiInfo->friendlyDead = NULL;
|
aiInfo->friendlyDead = NULL;
|
||||||
} else {
|
} else {
|
||||||
aiInfo->friendlyDead = objectFindById(a2);
|
// SFALL: Fix incorrect object type search when loading a game in
|
||||||
|
// combat mode.
|
||||||
|
aiInfo->friendlyDead = objectTypedFindById(a2, OBJ_TYPE_CRITTER);
|
||||||
if (aiInfo->friendlyDead == NULL) return -1;
|
if (aiInfo->friendlyDead == NULL) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2180,7 +2182,9 @@ int combatLoad(File* stream)
|
||||||
if (a2 == -1) {
|
if (a2 == -1) {
|
||||||
aiInfo->lastTarget = NULL;
|
aiInfo->lastTarget = NULL;
|
||||||
} else {
|
} else {
|
||||||
aiInfo->lastTarget = objectFindById(a2);
|
// SFALL: Fix incorrect object type search when loading a game in
|
||||||
|
// combat mode.
|
||||||
|
aiInfo->lastTarget = objectTypedFindById(a2, OBJ_TYPE_CRITTER);
|
||||||
if (aiInfo->lastTarget == NULL) return -1;
|
if (aiInfo->lastTarget == NULL) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2189,7 +2193,9 @@ int combatLoad(File* stream)
|
||||||
if (a2 == -1) {
|
if (a2 == -1) {
|
||||||
aiInfo->lastItem = NULL;
|
aiInfo->lastItem = NULL;
|
||||||
} else {
|
} else {
|
||||||
aiInfo->lastItem = objectFindById(a2);
|
// SFALL: Fix incorrect object type search when loading a game in
|
||||||
|
// combat mode.
|
||||||
|
aiInfo->lastItem = objectTypedFindById(a2, OBJ_TYPE_ITEM);
|
||||||
if (aiInfo->lastItem == NULL) return -1;
|
if (aiInfo->lastItem == NULL) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5222,3 +5222,16 @@ static int _obj_preload_sort(const void* a1, const void* a2)
|
||||||
cmp = ((v1 & 0xFF0000) >> 16) - (((v2 & 0xFF0000) >> 16));
|
cmp = ((v1 & 0xFF0000) >> 16) - (((v2 & 0xFF0000) >> 16));
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Object* objectTypedFindById(int id, int type)
|
||||||
|
{
|
||||||
|
Object* obj = objectFindFirst();
|
||||||
|
while (obj != NULL) {
|
||||||
|
if (obj->id == id && PID_TYPE(obj->pid) == type) {
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
obj = objectFindNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -96,4 +96,6 @@ int _obj_save_dude(File* stream);
|
||||||
int _obj_load_dude(File* stream);
|
int _obj_load_dude(File* stream);
|
||||||
void _obj_fix_violence_settings(int* fid);
|
void _obj_fix_violence_settings(int* fid);
|
||||||
|
|
||||||
|
Object* objectTypedFindById(int id, int type);
|
||||||
|
|
||||||
#endif /* OBJECT_H */
|
#endif /* OBJECT_H */
|
||||||
|
|
Loading…
Reference in New Issue