From 428b4baa7bf198407918899843f8ca31badd78dc Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 18 Jun 2022 18:33:10 +0300 Subject: [PATCH] Cleanup party_member.h See #42 --- src/party_member.cc | 81 ++++++++++++++++++++++++++++++++++----------- src/party_member.h | 49 --------------------------- 2 files changed, 61 insertions(+), 69 deletions(-) diff --git a/src/party_member.cc b/src/party_member.cc index 532b414..100c785 100644 --- a/src/party_member.cc +++ b/src/party_member.cc @@ -1,6 +1,7 @@ #include "party_member.h" #include "combat_ai.h" +#include "combat_ai_defs.h" #include "animation.h" #include "color.h" #include "config.h" @@ -30,6 +31,46 @@ #include #include +typedef struct PartyMemberDescription { + bool areaAttackMode[AREA_ATTACK_MODE_COUNT]; + bool runAwayMode[RUN_AWAY_MODE_COUNT]; + bool bestWeapon[BEST_WEAPON_COUNT]; + bool distanceMode[DISTANCE_COUNT]; + bool attackWho[ATTACK_WHO_COUNT]; + bool chemUse[CHEM_USE_COUNT]; + bool disposition[DISPOSITION_COUNT]; + int level_minimum; + int level_up_every; + int level_pids_num; + int level_pids[5]; +} PartyMemberDescription; + +typedef struct STRU_519DBC { + int field_0; + int field_4; // party member level + int field_8; // early what? +} STRU_519DBC; + +typedef struct STRUCT_519DA8 { + Object* object; + Script* script; + int* vars; + struct STRUCT_519DA8* next; +} STRUCT_519DA8; + +static int partyMemberGetDescription(Object* object, PartyMemberDescription** partyMemberDescriptionPtr); +static void partyMemberDescriptionInit(PartyMemberDescription* partyMemberDescription); +static int _partyMemberPrepLoadInstance(STRUCT_519DA8* a1); +static int _partyMemberRecoverLoadInstance(STRUCT_519DA8* a1); +static int _partyMemberNewObjID(); +static int _partyMemberNewObjIDRecurseFind(Object* object, int objectId); +static int _partyMemberPrepItemSave(Object* object); +static int _partyMemberItemSave(Object* object); +static int _partyMemberItemRecover(STRUCT_519DA8* a1); +static int _partyMemberClearItemList(); +static int _partyFixMultipleMembers(); +static int _partyMemberCopyLevelInfo(Object* object, int a2); + // 0x519D9C int gPartyMemberDescriptionsLength = 0; @@ -37,32 +78,32 @@ int gPartyMemberDescriptionsLength = 0; int* gPartyMemberPids = NULL; // -STRUCT_519DA8* _itemSaveListHead = NULL; +static STRUCT_519DA8* _itemSaveListHead = NULL; // List of party members, it's length is [gPartyMemberDescriptionsLength] + 20. // // 0x519DA8 -STRUCT_519DA8* gPartyMembers = NULL; +static STRUCT_519DA8* gPartyMembers = NULL; // Number of critters added to party. // // 0x519DAC -int gPartyMembersLength = 0; +static int gPartyMembersLength = 0; // 0x519DB0 -int _partyMemberItemCount = 20000; +static int _partyMemberItemCount = 20000; // 0x519DB4 -int _partyStatePrepped = 0; +static int _partyStatePrepped = 0; // 0x519DB8 -PartyMemberDescription* gPartyMemberDescriptions = NULL; +static PartyMemberDescription* gPartyMemberDescriptions = NULL; // 0x519DBC -STRU_519DBC* _partyMemberLevelUpInfoList = NULL; +static STRU_519DBC* _partyMemberLevelUpInfoList = NULL; // 0x519DC0 -int _curID = 20000; +static int _curID = 20000; // partyMember_init // 0x493BC0 @@ -260,7 +301,7 @@ void partyMembersExit() } // 0x4941F0 -int partyMemberGetDescription(Object* object, PartyMemberDescription** partyMemberDescriptionPtr) +static int partyMemberGetDescription(Object* object, PartyMemberDescription** partyMemberDescriptionPtr) { for (int index = 1; index < gPartyMemberDescriptionsLength; index++) { if (gPartyMemberPids[index] == object->pid) { @@ -273,7 +314,7 @@ int partyMemberGetDescription(Object* object, PartyMemberDescription** partyMemb } // 0x49425C -void partyMemberDescriptionInit(PartyMemberDescription* partyMemberDescription) +static void partyMemberDescriptionInit(PartyMemberDescription* partyMemberDescription) { for (int index = 0; index < AREA_ATTACK_MODE_COUNT; index++) { partyMemberDescription->areaAttackMode[index] = 0; @@ -504,7 +545,7 @@ int _partyMemberPrepLoad() // partyMemberPrepLoadInstance // 0x49480C -int _partyMemberPrepLoadInstance(STRUCT_519DA8* a1) +static int _partyMemberPrepLoadInstance(STRUCT_519DA8* a1) { Object* obj = a1->object; @@ -610,7 +651,7 @@ int _partyMemberRecoverLoad() // partyMemberRecoverLoadInstance // 0x494A88 -int _partyMemberRecoverLoadInstance(STRUCT_519DA8* a1) +static int _partyMemberRecoverLoadInstance(STRUCT_519DA8* a1) { if (a1->script == NULL) { showMesageBox("\n Error!: partyMemberRecoverLoadInstance: No script!"); @@ -859,7 +900,7 @@ int _getPartyMemberCount() } // 0x495070 -int _partyMemberNewObjID() +static int _partyMemberNewObjID() { Object* object; @@ -901,7 +942,7 @@ int _partyMemberNewObjID() } // 0x4950F4 -int _partyMemberNewObjIDRecurseFind(Object* obj, int objectId) +static int _partyMemberNewObjIDRecurseFind(Object* obj, int objectId) { Inventory* inventory = &(obj->data.inventory); for (int index = 0; index < inventory->length; index++) { @@ -935,7 +976,7 @@ int _partyMemberPrepItemSaveAll() } // partyMemberPrepItemSaveAll -int _partyMemberPrepItemSave(Object* object) +static int _partyMemberPrepItemSave(Object* object) { if (object->sid != -1) { Script* script; @@ -957,7 +998,7 @@ int _partyMemberPrepItemSave(Object* object) } // 0x495234 -int _partyMemberItemSave(Object* object) +static int _partyMemberItemSave(Object* object) { if (object->sid != -1) { Script* script; @@ -1015,7 +1056,7 @@ int _partyMemberItemSave(Object* object) // partyMemberItemRecover // 0x495388 -int _partyMemberItemRecover(STRUCT_519DA8* a1) +static int _partyMemberItemRecover(STRUCT_519DA8* a1) { int sid = -1; if (scriptAdd(&sid, SCRIPT_TYPE_ITEM) == -1) { @@ -1051,7 +1092,7 @@ int _partyMemberItemRecover(STRUCT_519DA8* a1) } // 0x4954C4 -int _partyMemberClearItemList() +static int _partyMemberClearItemList() { while (_itemSaveListHead != NULL) { STRUCT_519DA8* node = _itemSaveListHead; @@ -1143,7 +1184,7 @@ int partyGetBestSkillValue(int skill) } // 0x495620 -int _partyFixMultipleMembers() +static int _partyFixMultipleMembers() { debugPrint("\n\n\n[Party Members]:"); @@ -1508,7 +1549,7 @@ int _partyMemberIncLevels() } // 0x495EA8 -int _partyMemberCopyLevelInfo(Object* critter, int a2) +static int _partyMemberCopyLevelInfo(Object* critter, int a2) { if (critter == NULL) { return -1; diff --git a/src/party_member.h b/src/party_member.h index f87cccf..1df09a1 100644 --- a/src/party_member.h +++ b/src/party_member.h @@ -1,63 +1,22 @@ #ifndef PARTY_MEMBER_H #define PARTY_MEMBER_H -#include "combat_ai_defs.h" #include "db.h" #include "obj_types.h" -#include "scripts.h" - -typedef struct PartyMemberDescription { - bool areaAttackMode[AREA_ATTACK_MODE_COUNT]; - bool runAwayMode[RUN_AWAY_MODE_COUNT]; - bool bestWeapon[BEST_WEAPON_COUNT]; - bool distanceMode[DISTANCE_COUNT]; - bool attackWho[ATTACK_WHO_COUNT]; - bool chemUse[CHEM_USE_COUNT]; - bool disposition[DISPOSITION_COUNT]; - int level_minimum; - int level_up_every; - int level_pids_num; - int level_pids[5]; -} PartyMemberDescription; - -typedef struct STRU_519DBC { - int field_0; - int field_4; // party member level - int field_8; // early what? -} STRU_519DBC; - -typedef struct STRUCT_519DA8 { - Object* object; - Script* script; - int* vars; - struct STRUCT_519DA8* next; -} STRUCT_519DA8; extern int gPartyMemberDescriptionsLength; extern int* gPartyMemberPids; -extern STRUCT_519DA8* _itemSaveListHead; -extern STRUCT_519DA8* gPartyMembers; -extern int gPartyMembersLength; -extern int _partyMemberItemCount; -extern int _partyStatePrepped; -extern PartyMemberDescription* gPartyMemberDescriptions; -extern STRU_519DBC* _partyMemberLevelUpInfoList; -extern int _curID; int partyMembersInit(); void partyMembersReset(); void partyMembersExit(); -int partyMemberGetDescription(Object* object, PartyMemberDescription** partyMemberDescriptionPtr); -void partyMemberDescriptionInit(PartyMemberDescription* partyMemberDescription); int partyMemberAdd(Object* object); int partyMemberRemove(Object* object); int _partyMemberPrepSave(); int _partyMemberUnPrepSave(); int partyMembersSave(File* stream); int _partyMemberPrepLoad(); -int _partyMemberPrepLoadInstance(STRUCT_519DA8* a1); int _partyMemberRecoverLoad(); -int _partyMemberRecoverLoadInstance(STRUCT_519DA8* a1); int partyMembersLoad(File* stream); void _partyMemberClear(); int _partyMemberSyncPosition(); @@ -66,17 +25,10 @@ Object* partyMemberFindByPid(int a1); bool _isPotentialPartyMember(Object* object); bool objectIsPartyMember(Object* object); int _getPartyMemberCount(); -int _partyMemberNewObjID(); -int _partyMemberNewObjIDRecurseFind(Object* object, int objectId); int _partyMemberPrepItemSaveAll(); -int _partyMemberPrepItemSave(Object* object); -int _partyMemberItemSave(Object* object); -int _partyMemberItemRecover(STRUCT_519DA8* a1); -int _partyMemberClearItemList(); int partyMemberGetBestSkill(Object* object); Object* partyMemberGetBestInSkill(int skill); int partyGetBestSkillValue(int skill); -int _partyFixMultipleMembers(); void _partyMemberSaveProtos(); bool partyMemberSupportsDisposition(Object* object, int disposition); bool partyMemberSupportsAreaAttackMode(Object* object, int areaAttackMode); @@ -86,7 +38,6 @@ bool partyMemberSupportsDistance(Object* object, int distanceMode); bool partyMemberSupportsAttackWho(Object* object, int attackWho); bool partyMemberSupportsChemUse(Object* object, int chemUse); int _partyMemberIncLevels(); -int _partyMemberCopyLevelInfo(Object* object, int a2); bool partyIsAnyoneCanBeHealedByRest(); int partyGetMaxWoundToHealByRest();