From 13a7b5e743e96ec1a7042c457fbb51cd44dda5c3 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 18 Jun 2022 18:37:23 +0300 Subject: [PATCH] Cleanup perk.h See #42 --- src/perk.cc | 39 ++++++++++++++++++++++++++++++++------- src/perk.h | 31 ------------------------------- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src/perk.cc b/src/perk.cc index 57414a1..b45a8b7 100644 --- a/src/perk.cc +++ b/src/perk.cc @@ -4,6 +4,7 @@ #include "game.h" #include "game_config.h" #include "memory.h" +#include "message.h" #include "object.h" #include "party_member.h" #include "platform_compat.h" @@ -12,8 +13,32 @@ #include +typedef struct PerkDescription { + char* name; + char* description; + int frmId; + int maxRank; + int minLevel; + int stat; + int statModifier; + int param1; + int value1; + int field_24; + int param2; + int value2; + int stats[PRIMARY_STAT_COUNT]; +} PerkDescription; + +typedef struct PerkRankData { + int ranks[PERK_COUNT]; +} PerkRankData; + +static PerkRankData* perkGetRankData(Object* critter); +static bool perkCanAdd(Object* critter, int perk); +static void perkResetRanks(); + // 0x519DCC -PerkDescription gPerkDescriptions[PERK_COUNT] = { +static PerkDescription gPerkDescriptions[PERK_COUNT] = { { NULL, NULL, 72, 1, 3, -1, 0, -1, 0, 0, -1, 0, 0, 5, 0, 0, 0, 0, 0 }, { NULL, NULL, 73, 1, 15, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 6, 0 }, { NULL, NULL, 74, 3, 3, 11, 2, -1, 0, 0, -1, 0, 6, 0, 0, 0, 0, 6, 0 }, @@ -138,18 +163,18 @@ PerkDescription gPerkDescriptions[PERK_COUNT] = { // An array of perk ranks for each party member. // // 0x51C120 -PerkRankData* gPartyMemberPerkRanks = NULL; +static PerkRankData* gPartyMemberPerkRanks = NULL; // Amount of experience points granted when player selected "Here and now" // perk. // // 0x51C124 -int gHereAndNowBonusExperience = 0; +static int gHereAndNowBonusExperience = 0; // perk.msg // // 0x6642D4 -MessageList gPerksMessageList; +static MessageList gPerksMessageList; // 0x4965A0 int perksInit() @@ -238,7 +263,7 @@ int perksSave(File* stream) // perkGetLevelData // 0x49678C -PerkRankData* perkGetRankData(Object* critter) +static PerkRankData* perkGetRankData(Object* critter) { if (critter == gDude) { return gPartyMemberPerkRanks; @@ -256,7 +281,7 @@ PerkRankData* perkGetRankData(Object* critter) } // 0x49680C -bool perkCanAdd(Object* critter, int perk) +static bool perkCanAdd(Object* critter, int perk) { if (!perkIsValid(perk)) { return false; @@ -377,7 +402,7 @@ bool perkCanAdd(Object* critter, int perk) // Resets party member perks. // // 0x496A0C -void perkResetRanks() +static void perkResetRanks() { for (int index = 0; index < gPartyMemberDescriptionsLength; index++) { PerkRankData* ranksData = &(gPartyMemberPerkRanks[index]); diff --git a/src/perk.h b/src/perk.h index 55fb641..2c1dbac 100644 --- a/src/perk.h +++ b/src/perk.h @@ -2,45 +2,14 @@ #define PERK_H #include "db.h" -#include "message.h" #include "obj_types.h" #include "perk_defs.h" -#include "stat_defs.h" - -typedef struct PerkDescription { - char* name; - char* description; - int frmId; - int maxRank; - int minLevel; - int stat; - int statModifier; - int param1; - int value1; - int field_24; - int param2; - int value2; - int stats[PRIMARY_STAT_COUNT]; -} PerkDescription; - -typedef struct PerkRankData { - int ranks[PERK_COUNT]; -} PerkRankData; - -extern PerkDescription gPerkDescriptions[PERK_COUNT]; -extern PerkRankData* gPartyMemberPerkRanks; -extern int gHereAndNowBonusExperience; - -extern MessageList gPerksMessageList; int perksInit(); void perksReset(); void perksExit(); int perksLoad(File* stream); int perksSave(File* stream); -PerkRankData* perkGetRankData(Object* critter); -bool perkCanAdd(Object* critter, int perk); -void perkResetRanks(); int perkAdd(Object* critter, int perk); int perkAddForce(Object* critter, int perk); int perkRemove(Object* critter, int perk);