Delete critter from combat during _partyFixMultipleMembers (#277)
Co-authored-by: Alexander Batalov <alex.batalov@gmail.com>
This commit is contained in:
parent
53a4437be9
commit
70b0b61664
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "animation.h"
|
#include "animation.h"
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
|
#include "combat.h"
|
||||||
#include "combat_ai.h"
|
#include "combat_ai.h"
|
||||||
#include "combat_ai_defs.h"
|
#include "combat_ai_defs.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -80,7 +81,7 @@ static int _partyMemberPrepItemSave(Object* object);
|
||||||
static int _partyMemberItemSave(Object* object);
|
static int _partyMemberItemSave(Object* object);
|
||||||
static int _partyMemberItemRecover(STRUCT_519DA8* a1);
|
static int _partyMemberItemRecover(STRUCT_519DA8* a1);
|
||||||
static int _partyMemberClearItemList();
|
static int _partyMemberClearItemList();
|
||||||
static int _partyFixMultipleMembers();
|
static int partyFixMultipleMembers();
|
||||||
static int _partyMemberCopyLevelInfo(Object* object, int a2);
|
static int _partyMemberCopyLevelInfo(Object* object, int a2);
|
||||||
|
|
||||||
// 0x519D9C
|
// 0x519D9C
|
||||||
|
@ -655,7 +656,7 @@ int _partyMemberRecoverLoad()
|
||||||
_partyStatePrepped = 0;
|
_partyStatePrepped = 0;
|
||||||
|
|
||||||
if (!_isLoadingGame()) {
|
if (!_isLoadingGame()) {
|
||||||
_partyFixMultipleMembers();
|
partyFixMultipleMembers();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -759,7 +760,7 @@ int partyMembersLoad(File* stream)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_partyFixMultipleMembers();
|
partyFixMultipleMembers();
|
||||||
|
|
||||||
for (int index = 1; index < gPartyMemberDescriptionsLength; index++) {
|
for (int index = 1; index < gPartyMemberDescriptionsLength; index++) {
|
||||||
STRU_519DBC* ptr_519DBC = &(_partyMemberLevelUpInfoList[index]);
|
STRU_519DBC* ptr_519DBC = &(_partyMemberLevelUpInfoList[index]);
|
||||||
|
@ -1196,16 +1197,14 @@ int partyGetBestSkillValue(int skill)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x495620
|
// 0x495620
|
||||||
static int _partyFixMultipleMembers()
|
static int partyFixMultipleMembers()
|
||||||
{
|
{
|
||||||
debugPrint("\n\n\n[Party Members]:");
|
debugPrint("\n\n\n[Party Members]:");
|
||||||
|
|
||||||
|
// NOTE: Original code is slightly different (uses two nested loops).
|
||||||
int critterCount = 0;
|
int critterCount = 0;
|
||||||
for (Object* obj = objectFindFirst(); obj != NULL; obj = objectFindNext()) {
|
Object* obj = objectFindFirst();
|
||||||
if (PID_TYPE(obj->pid) == OBJ_TYPE_CRITTER) {
|
while (obj != NULL) {
|
||||||
critterCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isPartyMember = false;
|
bool isPartyMember = false;
|
||||||
for (int index = 1; index < gPartyMemberDescriptionsLength; index++) {
|
for (int index = 1; index < gPartyMemberDescriptionsLength; index++) {
|
||||||
if (obj->pid == gPartyMemberPids[index]) {
|
if (obj->pid == gPartyMemberPids[index]) {
|
||||||
|
@ -1214,49 +1213,26 @@ static int _partyFixMultipleMembers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isPartyMember) {
|
if (isPartyMember) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
debugPrint("\n PM: %s", critterGetName(obj));
|
debugPrint("\n PM: %s", critterGetName(obj));
|
||||||
|
|
||||||
bool v19 = false;
|
bool remove = false;
|
||||||
if (obj->sid == -1) {
|
if (obj->sid == -1) {
|
||||||
v19 = true;
|
remove = true;
|
||||||
} else {
|
} else {
|
||||||
Object* v7 = NULL;
|
// NOTE: Uninline.
|
||||||
for (int i = 0; i < gPartyMembersLength; i++) {
|
Object* partyMember = partyMemberFindByPid(obj->pid);
|
||||||
if (obj->pid == gPartyMembers[i].object->pid) {
|
if (partyMember != NULL && partyMember != obj) {
|
||||||
v7 = gPartyMembers[i].object;
|
if (partyMember->sid == obj->sid) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v7 != NULL && obj != v7) {
|
|
||||||
if (v7->sid == obj->sid) {
|
|
||||||
obj->sid = -1;
|
obj->sid = -1;
|
||||||
}
|
}
|
||||||
v19 = true;
|
remove = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!v19) {
|
if (remove) {
|
||||||
continue;
|
// NOTE: Uninline.
|
||||||
}
|
if (obj != partyMemberFindByPid(obj->pid)) {
|
||||||
|
|
||||||
Object* v10 = NULL;
|
|
||||||
for (int i = 0; i < gPartyMembersLength; i++) {
|
|
||||||
if (obj->pid == gPartyMembers[i].object->pid) {
|
|
||||||
v10 = gPartyMembers[i].object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Probably wrong.
|
|
||||||
if (obj == v10) {
|
|
||||||
debugPrint("\nError: Attempting to destroy evil critter doppleganger FAILED!");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
debugPrint("\nDestroying evil critter doppleganger!");
|
debugPrint("\nDestroying evil critter doppleganger!");
|
||||||
|
|
||||||
if (obj->sid != -1) {
|
if (obj->sid != -1) {
|
||||||
|
@ -1268,7 +1244,21 @@ static int _partyFixMultipleMembers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_combat_delete_critter(obj);
|
||||||
|
|
||||||
objectDestroy(obj, NULL);
|
objectDestroy(obj, NULL);
|
||||||
|
|
||||||
|
// Start over.
|
||||||
|
critterCount = 0;
|
||||||
|
obj = objectFindFirst();
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
debugPrint("\nError: Attempting to destroy evil critter doppleganger FAILED!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
obj = objectFindNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int index = 0; index < gPartyMembersLength; index++) {
|
for (int index = 0; index < gPartyMembersLength; index++) {
|
||||||
|
|
Loading…
Reference in New Issue