From a2da6fa26cc8c97361c6541449b28d009c3357a2 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sun, 19 Jun 2022 08:28:29 +0300 Subject: [PATCH] Cleanup skill.h See #42 --- src/skill.cc | 39 +++++++++++++++++++++++++++++++-------- src/skill.h | 30 ------------------------------ 2 files changed, 31 insertions(+), 38 deletions(-) diff --git a/src/skill.cc b/src/skill.cc index b3a73a3..1c13a4a 100644 --- a/src/skill.cc +++ b/src/skill.cc @@ -10,6 +10,7 @@ #include "game_config.h" #include "interface.h" #include "item.h" +#include "message.h" #include "object.h" #include "palette.h" #include "party_member.h" @@ -25,10 +26,32 @@ #include #include +#define SKILLS_MAX_USES_PER_DAY (3) + +#define REPAIRABLE_DAMAGE_FLAGS_LENGTH (5) +#define HEALABLE_DAMAGE_FLAGS_LENGTH (5) + +typedef struct SkillDescription { + char* name; + char* description; + char* attributes; + int frmId; + int defaultValue; + int statModifier; + int stat1; + int stat2; + int field_20; + int experience; + int field_28; +} SkillDescription; + +static void _show_skill_use_messages(Object* obj, int skill, Object* a3, int a4, int a5); +static int skillGetFreeUsageSlot(int skill); + // Damage flags which can be repaired using "Repair" skill. // // 0x4AA2F0 -const int gRepairableDamageFlags[REPAIRABLE_DAMAGE_FLAGS_LENGTH] = { +static const int gRepairableDamageFlags[REPAIRABLE_DAMAGE_FLAGS_LENGTH] = { DAM_BLIND, DAM_CRIP_ARM_LEFT, DAM_CRIP_ARM_RIGHT, @@ -39,7 +62,7 @@ const int gRepairableDamageFlags[REPAIRABLE_DAMAGE_FLAGS_LENGTH] = { // Damage flags which can be healed using "Doctor" skill. // // 0x4AA304 -const int gHealableDamageFlags[HEALABLE_DAMAGE_FLAGS_LENGTH] = { +static const int gHealableDamageFlags[HEALABLE_DAMAGE_FLAGS_LENGTH] = { DAM_BLIND, DAM_CRIP_ARM_LEFT, DAM_CRIP_ARM_RIGHT, @@ -48,7 +71,7 @@ const int gHealableDamageFlags[HEALABLE_DAMAGE_FLAGS_LENGTH] = { }; // 0x51D118 -SkillDescription gSkillDescriptions[SKILL_COUNT] = { +static SkillDescription gSkillDescriptions[SKILL_COUNT] = { { NULL, NULL, NULL, 28, 5, 4, STAT_AGILITY, STAT_INVALID, 1, 0, 0 }, { NULL, NULL, NULL, 29, 0, 2, STAT_AGILITY, STAT_INVALID, 1, 0, 0 }, { NULL, NULL, NULL, 30, 0, 2, STAT_AGILITY, STAT_INVALID, 1, 0, 0 }, @@ -81,15 +104,15 @@ int _gStealCount = 0; int _gStealSize = 0; // 0x667F98 -int _timesSkillUsed[SKILL_COUNT][SKILLS_MAX_USES_PER_DAY]; +static int _timesSkillUsed[SKILL_COUNT][SKILLS_MAX_USES_PER_DAY]; // 0x668070 -int gTaggedSkills[NUM_TAGGED_SKILLS]; +static int gTaggedSkills[NUM_TAGGED_SKILLS]; // skill.msg // // 0x668080 -MessageList gSkillsMessageList; +static MessageList gSkillsMessageList; // 0x4AA318 int skillsInit() @@ -471,7 +494,7 @@ int skillGetFrmId(int skill) } // 0x4AAC2C -void _show_skill_use_messages(Object* obj, int skill, Object* a3, int a4, int criticalChanceModifier) +static void _show_skill_use_messages(Object* obj, int skill, Object* a3, int a4, int criticalChanceModifier) { if (obj != gDude) { return; @@ -1112,7 +1135,7 @@ int skillGetGameDifficultyModifier(int skill) } // 0x4ABE44 -int skillGetFreeUsageSlot(int skill) +static int skillGetFreeUsageSlot(int skill) { for (int slot = 0; slot < SKILLS_MAX_USES_PER_DAY; slot++) { if (_timesSkillUsed[skill][slot] == 0) { diff --git a/src/skill.h b/src/skill.h index 64b1bd5..a828012 100644 --- a/src/skill.h +++ b/src/skill.h @@ -2,42 +2,14 @@ #define SKILL_H #include "db.h" -#include "message.h" #include "obj_types.h" #include "proto_types.h" #include "skill_defs.h" -#define SKILLS_MAX_USES_PER_DAY (3) - -#define REPAIRABLE_DAMAGE_FLAGS_LENGTH (5) -#define HEALABLE_DAMAGE_FLAGS_LENGTH (5) - -typedef struct SkillDescription { - char* name; - char* description; - char* attributes; - int frmId; - int defaultValue; - int statModifier; - int stat1; - int stat2; - int field_20; - int experience; - int field_28; -} SkillDescription; - -extern const int gRepairableDamageFlags[REPAIRABLE_DAMAGE_FLAGS_LENGTH]; -extern const int gHealableDamageFlags[HEALABLE_DAMAGE_FLAGS_LENGTH]; - -extern SkillDescription gSkillDescriptions[SKILL_COUNT]; extern int _gIsSteal; extern int _gStealCount; extern int _gStealSize; -extern int _timesSkillUsed[SKILL_COUNT][SKILLS_MAX_USES_PER_DAY]; -extern int gTaggedSkills[NUM_TAGGED_SKILLS]; -extern MessageList gSkillsMessageList; - int skillsInit(); void skillsReset(); void skillsExit(); @@ -60,11 +32,9 @@ char* skillGetName(int skill); char* skillGetDescription(int skill); char* skillGetAttributes(int skill); int skillGetFrmId(int skill); -void _show_skill_use_messages(Object* obj, int skill, Object* a3, int a4, int a5); int skillUse(Object* obj, Object* a2, int skill, int a4); int skillsPerformStealing(Object* a1, Object* a2, Object* item, bool isPlanting); int skillGetGameDifficultyModifier(int skill); -int skillGetFreeUsageSlot(int skill); int skillUpdateLastUse(int skill); int skillsUsageSave(File* stream); int skillsUsageLoad(File* stream);