From f28739e8d1b08d871c8430b949246bb6a0090bc2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 8 Nov 2014 19:54:53 +0300 Subject: Add most functions from int_pet.c to interfaces. --- src/char/int_pet.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/char/int_pet.h') diff --git a/src/char/int_pet.h b/src/char/int_pet.h index 52642fc54..44f3eb389 100644 --- a/src/char/int_pet.h +++ b/src/char/int_pet.h @@ -6,16 +6,17 @@ struct s_pet; -int inter_pet_init(void); -void inter_pet_sql_final(void); -int inter_pet_save(void); -int inter_pet_delete(int pet_id); +void inter_pet_defaults(void); -int inter_pet_parse_frommap(int fd); -int inter_pet_sql_init(void); -//extern char pet_txt[256]; +struct inter_pet_interface { + int (*tosql) (int pet_id, struct s_pet* p); + int (*fromsql) (int pet_id, struct s_pet* p); + int (*sql_init) (void); + void (*sql_final) (void); + int (*delete_) (int pet_id); + int (*parse_frommap) (int fd); +}; -//Exported for use in the TXT-SQL converter. -int inter_pet_tosql(int pet_id, struct s_pet *p); +struct inter_pet_interface *inter_pet; #endif /* CHAR_INT_PET_H */ -- cgit v1.2.3-70-g09d2 From 63075b84ecf52e329ee524e1e90878469c388f9d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 9 Nov 2014 20:49:54 +0300 Subject: Move global variable into interface in int_pet.c --- src/char/int_pet.c | 76 +++++++++++++++++++++++++++--------------------------- src/char/int_pet.h | 1 + 2 files changed, 39 insertions(+), 38 deletions(-) (limited to 'src/char/int_pet.h') diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 792f6678c..1118baa80 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -23,8 +23,6 @@ struct inter_pet_interface inter_pet_s; -struct s_pet *pet_pt; - //--------------------------------------------------------- int inter_pet_tosql(int pet_id, struct s_pet* p) { @@ -111,11 +109,11 @@ int inter_pet_fromsql(int pet_id, struct s_pet* p) int inter_pet_sql_init(void) { //memory alloc - pet_pt = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1); + inter_pet->pt = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1); return 0; } void inter_pet_sql_final(void) { - if (pet_pt) aFree(pet_pt); + if (inter_pet->pt) aFree(inter_pet->pt); return; } //---------------------------------- @@ -195,35 +193,35 @@ int mapif_delete_pet_ack(int fd, int flag) int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id, short pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name) { - memset(pet_pt, 0, sizeof(struct s_pet)); - safestrncpy(pet_pt->name, pet_name, NAME_LENGTH); + memset(inter_pet->pt, 0, sizeof(struct s_pet)); + safestrncpy(inter_pet->pt->name, pet_name, NAME_LENGTH); if(incubate == 1) - pet_pt->account_id = pet_pt->char_id = 0; + inter_pet->pt->account_id = inter_pet->pt->char_id = 0; else { - pet_pt->account_id = account_id; - pet_pt->char_id = char_id; + inter_pet->pt->account_id = account_id; + inter_pet->pt->char_id = char_id; } - pet_pt->class_ = pet_class; - pet_pt->level = pet_lv; - pet_pt->egg_id = pet_egg_id; - pet_pt->equip = pet_equip; - pet_pt->intimate = intimate; - pet_pt->hungry = hungry; - pet_pt->rename_flag = rename_flag; - pet_pt->incubate = incubate; - - if(pet_pt->hungry < 0) - pet_pt->hungry = 0; - else if(pet_pt->hungry > 100) - pet_pt->hungry = 100; - if(pet_pt->intimate < 0) - pet_pt->intimate = 0; - else if(pet_pt->intimate > 1000) - pet_pt->intimate = 1000; - - pet_pt->pet_id = -1; //Signal NEW pet. - if (inter_pet->tosql(pet_pt->pet_id,pet_pt)) - mapif->pet_created(fd, account_id, pet_pt); + inter_pet->pt->class_ = pet_class; + inter_pet->pt->level = pet_lv; + inter_pet->pt->egg_id = pet_egg_id; + inter_pet->pt->equip = pet_equip; + inter_pet->pt->intimate = intimate; + inter_pet->pt->hungry = hungry; + inter_pet->pt->rename_flag = rename_flag; + inter_pet->pt->incubate = incubate; + + if(inter_pet->pt->hungry < 0) + inter_pet->pt->hungry = 0; + else if(inter_pet->pt->hungry > 100) + inter_pet->pt->hungry = 100; + if(inter_pet->pt->intimate < 0) + inter_pet->pt->intimate = 0; + else if(inter_pet->pt->intimate > 1000) + inter_pet->pt->intimate = 1000; + + inter_pet->pt->pet_id = -1; //Signal NEW pet. + if (inter_pet->tosql(inter_pet->pt->pet_id,inter_pet->pt)) + mapif->pet_created(fd, account_id, inter_pet->pt); else //Failed... mapif->pet_created(fd, account_id, NULL); @@ -232,17 +230,17 @@ int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short int mapif_load_pet(int fd, int account_id, int char_id, int pet_id) { - memset(pet_pt, 0, sizeof(struct s_pet)); + memset(inter_pet->pt, 0, sizeof(struct s_pet)); - inter_pet->fromsql(pet_id, pet_pt); + inter_pet->fromsql(pet_id, inter_pet->pt); - if(pet_pt!=NULL) { - if(pet_pt->incubate == 1) { - pet_pt->account_id = pet_pt->char_id = 0; - mapif->pet_info(fd, account_id, pet_pt); + if(inter_pet->pt!=NULL) { + if(inter_pet->pt->incubate == 1) { + inter_pet->pt->account_id = inter_pet->pt->char_id = 0; + mapif->pet_info(fd, account_id, inter_pet->pt); } - else if(account_id == pet_pt->account_id && char_id == pet_pt->char_id) - mapif->pet_info(fd, account_id, pet_pt); + else if(account_id == inter_pet->pt->account_id && char_id == inter_pet->pt->char_id) + mapif->pet_info(fd, account_id, inter_pet->pt); else mapif->pet_noinfo(fd, account_id); } @@ -331,6 +329,8 @@ void inter_pet_defaults(void) { inter_pet = &inter_pet_s; + inter_pet->pt = NULL; + inter_pet->tosql = inter_pet_tosql; inter_pet->fromsql = inter_pet_fromsql; inter_pet->sql_init = inter_pet_sql_init; diff --git a/src/char/int_pet.h b/src/char/int_pet.h index 44f3eb389..8b3c1f7b4 100644 --- a/src/char/int_pet.h +++ b/src/char/int_pet.h @@ -9,6 +9,7 @@ struct s_pet; void inter_pet_defaults(void); struct inter_pet_interface { + struct s_pet *pt; int (*tosql) (int pet_id, struct s_pet* p); int (*fromsql) (int pet_id, struct s_pet* p); int (*sql_init) (void); -- cgit v1.2.3-70-g09d2 From 727496b378aa6b249e57031b5dc43f7484419d5f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 9 Nov 2014 22:34:26 +0300 Subject: Allow generate HPM hooks for all interfaces in char server. --- src/char/char.h | 3 +++ src/char/geoip.h | 4 +++- src/char/int_auction.h | 3 +++ src/char/int_elemental.h | 3 +++ src/char/int_guild.h | 3 +++ src/char/int_homun.h | 3 +++ src/char/int_mail.h | 3 +++ src/char/int_mercenary.h | 3 +++ src/char/int_party.h | 3 +++ src/char/int_pet.h | 3 +++ src/char/int_quest.h | 3 +++ src/char/int_storage.h | 3 +++ src/char/inter.h | 3 +++ src/char/loginif.h | 4 +++- src/char/mapif.h | 4 +++- src/char/pincode.h | 4 +++- 16 files changed, 48 insertions(+), 4 deletions(-) (limited to 'src/char/int_pet.h') diff --git a/src/char/char.h b/src/char/char.h index 95533d429..3bedbd0ce 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -116,6 +116,9 @@ struct char_auth_node { unsigned changing_mapservers : 1; }; +/** + * char interface + **/ struct char_interface { int login_fd; int char_fd; diff --git a/src/char/geoip.h b/src/char/geoip.h index 4579554a1..c83d886b5 100644 --- a/src/char/geoip.h +++ b/src/char/geoip.h @@ -15,7 +15,9 @@ struct s_geoip { bool active; }; -/* geoip interface */ +/** + * geoip interface + **/ struct geoip_interface { struct s_geoip *data; const char* (*getcountry) (uint32 ipnum); diff --git a/src/char/int_auction.h b/src/char/int_auction.h index 93c43069d..03efcdc51 100644 --- a/src/char/int_auction.h +++ b/src/char/int_auction.h @@ -8,6 +8,9 @@ void inter_auction_defaults(void); +/** + * inter_auction_interface interface + **/ struct inter_auction_interface { DBMap* db; // int auction_id -> struct auction_data* int (*count) (int char_id, bool buy); diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h index d9ad6ec29..995dfbfab 100644 --- a/src/char/int_elemental.h +++ b/src/char/int_elemental.h @@ -8,6 +8,9 @@ void inter_elemental_defaults(void); +/** + * inter_elemental_interface interface + **/ struct inter_elemental_interface { void (*sql_init) (void); void (*sql_final) (void); diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 0b43d45e5..c72856709 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -24,6 +24,9 @@ enum { void inter_guild_defaults(void); +/** + * inter_guild interface + **/ struct inter_guild_interface { DBMap* guild_db; // int guild_id -> struct guild* DBMap* castle_db; diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 13debcebc..69b30b781 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -10,6 +10,9 @@ struct s_homunculus; void inter_homunculus_defaults(void); +/** + * inter_homunculus interface + **/ struct inter_homunculus_interface { int (*sql_init) (void); void (*sql_final) (void); diff --git a/src/char/int_mail.h b/src/char/int_mail.h index 0a8449748..b69b27079 100644 --- a/src/char/int_mail.h +++ b/src/char/int_mail.h @@ -12,6 +12,9 @@ struct mail_message; void inter_mail_defaults(void); +/** + * inter_mail interface + **/ struct inter_mail_interface { int (*sql_init) (void); void (*sql_final) (void); diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h index 1d84a931a..900065cb7 100644 --- a/src/char/int_mercenary.h +++ b/src/char/int_mercenary.h @@ -10,6 +10,9 @@ struct mmo_charstatus; void inter_mercenary_defaults(void); +/** + * inter_mercenary interface + **/ struct inter_mercenary_interface { bool (*owner_fromsql) (int char_id, struct mmo_charstatus *status); bool (*owner_tosql) (int char_id, struct mmo_charstatus *status); diff --git a/src/char/int_party.h b/src/char/int_party.h index 94ca82c82..68fae32a8 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -25,6 +25,9 @@ struct party_data { void inter_party_defaults(void); +/** + * inter_party interface + **/ struct inter_party_interface { struct party_data *pt; DBMap* db; // int party_id -> struct party_data* diff --git a/src/char/int_pet.h b/src/char/int_pet.h index 8b3c1f7b4..fcb052f34 100644 --- a/src/char/int_pet.h +++ b/src/char/int_pet.h @@ -8,6 +8,9 @@ struct s_pet; void inter_pet_defaults(void); +/** + * inter_pet interface + **/ struct inter_pet_interface { struct s_pet *pt; int (*tosql) (int pet_id, struct s_pet* p); diff --git a/src/char/int_quest.h b/src/char/int_quest.h index a66c34a75..17740341b 100644 --- a/src/char/int_quest.h +++ b/src/char/int_quest.h @@ -6,6 +6,9 @@ void inter_quest_defaults(void); +/** + * inter_quest interface + **/ struct inter_quest_interface { int (*parse_frommap) (int fd); }; diff --git a/src/char/int_storage.h b/src/char/int_storage.h index 6da60f4a8..dcf8f07c1 100644 --- a/src/char/int_storage.h +++ b/src/char/int_storage.h @@ -9,6 +9,9 @@ struct guild_storage; void inter_storage_defaults(void); +/** + * inter_storage interface + **/ struct inter_storage_interface { int (*tosql) (int account_id, struct storage_data* p); int (*fromsql) (int account_id, struct storage_data* p); diff --git a/src/char/inter.h b/src/char/inter.h index 9aa0699cc..f15c8b0f7 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -17,6 +17,9 @@ extern unsigned int party_share_level; void inter_defaults(void); +/** + * inter interface + **/ struct inter_interface { Sql* sql_handle; const char* (*msg_txt) (int msg_number); diff --git a/src/char/loginif.h b/src/char/loginif.h index 325e7d75f..374adbcac 100644 --- a/src/char/loginif.h +++ b/src/char/loginif.h @@ -7,7 +7,9 @@ #include "char.h" -/* loginif interface */ +/** + * loginif interface + **/ struct loginif_interface { void (*reset) (void); void (*check_shutdown) (void); diff --git a/src/char/mapif.h b/src/char/mapif.h index 385e1054f..6774db5e5 100644 --- a/src/char/mapif.h +++ b/src/char/mapif.h @@ -17,7 +17,9 @@ struct quest; struct mail_message; struct WisData; -/* mapif interface */ +/** + * mapif interface + **/ struct mapif_interface { void (*ban) (int id, unsigned int flag, int status); void (*server_init) (int id); diff --git a/src/char/pincode.h b/src/char/pincode.h index 1ed05095e..fa43eb9c2 100644 --- a/src/char/pincode.h +++ b/src/char/pincode.h @@ -14,7 +14,9 @@ #define PINCODE_UNUSED 7 #define PINCODE_WRONG 8 -/* Pincode Interface */ +/** + * pincode interface + **/ struct pincode_interface { /* vars */ int *enabled; -- cgit v1.2.3-70-g09d2