summaryrefslogtreecommitdiff
path: root/src/map/homunculus.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-06-28 03:17:32 +0200
committerHaru <haru@dotalux.com>2018-07-01 21:09:26 +0200
commita675e06c38ec4e31a2758435a582b58a2199cfc4 (patch)
treea4bf91c20da434eef97f55f7427ccbf034c5e285 /src/map/homunculus.c
parentb7e6439f0c788ceacc567fbb017d3c7f09913f78 (diff)
downloadhercules-a675e06c38ec4e31a2758435a582b58a2199cfc4.tar.gz
hercules-a675e06c38ec4e31a2758435a582b58a2199cfc4.tar.bz2
hercules-a675e06c38ec4e31a2758435a582b58a2199cfc4.tar.xz
hercules-a675e06c38ec4e31a2758435a582b58a2199cfc4.zip
Change functions to static where possible (Part 4 - map)
This fixes issues with plugins defining symbols with the same names Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/homunculus.c')
-rw-r--r--src/map/homunculus.c144
1 files changed, 94 insertions, 50 deletions
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index a708c0a28..a6e7bb71c 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -58,19 +58,21 @@
#include <stdlib.h>
#include <string.h>
-struct homunculus_interface homunculus_s;
-struct homun_dbs homundbs;
+static struct homunculus_interface homunculus_s;
+static struct homun_dbs homundbs;
struct homunculus_interface *homun;
//Returns the viewdata for homunculus
-struct view_data* homunculus_get_viewdata(int class_) {
+static struct view_data *homunculus_get_viewdata(int class_)
+{
Assert_retr(NULL, homdb_checkid(class_));
return &homun->dbs->viewdb[class_-HM_CLASS_BASE];
}
-enum homun_type homunculus_class2type(int class_) {
+static enum homun_type homunculus_class2type(int class_)
+{
switch(class_) {
// Normal Homunculus
case HOMID_LIF:
@@ -104,7 +106,8 @@ enum homun_type homunculus_class2type(int class_) {
}
}
-void homunculus_addspiritball(struct homun_data *hd, int max) {
+static void homunculus_addspiritball(struct homun_data *hd, int max)
+{
nullpo_retv(hd);
if (max > MAX_SKILL_LEVEL)
@@ -121,7 +124,8 @@ void homunculus_addspiritball(struct homun_data *hd, int max) {
clif->spiritball(&hd->bl);
}
-void homunculus_delspiritball(struct homun_data *hd, int count, int type) {
+static void homunculus_delspiritball(struct homun_data *hd, int count, int type)
+{
nullpo_retv(hd);
if (hd->homunculus.spiritball <= 0) {
@@ -140,11 +144,13 @@ void homunculus_delspiritball(struct homun_data *hd, int count, int type) {
clif->spiritball(&hd->bl);
}
-void homunculus_damaged(struct homun_data *hd) {
+static void homunculus_damaged(struct homun_data *hd)
+{
clif->hominfo(hd->master,hd,0);
}
-int homunculus_dead(struct homun_data *hd) {
+static int homunculus_dead(struct homun_data *hd)
+{
//There's no intimacy penalties on death (from Tharis)
struct map_session_data *sd;
@@ -165,7 +171,8 @@ int homunculus_dead(struct homun_data *hd) {
}
//Vaporize a character's homun. If flag, HP needs to be 80% or above.
-int homunculus_vaporize(struct map_session_data *sd, enum homun_state flag) {
+static int homunculus_vaporize(struct map_session_data *sd, enum homun_state flag)
+{
struct homun_data *hd;
nullpo_ret(sd);
@@ -193,7 +200,8 @@ int homunculus_vaporize(struct map_session_data *sd, enum homun_state flag) {
//delete a homunculus, completely "killing it".
//Emote is the emotion the master should use, send negative to disable.
-int homunculus_delete(struct homun_data *hd, int emote) {
+static int homunculus_delete(struct homun_data *hd, int emote)
+{
struct map_session_data *sd;
nullpo_ret(hd);
sd = hd->master;
@@ -212,7 +220,8 @@ int homunculus_delete(struct homun_data *hd, int emote) {
return unit->remove_map(&hd->bl,CLR_OUTSIGHT, ALC_MARK);
}
-int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve) {
+static int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve)
+{
int i, id = 0;
int j, f = 1;
int c = 0;
@@ -269,7 +278,8 @@ int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve) {
return 0;
}
-int homunculus_checkskill(struct homun_data *hd,uint16 skill_id) {
+static int homunculus_checkskill(struct homun_data *hd, uint16 skill_id)
+{
int i = skill_id - HM_SKILLBASE;
if(!hd)
return 0;
@@ -281,7 +291,8 @@ int homunculus_checkskill(struct homun_data *hd,uint16 skill_id) {
return 0;
}
-int homunculus_skill_tree_get_max(int id, int b_class) {
+static int homunculus_skill_tree_get_max(int id, int b_class)
+{
int i, skill_id;
b_class -= HM_CLASS_BASE;
Assert_ret(b_class >= 0 && b_class < MAX_HOMUNCULUS_CLASS);
@@ -291,7 +302,8 @@ int homunculus_skill_tree_get_max(int id, int b_class) {
return skill->get_max(id);
}
-void homunculus_skillup(struct homun_data *hd,uint16 skill_id) {
+static void homunculus_skillup(struct homun_data *hd, uint16 skill_id)
+{
int i = 0 ;
nullpo_retv(hd);
@@ -317,7 +329,8 @@ void homunculus_skillup(struct homun_data *hd,uint16 skill_id) {
}
}
-bool homunculus_levelup(struct homun_data *hd) {
+static bool homunculus_levelup(struct homun_data *hd)
+{
struct s_homunculus *hom;
struct h_stats *min, *max;
int growth_str, growth_agi, growth_vit, growth_int, growth_dex, growth_luk ;
@@ -396,7 +409,8 @@ bool homunculus_levelup(struct homun_data *hd) {
return true;
}
-int homunculus_change_class(struct homun_data *hd, short class_) {
+static int homunculus_change_class(struct homun_data *hd, short class_)
+{
int i = homun->db_search(class_,HOMUNCULUS_CLASS);
nullpo_retr(0, hd);
if (i == INDEX_NOT_FOUND)
@@ -408,7 +422,8 @@ int homunculus_change_class(struct homun_data *hd, short class_) {
return 1;
}
-bool homunculus_evolve(struct homun_data *hd) {
+static bool homunculus_evolve(struct homun_data *hd)
+{
struct s_homunculus *hom;
struct h_stats *max, *min;
struct map_session_data *sd;
@@ -460,7 +475,8 @@ bool homunculus_evolve(struct homun_data *hd) {
return true;
}
-bool homunculus_mutate(struct homun_data *hd, int homun_id) {
+static bool homunculus_mutate(struct homun_data *hd, int homun_id)
+{
struct s_homunculus *hom;
struct map_session_data *sd;
int prev_class = 0;
@@ -506,7 +522,8 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) {
return true;
}
-int homunculus_gainexp(struct homun_data *hd,unsigned int exp) {
+static int homunculus_gainexp(struct homun_data *hd, unsigned int exp)
+{
enum homun_type htype;
nullpo_ret(hd);
@@ -550,7 +567,8 @@ int homunculus_gainexp(struct homun_data *hd,unsigned int exp) {
}
// Return the new value
-unsigned int homunculus_add_intimacy(struct homun_data *hd, unsigned int value) {
+static unsigned int homunculus_add_intimacy(struct homun_data *hd, unsigned int value)
+{
nullpo_ret(hd);
if (battle_config.homunculus_friendly_rate != 100)
value = (value * battle_config.homunculus_friendly_rate) / 100;
@@ -563,7 +581,8 @@ unsigned int homunculus_add_intimacy(struct homun_data *hd, unsigned int value)
}
// Return 0 if decrease fails or intimacy became 0 else the new value
-unsigned int homunculus_consume_intimacy(struct homun_data *hd, unsigned int value) {
+static unsigned int homunculus_consume_intimacy(struct homun_data *hd, unsigned int value)
+{
nullpo_ret(hd);
if (hd->homunculus.intimacy >= value)
hd->homunculus.intimacy -= value;
@@ -573,12 +592,14 @@ unsigned int homunculus_consume_intimacy(struct homun_data *hd, unsigned int val
return hd->homunculus.intimacy;
}
-void homunculus_healed (struct homun_data *hd) {
+static void homunculus_healed(struct homun_data *hd)
+{
nullpo_retv(hd);
clif->hominfo(hd->master,hd,0);
}
-void homunculus_save(struct homun_data *hd) {
+static void homunculus_save(struct homun_data *hd)
+{
// copy data that must be saved in homunculus struct ( hp / sp )
struct map_session_data *sd = NULL;
//Do not check for max_hp/max_sp caps as current could be higher to max due
@@ -592,7 +613,8 @@ void homunculus_save(struct homun_data *hd) {
intif->homunculus_requestsave(sd->status.account_id, &hd->homunculus);
}
-unsigned char homunculus_menu(struct map_session_data *sd,unsigned char menu_num) {
+static unsigned char homunculus_menu(struct map_session_data *sd, unsigned char menu_num)
+{
nullpo_ret(sd);
if (sd->hd == NULL)
return 1;
@@ -613,7 +635,8 @@ unsigned char homunculus_menu(struct map_session_data *sd,unsigned char menu_num
return 0;
}
-bool homunculus_feed(struct map_session_data *sd, struct homun_data *hd) {
+static bool homunculus_feed(struct map_session_data *sd, struct homun_data *hd)
+{
int i, foodID, emotion;
nullpo_retr(false, hd);
@@ -661,7 +684,8 @@ bool homunculus_feed(struct map_session_data *sd, struct homun_data *hd) {
return true;
}
-int homunculus_hunger_timer(int tid, int64 tick, int id, intptr_t data) {
+static int homunculus_hunger_timer(int tid, int64 tick, int id, intptr_t data)
+{
struct map_session_data *sd;
struct homun_data *hd;
@@ -702,7 +726,8 @@ int homunculus_hunger_timer(int tid, int64 tick, int id, intptr_t data) {
return 0;
}
-void homunculus_hunger_timer_delete(struct homun_data *hd) {
+static void homunculus_hunger_timer_delete(struct homun_data *hd)
+{
nullpo_retv(hd);
if(hd->hungry_timer != INVALID_TIMER) {
timer->delete(hd->hungry_timer,homun->hunger_timer);
@@ -710,7 +735,7 @@ void homunculus_hunger_timer_delete(struct homun_data *hd) {
}
}
-int homunculus_change_name(struct map_session_data *sd, const char *name)
+static int homunculus_change_name(struct map_session_data *sd, const char *name)
{
int i;
struct homun_data *hd;
@@ -731,7 +756,7 @@ int homunculus_change_name(struct map_session_data *sd, const char *name)
return intif_rename_hom(sd, name);
}
-bool homunculus_change_name_ack(struct map_session_data *sd, const char *name, int flag)
+static bool homunculus_change_name_ack(struct map_session_data *sd, const char *name, int flag)
{
struct homun_data *hd;
char *newname = NULL;
@@ -757,7 +782,8 @@ bool homunculus_change_name_ack(struct map_session_data *sd, const char *name, i
return true;
}
-int homunculus_db_search(int key,int type) {
+static int homunculus_db_search(int key, int type)
+{
int i;
for(i=0;i<MAX_HOMUNCULUS_CLASS;i++) {
@@ -791,7 +817,7 @@ int homunculus_db_search(int key,int type) {
* @param hom The homunculus source data.
* @retval false in case of errors.
*/
-bool homunculus_create(struct map_session_data *sd, const struct s_homunculus *hom)
+static bool homunculus_create(struct map_session_data *sd, const struct s_homunculus *hom)
{
struct homun_data *hd;
int i = 0;
@@ -841,14 +867,16 @@ bool homunculus_create(struct map_session_data *sd, const struct s_homunculus *h
return true;
}
-void homunculus_init_timers(struct homun_data * hd) {
+static void homunculus_init_timers(struct homun_data *hd)
+{
nullpo_retv(hd);
if (hd->hungry_timer == INVALID_TIMER)
hd->hungry_timer = timer->add(timer->gettick()+hd->homunculusDB->hungryDelay,homun->hunger_timer,hd->master->bl.id,0);
hd->regen.state.block = 0; //Restore HP/SP block.
}
-bool homunculus_call(struct map_session_data *sd) {
+static bool homunculus_call(struct map_session_data *sd)
+{
struct homun_data *hd;
nullpo_retr(false, sd);
@@ -886,7 +914,7 @@ bool homunculus_call(struct map_session_data *sd) {
}
// Receive homunculus data from char server
-bool homunculus_recv_data(int account_id, const struct s_homunculus *sh, int flag)
+static bool homunculus_recv_data(int account_id, const struct s_homunculus *sh, int flag)
{
struct map_session_data *sd;
struct homun_data *hd;
@@ -945,7 +973,8 @@ bool homunculus_recv_data(int account_id, const struct s_homunculus *sh, int fla
}
// Ask homunculus creation to char server
-bool homunculus_creation_request(struct map_session_data *sd, int class_) {
+static bool homunculus_creation_request(struct map_session_data *sd, int class_)
+{
struct s_homunculus hom;
struct h_stats *base;
int i;
@@ -981,7 +1010,8 @@ bool homunculus_creation_request(struct map_session_data *sd, int class_) {
return true;
}
-bool homunculus_ressurect(struct map_session_data* sd, unsigned char per, short x, short y) {
+static bool homunculus_ressurect(struct map_session_data *sd, unsigned char per, short x, short y)
+{
struct homun_data* hd;
nullpo_retr(false,sd);
@@ -1014,7 +1044,8 @@ bool homunculus_ressurect(struct map_session_data* sd, unsigned char per, short
return true;
}
-void homunculus_revive(struct homun_data *hd, unsigned int hp, unsigned int sp) {
+static void homunculus_revive(struct homun_data *hd, unsigned int hp, unsigned int sp)
+{
struct map_session_data *sd;
nullpo_retv(hd);
@@ -1028,7 +1059,8 @@ void homunculus_revive(struct homun_data *hd, unsigned int hp, unsigned int sp)
clif->homskillinfoblock(sd);
}
//Resets a homunc stats back to zero (but doesn't touches hunger or intimacy)
-void homunculus_stat_reset(struct homun_data *hd) {
+static void homunculus_stat_reset(struct homun_data *hd)
+{
struct s_homunculus_db *db;
struct s_homunculus *hom;
struct h_stats *base;
@@ -1052,7 +1084,8 @@ void homunculus_stat_reset(struct homun_data *hd) {
hd->homunculus.skillpts = 0;
}
-bool homunculus_shuffle(struct homun_data *hd) {
+static bool homunculus_shuffle(struct homun_data *hd)
+{
struct map_session_data *sd;
int lv, skillpts;
unsigned int exp;
@@ -1101,7 +1134,8 @@ bool homunculus_shuffle(struct homun_data *hd) {
return true;
}
-bool homunculus_read_db_sub(char* str[], int columns, int current) {
+static bool homunculus_read_db_sub(char *str[], int columns, int current)
+{
int classid;
struct s_homunculus_db *db;
@@ -1212,7 +1246,8 @@ bool homunculus_read_db_sub(char* str[], int columns, int current) {
return true;
}
-void homunculus_read_db(void) {
+static void homunculus_read_db(void)
+{
int i;
const char *filename[]={DBPATH"homunculus_db.txt","homunculus_db2.txt"};
memset(homun->dbs->db, 0, sizeof(homun->dbs->db));
@@ -1232,7 +1267,8 @@ void homunculus_read_db(void) {
}
// <hom class>,<skill id>,<max level>[,<job level>],<req id1>,<req lv1>,<req id2>,<req lv2>,<req id3>,<req lv3>,<req id4>,<req lv4>,<req id5>,<req lv5>,<intimacy lv req>
-bool homunculus_read_skill_db_sub(char* split[], int columns, int current) {
+static bool homunculus_read_skill_db_sub(char *split[], int columns, int current)
+{
int k, classid;
int j;
int minJobLevelPresent = 0;
@@ -1272,7 +1308,8 @@ bool homunculus_read_skill_db_sub(char* split[], int columns, int current) {
return true;
}
-int8 homunculus_get_intimacy_grade(struct homun_data *hd) {
+static int8 homunculus_get_intimacy_grade(struct homun_data *hd)
+{
unsigned int val;
nullpo_ret(hd);
val = hd->homunculus.intimacy / 100;
@@ -1292,12 +1329,14 @@ int8 homunculus_get_intimacy_grade(struct homun_data *hd) {
return 0;
}
-void homunculus_skill_db_read(void) {
+static void homunculus_skill_db_read(void)
+{
memset(homun->dbs->skill_tree, 0, sizeof(homun->dbs->skill_tree));
sv->readdb(map->db_path, "homun_skill_tree.txt", ',', 13, 15, -1, homun->read_skill_db_sub);
}
-void homunculus_exp_db_read(void) {
+static void homunculus_exp_db_read(void)
+{
char line[1024];
int i, j=0;
char *filename[]={
@@ -1331,16 +1370,19 @@ void homunculus_exp_db_read(void) {
}
}
-void homunculus_reload(void) {
+static void homunculus_reload(void)
+{
homun->read_db();
homun->exp_db_read();
}
-void homunculus_skill_reload(void) {
+static void homunculus_skill_reload(void)
+{
homun->skill_db_read();
}
-void do_init_homunculus(bool minimal) {
+static void do_init_homunculus(bool minimal)
+{
int class_;
if (minimal)
@@ -1358,11 +1400,13 @@ void do_init_homunculus(bool minimal) {
homun->dbs->viewdb[class_].class = HM_CLASS_BASE + class_;
}
-void do_final_homunculus(void) {
+static void do_final_homunculus(void)
+{
}
-void homunculus_defaults(void) {
+void homunculus_defaults(void)
+{
homun = &homunculus_s;
homun->dbs = &homundbs;