summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIbrahim Zidan <brahem@aotsw.com>2019-04-13 22:43:02 +0200
committerIbrahim Zidan <brahem@aotsw.com>2019-05-05 23:28:10 +0200
commit5a0c9f2f74070e9d1e6f4fec503b3687b5f1ef88 (patch)
tree79868878e938aee7fc005c71fdc31c102bd67884 /src
parentcedaae8a589e87300727e27a4af58217707e2e22 (diff)
downloadhercules-5a0c9f2f74070e9d1e6f4fec503b3687b5f1ef88.tar.gz
hercules-5a0c9f2f74070e9d1e6f4fec503b3687b5f1ef88.tar.bz2
hercules-5a0c9f2f74070e9d1e6f4fec503b3687b5f1ef88.tar.xz
hercules-5a0c9f2f74070e9d1e6f4fec503b3687b5f1ef88.zip
Move refine database from refine public interface to private interface
Signed-off-by: Ibrahim Zidan <brahem@aotsw.com>
Diffstat (limited to 'src')
-rw-r--r--src/map/refine.c20
-rw-r--r--src/map/refine.h12
-rw-r--r--src/map/refine.p.h13
3 files changed, 23 insertions, 22 deletions
diff --git a/src/map/refine.c b/src/map/refine.c
index 77d069643..5d0517d7d 100644
--- a/src/map/refine.c
+++ b/src/map/refine.c
@@ -46,7 +46,7 @@ static int refine_get_randombonus_max(enum refine_type equipment_type, int refin
Assert_ret((int)equipment_type >= REFINE_TYPE_ARMOR && equipment_type < REFINE_TYPE_MAX);
Assert_ret(refine_level > 0 && refine_level <= MAX_REFINE);
- return refine->dbs->refine_info[equipment_type].randombonus_max[refine_level - 1];
+ return refine->p->dbs->refine_info[equipment_type].randombonus_max[refine_level - 1];
}
/// @copydoc refine_interface::get_bonus()
@@ -55,7 +55,7 @@ static int refine_get_bonus(enum refine_type equipment_type, int refine_level)
Assert_ret((int)equipment_type >= REFINE_TYPE_ARMOR && equipment_type < REFINE_TYPE_MAX);
Assert_ret(refine_level > 0 && refine_level <= MAX_REFINE);
- return refine->dbs->refine_info[equipment_type].bonus[refine_level - 1];
+ return refine->p->dbs->refine_info[equipment_type].bonus[refine_level - 1];
}
/// @copydoc refine_interface::get_refine_chance()
@@ -69,7 +69,7 @@ static int refine_get_refine_chance(enum refine_type wlv, int refine_level, enum
if (type >= REFINE_CHANCE_TYPE_MAX)
return 0;
- return refine->dbs->refine_info[wlv].chance[type][refine_level];
+ return refine->p->dbs->refine_info[wlv].chance[type][refine_level];
}
/// @copydoc refine_interface_private::readdb_refine_libconfig_sub()
@@ -172,13 +172,13 @@ static int refine_readdb_refine_libconfig_sub(struct config_setting_t *r, const
rnd_bonus[level] = rnd_bonus_v * (level - rnd_bonus_lv + 2);
}
for (i = 0; i < MAX_REFINE; i++) {
- refine->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_NORMAL][i] = chance[REFINE_CHANCE_TYPE_NORMAL][i];
- refine->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_E_NORMAL][i] = chance[REFINE_CHANCE_TYPE_E_NORMAL][i];
- refine->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_ENRICHED][i] = chance[REFINE_CHANCE_TYPE_ENRICHED][i];
- refine->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_E_ENRICHED][i] = chance[REFINE_CHANCE_TYPE_E_ENRICHED][i];
- refine->dbs->refine_info[type].randombonus_max[i] = rnd_bonus[i];
+ refine->p->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_NORMAL][i] = chance[REFINE_CHANCE_TYPE_NORMAL][i];
+ refine->p->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_E_NORMAL][i] = chance[REFINE_CHANCE_TYPE_E_NORMAL][i];
+ refine->p->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_ENRICHED][i] = chance[REFINE_CHANCE_TYPE_ENRICHED][i];
+ refine->p->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_E_ENRICHED][i] = chance[REFINE_CHANCE_TYPE_E_ENRICHED][i];
+ refine->p->dbs->refine_info[type].randombonus_max[i] = rnd_bonus[i];
bonus[i] += bonus_per_level + (i > 0 ? bonus[i - 1] : 0);
- refine->dbs->refine_info[type].bonus[i] = bonus[i];
+ refine->p->dbs->refine_info[type].bonus[i] = bonus[i];
}
} else {
ShowWarning("status_readdb_refine_libconfig_sub: Missing refine rates for entry '%s' in \"%s\", skipping.\n", name, source);
@@ -240,11 +240,11 @@ void refine_defaults(void)
{
refine = &refine_s;
refine->p = &refine_p;
+ refine->p->dbs = &refine_dbs;
refine->p->readdb_refine_libconfig = refine_readdb_refine_libconfig;
refine->p->readdb_refine_libconfig_sub = refine_readdb_refine_libconfig_sub;
- refine->dbs = &refine_dbs;
refine->init = refine_init;
refine->final = refine_final;
refine->get_refine_chance = refine_get_refine_chance;
diff --git a/src/map/refine.h b/src/map/refine.h
index 05ab0f076..850f6143a 100644
--- a/src/map/refine.h
+++ b/src/map/refine.h
@@ -60,23 +60,11 @@ enum refine_chance_type {
REFINE_CHANCE_TYPE_MAX
};
-/* Structures */
-struct s_refine_info {
- int chance[REFINE_CHANCE_TYPE_MAX][MAX_REFINE]; // success chance
- int bonus[MAX_REFINE]; // cumulative fixed bonus damage
- int randombonus_max[MAX_REFINE]; // cumulative maximum random bonus damage
-};
-
-struct refine_interface_dbs {
- struct s_refine_info refine_info[REFINE_TYPE_MAX];
-};
-
/**
* Refine Interface
**/
struct refine_interface {
struct refine_interface_private *p;
- struct refine_interface_dbs *dbs;
/**
* Initialize refine system
diff --git a/src/map/refine.p.h b/src/map/refine.p.h
index 4d6f403bb..d47944315 100644
--- a/src/map/refine.p.h
+++ b/src/map/refine.p.h
@@ -28,10 +28,23 @@
#include "refine.h"
#include "common/conf.h"
+/* Structures */
+struct s_refine_info {
+ int chance[REFINE_CHANCE_TYPE_MAX][MAX_REFINE]; // success chance
+ int bonus[MAX_REFINE]; // cumulative fixed bonus damage
+ int randombonus_max[MAX_REFINE]; // cumulative maximum random bonus damage
+};
+
+struct refine_interface_dbs {
+ struct s_refine_info refine_info[REFINE_TYPE_MAX];
+};
+
/**
* Refine Private Interface
**/
struct refine_interface_private {
+ struct refine_interface_dbs *dbs;
+
/**
* Processes a refine_db.conf entry.
*