diff options
Diffstat (limited to 'src')
74 files changed, 6767 insertions, 441 deletions
diff --git a/src/char/HPMchar.c b/src/char/HPMchar.c index 3a74f443d..43a94604d 100644 --- a/src/char/HPMchar.c +++ b/src/char/HPMchar.c @@ -28,6 +28,7 @@ #include "char/geoip.h" #include "char/inter.h" #include "char/int_auction.h" +#include "char/int_clan.h" #include "char/int_elemental.h" #include "char/int_guild.h" #include "char/int_homun.h" diff --git a/src/char/Makefile.in b/src/char/Makefile.in index 1a7d067a4..fed7ec030 100644 --- a/src/char/Makefile.in +++ b/src/char/Makefile.in @@ -40,11 +40,11 @@ MT19937AR_D = $(THIRDPARTY_D)/mt19937ar MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o MT19937AR_H = $(MT19937AR_D)/mt19937ar.h -CHAR_C = char.c HPMchar.c loginif.c mapif.c geoip.c inter.c int_auction.c int_elemental.c int_guild.c \ +CHAR_C = char.c HPMchar.c loginif.c mapif.c geoip.c inter.c int_auction.c int_clan.c int_elemental.c int_guild.c \ int_homun.c int_mail.c int_mercenary.c int_party.c int_pet.c \ int_quest.c int_rodex.c int_storage.c pincode.c CHAR_OBJ = $(addprefix obj_sql/, $(patsubst %.c,%.o,$(CHAR_C))) -CHAR_H = char.h HPMchar.h loginif.h mapif.h geoip.h inter.h int_auction.h int_elemental.h int_guild.h \ +CHAR_H = char.h HPMchar.h loginif.h mapif.h geoip.h inter.h int_auction.h int_clan.h int_elemental.h int_guild.h \ int_homun.h int_mail.h int_mercenary.h int_party.h int_pet.h \ int_quest.h int_rodex.h int_storage.h pincode.h CHAR_PH = diff --git a/src/char/char.c b/src/char/char.c index c3fcd9e0a..aef35f216 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -26,6 +26,7 @@ #include "char/HPMchar.h" #include "char/geoip.h" #include "char/int_auction.h" +#include "char/int_clan.h" #include "char/int_elemental.h" #include "char/int_guild.h" #include "char/int_homun.h" @@ -465,7 +466,8 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) (p->look.head_mid != cp->look.head_mid) || (p->look.head_bottom != cp->look.head_bottom) || (p->delete_date != cp->delete_date) || (p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->look.robe != cp->look.robe) || (p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) || (p->font != cp->font) || - (p->uniqueitem_counter != cp->uniqueitem_counter) || (p->hotkey_rowshift != cp->hotkey_rowshift) + (p->uniqueitem_counter != cp->uniqueitem_counter) || (p->hotkey_rowshift != cp->hotkey_rowshift) || + (p->clan_id != cp->clan_id) || (p->last_login != cp->last_login) ) { //Save status unsigned int opt = 0; @@ -483,7 +485,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) "`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d'," "`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d', `rename`='%d'," "`delete_date`='%lu',`robe`='%d',`slotchange`='%d', `char_opt`='%u', `font`='%u', `uniqueitem_counter` ='%u'," - "`hotkey_rowshift`='%d'" + "`hotkey_rowshift`='%d',`clan_id`='%d',`last_login`='%"PRId64"'" " WHERE `account_id`='%d' AND `char_id` = '%d'", char_db, p->base_level, p->job_level, p->base_exp, p->job_exp, p->zeny, @@ -495,7 +497,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename, (unsigned long)p->delete_date, // FIXME: platform-dependent size p->look.robe,p->slotchange,opt,p->font,p->uniqueitem_counter, - p->hotkey_rowshift, + p->hotkey_rowshift,p->clan_id,p->last_login, p->account_id, p->char_id) ) { Sql_ShowDebug(inter->sql_handle); @@ -1173,7 +1175,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every "`status_point`,`skill_point`,`option`,`karma`,`manner`,`party_id`,`guild_id`,`pet_id`,`homun_id`,`elemental_id`,`hair`," "`hair_color`,`clothes_color`,`body`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,`last_map`,`last_x`,`last_y`," "`save_map`,`save_x`,`save_y`,`partner_id`,`father`,`mother`,`child`,`fame`,`rename`,`delete_date`,`robe`,`slotchange`," - "`char_opt`,`font`,`uniqueitem_counter`,`sex`,`hotkey_rowshift`" + "`char_opt`,`font`,`uniqueitem_counter`,`sex`,`hotkey_rowshift`,`clan_id`,`last_login`" " FROM `%s` WHERE `char_id`=? LIMIT 1", char_db) || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, sizeof char_id) || SQL_ERROR == SQL->StmtExecute(stmt) @@ -1236,6 +1238,8 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every || SQL_ERROR == SQL->StmtBindColumn(stmt, 56, SQLDT_UINT32, &p->uniqueitem_counter, sizeof p->uniqueitem_counter, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 57, SQLDT_ENUM, &sex, sizeof sex, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 58, SQLDT_UCHAR, &p->hotkey_rowshift, sizeof p->hotkey_rowshift, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 59, SQLDT_INT, &p->clan_id, sizeof p->clan_id, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 60, SQLDT_INT64, &p->last_login, sizeof p->last_login, NULL, NULL) ) { SqlStmt_ShowDebug(stmt); SQL->StmtFree(stmt); @@ -1612,7 +1616,7 @@ int char_make_new_char_sql(struct char_session_data *sd, const char *name_, int case JOB_NOVICE: break; default: - return -2; // Char Creation Denied + return -2; // Char Creation Denied } //check other inputs @@ -6424,6 +6428,7 @@ void char_load_defaults(void) loginif_defaults(); mapif_defaults(); inter_auction_defaults(); + inter_clan_defaults(); inter_elemental_defaults(); inter_guild_defaults(); inter_homunculus_defaults(); diff --git a/src/char/int_clan.c b/src/char/int_clan.c new file mode 100644 index 000000000..e68f6a655 --- /dev/null +++ b/src/char/int_clan.c @@ -0,0 +1,181 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2017 Hercules Dev Team + * + * Hercules is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#define HERCULES_CORE + +#include "config/core.h" // DBPATH +#include "int_clan.h" + +#include "char/char.h" +#include "char/inter.h" +#include "char/mapif.h" +#include "common/cbasetypes.h" +#include "common/memmgr.h" +#include "common/mmo.h" +#include "common/nullpo.h" +#include "common/showmsg.h" +#include "common/socket.h" +#include "common/sql.h" +#include "common/strlib.h" +#include "common/timer.h" + +#include <stdio.h> +#include <stdlib.h> + +struct inter_clan_interface inter_clan_s; +struct inter_clan_interface *inter_clan; + +/** + * Kick offline members of a clan + * + * Perform the update on the DB to reset clan id to 0 + * of the members that are inactive for too long + * + * @param clan_id Id of the clan + * @param kick_interval Time needed to consider a player inactive and kick it + * @return 0 on failure, 1 on success + */ +int inter_clan_kick_inactive_members(int clan_id, int kick_interval) +{ + if (clan_id <= 0) { + ShowError("inter_clan_kick_inactive_members: Invalid clan id received '%d'\n", clan_id); + Assert_report(clan_id > 0); + return 0; + } else if (kick_interval <= 0) { + ShowError("inter_clan_kick_inactive_members: Invalid kick_interval received '%d'", kick_interval); + Assert_report(kick_interval > 0); + return 0; + } + + // Kick Inactive members + if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET " + "`clan_id` = 0 WHERE `clan_id` = '%d' AND `online` = 0 AND `last_login` < %"PRId64, + char_db, clan_id, (int64)(time(NULL) - kick_interval))) + { + Sql_ShowDebug(inter->sql_handle); + return 0; + } + + return 1; +} + +/** + * Count members of a clan + * + * @param clan_id Id of the clan + * @param kick_interval Time needed to consider a player inactive and ignore it on the count + */ +int inter_clan_count_members(int clan_id, int kick_interval) +{ + struct SqlStmt *stmt; + int count = 0; + + if (clan_id <= 0) { + ShowError("inter_clan_count_members: Invalid clan id received '%d'\n", clan_id); + Assert_report(clan_id > 0); + return 0; + } else if (kick_interval <= 0) { + ShowError("inter_clan_count_member: Invalid kick_interval received '%d'", kick_interval); + Assert_report(kick_interval > 0); + return 0; + } + + stmt = SQL->StmtMalloc(inter->sql_handle); + if (stmt == NULL) { + SqlStmt_ShowDebug(stmt); + return 0; + } + + // Count members + if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT COUNT(*) FROM `%s` WHERE `clan_id` = ? AND `last_login` >= %"PRId64, char_db, (int64)(time(NULL) - kick_interval)) + || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &clan_id, sizeof(clan_id)) + || SQL_ERROR == SQL->StmtExecute(stmt) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &count, sizeof(count), NULL, NULL) + ) { + SqlStmt_ShowDebug(stmt); + SQL->StmtFree(stmt); + return 0; + } + + if (SQL->StmtNumRows(stmt) > 0 && SQL_SUCCESS != SQL->StmtNextRow(stmt)) { + SqlStmt_ShowDebug(stmt); + SQL->StmtFree(stmt); + return 0; + } + + SQL->StmtFree(stmt); + return count; +} + +int mapif_parse_ClanMemberCount(int fd, int clan_id, int kick_interval) +{ + + WFIFOHEAD(fd, 10); + WFIFOW(fd, 0) = 0x3858; + WFIFOL(fd, 2) = clan_id; + WFIFOL(fd, 6) = inter_clan->count_members(clan_id, kick_interval); + WFIFOSET(fd, 10); + return 0; +} + +int mapif_parse_ClanMemberKick(int fd, int clan_id, int kick_interval) +{ + int count = 0; + + if (inter_clan->kick_inactive_members(clan_id, kick_interval) == 1) + count = inter_clan->count_members(clan_id, kick_interval); + + WFIFOHEAD(fd, 10); + WFIFOW(fd, 0) = 0x3858; + WFIFOL(fd, 2) = clan_id; + WFIFOL(fd, 6) = count; + WFIFOSET(fd, 10); + return 0; +} + +// Communication from the map server +// - Can analyzed only one by one packet +// Data packet length that you set to inter.c +//- Shouldn't do checking and packet length, RFIFOSKIP is done by the caller +// Must Return +// 1 : ok +// 0 : error +int inter_clan_parse_frommap(int fd) +{ + RFIFOHEAD(fd); + + switch(RFIFOW(fd, 0)) { + case 0x3044: mapif->parse_ClanMemberCount(fd, RFIFOL(fd, 2), RFIFOL(fd, 6)); break; + case 0x3045: mapif->parse_ClanMemberKick(fd, RFIFOL(fd, 2), RFIFOL(fd, 6)); break; + + default: + return 0; + } + + return 1; +} + +void inter_clan_defaults(void) +{ + inter_clan = &inter_clan_s; + + inter_clan->kick_inactive_members = inter_clan_kick_inactive_members; + inter_clan->count_members = inter_clan_count_members; + inter_clan->parse_frommap = inter_clan_parse_frommap; +} diff --git a/src/char/int_clan.h b/src/char/int_clan.h new file mode 100644 index 000000000..e7b44ecd3 --- /dev/null +++ b/src/char/int_clan.h @@ -0,0 +1,39 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2017 Hercules Dev Team + * + * Hercules is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef CHAR_INT_CLAN_H +#define CHAR_INT_CLAN_H + +#include "common/mmo.h" + +/** + * inter clan Interface + **/ +struct inter_clan_interface { + int (*kick_inactive_members) (int clan_id, int kick_interval); + int (*count_members) (int clan_id, int kick_interval); + int (*parse_frommap) (int fd); +}; + +#ifdef HERCULES_CORE +void inter_clan_defaults(void); +#endif // HERCULES_CORE + +HPShared struct inter_clan_interface *inter_clan; +#endif /* CHAR_INT_CLAN_H */ diff --git a/src/char/inter.c b/src/char/inter.c index 557ee5313..baa000d82 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -25,6 +25,7 @@ #include "char/char.h" #include "char/geoip.h" #include "char/int_auction.h" +#include "char/int_clan.h" #include "char/int_elemental.h" #include "char/int_guild.h" #include "char/int_homun.h" @@ -72,7 +73,7 @@ int inter_recv_packet_length[] = { 6,-1, 0, 0, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, // 3010- Account Storage [Smokexyz] -1,10,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, // 3020- Party -1, 6,-1,-1, 55,19, 6,-1, 14,-1,-1,-1, 18,19,186,-1, // 3030- - -1, 9, 0, 0, 0, 0, 0, 0, 7, 6,10,10, 10,-1, 0, 0, // 3040- + -1, 9, 0, 0, 10,10, 0, 0, 7, 6,10,10, 10,-1, 0, 0, // 3040- Clan System(3044-3045) -1,-1,10,10, 0,-1,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3050- Auction System [Zephyrus], Item Bound [Mhalicot] 6,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3060- Quest system [Kevin] [Inkfish] -1,10, 6,-1, 0, 0, 0, 0, 0, 0, 0, 0, -1,10, 6,-1, // 3070- Mercenary packets [Zephyrus], Elemental packets [pakpil] @@ -1420,6 +1421,7 @@ int inter_parse_frommap(int fd) || inter_auction->parse_frommap(fd) || inter_quest->parse_frommap(fd) || inter_rodex->parse_frommap(fd) + || inter_clan->parse_frommap(fd) ) break; else diff --git a/src/char/mapif.c b/src/char/mapif.c index 9fccd691b..241edc925 100644 --- a/src/char/mapif.c +++ b/src/char/mapif.c @@ -221,6 +221,9 @@ int mapif_parse_Registry(int fd); int mapif_parse_RegistryRequest(int fd); void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, const char *const name); int mapif_parse_NameChangeRequest(int fd); +// Clan System +int mapif_parse_ClanMemberKick(int fd, int clan_id, int kick_interval); +int mapif_parse_ClanMemberCount(int fd, int clan_id, int kick_interval); struct mapif_interface mapif_s; struct mapif_interface *mapif; @@ -411,4 +414,7 @@ void mapif_defaults(void) { mapif->parse_RegistryRequest = mapif_parse_RegistryRequest; mapif->namechange_ack = mapif_namechange_ack; mapif->parse_NameChangeRequest = mapif_parse_NameChangeRequest; + /* Clan System */ + mapif->parse_ClanMemberKick = mapif_parse_ClanMemberKick; + mapif->parse_ClanMemberCount = mapif_parse_ClanMemberCount; } diff --git a/src/char/mapif.h b/src/char/mapif.h index a78940ba2..f03f1ad9a 100644 --- a/src/char/mapif.h +++ b/src/char/mapif.h @@ -213,6 +213,9 @@ struct mapif_interface { int (*parse_RegistryRequest) (int fd); void (*namechange_ack) (int fd, int account_id, int char_id, int type, int flag, const char *name); int (*parse_NameChangeRequest) (int fd); + // Clan System + int (*parse_ClanMemberKick) (int fd, int clan_id, int kick_interval); + int (*parse_ClanMemberCount) (int fd, int clan_id, int kick_interval); }; #ifdef HERCULES_CORE diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h index 97a772b6e..fe4745e79 100644 --- a/src/common/HPMDataCheck.h +++ b/src/common/HPMDataCheck.h @@ -61,6 +61,11 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #else #define CHAR_INT_AUCTION_H #endif // CHAR_INT_AUCTION_H + #ifdef CHAR_INT_CLAN_H + { "inter_clan_interface", sizeof(struct inter_clan_interface), SERVER_TYPE_CHAR }, + #else + #define CHAR_INT_CLAN_H + #endif // CHAR_INT_CLAN_H #ifdef CHAR_INT_ELEMENTAL_H { "inter_elemental_interface", sizeof(struct inter_elemental_interface), SERVER_TYPE_CHAR }, #else @@ -194,6 +199,10 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #endif // COMMON_MEMMGR_H #ifdef COMMON_MMO_H { "auction_data", sizeof(struct auction_data), SERVER_TYPE_ALL }, + { "clan", sizeof(struct clan), SERVER_TYPE_ALL }, + { "clan_buff", sizeof(struct clan_buff), SERVER_TYPE_ALL }, + { "clan_member", sizeof(struct clan_member), SERVER_TYPE_ALL }, + { "clan_relationship", sizeof(struct clan_relationship), SERVER_TYPE_ALL }, { "fame_list", sizeof(struct fame_list), SERVER_TYPE_ALL }, { "guild", sizeof(struct guild), SERVER_TYPE_ALL }, { "guild_alliance", sizeof(struct guild_alliance), SERVER_TYPE_ALL }, @@ -300,11 +309,20 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #ifdef LOGIN_ACCOUNT_H { "Account_engine", sizeof(struct Account_engine), SERVER_TYPE_LOGIN }, { "AccountDB", sizeof(struct AccountDB), SERVER_TYPE_LOGIN }, + { "AccountDB_SQL", sizeof(struct AccountDB_SQL), SERVER_TYPE_LOGIN }, { "AccountDBIterator", sizeof(struct AccountDBIterator), SERVER_TYPE_LOGIN }, + { "AccountDBIterator_SQL", sizeof(struct AccountDBIterator_SQL), SERVER_TYPE_LOGIN }, + { "account_interface", sizeof(struct account_interface), SERVER_TYPE_LOGIN }, { "mmo_account", sizeof(struct mmo_account), SERVER_TYPE_LOGIN }, #else #define LOGIN_ACCOUNT_H #endif // LOGIN_ACCOUNT_H + #ifdef LOGIN_IPBAN_H + { "ipban_interface", sizeof(struct ipban_interface), SERVER_TYPE_LOGIN }, + { "s_ipban_dbs", sizeof(struct s_ipban_dbs), SERVER_TYPE_LOGIN }, + #else + #define LOGIN_IPBAN_H + #endif // LOGIN_IPBAN_H #ifdef LOGIN_LCLIF_H { "lclif_interface", sizeof(struct lclif_interface), SERVER_TYPE_LOGIN }, { "login_packet_db", sizeof(struct login_packet_db), SERVER_TYPE_LOGIN }, @@ -332,14 +350,22 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #else #define LOGIN_LCLIF_P_H #endif // LOGIN_LCLIF_P_H + #ifdef LOGIN_LOGINLOG_H + { "loginlog_interface", sizeof(struct loginlog_interface), SERVER_TYPE_LOGIN }, + { "s_loginlog_dbs", sizeof(struct s_loginlog_dbs), SERVER_TYPE_LOGIN }, + #else + #define LOGIN_LOGINLOG_H + #endif // LOGIN_LOGINLOG_H #ifdef LOGIN_LOGIN_H { "Login_Config", sizeof(struct Login_Config), SERVER_TYPE_LOGIN }, { "client_hash_node", sizeof(struct client_hash_node), SERVER_TYPE_LOGIN }, + { "lchrif_interface", sizeof(struct lchrif_interface), SERVER_TYPE_LOGIN }, { "login_auth_node", sizeof(struct login_auth_node), SERVER_TYPE_LOGIN }, { "login_interface", sizeof(struct login_interface), SERVER_TYPE_LOGIN }, { "login_session_data", sizeof(struct login_session_data), SERVER_TYPE_LOGIN }, { "mmo_char_server", sizeof(struct mmo_char_server), SERVER_TYPE_LOGIN }, { "online_login_data", sizeof(struct online_login_data), SERVER_TYPE_LOGIN }, + { "s_login_dbs", sizeof(struct s_login_dbs), SERVER_TYPE_LOGIN }, #else #define LOGIN_LOGIN_H #endif // LOGIN_LOGIN_H @@ -394,6 +420,11 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #else #define MAP_CHRIF_H #endif // MAP_CHRIF_H + #ifdef MAP_CLAN_H + { "clan_interface", sizeof(struct clan_interface), SERVER_TYPE_MAP }, + #else + #define MAP_CLAN_H + #endif // MAP_CLAN_H #ifdef MAP_CLIF_H { "cdelayed_damage", sizeof(struct cdelayed_damage), SERVER_TYPE_MAP }, { "clif_interface", sizeof(struct clif_interface), SERVER_TYPE_MAP }, @@ -565,6 +596,7 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { { "PACKET_CZ_REQ_REMOVE_ITEM_MAIL", sizeof(struct PACKET_CZ_REQ_REMOVE_ITEM_MAIL), SERVER_TYPE_MAP }, { "PACKET_CZ_REQ_ZENY_FROM_MAIL", sizeof(struct PACKET_CZ_REQ_ZENY_FROM_MAIL), SERVER_TYPE_MAP }, { "PACKET_CZ_SEND_MAIL", sizeof(struct PACKET_CZ_SEND_MAIL), SERVER_TYPE_MAP }, + { "PACKET_ZC_ACK_CLAN_LEAVE", sizeof(struct PACKET_ZC_ACK_CLAN_LEAVE), SERVER_TYPE_MAP }, { "PACKET_ZC_ACK_DELETE_MAIL", sizeof(struct PACKET_ZC_ACK_DELETE_MAIL), SERVER_TYPE_MAP }, { "PACKET_ZC_ACK_ITEM_FROM_MAIL", sizeof(struct PACKET_ZC_ACK_ITEM_FROM_MAIL), SERVER_TYPE_MAP }, { "PACKET_ZC_ACK_OPEN_WRITE_MAIL", sizeof(struct PACKET_ZC_ACK_OPEN_WRITE_MAIL), SERVER_TYPE_MAP }, @@ -573,9 +605,12 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { { "PACKET_ZC_ADD_ITEM_TO_MAIL", sizeof(struct PACKET_ZC_ADD_ITEM_TO_MAIL), SERVER_TYPE_MAP }, { "PACKET_ZC_ADD_MEMBER_TO_GROUP", sizeof(struct PACKET_ZC_ADD_MEMBER_TO_GROUP), SERVER_TYPE_MAP }, { "PACKET_ZC_CHECKNAME", sizeof(struct PACKET_ZC_CHECKNAME), SERVER_TYPE_MAP }, + { "PACKET_ZC_CLANINFO", sizeof(struct PACKET_ZC_CLANINFO), SERVER_TYPE_MAP }, { "PACKET_ZC_GROUP_LIST", sizeof(struct PACKET_ZC_GROUP_LIST), SERVER_TYPE_MAP }, { "PACKET_ZC_GROUP_LIST_SUB", sizeof(struct PACKET_ZC_GROUP_LIST_SUB), SERVER_TYPE_MAP }, { "PACKET_ZC_MAIL_LIST", sizeof(struct PACKET_ZC_MAIL_LIST), SERVER_TYPE_MAP }, + { "PACKET_ZC_NOTIFY_CLAN_CHAT", sizeof(struct PACKET_ZC_NOTIFY_CLAN_CHAT), SERVER_TYPE_MAP }, + { "PACKET_ZC_NOTIFY_CLAN_CONNECTINFO", sizeof(struct PACKET_ZC_NOTIFY_CLAN_CONNECTINFO), SERVER_TYPE_MAP }, { "PACKET_ZC_NOTIFY_UNREADMAIL", sizeof(struct PACKET_ZC_NOTIFY_UNREADMAIL), SERVER_TYPE_MAP }, { "PACKET_ZC_READ_MAIL", sizeof(struct PACKET_ZC_READ_MAIL), SERVER_TYPE_MAP }, { "PACKET_ZC_SKILL_SCALE", sizeof(struct PACKET_ZC_SKILL_SCALE), SERVER_TYPE_MAP }, diff --git a/src/common/HPMSymbols.inc.h b/src/common/HPMSymbols.inc.h index 58540ee36..70de5cdef 100644 --- a/src/common/HPMSymbols.inc.h +++ b/src/common/HPMSymbols.inc.h @@ -29,6 +29,9 @@ #ifdef COMMON_UTILS_H /* HCache */ struct HCache_interface *HCache; #endif // COMMON_UTILS_H +#ifdef LOGIN_ACCOUNT_H /* account */ +struct account_interface *account; +#endif // LOGIN_ACCOUNT_H #ifdef MAP_ATCOMMAND_H /* atcommand */ struct atcommand_interface *atcommand; #endif // MAP_ATCOMMAND_H @@ -53,6 +56,9 @@ struct chat_interface *chat; #ifdef MAP_CHRIF_H /* chrif */ struct chrif_interface *chrif; #endif // MAP_CHRIF_H +#ifdef MAP_CLAN_H /* clan */ +struct clan_interface *clan; +#endif // MAP_CLAN_H #ifdef MAP_CLIF_H /* clif */ struct clif_interface *clif; #endif // MAP_CLIF_H @@ -98,6 +104,9 @@ struct instance_interface *instance; #ifdef CHAR_INT_AUCTION_H /* inter_auction */ struct inter_auction_interface *inter_auction; #endif // CHAR_INT_AUCTION_H +#ifdef CHAR_INT_CLAN_H /* inter_clan */ +struct inter_clan_interface *inter_clan; +#endif // CHAR_INT_CLAN_H #ifdef CHAR_INT_ELEMENTAL_H /* inter_elemental */ struct inter_elemental_interface *inter_elemental; #endif // CHAR_INT_ELEMENTAL_H @@ -134,12 +143,18 @@ struct inter_storage_interface *inter_storage; #ifdef MAP_INTIF_H /* intif */ struct intif_interface *intif; #endif // MAP_INTIF_H +#ifdef LOGIN_IPBAN_H /* ipban */ +struct ipban_interface *ipban; +#endif // LOGIN_IPBAN_H #ifdef MAP_IRC_BOT_H /* ircbot */ struct irc_bot_interface *ircbot; #endif // MAP_IRC_BOT_H #ifdef MAP_ITEMDB_H /* itemdb */ struct itemdb_interface *itemdb; #endif // MAP_ITEMDB_H +#ifdef LOGIN_LOGIN_H /* lchrif */ +struct lchrif_interface *lchrif; +#endif // LOGIN_LOGIN_H #ifdef LOGIN_LCLIF_H /* lclif */ struct lclif_interface *lclif; #endif // LOGIN_LCLIF_H @@ -155,6 +170,9 @@ struct login_interface *login; #ifdef CHAR_LOGINIF_H /* loginif */ struct loginif_interface *loginif; #endif // CHAR_LOGINIF_H +#ifdef LOGIN_LOGINLOG_H /* loginlog */ +struct loginlog_interface *loginlog; +#endif // LOGIN_LOGINLOG_H #ifdef MAP_MAIL_H /* mail */ struct mail_interface *mail; #endif // MAP_MAIL_H @@ -283,6 +301,10 @@ HPExport const char *HPM_shared_symbols(int server_type) if ((server_type&(SERVER_TYPE_ALL)) != 0 && !HPM_SYMBOL("HCache", HCache)) return "HCache"; #endif // COMMON_UTILS_H +#ifdef LOGIN_ACCOUNT_H /* account */ + if ((server_type&(SERVER_TYPE_LOGIN)) != 0 && !HPM_SYMBOL("account", account)) + return "account"; +#endif // LOGIN_ACCOUNT_H #ifdef MAP_ATCOMMAND_H /* atcommand */ if ((server_type&(SERVER_TYPE_MAP)) != 0 && !HPM_SYMBOL("atcommand", atcommand)) return "atcommand"; @@ -315,6 +337,10 @@ HPExport const char *HPM_shared_symbols(int server_type) if ((server_type&(SERVER_TYPE_MAP)) != 0 && !HPM_SYMBOL("chrif", chrif)) return "chrif"; #endif // MAP_CHRIF_H +#ifdef MAP_CLAN_H /* clan */ + if ((server_type&(SERVER_TYPE_MAP)) != 0 && !HPM_SYMBOL("clan", clan)) + return "clan"; +#endif // MAP_CLAN_H #ifdef MAP_CLIF_H /* clif */ if ((server_type&(SERVER_TYPE_MAP)) != 0 && !HPM_SYMBOL("clif", clif)) return "clif"; @@ -375,6 +401,10 @@ HPExport const char *HPM_shared_symbols(int server_type) if ((server_type&(SERVER_TYPE_CHAR)) != 0 && !HPM_SYMBOL("inter_auction", inter_auction)) return "inter_auction"; #endif // CHAR_INT_AUCTION_H +#ifdef CHAR_INT_CLAN_H /* inter_clan */ + if ((server_type&(SERVER_TYPE_CHAR)) != 0 && !HPM_SYMBOL("inter_clan", inter_clan)) + return "inter_clan"; +#endif // CHAR_INT_CLAN_H #ifdef CHAR_INT_ELEMENTAL_H /* inter_elemental */ if ((server_type&(SERVER_TYPE_CHAR)) != 0 && !HPM_SYMBOL("inter_elemental", inter_elemental)) return "inter_elemental"; @@ -423,6 +453,10 @@ HPExport const char *HPM_shared_symbols(int server_type) if ((server_type&(SERVER_TYPE_MAP)) != 0 && !HPM_SYMBOL("intif", intif)) return "intif"; #endif // MAP_INTIF_H +#ifdef LOGIN_IPBAN_H /* ipban */ + if ((server_type&(SERVER_TYPE_LOGIN)) != 0 && !HPM_SYMBOL("ipban", ipban)) + return "ipban"; +#endif // LOGIN_IPBAN_H #ifdef MAP_IRC_BOT_H /* ircbot */ if ((server_type&(SERVER_TYPE_MAP)) != 0 && !HPM_SYMBOL("ircbot", ircbot)) return "ircbot"; @@ -431,6 +465,10 @@ HPExport const char *HPM_shared_symbols(int server_type) if ((server_type&(SERVER_TYPE_MAP)) != 0 && !HPM_SYMBOL("itemdb", itemdb)) return "itemdb"; #endif // MAP_ITEMDB_H +#ifdef LOGIN_LOGIN_H /* lchrif */ + if ((server_type&(SERVER_TYPE_LOGIN)) != 0 && !HPM_SYMBOL("lchrif", lchrif)) + return "lchrif"; +#endif // LOGIN_LOGIN_H #ifdef LOGIN_LCLIF_H /* lclif */ if ((server_type&(SERVER_TYPE_LOGIN)) != 0 && !HPM_SYMBOL("lclif", lclif)) return "lclif"; @@ -451,6 +489,10 @@ HPExport const char *HPM_shared_symbols(int server_type) if ((server_type&(SERVER_TYPE_CHAR)) != 0 && !HPM_SYMBOL("loginif", loginif)) return "loginif"; #endif // CHAR_LOGINIF_H +#ifdef LOGIN_LOGINLOG_H /* loginlog */ + if ((server_type&(SERVER_TYPE_LOGIN)) != 0 && !HPM_SYMBOL("loginlog", loginlog)) + return "loginlog"; +#endif // LOGIN_LOGINLOG_H #ifdef MAP_MAIL_H /* mail */ if ((server_type&(SERVER_TYPE_MAP)) != 0 && !HPM_SYMBOL("mail", mail)) return "mail"; diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 143c325c1..7698d3ca7 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -89,6 +89,7 @@ enum HPluginDataTypes { HPDT_ITEMDATA, ///< For struct item_data. HPDT_BGDATA, ///< For struct battleground_data. HPDT_AUTOTRADE_VEND, ///< For struct autotrade_vending. + HPDT_CLAN, ///< For struct clan. }; /* used in macros and conf storage */ @@ -153,6 +154,10 @@ enum HPluginConfType { #define addToATVEND(ptr,data,classid,autofree) (HPMi->addToHPData(HPDT_AUTOTRADE_VEND,HPMi->pid,&(ptr)->hdata,(data),(classid),(autofree))) #define getFromATVEND(ptr,classid) (HPMi->getFromHPData(HPDT_AUTOTRADE_VEND,HPMi->pid,(ptr)->hdata,(classid))) #define removeFromATVEND(ptr,classid) (HPMi->removeFromHPData(HPDT_AUTOTRADE_VEND,HPMi->pid,(ptr)->hdata,(classid))) +/* clan */ +#define addtoCLAN(ptr,data,classid,autofree) (HPMi->addToHPData(HPDT_CLAN,HPMi->pid,&(ptr)->hdata,(data),(classid),(autofree))) +#define getfromCLAN(ptr,classid) (HPMi->getFromHPData(HPDT_CLAN,HPMi->pid,(ptr)->hdata,(classid))) +#define removefromCLAN(ptr,classid) (HPMi->removeFromHPData(HPDT_CLAN,HPMi->pid,(ptr)->hdata,(classid))) /// HPMi->addCommand #define addAtcommand(cname,funcname) do { \ diff --git a/src/common/mmo.h b/src/common/mmo.h index 7fd4ca6ea..04daedca0 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -304,6 +304,7 @@ STATIC_ASSERT(MAX_ITEM_OPTIONS <= 5, "This value is limited by the client and da #define INFINITE_DURATION (-1) // Infinite duration for status changes struct hplugin_data_store; +struct script_code; enum item_types { IT_HEALING = 0, @@ -359,7 +360,7 @@ struct item { char favorite; unsigned char bound; uint64 unique_id; - + struct { int16 index; int16 value; @@ -616,7 +617,7 @@ struct mmo_charstatus { short manner; // Defines how many minutes a char will be muted, each negative point is equivalent to a minute. unsigned char karma; short hair,hair_color,clothes_color,body; - int party_id,guild_id,pet_id,hom_id,mer_id,ele_id; + int party_id,guild_id,clan_id,pet_id,hom_id,mer_id,ele_id; int fame; // Mercenary Guilds Rank @@ -641,6 +642,7 @@ struct mmo_charstatus { uint32 mapip; uint16 mapport; + int64 last_login; struct point last_point,save_point,memo_point[MAX_MEMOPOINTS]; struct item inventory[MAX_INVENTORY],cart[MAX_CART]; struct s_skill skill[MAX_SKILL_DB]; @@ -818,6 +820,59 @@ struct guild_castle { int temp_guardians_max; }; +/** + * Clan Member Struct + */ +struct clan_member { + int char_id; ///< Char Id of member + short online; ///< Flag to know if the player is online or not + int64 last_login; ///< Last login of this member, used to kick if inactive for long time + struct map_session_data *sd; ///< Player data of member +}; + +/** + * Clan Buff Struct + */ +struct clan_buff { + int icon; ///< Status Icon to be shown in client (Use one of the 'SI_' constants) + struct script_code *script; ///< The script to be executed as CLan Buff +}; + +/** + * Clan Relationship Struct + */ +struct clan_relationship { + char constant[NAME_LENGTH]; ///< Unique name of the related clan + int clan_id; ///< Id of the related clan +}; + +/** + * Clan Struct + */ +struct clan { + int clan_id; ///< CLan's Id + char constant[NAME_LENGTH]; ///< Clan's Unique Name + char name[NAME_LENGTH]; ///< Clan's Name + char master[NAME_LENGTH]; ///< Name of the clan's master (used for clan information on client) + char map[MAP_NAME_LENGTH_EXT]; ///< The map of that clan (used for clan information on client) + struct clan_buff buff; ///< The buff for a clan when a member joins it + short max_member; ///< Limit of Members + short member_count; ///< Holds the amount of members in this clan, online and offline + short connect_member; ///< Members that are Online + VECTOR_DECL(struct clan_member) members; ///< Vector of Members + VECTOR_DECL(struct clan_relationship) allies; ///< Vector of Allies + VECTOR_DECL(struct clan_relationship) antagonists; ///< Vector of Antagonists + int kick_time; /// Needed inactive time to be kicked + int check_time; ///< Interval to check for inactive players + int tid; ///< Timer ID for inactivity kick + bool received; ///< Whether or not the requested data was received + int req_state; ///< Flag for knowing what to do after receiving the data from inter server + int req_count_tid; ///< Timer ID for the timer that handles the timeout of requests for interserver to count members + int req_kick_tid; ///< Timer ID for the timer that handles the timeout of requests for interserver to kick inactive members + + struct hplugin_data_store *hdata; ///< HPM Plugin Data Store +}; + struct fame_list { int id; int fame; @@ -844,7 +899,6 @@ struct rodex_message { struct { struct item item; int idx; - } items[RODEX_MAX_ITEM]; int64 zeny; uint8 type; diff --git a/src/common/socket.c b/src/common/socket.c index d4b8bb43f..c74cd4661 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -1537,7 +1537,7 @@ void socket_close(int fd) // Epoll based Event Dispatcher epevent.data.fd = fd; epevent.events = EPOLLIN; - epoll_ctl(epfd, EPOLL_CTL_DEL, fd, &epevent); // removing the socket from epoll when it's being closed is not required but recommended + epoll_ctl(epfd, EPOLL_CTL_DEL, fd, &epevent); // removing the socket from epoll when it's being closed is not required but recommended #endif // SOCKET_EPOLL sShutdown(fd, SHUT_RDWR); // Disallow further reads/writes @@ -1694,7 +1694,7 @@ void socket_init(void) #else // SOCKET_EPOLL // Epoll based Event Dispatcher: - epfd = epoll_create(FD_SETSIZE); // 2.6.8 or newer ignores the expected socket amount argument + epfd = epoll_create(FD_SETSIZE); // 2.6.8 or newer ignores the expected socket amount argument if(epfd == SOCKET_ERROR){ ShowError("Failed to Create Epoll Event Dispatcher: %s\n", error_msg()); exit(EXIT_FAILURE); diff --git a/src/login/HPMlogin.c b/src/login/HPMlogin.c index b35ac13cb..4f63da6ac 100644 --- a/src/login/HPMlogin.c +++ b/src/login/HPMlogin.c @@ -25,9 +25,11 @@ #include "common/cbasetypes.h" #include "login/account.h" +#include "login/ipban.h" #include "login/lclif.h" #include "login/lclif.p.h" #include "login/login.h" +#include "login/loginlog.h" #include "common/HPMi.h" #include "common/conf.h" #include "common/console.h" @@ -69,7 +71,7 @@ bool HPM_login_data_store_validate(enum HPluginDataTypes type, struct hplugin_da } void HPM_login_plugin_load_sub(struct hplugin *plugin) { - plugin->hpi->sql_handle = account_db_sql_up(login->accounts); + plugin->hpi->sql_handle = account->db_sql_up(login->accounts); } void HPM_login_do_init(void) { diff --git a/src/login/Makefile.in b/src/login/Makefile.in index 69cc6a897..d0258deb0 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -40,7 +40,7 @@ MT19937AR_D = $(THIRDPARTY_D)/mt19937ar MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o MT19937AR_H = $(MT19937AR_D)/mt19937ar.h -LOGIN_C = account_sql.c HPMlogin.c ipban_sql.c lclif.c login.c loginlog_sql.c +LOGIN_C = account.c HPMlogin.c ipban.c lclif.c login.c loginlog.c LOGIN_OBJ = $(addprefix obj_sql/, $(patsubst %.c,%.o,$(LOGIN_C))) LOGIN_H = login.h account.h HPMlogin.h ipban.h lclif.h loginlog.h LOGIN_PH = lclif.p.h diff --git a/src/login/account_sql.c b/src/login/account.c index 66ede6cfa..cd480def9 100644 --- a/src/login/account_sql.c +++ b/src/login/account.c @@ -39,54 +39,8 @@ /// global defines #define ACCOUNT_SQL_DB_VERSION 20110114 -/// internal structure -typedef struct AccountDB_SQL -{ - AccountDB vtable; // public interface - - struct Sql *accounts; // SQL accounts storage - - // Sql settings - char db_hostname[32]; - uint16 db_port; - char db_username[32]; - char db_password[100]; - char db_database[32]; - char codepage[32]; - // other settings - bool case_sensitive; - char account_db[32]; - char global_acc_reg_num_db[32]; - char global_acc_reg_str_db[32]; - - -} AccountDB_SQL; - -/// internal structure -typedef struct AccountDBIterator_SQL -{ - AccountDBIterator vtable; // public interface - - AccountDB_SQL* db; - int last_account_id; -} AccountDBIterator_SQL; - -/// internal functions -static bool account_db_sql_init(AccountDB* self); -static void account_db_sql_destroy(AccountDB* self); -static bool account_db_sql_get_property(AccountDB* self, const char* key, char* buf, size_t buflen); -static bool account_db_sql_set_property(AccountDB* self, struct config_t *config, bool imported); -static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc); -static bool account_db_sql_remove(AccountDB* self, const int account_id); -static bool account_db_sql_save(AccountDB* self, const struct mmo_account* acc); -static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, const int account_id); -static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, const char* userid); -static AccountDBIterator* account_db_sql_iterator(AccountDB* self); -static void account_db_sql_iter_destroy(AccountDBIterator* self); -static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account* acc); - -static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int account_id); -static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, bool is_new); +struct account_interface account_s; +struct account_interface *account; /// public constructor AccountDB* account_db_sql(void) @@ -94,16 +48,16 @@ AccountDB* account_db_sql(void) AccountDB_SQL* db = (AccountDB_SQL*)aCalloc(1, sizeof(AccountDB_SQL)); // set up the vtable - db->vtable.init = &account_db_sql_init; - db->vtable.destroy = &account_db_sql_destroy; - db->vtable.get_property = &account_db_sql_get_property; - db->vtable.set_property = &account_db_sql_set_property; - db->vtable.save = &account_db_sql_save; - db->vtable.create = &account_db_sql_create; - db->vtable.remove = &account_db_sql_remove; - db->vtable.load_num = &account_db_sql_load_num; - db->vtable.load_str = &account_db_sql_load_str; - db->vtable.iterator = &account_db_sql_iterator; + db->vtable.init = account->db_sql_init; + db->vtable.destroy = account->db_sql_destroy; + db->vtable.get_property = account->db_sql_get_property; + db->vtable.set_property = account->db_sql_set_property; + db->vtable.save = account->db_sql_save; + db->vtable.create = account->db_sql_create; + db->vtable.remove = account->db_sql_remove; + db->vtable.load_num = account->db_sql_load_num; + db->vtable.load_str = account->db_sql_load_str; + db->vtable.iterator = account->db_sql_iterator; // initialize to default values db->accounts = NULL; @@ -123,10 +77,8 @@ AccountDB* account_db_sql(void) return &db->vtable; } - /* ------------------------------------------------------------------------- */ - /// establishes database connection static bool account_db_sql_init(AccountDB* self) { @@ -323,7 +275,7 @@ static bool account_db_sql_set_property(AccountDB* self, struct config_t *config libconfig->setting_lookup_uint16(setting, "db_port", &db->db_port); libconfig->setting_lookup_bool_real(setting, "case_sensitive", &db->case_sensitive); - account_db_read_inter(db, "conf/common/inter-server.conf", imported); + account->db_read_inter(db, "conf/common/inter-server.conf", imported); return true; } @@ -381,7 +333,7 @@ static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc) // insert the data into the database acc->account_id = account_id; - return mmo_auth_tosql(db, acc, true); + return account->mmo_auth_tosql(db, acc, true); } /// delete an existing account entry + its regs @@ -411,14 +363,14 @@ static bool account_db_sql_remove(AccountDB* self, const int account_id) static bool account_db_sql_save(AccountDB* self, const struct mmo_account* acc) { AccountDB_SQL* db = (AccountDB_SQL*)self; - return mmo_auth_tosql(db, acc, false); + return account->mmo_auth_tosql(db, acc, false); } /// retrieve data from db and store it in the provided data structure static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, const int account_id) { AccountDB_SQL* db = (AccountDB_SQL*)self; - return mmo_auth_fromsql(db, acc, account_id); + return account->mmo_auth_fromsql(db, acc, account_id); } /// retrieve data from db and store it in the provided data structure @@ -458,7 +410,7 @@ static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, co SQL->GetData(sql_handle, 0, &data, NULL); account_id = atoi(data); - return account_db_sql_load_num(self, acc, account_id); + return account->db_sql_load_num(self, acc, account_id); } @@ -471,8 +423,8 @@ static AccountDBIterator* account_db_sql_iterator(AccountDB* self) nullpo_retr(NULL, db); iter = (AccountDBIterator_SQL*)aCalloc(1, sizeof(AccountDBIterator_SQL)); // set up the vtable - iter->vtable.destroy = &account_db_sql_iter_destroy; - iter->vtable.next = &account_db_sql_iter_next; + iter->vtable.destroy = account->db_sql_iter_destroy; + iter->vtable.next = account->db_sql_iter_next; // fill data iter->db = db; @@ -516,8 +468,7 @@ static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account {// get account data int account_id; account_id = atoi(data); - if( mmo_auth_fromsql(db, acc, account_id) ) - { + if (account->mmo_auth_fromsql(db, acc, account_id)) { iter->last_account_id = account_id; SQL->FreeResult(sql_handle); return true; @@ -528,7 +479,7 @@ static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account } -static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int account_id) +static bool account_mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int account_id) { struct Sql *sql_handle; char* data; @@ -573,7 +524,7 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc return true; } -static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, bool is_new) +static bool account_mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, bool is_new) { struct Sql *sql_handle; struct SqlStmt *stmt; @@ -673,7 +624,8 @@ struct Sql *account_db_sql_up(AccountDB* self) AccountDB_SQL* db = (AccountDB_SQL*)self; return db ? db->accounts : NULL; } -void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) + +void account_mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) { struct Sql *sql_handle; AccountDB_SQL* db = (AccountDB_SQL*)self; @@ -725,7 +677,7 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) } } -void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) +void account_mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { struct Sql *sql_handle; AccountDB_SQL* db = (AccountDB_SQL*)self; @@ -869,3 +821,28 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) SQL->FreeResult(sql_handle); } + +void account_defaults(void) { + account = &account_s; + + account->db_sql_up = account_db_sql_up; + account->mmo_send_accreg2 = account_mmo_send_accreg2; + account->mmo_save_accreg2 = account_mmo_save_accreg2; + account->mmo_auth_fromsql = account_mmo_auth_fromsql; + account->mmo_auth_tosql = account_mmo_auth_tosql; + + account->db_sql = account_db_sql; + account->db_sql_init = account_db_sql_init; + account->db_sql_destroy = account_db_sql_destroy; + account->db_sql_get_property = account_db_sql_get_property; + account->db_sql_set_property = account_db_sql_set_property; + account->db_sql_create = account_db_sql_create; + account->db_sql_remove = account_db_sql_remove; + account->db_sql_save = account_db_sql_save; + account->db_sql_load_num = account_db_sql_load_num; + account->db_sql_load_str = account_db_sql_load_str; + account->db_sql_iterator = account_db_sql_iterator; + account->db_sql_iter_destroy = account_db_sql_iter_destroy; + account->db_sql_iter_next = account_db_sql_iter_next; + account->db_read_inter = account_db_read_inter; +} diff --git a/src/login/account.h b/src/login/account.h index 9bb07fda3..8199ce3ba 100644 --- a/src/login/account.h +++ b/src/login/account.h @@ -33,12 +33,6 @@ struct config_t; // common/conf.h typedef struct AccountDB AccountDB; typedef struct AccountDBIterator AccountDBIterator; - -#ifdef HERCULES_CORE -// standard engines -AccountDB* account_db_sql(void); -#endif // HERCULES_CORE - struct mmo_account { int account_id; @@ -59,7 +53,6 @@ struct mmo_account char birthdate[10+1]; // assigned birth date (format: YYYY-MM-DD, default: 0000-00-00) }; - struct AccountDBIterator { /// Destroys this iterator, releasing all allocated memory (including itself). @@ -161,11 +154,66 @@ struct AccountDB AccountDBIterator* (*iterator)(AccountDB* self); }; -#ifdef HERCULES_CORE -struct Sql *account_db_sql_up(AccountDB* self); +typedef struct AccountDB_SQL +{ + AccountDB vtable; // public interface + + struct Sql *accounts; // SQL accounts storage + + // Sql settings + char db_hostname[32]; + uint16 db_port; + char db_username[32]; + char db_password[100]; + char db_database[32]; + char codepage[32]; + // other settings + bool case_sensitive; + char account_db[32]; + char global_acc_reg_num_db[32]; + char global_acc_reg_str_db[32]; +} AccountDB_SQL; + +/// internal structure +typedef struct AccountDBIterator_SQL +{ + AccountDBIterator vtable; // public interface + + AccountDB_SQL* db; + int last_account_id; +} AccountDBIterator_SQL; -void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id); -void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id); +/** + * Account.c Interface + **/ +struct account_interface { + struct Sql* (*db_sql_up) (AccountDB* self); + void (*mmo_send_accreg2) (AccountDB* self, int fd, int account_id, int char_id); + void (*mmo_save_accreg2) (AccountDB* self, int fd, int account_id, int char_id); + bool (*mmo_auth_fromsql) (AccountDB_SQL* db, struct mmo_account* acc, int account_id); + bool (*mmo_auth_tosql) (AccountDB_SQL* db, const struct mmo_account* acc, bool is_new); + + AccountDB* (*db_sql) (void); + bool (*db_sql_init) (AccountDB* self); + void (*db_sql_destroy) (AccountDB* self); + bool (*db_sql_get_property) (AccountDB* self, const char* key, char* buf, size_t buflen); + bool (*db_sql_set_property) (AccountDB* self, struct config_t *config, bool imported); + bool (*db_sql_create) (AccountDB* self, struct mmo_account* acc); + bool (*db_sql_remove) (AccountDB* self, const int account_id); + bool (*db_sql_save) (AccountDB* self, const struct mmo_account* acc); + bool (*db_sql_load_num) (AccountDB* self, struct mmo_account* acc, const int account_id); + bool (*db_sql_load_str) (AccountDB* self, struct mmo_account* acc, const char* userid); + AccountDBIterator* (*db_sql_iterator) (AccountDB* self); + void (*db_sql_iter_destroy) (AccountDBIterator* self); + bool (*db_sql_iter_next) (AccountDBIterator* self, struct mmo_account* acc); + + bool (*db_read_inter) (AccountDB_SQL *db, const char *filename, bool imported); +}; + +#ifdef HERCULES_CORE +void account_defaults(void); #endif // HERCULES_CORE +HPShared struct account_interface *account; + #endif /* LOGIN_ACCOUNT_H */ diff --git a/src/login/ipban_sql.c b/src/login/ipban.c index d74e6c4fa..60a90fec9 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban.c @@ -34,49 +34,36 @@ #include <stdlib.h> -// Sql settings -static char ipban_db_hostname[32] = "127.0.0.1"; -static uint16 ipban_db_port = 3306; -static char ipban_db_username[32] = "ragnarok"; -static char ipban_db_password[100] = "ragnarok"; -static char ipban_db_database[32] = "ragnarok"; -static char ipban_codepage[32] = ""; -static char ipban_table[32] = "ipbanlist"; - -// globals -static struct Sql *sql_handle = NULL; -static int cleanup_timer_id = INVALID_TIMER; -static bool ipban_inited = false; - -int ipban_cleanup(int tid, int64 tick, int id, intptr_t data); - +struct ipban_interface ipban_s; +struct ipban_interface *ipban; +struct s_ipban_dbs ipbandbs; // initialize void ipban_init(void) { - ipban_inited = true; + ipban->inited = true; if (!login->config->ipban) return;// ipban disabled // establish connections - sql_handle = SQL->Malloc(); - if (SQL_ERROR == SQL->Connect(sql_handle, ipban_db_username, ipban_db_password, - ipban_db_hostname, ipban_db_port, ipban_db_database)) { - Sql_ShowDebug(sql_handle); - SQL->Free(sql_handle); + ipban->sql_handle = SQL->Malloc(); + if (SQL_ERROR == SQL->Connect(ipban->sql_handle, ipban->dbs->db_username, ipban->dbs->db_password, + ipban->dbs->db_hostname, ipban->dbs->db_port, ipban->dbs->db_database)) { + Sql_ShowDebug(ipban->sql_handle); + SQL->Free(ipban->sql_handle); exit(EXIT_FAILURE); } - if (ipban_codepage[0] != '\0' && SQL_ERROR == SQL->SetEncoding(sql_handle, ipban_codepage)) - Sql_ShowDebug(sql_handle); + if (ipban->dbs->codepage[0] != '\0' && SQL_ERROR == SQL->SetEncoding(ipban->sql_handle, ipban->dbs->codepage)) + Sql_ShowDebug(ipban->sql_handle); if (login->config->ipban_cleanup_interval > 0) { // set up periodic cleanup of connection history and active bans - timer->add_func_list(ipban_cleanup, "ipban_cleanup"); - cleanup_timer_id = timer->add_interval(timer->gettick()+10, ipban_cleanup, 0, 0, login->config->ipban_cleanup_interval*1000); + timer->add_func_list(ipban->cleanup, "ipban_cleanup"); + ipban->cleanup_timer_id = timer->add_interval(timer->gettick()+10, ipban->cleanup, 0, 0, login->config->ipban_cleanup_interval*1000); } else { // make sure it gets cleaned up on login-server start regardless of interval-based cleanups - ipban_cleanup(0,0,0,0); + ipban->cleanup(0,0,0,0); } } @@ -88,13 +75,13 @@ void ipban_final(void) if (login->config->ipban_cleanup_interval > 0) // release data - timer->delete(cleanup_timer_id, ipban_cleanup); + timer->delete(ipban->cleanup_timer_id, ipban->cleanup); - ipban_cleanup(0,0,0,0); // always clean up on login-server stop + ipban->cleanup(0,0,0,0); // always clean up on login-server stop // close connections - SQL->Free(sql_handle); - sql_handle = NULL; + SQL->Free(ipban->sql_handle); + ipban->sql_handle = NULL; } /** @@ -126,14 +113,14 @@ bool ipban_config_read_inter(const char *filename, bool imported) ShowError("ipban_config_read: inter_configuration/database_names was not found!\n"); return false; } - libconfig->setting_lookup_mutable_string(setting, "ipban_table", ipban_table, sizeof(ipban_table)); + libconfig->setting_lookup_mutable_string(setting, "ipban_table", ipban->dbs->table, sizeof(ipban->dbs->table)); // import should overwrite any previous configuration, so it should be called last if (libconfig->lookup_string(&config, "import", &import) == CONFIG_TRUE) { if (strcmp(import, filename) == 0 || strcmp(import, "conf/common/inter-server.conf") == 0) { ShowWarning("ipban_config_read_inter: Loop detected! Skipping 'import'...\n"); } else { - if (!ipban_config_read_inter(import, true)) + if (!ipban->config_read_inter(import, true)) retval = false; } } @@ -165,13 +152,13 @@ bool ipban_config_read_connection(const char *filename, struct config_t *config, return false; } - libconfig->setting_lookup_mutable_string(setting, "db_hostname", ipban_db_hostname, sizeof(ipban_db_hostname)); - libconfig->setting_lookup_mutable_string(setting, "db_database", ipban_db_database, sizeof(ipban_db_database)); + libconfig->setting_lookup_mutable_string(setting, "db_hostname", ipban->dbs->db_hostname, sizeof(ipban->dbs->db_hostname)); + libconfig->setting_lookup_mutable_string(setting, "db_database", ipban->dbs->db_database, sizeof(ipban->dbs->db_database)); - libconfig->setting_lookup_mutable_string(setting, "db_username", ipban_db_username, sizeof(ipban_db_username)); - libconfig->setting_lookup_mutable_string(setting, "db_password", ipban_db_password, sizeof(ipban_db_password)); - libconfig->setting_lookup_mutable_string(setting, "codepage", ipban_codepage, sizeof(ipban_codepage)); - libconfig->setting_lookup_uint16(setting, "db_port", &ipban_db_port); + libconfig->setting_lookup_mutable_string(setting, "db_username", ipban->dbs->db_username, sizeof(ipban->dbs->db_username)); + libconfig->setting_lookup_mutable_string(setting, "db_password", ipban->dbs->db_password, sizeof(ipban->dbs->db_password)); + libconfig->setting_lookup_mutable_string(setting, "codepage", ipban->dbs->codepage, sizeof(ipban->dbs->codepage)); + libconfig->setting_lookup_uint16(setting, "db_port", &ipban->dbs->db_port); return true; } @@ -224,7 +211,7 @@ bool ipban_config_read(const char *filename, struct config_t *config, bool impor nullpo_retr(false, filename); nullpo_retr(false, config); - if (ipban_inited) + if (ipban->inited) return false; // settings can only be changed before init if ((setting = libconfig->lookup(config, "login_configuration/account/ipban")) == NULL) { @@ -256,20 +243,20 @@ bool ipban_check(uint32 ip) if (!login->config->ipban) return false;// ipban disabled - if( SQL_ERROR == SQL->Query(sql_handle, "SELECT count(*) FROM `%s` WHERE `rtime` > NOW() AND (`list` = '%u.*.*.*' OR `list` = '%u.%u.*.*' OR `list` = '%u.%u.%u.*' OR `list` = '%u.%u.%u.%u')", - ipban_table, p[3], p[3], p[2], p[3], p[2], p[1], p[3], p[2], p[1], p[0]) ) + if( SQL_ERROR == SQL->Query(ipban->sql_handle, "SELECT count(*) FROM `%s` WHERE `rtime` > NOW() AND (`list` = '%u.*.*.*' OR `list` = '%u.%u.*.*' OR `list` = '%u.%u.%u.*' OR `list` = '%u.%u.%u.%u')", + ipban->dbs->table, p[3], p[3], p[2], p[3], p[2], p[1], p[3], p[2], p[1], p[0]) ) { - Sql_ShowDebug(sql_handle); + Sql_ShowDebug(ipban->sql_handle); // close connection because we can't verify their connectivity. return true; } - if( SQL_SUCCESS != SQL->NextRow(sql_handle) ) + if( SQL_SUCCESS != SQL->NextRow(ipban->sql_handle) ) return false; - SQL->GetData(sql_handle, 0, &data, NULL); + SQL->GetData(ipban->sql_handle, 0, &data, NULL); matches = atoi(data); - SQL->FreeResult(sql_handle); + SQL->FreeResult(ipban->sql_handle); return( matches > 0 ); } @@ -282,16 +269,16 @@ void ipban_log(uint32 ip) if (!login->config->ipban) return;// ipban disabled - failures = loginlog_failedattempts(ip, login->config->dynamic_pass_failure_ban_interval);// how many times failed account? in one ip. + failures = loginlog->failedattempts(ip, login->config->dynamic_pass_failure_ban_interval);// how many times failed account? in one ip. // if over the limit, add a temporary ban entry if (failures >= login->config->dynamic_pass_failure_ban_limit) { uint8* p = (uint8*)&ip; - if (SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s`(`list`,`btime`,`rtime`,`reason`) VALUES ('%u.%u.%u.*', NOW() , NOW() + INTERVAL %u MINUTE ,'Password error ban')", - ipban_table, p[3], p[2], p[1], login->config->dynamic_pass_failure_ban_duration)) + if (SQL_ERROR == SQL->Query(ipban->sql_handle, "INSERT INTO `%s`(`list`,`btime`,`rtime`,`reason`) VALUES ('%u.%u.%u.*', NOW() , NOW() + INTERVAL %u MINUTE ,'Password error ban')", + ipban->dbs->table, p[3], p[2], p[1], login->config->dynamic_pass_failure_ban_duration)) { - Sql_ShowDebug(sql_handle); + Sql_ShowDebug(ipban->sql_handle); } } } @@ -301,8 +288,37 @@ int ipban_cleanup(int tid, int64 tick, int id, intptr_t data) { if (!login->config->ipban) return 0;// ipban disabled - if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `rtime` <= NOW()", ipban_table) ) - Sql_ShowDebug(sql_handle); + if( SQL_ERROR == SQL->Query(ipban->sql_handle, "DELETE FROM `%s` WHERE `rtime` <= NOW()", ipban->dbs->table) ) + Sql_ShowDebug(ipban->sql_handle); return 0; } + +void ipban_defaults(void) { + ipban = &ipban_s; + + ipban->dbs = &ipbandbs; + + ipban->sql_handle = NULL; + ipban->cleanup_timer_id = INVALID_TIMER; + ipban->inited = false; + + // Sql settings + strcpy(ipban->dbs->db_hostname, "127.0.0.1"); + ipban->dbs->db_port = 3306; + strcpy(ipban->dbs->db_username, "ragnarok"); + strcpy(ipban->dbs->db_password, "ragnarok"); + strcpy(ipban->dbs->db_database, "ragnarok"); + *ipban->dbs->codepage = 0; + strcpy(ipban->dbs->table, "ipbanlist"); + + ipban->init = ipban_init; + ipban->final = ipban_final; + ipban->cleanup = ipban_cleanup; + ipban->config_read_inter = ipban_config_read_inter; + ipban->config_read_connection = ipban_config_read_connection; + ipban->config_read_dynamic = ipban_config_read_dynamic; + ipban->config_read = ipban_config_read; + ipban->check = ipban_check; + ipban->log = ipban_log; +} diff --git a/src/login/ipban.h b/src/login/ipban.h index 104e3a8a3..29aafba9d 100644 --- a/src/login/ipban.h +++ b/src/login/ipban.h @@ -22,26 +22,44 @@ #define LOGIN_IPBAN_H #include "common/cbasetypes.h" +#include "common/hercules.h" /* Forward Declarations */ struct config_t; // common/conf.h -#ifdef HERCULES_CORE -// TODO: Interface -// initialize -void ipban_init(void); - -// finalize -void ipban_final(void); - -// check ip against ban list -bool ipban_check(uint32 ip); +struct s_ipban_dbs { + char db_hostname[32]; + uint16 db_port; + char db_username[32]; + char db_password[100]; + char db_database[32]; + char codepage[32]; + char table[32]; +}; -// increases failure count for the specified IP -void ipban_log(uint32 ip); +/** + * Ipban.c Interface + **/ +struct ipban_interface { + struct s_ipban_dbs *dbs; + struct Sql *sql_handle; + int cleanup_timer_id; + bool inited; + void (*init) (void); + void (*final) (void); + int (*cleanup) (int tid, int64 tick, int id, intptr_t data); + bool (*config_read_inter) (const char *filename, bool imported); + bool (*config_read_connection) (const char *filename, struct config_t *config, bool imported); + bool (*config_read_dynamic) (const char *filename, struct config_t *config, bool imported); + bool (*config_read) (const char *filename, struct config_t *config, bool imported); + bool (*check) (uint32 ip); + void (*log) (uint32 ip); +}; -// parses configuration options -bool ipban_config_read(const char *filename, struct config_t *config, bool imported); +#ifdef HERCULES_CORE +void ipban_defaults(void); #endif // HERCULES_CORE +HPShared struct ipban_interface *ipban; + #endif /* LOGIN_IPBAN_H */ diff --git a/src/login/lclif.c b/src/login/lclif.c index 1870f9bc9..ae9f035e3 100644 --- a/src/login/lclif.c +++ b/src/login/lclif.c @@ -257,8 +257,8 @@ bool lclif_send_server_list(struct login_session_data *sd) uint32 ip; struct packet_AC_ACCEPT_LOGIN *packet = NULL; - for (i = 0; i < ARRAYLENGTH(server); ++i) { - if (sockt->session_is_active(server[i].fd)) + for (i = 0; i < ARRAYLENGTH(login->dbs->server); ++i) { + if (sockt->session_is_active(login->dbs->server[i].fd)) server_num++; } if (server_num == 0) @@ -283,24 +283,24 @@ bool lclif_send_server_list(struct login_session_data *sd) packet->last_login_ip = 0; // Not used anymore memset(packet->last_login_time, '\0', sizeof(packet->last_login_time)); // Not used anymore packet->sex = sex_str2num(sd->sex); - for (i = 0, n = 0; i < ARRAYLENGTH(server); ++i) { + for (i = 0, n = 0; i < ARRAYLENGTH(login->dbs->server); ++i) { uint32 subnet_char_ip; - if (!sockt->session_is_valid(server[i].fd)) + if (!sockt->session_is_valid(login->dbs->server[i].fd)) continue; subnet_char_ip = login->lan_subnet_check(ip); - packet->server_list[n].ip = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip); - packet->server_list[n].port = sockt->ntows(htons(server[i].port)); // [!] LE byte order here [!] - safestrncpy(packet->server_list[n].name, server[i].name, 20); - packet->server_list[n].usercount = login->convert_users_to_colors(server[i].users); + packet->server_list[n].ip = htonl((subnet_char_ip) ? subnet_char_ip : login->dbs->server[i].ip); + packet->server_list[n].port = sockt->ntows(htons(login->dbs->server[i].port)); // [!] LE byte order here [!] + safestrncpy(packet->server_list[n].name, login->dbs->server[i].name, 20); + packet->server_list[n].usercount = login->convert_users_to_colors(login->dbs->server[i].users); - if (server[i].type == CST_PAYING && sd->expiration_time > time(NULL)) + if (login->dbs->server[i].type == CST_PAYING && sd->expiration_time > time(NULL)) packet->server_list[n].property = CST_NORMAL; else - packet->server_list[n].property = server[i].type; + packet->server_list[n].property = login->dbs->server[i].type; - packet->server_list[n].state = server[i].new_; + packet->server_list[n].state = login->dbs->server[i].new_; ++n; } WFIFOSET(sd->fd, length); @@ -373,9 +373,9 @@ int lclif_parse(int fd) if ((sd = sockt->session[fd]->session_data) == NULL) { // Perform ip-ban check - if (login->config->ipban && !sockt->trusted_ip_check(ipl) && ipban_check(ipl)) { + if (login->config->ipban && !sockt->trusted_ip_check(ipl) && ipban->check(ipl)) { ShowStatus("Connection refused: IP isn't authorized (deny/allow, ip: %s).\n", ip); - login_log(ipl, "unknown", -3, "ip banned"); + loginlog->log(ipl, "unknown", -3, "ip banned"); lclif->login_error(fd, 3); // 3 = Rejected from Server sockt->eof(fd); return 0; diff --git a/src/login/lclif.p.h b/src/login/lclif.p.h index 024280b37..5c5c062d3 100644 --- a/src/login/lclif.p.h +++ b/src/login/lclif.p.h @@ -122,7 +122,7 @@ struct packet_CA_LOGIN4 { */ struct packet_CA_LOGIN_PCBANG { int16 packet_id; ///< Packet ID (#PACKET_ID_CA_LOGIN_PCBANG) - uint32 version; ///< Client Version + uint32 version; ///< Client Version char id[24]; ///< Username char password[24]; ///< Password uint8 clienttype; ///< Client Type diff --git a/src/login/login.c b/src/login/login.c index a78276051..5b281c22d 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -52,12 +52,12 @@ struct login_interface login_s; struct login_interface *login; +struct s_login_dbs logindbs; +struct lchrif_interface lchrif_s; +struct lchrif_interface *lchrif; struct Login_Config login_config_; -struct mmo_char_server server[MAX_SERVERS]; // char server data -struct Account_engine account_engine[] = { - {account_db_sql, NULL} -}; +struct Account_engine account_engine; // account database AccountDB* accounts = NULL; @@ -164,9 +164,9 @@ int charif_sendallwos(int sfd, uint8* buf, size_t len) int i, c; nullpo_ret(buf); - for( i = 0, c = 0; i < ARRAYLENGTH(server); ++i ) + for (i = 0, c = 0; i < ARRAYLENGTH(login->dbs->server); ++i) { - int fd = server[i].fd; + int fd = login->dbs->server[i].fd; if (sockt->session_is_valid(fd) && fd != sfd) { WFIFOHEAD(fd,len); memcpy(WFIFOP(fd,0), buf, len); @@ -180,41 +180,41 @@ int charif_sendallwos(int sfd, uint8* buf, size_t len) /// Initializes a server structure. -void chrif_server_init(int id) +void lchrif_server_init(int id) { Assert_retv(id >= 0 && id < MAX_SERVERS); - memset(&server[id], 0, sizeof(server[id])); - server[id].fd = -1; + memset(&login->dbs->server[id], 0, sizeof(login->dbs->server[id])); + login->dbs->server[id].fd = -1; } /// Destroys a server structure. -void chrif_server_destroy(int id) +void lchrif_server_destroy(int id) { Assert_retv(id >= 0 && id < MAX_SERVERS); - if (server[id].fd != -1) + if (login->dbs->server[id].fd != -1) { - sockt->close(server[id].fd); - server[id].fd = -1; + sockt->close(login->dbs->server[id].fd); + login->dbs->server[id].fd = -1; } } /// Resets all the data related to a server. -void chrif_server_reset(int id) +void lchrif_server_reset(int id) { login->online_db->foreach(login->online_db, login->online_db_setoffline, id); //Set all chars from this char server to offline. - chrif_server_destroy(id); - chrif_server_init(id); + lchrif->server_destroy(id); + lchrif->server_init(id); } /// Called when the connection to Char Server is disconnected. -void chrif_on_disconnect(int id) +void lchrif_on_disconnect(int id) { Assert_retv(id >= 0 && id < MAX_SERVERS); - ShowStatus("Char-server '%s' has disconnected.\n", server[id].name); - chrif_server_reset(id); + ShowStatus("Char-server '%s' has disconnected.\n", login->dbs->server[id].name); + lchrif->server_reset(id); } @@ -324,7 +324,7 @@ void login_fromchar_parse_auth(int fd, int id, const char *const ip) node->sex == sex_num2str(sex) /*&& node->ip == ip_*/ ) {// found - //ShowStatus("Char-server '%s': authentication of the account %d accepted (ip: %s).\n", server[id].name, account_id, ip); + //ShowStatus("Char-server '%s': authentication of the account %d accepted (ip: %s).\n", login->dbs->server[id].name, account_id, ip); // send ack login->fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, node); @@ -334,7 +334,7 @@ void login_fromchar_parse_auth(int fd, int id, const char *const ip) else {// authentication not found nullpo_retv(ip); - ShowStatus("Char-server '%s': authentication of the account %d REFUSED (ip: %s).\n", server[id].name, account_id, ip); + ShowStatus("Char-server '%s': authentication of the account %d REFUSED (ip: %s).\n", login->dbs->server[id].name, account_id, ip); login->fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, NULL); } } @@ -345,11 +345,11 @@ void login_fromchar_parse_update_users(int fd, int id) RFIFOSKIP(fd,6); // how many users on world? (update) - if( server[id].users != users ) + if (login->dbs->server[id].users != users) { - ShowStatus("set users %s : %d\n", server[id].name, users); + ShowStatus("set users %s : %d\n", login->dbs->server[id].name, users); - server[id].users = (uint16)users; + login->dbs->server[id].users = (uint16)users; } } @@ -363,13 +363,13 @@ void login_fromchar_parse_request_change_email(int fd, int id, const char *const RFIFOSKIP(fd,46); if( e_mail_check(email) == 0 ) - ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - e-mail is invalid (account: %d, ip: %s)\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - e-mail is invalid (account: %d, ip: %s)\n", login->dbs->server[id].name, account_id, ip); else if( !accounts->load_num(accounts, &acc, account_id) || strcmp(acc.email, "a@a.com") == 0 || acc.email[0] == '\0' ) - ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - account doesn't exist or e-mail of account isn't default e-mail (account: %d, ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - account doesn't exist or e-mail of account isn't default e-mail (account: %d, ip: %s).\n", login->dbs->server[id].name, account_id, ip); else { memcpy(acc.email, email, sizeof(acc.email)); - ShowNotice("Char-server '%s': Create an e-mail on an account with a default e-mail (account: %d, new e-mail: %s, ip: %s).\n", server[id].name, account_id, email, ip); + ShowNotice("Char-server '%s': Create an e-mail on an account with a default e-mail (account: %d, new e-mail: %s, ip: %s).\n", login->dbs->server[id].name, account_id, email, ip); // Save accounts->save(accounts, &acc); } @@ -428,7 +428,7 @@ void login_fromchar_parse_account_data(int fd, int id, const char *const ip) if( !accounts->load_num(accounts, &acc, account_id) ) { - ShowNotice("Char-server '%s': account %d NOT found (ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': account %d NOT found (ip: %s).\n", login->dbs->server[id].name, account_id, ip); login->fromchar_account(fd, account_id, NULL); } else { @@ -461,22 +461,22 @@ void login_fromchar_parse_change_email(int fd, int id, const char *const ip) RFIFOSKIP(fd, 86); if( e_mail_check(actual_email) == 0 ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)\n", login->dbs->server[id].name, account_id, ip); else if( e_mail_check(new_email) == 0 ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a invalid new e-mail (account: %d, ip: %s)\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a invalid new e-mail (account: %d, ip: %s)\n", login->dbs->server[id].name, account_id, ip); else if( strcmpi(new_email, "a@a.com") == 0 ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a default e-mail (account: %d, ip: %s)\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a default e-mail (account: %d, ip: %s)\n", login->dbs->server[id].name, account_id, ip); else if( !accounts->load_num(accounts, &acc, account_id) ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but account doesn't exist (account: %d, ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but account doesn't exist (account: %d, ip: %s).\n", login->dbs->server[id].name, account_id, ip); else if( strcmpi(acc.email, actual_email) != 0 ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual e-mail is incorrect (account: %d (%s), actual e-mail: %s, proposed e-mail: %s, ip: %s).\n", server[id].name, account_id, acc.userid, acc.email, actual_email, ip); + ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual e-mail is incorrect (account: %d (%s), actual e-mail: %s, proposed e-mail: %s, ip: %s).\n", login->dbs->server[id].name, account_id, acc.userid, acc.email, actual_email, ip); else { safestrncpy(acc.email, new_email, sizeof(acc.email)); - ShowNotice("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s).\n", server[id].name, account_id, acc.userid, new_email, ip); + ShowNotice("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s).\n", login->dbs->server[id].name, account_id, acc.userid, new_email, ip); // Save accounts->save(accounts, &acc); } @@ -501,12 +501,12 @@ void login_fromchar_parse_account_update(int fd, int id, const char *const ip) RFIFOSKIP(fd,10); if( !accounts->load_num(accounts, &acc, account_id) ) - ShowNotice("Char-server '%s': Error of Status change (account: %d not found, suggested status %u, ip: %s).\n", server[id].name, account_id, state, ip); + ShowNotice("Char-server '%s': Error of Status change (account: %d not found, suggested status %u, ip: %s).\n", login->dbs->server[id].name, account_id, state, ip); else if( acc.state == state ) - ShowNotice("Char-server '%s': Error of Status change - actual status is already the good status (account: %d, status %u, ip: %s).\n", server[id].name, account_id, state, ip); + ShowNotice("Char-server '%s': Error of Status change - actual status is already the good status (account: %d, status %u, ip: %s).\n", login->dbs->server[id].name, account_id, state, ip); else { - ShowNotice("Char-server '%s': Status change (account: %d, new status %u, ip: %s).\n", server[id].name, account_id, state, ip); + ShowNotice("Char-server '%s': Status change (account: %d, new status %u, ip: %s).\n", login->dbs->server[id].name, account_id, state, ip); acc.state = state; // Save @@ -543,7 +543,7 @@ void login_fromchar_parse_ban(int fd, int id, const char *const ip) RFIFOSKIP(fd,18); if (!accounts->load_num(accounts, &acc, account_id)) { - ShowNotice("Char-server '%s': Error of ban request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Error of ban request (account: %d not found, ip: %s).\n", login->dbs->server[id].name, account_id, ip); } else { time_t timestamp; struct tm *tmtime; @@ -560,14 +560,14 @@ void login_fromchar_parse_ban(int fd, int id, const char *const ip) tmtime->tm_sec += sec; timestamp = mktime(tmtime); if (timestamp == -1) { - ShowNotice("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s).\n", login->dbs->server[id].name, account_id, ip); } else if( timestamp <= time(NULL) || timestamp == 0 ) { - ShowNotice("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s).\n", login->dbs->server[id].name, account_id, ip); } else { char tmpstr[24]; timestamp2string(tmpstr, sizeof(tmpstr), timestamp, login->config->date_format); ShowNotice("Char-server '%s': Ban request (account: %d, new final date of banishment: %ld (%s), ip: %s).\n", - server[id].name, account_id, (long)timestamp, tmpstr, ip); + login->dbs->server[id].name, account_id, (long)timestamp, tmpstr, ip); acc.unban_time = timestamp; @@ -596,15 +596,15 @@ void login_fromchar_parse_change_sex(int fd, int id, const char *const ip) RFIFOSKIP(fd,6); if( !accounts->load_num(accounts, &acc, account_id) ) - ShowNotice("Char-server '%s': Error of sex change (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Error of sex change (account: %d not found, ip: %s).\n", login->dbs->server[id].name, account_id, ip); else if( acc.sex == 'S' ) - ShowNotice("Char-server '%s': Error of sex change - account to change is a Server account (account: %d, ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Error of sex change - account to change is a Server account (account: %d, ip: %s).\n", login->dbs->server[id].name, account_id, ip); else { char sex = ( acc.sex == 'M' ) ? 'F' : 'M'; //Change gender - ShowNotice("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s).\n", server[id].name, account_id, sex, ip); + ShowNotice("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s).\n", login->dbs->server[id].name, account_id, sex, ip); acc.sex = sex; // Save @@ -622,9 +622,9 @@ void login_fromchar_parse_account_reg2(int fd, int id, const char *const ip) int account_id = RFIFOL(fd,4); if( !accounts->load_num(accounts, &acc, account_id) ) - ShowStatus("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); + ShowStatus("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d not found, ip: %s).\n", login->dbs->server[id].name, account_id, ip); else { - mmo_save_accreg2(accounts,fd,account_id,RFIFOL(fd, 8)); + account->mmo_save_accreg2(accounts,fd,account_id,RFIFOL(fd, 8)); } RFIFOSKIP(fd,RFIFOW(fd,2)); } @@ -637,13 +637,13 @@ void login_fromchar_parse_unban(int fd, int id, const char *const ip) RFIFOSKIP(fd,6); if( !accounts->load_num(accounts, &acc, account_id) ) - ShowNotice("Char-server '%s': Error of Unban request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Error of Unban request (account: %d not found, ip: %s).\n", login->dbs->server[id].name, account_id, ip); else if( acc.unban_time == 0 ) - ShowNotice("Char-server '%s': Error of Unban request (account: %d, no change for unban date, ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Error of Unban request (account: %d, no change for unban date, ip: %s).\n", login->dbs->server[id].name, account_id, ip); else { - ShowNotice("Char-server '%s': Unban request (account: %d, ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Unban request (account: %d, ip: %s).\n", login->dbs->server[id].name, account_id, ip); acc.unban_time = 0; accounts->save(accounts, &acc); } @@ -684,13 +684,13 @@ void login_fromchar_parse_request_account_reg2(int fd) int char_id = RFIFOL(fd,6); RFIFOSKIP(fd,10); - mmo_send_accreg2(accounts,fd,account_id,char_id); + account->mmo_send_accreg2(accounts,fd,account_id,char_id); } void login_fromchar_parse_update_wan_ip(int fd, int id) { - server[id].ip = ntohl(RFIFOL(fd,2)); - ShowInfo("Updated IP of Server #%d to %u.%u.%u.%u.\n",id, CONVIP(server[id].ip)); + login->dbs->server[id].ip = ntohl(RFIFOL(fd,2)); + ShowInfo("Updated IP of Server #%d to %u.%u.%u.%u.\n",id, CONVIP(login->dbs->server[id].ip)); RFIFOSKIP(fd,6); } @@ -725,7 +725,7 @@ bool login_fromchar_parse_wrong_pincode(int fd) return true; } - login_log(sockt->host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed"); // FIXME: Do we really want to log this with the same code as successful logins? + loginlog->log(sockt->host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed"); // FIXME: Do we really want to log this with the same code as successful logins? } login->remove_online_user(acc.account_id); @@ -794,8 +794,8 @@ int login_parse_fromchar(int fd) uint32 ipl; char ip[16]; - ARR_FIND( 0, ARRAYLENGTH(server), id, server[id].fd == fd ); - if( id == ARRAYLENGTH(server) ) + ARR_FIND(0, ARRAYLENGTH(login->dbs->server), id, login->dbs->server[id].fd == fd); + if (id == ARRAYLENGTH(login->dbs->server)) {// not a char server ShowDebug("login_parse_fromchar: Disconnecting invalid session #%d (is not a char-server)\n", fd); sockt->eof(fd); @@ -806,12 +806,12 @@ int login_parse_fromchar(int fd) if( sockt->session[fd]->flag.eof ) { sockt->close(fd); - server[id].fd = -1; - chrif_on_disconnect(id); + login->dbs->server[id].fd = -1; + lchrif->on_disconnect(id); return 0; } - ipl = server[id].ip; + ipl = login->dbs->server[id].ip; sockt->ip2str(ipl, ip); while (RFIFOREST(fd) >= 2) { @@ -1258,7 +1258,7 @@ void login_auth_ok(struct login_session_data* sd) return; } - login_log(ip, sd->userid, 100, "login ok"); + loginlog->log(ip, sd->userid, 100, "login ok"); ShowStatus("Connection of the account '%s' accepted.\n", sd->userid); // create temporary auth entry @@ -1322,11 +1322,11 @@ void login_auth_failed(struct login_session_data *sd, int result) default : error = "Unknown Error."; break; } - login_log(ip, sd->userid, result, error); // FIXME: result can be 100, conflicting with the value 100 we use for successful login... + loginlog->log(ip, sd->userid, result, error); // FIXME: result can be 100, conflicting with the value 100 we use for successful login... } if (result == 1 && login->config->dynamic_pass_failure_ban && !sockt->trusted_ip_check(ip)) - ipban_log(ip); // log failed password attempt + ipban->log(ip); // log failed password attempt if (result == 6) { struct mmo_account acc = { 0 }; @@ -1430,25 +1430,25 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const ShowInfo("Connection request of the char-server '%s' @ %u.%u.%u.%u:%u (account: '%s', pass: '%s', ip: '%s')\n", server_name, CONVIP(server_ip), server_port, sd->userid, sd->passwd, ip); sprintf(message, "charserver - %s@%u.%u.%u.%u:%u", server_name, CONVIP(server_ip), server_port); - login_log(sockt->session[fd]->client_addr, sd->userid, 100, message); + loginlog->log(sockt->session[fd]->client_addr, sd->userid, 100, message); result = login->mmo_auth(sd, true); if (core->runflag == LOGINSERVER_ST_RUNNING && result == -1 && sd->sex == 'S' && sd->account_id >= 0 && - sd->account_id < ARRAYLENGTH(server) && - !sockt->session_is_valid(server[sd->account_id].fd) && + sd->account_id < ARRAYLENGTH(login->dbs->server) && + !sockt->session_is_valid(login->dbs->server[sd->account_id].fd) && sockt->allowed_ip_check(ipl)) { ShowStatus("Connection of the char-server '%s' accepted.\n", server_name); - safestrncpy(server[sd->account_id].name, server_name, sizeof(server[sd->account_id].name)); - server[sd->account_id].fd = fd; - server[sd->account_id].ip = server_ip; - server[sd->account_id].port = server_port; - server[sd->account_id].users = 0; - server[sd->account_id].type = type; - server[sd->account_id].new_ = new_; + safestrncpy(login->dbs->server[sd->account_id].name, server_name, sizeof(login->dbs->server[sd->account_id].name)); + login->dbs->server[sd->account_id].fd = fd; + login->dbs->server[sd->account_id].ip = server_ip; + login->dbs->server[sd->account_id].port = server_port; + login->dbs->server[sd->account_id].users = 0; + login->dbs->server[sd->account_id].type = type; + login->dbs->server[sd->account_id].new_ = new_; sockt->session[fd]->func_parse = login->parse_fromchar; sockt->session[fd]->flag.server = 1; @@ -1607,7 +1607,7 @@ bool login_config_read_log(const char *filename, struct config_t *config, bool i bool login_config_read_account(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; - AccountDB *db = account_engine[0].db; + AccountDB *db = login->dbs->account_engine->db; bool retval = true; nullpo_retr(false, filename); @@ -1630,7 +1630,7 @@ bool login_config_read_account(const char *filename, struct config_t *config, bo if (!db->set_property(db, config, imported)) retval = false; - if (!ipban_config_read(filename, config, imported)) + if (!ipban->config_read(filename, config, imported)) retval = false; return retval; @@ -1913,7 +1913,7 @@ bool login_config_read(const char *filename, bool imported) if (!login->config_read_users(filename, &config, imported)) retval = false; - if (!loginlog_config_read("conf/common/inter-server.conf", imported)) // Only inter-server + if (!loginlog->config_read("conf/common/inter-server.conf", imported)) // Only inter-server retval = false; if (!HPM->parse_conf(&config, filename, HPCT_LOGIN, imported)) @@ -1973,24 +1973,24 @@ int do_final(void) login->clear_client_hash_nodes(); login->clear_dnsbl_servers(); - login_log(0, "login server", 100, "login server shutdown"); + loginlog->log(0, "login server", 100, "login server shutdown"); if (login->config->log_login) - loginlog_final(); + loginlog->final(); - ipban_final(); + ipban->final(); - if( account_engine[0].db ) + if (login->dbs->account_engine->db) {// destroy account engine - account_engine[0].db->destroy(account_engine[0].db); - account_engine[0].db = NULL; + login->dbs->account_engine->db->destroy(login->dbs->account_engine->db); + login->dbs->account_engine->db = NULL; } accounts = NULL; // destroyed in account_engine login->online_db->destroy(login->online_db, NULL); login->auth_db->destroy(login->auth_db, NULL); - for( i = 0; i < ARRAYLENGTH(server); ++i ) - chrif_server_destroy(i); + for (i = 0; i < ARRAYLENGTH(login->dbs->server); ++i) + lchrif->server_destroy(i); if( login->fd != -1 ) { @@ -2033,8 +2033,8 @@ void do_shutdown_login(void) core->runflag = LOGINSERVER_ST_SHUTDOWN; ShowStatus("Shutting down...\n"); // TODO proper shutdown procedure; kick all characters, wait for acks, ... [FlavioJS] - for( id = 0; id < ARRAYLENGTH(server); ++id ) - chrif_server_reset(id); + for (id = 0; id < ARRAYLENGTH(login->dbs->server); ++id) + lchrif->server_reset(id); sockt->flush_fifos(); core->runflag = CORE_ST_STOP; } @@ -2094,16 +2094,22 @@ int do_init(int argc, char** argv) { int i; + account_defaults(); + login_defaults(); + // initialize engine (to accept config settings) - account_engine[0].db = account_engine[0].constructor(); - accounts = account_engine[0].db; + login->dbs->account_engine->constructor = account->db_sql; + login->dbs->account_engine->db = login->dbs->account_engine->constructor(); + accounts = login->dbs->account_engine->db; if( accounts == NULL ) { ShowFatalError("do_init: account engine 'sql' not found.\n"); exit(EXIT_FAILURE); } - login_defaults(); + ipban_defaults(); + lchrif_defaults(); lclif_defaults(); + loginlog_defaults(); // read login-server configuration login->config_set_defaults(); @@ -2142,15 +2148,15 @@ int do_init(int argc, char** argv) login->config_read(login->LOGIN_CONF_NAME, false); sockt->net_config_read(login->NET_CONF_NAME); - for( i = 0; i < ARRAYLENGTH(server); ++i ) - chrif_server_init(i); + for (i = 0; i < ARRAYLENGTH(login->dbs->server); ++i) + lchrif->server_init(i); // initialize logging if (login->config->log_login) - loginlog_init(); + loginlog->init(); // initialize static and dynamic ipban system - ipban_init(); + ipban->init(); // Online user database init login->online_db = idb_alloc(DB_OPT_RELEASE_DATA); @@ -2196,18 +2202,23 @@ int do_init(int argc, char** argv) #endif // CONSOLE_INPUT ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %u).\n\n", login->config->login_port); - login_log(0, "login server", 100, "login server started"); + loginlog->log(0, "login server", 100, "login server started"); HPM->event(HPET_READY); return 0; } -void login_defaults(void) { +void login_defaults(void) +{ login = &login_s; login->config = &login_config_; login->accounts = accounts; + login->dbs = &logindbs; + login->dbs->account_engine = &account_engine; + login->dbs->account_engine->constructor = NULL; + login->dbs->account_engine->db = NULL; login->mmo_auth = login_mmo_auth; login->mmo_auth_new = login_mmo_auth_new; @@ -2279,3 +2290,12 @@ void login_defaults(void) { login->LOGIN_CONF_NAME = NULL; login->NET_CONF_NAME = NULL; } + +void lchrif_defaults(void) +{ + lchrif = &lchrif_s; + lchrif->server_init = lchrif_server_init; + lchrif->server_destroy = lchrif_server_destroy; + lchrif->server_reset = lchrif_server_reset; + lchrif->on_disconnect = lchrif_on_disconnect; +} diff --git a/src/login/login.h b/src/login/login.h index 3af54ef50..1a4a6d0a3 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -157,6 +157,11 @@ struct online_login_data { #define MAX_SERVERS 30 +struct s_login_dbs { + struct mmo_char_server server[MAX_SERVERS]; + struct Account_engine *account_engine; +}; + /** * Login.c Interface **/ @@ -166,6 +171,7 @@ struct login_interface { int fd; struct Login_Config *config; struct AccountDB* accounts; + struct s_login_dbs *dbs; int (*mmo_auth) (struct login_session_data* sd, bool isServer); int (*mmo_auth_new) (const char* userid, const char* pass, const char sex, const char* last_ip); @@ -234,12 +240,22 @@ struct login_interface { char *NET_CONF_NAME; ///< Network configuration filename }; -#ifdef HERCULES_CORE -extern struct mmo_char_server server[MAX_SERVERS]; +/** + * Login.c Interface + **/ +struct lchrif_interface { + void (*server_init) (int id); + void (*server_destroy) (int id); + void (*server_reset) (int id); + void (*on_disconnect) (int id); +}; +#ifdef HERCULES_CORE void login_defaults(void); +void lchrif_defaults(void); #endif // HERCULES_CORE HPShared struct login_interface *login; +HPShared struct lchrif_interface *lchrif; #endif /* LOGIN_LOGIN_H */ diff --git a/src/login/loginlog_sql.c b/src/login/loginlog.c index 7dff14990..0e4cc79f0 100644 --- a/src/login/loginlog_sql.c +++ b/src/login/loginlog.c @@ -33,17 +33,10 @@ #include <stdlib.h> // exit -// Sql settings -static char log_db_hostname[32] = "127.0.0.1"; -static uint16 log_db_port = 3306; -static char log_db_username[32] = "ragnarok"; -static char log_db_password[100] = "ragnarok"; -static char log_db_database[32] = "ragnarok"; -static char log_codepage[32] = ""; -static char log_login_db[256] = "loginlog"; -static struct Sql *sql_handle = NULL; -static bool enabled = false; +struct loginlog_interface loginlog_s; +struct loginlog_interface *loginlog; +struct s_loginlog_dbs loginlogdbs; // Returns the number of failed login attempts by the ip in the last minutes. @@ -51,19 +44,19 @@ unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes) { unsigned long failures = 0; - if( !enabled ) + if( !loginlog->enabled ) return 0; - if( SQL_ERROR == SQL->Query(sql_handle, "SELECT count(*) FROM `%s` WHERE `ip` = '%s' AND `rcode` = '1' AND `time` > NOW() - INTERVAL %u MINUTE", - log_login_db, sockt->ip2str(ip,NULL), minutes) )// how many times failed account? in one ip. - Sql_ShowDebug(sql_handle); + if( SQL_ERROR == SQL->Query(loginlog->sql_handle, "SELECT count(*) FROM `%s` WHERE `ip` = '%s' AND `rcode` = '1' AND `time` > NOW() - INTERVAL %u MINUTE", + loginlog->dbs->log_login_db, sockt->ip2str(ip,NULL), minutes) )// how many times failed account? in one ip. + Sql_ShowDebug(loginlog->sql_handle); - if( SQL_SUCCESS == SQL->NextRow(sql_handle) ) + if( SQL_SUCCESS == SQL->NextRow(loginlog->sql_handle) ) { char* data; - SQL->GetData(sql_handle, 0, &data, NULL); + SQL->GetData(loginlog->sql_handle, 0, &data, NULL); failures = strtoul(data, NULL, 10); - SQL->FreeResult(sql_handle); + SQL->FreeResult(loginlog->sql_handle); } return failures; } @@ -73,7 +66,7 @@ unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes) * Records an event in the login log *---------------------------------------------*/ // TODO: add an enum of rcode values -void login_log(uint32 ip, const char* username, int rcode, const char* message) +void loginlog_log(uint32 ip, const char* username, int rcode, const char* message) { char esc_username[NAME_LENGTH*2+1]; char esc_message[255*2+1]; @@ -81,43 +74,43 @@ void login_log(uint32 ip, const char* username, int rcode, const char* message) nullpo_retv(username); nullpo_retv(message); - if( !enabled ) + if( !loginlog->enabled ) return; - SQL->EscapeStringLen(sql_handle, esc_username, username, strnlen(username, NAME_LENGTH)); - SQL->EscapeStringLen(sql_handle, esc_message, message, strnlen(message, 255)); + SQL->EscapeStringLen(loginlog->sql_handle, esc_username, username, strnlen(username, NAME_LENGTH)); + SQL->EscapeStringLen(loginlog->sql_handle, esc_message, message, strnlen(message, 255)); - retcode = SQL->Query(sql_handle, + retcode = SQL->Query(loginlog->sql_handle, "INSERT INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%s', '%s', '%d', '%s')", - log_login_db, sockt->ip2str(ip,NULL), esc_username, rcode, esc_message); + loginlog->dbs->log_login_db, sockt->ip2str(ip,NULL), esc_username, rcode, esc_message); if( retcode != SQL_SUCCESS ) - Sql_ShowDebug(sql_handle); + Sql_ShowDebug(loginlog->sql_handle); } bool loginlog_init(void) { - sql_handle = SQL->Malloc(); + loginlog->sql_handle = SQL->Malloc(); - if (SQL_ERROR == SQL->Connect(sql_handle, log_db_username, log_db_password, - log_db_hostname, log_db_port, log_db_database)) { - Sql_ShowDebug(sql_handle); - SQL->Free(sql_handle); + if (SQL_ERROR == SQL->Connect(loginlog->sql_handle, loginlog->dbs->log_db_username, loginlog->dbs->log_db_password, + loginlog->dbs->log_db_hostname, loginlog->dbs->log_db_port, loginlog->dbs->log_db_database)) { + Sql_ShowDebug(loginlog->sql_handle); + SQL->Free(loginlog->sql_handle); exit(EXIT_FAILURE); } - if (log_codepage[0] != '\0' && SQL_ERROR == SQL->SetEncoding(sql_handle, log_codepage)) - Sql_ShowDebug(sql_handle); + if (loginlog->dbs->log_codepage[0] != '\0' && SQL_ERROR == SQL->SetEncoding(loginlog->sql_handle, loginlog->dbs->log_codepage)) + Sql_ShowDebug(loginlog->sql_handle); - enabled = true; + loginlog->enabled = true; return true; } bool loginlog_final(void) { - SQL->Free(sql_handle); - sql_handle = NULL; + SQL->Free(loginlog->sql_handle); + loginlog->sql_handle = NULL; return true; } @@ -145,7 +138,7 @@ bool loginlog_config_read_names(const char *filename, struct config_t *config, b return false; } - libconfig->setting_lookup_mutable_string(setting, "login_db", log_login_db, sizeof(log_login_db)); + libconfig->setting_lookup_mutable_string(setting, "login_db", loginlog->dbs->log_login_db, sizeof(loginlog->dbs->log_login_db)); return true; } @@ -174,13 +167,13 @@ bool loginlog_config_read_log(const char *filename, struct config_t *config, boo return false; } - libconfig->setting_lookup_mutable_string(setting, "db_hostname", log_db_hostname, sizeof(log_db_hostname)); - libconfig->setting_lookup_mutable_string(setting, "db_database", log_db_database, sizeof(log_db_database)); - libconfig->setting_lookup_mutable_string(setting, "db_username", log_db_username, sizeof(log_db_username)); - libconfig->setting_lookup_mutable_string(setting, "db_password", log_db_password, sizeof(log_db_password)); + libconfig->setting_lookup_mutable_string(setting, "db_hostname", loginlog->dbs->log_db_hostname, sizeof(loginlog->dbs->log_db_hostname)); + libconfig->setting_lookup_mutable_string(setting, "db_database", loginlog->dbs->log_db_database, sizeof(loginlog->dbs->log_db_database)); + libconfig->setting_lookup_mutable_string(setting, "db_username", loginlog->dbs->log_db_username, sizeof(loginlog->dbs->log_db_username)); + libconfig->setting_lookup_mutable_string(setting, "db_password", loginlog->dbs->log_db_password, sizeof(loginlog->dbs->log_db_password)); - libconfig->setting_lookup_uint16(setting, "db_port", &log_db_port); - libconfig->setting_lookup_mutable_string(setting, "codepage", log_codepage, sizeof(log_codepage)); + libconfig->setting_lookup_uint16(setting, "db_port", &loginlog->dbs->log_db_port); + libconfig->setting_lookup_mutable_string(setting, "codepage", loginlog->dbs->log_codepage, sizeof(loginlog->dbs->log_codepage)); return true; } @@ -206,16 +199,16 @@ bool loginlog_config_read(const char *filename, bool imported) if (!libconfig->load_file(&config, filename)) return false; // Error message is already shown by libconfig->load_file - if (!loginlog_config_read_names(filename, &config, imported)) + if (!loginlog->config_read_names(filename, &config, imported)) retval = false; - if (!loginlog_config_read_log(filename, &config, imported)) + if (!loginlog->config_read_log(filename, &config, imported)) retval = false; if (libconfig->lookup_string(&config, "import", &import) == CONFIG_TRUE) { if (strcmp(import, filename) == 0 || strcmp(import, "conf/common/inter-server.conf") == 0) { ShowWarning("inter_config_read: Loop detected! Skipping 'import'...\n"); } else { - if (!loginlog_config_read(import, true)) + if (!loginlog->config_read(import, true)) retval = false; } } @@ -223,3 +216,29 @@ bool loginlog_config_read(const char *filename, bool imported) libconfig->destroy(&config); return retval; } + +void loginlog_defaults(void) +{ + loginlog = &loginlog_s; + loginlog->dbs = &loginlogdbs; + + loginlog->sql_handle = NULL; + loginlog->enabled = false; + + // Sql settings + strcpy(loginlog->dbs->log_db_hostname, "127.0.0.1"); + loginlog->dbs->log_db_port = 3306; + strcpy(loginlog->dbs->log_db_username, "ragnarok"); + strcpy(loginlog->dbs->log_db_password, "ragnarok"); + strcpy(loginlog->dbs->log_db_database, "ragnarok"); + *loginlog->dbs->log_codepage = 0; + strcpy(loginlog->dbs->log_login_db, "loginlog"); + + loginlog->failedattempts = loginlog_failedattempts; + loginlog->log = loginlog_log; + loginlog->init = loginlog_init; + loginlog->final = loginlog_final; + loginlog->config_read_names = loginlog_config_read_names; + loginlog->config_read_log = loginlog_config_read_log; + loginlog->config_read = loginlog_config_read; +} diff --git a/src/login/loginlog.h b/src/login/loginlog.h index 589bc4fa1..fecb9b364 100644 --- a/src/login/loginlog.h +++ b/src/login/loginlog.h @@ -21,15 +21,41 @@ #ifndef LOGIN_LOGINLOG_H #define LOGIN_LOGINLOG_H +#include "common/hercules.h" #include "common/cbasetypes.h" +struct config_t; + +struct s_loginlog_dbs { + char log_db_hostname[32]; + uint16 log_db_port; + char log_db_username[32]; + char log_db_password[100]; + char log_db_database[32]; + char log_codepage[32]; + char log_login_db[256]; +}; + +/** + * Loginlog.c Interface + **/ +struct loginlog_interface { + struct Sql *sql_handle; + bool enabled; + struct s_loginlog_dbs *dbs; + unsigned long (*failedattempts) (uint32 ip, unsigned int minutes); + void (*log) (uint32 ip, const char* username, int rcode, const char* message); + bool (*init) (void); + bool (*final) (void); + bool (*config_read_names) (const char *filename, struct config_t *config, bool imported); + bool (*config_read_log) (const char *filename, struct config_t *config, bool imported); + bool (*config_read) (const char *filename, bool imported); +}; + #ifdef HERCULES_CORE -// TODO: Interface -unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes); -void login_log(uint32 ip, const char* username, int rcode, const char* message); -bool loginlog_init(void); -bool loginlog_final(void); -bool loginlog_config_read(const char *filename, bool imported); +void loginlog_defaults(void); #endif // HERCULES_CORE +HPShared struct loginlog_interface *loginlog; + #endif /* LOGIN_LOGINLOG_H */ diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index 381dbf599..17b4fd813 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -54,6 +54,7 @@ #include "map/channel.h" #include "map/chat.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/clif.h" #include "map/date.h" #include "map/duel.h" @@ -114,21 +115,22 @@ unsigned int atcommand_list_items = 0; bool HPM_map_data_store_validate(enum HPluginDataTypes type, struct hplugin_data_store **storeptr, bool initialize) { switch (type) { - case HPDT_MSD: - case HPDT_NPCD: - case HPDT_MAP: - case HPDT_PARTY: - case HPDT_GUILD: - case HPDT_INSTANCE: - case HPDT_MOBDB: - case HPDT_MOBDATA: - case HPDT_ITEMDATA: - case HPDT_BGDATA: - case HPDT_AUTOTRADE_VEND: - // Initialized by the caller. - return true; - default: - break; + case HPDT_MSD: + case HPDT_NPCD: + case HPDT_MAP: + case HPDT_PARTY: + case HPDT_GUILD: + case HPDT_INSTANCE: + case HPDT_MOBDB: + case HPDT_MOBDATA: + case HPDT_ITEMDATA: + case HPDT_BGDATA: + case HPDT_AUTOTRADE_VEND: + case HPDT_CLAN: + // Initialized by the caller. + return true; + default: + break; } return false; } diff --git a/src/map/Makefile.in b/src/map/Makefile.in index 91efba0ae..e6966d9a2 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -41,14 +41,14 @@ MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o MT19937AR_H = $(MT19937AR_D)/mt19937ar.h MAP_C = atcommand.c battle.c battleground.c buyingstore.c channel.c chat.c \ - chrif.c clif.c date.c duel.c elemental.c guild.c homunculus.c HPMmap.c \ + chrif.c clan.c clif.c date.c duel.c elemental.c guild.c homunculus.c HPMmap.c \ instance.c intif.c irc-bot.c itemdb.c log.c mail.c map.c mapreg_sql.c \ mercenary.c mob.c npc.c npc_chat.c party.c path.c pc.c pc_groups.c \ pet.c quest.c rodex.c script.c searchstore.c skill.c status.c storage.c \ trade.c unit.c vending.c MAP_OBJ = $(addprefix obj_sql/, $(patsubst %c,%o,$(MAP_C))) MAP_H = atcommand.h battle.h battleground.h buyingstore.h channel.h chat.h \ - chrif.h clif.h date.h duel.h elemental.h guild.h homunculus.h HPMmap.h \ + chrif.h clan.h clif.h date.h duel.h elemental.h guild.h homunculus.h HPMmap.h \ instance.h intif.h irc-bot.h itemdb.h log.h mail.h map.h mapreg.h \ mercenary.h mob.h npc.h packets.h packets_keys_main.h packets_keys_zero.h \ packets_shuffle_main.h packets_shuffle_zero.h packets_struct.h party.h \ diff --git a/src/map/atcommand.c b/src/map/atcommand.c index aa25f11d6..cb6428f1f 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -28,6 +28,7 @@ #include "map/channel.h" #include "map/chat.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/clif.h" #include "map/duel.h" #include "map/elemental.h" @@ -950,6 +951,7 @@ ACMD(hide) { //bugreport:2266 map->foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl); } else { + clif->clearunit_area(&sd->bl, CLR_OUTSIGHT); sd->sc.option |= OPTION_INVISIBLE; sd->vd.class = INVISIBLE_CLASS; clif->message(fd, msg_fd(fd,11)); // Invisible: On @@ -1677,6 +1679,45 @@ ACMD(gvgon) /*========================================== * *------------------------------------------*/ +ACMD(cvcoff) +{ + if (!map->list[sd->bl.m].flag.cvc) { + clif->message(fd, msg_fd(fd, 141)); // CvC is already Off. + return false; + } + + map->zone_change2(sd->bl.m, map->list[sd->bl.m].prev_zone); + map->list[sd->bl.m].flag.cvc = 0; + clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); + clif->maptypeproperty2(&sd->bl, ALL_SAMEMAP); + map->foreachinmap(atcommand->stopattack, sd->bl.m, BL_CHAR, 0); + clif->message(fd, msg_fd(fd, 26)); // CvC: Off. + + return true; +} + +/*========================================== + * + *------------------------------------------*/ +ACMD(cvcon) +{ + if (map->list[sd->bl.m].flag.cvc) { + clif->message(fd, msg_fd(fd, 142)); // CvC is already On. + return false; + } + + map->zone_change2(sd->bl.m, strdb_get(map->zone_db, MAP_ZONE_CVC_NAME)); + map->list[sd->bl.m].flag.cvc = 1; + clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE); + clif->maptypeproperty2(&sd->bl, ALL_SAMEMAP); + clif->message(fd, msg_fd(fd, 27)); // CvC: On. + + return true; +} + +/*========================================== + * + *------------------------------------------*/ ACMD(model) { int hair_style = 0, hair_color = 0, cloth_color = 0; @@ -3798,6 +3839,9 @@ ACMD(mapinfo) if (map->list[m_id].flag.battleground) clif->message(fd, msg_fd(fd,1045)); // Battlegrounds ON + if (map->list[m_id].flag.cvc) + clif->message(fd, msg_fd(fd, 139)); // CvC ON + strcpy(atcmd_output,msg_fd(fd,1046)); // PvP Flags: if (map->list[m_id].flag.pvp) strcat(atcmd_output, msg_fd(fd,1047)); // Pvp ON | @@ -7551,11 +7595,11 @@ ACMD(mapflag) { CHECKFLAG(noreturn); CHECKFLAG(monster_noteleport); CHECKFLAG(nosave); CHECKFLAG(nobranch); CHECKFLAG(noexppenalty); CHECKFLAG(pvp); CHECKFLAG(pvp_noparty); CHECKFLAG(pvp_noguild); CHECKFLAG(pvp_nightmaredrop); CHECKFLAG(pvp_nocalcrank); CHECKFLAG(gvg_castle); CHECKFLAG(gvg); - CHECKFLAG(gvg_dungeon); CHECKFLAG(gvg_noparty); CHECKFLAG(battleground); CHECKFLAG(nozenypenalty); - CHECKFLAG(notrade); CHECKFLAG(noskill); CHECKFLAG(nowarp); CHECKFLAG(nowarpto); - CHECKFLAG(noicewall); CHECKFLAG(snow); CHECKFLAG(clouds); CHECKFLAG(clouds2); - CHECKFLAG(fog); CHECKFLAG(fireworks); CHECKFLAG(sakura); CHECKFLAG(leaves); - CHECKFLAG(nobaseexp); + CHECKFLAG(gvg_dungeon); CHECKFLAG(gvg_noparty); CHECKFLAG(battleground); CHECKFLAG(cvc); + CHECKFLAG(nozenypenalty); CHECKFLAG(notrade); CHECKFLAG(noskill); CHECKFLAG(nowarp); + CHECKFLAG(nowarpto); CHECKFLAG(noicewall); CHECKFLAG(snow); CHECKFLAG(clouds); + CHECKFLAG(clouds2); CHECKFLAG(fog); CHECKFLAG(fireworks); CHECKFLAG(sakura); + CHECKFLAG(leaves); CHECKFLAG(nobaseexp); CHECKFLAG(nojobexp); CHECKFLAG(nomobloot); CHECKFLAG(nomvploot); CHECKFLAG(nightenabled); CHECKFLAG(nodrop); CHECKFLAG(novending); CHECKFLAG(loadevent); CHECKFLAG(nochat); CHECKFLAG(partylock); CHECKFLAG(guildlock); CHECKFLAG(src4instance); @@ -7567,48 +7611,53 @@ ACMD(mapflag) { } for (i = 0; flag_name[i]; i++) flag_name[i] = TOLOWER(flag_name[i]); //lowercase - if (strcmp( flag_name , "gvg" ) == 0) { - if( flag && !map->list[sd->bl.m].flag.gvg ) - map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)); - else if ( !flag && map->list[sd->bl.m].flag.gvg ) - map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); - } else if ( strcmp( flag_name , "pvp" ) == 0 ) { - if ( flag && !map->list[sd->bl.m].flag.pvp ) - map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)); - else if ( !flag && map->list[sd->bl.m].flag.pvp ) - map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); - } else if ( strcmp( flag_name , "battleground" ) == 0 ) { - if ( flag && !map->list[sd->bl.m].flag.battleground ) - map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_BG_NAME)); - else if ( !flag && map->list[sd->bl.m].flag.battleground ) - map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); + if (strcmp(flag_name, "gvg") == 0) { + if (flag && !map->list[sd->bl.m].flag.gvg) + map->zone_change2(sd->bl.m, strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)); + else if (!flag && map->list[sd->bl.m].flag.gvg) + map->zone_change2(sd->bl.m, map->list[sd->bl.m].prev_zone); + } else if (strcmp(flag_name, "pvp") == 0) { + if (flag && !map->list[sd->bl.m].flag.pvp) + map->zone_change2(sd->bl.m, strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)); + else if (!flag && map->list[sd->bl.m].flag.pvp) + map->zone_change2(sd->bl.m, map->list[sd->bl.m].prev_zone); + } else if (strcmp(flag_name, "battleground") == 0) { + if (flag && !map->list[sd->bl.m].flag.battleground) + map->zone_change2(sd->bl.m, strdb_get(map->zone_db, MAP_ZONE_BG_NAME)); + else if (!flag && map->list[sd->bl.m].flag.battleground) + map->zone_change2(sd->bl.m, map->list[sd->bl.m].prev_zone); + } else if (strcmp(flag_name, "cvc") == 0) { + if (flag && !map->list[sd->bl.m].flag.cvc) + map->zone_change2(sd->bl.m, strdb_get(map->zone_db, MAP_ZONE_CVC_NAME)); + else if (!flag && map->list[sd->bl.m].flag.cvc) + map->zone_change2(sd->bl.m, map->list[sd->bl.m].prev_zone); } SETFLAG(autotrade); SETFLAG(allowks); SETFLAG(nomemo); SETFLAG(noteleport); SETFLAG(noreturn); SETFLAG(monster_noteleport); SETFLAG(nosave); SETFLAG(nobranch); SETFLAG(noexppenalty); SETFLAG(pvp); SETFLAG(pvp_noparty); SETFLAG(pvp_noguild); SETFLAG(pvp_nightmaredrop); SETFLAG(pvp_nocalcrank); SETFLAG(gvg_castle); SETFLAG(gvg); - SETFLAG(gvg_dungeon); SETFLAG(gvg_noparty); SETFLAG(battleground); SETFLAG(nozenypenalty); - SETFLAG(notrade); SETFLAG(noskill); SETFLAG(nowarp); SETFLAG(nowarpto); - SETFLAG(noicewall); SETFLAG(snow); SETFLAG(clouds); SETFLAG(clouds2); - SETFLAG(fog); SETFLAG(fireworks); SETFLAG(sakura); SETFLAG(leaves); - SETFLAG(nobaseexp); - SETFLAG(nojobexp); SETFLAG(nomobloot); SETFLAG(nomvploot); SETFLAG(nightenabled); - SETFLAG(nodrop); SETFLAG(novending); SETFLAG(loadevent); - SETFLAG(nochat); SETFLAG(partylock); SETFLAG(guildlock); SETFLAG(src4instance); - SETFLAG(notomb); SETFLAG(nocashshop); SETFLAG(noviewid); - - clif->message(sd->fd,msg_fd(fd,1314)); // Invalid flag name or flag. - clif->message(sd->fd,msg_fd(fd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On) - clif->message(sd->fd,msg_fd(fd,1315)); // Available Flags: - clif->message(sd->fd,"----------------------------------"); - clif->message(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,"); - clif->message(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,"); - clif->message(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,"); - clif->message(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,"); - clif->message(sd->fd,"fog, fireworks, sakura, leaves, nobaseexp, nojobexp, nomobloot,"); - clif->message(sd->fd,"nomvploot, nightenabled, nodrop, novending, loadevent, nochat, partylock,"); - clif->message(sd->fd,"guildlock, src4instance, notomb, nocashshop, noviewid"); + SETFLAG(gvg_dungeon); SETFLAG(gvg_noparty); SETFLAG(battleground); SETFLAG(cvc); + SETFLAG(nozenypenalty); SETFLAG(notrade); SETFLAG(noskill); SETFLAG(nowarp); + SETFLAG(nowarpto); SETFLAG(noicewall); SETFLAG(snow); SETFLAG(clouds); + SETFLAG(clouds2); SETFLAG(fog); SETFLAG(fireworks); SETFLAG(sakura); + SETFLAG(leaves); SETFLAG(nobaseexp); SETFLAG(nojobexp); SETFLAG(nomobloot); + SETFLAG(nomvploot); SETFLAG(nightenabled); SETFLAG(nodrop); SETFLAG(novending); + SETFLAG(loadevent); SETFLAG(nochat); SETFLAG(partylock); SETFLAG(guildlock); + SETFLAG(src4instance); SETFLAG(notomb); SETFLAG(nocashshop); SETFLAG(noviewid); + + + clif->message(sd->fd, msg_fd(fd, 1314)); // Invalid flag name or flag. + clif->message(sd->fd, msg_fd(fd, 1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On) + clif->message(sd->fd, msg_fd(fd, 1315)); // Available Flags: + clif->message(sd->fd, "----------------------------------"); + clif->message(sd->fd, "town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,"); + clif->message(sd->fd, "nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,"); + clif->message(sd->fd, "pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground, cvc,"); + clif->message(sd->fd, "nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,"); + clif->message(sd->fd, "fog, fireworks, sakura, leaves, nobaseexp, nojobexp, nomobloot,"); + clif->message(sd->fd, "nomvploot, nightenabled, nodrop, novending, loadevent, nochat, partylock,"); + clif->message(sd->fd, "guildlock, src4instance, notomb, nocashshop, noviewid"); #undef CHECKFLAG #undef SETFLAG @@ -8424,7 +8473,7 @@ void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommand } } if (count_bind > 0) - clif->message(fd, line_buff); // Last Line + clif->message(fd, line_buff); // Last Line count += count_bind; } @@ -9451,6 +9500,139 @@ ACMD(lang) { return true; } + +ACMD(claninfo) +{ + struct DBIterator *iter = db_iterator(clan->db); + struct clan *c; + int i, count; + + for (c = dbi_first(iter); dbi_exists(iter); c = dbi_next(iter)) { + safesnprintf(atcmd_output, sizeof(atcmd_output), "Clan #%d:", c->clan_id); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Name: %s", c->name); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Constant: %s", c->constant); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Master: %s", c->master); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Map: %s", c->map); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Max Member: %d", c->max_member); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Kick Time: %dh", c->kick_time / 3600); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Check Time: %dh", c->check_time / 3600000); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Connected Members: %d", c->connect_member); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Total Members: %d", c->member_count); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Allies: %d", VECTOR_LENGTH(c->allies)); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + count = 0; + for (i = 0; i < VECTOR_LENGTH(c->allies); i++) { + struct clan_relationship *ally = &VECTOR_INDEX(c->allies, i); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- - Ally #%d (Id: %d): %s", i + 1, ally->clan_id, ally->constant); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + count++; + } + + if (count == 0) { + clif->messagecolor_self(fd, COLOR_DEFAULT, "- - No Allies Found!"); + } + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Antagonists: %d", VECTOR_LENGTH(c->antagonists)); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + count = 0; + for (i = 0; i < VECTOR_LENGTH(c->antagonists); i++) { + struct clan_relationship *antagonist = &VECTOR_INDEX(c->antagonists, i); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- - Antagonist #%d (Id: %d): %s", i + 1, antagonist->clan_id, antagonist->constant); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + count++; + } + + if (count == 0) { + clif->messagecolor_self(fd, COLOR_DEFAULT, "- - No Antagonists Found!"); + } + + clif->messagecolor_self(fd, COLOR_DEFAULT, "============================"); + } + dbi_destroy(iter); + return true; +} + +/** + * Clan System: Joins in the given clan + */ +ACMD(joinclan) +{ + int clan_id; + + if (*message == '\0') { + clif->message(fd, "Please enter a Clan ID (usage: @joinclan <clan ID>)."); + return false; + } + if (sd->status.clan_id != 0) { + clif->messagecolor_self(fd, COLOR_RED, "You are already in a clan."); + return false; + } else if (sd->status.guild_id != 0) { + clif->messagecolor_self(fd, COLOR_RED, "You must leave your guild before enter in a clan."); + return false; + } + + clan_id = atoi(message); + if (clan_id <= 0) { + clif->messagecolor_self(fd, COLOR_RED, "Invalid Clan ID."); + return false; + } + if (!clan->join(sd, clan_id)) { + clif->messagecolor_self(fd, COLOR_RED, "The clan couldn't be joined."); + return false; + } + return true; +} + +/** + * Clan System: Leaves current clan + */ +ACMD(leaveclan) +{ + if (sd->status.clan_id == 0) { + clif->messagecolor_self(fd, COLOR_RED, "You aren't in a clan."); + return false; + } + if (!clan->leave(sd, false)) { + clif->messagecolor_self(fd, COLOR_RED, "Failed on leaving clan."); + return false; + } + return true; +} + +/** + * Clan System: Reloads clan db + */ +ACMD(reloadclans) +{ + clan->reload(); + clif->messagecolor_self(fd, COLOR_DEFAULT, "Clan configuration and database have been reloaded."); + return true; +} + /** * Fills the reference of available commands in atcommand DBMap **/ @@ -9723,6 +9905,12 @@ void atcommand_basecommands(void) { ACMD_DEF(cddebug), ACMD_DEF(lang), ACMD_DEF(bodystyle), + ACMD_DEF(cvcoff), + ACMD_DEF(cvcon), + ACMD_DEF(claninfo), + ACMD_DEF(joinclan), + ACMD_DEF(leaveclan), + ACMD_DEF(reloadclans), }; int i; diff --git a/src/map/battle.c b/src/map/battle.c index 70ebc4a08..bd7e31d05 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -25,6 +25,7 @@ #include "map/battleground.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/clif.h" #include "map/elemental.h" #include "map/guild.h" @@ -6774,14 +6775,17 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f return (flag&state)?1:-1; } - if( map_flag_vs(m) ) { + if (map_flag_vs(m)) { //Check rivalry settings. - int sbg_id = 0, tbg_id = 0; - if( map->list[m].flag.battleground ) { + int sbg_id = 0, tbg_id = 0, s_clan = 0, t_clan = 0; + if (map->list[m].flag.battleground) { sbg_id = bg->team_get_id(s_bl); tbg_id = bg->team_get_id(t_bl); + } else if (map->list[m].flag.cvc) { + s_clan = clan->get_id(s_bl); + t_clan = clan->get_id(t_bl); } - if( flag&(BCT_PARTY|BCT_ENEMY) ) { + if (flag & (BCT_PARTY | BCT_ENEMY)) { int s_party = status->get_party_id(s_bl); int s_guild = status->get_guild_id(s_bl); int t_guild = status->get_guild_id(t_bl); @@ -6791,10 +6795,12 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if (s_guild != 0 && t_guild != 0 && (s_guild == t_guild || guild->isallied(s_guild, t_guild))) state |= BCT_PARTY; else - state |= flag&BCT_ENEMY ? BCT_ENEMY : BCT_PARTY; + state |= flag & BCT_ENEMY ? BCT_ENEMY : BCT_PARTY; } else if (!(map->list[m].flag.pvp && map->list[m].flag.pvp_noparty) && (!map->list[m].flag.battleground || sbg_id == tbg_id)) { state |= BCT_PARTY; + } else if (!map->list[m].flag.cvc || s_clan == t_clan) { + state |= BCT_PARTY; } else { state |= BCT_ENEMY; } @@ -6802,18 +6808,22 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f state |= BCT_ENEMY; } } - if( flag&(BCT_GUILD|BCT_ENEMY) ) { + if (flag & (BCT_GUILD | BCT_ENEMY)) { int s_guild = status->get_guild_id(s_bl); int t_guild = status->get_guild_id(t_bl); - if( !(map->list[m].flag.pvp && map->list[m].flag.pvp_noguild) + if (!(map->list[m].flag.pvp && map->list[m].flag.pvp_noguild) && s_guild && t_guild - && (s_guild == t_guild || (!(flag&BCT_SAMEGUILD) && guild->isallied(s_guild, t_guild))) - && (!map->list[m].flag.battleground || sbg_id == tbg_id) ) + && (s_guild == t_guild || (!(flag & BCT_SAMEGUILD) && guild->isallied(s_guild, t_guild))) + && (!map->list[m].flag.battleground || sbg_id == tbg_id) + && (!map->list[m].flag.cvc || s_clan == t_clan) + ) { state |= BCT_GUILD; - else + } else { state |= BCT_ENEMY; + } } - if( state&BCT_ENEMY && map->list[m].flag.battleground && sbg_id && sbg_id == tbg_id ) + + if (state & BCT_ENEMY && ((map->list[m].flag.battleground && sbg_id && sbg_id == tbg_id) || (map->list[m].flag.cvc && s_clan && s_clan == t_clan))) state &= ~BCT_ENEMY; if (state&BCT_ENEMY && battle_config.pk_mode && !map_flag_gvg(m) && s_bl->type == BL_PC && t_bl->type == BL_PC) { @@ -7299,7 +7309,7 @@ static const struct battle_data { { "max_body_style", &battle_config.max_body_style, 4, 0, SHRT_MAX, }, { "save_body_style", &battle_config.save_body_style, 0, 0, 1, }, { "player_warp_keep_direction", &battle_config.player_warp_keep_direction, 0, 0, 1, }, - { "atcommand_levelup_events", &battle_config.atcommand_levelup_events, 0, 0, 1, }, + { "atcommand_levelup_events", &battle_config.atcommand_levelup_events, 0, 0, 1, }, { "bow_unequip_arrow", &battle_config.bow_unequip_arrow, 1, 0, 1, }, { "max_summoner_parameter", &battle_config.max_summoner_parameter, 120, 10, 10000, }, { "mvp_exp_reward_message", &battle_config.mvp_exp_reward_message, 0, 0, 1, }, diff --git a/src/map/battle.h b/src/map/battle.h index 429249dca..8b7fea29f 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -546,7 +546,7 @@ struct Battle_Config { // Warp Face Direction int player_warp_keep_direction; - int atcommand_levelup_events; // Enable atcommands trigger level up events for NPCs + int atcommand_levelup_events; // Enable atcommands trigger level up events for NPCs int bow_unequip_arrow; diff --git a/src/map/clan.c b/src/map/clan.c new file mode 100644 index 000000000..865f5a4cd --- /dev/null +++ b/src/map/clan.c @@ -0,0 +1,1074 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2017 Hercules Dev Team + * + * Hercules is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#define HERCULES_CORE + +#include "config/core.h" +#include "clan.h" + +#include "map/clif.h" +#include "map/chrif.h" +#include "map/homunculus.h" +#include "map/intif.h" +#include "map/log.h" +#include "map/mercenary.h" +#include "map/mob.h" +#include "map/npc.h" +#include "map/pc.h" +#include "map/pet.h" +#include "map/script.h" +#include "map/skill.h" +#include "map/status.h" +#include "common/HPM.h" +#include "common/conf.h" +#include "common/cbasetypes.h" +#include "common/db.h" +#include "common/memmgr.h" +#include "common/mapindex.h" +#include "common/nullpo.h" +#include "common/showmsg.h" +#include "common/socket.h" +#include "common/strlib.h" +#include "common/timer.h" +#include "common/utils.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +struct clan_interface clan_s; +struct clan_interface *clan; + +/** + * Searches a Clan by clan_id + * + * @param clan_id Clan ID + * @return struct clan* + */ +struct clan *clan_search(int clan_id) +{ + if (clan_id <= 0) { + return NULL; + } + return (struct clan *)idb_get(clan->db, clan_id); +} + +/** + * Searches a Clan by clan_name or constant + * + * @param name Clan Name + * @return struct clan* + */ +struct clan *clan_searchname(const char *name) +{ + struct clan *c; + struct DBIterator *iter; + + nullpo_retr(NULL, name); + + iter = db_iterator(clan->db); + for (c = dbi_first(iter); dbi_exists(iter); c = dbi_next(iter)) { + if (strncmpi(c->name, name, NAME_LENGTH) == 0 || strncmpi(c->constant, name, NAME_LENGTH) == 0) { + break; + } + } + dbi_destroy(iter); + return c; +} + +/** + * Returns the first online character of clan + * + * @param (struct clan *) c clan structure + * @return (struct map_session_data *) + */ +struct map_session_data *clan_getonlinesd(struct clan *c) +{ + int i; + nullpo_retr(NULL, c); + + ARR_FIND(0, VECTOR_LENGTH(c->members), i, (VECTOR_INDEX(c->members, i).sd != NULL && VECTOR_INDEX(c->members, i).online == 1)); + return (i < VECTOR_LENGTH(c->members)) ? VECTOR_INDEX(c->members, i).sd : NULL; +} + +/** + * Returns the member index of given Player + * + * @param c Clan Data + * @param char_id Player's Char ID + * @return int + */ +int clan_getindex(const struct clan *c, int char_id) +{ + int i; + nullpo_retr(INDEX_NOT_FOUND, c); + + ARR_FIND(0, VECTOR_LENGTH(c->members), i, VECTOR_INDEX(c->members, i).char_id == char_id); + + if (i == VECTOR_LENGTH(c->members)) { + return INDEX_NOT_FOUND; + } + return i; +} + +/** + * Starts clan buff + */ +void clan_buff_start(struct map_session_data *sd, struct clan *c) +{ + nullpo_retv(sd); + nullpo_retv(c); + + if (c->buff.icon <= 0) { + return; + } + + clif->sc_load(&sd->bl, sd->bl.id, SELF, c->buff.icon, 0, c->clan_id, 0); + script->run(c->buff.script, 0, sd->bl.id, npc->fake_nd->bl.id); +} + +/** + * Ends clan buff + */ +void clan_buff_end(struct map_session_data *sd, struct clan *c) +{ + nullpo_retv(sd); + nullpo_retv(c); + + if (c->buff.icon <= 0) { + return; + } + + clif->sc_end(&sd->bl, sd->bl.id, SELF, c->buff.icon); +} + +/** + * Joins a Player into a Clan + * + * @param sd Player's Map Session Data + * @param clan_id Clan which will add this player + * @return bool + */ +bool clan_join(struct map_session_data *sd, int clan_id) +{ + struct clan *c; + struct clan_member m; + + nullpo_ret(sd); + + // Already joined a guild or clan + if (sd->status.guild_id > 0 || sd->guild != NULL) { + ShowError("clan_join: Player already joined in a guild. char_id: %d\n", sd->status.char_id); + return false; + } else if ( sd->status.clan_id > 0 || sd->clan != NULL) { + ShowError("clan_join: Player already joined in a clan. char_id: %d\n", sd->status.char_id); + return false; + } + + c = clan->search(clan_id); + if (c == NULL) { + ShowError("clan_join: Invalid Clan ID: %d\n", clan_id); + return false; + } + + if (!c->received) { + return false; + } + + if (clan->getindex(c, sd->status.char_id) != INDEX_NOT_FOUND) { + ShowError("clan_join: Player already joined this clan. char_id: %d clan_id: %d\n", sd->status.char_id, clan_id); + return false; + } + + if (VECTOR_LENGTH(c->members) >= c->max_member || c->member_count >= c->max_member) { + ShowError("clan_join: Clan '%s' already reached its max capacity!\n", c->name); + return false; + } + + VECTOR_ENSURE(c->members, 1, 1); + + m.sd = sd; + m.char_id = sd->status.char_id; + m.online = 1; + m.last_login = sd->status.last_login; + VECTOR_PUSH(c->members, m); + + c->connect_member++; + c->member_count++; + + sd->status.clan_id = c->clan_id; + sd->clan = c; + + sc_start2(NULL, &sd->bl, SC_CLAN_INFO, 10000, 0, c->clan_id, INFINITE_DURATION); + status_calc_pc(sd, SCO_FORCE); + + chrif->save(sd, 0); + clif->clan_basicinfo(sd); + clif->clan_onlinecount(c); + return true; +} + +/** + * Invoked when a player joins + * It assumes that clan_id is not 0 + * + * @param sd Player Data + */ +void clan_member_online(struct map_session_data *sd, bool first) +{ + struct clan *c; + int i, inactivity; + nullpo_retv(sd); + + // For invalid values we must reset it to 0 (no clan) + if (sd->status.clan_id < 0) { + ShowError("clan_member_online: Invalid clan id, changing to '0'. clan_id='%d' char_id='%d'\n", sd->status.clan_id, sd->status.char_id); + sd->status.clan_id = 0; + return; + } + + c = clan->search(sd->status.clan_id); + if (c == NULL) { + // This is a silent return because it will reset clan_id in case + // a custom clan that was removed and this is a remaining member + sd->status.clan_id = 0; + sd->clan = NULL; + if (!first) { + status_change_end(&sd->bl, SC_CLAN_INFO, INVALID_TIMER); // Remove the status + status_calc_pc(sd, SCO_FORCE); + } + clif->clan_leave(sd); + return; + } + + if (!c->received) { + return; + } + + if (c->max_member <= c->member_count || VECTOR_LENGTH(c->members) >= c->max_member) { + ShowError("Clan System: More members than the maximum allowed in clan #%d\n", c->clan_id); + return; + } + + i = clan->getindex(c, sd->status.char_id); + inactivity = (int)(time(NULL) - sd->status.last_login); + if (i == INDEX_NOT_FOUND) { + struct clan_member m; + + if (c->kick_time > 0 && inactivity > c->kick_time) { + sd->status.clan_id = 0; + sd->clan = NULL; + clan->buff_end(sd, c); + status_change_end(&sd->bl, SC_CLAN_INFO, INVALID_TIMER); + clif->clan_leave(sd); + return; + } + + VECTOR_ENSURE(c->members, 1, 1); + + m.sd = sd; + m.char_id = sd->status.char_id; + m.online = 1; + m.last_login = sd->status.last_login; + VECTOR_PUSH(c->members, m); + } else { + struct clan_member *m = &VECTOR_INDEX(c->members, i); + + + if (c->kick_time > 0 && inactivity > c->kick_time) { + if (m->online == 1) { + m->online = 0; + m->sd = NULL; + c->connect_member--; + c->member_count--; + } + clan->buff_end(sd, c); + sd->status.clan_id = 0; + sd->clan = NULL; + status_change_end(&sd->bl, SC_CLAN_INFO, INVALID_TIMER); + VECTOR_ERASE(c->members, i); + clif->clan_leave(sd); + return; + } + + m->sd = sd; + m->online = 1; + m->last_login = sd->status.last_login; + } + + sd->clan = c; + c->connect_member++; + + sc_start2(NULL, &sd->bl, SC_CLAN_INFO, 10000, 0, c->clan_id, INFINITE_DURATION); + + if (!first) { + // When first called from pc.c we don't need to do status_calc + status_calc_pc(sd, SCO_FORCE); + } + + clif->clan_basicinfo(sd); + clif->clan_onlinecount(c); +} + +/** + * Re-join a player on its clan + */ +int clan_rejoin(struct map_session_data *sd, va_list ap) +{ + nullpo_ret(sd); + + if (sd->status.clan_id != 0) { + // Note: Even if the value is invalid (lower than zero) + // the function will fix the invalid value + clan->member_online(sd, false); + } + return 0; +} + +/** + * Removes Player from clan + */ +bool clan_leave(struct map_session_data *sd, bool first) +{ + int i; + struct clan *c; + + nullpo_ret(sd); + + c = sd->clan; + + if (c == NULL) { + return false; + } + + if (!c->received) { + return false; + } + + i = clan->getindex(c, sd->status.char_id); + if (i != INDEX_NOT_FOUND) { + VECTOR_ERASE(c->members, i); + c->connect_member--; + c->member_count--; + } + + sd->status.clan_id = 0; + sd->clan = NULL; + clan->buff_end(sd, c); + + status_change_end(&sd->bl, SC_CLAN_INFO, INVALID_TIMER); + if (!first) { + status_calc_pc(sd, SCO_FORCE); + } + + chrif->save(sd, 0); + clif->clan_onlinecount(c); + clif->clan_leave(sd); + return true; +} + +/** + * Sets a player offline + * + * @param (struct map_session_data *) sd Player Data + */ +void clan_member_offline(struct map_session_data *sd) +{ + struct clan *c; + int i; + + nullpo_retv(sd); + + c = sd->clan; + + if (c == NULL) { + return; + } + + i = clan->getindex(c, sd->status.char_id); + if (i != INDEX_NOT_FOUND && VECTOR_INDEX(c->members, i).online == 1) { + // Only if it is online, because unit->free is called twice + VECTOR_INDEX(c->members, i).online = 0; + VECTOR_INDEX(c->members, i).sd = NULL; + c->connect_member--; + } + clif->clan_onlinecount(c); +} + + +/** + * Sends a message to the whole clan + */ +bool clan_send_message(struct map_session_data *sd, const char *mes) +{ + int len; + nullpo_retr(false, sd); + nullpo_retr(false, mes); + + len = (int)strlen(mes); + + if (sd->status.clan_id == 0) { + return false; + } + clan->recv_message(sd->clan, mes, len); + + // Chat logging type 'C' / Clan Chat + logs->chat(LOG_CHAT_CLAN, sd->status.clan_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, mes); + + return true; +} + +/** + * Clan receive a message, will be displayed to whole clan + */ +void clan_recv_message(struct clan *c, const char *mes, int len) +{ + clif->clan_message(c, mes, len); +} + +/** + * Set constants for each clan + */ +void clan_set_constants(void) +{ + struct DBIterator *iter = db_iterator(clan->db); + struct clan *c; + + for (c = dbi_first(iter); dbi_exists(iter); c = dbi_next(iter)) { + script->set_constant2(c->constant, c->clan_id, false, false); + } + + dbi_destroy(iter); +} + +/** + * Returns the clan_id of bl + */ +int clan_get_id(const struct block_list *bl) +{ + nullpo_ret(bl); + + switch (bl->type) { + case BL_PC: { + const struct map_session_data *sd = BL_UCCAST(BL_PC, bl); + return sd->status.clan_id; + } + case BL_NPC: { + const struct npc_data *nd = BL_UCCAST(BL_NPC, bl); + return nd->clan_id; + } + case BL_PET: { + const struct pet_data *pd = BL_UCCAST(BL_PET, bl); + if (pd->msd != NULL) + return pd->msd->status.clan_id; + } + break; + case BL_MOB: { + const struct mob_data *md = BL_UCCAST(BL_MOB, bl); + const struct map_session_data *msd; + if (md->special_state.ai != AI_NONE && (msd = map->id2sd(md->master_id)) != NULL) { + return msd->status.clan_id; + } + return md->clan_id; + } + case BL_HOM: { + const struct homun_data *hd = BL_UCCAST(BL_HOM, bl); + if (hd->master != NULL) { + return hd->master->status.clan_id; + } + } + break; + case BL_MER: { + const struct mercenary_data *md = BL_UCCAST(BL_MER, bl); + if (md->master != NULL) { + return md->master->status.clan_id; + } + } + break; + case BL_SKILL: { + const struct skill_unit *su = BL_UCCAST(BL_SKILL, bl); + if (su->group != NULL) + return su->group->clan_id; + } + break; + } + + return 0; +} + +/** + * Checks every clan player and remove those who are inactive + */ +int clan_inactivity_kick(int tid, int64 tick, int id, intptr_t data) +{ + struct clan *c = NULL; + int i; + + if ((c = clan->search(id)) != NULL) { + if (!c->kick_time || c->tid != tid || tid == INVALID_TIMER || c->tid == INVALID_TIMER) { + ShowError("Timer Mismatch (Time: %d seconds) %d != %d", c->kick_time, c->tid, tid); + Assert_report(0); + return 0; + } + for (i = 0; i < VECTOR_LENGTH(c->members); i++) { + struct clan_member *m = &VECTOR_INDEX(c->members, i); + if (m->char_id <= 0 || m->online <= 0) + continue; + + if (m->online) { + struct map_session_data *sd = m->sd; + if (DIFF_TICK32(sockt->last_tick, sd->idletime) > c->kick_time) { + clan->leave(sd, false); + } + } else if ((time(NULL) - m->last_login) > c->kick_time) { + VECTOR_ERASE(c->members, i); + c->member_count--; + clif->clan_onlinecount(c); + } + } + //Perform the kick for offline members that didn't connect after a server restart + c->received = false; + intif->clan_kickoffline(c->clan_id, c->kick_time); + c->tid = timer->add(timer->gettick() + c->check_time, clan->inactivity_kick, c->clan_id, 0); + } + return 1; +} + +/** + * Timeout for the request of offline kick + */ +int clan_request_kickoffline(int tid, int64 tick, int id, intptr_t data) +{ + struct clan *c = NULL; + + if ((c = clan->search(id)) != NULL) { + if (c->req_kick_tid != tid || c->req_kick_tid == INVALID_TIMER) { + ShowError("Timer Mismatch %d != %d", c->tid, tid); + return 0; + } + + if (c->received) { + c->req_kick_tid = INVALID_TIMER; + return 1; + } + + intif->clan_kickoffline(c->clan_id, c->kick_time); + c->req_kick_tid = timer->add(timer->gettick() + clan->req_timeout, clan->request_kickoffline, c->clan_id, 0); + } + return 1; +} + +/** + * Timeout of the request for counting members + */ +int clan_request_membercount(int tid, int64 tick, int id, intptr_t data) +{ + struct clan *c = NULL; + + if ((c = clan->search(id)) != NULL) { + if (c->req_count_tid != tid || c->req_count_tid == INVALID_TIMER) { + ShowError("Timer Mismatch %d != %d", c->tid, tid); + return 0; + } + + if (c->received) { + c->req_count_tid = INVALID_TIMER; + return 1; + } + + intif->clan_membercount(c->clan_id, c->kick_time); + c->req_count_tid = timer->add(timer->gettick() + clan->req_timeout, clan->request_membercount, c->clan_id, 0); + } + return 1; +} + +/** + * Processes any (plugin-defined) additional fields for a clan entry. + * + * @param[in, out] entry The destination clan entry, already initialized (clan_id is expected to be already set). + * @param[in] t The libconfig entry. + * @param[in] n Ordinal number of the entry, to be displayed in case of validation errors. + * @param[in] source Source of the entry (file name), to be displayed in case of validation errors. + */ +void clan_read_db_additional_fields(struct clan *entry, struct config_setting_t *t, int n, const char *source) +{ + // do nothing. plugins can do own work +} + +void clan_read_buffs(struct clan *c, struct config_setting_t *buff, const char *source) +{ + struct clan_buff *b; + const char *str = NULL; + + nullpo_retv(c); + nullpo_retv(buff); + + b = &c->buff; + + if (!libconfig->setting_lookup_int(buff, "Icon", &b->icon)) { + const char *temp_str = NULL; + if (libconfig->setting_lookup_string(buff, "Icon", &temp_str)) { + if (*temp_str && !script->get_constant(temp_str, &b->icon)) { + ShowWarning("Clan %d: Invalid Buff icon value. Defaulting to SI_BLANK.\n", c->clan_id); + b->icon = -1; // SI_BLANK + } + } + } + + if (libconfig->setting_lookup_string(buff, "Script", &str)) { + b->script = *str ? script->parse(str, source, -b->icon, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL; + } +} + +/** + * Processes one clandb entry from the libconfig file, loading and inserting it + * into the clan database. + * + * @param settings Libconfig setting entry. It is expected to be valid and it + * won't be freed (it is care of the caller to do so if + * necessary). + * @param source Source of the entry (file name), to be displayed in case of + * validation errors. + * @return int. + */ +int clan_read_db_sub(struct config_setting_t *settings, const char *source, bool reload) +{ + int total, s, valid = 0; + + nullpo_retr(false, settings); + + total = libconfig->setting_length(settings); + + for (s = 0; s < total; s++) { + struct clan *c; + struct config_setting_t *cl, *buff, *allies, *antagonists; + const char *aName, *aLeader, *aMap, *aConst; + int max_members, kicktime = 0, kickchecktime = 0, id, i, j; + + cl = libconfig->setting_get_elem(settings, s); + + if (libconfig->setting_lookup_int(cl, "Id", &id)) { + if (id <= 0) { + ShowError("clan_read_db: Invalid Clan Id %d, skipping...\n", id); + return false; + } + + if (clan->search(id) != NULL) { + ShowError("clan_read_db: Duplicate entry for Clan Id %d, skipping...\n", id); + return false; + } + } else { + ShowError("clan_read_db: failed to find 'Id' for clan #%d\n", s); + return false; + } + + if (libconfig->setting_lookup_string(cl, "Const", &aConst)) { + if (!*aConst) { + ShowError("clan_read_db: Invalid Clan Const '%s', skipping...\n", aConst); + return false; + } + + if (strlen(aConst) > NAME_LENGTH) { + ShowError("clan_read_db: Clan Name '%s' is longer than %d characters, skipping...\n", aConst, NAME_LENGTH); + return false; + } + + if (clan->searchname(aConst) != NULL) { + ShowError("clan_read_db: Duplicate entry for Clan Const '%s', skipping...\n", aConst); + return false; + } + } else { + ShowError("clan_read_db: failed to find 'Const' for clan #%d\n", s); + return false; + } + + if (libconfig->setting_lookup_string(cl, "Name", &aName)) { + if (!*aName) { + ShowError("clan_read_db: Invalid Clan Name '%s', skipping...\n", aName); + return false; + } + + if (strlen(aName) > NAME_LENGTH) { + ShowError("clan_read_db: Clan Name '%s' is longer than %d characters, skipping...\n", aName, NAME_LENGTH); + return false; + } + + if (clan->searchname(aName) != NULL) { + ShowError("clan_read_db: Duplicate entry for Clan Name '%s', skipping...\n", aName); + return false; + } + } else { + ShowError("clan_read_db: failed to find 'Name' for clan #%d\n", s); + return false; + } + + if (!libconfig->setting_lookup_string(cl, "Leader", &aLeader)) { + ShowError("clan_read_db: failed to find 'Leader' for clan #%d\n", s); + return false; + } + + if (!libconfig->setting_lookup_string(cl, "Map", &aMap)) { + ShowError("clan_read_db: failed to find 'Map' for clan #%d\n", s); + return false; + } + + CREATE(c, struct clan, 1); + + c->clan_id = id; + safestrncpy(c->constant, aConst, NAME_LENGTH); + safestrncpy(c->name, aName, NAME_LENGTH); + safestrncpy(c->master, aLeader, NAME_LENGTH); + safestrncpy(c->map, aMap, MAP_NAME_LENGTH_EXT); + c->connect_member = 0; + c->member_count = 0; // Char server will count members for us + c->received = false; + c->req_count_tid = INVALID_TIMER; + c->req_kick_tid = INVALID_TIMER; + c->tid = INVALID_TIMER; + + if (libconfig->setting_lookup_int(cl, "MaxMembers", &max_members)) { + if (max_members > 0) { + c->max_member = max_members; + } else { + ShowError("clan_read_db: Clan #%d has invalid value for 'MaxMembers' setting, defaulting to 'clan->max'...\n", id); + c->max_member = clan->max; + } + } else { + c->max_member = clan->max; + } + + if (libconfig->setting_lookup_int(cl, "KickTime", &kicktime)) { + c->kick_time = 60 * 60 * kicktime; + } else { + c->kick_time = clan->kicktime; + } + + if (libconfig->setting_lookup_int(cl, "CheckTime", &kickchecktime)) { + c->check_time = 60 * 60 * max(1, kickchecktime) * 1000; + } else { + c->check_time = clan->checktime; + } + + if ((buff = libconfig->setting_get_member(cl, "Buff")) != NULL) { + clan->read_buffs(c, buff, source); + } + + allies = libconfig->setting_get_member(cl, "Allies"); + + if (allies != NULL) { + int a = libconfig->setting_length(allies); + + VECTOR_INIT(c->allies); + if (a > 0 && clan->max_relations > 0) { + const char *allyConst; + + if (a > clan->max_relations) { + ShowWarning("clan_read_db: Clan %d has more allies(%d) than allowed(%d), reading only the first %d...\n", c->clan_id, a, clan->max_relations, clan->max_relations); + a = clan->max_relations; + } + + VECTOR_ENSURE(c->allies, a, 1); + for (i = 0; i < a; i++) { + struct clan_relationship r; + if ((allyConst = libconfig->setting_get_string_elem(allies, i)) != NULL) { + ARR_FIND(0, VECTOR_LENGTH(c->allies), j, strcmp(VECTOR_INDEX(c->allies, j).constant, allyConst) == 0); + if (j != VECTOR_LENGTH(c->allies)) { + ShowError("clan_read_db: Duplicate entry '%s' in allies for Clan %d in '%s', skipping...\n", allyConst, c->clan_id, source); + continue; + } else if (strcmp(allyConst, c->constant) == 0) { + ShowError("clan_read_db: Clans can't be allies of themselves! Clan Id: %d, in '%s'\n", c->clan_id, source); + continue; + } + safestrncpy(r.constant, allyConst, NAME_LENGTH); + VECTOR_PUSH(c->allies, r); + } + + } + } + } + antagonists = libconfig->setting_get_member(cl, "Antagonists"); + + if (antagonists != NULL) { + int a = libconfig->setting_length(antagonists); + + VECTOR_INIT(c->antagonists); + if (a > 0 && clan->max_relations > 0) { + const char *antagonistConst; + + if (a > clan->max_relations) { + ShowWarning("clan_read_db: Clan %d has more antagonists(%d) than allowed(%d), reading only the first %d...\n", c->clan_id, a, clan->max_relations, clan->max_relations); + a = clan->max_relations; + } + + VECTOR_ENSURE(c->antagonists, a, 1); + for (i = 0; i < a; i++) { + struct clan_relationship r; + if ((antagonistConst = libconfig->setting_get_string_elem(antagonists, i)) != NULL) { + ARR_FIND(0, VECTOR_LENGTH(c->antagonists), j, strcmp(VECTOR_INDEX(c->antagonists, j).constant, antagonistConst) == 0); + if (j != VECTOR_LENGTH(c->antagonists)) { + ShowError("clan_read_db: Duplicate entry '%s' in antagonists for Clan %d in '%s', skipping...\n", antagonistConst, c->clan_id, source); + continue; + } else if (strcmp(antagonistConst, c->constant) == 0) { + ShowError("clan_read_db: Clans can't be antagonists of themselves! Clan Id: %d, in '%s'\n", c->clan_id, source); + continue; + } + safestrncpy(r.constant, antagonistConst, NAME_LENGTH); + VECTOR_PUSH(c->antagonists, r); + } + } + } + } + + clan->read_db_additional_fields(c, cl, s, source); + if (c->kick_time > 0) { + c->tid = timer->add(timer->gettick() + c->check_time, clan->inactivity_kick, c->clan_id, 0); + } + c->received = false; + c->req_state = reload ? CLAN_REQ_RELOAD : CLAN_REQ_FIRST; + c->req_count_tid = timer->add(timer->gettick() + clan->req_timeout, clan->request_membercount, c->clan_id, 0); + idb_put(clan->db, c->clan_id, c); + VECTOR_INIT(c->members); + valid++; + } + + // Validating Relations + if (valid > 0) { + struct DBIterator *iter = db_iterator(clan->db); + struct clan *c_ok, *c; + int i; + + for (c_ok = dbi_first(iter); dbi_exists(iter); c_ok = dbi_next(iter)) { + i = VECTOR_LENGTH(c_ok->allies); + while ( i > 0) { + struct clan_relationship *r; + + i--; + r = &VECTOR_INDEX(c_ok->allies, i); + if ((c = clan->searchname(r->constant)) == NULL) { + ShowError("clan_read_db: Invalid (nonexistent) Ally '%s' for clan %d in '%s', skipping ally...\n", r->constant, c_ok->clan_id, source); + VECTOR_ERASE(c_ok->allies, i); + } else { + r->clan_id = c->clan_id; + } + } + + i = VECTOR_LENGTH(c_ok->antagonists); + while ( i > 0) { + struct clan_relationship *r; + + i--; + r = &VECTOR_INDEX(c_ok->antagonists, i); + if ((c = clan->searchname(r->constant)) == NULL) { + ShowError("clan_read_db: Invalid (nonexistent) Antagonist '%s' for clan %d in '%s', skipping antagonist...", r->constant, c_ok->clan_id, source); + VECTOR_ERASE(c_ok->antagonists, i); + } else { + r->clan_id = c->clan_id; + } + } + } + dbi_destroy(iter); + } + + ShowStatus("Done reading '" CL_WHITE "%d" CL_RESET "' valid clans of '" CL_WHITE "%d" CL_RESET "' entries in '" CL_WHITE "%s" CL_RESET "'.\n", valid, total, source); + return valid; +} + +/** + * Reads Clan DB included by clan configuration file. + * + * @param settings The Settings Group from config file. + * @param source File name. + */ +void clan_read_db(struct config_setting_t *settings, const char *source, bool reload) +{ + struct config_setting_t *clans; + + nullpo_retv(settings); + + if ((clans = libconfig->setting_get_member(settings, "clans")) != NULL) { + int read; + + read = clan->read_db_sub(clans, source, reload); + if (read > 0) { + clan->set_constants(); + } + } else { + ShowError("clan_read_db: Can't find setting 'clans' in '%s'. No Clans found.\n", source); + } +} + +/** + * Reads clan config file + * + * @param bool clear Whether to clear clan->db before reading clans + */ +bool clan_config_read(bool reload) +{ + struct config_t clan_conf; + struct config_setting_t *settings = NULL; + const char *config_filename = "conf/clans.conf"; // FIXME: hardcoded name + int kicktime = 0, kickchecktime = 0; + + if (reload) { + struct DBIterator *iter = db_iterator(clan->db); + struct clan *c_clear; + + for (c_clear = dbi_first(iter); dbi_exists(iter); c_clear = dbi_next(iter)) { + if (c_clear->buff.script != NULL) { + script->free_code(c_clear->buff.script); + } + if (c_clear->tid != INVALID_TIMER) { + timer->delete(c_clear->tid, clan->inactivity_kick); + } + VECTOR_CLEAR(c_clear->allies); + VECTOR_CLEAR(c_clear->antagonists); + VECTOR_CLEAR(c_clear->members); + HPM->data_store_destroy(&c_clear->hdata); + } + dbi_destroy(iter); + clan->db->clear(clan->db, NULL); + } + + if (!libconfig->load_file(&clan_conf, config_filename)) { + return false; + } + + if ((settings = libconfig->lookup(&clan_conf, "clan_configuration")) == NULL) { + ShowError("clan_config_read: failed to find 'clan_configuration'.\n"); + return false; + } + + libconfig->setting_lookup_int(settings, "MaxMembers", &clan->max); + libconfig->setting_lookup_int(settings, "MaxRelations", &clan->max_relations); + libconfig->setting_lookup_int(settings, "InactivityKickTime", &kicktime); + if (!libconfig->setting_lookup_int(settings, "InactivityCheckTime", &kickchecktime)) { + ShowError("clan_config_read: failed to find InactivityCheckTime using official value.\n"); + kickchecktime = 24; + } + + // On config file we set the time in hours but here we use in seconds + clan->kicktime = 60 * 60 * kicktime; + clan->checktime = 60 * 60 * max(kickchecktime, 1) * 1000; + + clan->config_read_additional_settings(settings, config_filename); + clan->read_db(settings, config_filename, reload); + libconfig->destroy(&clan_conf); + return true; +} + +/** + * Processes any (plugin-defined) additional settings for clan config. + * + * @param settings The Settings Group from config file. + * @param source Source of the entry (file name), to be displayed in + * case of validation errors. + */ +void clan_config_read_additional_settings(struct config_setting_t *settings, const char *source) +{ + // do nothing. plugins can do own work +} + +/** + * Reloads Clan DB + */ +void clan_reload(void) +{ + clan->config_read(true); +} + +/** + * + */ +void do_init_clan(bool minimal) +{ + if (minimal) { + return; + } + clan->db = idb_alloc(DB_OPT_RELEASE_DATA); + clan->config_read(false); + timer->add_func_list(clan->inactivity_kick, "clan_inactivity_kick"); +} + +/** + * + */ +void do_final_clan(void) +{ + struct DBIterator *iter = db_iterator(clan->db); + struct clan *c; + + for (c = dbi_first(iter); dbi_exists(iter); c = dbi_next(iter)) { + if (c->buff.script) { + script->free_code(c->buff.script); + } + if (c->tid != INVALID_TIMER) { + timer->delete(c->tid, clan->inactivity_kick); + } + VECTOR_CLEAR(c->allies); + VECTOR_CLEAR(c->antagonists); + VECTOR_CLEAR(c->members); + HPM->data_store_destroy(&c->hdata); + } + dbi_destroy(iter); + db_destroy(clan->db); +} + +/** + * Inits Clan Defaults + */ +void clan_defaults(void) +{ + clan = &clan_s; + + clan->init = do_init_clan; + clan->final = do_final_clan; + /* */ + clan->db = NULL; + clan->max = 0; + clan->max_relations = 0; + clan->kicktime = 0; + clan->checktime = 0; + clan->req_timeout = 60; + /* */ + clan->config_read = clan_config_read; + clan->config_read_additional_settings = clan_config_read_additional_settings; + clan->read_db = clan_read_db; + clan->read_db_sub = clan_read_db_sub; + clan->read_db_additional_fields = clan_read_db_additional_fields; + clan->read_buffs = clan_read_buffs; + clan->search = clan_search; + clan->searchname = clan_searchname; + clan->getonlinesd = clan_getonlinesd; + clan->getindex = clan_getindex; + clan->join = clan_join; + clan->member_online = clan_member_online; + clan->leave = clan_leave; + clan->send_message = clan_send_message; + clan->recv_message = clan_recv_message; + clan->member_offline = clan_member_offline; + clan->set_constants = clan_set_constants; + clan->get_id = clan_get_id; + clan->buff_start = clan_buff_start; + clan->buff_end = clan_buff_end; + clan->reload = clan_reload; + clan->rejoin = clan_rejoin; + clan->inactivity_kick = clan_inactivity_kick; + clan->request_kickoffline = clan_request_kickoffline; + clan->request_membercount = clan_request_membercount; +} diff --git a/src/map/clan.h b/src/map/clan.h new file mode 100644 index 000000000..15ed52680 --- /dev/null +++ b/src/map/clan.h @@ -0,0 +1,85 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2017 Hercules Dev Team + * + * Hercules is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef MAP_CLAN_H +#define MAP_CLAN_H + +#include "map/map.h" +#include "common/hercules.h" +#include "common/db.h" +#include "common/mmo.h" + +struct map_session_data; + +enum clan_req_state { + CLAN_REQ_NONE = 0, + CLAN_REQ_FIRST = 1, + CLAN_REQ_RELOAD = 2, + CLAN_REQ_AFTER_KICK = 3, +}; + +/** + * clan Interface + **/ +struct clan_interface { + struct DBMap *db; // int clan_id -> struct clan* + + int max; + int max_relations; + int kicktime; + int checktime; + int req_timeout; + + void (*init) (bool minimal); + void (*final) (void); + + bool (*config_read) (bool reload); + void (*config_read_additional_settings) (struct config_setting_t *settings, const char *source); + void (*read_db) (struct config_setting_t *settings, const char *source, bool reload); + int (*read_db_sub) (struct config_setting_t *settings, const char *source, bool reload); + void (*read_db_additional_fields) (struct clan *entry, struct config_setting_t *t, int n, const char *source); + void (*read_buffs) (struct clan *c, struct config_setting_t *buff, const char *source); + struct clan *(*search) (int clan_id); + struct clan *(*searchname) (const char *name); + struct map_session_data *(*getonlinesd) (struct clan *c); + int (*getindex) (const struct clan *c, int char_id); + bool (*join) (struct map_session_data *sd, int clan_id); + void (*member_online) (struct map_session_data *sd, bool first); + bool (*leave) (struct map_session_data *sd, bool first); + bool (*send_message) (struct map_session_data *sd, const char *mes); + void (*recv_message) (struct clan *c, const char *mes, int len); + void (*member_offline) (struct map_session_data *sd); + void (*set_constants) (void); + int (*get_id) (const struct block_list *bl); + void (*buff_start) (struct map_session_data *sd, struct clan *c); + void (*buff_end) (struct map_session_data *sd, struct clan *c); + void (*reload) (void); + int (*rejoin) (struct map_session_data *sd, va_list ap); + int (*inactivity_kick) (int tid, int64 tick, int id, intptr_t data); + int (*request_kickoffline) (int tid, int64 tick, int id, intptr_t data); + int (*request_membercount) (int tid, int64 tick, int id, intptr_t data); +}; + +#ifdef HERCULES_CORE +void clan_defaults (void); +#endif // HERCULES_CORE + +HPShared struct clan_interface *clan; + +#endif /* MAP_CLAN_H */ diff --git a/src/map/clif.c b/src/map/clif.c index 6de375e49..6e1cb4cf7 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -29,6 +29,7 @@ #include "map/channel.h" #include "map/chat.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/elemental.h" #include "map/guild.h" #include "map/homunculus.h" @@ -419,8 +420,14 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target sd = BL_CAST(BL_PC, bl); - switch(type) { + if (sd != NULL && pc_isinvisible(sd)) { + if (type == AREA || type == BG || type == BG_AREA) + type = SELF; + else if (type == AREA_WOS || type == BG_WOS || type == BG_AREA_WOS) + return true; + } + switch(type) { case ALL_CLIENT: //All player clients. iter = mapit_getallusers(); while ((tsd = BL_UCAST(BL_PC, mapit->next(iter))) != NULL) { @@ -659,6 +666,22 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target } break; + case CLAN: + if (sd && sd->status.clan_id) { + struct clan *c = clan->search(sd->status.clan_id); + + nullpo_retr(false, c); + + for (i = 0; i < VECTOR_LENGTH(c->members); i++) { + if (VECTOR_INDEX(c->members, i).online == 0 || (sd = VECTOR_INDEX(c->members, i).sd) == NULL || (fd = sd->fd) <= 0) + continue; + WFIFOHEAD(fd, len); + memcpy(WFIFOP(fd, 0), buf, len); + WFIFOSET(fd, len); + } + } + break; + default: ShowError("clif_send: Unrecognized type %u\n", type); return false; @@ -1534,6 +1557,8 @@ bool clif_spawn(struct block_list *bl) clif->specialeffect(&nd->bl,423,AREA); else if (nd->size == SZ_MEDIUM) clif->specialeffect(&nd->bl,421,AREA); + if (nd->clan_id > 0) + clif->sc_load(&nd->bl, nd->bl.id, AREA, status->dbs->IconChangeTable[SC_CLAN_INFO], 0, nd->clan_id, 0); } break; case BL_PET: @@ -4388,6 +4413,8 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { clif->specialeffect_single(bl,423,sd->fd); else if (nd->size == SZ_MEDIUM) clif->specialeffect_single(bl,421,sd->fd); + if (nd->clan_id > 0) + clif->sc_load(&nd->bl, nd->bl.id, AREA, status->dbs->IconChangeTable[SC_CLAN_INFO], 0, nd->clan_id, 0); } break; case BL_MOB: @@ -7382,7 +7409,7 @@ void clif_mvp_item(struct map_session_data *sd,int nameid) /// 010b <exp>.L void clif_mvp_exp(struct map_session_data *sd, unsigned int exp) { -#if PACKETVER >= 20131223 // Kro removed this packet [Napster] +#if PACKETVER >= 20131223 // Kro removed this packet [Napster] if (battle_config.mvp_exp_reward_message) { char e_msg[CHAT_SIZE_MAX]; sprintf(e_msg, msg_txt(855), exp); @@ -11862,8 +11889,8 @@ void clif_parse_ItemIdentify(int fd,struct map_session_data *sd) clif_menuskill_clear(sd); } -/// Identifying item with right-click (CZ_REQ_ONECLICK_ITEMIDENTIFY). -/// 0A35 <index>.W +/// Identifying item with right-click (CZ_REQ_ONECLICK_ITEMIDENTIFY). +/// 0A35 <index>.W void clif_parse_OneClick_ItemIdentify(int fd, struct map_session_data *sd) { int cmd = RFIFOW(fd,0); @@ -13340,6 +13367,12 @@ bool clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_sessi return false; } + // Players in a clan can't join a guild + if (t_sd->clan != NULL) { + clif->message(fd, msg_fd(fd, 140)); // You can't join in a clan if you're in a guild. + return false; + } + guild->invite(sd,t_sd); return true; } @@ -19285,6 +19318,156 @@ const char *clif_get_bl_name(const struct block_list *bl) return name; } +/** + * Clan System: Sends the basic clan informations to client. + * 098a <length>.W <clan id>.L <clan name>.24B <clan master>.24B <clan map>.16B <alliance count>.B + * <antagonist count>.B { <alliance>.24B } * alliance count { <antagonist>.24B } * antagonist count (ZC_CLANINFO) + */ +void clif_clan_basicinfo(struct map_session_data *sd) +{ +#if PACKETVER >= 20120716 + int len, i, fd; + struct clan *c, *ally, *antagonist; + struct PACKET_ZC_CLANINFO *packet = NULL; + + nullpo_retv(sd); + nullpo_retv(c = sd->clan); + + len = sizeof(struct PACKET_ZC_CLANINFO); + fd = sd->fd; + + WFIFOHEAD(fd, len); + packet = WFIFOP(fd, 0); + + packet->PacketType = clanBasicInfo; + packet->ClanID = c->clan_id; + + safestrncpy(packet->ClanName, c->name, NAME_LENGTH); + safestrncpy(packet->MasterName, c->master, NAME_LENGTH); + + mapindex->getmapname_ext(c->map, packet->Map); + + packet->AllyCount = VECTOR_LENGTH(c->allies); + packet->AntagonistCount = VECTOR_LENGTH(c->antagonists); + + // All allies and antagonists are assumed as valid entries + // since it only gets inside the vector after the validation + // on clan->config_read + for (i = 0; i < VECTOR_LENGTH(c->allies); i++) { + struct clan_relationship *al = &VECTOR_INDEX(c->allies, i); + + if ((ally = clan->search(al->clan_id)) != NULL) { + safestrncpy(WFIFOP(fd, len), ally->name, NAME_LENGTH); + len += NAME_LENGTH; + } + } + + for (i = 0; i < VECTOR_LENGTH(c->antagonists); i++) { + struct clan_relationship *an = &VECTOR_INDEX(c->antagonists, i); + + if ((antagonist = clan->search(an->clan_id)) != NULL) { + safestrncpy(WFIFOP(fd, len), antagonist->name, NAME_LENGTH); + len += NAME_LENGTH; + } + } + + packet->PacketLength = len; + WFIFOSET(fd, len); +#endif +} + +/** + * Clan System: Updates the online and maximum player count of a clan. + * 0988 <online count>.W <maximum member amount>.W (ZC_NOTIFY_CLAN_CONNECTINFO) + */ +void clif_clan_onlinecount(struct clan *c) +{ +#if PACKETVER >= 20120716 + struct map_session_data *sd; + struct PACKET_ZC_NOTIFY_CLAN_CONNECTINFO p; + + nullpo_retv(c); + + p.PacketType = clanOnlineCount; + p.NumConnect = c->connect_member; + p.NumTotal = c->max_member; + + if ((sd = clan->getonlinesd(c)) != NULL) { + clif->send(&p, sizeof(p), &sd->bl, CLAN); + } +#endif +} + +/** +* Clan System: Notifies the client that the player has left his clan. +* 0989 (ZC_ACK_CLAN_LEAVE) +**/ +void clif_clan_leave(struct map_session_data* sd) +{ +#if PACKETVER >= 20131223 + struct PACKET_ZC_ACK_CLAN_LEAVE p; + + nullpo_retv(sd); + + p.PacketType = clanLeave; + + clif->send(&p, sizeof(p), &sd->bl, SELF); +#endif +} + +/** + * Clan System: Sends a clan message to a player + * 098e <length>.W <name>.24B <message>.?B (ZC_NOTIFY_CLAN_CHAT) + */ +void clif_clan_message(struct clan *c, const char *mes, int len) +{ +#if PACKETVER >= 20120716 + struct map_session_data *sd; + struct PACKET_ZC_NOTIFY_CLAN_CHAT *p; + unsigned int max_len = CHAT_SIZE_MAX - 5 - NAME_LENGTH; + int packet_length; + + nullpo_retv(c); + nullpo_retv(mes); + + if (len == 0) { + return; + } else if (len > max_len) { + ShowWarning("clif_clan_message: Truncated message '%s' (len=%d, max=%u, clan_id=%d).\n", mes, len, max_len, c->clan_id); + len = max_len; + } + + packet_length = sizeof(*p) + len + 1; + p = (struct PACKET_ZC_NOTIFY_CLAN_CHAT *)aMalloc(packet_length); + p->PacketType = clanMessage; + p->PacketLength = packet_length; + // p->MemberName is being ignored on the client side. + safestrncpy(p->Message, mes, len + 1); + + if ((sd = clan->getonlinesd(c)) != NULL) + clif->send(p, packet_length, &sd->bl, CLAN); + aFree(p); +#endif +} + +void clif_parse_ClanMessage(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); +/** + * Clan System: Parses a clan message from a player. + * 098d <length>.W <text>.?B (<name> : <message>) (CZ_CLAN_CHAT) + */ +void clif_parse_ClanMessage(int fd, struct map_session_data *sd) +{ +#if PACKETVER >= 20120716 + const struct packet_chat_message *packet = RP2PTR(fd); + char message[CHAT_SIZE_MAX + NAME_LENGTH + 3 + 1]; + + if (clif->process_chat_message(sd, packet, message, sizeof(message)) == NULL) + return; + + clan->send_message(sd, message); +#endif +} + /* */ unsigned short clif_decrypt_cmd( int cmd, struct map_session_data *sd ) { if( sd ) { @@ -21009,4 +21192,10 @@ void clif_defaults(void) { clif->rodex_icon = clif_rodex_icon; clif->rodex_send_mails_all = clif_rodex_send_mails_all; clif->skill_scale = clif_skill_scale; + // -- Clan system + clif->clan_basicinfo = clif_clan_basicinfo; + clif->clan_onlinecount = clif_clan_onlinecount; + clif->clan_leave = clif_clan_leave; + clif->clan_message = clif_clan_message; + clif->pClanMessage = clif_parse_ClanMessage; } diff --git a/src/map/clif.h b/src/map/clif.h index 69567cc2c..0711546df 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -110,6 +110,8 @@ typedef enum send_target { BG_AREA_WOS, BG_QUEUE, + + CLAN, // Clan System } send_target; typedef enum broadcast_flags { @@ -1405,6 +1407,12 @@ struct clif_interface { void (*rodex_request_items) (struct map_session_data *sd, int8 opentype, int64 mail_id, int8 result); void (*rodex_icon) (int fd, bool show); void (*skill_scale) (struct block_list *bl, int src_id, int x, int y, uint16 skill_id, uint16 skill_lv, int casttime); + /* Clan System */ + void (*clan_basicinfo) (struct map_session_data *sd); + void (*clan_onlinecount) (struct clan *c); + void (*clan_leave) (struct map_session_data *sd); + void (*clan_message) (struct clan *c, const char *mes, int len); + void (*pClanMessage) (int fd, struct map_session_data* sd); }; #ifdef HERCULES_CORE diff --git a/src/map/constants.inc b/src/map/constants.inc new file mode 100644 index 000000000..355e2a825 --- /dev/null +++ b/src/map/constants.inc @@ -0,0 +1,1029 @@ + script->constdb_comment("Status Icons"); + + script->set_constant("SI_BLANK", SI_BLANK, false, false); + + script->set_constant("SI_PROVOKE", SI_PROVOKE, false, false); + script->set_constant("SI_ENDURE", SI_ENDURE, false, false); + script->set_constant("SI_TWOHANDQUICKEN", SI_TWOHANDQUICKEN, false, false); + script->set_constant("SI_CONCENTRATION", SI_CONCENTRATION, false, false); + script->set_constant("SI_HIDING", SI_HIDING, false, false); + script->set_constant("SI_CLOAKING", SI_CLOAKING, false, false); + script->set_constant("SI_ENCHANTPOISON", SI_ENCHANTPOISON, false, false); + script->set_constant("SI_POISONREACT", SI_POISONREACT, false, false); + script->set_constant("SI_QUAGMIRE", SI_QUAGMIRE, false, false); + script->set_constant("SI_ANGELUS", SI_ANGELUS, false, false); + script->set_constant("SI_BLESSING", SI_BLESSING, false, false); + script->set_constant("SI_CRUCIS", SI_CRUCIS, false, false); + script->set_constant("SI_INC_AGI", SI_INC_AGI, false, false); + script->set_constant("SI_DEC_AGI", SI_DEC_AGI, false, false); + script->set_constant("SI_SLOWPOISON", SI_SLOWPOISON, false, false); + script->set_constant("SI_IMPOSITIO", SI_IMPOSITIO, false, false); + script->set_constant("SI_SUFFRAGIUM", SI_SUFFRAGIUM, false, false); + script->set_constant("SI_ASPERSIO", SI_ASPERSIO, false, false); + script->set_constant("SI_BENEDICTIO", SI_BENEDICTIO, false, false); + script->set_constant("SI_KYRIE", SI_KYRIE, false, false); + script->set_constant("SI_MAGNIFICAT", SI_MAGNIFICAT, false, false); + script->set_constant("SI_GLORIA", SI_GLORIA, false, false); + script->set_constant("SI_LEXAETERNA", SI_LEXAETERNA, false, false); + script->set_constant("SI_ADRENALINE", SI_ADRENALINE, false, false); + script->set_constant("SI_WEAPONPERFECT", SI_WEAPONPERFECT, false, false); + script->set_constant("SI_OVERTHRUST", SI_OVERTHRUST, false, false); + script->set_constant("SI_MAXIMIZE", SI_MAXIMIZE, false, false); + script->set_constant("SI_RIDING", SI_RIDING, false, false); + script->set_constant("SI_FALCON", SI_FALCON, false, false); + script->set_constant("SI_TRICKDEAD", SI_TRICKDEAD, false, false); + script->set_constant("SI_SHOUT", SI_SHOUT, false, false); + script->set_constant("SI_ENERGYCOAT", SI_ENERGYCOAT, false, false); + script->set_constant("SI_BROKENARMOR", SI_BROKENARMOR, false, false); + script->set_constant("SI_BROKENWEAPON", SI_BROKENWEAPON, false, false); + script->set_constant("SI_ILLUSION", SI_ILLUSION, false, false); + script->set_constant("SI_WEIGHTOVER50", SI_WEIGHTOVER50, false, false); + script->set_constant("SI_WEIGHTOVER90", SI_WEIGHTOVER90, false, false); + script->set_constant("SI_ATTHASTE_POTION1", SI_ATTHASTE_POTION1, false, false); + script->set_constant("SI_ATTHASTE_POTION2", SI_ATTHASTE_POTION2, false, false); + script->set_constant("SI_ATTHASTE_POTION3", SI_ATTHASTE_POTION3, false, false); + script->set_constant("SI_ATTHASTE_INFINITY", SI_ATTHASTE_INFINITY, false, false); + script->set_constant("SI_MOVHASTE_POTION", SI_MOVHASTE_POTION, false, false); + script->set_constant("SI_MOVHASTE_INFINITY", SI_MOVHASTE_INFINITY, false, false); + //script->set_constant("SI_AUTOCOUNTER", SI_AUTOCOUNTER, false, false); + //script->set_constant("SI_SPLASHER", SI_SPLASHER, false, false); + script->set_constant("SI_ANKLESNARE", SI_ANKLESNARE, false, false); + script->set_constant("SI_POSTDELAY", SI_POSTDELAY, false, false); + //script->set_constant("SI_NOACTION", SI_NOACTION, false, false); + //script->set_constant("SI_IMPOSSIBLEPICKUP", SI_IMPOSSIBLEPICKUP, false, false); + //script->set_constant("SI_BARRIER", SI_BARRIER, false, false); + + script->set_constant("SI_NOEQUIPWEAPON", SI_NOEQUIPWEAPON, false, false); + script->set_constant("SI_NOEQUIPSHIELD", SI_NOEQUIPSHIELD, false, false); + script->set_constant("SI_NOEQUIPARMOR", SI_NOEQUIPARMOR, false, false); + script->set_constant("SI_NOEQUIPHELM", SI_NOEQUIPHELM, false, false); + script->set_constant("SI_PROTECTWEAPON", SI_PROTECTWEAPON, false, false); + script->set_constant("SI_PROTECTSHIELD", SI_PROTECTSHIELD, false, false); + script->set_constant("SI_PROTECTARMOR", SI_PROTECTARMOR, false, false); + script->set_constant("SI_PROTECTHELM", SI_PROTECTHELM, false, false); + script->set_constant("SI_AUTOGUARD", SI_AUTOGUARD, false, false); + script->set_constant("SI_REFLECTSHIELD", SI_REFLECTSHIELD, false, false); + //script->set_constant("SI_DEVOTION", SI_DEVOTION, false, false); + script->set_constant("SI_PROVIDENCE", SI_PROVIDENCE, false, false); + script->set_constant("SI_DEFENDER", SI_DEFENDER, false, false); + //script->set_constant("SI_MAGICROD", SI_MAGICROD, false, false); + //script->set_constant("SI_WEAPONPROPERTY", SI_WEAPONPROPERTY, false, false); + script->set_constant("SI_AUTOSPELL", SI_AUTOSPELL, false, false); + //script->set_constant("SI_SPECIALZONE", SI_SPECIALZONE, false, false); + //script->set_constant("SI_MASK", SI_MASK, false, false); + script->set_constant("SI_SPEARQUICKEN", SI_SPEARQUICKEN, false, false); + //script->set_constant("SI_BDPLAYING", SI_BDPLAYING, false, false); + //script->set_constant("SI_WHISTLE", SI_WHISTLE, false, false); + //script->set_constant("SI_ASSASSINCROSS", SI_ASSASSINCROSS, false, false); + //script->set_constant("SI_POEMBRAGI", SI_POEMBRAGI, false, false); + //script->set_constant("SI_APPLEIDUN", SI_APPLEIDUN, false, false); + //script->set_constant("SI_HUMMING", SI_HUMMING, false, false); + //script->set_constant("SI_DONTFORGETME", SI_DONTFORGETME, false, false); + //script->set_constant("SI_FORTUNEKISS", SI_FORTUNEKISS, false, false); + //script->set_constant("SI_SERVICEFORYOU", SI_SERVICEFORYOU, false, false); + //script->set_constant("SI_RICHMANKIM", SI_RICHMANKIM, false, false); + //script->set_constant("SI_ETERNALCHAOS", SI_ETERNALCHAOS, false, false); + //script->set_constant("SI_DRUMBATTLEFIELD", SI_DRUMBATTLEFIELD, false, false); + //script->set_constant("SI_RINGNIBELUNGEN", SI_RINGNIBELUNGEN, false, false); + //script->set_constant("SI_ROKISWEIL", SI_ROKISWEIL, false, false); + //script->set_constant("SI_INTOABYSS", SI_INTOABYSS, false, false); + //script->set_constant("SI_SIEGFRIED", SI_SIEGFRIED, false, false); + //script->set_constant("SI_BLADESTOP", SI_BLADESTOP, false, false); + script->set_constant("SI_EXPLOSIONSPIRITS", SI_EXPLOSIONSPIRITS, false, false); + script->set_constant("SI_STEELBODY", SI_STEELBODY, false, false); + script->set_constant("SI_EXTREMITYFIST", SI_EXTREMITYFIST, false, false); + //script->set_constant("SI_COMBOATTACK", SI_COMBOATTACK, false, false); + script->set_constant("SI_PROPERTYFIRE", SI_PROPERTYFIRE, false, false); + script->set_constant("SI_PROPERTYWATER", SI_PROPERTYWATER, false, false); + script->set_constant("SI_PROPERTYWIND", SI_PROPERTYWIND, false, false); + script->set_constant("SI_PROPERTYGROUND", SI_PROPERTYGROUND, false, false); + //script->set_constant("SI_MAGICATTACK", SI_MAGICATTACK, false, false); + script->set_constant("SI_STOP", SI_STOP, false, false); + //script->set_constant("SI_WEAPONBRAKER", SI_WEAPONBRAKER, false, false); + script->set_constant("SI_PROPERTYUNDEAD", SI_PROPERTYUNDEAD, false, false); + //script->set_constant("SI_POWERUP", SI_POWERUP, false, false); + //script->set_constant("SI_AGIUP", SI_AGIUP, false, false); + + //script->set_constant("SI_SIEGEMODE", SI_SIEGEMODE, false, false); + //script->set_constant("SI_INVISIBLE", SI_INVISIBLE, false, false); + //script->set_constant("SI_STATUSONE", SI_STATUSONE, false, false); + script->set_constant("SI_AURABLADE", SI_AURABLADE, false, false); + script->set_constant("SI_PARRYING", SI_PARRYING, false, false); + script->set_constant("SI_LKCONCENTRATION", SI_LKCONCENTRATION, false, false); + script->set_constant("SI_TENSIONRELAX", SI_TENSIONRELAX, false, false); + script->set_constant("SI_BERSERK", SI_BERSERK, false, false); + //script->set_constant("SI_SACRIFICE", SI_SACRIFICE, false, false); + //script->set_constant("SI_GOSPEL", SI_GOSPEL, false, false); + script->set_constant("SI_ASSUMPTIO", SI_ASSUMPTIO, false, false); + //script->set_constant("SI_BASILICA", SI_BASILICA, false, false); + script->set_constant("SI_GROUNDMAGIC", SI_GROUNDMAGIC, false, false); + script->set_constant("SI_MAGICPOWER", SI_MAGICPOWER, false, false); + script->set_constant("SI_EDP", SI_EDP, false, false); + script->set_constant("SI_TRUESIGHT", SI_TRUESIGHT, false, false); + script->set_constant("SI_WINDWALK", SI_WINDWALK, false, false); + script->set_constant("SI_MELTDOWN", SI_MELTDOWN, false, false); + script->set_constant("SI_CARTBOOST", SI_CARTBOOST, false, false); + //script->set_constant("SI_CHASEWALK", SI_CHASEWALK, false, false); + script->set_constant("SI_SWORDREJECT", SI_SWORDREJECT, false, false); + script->set_constant("SI_MARIONETTE_MASTER", SI_MARIONETTE_MASTER, false, false); + script->set_constant("SI_MARIONETTE", SI_MARIONETTE, false, false); + script->set_constant("SI_MOON", SI_MOON, false, false); + script->set_constant("SI_BLOODING", SI_BLOODING, false, false); + script->set_constant("SI_JOINTBEAT", SI_JOINTBEAT, false, false); + //script->set_constant("SI_MINDBREAKER", SI_MINDBREAKER, false, false); + //script->set_constant("SI_MEMORIZE", SI_MEMORIZE, false, false); + //script->set_constant("SI_FOGWALL", SI_FOGWALL, false, false); + //script->set_constant("SI_SPIDERWEB", SI_SPIDERWEB, false, false); + script->set_constant("SI_PROTECTEXP", SI_PROTECTEXP, false, false); + //script->set_constant("SI_SUB_WEAPONPROPERTY", SI_SUB_WEAPONPROPERTY, false, false); + script->set_constant("SI_AUTOBERSERK", SI_AUTOBERSERK, false, false); + script->set_constant("SI_RUN", SI_RUN, false, false); + script->set_constant("SI_TING", SI_TING, false, false); + script->set_constant("SI_STORMKICK_ON", SI_STORMKICK_ON, false, false); + script->set_constant("SI_STORMKICK_READY", SI_STORMKICK_READY, false, false); + script->set_constant("SI_DOWNKICK_ON", SI_DOWNKICK_ON, false, false); + script->set_constant("SI_DOWNKICK_READY", SI_DOWNKICK_READY, false, false); + script->set_constant("SI_TURNKICK_ON", SI_TURNKICK_ON, false, false); + script->set_constant("SI_TURNKICK_READY", SI_TURNKICK_READY, false, false); + script->set_constant("SI_COUNTER_ON", SI_COUNTER_ON, false, false); + script->set_constant("SI_COUNTER_READY", SI_COUNTER_READY, false, false); + script->set_constant("SI_DODGE_ON", SI_DODGE_ON, false, false); + script->set_constant("SI_DODGE_READY", SI_DODGE_READY, false, false); + script->set_constant("SI_STRUP", SI_STRUP, false, false); + script->set_constant("SI_PROPERTYDARK", SI_PROPERTYDARK, false, false); + script->set_constant("SI_ADRENALINE2", SI_ADRENALINE2, false, false); + script->set_constant("SI_PROPERTYTELEKINESIS", SI_PROPERTYTELEKINESIS, false, false); + script->set_constant("SI_SOULLINK", SI_SOULLINK, false, false); + + script->set_constant("SI_PLUSATTACKPOWER", SI_PLUSATTACKPOWER, false, false); + script->set_constant("SI_PLUSMAGICPOWER", SI_PLUSMAGICPOWER, false, false); + script->set_constant("SI_DEVIL1", SI_DEVIL1, false, false); + script->set_constant("SI_KAITE", SI_KAITE, false, false); + //script->set_constant("SI_SWOO", SI_SWOO, false, false); + //script->set_constant("SI_STAR2", SI_STAR2, false, false); + script->set_constant("SI_KAIZEL", SI_KAIZEL, false, false); + script->set_constant("SI_KAAHI", SI_KAAHI, false, false); + script->set_constant("SI_KAUPE", SI_KAUPE, false, false); + script->set_constant("SI_SMA_READY", SI_SMA_READY, false, false); + script->set_constant("SI_SKE", SI_SKE, false, false); + script->set_constant("SI_ONEHANDQUICKEN", SI_ONEHANDQUICKEN, false, false); + //script->set_constant("SI_FRIEND", SI_FRIEND, false, false); + //script->set_constant("SI_FRIENDUP", SI_FRIENDUP, false, false); + //script->set_constant("SI_SG_WARM", SI_SG_WARM, false, false); + script->set_constant("SI_SG_SUN_WARM", SI_SG_SUN_WARM, false, false); + //script->set_constant("SI_SG_MOON_WARM", SI_SG_MOON_WARM, false, false); + //script->set_constant("SI_SG_STAR_WARM", SI_SG_STAR_WARM, false, false); + //script->set_constant("SI_EMOTION", SI_EMOTION, false, false); + script->set_constant("SI_SUN_COMFORT", SI_SUN_COMFORT, false, false); + script->set_constant("SI_MOON_COMFORT", SI_MOON_COMFORT, false, false); + script->set_constant("SI_STAR_COMFORT", SI_STAR_COMFORT, false, false); + //script->set_constant("SI_EXPUP", SI_EXPUP, false, false); + //script->set_constant("SI_GDSKILL_BATTLEORDER", SI_GDSKILL_BATTLEORDER, false, false); + //script->set_constant("SI_GDSKILL_REGENERATION", SI_GDSKILL_REGENERATION, false, false); + //script->set_constant("SI_GDSKILL_POSTDELAY", SI_GDSKILL_POSTDELAY, false, false); + //script->set_constant("SI_RESISTHANDICAP", SI_RESISTHANDICAP, false, false); + //script->set_constant("SI_MAXHPPERCENT", SI_MAXHPPERCENT, false, false); + //script->set_constant("SI_MAXSPPERCENT", SI_MAXSPPERCENT, false, false); + //script->set_constant("SI_DEFENCE", SI_DEFENCE, false, false); + //script->set_constant("SI_SLOWDOWN", SI_SLOWDOWN, false, false); + script->set_constant("SI_PRESERVE", SI_PRESERVE, false, false); + script->set_constant("SI_INCSTR", SI_INCSTR, false, false); + //script->set_constant("SI_NOT_EXTREMITYFIST", SI_NOT_EXTREMITYFIST, false, false); + script->set_constant("SI_CLAIRVOYANCE", SI_CLAIRVOYANCE, false, false); + script->set_constant("SI_MOVESLOW_POTION", SI_MOVESLOW_POTION, false, false); + script->set_constant("SI_DOUBLECASTING", SI_DOUBLECASTING, false, false); + //script->set_constant("SI_GRAVITATION", SI_GRAVITATION, false, false); + script->set_constant("SI_OVERTHRUSTMAX", SI_OVERTHRUSTMAX, false, false); + //script->set_constant("SI_LONGING", SI_LONGING, false, false); + //script->set_constant("SI_HERMODE", SI_HERMODE, false, false); + script->set_constant("SI_TAROTCARD", SI_TAROTCARD, false, false); + //script->set_constant("SI_HLIF_AVOID", SI_HLIF_AVOID, false, false); + //script->set_constant("SI_HFLI_FLEET", SI_HFLI_FLEET, false, false); + //script->set_constant("SI_HFLI_SPEED", SI_HFLI_SPEED, false, false); + //script->set_constant("SI_HLIF_CHANGE", SI_HLIF_CHANGE, false, false); + //script->set_constant("SI_HAMI_BLOODLUST", SI_HAMI_BLOODLUST, false, false); + script->set_constant("SI_CR_SHRINK", SI_CR_SHRINK, false, false); + script->set_constant("SI_WZ_SIGHTBLASTER", SI_WZ_SIGHTBLASTER, false, false); + script->set_constant("SI_DC_WINKCHARM", SI_DC_WINKCHARM, false, false); + + script->set_constant("SI_RG_CCONFINE_M", SI_RG_CCONFINE_M, false, false); + script->set_constant("SI_RG_CCONFINE_S", SI_RG_CCONFINE_S, false, false); + //script->set_constant("SI_DISABLEMOVE", SI_DISABLEMOVE, false, false); + script->set_constant("SI_GS_MADNESSCANCEL", SI_GS_MADNESSCANCEL, false, false); + script->set_constant("SI_GS_GATLINGFEVER", SI_GS_GATLINGFEVER, false, false); + script->set_constant("SI_EARTHSCROLL", SI_EARTHSCROLL, false, false); + script->set_constant("SI_NJ_UTSUSEMI", SI_NJ_UTSUSEMI, false, false); + script->set_constant("SI_NJ_BUNSINJYUTSU", SI_NJ_BUNSINJYUTSU, false, false); + script->set_constant("SI_NJ_NEN", SI_NJ_NEN, false, false); + script->set_constant("SI_GS_ADJUSTMENT", SI_GS_ADJUSTMENT, false, false); + script->set_constant("SI_GS_ACCURACY", SI_GS_ACCURACY, false, false); + script->set_constant("SI_NJ_SUITON", SI_NJ_SUITON, false, false); + //script->set_constant("SI_PET", SI_PET, false, false); + //script->set_constant("SI_MENTAL", SI_MENTAL, false, false); + //script->set_constant("SI_EXPMEMORY", SI_EXPMEMORY, false, false); + //script->set_constant("SI_PERFORMANCE", SI_PERFORMANCE, false, false); + //script->set_constant("SI_GAIN", SI_GAIN, false, false); + //script->set_constant("SI_GRIFFON", SI_GRIFFON, false, false); + //script->set_constant("SI_DRIFT", SI_DRIFT, false, false); + //script->set_constant("SI_WALLSHIFT", SI_WALLSHIFT, false, false); + //script->set_constant("SI_REINCARNATION", SI_REINCARNATION, false, false); + //script->set_constant("SI_PATTACK", SI_PATTACK, false, false); + //script->set_constant("SI_PSPEED", SI_PSPEED, false, false); + //script->set_constant("SI_PDEFENSE", SI_PDEFENSE, false, false); + //script->set_constant("SI_PCRITICAL", SI_PCRITICAL, false, false); + //script->set_constant("SI_RANKING", SI_RANKING, false, false); + //script->set_constant("SI_PTRIPLE", SI_PTRIPLE, false, false); + //script->set_constant("SI_DENERGY", SI_DENERGY, false, false); + //script->set_constant("SI_WAVE1", SI_WAVE1, false, false); + //script->set_constant("SI_WAVE2", SI_WAVE2, false, false); + //script->set_constant("SI_WAVE3", SI_WAVE3, false, false); + //script->set_constant("SI_WAVE4", SI_WAVE4, false, false); + //script->set_constant("SI_DAURA", SI_DAURA, false, false); + //script->set_constant("SI_DFREEZER", SI_DFREEZER, false, false); + //script->set_constant("SI_DPUNISH", SI_DPUNISH, false, false); + //script->set_constant("SI_DBARRIER", SI_DBARRIER, false, false); + //script->set_constant("SI_DWARNING", SI_DWARNING, false, false); + //script->set_constant("SI_MOUSEWHEEL", SI_MOUSEWHEEL, false, false); + //script->set_constant("SI_DGAUGE", SI_DGAUGE, false, false); + //script->set_constant("SI_DACCEL", SI_DACCEL, false, false); + //script->set_constant("SI_DBLOCK", SI_DBLOCK, false, false); + script->set_constant("SI_FOOD_STR", SI_FOOD_STR, false, false); + script->set_constant("SI_FOOD_AGI", SI_FOOD_AGI, false, false); + script->set_constant("SI_FOOD_VIT", SI_FOOD_VIT, false, false); + script->set_constant("SI_FOOD_DEX", SI_FOOD_DEX, false, false); + script->set_constant("SI_FOOD_INT", SI_FOOD_INT, false, false); + script->set_constant("SI_FOOD_LUK", SI_FOOD_LUK, false, false); + script->set_constant("SI_FOOD_BASICAVOIDANCE", SI_FOOD_BASICAVOIDANCE, false, false); + script->set_constant("SI_FOOD_BASICHIT", SI_FOOD_BASICHIT, false, false); + script->set_constant("SI_FOOD_CRITICALSUCCESSVALUE", SI_FOOD_CRITICALSUCCESSVALUE, false, false); + + script->set_constant("SI_CASH_PLUSEXP", SI_CASH_PLUSEXP, false, false); + script->set_constant("SI_CASH_DEATHPENALTY", SI_CASH_DEATHPENALTY, false, false); + script->set_constant("SI_CASH_RECEIVEITEM", SI_CASH_RECEIVEITEM, false, false); + script->set_constant("SI_CASH_BOSS_ALARM", SI_CASH_BOSS_ALARM, false, false); + //script->set_constant("SI_DA_ENERGY", SI_DA_ENERGY, false, false); + //script->set_constant("SI_DA_FIRSTSLOT", SI_DA_FIRSTSLOT, false, false); + //script->set_constant("SI_DA_HEADDEF", SI_DA_HEADDEF, false, false); + //script->set_constant("SI_DA_SPACE", SI_DA_SPACE, false, false); + //script->set_constant("SI_DA_TRANSFORM", SI_DA_TRANSFORM, false, false); + //script->set_constant("SI_DA_ITEMREBUILD", SI_DA_ITEMREBUILD, false, false); + //script->set_constant("SI_DA_ILLUSION", SI_DA_ILLUSION, false, false); + //script->set_constant("SI_DA_DARKPOWER", SI_DA_DARKPOWER, false, false); + //script->set_constant("SI_DA_EARPLUG", SI_DA_EARPLUG, false, false); + //script->set_constant("SI_DA_CONTRACT", SI_DA_CONTRACT, false, false); + //script->set_constant("SI_DA_BLACK", SI_DA_BLACK, false, false); + //script->set_constant("SI_DA_MAGICCART", SI_DA_MAGICCART, false, false); + //script->set_constant("SI_CRYSTAL", SI_CRYSTAL, false, false); + //script->set_constant("SI_DA_REBUILD", SI_DA_REBUILD, false, false); + //script->set_constant("SI_DA_EDARKNESS", SI_DA_EDARKNESS, false, false); + //script->set_constant("SI_DA_EGUARDIAN", SI_DA_EGUARDIAN, false, false); + //script->set_constant("SI_DA_TIMEOUT", SI_DA_TIMEOUT, false, false); + script->set_constant("SI_FOOD_STR_CASH", SI_FOOD_STR_CASH, false, false); + script->set_constant("SI_FOOD_AGI_CASH", SI_FOOD_AGI_CASH, false, false); + script->set_constant("SI_FOOD_VIT_CASH", SI_FOOD_VIT_CASH, false, false); + script->set_constant("SI_FOOD_DEX_CASH", SI_FOOD_DEX_CASH, false, false); + script->set_constant("SI_FOOD_INT_CASH", SI_FOOD_INT_CASH, false, false); + script->set_constant("SI_FOOD_LUK_CASH", SI_FOOD_LUK_CASH, false, false); + script->set_constant("SI_MER_FLEE", SI_MER_FLEE, false, false); + script->set_constant("SI_MER_ATK", SI_MER_ATK, false, false); + script->set_constant("SI_MER_HP", SI_MER_HP, false, false); + script->set_constant("SI_MER_SP", SI_MER_SP, false, false); + script->set_constant("SI_MER_HIT", SI_MER_HIT, false, false); + script->set_constant("SI_SLOWCAST", SI_SLOWCAST, false, false); + //script->set_constant("SI_MAGICMIRROR", SI_MAGICMIRROR, false, false); + //script->set_constant("SI_STONESKIN", SI_STONESKIN, false, false); + //script->set_constant("SI_ANTIMAGIC", SI_ANTIMAGIC, false, false); + script->set_constant("SI_CRITICALWOUND", SI_CRITICALWOUND, false, false); + //script->set_constant("SI_NPC_DEFENDER", SI_NPC_DEFENDER, false, false); + //script->set_constant("SI_NOACTION_WAIT", SI_NOACTION_WAIT, false, false); + script->set_constant("SI_MOVHASTE_HORSE", SI_MOVHASTE_HORSE, false, false); + script->set_constant("SI_PROTECT_DEF", SI_PROTECT_DEF, false, false); + script->set_constant("SI_PROTECT_MDEF", SI_PROTECT_MDEF, false, false); + script->set_constant("SI_HEALPLUS", SI_HEALPLUS, false, false); + script->set_constant("SI_S_LIFEPOTION", SI_S_LIFEPOTION, false, false); + script->set_constant("SI_L_LIFEPOTION", SI_L_LIFEPOTION, false, false); + script->set_constant("SI_CRITICALPERCENT", SI_CRITICALPERCENT, false, false); + script->set_constant("SI_PLUSAVOIDVALUE", SI_PLUSAVOIDVALUE, false, false); + script->set_constant("SI_ATKER_ASPD", SI_ATKER_ASPD, false, false); + script->set_constant("SI_TARGET_ASPD", SI_TARGET_ASPD, false, false); + script->set_constant("SI_ATKER_MOVESPEED", SI_ATKER_MOVESPEED, false, false); + + script->set_constant("SI_ATKER_BLOOD", SI_ATKER_BLOOD, false, false); + script->set_constant("SI_TARGET_BLOOD", SI_TARGET_BLOOD, false, false); + script->set_constant("SI_ARMOR_PROPERTY", SI_ARMOR_PROPERTY, false, false); + //script->set_constant("SI_REUSE_LIMIT_A", SI_REUSE_LIMIT_A, false, false); + script->set_constant("SI_HELLPOWER", SI_HELLPOWER, false, false); + script->set_constant("SI_STEAMPACK", SI_STEAMPACK, false, false); + //script->set_constant("SI_REUSE_LIMIT_B", SI_REUSE_LIMIT_B, false, false); + //script->set_constant("SI_REUSE_LIMIT_C", SI_REUSE_LIMIT_C, false, false); + //script->set_constant("SI_REUSE_LIMIT_D", SI_REUSE_LIMIT_D, false, false); + //script->set_constant("SI_REUSE_LIMIT_E", SI_REUSE_LIMIT_E, false, false); + //script->set_constant("SI_REUSE_LIMIT_F", SI_REUSE_LIMIT_F, false, false); + script->set_constant("SI_INVINCIBLE", SI_INVINCIBLE, false, false); + script->set_constant("SI_CASH_PLUSONLYJOBEXP", SI_CASH_PLUSONLYJOBEXP, false, false); + script->set_constant("SI_PARTYFLEE", SI_PARTYFLEE, false, false); + script->set_constant("SI_ANGEL_PROTECT", SI_ANGEL_PROTECT, false, false); + //script->set_constant("SI_ENDURE_MDEF", SI_ENDURE_MDEF, false, false); + script->set_constant("SI_ENCHANTBLADE", SI_ENCHANTBLADE, false, false); + script->set_constant("SI_DEATHBOUND", SI_DEATHBOUND, false, false); + script->set_constant("SI_REFRESH", SI_REFRESH, false, false); + script->set_constant("SI_GIANTGROWTH", SI_GIANTGROWTH, false, false); + script->set_constant("SI_STONEHARDSKIN", SI_STONEHARDSKIN, false, false); + script->set_constant("SI_VITALITYACTIVATION", SI_VITALITYACTIVATION, false, false); + script->set_constant("SI_FIGHTINGSPIRIT", SI_FIGHTINGSPIRIT, false, false); + script->set_constant("SI_ABUNDANCE", SI_ABUNDANCE, false, false); + script->set_constant("SI_REUSE_MILLENNIUMSHIELD", SI_REUSE_MILLENNIUMSHIELD, false, false); + script->set_constant("SI_REUSE_CRUSHSTRIKE", SI_REUSE_CRUSHSTRIKE, false, false); + script->set_constant("SI_REUSE_REFRESH", SI_REUSE_REFRESH, false, false); + script->set_constant("SI_REUSE_STORMBLAST", SI_REUSE_STORMBLAST, false, false); + script->set_constant("SI_VENOMIMPRESS", SI_VENOMIMPRESS, false, false); + script->set_constant("SI_EPICLESIS", SI_EPICLESIS, false, false); + script->set_constant("SI_ORATIO", SI_ORATIO, false, false); + script->set_constant("SI_LAUDAAGNUS", SI_LAUDAAGNUS, false, false); + script->set_constant("SI_LAUDARAMUS", SI_LAUDARAMUS, false, false); + script->set_constant("SI_CLOAKINGEXCEED", SI_CLOAKINGEXCEED, false, false); + script->set_constant("SI_HALLUCINATIONWALK", SI_HALLUCINATIONWALK, false, false); + script->set_constant("SI_HALLUCINATIONWALK_POSTDELAY", SI_HALLUCINATIONWALK_POSTDELAY, false, false); + script->set_constant("SI_RENOVATIO", SI_RENOVATIO, false, false); + script->set_constant("SI_WEAPONBLOCKING", SI_WEAPONBLOCKING, false, false); + script->set_constant("SI_WEAPONBLOCKING_POSTDELAY", SI_WEAPONBLOCKING_POSTDELAY, false, false); + script->set_constant("SI_ROLLINGCUTTER", SI_ROLLINGCUTTER, false, false); + script->set_constant("SI_EXPIATIO", SI_EXPIATIO, false, false); + script->set_constant("SI_POISONINGWEAPON", SI_POISONINGWEAPON, false, false); + script->set_constant("SI_TOXIN", SI_TOXIN, false, false); + script->set_constant("SI_PARALYSE", SI_PARALYSE, false, false); + script->set_constant("SI_VENOMBLEED", SI_VENOMBLEED, false, false); + script->set_constant("SI_MAGICMUSHROOM", SI_MAGICMUSHROOM, false, false); + script->set_constant("SI_DEATHHURT", SI_DEATHHURT, false, false); + script->set_constant("SI_PYREXIA", SI_PYREXIA, false, false); + script->set_constant("SI_OBLIVIONCURSE", SI_OBLIVIONCURSE, false, false); + script->set_constant("SI_LEECHESEND", SI_LEECHESEND, false, false); + + script->set_constant("SI_DUPLELIGHT", SI_DUPLELIGHT, false, false); + script->set_constant("SI_FROSTMISTY", SI_FROSTMISTY, false, false); + script->set_constant("SI_FEARBREEZE", SI_FEARBREEZE, false, false); + script->set_constant("SI_ELECTRICSHOCKER", SI_ELECTRICSHOCKER, false, false); + script->set_constant("SI_MARSHOFABYSS", SI_MARSHOFABYSS, false, false); + script->set_constant("SI_RECOGNIZEDSPELL", SI_RECOGNIZEDSPELL, false, false); + script->set_constant("SI_STASIS", SI_STASIS, false, false); + script->set_constant("SI_WUGRIDER", SI_WUGRIDER, false, false); + script->set_constant("SI_WUGDASH", SI_WUGDASH, false, false); + script->set_constant("SI_WUGBITE", SI_WUGBITE, false, false); + script->set_constant("SI_CAMOUFLAGE", SI_CAMOUFLAGE, false, false); + script->set_constant("SI_ACCELERATION", SI_ACCELERATION, false, false); + script->set_constant("SI_HOVERING", SI_HOVERING, false, false); + script->set_constant("SI_SPHERE_1", SI_SPHERE_1, false, false); + script->set_constant("SI_SPHERE_2", SI_SPHERE_2, false, false); + script->set_constant("SI_SPHERE_3", SI_SPHERE_3, false, false); + script->set_constant("SI_SPHERE_4", SI_SPHERE_4, false, false); + script->set_constant("SI_SPHERE_5", SI_SPHERE_5, false, false); + script->set_constant("SI_MVPCARD_TAOGUNKA", SI_MVPCARD_TAOGUNKA, false, false); + script->set_constant("SI_MVPCARD_MISTRESS", SI_MVPCARD_MISTRESS, false, false); + script->set_constant("SI_MVPCARD_ORCHERO", SI_MVPCARD_ORCHERO, false, false); + script->set_constant("SI_MVPCARD_ORCLORD", SI_MVPCARD_ORCLORD, false, false); + script->set_constant("SI_OVERHEAT_LIMITPOINT", SI_OVERHEAT_LIMITPOINT, false, false); + script->set_constant("SI_OVERHEAT", SI_OVERHEAT, false, false); + script->set_constant("SI_SHAPESHIFT", SI_SHAPESHIFT, false, false); + script->set_constant("SI_INFRAREDSCAN", SI_INFRAREDSCAN, false, false); + script->set_constant("SI_MAGNETICFIELD", SI_MAGNETICFIELD, false, false); + script->set_constant("SI_NEUTRALBARRIER", SI_NEUTRALBARRIER, false, false); + script->set_constant("SI_NEUTRALBARRIER_MASTER", SI_NEUTRALBARRIER_MASTER, false, false); + script->set_constant("SI_STEALTHFIELD", SI_STEALTHFIELD, false, false); + script->set_constant("SI_STEALTHFIELD_MASTER", SI_STEALTHFIELD_MASTER, false, false); + script->set_constant("SI_MANU_ATK", SI_MANU_ATK, false, false); + script->set_constant("SI_MANU_DEF", SI_MANU_DEF, false, false); + script->set_constant("SI_SPL_ATK", SI_SPL_ATK, false, false); + script->set_constant("SI_SPL_DEF", SI_SPL_DEF, false, false); + script->set_constant("SI_REPRODUCE", SI_REPRODUCE, false, false); + script->set_constant("SI_MANU_MATK", SI_MANU_MATK, false, false); + script->set_constant("SI_SPL_MATK", SI_SPL_MATK, false, false); + script->set_constant("SI_STR_SCROLL", SI_STR_SCROLL, false, false); + script->set_constant("SI_INT_SCROLL", SI_INT_SCROLL, false, false); + script->set_constant("SI_LG_REFLECTDAMAGE", SI_LG_REFLECTDAMAGE, false, false); + script->set_constant("SI_FORCEOFVANGUARD", SI_FORCEOFVANGUARD, false, false); + script->set_constant("SI_BUCHEDENOEL", SI_BUCHEDENOEL, false, false); + script->set_constant("SI_AUTOSHADOWSPELL", SI_AUTOSHADOWSPELL, false, false); + script->set_constant("SI_SHADOWFORM", SI_SHADOWFORM, false, false); + script->set_constant("SI_RAID", SI_RAID, false, false); + script->set_constant("SI_SHIELDSPELL_DEF", SI_SHIELDSPELL_DEF, false, false); + script->set_constant("SI_SHIELDSPELL_MDEF", SI_SHIELDSPELL_MDEF, false, false); + script->set_constant("SI_SHIELDSPELL_REF", SI_SHIELDSPELL_REF, false, false); + script->set_constant("SI_BODYPAINT", SI_BODYPAINT, false, false); + + script->set_constant("SI_EXEEDBREAK", SI_EXEEDBREAK, false, false); + script->set_constant("SI_ADORAMUS", SI_ADORAMUS, false, false); + script->set_constant("SI_PRESTIGE", SI_PRESTIGE, false, false); + script->set_constant("SI_INVISIBILITY", SI_INVISIBILITY, false, false); + script->set_constant("SI_DEADLYINFECT", SI_DEADLYINFECT, false, false); + script->set_constant("SI_BANDING", SI_BANDING, false, false); + script->set_constant("SI_EARTHDRIVE", SI_EARTHDRIVE, false, false); + script->set_constant("SI_INSPIRATION", SI_INSPIRATION, false, false); + script->set_constant("SI_ENERVATION", SI_ENERVATION, false, false); + script->set_constant("SI_GROOMY", SI_GROOMY, false, false); + script->set_constant("SI_RAISINGDRAGON", SI_RAISINGDRAGON, false, false); + script->set_constant("SI_IGNORANCE", SI_IGNORANCE, false, false); + script->set_constant("SI_LAZINESS", SI_LAZINESS, false, false); + script->set_constant("SI_LIGHTNINGWALK", SI_LIGHTNINGWALK, false, false); + script->set_constant("SI_ACARAJE", SI_ACARAJE, false, false); + script->set_constant("SI_UNLUCKY", SI_UNLUCKY, false, false); + script->set_constant("SI_CURSEDCIRCLE_ATKER", SI_CURSEDCIRCLE_ATKER, false, false); + script->set_constant("SI_CURSEDCIRCLE_TARGET", SI_CURSEDCIRCLE_TARGET, false, false); + script->set_constant("SI_WEAKNESS", SI_WEAKNESS, false, false); + script->set_constant("SI_CRESCENTELBOW", SI_CRESCENTELBOW, false, false); + script->set_constant("SI_NOEQUIPACCESSARY", SI_NOEQUIPACCESSARY, false, false); + script->set_constant("SI_STRIPACCESSARY", SI_STRIPACCESSARY, false, false); + script->set_constant("SI_MANHOLE", SI_MANHOLE, false, false); + script->set_constant("SI_POPECOOKIE", SI_POPECOOKIE, false, false); + script->set_constant("SI_FALLENEMPIRE", SI_FALLENEMPIRE, false, false); + script->set_constant("SI_GENTLETOUCH_ENERGYGAIN", SI_GENTLETOUCH_ENERGYGAIN, false, false); + script->set_constant("SI_GENTLETOUCH_CHANGE", SI_GENTLETOUCH_CHANGE, false, false); + script->set_constant("SI_GENTLETOUCH_REVITALIZE", SI_GENTLETOUCH_REVITALIZE, false, false); + script->set_constant("SI_BLOODYLUST", SI_BLOODYLUST, false, false); + script->set_constant("SI_SWINGDANCE", SI_SWINGDANCE, false, false); + script->set_constant("SI_SYMPHONYOFLOVERS", SI_SYMPHONYOFLOVERS, false, false); + script->set_constant("SI_PROPERTYWALK", SI_PROPERTYWALK, false, false); + script->set_constant("SI_SPELLFIST", SI_SPELLFIST, false, false); + script->set_constant("SI_NETHERWORLD", SI_NETHERWORLD, false, false); + script->set_constant("SI_SIREN", SI_SIREN, false, false); + script->set_constant("SI_DEEPSLEEP", SI_DEEPSLEEP, false, false); + script->set_constant("SI_SIRCLEOFNATURE", SI_SIRCLEOFNATURE, false, false); + script->set_constant("SI_COLD", SI_COLD, false, false); + script->set_constant("SI_GLOOMYDAY", SI_GLOOMYDAY, false, false); + script->set_constant("SI_SONG_OF_MANA", SI_SONG_OF_MANA, false, false); + script->set_constant("SI_CLOUDKILL", SI_CLOUDKILL, false, false); + script->set_constant("SI_DANCEWITHWUG", SI_DANCEWITHWUG, false, false); + script->set_constant("SI_RUSHWINDMILL", SI_RUSHWINDMILL, false, false); + script->set_constant("SI_ECHOSONG", SI_ECHOSONG, false, false); + script->set_constant("SI_HARMONIZE", SI_HARMONIZE, false, false); + script->set_constant("SI_STRIKING", SI_STRIKING, false, false); + //script->set_constant("SI_WARMER", SI_WARMER, false, false); + script->set_constant("SI_MOONLITSERENADE", SI_MOONLITSERENADE, false, false); + script->set_constant("SI_SATURDAYNIGHTFEVER", SI_SATURDAYNIGHTFEVER, false, false); + script->set_constant("SI_SITDOWN_FORCE", SI_SITDOWN_FORCE, false, false); + + script->set_constant("SI_ANALYZE", SI_ANALYZE, false, false); + script->set_constant("SI_LERADSDEW", SI_LERADSDEW, false, false); + script->set_constant("SI_MELODYOFSINK", SI_MELODYOFSINK, false, false); + script->set_constant("SI_WARCRYOFBEYOND", SI_WARCRYOFBEYOND, false, false); + script->set_constant("SI_UNLIMITEDHUMMINGVOICE", SI_UNLIMITEDHUMMINGVOICE, false, false); + script->set_constant("SI_SPELLBOOK1", SI_SPELLBOOK1, false, false); + script->set_constant("SI_SPELLBOOK2", SI_SPELLBOOK2, false, false); + script->set_constant("SI_SPELLBOOK3", SI_SPELLBOOK3, false, false); + script->set_constant("SI_FREEZE_SP", SI_FREEZE_SP, false, false); + script->set_constant("SI_GN_TRAINING_SWORD", SI_GN_TRAINING_SWORD, false, false); + script->set_constant("SI_GN_REMODELING_CART", SI_GN_REMODELING_CART, false, false); + script->set_constant("SI_CARTSBOOST", SI_CARTSBOOST, false, false); + script->set_constant("SI_FIXEDCASTINGTM_REDUCE", SI_FIXEDCASTINGTM_REDUCE, false, false); + script->set_constant("SI_THORNTRAP", SI_THORNTRAP, false, false); + script->set_constant("SI_BLOODSUCKER", SI_BLOODSUCKER, false, false); + script->set_constant("SI_SPORE_EXPLOSION", SI_SPORE_EXPLOSION, false, false); + script->set_constant("SI_DEMONIC_FIRE", SI_DEMONIC_FIRE, false, false); + script->set_constant("SI_FIRE_EXPANSION_SMOKE_POWDER", SI_FIRE_EXPANSION_SMOKE_POWDER, false, false); + script->set_constant("SI_FIRE_EXPANSION_TEAR_GAS", SI_FIRE_EXPANSION_TEAR_GAS, false, false); + script->set_constant("SI_BLOCKING_PLAY", SI_BLOCKING_PLAY, false, false); + script->set_constant("SI_MANDRAGORA", SI_MANDRAGORA, false, false); + script->set_constant("SI_ACTIVATE", SI_ACTIVATE, false, false); + script->set_constant("SI_SECRAMENT", SI_SECRAMENT, false, false); + script->set_constant("SI_ASSUMPTIO2", SI_ASSUMPTIO2, false, false); + script->set_constant("SI_TK_SEVENWIND", SI_TK_SEVENWIND, false, false); + script->set_constant("SI_LIMIT_ODINS_RECALL", SI_LIMIT_ODINS_RECALL, false, false); + script->set_constant("SI_STOMACHACHE", SI_STOMACHACHE, false, false); + script->set_constant("SI_MYSTERIOUS_POWDER", SI_MYSTERIOUS_POWDER, false, false); + script->set_constant("SI_MELON_BOMB", SI_MELON_BOMB, false, false); + script->set_constant("SI_BANANA_BOMB_SITDOWN_POSTDELAY", SI_BANANA_BOMB_SITDOWN_POSTDELAY, false, false); + script->set_constant("SI_PROMOTE_HEALTH_RESERCH", SI_PROMOTE_HEALTH_RESERCH, false, false); + script->set_constant("SI_ENERGY_DRINK_RESERCH", SI_ENERGY_DRINK_RESERCH, false, false); + script->set_constant("SI_EXTRACT_WHITE_POTION_Z", SI_EXTRACT_WHITE_POTION_Z, false, false); + script->set_constant("SI_VITATA_500", SI_VITATA_500, false, false); + script->set_constant("SI_EXTRACT_SALAMINE_JUICE", SI_EXTRACT_SALAMINE_JUICE, false, false); + script->set_constant("SI_BOOST500", SI_BOOST500, false, false); + script->set_constant("SI_FULL_SWING_K", SI_FULL_SWING_K, false, false); + script->set_constant("SI_MANA_PLUS", SI_MANA_PLUS, false, false); + script->set_constant("SI_MUSTLE_M", SI_MUSTLE_M, false, false); + script->set_constant("SI_LIFE_FORCE_F", SI_LIFE_FORCE_F, false, false); + script->set_constant("SI_VACUUM_EXTREME", SI_VACUUM_EXTREME, false, false); + script->set_constant("SI_SAVAGE_STEAK", SI_SAVAGE_STEAK, false, false); + script->set_constant("SI_COCKTAIL_WARG_BLOOD", SI_COCKTAIL_WARG_BLOOD, false, false); + script->set_constant("SI_MINOR_BBQ", SI_MINOR_BBQ, false, false); + script->set_constant("SI_SIROMA_ICE_TEA", SI_SIROMA_ICE_TEA, false, false); + script->set_constant("SI_DROCERA_HERB_STEAMED", SI_DROCERA_HERB_STEAMED, false, false); + script->set_constant("SI_PUTTI_TAILS_NOODLES", SI_PUTTI_TAILS_NOODLES, false, false); + script->set_constant("SI_BANANA_BOMB", SI_BANANA_BOMB, false, false); + script->set_constant("SI_SUMMON_AGNI", SI_SUMMON_AGNI, false, false); + script->set_constant("SI_SPELLBOOK4", SI_SPELLBOOK4, false, false); + + script->set_constant("SI_SPELLBOOK5", SI_SPELLBOOK5, false, false); + script->set_constant("SI_SPELLBOOK6", SI_SPELLBOOK6, false, false); + script->set_constant("SI_SPELLBOOK7", SI_SPELLBOOK7, false, false); + script->set_constant("SI_ELEMENTAL_AGGRESSIVE", SI_ELEMENTAL_AGGRESSIVE, false, false); + script->set_constant("SI_RETURN_TO_ELDICASTES", SI_RETURN_TO_ELDICASTES, false, false); + script->set_constant("SI_BANDING_DEFENCE", SI_BANDING_DEFENCE, false, false); + script->set_constant("SI_SKELSCROLL", SI_SKELSCROLL, false, false); + script->set_constant("SI_DISTRUCTIONSCROLL", SI_DISTRUCTIONSCROLL, false, false); + script->set_constant("SI_ROYALSCROLL", SI_ROYALSCROLL, false, false); + script->set_constant("SI_IMMUNITYSCROLL", SI_IMMUNITYSCROLL, false, false); + script->set_constant("SI_MYSTICSCROLL", SI_MYSTICSCROLL, false, false); + script->set_constant("SI_BATTLESCROLL", SI_BATTLESCROLL, false, false); + script->set_constant("SI_ARMORSCROLL", SI_ARMORSCROLL, false, false); + script->set_constant("SI_FREYJASCROLL", SI_FREYJASCROLL, false, false); + script->set_constant("SI_SOULSCROLL", SI_SOULSCROLL, false, false); + script->set_constant("SI_CIRCLE_OF_FIRE", SI_CIRCLE_OF_FIRE, false, false); + script->set_constant("SI_CIRCLE_OF_FIRE_OPTION", SI_CIRCLE_OF_FIRE_OPTION, false, false); + script->set_constant("SI_FIRE_CLOAK", SI_FIRE_CLOAK, false, false); + script->set_constant("SI_FIRE_CLOAK_OPTION", SI_FIRE_CLOAK_OPTION, false, false); + script->set_constant("SI_WATER_SCREEN", SI_WATER_SCREEN, false, false); + script->set_constant("SI_WATER_SCREEN_OPTION", SI_WATER_SCREEN_OPTION, false, false); + script->set_constant("SI_WATER_DROP", SI_WATER_DROP, false, false); + script->set_constant("SI_WATER_DROP_OPTION", SI_WATER_DROP_OPTION, false, false); + script->set_constant("SI_WIND_STEP", SI_WIND_STEP, false, false); + script->set_constant("SI_WIND_STEP_OPTION", SI_WIND_STEP_OPTION, false, false); + script->set_constant("SI_WIND_CURTAIN", SI_WIND_CURTAIN, false, false); + script->set_constant("SI_WIND_CURTAIN_OPTION", SI_WIND_CURTAIN_OPTION, false, false); + script->set_constant("SI_WATER_BARRIER", SI_WATER_BARRIER, false, false); + script->set_constant("SI_ZEPHYR", SI_ZEPHYR, false, false); + script->set_constant("SI_SOLID_SKIN", SI_SOLID_SKIN, false, false); + script->set_constant("SI_SOLID_SKIN_OPTION", SI_SOLID_SKIN_OPTION, false, false); + script->set_constant("SI_STONE_SHIELD", SI_STONE_SHIELD, false, false); + script->set_constant("SI_STONE_SHIELD_OPTION", SI_STONE_SHIELD_OPTION, false, false); + script->set_constant("SI_POWER_OF_GAIA", SI_POWER_OF_GAIA, false, false); + //script->set_constant("SI_EL_WAIT", SI_EL_WAIT, false, false); + //script->set_constant("SI_EL_PASSIVE", SI_EL_PASSIVE, false, false); + //script->set_constant("SI_EL_DEFENSIVE", SI_EL_DEFENSIVE, false, false); + //script->set_constant("SI_EL_OFFENSIVE", SI_EL_OFFENSIVE, false, false); + //script->set_constant("SI_EL_COST", SI_EL_COST, false, false); + script->set_constant("SI_PYROTECHNIC", SI_PYROTECHNIC, false, false); + script->set_constant("SI_PYROTECHNIC_OPTION", SI_PYROTECHNIC_OPTION, false, false); + script->set_constant("SI_HEATER", SI_HEATER, false, false); + script->set_constant("SI_HEATER_OPTION", SI_HEATER_OPTION, false, false); + script->set_constant("SI_TROPIC", SI_TROPIC, false, false); + script->set_constant("SI_TROPIC_OPTION", SI_TROPIC_OPTION, false, false); + script->set_constant("SI_AQUAPLAY", SI_AQUAPLAY, false, false); + script->set_constant("SI_AQUAPLAY_OPTION", SI_AQUAPLAY_OPTION, false, false); + script->set_constant("SI_COOLER", SI_COOLER, false, false); + script->set_constant("SI_COOLER_OPTION", SI_COOLER_OPTION, false, false); + script->set_constant("SI_CHILLY_AIR", SI_CHILLY_AIR, false, false); + + script->set_constant("SI_CHILLY_AIR_OPTION", SI_CHILLY_AIR_OPTION, false, false); + script->set_constant("SI_GUST", SI_GUST, false, false); + script->set_constant("SI_GUST_OPTION", SI_GUST_OPTION, false, false); + script->set_constant("SI_BLAST", SI_BLAST, false, false); + script->set_constant("SI_BLAST_OPTION", SI_BLAST_OPTION, false, false); + script->set_constant("SI_WILD_STORM", SI_WILD_STORM, false, false); + script->set_constant("SI_WILD_STORM_OPTION", SI_WILD_STORM_OPTION, false, false); + script->set_constant("SI_PETROLOGY", SI_PETROLOGY, false, false); + script->set_constant("SI_PETROLOGY_OPTION", SI_PETROLOGY_OPTION, false, false); + script->set_constant("SI_CURSED_SOIL", SI_CURSED_SOIL, false, false); + script->set_constant("SI_CURSED_SOIL_OPTION", SI_CURSED_SOIL_OPTION, false, false); + script->set_constant("SI_UPHEAVAL", SI_UPHEAVAL, false, false); + script->set_constant("SI_UPHEAVAL_OPTION", SI_UPHEAVAL_OPTION, false, false); + script->set_constant("SI_TIDAL_WEAPON", SI_TIDAL_WEAPON, false, false); + script->set_constant("SI_TIDAL_WEAPON_OPTION", SI_TIDAL_WEAPON_OPTION, false, false); + script->set_constant("SI_ROCK_CRUSHER", SI_ROCK_CRUSHER, false, false); + script->set_constant("SI_ROCK_CRUSHER_ATK", SI_ROCK_CRUSHER_ATK, false, false); + script->set_constant("SI_FIRE_INSIGNIA", SI_FIRE_INSIGNIA, false, false); + script->set_constant("SI_WATER_INSIGNIA", SI_WATER_INSIGNIA, false, false); + script->set_constant("SI_WIND_INSIGNIA", SI_WIND_INSIGNIA, false, false); + script->set_constant("SI_EARTH_INSIGNIA", SI_EARTH_INSIGNIA, false, false); + script->set_constant("SI_EQUIPED_FLOOR", SI_EQUIPED_FLOOR, false, false); + script->set_constant("SI_GUARDIAN_RECALL", SI_GUARDIAN_RECALL, false, false); + script->set_constant("SI_MORA_BUFF", SI_MORA_BUFF, false, false); + script->set_constant("SI_REUSE_LIMIT_G", SI_REUSE_LIMIT_G, false, false); + script->set_constant("SI_REUSE_LIMIT_H", SI_REUSE_LIMIT_H, false, false); + script->set_constant("SI_NEEDLE_OF_PARALYZE", SI_NEEDLE_OF_PARALYZE, false, false); + script->set_constant("SI_PAIN_KILLER", SI_PAIN_KILLER, false, false); + script->set_constant("SI_G_LIFEPOTION", SI_G_LIFEPOTION, false, false); + script->set_constant("SI_VITALIZE_POTION", SI_VITALIZE_POTION, false, false); + script->set_constant("SI_LIGHT_OF_REGENE", SI_LIGHT_OF_REGENE, false, false); + script->set_constant("SI_OVERED_BOOST", SI_OVERED_BOOST, false, false); + script->set_constant("SI_SILENT_BREEZE", SI_SILENT_BREEZE, false, false); + script->set_constant("SI_ODINS_POWER", SI_ODINS_POWER, false, false); + script->set_constant("SI_STYLE_CHANGE", SI_STYLE_CHANGE, false, false); + script->set_constant("SI_SONIC_CLAW_POSTDELAY", SI_SONIC_CLAW_POSTDELAY, false, false); + // 586 + // 587 + // 588 + // 589 + // 590 + // 591 + // 592 + // 593 + // 594 + // 595 + script->set_constant("SI_SILVERVEIN_RUSH_POSTDELAY", SI_SILVERVEIN_RUSH_POSTDELAY, false, false); + script->set_constant("SI_MIDNIGHT_FRENZY_POSTDELAY", SI_MIDNIGHT_FRENZY_POSTDELAY, false, false); + script->set_constant("SI_GOLDENE_FERSE", SI_GOLDENE_FERSE, false, false); + script->set_constant("SI_ANGRIFFS_MODUS", SI_ANGRIFFS_MODUS, false, false); + + script->set_constant("SI_TINDER_BREAKER", SI_TINDER_BREAKER, false, false); + script->set_constant("SI_TINDER_BREAKER_POSTDELAY", SI_TINDER_BREAKER_POSTDELAY, false, false); + script->set_constant("SI_CBC", SI_CBC, false, false); + script->set_constant("SI_CBC_POSTDELAY", SI_CBC_POSTDELAY, false, false); + script->set_constant("SI_EQC", SI_EQC, false, false); + script->set_constant("SI_MAGMA_FLOW", SI_MAGMA_FLOW, false, false); + script->set_constant("SI_GRANITIC_ARMOR", SI_GRANITIC_ARMOR, false, false); + script->set_constant("SI_PYROCLASTIC", SI_PYROCLASTIC, false, false); + script->set_constant("SI_VOLCANIC_ASH", SI_VOLCANIC_ASH, false, false); + script->set_constant("SI_SPIRITS_SAVEINFO1", SI_SPIRITS_SAVEINFO1, false, false); + script->set_constant("SI_SPIRITS_SAVEINFO2", SI_SPIRITS_SAVEINFO2, false, false); + script->set_constant("SI_MAGIC_CANDY", SI_MAGIC_CANDY, false, false); + script->set_constant("SI_SEARCH_STORE_INFO", SI_SEARCH_STORE_INFO, false, false); + script->set_constant("SI_ALL_RIDING", SI_ALL_RIDING, false, false); + script->set_constant("SI_ALL_RIDING_REUSE_LIMIT", SI_ALL_RIDING_REUSE_LIMIT, false, false); + script->set_constant("SI_MACRO", SI_MACRO, false, false); + script->set_constant("SI_MACRO_POSTDELAY", SI_MACRO_POSTDELAY, false, false); + script->set_constant("SI_BEER_BOTTLE_CAP", SI_BEER_BOTTLE_CAP, false, false); + script->set_constant("SI_OVERLAPEXPUP", SI_OVERLAPEXPUP, false, false); + script->set_constant("SI_PC_IZ_DUN05", SI_PC_IZ_DUN05, false, false); + script->set_constant("SI_CRUSHSTRIKE", SI_CRUSHSTRIKE, false, false); + script->set_constant("SI_MONSTER_TRANSFORM", SI_MONSTER_TRANSFORM, false, false); + script->set_constant("SI_SIT", SI_SIT, false, false); + script->set_constant("SI_ONAIR", SI_ONAIR, false, false); + script->set_constant("SI_MTF_ASPD", SI_MTF_ASPD, false, false); + script->set_constant("SI_MTF_RANGEATK", SI_MTF_RANGEATK, false, false); + script->set_constant("SI_MTF_MATK", SI_MTF_MATK, false, false); + script->set_constant("SI_MTF_MLEATKED", SI_MTF_MLEATKED, false, false); + script->set_constant("SI_MTF_CRIDAMAGE", SI_MTF_CRIDAMAGE, false, false); + script->set_constant("SI_REUSE_LIMIT_MTF", SI_REUSE_LIMIT_MTF, false, false); + script->set_constant("SI_MACRO_PERMIT", SI_MACRO_PERMIT, false, false); + script->set_constant("SI_MACRO_PLAY", SI_MACRO_PLAY, false, false); + script->set_constant("SI_SKF_CAST", SI_SKF_CAST, false, false); + script->set_constant("SI_SKF_ASPD", SI_SKF_ASPD, false, false); + script->set_constant("SI_SKF_ATK", SI_SKF_ATK, false, false); + script->set_constant("SI_SKF_MATK", SI_SKF_MATK, false, false); + script->set_constant("SI_REWARD_PLUSONLYJOBEXP", SI_REWARD_PLUSONLYJOBEXP, false, false); + script->set_constant("SI_HANDICAPSTATE_NORECOVER", SI_HANDICAPSTATE_NORECOVER, false, false); + script->set_constant("SI_SET_NUM_DEF", SI_SET_NUM_DEF, false, false); + script->set_constant("SI_SET_NUM_MDEF", SI_SET_NUM_MDEF, false, false); + script->set_constant("SI_SET_PER_DEF", SI_SET_PER_DEF, false, false); + script->set_constant("SI_SET_PER_MDEF", SI_SET_PER_MDEF, false, false); + script->set_constant("SI_PARTYBOOKING_SEARCH_DEALY", SI_PARTYBOOKING_SEARCH_DEALY, false, false); + script->set_constant("SI_PARTYBOOKING_REGISTER_DEALY", SI_PARTYBOOKING_REGISTER_DEALY, false, false); + script->set_constant("SI_PERIOD_TIME_CHECK_DETECT_SKILL", SI_PERIOD_TIME_CHECK_DETECT_SKILL, false, false); + script->set_constant("SI_KO_JYUMONJIKIRI", SI_KO_JYUMONJIKIRI, false, false); + script->set_constant("SI_MEIKYOUSISUI", SI_MEIKYOUSISUI, false, false); + script->set_constant("SI_ATTHASTE_CASH", SI_ATTHASTE_CASH, false, false); + script->set_constant("SI_EQUIPPED_DIVINE_ARMOR", SI_EQUIPPED_DIVINE_ARMOR, false, false); + script->set_constant("SI_EQUIPPED_HOLY_ARMOR", SI_EQUIPPED_HOLY_ARMOR, false, false); + + script->set_constant("SI_2011RWC", SI_2011RWC, false, false); + script->set_constant("SI_KYOUGAKU", SI_KYOUGAKU, false, false); + script->set_constant("SI_IZAYOI", SI_IZAYOI, false, false); + script->set_constant("SI_ZENKAI", SI_ZENKAI, false, false); + script->set_constant("SI_KG_KAGEHUMI", SI_KG_KAGEHUMI, false, false); + script->set_constant("SI_KYOMU", SI_KYOMU, false, false); + script->set_constant("SI_KAGEMUSYA", SI_KAGEMUSYA, false, false); + script->set_constant("SI_ZANGETSU", SI_ZANGETSU, false, false); + script->set_constant("SI_PHI_DEMON", SI_PHI_DEMON, false, false); + script->set_constant("SI_GENSOU", SI_GENSOU, false, false); + script->set_constant("SI_AKAITSUKI", SI_AKAITSUKI, false, false); + script->set_constant("SI_TETANY", SI_TETANY, false, false); + script->set_constant("SI_GM_BATTLE", SI_GM_BATTLE, false, false); + script->set_constant("SI_GM_BATTLE2", SI_GM_BATTLE2, false, false); + script->set_constant("SI_2011RWC_SCROLL", SI_2011RWC_SCROLL, false, false); + script->set_constant("SI_ACTIVE_MONSTER_TRANSFORM", SI_ACTIVE_MONSTER_TRANSFORM, false, false); + script->set_constant("SI_MYSTICPOWDER", SI_MYSTICPOWDER, false, false); + script->set_constant("SI_ECLAGE_RECALL", SI_ECLAGE_RECALL, false, false); + script->set_constant("SI_ENTRY_QUEUE_APPLY_DELAY", SI_ENTRY_QUEUE_APPLY_DELAY, false, false); + script->set_constant("SI_REUSE_LIMIT_ECL", SI_REUSE_LIMIT_ECL, false, false); + script->set_constant("SI_M_LIFEPOTION", SI_M_LIFEPOTION, false, false); + script->set_constant("SI_ENTRY_QUEUE_NOTIFY_ADMISSION_TIME_OUT", SI_ENTRY_QUEUE_NOTIFY_ADMISSION_TIME_OUT, false, false); + script->set_constant("SI_UNKNOWN_NAME", SI_UNKNOWN_NAME, false, false); + script->set_constant("SI_ON_PUSH_CART", SI_ON_PUSH_CART, false, false); + script->set_constant("SI_HAT_EFFECT", SI_HAT_EFFECT, false, false); + script->set_constant("SI_FLOWER_LEAF", SI_FLOWER_LEAF, false, false); + script->set_constant("SI_RAY_OF_PROTECTION", SI_RAY_OF_PROTECTION, false, false); + script->set_constant("SI_GLASTHEIM_ATK", SI_GLASTHEIM_ATK, false, false); + script->set_constant("SI_GLASTHEIM_DEF", SI_GLASTHEIM_DEF, false, false); + script->set_constant("SI_GLASTHEIM_HEAL", SI_GLASTHEIM_HEAL, false, false); + script->set_constant("SI_GLASTHEIM_HIDDEN", SI_GLASTHEIM_HIDDEN, false, false); + script->set_constant("SI_GLASTHEIM_STATE", SI_GLASTHEIM_STATE, false, false); + script->set_constant("SI_GLASTHEIM_ITEMDEF", SI_GLASTHEIM_ITEMDEF, false, false); + script->set_constant("SI_GLASTHEIM_HPSP", SI_GLASTHEIM_HPSP, false, false); + script->set_constant("SI_HOMUN_SKILL_POSTDELAY", SI_HOMUN_SKILL_POSTDELAY, false, false); + script->set_constant("SI_ALMIGHTY", SI_ALMIGHTY, false, false); + script->set_constant("SI_GVG_GIANT", SI_GVG_GIANT, false, false); + script->set_constant("SI_GVG_GOLEM", SI_GVG_GOLEM, false, false); + script->set_constant("SI_GVG_STUN", SI_GVG_STUN, false, false); + script->set_constant("SI_GVG_STONE", SI_GVG_STONE, false, false); + script->set_constant("SI_GVG_FREEZ", SI_GVG_FREEZ, false, false); + script->set_constant("SI_GVG_SLEEP", SI_GVG_SLEEP, false, false); + script->set_constant("SI_GVG_CURSE", SI_GVG_CURSE, false, false); + script->set_constant("SI_GVG_SILENCE", SI_GVG_SILENCE, false, false); + script->set_constant("SI_GVG_BLIND", SI_GVG_BLIND, false, false); + script->set_constant("SI_CLIENT_ONLY_EQUIP_ARROW", SI_CLIENT_ONLY_EQUIP_ARROW, false, false); + script->set_constant("SI_CLAN_INFO", SI_CLAN_INFO, false, false); + script->set_constant("SI_JP_EVENT01", SI_JP_EVENT01, false, false); + script->set_constant("SI_JP_EVENT02", SI_JP_EVENT02, false, false); + script->set_constant("SI_JP_EVENT03", SI_JP_EVENT03, false, false); + + script->set_constant("SI_JP_EVENT04", SI_JP_EVENT04, false, false); + script->set_constant("SI_TELEPORT_FIXEDCASTINGDELAY", SI_TELEPORT_FIXEDCASTINGDELAY, false, false); + script->set_constant("SI_GEFFEN_MAGIC1", SI_GEFFEN_MAGIC1, false, false); + script->set_constant("SI_GEFFEN_MAGIC2", SI_GEFFEN_MAGIC2, false, false); + script->set_constant("SI_GEFFEN_MAGIC3", SI_GEFFEN_MAGIC3, false, false); + script->set_constant("SI_QUEST_BUFF1", SI_QUEST_BUFF1, false, false); + script->set_constant("SI_QUEST_BUFF2", SI_QUEST_BUFF2, false, false); + script->set_constant("SI_QUEST_BUFF3", SI_QUEST_BUFF3, false, false); + script->set_constant("SI_REUSE_LIMIT_RECALL", SI_REUSE_LIMIT_RECALL, false, false); + script->set_constant("SI_SAVEPOSITION", SI_SAVEPOSITION, false, false); + script->set_constant("SI_HANDICAPSTATE_ICEEXPLO", SI_HANDICAPSTATE_ICEEXPLO, false, false); + script->set_constant("SI_FENRIR_CARD", SI_FENRIR_CARD, false, false); + script->set_constant("SI_REUSE_LIMIT_ASPD_POTION", SI_REUSE_LIMIT_ASPD_POTION, false, false); + script->set_constant("SI_MAXPAIN", SI_MAXPAIN, false, false); + script->set_constant("SI_PC_STOP", SI_PC_STOP, false, false); + script->set_constant("SI_FRIGG_SONG", SI_FRIGG_SONG, false, false); + script->set_constant("SI_OFFERTORIUM", SI_OFFERTORIUM, false, false); + script->set_constant("SI_TELEKINESIS_INTENSE", SI_TELEKINESIS_INTENSE, false, false); + script->set_constant("SI_MOONSTAR", SI_MOONSTAR, false, false); + script->set_constant("SI_STRANGELIGHTS", SI_STRANGELIGHTS, false, false); + script->set_constant("SI_FULL_THROTTLE", SI_FULL_THROTTLE, false, false); + script->set_constant("SI_REBOUND", SI_REBOUND, false, false); + script->set_constant("SI_UNLIMIT", SI_UNLIMIT, false, false); + script->set_constant("SI_KINGS_GRACE", SI_KINGS_GRACE, false, false); + script->set_constant("SI_ITEM_ATKMAX", SI_ITEM_ATKMAX, false, false); + script->set_constant("SI_ITEM_ATKMIN", SI_ITEM_ATKMIN, false, false); + script->set_constant("SI_ITEM_MATKMAX", SI_ITEM_MATKMAX, false, false); + script->set_constant("SI_ITEM_MATKMIN", SI_ITEM_MATKMIN, false, false); + script->set_constant("SI_SUPER_STAR", SI_SUPER_STAR, false, false); + script->set_constant("SI_HIGH_RANKER", SI_HIGH_RANKER, false, false); + script->set_constant("SI_DARKCROW", SI_DARKCROW, false, false); + script->set_constant("SI_2013_VALENTINE1", SI_2013_VALENTINE1, false, false); + script->set_constant("SI_2013_VALENTINE2", SI_2013_VALENTINE2, false, false); + script->set_constant("SI_2013_VALENTINE3", SI_2013_VALENTINE3, false, false); + script->set_constant("SI_ILLUSIONDOPING", SI_ILLUSIONDOPING, false, false); + //script->set_constant("SI_WIDEWEB", SI_WIDEWEB, false, false); + script->set_constant("SI_CHILL", SI_CHILL, false, false); + script->set_constant("SI_BURNT", SI_BURNT, false, false); + //script->set_constant("SI_PCCAFE_PLAY_TIME", SI_PCCAFE_PLAY_TIME, false, false); + //script->set_constant("SI_TWISTED_TIME", SI_TWISTED_TIME, false, false); + script->set_constant("SI_FLASHCOMBO", SI_FLASHCOMBO, false, false); + //script->set_constant("SI_JITTER_BUFF1", SI_JITTER_BUFF1, false, false); + //script->set_constant("SI_JITTER_BUFF2", SI_JITTER_BUFF2, false, false); + //script->set_constant("SI_JITTER_BUFF3", SI_JITTER_BUFF3, false, false); + //script->set_constant("SI_JITTER_BUFF4", SI_JITTER_BUFF4, false, false); + //script->set_constant("SI_JITTER_BUFF5", SI_JITTER_BUFF5, false, false); + //script->set_constant("SI_JITTER_BUFF6", SI_JITTER_BUFF6, false, false); + //script->set_constant("SI_JITTER_BUFF7", SI_JITTER_BUFF7, false, false); + //script->set_constant("SI_JITTER_BUFF8", SI_JITTER_BUFF8, false, false); + //script->set_constant("SI_JITTER_BUFF9", SI_JITTER_BUFF9, false, false); + + //script->set_constant("SI_JITTER_BUFF10", SI_JITTER_BUFF10, false, false); + script->set_constant("SI_CUP_OF_BOZA", SI_CUP_OF_BOZA, false, false); + script->set_constant("SI_B_TRAP", SI_B_TRAP, false, false); + script->set_constant("SI_E_CHAIN", SI_E_CHAIN, false, false); + script->set_constant("SI_E_QD_SHOT_READY", SI_E_QD_SHOT_READY, false, false); + script->set_constant("SI_C_MARKER", SI_C_MARKER, false, false); + script->set_constant("SI_H_MINE", SI_H_MINE, false, false); + script->set_constant("SI_H_MINE_SPLASH", SI_H_MINE_SPLASH, false, false); + script->set_constant("SI_P_ALTER", SI_P_ALTER, false, false); + script->set_constant("SI_HEAT_BARREL", SI_HEAT_BARREL, false, false); + script->set_constant("SI_ANTI_M_BLAST", SI_ANTI_M_BLAST, false, false); + script->set_constant("SI_SLUGSHOT", SI_SLUGSHOT, false, false); + script->set_constant("SI_SWORDCLAN", SI_SWORDCLAN, false, false); + script->set_constant("SI_ARCWANDCLAN", SI_ARCWANDCLAN, false, false); + script->set_constant("SI_GOLDENMACECLAN", SI_GOLDENMACECLAN, false, false); + script->set_constant("SI_CROSSBOWCLAN", SI_CROSSBOWCLAN, false, false); + script->set_constant("SI_PACKING_ENVELOPE1", SI_PACKING_ENVELOPE1, false, false); + script->set_constant("SI_PACKING_ENVELOPE2", SI_PACKING_ENVELOPE2, false, false); + script->set_constant("SI_PACKING_ENVELOPE3", SI_PACKING_ENVELOPE3, false, false); + script->set_constant("SI_PACKING_ENVELOPE4", SI_PACKING_ENVELOPE4, false, false); + script->set_constant("SI_PACKING_ENVELOPE5", SI_PACKING_ENVELOPE5, false, false); + script->set_constant("SI_PACKING_ENVELOPE6", SI_PACKING_ENVELOPE6, false, false); + script->set_constant("SI_PACKING_ENVELOPE7", SI_PACKING_ENVELOPE7, false, false); + script->set_constant("SI_PACKING_ENVELOPE8", SI_PACKING_ENVELOPE8, false, false); + script->set_constant("SI_PACKING_ENVELOPE9", SI_PACKING_ENVELOPE9, false, false); + script->set_constant("SI_PACKING_ENVELOPE10", SI_PACKING_ENVELOPE10, false, false); + script->set_constant("SI_GLASTHEIM_TRANS", SI_GLASTHEIM_TRANS, false, false); + //script->set_constant("SI_ZONGZI_POUCH_TRANS", SI_ZONGZI_POUCH_TRANS, false, false); + script->set_constant("SI_HEAT_BARREL_AFTER", SI_HEAT_BARREL_AFTER, false, false); + script->set_constant("SI_DECORATION_OF_MUSIC", SI_DECORATION_OF_MUSIC, false, false); + //script->set_constant("SI_OVERSEAEXPUP", SI_OVERSEAEXPUP, false, false); + //script->set_constant("SI_CLOWN_N_GYPSY_CARD", SI_CLOWN_N_GYPSY_CARD, false, false); + //script->set_constant("SI_OPEN_NPC_MARKET", SI_OPEN_NPC_MARKET, false, false); + //script->set_constant("SI_BEEF_RIB_STEW", SI_BEEF_RIB_STEW, false, false); + //script->set_constant("SI_PORK_RIB_STEW", SI_PORK_RIB_STEW, false, false); + //script->set_constant("SI_CHUSEOK_MONDAY", SI_CHUSEOK_MONDAY, false, false); + //script->set_constant("SI_CHUSEOK_TUESDAY", SI_CHUSEOK_TUESDAY, false, false); + //script->set_constant("SI_CHUSEOK_WEDNESDAY", SI_CHUSEOK_WEDNESDAY, false, false); + //script->set_constant("SI_CHUSEOK_THURSDAY", SI_CHUSEOK_THURSDAY, false, false); + //script->set_constant("SI_CHUSEOK_FRIDAY", SI_CHUSEOK_FRIDAY, false, false); + //script->set_constant("SI_CHUSEOK_WEEKEND", SI_CHUSEOK_WEEKEND, false, false); + //script->set_constant("SI_ALL_LIGHTGUARD", SI_ALL_LIGHTGUARD, false, false); + //script->set_constant("SI_ALL_LIGHTGUARD_COOL_TIME", SI_ALL_LIGHTGUARD_COOL_TIME, false, false); + script->set_constant("SI_MTF_MHP", SI_MTF_MHP, false, false); + script->set_constant("SI_MTF_MSP", SI_MTF_MSP, false, false); + script->set_constant("SI_MTF_PUMPKIN", SI_MTF_PUMPKIN, false, false); + script->set_constant("SI_MTF_HITFLEE", SI_MTF_HITFLEE, false, false); + //script->set_constant("SI_MTF_CRIDAMAGE2", SI_MTF_CRIDAMAGE2, false, false); + //script->set_constant("SI_MTF_SPDRAIN", SI_MTF_SPDRAIN, false, false); + //script->set_constant("SI_ACUO_MINT_GUM", SI_ACUO_MINT_GUM, false, false); + + //script->set_constant("SI_S_HEALPOTION", SI_S_HEALPOTION, false, false); + //script->set_constant("SI_REUSE_LIMIT_S_HEAL_POTION", SI_REUSE_LIMIT_S_HEAL_POTION, false, false); + //script->set_constant("SI_PLAYTIME_STATISTICS", SI_PLAYTIME_STATISTICS, false, false); + //script->set_constant("SI_GN_CHANGEMATERIAL_OPERATOR", SI_GN_CHANGEMATERIAL_OPERATOR, false, false); + //script->set_constant("SI_GN_MIX_COOKING_OPERATOR", SI_GN_MIX_COOKING_OPERATOR, false, false); + //script->set_constant("SI_GN_MAKEBOMB_OPERATOR", SI_GN_MAKEBOMB_OPERATOR, false, false); + //script->set_constant("SI_GN_S_PHARMACY_OPERATOR", SI_GN_S_PHARMACY_OPERATOR, false, false); + //script->set_constant("SI_SO_EL_ANALYSIS_DISASSEMBLY_OPERATOR", SI_SO_EL_ANALYSIS_DISASSEMBLY_OPERATOR, false, false); + //script->set_constant("SI_SO_EL_ANALYSIS_COMBINATION_OPERATOR", SI_SO_EL_ANALYSIS_COMBINATION_OPERATOR, false, false); + //script->set_constant("SI_NC_MAGICDECOY_OPERATOR", SI_NC_MAGICDECOY_OPERATOR, false, false); + //script->set_constant("SI_GUILD_STORAGE", SI_GUILD_STORAGE, false, false); + //script->set_constant("SI_GC_POISONINGWEAPON_OPERATOR", SI_GC_POISONINGWEAPON_OPERATOR, false, false); + //script->set_constant("SI_WS_WEAPONREFINE_OPERATOR", SI_WS_WEAPONREFINE_OPERATOR, false, false); + //script->set_constant("SI_BS_REPAIRWEAPON_OPERATOR", SI_BS_REPAIRWEAPON_OPERATOR, false, false); + //script->set_constant("SI_GET_MAILBOX", SI_GET_MAILBOX, false, false); + //script->set_constant("SI_JUMPINGCLAN", SI_JUMPINGCLAN, false, false); + //script->set_constant("SI_JP_OTP", SI_JP_OTP, false, false); + //script->set_constant("SI_HANDICAPTOLERANCE_LEVELGAP", SI_HANDICAPTOLERANCE_LEVELGAP, false, false); + //script->set_constant("SI_MTF_RANGEATK2", SI_MTF_RANGEATK2, false, false); + //script->set_constant("SI_MTF_ASPD2", SI_MTF_ASPD2, false, false); + //script->set_constant("SI_MTF_MATK2", SI_MTF_MATK2, false, false); + //script->set_constant("SI_SHOW_NPCHPBAR", SI_SHOW_NPCHPBAR, false, false); + script->set_constant("SI_FLOWERSMOKE", SI_FLOWERSMOKE, false, false); + script->set_constant("SI_FSTONE", SI_FSTONE, false, false); + //script->set_constant("SI_DAILYSENDMAILCNT", SI_DAILYSENDMAILCNT, false, false); + //script->set_constant("SI_QSCARABA", SI_QSCARABA, false, false); + script->set_constant("SI_LJOSALFAR", SI_LJOSALFAR, false, false); + //script->set_constant("SI_PAD_READER_KNIGHT", SI_PAD_READER_KNIGHT, false, false); + //script->set_constant("SI_PAD_READER_CRUSADER", SI_PAD_READER_CRUSADER, false, false); + //script->set_constant("SI_PAD_READER_BLACKSMITH", SI_PAD_READER_BLACKSMITH, false, false); + //script->set_constant("SI_PAD_READER_ALCHEMIST", SI_PAD_READER_ALCHEMIST, false, false); + //script->set_constant("SI_PAD_READER_ASSASSIN", SI_PAD_READER_ASSASSIN, false, false); + //script->set_constant("SI_PAD_READER_ROGUE", SI_PAD_READER_ROGUE, false, false); + //script->set_constant("SI_PAD_READER_WIZARD", SI_PAD_READER_WIZARD, false, false); + //script->set_constant("SI_PAD_READER_SAGE", SI_PAD_READER_SAGE, false, false); + //script->set_constant("SI_PAD_READER_PRIEST", SI_PAD_READER_PRIEST, false, false); + //script->set_constant("SI_PAD_READER_MONK", SI_PAD_READER_MONK, false, false); + //script->set_constant("SI_PAD_READER_HUNTER", SI_PAD_READER_HUNTER, false, false); + //script->set_constant("SI_PAD_READER_BARD", SI_PAD_READER_BARD, false, false); + //script->set_constant("SI_PAD_READER_DANCER", SI_PAD_READER_DANCER, false, false); + //script->set_constant("SI_PAD_READER_TAEKWON", SI_PAD_READER_TAEKWON, false, false); + //script->set_constant("SI_PAD_READER_NINJA", SI_PAD_READER_NINJA, false, false); + //script->set_constant("SI_PAD_READER_GUNSLINGER", SI_PAD_READER_GUNSLINGER, false, false); + //script->set_constant("SI_PAD_READER_SUPERNOVICE", SI_PAD_READER_SUPERNOVICE, false, false); + //script->set_constant("SI_ESSENCE_OF_TIME", SI_ESSENCE_OF_TIME, false, false); + //script->set_constant("SI_MINIGAME_ROULETTE", SI_MINIGAME_ROULETTE, false, false); + //script->set_constant("SI_MINIGAME_GOLD_POINT", SI_MINIGAME_GOLD_POINT, false, false); + //script->set_constant("SI_MINIGAME_SILVER_POINT", SI_MINIGAME_SILVER_POINT, false, false); + //script->set_constant("SI_MINIGAME_BRONZE_POINT", SI_MINIGAME_BRONZE_POINT, false, false); + script->set_constant("SI_HAPPINESS_STAR", SI_HAPPINESS_STAR, false, false); + + //script->set_constant("SI_SUMMEREVENT01", SI_SUMMEREVENT01, false, false); + //script->set_constant("SI_SUMMEREVENT02", SI_SUMMEREVENT02, false, false); + //script->set_constant("SI_SUMMEREVENT03", SI_SUMMEREVENT03, false, false); + //script->set_constant("SI_SUMMEREVENT04", SI_SUMMEREVENT04, false, false); + //script->set_constant("SI_SUMMEREVENT05", SI_SUMMEREVENT05, false, false); + //script->set_constant("SI_MINIGAME_ROULETTE_BONUS_ITEM", SI_MINIGAME_ROULETTE_BONUS_ITEM, false, false); + //script->set_constant("SI_DRESS_UP", SI_DRESS_UP, false, false); + script->set_constant("SI_MAPLE_FALLS", SI_MAPLE_FALLS, false, false); + //script->set_constant("SI_ALL_NIFLHEIM_RECALL", SI_ALL_NIFLHEIM_RECALL, false, false); + // 859 + //script->set_constant("SI_MTF_MARIONETTE", SI_MTF_MARIONETTE, false, false); + //script->set_constant("SI_MTF_LUDE", SI_MTF_LUDE, false, false); + //script->set_constant("SI_MTF_CRUISER", SI_MTF_CRUISER, false, false); + script->set_constant("SI_MERMAID_LONGING", SI_MERMAID_LONGING, false, false); + script->set_constant("SI_MAGICAL_FEATHER", SI_MAGICAL_FEATHER, false, false); + //script->set_constant("SI_DRACULA_CARD", SI_DRACULA_CARD, false, false); + // 866 + //script->set_constant("SI_LIMIT_POWER_BOOSTER", SI_LIMIT_POWER_BOOSTER, false, false); + // 868 + // 869 + // 870 + // 871 + script->set_constant("SI_TIME_ACCESSORY", SI_TIME_ACCESSORY, false, false); + //script->set_constant("SI_EP16_DEF", SI_EP16_DEF, false, false); + //script->set_constant("SI_NORMAL_ATKED_SP", SI_NORMAL_ATKED_SP, false, false); + //script->set_constant("SI_BODYSTATE_STONECURSE", SI_BODYSTATE_STONECURSE, false, false); + //script->set_constant("SI_BODYSTATE_FREEZING", SI_BODYSTATE_FREEZING, false, false); + //script->set_constant("SI_BODYSTATE_STUN", SI_BODYSTATE_STUN, false, false); + //script->set_constant("SI_BODYSTATE_SLEEP", SI_BODYSTATE_SLEEP, false, false); + //script->set_constant("SI_BODYSTATE_UNDEAD", SI_BODYSTATE_UNDEAD, false, false); + //script->set_constant("SI_BODYSTATE_STONECURSE_ING", SI_BODYSTATE_STONECURSE_ING, false, false); + //script->set_constant("SI_BODYSTATE_BURNNING", SI_BODYSTATE_BURNNING, false, false); + //script->set_constant("SI_BODYSTATE_IMPRISON", SI_BODYSTATE_IMPRISON, false, false); + //script->set_constant("SI_HEALTHSTATE_POISON", SI_HEALTHSTATE_POISON, false, false); + //script->set_constant("SI_HEALTHSTATE_CURSE", SI_HEALTHSTATE_CURSE, false, false); + //script->set_constant("SI_HEALTHSTATE_SILENCE", SI_HEALTHSTATE_SILENCE, false, false); + //script->set_constant("SI_HEALTHSTATE_CONFUSION", SI_HEALTHSTATE_CONFUSION, false, false); + //script->set_constant("SI_HEALTHSTATE_BLIND", SI_HEALTHSTATE_BLIND, false, false); + //script->set_constant("SI_HEALTHSTATE_ANGELUS", SI_HEALTHSTATE_ANGELUS, false, false); + //script->set_constant("SI_HEALTHSTATE_BLOODING", SI_HEALTHSTATE_BLOODING, false, false); + //script->set_constant("SI_HEALTHSTATE_HEAVYPOISON", SI_HEALTHSTATE_HEAVYPOISON, false, false); + //script->set_constant("SI_HEALTHSTATE_FEAR", SI_HEALTHSTATE_FEAR, false, false); + //script->set_constant("SI_CHERRY_BLOSSOM_CAKE", SI_CHERRY_BLOSSOM_CAKE, false, false); + script->set_constant("SI_SU_STOOP", SI_SU_STOOP, false, false); + script->set_constant("SI_CATNIPPOWDER", SI_CATNIPPOWDER, false, false); + script->set_constant("SI_BLOSSOM_FLUTTERING", SI_BLOSSOM_FLUTTERING, false, false); + script->set_constant("SI_SV_ROOTTWIST", SI_SV_ROOTTWIST, false, false); + //script->set_constant("SI_ATTACK_PROPERTY_NOTHING", SI_ATTACK_PROPERTY_NOTHING, false, false); + //script->set_constant("SI_ATTACK_PROPERTY_WATER", SI_ATTACK_PROPERTY_WATER, false, false); + //script->set_constant("SI_ATTACK_PROPERTY_GROUND", SI_ATTACK_PROPERTY_GROUND, false, false); + + //script->set_constant("SI_ATTACK_PROPERTY_FIRE", SI_ATTACK_PROPERTY_FIRE, false, false); + //script->set_constant("SI_ATTACK_PROPERTY_WIND", SI_ATTACK_PROPERTY_WIND, false, false); + //script->set_constant("SI_ATTACK_PROPERTY_POISON", SI_ATTACK_PROPERTY_POISON, false, false); + //script->set_constant("SI_ATTACK_PROPERTY_SAINT", SI_ATTACK_PROPERTY_SAINT, false, false); + //script->set_constant("SI_ATTACK_PROPERTY_DARKNESS", SI_ATTACK_PROPERTY_DARKNESS, false, false); + //script->set_constant("SI_ATTACK_PROPERTY_TELEKINESIS", SI_ATTACK_PROPERTY_TELEKINESIS, false, false); + //script->set_constant("SI_ATTACK_PROPERTY_UNDEAD", SI_ATTACK_PROPERTY_UNDEAD, false, false); + //script->set_constant("SI_RESIST_PROPERTY_NOTHING", SI_RESIST_PROPERTY_NOTHING, false, false); + //script->set_constant("SI_RESIST_PROPERTY_WATER", SI_RESIST_PROPERTY_WATER, false, false); + //script->set_constant("SI_RESIST_PROPERTY_GROUND", SI_RESIST_PROPERTY_GROUND, false, false); + //script->set_constant("SI_RESIST_PROPERTY_FIRE", SI_RESIST_PROPERTY_FIRE, false, false); + //script->set_constant("SI_RESIST_PROPERTY_WIND", SI_RESIST_PROPERTY_WIND, false, false); + //script->set_constant("SI_RESIST_PROPERTY_POISON", SI_RESIST_PROPERTY_POISON, false, false); + //script->set_constant("SI_RESIST_PROPERTY_SAINT", SI_RESIST_PROPERTY_SAINT, false, false); + //script->set_constant("SI_RESIST_PROPERTY_DARKNESS", SI_RESIST_PROPERTY_DARKNESS, false, false); + //script->set_constant("SI_RESIST_PROPERTY_TELEKINESIS", SI_RESIST_PROPERTY_TELEKINESIS, false, false); + //script->set_constant("SI_RESIST_PROPERTY_UNDEAD", SI_RESIST_PROPERTY_UNDEAD, false, false); + script->set_constant("SI_BITESCAR", SI_BITESCAR, false, false); + script->set_constant("SI_ARCLOUSEDASH", SI_ARCLOUSEDASH, false, false); + script->set_constant("SI_TUNAPARTY", SI_TUNAPARTY, false, false); + script->set_constant("SI_SHRIMP", SI_SHRIMP, false, false); + script->set_constant("SI_FRESHSHRIMP", SI_FRESHSHRIMP, false, false); + //script->set_constant("SI_PERIOD_RECEIVEITEM", SI_PERIOD_RECEIVEITEM, false, false); + //script->set_constant("SI_PERIOD_PLUSEXP", SI_PERIOD_PLUSEXP, false, false); + //script->set_constant("SI_PERIOD_PLUSJOBEXP", SI_PERIOD_PLUSJOBEXP, false, false); + //script->set_constant("SI_RUNEHELM", SI_RUNEHELM, false, false); + //script->set_constant("SI_HELM_VERKANA", SI_HELM_VERKANA, false, false); + //script->set_constant("SI_HELM_RHYDO", SI_HELM_RHYDO, false, false); + //script->set_constant("SI_HELM_TURISUS", SI_HELM_TURISUS, false, false); + //script->set_constant("SI_HELM_HAGALAS", SI_HELM_HAGALAS, false, false); + //script->set_constant("SI_HELM_ISIA", SI_HELM_ISIA, false, false); + //script->set_constant("SI_HELM_ASIR", SI_HELM_ASIR, false, false); + //script->set_constant("SI_HELM_URJ", SI_HELM_URJ, false, false); + script->set_constant("SI_SUHIDE", SI_SUHIDE, false, false); + // 934 + //script->set_constant("SI_DORAM_BUF_01", SI_DORAM_BUF_01, false, false); + //script->set_constant("SI_DORAM_BUF_02", SI_DORAM_BUF_02, false, false); + script->set_constant("SI_SPRITEMABLE", SI_SPRITEMABLE, false, false); + //script->set_constant("SI_AID_PERIOD_RECEIVEITEM", SI_AID_PERIOD_RECEIVEITEM, false, false); + //script->set_constant("SI_AID_PERIOD_PLUSEXP", SI_AID_PERIOD_PLUSEXP, false, false); + //script->set_constant("SI_AID_PERIOD_PLUSJOBEXP", SI_AID_PERIOD_PLUSJOBEXP, false, false); + //script->set_constant("SI_AID_PERIOD_DEADPENALTY", SI_AID_PERIOD_DEADPENALTY, false, false); + //script->set_constant("SI_AID_PERIOD_ADDSTOREITEMCOUNT", SI_AID_PERIOD_ADDSTOREITEMCOUNT, false, false); + // 943 + // 944 + // 945 + // 946 + // 947 + // 948 + // 949 + //script->set_constant("SI_HISS", SI_HISS, false, false); + // 951 + //script->set_constant("SI_NYANGGRASS", SI_NYANGGRASS, false, false); + //script->set_constant("SI_CHATTERING", SI_CHATTERING, false, false); + // 954 + // 955 + // 956 + // 957 + // 958 + // 959 + // 960 + //script->set_constant("SI_GROOMING", SI_GROOMING, false, false); + //script->set_constant("SI_PROTECTIONOFSHRIMP", SI_PROTECTIONOFSHRIMP, false, false); + //script->set_constant("SI_EP16_2_BUFF_SS", SI_EP16_2_BUFF_SS, false, false); + //script->set_constant("SI_EP16_2_BUFF_SC", SI_EP16_2_BUFF_SC, false, false); + //script->set_constant("SI_EP16_2_BUFF_AC", SI_EP16_2_BUFF_AC, false, false); + //script->set_constant("SI_GS_MAGICAL_BULLET", SI_GS_MAGICAL_BULLET, false, false); + // 967 + // 968 + // 969 + // 970 + // 971 + // 972 + // 973 + // 974 + // 975 + //script->set_constant("SI_FALLEN_ANGEL", SI_FALLEN_ANGEL, false, false); + // 977 + // 978 + //script->set_constant("SI_BLAZE_BEAD", SI_BLAZE_BEAD, false, false); + //script->set_constant("SI_FROZEN_BEAD", SI_FROZEN_BEAD, false, false); + //script->set_constant("SI_BREEZE_BEAD", SI_BREEZE_BEAD, false, false); + // 982 + //script->set_constant("SI_AID_PERIOD_RECEIVEITEM_2ND", SI_AID_PERIOD_RECEIVEITEM_2ND, false, false); + //script->set_constant("SI_AID_PERIOD_PLUSEXP_2ND", SI_AID_PERIOD_PLUSEXP_2ND, false, false); + //script->set_constant("SI_AID_PERIOD_PLUSJOBEXP_2ND", SI_AID_PERIOD_PLUSJOBEXP_2ND, false, false); + //script->set_constant("SI_PRONTERA_JP", SI_PRONTERA_JP, false, false); + // 987 + //script->set_constant("SI_GLOOM_CARD", SI_GLOOM_CARD, false, false); + //script->set_constant("SI_PHARAOH_CARD", SI_PHARAOH_CARD, false, false); + //script->set_constant("SI_KIEL_CARD", SI_KIEL_CARD, false, false); + // 991 + //script->set_constant("SI_CHEERUP", SI_CHEERUP, false, false); + // 993 + // 994 + //script->set_constant("SI_S_MANAPOTION", SI_S_MANAPOTION, false, false); + //script->set_constant("SI_M_DEFSCROLL", SI_M_DEFSCROLL, false, false); + // 997 + // 998 + // 999 + //script->set_constant("SI_AS_RAGGED_GOLEM_CARD", SI_AS_RAGGED_GOLEM_CARD, false, false); + //script->set_constant("SI_LHZ_DUN_N1", SI_LHZ_DUN_N1, false, false); + //script->set_constant("SI_LHZ_DUN_N2", SI_LHZ_DUN_N2, false, false); + //script->set_constant("SI_LHZ_DUN_N3", SI_LHZ_DUN_N3, false, false); + //script->set_constant("SI_LHZ_DUN_N4", SI_LHZ_DUN_N4, false, false); + + script->set_constant("SI_MAX", SI_MAX, false, false); diff --git a/src/map/guild.c b/src/map/guild.c index bb0484477..11609ec81 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -365,6 +365,11 @@ int guild_create(struct map_session_data *sd, const char *name) nullpo_ret(sd); nullpo_ret(name); + if (sd->clan != NULL) { + clif->messagecolor_self(sd->fd, COLOR_RED, "You cannot create a guild because you are in a clan."); + return 0; + } + safestrncpy(tname, name, NAME_LENGTH); trim(tname); diff --git a/src/map/intif.c b/src/map/intif.c index be6b75d96..0e5cd3db2 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -26,6 +26,7 @@ #include "map/atcommand.h" #include "map/battle.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/clif.h" #include "map/elemental.h" #include "map/guild.h" @@ -744,6 +745,81 @@ int intif_party_leaderchange(int party_id,int account_id,int char_id) return 0; } +//========================= +// Clan System +//------------------------- + +/** + * Request clan member count + * + * @param clan_id Id of the clan to have members counted + * @param kick_interval Interval of the inactivity kick + */ +int intif_clan_membercount(int clan_id, int kick_interval) +{ + if (intif->CheckForCharServer() || clan_id == 0 || kick_interval <= 0) + return 0; + + WFIFOHEAD(inter_fd, 10); + WFIFOW(inter_fd, 0) = 0x3044; + WFIFOL(inter_fd, 2) = clan_id; + WFIFOL(inter_fd, 6) = kick_interval; + WFIFOSET(inter_fd, 10); + return 1; +} + +int intif_clan_kickoffline(int clan_id, int kick_interval) +{ + if (intif->CheckForCharServer() || clan_id == 0 || kick_interval <= 0) + return 0; + + WFIFOHEAD(inter_fd, 10); + WFIFOW(inter_fd, 0) = 0x3045; + WFIFOL(inter_fd, 2) = clan_id; + WFIFOL(inter_fd, 6) = kick_interval; + WFIFOSET(inter_fd, 10); + return 1; +} + +void intif_parse_RecvClanMemberAction(int fd) +{ + struct clan *c; + int clan_id = RFIFOL(fd, 2); + int count = RFIFOL(fd, 6); + + if ((c = clan->search(clan_id)) == NULL) { + ShowError("intif_parse_RecvClanMemberAction: Received invalid clan_id '%d'\n", clan_id); + return; + } + + if (count < 0) { + ShowError("intif_parse_RecvClanMemberAction: Received invalid member count value '%d'\n", count); + return; + } + + c->received = true; + if (c->req_count_tid != INVALID_TIMER) { + timer->delete(c->req_count_tid, clan->request_membercount); + c->req_count_tid = INVALID_TIMER; + } + + c->member_count = count; + switch (c->req_state) { + case CLAN_REQ_AFTER_KICK: + if (c->req_kick_tid != INVALID_TIMER) { + timer->delete(c->req_kick_tid, clan->request_kickoffline); + c->req_kick_tid = INVALID_TIMER; + } + break; + case CLAN_REQ_RELOAD: + map->foreachpc(clan->rejoin); + break; + default: + break; + } + c->req_state = CLAN_REQ_NONE; +} + // Request a Guild creation int intif_guild_create(const char *name,const struct guild_member *master) { @@ -2523,10 +2599,10 @@ void intif_parse_RodexNotifications(int fd) /// Updates a mail /// flag: -/// 0 - user Read -/// 1 - user got Zeny -/// 2 - user got Items -/// 3 - delete +/// 0 - user Read +/// 1 - user got Zeny +/// 2 - user got Items +/// 3 - delete int intif_rodex_updatemail(int64 mail_id, int8 flag) { if (intif->CheckForCharServer()) @@ -2744,6 +2820,9 @@ int intif_parse(int fd) case 0x3896: intif->pRodexHasNew(fd); break; case 0x3897: intif->pRodexSendMail(fd); break; case 0x3898: intif->pRodexCheckName(fd); break; + + // Clan System + case 0x3858: intif->pRecvClanMemberAction(fd); break; default: ShowError("intif_parse : unknown packet %d %x\n",fd,RFIFOW(fd,0)); return 0; @@ -2765,7 +2844,7 @@ void intif_defaults(void) { 39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830 -1, 0, 0,14, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, //0x3840 - -1,-1, 7, 7, 7,11, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus] itembound[Akinari] + -1,-1, 7, 7, 7,11, 8, 0, 10, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus] itembound[Akinari] Clan System[Murilo BiO] -1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3860 Quests [Kevin] [Inkfish] -1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 3, 3, 0, //0x3870 Mercenaries [Zephyrus] / Elemental [pakpil] 12,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880 @@ -2857,6 +2936,9 @@ void intif_defaults(void) { intif->rodex_updatemail = intif_rodex_updatemail; intif->rodex_sendmail = intif_rodex_sendmail; intif->rodex_checkname = intif_rodex_checkname; + /* Clan System */ + intif->clan_kickoffline = intif_clan_kickoffline; + intif->clan_membercount = intif_clan_membercount; /* @accinfo */ intif->request_accinfo = intif_request_accinfo; /* */ @@ -2933,4 +3015,6 @@ void intif_defaults(void) { intif->pRodexHasNew = intif_parse_RodexNotifications; intif->pRodexSendMail = intif_parse_RodexSendMail; intif->pRodexCheckName = intif_parse_RodexCheckName; + /* Clan System */ + intif->pRecvClanMemberAction = intif_parse_RecvClanMemberAction; } diff --git a/src/map/intif.h b/src/map/intif.h index 4bca5f167..be8ff4181 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -138,6 +138,9 @@ struct intif_interface { int(*rodex_updatemail) (int64 mail_id, int8 flag); int(*rodex_sendmail) (struct rodex_message *msg); int(*rodex_checkname) (struct map_session_data *sd, const char *name); + /* Clan System */ + int (*clan_kickoffline) (int clan_id, int kick_interval); + int (*clan_membercount) (int clan_id, int kick_interval); /* @accinfo */ void (*request_accinfo) (int u_fd, int aid, int group_lv, char* query); /* */ @@ -212,6 +215,8 @@ struct intif_interface { void(*pRodexHasNew) (int fd); void(*pRodexSendMail) (int fd); void(*pRodexCheckName) (int fd); + /* Clan System */ + void (*pRecvClanMemberAction) (int fd); }; #ifdef HERCULES_CORE diff --git a/src/map/log.c b/src/map/log.c index 6419c4766..c3fec077e 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -82,13 +82,21 @@ char log_picktype2char(e_log_pick_type type) { } /// obtain log type character for chat logs -char log_chattype2char(e_log_chat_type type) { - switch( type ) { - case LOG_CHAT_GLOBAL: return 'O'; // Gl(O)bal - case LOG_CHAT_WHISPER: return 'W'; // (W)hisper - case LOG_CHAT_PARTY: return 'P'; // (P)arty - case LOG_CHAT_GUILD: return 'G'; // (G)uild - case LOG_CHAT_MAINCHAT: return 'M'; // (M)ain chat +char log_chattype2char(e_log_chat_type type) +{ + switch (type) { + case LOG_CHAT_GLOBAL: + return 'O'; // Gl(O)bal + case LOG_CHAT_WHISPER: + return 'W'; // (W)hisper + case LOG_CHAT_PARTY: + return 'P'; // (P)arty + case LOG_CHAT_GUILD: + return 'G'; // (G)uild + case LOG_CHAT_MAINCHAT: + return 'M'; // (M)ain chat + case LOG_CHAT_CLAN: + return 'C'; // (C)lan } // should not get here, fallback diff --git a/src/map/log.h b/src/map/log.h index 7ff36d126..e7eb72713 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -52,6 +52,7 @@ typedef enum e_log_chat_type { LOG_CHAT_PARTY = 0x04, LOG_CHAT_GUILD = 0x08, LOG_CHAT_MAINCHAT = 0x10, + LOG_CHAT_CLAN = 0x20, // all LOG_CHAT_ALL = 0xFF, } e_log_chat_type; diff --git a/src/map/map.c b/src/map/map.c index 306f3a99d..106224a47 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -30,6 +30,7 @@ #include "map/channel.h" #include "map/chat.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/clif.h" #include "map/duel.h" #include "map/elemental.h" @@ -1904,6 +1905,9 @@ int map_quit(struct map_session_data *sd) { if( sd->bg_id && !sd->bg_queue.arena ) /* TODO: dump this chunk after bg_queue is fully enabled */ bg->team_leave(sd,BGTL_QUIT); + if (sd->status.clan_id) + clan->member_offline(sd); + if (sd->state.autotrade && core->runflag != MAPSERVER_ST_SHUTDOWN && !channel->config->closing) pc->autotrade_update(sd,PAUC_REMOVE); @@ -4815,6 +4819,15 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { else if( map->list[m].flag.battleground ) map_zone_mf_cache_add(m,"battleground"); } + } else if (!strcmpi(flag,"cvc")) { + if (state && map->list[m].flag.cvc) { + ;/* nothing to do */ + } else { + if (state) + map_zone_mf_cache_add(m,"cvc\toff"); + else if (map->list[m].flag.cvc) + map_zone_mf_cache_add(m,"cvc"); + } } else if (!strcmpi(flag,"noexppenalty")) { if( state && map->list[m].flag.noexppenalty ) ;/* nothing to do */ @@ -5839,6 +5852,8 @@ void read_map_zone_db(void) { zone->merge_type = MZMT_MERGEABLE; if( (zone = strdb_get(map->zone_db, MAP_ZONE_BG_NAME)) ) zone->merge_type = MZMT_MERGEABLE; + if ((zone = strdb_get(map->zone_db, MAP_ZONE_CVC_NAME))) + zone->merge_type = MZMT_MERGEABLE; } /* not supposed to go in here but in skill_final whatever */ libconfig->destroy(&map_zone_db); @@ -5999,6 +6014,7 @@ int do_final(void) { ircbot->final();/* before channel. */ channel->final(); chrif->final(); + clan->final(); clif->final(); npc->final(); quest->final(); @@ -6185,6 +6201,7 @@ void map_load_defaults(void) { battleground_defaults(); buyingstore_defaults(); channel_defaults(); + clan_defaults(); clif_defaults(); chrif_defaults(); guild_defaults(); @@ -6517,6 +6534,7 @@ int do_init(int argc, char *argv[]) ircbot->init(minimal); script->init(minimal); itemdb->init(minimal); + clan->init(minimal); skill->init(minimal); if (!minimal) map->read_zone_db();/* read after item and skill initialization */ diff --git a/src/map/map.h b/src/map/map.h index fab8839d8..facf1d921 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -352,6 +352,7 @@ STATIC_ASSERT(((MAPID_1_1_MAX - 1) | MAPID_BASEMASK) == MAPID_BASEMASK, "First c || map->list[m].flag.gvg \ || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle) \ || map->list[m].flag.battleground \ + || map->list[m].flag.cvc \ ) // Specifies maps that have special GvG/WoE restrictions #define map_flag_gvg(m) (map->list[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle)) @@ -737,6 +738,7 @@ enum map_zone_merge_type { #define MAP_ZONE_PVP_NAME "PvP" #define MAP_ZONE_GVG_NAME "GvG" #define MAP_ZONE_BG_NAME "Battlegrounds" +#define MAP_ZONE_CVC_NAME "CvC" #define MAP_ZONE_PK_NAME "PK Mode" #define MAP_ZONE_MAPFLAG_LENGTH 50 @@ -823,6 +825,7 @@ struct map_data { unsigned gvg_dungeon : 1; // Celest unsigned gvg_noparty : 1; unsigned battleground : 2; // [BattleGround System] + unsigned cvc : 1; unsigned nozenypenalty : 1; unsigned notrade : 1; unsigned noskill : 1; diff --git a/src/map/mob.h b/src/map/mob.h index 98d64873b..3d1b3aadf 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -208,6 +208,7 @@ struct mob_data { int target_id,attacked_id; int areanpc_id; //Required in OnTouchNPC (to avoid multiple area touchs) unsigned int bg_id; // BattleGround System + int clan_id; // Clan System int64 next_walktime, last_thinktime, last_linktime, last_pcneartime, dmgtick; short move_fail_count; diff --git a/src/map/npc.c b/src/map/npc.c index d3dfb39d2..94ab57bd9 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -25,6 +25,7 @@ #include "map/battle.h" #include "map/chat.h" +#include "map/clan.h" #include "map/clif.h" #include "map/guild.h" #include "map/instance.h" @@ -4144,6 +4145,11 @@ const char *npc_parse_mapflag(const char *w1, const char *w2, const char *w3, co ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing GvG flags from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer,start-buffer)); if (retval) *retval = EXIT_FAILURE; } + if (state && map->list[m].flag.cvc) { + map->list[m].flag.cvc = 0; + ShowWarning("npc_parse_mapflag: You can't set CvC and PvP flags for the same map! Removing CvC flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer, start-buffer)); + if (retval) *retval = EXIT_FAILURE; + } if( state && map->list[m].flag.battleground ) { map->list[m].flag.battleground = 0; ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing BattleGround flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer,start-buffer)); @@ -4196,6 +4202,11 @@ const char *npc_parse_mapflag(const char *w1, const char *w2, const char *w3, co ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing PvP flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer,start-buffer)); if (retval) *retval = EXIT_FAILURE; } + if (state && map->list[m].flag.cvc) { + map->list[m].flag.cvc = 0; + ShowWarning("npc_parse_mapflag: You can't set CvC and GvG flags for the same map! Removing CvC flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer, start-buffer)); + if (retval) *retval = EXIT_FAILURE; + } if( state && map->list[m].flag.battleground ) { map->list[m].flag.battleground = 0; ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing BattleGround flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer,start-buffer)); @@ -4238,11 +4249,47 @@ const char *npc_parse_mapflag(const char *w1, const char *w2, const char *w3, co ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing GvG flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer,start-buffer)); if (retval) *retval = EXIT_FAILURE; } + if (map->list[m].flag.cvc) { + map->list[m].flag.cvc = 0; + ShowWarning("npc_parse_mapflag: You can't set CvC and BattleGround flags for the same map! Removing CvC flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer, start-buffer)); + if (retval) *retval = EXIT_FAILURE; + } if( state && (zone = strdb_get(map->zone_db, MAP_ZONE_BG_NAME)) != NULL && map->list[m].zone != zone ) { map->zone_change(m,zone,start,buffer,filepath); } } + else if (!strcmpi(w3, "cvc")) { + struct map_zone_data *zone; + + map->list[m].flag.cvc = state; + if (state && (map->list[m].flag.gvg || map->list[m].flag.gvg_dungeon || map->list[m].flag.gvg_castle)) { + map->list[m].flag.gvg = 0; + map->list[m].flag.gvg_dungeon = 0; + map->list[m].flag.gvg_castle = 0; + ShowWarning("npc_parse_mapflag: You can't set GvG and CvC flags for the same map! Removing GvG flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer, start-buffer)); + if (retval) { + *retval = EXIT_FAILURE; + } + } + if (state && map->list[m].flag.pvp) { + map->list[m].flag.pvp = 0; + ShowWarning("npc_parse_mapflag: You can't set PvP and CvC flags for the same map! Removing PvP flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer, start-buffer)); + if (retval) { + *retval = EXIT_FAILURE; + } + } + if (state && map->list[m].flag.battleground) { + map->list[m].flag.battleground = 0; + ShowWarning("npc_parse_mapflag: You can't set CvC and BattleGround flags for the same map! Removing BattleGround flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer, start-buffer)); + if (retval) { + *retval = EXIT_FAILURE; + } + } + if (state && (zone = strdb_get(map->zone_db, MAP_ZONE_CVC_NAME)) != NULL && map->list[m].zone != zone) { + map->zone_change(m, zone, start, buffer, filepath); + } + } else if (!strcmpi(w3,"noexppenalty")) map->list[m].flag.noexppenalty=state; else if (!strcmpi(w3,"nozenypenalty")) @@ -4887,6 +4934,7 @@ int npc_reload(void) { // Reprocess npc files and reload constants itemdb->name_constants(); + clan->set_constants(); npc_process_files( npc_new_min ); instance->reload(); @@ -5026,6 +5074,7 @@ int do_init_npc(bool minimal) { // Should be loaded before npc processing, otherwise labels could overwrite constant values // and lead to undefined behavior [Panikon] itemdb->name_constants(); + clan->set_constants(); if (!minimal) { npc->timer_event_ers = ers_new(sizeof(struct timer_event_data),"clif.c::timer_event_ers",ERS_OPT_NONE); diff --git a/src/map/npc.h b/src/map/npc.h index 8bb38f252..64a2b3a51 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -83,6 +83,8 @@ struct npc_data { uint8 dir; uint8 area_size; + int clan_id; + unsigned size : 2; struct status_data status; diff --git a/src/map/packets.h b/src/map/packets.h index 229d6afde..4c41a7e8f 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -2179,6 +2179,12 @@ packet(0x96e,-1,clif->ackmergeitems); packet(0x0960,5,clif->pChangeDir,2,4); // CZ_CHANGE_DIRECTION #endif +//2012-07-02 +#if PACKETVER >= 20120702 +// new packets + packet(0x098a, -1); // ZC_CLANINFO +#endif + //2012-07-10 #if PACKETVER >= 20120710 packet(0x0886,2,clif->pReqCloseBuyingStore,0); // CZ_REQ_CLOSE_BUYING_STORE @@ -2218,6 +2224,15 @@ packet(0x96e,-1,clif->ackmergeitems); packet(0x0436,4,clif->pDull); // CZ_GANGSI_RANK #endif +//2012-07-16aRagExe +#if PACKETVER >= 20120716 +// new packets + packet(0x0988, 6); // ZC_NOTIFY_CLAN_CONNECTINFO + packet(0x0989, 2); // ZC_ACK_CLAN_LEAVE + packet(0x098d, -1, clif->pClanMessage, 2, 4); // CZ_CLAN_CHAT + packet(0x098e, -1); // ZC_NOTIFY_CLAN_CHAT +#endif + // 2012-09-25aRagexe #if PACKETVER >= 20120925 // new packets (not all) @@ -3972,4 +3987,40 @@ packet(0x96e,-1,clif->ackmergeitems); #endif #endif +#ifdef PACKETVER_ZERO +// 2018-01-31dRagexe_zero +#if PACKETVER >= 20180131 +// new packets + packet(0x0af2,40,clif->pDull/*,XXX*/); + packet(0x0af3,-1,clif->pDull/*,XXX*/); + packet(0x0af4,11,clif->pDull/*,XXX*/); +// changed packet sizes + packet(0x0821,102); // AC_OTP_USER + packet(0x0ae6,10,clif->pDull/*,XXX*/); +#endif +#endif // PACKETVER_ZERO + +#ifdef PACKETVER_ZERO +// 2018-02-07bRagexe_zero +#if PACKETVER >= 20180207 +// new packets + packet(0x0af5,3); + packet(0x0af6,88); + packet(0x0af7,32); +// changed packet sizes +#endif +#else // PACKETVER_ZERO +// 2018-02-07bRagexeRE, 2018-02-07bRagexe +#if PACKETVER >= 20180207 +// new packets + packet(0x0af4,11); + packet(0x0af5,3); + packet(0x0af6,88); + packet(0x0af7,32); +// changed packet sizes + packet(0x0ae6,10); +#endif +#endif // PACKETVER_ZERO + + #endif /* MAP_PACKETS_H */ diff --git a/src/map/packets_keys_main.h b/src/map/packets_keys_main.h index afaf62e2d..9aa39fad5 100644 --- a/src/map/packets_keys_main.h +++ b/src/map/packets_keys_main.h @@ -1954,5 +1954,10 @@ packetKeys(0x7EAA1CE0,0x415D1CFD,0x4C8F19FA); #endif +// 2018-02-07bRagexe, 2018-02-07bRagexeRE +#if PACKETVER == 20180207 + packetKeys(0x45AA1B44,0x20E716B7,0x5388105C); +#endif + #endif /* MAP_PACKETS_MAIN_KEYS_H */ diff --git a/src/map/packets_keys_zero.h b/src/map/packets_keys_zero.h index 93c917559..101d0b973 100644 --- a/src/map/packets_keys_zero.h +++ b/src/map/packets_keys_zero.h @@ -114,5 +114,15 @@ packetKeys(0x230959EB,0x1CCB0182,0x1FFA2B30); #endif +// 2018-01-31dRagexe_zero +#if PACKETVER == 20180131 + packetKeys(0x1F422E02,0x12025202,0x52025202); +#endif + +// 2018-02-07bRagexe_zero +#if PACKETVER == 20180207 + packetKeys(0x07CB29CB,0x69CB69CB,0x69CB69CB); +#endif + #endif /* MAP_PACKETS_ZERO_KEYS_H */ diff --git a/src/map/packets_shuffle_main.h b/src/map/packets_shuffle_main.h index c30f4296b..13861dd46 100644 --- a/src/map/packets_shuffle_main.h +++ b/src/map/packets_shuffle_main.h @@ -9533,5 +9533,38 @@ packet(0x096a,6,clif->pGetCharNameRequest,2); // CZ_REQNAME #endif +// 2018-02-07bRagexe, 2018-02-07bRagexeRE +#if PACKETVER == 20180207 + packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8); // CZ_ITEMLISTWIN_RES + packet(0x035f,6,clif->pReqClickBuyingStore,2); // CZ_REQ_CLICK_TO_BUYING_STORE + packet(0x0360,4,clif->pDull/*,XXX*/); // CZ_GANGSI_RANK + packet(0x0362,6,clif->pDropItem,2,4); // CZ_ITEM_THROW + packet(0x0363,8,clif->pDull/*,XXX*/); // CZ_JOIN_BATTLE_FIELD + packet(0x0364,8,clif->pMoveFromKafra,2,4); // CZ_MOVE_ITEM_FROM_STORE_TO_BODY + packet(0x0365,18,clif->pPartyBookingRegisterReq,2,4); // CZ_PARTY_BOOKING_REQ_REGISTER + packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); // CZ_USE_SKILL_TOGROUND_WITHTALKBOX + packet(0x0368,6,clif->pSolveCharName,2); // CZ_REQNAME_BYGID + packet(0x0369,7,clif->pActionRequest,2,6); // CZ_REQUEST_ACT + packet(0x0437,5,clif->pWalkToXY,2); // CZ_REQUEST_MOVE + packet(0x0438,10,clif->pUseSkillToPos,2,4,6,8); // CZ_USE_SKILL_TOGROUND + packet(0x07e4,6,clif->pTakeItem,2); // CZ_ITEM_PICKUP + packet(0x07ec,8,clif->pMoveToKafra,2,4); // CZ_MOVE_ITEM_FROM_BODY_TO_STORE + packet(0x0802,26,clif->pPartyInvite2,2); // CZ_PARTY_JOIN_REQ + packet(0x0811,-1,clif->pReqTradeBuyingStore,2,4,8,12); // CZ_REQ_TRADE_BUYING_STORE + packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); // CZ_REQ_OPEN_BUYING_STORE + packet(0x0817,2,clif->pReqCloseBuyingStore,0); // CZ_REQ_CLOSE_BUYING_STORE + packet(0x0819,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); // CZ_SEARCH_STORE_INFO + packet(0x0835,2,clif->pSearchStoreInfoNextPage,0); // CZ_SEARCH_STORE_INFO_NEXT_PAGE + packet(0x0838,12,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK + packet(0x083c,10,clif->pUseSkillToId,2,4,6); // CZ_USE_SKILL + packet(0x0870,19,clif->pWantToConnection,2,6,10,14,18); // CZ_ENTER + packet(0x0881,26,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS + packet(0x092c,5,clif->pHomMenu,2,4); // CZ_COMMAND_MER + packet(0x092e,5,clif->pChangeDir,2,4); // CZ_CHANGE_DIRECTION + packet(0x0940,6,clif->pTickSend,2); // CZ_REQUEST_TIME + packet(0x0950,36,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD + packet(0x096a,6,clif->pGetCharNameRequest,2); // CZ_REQNAME +#endif + #endif /* MAP_PACKETS_SHUFFLE_MAIN_H */ diff --git a/src/map/packets_shuffle_zero.h b/src/map/packets_shuffle_zero.h index 01facb96b..38c34b18e 100644 --- a/src/map/packets_shuffle_zero.h +++ b/src/map/packets_shuffle_zero.h @@ -485,5 +485,71 @@ packet(0x0963,5,clif->pHomMenu,2,4); // CZ_COMMAND_MER #endif +// 2018-01-31dRagexe_zero +#if PACKETVER == 20180131 + packet(0x0202,5,clif->pChangeDir,2,4); // CZ_CHANGE_DIRECTION + packet(0x022d,19,clif->pWantToConnection,2,6,10,14,18); // CZ_ENTER + packet(0x023b,26,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS + packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8); // CZ_ITEMLISTWIN_RES + packet(0x035f,6,clif->pTickSend,2); // CZ_REQUEST_TIME + packet(0x0360,6,clif->pReqClickBuyingStore,2); // CZ_REQ_CLICK_TO_BUYING_STORE + packet(0x0361,5,clif->pHomMenu,2,4); // CZ_COMMAND_MER + packet(0x0362,6,clif->pDropItem,2,4); // CZ_ITEM_THROW + packet(0x0363,8,clif->pDull/*,XXX*/); // CZ_JOIN_BATTLE_FIELD + packet(0x0364,8,clif->pMoveFromKafra,2,4); // CZ_MOVE_ITEM_FROM_STORE_TO_BODY + packet(0x0365,18,clif->pPartyBookingRegisterReq,2,4); // CZ_PARTY_BOOKING_REQ_REGISTER + packet(0x0367,36,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD + packet(0x0368,6,clif->pSolveCharName,2); // CZ_REQNAME_BYGID + packet(0x0369,7,clif->pActionRequest,2,6); // CZ_REQUEST_ACT + packet(0x0436,4,clif->pDull/*,XXX*/); // CZ_GANGSI_RANK + packet(0x0437,5,clif->pWalkToXY,2); // CZ_REQUEST_MOVE + packet(0x0438,10,clif->pUseSkillToPos,2,4,6,8); // CZ_USE_SKILL_TOGROUND + packet(0x07e4,6,clif->pTakeItem,2); // CZ_ITEM_PICKUP + packet(0x07ec,8,clif->pMoveToKafra,2,4); // CZ_MOVE_ITEM_FROM_BODY_TO_STORE + packet(0x0802,26,clif->pPartyInvite2,2); // CZ_PARTY_JOIN_REQ + packet(0x0811,-1,clif->pReqTradeBuyingStore,2,4,8,12); // CZ_REQ_TRADE_BUYING_STORE + packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); // CZ_REQ_OPEN_BUYING_STORE + packet(0x0817,2,clif->pReqCloseBuyingStore,0); // CZ_REQ_CLOSE_BUYING_STORE + packet(0x0819,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); // CZ_SEARCH_STORE_INFO + packet(0x0835,2,clif->pSearchStoreInfoNextPage,0); // CZ_SEARCH_STORE_INFO_NEXT_PAGE + packet(0x0838,12,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK + packet(0x083c,10,clif->pUseSkillToId,2,4,6); // CZ_USE_SKILL + packet(0x0940,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); // CZ_USE_SKILL_TOGROUND_WITHTALKBOX + packet(0x096a,6,clif->pGetCharNameRequest,2); // CZ_REQNAME +#endif + +// 2018-02-07bRagexe_zero +#if PACKETVER == 20180207 + packet(0x0202,5,clif->pChangeDir,2,4); // CZ_CHANGE_DIRECTION + packet(0x022d,19,clif->pWantToConnection,2,6,10,14,18); // CZ_ENTER + packet(0x023b,26,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS + packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8); // CZ_ITEMLISTWIN_RES + packet(0x035f,6,clif->pTickSend,2); // CZ_REQUEST_TIME + packet(0x0360,6,clif->pReqClickBuyingStore,2); // CZ_REQ_CLICK_TO_BUYING_STORE + packet(0x0361,5,clif->pHomMenu,2,4); // CZ_COMMAND_MER + packet(0x0362,6,clif->pDropItem,2,4); // CZ_ITEM_THROW + packet(0x0363,8,clif->pDull/*,XXX*/); // CZ_JOIN_BATTLE_FIELD + packet(0x0364,8,clif->pMoveFromKafra,2,4); // CZ_MOVE_ITEM_FROM_STORE_TO_BODY + packet(0x0365,18,clif->pPartyBookingRegisterReq,2,4); // CZ_PARTY_BOOKING_REQ_REGISTER + packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); // CZ_USE_SKILL_TOGROUND_WITHTALKBOX + packet(0x0368,6,clif->pSolveCharName,2); // CZ_REQNAME_BYGID + packet(0x0369,7,clif->pActionRequest,2,6); // CZ_REQUEST_ACT + packet(0x0436,4,clif->pDull/*,XXX*/); // CZ_GANGSI_RANK + packet(0x0437,5,clif->pWalkToXY,2); // CZ_REQUEST_MOVE + packet(0x0438,10,clif->pUseSkillToPos,2,4,6,8); // CZ_USE_SKILL_TOGROUND + packet(0x07e4,6,clif->pTakeItem,2); // CZ_ITEM_PICKUP + packet(0x07ec,8,clif->pMoveToKafra,2,4); // CZ_MOVE_ITEM_FROM_BODY_TO_STORE + packet(0x0802,26,clif->pPartyInvite2,2); // CZ_PARTY_JOIN_REQ + packet(0x0811,-1,clif->pReqTradeBuyingStore,2,4,8,12); // CZ_REQ_TRADE_BUYING_STORE + packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); // CZ_REQ_OPEN_BUYING_STORE + packet(0x0817,2,clif->pReqCloseBuyingStore,0); // CZ_REQ_CLOSE_BUYING_STORE + packet(0x0819,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); // CZ_SEARCH_STORE_INFO + packet(0x0835,2,clif->pSearchStoreInfoNextPage,0); // CZ_SEARCH_STORE_INFO_NEXT_PAGE + packet(0x0838,12,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK + packet(0x083c,10,clif->pUseSkillToId,2,4,6); // CZ_USE_SKILL + packet(0x0967,36,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD + packet(0x096a,6,clif->pGetCharNameRequest,2); // CZ_REQNAME +#endif + #endif /* MAP_PACKETS_SHUFFLE_ZERO_H */ diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 1105bec96..2a65eb6cf 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -349,6 +349,14 @@ enum packet_headers { partymemberinfo = 0x01e9, partyinfo = 0x00fb, #endif +#if PACKETVER >= 20120702 + clanBasicInfo = 0x098A, ///< ZC_CLANINFO +#endif +#if PACKETVER >= 20120716 + clanOnlineCount = 0x0988, ///< ZC_NOTIFY_CLAN_CONNECTINFO + clanLeave = 0x0989, ///< ZC_ACK_CLAN_LEAVE + clanMessage = 0x098E, ///< ZC_NOTIFY_CLAN_CHAT +#endif }; #if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute @@ -1562,6 +1570,34 @@ struct PACKET_ZC_GROUP_LIST { struct PACKET_ZC_GROUP_LIST_SUB members[]; } __attribute__((packed)); +struct PACKET_ZC_CLANINFO { + int16 PacketType; + int16 PacketLength; + uint32 ClanID; + char ClanName[NAME_LENGTH]; + char MasterName[NAME_LENGTH]; + char Map[MAP_NAME_LENGTH_EXT]; + uint8 AllyCount; + uint8 AntagonistCount; +} __attribute__((packed)); + +struct PACKET_ZC_NOTIFY_CLAN_CONNECTINFO { + int16 PacketType; + int16 NumConnect; + int16 NumTotal; +} __attribute__((packed)); + +struct PACKET_ZC_ACK_CLAN_LEAVE { + int16 PacketType; +} __attribute__((packed)); + +struct PACKET_ZC_NOTIFY_CLAN_CHAT { + int16 PacketType; + int16 PacketLength; + char MemberName[NAME_LENGTH]; + char Message[]; +} __attribute__((packed)); + #if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(pop) #endif // not NetBSD < 6 / Solaris diff --git a/src/map/pc.c b/src/map/pc.c index 449cb25d3..0b30b1221 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -29,6 +29,7 @@ #include "map/channel.h" #include "map/chat.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/clif.h" #include "map/date.h" // is_day_of_*() #include "map/duel.h" @@ -1524,6 +1525,12 @@ int pc_reg_received(struct map_session_data *sd) status_calc_pc(sd,SCO_FIRST|SCO_FORCE); chrif->scdata_request(sd->status.account_id, sd->status.char_id); + if (sd->status.clan_id) + clan->member_online(sd, true); + + //Auth is fully okay, update last_login + sd->status.last_login = time(NULL); + // Storage Request intif->request_account_storage(sd); diff --git a/src/map/pc.h b/src/map/pc.h index df0df979d..a01152df5 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -443,6 +443,7 @@ END_ZEROED_BLOCK; int party_invite, party_invite_account; // for handling party invitation (holds party id and account id) int adopt_invite; // Adoption struct guild *guild;/* [Ind/Hercules] speed everything up */ + struct clan *clan; int guild_invite,guild_invite_account; int guild_emblem_id,guild_alliance,guild_alliance_account; short guild_x,guild_y; // For guildmate position display. [Skotlex] should be short [zzo] diff --git a/src/map/rodex.c b/src/map/rodex.c index dcecb6b8f..d5a6064cf 100644 --- a/src/map/rodex.c +++ b/src/map/rodex.c @@ -216,11 +216,11 @@ void rodex_check_player(struct map_session_data *sd, const char *name, int *base /// @param title : Mail Title /// @param zeny : Amount of zeny attached /// Returns result code: -/// RODEX_SEND_MAIL_SUCCESS = 0, -/// RODEX_SEND_MAIL_FATAL_ERROR = 1, -/// RODEX_SEND_MAIL_COUNT_ERROR = 2, -/// RODEX_SEND_MAIL_ITEM_ERROR = 3, -/// RODEX_SEND_MAIL_RECEIVER_ERROR = 4 +/// RODEX_SEND_MAIL_SUCCESS = 0, +/// RODEX_SEND_MAIL_FATAL_ERROR = 1, +/// RODEX_SEND_MAIL_COUNT_ERROR = 2, +/// RODEX_SEND_MAIL_ITEM_ERROR = 3, +/// RODEX_SEND_MAIL_RECEIVER_ERROR = 4 int rodex_send_mail(struct map_session_data *sd, const char *receiver_name, const char *body, const char *title, int64 zeny) { int i; @@ -532,8 +532,8 @@ void rodex_get_items(struct map_session_data *sd, int8 opentype, int64 mail_id) /// - should be called everytime we're going to stop using rodex in this character /// @param sd : Target to clean /// @param flag : -/// 0 - clear everything -/// 1 - clear tmp only +/// 0 - clear everything +/// 1 - clear tmp only void rodex_clean(struct map_session_data *sd, int8 flag) { nullpo_retv(sd); diff --git a/src/map/script.c b/src/map/script.c index d7a65f554..26de803d7 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -29,6 +29,7 @@ #include "map/channel.h" #include "map/chat.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/clif.h" #include "map/date.h" #include "map/elemental.h" @@ -5593,6 +5594,8 @@ int script_reload(void) itemdb->name_constants(); + clan->set_constants(); + sysinfo->vcsrevision_reload(); return 0; @@ -8281,7 +8284,7 @@ BUILDIN(makeitem2) map->search_freecell(NULL, m, &x, &y, -1, -1, 1); } else { range = (script_hasdata(st, 14) ? cap_value(script_getnum(st, 14), 1, battle_config.area_size) : 3); - map->search_freecell(&sd->bl, sd->bl.m, &x, &y, range, range, 0); // Locate spot next to player. + map->search_freecell(&sd->bl, sd->bl.m, &x, &y, range, range, 0); // Locate spot next to player. } } @@ -8627,32 +8630,45 @@ BUILDIN(readparam) { * 2 : guild_id * 3 : account_id * 4 : bg_id + * 5 : clan_id *------------------------------------------*/ BUILDIN(getcharid) { - int num; + int num = script_getnum(st, 2); struct map_session_data *sd; - num = script_getnum(st,2); - if( script_hasdata(st,3) ) - sd=map->nick2sd(script_getstr(st,3)); + if (script_hasdata(st, 3)) + sd = map->nick2sd(script_getstr(st, 3)); else - sd=script->rid2sd(st); + sd = script->rid2sd(st); - if(sd==NULL) { - script_pushint(st,0); //return 0, according docs + if (sd == NULL) { + script_pushint(st, 0); //return 0, according docs return true; } - switch( num ) { - case 0: script_pushint(st,sd->status.char_id); break; - case 1: script_pushint(st,sd->status.party_id); break; - case 2: script_pushint(st,sd->status.guild_id); break; - case 3: script_pushint(st,sd->status.account_id); break; - case 4: script_pushint(st,sd->bg_id); break; - default: - ShowError("buildin_getcharid: invalid parameter (%d).\n", num); - script_pushint(st,0); - break; + switch (num) { + case 0: + script_pushint(st, sd->status.char_id); + break; + case 1: + script_pushint(st, sd->status.party_id); + break; + case 2: + script_pushint(st, sd->status.guild_id); + break; + case 3: + script_pushint(st, sd->status.account_id); + break; + case 4: + script_pushint(st, sd->bg_id); + break; + case 5: + script_pushint(st, sd->status.clan_id); + break; + default: + ShowError("buildin_getcharid: invalid parameter (%d).\n", num); + script_pushint(st, 0); + break; } return true; @@ -8900,10 +8916,12 @@ BUILDIN(getguildmember) * 1 : party_name or "" * 2 : guild_name or "" * 3 : map_name + * 4 : clan_name or "" * - : "" *------------------------------------------*/ BUILDIN(strcharinfo) { + struct clan *c; struct guild* g; struct party_data* p; struct map_session_data *sd; @@ -8943,6 +8961,13 @@ BUILDIN(strcharinfo) case 3: script_pushconststr(st, map->list[sd->bl.m].name); break; + case 4: + if ((c = sd->clan) != NULL) { + script_pushstrcopy(st, c->name); + } else { + script_pushconststr(st, ""); + } + break; default: ShowWarning("script:strcharinfo: unknown parameter.\n"); script_pushconststr(st, ""); @@ -23861,6 +23886,85 @@ BUILDIN(rodex_sendmail2) } /** + * Clan System: Add a player to a clan + */ +BUILDIN(clan_join) +{ + struct map_session_data *sd = NULL; + int clan_id = script_getnum(st, 2); + + if (script_hasdata(st, 3)) + sd = map->id2sd(script_getnum(st, 3)); + else + sd = map->id2sd(st->rid); + + if (sd == NULL) { + script_pushint(st, false); + return false; + } + + if (clan->join(sd, clan_id)) + script_pushint(st, true); + else + script_pushint(st, false); + + return true; +} + +/** + * Clan System: Remove a player from clan + */ +BUILDIN(clan_leave) +{ + struct map_session_data *sd = NULL; + + if (script_hasdata(st, 2)) + sd = map->id2sd(script_getnum(st, 2)); + else + sd = map->id2sd(st->rid); + + if (sd == NULL) { + script_pushint(st, false); + return false; + } + + if (clan->leave(sd, false)) + script_pushint(st, true); + else + script_pushint(st, false); + + return true; +} + +/** + * Clan System: Show clan emblem next to npc name + */ +BUILDIN(clan_master) +{ + struct npc_data *nd = map->id2nd(st->oid); + int clan_id = script_getnum(st, 2); + + if (nd == NULL) { + script_pushint(st, false); + return false; + } else if (clan_id <= 0) { + script_pushint(st, false); + ShowError("buildin_clan_master: Received Invalid Clan ID %d\n", clan_id); + return false; + } else if (clan->search(clan_id) == NULL) { + script_pushint(st, false); + ShowError("buildin_clan_master: Received Id of a nonexistent Clan. Id: %d\n", clan_id); + return false; + } + + nd->clan_id = clan_id; + clif->sc_load(&nd->bl, nd->bl.id, AREA, status->dbs->IconChangeTable[SC_CLAN_INFO], 0, clan_id, 0); + + script_pushint(st, true); + return true; +} + +/** * Adds a built-in script function. * * @param buildin Script function data @@ -24556,6 +24660,11 @@ void script_parse_builtin(void) { /* Navigation */ BUILDIN_DEF(navigateto, "s??????"), + /* Clan System */ + BUILDIN_DEF(clan_join,"i?"), + BUILDIN_DEF(clan_leave,"?"), + BUILDIN_DEF(clan_master,"i"), + BUILDIN_DEF(channelmes, "ss"), BUILDIN_DEF(addchannelhandler, "ss"), BUILDIN_DEF(removechannelhandler, "ss"), @@ -24923,6 +25032,7 @@ void script_hardcoded_constants(void) script->set_constant("RENEWAL_ASPD", 0, false, false); #endif script->constdb_comment(NULL); +#include "constants.inc" } /** diff --git a/src/map/skill.c b/src/map/skill.c index 4c9e83579..3d541bf76 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -26,6 +26,7 @@ #include "map/battle.h" #include "map/battleground.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/clif.h" #include "map/date.h" #include "map/elemental.h" @@ -17180,6 +17181,7 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, group->party_id = status->get_party_id(src); group->guild_id = status->get_guild_id(src); group->bg_id = bg->team_get_id(src); + group->clan_id = clan->get_id(src); group->group_id = skill->get_new_group_id(); CREATE(group->unit.data, struct skill_unit, count); group->unit.count = count; diff --git a/src/map/skill.h b/src/map/skill.h index c494c0e83..d7590921a 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1371,7 +1371,7 @@ enum e_skill { GM_FORCE_TRANSFER, GM_WIDE_RESURRECTION, ALL_NIFLHEIM_RECALL, - ALL_PRONTERA_RECALL, + ALL_PRONTERA_RECALL, ALL_GLASTHEIM_RECALL, ALL_THANATOS_RECALL, @@ -1774,6 +1774,7 @@ struct skill_unit_group { int party_id; int guild_id; int bg_id; + int clan_id; int map; int target_flag; //Holds BCT_* flag for battle_check_target int bl_flag; //Holds BL_* flag for map_foreachin* functions diff --git a/src/map/status.c b/src/map/status.c index 9e578bc12..3e4b4a45c 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -25,6 +25,7 @@ #include "map/battle.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/clif.h" #include "map/elemental.h" #include "map/guild.h" @@ -1019,6 +1020,9 @@ void initChangeTables(void) // Summoner status->dbs->IconChangeTable[SC_SPRITEMABLE] = SI_SPRITEMABLE; + // Clan System + status->dbs->IconChangeTable[SC_CLAN_INFO] = SI_CLAN_INFO; + // RoDEX status->dbs->IconChangeTable[SC_DAILYSENDMAILCNT] = SI_DAILYSENDMAILCNT; @@ -1181,6 +1185,9 @@ void initChangeTables(void) status->dbs->ChangeFlagTable[SC_MVPCARD_ORCHERO] |= SCB_ALL; status->dbs->ChangeFlagTable[SC_MVPCARD_ORCLORD] |= SCB_ALL; + // Clan System + status->dbs->ChangeFlagTable[SC_CLAN_INFO] |= SCB_NONE; + // Costumes status->dbs->ChangeFlagTable[SC_DRESS_UP] |= SCB_NONE; status->dbs->ChangeFlagTable[SC_MOONSTAR] |= SCB_NONE; @@ -2685,6 +2692,12 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) status->current_equip_option_index = -1; status->current_equip_item_index = -1; + // Clan Buffs + if (sd->status.clan_id > 0) { + struct clan *c = clan->search(sd->status.clan_id); + clan->buff_start(sd, c); + } + status->calc_pc_additional(sd, opt); if( sd->pd ) { // Pet Bonus @@ -9726,6 +9739,11 @@ void status_change_start_display(struct map_session_data *sd, enum sc_type type, case SC_ALL_RIDING: dval1 = 1; break; + case SC_CLAN_INFO: + dval1 = val1; + dval2 = val2; + dval3 = val3; + break; default: /* all others: just copy val1 */ dval1 = val1; break; @@ -9745,6 +9763,9 @@ int status_get_val_flag(enum sc_type type) { int val_flag = 0; switch (type) { + case SC_CLAN_INFO: + val_flag |= 1 | 2; + break; case SC_FIGHTINGSPIRIT: val_flag |= 1 | 2; break; diff --git a/src/map/status.h b/src/map/status.h index e9c2218e8..5a031fa48 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -838,13 +838,16 @@ typedef enum sc_type { SC_BITESCAR, SC_ARCLOUSEDASH, SC_TUNAPARTY, - SC_SHRIMP, // 650 + SC_SHRIMP, // 650 SC_FRESHSHRIMP, - + SC_DRESS_UP, // Rodex SC_DAILYSENDMAILCNT, + + // Clan System + SC_CLAN_INFO, #ifndef SC_MAX SC_MAX, //Automatically updated max, used in for's to check we are within bounds. #endif diff --git a/src/map/unit.c b/src/map/unit.c index 0b5b21caf..938b587f3 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -27,6 +27,7 @@ #include "map/battleground.h" #include "map/chat.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/clif.h" #include "map/duel.h" #include "map/elemental.h" @@ -2057,7 +2058,7 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, #ifdef OFFICIAL_WALKPATH if( !path->search_long(NULL, bl, bl->m, bl->x, bl->y, tbl->x-dx, tbl->y-dy, CELL_CHKNOPASS) // Check if there is an obstacle between - && wpd.path_len > 14 // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett] + && wpd.path_len > 14 // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett] && (bl->type != BL_NPC) ) // If type is a NPC, please disregard. return false; #endif @@ -2725,6 +2726,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) map->foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 0); party->send_logout(sd); guild->send_memberinfoshort(sd,0); + clan->member_offline(sd); pc->cleareventtimer(sd); pc->inventory_rental_clear(sd); pc->delspiritball(sd,sd->spiritball,1); diff --git a/src/plugins/HPMHooking.c b/src/plugins/HPMHooking.c index 6d6184402..8686a07be 100644 --- a/src/plugins/HPMHooking.c +++ b/src/plugins/HPMHooking.c @@ -34,9 +34,12 @@ PRAGMA_GCC5(GCC diagnostic ignored "-Wdiscarded-qualifiers") #define HPM_HOOKS_INCLUDE "HPMHooking/HPMHooking_login.Hooks.inc" #define HPM_POINTS_INCLUDE "HPMHooking/HPMHooking_login.HookingPoints.inc" #define HPM_SOURCES_INCLUDE "HPMHooking/HPMHooking_login.sources.inc" +#include "login/account.h" +#include "login/ipban.h" #include "login/lclif.h" #include "login/lclif.p.h" #include "login/login.h" +#include "login/loginlog.h" #elif defined (HPMHOOKING_CHAR) #define HPM_SERVER_TYPE SERVER_TYPE_CHAR #define HPM_CORE_INCLUDE "HPMHooking/HPMHooking_char.HPMHooksCore.inc" @@ -46,6 +49,7 @@ PRAGMA_GCC5(GCC diagnostic ignored "-Wdiscarded-qualifiers") #include "char/char.h" #include "char/geoip.h" #include "char/int_auction.h" +#include "char/int_clan.h" #include "char/int_elemental.h" #include "char/int_guild.h" #include "char/int_homun.h" @@ -73,6 +77,7 @@ PRAGMA_GCC5(GCC diagnostic ignored "-Wdiscarded-qualifiers") #include "map/channel.h" #include "map/chat.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/clif.h" #include "map/duel.h" #include "map/elemental.h" diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index db578e59f..816e1981d 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -33,6 +33,46 @@ typedef bool (*HPMHOOK_post_HCache_check) (bool retVal___, const char *file); typedef FILE* (*HPMHOOK_pre_HCache_open) (const char **file, const char **opt); typedef FILE* (*HPMHOOK_post_HCache_open) (FILE* retVal___, const char *file, const char *opt); #endif // COMMON_UTILS_H +#ifdef LOGIN_ACCOUNT_H /* account */ +typedef struct Sql* (*HPMHOOK_pre_account_db_sql_up) (AccountDB **self); +typedef struct Sql* (*HPMHOOK_post_account_db_sql_up) (struct Sql* retVal___, AccountDB *self); +typedef void (*HPMHOOK_pre_account_mmo_send_accreg2) (AccountDB **self, int *fd, int *account_id, int *char_id); +typedef void (*HPMHOOK_post_account_mmo_send_accreg2) (AccountDB *self, int fd, int account_id, int char_id); +typedef void (*HPMHOOK_pre_account_mmo_save_accreg2) (AccountDB **self, int *fd, int *account_id, int *char_id); +typedef void (*HPMHOOK_post_account_mmo_save_accreg2) (AccountDB *self, int fd, int account_id, int char_id); +typedef bool (*HPMHOOK_pre_account_mmo_auth_fromsql) (AccountDB_SQL **db, struct mmo_account **acc, int *account_id); +typedef bool (*HPMHOOK_post_account_mmo_auth_fromsql) (bool retVal___, AccountDB_SQL *db, struct mmo_account *acc, int account_id); +typedef bool (*HPMHOOK_pre_account_mmo_auth_tosql) (AccountDB_SQL **db, const struct mmo_account **acc, bool *is_new); +typedef bool (*HPMHOOK_post_account_mmo_auth_tosql) (bool retVal___, AccountDB_SQL *db, const struct mmo_account *acc, bool is_new); +typedef AccountDB* (*HPMHOOK_pre_account_db_sql) (void); +typedef AccountDB* (*HPMHOOK_post_account_db_sql) (AccountDB* retVal___); +typedef bool (*HPMHOOK_pre_account_db_sql_init) (AccountDB **self); +typedef bool (*HPMHOOK_post_account_db_sql_init) (bool retVal___, AccountDB *self); +typedef void (*HPMHOOK_pre_account_db_sql_destroy) (AccountDB **self); +typedef void (*HPMHOOK_post_account_db_sql_destroy) (AccountDB *self); +typedef bool (*HPMHOOK_pre_account_db_sql_get_property) (AccountDB **self, const char **key, char **buf, size_t *buflen); +typedef bool (*HPMHOOK_post_account_db_sql_get_property) (bool retVal___, AccountDB *self, const char *key, char *buf, size_t buflen); +typedef bool (*HPMHOOK_pre_account_db_sql_set_property) (AccountDB **self, struct config_t **config, bool *imported); +typedef bool (*HPMHOOK_post_account_db_sql_set_property) (bool retVal___, AccountDB *self, struct config_t *config, bool imported); +typedef bool (*HPMHOOK_pre_account_db_sql_create) (AccountDB **self, struct mmo_account **acc); +typedef bool (*HPMHOOK_post_account_db_sql_create) (bool retVal___, AccountDB *self, struct mmo_account *acc); +typedef bool (*HPMHOOK_pre_account_db_sql_remove) (AccountDB **self, const int *account_id); +typedef bool (*HPMHOOK_post_account_db_sql_remove) (bool retVal___, AccountDB *self, const int account_id); +typedef bool (*HPMHOOK_pre_account_db_sql_save) (AccountDB **self, const struct mmo_account **acc); +typedef bool (*HPMHOOK_post_account_db_sql_save) (bool retVal___, AccountDB *self, const struct mmo_account *acc); +typedef bool (*HPMHOOK_pre_account_db_sql_load_num) (AccountDB **self, struct mmo_account **acc, const int *account_id); +typedef bool (*HPMHOOK_post_account_db_sql_load_num) (bool retVal___, AccountDB *self, struct mmo_account *acc, const int account_id); +typedef bool (*HPMHOOK_pre_account_db_sql_load_str) (AccountDB **self, struct mmo_account **acc, const char **userid); +typedef bool (*HPMHOOK_post_account_db_sql_load_str) (bool retVal___, AccountDB *self, struct mmo_account *acc, const char *userid); +typedef AccountDBIterator* (*HPMHOOK_pre_account_db_sql_iterator) (AccountDB **self); +typedef AccountDBIterator* (*HPMHOOK_post_account_db_sql_iterator) (AccountDBIterator* retVal___, AccountDB *self); +typedef void (*HPMHOOK_pre_account_db_sql_iter_destroy) (AccountDBIterator **self); +typedef void (*HPMHOOK_post_account_db_sql_iter_destroy) (AccountDBIterator *self); +typedef bool (*HPMHOOK_pre_account_db_sql_iter_next) (AccountDBIterator **self, struct mmo_account **acc); +typedef bool (*HPMHOOK_post_account_db_sql_iter_next) (bool retVal___, AccountDBIterator *self, struct mmo_account *acc); +typedef bool (*HPMHOOK_pre_account_db_read_inter) (AccountDB_SQL **db, const char **filename, bool *imported); +typedef bool (*HPMHOOK_post_account_db_read_inter) (bool retVal___, AccountDB_SQL *db, const char *filename, bool imported); +#endif // LOGIN_ACCOUNT_H #ifdef MAP_ATCOMMAND_H /* atcommand */ typedef void (*HPMHOOK_pre_atcommand_init) (bool *minimal); typedef void (*HPMHOOK_post_atcommand_init) (bool minimal); @@ -867,6 +907,62 @@ typedef void (*HPMHOOK_post_chrif_save_scdata_single) (int account_id, int char_ typedef void (*HPMHOOK_pre_chrif_del_scdata_single) (int *account_id, int *char_id, short *type); typedef void (*HPMHOOK_post_chrif_del_scdata_single) (int account_id, int char_id, short type); #endif // MAP_CHRIF_H +#ifdef MAP_CLAN_H /* clan */ +typedef void (*HPMHOOK_pre_clan_init) (bool *minimal); +typedef void (*HPMHOOK_post_clan_init) (bool minimal); +typedef void (*HPMHOOK_pre_clan_final) (void); +typedef void (*HPMHOOK_post_clan_final) (void); +typedef bool (*HPMHOOK_pre_clan_config_read) (bool *reload); +typedef bool (*HPMHOOK_post_clan_config_read) (bool retVal___, bool reload); +typedef void (*HPMHOOK_pre_clan_config_read_additional_settings) (struct config_setting_t **settings, const char **source); +typedef void (*HPMHOOK_post_clan_config_read_additional_settings) (struct config_setting_t *settings, const char *source); +typedef void (*HPMHOOK_pre_clan_read_db) (struct config_setting_t **settings, const char **source, bool *reload); +typedef void (*HPMHOOK_post_clan_read_db) (struct config_setting_t *settings, const char *source, bool reload); +typedef int (*HPMHOOK_pre_clan_read_db_sub) (struct config_setting_t **settings, const char **source, bool *reload); +typedef int (*HPMHOOK_post_clan_read_db_sub) (int retVal___, struct config_setting_t *settings, const char *source, bool reload); +typedef void (*HPMHOOK_pre_clan_read_db_additional_fields) (struct clan **entry, struct config_setting_t **t, int *n, const char **source); +typedef void (*HPMHOOK_post_clan_read_db_additional_fields) (struct clan *entry, struct config_setting_t *t, int n, const char *source); +typedef void (*HPMHOOK_pre_clan_read_buffs) (struct clan **c, struct config_setting_t **buff, const char **source); +typedef void (*HPMHOOK_post_clan_read_buffs) (struct clan *c, struct config_setting_t *buff, const char *source); +typedef struct clan* (*HPMHOOK_pre_clan_search) (int *clan_id); +typedef struct clan* (*HPMHOOK_post_clan_search) (struct clan* retVal___, int clan_id); +typedef struct clan* (*HPMHOOK_pre_clan_searchname) (const char **name); +typedef struct clan* (*HPMHOOK_post_clan_searchname) (struct clan* retVal___, const char *name); +typedef struct map_session_data* (*HPMHOOK_pre_clan_getonlinesd) (struct clan **c); +typedef struct map_session_data* (*HPMHOOK_post_clan_getonlinesd) (struct map_session_data* retVal___, struct clan *c); +typedef int (*HPMHOOK_pre_clan_getindex) (const struct clan **c, int *char_id); +typedef int (*HPMHOOK_post_clan_getindex) (int retVal___, const struct clan *c, int char_id); +typedef bool (*HPMHOOK_pre_clan_join) (struct map_session_data **sd, int *clan_id); +typedef bool (*HPMHOOK_post_clan_join) (bool retVal___, struct map_session_data *sd, int clan_id); +typedef void (*HPMHOOK_pre_clan_member_online) (struct map_session_data **sd, bool *first); +typedef void (*HPMHOOK_post_clan_member_online) (struct map_session_data *sd, bool first); +typedef bool (*HPMHOOK_pre_clan_leave) (struct map_session_data **sd, bool *first); +typedef bool (*HPMHOOK_post_clan_leave) (bool retVal___, struct map_session_data *sd, bool first); +typedef bool (*HPMHOOK_pre_clan_send_message) (struct map_session_data **sd, const char **mes); +typedef bool (*HPMHOOK_post_clan_send_message) (bool retVal___, struct map_session_data *sd, const char *mes); +typedef void (*HPMHOOK_pre_clan_recv_message) (struct clan **c, const char **mes, int *len); +typedef void (*HPMHOOK_post_clan_recv_message) (struct clan *c, const char *mes, int len); +typedef void (*HPMHOOK_pre_clan_member_offline) (struct map_session_data **sd); +typedef void (*HPMHOOK_post_clan_member_offline) (struct map_session_data *sd); +typedef void (*HPMHOOK_pre_clan_set_constants) (void); +typedef void (*HPMHOOK_post_clan_set_constants) (void); +typedef int (*HPMHOOK_pre_clan_get_id) (const struct block_list **bl); +typedef int (*HPMHOOK_post_clan_get_id) (int retVal___, const struct block_list *bl); +typedef void (*HPMHOOK_pre_clan_buff_start) (struct map_session_data **sd, struct clan **c); +typedef void (*HPMHOOK_post_clan_buff_start) (struct map_session_data *sd, struct clan *c); +typedef void (*HPMHOOK_pre_clan_buff_end) (struct map_session_data **sd, struct clan **c); +typedef void (*HPMHOOK_post_clan_buff_end) (struct map_session_data *sd, struct clan *c); +typedef void (*HPMHOOK_pre_clan_reload) (void); +typedef void (*HPMHOOK_post_clan_reload) (void); +typedef int (*HPMHOOK_pre_clan_rejoin) (struct map_session_data **sd, va_list ap); +typedef int (*HPMHOOK_post_clan_rejoin) (int retVal___, struct map_session_data *sd, va_list ap); +typedef int (*HPMHOOK_pre_clan_inactivity_kick) (int *tid, int64 *tick, int *id, intptr_t *data); +typedef int (*HPMHOOK_post_clan_inactivity_kick) (int retVal___, int tid, int64 tick, int id, intptr_t data); +typedef int (*HPMHOOK_pre_clan_request_kickoffline) (int *tid, int64 *tick, int *id, intptr_t *data); +typedef int (*HPMHOOK_post_clan_request_kickoffline) (int retVal___, int tid, int64 tick, int id, intptr_t data); +typedef int (*HPMHOOK_pre_clan_request_membercount) (int *tid, int64 *tick, int *id, intptr_t *data); +typedef int (*HPMHOOK_post_clan_request_membercount) (int retVal___, int tid, int64 tick, int id, intptr_t data); +#endif // MAP_CLAN_H #ifdef MAP_CLIF_H /* clif */ typedef int (*HPMHOOK_pre_clif_init) (bool *minimal); typedef int (*HPMHOOK_post_clif_init) (int retVal___, bool minimal); @@ -2298,6 +2394,16 @@ typedef void (*HPMHOOK_pre_clif_rodex_icon) (int *fd, bool *show); typedef void (*HPMHOOK_post_clif_rodex_icon) (int fd, bool show); typedef void (*HPMHOOK_pre_clif_skill_scale) (struct block_list **bl, int *src_id, int *x, int *y, uint16 *skill_id, uint16 *skill_lv, int *casttime); typedef void (*HPMHOOK_post_clif_skill_scale) (struct block_list *bl, int src_id, int x, int y, uint16 skill_id, uint16 skill_lv, int casttime); +typedef void (*HPMHOOK_pre_clif_clan_basicinfo) (struct map_session_data **sd); +typedef void (*HPMHOOK_post_clif_clan_basicinfo) (struct map_session_data *sd); +typedef void (*HPMHOOK_pre_clif_clan_onlinecount) (struct clan **c); +typedef void (*HPMHOOK_post_clif_clan_onlinecount) (struct clan *c); +typedef void (*HPMHOOK_pre_clif_clan_leave) (struct map_session_data **sd); +typedef void (*HPMHOOK_post_clif_clan_leave) (struct map_session_data *sd); +typedef void (*HPMHOOK_pre_clif_clan_message) (struct clan **c, const char **mes, int *len); +typedef void (*HPMHOOK_post_clif_clan_message) (struct clan *c, const char *mes, int len); +typedef void (*HPMHOOK_pre_clif_pClanMessage) (int *fd, struct map_session_data **sd); +typedef void (*HPMHOOK_post_clif_pClanMessage) (int fd, struct map_session_data *sd); #endif // MAP_CLIF_H #ifdef COMMON_CORE_H /* cmdline */ typedef void (*HPMHOOK_pre_cmdline_init) (void); @@ -2845,6 +2951,14 @@ typedef int (*HPMHOOK_post_inter_auction_sql_init) (int retVal___); typedef void (*HPMHOOK_pre_inter_auction_sql_final) (void); typedef void (*HPMHOOK_post_inter_auction_sql_final) (void); #endif // CHAR_INT_AUCTION_H +#ifdef CHAR_INT_CLAN_H /* inter_clan */ +typedef int (*HPMHOOK_pre_inter_clan_kick_inactive_members) (int *clan_id, int *kick_interval); +typedef int (*HPMHOOK_post_inter_clan_kick_inactive_members) (int retVal___, int clan_id, int kick_interval); +typedef int (*HPMHOOK_pre_inter_clan_count_members) (int *clan_id, int *kick_interval); +typedef int (*HPMHOOK_post_inter_clan_count_members) (int retVal___, int clan_id, int kick_interval); +typedef int (*HPMHOOK_pre_inter_clan_parse_frommap) (int *fd); +typedef int (*HPMHOOK_post_inter_clan_parse_frommap) (int retVal___, int fd); +#endif // CHAR_INT_CLAN_H #ifdef CHAR_INT_ELEMENTAL_H /* inter_elemental */ typedef void (*HPMHOOK_pre_inter_elemental_sql_init) (void); typedef void (*HPMHOOK_post_inter_elemental_sql_init) (void); @@ -3208,6 +3322,10 @@ typedef int (*HPMHOOK_pre_intif_rodex_sendmail) (struct rodex_message **msg); typedef int (*HPMHOOK_post_intif_rodex_sendmail) (int retVal___, struct rodex_message *msg); typedef int (*HPMHOOK_pre_intif_rodex_checkname) (struct map_session_data **sd, const char **name); typedef int (*HPMHOOK_post_intif_rodex_checkname) (int retVal___, struct map_session_data *sd, const char *name); +typedef int (*HPMHOOK_pre_intif_clan_kickoffline) (int *clan_id, int *kick_interval); +typedef int (*HPMHOOK_post_intif_clan_kickoffline) (int retVal___, int clan_id, int kick_interval); +typedef int (*HPMHOOK_pre_intif_clan_membercount) (int *clan_id, int *kick_interval); +typedef int (*HPMHOOK_post_intif_clan_membercount) (int retVal___, int clan_id, int kick_interval); typedef void (*HPMHOOK_pre_intif_request_accinfo) (int *u_fd, int *aid, int *group_lv, char **query); typedef void (*HPMHOOK_post_intif_request_accinfo) (int u_fd, int aid, int group_lv, char *query); typedef int (*HPMHOOK_pre_intif_CheckForCharServer) (void); @@ -3348,7 +3466,29 @@ typedef void (*HPMHOOK_pre_intif_pRodexSendMail) (int *fd); typedef void (*HPMHOOK_post_intif_pRodexSendMail) (int fd); typedef void (*HPMHOOK_pre_intif_pRodexCheckName) (int *fd); typedef void (*HPMHOOK_post_intif_pRodexCheckName) (int fd); +typedef void (*HPMHOOK_pre_intif_pRecvClanMemberAction) (int *fd); +typedef void (*HPMHOOK_post_intif_pRecvClanMemberAction) (int fd); #endif // MAP_INTIF_H +#ifdef LOGIN_IPBAN_H /* ipban */ +typedef void (*HPMHOOK_pre_ipban_init) (void); +typedef void (*HPMHOOK_post_ipban_init) (void); +typedef void (*HPMHOOK_pre_ipban_final) (void); +typedef void (*HPMHOOK_post_ipban_final) (void); +typedef int (*HPMHOOK_pre_ipban_cleanup) (int *tid, int64 *tick, int *id, intptr_t *data); +typedef int (*HPMHOOK_post_ipban_cleanup) (int retVal___, int tid, int64 tick, int id, intptr_t data); +typedef bool (*HPMHOOK_pre_ipban_config_read_inter) (const char **filename, bool *imported); +typedef bool (*HPMHOOK_post_ipban_config_read_inter) (bool retVal___, const char *filename, bool imported); +typedef bool (*HPMHOOK_pre_ipban_config_read_connection) (const char **filename, struct config_t **config, bool *imported); +typedef bool (*HPMHOOK_post_ipban_config_read_connection) (bool retVal___, const char *filename, struct config_t *config, bool imported); +typedef bool (*HPMHOOK_pre_ipban_config_read_dynamic) (const char **filename, struct config_t **config, bool *imported); +typedef bool (*HPMHOOK_post_ipban_config_read_dynamic) (bool retVal___, const char *filename, struct config_t *config, bool imported); +typedef bool (*HPMHOOK_pre_ipban_config_read) (const char **filename, struct config_t **config, bool *imported); +typedef bool (*HPMHOOK_post_ipban_config_read) (bool retVal___, const char *filename, struct config_t *config, bool imported); +typedef bool (*HPMHOOK_pre_ipban_check) (uint32 *ip); +typedef bool (*HPMHOOK_post_ipban_check) (bool retVal___, uint32 ip); +typedef void (*HPMHOOK_pre_ipban_log) (uint32 *ip); +typedef void (*HPMHOOK_post_ipban_log) (uint32 ip); +#endif // LOGIN_IPBAN_H #ifdef MAP_IRC_BOT_H /* ircbot */ typedef void (*HPMHOOK_pre_ircbot_init) (bool *minimal); typedef void (*HPMHOOK_post_ircbot_init) (bool minimal); @@ -3519,6 +3659,16 @@ typedef bool (*HPMHOOK_post_itemdb_lookup_const) (bool retVal___, const struct c typedef bool (*HPMHOOK_pre_itemdb_lookup_const_mask) (const struct config_setting_t **it, const char **name, int **value); typedef bool (*HPMHOOK_post_itemdb_lookup_const_mask) (bool retVal___, const struct config_setting_t *it, const char *name, int *value); #endif // MAP_ITEMDB_H +#ifdef LOGIN_LOGIN_H /* lchrif */ +typedef void (*HPMHOOK_pre_lchrif_server_init) (int *id); +typedef void (*HPMHOOK_post_lchrif_server_init) (int id); +typedef void (*HPMHOOK_pre_lchrif_server_destroy) (int *id); +typedef void (*HPMHOOK_post_lchrif_server_destroy) (int id); +typedef void (*HPMHOOK_pre_lchrif_server_reset) (int *id); +typedef void (*HPMHOOK_post_lchrif_server_reset) (int id); +typedef void (*HPMHOOK_pre_lchrif_on_disconnect) (int *id); +typedef void (*HPMHOOK_post_lchrif_on_disconnect) (int id); +#endif // LOGIN_LOGIN_H #ifdef LOGIN_LCLIF_H /* lclif */ typedef void (*HPMHOOK_pre_lclif_init) (void); typedef void (*HPMHOOK_post_lclif_init) (void); @@ -3911,6 +4061,22 @@ typedef void (*HPMHOOK_post_loginif_send_users_count) (int users); typedef void (*HPMHOOK_pre_loginif_connect_to_server) (void); typedef void (*HPMHOOK_post_loginif_connect_to_server) (void); #endif // CHAR_LOGINIF_H +#ifdef LOGIN_LOGINLOG_H /* loginlog */ +typedef unsigned long (*HPMHOOK_pre_loginlog_failedattempts) (uint32 *ip, unsigned int *minutes); +typedef unsigned long (*HPMHOOK_post_loginlog_failedattempts) (unsigned long retVal___, uint32 ip, unsigned int minutes); +typedef void (*HPMHOOK_pre_loginlog_log) (uint32 *ip, const char **username, int *rcode, const char **message); +typedef void (*HPMHOOK_post_loginlog_log) (uint32 ip, const char *username, int rcode, const char *message); +typedef bool (*HPMHOOK_pre_loginlog_init) (void); +typedef bool (*HPMHOOK_post_loginlog_init) (bool retVal___); +typedef bool (*HPMHOOK_pre_loginlog_final) (void); +typedef bool (*HPMHOOK_post_loginlog_final) (bool retVal___); +typedef bool (*HPMHOOK_pre_loginlog_config_read_names) (const char **filename, struct config_t **config, bool *imported); +typedef bool (*HPMHOOK_post_loginlog_config_read_names) (bool retVal___, const char *filename, struct config_t *config, bool imported); +typedef bool (*HPMHOOK_pre_loginlog_config_read_log) (const char **filename, struct config_t **config, bool *imported); +typedef bool (*HPMHOOK_post_loginlog_config_read_log) (bool retVal___, const char *filename, struct config_t *config, bool imported); +typedef bool (*HPMHOOK_pre_loginlog_config_read) (const char **filename, bool *imported); +typedef bool (*HPMHOOK_post_loginlog_config_read) (bool retVal___, const char *filename, bool imported); +#endif // LOGIN_LOGINLOG_H #ifdef MAP_MAIL_H /* mail */ typedef void (*HPMHOOK_pre_mail_clear) (struct map_session_data **sd); typedef void (*HPMHOOK_post_mail_clear) (struct map_session_data *sd); @@ -4566,6 +4732,10 @@ typedef void (*HPMHOOK_pre_mapif_namechange_ack) (int *fd, int *account_id, int typedef void (*HPMHOOK_post_mapif_namechange_ack) (int fd, int account_id, int char_id, int type, int flag, const char *name); typedef int (*HPMHOOK_pre_mapif_parse_NameChangeRequest) (int *fd); typedef int (*HPMHOOK_post_mapif_parse_NameChangeRequest) (int retVal___, int fd); +typedef int (*HPMHOOK_pre_mapif_parse_ClanMemberKick) (int *fd, int *clan_id, int *kick_interval); +typedef int (*HPMHOOK_post_mapif_parse_ClanMemberKick) (int retVal___, int fd, int clan_id, int kick_interval); +typedef int (*HPMHOOK_pre_mapif_parse_ClanMemberCount) (int *fd, int *clan_id, int *kick_interval); +typedef int (*HPMHOOK_post_mapif_parse_ClanMemberCount) (int retVal___, int fd, int clan_id, int kick_interval); #endif // CHAR_MAPIF_H #ifdef COMMON_MAPINDEX_H /* mapindex */ typedef int (*HPMHOOK_pre_mapindex_init) (void); diff --git a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc index d7e6f524d..d0b4ac5ce 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc @@ -466,6 +466,12 @@ struct { struct HPMHookPoint *HP_inter_auction_sql_init_post; struct HPMHookPoint *HP_inter_auction_sql_final_pre; struct HPMHookPoint *HP_inter_auction_sql_final_post; + struct HPMHookPoint *HP_inter_clan_kick_inactive_members_pre; + struct HPMHookPoint *HP_inter_clan_kick_inactive_members_post; + struct HPMHookPoint *HP_inter_clan_count_members_pre; + struct HPMHookPoint *HP_inter_clan_count_members_post; + struct HPMHookPoint *HP_inter_clan_parse_frommap_pre; + struct HPMHookPoint *HP_inter_clan_parse_frommap_post; struct HPMHookPoint *HP_inter_elemental_sql_init_pre; struct HPMHookPoint *HP_inter_elemental_sql_init_post; struct HPMHookPoint *HP_inter_elemental_sql_final_pre; @@ -1184,6 +1190,10 @@ struct { struct HPMHookPoint *HP_mapif_namechange_ack_post; struct HPMHookPoint *HP_mapif_parse_NameChangeRequest_pre; struct HPMHookPoint *HP_mapif_parse_NameChangeRequest_post; + struct HPMHookPoint *HP_mapif_parse_ClanMemberKick_pre; + struct HPMHookPoint *HP_mapif_parse_ClanMemberKick_post; + struct HPMHookPoint *HP_mapif_parse_ClanMemberCount_pre; + struct HPMHookPoint *HP_mapif_parse_ClanMemberCount_post; struct HPMHookPoint *HP_mapindex_init_pre; struct HPMHookPoint *HP_mapindex_init_post; struct HPMHookPoint *HP_mapindex_final_pre; @@ -1985,6 +1995,12 @@ struct { int HP_inter_auction_sql_init_post; int HP_inter_auction_sql_final_pre; int HP_inter_auction_sql_final_post; + int HP_inter_clan_kick_inactive_members_pre; + int HP_inter_clan_kick_inactive_members_post; + int HP_inter_clan_count_members_pre; + int HP_inter_clan_count_members_post; + int HP_inter_clan_parse_frommap_pre; + int HP_inter_clan_parse_frommap_post; int HP_inter_elemental_sql_init_pre; int HP_inter_elemental_sql_init_post; int HP_inter_elemental_sql_final_pre; @@ -2703,6 +2719,10 @@ struct { int HP_mapif_namechange_ack_post; int HP_mapif_parse_NameChangeRequest_pre; int HP_mapif_parse_NameChangeRequest_post; + int HP_mapif_parse_ClanMemberKick_pre; + int HP_mapif_parse_ClanMemberKick_post; + int HP_mapif_parse_ClanMemberCount_pre; + int HP_mapif_parse_ClanMemberCount_post; int HP_mapindex_init_pre; int HP_mapindex_init_post; int HP_mapindex_final_pre; @@ -3073,6 +3093,7 @@ struct { struct des_interface des; struct geoip_interface geoip; struct inter_auction_interface inter_auction; + struct inter_clan_interface inter_clan; struct inter_elemental_interface inter_elemental; struct inter_guild_interface inter_guild; struct inter_homunculus_interface inter_homunculus; diff --git a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc index 14dc89804..36a115e1b 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc @@ -255,6 +255,10 @@ struct HookingPointData HookingPoints[] = { { HP_POP(inter_auction->parse_frommap, HP_inter_auction_parse_frommap) }, { HP_POP(inter_auction->sql_init, HP_inter_auction_sql_init) }, { HP_POP(inter_auction->sql_final, HP_inter_auction_sql_final) }, +/* inter_clan_interface */ + { HP_POP(inter_clan->kick_inactive_members, HP_inter_clan_kick_inactive_members) }, + { HP_POP(inter_clan->count_members, HP_inter_clan_count_members) }, + { HP_POP(inter_clan->parse_frommap, HP_inter_clan_parse_frommap) }, /* inter_elemental_interface */ { HP_POP(inter_elemental->sql_init, HP_inter_elemental_sql_init) }, { HP_POP(inter_elemental->sql_final, HP_inter_elemental_sql_final) }, @@ -628,6 +632,8 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mapif->parse_RegistryRequest, HP_mapif_parse_RegistryRequest) }, { HP_POP(mapif->namechange_ack, HP_mapif_namechange_ack) }, { HP_POP(mapif->parse_NameChangeRequest, HP_mapif_parse_NameChangeRequest) }, + { HP_POP(mapif->parse_ClanMemberKick, HP_mapif_parse_ClanMemberKick) }, + { HP_POP(mapif->parse_ClanMemberCount, HP_mapif_parse_ClanMemberCount) }, /* mapindex_interface */ { HP_POP(mapindex->init, HP_mapindex_init) }, { HP_POP(mapindex->final, HP_mapindex_final) }, diff --git a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc index 1836bf6ba..cfd6caee1 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc @@ -5879,6 +5879,88 @@ void HP_inter_auction_sql_final(void) { } return; } +/* inter_clan_interface */ +int HP_inter_clan_kick_inactive_members(int clan_id, int kick_interval) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_inter_clan_kick_inactive_members_pre > 0) { + int (*preHookFunc) (int *clan_id, int *kick_interval); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_inter_clan_kick_inactive_members_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_inter_clan_kick_inactive_members_pre[hIndex].func; + retVal___ = preHookFunc(&clan_id, &kick_interval); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.inter_clan.kick_inactive_members(clan_id, kick_interval); + } + if (HPMHooks.count.HP_inter_clan_kick_inactive_members_post > 0) { + int (*postHookFunc) (int retVal___, int clan_id, int kick_interval); + for (hIndex = 0; hIndex < HPMHooks.count.HP_inter_clan_kick_inactive_members_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_inter_clan_kick_inactive_members_post[hIndex].func; + retVal___ = postHookFunc(retVal___, clan_id, kick_interval); + } + } + return retVal___; +} +int HP_inter_clan_count_members(int clan_id, int kick_interval) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_inter_clan_count_members_pre > 0) { + int (*preHookFunc) (int *clan_id, int *kick_interval); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_inter_clan_count_members_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_inter_clan_count_members_pre[hIndex].func; + retVal___ = preHookFunc(&clan_id, &kick_interval); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.inter_clan.count_members(clan_id, kick_interval); + } + if (HPMHooks.count.HP_inter_clan_count_members_post > 0) { + int (*postHookFunc) (int retVal___, int clan_id, int kick_interval); + for (hIndex = 0; hIndex < HPMHooks.count.HP_inter_clan_count_members_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_inter_clan_count_members_post[hIndex].func; + retVal___ = postHookFunc(retVal___, clan_id, kick_interval); + } + } + return retVal___; +} +int HP_inter_clan_parse_frommap(int fd) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_inter_clan_parse_frommap_pre > 0) { + int (*preHookFunc) (int *fd); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_inter_clan_parse_frommap_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_inter_clan_parse_frommap_pre[hIndex].func; + retVal___ = preHookFunc(&fd); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.inter_clan.parse_frommap(fd); + } + if (HPMHooks.count.HP_inter_clan_parse_frommap_post > 0) { + int (*postHookFunc) (int retVal___, int fd); + for (hIndex = 0; hIndex < HPMHooks.count.HP_inter_clan_parse_frommap_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_inter_clan_parse_frommap_post[hIndex].func; + retVal___ = postHookFunc(retVal___, fd); + } + } + return retVal___; +} /* inter_elemental_interface */ void HP_inter_elemental_sql_init(void) { int hIndex = 0; @@ -15500,6 +15582,60 @@ int HP_mapif_parse_NameChangeRequest(int fd) { } return retVal___; } +int HP_mapif_parse_ClanMemberKick(int fd, int clan_id, int kick_interval) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_mapif_parse_ClanMemberKick_pre > 0) { + int (*preHookFunc) (int *fd, int *clan_id, int *kick_interval); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_ClanMemberKick_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_mapif_parse_ClanMemberKick_pre[hIndex].func; + retVal___ = preHookFunc(&fd, &clan_id, &kick_interval); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.mapif.parse_ClanMemberKick(fd, clan_id, kick_interval); + } + if (HPMHooks.count.HP_mapif_parse_ClanMemberKick_post > 0) { + int (*postHookFunc) (int retVal___, int fd, int clan_id, int kick_interval); + for (hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_ClanMemberKick_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_mapif_parse_ClanMemberKick_post[hIndex].func; + retVal___ = postHookFunc(retVal___, fd, clan_id, kick_interval); + } + } + return retVal___; +} +int HP_mapif_parse_ClanMemberCount(int fd, int clan_id, int kick_interval) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_mapif_parse_ClanMemberCount_pre > 0) { + int (*preHookFunc) (int *fd, int *clan_id, int *kick_interval); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_ClanMemberCount_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_mapif_parse_ClanMemberCount_pre[hIndex].func; + retVal___ = preHookFunc(&fd, &clan_id, &kick_interval); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.mapif.parse_ClanMemberCount(fd, clan_id, kick_interval); + } + if (HPMHooks.count.HP_mapif_parse_ClanMemberCount_post > 0) { + int (*postHookFunc) (int retVal___, int fd, int clan_id, int kick_interval); + for (hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_ClanMemberCount_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_mapif_parse_ClanMemberCount_post[hIndex].func; + retVal___ = postHookFunc(retVal___, fd, clan_id, kick_interval); + } + } + return retVal___; +} /* mapindex_interface */ int HP_mapindex_init(void) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_char.sources.inc b/src/plugins/HPMHooking/HPMHooking_char.sources.inc index 8b2f1b071..9ba9e129e 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.sources.inc @@ -34,6 +34,7 @@ HPMHooks.source.DB = *DB; HPMHooks.source.des = *des; HPMHooks.source.geoip = *geoip; HPMHooks.source.inter_auction = *inter_auction; +HPMHooks.source.inter_clan = *inter_clan; HPMHooks.source.inter_elemental = *inter_elemental; HPMHooks.source.inter_guild = *inter_guild; HPMHooks.source.inter_homunculus = *inter_homunculus; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc index f8c270de3..5300ca3a6 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc @@ -32,6 +32,44 @@ struct { struct HPMHookPoint *HP_HCache_check_post; struct HPMHookPoint *HP_HCache_open_pre; struct HPMHookPoint *HP_HCache_open_post; + struct HPMHookPoint *HP_account_db_sql_up_pre; + struct HPMHookPoint *HP_account_db_sql_up_post; + struct HPMHookPoint *HP_account_mmo_send_accreg2_pre; + struct HPMHookPoint *HP_account_mmo_send_accreg2_post; + struct HPMHookPoint *HP_account_mmo_save_accreg2_pre; + struct HPMHookPoint *HP_account_mmo_save_accreg2_post; + struct HPMHookPoint *HP_account_mmo_auth_fromsql_pre; + struct HPMHookPoint *HP_account_mmo_auth_fromsql_post; + struct HPMHookPoint *HP_account_mmo_auth_tosql_pre; + struct HPMHookPoint *HP_account_mmo_auth_tosql_post; + struct HPMHookPoint *HP_account_db_sql_pre; + struct HPMHookPoint *HP_account_db_sql_post; + struct HPMHookPoint *HP_account_db_sql_init_pre; + struct HPMHookPoint *HP_account_db_sql_init_post; + struct HPMHookPoint *HP_account_db_sql_destroy_pre; + struct HPMHookPoint *HP_account_db_sql_destroy_post; + struct HPMHookPoint *HP_account_db_sql_get_property_pre; + struct HPMHookPoint *HP_account_db_sql_get_property_post; + struct HPMHookPoint *HP_account_db_sql_set_property_pre; + struct HPMHookPoint *HP_account_db_sql_set_property_post; + struct HPMHookPoint *HP_account_db_sql_create_pre; + struct HPMHookPoint *HP_account_db_sql_create_post; + struct HPMHookPoint *HP_account_db_sql_remove_pre; + struct HPMHookPoint *HP_account_db_sql_remove_post; + struct HPMHookPoint *HP_account_db_sql_save_pre; + struct HPMHookPoint *HP_account_db_sql_save_post; + struct HPMHookPoint *HP_account_db_sql_load_num_pre; + struct HPMHookPoint *HP_account_db_sql_load_num_post; + struct HPMHookPoint *HP_account_db_sql_load_str_pre; + struct HPMHookPoint *HP_account_db_sql_load_str_post; + struct HPMHookPoint *HP_account_db_sql_iterator_pre; + struct HPMHookPoint *HP_account_db_sql_iterator_post; + struct HPMHookPoint *HP_account_db_sql_iter_destroy_pre; + struct HPMHookPoint *HP_account_db_sql_iter_destroy_post; + struct HPMHookPoint *HP_account_db_sql_iter_next_pre; + struct HPMHookPoint *HP_account_db_sql_iter_next_post; + struct HPMHookPoint *HP_account_db_read_inter_pre; + struct HPMHookPoint *HP_account_db_read_inter_post; struct HPMHookPoint *HP_cmdline_init_pre; struct HPMHookPoint *HP_cmdline_init_post; struct HPMHookPoint *HP_cmdline_final_pre; @@ -96,6 +134,32 @@ struct { struct HPMHookPoint *HP_des_decrypt_block_post; struct HPMHookPoint *HP_des_decrypt_pre; struct HPMHookPoint *HP_des_decrypt_post; + struct HPMHookPoint *HP_ipban_init_pre; + struct HPMHookPoint *HP_ipban_init_post; + struct HPMHookPoint *HP_ipban_final_pre; + struct HPMHookPoint *HP_ipban_final_post; + struct HPMHookPoint *HP_ipban_cleanup_pre; + struct HPMHookPoint *HP_ipban_cleanup_post; + struct HPMHookPoint *HP_ipban_config_read_inter_pre; + struct HPMHookPoint *HP_ipban_config_read_inter_post; + struct HPMHookPoint *HP_ipban_config_read_connection_pre; + struct HPMHookPoint *HP_ipban_config_read_connection_post; + struct HPMHookPoint *HP_ipban_config_read_dynamic_pre; + struct HPMHookPoint *HP_ipban_config_read_dynamic_post; + struct HPMHookPoint *HP_ipban_config_read_pre; + struct HPMHookPoint *HP_ipban_config_read_post; + struct HPMHookPoint *HP_ipban_check_pre; + struct HPMHookPoint *HP_ipban_check_post; + struct HPMHookPoint *HP_ipban_log_pre; + struct HPMHookPoint *HP_ipban_log_post; + struct HPMHookPoint *HP_lchrif_server_init_pre; + struct HPMHookPoint *HP_lchrif_server_init_post; + struct HPMHookPoint *HP_lchrif_server_destroy_pre; + struct HPMHookPoint *HP_lchrif_server_destroy_post; + struct HPMHookPoint *HP_lchrif_server_reset_pre; + struct HPMHookPoint *HP_lchrif_server_reset_post; + struct HPMHookPoint *HP_lchrif_on_disconnect_pre; + struct HPMHookPoint *HP_lchrif_on_disconnect_post; struct HPMHookPoint *HP_lclif_init_pre; struct HPMHookPoint *HP_lclif_init_post; struct HPMHookPoint *HP_lclif_final_pre; @@ -406,6 +470,20 @@ struct { struct HPMHookPoint *HP_login_config_set_md5hash_post; struct HPMHookPoint *HP_login_convert_users_to_colors_pre; struct HPMHookPoint *HP_login_convert_users_to_colors_post; + struct HPMHookPoint *HP_loginlog_failedattempts_pre; + struct HPMHookPoint *HP_loginlog_failedattempts_post; + struct HPMHookPoint *HP_loginlog_log_pre; + struct HPMHookPoint *HP_loginlog_log_post; + struct HPMHookPoint *HP_loginlog_init_pre; + struct HPMHookPoint *HP_loginlog_init_post; + struct HPMHookPoint *HP_loginlog_final_pre; + struct HPMHookPoint *HP_loginlog_final_post; + struct HPMHookPoint *HP_loginlog_config_read_names_pre; + struct HPMHookPoint *HP_loginlog_config_read_names_post; + struct HPMHookPoint *HP_loginlog_config_read_log_pre; + struct HPMHookPoint *HP_loginlog_config_read_log_post; + struct HPMHookPoint *HP_loginlog_config_read_pre; + struct HPMHookPoint *HP_loginlog_config_read_post; struct HPMHookPoint *HP_md5_string_pre; struct HPMHookPoint *HP_md5_string_post; struct HPMHookPoint *HP_md5_binary_pre; @@ -735,6 +813,44 @@ struct { int HP_HCache_check_post; int HP_HCache_open_pre; int HP_HCache_open_post; + int HP_account_db_sql_up_pre; + int HP_account_db_sql_up_post; + int HP_account_mmo_send_accreg2_pre; + int HP_account_mmo_send_accreg2_post; + int HP_account_mmo_save_accreg2_pre; + int HP_account_mmo_save_accreg2_post; + int HP_account_mmo_auth_fromsql_pre; + int HP_account_mmo_auth_fromsql_post; + int HP_account_mmo_auth_tosql_pre; + int HP_account_mmo_auth_tosql_post; + int HP_account_db_sql_pre; + int HP_account_db_sql_post; + int HP_account_db_sql_init_pre; + int HP_account_db_sql_init_post; + int HP_account_db_sql_destroy_pre; + int HP_account_db_sql_destroy_post; + int HP_account_db_sql_get_property_pre; + int HP_account_db_sql_get_property_post; + int HP_account_db_sql_set_property_pre; + int HP_account_db_sql_set_property_post; + int HP_account_db_sql_create_pre; + int HP_account_db_sql_create_post; + int HP_account_db_sql_remove_pre; + int HP_account_db_sql_remove_post; + int HP_account_db_sql_save_pre; + int HP_account_db_sql_save_post; + int HP_account_db_sql_load_num_pre; + int HP_account_db_sql_load_num_post; + int HP_account_db_sql_load_str_pre; + int HP_account_db_sql_load_str_post; + int HP_account_db_sql_iterator_pre; + int HP_account_db_sql_iterator_post; + int HP_account_db_sql_iter_destroy_pre; + int HP_account_db_sql_iter_destroy_post; + int HP_account_db_sql_iter_next_pre; + int HP_account_db_sql_iter_next_post; + int HP_account_db_read_inter_pre; + int HP_account_db_read_inter_post; int HP_cmdline_init_pre; int HP_cmdline_init_post; int HP_cmdline_final_pre; @@ -799,6 +915,32 @@ struct { int HP_des_decrypt_block_post; int HP_des_decrypt_pre; int HP_des_decrypt_post; + int HP_ipban_init_pre; + int HP_ipban_init_post; + int HP_ipban_final_pre; + int HP_ipban_final_post; + int HP_ipban_cleanup_pre; + int HP_ipban_cleanup_post; + int HP_ipban_config_read_inter_pre; + int HP_ipban_config_read_inter_post; + int HP_ipban_config_read_connection_pre; + int HP_ipban_config_read_connection_post; + int HP_ipban_config_read_dynamic_pre; + int HP_ipban_config_read_dynamic_post; + int HP_ipban_config_read_pre; + int HP_ipban_config_read_post; + int HP_ipban_check_pre; + int HP_ipban_check_post; + int HP_ipban_log_pre; + int HP_ipban_log_post; + int HP_lchrif_server_init_pre; + int HP_lchrif_server_init_post; + int HP_lchrif_server_destroy_pre; + int HP_lchrif_server_destroy_post; + int HP_lchrif_server_reset_pre; + int HP_lchrif_server_reset_post; + int HP_lchrif_on_disconnect_pre; + int HP_lchrif_on_disconnect_post; int HP_lclif_init_pre; int HP_lclif_init_post; int HP_lclif_final_pre; @@ -1109,6 +1251,20 @@ struct { int HP_login_config_set_md5hash_post; int HP_login_convert_users_to_colors_pre; int HP_login_convert_users_to_colors_post; + int HP_loginlog_failedattempts_pre; + int HP_loginlog_failedattempts_post; + int HP_loginlog_log_pre; + int HP_loginlog_log_post; + int HP_loginlog_init_pre; + int HP_loginlog_init_post; + int HP_loginlog_final_pre; + int HP_loginlog_final_post; + int HP_loginlog_config_read_names_pre; + int HP_loginlog_config_read_names_post; + int HP_loginlog_config_read_log_pre; + int HP_loginlog_config_read_log_post; + int HP_loginlog_config_read_pre; + int HP_loginlog_config_read_post; int HP_md5_string_pre; int HP_md5_string_post; int HP_md5_binary_pre; @@ -1433,15 +1589,19 @@ struct { struct { struct HCache_interface HCache; + struct account_interface account; struct cmdline_interface cmdline; struct console_interface console; struct core_interface core; struct db_interface DB; struct des_interface des; + struct ipban_interface ipban; + struct lchrif_interface lchrif; struct lclif_interface lclif; struct lclif_interface_private PRIV__lclif; struct libconfig_interface libconfig; struct login_interface login; + struct loginlog_interface loginlog; struct md5_interface md5; struct mutex_interface mutex; struct nullpo_interface nullpo; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc index 8cec39974..6eb2e8121 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc @@ -30,6 +30,26 @@ struct HookingPointData HookingPoints[] = { { HP_POP(HCache->init, HP_HCache_init) }, { HP_POP(HCache->check, HP_HCache_check) }, { HP_POP(HCache->open, HP_HCache_open) }, +/* account_interface */ + { HP_POP(account->db_sql_up, HP_account_db_sql_up) }, + { HP_POP(account->mmo_send_accreg2, HP_account_mmo_send_accreg2) }, + { HP_POP(account->mmo_save_accreg2, HP_account_mmo_save_accreg2) }, + { HP_POP(account->mmo_auth_fromsql, HP_account_mmo_auth_fromsql) }, + { HP_POP(account->mmo_auth_tosql, HP_account_mmo_auth_tosql) }, + { HP_POP(account->db_sql, HP_account_db_sql) }, + { HP_POP(account->db_sql_init, HP_account_db_sql_init) }, + { HP_POP(account->db_sql_destroy, HP_account_db_sql_destroy) }, + { HP_POP(account->db_sql_get_property, HP_account_db_sql_get_property) }, + { HP_POP(account->db_sql_set_property, HP_account_db_sql_set_property) }, + { HP_POP(account->db_sql_create, HP_account_db_sql_create) }, + { HP_POP(account->db_sql_remove, HP_account_db_sql_remove) }, + { HP_POP(account->db_sql_save, HP_account_db_sql_save) }, + { HP_POP(account->db_sql_load_num, HP_account_db_sql_load_num) }, + { HP_POP(account->db_sql_load_str, HP_account_db_sql_load_str) }, + { HP_POP(account->db_sql_iterator, HP_account_db_sql_iterator) }, + { HP_POP(account->db_sql_iter_destroy, HP_account_db_sql_iter_destroy) }, + { HP_POP(account->db_sql_iter_next, HP_account_db_sql_iter_next) }, + { HP_POP(account->db_read_inter, HP_account_db_read_inter) }, /* cmdline_interface */ { HP_POP(cmdline->init, HP_cmdline_init) }, { HP_POP(cmdline->final, HP_cmdline_final) }, @@ -67,6 +87,21 @@ struct HookingPointData HookingPoints[] = { /* des_interface */ { HP_POP(des->decrypt_block, HP_des_decrypt_block) }, { HP_POP(des->decrypt, HP_des_decrypt) }, +/* ipban_interface */ + { HP_POP(ipban->init, HP_ipban_init) }, + { HP_POP(ipban->final, HP_ipban_final) }, + { HP_POP(ipban->cleanup, HP_ipban_cleanup) }, + { HP_POP(ipban->config_read_inter, HP_ipban_config_read_inter) }, + { HP_POP(ipban->config_read_connection, HP_ipban_config_read_connection) }, + { HP_POP(ipban->config_read_dynamic, HP_ipban_config_read_dynamic) }, + { HP_POP(ipban->config_read, HP_ipban_config_read) }, + { HP_POP(ipban->check, HP_ipban_check) }, + { HP_POP(ipban->log, HP_ipban_log) }, +/* lchrif_interface */ + { HP_POP(lchrif->server_init, HP_lchrif_server_init) }, + { HP_POP(lchrif->server_destroy, HP_lchrif_server_destroy) }, + { HP_POP(lchrif->server_reset, HP_lchrif_server_reset) }, + { HP_POP(lchrif->on_disconnect, HP_lchrif_on_disconnect) }, /* lclif_interface */ { HP_POP(lclif->init, HP_lclif_init) }, { HP_POP(lclif->final, HP_lclif_final) }, @@ -226,6 +261,14 @@ struct HookingPointData HookingPoints[] = { { HP_POP(login->clear_client_hash_nodes, HP_login_clear_client_hash_nodes) }, { HP_POP(login->config_set_md5hash, HP_login_config_set_md5hash) }, { HP_POP(login->convert_users_to_colors, HP_login_convert_users_to_colors) }, +/* loginlog_interface */ + { HP_POP(loginlog->failedattempts, HP_loginlog_failedattempts) }, + { HP_POP(loginlog->log, HP_loginlog_log) }, + { HP_POP(loginlog->init, HP_loginlog_init) }, + { HP_POP(loginlog->final, HP_loginlog_final) }, + { HP_POP(loginlog->config_read_names, HP_loginlog_config_read_names) }, + { HP_POP(loginlog->config_read_log, HP_loginlog_config_read_log) }, + { HP_POP(loginlog->config_read, HP_loginlog_config_read) }, /* md5_interface */ { HP_POP(md5->string, HP_md5_string) }, { HP_POP(md5->binary, HP_md5_binary) }, diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc index 658ee874d..e432da70d 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc @@ -106,6 +106,516 @@ FILE* HP_HCache_open(const char *file, const char *opt) { } return retVal___; } +/* account_interface */ +struct Sql* HP_account_db_sql_up(AccountDB *self) { + int hIndex = 0; + struct Sql* retVal___ = NULL; + if (HPMHooks.count.HP_account_db_sql_up_pre > 0) { + struct Sql* (*preHookFunc) (AccountDB **self); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_up_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_up_pre[hIndex].func; + retVal___ = preHookFunc(&self); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.db_sql_up(self); + } + if (HPMHooks.count.HP_account_db_sql_up_post > 0) { + struct Sql* (*postHookFunc) (struct Sql* retVal___, AccountDB *self); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_up_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_up_post[hIndex].func; + retVal___ = postHookFunc(retVal___, self); + } + } + return retVal___; +} +void HP_account_mmo_send_accreg2(AccountDB *self, int fd, int account_id, int char_id) { + int hIndex = 0; + if (HPMHooks.count.HP_account_mmo_send_accreg2_pre > 0) { + void (*preHookFunc) (AccountDB **self, int *fd, int *account_id, int *char_id); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_mmo_send_accreg2_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_mmo_send_accreg2_pre[hIndex].func; + preHookFunc(&self, &fd, &account_id, &char_id); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.account.mmo_send_accreg2(self, fd, account_id, char_id); + } + if (HPMHooks.count.HP_account_mmo_send_accreg2_post > 0) { + void (*postHookFunc) (AccountDB *self, int fd, int account_id, int char_id); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_mmo_send_accreg2_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_mmo_send_accreg2_post[hIndex].func; + postHookFunc(self, fd, account_id, char_id); + } + } + return; +} +void HP_account_mmo_save_accreg2(AccountDB *self, int fd, int account_id, int char_id) { + int hIndex = 0; + if (HPMHooks.count.HP_account_mmo_save_accreg2_pre > 0) { + void (*preHookFunc) (AccountDB **self, int *fd, int *account_id, int *char_id); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_mmo_save_accreg2_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_mmo_save_accreg2_pre[hIndex].func; + preHookFunc(&self, &fd, &account_id, &char_id); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.account.mmo_save_accreg2(self, fd, account_id, char_id); + } + if (HPMHooks.count.HP_account_mmo_save_accreg2_post > 0) { + void (*postHookFunc) (AccountDB *self, int fd, int account_id, int char_id); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_mmo_save_accreg2_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_mmo_save_accreg2_post[hIndex].func; + postHookFunc(self, fd, account_id, char_id); + } + } + return; +} +bool HP_account_mmo_auth_fromsql(AccountDB_SQL *db, struct mmo_account *acc, int account_id) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_account_mmo_auth_fromsql_pre > 0) { + bool (*preHookFunc) (AccountDB_SQL **db, struct mmo_account **acc, int *account_id); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_mmo_auth_fromsql_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_mmo_auth_fromsql_pre[hIndex].func; + retVal___ = preHookFunc(&db, &acc, &account_id); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.mmo_auth_fromsql(db, acc, account_id); + } + if (HPMHooks.count.HP_account_mmo_auth_fromsql_post > 0) { + bool (*postHookFunc) (bool retVal___, AccountDB_SQL *db, struct mmo_account *acc, int account_id); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_mmo_auth_fromsql_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_mmo_auth_fromsql_post[hIndex].func; + retVal___ = postHookFunc(retVal___, db, acc, account_id); + } + } + return retVal___; +} +bool HP_account_mmo_auth_tosql(AccountDB_SQL *db, const struct mmo_account *acc, bool is_new) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_account_mmo_auth_tosql_pre > 0) { + bool (*preHookFunc) (AccountDB_SQL **db, const struct mmo_account **acc, bool *is_new); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_mmo_auth_tosql_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_mmo_auth_tosql_pre[hIndex].func; + retVal___ = preHookFunc(&db, &acc, &is_new); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.mmo_auth_tosql(db, acc, is_new); + } + if (HPMHooks.count.HP_account_mmo_auth_tosql_post > 0) { + bool (*postHookFunc) (bool retVal___, AccountDB_SQL *db, const struct mmo_account *acc, bool is_new); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_mmo_auth_tosql_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_mmo_auth_tosql_post[hIndex].func; + retVal___ = postHookFunc(retVal___, db, acc, is_new); + } + } + return retVal___; +} +AccountDB* HP_account_db_sql(void) { + int hIndex = 0; + AccountDB* retVal___ = NULL; + if (HPMHooks.count.HP_account_db_sql_pre > 0) { + AccountDB* (*preHookFunc) (void); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.db_sql(); + } + if (HPMHooks.count.HP_account_db_sql_post > 0) { + AccountDB* (*postHookFunc) (AccountDB* retVal___); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +bool HP_account_db_sql_init(AccountDB *self) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_account_db_sql_init_pre > 0) { + bool (*preHookFunc) (AccountDB **self); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_init_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_init_pre[hIndex].func; + retVal___ = preHookFunc(&self); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.db_sql_init(self); + } + if (HPMHooks.count.HP_account_db_sql_init_post > 0) { + bool (*postHookFunc) (bool retVal___, AccountDB *self); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_init_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_init_post[hIndex].func; + retVal___ = postHookFunc(retVal___, self); + } + } + return retVal___; +} +void HP_account_db_sql_destroy(AccountDB *self) { + int hIndex = 0; + if (HPMHooks.count.HP_account_db_sql_destroy_pre > 0) { + void (*preHookFunc) (AccountDB **self); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_destroy_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_destroy_pre[hIndex].func; + preHookFunc(&self); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.account.db_sql_destroy(self); + } + if (HPMHooks.count.HP_account_db_sql_destroy_post > 0) { + void (*postHookFunc) (AccountDB *self); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_destroy_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_destroy_post[hIndex].func; + postHookFunc(self); + } + } + return; +} +bool HP_account_db_sql_get_property(AccountDB *self, const char *key, char *buf, size_t buflen) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_account_db_sql_get_property_pre > 0) { + bool (*preHookFunc) (AccountDB **self, const char **key, char **buf, size_t *buflen); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_get_property_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_get_property_pre[hIndex].func; + retVal___ = preHookFunc(&self, &key, &buf, &buflen); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.db_sql_get_property(self, key, buf, buflen); + } + if (HPMHooks.count.HP_account_db_sql_get_property_post > 0) { + bool (*postHookFunc) (bool retVal___, AccountDB *self, const char *key, char *buf, size_t buflen); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_get_property_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_get_property_post[hIndex].func; + retVal___ = postHookFunc(retVal___, self, key, buf, buflen); + } + } + return retVal___; +} +bool HP_account_db_sql_set_property(AccountDB *self, struct config_t *config, bool imported) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_account_db_sql_set_property_pre > 0) { + bool (*preHookFunc) (AccountDB **self, struct config_t **config, bool *imported); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_set_property_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_set_property_pre[hIndex].func; + retVal___ = preHookFunc(&self, &config, &imported); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.db_sql_set_property(self, config, imported); + } + if (HPMHooks.count.HP_account_db_sql_set_property_post > 0) { + bool (*postHookFunc) (bool retVal___, AccountDB *self, struct config_t *config, bool imported); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_set_property_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_set_property_post[hIndex].func; + retVal___ = postHookFunc(retVal___, self, config, imported); + } + } + return retVal___; +} +bool HP_account_db_sql_create(AccountDB *self, struct mmo_account *acc) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_account_db_sql_create_pre > 0) { + bool (*preHookFunc) (AccountDB **self, struct mmo_account **acc); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_create_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_create_pre[hIndex].func; + retVal___ = preHookFunc(&self, &acc); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.db_sql_create(self, acc); + } + if (HPMHooks.count.HP_account_db_sql_create_post > 0) { + bool (*postHookFunc) (bool retVal___, AccountDB *self, struct mmo_account *acc); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_create_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_create_post[hIndex].func; + retVal___ = postHookFunc(retVal___, self, acc); + } + } + return retVal___; +} +bool HP_account_db_sql_remove(AccountDB *self, const int account_id) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_account_db_sql_remove_pre > 0) { + bool (*preHookFunc) (AccountDB **self, const int *account_id); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_remove_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_remove_pre[hIndex].func; + retVal___ = preHookFunc(&self, &account_id); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.db_sql_remove(self, account_id); + } + if (HPMHooks.count.HP_account_db_sql_remove_post > 0) { + bool (*postHookFunc) (bool retVal___, AccountDB *self, const int account_id); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_remove_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_remove_post[hIndex].func; + retVal___ = postHookFunc(retVal___, self, account_id); + } + } + return retVal___; +} +bool HP_account_db_sql_save(AccountDB *self, const struct mmo_account *acc) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_account_db_sql_save_pre > 0) { + bool (*preHookFunc) (AccountDB **self, const struct mmo_account **acc); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_save_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_save_pre[hIndex].func; + retVal___ = preHookFunc(&self, &acc); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.db_sql_save(self, acc); + } + if (HPMHooks.count.HP_account_db_sql_save_post > 0) { + bool (*postHookFunc) (bool retVal___, AccountDB *self, const struct mmo_account *acc); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_save_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_save_post[hIndex].func; + retVal___ = postHookFunc(retVal___, self, acc); + } + } + return retVal___; +} +bool HP_account_db_sql_load_num(AccountDB *self, struct mmo_account *acc, const int account_id) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_account_db_sql_load_num_pre > 0) { + bool (*preHookFunc) (AccountDB **self, struct mmo_account **acc, const int *account_id); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_load_num_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_load_num_pre[hIndex].func; + retVal___ = preHookFunc(&self, &acc, &account_id); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.db_sql_load_num(self, acc, account_id); + } + if (HPMHooks.count.HP_account_db_sql_load_num_post > 0) { + bool (*postHookFunc) (bool retVal___, AccountDB *self, struct mmo_account *acc, const int account_id); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_load_num_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_load_num_post[hIndex].func; + retVal___ = postHookFunc(retVal___, self, acc, account_id); + } + } + return retVal___; +} +bool HP_account_db_sql_load_str(AccountDB *self, struct mmo_account *acc, const char *userid) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_account_db_sql_load_str_pre > 0) { + bool (*preHookFunc) (AccountDB **self, struct mmo_account **acc, const char **userid); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_load_str_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_load_str_pre[hIndex].func; + retVal___ = preHookFunc(&self, &acc, &userid); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.db_sql_load_str(self, acc, userid); + } + if (HPMHooks.count.HP_account_db_sql_load_str_post > 0) { + bool (*postHookFunc) (bool retVal___, AccountDB *self, struct mmo_account *acc, const char *userid); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_load_str_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_load_str_post[hIndex].func; + retVal___ = postHookFunc(retVal___, self, acc, userid); + } + } + return retVal___; +} +AccountDBIterator* HP_account_db_sql_iterator(AccountDB *self) { + int hIndex = 0; + AccountDBIterator* retVal___ = NULL; + if (HPMHooks.count.HP_account_db_sql_iterator_pre > 0) { + AccountDBIterator* (*preHookFunc) (AccountDB **self); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_iterator_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_iterator_pre[hIndex].func; + retVal___ = preHookFunc(&self); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.db_sql_iterator(self); + } + if (HPMHooks.count.HP_account_db_sql_iterator_post > 0) { + AccountDBIterator* (*postHookFunc) (AccountDBIterator* retVal___, AccountDB *self); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_iterator_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_iterator_post[hIndex].func; + retVal___ = postHookFunc(retVal___, self); + } + } + return retVal___; +} +void HP_account_db_sql_iter_destroy(AccountDBIterator *self) { + int hIndex = 0; + if (HPMHooks.count.HP_account_db_sql_iter_destroy_pre > 0) { + void (*preHookFunc) (AccountDBIterator **self); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_iter_destroy_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_iter_destroy_pre[hIndex].func; + preHookFunc(&self); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.account.db_sql_iter_destroy(self); + } + if (HPMHooks.count.HP_account_db_sql_iter_destroy_post > 0) { + void (*postHookFunc) (AccountDBIterator *self); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_iter_destroy_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_iter_destroy_post[hIndex].func; + postHookFunc(self); + } + } + return; +} +bool HP_account_db_sql_iter_next(AccountDBIterator *self, struct mmo_account *acc) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_account_db_sql_iter_next_pre > 0) { + bool (*preHookFunc) (AccountDBIterator **self, struct mmo_account **acc); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_iter_next_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_sql_iter_next_pre[hIndex].func; + retVal___ = preHookFunc(&self, &acc); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.db_sql_iter_next(self, acc); + } + if (HPMHooks.count.HP_account_db_sql_iter_next_post > 0) { + bool (*postHookFunc) (bool retVal___, AccountDBIterator *self, struct mmo_account *acc); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_sql_iter_next_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_sql_iter_next_post[hIndex].func; + retVal___ = postHookFunc(retVal___, self, acc); + } + } + return retVal___; +} +bool HP_account_db_read_inter(AccountDB_SQL *db, const char *filename, bool imported) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_account_db_read_inter_pre > 0) { + bool (*preHookFunc) (AccountDB_SQL **db, const char **filename, bool *imported); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_read_inter_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_account_db_read_inter_pre[hIndex].func; + retVal___ = preHookFunc(&db, &filename, &imported); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.account.db_read_inter(db, filename, imported); + } + if (HPMHooks.count.HP_account_db_read_inter_post > 0) { + bool (*postHookFunc) (bool retVal___, AccountDB_SQL *db, const char *filename, bool imported); + for (hIndex = 0; hIndex < HPMHooks.count.HP_account_db_read_inter_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_account_db_read_inter_post[hIndex].func; + retVal___ = postHookFunc(retVal___, db, filename, imported); + } + } + return retVal___; +} /* cmdline_interface */ void HP_cmdline_init(void) { int hIndex = 0; @@ -964,6 +1474,352 @@ void HP_des_decrypt(unsigned char *data, size_t size) { } return; } +/* ipban_interface */ +void HP_ipban_init(void) { + int hIndex = 0; + if (HPMHooks.count.HP_ipban_init_pre > 0) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_init_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_ipban_init_pre[hIndex].func; + preHookFunc(); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.ipban.init(); + } + if (HPMHooks.count.HP_ipban_init_post > 0) { + void (*postHookFunc) (void); + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_init_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_ipban_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_ipban_final(void) { + int hIndex = 0; + if (HPMHooks.count.HP_ipban_final_pre > 0) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_final_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_ipban_final_pre[hIndex].func; + preHookFunc(); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.ipban.final(); + } + if (HPMHooks.count.HP_ipban_final_post > 0) { + void (*postHookFunc) (void); + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_final_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_ipban_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +int HP_ipban_cleanup(int tid, int64 tick, int id, intptr_t data) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_ipban_cleanup_pre > 0) { + int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_cleanup_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_ipban_cleanup_pre[hIndex].func; + retVal___ = preHookFunc(&tid, &tick, &id, &data); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.ipban.cleanup(tid, tick, id, data); + } + if (HPMHooks.count.HP_ipban_cleanup_post > 0) { + int (*postHookFunc) (int retVal___, int tid, int64 tick, int id, intptr_t data); + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_cleanup_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_ipban_cleanup_post[hIndex].func; + retVal___ = postHookFunc(retVal___, tid, tick, id, data); + } + } + return retVal___; +} +bool HP_ipban_config_read_inter(const char *filename, bool imported) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_ipban_config_read_inter_pre > 0) { + bool (*preHookFunc) (const char **filename, bool *imported); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_config_read_inter_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_ipban_config_read_inter_pre[hIndex].func; + retVal___ = preHookFunc(&filename, &imported); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.ipban.config_read_inter(filename, imported); + } + if (HPMHooks.count.HP_ipban_config_read_inter_post > 0) { + bool (*postHookFunc) (bool retVal___, const char *filename, bool imported); + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_config_read_inter_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_ipban_config_read_inter_post[hIndex].func; + retVal___ = postHookFunc(retVal___, filename, imported); + } + } + return retVal___; +} +bool HP_ipban_config_read_connection(const char *filename, struct config_t *config, bool imported) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_ipban_config_read_connection_pre > 0) { + bool (*preHookFunc) (const char **filename, struct config_t **config, bool *imported); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_config_read_connection_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_ipban_config_read_connection_pre[hIndex].func; + retVal___ = preHookFunc(&filename, &config, &imported); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.ipban.config_read_connection(filename, config, imported); + } + if (HPMHooks.count.HP_ipban_config_read_connection_post > 0) { + bool (*postHookFunc) (bool retVal___, const char *filename, struct config_t *config, bool imported); + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_config_read_connection_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_ipban_config_read_connection_post[hIndex].func; + retVal___ = postHookFunc(retVal___, filename, config, imported); + } + } + return retVal___; +} +bool HP_ipban_config_read_dynamic(const char *filename, struct config_t *config, bool imported) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_ipban_config_read_dynamic_pre > 0) { + bool (*preHookFunc) (const char **filename, struct config_t **config, bool *imported); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_config_read_dynamic_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_ipban_config_read_dynamic_pre[hIndex].func; + retVal___ = preHookFunc(&filename, &config, &imported); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.ipban.config_read_dynamic(filename, config, imported); + } + if (HPMHooks.count.HP_ipban_config_read_dynamic_post > 0) { + bool (*postHookFunc) (bool retVal___, const char *filename, struct config_t *config, bool imported); + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_config_read_dynamic_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_ipban_config_read_dynamic_post[hIndex].func; + retVal___ = postHookFunc(retVal___, filename, config, imported); + } + } + return retVal___; +} +bool HP_ipban_config_read(const char *filename, struct config_t *config, bool imported) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_ipban_config_read_pre > 0) { + bool (*preHookFunc) (const char **filename, struct config_t **config, bool *imported); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_config_read_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_ipban_config_read_pre[hIndex].func; + retVal___ = preHookFunc(&filename, &config, &imported); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.ipban.config_read(filename, config, imported); + } + if (HPMHooks.count.HP_ipban_config_read_post > 0) { + bool (*postHookFunc) (bool retVal___, const char *filename, struct config_t *config, bool imported); + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_config_read_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_ipban_config_read_post[hIndex].func; + retVal___ = postHookFunc(retVal___, filename, config, imported); + } + } + return retVal___; +} +bool HP_ipban_check(uint32 ip) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_ipban_check_pre > 0) { + bool (*preHookFunc) (uint32 *ip); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_check_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_ipban_check_pre[hIndex].func; + retVal___ = preHookFunc(&ip); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.ipban.check(ip); + } + if (HPMHooks.count.HP_ipban_check_post > 0) { + bool (*postHookFunc) (bool retVal___, uint32 ip); + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_check_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_ipban_check_post[hIndex].func; + retVal___ = postHookFunc(retVal___, ip); + } + } + return retVal___; +} +void HP_ipban_log(uint32 ip) { + int hIndex = 0; + if (HPMHooks.count.HP_ipban_log_pre > 0) { + void (*preHookFunc) (uint32 *ip); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_log_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_ipban_log_pre[hIndex].func; + preHookFunc(&ip); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.ipban.log(ip); + } + if (HPMHooks.count.HP_ipban_log_post > 0) { + void (*postHookFunc) (uint32 ip); + for (hIndex = 0; hIndex < HPMHooks.count.HP_ipban_log_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_ipban_log_post[hIndex].func; + postHookFunc(ip); + } + } + return; +} +/* lchrif_interface */ +void HP_lchrif_server_init(int id) { + int hIndex = 0; + if (HPMHooks.count.HP_lchrif_server_init_pre > 0) { + void (*preHookFunc) (int *id); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_lchrif_server_init_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_lchrif_server_init_pre[hIndex].func; + preHookFunc(&id); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.lchrif.server_init(id); + } + if (HPMHooks.count.HP_lchrif_server_init_post > 0) { + void (*postHookFunc) (int id); + for (hIndex = 0; hIndex < HPMHooks.count.HP_lchrif_server_init_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_lchrif_server_init_post[hIndex].func; + postHookFunc(id); + } + } + return; +} +void HP_lchrif_server_destroy(int id) { + int hIndex = 0; + if (HPMHooks.count.HP_lchrif_server_destroy_pre > 0) { + void (*preHookFunc) (int *id); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_lchrif_server_destroy_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_lchrif_server_destroy_pre[hIndex].func; + preHookFunc(&id); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.lchrif.server_destroy(id); + } + if (HPMHooks.count.HP_lchrif_server_destroy_post > 0) { + void (*postHookFunc) (int id); + for (hIndex = 0; hIndex < HPMHooks.count.HP_lchrif_server_destroy_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_lchrif_server_destroy_post[hIndex].func; + postHookFunc(id); + } + } + return; +} +void HP_lchrif_server_reset(int id) { + int hIndex = 0; + if (HPMHooks.count.HP_lchrif_server_reset_pre > 0) { + void (*preHookFunc) (int *id); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_lchrif_server_reset_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_lchrif_server_reset_pre[hIndex].func; + preHookFunc(&id); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.lchrif.server_reset(id); + } + if (HPMHooks.count.HP_lchrif_server_reset_post > 0) { + void (*postHookFunc) (int id); + for (hIndex = 0; hIndex < HPMHooks.count.HP_lchrif_server_reset_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_lchrif_server_reset_post[hIndex].func; + postHookFunc(id); + } + } + return; +} +void HP_lchrif_on_disconnect(int id) { + int hIndex = 0; + if (HPMHooks.count.HP_lchrif_on_disconnect_pre > 0) { + void (*preHookFunc) (int *id); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_lchrif_on_disconnect_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_lchrif_on_disconnect_pre[hIndex].func; + preHookFunc(&id); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.lchrif.on_disconnect(id); + } + if (HPMHooks.count.HP_lchrif_on_disconnect_post > 0) { + void (*postHookFunc) (int id); + for (hIndex = 0; hIndex < HPMHooks.count.HP_lchrif_on_disconnect_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_lchrif_on_disconnect_post[hIndex].func; + postHookFunc(id); + } + } + return; +} /* lclif_interface */ void HP_lclif_init(void) { int hIndex = 0; @@ -5117,6 +5973,195 @@ uint16 HP_login_convert_users_to_colors(uint16 users) { } return retVal___; } +/* loginlog_interface */ +unsigned long HP_loginlog_failedattempts(uint32 ip, unsigned int minutes) { + int hIndex = 0; + unsigned long retVal___ = 0; + if (HPMHooks.count.HP_loginlog_failedattempts_pre > 0) { + unsigned long (*preHookFunc) (uint32 *ip, unsigned int *minutes); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_failedattempts_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_loginlog_failedattempts_pre[hIndex].func; + retVal___ = preHookFunc(&ip, &minutes); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.loginlog.failedattempts(ip, minutes); + } + if (HPMHooks.count.HP_loginlog_failedattempts_post > 0) { + unsigned long (*postHookFunc) (unsigned long retVal___, uint32 ip, unsigned int minutes); + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_failedattempts_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_loginlog_failedattempts_post[hIndex].func; + retVal___ = postHookFunc(retVal___, ip, minutes); + } + } + return retVal___; +} +void HP_loginlog_log(uint32 ip, const char *username, int rcode, const char *message) { + int hIndex = 0; + if (HPMHooks.count.HP_loginlog_log_pre > 0) { + void (*preHookFunc) (uint32 *ip, const char **username, int *rcode, const char **message); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_log_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_loginlog_log_pre[hIndex].func; + preHookFunc(&ip, &username, &rcode, &message); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.loginlog.log(ip, username, rcode, message); + } + if (HPMHooks.count.HP_loginlog_log_post > 0) { + void (*postHookFunc) (uint32 ip, const char *username, int rcode, const char *message); + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_log_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_loginlog_log_post[hIndex].func; + postHookFunc(ip, username, rcode, message); + } + } + return; +} +bool HP_loginlog_init(void) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_loginlog_init_pre > 0) { + bool (*preHookFunc) (void); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_init_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_loginlog_init_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.loginlog.init(); + } + if (HPMHooks.count.HP_loginlog_init_post > 0) { + bool (*postHookFunc) (bool retVal___); + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_init_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_loginlog_init_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +bool HP_loginlog_final(void) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_loginlog_final_pre > 0) { + bool (*preHookFunc) (void); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_final_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_loginlog_final_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.loginlog.final(); + } + if (HPMHooks.count.HP_loginlog_final_post > 0) { + bool (*postHookFunc) (bool retVal___); + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_final_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_loginlog_final_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +bool HP_loginlog_config_read_names(const char *filename, struct config_t *config, bool imported) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_loginlog_config_read_names_pre > 0) { + bool (*preHookFunc) (const char **filename, struct config_t **config, bool *imported); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_config_read_names_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_loginlog_config_read_names_pre[hIndex].func; + retVal___ = preHookFunc(&filename, &config, &imported); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.loginlog.config_read_names(filename, config, imported); + } + if (HPMHooks.count.HP_loginlog_config_read_names_post > 0) { + bool (*postHookFunc) (bool retVal___, const char *filename, struct config_t *config, bool imported); + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_config_read_names_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_loginlog_config_read_names_post[hIndex].func; + retVal___ = postHookFunc(retVal___, filename, config, imported); + } + } + return retVal___; +} +bool HP_loginlog_config_read_log(const char *filename, struct config_t *config, bool imported) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_loginlog_config_read_log_pre > 0) { + bool (*preHookFunc) (const char **filename, struct config_t **config, bool *imported); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_config_read_log_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_loginlog_config_read_log_pre[hIndex].func; + retVal___ = preHookFunc(&filename, &config, &imported); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.loginlog.config_read_log(filename, config, imported); + } + if (HPMHooks.count.HP_loginlog_config_read_log_post > 0) { + bool (*postHookFunc) (bool retVal___, const char *filename, struct config_t *config, bool imported); + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_config_read_log_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_loginlog_config_read_log_post[hIndex].func; + retVal___ = postHookFunc(retVal___, filename, config, imported); + } + } + return retVal___; +} +bool HP_loginlog_config_read(const char *filename, bool imported) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_loginlog_config_read_pre > 0) { + bool (*preHookFunc) (const char **filename, bool *imported); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_config_read_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_loginlog_config_read_pre[hIndex].func; + retVal___ = preHookFunc(&filename, &imported); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.loginlog.config_read(filename, imported); + } + if (HPMHooks.count.HP_loginlog_config_read_post > 0) { + bool (*postHookFunc) (bool retVal___, const char *filename, bool imported); + for (hIndex = 0; hIndex < HPMHooks.count.HP_loginlog_config_read_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_loginlog_config_read_post[hIndex].func; + retVal___ = postHookFunc(retVal___, filename, imported); + } + } + return retVal___; +} /* md5_interface */ void HP_md5_string(const char *string, char *output) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_login.sources.inc b/src/plugins/HPMHooking/HPMHooking_login.sources.inc index 55ced3025..78c506043 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.sources.inc @@ -26,15 +26,19 @@ /* GENERATED FILE DO NOT EDIT */ HPMHooks.source.HCache = *HCache; +HPMHooks.source.account = *account; HPMHooks.source.cmdline = *cmdline; HPMHooks.source.console = *console; HPMHooks.source.core = *core; HPMHooks.source.DB = *DB; HPMHooks.source.des = *des; +HPMHooks.source.ipban = *ipban; +HPMHooks.source.lchrif = *lchrif; HPMHooks.source.lclif = *lclif; HPMHooks.source.PRIV__lclif = *lclif->p; HPMHooks.source.libconfig = *libconfig; HPMHooks.source.login = *login; +HPMHooks.source.loginlog = *loginlog; HPMHooks.source.md5 = *md5; HPMHooks.source.mutex = *mutex; HPMHooks.source.nullpo = *nullpo; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index f057b34d8..7e9d5589b 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -504,6 +504,60 @@ struct { struct HPMHookPoint *HP_chrif_save_scdata_single_post; struct HPMHookPoint *HP_chrif_del_scdata_single_pre; struct HPMHookPoint *HP_chrif_del_scdata_single_post; + struct HPMHookPoint *HP_clan_init_pre; + struct HPMHookPoint *HP_clan_init_post; + struct HPMHookPoint *HP_clan_final_pre; + struct HPMHookPoint *HP_clan_final_post; + struct HPMHookPoint *HP_clan_config_read_pre; + struct HPMHookPoint *HP_clan_config_read_post; + struct HPMHookPoint *HP_clan_config_read_additional_settings_pre; + struct HPMHookPoint *HP_clan_config_read_additional_settings_post; + struct HPMHookPoint *HP_clan_read_db_pre; + struct HPMHookPoint *HP_clan_read_db_post; + struct HPMHookPoint *HP_clan_read_db_sub_pre; + struct HPMHookPoint *HP_clan_read_db_sub_post; + struct HPMHookPoint *HP_clan_read_db_additional_fields_pre; + struct HPMHookPoint *HP_clan_read_db_additional_fields_post; + struct HPMHookPoint *HP_clan_read_buffs_pre; + struct HPMHookPoint *HP_clan_read_buffs_post; + struct HPMHookPoint *HP_clan_search_pre; + struct HPMHookPoint *HP_clan_search_post; + struct HPMHookPoint *HP_clan_searchname_pre; + struct HPMHookPoint *HP_clan_searchname_post; + struct HPMHookPoint *HP_clan_getonlinesd_pre; + struct HPMHookPoint *HP_clan_getonlinesd_post; + struct HPMHookPoint *HP_clan_getindex_pre; + struct HPMHookPoint *HP_clan_getindex_post; + struct HPMHookPoint *HP_clan_join_pre; + struct HPMHookPoint *HP_clan_join_post; + struct HPMHookPoint *HP_clan_member_online_pre; + struct HPMHookPoint *HP_clan_member_online_post; + struct HPMHookPoint *HP_clan_leave_pre; + struct HPMHookPoint *HP_clan_leave_post; + struct HPMHookPoint *HP_clan_send_message_pre; + struct HPMHookPoint *HP_clan_send_message_post; + struct HPMHookPoint *HP_clan_recv_message_pre; + struct HPMHookPoint *HP_clan_recv_message_post; + struct HPMHookPoint *HP_clan_member_offline_pre; + struct HPMHookPoint *HP_clan_member_offline_post; + struct HPMHookPoint *HP_clan_set_constants_pre; + struct HPMHookPoint *HP_clan_set_constants_post; + struct HPMHookPoint *HP_clan_get_id_pre; + struct HPMHookPoint *HP_clan_get_id_post; + struct HPMHookPoint *HP_clan_buff_start_pre; + struct HPMHookPoint *HP_clan_buff_start_post; + struct HPMHookPoint *HP_clan_buff_end_pre; + struct HPMHookPoint *HP_clan_buff_end_post; + struct HPMHookPoint *HP_clan_reload_pre; + struct HPMHookPoint *HP_clan_reload_post; + struct HPMHookPoint *HP_clan_rejoin_pre; + struct HPMHookPoint *HP_clan_rejoin_post; + struct HPMHookPoint *HP_clan_inactivity_kick_pre; + struct HPMHookPoint *HP_clan_inactivity_kick_post; + struct HPMHookPoint *HP_clan_request_kickoffline_pre; + struct HPMHookPoint *HP_clan_request_kickoffline_post; + struct HPMHookPoint *HP_clan_request_membercount_pre; + struct HPMHookPoint *HP_clan_request_membercount_post; struct HPMHookPoint *HP_clif_init_pre; struct HPMHookPoint *HP_clif_init_post; struct HPMHookPoint *HP_clif_final_pre; @@ -1934,6 +1988,16 @@ struct { struct HPMHookPoint *HP_clif_rodex_icon_post; struct HPMHookPoint *HP_clif_skill_scale_pre; struct HPMHookPoint *HP_clif_skill_scale_post; + struct HPMHookPoint *HP_clif_clan_basicinfo_pre; + struct HPMHookPoint *HP_clif_clan_basicinfo_post; + struct HPMHookPoint *HP_clif_clan_onlinecount_pre; + struct HPMHookPoint *HP_clif_clan_onlinecount_post; + struct HPMHookPoint *HP_clif_clan_leave_pre; + struct HPMHookPoint *HP_clif_clan_leave_post; + struct HPMHookPoint *HP_clif_clan_message_pre; + struct HPMHookPoint *HP_clif_clan_message_post; + struct HPMHookPoint *HP_clif_pClanMessage_pre; + struct HPMHookPoint *HP_clif_pClanMessage_post; struct HPMHookPoint *HP_cmdline_init_pre; struct HPMHookPoint *HP_cmdline_init_post; struct HPMHookPoint *HP_cmdline_final_pre; @@ -2576,6 +2640,10 @@ struct { struct HPMHookPoint *HP_intif_rodex_sendmail_post; struct HPMHookPoint *HP_intif_rodex_checkname_pre; struct HPMHookPoint *HP_intif_rodex_checkname_post; + struct HPMHookPoint *HP_intif_clan_kickoffline_pre; + struct HPMHookPoint *HP_intif_clan_kickoffline_post; + struct HPMHookPoint *HP_intif_clan_membercount_pre; + struct HPMHookPoint *HP_intif_clan_membercount_post; struct HPMHookPoint *HP_intif_request_accinfo_pre; struct HPMHookPoint *HP_intif_request_accinfo_post; struct HPMHookPoint *HP_intif_CheckForCharServer_pre; @@ -2716,6 +2784,8 @@ struct { struct HPMHookPoint *HP_intif_pRodexSendMail_post; struct HPMHookPoint *HP_intif_pRodexCheckName_pre; struct HPMHookPoint *HP_intif_pRodexCheckName_post; + struct HPMHookPoint *HP_intif_pRecvClanMemberAction_pre; + struct HPMHookPoint *HP_intif_pRecvClanMemberAction_post; struct HPMHookPoint *HP_ircbot_init_pre; struct HPMHookPoint *HP_ircbot_init_post; struct HPMHookPoint *HP_ircbot_final_pre; @@ -6713,6 +6783,60 @@ struct { int HP_chrif_save_scdata_single_post; int HP_chrif_del_scdata_single_pre; int HP_chrif_del_scdata_single_post; + int HP_clan_init_pre; + int HP_clan_init_post; + int HP_clan_final_pre; + int HP_clan_final_post; + int HP_clan_config_read_pre; + int HP_clan_config_read_post; + int HP_clan_config_read_additional_settings_pre; + int HP_clan_config_read_additional_settings_post; + int HP_clan_read_db_pre; + int HP_clan_read_db_post; + int HP_clan_read_db_sub_pre; + int HP_clan_read_db_sub_post; + int HP_clan_read_db_additional_fields_pre; + int HP_clan_read_db_additional_fields_post; + int HP_clan_read_buffs_pre; + int HP_clan_read_buffs_post; + int HP_clan_search_pre; + int HP_clan_search_post; + int HP_clan_searchname_pre; + int HP_clan_searchname_post; + int HP_clan_getonlinesd_pre; + int HP_clan_getonlinesd_post; + int HP_clan_getindex_pre; + int HP_clan_getindex_post; + int HP_clan_join_pre; + int HP_clan_join_post; + int HP_clan_member_online_pre; + int HP_clan_member_online_post; + int HP_clan_leave_pre; + int HP_clan_leave_post; + int HP_clan_send_message_pre; + int HP_clan_send_message_post; + int HP_clan_recv_message_pre; + int HP_clan_recv_message_post; + int HP_clan_member_offline_pre; + int HP_clan_member_offline_post; + int HP_clan_set_constants_pre; + int HP_clan_set_constants_post; + int HP_clan_get_id_pre; + int HP_clan_get_id_post; + int HP_clan_buff_start_pre; + int HP_clan_buff_start_post; + int HP_clan_buff_end_pre; + int HP_clan_buff_end_post; + int HP_clan_reload_pre; + int HP_clan_reload_post; + int HP_clan_rejoin_pre; + int HP_clan_rejoin_post; + int HP_clan_inactivity_kick_pre; + int HP_clan_inactivity_kick_post; + int HP_clan_request_kickoffline_pre; + int HP_clan_request_kickoffline_post; + int HP_clan_request_membercount_pre; + int HP_clan_request_membercount_post; int HP_clif_init_pre; int HP_clif_init_post; int HP_clif_final_pre; @@ -8143,6 +8267,16 @@ struct { int HP_clif_rodex_icon_post; int HP_clif_skill_scale_pre; int HP_clif_skill_scale_post; + int HP_clif_clan_basicinfo_pre; + int HP_clif_clan_basicinfo_post; + int HP_clif_clan_onlinecount_pre; + int HP_clif_clan_onlinecount_post; + int HP_clif_clan_leave_pre; + int HP_clif_clan_leave_post; + int HP_clif_clan_message_pre; + int HP_clif_clan_message_post; + int HP_clif_pClanMessage_pre; + int HP_clif_pClanMessage_post; int HP_cmdline_init_pre; int HP_cmdline_init_post; int HP_cmdline_final_pre; @@ -8785,6 +8919,10 @@ struct { int HP_intif_rodex_sendmail_post; int HP_intif_rodex_checkname_pre; int HP_intif_rodex_checkname_post; + int HP_intif_clan_kickoffline_pre; + int HP_intif_clan_kickoffline_post; + int HP_intif_clan_membercount_pre; + int HP_intif_clan_membercount_post; int HP_intif_request_accinfo_pre; int HP_intif_request_accinfo_post; int HP_intif_CheckForCharServer_pre; @@ -8925,6 +9063,8 @@ struct { int HP_intif_pRodexSendMail_post; int HP_intif_pRodexCheckName_pre; int HP_intif_pRodexCheckName_post; + int HP_intif_pRecvClanMemberAction_pre; + int HP_intif_pRecvClanMemberAction_post; int HP_ircbot_init_pre; int HP_ircbot_init_post; int HP_ircbot_final_pre; @@ -12452,6 +12592,7 @@ struct { struct channel_interface channel; struct chat_interface chat; struct chrif_interface chrif; + struct clan_interface clan; struct clif_interface clif; struct cmdline_interface cmdline; struct console_interface console; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 6a27f3d94..f023731aa 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -273,6 +273,34 @@ struct HookingPointData HookingPoints[] = { { HP_POP(chrif->parse, HP_chrif_parse) }, { HP_POP(chrif->save_scdata_single, HP_chrif_save_scdata_single) }, { HP_POP(chrif->del_scdata_single, HP_chrif_del_scdata_single) }, +/* clan_interface */ + { HP_POP(clan->init, HP_clan_init) }, + { HP_POP(clan->final, HP_clan_final) }, + { HP_POP(clan->config_read, HP_clan_config_read) }, + { HP_POP(clan->config_read_additional_settings, HP_clan_config_read_additional_settings) }, + { HP_POP(clan->read_db, HP_clan_read_db) }, + { HP_POP(clan->read_db_sub, HP_clan_read_db_sub) }, + { HP_POP(clan->read_db_additional_fields, HP_clan_read_db_additional_fields) }, + { HP_POP(clan->read_buffs, HP_clan_read_buffs) }, + { HP_POP(clan->search, HP_clan_search) }, + { HP_POP(clan->searchname, HP_clan_searchname) }, + { HP_POP(clan->getonlinesd, HP_clan_getonlinesd) }, + { HP_POP(clan->getindex, HP_clan_getindex) }, + { HP_POP(clan->join, HP_clan_join) }, + { HP_POP(clan->member_online, HP_clan_member_online) }, + { HP_POP(clan->leave, HP_clan_leave) }, + { HP_POP(clan->send_message, HP_clan_send_message) }, + { HP_POP(clan->recv_message, HP_clan_recv_message) }, + { HP_POP(clan->member_offline, HP_clan_member_offline) }, + { HP_POP(clan->set_constants, HP_clan_set_constants) }, + { HP_POP(clan->get_id, HP_clan_get_id) }, + { HP_POP(clan->buff_start, HP_clan_buff_start) }, + { HP_POP(clan->buff_end, HP_clan_buff_end) }, + { HP_POP(clan->reload, HP_clan_reload) }, + { HP_POP(clan->rejoin, HP_clan_rejoin) }, + { HP_POP(clan->inactivity_kick, HP_clan_inactivity_kick) }, + { HP_POP(clan->request_kickoffline, HP_clan_request_kickoffline) }, + { HP_POP(clan->request_membercount, HP_clan_request_membercount) }, /* clif_interface */ { HP_POP(clif->init, HP_clif_init) }, { HP_POP(clif->final, HP_clif_final) }, @@ -989,6 +1017,11 @@ struct HookingPointData HookingPoints[] = { { HP_POP(clif->rodex_request_items, HP_clif_rodex_request_items) }, { HP_POP(clif->rodex_icon, HP_clif_rodex_icon) }, { HP_POP(clif->skill_scale, HP_clif_skill_scale) }, + { HP_POP(clif->clan_basicinfo, HP_clif_clan_basicinfo) }, + { HP_POP(clif->clan_onlinecount, HP_clif_clan_onlinecount) }, + { HP_POP(clif->clan_leave, HP_clif_clan_leave) }, + { HP_POP(clif->clan_message, HP_clif_clan_message) }, + { HP_POP(clif->pClanMessage, HP_clif_pClanMessage) }, /* cmdline_interface */ { HP_POP(cmdline->init, HP_cmdline_init) }, { HP_POP(cmdline->final, HP_cmdline_final) }, @@ -1323,6 +1356,8 @@ struct HookingPointData HookingPoints[] = { { HP_POP(intif->rodex_updatemail, HP_intif_rodex_updatemail) }, { HP_POP(intif->rodex_sendmail, HP_intif_rodex_sendmail) }, { HP_POP(intif->rodex_checkname, HP_intif_rodex_checkname) }, + { HP_POP(intif->clan_kickoffline, HP_intif_clan_kickoffline) }, + { HP_POP(intif->clan_membercount, HP_intif_clan_membercount) }, { HP_POP(intif->request_accinfo, HP_intif_request_accinfo) }, { HP_POP(intif->CheckForCharServer, HP_intif_CheckForCharServer) }, { HP_POP(intif->pWisMessage, HP_intif_pWisMessage) }, @@ -1393,6 +1428,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(intif->pRodexHasNew, HP_intif_pRodexHasNew) }, { HP_POP(intif->pRodexSendMail, HP_intif_pRodexSendMail) }, { HP_POP(intif->pRodexCheckName, HP_intif_pRodexCheckName) }, + { HP_POP(intif->pRecvClanMemberAction, HP_intif_pRecvClanMemberAction) }, /* irc_bot_interface */ { HP_POP(ircbot->init, HP_ircbot_init) }, { HP_POP(ircbot->final, HP_ircbot_final) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 5b0ae00a7..467c57dd9 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -6495,6 +6495,729 @@ void HP_chrif_del_scdata_single(int account_id, int char_id, short type) { } return; } +/* clan_interface */ +void HP_clan_init(bool minimal) { + int hIndex = 0; + if (HPMHooks.count.HP_clan_init_pre > 0) { + void (*preHookFunc) (bool *minimal); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_init_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_init_pre[hIndex].func; + preHookFunc(&minimal); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clan.init(minimal); + } + if (HPMHooks.count.HP_clan_init_post > 0) { + void (*postHookFunc) (bool minimal); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_init_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_init_post[hIndex].func; + postHookFunc(minimal); + } + } + return; +} +void HP_clan_final(void) { + int hIndex = 0; + if (HPMHooks.count.HP_clan_final_pre > 0) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_final_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_final_pre[hIndex].func; + preHookFunc(); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clan.final(); + } + if (HPMHooks.count.HP_clan_final_post > 0) { + void (*postHookFunc) (void); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_final_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +bool HP_clan_config_read(bool reload) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_clan_config_read_pre > 0) { + bool (*preHookFunc) (bool *reload); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_config_read_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_config_read_pre[hIndex].func; + retVal___ = preHookFunc(&reload); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clan.config_read(reload); + } + if (HPMHooks.count.HP_clan_config_read_post > 0) { + bool (*postHookFunc) (bool retVal___, bool reload); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_config_read_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_config_read_post[hIndex].func; + retVal___ = postHookFunc(retVal___, reload); + } + } + return retVal___; +} +void HP_clan_config_read_additional_settings(struct config_setting_t *settings, const char *source) { + int hIndex = 0; + if (HPMHooks.count.HP_clan_config_read_additional_settings_pre > 0) { + void (*preHookFunc) (struct config_setting_t **settings, const char **source); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_config_read_additional_settings_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_config_read_additional_settings_pre[hIndex].func; + preHookFunc(&settings, &source); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clan.config_read_additional_settings(settings, source); + } + if (HPMHooks.count.HP_clan_config_read_additional_settings_post > 0) { + void (*postHookFunc) (struct config_setting_t *settings, const char *source); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_config_read_additional_settings_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_config_read_additional_settings_post[hIndex].func; + postHookFunc(settings, source); + } + } + return; +} +void HP_clan_read_db(struct config_setting_t *settings, const char *source, bool reload) { + int hIndex = 0; + if (HPMHooks.count.HP_clan_read_db_pre > 0) { + void (*preHookFunc) (struct config_setting_t **settings, const char **source, bool *reload); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_read_db_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_read_db_pre[hIndex].func; + preHookFunc(&settings, &source, &reload); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clan.read_db(settings, source, reload); + } + if (HPMHooks.count.HP_clan_read_db_post > 0) { + void (*postHookFunc) (struct config_setting_t *settings, const char *source, bool reload); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_read_db_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_read_db_post[hIndex].func; + postHookFunc(settings, source, reload); + } + } + return; +} +int HP_clan_read_db_sub(struct config_setting_t *settings, const char *source, bool reload) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_clan_read_db_sub_pre > 0) { + int (*preHookFunc) (struct config_setting_t **settings, const char **source, bool *reload); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_read_db_sub_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_read_db_sub_pre[hIndex].func; + retVal___ = preHookFunc(&settings, &source, &reload); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clan.read_db_sub(settings, source, reload); + } + if (HPMHooks.count.HP_clan_read_db_sub_post > 0) { + int (*postHookFunc) (int retVal___, struct config_setting_t *settings, const char *source, bool reload); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_read_db_sub_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_read_db_sub_post[hIndex].func; + retVal___ = postHookFunc(retVal___, settings, source, reload); + } + } + return retVal___; +} +void HP_clan_read_db_additional_fields(struct clan *entry, struct config_setting_t *t, int n, const char *source) { + int hIndex = 0; + if (HPMHooks.count.HP_clan_read_db_additional_fields_pre > 0) { + void (*preHookFunc) (struct clan **entry, struct config_setting_t **t, int *n, const char **source); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_read_db_additional_fields_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_read_db_additional_fields_pre[hIndex].func; + preHookFunc(&entry, &t, &n, &source); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clan.read_db_additional_fields(entry, t, n, source); + } + if (HPMHooks.count.HP_clan_read_db_additional_fields_post > 0) { + void (*postHookFunc) (struct clan *entry, struct config_setting_t *t, int n, const char *source); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_read_db_additional_fields_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_read_db_additional_fields_post[hIndex].func; + postHookFunc(entry, t, n, source); + } + } + return; +} +void HP_clan_read_buffs(struct clan *c, struct config_setting_t *buff, const char *source) { + int hIndex = 0; + if (HPMHooks.count.HP_clan_read_buffs_pre > 0) { + void (*preHookFunc) (struct clan **c, struct config_setting_t **buff, const char **source); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_read_buffs_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_read_buffs_pre[hIndex].func; + preHookFunc(&c, &buff, &source); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clan.read_buffs(c, buff, source); + } + if (HPMHooks.count.HP_clan_read_buffs_post > 0) { + void (*postHookFunc) (struct clan *c, struct config_setting_t *buff, const char *source); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_read_buffs_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_read_buffs_post[hIndex].func; + postHookFunc(c, buff, source); + } + } + return; +} +struct clan* HP_clan_search(int clan_id) { + int hIndex = 0; + struct clan* retVal___ = NULL; + if (HPMHooks.count.HP_clan_search_pre > 0) { + struct clan* (*preHookFunc) (int *clan_id); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_search_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_search_pre[hIndex].func; + retVal___ = preHookFunc(&clan_id); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clan.search(clan_id); + } + if (HPMHooks.count.HP_clan_search_post > 0) { + struct clan* (*postHookFunc) (struct clan* retVal___, int clan_id); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_search_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_search_post[hIndex].func; + retVal___ = postHookFunc(retVal___, clan_id); + } + } + return retVal___; +} +struct clan* HP_clan_searchname(const char *name) { + int hIndex = 0; + struct clan* retVal___ = NULL; + if (HPMHooks.count.HP_clan_searchname_pre > 0) { + struct clan* (*preHookFunc) (const char **name); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_searchname_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_searchname_pre[hIndex].func; + retVal___ = preHookFunc(&name); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clan.searchname(name); + } + if (HPMHooks.count.HP_clan_searchname_post > 0) { + struct clan* (*postHookFunc) (struct clan* retVal___, const char *name); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_searchname_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_searchname_post[hIndex].func; + retVal___ = postHookFunc(retVal___, name); + } + } + return retVal___; +} +struct map_session_data* HP_clan_getonlinesd(struct clan *c) { + int hIndex = 0; + struct map_session_data* retVal___ = NULL; + if (HPMHooks.count.HP_clan_getonlinesd_pre > 0) { + struct map_session_data* (*preHookFunc) (struct clan **c); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_getonlinesd_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_getonlinesd_pre[hIndex].func; + retVal___ = preHookFunc(&c); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clan.getonlinesd(c); + } + if (HPMHooks.count.HP_clan_getonlinesd_post > 0) { + struct map_session_data* (*postHookFunc) (struct map_session_data* retVal___, struct clan *c); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_getonlinesd_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_getonlinesd_post[hIndex].func; + retVal___ = postHookFunc(retVal___, c); + } + } + return retVal___; +} +int HP_clan_getindex(const struct clan *c, int char_id) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_clan_getindex_pre > 0) { + int (*preHookFunc) (const struct clan **c, int *char_id); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_getindex_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_getindex_pre[hIndex].func; + retVal___ = preHookFunc(&c, &char_id); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clan.getindex(c, char_id); + } + if (HPMHooks.count.HP_clan_getindex_post > 0) { + int (*postHookFunc) (int retVal___, const struct clan *c, int char_id); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_getindex_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_getindex_post[hIndex].func; + retVal___ = postHookFunc(retVal___, c, char_id); + } + } + return retVal___; +} +bool HP_clan_join(struct map_session_data *sd, int clan_id) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_clan_join_pre > 0) { + bool (*preHookFunc) (struct map_session_data **sd, int *clan_id); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_join_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_join_pre[hIndex].func; + retVal___ = preHookFunc(&sd, &clan_id); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clan.join(sd, clan_id); + } + if (HPMHooks.count.HP_clan_join_post > 0) { + bool (*postHookFunc) (bool retVal___, struct map_session_data *sd, int clan_id); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_join_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_join_post[hIndex].func; + retVal___ = postHookFunc(retVal___, sd, clan_id); + } + } + return retVal___; +} +void HP_clan_member_online(struct map_session_data *sd, bool first) { + int hIndex = 0; + if (HPMHooks.count.HP_clan_member_online_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd, bool *first); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_member_online_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_member_online_pre[hIndex].func; + preHookFunc(&sd, &first); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clan.member_online(sd, first); + } + if (HPMHooks.count.HP_clan_member_online_post > 0) { + void (*postHookFunc) (struct map_session_data *sd, bool first); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_member_online_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_member_online_post[hIndex].func; + postHookFunc(sd, first); + } + } + return; +} +bool HP_clan_leave(struct map_session_data *sd, bool first) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_clan_leave_pre > 0) { + bool (*preHookFunc) (struct map_session_data **sd, bool *first); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_leave_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_leave_pre[hIndex].func; + retVal___ = preHookFunc(&sd, &first); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clan.leave(sd, first); + } + if (HPMHooks.count.HP_clan_leave_post > 0) { + bool (*postHookFunc) (bool retVal___, struct map_session_data *sd, bool first); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_leave_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_leave_post[hIndex].func; + retVal___ = postHookFunc(retVal___, sd, first); + } + } + return retVal___; +} +bool HP_clan_send_message(struct map_session_data *sd, const char *mes) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_clan_send_message_pre > 0) { + bool (*preHookFunc) (struct map_session_data **sd, const char **mes); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_send_message_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_send_message_pre[hIndex].func; + retVal___ = preHookFunc(&sd, &mes); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clan.send_message(sd, mes); + } + if (HPMHooks.count.HP_clan_send_message_post > 0) { + bool (*postHookFunc) (bool retVal___, struct map_session_data *sd, const char *mes); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_send_message_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_send_message_post[hIndex].func; + retVal___ = postHookFunc(retVal___, sd, mes); + } + } + return retVal___; +} +void HP_clan_recv_message(struct clan *c, const char *mes, int len) { + int hIndex = 0; + if (HPMHooks.count.HP_clan_recv_message_pre > 0) { + void (*preHookFunc) (struct clan **c, const char **mes, int *len); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_recv_message_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_recv_message_pre[hIndex].func; + preHookFunc(&c, &mes, &len); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clan.recv_message(c, mes, len); + } + if (HPMHooks.count.HP_clan_recv_message_post > 0) { + void (*postHookFunc) (struct clan *c, const char *mes, int len); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_recv_message_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_recv_message_post[hIndex].func; + postHookFunc(c, mes, len); + } + } + return; +} +void HP_clan_member_offline(struct map_session_data *sd) { + int hIndex = 0; + if (HPMHooks.count.HP_clan_member_offline_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_member_offline_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_member_offline_pre[hIndex].func; + preHookFunc(&sd); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clan.member_offline(sd); + } + if (HPMHooks.count.HP_clan_member_offline_post > 0) { + void (*postHookFunc) (struct map_session_data *sd); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_member_offline_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_member_offline_post[hIndex].func; + postHookFunc(sd); + } + } + return; +} +void HP_clan_set_constants(void) { + int hIndex = 0; + if (HPMHooks.count.HP_clan_set_constants_pre > 0) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_set_constants_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_set_constants_pre[hIndex].func; + preHookFunc(); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clan.set_constants(); + } + if (HPMHooks.count.HP_clan_set_constants_post > 0) { + void (*postHookFunc) (void); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_set_constants_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_set_constants_post[hIndex].func; + postHookFunc(); + } + } + return; +} +int HP_clan_get_id(const struct block_list *bl) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_clan_get_id_pre > 0) { + int (*preHookFunc) (const struct block_list **bl); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_get_id_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_get_id_pre[hIndex].func; + retVal___ = preHookFunc(&bl); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clan.get_id(bl); + } + if (HPMHooks.count.HP_clan_get_id_post > 0) { + int (*postHookFunc) (int retVal___, const struct block_list *bl); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_get_id_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_get_id_post[hIndex].func; + retVal___ = postHookFunc(retVal___, bl); + } + } + return retVal___; +} +void HP_clan_buff_start(struct map_session_data *sd, struct clan *c) { + int hIndex = 0; + if (HPMHooks.count.HP_clan_buff_start_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd, struct clan **c); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_buff_start_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_buff_start_pre[hIndex].func; + preHookFunc(&sd, &c); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clan.buff_start(sd, c); + } + if (HPMHooks.count.HP_clan_buff_start_post > 0) { + void (*postHookFunc) (struct map_session_data *sd, struct clan *c); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_buff_start_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_buff_start_post[hIndex].func; + postHookFunc(sd, c); + } + } + return; +} +void HP_clan_buff_end(struct map_session_data *sd, struct clan *c) { + int hIndex = 0; + if (HPMHooks.count.HP_clan_buff_end_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd, struct clan **c); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_buff_end_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_buff_end_pre[hIndex].func; + preHookFunc(&sd, &c); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clan.buff_end(sd, c); + } + if (HPMHooks.count.HP_clan_buff_end_post > 0) { + void (*postHookFunc) (struct map_session_data *sd, struct clan *c); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_buff_end_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_buff_end_post[hIndex].func; + postHookFunc(sd, c); + } + } + return; +} +void HP_clan_reload(void) { + int hIndex = 0; + if (HPMHooks.count.HP_clan_reload_pre > 0) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_reload_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_reload_pre[hIndex].func; + preHookFunc(); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clan.reload(); + } + if (HPMHooks.count.HP_clan_reload_post > 0) { + void (*postHookFunc) (void); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_reload_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_reload_post[hIndex].func; + postHookFunc(); + } + } + return; +} +int HP_clan_rejoin(struct map_session_data *sd, va_list ap) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_clan_rejoin_pre > 0) { + int (*preHookFunc) (struct map_session_data **sd, va_list ap); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_rejoin_pre; hIndex++) { + va_list ap___copy; va_copy(ap___copy, ap); + preHookFunc = HPMHooks.list.HP_clan_rejoin_pre[hIndex].func; + retVal___ = preHookFunc(&sd, ap___copy); + va_end(ap___copy); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + va_list ap___copy; va_copy(ap___copy, ap); + retVal___ = HPMHooks.source.clan.rejoin(sd, ap___copy); + va_end(ap___copy); + } + if (HPMHooks.count.HP_clan_rejoin_post > 0) { + int (*postHookFunc) (int retVal___, struct map_session_data *sd, va_list ap); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_rejoin_post; hIndex++) { + va_list ap___copy; va_copy(ap___copy, ap); + postHookFunc = HPMHooks.list.HP_clan_rejoin_post[hIndex].func; + retVal___ = postHookFunc(retVal___, sd, ap___copy); + va_end(ap___copy); + } + } + return retVal___; +} +int HP_clan_inactivity_kick(int tid, int64 tick, int id, intptr_t data) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_clan_inactivity_kick_pre > 0) { + int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_inactivity_kick_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_inactivity_kick_pre[hIndex].func; + retVal___ = preHookFunc(&tid, &tick, &id, &data); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clan.inactivity_kick(tid, tick, id, data); + } + if (HPMHooks.count.HP_clan_inactivity_kick_post > 0) { + int (*postHookFunc) (int retVal___, int tid, int64 tick, int id, intptr_t data); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_inactivity_kick_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_inactivity_kick_post[hIndex].func; + retVal___ = postHookFunc(retVal___, tid, tick, id, data); + } + } + return retVal___; +} +int HP_clan_request_kickoffline(int tid, int64 tick, int id, intptr_t data) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_clan_request_kickoffline_pre > 0) { + int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_request_kickoffline_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_request_kickoffline_pre[hIndex].func; + retVal___ = preHookFunc(&tid, &tick, &id, &data); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clan.request_kickoffline(tid, tick, id, data); + } + if (HPMHooks.count.HP_clan_request_kickoffline_post > 0) { + int (*postHookFunc) (int retVal___, int tid, int64 tick, int id, intptr_t data); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_request_kickoffline_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_request_kickoffline_post[hIndex].func; + retVal___ = postHookFunc(retVal___, tid, tick, id, data); + } + } + return retVal___; +} +int HP_clan_request_membercount(int tid, int64 tick, int id, intptr_t data) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_clan_request_membercount_pre > 0) { + int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_request_membercount_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clan_request_membercount_pre[hIndex].func; + retVal___ = preHookFunc(&tid, &tick, &id, &data); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clan.request_membercount(tid, tick, id, data); + } + if (HPMHooks.count.HP_clan_request_membercount_post > 0) { + int (*postHookFunc) (int retVal___, int tid, int64 tick, int id, intptr_t data); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clan_request_membercount_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clan_request_membercount_post[hIndex].func; + retVal___ = postHookFunc(retVal___, tid, tick, id, data); + } + } + return retVal___; +} /* clif_interface */ int HP_clif_init(bool minimal) { int hIndex = 0; @@ -25165,6 +25888,136 @@ void HP_clif_skill_scale(struct block_list *bl, int src_id, int x, int y, uint16 } return; } +void HP_clif_clan_basicinfo(struct map_session_data *sd) { + int hIndex = 0; + if (HPMHooks.count.HP_clif_clan_basicinfo_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_clan_basicinfo_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clif_clan_basicinfo_pre[hIndex].func; + preHookFunc(&sd); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.clan_basicinfo(sd); + } + if (HPMHooks.count.HP_clif_clan_basicinfo_post > 0) { + void (*postHookFunc) (struct map_session_data *sd); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_clan_basicinfo_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clif_clan_basicinfo_post[hIndex].func; + postHookFunc(sd); + } + } + return; +} +void HP_clif_clan_onlinecount(struct clan *c) { + int hIndex = 0; + if (HPMHooks.count.HP_clif_clan_onlinecount_pre > 0) { + void (*preHookFunc) (struct clan **c); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_clan_onlinecount_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clif_clan_onlinecount_pre[hIndex].func; + preHookFunc(&c); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.clan_onlinecount(c); + } + if (HPMHooks.count.HP_clif_clan_onlinecount_post > 0) { + void (*postHookFunc) (struct clan *c); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_clan_onlinecount_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clif_clan_onlinecount_post[hIndex].func; + postHookFunc(c); + } + } + return; +} +void HP_clif_clan_leave(struct map_session_data *sd) { + int hIndex = 0; + if (HPMHooks.count.HP_clif_clan_leave_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_clan_leave_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clif_clan_leave_pre[hIndex].func; + preHookFunc(&sd); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.clan_leave(sd); + } + if (HPMHooks.count.HP_clif_clan_leave_post > 0) { + void (*postHookFunc) (struct map_session_data *sd); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_clan_leave_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clif_clan_leave_post[hIndex].func; + postHookFunc(sd); + } + } + return; +} +void HP_clif_clan_message(struct clan *c, const char *mes, int len) { + int hIndex = 0; + if (HPMHooks.count.HP_clif_clan_message_pre > 0) { + void (*preHookFunc) (struct clan **c, const char **mes, int *len); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_clan_message_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clif_clan_message_pre[hIndex].func; + preHookFunc(&c, &mes, &len); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.clan_message(c, mes, len); + } + if (HPMHooks.count.HP_clif_clan_message_post > 0) { + void (*postHookFunc) (struct clan *c, const char *mes, int len); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_clan_message_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clif_clan_message_post[hIndex].func; + postHookFunc(c, mes, len); + } + } + return; +} +void HP_clif_pClanMessage(int fd, struct map_session_data *sd) { + int hIndex = 0; + if (HPMHooks.count.HP_clif_pClanMessage_pre > 0) { + void (*preHookFunc) (int *fd, struct map_session_data **sd); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_pClanMessage_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_clif_pClanMessage_pre[hIndex].func; + preHookFunc(&fd, &sd); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.pClanMessage(fd, sd); + } + if (HPMHooks.count.HP_clif_pClanMessage_post > 0) { + void (*postHookFunc) (int fd, struct map_session_data *sd); + for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_pClanMessage_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_clif_pClanMessage_post[hIndex].func; + postHookFunc(fd, sd); + } + } + return; +} /* cmdline_interface */ void HP_cmdline_init(void) { int hIndex = 0; @@ -33854,6 +34707,60 @@ int HP_intif_rodex_checkname(struct map_session_data *sd, const char *name) { } return retVal___; } +int HP_intif_clan_kickoffline(int clan_id, int kick_interval) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_intif_clan_kickoffline_pre > 0) { + int (*preHookFunc) (int *clan_id, int *kick_interval); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_intif_clan_kickoffline_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_intif_clan_kickoffline_pre[hIndex].func; + retVal___ = preHookFunc(&clan_id, &kick_interval); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.intif.clan_kickoffline(clan_id, kick_interval); + } + if (HPMHooks.count.HP_intif_clan_kickoffline_post > 0) { + int (*postHookFunc) (int retVal___, int clan_id, int kick_interval); + for (hIndex = 0; hIndex < HPMHooks.count.HP_intif_clan_kickoffline_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_intif_clan_kickoffline_post[hIndex].func; + retVal___ = postHookFunc(retVal___, clan_id, kick_interval); + } + } + return retVal___; +} +int HP_intif_clan_membercount(int clan_id, int kick_interval) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_intif_clan_membercount_pre > 0) { + int (*preHookFunc) (int *clan_id, int *kick_interval); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_intif_clan_membercount_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_intif_clan_membercount_pre[hIndex].func; + retVal___ = preHookFunc(&clan_id, &kick_interval); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.intif.clan_membercount(clan_id, kick_interval); + } + if (HPMHooks.count.HP_intif_clan_membercount_post > 0) { + int (*postHookFunc) (int retVal___, int clan_id, int kick_interval); + for (hIndex = 0; hIndex < HPMHooks.count.HP_intif_clan_membercount_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_intif_clan_membercount_post[hIndex].func; + retVal___ = postHookFunc(retVal___, clan_id, kick_interval); + } + } + return retVal___; +} void HP_intif_request_accinfo(int u_fd, int aid, int group_lv, char *query) { int hIndex = 0; if (HPMHooks.count.HP_intif_request_accinfo_pre > 0) { @@ -35682,6 +36589,32 @@ void HP_intif_pRodexCheckName(int fd) { } return; } +void HP_intif_pRecvClanMemberAction(int fd) { + int hIndex = 0; + if (HPMHooks.count.HP_intif_pRecvClanMemberAction_pre > 0) { + void (*preHookFunc) (int *fd); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_intif_pRecvClanMemberAction_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_intif_pRecvClanMemberAction_pre[hIndex].func; + preHookFunc(&fd); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.intif.pRecvClanMemberAction(fd); + } + if (HPMHooks.count.HP_intif_pRecvClanMemberAction_post > 0) { + void (*postHookFunc) (int fd); + for (hIndex = 0; hIndex < HPMHooks.count.HP_intif_pRecvClanMemberAction_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_intif_pRecvClanMemberAction_post[hIndex].func; + postHookFunc(fd); + } + } + return; +} /* irc_bot_interface */ void HP_ircbot_init(bool minimal) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_map.sources.inc b/src/plugins/HPMHooking/HPMHooking_map.sources.inc index 23f762151..e6f305726 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.sources.inc @@ -33,6 +33,7 @@ HPMHooks.source.buyingstore = *buyingstore; HPMHooks.source.channel = *channel; HPMHooks.source.chat = *chat; HPMHooks.source.chrif = *chrif; +HPMHooks.source.clan = *clan; HPMHooks.source.clif = *clif; HPMHooks.source.cmdline = *cmdline; HPMHooks.source.console = *console; |