summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/HPMchar.c53
-rw-r--r--src/char/HPMchar.h21
-rw-r--r--src/char/Makefile.in14
-rw-r--r--src/char/char.c5556
-rw-r--r--src/char/char.h223
-rw-r--r--src/char/geoip.c187
-rw-r--r--src/char/geoip.h32
-rw-r--r--src/char/int_auction.c221
-rw-r--r--src/char/int_auction.h23
-rw-r--r--src/char/int_elemental.c123
-rw-r--r--src/char/int_elemental.h15
-rw-r--r--src/char/int_guild.c727
-rw-r--r--src/char/int_guild.h47
-rw-r--r--src/char/int_homun.c156
-rw-r--r--src/char/int_homun.h18
-rw-r--r--src/char/int_mail.c293
-rw-r--r--src/char/int_mail.h24
-rw-r--r--src/char/int_mercenary.c132
-rw-r--r--src/char/int_mercenary.h21
-rw-r--r--src/char/int_party.c382
-rw-r--r--src/char/int_party.h39
-rw-r--r--src/char/int_pet.c209
-rw-r--r--src/char/int_pet.h23
-rw-r--r--src/char/int_quest.c98
-rw-r--r--src/char/int_quest.h11
-rw-r--r--src/char/int_storage.c181
-rw-r--r--src/char/int_storage.h25
-rw-r--r--src/char/inter.c779
-rw-r--r--src/char/inter.h43
-rw-r--r--src/char/loginif.c181
-rw-r--r--src/char/loginif.h33
-rw-r--r--src/char/mapif.c362
-rw-r--r--src/char/mapif.h198
-rw-r--r--src/char/pincode.c97
-rw-r--r--src/char/pincode.h32
-rw-r--r--src/common/HPM.c350
-rw-r--r--src/common/HPM.h6
-rw-r--r--src/common/HPMDataCheck.h159
-rw-r--r--src/common/HPMi.h49
-rw-r--r--src/common/atomic.h14
-rw-r--r--src/common/cbasetypes.h113
-rw-r--r--src/common/conf.c12
-rw-r--r--src/common/conf.h28
-rw-r--r--src/common/console.c92
-rw-r--r--src/common/core.c30
-rw-r--r--src/common/db.c23
-rw-r--r--src/common/db.h103
-rw-r--r--src/common/des.c16
-rw-r--r--src/common/ers.c40
-rw-r--r--src/common/ers.h2
-rw-r--r--src/common/grfio.c91
-rw-r--r--src/common/malloc.c76
-rw-r--r--src/common/malloc.h20
-rw-r--r--src/common/mapindex.c43
-rw-r--r--src/common/mapindex.h7
-rw-r--r--src/common/md5calc.c224
-rw-r--r--src/common/mmo.h32
-rw-r--r--src/common/mutex.c60
-rw-r--r--src/common/nullpo.c4
-rw-r--r--src/common/showmsg.c361
-rw-r--r--src/common/socket.c78
-rw-r--r--src/common/socket.h2
-rw-r--r--src/common/spinlock.h26
-rw-r--r--src/common/sql.c18
-rw-r--r--src/common/sql.h2
-rw-r--r--src/common/strlib.c21
-rw-r--r--src/common/strlib.h32
-rw-r--r--src/common/thread.c37
-rw-r--r--src/common/thread.h4
-rw-r--r--src/common/timer.c36
-rw-r--r--src/common/utils.c66
-rw-r--r--src/common/winapi.h6
-rw-r--r--src/config/classes/general.h5
-rw-r--r--src/config/const.h13
-rw-r--r--src/config/core.h13
-rw-r--r--src/login/HPMlogin.c53
-rw-r--r--src/login/HPMlogin.h20
-rw-r--r--src/login/Makefile.in6
-rw-r--r--src/login/account.h4
-rw-r--r--src/login/account_sql.c93
-rw-r--r--src/login/ipban_sql.c6
-rw-r--r--src/login/login.c1675
-rw-r--r--src/login/login.h154
-rw-r--r--src/login/loginlog_sql.c4
-rw-r--r--src/map/HPMmap.c56
-rw-r--r--src/map/HPMmap.h2
-rw-r--r--src/map/Makefile.in2
-rw-r--r--src/map/atcommand.c2436
-rw-r--r--src/map/battle.c762
-rw-r--r--src/map/battle.h172
-rw-r--r--src/map/battleground.c124
-rw-r--r--src/map/buyingstore.c15
-rw-r--r--src/map/chat.c32
-rw-r--r--src/map/chat.h23
-rw-r--r--src/map/chrif.c303
-rw-r--r--src/map/chrif.h16
-rw-r--r--src/map/clif.c1001
-rw-r--r--src/map/clif.h129
-rw-r--r--src/map/duel.c2
-rw-r--r--src/map/duel.h4
-rw-r--r--src/map/elemental.c44
-rw-r--r--src/map/elemental.h16
-rw-r--r--src/map/guild.c185
-rw-r--r--src/map/guild.h4
-rw-r--r--src/map/homunculus.c68
-rw-r--r--src/map/homunculus.h13
-rw-r--r--src/map/instance.c12
-rw-r--r--src/map/instance.h8
-rw-r--r--src/map/intif.c157
-rw-r--r--src/map/irc-bot.c34
-rw-r--r--src/map/itemdb.c145
-rw-r--r--src/map/itemdb.h34
-rw-r--r--src/map/log.c7
-rw-r--r--src/map/log.h8
-rw-r--r--src/map/map.c235
-rw-r--r--src/map/map.h145
-rw-r--r--src/map/mercenary.c2
-rw-r--r--src/map/mercenary.h20
-rw-r--r--src/map/mob.c544
-rw-r--r--src/map/mob.h39
-rw-r--r--src/map/npc.c274
-rw-r--r--src/map/npc.h8
-rw-r--r--src/map/packets.h335
-rw-r--r--src/map/packets_struct.h76
-rw-r--r--src/map/party.c44
-rw-r--r--src/map/party.h16
-rw-r--r--src/map/path.c99
-rw-r--r--src/map/path.h12
-rw-r--r--src/map/pc.c899
-rw-r--r--src/map/pc.h205
-rw-r--r--src/map/pc_groups.c4
-rw-r--r--src/map/pc_groups.h4
-rw-r--r--src/map/pet.c74
-rw-r--r--src/map/pet.h13
-rw-r--r--src/map/script.c1293
-rw-r--r--src/map/script.h29
-rw-r--r--src/map/searchstore.c4
-rw-r--r--src/map/skill.c1391
-rw-r--r--src/map/skill.h165
-rw-r--r--src/map/status.c2011
-rw-r--r--src/map/status.h162
-rw-r--r--src/map/storage.c172
-rw-r--r--src/map/storage.h3
-rw-r--r--src/map/trade.c43
-rw-r--r--src/map/unit.c565
-rw-r--r--src/map/unit.h8
-rw-r--r--src/map/vending.c30
-rw-r--r--src/plugins/HPMHooking.c105
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.GetSymbol.inc22
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc1814
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc472
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.Hooks.inc11904
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.sources.inc22
-rw-r--r--src/plugins/HPMHooking/HPMHooking_login.GetSymbol.inc7
-rw-r--r--src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc235
-rw-r--r--src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc66
-rw-r--r--src/plugins/HPMHooking/HPMHooking_login.Hooks.inc1473
-rw-r--r--src/plugins/HPMHooking/HPMHooking_login.sources.inc7
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.GetSymbol.inc (renamed from src/plugins/HPMHooking/HPMHooking.GetSymbol.inc)0
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc (renamed from src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc)156
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc (renamed from src/plugins/HPMHooking/HPMHooking.HookingPoints.inc)39
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.Hooks.inc (renamed from src/plugins/HPMHooking/HPMHooking.Hooks.inc)1026
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.sources.inc (renamed from src/plugins/HPMHooking/HPMHooking.sources.inc)0
-rw-r--r--src/plugins/Makefile.in20
-rw-r--r--src/plugins/db2sql.c46
-rw-r--r--src/plugins/dbghelpplug.c175
-rw-r--r--src/plugins/sample.c44
-rw-r--r--src/test/test_spinlock.c26
-rw-r--r--src/tool/Makefile.in2
169 files changed, 34506 insertions, 12801 deletions
diff --git a/src/char/HPMchar.c b/src/char/HPMchar.c
new file mode 100644
index 000000000..4b153b244
--- /dev/null
+++ b/src/char/HPMchar.c
@@ -0,0 +1,53 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+
+#define HERCULES_CORE
+
+#include "HPMchar.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "../common/HPM.h"
+#include "../common/cbasetypes.h"
+#include "../common/conf.h"
+#include "../common/db.h"
+#include "../common/des.h"
+#include "../common/ers.h"
+#include "../common/malloc.h"
+#include "../common/mapindex.h"
+#include "../common/mmo.h"
+#include "../common/showmsg.h"
+#include "../common/socket.h"
+#include "../common/strlib.h"
+#include "../common/sysinfo.h"
+
+#include "../common/HPMDataCheck.h"
+
+bool HPM_char_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr) {
+ /* record address */
+ switch( type ) {
+ default:
+ return false;
+ }
+ return true;
+}
+
+void HPM_char_plugin_load_sub(struct hplugin *plugin) {
+}
+
+void HPM_char_do_init(void) {
+#if 0 // TODO (HPMDataCheck is disabled for the time being)
+ HPM->datacheck_init(HPMDataCheck, HPMDataCheckLen, HPMDataCheckVer);
+#else
+ HPM->DataCheck = NULL;
+#endif
+}
+
+void HPM_char_do_final(void) {
+#if 0 // TODO (HPMDataCheck is disabled for the time being)
+ HPM->datacheck_final();
+#endif
+}
diff --git a/src/char/HPMchar.h b/src/char/HPMchar.h
new file mode 100644
index 000000000..9d367725c
--- /dev/null
+++ b/src/char/HPMchar.h
@@ -0,0 +1,21 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+
+#ifndef CHAR_HPMCHAR_H
+#define CHAR_HPMCHAR_H
+
+#include "../common/cbasetypes.h"
+#include "../common/HPM.h"
+
+struct hplugin;
+
+bool HPM_char_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr);
+
+void HPM_char_plugin_load_sub(struct hplugin *plugin);
+
+void HPM_char_do_final(void);
+
+void HPM_char_do_init(void);
+
+#endif /* CHAR_HPMCHAR_H */
+
diff --git a/src/char/Makefile.in b/src/char/Makefile.in
index 59dc56076..20d19966e 100644
--- a/src/char/Makefile.in
+++ b/src/char/Makefile.in
@@ -22,13 +22,13 @@ MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
MT19937AR_INCLUDE = -I$(MT19937AR_D)
-CHAR_C = char.c inter.c int_auction.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_storage.c pincode.c
+CHAR_C = char.c HPMchar.c loginif.c mapif.c geoip.c inter.c int_auction.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_storage.c pincode.c
CHAR_OBJ = $(addprefix obj_sql/, $(patsubst %.c,%.o,$(CHAR_C)))
-CHAR_H = char.h inter.h int_auction.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_storage.h pincode.h
+CHAR_H = char.h HPMchar.h loginif.h mapif.h geoip.h inter.h int_auction.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_storage.h pincode.h
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
@@ -91,7 +91,7 @@ char-server: ../../char-server@EXEEXT@
../../char-server@EXEEXT@: $(CHAR_SERVER_SQL_DEPENDS) Makefile
@echo " LD $(notdir $@)"
- @$(CC) @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) $(COMMON_D)/obj_sql/common_sql.a \
+ @$(CC) @STATIC@ @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) $(COMMON_D)/obj_sql/common_sql.a \
$(COMMON_D)/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@
# char object files
diff --git a/src/char/char.c b/src/char/char.c
index 9abb17257..698832bfb 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -15,13 +15,21 @@
#include <sys/types.h>
#include <time.h>
+#include "HPMchar.h"
+#include "geoip.h"
+#include "int_auction.h"
#include "int_elemental.h"
#include "int_guild.h"
#include "int_homun.h"
+#include "int_mail.h"
#include "int_mercenary.h"
#include "int_party.h"
+#include "int_pet.h"
+#include "int_quest.h"
#include "int_storage.h"
#include "inter.h"
+#include "loginif.h"
+#include "mapif.h"
#include "pincode.h"
#include "../common/HPM.h"
#include "../common/cbasetypes.h"
@@ -38,9 +46,9 @@
#include "../common/utils.h"
// private declarations
-#define CHAR_CONF_NAME "conf/char-server.conf"
-#define LAN_CONF_NAME "conf/subnet.conf"
-#define SQL_CONF_NAME "conf/inter-server.conf"
+#define CHAR_CONF_NAME "conf/char-server.conf"
+#define LAN_CONF_NAME "conf/subnet.conf"
+#define SQL_CONF_NAME "conf/inter-server.conf"
char char_db[256] = "char";
char scdata_db[256] = "sc_data";
@@ -79,43 +87,26 @@ char acc_reg_str_db[32] = "acc_reg_str_db";
char char_reg_str_db[32] = "char_reg_str_db";
char char_reg_num_db[32] = "char_reg_num_db";
+struct char_interface char_s;
+
// show loading/saving messages
int save_log = 1;
-static DBMap* char_db_; // int char_id -> struct mmo_charstatus*
-
char db_path[1024] = "db";
int db_use_sql_item_db;
int db_use_sql_mob_db;
int db_use_sql_mob_skill_db;
-struct mmo_map_server {
- int fd;
- uint32 ip;
- uint16 port;
- int users;
- unsigned short *map;
- unsigned short maps;
-} server[MAX_MAP_SERVERS];
-
-int char_fd=-1;
-char userid[24];
-char passwd[24];
-char server_name[20];
char wisp_server_name[NAME_LENGTH] = "Server";
char login_ip_str[128];
uint32 login_ip = 0;
uint16 login_port = 6900;
char char_ip_str[128];
-uint32 char_ip = 0;
char bind_ip_str[128];
uint32 bind_ip = INADDR_ANY;
-uint16 char_port = 6121;
-int char_server_type = 0;
int char_maintenance_min_group_id = 0;
bool char_new = true;
-int char_new_display = 0;
bool name_ignoring_case = false; // Allow or not identical name for characters but with a different case by [Yor]
int char_name_option = 0; // Option to know which letters/symbols are authorized in the name of a character (0: all, 1: only those in char_name_letters, 2: all EXCEPT those in char_name_letters) by [Yor]
@@ -126,10 +117,10 @@ char char_name_letters[1024] = ""; // list of letters/symbols allowed (or not) i
int char_del_level = 0; //From which level u can delete character [Lupus]
int char_del_delay = 86400;
-int log_char = 1; // logging char or not [devil]
-int log_inter = 1; // logging inter or not [devil]
+int log_char = 1; // logging char or not [devil]
+int log_inter = 1; // logging inter or not [devil]
-int char_aegis_delete = 0; // Verify if char is in guild/party or char and reacts as Aegis does (doesn't allow deletion), see char_delete2_req for more information
+int char_aegis_delete = 0; // Verify if char is in guild/party or char and reacts as Aegis does (doesn't allow deletion), see chr->delete2_req for more information
// Advanced subnet check [LuzZza]
struct s_subnet {
@@ -171,31 +162,16 @@ unsigned short skillid2idx[MAX_SKILL_ID];
//-----------------------------------------------------
#define AUTH_TIMEOUT 30000
-struct auth_node {
- int account_id;
- int char_id;
- uint32 login_id1;
- uint32 login_id2;
- uint32 ip;
- int sex;
- time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
- int group_id;
- unsigned changing_mapservers : 1;
-};
-
-static DBMap* auth_db; // int account_id -> struct auth_node*
+static DBMap* auth_db; // int account_id -> struct char_auth_node*
//-----------------------------------------------------
// Online User Database
//-----------------------------------------------------
-static int chardb_waiting_disconnect(int tid, int64 tick, int id, intptr_t data);
-int delete_char_sql(int char_id);
-
/**
* @see DBCreateData
*/
-static DBData create_online_char_data(DBKey key, va_list args)
+static DBData char_create_online_char_data(DBKey key, va_list args)
{
struct online_char_data* character;
CREATE(character, struct online_char_data, 1);
@@ -208,52 +184,62 @@ static DBData create_online_char_data(DBKey key, va_list args)
return DB->ptr2data(character);
}
-void set_char_charselect(int account_id)
+void char_set_account_online(int account_id)
+{
+ WFIFOHEAD(chr->login_fd,6);
+ WFIFOW(chr->login_fd,0) = 0x272b;
+ WFIFOL(chr->login_fd,2) = account_id;
+ WFIFOSET(chr->login_fd,6);
+}
+
+void char_set_account_offline(int account_id)
+{
+ WFIFOHEAD(chr->login_fd,6);
+ WFIFOW(chr->login_fd,0) = 0x272c;
+ WFIFOL(chr->login_fd,2) = account_id;
+ WFIFOSET(chr->login_fd,6);
+}
+
+void char_set_char_charselect(int account_id)
{
struct online_char_data* character;
- character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data);
+ character = (struct online_char_data*)idb_ensure(chr->online_char_db, account_id, chr->create_online_char_data);
if( character->server > -1 )
- if( server[character->server].users > 0 ) // Prevent this value from going negative.
- server[character->server].users--;
+ if( chr->server[character->server].users > 0 ) // Prevent this value from going negative.
+ chr->server[character->server].users--;
character->char_id = -1;
character->server = -1;
if(character->pincode_enable == -1)
- character->pincode_enable = *pincode->charselect + *pincode->enabled;
+ character->pincode_enable = pincode->charselect + pincode->enabled;
if(character->waiting_disconnect != INVALID_TIMER) {
- timer->delete(character->waiting_disconnect, chardb_waiting_disconnect);
+ timer->delete(character->waiting_disconnect, chr->waiting_disconnect);
character->waiting_disconnect = INVALID_TIMER;
}
- if (login_fd > 0 && !session[login_fd]->flag.eof)
- {
- WFIFOHEAD(login_fd,6);
- WFIFOW(login_fd,0) = 0x272b;
- WFIFOL(login_fd,2) = account_id;
- WFIFOSET(login_fd,6);
- }
-
+ if (chr->login_fd > 0 && !session[chr->login_fd]->flag.eof)
+ chr->set_account_online(account_id);
}
-void set_char_online(int map_id, int char_id, int account_id)
+void char_set_char_online(int map_id, int char_id, int account_id)
{
struct online_char_data* character;
struct mmo_charstatus *cp;
//Update DB
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
//Check to see for online conflicts
- character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data);
+ character = (struct online_char_data*)idb_ensure(chr->online_char_db, account_id, chr->create_online_char_data);
if( character->char_id != -1 && character->server > -1 && character->server != map_id )
{
- ShowNotice("set_char_online: Character %d:%d marked in map server %d, but map server %d claims to have (%d:%d) online!\n",
+ ShowNotice("chr->set_char_online: Character %d:%d marked in map server %d, but map server %d claims to have (%d:%d) online!\n",
character->account_id, character->char_id, character->server, map_id, account_id, char_id);
- mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2);
+ mapif->disconnectplayer(chr->server[character->server].fd, character->account_id, character->char_id, 2);
}
//Update state data
@@ -261,56 +247,51 @@ void set_char_online(int map_id, int char_id, int account_id)
character->server = map_id;
if( character->server > -1 )
- server[character->server].users++;
+ chr->server[character->server].users++;
//Get rid of disconnect timer
if(character->waiting_disconnect != INVALID_TIMER) {
- timer->delete(character->waiting_disconnect, chardb_waiting_disconnect);
+ timer->delete(character->waiting_disconnect, chr->waiting_disconnect);
character->waiting_disconnect = INVALID_TIMER;
}
//Set char online in guild cache. If char is in memory, use the guild id on it, otherwise seek it.
- cp = (struct mmo_charstatus*)idb_get(char_db_,char_id);
- inter_guild_CharOnline(char_id, cp?cp->guild_id:-1);
+ cp = (struct mmo_charstatus*)idb_get(chr->char_db_,char_id);
+ inter_guild->CharOnline(char_id, cp?cp->guild_id:-1);
//Notify login server
- if (login_fd > 0 && !session[login_fd]->flag.eof)
- {
- WFIFOHEAD(login_fd,6);
- WFIFOW(login_fd,0) = 0x272b;
- WFIFOL(login_fd,2) = account_id;
- WFIFOSET(login_fd,6);
- }
+ if (chr->login_fd > 0 && !session[chr->login_fd]->flag.eof)
+ chr->set_account_online(account_id);
}
-void set_char_offline(int char_id, int account_id)
+void char_set_char_offline(int char_id, int account_id)
{
struct online_char_data* character;
if ( char_id == -1 )
{
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `account_id`='%d'", char_db, account_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `online`='0' WHERE `account_id`='%d'", char_db, account_id) )
+ Sql_ShowDebug(inter->sql_handle);
}
else
{
- struct mmo_charstatus* cp = (struct mmo_charstatus*)idb_get(char_db_,char_id);
- inter_guild_CharOffline(char_id, cp?cp->guild_id:-1);
+ struct mmo_charstatus* cp = (struct mmo_charstatus*)idb_get(chr->char_db_,char_id);
+ inter_guild->CharOffline(char_id, cp?cp->guild_id:-1);
if (cp)
- idb_remove(char_db_,char_id);
+ idb_remove(chr->char_db_,char_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `online`='0' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
}
- if ((character = (struct online_char_data*)idb_get(online_char_db, account_id)) != NULL)
- { //We don't free yet to avoid aCalloc/aFree spamming during char change. [Skotlex]
+ if ((character = (struct online_char_data*)idb_get(chr->online_char_db, account_id)) != NULL) {
+ //We don't free yet to avoid aCalloc/aFree spamming during char change. [Skotlex]
if( character->server > -1 )
- if( server[character->server].users > 0 ) // Prevent this value from going negative.
- server[character->server].users--;
+ if( chr->server[character->server].users > 0 ) // Prevent this value from going negative.
+ chr->server[character->server].users--;
if(character->waiting_disconnect != INVALID_TIMER){
- timer->delete(character->waiting_disconnect, chardb_waiting_disconnect);
+ timer->delete(character->waiting_disconnect, chr->waiting_disconnect);
character->waiting_disconnect = INVALID_TIMER;
}
@@ -325,13 +306,8 @@ void set_char_offline(int char_id, int account_id)
}
//Remove char if 1- Set all offline, or 2- character is no longer connected to char-server.
- if (login_fd > 0 && !session[login_fd]->flag.eof && (char_id == -1 || character == NULL || character->fd == -1))
- {
- WFIFOHEAD(login_fd,6);
- WFIFOW(login_fd,0) = 0x272c;
- WFIFOL(login_fd,2) = account_id;
- WFIFOSET(login_fd,6);
- }
+ if (chr->login_fd > 0 && !session[chr->login_fd]->flag.eof && (char_id == -1 || character == NULL || character->fd == -1))
+ chr->set_account_offline(account_id);
}
/**
@@ -345,7 +321,7 @@ static int char_db_setoffline(DBKey key, DBData *data, va_list ap)
character->char_id = -1;
character->server = -1;
if(character->waiting_disconnect != INVALID_TIMER){
- timer->delete(character->waiting_disconnect, chardb_waiting_disconnect);
+ timer->delete(character->waiting_disconnect, chr->waiting_disconnect);
character->waiting_disconnect = INVALID_TIMER;
}
} else if (character->server == server_id)
@@ -366,46 +342,51 @@ static int char_db_kickoffline(DBKey key, DBData *data, va_list ap)
//Kick out any connected characters, and set them offline as appropriate.
if (character->server > -1)
- mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 1);
+ mapif->disconnectplayer(chr->server[character->server].fd, character->account_id, character->char_id, 1);
else if (character->waiting_disconnect == INVALID_TIMER)
- set_char_offline(character->char_id, character->account_id);
+ chr->set_char_offline(character->char_id, character->account_id);
else
return 0; // fail
return 1;
}
-void set_all_offline(int id)
+void char_set_login_all_offline(void)
+{
+ //Tell login-server to also mark all our characters as offline.
+ WFIFOHEAD(chr->login_fd,2);
+ WFIFOW(chr->login_fd,0) = 0x2737;
+ WFIFOSET(chr->login_fd,2);
+}
+
+void char_set_all_offline(int id)
{
if (id < 0)
ShowNotice("Sending all users offline.\n");
else
ShowNotice("Sending users of map-server %d offline.\n",id);
- online_char_db->foreach(online_char_db,char_db_kickoffline,id);
+ chr->online_char_db->foreach(chr->online_char_db,chr->db_kickoffline,id);
- if (id >= 0 || login_fd <= 0 || session[login_fd]->flag.eof)
+ if (id >= 0 || chr->login_fd <= 0 || session[chr->login_fd]->flag.eof)
return;
- //Tell login-server to also mark all our characters as offline.
- WFIFOHEAD(login_fd,2);
- WFIFOW(login_fd,0) = 0x2737;
- WFIFOSET(login_fd,2);
+ chr->set_login_all_offline();
}
-void set_all_offline_sql(void)
+void char_set_all_offline_sql(void)
{
//Set all players to 'OFFLINE'
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `online` = '0'", char_db) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `online` = '0'", guild_member_db) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `connect_member` = '0'", guild_db) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `online` = '0'", char_db) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `online` = '0'", guild_member_db) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `connect_member` = '0'", guild_db) )
+ Sql_ShowDebug(inter->sql_handle);
}
/**
* @see DBCreateData
*/
-static DBData create_charstatus(DBKey key, va_list args)
+static DBData char_create_charstatus(DBKey key, va_list args)
{
struct mmo_charstatus *cp;
cp = (struct mmo_charstatus *) aCalloc(1,sizeof(struct mmo_charstatus));
@@ -413,9 +394,7 @@ static DBData create_charstatus(DBKey key, va_list args)
return DB->ptr2data(cp);
}
-int inventory_to_sql(const struct item items[], int max, int id);
-
-int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
+int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
{
int i = 0;
int count = 0;
@@ -427,14 +406,14 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
if (char_id!=p->char_id) return 0;
- cp = idb_ensure(char_db_, char_id, create_charstatus);
+ cp = idb_ensure(chr->char_db_, char_id, chr->create_charstatus);
StrBuf->Init(&buf);
memset(save_status, 0, sizeof(save_status));
//map inventory data
if( memcmp(p->inventory, cp->inventory, sizeof(p->inventory)) ) {
- if (!inventory_to_sql(p->inventory, MAX_INVENTORY, p->char_id))
+ if (!chr->inventory_to_sql(p->inventory, MAX_INVENTORY, p->char_id))
strcat(save_status, " inventory");
else
errors++;
@@ -442,7 +421,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
//map cart data
if( memcmp(p->cart, cp->cart, sizeof(p->cart)) ) {
- if (!memitemdata_to_sql(p->cart, MAX_CART, p->char_id, TABLE_CART))
+ if (!chr->memitemdata_to_sql(p->cart, MAX_CART, p->char_id, TABLE_CART))
strcat(save_status, " cart");
else
errors++;
@@ -450,12 +429,12 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
//map storage data
if( memcmp(p->storage.items, cp->storage.items, sizeof(p->storage.items)) ) {
- if (!memitemdata_to_sql(p->storage.items, MAX_STORAGE, p->account_id, TABLE_STORAGE))
+ if (!chr->memitemdata_to_sql(p->storage.items, MAX_STORAGE, p->account_id, TABLE_STORAGE))
strcat(save_status, " storage");
else
errors++;
}
-
+
if (
(p->base_exp != cp->base_exp) || (p->base_level != cp->base_level) ||
(p->job_level != cp->job_level) || (p->job_exp != cp->job_exp) ||
@@ -474,23 +453,40 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
(p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->delete_date != cp->delete_date) ||
(p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->robe != cp->robe) ||
(p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) || (p->font != cp->font) ||
- (p->uniqueitem_counter != cp->uniqueitem_counter )
- ) { //Save status
+ (p->uniqueitem_counter != cp->uniqueitem_counter ) || (p->sex != cp->sex)
+ ) {
+ //Save status
unsigned int opt = 0;
-
+ char sex;
+
if( p->allow_party )
opt |= OPT_ALLOW_PARTY;
if( p->show_equip )
opt |= OPT_SHOW_EQUIP;
-
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `base_level`='%d', `job_level`='%d',"
+
+ switch (p->sex)
+ {
+ case 0:
+ sex = 'F';
+ break;
+ case 1:
+ sex = 'M';
+ break;
+ case 99:
+ default:
+ sex = 'U';
+ break;
+ }
+
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `base_level`='%d', `job_level`='%d',"
"`base_exp`='%u', `job_exp`='%u', `zeny`='%d',"
"`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d',"
"`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d',"
"`option`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',`homun_id`='%d',`elemental_id`='%d',"
"`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'"
+ "`delete_date`='%lu',`robe`='%d',`slotchange`='%d', `char_opt`='%u', `font`='%u', `uniqueitem_counter` ='%u',"
+ " sex = '%c'"
" WHERE `account_id`='%d' AND `char_id` = '%d'",
char_db, p->base_level, p->job_level,
p->base_exp, p->job_exp, p->zeny,
@@ -501,18 +497,18 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y,
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->robe,p->slotchange,opt,p->font,p->uniqueitem_counter,
+ p->robe,p->slotchange,opt,p->font,p->uniqueitem_counter, sex,
p->account_id, p->char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
} else
strcat(save_status, " status");
}
-
+
if( p->bank_vault != cp->bank_vault || p->mod_exp != cp->mod_exp || p->mod_drop != cp->mod_drop || p->mod_death != cp->mod_death ) {
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`bank_vault`,`base_exp`,`base_drop`,`base_death`) VALUES ('%d','%d','%d','%d','%d')",account_data_db,p->account_id,p->bank_vault,p->mod_exp,p->mod_drop,p->mod_death) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`account_id`,`bank_vault`,`base_exp`,`base_drop`,`base_death`) VALUES ('%d','%d','%d','%d','%d')",account_data_db,p->account_id,p->bank_vault,p->mod_exp,p->mod_drop,p->mod_death) ) {
+ Sql_ShowDebug(inter->sql_handle);
errors++;
} else
strcat(save_status, " accdata");
@@ -524,11 +520,11 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
(p->class_ != cp->class_) ||
(p->partner_id != cp->partner_id) || (p->father != cp->father) ||
(p->mother != cp->mother) || (p->child != cp->child) ||
- (p->karma != cp->karma) || (p->manner != cp->manner) ||
+ (p->karma != cp->karma) || (p->manner != cp->manner) ||
(p->fame != cp->fame)
)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `class`='%d',"
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `class`='%d',"
"`hair`='%d',`hair_color`='%d',`clothes_color`='%d',"
"`partner_id`='%d', `father`='%d', `mother`='%d', `child`='%d',"
"`karma`='%d',`manner`='%d', `fame`='%d'"
@@ -539,7 +535,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
p->karma, p->manner, p->fame,
p->account_id, p->char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
} else
strcat(save_status, " status2");
@@ -551,7 +547,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
(p->spear_calls != cp->spear_calls) || (p->spear_faith != cp->spear_faith) ||
(p->sword_calls != cp->sword_calls) || (p->sword_faith != cp->sword_faith) )
{
- if (mercenary_owner_tosql(char_id, p))
+ if (inter_mercenary->owner_tosql(char_id, p))
strcat(save_status, " mercenary");
else
errors++;
@@ -563,9 +559,9 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
char esc_mapname[NAME_LENGTH*2+1];
//`memo` (`memo_id`,`char_id`,`map`,`x`,`y`)
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, p->char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, p->char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
@@ -578,16 +574,16 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
{
if( count )
StrBuf->AppendStr(&buf, ",");
- SQL->EscapeString(sql_handle, esc_mapname, mapindex_id2name(p->memo_point[i].map));
+ SQL->EscapeString(inter->sql_handle, esc_mapname, mapindex_id2name(p->memo_point[i].map));
StrBuf->Printf(&buf, "('%d', '%s', '%d', '%d')", char_id, esc_mapname, p->memo_point[i].x, p->memo_point[i].y);
++count;
}
}
if( count )
{
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -597,8 +593,8 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
//skills
if( memcmp(p->skill, cp->skill, sizeof(p->skill)) ) {
//`skill` (`char_id`, `id`, `lv`)
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, p->char_id) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, p->char_id) ) {
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
@@ -607,7 +603,6 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
//insert here.
for( i = 0, count = 0; i < MAX_SKILL; ++i ) {
if( p->skill[i].id != 0 && p->skill[i].flag != SKILL_FLAG_TEMPORARY ) {
-
if( p->skill[i].lv == 0 && ( p->skill[i].flag == SKILL_FLAG_PERM_GRANTED || p->skill[i].flag == SKILL_FLAG_PERMANENT ) )
continue;
if( p->skill[i].flag != SKILL_FLAG_PERMANENT && p->skill[i].flag != SKILL_FLAG_PERM_GRANTED && (p->skill[i].flag - SKILL_FLAG_REPLACED_LV_0) == 0 )
@@ -622,9 +617,9 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
}
if( count )
{
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -641,11 +636,11 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
}
}
- if(diff == 1)
- { //Save friends
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", friend_db, char_id) )
+ if(diff == 1) {
+ //Save friends
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", friend_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
@@ -663,9 +658,9 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
}
if( count )
{
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -687,15 +682,15 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
}
}
if(diff) {
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
} else
strcat(save_status, " hotkeys");
}
#endif
-
+
StrBuf->Destroy(&buf);
if (save_status[0]!='\0' && save_log)
ShowInfo("Saved char %d - %s:%s.\n", char_id, p->name, save_status);
@@ -705,7 +700,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
}
/// Saves an array of 'item' entries into the specified table.
-int memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch)
+int char_memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch)
{
StringBuf buf;
SqlStmt* stmt;
@@ -736,11 +731,11 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
StrBuf->Init(&buf);
StrBuf->AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `bound`");
- for( j = 0; j < MAX_SLOTS; ++j )
+ for( j = 0; j < MAX_SLOTS; ++j )
StrBuf->Printf(&buf, ", `card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `%s`='%d'", tablename, selectoption, id);
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SQL->StmtExecute(stmt) )
{
@@ -750,6 +745,7 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
return 1;
}
+ memset(&item, 0, sizeof(item));
SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &item.id, 0, NULL, NULL);
SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &item.nameid, 0, NULL, NULL);
SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &item.amount, 0, NULL, NULL);
@@ -759,7 +755,7 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &item.attribute, 0, NULL, NULL);
SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &item.expire_time, 0, NULL, NULL);
SQL->StmtBindColumn(stmt, 8, SQLDT_UCHAR, &item.bound, 0, NULL, NULL);
- for( j = 0; j < MAX_SLOTS; ++j )
+ for( j = 0; j < MAX_SLOTS; ++j )
SQL->StmtBindColumn(stmt, 9+j, SQLDT_SHORT, &item.card[j], 0, NULL, NULL);
// bit array indicating which inventory items have already been matched
@@ -776,33 +772,34 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
continue;
if( items[i].nameid == item.nameid
- && items[i].card[0] == item.card[0]
- && items[i].card[2] == item.card[2]
- && items[i].card[3] == item.card[3]
- ) { //They are the same item.
+ && items[i].card[0] == item.card[0]
+ && items[i].card[2] == item.card[2]
+ && items[i].card[3] == item.card[3]
+ ) {
+ //They are the same item.
ARR_FIND( 0, MAX_SLOTS, j, items[i].card[j] != item.card[j] );
- if( j == MAX_SLOTS &&
- items[i].amount == item.amount &&
- items[i].equip == item.equip &&
- items[i].identify == item.identify &&
- items[i].refine == item.refine &&
- items[i].attribute == item.attribute &&
- items[i].expire_time == item.expire_time &&
- items[i].bound == item.bound )
- ; //Do nothing.
- else
- {
+ if( j == MAX_SLOTS
+ && items[i].amount == item.amount
+ && items[i].equip == item.equip
+ && items[i].identify == item.identify
+ && items[i].refine == item.refine
+ && items[i].attribute == item.attribute
+ && items[i].expire_time == item.expire_time
+ && items[i].bound == item.bound
+ ) {
+ ; //Do nothing.
+ } else {
// update all fields.
StrBuf->Clear(&buf);
StrBuf->Printf(&buf, "UPDATE `%s` SET `amount`='%d', `equip`='%d', `identify`='%d', `refine`='%d',`attribute`='%d', `expire_time`='%u', `bound`='%d'",
tablename, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].bound);
- for( j = 0; j < MAX_SLOTS; ++j )for( j = 0; j < MAX_SLOTS; ++j )
+ for( j = 0; j < MAX_SLOTS; ++j )for( j = 0; j < MAX_SLOTS; ++j )
StrBuf->Printf(&buf, ", `card%d`=%d", j, items[i].card[j]);
- StrBuf->Printf(&buf, " WHERE `id`='%d' LIMIT 1", item.id);
+ StrBuf->Printf(&buf, " WHERE `id`='%d' LIMIT 1", item.id);
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -813,9 +810,9 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
}
if( !found )
{// Item not present in inventory, remove it.
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", tablename, item.id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", tablename, item.id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -824,7 +821,7 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
StrBuf->Clear(&buf);
StrBuf->Printf(&buf, "INSERT INTO `%s`(`%s`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `bound`, `unique_id`", tablename, selectoption);
- for( j = 0; j < MAX_SLOTS; ++j )
+ for( j = 0; j < MAX_SLOTS; ++j )
StrBuf->Printf(&buf, ", `card%d`", j);
StrBuf->AppendStr(&buf, ") VALUES ");
@@ -843,14 +840,14 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
StrBuf->Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%u', '%d', '%"PRIu64"'",
id, items[i].nameid, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].bound, items[i].unique_id);
- for( j = 0; j < MAX_SLOTS; ++j )
+ for( j = 0; j < MAX_SLOTS; ++j )
StrBuf->Printf(&buf, ", '%d'", items[i].card[j]);
StrBuf->AppendStr(&buf, ")");
}
- if( found && SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
+ if( found && SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
@@ -859,9 +856,9 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
return errors;
}
-/* pretty much a copy of memitemdata_to_sql except it handles inventory_db exclusively,
+/* pretty much a copy of chr->memitemdata_to_sql except it handles inventory_db exclusively,
* - this is required because inventory db is the only one with the 'favorite' column. */
-int inventory_to_sql(const struct item items[], int max, int id) {
+int char_inventory_to_sql(const struct item items[], int max, int id) {
StringBuf buf;
SqlStmt* stmt;
int i;
@@ -879,11 +876,11 @@ int inventory_to_sql(const struct item items[], int max, int id) {
StrBuf->Init(&buf);
StrBuf->AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `favorite`, `bound`");
- for( j = 0; j < MAX_SLOTS; ++j )
+ for( j = 0; j < MAX_SLOTS; ++j )
StrBuf->Printf(&buf, ", `card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`='%d'", inventory_db, id);
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SQL->StmtExecute(stmt) )
{
@@ -893,6 +890,7 @@ int inventory_to_sql(const struct item items[], int max, int id) {
return 1;
}
+ memset(&item, 0, sizeof(item));
SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &item.id, 0, NULL, NULL);
SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &item.nameid, 0, NULL, NULL);
SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &item.amount, 0, NULL, NULL);
@@ -903,7 +901,7 @@ int inventory_to_sql(const struct item items[], int max, int id) {
SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &item.expire_time, 0, NULL, NULL);
SQL->StmtBindColumn(stmt, 8, SQLDT_CHAR, &item.favorite, 0, NULL, NULL);
SQL->StmtBindColumn(stmt, 9, SQLDT_UCHAR, &item.bound, 0, NULL, NULL);
- for( j = 0; j < MAX_SLOTS; ++j )
+ for( j = 0; j < MAX_SLOTS; ++j )
SQL->StmtBindColumn(stmt, 10+j, SQLDT_SHORT, &item.card[j], 0, NULL, NULL);
// bit array indicating which inventory items have already been matched
@@ -918,32 +916,34 @@ int inventory_to_sql(const struct item items[], int max, int id) {
continue;
if( items[i].nameid == item.nameid
- && items[i].card[0] == item.card[0]
- && items[i].card[2] == item.card[2]
- && items[i].card[3] == item.card[3]
- ) { //They are the same item.
+ && items[i].card[0] == item.card[0]
+ && items[i].card[2] == item.card[2]
+ && items[i].card[3] == item.card[3]
+ ) {
+ //They are the same item.
ARR_FIND( 0, MAX_SLOTS, j, items[i].card[j] != item.card[j] );
- if( j == MAX_SLOTS &&
- items[i].amount == item.amount &&
- items[i].equip == item.equip &&
- items[i].identify == item.identify &&
- items[i].refine == item.refine &&
- items[i].attribute == item.attribute &&
- items[i].expire_time == item.expire_time &&
- items[i].favorite == item.favorite &&
- items[i].bound == item.bound )
- ; //Do nothing.
- else {
+ if( j == MAX_SLOTS
+ && items[i].amount == item.amount
+ && items[i].equip == item.equip
+ && items[i].identify == item.identify
+ && items[i].refine == item.refine
+ && items[i].attribute == item.attribute
+ && items[i].expire_time == item.expire_time
+ && items[i].favorite == item.favorite
+ && items[i].bound == item.bound
+ ) {
+ ; //Do nothing.
+ } else {
// update all fields.
StrBuf->Clear(&buf);
StrBuf->Printf(&buf, "UPDATE `%s` SET `amount`='%d', `equip`='%d', `identify`='%d', `refine`='%d',`attribute`='%d', `expire_time`='%u', `favorite`='%d', `bound`='%d'",
- inventory_db, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].favorite, items[i].bound);
- for( j = 0; j < MAX_SLOTS; ++j )
- StrBuf->Printf(&buf, ", `card%d`=%d", j, items[i].card[j]);
+ inventory_db, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].favorite, items[i].bound);
+ for( j = 0; j < MAX_SLOTS; ++j )
+ StrBuf->Printf(&buf, ", `card%d`=%d", j, items[i].card[j]);
StrBuf->Printf(&buf, " WHERE `id`='%d' LIMIT 1", item.id);
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) ) {
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -953,8 +953,8 @@ int inventory_to_sql(const struct item items[], int max, int id) {
}
}
if( !found ) {// Item not present in inventory, remove it.
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", inventory_db, item.id) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", inventory_db, item.id) ) {
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -963,7 +963,7 @@ int inventory_to_sql(const struct item items[], int max, int id) {
StrBuf->Clear(&buf);
StrBuf->Printf(&buf, "INSERT INTO `%s` (`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `favorite`, `bound`, `unique_id`", inventory_db);
- for( j = 0; j < MAX_SLOTS; ++j )
+ for( j = 0; j < MAX_SLOTS; ++j )
StrBuf->Printf(&buf, ", `card%d`", j);
StrBuf->AppendStr(&buf, ") VALUES ");
@@ -981,13 +981,13 @@ int inventory_to_sql(const struct item items[], int max, int id) {
StrBuf->Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%u', '%d', '%d', '%"PRIu64"'",
id, items[i].nameid, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].favorite, items[i].bound, items[i].unique_id);
- for( j = 0; j < MAX_SLOTS; ++j )
+ for( j = 0; j < MAX_SLOTS; ++j )
StrBuf->Printf(&buf, ", '%d'", items[i].card[j]);
StrBuf->AppendStr(&buf, ")");
}
- if( found && SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) ) {
- Sql_ShowDebug(sql_handle);
+ if( found && SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) ) {
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
@@ -997,20 +997,18 @@ int inventory_to_sql(const struct item items[], int max, int id) {
return errors;
}
-
-int mmo_char_tobuf(uint8* buf, struct mmo_charstatus* p);
-
//=====================================================================================================
// Loads the basic character rooster for the given account. Returns total buffer used.
-int mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
+int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
{
SqlStmt* stmt;
struct mmo_charstatus p;
int j = 0, i;
char last_map[MAP_NAME_LENGTH_EXT];
time_t unban_time = 0;
+ char sex[2];
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( stmt == NULL ) {
SqlStmt_ShowDebug(stmt);
return 0;
@@ -1021,68 +1019,80 @@ int mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
sd->found_char[i] = -1;
sd->unban_time[i] = 0;
}
-
+
// read char data
- if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT "
+ if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT "
"`char_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`,"
"`str`,`agi`,`vit`,`int`,`dex`,`luk`,`max_hp`,`hp`,`max_sp`,`sp`,"
"`status_point`,`skill_point`,`option`,`karma`,`manner`,`hair`,`hair_color`,"
"`clothes_color`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,`last_map`,`rename`,`delete_date`,"
- "`robe`,`slotchange`,`unban_time`"
+ "`robe`,`slotchange`,`unban_time`,`sex`"
" FROM `%s` WHERE `account_id`='%d' AND `char_num` < '%d'", char_db, sd->account_id, MAX_CHARS)
- || SQL_ERROR == SQL->StmtExecute(stmt)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p.char_id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR, &p.slot, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_STRING, &p.name, sizeof(p.name), NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_SHORT, &p.class_, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_UINT, &p.base_level, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_UINT, &p.job_level, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT, &p.base_exp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p.job_exp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_INT, &p.zeny, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_SHORT, &p.str, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_SHORT, &p.agi, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_SHORT, &p.vit, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 12, SQLDT_SHORT, &p.int_, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 13, SQLDT_SHORT, &p.dex, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 14, SQLDT_SHORT, &p.luk, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 15, SQLDT_INT, &p.max_hp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 16, SQLDT_INT, &p.hp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p.max_sp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p.sp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_UINT, &p.status_point, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p.skill_point, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p.option, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UCHAR, &p.karma, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_SHORT, &p.manner, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 24, SQLDT_SHORT, &p.hair, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 25, SQLDT_SHORT, &p.hair_color, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_SHORT, &p.weapon, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.shield, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.head_top, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_USHORT, &p.rename, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_UINT32, &p.delete_date, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p.robe, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_USHORT, &p.slotchange, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_LONG, &unban_time, 0, NULL, NULL)
- )
- {
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p.char_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR, &p.slot, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_STRING, &p.name, sizeof(p.name), NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_SHORT, &p.class_, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_UINT, &p.base_level, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_UINT, &p.job_level, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT, &p.base_exp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p.job_exp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_INT, &p.zeny, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_SHORT, &p.str, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_SHORT, &p.agi, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_SHORT, &p.vit, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 12, SQLDT_SHORT, &p.int_, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 13, SQLDT_SHORT, &p.dex, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 14, SQLDT_SHORT, &p.luk, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 15, SQLDT_INT, &p.max_hp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 16, SQLDT_INT, &p.hp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p.max_sp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p.sp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_UINT, &p.status_point, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p.skill_point, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p.option, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UCHAR, &p.karma, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_SHORT, &p.manner, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 24, SQLDT_SHORT, &p.hair, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 25, SQLDT_SHORT, &p.hair_color, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_SHORT, &p.weapon, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.shield, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.head_top, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_USHORT, &p.rename, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_UINT32, &p.delete_date, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p.robe, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_USHORT, &p.slotchange, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_LONG, &unban_time, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_ENUM, &sex, sizeof(sex), NULL, NULL)
+ ) {
SqlStmt_ShowDebug(stmt);
SQL->StmtFree(stmt);
return 0;
}
-
+
for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SQL->StmtNextRow(stmt); i++ ) {
p.last_point.map = mapindex->name2id(last_map);
sd->found_char[p.slot] = p.char_id;
sd->unban_time[p.slot] = unban_time;
- j += mmo_char_tobuf(WBUFP(buf, j), &p);
+ switch( sex[0] ) {
+ case 'M':
+ p.sex = 1;
+ break;
+ case 'F':
+ p.sex = 0;
+ break;
+ case 'U':
+ default:
+ p.sex = 99;
+ break;
+ }
+ j += chr->mmo_char_tobuf(WBUFP(buf, j), &p);
}
-
+
memset(sd->new_name,0,sizeof(sd->new_name));
SQL->StmtFree(stmt);
@@ -1090,7 +1100,7 @@ int mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
}
//=====================================================================================================
-int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything)
+int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything)
{
int i,j;
char t_msg[128] = "";
@@ -1110,12 +1120,13 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
#endif
unsigned int opt;
int account_id;
+ char sex[2];
memset(p, 0, sizeof(struct mmo_charstatus));
if (save_log) ShowInfo("Char load request (%d)\n", char_id);
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( stmt == NULL )
{
SqlStmt_ShowDebug(stmt);
@@ -1123,74 +1134,74 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
}
// read char data
- if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT "
+ if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT "
"`char_id`,`account_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`,"
"`str`,`agi`,`vit`,`int`,`dex`,`luk`,`max_hp`,`hp`,`max_sp`,`sp`,"
"`status_point`,`skill_point`,`option`,`karma`,`manner`,`party_id`,`guild_id`,`pet_id`,`homun_id`,`elemental_id`,`hair`,"
"`hair_color`,`clothes_color`,`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`"
+ "`char_opt`,`font`,`uniqueitem_counter`,`sex`"
" FROM `%s` WHERE `char_id`=? LIMIT 1", char_db)
- || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SQL->StmtExecute(stmt)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p->char_id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &p->account_id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UCHAR, &p->slot, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_STRING, &p->name, sizeof(p->name), NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_SHORT, &p->class_, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_UINT, &p->base_level, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT, &p->job_level, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p->base_exp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_UINT, &p->job_exp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_INT, &p->zeny, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_SHORT, &p->str, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_SHORT, &p->agi, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 12, SQLDT_SHORT, &p->vit, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 13, SQLDT_SHORT, &p->int_, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 14, SQLDT_SHORT, &p->dex, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 15, SQLDT_SHORT, &p->luk, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 16, SQLDT_INT, &p->max_hp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p->hp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p->max_sp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_INT, &p->sp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p->status_point, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p->skill_point, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UINT, &p->option, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_UCHAR, &p->karma, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 24, SQLDT_SHORT, &p->manner, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 25, SQLDT_INT, &p->party_id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_INT, &p->guild_id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_INT, &p->pet_id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_INT, &p->hom_id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_INT, &p->ele_id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p->hair, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_SHORT, &p->weapon, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->shield, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->head_top, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 39, SQLDT_SHORT, &p->last_point.x, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 40, SQLDT_SHORT, &p->last_point.y, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 41, SQLDT_STRING, &save_map, sizeof(save_map), NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 42, SQLDT_SHORT, &p->save_point.x, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 43, SQLDT_SHORT, &p->save_point.y, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 44, SQLDT_INT, &p->partner_id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 45, SQLDT_INT, &p->father, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 46, SQLDT_INT, &p->mother, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 47, SQLDT_INT, &p->child, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 48, SQLDT_INT, &p->fame, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 49, SQLDT_USHORT, &p->rename, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 50, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 51, SQLDT_SHORT, &p->robe, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 52, SQLDT_USHORT, &p->slotchange, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 53, SQLDT_UINT, &opt, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 54, SQLDT_UCHAR, &p->font, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 55, SQLDT_UINT, &p->uniqueitem_counter, 0, NULL, NULL)
- )
- {
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p->char_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &p->account_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UCHAR, &p->slot, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_STRING, &p->name, sizeof(p->name), NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_SHORT, &p->class_, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_UINT, &p->base_level, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT, &p->job_level, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p->base_exp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_UINT, &p->job_exp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_INT, &p->zeny, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_SHORT, &p->str, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_SHORT, &p->agi, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 12, SQLDT_SHORT, &p->vit, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 13, SQLDT_SHORT, &p->int_, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 14, SQLDT_SHORT, &p->dex, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 15, SQLDT_SHORT, &p->luk, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 16, SQLDT_INT, &p->max_hp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p->hp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p->max_sp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_INT, &p->sp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p->status_point, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p->skill_point, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UINT, &p->option, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_UCHAR, &p->karma, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 24, SQLDT_SHORT, &p->manner, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 25, SQLDT_INT, &p->party_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_INT, &p->guild_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_INT, &p->pet_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_INT, &p->hom_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_INT, &p->ele_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p->hair, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_SHORT, &p->weapon, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->shield, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->head_top, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 39, SQLDT_SHORT, &p->last_point.x, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 40, SQLDT_SHORT, &p->last_point.y, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 41, SQLDT_STRING, &save_map, sizeof(save_map), NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 42, SQLDT_SHORT, &p->save_point.x, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 43, SQLDT_SHORT, &p->save_point.y, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 44, SQLDT_INT, &p->partner_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 45, SQLDT_INT, &p->father, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 46, SQLDT_INT, &p->mother, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 47, SQLDT_INT, &p->child, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 48, SQLDT_INT, &p->fame, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 49, SQLDT_USHORT, &p->rename, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 50, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 51, SQLDT_SHORT, &p->robe, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 52, SQLDT_USHORT, &p->slotchange, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 53, SQLDT_UINT, &opt, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 54, SQLDT_UCHAR, &p->font, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 55, SQLDT_UINT, &p->uniqueitem_counter, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 56, SQLDT_ENUM, &sex, sizeof(sex), NULL, NULL)
+ ) {
SqlStmt_ShowDebug(stmt);
SQL->StmtFree(stmt);
return 0;
@@ -1201,24 +1212,37 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
SQL->StmtFree(stmt);
return 0;
}
-
+
+ switch( sex[0] ) {
+ case 'M':
+ p->sex = 1;
+ break;
+ case 'F':
+ p->sex = 0;
+ break;
+ case 'U':
+ default:
+ p->sex = 99;
+ break;
+ }
+
account_id = p->account_id;
-
+
p->last_point.map = mapindex->name2id(last_map);
p->save_point.map = mapindex->name2id(save_map);
if( p->last_point.map == 0 ) {
- p->last_point.map = (unsigned short)strdb_iget(mapindex->db, MAP_DEFAULT);
- p->last_point.x = MAP_DEFAULT_X;
- p->last_point.y = MAP_DEFAULT_Y;
+ p->last_point.map = (unsigned short)strdb_iget(mapindex->db, mapindex->default_map);
+ p->last_point.x = mapindex->default_x;
+ p->last_point.y = mapindex->default_y;
}
-
+
if( p->save_point.map == 0 ) {
- p->save_point.map = (unsigned short)strdb_iget(mapindex->db, MAP_DEFAULT);
- p->save_point.x = MAP_DEFAULT_X;
- p->save_point.y = MAP_DEFAULT_Y;
+ p->save_point.map = (unsigned short)strdb_iget(mapindex->db, mapindex->default_map);
+ p->save_point.x = mapindex->default_x;
+ p->save_point.y = mapindex->default_y;
}
-
+
strcat(t_msg, " status");
if (!load_everything) // For quick selection of data when displaying the char menu
@@ -1229,12 +1253,14 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
//read memo data
//`memo` (`memo_id`,`char_id`,`map`,`x`,`y`)
- if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `map`,`x`,`y` FROM `%s` WHERE `char_id`=? ORDER by `memo_id` LIMIT %d", memo_db, MAX_MEMOPOINTS)
- || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SQL->StmtExecute(stmt)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_STRING, &point_map, sizeof(point_map), NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_point.x, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_point.y, 0, NULL, NULL) )
+ memset(&tmp_point, 0, sizeof(tmp_point));
+ if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `map`,`x`,`y` FROM `%s` WHERE `char_id`=? ORDER by `memo_id` LIMIT %d", memo_db, MAX_MEMOPOINTS)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_STRING, &point_map, sizeof(point_map), NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_point.x, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_point.y, 0, NULL, NULL)
+ )
SqlStmt_ShowDebug(stmt);
for( i = 0; i < MAX_MEMOPOINTS && SQL_SUCCESS == SQL->StmtNextRow(stmt); ++i ) {
@@ -1245,27 +1271,29 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
//read inventory
//`inventory` (`id`,`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`, `expire_time`, `favorite`, `bound`, `unique_id`)
- StrBuf->Init(&buf);
+ StrBuf->Init(&buf);
StrBuf->AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `favorite`, `bound`, `unique_id`");
- for( i = 0; i < MAX_SLOTS; ++i )
+ for( i = 0; i < MAX_SLOTS; ++i )
StrBuf->Printf(&buf, ", `card%d`", i);
StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", inventory_db, MAX_INVENTORY);
- if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
- || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SQL->StmtExecute(stmt)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_UINT, &tmp_item.equip, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_CHAR, &tmp_item.favorite, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_UCHAR, &tmp_item.bound, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_UINT64, &tmp_item.unique_id, 0, NULL, NULL) )
- SqlStmt_ShowDebug(stmt);
+ memset(&tmp_item, 0, sizeof(tmp_item));
+ if (SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_UINT, &tmp_item.equip, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_CHAR, &tmp_item.favorite, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_UCHAR, &tmp_item.bound, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_UINT64, &tmp_item.unique_id, 0, NULL, NULL)
+ )
+ SqlStmt_ShowDebug(stmt);
for( i = 0; i < MAX_SLOTS; ++i )
if( SQL_ERROR == SQL->StmtBindColumn(stmt, 11+i, SQLDT_SHORT, &tmp_item.card[i], 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
@@ -1277,27 +1305,28 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
//read cart
//`cart_inventory` (`id`,`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`, expire_time`, `bound`, `unique_id`)
- StrBuf->Clear(&buf);
+ StrBuf->Clear(&buf);
StrBuf->AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `bound`, `unique_id`");
- for( j = 0; j < MAX_SLOTS; ++j )
+ for( j = 0; j < MAX_SLOTS; ++j )
StrBuf->Printf(&buf, ", `card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", cart_db, MAX_CART);
memset(&tmp_item, 0, sizeof(tmp_item));
- if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
- || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SQL->StmtExecute(stmt)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_UINT, &tmp_item.equip, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_UCHAR, &tmp_item.bound, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_UINT64, &tmp_item.unique_id, 0, NULL, NULL) )
- SqlStmt_ShowDebug(stmt);
+ if (SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_UINT, &tmp_item.equip, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_UCHAR, &tmp_item.bound, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_UINT64, &tmp_item.unique_id, 0, NULL, NULL)
+ )
+ SqlStmt_ShowDebug(stmt);
for( i = 0; i < MAX_SLOTS; ++i )
if( SQL_ERROR == SQL->StmtBindColumn(stmt, 10+i, SQLDT_SHORT, &tmp_item.card[i], 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
@@ -1307,19 +1336,21 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
strcat(t_msg, " cart");
//read storage
- storage_fromsql(p->account_id, &p->storage);
+ inter_storage->fromsql(p->account_id, &p->storage);
strcat(t_msg, " storage");
//read skill
//`skill` (`char_id`, `id`, `lv`)
- if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `id`, `lv`,`flag` FROM `%s` WHERE `char_id`=? LIMIT %d", skill_db, MAX_SKILL)
- || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SQL->StmtExecute(stmt)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_USHORT, &tmp_skill.id , 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR , &tmp_skill.lv , 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UCHAR , &tmp_skill.flag, 0, NULL, NULL) )
+ memset(&tmp_skill, 0, sizeof(tmp_skill));
+ if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `id`, `lv`,`flag` FROM `%s` WHERE `char_id`=? LIMIT %d", skill_db, MAX_SKILL)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_USHORT, &tmp_skill.id , 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR , &tmp_skill.lv , 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UCHAR , &tmp_skill.flag, 0, NULL, NULL)
+ )
SqlStmt_ShowDebug(stmt);
-
+
if( tmp_skill.flag != SKILL_FLAG_PERM_GRANTED )
tmp_skill.flag = SKILL_FLAG_PERMANENT;
@@ -1327,18 +1358,19 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
if( skillid2idx[tmp_skill.id] )
memcpy(&p->skill[skillid2idx[tmp_skill.id]], &tmp_skill, sizeof(tmp_skill));
else
- ShowWarning("mmo_char_fromsql: ignoring invalid skill (id=%u,lv=%u) of character %s (AID=%d,CID=%d)\n", tmp_skill.id, tmp_skill.lv, p->name, p->account_id, p->char_id);
+ ShowWarning("chr->mmo_char_fromsql: ignoring invalid skill (id=%u,lv=%u) of character %s (AID=%d,CID=%d)\n", tmp_skill.id, tmp_skill.lv, p->name, p->account_id, p->char_id);
}
strcat(t_msg, " skills");
//read friends
//`friends` (`char_id`, `friend_account`, `friend_id`)
- if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT c.`account_id`, c.`char_id`, c.`name` FROM `%s` c LEFT JOIN `%s` f ON f.`friend_account` = c.`account_id` AND f.`friend_id` = c.`char_id` WHERE f.`char_id`=? LIMIT %d", char_db, friend_db, MAX_FRIENDS)
- || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SQL->StmtExecute(stmt)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_friend.account_id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &tmp_friend.char_id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_STRING, &tmp_friend.name, sizeof(tmp_friend.name), NULL, NULL) )
+ memset(&tmp_friend, 0, sizeof(tmp_friend));
+ if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT c.`account_id`, c.`char_id`, c.`name` FROM `%s` c LEFT JOIN `%s` f ON f.`friend_account` = c.`account_id` AND f.`friend_id` = c.`char_id` WHERE f.`char_id`=? LIMIT %d", char_db, friend_db, MAX_FRIENDS)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_friend.account_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &tmp_friend.char_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_STRING, &tmp_friend.name, sizeof(tmp_friend.name), NULL, NULL) )
SqlStmt_ShowDebug(stmt);
for( i = 0; i < MAX_FRIENDS && SQL_SUCCESS == SQL->StmtNextRow(stmt); ++i )
@@ -1348,13 +1380,14 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
#ifdef HOTKEY_SAVING
//read hotkeys
//`hotkey` (`char_id`, `hotkey`, `type`, `itemskill_id`, `skill_lvl`
- if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `hotkey`, `type`, `itemskill_id`, `skill_lvl` FROM `%s` WHERE `char_id`=?", hotkey_db)
- || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SQL->StmtExecute(stmt)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &hotkey_num, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR, &tmp_hotkey.type, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UINT, &tmp_hotkey.id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT, &tmp_hotkey.lv, 0, NULL, NULL) )
+ memset(&tmp_hotkey, 0, sizeof(tmp_hotkey));
+ if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `hotkey`, `type`, `itemskill_id`, `skill_lvl` FROM `%s` WHERE `char_id`=?", hotkey_db)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &hotkey_num, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR, &tmp_hotkey.type, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UINT, &tmp_hotkey.id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT, &tmp_hotkey.lv, 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
while( SQL_SUCCESS == SQL->StmtNextRow(stmt) )
@@ -1362,32 +1395,32 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
if( hotkey_num >= 0 && hotkey_num < MAX_HOTKEYS )
memcpy(&p->hotkeys[hotkey_num], &tmp_hotkey, sizeof(tmp_hotkey));
else
- ShowWarning("mmo_char_fromsql: ignoring invalid hotkey (hotkey=%d,type=%u,id=%u,lv=%u) of character %s (AID=%d,CID=%d)\n", hotkey_num, tmp_hotkey.type, tmp_hotkey.id, tmp_hotkey.lv, p->name, p->account_id, p->char_id);
+ ShowWarning("chr->mmo_char_fromsql: ignoring invalid hotkey (hotkey=%d,type=%u,id=%u,lv=%u) of character %s (AID=%d,CID=%d)\n", hotkey_num, tmp_hotkey.type, tmp_hotkey.id, tmp_hotkey.lv, p->name, p->account_id, p->char_id);
}
strcat(t_msg, " hotkeys");
#endif
/* Mercenary Owner DataBase */
- mercenary_owner_fromsql(char_id, p);
+ inter_mercenary->owner_fromsql(char_id, p);
strcat(t_msg, " mercenary");
/* default */
p->mod_exp = p->mod_drop = p->mod_death = 100;
-
+
//`account_data` (`account_id`,`bank_vault`,`base_exp`,`base_drop`,`base_death`)
- if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `bank_vault`,`base_exp`,`base_drop`,`base_death` FROM `%s` WHERE `account_id`=? LIMIT 1", account_data_db)
- || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &account_id, 0)
- || SQL_ERROR == SQL->StmtExecute(stmt)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p->bank_vault, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_USHORT, &p->mod_exp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_USHORT, &p->mod_drop, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT, &p->mod_death, 0, NULL, NULL) )
+ if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `bank_vault`,`base_exp`,`base_drop`,`base_death` FROM `%s` WHERE `account_id`=? LIMIT 1", account_data_db)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &account_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p->bank_vault, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_USHORT, &p->mod_exp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_USHORT, &p->mod_drop, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT, &p->mod_death, 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
-
+
if( SQL_SUCCESS == SQL->StmtNextRow(stmt) )
strcat(t_msg, " accdata");
- if (save_log) ShowInfo("Loaded char (%d - %s): %s\n", char_id, p->name, t_msg); //ok. all data load successfully!
+ if (save_log) ShowInfo("Loaded char (%d - %s): %s\n", char_id, p->name, t_msg); //ok. all data load successfully!
SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
@@ -1396,16 +1429,16 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
p->allow_party = true;
if( opt & OPT_SHOW_EQUIP )
p->show_equip = true;
-
- cp = idb_ensure(char_db_, char_id, create_charstatus);
+
+ cp = idb_ensure(chr->char_db_, char_id, chr->create_charstatus);
memcpy(cp, p, sizeof(struct mmo_charstatus));
return 1;
}
//==========================================================================================================
-int mmo_char_sql_init(void)
+int char_mmo_char_sql_init(void)
{
- char_db_= idb_alloc(DB_OPT_RELEASE_DATA);
+ chr->char_db_= idb_alloc(DB_OPT_RELEASE_DATA);
//the 'set offline' part is now in check_login_conn ...
//if the server connects to loginserver
@@ -1414,63 +1447,63 @@ int mmo_char_sql_init(void)
// Force all users offline in sql when starting char-server
// (useful when servers crashes and don't clean the database)
- set_all_offline_sql();
+ chr->set_all_offline_sql();
return 0;
}
+
/* [Ind/Hercules] - special thanks to Yommy for providing the packet structure/data */
-bool char_slotchange(struct char_session_data *sd, int fd, unsigned short from, unsigned short to) {
+bool char_char_slotchange(struct char_session_data *sd, int fd, unsigned short from, unsigned short to) {
struct mmo_charstatus char_dat;
int from_id = 0;
if( from > MAX_CHARS || to > MAX_CHARS || ( sd->char_slots && to > sd->char_slots ) || sd->found_char[from] <= 0 )
return false;
- if( !mmo_char_fromsql(sd->found_char[from], &char_dat, false) ) // Only the short data is needed.
+ if( !chr->mmo_char_fromsql(sd->found_char[from], &char_dat, false) ) // Only the short data is needed.
return false;
if( char_dat.slotchange == 0 )
return false;
from_id = sd->found_char[from];
-
+
if( sd->found_char[to] > 0 ) {/* moving char to occupied slot */
bool result = false;
/* update both at once */
- if( SQL_SUCCESS != SQL->QueryStr(sql_handle, "START TRANSACTION")
- || SQL_SUCCESS != SQL->Query(sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d' LIMIT 1", char_db, from, sd->found_char[to])
- || SQL_SUCCESS != SQL->Query(sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d' LIMIT 1", char_db, to, sd->found_char[from]) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_SUCCESS != SQL->QueryStr(inter->sql_handle, "START TRANSACTION")
+ || SQL_SUCCESS != SQL->Query(inter->sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d' LIMIT 1", char_db, from, sd->found_char[to])
+ || SQL_SUCCESS != SQL->Query(inter->sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d' LIMIT 1", char_db, to, sd->found_char[from]) )
+ Sql_ShowDebug(inter->sql_handle);
else
result = true;
-
- if( SQL_ERROR == SQL->QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") ) {
- Sql_ShowDebug(sql_handle);
+
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") ) {
+ Sql_ShowDebug(inter->sql_handle);
result = false;
}
if( !result )
return false;
-
} else {/* slot is free. */
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d' LIMIT 1", char_db, to, sd->found_char[from] ) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d' LIMIT 1", char_db, to, sd->found_char[from] ) ) {
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
}
-
+
/* update count */
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `slotchange`=`slotchange`-1 WHERE `char_id`='%d' LIMIT 1", char_db, from_id ) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `slotchange`=`slotchange`-1 WHERE `char_id`='%d' LIMIT 1", char_db, from_id ) ) {
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
-
+
return true;
}
//-----------------------------------
// Function to change character's names
//-----------------------------------
-int rename_char_sql(struct char_session_data *sd, int char_id)
+int char_rename_char_sql(struct char_session_data *sd, int char_id)
{
struct mmo_charstatus char_dat;
char esc_name[NAME_LENGTH*2+1];
@@ -1478,30 +1511,30 @@ int rename_char_sql(struct char_session_data *sd, int char_id)
if( sd->new_name[0] == 0 ) // Not ready for rename
return 2;
- if( !mmo_char_fromsql(char_id, &char_dat, false) ) // Only the short data is needed.
+ if( !chr->mmo_char_fromsql(char_id, &char_dat, false) ) // Only the short data is needed.
return 2;
if( char_dat.rename == 0 )
return 1;
- SQL->EscapeStringLen(sql_handle, esc_name, sd->new_name, strnlen(sd->new_name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, sd->new_name, strnlen(sd->new_name, NAME_LENGTH));
// check if the char exist
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` LIKE '%s' LIMIT 1", char_db, esc_name) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT 1 FROM `%s` WHERE `name` LIKE '%s' LIMIT 1", char_db, esc_name) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 4;
}
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `name` = '%s', `rename` = '%d' WHERE `char_id` = '%d'", char_db, esc_name, --char_dat.rename, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `name` = '%s', `rename` = '%d' WHERE `char_id` = '%d'", char_db, esc_name, --char_dat.rename, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 3;
}
// Change character's name into guild_db.
if( char_dat.guild_id )
- inter_guild_charname_changed(char_dat.guild_id, sd->account_id, char_id, sd->new_name);
+ inter_guild->charname_changed(char_dat.guild_id, sd->account_id, char_id, sd->new_name);
safestrncpy(char_dat.name, sd->new_name, NAME_LENGTH);
memset(sd->new_name,0,sizeof(sd->new_name));
@@ -1509,17 +1542,17 @@ int rename_char_sql(struct char_session_data *sd, int char_id)
// log change
if( log_char )
{
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
"VALUES (NOW(), '%s', '%d', '%d', '%d', '%s', '0', '0', '0', '0', '0', '0', '0', '0')",
charlog_db, "change char name", sd->account_id, char_dat.char_id, char_dat.slot, esc_name) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
return 0;
}
-int check_char_name(char * name, char * esc_name)
+int char_check_char_name(char * name, char * esc_name)
{
int i;
@@ -1554,17 +1587,17 @@ int check_char_name(char * name, char * esc_name)
return -5;
}
if( name_ignoring_case ) {
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT 1 FROM `%s` WHERE BINARY `name` = '%s' LIMIT 1", char_db, esc_name) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT 1 FROM `%s` WHERE BINARY `name` = '%s' LIMIT 1", char_db, esc_name) ) {
+ Sql_ShowDebug(inter->sql_handle);
return -2;
}
} else {
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) ) {
+ Sql_ShowDebug(inter->sql_handle);
return -2;
}
}
- if( SQL->NumRows(sql_handle) > 0 )
+ if( SQL->NumRows(inter->sql_handle) > 0 )
return -1; // name already exists
return 0;
@@ -1580,25 +1613,19 @@ int check_char_name(char * name, char * esc_name)
* -5: 'Symbols in Character Names are forbidden'
* char_id: Success
**/
-#if PACKETVER >= 20120307
-int make_new_char_sql(struct char_session_data* sd, char* name_, int slot, int hair_color, int hair_style) {
- int str = 1, agi = 1, vit = 1, int_ = 1, dex = 1, luk = 1;
-#else
-int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int agi, int vit, int int_, int dex, int luk, int slot, int hair_color, int hair_style) {
-#endif
-
+int char_make_new_char_sql(struct char_session_data* sd, char* name_, int str, int agi, int vit, int int_, int dex, int luk, int slot, int hair_color, int hair_style) {
char name[NAME_LENGTH];
char esc_name[NAME_LENGTH*2+1];
int char_id, flag, k, l;
safestrncpy(name, name_, NAME_LENGTH);
normalize_name(name,TRIM_CHARS);
- SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
- flag = check_char_name(name,esc_name);
+ flag = chr->check_char_name(name,esc_name);
if( flag < 0 )
return flag;
-
+
//check other inputs
#if PACKETVER >= 20120307
if(slot < 0 || slot >= sd->char_slots)
@@ -1620,41 +1647,41 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag
#if PACKETVER >= 20120307
//Insert the new char entry to the database
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`account_id`, `char_num`, `name`, `zeny`, `status_point`,`str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`,"
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` (`account_id`, `char_num`, `name`, `zeny`, `status_point`,`str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`,"
"`max_sp`, `sp`, `hair`, `hair_color`, `last_map`, `last_x`, `last_y`, `save_map`, `save_x`, `save_y`) VALUES ("
"'%d', '%d', '%s', '%d', '%d','%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d','%d', '%d','%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d')",
char_db, sd->account_id , slot, esc_name, start_zeny, 48, str, agi, vit, int_, dex, luk,
(40 * (100 + vit)/100) , (40 * (100 + vit)/100 ), (11 * (100 + int_)/100), (11 * (100 + int_)/100), hair_style, hair_color,
mapindex_id2name(start_point.map), start_point.x, start_point.y, mapindex_id2name(start_point.map), start_point.x, start_point.y) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return -2; //No, stop the procedure!
}
#else
//Insert the new char entry to the database
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`account_id`, `char_num`, `name`, `zeny`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`,"
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` (`account_id`, `char_num`, `name`, `zeny`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`,"
"`max_sp`, `sp`, `hair`, `hair_color`, `last_map`, `last_x`, `last_y`, `save_map`, `save_x`, `save_y`) VALUES ("
"'%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d','%d', '%d','%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d')",
char_db, sd->account_id , slot, esc_name, start_zeny, str, agi, vit, int_, dex, luk,
(40 * (100 + vit)/100) , (40 * (100 + vit)/100 ), (11 * (100 + int_)/100), (11 * (100 + int_)/100), hair_style, hair_color,
mapindex_id2name(start_point.map), start_point.x, start_point.y, mapindex_id2name(start_point.map), start_point.x, start_point.y) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return -2; //No, stop the procedure!
}
#endif
//Retrieve the newly auto-generated char id
- char_id = (int)SQL->LastInsertId(sql_handle);
+ char_id = (int)SQL->LastInsertId(inter->sql_handle);
if( !char_id )
return -2;
// Validation success, log result
if (log_char) {
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
"VALUES (NOW(), '%s', '%d', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
charlog_db, "make new char", sd->account_id, char_id, slot, esc_name, str, agi, vit, int_, dex, luk, hair_style, hair_color) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
//Give the char the default items
@@ -1662,21 +1689,21 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag
// FIXME: How to define if an item is stackable without having to lookup itemdb? [panikon]
if( start_items[k+2] == 1 )
{
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `identify`) VALUES ('%d', '%d', '%d', '%d')",
inventory_db, char_id, start_items[k], start_items[k + 1], 1) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
else if( start_items[k+2] == 0 )
{
// Non-stackable items should have their own entries (issue: 7279)
for( l = 0; l < start_items[k+1]; l++ )
{
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `identify`) VALUES ('%d', '%d', '%d', '%d')",
inventory_db, char_id, start_items[k], 1, 1)
)
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
}
}
@@ -1688,19 +1715,19 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag
/*----------------------------------------------------------------------------------------------------------*/
/* Divorce Players */
/*----------------------------------------------------------------------------------------------------------*/
-int divorce_char_sql(int partner_id1, int partner_id2)
+int char_divorce_char_sql(int partner_id1, int partner_id2)
{
unsigned char buf[64];
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `partner_id`='0' WHERE `char_id`='%d' OR `char_id`='%d' LIMIT 2", char_db, partner_id1, partner_id2) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE (`nameid`='%d' OR `nameid`='%d') AND (`char_id`='%d' OR `char_id`='%d') LIMIT 2", inventory_db, WEDDING_RING_M, WEDDING_RING_F, partner_id1, partner_id2) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `partner_id`='0' WHERE `char_id`='%d' OR `char_id`='%d' LIMIT 2", char_db, partner_id1, partner_id2) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE (`nameid`='%d' OR `nameid`='%d') AND (`char_id`='%d' OR `char_id`='%d') LIMIT 2", inventory_db, WEDDING_RING_M, WEDDING_RING_F, partner_id1, partner_id2) )
+ Sql_ShowDebug(inter->sql_handle);
WBUFW(buf,0) = 0x2b12;
WBUFL(buf,2) = partner_id1;
WBUFL(buf,6) = partner_id2;
- mapif_sendall(buf,10);
+ mapif->sendall(buf,10);
return 0;
}
@@ -1711,7 +1738,7 @@ int divorce_char_sql(int partner_id1, int partner_id2)
/* Returns 0 if successful
* Returns < 0 for error
*/
-int delete_char_sql(int char_id)
+int char_delete_char_sql(int char_id)
{
char name[NAME_LENGTH];
char esc_name[NAME_LENGTH*2+1]; //Name needs be escaped.
@@ -1719,30 +1746,30 @@ int delete_char_sql(int char_id)
char *data;
size_t len;
- if (SQL_ERROR == SQL->Query(sql_handle, "SELECT `name`,`account_id`,`party_id`,`guild_id`,`base_level`,`homun_id`,`partner_id`,`father`,`mother`,`elemental_id` FROM `%s` WHERE `char_id`='%d'", char_db, char_id))
- Sql_ShowDebug(sql_handle);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `name`,`account_id`,`party_id`,`guild_id`,`base_level`,`homun_id`,`partner_id`,`father`,`mother`,`elemental_id` FROM `%s` WHERE `char_id`='%d'", char_db, char_id))
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
- ShowError("delete_char_sql: Unable to fetch character data, deletion aborted.\n");
- SQL->FreeResult(sql_handle);
+ ShowError("chr->delete_char_sql: Unable to fetch character data, deletion aborted.\n");
+ SQL->FreeResult(inter->sql_handle);
return -1;
}
- SQL->GetData(sql_handle, 0, &data, &len); safestrncpy(name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 1, &data, NULL); account_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); party_id = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); guild_id = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); hom_id = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); partner_id = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); father_id = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); mother_id = atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, &len); safestrncpy(name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); party_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); guild_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); base_level = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); hom_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); partner_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); father_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); mother_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL);
elemental_id = atoi(data);
- SQL->EscapeStringLen(sql_handle, esc_name, name, min(len, NAME_LENGTH));
- SQL->FreeResult(sql_handle);
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, name, min(len, NAME_LENGTH));
+ SQL->FreeResult(inter->sql_handle);
//check for config char del condition [Lupus]
// TODO: Move this out to packet processing (0x68/0x1fb).
@@ -1755,135 +1782,135 @@ int delete_char_sql(int char_id)
/* Divorce [Wizputer] */
if( partner_id )
- divorce_char_sql(char_id, partner_id);
+ chr->divorce_char_sql(char_id, partner_id);
/* De-addopt [Zephyrus] */
if( father_id || mother_id )
{ // Char is Baby
unsigned char buf[64];
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `child`='0' WHERE `char_id`='%d' OR `char_id`='%d'", char_db, father_id, mother_id) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '410'AND (`char_id`='%d' OR `char_id`='%d')", skill_db, father_id, mother_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `child`='0' WHERE `char_id`='%d' OR `char_id`='%d'", char_db, father_id, mother_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `id` = '410'AND (`char_id`='%d' OR `char_id`='%d')", skill_db, father_id, mother_id) )
+ Sql_ShowDebug(inter->sql_handle);
WBUFW(buf,0) = 0x2b25;
WBUFL(buf,2) = father_id;
WBUFL(buf,6) = mother_id;
WBUFL(buf,10) = char_id; // Baby
- mapif_sendall(buf,14);
+ mapif->sendall(buf,14);
}
//Make the character leave the party [Skotlex]
if (party_id)
- inter_party_leave(party_id, account_id, char_id);
+ inter_party->leave(party_id, account_id, char_id);
/* delete char's pet */
//Delete the hatched pet if you have one...
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `incubate` = '0'", pet_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `incubate` = '0'", pet_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
//Delete all pets that are stored in eggs (inventory + cart)
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` USING `%s` JOIN `%s` ON `pet_id` = `card1`|`card2`<<16 WHERE `%s`.char_id = '%d' AND card0 = -256", pet_db, pet_db, inventory_db, inventory_db, char_id) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` USING `%s` JOIN `%s` ON `pet_id` = `card1`|`card2`<<16 WHERE `%s`.char_id = '%d' AND card0 = -256", pet_db, pet_db, cart_db, cart_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` USING `%s` JOIN `%s` ON `pet_id` = `card1`|`card2`<<16 WHERE `%s`.char_id = '%d' AND card0 = -256", pet_db, pet_db, inventory_db, inventory_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` USING `%s` JOIN `%s` ON `pet_id` = `card1`|`card2`<<16 WHERE `%s`.char_id = '%d' AND card0 = -256", pet_db, pet_db, cart_db, cart_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* remove homunculus */
if( hom_id )
- mapif_homunculus_delete(hom_id);
+ mapif->homunculus_delete(hom_id);
/* remove elemental */
if (elemental_id)
- mapif_elemental_delete(elemental_id);
+ mapif->elemental_delete(elemental_id);
/* remove mercenary data */
- mercenary_owner_delete(char_id);
+ inter_mercenary->owner_delete(char_id);
/* delete char's friends list */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", friend_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", friend_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* delete char from other's friend list */
//NOTE: Won't this cause problems for people who are already online? [Skotlex]
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `friend_id` = '%d'", friend_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `friend_id` = '%d'", friend_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
#ifdef HOTKEY_SAVING
/* delete hotkeys */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", hotkey_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", hotkey_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
#endif
/* delete inventory */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", inventory_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", inventory_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* delete cart inventory */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", cart_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", cart_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* delete memo areas */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* delete character registry */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_reg_str_db, char_id) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_reg_num_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_reg_str_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_reg_num_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* delete skills */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* delete mails (only received) */
- if (SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `dest_id`='%d'", mail_db, char_id))
- Sql_ShowDebug(sql_handle);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `dest_id`='%d'", mail_db, char_id))
+ Sql_ShowDebug(inter->sql_handle);
#ifdef ENABLE_SC_SAVING
/* status changes */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, account_id, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, account_id, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
#endif
/* delete character */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
else if( log_char ) {
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"INSERT INTO `%s`(`time`, `account_id`, `char_id`, `char_num`, `char_msg`, `name`)"
" VALUES (NOW(), '%d', '%d', '%d', 'Deleted character', '%s')",
charlog_db, account_id, char_id, 0, esc_name) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
- /* No need as we used inter_guild_leave [Skotlex]
+ /* No need as we used inter_guild->leave [Skotlex]
// Also delete info from guildtables.
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", guild_member_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", guild_member_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
*/
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `char_id` = '%d'", guild_db, char_id) )
- Sql_ShowDebug(sql_handle);
- else if( SQL->NumRows(sql_handle) > 0 )
- mapif_parse_BreakGuild(0,guild_id);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `guild_id` FROM `%s` WHERE `char_id` = '%d'", guild_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL->NumRows(inter->sql_handle) > 0 )
+ mapif->parse_BreakGuild(0,guild_id);
else if( guild_id )
- inter_guild_leave(guild_id, account_id, char_id);// Leave your guild.
+ inter_guild->leave(guild_id, account_id, char_id);// Leave your guild.
return 0;
}
//---------------------------------------------------------------------
// This function return the number of online players in all map-servers
//---------------------------------------------------------------------
-int count_users(void)
+int char_count_users(void)
{
int i, users;
users = 0;
- for(i = 0; i < ARRAYLENGTH(server); i++) {
- if (server[i].fd > 0) {
- users += server[i].users;
+ for(i = 0; i < ARRAYLENGTH(chr->server); i++) {
+ if (chr->server[i].fd > 0) {
+ users += chr->server[i].users;
}
}
return users;
@@ -1892,8 +1919,8 @@ int count_users(void)
// Writes char data to the buffer in the format used by the client.
// Used in packets 0x6b (chars info) and 0x6d (new char info)
// Returns the size
-#define MAX_CHAR_BUF 144 //Max size (for WFIFOHEAD calls)
-int mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) {
+#define MAX_CHAR_BUF 150 //Max size (for WFIFOHEAD calls)
+int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) {
unsigned short offset = 0;
uint8* buf;
@@ -1927,8 +1954,15 @@ int mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) {
WBUFW(buf,52) = p->class_;
WBUFW(buf,54) = p->hair;
+#if PACKETVER >= 20141022
+ //When the weapon is sent and your option is riding, the client crashes on login!?
+ WBUFL(buf,56) = p->option&(0x20|0x80000|0x100000|0x200000|0x400000|0x800000|0x1000000|0x2000000|0x4000000|0x8000000) ? 0 : p->weapon;
+ offset+=2;
+ buf = WBUFP(buffer,offset);
+#else
//When the weapon is sent and your option is riding, the client crashes on login!?
WBUFW(buf,56) = p->option&(0x20|0x80000|0x100000|0x200000|0x400000|0x800000|0x1000000|0x2000000|0x4000000|0x8000000) ? 0 : p->weapon;
+#endif
WBUFW(buf,58) = p->base_level;
WBUFW(buf,60) = min(p->skill_point, INT16_MAX);
@@ -1964,40 +1998,44 @@ int mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) {
#endif
#if PACKETVER != 20111116 //2011-11-16 wants 136, ask gravity.
#if PACKETVER >= 20110928
- WBUFL(buf,132) = ( p->slotchange > 0 ) ? 1 : 0; // change slot feature (0 = disabled, otherwise enabled)
+ WBUFL(buf,132) = ( p->slotchange > 0 ) ? 1 : 0; // change slot feature (0 = disabled, otherwise enabled)
offset += 4;
#endif
#if PACKETVER >= 20111025
WBUFL(buf,136) = ( p->rename > 0 ) ? 1 : 0; // (0 = disabled, otherwise displays "Add-Ons" sidebar)
offset += 4;
#endif
+ #if PACKETVER >= 20141016
+ WBUFB(buf,140) = p->sex;// sex - (0 = female, 1 = male, 99 = logindefined)
+ offset += 1;
+ #endif
#endif
return 106+offset;
}
-
+
/* Made Possible by Yommy~! <3 */
-void mmo_char_send099d(int fd, struct char_session_data *sd) {
+void char_mmo_char_send099d(int fd, struct char_session_data *sd) {
WFIFOHEAD(fd,4 + (MAX_CHARS*MAX_CHAR_BUF));
WFIFOW(fd,0) = 0x99d;
- WFIFOW(fd,2) = mmo_chars_fromsql(sd, WFIFOP(fd,4)) + 4;
+ WFIFOW(fd,2) = chr->mmo_chars_fromsql(sd, WFIFOP(fd,4)) + 4;
WFIFOSET(fd,WFIFOW(fd,2));
}
+
/* Sends character ban list */
/* Made Possible by Yommy~! <3 */
-void mmo_char_send020d(int fd, struct char_session_data *sd) {
+void char_mmo_char_send_ban_list(int fd, struct char_session_data *sd) {
int i;
time_t now = time(NULL);
-
+
ARR_FIND(0, MAX_CHARS, i, sd->unban_time[i]);
-
if( i != MAX_CHARS ) {
int c;
-
+
WFIFOHEAD(fd, 4 + (MAX_CHARS*24));
WFIFOW(fd, 0) = 0x20d;
-
+
for(i = 0, c = 0; i < MAX_CHARS; i++) {
if( sd->unban_time[i] ) {
timestamp2string((char*)WFIFOP(fd,8 + (28*c)), 20, sd->unban_time[i], "%Y-%m-%d %H:%M:%S");
@@ -2009,24 +2047,23 @@ void mmo_char_send020d(int fd, struct char_session_data *sd) {
WFIFOL(fd, 4 + (24*c)) = 0;
/* also update on mysql */
sd->unban_time[i] = 0;
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `unban_time`='0' WHERE `char_id`='%d' LIMIT 1", char_db, sd->found_char[i]) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `unban_time`='0' WHERE `char_id`='%d' LIMIT 1", char_db, sd->found_char[i]) )
+ Sql_ShowDebug(inter->sql_handle);
}
c++;
}
}
-
+
WFIFOW(fd, 2) = 4 + (24*c);
-
+
WFIFOSET(fd, WFIFOW(fd, 2));
}
}
-int mmo_char_send006b(int fd, struct char_session_data* sd);
+
//----------------------------------------
// [Ind/Hercules] notify client about charselect window data
//----------------------------------------
-void mmo_char_send082d(int fd, struct char_session_data* sd) {
-
+void char_mmo_char_send_slots_info(int fd, struct char_session_data* sd) {
WFIFOHEAD(fd,29);
WFIFOW(fd,0) = 0x82d;
WFIFOW(fd,2) = 29;
@@ -2037,13 +2074,11 @@ void mmo_char_send082d(int fd, struct char_session_data* sd) {
WFIFOB(fd,8) = sd->char_slots;
memset(WFIFOP(fd,9), 0, 20); // unused bytes
WFIFOSET(fd,29);
- mmo_char_send006b(fd,sd);
-
}
//----------------------------------------
// Function to send characters to a player
//----------------------------------------
-int mmo_char_send006b(int fd, struct char_session_data* sd)
+int char_mmo_char_send_characters(int fd, struct char_session_data* sd)
{
int j, offset = 0;
#if PACKETVER >= 20100413
@@ -2051,7 +2086,7 @@ int mmo_char_send006b(int fd, struct char_session_data* sd)
#endif
if (save_log)
ShowInfo("Loading Char Data ("CL_BOLD"%d"CL_RESET")\n",sd->account_id);
-
+
j = 24 + offset; // offset
WFIFOHEAD(fd,j + MAX_CHARS*MAX_CHAR_BUF);
WFIFOW(fd,0) = 0x6b;
@@ -2061,82 +2096,82 @@ int mmo_char_send006b(int fd, struct char_session_data* sd)
WFIFOB(fd,6) = MAX_CHARS; // Premium slots. AKA any existent chars past sd->char_slots but within MAX_CHARS will show a 'Premium Service' in red
#endif
memset(WFIFOP(fd,4 + offset), 0, 20); // unknown bytes
- j+=mmo_chars_fromsql(sd, WFIFOP(fd,j));
+ j+=chr->mmo_chars_fromsql(sd, WFIFOP(fd,j));
WFIFOW(fd,2) = j; // packet len
WFIFOSET(fd,j);
return 0;
}
-int char_married(int pl1, int pl2)
+int char_char_married(int pl1, int pl2)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `partner_id` FROM `%s` WHERE `char_id` = '%d'", char_db, pl1) )
- Sql_ShowDebug(sql_handle);
- else if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `partner_id` FROM `%s` WHERE `char_id` = '%d'", char_db, pl1) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
if( pl2 == atoi(data) )
{
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return 1;
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return 0;
}
-int char_child(int parent_id, int child_id)
+int char_char_child(int parent_id, int child_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id) )
- Sql_ShowDebug(sql_handle);
- else if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
if( child_id == atoi(data) )
{
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return 1;
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return 0;
}
-int char_family(int cid1, int cid2, int cid3)
+int char_char_family(int cid1, int cid2, int cid3)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", char_db, cid1, cid2, cid3) )
- Sql_ShowDebug(sql_handle);
- else while( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", char_db, cid1, cid2, cid3) )
+ Sql_ShowDebug(inter->sql_handle);
+ else while( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
int charid;
int partnerid;
int childid;
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL); charid = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); partnerid = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); childid = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); charid = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); partnerid = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); childid = atoi(data);
if( (cid1 == charid && ((cid2 == partnerid && cid3 == childid ) || (cid2 == childid && cid3 == partnerid))) ||
(cid1 == partnerid && ((cid2 == charid && cid3 == childid ) || (cid2 == childid && cid3 == charid ))) ||
(cid1 == childid && ((cid2 == charid && cid3 == partnerid) || (cid2 == partnerid && cid3 == charid ))) )
{
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return childid;
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return 0;
}
//----------------------------------------------------------------------
// Force disconnection of an online player (with account value) by [Yor]
//----------------------------------------------------------------------
-void disconnect_player(int account_id)
+void char_disconnect_player(int account_id)
{
int i;
struct char_session_data* sd;
@@ -2147,163 +2182,421 @@ void disconnect_player(int account_id)
set_eof(i);
}
+void char_authfail_fd(int fd, int type)
+{
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x81;
+ WFIFOB(fd,2) = type;
+ WFIFOSET(fd,3);
+}
+
+void char_request_account_data(int account_id)
+{
+ WFIFOHEAD(chr->login_fd,6);
+ WFIFOW(chr->login_fd,0) = 0x2716;
+ WFIFOL(chr->login_fd,2) = account_id;
+ WFIFOSET(chr->login_fd,6);
+}
+
static void char_auth_ok(int fd, struct char_session_data *sd)
{
struct online_char_data* character;
- if( (character = (struct online_char_data*)idb_get(online_char_db, sd->account_id)) != NULL )
- { // check if character is not online already. [Skotlex]
- if (character->server > -1)
- { //Character already online. KICK KICK KICK
- mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2);
+ if( (character = (struct online_char_data*)idb_get(chr->online_char_db, sd->account_id)) != NULL ) {
+ // check if character is not online already. [Skotlex]
+ if (character->server > -1) {
+ //Character already online. KICK KICK KICK
+ mapif->disconnectplayer(chr->server[character->server].fd, character->account_id, character->char_id, 2);
if (character->waiting_disconnect == INVALID_TIMER)
- character->waiting_disconnect = timer->add(timer->gettick()+20000, chardb_waiting_disconnect, character->account_id, 0);
+ character->waiting_disconnect = timer->add(timer->gettick()+20000, chr->waiting_disconnect, character->account_id, 0);
if (character)
character->pincode_enable = -1;
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = 8;
- WFIFOSET(fd,3);
+ chr->authfail_fd(fd, 8);
return;
}
- if (character->fd >= 0 && character->fd != fd)
- { //There's already a connection from this account that hasn't picked a char yet.
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = 8;
- WFIFOSET(fd,3);
+ if (character->fd >= 0 && character->fd != fd) {
+ //There's already a connection from this account that hasn't picked a char yet.
+ chr->authfail_fd(fd, 8);
return;
}
character->fd = fd;
}
- if (login_fd > 0) {
- // request account data
- WFIFOHEAD(login_fd,6);
- WFIFOW(login_fd,0) = 0x2716;
- WFIFOL(login_fd,2) = sd->account_id;
- WFIFOSET(login_fd,6);
+ if (chr->login_fd > 0) {
+ chr->request_account_data(sd->account_id);
}
// mark session as 'authed'
sd->auth = true;
// set char online on charserver
- set_char_charselect(sd->account_id);
+ chr->set_char_charselect(sd->account_id);
// continues when account data is received...
}
-int send_accounts_tologin(int tid, int64 tick, int id, intptr_t data);
-void mapif_server_reset(int id);
-
+void char_ping_login_server(int fd)
+{
+ WFIFOHEAD(fd,2);// sends a ping packet to login server (will receive pong 0x2718)
+ WFIFOW(fd,0) = 0x2719;
+ WFIFOSET(fd,2);
+}
-/// Resets all the data.
-void loginif_reset(void)
+int char_parse_fromlogin_connection_state(int fd)
{
- int id;
- // TODO kick everyone out and reset everything or wait for connect and try to reacquire locks [FlavioJS]
- for( id = 0; id < ARRAYLENGTH(server); ++id )
- mapif_server_reset(id);
- flush_fifos();
- exit(EXIT_FAILURE);
+ if (RFIFOB(fd,2)) {
+ //printf("connect login server error : %d\n", RFIFOB(fd,2));
+ ShowError("Can not connect to login-server.\n");
+ ShowError("The server communication passwords (default s1/p1) are probably invalid.\n");
+ ShowError("Also, please make sure your login db has the correct communication username/passwords and the gender of the account is S.\n");
+ ShowError("The communication passwords are set in /conf/map-server.conf and /conf/char-server.conf\n");
+ set_eof(fd);
+ return 1;
+ } else {
+ ShowStatus("Connected to login-server (connection #%d).\n", fd);
+ loginif->on_ready();
+ }
+ RFIFOSKIP(fd,3);
+ return 0;
}
+// 0 - rejected from server
+//
+void char_auth_error(int fd, unsigned char flag)
+{
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x6c;
+ WFIFOB(fd,2) = flag;
+ WFIFOSET(fd,3);
+}
-/// Checks the conditions for the server to stop.
-/// Releases the cookie when all characters are saved.
-/// If all the conditions are met, it stops the core loop.
-void loginif_check_shutdown(void)
+void char_parse_fromlogin_auth_state(int fd)
{
- if( runflag != CHARSERVER_ST_SHUTDOWN )
- return;
- runflag = CORE_ST_STOP;
+ struct char_session_data* sd = NULL;
+ int account_id = RFIFOL(fd,2);
+ uint32 login_id1 = RFIFOL(fd,6);
+ uint32 login_id2 = RFIFOL(fd,10);
+ uint8 sex = RFIFOB(fd,14);
+ uint8 result = RFIFOB(fd,15);
+ int request_id = RFIFOL(fd,16);
+ uint32 version = RFIFOL(fd,20);
+ uint8 clienttype = RFIFOB(fd,24);
+ int group_id = RFIFOL(fd,25);
+ unsigned int expiration_time = RFIFOL(fd, 29);
+ RFIFOSKIP(fd,33);
+
+ if( session_isActive(request_id) && (sd=(struct char_session_data*)session[request_id]->session_data) &&
+ !sd->auth && sd->account_id == account_id && sd->login_id1 == login_id1 && sd->login_id2 == login_id2 && sd->sex == sex )
+ {
+ int client_fd = request_id;
+ sd->version = version;
+ sd->clienttype = clienttype;
+ switch( result ) {
+ case 0:// ok
+ /* restrictions apply */
+ if( chr->server_type == CST_MAINTENANCE && group_id < char_maintenance_min_group_id ) {
+ chr->auth_error(client_fd, 0);
+ break;
+ }
+ /* the client will already deny this request, this check is to avoid someone bypassing. */
+ if( chr->server_type == CST_PAYING && (time_t)expiration_time < time(NULL) ) {
+ chr->auth_error(client_fd, 0);
+ break;
+ }
+ chr->auth_ok(client_fd, sd);
+ break;
+ case 1:// auth failed
+ chr->auth_error(client_fd, 0);
+ break;
+ }
+ }
}
+void char_parse_fromlogin_account_data(int fd)
+{
+ struct char_session_data* sd = (struct char_session_data*)session[fd]->session_data;
+ int i;
+ // find the authenticated session with this account id
+ ARR_FIND( 0, sockt->fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->auth && sd->account_id == RFIFOL(fd,2) );
+ if( i < sockt->fd_max ) {
+ memcpy(sd->email, RFIFOP(fd,6), 40);
+ sd->expiration_time = (time_t)RFIFOL(fd,46);
+ sd->group_id = RFIFOB(fd,50);
+ sd->char_slots = RFIFOB(fd,51);
+ if( sd->char_slots > MAX_CHARS ) {
+ ShowError("Account '%d' `character_slots` column is higher than supported MAX_CHARS (%d), update MAX_CHARS in mmo.h! capping to MAX_CHARS...\n",sd->account_id,sd->char_slots);
+ sd->char_slots = MAX_CHARS;/* cap to maximum */
+ } else if ( sd->char_slots <= 0 )/* no value aka 0 in sql */
+ sd->char_slots = MAX_CHARS;/* cap to maximum */
+ safestrncpy(sd->birthdate, (const char*)RFIFOP(fd,52), sizeof(sd->birthdate));
+ safestrncpy(sd->pincode, (const char*)RFIFOP(fd,63), sizeof(sd->pincode));
+ sd->pincode_change = RFIFOL(fd,68);
+ // continued from chr->auth_ok...
+ if( (max_connect_user == 0 && sd->group_id != gm_allow_group) ||
+ ( max_connect_user > 0 && chr->count_users() >= max_connect_user && sd->group_id != gm_allow_group ) ) {
+ // refuse connection (over populated)
+ chr->auth_error(i, 0);
+ } else {
+ // send characters to player
+ #if PACKETVER >= 20130000
+ chr->mmo_char_send_slots_info(i, sd);
+ chr->mmo_char_send_characters(i, sd);
+ #else
+ chr->mmo_char_send_characters(i, sd);
+ #endif
+ #if PACKETVER >= 20060819
+ chr->mmo_char_send_ban_list(i, sd);
+ #endif
+ #if PACKETVER >= 20110309
+ pincode->handle(i, sd);
+ #endif
+ }
+ }
+ RFIFOSKIP(fd,72);
+}
-/// Called when the connection to Login Server is disconnected.
-void loginif_on_disconnect(void)
+void char_parse_fromlogin_login_pong(int fd)
{
- ShowWarning("Connection to Login Server lost.\n\n");
+ RFIFOSKIP(fd,2);
+ session[fd]->flag.ping = 0;
}
+void char_changesex(int account_id, int sex)
+{
+ unsigned char buf[7];
+
+ WBUFW(buf,0) = 0x2b0d;
+ WBUFL(buf,2) = account_id;
+ WBUFB(buf,6) = sex;
+ mapif->sendall(buf, 7);
+}
-/// Called when all the connection steps are completed.
-void loginif_on_ready(void)
+int char_parse_fromlogin_changesex_reply(int fd)
{
+ int char_id[MAX_CHARS];
+ int class_[MAX_CHARS];
+ int guild_id[MAX_CHARS];
+ int num;
int i;
+ char* data;
+ struct char_auth_node* node;
+
+ int acc = RFIFOL(fd,2);
+ int sex = RFIFOB(fd,6);
+
+ RFIFOSKIP(fd,7);
+
+ // This should _never_ happen
+ if( acc <= 0 ) {
+ ShowError("Received invalid account id from login server! (aid: %d)\n", acc);
+ return 1;
+ }
- loginif_check_shutdown();
+ node = (struct char_auth_node*)idb_get(auth_db, acc);
+ if( node != NULL )
+ node->sex = sex;
- //Send online accounts to login server.
- send_accounts_tologin(INVALID_TIMER, timer->gettick(), 0, 0);
+ // get characters
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`,`class`,`guild_id` FROM `%s` WHERE `account_id` = '%d'", char_db, acc) )
+ Sql_ShowDebug(inter->sql_handle);
+ for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
+ {
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); char_id[i] = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); class_[i] = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); guild_id[i] = atoi(data);
+ }
+ num = i;
+ for( i = 0; i < num; ++i )
+ {
+ if( class_[i] == JOB_BARD || class_[i] == JOB_DANCER ||
+ class_[i] == JOB_CLOWN || class_[i] == JOB_GYPSY ||
+ class_[i] == JOB_BABY_BARD || class_[i] == JOB_BABY_DANCER ||
+ class_[i] == JOB_MINSTREL || class_[i] == JOB_WANDERER ||
+ class_[i] == JOB_MINSTREL_T || class_[i] == JOB_WANDERER_T ||
+ class_[i] == JOB_BABY_MINSTREL || class_[i] == JOB_BABY_WANDERER ||
+ class_[i] == JOB_KAGEROU || class_[i] == JOB_OBORO )
+ {
+ // job modification
+ if( class_[i] == JOB_BARD || class_[i] == JOB_DANCER )
+ class_[i] = (sex ? JOB_BARD : JOB_DANCER);
+ else if( class_[i] == JOB_CLOWN || class_[i] == JOB_GYPSY )
+ class_[i] = (sex ? JOB_CLOWN : JOB_GYPSY);
+ else if( class_[i] == JOB_BABY_BARD || class_[i] == JOB_BABY_DANCER )
+ class_[i] = (sex ? JOB_BABY_BARD : JOB_BABY_DANCER);
+ else if( class_[i] == JOB_MINSTREL || class_[i] == JOB_WANDERER )
+ class_[i] = (sex ? JOB_MINSTREL : JOB_WANDERER);
+ else if( class_[i] == JOB_MINSTREL_T || class_[i] == JOB_WANDERER_T )
+ class_[i] = (sex ? JOB_MINSTREL_T : JOB_WANDERER_T);
+ else if( class_[i] == JOB_BABY_MINSTREL || class_[i] == JOB_BABY_WANDERER )
+ class_[i] = (sex ? JOB_BABY_MINSTREL : JOB_BABY_WANDERER);
+ else if( class_[i] == JOB_KAGEROU || class_[i] == JOB_OBORO )
+ class_[i] = (sex ? JOB_KAGEROU : JOB_OBORO);
+ }
+
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `equip`='0' WHERE `char_id`='%d'", inventory_db, char_id[i]) )
+ Sql_ShowDebug(inter->sql_handle);
+
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
+ "UPDATE `%s` SET `class`='%d', `weapon`='0', `shield`='0', `head_top`='0', `head_mid`='0', "
+ "`head_bottom`='0' WHERE `char_id`='%d'",
+ char_db, class_[i], char_id[i]) )
+ Sql_ShowDebug(inter->sql_handle);
+
+ if( guild_id[i] )// If there is a guild, update the guild_member data [Skotlex]
+ inter_guild->sex_changed(guild_id[i], acc, char_id[i], sex);
+ }
+ SQL->FreeResult(inter->sql_handle);
+
+ // disconnect player if online on char-server
+ chr->disconnect_player(acc);
- // if no map-server already connected, display a message...
- ARR_FIND( 0, ARRAYLENGTH(server), i, server[i].fd > 0 && server[i].map[0] );
- if( i == ARRAYLENGTH(server) )
- ShowStatus("Awaiting maps from map-server.\n");
+ // notify all mapservers about this change
+ chr->changesex(acc, sex);
+ return 0;
}
+void char_parse_fromlogin_account_reg2(int fd)
+{
+ //Receive account_reg2 registry, forward to map servers.
+ mapif->sendall(RFIFOP(fd, 0), RFIFOW(fd,2));
+ RFIFOSKIP(fd, RFIFOW(fd,2));
+}
-int parse_fromlogin(int fd) {
- struct char_session_data* sd = NULL;
+void mapif_ban(int id, unsigned int flag, int status)
+{
+ // send to all map-servers to disconnect the player
+ unsigned char buf[11];
+ WBUFW(buf,0) = 0x2b14;
+ WBUFL(buf,2) = id;
+ WBUFB(buf,6) = flag; // 0: change of status, 1: ban
+ WBUFL(buf,7) = status; // status or final date of a banishment
+ mapif->sendall(buf, 11);
+}
+
+void char_parse_fromlogin_ban(int fd)
+{
+ mapif->ban(RFIFOL(fd,2), RFIFOB(fd,6), RFIFOL(fd,7));
+ // disconnect player if online on char-server
+ chr->disconnect_player(RFIFOL(fd,2));
+ RFIFOSKIP(fd,11);
+}
+
+void char_parse_fromlogin_kick(int fd)
+{
+ int aid = RFIFOL(fd,2);
+ struct online_char_data* character = (struct online_char_data*)idb_get(chr->online_char_db, aid);
+ RFIFOSKIP(fd,6);
+ if( character != NULL )
+ {// account is already marked as online!
+ if( character->server > -1 ) {
+ //Kick it from the map server it is on.
+ mapif->disconnectplayer(chr->server[character->server].fd, character->account_id, character->char_id, 2);
+ if (character->waiting_disconnect == INVALID_TIMER)
+ character->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, chr->waiting_disconnect, character->account_id, 0);
+ }
+ else
+ {// Manual kick from char server.
+ struct char_session_data *tsd;
+ int i;
+ ARR_FIND( 0, sockt->fd_max, i, session[i] && (tsd = (struct char_session_data*)session[i]->session_data) && tsd->account_id == aid );
+ if( i < sockt->fd_max )
+ {
+ chr->authfail_fd(i, 2);
+ set_eof(i);
+ }
+ else // still moving to the map-server
+ chr->set_char_offline(-1, aid);
+ }
+ }
+ idb_remove(auth_db, aid);// reject auth attempts from map-server
+}
+void char_update_ip(int fd)
+{
+ WFIFOHEAD(fd,6);
+ WFIFOW(fd,0) = 0x2736;
+ WFIFOL(fd,2) = htonl(chr->ip);
+ WFIFOSET(fd,6);
+}
+
+void char_parse_fromlogin_update_ip(int fd)
+{
+ unsigned char buf[2];
+ uint32 new_ip = 0;
+
+ WBUFW(buf,0) = 0x2b1e;
+ mapif->sendall(buf, 2);
+
+ new_ip = host2ip(login_ip_str);
+ if (new_ip && new_ip != login_ip)
+ login_ip = new_ip; //Update login ip, too.
+
+ new_ip = host2ip(char_ip_str);
+ if (new_ip && new_ip != chr->ip) {
+ //Update ip.
+ chr->ip = new_ip;
+ ShowInfo("Updating IP for [%s].\n", char_ip_str);
+ // notify login server about the change
+ chr->update_ip(fd);
+ }
+ RFIFOSKIP(fd,2);
+}
+
+void char_parse_fromlogin_accinfo2_failed(int fd)
+{
+ mapif->parse_accinfo2(false, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14),
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, 0, 0);
+ RFIFOSKIP(fd,18);
+}
+
+void char_parse_fromlogin_accinfo2_ok(int fd)
+{
+ mapif->parse_accinfo2(true, RFIFOL(fd,167), RFIFOL(fd,171), RFIFOL(fd,175), RFIFOL(fd,179),
+ (char*)RFIFOP(fd,2), (char*)RFIFOP(fd,26), (char*)RFIFOP(fd,59),
+ (char*)RFIFOP(fd,99), (char*)RFIFOP(fd,119), (char*)RFIFOP(fd,151),
+ (char*)RFIFOP(fd,156), RFIFOL(fd,115), RFIFOL(fd,143), RFIFOL(fd,147));
+ RFIFOSKIP(fd,183);
+}
+
+int char_parse_fromlogin(int fd) {
// only process data from the login-server
- if( fd != login_fd ) {
- ShowDebug("parse_fromlogin: Disconnecting invalid session #%d (is not the login-server)\n", fd);
+ if( fd != chr->login_fd ) {
+ ShowDebug("chr->parse_fromlogin: Disconnecting invalid session #%d (is not the login-server)\n", fd);
do_close(fd);
return 0;
}
if( session[fd]->flag.eof ) {
do_close(fd);
- login_fd = -1;
- loginif_on_disconnect();
+ chr->login_fd = -1;
+ loginif->on_disconnect();
return 0;
} else if ( session[fd]->flag.ping ) {/* we've reached stall time */
if( DIFF_TICK(sockt->last_tick, session[fd]->rdata_tick) > (sockt->stall_time * 2) ) {/* we can't wait any longer */
set_eof(fd);
return 0;
} else if( session[fd]->flag.ping != 2 ) { /* we haven't sent ping out yet */
- WFIFOHEAD(fd,2);// sends a ping packet to login server (will receive pong 0x2718)
- WFIFOW(fd,0) = 0x2719;
- WFIFOSET(fd,2);
-
+ chr->ping_login_server(fd);
session[fd]->flag.ping = 2;
}
}
- sd = (struct char_session_data*)session[fd]->session_data;
-
while(RFIFOREST(fd) >= 2) {
uint16 command = RFIFOW(fd,0);
-
+
if( HPM->packetsc[hpParse_FromLogin] ) {
int success = HPM->parse_packets(fd,hpParse_FromLogin);
if( success == 1 ) continue;
else if( success == 2 ) return 0;
}
-
- switch( command ) {
+ switch (command) {
// acknowledgment of connect-to-loginserver request
case 0x2711:
if (RFIFOREST(fd) < 3)
return 0;
-
- if (RFIFOB(fd,2)) {
- //printf("connect login server error : %d\n", RFIFOB(fd,2));
- ShowError("Can not connect to login-server.\n");
- ShowError("The server communication passwords (default s1/p1) are probably invalid.\n");
- ShowError("Also, please make sure your login db has the correct communication username/passwords and the gender of the account is S.\n");
- ShowError("The communication passwords are set in /conf/map-server.conf and /conf/char-server.conf\n");
- set_eof(fd);
+ if (chr->parse_fromlogin_connection_state(fd))
return 0;
- } else {
- ShowStatus("Connected to login-server (connection #%d).\n", fd);
- loginif_on_ready();
- }
- RFIFOSKIP(fd,3);
break;
// acknowledgment of account authentication request
@@ -2311,100 +2604,15 @@ int parse_fromlogin(int fd) {
if (RFIFOREST(fd) < 33)
return 0;
{
- int account_id = RFIFOL(fd,2);
- uint32 login_id1 = RFIFOL(fd,6);
- uint32 login_id2 = RFIFOL(fd,10);
- uint8 sex = RFIFOB(fd,14);
- uint8 result = RFIFOB(fd,15);
- int request_id = RFIFOL(fd,16);
- uint32 version = RFIFOL(fd,20);
- uint8 clienttype = RFIFOB(fd,24);
- int group_id = RFIFOL(fd,25);
- unsigned int expiration_time = RFIFOL(fd, 29);
- RFIFOSKIP(fd,33);
-
- if( session_isActive(request_id) && (sd=(struct char_session_data*)session[request_id]->session_data) &&
- !sd->auth && sd->account_id == account_id && sd->login_id1 == login_id1 && sd->login_id2 == login_id2 && sd->sex == sex )
- {
- int client_fd = request_id;
- sd->version = version;
- sd->clienttype = clienttype;
- switch( result ) {
- case 0:// ok
- /* restrictions apply */
- if( char_server_type == CST_MAINTENANCE && group_id < char_maintenance_min_group_id ) {
- WFIFOHEAD(client_fd,3);
- WFIFOW(client_fd,0) = 0x6c;
- WFIFOB(client_fd,2) = 0;// rejected from server
- WFIFOSET(client_fd,3);
- break;
- }
- /* the client will already deny this request, this check is to avoid someone bypassing. */
- if( char_server_type == CST_PAYING && (time_t)expiration_time < time(NULL) ) {
- WFIFOHEAD(client_fd,3);
- WFIFOW(client_fd,0) = 0x6c;
- WFIFOB(client_fd,2) = 0;// rejected from server
- WFIFOSET(client_fd,3);
- break;
- }
- char_auth_ok(client_fd, sd);
- break;
- case 1:// auth failed
- WFIFOHEAD(client_fd,3);
- WFIFOW(client_fd,0) = 0x6c;
- WFIFOB(client_fd,2) = 0;// rejected from server
- WFIFOSET(client_fd,3);
- break;
- }
- }
+ chr->parse_fromlogin_auth_state(fd);
}
break;
case 0x2717: // account data
{
- int i;
if (RFIFOREST(fd) < 72)
return 0;
-
- // find the authenticated session with this account id
- ARR_FIND( 0, sockt->fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->auth && sd->account_id == RFIFOL(fd,2) );
- if( i < sockt->fd_max ) {
- memcpy(sd->email, RFIFOP(fd,6), 40);
- sd->expiration_time = (time_t)RFIFOL(fd,46);
- sd->group_id = RFIFOB(fd,50);
- sd->char_slots = RFIFOB(fd,51);
- if( sd->char_slots > MAX_CHARS ) {
- ShowError("Account '%d' `character_slots` column is higher than supported MAX_CHARS (%d), update MAX_CHARS in mmo.h! capping to MAX_CHARS...\n",sd->account_id,sd->char_slots);
- sd->char_slots = MAX_CHARS;/* cap to maximum */
- } else if ( sd->char_slots <= 0 )/* no value aka 0 in sql */
- sd->char_slots = MAX_CHARS;/* cap to maximum */
- safestrncpy(sd->birthdate, (const char*)RFIFOP(fd,52), sizeof(sd->birthdate));
- safestrncpy(sd->pincode, (const char*)RFIFOP(fd,63), sizeof(sd->pincode));
- sd->pincode_change = RFIFOL(fd,68);
- // continued from char_auth_ok...
- if( (max_connect_user == 0 && sd->group_id != gm_allow_group) ||
- ( max_connect_user > 0 && count_users() >= max_connect_user && sd->group_id != gm_allow_group ) ) {
- // refuse connection (over populated)
- WFIFOHEAD(i,3);
- WFIFOW(i,0) = 0x6c;
- WFIFOW(i,2) = 0;
- WFIFOSET(i,3);
- } else {
- // send characters to player
- #if PACKETVER >= 20130000
- mmo_char_send082d(i, sd);
- #else
- mmo_char_send006b(i, sd);
- #endif
- #if PACKETVER >= 20060819
- mmo_char_send020d(i, sd);
- #endif
- #if PACKETVER >= 20110309
- pincode->handle(i, sd);
- #endif
- }
- }
- RFIFOSKIP(fd,72);
+ chr->parse_fromlogin_account_data(fd);
}
break;
@@ -2412,8 +2620,7 @@ int parse_fromlogin(int fd) {
case 0x2718:
if (RFIFOREST(fd) < 2)
return 0;
- RFIFOSKIP(fd,2);
- session[fd]->flag.ping = 0;
+ chr->parse_fromlogin_login_pong(fd);
break;
// changesex reply
@@ -2421,90 +2628,8 @@ int parse_fromlogin(int fd) {
if (RFIFOREST(fd) < 7)
return 0;
{
- unsigned char buf[7];
-
- int char_id[MAX_CHARS];
- int class_[MAX_CHARS];
- int guild_id[MAX_CHARS];
- int num;
- int i;
- char* data;
- struct auth_node* node;
-
- int acc = RFIFOL(fd,2);
- int sex = RFIFOB(fd,6);
-
- RFIFOSKIP(fd,7);
-
- // This should _never_ happen
- if( acc <= 0 ) {
- ShowError("Received invalid account id from login server! (aid: %d)\n", acc);
+ if (chr->parse_fromlogin_changesex_reply(fd))
return 0;
- }
-
- node = (struct auth_node*)idb_get(auth_db, acc);
- if( node != NULL )
- node->sex = sex;
-
- // get characters
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`,`class`,`guild_id` FROM `%s` WHERE `account_id` = '%d'", char_db, acc) )
- Sql_ShowDebug(sql_handle);
- for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
- {
- SQL->GetData(sql_handle, 0, &data, NULL); char_id[i] = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); class_[i] = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); guild_id[i] = atoi(data);
- }
- num = i;
- for( i = 0; i < num; ++i )
- {
- if( class_[i] == JOB_BARD || class_[i] == JOB_DANCER ||
- class_[i] == JOB_CLOWN || class_[i] == JOB_GYPSY ||
- class_[i] == JOB_BABY_BARD || class_[i] == JOB_BABY_DANCER ||
- class_[i] == JOB_MINSTREL || class_[i] == JOB_WANDERER ||
- class_[i] == JOB_MINSTREL_T || class_[i] == JOB_WANDERER_T ||
- class_[i] == JOB_BABY_MINSTREL || class_[i] == JOB_BABY_WANDERER ||
- class_[i] == JOB_KAGEROU || class_[i] == JOB_OBORO )
- {
- // job modification
- if( class_[i] == JOB_BARD || class_[i] == JOB_DANCER )
- class_[i] = (sex ? JOB_BARD : JOB_DANCER);
- else if( class_[i] == JOB_CLOWN || class_[i] == JOB_GYPSY )
- class_[i] = (sex ? JOB_CLOWN : JOB_GYPSY);
- else if( class_[i] == JOB_BABY_BARD || class_[i] == JOB_BABY_DANCER )
- class_[i] = (sex ? JOB_BABY_BARD : JOB_BABY_DANCER);
- else if( class_[i] == JOB_MINSTREL || class_[i] == JOB_WANDERER )
- class_[i] = (sex ? JOB_MINSTREL : JOB_WANDERER);
- else if( class_[i] == JOB_MINSTREL_T || class_[i] == JOB_WANDERER_T )
- class_[i] = (sex ? JOB_MINSTREL_T : JOB_WANDERER_T);
- else if( class_[i] == JOB_BABY_MINSTREL || class_[i] == JOB_BABY_WANDERER )
- class_[i] = (sex ? JOB_BABY_MINSTREL : JOB_BABY_WANDERER);
- else if( class_[i] == JOB_KAGEROU || class_[i] == JOB_OBORO )
- class_[i] = (sex ? JOB_KAGEROU : JOB_OBORO);
- }
-
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `equip`='0' WHERE `char_id`='%d'", inventory_db, char_id[i]) )
- Sql_ShowDebug(sql_handle);
-
- if( SQL_ERROR == SQL->Query(sql_handle,
- "UPDATE `%s` SET `class`='%d', `weapon`='0', `shield`='0', `head_top`='0', `head_mid`='0', "
- "`head_bottom`='0' WHERE `char_id`='%d'",
- char_db, class_[i], char_id[i]) )
- Sql_ShowDebug(sql_handle);
-
- if( guild_id[i] )// If there is a guild, update the guild_member data [Skotlex]
- inter_guild_sex_changed(guild_id[i], acc, char_id[i], sex);
- }
- SQL->FreeResult(sql_handle);
-
- // disconnect player if online on char-server
- disconnect_player(acc);
-
- // notify all mapservers about this change
- WBUFW(buf,0) = 0x2b0d;
- WBUFL(buf,2) = acc;
- WBUFB(buf,6) = sex;
- mapif_sendall(buf, 7);
}
break;
@@ -2512,28 +2637,14 @@ int parse_fromlogin(int fd) {
case 0x3804:
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
- //Receive account_reg2 registry, forward to map servers.
- mapif_sendall(RFIFOP(fd, 0), RFIFOW(fd,2));
- RFIFOSKIP(fd, RFIFOW(fd,2));
+ chr->parse_fromlogin_account_reg2(fd);
break;
// State change of account/ban notification (from login-server)
case 0x2731:
if (RFIFOREST(fd) < 11)
return 0;
-
- { // send to all map-servers to disconnect the player
- unsigned char buf[11];
- WBUFW(buf,0) = 0x2b14;
- WBUFL(buf,2) = RFIFOL(fd,2);
- WBUFB(buf,6) = RFIFOB(fd,6); // 0: change of status, 1: ban
- WBUFL(buf,7) = RFIFOL(fd,7); // status or final date of a banishment
- mapif_sendall(buf, 11);
- }
- // disconnect player if online on char-server
- disconnect_player(RFIFOL(fd,2));
-
- RFIFOSKIP(fd,11);
+ chr->parse_fromlogin_ban(fd);
break;
// Login server request to kick a character out. [Skotlex]
@@ -2541,64 +2652,14 @@ int parse_fromlogin(int fd) {
if (RFIFOREST(fd) < 6)
return 0;
{
- int aid = RFIFOL(fd,2);
- struct online_char_data* character = (struct online_char_data*)idb_get(online_char_db, aid);
- RFIFOSKIP(fd,6);
- if( character != NULL )
- {// account is already marked as online!
- if( character->server > -1 )
- { //Kick it from the map server it is on.
- mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2);
- if (character->waiting_disconnect == INVALID_TIMER)
- character->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, chardb_waiting_disconnect, character->account_id, 0);
- }
- else
- {// Manual kick from char server.
- struct char_session_data *tsd;
- int i;
- ARR_FIND( 0, sockt->fd_max, i, session[i] && (tsd = (struct char_session_data*)session[i]->session_data) && tsd->account_id == aid );
- if( i < sockt->fd_max )
- {
- WFIFOHEAD(i,3);
- WFIFOW(i,0) = 0x81;
- WFIFOB(i,2) = 2; // "Someone has already logged in with this id"
- WFIFOSET(i,3);
- set_eof(i);
- }
- else // still moving to the map-server
- set_char_offline(-1, aid);
- }
- }
- idb_remove(auth_db, aid);// reject auth attempts from map-server
+ chr->parse_fromlogin_kick(fd);
}
break;
// ip address update signal from login server
case 0x2735:
{
- unsigned char buf[2];
- uint32 new_ip = 0;
-
- WBUFW(buf,0) = 0x2b1e;
- mapif_sendall(buf, 2);
-
- new_ip = host2ip(login_ip_str);
- if (new_ip && new_ip != login_ip)
- login_ip = new_ip; //Update login ip, too.
-
- new_ip = host2ip(char_ip_str);
- if (new_ip && new_ip != char_ip)
- { //Update ip.
- char_ip = new_ip;
- ShowInfo("Updating IP for [%s].\n", char_ip_str);
- // notify login server about the change
- WFIFOHEAD(fd,6);
- WFIFOW(fd,0) = 0x2736;
- WFIFOL(fd,2) = htonl(char_ip);
- WFIFOSET(fd,6);
- }
-
- RFIFOSKIP(fd,2);
+ chr->parse_fromlogin_update_ip(fd);
}
break;
@@ -2606,20 +2667,14 @@ int parse_fromlogin(int fd) {
if (RFIFOREST(fd) < 18)
return 0;
- mapif_parse_accinfo2(false, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14),
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, 0, 0);
- RFIFOSKIP(fd,18);
+ chr->parse_fromlogin_accinfo2_failed(fd);
break;
case 0x2737: // Successful accinfo lookup to forward to mapserver
if (RFIFOREST(fd) < 183)
return 0;
- mapif_parse_accinfo2(true, RFIFOL(fd,167), RFIFOL(fd,171), RFIFOL(fd,175), RFIFOL(fd,179),
- (char*)RFIFOP(fd,2), (char*)RFIFOP(fd,26), (char*)RFIFOP(fd,59),
- (char*)RFIFOP(fd,99), (char*)RFIFOP(fd,119), (char*)RFIFOP(fd,151),
- (char*)RFIFOP(fd,156), RFIFOL(fd,115), RFIFOL(fd,143), RFIFOL(fd,147));
- RFIFOSKIP(fd,183);
+ chr->parse_fromlogin_accinfo2_ok(fd);
break;
default:
@@ -2633,110 +2688,88 @@ int parse_fromlogin(int fd) {
return 0;
}
-int check_connect_login_server(int tid, int64 tick, int id, intptr_t data);
-
-void do_init_loginif(void)
-{
- // establish char-login connection if not present
- timer->add_func_list(check_connect_login_server, "check_connect_login_server");
- timer->add_interval(timer->gettick() + 1000, check_connect_login_server, 0, 0, 10 * 1000);
-
- // send a list of all online account IDs to login server
- timer->add_func_list(send_accounts_tologin, "send_accounts_tologin");
- timer->add_interval(timer->gettick() + 1000, send_accounts_tologin, 0, 0, 3600 * 1000); //Sync online accounts every hour
-}
-
-void do_final_loginif(void)
+int char_request_accreg2(int account_id, int char_id)
{
- if( login_fd != -1 )
- {
- do_close(login_fd);
- login_fd = -1;
- }
-}
-
-int request_accreg2(int account_id, int char_id)
-{
- if (login_fd > 0) {
- WFIFOHEAD(login_fd,10);
- WFIFOW(login_fd,0) = 0x272e;
- WFIFOL(login_fd,2) = account_id;
- WFIFOL(login_fd,6) = char_id;
- WFIFOSET(login_fd,10);
+ if (chr->login_fd > 0) {
+ WFIFOHEAD(chr->login_fd,10);
+ WFIFOW(chr->login_fd,0) = 0x272e;
+ WFIFOL(chr->login_fd,2) = account_id;
+ WFIFOL(chr->login_fd,6) = char_id;
+ WFIFOSET(chr->login_fd,10);
return 1;
}
return 0;
}
+
/**
- * Handles global account reg saving that continues with global_accreg_to_login_add and global_accreg_to_send
+ * Handles global account reg saving that continues with chr->global_accreg_to_login_add and global_accreg_to_send
**/
-void global_accreg_to_login_start (int account_id, int char_id) {
- WFIFOHEAD(login_fd, 60000 + 300);
- WFIFOW(login_fd,0) = 0x2728;
- WFIFOW(login_fd,2) = 14;
- WFIFOL(login_fd,4) = account_id;
- WFIFOL(login_fd,8) = char_id;
- WFIFOW(login_fd,12) = 0;/* count */
+void char_global_accreg_to_login_start (int account_id, int char_id) {
+ WFIFOHEAD(chr->login_fd, 60000 + 300);
+ WFIFOW(chr->login_fd,0) = 0x2728;
+ WFIFOW(chr->login_fd,2) = 14;
+ WFIFOL(chr->login_fd,4) = account_id;
+ WFIFOL(chr->login_fd,8) = char_id;
+ WFIFOW(chr->login_fd,12) = 0;/* count */
}
+
/**
- * Completes global account reg saving that starts global_accreg_to_login_start and continues with global_accreg_to_login_add
+ * Completes global account reg saving that starts chr->global_accreg_to_login_start and continues with chr->global_accreg_to_login_add
**/
-void global_accreg_to_login_send (void) {
- WFIFOSET(login_fd, WFIFOW(login_fd,2));
+void char_global_accreg_to_login_send (void) {
+ WFIFOSET(chr->login_fd, WFIFOW(chr->login_fd,2));
}
+
/**
- * Handles global account reg saving that starts global_accreg_to_login_start and ends with global_accreg_to_send
+ * Handles global account reg saving that starts chr->global_accreg_to_login_start and ends with global_accreg_to_send
**/
-void global_accreg_to_login_add (const char *key, unsigned int index, intptr_t val, bool is_string) {
- int nlen = WFIFOW(login_fd, 2);
- size_t len;
-
- len = strlen(key)+1;
-
- WFIFOB(login_fd, nlen) = (unsigned char)len;/* won't be higher; the column size is 32 */
+void char_global_accreg_to_login_add (const char *key, unsigned int index, intptr_t val, bool is_string) {
+ int nlen = WFIFOW(chr->login_fd, 2);
+ size_t len = strlen(key)+1;
+
+ WFIFOB(chr->login_fd, nlen) = (unsigned char)len;/* won't be higher; the column size is 32 */
nlen += 1;
-
- safestrncpy((char*)WFIFOP(login_fd,nlen), key, len);
+
+ safestrncpy((char*)WFIFOP(chr->login_fd,nlen), key, len);
nlen += len;
-
- WFIFOL(login_fd, nlen) = index;
+
+ WFIFOL(chr->login_fd, nlen) = index;
nlen += 4;
-
+
if( is_string ) {
- WFIFOB(login_fd, nlen) = val ? 2 : 3;
+ WFIFOB(chr->login_fd, nlen) = val ? 2 : 3;
nlen += 1;
-
+
if( val ) {
char *sval = (char*)val;
len = strlen(sval)+1;
-
- WFIFOB(login_fd, nlen) = (unsigned char)len;/* won't be higher; the column size is 254 */
+
+ WFIFOB(chr->login_fd, nlen) = (unsigned char)len;/* won't be higher; the column size is 254 */
nlen += 1;
-
- safestrncpy((char*)WFIFOP(login_fd,nlen), sval, len);
+
+ safestrncpy((char*)WFIFOP(chr->login_fd,nlen), sval, len);
nlen += len;
}
-
} else {
- WFIFOB(login_fd, nlen) = val ? 0 : 1;
+ WFIFOB(chr->login_fd, nlen) = val ? 0 : 1;
nlen += 1;
-
+
if( val ) {
- WFIFOL(login_fd, nlen) = (int)val;
+ WFIFOL(chr->login_fd, nlen) = (int)val;
nlen += 4;
}
-
}
-
- WFIFOW(login_fd,12) += 1;
-
- WFIFOW(login_fd, 2) = nlen;
- if( WFIFOW(login_fd, 2) > 60000 ) {
- int account_id = WFIFOL(login_fd,4), char_id = WFIFOL(login_fd,8);
- global_accreg_to_login_send();
- global_accreg_to_login_start(account_id,char_id);/* prepare next */
+
+ WFIFOW(chr->login_fd,12) += 1;
+
+ WFIFOW(chr->login_fd, 2) = nlen;
+ if( WFIFOW(chr->login_fd, 2) > 60000 ) {
+ int account_id = WFIFOL(chr->login_fd,4), char_id = WFIFOL(chr->login_fd,8);
+ chr->global_accreg_to_login_send();
+ chr->global_accreg_to_login_start(account_id,char_id);/* prepare next */
}
}
+
void char_read_fame_list(void) {
int i;
char* data;
@@ -2747,51 +2780,51 @@ void char_read_fame_list(void) {
memset(chemist_fame_list, 0, sizeof(chemist_fame_list));
memset(taekwon_fame_list, 0, sizeof(taekwon_fame_list));
// Build Blacksmith ranking list
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_BLACKSMITH, JOB_WHITESMITH, JOB_BABY_BLACKSMITH, JOB_MECHANIC, JOB_MECHANIC_T, JOB_BABY_MECHANIC, fame_list_size_smith) )
- Sql_ShowDebug(sql_handle);
- for( i = 0; i < fame_list_size_smith && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_BLACKSMITH, JOB_WHITESMITH, JOB_BABY_BLACKSMITH, JOB_MECHANIC, JOB_MECHANIC_T, JOB_BABY_MECHANIC, fame_list_size_smith) )
+ Sql_ShowDebug(inter->sql_handle);
+ for( i = 0; i < fame_list_size_smith && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
// char_id
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
smith_fame_list[i].id = atoi(data);
// fame
- SQL->GetData(sql_handle, 1, &data, &len);
+ SQL->GetData(inter->sql_handle, 1, &data, &len);
smith_fame_list[i].fame = atoi(data);
// name
- SQL->GetData(sql_handle, 2, &data, &len);
+ SQL->GetData(inter->sql_handle, 2, &data, &len);
memcpy(smith_fame_list[i].name, data, min(len, NAME_LENGTH));
}
// Build Alchemist ranking list
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_ALCHEMIST, JOB_CREATOR, JOB_BABY_ALCHEMIST, JOB_GENETIC, JOB_GENETIC_T, JOB_BABY_GENETIC, fame_list_size_chemist) )
- Sql_ShowDebug(sql_handle);
- for( i = 0; i < fame_list_size_chemist && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_ALCHEMIST, JOB_CREATOR, JOB_BABY_ALCHEMIST, JOB_GENETIC, JOB_GENETIC_T, JOB_BABY_GENETIC, fame_list_size_chemist) )
+ Sql_ShowDebug(inter->sql_handle);
+ for( i = 0; i < fame_list_size_chemist && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
// char_id
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
chemist_fame_list[i].id = atoi(data);
// fame
- SQL->GetData(sql_handle, 1, &data, &len);
+ SQL->GetData(inter->sql_handle, 1, &data, &len);
chemist_fame_list[i].fame = atoi(data);
// name
- SQL->GetData(sql_handle, 2, &data, &len);
+ SQL->GetData(inter->sql_handle, 2, &data, &len);
memcpy(chemist_fame_list[i].name, data, min(len, NAME_LENGTH));
}
// Build Taekwon ranking list
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_TAEKWON, fame_list_size_taekwon) )
- Sql_ShowDebug(sql_handle);
- for( i = 0; i < fame_list_size_taekwon && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_TAEKWON, fame_list_size_taekwon) )
+ Sql_ShowDebug(inter->sql_handle);
+ for( i = 0; i < fame_list_size_taekwon && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
// char_id
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
taekwon_fame_list[i].id = atoi(data);
// fame
- SQL->GetData(sql_handle, 1, &data, &len);
+ SQL->GetData(inter->sql_handle, 1, &data, &len);
taekwon_fame_list[i].fame = atoi(data);
// name
- SQL->GetData(sql_handle, 2, &data, &len);
+ SQL->GetData(inter->sql_handle, 2, &data, &len);
memcpy(taekwon_fame_list[i].name, data, min(len, NAME_LENGTH));
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
// Send map-servers the fame ranking lists
@@ -2823,9 +2856,9 @@ int char_send_fame_list(int fd) {
WBUFW(buf, 2) = len;
if (fd != -1)
- mapif_send(fd, buf, len);
+ mapif->send(fd, buf, len);
else
- mapif_sendall(buf, len);
+ mapif->sendall(buf, len);
return 0;
}
@@ -2836,7 +2869,7 @@ void char_update_fame_list(int type, int index, int fame) {
WBUFB(buf,2) = type;
WBUFB(buf,3) = index;
WBUFL(buf,4) = fame;
- mapif_sendall(buf, 8);
+ mapif->sendall(buf, 8);
}
//Loads a character's name and stores it in the buffer given (must be NAME_LENGTH in size)
@@ -2846,11 +2879,11 @@ int char_loadName(int char_id, char* name)
char* data;
size_t len;
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `name` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) )
- Sql_ShowDebug(sql_handle);
- else if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `name` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
- SQL->GetData(sql_handle, 0, &data, &len);
+ SQL->GetData(inter->sql_handle, 0, &data, &len);
safestrncpy(name, data, NAME_LENGTH);
return 1;
}
@@ -2861,24 +2894,20 @@ int char_loadName(int char_id, char* name)
return 0;
}
-int search_mapserver(unsigned short map, uint32 ip, uint16 port);
-
-
/// Initializes a server structure.
void mapif_server_init(int id)
{
- //memset(&server[id], 0, sizeof(server[id]));
- server[id].fd = -1;
+ //memset(&chr->server[id], 0, sizeof(server[id]));
+ chr->server[id].fd = -1;
}
-
/// Destroys a server structure.
void mapif_server_destroy(int id)
{
- if( server[id].fd == -1 )
+ if( chr->server[id].fd == -1 )
{
- do_close(server[id].fd);
- server[id].fd = -1;
+ do_close(chr->server[id].fd);
+ chr->server[id].fd = -1;
}
}
@@ -2888,254 +2917,940 @@ void mapif_server_reset(int id)
{
int i,j;
unsigned char buf[16384];
- int fd = server[id].fd;
+ int fd = chr->server[id].fd;
//Notify other map servers that this one is gone. [Skotlex]
WBUFW(buf,0) = 0x2b20;
- WBUFL(buf,4) = htonl(server[id].ip);
- WBUFW(buf,8) = htons(server[id].port);
+ WBUFL(buf,4) = htonl(chr->server[id].ip);
+ WBUFW(buf,8) = htons(chr->server[id].port);
j = 0;
- for(i = 0; i < server[id].maps; i++)
- if (server[id].map[i])
- WBUFW(buf,10+(j++)*4) = server[id].map[i];
+ for(i = 0; i < chr->server[id].maps; i++)
+ if (chr->server[id].map[i])
+ WBUFW(buf,10+(j++)*4) = chr->server[id].map[i];
if (j > 0) {
WBUFW(buf,2) = j * 4 + 10;
- mapif_sendallwos(fd, buf, WBUFW(buf,2));
+ mapif->sendallwos(fd, buf, WBUFW(buf,2));
}
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `index`='%d'", ragsrvinfo_db, server[id].fd) )
- Sql_ShowDebug(sql_handle);
- online_char_db->foreach(online_char_db,char_db_setoffline,id); //Tag relevant chars as 'in disconnected' server.
- mapif_server_destroy(id);
- mapif_server_init(id);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `index`='%d'", ragsrvinfo_db, chr->server[id].fd) )
+ Sql_ShowDebug(inter->sql_handle);
+ chr->online_char_db->foreach(chr->online_char_db,chr->db_setoffline,id); //Tag relevant chars as 'in disconnected' server.
+ mapif->server_destroy(id);
+ mapif->server_init(id);
}
-
/// Called when the connection to a Map Server is disconnected.
void mapif_on_disconnect(int id)
{
ShowStatus("Map-server #%d has disconnected.\n", id);
- mapif_server_reset(id);
+ mapif->server_reset(id);
}
void mapif_on_parse_accinfo(int account_id, int u_fd, int u_aid, int u_group, int map_fd) {
- WFIFOHEAD(login_fd,22);
- WFIFOW(login_fd,0) = 0x2740;
- WFIFOL(login_fd,2) = account_id;
- WFIFOL(login_fd,6) = u_fd;
- WFIFOL(login_fd,10) = u_aid;
- WFIFOL(login_fd,14) = u_group;
- WFIFOL(login_fd,18) = map_fd;
- WFIFOSET(login_fd,22);
+ WFIFOHEAD(chr->login_fd,22);
+ WFIFOW(chr->login_fd,0) = 0x2740;
+ WFIFOL(chr->login_fd,2) = account_id;
+ WFIFOL(chr->login_fd,6) = u_fd;
+ WFIFOL(chr->login_fd,10) = u_aid;
+ WFIFOL(chr->login_fd,14) = u_group;
+ WFIFOL(chr->login_fd,18) = map_fd;
+ WFIFOSET(chr->login_fd,22);
}
-int parse_frommap(int fd)
+void char_parse_frommap_datasync(int fd)
{
- int i, j;
+ sockt->datasync(fd, false);
+ RFIFOSKIP(fd,RFIFOW(fd,2));
+}
+
+void char_parse_frommap_skillid2idx(int fd)
+{
+ int i;
+ int j = RFIFOW(fd, 2) - 4;
+
+ memset(&skillid2idx, 0, sizeof(skillid2idx));
+ if( j )
+ j /= 4;
+ for(i = 0; i < j; i++) {
+ if( RFIFOW(fd, 4 + (i*4)) > MAX_SKILL_ID ) {
+ ShowWarning("Error skillid2dx[%d] = %d failed, %d is higher than MAX_SKILL_ID (%d)\n",RFIFOW(fd, 4 + (i*4)), RFIFOW(fd, 6 + (i*4)),RFIFOW(fd, 4 + (i*4)),MAX_SKILL_ID);
+ continue;
+ }
+ skillid2idx[RFIFOW(fd, 4 + (i*4))] = RFIFOW(fd, 6 + (i*4));
+ }
+ RFIFOSKIP(fd, RFIFOW(fd, 2));
+}
+
+void char_map_received_ok(int fd)
+{
+ WFIFOHEAD(fd, 3 + NAME_LENGTH);
+ WFIFOW(fd,0) = 0x2afb;
+ WFIFOB(fd,2) = 0;
+ memcpy(WFIFOP(fd,3), wisp_server_name, NAME_LENGTH);
+ WFIFOSET(fd,3+NAME_LENGTH);
+}
+
+void char_send_maps(int fd, int id, int j)
+{
+ unsigned char buf[16384];
+ int x,i;
+
+ if (j == 0) {
+ ShowWarning("Map-server %d has NO maps.\n", id);
+ } else {
+ // Transmitting maps information to the other map-servers
+ WBUFW(buf,0) = 0x2b04;
+ WBUFW(buf,2) = j * 4 + 10;
+ WBUFL(buf,4) = htonl(chr->server[id].ip);
+ WBUFW(buf,8) = htons(chr->server[id].port);
+ memcpy(WBUFP(buf,10), RFIFOP(fd,4), j * 4);
+ mapif->sendallwos(fd, buf, WBUFW(buf,2));
+ }
+ // Transmitting the maps of the other map-servers to the new map-server
+ for(x = 0; x < ARRAYLENGTH(chr->server); x++) {
+ if (chr->server[x].fd > 0 && x != id) {
+ WFIFOHEAD(fd,10 +4*ARRAYLENGTH(chr->server[x].map));
+ WFIFOW(fd,0) = 0x2b04;
+ WFIFOL(fd,4) = htonl(chr->server[x].ip);
+ WFIFOW(fd,8) = htons(chr->server[x].port);
+ j = 0;
+ for(i = 0; i < ARRAYLENGTH(chr->server[x].map); i++)
+ if (chr->server[x].map[i])
+ WFIFOW(fd,10+(j++)*4) = chr->server[x].map[i];
+ if (j > 0) {
+ WFIFOW(fd,2) = j * 4 + 10;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ }
+ }
+ }
+}
+
+void char_parse_frommap_map_names(int fd, int id)
+{
+ int i,j = 0;
+
+ if( chr->server[id].map != NULL ) { aFree(chr->server[id].map); chr->server[id].map = NULL; }
+
+ chr->server[id].maps = ( RFIFOW(fd, 2) - 4 ) / 4;
+ CREATE(chr->server[id].map, unsigned short, chr->server[id].maps);
+
+
+ for(i = 4; i < RFIFOW(fd,2); i += 4) {
+ chr->server[id].map[j] = RFIFOW(fd,i);
+ j++;
+ }
+
+ ShowStatus("Map-Server %d connected: %d maps, from IP %d.%d.%d.%d port %d.\n",
+ id, j, CONVIP(chr->server[id].ip), chr->server[id].port);
+ ShowStatus("Map-server %d loading complete.\n", id);
+
+ // send name for wisp to player
+ chr->map_received_ok(fd);
+ chr->send_fame_list(fd); //Send fame list.
+ chr->send_maps(fd, id, j);
+ RFIFOSKIP(fd,RFIFOW(fd,2));
+}
+
+void char_send_scdata(int fd, int aid, int cid)
+{
+ #ifdef ENABLE_SC_SAVING
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `type`, `tick`, `val1`, `val2`, `val3`, `val4` "
+ "FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'",
+ scdata_db, aid, cid) )
+ {
+ Sql_ShowDebug(inter->sql_handle);
+ return;
+ }
+ if( SQL->NumRows(inter->sql_handle) > 0 ) {
+ struct status_change_data scdata;
+ int count;
+ char* data;
+
+ memset(&scdata, 0, sizeof(scdata));
+ WFIFOHEAD(fd,14+50*sizeof(struct status_change_data));
+ WFIFOW(fd,0) = 0x2b1d;
+ WFIFOL(fd,4) = aid;
+ WFIFOL(fd,8) = cid;
+ for( count = 0; count < 50 && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++count )
+ {
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); scdata.type = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); scdata.tick = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); scdata.val1 = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); scdata.val2 = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); scdata.val3 = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); scdata.val4 = atoi(data);
+ memcpy(WFIFOP(fd, 14+count*sizeof(struct status_change_data)), &scdata, sizeof(struct status_change_data));
+ }
+ if (count >= 50)
+ ShowWarning("Too many status changes for %d:%d, some of them were not loaded.\n", aid, cid);
+ if (count > 0) {
+ WFIFOW(fd,2) = 14 + count*sizeof(struct status_change_data);
+ WFIFOW(fd,12) = count;
+ WFIFOSET(fd,WFIFOW(fd,2));
+
+ //Clear the data once loaded.
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) )
+ Sql_ShowDebug(inter->sql_handle);
+ }
+ } else { //no sc (needs a response)
+ WFIFOHEAD(fd,14);
+ WFIFOW(fd,0) = 0x2b1d;
+ WFIFOW(fd,2) = 14;
+ WFIFOL(fd,4) = aid;
+ WFIFOL(fd,8) = cid;
+ WFIFOW(fd,12) = 0;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ }
+ SQL->FreeResult(inter->sql_handle);
+ #endif
+}
+
+void char_parse_frommap_request_scdata(int fd)
+{
+ #ifdef ENABLE_SC_SAVING
+ int aid = RFIFOL(fd,2);
+ int cid = RFIFOL(fd,6);
+ chr->send_scdata(fd, aid, cid);
+ #endif
+ RFIFOSKIP(fd, 10);
+}
+
+void char_parse_frommap_set_users_count(int fd, int id)
+{
+ if (RFIFOW(fd,2) != chr->server[id].users) {
+ chr->server[id].users = RFIFOW(fd,2);
+ ShowInfo("User Count: %d (Server: %d)\n", chr->server[id].users, id);
+ }
+ RFIFOSKIP(fd, 4);
+}
+
+void char_parse_frommap_set_users(int fd, int id)
+{
+ //TODO: When data mismatches memory, update guild/party online/offline states.
+ int aid, cid, i;
+ struct online_char_data* character;
+
+ chr->server[id].users = RFIFOW(fd,4);
+ chr->online_char_db->foreach(chr->online_char_db,chr->db_setoffline,id); //Set all chars from this server as 'unknown'
+ for(i = 0; i < chr->server[id].users; i++) {
+ aid = RFIFOL(fd,6+i*8);
+ cid = RFIFOL(fd,6+i*8+4);
+ character = idb_ensure(chr->online_char_db, aid, chr->create_online_char_data);
+ if( character->server > -1 && character->server != id )
+ {
+ ShowNotice("Set map user: Character (%d:%d) marked on map server %d, but map server %d claims to have (%d:%d) online!\n",
+ character->account_id, character->char_id, character->server, id, aid, cid);
+ mapif->disconnectplayer(chr->server[character->server].fd, character->account_id, character->char_id, 2);
+ }
+ character->server = id;
+ character->char_id = cid;
+ }
+ //If any chars remain in -2, they will be cleaned in the cleanup timer.
+ RFIFOSKIP(fd,RFIFOW(fd,2));
+}
+
+void char_save_character_ack(int fd, int aid, int cid)
+{
+ WFIFOHEAD(fd,10);
+ WFIFOW(fd,0) = 0x2b21; //Save ack only needed on final save.
+ WFIFOL(fd,2) = aid;
+ WFIFOL(fd,6) = cid;
+ WFIFOSET(fd,10);
+}
+
+void char_parse_frommap_save_character(int fd, int id)
+{
+ int aid = RFIFOL(fd,4), cid = RFIFOL(fd,8), size = RFIFOW(fd,2);
+ struct online_char_data* character;
+
+ if (size - 13 != sizeof(struct mmo_charstatus)) {
+ ShowError("parse_from_map (save-char): Size mismatch! %d != %"PRIuS"\n", size-13, sizeof(struct mmo_charstatus));
+ RFIFOSKIP(fd,size);
+ return;
+ }
+ //Check account only if this ain't final save. Final-save goes through because of the char-map reconnect
+ if (RFIFOB(fd,12)
+ || ( (character = (struct online_char_data*)idb_get(chr->online_char_db, aid)) != NULL
+ && character->char_id == cid)
+ ) {
+ struct mmo_charstatus char_dat;
+ memcpy(&char_dat, RFIFOP(fd,13), sizeof(struct mmo_charstatus));
+ chr->mmo_char_tosql(cid, &char_dat);
+ } else {
+ //This may be valid on char-server reconnection, when re-sending characters that already logged off.
+ ShowError("parse_from_map (save-char): Received data for non-existing/offline character (%d:%d).\n", aid, cid);
+ chr->set_char_online(id, cid, aid);
+ }
+
+ if (RFIFOB(fd,12)) {
+ //Flag, set character offline after saving. [Skotlex]
+ chr->set_char_offline(cid, aid);
+ chr->save_character_ack(fd, aid, cid);
+ }
+ RFIFOSKIP(fd,size);
+}
+
+// 0 - not ok
+// 1 - ok
+void char_select_ack(int fd, int account_id, uint8 flag)
+{
+ WFIFOHEAD(fd,7);
+ WFIFOW(fd,0) = 0x2b03;
+ WFIFOL(fd,2) = account_id;
+ WFIFOB(fd,6) = flag;
+ WFIFOSET(fd,7);
+}
+
+void char_parse_frommap_char_select_req(int fd)
+{
+ int account_id = RFIFOL(fd,2);
+ uint32 login_id1 = RFIFOL(fd,6);
+ uint32 login_id2 = RFIFOL(fd,10);
+ uint32 ip = RFIFOL(fd,14);
+ int32 group_id = RFIFOL(fd, 18);
+ RFIFOSKIP(fd,22);
+
+ if( runflag != CHARSERVER_ST_RUNNING )
+ {
+ chr->select_ack(fd, account_id, 0);
+ }
+ else
+ {
+ struct char_auth_node* node;
+
+ // create temporary auth entry
+ CREATE(node, struct char_auth_node, 1);
+ node->account_id = account_id;
+ node->char_id = 0;
+ node->login_id1 = login_id1;
+ node->login_id2 = login_id2;
+ node->group_id = group_id;
+ //node->sex = 0;
+ node->ip = ntohl(ip);
+ /* sounds troublesome. */
+ //node->expiration_time = 0; // unlimited/unknown time by default (not display in map-server)
+ //node->gmlevel = 0;
+ idb_put(auth_db, account_id, node);
+
+ //Set char to "@ char select" in online db [Kevin]
+ chr->set_char_charselect(account_id);
+ chr->select_ack(fd, account_id, 1);
+ }
+}
+
+void char_change_map_server_ack(int fd, uint8 *data, bool ok)
+{
+ WFIFOHEAD(fd,30);
+ WFIFOW(fd,0) = 0x2b06;
+ memcpy(WFIFOP(fd,2), data, 28);
+ if (!ok)
+ WFIFOL(fd,6) = 0; //Set login1 to 0.
+ WFIFOSET(fd,30);
+}
+
+void char_parse_frommap_change_map_server(int fd)
+{
+ int map_id, map_fd = -1;
+ struct mmo_charstatus* char_data;
+
+ map_id = chr->search_mapserver(RFIFOW(fd,18), ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28))); //Locate mapserver by ip and port.
+ if (map_id >= 0)
+ map_fd = chr->server[map_id].fd;
+ //Char should just had been saved before this packet, so this should be safe. [Skotlex]
+ char_data = (struct mmo_charstatus*)uidb_get(chr->char_db_,RFIFOL(fd,14));
+ if (char_data == NULL) {
+ //Really shouldn't happen.
+ struct mmo_charstatus char_dat;
+ chr->mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true);
+ char_data = (struct mmo_charstatus*)uidb_get(chr->char_db_,RFIFOL(fd,14));
+ }
+
+ if (runflag == CHARSERVER_ST_RUNNING && session_isActive(map_fd) && char_data) {
+ //Send the map server the auth of this player.
+ struct online_char_data* data;
+ struct char_auth_node* node;
+
+ //Update the "last map" as this is where the player must be spawned on the new map server.
+ char_data->last_point.map = RFIFOW(fd,18);
+ char_data->last_point.x = RFIFOW(fd,20);
+ char_data->last_point.y = RFIFOW(fd,22);
+ char_data->sex = RFIFOB(fd,30);
+
+ // create temporary auth entry
+ CREATE(node, struct char_auth_node, 1);
+ node->account_id = RFIFOL(fd,2);
+ node->char_id = RFIFOL(fd,14);
+ node->login_id1 = RFIFOL(fd,6);
+ node->login_id2 = RFIFOL(fd,10);
+ node->sex = RFIFOB(fd,30);
+ node->expiration_time = 0; // FIXME (this thing isn't really supported we could as well purge it instead of fixing)
+ node->ip = ntohl(RFIFOL(fd,31));
+ node->group_id = RFIFOL(fd,35);
+ node->changing_mapservers = 1;
+ idb_put(auth_db, RFIFOL(fd,2), node);
+
+ data = idb_ensure(chr->online_char_db, RFIFOL(fd,2), chr->create_online_char_data);
+ data->char_id = char_data->char_id;
+ data->server = map_id; //Update server where char is.
+
+ //Reply with an ack.
+ chr->change_map_server_ack(fd, RFIFOP(fd,2), true);
+ } else { //Reply with nak
+ chr->change_map_server_ack(fd, RFIFOP(fd,2), false);
+ }
+ RFIFOSKIP(fd,39);
+}
+
+void char_parse_frommap_remove_friend(int fd)
+{
+ int char_id = RFIFOL(fd,2);
+ int friend_id = RFIFOL(fd,6);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `friend_id`='%d' LIMIT 1",
+ friend_db, char_id, friend_id) ) {
+ Sql_ShowDebug(inter->sql_handle);
+ }
+ RFIFOSKIP(fd,10);
+}
+
+void char_char_name_ack(int fd, int char_id)
+{
+ WFIFOHEAD(fd,30);
+ WFIFOW(fd,0) = 0x2b09;
+ WFIFOL(fd,2) = char_id;
+ chr->loadName(char_id, (char*)WFIFOP(fd,6));
+ WFIFOSET(fd,30);
+}
+
+void char_parse_frommap_char_name_request(int fd)
+{
+ chr->char_name_ack(fd, RFIFOL(fd,2));
+ RFIFOSKIP(fd,6);
+}
+
+void char_parse_frommap_change_email(int fd)
+{
+ if (chr->login_fd > 0) { // don't send request if no login-server
+ WFIFOHEAD(chr->login_fd,86);
+ memcpy(WFIFOP(chr->login_fd,0), RFIFOP(fd,0),86); // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
+ WFIFOW(chr->login_fd,0) = 0x2722;
+ WFIFOSET(chr->login_fd,86);
+ }
+ RFIFOSKIP(fd, 86);
+}
+
+void mapif_char_ban(int char_id, time_t timestamp)
+{
+ unsigned char buf[11];
+ WBUFW(buf,0) = 0x2b14;
+ WBUFL(buf,2) = char_id;
+ WBUFB(buf,6) = 2;
+ WBUFL(buf,7) = (unsigned int)timestamp;
+ mapif->sendall(buf, 11);
+}
+
+void char_ban(int account_id, int char_id, time_t *unban_time, short year, short month, short day, short hour, short minute, short second)
+{
+ time_t timestamp;
+ struct tm *tmtime;
+ SqlStmt* stmt = SQL->StmtMalloc(inter->sql_handle);
+
+ if (*unban_time == 0 || *unban_time < time(NULL))
+ timestamp = time(NULL); // new ban
+ else
+ timestamp = *unban_time; // add to existing ban
+
+ tmtime = localtime(&timestamp);
+ tmtime->tm_year = tmtime->tm_year + year;
+ tmtime->tm_mon = tmtime->tm_mon + month;
+ tmtime->tm_mday = tmtime->tm_mday + day;
+ tmtime->tm_hour = tmtime->tm_hour + hour;
+ tmtime->tm_min = tmtime->tm_min + minute;
+ tmtime->tm_sec = tmtime->tm_sec + second;
+ timestamp = mktime(tmtime);
+
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt,
+ "UPDATE `%s` SET `unban_time` = ? WHERE `char_id` = ? LIMIT 1",
+ char_db)
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_LONG, (void*)&timestamp, sizeof(timestamp))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_INT, (void*)&char_id, sizeof(char_id))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt)
+
+ ) {
+ SqlStmt_ShowDebug(stmt);
+ }
+
+ SQL->StmtFree(stmt);
+
+ // condition applies; send to all map-servers to disconnect the player
+ if( timestamp > time(NULL) ) {
+ mapif->char_ban(char_id, timestamp);
+ // disconnect player if online on char-server
+ chr->disconnect_player(account_id);
+ }
+}
+
+void char_unban(int char_id, int *result)
+{
+ /* handled by char server, so no redirection */
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `unban_time` = '0' WHERE `char_id` = '%d' LIMIT 1", char_db, char_id) ) {
+ Sql_ShowDebug(inter->sql_handle);
+ *result = 1;
+ }
+}
+
+void char_ask_name_ack(int fd, int acc, const char* name, int type, int result)
+{
+ WFIFOHEAD(fd,34);
+ WFIFOW(fd, 0) = 0x2b0f;
+ WFIFOL(fd, 2) = acc;
+ safestrncpy((char*)WFIFOP(fd,6), name, NAME_LENGTH);
+ WFIFOW(fd,30) = type;
+ WFIFOW(fd,32) = result;
+ WFIFOSET(fd,34);
+}
+
+void char_parse_frommap_change_account(int fd)
+{
+ int result = 0; // 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
+ char esc_name[NAME_LENGTH*2+1];
+
+ int acc = RFIFOL(fd,2); // account_id of who ask (-1 if server itself made this request)
+ const char* name = (char*)RFIFOP(fd,6); // name of the target character
+ int type = RFIFOW(fd,30); // type of operation: 1-block, 2-ban, 3-unblock, 4-unban, 5 changesex, 6 charban, 7 charunban
+ short year = RFIFOW(fd,32);
+ short month = RFIFOW(fd,34);
+ short day = RFIFOW(fd,36);
+ short hour = RFIFOW(fd,38);
+ short minute = RFIFOW(fd,40);
+ short second = RFIFOW(fd,42);
+ RFIFOSKIP(fd,44);
+
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`char_id`,`unban_time` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL->NumRows(inter->sql_handle) == 0 ) {
+ result = 1; // 1-player not found
+ } else if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) ) {
+ Sql_ShowDebug(inter->sql_handle);
+ result = 1; // 1-player not found
+ } else {
+ int account_id, char_id;
+ char* data;
+ time_t unban_time;
+
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); unban_time = atol(data);
+
+ if( chr->login_fd <= 0 ) {
+ result = 3; // 3-login-server offline
+#if 0 //FIXME: need to move this check to login server [ultramage]
+ } else if( acc != -1 && isGM(acc) < isGM(account_id) ) {
+ result = 2; // 2-gm level too low
+#endif // 0
+ } else {
+ switch( type ) {
+ case 1: // block
+ loginif->block_account(account_id, 5);
+ break;
+ case 2: // ban
+ loginif->ban_account(account_id, year, month, day, hour, minute, second);
+ break;
+ case 3: // unblock
+ loginif->block_account(account_id, 0);
+ break;
+ case 4: // unban
+ loginif->unban_account(account_id);
+ break;
+ case 5: // changesex
+ loginif->changesex(account_id);
+ break;
+ case 6: //char ban
+ /* handled by char server, so no redirection */
+ {
+ chr->ban(account_id, char_id, &unban_time, year, month, day, hour, minute, second);
+ }
+ break;
+ case 7: //char unban
+ chr->unban(char_id, &result);
+ break;
+
+ }
+ }
+ }
+
+ SQL->FreeResult(inter->sql_handle);
+
+ // send answer if a player ask, not if the server ask
+ if( acc != -1 && type != 5 ) { // Don't send answer for changesex
+ chr->ask_name_ack(fd, acc, name, type, result);
+ }
+}
+
+void char_parse_frommap_fame_list(int fd)
+{
+ int cid = RFIFOL(fd, 2);
+ int fame = RFIFOL(fd, 6);
+ char type = RFIFOB(fd, 10);
+ int size;
+ struct fame_list* list;
+ int player_pos;
+ int fame_pos;
+
+ switch(type) {
+ case RANKTYPE_BLACKSMITH: size = fame_list_size_smith; list = smith_fame_list; break;
+ case RANKTYPE_ALCHEMIST: size = fame_list_size_chemist; list = chemist_fame_list; break;
+ case RANKTYPE_TAEKWON: size = fame_list_size_taekwon; list = taekwon_fame_list; break;
+ default: size = 0; list = NULL; break;
+ }
+
+ ARR_FIND(0, size, player_pos, list[player_pos].id == cid);// position of the player
+ ARR_FIND(0, size, fame_pos, list[fame_pos].fame <= fame);// where the player should be
+
+ if( player_pos == size && fame_pos == size )
+ ;// not on list and not enough fame to get on it
+ else if( fame_pos == player_pos ) {
+ // same position
+ list[player_pos].fame = fame;
+ chr->update_fame_list(type, player_pos, fame);
+ } else {
+ // move in the list
+ if( player_pos == size ) {
+ // new ranker - not in the list
+ ARR_MOVE(size - 1, fame_pos, list, struct fame_list);
+ list[fame_pos].id = cid;
+ list[fame_pos].fame = fame;
+ chr->loadName(cid, list[fame_pos].name);
+ } else {
+ // already in the list
+ if( fame_pos == size )
+ --fame_pos;// move to the end of the list
+ ARR_MOVE(player_pos, fame_pos, list, struct fame_list);
+ list[fame_pos].fame = fame;
+ }
+ chr->send_fame_list(-1);
+ }
+
+ RFIFOSKIP(fd,11);
+}
+
+void char_parse_frommap_divorce_char(int fd)
+{
+ chr->divorce_char_sql(RFIFOL(fd,2), RFIFOL(fd,6));
+ RFIFOSKIP(fd,10);
+}
+
+void char_parse_frommap_ragsrvinfo(int fd)
+{
+ char esc_server_name[sizeof(chr->server_name)*2+1];
+
+ SQL->EscapeString(inter->sql_handle, esc_server_name, chr->server_name);
+
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` SET `index`='%d',`name`='%s',`exp`='%d',`jexp`='%d',`drop`='%d'",
+ ragsrvinfo_db, fd, esc_server_name, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)) )
+ {
+ Sql_ShowDebug(inter->sql_handle);
+ }
+ RFIFOSKIP(fd,14);
+}
+
+void char_parse_frommap_set_char_offline(int fd)
+{
+ chr->set_char_offline(RFIFOL(fd,2),RFIFOL(fd,6));
+ RFIFOSKIP(fd,10);
+}
+
+void char_parse_frommap_set_all_offline(int fd, int id)
+{
+ chr->set_all_offline(id);
+ RFIFOSKIP(fd,2);
+}
+
+void char_parse_frommap_set_char_online(int fd, int id)
+{
+ chr->set_char_online(id, RFIFOL(fd,2),RFIFOL(fd,6));
+ RFIFOSKIP(fd,10);
+}
+
+void char_parse_frommap_build_fame_list(int fd)
+{
+ chr->read_fame_list();
+ chr->send_fame_list(-1);
+ RFIFOSKIP(fd,2);
+}
+
+void char_parse_frommap_save_status_change_data(int fd)
+{
+ #ifdef ENABLE_SC_SAVING
+ int aid = RFIFOL(fd, 4);
+ int cid = RFIFOL(fd, 8);
+ int count = RFIFOW(fd, 12);
+
+ /* clear; ensure no left overs e.g. permanent */
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) )
+ Sql_ShowDebug(inter->sql_handle);
+
+ if( count > 0 )
+ {
+ struct status_change_data data;
+ StringBuf buf;
+ int i;
+
+ StrBuf->Init(&buf);
+ StrBuf->Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db);
+ for( i = 0; i < count; ++i )
+ {
+ memcpy (&data, RFIFOP(fd, 14+i*sizeof(struct status_change_data)), sizeof(struct status_change_data));
+ if( i > 0 )
+ StrBuf->AppendStr(&buf, ", ");
+ StrBuf->Printf(&buf, "('%d','%d','%hu','%d','%d','%d','%d','%d')", aid, cid,
+ data.type, data.tick, data.val1, data.val2, data.val3, data.val4);
+ }
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
+ Sql_ShowDebug(inter->sql_handle);
+ StrBuf->Destroy(&buf);
+ }
+ #endif
+ RFIFOSKIP(fd, RFIFOW(fd, 2));
+}
+
+void char_send_pong(int fd)
+{
+ WFIFOHEAD(fd,2);
+ WFIFOW(fd,0) = 0x2b24;
+ WFIFOSET(fd,2);
+}
+
+void char_parse_frommap_ping(int fd)
+{
+ chr->send_pong(fd);
+ RFIFOSKIP(fd,2);
+}
+
+void char_map_auth_ok(int fd, int account_id, struct char_auth_node* node, struct mmo_charstatus* cd)
+{
+ WFIFOHEAD(fd,25 + sizeof(struct mmo_charstatus));
+ WFIFOW(fd,0) = 0x2afd;
+ WFIFOW(fd,2) = 25 + sizeof(struct mmo_charstatus);
+ WFIFOL(fd,4) = account_id;
+ if (node)
+ {
+ WFIFOL(fd,8) = node->login_id1;
+ WFIFOL(fd,12) = node->login_id2;
+ WFIFOL(fd,16) = (uint32)node->expiration_time; // FIXME: will wrap to negative after "19-Jan-2038, 03:14:07 AM GMT"
+ WFIFOL(fd,20) = node->group_id;
+ WFIFOB(fd,24) = node->changing_mapservers;
+ }
+ else
+ {
+ WFIFOL(fd,8) = 0;
+ WFIFOL(fd,12) = 0;
+ WFIFOL(fd,16) = 0;
+ WFIFOL(fd,20) = 0;
+ WFIFOB(fd,24) = 0;
+ }
+ memcpy(WFIFOP(fd,25), cd, sizeof(struct mmo_charstatus));
+ WFIFOSET(fd, WFIFOW(fd,2));
+}
+
+void char_map_auth_failed(int fd, int account_id, int char_id, int login_id1, char sex, uint32 ip)
+{
+ WFIFOHEAD(fd,19);
+ WFIFOW(fd,0) = 0x2b27;
+ WFIFOL(fd,2) = account_id;
+ WFIFOL(fd,6) = char_id;
+ WFIFOL(fd,10) = login_id1;
+ WFIFOB(fd,14) = sex;
+ WFIFOL(fd,15) = htonl(ip);
+ WFIFOSET(fd,19);
+}
+
+void char_parse_frommap_auth_request(int fd, int id)
+{
+ struct mmo_charstatus char_dat;
+ struct char_auth_node* node;
+ struct mmo_charstatus* cd;
+
+ int account_id = RFIFOL(fd,2);
+ int char_id = RFIFOL(fd,6);
+ int login_id1 = RFIFOL(fd,10);
+ char sex = RFIFOB(fd,14);
+ uint32 ip = ntohl(RFIFOL(fd,15));
+ char standalone = RFIFOB(fd, 19);
+ RFIFOSKIP(fd,20);
+
+ node = (struct char_auth_node*)idb_get(auth_db, account_id);
+ cd = (struct mmo_charstatus*)uidb_get(chr->char_db_,char_id);
+
+ if( cd == NULL ) { //Really shouldn't happen.
+ chr->mmo_char_fromsql(char_id, &char_dat, true);
+ cd = (struct mmo_charstatus*)uidb_get(chr->char_db_,char_id);
+ }
+
+ if( runflag == CHARSERVER_ST_RUNNING && cd && standalone ) {
+ cd->sex = sex;
+
+ chr->map_auth_ok(fd, account_id, NULL, cd);
+ chr->set_char_online(id, char_id, account_id);
+ return;
+ }
+
+ if( runflag == CHARSERVER_ST_RUNNING &&
+ cd != NULL &&
+ node != NULL &&
+ node->account_id == account_id &&
+ node->char_id == char_id &&
+ node->login_id1 == login_id1 /*&&
+ node->sex == sex &&
+ node->ip == ip*/ )
+ {// auth ok
+ if( cd->sex == 99 )
+ cd->sex = sex;
+
+ chr->map_auth_ok(fd, account_id, node, cd);
+ // only use the auth once and mark user online
+ idb_remove(auth_db, account_id);
+ chr->set_char_online(id, char_id, account_id);
+ }
+ else
+ {// auth failed
+ chr->map_auth_failed(fd, account_id, char_id, login_id1, sex, ip);
+ }
+}
+
+void char_parse_frommap_update_ip(int fd, int id)
+{
+ chr->server[id].ip = ntohl(RFIFOL(fd, 2));
+ ShowInfo("Updated IP address of map-server #%d to %d.%d.%d.%d.\n", id, CONVIP(chr->server[id].ip));
+ RFIFOSKIP(fd,6);
+}
+
+void char_parse_frommap_request_stats_report(int fd)
+{
+ int sfd;/* stat server fd */
+ struct hSockOpt opt;
+ RFIFOSKIP(fd, 2);/* we skip first 2 bytes which are the 0x3008, so we end up with a buffer equal to the one we send */
+
+ opt.silent = 1;
+ opt.setTimeo = 1;
+
+ if( (sfd = make_connection(host2ip("stats.hercules.ws"),(uint16)25427,&opt) ) == -1 ) {
+ RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
+ RFIFOFLUSH(fd);
+ return;/* connection not possible, we drop the report */
+ }
+
+ session[sfd]->flag.server = 1;/* to ensure we won't drop our own packet */
+ realloc_fifo(sfd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+
+ WFIFOHEAD(sfd, RFIFOW(fd,2) );
+
+ memcpy((char*)WFIFOP(sfd,0), (char*)RFIFOP(fd, 0), RFIFOW(fd,2));
+
+ WFIFOSET(sfd, RFIFOW(fd,2) );
+
+ flush_fifo(sfd);
+
+ do_close(sfd);
+
+ RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
+ RFIFOFLUSH(fd);
+}
+
+void char_parse_frommap_scdata_update(int fd)
+{
+ int account_id = RFIFOL(fd, 2);
+ int char_id = RFIFOL(fd, 6);
+ int val1 = RFIFOL(fd, 12);
+ int val2 = RFIFOL(fd, 16);
+ int val3 = RFIFOL(fd, 20);
+ int val4 = RFIFOL(fd, 24);
+ short type = RFIFOW(fd, 10);
+
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`account_id`,`char_id`,`type`,`tick`,`val1`,`val2`,`val3`,`val4`) VALUES ('%d','%d','%d',-1,'%d','%d','%d','%d')",
+ scdata_db, account_id, char_id, type, val1, val2, val3, val4) )
+ {
+ Sql_ShowDebug(inter->sql_handle);
+ }
+ RFIFOSKIP(fd, 28);
+}
+
+void char_parse_frommap_scdata_delete(int fd)
+{
+ int account_id = RFIFOL(fd, 2);
+ int char_id = RFIFOL(fd, 6);
+ short type = RFIFOW(fd, 10);
+
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id` = '%d' AND `type` = '%d' LIMIT 1",
+ scdata_db, account_id, char_id, type) )
+ {
+ Sql_ShowDebug(inter->sql_handle);
+ }
+ RFIFOSKIP(fd, 12);
+}
+
+int char_parse_frommap(int fd)
+{
+ int i;
int id;
- ARR_FIND( 0, ARRAYLENGTH(server), id, server[id].fd == fd );
- if( id == ARRAYLENGTH(server) ) {// not a map server
- ShowDebug("parse_frommap: Disconnecting invalid session #%d (is not a map-server)\n", fd);
+ ARR_FIND( 0, ARRAYLENGTH(chr->server), id, chr->server[id].fd == fd );
+ if( id == ARRAYLENGTH(chr->server) ) {// not a map server
+ ShowDebug("chr->parse_frommap: Disconnecting invalid session #%d (is not a map-server)\n", fd);
do_close(fd);
return 0;
}
if( session[fd]->flag.eof ) {
do_close(fd);
- server[id].fd = -1;
- mapif_on_disconnect(id);
+ chr->server[id].fd = -1;
+ mapif->on_disconnect(id);
return 0;
}
while(RFIFOREST(fd) >= 2) {
-
if( HPM->packetsc[hpParse_FromMap] ) {
if( (i = HPM->parse_packets(fd,hpParse_FromMap)) ) {
if( i == 1 ) continue;
if( i == 2 ) return 0;
}
}
-
- switch(RFIFOW(fd,0)) {
+ switch(RFIFOW(fd,0)) {
case 0x2b0a:
if( RFIFOREST(fd) < RFIFOW(fd, 2) )
return 0;
- sockt->datasync(fd, false);
- RFIFOSKIP(fd,RFIFOW(fd,2));
+ chr->parse_frommap_datasync(fd);
break;
case 0x2b0b:
if( RFIFOREST(fd) < RFIFOW(fd, 2) )
return 0;
- memset(&skillid2idx, 0, sizeof(skillid2idx));
- j = RFIFOW(fd, 2) - 4;
- if( j )
- j /= 4;
- for(i = 0; i < j; i++) {
- if( RFIFOW(fd, 4 + (i*4)) > MAX_SKILL_ID ) {
- ShowWarning("Error skillid2dx[%d] = %d failed, %d is higher than MAX_SKILL_ID (%d)\n",RFIFOW(fd, 4 + (i*4)), RFIFOW(fd, 6 + (i*4)),RFIFOW(fd, 4 + (i*4)),MAX_SKILL_ID);
- continue;
- }
- skillid2idx[RFIFOW(fd, 4 + (i*4))] = RFIFOW(fd, 6 + (i*4));
- }
- RFIFOSKIP(fd, RFIFOW(fd, 2));
+ chr->parse_frommap_skillid2idx(fd);
break;
case 0x2afa: // Receiving map names list from the map-server
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
- if( server[id].map != NULL ) { aFree(server[id].map); server[id].map = NULL; }
-
- server[id].maps = ( RFIFOW(fd, 2) - 4 ) / 4;
- CREATE(server[id].map, unsigned short, server[id].maps);
-
- j = 0;
- for(i = 4; i < RFIFOW(fd,2); i += 4) {
- server[id].map[j] = RFIFOW(fd,i);
- j++;
- }
-
- ShowStatus("Map-Server %d connected: %d maps, from IP %d.%d.%d.%d port %d.\n",
- id, j, CONVIP(server[id].ip), server[id].port);
- ShowStatus("Map-server %d loading complete.\n", id);
-
- // send name for wisp to player
- WFIFOHEAD(fd, 3 + NAME_LENGTH);
- WFIFOW(fd,0) = 0x2afb;
- WFIFOB(fd,2) = 0;
- memcpy(WFIFOP(fd,3), wisp_server_name, NAME_LENGTH);
- WFIFOSET(fd,3+NAME_LENGTH);
-
- char_send_fame_list(fd); //Send fame list.
-
- {
- unsigned char buf[16384];
- int x;
- if (j == 0) {
- ShowWarning("Map-server %d has NO maps.\n", id);
- } else {
- // Transmitting maps information to the other map-servers
- WBUFW(buf,0) = 0x2b04;
- WBUFW(buf,2) = j * 4 + 10;
- WBUFL(buf,4) = htonl(server[id].ip);
- WBUFW(buf,8) = htons(server[id].port);
- memcpy(WBUFP(buf,10), RFIFOP(fd,4), j * 4);
- mapif_sendallwos(fd, buf, WBUFW(buf,2));
- }
- // Transmitting the maps of the other map-servers to the new map-server
- for(x = 0; x < ARRAYLENGTH(server); x++) {
- if (server[x].fd > 0 && x != id) {
- WFIFOHEAD(fd,10 +4*ARRAYLENGTH(server[x].map));
- WFIFOW(fd,0) = 0x2b04;
- WFIFOL(fd,4) = htonl(server[x].ip);
- WFIFOW(fd,8) = htons(server[x].port);
- j = 0;
- for(i = 0; i < ARRAYLENGTH(server[x].map); i++)
- if (server[x].map[i])
- WFIFOW(fd,10+(j++)*4) = server[x].map[i];
- if (j > 0) {
- WFIFOW(fd,2) = j * 4 + 10;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- }
- }
- }
- RFIFOSKIP(fd,RFIFOW(fd,2));
+ chr->parse_frommap_map_names(fd, id);
break;
case 0x2afc: //Packet command is now used for sc_data request. [Skotlex]
if (RFIFOREST(fd) < 10)
return 0;
{
- #ifdef ENABLE_SC_SAVING
- int aid, cid;
- aid = RFIFOL(fd,2);
- cid = RFIFOL(fd,6);
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `type`, `tick`, `val1`, `val2`, `val3`, `val4` "
- "FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'",
- scdata_db, aid, cid) )
- {
- Sql_ShowDebug(sql_handle);
- break;
- }
- if( SQL->NumRows(sql_handle) > 0 ) {
- struct status_change_data scdata;
- int count;
- char* data;
-
- WFIFOHEAD(fd,14+50*sizeof(struct status_change_data));
- WFIFOW(fd,0) = 0x2b1d;
- WFIFOL(fd,4) = aid;
- WFIFOL(fd,8) = cid;
- for( count = 0; count < 50 && SQL_SUCCESS == SQL->NextRow(sql_handle); ++count )
- {
- SQL->GetData(sql_handle, 0, &data, NULL); scdata.type = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); scdata.tick = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); scdata.val1 = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); scdata.val2 = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); scdata.val3 = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); scdata.val4 = atoi(data);
- memcpy(WFIFOP(fd, 14+count*sizeof(struct status_change_data)), &scdata, sizeof(struct status_change_data));
- }
- if (count >= 50)
- ShowWarning("Too many status changes for %d:%d, some of them were not loaded.\n", aid, cid);
- if (count > 0) {
- WFIFOW(fd,2) = 14 + count*sizeof(struct status_change_data);
- WFIFOW(fd,12) = count;
- WFIFOSET(fd,WFIFOW(fd,2));
-
- //Clear the data once loaded.
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) )
- Sql_ShowDebug(sql_handle);
- }
- } else { //no sc (needs a response)
- WFIFOHEAD(fd,14);
- WFIFOW(fd,0) = 0x2b1d;
- WFIFOW(fd,2) = 14;
- WFIFOL(fd,4) = aid;
- WFIFOL(fd,8) = cid;
- WFIFOW(fd,12) = 0;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- SQL->FreeResult(sql_handle);
- #endif
- RFIFOSKIP(fd, 10);
+ chr->parse_frommap_request_scdata(fd);
}
break;
case 0x2afe: //set MAP user count
if (RFIFOREST(fd) < 4)
return 0;
- if (RFIFOW(fd,2) != server[id].users) {
- server[id].users = RFIFOW(fd,2);
- ShowInfo("User Count: %d (Server: %d)\n", server[id].users, id);
- }
- RFIFOSKIP(fd, 4);
+ chr->parse_frommap_set_users_count(fd, id);
break;
case 0x2aff: //set MAP users
if (RFIFOREST(fd) < 6 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
{
- //TODO: When data mismatches memory, update guild/party online/offline states.
- int aid, cid;
- struct online_char_data* character;
-
- server[id].users = RFIFOW(fd,4);
- online_char_db->foreach(online_char_db,char_db_setoffline,id); //Set all chars from this server as 'unknown'
- for(i = 0; i < server[id].users; i++) {
- aid = RFIFOL(fd,6+i*8);
- cid = RFIFOL(fd,6+i*8+4);
- character = idb_ensure(online_char_db, aid, create_online_char_data);
- if( character->server > -1 && character->server != id )
- {
- ShowNotice("Set map user: Character (%d:%d) marked on map server %d, but map server %d claims to have (%d:%d) online!\n",
- character->account_id, character->char_id, character->server, id, aid, cid);
- mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2);
- }
- character->server = id;
- character->char_id = cid;
- }
- //If any chars remain in -2, they will be cleaned in the cleanup timer.
- RFIFOSKIP(fd,RFIFOW(fd,2));
+ chr->parse_frommap_set_users(fd, id);
}
break;
@@ -3143,37 +3858,8 @@ int parse_frommap(int fd)
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
{
- int aid = RFIFOL(fd,4), cid = RFIFOL(fd,8), size = RFIFOW(fd,2);
- struct online_char_data* character;
+ chr->parse_frommap_save_character(fd, id);
- if (size - 13 != sizeof(struct mmo_charstatus)) {
- ShowError("parse_from_map (save-char): Size mismatch! %d != %"PRIuS"\n", size-13, sizeof(struct mmo_charstatus));
- RFIFOSKIP(fd,size);
- break;
- }
- //Check account only if this ain't final save. Final-save goes through because of the char-map reconnect
- if (RFIFOB(fd,12) || (
- (character = (struct online_char_data*)idb_get(online_char_db, aid)) != NULL &&
- character->char_id == cid))
- {
- struct mmo_charstatus char_dat;
- memcpy(&char_dat, RFIFOP(fd,13), sizeof(struct mmo_charstatus));
- mmo_char_tosql(cid, &char_dat);
- } else { //This may be valid on char-server reconnection, when re-sending characters that already logged off.
- ShowError("parse_from_map (save-char): Received data for non-existing/offline character (%d:%d).\n", aid, cid);
- set_char_online(id, cid, aid);
- }
-
- if (RFIFOB(fd,12))
- { //Flag, set character offline after saving. [Skotlex]
- set_char_offline(cid, aid);
- WFIFOHEAD(fd,10);
- WFIFOW(fd,0) = 0x2b21; //Save ack only needed on final save.
- WFIFOL(fd,2) = aid;
- WFIFOL(fd,6) = cid;
- WFIFOSET(fd,10);
- }
- RFIFOSKIP(fd,size);
}
break;
@@ -3181,48 +3867,7 @@ int parse_frommap(int fd)
if( RFIFOREST(fd) < 22 )
return 0;
{
- int account_id = RFIFOL(fd,2);
- uint32 login_id1 = RFIFOL(fd,6);
- uint32 login_id2 = RFIFOL(fd,10);
- uint32 ip = RFIFOL(fd,14);
- int32 group_id = RFIFOL(fd, 18);
- RFIFOSKIP(fd,22);
-
- if( runflag != CHARSERVER_ST_RUNNING )
- {
- WFIFOHEAD(fd,7);
- WFIFOW(fd,0) = 0x2b03;
- WFIFOL(fd,2) = account_id;
- WFIFOB(fd,6) = 0;// not ok
- WFIFOSET(fd,7);
- }
- else
- {
- struct auth_node* node;
-
- // create temporary auth entry
- CREATE(node, struct auth_node, 1);
- node->account_id = account_id;
- node->char_id = 0;
- node->login_id1 = login_id1;
- node->login_id2 = login_id2;
- node->group_id = group_id;
- //node->sex = 0;
- node->ip = ntohl(ip);
- /* sounds troublesome. */
- //node->expiration_time = 0; // unlimited/unknown time by default (not display in map-server)
- //node->gmlevel = 0;
- idb_put(auth_db, account_id, node);
-
- //Set char to "@ char select" in online db [Kevin]
- set_char_charselect(account_id);
-
- WFIFOHEAD(fd,7);
- WFIFOW(fd,0) = 0x2b03;
- WFIFOL(fd,2) = account_id;
- WFIFOB(fd,6) = 1;// ok
- WFIFOSET(fd,7);
- }
+ chr->parse_frommap_char_select_req(fd);
}
break;
@@ -3230,63 +3875,7 @@ int parse_frommap(int fd)
if (RFIFOREST(fd) < 39)
return 0;
{
- int map_id, map_fd = -1;
- struct mmo_charstatus* char_data;
- struct mmo_charstatus char_dat;
-
- map_id = search_mapserver(RFIFOW(fd,18), ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28))); //Locate mapserver by ip and port.
- if (map_id >= 0)
- map_fd = server[map_id].fd;
- //Char should just had been saved before this packet, so this should be safe. [Skotlex]
- char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14));
- if (char_data == NULL) { //Really shouldn't happen.
- mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true);
- char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14));
- }
-
- if( runflag == CHARSERVER_ST_RUNNING &&
- session_isActive(map_fd) &&
- char_data )
- { //Send the map server the auth of this player.
- struct online_char_data* data;
- struct auth_node* node;
-
- //Update the "last map" as this is where the player must be spawned on the new map server.
- char_data->last_point.map = RFIFOW(fd,18);
- char_data->last_point.x = RFIFOW(fd,20);
- char_data->last_point.y = RFIFOW(fd,22);
- char_data->sex = RFIFOB(fd,30);
-
- // create temporary auth entry
- CREATE(node, struct auth_node, 1);
- node->account_id = RFIFOL(fd,2);
- node->char_id = RFIFOL(fd,14);
- node->login_id1 = RFIFOL(fd,6);
- node->login_id2 = RFIFOL(fd,10);
- node->sex = RFIFOB(fd,30);
- node->expiration_time = 0; // FIXME (this thing isn't really supported we could as well purge it instead of fixing)
- node->ip = ntohl(RFIFOL(fd,31));
- node->group_id = RFIFOL(fd,35);
- node->changing_mapservers = 1;
- idb_put(auth_db, RFIFOL(fd,2), node);
-
- data = idb_ensure(online_char_db, RFIFOL(fd,2), create_online_char_data);
- data->char_id = char_data->char_id;
- data->server = map_id; //Update server where char is.
-
- //Reply with an ack.
- WFIFOHEAD(fd,30);
- WFIFOW(fd,0) = 0x2b06;
- memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
- WFIFOSET(fd,30);
- } else { //Reply with nak
- WFIFOHEAD(fd,30);
- WFIFOW(fd,0) = 0x2b06;
- memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
- WFIFOL(fd,6) = 0; //Set login1 to 0.
- WFIFOSET(fd,30);
- }
- RFIFOSKIP(fd,39);
+ chr->parse_frommap_change_map_server(fd);
}
break;
@@ -3294,15 +3883,7 @@ int parse_frommap(int fd)
if (RFIFOREST(fd) < 10)
return 0;
{
- int char_id, friend_id;
- char_id = RFIFOL(fd,2);
- friend_id = RFIFOL(fd,6);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `friend_id`='%d' LIMIT 1",
- friend_db, char_id, friend_id) ) {
- Sql_ShowDebug(sql_handle);
- break;
- }
- RFIFOSKIP(fd,10);
+ chr->parse_frommap_remove_friend(fd);
}
break;
@@ -3310,182 +3891,20 @@ int parse_frommap(int fd)
if (RFIFOREST(fd) < 6)
return 0;
- WFIFOHEAD(fd,30);
- WFIFOW(fd,0) = 0x2b09;
- WFIFOL(fd,2) = RFIFOL(fd,2);
- char_loadName((int)RFIFOL(fd,2), (char*)WFIFOP(fd,6));
- WFIFOSET(fd,30);
-
- RFIFOSKIP(fd,6);
+ chr->parse_frommap_char_name_request(fd);
break;
case 0x2b0c: // Map server send information to change an email of an account -> login-server
if (RFIFOREST(fd) < 86)
return 0;
- if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd,86);
- memcpy(WFIFOP(login_fd,0), RFIFOP(fd,0),86); // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
- WFIFOW(login_fd,0) = 0x2722;
- WFIFOSET(login_fd,86);
- }
- RFIFOSKIP(fd, 86);
+ chr->parse_frommap_change_email(fd);
break;
case 0x2b0e: // Request from map-server to change an account's or character's status (accounts will just be forwarded to login server)
if (RFIFOREST(fd) < 44)
return 0;
{
- int result = 0; // 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- char esc_name[NAME_LENGTH*2+1];
-
- int acc = RFIFOL(fd,2); // account_id of who ask (-1 if server itself made this request)
- const char* name = (char*)RFIFOP(fd,6); // name of the target character
- int type = RFIFOW(fd,30); // type of operation: 1-block, 2-ban, 3-unblock, 4-unban, 5 changesex, 6 charban, 7 charunban
- short year = RFIFOW(fd,32);
- short month = RFIFOW(fd,34);
- short day = RFIFOW(fd,36);
- short hour = RFIFOW(fd,38);
- short minute = RFIFOW(fd,40);
- short second = RFIFOW(fd,42);
- RFIFOSKIP(fd,44);
-
- SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
-
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`char_id`,`unban_time` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
- Sql_ShowDebug(sql_handle);
- else if( SQL->NumRows(sql_handle) == 0 ) {
- result = 1; // 1-player not found
- } else if( SQL_SUCCESS != SQL->NextRow(sql_handle) ) {
- Sql_ShowDebug(sql_handle);
- result = 1; // 1-player not found
- } else {
- int account_id, char_id;
- char* data;
- time_t unban_time;
-
- SQL->GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); char_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); unban_time = atol(data);
-
- if( login_fd <= 0 )
- result = 3; // 3-login-server offline
- //FIXME: need to move this check to login server [ultramage]
- // else
- // if( acc != -1 && isGM(acc) < isGM(account_id) )
- // result = 2; // 2-gm level too low
- else {
- switch( type ) {
- case 1: // block
- WFIFOHEAD(login_fd,10);
- WFIFOW(login_fd,0) = 0x2724;
- WFIFOL(login_fd,2) = account_id;
- WFIFOL(login_fd,6) = 5; // new account status
- WFIFOSET(login_fd,10);
- break;
- case 2: // ban
- WFIFOHEAD(login_fd,18);
- WFIFOW(login_fd, 0) = 0x2725;
- WFIFOL(login_fd, 2) = account_id;
- WFIFOW(login_fd, 6) = year;
- WFIFOW(login_fd, 8) = month;
- WFIFOW(login_fd,10) = day;
- WFIFOW(login_fd,12) = hour;
- WFIFOW(login_fd,14) = minute;
- WFIFOW(login_fd,16) = second;
- WFIFOSET(login_fd,18);
- break;
- case 3: // unblock
- WFIFOHEAD(login_fd,10);
- WFIFOW(login_fd,0) = 0x2724;
- WFIFOL(login_fd,2) = account_id;
- WFIFOL(login_fd,6) = 0; // new account status
- WFIFOSET(login_fd,10);
- break;
- case 4: // unban
- WFIFOHEAD(login_fd,6);
- WFIFOW(login_fd,0) = 0x272a;
- WFIFOL(login_fd,2) = account_id;
- WFIFOSET(login_fd,6);
- break;
- case 5: // changesex
- WFIFOHEAD(login_fd,6);
- WFIFOW(login_fd,0) = 0x2727;
- WFIFOL(login_fd,2) = account_id;
- WFIFOSET(login_fd,6);
- break;
- case 6: //char ban
- /* handled by char server, so no redirection */
- {
- time_t timestamp;
- struct tm *tmtime;
- SqlStmt* stmt = SQL->StmtMalloc(sql_handle);
-
- if (unban_time == 0 || unban_time < time(NULL))
- timestamp = time(NULL); // new ban
- else
- timestamp = unban_time; // add to existing ban
-
- tmtime = localtime(&timestamp);
- tmtime->tm_year = tmtime->tm_year + year;
- tmtime->tm_mon = tmtime->tm_mon + month;
- tmtime->tm_mday = tmtime->tm_mday + day;
- tmtime->tm_hour = tmtime->tm_hour + hour;
- tmtime->tm_min = tmtime->tm_min + minute;
- tmtime->tm_sec = tmtime->tm_sec + second;
- timestamp = mktime(tmtime);
-
- if( SQL_SUCCESS != SQL->StmtPrepare(stmt,
- "UPDATE `%s` SET `unban_time` = ? WHERE `char_id` = ? LIMIT 1",
- char_db)
- || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_LONG, (void*)&timestamp, sizeof(timestamp))
- || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_INT, (void*)&char_id, sizeof(char_id))
- || SQL_SUCCESS != SQL->StmtExecute(stmt)
-
- ) {
- SqlStmt_ShowDebug(stmt);
- }
-
- SQL->StmtFree(stmt);
-
- // condition applies; send to all map-servers to disconnect the player
- if( timestamp > time(NULL) ) {
- unsigned char buf[11];
-
- WBUFW(buf,0) = 0x2b14;
- WBUFL(buf,2) = char_id;
- WBUFB(buf,6) = 2;
- WBUFL(buf,7) = (unsigned int)timestamp;
- mapif_sendall(buf, 11);
-
- // disconnect player if online on char-server
- disconnect_player(account_id);
- }
- }
- break;
- case 7: //char unban
- /* handled by char server, so no redirection */
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `unban_time` = '0' WHERE `char_id` = '%d' LIMIT 1", char_db, char_id) ) {
- Sql_ShowDebug(sql_handle);
- result = 1;
- }
- break;
-
- }
- }
- }
-
- SQL->FreeResult(sql_handle);
-
- // send answer if a player ask, not if the server ask
- if( acc != -1 && type != 5 ) { // Don't send answer for changesex
- WFIFOHEAD(fd,34);
- WFIFOW(fd, 0) = 0x2b0f;
- WFIFOL(fd, 2) = acc;
- safestrncpy((char*)WFIFOP(fd,6), name, NAME_LENGTH);
- WFIFOW(fd,30) = type;
- WFIFOW(fd,32) = result;
- WFIFOSET(fd,34);
- }
+ chr->parse_frommap_change_account(fd);
}
break;
@@ -3493,49 +3912,7 @@ int parse_frommap(int fd)
if (RFIFOREST(fd) < 11)
return 0;
{
- int cid = RFIFOL(fd, 2);
- int fame = RFIFOL(fd, 6);
- char type = RFIFOB(fd, 10);
- int size;
- struct fame_list* list;
- int player_pos;
- int fame_pos;
-
- switch(type) {
- case RANKTYPE_BLACKSMITH: size = fame_list_size_smith; list = smith_fame_list; break;
- case RANKTYPE_ALCHEMIST: size = fame_list_size_chemist; list = chemist_fame_list; break;
- case RANKTYPE_TAEKWON: size = fame_list_size_taekwon; list = taekwon_fame_list; break;
- default: size = 0; list = NULL; break;
- }
-
- ARR_FIND(0, size, player_pos, list[player_pos].id == cid);// position of the player
- ARR_FIND(0, size, fame_pos, list[fame_pos].fame <= fame);// where the player should be
-
- if( player_pos == size && fame_pos == size )
- ;// not on list and not enough fame to get on it
- else if( fame_pos == player_pos ) {
- // same position
- list[player_pos].fame = fame;
- char_update_fame_list(type, player_pos, fame);
- } else {
- // move in the list
- if( player_pos == size ) {
- // new ranker - not in the list
- ARR_MOVE(size - 1, fame_pos, list, struct fame_list);
- list[fame_pos].id = cid;
- list[fame_pos].fame = fame;
- char_loadName(cid, list[fame_pos].name);
- } else {
- // already in the list
- if( fame_pos == size )
- --fame_pos;// move to the end of the list
- ARR_MOVE(player_pos, fame_pos, list, struct fame_list);
- list[fame_pos].fame = fame;
- }
- char_send_fame_list(-1);
- }
-
- RFIFOSKIP(fd,11);
+ chr->parse_frommap_fame_list(fd);
}
break;
@@ -3544,96 +3921,49 @@ int parse_frommap(int fd)
if( RFIFOREST(fd) < 10 )
return 0;
- divorce_char_sql(RFIFOL(fd,2), RFIFOL(fd,6));
- RFIFOSKIP(fd,10);
+ chr->parse_frommap_divorce_char(fd);
break;
case 0x2b16: // Receive rates [Wizputer]
if( RFIFOREST(fd) < 14 )
return 0;
{
- char esc_server_name[sizeof(server_name)*2+1];
-
- SQL->EscapeString(sql_handle, esc_server_name, server_name);
-
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` SET `index`='%d',`name`='%s',`exp`='%d',`jexp`='%d',`drop`='%d'",
- ragsrvinfo_db, fd, esc_server_name, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)) )
- Sql_ShowDebug(sql_handle);
- RFIFOSKIP(fd,14);
+ chr->parse_frommap_ragsrvinfo(fd);
}
break;
case 0x2b17: // Character disconnected set online 0 [Wizputer]
if (RFIFOREST(fd) < 6)
return 0;
- set_char_offline(RFIFOL(fd,2),RFIFOL(fd,6));
- RFIFOSKIP(fd,10);
+ chr->parse_frommap_set_char_offline(fd);
break;
case 0x2b18: // Reset all chars to offline [Wizputer]
- set_all_offline(id);
- RFIFOSKIP(fd,2);
+ chr->parse_frommap_set_all_offline(fd, id);
break;
case 0x2b19: // Character set online [Wizputer]
if (RFIFOREST(fd) < 10)
return 0;
- set_char_online(id, RFIFOL(fd,2),RFIFOL(fd,6));
- RFIFOSKIP(fd,10);
+ chr->parse_frommap_set_char_online(fd, id);
break;
case 0x2b1a: // Build and send fame ranking lists [DracoRPG]
if (RFIFOREST(fd) < 2)
return 0;
- char_read_fame_list();
- char_send_fame_list(-1);
- RFIFOSKIP(fd,2);
+ chr->parse_frommap_build_fame_list(fd);
break;
case 0x2b1c: //Request to save status change data. [Skotlex]
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
{
- #ifdef ENABLE_SC_SAVING
- int count, aid, cid;
-
- aid = RFIFOL(fd, 4);
- cid = RFIFOL(fd, 8);
- count = RFIFOW(fd, 12);
-
- /* clear; ensure no left overs e.g. permanent */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) )
- Sql_ShowDebug(sql_handle);
-
- if( count > 0 )
- {
- struct status_change_data data;
- StringBuf buf;
-
- StrBuf->Init(&buf);
- StrBuf->Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db);
- for( i = 0; i < count; ++i )
- {
- memcpy (&data, RFIFOP(fd, 14+i*sizeof(struct status_change_data)), sizeof(struct status_change_data));
- if( i > 0 )
- StrBuf->AppendStr(&buf, ", ");
- StrBuf->Printf(&buf, "('%d','%d','%hu','%d','%d','%d','%d','%d')", aid, cid,
- data.type, data.tick, data.val1, data.val2, data.val3, data.val4);
- }
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
- Sql_ShowDebug(sql_handle);
- StrBuf->Destroy(&buf);
- }
- #endif
- RFIFOSKIP(fd, RFIFOW(fd, 2));
+ chr->parse_frommap_save_status_change_data(fd);
}
break;
case 0x2b23: // map-server alive packet
- WFIFOHEAD(fd,2);
- WFIFOW(fd,0) = 0x2b24;
- WFIFOSET(fd,2);
- RFIFOSKIP(fd,2);
+ chr->parse_frommap_ping(fd);
break;
case 0x2b26: // auth request from map-server
@@ -3641,148 +3971,29 @@ int parse_frommap(int fd)
return 0;
{
- int account_id;
- int char_id;
- int login_id1;
- char sex, standalone;
- uint32 ip;
- struct auth_node* node;
- struct mmo_charstatus* cd;
- struct mmo_charstatus char_dat;
-
- account_id = RFIFOL(fd,2);
- char_id = RFIFOL(fd,6);
- login_id1 = RFIFOL(fd,10);
- sex = RFIFOB(fd,14);
- ip = ntohl(RFIFOL(fd,15));
- standalone = RFIFOB(fd, 19);
- RFIFOSKIP(fd,20);
-
- node = (struct auth_node*)idb_get(auth_db, account_id);
- cd = (struct mmo_charstatus*)uidb_get(char_db_,char_id);
-
- if( cd == NULL ) { //Really shouldn't happen.
- mmo_char_fromsql(char_id, &char_dat, true);
- cd = (struct mmo_charstatus*)uidb_get(char_db_,char_id);
- }
-
- if( runflag == CHARSERVER_ST_RUNNING && cd && standalone ) {
- cd->sex = sex;
-
- WFIFOHEAD(fd,25 + sizeof(struct mmo_charstatus));
- WFIFOW(fd,0) = 0x2afd;
- WFIFOW(fd,2) = 25 + sizeof(struct mmo_charstatus);
- WFIFOL(fd,4) = account_id;
- WFIFOL(fd,8) = 0;
- WFIFOL(fd,12) = 0;
- WFIFOL(fd,16) = 0;
- WFIFOL(fd,20) = 0;
- WFIFOB(fd,24) = 0;
- memcpy(WFIFOP(fd,25), cd, sizeof(struct mmo_charstatus));
- WFIFOSET(fd, WFIFOW(fd,2));
-
- set_char_online(id, char_id, account_id);
- break;
- }
-
- if( runflag == CHARSERVER_ST_RUNNING &&
- cd != NULL &&
- node != NULL &&
- node->account_id == account_id &&
- node->char_id == char_id &&
- node->login_id1 == login_id1 &&
- node->sex == sex /*&&
- node->ip == ip*/ )
- {// auth ok
- cd->sex = sex;
-
- WFIFOHEAD(fd,25 + sizeof(struct mmo_charstatus));
- WFIFOW(fd,0) = 0x2afd;
- WFIFOW(fd,2) = 25 + sizeof(struct mmo_charstatus);
- WFIFOL(fd,4) = account_id;
- WFIFOL(fd,8) = node->login_id1;
- WFIFOL(fd,12) = node->login_id2;
- WFIFOL(fd,16) = (uint32)node->expiration_time; // FIXME: will wrap to negative after "19-Jan-2038, 03:14:07 AM GMT"
- WFIFOL(fd,20) = node->group_id;
- WFIFOB(fd,24) = node->changing_mapservers;
- memcpy(WFIFOP(fd,25), cd, sizeof(struct mmo_charstatus));
- WFIFOSET(fd, WFIFOW(fd,2));
-
- // only use the auth once and mark user online
- idb_remove(auth_db, account_id);
- set_char_online(id, char_id, account_id);
- }
- else
- {// auth failed
- WFIFOHEAD(fd,19);
- WFIFOW(fd,0) = 0x2b27;
- WFIFOL(fd,2) = account_id;
- WFIFOL(fd,6) = char_id;
- WFIFOL(fd,10) = login_id1;
- WFIFOB(fd,14) = sex;
- WFIFOL(fd,15) = htonl(ip);
- WFIFOSET(fd,19);
- }
+ chr->parse_frommap_auth_request(fd, id);
}
break;
case 0x2736: // ip address update
if (RFIFOREST(fd) < 6) return 0;
- server[id].ip = ntohl(RFIFOL(fd, 2));
- ShowInfo("Updated IP address of map-server #%d to %d.%d.%d.%d.\n", id, CONVIP(server[id].ip));
- RFIFOSKIP(fd,6);
+ chr->parse_frommap_update_ip(fd, id);
break;
case 0x3008:
if( RFIFOREST(fd) < RFIFOW(fd,4) )
return 0;/* packet wasn't fully received yet (still fragmented) */
else {
- int sfd;/* stat server fd */
- struct hSockOpt opt;
- RFIFOSKIP(fd, 2);/* we skip first 2 bytes which are the 0x3008, so we end up with a buffer equal to the one we send */
-
- opt.silent = 1;
- opt.setTimeo = 1;
-
- if( (sfd = make_connection(host2ip("stats.hercules.ws"),(uint16)25427,&opt) ) == -1 ) {
- RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
- RFIFOFLUSH(fd);
- break;/* connection not possible, we drop the report */
- }
-
- session[sfd]->flag.server = 1;/* to ensure we won't drop our own packet */
- realloc_fifo(sfd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
-
- WFIFOHEAD(sfd, RFIFOW(fd,2) );
-
- memcpy((char*)WFIFOP(sfd,0), (char*)RFIFOP(fd, 0), RFIFOW(fd,2));
-
- WFIFOSET(sfd, RFIFOW(fd,2) );
-
- flush_fifo(sfd);
-
- do_close(sfd);
-
- RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
- RFIFOFLUSH(fd);
+ chr->parse_frommap_request_stats_report(fd);
}
break;
-
+
/* individual sc data insertion/update */
case 0x2740:
if( RFIFOREST(fd) < 28 )
return 0;
else {
- int account_id = RFIFOL(fd, 2), char_id = RFIFOL(fd, 6),
- val1 = RFIFOL(fd, 12), val2 = RFIFOL(fd, 16),
- val3 = RFIFOL(fd, 20), val4 = RFIFOL(fd, 24);
- short type = RFIFOW(fd, 10);
-
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`char_id`,`type`,`tick`,`val1`,`val2`,`val3`,`val4`) VALUES ('%d','%d','%d',-1,'%d','%d','%d','%d')",
- scdata_db, account_id, char_id, type, val1, val2, val3, val4) )
- Sql_ShowDebug(sql_handle);
-
- RFIFOSKIP(fd, 28);
+ chr->parse_frommap_scdata_update(fd);
}
break;
@@ -3791,24 +4002,16 @@ int parse_frommap(int fd)
if( RFIFOREST(fd) < 12 )
return 0;
else {
- int account_id = RFIFOL(fd, 2), char_id = RFIFOL(fd, 6);
- short type = RFIFOW(fd, 10);
-
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id` = '%d' AND `type` = '%d' LIMIT 1",
- scdata_db, account_id, char_id, type) )
- Sql_ShowDebug(sql_handle);
-
- RFIFOSKIP(fd, 12);
+ chr->parse_frommap_scdata_delete(fd);
}
break;
-
default:
{
// inter server - packet
- int r = inter_parse_frommap(fd);
- if (r == 1) break; // processed
- if (r == 2) return 0; // need more packet
+ int r = inter->parse_frommap(fd);
+ if (r == 1) break; // processed
+ if (r == 2) return 0; // need more packet
// no inter server packet. no char server packet -> disconnect
ShowError("Unknown packet 0x%04x from map server, disconnecting.\n", RFIFOW(fd,0));
@@ -3824,31 +4027,31 @@ int parse_frommap(int fd)
void do_init_mapif(void)
{
int i;
- for( i = 0; i < ARRAYLENGTH(server); ++i )
- mapif_server_init(i);
+ for( i = 0; i < ARRAYLENGTH(chr->server); ++i )
+ mapif->server_init(i);
}
void do_final_mapif(void)
{
int i;
- for( i = 0; i < ARRAYLENGTH(server); ++i )
- mapif_server_destroy(i);
+ for( i = 0; i < ARRAYLENGTH(chr->server); ++i )
+ mapif->server_destroy(i);
}
// Searches for the mapserver that has a given map (and optionally ip/port, if not -1).
// If found, returns the server's index in the 'server' array (otherwise returns -1).
-int search_mapserver(unsigned short map, uint32 ip, uint16 port)
+int char_search_mapserver(unsigned short map, uint32 ip, uint16 port)
{
int i, j;
- for(i = 0; i < ARRAYLENGTH(server); i++)
+ for(i = 0; i < ARRAYLENGTH(chr->server); i++)
{
- if (server[i].fd > 0
- && (ip == (uint32)-1 || server[i].ip == ip)
- && (port == (uint16)-1 || server[i].port == port))
+ if (chr->server[i].fd > 0
+ && (ip == (uint32)-1 || chr->server[i].ip == ip)
+ && (port == (uint16)-1 || chr->server[i].port == port))
{
- for (j = 0; server[i].map[j]; j++)
- if (server[i].map[j] == map)
+ for (j = 0; chr->server[i].map[j]; j++)
+ if (chr->server[i].map[j] == map)
return i;
}
}
@@ -3859,13 +4062,13 @@ int search_mapserver(unsigned short map, uint32 ip, uint16 port)
// Initialization process (currently only initialization inter_mapif)
static int char_mapif_init(int fd)
{
- return inter_mapif_init(fd);
+ return inter->mapif_init(fd);
}
//--------------------------------------------
// Test to know if an IP come from LAN or WAN.
//--------------------------------------------
-int lan_subnetcheck(uint32 ip)
+int char_lan_subnetcheck(uint32 ip)
{
int i;
ARR_FIND( 0, subnet_count, i, (subnet[i].char_ip & subnet[i].mask) == (ip & subnet[i].mask) );
@@ -3902,6 +4105,14 @@ void char_delete2_ack(int fd, int char_id, uint32 result, time_t delete_date)
WFIFOSET(fd,14);
}
+void char_delete2_accept_actual_ack(int fd, int char_id, uint32 result)
+{
+ WFIFOHEAD(fd,10);
+ WFIFOW(fd,0) = 0x82a;
+ WFIFOL(fd,2) = char_id;
+ WFIFOL(fd,6) = result;
+ WFIFOSET(fd,10);
+}
/// @param result
/// 0 (0x718): An unknown error has occurred.
@@ -3913,22 +4124,15 @@ void char_delete2_ack(int fd, int char_id, uint32 result, time_t delete_date)
/// Any (0x718): An unknown error has occurred.
void char_delete2_accept_ack(int fd, int char_id, uint32 result)
{// HC: <082a>.W <char id>.L <Msg:0-5>.L
-
#if PACKETVER >= 20130000 /* not sure the exact date -- must refresh or client gets stuck */
if( result == 1 ) {
struct char_session_data* sd = (struct char_session_data*)session[fd]->session_data;
- mmo_char_send099d(fd, sd);
+ chr->mmo_char_send099d(fd, sd);
}
#endif
-
- WFIFOHEAD(fd,10);
- WFIFOW(fd,0) = 0x82a;
- WFIFOL(fd,2) = char_id;
- WFIFOL(fd,6) = result;
- WFIFOSET(fd,10);
+ chr->delete2_accept_actual_ack(fd, char_id, result);
}
-
/// @param result
/// 1 (0x718): none/success, (if char id not in deletion process): An unknown error has occurred.
/// 2 (0x719): A database error occurred.
@@ -3942,7 +4146,6 @@ void char_delete2_cancel_ack(int fd, int char_id, uint32 result)
WFIFOSET(fd,10);
}
-
static void char_delete2_req(int fd, struct char_session_data* sd)
{// CH: <0827>.W <char id>.L
int char_id, party_id, guild_id, i;
@@ -3954,21 +4157,21 @@ static void char_delete2_req(int fd, struct char_session_data* sd)
ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id );
if( i == MAX_CHARS )
{// character not found
- char_delete2_ack(fd, char_id, 3, 0);
+ chr->delete2_ack(fd, char_id, 3, 0);
return;
}
- if( SQL_SUCCESS != SQL->Query(sql_handle, "SELECT `delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->Query(inter->sql_handle, "SELECT `delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
- Sql_ShowDebug(sql_handle);
- char_delete2_ack(fd, char_id, 3, 0);
+ Sql_ShowDebug(inter->sql_handle);
+ chr->delete2_ack(fd, char_id, 3, 0);
return;
}
- SQL->GetData(sql_handle, 0, &data, NULL); delete_date = strtoul(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); delete_date = strtoul(data, NULL, 10);
if( delete_date ) {// character already queued for deletion
- char_delete2_ack(fd, char_id, 0, 0);
+ chr->delete2_ack(fd, char_id, 0, 0);
return;
}
@@ -3977,26 +4180,26 @@ static void char_delete2_req(int fd, struct char_session_data* sd)
// see issue: 7338
if( char_aegis_delete )
{
- if( SQL_SUCCESS != SQL->Query(sql_handle, "SELECT `party_id`, `guild_id` FROM `%s` WHERE `char_id`='%d'", char_db, char_id)
- || SQL_SUCCESS != SQL->NextRow(sql_handle)
+ if( SQL_SUCCESS != SQL->Query(inter->sql_handle, "SELECT `party_id`, `guild_id` FROM `%s` WHERE `char_id`='%d'", char_db, char_id)
+ || SQL_SUCCESS != SQL->NextRow(inter->sql_handle)
)
{
- Sql_ShowDebug(sql_handle);
- char_delete2_ack(fd, char_id, 3, 0);
+ Sql_ShowDebug(inter->sql_handle);
+ chr->delete2_ack(fd, char_id, 3, 0);
return;
}
- SQL->GetData(sql_handle, 0, &data, NULL); party_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); guild_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); party_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); guild_id = atoi(data);
if( guild_id )
{
- char_delete2_ack(fd, char_id, 4, 0);
+ chr->delete2_ack(fd, char_id, 4, 0);
return;
}
if( party_id )
{
- char_delete2_ack(fd, char_id, 5, 0);
+ chr->delete2_ack(fd, char_id, 5, 0);
return;
}
}
@@ -4004,17 +4207,16 @@ static void char_delete2_req(int fd, struct char_session_data* sd)
// success
delete_date = time(NULL)+char_del_delay;
- if( SQL_SUCCESS != SQL->Query(sql_handle, "UPDATE `%s` SET `delete_date`='%lu' WHERE `char_id`='%d'", char_db, (unsigned long)delete_date, char_id) )
+ if( SQL_SUCCESS != SQL->Query(inter->sql_handle, "UPDATE `%s` SET `delete_date`='%lu' WHERE `char_id`='%d'", char_db, (unsigned long)delete_date, char_id) )
{
- Sql_ShowDebug(sql_handle);
- char_delete2_ack(fd, char_id, 3, 0);
+ Sql_ShowDebug(inter->sql_handle);
+ chr->delete2_ack(fd, char_id, 3, 0);
return;
}
- char_delete2_ack(fd, char_id, 1, delete_date);
+ chr->delete2_ack(fd, char_id, 1, delete_date);
}
-
static void char_delete2_accept(int fd, struct char_session_data* sd)
{// CH: <0829>.W <char id>.L <birth date:YYMMDD>.6B
char birthdate[8+1];
@@ -4041,51 +4243,50 @@ static void char_delete2_accept(int fd, struct char_session_data* sd)
ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id );
if( i == MAX_CHARS )
{// character not found
- char_delete2_accept_ack(fd, char_id, 3);
+ chr->delete2_accept_ack(fd, char_id, 3);
return;
}
- if( SQL_SUCCESS != SQL->Query(sql_handle, "SELECT `base_level`,`delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->Query(inter->sql_handle, "SELECT `base_level`,`delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{// data error
- Sql_ShowDebug(sql_handle);
- char_delete2_accept_ack(fd, char_id, 3);
+ Sql_ShowDebug(inter->sql_handle);
+ chr->delete2_accept_ack(fd, char_id, 3);
return;
}
- SQL->GetData(sql_handle, 0, &data, NULL); base_level = (unsigned int)strtoul(data, NULL, 10);
- SQL->GetData(sql_handle, 1, &data, NULL); delete_date = strtoul(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); base_level = (unsigned int)strtoul(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); delete_date = strtoul(data, NULL, 10);
if( !delete_date || delete_date>time(NULL) )
{// not queued or delay not yet passed
- char_delete2_accept_ack(fd, char_id, 4);
+ chr->delete2_accept_ack(fd, char_id, 4);
return;
}
if( strcmp(sd->birthdate+2, birthdate) ) // +2 to cut off the century
{// birth date is wrong
- char_delete2_accept_ack(fd, char_id, 5);
+ chr->delete2_accept_ack(fd, char_id, 5);
return;
}
if( ( char_del_level > 0 && base_level >= (unsigned int)char_del_level ) || ( char_del_level < 0 && base_level <= (unsigned int)(-char_del_level) ) )
{// character level config restriction
- char_delete2_accept_ack(fd, char_id, 2);
+ chr->delete2_accept_ack(fd, char_id, 2);
return;
}
// success
- if( delete_char_sql(char_id) < 0 )
+ if( chr->delete_char_sql(char_id) < 0 )
{
- char_delete2_accept_ack(fd, char_id, 3);
+ chr->delete2_accept_ack(fd, char_id, 3);
return;
}
// refresh character list cache
sd->found_char[i] = -1;
-
- char_delete2_accept_ack(fd, char_id, 1);
-}
+ chr->delete2_accept_ack(fd, char_id, 1);
+}
static void char_delete2_cancel(int fd, struct char_session_data* sd)
{// CH: <082b>.W <char id>.L
@@ -4096,47 +4297,668 @@ static void char_delete2_cancel(int fd, struct char_session_data* sd)
ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id );
if( i == MAX_CHARS )
{// character not found
- char_delete2_cancel_ack(fd, char_id, 2);
+ chr->delete2_cancel_ack(fd, char_id, 2);
return;
}
// there is no need to check, whether or not the character was
// queued for deletion, as the client prints an error message by
- // itself, if it was not the case (@see char_delete2_cancel_ack)
- if( SQL_SUCCESS != SQL->Query(sql_handle, "UPDATE `%s` SET `delete_date`='0' WHERE `char_id`='%d'", char_db, char_id) )
+ // itself, if it was not the case (@see chr->delete2_cancel_ack)
+ if( SQL_SUCCESS != SQL->Query(inter->sql_handle, "UPDATE `%s` SET `delete_date`='0' WHERE `char_id`='%d'", char_db, char_id) )
+ {
+ Sql_ShowDebug(inter->sql_handle);
+ chr->delete2_cancel_ack(fd, char_id, 2);
+ return;
+ }
+
+ chr->delete2_cancel_ack(fd, char_id, 1);
+}
+
+void char_send_account_id(int fd, int account_id)
+{
+ WFIFOHEAD(fd,4);
+ WFIFOL(fd,0) = account_id;
+ WFIFOSET(fd,4);
+}
+
+void char_parse_char_connect(int fd, struct char_session_data* sd, uint32 ipl)
+{
+ int account_id = RFIFOL(fd,2);
+ uint32 login_id1 = RFIFOL(fd,6);
+ uint32 login_id2 = RFIFOL(fd,10);
+ int sex = RFIFOB(fd,16);
+ struct char_auth_node* node;
+
+ RFIFOSKIP(fd,17);
+
+ ShowInfo("request connect - account_id:%d/login_id1:%d/login_id2:%d\n", account_id, login_id1, login_id2);
+
+ if (sd) {
+ //Received again auth packet for already authenticated account?? Discard it.
+ //TODO: Perhaps log this as a hack attempt?
+ //TODO: and perhaps send back a reply?
+ return;
+ }
+
+ CREATE(session[fd]->session_data, struct char_session_data, 1);
+ sd = (struct char_session_data*)session[fd]->session_data;
+ sd->account_id = account_id;
+ sd->login_id1 = login_id1;
+ sd->login_id2 = login_id2;
+ sd->sex = sex;
+ sd->auth = false; // not authed yet
+
+ // send back account_id
+ chr->send_account_id(fd, account_id);
+
+ if( runflag != CHARSERVER_ST_RUNNING ) {
+ chr->auth_error(fd, 0);
+ return;
+ }
+
+ // search authentication
+ node = (struct char_auth_node*)idb_get(auth_db, account_id);
+ if( node != NULL &&
+ node->account_id == account_id &&
+ node->login_id1 == login_id1 &&
+ node->login_id2 == login_id2 /*&&
+ node->ip == ipl*/ )
+ {// authentication found (coming from map server)
+ /* restrictions apply */
+ if( chr->server_type == CST_MAINTENANCE && node->group_id < char_maintenance_min_group_id ) {
+ chr->auth_error(fd, 0);
+ return;
+ }
+ /* the client will already deny this request, this check is to avoid someone bypassing. */
+ if( chr->server_type == CST_PAYING && (time_t)node->expiration_time < time(NULL) ) {
+ chr->auth_error(fd, 0);
+ return;
+ }
+ idb_remove(auth_db, account_id);
+ chr->auth_ok(fd, sd);
+ }
+ else
+ {// authentication not found (coming from login server)
+ if (chr->login_fd > 0) { // don't send request if no login-server
+ loginif->auth(fd, sd, ipl);
+ } else { // if no login-server, we must refuse connection
+ chr->auth_error(fd, 0);
+ }
+ }
+}
+
+void char_send_map_info(int fd, int i, uint32 subnet_map_ip, struct mmo_charstatus *cd)
+{
+ WFIFOHEAD(fd,28);
+ WFIFOW(fd,0) = 0x71;
+ WFIFOL(fd,2) = cd->char_id;
+ mapindex->getmapname_ext(mapindex_id2name(cd->last_point.map), (char*)WFIFOP(fd,6));
+ WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : chr->server[i].ip);
+ WFIFOW(fd,26) = ntows(htons(chr->server[i].port)); // [!] LE byte order here [!]
+ WFIFOSET(fd,28);
+}
+
+void char_send_wait_char_server(int fd)
+{
+ WFIFOHEAD(fd, 24);
+ WFIFOW(fd, 0) = 0x840;
+ WFIFOW(fd, 2) = 24;
+ safestrncpy((char*)WFIFOP(fd,4), "0", 20);/* we can't send empty (otherwise the list will pop up) */
+ WFIFOSET(fd, 24);
+}
+
+int char_search_default_maps_mapserver(struct mmo_charstatus *cd)
+{
+ int i;
+ int j;
+ if ((i = chr->search_mapserver((j=mapindex->name2id(MAP_PRONTERA)),-1,-1)) >= 0) {
+ cd->last_point.x = 273;
+ cd->last_point.y = 354;
+ } else if ((i = chr->search_mapserver((j=mapindex->name2id(MAP_GEFFEN)),-1,-1)) >= 0) {
+ cd->last_point.x = 120;
+ cd->last_point.y = 100;
+ } else if ((i = chr->search_mapserver((j=mapindex->name2id(MAP_MORROC)),-1,-1)) >= 0) {
+ cd->last_point.x = 160;
+ cd->last_point.y = 94;
+ } else if ((i = chr->search_mapserver((j=mapindex->name2id(MAP_ALBERTA)),-1,-1)) >= 0) {
+ cd->last_point.x = 116;
+ cd->last_point.y = 57;
+ } else if ((i = chr->search_mapserver((j=mapindex->name2id(MAP_PAYON)),-1,-1)) >= 0) {
+ cd->last_point.x = 87;
+ cd->last_point.y = 117;
+ } else if ((i = chr->search_mapserver((j=mapindex->name2id(MAP_IZLUDE)),-1,-1)) >= 0) {
+ cd->last_point.x = 94;
+ cd->last_point.y = 103;
+ }
+ if (i >= 0)
+ {
+ cd->last_point.map = j;
+ ShowWarning("Unable to find map-server for '%s', sending to major city '%s'.\n", mapindex_id2name(cd->last_point.map), mapindex_id2name(j));
+ }
+ return i;
+}
+
+void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl)
+{
+ struct mmo_charstatus char_dat;
+ struct mmo_charstatus *cd;
+ struct char_auth_node* node;
+ char* data;
+ int char_id;
+ int server_id = 0;
+ int i;
+ int map_fd;
+ uint32 subnet_map_ip;
+ int slot = RFIFOB(fd,2);
+
+ RFIFOSKIP(fd,3);
+
+#if PACKETVER >= 20110309
+ if( pincode->enabled ){ // hack check
+ struct online_char_data* character;
+ character = (struct online_char_data*)idb_get(chr->online_char_db, sd->account_id);
+ if( character && character->pincode_enable == -1){
+ chr->auth_error(fd, 0);
+ return;
+ }
+ }
+#endif
+
+ ARR_FIND( 0, ARRAYLENGTH(chr->server), server_id, chr->server[server_id].fd > 0 && chr->server[server_id].map );
+ /* not available, tell it to wait (client wont close; char select will respawn).
+ * magic response found by Ind thanks to Yommy <3 */
+ if( server_id == ARRAYLENGTH(chr->server) ) {
+ chr->send_wait_char_server(fd);
+ return;
+ }
+
+ if (SQL_SUCCESS != SQL->Query(inter->sql_handle, "SELECT `char_id` FROM `%s` WHERE `account_id`='%d' AND `char_num`='%d'", char_db, sd->account_id, slot)
+ || SQL_SUCCESS != SQL->NextRow(inter->sql_handle)
+ || SQL_SUCCESS != SQL->GetData(inter->sql_handle, 0, &data, NULL)
+ ) {
+ //Not found?? May be forged packet.
+ Sql_ShowDebug(inter->sql_handle);
+ SQL->FreeResult(inter->sql_handle);
+ chr->auth_error(fd, 0);
+ return;
+ }
+
+ char_id = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
+
+ /* client doesn't let it get to this point if you're banned, so its a forged packet */
+ if( sd->found_char[slot] == char_id && sd->unban_time[slot] > time(NULL) ) {
+ chr->auth_error(fd, 0);
+ return;
+ }
+
+ /* set char as online prior to loading its data so 3rd party applications will realize the sql data is not reliable */
+ chr->set_char_online(-2,char_id,sd->account_id);
+ if( !chr->mmo_char_fromsql(char_id, &char_dat, true) ) { /* failed? set it back offline */
+ chr->set_char_offline(char_id, sd->account_id);
+ /* failed to load something. REJECT! */
+ chr->auth_error(fd, 0);
+ return;/* jump off this boat */
+ }
+
+ //Have to switch over to the DB instance otherwise data won't propagate [Kevin]
+ cd = (struct mmo_charstatus *)idb_get(chr->char_db_, char_id);
+ if( cd->sex == 99 )
+ cd->sex = sd->sex;
+
+ if (log_char) {
+ char esc_name[NAME_LENGTH*2+1];
+ // FIXME: Why are we re-escaping the name if it was already escaped in rename/make_new_char? [Panikon]
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, char_dat.name, strnlen(char_dat.name, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
+ "INSERT INTO `%s`(`time`, `account_id`, `char_id`, `char_num`, `name`) VALUES (NOW(), '%d', '%d', '%d', '%s')",
+ charlog_db, sd->account_id, cd->char_id, slot, esc_name) )
+ Sql_ShowDebug(inter->sql_handle);
+ }
+ ShowInfo("Selected char: (Account %d: %d - %s)\n", sd->account_id, slot, char_dat.name);
+
+ // searching map server
+ i = chr->search_mapserver(cd->last_point.map, -1, -1);
+
+ // if map is not found, we check major cities
+ if (i < 0 || !cd->last_point.map) {
+ unsigned short j;
+ //First check that there's actually a map server online.
+ ARR_FIND( 0, ARRAYLENGTH(chr->server), j, chr->server[j].fd >= 0 && chr->server[j].map );
+ if (j == ARRAYLENGTH(chr->server)) {
+ ShowInfo("Connection Closed. No map servers available.\n");
+ chr->authfail_fd(fd, 1);
+ return;
+ }
+ i = chr->search_default_maps_mapserver(cd);
+ if (i < 0)
+ {
+ ShowInfo("Connection Closed. No map server available that has a major city, and unable to find map-server for '%s'.\n", mapindex_id2name(cd->last_point.map));
+ chr->authfail_fd(fd, 1);
+ return;
+ }
+ }
+
+ //Send NEW auth packet [Kevin]
+ //FIXME: is this case even possible? [ultramage]
+ if ((map_fd = chr->server[i].fd) < 1 || session[map_fd] == NULL)
{
- Sql_ShowDebug(sql_handle);
- char_delete2_cancel_ack(fd, char_id, 2);
+ ShowError("chr->parse_char: Attempting to write to invalid session %d! Map Server #%d disconnected.\n", map_fd, i);
+ chr->server[i].fd = -1;
+ memset(&chr->server[i], 0, sizeof(struct mmo_map_server));
+ //Send server closed.
+ chr->authfail_fd(fd, 1);
return;
}
- char_delete2_cancel_ack(fd, char_id, 1);
+ subnet_map_ip = chr->lan_subnetcheck(ipl); // Advanced subnet check [LuzZza]
+ //Send player to map
+ chr->send_map_info(fd, i, subnet_map_ip, cd);
+
+ // create temporary auth entry
+ CREATE(node, struct char_auth_node, 1);
+ node->account_id = sd->account_id;
+ node->char_id = cd->char_id;
+ node->login_id1 = sd->login_id1;
+ node->login_id2 = sd->login_id2;
+ node->sex = sd->sex;
+ node->expiration_time = sd->expiration_time;
+ node->group_id = sd->group_id;
+ node->ip = ipl;
+ idb_put(auth_db, sd->account_id, node);
+}
+
+void char_creation_failed(int fd, int result)
+{
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x6e;
+ /* Others I found [Ind] */
+ /* 0x02 = Symbols in Character Names are forbidden */
+ /* 0x03 = You are not eligible to open the Character Slot. */
+ /* 0x0B = This service is only available for premium users. */
+ switch (result) {
+ case -1: WFIFOB(fd,2) = 0x00; break; // 'Charname already exists'
+ case -2: WFIFOB(fd,2) = 0xFF; break; // 'Char creation denied'
+ case -3: WFIFOB(fd,2) = 0x01; break; // 'You are underaged'
+ case -4: WFIFOB(fd,2) = 0x03; break; // 'You are not eligible to open the Character Slot.'
+ case -5: WFIFOB(fd,2) = 0x02; break; // 'Symbols in Character Names are forbidden'
+
+ default:
+ ShowWarning("chr->parse_char: Unknown result received from chr->make_new_char_sql!\n");
+ WFIFOB(fd,2) = 0xFF;
+ break;
+ }
+ WFIFOSET(fd,3);
+}
+
+void char_creation_ok(int fd, struct mmo_charstatus *char_dat)
+{
+ int len;
+
+ // send to player
+ WFIFOHEAD(fd,2+MAX_CHAR_BUF);
+ WFIFOW(fd,0) = 0x6d;
+ len = 2 + chr->mmo_char_tobuf(WFIFOP(fd,2), char_dat);
+ WFIFOSET(fd,len);
+}
+
+void char_parse_char_create_new_char(int fd, struct char_session_data* sd)
+{
+ int result;
+ if( !char_new ) //turn character creation on/off [Kevin]
+ result = -2;
+ else
+ #if PACKETVER >= 20120307
+ result = chr->make_new_char_sql(sd, (char*)RFIFOP(fd,2), 1, 1, 1, 1, 1, 1, RFIFOB(fd,26),RFIFOW(fd,27),RFIFOW(fd,29));
+ #else
+ result = chr->make_new_char_sql(sd, (char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27),RFIFOB(fd,28),RFIFOB(fd,29),RFIFOB(fd,30),RFIFOB(fd,31),RFIFOB(fd,32),RFIFOW(fd,33),RFIFOW(fd,35));
+ #endif
+
+ if (result < 0) {
+ chr->creation_failed(fd, result);
+ } else {
+ // retrieve data
+ struct mmo_charstatus char_dat;
+ chr->mmo_char_fromsql(result, &char_dat, false); //Only the short data is needed.
+ chr->creation_ok(fd, &char_dat);
+
+ // add new entry to the chars list
+ sd->found_char[char_dat.slot] = result; // the char_id of the new char
+ }
+ #if PACKETVER >= 20120307
+ RFIFOSKIP(fd,31);
+ #else
+ RFIFOSKIP(fd,37);
+ #endif
+}
+
+// flag:
+// 0 = Incorrect Email address
+void char_delete_char_failed(int fd, int flag)
+{
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x70;
+ WFIFOB(fd,2) = flag;
+ WFIFOSET(fd,3);
}
+void char_delete_char_ok(int fd)
+{
+ WFIFOHEAD(fd,2);
+ WFIFOW(fd,0) = 0x6f;
+ WFIFOSET(fd,2);
+}
-int parse_char(int fd)
+void char_parse_char_delete_char(int fd, struct char_session_data* sd, unsigned short cmd)
{
char email[40];
+ int cid = RFIFOL(fd,2);
+ int i;
+
+#if PACKETVER >= 20110309
+ if( pincode->enabled ){ // hack check
+ struct online_char_data* character;
+ character = (struct online_char_data*)idb_get(chr->online_char_db, sd->account_id);
+ if( character && character->pincode_enable == -1 ){
+ chr->auth_error(fd, 0);
+ RFIFOSKIP(fd,( cmd == 0x68) ? 46 : 56);
+ return;
+ }
+ }
+#endif
+ ShowInfo(CL_RED"Request Char Deletion: "CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, cid);
+ memcpy(email, RFIFOP(fd,6), 40);
+ RFIFOSKIP(fd,( cmd == 0x68) ? 46 : 56);
+
+ // Check if e-mail is correct
+ if (strcmpi(email, sd->email) != 0 /* emails don't match */
+ && ( strcmp("a@a.com", sd->email) != 0 /* it's not the default email */
+ || (strcmp("a@a.com", email) != 0 && strcmp("", email) != 0) /* sent email isn't the default */
+ )) {
+ //Fail
+ chr->delete_char_failed(fd, 0);
+ return;
+ }
+
+ // check if this char exists
+ ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid );
+ if( i == MAX_CHARS )
+ { // Such a character does not exist in the account
+ chr->delete_char_failed(fd, 0);
+ return;
+ }
+
+ // remove char from list and compact it
+ sd->found_char[i] = -1;
+
+ /* Delete character */
+ if(chr->delete_char_sql(cid)<0){
+ //can't delete the char
+ //either SQL error or can't delete by some CONFIG conditions
+ //del fail
+ chr->delete_char_failed(fd, 0);
+ return;
+ }
+ /* Char successfully deleted.*/
+ chr->delete_char_ok(fd);
+}
+
+void char_parse_char_ping(int fd)
+{
+ RFIFOSKIP(fd,6);
+}
+
+void char_allow_rename(int fd, int flag)
+{
+ WFIFOHEAD(fd, 4);
+ WFIFOW(fd,0) = 0x28e;
+ WFIFOW(fd,2) = flag;
+ WFIFOSET(fd,4);
+}
+
+void char_parse_char_rename_char(int fd, struct char_session_data* sd)
+{
+ int i, cid =RFIFOL(fd,2);
+ char name[NAME_LENGTH];
+ char esc_name[NAME_LENGTH*2+1];
+ safestrncpy(name, (char *)RFIFOP(fd,6), NAME_LENGTH);
+ RFIFOSKIP(fd,30);
+
+ ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid );
+ if( i == MAX_CHARS )
+ return;
+
+ normalize_name(name,TRIM_CHARS);
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+ if( !chr->check_char_name(name,esc_name) ) {
+ i = 1;
+ safestrncpy(sd->new_name, name, NAME_LENGTH);
+ } else {
+ i = 0;
+ }
+
+ chr->allow_rename(fd, i);
+}
+
+void char_parse_char_rename_char2(int fd, struct char_session_data* sd)
+{
+ int i, aid = RFIFOL(fd,2), cid =RFIFOL(fd,6);
+ char name[NAME_LENGTH];
+ char esc_name[NAME_LENGTH*2+1];
+ safestrncpy(name, (char *)RFIFOP(fd,10), NAME_LENGTH);
+ RFIFOSKIP(fd,34);
+
+ if( aid != sd->account_id )
+ return;
+ ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid );
+ if( i == MAX_CHARS )
+ return;
+
+ normalize_name(name,TRIM_CHARS);
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+ if( !chr->check_char_name(name,esc_name) )
+ {
+ i = 1;
+ safestrncpy(sd->new_name, name, NAME_LENGTH);
+ }
+ else
+ i = 0;
+
+ chr->allow_rename(fd, i);
+}
+
+void char_rename_char_ack(int fd, int flag)
+{
+ WFIFOHEAD(fd, 4);
+ WFIFOW(fd,0) = 0x290;
+ WFIFOW(fd,2) = flag;
+ WFIFOSET(fd,4);
+}
+
+void char_parse_char_rename_char_confirm(int fd, struct char_session_data* sd)
+{
+ int i;
+ int cid = RFIFOL(fd,2);
+ RFIFOSKIP(fd,6);
+
+ ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid );
+ if( i == MAX_CHARS )
+ return;
+ i = chr->rename_char_sql(sd, cid);
+
+ chr->rename_char_ack(fd, i);
+}
+
+void char_captcha_notsupported(int fd)
+{
+ WFIFOHEAD(fd,5);
+ WFIFOW(fd,0) = 0x7e9;
+ WFIFOW(fd,2) = 5;
+ WFIFOB(fd,4) = 1;
+ WFIFOSET(fd,5);
+}
+
+void char_parse_char_request_captcha(int fd)
+{
+ chr->captcha_notsupported(fd);
+ RFIFOSKIP(fd,8);
+}
+
+void char_parse_char_check_captcha(int fd)
+{
+ chr->captcha_notsupported(fd);
+ RFIFOSKIP(fd,32);
+}
+
+void char_parse_char_delete2_req(int fd, struct char_session_data* sd)
+{
+ chr->delete2_req(fd, sd);
+ RFIFOSKIP(fd,6);
+}
+
+void char_parse_char_delete2_accept(int fd, struct char_session_data* sd)
+{
+ chr->delete2_accept(fd, sd);
+ RFIFOSKIP(fd,12);
+}
+
+void char_parse_char_delete2_cancel(int fd, struct char_session_data* sd)
+{
+ chr->delete2_cancel(fd, sd);
+ RFIFOSKIP(fd,6);
+}
+
+// flag:
+// 0 - ok
+// 3 - error
+void char_login_map_server_ack(int fd, uint8 flag)
+{
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x2af9;
+ WFIFOB(fd,2) = flag;
+ WFIFOSET(fd,3);
+}
+
+void char_parse_char_login_map_server(int fd)
+{
+ char* l_user = (char*)RFIFOP(fd,2);
+ char* l_pass = (char*)RFIFOP(fd,26);
+ int i;
+ l_user[23] = '\0';
+ l_pass[23] = '\0';
+ ARR_FIND( 0, ARRAYLENGTH(chr->server), i, chr->server[i].fd <= 0 );
+ if( runflag != CHARSERVER_ST_RUNNING ||
+ i == ARRAYLENGTH(chr->server) ||
+ strcmp(l_user, chr->userid) != 0 ||
+ strcmp(l_pass, chr->passwd) != 0 )
+ {
+ chr->login_map_server_ack(fd, 3);
+ } else {
+ chr->login_map_server_ack(fd, 0);
+
+ chr->server[i].fd = fd;
+ chr->server[i].ip = ntohl(RFIFOL(fd,54));
+ chr->server[i].port = ntohs(RFIFOW(fd,58));
+ chr->server[i].users = 0;
+ session[fd]->func_parse = chr->parse_frommap;
+ session[fd]->flag.server = 1;
+ realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+ chr->mapif_init(fd);
+ }
+ sockt->datasync(fd, true);
+
+ RFIFOSKIP(fd,60);
+}
+
+void char_parse_char_pincode_check(int fd, struct char_session_data* sd)
+{
+ if( RFIFOL(fd,2) == sd->account_id )
+ pincode->check( fd, sd );
+
+ RFIFOSKIP(fd,10);
+}
+
+void char_parse_char_pincode_window(int fd, struct char_session_data* sd)
+{
+ if( RFIFOL(fd,2) == sd->account_id )
+ pincode->sendstate( fd, sd, PINCODE_NOTSET );
+
+ RFIFOSKIP(fd,6);
+}
+
+void char_parse_char_pincode_change(int fd, struct char_session_data* sd)
+{
+ if( RFIFOL(fd,2) == sd->account_id )
+ pincode->change( fd, sd );
+
+ RFIFOSKIP(fd,14);
+}
+
+void char_parse_char_pincode_first_pin(int fd, struct char_session_data* sd)
+{
+ if( RFIFOL(fd,2) == sd->account_id )
+ pincode->setnew( fd, sd );
+ RFIFOSKIP(fd,10);
+}
+
+void char_parse_char_request_chars(int fd, struct char_session_data* sd)
+{
+ chr->mmo_char_send099d(fd, sd);
+ RFIFOSKIP(fd,2);
+}
+
+void char_change_character_slot_ack(int fd, bool ret)
+{
+ WFIFOHEAD(fd, 8);
+ WFIFOW(fd, 0) = 0x8d5;
+ WFIFOW(fd, 2) = 8;
+ WFIFOW(fd, 4) = ret?0:1;
+ WFIFOW(fd, 6) = 0;/* we enforce it elsewhere, go 0 */
+ WFIFOSET(fd, 8);
+}
+
+void char_parse_char_move_character(int fd, struct char_session_data* sd)
+{
+ bool ret = chr->char_slotchange(sd, fd, RFIFOW(fd, 2), RFIFOW(fd, 4));
+ chr->change_character_slot_ack(fd, ret);
+ /* for some stupid reason it requires the char data again (gravity -_-) */
+ if( ret )
+#if PACKETVER >= 20130000
+ chr->mmo_char_send099d(fd, sd);
+#else
+ chr->mmo_char_send_characters(fd, sd);
+#endif
+ RFIFOSKIP(fd, 8);
+}
+
+int char_parse_char_unknown_packet(int fd, uint32 ipl)
+{
+ ShowError("chr->parse_char: Received unknown packet "CL_WHITE"0x%x"CL_RESET" from ip '"CL_WHITE"%s"CL_RESET"'! Disconnecting!\n", RFIFOW(fd,0), ip2str(ipl, NULL));
+ set_eof(fd);
+ return 1;
+}
+
+int char_parse_char(int fd)
+{
unsigned short cmd;
- int map_fd;
struct char_session_data* sd;
uint32 ipl = session[fd]->client_addr;
sd = (struct char_session_data*)session[fd]->session_data;
// disconnect any player if no login-server.
- if(login_fd < 0)
+ if(chr->login_fd < 0)
set_eof(fd);
if(session[fd]->flag.eof)
{
- if( sd != NULL && sd->auth )
- { // already authed client
- struct online_char_data* data = (struct online_char_data*)idb_get(online_char_db, sd->account_id);
+ if( sd != NULL && sd->auth ) {
+ // already authed client
+ struct online_char_data* data = (struct online_char_data*)idb_get(chr->online_char_db, sd->account_id);
if( data != NULL && data->fd == fd)
data->fd = -1;
if( data == NULL || data->server == -1) //If it is not in any server, send it offline. [Skotlex]
- set_char_offline(-1,sd->account_id);
+ chr->set_char_offline(-1,sd->account_id);
}
do_close(fd);
return 0;
@@ -4151,101 +4973,17 @@ int parse_char(int fd)
if( success == 1 ) continue;
else if( success == 2 ) return 0;
}
-
+
cmd = RFIFOW(fd,0);
switch( cmd ) {
-
// request to connect
// 0065 <account id>.L <login id1>.L <login id2>.L <???>.W <sex>.B
case 0x65:
if( RFIFOREST(fd) < 17 )
return 0;
{
- struct auth_node* node;
-
- int account_id = RFIFOL(fd,2);
- uint32 login_id1 = RFIFOL(fd,6);
- uint32 login_id2 = RFIFOL(fd,10);
- int sex = RFIFOB(fd,16);
- RFIFOSKIP(fd,17);
-
- ShowInfo("request connect - account_id:%d/login_id1:%d/login_id2:%d\n", account_id, login_id1, login_id2);
-
- if (sd) {
- //Received again auth packet for already authenticated account?? Discard it.
- //TODO: Perhaps log this as a hack attempt?
- //TODO: and perhaps send back a reply?
- break;
- }
-
- CREATE(session[fd]->session_data, struct char_session_data, 1);
- sd = (struct char_session_data*)session[fd]->session_data;
- sd->account_id = account_id;
- sd->login_id1 = login_id1;
- sd->login_id2 = login_id2;
- sd->sex = sex;
- sd->auth = false; // not authed yet
-
- // send back account_id
- WFIFOHEAD(fd,4);
- WFIFOL(fd,0) = account_id;
- WFIFOSET(fd,4);
-
- if( runflag != CHARSERVER_ST_RUNNING ) {
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x6c;
- WFIFOB(fd,2) = 0;// rejected from server
- WFIFOSET(fd,3);
- break;
- }
-
- // search authentication
- node = (struct auth_node*)idb_get(auth_db, account_id);
- if( node != NULL &&
- node->account_id == account_id &&
- node->login_id1 == login_id1 &&
- node->login_id2 == login_id2 /*&&
- node->ip == ipl*/ )
- {// authentication found (coming from map server)
- /* restrictions apply */
- if( char_server_type == CST_MAINTENANCE && node->group_id < char_maintenance_min_group_id ) {
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x6c;
- WFIFOB(fd,2) = 0;// rejected from server
- WFIFOSET(fd,3);
- break;
- }
- /* the client will already deny this request, this check is to avoid someone bypassing. */
- if( char_server_type == CST_PAYING && (time_t)node->expiration_time < time(NULL) ) {
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x6c;
- WFIFOB(fd,2) = 0;// rejected from server
- WFIFOSET(fd,3);
- break;
- }
- idb_remove(auth_db, account_id);
- char_auth_ok(fd, sd);
- }
- else
- {// authentication not found (coming from login server)
- if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd,23);
- WFIFOW(login_fd,0) = 0x2712; // ask login-server to authenticate an account
- WFIFOL(login_fd,2) = sd->account_id;
- WFIFOL(login_fd,6) = sd->login_id1;
- WFIFOL(login_fd,10) = sd->login_id2;
- WFIFOB(login_fd,14) = sd->sex;
- WFIFOL(login_fd,15) = htonl(ipl);
- WFIFOL(login_fd,19) = fd;
- WFIFOSET(login_fd,23);
- } else { // if no login-server, we must refuse connection
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x6c;
- WFIFOB(fd,2) = 0;
- WFIFOSET(fd,3);
- }
- }
+ chr->parse_char_connect(fd, sd, ipl);
}
break;
@@ -4253,178 +4991,7 @@ int parse_char(int fd)
case 0x66:
FIFOSD_CHECK(3);
{
- struct mmo_charstatus char_dat;
- struct mmo_charstatus *cd;
- char* data;
- int char_id;
- uint32 subnet_map_ip;
- struct auth_node* node;
- int server_id = 0;
- int i;
-
- int slot = RFIFOB(fd,2);
- RFIFOSKIP(fd,3);
-
-#if PACKETVER >= 20110309
- if( *pincode->enabled ){ // hack check
- struct online_char_data* character;
- character = (struct online_char_data*)idb_get(online_char_db, sd->account_id);
- if( character && character->pincode_enable == -1){
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x6c;
- WFIFOB(fd,2) = 0;
- WFIFOSET(fd,3);
- break;
- }
- }
-#endif
-
- ARR_FIND( 0, ARRAYLENGTH(server), server_id, server[server_id].fd > 0 && server[server_id].map[0] );
- /* not available, tell it to wait (client wont close; char select will respawn).
- * magic response found by Ind thanks to Yommy <3 */
- if( server_id == ARRAYLENGTH(server) ) {
- WFIFOHEAD(fd, 24);
- WFIFOW(fd, 0) = 0x840;
- WFIFOW(fd, 2) = 24;
- safestrncpy((char*)WFIFOP(fd,4), "0", 20);/* we can't send empty (otherwise the list will pop up) */
- WFIFOSET(fd, 24);
- break;
- }
-
- if ( SQL_SUCCESS != SQL->Query(sql_handle, "SELECT `char_id` FROM `%s` WHERE `account_id`='%d' AND `char_num`='%d'", char_db, sd->account_id, slot)
- || SQL_SUCCESS != SQL->NextRow(sql_handle)
- || SQL_SUCCESS != SQL->GetData(sql_handle, 0, &data, NULL) )
- { //Not found?? May be forged packet.
- Sql_ShowDebug(sql_handle);
- SQL->FreeResult(sql_handle);
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x6c;
- WFIFOB(fd,2) = 0; // rejected from server
- WFIFOSET(fd,3);
- break;
- }
-
- char_id = atoi(data);
- SQL->FreeResult(sql_handle);
-
- /* client doesn't let it get to this point if you're banned, so its a forged packet */
- if( sd->found_char[slot] == char_id && sd->unban_time[slot] > time(NULL) ) {
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x6c;
- WFIFOB(fd,2) = 0; // rejected from server
- WFIFOSET(fd,3);
- break;
- }
-
- /* set char as online prior to loading its data so 3rd party applications will realize the sql data is not reliable */
- set_char_online(-2,char_id,sd->account_id);
- if( !mmo_char_fromsql(char_id, &char_dat, true) ) { /* failed? set it back offline */
- set_char_offline(char_id, sd->account_id);
- /* failed to load something. REJECT! */
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x6c;
- WFIFOB(fd,2) = 0;
- WFIFOSET(fd,3);
- break;/* jump off this boat */
- }
-
- //Have to switch over to the DB instance otherwise data won't propagate [Kevin]
- cd = (struct mmo_charstatus *)idb_get(char_db_, char_id);
- cd->sex = sd->sex;
-
- if (log_char) {
- char esc_name[NAME_LENGTH*2+1];
- // FIXME: Why are we re-escaping the name if it was already escaped in rename/make_new_char? [Panikon]
- SQL->EscapeStringLen(sql_handle, esc_name, char_dat.name, strnlen(char_dat.name, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle,
- "INSERT INTO `%s`(`time`, `account_id`, `char_id`, `char_num`, `name`) VALUES (NOW(), '%d', '%d', '%d', '%s')",
- charlog_db, sd->account_id, cd->char_id, slot, esc_name) )
- Sql_ShowDebug(sql_handle);
- }
- ShowInfo("Selected char: (Account %d: %d - %s)\n", sd->account_id, slot, char_dat.name);
-
- // searching map server
- i = search_mapserver(cd->last_point.map, -1, -1);
-
- // if map is not found, we check major cities
- if (i < 0 || !cd->last_point.map) {
- unsigned short j;
- //First check that there's actually a map server online.
- ARR_FIND( 0, ARRAYLENGTH(server), j, server[j].fd >= 0 && server[j].map[0] );
- if (j == ARRAYLENGTH(server)) {
- ShowInfo("Connection Closed. No map servers available.\n");
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = 1; // 01 = Server closed
- WFIFOSET(fd,3);
- break;
- }
- if ((i = search_mapserver((j=mapindex->name2id(MAP_PRONTERA)),-1,-1)) >= 0) {
- cd->last_point.x = 273;
- cd->last_point.y = 354;
- } else if ((i = search_mapserver((j=mapindex->name2id(MAP_GEFFEN)),-1,-1)) >= 0) {
- cd->last_point.x = 120;
- cd->last_point.y = 100;
- } else if ((i = search_mapserver((j=mapindex->name2id(MAP_MORROC)),-1,-1)) >= 0) {
- cd->last_point.x = 160;
- cd->last_point.y = 94;
- } else if ((i = search_mapserver((j=mapindex->name2id(MAP_ALBERTA)),-1,-1)) >= 0) {
- cd->last_point.x = 116;
- cd->last_point.y = 57;
- } else if ((i = search_mapserver((j=mapindex->name2id(MAP_PAYON)),-1,-1)) >= 0) {
- cd->last_point.x = 87;
- cd->last_point.y = 117;
- } else if ((i = search_mapserver((j=mapindex->name2id(MAP_IZLUDE)),-1,-1)) >= 0) {
- cd->last_point.x = 94;
- cd->last_point.y = 103;
- } else {
- ShowInfo("Connection Closed. No map server available that has a major city, and unable to find map-server for '%s'.\n", mapindex_id2name(cd->last_point.map));
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = 1; // 01 = Server closed
- WFIFOSET(fd,3);
- break;
- }
- ShowWarning("Unable to find map-server for '%s', sending to major city '%s'.\n", mapindex_id2name(cd->last_point.map), mapindex_id2name(j));
- cd->last_point.map = j;
- }
-
- //Send NEW auth packet [Kevin]
- //FIXME: is this case even possible? [ultramage]
- if ((map_fd = server[i].fd) < 1 || session[map_fd] == NULL)
- {
- ShowError("parse_char: Attempting to write to invalid session %d! Map Server #%d disconnected.\n", map_fd, i);
- server[i].fd = -1;
- memset(&server[i], 0, sizeof(struct mmo_map_server));
- //Send server closed.
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = 1; // 01 = Server closed
- WFIFOSET(fd,3);
- break;
- }
-
- //Send player to map
- WFIFOHEAD(fd,28);
- WFIFOW(fd,0) = 0x71;
- WFIFOL(fd,2) = cd->char_id;
- mapindex->getmapname_ext(mapindex_id2name(cd->last_point.map), (char*)WFIFOP(fd,6));
- subnet_map_ip = lan_subnetcheck(ipl); // Advanced subnet check [LuzZza]
- WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : server[i].ip);
- WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!]
- WFIFOSET(fd,28);
-
- // create temporary auth entry
- CREATE(node, struct auth_node, 1);
- node->account_id = sd->account_id;
- node->char_id = cd->char_id;
- node->login_id1 = sd->login_id1;
- node->login_id2 = sd->login_id2;
- node->sex = sd->sex;
- node->expiration_time = sd->expiration_time;
- node->group_id = sd->group_id;
- node->ip = ipl;
- idb_put(auth_db, sd->account_id, node);
+ chr->parse_char_select(fd, sd, ipl);
}
break;
@@ -4434,65 +5001,15 @@ int parse_char(int fd)
// S 0970 <name>.24B <slot>.B <hair color>.W <hair style>.W
case 0x970:
{
- int result;
FIFOSD_CHECK(31);
#else
// S 0067 <name>.24B <str>.B <agi>.B <vit>.B <int>.B <dex>.B <luk>.B <slot>.B <hair color>.W <hair style>.W
case 0x67:
{
- int result;
FIFOSD_CHECK(37);
#endif
- if( !char_new ) //turn character creation on/off [Kevin]
- result = -2;
- else
- #if PACKETVER >= 20120307
- result = make_new_char_sql(sd, (char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOW(fd,27),RFIFOW(fd,29));
- #else
- result = make_new_char_sql(sd, (char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27),RFIFOB(fd,28),RFIFOB(fd,29),RFIFOB(fd,30),RFIFOB(fd,31),RFIFOB(fd,32),RFIFOW(fd,33),RFIFOW(fd,35));
- #endif
-
- if (result < 0) {
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x6e;
- /* Others I found [Ind] */
- /* 0x02 = Symbols in Character Names are forbidden */
- /* 0x03 = You are not eligible to open the Character Slot. */
- /* 0x0B = This service is only available for premium users. */
- switch (result) {
- case -1: WFIFOB(fd,2) = 0x00; break; // 'Charname already exists'
- case -2: WFIFOB(fd,2) = 0xFF; break; // 'Char creation denied'
- case -3: WFIFOB(fd,2) = 0x01; break; // 'You are underaged'
- case -4: WFIFOB(fd,2) = 0x03; break; // 'You are not eligible to open the Character Slot.'
- case -5: WFIFOB(fd,2) = 0x02; break; // 'Symbols in Character Names are forbidden'
-
- default:
- ShowWarning("parse_char: Unknown result received from make_new_char_sql!\n");
- WFIFOB(fd,2) = 0xFF;
- break;
- }
- WFIFOSET(fd,3);
- } else {
- int len;
- // retrieve data
- struct mmo_charstatus char_dat;
- mmo_char_fromsql(result, &char_dat, false); //Only the short data is needed.
-
- // send to player
- WFIFOHEAD(fd,2+MAX_CHAR_BUF);
- WFIFOW(fd,0) = 0x6d;
- len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat);
- WFIFOSET(fd,len);
-
- // add new entry to the chars list
- sd->found_char[char_dat.slot] = result; // the char_id of the new char
- }
- #if PACKETVER >= 20120307
- RFIFOSKIP(fd,31);
- #else
- RFIFOSKIP(fd,37);
- #endif
+ chr->parse_char_create_new_char(fd, sd);
}
break;
@@ -4503,67 +5020,7 @@ int parse_char(int fd)
if (cmd == 0x68) FIFOSD_CHECK(46);
if (cmd == 0x1fb) FIFOSD_CHECK(56);
{
- int cid = RFIFOL(fd,2);
- int i;
-#if PACKETVER >= 20110309
- if( *pincode->enabled ){ // hack check
- struct online_char_data* character;
- character = (struct online_char_data*)idb_get(online_char_db, sd->account_id);
- if( character && character->pincode_enable == -1 ){
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x6c;
- WFIFOB(fd,2) = 0;
- WFIFOSET(fd,3);
- break;
- }
- }
-#endif
- ShowInfo(CL_RED"Request Char Deletion: "CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, cid);
- memcpy(email, RFIFOP(fd,6), 40);
- RFIFOSKIP(fd,( cmd == 0x68) ? 46 : 56);
-
- // Check if e-mail is correct
- if(strcmpi(email, sd->email) && //email does not matches and
- (
- strcmp("a@a.com", sd->email) || //it is not default email, or
- (strcmp("a@a.com", email) && strcmp("", email)) //email sent does not matches default
- )) { //Fail
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x70;
- WFIFOB(fd,2) = 0; // 00 = Incorrect Email address
- WFIFOSET(fd,3);
- break;
- }
-
- // check if this char exists
- ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid );
- if( i == MAX_CHARS )
- { // Such a character does not exist in the account
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x70;
- WFIFOB(fd,2) = 0;
- WFIFOSET(fd,3);
- break;
- }
-
- // remove char from list and compact it
- sd->found_char[i] = -1;
-
- /* Delete character */
- if(delete_char_sql(cid)<0){
- //can't delete the char
- //either SQL error or can't delete by some CONFIG conditions
- //del fail
- WFIFOHEAD(fd,3);
- WFIFOW(fd, 0) = 0x70;
- WFIFOB(fd, 2) = 0;
- WFIFOSET(fd, 3);
- break;
- }
- /* Char successfully deleted.*/
- WFIFOHEAD(fd,2);
- WFIFOW(fd,0) = 0x6f;
- WFIFOSET(fd,2);
+ chr->parse_char_delete_char(fd, sd, cmd);
}
break;
@@ -4572,35 +5029,14 @@ int parse_char(int fd)
case 0x187:
if (RFIFOREST(fd) < 6)
return 0;
- RFIFOSKIP(fd,6);
+ chr->parse_char_ping(fd);
break;
// char rename request
// R 08fc <char ID>.l <new name>.24B
case 0x8fc:
FIFOSD_CHECK(30);
{
- int i, cid =RFIFOL(fd,2);
- char name[NAME_LENGTH];
- char esc_name[NAME_LENGTH*2+1];
- safestrncpy(name, (char *)RFIFOP(fd,6), NAME_LENGTH);
- RFIFOSKIP(fd,30);
-
- ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid );
- if( i == MAX_CHARS )
- break;
-
- normalize_name(name,TRIM_CHARS);
- SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
- if( !check_char_name(name,esc_name) ) {
- i = 1;
- safestrncpy(sd->new_name, name, NAME_LENGTH);
- } else
- i = 0;
-
- WFIFOHEAD(fd, 4);
- WFIFOW(fd,0) = 0x28e;
- WFIFOW(fd,2) = i;
- WFIFOSET(fd,4);
+ chr->parse_char_rename_char(fd, sd);
}
break;
@@ -4609,32 +5045,7 @@ int parse_char(int fd)
case 0x28d:
FIFOSD_CHECK(34);
{
- int i, aid = RFIFOL(fd,2), cid =RFIFOL(fd,6);
- char name[NAME_LENGTH];
- char esc_name[NAME_LENGTH*2+1];
- safestrncpy(name, (char *)RFIFOP(fd,10), NAME_LENGTH);
- RFIFOSKIP(fd,34);
-
- if( aid != sd->account_id )
- break;
- ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid );
- if( i == MAX_CHARS )
- break;
-
- normalize_name(name,TRIM_CHARS);
- SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
- if( !check_char_name(name,esc_name) )
- {
- i = 1;
- safestrncpy(sd->new_name, name, NAME_LENGTH);
- }
- else
- i = 0;
-
- WFIFOHEAD(fd, 4);
- WFIFOW(fd,0) = 0x28e;
- WFIFOW(fd,2) = i;
- WFIFOSET(fd,4);
+ chr->parse_char_rename_char2(fd, sd);
}
break;
//Confirm change name.
@@ -4647,63 +5058,38 @@ int parse_char(int fd)
// 4: Another user is using this character name, so please select another one.
FIFOSD_CHECK(6);
{
- int i;
- int cid = RFIFOL(fd,2);
- RFIFOSKIP(fd,6);
-
- ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid );
- if( i == MAX_CHARS )
- break;
- i = rename_char_sql(sd, cid);
-
- WFIFOHEAD(fd, 4);
- WFIFOW(fd,0) = 0x290;
- WFIFOW(fd,2) = i;
- WFIFOSET(fd,4);
+ chr->parse_char_rename_char_confirm(fd, sd);
}
break;
// captcha code request (not implemented)
// R 07e5 <?>.w <aid>.l
case 0x7e5:
- WFIFOHEAD(fd,5);
- WFIFOW(fd,0) = 0x7e9;
- WFIFOW(fd,2) = 5;
- WFIFOB(fd,4) = 1;
- WFIFOSET(fd,5);
- RFIFOSKIP(fd,8);
+ chr->parse_char_request_captcha(fd);
break;
// captcha code check (not implemented)
// R 07e7 <len>.w <aid>.l <code>.b10 <?>.b14
case 0x7e7:
- WFIFOHEAD(fd,5);
- WFIFOW(fd,0) = 0x7e9;
- WFIFOW(fd,2) = 5;
- WFIFOB(fd,4) = 1;
- WFIFOSET(fd,5);
- RFIFOSKIP(fd,32);
+ chr->parse_char_check_captcha(fd);
break;
// deletion timer request
case 0x827:
FIFOSD_CHECK(6);
- char_delete2_req(fd, sd);
- RFIFOSKIP(fd,6);
+ chr->parse_char_delete2_req(fd, sd);
break;
// deletion accept request
case 0x829:
FIFOSD_CHECK(12);
- char_delete2_accept(fd, sd);
- RFIFOSKIP(fd,12);
+ chr->parse_char_delete2_accept(fd, sd);
break;
// deletion cancel request
case 0x82b:
FIFOSD_CHECK(6);
- char_delete2_cancel(fd, sd);
- RFIFOSKIP(fd,6);
+ chr->parse_char_delete2_cancel(fd, sd);
break;
// login as map-server
@@ -4711,112 +5097,51 @@ int parse_char(int fd)
if (RFIFOREST(fd) < 60)
return 0;
{
- char* l_user = (char*)RFIFOP(fd,2);
- char* l_pass = (char*)RFIFOP(fd,26);
- int i;
- l_user[23] = '\0';
- l_pass[23] = '\0';
- ARR_FIND( 0, ARRAYLENGTH(server), i, server[i].fd <= 0 );
- if( runflag != CHARSERVER_ST_RUNNING ||
- i == ARRAYLENGTH(server) ||
- strcmp(l_user, userid) != 0 ||
- strcmp(l_pass, passwd) != 0 )
- {
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x2af9;
- WFIFOB(fd,2) = 3;
- WFIFOSET(fd,3);
- } else {
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x2af9;
- WFIFOB(fd,2) = 0;
- WFIFOSET(fd,3);
-
- server[i].fd = fd;
- server[i].ip = ntohl(RFIFOL(fd,54));
- server[i].port = ntohs(RFIFOW(fd,58));
- server[i].users = 0;
- session[fd]->func_parse = parse_frommap;
- session[fd]->flag.server = 1;
- realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
- char_mapif_init(fd);
- }
- sockt->datasync(fd, true);
-
- RFIFOSKIP(fd,60);
+ chr->parse_char_login_map_server(fd);
}
return 0; // avoid processing of follow-up packets here
-
+
// checks the entered pin
case 0x8b8:
- if( RFIFOREST(fd) < 10 )
- return 0;
-
- if( RFIFOL(fd,2) == sd->account_id )
- pincode->check( fd, sd );
-
- RFIFOSKIP(fd,10);
+ FIFOSD_CHECK(10);
+ chr->parse_char_pincode_check(fd, sd);
break;
-
+
// request for PIN window
case 0x8c5:
- if( RFIFOREST(fd) < 6 )
- return 0;
- if( RFIFOL(fd,2) == sd->account_id )
- pincode->sendstate( fd, sd, PINCODE_NOTSET );
-
- RFIFOSKIP(fd,6);
+ FIFOSD_CHECK(6);
+ chr->parse_char_pincode_window(fd, sd);
break;
-
+
// pincode change request
case 0x8be:
- if( RFIFOREST(fd) < 14 )
- return 0;
- if( RFIFOL(fd,2) == sd->account_id )
- pincode->change( fd, sd );
-
- RFIFOSKIP(fd,14);
+ FIFOSD_CHECK(14);
+ chr->parse_char_pincode_change(fd, sd);
break;
-
+
// activate PIN system and set first PIN
case 0x8ba:
- if( RFIFOREST(fd) < 10 )
- return 0;
- if( RFIFOL(fd,2) == sd->account_id )
- pincode->setnew( fd, sd );
- RFIFOSKIP(fd,10);
+ FIFOSD_CHECK(10);
+ chr->parse_char_pincode_first_pin(fd, sd);
break;
-
+
+ case 0x9a1:
+ FIFOSD_CHECK(2);
+ chr->parse_char_request_chars(fd, sd);
+ break;
+
/* 0x8d4 <from>.W <to>.W <unused>.W (2+2+2+2) */
case 0x8d4:
- if( RFIFOREST(fd) < 8 )
- return 0;
- else {
- bool ret;
- ret = char_slotchange(sd, fd, RFIFOW(fd, 2), RFIFOW(fd, 4));
- WFIFOHEAD(fd, 8);
- WFIFOW(fd, 0) = 0x8d5;
- WFIFOW(fd, 2) = 8;
- WFIFOW(fd, 4) = ret?0:1;
- WFIFOW(fd, 6) = 0;/* we enforce it elsewhere, go 0 */
- WFIFOSET(fd, 8);
- /* for some stupid reason it requires the char data again (gravity -_-) */
- if( ret )
-#if PACKETVER >= 20130000
- mmo_char_send099d(fd, sd);
-#else
- mmo_char_send006b(fd, sd);
-#endif
-
- RFIFOSKIP(fd, 8);
+ FIFOSD_CHECK(8);
+ {
+ chr->parse_char_move_character(fd, sd);
}
break;
-
+
// unknown packet received
default:
- ShowError("parse_char: Received unknown packet "CL_WHITE"0x%x"CL_RESET" from ip '"CL_WHITE"%s"CL_RESET"'! Disconnecting!\n", RFIFOW(fd,0), ip2str(ipl, NULL));
- set_eof(fd);
- return 0;
+ if (chr->parse_char_unknown_packet(fd, ipl))
+ return 0;
}
}
@@ -4829,9 +5154,9 @@ int mapif_sendall(unsigned char *buf, unsigned int len)
int i, c;
c = 0;
- for(i = 0; i < ARRAYLENGTH(server); i++) {
+ for(i = 0; i < ARRAYLENGTH(chr->server); i++) {
int fd;
- if ((fd = server[i].fd) > 0) {
+ if ((fd = chr->server[i].fd) > 0) {
WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len);
@@ -4847,9 +5172,9 @@ int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len)
int i, c;
c = 0;
- for(i = 0; i < ARRAYLENGTH(server); i++) {
+ for(i = 0; i < ARRAYLENGTH(chr->server); i++) {
int fd;
- if ((fd = server[i].fd) > 0 && fd != sfd) {
+ if ((fd = chr->server[i].fd) > 0 && fd != sfd) {
WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len);
@@ -4864,8 +5189,8 @@ int mapif_send(int fd, unsigned char *buf, unsigned int len)
{
if (fd >= 0) {
int i;
- ARR_FIND( 0, ARRAYLENGTH(server), i, fd == server[i].fd );
- if( i < ARRAYLENGTH(server) )
+ ARR_FIND( 0, ARRAYLENGTH(chr->server), i, fd == chr->server[i].fd );
+ if( i < ARRAYLENGTH(chr->server) )
{
WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
@@ -4876,9 +5201,17 @@ int mapif_send(int fd, unsigned char *buf, unsigned int len)
return 0;
}
-int broadcast_user_count(int tid, int64 tick, int id, intptr_t data) {
+void mapif_send_users_count(int users)
+{
uint8 buf[6];
- int users = count_users();
+ // send number of players to all map-servers
+ WBUFW(buf,0) = 0x2b00;
+ WBUFL(buf,2) = users;
+ mapif->sendall(buf,6);
+}
+
+int char_broadcast_user_count(int tid, int64 tick, int id, intptr_t data) {
+ int users = chr->count_users();
// only send an update when needed
static int prev_users = 0;
@@ -4886,19 +5219,13 @@ int broadcast_user_count(int tid, int64 tick, int id, intptr_t data) {
return 0;
prev_users = users;
- if( login_fd > 0 && session[login_fd] )
+ if( chr->login_fd > 0 && session[chr->login_fd] )
{
// send number of user to login server
- WFIFOHEAD(login_fd,6);
- WFIFOW(login_fd,0) = 0x2714;
- WFIFOL(login_fd,2) = users;
- WFIFOSET(login_fd,6);
+ loginif->send_users_count(users);
}
- // send number of players to all map-servers
- WBUFW(buf,0) = 0x2b00;
- WBUFL(buf,2) = users;
- mapif_sendall(buf,6);
+ mapif->send_users_count(users);
return 0;
}
@@ -4907,78 +5234,67 @@ int broadcast_user_count(int tid, int64 tick, int id, intptr_t data) {
* Load this character's account id into the 'online accounts' packet
* @see DBApply
*/
-static int send_accounts_tologin_sub(DBKey key, DBData *data, va_list ap)
+static int char_send_accounts_tologin_sub(DBKey key, DBData *data, va_list ap)
{
struct online_char_data* character = DB->data2ptr(data);
int* i = va_arg(ap, int*);
if(character->server > -1)
{
- WFIFOL(login_fd,8+(*i)*4) = character->account_id;
+ WFIFOL(chr->login_fd,8+(*i)*4) = character->account_id;
(*i)++;
return 1;
}
return 0;
}
-int send_accounts_tologin(int tid, int64 tick, int id, intptr_t data) {
- if (login_fd > 0 && session[login_fd])
+int char_send_accounts_tologin(int tid, int64 tick, int id, intptr_t data) {
+ if (chr->login_fd > 0 && session[chr->login_fd])
{
// send account list to login server
- int users = online_char_db->size(online_char_db);
+ int users = chr->online_char_db->size(chr->online_char_db);
int i = 0;
- WFIFOHEAD(login_fd,8+users*4);
- WFIFOW(login_fd,0) = 0x272d;
- online_char_db->foreach(online_char_db, send_accounts_tologin_sub, &i, users);
- WFIFOW(login_fd,2) = 8+ i*4;
- WFIFOL(login_fd,4) = i;
- WFIFOSET(login_fd,WFIFOW(login_fd,2));
+ WFIFOHEAD(chr->login_fd,8+users*4);
+ WFIFOW(chr->login_fd,0) = 0x272d;
+ chr->online_char_db->foreach(chr->online_char_db, chr->send_accounts_tologin_sub, &i, users);
+ WFIFOW(chr->login_fd,2) = 8+ i*4;
+ WFIFOL(chr->login_fd,4) = i;
+ WFIFOSET(chr->login_fd,WFIFOW(chr->login_fd,2));
}
return 0;
}
-int check_connect_login_server(int tid, int64 tick, int id, intptr_t data) {
- if (login_fd > 0 && session[login_fd] != NULL)
+int char_check_connect_login_server(int tid, int64 tick, int id, intptr_t data) {
+ if (chr->login_fd > 0 && session[chr->login_fd] != NULL)
return 0;
ShowInfo("Attempt to connect to login-server...\n");
- if ( (login_fd = make_connection(login_ip, login_port, NULL)) == -1) { //Try again later. [Skotlex]
- login_fd = 0;
+ if ( (chr->login_fd = make_connection(login_ip, login_port, NULL)) == -1) { //Try again later. [Skotlex]
+ chr->login_fd = 0;
return 0;
}
-
- session[login_fd]->func_parse = parse_fromlogin;
- session[login_fd]->flag.server = 1;
- realloc_fifo(login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
-
- WFIFOHEAD(login_fd,86);
- WFIFOW(login_fd,0) = 0x2710;
- memcpy(WFIFOP(login_fd,2), userid, 24);
- memcpy(WFIFOP(login_fd,26), passwd, 24);
- WFIFOL(login_fd,50) = 0;
- WFIFOL(login_fd,54) = htonl(char_ip);
- WFIFOW(login_fd,58) = htons(char_port);
- memcpy(WFIFOP(login_fd,60), server_name, 20);
- WFIFOW(login_fd,80) = 0;
- WFIFOW(login_fd,82) = char_server_type;
- WFIFOW(login_fd,84) = char_new_display; //only display (New) if they want to [Kevin]
- WFIFOSET(login_fd,86);
+
+ session[chr->login_fd]->func_parse = chr->parse_fromlogin;
+ session[chr->login_fd]->flag.server = 1;
+ realloc_fifo(chr->login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+
+ loginif->connect_to_server();
return 1;
}
//------------------------------------------------
-//Invoked 15 seconds after mapif_disconnectplayer in case the map server doesn't
+//Invoked 15 seconds after mapif->disconnectplayer in case the map server doesn't
//replies/disconnect the player we tried to kick. [Skotlex]
//------------------------------------------------
-static int chardb_waiting_disconnect(int tid, int64 tick, int id, intptr_t data) {
+static int char_waiting_disconnect(int tid, int64 tick, int id, intptr_t data) {
struct online_char_data* character;
- if ((character = (struct online_char_data*)idb_get(online_char_db, id)) != NULL && character->waiting_disconnect == tid)
- { //Mark it offline due to timeout.
+ if ((character = (struct online_char_data*)idb_get(chr->online_char_db, id)) != NULL && character->waiting_disconnect == tid) {
+ //Mark it offline due to timeout.
character->waiting_disconnect = INVALID_TIMER;
- set_char_offline(character->char_id, character->account_id);
+ chr->set_char_offline(character->char_id, character->account_id);
}
return 0;
}
@@ -4986,21 +5302,21 @@ static int chardb_waiting_disconnect(int tid, int64 tick, int id, intptr_t data)
/**
* @see DBApply
*/
-static int online_data_cleanup_sub(DBKey key, DBData *data, va_list ap)
+static int char_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap)
{
struct online_char_data *character= DB->data2ptr(data);
if (character->fd != -1)
return 0; //Character still connected
if (character->server == -2) //Unknown server.. set them offline
- set_char_offline(character->char_id, character->account_id);
+ chr->set_char_offline(character->char_id, character->account_id);
if (character->server < 0)
//Free data from players that have not been online for a while.
- db_remove(online_char_db, key);
+ db_remove(chr->online_char_db, key);
return 0;
}
-static int online_data_cleanup(int tid, int64 tick, int id, intptr_t data) {
- online_char_db->foreach(online_char_db, online_data_cleanup_sub);
+static int char_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) {
+ chr->online_char_db->foreach(chr->online_char_db, chr->online_data_cleanup_sub);
return 0;
}
@@ -5058,7 +5374,7 @@ int char_lan_config_read(const char *lancfgName)
return 0;
}
-void sql_config_read(const char* cfgName)
+void char_sql_config_read(const char* cfgName)
{
char line[1024], w1[1024], w2[1024];
FILE* fp;
@@ -5148,14 +5464,16 @@ void sql_config_read(const char* cfgName)
safestrncpy(acc_reg_str_db, w2, sizeof(acc_reg_str_db));
else if(!strcmpi(w1,"acc_reg_num_db"))
safestrncpy(acc_reg_num_db, w2, sizeof(acc_reg_num_db));
-
//support the import command, just like any other config
else if(!strcmpi(w1,"import"))
- sql_config_read(w2);
+ chr->sql_config_read(w2);
+ else
+ HPM->parseConf(w1, w2, HPCT_CHAR_INTER);
}
fclose(fp);
ShowInfo("Done reading %s.\n", cfgName);
}
+
void char_config_dispatch(char *w1, char *w2) {
bool (*dispatch_to[]) (char *w1, char *w2) = {
/* as many as it needs */
@@ -5166,7 +5484,10 @@ void char_config_dispatch(char *w1, char *w2) {
if( (*dispatch_to[i])(w1,w2) )
break;/* we found who this belongs to, can stop */
}
+ if (i == len)
+ HPM->parseConf(w1, w2, HPCT_CHAR);
}
+
int char_config_read(const char* cfgName)
{
char line[1024], w1[1024], w2[1024];
@@ -5195,11 +5516,11 @@ int char_config_read(const char* cfgName)
} else if(strcmpi(w1,"stdout_with_ansisequence")==0){
stdout_with_ansisequence = config_switch(w2);
} else if (strcmpi(w1, "userid") == 0) {
- safestrncpy(userid, w2, sizeof(userid));
+ safestrncpy(chr->userid, w2, sizeof(chr->userid));
} else if (strcmpi(w1, "passwd") == 0) {
- safestrncpy(passwd, w2, sizeof(passwd));
+ safestrncpy(chr->passwd, w2, sizeof(chr->passwd));
} else if (strcmpi(w1, "server_name") == 0) {
- safestrncpy(server_name, w2, sizeof(server_name));
+ safestrncpy(chr->server_name, w2, sizeof(chr->server_name));
} else if (strcmpi(w1, "wisp_server_name") == 0) {
if (strlen(w2) >= 4) {
safestrncpy(wisp_server_name, w2, sizeof(wisp_server_name));
@@ -5214,11 +5535,11 @@ int char_config_read(const char* cfgName)
} else if (strcmpi(w1, "login_port") == 0) {
login_port = atoi(w2);
} else if (strcmpi(w1, "char_ip") == 0) {
- char_ip = host2ip(w2);
- if (char_ip) {
+ chr->ip = host2ip(w2);
+ if (chr->ip) {
char ip_str[16];
safestrncpy(char_ip_str, w2, sizeof(char_ip_str));
- ShowStatus("Character server IP address : %s -> %s\n", w2, ip2str(char_ip, ip_str));
+ ShowStatus("Character server IP address : %s -> %s\n", w2, ip2str(chr->ip, ip_str));
}
} else if (strcmpi(w1, "bind_ip") == 0) {
bind_ip = host2ip(w2);
@@ -5228,13 +5549,13 @@ int char_config_read(const char* cfgName)
ShowStatus("Character server binding IP address : %s -> %s\n", w2, ip2str(bind_ip, ip_str));
}
} else if (strcmpi(w1, "char_port") == 0) {
- char_port = atoi(w2);
+ chr->port = atoi(w2);
} else if (strcmpi(w1, "char_server_type") == 0) {
- char_server_type = atoi(w2);
+ chr->server_type = atoi(w2);
} else if (strcmpi(w1, "char_new") == 0) {
char_new = (bool)atoi(w2);
} else if (strcmpi(w1, "char_new_display") == 0) {
- char_new_display = atoi(w2);
+ chr->new_display = atoi(w2);
} else if (strcmpi(w1, "max_connect_user") == 0) {
max_connect_user = atoi(w2);
if (max_connect_user < -1)
@@ -5277,7 +5598,7 @@ int char_config_read(const char* cfgName)
// Format is: id1,quantity1,stackable1,idN,quantityN,stackableN
if( i%3 )
{
- ShowWarning("char_config_read: There are not enough parameters in start_items, ignoring last item...\n");
+ ShowWarning("chr->config_read: There are not enough parameters in start_items, ignoring last item...\n");
if( i%3 == 1 )
start_items[i-1] = 0;
else
@@ -5287,8 +5608,8 @@ int char_config_read(const char* cfgName)
start_zeny = atoi(w2);
if (start_zeny < 0)
start_zeny = 0;
- } else if(strcmpi(w1,"log_char")==0) { //log char or not [devil]
- log_char = atoi(w2);
+ } else if(strcmpi(w1,"log_char")==0) {
+ log_char = atoi(w2); //log char or not [devil]
} else if (strcmpi(w1, "unknown_char_name") == 0) {
safestrncpy(unknown_char_name, w2, sizeof(unknown_char_name));
unknown_char_name[NAME_LENGTH-1] = '\0';
@@ -5329,9 +5650,9 @@ int char_config_read(const char* cfgName)
} else if (strcmpi(w1, "char_maintenance_min_group_id") == 0) {
char_maintenance_min_group_id = atoi(w2);
} else if (strcmpi(w1, "import") == 0) {
- char_config_read(w2);
+ chr->config_read(w2);
} else
- char_config_dispatch(w1,w2);
+ chr->config_dispatch(w1,w2);
}
fclose(fp);
@@ -5341,40 +5662,44 @@ int char_config_read(const char* cfgName)
int do_final(void) {
int i;
-
+
ShowStatus("Terminating...\n");
HPM->event(HPET_FINAL);
-
- set_all_offline(-1);
- set_all_offline_sql();
- inter_final();
+ chr->set_all_offline(-1);
+ chr->set_all_offline_sql();
+
+ inter->final();
flush_fifos();
do_final_mapif();
- do_final_loginif();
+ loginif->final();
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s`", ragsrvinfo_db) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s`", ragsrvinfo_db) )
+ Sql_ShowDebug(inter->sql_handle);
- char_db_->destroy(char_db_, NULL);
- online_char_db->destroy(online_char_db, NULL);
+ chr->char_db_->destroy(chr->char_db_, NULL);
+ chr->online_char_db->destroy(chr->online_char_db, NULL);
auth_db->destroy(auth_db, NULL);
- if( char_fd != -1 ) {
- do_close(char_fd);
- char_fd = -1;
+ if( chr->char_fd != -1 ) {
+ do_close(chr->char_fd);
+ chr->char_fd = -1;
}
- SQL->Free(sql_handle);
+ HPM_char_do_final();
+
+ SQL->Free(inter->sql_handle);
mapindex->final();
for(i = 0; i < MAX_MAP_SERVERS; i++ )
- if( server[i].map )
- aFree(server[i].map);
-
+ if( chr->server[i].map )
+ aFree(chr->server[i].map);
+
+ HPM->event(HPET_POST_FINAL);
+
ShowStatus("Finished.\n");
return EXIT_SUCCESS;
}
@@ -5391,7 +5716,6 @@ void set_server_type(void) {
SERVER_TYPE = SERVER_TYPE_CHAR;
}
-
/// Called when a terminate signal is received.
void do_shutdown(void)
{
@@ -5401,52 +5725,92 @@ void do_shutdown(void)
runflag = CHARSERVER_ST_SHUTDOWN;
ShowStatus("Shutting down...\n");
// TODO proper shutdown procedure; wait for acks?, kick all characters, ... [FlavoJS]
- for( id = 0; id < ARRAYLENGTH(server); ++id )
- mapif_server_reset(id);
- loginif_check_shutdown();
+ for( id = 0; id < ARRAYLENGTH(chr->server); ++id )
+ mapif->server_reset(id);
+ loginif->check_shutdown();
flush_fifos();
runflag = CORE_ST_STOP;
}
}
+void char_hp_symbols(void) {
+ HPM->share(mapindex,"mapindex");
+ HPM->share(chr, "chr");
+ HPM->share(geoip, "geoip");
+ HPM->share(inter_auction, "inter_auction");
+ HPM->share(inter_elemental, "inter_elemental");
+ HPM->share(inter_guild, "inter_guild");
+ HPM->share(inter_homunculus, "inter_homunculus");
+ HPM->share(inter_mail, "inter_mail");
+ HPM->share(inter_mercenary, "inter_mercenary");
+ HPM->share(inter_party, "inter_party");
+ HPM->share(inter_pet, "inter_pet");
+ HPM->share(inter_quest, "inter_quest");
+ HPM->share(inter_storage, "inter_storage");
+ HPM->share(inter, "inter");
+ HPM->share(loginif, "loginif");
+ HPM->share(mapif, "mapif");
+ HPM->share(pincode, "pincode");
+ HPM->share(inter->sql_handle, "sql_handle");
+}
int do_init(int argc, char **argv) {
int i;
memset(&skillid2idx, 0, sizeof(skillid2idx));
+ char_load_defaults();
+
for(i = 0; i < MAX_MAP_SERVERS; i++ )
- server[i].map = NULL;
+ chr->server[i].map = NULL;
+
+ HPM_char_do_init();
+ HPM->symbol_defaults_sub = char_hp_symbols;
+#if 0
+ /* TODO: Move to common code */
+ for( i = 1; i < argc; i++ ) {
+ const char* arg = argv[i];
+ if( strcmp(arg, "--load-plugin") == 0 ) {
+ if( map->arg_next_value(arg, i, argc, true) ) {
+ RECREATE(load_extras, char *, ++load_extras_count);
+ load_extras[load_extras_count-1] = argv[++i];
+ }
+ }
+ }
+ HPM->config_read((const char * const *)load_extras, load_extras_count);
+ if (load_extras) {
+ aFree(load_extras);
+ load_extras = NULL;
+ load_extras_count = 0;
+ }
+#endif
+ HPM->config_read(NULL, 0);
+ HPM->event(HPET_PRE_INIT);
- mapindex_defaults();
- pincode_defaults();
-
//Read map indexes
mapindex->init();
start_point.map = mapindex->name2id("new_zone01");
-
- char_config_read((argc < 2) ? CHAR_CONF_NAME : argv[1]);
- char_lan_config_read((argc > 3) ? argv[3] : LAN_CONF_NAME);
- sql_config_read(SQL_CONF_NAME);
- if (strcmp(userid, "s1")==0 && strcmp(passwd, "p1")==0) {
+ chr->config_read((argc < 2) ? CHAR_CONF_NAME : argv[1]);
+ chr->lan_config_read((argc > 3) ? argv[3] : LAN_CONF_NAME);
+ chr->sql_config_read(SQL_CONF_NAME);
+
+ if (strcmp(chr->userid, "s1")==0 && strcmp(chr->passwd, "p1")==0) {
ShowWarning("Using the default user/password s1/p1 is NOT RECOMMENDED.\n");
ShowNotice("Please edit your 'login' table to create a proper inter-server user/password (gender 'S')\n");
ShowNotice("And then change the user/password to use in conf/char-server.conf (or conf/import/char_conf.txt)\n");
}
-
- inter_init_sql((argc > 2) ? argv[2] : inter_cfgName); // inter server configuration
+
+ inter->init_sql((argc > 2) ? argv[2] : inter_cfgName); // inter server configuration
auth_db = idb_alloc(DB_OPT_RELEASE_DATA);
- online_char_db = idb_alloc(DB_OPT_RELEASE_DATA);
+ chr->online_char_db = idb_alloc(DB_OPT_RELEASE_DATA);
- HPM->share(sql_handle,"sql_handle");
- HPM->config_read(NULL, 0);
HPM->event(HPET_INIT);
-
- mmo_char_sql_init();
- char_read_fame_list(); //Read fame lists.
- if ((sockt->naddr_ != 0) && (!login_ip || !char_ip)) {
+ chr->mmo_char_sql_init();
+ chr->read_fame_list(); //Read fame lists.
+
+ if ((sockt->naddr_ != 0) && (!login_ip || !chr->ip)) {
char ip_str[16];
ip2str(sockt->addr_[0], ip_str);
@@ -5458,52 +5822,52 @@ int do_init(int argc, char **argv) {
safestrncpy(login_ip_str, ip_str, sizeof(login_ip_str));
login_ip = str2ip(login_ip_str);
}
- if (!char_ip) {
+ if (!chr->ip) {
safestrncpy(char_ip_str, ip_str, sizeof(char_ip_str));
- char_ip = str2ip(char_ip_str);
+ chr->ip = str2ip(char_ip_str);
}
}
- do_init_loginif();
+ loginif->init();
do_init_mapif();
// periodically update the overall user count on all mapservers + login server
- timer->add_func_list(broadcast_user_count, "broadcast_user_count");
- timer->add_interval(timer->gettick() + 1000, broadcast_user_count, 0, 0, 5 * 1000);
+ timer->add_func_list(chr->broadcast_user_count, "chr->broadcast_user_count");
+ timer->add_interval(timer->gettick() + 1000, chr->broadcast_user_count, 0, 0, 5 * 1000);
- // Timer to clear (online_char_db)
- timer->add_func_list(chardb_waiting_disconnect, "chardb_waiting_disconnect");
+ // Timer to clear (chr->online_char_db)
+ timer->add_func_list(chr->waiting_disconnect, "chr->waiting_disconnect");
// Online Data timers (checking if char still connected)
- timer->add_func_list(online_data_cleanup, "online_data_cleanup");
- timer->add_interval(timer->gettick() + 1000, online_data_cleanup, 0, 0, 600 * 1000);
+ timer->add_func_list(chr->online_data_cleanup, "chr->online_data_cleanup");
+ timer->add_interval(timer->gettick() + 1000, chr->online_data_cleanup, 0, 0, 600 * 1000);
//Cleaning the tables for NULL entries @ startup [Sirius]
//Chardb clean
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '0'", char_db) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '0'", char_db) )
+ Sql_ShowDebug(inter->sql_handle);
//guilddb clean
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_lv` = '0' AND `max_member` = '0' AND `exp` = '0' AND `next_exp` = '0' AND `average_lv` = '0'", guild_db) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_lv` = '0' AND `max_member` = '0' AND `exp` = '0' AND `next_exp` = '0' AND `average_lv` = '0'", guild_db) )
+ Sql_ShowDebug(inter->sql_handle);
//guildmemberdb clean
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '0' AND `account_id` = '0' AND `char_id` = '0'", guild_member_db) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '0' AND `account_id` = '0' AND `char_id` = '0'", guild_member_db) )
+ Sql_ShowDebug(inter->sql_handle);
- set_defaultparse(parse_char);
-
- if( (char_fd = make_listen_bind(bind_ip,char_port)) == -1 ) {
- ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",char_port);
+ set_defaultparse(chr->parse_char);
+
+ if( (chr->char_fd = make_listen_bind(bind_ip,chr->port)) == -1 ) {
+ ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",chr->port);
exit(EXIT_FAILURE);
}
-
- Sql_HerculesUpdateCheck(sql_handle);
+
+ Sql_HerculesUpdateCheck(inter->sql_handle);
#ifdef CONSOLE_INPUT
- console->input->setSQL(sql_handle);
+ console->input->setSQL(inter->sql_handle);
#endif
- ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port);
-
+ ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", chr->port);
+
if( runflag != CORE_ST_STOP )
{
shutdown_callback = do_shutdown;
@@ -5511,6 +5875,206 @@ int do_init(int argc, char **argv) {
}
HPM->event(HPET_READY);
-
+
return 0;
}
+
+void char_load_defaults(void)
+{
+ mapindex_defaults();
+ pincode_defaults();
+ char_defaults();
+ loginif_defaults();
+ mapif_defaults();
+ inter_auction_defaults();
+ inter_elemental_defaults();
+ inter_guild_defaults();
+ inter_homunculus_defaults();
+ inter_mail_defaults();
+ inter_mercenary_defaults();
+ inter_party_defaults();
+ inter_pet_defaults();
+ inter_quest_defaults();
+ inter_storage_defaults();
+ inter_defaults();
+ geoip_defaults();
+}
+
+void char_defaults(void)
+{
+ chr = &char_s;
+
+ memset(chr->server, 0, sizeof(chr->server));
+
+ chr->login_fd = 0;
+ chr->char_fd = -1;
+ chr->online_char_db = NULL;
+ chr->char_db_ = NULL;
+
+ memset(chr->userid, 0, sizeof(chr->userid));
+ memset(chr->passwd, 0, sizeof(chr->passwd));
+
+ chr->ip = 0;
+ chr->port = 6121;
+ chr->server_type = 0;
+ chr->new_display = 0;
+
+ chr->waiting_disconnect = char_waiting_disconnect;
+ chr->delete_char_sql = char_delete_char_sql;
+ chr->create_online_char_data = char_create_online_char_data;
+ chr->set_account_online = char_set_account_online;
+ chr->set_account_offline = char_set_account_offline;
+ chr->set_char_charselect = char_set_char_charselect;
+ chr->set_char_online = char_set_char_online;
+ chr->set_char_offline = char_set_char_offline;
+ chr->db_setoffline = char_db_setoffline;
+ chr->db_kickoffline = char_db_kickoffline;
+ chr->set_login_all_offline = char_set_login_all_offline;
+ chr->set_all_offline = char_set_all_offline;
+ chr->set_all_offline_sql = char_set_all_offline_sql;
+ chr->create_charstatus = char_create_charstatus;
+ chr->mmo_char_tosql = char_mmo_char_tosql;
+ chr->memitemdata_to_sql = char_memitemdata_to_sql;
+ chr->inventory_to_sql = char_inventory_to_sql;
+ chr->mmo_chars_fromsql = char_mmo_chars_fromsql;
+ chr->mmo_char_fromsql = char_mmo_char_fromsql;
+ chr->mmo_char_sql_init = char_mmo_char_sql_init;
+ chr->char_slotchange = char_char_slotchange;
+ chr->rename_char_sql = char_rename_char_sql;
+ chr->check_char_name = char_check_char_name;
+ chr->make_new_char_sql = char_make_new_char_sql;
+ chr->divorce_char_sql = char_divorce_char_sql;
+ chr->count_users = char_count_users;
+ chr->mmo_char_tobuf = char_mmo_char_tobuf;
+ chr->mmo_char_send099d = char_mmo_char_send099d;
+ chr->mmo_char_send_ban_list = char_mmo_char_send_ban_list;
+ chr->mmo_char_send_slots_info = char_mmo_char_send_slots_info;
+ chr->mmo_char_send_characters = char_mmo_char_send_characters;
+ chr->char_married = char_char_married;
+ chr->char_child = char_char_child;
+ chr->char_family = char_char_family;
+ chr->disconnect_player = char_disconnect_player;
+ chr->authfail_fd = char_authfail_fd;
+ chr->request_account_data = char_request_account_data;
+ chr->auth_ok = char_auth_ok;
+ chr->ping_login_server = char_ping_login_server;
+ chr->parse_fromlogin_connection_state = char_parse_fromlogin_connection_state;
+ chr->auth_error = char_auth_error;
+ chr->parse_fromlogin_auth_state = char_parse_fromlogin_auth_state;
+ chr->parse_fromlogin_account_data = char_parse_fromlogin_account_data;
+ chr->parse_fromlogin_login_pong = char_parse_fromlogin_login_pong;
+ chr->changesex = char_changesex;
+ chr->parse_fromlogin_changesex_reply = char_parse_fromlogin_changesex_reply;
+ chr->parse_fromlogin_account_reg2 = char_parse_fromlogin_account_reg2;
+ chr->parse_fromlogin_ban = char_parse_fromlogin_ban;
+ chr->parse_fromlogin_kick = char_parse_fromlogin_kick;
+ chr->update_ip = char_update_ip;
+ chr->parse_fromlogin_update_ip = char_parse_fromlogin_update_ip;
+ chr->parse_fromlogin_accinfo2_failed = char_parse_fromlogin_accinfo2_failed;
+ chr->parse_fromlogin_accinfo2_ok = char_parse_fromlogin_accinfo2_ok;
+ chr->parse_fromlogin = char_parse_fromlogin;
+ chr->request_accreg2 = char_request_accreg2;
+ chr->global_accreg_to_login_start = char_global_accreg_to_login_start;
+ chr->global_accreg_to_login_send = char_global_accreg_to_login_send;
+ chr->global_accreg_to_login_add = char_global_accreg_to_login_add;
+ chr->read_fame_list = char_read_fame_list;
+ chr->send_fame_list = char_send_fame_list;
+ chr->update_fame_list = char_update_fame_list;
+ chr->loadName = char_loadName;
+ chr->parse_frommap_datasync = char_parse_frommap_datasync;
+ chr->parse_frommap_skillid2idx = char_parse_frommap_skillid2idx;
+ chr->map_received_ok = char_map_received_ok;
+ chr->send_maps = char_send_maps;
+ chr->parse_frommap_map_names = char_parse_frommap_map_names;
+ chr->send_scdata = char_send_scdata;
+ chr->parse_frommap_request_scdata = char_parse_frommap_request_scdata;
+ chr->parse_frommap_set_users_count = char_parse_frommap_set_users_count;
+ chr->parse_frommap_set_users = char_parse_frommap_set_users;
+ chr->save_character_ack = char_save_character_ack;
+ chr->parse_frommap_save_character = char_parse_frommap_save_character;
+ chr->select_ack = char_select_ack;
+ chr->parse_frommap_char_select_req = char_parse_frommap_char_select_req;
+ chr->change_map_server_ack = char_change_map_server_ack;
+ chr->parse_frommap_change_map_server = char_parse_frommap_change_map_server;
+ chr->parse_frommap_remove_friend = char_parse_frommap_remove_friend;
+ chr->char_name_ack = char_char_name_ack;
+ chr->parse_frommap_char_name_request = char_parse_frommap_char_name_request;
+ chr->parse_frommap_change_email = char_parse_frommap_change_email;
+ chr->ban = char_ban;
+ chr->unban = char_unban;
+ chr->ask_name_ack = char_ask_name_ack;
+ chr->parse_frommap_change_account = char_parse_frommap_change_account;
+ chr->parse_frommap_fame_list = char_parse_frommap_fame_list;
+ chr->parse_frommap_divorce_char = char_parse_frommap_divorce_char;
+ chr->parse_frommap_ragsrvinfo = char_parse_frommap_ragsrvinfo;
+ chr->parse_frommap_set_char_offline = char_parse_frommap_set_char_offline;
+ chr->parse_frommap_set_all_offline = char_parse_frommap_set_all_offline;
+ chr->parse_frommap_set_char_online = char_parse_frommap_set_char_online;
+ chr->parse_frommap_build_fame_list = char_parse_frommap_build_fame_list;
+ chr->parse_frommap_save_status_change_data = char_parse_frommap_save_status_change_data;
+ chr->send_pong = char_send_pong;
+ chr->parse_frommap_ping = char_parse_frommap_ping;
+ chr->map_auth_ok = char_map_auth_ok;
+ chr->map_auth_failed = char_map_auth_failed;
+ chr->parse_frommap_auth_request = char_parse_frommap_auth_request;
+ chr->parse_frommap_update_ip = char_parse_frommap_update_ip;
+ chr->parse_frommap_request_stats_report = char_parse_frommap_request_stats_report;
+ chr->parse_frommap_scdata_update = char_parse_frommap_scdata_update;
+ chr->parse_frommap_scdata_delete = char_parse_frommap_scdata_delete;
+ chr->parse_frommap = char_parse_frommap;
+ chr->search_mapserver = char_search_mapserver;
+ chr->mapif_init = char_mapif_init;
+ chr->lan_subnetcheck = char_lan_subnetcheck;
+ chr->delete2_ack = char_delete2_ack;
+ chr->delete2_accept_actual_ack = char_delete2_accept_actual_ack;
+ chr->delete2_accept_ack = char_delete2_accept_ack;
+ chr->delete2_cancel_ack = char_delete2_cancel_ack;
+ chr->delete2_req = char_delete2_req;
+ chr->delete2_accept = char_delete2_accept;
+ chr->delete2_cancel = char_delete2_cancel;
+ chr->send_account_id = char_send_account_id;
+ chr->parse_char_connect = char_parse_char_connect;
+ chr->send_map_info = char_send_map_info;
+ chr->send_wait_char_server = char_send_wait_char_server;
+ chr->search_default_maps_mapserver = char_search_default_maps_mapserver;
+ chr->parse_char_select = char_parse_char_select;
+ chr->creation_failed = char_creation_failed;
+ chr->creation_ok = char_creation_ok;
+ chr->parse_char_create_new_char = char_parse_char_create_new_char;
+ chr->delete_char_failed = char_delete_char_failed;
+ chr->delete_char_ok = char_delete_char_ok;
+ chr->parse_char_delete_char = char_parse_char_delete_char;
+ chr->parse_char_ping = char_parse_char_ping;
+ chr->allow_rename = char_allow_rename;
+ chr->parse_char_rename_char = char_parse_char_rename_char;
+ chr->parse_char_rename_char2 = char_parse_char_rename_char2;
+ chr->rename_char_ack = char_rename_char_ack;
+ chr->parse_char_rename_char_confirm = char_parse_char_rename_char_confirm;
+ chr->captcha_notsupported = char_captcha_notsupported;
+ chr->parse_char_request_captcha = char_parse_char_request_captcha;
+ chr->parse_char_check_captcha = char_parse_char_check_captcha;
+ chr->parse_char_delete2_req = char_parse_char_delete2_req;
+ chr->parse_char_delete2_accept = char_parse_char_delete2_accept;
+ chr->parse_char_delete2_cancel = char_parse_char_delete2_cancel;
+ chr->login_map_server_ack = char_login_map_server_ack;
+ chr->parse_char_login_map_server = char_parse_char_login_map_server;
+ chr->parse_char_pincode_check = char_parse_char_pincode_check;
+ chr->parse_char_pincode_window = char_parse_char_pincode_window;
+ chr->parse_char_pincode_change = char_parse_char_pincode_change;
+ chr->parse_char_pincode_first_pin = char_parse_char_pincode_first_pin;
+ chr->parse_char_request_chars = char_parse_char_request_chars;
+ chr->change_character_slot_ack = char_change_character_slot_ack;
+ chr->parse_char_move_character = char_parse_char_move_character;
+ chr->parse_char_unknown_packet = char_parse_char_unknown_packet;
+ chr->parse_char = char_parse_char;
+ chr->broadcast_user_count = char_broadcast_user_count;
+ chr->send_accounts_tologin_sub = char_send_accounts_tologin_sub;
+ chr->send_accounts_tologin = char_send_accounts_tologin;
+ chr->check_connect_login_server = char_check_connect_login_server;
+ chr->online_data_cleanup_sub = char_online_data_cleanup_sub;
+ chr->online_data_cleanup = char_online_data_cleanup;
+ chr->lan_config_read = char_lan_config_read;
+ chr->sql_config_read = char_sql_config_read;
+ chr->config_dispatch = char_config_dispatch;
+ chr->config_read = char_config_read;
+}
diff --git a/src/char/char.h b/src/char/char.h
index 5a70d2ca7..a6707a7f9 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -5,6 +5,7 @@
#ifndef COMMON_CHAR_H
#define COMMON_CHAR_H
+#include "../common/cbasetypes.h"
#include "../common/core.h" // CORE_ST_LAST
#include "../common/db.h"
@@ -14,8 +15,6 @@ enum E_CHARSERVER_ST {
CHARSERVER_ST_LAST
};
-struct mmo_charstatus;
-
struct char_session_data {
bool auth; // whether the session is authed or not
int account_id, login_id1, login_id2, sex;
@@ -44,7 +43,14 @@ struct online_char_data {
int pincode_enable;
};
-DBMap* online_char_db; // int account_id -> struct online_char_data*
+struct mmo_map_server {
+ int fd;
+ uint32 ip;
+ uint16 port;
+ int users;
+ unsigned short *map;
+ unsigned short maps;
+};
#define MAX_MAP_SERVERS 2
@@ -57,21 +63,6 @@ enum {
TABLE_GUILD_STORAGE,
};
-int memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch);
-
-int mapif_sendall(unsigned char *buf,unsigned int len);
-int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len);
-int mapif_send(int fd,unsigned char *buf,unsigned int len);
-void mapif_on_parse_accinfo(int account_id,int u_fd, int aid, int castergroup, int map_fd);
-
-void disconnect_player(int account_id);
-
-int char_married(int pl1,int pl2);
-int char_child(int parent_id, int child_id);
-int char_family(int pl1,int pl2,int pl3);
-
-int request_accreg2(int account_id, int char_id);
-int login_fd;
extern int char_name_option;
extern char char_name_letters[];
extern bool char_gm_read;
@@ -119,8 +110,198 @@ extern int db_use_sql_mob_skill_db;
extern int guild_exp_rate;
extern int log_inter;
-void global_accreg_to_login_start (int account_id, int char_id);
-void global_accreg_to_login_send (void);
-void global_accreg_to_login_add (const char *key, unsigned int index, intptr_t val, bool is_string);
+void char_load_defaults();
+void char_defaults();
+
+struct char_auth_node {
+ int account_id;
+ int char_id;
+ uint32 login_id1;
+ uint32 login_id2;
+ uint32 ip;
+ int sex;
+ time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
+ int group_id;
+ unsigned changing_mapservers : 1;
+};
+
+/**
+ * char interface
+ **/
+struct char_interface {
+ struct mmo_map_server server[MAX_MAP_SERVERS];
+ int login_fd;
+ int char_fd;
+ DBMap* online_char_db; // int account_id -> struct online_char_data*
+ DBMap* char_db_;
+ char userid[NAME_LENGTH];
+ char passwd[NAME_LENGTH];
+ char server_name[20];
+ uint32 ip;
+ uint16 port;
+ int server_type;
+ int new_display;
+
+ int (*waiting_disconnect) (int tid, int64 tick, int id, intptr_t data);
+ int (*delete_char_sql) (int char_id);
+ DBData (*create_online_char_data) (DBKey key, va_list args);
+ void (*set_account_online) (int account_id);
+ void (*set_account_offline) (int account_id);
+ void (*set_char_charselect) (int account_id);
+ void (*set_char_online) (int map_id, int char_id, int account_id);
+ void (*set_char_offline) (int char_id, int account_id);
+ int (*db_setoffline) (DBKey key, DBData *data, va_list ap);
+ int (*db_kickoffline) (DBKey key, DBData *data, va_list ap);
+ void (*set_login_all_offline) (void);
+ void (*set_all_offline) (int id);
+ void (*set_all_offline_sql) (void);
+ DBData (*create_charstatus) (DBKey key, va_list args);
+ int (*mmo_char_tosql) (int char_id, struct mmo_charstatus* p);
+ int (*memitemdata_to_sql) (const struct item items[], int max, int id, int tableswitch);
+ int (*inventory_to_sql) (const struct item items[], int max, int id);
+ int (*mmo_chars_fromsql) (struct char_session_data* sd, uint8* buf);
+ int (*mmo_char_fromsql) (int char_id, struct mmo_charstatus* p, bool load_everything);
+ int (*mmo_char_sql_init) (void);
+ bool (*char_slotchange) (struct char_session_data *sd, int fd, unsigned short from, unsigned short to);
+ int (*rename_char_sql) (struct char_session_data *sd, int char_id);
+ int (*check_char_name) (char * name, char * esc_name);
+ int (*make_new_char_sql) (struct char_session_data* sd, char* name_, int str, int agi, int vit, int int_, int dex, int luk, int slot, int hair_color, int hair_style);
+ int (*divorce_char_sql) (int partner_id1, int partner_id2);
+ int (*count_users) (void);
+ int (*mmo_char_tobuf) (uint8* buffer, struct mmo_charstatus* p);
+ void (*mmo_char_send099d) (int fd, struct char_session_data *sd);
+ void (*mmo_char_send_ban_list) (int fd, struct char_session_data *sd);
+ void (*mmo_char_send_slots_info) (int fd, struct char_session_data* sd);
+ int (*mmo_char_send_characters) (int fd, struct char_session_data* sd);
+ int (*char_married) (int pl1, int pl2);
+ int (*char_child) (int parent_id, int child_id);
+ int (*char_family) (int cid1, int cid2, int cid3);
+ void (*disconnect_player) (int account_id);
+ void (*authfail_fd) (int fd, int type);
+ void (*request_account_data) (int account_id);
+ void (*auth_ok) (int fd, struct char_session_data *sd);
+ void (*ping_login_server) (int fd);
+ int (*parse_fromlogin_connection_state) (int fd);
+ void (*auth_error) (int fd, unsigned char flag);
+ void (*parse_fromlogin_auth_state) (int fd);
+ void (*parse_fromlogin_account_data) (int fd);
+ void (*parse_fromlogin_login_pong) (int fd);
+ void (*changesex) (int account_id, int sex);
+ int (*parse_fromlogin_changesex_reply) (int fd);
+ void (*parse_fromlogin_account_reg2) (int fd);
+ void (*parse_fromlogin_ban) (int fd);
+ void (*parse_fromlogin_kick) (int fd);
+ void (*update_ip) (int fd);
+ void (*parse_fromlogin_update_ip) (int fd);
+ void (*parse_fromlogin_accinfo2_failed) (int fd);
+ void (*parse_fromlogin_accinfo2_ok) (int fd);
+ int (*parse_fromlogin) (int fd);
+ int (*request_accreg2) (int account_id, int char_id);
+ void (*global_accreg_to_login_start) (int account_id, int char_id);
+ void (*global_accreg_to_login_send) (void);
+ void (*global_accreg_to_login_add) (const char *key, unsigned int index, intptr_t val, bool is_string);
+ void (*read_fame_list) (void);
+ int (*send_fame_list) (int fd);
+ void (*update_fame_list) (int type, int index, int fame);
+ int (*loadName) (int char_id, char* name);
+ void (*parse_frommap_datasync) (int fd);
+ void (*parse_frommap_skillid2idx) (int fd);
+ void (*map_received_ok) (int fd);
+ void (*send_maps) (int fd, int id, int j);
+ void (*parse_frommap_map_names) (int fd, int id);
+ void (*send_scdata) (int fd, int aid, int cid);
+ void (*parse_frommap_request_scdata) (int fd);
+ void (*parse_frommap_set_users_count) (int fd, int id);
+ void (*parse_frommap_set_users) (int fd, int id);
+ void (*save_character_ack) (int fd, int aid, int cid);
+ void (*parse_frommap_save_character) (int fd, int id);
+ void (*select_ack) (int fd, int account_id, uint8 flag);
+ void (*parse_frommap_char_select_req) (int fd);
+ void (*change_map_server_ack) (int fd, uint8 *data, bool ok);
+ void (*parse_frommap_change_map_server) (int fd);
+ void (*parse_frommap_remove_friend) (int fd);
+ void (*char_name_ack) (int fd, int char_id);
+ void (*parse_frommap_char_name_request) (int fd);
+ void (*parse_frommap_change_email) (int fd);
+ void (*ban) (int account_id, int char_id, time_t *unban_time, short year, short month, short day, short hour, short minute, short second);
+ void (*unban) (int char_id, int *result);
+ void (*ask_name_ack) (int fd, int acc, const char* name, int type, int result);
+ void (*parse_frommap_change_account) (int fd);
+ void (*parse_frommap_fame_list) (int fd);
+ void (*parse_frommap_divorce_char) (int fd);
+ void (*parse_frommap_ragsrvinfo) (int fd);
+ void (*parse_frommap_set_char_offline) (int fd);
+ void (*parse_frommap_set_all_offline) (int fd, int id);
+ void (*parse_frommap_set_char_online) (int fd, int id);
+ void (*parse_frommap_build_fame_list) (int fd);
+ void (*parse_frommap_save_status_change_data) (int fd);
+ void (*send_pong) (int fd);
+ void (*parse_frommap_ping) (int fd);
+ void (*map_auth_ok) (int fd, int account_id, struct char_auth_node* node, struct mmo_charstatus* cd);
+ void (*map_auth_failed) (int fd, int account_id, int char_id, int login_id1, char sex, uint32 ip);
+ void (*parse_frommap_auth_request) (int fd, int id);
+ void (*parse_frommap_update_ip) (int fd, int id);
+ void (*parse_frommap_request_stats_report) (int fd);
+ void (*parse_frommap_scdata_update) (int fd);
+ void (*parse_frommap_scdata_delete) (int fd);
+ int (*parse_frommap) (int fd);
+ int (*search_mapserver) (unsigned short map, uint32 ip, uint16 port);
+ int (*mapif_init) (int fd);
+ int (*lan_subnetcheck) (uint32 ip);
+ void (*delete2_ack) (int fd, int char_id, uint32 result, time_t delete_date);
+ void (*delete2_accept_actual_ack) (int fd, int char_id, uint32 result);
+ void (*delete2_accept_ack) (int fd, int char_id, uint32 result);
+ void (*delete2_cancel_ack) (int fd, int char_id, uint32 result);
+ void (*delete2_req) (int fd, struct char_session_data* sd);
+ void (*delete2_accept) (int fd, struct char_session_data* sd);
+ void (*delete2_cancel) (int fd, struct char_session_data* sd);
+ void (*send_account_id) (int fd, int account_id);
+ void (*parse_char_connect) (int fd, struct char_session_data* sd, uint32 ipl);
+ void (*send_map_info) (int fd, int i, uint32 subnet_map_ip, struct mmo_charstatus *cd);
+ void (*send_wait_char_server) (int fd);
+ int (*search_default_maps_mapserver) (struct mmo_charstatus *cd);
+ void (*parse_char_select) (int fd, struct char_session_data* sd, uint32 ipl);
+ void (*creation_failed) (int fd, int result);
+ void (*creation_ok) (int fd, struct mmo_charstatus *char_dat);
+ void (*parse_char_create_new_char) (int fd, struct char_session_data* sd);
+ void (*delete_char_failed) (int fd, int flag);
+ void (*delete_char_ok) (int fd);
+ void (*parse_char_delete_char) (int fd, struct char_session_data* sd, unsigned short cmd);
+ void (*parse_char_ping) (int fd);
+ void (*allow_rename) (int fd, int flag);
+ void (*parse_char_rename_char) (int fd, struct char_session_data* sd);
+ void (*parse_char_rename_char2) (int fd, struct char_session_data* sd);
+ void (*rename_char_ack) (int fd, int flag);
+ void (*parse_char_rename_char_confirm) (int fd, struct char_session_data* sd);
+ void (*captcha_notsupported) (int fd);
+ void (*parse_char_request_captcha) (int fd);
+ void (*parse_char_check_captcha) (int fd);
+ void (*parse_char_delete2_req) (int fd, struct char_session_data* sd);
+ void (*parse_char_delete2_accept) (int fd, struct char_session_data* sd);
+ void (*parse_char_delete2_cancel) (int fd, struct char_session_data* sd);
+ void (*login_map_server_ack) (int fd, uint8 flag);
+ void (*parse_char_login_map_server) (int fd);
+ void (*parse_char_pincode_check) (int fd, struct char_session_data* sd);
+ void (*parse_char_pincode_window) (int fd, struct char_session_data* sd);
+ void (*parse_char_pincode_change) (int fd, struct char_session_data* sd);
+ void (*parse_char_pincode_first_pin) (int fd, struct char_session_data* sd);
+ void (*parse_char_request_chars) (int fd, struct char_session_data* sd);
+ void (*change_character_slot_ack) (int fd, bool ret);
+ void (*parse_char_move_character) (int fd, struct char_session_data* sd);
+ int (*parse_char_unknown_packet) (int fd, uint32 ipl);
+ int (*parse_char) (int fd);
+ int (*broadcast_user_count) (int tid, int64 tick, int id, intptr_t data);
+ int (*send_accounts_tologin_sub) (DBKey key, DBData *data, va_list ap);
+ int (*send_accounts_tologin) (int tid, int64 tick, int id, intptr_t data);
+ int (*check_connect_login_server) (int tid, int64 tick, int id, intptr_t data);
+ int (*online_data_cleanup_sub) (DBKey key, DBData *data, va_list ap);
+ int (*online_data_cleanup) (int tid, int64 tick, int id, intptr_t data);
+ int (*lan_config_read) (const char *lancfgName);
+ void (*sql_config_read) (const char* cfgName);
+ void (*config_dispatch) (char *w1, char *w2);
+ int (*config_read) (const char* cfgName);
+};
+
+struct char_interface *chr;
#endif /* COMMON_CHAR_H */
diff --git a/src/char/geoip.c b/src/char/geoip.c
new file mode 100644
index 000000000..4fe03ab07
--- /dev/null
+++ b/src/char/geoip.c
@@ -0,0 +1,187 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
+
+#define HERCULES_CORE
+
+#include "geoip.h"
+
+#include <errno.h>
+#include <stdio.h>
+#include <sys/stat.h> // for stat/lstat/fstat - [Dekamaster/Ultimate GM Tool]
+
+#include "../common/cbasetypes.h"
+#include "../common/malloc.h"
+#include "../common/showmsg.h"
+
+struct s_geoip geoip_data;
+
+struct geoip_interface geoip_s;
+
+/* [Dekamaster/Nightroad] */
+#define GEOIP_MAX_COUNTRIES 255
+#define GEOIP_STRUCTURE_INFO_MAX_SIZE 20
+#define GEOIP_COUNTRY_BEGIN 16776960
+
+const char * geoip_countryname[GEOIP_MAX_COUNTRIES] = {"Unknown","Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Netherlands Antilles",
+ "Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Azerbaijan","Bosnia and Herzegovina","Barbados",
+ "Bangladesh","Belgium","Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia",
+ "Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands","Congo, The Democratic Republic of the",
+ "Central African Republic","Congo","Switzerland","Cote D'Ivoire","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica",
+ "Cuba","Cape Verde","Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark","Dominica","Dominican Republic",
+ "Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji",
+ "Falkland Islands (Malvinas)","Micronesia, Federated States of","Faroe Islands","France","France, Metropolitan","Gabon","United Kingdom","Grenada","Georgia","French Guiana",
+ "Ghana","Gibraltar","Greenland","Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece","South Georgia and the South Sandwich Islands","Guatemala",
+ "Guam","Guinea-Bissau","Guyana","Hong Kong","Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary","Indonesia",
+ "Ireland","Israel","India","British Indian Ocean Territory","Iraq","Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan",
+ "Japan","Kenya","Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis","Korea, Democratic People's Republic of","Korea, Republic of","Kuwait",
+ "Cayman Islands","Kazakhstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein","Sri Lanka","Liberia","Lesotho","Lithuania",
+ "Luxembourg","Latvia","Libyan Arab Jamahiriya","Morocco","Monaco","Moldova, Republic of","Madagascar","Marshall Islands","Macedonia","Mali",
+ "Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique","Mauritania","Montserrat","Malta","Mauritius","Maldives",
+ "Malawi","Mexico","Malaysia","Mozambique","Namibia","New Caledonia","Niger","Norfolk Island","Nigeria","Nicaragua",
+ "Netherlands","Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru","French Polynesia",
+ "Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon","Pitcairn Islands","Puerto Rico","Palestinian Territory","Portugal","Palau",
+ "Paraguay","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia","Solomon Islands","Seychelles","Sudan",
+ "Sweden","Singapore","Saint Helena","Slovenia","Svalbard and Jan Mayen","Slovakia","Sierra Leone","San Marino","Senegal","Somalia","Suriname",
+ "Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland","Turks and Caicos Islands","Chad","French Southern Territories","Togo","Thailand",
+ "Tajikistan","Tokelau","Turkmenistan","Tunisia","Tonga","Timor-Leste","Turkey","Trinidad and Tobago","Tuvalu","Taiwan",
+ "Tanzania, United Republic of","Ukraine","Uganda","United States Minor Outlying Islands","United States","Uruguay","Uzbekistan","Holy See (Vatican City State)","Saint Vincent and the Grenadines","Venezuela",
+ "Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna","Samoa","Yemen","Mayotte","Serbia","South Africa",
+ "Zambia","Montenegro","Zimbabwe","Anonymous Proxy","Satellite Provider","Other","Aland Islands","Guernsey","Isle of Man","Jersey",
+ "Saint Barthelemy", "Saint Martin", "Bonaire, Saint Eustatius and Saba", "South Sudan"};
+
+/* [Dekamaster/Nightroad] */
+/* WHY NOT A DBMAP: There are millions of entries in GeoIP and it has its own algorithm to go quickly through them, a DBMap wouldn't be efficient */
+const char* geoip_getcountry(uint32 ipnum)
+{
+ int depth;
+ unsigned int x;
+ const unsigned char *buf;
+ unsigned int offset = 0;
+
+ if( geoip->data->active == false )
+ return geoip_countryname[0];
+
+ for (depth = 31; depth >= 0; depth--) {
+ buf = geoip->data->cache + (long)6 *offset;
+ if (ipnum & (1 << depth)) {
+ /* Take the right-hand branch */
+ x = (buf[3*1 + 0] << (0*8))
+ + (buf[3*1 + 1] << (1*8))
+ + (buf[3*1 + 2] << (2*8));
+ } else {
+ /* Take the left-hand branch */
+ x = (buf[3*0 + 0] << (0*8))
+ + (buf[3*0 + 1] << (1*8))
+ + (buf[3*0 + 2] << (2*8));
+ }
+ if (x >= GEOIP_COUNTRY_BEGIN) {
+ x = x-GEOIP_COUNTRY_BEGIN;
+
+ if( x > GEOIP_MAX_COUNTRIES )
+ return geoip_countryname[0];
+
+ return geoip_countryname[x];
+ }
+ offset = x;
+ }
+ ShowError("geoip_getcountry(): Error traversing database for ipnum %d\n", ipnum);
+ ShowWarning("geoip_getcountry(): Possible database corruption!\n");
+
+ return geoip_countryname[0];
+}
+
+/**
+ * Disables GeoIP
+ * frees geoip.cache
+ **/
+void geoip_final(bool shutdown)
+{
+ if (geoip->data->cache) {
+ aFree(geoip->data->cache);
+ geoip->data->cache = NULL;
+ }
+
+ if (geoip->data->active) {
+ if (!shutdown)
+ ShowStatus("GeoIP "CL_RED"disabled"CL_RESET".\n");
+ geoip->data->active = false;
+ }
+}
+
+/**
+ * Reads GeoIP database and stores it into memory
+ * geoip.cache should be freed after use!
+ * http://dev.maxmind.com/geoip/legacy/geolite/
+ **/
+void geoip_init(void)
+{
+ int i, fno;
+ char db_type = 1;
+ unsigned char delim[3];
+ struct stat bufa;
+ FILE *db;
+
+ geoip->data->active = true;
+
+ db = fopen("./db/GeoIP.dat","rb");
+ if (db == NULL) {
+ ShowError("geoip_readdb: Error reading GeoIP.dat!\n");
+ geoip->final(false);
+ return;
+ }
+ fno = fileno(db);
+ if (fstat(fno, &bufa) < 0) {
+ ShowError("geoip_readdb: Error stating GeoIP.dat! Error %d\n", errno);
+ geoip->final(false);
+ return;
+ }
+ geoip->data->cache = aMalloc( (sizeof(geoip->data->cache) * bufa.st_size) );
+ if (fread(geoip->data->cache, sizeof(unsigned char), bufa.st_size, db) != bufa.st_size) {
+ ShowError("geoip_cache: Couldn't read all elements!\n");
+ fclose(db);
+ geoip->final(false);
+ return;
+ }
+
+ // Search database type
+ fseek(db, -3l, SEEK_END);
+ for (i = 0; i < GEOIP_STRUCTURE_INFO_MAX_SIZE; i++) {
+ if (fread(delim, sizeof(delim[0]), 3, db) != 3) {
+ db_type = 0;
+ break;
+ }
+ if (delim[0] == 255 && delim[1] == 255 && delim[2] == 255) {
+ if (fread(&db_type, sizeof(db_type), 1, db) != 1) {
+ db_type = 0;
+ }
+ break;
+ } else {
+ fseek(db, -4l, SEEK_CUR);
+ }
+ }
+
+ fclose(db);
+
+ if (db_type != 1) {
+ if (db_type)
+ ShowError("geoip_init(): Database type is not supported %d!\n", db_type);
+ else
+ ShowError("geoip_init(): GeoIP is corrupted!\n");
+
+ geoip->final(false);
+ return;
+ }
+ ShowStatus("Finished Reading "CL_GREEN"GeoIP"CL_RESET" Database.\n");
+}
+
+void geoip_defaults(void)
+{
+ geoip = &geoip_s;
+
+ geoip->data = &geoip_data;
+
+ geoip->getcountry = geoip_getcountry;
+ geoip->final = geoip_final;
+ geoip->init = geoip_init;
+}
diff --git a/src/char/geoip.h b/src/char/geoip.h
new file mode 100644
index 000000000..8cad2f73b
--- /dev/null
+++ b/src/char/geoip.h
@@ -0,0 +1,32 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
+
+#ifndef CHAR_GEOIP_H
+#define CHAR_GEOIP_H
+
+#include "../common/cbasetypes.h"
+
+/**
+ * GeoIP information
+ **/
+struct s_geoip {
+ unsigned char *cache; // GeoIP.dat information see geoip->init()
+ bool active;
+};
+
+/**
+ * geoip interface
+ **/
+struct geoip_interface {
+ struct s_geoip *data;
+ const char* (*getcountry) (uint32 ipnum);
+ void (*final) (bool shutdown);
+ void (*init) (void);
+};
+
+struct geoip_interface *geoip;
+
+void geoip_defaults(void);
+
+#endif /* CHAR_GEOIP_H */
diff --git a/src/char/int_auction.c b/src/char/int_auction.c
index ddfef68c2..e28240ca6 100644
--- a/src/char/int_auction.c
+++ b/src/char/int_auction.c
@@ -13,6 +13,7 @@
#include "char.h"
#include "int_mail.h"
#include "inter.h"
+#include "mapif.h"
#include "../common/db.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
@@ -22,16 +23,13 @@
#include "../common/strlib.h"
#include "../common/timer.h"
-static DBMap* auction_db_ = NULL; // int auction_id -> struct auction_data*
+struct inter_auction_interface inter_auction_s;
-void auction_delete(struct auction_data *auction);
-static int auction_end_timer(int tid, int64 tick, int id, intptr_t data);
-
-static int auction_count(int char_id, bool buy)
+static int inter_auction_count(int char_id, bool buy)
{
int i = 0;
struct auction_data *auction;
- DBIterator *iter = db_iterator(auction_db_);
+ DBIterator *iter = db_iterator(inter_auction->db);
for( auction = dbi_first(iter); dbi_exists(iter); auction = dbi_next(iter) )
{
@@ -43,7 +41,7 @@ static int auction_count(int char_id, bool buy)
return i;
}
-void auction_save(struct auction_data *auction)
+void inter_auction_save(struct auction_data *auction)
{
int j;
StringBuf buf;
@@ -59,7 +57,7 @@ void auction_save(struct auction_data *auction)
StrBuf->Printf(&buf, ", `card%d` = '%d'", j, auction->item.card[j]);
StrBuf->Printf(&buf, " WHERE `auction_id` = '%d'", auction->auction_id);
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_SUCCESS != SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, auction->seller_name, strnlen(auction->seller_name, NAME_LENGTH))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, auction->buyer_name, strnlen(auction->buyer_name, NAME_LENGTH))
@@ -73,7 +71,7 @@ void auction_save(struct auction_data *auction)
StrBuf->Destroy(&buf);
}
-unsigned int auction_create(struct auction_data *auction)
+unsigned int inter_auction_create(struct auction_data *auction)
{
int j;
StringBuf buf;
@@ -94,7 +92,7 @@ unsigned int auction_create(struct auction_data *auction)
StrBuf->Printf(&buf, ",'%d'", auction->item.card[j]);
StrBuf->AppendStr(&buf, ")");
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_SUCCESS != SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, auction->seller_name, strnlen(auction->seller_name, NAME_LENGTH))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, auction->buyer_name, strnlen(auction->buyer_name, NAME_LENGTH))
@@ -114,12 +112,12 @@ unsigned int auction_create(struct auction_data *auction)
auction->item.expire_time = 0;
auction->auction_id = (unsigned int)SQL->StmtLastInsertId(stmt);
- auction->auction_end_timer = timer->add( timer->gettick() + tick , auction_end_timer, auction->auction_id, 0);
+ auction->auction_end_timer = timer->add( timer->gettick() + tick , inter_auction->end_timer, auction->auction_id, 0);
ShowInfo("New Auction %u | time left %"PRId64" ms | By %s.\n", auction->auction_id, tick, auction->seller_name);
CREATE(auction_, struct auction_data, 1);
memcpy(auction_, auction, sizeof(struct auction_data));
- idb_put(auction_db_, auction_->auction_id, auction_);
+ idb_put(inter_auction->db, auction_->auction_id, auction_);
}
SQL->StmtFree(stmt);
@@ -128,49 +126,49 @@ unsigned int auction_create(struct auction_data *auction)
return auction->auction_id;
}
-static void mapif_Auction_message(int char_id, unsigned char result)
+void mapif_auction_message(int char_id, unsigned char result)
{
unsigned char buf[74];
-
+
WBUFW(buf,0) = 0x3854;
WBUFL(buf,2) = char_id;
WBUFL(buf,6) = result;
- mapif_sendall(buf,7);
+ mapif->sendall(buf,7);
}
-static int auction_end_timer(int tid, int64 tick, int id, intptr_t data) {
+static int inter_auction_end_timer(int tid, int64 tick, int id, intptr_t data) {
struct auction_data *auction;
- if( (auction = (struct auction_data *)idb_get(auction_db_, id)) != NULL )
+ if( (auction = (struct auction_data *)idb_get(inter_auction->db, id)) != NULL )
{
if( auction->buyer_id )
{
- mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Thanks, you won the auction!.", 0, &auction->item);
- mapif_Auction_message(auction->buyer_id, 6); // You have won the auction
- mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Payment for your auction!.", auction->price, NULL);
+ inter_mail->sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Thanks, you won the auction!.", 0, &auction->item);
+ mapif->auction_message(auction->buyer_id, 6); // You have won the auction
+ inter_mail->sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Payment for your auction!.", auction->price, NULL);
}
else
- mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "No buyers have been found for your auction.", 0, &auction->item);
-
+ inter_mail->sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "No buyers have been found for your auction.", 0, &auction->item);
+
ShowInfo("Auction End: id %u.\n", auction->auction_id);
auction->auction_end_timer = INVALID_TIMER;
- auction_delete(auction);
+ inter_auction->delete_(auction);
}
return 0;
}
-void auction_delete(struct auction_data *auction)
+void inter_auction_delete(struct auction_data *auction)
{
unsigned int auction_id = auction->auction_id;
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `auction_id` = '%d'", auction_db, auction_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `auction_id` = '%d'", auction_db, auction_id) )
+ Sql_ShowDebug(inter->sql_handle);
if( auction->auction_end_timer != INVALID_TIMER )
- timer->delete(auction->auction_end_timer, auction_end_timer);
+ timer->delete(auction->auction_end_timer, inter_auction->end_timer);
- idb_remove(auction_db_, auction_id);
+ idb_remove(inter_auction->db, auction_id);
}
void inter_auctions_fromsql(void)
@@ -190,32 +188,32 @@ void inter_auctions_fromsql(void)
StrBuf->Printf(&buf, ",`card%d`", i);
StrBuf->Printf(&buf, " FROM `%s` ORDER BY `auction_id` DESC", auction_db);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)) )
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
- while( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ while( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
CREATE(auction, struct auction_data, 1);
- SQL->GetData(sql_handle, 0, &data, NULL); auction->auction_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); auction->seller_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); safestrncpy(auction->seller_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 3, &data, NULL); auction->buyer_id = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); safestrncpy(auction->buyer_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 5, &data, NULL); auction->price = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); auction->buynow = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); auction->hours = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); auction->timestamp = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); auction->auction_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); auction->seller_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); safestrncpy(auction->seller_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); auction->buyer_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); safestrncpy(auction->buyer_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); auction->price = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); auction->buynow = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); auction->hours = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); auction->timestamp = atoi(data);
item = &auction->item;
- SQL->GetData(sql_handle, 9, &data, NULL); item->nameid = atoi(data);
- SQL->GetData(sql_handle,10, &data, NULL); safestrncpy(auction->item_name, data, ITEM_NAME_LENGTH);
- SQL->GetData(sql_handle,11, &data, NULL); auction->type = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); item->nameid = atoi(data);
+ SQL->GetData(inter->sql_handle,10, &data, NULL); safestrncpy(auction->item_name, data, ITEM_NAME_LENGTH);
+ SQL->GetData(inter->sql_handle,11, &data, NULL); auction->type = atoi(data);
- SQL->GetData(sql_handle,12, &data, NULL); item->refine = atoi(data);
- SQL->GetData(sql_handle,13, &data, NULL); item->attribute = atoi(data);
- SQL->GetData(sql_handle,14, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle,12, &data, NULL); item->refine = atoi(data);
+ SQL->GetData(inter->sql_handle,13, &data, NULL); item->attribute = atoi(data);
+ SQL->GetData(inter->sql_handle,14, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
item->identify = 1;
item->amount = 1;
@@ -223,7 +221,7 @@ void inter_auctions_fromsql(void)
for( i = 0; i < MAX_SLOTS; i++ )
{
- SQL->GetData(sql_handle, 15 + i, &data, NULL);
+ SQL->GetData(inter->sql_handle, 15 + i, &data, NULL);
item->card[i] = atoi(data);
}
@@ -232,14 +230,14 @@ void inter_auctions_fromsql(void)
else
endtick = tick + 10000; // 10 seconds to process ended auctions
- auction->auction_end_timer = timer->add(endtick, auction_end_timer, auction->auction_id, 0);
- idb_put(auction_db_, auction->auction_id, auction);
+ auction->auction_end_timer = timer->add(endtick, inter_auction->end_timer, auction->auction_id, 0);
+ idb_put(inter_auction->db, auction->auction_id, auction);
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
-static void mapif_Auction_sendlist(int fd, int char_id, short count, short pages, unsigned char *buf)
+void mapif_auction_sendlist(int fd, int char_id, short count, short pages, unsigned char *buf)
{
int len = (sizeof(struct auction_data) * count) + 12;
@@ -253,14 +251,14 @@ static void mapif_Auction_sendlist(int fd, int char_id, short count, short pages
WFIFOSET(fd,len);
}
-static void mapif_parse_Auction_requestlist(int fd)
+void mapif_parse_auction_requestlist(int fd)
{
char searchtext[NAME_LENGTH];
int char_id = RFIFOL(fd,4), len = sizeof(struct auction_data);
int price = RFIFOL(fd,10);
short type = RFIFOW(fd,8), page = max(1,RFIFOW(fd,14));
unsigned char buf[5 * sizeof(struct auction_data)];
- DBIterator *iter = db_iterator(auction_db_);
+ DBIterator *iter = db_iterator(inter_auction->db);
struct auction_data *auction;
short i = 0, j = 0, pages = 1;
@@ -293,10 +291,10 @@ static void mapif_parse_Auction_requestlist(int fd)
}
dbi_destroy(iter);
- mapif_Auction_sendlist(fd, char_id, j, pages, buf);
+ mapif->auction_sendlist(fd, char_id, j, pages, buf);
}
-static void mapif_Auction_register(int fd, struct auction_data *auction)
+void mapif_auction_register(int fd, struct auction_data *auction)
{
int len = sizeof(struct auction_data) + 4;
@@ -307,20 +305,20 @@ static void mapif_Auction_register(int fd, struct auction_data *auction)
WFIFOSET(fd,len);
}
-static void mapif_parse_Auction_register(int fd)
+void mapif_parse_auction_register(int fd)
{
struct auction_data auction;
if( RFIFOW(fd,2) != sizeof(struct auction_data) + 4 )
return;
memcpy(&auction, RFIFOP(fd,4), sizeof(struct auction_data));
- if( auction_count(auction.seller_id, false) < 5 )
- auction.auction_id = auction_create(&auction);
+ if( inter_auction->count(auction.seller_id, false) < 5 )
+ auction.auction_id = inter_auction->create(&auction);
- mapif_Auction_register(fd, &auction);
+ mapif->auction_register(fd, &auction);
}
-static void mapif_Auction_cancel(int fd, int char_id, unsigned char result)
+void mapif_auction_cancel(int fd, int char_id, unsigned char result)
{
WFIFOHEAD(fd,7);
WFIFOW(fd,0) = 0x3852;
@@ -329,36 +327,36 @@ static void mapif_Auction_cancel(int fd, int char_id, unsigned char result)
WFIFOSET(fd,7);
}
-static void mapif_parse_Auction_cancel(int fd)
+void mapif_parse_auction_cancel(int fd)
{
int char_id = RFIFOL(fd,2), auction_id = RFIFOL(fd,6);
struct auction_data *auction;
- if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL )
+ if( (auction = (struct auction_data *)idb_get(inter_auction->db, auction_id)) == NULL )
{
- mapif_Auction_cancel(fd, char_id, 1); // Bid Number is Incorrect
+ mapif->auction_cancel(fd, char_id, 1); // Bid Number is Incorrect
return;
}
if( auction->seller_id != char_id )
{
- mapif_Auction_cancel(fd, char_id, 2); // You cannot end the auction
+ mapif->auction_cancel(fd, char_id, 2); // You cannot end the auction
return;
}
if( auction->buyer_id > 0 )
{
- mapif_Auction_cancel(fd, char_id, 3); // An auction with at least one bidder cannot be canceled
+ mapif->auction_cancel(fd, char_id, 3); // An auction with at least one bidder cannot be canceled
return;
}
- mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Auction canceled.", 0, &auction->item);
- auction_delete(auction);
+ inter_mail->sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Auction canceled.", 0, &auction->item);
+ inter_auction->delete_(auction);
- mapif_Auction_cancel(fd, char_id, 0); // The auction has been canceled
+ mapif->auction_cancel(fd, char_id, 0); // The auction has been canceled
}
-static void mapif_Auction_close(int fd, int char_id, unsigned char result)
+void mapif_auction_close(int fd, int char_id, unsigned char result)
{
WFIFOHEAD(fd,7);
WFIFOW(fd,0) = 0x3853;
@@ -367,40 +365,40 @@ static void mapif_Auction_close(int fd, int char_id, unsigned char result)
WFIFOSET(fd,7);
}
-static void mapif_parse_Auction_close(int fd)
+void mapif_parse_auction_close(int fd)
{
int char_id = RFIFOL(fd,2), auction_id = RFIFOL(fd,6);
struct auction_data *auction;
- if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL )
+ if( (auction = (struct auction_data *)idb_get(inter_auction->db, auction_id)) == NULL )
{
- mapif_Auction_close(fd, char_id, 2); // Bid Number is Incorrect
+ mapif->auction_close(fd, char_id, 2); // Bid Number is Incorrect
return;
}
if( auction->seller_id != char_id )
{
- mapif_Auction_close(fd, char_id, 1); // You cannot end the auction
+ mapif->auction_close(fd, char_id, 1); // You cannot end the auction
return;
}
if( auction->buyer_id == 0 )
{
- mapif_Auction_close(fd, char_id, 1); // You cannot end the auction
+ mapif->auction_close(fd, char_id, 1); // You cannot end the auction
return;
}
// Send Money to Seller
- mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Auction closed.", auction->price, NULL);
+ inter_mail->sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Auction closed.", auction->price, NULL);
// Send Item to Buyer
- mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Auction winner.", 0, &auction->item);
- mapif_Auction_message(auction->buyer_id, 6); // You have won the auction
- auction_delete(auction);
+ inter_mail->sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Auction winner.", 0, &auction->item);
+ mapif->auction_message(auction->buyer_id, 6); // You have won the auction
+ inter_auction->delete_(auction);
- mapif_Auction_close(fd, char_id, 0); // You have ended the auction
+ mapif->auction_close(fd, char_id, 0); // You have ended the auction
}
-static void mapif_Auction_bid(int fd, int char_id, int bid, unsigned char result)
+void mapif_auction_bid(int fd, int char_id, int bid, unsigned char result)
{
WFIFOHEAD(fd,11);
WFIFOW(fd,0) = 0x3855;
@@ -410,21 +408,21 @@ static void mapif_Auction_bid(int fd, int char_id, int bid, unsigned char result
WFIFOSET(fd,11);
}
-static void mapif_parse_Auction_bid(int fd)
+void mapif_parse_auction_bid(int fd)
{
int char_id = RFIFOL(fd,4), bid = RFIFOL(fd,12);
unsigned int auction_id = RFIFOL(fd,8);
struct auction_data *auction;
- if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL || auction->price >= bid || auction->seller_id == char_id )
+ if( (auction = (struct auction_data *)idb_get(inter_auction->db, auction_id)) == NULL || auction->price >= bid || auction->seller_id == char_id )
{
- mapif_Auction_bid(fd, char_id, bid, 0); // You have failed to bid in the auction
+ mapif->auction_bid(fd, char_id, bid, 0); // You have failed to bid in the auction
return;
}
- if( auction_count(char_id, true) > 4 && bid < auction->buynow && auction->buyer_id != char_id )
+ if( inter_auction->count(char_id, true) > 4 && bid < auction->buynow && auction->buyer_id != char_id )
{
- mapif_Auction_bid(fd, char_id, bid, 9); // You cannot place more than 5 bids at a time
+ mapif->auction_bid(fd, char_id, bid, 9); // You cannot place more than 5 bids at a time
return;
}
@@ -432,11 +430,11 @@ static void mapif_parse_Auction_bid(int fd)
{ // Send Money back to the previous Buyer
if( auction->buyer_id != char_id )
{
- mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Someone has placed a higher bid.", auction->price, NULL);
- mapif_Auction_message(auction->buyer_id, 7); // You have failed to win the auction
+ inter_mail->sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Someone has placed a higher bid.", auction->price, NULL);
+ mapif->auction_message(auction->buyer_id, 7); // You have failed to win the auction
}
else
- mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "You have placed a higher bid.", auction->price, NULL);
+ inter_mail->sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "You have placed a higher bid.", auction->price, NULL);
}
auction->buyer_id = char_id;
@@ -445,19 +443,19 @@ static void mapif_parse_Auction_bid(int fd)
if( bid >= auction->buynow )
{ // Automatic won the auction
- mapif_Auction_bid(fd, char_id, bid - auction->buynow, 1); // You have successfully bid in the auction
+ mapif->auction_bid(fd, char_id, bid - auction->buynow, 1); // You have successfully bid in the auction
- mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "You have won the auction.", 0, &auction->item);
- mapif_Auction_message(char_id, 6); // You have won the auction
- mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Payment for your auction!.", auction->buynow, NULL);
+ inter_mail->sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "You have won the auction.", 0, &auction->item);
+ mapif->auction_message(char_id, 6); // You have won the auction
+ inter_mail->sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Payment for your auction!.", auction->buynow, NULL);
- auction_delete(auction);
+ inter_auction->delete_(auction);
return;
}
- auction_save(auction);
+ inter_auction->save(auction);
- mapif_Auction_bid(fd, char_id, 0, 1); // You have successfully bid in the auction
+ mapif->auction_bid(fd, char_id, 0, 1); // You have successfully bid in the auction
}
/*==========================================
@@ -467,11 +465,11 @@ int inter_auction_parse_frommap(int fd)
{
switch(RFIFOW(fd,0))
{
- case 0x3050: mapif_parse_Auction_requestlist(fd); break;
- case 0x3051: mapif_parse_Auction_register(fd); break;
- case 0x3052: mapif_parse_Auction_cancel(fd); break;
- case 0x3053: mapif_parse_Auction_close(fd); break;
- case 0x3055: mapif_parse_Auction_bid(fd); break;
+ case 0x3050: mapif->parse_auction_requestlist(fd); break;
+ case 0x3051: mapif->parse_auction_register(fd); break;
+ case 0x3052: mapif->parse_auction_cancel(fd); break;
+ case 0x3053: mapif->parse_auction_close(fd); break;
+ case 0x3055: mapif->parse_auction_bid(fd); break;
default:
return 0;
}
@@ -480,15 +478,32 @@ int inter_auction_parse_frommap(int fd)
int inter_auction_sql_init(void)
{
- auction_db_ = idb_alloc(DB_OPT_RELEASE_DATA);
- inter_auctions_fromsql();
+ inter_auction->db = idb_alloc(DB_OPT_RELEASE_DATA);
+ inter_auction->fromsql();
return 0;
}
void inter_auction_sql_final(void)
{
- auction_db_->destroy(auction_db_,NULL);
+ inter_auction->db->destroy(inter_auction->db,NULL);
return;
}
+
+void inter_auction_defaults(void)
+{
+ inter_auction = &inter_auction_s;
+
+ inter_auction->db = NULL; // int auction_id -> struct auction_data*
+
+ inter_auction->count = inter_auction_count;
+ inter_auction->save = inter_auction_save;
+ inter_auction->create = inter_auction_create;
+ inter_auction->end_timer = inter_auction_end_timer;
+ inter_auction->delete_ = inter_auction_delete;
+ inter_auction->fromsql = inter_auctions_fromsql;
+ inter_auction->parse_frommap = inter_auction_parse_frommap;
+ inter_auction->sql_init = inter_auction_sql_init;
+ inter_auction->sql_final = inter_auction_sql_final;
+}
diff --git a/src/char/int_auction.h b/src/char/int_auction.h
index 17fd75a58..ad8ac7b67 100644
--- a/src/char/int_auction.h
+++ b/src/char/int_auction.h
@@ -4,9 +4,26 @@
#ifndef CHAR_INT_AUCTION_H
#define CHAR_INT_AUCTION_H
-int inter_auction_parse_frommap(int fd);
+#include "../common/mmo.h"
-int inter_auction_sql_init(void);
-void inter_auction_sql_final(void);
+void inter_auction_defaults(void);
+
+/**
+ * inter_auction_interface interface
+ **/
+struct inter_auction_interface {
+ DBMap* db; // int auction_id -> struct auction_data*
+ int (*count) (int char_id, bool buy);
+ void (*save) (struct auction_data *auction);
+ unsigned int (*create) (struct auction_data *auction);
+ int (*end_timer) (int tid, int64 tick, int id, intptr_t data);
+ void (*delete_) (struct auction_data *auction);
+ void (*fromsql) (void);
+ int (*parse_frommap) (int fd);
+ int (*sql_init) (void);
+ void (*sql_final) (void);
+};
+
+struct inter_auction_interface *inter_auction;
#endif /* CHAR_INT_AUCTION_H */
diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c
index 3a36e75a2..d14d1e1e0 100644
--- a/src/char/int_elemental.c
+++ b/src/char/int_elemental.c
@@ -12,6 +12,7 @@
#include "char.h"
#include "inter.h"
+#include "mapif.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/showmsg.h"
@@ -20,28 +21,30 @@
#include "../common/strlib.h"
#include "../common/utils.h"
+struct inter_elemental_interface inter_elemental_s;
+
bool mapif_elemental_save(struct s_elemental* ele) {
bool flag = true;
-
+
if( ele->elemental_id == 0 ) { // Create new DB entry
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"INSERT INTO `%s` (`char_id`,`class`,`mode`,`hp`,`sp`,`max_hp`,`max_sp`,`atk1`,`atk2`,`matk`,`aspd`,`def`,`mdef`,`flee`,`hit`,`life_time`)"
"VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%u')",
elemental_db, ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2, ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
flag = false;
}
else
- ele->elemental_id = (int)SQL->LastInsertId(sql_handle);
- } else if( SQL_ERROR == SQL->Query(sql_handle,
+ ele->elemental_id = (int)SQL->LastInsertId(inter->sql_handle);
+ } else if( SQL_ERROR == SQL->Query(inter->sql_handle,
"UPDATE `%s` SET `char_id` = '%d', `class` = '%d', `mode` = '%d', `hp` = '%d', `sp` = '%d',"
"`max_hp` = '%d', `max_sp` = '%d', `atk1` = '%d', `atk2` = '%d', `matk` = '%d', `aspd` = '%d', `def` = '%d',"
"`mdef` = '%d', `flee` = '%d', `hit` = '%d', `life_time` = '%u' WHERE `ele_id` = '%d'",
elemental_db, ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2,
ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time, ele->elemental_id) )
{ // Update DB entry
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
flag = false;
}
return flag;
@@ -49,59 +52,59 @@ bool mapif_elemental_save(struct s_elemental* ele) {
bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) {
char* data;
-
+
memset(ele, 0, sizeof(struct s_elemental));
ele->elemental_id = ele_id;
ele->char_id = char_id;
-
- if( SQL_ERROR == SQL->Query(sql_handle,
+
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"SELECT `class`, `mode`, `hp`, `sp`, `max_hp`, `max_sp`, `atk1`, `atk2`, `matk`, `aspd`,"
"`def`, `mdef`, `flee`, `hit`, `life_time` FROM `%s` WHERE `ele_id` = '%d' AND `char_id` = '%d'",
elemental_db, ele_id, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
-
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) ) {
- SQL->FreeResult(sql_handle);
+
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) ) {
+ SQL->FreeResult(inter->sql_handle);
return false;
}
-
- SQL->GetData(sql_handle, 0, &data, NULL); ele->class_ = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); ele->mode = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); ele->hp = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); ele->sp = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); ele->max_hp = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); ele->max_sp = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); ele->atk = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); ele->atk2 = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); ele->matk = atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); ele->amotion = atoi(data);
- SQL->GetData(sql_handle, 10, &data, NULL); ele->def = atoi(data);
- SQL->GetData(sql_handle, 11, &data, NULL); ele->mdef = atoi(data);
- SQL->GetData(sql_handle, 12, &data, NULL); ele->flee = atoi(data);
- SQL->GetData(sql_handle, 13, &data, NULL); ele->hit = atoi(data);
- SQL->GetData(sql_handle, 14, &data, NULL); ele->life_time = atoi(data);
- SQL->FreeResult(sql_handle);
+
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); ele->class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); ele->mode = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); ele->hp = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); ele->sp = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); ele->max_hp = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); ele->max_sp = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); ele->atk = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); ele->atk2 = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); ele->matk = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); ele->amotion = atoi(data);
+ SQL->GetData(inter->sql_handle, 10, &data, NULL); ele->def = atoi(data);
+ SQL->GetData(inter->sql_handle, 11, &data, NULL); ele->mdef = atoi(data);
+ SQL->GetData(inter->sql_handle, 12, &data, NULL); ele->flee = atoi(data);
+ SQL->GetData(inter->sql_handle, 13, &data, NULL); ele->hit = atoi(data);
+ SQL->GetData(inter->sql_handle, 14, &data, NULL); ele->life_time = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
if( save_log )
ShowInfo("Elemental loaded (%d - %d).\n", ele->elemental_id, ele->char_id);
-
+
return true;
}
bool mapif_elemental_delete(int ele_id) {
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `ele_id` = '%d'", elemental_db, ele_id) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `ele_id` = '%d'", elemental_db, ele_id) ) {
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
-
+
return true;
}
-static void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) {
+void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) {
int size = sizeof(struct s_elemental) + 5;
-
+
WFIFOHEAD(fd,size);
WFIFOW(fd,0) = 0x387c;
WFIFOW(fd,2) = size;
@@ -110,44 +113,45 @@ static void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char
WFIFOSET(fd,size);
}
-static void mapif_parse_elemental_create(int fd, struct s_elemental* ele) {
- bool result = mapif_elemental_save(ele);
- mapif_elemental_send(fd, ele, result);
+void mapif_parse_elemental_create(int fd, struct s_elemental* ele) {
+ bool result = mapif->elemental_save(ele);
+ mapif->elemental_send(fd, ele, result);
}
-static void mapif_parse_elemental_load(int fd, int ele_id, int char_id) {
+void mapif_parse_elemental_load(int fd, int ele_id, int char_id) {
struct s_elemental ele;
- bool result = mapif_elemental_load(ele_id, char_id, &ele);
- mapif_elemental_send(fd, &ele, result);
+ bool result = mapif->elemental_load(ele_id, char_id, &ele);
+ mapif->elemental_send(fd, &ele, result);
}
-static void mapif_elemental_deleted(int fd, unsigned char flag) {
+void mapif_elemental_deleted(int fd, unsigned char flag) {
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x387d;
WFIFOB(fd,2) = flag;
WFIFOSET(fd,3);
}
-static void mapif_parse_elemental_delete(int fd, int ele_id) {
- bool result = mapif_elemental_delete(ele_id);
- mapif_elemental_deleted(fd, result);
+void mapif_parse_elemental_delete(int fd, int ele_id) {
+ bool result = mapif->elemental_delete(ele_id);
+ mapif->elemental_deleted(fd, result);
}
-static void mapif_elemental_saved(int fd, unsigned char flag) {
+void mapif_elemental_saved(int fd, unsigned char flag) {
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x387e;
WFIFOB(fd,2) = flag;
WFIFOSET(fd,3);
}
-static void mapif_parse_elemental_save(int fd, struct s_elemental* ele) {
- bool result = mapif_elemental_save(ele);
- mapif_elemental_saved(fd, result);
+void mapif_parse_elemental_save(int fd, struct s_elemental* ele) {
+ bool result = mapif->elemental_save(ele);
+ mapif->elemental_saved(fd, result);
}
void inter_elemental_sql_init(void) {
return;
}
+
void inter_elemental_sql_final(void) {
return;
}
@@ -157,14 +161,23 @@ void inter_elemental_sql_final(void) {
*------------------------------------------*/
int inter_elemental_parse_frommap(int fd) {
unsigned short cmd = RFIFOW(fd,0);
-
+
switch( cmd ) {
- case 0x307c: mapif_parse_elemental_create(fd, (struct s_elemental*)RFIFOP(fd,4)); break;
- case 0x307d: mapif_parse_elemental_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
- case 0x307e: mapif_parse_elemental_delete(fd, (int)RFIFOL(fd,2)); break;
- case 0x307f: mapif_parse_elemental_save(fd, (struct s_elemental*)RFIFOP(fd,4)); break;
+ case 0x307c: mapif->parse_elemental_create(fd, (struct s_elemental*)RFIFOP(fd,4)); break;
+ case 0x307d: mapif->parse_elemental_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
+ case 0x307e: mapif->parse_elemental_delete(fd, (int)RFIFOL(fd,2)); break;
+ case 0x307f: mapif->parse_elemental_save(fd, (struct s_elemental*)RFIFOP(fd,4)); break;
default:
return 0;
}
return 1;
}
+
+void inter_elemental_defaults(void)
+{
+ inter_elemental = &inter_elemental_s;
+
+ inter_elemental->sql_init = inter_elemental_sql_init;
+ inter_elemental->sql_final = inter_elemental_sql_final;
+ inter_elemental->parse_frommap = inter_elemental_parse_frommap;
+}
diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h
index e28cfedea..611d97550 100644
--- a/src/char/int_elemental.h
+++ b/src/char/int_elemental.h
@@ -6,10 +6,17 @@
#include "../common/cbasetypes.h"
-void inter_elemental_sql_init(void);
-void inter_elemental_sql_final(void);
-int inter_elemental_parse_frommap(int fd);
+void inter_elemental_defaults(void);
-bool mapif_elemental_delete(int ele_id);
+/**
+ * inter_elemental_interface interface
+ **/
+struct inter_elemental_interface {
+ void (*sql_init) (void);
+ void (*sql_final) (void);
+ int (*parse_frommap) (int fd);
+};
+
+struct inter_elemental_interface *inter_elemental;
#endif /* CHAR_INT_ELEMENTAL_H */
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index a6fcfe48c..a5623f83d 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -13,6 +13,7 @@
#include "char.h"
#include "inter.h"
+#include "mapif.h"
#include "../common/cbasetypes.h"
#include "../common/db.h"
#include "../common/malloc.h"
@@ -33,26 +34,14 @@
#define GUILD_ALLIANCE_TYPE_MASK 0x01
#define GUILD_ALLIANCE_REMOVE 0x08
-static const char dataToHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
-
-//Guild cache
-static DBMap* guild_db_; // int guild_id -> struct guild*
-static DBMap *castle_db;
+struct inter_guild_interface inter_guild_s;
-static unsigned int guild_exp[MAX_GUILDLEVEL];
-
-int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int flag,const char *mes);
-int mapif_guild_broken(int guild_id,int flag);
-static bool guild_check_empty(struct guild *g);
-int guild_calcinfo(struct guild *g);
-int mapif_guild_basicinfochanged(int guild_id,int type,const void *data,int len);
-int mapif_guild_info(int fd,struct guild *g);
-int inter_guild_tosql(struct guild *g,int flag);
+static const char dataToHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
-static int guild_save_timer(int tid, int64 tick, int id, intptr_t data) {
+int inter_guild_save_timer(int tid, int64 tick, int id, intptr_t data) {
static int last_id = 0; //To know in which guild we were.
int state = 0; //0: Have not reached last guild. 1: Reached last guild, ready for save. 2: Some guild saved, don't do further saving.
- DBIterator *iter = db_iterator(guild_db_);
+ DBIterator *iter = db_iterator(inter_guild->guild_db);
DBKey key;
struct guild* g;
@@ -66,7 +55,7 @@ static int guild_save_timer(int tid, int64 tick, int id, intptr_t data) {
else
if( state == 1 && g->save_flag&GS_MASK )
{
- inter_guild_tosql(g, g->save_flag&GS_MASK);
+ inter_guild->tosql(g, g->save_flag&GS_MASK);
g->save_flag &= ~GS_MASK;
//Some guild saved.
@@ -78,7 +67,7 @@ static int guild_save_timer(int tid, int64 tick, int id, intptr_t data) {
{// Nothing to save, guild is ready for removal.
if (save_log)
ShowInfo("Guild Unloaded (%d - %s)\n", g->guild_id, g->name);
- db_remove(guild_db_, key);
+ db_remove(inter_guild->guild_db, key);
}
}
dbi_destroy(iter);
@@ -86,18 +75,18 @@ static int guild_save_timer(int tid, int64 tick, int id, intptr_t data) {
if( state != 2 ) //Reached the end of the guild db without saving.
last_id = 0; //Reset guild saved, return to beginning.
- state = guild_db_->size(guild_db_);
+ state = inter_guild->guild_db->size(inter_guild->guild_db);
if( state < 1 ) state = 1; //Calculate the time slot for the next save.
- timer->add(tick + autosave_interval/state, guild_save_timer, 0, 0);
+ timer->add(tick + autosave_interval/state, inter_guild->save_timer, 0, 0);
return 0;
}
int inter_guild_removemember_tosql(int account_id, int char_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE from `%s` where `account_id` = '%d' and `char_id` = '%d'", guild_member_db, account_id, char_id) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `guild_id` = '0' WHERE `char_id` = '%d'", char_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE from `%s` where `account_id` = '%d' and `char_id` = '%d'", guild_member_db, account_id, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `guild_id` = '0' WHERE `char_id` = '%d'", char_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
@@ -131,8 +120,8 @@ int inter_guild_tosql(struct guild *g,int flag)
ShowInfo("Save guild request ("CL_BOLD"%d"CL_RESET" - flag 0x%x).",g->guild_id, flag);
#endif
- SQL->EscapeStringLen(sql_handle, esc_name, g->name, strnlen(g->name, NAME_LENGTH));
- SQL->EscapeStringLen(sql_handle, esc_master, g->master, strnlen(g->master, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, g->name, strnlen(g->name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_master, g->master, strnlen(g->master, NAME_LENGTH));
*t_info = '\0';
// Insert a new guild the guild
@@ -141,18 +130,18 @@ int inter_guild_tosql(struct guild *g,int flag)
strcat(t_info, " guild_create");
// Create a new guild
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` "
"(`name`,`master`,`guild_lv`,`max_member`,`average_lv`,`char_id`) "
"VALUES ('%s', '%s', '%d', '%d', '%d', '%d')",
guild_db, esc_name, esc_master, g->guild_lv, g->max_member, g->average_lv, g->member[0].char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
if (g->guild_id == -1)
return 0; //Failed to create guild!
}
else
{
- g->guild_id = (int)SQL->LastInsertId(sql_handle);
+ g->guild_id = (int)SQL->LastInsertId(inter->sql_handle);
new_guild = 1;
}
}
@@ -210,8 +199,8 @@ int inter_guild_tosql(struct guild *g,int flag)
StrBuf->AppendStr(&buf, ", ");
else
add_comma = true;
- SQL->EscapeStringLen(sql_handle, esc_mes1, g->mes1, strnlen(g->mes1, sizeof(g->mes1)));
- SQL->EscapeStringLen(sql_handle, esc_mes2, g->mes2, strnlen(g->mes2, sizeof(g->mes2)));
+ SQL->EscapeStringLen(inter->sql_handle, esc_mes1, g->mes1, strnlen(g->mes1, sizeof(g->mes1)));
+ SQL->EscapeStringLen(inter->sql_handle, esc_mes2, g->mes2, strnlen(g->mes2, sizeof(g->mes2)));
StrBuf->Printf(&buf, "`mes1`='%s', `mes2`='%s'", esc_mes1, esc_mes2);
}
if (flag & GS_LEVEL)
@@ -219,13 +208,15 @@ int inter_guild_tosql(struct guild *g,int flag)
strcat(t_info, " level");
if( add_comma )
StrBuf->AppendStr(&buf, ", ");
- //else //last condition using add_coma setting
- // add_comma = true;
+#if 0
+ else //last condition using add_coma setting
+ add_comma = true;
+#endif // 0
StrBuf->Printf(&buf, "`guild_lv`=%d, `skill_point`=%d, `exp`=%"PRIu64", `next_exp`=%u, `max_member`=%d", g->guild_lv, g->skill_point, g->exp, g->next_exp, g->max_member);
}
StrBuf->Printf(&buf, " WHERE `guild_id`=%d", g->guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "%s", StrBuf->Value(&buf)) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "%s", StrBuf->Value(&buf)) )
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
}
@@ -241,18 +232,18 @@ int inter_guild_tosql(struct guild *g,int flag)
continue;
if(m->account_id) {
//Since nothing references guild member table as foreign keys, it's safe to use REPLACE INTO
- SQL->EscapeStringLen(sql_handle, esc_name, m->name, strnlen(m->name, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name`) "
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, m->name, strnlen(m->name, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name`) "
"VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%"PRIu64"','%d','%d','%d','%s')",
guild_member_db, g->guild_id, m->account_id, m->char_id,
m->hair, m->hair_color, m->gender,
m->class_, m->lv, m->exp, m->exp_payper, m->online, m->position, esc_name) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
if (m->modified&GS_MEMBER_NEW || new_guild == 1)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `guild_id` = '%d' WHERE `char_id` = '%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `guild_id` = '%d' WHERE `char_id` = '%d'",
char_db, g->guild_id, m->char_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
m->modified = GS_MEMBER_UNMODIFIED;
}
@@ -266,10 +257,10 @@ int inter_guild_tosql(struct guild *g,int flag)
struct guild_position *p = &g->position[i];
if (!p->modified)
continue;
- SQL->EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`position`,`name`,`mode`,`exp_mode`) VALUES ('%d','%d','%s','%d','%d')",
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`guild_id`,`position`,`name`,`mode`,`exp_mode`) VALUES ('%d','%d','%s','%d','%d')",
guild_position_db, g->guild_id, i, esc_name, p->mode, p->exp_mode) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
p->modified = GS_POSITION_UNMODIFIED;
}
}
@@ -280,10 +271,10 @@ int inter_guild_tosql(struct guild *g,int flag)
// NOTE: no need to do it on both sides since both guilds in memory had
// their info changed, not to mention this would also mess up oppositions!
// [Skotlex]
- //if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d' OR `alliance_id`='%d'", guild_alliance_db, g->guild_id, g->guild_id) )
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, g->guild_id) )
+ //if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d' OR `alliance_id`='%d'", guild_alliance_db, g->guild_id, g->guild_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, g->guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
else
{
@@ -293,11 +284,11 @@ int inter_guild_tosql(struct guild *g,int flag)
struct guild_alliance *a=&g->alliance[i];
if(a->guild_id>0)
{
- SQL->EscapeStringLen(sql_handle, esc_name, a->name, strnlen(a->name, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`opposition`,`alliance_id`,`name`) "
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, a->name, strnlen(a->name, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`guild_id`,`opposition`,`alliance_id`,`name`) "
"VALUES ('%d','%d','%d','%s')",
guild_alliance_db, g->guild_id, a->opposition, a->guild_id, esc_name) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
}
}
@@ -311,11 +302,11 @@ int inter_guild_tosql(struct guild *g,int flag)
if(e->account_id>0){
char esc_mes[sizeof(e->mes)*2+1];
- SQL->EscapeStringLen(sql_handle, esc_name, e->name, strnlen(e->name, NAME_LENGTH));
- SQL->EscapeStringLen(sql_handle, esc_mes, e->mes, strnlen(e->mes, sizeof(e->mes)));
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`name`,`mes`) "
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, e->name, strnlen(e->name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_mes, e->mes, strnlen(e->mes, sizeof(e->mes)));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`name`,`mes`) "
"VALUES ('%d','%d','%s','%s')", guild_expulsion_db, g->guild_id, e->account_id, esc_name, esc_mes) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
}
}
@@ -325,9 +316,9 @@ int inter_guild_tosql(struct guild *g,int flag)
//printf("- Insert guild %d to guild_skill\n",g->guild_id);
for(i=0;i<MAX_GUILDSKILL;i++){
if (g->skill[i].id>0 && g->skill[i].lv>0){
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`id`,`lv`) VALUES ('%d','%d','%d')",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`guild_id`,`id`,`lv`) VALUES ('%d','%d','%d')",
guild_skill_db, g->guild_id, g->skill[i].id, g->skill[i].lv) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
}
}
@@ -349,7 +340,7 @@ struct guild * inter_guild_fromsql(int guild_id)
if( guild_id <= 0 )
return NULL;
- g = (struct guild*)idb_get(guild_db_, guild_id);
+ g = (struct guild*)idb_get(inter_guild->guild_db, guild_id);
if( g )
return g;
@@ -357,38 +348,38 @@ struct guild * inter_guild_fromsql(int guild_id)
ShowInfo("Guild load request (%d)...\n", guild_id);
#endif
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT g.`name`,c.`name`,g.`guild_lv`,g.`connect_member`,g.`max_member`,g.`average_lv`,g.`exp`,g.`next_exp`,g.`skill_point`,g.`mes1`,g.`mes2`,g.`emblem_len`,g.`emblem_id`,g.`emblem_data` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT g.`name`,c.`name`,g.`guild_lv`,g.`connect_member`,g.`max_member`,g.`average_lv`,g.`exp`,g.`next_exp`,g.`skill_point`,g.`mes1`,g.`mes2`,g.`emblem_len`,g.`emblem_id`,g.`emblem_data` "
"FROM `%s` g LEFT JOIN `%s` c ON c.`char_id` = g.`char_id` WHERE g.`guild_id`='%d'", guild_db, char_db, guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return NULL;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
return NULL;// Guild does not exists.
CREATE(g, struct guild, 1);
g->guild_id = guild_id;
- SQL->GetData(sql_handle, 0, &data, &len); memcpy(g->name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 1, &data, &len); memcpy(g->master, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 2, &data, NULL); g->guild_lv = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); g->connect_member = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); g->max_member = atoi(data);
- if( g->max_member > MAX_GUILD )
- { // Fix reduction of MAX_GUILD [PoW]
+ SQL->GetData(inter->sql_handle, 0, &data, &len); memcpy(g->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 1, &data, &len); memcpy(g->master, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); g->guild_lv = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); g->connect_member = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); g->max_member = atoi(data);
+ if (g->max_member > MAX_GUILD) {
+ // Fix reduction of MAX_GUILD [PoW]
ShowWarning("Guild %d:%s specifies higher capacity (%d) than MAX_GUILD (%d)\n", guild_id, g->name, g->max_member, MAX_GUILD);
g->max_member = MAX_GUILD;
}
- SQL->GetData(sql_handle, 5, &data, NULL); g->average_lv = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); g->exp = strtoull(data, NULL, 10);
- SQL->GetData(sql_handle, 7, &data, NULL); g->next_exp = (unsigned int)strtoul(data, NULL, 10);
- SQL->GetData(sql_handle, 8, &data, NULL); g->skill_point = atoi(data);
- SQL->GetData(sql_handle, 9, &data, &len); memcpy(g->mes1, data, min(len, sizeof(g->mes1)));
- SQL->GetData(sql_handle, 10, &data, &len); memcpy(g->mes2, data, min(len, sizeof(g->mes2)));
- SQL->GetData(sql_handle, 11, &data, &len); g->emblem_len = atoi(data);
- SQL->GetData(sql_handle, 12, &data, &len); g->emblem_id = atoi(data);
- SQL->GetData(sql_handle, 13, &data, &len);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); g->average_lv = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); g->exp = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); g->next_exp = (unsigned int)strtoul(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); g->skill_point = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, &len); memcpy(g->mes1, data, min(len, sizeof(g->mes1)));
+ SQL->GetData(inter->sql_handle, 10, &data, &len); memcpy(g->mes2, data, min(len, sizeof(g->mes2)));
+ SQL->GetData(inter->sql_handle, 11, &data, &len); g->emblem_len = atoi(data);
+ SQL->GetData(inter->sql_handle, 12, &data, &len); g->emblem_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 13, &data, &len);
// convert emblem data from hexadecimal to binary
//TODO: why not store it in the db as binary directly? [ultramage]
for( i = 0, p = g->emblem_data; i < g->emblem_len; ++i, ++p )
@@ -412,112 +403,112 @@ struct guild * inter_guild_fromsql(int guild_id)
}
// load guild member info
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name` "
"FROM `%s` WHERE `guild_id`='%d' ORDER BY `position`", guild_member_db, guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
aFree(g);
return NULL;
}
- for( i = 0; i < g->max_member && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for( i = 0; i < g->max_member && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
struct guild_member* m = &g->member[i];
- SQL->GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); m->hair = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); m->hair_color = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); m->gender = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); m->class_ = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); m->lv = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); m->exp = strtoull(data, NULL, 10);
- SQL->GetData(sql_handle, 8, &data, NULL); m->exp_payper = (unsigned int)atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); m->online = atoi(data);
- SQL->GetData(sql_handle, 10, &data, NULL); m->position = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); m->account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); m->char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); m->hair = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); m->hair_color = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); m->gender = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); m->class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); m->lv = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); m->exp = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); m->exp_payper = (unsigned int)atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); m->online = atoi(data);
+ SQL->GetData(inter->sql_handle, 10, &data, NULL); m->position = atoi(data);
if( m->position >= MAX_GUILDPOSITION ) // Fix reduction of MAX_GUILDPOSITION [PoW]
m->position = MAX_GUILDPOSITION - 1;
- SQL->GetData(sql_handle, 11, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 11, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
m->modified = GS_MEMBER_UNMODIFIED;
}
//printf("- Read guild_position %d from sql \n",guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `position`,`name`,`mode`,`exp_mode` FROM `%s` WHERE `guild_id`='%d'", guild_position_db, guild_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `position`,`name`,`mode`,`exp_mode` FROM `%s` WHERE `guild_id`='%d'", guild_position_db, guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
aFree(g);
return NULL;
}
- while( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ while( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
int position;
struct guild_position *pos;
- SQL->GetData(sql_handle, 0, &data, NULL); position = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); position = atoi(data);
if( position < 0 || position >= MAX_GUILDPOSITION )
continue;// invalid position
pos = &g->position[position];
- SQL->GetData(sql_handle, 1, &data, &len); memcpy(pos->name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 2, &data, NULL); pos->mode = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); pos->exp_mode = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, &len); memcpy(pos->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); pos->mode = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); pos->exp_mode = atoi(data);
pos->modified = GS_POSITION_UNMODIFIED;
}
//printf("- Read guild_alliance %d from sql \n",guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `opposition`,`alliance_id`,`name` FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, guild_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `opposition`,`alliance_id`,`name` FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
aFree(g);
return NULL;
}
- for( i = 0; i < MAX_GUILDALLIANCE && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for( i = 0; i < MAX_GUILDALLIANCE && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
struct guild_alliance* a = &g->alliance[i];
- SQL->GetData(sql_handle, 0, &data, NULL); a->opposition = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); a->guild_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, &len); memcpy(a->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); a->opposition = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); a->guild_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, &len); memcpy(a->name, data, min(len, NAME_LENGTH));
}
//printf("- Read guild_expulsion %d from sql \n",guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`name`,`mes` FROM `%s` WHERE `guild_id`='%d'", guild_expulsion_db, guild_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`name`,`mes` FROM `%s` WHERE `guild_id`='%d'", guild_expulsion_db, guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
aFree(g);
return NULL;
}
- for( i = 0; i < MAX_GUILDEXPULSION && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for( i = 0; i < MAX_GUILDEXPULSION && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
struct guild_expulsion *e = &g->expulsion[i];
- SQL->GetData(sql_handle, 0, &data, NULL); e->account_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, &len); memcpy(e->name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 2, &data, &len); memcpy(e->mes, data, min(len, sizeof(e->mes)));
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); e->account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, &len); memcpy(e->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 2, &data, &len); memcpy(e->mes, data, min(len, sizeof(e->mes)));
}
//printf("- Read guild_skill %d from sql \n",guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `guild_id`='%d' ORDER BY `id`", guild_skill_db, guild_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `guild_id`='%d' ORDER BY `id`", guild_skill_db, guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
aFree(g);
return NULL;
}
- for(i = 0; i < MAX_GUILDSKILL; i++)
- { //Skill IDs must always be initialized. [Skotlex]
+ for (i = 0; i < MAX_GUILDSKILL; i++) {
+ //Skill IDs must always be initialized. [Skotlex]
g->skill[i].id = i + GD_SKILLBASE;
}
- while( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ while( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
int id;
- SQL->GetData(sql_handle, 0, &data, NULL); id = atoi(data) - GD_SKILLBASE;
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); id = atoi(data) - GD_SKILLBASE;
if( id < 0 || id >= MAX_GUILDSKILL )
continue;// invalid guild skill
- SQL->GetData(sql_handle, 1, &data, NULL); g->skill[id].lv = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); g->skill[id].lv = atoi(data);
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
- idb_put(guild_db_, guild_id, g); //Add to cache
+ idb_put(inter_guild->guild_db, guild_id, g); //Add to cache
g->save_flag |= GS_REMOVE; //But set it to be removed, in case it is not needed for long.
if (save_log)
@@ -527,7 +518,7 @@ struct guild * inter_guild_fromsql(int guild_id)
}
// `guild_castle` (`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`, `visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`)
-int inter_guildcastle_tosql(struct guild_castle *gc)
+int inter_guild_castle_tosql(struct guild_castle *gc)
{
StringBuf buf;
int i;
@@ -540,8 +531,8 @@ int inter_guildcastle_tosql(struct guild_castle *gc)
for (i = 0; i < MAX_GUARDIANS; ++i)
StrBuf->Printf(&buf, ", `visibleG%d`='%d'", i, gc->guardian[i].visible);
- if (SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)))
- Sql_ShowDebug(sql_handle);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)))
+ Sql_ShowDebug(inter->sql_handle);
else if(save_log)
ShowInfo("Saved guild castle (%d)\n", gc->castle_id);
@@ -550,12 +541,12 @@ int inter_guildcastle_tosql(struct guild_castle *gc)
}
// Read guild_castle from SQL
-static struct guild_castle* inter_guildcastle_fromsql(int castle_id)
+struct guild_castle* inter_guild_castle_fromsql(int castle_id)
{
char *data;
int i;
StringBuf buf;
- struct guild_castle *gc = idb_get(castle_db, castle_id);
+ struct guild_castle *gc = idb_get(inter_guild->castle_db, castle_id);
if (gc != NULL)
return gc;
@@ -566,8 +557,8 @@ static struct guild_castle* inter_guildcastle_fromsql(int castle_id)
for (i = 0; i < MAX_GUARDIANS; ++i)
StrBuf->Printf(&buf, ", `visibleG%d`", i);
StrBuf->Printf(&buf, " FROM `%s` WHERE `castle_id`='%d'", guild_castle_db, castle_id);
- if (SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf))) {
- Sql_ShowDebug(sql_handle);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf))) {
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
return NULL;
}
@@ -576,23 +567,23 @@ static struct guild_castle* inter_guildcastle_fromsql(int castle_id)
CREATE(gc, struct guild_castle, 1);
gc->castle_id = castle_id;
- if (SQL_SUCCESS == SQL->NextRow(sql_handle)) {
- SQL->GetData(sql_handle, 1, &data, NULL); gc->guild_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); gc->economy = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); gc->defense = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); gc->triggerE = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); gc->triggerD = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); gc->nextTime = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); gc->payTime = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); gc->createTime = atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); gc->visibleC = atoi(data);
+ if (SQL_SUCCESS == SQL->NextRow(inter->sql_handle)) {
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); gc->guild_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); gc->economy = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); gc->defense = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); gc->triggerE = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); gc->triggerD = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); gc->nextTime = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); gc->payTime = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); gc->createTime = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); gc->visibleC = atoi(data);
for (i = 10; i < 10+MAX_GUARDIANS; i++) {
- SQL->GetData(sql_handle, i, &data, NULL); gc->guardian[i-10].visible = atoi(data);
+ SQL->GetData(inter->sql_handle, i, &data, NULL); gc->guardian[i-10].visible = atoi(data);
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
- idb_put(castle_db, castle_id, gc);
+ idb_put(inter_guild->castle_db, castle_id, gc);
if (save_log)
ShowInfo("Loaded guild castle (%d - guild %d)\n", castle_id, gc->guild_id);
@@ -602,7 +593,7 @@ static struct guild_castle* inter_guildcastle_fromsql(int castle_id)
// Read exp_guild.txt
-static bool exp_guild_parse_row(char* split[], int column, int current) {
+bool inter_guild_exp_parse_row(char* split[], int column, int current) {
int64 exp = strtoll(split[0], NULL, 10);
if (exp < 0 || exp >= UINT_MAX) {
@@ -610,7 +601,7 @@ static bool exp_guild_parse_row(char* split[], int column, int current) {
return false;
}
- guild_exp[current] = (unsigned int)exp;
+ inter_guild->exp[current] = (unsigned int)exp;
return true;
}
@@ -621,29 +612,29 @@ int inter_guild_CharOnline(int char_id, int guild_id) {
if (guild_id == -1) {
//Get guild_id from the database
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
guild_id = atoi(data);
}
else
{
guild_id = 0;
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
if (guild_id == 0)
return 0; //No guild...
- g = inter_guild_fromsql(guild_id);
+ g = inter_guild->fromsql(guild_id);
if(!g) {
ShowError("Character %d's guild %d not found!\n", char_id, guild_id);
return 0;
@@ -672,30 +663,30 @@ int inter_guild_CharOffline(int char_id, int guild_id)
if (guild_id == -1)
{
//Get guild_id from the database
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
guild_id = atoi(data);
}
else
{
guild_id = 0;
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
if (guild_id == 0)
return 0; //No guild...
//Character has a guild, set character offline and check if they were the only member online
- g = inter_guild_fromsql(guild_id);
+ g = inter_guild->fromsql(guild_id);
if (g == NULL) //Guild not found?
return 0;
@@ -723,25 +714,25 @@ int inter_guild_CharOffline(int char_id, int guild_id)
int inter_guild_sql_init(void)
{
//Initialize the guild cache
- guild_db_= idb_alloc(DB_OPT_RELEASE_DATA);
- castle_db = idb_alloc(DB_OPT_RELEASE_DATA);
+ inter_guild->guild_db= idb_alloc(DB_OPT_RELEASE_DATA);
+ inter_guild->castle_db = idb_alloc(DB_OPT_RELEASE_DATA);
//Read exp file
- sv->readdb("db", DBPATH"exp_guild.txt", ',', 1, 1, MAX_GUILDLEVEL, exp_guild_parse_row);
+ sv->readdb("db", DBPATH"exp_guild.txt", ',', 1, 1, MAX_GUILDLEVEL, inter_guild->exp_parse_row);
- timer->add_func_list(guild_save_timer, "guild_save_timer");
- timer->add(timer->gettick() + 10000, guild_save_timer, 0, 0);
+ timer->add_func_list(inter_guild->save_timer, "inter_guild->save_timer");
+ timer->add(timer->gettick() + 10000, inter_guild->save_timer, 0, 0);
return 0;
}
/**
* @see DBApply
*/
-static int guild_db_final(DBKey key, DBData *data, va_list ap)
+int inter_guild_db_final(DBKey key, DBData *data, va_list ap)
{
struct guild *g = DB->data2ptr(data);
if (g->save_flag&GS_MASK) {
- inter_guild_tosql(g, g->save_flag&GS_MASK);
+ inter_guild->tosql(g, g->save_flag&GS_MASK);
return 1;
}
return 0;
@@ -749,42 +740,42 @@ static int guild_db_final(DBKey key, DBData *data, va_list ap)
void inter_guild_sql_final(void)
{
- guild_db_->destroy(guild_db_, guild_db_final);
- db_destroy(castle_db);
+ inter_guild->guild_db->destroy(inter_guild->guild_db, inter_guild->db_final);
+ db_destroy(inter_guild->castle_db);
return;
}
// Get guild_id by its name. Returns 0 if not found, -1 on error.
-int search_guildname(char *str)
+int inter_guild_search_guildname(char *str)
{
int guild_id;
char esc_name[NAME_LENGTH*2+1];
- SQL->EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
//Lookup guilds with the same name
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT guild_id FROM `%s` WHERE name='%s'", guild_db, esc_name) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT guild_id FROM `%s` WHERE name='%s'", guild_db, esc_name) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return -1;
}
- if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
guild_id = atoi(data);
}
else
{
guild_id = 0;
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return guild_id;
}
// Check if guild is empty
-static bool guild_check_empty(struct guild *g)
+static bool inter_guild_check_empty(struct guild *g)
{
int i;
ARR_FIND( 0, g->max_member, i, g->member[i].account_id > 0 );
@@ -796,16 +787,16 @@ static bool guild_check_empty(struct guild *g)
return true;
}
-unsigned int guild_nextexp(int level) {
+unsigned int inter_guild_nextexp(int level) {
if (level == 0)
return 1;
if (level <= 0 || level >= MAX_GUILDLEVEL)
return 0;
- return guild_exp[level-1];
+ return inter_guild->exp[level-1];
}
-int guild_checkskill(struct guild *g,int id)
+int inter_guild_checkskill(struct guild *g,int id)
{
int idx = id - GD_SKILLBASE;
@@ -815,7 +806,7 @@ int guild_checkskill(struct guild *g,int id)
return g->skill[idx].lv;
}
-int guild_calcinfo(struct guild *g)
+int inter_guild_calcinfo(struct guild *g)
{
int i,c;
unsigned int nextexp;
@@ -823,21 +814,21 @@ int guild_calcinfo(struct guild *g)
if(g->guild_lv<=0)
g->guild_lv = 1;
- nextexp = guild_nextexp(g->guild_lv);
+ nextexp = inter_guild->nextexp(g->guild_lv);
// Consume guild exp and increase guild level
while(g->exp >= nextexp && nextexp > 0) { // nextexp would be 0 if g->guild_lv was >= MAX_GUILDLEVEL
g->exp-=nextexp;
g->guild_lv++;
g->skill_point++;
- nextexp = guild_nextexp(g->guild_lv);
+ nextexp = inter_guild->nextexp(g->guild_lv);
}
// Save next exp step
g->next_exp = nextexp;
// Set the max number of members, Guild Extension skill - currently adds 6 to max per skill lv.
- g->max_member = 16 + guild_checkskill(g, GD_EXTENSION) * 6;
+ g->max_member = 16 + inter_guild->checkskill(g, GD_EXTENSION) * 6;
if(g->max_member > MAX_GUILD)
{
ShowError("Guild %d:%s has capacity for too many guild members (%d), max supported is %d\n", g->guild_id, g->name, g->max_member, MAX_GUILD);
@@ -869,10 +860,9 @@ int guild_calcinfo(struct guild *g)
g->average_lv /= c;
// Check if guild stats has change
- if(g->max_member != before.max_member || g->guild_lv != before.guild_lv || g->skill_point != before.skill_point )
- {
+ if (g->max_member != before.max_member || g->guild_lv != before.guild_lv || g->skill_point != before.skill_point) {
g->save_flag |= GS_LEVEL;
- mapif_guild_info(-1,g);
+ mapif->guild_info(-1,g);
return 1;
}
@@ -882,7 +872,7 @@ int guild_calcinfo(struct guild *g)
//-------------------------------------------------------------------
// Packet sent to map server
-int mapif_guild_created(int fd,int account_id,struct guild *g)
+int mapif_guild_created(int fd, int account_id, struct guild *g)
{
WFIFOHEAD(fd, 10);
WFIFOW(fd,0)=0x3830;
@@ -899,7 +889,7 @@ int mapif_guild_created(int fd,int account_id,struct guild *g)
}
// Guild not found
-int mapif_guild_noinfo(int fd,int guild_id)
+int mapif_guild_noinfo(int fd, int guild_id)
{
unsigned char buf[12];
WBUFW(buf,0)=0x3831;
@@ -907,28 +897,28 @@ int mapif_guild_noinfo(int fd,int guild_id)
WBUFL(buf,4)=guild_id;
ShowWarning("int_guild: info not found %d\n",guild_id);
if(fd<0)
- mapif_sendall(buf,8);
+ mapif->sendall(buf,8);
else
- mapif_send(fd,buf,8);
+ mapif->send(fd,buf,8);
return 0;
}
// Send guild info
-int mapif_guild_info(int fd,struct guild *g)
+int mapif_guild_info(int fd, struct guild *g)
{
unsigned char buf[8+sizeof(struct guild)];
WBUFW(buf,0)=0x3831;
WBUFW(buf,2)=4+sizeof(struct guild);
memcpy(buf+4,g,sizeof(struct guild));
if(fd<0)
- mapif_sendall(buf,WBUFW(buf,2));
+ mapif->sendall(buf,WBUFW(buf,2));
else
- mapif_send(fd,buf,WBUFW(buf,2));
+ mapif->send(fd,buf,WBUFW(buf,2));
return 0;
}
// ACK member add
-int mapif_guild_memberadded(int fd,int guild_id,int account_id,int char_id,int flag)
+int mapif_guild_memberadded(int fd, int guild_id, int account_id, int char_id, int flag)
{
WFIFOHEAD(fd, 15);
WFIFOW(fd,0)=0x3832;
@@ -951,13 +941,13 @@ int mapif_guild_withdraw(int guild_id,int account_id,int char_id,int flag, const
WBUFB(buf,14)=flag;
memcpy(WBUFP(buf,15),mes,40);
memcpy(WBUFP(buf,55),name,NAME_LENGTH);
- mapif_sendall(buf,55+NAME_LENGTH);
+ mapif->sendall(buf,55+NAME_LENGTH);
ShowInfo("int_guild: guild withdraw (%d - %d: %s - %s)\n",guild_id,account_id,name,mes);
return 0;
}
// Send short member's info
-int mapif_guild_memberinfoshort(struct guild *g,int idx)
+int mapif_guild_memberinfoshort(struct guild *g, int idx)
{
unsigned char buf[19];
WBUFW(buf, 0)=0x3835;
@@ -967,24 +957,24 @@ int mapif_guild_memberinfoshort(struct guild *g,int idx)
WBUFB(buf,14)=(unsigned char)g->member[idx].online;
WBUFW(buf,15)=g->member[idx].lv;
WBUFW(buf,17)=g->member[idx].class_;
- mapif_sendall(buf,19);
+ mapif->sendall(buf,19);
return 0;
}
// Send guild broken
-int mapif_guild_broken(int guild_id,int flag)
+int mapif_guild_broken(int guild_id, int flag)
{
unsigned char buf[7];
WBUFW(buf,0)=0x3836;
WBUFL(buf,2)=guild_id;
WBUFB(buf,6)=flag;
- mapif_sendall(buf,7);
+ mapif->sendall(buf,7);
ShowInfo("int_guild: Guild broken (%d)\n",guild_id);
return 0;
}
// Send guild message
-int mapif_guild_message(int guild_id,int account_id,char *mes,int len, int sfd)
+int mapif_guild_message(int guild_id, int account_id, char *mes, int len, int sfd)
{
unsigned char buf[512];
if (len > 500)
@@ -994,12 +984,12 @@ int mapif_guild_message(int guild_id,int account_id,char *mes,int len, int sfd)
WBUFL(buf,4)=guild_id;
WBUFL(buf,8)=account_id;
memcpy(WBUFP(buf,12),mes,len);
- mapif_sendallwos(sfd, buf,len+12);
+ mapif->sendallwos(sfd, buf,len+12);
return 0;
}
// Send basic info
-int mapif_guild_basicinfochanged(int guild_id,int type,const void *data,int len)
+int mapif_guild_basicinfochanged(int guild_id, int type, const void *data, int len)
{
unsigned char buf[2048];
if (len > 2038)
@@ -1009,12 +999,12 @@ int mapif_guild_basicinfochanged(int guild_id,int type,const void *data,int len)
WBUFL(buf, 4)=guild_id;
WBUFW(buf, 8)=type;
memcpy(WBUFP(buf,10),data,len);
- mapif_sendall(buf,len+10);
+ mapif->sendall(buf,len+10);
return 0;
}
// Send member info
-int mapif_guild_memberinfochanged(int guild_id,int account_id,int char_id, int type,const void *data,int len)
+int mapif_guild_memberinfochanged(int guild_id, int account_id, int char_id, int type, const void *data, int len)
{
unsigned char buf[2048];
if (len > 2030)
@@ -1026,24 +1016,24 @@ int mapif_guild_memberinfochanged(int guild_id,int account_id,int char_id, int t
WBUFL(buf,12)=char_id;
WBUFW(buf,16)=type;
memcpy(WBUFP(buf,18),data,len);
- mapif_sendall(buf,len+18);
+ mapif->sendall(buf,len+18);
return 0;
}
// ACK guild skill up
-int mapif_guild_skillupack(int guild_id,uint16 skill_id,int account_id)
+int mapif_guild_skillupack(int guild_id, uint16 skill_id, int account_id)
{
unsigned char buf[14];
WBUFW(buf, 0)=0x383c;
WBUFL(buf, 2)=guild_id;
WBUFL(buf, 6)=skill_id;
WBUFL(buf,10)=account_id;
- mapif_sendall(buf,14);
+ mapif->sendall(buf,14);
return 0;
}
// ACK guild alliance
-int mapif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag,const char *name1,const char *name2)
+int mapif_guild_alliance(int guild_id1, int guild_id2, int account_id1, int account_id2, int flag, const char *name1, const char *name2)
{
unsigned char buf[19+2*NAME_LENGTH];
WBUFW(buf, 0)=0x383d;
@@ -1054,12 +1044,12 @@ int mapif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account
WBUFB(buf,18)=flag;
memcpy(WBUFP(buf,19),name1,NAME_LENGTH);
memcpy(WBUFP(buf,19+NAME_LENGTH),name2,NAME_LENGTH);
- mapif_sendall(buf,19+2*NAME_LENGTH);
+ mapif->sendall(buf,19+2*NAME_LENGTH);
return 0;
}
// Send a guild position desc
-int mapif_guild_position(struct guild *g,int idx)
+int mapif_guild_position(struct guild *g, int idx)
{
unsigned char buf[12 + sizeof(struct guild_position)];
WBUFW(buf,0)=0x383b;
@@ -1067,7 +1057,7 @@ int mapif_guild_position(struct guild *g,int idx)
WBUFL(buf,4)=g->guild_id;
WBUFL(buf,8)=idx;
memcpy(WBUFP(buf,12),&g->position[idx],sizeof(struct guild_position));
- mapif_sendall(buf,WBUFW(buf,2));
+ mapif->sendall(buf,WBUFW(buf,2));
return 0;
}
@@ -1079,7 +1069,7 @@ int mapif_guild_notice(struct guild *g)
WBUFL(buf,2)=g->guild_id;
memcpy(WBUFP(buf,6),g->mes1,MAX_GUILDMES1);
memcpy(WBUFP(buf,66),g->mes2,MAX_GUILDMES2);
- mapif_sendall(buf,186);
+ mapif->sendall(buf,186);
return 0;
}
@@ -1092,7 +1082,7 @@ int mapif_guild_emblem(struct guild *g)
WBUFL(buf,4)=g->guild_id;
WBUFL(buf,8)=g->emblem_id;
memcpy(WBUFP(buf,12),g->emblem_data,g->emblem_len);
- mapif_sendall(buf,WBUFW(buf,2));
+ mapif->sendall(buf,WBUFW(buf,2));
return 0;
}
@@ -1103,7 +1093,7 @@ int mapif_guild_master_changed(struct guild *g, int aid, int cid)
WBUFL(buf,2)=g->guild_id;
WBUFL(buf,6)=aid;
WBUFL(buf,10)=cid;
- mapif_sendall(buf,14);
+ mapif->sendall(buf,14);
return 0;
}
@@ -1118,7 +1108,7 @@ int mapif_guild_castle_dataload(int fd, int sz, int *castle_ids)
WFIFOW(fd, 0) = 0x3840;
WFIFOW(fd, 2) = len;
for (i = 0; i < num; i++) {
- gc = inter_guildcastle_fromsql(*(castle_ids++));
+ gc = inter_guild->castle_fromsql(*(castle_ids++));
memcpy(WFIFOP(fd, 4 + i * sizeof(*gc)), gc, sizeof(*gc));
}
WFIFOSET(fd, len);
@@ -1137,22 +1127,22 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member
#ifdef NOISY
ShowInfo("Creating Guild (%s)\n", name);
#endif
- if(search_guildname(name) != 0){
+ if(inter_guild->search_guildname(name) != 0){
ShowInfo("int_guild: guild with same name exists [%s]\n",name);
- mapif_guild_created(fd,account_id,NULL);
+ mapif->guild_created(fd,account_id,NULL);
return 0;
}
// Check Authorized letters/symbols in the name of the character
if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorized
for (i = 0; i < NAME_LENGTH && name[i]; i++)
if (strchr(char_name_letters, name[i]) == NULL) {
- mapif_guild_created(fd,account_id,NULL);
+ mapif->guild_created(fd,account_id,NULL);
return 0;
}
} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
for (i = 0; i < NAME_LENGTH && name[i]; i++)
if (strchr(char_name_letters, name[i]) != NULL) {
- mapif_guild_created(fd,account_id,NULL);
+ mapif->guild_created(fd,account_id,NULL);
return 0;
}
}
@@ -1186,53 +1176,53 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member
g->guild_id= -1; //Request to create guild.
// Create the guild
- if (!inter_guild_tosql(g,GS_BASIC|GS_POSITION|GS_SKILL|GS_MEMBER)) {
+ if (!inter_guild->tosql(g,GS_BASIC|GS_POSITION|GS_SKILL|GS_MEMBER)) {
//Failed to Create guild....
ShowError("Failed to create Guild %s (Guild Master: %s)\n", g->name, g->master);
- mapif_guild_created(fd,account_id,NULL);
+ mapif->guild_created(fd,account_id,NULL);
aFree(g);
return 0;
}
ShowInfo("Created Guild %d - %s (Guild Master: %s)\n", g->guild_id, g->name, g->master);
//Add to cache
- idb_put(guild_db_, g->guild_id, g);
+ idb_put(inter_guild->guild_db, g->guild_id, g);
// Report to client
- mapif_guild_created(fd,account_id,g);
- mapif_guild_info(fd,g);
+ mapif->guild_created(fd,account_id,g);
+ mapif->guild_info(fd,g);
if(log_inter)
- inter_log("guild %s (id=%d) created by master %s (id=%d)\n",
+ inter->log("guild %s (id=%d) created by master %s (id=%d)\n",
name, g->guild_id, master->name, master->account_id );
return 0;
}
// Return guild info to client
-int mapif_parse_GuildInfo(int fd,int guild_id)
+int mapif_parse_GuildInfo(int fd, int guild_id)
{
- struct guild * g = inter_guild_fromsql(guild_id); //We use this because on start-up the info of castle-owned guilds is required. [Skotlex]
+ struct guild * g = inter_guild->fromsql(guild_id); //We use this because on start-up the info of castle-owned guilds is required. [Skotlex]
if(g)
{
- if (!guild_calcinfo(g))
- mapif_guild_info(fd,g);
+ if (!inter_guild->calcinfo(g))
+ mapif->guild_info(fd,g);
}
else
- mapif_guild_noinfo(fd,guild_id); // Failed to load info
+ mapif->guild_noinfo(fd,guild_id); // Failed to load info
return 0;
}
// Add member to guild
-int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m)
+int mapif_parse_GuildAddMember(int fd, int guild_id, struct guild_member *m)
{
struct guild * g;
int i;
- g = inter_guild_fromsql(guild_id);
+ g = inter_guild->fromsql(guild_id);
if(g==NULL){
// Failed to add
- mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,1);
+ mapif->guild_memberadded(fd,guild_id,m->account_id,m->char_id,1);
return 0;
}
@@ -1243,9 +1233,9 @@ int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m)
{
memcpy(&g->member[i],m,sizeof(struct guild_member));
g->member[i].modified = (GS_MEMBER_NEW | GS_MEMBER_MODIFIED);
- mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,0);
- if (!guild_calcinfo(g)) //Send members if it was not invoked.
- mapif_guild_info(-1,g);
+ mapif->guild_memberadded(fd,guild_id,m->account_id,m->char_id,0);
+ if (!inter_guild->calcinfo(g)) //Send members if it was not invoked.
+ mapif->guild_info(-1,g);
g->save_flag |= GS_MEMBER;
if (g->save_flag&GS_REMOVE)
@@ -1255,7 +1245,7 @@ int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m)
}
// Failed to add
- mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,1);
+ mapif->guild_memberadded(fd,guild_id,m->account_id,m->char_id,1);
return 0;
}
@@ -1264,13 +1254,13 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in
{
int i;
- struct guild* g = inter_guild_fromsql(guild_id);
+ struct guild* g = inter_guild->fromsql(guild_id);
if( g == NULL )
{
// Unknown guild, just update the player
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `account_id`='%d' AND `char_id`='%d'", char_db, account_id, char_id) )
- Sql_ShowDebug(sql_handle);
- // mapif_guild_withdraw(guild_id,account_id,char_id,flag,g->member[i].name,mes);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `account_id`='%d' AND `char_id`='%d'", char_db, account_id, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ // mapif->guild_withdraw(guild_id,account_id,char_id,flag,g->member[i].name,mes);
return 0;
}
@@ -1282,8 +1272,8 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in
return 0;
}
- if( flag )
- { // Write expulsion reason
+ if (flag) {
+ // Write expulsion reason
// Find an empty slot
int j;
ARR_FIND( 0, MAX_GUILDEXPULSION, j, g->expulsion[j].account_id == 0 );
@@ -1300,17 +1290,17 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in
safestrncpy(g->expulsion[j].mes, mes, 40);
}
- mapif_guild_withdraw(guild_id,account_id,char_id,flag,g->member[i].name,mes);
- inter_guild_removemember_tosql(g->member[i].account_id,g->member[i].char_id);
+ mapif->guild_withdraw(guild_id,account_id,char_id,flag,g->member[i].name,mes);
+ inter_guild->removemember_tosql(g->member[i].account_id,g->member[i].char_id);
memset(&g->member[i],0,sizeof(struct guild_member));
- if( guild_check_empty(g) )
- mapif_parse_BreakGuild(-1,guild_id); //Break the guild.
+ if( inter_guild->check_empty(g) )
+ mapif->parse_BreakGuild(-1,guild_id); //Break the guild.
else {
//Update member info.
- if (!guild_calcinfo(g))
- mapif_guild_info(fd,g);
+ if (!inter_guild->calcinfo(g))
+ mapif->guild_info(fd,g);
g->save_flag |= GS_EXPULSION;
}
@@ -1318,14 +1308,14 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in
}
// Change member info
-int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id,int account_id,int char_id,int online,int lv,int class_)
+int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, int char_id, int online, int lv, int class_)
{
// Could speed up by manipulating only guild_member
struct guild * g;
int i,sum,c;
int prev_count, prev_alv;
- g = inter_guild_fromsql(guild_id);
+ g = inter_guild->fromsql(guild_id);
if(g==NULL)
return 0;
@@ -1336,7 +1326,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id,int account_id,in
g->member[i].lv = lv;
g->member[i].class_ = class_;
g->member[i].modified = GS_MEMBER_MODIFIED;
- mapif_guild_memberinfoshort(g,i);
+ mapif->guild_memberinfoshort(g,i);
}
prev_count = g->connect_member;
@@ -1371,58 +1361,58 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id,int account_id,in
}
// BreakGuild
-int mapif_parse_BreakGuild(int fd,int guild_id)
+int mapif_parse_BreakGuild(int fd, int guild_id)
{
struct guild * g;
- g = inter_guild_fromsql(guild_id);
+ g = inter_guild->fromsql(guild_id);
if(g==NULL)
return 0;
// Delete guild from sql
//printf("- Delete guild %d from guild\n",guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_member_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_member_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_castle_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_castle_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_storage_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_storage_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d' OR `alliance_id` = '%d'", guild_alliance_db, guild_id, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d' OR `alliance_id` = '%d'", guild_alliance_db, guild_id, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_position_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_position_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_skill_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_skill_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_expulsion_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_expulsion_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
//printf("- Update guild %d of char\n",guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'", char_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'", char_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- mapif_guild_broken(guild_id,0);
+ mapif->guild_broken(guild_id,0);
if(log_inter)
- inter_log("guild %s (id=%d) broken\n",g->name,guild_id);
+ inter->log("guild %s (id=%d) broken\n",g->name,guild_id);
//Remove the guild from memory. [Skotlex]
- idb_remove(guild_db_, guild_id);
+ idb_remove(inter_guild->guild_db, guild_id);
return 0;
}
// Forward Guild message to others map servers
-int mapif_parse_GuildMessage(int fd,int guild_id,int account_id,char *mes,int len)
+int mapif_parse_GuildMessage(int fd, int guild_id, int account_id, char *mes, int len)
{
- return mapif_guild_message(guild_id,account_id,mes,len, fd);
+ return mapif->guild_message(guild_id,account_id,mes,len, fd);
}
/**
@@ -1433,7 +1423,7 @@ int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const void
struct guild *g;
struct guild_skill gd_skill;
short value;
- g = inter_guild_fromsql(guild_id);
+ g = inter_guild->fromsql(guild_id);
if( g == NULL )
return 0;
@@ -1444,7 +1434,7 @@ int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const void
if( value < 0 && abs(value) > g->exp )
return 0;
g->exp += value;
- guild_calcinfo(g);
+ inter_guild->calcinfo(g);
break;
case GBI_GUILDLV:
@@ -1466,39 +1456,39 @@ int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const void
case GBI_SKILLLV:
gd_skill = *((const struct guild_skill*)data);
memcpy(&(g->skill[(gd_skill.id - GD_SKILLBASE)]), &gd_skill, sizeof(gd_skill));
- if( !guild_calcinfo(g) )
- mapif_guild_info(-1,g);
+ if( !inter_guild->calcinfo(g) )
+ mapif->guild_info(-1,g);
g->save_flag |= GS_SKILL;
- mapif_guild_skillupack(g->guild_id, gd_skill.id, 0);
+ mapif->guild_skillupack(g->guild_id, gd_skill.id, 0);
break;
default:
ShowError("int_guild: GuildBasicInfoChange: Unknown type %d, see mmo.h::guild_basic_info for more information\n",type);
return 0;
}
- mapif_guild_info(-1,g);
+ mapif->guild_info(-1,g);
g->save_flag |= GS_LEVEL;
- // Information is already sent in mapif_guild_info
- //mapif_guild_basicinfochanged(guild_id,type,data,len);
+ // Information is already sent in mapif->guild_info
+ //mapif->guild_basicinfochanged(guild_id,type,data,len);
return 0;
}
// Modification of the guild
-int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int char_id,int type,const char *data,int len)
+int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int char_id, int type, const char *data, int len)
{
// Could make some improvement in speed, because only change guild_member
int i;
struct guild * g;
- g = inter_guild_fromsql(guild_id);
+ g = inter_guild->fromsql(guild_id);
if(g==NULL)
return 0;
// Search the member
- for(i=0;i<g->max_member;i++)
- if( g->member[i].account_id==account_id &&
- g->member[i].char_id==char_id )
- break;
+ for (i = 0; i < g->max_member; i++) {
+ if (g->member[i].account_id == account_id && g->member[i].char_id==char_id)
+ break;
+ }
// Not Found
if(i==g->max_member){
@@ -1513,12 +1503,12 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha
{
g->member[i].position=*((short *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
- mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
+ mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER;
break;
}
case GMI_EXP:
- { // EXP
+ {
uint64 exp, old_exp=g->member[i].exp;
g->member[i].exp=*((uint64 *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
@@ -1536,11 +1526,11 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha
else
g->exp+=exp;
- guild_calcinfo(g);
- mapif_guild_basicinfochanged(guild_id,GBI_EXP,&g->exp,sizeof(g->exp));
+ inter_guild->calcinfo(g);
+ mapif->guild_basicinfochanged(guild_id,GBI_EXP,&g->exp,sizeof(g->exp));
g->save_flag |= GS_LEVEL;
}
- mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
+ mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER;
break;
}
@@ -1548,7 +1538,7 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha
{
g->member[i].hair=*((short *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
- mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
+ mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
break;
}
@@ -1556,7 +1546,7 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha
{
g->member[i].hair_color=*((short *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
- mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
+ mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
break;
}
@@ -1564,7 +1554,7 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha
{
g->member[i].gender=*((short *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
- mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
+ mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
break;
}
@@ -1572,7 +1562,7 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha
{
g->member[i].class_=*((short *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
- mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
+ mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
break;
}
@@ -1580,7 +1570,7 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha
{
g->member[i].lv=*((short *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
- mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
+ mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
break;
}
@@ -1591,17 +1581,17 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha
return 0;
}
-int inter_guild_sex_changed(int guild_id,int account_id,int char_id, short gender)
+int inter_guild_sex_changed(int guild_id, int account_id, int char_id, short gender)
{
- return mapif_parse_GuildMemberInfoChange(0, guild_id, account_id, char_id, GMI_GENDER, (const char*)&gender, sizeof(gender));
+ return mapif->parse_GuildMemberInfoChange(0, guild_id, account_id, char_id, GMI_GENDER, (const char*)&gender, sizeof(gender));
}
-int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char *name)
+int inter_guild_charname_changed(int guild_id, int account_id, int char_id, char *name)
{
struct guild *g;
int i, flag = 0;
- g = inter_guild_fromsql(guild_id);
+ g = inter_guild->fromsql(guild_id);
if( g == NULL )
{
ShowError("inter_guild_charrenamed: Can't find guild %d.\n", guild_id);
@@ -1624,38 +1614,38 @@ int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char
g->member[i].modified = GS_MEMBER_MODIFIED;
flag |= GS_MEMBER;
- if( !inter_guild_tosql(g, flag) )
+ if( !inter_guild->tosql(g, flag) )
return 0;
- mapif_guild_info(-1,g);
+ mapif->guild_info(-1,g);
return 0;
}
// Change a position desc
-int mapif_parse_GuildPosition(int fd,int guild_id,int idx,struct guild_position *p)
+int mapif_parse_GuildPosition(int fd, int guild_id, int idx, struct guild_position *p)
{
// Could make some improvement in speed, because only change guild_position
struct guild * g;
- g = inter_guild_fromsql(guild_id);
+ g = inter_guild->fromsql(guild_id);
if(g==NULL || idx<0 || idx>=MAX_GUILDPOSITION)
return 0;
memcpy(&g->position[idx],p,sizeof(struct guild_position));
- mapif_guild_position(g,idx);
+ mapif->guild_position(g,idx);
g->position[idx].modified = GS_POSITION_MODIFIED;
g->save_flag |= GS_POSITION; // Change guild_position
return 0;
}
// Guild Skill UP
-int mapif_parse_GuildSkillUp(int fd,int guild_id,uint16 skill_id,int account_id,int max)
+int mapif_parse_GuildSkillUp(int fd, int guild_id, uint16 skill_id, int account_id, int max)
{
struct guild * g;
int idx = skill_id - GD_SKILLBASE;
- g = inter_guild_fromsql(guild_id);
+ g = inter_guild->fromsql(guild_id);
if(g == NULL || idx < 0 || idx >= MAX_GUILDSKILL)
return 0;
@@ -1663,16 +1653,16 @@ int mapif_parse_GuildSkillUp(int fd,int guild_id,uint16 skill_id,int account_id,
{
g->skill[idx].lv++;
g->skill_point--;
- if (!guild_calcinfo(g))
- mapif_guild_info(-1,g);
- mapif_guild_skillupack(guild_id,skill_id,account_id);
+ if (!inter_guild->calcinfo(g))
+ mapif->guild_info(-1,g);
+ mapif->guild_skillupack(guild_id,skill_id,account_id);
g->save_flag |= (GS_LEVEL|GS_SKILL); // Change guild & guild_skill
}
return 0;
}
//Manual deletion of an alliance when partnering guild does not exists. [Skotlex]
-static int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int account_id1, int account_id2, int flag)
+int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int account_id1, int account_id2, int flag)
{
int i;
char name[NAME_LENGTH];
@@ -1684,22 +1674,22 @@ static int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int ac
strcpy(name, g->alliance[i].name);
g->alliance[i].guild_id=0;
- mapif_guild_alliance(g->guild_id,guild_id,account_id1,account_id2,flag,g->name,name);
+ mapif->guild_alliance(g->guild_id,guild_id,account_id1,account_id2,flag,g->name,name);
g->save_flag |= GS_ALLIANCE;
return 0;
}
// Alliance modification
-int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2,int account_id1,int account_id2,int flag)
+int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_id1, int account_id2, int flag)
{
// Could speed up
struct guild *g[2] = { NULL };
int j,i;
- g[0] = inter_guild_fromsql(guild_id1);
- g[1] = inter_guild_fromsql(guild_id2);
+ g[0] = inter_guild->fromsql(guild_id1);
+ g[1] = inter_guild->fromsql(guild_id2);
if(g[0] && g[1]==NULL && (flag & GUILD_ALLIANCE_REMOVE)) //Requested to remove an alliance with a not found guild.
- return mapif_parse_GuildDeleteAlliance(g[0], guild_id2, account_id1, account_id2, flag); //Try to do a manual removal of said guild.
+ return mapif->parse_GuildDeleteAlliance(g[0], guild_id2, account_id1, account_id2, flag); //Try to do a manual removal of said guild.
if(g[0]==NULL || g[1]==NULL)
return 0;
@@ -1726,7 +1716,7 @@ int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2,int account_id1
}
// Send on all map the new alliance/opposition
- mapif_guild_alliance(guild_id1,guild_id2,account_id1,account_id2,flag,g[0]->name,g[1]->name);
+ mapif->guild_alliance(guild_id1,guild_id2,account_id1,account_id2,flag,g[0]->name,g[1]->name);
// Mark the two guild to be saved
g[0]->save_flag |= GS_ALLIANCE;
@@ -1735,25 +1725,25 @@ int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2,int account_id1
}
// Change guild message
-int mapif_parse_GuildNotice(int fd,int guild_id,const char *mes1,const char *mes2)
+int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char *mes2)
{
struct guild *g;
- g = inter_guild_fromsql(guild_id);
+ g = inter_guild->fromsql(guild_id);
if(g==NULL)
return 0;
memcpy(g->mes1,mes1,MAX_GUILDMES1);
memcpy(g->mes2,mes2,MAX_GUILDMES2);
- g->save_flag |= GS_MES; //Change mes of guild
- return mapif_guild_notice(g);
+ g->save_flag |= GS_MES; //Change mes of guild
+ return mapif->guild_notice(g);
}
-int mapif_parse_GuildEmblem(int fd,int len,int guild_id,int dummy,const char *data)
+int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char *data)
{
struct guild * g;
- g = inter_guild_fromsql(guild_id);
+ g = inter_guild->fromsql(guild_id);
if(g==NULL)
return 0;
@@ -1763,21 +1753,21 @@ int mapif_parse_GuildEmblem(int fd,int len,int guild_id,int dummy,const char *da
memcpy(g->emblem_data,data,len);
g->emblem_len=len;
g->emblem_id++;
- g->save_flag |= GS_EMBLEM; //Change guild
- return mapif_guild_emblem(g);
+ g->save_flag |= GS_EMBLEM; //Change guild
+ return mapif->guild_emblem(g);
}
int mapif_parse_GuildCastleDataLoad(int fd, int len, int *castle_ids)
{
- return mapif_guild_castle_dataload(fd, len, castle_ids);
+ return mapif->guild_castle_dataload(fd, len, castle_ids);
}
int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value)
{
- struct guild_castle *gc = inter_guildcastle_fromsql(castle_id);
+ struct guild_castle *gc = inter_guild->castle_fromsql(castle_id);
if (gc == NULL) {
- ShowError("mapif_parse_GuildCastleDataSave: castle id=%d not found\n", castle_id);
+ ShowError("mapif->parse_GuildCastleDataSave: castle id=%d not found\n", castle_id);
return 0;
}
@@ -1785,8 +1775,8 @@ int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value)
case 1:
if (log_inter && gc->guild_id != value) {
int gid = (value) ? value : gc->guild_id;
- struct guild *g = idb_get(guild_db_, gid);
- inter_log("guild %s (id=%d) %s castle id=%d\n",
+ struct guild *g = idb_get(inter_guild->guild_db, gid);
+ inter->log("guild %s (id=%d) %s castle id=%d\n",
(g) ? g->name : "??", gid, (value) ? "occupy" : "abandon", castle_id);
}
gc->guild_id = value;
@@ -1804,10 +1794,10 @@ int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value)
gc->guardian[index-10].visible = value;
break;
}
- ShowError("mapif_parse_GuildCastleDataSave: not found index=%d\n", index);
+ ShowError("mapif->parse_GuildCastleDataSave: not found index=%d\n", index);
return 0;
}
- inter_guildcastle_tosql(gc);
+ inter_guild->castle_tosql(gc);
return 0;
}
@@ -1817,7 +1807,7 @@ int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int le
struct guild_member gm;
int pos;
- g = inter_guild_fromsql(guild_id);
+ g = inter_guild->fromsql(guild_id);
if(g==NULL || len > NAME_LENGTH)
return 0;
@@ -1845,7 +1835,7 @@ int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int le
ShowInfo("int_guild: Guildmaster Changed to %s (Guild %d - %s)\n",g->master, guild_id, g->name);
g->save_flag |= (GS_BASIC|GS_MEMBER); //Save main data and member data.
- return mapif_guild_master_changed(g, g->member[0].account_id, g->member[0].char_id);
+ return mapif->guild_master_changed(g, g->member[0].account_id, g->member[0].char_id);
}
// Communication from the map server
@@ -1853,29 +1843,29 @@ int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int le
// 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
+// 1 : ok
+// 0 : error
int inter_guild_parse_frommap(int fd)
{
RFIFOHEAD(fd);
switch(RFIFOW(fd,0)) {
- case 0x3030: mapif_parse_CreateGuild(fd,RFIFOL(fd,4),(char*)RFIFOP(fd,8),(struct guild_member *)RFIFOP(fd,32)); break;
- case 0x3031: mapif_parse_GuildInfo(fd,RFIFOL(fd,2)); break;
- case 0x3032: mapif_parse_GuildAddMember(fd,RFIFOL(fd,4),(struct guild_member *)RFIFOP(fd,8)); break;
- case 0x3033: mapif_parse_GuildMasterChange(fd,RFIFOL(fd,4),(const char*)RFIFOP(fd,8),RFIFOW(fd,2)-8); break;
- case 0x3034: mapif_parse_GuildLeave(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),(const char*)RFIFOP(fd,15)); break;
- case 0x3035: mapif_parse_GuildChangeMemberInfoShort(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17)); break;
- case 0x3036: mapif_parse_BreakGuild(fd,RFIFOL(fd,2)); break;
- case 0x3037: mapif_parse_GuildMessage(fd,RFIFOL(fd,4),RFIFOL(fd,8),(char*)RFIFOP(fd,12),RFIFOW(fd,2)-12); break;
- case 0x3039: mapif_parse_GuildBasicInfoChange(fd,RFIFOL(fd,4),RFIFOW(fd,8),(const int16 *)RFIFOP(fd,10),RFIFOW(fd,2)-10); break;
- case 0x303A: mapif_parse_GuildMemberInfoChange(fd,RFIFOL(fd,4),RFIFOL(fd,8),RFIFOL(fd,12),RFIFOW(fd,16),(const char*)RFIFOP(fd,18),RFIFOW(fd,2)-18); break;
- case 0x303B: mapif_parse_GuildPosition(fd,RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12)); break;
- case 0x303C: mapif_parse_GuildSkillUp(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14)); break;
- case 0x303D: mapif_parse_GuildAlliance(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),RFIFOB(fd,18)); break;
- case 0x303E: mapif_parse_GuildNotice(fd,RFIFOL(fd,2),(const char*)RFIFOP(fd,6),(const char*)RFIFOP(fd,66)); break;
- case 0x303F: mapif_parse_GuildEmblem(fd,RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8),(const char*)RFIFOP(fd,12)); break;
- case 0x3040: mapif_parse_GuildCastleDataLoad(fd,RFIFOW(fd,2),(int *)RFIFOP(fd,4)); break;
- case 0x3041: mapif_parse_GuildCastleDataSave(fd,RFIFOW(fd,2),RFIFOB(fd,4),RFIFOL(fd,5)); break;
+ case 0x3030: mapif->parse_CreateGuild(fd,RFIFOL(fd,4),(char*)RFIFOP(fd,8),(struct guild_member *)RFIFOP(fd,32)); break;
+ case 0x3031: mapif->parse_GuildInfo(fd,RFIFOL(fd,2)); break;
+ case 0x3032: mapif->parse_GuildAddMember(fd,RFIFOL(fd,4),(struct guild_member *)RFIFOP(fd,8)); break;
+ case 0x3033: mapif->parse_GuildMasterChange(fd,RFIFOL(fd,4),(const char*)RFIFOP(fd,8),RFIFOW(fd,2)-8); break;
+ case 0x3034: mapif->parse_GuildLeave(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),(const char*)RFIFOP(fd,15)); break;
+ case 0x3035: mapif->parse_GuildChangeMemberInfoShort(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17)); break;
+ case 0x3036: mapif->parse_BreakGuild(fd,RFIFOL(fd,2)); break;
+ case 0x3037: mapif->parse_GuildMessage(fd,RFIFOL(fd,4),RFIFOL(fd,8),(char*)RFIFOP(fd,12),RFIFOW(fd,2)-12); break;
+ case 0x3039: mapif->parse_GuildBasicInfoChange(fd,RFIFOL(fd,4),RFIFOW(fd,8),(const int16 *)RFIFOP(fd,10),RFIFOW(fd,2)-10); break;
+ case 0x303A: mapif->parse_GuildMemberInfoChange(fd,RFIFOL(fd,4),RFIFOL(fd,8),RFIFOL(fd,12),RFIFOW(fd,16),(const char*)RFIFOP(fd,18),RFIFOW(fd,2)-18); break;
+ case 0x303B: mapif->parse_GuildPosition(fd,RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12)); break;
+ case 0x303C: mapif->parse_GuildSkillUp(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14)); break;
+ case 0x303D: mapif->parse_GuildAlliance(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),RFIFOB(fd,18)); break;
+ case 0x303E: mapif->parse_GuildNotice(fd,RFIFOL(fd,2),(const char*)RFIFOP(fd,6),(const char*)RFIFOP(fd,66)); break;
+ case 0x303F: mapif->parse_GuildEmblem(fd,RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8),(const char*)RFIFOP(fd,12)); break;
+ case 0x3040: mapif->parse_GuildCastleDataLoad(fd,RFIFOW(fd,2),(int *)RFIFOP(fd,4)); break;
+ case 0x3041: mapif->parse_GuildCastleDataSave(fd,RFIFOW(fd,2),RFIFOB(fd,4),RFIFOL(fd,5)); break;
default:
return 0;
@@ -1887,10 +1877,41 @@ int inter_guild_parse_frommap(int fd)
//Leave request from the server (for deleting character from guild)
int inter_guild_leave(int guild_id, int account_id, int char_id)
{
- return mapif_parse_GuildLeave(-1, guild_id, account_id, char_id, 0, "** Character Deleted **");
+ return mapif->parse_GuildLeave(-1, guild_id, account_id, char_id, 0, "** Character Deleted **");
}
int inter_guild_broken(int guild_id)
{
- return mapif_guild_broken(guild_id, 0);
+ return mapif->guild_broken(guild_id, 0);
+}
+
+void inter_guild_defaults(void)
+{
+ inter_guild = &inter_guild_s;
+
+ inter_guild->guild_db = NULL;
+ inter_guild->castle_db = NULL;
+
+ inter_guild->save_timer = inter_guild_save_timer;
+ inter_guild->removemember_tosql = inter_guild_removemember_tosql;
+ inter_guild->tosql = inter_guild_tosql;
+ inter_guild->fromsql = inter_guild_fromsql;
+ inter_guild->castle_tosql = inter_guild_castle_tosql;
+ inter_guild->castle_fromsql = inter_guild_castle_fromsql;
+ inter_guild->exp_parse_row = inter_guild_exp_parse_row;
+ inter_guild->CharOnline = inter_guild_CharOnline;
+ inter_guild->CharOffline = inter_guild_CharOffline;
+ inter_guild->sql_init = inter_guild_sql_init;
+ inter_guild->db_final = inter_guild_db_final;
+ inter_guild->sql_final = inter_guild_sql_final;
+ inter_guild->search_guildname = inter_guild_search_guildname;
+ inter_guild->check_empty = inter_guild_check_empty;
+ inter_guild->nextexp = inter_guild_nextexp;
+ inter_guild->checkskill = inter_guild_checkskill;
+ inter_guild->calcinfo = inter_guild_calcinfo;
+ inter_guild->sex_changed = inter_guild_sex_changed;
+ inter_guild->charname_changed = inter_guild_charname_changed;
+ inter_guild->parse_frommap = inter_guild_parse_frommap;
+ inter_guild->leave = inter_guild_leave;
+ inter_guild->broken = inter_guild_broken;
}
diff --git a/src/char/int_guild.h b/src/char/int_guild.h
index bc457d86b..960150f4f 100644
--- a/src/char/int_guild.h
+++ b/src/char/int_guild.h
@@ -4,6 +4,8 @@
#ifndef CHAR_INT_GUILD_H
#define CHAR_INT_GUILD_H
+#include "../common/mmo.h"
+
enum {
GS_BASIC = 0x0001,
GS_MEMBER = 0x0002,
@@ -20,15 +22,40 @@ enum {
GS_REMOVE = 0x8000,
};
-int inter_guild_parse_frommap(int fd);
-int inter_guild_sql_init(void);
-void inter_guild_sql_final(void);
-int inter_guild_leave(int guild_id,int account_id,int char_id);
-int mapif_parse_BreakGuild(int fd,int guild_id);
-int inter_guild_broken(int guild_id);
-int inter_guild_sex_changed(int guild_id,int account_id,int char_id, short gender);
-int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char *name);
-int inter_guild_CharOnline(int char_id, int guild_id);
-int inter_guild_CharOffline(int char_id, int guild_id);
+void inter_guild_defaults(void);
+
+/**
+ * inter_guild interface
+ **/
+struct inter_guild_interface {
+ DBMap* guild_db; // int guild_id -> struct guild*
+ DBMap* castle_db;
+ unsigned int exp[MAX_GUILDLEVEL];
+
+ int (*save_timer) (int tid, int64 tick, int id, intptr_t data);
+ int (*removemember_tosql) (int account_id, int char_id);
+ int (*tosql) (struct guild *g, int flag);
+ struct guild* (*fromsql) (int guild_id);
+ int (*castle_tosql) (struct guild_castle *gc);
+ struct guild_castle* (*castle_fromsql) (int castle_id);
+ bool (*exp_parse_row) (char* split[], int column, int current);
+ int (*CharOnline) (int char_id, int guild_id);
+ int (*CharOffline) (int char_id, int guild_id);
+ int (*sql_init) (void);
+ int (*db_final) (DBKey key, DBData *data, va_list ap);
+ void (*sql_final) (void);
+ int (*search_guildname) (char *str);
+ bool (*check_empty) (struct guild *g);
+ unsigned int (*nextexp) (int level);
+ int (*checkskill) (struct guild *g, int id);
+ int (*calcinfo) (struct guild *g);
+ int (*sex_changed) (int guild_id, int account_id, int char_id, short gender);
+ int (*charname_changed) (int guild_id, int account_id, int char_id, char *name);
+ int (*parse_frommap) (int fd);
+ int (*leave) (int guild_id, int account_id, int char_id);
+ int (*broken) (int guild_id);
+};
+
+struct inter_guild_interface *inter_guild;
#endif /* CHAR_INT_GUILD_H */
diff --git a/src/char/int_homun.c b/src/char/int_homun.c
index acde9eb38..7f9323bdd 100644
--- a/src/char/int_homun.c
+++ b/src/char/int_homun.c
@@ -12,6 +12,7 @@
#include "char.h"
#include "inter.h"
+#include "mapif.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/showmsg.h"
@@ -20,6 +21,8 @@
#include "../common/strlib.h"
#include "../common/utils.h"
+struct inter_homunculus_interface inter_homunculus_s;
+
int inter_homunculus_sql_init(void)
{
return 0;
@@ -29,7 +32,7 @@ void inter_homunculus_sql_final(void)
return;
}
-static void mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, unsigned char flag)
+void mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, unsigned char flag)
{
WFIFOHEAD(fd, sizeof(struct s_homunculus)+9);
WFIFOW(fd,0) = 0x3890;
@@ -40,7 +43,7 @@ static void mapif_homunculus_created(int fd, int account_id, struct s_homunculus
WFIFOSET(fd, WFIFOW(fd,2));
}
-static void mapif_homunculus_deleted(int fd, int flag)
+void mapif_homunculus_deleted(int fd, int flag)
{
WFIFOHEAD(fd, 3);
WFIFOW(fd, 0) = 0x3893;
@@ -48,7 +51,7 @@ static void mapif_homunculus_deleted(int fd, int flag)
WFIFOSET(fd, 3);
}
-static void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd)
+void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd)
{
WFIFOHEAD(fd, sizeof(struct s_homunculus)+9);
WFIFOW(fd,0) = 0x3891;
@@ -67,7 +70,7 @@ static void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus
WFIFOSET(fd, sizeof(struct s_homunculus)+9);
}
-static void mapif_homunculus_saved(int fd, int account_id, bool flag)
+void mapif_homunculus_saved(int fd, int account_id, bool flag)
{
WFIFOHEAD(fd, 7);
WFIFOW(fd,0) = 0x3892;
@@ -76,7 +79,7 @@ static void mapif_homunculus_saved(int fd, int account_id, bool flag)
WFIFOSET(fd, 7);
}
-static void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, char* name)
+void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, char* name)
{
WFIFOHEAD(fd, NAME_LENGTH+12);
WFIFOW(fd, 0) = 0x3894;
@@ -92,31 +95,31 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
bool flag = true;
char esc_name[NAME_LENGTH*2+1];
- SQL->EscapeStringLen(sql_handle, esc_name, hd->name, strnlen(hd->name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, hd->name, strnlen(hd->name, NAME_LENGTH));
if( hd->hom_id == 0 )
{// new homunculus
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` "
"(`char_id`, `class`,`prev_class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`, `rename_flag`, `vaporize`) "
"VALUES ('%d', '%d', '%d', '%s', '%d', '%u', '%u', '%d', '%d', %d, '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
homunculus_db, hd->char_id, hd->class_, hd->prev_class, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
flag = false;
}
else
{
- hd->hom_id = (int)SQL->LastInsertId(sql_handle);
+ hd->hom_id = (int)SQL->LastInsertId(inter->sql_handle);
}
}
else
{
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `char_id`='%d', `class`='%d',`prev_class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `char_id`='%d', `class`='%d',`prev_class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'",
homunculus_db, hd->char_id, hd->class_, hd->prev_class, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize, hd->hom_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
flag = false;
}
else
@@ -124,7 +127,7 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
SqlStmt* stmt;
int i;
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_ERROR == SQL->StmtPrepare(stmt, "REPLACE INTO `%s` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", skill_homunculus_db, hd->hom_id) )
SqlStmt_ShowDebug(stmt);
for( i = 0; i < MAX_HOMUNSKILL; ++i )
@@ -149,8 +152,6 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
return flag;
}
-
-
// Load an homunculus
bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
{
@@ -160,61 +161,61 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
memset(hd, 0, sizeof(*hd));
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `homun_id`,`char_id`,`class`,`prev_class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `%s` WHERE `homun_id`='%u'", homunculus_db, homun_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `homun_id`,`char_id`,`class`,`prev_class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `%s` WHERE `homun_id`='%u'", homunculus_db, homun_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
- if( !SQL->NumRows(sql_handle) )
- { //No homunculus found.
- SQL->FreeResult(sql_handle);
+ if (!SQL->NumRows(inter->sql_handle)) {
+ //No homunculus found.
+ SQL->FreeResult(inter->sql_handle);
return false;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
- Sql_ShowDebug(sql_handle);
- SQL->FreeResult(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return false;
}
hd->hom_id = homun_id;
- SQL->GetData(sql_handle, 1, &data, NULL); hd->char_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); hd->class_ = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); hd->prev_class = atoi(data);
- SQL->GetData(sql_handle, 4, &data, &len); safestrncpy(hd->name, data, sizeof(hd->name));
- SQL->GetData(sql_handle, 5, &data, NULL); hd->level = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); hd->exp = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); hd->intimacy = (unsigned int)strtoul(data, NULL, 10);
- SQL->GetData(sql_handle, 8, &data, NULL); hd->hunger = atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); hd->str = atoi(data);
- SQL->GetData(sql_handle, 10, &data, NULL); hd->agi = atoi(data);
- SQL->GetData(sql_handle, 11, &data, NULL); hd->vit = atoi(data);
- SQL->GetData(sql_handle, 12, &data, NULL); hd->int_ = atoi(data);
- SQL->GetData(sql_handle, 13, &data, NULL); hd->dex = atoi(data);
- SQL->GetData(sql_handle, 14, &data, NULL); hd->luk = atoi(data);
- SQL->GetData(sql_handle, 15, &data, NULL); hd->hp = atoi(data);
- SQL->GetData(sql_handle, 16, &data, NULL); hd->max_hp = atoi(data);
- SQL->GetData(sql_handle, 17, &data, NULL); hd->sp = atoi(data);
- SQL->GetData(sql_handle, 18, &data, NULL); hd->max_sp = atoi(data);
- SQL->GetData(sql_handle, 19, &data, NULL); hd->skillpts = atoi(data);
- SQL->GetData(sql_handle, 20, &data, NULL); hd->rename_flag = atoi(data);
- SQL->GetData(sql_handle, 21, &data, NULL); hd->vaporize = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); hd->char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); hd->class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); hd->prev_class = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, &len); safestrncpy(hd->name, data, sizeof(hd->name));
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); hd->level = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); hd->exp = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); hd->intimacy = (unsigned int)strtoul(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); hd->hunger = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); hd->str = atoi(data);
+ SQL->GetData(inter->sql_handle, 10, &data, NULL); hd->agi = atoi(data);
+ SQL->GetData(inter->sql_handle, 11, &data, NULL); hd->vit = atoi(data);
+ SQL->GetData(inter->sql_handle, 12, &data, NULL); hd->int_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 13, &data, NULL); hd->dex = atoi(data);
+ SQL->GetData(inter->sql_handle, 14, &data, NULL); hd->luk = atoi(data);
+ SQL->GetData(inter->sql_handle, 15, &data, NULL); hd->hp = atoi(data);
+ SQL->GetData(inter->sql_handle, 16, &data, NULL); hd->max_hp = atoi(data);
+ SQL->GetData(inter->sql_handle, 17, &data, NULL); hd->sp = atoi(data);
+ SQL->GetData(inter->sql_handle, 18, &data, NULL); hd->max_sp = atoi(data);
+ SQL->GetData(inter->sql_handle, 19, &data, NULL); hd->skillpts = atoi(data);
+ SQL->GetData(inter->sql_handle, 20, &data, NULL); hd->rename_flag = atoi(data);
+ SQL->GetData(inter->sql_handle, 21, &data, NULL); hd->vaporize = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
hd->intimacy = cap_value(hd->intimacy, 0, 100000);
hd->hunger = cap_value(hd->hunger, 0, 100);
// Load Homunculus Skill
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `homun_id`=%d", skill_homunculus_db, homun_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `homun_id`=%d", skill_homunculus_db, homun_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
- while( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ while( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
// id
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
i = atoi(data);
if( i < HM_SKILLBASE || i >= HM_SKILLBASE + MAX_HOMUNSKILL )
continue;// invalid skill id
@@ -222,10 +223,10 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
hd->hskill[i].id = (unsigned short)atoi(data);
// lv
- SQL->GetData(sql_handle, 1, &data, NULL);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL);
hd->hskill[i].lv = (unsigned char)atoi(data);
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
if( save_log )
ShowInfo("Homunculus loaded (%d - %s).\n", hd->hom_id, hd->name);
@@ -235,10 +236,10 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
bool mapif_homunculus_delete(int homun_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", homunculus_db, homun_id)
- || SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", skill_homunculus_db, homun_id)
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", homunculus_db, homun_id)
+ || SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", skill_homunculus_db, homun_id)
) {
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
return true;
@@ -266,35 +267,35 @@ bool mapif_homunculus_rename(char *name)
}
-static void mapif_parse_homunculus_create(int fd, int len, int account_id, struct s_homunculus* phd)
+void mapif_parse_homunculus_create(int fd, int len, int account_id, struct s_homunculus* phd)
{
- bool result = mapif_homunculus_save(phd);
- mapif_homunculus_created(fd, account_id, phd, result);
+ bool result = mapif->homunculus_save(phd);
+ mapif->homunculus_created(fd, account_id, phd, result);
}
-static void mapif_parse_homunculus_delete(int fd, int homun_id)
+void mapif_parse_homunculus_delete(int fd, int homun_id)
{
- bool result = mapif_homunculus_delete(homun_id);
- mapif_homunculus_deleted(fd, result);
+ bool result = mapif->homunculus_delete(homun_id);
+ mapif->homunculus_deleted(fd, result);
}
-static void mapif_parse_homunculus_load(int fd, int account_id, int homun_id)
+void mapif_parse_homunculus_load(int fd, int account_id, int homun_id)
{
struct s_homunculus hd;
- bool result = mapif_homunculus_load(homun_id, &hd);
- mapif_homunculus_loaded(fd, account_id, ( result ? &hd : NULL ));
+ bool result = mapif->homunculus_load(homun_id, &hd);
+ mapif->homunculus_loaded(fd, account_id, ( result ? &hd : NULL ));
}
-static void mapif_parse_homunculus_save(int fd, int len, int account_id, struct s_homunculus* phd)
+void mapif_parse_homunculus_save(int fd, int len, int account_id, struct s_homunculus* phd)
{
- bool result = mapif_homunculus_save(phd);
- mapif_homunculus_saved(fd, account_id, result);
+ bool result = mapif->homunculus_save(phd);
+ mapif->homunculus_saved(fd, account_id, result);
}
-static void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, char* name)
+void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, char* name)
{
- bool result = mapif_homunculus_rename(name);
- mapif_homunculus_renamed(fd, account_id, char_id, result, name);
+ bool result = mapif->homunculus_rename(name);
+ mapif->homunculus_renamed(fd, account_id, char_id, result, name);
}
/*==========================================
@@ -306,13 +307,22 @@ int inter_homunculus_parse_frommap(int fd)
switch( cmd )
{
- case 0x3090: mapif_parse_homunculus_create(fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break;
- case 0x3091: mapif_parse_homunculus_load (fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
- case 0x3092: mapif_parse_homunculus_save (fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break;
- case 0x3093: mapif_parse_homunculus_delete(fd, (int)RFIFOL(fd,2)); break;
- case 0x3094: mapif_parse_homunculus_rename(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6), (char*)RFIFOP(fd,10)); break;
+ case 0x3090: mapif->parse_homunculus_create(fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break;
+ case 0x3091: mapif->parse_homunculus_load (fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
+ case 0x3092: mapif->parse_homunculus_save (fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break;
+ case 0x3093: mapif->parse_homunculus_delete(fd, (int)RFIFOL(fd,2)); break;
+ case 0x3094: mapif->parse_homunculus_rename(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6), (char*)RFIFOP(fd,10)); break;
default:
return 0;
}
return 1;
}
+
+void inter_homunculus_defaults(void)
+{
+ inter_homunculus = &inter_homunculus_s;
+
+ inter_homunculus->sql_init = inter_homunculus_sql_init;
+ inter_homunculus->sql_final = inter_homunculus_sql_final;
+ inter_homunculus->parse_frommap = inter_homunculus_parse_frommap;
+}
diff --git a/src/char/int_homun.h b/src/char/int_homun.h
index 6fa4f9dc7..5bfa355d4 100644
--- a/src/char/int_homun.h
+++ b/src/char/int_homun.h
@@ -8,13 +8,17 @@
struct s_homunculus;
-int inter_homunculus_sql_init(void);
-void inter_homunculus_sql_final(void);
-int inter_homunculus_parse_frommap(int fd);
+void inter_homunculus_defaults(void);
-bool mapif_homunculus_save(struct s_homunculus* hd);
-bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd);
-bool mapif_homunculus_delete(int homun_id);
-bool mapif_homunculus_rename(char *name);
+/**
+ * inter_homunculus interface
+ **/
+struct inter_homunculus_interface {
+ int (*sql_init) (void);
+ void (*sql_final) (void);
+ int (*parse_frommap) (int fd);
+};
+
+struct inter_homunculus_interface *inter_homunculus;
#endif /* CHAR_INT_HOMUN_H */
diff --git a/src/char/int_mail.c b/src/char/int_mail.c
index 86a36d59f..2c0a85f33 100644
--- a/src/char/int_mail.c
+++ b/src/char/int_mail.c
@@ -12,6 +12,7 @@
#include "char.h"
#include "inter.h"
+#include "mapif.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/showmsg.h"
@@ -20,7 +21,9 @@
#include "../common/strlib.h"
#include "../common/timer.h"
-static int mail_fromsql(int char_id, struct mail_data* md)
+struct inter_mail_interface inter_mail_s;
+
+static int inter_mail_fromsql(int char_id, struct mail_data* md)
{
int i, j;
struct mail_message *msg;
@@ -42,45 +45,45 @@ static int mail_fromsql(int char_id, struct mail_data* md)
StrBuf->Printf(&buf, " FROM `%s` WHERE `dest_id`='%d' AND `status` < 3 ORDER BY `id` LIMIT %d",
mail_db, char_id, MAIL_MAX_INBOX + 1);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)) )
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
- for (i = 0; i < MAIL_MAX_INBOX && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for (i = 0; i < MAIL_MAX_INBOX && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
msg = &md->msg[i];
- SQL->GetData(sql_handle, 0, &data, NULL); msg->id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 2, &data, NULL); msg->send_id = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 4, &data, NULL); msg->dest_id = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
- SQL->GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
- SQL->GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); msg->id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); msg->send_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); msg->dest_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
item = &msg->item;
- SQL->GetData(sql_handle,10, &data, NULL); item->amount = (short)atoi(data);
- SQL->GetData(sql_handle,11, &data, NULL); item->nameid = atoi(data);
- SQL->GetData(sql_handle,12, &data, NULL); item->refine = atoi(data);
- SQL->GetData(sql_handle,13, &data, NULL); item->attribute = atoi(data);
- SQL->GetData(sql_handle,14, &data, NULL); item->identify = atoi(data);
- SQL->GetData(sql_handle,15, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle,10, &data, NULL); item->amount = (short)atoi(data);
+ SQL->GetData(inter->sql_handle,11, &data, NULL); item->nameid = atoi(data);
+ SQL->GetData(inter->sql_handle,12, &data, NULL); item->refine = atoi(data);
+ SQL->GetData(inter->sql_handle,13, &data, NULL); item->attribute = atoi(data);
+ SQL->GetData(inter->sql_handle,14, &data, NULL); item->identify = atoi(data);
+ SQL->GetData(inter->sql_handle,15, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
item->expire_time = 0;
item->bound = 0;
for (j = 0; j < MAX_SLOTS; j++)
{
- SQL->GetData(sql_handle, 16 + j, &data, NULL);
+ SQL->GetData(inter->sql_handle, 16 + j, &data, NULL);
item->card[j] = atoi(data);
}
}
- md->full = ( SQL->NumRows(sql_handle) > MAIL_MAX_INBOX );
+ md->full = ( SQL->NumRows(inter->sql_handle) > MAIL_MAX_INBOX );
md->amount = i;
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
md->unchecked = 0;
md->unread = 0;
@@ -89,8 +92,8 @@ static int mail_fromsql(int char_id, struct mail_data* md)
msg = &md->msg[i];
if( msg->status == MAIL_NEW )
{
- if ( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_UNREAD, msg->id) )
- Sql_ShowDebug(sql_handle);
+ if ( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_UNREAD, msg->id) )
+ Sql_ShowDebug(inter->sql_handle);
msg->status = MAIL_UNREAD;
md->unchecked++;
@@ -105,7 +108,7 @@ static int mail_fromsql(int char_id, struct mail_data* md)
/// Stores a single message in the database.
/// Returns the message's ID if successful (or 0 if it fails).
-int mail_savemessage(struct mail_message* msg)
+int inter_mail_savemessage(struct mail_message* msg)
{
StringBuf buf;
SqlStmt* stmt;
@@ -123,7 +126,7 @@ int mail_savemessage(struct mail_message* msg)
StrBuf->AppendStr(&buf, ")");
// prepare and execute query
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_SUCCESS != SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, msg->send_name, strnlen(msg->send_name, NAME_LENGTH))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, msg->dest_name, strnlen(msg->dest_name, NAME_LENGTH))
@@ -144,10 +147,11 @@ int mail_savemessage(struct mail_message* msg)
/// Retrieves a single message from the database.
/// Returns true if the operation succeeds (or false if it fails).
-static bool mail_loadmessage(int mail_id, struct mail_message* msg)
+static bool inter_mail_loadmessage(int mail_id, struct mail_message* msg)
{
int j;
StringBuf buf;
+ memset(msg, 0, sizeof(struct mail_message)); // Initialize data
StrBuf->Init(&buf);
StrBuf->AppendStr(&buf, "SELECT `id`,`send_name`,`send_id`,`dest_name`,`dest_id`,`title`,`message`,`time`,`status`,"
@@ -156,11 +160,11 @@ static bool mail_loadmessage(int mail_id, struct mail_message* msg)
StrBuf->Printf(&buf, ",`card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `id` = '%d'", mail_db, mail_id);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf))
- || SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf))
+ || SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
- Sql_ShowDebug(sql_handle);
- SQL->FreeResult(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
+ SQL->FreeResult(inter->sql_handle);
StrBuf->Destroy(&buf);
return false;
}
@@ -168,75 +172,77 @@ static bool mail_loadmessage(int mail_id, struct mail_message* msg)
{
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL); msg->id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 2, &data, NULL); msg->send_id = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 4, &data, NULL); msg->dest_id = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
- SQL->GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
- SQL->GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
- SQL->GetData(sql_handle,10, &data, NULL); msg->item.amount = (short)atoi(data);
- SQL->GetData(sql_handle,11, &data, NULL); msg->item.nameid = atoi(data);
- SQL->GetData(sql_handle,12, &data, NULL); msg->item.refine = atoi(data);
- SQL->GetData(sql_handle,13, &data, NULL); msg->item.attribute = atoi(data);
- SQL->GetData(sql_handle,14, &data, NULL); msg->item.identify = atoi(data);
- SQL->GetData(sql_handle,15, &data, NULL); msg->item.unique_id = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); msg->id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); msg->send_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); msg->dest_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
+ SQL->GetData(inter->sql_handle,10, &data, NULL); msg->item.amount = (short)atoi(data);
+ SQL->GetData(inter->sql_handle,11, &data, NULL); msg->item.nameid = atoi(data);
+ SQL->GetData(inter->sql_handle,12, &data, NULL); msg->item.refine = atoi(data);
+ SQL->GetData(inter->sql_handle,13, &data, NULL); msg->item.attribute = atoi(data);
+ SQL->GetData(inter->sql_handle,14, &data, NULL); msg->item.identify = atoi(data);
+ SQL->GetData(inter->sql_handle,15, &data, NULL); msg->item.unique_id = strtoull(data, NULL, 10);
msg->item.expire_time = 0;
msg->item.bound = 0;
for( j = 0; j < MAX_SLOTS; j++ )
{
- SQL->GetData(sql_handle,16 + j, &data, NULL);
+ SQL->GetData(inter->sql_handle,16 + j, &data, NULL);
msg->item.card[j] = atoi(data);
}
}
StrBuf->Destroy(&buf);
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return true;
}
-/*==========================================
- * Client Inbox Request
- *------------------------------------------*/
-static void mapif_Mail_sendinbox(int fd, int char_id, unsigned char flag)
+void mapif_mail_sendinbox(int fd, int char_id, unsigned char flag, struct mail_data *md)
{
- struct mail_data md;
- mail_fromsql(char_id, &md);
-
//FIXME: dumping the whole structure like this is unsafe [ultramage]
- WFIFOHEAD(fd, sizeof(md) + 9);
+ WFIFOHEAD(fd, sizeof(struct mail_data) + 9);
WFIFOW(fd,0) = 0x3848;
- WFIFOW(fd,2) = sizeof(md) + 9;
+ WFIFOW(fd,2) = sizeof(struct mail_data) + 9;
WFIFOL(fd,4) = char_id;
WFIFOB(fd,8) = flag;
- memcpy(WFIFOP(fd,9),&md,sizeof(md));
+ memcpy(WFIFOP(fd,9),md,sizeof(struct mail_data));
WFIFOSET(fd,WFIFOW(fd,2));
}
-static void mapif_parse_Mail_requestinbox(int fd)
+/*==========================================
+ * Client Inbox Request
+ *------------------------------------------*/
+void mapif_parse_mail_requestinbox(int fd)
{
- mapif_Mail_sendinbox(fd, RFIFOL(fd,2), RFIFOB(fd,6));
+ int char_id = RFIFOL(fd,2);
+ unsigned char flag = RFIFOB(fd,6);
+ struct mail_data md;
+ memset(&md, 0, sizeof(md));
+ inter_mail->fromsql(char_id, &md);
+ mapif->mail_sendinbox(fd, char_id, flag, &md);
}
/*==========================================
* Mark mail as 'Read'
*------------------------------------------*/
-static void mapif_parse_Mail_read(int fd)
+void mapif_parse_mail_read(int fd)
{
int mail_id = RFIFOL(fd,2);
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_READ, mail_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_READ, mail_id) )
+ Sql_ShowDebug(inter->sql_handle);
}
/*==========================================
* Client Attachment Request
*------------------------------------------*/
-static bool mail_DeleteAttach(int mail_id)
+static bool inter_mail_DeleteAttach(int mail_id)
{
StringBuf buf;
int i;
@@ -247,9 +253,9 @@ static bool mail_DeleteAttach(int mail_id)
StrBuf->Printf(&buf, ", `card%d` = '0'", i);
StrBuf->Printf(&buf, " WHERE `id` = '%d'", mail_id);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
return false;
@@ -259,11 +265,23 @@ static bool mail_DeleteAttach(int mail_id)
return true;
}
-static void mapif_Mail_getattach(int fd, int char_id, int mail_id)
+void mapif_mail_sendattach(int fd, int char_id, struct mail_message *msg)
+{
+ WFIFOHEAD(fd, sizeof(struct item) + 12);
+ WFIFOW(fd,0) = 0x384a;
+ WFIFOW(fd,2) = sizeof(struct item) + 12;
+ WFIFOL(fd,4) = char_id;
+ WFIFOL(fd,8) = (msg->zeny > 0)?msg->zeny:0;
+ memcpy(WFIFOP(fd,12), &msg->item, sizeof(struct item));
+ WFIFOSET(fd,WFIFOW(fd,2));
+}
+
+void mapif_mail_getattach(int fd, int char_id, int mail_id)
{
struct mail_message msg;
+ memset(&msg, 0, sizeof(msg));
- if( !mail_loadmessage(mail_id, &msg) )
+ if( !inter_mail->loadmessage(mail_id, &msg) )
return;
if( msg.dest_id != char_id )
@@ -275,35 +293,22 @@ static void mapif_Mail_getattach(int fd, int char_id, int mail_id)
if( (msg.item.nameid < 1 || msg.item.amount < 1) && msg.zeny < 1 )
return; // No Attachment
- if( !mail_DeleteAttach(mail_id) )
+ if( !inter_mail->DeleteAttach(mail_id) )
return;
- WFIFOHEAD(fd, sizeof(struct item) + 12);
- WFIFOW(fd,0) = 0x384a;
- WFIFOW(fd,2) = sizeof(struct item) + 12;
- WFIFOL(fd,4) = char_id;
- WFIFOL(fd,8) = (msg.zeny > 0)?msg.zeny:0;
- memcpy(WFIFOP(fd,12), &msg.item, sizeof(struct item));
- WFIFOSET(fd,WFIFOW(fd,2));
+ mapif->mail_sendattach(fd, char_id, &msg);
}
-static void mapif_parse_Mail_getattach(int fd)
+void mapif_parse_mail_getattach(int fd)
{
- mapif_Mail_getattach(fd, RFIFOL(fd,2), RFIFOL(fd,6));
+ mapif->mail_getattach(fd, RFIFOL(fd,2), RFIFOL(fd,6));
}
/*==========================================
* Delete Mail
*------------------------------------------*/
-static void mapif_Mail_delete(int fd, int char_id, int mail_id)
+void mapif_mail_delete(int fd, int char_id, int mail_id, bool failed)
{
- bool failed = false;
- if ( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
- {
- Sql_ShowDebug(sql_handle);
- failed = true;
- }
-
WFIFOHEAD(fd,11);
WFIFOW(fd,0) = 0x384b;
WFIFOL(fd,2) = char_id;
@@ -312,18 +317,26 @@ static void mapif_Mail_delete(int fd, int char_id, int mail_id)
WFIFOSET(fd,11);
}
-static void mapif_parse_Mail_delete(int fd)
+void mapif_parse_mail_delete(int fd)
{
- mapif_Mail_delete(fd, RFIFOL(fd,2), RFIFOL(fd,6));
+ int char_id = RFIFOL(fd,2);
+ int mail_id = RFIFOL(fd,6);
+ bool failed = false;
+ if ( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
+ {
+ Sql_ShowDebug(inter->sql_handle);
+ failed = true;
+ }
+ mapif->mail_delete(fd, char_id, mail_id, failed);
}
/*==========================================
* Report New Mail to Map Server
*------------------------------------------*/
-void mapif_Mail_new(struct mail_message *msg)
+void mapif_mail_new(struct mail_message *msg)
{
unsigned char buf[74];
-
+
if( !msg || !msg->id )
return;
@@ -332,23 +345,35 @@ void mapif_Mail_new(struct mail_message *msg)
WBUFL(buf,6) = msg->id;
memcpy(WBUFP(buf,10), msg->send_name, NAME_LENGTH);
memcpy(WBUFP(buf,34), msg->title, MAIL_TITLE_LENGTH);
- mapif_sendall(buf, 74);
+ mapif->sendall(buf, 74);
}
/*==========================================
* Return Mail
*------------------------------------------*/
-static void mapif_Mail_return(int fd, int char_id, int mail_id)
+void mapif_mail_return(int fd, int char_id, int mail_id, int new_mail)
+{
+ WFIFOHEAD(fd,11);
+ WFIFOW(fd,0) = 0x384c;
+ WFIFOL(fd,2) = char_id;
+ WFIFOL(fd,6) = mail_id;
+ WFIFOB(fd,10) = (new_mail == 0);
+ WFIFOSET(fd,11);
+}
+
+void mapif_parse_mail_return(int fd)
{
+ int char_id = RFIFOL(fd,2);
+ int mail_id = RFIFOL(fd,6);
struct mail_message msg;
int new_mail = 0;
- if( mail_loadmessage(mail_id, &msg) )
+ if( inter_mail->loadmessage(mail_id, &msg) )
{
if( msg.dest_id != char_id)
return;
- else if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
- Sql_ShowDebug(sql_handle);
+ else if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
+ Sql_ShowDebug(inter->sql_handle);
else
{
char temp_[MAIL_TITLE_LENGTH];
@@ -366,31 +391,21 @@ static void mapif_Mail_return(int fd, int char_id, int mail_id)
msg.status = MAIL_NEW;
msg.timestamp = time(NULL);
- new_mail = mail_savemessage(&msg);
- mapif_Mail_new(&msg);
+ new_mail = inter_mail->savemessage(&msg);
+ mapif->mail_new(&msg);
}
}
- WFIFOHEAD(fd,11);
- WFIFOW(fd,0) = 0x384c;
- WFIFOL(fd,2) = char_id;
- WFIFOL(fd,6) = mail_id;
- WFIFOB(fd,10) = (new_mail == 0);
- WFIFOSET(fd,11);
-}
-
-static void mapif_parse_Mail_return(int fd)
-{
- mapif_Mail_return(fd, RFIFOL(fd,2), RFIFOL(fd,6));
+ mapif->mail_return(fd, char_id, mail_id, new_mail);
}
/*==========================================
* Send Mail
*------------------------------------------*/
-static void mapif_Mail_send(int fd, struct mail_message* msg)
+void mapif_mail_send(int fd, struct mail_message* msg)
{
int len = sizeof(struct mail_message) + 4;
-
+
WFIFOHEAD(fd,len);
WFIFOW(fd,0) = 0x384d;
WFIFOW(fd,2) = len;
@@ -398,7 +413,7 @@ static void mapif_Mail_send(int fd, struct mail_message* msg)
WFIFOSET(fd,len);
}
-static void mapif_parse_Mail_send(int fd)
+void mapif_parse_mail_send(int fd)
{
struct mail_message msg;
char esc_name[NAME_LENGTH*2+1];
@@ -411,31 +426,31 @@ static void mapif_parse_Mail_send(int fd)
memcpy(&msg, RFIFOP(fd,8), sizeof(struct mail_message));
// Try to find the Dest Char by Name
- SQL->EscapeStringLen(sql_handle, esc_name, msg.dest_name, strnlen(msg.dest_name, NAME_LENGTH));
- if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`, `char_id` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
- Sql_ShowDebug(sql_handle);
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, msg.dest_name, strnlen(msg.dest_name, NAME_LENGTH));
+ if ( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`, `char_id` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
+ Sql_ShowDebug(inter->sql_handle);
else
- if ( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
char *data;
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
if (atoi(data) != account_id)
{ // Cannot send mail to char in the same account
- SQL->GetData(sql_handle, 1, &data, NULL);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL);
msg.dest_id = atoi(data);
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
msg.status = MAIL_NEW;
if( msg.dest_id > 0 )
- msg.id = mail_savemessage(&msg);
+ msg.id = inter_mail->savemessage(&msg);
- mapif_Mail_send(fd, &msg); // notify sender
- mapif_Mail_new(&msg); // notify recipient
+ mapif->mail_send(fd, &msg); // notify sender
+ mapif->mail_new(&msg); // notify recipient
}
-void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item)
+void inter_mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item)
{
struct mail_message msg;
memset(&msg, 0, sizeof(struct mail_message));
@@ -452,8 +467,8 @@ void mail_sendmail(int send_id, const char* send_name, int dest_id, const char*
msg.timestamp = time(NULL);
- mail_savemessage(&msg);
- mapif_Mail_new(&msg);
+ inter_mail->savemessage(&msg);
+ mapif->mail_new(&msg);
}
/*==========================================
@@ -463,12 +478,12 @@ int inter_mail_parse_frommap(int fd)
{
switch(RFIFOW(fd,0))
{
- case 0x3048: mapif_parse_Mail_requestinbox(fd); break;
- case 0x3049: mapif_parse_Mail_read(fd); break;
- case 0x304a: mapif_parse_Mail_getattach(fd); break;
- case 0x304b: mapif_parse_Mail_delete(fd); break;
- case 0x304c: mapif_parse_Mail_return(fd); break;
- case 0x304d: mapif_parse_Mail_send(fd); break;
+ case 0x3048: mapif->parse_mail_requestinbox(fd); break;
+ case 0x3049: mapif->parse_mail_read(fd); break;
+ case 0x304a: mapif->parse_mail_getattach(fd); break;
+ case 0x304b: mapif->parse_mail_delete(fd); break;
+ case 0x304c: mapif->parse_mail_return(fd); break;
+ case 0x304d: mapif->parse_mail_send(fd); break;
default:
return 0;
}
@@ -484,3 +499,17 @@ void inter_mail_sql_final(void)
{
return;
}
+
+void inter_mail_defaults(void)
+{
+ inter_mail = &inter_mail_s;
+
+ inter_mail->savemessage = inter_mail_savemessage;
+ inter_mail->DeleteAttach = inter_mail_DeleteAttach;
+ inter_mail->sendmail = inter_mail_sendmail;
+ inter_mail->parse_frommap = inter_mail_parse_frommap;
+ inter_mail->sql_init = inter_mail_sql_init;
+ inter_mail->sql_final = inter_mail_sql_final;
+ inter_mail->fromsql = inter_mail_fromsql;
+ inter_mail->loadmessage = inter_mail_loadmessage;
+}
diff --git a/src/char/int_mail.h b/src/char/int_mail.h
index 8800061d7..5ce7bafa2 100644
--- a/src/char/int_mail.h
+++ b/src/char/int_mail.h
@@ -4,16 +4,28 @@
#ifndef CHAR_INT_MAIL_H
#define CHAR_INT_MAIL_H
+#include "../common/cbasetypes.h"
+
struct item;
+struct mail_data;
struct mail_message;
-int inter_mail_parse_frommap(int fd);
-void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item);
+void inter_mail_defaults(void);
-int inter_mail_sql_init(void);
-void inter_mail_sql_final(void);
+/**
+ * inter_mail interface
+ **/
+struct inter_mail_interface {
+ int (*sql_init) (void);
+ void (*sql_final) (void);
+ int (*parse_frommap) (int fd);
+ int (*fromsql) (int char_id, struct mail_data* md);
+ int (*savemessage) (struct mail_message* msg);
+ bool (*loadmessage) (int mail_id, struct mail_message* msg);
+ bool (*DeleteAttach) (int mail_id);
+ void (*sendmail) (int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item);
+};
-int mail_savemessage(struct mail_message* msg);
-void mapif_Mail_new(struct mail_message *msg);
+struct inter_mail_interface *inter_mail;
#endif /* CHAR_INT_MAIL_H */
diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c
index 1dffb656c..2bd94b97e 100644
--- a/src/char/int_mercenary.c
+++ b/src/char/int_mercenary.c
@@ -12,6 +12,7 @@
#include "char.h"
#include "inter.h"
+#include "mapif.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/showmsg.h"
@@ -20,53 +21,55 @@
#include "../common/strlib.h"
#include "../common/utils.h"
-bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status)
+struct inter_mercenary_interface inter_mercenary_s;
+
+bool inter_mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status)
{
char* data;
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith` FROM `%s` WHERE `char_id` = '%d'", mercenary_owner_db, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith` FROM `%s` WHERE `char_id` = '%d'", mercenary_owner_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return false;
}
- SQL->GetData(sql_handle, 0, &data, NULL); status->mer_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); status->arch_calls = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); status->arch_faith = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); status->spear_calls = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); status->spear_faith = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); status->sword_calls = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); status->sword_faith = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); status->mer_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); status->arch_calls = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); status->arch_faith = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); status->spear_calls = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); status->spear_faith = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); status->sword_calls = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); status->sword_faith = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
return true;
}
-bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status)
+bool inter_mercenary_owner_tosql(int char_id, struct mmo_charstatus *status)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`char_id`, `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`char_id`, `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
mercenary_owner_db, char_id, status->mer_id, status->arch_calls, status->arch_faith, status->spear_calls, status->spear_faith, status->sword_calls, status->sword_faith) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
return true;
}
-bool mercenary_owner_delete(int char_id)
+bool inter_mercenary_owner_delete(int char_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_owner_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_owner_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
return true;
}
@@ -77,21 +80,21 @@ bool mapif_mercenary_save(struct s_mercenary* merc)
if( merc->mercenary_id == 0 )
{ // Create new DB entry
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"INSERT INTO `%s` (`char_id`,`class`,`hp`,`sp`,`kill_counter`,`life_time`) VALUES ('%d','%d','%d','%d','%u','%u')",
mercenary_db, merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
flag = false;
}
else
- merc->mercenary_id = (int)SQL->LastInsertId(sql_handle);
+ merc->mercenary_id = (int)SQL->LastInsertId(inter->sql_handle);
}
- else if( SQL_ERROR == SQL->Query(sql_handle,
+ else if( SQL_ERROR == SQL->Query(inter->sql_handle,
"UPDATE `%s` SET `char_id` = '%d', `class` = '%d', `hp` = '%d', `sp` = '%d', `kill_counter` = '%u', `life_time` = '%u' WHERE `mer_id` = '%d'",
mercenary_db, merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time, merc->mercenary_id) )
{ // Update DB entry
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
flag = false;
}
@@ -106,42 +109,42 @@ bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc)
merc->mercenary_id = merc_id;
merc->char_id = char_id;
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `class`, `hp`, `sp`, `kill_counter`, `life_time` FROM `%s` WHERE `mer_id` = '%d' AND `char_id` = '%d'", mercenary_db, merc_id, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `class`, `hp`, `sp`, `kill_counter`, `life_time` FROM `%s` WHERE `mer_id` = '%d' AND `char_id` = '%d'", mercenary_db, merc_id, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return false;
}
- SQL->GetData(sql_handle, 0, &data, NULL); merc->class_ = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); merc->hp = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); merc->sp = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); merc->kill_count = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); merc->life_time = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); merc->class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); merc->hp = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); merc->sp = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); merc->kill_count = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); merc->life_time = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
if( save_log )
ShowInfo("Mercenary loaded (%d - %d).\n", merc->mercenary_id, merc->char_id);
-
+
return true;
}
bool mapif_mercenary_delete(int merc_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `mer_id` = '%d'", mercenary_db, merc_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `mer_id` = '%d'", mercenary_db, merc_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
return true;
}
-static void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag)
+void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag)
{
int size = sizeof(struct s_mercenary) + 5;
@@ -153,20 +156,20 @@ static void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char
WFIFOSET(fd,size);
}
-static void mapif_parse_mercenary_create(int fd, struct s_mercenary* merc)
+void mapif_parse_mercenary_create(int fd, struct s_mercenary* merc)
{
- bool result = mapif_mercenary_save(merc);
- mapif_mercenary_send(fd, merc, result);
+ bool result = mapif->mercenary_save(merc);
+ mapif->mercenary_send(fd, merc, result);
}
-static void mapif_parse_mercenary_load(int fd, int merc_id, int char_id)
+void mapif_parse_mercenary_load(int fd, int merc_id, int char_id)
{
struct s_mercenary merc;
- bool result = mapif_mercenary_load(merc_id, char_id, &merc);
- mapif_mercenary_send(fd, &merc, result);
+ bool result = mapif->mercenary_load(merc_id, char_id, &merc);
+ mapif->mercenary_send(fd, &merc, result);
}
-static void mapif_mercenary_deleted(int fd, unsigned char flag)
+void mapif_mercenary_deleted(int fd, unsigned char flag)
{
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x3871;
@@ -174,13 +177,13 @@ static void mapif_mercenary_deleted(int fd, unsigned char flag)
WFIFOSET(fd,3);
}
-static void mapif_parse_mercenary_delete(int fd, int merc_id)
+void mapif_parse_mercenary_delete(int fd, int merc_id)
{
- bool result = mapif_mercenary_delete(merc_id);
- mapif_mercenary_deleted(fd, result);
+ bool result = mapif->mercenary_delete(merc_id);
+ mapif->mercenary_deleted(fd, result);
}
-static void mapif_mercenary_saved(int fd, unsigned char flag)
+void mapif_mercenary_saved(int fd, unsigned char flag)
{
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x3872;
@@ -188,10 +191,10 @@ static void mapif_mercenary_saved(int fd, unsigned char flag)
WFIFOSET(fd,3);
}
-static void mapif_parse_mercenary_save(int fd, struct s_mercenary* merc)
+void mapif_parse_mercenary_save(int fd, struct s_mercenary* merc)
{
- bool result = mapif_mercenary_save(merc);
- mapif_mercenary_saved(fd, result);
+ bool result = mapif->mercenary_save(merc);
+ mapif->mercenary_saved(fd, result);
}
int inter_mercenary_sql_init(void)
@@ -212,12 +215,25 @@ int inter_mercenary_parse_frommap(int fd)
switch( cmd )
{
- case 0x3070: mapif_parse_mercenary_create(fd, (struct s_mercenary*)RFIFOP(fd,4)); break;
- case 0x3071: mapif_parse_mercenary_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
- case 0x3072: mapif_parse_mercenary_delete(fd, (int)RFIFOL(fd,2)); break;
- case 0x3073: mapif_parse_mercenary_save(fd, (struct s_mercenary*)RFIFOP(fd,4)); break;
+ case 0x3070: mapif->parse_mercenary_create(fd, (struct s_mercenary*)RFIFOP(fd,4)); break;
+ case 0x3071: mapif->parse_mercenary_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
+ case 0x3072: mapif->parse_mercenary_delete(fd, (int)RFIFOL(fd,2)); break;
+ case 0x3073: mapif->parse_mercenary_save(fd, (struct s_mercenary*)RFIFOP(fd,4)); break;
default:
return 0;
}
return 1;
}
+
+void inter_mercenary_defaults(void)
+{
+ inter_mercenary = &inter_mercenary_s;
+
+ inter_mercenary->owner_fromsql = inter_mercenary_owner_fromsql;
+ inter_mercenary->owner_tosql = inter_mercenary_owner_tosql;
+ inter_mercenary->owner_delete = inter_mercenary_owner_delete;
+
+ inter_mercenary->sql_init = inter_mercenary_sql_init;
+ inter_mercenary->sql_final = inter_mercenary_sql_final;
+ inter_mercenary->parse_frommap = inter_mercenary_parse_frommap;
+}
diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h
index b03c20de3..b22ea61b2 100644
--- a/src/char/int_mercenary.h
+++ b/src/char/int_mercenary.h
@@ -8,15 +8,20 @@
struct mmo_charstatus;
-int inter_mercenary_sql_init(void);
-void inter_mercenary_sql_final(void);
-int inter_mercenary_parse_frommap(int fd);
+void inter_mercenary_defaults(void);
-// Mercenary Owner Database
-bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status);
-bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status);
-bool mercenary_owner_delete(int char_id);
+/**
+ * inter_mercenary interface
+ **/
+struct inter_mercenary_interface {
+ bool (*owner_fromsql) (int char_id, struct mmo_charstatus *status);
+ bool (*owner_tosql) (int char_id, struct mmo_charstatus *status);
+ bool (*owner_delete) (int char_id);
+ int (*sql_init) (void);
+ void (*sql_final) (void);
+ int (*parse_frommap) (int fd);
+};
-bool mapif_mercenary_delete(int merc_id);
+struct inter_mercenary_interface *inter_mercenary;
#endif /* CHAR_INT_MERCENARY_H */
diff --git a/src/char/int_party.c b/src/char/int_party.c
index a8722fbe3..b16f106be 100644
--- a/src/char/int_party.c
+++ b/src/char/int_party.c
@@ -12,6 +12,7 @@
#include "char.h"
#include "inter.h"
+#include "mapif.h"
#include "../common/cbasetypes.h"
#include "../common/db.h"
#include "../common/malloc.h"
@@ -22,24 +23,10 @@
#include "../common/sql.h"
#include "../common/strlib.h"
-struct party_data {
- struct party party;
- unsigned int min_lv, max_lv;
- int family; //Is this party a family? if so, this holds the child id.
- unsigned char size; //Total size of party.
-};
-
-static struct party_data *party_pt;
-static DBMap* party_db_; // int party_id -> struct party_data*
-
-int mapif_party_broken(int party_id,int flag);
-int party_check_empty(struct party_data *p);
-int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id);
-int party_check_exp_share(struct party_data *p);
-int mapif_party_optionchanged(int fd,struct party *p, int account_id, int flag);
+struct inter_party_interface inter_party_s;
//Updates party's level range and unsets even share if broken.
-static int int_party_check_lv(struct party_data *p) {
+static int inter_party_check_lv(struct party_data *p) {
int i;
unsigned int lv;
p->min_lv = UINT_MAX;
@@ -56,15 +43,15 @@ static int int_party_check_lv(struct party_data *p) {
if (lv > p->max_lv) p->max_lv = lv;
}
- if (p->party.exp && !party_check_exp_share(p)) {
+ if (p->party.exp && !inter_party->check_exp_share(p)) {
p->party.exp = 0;
- mapif_party_optionchanged(0, &p->party, 0, 0);
+ mapif->party_optionchanged(0, &p->party, 0, 0);
return 0;
}
return 1;
}
//Calculates the state of a party.
-static void int_party_calc_state(struct party_data *p)
+static void inter_party_calc_state(struct party_data *p)
{
int i;
unsigned int lv;
@@ -81,7 +68,7 @@ static void int_party_calc_state(struct party_data *p)
if(p->party.member[i].online)
p->party.count++;
}
- if( p->size == 2 && ( char_child(p->party.member[0].char_id,p->party.member[1].char_id) || char_child(p->party.member[1].char_id,p->party.member[0].char_id) ) ) {
+ if( p->size == 2 && ( chr->char_child(p->party.member[0].char_id,p->party.member[1].char_id) || chr->char_child(p->party.member[1].char_id,p->party.member[0].char_id) ) ) {
//Child should be able to share with either of their parents [RoM]
if(p->party.member[0].class_&0x2000) //first slot is the child?
p->family = p->party.member[0].char_id;
@@ -89,7 +76,7 @@ static void int_party_calc_state(struct party_data *p)
p->family = p->party.member[1].char_id;
} else if( p->size == 3 ) {
//Check Family State.
- p->family = char_family(
+ p->family = chr->char_family(
p->party.member[0].char_id,
p->party.member[1].char_id,
p->party.member[2].char_id
@@ -108,9 +95,9 @@ static void int_party_calc_state(struct party_data *p)
}
}
- if (p->party.exp && !party_check_exp_share(p)) {
+ if (p->party.exp && !inter_party->check_exp_share(p)) {
p->party.exp = 0; //Set off even share.
- mapif_party_optionchanged(0, &p->party, 0, 0);
+ mapif->party_optionchanged(0, &p->party, 0, 0);
}
return;
}
@@ -129,59 +116,59 @@ int inter_party_tosql(struct party *p, int flag, int index)
#ifdef NOISY
ShowInfo("Save party request ("CL_BOLD"%d"CL_RESET" - %s).\n", party_id, p->name);
#endif
- SQL->EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
if( flag & PS_BREAK )
{// Break the party
// we'll skip name-checking and just reset everyone with the same party id [celest]
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
+ Sql_ShowDebug(inter->sql_handle);
//Remove from memory
- idb_remove(party_db_, party_id);
+ idb_remove(inter_party->db, party_id);
return 1;
}
if( flag & PS_CREATE )
{// Create party
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` "
"(`name`, `exp`, `item`, `leader_id`, `leader_char`) "
"VALUES ('%s', '%d', '%d', '%d', '%d')",
party_db, esc_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- party_id = p->party_id = (int)SQL->LastInsertId(sql_handle);
+ party_id = p->party_id = (int)SQL->LastInsertId(inter->sql_handle);
}
if( flag & PS_BASIC )
{// Update party info.
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d' WHERE `party_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d' WHERE `party_id`='%d'",
party_db, esc_name, p->exp, p->item, party_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
if( flag & PS_LEADER )
{// Update leader
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `leader_id`='%d', `leader_char`='%d' WHERE `party_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `leader_id`='%d', `leader_char`='%d' WHERE `party_id`='%d'",
party_db, p->member[index].account_id, p->member[index].char_id, party_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
-
+
if( flag & PS_ADDMEMBER )
{// Add one party member.
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'",
char_db, party_id, p->member[index].account_id, p->member[index].char_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
if( flag & PS_DELMEMBER )
{// Remove one party member.
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `char_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `char_id`='%d'",
char_db, party_id, p->member[index].account_id, p->member[index].char_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
if( save_log )
@@ -205,124 +192,124 @@ struct party_data *inter_party_fromsql(int party_id)
#endif
if( party_id <= 0 )
return NULL;
-
+
//Load from memory
- p = (struct party_data*)idb_get(party_db_, party_id);
+ p = (struct party_data*)idb_get(inter_party->db, party_id);
if( p != NULL )
return p;
- p = party_pt;
+ p = inter_party->pt;
memset(p, 0, sizeof(struct party_data));
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return NULL;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
return NULL;
p->party.party_id = party_id;
- SQL->GetData(sql_handle, 1, &data, &len); memcpy(p->party.name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 2, &data, NULL); p->party.exp = (atoi(data) ? 1 : 0);
- SQL->GetData(sql_handle, 3, &data, NULL); p->party.item = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); leader_id = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); leader_char = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->GetData(inter->sql_handle, 1, &data, &len); memcpy(p->party.name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); p->party.exp = (atoi(data) ? 1 : 0);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); p->party.item = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); leader_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); leader_char = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
// Load members
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", char_db, party_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", char_db, party_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return NULL;
}
- for( i = 0; i < MAX_PARTY && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for( i = 0; i < MAX_PARTY && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
m = &p->party.member[i];
- SQL->GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 3, &data, NULL); m->lv = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); m->map = mapindex->name2id(data);
- SQL->GetData(sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0);
- SQL->GetData(sql_handle, 6, &data, NULL); m->class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); m->account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); m->char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); m->lv = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); m->map = mapindex->name2id(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); m->class_ = atoi(data);
m->leader = (m->account_id == leader_id && m->char_id == leader_char ? 1 : 0);
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
if( save_log )
ShowInfo("Party loaded (%d - %s).\n", party_id, p->party.name);
//Add party to memory.
CREATE(p, struct party_data, 1);
- memcpy(p, party_pt, sizeof(struct party_data));
+ memcpy(p, inter_party->pt, sizeof(struct party_data));
//init state
- int_party_calc_state(p);
- idb_put(party_db_, party_id, p);
+ inter_party->calc_state(p);
+ idb_put(inter_party->db, party_id, p);
return p;
}
int inter_party_sql_init(void)
{
//memory alloc
- party_db_ = idb_alloc(DB_OPT_RELEASE_DATA);
- party_pt = (struct party_data*)aCalloc(sizeof(struct party_data), 1);
- if (!party_pt) {
- ShowFatalError("inter_party_sql_init: Out of Memory!\n");
+ inter_party->db = idb_alloc(DB_OPT_RELEASE_DATA);
+ inter_party->pt = (struct party_data*)aCalloc(sizeof(struct party_data), 1);
+ if (!inter_party->pt) {
+ ShowFatalError("inter_party->sql_init: Out of Memory!\n");
exit(EXIT_FAILURE);
}
/* Uncomment the following if you want to do a party_db cleanup (remove parties with no members) on startup.[Skotlex]
ShowStatus("cleaning party table...\n");
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL",
party_db, party_db, char_db, party_db, char_db, party_db, char_db, char_db) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
*/
return 0;
}
void inter_party_sql_final(void)
{
- party_db_->destroy(party_db_, NULL);
- aFree(party_pt);
+ inter_party->db->destroy(inter_party->db, NULL);
+ aFree(inter_party->pt);
return;
}
// Search for the party according to its name
-struct party_data* search_partyname(char* str)
+struct party_data* inter_party_search_partyname(const char *const str)
{
char esc_name[NAME_LENGTH*2+1];
char* data;
struct party_data* p = NULL;
- SQL->EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `party_id` FROM `%s` WHERE `name`='%s'", party_db, esc_name) )
- Sql_ShowDebug(sql_handle);
- else if( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
- SQL->GetData(sql_handle, 0, &data, NULL);
- p = inter_party_fromsql(atoi(data));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `party_id` FROM `%s` WHERE `name`='%s'", party_db, esc_name) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) {
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
+ p = inter_party->fromsql(atoi(data));
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return p;
}
// Returns whether this party can keep having exp share or not.
-int party_check_exp_share(struct party_data *p)
+int inter_party_check_exp_share(struct party_data *const p)
{
return (p->party.count < 2 || p->max_lv - p->min_lv <= party_share_level);
}
// Is there any member in the party?
-int party_check_empty(struct party_data *p)
+int inter_party_check_empty(struct party_data *p)
{
int i;
if (p==NULL||p->party.party_id==0) return 1;
for(i=0;i<MAX_PARTY && !p->party.member[i].account_id;i++);
if (i < MAX_PARTY) return 0;
// If there is no member, then break the party
- mapif_party_broken(p->party.party_id,0);
- inter_party_tosql(&p->party, PS_BREAK, 0);
+ mapif->party_broken(p->party.party_id,0);
+ inter_party->tosql(&p->party, PS_BREAK, 0);
return 1;
}
@@ -331,7 +318,7 @@ int party_check_empty(struct party_data *p)
// Create a party whether or not
-int mapif_party_created(int fd,int account_id,int char_id,struct party *p)
+int mapif_party_created(int fd, int account_id, int char_id, struct party *p)
{
WFIFOHEAD(fd, 39);
WFIFOW(fd,0)=0x3820;
@@ -353,7 +340,7 @@ int mapif_party_created(int fd,int account_id,int char_id,struct party *p)
}
//Party information not found
-static void mapif_party_noinfo(int fd, int party_id, int char_id)
+void mapif_party_noinfo(int fd, int party_id, int char_id)
{
WFIFOHEAD(fd, 12);
WFIFOW(fd,0) = 0x3821;
@@ -365,7 +352,7 @@ static void mapif_party_noinfo(int fd, int party_id, int char_id)
}
//Digest party information
-static void mapif_party_info(int fd, struct party* p, int char_id)
+void mapif_party_info(int fd, struct party* p, int char_id)
{
unsigned char buf[8 + sizeof(struct party)];
WBUFW(buf,0) = 0x3821;
@@ -374,9 +361,9 @@ static void mapif_party_info(int fd, struct party* p, int char_id)
memcpy(WBUFP(buf,8), p, sizeof(struct party));
if(fd<0)
- mapif_sendall(buf,WBUFW(buf,2));
+ mapif->sendall(buf,WBUFW(buf,2));
else
- mapif_send(fd,buf,WBUFW(buf,2));
+ mapif->send(fd,buf,WBUFW(buf,2));
}
//Whether or not additional party members
@@ -393,7 +380,7 @@ int mapif_party_memberadded(int fd, int party_id, int account_id, int char_id, i
}
// Party setting change notification
-int mapif_party_optionchanged(int fd,struct party *p,int account_id,int flag)
+int mapif_party_optionchanged(int fd, struct party *p, int account_id, int flag)
{
unsigned char buf[16];
WBUFW(buf,0)=0x3823;
@@ -403,9 +390,9 @@ int mapif_party_optionchanged(int fd,struct party *p,int account_id,int flag)
WBUFW(buf,12)=p->item;
WBUFB(buf,14)=flag;
if(flag==0)
- mapif_sendall(buf,15);
+ mapif->sendall(buf,15);
else
- mapif_send(fd,buf,15);
+ mapif->send(fd,buf,15);
return 0;
}
@@ -417,12 +404,12 @@ int mapif_party_withdraw(int party_id,int account_id, int char_id) {
WBUFL(buf,2) = party_id;
WBUFL(buf,6) = account_id;
WBUFL(buf,10) = char_id;
- mapif_sendall(buf, 14);
+ mapif->sendall(buf, 14);
return 0;
}
//Party map update notification
-int mapif_party_membermoved(struct party *p,int idx)
+int mapif_party_membermoved(struct party *p, int idx)
{
unsigned char buf[20];
@@ -433,24 +420,24 @@ int mapif_party_membermoved(struct party *p,int idx)
WBUFW(buf,14) = p->member[idx].map;
WBUFB(buf,16) = p->member[idx].online;
WBUFW(buf,17) = p->member[idx].lv;
- mapif_sendall(buf, 19);
+ mapif->sendall(buf, 19);
return 0;
}
//Dissolution party notification
-int mapif_party_broken(int party_id,int flag)
+int mapif_party_broken(int party_id, int flag)
{
unsigned char buf[16];
WBUFW(buf,0)=0x3826;
WBUFL(buf,2)=party_id;
WBUFB(buf,6)=flag;
- mapif_sendall(buf,7);
+ mapif->sendall(buf,7);
//printf("int_party: broken %d\n",party_id);
return 0;
}
//Remarks in the party
-int mapif_party_message(int party_id,int account_id,char *mes,int len, int sfd)
+int mapif_party_message(int party_id, int account_id, char *mes, int len, int sfd)
{
unsigned char buf[512];
WBUFW(buf,0)=0x3827;
@@ -458,7 +445,7 @@ int mapif_party_message(int party_id,int account_id,char *mes,int len, int sfd)
WBUFL(buf,4)=party_id;
WBUFL(buf,8)=account_id;
memcpy(WBUFP(buf,12),mes,len);
- mapif_sendallwos(sfd, buf,len+12);
+ mapif->sendallwos(sfd, buf,len+12);
return 0;
}
@@ -471,8 +458,8 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part
{
struct party_data *p;
int i;
- if( (p=search_partyname(name))!=NULL){
- mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
+ if( (p=inter_party->search_partyname(name))!=NULL){
+ mapif->party_created(fd,leader->account_id,leader->char_id,NULL);
return 0;
}
// Check Authorized letters/symbols in the name of the character
@@ -481,22 +468,22 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part
if (strchr(char_name_letters, name[i]) == NULL) {
if( name[i] == '"' ) { /* client-special-char */
normalize_name(name,"\"");
- mapif_parse_CreateParty(fd,name,item,item2,leader);
+ mapif->parse_CreateParty(fd,name,item,item2,leader);
return 0;
}
- mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
+ mapif->party_created(fd,leader->account_id,leader->char_id,NULL);
return 0;
}
} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
for (i = 0; i < NAME_LENGTH && name[i]; i++)
if (strchr(char_name_letters, name[i]) != NULL) {
- mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
+ mapif->party_created(fd,leader->account_id,leader->char_id,NULL);
return 0;
}
}
p = (struct party_data*)aCalloc(1, sizeof(struct party_data));
-
+
memcpy(p->party.name,name,NAME_LENGTH);
p->party.exp=0;
p->party.item=(item?1:0)|(item2?2:0);
@@ -506,30 +493,30 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part
p->party.member[0].online=1;
p->party.party_id=-1;//New party.
- if (inter_party_tosql(&p->party,PS_CREATE|PS_ADDMEMBER,0)) {
+ if (inter_party->tosql(&p->party,PS_CREATE|PS_ADDMEMBER,0)) {
//Add party to db
- int_party_calc_state(p);
- idb_put(party_db_, p->party.party_id, p);
- mapif_party_info(fd, &p->party, 0);
- mapif_party_created(fd,leader->account_id,leader->char_id,&p->party);
+ inter_party->calc_state(p);
+ idb_put(inter_party->db, p->party.party_id, p);
+ mapif->party_info(fd, &p->party, 0);
+ mapif->party_created(fd,leader->account_id,leader->char_id,&p->party);
} else { //Failed to create party.
aFree(p);
- mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
+ mapif->party_created(fd,leader->account_id,leader->char_id,NULL);
}
return 0;
}
// Party information request
-static void mapif_parse_PartyInfo(int fd, int party_id, int char_id)
+void mapif_parse_PartyInfo(int fd, int party_id, int char_id)
{
struct party_data *p;
- p = inter_party_fromsql(party_id);
+ p = inter_party->fromsql(party_id);
if (p)
- mapif_party_info(fd, &p->party, char_id);
+ mapif->party_info(fd, &p->party, char_id);
else
- mapif_party_noinfo(fd, party_id, char_id);
+ mapif->party_noinfo(fd, party_id, char_id);
}
// Add a player to party request
@@ -538,16 +525,16 @@ int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member
struct party_data *p;
int i;
- p = inter_party_fromsql(party_id);
+ p = inter_party->fromsql(party_id);
if( p == NULL || p->size == MAX_PARTY ) {
- mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 1);
+ mapif->party_memberadded(fd, party_id, member->account_id, member->char_id, 1);
return 0;
}
ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == 0 );
if( i == MAX_PARTY )
{// Party full
- mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 1);
+ mapif->party_memberadded(fd, party_id, member->account_id, member->char_id, 1);
return 0;
}
@@ -556,16 +543,16 @@ int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member
if (p->party.member[i].online) p->party.count++;
p->size++;
if (p->size == 2 || p->size == 3) // Check family state. And also accept either of their Parents. [RoM]
- int_party_calc_state(p);
+ inter_party->calc_state(p);
else //Check even share range.
if (member->lv < p->min_lv || member->lv > p->max_lv || p->family) {
if (p->family) p->family = 0; //Family state broken.
- int_party_check_lv(p);
+ inter_party->check_lv(p);
}
- mapif_party_info(-1, &p->party, 0);
- mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 0);
- inter_party_tosql(&p->party, PS_ADDMEMBER, i);
+ mapif->party_info(-1, &p->party, 0);
+ mapif->party_memberadded(fd, party_id, member->account_id, member->char_id, 0);
+ inter_party->tosql(&p->party, PS_ADDMEMBER, i);
return 0;
}
@@ -575,19 +562,19 @@ int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int
{
struct party_data *p;
int flag = 0;
- p = inter_party_fromsql(party_id);
+ p = inter_party->fromsql(party_id);
if(!p)
return 0;
p->party.exp=exp;
- if( exp && !party_check_exp_share(p) ){
+ if( exp && !inter_party->check_exp_share(p) ){
flag|=0x01;
p->party.exp=0;
}
p->party.item = item&0x3; //Filter out invalid values.
- mapif_party_optionchanged(fd,&p->party,account_id,flag);
- inter_party_tosql(&p->party, PS_BASIC, 0);
+ mapif->party_optionchanged(fd,&p->party,account_id,flag);
+ inter_party->tosql(&p->party, PS_BASIC, 0);
return 0;
}
@@ -597,11 +584,11 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
struct party_data *p;
int i,j=-1;
- p = inter_party_fromsql(party_id);
+ p = inter_party->fromsql(party_id);
if( p == NULL )
{// Party does not exists?
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
@@ -614,19 +601,19 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
if (i >= MAX_PARTY)
return 0; //Member not found?
- mapif_party_withdraw(party_id, account_id, char_id);
+ mapif->party_withdraw(party_id, account_id, char_id);
if (p->party.member[i].leader){
p->party.member[i].account_id = 0;
for (j = 0; j < MAX_PARTY; j++) {
if (!p->party.member[j].account_id)
continue;
- mapif_party_withdraw(party_id, p->party.member[j].account_id, p->party.member[j].char_id);
+ mapif->party_withdraw(party_id, p->party.member[j].account_id, p->party.member[j].char_id);
p->party.member[j].account_id = 0;
}
//Party gets deleted on the check_empty call below.
} else {
- inter_party_tosql(&p->party,PS_DELMEMBER,i);
+ inter_party->tosql(&p->party,PS_DELMEMBER,i);
j = p->party.member[i].lv;
if(p->party.member[i].online) p->party.count--;
memset(&p->party.member[i], 0, sizeof(struct party_member));
@@ -634,12 +621,12 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
if (j == p->min_lv || j == p->max_lv || p->family)
{
if(p->family) p->family = 0; //Family state broken.
- int_party_check_lv(p);
+ inter_party->check_lv(p);
}
}
-
- if (party_check_empty(p) == 0)
- mapif_party_info(-1, &p->party, 0);
+
+ if (inter_party->check_empty(p) == 0)
+ mapif->party_info(-1, &p->party, 0);
return 0;
}
// When member goes to other map or levels up.
@@ -648,7 +635,7 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id
struct party_data *p;
int i;
- p = inter_party_fromsql(party_id);
+ p = inter_party->fromsql(party_id);
if (p == NULL)
return 0;
@@ -674,10 +661,10 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id
)
{
p->party.member[i].lv = lv;
- int_party_check_lv(p);
+ inter_party->check_lv(p);
}
//Send online/offline update.
- mapif_party_membermoved(&p->party, i);
+ mapif->party_membermoved(&p->party, i);
}
if (p->party.member[i].lv != lv) {
@@ -685,7 +672,7 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id
p->party.member[i].lv == p->max_lv)
{
p->party.member[i].lv = lv;
- int_party_check_lv(p);
+ inter_party->check_lv(p);
} else
p->party.member[i].lv = lv;
//There is no need to send level update to map servers
@@ -694,50 +681,47 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id
if (p->party.member[i].map != map) {
p->party.member[i].map = map;
- mapif_party_membermoved(&p->party, i);
+ mapif->party_membermoved(&p->party, i);
}
return 0;
}
//Request party dissolution
-int mapif_parse_BreakParty(int fd,int party_id)
+int mapif_parse_BreakParty(int fd, int party_id)
{
struct party_data *p;
- p = inter_party_fromsql(party_id);
+ p = inter_party->fromsql(party_id);
if(!p)
return 0;
- inter_party_tosql(&p->party,PS_BREAK,0);
- mapif_party_broken(fd,party_id);
+ inter_party->tosql(&p->party,PS_BREAK,0);
+ mapif->party_broken(fd,party_id);
return 0;
}
//Party sending the message
-int mapif_parse_PartyMessage(int fd,int party_id,int account_id,char *mes,int len)
+int mapif_parse_PartyMessage(int fd, int party_id, int account_id, char *mes, int len)
{
- return mapif_party_message(party_id,account_id,mes,len, fd);
+ return mapif->party_message(party_id,account_id,mes,len, fd);
}
-int mapif_parse_PartyLeaderChange(int fd,int party_id,int account_id,int char_id)
+int mapif_parse_PartyLeaderChange(int fd, int party_id, int account_id, int char_id)
{
struct party_data *p;
int i;
- p = inter_party_fromsql(party_id);
+ p = inter_party->fromsql(party_id);
if(!p)
return 0;
- for (i = 0; i < MAX_PARTY; i++)
- {
+ for (i = 0; i < MAX_PARTY; i++) {
if(p->party.member[i].leader)
p->party.member[i].leader = 0;
- if(p->party.member[i].account_id == account_id &&
- p->party.member[i].char_id == char_id)
- {
+ if(p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id) {
p->party.member[i].leader = 1;
- inter_party_tosql(&p->party,PS_LEADER, i);
+ inter_party->tosql(&p->party,PS_LEADER, i);
}
}
return 1;
@@ -749,21 +733,21 @@ int mapif_parse_PartyLeaderChange(int fd,int party_id,int account_id,int char_id
// Data packet length is set to inter.c that you
// Do NOT go and check the packet length, RFIFOSKIP is done by the caller
// Return :
-// 0 : error
-// 1 : ok
+// 0 : error
+// 1 : ok
int inter_party_parse_frommap(int fd)
{
RFIFOHEAD(fd);
switch(RFIFOW(fd,0)) {
- case 0x3020: mapif_parse_CreateParty(fd, (char*)RFIFOP(fd,4), RFIFOB(fd,28), RFIFOB(fd,29), (struct party_member*)RFIFOP(fd,30)); break;
- case 0x3021: mapif_parse_PartyInfo(fd, RFIFOL(fd,2), RFIFOL(fd,6)); break;
- case 0x3022: mapif_parse_PartyAddMember(fd, RFIFOL(fd,4), (struct party_member*)RFIFOP(fd,8)); break;
- case 0x3023: mapif_parse_PartyChangeOption(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOW(fd,10), RFIFOW(fd,12)); break;
- case 0x3024: mapif_parse_PartyLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break;
- case 0x3025: mapif_parse_PartyChangeMap(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOW(fd,14), RFIFOB(fd,16), RFIFOW(fd,17)); break;
- case 0x3026: mapif_parse_BreakParty(fd, RFIFOL(fd,2)); break;
- case 0x3027: mapif_parse_PartyMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), (char*)RFIFOP(fd,12), RFIFOW(fd,2)-12); break;
- case 0x3029: mapif_parse_PartyLeaderChange(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break;
+ case 0x3020: mapif->parse_CreateParty(fd, (char*)RFIFOP(fd,4), RFIFOB(fd,28), RFIFOB(fd,29), (struct party_member*)RFIFOP(fd,30)); break;
+ case 0x3021: mapif->parse_PartyInfo(fd, RFIFOL(fd,2), RFIFOL(fd,6)); break;
+ case 0x3022: mapif->parse_PartyAddMember(fd, RFIFOL(fd,4), (struct party_member*)RFIFOP(fd,8)); break;
+ case 0x3023: mapif->parse_PartyChangeOption(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOW(fd,10), RFIFOW(fd,12)); break;
+ case 0x3024: mapif->parse_PartyLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break;
+ case 0x3025: mapif->parse_PartyChangeMap(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOW(fd,14), RFIFOB(fd,16), RFIFOW(fd,17)); break;
+ case 0x3026: mapif->parse_BreakParty(fd, RFIFOL(fd,2)); break;
+ case 0x3027: mapif->parse_PartyMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), (char*)RFIFOP(fd,12), RFIFOW(fd,2)-12); break;
+ case 0x3029: mapif->parse_PartyLeaderChange(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break;
default:
return 0;
}
@@ -773,7 +757,7 @@ int inter_party_parse_frommap(int fd)
//Leave request from the server (for delete character)
int inter_party_leave(int party_id,int account_id, int char_id)
{
- return mapif_parse_PartyLeave(-1,party_id,account_id, char_id);
+ return mapif->parse_PartyLeave(-1,party_id,account_id, char_id);
}
int inter_party_CharOnline(int char_id, int party_id)
@@ -785,23 +769,23 @@ int inter_party_CharOnline(int char_id, int party_id)
{// Get party_id from the database
char* data;
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
return 0; //Eh? No party?
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
party_id = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
if (party_id == 0)
return 0; //No party...
-
- p = inter_party_fromsql(party_id);
+
+ p = inter_party->fromsql(party_id);
if(!p) {
ShowError("Character %d's party %d not found!\n", char_id, party_id);
return 0;
@@ -815,7 +799,7 @@ int inter_party_CharOnline(int char_id, int party_id)
p->party.count++;
if (p->party.member[i].lv < p->min_lv ||
p->party.member[i].lv > p->max_lv)
- int_party_check_lv(p);
+ inter_party->check_lv(p);
}
break;
}
@@ -831,24 +815,24 @@ int inter_party_CharOffline(int char_id, int party_id) {
{// Get guild_id from the database
char* data;
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
return 0; //Eh? No party?
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
party_id = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
if (party_id == 0)
return 0; //No party...
-
+
//Character has a party, set character offline and check if they were the only member online
- if ((p = inter_party_fromsql(party_id)) == NULL)
+ if ((p = inter_party->fromsql(party_id)) == NULL)
return 0;
//Set member offline
@@ -859,13 +843,35 @@ int inter_party_CharOffline(int char_id, int party_id) {
p->party.count--;
if(p->party.member[i].lv == p->min_lv ||
p->party.member[i].lv == p->max_lv)
- int_party_check_lv(p);
+ inter_party->check_lv(p);
break;
}
}
if(!p->party.count)
//Parties don't have any data that needs be saved at this point... so just remove it from memory.
- idb_remove(party_db_, party_id);
+ idb_remove(inter_party->db, party_id);
return 1;
}
+
+void inter_party_defaults(void)
+{
+ inter_party = &inter_party_s;
+
+ inter_party->pt = NULL;
+ inter_party->db = NULL;
+
+ inter_party->sql_init = inter_party_sql_init;
+ inter_party->sql_final = inter_party_sql_final;
+ inter_party->check_lv = inter_party_check_lv;
+ inter_party->calc_state = inter_party_calc_state;
+ inter_party->tosql = inter_party_tosql;
+ inter_party->fromsql = inter_party_fromsql;
+ inter_party->search_partyname = inter_party_search_partyname;
+ inter_party->check_exp_share = inter_party_check_exp_share;
+ inter_party->check_empty = inter_party_check_empty;
+ inter_party->parse_frommap = inter_party_parse_frommap;
+ inter_party->leave = inter_party_leave;
+ inter_party->CharOnline = inter_party_CharOnline;
+ inter_party->CharOffline = inter_party_CharOffline;
+}
diff --git a/src/char/int_party.h b/src/char/int_party.h
index 2b24b1d1a..0c70a5300 100644
--- a/src/char/int_party.h
+++ b/src/char/int_party.h
@@ -4,6 +4,8 @@
#ifndef CHAR_INT_PARTY_H
#define CHAR_INT_PARTY_H
+#include "../common/mmo.h"
+
//Party Flags on what to save/delete.
enum {
PS_CREATE = 0x01, //Create a new party entry (index holds leader's info)
@@ -14,11 +16,36 @@ enum {
PS_BREAK = 0x20, //Specify that this party must be deleted.
};
-int inter_party_parse_frommap(int fd);
-int inter_party_sql_init(void);
-void inter_party_sql_final(void);
-int inter_party_leave(int party_id,int account_id, int char_id);
-int inter_party_CharOnline(int char_id, int party_id);
-int inter_party_CharOffline(int char_id, int party_id);
+struct party_data {
+ struct party party;
+ unsigned int min_lv, max_lv;
+ int family; //Is this party a family? if so, this holds the child id.
+ unsigned char size; //Total size of party.
+};
+
+void inter_party_defaults(void);
+
+/**
+ * inter_party interface
+ **/
+struct inter_party_interface {
+ struct party_data *pt;
+ DBMap* db; // int party_id -> struct party_data*
+ int (*check_lv) (struct party_data *p);
+ void (*calc_state) (struct party_data *p);
+ int (*tosql) (struct party *p, int flag, int index);
+ struct party_data* (*fromsql) (int party_id);
+ int (*sql_init) (void);
+ void (*sql_final) (void);
+ struct party_data* (*search_partyname) (const char *str);
+ int (*check_exp_share) (struct party_data *p);
+ int (*check_empty) (struct party_data *p);
+ int (*parse_frommap) (int fd);
+ int (*leave) (int party_id,int account_id, int char_id);
+ int (*CharOnline) (int char_id, int party_id);
+ int (*CharOffline) (int char_id, int party_id);
+};
+
+struct inter_party_interface *inter_party;
#endif /* CHAR_INT_PARTY_H */
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index bf7961462..b37037844 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -12,6 +12,7 @@
#include "char.h"
#include "inter.h"
+#include "mapif.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/showmsg.h"
@@ -20,7 +21,7 @@
#include "../common/strlib.h"
#include "../common/utils.h"
-struct s_pet *pet_pt;
+struct inter_pet_interface inter_pet_s;
//---------------------------------------------------------
int inter_pet_tosql(int pet_id, struct s_pet* p)
@@ -28,30 +29,30 @@ int inter_pet_tosql(int pet_id, struct s_pet* p)
//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`)
char esc_name[NAME_LENGTH*2+1];// escaped pet name
- SQL->EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
p->hungry = cap_value(p->hungry, 0, 100);
p->intimate = cap_value(p->intimate, 0, 1000);
if( pet_id == -1 )
{// New pet.
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` "
"(`class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`) "
"VALUES ('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
p->equip, p->intimate, p->hungry, p->rename_flag, p->incubate) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- p->pet_id = (int)SQL->LastInsertId(sql_handle);
+ p->pet_id = (int)SQL->LastInsertId(inter->sql_handle);
}
else
{// Update pet.
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incubate`='%d' WHERE `pet_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incubate`='%d' WHERE `pet_id`='%d'",
pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
p->equip, p->intimate, p->hungry, p->rename_flag, p->incubate, p->pet_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
}
@@ -73,28 +74,28 @@ int inter_pet_fromsql(int pet_id, struct s_pet* p)
//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`)
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
p->pet_id = pet_id;
- SQL->GetData(sql_handle, 1, &data, NULL); p->class_ = atoi(data);
- SQL->GetData(sql_handle, 2, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 3, &data, NULL); p->account_id = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); p->char_id = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); p->level = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); p->egg_id = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); p->equip = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); p->intimate = atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); p->hungry = atoi(data);
- SQL->GetData(sql_handle, 10, &data, NULL); p->rename_flag = atoi(data);
- SQL->GetData(sql_handle, 11, &data, NULL); p->incubate = atoi(data);
-
- SQL->FreeResult(sql_handle);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); p->class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); p->account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); p->char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); p->level = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); p->egg_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); p->equip = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); p->intimate = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); p->hungry = atoi(data);
+ SQL->GetData(inter->sql_handle, 10, &data, NULL); p->rename_flag = atoi(data);
+ SQL->GetData(inter->sql_handle, 11, &data, NULL); p->incubate = atoi(data);
+
+ SQL->FreeResult(inter->sql_handle);
p->hungry = cap_value(p->hungry, 0, 100);
p->intimate = cap_value(p->intimate, 0, 1000);
@@ -106,21 +107,21 @@ int inter_pet_fromsql(int pet_id, struct s_pet* p)
}
//----------------------------------------------
-int inter_pet_sql_init(void){
+int inter_pet_sql_init(void) {
//memory alloc
- pet_pt = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1);
+ inter_pet->pt = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1);
return 0;
}
-void inter_pet_sql_final(void){
- if (pet_pt) aFree(pet_pt);
+void inter_pet_sql_final(void) {
+ if (inter_pet->pt) aFree(inter_pet->pt);
return;
}
//----------------------------------
-int inter_pet_delete(int pet_id){
+int inter_pet_delete(int pet_id) {
ShowInfo("delete pet request: %d...\n",pet_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
//------------------------------------------------------
@@ -142,7 +143,8 @@ int mapif_pet_created(int fd, int account_id, struct s_pet *p)
return 0;
}
-int mapif_pet_info(int fd, int account_id, struct s_pet *p){
+int mapif_pet_info(int fd, int account_id, struct s_pet *p)
+{
WFIFOHEAD(fd, sizeof(struct s_pet) + 9);
WFIFOW(fd, 0) =0x3881;
WFIFOW(fd, 2) =sizeof(struct s_pet) + 9;
@@ -154,7 +156,8 @@ int mapif_pet_info(int fd, int account_id, struct s_pet *p){
return 0;
}
-int mapif_pet_noinfo(int fd, int account_id){
+int mapif_pet_noinfo(int fd, int account_id)
+{
WFIFOHEAD(fd, sizeof(struct s_pet) + 9);
WFIFOW(fd, 0) =0x3881;
WFIFOW(fd, 2) =sizeof(struct s_pet) + 9;
@@ -166,7 +169,8 @@ int mapif_pet_noinfo(int fd, int account_id){
return 0;
}
-int mapif_save_pet_ack(int fd, int account_id, int flag){
+int mapif_save_pet_ack(int fd, int account_id, int flag)
+{
WFIFOHEAD(fd, 7);
WFIFOW(fd, 0) =0x3882;
WFIFOL(fd, 2) =account_id;
@@ -176,7 +180,8 @@ int mapif_save_pet_ack(int fd, int account_id, int flag){
return 0;
}
-int mapif_delete_pet_ack(int fd, int flag){
+int mapif_delete_pet_ack(int fd, int flag)
+{
WFIFOHEAD(fd, 3);
WFIFOW(fd, 0) =0x3883;
WFIFOB(fd, 2) =flag;
@@ -188,63 +193,65 @@ int mapif_delete_pet_ack(int fd, int flag){
int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id,
short pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name)
{
- memset(pet_pt, 0, sizeof(struct s_pet));
- safestrncpy(pet_pt->name, pet_name, NAME_LENGTH);
+ memset(inter_pet->pt, 0, sizeof(struct s_pet));
+ safestrncpy(inter_pet->pt->name, pet_name, NAME_LENGTH);
if(incubate == 1)
- pet_pt->account_id = pet_pt->char_id = 0;
+ inter_pet->pt->account_id = inter_pet->pt->char_id = 0;
else {
- pet_pt->account_id = account_id;
- pet_pt->char_id = char_id;
+ inter_pet->pt->account_id = account_id;
+ inter_pet->pt->char_id = char_id;
}
- pet_pt->class_ = pet_class;
- pet_pt->level = pet_lv;
- pet_pt->egg_id = pet_egg_id;
- pet_pt->equip = pet_equip;
- pet_pt->intimate = intimate;
- pet_pt->hungry = hungry;
- pet_pt->rename_flag = rename_flag;
- pet_pt->incubate = incubate;
-
- if(pet_pt->hungry < 0)
- pet_pt->hungry = 0;
- else if(pet_pt->hungry > 100)
- pet_pt->hungry = 100;
- if(pet_pt->intimate < 0)
- pet_pt->intimate = 0;
- else if(pet_pt->intimate > 1000)
- pet_pt->intimate = 1000;
-
- pet_pt->pet_id = -1; //Signal NEW pet.
- if (inter_pet_tosql(pet_pt->pet_id,pet_pt))
- mapif_pet_created(fd, account_id, pet_pt);
- else //Failed...
- mapif_pet_created(fd, account_id, NULL);
+ inter_pet->pt->class_ = pet_class;
+ inter_pet->pt->level = pet_lv;
+ inter_pet->pt->egg_id = pet_egg_id;
+ inter_pet->pt->equip = pet_equip;
+ inter_pet->pt->intimate = intimate;
+ inter_pet->pt->hungry = hungry;
+ inter_pet->pt->rename_flag = rename_flag;
+ inter_pet->pt->incubate = incubate;
+
+ if(inter_pet->pt->hungry < 0)
+ inter_pet->pt->hungry = 0;
+ else if(inter_pet->pt->hungry > 100)
+ inter_pet->pt->hungry = 100;
+ if(inter_pet->pt->intimate < 0)
+ inter_pet->pt->intimate = 0;
+ else if(inter_pet->pt->intimate > 1000)
+ inter_pet->pt->intimate = 1000;
+
+ inter_pet->pt->pet_id = -1; //Signal NEW pet.
+ if (inter_pet->tosql(inter_pet->pt->pet_id,inter_pet->pt))
+ mapif->pet_created(fd, account_id, inter_pet->pt);
+ else //Failed...
+ mapif->pet_created(fd, account_id, NULL);
return 0;
}
-int mapif_load_pet(int fd, int account_id, int char_id, int pet_id){
- memset(pet_pt, 0, sizeof(struct s_pet));
+int mapif_load_pet(int fd, int account_id, int char_id, int pet_id)
+{
+ memset(inter_pet->pt, 0, sizeof(struct s_pet));
- inter_pet_fromsql(pet_id, pet_pt);
+ inter_pet->fromsql(pet_id, inter_pet->pt);
- if(pet_pt!=NULL) {
- if(pet_pt->incubate == 1) {
- pet_pt->account_id = pet_pt->char_id = 0;
- mapif_pet_info(fd, account_id, pet_pt);
+ if(inter_pet->pt!=NULL) {
+ if(inter_pet->pt->incubate == 1) {
+ inter_pet->pt->account_id = inter_pet->pt->char_id = 0;
+ mapif->pet_info(fd, account_id, inter_pet->pt);
}
- else if(account_id == pet_pt->account_id && char_id == pet_pt->char_id)
- mapif_pet_info(fd, account_id, pet_pt);
+ else if(account_id == inter_pet->pt->account_id && char_id == inter_pet->pt->char_id)
+ mapif->pet_info(fd, account_id, inter_pet->pt);
else
- mapif_pet_noinfo(fd, account_id);
+ mapif->pet_noinfo(fd, account_id);
}
else
- mapif_pet_noinfo(fd, account_id);
+ mapif->pet_noinfo(fd, account_id);
return 0;
}
-int mapif_save_pet(int fd, int account_id, struct s_pet *data) {
+int mapif_save_pet(int fd, int account_id, struct s_pet *data)
+{
//here process pet save request.
int len;
RFIFOHEAD(fd);
@@ -262,52 +269,72 @@ int mapif_save_pet(int fd, int account_id, struct s_pet *data) {
data->intimate = 0;
else if (data->intimate > 1000)
data->intimate = 1000;
- inter_pet_tosql(data->pet_id,data);
- mapif_save_pet_ack(fd, account_id, 0);
+ inter_pet->tosql(data->pet_id,data);
+ mapif->save_pet_ack(fd, account_id, 0);
return 0;
}
-int mapif_delete_pet(int fd, int pet_id){
- mapif_delete_pet_ack(fd, inter_pet_delete(pet_id));
+int mapif_delete_pet(int fd, int pet_id)
+{
+ mapif->delete_pet_ack(fd, inter_pet->delete_(pet_id));
return 0;
}
-int mapif_parse_CreatePet(int fd){
+int mapif_parse_CreatePet(int fd)
+{
RFIFOHEAD(fd);
- mapif_create_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOW(fd, 10), RFIFOW(fd, 12), RFIFOW(fd, 14), RFIFOW(fd, 16), RFIFOW(fd, 18),
+ mapif->create_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOW(fd, 10), RFIFOW(fd, 12), RFIFOW(fd, 14), RFIFOW(fd, 16), RFIFOW(fd, 18),
RFIFOW(fd, 20), RFIFOB(fd, 22), RFIFOB(fd, 23), (char*)RFIFOP(fd, 24));
return 0;
}
-int mapif_parse_LoadPet(int fd){
+int mapif_parse_LoadPet(int fd)
+{
RFIFOHEAD(fd);
- mapif_load_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOL(fd, 10));
+ mapif->load_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOL(fd, 10));
return 0;
}
-int mapif_parse_SavePet(int fd){
+int mapif_parse_SavePet(int fd)
+{
RFIFOHEAD(fd);
- mapif_save_pet(fd, RFIFOL(fd, 4), (struct s_pet *) RFIFOP(fd, 8));
+ mapif->save_pet(fd, RFIFOL(fd, 4), (struct s_pet *) RFIFOP(fd, 8));
return 0;
}
-int mapif_parse_DeletePet(int fd){
+int mapif_parse_DeletePet(int fd)
+{
RFIFOHEAD(fd);
- mapif_delete_pet(fd, RFIFOL(fd, 2));
+ mapif->delete_pet(fd, RFIFOL(fd, 2));
return 0;
}
-int inter_pet_parse_frommap(int fd){
+int inter_pet_parse_frommap(int fd)
+{
RFIFOHEAD(fd);
switch(RFIFOW(fd, 0)){
- case 0x3080: mapif_parse_CreatePet(fd); break;
- case 0x3081: mapif_parse_LoadPet(fd); break;
- case 0x3082: mapif_parse_SavePet(fd); break;
- case 0x3083: mapif_parse_DeletePet(fd); break;
+ case 0x3080: mapif->parse_CreatePet(fd); break;
+ case 0x3081: mapif->parse_LoadPet(fd); break;
+ case 0x3082: mapif->parse_SavePet(fd); break;
+ case 0x3083: mapif->parse_DeletePet(fd); break;
default:
return 0;
}
return 1;
}
+
+void inter_pet_defaults(void)
+{
+ inter_pet = &inter_pet_s;
+
+ inter_pet->pt = NULL;
+
+ inter_pet->tosql = inter_pet_tosql;
+ inter_pet->fromsql = inter_pet_fromsql;
+ inter_pet->sql_init = inter_pet_sql_init;
+ inter_pet->sql_final = inter_pet_sql_final;
+ inter_pet->delete_ = inter_pet_delete;
+ inter_pet->parse_frommap = inter_pet_parse_frommap;
+}
diff --git a/src/char/int_pet.h b/src/char/int_pet.h
index 52642fc54..873613307 100644
--- a/src/char/int_pet.h
+++ b/src/char/int_pet.h
@@ -6,16 +6,21 @@
struct s_pet;
-int inter_pet_init(void);
-void inter_pet_sql_final(void);
-int inter_pet_save(void);
-int inter_pet_delete(int pet_id);
+void inter_pet_defaults(void);
-int inter_pet_parse_frommap(int fd);
-int inter_pet_sql_init(void);
-//extern char pet_txt[256];
+/**
+ * inter_pet interface
+ **/
+struct inter_pet_interface {
+ struct s_pet *pt;
+ int (*tosql) (int pet_id, struct s_pet* p);
+ int (*fromsql) (int pet_id, struct s_pet* p);
+ int (*sql_init) (void);
+ void (*sql_final) (void);
+ int (*delete_) (int pet_id);
+ int (*parse_frommap) (int fd);
+};
-//Exported for use in the TXT-SQL converter.
-int inter_pet_tosql(int pet_id, struct s_pet *p);
+struct inter_pet_interface *inter_pet;
#endif /* CHAR_INT_PET_H */
diff --git a/src/char/int_quest.c b/src/char/int_quest.c
index d4155b0d6..b993cbc14 100644
--- a/src/char/int_quest.c
+++ b/src/char/int_quest.c
@@ -12,6 +12,7 @@
#include "char.h"
#include "inter.h"
+#include "mapif.h"
#include "../common/db.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
@@ -21,6 +22,8 @@
#include "../common/strlib.h"
#include "../common/timer.h"
+struct inter_quest_interface inter_quest_s;
+
/**
* Loads the entire questlog for a character.
*
@@ -29,7 +32,8 @@
* @return Array of found entries. It has *count entries, and it is care of the
* caller to aFree() it afterwards.
*/
-struct quest *mapif_quests_fromsql(int char_id, int *count) {
+struct quest *mapif_quests_fromsql(int char_id, int *count)
+{
struct quest *questlog = NULL;
struct quest tmp_quest;
SqlStmt *stmt;
@@ -40,7 +44,7 @@ struct quest *mapif_quests_fromsql(int char_id, int *count) {
if (!count)
return NULL;
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if (stmt == NULL) {
SqlStmt_ShowDebug(stmt);
*count = 0;
@@ -106,9 +110,10 @@ struct quest *mapif_quests_fromsql(int char_id, int *count) {
* @param quest_id Quest ID
* @return false in case of errors, true otherwise
*/
-bool mapif_quest_delete(int char_id, int quest_id) {
- if (SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `quest_id` = '%d' AND `char_id` = '%d'", quest_db, quest_id, char_id)) {
- Sql_ShowDebug(sql_handle);
+bool mapif_quest_delete(int char_id, int quest_id)
+{
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `quest_id` = '%d' AND `char_id` = '%d'", quest_db, quest_id, char_id)) {
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
@@ -122,7 +127,8 @@ bool mapif_quest_delete(int char_id, int quest_id) {
* @param qd Quest data
* @return false in case of errors, true otherwise
*/
-bool mapif_quest_add(int char_id, struct quest qd) {
+bool mapif_quest_add(int char_id, struct quest qd)
+{
StringBuf buf;
int i;
@@ -136,8 +142,8 @@ bool mapif_quest_add(int char_id, struct quest qd) {
StrBuf->Printf(&buf, ", '%d'", qd.count[i]);
}
StrBuf->AppendStr(&buf, ")");
- if (SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf))) {
- Sql_ShowDebug(sql_handle);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf))) {
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
return false;
}
@@ -153,7 +159,8 @@ bool mapif_quest_add(int char_id, struct quest qd) {
* @param qd Quest data
* @return false in case of errors, true otherwise
*/
-bool mapif_quest_update(int char_id, struct quest qd) {
+bool mapif_quest_update(int char_id, struct quest qd)
+{
StringBuf buf;
int i;
@@ -164,8 +171,8 @@ bool mapif_quest_update(int char_id, struct quest qd) {
}
StrBuf->Printf(&buf, " WHERE `quest_id` = '%d' AND `char_id` = '%d'", qd.quest_id, char_id);
- if (SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf))) {
- Sql_ShowDebug(sql_handle);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf))) {
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
return false;
}
@@ -174,6 +181,15 @@ bool mapif_quest_update(int char_id, struct quest qd) {
return true;
}
+void mapif_quest_save_ack(int fd, int char_id, bool success)
+{
+ WFIFOHEAD(fd,7);
+ WFIFOW(fd,0) = 0x3861;
+ WFIFOL(fd,2) = char_id;
+ WFIFOB(fd,6) = success?1:0;
+ WFIFOSET(fd,7);
+}
+
/**
* Handles the save request from mapserver for a character's questlog.
*
@@ -181,7 +197,8 @@ bool mapif_quest_update(int char_id, struct quest qd) {
*
* @see inter_parse_frommap
*/
-int mapif_parse_quest_save(int fd) {
+int mapif_parse_quest_save(int fd)
+{
int i, j, k, old_n, new_n = (RFIFOW(fd,2)-8)/sizeof(struct quest);
int char_id = RFIFOL(fd,4);
struct quest *old_qd = NULL, *new_qd = NULL;
@@ -190,7 +207,7 @@ int mapif_parse_quest_save(int fd) {
if (new_n > 0)
new_qd = (struct quest*)RFIFOP(fd,8);
- old_qd = mapif_quests_fromsql(char_id, &old_n);
+ old_qd = mapif->quests_fromsql(char_id, &old_n);
for (i = 0; i < new_n; i++) {
ARR_FIND( 0, old_n, j, new_qd[i].quest_id == old_qd[j].quest_id );
@@ -200,7 +217,7 @@ int mapif_parse_quest_save(int fd) {
// Only states and counts are changeable.
ARR_FIND( 0, MAX_QUEST_OBJECTIVES, k, new_qd[i].count[k] != old_qd[j].count[k] );
if (k != MAX_QUEST_OBJECTIVES || new_qd[i].state != old_qd[j].state)
- success &= mapif_quest_update(char_id, new_qd[i]);
+ success &= mapif->quest_update(char_id, new_qd[i]);
if (j < (--old_n)) {
// Compact array
@@ -209,26 +226,35 @@ int mapif_parse_quest_save(int fd) {
}
} else {
// Add new quests
- success &= mapif_quest_add(char_id, new_qd[i]);
+ success &= mapif->quest_add(char_id, new_qd[i]);
}
}
for (i = 0; i < old_n; i++) // Quests not in new_qd but in old_qd are to be erased.
- success &= mapif_quest_delete(char_id, old_qd[i].quest_id);
+ success &= mapif->quest_delete(char_id, old_qd[i].quest_id);
if (old_qd)
aFree(old_qd);
// Send ack
- WFIFOHEAD(fd,7);
- WFIFOW(fd,0) = 0x3861;
- WFIFOL(fd,2) = char_id;
- WFIFOB(fd,6) = success?1:0;
- WFIFOSET(fd,7);
+ mapif->quest_save_ack(fd, char_id, success);
return 0;
}
+void mapif_send_quests(int fd, int char_id, struct quest *tmp_questlog, int num_quests)
+{
+ WFIFOHEAD(fd,num_quests*sizeof(struct quest)+8);
+ WFIFOW(fd,0) = 0x3860;
+ WFIFOW(fd,2) = num_quests*sizeof(struct quest)+8;
+ WFIFOL(fd,4) = char_id;
+
+ if (num_quests > 0)
+ memcpy(WFIFOP(fd,8), tmp_questlog, sizeof(struct quest)*num_quests);
+
+ WFIFOSET(fd,num_quests*sizeof(struct quest)+8);
+}
+
/**
* Sends questlog to the map server
*
@@ -238,22 +264,14 @@ int mapif_parse_quest_save(int fd) {
*
* @see inter_parse_frommap
*/
-int mapif_parse_quest_load(int fd) {
+int mapif_parse_quest_load(int fd)
+{
int char_id = RFIFOL(fd,2);
struct quest *tmp_questlog = NULL;
int num_quests;
- tmp_questlog = mapif_quests_fromsql(char_id, &num_quests);
-
- WFIFOHEAD(fd,num_quests*sizeof(struct quest)+8);
- WFIFOW(fd,0) = 0x3860;
- WFIFOW(fd,2) = num_quests*sizeof(struct quest)+8;
- WFIFOL(fd,4) = char_id;
-
- if (num_quests > 0)
- memcpy(WFIFOP(fd,8), tmp_questlog, sizeof(struct quest)*num_quests);
-
- WFIFOSET(fd,num_quests*sizeof(struct quest)+8);
+ tmp_questlog = mapif->quests_fromsql(char_id, &num_quests);
+ mapif->send_quests(fd, char_id, tmp_questlog, num_quests);
if (tmp_questlog)
aFree(tmp_questlog);
@@ -266,12 +284,20 @@ int mapif_parse_quest_load(int fd) {
*
* @see inter_parse_frommap
*/
-int inter_quest_parse_frommap(int fd) {
+int inter_quest_parse_frommap(int fd)
+{
switch(RFIFOW(fd,0)) {
- case 0x3060: mapif_parse_quest_load(fd); break;
- case 0x3061: mapif_parse_quest_save(fd); break;
+ case 0x3060: mapif->parse_quest_load(fd); break;
+ case 0x3061: mapif->parse_quest_save(fd); break;
default:
return 0;
}
return 1;
}
+
+void inter_quest_defaults(void)
+{
+ inter_quest = &inter_quest_s;
+
+ inter_quest->parse_frommap = inter_quest_parse_frommap;
+}
diff --git a/src/char/int_quest.h b/src/char/int_quest.h
index f0dd370ea..265a3f97a 100644
--- a/src/char/int_quest.h
+++ b/src/char/int_quest.h
@@ -4,7 +4,16 @@
#ifndef CHAR_QUEST_H
#define CHAR_QUEST_H
-int inter_quest_parse_frommap(int fd);
+void inter_quest_defaults(void);
+
+/**
+ * inter_quest interface
+ **/
+struct inter_quest_interface {
+ int (*parse_frommap) (int fd);
+};
+
+struct inter_quest_interface *inter_quest;
#endif /* CHAR_QUEST_H */
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index 882d9b2a5..d64e11b89 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -13,6 +13,7 @@
#include "char.h"
#include "inter.h"
+#include "mapif.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/showmsg.h"
@@ -20,17 +21,19 @@
#include "../common/sql.h"
#include "../common/strlib.h" // StringBuf
-#define STORAGE_MEMINC 16
+#define STORAGE_MEMINC 16
+
+struct inter_storage_interface inter_storage_s;
/// Save storage data to sql
-int storage_tosql(int account_id, struct storage_data* p)
+int inter_storage_tosql(int account_id, struct storage_data* p)
{
- memitemdata_to_sql(p->items, MAX_STORAGE, account_id, TABLE_STORAGE);
+ chr->memitemdata_to_sql(p->items, MAX_STORAGE, account_id, TABLE_STORAGE);
return 0;
}
/// Load storage data to mem
-int storage_fromsql(int account_id, struct storage_data* p)
+int inter_storage_fromsql(int account_id, struct storage_data* p)
{
StringBuf buf;
struct item* item;
@@ -44,50 +47,50 @@ int storage_fromsql(int account_id, struct storage_data* p)
// storage {`account_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`}
StrBuf->Init(&buf);
StrBuf->AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`expire_time`,`bound`,`unique_id`");
- for( j = 0; j < MAX_SLOTS; ++j )
+ for( j = 0; j < MAX_SLOTS; ++j )
StrBuf->Printf(&buf, ",`card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `account_id`='%d' ORDER BY `nameid`", storage_db, account_id);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)) )
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
- for( i = 0; i < MAX_STORAGE && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for( i = 0; i < MAX_STORAGE && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
item = &p->items[i];
- SQL->GetData(sql_handle, 0, &data, NULL); item->id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); item->expire_time = (unsigned int)atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); item->bound = atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
- for( j = 0; j < MAX_SLOTS; ++j )
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); item->id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); item->nameid = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); item->amount = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); item->equip = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); item->identify = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); item->refine = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); item->attribute = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); item->expire_time = (unsigned int)atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); item->bound = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
+ for( j = 0; j < MAX_SLOTS; ++j )
{
- SQL->GetData(sql_handle, 10+j, &data, NULL); item->card[j] = atoi(data);
+ SQL->GetData(inter->sql_handle, 10+j, &data, NULL); item->card[j] = atoi(data);
}
}
p->storage_amount = i;
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
ShowInfo("storage load complete from DB - id: %d (total: %d)\n", account_id, p->storage_amount);
return 1;
}
/// Save guild_storage data to sql
-int guild_storage_tosql(int guild_id, struct guild_storage* p)
+int inter_storage_guild_storage_tosql(int guild_id, struct guild_storage* p)
{
- memitemdata_to_sql(p->items, MAX_GUILD_STORAGE, guild_id, TABLE_GUILD_STORAGE);
+ chr->memitemdata_to_sql(p->items, MAX_GUILD_STORAGE, guild_id, TABLE_GUILD_STORAGE);
ShowInfo ("guild storage save to DB - guild: %d\n", guild_id);
return 0;
}
/// Load guild_storage data to mem
-int guild_storage_fromsql(int guild_id, struct guild_storage* p)
+int inter_storage_guild_storage_fromsql(int guild_id, struct guild_storage* p)
{
StringBuf buf;
struct item* item;
@@ -102,34 +105,34 @@ int guild_storage_fromsql(int guild_id, struct guild_storage* p)
// storage {`guild_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`}
StrBuf->Init(&buf);
StrBuf->AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`bound`,`unique_id`");
- for( j = 0; j < MAX_SLOTS; ++j )
+ for( j = 0; j < MAX_SLOTS; ++j )
StrBuf->Printf(&buf, ",`card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `guild_id`='%d' ORDER BY `nameid`", guild_storage_db, guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)) )
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
- for( i = 0; i < MAX_GUILD_STORAGE && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i ) {
+ for( i = 0; i < MAX_GUILD_STORAGE && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i ) {
item = &p->items[i];
- SQL->GetData(sql_handle, 0, &data, NULL); item->id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); item->bound = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
- item->expire_time = 0;
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); item->id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); item->nameid = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); item->amount = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); item->equip = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); item->identify = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); item->refine = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); item->attribute = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); item->bound = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
+ item->expire_time = 0;
for( j = 0; j < MAX_SLOTS; ++j ) {
- SQL->GetData(sql_handle, 9+j, &data, NULL); item->card[j] = atoi(data);
+ SQL->GetData(inter->sql_handle, 9+j, &data, NULL); item->card[j] = atoi(data);
}
}
p->storage_amount = i;
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
ShowInfo("guild storage load complete from DB - id: %d (total: %d)\n", guild_id, p->storage_amount);
return 0;
@@ -150,25 +153,25 @@ void inter_storage_sql_final(void)
// q?f[^?
int inter_storage_delete(int account_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", storage_db, account_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", storage_db, account_id) )
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
-int inter_guild_storage_delete(int guild_id)
+int inter_storage_guild_storage_delete(int guild_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_storage_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_storage_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
//---------------------------------------------------------
// packet from map server
-int mapif_load_guild_storage(int fd,int account_id,int guild_id, char flag)
+int mapif_load_guild_storage(int fd, int account_id, int guild_id, char flag)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) )
- Sql_ShowDebug(sql_handle);
- else if( SQL->NumRows(sql_handle) > 0 )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL->NumRows(inter->sql_handle) > 0 )
{// guild exists
WFIFOHEAD(fd, sizeof(struct guild_storage)+13);
WFIFOW(fd,0) = 0x3818;
@@ -176,12 +179,12 @@ int mapif_load_guild_storage(int fd,int account_id,int guild_id, char flag)
WFIFOL(fd,4) = account_id;
WFIFOL(fd,8) = guild_id;
WFIFOB(fd,12) = flag; //1 open storage, 0 don't open
- guild_storage_fromsql(guild_id, (struct guild_storage*)WFIFOP(fd,13));
- WFIFOSET(fd, WFIFOW(fd,2));
+ inter_storage->guild_storage_fromsql(guild_id, (struct guild_storage*)WFIFOP(fd,13));
+ WFIFOSET(fd, WFIFOW(fd,2));
return 0;
}
// guild does not exist
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
WFIFOHEAD(fd, 12);
WFIFOW(fd,0) = 0x3818;
WFIFOW(fd,2) = 12;
@@ -190,7 +193,7 @@ int mapif_load_guild_storage(int fd,int account_id,int guild_id, char flag)
WFIFOSET(fd, 12);
return 0;
}
-int mapif_save_guild_storage_ack(int fd,int account_id,int guild_id,int fail)
+int mapif_save_guild_storage_ack(int fd, int account_id, int guild_id, int fail)
{
WFIFOHEAD(fd,11);
WFIFOW(fd,0)=0x3819;
@@ -207,7 +210,7 @@ int mapif_save_guild_storage_ack(int fd,int account_id,int guild_id,int fail)
int mapif_parse_LoadGuildStorage(int fd)
{
RFIFOHEAD(fd);
- mapif_load_guild_storage(fd,RFIFOL(fd,2),RFIFOL(fd,6),1);
+ mapif->load_guild_storage(fd,RFIFOL(fd,2),RFIFOL(fd,6),1);
return 0;
}
@@ -223,18 +226,18 @@ int mapif_parse_SaveGuildStorage(int fd)
if (sizeof(struct guild_storage) != len - 12) {
ShowError("inter storage: data size mismatch: %d != %"PRIuS"\n", len - 12, sizeof(struct guild_storage));
} else {
- if (SQL_ERROR == SQL->Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id)) {
- Sql_ShowDebug(sql_handle);
- } else if(SQL->NumRows(sql_handle) > 0) {
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id)) {
+ Sql_ShowDebug(inter->sql_handle);
+ } else if(SQL->NumRows(inter->sql_handle) > 0) {
// guild exists
- SQL->FreeResult(sql_handle);
- guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12));
- mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0);
+ SQL->FreeResult(inter->sql_handle);
+ inter_storage->guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12));
+ mapif->save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0);
return 0;
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
- mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 1);
+ mapif->save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 1);
return 0;
}
@@ -249,6 +252,7 @@ int mapif_itembound_ack(int fd, int aid, int guild_id)
#endif
return 0;
}
+
//------------------------------------------------
//Guild bound items pull for offline characters [Akinari]
//Revised by [Mhalicot]
@@ -272,16 +276,17 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
StrBuf->Printf(&buf, ", `card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`='%d' AND `bound` = '%d'",inventory_db,char_id,IBT_GUILD);
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SQL->StmtExecute(stmt) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
return 1;
}
+ memset(&item, 0, sizeof(item));
SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &item.id, 0, NULL, NULL);
SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &item.nameid, 0, NULL, NULL);
SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &item.amount, 0, NULL, NULL);
@@ -299,8 +304,8 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
memcpy(&items[i],&item,sizeof(struct item));
i++;
}
- SQL->FreeResult(sql_handle);
-
+ SQL->FreeResult(inter->sql_handle);
+
if(!i) { //No items found - No need to continue
StrBuf->Destroy(&buf);
SQL->StmtFree(stmt);
@@ -334,7 +339,7 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SQL->StmtExecute(stmt) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
return 1;
@@ -368,7 +373,7 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SQL->StmtExecute(stmt) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
return 1;
@@ -378,9 +383,9 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
//Now let's update the guild storage with those deleted items
/// TODO/FIXME:
- /// This approach is basically the same as the one from memitemdata_to_sql, but
+ /// This approach is basically the same as the one from chr->memitemdata_to_sql, but
/// the latter compares current database values and this is not needed in this case
- /// maybe sometime separate memitemdata_to_sql into different methods in order to use
+ /// maybe sometime separate chr->memitemdata_to_sql into different methods in order to use
/// call that function here as well [Panikon]
StrBuf->Clear(&buf);
StrBuf->Printf(&buf,"INSERT INTO `%s` (`guild_id`,`nameid`,`amount`,`equip`,`identify`,`refine`,"
@@ -405,7 +410,7 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SQL->StmtExecute(stmt) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
return 1;
@@ -415,29 +420,47 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
SQL->StmtFree(stmt);
//Finally reload storage and tell map we're done
- mapif_load_guild_storage(fd,aid,guild_id,0);
+ mapif->load_guild_storage(fd,aid,guild_id,0);
// If character is logged in char, disconnect
- disconnect_player(aid);
+ chr->disconnect_player(aid);
#endif
return 0;
}
-void mapif_parse_ItemBoundRetrieve(int fd) {
- mapif_parse_ItemBoundRetrieve_sub(fd);
+
+void mapif_parse_ItemBoundRetrieve(int fd)
+{
+ mapif->parse_ItemBoundRetrieve_sub(fd);
/* tell map server the operation is over and it can unlock the storage */
- mapif_itembound_ack(fd,RFIFOL(fd,6),RFIFOW(fd,10));
+ mapif->itembound_ack(fd,RFIFOL(fd,6),RFIFOW(fd,10));
}
+
int inter_storage_parse_frommap(int fd)
{
RFIFOHEAD(fd);
switch(RFIFOW(fd,0)){
- case 0x3018: mapif_parse_LoadGuildStorage(fd); break;
- case 0x3019: mapif_parse_SaveGuildStorage(fd); break;
+ case 0x3018: mapif->parse_LoadGuildStorage(fd); break;
+ case 0x3019: mapif->parse_SaveGuildStorage(fd); break;
#ifdef GP_BOUND_ITEMS
- case 0x3056: mapif_parse_ItemBoundRetrieve(fd); break;
+ case 0x3056: mapif->parse_ItemBoundRetrieve(fd); break;
#endif
default:
return 0;
}
return 1;
}
+
+void inter_storage_defaults(void)
+{
+ inter_storage = &inter_storage_s;
+
+ inter_storage->tosql = inter_storage_tosql;
+ inter_storage->fromsql = inter_storage_fromsql;
+ inter_storage->guild_storage_tosql = inter_storage_guild_storage_tosql;
+ inter_storage->guild_storage_fromsql = inter_storage_guild_storage_fromsql;
+ inter_storage->sql_init = inter_storage_sql_init;
+ inter_storage->sql_final = inter_storage_sql_final;
+ inter_storage->delete_ = inter_storage_delete;
+ inter_storage->guild_storage_delete = inter_storage_guild_storage_delete;
+ inter_storage->parse_frommap = inter_storage_parse_frommap;
+}
diff --git a/src/char/int_storage.h b/src/char/int_storage.h
index 1cef94d98..6c380f29b 100644
--- a/src/char/int_storage.h
+++ b/src/char/int_storage.h
@@ -7,16 +7,23 @@
struct storage_data;
struct guild_storage;
-int inter_storage_sql_init(void);
-void inter_storage_sql_final(void);
-int inter_storage_delete(int account_id);
-int inter_guild_storage_delete(int guild_id);
+void inter_storage_defaults(void);
-int inter_storage_parse_frommap(int fd);
+/**
+ * inter_storage interface
+ **/
+struct inter_storage_interface {
+ int (*tosql) (int account_id, struct storage_data* p);
+ int (*fromsql) (int account_id, struct storage_data* p);
+ int (*guild_storage_tosql) (int guild_id, struct guild_storage* p);
+ int (*guild_storage_fromsql) (int guild_id, struct guild_storage* p);
+ int (*sql_init) (void);
+ void (*sql_final) (void);
+ int (*delete_) (int account_id);
+ int (*guild_storage_delete) (int guild_id);
+ int (*parse_frommap) (int fd);
+};
-//Exported for use in the TXT-SQL converter.
-int storage_fromsql(int account_id, struct storage_data* p);
-int storage_tosql(int account_id,struct storage_data *p);
-int guild_storage_tosql(int guild_id, struct guild_storage *p);
+struct inter_storage_interface *inter_storage;
#endif /* CHAR_INT_STORAGE_H */
diff --git a/src/char/inter.c b/src/char/inter.c
index a7794c9c9..ab91e25b9 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -6,13 +6,12 @@
#include "inter.h"
-#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/stat.h> // for stat/lstat/fstat - [Dekamaster/Ultimate GM Tool]
#include "char.h"
+#include "geoip.h"
#include "int_auction.h"
#include "int_elemental.h"
#include "int_guild.h"
@@ -23,6 +22,7 @@
#include "int_pet.h"
#include "int_quest.h"
#include "int_storage.h"
+#include "mapif.h"
#include "../common/cbasetypes.h"
#include "../common/db.h"
#include "../common/malloc.h"
@@ -32,16 +32,15 @@
#include "../common/strlib.h"
#include "../common/timer.h"
-#define WISDATA_TTL (60*1000) //Wis data Time To Live (60 seconds)
-#define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis
+#define WISDATA_TTL (60*1000) // Wis data Time To Live (60 seconds)
+#define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis
-
-Sql* sql_handle = NULL;
+struct inter_interface inter_s;
int char_server_port = 3306;
char char_server_ip[32] = "127.0.0.1";
char char_server_id[32] = "ragnarok";
-char char_server_pw[32] = "ragnarok";
+char char_server_pw[100] = "ragnarok";
char char_server_db[32] = "ragnarok";
char default_codepage[32] = ""; //Feature by irmin.
@@ -49,7 +48,7 @@ unsigned int party_share_level = 10;
// recv. packet list
int inter_recv_packet_length[] = {
- -1,-1, 7,-1, -1,13,36, (2 + 4 + 4 + 4 + NAME_LENGTH), 0, 0, 0, 0, 0, 0, 0, 0, // 3000-
+ -1,-1, 7,-1, -1,13,36, (2 + 4 + 4 + 4 + NAME_LENGTH), 0, 0, 0, 0, 0, 0, 0, 0, // 3000-
6,-1, 0, 0, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, // 3010-
-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-
@@ -72,7 +71,7 @@ static int wis_dellist[WISDELLIST_MAX], wis_delnum;
#define MAX_JOB_NAMES 150
static char* msg_table[MAX_JOB_NAMES]; // messages 550 ~ 699 are job names
-const char* msg_txt(int msg_number) {
+const char* inter_msg_txt(int msg_number) {
msg_number -= 550;
if (msg_number >= 0 && msg_number < MAX_JOB_NAMES &&
msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
@@ -84,14 +83,15 @@ const char* msg_txt(int msg_number) {
/**
* Reads Message Data.
*
- * This is a modified version of the mapserver's msg_config_read to
+ * This is a modified version of the mapserver's inter->msg_config_read to
* only read messages with IDs between 550 and 550+MAX_JOB_NAMES.
*
* @param[in] cfg_name configuration filename to read.
* @param[in] allow_override whether to allow duplicate message IDs to override the original value.
* @return success state.
*/
-bool msg_config_read(const char *cfg_name, bool allow_override) {
+bool inter_msg_config_read(const char *cfg_name, bool allow_override)
+{
int msg_number;
char line[1024], w1[1024], w2[1024];
FILE *fp;
@@ -112,7 +112,7 @@ bool msg_config_read(const char *cfg_name, bool allow_override) {
continue;
if (strcmpi(w1, "import") == 0)
- msg_config_read(w2, true);
+ inter->msg_config_read(w2, true);
else {
msg_number = atoi(w1);
if( msg_number < 550 || msg_number > (550+MAX_JOB_NAMES) )
@@ -141,13 +141,15 @@ bool msg_config_read(const char *cfg_name, bool allow_override) {
/*==========================================
* Cleanup Message Data
*------------------------------------------*/
-void do_final_msg(void) {
+void inter_do_final_msg(void)
+{
int i;
for (i = 0; i < MAX_JOB_NAMES; i++)
aFree(msg_table[i]);
}
/* from pc.c due to @accinfo. any ideas to replace this crap are more than welcome. */
-const char* job_name(int class_) {
+const char* inter_job_name(int class_)
+{
switch (class_) {
case JOB_NOVICE: // 550
case JOB_SWORDMAN: // 551
@@ -156,7 +158,7 @@ const char* job_name(int class_) {
case JOB_ACOLYTE: // 554
case JOB_MERCHANT: // 555
case JOB_THIEF: // 556
- return msg_txt(550 - JOB_NOVICE+class_);
+ return inter->msg_txt(550 - JOB_NOVICE+class_);
case JOB_KNIGHT: // 557
case JOB_PRIEST: // 558
@@ -164,10 +166,10 @@ const char* job_name(int class_) {
case JOB_BLACKSMITH: // 560
case JOB_HUNTER: // 561
case JOB_ASSASSIN: // 562
- return msg_txt(557 - JOB_KNIGHT+class_);
+ return inter->msg_txt(557 - JOB_KNIGHT+class_);
case JOB_KNIGHT2:
- return msg_txt(557);
+ return inter->msg_txt(557);
case JOB_CRUSADER: // 563
case JOB_MONK: // 564
@@ -176,20 +178,20 @@ const char* job_name(int class_) {
case JOB_ALCHEMIST: // 567
case JOB_BARD: // 568
case JOB_DANCER: // 569
- return msg_txt(563 - JOB_CRUSADER+class_);
+ return inter->msg_txt(563 - JOB_CRUSADER+class_);
case JOB_CRUSADER2:
- return msg_txt(563);
+ return inter->msg_txt(563);
case JOB_WEDDING: // 570
case JOB_SUPER_NOVICE: // 571
case JOB_GUNSLINGER: // 572
case JOB_NINJA: // 573
case JOB_XMAS: // 574
- return msg_txt(570 - JOB_WEDDING+class_);
+ return inter->msg_txt(570 - JOB_WEDDING+class_);
case JOB_SUMMER:
- return msg_txt(621);
+ return inter->msg_txt(621);
case JOB_NOVICE_HIGH: // 575
case JOB_SWORDMAN_HIGH: // 576
@@ -198,7 +200,7 @@ const char* job_name(int class_) {
case JOB_ACOLYTE_HIGH: // 579
case JOB_MERCHANT_HIGH: // 580
case JOB_THIEF_HIGH: // 581
- return msg_txt(575 - JOB_NOVICE_HIGH+class_);
+ return inter->msg_txt(575 - JOB_NOVICE_HIGH+class_);
case JOB_LORD_KNIGHT: // 582
case JOB_HIGH_PRIEST: // 583
@@ -206,10 +208,10 @@ const char* job_name(int class_) {
case JOB_WHITESMITH: // 585
case JOB_SNIPER: // 586
case JOB_ASSASSIN_CROSS: // 587
- return msg_txt(582 - JOB_LORD_KNIGHT+class_);
+ return inter->msg_txt(582 - JOB_LORD_KNIGHT+class_);
case JOB_LORD_KNIGHT2:
- return msg_txt(582);
+ return inter->msg_txt(582);
case JOB_PALADIN: // 588
case JOB_CHAMPION: // 589
@@ -218,10 +220,10 @@ const char* job_name(int class_) {
case JOB_CREATOR: // 592
case JOB_CLOWN: // 593
case JOB_GYPSY: // 594
- return msg_txt(588 - JOB_PALADIN + class_);
+ return inter->msg_txt(588 - JOB_PALADIN + class_);
case JOB_PALADIN2:
- return msg_txt(588);
+ return inter->msg_txt(588);
case JOB_BABY: // 595
case JOB_BABY_SWORDMAN: // 596
@@ -230,7 +232,7 @@ const char* job_name(int class_) {
case JOB_BABY_ACOLYTE: // 599
case JOB_BABY_MERCHANT: // 600
case JOB_BABY_THIEF: // 601
- return msg_txt(595 - JOB_BABY + class_);
+ return inter->msg_txt(595 - JOB_BABY + class_);
case JOB_BABY_KNIGHT: // 602
case JOB_BABY_PRIEST: // 603
@@ -238,10 +240,10 @@ const char* job_name(int class_) {
case JOB_BABY_BLACKSMITH: // 605
case JOB_BABY_HUNTER: // 606
case JOB_BABY_ASSASSIN: // 607
- return msg_txt(602 - JOB_BABY_KNIGHT + class_);
+ return inter->msg_txt(602 - JOB_BABY_KNIGHT + class_);
case JOB_BABY_KNIGHT2:
- return msg_txt(602);
+ return inter->msg_txt(602);
case JOB_BABY_CRUSADER: // 608
case JOB_BABY_MONK: // 609
@@ -250,26 +252,26 @@ const char* job_name(int class_) {
case JOB_BABY_ALCHEMIST: // 612
case JOB_BABY_BARD: // 613
case JOB_BABY_DANCER: // 614
- return msg_txt(608 - JOB_BABY_CRUSADER + class_);
+ return inter->msg_txt(608 - JOB_BABY_CRUSADER + class_);
case JOB_BABY_CRUSADER2:
- return msg_txt(608);
+ return inter->msg_txt(608);
case JOB_SUPER_BABY:
- return msg_txt(615);
+ return inter->msg_txt(615);
case JOB_TAEKWON:
- return msg_txt(616);
+ return inter->msg_txt(616);
case JOB_STAR_GLADIATOR:
case JOB_STAR_GLADIATOR2:
- return msg_txt(617);
+ return inter->msg_txt(617);
case JOB_SOUL_LINKER:
- return msg_txt(618);
+ return inter->msg_txt(618);
case JOB_GANGSI: // 622
case JOB_DEATH_KNIGHT: // 623
case JOB_DARK_COLLECTOR: // 624
- return msg_txt(622 - JOB_GANGSI+class_);
+ return inter->msg_txt(622 - JOB_GANGSI+class_);
case JOB_RUNE_KNIGHT: // 625
case JOB_WARLOCK: // 626
@@ -277,7 +279,7 @@ const char* job_name(int class_) {
case JOB_ARCH_BISHOP: // 628
case JOB_MECHANIC: // 629
case JOB_GUILLOTINE_CROSS: // 630
- return msg_txt(625 - JOB_RUNE_KNIGHT+class_);
+ return inter->msg_txt(625 - JOB_RUNE_KNIGHT+class_);
case JOB_RUNE_KNIGHT_T: // 656
case JOB_WARLOCK_T: // 657
@@ -285,7 +287,7 @@ const char* job_name(int class_) {
case JOB_ARCH_BISHOP_T: // 659
case JOB_MECHANIC_T: // 660
case JOB_GUILLOTINE_CROSS_T: // 661
- return msg_txt(656 - JOB_RUNE_KNIGHT_T+class_);
+ return inter->msg_txt(656 - JOB_RUNE_KNIGHT_T+class_);
case JOB_ROYAL_GUARD: // 631
case JOB_SORCERER: // 632
@@ -294,7 +296,7 @@ const char* job_name(int class_) {
case JOB_SURA: // 635
case JOB_GENETIC: // 636
case JOB_SHADOW_CHASER: // 637
- return msg_txt(631 - JOB_ROYAL_GUARD+class_);
+ return inter->msg_txt(631 - JOB_ROYAL_GUARD+class_);
case JOB_ROYAL_GUARD_T: // 662
case JOB_SORCERER_T: // 663
@@ -303,31 +305,31 @@ const char* job_name(int class_) {
case JOB_SURA_T: // 666
case JOB_GENETIC_T: // 667
case JOB_SHADOW_CHASER_T: // 668
- return msg_txt(662 - JOB_ROYAL_GUARD_T+class_);
+ return inter->msg_txt(662 - JOB_ROYAL_GUARD_T+class_);
case JOB_RUNE_KNIGHT2:
- return msg_txt(625);
+ return inter->msg_txt(625);
case JOB_RUNE_KNIGHT_T2:
- return msg_txt(656);
+ return inter->msg_txt(656);
case JOB_ROYAL_GUARD2:
- return msg_txt(631);
+ return inter->msg_txt(631);
case JOB_ROYAL_GUARD_T2:
- return msg_txt(662);
+ return inter->msg_txt(662);
case JOB_RANGER2:
- return msg_txt(627);
+ return inter->msg_txt(627);
case JOB_RANGER_T2:
- return msg_txt(658);
+ return inter->msg_txt(658);
case JOB_MECHANIC2:
- return msg_txt(629);
+ return inter->msg_txt(629);
case JOB_MECHANIC_T2:
- return msg_txt(660);
+ return inter->msg_txt(660);
case JOB_BABY_RUNE: // 638
case JOB_BABY_WARLOCK: // 639
@@ -342,197 +344,42 @@ const char* job_name(int class_) {
case JOB_BABY_SURA: // 648
case JOB_BABY_GENETIC: // 649
case JOB_BABY_CHASER: // 650
- return msg_txt(638 - JOB_BABY_RUNE+class_);
+ return inter->msg_txt(638 - JOB_BABY_RUNE+class_);
case JOB_BABY_RUNE2:
- return msg_txt(638);
+ return inter->msg_txt(638);
case JOB_BABY_GUARD2:
- return msg_txt(644);
+ return inter->msg_txt(644);
case JOB_BABY_RANGER2:
- return msg_txt(640);
+ return inter->msg_txt(640);
case JOB_BABY_MECHANIC2:
- return msg_txt(642);
+ return inter->msg_txt(642);
case JOB_SUPER_NOVICE_E: // 651
case JOB_SUPER_BABY_E: // 652
- return msg_txt(651 - JOB_SUPER_NOVICE_E+class_);
+ return inter->msg_txt(651 - JOB_SUPER_NOVICE_E+class_);
case JOB_KAGEROU: // 653
case JOB_OBORO: // 654
- return msg_txt(653 - JOB_KAGEROU+class_);
+ return inter->msg_txt(653 - JOB_KAGEROU+class_);
case JOB_REBELLION:
- return msg_txt(655);
+ return inter->msg_txt(655);
default:
- return msg_txt(620); // "Unknown Job"
- }
-}
-
-/* [Dekamaster/Nightroad] */
-#define GEOIP_MAX_COUNTRIES 255
-#define GEOIP_STRUCTURE_INFO_MAX_SIZE 20
-#define GEOIP_COUNTRY_BEGIN 16776960
-
-const char * geoip_countryname[GEOIP_MAX_COUNTRIES] = {"Unknown","Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Netherlands Antilles",
- "Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Azerbaijan","Bosnia and Herzegovina","Barbados",
- "Bangladesh","Belgium","Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia",
- "Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands","Congo, The Democratic Republic of the",
- "Central African Republic","Congo","Switzerland","Cote D'Ivoire","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica",
- "Cuba","Cape Verde","Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark","Dominica","Dominican Republic",
- "Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji",
- "Falkland Islands (Malvinas)","Micronesia, Federated States of","Faroe Islands","France","France, Metropolitan","Gabon","United Kingdom","Grenada","Georgia","French Guiana",
- "Ghana","Gibraltar","Greenland","Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece","South Georgia and the South Sandwich Islands","Guatemala",
- "Guam","Guinea-Bissau","Guyana","Hong Kong","Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary","Indonesia",
- "Ireland","Israel","India","British Indian Ocean Territory","Iraq","Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan",
- "Japan","Kenya","Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis","Korea, Democratic People's Republic of","Korea, Republic of","Kuwait",
- "Cayman Islands","Kazakhstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein","Sri Lanka","Liberia","Lesotho","Lithuania",
- "Luxembourg","Latvia","Libyan Arab Jamahiriya","Morocco","Monaco","Moldova, Republic of","Madagascar","Marshall Islands","Macedonia","Mali",
- "Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique","Mauritania","Montserrat","Malta","Mauritius","Maldives",
- "Malawi","Mexico","Malaysia","Mozambique","Namibia","New Caledonia","Niger","Norfolk Island","Nigeria","Nicaragua",
- "Netherlands","Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru","French Polynesia",
- "Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon","Pitcairn Islands","Puerto Rico","Palestinian Territory","Portugal","Palau",
- "Paraguay","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia","Solomon Islands","Seychelles","Sudan",
- "Sweden","Singapore","Saint Helena","Slovenia","Svalbard and Jan Mayen","Slovakia","Sierra Leone","San Marino","Senegal","Somalia","Suriname",
- "Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland","Turks and Caicos Islands","Chad","French Southern Territories","Togo","Thailand",
- "Tajikistan","Tokelau","Turkmenistan","Tunisia","Tonga","Timor-Leste","Turkey","Trinidad and Tobago","Tuvalu","Taiwan",
- "Tanzania, United Republic of","Ukraine","Uganda","United States Minor Outlying Islands","United States","Uruguay","Uzbekistan","Holy See (Vatican City State)","Saint Vincent and the Grenadines","Venezuela",
- "Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna","Samoa","Yemen","Mayotte","Serbia","South Africa",
- "Zambia","Montenegro","Zimbabwe","Anonymous Proxy","Satellite Provider","Other","Aland Islands","Guernsey","Isle of Man","Jersey",
- "Saint Barthelemy", "Saint Martin", "Bonaire, Saint Eustatius and Saba", "South Sudan"};
-/**
- * GeoIP information
- **/
-struct s_geoip {
- unsigned char *cache; // GeoIP.dat information see geoip_init()
- bool active;
-} geoip;
-
-/* [Dekamaster/Nightroad] */
-/* WHY NOT A DBMAP: There are millions of entries in GeoIP and it has its own algorithm to go quickly through them, a DBMap wouldn't be efficient */
-const char* geoip_getcountry(uint32 ipnum){
- int depth;
- unsigned int x;
- const unsigned char *buf;
- unsigned int offset = 0;
-
- if( geoip.active == false )
- return geoip_countryname[0];
-
- for (depth = 31; depth >= 0; depth--) {
- buf = geoip.cache + (long)6 *offset;
- if (ipnum & (1 << depth)) {
- /* Take the right-hand branch */
- x = (buf[3*1 + 0] << (0*8))
- + (buf[3*1 + 1] << (1*8))
- + (buf[3*1 + 2] << (2*8));
- } else {
- /* Take the left-hand branch */
- x = (buf[3*0 + 0] << (0*8))
- + (buf[3*0 + 1] << (1*8))
- + (buf[3*0 + 2] << (2*8));
- }
- if (x >= GEOIP_COUNTRY_BEGIN) {
- x = x-GEOIP_COUNTRY_BEGIN;
-
- if( x > GEOIP_MAX_COUNTRIES )
- return geoip_countryname[0];
-
- return geoip_countryname[x];
- }
- offset = x;
- }
- ShowError("geoip_getcountry(): Error traversing database for ipnum %d\n", ipnum);
- ShowWarning("geoip_getcountry(): Possible database corruption!\n");
-
- return geoip_countryname[0];
-}
-
-/**
- * Disables GeoIP
- * frees geoip.cache
- **/
-void geoip_final(bool shutdown) {
- if (geoip.cache) {
- aFree(geoip.cache);
- geoip.cache = NULL;
- }
-
- if (geoip.active) {
- if (!shutdown)
- ShowStatus("GeoIP "CL_RED"disabled"CL_RESET".\n");
- geoip.active = false;
- }
-}
-
-/**
- * Reads GeoIP database and stores it into memory
- * geoip.cache should be freed after use!
- * http://dev.maxmind.com/geoip/legacy/geolite/
- **/
-void geoip_init(void) {
- int i, fno;
- char db_type = 1;
- unsigned char delim[3];
- struct stat bufa;
- FILE *db;
-
- geoip.active = true;
-
- db = fopen("./db/GeoIP.dat","rb");
- if( db == NULL ) {
- ShowError("geoip_readdb: Error reading GeoIP.dat!\n");
- geoip_final(false);
- return;
- }
- fno = fileno(db);
- if( fstat(fno, &bufa) < 0 ) {
- ShowError("geoip_readdb: Error stating GeoIP.dat! Error %d\n", errno);
- geoip_final(false);
- return;
- }
- geoip.cache = aMalloc( (sizeof(geoip.cache) * bufa.st_size) );
- if( fread(geoip.cache, sizeof(unsigned char), bufa.st_size, db) != bufa.st_size ) {
- ShowError("geoip_cache: Couldn't read all elements!\n");
- fclose(db);
- geoip_final(false);
- return;
- }
-
- // Search database type
- fseek(db, -3l, SEEK_END);
- for( i = 0; i < GEOIP_STRUCTURE_INFO_MAX_SIZE; i++ ) {
- fread(delim, sizeof(delim[0]), 3, db);
- if( delim[0] == 255 && delim[1] == 255 && delim[2] == 255 ) {
- fread(&db_type, sizeof(db_type), 1, db);
- break;
- } else {
- fseek(db, -4l, SEEK_CUR);
- }
- }
-
- fclose(db);
-
- if( db_type != 1 ) {
- if( db_type )
- ShowError("geoip_init(): Database type is not supported %d!\n", db_type);
- else
- ShowError("geoip_init(): GeoIP is corrupted!\n");
-
- geoip_final(false);
- return;
+ return inter->msg_txt(620); // "Unknown Job"
}
- ShowStatus("Finished Reading "CL_GREEN"GeoIP"CL_RESET" Database.\n");
}
/**
* Argument-list version of inter_msg_to_fd
* @see inter_msg_to_fd
*/
-void inter_vmsg_to_fd(int fd, int u_fd, int aid, char* msg, va_list ap) {
+void inter_vmsg_to_fd(int fd, int u_fd, int aid, char* msg, va_list ap)
+{
char msg_out[512];
va_list apcopy;
int len = 1;/* yes we start at 1 */
@@ -564,15 +411,17 @@ void inter_vmsg_to_fd(int fd, int u_fd, int aid, char* msg, va_list ap) {
* @param ... Additional parameters for (v)sprinf
*/
void inter_msg_to_fd(int fd, int u_fd, int aid, char *msg, ...) __attribute__((format(printf, 4, 5)));
-void inter_msg_to_fd(int fd, int u_fd, int aid, char *msg, ...) {
+void inter_msg_to_fd(int fd, int u_fd, int aid, char *msg, ...)
+{
va_list ap;
va_start(ap,msg);
- inter_vmsg_to_fd(fd, u_fd, aid, msg, ap);
+ inter->vmsg_to_fd(fd, u_fd, aid, msg, ap);
va_end(ap);
}
/* [Dekamaster/Nightroad] */
-void mapif_parse_accinfo(int fd) {
+void mapif_parse_accinfo(int fd)
+{
int u_fd = RFIFOL(fd,2), aid = RFIFOL(fd,6), castergroup = RFIFOL(fd,10);
char query[NAME_LENGTH], query_esq[NAME_LENGTH*2+1];
int account_id;
@@ -580,43 +429,44 @@ void mapif_parse_accinfo(int fd) {
safestrncpy(query, (char*) RFIFOP(fd,14), NAME_LENGTH);
- SQL->EscapeString(sql_handle, query_esq, query);
+ SQL->EscapeString(inter->sql_handle, query_esq, query);
account_id = atoi(query);
- if (account_id < START_ACCOUNT_NUM) { // is string
- if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", char_db, query_esq)
- || SQL->NumRows(sql_handle) == 0 ) {
- if( SQL->NumRows(sql_handle) == 0 ) {
- inter_msg_to_fd(fd, u_fd, aid, "No matches were found for your criteria, '%s'",query);
+ if (account_id < START_ACCOUNT_NUM) {
+ // is string
+ if ( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", char_db, query_esq)
+ || SQL->NumRows(inter->sql_handle) == 0 ) {
+ if( SQL->NumRows(inter->sql_handle) == 0 ) {
+ inter->msg_to_fd(fd, u_fd, aid, "No matches were found for your criteria, '%s'",query);
} else {
- Sql_ShowDebug(sql_handle);
- inter_msg_to_fd(fd, u_fd, aid, "An error occurred, bother your admin about it.");
+ Sql_ShowDebug(inter->sql_handle);
+ inter->msg_to_fd(fd, u_fd, aid, "An error occurred, bother your admin about it.");
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return;
} else {
- if( SQL->NumRows(sql_handle) == 1 ) {//we found a perfect match
- SQL->NextRow(sql_handle);
- SQL->GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
- SQL->FreeResult(sql_handle);
+ if( SQL->NumRows(inter->sql_handle) == 1 ) {//we found a perfect match
+ SQL->NextRow(inter->sql_handle);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); account_id = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
} else {// more than one, listing... [Dekamaster/Nightroad]
- inter_msg_to_fd(fd, u_fd, aid, "Your query returned the following %d results, please be more specific...",(int)SQL->NumRows(sql_handle));
- while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
+ inter->msg_to_fd(fd, u_fd, aid, "Your query returned the following %d results, please be more specific...",(int)SQL->NumRows(inter->sql_handle));
+ while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) {
int class_;
short base_level, job_level, online;
char name[NAME_LENGTH];
- SQL->GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
- SQL->GetData(sql_handle, 2, &data, NULL); class_ = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); base_level = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); job_level = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); online = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); base_level = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); job_level = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); online = atoi(data);
- inter_msg_to_fd(fd, u_fd, aid, "[AID: %d] %s | %s | Level: %d/%d | %s", account_id, name, job_name(class_), base_level, job_level, online?"Online":"Offline");
+ inter->msg_to_fd(fd, u_fd, aid, "[AID: %d] %s | %s | Level: %d/%d | %s", account_id, name, inter->job_name(class_), base_level, job_level, online?"Online":"Offline");
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return;
}
}
@@ -625,63 +475,66 @@ void mapif_parse_accinfo(int fd) {
/* it will only get here if we have a single match */
/* and we will send packet with account id to login server asking for account info */
if( account_id ) {
- mapif_on_parse_accinfo(account_id, u_fd, aid, castergroup, fd);
+ mapif->on_parse_accinfo(account_id, u_fd, aid, castergroup, fd);
}
return;
}
-void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state) {
+void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass,
+ const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate,
+ int group_id, int logincount, int state)
+{
if (map_fd <= 0 || !session_isActive(map_fd))
return; // check if we have a valid fd
if (!success) {
- inter_msg_to_fd(map_fd, u_fd, u_aid, "No account with ID '%d' was found.", account_id);
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "No account with ID '%d' was found.", account_id);
return;
}
- inter_msg_to_fd(map_fd, u_fd, u_aid, "-- Account %d --", account_id);
- inter_msg_to_fd(map_fd, u_fd, u_aid, "User: %s | GM Group: %d | State: %d", userid, group_id, state);
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "-- Account %d --", account_id);
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "User: %s | GM Group: %d | State: %d", userid, group_id, state);
if (user_pass && *user_pass != '\0') { /* password is only received if your gm level is greater than the one you're searching for */
if (pin_code && *pin_code != '\0')
- inter_msg_to_fd(map_fd, u_fd, u_aid, "Password: %s (PIN:%s)", user_pass, pin_code);
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "Password: %s (PIN:%s)", user_pass, pin_code);
else
- inter_msg_to_fd(map_fd, u_fd, u_aid, "Password: %s", user_pass );
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "Password: %s", user_pass );
}
- inter_msg_to_fd(map_fd, u_fd, u_aid, "Account e-mail: %s | Birthdate: %s", email, birthdate);
- inter_msg_to_fd(map_fd, u_fd, u_aid, "Last IP: %s (%s)", last_ip, geoip_getcountry(str2ip(last_ip)));
- inter_msg_to_fd(map_fd, u_fd, u_aid, "This user has logged %d times, the last time were at %s", logincount, lastlogin);
- inter_msg_to_fd(map_fd, u_fd, u_aid, "-- Character Details --");
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "Account e-mail: %s | Birthdate: %s", email, birthdate);
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "Last IP: %s (%s)", last_ip, geoip->getcountry(str2ip(last_ip)));
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "This user has logged %d times, the last time were at %s", logincount, lastlogin);
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "-- Character Details --");
- if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` "
+ if ( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` "
"FROM `%s` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", char_db, account_id, MAX_CHARS)
- || SQL->NumRows(sql_handle) == 0 ) {
- if (SQL->NumRows(sql_handle) == 0) {
- inter_msg_to_fd(map_fd, u_fd, u_aid, "This account doesn't have characters.");
+ || SQL->NumRows(inter->sql_handle) == 0 ) {
+ if (SQL->NumRows(inter->sql_handle) == 0) {
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "This account doesn't have characters.");
} else {
- inter_msg_to_fd(map_fd, u_fd, u_aid, "An error occurred, bother your admin about it.");
- Sql_ShowDebug(sql_handle);
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "An error occurred, bother your admin about it.");
+ Sql_ShowDebug(inter->sql_handle);
}
} else {
- while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
+ while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) {
char *data;
int char_id, class_;
short char_num, base_level, job_level, online;
char name[NAME_LENGTH];
- SQL->GetData(sql_handle, 0, &data, NULL); char_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
- SQL->GetData(sql_handle, 2, &data, NULL); char_num = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); class_ = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); job_level = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); online = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); char_num = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); base_level = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); job_level = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); online = atoi(data);
- inter_msg_to_fd(map_fd, u_fd, u_aid, "[Slot/CID: %d/%d] %s | %s | Level: %d/%d | %s", char_num, char_id, name, job_name(class_), base_level, job_level, online?"On":"Off");
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "[Slot/CID: %d/%d] %s | %s | Level: %d/%d | %s", char_num, char_id, name, inter->job_name(class_), base_level, job_level, online?"On":"Off");
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return;
}
@@ -691,48 +544,52 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc
* @param val either str or int, depending on type
* @param type false when int, true otherwise
**/
-void inter_savereg(int account_id, int char_id, const char *key, unsigned int index, intptr_t val, bool is_string) {
+void inter_savereg(int account_id, int char_id, const char *key, unsigned int index, intptr_t val, bool is_string)
+{
/* to login server we go! */
if( key[0] == '#' && key[1] == '#' ) {/* global account reg */
- global_accreg_to_login_add(key,index,val,is_string);
+ if( session_isValid(chr->login_fd) )
+ chr->global_accreg_to_login_add(key,index,val,is_string);
+ else {
+ ShowError("Login server unavailable, cant perform update on '%s' variable for AID:%d CID:%d\n",key,account_id,char_id);
+ }
} else if ( key[0] == '#' ) {/* local account reg */
if( is_string ) {
if( val ) {
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%s')", acc_reg_str_db, account_id, key, index, (char*)val) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%s')", acc_reg_str_db, account_id, key, index, (char*)val) )
+ Sql_ShowDebug(inter->sql_handle);
} else {
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", acc_reg_str_db, account_id, key, index) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", acc_reg_str_db, account_id, key, index) )
+ Sql_ShowDebug(inter->sql_handle);
}
} else {
if( val ) {
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%d')", acc_reg_num_db, account_id, key, index, (int)val) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%d')", acc_reg_num_db, account_id, key, index, (int)val) )
+ Sql_ShowDebug(inter->sql_handle);
} else {
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", acc_reg_num_db, account_id, key, index) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", acc_reg_num_db, account_id, key, index) )
+ Sql_ShowDebug(inter->sql_handle);
}
}
} else { /* char reg */
if( is_string ) {
if( val ) {
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`char_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%s')", char_reg_str_db, char_id, key, index, (char*)val) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`char_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%s')", char_reg_str_db, char_id, key, index, (char*)val) )
+ Sql_ShowDebug(inter->sql_handle);
} else {
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", char_reg_str_db, char_id, key, index) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", char_reg_str_db, char_id, key, index) )
+ Sql_ShowDebug(inter->sql_handle);
}
} else {
if( val ) {
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`char_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%d')", char_reg_num_db, char_id, key, index, (int)val) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`char_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%d')", char_reg_num_db, char_id, key, index, (int)val) )
+ Sql_ShowDebug(inter->sql_handle);
} else {
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", char_reg_num_db, char_id, key, index) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", char_reg_num_db, char_id, key, index) )
+ Sql_ShowDebug(inter->sql_handle);
}
}
}
-
}
// Load account_reg from sql (type=2)
@@ -744,21 +601,21 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type)
switch( type ) {
case 3: //char reg
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%d'", char_reg_str_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%d'", char_reg_str_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
break;
case 2: //account reg
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", acc_reg_str_db, account_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", acc_reg_str_db, account_id) )
+ Sql_ShowDebug(inter->sql_handle);
break;
case 1: //account2 reg
- ShowError("inter_accreg_fromsql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
+ ShowError("inter->accreg_fromsql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
return 0;
default:
- ShowError("inter_accreg_fromsql: Invalid type %d\n", type);
+ ShowError("inter->accreg_fromsql: Invalid type %d\n", type);
return 0;
}
-
+
WFIFOHEAD(fd, 60000 + 300);
WFIFOW(fd, 0) = 0x3804;
/* 0x2 = length, set prior to being sent */
@@ -768,44 +625,43 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type)
WFIFOB(fd, 13) = 1;/* is string type */
WFIFOW(fd, 14) = 0;/* count */
plen = 16;
-
+
/**
* Vessel!
*
* str type
* { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) }
**/
- while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
-
- SQL->GetData(sql_handle, 0, &data, NULL);
+ while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) {
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
len = strlen(data)+1;
-
+
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */
plen += 1;
-
+
safestrncpy((char*)WFIFOP(fd,plen), data, len);
plen += len;
-
- SQL->GetData(sql_handle, 1, &data, NULL);
+
+ SQL->GetData(inter->sql_handle, 1, &data, NULL);
WFIFOL(fd, plen) = (unsigned int)atol(data);
plen += 4;
- SQL->GetData(sql_handle, 2, &data, NULL);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL);
len = strlen(data)+1;
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 254 */
plen += 1;
-
+
safestrncpy((char*)WFIFOP(fd,plen), data, len);
plen += len;
WFIFOW(fd, 14) += 1;
-
+
if( plen > 60000 ) {
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
-
+
/* prepare follow up */
WFIFOHEAD(fd, 60000 + 300);
WFIFOW(fd, 0) = 0x3804;
@@ -818,24 +674,24 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type)
plen = 16;
}
}
-
+
/* mark & go. */
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
- SQL->FreeResult(sql_handle);
-
+ SQL->FreeResult(inter->sql_handle);
+
switch( type ) {
case 3: //char reg
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%d'", char_reg_num_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%d'", char_reg_num_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
break;
case 2: //account reg
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", acc_reg_num_db, account_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", acc_reg_num_db, account_id) )
+ Sql_ShowDebug(inter->sql_handle);
break;
case 1: //account2 reg
- ShowError("inter_accreg_fromsql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
+ ShowError("inter->accreg_fromsql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
return 0;
}
@@ -848,40 +704,39 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type)
WFIFOB(fd, 13) = 0;/* is int type */
WFIFOW(fd, 14) = 0;/* count */
plen = 16;
-
+
/**
* Vessel!
*
* int type
* { keyLength(B), key(<keyLength>), index(L), value(L) }
**/
- while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
-
- SQL->GetData(sql_handle, 0, &data, NULL);
+ while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) {
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
len = strlen(data)+1;
-
+
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */
plen += 1;
-
+
safestrncpy((char*)WFIFOP(fd,plen), data, len);
plen += len;
-
- SQL->GetData(sql_handle, 1, &data, NULL);
-
+
+ SQL->GetData(inter->sql_handle, 1, &data, NULL);
+
WFIFOL(fd, plen) = (unsigned int)atol(data);
plen += 4;
-
- SQL->GetData(sql_handle, 2, &data, NULL);
-
+
+ SQL->GetData(inter->sql_handle, 2, &data, NULL);
+
WFIFOL(fd, plen) = atoi(data);
plen += 4;
-
+
WFIFOW(fd, 14) += 1;
-
+
if( plen > 60000 ) {
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
-
+
/* prepare follow up */
WFIFOHEAD(fd, 60000 + 300);
WFIFOW(fd, 0) = 0x3804;
@@ -894,13 +749,13 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type)
plen = 16;
}
}
-
+
/* mark as complete & go. */
WFIFOB(fd, 12) = type;
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
-
- SQL->FreeResult(sql_handle);
+
+ SQL->FreeResult(inter->sql_handle);
return 1;
}
@@ -947,7 +802,7 @@ static int inter_config_read(const char* cfgName)
else if(!strcmpi(w1,"log_inter"))
log_inter = atoi(w2);
else if(!strcmpi(w1,"import"))
- inter_config_read(w2);
+ inter->config_read(w2);
}
fclose(fp);
@@ -960,7 +815,8 @@ static int inter_config_read(const char* cfgName)
* Save interlog into sql (arglist version)
* @see inter_log
*/
-int inter_vlog(char* fmt, va_list ap) {
+int inter_vlog(char* fmt, va_list ap)
+{
char str[255];
char esc_str[sizeof(str)*2+1];// escaped str
va_list apcopy;
@@ -969,9 +825,9 @@ int inter_vlog(char* fmt, va_list ap) {
vsnprintf(str, sizeof(str), fmt, apcopy);
va_end(apcopy);
- SQL->EscapeStringLen(sql_handle, esc_str, str, strnlen(str, sizeof(str)));
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`time`, `log`) VALUES (NOW(), '%s')", interlog_db, esc_str) )
- Sql_ShowDebug(sql_handle);
+ SQL->EscapeStringLen(inter->sql_handle, esc_str, str, strnlen(str, sizeof(str)));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` (`time`, `log`) VALUES (NOW(), '%s')", interlog_db, esc_str) )
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
@@ -982,12 +838,13 @@ int inter_vlog(char* fmt, va_list ap) {
* @param ... Additional (printf-like) arguments
* @return Always 0 // FIXME
*/
-int inter_log(char* fmt, ...) {
+int inter_log(char* fmt, ...)
+{
va_list ap;
int ret;
va_start(ap,fmt);
- ret = inter_vlog(fmt, ap);
+ ret = inter->vlog(fmt, ap);
va_end(ap);
return ret;
@@ -998,36 +855,36 @@ int inter_init_sql(const char *file)
{
//int i;
- inter_config_read(file);
+ inter->config_read(file);
//DB connection initialized
- sql_handle = SQL->Malloc();
+ inter->sql_handle = SQL->Malloc();
ShowInfo("Connect Character DB server.... (Character Server)\n");
- if( SQL_ERROR == SQL->Connect(sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) )
+ if( SQL_ERROR == SQL->Connect(inter->sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) )
{
- Sql_ShowDebug(sql_handle);
- SQL->Free(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
+ SQL->Free(inter->sql_handle);
exit(EXIT_FAILURE);
}
if( *default_codepage ) {
- if( SQL_ERROR == SQL->SetEncoding(sql_handle, default_codepage) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->SetEncoding(inter->sql_handle, default_codepage) )
+ Sql_ShowDebug(inter->sql_handle);
}
wis_db = idb_alloc(DB_OPT_RELEASE_DATA);
- inter_guild_sql_init();
- inter_storage_sql_init();
- inter_party_sql_init();
- inter_pet_sql_init();
- inter_homunculus_sql_init();
- inter_mercenary_sql_init();
- inter_elemental_sql_init();
- inter_mail_sql_init();
- inter_auction_sql_init();
-
- geoip_init();
- msg_config_read("conf/messages.conf", false);
+ inter_guild->sql_init();
+ inter_storage->sql_init();
+ inter_party->sql_init();
+ inter_pet->sql_init();
+ inter_homunculus->sql_init();
+ inter_mercenary->sql_init();
+ inter_elemental->sql_init();
+ inter_mail->sql_init();
+ inter_auction->sql_init();
+
+ geoip->init();
+ inter->msg_config_read("conf/messages.conf", false);
return 0;
}
@@ -1036,18 +893,18 @@ void inter_final(void)
{
wis_db->destroy(wis_db, NULL);
- inter_guild_sql_final();
- inter_storage_sql_final();
- inter_party_sql_final();
- inter_pet_sql_final();
- inter_homunculus_sql_final();
- inter_mercenary_sql_final();
- inter_elemental_sql_final();
- inter_mail_sql_final();
- inter_auction_sql_final();
-
- geoip_final(true);
- do_final_msg();
+ inter_guild->sql_final();
+ inter_storage->sql_final();
+ inter_party->sql_final();
+ inter_pet->sql_final();
+ inter_homunculus->sql_final();
+ inter_mercenary->sql_final();
+ inter_elemental->sql_final();
+ inter_mail->sql_final();
+ inter_auction->sql_final();
+
+ geoip->final(true);
+ inter->do_final_msg();
return;
}
@@ -1072,7 +929,7 @@ int mapif_broadcast(unsigned char *mes, int len, unsigned int fontColor, short f
WBUFW(buf,12) = fontAlign;
WBUFW(buf,14) = fontY;
memcpy(WBUFP(buf,16), mes, len - 16);
- mapif_sendallwos(sfd, buf, len);
+ mapif->sendallwos(sfd, buf, len);
if (buf)
aFree(buf);
@@ -1091,33 +948,40 @@ int mapif_wis_message(struct WisData *wd)
memcpy(WBUFP(buf, 8), wd->src, NAME_LENGTH);
memcpy(WBUFP(buf,32), wd->dst, NAME_LENGTH);
memcpy(WBUFP(buf,56), wd->msg, wd->len);
- wd->count = mapif_sendall(buf,WBUFW(buf,2));
+ wd->count = mapif->sendall(buf,WBUFW(buf,2));
return 0;
}
-// Wis sending result
-int mapif_wis_end(struct WisData *wd, int flag)
+void mapif_wis_response(int fd, unsigned char *src, int flag)
{
unsigned char buf[27];
-
WBUFW(buf, 0)=0x3802;
- memcpy(WBUFP(buf, 2),wd->src,24);
+ memcpy(WBUFP(buf, 2),src,24);
WBUFB(buf,26)=flag;
- mapif_send(wd->fd,buf,27);
+ mapif->send(fd,buf,27);
+}
+
+// Wis sending result
+int mapif_wis_end(struct WisData *wd, int flag)
+{
+ mapif->wis_response(wd->fd, wd->src, flag);
return 0;
}
+#if 0
// Account registry transfer to map-server
-//static void mapif_account_reg(int fd, unsigned char *src)
-//{
-// WBUFW(src,0)=0x3804; //NOTE: writing to RFIFO
-// mapif_sendallwos(fd, src, WBUFW(src,2));
-//}
+static void mapif_account_reg(int fd, unsigned char *src)
+{
+ WBUFW(src,0)=0x3804; //NOTE: writing to RFIFO
+ mapif->sendallwos(fd, src, WBUFW(src,2));
+}
+#endif // 0
// Send the requested account_reg
-int mapif_account_reg_reply(int fd,int account_id,int char_id, int type) {
- inter_accreg_fromsql(account_id,char_id,fd,type);
+int mapif_account_reg_reply(int fd,int account_id,int char_id, int type)
+{
+ inter->accreg_fromsql(account_id,char_id,fd,type);
return 0;
}
@@ -1142,7 +1006,7 @@ int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason)
* Existence check of WISP data
* @see DBApply
*/
-int check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap)
+int inter_check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap)
{
int64 tick;
struct WisData *wd = DB->data2ptr(data);
@@ -1154,19 +1018,19 @@ int check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap)
return 0;
}
-int check_ttl_wisdata(void)
+int inter_check_ttl_wisdata(void)
{
int64 tick = timer->gettick();
int i;
do {
wis_delnum = 0;
- wis_db->foreach(wis_db, check_ttl_wisdata_sub, tick);
+ wis_db->foreach(wis_db, inter->check_ttl_wisdata_sub, tick);
for(i = 0; i < wis_delnum; i++) {
struct WisData *wd = (struct WisData*)idb_get(wis_db, wis_dellist[i]);
ShowWarning("inter: wis data id=%d time out : from %s to %s\n", wd->id, wd->src, wd->dst);
// removed. not send information after a timeout. Just no answer for the player
- //mapif_wis_end(wd, 1); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target
+ //mapif->wis_end(wd, 1); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target
idb_remove(wis_db, wd->id);
}
} while(wis_delnum >= WISDELLIST_MAX);
@@ -1179,7 +1043,7 @@ int check_ttl_wisdata(void)
// broadcast sending
int mapif_parse_broadcast(int fd)
{
- mapif_broadcast(RFIFOP(fd,16), RFIFOW(fd,2), RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), fd);
+ mapif->broadcast(RFIFOP(fd,16), RFIFOW(fd,2), RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), fd);
return 0;
}
@@ -1207,41 +1071,32 @@ int mapif_parse_WisRequest(int fd)
safestrncpy(name, (char*)RFIFOP(fd,28), NAME_LENGTH); //Received name may be too large and not contain \0! [Skotlex]
- SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `name` FROM `%s` WHERE `name`='%s'", char_db, esc_name) )
- Sql_ShowDebug(sql_handle);
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `name` FROM `%s` WHERE `name`='%s'", char_db, esc_name) )
+ Sql_ShowDebug(inter->sql_handle);
// search if character exists before to ask all map-servers
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
- unsigned char buf[27];
- WBUFW(buf, 0) = 0x3802;
- memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH);
- WBUFB(buf,26) = 1; // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target
- mapif_send(fd, buf, 27);
+ mapif->wis_response(fd, RFIFOP(fd, 4), 1);
}
else
{// Character exists. So, ask all map-servers
// to be sure of the correct name, rewrite it
- SQL->GetData(sql_handle, 0, &data, &len);
+ SQL->GetData(inter->sql_handle, 0, &data, &len);
memset(name, 0, NAME_LENGTH);
memcpy(name, data, min(len, NAME_LENGTH));
// if source is destination, don't ask other servers.
if( strncmp((const char*)RFIFOP(fd,4), name, NAME_LENGTH) == 0 )
{
- uint8 buf[27];
- WBUFW(buf, 0) = 0x3802;
- memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH);
- WBUFB(buf,26) = 1; // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target
- mapif_send(fd, buf, 27);
+ mapif->wis_response(fd, RFIFOP(fd, 4), 1);
}
else
{
-
CREATE(wd, struct WisData, 1);
// Whether the failure of previous wisp/page transmission (timeout)
- check_ttl_wisdata();
+ inter->check_ttl_wisdata();
wd->id = ++wisid;
wd->fd = fd;
@@ -1251,11 +1106,11 @@ int mapif_parse_WisRequest(int fd)
memcpy(wd->msg, RFIFOP(fd,52), wd->len);
wd->tick = timer->gettick();
idb_put(wis_db, wd->id, wd);
- mapif_wis_message(wd);
+ mapif->wis_message(wd);
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return 0;
}
@@ -1270,10 +1125,10 @@ int mapif_parse_WisReply(int fd)
flag = RFIFOB(fd,6);
wd = (struct WisData*)idb_get(wis_db, id);
if (wd == NULL)
- return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server
+ return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server
if ((--wd->count) <= 0 || flag != 1) {
- mapif_wis_end(wd, flag); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target
+ mapif->wis_end(wd, flag); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target
idb_remove(wis_db, id);
}
@@ -1287,7 +1142,7 @@ int mapif_parse_WisToGM(int fd)
memcpy(WBUFP(buf,0), RFIFOP(fd,0), RFIFOW(fd,2));
WBUFW(buf, 0) = 0x3803;
- mapif_sendall(buf, RFIFOW(fd,2));
+ mapif->sendall(buf, RFIFOW(fd,2));
return 0;
}
@@ -1296,14 +1151,16 @@ int mapif_parse_WisToGM(int fd)
int mapif_parse_Registry(int fd)
{
int account_id = RFIFOL(fd, 4), char_id = RFIFOL(fd, 8), count = RFIFOW(fd, 12);
-
+
if( count ) {
int cursor = 14, i;
char key[32], sval[254];
unsigned int index;
-
- global_accreg_to_login_start(account_id,char_id);
-
+ bool isLoginActive = session_isActive(chr->login_fd);
+
+ if( isLoginActive )
+ chr->global_accreg_to_login_start(account_id,char_id);
+
for(i = 0; i < count; i++) {
safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), RFIFOB(fd, cursor));
cursor += RFIFOB(fd, cursor) + 1;
@@ -1314,30 +1171,30 @@ int mapif_parse_Registry(int fd)
switch (RFIFOB(fd, cursor++)) {
/* int */
case 0:
- inter_savereg(account_id,char_id,key,index,RFIFOL(fd, cursor),false);
+ inter->savereg(account_id,char_id,key,index,RFIFOL(fd, cursor),false);
cursor += 4;
break;
case 1:
- inter_savereg(account_id,char_id,key,index,0,false);
+ inter->savereg(account_id,char_id,key,index,0,false);
break;
/* str */
case 2:
safestrncpy(sval, (char*)RFIFOP(fd, cursor + 1), RFIFOB(fd, cursor));
cursor += RFIFOB(fd, cursor) + 1;
- inter_savereg(account_id,char_id,key,index,(intptr_t)sval,true);
+ inter->savereg(account_id,char_id,key,index,(intptr_t)sval,true);
break;
case 3:
- inter_savereg(account_id,char_id,key,index,0,true);
+ inter->savereg(account_id,char_id,key,index,0,true);
break;
-
default:
- ShowError("mapif_parse_Registry: unknown type %d\n",RFIFOB(fd, cursor - 1));
+ ShowError("mapif->parse_Registry: unknown type %d\n",RFIFOB(fd, cursor - 1));
return 1;
}
}
-
- global_accreg_to_login_send();
+
+ if (isLoginActive)
+ chr->global_accreg_to_login_send();
}
return 0;
}
@@ -1346,15 +1203,15 @@ int mapif_parse_Registry(int fd)
int mapif_parse_RegistryRequest(int fd)
{
//Load Char Registry
- if (RFIFOB(fd,12)) mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),3);
+ if (RFIFOB(fd,12)) mapif->account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),3);
//Load Account Registry
- if (RFIFOB(fd,11)) mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),2);
+ if (RFIFOB(fd,11)) mapif->account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),2);
//Ask Login Server for Account2 values.
- if (RFIFOB(fd,10)) request_accreg2(RFIFOL(fd,2),RFIFOL(fd,6));
+ if (RFIFOB(fd,10)) chr->request_accreg2(RFIFOL(fd,2),RFIFOL(fd,6));
return 1;
}
-static void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, char *name)
+void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, const char *const name)
{
WFIFOHEAD(fd, NAME_LENGTH+13);
WFIFOW(fd, 0) = 0x3806;
@@ -1381,13 +1238,13 @@ int mapif_parse_NameChangeRequest(int fd)
if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorized
for (i = 0; i < NAME_LENGTH && name[i]; i++)
if (strchr(char_name_letters, name[i]) == NULL) {
- mapif_namechange_ack(fd, account_id, char_id, type, 0, name);
+ mapif->namechange_ack(fd, account_id, char_id, type, 0, name);
return 0;
}
} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
for (i = 0; i < NAME_LENGTH && name[i]; i++)
if (strchr(char_name_letters, name[i]) != NULL) {
- mapif_namechange_ack(fd, account_id, char_id, type, 0, name);
+ mapif->namechange_ack(fd, account_id, char_id, type, 0, name);
return 0;
}
}
@@ -1396,7 +1253,7 @@ int mapif_parse_NameChangeRequest(int fd)
//updated here, because changing it on the map won't make it be saved [Skotlex]
//name allowed.
- mapif_namechange_ack(fd, account_id, char_id, type, 1, name);
+ mapif->namechange_ack(fd, account_id, char_id, type, 1, name);
return 0;
}
@@ -1431,30 +1288,30 @@ int inter_parse_frommap(int fd)
return 0;
// Check packet length
- if((len = inter_check_length(fd, inter_recv_packet_length[cmd - 0x3000])) == 0)
+ if((len = inter->check_length(fd, inter_recv_packet_length[cmd - 0x3000])) == 0)
return 2;
switch(cmd) {
- case 0x3000: mapif_parse_broadcast(fd); break;
- case 0x3001: mapif_parse_WisRequest(fd); break;
- case 0x3002: mapif_parse_WisReply(fd); break;
- case 0x3003: mapif_parse_WisToGM(fd); break;
- case 0x3004: mapif_parse_Registry(fd); break;
- case 0x3005: mapif_parse_RegistryRequest(fd); break;
- case 0x3006: mapif_parse_NameChangeRequest(fd); break;
- case 0x3007: mapif_parse_accinfo(fd); break;
+ case 0x3000: mapif->parse_broadcast(fd); break;
+ case 0x3001: mapif->parse_WisRequest(fd); break;
+ case 0x3002: mapif->parse_WisReply(fd); break;
+ case 0x3003: mapif->parse_WisToGM(fd); break;
+ case 0x3004: mapif->parse_Registry(fd); break;
+ case 0x3005: mapif->parse_RegistryRequest(fd); break;
+ case 0x3006: mapif->parse_NameChangeRequest(fd); break;
+ case 0x3007: mapif->parse_accinfo(fd); break;
/* 0x3008 is used by the report stuff */
default:
- if( inter_party_parse_frommap(fd)
- || inter_guild_parse_frommap(fd)
- || inter_storage_parse_frommap(fd)
- || inter_pet_parse_frommap(fd)
- || inter_homunculus_parse_frommap(fd)
- || inter_mercenary_parse_frommap(fd)
- || inter_elemental_parse_frommap(fd)
- || inter_mail_parse_frommap(fd)
- || inter_auction_parse_frommap(fd)
- || inter_quest_parse_frommap(fd)
+ if( inter_party->parse_frommap(fd)
+ || inter_guild->parse_frommap(fd)
+ || inter_storage->parse_frommap(fd)
+ || inter_pet->parse_frommap(fd)
+ || inter_homunculus->parse_frommap(fd)
+ || inter_mercenary->parse_frommap(fd)
+ || inter_elemental->parse_frommap(fd)
+ || inter_mail->parse_frommap(fd)
+ || inter_auction->parse_frommap(fd)
+ || inter_quest->parse_frommap(fd)
)
break;
else
@@ -1465,4 +1322,28 @@ int inter_parse_frommap(int fd)
return 1;
}
-
+void inter_defaults(void)
+{
+ inter = &inter_s;
+
+ inter->sql_handle = NULL;
+
+ inter->msg_txt = inter_msg_txt;
+ inter->msg_config_read = inter_msg_config_read;
+ inter->do_final_msg = inter_do_final_msg;
+ inter->job_name = inter_job_name;
+ inter->vmsg_to_fd = inter_vmsg_to_fd;
+ inter->msg_to_fd = inter_msg_to_fd;
+ inter->savereg = inter_savereg;
+ inter->accreg_fromsql = inter_accreg_fromsql;
+ inter->config_read = inter_config_read;
+ inter->vlog = inter_vlog;
+ inter->log = inter_log;
+ inter->init_sql = inter_init_sql;
+ inter->mapif_init = inter_mapif_init;
+ inter->check_ttl_wisdata_sub = inter_check_ttl_wisdata_sub;
+ inter->check_ttl_wisdata = inter->check_ttl_wisdata;
+ inter->check_length = inter_check_length;
+ inter->parse_frommap = inter_parse_frommap;
+ inter->final = inter_final;
+}
diff --git a/src/char/inter.h b/src/char/inter.h
index d7d7c3c2b..c4bb43c1d 100644
--- a/src/char/inter.h
+++ b/src/char/inter.h
@@ -11,24 +11,37 @@
struct accreg;
-int inter_init_sql(const char *file);
-void inter_final(void);
-int inter_parse_frommap(int fd);
-int inter_mapif_init(int fd);
-int mapif_send_gmaccounts(void);
-int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason);
-void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state);
-
-int inter_log(char *fmt, ...) __attribute__((format(printf, 1, 2)));
-int inter_vlog(char *fmt, va_list ap);
-
#define inter_cfgName "conf/inter-server.conf"
extern unsigned int party_share_level;
-extern Sql* sql_handle;
-extern Sql* lsql_handle;
-
-int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type);
+void inter_defaults(void);
+
+/**
+ * inter interface
+ **/
+struct inter_interface {
+ Sql* sql_handle;
+ const char* (*msg_txt) (int msg_number);
+ bool (*msg_config_read) (const char *cfg_name, bool allow_override);
+ void (*do_final_msg) (void);
+ const char* (*job_name) (int class_);
+ void (*vmsg_to_fd) (int fd, int u_fd, int aid, char* msg, va_list ap);
+ void (*msg_to_fd) (int fd, int u_fd, int aid, char *msg, ...);
+ void (*savereg) (int account_id, int char_id, const char *key, unsigned int index, intptr_t val, bool is_string);
+ int (*accreg_fromsql) (int account_id,int char_id, int fd, int type);
+ int (*config_read) (const char* cfgName);
+ int (*vlog) (char* fmt, va_list ap);
+ int (*log) (char* fmt, ...);
+ int (*init_sql) (const char *file);
+ int (*mapif_init) (int fd);
+ int (*check_ttl_wisdata_sub) (DBKey key, DBData *data, va_list ap);
+ int (*check_ttl_wisdata) (void);
+ int (*check_length) (int fd, int length);
+ int (*parse_frommap) (int fd);
+ void (*final) (void);
+};
+
+struct inter_interface *inter;
#endif /* CHAR_INTER_H */
diff --git a/src/char/loginif.c b/src/char/loginif.c
new file mode 100644
index 000000000..5247e6c3e
--- /dev/null
+++ b/src/char/loginif.c
@@ -0,0 +1,181 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
+
+#define HERCULES_CORE
+
+#include "loginif.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "char.h"
+#include "mapif.h"
+
+#include "../common/cbasetypes.h"
+#include "../common/core.h"
+#include "../common/showmsg.h"
+#include "../common/socket.h"
+#include "../common/timer.h"
+
+struct loginif_interface loginif_s;
+
+/// Resets all the data.
+void loginif_reset(void)
+{
+ int id;
+ // TODO kick everyone out and reset everything or wait for connect and try to reacquire locks [FlavioJS]
+ for( id = 0; id < ARRAYLENGTH(chr->server); ++id )
+ mapif->server_reset(id);
+ flush_fifos();
+ exit(EXIT_FAILURE);
+}
+
+
+/// Checks the conditions for the server to stop.
+/// Releases the cookie when all characters are saved.
+/// If all the conditions are met, it stops the core loop.
+void loginif_check_shutdown(void)
+{
+ if( runflag != CHARSERVER_ST_SHUTDOWN )
+ return;
+ runflag = CORE_ST_STOP;
+}
+
+
+/// Called when the connection to Login Server is disconnected.
+void loginif_on_disconnect(void)
+{
+ ShowWarning("Connection to Login Server lost.\n\n");
+}
+
+
+/// Called when all the connection steps are completed.
+void loginif_on_ready(void)
+{
+ int i;
+
+ loginif->check_shutdown();
+
+ //Send online accounts to login server.
+ chr->send_accounts_tologin(INVALID_TIMER, timer->gettick(), 0, 0);
+
+ // if no map-server already connected, display a message...
+ ARR_FIND( 0, ARRAYLENGTH(chr->server), i, chr->server[i].fd > 0 && chr->server[i].map );
+ if( i == ARRAYLENGTH(chr->server) )
+ ShowStatus("Awaiting maps from map-server.\n");
+}
+
+void do_init_loginif(void)
+{
+ // establish char-login connection if not present
+ timer->add_func_list(chr->check_connect_login_server, "chr->check_connect_login_server");
+ timer->add_interval(timer->gettick() + 1000, chr->check_connect_login_server, 0, 0, 10 * 1000);
+
+ // send a list of all online account IDs to login server
+ timer->add_func_list(chr->send_accounts_tologin, "chr->send_accounts_tologin");
+ timer->add_interval(timer->gettick() + 1000, chr->send_accounts_tologin, 0, 0, 3600 * 1000); //Sync online accounts every hour
+}
+
+void do_final_loginif(void)
+{
+ if( chr->login_fd != -1 )
+ {
+ do_close(chr->login_fd);
+ chr->login_fd = -1;
+ }
+}
+
+void loginif_block_account(int account_id, int flag)
+{
+ WFIFOHEAD(chr->login_fd,10);
+ WFIFOW(chr->login_fd,0) = 0x2724;
+ WFIFOL(chr->login_fd,2) = account_id;
+ WFIFOL(chr->login_fd,6) = flag; // new account status
+ WFIFOSET(chr->login_fd,10);
+}
+
+void loginif_ban_account(int account_id, short year, short month, short day, short hour, short minute, short second)
+{
+ WFIFOHEAD(chr->login_fd,18);
+ WFIFOW(chr->login_fd, 0) = 0x2725;
+ WFIFOL(chr->login_fd, 2) = account_id;
+ WFIFOW(chr->login_fd, 6) = year;
+ WFIFOW(chr->login_fd, 8) = month;
+ WFIFOW(chr->login_fd,10) = day;
+ WFIFOW(chr->login_fd,12) = hour;
+ WFIFOW(chr->login_fd,14) = minute;
+ WFIFOW(chr->login_fd,16) = second;
+ WFIFOSET(chr->login_fd,18);
+}
+
+void loginif_unban_account(int account_id)
+{
+ WFIFOHEAD(chr->login_fd,6);
+ WFIFOW(chr->login_fd,0) = 0x272a;
+ WFIFOL(chr->login_fd,2) = account_id;
+ WFIFOSET(chr->login_fd,6);
+}
+
+void loginif_changesex(int account_id)
+{
+ WFIFOHEAD(chr->login_fd,6);
+ WFIFOW(chr->login_fd,0) = 0x2727;
+ WFIFOL(chr->login_fd,2) = account_id;
+ WFIFOSET(chr->login_fd,6);
+}
+
+void loginif_auth(int fd, struct char_session_data* sd, uint32 ipl)
+{
+ WFIFOHEAD(chr->login_fd,23);
+ WFIFOW(chr->login_fd,0) = 0x2712; // ask login-server to authenticate an account
+ WFIFOL(chr->login_fd,2) = sd->account_id;
+ WFIFOL(chr->login_fd,6) = sd->login_id1;
+ WFIFOL(chr->login_fd,10) = sd->login_id2;
+ WFIFOB(chr->login_fd,14) = sd->sex;
+ WFIFOL(chr->login_fd,15) = htonl(ipl);
+ WFIFOL(chr->login_fd,19) = fd;
+ WFIFOSET(chr->login_fd,23);
+}
+
+void loginif_send_users_count(int users)
+{
+ WFIFOHEAD(chr->login_fd,6);
+ WFIFOW(chr->login_fd,0) = 0x2714;
+ WFIFOL(chr->login_fd,2) = users;
+ WFIFOSET(chr->login_fd,6);
+}
+
+void loginif_connect_to_server(void)
+{
+ WFIFOHEAD(chr->login_fd,86);
+ WFIFOW(chr->login_fd,0) = 0x2710;
+ memcpy(WFIFOP(chr->login_fd,2), chr->userid, NAME_LENGTH);
+ memcpy(WFIFOP(chr->login_fd,26), chr->passwd, NAME_LENGTH);
+ WFIFOL(chr->login_fd,50) = 0;
+ WFIFOL(chr->login_fd,54) = htonl(chr->ip);
+ WFIFOW(chr->login_fd,58) = htons(chr->port);
+ memcpy(WFIFOP(chr->login_fd,60), chr->server_name, 20);
+ WFIFOW(chr->login_fd,80) = 0;
+ WFIFOW(chr->login_fd,82) = chr->server_type;
+ WFIFOW(chr->login_fd,84) = chr->new_display; //only display (New) if they want to [Kevin]
+ WFIFOSET(chr->login_fd,86);
+}
+
+void loginif_defaults(void) {
+ loginif = &loginif_s;
+
+ loginif->init = do_init_loginif;
+ loginif->final = do_final_loginif;
+ loginif->reset = loginif_reset;
+ loginif->check_shutdown = loginif_check_shutdown;
+ loginif->on_disconnect = loginif_on_disconnect;
+ loginif->on_ready = loginif_on_ready;
+ loginif->block_account = loginif_block_account;
+ loginif->ban_account = loginif_ban_account;
+ loginif->unban_account = loginif_unban_account;
+ loginif->changesex = loginif_changesex;
+ loginif->auth = loginif_auth;
+ loginif->send_users_count = loginif_send_users_count;
+ loginif->connect_to_server = loginif_connect_to_server;
+}
diff --git a/src/char/loginif.h b/src/char/loginif.h
new file mode 100644
index 000000000..27eb62a1a
--- /dev/null
+++ b/src/char/loginif.h
@@ -0,0 +1,33 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
+
+#ifndef CHAR_LOGINIF_H
+#define CHAR_LOGINIF_H
+
+#include "char.h"
+
+/**
+ * loginif interface
+ **/
+struct loginif_interface {
+ void (*init) (void);
+ void (*final) (void);
+ void (*reset) (void);
+ void (*check_shutdown) (void);
+ void (*on_disconnect) (void);
+ void (*on_ready) (void);
+ void (*block_account) (int account_id, int flag);
+ void (*ban_account) (int account_id, short year, short month, short day, short hour, short minute, short second);
+ void (*unban_account) (int account_id);
+ void (*changesex) (int account_id);
+ void (*auth) (int fd, struct char_session_data* sd, uint32 ipl);
+ void (*send_users_count) (int users);
+ void (*connect_to_server) (void);
+};
+
+struct loginif_interface *loginif;
+
+void loginif_defaults(void);
+
+#endif /* CHAR_LOGINIF_H */
diff --git a/src/char/mapif.c b/src/char/mapif.c
new file mode 100644
index 000000000..65f2984fd
--- /dev/null
+++ b/src/char/mapif.c
@@ -0,0 +1,362 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
+
+#define HERCULES_CORE
+
+#include "mapif.h"
+
+#include <stdlib.h>
+
+#include "char.h"
+#include "int_auction.h"
+#include "int_homun.h"
+#include "int_guild.h"
+#include "../common/cbasetypes.h"
+#include "../common/mmo.h"
+#include "../common/random.h"
+#include "../common/showmsg.h"
+#include "../common/socket.h"
+#include "../common/strlib.h"
+
+void mapif_ban(int id, unsigned int flag, int status);
+void mapif_server_init(int id);
+void mapif_server_destroy(int id);
+void mapif_server_reset(int id);
+void mapif_on_disconnect(int id);
+void mapif_on_parse_accinfo(int account_id, int u_fd, int u_aid, int u_group, int map_fd);
+void mapif_char_ban(int char_id, time_t timestamp);
+int mapif_sendall(unsigned char *buf, unsigned int len);
+int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len);
+int mapif_send(int fd, unsigned char *buf, unsigned int len);
+void mapif_send_users_count(int users);
+void mapif_auction_message(int char_id, unsigned char result);
+void mapif_auction_sendlist(int fd, int char_id, short count, short pages, unsigned char *buf);
+void mapif_parse_auction_requestlist(int fd);
+void mapif_auction_register(int fd, struct auction_data *auction);
+void mapif_parse_auction_register(int fd);
+void mapif_auction_cancel(int fd, int char_id, unsigned char result);
+void mapif_parse_auction_cancel(int fd);
+void mapif_auction_close(int fd, int char_id, unsigned char result);
+void mapif_parse_auction_close(int fd);
+void mapif_auction_bid(int fd, int char_id, int bid, unsigned char result);
+void mapif_parse_auction_bid(int fd);
+bool mapif_elemental_save(struct s_elemental* ele);
+bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele);
+bool mapif_elemental_delete(int ele_id);
+void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag);
+void mapif_parse_elemental_create(int fd, struct s_elemental* ele);
+void mapif_parse_elemental_load(int fd, int ele_id, int char_id);
+void mapif_elemental_deleted(int fd, unsigned char flag);
+void mapif_parse_elemental_delete(int fd, int ele_id);
+void mapif_elemental_saved(int fd, unsigned char flag);
+void mapif_parse_elemental_save(int fd, struct s_elemental* ele);
+int mapif_guild_created(int fd, int account_id, struct guild *g);
+int mapif_guild_noinfo(int fd, int guild_id);
+int mapif_guild_info(int fd, struct guild *g);
+int mapif_guild_memberadded(int fd, int guild_id, int account_id, int char_id, int flag);
+int mapif_guild_withdraw(int guild_id, int account_id, int char_id, int flag, const char *name, const char *mes);
+int mapif_guild_memberinfoshort(struct guild *g, int idx);
+int mapif_guild_broken(int guild_id, int flag);
+int mapif_guild_message(int guild_id,int account_id,char *mes,int len, int sfd);
+int mapif_guild_basicinfochanged(int guild_id, int type, const void *data, int len);
+int mapif_guild_memberinfochanged(int guild_id, int account_id, int char_id, int type, const void *data, int len);
+int mapif_guild_skillupack(int guild_id, uint16 skill_id, int account_id);
+int mapif_guild_alliance(int guild_id1, int guild_id2, int account_id1, int account_id2, int flag, const char *name1, const char *name2);
+int mapif_guild_position(struct guild *g, int idx);
+int mapif_guild_notice(struct guild *g);
+int mapif_guild_emblem(struct guild *g);
+int mapif_guild_master_changed(struct guild *g, int aid, int cid);
+int mapif_guild_castle_dataload(int fd, int sz, int *castle_ids);
+int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member *master);
+int mapif_parse_GuildInfo(int fd, int guild_id);
+int mapif_parse_GuildAddMember(int fd, int guild_id, struct guild_member *m);
+int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, int flag, const char *mes);
+int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, int char_id, int online, int lv, int class_);
+int mapif_parse_BreakGuild(int fd, int guild_id);
+int mapif_parse_GuildMessage(int fd, int guild_id, int account_id, char *mes, int len);
+int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const void *data, int len);
+int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int char_id, int type, const char *data, int len);
+int mapif_parse_GuildPosition(int fd, int guild_id, int idx, struct guild_position *p);
+int mapif_parse_GuildSkillUp(int fd, int guild_id, uint16 skill_id, int account_id, int max);
+int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int account_id1, int account_id2, int flag);
+int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_id1, int account_id2, int flag);
+int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char *mes2);
+int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char *data);
+int mapif_parse_GuildCastleDataLoad(int fd, int len, int *castle_ids);
+int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value);
+int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int len);
+void mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, unsigned char flag);
+void mapif_homunculus_deleted(int fd, int flag);
+void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd);
+void mapif_homunculus_saved(int fd, int account_id, bool flag);
+void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, char* name);
+bool mapif_homunculus_save(struct s_homunculus* hd);
+bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd);
+bool mapif_homunculus_delete(int homun_id);
+bool mapif_homunculus_rename(char *name);
+void mapif_parse_homunculus_create(int fd, int len, int account_id, struct s_homunculus* phd);
+void mapif_parse_homunculus_delete(int fd, int homun_id);
+void mapif_parse_homunculus_load(int fd, int account_id, int homun_id);
+void mapif_parse_homunculus_save(int fd, int len, int account_id, struct s_homunculus* phd);
+void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, char* name);
+void mapif_mail_sendinbox(int fd, int char_id, unsigned char flag, struct mail_data *md);
+void mapif_parse_mail_requestinbox(int fd);
+void mapif_parse_mail_read(int fd);
+void mapif_mail_sendattach(int fd, int char_id, struct mail_message *msg);
+void mapif_mail_getattach(int fd, int char_id, int mail_id);
+void mapif_parse_mail_getattach(int fd);
+void mapif_mail_delete(int fd, int char_id, int mail_id, bool failed);
+void mapif_parse_mail_delete(int fd);
+void mapif_mail_new(struct mail_message *msg);
+void mapif_mail_return(int fd, int char_id, int mail_id, int new_mail);
+void mapif_parse_mail_return(int fd);
+void mapif_mail_send(int fd, struct mail_message* msg);
+void mapif_parse_mail_send(int fd);
+bool mapif_mercenary_save(struct s_mercenary* merc);
+bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc);
+bool mapif_mercenary_delete(int merc_id);
+void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag);
+void mapif_parse_mercenary_create(int fd, struct s_mercenary* merc);
+void mapif_parse_mercenary_load(int fd, int merc_id, int char_id);
+void mapif_mercenary_deleted(int fd, unsigned char flag);
+void mapif_parse_mercenary_delete(int fd, int merc_id);
+void mapif_mercenary_saved(int fd, unsigned char flag);
+void mapif_parse_mercenary_save(int fd, struct s_mercenary* merc);
+int mapif_party_created(int fd, int account_id, int char_id, struct party *p);
+void mapif_party_noinfo(int fd, int party_id, int char_id);
+void mapif_party_info(int fd, struct party* p, int char_id);
+int mapif_party_memberadded(int fd, int party_id, int account_id, int char_id, int flag);
+int mapif_party_optionchanged(int fd, struct party *p, int account_id, int flag);
+int mapif_party_withdraw(int party_id,int account_id, int char_id);
+int mapif_party_membermoved(struct party *p, int idx);
+int mapif_party_broken(int party_id, int flag);
+int mapif_party_message(int party_id, int account_id, char *mes, int len, int sfd);
+int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct party_member *leader);
+void mapif_parse_PartyInfo(int fd, int party_id, int char_id);
+int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member);
+int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int item);
+int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id);
+int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv);
+int mapif_parse_BreakParty(int fd, int party_id);
+int mapif_parse_PartyMessage(int fd, int party_id, int account_id, char *mes, int len);
+int mapif_parse_PartyLeaderChange(int fd, int party_id, int account_id, int char_id);
+int mapif_pet_created(int fd, int account_id, struct s_pet *p);
+int mapif_pet_info(int fd, int account_id, struct s_pet *p);
+int mapif_pet_noinfo(int fd, int account_id);
+int mapif_save_pet_ack(int fd, int account_id, int flag);
+int mapif_delete_pet_ack(int fd, int flag);
+int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id,
+ short pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name);
+int mapif_load_pet(int fd, int account_id, int char_id, int pet_id);
+int mapif_save_pet(int fd, int account_id, struct s_pet *data);
+int mapif_delete_pet(int fd, int pet_id);
+int mapif_parse_CreatePet(int fd);
+int mapif_parse_LoadPet(int fd);
+int mapif_parse_SavePet(int fd);
+int mapif_parse_DeletePet(int fd);
+struct quest *mapif_quests_fromsql(int char_id, int *count);
+bool mapif_quest_delete(int char_id, int quest_id);
+bool mapif_quest_add(int char_id, struct quest qd);
+bool mapif_quest_update(int char_id, struct quest qd);
+void mapif_quest_save_ack(int fd, int char_id, bool success);
+int mapif_parse_quest_save(int fd);
+void mapif_send_quests(int fd, int char_id, struct quest *tmp_questlog, int num_quests);
+int mapif_parse_quest_load(int fd);
+int mapif_load_guild_storage(int fd,int account_id,int guild_id, char flag);
+int mapif_save_guild_storage_ack(int fd, int account_id, int guild_id, int fail);
+int mapif_parse_LoadGuildStorage(int fd);
+int mapif_parse_SaveGuildStorage(int fd);
+int mapif_itembound_ack(int fd, int aid, int guild_id);
+int mapif_parse_ItemBoundRetrieve_sub(int fd);
+void mapif_parse_ItemBoundRetrieve(int fd);
+void mapif_parse_accinfo(int fd);
+void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass,
+ const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state);
+int mapif_broadcast(unsigned char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, int sfd);
+int mapif_wis_message(struct WisData *wd);
+void mapif_wis_response(int fd, unsigned char *src, int flag);
+int mapif_wis_end(struct WisData *wd, int flag);
+int mapif_account_reg_reply(int fd,int account_id,int char_id, int type);
+int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason);
+int mapif_parse_broadcast(int fd);
+int mapif_parse_WisRequest(int fd);
+int mapif_parse_WisReply(int fd);
+int mapif_parse_WisToGM(int fd);
+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);
+
+struct mapif_interface mapif_s;
+
+void mapif_defaults(void) {
+ mapif = &mapif_s;
+
+ mapif->ban = mapif_ban;
+ mapif->server_init = mapif_server_init;
+ mapif->server_destroy = mapif_server_destroy;
+ mapif->server_reset = mapif_server_reset;
+ mapif->on_disconnect = mapif_on_disconnect;
+ mapif->on_parse_accinfo = mapif_on_parse_accinfo;
+ mapif->char_ban = mapif_char_ban;
+ mapif->sendall = mapif_sendall;
+ mapif->sendallwos = mapif_sendallwos;
+ mapif->send = mapif_send;
+ mapif->send_users_count = mapif_send_users_count;
+ mapif->auction_message = mapif_auction_message;
+ mapif->auction_sendlist = mapif_auction_sendlist;
+ mapif->parse_auction_requestlist = mapif_parse_auction_requestlist;
+ mapif->auction_register = mapif_auction_register;
+ mapif->parse_auction_register = mapif_parse_auction_register;
+ mapif->auction_cancel = mapif_auction_cancel;
+ mapif->parse_auction_cancel = mapif_parse_auction_cancel;
+ mapif->auction_close = mapif_auction_close;
+ mapif->parse_auction_close = mapif_parse_auction_close;
+ mapif->auction_bid = mapif_auction_bid;
+ mapif->parse_auction_bid = mapif_parse_auction_bid;
+ mapif->elemental_save = mapif_elemental_save;
+ mapif->elemental_load = mapif_elemental_load;
+ mapif->elemental_delete = mapif_elemental_delete;
+ mapif->elemental_send = mapif_elemental_send;
+ mapif->parse_elemental_create = mapif_parse_elemental_create;
+ mapif->parse_elemental_load = mapif_parse_elemental_load;
+ mapif->elemental_deleted = mapif_elemental_deleted;
+ mapif->parse_elemental_delete = mapif_parse_elemental_delete;
+ mapif->elemental_saved = mapif_elemental_saved;
+ mapif->parse_elemental_save = mapif_parse_elemental_save;
+ mapif->guild_created = mapif_guild_created;
+ mapif->guild_noinfo = mapif_guild_noinfo;
+ mapif->guild_info = mapif_guild_info;
+ mapif->guild_memberadded = mapif_guild_memberadded;
+ mapif->guild_withdraw = mapif_guild_withdraw;
+ mapif->guild_memberinfoshort = mapif_guild_memberinfoshort;
+ mapif->guild_broken = mapif_guild_broken;
+ mapif->guild_message = mapif_guild_message;
+ mapif->guild_basicinfochanged = mapif_guild_basicinfochanged;
+ mapif->guild_memberinfochanged = mapif_guild_memberinfochanged;
+ mapif->guild_skillupack = mapif_guild_skillupack;
+ mapif->guild_alliance = mapif_guild_alliance;
+ mapif->guild_position = mapif_guild_position;
+ mapif->guild_notice = mapif_guild_notice;
+ mapif->guild_emblem = mapif_guild_emblem;
+ mapif->guild_master_changed = mapif_guild_master_changed;
+ mapif->guild_castle_dataload = mapif_guild_castle_dataload;
+ mapif->parse_CreateGuild = mapif_parse_CreateGuild;
+ mapif->parse_GuildInfo = mapif_parse_GuildInfo;
+ mapif->parse_GuildAddMember = mapif_parse_GuildAddMember;
+ mapif->parse_GuildLeave = mapif_parse_GuildLeave;
+ mapif->parse_GuildChangeMemberInfoShort = mapif_parse_GuildChangeMemberInfoShort;
+ mapif->parse_BreakGuild = mapif_parse_BreakGuild;
+ mapif->parse_GuildMessage = mapif_parse_GuildMessage;
+ mapif->parse_GuildBasicInfoChange = mapif_parse_GuildBasicInfoChange;
+ mapif->parse_GuildMemberInfoChange = mapif_parse_GuildMemberInfoChange;
+ mapif->parse_GuildPosition = mapif_parse_GuildPosition;
+ mapif->parse_GuildSkillUp = mapif_parse_GuildSkillUp;
+ mapif->parse_GuildDeleteAlliance = mapif_parse_GuildDeleteAlliance;
+ mapif->parse_GuildAlliance = mapif_parse_GuildAlliance;
+ mapif->parse_GuildNotice = mapif_parse_GuildNotice;
+ mapif->parse_GuildEmblem = mapif_parse_GuildEmblem;
+ mapif->parse_GuildCastleDataLoad = mapif_parse_GuildCastleDataLoad;
+ mapif->parse_GuildCastleDataSave = mapif_parse_GuildCastleDataSave;
+ mapif->parse_GuildMasterChange = mapif_parse_GuildMasterChange;
+ mapif->homunculus_created = mapif_homunculus_created;
+ mapif->homunculus_deleted = mapif_homunculus_deleted;
+ mapif->homunculus_loaded = mapif_homunculus_loaded;
+ mapif->homunculus_saved = mapif_homunculus_saved;
+ mapif->homunculus_renamed = mapif_homunculus_renamed;
+ mapif->homunculus_save = mapif_homunculus_save;
+ mapif->homunculus_load = mapif_homunculus_load;
+ mapif->homunculus_delete = mapif_homunculus_delete;
+ mapif->homunculus_rename = mapif_homunculus_rename;
+ mapif->parse_homunculus_create = mapif_parse_homunculus_create;
+ mapif->parse_homunculus_delete = mapif_parse_homunculus_delete;
+ mapif->parse_homunculus_load = mapif_parse_homunculus_load;
+ mapif->parse_homunculus_save = mapif_parse_homunculus_save;
+ mapif->parse_homunculus_rename = mapif_parse_homunculus_rename;
+ mapif->mail_sendinbox = mapif_mail_sendinbox;
+ mapif->parse_mail_requestinbox = mapif_parse_mail_requestinbox;
+ mapif->parse_mail_read = mapif_parse_mail_read;
+ mapif->mail_sendattach = mapif_mail_sendattach;
+ mapif->mail_getattach = mapif_mail_getattach;
+ mapif->parse_mail_getattach = mapif_parse_mail_getattach;
+ mapif->mail_delete = mapif_mail_delete;
+ mapif->parse_mail_delete = mapif_parse_mail_delete;
+ mapif->mail_new = mapif_mail_new;
+ mapif->mail_return = mapif_mail_return;
+ mapif->parse_mail_return = mapif_parse_mail_return;
+ mapif->mail_send = mapif_mail_send;
+ mapif->parse_mail_send = mapif_parse_mail_send;
+ mapif->mercenary_save = mapif_mercenary_save;
+ mapif->mercenary_load = mapif_mercenary_load;
+ mapif->mercenary_delete = mapif_mercenary_delete;
+ mapif->mercenary_send = mapif_mercenary_send;
+ mapif->parse_mercenary_create = mapif_parse_mercenary_create;
+ mapif->parse_mercenary_load = mapif_parse_mercenary_load;
+ mapif->mercenary_deleted = mapif_mercenary_deleted;
+ mapif->parse_mercenary_delete = mapif_parse_mercenary_delete;
+ mapif->mercenary_saved = mapif_mercenary_saved;
+ mapif->parse_mercenary_save = mapif_parse_mercenary_save;
+ mapif->party_created = mapif_party_created;
+ mapif->party_noinfo = mapif_party_noinfo;
+ mapif->party_info = mapif_party_info;
+ mapif->party_memberadded = mapif_party_memberadded;
+ mapif->party_optionchanged = mapif_party_optionchanged;
+ mapif->party_withdraw = mapif_party_withdraw;
+ mapif->party_membermoved = mapif_party_membermoved;
+ mapif->party_broken = mapif_party_broken;
+ mapif->party_message = mapif_party_message;
+ mapif->parse_CreateParty = mapif_parse_CreateParty;
+ mapif->parse_PartyInfo = mapif_parse_PartyInfo;
+ mapif->parse_PartyAddMember = mapif_parse_PartyAddMember;
+ mapif->parse_PartyChangeOption = mapif_parse_PartyChangeOption;
+ mapif->parse_PartyLeave = mapif_parse_PartyLeave;
+ mapif->parse_PartyChangeMap = mapif_parse_PartyChangeMap;
+ mapif->parse_BreakParty = mapif_parse_BreakParty;
+ mapif->parse_PartyMessage = mapif_parse_PartyMessage;
+ mapif->parse_PartyLeaderChange = mapif_parse_PartyLeaderChange;
+ mapif->pet_created = mapif_pet_created;
+ mapif->pet_info = mapif_pet_info;
+ mapif->pet_noinfo = mapif_pet_noinfo;
+ mapif->save_pet_ack = mapif_save_pet_ack;
+ mapif->delete_pet_ack = mapif_delete_pet_ack;
+ mapif->create_pet = mapif_create_pet;
+ mapif->load_pet = mapif_load_pet;
+ mapif->save_pet = mapif_save_pet;
+ mapif->delete_pet = mapif_delete_pet;
+ mapif->parse_CreatePet = mapif_parse_CreatePet;
+ mapif->parse_LoadPet = mapif_parse_LoadPet;
+ mapif->parse_SavePet = mapif_parse_SavePet;
+ mapif->parse_DeletePet = mapif_parse_DeletePet;
+ mapif->quests_fromsql = mapif_quests_fromsql;
+ mapif->quest_delete = mapif_quest_delete;
+ mapif->quest_add = mapif_quest_add;
+ mapif->quest_update = mapif_quest_update;
+ mapif->quest_save_ack = mapif_quest_save_ack;
+ mapif->parse_quest_save = mapif_parse_quest_save;
+ mapif->send_quests = mapif_send_quests;
+ mapif->parse_quest_load = mapif_parse_quest_load;
+ mapif->load_guild_storage = mapif_load_guild_storage;
+ mapif->save_guild_storage_ack = mapif_save_guild_storage_ack;
+ mapif->parse_LoadGuildStorage = mapif_parse_LoadGuildStorage;
+ mapif->parse_SaveGuildStorage = mapif_parse_SaveGuildStorage;
+ mapif->itembound_ack = mapif_itembound_ack;
+ mapif->parse_ItemBoundRetrieve_sub = mapif_parse_ItemBoundRetrieve_sub;
+ mapif->parse_ItemBoundRetrieve = mapif_parse_ItemBoundRetrieve;
+ mapif->parse_accinfo = mapif_parse_accinfo;
+ mapif->parse_accinfo2 = mapif_parse_accinfo2;
+ mapif->broadcast = mapif_broadcast;
+ mapif->wis_message = mapif_wis_message;
+ mapif->wis_response = mapif_wis_response;
+ mapif->wis_end = mapif_wis_end;
+ mapif->account_reg_reply = mapif_account_reg_reply;
+ mapif->disconnectplayer = mapif_disconnectplayer;
+ mapif->parse_broadcast = mapif_parse_broadcast;
+ mapif->parse_WisRequest = mapif_parse_WisRequest;
+ mapif->parse_WisReply = mapif_parse_WisReply;
+ mapif->parse_WisToGM = mapif_parse_WisToGM;
+ mapif->parse_Registry = mapif_parse_Registry;
+ mapif->parse_RegistryRequest = mapif_parse_RegistryRequest;
+ mapif->namechange_ack = mapif_namechange_ack;
+ mapif->parse_NameChangeRequest = mapif_parse_NameChangeRequest;
+}
diff --git a/src/char/mapif.h b/src/char/mapif.h
new file mode 100644
index 000000000..f9c06256d
--- /dev/null
+++ b/src/char/mapif.h
@@ -0,0 +1,198 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
+
+#ifndef CHAR_MAPIF_H
+#define CHAR_MAPIF_H
+
+#include "char.h"
+
+struct s_elemental;
+struct s_homunculus;
+struct s_mercenary;
+struct s_pet;
+struct guild_storage;
+struct storage_data;
+struct quest;
+struct mail_message;
+struct WisData;
+
+/**
+ * mapif interface
+ **/
+struct mapif_interface {
+ void (*ban) (int id, unsigned int flag, int status);
+ void (*server_init) (int id);
+ void (*server_destroy) (int id);
+ void (*server_reset) (int id);
+ void (*on_disconnect) (int id);
+ void (*on_parse_accinfo) (int account_id, int u_fd, int u_aid, int u_group, int map_fd);
+ void (*char_ban) (int char_id, time_t timestamp);
+ int (*sendall) (unsigned char *buf, unsigned int len);
+ int (*sendallwos) (int sfd, unsigned char *buf, unsigned int len);
+ int (*send) (int fd, unsigned char *buf, unsigned int len);
+ void (*send_users_count) (int users);
+ void (*auction_message) (int char_id, unsigned char result);
+ void (*auction_sendlist) (int fd, int char_id, short count, short pages, unsigned char *buf);
+ void (*parse_auction_requestlist) (int fd);
+ void (*auction_register) (int fd, struct auction_data *auction);
+ void (*parse_auction_register) (int fd);
+ void (*auction_cancel) (int fd, int char_id, unsigned char result);
+ void (*parse_auction_cancel) (int fd);
+ void (*auction_close) (int fd, int char_id, unsigned char result);
+ void (*parse_auction_close) (int fd);
+ void (*auction_bid) (int fd, int char_id, int bid, unsigned char result);
+ void (*parse_auction_bid) (int fd);
+ bool (*elemental_save) (struct s_elemental* ele);
+ bool (*elemental_load) (int ele_id, int char_id, struct s_elemental *ele);
+ bool (*elemental_delete) (int ele_id);
+ void (*elemental_send) (int fd, struct s_elemental *ele, unsigned char flag);
+ void (*parse_elemental_create) (int fd, struct s_elemental* ele);
+ void (*parse_elemental_load) (int fd, int ele_id, int char_id);
+ void (*elemental_deleted) (int fd, unsigned char flag);
+ void (*parse_elemental_delete) (int fd, int ele_id);
+ void (*elemental_saved) (int fd, unsigned char flag);
+ void (*parse_elemental_save) (int fd, struct s_elemental* ele);
+ int (*guild_created) (int fd, int account_id, struct guild *g);
+ int (*guild_noinfo) (int fd, int guild_id);
+ int (*guild_info) (int fd, struct guild *g);
+ int (*guild_memberadded) (int fd, int guild_id, int account_id, int char_id, int flag);
+ int (*guild_withdraw) (int guild_id, int account_id, int char_id, int flag, const char *name, const char *mes);
+ int (*guild_memberinfoshort) (struct guild *g, int idx);
+ int (*guild_broken) (int guild_id, int flag);
+ int (*guild_message) (int guild_id,int account_id,char *mes,int len, int sfd);
+ int (*guild_basicinfochanged) (int guild_id, int type, const void *data, int len);
+ int (*guild_memberinfochanged) (int guild_id, int account_id, int char_id, int type, const void *data, int len);
+ int (*guild_skillupack) (int guild_id, uint16 skill_id, int account_id);
+ int (*guild_alliance) (int guild_id1, int guild_id2, int account_id1, int account_id2, int flag, const char *name1, const char *name2);
+ int (*guild_position) (struct guild *g, int idx);
+ int (*guild_notice) (struct guild *g);
+ int (*guild_emblem) (struct guild *g);
+ int (*guild_master_changed) (struct guild *g, int aid, int cid);
+ int (*guild_castle_dataload) (int fd, int sz, int *castle_ids);
+ int (*parse_CreateGuild) (int fd,int account_id,char *name,struct guild_member *master);
+ int (*parse_GuildInfo) (int fd, int guild_id);
+ int (*parse_GuildAddMember) (int fd, int guild_id, struct guild_member *m);
+ int (*parse_GuildLeave) (int fd, int guild_id, int account_id, int char_id, int flag, const char *mes);
+ int (*parse_GuildChangeMemberInfoShort) (int fd, int guild_id, int account_id, int char_id, int online, int lv, int class_);
+ int (*parse_BreakGuild) (int fd, int guild_id);
+ int (*parse_GuildMessage) (int fd, int guild_id, int account_id, char *mes, int len);
+ int (*parse_GuildBasicInfoChange) (int fd, int guild_id, int type, const void *data, int len);
+ int (*parse_GuildMemberInfoChange) (int fd, int guild_id, int account_id, int char_id, int type, const char *data, int len);
+ int (*parse_GuildPosition) (int fd, int guild_id, int idx, struct guild_position *p);
+ int (*parse_GuildSkillUp) (int fd, int guild_id, uint16 skill_id, int account_id, int max);
+ int (*parse_GuildDeleteAlliance) (struct guild *g, int guild_id, int account_id1, int account_id2, int flag);
+ int (*parse_GuildAlliance) (int fd, int guild_id1, int guild_id2, int account_id1, int account_id2, int flag);
+ int (*parse_GuildNotice) (int fd, int guild_id, const char *mes1, const char *mes2);
+ int (*parse_GuildEmblem) (int fd, int len, int guild_id, int dummy, const char *data);
+ int (*parse_GuildCastleDataLoad) (int fd, int len, int *castle_ids);
+ int (*parse_GuildCastleDataSave) (int fd, int castle_id, int index, int value);
+ int (*parse_GuildMasterChange) (int fd, int guild_id, const char* name, int len);
+ void (*homunculus_created) (int fd, int account_id, struct s_homunculus *sh, unsigned char flag);
+ void (*homunculus_deleted) (int fd, int flag);
+ void (*homunculus_loaded) (int fd, int account_id, struct s_homunculus *hd);
+ void (*homunculus_saved) (int fd, int account_id, bool flag);
+ void (*homunculus_renamed) (int fd, int account_id, int char_id, unsigned char flag, char* name);
+ bool (*homunculus_save) (struct s_homunculus* hd);
+ bool (*homunculus_load) (int homun_id, struct s_homunculus* hd);
+ bool (*homunculus_delete) (int homun_id);
+ bool (*homunculus_rename) (char *name);
+ void (*parse_homunculus_create) (int fd, int len, int account_id, struct s_homunculus* phd);
+ void (*parse_homunculus_delete) (int fd, int homun_id);
+ void (*parse_homunculus_load) (int fd, int account_id, int homun_id);
+ void (*parse_homunculus_save) (int fd, int len, int account_id, struct s_homunculus* phd);
+ void (*parse_homunculus_rename) (int fd, int account_id, int char_id, char* name);
+ void (*mail_sendinbox) (int fd, int char_id, unsigned char flag, struct mail_data *md);
+ void (*parse_mail_requestinbox) (int fd);
+ void (*parse_mail_read) (int fd);
+ void (*mail_sendattach) (int fd, int char_id, struct mail_message *msg);
+ void (*mail_getattach) (int fd, int char_id, int mail_id);
+ void (*parse_mail_getattach) (int fd);
+ void (*mail_delete) (int fd, int char_id, int mail_id, bool failed);
+ void (*parse_mail_delete) (int fd);
+ void (*mail_new) (struct mail_message *msg);
+ void (*mail_return) (int fd, int char_id, int mail_id, int new_mail);
+ void (*parse_mail_return) (int fd);
+ void (*mail_send) (int fd, struct mail_message* msg);
+ void (*parse_mail_send) (int fd);
+ bool (*mercenary_save) (struct s_mercenary* merc);
+ bool (*mercenary_load) (int merc_id, int char_id, struct s_mercenary *merc);
+ bool (*mercenary_delete) (int merc_id);
+ void (*mercenary_send) (int fd, struct s_mercenary *merc, unsigned char flag);
+ void (*parse_mercenary_create) (int fd, struct s_mercenary* merc);
+ void (*parse_mercenary_load) (int fd, int merc_id, int char_id);
+ void (*mercenary_deleted) (int fd, unsigned char flag);
+ void (*parse_mercenary_delete) (int fd, int merc_id);
+ void (*mercenary_saved) (int fd, unsigned char flag);
+ void (*parse_mercenary_save) (int fd, struct s_mercenary* merc);
+ int (*party_created) (int fd, int account_id, int char_id, struct party *p);
+ void (*party_noinfo) (int fd, int party_id, int char_id);
+ void (*party_info) (int fd, struct party* p, int char_id);
+ int (*party_memberadded) (int fd, int party_id, int account_id, int char_id, int flag);
+ int (*party_optionchanged) (int fd, struct party *p, int account_id, int flag);
+ int (*party_withdraw) (int party_id,int account_id, int char_id);
+ int (*party_membermoved) (struct party *p, int idx);
+ int (*party_broken) (int party_id, int flag);
+ int (*party_message) (int party_id, int account_id, char *mes, int len, int sfd);
+ int (*parse_CreateParty) (int fd, char *name, int item, int item2, struct party_member *leader);
+ void (*parse_PartyInfo) (int fd, int party_id, int char_id);
+ int (*parse_PartyAddMember) (int fd, int party_id, struct party_member *member);
+ int (*parse_PartyChangeOption) (int fd,int party_id,int account_id,int exp,int item);
+ int (*parse_PartyLeave) (int fd, int party_id, int account_id, int char_id);
+ int (*parse_PartyChangeMap) (int fd, int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv);
+ int (*parse_BreakParty) (int fd, int party_id);
+ int (*parse_PartyMessage) (int fd, int party_id, int account_id, char *mes, int len);
+ int (*parse_PartyLeaderChange) (int fd, int party_id, int account_id, int char_id);
+ int (*pet_created) (int fd, int account_id, struct s_pet *p);
+ int (*pet_info) (int fd, int account_id, struct s_pet *p);
+ int (*pet_noinfo) (int fd, int account_id);
+ int (*save_pet_ack) (int fd, int account_id, int flag);
+ int (*delete_pet_ack) (int fd, int flag);
+ int (*create_pet) (int fd, int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id,
+ short pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name);
+ int (*load_pet) (int fd, int account_id, int char_id, int pet_id);
+ int (*save_pet) (int fd, int account_id, struct s_pet *data);
+ int (*delete_pet) (int fd, int pet_id);
+ int (*parse_CreatePet) (int fd);
+ int (*parse_LoadPet) (int fd);
+ int (*parse_SavePet) (int fd);
+ int (*parse_DeletePet) (int fd);
+ struct quest *(*quests_fromsql) (int char_id, int *count);
+ bool (*quest_delete) (int char_id, int quest_id);
+ bool (*quest_add) (int char_id, struct quest qd);
+ bool (*quest_update) (int char_id, struct quest qd);
+ void (*quest_save_ack) (int fd, int char_id, bool success);
+ int (*parse_quest_save) (int fd);
+ void (*send_quests) (int fd, int char_id, struct quest *tmp_questlog, int num_quests);
+ int (*parse_quest_load) (int fd);
+ int (*load_guild_storage) (int fd, int account_id, int guild_id, char flag);
+ int (*save_guild_storage_ack) (int fd, int account_id, int guild_id, int fail);
+ int (*parse_LoadGuildStorage) (int fd);
+ int (*parse_SaveGuildStorage) (int fd);
+ int (*itembound_ack) (int fd, int aid, int guild_id);
+ int (*parse_ItemBoundRetrieve_sub) (int fd);
+ void (*parse_ItemBoundRetrieve) (int fd);
+ void (*parse_accinfo) (int fd);
+ void (*parse_accinfo2) (bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass,
+ const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state);
+ int (*broadcast) (unsigned char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, int sfd);
+ int (*wis_message) (struct WisData *wd);
+ void (*wis_response) (int fd, unsigned char *src, int flag);
+ int (*wis_end) (struct WisData *wd, int flag);
+ int (*account_reg_reply) (int fd,int account_id,int char_id, int type);
+ int (*disconnectplayer) (int fd, int account_id, int char_id, int reason);
+ int (*parse_broadcast) (int fd);
+ int (*parse_WisRequest) (int fd);
+ int (*parse_WisReply) (int fd);
+ int (*parse_WisToGM) (int fd);
+ int (*parse_Registry) (int fd);
+ 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);
+};
+
+struct mapif_interface *mapif;
+
+void mapif_defaults(void);
+
+#endif /* CHAR_MAPIF_H */
diff --git a/src/char/pincode.c b/src/char/pincode.c
index 18ad0ffc8..a3843ff53 100644
--- a/src/char/pincode.c
+++ b/src/char/pincode.c
@@ -16,24 +16,20 @@
#include "../common/socket.h"
#include "../common/strlib.h"
-int enabled = PINCODE_OK;
-int changetime = 0;
-int maxtry = 3;
-int charselect = 0;
-unsigned int multiplier = 0x3498, baseSeed = 0x881234;
+struct pincode_interface pincode_s;
void pincode_handle ( int fd, struct char_session_data* sd ) {
- struct online_char_data* character = (struct online_char_data*)idb_get(online_char_db, sd->account_id);
-
- if( character && character->pincode_enable > *pincode->charselect ){
- character->pincode_enable = *pincode->charselect * 2;
+ struct online_char_data* character = (struct online_char_data*)idb_get(chr->online_char_db, sd->account_id);
+
+ if( character && character->pincode_enable > pincode->charselect ){
+ character->pincode_enable = pincode->charselect * 2;
}else{
pincode->sendstate( fd, sd, PINCODE_OK );
return;
}
-
+
if( strlen(sd->pincode) == 4 ){
- if( *pincode->changetime && time(NULL) > (sd->pincode_change+*pincode->changetime) ){ // User hasn't changed his PIN code for a long time
+ if( pincode->changetime && time(NULL) > (sd->pincode_change+pincode->changetime) ){ // User hasn't changed his PIN code for a long time
pincode->sendstate( fd, sd, PINCODE_EXPIRED );
} else { // Ask user for his PIN code
pincode->sendstate( fd, sd, PINCODE_ASK );
@@ -47,13 +43,13 @@ void pincode_handle ( int fd, struct char_session_data* sd ) {
void pincode_check(int fd, struct char_session_data* sd) {
char pin[5] = "\0\0\0\0";
-
+
strncpy(pin, (char*)RFIFOP(fd, 6), 4+1);
pincode->decrypt(sd->pincode_seed, pin);
if( pincode->compare( fd, sd, pin ) ){
struct online_char_data* character;
- if( (character = (struct online_char_data*)idb_get(online_char_db, sd->account_id)) )
- character->pincode_enable = *pincode->charselect * 2;
+ if( (character = (struct online_char_data*)idb_get(chr->online_char_db, sd->account_id)) )
+ character->pincode_enable = pincode->charselect * 2;
pincode->sendstate( fd, sd, PINCODE_OK );
}
}
@@ -64,7 +60,7 @@ int pincode_compare(int fd, struct char_session_data* sd, char* pin) {
return 1;
} else {
pincode->sendstate( fd, sd, PINCODE_WRONG );
- if( *pincode->maxtry && ++sd->pincode_try >= *pincode->maxtry ){
+ if( pincode->maxtry && ++sd->pincode_try >= pincode->maxtry ){
pincode->error( sd->account_id );
}
return 0;
@@ -78,7 +74,7 @@ void pincode_change(int fd, struct char_session_data* sd) {
pincode->decrypt(sd->pincode_seed,oldpin);
if( !pincode->compare( fd, sd, oldpin ) )
return;
-
+
strncpy(newpin, (char*)RFIFOP(fd,10), sizeof(newpin));
pincode->decrypt(sd->pincode_seed,newpin);
pincode->update( sd->account_id, newpin );
@@ -115,26 +111,26 @@ void pincode_sendstate(int fd, struct char_session_data* sd, uint16 state) {
}
void pincode_notifyLoginPinUpdate(int account_id, char* pin) {
- WFIFOHEAD(login_fd,11);
- WFIFOW(login_fd,0) = 0x2738;
- WFIFOL(login_fd,2) = account_id;
- strncpy( (char*)WFIFOP(login_fd,6), pin, 5 );
- WFIFOSET(login_fd,11);
+ WFIFOHEAD(chr->login_fd,11);
+ WFIFOW(chr->login_fd,0) = 0x2738;
+ WFIFOL(chr->login_fd,2) = account_id;
+ strncpy( (char*)WFIFOP(chr->login_fd,6), pin, 5 );
+ WFIFOSET(chr->login_fd,11);
}
void pincode_notifyLoginPinError(int account_id) {
- WFIFOHEAD(login_fd,6);
- WFIFOW(login_fd,0) = 0x2739;
- WFIFOL(login_fd,2) = account_id;
- WFIFOSET(login_fd,6);
+ WFIFOHEAD(chr->login_fd,6);
+ WFIFOW(chr->login_fd,0) = 0x2739;
+ WFIFOL(chr->login_fd,2) = account_id;
+ WFIFOSET(chr->login_fd,6);
}
void pincode_decrypt(unsigned int userSeed, char* pin) {
int i, pos;
char tab[10] = {0,1,2,3,4,5,6,7,8,9};
-
+
for( i = 1; i < 10; i++ ){
- userSeed = *pincode->baseSeed + userSeed * *pincode->multiplier;
+ userSeed = pincode->baseSeed + userSeed * pincode->multiplier;
pos = userSeed % (i + 1);
if( i != pos ){
tab[i] ^= tab[pos];
@@ -142,55 +138,54 @@ void pincode_decrypt(unsigned int userSeed, char* pin) {
tab[i] ^= tab[pos];
}
}
-
+
for( i = 0; i < 4; i++ ){
pin[i] = tab[pin[i] - '0'];
}
-
+
sprintf(pin, "%d%d%d%d", pin[0], pin[1], pin[2], pin[3]);
}
bool pincode_config_read(char *w1, char *w2) {
-
+
while ( true ) {
-
if ( strcmpi(w1, "pincode_enabled") == 0 ) {
- enabled = atoi(w2);
+ pincode->enabled = atoi(w2);
#if PACKETVER < 20110309
- if( enabled ) {
+ if( pincode->enabled ) {
ShowWarning("pincode_enabled requires PACKETVER 20110309 or higher. disabling...\n");
- enabled = 0;
+ pincode->enabled = 0;
}
#endif
} else if ( strcmpi(w1, "pincode_changetime") == 0 ) {
- changetime = atoi(w2)*60;
+ pincode->changetime = atoi(w2)*60;
} else if ( strcmpi(w1, "pincode_maxtry") == 0 ) {
- maxtry = atoi(w2);
- if( maxtry > 3 ) {
- ShowWarning("pincode_maxtry is too high (%d); maximum allowed: 3! capping to 3...\n",maxtry);
- maxtry = 3;
+ pincode->maxtry = atoi(w2);
+ if( pincode->maxtry > 3 ) {
+ ShowWarning("pincode_maxtry is too high (%d); maximum allowed: 3! capping to 3...\n", pincode->maxtry);
+ pincode->maxtry = 3;
}
} else if ( strcmpi(w1, "pincode_charselect") == 0 ) {
- charselect = atoi(w2);
- } else
+ pincode->charselect = atoi(w2);
+ } else {
return false;
-
+ }
break;
}
-
+
return true;
}
void pincode_defaults(void) {
pincode = &pincode_s;
-
- pincode->enabled = &enabled;
- pincode->changetime = &changetime;
- pincode->maxtry = &maxtry;
- pincode->charselect = &charselect;
- pincode->multiplier = &multiplier;
- pincode->baseSeed = &baseSeed;
-
+
+ pincode->enabled = PINCODE_OK;
+ pincode->changetime = 0;
+ pincode->maxtry = 3;
+ pincode->charselect = 0;
+ pincode->multiplier = 0x3498;
+ pincode->baseSeed = 0x881234;
+
pincode->handle = pincode_handle;
pincode->decrypt = pincode_decrypt;
pincode->error = pincode_notifyLoginPinError;
diff --git a/src/char/pincode.h b/src/char/pincode.h
index 1ed05095e..f4265716a 100644
--- a/src/char/pincode.h
+++ b/src/char/pincode.h
@@ -7,22 +7,26 @@
#include "char.h"
-#define PINCODE_OK 0
-#define PINCODE_ASK 1
-#define PINCODE_NOTSET 2
-#define PINCODE_EXPIRED 3
-#define PINCODE_UNUSED 7
-#define PINCODE_WRONG 8
+enum PincodeResponseCode {
+ PINCODE_OK = 0,
+ PINCODE_ASK = 1,
+ PINCODE_NOTSET = 2,
+ PINCODE_EXPIRED = 3,
+ PINCODE_UNUSED = 7,
+ PINCODE_WRONG = 8,
+};
-/* Pincode Interface */
+/**
+ * pincode interface
+ **/
struct pincode_interface {
/* vars */
- int *enabled;
- int *changetime;
- int *maxtry;
- int *charselect;
- unsigned int *multiplier;
- unsigned int *baseSeed;
+ int enabled;
+ int changetime;
+ int maxtry;
+ int charselect;
+ unsigned int multiplier;
+ unsigned int baseSeed;
/* handler */
void (*handle) (int fd, struct char_session_data* sd);
void (*decrypt) (unsigned int userSeed, char* pin);
@@ -34,7 +38,7 @@ struct pincode_interface {
int (*compare) (int fd, struct char_session_data* sd, char* pin);
void (*check) (int fd, struct char_session_data* sd);
bool (*config_read) (char *w1, char *w2);
-} pincode_s;
+};
struct pincode_interface *pincode;
diff --git a/src/common/HPM.c b/src/common/HPM.c
index f39954175..51a595310 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -30,6 +30,14 @@
struct malloc_interface iMalloc_HPM;
struct malloc_interface *HPMiMalloc;
+struct HPM_interface HPM_s;
+
+/**
+ * (char*) data name -> (unsigned int) HPMDataCheck[] index
+ **/
+DBMap *datacheck_db;
+int datacheck_version;
+const struct s_HPMDataCheck *datacheck_data;
void hplugin_trigger_event(enum hp_event_types type) {
unsigned int i;
@@ -48,22 +56,22 @@ void hplugin_export_symbol(void *var, char *name) {
void *hplugin_import_symbol(char *name, unsigned int pID) {
unsigned int i;
-
+
for( i = 0; i < HPM->symbol_count; i++ ) {
if( strcmp(HPM->symbols[i]->name,name) == 0 )
return HPM->symbols[i]->ptr;
}
-
+
ShowError("HPM:get_symbol:%s: '"CL_WHITE"%s"CL_RESET"' not found!\n",HPM->pid2name(pID),name);
return NULL;
}
bool hplugin_iscompatible(char* version) {
unsigned int req_major = 0, req_minor = 0;
-
+
if( version == NULL )
return false;
-
+
sscanf(version, "%u.%u", &req_major, &req_minor);
return ( req_major == HPM->version[0] && req_minor <= HPM->version[1] ) ? true : false;
@@ -102,7 +110,7 @@ bool hplugin_populate(struct hplugin *plugin, const char *filename) {
HPM_POP(ShowFatalError),
};
int i, length = ARRAYLENGTH(ToLink);
-
+
for(i = 0; i < length; i++) {
if( !( Link = plugin_import(plugin->dll, ToLink[i].name,void **) ) ) {
ShowWarning("HPM:plugin_load: failed to retrieve '%s' for '"CL_WHITE"%s"CL_RESET"', skipping...\n", ToLink[i].name, filename);
@@ -111,7 +119,7 @@ bool hplugin_populate(struct hplugin *plugin, const char *filename) {
}
*Link = ToLink[i].Ref;
}
-
+
return true;
}
#undef HPM_POP
@@ -122,56 +130,57 @@ struct hplugin *hplugin_load(const char* filename) {
bool anyEvent = false;
void **import_symbol_ref;
Sql **sql_handle;
+ int *HPMDataCheckVer;
unsigned int *HPMDataCheckLen;
struct s_HPMDataCheck *HPMDataCheck;
-
+
if( HPM->exists(filename) ) {
ShowWarning("HPM:plugin_load: attempting to load duplicate '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename);
return NULL;
}
-
+
plugin = HPM->create();
-
+
if( !( plugin->dll = plugin_open(filename) ) ){
ShowWarning("HPM:plugin_load: failed to load '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename);
HPM->unload(plugin);
return NULL;
}
-
+
if( !( info = plugin_import(plugin->dll, "pinfo",struct hplugin_info*) ) ) {
ShowDebug("HPM:plugin_load: failed to retrieve 'plugin_info' for '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename);
HPM->unload(plugin);
return NULL;
}
-
+
if( !(info->type & SERVER_TYPE) ) {
HPM->unload(plugin);
return NULL;
}
-
+
if( !HPM->iscompatible(info->req_version) ) {
ShowWarning("HPM:plugin_load: '"CL_WHITE"%s"CL_RESET"' incompatible version '%s' -> '%s', skipping...\n", filename, info->req_version, HPM_VERSION);
HPM->unload(plugin);
return NULL;
}
-
+
plugin->info = info;
plugin->filename = aStrdup(filename);
-
+
if( !( import_symbol_ref = plugin_import(plugin->dll, "import_symbol",void **) ) ) {
ShowWarning("HPM:plugin_load: failed to retrieve 'import_symbol' for '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename);
HPM->unload(plugin);
return NULL;
}
-
+
*import_symbol_ref = HPM->import_symbol;
-
+
if( !( sql_handle = plugin_import(plugin->dll, "mysql_handle",Sql **) ) ) {
ShowWarning("HPM:plugin_load: failed to retrieve 'mysql_handle' for '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename);
HPM->unload(plugin);
return NULL;
}
-
+
*sql_handle = HPM->import_symbol("sql_handle",plugin->idx);
if( !( HPMi = plugin_import(plugin->dll, "HPMi",struct HPMi_interface **) ) ) {
@@ -179,56 +188,63 @@ struct hplugin *hplugin_load(const char* filename) {
HPM->unload(plugin);
return NULL;
}
-
+
if( !( *HPMi = plugin_import(plugin->dll, "HPMi_s",struct HPMi_interface *) ) ) {
ShowWarning("HPM:plugin_load: failed to retrieve 'HPMi_s' for '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename);
HPM->unload(plugin);
return NULL;
}
plugin->hpi = *HPMi;
-
+
if( ( plugin->hpi->event[HPET_INIT] = plugin_import(plugin->dll, "plugin_init",void (*)(void)) ) )
anyEvent = true;
-
+
if( ( plugin->hpi->event[HPET_FINAL] = plugin_import(plugin->dll, "plugin_final",void (*)(void)) ) )
anyEvent = true;
-
+
if( ( plugin->hpi->event[HPET_READY] = plugin_import(plugin->dll, "server_online",void (*)(void)) ) )
anyEvent = true;
-
+
if( ( plugin->hpi->event[HPET_POST_FINAL] = plugin_import(plugin->dll, "server_post_final",void (*)(void)) ) )
anyEvent = true;
-
+
if( ( plugin->hpi->event[HPET_PRE_INIT] = plugin_import(plugin->dll, "server_preinit",void (*)(void)) ) )
anyEvent = true;
-
+
if( !anyEvent ) {
ShowWarning("HPM:plugin_load: no events found for '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename);
HPM->unload(plugin);
return NULL;
}
-
+
if( !HPM->populate(plugin,filename) )
return NULL;
-
+
if( !( HPMDataCheckLen = plugin_import(plugin->dll, "HPMDataCheckLen", unsigned int *) ) ) {
ShowWarning("HPM:plugin_load: failed to retrieve 'HPMDataCheckLen' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h, skipping...\n", filename);
HPM->unload(plugin);
return NULL;
}
-
+
+ if( !( HPMDataCheckVer = plugin_import(plugin->dll, "HPMDataCheckVer", int *) ) ) {
+ ShowWarning("HPM:plugin_load: failed to retrieve 'HPMDataCheckVer' for '"CL_WHITE"%s"CL_RESET"', most likely an outdated plugin, skipping...\n", filename);
+ HPM->unload(plugin);
+ return NULL;
+ }
+
if( !( HPMDataCheck = plugin_import(plugin->dll, "HPMDataCheck", struct s_HPMDataCheck *) ) ) {
ShowWarning("HPM:plugin_load: failed to retrieve 'HPMDataCheck' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h, skipping...\n", filename);
HPM->unload(plugin);
return NULL;
}
-
- if( HPM->DataCheck && !HPM->DataCheck(HPMDataCheck,*HPMDataCheckLen,plugin->info->name) ) {
+
+ // TODO: Remove the HPM->DataCheck != NULL check once login and char support is complete
+ if (HPM->DataCheck != NULL && !HPM->DataCheck(HPMDataCheck,*HPMDataCheckLen,*HPMDataCheckVer,plugin->info->name)) {
ShowWarning("HPM:plugin_load: '"CL_WHITE"%s"CL_RESET"' failed DataCheck, out of sync from the core (recompile plugin), skipping...\n", filename);
HPM->unload(plugin);
return NULL;
}
-
+
/* id */
plugin->hpi->pid = plugin->idx;
/* core */
@@ -245,19 +261,19 @@ struct hplugin *hplugin_load(const char* filename) {
/* server specific */
if( HPM->load_sub )
HPM->load_sub(plugin);
-
+
return plugin;
}
void hplugin_unload(struct hplugin* plugin) {
unsigned int i = plugin->idx, cursor = 0;
-
+
if( plugin->filename )
aFree(plugin->filename);
if( plugin->dll )
plugin_close(plugin->dll);
/* TODO: for manual packet unload */
- /* - Go thru known packets and unlink any belonging to the plugin being removed */
+ /* - Go through known packets and unlink any belonging to the plugin being removed */
aFree(plugin);
if( !HPM->off ) {
HPM->plugins[i] = NULL;
@@ -281,59 +297,66 @@ void hplugins_config_read(const char * const *extra_plugins, int extra_plugins_c
const char *config_filename = "conf/plugins.conf"; // FIXME hardcoded name
FILE *fp;
int i;
-
-// uncomment once login/char support is wrapped up
-// if( !HPM->DataCheck ) {
-// ShowError("HPM:config_read: HPM->DataCheck not set! Failure\n");
-// return;
-// }
-
+
/* yes its ugly, its temporary and will be gone as soon as the new inter-server.conf is set */
if( (fp = fopen("conf/import/plugins.conf","r")) ) {
config_filename = "conf/import/plugins.conf";
fclose(fp);
}
-
+
if (libconfig->read_file(&plugins_conf, config_filename))
return;
if( HPM->symbol_defaults_sub )
HPM->symbol_defaults_sub();
-
+
plist = libconfig->lookup(&plugins_conf, "plugins_list");
for (i = 0; i < extra_plugins_count; i++) {
config_setting_t *entry = libconfig->setting_add(plist, NULL, CONFIG_TYPE_STRING);
config_setting_set_string(entry, extra_plugins[i]);
}
-
+
if (plist != NULL) {
int length = libconfig->setting_length(plist);
char filename[60];
- for(i = 0; i < length; i++) {
- if( !strcmpi(libconfig->setting_get_string_elem(plist,i),"HPMHooking") ) {//must load it first
+ char hooking_plugin_name[32];
+ const char *plugin_name_suffix = "";
+ if (SERVER_TYPE == SERVER_TYPE_LOGIN)
+ plugin_name_suffix = "_login";
+ else if (SERVER_TYPE == SERVER_TYPE_CHAR)
+ plugin_name_suffix = "_char";
+ else if (SERVER_TYPE == SERVER_TYPE_MAP)
+ plugin_name_suffix = "_map";
+ snprintf(hooking_plugin_name, sizeof(hooking_plugin_name), "HPMHooking%s", plugin_name_suffix);
+
+ for (i = 0; i < length; i++) {
+ const char *plugin_name = libconfig->setting_get_string_elem(plist,i);
+ if (strcmpi(plugin_name, "HPMHooking") == 0 || strcmpi(plugin_name, hooking_plugin_name) == 0) { //must load it first
struct hplugin *plugin;
- snprintf(filename, 60, "plugins/%s%s", libconfig->setting_get_string_elem(plist,i), DLL_EXT);
- if( ( plugin = HPM->load(filename) ) ) {
+ snprintf(filename, 60, "plugins/%s%s", hooking_plugin_name, DLL_EXT);
+ if ((plugin = HPM->load(filename))) {
bool (*func)(bool *fr);
bool (*addhook_sub) (enum HPluginHookType type, const char *target, void *hook, unsigned int pID);
- if( ( func = plugin_import(plugin->dll, "Hooked",bool (*)(bool *)) ) && ( addhook_sub = plugin_import(plugin->dll, "HPM_Plugin_AddHook",bool (*)(enum HPluginHookType, const char *, void *, unsigned int)) ) ) {
- if( func(&HPM->force_return) ) {
+ if ((func = plugin_import(plugin->dll, "Hooked",bool (*)(bool *)))
+ && (addhook_sub = plugin_import(plugin->dll, "HPM_Plugin_AddHook",bool (*)(enum HPluginHookType, const char *, void *, unsigned int)))) {
+ if (func(&HPM->force_return)) {
HPM->hooking = true;
HPM->addhook_sub = addhook_sub;
}
}
}
+ break;
}
}
- for(i = 0; i < length; i++) {
- if( strcmpi(libconfig->setting_get_string_elem(plist,i),"HPMHooking") ) {//now all others
- snprintf(filename, 60, "plugins/%s%s", libconfig->setting_get_string_elem(plist,i), DLL_EXT);
- HPM->load(filename);
- }
+ for (i = 0; i < length; i++) {
+ if (strncmpi(libconfig->setting_get_string_elem(plist,i),"HPMHooking", 10) == 0) // Already loaded, skip
+ continue;
+ snprintf(filename, 60, "plugins/%s%s", libconfig->setting_get_string_elem(plist,i), DLL_EXT);
+ HPM->load(filename);
}
libconfig->destroy(&plugins_conf);
}
-
+
if( HPM->plugin_count )
ShowStatus("HPM: There are '"CL_WHITE"%d"CL_RESET"' plugins loaded, type '"CL_WHITE"plugins"CL_RESET"' to list them\n", HPM->plugin_count);
}
@@ -342,9 +365,9 @@ CPCMD(plugins) {
ShowInfo("HPC: there are no plugins loaded\n");
} else {
unsigned int i;
-
+
ShowInfo("HPC: There are '"CL_WHITE"%d"CL_RESET"' plugins loaded\n",HPM->plugin_count);
-
+
for(i = 0; i < HPM->plugin_count; i++) {
ShowInfo("HPC: - '"CL_WHITE"%s"CL_RESET"' (%s)\n",HPM->plugins[i]->info->name,HPM->plugins[i]->filename);
}
@@ -377,18 +400,18 @@ void hplugins_addToHPData(enum HPluginDataTypes type, unsigned int pluginID, voi
struct HPluginData *HPData, **HPDataSRC;
struct HPDataOperationStorage action;
unsigned int i, max;
-
+
HPM->grabHPData(&action,type,ptr);
if( action.hdatac == NULL ) { /* woo it failed! */
ShowError("HPM:addToHPData:%s: failed, type %d (%u|%u)\n",HPM->pid2name(pluginID),type,pluginID,index);
return;
}
-
+
/* flag */
HPDataSRC = *(action.HPDataSRCPtr);
max = *(action.hdatac);
-
+
/* duplicate check */
for(i = 0; i < max; i++) {
if( HPDataSRC[i]->pluginID == pluginID && HPDataSRC[i]->type == index ) {
@@ -396,20 +419,20 @@ void hplugins_addToHPData(enum HPluginDataTypes type, unsigned int pluginID, voi
return;
}
}
-
+
/* HPluginData is always same size, probably better to use the ERS (with reasonable chunk size e.g. 10/25/50) */
CREATE(HPData, struct HPluginData, 1);
-
+
/* input */
HPData->pluginID = pluginID;
HPData->type = index;
HPData->flag.free = autofree ? 1 : 0;
HPData->data = data;
-
+
/* resize */
*(action.hdatac) += 1;
RECREATE(*(action.HPDataSRCPtr),struct HPluginData *,*(action.hdatac));
-
+
/* RECREATE modified the address */
HPDataSRC = *(action.HPDataSRCPtr);
HPDataSRC[*(action.hdatac) - 1] = HPData;
@@ -419,23 +442,23 @@ void *hplugins_getFromHPData(enum HPluginDataTypes type, unsigned int pluginID,
struct HPDataOperationStorage action;
struct HPluginData **HPDataSRC;
unsigned int i, max;
-
+
HPM->grabHPData(&action,type,ptr);
-
+
if( action.hdatac == NULL ) { /* woo it failed! */
ShowError("HPM:getFromHPData:%s: failed, type %d (%u|%u)\n",HPM->pid2name(pluginID),type,pluginID,index);
return NULL;
}
-
+
/* flag */
HPDataSRC = *(action.HPDataSRCPtr);
max = *(action.hdatac);
-
+
for(i = 0; i < max; i++) {
if( HPDataSRC[i]->pluginID == pluginID && HPDataSRC[i]->type == index )
return HPDataSRC[i]->data;
}
-
+
return NULL;
}
@@ -443,30 +466,30 @@ void hplugins_removeFromHPData(enum HPluginDataTypes type, unsigned int pluginID
struct HPDataOperationStorage action;
struct HPluginData **HPDataSRC;
unsigned int i, max;
-
+
HPM->grabHPData(&action,type,ptr);
-
+
if( action.hdatac == NULL ) { /* woo it failed! */
ShowError("HPM:removeFromHPData:%s: failed, type %d (%u|%u)\n",HPM->pid2name(pluginID),type,pluginID,index);
return;
}
-
+
/* flag */
HPDataSRC = *(action.HPDataSRCPtr);
max = *(action.hdatac);
-
+
for(i = 0; i < max; i++) {
if( HPDataSRC[i]->pluginID == pluginID && HPDataSRC[i]->type == index )
break;
}
-
+
if( i != max ) {
unsigned int cursor;
-
+
aFree(HPDataSRC[i]->data);/* when its removed we delete it regardless of autofree */
aFree(HPDataSRC[i]);
HPDataSRC[i] = NULL;
-
+
for(i = 0, cursor = 0; i < max; i++) {
if( HPDataSRC[i] == NULL )
continue;
@@ -476,13 +499,12 @@ void hplugins_removeFromHPData(enum HPluginDataTypes type, unsigned int pluginID
}
*(action.hdatac) = cursor;
}
-
}
bool hplugins_addpacket(unsigned short cmd, short length,void (*receive) (int fd),unsigned int point,unsigned int pluginID) {
struct HPluginPacket *packet;
unsigned int i;
-
+
if( point >= hpPHP_MAX ) {
ShowError("HPM->addPacket:%s: unknown point '%u' specified for packet 0x%04x (len %d)\n",HPM->pid2name(pluginID),point,cmd,length);
return false;
@@ -494,15 +516,15 @@ bool hplugins_addpacket(unsigned short cmd, short length,void (*receive) (int fd
return false;
}
}
-
+
RECREATE(HPM->packets[point], struct HPluginPacket, ++HPM->packetsc[point]);
packet = &HPM->packets[point][HPM->packetsc[point] - 1];
-
+
packet->pluginID = pluginID;
packet->cmd = cmd;
packet->len = length;
packet->receive = receive;
-
+
return true;
}
/*
@@ -512,52 +534,52 @@ bool hplugins_addpacket(unsigned short cmd, short length,void (*receive) (int fd
*/
unsigned char hplugins_parse_packets(int fd, enum HPluginPacketHookingPoints point) {
unsigned int i;
-
+
for(i = 0; i < HPM->packetsc[point]; i++) {
if( HPM->packets[point][i].cmd == RFIFOW(fd,0) )
break;
}
-
+
if( i != HPM->packetsc[point] ) {
struct HPluginPacket *packet = &HPM->packets[point][i];
short length;
-
+
if( (length = packet->len) == -1 ) {
if( (length = RFIFOW(fd, 2)) > (int)RFIFOREST(fd) )
- return 2;
+ return 2;
}
-
+
packet->receive(fd);
RFIFOSKIP(fd, length);
return 1;
}
-
+
return 0;
}
char *hplugins_id2name (unsigned int pid) {
unsigned int i;
-
+
for( i = 0; i < HPM->plugin_count; i++ ) {
if( HPM->plugins[i]->idx == pid )
return HPM->plugins[i]->info->name;
}
-
+
return "UnknownPlugin";
}
char* HPM_file2ptr(const char *file) {
unsigned int i;
-
+
for(i = 0; i < HPM->fnamec; i++) {
if( HPM->fnames[i].addr == file )
return HPM->fnames[i].name;
}
-
+
i = HPM->fnamec;
-
+
/* we handle this memory outside of the server's memory manager because we need it to exist after the memory manager goes down */
HPM->fnames = realloc(HPM->fnames,(++HPM->fnamec)*sizeof(struct HPMFileNameCache));
-
+
HPM->fnames[i].addr = file;
HPM->fnames[i].name = strdup(file);
@@ -588,9 +610,9 @@ bool HPM_AddHook(enum HPluginHookType type, const char *target, void *hook, unsi
/* if not check if a sub-hooking list is available (from the server) and run it by */
if( HPM->addhook_sub && HPM->addhook_sub(type,target,hook,pID) )
return true;
-
+
ShowError("HPM:AddHook: unknown Hooking Point '%s'!\n",target);
-
+
return false;
}
void HPM_HookStop (const char *func, unsigned int pID) {
@@ -609,85 +631,135 @@ bool hpm_parse_arg(const char *arg, int *index, char *argv[], bool param) {
if( data->has_param && param ) *index += 1;
return true;
}
-
+
return false;
}
void hpm_arg_help(void) {
DBIterator *iter = db_iterator(HPM->arg_db);
struct HPMArgData *data = NULL;
-
+
for( data = dbi_first(iter); dbi_exists(iter); data = dbi_next(iter) ) {
if( data->help != NULL )
data->help();
else
ShowInfo(" %s (%s)\t\t<no description provided>\n",data->name,HPM->pid2name(data->pluginID));
}
-
+
dbi_destroy(iter);
}
bool hpm_add_arg(unsigned int pluginID, char *name, bool has_param, void (*func) (char *param),void (*help) (void)) {
struct HPMArgData *data = NULL;
-
+
if( strdb_exists(HPM->arg_db, name) ) {
ShowError("HPM:add_arg:%s duplicate! (from %s)\n",name,HPM->pid2name(pluginID));
return false;
}
-
+
CREATE(data, struct HPMArgData, 1);
-
+
data->pluginID = pluginID;
data->name = aStrdup(name);
data->func = func;
data->help = help;
data->has_param = has_param;
-
+
strdb_put(HPM->arg_db, data->name, data);
-
+
return true;
}
bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, char *name, void (*func) (const char *val)) {
struct HPConfListenStorage *conf;
unsigned int i;
-
+
if( type >= HPCT_MAX ) {
ShowError("HPM->addConf:%s: unknown point '%u' specified for config '%s'\n",HPM->pid2name(pluginID),type,name);
return false;
}
-
+
for(i = 0; i < HPM->confsc[type]; i++) {
if( !strcmpi(name,HPM->confs[type][i].key) ) {
ShowError("HPM->addConf:%s: duplicate '%s', already in use by '%s'!",HPM->pid2name(pluginID),name,HPM->pid2name(HPM->confs[type][i].pluginID));
return false;
}
}
-
+
RECREATE(HPM->confs[type], struct HPConfListenStorage, ++HPM->confsc[type]);
conf = &HPM->confs[type][HPM->confsc[type] - 1];
-
+
conf->pluginID = pluginID;
safestrncpy(conf->key, name, HPM_ADDCONF_LENGTH);
conf->func = func;
-
+
return true;
}
bool hplugins_parse_conf(const char *w1, const char *w2, enum HPluginConfType point) {
unsigned int i;
-
+
/* exists? */
for(i = 0; i < HPM->confsc[point]; i++) {
if( !strcmpi(w1,HPM->confs[point][i].key) )
break;
}
-
+
/* trigger and we're set! */
if( i != HPM->confsc[point] ) {
HPM->confs[point][i].func(w2);
return true;
}
-
+
return false;
}
+/**
+ * Called by HPM->DataCheck on a plugins incoming data, ensures data structs in use are matching!
+ **/
+bool HPM_DataCheck(struct s_HPMDataCheck *src, unsigned int size, int version, char *name) {
+ unsigned int i, j;
+
+ if (version != datacheck_version) {
+ ShowError("HPMDataCheck:%s: DataCheck API version mismatch %d != %d\n", name, datacheck_version, version);
+ return false;
+ }
+
+ for (i = 0; i < size; i++) {
+ if (!(src[i].type|SERVER_TYPE))
+ continue;
+
+ if (!strdb_exists(datacheck_db, src[i].name)) {
+ ShowError("HPMDataCheck:%s: '%s' was not found\n",name,src[i].name);
+ return false;
+ } else {
+ j = strdb_uiget(datacheck_db, src[i].name);/* not double lookup; exists sets cache to found data */
+ if (src[i].size != datacheck_data[j].size) {
+ ShowWarning("HPMDataCheck:%s: '%s' size mismatch %u != %u\n",name,src[i].name,src[i].size,datacheck_data[j].size);
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+void HPM_datacheck_init(const struct s_HPMDataCheck *src, unsigned int length, int version) {
+ unsigned int i;
+
+ datacheck_version = version;
+ datacheck_data = src;
+
+ /**
+ * Populates datacheck_db for easy lookup later on
+ **/
+ datacheck_db = strdb_alloc(DB_OPT_BASE,0);
+
+ for(i = 0; i < length; i++) {
+ strdb_uiput(datacheck_db, src[i].name, i);
+ }
+}
+
+void HPM_datacheck_final(void) {
+ db_destroy(datacheck_db);
+}
+
void hplugins_share_defaults(void) {
/* console */
#ifdef CONSOLE_INPUT
@@ -729,12 +801,15 @@ void hplugins_share_defaults(void) {
void hpm_init(void) {
unsigned int i;
-
+ datacheck_db = NULL;
+ datacheck_data = NULL;
+ datacheck_version = 0;
+
HPM->symbols = NULL;
HPM->plugins = NULL;
HPM->plugin_count = HPM->symbol_count = 0;
HPM->off = false;
-
+
memcpy(&iMalloc_HPM, iMalloc, sizeof(struct malloc_interface));
HPMiMalloc = &iMalloc_HPM;
HPMiMalloc->malloc = HPM_mmalloc;
@@ -744,21 +819,21 @@ void hpm_init(void) {
HPMiMalloc->astrdup = HPM_astrdup;
sscanf(HPM_VERSION, "%u.%u", &HPM->version[0], &HPM->version[1]);
-
+
if( HPM->version[0] == 0 && HPM->version[1] == 0 ) {
ShowError("HPM:init:failed to retrieve HPM version!!\n");
return;
}
-
+
for(i = 0; i < hpPHP_MAX; i++) {
HPM->packets[i] = NULL;
HPM->packetsc[i] = 0;
}
-
+
HPM->arg_db = strdb_alloc(DB_OPT_RELEASE_DATA, 0);
-
+
HPM->symbol_defaults();
-
+
#ifdef CONSOLE_INPUT
console->input->addCommand("plugins",CPCMD_A(plugins));
#endif
@@ -766,64 +841,63 @@ void hpm_init(void) {
}
void hpm_memdown(void) {
unsigned int i;
-
+
/* this memory is handled outside of the server's memory manager and thus cleared after memory manager goes down */
-
+
for( i = 0; i < HPM->fnamec; i++ ) {
free(HPM->fnames[i].name);
}
-
+
if( HPM->fnames )
free(HPM->fnames);
-
}
int hpm_arg_db_clear_sub(DBKey key, DBData *data, va_list args) {
struct HPMArgData *a = DB->data2ptr(data);
-
+
aFree(a->name);
-
+
return 0;
}
void hpm_final(void) {
unsigned int i;
-
+
HPM->off = true;
-
+
for( i = 0; i < HPM->plugin_count; i++ ) {
HPM->unload(HPM->plugins[i]);
}
-
+
if( HPM->plugins )
aFree(HPM->plugins);
-
+
for( i = 0; i < HPM->symbol_count; i++ ) {
aFree(HPM->symbols[i]);
}
-
+
if( HPM->symbols )
aFree(HPM->symbols);
-
+
for( i = 0; i < hpPHP_MAX; i++ ) {
if( HPM->packets[i] )
aFree(HPM->packets[i]);
}
-
+
for( i = 0; i < HPCT_MAX; i++ ) {
if( HPM->confsc[i] )
aFree(HPM->confs[i]);
}
-
+
HPM->arg_db->destroy(HPM->arg_db,HPM->arg_db_clear_sub);
-
+
/* HPM->fnames is cleared after the memory manager goes down */
iMalloc->post_shutdown = hpm_memdown;
-
+
return;
}
void hpm_defaults(void) {
unsigned int i;
HPM = &HPM_s;
-
+
HPM->fnames = NULL;
HPM->fnamec = 0;
HPM->force_return = false;
@@ -843,7 +917,7 @@ void hpm_defaults(void) {
/* */
HPM->init = hpm_init;
HPM->final = hpm_final;
-
+
HPM->create = hplugin_create;
HPM->load = hplugin_load;
HPM->unload = hplugin_unload;
@@ -866,5 +940,7 @@ void hpm_defaults(void) {
HPM->grabHPData = hplugins_grabHPData;
HPM->grabHPDataSub = NULL;
HPM->parseConf = hplugins_parse_conf;
- HPM->DataCheck = NULL;
+ HPM->DataCheck = HPM_DataCheck;
+ HPM->datacheck_init = HPM_datacheck_init;
+ HPM->datacheck_final = HPM_datacheck_final;
}
diff --git a/src/common/HPM.h b/src/common/HPM.h
index fe8d45066..4e1aa5beb 100644
--- a/src/common/HPM.h
+++ b/src/common/HPM.h
@@ -151,8 +151,10 @@ struct HPM_interface {
/* for custom config parsing */
bool (*parseConf) (const char *w1, const char *w2, enum HPluginConfType point);
/* validates plugin data */
- bool (*DataCheck) (struct s_HPMDataCheck *src, unsigned int size, char *name);
-} HPM_s;
+ bool (*DataCheck) (struct s_HPMDataCheck *src, unsigned int size, int version, char *name);
+ void (*datacheck_init) (const struct s_HPMDataCheck *src, unsigned int length, int version);
+ void (*datacheck_final) (void);
+};
struct HPM_interface *HPM;
diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h
index 79ec36472..e97a655e3 100644
--- a/src/common/HPMDataCheck.h
+++ b/src/common/HPMDataCheck.h
@@ -8,135 +8,222 @@
HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
+ #ifdef CHAR_CHAR_H
+ { "char_interface", sizeof(struct char_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_CHAR_H
+ #endif // CHAR_CHAR_H
+ #ifdef CHAR_GEOIP_H
+ { "geoip_interface", sizeof(struct geoip_interface), SERVER_TYPE_CHAR },
+ { "s_geoip", sizeof(struct s_geoip), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_GEOIP_H
+ #endif // CHAR_GEOIP_H
+ #ifdef CHAR_INTER_H
+ { "inter_interface", sizeof(struct inter_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_INTER_H
+ #endif // CHAR_INTER_H
+ #ifdef CHAR_INT_AUCTION_H
+ { "inter_auction_interface", sizeof(struct inter_auction_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_INT_AUCTION_H
+ #endif // CHAR_INT_AUCTION_H
+ #ifdef CHAR_INT_ELEMENTAL_H
+ { "inter_elemental_interface", sizeof(struct inter_elemental_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_INT_ELEMENTAL_H
+ #endif // CHAR_INT_ELEMENTAL_H
+ #ifdef CHAR_INT_GUILD_H
+ { "inter_guild_interface", sizeof(struct inter_guild_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_INT_GUILD_H
+ #endif // CHAR_INT_GUILD_H
+ #ifdef CHAR_INT_HOMUN_H
+ { "inter_homunculus_interface", sizeof(struct inter_homunculus_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_INT_HOMUN_H
+ #endif // CHAR_INT_HOMUN_H
+ #ifdef CHAR_INT_MAIL_H
+ { "inter_mail_interface", sizeof(struct inter_mail_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_INT_MAIL_H
+ #endif // CHAR_INT_MAIL_H
+ #ifdef CHAR_INT_MERCENARY_H
+ { "inter_mercenary_interface", sizeof(struct inter_mercenary_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_INT_MERCENARY_H
+ #endif // CHAR_INT_MERCENARY_H
+ #ifdef CHAR_INT_PARTY_H
+ { "inter_party_interface", sizeof(struct inter_party_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_INT_PARTY_H
+ #endif // CHAR_INT_PARTY_H
+ #ifdef CHAR_INT_PET_H
+ { "inter_pet_interface", sizeof(struct inter_pet_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_INT_PET_H
+ #endif // CHAR_INT_PET_H
+ #ifdef CHAR_INT_QUEST_H
+ { "inter_quest_interface", sizeof(struct inter_quest_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_INT_QUEST_H
+ #endif // CHAR_INT_QUEST_H
+ #ifdef CHAR_INT_STORAGE_H
+ { "inter_storage_interface", sizeof(struct inter_storage_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_INT_STORAGE_H
+ #endif // CHAR_INT_STORAGE_H
+ #ifdef CHAR_LOGINIF_H
+ { "loginif_interface", sizeof(struct loginif_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_LOGINIF_H
+ #endif // CHAR_LOGINIF_H
+ #ifdef CHAR_MAPIF_H
+ { "mapif_interface", sizeof(struct mapif_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_MAPIF_H
+ #endif // CHAR_MAPIF_H
+ #ifdef CHAR_PINCODE_H
+ { "pincode_interface", sizeof(struct pincode_interface), SERVER_TYPE_CHAR },
+ #else
+ #define CHAR_PINCODE_H
+ #endif // CHAR_PINCODE_H
#ifdef COMMON_CONF_H
- { "libconfig_interface", sizeof(struct libconfig_interface) },
+ { "libconfig_interface", sizeof(struct libconfig_interface), SERVER_TYPE_ALL },
#else
#define COMMON_CONF_H
#endif // COMMON_CONF_H
#ifdef COMMON_DB_H
- { "DBData", sizeof(struct DBData) },
- { "DBIterator", sizeof(struct DBIterator) },
- { "DBMap", sizeof(struct DBMap) },
+ { "DBData", sizeof(struct DBData), SERVER_TYPE_ALL },
+ { "DBIterator", sizeof(struct DBIterator), SERVER_TYPE_ALL },
+ { "DBMap", sizeof(struct DBMap), SERVER_TYPE_ALL },
#else
#define COMMON_DB_H
#endif // COMMON_DB_H
#ifdef COMMON_DES_H
- { "BIT64", sizeof(struct BIT64) },
+ { "BIT64", sizeof(struct BIT64), SERVER_TYPE_ALL },
#else
#define COMMON_DES_H
#endif // COMMON_DES_H
#ifdef COMMON_ERS_H
- { "eri", sizeof(struct eri) },
+ { "eri", sizeof(struct eri), SERVER_TYPE_ALL },
#else
#define COMMON_ERS_H
#endif // COMMON_ERS_H
#ifdef COMMON_MAPINDEX_H
- { "mapindex_interface", sizeof(struct mapindex_interface) },
+ { "mapindex_interface", sizeof(struct mapindex_interface), SERVER_TYPE_ALL },
#else
#define COMMON_MAPINDEX_H
#endif // COMMON_MAPINDEX_H
#ifdef COMMON_MMO_H
- { "quest", sizeof(struct quest) },
+ { "quest", sizeof(struct quest), SERVER_TYPE_ALL },
#else
#define COMMON_MMO_H
#endif // COMMON_MMO_H
#ifdef COMMON_SOCKET_H
- { "socket_interface", sizeof(struct socket_interface) },
+ { "socket_interface", sizeof(struct socket_interface), SERVER_TYPE_ALL },
#else
#define COMMON_SOCKET_H
#endif // COMMON_SOCKET_H
#ifdef COMMON_STRLIB_H
- { "StringBuf", sizeof(struct StringBuf) },
- { "s_svstate", sizeof(struct s_svstate) },
+ { "StringBuf", sizeof(struct StringBuf), SERVER_TYPE_ALL },
+ { "s_svstate", sizeof(struct s_svstate), SERVER_TYPE_ALL },
#else
#define COMMON_STRLIB_H
#endif // COMMON_STRLIB_H
#ifdef COMMON_SYSINFO_H
- { "sysinfo_interface", sizeof(struct sysinfo_interface) },
+ { "sysinfo_interface", sizeof(struct sysinfo_interface), SERVER_TYPE_ALL },
#else
#define COMMON_SYSINFO_H
#endif // COMMON_SYSINFO_H
+ #ifdef LOGIN_LOGIN_H
+ { "login_interface", sizeof(struct login_interface), SERVER_TYPE_LOGIN },
+ #else
+ #define LOGIN_LOGIN_H
+ #endif // LOGIN_LOGIN_H
#ifdef MAP_ATCOMMAND_H
- { "AliasInfo", sizeof(struct AliasInfo) },
- { "atcommand_interface", sizeof(struct atcommand_interface) },
+ { "AliasInfo", sizeof(struct AliasInfo), SERVER_TYPE_MAP },
+ { "atcommand_interface", sizeof(struct atcommand_interface), SERVER_TYPE_MAP },
#else
#define MAP_ATCOMMAND_H
#endif // MAP_ATCOMMAND_H
#ifdef MAP_BATTLE_H
- { "Damage", sizeof(struct Damage) },
- { "battle_interface", sizeof(struct battle_interface) },
+ { "Damage", sizeof(struct Damage), SERVER_TYPE_MAP },
+ { "battle_interface", sizeof(struct battle_interface), SERVER_TYPE_MAP },
#else
#define MAP_BATTLE_H
#endif // MAP_BATTLE_H
#ifdef MAP_BUYINGSTORE_H
- { "buyingstore_interface", sizeof(struct buyingstore_interface) },
- { "s_buyingstore_item", sizeof(struct s_buyingstore_item) },
+ { "buyingstore_interface", sizeof(struct buyingstore_interface), SERVER_TYPE_MAP },
+ { "s_buyingstore_item", sizeof(struct s_buyingstore_item), SERVER_TYPE_MAP },
#else
#define MAP_BUYINGSTORE_H
#endif // MAP_BUYINGSTORE_H
#ifdef MAP_CHRIF_H
- { "auth_node", sizeof(struct auth_node) },
+ { "auth_node", sizeof(struct auth_node), SERVER_TYPE_MAP },
#else
#define MAP_CHRIF_H
#endif // MAP_CHRIF_H
#ifdef MAP_CLIF_H
- { "clif_interface", sizeof(struct clif_interface) },
+ { "clif_interface", sizeof(struct clif_interface), SERVER_TYPE_MAP },
#else
#define MAP_CLIF_H
#endif // MAP_CLIF_H
#ifdef MAP_ELEMENTAL_H
- { "elemental_skill", sizeof(struct elemental_skill) },
+ { "elemental_skill", sizeof(struct elemental_skill), SERVER_TYPE_MAP },
#else
#define MAP_ELEMENTAL_H
#endif // MAP_ELEMENTAL_H
#ifdef MAP_GUILD_H
- { "eventlist", sizeof(struct eventlist) },
- { "guardian_data", sizeof(struct guardian_data) },
+ { "eventlist", sizeof(struct eventlist), SERVER_TYPE_MAP },
+ { "guardian_data", sizeof(struct guardian_data), SERVER_TYPE_MAP },
#else
#define MAP_GUILD_H
#endif // MAP_GUILD_H
#ifdef MAP_MAPREG_H
- { "mapreg_save", sizeof(struct mapreg_save) },
+ { "mapreg_save", sizeof(struct mapreg_save), SERVER_TYPE_MAP },
#else
#define MAP_MAPREG_H
#endif // MAP_MAPREG_H
#ifdef MAP_MAP_H
- { "map_data_other_server", sizeof(struct map_data_other_server) },
+ { "map_data_other_server", sizeof(struct map_data_other_server), SERVER_TYPE_MAP },
#else
#define MAP_MAP_H
#endif // MAP_MAP_H
#ifdef MAP_PACKETS_STRUCT_H
- { "EQUIPSLOTINFO", sizeof(struct EQUIPSLOTINFO) },
+ { "EQUIPSLOTINFO", sizeof(struct EQUIPSLOTINFO), SERVER_TYPE_MAP },
#else
#define MAP_PACKETS_STRUCT_H
#endif // MAP_PACKETS_STRUCT_H
#ifdef MAP_PC_H
- { "autotrade_vending", sizeof(struct autotrade_vending) },
- { "item_cd", sizeof(struct item_cd) },
+ { "autotrade_vending", sizeof(struct autotrade_vending), SERVER_TYPE_MAP },
+ { "item_cd", sizeof(struct item_cd), SERVER_TYPE_MAP },
#else
#define MAP_PC_H
#endif // MAP_PC_H
#ifdef MAP_SCRIPT_H
- { "Script_Config", sizeof(struct Script_Config) },
- { "reg_db", sizeof(struct reg_db) },
- { "script_interface", sizeof(struct script_interface) },
+ { "Script_Config", sizeof(struct Script_Config), SERVER_TYPE_MAP },
+ { "reg_db", sizeof(struct reg_db), SERVER_TYPE_MAP },
+ { "script_interface", sizeof(struct script_interface), SERVER_TYPE_MAP },
#else
#define MAP_SCRIPT_H
#endif // MAP_SCRIPT_H
#ifdef MAP_SEARCHSTORE_H
- { "searchstore_interface", sizeof(struct searchstore_interface) },
+ { "searchstore_interface", sizeof(struct searchstore_interface), SERVER_TYPE_MAP },
#else
#define MAP_SEARCHSTORE_H
#endif // MAP_SEARCHSTORE_H
#ifdef MAP_SKILL_H
- { "skill_cd", sizeof(struct skill_cd) },
- { "skill_condition", sizeof(struct skill_condition) },
- { "skill_interface", sizeof(struct skill_interface) },
- { "skill_unit_save", sizeof(struct skill_unit_save) },
+ { "skill_cd", sizeof(struct skill_cd), SERVER_TYPE_MAP },
+ { "skill_condition", sizeof(struct skill_condition), SERVER_TYPE_MAP },
+ { "skill_interface", sizeof(struct skill_interface), SERVER_TYPE_MAP },
+ { "skill_unit_save", sizeof(struct skill_unit_save), SERVER_TYPE_MAP },
#else
#define MAP_SKILL_H
#endif // MAP_SKILL_H
};
HPExport unsigned int HPMDataCheckLen = ARRAYLENGTH(HPMDataCheck);
+HPExport int HPMDataCheckVer = 1;
#endif /* HPM_DATA_CHECK_H */
diff --git a/src/common/HPMi.h b/src/common/HPMi.h
index 478cfbdd9..47f4e6b8b 100644
--- a/src/common/HPMi.h
+++ b/src/common/HPMi.h
@@ -36,6 +36,7 @@ struct hplugin_info {
struct s_HPMDataCheck {
char *name;
unsigned int size;
+ int type;
};
HPExport void *(*import_symbol) (char *name, unsigned int pID);
@@ -79,11 +80,20 @@ enum HPluginDataTypes {
HPDT_INSTANCE,
HPDT_GUILD,
HPDT_PARTY,
+ HPDT_MOBDB,
+ HPDT_MOBDATA,
+ HPDT_ITEMDATA,
};
/* used in macros and conf storage */
enum HPluginConfType {
- HPCT_BATTLE, /* battle-conf (map-server */
+ HPCT_BATTLE, /* battle-conf (map-server */
+ HPCT_LOGIN, /* login-server.conf (login-server) */
+ HPCT_CHAR, /* char-server.conf (char-server) */
+ HPCT_CHAR_INTER, /* inter-server.conf (char-server) */
+ HPCT_MAP_INTER, /* inter-server.conf (map-server) */
+ HPCT_LOG, /* logs.conf (map-server) */
+ HPCT_SCRIPT, /* script.conf (map-server) */
HPCT_MAX,
};
@@ -124,6 +134,18 @@ enum HPluginConfType {
#define addToINSTD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_INSTANCE,HPMi->pid,(ptr),(data),(index),(autofree)))
#define getFromINSTD(ptr,index) (HPMi->getFromHPData(HPDT_INSTANCE,HPMi->pid,(ptr),(index)))
#define removeFromINSTD(ptr,index) (HPMi->removeFromHPData(HPDT_INSTANCE,HPMi->pid,(ptr),(index)))
+/* mob_db */
+#define addToMOBDB(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_MOBDB,HPMi->pid,(ptr),(data),(index),(autofree)))
+#define getFromMOBDB(ptr,index) (HPMi->getFromHPData(HPDT_MOBDB,HPMi->pid,(ptr),(index)))
+#define removeFromMOBDB(ptr,index) (HPMi->removeFromHPData(HPDT_MOBDB,HPMi->pid,(ptr),(index)))
+/* mob_data */
+#define addToMOBDATA(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_MOBDATA,HPMi->pid,(ptr),(data),(index),(autofree)))
+#define getFromMOBDATA(ptr,index) (HPMi->getFromHPData(HPDT_MOBDATA,HPMi->pid,(ptr),(index)))
+#define removeFromMOBDATA(ptr,index) (HPMi->removeFromHPData(HPDT_MOBDATA,HPMi->pid,(ptr),(index)))
+/* item_data */
+#define addToITEMDATA(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_ITEMDATA,HPMi->pid,(ptr),(data),(index),(autofree)))
+#define getFromITEMDATA(ptr,index) (HPMi->getFromHPData(HPDT_ITEMDATA,HPMi->pid,(ptr),(index)))
+#define removeFromITEMDATA(ptr,index) (HPMi->removeFromHPData(HPDT_ITEMDATA,HPMi->pid,(ptr),(index)))
/* HPMi->addCommand */
#define addAtcommand(cname,funcname) \
@@ -135,10 +157,16 @@ enum HPluginConfType {
/* HPMi->addScript */
#define addScriptCommand(cname,scinfo,funcname) \
if ( HPMi->addScript != NULL ) { \
- HPMi->addScript(cname,scinfo,buildin_ ## funcname); \
+ HPMi->addScript(cname,scinfo,buildin_ ## funcname, false); \
} else { \
ShowWarning("HPM (%s):addScriptCommand(\"%s\",\"%s\",%s) failed, addScript sub is NULL!\n",pinfo.name,cname,scinfo,# funcname);\
}
+#define addScriptCommandDeprecated(cname,scinfo,funcname) \
+ if ( HPMi->addScript != NULL ) { \
+ HPMi->addScript(cname,scinfo,buildin_ ## funcname, true); \
+ } else { \
+ ShowWarning("HPM (%s):addScriptCommandDeprecated(\"%s\",\"%s\",%s) failed, addScript sub is NULL!\n",pinfo.name,cname,scinfo,# funcname);\
+ }
/* HPMi->addCPCommand */
#define addCPCommand(cname,funcname) \
if ( HPMi->addCPCommand != NULL ) { \
@@ -150,6 +178,18 @@ enum HPluginConfType {
#define addPacket(cmd,len,receive,point) HPMi->addPacket(cmd,len,receive,point,HPMi->pid)
/* HPMi->addBattleConf */
#define addBattleConf(bcname,funcname) HPMi->addConf(HPMi->pid,HPCT_BATTLE,bcname,funcname)
+/* HPMi->addLogin */
+#define addLoginConf(bcname,funcname) HPMi->addConf(HPMi->pid,HPCT_LOGIN,bcname,funcname)
+/* HPMi->addChar */
+#define addCharConf(bcname,funcname) HPMi->addConf(HPMi->pid,HPCT_CHAR,bcname,funcname)
+/* HPMi->addCharInter */
+#define addCharInterConf(bcname,funcname) HPMi->addConf(HPMi->pid,HPCT_CHAR_INTER,bcname,funcname)
+/* HPMi->addMapInter */
+#define addMapInterConf(bcname,funcname) HPMi->addConf(HPMi->pid,HPCT_MAP_INTER,bcname,funcname)
+/* HPMi->addLog */
+#define addLogConf(bcname,funcname) HPMi->addConf(HPMi->pid,HPCT_LOG,bcname,funcname)
+/* HPMi->addScript */
+#define addScriptConf(bcname,funcname) HPMi->addConf(HPMi->pid,HPCT_SCRIPT,bcname,funcname)
/* HPMi->addPCGPermission */
#define addGroupPermission(pcgname,maskptr) HPMi->addPCGPermission(HPMi->pid,pcgname,&maskptr)
@@ -161,7 +201,7 @@ HPExport struct HPMi_interface {
/* */
void (*event[HPET_MAX]) (void);
bool (*addCommand) (char *name, bool (*func)(const int fd, struct map_session_data* sd, const char* command, const char* message,struct AtCommandInfo *info));
- bool (*addScript) (char *name, char *args, bool (*func)(struct script_state *st));
+ bool (*addScript) (char *name, char *args, bool (*func)(struct script_state *st), bool isDeprecated);
void (*addCPCommand) (char *name, CParseFunc func);
/* HPM Custom Data */
void (*addToHPData) (enum HPluginDataTypes type, unsigned int pluginID, void *ptr, void *data, unsigned int index, bool autofree);
@@ -179,8 +219,9 @@ HPExport struct HPMi_interface {
bool (*addConf) (unsigned int pluginID, enum HPluginConfType type, char *name, void (*func) (const char *val));
/* pc group permission */
void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask);
-} HPMi_s;
+};
#ifndef HERCULES_CORE
+HPExport struct HPMi_interface HPMi_s;
HPExport struct HPMi_interface *HPMi;
#endif
diff --git a/src/common/atomic.h b/src/common/atomic.h
index e73b1c464..a42dfad1c 100644
--- a/src/common/atomic.h
+++ b/src/common/atomic.h
@@ -8,9 +8,9 @@
// (Interlocked CompareExchange, Add .. and so on ..)
//
// Implementation varies / depends on:
-// - Architecture
-// - Compiler
-// - Operating System
+// - Architecture
+// - Compiler
+// - Operating System
//
// our Abstraction is fully API-Compatible to Microsoft's implementation @ NT5.0+
//
@@ -29,13 +29,13 @@ forceinline int64 InterlockedCompareExchange64(volatile int64 *dest, int64 exch,
_asm{
lea esi,_cmp;
lea edi,exch;
-
+
mov eax,[esi];
mov edx,4[esi];
mov ebx,[edi];
mov ecx,4[edi];
mov esi,dest;
-
+
lock CMPXCHG8B [esi];
}
}
@@ -109,7 +109,7 @@ static forceinline int64 InterlockedIncrement64(volatile int64 *addend){
static forceinline int32 InterlockedIncrement(volatile int32 *addend){
- return __sync_add_and_fetch(addend, 1);
+ return __sync_add_and_fetch(addend, 1);
}//end: InterlockedIncrement()
@@ -139,7 +139,7 @@ static forceinline int64 InterlockedExchange64(volatile int64 *target, int64 val
static forceinline int32 InterlockedExchange(volatile int32 *target, int32 val){
- return __sync_lock_test_and_set(target, val);
+ return __sync_lock_test_and_set(target, val);
}//end: InterlockedExchange()
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h
index 18bc0b8cb..df1d364d4 100644
--- a/src/common/cbasetypes.h
+++ b/src/common/cbasetypes.h
@@ -117,56 +117,56 @@
// Integers with guaranteed _exact_ size.
//////////////////////////////////////////////////////////////////////////
-typedef int8_t int8;
-typedef int16_t int16;
-typedef int32_t int32;
-typedef int64_t int64;
+typedef int8_t int8;
+typedef int16_t int16;
+typedef int32_t int32;
+typedef int64_t int64;
-typedef int8_t sint8;
-typedef int16_t sint16;
-typedef int32_t sint32;
-typedef int64_t sint64;
+typedef int8_t sint8;
+typedef int16_t sint16;
+typedef int32_t sint32;
+typedef int64_t sint64;
-typedef uint8_t uint8;
-typedef uint16_t uint16;
-typedef uint32_t uint32;
-typedef uint64_t uint64;
+typedef uint8_t uint8;
+typedef uint16_t uint16;
+typedef uint32_t uint32;
+typedef uint64_t uint64;
#undef UINT8_MIN
#undef UINT16_MIN
#undef UINT32_MIN
#undef UINT64_MIN
-#define UINT8_MIN ((uint8) UINT8_C(0x00))
-#define UINT16_MIN ((uint16)UINT16_C(0x0000))
-#define UINT32_MIN ((uint32)UINT32_C(0x00000000))
-#define UINT64_MIN ((uint64)UINT64_C(0x0000000000000000))
+#define UINT8_MIN ((uint8) UINT8_C(0x00))
+#define UINT16_MIN ((uint16)UINT16_C(0x0000))
+#define UINT32_MIN ((uint32)UINT32_C(0x00000000))
+#define UINT64_MIN ((uint64)UINT64_C(0x0000000000000000))
#undef UINT8_MAX
#undef UINT16_MAX
#undef UINT32_MAX
#undef UINT64_MAX
-#define UINT8_MAX ((uint8) UINT8_C(0xFF))
-#define UINT16_MAX ((uint16)UINT16_C(0xFFFF))
-#define UINT32_MAX ((uint32)UINT32_C(0xFFFFFFFF))
-#define UINT64_MAX ((uint64)UINT64_C(0xFFFFFFFFFFFFFFFF))
+#define UINT8_MAX ((uint8) UINT8_C(0xFF))
+#define UINT16_MAX ((uint16)UINT16_C(0xFFFF))
+#define UINT32_MAX ((uint32)UINT32_C(0xFFFFFFFF))
+#define UINT64_MAX ((uint64)UINT64_C(0xFFFFFFFFFFFFFFFF))
#undef SINT8_MIN
#undef SINT16_MIN
#undef SINT32_MIN
#undef SINT64_MIN
-#define SINT8_MIN ((sint8) INT8_C(0x80))
-#define SINT16_MIN ((sint16)INT16_C(0x8000))
-#define SINT32_MIN ((sint32)INT32_C(0x80000000))
-#define SINT64_MIN ((sint32)INT64_C(0x8000000000000000))
+#define SINT8_MIN ((sint8) INT8_C(0x80))
+#define SINT16_MIN ((sint16)INT16_C(0x8000))
+#define SINT32_MIN ((sint32)INT32_C(0x80000000))
+#define SINT64_MIN ((sint32)INT64_C(0x8000000000000000))
#undef SINT8_MAX
#undef SINT16_MAX
#undef SINT32_MAX
#undef SINT64_MAX
-#define SINT8_MAX ((sint8) INT8_C(0x7F))
-#define SINT16_MAX ((sint16)INT16_C(0x7FFF))
-#define SINT32_MAX ((sint32)INT32_C(0x7FFFFFFF))
-#define SINT64_MAX ((sint64)INT64_C(0x7FFFFFFFFFFFFFFF))
+#define SINT8_MAX ((sint8) INT8_C(0x7F))
+#define SINT16_MAX ((sint16)INT16_C(0x7FFF))
+#define SINT32_MAX ((sint32)INT32_C(0x7FFFFFFF))
+#define SINT64_MAX ((sint64)INT64_C(0x7FFFFFFFFFFFFFFF))
//////////////////////////////////////////////////////////////////////////
// Integers with guaranteed _minimum_ size.
@@ -191,10 +191,10 @@ typedef unsigned long int ppuint32;
#if defined(WIN32) && !defined(MINGW) // does not have a signed size_t
//////////////////////////////
-#if defined(_WIN64) // native 64bit windows platform
-typedef __int64 ssize_t;
+#if defined(_WIN64) // native 64bit windows platform
+typedef __int64 ssize_t;
#else
-typedef int ssize_t;
+typedef int ssize_t;
#endif
//////////////////////////////
#endif
@@ -236,22 +236,22 @@ typedef uintptr_t uintptr;
// some redefine of function redefines for some Compilers
//////////////////////////////////////////////////////////////////////////
#if defined(_MSC_VER) || defined(__BORLANDC__)
-#define strcasecmp stricmp
-#define strncasecmp strnicmp
-#define strncmpi strnicmp
-#define snprintf _snprintf
+#define strcasecmp stricmp
+#define strncasecmp strnicmp
+#define strncmpi strnicmp
+#define snprintf _snprintf
#if defined(_MSC_VER) && _MSC_VER < 1400
-#define vsnprintf _vsnprintf
+#define vsnprintf _vsnprintf
#endif
#else
-#define strcmpi strcasecmp
-#define stricmp strcasecmp
-#define strncmpi strncasecmp
-#define strnicmp strncasecmp
+#define strcmpi strcasecmp
+#define stricmp strcasecmp
+#define strncmpi strncasecmp
+#define strnicmp strncasecmp
#endif
#if defined(_MSC_VER) && _MSC_VER > 1200
-#define strtoull _strtoui64
-#define strtoll _strtoi64
+#define strtoull _strtoui64
+#define strtoll _strtoi64
#endif
// keyword replacement
@@ -286,8 +286,8 @@ typedef uintptr_t uintptr;
#ifndef __bool_true_false_are_defined
// If stdbool.h is not available or does not define this
typedef char bool;
-#define false (1==0)
-#define true (1==1)
+#define false (1==0)
+#define true (1==1)
#define __bool_true_false_are_defined
#endif // __bool_true_false_are_defined
@@ -308,18 +308,17 @@ typedef char bool;
#if 0 //to be activated soon, more tests needed on how VS works with the macro above
#ifdef WIN32
#undef swap
-#define swap(a,b)__asm \
-{ \
- __asm mov eax, dword ptr [a] \
- __asm cmp eax, dword ptr [b] \
- __asm je _ret \
- __asm xor eax, dword ptr [b] \
- __asm mov dword ptr [a], eax \
- __asm xor eax, dword ptr [b] \
- __asm mov dword ptr [b], eax \
- __asm xor eax, dword ptr [a] \
- __asm mov dword ptr [a], eax \
- __asm _ret: \
+#define swap(a,b)__asm { \
+ __asm mov eax, dword ptr [a] \
+ __asm cmp eax, dword ptr [b] \
+ __asm je _ret \
+ __asm xor eax, dword ptr [b] \
+ __asm mov dword ptr [a], eax \
+ __asm xor eax, dword ptr [b] \
+ __asm mov dword ptr [b], eax \
+ __asm xor eax, dword ptr [a] \
+ __asm mov dword ptr [a], eax \
+ __asm _ret: \
}
#endif
#endif
@@ -343,7 +342,7 @@ typedef char bool;
//////////////////////////////////////////////////////////////////////////
// number of bits in a byte
#ifndef NBBY
-#define NBBY 8
+#define NBBY 8
#endif
//////////////////////////////////////////////////////////////////////////
diff --git a/src/common/conf.c b/src/common/conf.c
index 46a034497..c974decf9 100644
--- a/src/common/conf.c
+++ b/src/common/conf.c
@@ -34,10 +34,10 @@ void config_setting_copy_simple(config_setting_t *parent, const config_setting_t
}
else {
config_setting_t *set;
-
+
if( libconfig->setting_get_member(parent, config_setting_name(src)) != NULL )
return;
-
+
if ((set = libconfig->setting_add(parent, config_setting_name(src), config_setting_type(src))) == NULL)
return;
@@ -83,14 +83,14 @@ void config_setting_copy_aggregate(config_setting_t *parent, const config_settin
if( libconfig->setting_get_member(parent, config_setting_name(src)) != NULL )
return;
-
+
newAgg = libconfig->setting_add(parent, config_setting_name(src), config_setting_type(src));
if (newAgg == NULL)
return;
n = config_setting_length(src);
-
+
for (i = 0; i < n; i++) {
if (config_setting_is_group(src)) {
libconfig->setting_copy_simple(newAgg, libconfig->setting_get_elem(src, i));
@@ -101,7 +101,6 @@ void config_setting_copy_aggregate(config_setting_t *parent, const config_settin
}
int config_setting_copy(config_setting_t *parent, const config_setting_t *src) {
-
if (!config_setting_is_group(parent) && !config_setting_is_list(parent))
return CONFIG_FALSE;
@@ -115,7 +114,7 @@ int config_setting_copy(config_setting_t *parent, const config_setting_t *src) {
void libconfig_defaults(void) {
libconfig = &libconfig_s;
-
+
libconfig->read = config_read;
libconfig->write = config_write;
/* */
@@ -146,6 +145,7 @@ void libconfig_defaults(void) {
/* */
libconfig->setting_set_int = config_setting_set_int;
libconfig->setting_set_int64 = config_setting_set_int64;
+ libconfig->setting_set_float = config_setting_set_float;
libconfig->setting_set_bool = config_setting_set_bool;
libconfig->setting_set_string = config_setting_set_string;
/* */
diff --git a/src/common/conf.h b/src/common/conf.h
index c232a035c..9ea5f5b72 100644
--- a/src/common/conf.h
+++ b/src/common/conf.h
@@ -22,21 +22,21 @@ struct libconfig_interface {
int (*read_string) (config_t *config, const char *str);
int (*read_file_src) (config_t *config, const char *filename);
int (*write_file) (config_t *config, const char *filename);
-
+
void (*set_destructor) (config_t *config, void (*destructor)(void *));
void (*set_include_dir) (config_t *config, const char *include_dir);
-
+
void (*init) (config_t *config);
void (*destroy) (config_t *config);
-
+
int (*setting_get_int) (const config_setting_t *setting);
long long (*setting_get_int64) (const config_setting_t *setting);
double (*setting_get_float) (const config_setting_t *setting);
-
+
int (*setting_get_bool) (const config_setting_t *setting);
-
+
const char * (*setting_get_string) (const config_setting_t *setting);
-
+
int (*setting_lookup_int) (const config_setting_t *setting, const char *name, int *value);
int (*setting_lookup_int64) (const config_setting_t *setting, const char *name, long long *value);
int (*setting_lookup_float) (const config_setting_t *setting, const char *name, double *value);
@@ -47,10 +47,10 @@ struct libconfig_interface {
int (*setting_set_float) (config_setting_t *setting, double value);
int (*setting_set_bool) (config_setting_t *setting, int value);
int (*setting_set_string) (config_setting_t *setting, const char *value);
-
+
int (*setting_set_format) (config_setting_t *setting, short format);
short (*setting_get_format) (const config_setting_t *setting);
-
+
int (*setting_get_int_elem) (const config_setting_t *setting, int idx);
long long (*setting_get_int64_elem) (const config_setting_t *setting, int idx);
double (*setting_get_float_elem) (const config_setting_t *setting, int idx);
@@ -61,19 +61,19 @@ struct libconfig_interface {
config_setting_t * (*setting_set_float_elem) (config_setting_t *setting, int idx, double value);
config_setting_t * (*setting_set_bool_elem) (config_setting_t *setting, int idx, int value);
config_setting_t * (*setting_set_string_elem) (config_setting_t *setting, int idx, const char *value);
-
+
int (*setting_index) (const config_setting_t *setting);
int (*setting_length) (const config_setting_t *setting);
-
+
config_setting_t * (*setting_get_elem) (const config_setting_t *setting, unsigned int idx);
config_setting_t * (*setting_get_member) (const config_setting_t *setting, const char *name);
-
+
config_setting_t * (*setting_add) (config_setting_t *parent, const char *name, int type);
int (*setting_remove) (config_setting_t *parent, const char *name);
-
+
int (*setting_remove_elem) (config_setting_t *parent, unsigned int idx);
void (*setting_set_hook) (config_setting_t *setting, void *hook);
-
+
config_setting_t * (*lookup) (const config_t *config, const char *path);
config_setting_t * (*lookup_from) (config_setting_t *setting, const char *path);
int (*lookup_int) (const config_t *config, const char *path, int *value);
@@ -81,7 +81,7 @@ struct libconfig_interface {
int (*lookup_float) (const config_t *config, const char *path, double *value);
int (*lookup_bool) (const config_t *config, const char *path, int *value);
int (*lookup_string) (const config_t *config, const char *path, const char **value);
-
+
/* those are custom and are from src/common/conf.c */
/* Functions to copy settings from libconfig/contrib */
int (*read_file) (config_t *config, const char *config_filename);
diff --git a/src/common/console.c b/src/common/console.c
index 6a82db555..6c5a5c886 100644
--- a/src/common/console.c
+++ b/src/common/console.c
@@ -43,7 +43,7 @@ struct console_input_interface console_input_s;
#endif
/*======================================
- * CORE : Display title
+ * CORE : Display title
*--------------------------------------*/
void display_title(void) {
const char *vcstype = sysinfo->vcstype();
@@ -80,18 +80,18 @@ int console_parse_key_pressed(void) {
fd_set fds;
tv.tv_sec = 0;
tv.tv_usec = 0;
-
+
FD_ZERO(&fds);
FD_SET(STDIN_FILENO, &fds);
-
+
select(STDIN_FILENO+1, &fds, NULL, NULL, &tv);
-
+
return FD_ISSET(STDIN_FILENO, &fds);
}
#endif /* _WIN32 */
/*======================================
- * CORE: Console commands
+ * CORE: Console commands
*--------------------------------------*/
/**
@@ -112,7 +112,9 @@ CPCMD_C(ers_report,server) {
* Displays memory usage
**/
CPCMD_C(mem_report,server) {
+#ifdef USE_MEMMGR
memmgr_report(line?atoi(line):0);
+#endif
}
/**
@@ -152,20 +154,22 @@ CPCMD_C(skip,update) {
}
/**
- * Defines a main category
- * Categories can't be used as commands!
+ * Defines a main category.
+ *
+ * Categories can't be used as commands!
* E.G.
- * sql update skip
- * 'sql' is the main category
+ * - sql update skip
+ * 'sql' is the main category
* CP_DEF_C(category)
**/
#define CP_DEF_C(x) { #x , NULL , NULL, NULL }
/**
- * Defines a sub-category
- * Sub-categories can't be used as commands!
+ * Defines a sub-category.
+ *
+ * Sub-categories can't be used as commands!
* E.G.
- * sql update skip
- * 'update' is a sub-category
+ * - sql update skip
+ * 'update' is a sub-category
* CP_DEF_C2(command, category)
**/
#define CP_DEF_C2(x,y) { #x , NULL , #y, NULL }
@@ -209,21 +213,21 @@ void console_load_defaults(void) {
};
unsigned int i, len = ARRAYLENGTH(default_list);
struct CParseEntry *cmd;
-
+
RECREATE(console->input->cmds,struct CParseEntry *, len);
-
+
for(i = 0; i < len; i++) {
CREATE(cmd, struct CParseEntry, 1);
-
+
safestrncpy(cmd->cmd, default_list[i].name, CP_CMD_LENGTH);
-
+
if( default_list[i].func )
cmd->u.func = default_list[i].func;
else
cmd->u.next = NULL;
-
+
cmd->next_count = 0;
-
+
console->input->cmd_count++;
console->input->cmds[i] = cmd;
default_list[i].self = cmd;
@@ -232,7 +236,7 @@ void console_load_defaults(void) {
console->input->cmd_list[console->input->cmd_list_count - 1] = cmd;
}
}
-
+
for(i = 0; i < len; i++) {
unsigned int k;
if( !default_list[i].connect )
@@ -256,10 +260,10 @@ void console_parse_create(char *name, CParseFunc func) {
char *tok;
char sublist[CP_CMD_LENGTH * 5];
struct CParseEntry *cmd;
-
+
safestrncpy(sublist, name, CP_CMD_LENGTH * 5);
tok = strtok(sublist,":");
-
+
for ( i = 0; i < console->input->cmd_list_count; i++ ) {
if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 )
break;
@@ -278,12 +282,11 @@ void console_parse_create(char *name, CParseFunc func) {
cmd = console->input->cmd_list[i];
while( ( tok = strtok(NULL, ":") ) != NULL ) {
-
for(i = 0; i < cmd->next_count; i++) {
if( strcmpi(cmd->u.next[i]->cmd,tok) == 0 )
break;
}
-
+
if ( i == cmd->next_count ) {
RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count);
CREATE(console->input->cmds[console->input->cmd_count-1], struct CParseEntry, 1);
@@ -294,7 +297,6 @@ void console_parse_create(char *name, CParseFunc func) {
cmd = console->input->cmds[console->input->cmd_count-1];
continue;
}
-
}
cmd->u.func = func;
}
@@ -320,24 +322,24 @@ void console_parse_sub(char *line) {
char *tok;
char sublist[CP_CMD_LENGTH * 5];
unsigned int i, len = 0;
-
+
memcpy(bline, line, 200);
tok = strtok(line, " ");
-
+
for ( i = 0; i < console->input->cmd_list_count; i++ ) {
if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 )
break;
}
-
+
if( i == console->input->cmd_list_count ) {
ShowError("'"CL_WHITE"%s"CL_RESET"' is not a known command, type '"CL_WHITE"help"CL_RESET"' to list all commands\n",line);
return;
}
-
+
cmd = console->input->cmd_list[i];
-
+
len += snprintf(sublist,CP_CMD_LENGTH * 5,"%s", cmd->cmd) + 1;
-
+
if( cmd->next_count == 0 && console->input->cmd_list[i]->u.func ) {
char *r = NULL;
if( (tok = strtok(NULL, " ")) ) {
@@ -381,8 +383,8 @@ void console_parse_sub(char *line) {
}
}
void console_parse(char* line) {
- int c, i = 0, len = MAX_CONSOLE_INPUT - 1;/* we leave room for the \0 :P */
-
+ int c, i = 0, len = MAX_CONSOLE_INPUT - 1;/* we leave room for the \0 :P */
+
while( (c = fgetc(stdin)) != EOF ) {
if( --len == 0 )
break;
@@ -391,33 +393,32 @@ void console_parse(char* line) {
break;/* new line~! we leave it for the next cycle */
}
}
-
+
line[i++] = '\0';
}
void *cThread_main(void *x) {
-
while( console->input->ptstate ) {/* loopx */
if( console->input->key_pressed() ) {
char input[MAX_CONSOLE_INPUT];
-
+
console->input->parse(input);
if( input[0] != '\0' ) {/* did we get something? */
EnterSpinLock(&console->input->ptlock);
-
+
if( cinput.count == CONSOLE_PARSE_SIZE ) {
LeaveSpinLock(&console->input->ptlock);
continue;/* drop */
}
-
+
safestrncpy(cinput.queue[cinput.count++],input,MAX_CONSOLE_INPUT);
LeaveSpinLock(&console->input->ptlock);
}
}
ramutex_lock( console->input->ptmutex );
- racond_wait( console->input->ptcond, console->input->ptmutex, -1 );
+ racond_wait( console->input->ptcond, console->input->ptmutex, -1 );
ramutex_unlock( console->input->ptmutex );
}
-
+
return NULL;
}
int console_parse_timer(int tid, int64 tick, int id, intptr_t data) {
@@ -435,7 +436,7 @@ void console_parse_final(void) {
if( console->input->ptstate ) {
InterlockedDecrement(&console->input->ptstate);
racond_signal(console->input->ptcond);
-
+
/* wait for thread to close */
rathread_wait(console->input->pthread, NULL);
@@ -445,22 +446,21 @@ void console_parse_final(void) {
}
void console_parse_init(void) {
cinput.count = 0;
-
+
console->input->ptstate = 1;
InitializeSpinLock(&console->input->ptlock);
-
+
console->input->ptmutex = ramutex_create();
console->input->ptcond = racond_create();
-
+
if( (console->input->pthread = rathread_create(console->input->pthread_main, NULL)) == NULL ){
ShowFatalError("console_parse_init: failed to spawn console_parse thread.\n");
exit(EXIT_FAILURE);
}
-
+
timer->add_func_list(console->input->parse_timer, "console_parse_timer");
timer->add_interval(timer->gettick() + 1000, console->input->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */
-
}
void console_setSQL(Sql *SQL_handle) {
console->input->SQL = SQL_handle;
diff --git a/src/common/core.c b/src/common/core.c
index 99dbc36ec..04434a5dd 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -48,14 +48,14 @@ char **arg_v = NULL;
char *SERVER_NAME = NULL;
-#ifndef MINICORE // minimalist Core
+#ifndef MINICORE // minimalist Core
// Added by Gabuzomeu
//
// This is an implementation of signal() using sigaction() for portability.
// (sigaction() is POSIX; signal() is not.) Taken from Stevens' _Advanced
// Programming in the UNIX Environment_.
//
-#ifdef WIN32 // windows don't have SIGPIPE
+#ifdef WIN32 // windows don't have SIGPIPE
#define SIGPIPE SIGINT
#endif
@@ -69,7 +69,7 @@ sigfunc *compat_signal(int signo, sigfunc *func) {
sigemptyset(&sact.sa_mask);
sact.sa_flags = 0;
#ifdef SA_INTERRUPT
- sact.sa_flags |= SA_INTERRUPT; /* SunOS */
+ sact.sa_flags |= SA_INTERRUPT; /* SunOS */
#endif
if (sigaction(signo, &sact, &oact) < 0)
@@ -80,7 +80,7 @@ sigfunc *compat_signal(int signo, sigfunc *func) {
#endif
/*======================================
- * CORE : Console events for Windows
+ * CORE : Console events for Windows
*--------------------------------------*/
#ifdef _WIN32
static BOOL WINAPI console_handler(DWORD c_event) {
@@ -106,7 +106,7 @@ static void cevents_init(void) {
#endif
/*======================================
- * CORE : Signal Sub Function
+ * CORE : Signal Sub Function
*--------------------------------------*/
static void sig_proc(int sn) {
static int is_called = 0;
@@ -132,11 +132,11 @@ static void sig_proc(int sn) {
case SIGXFSZ:
// ignore and allow it to set errno to EFBIG
ShowWarning ("Max file size reached!\n");
- //run_flag = 0; // should we quit?
+ //run_flag = 0; // should we quit?
break;
case SIGPIPE:
- //ShowInfo ("Broken pipe found... closing socket\n"); // set to eof in socket.c
- break; // does nothing here
+ //ShowInfo ("Broken pipe found... closing socket\n"); // set to eof in socket.c
+ break; // does nothing here
#endif
}
}
@@ -185,7 +185,7 @@ void core_defaults(void) {
#endif
}
/*======================================
- * CORE : MAINROUTINE
+ * CORE : MAINROUTINE
*--------------------------------------*/
int main (int argc, char **argv) {
int retval = EXIT_SUCCESS;
@@ -209,7 +209,7 @@ int main (int argc, char **argv) {
}
}
}
-
+
iMalloc->init();// needed for Show* in display_title() [FlavioJS]
sysinfo->init();
@@ -229,7 +229,7 @@ int main (int argc, char **argv) {
rathread_init();
DB->init();
signals_init();
-
+
#ifdef _WIN32
cevents_init();
#endif
@@ -239,11 +239,11 @@ int main (int argc, char **argv) {
/* timer first */
rnd_init();
srand((unsigned int)timer->gettick());
-
+
console->init();
-
+
HCache->init();
-
+
HPM->init();
sockt->init();
@@ -258,7 +258,7 @@ int main (int argc, char **argv) {
}
console->final();
-
+
retval = do_final();
HPM->final();
timer->final();
diff --git a/src/common/db.c b/src/common/db.c
index f414ca04d..044df19aa 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -81,6 +81,8 @@
#include "../common/showmsg.h"
#include "../common/strlib.h"
+struct db_interface DB_s;
+
/*****************************************************************************\
* (1) Private typedefs, enums, structures, defines and global variables of *
* the database system. *
@@ -577,7 +579,7 @@ static void db_rebalance_erase(DBNode *node, DBNode **root)
x = x_parent;
x_parent = x_parent->parent;
} else {
- if (w->right == NULL || w->right->color == BLACK) {
+ if (w->right == NULL || w->right->color == BLACK) {
if (w->left) w->left->color = BLACK;
w->color = RED;
db_rotate_right(w, root);
@@ -1229,7 +1231,7 @@ static void db_release_both(DBKey key, DBData data, DBRelease which)
DBData* dbit_obj_first(DBIterator* self, DBKey* out_key)
{
DBIterator_impl* it = (DBIterator_impl*)self;
-
+
DB_COUNTSTAT(dbit_first);
// position before the first entry
it->ht_index = -1;
@@ -1251,7 +1253,7 @@ DBData* dbit_obj_first(DBIterator* self, DBKey* out_key)
DBData* dbit_obj_last(DBIterator* self, DBKey* out_key)
{
DBIterator_impl* it = (DBIterator_impl*)self;
-
+
DB_COUNTSTAT(dbit_last);
// position after the last entry
it->ht_index = HASH_SIZE;
@@ -1373,7 +1375,6 @@ DBData* dbit_obj_prev(DBIterator* self, DBKey* out_key)
node = &fake;
}
-
while( node )
{// next node
if( node->left )
@@ -1660,17 +1661,17 @@ static unsigned int db_obj_vgetall(DBMap* self, DBData **buf, unsigned int max,
}
va_end(argscopy);
}
-
+
if (node->left) {
node = node->left;
continue;
}
-
+
if (node->right) {
node = node->right;
continue;
}
-
+
while (node) {
parent = node->parent;
if (parent && parent->right && parent->left == node) {
@@ -1857,7 +1858,7 @@ static DBData* db_obj_ensure(DBMap* self, DBKey key, DBCreateData create, ...)
* @see #db_malloc_dbn(void)
* @see DBMap#put
* FIXME: If this method fails shouldn't it return another value?
- * Other functions rely on this to know if they were able to put something [Panikon]
+ * Other functions rely on this to know if they were able to put something [Panikon]
*/
static int db_obj_put(DBMap* self, DBKey key, DBData data, DBData *out_data)
{
@@ -1979,7 +1980,7 @@ static int db_obj_remove(DBMap* self, DBKey key, DBData *out_data)
db->alloc_file, db->alloc_line);
return 0; // nullpo candidate
}
- if (!(db->options&DB_OPT_ALLOW_NULL_KEY) && db_is_key_null(db->type, key)) {
+ if (!(db->options&DB_OPT_ALLOW_NULL_KEY) && db_is_key_null(db->type, key)) {
ShowError("db_remove: Attempted to use non-allowed NULL key for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
return 0; // nullpo candidate
}
@@ -2643,7 +2644,7 @@ DBKey db_str2key(const char *key)
DBKey db_i642key(int64 key)
{
DBKey ret;
-
+
DB_COUNTSTAT(db_i642key);
ret.i64 = key;
return ret;
@@ -2658,7 +2659,7 @@ DBKey db_i642key(int64 key)
DBKey db_ui642key(uint64 key)
{
DBKey ret;
-
+
DB_COUNTSTAT(db_ui642key);
ret.ui64 = key;
return ret;
diff --git a/src/common/db.h b/src/common/db.h
index bf59e37d6..88265c3e8 100644
--- a/src/common/db.h
+++ b/src/common/db.h
@@ -848,7 +848,7 @@ DBKey (*i642key) (int64 key);
* @public
*/
DBKey (*ui642key) (uint64 key);
-
+
/**
* Manual cast from 'int' to the struct DBData.
* @param data Data to be casted
@@ -914,7 +914,7 @@ void (*init) (void);
* @see #db_init(void)
*/
void (*final) (void);
-} DB_s;
+};
struct db_interface *DB;
@@ -1347,6 +1347,7 @@ void linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...);
/////////////////////////////////////////////////////////////////////
// Binary heap library based on defines. (uses the vector defines above)
// uses aMalloc, aRealloc, aFree
+// WARNING: BHEAP implementation details affect behaviour of A* pathfinding
@@ -1459,6 +1460,21 @@ void linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...);
+/// See BHEAP_PUSH. Version used by A* implementation, matching client bheap.
+///
+/// @param __heap Binary heap
+/// @param __val Value
+/// @param __topcmp Comparator
+/// @param __swp Swapper
+#define BHEAP_PUSH2(__heap,__val,__topcmp,__swp) \
+ do{ \
+ size_t _i_ = VECTOR_LENGTH(__heap); \
+ VECTOR_PUSH(__heap,__val); /* insert at end */ \
+ BHEAP_SIFTDOWN(__heap,0,_i_,__topcmp,__swp); \
+ }while(0)
+
+
+
/// Removes the top value of the heap. (using the '=' operator)
/// Assumes the heap is not empty.
///
@@ -1474,6 +1490,21 @@ void linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...);
+/// See BHEAP_POP. Version used by A* implementation, matching client bheap.
+///
+/// @param __heap Binary heap
+/// @param __topcmp Comparator
+/// @param __swp Swapper
+#define BHEAP_POP2(__heap,__topcmp,__swp) \
+ do{ \
+ VECTOR_INDEX(__heap,0) = VECTOR_POP(__heap); /* put last at index */ \
+ if( !VECTOR_LENGTH(__heap) ) /* removed last, nothing to do */ \
+ break; \
+ BHEAP_SIFTUP(__heap,0,__topcmp,__swp); \
+ }while(0)
+
+
+
/// Removes the target value of the heap. (using the '=' operator)
/// Assumes the index exists.
///
@@ -1522,6 +1553,74 @@ void linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...);
+/// Follow path up towards (but not all the way to) the root, swapping nodes until finding
+/// a place where the new item that was placed at __idx fits.
+/// Only goes as high as __startidx (usually 0).
+///
+/// @param __heap Binary heap
+/// @param __startidx Index of an ancestor of __idx
+/// @param __idx Index of an inserted element
+/// @param __topcmp Comparator
+/// @param __swp Swapper
+#define BHEAP_SIFTDOWN(__heap,__startidx,__idx,__topcmp,__swp) \
+ do{ \
+ size_t _i2_ = __idx; \
+ while( _i2_ > __startidx ) \
+ { /* restore heap property in parents */ \
+ size_t _parent_ = (_i2_-1)/2; \
+ if( __topcmp(VECTOR_INDEX(__heap,_parent_),VECTOR_INDEX(__heap,_i2_)) <= 0 ) \
+ break; /* done */ \
+ __swp(VECTOR_INDEX(__heap,_parent_),VECTOR_INDEX(__heap,_i2_)); \
+ _i2_ = _parent_; \
+ } \
+ }while(0)
+
+
+
+/// Repeatedly swap the smaller child with parent, after placing a new item at __idx.
+///
+/// @param __heap Binary heap
+/// @param __idx Index of an inserted element
+/// @param __topcmp Comparator
+/// @param __swp Swapper
+#define BHEAP_SIFTUP(__heap,__idx,__topcmp,__swp) \
+ do{ \
+ size_t _i_ = __idx; \
+ size_t _lchild_ = _i_*2 + 1; \
+ while( _lchild_ < VECTOR_LENGTH(__heap) ) \
+ { /* restore heap property in childs */ \
+ size_t _rchild_ = _i_*2 + 2; \
+ if( _rchild_ >= VECTOR_LENGTH(__heap) || __topcmp(VECTOR_INDEX(__heap,_lchild_),VECTOR_INDEX(__heap,_rchild_)) < 0 ) \
+ { /* left child */ \
+ __swp(VECTOR_INDEX(__heap,_i_),VECTOR_INDEX(__heap,_lchild_)); \
+ _i_ = _lchild_; \
+ } \
+ else \
+ { /* right child */ \
+ __swp(VECTOR_INDEX(__heap,_i_),VECTOR_INDEX(__heap,_rchild_)); \
+ _i_ = _rchild_; \
+ } \
+ _lchild_ = _i_*2 + 1; \
+ } \
+ BHEAP_SIFTDOWN(__heap,__idx,_i_,__topcmp,__swp); \
+ }while(0)
+
+
+
+/// Call this after modifying the item at __idx__ to restore the heap
+///
+/// @param __heap Binary heap
+/// @param __idx Index
+/// @param __topcmp Comparator
+/// @param __swp Swapper
+#define BHEAP_UPDATE(__heap,__idx,__topcmp,__swp) \
+ do{ \
+ BHEAP_SIFTDOWN(__heap,0,__idx,__topcmp,__swp); \
+ BHEAP_SIFTUP(__heap,__idx,__topcmp,__swp); \
+ }while(0)
+
+
+
/// Clears the binary heap, freeing allocated data.
///
/// @param __heap Binary heap
diff --git a/src/common/des.c b/src/common/des.c
index 7f952be76..89a920bc9 100644
--- a/src/common/des.c
+++ b/src/common/des.c
@@ -103,14 +103,14 @@ static void E(BIT64* src)
}
#endif
// optimized
- tmp.b[0] = ((src->b[7]<<5) | (src->b[4]>>3)) & 0x3f; // ..0 vutsr
- tmp.b[1] = ((src->b[4]<<1) | (src->b[5]>>7)) & 0x3f; // ..srqpo n
- tmp.b[2] = ((src->b[4]<<5) | (src->b[5]>>3)) & 0x3f; // ..o nmlkj
- tmp.b[3] = ((src->b[5]<<1) | (src->b[6]>>7)) & 0x3f; // ..kjihg f
- tmp.b[4] = ((src->b[5]<<5) | (src->b[6]>>3)) & 0x3f; // ..g fedcb
- tmp.b[5] = ((src->b[6]<<1) | (src->b[7]>>7)) & 0x3f; // ..cba98 7
- tmp.b[6] = ((src->b[6]<<5) | (src->b[7]>>3)) & 0x3f; // ..8 76543
- tmp.b[7] = ((src->b[7]<<1) | (src->b[4]>>7)) & 0x3f; // ..43210 v
+ tmp.b[0] = ((src->b[7]<<5) | (src->b[4]>>3)) & 0x3f; // ..0 vutsr
+ tmp.b[1] = ((src->b[4]<<1) | (src->b[5]>>7)) & 0x3f; // ..srqpo n
+ tmp.b[2] = ((src->b[4]<<5) | (src->b[5]>>3)) & 0x3f; // ..o nmlkj
+ tmp.b[3] = ((src->b[5]<<1) | (src->b[6]>>7)) & 0x3f; // ..kjihg f
+ tmp.b[4] = ((src->b[5]<<5) | (src->b[6]>>3)) & 0x3f; // ..g fedcb
+ tmp.b[5] = ((src->b[6]<<1) | (src->b[7]>>7)) & 0x3f; // ..cba98 7
+ tmp.b[6] = ((src->b[6]<<5) | (src->b[7]>>3)) & 0x3f; // ..8 76543
+ tmp.b[7] = ((src->b[7]<<1) | (src->b[4]>>7)) & 0x3f; // ..43210 v
*src = tmp;
}
diff --git a/src/common/ers.c b/src/common/ers.c
index c8a11d2a9..489d8f7ae 100644
--- a/src/common/ers.c
+++ b/src/common/ers.c
@@ -83,19 +83,19 @@ typedef struct ers_cache
// Free objects count
unsigned int Free;
-
+
// Used blocks count
unsigned int Used;
-
+
// Objects in-use count
unsigned int UsedObjs;
-
+
// Default = ERS_BLOCK_ENTRIES, can be adjusted for performance for individual cache sizes.
unsigned int ChunkSize;
-
+
// Misc options, some options are shared from the instance
enum ERSOptions Options;
-
+
// Linked list
struct ers_cache *Next, *Prev;
} ers_cache_t;
@@ -103,10 +103,10 @@ typedef struct ers_cache
struct ers_instance_t {
// Interface to ERS
struct eri VTable;
-
+
// Name, used for debugging purposes
char *Name;
-
+
// Misc options
enum ERSOptions Options;
@@ -115,7 +115,7 @@ struct ers_instance_t {
// Count of objects in use, used for detecting memory leaks
unsigned int Count;
-
+
#ifdef DEBUG
/* for data analysis [Ind/Hercules] */
unsigned int Peak;
@@ -149,7 +149,7 @@ static ers_cache_t *ers_find_cache(unsigned int size, enum ERSOptions Options) {
cache->Max = 0;
cache->ChunkSize = ERS_BLOCK_ENTRIES;
cache->Options = (Options & ERS_CACHE_OPTIONS);
-
+
if (CacheList == NULL)
{
CacheList = cache;
@@ -181,7 +181,7 @@ static void ers_free_cache(ers_cache_t *cache, bool remove)
CacheList = cache->Next;
aFree(cache->Blocks);
-
+
aFree(cache);
}
@@ -216,7 +216,7 @@ static void *ers_obj_alloc_entry(ERS *self)
instance->Count++;
instance->Cache->UsedObjs++;
-
+
#ifdef DEBUG
if( instance->Count > instance->Peak )
instance->Peak = instance->Count;
@@ -240,7 +240,7 @@ static void ers_obj_free_entry(ERS *self, void *entry)
if( instance->Cache->Options & ERS_OPT_CLEAN )
memset((unsigned char*)reuse + sizeof(struct ers_list), 0, instance->Cache->ObjectSize - sizeof(struct ers_list));
-
+
reuse->Next = instance->Cache->ReuseList;
instance->Cache->ReuseList = reuse;
instance->Count--;
@@ -277,27 +277,27 @@ static void ers_obj_destroy(ERS *self)
if (instance->Next)
instance->Next->Prev = instance->Prev;
-
+
if (instance->Prev)
instance->Prev->Next = instance->Next;
else
InstanceList = instance->Next;
-
+
if( instance->Options & ERS_OPT_FREE_NAME )
aFree(instance->Name);
-
+
aFree(instance);
}
void ers_cache_size(ERS *self, unsigned int new_size) {
struct ers_instance_t *instance = (struct ers_instance_t *)self;
-
+
nullpo_retv(instance);
-
+
if( !(instance->Cache->Options&ERS_OPT_FLEX_CHUNK) ) {
ShowWarning("ers_cache_size: '%s' has adjusted its chunk size to '%d', however ERS_OPT_FLEX_CHUNK is missing!\n",instance->Name,new_size);
}
-
+
instance->Cache->ChunkSize = new_size;
}
@@ -321,7 +321,7 @@ ERS *ers_new(uint32 size, char *name, enum ERSOptions options)
instance->Options = options;
instance->Cache = ers_find_cache(size,instance->Options);
-
+
instance->Cache->ReferenceCount++;
if (InstanceList == NULL) {
@@ -384,7 +384,7 @@ void ers_report(void) {
**/
void ers_final(void) {
struct ers_instance_t *instance = InstanceList, *next;
-
+
while( instance ) {
next = instance->Next;
ers_obj_destroy((ERS*)instance);
diff --git a/src/common/ers.h b/src/common/ers.h
index 904f7fb81..8c56118ae 100644
--- a/src/common/ers.h
+++ b/src/common/ers.h
@@ -77,7 +77,7 @@ enum ERSOptions {
ERS_OPT_FREE_NAME = 0x4,/* name is dynamic memory, and should be freed */
ERS_OPT_CLEAN = 0x8,/* clears used memory upon ers_free so that its all new to be reused on the next alloc */
ERS_OPT_FLEX_CHUNK = 0x10,/* signs that it should look for its own cache given it'll have a dynamic chunk size, so that it doesn't affect the other ERS it'd otherwise be sharing */
-
+
/* Compound, is used to determine whether it should be looking for a cache of matching options */
ERS_CACHE_OPTIONS = ERS_OPT_CLEAN|ERS_OPT_FLEX_CHUNK,
};
diff --git a/src/common/grfio.c b/src/common/grfio.c
index 5be0c8237..eeda7e4b5 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -21,7 +21,7 @@
#include "../common/utils.h"
//----------------------------
-// file entry table struct
+// file entry table struct
//----------------------------
typedef struct FILELIST {
int srclen; ///< compressed size
@@ -50,14 +50,14 @@ typedef struct FILELIST {
// stores info about every loaded file
-FILELIST* filelist = NULL;
-int filelist_entrys = 0;
-int filelist_maxentry = 0;
+FILELIST* filelist = NULL;
+int filelist_entrys = 0;
+int filelist_maxentry = 0;
// stores grf file names
-char** gentry_table = NULL;
-int gentry_entrys = 0;
-int gentry_maxentry = 0;
+char** gentry_table = NULL;
+int gentry_entrys = 0;
+int gentry_maxentry = 0;
// the path to the data directory
char data_dir[1024] = "";
@@ -109,22 +109,23 @@ static uint8_t grf_substitution(uint8_t in)
return out;
}
-/* this is not used anywhere, is it ok to delete? */
-//static void grf_shuffle_enc(BIT64* src) {
-// BIT64 out;
-//
-// out.b[0] = src->b[3];
-// out.b[1] = src->b[4];
-// out.b[2] = src->b[5];
-// out.b[3] = src->b[0];
-// out.b[4] = src->b[1];
-// out.b[5] = src->b[6];
-// out.b[6] = src->b[2];
-// out.b[7] = grf_substitution(src->b[7]);
-//
-// *src = out;
-//}
+#if 0 /* this is not used anywhere, is it ok to delete? */
+static void grf_shuffle_enc(BIT64* src)
+{
+ BIT64 out;
+ out.b[0] = src->b[3];
+ out.b[1] = src->b[4];
+ out.b[2] = src->b[5];
+ out.b[3] = src->b[0];
+ out.b[4] = src->b[1];
+ out.b[5] = src->b[6];
+ out.b[6] = src->b[2];
+ out.b[7] = grf_substitution(src->b[7]);
+
+ *src = out;
+}
+#endif // 0
static void grf_shuffle_dec(BIT64* src)
{
@@ -425,7 +426,7 @@ void* grfio_reads(const char* fname, int* size)
*size = declen;
} else {
if (entry != NULL && entry->gentry < 0) {
- entry->gentry = -entry->gentry; // local file checked
+ entry->gentry = -entry->gentry; // local file checked
} else {
ShowError("grfio_reads: %s not found (local file: %s)\n", fname, lfname);
return NULL;
@@ -515,7 +516,7 @@ static int grfio_entryread(const char* grfname, int gentry)
FILE* fp = fopen(grfname, "rb");
if( fp == NULL ) {
ShowWarning("GRF data file not found: '%s'\n",grfname);
- return 1; // 1:not found error
+ return 1; // 1:not found error
} else
ShowInfo("GRF data file found: '%s'\n",grfname);
@@ -527,7 +528,7 @@ static int grfio_entryread(const char* grfname, int gentry)
if( strcmp((const char*)grf_header,"Master of Magic") != 0 || fseek(fp,getlong(grf_header+0x1e),SEEK_CUR) != 0 ) {
fclose(fp);
ShowError("GRF %s read error\n", grfname);
- return 2; // 2:file format error
+ return 2; // 2:file format error
}
grf_version = getlong(grf_header+0x2a) >> 8;
@@ -565,11 +566,11 @@ static int grfio_entryread(const char* grfname, int gentry)
aentry.srcpos = getlong(grf_filelist+ofs2+13)+0x2e;
aentry.type = type;
safestrncpy(aentry.fn, fname, sizeof(aentry.fn));
- aentry.fnd = NULL;
-#ifdef GRFIO_LOCAL
- aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck
+ aentry.fnd = NULL;
+#ifdef GRFIO_LOCAL
+ aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck
#else
- aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck
+ aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck
#endif
filelist_modify(&aentry);
}
@@ -584,8 +585,8 @@ static int grfio_entryread(const char* grfname, int gentry)
uLongf rSize, eSize;
if(fread(eheader,1,8,fp) != 8) ShowError("An error occurred in fread while reading header buffer\n");
- rSize = getlong(eheader); // Read Size
- eSize = getlong(eheader+4); // Extend Size
+ rSize = getlong(eheader); // Read Size
+ eSize = getlong(eheader+4); // Extend Size
if( (long)rSize > grf_size-ftell(fp) ) {
fclose(fp);
@@ -593,11 +594,11 @@ static int grfio_entryread(const char* grfname, int gentry)
return 4;
}
- rBuf = (unsigned char *)aMalloc(rSize); // Get a Read Size
- grf_filelist = (unsigned char *)aMalloc(eSize); // Get a Extend Size
+ rBuf = (unsigned char *)aMalloc(rSize); // Get a Read Size
+ grf_filelist = (unsigned char *)aMalloc(eSize); // Get a Extend Size
if(fread(rBuf,1,rSize,fp) != rSize) ShowError("An error occurred in fread \n");
fclose(fp);
- decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function
+ decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function
aFree(rBuf);
entrys = getlong(grf_header+0x26) - 7;
@@ -623,11 +624,11 @@ static int grfio_entryread(const char* grfname, int gentry)
aentry.srcpos = getlong(grf_filelist+ofs2+13)+0x2e;
aentry.type = (char)type;
safestrncpy(aentry.fn, fname, sizeof(aentry.fn));
- aentry.fnd = NULL;
-#ifdef GRFIO_LOCAL
- aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck
+ aentry.fnd = NULL;
+#ifdef GRFIO_LOCAL
+ aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck
#else
- aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck
+ aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck
#endif
filelist_modify(&aentry);
}
@@ -642,9 +643,9 @@ static int grfio_entryread(const char* grfname, int gentry)
return 4;
}
- filelist_compact(); // Unnecessary area release of filelist
+ filelist_compact(); // Unnecessary area release of filelist
- return 0; // 0:no error
+ return 0; // 0:no error
}
@@ -714,7 +715,7 @@ static void grfio_resourcecheck(void)
fclose(fp);
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, "resnametable.txt");
- return; // we're done here!
+ return; // we're done here!
}
// read resnametable from loaded GRF's, only if it cannot be loaded from the data directory
@@ -745,12 +746,12 @@ static void grfio_resourcecheck(void)
/// Reads a grf file and adds it to the list.
static int grfio_add(const char* fname)
{
- if( gentry_entrys >= gentry_maxentry )
- {
- #define GENTRY_ADDS 4 // The number increment of gentry_table entries
+ if (gentry_entrys >= gentry_maxentry) {
+#define GENTRY_ADDS 4 // The number increment of gentry_table entries
gentry_maxentry += GENTRY_ADDS;
gentry_table = (char**)aRealloc(gentry_table, gentry_maxentry * sizeof(char*));
memset(gentry_table + (gentry_maxentry - GENTRY_ADDS), 0, sizeof(char*) * GENTRY_ADDS);
+#undef GENTRY_ADDS
}
gentry_table[gentry_entrys++] = aStrdup(fname);
@@ -792,7 +793,7 @@ void grfio_init(const char* fname)
FILE* data_conf;
int grf_num = 0;
- hashinit(); // hash table initialization
+ hashinit(); // hash table initialization
data_conf = fopen(fname, "r");
if( data_conf != NULL )
diff --git a/src/common/malloc.c b/src/common/malloc.c
index eae9ad423..244b1114c 100644
--- a/src/common/malloc.c
+++ b/src/common/malloc.c
@@ -143,7 +143,7 @@ void aFree_(void *p, const char *file, int line, const char *func)
* Since the complex processing, I might be slightly heavier.
*
* (I'm sorry for the poor description ^ ^;) such as data structures
-* Divided into "blocks" of a plurality of memory, "unit" of a plurality of blocks further
+* Divided into "blocks" of a plurality of memory, "unit" of a plurality of blocks further
* I have to divide. Size of the unit, a plurality of distribution equal to the capacity of one block
* That's what you have. For example, if one unit of 32KB, one block 1 Yu 32Byte
* Knit, or are able to gather 1024, gathered 512 units 64Byte
@@ -155,33 +155,33 @@ void aFree_(void *p, const char *file, int line, const char *func)
*/
/* Alignment of the block */
-#define BLOCK_ALIGNMENT1 16
-#define BLOCK_ALIGNMENT2 64
+#define BLOCK_ALIGNMENT1 16
+#define BLOCK_ALIGNMENT2 64
/* Amount of data entering a block */
-#define BLOCK_DATA_COUNT1 128
-#define BLOCK_DATA_COUNT2 608
+#define BLOCK_DATA_COUNT1 128
+#define BLOCK_DATA_COUNT2 608
/* The size of the block: 16*128 + 64*576 = 40KB */
-#define BLOCK_DATA_SIZE1 ( BLOCK_ALIGNMENT1 * BLOCK_DATA_COUNT1 )
-#define BLOCK_DATA_SIZE2 ( BLOCK_ALIGNMENT2 * BLOCK_DATA_COUNT2 )
-#define BLOCK_DATA_SIZE ( BLOCK_DATA_SIZE1 + BLOCK_DATA_SIZE2 )
+#define BLOCK_DATA_SIZE1 ( BLOCK_ALIGNMENT1 * BLOCK_DATA_COUNT1 )
+#define BLOCK_DATA_SIZE2 ( BLOCK_ALIGNMENT2 * BLOCK_DATA_COUNT2 )
+#define BLOCK_DATA_SIZE ( BLOCK_DATA_SIZE1 + BLOCK_DATA_SIZE2 )
/* The number of blocks to be allocated at a time. */
-#define BLOCK_ALLOC 104
+#define BLOCK_ALLOC 104
/* block */
struct block {
- struct block* block_next; /* Then the allocated area */
- struct block* unfill_prev; /* The previous area not filled */
- struct block* unfill_next; /* The next area not filled */
- unsigned short unit_size; /* The size of the unit */
- unsigned short unit_hash; /* The hash of the unit */
- unsigned short unit_count; /* The number of units */
- unsigned short unit_used; /* The number of used units */
- unsigned short unit_unfill; /* The number of unused units */
- unsigned short unit_maxused; /* The maximum value of units used */
- char data[ BLOCK_DATA_SIZE ];
+ struct block *block_next; ///< Then the allocated area
+ struct block *unfill_prev; ///< The previous area not filled
+ struct block *unfill_next; ///< The next area not filled
+ unsigned short unit_size; ///< The size of the unit
+ unsigned short unit_hash; ///< The hash of the unit
+ unsigned short unit_count; ///< The number of units
+ unsigned short unit_used; ///< The number of used units
+ unsigned short unit_unfill; ///< The number of unused units
+ unsigned short unit_maxused; ///< The maximum value of units used
+ char data[BLOCK_DATA_SIZE];
};
struct unit_head {
@@ -222,7 +222,7 @@ static unsigned short size2hash( size_t size )
return (unsigned short)(size - BLOCK_DATA_SIZE1 + BLOCK_ALIGNMENT2 - 1) / BLOCK_ALIGNMENT2
+ BLOCK_DATA_COUNT1;
} else {
- return 0xffff; // If it exceeds the block length hash I do not
+ return 0xffff; // If it exceeds the block length hash I do not
}
}
@@ -375,13 +375,13 @@ void *mrealloc_(void *memblock, size_t size, const char *file, int line, const c
void *mreallocz_(void *memblock, size_t size, const char *file, int line, const char *func) {
size_t old_size;
void *p = NULL;
-
+
if(memblock == NULL) {
p = iMalloc->malloc(size,file,line,func);
memset(p,0,size);
return p;
}
-
+
old_size = ((struct unit_head *)((char *)memblock - sizeof(struct unit_head) + sizeof(long)))->size;
if( old_size == 0 ) {
old_size = ((struct unit_head_large *)((char *)memblock - sizeof(struct unit_head_large) + sizeof(long)))->size;
@@ -702,7 +702,7 @@ void memmgr_report (int extra) {
unsigned int count;
} data[100];
memset(&data, 0, sizeof(data));
-
+
if( extra != 0 )
msize = extra;
@@ -732,7 +732,7 @@ void memmgr_report (int extra) {
}
block = block->block_next;
}
-
+
while(large) {
if( large->size > msize ) {
for( j = 0; j < 100; j++ ) {
@@ -760,7 +760,7 @@ void memmgr_report (int extra) {
}
ShowMessage("[malloc] : reporting %u instances | %.2f MB\n",count,(double)((size)/1024)/1024);
ShowMessage("[malloc] : internal usage %.2f MB | %.2f MB\n",(double)((memmgr_usage_bytes_t-memmgr_usage_bytes)/1024)/1024,(double)((memmgr_usage_bytes_t)/1024)/1024);
-
+
if (extra) {
ShowMessage("[malloc] : unit_head_large: %"PRIuS" bytes\n", sizeof(struct unit_head_large));
ShowMessage("[malloc] : unit_head: %"PRIuS" bytes\n", sizeof(struct unit_head));
@@ -822,8 +822,10 @@ void malloc_final (void) {
}
void malloc_init (void) {
+#ifdef USE_MEMMGR
memmgr_usage_bytes_t = 0;
memmgr_usage_bytes = 0;
+#endif
#if defined(DMALLOC) && defined(CYGWIN)
// http://dmalloc.com/docs/latest/online/dmalloc_19.html
dmalloc_debug_setup(getenv("DMALLOC_OPTIONS"));
@@ -848,19 +850,19 @@ void malloc_defaults(void) {
// Athena's built-in Memory Manager
#ifdef USE_MEMMGR
- iMalloc->malloc = mmalloc_;
- iMalloc->calloc = mcalloc_;
- iMalloc->realloc = mrealloc_;
- iMalloc->reallocz= mreallocz_;
- iMalloc->astrdup = mstrdup_;
- iMalloc->free = mfree_;
+ iMalloc->malloc = mmalloc_;
+ iMalloc->calloc = mcalloc_;
+ iMalloc->realloc = mrealloc_;
+ iMalloc->reallocz = mreallocz_;
+ iMalloc->astrdup = mstrdup_;
+ iMalloc->free = mfree_;
#else
- iMalloc->malloc = aMalloc_;
- iMalloc->calloc = aCalloc_;
- iMalloc->realloc = aRealloc_;
- iMalloc->reallocz= aRealloc_;/* not using memory manager huhum o.o perhaps we could still do something about */
- iMalloc->astrdup = aStrdup_;
- iMalloc->free = aFree_;
+ iMalloc->malloc = aMalloc_;
+ iMalloc->calloc = aCalloc_;
+ iMalloc->realloc = aRealloc_;
+ iMalloc->reallocz = aRealloc_;/* not using memory manager huhum o.o perhaps we could still do something about */
+ iMalloc->astrdup = aStrdup_;
+ iMalloc->free = aFree_;
#endif
iMalloc->post_shutdown = NULL;
}
diff --git a/src/common/malloc.h b/src/common/malloc.h
index 8dace2d68..53d2ebdd2 100644
--- a/src/common/malloc.h
+++ b/src/common/malloc.h
@@ -68,19 +68,19 @@
void malloc_defaults(void);
struct malloc_interface {
- void (*init) (void);
- void (*final) (void);
+ void (*init) (void);
+ void (*final) (void);
/* */
- void* (*malloc )(size_t size, const char *file, int line, const char *func);
- void* (*calloc )(size_t num, size_t size, const char *file, int line, const char *func);
- void* (*realloc )(void *p, size_t size, const char *file, int line, const char *func);
+ void* (*malloc)(size_t size, const char *file, int line, const char *func);
+ void* (*calloc)(size_t num, size_t size, const char *file, int line, const char *func);
+ void* (*realloc)(void *p, size_t size, const char *file, int line, const char *func);
void* (*reallocz)(void *p, size_t size, const char *file, int line, const char *func);
- char* (*astrdup )(const char *p, const char *file, int line, const char *func);
- void (*free )(void *p, const char *file, int line, const char *func);
+ char* (*astrdup)(const char *p, const char *file, int line, const char *func);
+ void (*free)(void *p, const char *file, int line, const char *func);
/* */
- void (*memory_check)(void);
- bool (*verify_ptr)(void* ptr);
- size_t (*usage) (void);
+ void (*memory_check)(void);
+ bool (*verify_ptr)(void* ptr);
+ size_t (*usage) (void);
/* */
void (*post_shutdown) (void);
};
diff --git a/src/common/mapindex.c b/src/common/mapindex.c
index f540c98d8..0d8a69726 100644
--- a/src/common/mapindex.c
+++ b/src/common/mapindex.c
@@ -24,7 +24,7 @@ struct mapindex_interface mapindex_s;
const char* mapindex_getmapname(const char* string, char* output) {
static char buf[MAP_NAME_LENGTH];
char* dest = (output != NULL) ? output : buf;
-
+
size_t len = strnlen(string, MAP_NAME_LENGTH_EXT);
if (len == MAP_NAME_LENGTH_EXT) {
ShowWarning("(mapindex_normalize_name) Map name '%*s' is too long!\n", 2*MAP_NAME_LENGTH_EXT, string);
@@ -32,11 +32,11 @@ const char* mapindex_getmapname(const char* string, char* output) {
}
if (len >= 4 && stricmp(&string[len-4], ".gat") == 0)
len -= 4; // strip .gat extension
-
+
len = min(len, MAP_NAME_LENGTH-1);
safestrncpy(dest, string, len+1);
memset(&dest[len], '\0', MAP_NAME_LENGTH-len);
-
+
return dest;
}
@@ -65,7 +65,7 @@ const char* mapindex_getmapname_ext(const char* string, char* output) {
}
memset(&dest[len], '\0', MAP_NAME_LENGTH_EXT-len);
-
+
return dest;
}
@@ -105,7 +105,7 @@ int mapindex_addmap(int index, const char* name) {
safestrncpy(mapindex->list[index].name, map_name, MAP_NAME_LENGTH);
strdb_iput(mapindex->db, map_name, index);
-
+
if (mapindex->num <= index)
mapindex->num = index+1;
@@ -115,12 +115,12 @@ int mapindex_addmap(int index, const char* name) {
unsigned short mapindex_name2id(const char* name) {
int i;
char map_name[MAP_NAME_LENGTH];
-
+
mapindex->getmapname(name, map_name);
if( (i = strdb_iget(mapindex->db, map_name)) )
return i;
-
+
ShowDebug("mapindex_name2id: Map \"%s\" not found in index list!\n", map_name);
return 0;
}
@@ -138,15 +138,15 @@ int mapindex_init(void) {
char line[1024];
int last_index = -1;
int index, total = 0;
- char map_name[12];
-
+ char map_name[13];
+
if( ( fp = fopen(mapindex->config_file,"r") ) == NULL ){
ShowFatalError("Unable to read mapindex config file %s!\n", mapindex->config_file);
exit(EXIT_FAILURE); //Server can't really run without this file.
}
mapindex->db = strdb_alloc(DB_OPT_DUP_KEY, MAP_NAME_LENGTH);
-
+
while(fgets(line, sizeof(line), fp)) {
if(line[0] == '/' && line[1] == '/')
continue;
@@ -165,13 +165,20 @@ int mapindex_init(void) {
}
fclose(fp);
- if( !strdb_iget(mapindex->db, MAP_DEFAULT) ) {
- ShowError("mapindex_init: MAP_DEFAULT '%s' not found in cache! update mapindex.h MAP_DEFAULT var!!!\n",MAP_DEFAULT);
- }
-
+ mapindex->check_default();
+
return total;
}
+bool mapindex_check_default(void)
+{
+ if (!strdb_iget(mapindex->db, mapindex->default_map)) {
+ ShowError("mapindex_init: MAP_DEFAULT '%s' not found in cache! update mapindex.h MAP_DEFAULT var!!!\n", mapindex->default_map);
+ return false;
+ }
+ return true;
+}
+
void mapindex_removemap(int index){
strdb_remove(mapindex->db, mapindex->list[index].name);
mapindex->list[index].name[0] = '\0';
@@ -183,14 +190,17 @@ void mapindex_final(void) {
void mapindex_defaults(void) {
mapindex = &mapindex_s;
-
+
/* TODO: place it in inter-server.conf? */
snprintf(mapindex->config_file, 80, "%s","db/map_index.txt");
/* */
mapindex->db = NULL;
mapindex->num = 0;
+ mapindex->default_map = MAP_DEFAULT;
+ mapindex->default_x = MAP_DEFAULT_X;
+ mapindex->default_y = MAP_DEFAULT_Y;
memset (&mapindex->list, 0, sizeof (mapindex->list));
-
+
/* */
mapindex->init = mapindex_init;
mapindex->final = mapindex_final;
@@ -201,4 +211,5 @@ void mapindex_defaults(void) {
mapindex->getmapname_ext = mapindex_getmapname_ext;
mapindex->name2id = mapindex_name2id;
mapindex->id2name = mapindex_id2name_sub;
+ mapindex->check_default = mapindex_check_default;
}
diff --git a/src/common/mapindex.h b/src/common/mapindex.h
index 446a2422d..91bf4562e 100644
--- a/src/common/mapindex.h
+++ b/src/common/mapindex.h
@@ -67,6 +67,12 @@ struct mapindex_interface {
DBMap *db;
/* number of entries in the index table */
int num;
+ /* default map name */
+ char *default_map;
+ /* default x on map */
+ int default_x;
+ /* default y on map */
+ int default_y;
/* index list -- since map server map count is *unlimited* this should be too */
struct {
char name[MAP_NAME_LENGTH];
@@ -84,6 +90,7 @@ struct mapindex_interface {
/* TODO: Hello World! make up your mind, this thing is int on some places and unsigned short on others */
unsigned short (*name2id) (const char*);
const char* (*id2name) (unsigned short,const char *file, int line, const char *func);
+ bool (*check_default) (void);
};
struct mapindex_interface *mapindex;
diff --git a/src/common/md5calc.c b/src/common/md5calc.c
index e7b506e27..18e502da2 100644
--- a/src/common/md5calc.c
+++ b/src/common/md5calc.c
@@ -25,22 +25,22 @@ static unsigned int *pX;
// String Table
static const unsigned int T[] = {
- 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, //0
- 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, //4
- 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, //8
- 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, //12
- 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, //16
- 0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8, //20
- 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, //24
- 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, //28
- 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, //32
- 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, //36
- 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05, //40
- 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, //44
- 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, //48
- 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, //52
- 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, //56
- 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 //60
+ 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, //0
+ 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, //4
+ 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, //8
+ 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, //12
+ 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, //16
+ 0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8, //20
+ 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, //24
+ 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, //28
+ 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, //32
+ 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, //36
+ 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05, //40
+ 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, //44
+ 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, //48
+ 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, //52
+ 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, //56
+ 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 //60
};
// ROTATE_LEFT The left is made to rotate x [ n-bit ]. This is diverted as it is from RFC.
@@ -49,25 +49,25 @@ static const unsigned int T[] = {
// The function used for other calculation
static unsigned int F(unsigned int X, unsigned int Y, unsigned int Z)
{
- return (X & Y) | (~X & Z);
+ return (X & Y) | (~X & Z);
}
static unsigned int G(unsigned int X, unsigned int Y, unsigned int Z)
{
- return (X & Z) | (Y & ~Z);
+ return (X & Z) | (Y & ~Z);
}
static unsigned int H(unsigned int X, unsigned int Y, unsigned int Z)
{
- return X ^ Y ^ Z;
+ return X ^ Y ^ Z;
}
static unsigned int I(unsigned int X, unsigned int Y, unsigned int Z)
{
- return Y ^ (X | ~Z);
+ return Y ^ (X | ~Z);
}
static unsigned int Round(unsigned int a, unsigned int b, unsigned int FGHI,
- unsigned int k, unsigned int s, unsigned int i)
+ unsigned int k, unsigned int s, unsigned int i)
{
- return b + ROTATE_LEFT(a + FGHI + pX[k] + T[i], s);
+ return b + ROTATE_LEFT(a + FGHI + pX[k] + T[i], s);
}
static void Round1(unsigned int *a, unsigned int b, unsigned int c,
@@ -113,103 +113,103 @@ static void MD5_Round_Calculate(const unsigned char *block,
| ( ((unsigned int )block[j+3]) << 24 );
- //Round 1
- Round1(&A,B,C,D, 0, 7, 0); Round1(&D,A,B,C, 1, 12, 1); Round1(&C,D,A,B, 2, 17, 2); Round1(&B,C,D,A, 3, 22, 3);
- Round1(&A,B,C,D, 4, 7, 4); Round1(&D,A,B,C, 5, 12, 5); Round1(&C,D,A,B, 6, 17, 6); Round1(&B,C,D,A, 7, 22, 7);
- Round1(&A,B,C,D, 8, 7, 8); Round1(&D,A,B,C, 9, 12, 9); Round1(&C,D,A,B, 10, 17, 10); Round1(&B,C,D,A, 11, 22, 11);
- Round1(&A,B,C,D, 12, 7, 12); Round1(&D,A,B,C, 13, 12, 13); Round1(&C,D,A,B, 14, 17, 14); Round1(&B,C,D,A, 15, 22, 15);
-
- //Round 2
- Round2(&A,B,C,D, 1, 5, 16); Round2(&D,A,B,C, 6, 9, 17); Round2(&C,D,A,B, 11, 14, 18); Round2(&B,C,D,A, 0, 20, 19);
- Round2(&A,B,C,D, 5, 5, 20); Round2(&D,A,B,C, 10, 9, 21); Round2(&C,D,A,B, 15, 14, 22); Round2(&B,C,D,A, 4, 20, 23);
- Round2(&A,B,C,D, 9, 5, 24); Round2(&D,A,B,C, 14, 9, 25); Round2(&C,D,A,B, 3, 14, 26); Round2(&B,C,D,A, 8, 20, 27);
- Round2(&A,B,C,D, 13, 5, 28); Round2(&D,A,B,C, 2, 9, 29); Round2(&C,D,A,B, 7, 14, 30); Round2(&B,C,D,A, 12, 20, 31);
-
- //Round 3
- Round3(&A,B,C,D, 5, 4, 32); Round3(&D,A,B,C, 8, 11, 33); Round3(&C,D,A,B, 11, 16, 34); Round3(&B,C,D,A, 14, 23, 35);
- Round3(&A,B,C,D, 1, 4, 36); Round3(&D,A,B,C, 4, 11, 37); Round3(&C,D,A,B, 7, 16, 38); Round3(&B,C,D,A, 10, 23, 39);
- Round3(&A,B,C,D, 13, 4, 40); Round3(&D,A,B,C, 0, 11, 41); Round3(&C,D,A,B, 3, 16, 42); Round3(&B,C,D,A, 6, 23, 43);
- Round3(&A,B,C,D, 9, 4, 44); Round3(&D,A,B,C, 12, 11, 45); Round3(&C,D,A,B, 15, 16, 46); Round3(&B,C,D,A, 2, 23, 47);
-
- //Round 4
- Round4(&A,B,C,D, 0, 6, 48); Round4(&D,A,B,C, 7, 10, 49); Round4(&C,D,A,B, 14, 15, 50); Round4(&B,C,D,A, 5, 21, 51);
- Round4(&A,B,C,D, 12, 6, 52); Round4(&D,A,B,C, 3, 10, 53); Round4(&C,D,A,B, 10, 15, 54); Round4(&B,C,D,A, 1, 21, 55);
- Round4(&A,B,C,D, 8, 6, 56); Round4(&D,A,B,C, 15, 10, 57); Round4(&C,D,A,B, 6, 15, 58); Round4(&B,C,D,A, 13, 21, 59);
- Round4(&A,B,C,D, 4, 6, 60); Round4(&D,A,B,C, 11, 10, 61); Round4(&C,D,A,B, 2, 15, 62); Round4(&B,C,D,A, 9, 21, 63);
-
- // Then perform the following additions. (let's add)
- *A2 = A + AA;
- *B2 = B + BB;
- *C2 = C + CC;
- *D2 = D + DD;
-
- //The clearance of confidential information
- memset(pX, 0, sizeof(X));
+ //Round 1
+ Round1(&A,B,C,D, 0, 7, 0); Round1(&D,A,B,C, 1, 12, 1); Round1(&C,D,A,B, 2, 17, 2); Round1(&B,C,D,A, 3, 22, 3);
+ Round1(&A,B,C,D, 4, 7, 4); Round1(&D,A,B,C, 5, 12, 5); Round1(&C,D,A,B, 6, 17, 6); Round1(&B,C,D,A, 7, 22, 7);
+ Round1(&A,B,C,D, 8, 7, 8); Round1(&D,A,B,C, 9, 12, 9); Round1(&C,D,A,B, 10, 17, 10); Round1(&B,C,D,A, 11, 22, 11);
+ Round1(&A,B,C,D, 12, 7, 12); Round1(&D,A,B,C, 13, 12, 13); Round1(&C,D,A,B, 14, 17, 14); Round1(&B,C,D,A, 15, 22, 15);
+
+ //Round 2
+ Round2(&A,B,C,D, 1, 5, 16); Round2(&D,A,B,C, 6, 9, 17); Round2(&C,D,A,B, 11, 14, 18); Round2(&B,C,D,A, 0, 20, 19);
+ Round2(&A,B,C,D, 5, 5, 20); Round2(&D,A,B,C, 10, 9, 21); Round2(&C,D,A,B, 15, 14, 22); Round2(&B,C,D,A, 4, 20, 23);
+ Round2(&A,B,C,D, 9, 5, 24); Round2(&D,A,B,C, 14, 9, 25); Round2(&C,D,A,B, 3, 14, 26); Round2(&B,C,D,A, 8, 20, 27);
+ Round2(&A,B,C,D, 13, 5, 28); Round2(&D,A,B,C, 2, 9, 29); Round2(&C,D,A,B, 7, 14, 30); Round2(&B,C,D,A, 12, 20, 31);
+
+ //Round 3
+ Round3(&A,B,C,D, 5, 4, 32); Round3(&D,A,B,C, 8, 11, 33); Round3(&C,D,A,B, 11, 16, 34); Round3(&B,C,D,A, 14, 23, 35);
+ Round3(&A,B,C,D, 1, 4, 36); Round3(&D,A,B,C, 4, 11, 37); Round3(&C,D,A,B, 7, 16, 38); Round3(&B,C,D,A, 10, 23, 39);
+ Round3(&A,B,C,D, 13, 4, 40); Round3(&D,A,B,C, 0, 11, 41); Round3(&C,D,A,B, 3, 16, 42); Round3(&B,C,D,A, 6, 23, 43);
+ Round3(&A,B,C,D, 9, 4, 44); Round3(&D,A,B,C, 12, 11, 45); Round3(&C,D,A,B, 15, 16, 46); Round3(&B,C,D,A, 2, 23, 47);
+
+ //Round 4
+ Round4(&A,B,C,D, 0, 6, 48); Round4(&D,A,B,C, 7, 10, 49); Round4(&C,D,A,B, 14, 15, 50); Round4(&B,C,D,A, 5, 21, 51);
+ Round4(&A,B,C,D, 12, 6, 52); Round4(&D,A,B,C, 3, 10, 53); Round4(&C,D,A,B, 10, 15, 54); Round4(&B,C,D,A, 1, 21, 55);
+ Round4(&A,B,C,D, 8, 6, 56); Round4(&D,A,B,C, 15, 10, 57); Round4(&C,D,A,B, 6, 15, 58); Round4(&B,C,D,A, 13, 21, 59);
+ Round4(&A,B,C,D, 4, 6, 60); Round4(&D,A,B,C, 11, 10, 61); Round4(&C,D,A,B, 2, 15, 62); Round4(&B,C,D,A, 9, 21, 63);
+
+ // Then perform the following additions. (let's add)
+ *A2 = A + AA;
+ *B2 = B + BB;
+ *C2 = C + CC;
+ *D2 = D + DD;
+
+ //The clearance of confidential information
+ memset(pX, 0, sizeof(X));
}
static void MD5_String2binary(const char * string, unsigned char * output)
{
//var
- /*8bit*/
- unsigned char padding_message[64]; //Extended message 512bit 64byte
- unsigned char *pstring; //The position of string in the present scanning notes is held.
-
- /*32bit*/
- unsigned int string_byte_len, //The byte chief of string is held.
- string_bit_len, //The bit length of string is held.
- copy_len, //The number of bytes which is used by 1-3 and which remained
- msg_digest[4]; //Message digest 128bit 4byte
- unsigned int *A = &msg_digest[0], //The message digest in accordance with RFC (reference)
- *B = &msg_digest[1],
- *C = &msg_digest[2],
- *D = &msg_digest[3];
+ /*8bit*/
+ unsigned char padding_message[64]; //Extended message 512bit 64byte
+ unsigned char *pstring; //The position of string in the present scanning notes is held.
+
+ /*32bit*/
+ unsigned int string_byte_len, //The byte chief of string is held.
+ string_bit_len, //The bit length of string is held.
+ copy_len, //The number of bytes which is used by 1-3 and which remained
+ msg_digest[4]; //Message digest 128bit 4byte
+ unsigned int *A = &msg_digest[0], //The message digest in accordance with RFC (reference)
+ *B = &msg_digest[1],
+ *C = &msg_digest[2],
+ *D = &msg_digest[3];
int i;
//prog
- //Step 3.Initialize MD Buffer (although it is the initialization; step 3 of A, B, C, and D -- unavoidable -- a head)
- *A = 0x67452301;
- *B = 0xefcdab89;
- *C = 0x98badcfe;
- *D = 0x10325476;
-
- //Step 1.Append Padding Bits (extension of a mark bit)
- //1-1
- string_byte_len = (unsigned int)strlen(string); //The byte chief of a character sequence is acquired.
- pstring = (unsigned char *)string; //The position of the present character sequence is set.
-
- //1-2 Repeat calculation until length becomes less than 64 bytes.
- for (i=string_byte_len; 64<=i; i-=64,pstring+=64)
- MD5_Round_Calculate(pstring, A,B,C,D);
-
- //1-3
- copy_len = string_byte_len % 64; //The number of bytes which remained is computed.
- strncpy((char *)padding_message, (char *)pstring, copy_len); //A message is copied to an extended bit sequence.
- memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length.
- padding_message[copy_len] |= 0x80; //The next of a message is 1.
-
- //1-4
- //If 56 bytes or more (less than 64 bytes) of remainder becomes, it will calculate by extending to 64 bytes.
- if (56 <= copy_len) {
- MD5_Round_Calculate(padding_message, A,B,C,D);
- memset(padding_message, 0, 56); //56 bytes is newly fill uped with 0.
- }
-
- //Step 2.Append Length (the information on length is added)
- string_bit_len = string_byte_len * 8; //From the byte chief to bit length (32 bytes of low rank)
- memcpy(&padding_message[56], &string_bit_len, 4); //32 bytes of low rank is set.
-
- //When bit length cannot be expressed in 32 bytes of low rank, it is a beam raising to a higher rank.
- if (UINT_MAX / 8 < string_byte_len) {
- unsigned int high = (string_byte_len - UINT_MAX / 8) * 8;
- memcpy(&padding_message[60], &high, 4);
- } else
- memset(&padding_message[60], 0, 4); //In this case, it is good for a higher rank at 0.
-
- //Step 4.Process Message in 16-Word Blocks (calculation of MD5)
- MD5_Round_Calculate(padding_message, A,B,C,D);
-
- //Step 5.Output (output)
- memcpy(output,msg_digest,16);
+ //Step 3.Initialize MD Buffer (although it is the initialization; step 3 of A, B, C, and D -- unavoidable -- a head)
+ *A = 0x67452301;
+ *B = 0xefcdab89;
+ *C = 0x98badcfe;
+ *D = 0x10325476;
+
+ //Step 1.Append Padding Bits (extension of a mark bit)
+ //1-1
+ string_byte_len = (unsigned int)strlen(string); //The byte chief of a character sequence is acquired.
+ pstring = (unsigned char *)string; //The position of the present character sequence is set.
+
+ //1-2 Repeat calculation until length becomes less than 64 bytes.
+ for (i=string_byte_len; 64<=i; i-=64,pstring+=64)
+ MD5_Round_Calculate(pstring, A,B,C,D);
+
+ //1-3
+ copy_len = string_byte_len % 64; //The number of bytes which remained is computed.
+ strncpy((char *)padding_message, (char *)pstring, copy_len); //A message is copied to an extended bit sequence.
+ memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length.
+ padding_message[copy_len] |= 0x80; //The next of a message is 1.
+
+ //1-4
+ //If 56 bytes or more (less than 64 bytes) of remainder becomes, it will calculate by extending to 64 bytes.
+ if (56 <= copy_len) {
+ MD5_Round_Calculate(padding_message, A,B,C,D);
+ memset(padding_message, 0, 56); //56 bytes is newly fill uped with 0.
+ }
+
+ //Step 2.Append Length (the information on length is added)
+ string_bit_len = string_byte_len * 8; //From the byte chief to bit length (32 bytes of low rank)
+ memcpy(&padding_message[56], &string_bit_len, 4); //32 bytes of low rank is set.
+
+ //When bit length cannot be expressed in 32 bytes of low rank, it is a beam raising to a higher rank.
+ if (UINT_MAX / 8 < string_byte_len) {
+ unsigned int high = (string_byte_len - UINT_MAX / 8) * 8;
+ memcpy(&padding_message[60], &high, 4);
+ } else
+ memset(&padding_message[60], 0, 4); //In this case, it is good for a higher rank at 0.
+
+ //Step 4.Process Message in 16-Word Blocks (calculation of MD5)
+ MD5_Round_Calculate(padding_message, A,B,C,D);
+
+ //Step 5.Output (output)
+ memcpy(output,msg_digest,16);
}
//-------------------------------------------------------------------
@@ -227,7 +227,7 @@ void MD5_String(const char * string, char * output)
unsigned char digest[16];
MD5_String2binary(string,digest);
- sprintf(output, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ sprintf(output, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
digest[ 0], digest[ 1], digest[ 2], digest[ 3],
digest[ 4], digest[ 5], digest[ 6], digest[ 7],
digest[ 8], digest[ 9], digest[10], digest[11],
diff --git a/src/common/mmo.h b/src/common/mmo.h
index ff7c1da28..ef42e49c0 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -49,7 +49,7 @@
// 20120307 - 2012-03-07aRagexeRE+ - 0x970
#ifndef PACKETVER
- #define PACKETVER 20131223
+ #define PACKETVER 20141022
#endif // PACKETVER
//Uncomment the following line if your client is ragexeRE instead of ragexe (required because of conflicting packets in ragexe vs ragexeRE).
@@ -73,14 +73,14 @@
#define HOTKEY_SAVING
#if PACKETVER < 20090603
- // (27 = 9 skills x 3 bars) (0x02b9,191)
- #define MAX_HOTKEYS 27
+ // (27 = 9 skills x 3 bars) (0x02b9,191)
+ #define MAX_HOTKEYS 27
#elif PACKETVER < 20090617
- // (36 = 9 skills x 4 bars) (0x07d9,254)
- #define MAX_HOTKEYS 36
+ // (36 = 9 skills x 4 bars) (0x07d9,254)
+ #define MAX_HOTKEYS 36
#else // >= 20090617
- // (38 = 9 skills x 4 bars & 2 Quickslots)(0x07d9,268)
- #define MAX_HOTKEYS 38
+ // (38 = 9 skills x 4 bars & 2 Quickslots)(0x07d9,268)
+ #define MAX_HOTKEYS 38
#endif // 20090603
#endif // 20070227
@@ -376,6 +376,14 @@ struct s_homunculus { //[orn]
int int_;
int dex;
int luk;
+
+ int str_value;
+ int agi_value;
+ int vit_value;
+ int int_value;
+ int dex_value;
+ int luk_value;
+
int8 spiritball; //for homun S [lighta]
};
@@ -469,7 +477,7 @@ struct mmo_charstatus {
/* `account_data` modifiers */
unsigned short mod_exp,mod_drop,mod_death;
-
+
unsigned char font;
uint32 uniqueitem_counter;
@@ -593,15 +601,15 @@ struct guild {
struct guild_alliance alliance[MAX_GUILDALLIANCE];
struct guild_expulsion expulsion[MAX_GUILDEXPULSION];
struct guild_skill skill[MAX_GUILDSKILL];
-
+
/* used on char.c to state what kind of data is being saved/processed */
unsigned short save_flag;
-
+
short *instance;
unsigned short instances;
-
+
struct hChSysCh *channel;
-
+
/* HPM Custom Struct */
struct HPluginData **hdata;
unsigned int hdatac;
diff --git a/src/common/mutex.c b/src/common/mutex.c
index f046febf6..31202d440 100644
--- a/src/common/mutex.c
+++ b/src/common/mutex.c
@@ -52,19 +52,19 @@ struct racond{
ramutex *ramutex_create(void) {
struct ramutex *m;
-
+
m = (struct ramutex*)aMalloc( sizeof(struct ramutex) );
if (m == NULL) {
ShowFatalError("ramutex_create: OOM while allocating %"PRIuS" bytes.\n", sizeof(struct ramutex));
return NULL;
}
-
+
#ifdef WIN32
InitializeCriticalSection(&m->hMutex);
#else
pthread_mutex_init(&m->hMutex, NULL);
#endif
-
+
return m;
}//end: ramutex_create()
@@ -101,7 +101,7 @@ bool ramutex_trylock(ramutex *m) {
#else
if(pthread_mutex_trylock(&m->hMutex) == 0)
return true;
-
+
return false;
#endif
}//end: ramutex_trylock()
@@ -126,7 +126,7 @@ void ramutex_unlock(ramutex *m) {
racond *racond_create(void) {
struct racond *c;
-
+
c = (struct racond*)aMalloc( sizeof(struct racond) );
if (c == NULL) {
ShowFatalError("racond_create: OOM while allocating %"PRIuS" bytes\n", sizeof(struct racond));
@@ -135,13 +135,13 @@ racond *racond_create(void) {
#ifdef WIN32
c->nWaiters = 0;
- c->events[ EVENT_COND_SIGNAL ] = CreateEvent( NULL, FALSE, FALSE, NULL );
- c->events[ EVENT_COND_BROADCAST ] = CreateEvent( NULL, TRUE, FALSE, NULL );
+ c->events[EVENT_COND_SIGNAL] = CreateEvent(NULL, FALSE, FALSE, NULL);
+ c->events[EVENT_COND_BROADCAST] = CreateEvent(NULL, TRUE, FALSE, NULL);
InitializeCriticalSection( &c->waiters_lock );
#else
pthread_cond_init(&c->hCond, NULL);
#endif
-
+
return c;
}//end: racond_create()
@@ -174,24 +174,20 @@ void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) {
ms = INFINITE;
else
ms = (timeout_ticks > MAXDWORD) ? (MAXDWORD - 1) : (DWORD)timeout_ticks;
-
-
+
// we can release the mutex (m) here, cause win's
// manual reset events maintain state when used with
// SetEvent()
ramutex_unlock(m);
result = WaitForMultipleObjects(2, c->events, FALSE, ms);
-
-
+
EnterCriticalSection(&c->waiters_lock);
c->nWaiters--;
if( (result == WAIT_OBJECT_0 + EVENT_COND_BROADCAST) && (c->nWaiters == 0) )
is_last = true; // Broadcast called!
LeaveCriticalSection(&c->waiters_lock);
-
-
// we are the last waiter that has to be notified, or to stop waiting
// so we have to do a manual reset
if(is_last == true)
@@ -206,10 +202,10 @@ void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) {
}else{
struct timespec wtime;
int64 exact_timeout = timer->gettick() + timeout_ticks;
-
+
wtime.tv_sec = exact_timeout/1000;
wtime.tv_nsec = (exact_timeout%1000)*1000000;
-
+
pthread_cond_timedwait( &c->hCond, &m->hMutex, &wtime);
}
@@ -219,13 +215,15 @@ void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) {
void racond_signal(racond *c) {
#ifdef WIN32
-// bool has_waiters = false;
-// EnterCriticalSection(&c->waiters_lock);
-// if(c->nWaiters > 0)
-// has_waiters = true;
-// LeaveCriticalSection(&c->waiters_lock);
-
-// if(has_waiters == true)
+# if 0
+ bool has_waiters = false;
+ EnterCriticalSection(&c->waiters_lock);
+ if(c->nWaiters > 0)
+ has_waiters = true;
+ LeaveCriticalSection(&c->waiters_lock);
+
+ if(has_waiters == true)
+# endif // 0
SetEvent( c->events[ EVENT_COND_SIGNAL ] );
#else
pthread_cond_signal(&c->hCond);
@@ -235,13 +233,15 @@ void racond_signal(racond *c) {
void racond_broadcast(racond *c) {
#ifdef WIN32
-// bool has_waiters = false;
-// EnterCriticalSection(&c->waiters_lock);
-// if(c->nWaiters > 0)
-// has_waiters = true;
-// LeaveCriticalSection(&c->waiters_lock);
-
-// if(has_waiters == true)
+# if 0
+ bool has_waiters = false;
+ EnterCriticalSection(&c->waiters_lock);
+ if(c->nWaiters > 0)
+ has_waiters = true;
+ LeaveCriticalSection(&c->waiters_lock);
+
+ if(has_waiters == true)
+# endif // 0
SetEvent( c->events[ EVENT_COND_BROADCAST ] );
#else
pthread_cond_broadcast(&c->hCond);
diff --git a/src/common/nullpo.c b/src/common/nullpo.c
index a3471b00d..0333c02ef 100644
--- a/src/common/nullpo.c
+++ b/src/common/nullpo.c
@@ -24,10 +24,10 @@
void assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) {
if (file == NULL)
file = "??";
-
+
if (func == NULL || *func == '\0')
func = "unknown";
-
+
ShowError("--- %s --------------------------------------------\n", title);
ShowError("%s:%d: '%s' in function `%s'\n", file, line, targetname, func);
ShowError("--- end %s ----------------------------------------\n", title);
diff --git a/src/common/showmsg.c b/src/common/showmsg.c
index f3982d364..0dd645eeb 100644
--- a/src/common/showmsg.c
+++ b/src/common/showmsg.c
@@ -93,20 +93,20 @@ int console_msg_log = 0;//[Ind] msg error logging
//
// \033[#;...;#m - Set Graphics Rendition (SGR)
//
-// printf("\x1b[1;31;40m"); // Bright red on black
-// printf("\x1b[3;33;45m"); // Blinking yellow on magenta (blink not implemented)
-// printf("\x1b[1;30;47m"); // Bright black (grey) on dim white
+// printf("\x1b[1;31;40m"); // Bright red on black
+// printf("\x1b[3;33;45m"); // Blinking yellow on magenta (blink not implemented)
+// printf("\x1b[1;30;47m"); // Bright black (grey) on dim white
//
// Style Foreground Background
-// 1st Digit 2nd Digit 3rd Digit RGB
-// 0 - Reset 30 - Black 40 - Black 000
-// 1 - FG Bright 31 - Red 41 - Red 100
-// 2 - Unknown 32 - Green 42 - Green 010
-// 3 - Blink 33 - Yellow 43 - Yellow 110
-// 4 - Underline 34 - Blue 44 - Blue 001
-// 5 - BG Bright 35 - Magenta 45 - Magenta 101
-// 6 - Unknown 36 - Cyan 46 - Cyan 011
-// 7 - Reverse 37 - White 47 - White 111
+// 1st Digit 2nd Digit 3rd Digit RGB
+// 0 - Reset 30 - Black 40 - Black 000
+// 1 - FG Bright 31 - Red 41 - Red 100
+// 2 - Unknown 32 - Green 42 - Green 010
+// 3 - Blink 33 - Yellow 43 - Yellow 110
+// 4 - Underline 34 - Blue 44 - Blue 001
+// 5 - BG Bright 35 - Magenta 45 - Magenta 101
+// 6 - Unknown 36 - Cyan 46 - Cyan 011
+// 7 - Reverse 37 - White 47 - White 111
// 8 - Concealed (invisible)
//
// \033[#A - Cursor Up (CUU)
@@ -181,7 +181,7 @@ Escape sequences for Select Character Set
#define is_console(handle) (FILE_TYPE_CHAR==GetFileType(handle))
///////////////////////////////////////////////////////////////////////////////
-int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
+int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
{
/////////////////////////////////////////////////////////////////
/* XXX Two streams are being used. Disabled to avoid inconsistency [flaviojs]
@@ -207,19 +207,18 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
// start with processing
p = BUFVAL(tempbuf);
- while ((q = strchr(p, 0x1b)) != NULL)
- { // find the escape character
+ while ((q = strchr(p, 0x1b)) != NULL) {
+ // find the escape character
if( 0==WriteConsole(handle, p, (DWORD)(q-p), &written, 0) ) // write up to the escape
WriteFile(handle, p, (DWORD)(q-p), &written, 0);
- if( q[1]!='[' )
- { // write the escape char (whatever purpose it has)
+ if (q[1]!='[') {
+ // write the escape char (whatever purpose it has)
if(0==WriteConsole(handle, q, 1, &written, 0) )
WriteFile(handle,q, 1, &written, 0);
- p=q+1; //and start searching again
- }
- else
- { // from here, we will skip the '\033['
+ p=q+1; //and start searching again
+ } else {
+ // from here, we will skip the '\033['
// we break at the first unprocessible position
// assuming regular text is starting there
uint8 numbers[16], numpoint=0;
@@ -231,84 +230,72 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
// skip escape and bracket
q=q+2;
- for(;;)
- {
- if( ISDIGIT(*q) )
- { // add number to number array, only accept 2digits, shift out the rest
+ for (;;) {
+ if (ISDIGIT(*q)) {
+ // add number to number array, only accept 2digits, shift out the rest
// so // \033[123456789m will become \033[89m
numbers[numpoint] = (numbers[numpoint]<<4) | (*q-'0');
++q;
// and next character
continue;
- }
- else if( *q == ';' )
- { // delimiter
- if(numpoint<sizeof(numbers)/sizeof(*numbers))
- { // go to next array position
+ } else if (*q == ';') {
+ // delimiter
+ if (numpoint < sizeof(numbers)/sizeof(*numbers)) {
+ // go to next array position
numpoint++;
- }
- else
- { // array is full, so we 'forget' the first value
+ } else {
+ // array is full, so we 'forget' the first value
memmove(numbers,numbers+1,sizeof(numbers)/sizeof(*numbers)-1);
numbers[sizeof(numbers)/sizeof(*numbers)-1]=0;
}
++q;
// and next number
continue;
- }
- else if( *q == 'm' )
- { // \033[#;...;#m - Set Graphics Rendition (SGR)
+ } else if (*q == 'm') {
+ // \033[#;...;#m - Set Graphics Rendition (SGR)
uint8 i;
- for(i=0; i<= numpoint; ++i)
- {
- if( 0x00 == (0xF0 & numbers[i]) )
- { // upper nibble 0
- if( 0 == numbers[i] )
- { // reset
+ for (i=0; i<= numpoint; ++i) {
+ if (0x00 == (0xF0 & numbers[i])) {
+ // upper nibble 0
+ if (0 == numbers[i]) {
+ // reset
info.wAttributes = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
- }
- else if( 1==numbers[i] )
- { // set foreground intensity
+ } else if (1 == numbers[i]) {
+ // set foreground intensity
info.wAttributes |= FOREGROUND_INTENSITY;
- }
- else if( 5==numbers[i] )
- { // set background intensity
+ } else if (5 == numbers[i]) {
+ // set background intensity
info.wAttributes |= BACKGROUND_INTENSITY;
- }
- else if( 7==numbers[i] )
- { // reverse colors (just xor them)
+ } else if (7 == numbers[i]) {
+ // reverse colors (just xor them)
info.wAttributes ^= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE |
- BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE;
+ BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE;
}
//case '2': // not existing
- //case '3': // blinking (not implemented)
- //case '4': // underline (not implemented)
+ //case '3': // blinking (not implemented)
+ //case '4': // underline (not implemented)
//case '6': // not existing
//case '8': // concealed (not implemented)
//case '9': // not existing
- }
- else if( 0x20 == (0xF0 & numbers[i]) )
- { // off
+ } else if (0x20 == (0xF0 & numbers[i])) {
+ // off
- if( 1==numbers[i] )
- { // set foreground intensity off
+ if (1 == numbers[i]) {
+ // set foreground intensity off
info.wAttributes &= ~FOREGROUND_INTENSITY;
- }
- else if( 5==numbers[i] )
- { // set background intensity off
+ } else if (5 == numbers[i]) {
+ // set background intensity off
info.wAttributes &= ~BACKGROUND_INTENSITY;
- }
- else if( 7==numbers[i] )
- { // reverse colors (just xor them)
+ } else if (7 == numbers[i]) {
+ // reverse colors (just xor them)
info.wAttributes ^= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE |
- BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE;
+ BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE;
}
- }
- else if( 0x30 == (0xF0 & numbers[i]) )
- { // foreground
+ } else if (0x30 == (0xF0 & numbers[i])) {
+ // foreground
uint8 num = numbers[i]&0x0F;
if(num==9) info.wAttributes |= FOREGROUND_INTENSITY;
- if(num>7) num=7; // set white for 37, 38 and 39
+ if(num>7) num=7; // set white for 37, 38 and 39
info.wAttributes &= ~(FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if( (num & 0x01)>0 ) // lowest bit set = red
info.wAttributes |= FOREGROUND_RED;
@@ -316,12 +303,11 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
info.wAttributes |= FOREGROUND_GREEN;
if( (num & 0x04)>0 ) // third bit set = blue
info.wAttributes |= FOREGROUND_BLUE;
- }
- else if( 0x40 == (0xF0 & numbers[i]) )
- { // background
+ } else if (0x40 == (0xF0 & numbers[i])) {
+ // background
uint8 num = numbers[i]&0x0F;
if(num==9) info.wAttributes |= BACKGROUND_INTENSITY;
- if(num>7) num=7; // set white for 47, 48 and 49
+ if(num>7) num=7; // set white for 47, 48 and 49
info.wAttributes &= ~(BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE);
if( (num & 0x01)>0 ) // lowest bit set = red
info.wAttributes |= BACKGROUND_RED;
@@ -333,61 +319,51 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
}
// set the attributes
SetConsoleTextAttribute(handle, info.wAttributes);
- }
- else if( *q=='J' )
- { // \033[#J - Erase Display (ED)
- // \033[0J - Clears the screen from cursor to end of display. The cursor position is unchanged.
- // \033[1J - Clears the screen from start to cursor. The cursor position is unchanged.
- // \033[2J - Clears the screen and moves the cursor to the home position (line 1, column 1).
+ } else if (*q=='J') {
+ // \033[#J - Erase Display (ED)
+ // \033[0J - Clears the screen from cursor to end of display. The cursor position is unchanged.
+ // \033[1J - Clears the screen from start to cursor. The cursor position is unchanged.
+ // \033[2J - Clears the screen and moves the cursor to the home position (line 1, column 1).
uint8 num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F);
int cnt;
DWORD tmp;
COORD origin = {0,0};
- if(num==1)
- { // chars from start up to and including cursor
+ if (num == 1) {
+ // chars from start up to and including cursor
cnt = info.dwSize.X * info.dwCursorPosition.Y + info.dwCursorPosition.X + 1;
- }
- else if(num==2)
- { // Number of chars on screen.
+ } else if (num == 2) {
+ // Number of chars on screen.
cnt = info.dwSize.X * info.dwSize.Y;
SetConsoleCursorPosition(handle, origin);
- }
- else// 0 and default
- { // number of chars from cursor to end
+ } else { /* 0 and default */
+ // number of chars from cursor to end
origin = info.dwCursorPosition;
cnt = info.dwSize.X * (info.dwSize.Y - info.dwCursorPosition.Y) - info.dwCursorPosition.X;
}
FillConsoleOutputAttribute(handle, info.wAttributes, cnt, origin, &tmp);
FillConsoleOutputCharacter(handle, ' ', cnt, origin, &tmp);
- }
- else if( *q=='K' )
- { // \033[K : clear line from actual position to end of the line
- // \033[0K - Clears all characters from the cursor position to the end of the line.
- // \033[1K - Clears all characters from start of line to the cursor position.
- // \033[2K - Clears all characters of the whole line.
+ } else if (*q=='K') {
+ // \033[K : clear line from actual position to end of the line
+ // \033[0K - Clears all characters from the cursor position to the end of the line.
+ // \033[1K - Clears all characters from start of line to the cursor position.
+ // \033[2K - Clears all characters of the whole line.
uint8 num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F);
COORD origin = {0,info.dwCursorPosition.Y}; //warning C4204
SHORT cnt;
DWORD tmp;
- if(num==1)
- {
+ if (num == 1) {
cnt = info.dwCursorPosition.X + 1;
- }
- else if(num==2)
- {
+ } else if (num == 2) {
cnt = info.dwSize.X;
- }
- else// 0 and default
- {
+ } else { /* 0 and default */
origin = info.dwCursorPosition;
cnt = info.dwSize.X - info.dwCursorPosition.X; // how many spaces until line is full
}
FillConsoleOutputAttribute(handle, info.wAttributes, cnt, origin, &tmp);
FillConsoleOutputCharacter(handle, ' ', cnt, origin, &tmp);
- }
- else if( *q == 'H' || *q == 'f' )
- { // \033[#;#H - Cursor Position (CUP)
+ } else if (*q == 'H' || *q == 'f') {
+ // \033[#;#H - Cursor Position (CUP)
// \033[#;#f - Horizontal & Vertical Position
// The first # specifies the line number, the second # specifies the column.
// The default for both is 1
@@ -397,59 +373,52 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
if( info.dwCursorPosition.X >= info.dwSize.X ) info.dwCursorPosition.Y = info.dwSize.X-1;
if( info.dwCursorPosition.Y >= info.dwSize.Y ) info.dwCursorPosition.Y = info.dwSize.Y-1;
SetConsoleCursorPosition(handle, info.dwCursorPosition);
- }
- else if( *q=='s' )
- { // \033[s - Save Cursor Position (SCP)
+ } else if (*q=='s') {
+ // \033[s - Save Cursor Position (SCP)
/* XXX Two streams are being used. Disabled to avoid inconsistency [flaviojs]
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(handle, &info);
saveposition = info.dwCursorPosition;
*/
- }
- else if( *q=='u' )
- { // \033[u - Restore cursor position (RCP)
+ } else if (*q=='u') {
+ // \033[u - Restore cursor position (RCP)
/* XXX Two streams are being used. Disabled to avoid inconsistency [flaviojs]
SetConsoleCursorPosition(handle, saveposition);
*/
- }
- else if( *q == 'A' )
- { // \033[#A - Cursor Up (CUU)
+ } else if (*q == 'A') {
+ // \033[#A - Cursor Up (CUU)
// Moves the cursor UP # number of lines
info.dwCursorPosition.Y -= (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F):1;
if( info.dwCursorPosition.Y < 0 )
info.dwCursorPosition.Y = 0;
SetConsoleCursorPosition(handle, info.dwCursorPosition);
- }
- else if( *q == 'B' )
- { // \033[#B - Cursor Down (CUD)
+ } else if (*q == 'B') {
+ // \033[#B - Cursor Down (CUD)
// Moves the cursor DOWN # number of lines
info.dwCursorPosition.Y += (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F):1;
if( info.dwCursorPosition.Y >= info.dwSize.Y )
info.dwCursorPosition.Y = info.dwSize.Y-1;
SetConsoleCursorPosition(handle, info.dwCursorPosition);
- }
- else if( *q == 'C' )
- { // \033[#C - Cursor Forward (CUF)
+ } else if (*q == 'C') {
+ // \033[#C - Cursor Forward (CUF)
// Moves the cursor RIGHT # number of columns
info.dwCursorPosition.X += (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F):1;
if( info.dwCursorPosition.X >= info.dwSize.X )
info.dwCursorPosition.X = info.dwSize.X-1;
SetConsoleCursorPosition(handle, info.dwCursorPosition);
- }
- else if( *q == 'D' )
- { // \033[#D - Cursor Backward (CUB)
+ } else if (*q == 'D') {
+ // \033[#D - Cursor Backward (CUB)
// Moves the cursor LEFT # number of columns
info.dwCursorPosition.X -= (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F):1;
if( info.dwCursorPosition.X < 0 )
info.dwCursorPosition.X = 0;
SetConsoleCursorPosition(handle, info.dwCursorPosition);
- }
- else if( *q == 'E' )
- { // \033[#E - Cursor Next Line (CNL)
+ } else if (*q == 'E') {
+ // \033[#E - Cursor Next Line (CNL)
// Moves the cursor down the indicated # of rows, to column 1
info.dwCursorPosition.Y += (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F):1;
info.dwCursorPosition.X = 0;
@@ -457,9 +426,8 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
if( info.dwCursorPosition.Y >= info.dwSize.Y )
info.dwCursorPosition.Y = info.dwSize.Y-1;
SetConsoleCursorPosition(handle, info.dwCursorPosition);
- }
- else if( *q == 'F' )
- { // \033[#F - Cursor Preceding Line (CPL)
+ } else if (*q == 'F') {
+ // \033[#F - Cursor Preceding Line (CPL)
// Moves the cursor up the indicated # of rows, to column 1.
info.dwCursorPosition.Y -= (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F):1;
info.dwCursorPosition.X = 0;
@@ -467,21 +435,18 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
if( info.dwCursorPosition.Y < 0 )
info.dwCursorPosition.Y = 0;
SetConsoleCursorPosition(handle, info.dwCursorPosition);
- }
- else if( *q == 'G' )
- { // \033[#G - Cursor Horizontal Absolute (CHA)
+ } else if (*q == 'G') {
+ // \033[#G - Cursor Horizontal Absolute (CHA)
// Moves the cursor to indicated column in current row.
info.dwCursorPosition.X = (numbers[numpoint])?(numbers[numpoint]>>4)*10+((numbers[numpoint]&0x0F)-1):0;
if( info.dwCursorPosition.X >= info.dwSize.X )
info.dwCursorPosition.X = info.dwSize.X-1;
SetConsoleCursorPosition(handle, info.dwCursorPosition);
- }
- else if( *q == 'L' || *q == 'M' || *q == '@' || *q == 'P')
- { // not implemented, just skip
- }
- else
- { // no number nor valid sequencer
+ } else if (*q == 'L' || *q == 'M' || *q == '@' || *q == 'P') {
+ // not implemented, just skip
+ } else {
+ // no number nor valid sequencer
// something is fishy, we break and give the current char free
--q;
}
@@ -491,7 +456,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
}// end while
}
}
- if (*p) // write the rest of the buffer
+ if (*p) // write the rest of the buffer
if( 0==WriteConsole(handle, p, (DWORD)strlen(p), &written, 0) )
WriteFile(handle, p, (DWORD)strlen(p), &written, 0);
FREEBUF(tempbuf);
@@ -519,7 +484,7 @@ int FPRINTF(HANDLE handle, const char *fmt, ...) {
#define is_console(file) (0!=isatty(fileno(file)))
//vprintf_without_ansiformats
-int VFPRINTF(FILE *file, const char *fmt, va_list argptr)
+int VFPRINTF(FILE *file, const char *fmt, va_list argptr)
{
char *p, *q;
NEWBUF(tempbuf); // temporary buffer
@@ -538,88 +503,70 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr)
// start with processing
p = BUFVAL(tempbuf);
- while ((q = strchr(p, 0x1b)) != NULL)
- { // find the escape character
+ while ((q = strchr(p, 0x1b)) != NULL) {
+ // find the escape character
fprintf(file, "%.*s", (int)(q-p), p); // write up to the escape
- if( q[1]!='[' )
- { // write the escape char (whatever purpose it has)
+ if (q[1]!='[') {
+ // write the escape char (whatever purpose it has)
fprintf(file, "%.*s", 1, q);
- p=q+1; //and start searching again
- }
- else
- { // from here, we will skip the '\033['
+ p=q+1; //and start searching again
+ } else {
+ // from here, we will skip the '\033['
// we break at the first unprocessible position
// assuming regular text is starting there
// skip escape and bracket
q=q+2;
- while(1)
- {
- if( ISDIGIT(*q) )
- {
+ while(1) {
+ if (ISDIGIT(*q)) {
++q;
// and next character
continue;
- }
- else if( *q == ';' )
- { // delimiter
+ } else if (*q == ';') {
+ // delimiter
++q;
// and next number
continue;
- }
- else if( *q == 'm' )
- { // \033[#;...;#m - Set Graphics Rendition (SGR)
+ } else if (*q == 'm') {
+ // \033[#;...;#m - Set Graphics Rendition (SGR)
// set the attributes
+ } else if (*q=='J') {
+ // \033[#J - Erase Display (ED)
}
- else if( *q=='J' )
- { // \033[#J - Erase Display (ED)
- }
- else if( *q=='K' )
- { // \033[K : clear line from actual position to end of the line
- }
- else if( *q == 'H' || *q == 'f' )
- { // \033[#;#H - Cursor Position (CUP)
+ else if (*q=='K') {
+ // \033[K : clear line from actual position to end of the line
+ } else if (*q == 'H' || *q == 'f') {
+ // \033[#;#H - Cursor Position (CUP)
// \033[#;#f - Horizontal & Vertical Position
- }
- else if( *q=='s' )
- { // \033[s - Save Cursor Position (SCP)
- }
- else if( *q=='u' )
- { // \033[u - Restore cursor position (RCP)
- }
- else if( *q == 'A' )
- { // \033[#A - Cursor Up (CUU)
+ } else if (*q=='s') {
+ // \033[s - Save Cursor Position (SCP)
+ } else if (*q=='u') {
+ // \033[u - Restore cursor position (RCP)
+ } else if (*q == 'A') {
+ // \033[#A - Cursor Up (CUU)
// Moves the cursor UP # number of lines
- }
- else if( *q == 'B' )
- { // \033[#B - Cursor Down (CUD)
+ } else if (*q == 'B') {
+ // \033[#B - Cursor Down (CUD)
// Moves the cursor DOWN # number of lines
- }
- else if( *q == 'C' )
- { // \033[#C - Cursor Forward (CUF)
+ } else if (*q == 'C') {
+ // \033[#C - Cursor Forward (CUF)
// Moves the cursor RIGHT # number of columns
- }
- else if( *q == 'D' )
- { // \033[#D - Cursor Backward (CUB)
+ } else if (*q == 'D') {
+ // \033[#D - Cursor Backward (CUB)
// Moves the cursor LEFT # number of columns
- }
- else if( *q == 'E' )
- { // \033[#E - Cursor Next Line (CNL)
+ } else if (*q == 'E') {
+ // \033[#E - Cursor Next Line (CNL)
// Moves the cursor down the indicated # of rows, to column 1
- }
- else if( *q == 'F' )
- { // \033[#F - Cursor Preceding Line (CPL)
+ } else if (*q == 'F') {
+ // \033[#F - Cursor Preceding Line (CPL)
// Moves the cursor up the indicated # of rows, to column 1.
- }
- else if( *q == 'G' )
- { // \033[#G - Cursor Horizontal Absolute (CHA)
+ } else if (*q == 'G') {
+ // \033[#G - Cursor Horizontal Absolute (CHA)
// Moves the cursor to indicated column in current row.
- }
- else if( *q == 'L' || *q == 'M' || *q == '@' || *q == 'P')
- { // not implemented, just skip
- }
- else
- { // no number nor valid sequencer
+ } else if (*q == 'L' || *q == 'M' || *q == '@' || *q == 'P') {
+ // not implemented, just skip
+ } else {
+ // no number nor valid sequencer
// something is fishy, we break and give the current char free
--q;
}
@@ -629,7 +576,7 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr)
}// end while
}
}
- if (*p) // write the rest of the buffer
+ if (*p) // write the rest of the buffer
fprintf(file, "%s", p);
FREEBUF(tempbuf);
return 0;
@@ -661,7 +608,7 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap)
#if defined(DEBUGLOGMAP) || defined(DEBUGLOGCHAR) || defined(DEBUGLOGLOGIN)
FILE *fp;
#endif
-
+
if (!string || *string == '\0') {
ShowError("Empty string passed to vShowMessage_().\n");
return 1;
@@ -700,8 +647,8 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap)
)
return 0; //Do not print it.
- if (timestamp_format[0] && flag != MSG_NONE)
- { //Display time format. [Skotlex]
+ if (timestamp_format[0] && flag != MSG_NONE) {
+ //Display time format. [Skotlex]
time_t t = time(NULL);
strftime(prefix, 80, timestamp_format, localtime(&t));
} else prefix[0]='\0';
@@ -738,8 +685,8 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap)
return 1;
}
- if (flag == MSG_ERROR || flag == MSG_FATALERROR || flag == MSG_SQL)
- { //Send Errors to StdErr [Skotlex]
+ if (flag == MSG_ERROR || flag == MSG_FATALERROR || flag == MSG_SQL) {
+ //Send Errors to StdErr [Skotlex]
FPRINTF(STDERR, "%s ", prefix);
va_copy(apcopy, ap);
VFPRINTF(STDERR, string, apcopy);
@@ -757,7 +704,7 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap)
#if defined(DEBUGLOGMAP) || defined(DEBUGLOGCHAR) || defined(DEBUGLOGLOGIN)
if(strlen(DEBUGLOGPATH) > 0) {
fp=fopen(DEBUGLOGPATH,"a");
- if (fp == NULL) {
+ if (fp == NULL) {
FPRINTF(STDERR, CL_RED"[ERROR]"CL_RESET": Could not open '"CL_WHITE"%s"CL_RESET"', access denied.\n", DEBUGLOGPATH);
FFLUSH(STDERR);
} else {
@@ -779,7 +726,7 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap)
void ClearScreen(void)
{
#ifndef _WIN32
- ShowMessage(CL_CLS); // to prevent empty string passed messages
+ ShowMessage(CL_CLS); // to prevent empty string passed messages
#endif
}
int ShowMessage_(enum msg_type flag, const char *string, ...) __attribute__((format(printf, 2, 3)));
diff --git a/src/common/socket.c b/src/common/socket.c
index 0c48c7c46..09521c312 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -29,8 +29,12 @@
# include <errno.h>
# include <net/if.h>
# include <netdb.h>
+#if defined __linux__ || defined __linux
+# include <linux/tcp.h>
+#else
# include <netinet/in.h>
# include <netinet/tcp.h>
+#endif
# include <sys/ioctl.h>
# include <sys/socket.h>
# include <sys/time.h>
@@ -274,7 +278,7 @@ const char* error_msg(void)
}
/*======================================
- * CORE : Default processing functions
+ * CORE : Default processing functions
*--------------------------------------*/
int null_recv(int fd) { return 0; }
int null_send(int fd) { return 0; }
@@ -289,7 +293,7 @@ void set_defaultparse(ParseFunc defaultparse)
/*======================================
- * CORE : Socket options
+ * CORE : Socket options
*--------------------------------------*/
void set_nonblocking(int fd, unsigned long yes)
{
@@ -302,7 +306,7 @@ void set_nonblocking(int fd, unsigned long yes)
void setsocketopts(int fd, struct hSockOpt *opt) {
int yes = 1; // reuse fix
struct linger lopt;
-
+
#if !defined(WIN32)
// set SO_REAUSEADDR to true, unix only. on windows this option causes
// the previous owner of the socket to give up, which is not desirable
@@ -319,24 +323,31 @@ void setsocketopts(int fd, struct hSockOpt *opt) {
if( opt && opt->setTimeo ) {
struct timeval timeout;
-
+
timeout.tv_sec = 5;
timeout.tv_usec = 0;
-
+
sSetsockopt(fd,SOL_SOCKET,SO_RCVTIMEO,(char *)&timeout,sizeof(timeout));
sSetsockopt(fd,SOL_SOCKET,SO_SNDTIMEO,(char *)&timeout,sizeof(timeout));
}
-
+
// force the socket into no-wait, graceful-close mode (should be the default, but better make sure)
//(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/closesocket_2.asp)
lopt.l_onoff = 0; // SO_DONTLINGER
lopt.l_linger = 0; // Do not care
if( sSetsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&lopt, sizeof(lopt)) )
ShowWarning("setsocketopts: Unable to set SO_LINGER mode for connection #%d!\n", fd);
+
+#ifdef TCP_THIN_LINEAR_TIMEOUTS
+ setsockopt(fd, IPPROTO_TCP, TCP_THIN_LINEAR_TIMEOUTS, &yes, sizeof yes);
+#endif
+#ifdef TCP_THIN_DUPACK
+ setsockopt(fd, IPPROTO_TCP, TCP_THIN_DUPACK, &yes, sizeof yes);
+#endif
}
/*======================================
- * CORE : Socket Sub Function
+ * CORE : Socket Sub Function
*--------------------------------------*/
void set_eof(int fd)
{
@@ -448,7 +459,7 @@ void flush_fifos(void)
}
/*======================================
- * CORE : Connection functions
+ * CORE : Connection functions
*--------------------------------------*/
int connect_client(int listen_fd) {
int fd;
@@ -659,19 +670,19 @@ int realloc_writefifo(int fd, size_t addition)
if( !sockt->session_isValid(fd) ) // might not happen
return 0;
- if( session[fd]->wdata_size + addition > session[fd]->max_wdata )
- { // grow rule; grow in multiples of WFIFO_SIZE
+ if (session[fd]->wdata_size + addition > session[fd]->max_wdata) {
+ // grow rule; grow in multiples of WFIFO_SIZE
newsize = WFIFO_SIZE;
while( session[fd]->wdata_size + addition > newsize ) newsize += WFIFO_SIZE;
- }
- else
- if( session[fd]->max_wdata >= (size_t)2*(session[fd]->flag.server?FIFOSIZE_SERVERLINK:WFIFO_SIZE)
- && (session[fd]->wdata_size+addition)*4 < session[fd]->max_wdata )
- { // shrink rule, shrink by 2 when only a quarter of the fifo is used, don't shrink below nominal size.
+ } else if (session[fd]->max_wdata >= (size_t)2*(session[fd]->flag.server?FIFOSIZE_SERVERLINK:WFIFO_SIZE)
+ && (session[fd]->wdata_size+addition)*4 < session[fd]->max_wdata
+ ) {
+ // shrink rule, shrink by 2 when only a quarter of the fifo is used, don't shrink below nominal size.
newsize = session[fd]->max_wdata / 2;
- }
- else // no change
+ } else {
+ // no change
return 0;
+ }
RECREATE(session[fd]->wdata, unsigned char, newsize);
session[fd]->max_wdata = newsize;
@@ -682,7 +693,7 @@ int realloc_writefifo(int fd, size_t addition)
/// advance the RFIFO cursor (marking 'len' bytes as processed)
int RFIFOSKIP(int fd, size_t len)
{
- struct socket_data *s;
+ struct socket_data *s;
if ( !sockt->session_isActive(fd) )
return 0;
@@ -711,8 +722,8 @@ int WFIFOSET(int fd, size_t len)
return 0;
// we have written len bytes to the buffer already before calling WFIFOSET
- if(s->wdata_size+len > s->max_wdata)
- { // actually there was a buffer overflow already
+ if (s->wdata_size+len > s->max_wdata) {
+ // actually there was a buffer overflow already
uint32 ip = s->client_addr;
ShowFatalError("WFIFOSET: Write Buffer Overflow. Connection %d (%d.%d.%d.%d) has written %u bytes on a %u/%u bytes buffer.\n", fd, CONVIP(ip), (unsigned int)len, (unsigned int)s->wdata_size, (unsigned int)s->max_wdata);
ShowDebug("Likely command that caused it: 0x%x\n", (*(uint16*)(s->wdata + s->wdata_size)));
@@ -744,13 +755,6 @@ int WFIFOSET(int fd, size_t len)
return 0;
}
- if (s->wdata_size+len > WFIFO_MAX) { // reached maximum write fifo size
- ShowError("WFIFOSET: Maximum write buffer size for client connection %d exceeded, most likely caused by packet 0x%04x (len=%"PRIuS", ip=%u.%u.%u.%u).\n",
- fd, WFIFOW(fd,0), len, CONVIP(s->client_addr));
- set_eof(fd);
- return 0;
- }
-
}
s->wdata_size += len;
#ifdef SHOW_SERVER_STATS
@@ -846,8 +850,8 @@ int do_sockets(int next)
if(session[i]->wdata_size)
session[i]->func_send(i);
- if(session[i]->flag.eof) //func_send can't free a session, this is safe.
- { //Finally, even if there is no data to parse, connections signaled eof should be closed, so we call parse_func [Skotlex]
+ if (session[i]->flag.eof) { //func_send can't free a session, this is safe.
+ //Finally, even if there is no data to parse, connections signaled eof should be closed, so we call parse_func [Skotlex]
session[i]->func_parse(i); //This should close the session immediately.
}
}
@@ -877,7 +881,7 @@ int do_sockets(int next)
if(!session[i])
continue;
-
+
RFIFOFLUSH(i);
// after parse, check client's RFIFO size to know if there is an invalid packet (too big and not parsed)
if (session[i]->rdata_size == session[i]->max_rdata) {
@@ -890,7 +894,7 @@ int do_sockets(int next)
if (sockt->last_tick != socket_data_last_tick)
{
char buf[1024];
-
+
sprintf(buf, "In: %.03f kB/s (%.03f kB/s, Q: %.03f kB) | Out: %.03f kB/s (%.03f kB/s, Q: %.03f kB) | RAM: %.03f MB", socket_data_i/1024., socket_data_ci/1024., socket_data_qi/1024., socket_data_o/1024., socket_data_co/1024., socket_data_qo/1024., iMalloc->usage()/1024.);
#ifdef _WIN32
SetConsoleTitle(buf);
@@ -1239,7 +1243,7 @@ void socket_final(void)
aFree(session[0]->rdata);
aFree(session[0]->wdata);
aFree(session[0]);
-
+
aFree(session);
}
@@ -1403,7 +1407,7 @@ void socket_init(void)
#endif
CREATE(session, struct socket_data *, FD_SETSIZE);
-
+
socket_config_read(SOCKET_CONF_FILENAME);
// initialize last send-receive tick
@@ -1421,7 +1425,7 @@ void socket_init(void)
#endif
ShowInfo("Server supports up to '"CL_WHITE"%"PRId64""CL_RESET"' concurrent connections.\n", rlim_cur);
-
+
/* Hercules Plugin Manager */
HPM->share(session,"session");
}
@@ -1505,11 +1509,11 @@ void socket_datasync(int fd, bool send) {
WFIFOW(fd, 0) = 0x2b0a;
WFIFOW(fd, 2) = p_len;
-
+
for( i = 0; i < alen; i++ ) {
WFIFOL(fd, 4 + ( i * 4 ) ) = data_list[i].length;
}
-
+
WFIFOSET(fd, p_len);
} else {
for( i = 0; i < alen; i++ ) {
@@ -1609,7 +1613,7 @@ void send_shortlist_do_sends()
void socket_defaults(void) {
sockt = &sockt_s;
-
+
sockt->fd_max = 0;
/* */
sockt->stall_time = 60;
diff --git a/src/common/socket.h b/src/common/socket.h
index 42b0efe3b..b9c562a29 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -97,7 +97,7 @@ struct socket_data {
ParseFunc func_parse;
void* session_data; // stores application-specific data related to the session
-
+
struct HPluginData **hdata;
unsigned int hdatac;
};
diff --git a/src/common/spinlock.h b/src/common/spinlock.h
index bde36b8e5..85a78ed33 100644
--- a/src/common/spinlock.h
+++ b/src/common/spinlock.h
@@ -13,7 +13,7 @@
// For more information, see LICENCE in the main folder
//
//
-
+
#include "../common/atomic.h"
#include "../common/cbasetypes.h"
#include "../common/thread.h"
@@ -33,7 +33,7 @@ typedef struct __declspec( align(64) ) SPIN_LOCK{
typedef struct SPIN_LOCK{
volatile int32 lock;
volatile int32 nest; // nesting level.
-
+
volatile int32 sync_lock;
} __attribute__((aligned(64))) SPIN_LOCK;
#endif
@@ -56,7 +56,7 @@ static forceinline void FinalizeSpinLock(SPIN_LOCK *lck){
static forceinline void EnterSpinLock(SPIN_LOCK *lck){
int tid = rathread_get_tid();
-
+
// Get Sync Lock && Check if the requester thread already owns the lock.
// if it owns, increase nesting level
getsynclock(&lck->sync_lock);
@@ -67,18 +67,14 @@ static forceinline void EnterSpinLock(SPIN_LOCK *lck){
}
// drop sync lock
dropsynclock(&lck->sync_lock);
-
-
+
// Spin until we've got it !
while(1){
-
- if(InterlockedCompareExchange(&lck->lock, tid, 0) == 0){
-
- InterlockedIncrement(&lck->nest);
- return; // Got Lock
- }
-
- rathread_yield(); // Force ctxswitch to another thread.
+ if(InterlockedCompareExchange(&lck->lock, tid, 0) == 0){
+ InterlockedIncrement(&lck->nest);
+ return; // Got Lock
+ }
+ rathread_yield(); // Force ctxswitch to another thread.
}
}
@@ -88,12 +84,12 @@ static forceinline void LeaveSpinLock(SPIN_LOCK *lck){
int tid = rathread_get_tid();
getsynclock(&lck->sync_lock);
-
+
if(InterlockedCompareExchange(&lck->lock, tid, tid) == tid){ // this thread owns the lock.
if(InterlockedDecrement(&lck->nest) == 0)
InterlockedExchange(&lck->lock, 0); // Unlock!
}
-
+
dropsynclock(&lck->sync_lock);
}
diff --git a/src/common/sql.c b/src/common/sql.c
index 8ae9d3cdb..7f89e9828 100644
--- a/src/common/sql.c
+++ b/src/common/sql.c
@@ -25,6 +25,8 @@ void hercules_mysql_error_handler(unsigned int ecode);
int mysql_reconnect_type;
unsigned int mysql_reconnect_count;
+struct sql_interface sql_s;
+
/// Sql handle
struct Sql {
StringBuf buf;
@@ -1002,10 +1004,10 @@ void Sql_HerculesUpdateCheck(Sql* self) {
FILE* ifp;/* index fp */
unsigned int performed = 0;
StringBuf buf;
-
+
if( self == NULL )
return;/* return silently, build has no mysql connection */
-
+
if( !( ifp = fopen("sql-files/upgrades/index.txt", "r") ) ) {
ShowError("SQL upgrade index was not found!\n");
return;
@@ -1053,7 +1055,7 @@ void Sql_HerculesUpdateCheck(Sql* self) {
ShowMessage("%s",StrBuf->Value(&buf));
ShowSQL("To manually skip, type: 'sql update skip <file name>'\n");
}
-
+
StrBuf->Destroy(&buf);
}
@@ -1061,21 +1063,21 @@ void Sql_HerculesUpdateSkip(Sql* self,const char *filename) {
char path[41];// "sql-files/upgrades/" (19) + "yyyy-mm-dd--hh-mm" (17) + ".sql" (4) + 1
char timestamp[11];// "1360186680" (10) + 1
FILE* ifp;/* index fp */
-
+
if( !self ) {
ShowError("SQL not hooked!\n");
return;
}
-
+
snprintf(path,41,"sql-files/upgrades/%s",filename);
-
+
if( !( ifp = fopen(path, "r") ) ) {
ShowError("Upgrade file '%s' was not found!\n",filename);
return;
}
-
+
fseek (ifp,1,SEEK_SET);/* woo. skip the # */
-
+
if( fgets(timestamp,sizeof(timestamp),ifp) ) {
unsigned int timestampui = (unsigned int)atol(timestamp);
if( SQL_ERROR == SQL->Query(self, "SELECT 1 FROM `sql_updates` WHERE `timestamp` = '%u' LIMIT 1", timestampui) )
diff --git a/src/common/sql.h b/src/common/sql.h
index b1f1f41c3..9a79b3f33 100644
--- a/src/common/sql.h
+++ b/src/common/sql.h
@@ -267,7 +267,7 @@ struct sql_interface {
void (*StmtShowDebug_)(SqlStmt* self, const char* debug_file, const unsigned long debug_line);
-} sql_s;
+};
struct sql_interface *SQL;
diff --git a/src/common/strlib.c b/src/common/strlib.c
index 592390770..8b63b4161 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -18,6 +18,10 @@
#define J_MAX_MALLOC_SIZE 65535
+struct strlib_interface strlib_s;
+struct stringbuf_interface stringbuf_s;
+struct sv_interface sv_s;
+
// escapes a string in-place (' -> \' , \ -> \\ , % -> _)
char* jstrescape (char* pt) {
//copy from here
@@ -58,11 +62,12 @@ char* jstrescapecpy (char* pt, const char* spt)
//a escape character is found, the target's final length increases! [Skotlex]
int i =0, j=0;
- if (!spt) { //Return an empty string [Skotlex]
+ if (!spt) {
+ //Return an empty string [Skotlex]
pt[0] = '\0';
return &pt[0];
}
-
+
while (spt[i] != '\0') {
switch (spt[i]) {
case '\'':
@@ -248,7 +253,8 @@ char* strtok_r_(char *s1, const char *s2, char **lasts) {
// for NetBSD 5.x and possibly some Solaris versions.
#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN)
/* Find the length of STRING, but scan at most MAXLEN characters.
- If no '\0' terminator is found in that many characters, return MAXLEN. */
+ * If no '\0' terminator is found in that many characters, return MAXLEN.
+ */
size_t strnlen(const char* string, size_t maxlen) {
const char* end = (const char*)memchr(string, '\0', maxlen);
return end ? (size_t) (end - string) : maxlen;
@@ -1126,18 +1132,19 @@ void strlib_defaults(void) {
sv = &sv_s;
/* link~u! */
strlib->jstrescape = jstrescape;
+ strlib->jstrescapecpy = jstrescapecpy;
strlib->jmemescapecpy = jmemescapecpy;
strlib->remove_control_chars = remove_control_chars;
strlib->trim = trim;
strlib->normalize_name = normalize_name;
strlib->stristr = stristr;
-
+
#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN)
strlib->strnlen = strnlen;
#else
strlib->strnlen = NULL;
#endif
-
+
#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200
strlib->strtoull = strtoull;
#else
@@ -1150,7 +1157,7 @@ void strlib_defaults(void) {
strlib->safesnprintf = safesnprintf;
strlib->strline = strline;
strlib->bin2hex = bin2hex;
-
+
StrBuf->Malloc = StringBuf_Malloc;
StrBuf->Init = StringBuf_Init;
StrBuf->Printf = StringBuf_Printf;
@@ -1162,7 +1169,7 @@ void strlib_defaults(void) {
StrBuf->Clear = StringBuf_Clear;
StrBuf->Destroy = StringBuf_Destroy;
StrBuf->Free = StringBuf_Free;
-
+
sv->parse_next = sv_parse_next;
sv->parse = sv_parse;
sv->split = sv_split;
diff --git a/src/common/strlib.h b/src/common/strlib.h
index 00a588772..0c596cb8f 100644
--- a/src/common/strlib.h
+++ b/src/common/strlib.h
@@ -63,36 +63,36 @@ struct strlib_interface {
char *(*trim) (char* str);
char *(*normalize_name) (char* str,const char* delims);
const char *(*stristr) (const char *haystack, const char *needle);
-
+
/* only used when '!(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN)', needs to be defined at all times however */
size_t (*strnlen) (const char* string, size_t maxlen);
/* only used when 'defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200', needs to be defined at all times however */
uint64 (*strtoull) (const char* str, char** endptr, int base);
-
+
int (*e_mail_check) (char* email);
int (*config_switch) (const char* str);
-
+
/// strncpy that always null-terminates the string
char *(*safestrncpy) (char* dst, const char* src, size_t n);
-
+
/// doesn't crash on null pointer
size_t (*safestrnlen) (const char* string, size_t maxlen);
-
+
/// Works like snprintf, but always null-terminates the buffer.
/// Returns the size of the string (without null-terminator)
/// or -1 if the buffer is too small.
int (*safesnprintf) (char *buf, size_t sz, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
-
+
/// Returns the line of the target position in the string.
/// Lines start at 1.
int (*strline) (const char* str, size_t pos);
-
+
/// Produces the hexadecimal representation of the given input.
/// The output buffer must be at least count*2+1 in size.
/// Returns true on success, false on failure.
bool (*bin2hex) (char* output, unsigned char* input, size_t count);
-} strlib_s;
+};
struct strlib_interface *strlib;
@@ -108,7 +108,7 @@ struct stringbuf_interface {
void (*Clear) (StringBuf* self);
void (*Destroy) (StringBuf* self);
void (*Free) (StringBuf* self);
-} stringbuf_s;
+};
struct stringbuf_interface *StrBuf;
@@ -119,14 +119,14 @@ struct sv_interface {
/// @param svstate Parse state
/// @return 1 if a field was parsed, 0 if done, -1 on error.
int (*parse_next) (struct s_svstate* svstate);
-
+
/// Parses a delim-separated string.
/// Starts parsing at startoff and fills the pos array with position pairs.
/// out_pos[0] and out_pos[1] are the start and end of line.
/// Other position pairs are the start and end of fields.
/// Returns the number of fields found or -1 if an error occurs.
int (*parse) (const char* str, int len, int startoff, char delim, int* out_pos, int npos, enum e_svopt opt);
-
+
/// Splits a delim-separated string.
/// WARNING: this function modifies the input string
/// Starts splitting at startoff and fills the out_fields array.
@@ -134,25 +134,25 @@ struct sv_interface {
/// Other entries are the start of fields (null-terminated).
/// Returns the number of fields found or -1 if an error occurs.
int (*split) (char* str, int len, int startoff, char delim, char** out_fields, int nfields, enum e_svopt opt);
-
+
/// Escapes src to out_dest according to the format of the C compiler.
/// Returns the length of the escaped string.
/// out_dest should be len*4+1 in size.
size_t (*escape_c) (char* out_dest, const char* src, size_t len, const char* escapes);
-
+
/// Unescapes src to out_dest according to the format of the C compiler.
/// Returns the length of the unescaped string.
/// out_dest should be len+1 in size and can be the same buffer as src.
size_t (*unescape_c) (char* out_dest, const char* src, size_t len);
-
+
/// Skips a C escape sequence (starting with '\\').
const char* (*skip_escaped_c) (const char* p);
-
+
/// Opens and parses a file containing delim-separated columns, feeding them to the specified callback function row by row.
/// Tracks the progress of the operation (current line number, number of successfully processed rows).
/// Returns 'true' if it was able to process the specified file, or 'false' if it could not be read.
bool (*readdb) (const char* directory, const char* filename, char delim, int mincols, int maxcols, int maxrows, bool (*parseproc)(char* fields[], int columns, int current));
-} sv_s;
+};
struct sv_interface *sv;
diff --git a/src/common/thread.c b/src/common/thread.c
index 1d0285302..a00bd6333 100644
--- a/src/common/thread.c
+++ b/src/common/thread.c
@@ -36,7 +36,7 @@
struct rAthread {
unsigned int myID;
-
+
RATHREAD_PRIO prio;
rAthreadProc proc;
void *param;
@@ -62,7 +62,7 @@ static struct rAthread l_threads[RA_THREADS_MAX];
void rathread_init(void) {
register unsigned int i;
memset(&l_threads, 0x00, RA_THREADS_MAX * sizeof(struct rAthread) );
-
+
for(i = 0; i < RA_THREADS_MAX; i++){
l_threads[i].myID = i;
}
@@ -80,7 +80,7 @@ void rathread_init(void) {
void rathread_final(void) {
register unsigned int i;
-
+
// Unterminated Threads Left?
// Shouldn't happen ..
// Kill 'em all!
@@ -91,8 +91,7 @@ void rathread_final(void) {
rathread_destroy(&l_threads[i]);
}
}
-
-
+
}//end: rathread_final()
@@ -112,7 +111,7 @@ static void *raThreadMainRedirector( void *p ){
sigset_t set; // on Posix Thread platforms
#endif
void *ret;
-
+
// Update myID @ TLS to right id.
#ifdef HAS_TLS
g_rathread_ID = ((rAthread*)p)->myID;
@@ -129,7 +128,7 @@ static void *raThreadMainRedirector( void *p ){
sigaddset(&set, SIGPIPE);
pthread_sigmask(SIG_BLOCK, &set, NULL);
-
+
#endif
@@ -181,14 +180,12 @@ rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack
break;
}
}
-
+
if(handle == NULL){
ShowError("rAthread: cannot create new thread (entryPoint: %p) - no free thread slot found!", entryPoint);
return NULL;
}
-
-
-
+
handle->proc = entryPoint;
handle->param = param;
@@ -197,7 +194,7 @@ rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack
#else
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, szStack);
-
+
if(pthread_create(&handle->hThread, &attr, raThreadMainRedirector, (void*)handle) != 0){
handle->proc = NULL;
handle->param = NULL;
@@ -207,7 +204,7 @@ rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack
#endif
rathread_prio_set( handle, prio );
-
+
return handle;
}//end: rathread_createEx
@@ -220,10 +217,9 @@ void rathread_destroy(rAthread *handle) {
}
#else
if( pthread_cancel( handle->hThread ) == 0){
-
// We have to join it, otherwise pthread wont re-cycle its internal resources assoc. with this thread.
pthread_join( handle->hThread, NULL );
-
+
// Tell our manager to release resources ;)
rat_thread_terminated(handle);
}
@@ -233,7 +229,7 @@ void rathread_destroy(rAthread *handle) {
rAthread *rathread_self(void) {
#ifdef HAS_TLS
rAthread *handle = &l_threads[g_rathread_ID];
-
+
if(handle->proc != NULL) // entry point set, so its used!
return handle;
#else
@@ -247,14 +243,13 @@ rAthread *rathread_self(void) {
pthread_t hSelf;
hSelf = pthread_self();
#endif
-
+
for(i = 0; i < RA_THREADS_MAX; i++){
if(l_threads[i].hThread == hSelf && l_threads[i].proc != NULL)
return &l_threads[i];
}
-
#endif
-
+
return NULL;
}//end: rathread_self()
@@ -270,14 +265,12 @@ int rathread_get_tid(void) {
#else
return (intptr_t)pthread_self();
#endif
-
#endif
-
+
}//end: rathread_get_tid()
bool rathread_wait(rAthread *handle, void **out_exitCode) {
-
// Hint:
// no thread data cleanup routine call here!
// its managed by the callProxy itself..
diff --git a/src/common/thread.h b/src/common/thread.h
index c7582366d..f00e7290d 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -104,8 +104,8 @@ RATHREAD_PRIO rathread_prio_get(rAthread *handle);
* Tells the OS scheduler to yield the execution of the calling thread
*
* @note: this will not "pause" the thread,
- * it just allows the OS to spent the remaining time
- * of the slice to another thread.
+ * it just allows the OS to spend the remaining time
+ * of the slice to another thread.
*/
void rathread_yield(void);
diff --git a/src/common/timer.c b/src/common/timer.c
index 5d0a45b99..f2bfa98b3 100644
--- a/src/common/timer.c
+++ b/src/common/timer.c
@@ -59,7 +59,7 @@ time_t start_time;
/*----------------------------
- * Timer debugging
+ * Timer debugging
*----------------------------*/
struct timer_func_list {
struct timer_func_list* next;
@@ -101,31 +101,31 @@ char* search_timer_func_list(TimerFunc func)
}
/*----------------------------
- * Get tick time
+ * Get tick time
*----------------------------*/
#if defined(ENABLE_RDTSC)
static uint64 RDTSC_BEGINTICK = 0, RDTSC_CLOCK = 0;
static __inline uint64 rdtsc_(void) {
- register union{
- uint64 qw;
- uint32 dw[2];
+ register union {
+ uint64 qw;
+ uint32 dw[2];
} t;
asm volatile("rdtsc":"=a"(t.dw[0]), "=d"(t.dw[1]) );
-
+
return t.qw;
}
static void rdtsc_calibrate(void){
uint64 t1, t2;
int32 i;
-
+
ShowStatus("Calibrating Timer Source, please wait... ");
-
+
RDTSC_CLOCK = 0;
-
+
for(i = 0; i < 5; i++){
t1 = rdtsc_();
usleep(1000000); //1000 MS
@@ -133,9 +133,9 @@ static void rdtsc_calibrate(void){
RDTSC_CLOCK += (t2 - t1) / 1000;
}
RDTSC_CLOCK /= 5;
-
+
RDTSC_BEGINTICK = rdtsc_();
-
+
ShowMessage(" done. (Frequency: %u Mhz)\n", (uint32)(RDTSC_CLOCK/1000) );
}
@@ -233,7 +233,7 @@ int64 timer_gettick(void) {
//////////////////////////////////////////////////////////////////////////
/*======================================
- * CORE : Timer Heap
+ * CORE : Timer Heap
*--------------------------------------*/
/// Adds a timer to the timer_heap
@@ -243,7 +243,7 @@ static void push_timer_heap(int tid) {
}
/*==========================
- * Timer Management
+ * Timer Management
*--------------------------*/
/// Returns a free timer id.
@@ -281,7 +281,7 @@ static int acquire_timer(void) {
/// Returns the timer's id.
int timer_add(int64 tick, TimerFunc func, int id, intptr_t data) {
int tid;
-
+
tid = acquire_timer();
timer_data[tid].tick = tick;
timer_data[tid].func = func;
@@ -304,7 +304,7 @@ int timer_add_interval(int64 tick, TimerFunc func, int id, intptr_t data, int in
tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, timer->gettick()));
return INVALID_TIMER;
}
-
+
tid = acquire_timer();
timer_data[tid].tick = tick;
timer_data[tid].func = func;
@@ -351,7 +351,7 @@ int64 timer_addtick(int tid, int64 tick) {
/// Returns the new tick value, or -1 if it fails.
int64 timer_settick(int tid, int64 tick) {
size_t i;
-
+
// search timer position
ARR_FIND(0, BHEAP_LENGTH(timer_heap), i, BHEAP_DATA(timer_heap)[i] == tid);
if( i == BHEAP_LENGTH(timer_heap) ) {
@@ -444,8 +444,8 @@ void timer_final(void) {
struct timer_func_list *next;
for( tfl=tfl_root; tfl != NULL; tfl = next ) {
- next = tfl->next; // copy next pointer
- aFree(tfl->name); // free structures
+ next = tfl->next; // copy next pointer
+ aFree(tfl->name); // free structures
aFree(tfl);
}
diff --git a/src/common/utils.c b/src/common/utils.c
index 79232b25c..d73aab066 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -92,7 +92,8 @@ void ShowDump(const void *buffer, size_t length) {
#ifdef WIN32
static char* checkpath(char *path, const char *srcpath)
-{ // just make sure the char*path is not const
+{
+ // just make sure the char*path is not const
char *p=path;
if(NULL!=path && NULL!=srcpath)
while(*srcpath) {
@@ -112,16 +113,15 @@ void findfile(const char *p, const char *pat, void (func)(const char*))
WIN32_FIND_DATAA FindFileData;
HANDLE hFind;
char tmppath[MAX_PATH+1];
-
const char *path = (p ==NULL)? "." : p;
const char *pattern = (pat==NULL)? "" : pat;
-
+
checkpath(tmppath,path);
if( PATHSEP != tmppath[strlen(tmppath)-1])
strcat(tmppath, "\\*");
else
strcat(tmppath, "*");
-
+
hFind = FindFirstFileA(tmppath, &FindFileData);
if (hFind != INVALID_HANDLE_VALUE)
{
@@ -153,7 +153,8 @@ void findfile(const char *p, const char *pat, void (func)(const char*))
#define MAX_DIR_PATH 2048
static char* checkpath(char *path, const char*srcpath)
-{ // just make sure the char*path is not const
+{
+ // just make sure the char*path is not const
char *p=path;
if(NULL!=path && NULL!=srcpath)
while(*srcpath) {
@@ -170,9 +171,9 @@ static char* checkpath(char *path, const char*srcpath)
void findfile(const char *p, const char *pat, void (func)(const char*))
{
- DIR* dir; // pointer to the scanned directory.
- struct dirent* entry; // pointer to one directory entry.
- struct stat dir_stat; // used by stat().
+ DIR* dir; ///< pointer to the scanned directory.
+ struct dirent* entry; ///< pointer to one directory entry.
+ struct stat dir_stat; ///< used by stat().
char tmppath[MAX_DIR_PATH+1];
char path[MAX_DIR_PATH+1]= ".";
const char *pattern = (pat==NULL)? "" : pat;
@@ -289,17 +290,17 @@ int32 MakeLongLE(int32 val)
// Reads an uint16 in little-endian from the buffer
uint16 GetUShort(const unsigned char* buf)
{
- return ( ((uint16)(buf[0])) )
- |( ((uint16)(buf[1])) << 0x08 );
+ return ( ((uint16)(buf[0])) )
+ | ( ((uint16)(buf[1])) << 0x08 );
}
// Reads an uint32 in little-endian from the buffer
uint32 GetULong(const unsigned char* buf)
{
- return ( ((uint32)(buf[0])) )
- |( ((uint32)(buf[1])) << 0x08 )
- |( ((uint32)(buf[2])) << 0x10 )
- |( ((uint32)(buf[3])) << 0x18 );
+ return ( ((uint32)(buf[0])) )
+ | ( ((uint32)(buf[1])) << 0x08 )
+ | ( ((uint32)(buf[2])) << 0x10 )
+ | ( ((uint32)(buf[3])) << 0x18 );
}
// Reads an int32 in little-endian from the buffer
@@ -356,15 +357,15 @@ bool HCache_check(const char *file) {
time_t rtime;
if( !(first = fopen(file,"rb")) )
- return false;
+ return false;
if( file[0] == '.' && file[1] == '/' )
- file += 2;
+ file += 2;
else if( file[0] == '.' )
- file++;
-
+ file++;
+
snprintf(s_path, 255, "./cache/%s", file);
-
+
if( !(second = fopen(s_path,"rb")) ) {
fclose(first);
return false;
@@ -375,34 +376,34 @@ bool HCache_check(const char *file) {
fclose(second);
return false;
}
-
+
fstat(fileno(first), &bufa);
fstat(fileno(second), &bufb);
-
+
fclose(first);
fclose(second);
-
+
if( bufa.st_mtime > bufb.st_mtime )
return false;
-
+
return true;
}
FILE *HCache_open(const char *file, const char *opt) {
FILE *first;
char s_path[255];
-
+
if( file[0] == '.' && file[1] == '/' )
file += 2;
else if( file[0] == '.' )
file++;
-
+
snprintf(s_path, 255, "./cache/%s", file);
-
+
if( !(first = fopen(s_path,opt)) ) {
return NULL;
}
-
+
if( opt[0] != 'r' ) {
char dT[1];/* 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */
dT[0] = HCACHE_KEY;
@@ -410,19 +411,19 @@ FILE *HCache_open(const char *file, const char *opt) {
hwrite(&HCache->recompile_time,sizeof(HCache->recompile_time),1,first);
}
fseek(first, 20, SEEK_SET);/* skip first 20, might wanna store something else later */
-
+
return first;
}
void HCache_init(void) {
FILE *server;
-
+
if( (server = fopen(SERVER_NAME,"rb")) ) {
struct stat buf;
-
+
fstat(fileno(server), &buf);
HCache->recompile_time = buf.st_mtime;
fclose(server);
-
+
HCache->enabled = true;
} else
ShowWarning("Unable to open '%s', caching capabilities have been disabled!\n",SERVER_NAME);
@@ -437,11 +438,10 @@ size_t hwrite(const void * ptr, size_t size, size_t count, FILE * stream) {
}
void HCache_defaults(void) {
-
HCache = &HCache_s;
HCache->init = HCache_init;
-
+
HCache->check = HCache_check;
HCache->open = HCache_open;
HCache->recompile_time = 0;
diff --git a/src/common/winapi.h b/src/common/winapi.h
index a8a38f30e..f53d9cbbd 100644
--- a/src/common/winapi.h
+++ b/src/common/winapi.h
@@ -2,10 +2,10 @@
#define STRICT
-#define NTDDI_VERSION NTDDI_WIN2K
+#define NTDDI_VERSION NTDDI_WIN2K
#define _WIN32_WINNT 0x0500
-#define WINVER 0x0500
-#define _WIN32_IE 0x0600
+#define WINVER 0x0500
+#define _WIN32_IE 0x0600
#define WIN32_LEAN_AND_MEAN
#define NOCOMM
#define NOKANJI
diff --git a/src/config/classes/general.h b/src/config/classes/general.h
index b3da4a475..b75c907e3 100644
--- a/src/config/classes/general.h
+++ b/src/config/classes/general.h
@@ -22,6 +22,11 @@
#define MAX_SPIRITBALL 15
/**
+* Spirit Charm Limitation
+**/
+#define MAX_SPIRITCHARM 10
+
+/**
* when enabled, reflect damage doesn't bypass devotion (and thus damage is passed to crusader)
* uncomment to enable
**/
diff --git a/src/config/const.h b/src/config/const.h
index 2b5b180c4..e10d2ad2a 100644
--- a/src/config/const.h
+++ b/src/config/const.h
@@ -52,10 +52,14 @@
#define DEFTYPE_MAX CHAR_MAX
#endif
-/* ATCMD_FUNC(mobinfo) HIT and FLEE calculations */
+/* ATCMD_FUNC(mobinfo) HIT, FLEE, ATK, ATK2, MATK and MATK2 calculations */
#ifdef RENEWAL
#define MOB_FLEE(mobdata) ( (mobdata)->lv + (mobdata)->status.agi + 100 )
#define MOB_HIT(mobdata) ( (mobdata)->lv + (mobdata)->status.dex + 150 )
+ #define MOB_ATK1(mobdata) ( ((mobdata)->lv + (mobdata)->status.str) + (mobdata)->status.rhw.atk * 8 / 10 )
+ #define MOB_ATK2(mobdata) ( ((mobdata)->lv + (mobdata)->status.str) + (mobdata)->status.rhw.atk * 12 / 10 )
+ #define MOB_MATK1(mobdata)( ((mobdata)->lv + (mobdata)->status.int_) + (mobdata)->status.rhw.atk2 * 7 / 10 )
+ #define MOB_MATK2(mobdata)( ((mobdata)->lv + (mobdata)->status.int_) + (mobdata)->status.rhw.atk2 * 13 / 10 )
#define RE_SKILL_REDUCTION() do { \
wd.damage = battle->calc_elefix(src, target, skill_id, skill_lv, battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 0, wd.flag), nk, n_ele, s_ele, s_ele_, false, flag.arrow); \
if( flag.lh ) \
@@ -69,17 +73,16 @@
/* Renewal's dmg level modifier, used as a macro for a easy way to turn off. */
#ifdef RENEWAL_LVDMG
#define RE_LVL_DMOD(val) do { \
- if( status->get_lv(src) > 100 && (val) > 0 ) \
+ if( (val) > 0 ) \
skillratio = skillratio * status->get_lv(src) / (val); \
} while(0)
#define RE_LVL_MDMOD(val) do { \
- if( status->get_lv(src) > 100 && (val) > 0) \
+ if ( (val) > 0 ) \
md.damage = md.damage * status->get_lv(src) / (val); \
} while(0)
/* ranger traps special */
#define RE_LVL_TMDMOD() do { \
- if( status->get_lv(src) > 100 ) \
- md.damage = md.damage * 150 / 100 + md.damage * status->get_lv(src) / 100; \
+ md.damage = md.damage * 150 / 100 + md.damage * status->get_lv(src) / 100; \
} while(0)
#else
#define RE_LVL_DMOD(val)
diff --git a/src/config/core.h b/src/config/core.h
index ac59563b5..da9296bda 100644
--- a/src/config/core.h
+++ b/src/config/core.h
@@ -35,15 +35,16 @@
//#define STATS_OPT_OUT
/// Uncomment to enable the Cell Stack Limit mod.
-/// It's only config is the battle_config cell_stack_limit.
-/// Only chars affected are those defined in BL_CHAR (mobs and players currently)
+/// It's only config is the battle_config custom_cell_stack_limit.
+/// Only chars affected are those defined in BL_CHAR
//#define CELL_NOSTACK
/// Uncomment to enable circular area checks.
-/// By default, all range checks in Aegis are of Square shapes, so a weapon range
-/// - of 10 allows you to attack from anywhere within a 21x21 area.
-/// Enabling this changes such checks to circular checks, which is more realistic,
-/// - but is not the official behavior.
+/// By default, most server-sided range checks in Aegis are of square shapes, so a monster
+/// with a range of 4 can attack anything within a 9x9 area.
+/// Client-sided range checks are, however, are always circular.
+/// Enabling this changes all checks to circular checks, which is more realistic,
+/// - but is not the official behaviour.
//#define CIRCULAR_AREA
//This is the distance at which @autoloot works,
diff --git a/src/login/HPMlogin.c b/src/login/HPMlogin.c
new file mode 100644
index 000000000..6b223d249
--- /dev/null
+++ b/src/login/HPMlogin.c
@@ -0,0 +1,53 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+
+#define HERCULES_CORE
+
+#include "HPMlogin.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "../common/HPM.h"
+#include "../common/cbasetypes.h"
+#include "../common/conf.h"
+#include "../common/db.h"
+#include "../common/des.h"
+#include "../common/ers.h"
+#include "../common/malloc.h"
+#include "../common/mapindex.h"
+#include "../common/mmo.h"
+#include "../common/showmsg.h"
+#include "../common/socket.h"
+#include "../common/strlib.h"
+#include "../common/sysinfo.h"
+
+#include "../common/HPMDataCheck.h"
+
+bool HPM_login_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr) {
+ /* record address */
+ switch( type ) {
+ default:
+ return false;
+ }
+ return true;
+}
+
+void HPM_login_plugin_load_sub(struct hplugin *plugin) {
+}
+
+void HPM_login_do_init(void) {
+#if 0 // TODO (HPMDataCheck is disabled for the time being)
+ HPM->datacheck_init(HPMDataCheck, HPMDataCheckLen, HPMDataCheckVer);
+#else
+ HPM->DataCheck = NULL;
+#endif
+}
+
+void HPM_login_do_final(void) {
+#if 0 // TODO (HPMDataCheck is disabled for the time being)
+ HPM->datacheck_final();
+#endif
+}
diff --git a/src/login/HPMlogin.h b/src/login/HPMlogin.h
new file mode 100644
index 000000000..6bdc0fb7b
--- /dev/null
+++ b/src/login/HPMlogin.h
@@ -0,0 +1,20 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+
+#ifndef LOGIN_HPMLOGIN_H
+#define LOGIN_HPMLOGIN_H
+
+#include "../common/cbasetypes.h"
+#include "../common/HPM.h"
+
+struct hplugin;
+
+bool HPM_login_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr);
+
+void HPM_login_plugin_load_sub(struct hplugin *plugin);
+
+void HPM_login_do_final(void);
+
+void HPM_login_do_init(void);
+
+#endif /* LOGIN_HPMLOGIN_H */
diff --git a/src/login/Makefile.in b/src/login/Makefile.in
index 7551eed5f..9b1db69c2 100644
--- a/src/login/Makefile.in
+++ b/src/login/Makefile.in
@@ -22,9 +22,9 @@ MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
MT19937AR_INCLUDE = -I$(MT19937AR_D)
-LOGIN_C = account_sql.c ipban_sql.c login.c loginlog_sql.c
+LOGIN_C = account_sql.c HPMlogin.c ipban_sql.c login.c loginlog_sql.c
LOGIN_OBJ = $(addprefix obj_sql/, $(patsubst %.c,%.o,$(LOGIN_C)))
-LOGIN_H = login.h account.h ipban.h loginlog.h
+LOGIN_H = login.h account.h HPMlogin.h ipban.h loginlog.h
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
@@ -87,7 +87,7 @@ login-server: ../../login-server@EXEEXT@
../../login-server@EXEEXT@: $(LOGIN_SERVER_SQL_DEPENDS) Makefile
@echo " LD $(notdir $@)"
- @$(CC) @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_OBJ) $(COMMON_D)/obj_sql/common_sql.a \
+ @$(CC) @STATIC@ @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_OBJ) $(COMMON_D)/obj_sql/common_sql.a \
$(COMMON_D)/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@
# login object files
diff --git a/src/login/account.h b/src/login/account.h
index e15143ce9..fb7368d69 100644
--- a/src/login/account.h
+++ b/src/login/account.h
@@ -52,6 +52,10 @@ struct AccountDBIterator
bool (*next)(AccountDBIterator* self, struct mmo_account* acc);
};
+struct Account_engine {
+ AccountDB* (*constructor)(void);
+ AccountDB* db;
+};
struct AccountDB
{
diff --git a/src/login/account_sql.c b/src/login/account_sql.c
index 51e499369..adbb7914d 100644
--- a/src/login/account_sql.c
+++ b/src/login/account_sql.c
@@ -33,14 +33,14 @@ typedef struct AccountDB_SQL
char global_db_hostname[32];
uint16 global_db_port;
char global_db_username[32];
- char global_db_password[32];
+ char global_db_password[100];
char global_db_database[32];
char global_codepage[32];
// local sql settings
char db_hostname[32];
uint16 db_port;
char db_username[32];
- char db_password[32];
+ char db_password[100];
char db_database[32];
char codepage[32];
// other settings
@@ -169,6 +169,10 @@ static bool account_db_sql_init(AccountDB* self)
if( codepage[0] != '\0' && SQL_ERROR == SQL->SetEncoding(sql_handle, codepage) )
Sql_ShowDebug(sql_handle);
+ Sql_HerculesUpdateCheck(db->accounts);
+#ifdef CONSOLE_INPUT
+ console->input->setSQL(db->accounts);
+#endif
return true;
}
@@ -218,7 +222,7 @@ static bool account_db_sql_get_property(AccountDB* self, const char* key, char*
if( strcmpi(key, "db_username") == 0 )
safesnprintf(buf, buflen, "%s", db->global_db_username);
else
- if( strcmpi(key, "db_password") == 0 )
+ if( strcmpi(key, "db_password") == 0 )
safesnprintf(buf, buflen, "%s", db->global_db_password);
else
if( strcmpi(key, "db_database") == 0 )
@@ -244,7 +248,7 @@ static bool account_db_sql_get_property(AccountDB* self, const char* key, char*
if( strcmpi(key, "db_username") == 0 )
safesnprintf(buf, buflen, "%s", db->db_username);
else
- if( strcmpi(key, "db_password") == 0 )
+ if( strcmpi(key, "db_password") == 0 )
safesnprintf(buf, buflen, "%s", db->db_password);
else
if( strcmpi(key, "db_database") == 0 )
@@ -569,7 +573,7 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc
SQL->GetData(sql_handle, 13, &data, NULL); acc->char_slots = (uint8)atoi(data);
SQL->GetData(sql_handle, 14, &data, NULL); safestrncpy(acc->pincode, data, sizeof(acc->pincode));
SQL->GetData(sql_handle, 15, &data, NULL); acc->pincode_change = (unsigned int)atol(data);
-
+
SQL->FreeResult(sql_handle);
return true;
@@ -655,29 +659,25 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
Sql* account_db_sql_up(AccountDB* self) {
AccountDB_SQL* db = (AccountDB_SQL*)self;
- Sql_HerculesUpdateCheck(db->accounts);
-#ifdef CONSOLE_INPUT
- console->input->setSQL(db->accounts);
-#endif
- return db->accounts;
+ return db ? db->accounts : NULL;
}
void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
Sql* sql_handle = ((AccountDB_SQL*)self)->accounts;
AccountDB_SQL* db = (AccountDB_SQL*)self;
int count = RFIFOW(fd, 12);
-
+
if( count ) {
int cursor = 14, i;
char key[32], sval[254];
unsigned int index;
-
+
for(i = 0; i < count; i++) {
safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), RFIFOB(fd, cursor));
cursor += RFIFOB(fd, cursor) + 1;
-
+
index = RFIFOL(fd, cursor);
cursor += 4;
-
+
switch (RFIFOB(fd, cursor++)) {
/* int */
case 0:
@@ -700,24 +700,21 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", db->global_acc_reg_str_db, account_id, key, index) )
Sql_ShowDebug(sql_handle);
break;
-
default:
ShowError("mmo_save_accreg2: DA HOO UNKNOWN TYPE %d\n",RFIFOB(fd, cursor - 1));
return;
}
-
}
-
}
-
}
+
void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
Sql* sql_handle = ((AccountDB_SQL*)self)->accounts;
AccountDB_SQL* db = (AccountDB_SQL*)self;
char* data;
int plen = 0;
size_t len;
-
+
if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", db->global_acc_reg_str_db, account_id) )
Sql_ShowDebug(sql_handle);
@@ -730,7 +727,7 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
WFIFOB(fd, 13) = 1;/* is string type */
WFIFOW(fd, 14) = 0;/* count */
plen = 16;
-
+
/**
* Vessel!
*
@@ -738,36 +735,35 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
* { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) }
**/
while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
-
SQL->GetData(sql_handle, 0, &data, NULL);
len = strlen(data)+1;
-
+
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */
plen += 1;
-
+
safestrncpy((char*)WFIFOP(fd,plen), data, len);
plen += len;
-
+
SQL->GetData(sql_handle, 1, &data, NULL);
-
+
WFIFOL(fd, plen) = (unsigned int)atol(data);
plen += 4;
-
+
SQL->GetData(sql_handle, 2, &data, NULL);
len = strlen(data)+1;
-
+
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 254 */
plen += 1;
-
+
safestrncpy((char*)WFIFOP(fd,plen), data, len);
plen += len;
-
+
WFIFOW(fd, 14) += 1;
-
+
if( plen > 60000 ) {
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
-
+
/* prepare follow up */
WFIFOHEAD(fd, 60000 + 300);
WFIFOW(fd, 0) = 0x3804;
@@ -780,16 +776,16 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
plen = 16;
}
}
-
+
/* mark & go. */
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
-
+
SQL->FreeResult(sql_handle);
-
+
if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", db->global_acc_reg_num_db, account_id) )
Sql_ShowDebug(sql_handle);
-
+
WFIFOHEAD(fd, 60000 + 300);
WFIFOW(fd, 0) = 0x3804;
/* 0x2 = length, set prior to being sent */
@@ -799,7 +795,7 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
WFIFOB(fd, 13) = 0;/* is int type */
WFIFOW(fd, 14) = 0;/* count */
plen = 16;
-
+
/**
* Vessel!
*
@@ -807,32 +803,31 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
* { keyLength(B), key(<keyLength>), index(L), value(L) }
**/
while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
-
SQL->GetData(sql_handle, 0, &data, NULL);
len = strlen(data)+1;
-
+
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */
plen += 1;
-
+
safestrncpy((char*)WFIFOP(fd,plen), data, len);
plen += len;
-
+
SQL->GetData(sql_handle, 1, &data, NULL);
-
+
WFIFOL(fd, plen) = (unsigned int)atol(data);
plen += 4;
-
+
SQL->GetData(sql_handle, 2, &data, NULL);
-
+
WFIFOL(fd, plen) = atoi(data);
plen += 4;
-
+
WFIFOW(fd, 14) += 1;
-
+
if( plen > 60000 ) {
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
-
+
/* prepare follow up */
WFIFOHEAD(fd, 60000 + 300);
WFIFOW(fd, 0) = 0x3804;
@@ -842,15 +837,15 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
WFIFOB(fd, 12) = 0;/* var type (only set when all vars have been sent, regardless of type) */
WFIFOB(fd, 13) = 0;/* is int type */
WFIFOW(fd, 14) = 0;/* count */
-
+
plen = 16;
}
}
-
+
/* mark as complete & go. */
WFIFOB(fd, 12) = 1;
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
-
+
SQL->FreeResult(sql_handle);
}
diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c
index 081f28d84..bfc90ad11 100644
--- a/src/login/ipban_sql.c
+++ b/src/login/ipban_sql.c
@@ -23,14 +23,14 @@
static char global_db_hostname[32] = "127.0.0.1";
static uint16 global_db_port = 3306;
static char global_db_username[32] = "ragnarok";
-static char global_db_password[32] = "ragnarok";
+static char global_db_password[100] = "ragnarok";
static char global_db_database[32] = "ragnarok";
static char global_codepage[32] = "";
// local sql settings
static char ipban_db_hostname[32] = "";
static uint16 ipban_db_port = 0;
static char ipban_db_username[32] = "";
-static char ipban_db_password[32] = "";
+static char ipban_db_password[100] = "";
static char ipban_db_database[32] = "";
static char ipban_codepage[32] = "";
static char ipban_table[32] = "ipbanlist";
@@ -105,7 +105,7 @@ void ipban_final(void)
if( login_config.ipban_cleanup_interval > 0 )
// release data
timer->delete(cleanup_timer_id, ipban_cleanup);
-
+
ipban_cleanup(0,0,0,0); // always clean up on login-server stop
// close connections
diff --git a/src/login/login.c b/src/login/login.c
index c8e219602..c006d9c45 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -10,6 +10,7 @@
#include <stdlib.h>
#include <string.h>
+#include "HPMlogin.h"
#include "account.h"
#include "ipban.h"
#include "loginlog.h"
@@ -25,74 +26,26 @@
#include "../common/timer.h"
#include "../common/utils.h"
+struct login_interface login_s;
struct Login_Config login_config;
-
-int login_fd; // login server socket
struct mmo_char_server server[MAX_SERVERS]; // char server data
-static struct account_engine {
- AccountDB* (*constructor)(void);
- AccountDB* db;
-} account_engine[] = {
+struct Account_engine account_engine[] = {
{account_db_sql, NULL}
};
// account database
AccountDB* accounts = NULL;
-//Account registration flood protection [Kevin]
-int allowed_regs = 1;
-int time_allowed = 10; //in seconds
-
-// Advanced subnet check [LuzZza]
-struct s_subnet {
- uint32 mask;
- uint32 char_ip;
- uint32 map_ip;
-} subnet[16];
-
-int subnet_count = 0;
-
-int mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip);
-
//-----------------------------------------------------
// Auth database
//-----------------------------------------------------
#define AUTH_TIMEOUT 30000
-struct auth_node {
-
- int account_id;
- uint32 login_id1;
- uint32 login_id2;
- uint32 ip;
- char sex;
- uint32 version;
- uint8 clienttype;
- int group_id;
- time_t expiration_time;
-};
-
-static DBMap* auth_db; // int account_id -> struct auth_node*
-
-
-//-----------------------------------------------------
-// Online User Database [Wizputer]
-//-----------------------------------------------------
-struct online_login_data {
-
- int account_id;
- int waiting_disconnect;
- int char_server;
-};
-
-static DBMap* online_db; // int account_id -> struct online_login_data*
-static int waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data);
-
/**
* @see DBCreateData
*/
-static DBData create_online_user(DBKey key, va_list args)
+static DBData login_create_online_user(DBKey key, va_list args)
{
struct online_login_data* p;
CREATE(p, struct online_login_data, 1);
@@ -102,38 +55,38 @@ static DBData create_online_user(DBKey key, va_list args)
return DB->ptr2data(p);
}
-struct online_login_data* add_online_user(int char_server, int account_id)
+struct online_login_data* login_add_online_user(int char_server, int account_id)
{
struct online_login_data* p;
- p = idb_ensure(online_db, account_id, create_online_user);
+ p = idb_ensure(login->online_db, account_id, login->create_online_user);
p->char_server = char_server;
if( p->waiting_disconnect != INVALID_TIMER )
{
- timer->delete(p->waiting_disconnect, waiting_disconnect_timer);
+ timer->delete(p->waiting_disconnect, login->waiting_disconnect_timer);
p->waiting_disconnect = INVALID_TIMER;
}
return p;
}
-void remove_online_user(int account_id)
+void login_remove_online_user(int account_id)
{
struct online_login_data* p;
- p = (struct online_login_data*)idb_get(online_db, account_id);
+ p = (struct online_login_data*)idb_get(login->online_db, account_id);
if( p == NULL )
return;
if( p->waiting_disconnect != INVALID_TIMER )
- timer->delete(p->waiting_disconnect, waiting_disconnect_timer);
+ timer->delete(p->waiting_disconnect, login->waiting_disconnect_timer);
- idb_remove(online_db, account_id);
+ idb_remove(login->online_db, account_id);
}
-static int waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data) {
- struct online_login_data* p = (struct online_login_data*)idb_get(online_db, id);
+static int login_waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data) {
+ struct online_login_data* p = (struct online_login_data*)idb_get(login->online_db, id);
if( p != NULL && p->waiting_disconnect == tid && p->account_id == id )
{
p->waiting_disconnect = INVALID_TIMER;
- remove_online_user(id);
- idb_remove(auth_db, id);
+ login->remove_online_user(id);
+ idb_remove(login->auth_db, id);
}
return 0;
}
@@ -141,7 +94,7 @@ static int waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data)
/**
* @see DBApply
*/
-static int online_db_setoffline(DBKey key, DBData *data, va_list ap)
+static int login_online_db_setoffline(DBKey key, DBData *data, va_list ap)
{
struct online_login_data* p = DB->data2ptr(data);
int server_id = va_arg(ap, int);
@@ -150,7 +103,7 @@ static int online_db_setoffline(DBKey key, DBData *data, va_list ap)
p->char_server = -1;
if( p->waiting_disconnect != INVALID_TIMER )
{
- timer->delete(p->waiting_disconnect, waiting_disconnect_timer);
+ timer->delete(p->waiting_disconnect, login->waiting_disconnect_timer);
p->waiting_disconnect = INVALID_TIMER;
}
}
@@ -162,16 +115,16 @@ static int online_db_setoffline(DBKey key, DBData *data, va_list ap)
/**
* @see DBApply
*/
-static int online_data_cleanup_sub(DBKey key, DBData *data, va_list ap)
+static int login_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap)
{
struct online_login_data *character= DB->data2ptr(data);
if (character->char_server == -2) //Unknown server.. set them offline
- remove_online_user(character->account_id);
+ login->remove_online_user(character->account_id);
return 0;
}
-static int online_data_cleanup(int tid, int64 tick, int id, intptr_t data) {
- online_db->foreach(online_db, online_data_cleanup_sub);
+static int login_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) {
+ login->online_db->foreach(login->online_db, login->online_data_cleanup_sub);
return 0;
}
@@ -221,7 +174,7 @@ void chrif_server_destroy(int id)
/// Resets all the data related to a server.
void chrif_server_reset(int id)
{
- online_db->foreach(online_db, online_db_setoffline, id); //Set all chars from this char server to offline.
+ 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);
}
@@ -238,7 +191,7 @@ void chrif_on_disconnect(int id)
//-----------------------------------------------------
// periodic ip address synchronization
//-----------------------------------------------------
-static int sync_ip_addresses(int tid, int64 tick, int id, intptr_t data) {
+static int login_sync_ip_addresses(int tid, int64 tick, int id, intptr_t data) {
uint8 buf[2];
ShowInfo("IP Sync in progress...\n");
WBUFW(buf,0) = 0x2735;
@@ -250,7 +203,7 @@ static int sync_ip_addresses(int tid, int64 tick, int id, intptr_t data) {
//-----------------------------------------------------
// encrypted/unencrypted password check (from eApp)
//-----------------------------------------------------
-bool check_encrypted(const char* str1, const char* str2, const char* passwd)
+bool login_check_encrypted(const char* str1, const char* str2, const char* passwd)
{
char tmpstr[64+1], md5str[32+1];
@@ -260,7 +213,7 @@ bool check_encrypted(const char* str1, const char* str2, const char* passwd)
return (0==strcmp(passwd, md5str));
}
-bool check_password(const char* md5key, int passwdenc, const char* passwd, const char* refpass)
+bool login_check_password(const char* md5key, int passwdenc, const char* passwd, const char* refpass)
{
if(passwdenc == 0)
{
@@ -270,20 +223,20 @@ bool check_password(const char* md5key, int passwdenc, const char* passwd, const
{
// password mode set to 1 -> md5(md5key, refpass) enable with <passwordencrypt></passwordencrypt>
// password mode set to 2 -> md5(refpass, md5key) enable with <passwordencrypt2></passwordencrypt2>
-
- return ((passwdenc&0x01) && check_encrypted(md5key, refpass, passwd)) ||
- ((passwdenc&0x02) && check_encrypted(refpass, md5key, passwd));
+
+ return ((passwdenc&0x01) && login->check_encrypted(md5key, refpass, passwd)) ||
+ ((passwdenc&0x02) && login->check_encrypted(refpass, md5key, passwd));
}
}
//--------------------------------------------
// Test to know if an IP come from LAN or WAN.
//--------------------------------------------
-int lan_subnetcheck(uint32 ip)
+int login_lan_subnetcheck(uint32 ip)
{
int i;
- ARR_FIND( 0, subnet_count, i, (subnet[i].char_ip & subnet[i].mask) == (ip & subnet[i].mask) );
- return ( i < subnet_count ) ? subnet[i].char_ip : 0;
+ ARR_FIND( 0, login_config.subnet_count, i, (login_config.subnet[i].char_ip & login_config.subnet[i].mask) == (ip & login_config.subnet[i].mask) );
+ return ( i < login_config.subnet_count ) ? login_config.subnet[i].char_ip : 0;
}
//----------------------------------
@@ -313,31 +266,546 @@ int login_lan_config_read(const char *lancfgName)
if( strcmpi(w1, "subnet") == 0 )
{
- subnet[subnet_count].mask = str2ip(w2);
- subnet[subnet_count].char_ip = str2ip(w3);
- subnet[subnet_count].map_ip = str2ip(w4);
+ login_config.subnet[login_config.subnet_count].mask = str2ip(w2);
+ login_config.subnet[login_config.subnet_count].char_ip = str2ip(w3);
+ login_config.subnet[login_config.subnet_count].map_ip = str2ip(w4);
- if( (subnet[subnet_count].char_ip & subnet[subnet_count].mask) != (subnet[subnet_count].map_ip & subnet[subnet_count].mask) )
+ if( (login_config.subnet[login_config.subnet_count].char_ip
+ & login_config.subnet[login_config.subnet_count].mask) != (login_config.subnet[login_config.subnet_count].map_ip
+ & login_config.subnet[login_config.subnet_count].mask) )
{
ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4);
continue;
}
- subnet_count++;
+ login_config.subnet_count++;
}
}
- if( subnet_count > 1 ) /* only useful if there is more than 1 available */
- ShowStatus("Read information about %d subnetworks.\n", subnet_count);
+ if( login_config.subnet_count > 1 ) /* only useful if there is more than 1 available */
+ ShowStatus("Read information about %d subnetworks.\n", login_config.subnet_count);
fclose(fp);
return 0;
}
+void login_fromchar_auth_ack(int fd, int account_id, uint32 login_id1, uint32 login_id2, uint8 sex, int request_id, struct login_auth_node* node)
+{
+ WFIFOHEAD(fd,33);
+ WFIFOW(fd,0) = 0x2713;
+ WFIFOL(fd,2) = account_id;
+ WFIFOL(fd,6) = login_id1;
+ WFIFOL(fd,10) = login_id2;
+ WFIFOB(fd,14) = sex;
+ if (node)
+ {
+ WFIFOB(fd,15) = 0;// ok
+ WFIFOL(fd,16) = request_id;
+ WFIFOL(fd,20) = node->version;
+ WFIFOB(fd,24) = node->clienttype;
+ WFIFOL(fd,25) = node->group_id;
+ WFIFOL(fd,29) = (unsigned int)node->expiration_time;
+ }
+ else
+ {
+ WFIFOB(fd,15) = 1;// auth failed
+ WFIFOL(fd,16) = request_id;
+ WFIFOL(fd,20) = 0;
+ WFIFOB(fd,24) = 0;
+ WFIFOL(fd,25) = 0;
+ WFIFOL(fd,29) = 0;
+ }
+ WFIFOSET(fd,33);
+}
+
+void login_fromchar_parse_auth(int fd, int id, const char *const ip)
+{
+ struct login_auth_node* node;
+
+ int account_id = RFIFOL(fd,2);
+ uint32 login_id1 = RFIFOL(fd,6);
+ uint32 login_id2 = RFIFOL(fd,10);
+ uint8 sex = RFIFOB(fd,14);
+ //uint32 ip_ = ntohl(RFIFOL(fd,15));
+ int request_id = RFIFOL(fd,19);
+ RFIFOSKIP(fd,23);
+
+ node = (struct login_auth_node*)idb_get(login->auth_db, account_id);
+ if( runflag == LOGINSERVER_ST_RUNNING &&
+ node != NULL &&
+ node->account_id == account_id &&
+ node->login_id1 == login_id1 &&
+ node->login_id2 == login_id2 &&
+ 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);
+
+ // send ack
+ login->fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, node);
+ // each auth entry can only be used once
+ idb_remove(login->auth_db, account_id);
+ }
+ else
+ {// authentication not found
+ ShowStatus("Char-server '%s': authentication of the account %d REFUSED (ip: %s).\n", server[id].name, account_id, ip);
+ login->fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, NULL);
+ }
+}
+
+void login_fromchar_parse_update_users(int fd, int id)
+{
+ int users = RFIFOL(fd,2);
+ RFIFOSKIP(fd,6);
+
+ // how many users on world? (update)
+ if( server[id].users != users )
+ {
+ ShowStatus("set users %s : %d\n", server[id].name, users);
+
+ server[id].users = (uint16)users;
+ }
+}
+
+void login_fromchar_parse_request_change_email(int fd, int id, const char *const ip)
+{
+ struct mmo_account acc;
+ char email[40];
+
+ int account_id = RFIFOL(fd,2);
+ safestrncpy(email, (char*)RFIFOP(fd,6), 40); remove_control_chars(email);
+ 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);
+ 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);
+ else {
+ memcpy(acc.email, email, 40);
+ 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);
+ // Save
+ accounts->save(accounts, &acc);
+ }
+}
+
+void login_fromchar_account(int fd, int account_id, struct mmo_account *acc)
+{
+ WFIFOHEAD(fd,72);
+ WFIFOW(fd,0) = 0x2717;
+ WFIFOL(fd,2) = account_id;
+ if (acc)
+ {
+ time_t expiration_time = 0;
+ char email[40] = "";
+ int group_id = 0;
+ uint8 char_slots = 0;
+ char birthdate[10+1] = "";
+ char pincode[4+1] = "\0\0\0\0";
+
+ safestrncpy(email, acc->email, sizeof(email));
+ expiration_time = acc->expiration_time;
+ group_id = acc->group_id;
+ char_slots = acc->char_slots;
+ safestrncpy(pincode, acc->pincode, sizeof(pincode));
+ safestrncpy(birthdate, acc->birthdate, sizeof(birthdate));
+ if( strlen(pincode) == 0 )
+ memset(pincode,'\0',sizeof(pincode));
+
+ safestrncpy((char*)WFIFOP(fd,6), email, 40);
+ WFIFOL(fd,46) = (uint32)expiration_time;
+ WFIFOB(fd,50) = (unsigned char)group_id;
+ WFIFOB(fd,51) = char_slots;
+ safestrncpy((char*)WFIFOP(fd,52), birthdate, 10+1);
+ safestrncpy((char*)WFIFOP(fd,63), pincode, 4+1 );
+ WFIFOL(fd,68) = acc->pincode_change;
+ }
+ else
+ {
+ safestrncpy((char*)WFIFOP(fd,6), "", 40);
+ WFIFOL(fd,46) = 0;
+ WFIFOB(fd,50) = 0;
+ WFIFOB(fd,51) = 0;
+ safestrncpy((char*)WFIFOP(fd,52), "", 10+1);
+ safestrncpy((char*)WFIFOP(fd,63), "\0\0\0\0", 4+1 );
+ WFIFOL(fd,68) = 0;
+ }
+ WFIFOSET(fd,72);
+}
+
+void login_fromchar_parse_account_data(int fd, int id, const char *const ip)
+{
+ struct mmo_account acc;
+
+ int account_id = RFIFOL(fd,2);
+ RFIFOSKIP(fd,6);
+
+ 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);
+ login->fromchar_account(fd, account_id, NULL);
+ }
+ else {
+ login->fromchar_account(fd, account_id, &acc);
+ }
+}
+
+void login_fromchar_pong(int fd)
+{
+ WFIFOHEAD(fd,2);
+ WFIFOW(fd,0) = 0x2718;
+ WFIFOSET(fd,2);
+}
+
+void login_fromchar_parse_ping(int fd)
+{
+ RFIFOSKIP(fd,2);
+ login->fromchar_pong(fd);
+}
+
+void login_fromchar_parse_change_email(int fd, int id, const char *const ip)
+{
+ struct mmo_account acc;
+ char actual_email[40];
+ char new_email[40];
+
+ int account_id = RFIFOL(fd,2);
+ safestrncpy(actual_email, (char*)RFIFOP(fd,6), 40);
+ safestrncpy(new_email, (char*)RFIFOP(fd,46), 40);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ else {
+ safestrncpy(acc.email, new_email, 40);
+ 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);
+ // Save
+ accounts->save(accounts, &acc);
+ }
+}
+
+void login_fromchar_account_update_other(int account_id, unsigned int state)
+{
+ uint8 buf[11];
+ WBUFW(buf,0) = 0x2731;
+ WBUFL(buf,2) = account_id;
+ WBUFB(buf,6) = 0; // 0: change of state, 1: ban
+ WBUFL(buf,7) = state; // status or final date of a banishment
+ charif_sendallwos(-1, buf, 11);
+}
+
+void login_fromchar_parse_account_update(int fd, int id, const char *const ip)
+{
+ struct mmo_account acc;
+
+ int account_id = RFIFOL(fd,2);
+ unsigned int state = RFIFOL(fd,6);
+ 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 %d, ip: %s).\n", 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 %d, ip: %s).\n", server[id].name, account_id, state, ip);
+ else {
+ ShowNotice("Char-server '%s': Status change (account: %d, new status %d, ip: %s).\n", server[id].name, account_id, state, ip);
+
+ acc.state = state;
+ // Save
+ accounts->save(accounts, &acc);
+
+ // notify other servers
+ if (state != 0) {
+ login->fromchar_account_update_other(account_id, state);
+ }
+ }
+}
+
+void login_fromchar_ban(int account_id, time_t timestamp)
+{
+ uint8 buf[11];
+ WBUFW(buf,0) = 0x2731;
+ WBUFL(buf,2) = account_id;
+ WBUFB(buf,6) = 1; // 0: change of status, 1: ban
+ WBUFL(buf,7) = (uint32)timestamp; // status or final date of a banishment
+ charif_sendallwos(-1, buf, 11);
+}
+
+void login_fromchar_parse_ban(int fd, int id, const char *const ip)
+{
+ struct mmo_account acc;
+
+ int account_id = RFIFOL(fd,2);
+ int year = (short)RFIFOW(fd,6);
+ int month = (short)RFIFOW(fd,8);
+ int mday = (short)RFIFOW(fd,10);
+ int hour = (short)RFIFOW(fd,12);
+ int min = (short)RFIFOW(fd,14);
+ int sec = (short)RFIFOW(fd,16);
+ 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);
+ } else {
+ time_t timestamp;
+ struct tm *tmtime;
+ if (acc.unban_time == 0 || acc.unban_time < time(NULL))
+ timestamp = time(NULL); // new ban
+ else
+ timestamp = acc.unban_time; // add to existing ban
+ tmtime = localtime(&timestamp);
+ tmtime->tm_year += year;
+ tmtime->tm_mon += month;
+ tmtime->tm_mday += mday;
+ tmtime->tm_hour += hour;
+ tmtime->tm_min += min;
+ 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);
+ } 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);
+ } 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);
+
+ acc.unban_time = timestamp;
+
+ // Save
+ accounts->save(accounts, &acc);
+
+ login->fromchar_ban(account_id, timestamp);
+ }
+ }
+}
+
+void login_fromchar_change_sex_other(int account_id, char sex)
+{
+ unsigned char buf[7];
+ WBUFW(buf,0) = 0x2723;
+ WBUFL(buf,2) = account_id;
+ WBUFB(buf,6) = sex_str2num(sex);
+ charif_sendallwos(-1, buf, 7);
+}
+
+void login_fromchar_parse_change_sex(int fd, int id, const char *const ip)
+{
+ struct mmo_account acc;
+
+ int account_id = RFIFOL(fd,2);
+ 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);
+ 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);
+ 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);
+
+ acc.sex = sex;
+ // Save
+ accounts->save(accounts, &acc);
+
+ // announce to other servers
+ login->fromchar_change_sex_other(account_id, sex);
+ }
+}
+
+void login_fromchar_parse_account_reg2(int fd, int id, const char *const ip)
+{
+ struct mmo_account acc;
+
+ 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);
+ else {
+ mmo_save_accreg2(accounts,fd,account_id,RFIFOL(fd, 8));
+ }
+ RFIFOSKIP(fd,RFIFOW(fd,2));
+}
+
+void login_fromchar_parse_unban(int fd, int id, const char *const ip)
+{
+ struct mmo_account acc;
+
+ int account_id = RFIFOL(fd,2);
+ 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);
+ 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);
+ else
+ {
+ ShowNotice("Char-server '%s': Unban request (account: %d, ip: %s).\n", server[id].name, account_id, ip);
+ acc.unban_time = 0;
+ accounts->save(accounts, &acc);
+ }
+}
+
+void login_fromchar_parse_account_online(int fd, int id)
+{
+ login->add_online_user(id, RFIFOL(fd,2));
+ RFIFOSKIP(fd,6);
+}
+
+void login_fromchar_parse_account_offline(int fd)
+{
+ login->remove_online_user(RFIFOL(fd,2));
+ RFIFOSKIP(fd,6);
+}
+
+void login_fromchar_parse_online_accounts(int fd, int id)
+{
+ struct online_login_data *p;
+ int aid;
+ uint32 i, users;
+ login->online_db->foreach(login->online_db, login->online_db_setoffline, id); //Set all chars from this char-server offline first
+ users = RFIFOW(fd,4);
+ for (i = 0; i < users; i++) {
+ aid = RFIFOL(fd,6+i*4);
+ p = idb_ensure(login->online_db, aid, login->create_online_user);
+ p->char_server = id;
+ if (p->waiting_disconnect != INVALID_TIMER)
+ {
+ timer->delete(p->waiting_disconnect, login->waiting_disconnect_timer);
+ p->waiting_disconnect = INVALID_TIMER;
+ }
+ }
+}
+
+void login_fromchar_parse_request_account_reg2(int fd)
+{
+ int account_id = RFIFOL(fd,2);
+ int char_id = RFIFOL(fd,6);
+ RFIFOSKIP(fd,10);
+
+ 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 %d.%d.%d.%d.\n",id, CONVIP(server[id].ip));
+ RFIFOSKIP(fd,6);
+}
+
+void login_fromchar_parse_all_offline(int fd, int id)
+{
+ ShowInfo("Setting accounts from char-server %d offline.\n", id);
+ login->online_db->foreach(login->online_db, login->online_db_setoffline, id);
+ RFIFOSKIP(fd,2);
+}
+
+void login_fromchar_parse_change_pincode(int fd)
+{
+ struct mmo_account acc;
+
+ if( accounts->load_num(accounts, &acc, RFIFOL(fd,2) ) ) {
+ strncpy( acc.pincode, (char*)RFIFOP(fd,6), 5 );
+ acc.pincode_change = ((unsigned int)time( NULL ));
+ accounts->save(accounts, &acc);
+ }
+ RFIFOSKIP(fd,11);
+}
+
+bool login_fromchar_parse_wrong_pincode(int fd)
+{
+ struct mmo_account acc;
+
+ if( accounts->load_num(accounts, &acc, RFIFOL(fd,2) ) ) {
+ struct online_login_data* ld;
+
+ if( ( ld = (struct online_login_data*)idb_get(login->online_db,acc.account_id) ) == NULL )
+ {
+ RFIFOSKIP(fd,6);
+ return true;
+ }
+
+ login_log( host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed" );
+ }
+
+ login->remove_online_user(acc.account_id);
+ RFIFOSKIP(fd,6);
+ return false;
+}
+
+void login_fromchar_accinfo(int fd, int account_id, int u_fd, int u_aid, int u_group, int map_fd, struct mmo_account *acc)
+{
+ if (acc)
+ {
+ WFIFOHEAD(fd,183);
+ WFIFOW(fd,0) = 0x2737;
+ safestrncpy((char*)WFIFOP(fd,2), acc->userid, NAME_LENGTH);
+ if (u_group >= acc->group_id)
+ safestrncpy((char*)WFIFOP(fd,26), acc->pass, 33);
+ else
+ memset(WFIFOP(fd,26), '\0', 33);
+ safestrncpy((char*)WFIFOP(fd,59), acc->email, 40);
+ safestrncpy((char*)WFIFOP(fd,99), acc->last_ip, 16);
+ WFIFOL(fd,115) = acc->group_id;
+ safestrncpy((char*)WFIFOP(fd,119), acc->lastlogin, 24);
+ WFIFOL(fd,143) = acc->logincount;
+ WFIFOL(fd,147) = acc->state;
+ if (u_group >= acc->group_id)
+ safestrncpy((char*)WFIFOP(fd,151), acc->pincode, 5);
+ else
+ memset(WFIFOP(fd,151), '\0', 5);
+ safestrncpy((char*)WFIFOP(fd,156), acc->birthdate, 11);
+ WFIFOL(fd,167) = map_fd;
+ WFIFOL(fd,171) = u_fd;
+ WFIFOL(fd,175) = u_aid;
+ WFIFOL(fd,179) = account_id;
+ WFIFOSET(fd,183);
+ }
+ else
+ {
+ WFIFOHEAD(fd,18);
+ WFIFOW(fd,0) = 0x2736;
+ WFIFOL(fd,2) = map_fd;
+ WFIFOL(fd,6) = u_fd;
+ WFIFOL(fd,10) = u_aid;
+ WFIFOL(fd,14) = account_id;
+ WFIFOSET(fd,18);
+ }
+}
+
+void login_fromchar_parse_accinfo(int fd)
+{
+ struct mmo_account acc;
+ int account_id = RFIFOL(fd, 2), u_fd = RFIFOL(fd, 6), u_aid = RFIFOL(fd, 10), u_group = RFIFOL(fd, 14), map_fd = RFIFOL(fd, 18);
+ if (accounts->load_num(accounts, &acc, account_id)) {
+ login->fromchar_accinfo(fd, account_id, u_fd, u_aid, u_group, map_fd, &acc);
+ } else {
+ login->fromchar_accinfo(fd, account_id, u_fd, u_aid, u_group, map_fd, NULL);
+ }
+ RFIFOSKIP(fd,22);
+}
+
//--------------------------------
// Packet parsing for char-servers
//--------------------------------
-int parse_fromchar(int fd)
+int login_parse_fromchar(int fd)
{
int j, id;
uint32 ipl;
@@ -346,7 +814,7 @@ int parse_fromchar(int fd)
ARR_FIND( 0, ARRAYLENGTH(server), id, server[id].fd == fd );
if( id == ARRAYLENGTH(server) )
{// not a char server
- ShowDebug("parse_fromchar: Disconnecting invalid session #%d (is not a char-server)\n", fd);
+ ShowDebug("login_parse_fromchar: Disconnecting invalid session #%d (is not a char-server)\n", fd);
set_eof(fd);
do_close(fd);
return 0;
@@ -372,69 +840,14 @@ int parse_fromchar(int fd)
if( j == 2 ) return 0;
}
}
-
+
switch( command ) {
case 0x2712: // request from char-server to authenticate an account
if( RFIFOREST(fd) < 23 )
return 0;
{
- struct auth_node* node;
-
- int account_id = RFIFOL(fd,2);
- uint32 login_id1 = RFIFOL(fd,6);
- uint32 login_id2 = RFIFOL(fd,10);
- uint8 sex = RFIFOB(fd,14);
- //uint32 ip_ = ntohl(RFIFOL(fd,15));
- int request_id = RFIFOL(fd,19);
- RFIFOSKIP(fd,23);
-
- node = (struct auth_node*)idb_get(auth_db, account_id);
- if( runflag == LOGINSERVER_ST_RUNNING &&
- node != NULL &&
- node->account_id == account_id &&
- node->login_id1 == login_id1 &&
- node->login_id2 == login_id2 &&
- 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);
-
- // send ack
- WFIFOHEAD(fd,33);
- WFIFOW(fd,0) = 0x2713;
- WFIFOL(fd,2) = account_id;
- WFIFOL(fd,6) = login_id1;
- WFIFOL(fd,10) = login_id2;
- WFIFOB(fd,14) = sex;
- WFIFOB(fd,15) = 0;// ok
- WFIFOL(fd,16) = request_id;
- WFIFOL(fd,20) = node->version;
- WFIFOB(fd,24) = node->clienttype;
- WFIFOL(fd,25) = node->group_id;
- WFIFOL(fd,29) = (unsigned int)node->expiration_time;
- WFIFOSET(fd,33);
-
- // each auth entry can only be used once
- idb_remove(auth_db, account_id);
- }
- else
- {// authentication not found
- ShowStatus("Char-server '%s': authentication of the account %d REFUSED (ip: %s).\n", server[id].name, account_id, ip);
- WFIFOHEAD(fd,33);
- WFIFOW(fd,0) = 0x2713;
- WFIFOL(fd,2) = account_id;
- WFIFOL(fd,6) = login_id1;
- WFIFOL(fd,10) = login_id2;
- WFIFOB(fd,14) = sex;
- WFIFOB(fd,15) = 1;// auth failed
- WFIFOL(fd,16) = request_id;
- WFIFOL(fd,20) = 0;
- WFIFOB(fd,24) = 0;
- WFIFOL(fd,25) = 0;
- WFIFOL(fd,29) = 0;
- WFIFOSET(fd,33);
- }
+ login->fromchar_parse_auth(fd, id, ip);
}
break;
@@ -442,16 +855,7 @@ int parse_fromchar(int fd)
if( RFIFOREST(fd) < 6 )
return 0;
{
- int users = RFIFOL(fd,2);
- RFIFOSKIP(fd,6);
-
- // how many users on world? (update)
- if( server[id].users != users )
- {
- ShowStatus("set users %s : %d\n", server[id].name, users);
-
- server[id].users = (uint16)users;
- }
+ login->fromchar_parse_update_users(fd, id);
}
break;
@@ -459,24 +863,7 @@ int parse_fromchar(int fd)
if (RFIFOREST(fd) < 46)
return 0;
{
- struct mmo_account acc;
- char email[40];
-
- int account_id = RFIFOL(fd,2);
- safestrncpy(email, (char*)RFIFOP(fd,6), 40); remove_control_chars(email);
- 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);
- 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);
- else {
- memcpy(acc.email, email, 40);
- 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);
- // Save
- accounts->save(accounts, &acc);
- }
+ login->fromchar_parse_request_change_email(fd, id, ip);
}
break;
@@ -484,86 +871,20 @@ int parse_fromchar(int fd)
if( RFIFOREST(fd) < 6 )
return 0;
{
- struct mmo_account acc;
- time_t expiration_time = 0;
- char email[40] = "";
- int group_id = 0;
- uint8 char_slots = 0;
- char birthdate[10+1] = "";
- char pincode[4+1] = "\0\0\0\0";
-
- int account_id = RFIFOL(fd,2);
- RFIFOSKIP(fd,6);
-
- 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);
- else {
- safestrncpy(email, acc.email, sizeof(email));
- expiration_time = acc.expiration_time;
- group_id = acc.group_id;
- char_slots = acc.char_slots;
- safestrncpy(pincode, acc.pincode, sizeof(pincode));
- safestrncpy(birthdate, acc.birthdate, sizeof(birthdate));
- if( strlen(pincode) == 0 )
- memset(pincode,'\0',sizeof(pincode));
- }
-
- WFIFOHEAD(fd,72);
- WFIFOW(fd,0) = 0x2717;
- WFIFOL(fd,2) = account_id;
- safestrncpy((char*)WFIFOP(fd,6), email, 40);
- WFIFOL(fd,46) = (uint32)expiration_time;
- WFIFOB(fd,50) = (unsigned char)group_id;
- WFIFOB(fd,51) = char_slots;
- safestrncpy((char*)WFIFOP(fd,52), birthdate, 10+1);
- safestrncpy((char*)WFIFOP(fd,63), pincode, 4+1 );
- WFIFOL(fd,68) = acc.pincode_change;
- WFIFOSET(fd,72);
+ login->fromchar_parse_account_data(fd, id, ip);
}
break;
case 0x2719: // ping request from charserver
- RFIFOSKIP(fd,2);
-
- WFIFOHEAD(fd,2);
- WFIFOW(fd,0) = 0x2718;
- WFIFOSET(fd,2);
+ login->fromchar_parse_ping(fd);
break;
// Map server send information to change an email of an account via char-server
- case 0x2722: // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
+ case 0x2722: // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
if (RFIFOREST(fd) < 86)
return 0;
{
- struct mmo_account acc;
- char actual_email[40];
- char new_email[40];
-
- int account_id = RFIFOL(fd,2);
- safestrncpy(actual_email, (char*)RFIFOP(fd,6), 40);
- safestrncpy(new_email, (char*)RFIFOP(fd,46), 40);
- 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);
- 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);
- 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);
- 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);
- 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);
- else {
- safestrncpy(acc.email, new_email, 40);
- 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);
- // Save
- accounts->save(accounts, &acc);
- }
+ login->fromchar_parse_change_email(fd, id, ip);
}
break;
@@ -571,34 +892,7 @@ int parse_fromchar(int fd)
if (RFIFOREST(fd) < 10)
return 0;
{
- struct mmo_account acc;
-
- int account_id = RFIFOL(fd,2);
- unsigned int state = RFIFOL(fd,6);
- 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 %d, ip: %s).\n", 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 %d, ip: %s).\n", server[id].name, account_id, state, ip);
- else {
- ShowNotice("Char-server '%s': Status change (account: %d, new status %d, ip: %s).\n", server[id].name, account_id, state, ip);
-
- acc.state = state;
- // Save
- accounts->save(accounts, &acc);
-
- // notify other servers
- if (state != 0) {
- uint8 buf[11];
- WBUFW(buf,0) = 0x2731;
- WBUFL(buf,2) = account_id;
- WBUFB(buf,6) = 0; // 0: change of state, 1: ban
- WBUFL(buf,7) = state; // status or final date of a banishment
- charif_sendallwos(-1, buf, 11);
- }
- }
+ login->fromchar_parse_account_update(fd, id, ip);
}
break;
@@ -606,57 +900,7 @@ int parse_fromchar(int fd)
if (RFIFOREST(fd) < 18)
return 0;
{
- struct mmo_account acc;
-
- int account_id = RFIFOL(fd,2);
- int year = (short)RFIFOW(fd,6);
- int month = (short)RFIFOW(fd,8);
- int mday = (short)RFIFOW(fd,10);
- int hour = (short)RFIFOW(fd,12);
- int min = (short)RFIFOW(fd,14);
- int sec = (short)RFIFOW(fd,16);
- 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);
- } else {
- time_t timestamp;
- struct tm *tmtime;
- if (acc.unban_time == 0 || acc.unban_time < time(NULL))
- timestamp = time(NULL); // new ban
- else
- timestamp = acc.unban_time; // add to existing ban
- tmtime = localtime(&timestamp);
- tmtime->tm_year += year;
- tmtime->tm_mon += month;
- tmtime->tm_mday += mday;
- tmtime->tm_hour += hour;
- tmtime->tm_min += min;
- 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);
- } 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);
- } else {
- uint8 buf[11];
- 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);
-
- acc.unban_time = timestamp;
-
- // Save
- accounts->save(accounts, &acc);
-
- WBUFW(buf,0) = 0x2731;
- WBUFL(buf,2) = account_id;
- WBUFB(buf,6) = 1; // 0: change of status, 1: ban
- WBUFL(buf,7) = (uint32)timestamp; // status or final date of a banishment
- charif_sendallwos(-1, buf, 11);
- }
- }
+ login->fromchar_parse_ban(fd, id, ip);
}
break;
@@ -664,109 +908,43 @@ int parse_fromchar(int fd)
if( RFIFOREST(fd) < 6 )
return 0;
{
- struct mmo_account acc;
-
- int account_id = RFIFOL(fd,2);
- 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);
- 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);
- else
- {
- unsigned char buf[7];
- 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);
-
- acc.sex = sex;
- // Save
- accounts->save(accounts, &acc);
-
- // announce to other servers
- WBUFW(buf,0) = 0x2723;
- WBUFL(buf,2) = account_id;
- WBUFB(buf,6) = sex_str2num(sex);
- charif_sendallwos(-1, buf, 7);
- }
+ login->fromchar_parse_change_sex(fd, id, ip);
}
break;
- case 0x2728: // We receive account_reg2 from a char-server, and we send them to other map-servers.
+ case 0x2728: // We receive account_reg2 from a char-server, and we send them to other map-servers.
if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) )
return 0;
{
- struct mmo_account acc;
-
- 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);
- else {
- mmo_save_accreg2(accounts,fd,account_id,RFIFOL(fd, 8));
- }
- RFIFOSKIP(fd,RFIFOW(fd,2));
+ login->fromchar_parse_account_reg2(fd, id, ip);
}
break;
- case 0x272a: // Receiving of map-server via char-server an unban request
+ case 0x272a: // Receiving of map-server via char-server an unban request
if( RFIFOREST(fd) < 6 )
return 0;
{
- struct mmo_account acc;
-
- int account_id = RFIFOL(fd,2);
- 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);
- 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);
- else
- {
- ShowNotice("Char-server '%s': Unban request (account: %d, ip: %s).\n", server[id].name, account_id, ip);
- acc.unban_time = 0;
- accounts->save(accounts, &acc);
- }
+ login->fromchar_parse_unban(fd, id, ip);
}
break;
case 0x272b: // Set account_id to online [Wizputer]
if( RFIFOREST(fd) < 6 )
return 0;
- add_online_user(id, RFIFOL(fd,2));
- RFIFOSKIP(fd,6);
+ login->fromchar_parse_account_online(fd, id);
break;
case 0x272c: // Set account_id to offline [Wizputer]
if( RFIFOREST(fd) < 6 )
return 0;
- remove_online_user(RFIFOL(fd,2));
- RFIFOSKIP(fd,6);
+ login->fromchar_parse_account_offline(fd);
break;
- case 0x272d: // Receive list of all online accounts. [Skotlex]
+ case 0x272d: // Receive list of all online accounts. [Skotlex]
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
{
- struct online_login_data *p;
- int aid;
- uint32 i, users;
- online_db->foreach(online_db, online_db_setoffline, id); //Set all chars from this char-server offline first
- users = RFIFOW(fd,4);
- for (i = 0; i < users; i++) {
- aid = RFIFOL(fd,6+i*4);
- p = idb_ensure(online_db, aid, create_online_user);
- p->char_server = id;
- if (p->waiting_disconnect != INVALID_TIMER)
- {
- timer->delete(p->waiting_disconnect, waiting_disconnect_timer);
- p->waiting_disconnect = INVALID_TIMER;
- }
- }
+ login->fromchar_parse_online_accounts(fd, id);
}
RFIFOSKIP(fd,RFIFOW(fd,2));
break;
@@ -775,107 +953,46 @@ int parse_fromchar(int fd)
if (RFIFOREST(fd) < 10)
return 0;
{
- int account_id = RFIFOL(fd,2);
- int char_id = RFIFOL(fd,6);
- RFIFOSKIP(fd,10);
-
- mmo_send_accreg2(accounts,fd,account_id,char_id);
+ login->fromchar_parse_request_account_reg2(fd);
}
break;
case 0x2736: // WAN IP update from char-server
if( RFIFOREST(fd) < 6 )
return 0;
- server[id].ip = ntohl(RFIFOL(fd,2));
- ShowInfo("Updated IP of Server #%d to %d.%d.%d.%d.\n",id, CONVIP(server[id].ip));
- RFIFOSKIP(fd,6);
+ login->fromchar_parse_update_wan_ip(fd, id);
break;
case 0x2737: //Request to set all offline.
- ShowInfo("Setting accounts from char-server %d offline.\n", id);
- online_db->foreach(online_db, online_db_setoffline, id);
- RFIFOSKIP(fd,2);
+ login->fromchar_parse_all_offline(fd, id);
break;
case 0x2738: //Change PIN Code for a account
if( RFIFOREST(fd) < 11 )
return 0;
else {
- struct mmo_account acc;
-
- if( accounts->load_num(accounts, &acc, RFIFOL(fd,2) ) ) {
- strncpy( acc.pincode, (char*)RFIFOP(fd,6), 5 );
- acc.pincode_change = ((unsigned int)time( NULL ));
- accounts->save(accounts, &acc);
- }
- RFIFOSKIP(fd,11);
+ login->fromchar_parse_change_pincode(fd);
}
break;
-
+
case 0x2739: // PIN Code was entered wrong too often
if( RFIFOREST(fd) < 6 )
return 0;
else {
- struct mmo_account acc;
-
- if( accounts->load_num(accounts, &acc, RFIFOL(fd,2) ) ) {
- struct online_login_data* ld;
-
- if( ( ld = (struct online_login_data*)idb_get(online_db,acc.account_id) ) == NULL )
- return 0;
-
- login_log( host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed" );
- }
-
- remove_online_user(acc.account_id);
- RFIFOSKIP(fd,6);
+ if (login->fromchar_parse_wrong_pincode(fd))
+ return 0;
}
break;
-
+
case 0x2740: // Accinfo request forwarded by charserver on mapserver's account
if( RFIFOREST(fd) < 22 )
return 0;
else {
- struct mmo_account acc;
- int account_id = RFIFOL(fd, 2), u_fd = RFIFOL(fd, 6), u_aid = RFIFOL(fd, 10), u_group = RFIFOL(fd, 14), map_fd = RFIFOL(fd, 18);
- if (accounts->load_num(accounts, &acc, account_id)) {
- WFIFOHEAD(fd,183);
- WFIFOW(fd,0) = 0x2737;
- safestrncpy((char*)WFIFOP(fd,2), acc.userid, NAME_LENGTH);
- if (u_group >= acc.group_id)
- safestrncpy((char*)WFIFOP(fd,26), acc.pass, 33);
- else
- memset(WFIFOP(fd,26), '\0', 33);
- safestrncpy((char*)WFIFOP(fd,59), acc.email, 40);
- safestrncpy((char*)WFIFOP(fd,99), acc.last_ip, 16);
- WFIFOL(fd,115) = acc.group_id;
- safestrncpy((char*)WFIFOP(fd,119), acc.lastlogin, 24);
- WFIFOL(fd,143) = acc.logincount;
- WFIFOL(fd,147) = acc.state;
- if (u_group >= acc.group_id)
- safestrncpy((char*)WFIFOP(fd,151), acc.pincode, 5);
- else
- memset(WFIFOP(fd,151), '\0', 5);
- safestrncpy((char*)WFIFOP(fd,156), acc.birthdate, 11);
- WFIFOL(fd,167) = map_fd;
- WFIFOL(fd,171) = u_fd;
- WFIFOL(fd,175) = u_aid;
- WFIFOL(fd,179) = account_id;
- WFIFOSET(fd,183);
- } else {
- WFIFOHEAD(fd,18);
- WFIFOW(fd,0) = 0x2736;
- WFIFOL(fd,2) = map_fd;
- WFIFOL(fd,6) = u_fd;
- WFIFOL(fd,10) = u_aid;
- WFIFOL(fd,14) = account_id;
- WFIFOSET(fd,18);
- }
- RFIFOSKIP(fd,22);
+ login->fromchar_parse_accinfo(fd);
}
break;
default:
- ShowError("parse_fromchar: Unknown packet 0x%x from a char-server! Disconnecting!\n", command);
+ ShowError("login_parse_fromchar: Unknown packet 0x%x from a char-server! Disconnecting!\n", command);
set_eof(fd);
return 0;
} // switch
@@ -888,7 +1005,7 @@ int parse_fromchar(int fd)
//-------------------------------------
// Make new account
//-------------------------------------
-int mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip) {
+int login_mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip) {
static int num_regs = 0; // registration counter
static int64 new_reg_tick = 0;
int64 tick = timer->gettick();
@@ -897,7 +1014,7 @@ int mmo_auth_new(const char* userid, const char* pass, const char sex, const cha
//Account Registration Flood Protection by [Kevin]
if( new_reg_tick == 0 )
new_reg_tick = timer->gettick();
- if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= allowed_regs ) {
+ if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= login_config.allowed_regs ) {
ShowNotice("Account registration denied (registration limit exceeded)\n");
return 3;
}
@@ -928,7 +1045,7 @@ int mmo_auth_new(const char* userid, const char* pass, const char sex, const cha
safestrncpy(acc.pincode, "\0", sizeof(acc.pincode));
acc.pincode_change = 0;
acc.char_slots = 0;
-
+
if( !accounts->create(accounts, &acc) )
return 0;
@@ -936,7 +1053,7 @@ int mmo_auth_new(const char* userid, const char* pass, const char sex, const cha
if( DIFF_TICK(tick, new_reg_tick) > 0 ) {// Update the registration check.
num_regs = 0;
- new_reg_tick = tick + time_allowed*1000;
+ new_reg_tick = tick + login_config.time_allowed*1000;
}
++num_regs;
@@ -946,7 +1063,7 @@ int mmo_auth_new(const char* userid, const char* pass, const char sex, const cha
//-----------------------------------------------------
// Check/authentication of a connection
//-----------------------------------------------------
-int mmo_auth(struct login_session_data* sd, bool isServer) {
+int login_mmo_auth(struct login_session_data* sd, bool isServer) {
struct mmo_account acc;
size_t len;
@@ -990,18 +1107,23 @@ int mmo_auth(struct login_session_data* sd, bool isServer) {
len -= 2;
sd->userid[len] = '\0';
- result = mmo_auth_new(sd->userid, sd->passwd, TOUPPER(sd->userid[len+1]), ip);
+ result = login->mmo_auth_new(sd->userid, sd->passwd, TOUPPER(sd->userid[len+1]), ip);
if( result != -1 )
return result;// Failed to make account. [Skotlex].
}
}
-
+
+ if( len <= 0 ) { /** a empty password is fine, a userid is not. **/
+ ShowNotice("Empty userid (received pass: '%s', ip: %s)\n", sd->passwd, ip);
+ return 0; // 0 = Unregistered ID
+ }
+
if( !accounts->load_str(accounts, &acc, sd->userid) ) {
ShowNotice("Unknown account (account: %s, received pass: %s, ip: %s)\n", sd->userid, sd->passwd, ip);
return 0; // 0 = Unregistered ID
}
- if( !check_password(sd->md5key, sd->passwdenc, sd->passwd, acc.pass) ) {
+ if( !login->check_password(sd->md5key, sd->passwdenc, sd->passwd, acc.pass) ) {
ShowNotice("Invalid password (account: '%s', pass: '%s', received pass: '%s', ip: %s)\n", sd->userid, acc.pass, sd->passwd, ip);
return 1; // 1 = Incorrect Password
}
@@ -1017,7 +1139,7 @@ int mmo_auth(struct login_session_data* sd, bool isServer) {
ShowNotice("Connection refused (account: %s, pass: %s, state: %d, ip: %s)\n", sd->userid, sd->passwd, acc.state, ip);
return acc.state - 1;
}
-
+
if( login_config.client_hash_check && !isServer ) {
struct client_hash_node *node = NULL;
bool match = false;
@@ -1076,6 +1198,22 @@ int mmo_auth(struct login_session_data* sd, bool isServer) {
return -1; // account OK
}
+void login_connection_problem(int fd, uint8 status)
+{
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x81;
+ WFIFOB(fd,2) = status;
+ WFIFOSET(fd,3);
+}
+
+void login_kick(struct login_session_data* sd)
+{
+ uint8 buf[6];
+ WBUFW(buf,0) = 0x2734;
+ WBUFL(buf,2) = sd->account_id;
+ charif_sendallwos(-1, buf, 6);
+}
+
void login_auth_ok(struct login_session_data* sd)
{
int fd = sd->fd;
@@ -1083,32 +1221,23 @@ void login_auth_ok(struct login_session_data* sd)
uint8 server_num, n;
uint32 subnet_char_ip;
- struct auth_node* node;
+ struct login_auth_node* node;
int i;
if( runflag != LOGINSERVER_ST_RUNNING )
{
// players can only login while running
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = 1;// server closed
- WFIFOSET(fd,3);
+ login->connection_problem(fd, 1); // 01 = server closed
return;
}
if( login_config.group_id_to_connect >= 0 && sd->group_id != login_config.group_id_to_connect ) {
ShowStatus("Connection refused: the required group id for connection is %d (account: %s, group: %d).\n", login_config.group_id_to_connect, sd->userid, sd->group_id);
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = 1; // 01 = Server closed
- WFIFOSET(fd,3);
+ login->connection_problem(fd, 1); // 01 = server closed
return;
} else if( login_config.min_group_id_to_connect >= 0 && login_config.group_id_to_connect == -1 && sd->group_id < login_config.min_group_id_to_connect ) {
ShowStatus("Connection refused: the minimum group id required for connection is %d (account: %s, group: %d).\n", login_config.min_group_id_to_connect, sd->userid, sd->group_id);
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = 1; // 01 = Server closed
- WFIFOSET(fd,3);
+ login->connection_problem(fd, 1); // 01 = server closed
return;
}
@@ -1120,39 +1249,30 @@ void login_auth_ok(struct login_session_data* sd)
if( server_num == 0 )
{// if no char-server, don't send void list of servers, just disconnect the player with proper message
ShowStatus("Connection refused: there is no char-server online (account: %s).\n", sd->userid);
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = 1; // 01 = Server closed
- WFIFOSET(fd,3);
+ login->connection_problem(fd, 1); // 01 = server closed
return;
}
{
- struct online_login_data* data = (struct online_login_data*)idb_get(online_db, sd->account_id);
+ struct online_login_data* data = (struct online_login_data*)idb_get(login->online_db, sd->account_id);
if( data )
{// account is already marked as online!
if( data->char_server > -1 )
{// Request char servers to kick this account out. [Skotlex]
- uint8 buf[6];
ShowNotice("User '%s' is already online - Rejected.\n", sd->userid);
- WBUFW(buf,0) = 0x2734;
- WBUFL(buf,2) = sd->account_id;
- charif_sendallwos(-1, buf, 6);
+ login->kick(sd);
if( data->waiting_disconnect == INVALID_TIMER )
- data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0);
+ data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, login->waiting_disconnect_timer, sd->account_id, 0);
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = 8; // 08 = Server still recognizes your last login
- WFIFOSET(fd,3);
+ login->connection_problem(fd, 8); // 08 = Server still recognizes your last login
return;
}
else
if( data->char_server == -1 )
{// client has authed but did not access char-server yet
// wipe previous session
- idb_remove(auth_db, sd->account_id);
- remove_online_user(sd->account_id);
+ idb_remove(login->auth_db, sd->account_id);
+ login->remove_online_user(sd->account_id);
data = NULL;
}
}
@@ -1177,24 +1297,24 @@ void login_auth_ok(struct login_session_data* sd)
if( !session_isValid(server[i].fd) )
continue;
- subnet_char_ip = lan_subnetcheck(ip); // Advanced subnet check [LuzZza]
+ subnet_char_ip = login->lan_subnetcheck(ip); // Advanced subnet check [LuzZza]
WFIFOL(fd,47+n*32) = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip);
WFIFOW(fd,47+n*32+4) = ntows(htons(server[i].port)); // [!] LE byte order here [!]
memcpy(WFIFOP(fd,47+n*32+6), server[i].name, 20);
WFIFOW(fd,47+n*32+26) = server[i].users;
-
+
if( server[i].type == CST_PAYING && sd->expiration_time > time(NULL) )
WFIFOW(fd,47+n*32+28) = CST_NORMAL;
else
WFIFOW(fd,47+n*32+28) = server[i].type;
-
+
WFIFOW(fd,47+n*32+30) = server[i].new_;
n++;
}
WFIFOSET(fd,47+32*server_num);
// create temporary auth entry
- CREATE(node, struct auth_node, 1);
+ CREATE(node, struct login_auth_node, 1);
node->account_id = sd->account_id;
node->login_id1 = sd->login_id1;
node->login_id2 = sd->login_id2;
@@ -1204,16 +1324,16 @@ void login_auth_ok(struct login_session_data* sd)
node->clienttype = sd->clienttype;
node->group_id = sd->group_id;
node->expiration_time = sd->expiration_time;
- idb_put(auth_db, sd->account_id, node);
+ idb_put(login->auth_db, sd->account_id, node);
{
struct online_login_data* data;
// mark client as 'online'
- data = add_online_user(-1, sd->account_id);
+ data = login->add_online_user(-1, sd->account_id);
// schedule deletion of this node
- data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0);
+ data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, login->waiting_disconnect_timer, sd->account_id, 0);
}
}
@@ -1284,11 +1404,194 @@ void login_auth_failed(struct login_session_data* sd, int result)
#endif
}
+void login_login_error(int fd, uint8 status)
+{
+ WFIFOHEAD(fd,23);
+ WFIFOW(fd,0) = 0x6a;
+ WFIFOB(fd,2) = status;
+ WFIFOSET(fd,23);
+}
+
+void login_parse_ping(int fd, struct login_session_data* sd)
+{
+ RFIFOSKIP(fd,26);
+}
+
+void login_parse_client_md5(int fd, struct login_session_data* sd)
+{
+ sd->has_client_hash = 1;
+ memcpy(sd->client_hash, RFIFOP(fd, 2), 16);
+
+ RFIFOSKIP(fd,18);
+}
+
+bool login_parse_client_login(int fd, struct login_session_data* sd, const char *const ip)
+{
+ uint32 version;
+ char username[NAME_LENGTH];
+ char password[PASSWD_LEN];
+ unsigned char passhash[16];
+ uint8 clienttype;
+ int result;
+ uint16 command = RFIFOW(fd,0);
+ bool israwpass = (command==0x0064 || command==0x0277 || command==0x02b0 || command == 0x0825);
+
+ // Shinryo: For the time being, just use token as password.
+ if(command == 0x0825)
+ {
+ char *accname = (char *)RFIFOP(fd, 9);
+ char *token = (char *)RFIFOP(fd, 0x5C);
+ size_t uAccLen = strlen(accname);
+ size_t uTokenLen = RFIFOREST(fd) - 0x5C;
+
+ version = RFIFOL(fd,4);
+
+ if(uAccLen <= 0 || uTokenLen <= 0) {
+ login->auth_failed(sd, 3);
+ return true;
+ }
+
+ safestrncpy(username, accname, NAME_LENGTH);
+ safestrncpy(password, token, min(uTokenLen+1, PASSWD_LEN)); // Variable-length field, don't copy more than necessary
+ clienttype = RFIFOB(fd, 8);
+ }
+ else
+ {
+ version = RFIFOL(fd,2);
+ safestrncpy(username, (const char*)RFIFOP(fd,6), NAME_LENGTH);
+ if( israwpass )
+ {
+ safestrncpy(password, (const char*)RFIFOP(fd,30), NAME_LENGTH);
+ clienttype = RFIFOB(fd,54);
+ }
+ else
+ {
+ memcpy(passhash, RFIFOP(fd,30), 16);
+ clienttype = RFIFOB(fd,46);
+ }
+ }
+ RFIFOSKIP(fd,RFIFOREST(fd)); // assume no other packet was sent
+
+ sd->clienttype = clienttype;
+ sd->version = version;
+ safestrncpy(sd->userid, username, NAME_LENGTH);
+ if( israwpass )
+ {
+ ShowStatus("Request for connection of %s (ip: %s).\n", sd->userid, ip);
+ safestrncpy(sd->passwd, password, PASSWD_LEN);
+ if( login_config.use_md5_passwds )
+ MD5_String(sd->passwd, sd->passwd);
+ sd->passwdenc = 0;
+ }
+ else
+ {
+ ShowStatus("Request for connection (passwdenc mode) of %s (ip: %s).\n", sd->userid, ip);
+ bin2hex(sd->passwd, passhash, 16); // raw binary data here!
+ sd->passwdenc = PASSWORDENC;
+ }
+
+ if( sd->passwdenc != 0 && login_config.use_md5_passwds )
+ {
+ login->auth_failed(sd, 3); // send "rejected from server"
+ return true;
+ }
+
+ result = login->mmo_auth(sd, false);
+
+ if( result == -1 )
+ login->auth_ok(sd);
+ else
+ login->auth_failed(sd, result);
+ return false;
+}
+
+void login_send_coding_key(int fd, struct login_session_data* sd)
+{
+ WFIFOHEAD(fd,4 + sd->md5keylen);
+ WFIFOW(fd,0) = 0x01dc;
+ WFIFOW(fd,2) = 4 + sd->md5keylen;
+ memcpy(WFIFOP(fd,4), sd->md5key, sd->md5keylen);
+ WFIFOSET(fd,WFIFOW(fd,2));
+}
+
+void login_parse_request_coding_key(int fd, struct login_session_data* sd)
+{
+ memset(sd->md5key, '\0', sizeof(sd->md5key));
+ sd->md5keylen = (uint16)(12 + rnd() % 4);
+ MD5_Salt(sd->md5keylen, sd->md5key);
+
+ login->send_coding_key(fd, sd);
+}
+
+void login_char_server_connection_status(int fd, struct login_session_data* sd, uint8 status)
+{
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x2711;
+ WFIFOB(fd,2) = status;
+ WFIFOSET(fd,3);
+}
+
+void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip)
+{
+ char server_name[20];
+ char message[256];
+ uint32 server_ip;
+ uint16 server_port;
+ uint16 type;
+ uint16 new_;
+ int result;
+
+ safestrncpy(sd->userid, (char*)RFIFOP(fd,2), NAME_LENGTH);
+ safestrncpy(sd->passwd, (char*)RFIFOP(fd,26), NAME_LENGTH);
+ if( login_config.use_md5_passwds )
+ MD5_String(sd->passwd, sd->passwd);
+ sd->passwdenc = 0;
+ sd->version = login_config.client_version_to_connect; // hack to skip version check
+ server_ip = ntohl(RFIFOL(fd,54));
+ server_port = ntohs(RFIFOW(fd,58));
+ safestrncpy(server_name, (char*)RFIFOP(fd,60), 20);
+ type = RFIFOW(fd,82);
+ new_ = RFIFOW(fd,84);
+ RFIFOSKIP(fd,86);
+
+ 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(session[fd]->client_addr, sd->userid, 100, message);
+
+ result = login->mmo_auth(sd, true);
+ if( runflag == LOGINSERVER_ST_RUNNING &&
+ result == -1 &&
+ sd->sex == 'S' &&
+ sd->account_id >= 0 && sd->account_id < ARRAYLENGTH(server) &&
+ !session_isValid(server[sd->account_id].fd) )
+ {
+ 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_;
+
+ session[fd]->func_parse = login->parse_fromchar;
+ session[fd]->flag.server = 1;
+ realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+
+ // send connection success
+ login->char_server_connection_status(fd, sd, 0);
+ }
+ else
+ {
+ ShowNotice("Connection of the char-server '%s' REFUSED.\n", server_name);
+ login->char_server_connection_status(fd, sd, 3);
+ }
+}
//----------------------------------------------------------------------------------------
// Default packet parsing (normal players or char-server connection requests)
//----------------------------------------------------------------------------------------
-int parse_login(int fd)
+int login_parse_login(int fd)
{
struct login_session_data* sd = (struct login_session_data*)session[fd]->session_data;
int result;
@@ -1311,10 +1614,7 @@ int parse_login(int fd)
{
ShowStatus("Connection refused: IP isn't authorized (deny/allow, ip: %s).\n", ip);
login_log(ipl, "unknown", -3, "ip banned");
- WFIFOHEAD(fd,23);
- WFIFOW(fd,0) = 0x6a;
- WFIFOB(fd,2) = 3; // 3 = Rejected from Server
- WFIFOSET(fd,23);
+ login->login_error(fd, 3); // 3 = Rejected from Server
set_eof(fd);
return 0;
}
@@ -1334,13 +1634,13 @@ int parse_login(int fd)
if( result == 2 ) return 0;
}
}
-
+
switch( command ) {
- case 0x0200: // New alive packet: structure: 0x200 <account.userid>.24B. used to verify if client is always alive.
+ case 0x0200: // New alive packet: structure: 0x200 <account.userid>.24B. used to verify if client is always alive.
if (RFIFOREST(fd) < 26)
return 0;
- RFIFOSKIP(fd,26);
+ login->parse_ping(fd, sd);
break;
// client md5 hash (binary)
@@ -1348,10 +1648,7 @@ int parse_login(int fd)
if (RFIFOREST(fd) < 18)
return 0;
- sd->has_client_hash = 1;
- memcpy(sd->client_hash, RFIFOP(fd, 2), 16);
-
- RFIFOSKIP(fd,18);
+ login->parse_client_md5(fd, sd);
break;
// request client login (raw password)
@@ -1376,159 +1673,23 @@ int parse_login(int fd)
return 0;
}
{
- uint32 version;
- char username[NAME_LENGTH];
- char password[PASSWD_LEN];
- unsigned char passhash[16];
- uint8 clienttype;
- bool israwpass = (command==0x0064 || command==0x0277 || command==0x02b0 || command == 0x0825);
-
- // Shinryo: For the time being, just use token as password.
- if(command == 0x0825)
- {
- char *accname = (char *)RFIFOP(fd, 9);
- char *token = (char *)RFIFOP(fd, 0x5C);
- size_t uAccLen = strlen(accname);
- size_t uTokenLen = RFIFOREST(fd) - 0x5C;
-
- version = RFIFOL(fd,4);
-
- if(uAccLen <= 0 || uTokenLen <= 0) {
- login_auth_failed(sd, 3);
- return 0;
- }
-
- safestrncpy(username, accname, NAME_LENGTH);
- safestrncpy(password, token, min(uTokenLen+1, PASSWD_LEN)); // Variable-length field, don't copy more than necessary
- clienttype = RFIFOB(fd, 8);
- }
- else
- {
- version = RFIFOL(fd,2);
- safestrncpy(username, (const char*)RFIFOP(fd,6), NAME_LENGTH);
- if( israwpass )
- {
- safestrncpy(password, (const char*)RFIFOP(fd,30), NAME_LENGTH);
- clienttype = RFIFOB(fd,54);
- }
- else
- {
- memcpy(passhash, RFIFOP(fd,30), 16);
- clienttype = RFIFOB(fd,46);
- }
- }
- RFIFOSKIP(fd,RFIFOREST(fd)); // assume no other packet was sent
-
- sd->clienttype = clienttype;
- sd->version = version;
- safestrncpy(sd->userid, username, NAME_LENGTH);
- if( israwpass )
- {
- ShowStatus("Request for connection of %s (ip: %s).\n", sd->userid, ip);
- safestrncpy(sd->passwd, password, PASSWD_LEN);
- if( login_config.use_md5_passwds )
- MD5_String(sd->passwd, sd->passwd);
- sd->passwdenc = 0;
- }
- else
- {
- ShowStatus("Request for connection (passwdenc mode) of %s (ip: %s).\n", sd->userid, ip);
- bin2hex(sd->passwd, passhash, 16); // raw binary data here!
- sd->passwdenc = PASSWORDENC;
- }
-
- if( sd->passwdenc != 0 && login_config.use_md5_passwds )
- {
- login_auth_failed(sd, 3); // send "rejected from server"
+ if (login->parse_client_login(fd, sd, ip))
return 0;
- }
-
- result = mmo_auth(sd, false);
-
- if( result == -1 )
- login_auth_ok(sd);
- else
- login_auth_failed(sd, result);
}
break;
- case 0x01db: // Sending request of the coding key
+ case 0x01db: // Sending request of the coding key
RFIFOSKIP(fd,2);
{
- memset(sd->md5key, '\0', sizeof(sd->md5key));
- sd->md5keylen = (uint16)(12 + rnd() % 4);
- MD5_Salt(sd->md5keylen, sd->md5key);
-
- WFIFOHEAD(fd,4 + sd->md5keylen);
- WFIFOW(fd,0) = 0x01dc;
- WFIFOW(fd,2) = 4 + sd->md5keylen;
- memcpy(WFIFOP(fd,4), sd->md5key, sd->md5keylen);
- WFIFOSET(fd,WFIFOW(fd,2));
+ login->parse_request_coding_key(fd, sd);
}
break;
- case 0x2710: // Connection request of a char-server
+ case 0x2710: // Connection request of a char-server
if (RFIFOREST(fd) < 86)
return 0;
{
- char server_name[20];
- char message[256];
- uint32 server_ip;
- uint16 server_port;
- uint16 type;
- uint16 new_;
-
- safestrncpy(sd->userid, (char*)RFIFOP(fd,2), NAME_LENGTH);
- safestrncpy(sd->passwd, (char*)RFIFOP(fd,26), NAME_LENGTH);
- if( login_config.use_md5_passwds )
- MD5_String(sd->passwd, sd->passwd);
- sd->passwdenc = 0;
- sd->version = login_config.client_version_to_connect; // hack to skip version check
- server_ip = ntohl(RFIFOL(fd,54));
- server_port = ntohs(RFIFOW(fd,58));
- safestrncpy(server_name, (char*)RFIFOP(fd,60), 20);
- type = RFIFOW(fd,82);
- new_ = RFIFOW(fd,84);
- RFIFOSKIP(fd,86);
-
- 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(session[fd]->client_addr, sd->userid, 100, message);
-
- result = mmo_auth(sd, true);
- if( runflag == LOGINSERVER_ST_RUNNING &&
- result == -1 &&
- sd->sex == 'S' &&
- sd->account_id >= 0 && sd->account_id < ARRAYLENGTH(server) &&
- !session_isValid(server[sd->account_id].fd) )
- {
- 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_;
-
- session[fd]->func_parse = parse_fromchar;
- session[fd]->flag.server = 1;
- realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
-
- // send connection success
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x2711;
- WFIFOB(fd,2) = 0;
- WFIFOSET(fd,3);
- }
- else
- {
- ShowNotice("Connection of the char-server '%s' REFUSED.\n", server_name);
- WFIFOHEAD(fd,3);
- WFIFOW(fd,0) = 0x2711;
- WFIFOB(fd,2) = 3;
- WFIFOSET(fd,3);
- }
+ login->parse_request_connection(fd, sd, ip);
}
return 0; // processing will continue elsewhere
@@ -1558,6 +1719,8 @@ void login_set_defaults()
login_config.min_group_id_to_connect = -1;
login_config.check_client_version = false;
login_config.client_version_to_connect = 20;
+ login_config.allowed_regs = 1;
+ login_config.time_allowed = 10;
login_config.ipban = true;
login_config.dynamic_pass_failure_ban = true;
@@ -1569,6 +1732,7 @@ void login_set_defaults()
login_config.client_hash_check = 0;
login_config.client_hash_nodes = NULL;
+ login_config.subnet_count = 0;
}
//-----------------------------------
@@ -1630,9 +1794,9 @@ int login_config_read(const char* cfgName)
else if(!strcmpi(w1, "date_format"))
safestrncpy(login_config.date_format, w2, sizeof(login_config.date_format));
else if(!strcmpi(w1, "allowed_regs")) //account flood protection system
- allowed_regs = atoi(w2);
+ login_config.allowed_regs = atoi(w2);
else if(!strcmpi(w1, "time_allowed"))
- time_allowed = atoi(w2);
+ login_config.time_allowed = atoi(w2);
else if(!strcmpi(w1, "use_dnsbl"))
login_config.use_dnsbl = (bool)config_switch(w2);
else if(!strcmpi(w1, "dnsbl_servers"))
@@ -1646,6 +1810,7 @@ int login_config_read(const char* cfgName)
else if(!strcmpi(w1, "client_hash")) {
int group = 0;
char md5[33];
+ memset(md5, '\0', 33);
if (sscanf(w2, "%d, %32s", &group, md5) == 2) {
struct client_hash_node *nnode;
@@ -1678,10 +1843,11 @@ int login_config_read(const char* cfgName)
else
{
AccountDB* db = account_engine[0].db;
- if( db )
+ if (db)
db->set_property(db, w1, w2);
ipban_config_read(w1, w2);
loginlog_config_read(w1, w2);
+ HPM->parseConf(w1, w2, HPCT_LOGIN);
}
}
fclose(fp);
@@ -1697,9 +1863,9 @@ int do_final(void) {
struct client_hash_node *hn = login_config.client_hash_nodes;
ShowStatus("Terminating...\n");
-
+
HPM->event(HPET_FINAL);
-
+
while (hn) {
struct client_hash_node *tmp = hn;
hn = hn->next;
@@ -1719,18 +1885,22 @@ int do_final(void) {
account_engine[0].db = NULL;
}
accounts = NULL; // destroyed in account_engine
- online_db->destroy(online_db, NULL);
- auth_db->destroy(auth_db, NULL);
-
+ 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);
- if( login_fd != -1 )
+ if( login->fd != -1 )
{
- do_close(login_fd);
- login_fd = -1;
+ do_close(login->fd);
+ login->fd = -1;
}
+ HPM_login_do_final();
+
+ HPM->event(HPET_POST_FINAL);
+
ShowStatus("Finished.\n");
return EXIT_SUCCESS;
}
@@ -1749,7 +1919,7 @@ void set_server_type(void) {
/// Called when a terminate signal is received.
-void do_shutdown(void)
+void do_shutdown_login(void)
{
if( runflag != LOGINSERVER_ST_SHUTDOWN )
{
@@ -1764,6 +1934,10 @@ void do_shutdown(void)
}
}
+void login_hp_symbols(void) {
+ HPM->share(account_db_sql_up(accounts),"sql_handle");
+ HPM->share(login,"login");
+}
//------------------------------
// Login server initialization
@@ -1774,12 +1948,43 @@ int do_init(int argc, char** argv)
// initialize engine (to accept config settings)
account_engine[0].db = account_engine[0].constructor();
+ accounts = account_engine[0].db;
+ if( accounts == NULL ) {
+ ShowFatalError("do_init: account engine 'sql' not found.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ login_defaults();
// read login-server configuration
login_set_defaults();
+
+ HPM_login_do_init();
+ HPM->symbol_defaults_sub = login_hp_symbols;
+ HPM->config_read(NULL, 0);
+#if 0
+ /* TODO: Move to common code */
+ for( i = 1; i < argc; i++ ) {
+ const char* arg = argv[i];
+ if( strcmp(arg, "--load-plugin") == 0 ) {
+ if( map->arg_next_value(arg, i, argc, true) ) {
+ RECREATE(load_extras, char *, ++load_extras_count);
+ load_extras[load_extras_count-1] = argv[++i];
+ }
+ }
+ }
+ HPM->config_read((const char * const *)load_extras, load_extras_count);
+ if (load_extras) {
+ aFree(load_extras);
+ load_extras = NULL;
+ load_extras_count = 0;
+ }
+#endif
+ HPM->event(HPET_PRE_INIT);
+
login_config_read((argc > 1) ? argv[1] : LOGIN_CONF_NAME);
- login_lan_config_read((argc > 2) ? argv[2] : LAN_CONF_NAME);
-
+ login->lan_config_read((argc > 2) ? argv[2] : LAN_CONF_NAME);
+
for( i = 0; i < ARRAYLENGTH(server); ++i )
chrif_server_init(i);
@@ -1789,59 +1994,115 @@ int do_init(int argc, char** argv)
// initialize static and dynamic ipban system
ipban_init();
-
+
// Online user database init
- online_db = idb_alloc(DB_OPT_RELEASE_DATA);
- timer->add_func_list(waiting_disconnect_timer, "waiting_disconnect_timer");
+ login->online_db = idb_alloc(DB_OPT_RELEASE_DATA);
+ timer->add_func_list(login->waiting_disconnect_timer, "login->waiting_disconnect_timer");
// Interserver auth init
- auth_db = idb_alloc(DB_OPT_RELEASE_DATA);
+ login->auth_db = idb_alloc(DB_OPT_RELEASE_DATA);
- // set default parser as parse_login function
- set_defaultparse(parse_login);
+ // set default parser as login_parse_login function
+ set_defaultparse(login->parse_login);
// every 10 minutes cleanup online account db.
- timer->add_func_list(online_data_cleanup, "online_data_cleanup");
- timer->add_interval(timer->gettick() + 600*1000, online_data_cleanup, 0, 0, 600*1000);
+ timer->add_func_list(login->online_data_cleanup, "login->online_data_cleanup");
+ timer->add_interval(timer->gettick() + 600*1000, login->online_data_cleanup, 0, 0, 600*1000);
// add timer to detect ip address change and perform update
if (login_config.ip_sync_interval) {
- timer->add_func_list(sync_ip_addresses, "sync_ip_addresses");
- timer->add_interval(timer->gettick() + login_config.ip_sync_interval, sync_ip_addresses, 0, 0, login_config.ip_sync_interval);
+ timer->add_func_list(login->sync_ip_addresses, "login->sync_ip_addresses");
+ timer->add_interval(timer->gettick() + login_config.ip_sync_interval, login->sync_ip_addresses, 0, 0, login_config.ip_sync_interval);
}
// Account database init
- accounts = account_engine[0].db;
- if( accounts == NULL ) {
- ShowFatalError("do_init: account engine 'sql' not found.\n");
+ if(!accounts->init(accounts)) {
+ ShowFatalError("do_init: Failed to initialize account engine 'sql'.\n");
exit(EXIT_FAILURE);
- } else {
-
- if(!accounts->init(accounts)) {
- ShowFatalError("do_init: Failed to initialize account engine 'sql'.\n");
- exit(EXIT_FAILURE);
- }
}
- HPM->share(account_db_sql_up(accounts),"sql_handle");
- HPM->config_read(NULL, 0);
HPM->event(HPET_INIT);
-
+
// server port open & binding
- if( (login_fd = make_listen_bind(login_config.login_ip,login_config.login_port)) == -1 ) {
+ if( (login->fd = make_listen_bind(login_config.login_ip,login_config.login_port)) == -1 ) {
ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",login_config.login_port);
exit(EXIT_FAILURE);
}
-
+
if( runflag != CORE_ST_STOP ) {
- shutdown_callback = do_shutdown;
+ shutdown_callback = do_shutdown_login;
runflag = LOGINSERVER_ST_RUNNING;
}
-
+
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");
-
+
HPM->event(HPET_READY);
-
+
return 0;
}
+
+void login_defaults(void) {
+ login = &login_s;
+
+ login->lc = &login_config;
+ login->accounts = accounts;
+
+ login->mmo_auth = login_mmo_auth;
+ login->mmo_auth_new = login_mmo_auth_new;
+ login->waiting_disconnect_timer = login_waiting_disconnect_timer;
+ login->create_online_user = login_create_online_user;
+ login->add_online_user = login_add_online_user;
+ login->remove_online_user = login_remove_online_user;
+ login->online_db_setoffline = login_online_db_setoffline;
+ login->online_data_cleanup_sub = login_online_data_cleanup_sub;
+ login->online_data_cleanup = login_online_data_cleanup;
+ login->sync_ip_addresses = login_sync_ip_addresses;
+ login->check_encrypted = login_check_encrypted;
+ login->check_password = login_check_password;
+ login->lan_subnetcheck = login_lan_subnetcheck;
+ login->lan_config_read = login_lan_config_read;
+
+ login->fromchar_auth_ack = login_fromchar_auth_ack;
+ login->fromchar_accinfo = login_fromchar_accinfo;
+ login->fromchar_account = login_fromchar_account;
+ login->fromchar_account_update_other = login_fromchar_account_update_other;
+ login->fromchar_ban = login_fromchar_ban;
+ login->fromchar_change_sex_other = login_fromchar_change_sex_other;
+ login->fromchar_pong = login_fromchar_pong;
+ login->fromchar_parse_auth = login_fromchar_parse_auth;
+ login->fromchar_parse_update_users = login_fromchar_parse_update_users;
+ login->fromchar_parse_request_change_email = login_fromchar_parse_request_change_email;
+ login->fromchar_parse_account_data = login_fromchar_parse_account_data;
+ login->fromchar_parse_ping = login_fromchar_parse_ping;
+ login->fromchar_parse_change_email = login_fromchar_parse_change_email;
+ login->fromchar_parse_account_update = login_fromchar_parse_account_update;
+ login->fromchar_parse_ban = login_fromchar_parse_ban;
+ login->fromchar_parse_change_sex = login_fromchar_parse_change_sex;
+ login->fromchar_parse_account_reg2 = login_fromchar_parse_account_reg2;
+ login->fromchar_parse_unban = login_fromchar_parse_unban;
+ login->fromchar_parse_account_online = login_fromchar_parse_account_online;
+ login->fromchar_parse_account_offline = login_fromchar_parse_account_offline;
+ login->fromchar_parse_online_accounts = login_fromchar_parse_online_accounts;
+ login->fromchar_parse_request_account_reg2 = login_fromchar_parse_request_account_reg2;
+ login->fromchar_parse_update_wan_ip = login_fromchar_parse_update_wan_ip;
+ login->fromchar_parse_all_offline = login_fromchar_parse_all_offline;
+ login->fromchar_parse_change_pincode = login_fromchar_parse_change_pincode;
+ login->fromchar_parse_wrong_pincode = login_fromchar_parse_wrong_pincode;
+ login->fromchar_parse_accinfo = login_fromchar_parse_accinfo;
+
+ login->parse_fromchar = login_parse_fromchar;
+ login->parse_login = login_parse_login;
+ login->parse_ping = login_parse_ping;
+ login->parse_client_md5 = login_parse_client_md5;
+ login->parse_client_login = login_parse_client_login;
+ login->parse_request_coding_key = login_parse_request_coding_key;
+ login->parse_request_connection = login_parse_request_connection;
+ login->auth_ok = login_auth_ok;
+ login->auth_failed = login_auth_failed;
+ login->char_server_connection_status = login_char_server_connection_status;
+ login->connection_problem = login_connection_problem;
+ login->kick = login_kick;
+ login->login_error = login_login_error;
+ login->send_coding_key = login_send_coding_key;
+}
diff --git a/src/login/login.h b/src/login/login.h
index 9b9d1e82c..4c9bbd8b7 100644
--- a/src/login/login.h
+++ b/src/login/login.h
@@ -8,6 +8,9 @@
#include "../common/core.h" // CORE_ST_LAST
#include "../common/mmo.h" // NAME_LENGTH,SEX_*
+struct mmo_account;
+struct AccountDB;
+
enum E_LOGINSERVER_ST
{
LOGINSERVER_ST_RUNNING = CORE_ST_LAST,
@@ -43,7 +46,7 @@ struct login_session_data {
int has_client_hash;
int fd;
-
+
time_t expiration_time;
};
@@ -66,30 +69,61 @@ struct client_hash_node {
struct Login_Config {
- uint32 login_ip; // the address to bind to
- uint16 login_port; // the port to bind to
- unsigned int ipban_cleanup_interval; // interval (in seconds) to clean up expired IP bans
- unsigned int ip_sync_interval; // interval (in minutes) to execute a DNS/IP update (for dynamic IPs)
- bool log_login; // whether to log login server actions or not
- char date_format[32]; // date format used in messages
- bool new_account_flag,new_acc_length_limit; // auto-registration via _M/_F ? / if yes minimum length is 4?
- int start_limited_time; // new account expiration time (-1: unlimited)
- bool use_md5_passwds; // work with password hashes instead of plaintext passwords?
- int group_id_to_connect; // required group id to connect
- int min_group_id_to_connect; // minimum group id to connect
- bool check_client_version; // check the clientversion set in the clientinfo ?
- uint32 client_version_to_connect; // the client version needed to connect (if checking is enabled)
-
- bool ipban; // perform IP blocking (via contents of `ipbanlist`) ?
- bool dynamic_pass_failure_ban; // automatic IP blocking due to failed login attemps ?
- unsigned int dynamic_pass_failure_ban_interval; // how far to scan the loginlog for password failures
- unsigned int dynamic_pass_failure_ban_limit; // number of failures needed to trigger the ipban
- unsigned int dynamic_pass_failure_ban_duration; // duration of the ipban
- bool use_dnsbl; // dns blacklist blocking ?
- char dnsbl_servs[1024]; // comma-separated list of dnsbl servers
-
- int client_hash_check; // flags for checking client md5
- struct client_hash_node *client_hash_nodes; // linked list containg md5 hash for each gm group
+ uint32 login_ip; ///< the address to bind to
+ uint16 login_port; ///< the port to bind to
+ unsigned int ipban_cleanup_interval; ///< interval (in seconds) to clean up expired IP bans
+ unsigned int ip_sync_interval; ///< interval (in minutes) to execute a DNS/IP update (for dynamic IPs)
+ bool log_login; ///< whether to log login server actions or not
+ char date_format[32]; ///< date format used in messages
+ bool new_account_flag,new_acc_length_limit; ///< auto-registration via _M/_F ? / if yes minimum length is 4?
+ int start_limited_time; ///< new account expiration time (-1: unlimited)
+ bool use_md5_passwds; ///< work with password hashes instead of plaintext passwords?
+ int group_id_to_connect; ///< required group id to connect
+ int min_group_id_to_connect; ///< minimum group id to connect
+ bool check_client_version; ///< check the clientversion set in the clientinfo ?
+ uint32 client_version_to_connect; ///< the client version needed to connect (if checking is enabled)
+ int allowed_regs; ///< account registration flood protection [Kevin]
+ int time_allowed; ///< time in seconds
+
+ bool ipban; ///< perform IP blocking (via contents of `ipbanlist`) ?
+ bool dynamic_pass_failure_ban; ///< automatic IP blocking due to failed login attemps ?
+ unsigned int dynamic_pass_failure_ban_interval; ///< how far to scan the loginlog for password failures
+ unsigned int dynamic_pass_failure_ban_limit; ///< number of failures needed to trigger the ipban
+ unsigned int dynamic_pass_failure_ban_duration; ///< duration of the ipban
+ bool use_dnsbl; ///< dns blacklist blocking ?
+ char dnsbl_servs[1024]; ///< comma-separated list of dnsbl servers
+
+ int client_hash_check; ///< flags for checking client md5
+ struct client_hash_node *client_hash_nodes; ///< linked list containg md5 hash for each gm group
+
+ /// Advanced subnet check [LuzZza]
+ struct s_subnet {
+ uint32 mask;
+ uint32 char_ip;
+ uint32 map_ip;
+ } subnet[16];
+ int subnet_count;
+};
+
+struct login_auth_node {
+ int account_id;
+ uint32 login_id1;
+ uint32 login_id2;
+ uint32 ip;
+ char sex;
+ uint32 version;
+ uint8 clienttype;
+ int group_id;
+ time_t expiration_time;
+};
+
+//-----------------------------------------------------
+// Online User Database [Wizputer]
+//-----------------------------------------------------
+struct online_login_data {
+ int account_id;
+ int waiting_disconnect;
+ int char_server;
};
#define sex_num2str(num) ( ((num) == SEX_FEMALE) ? 'F' : ((num) == SEX_MALE) ? 'M' : 'S' )
@@ -99,5 +133,75 @@ struct Login_Config {
extern struct mmo_char_server server[MAX_SERVERS];
extern struct Login_Config login_config;
+/**
+ * Login.c Interface
+ **/
+struct login_interface {
+ DBMap* auth_db;
+ DBMap* online_db;
+ int fd;
+ struct Login_Config *lc;
+ struct AccountDB* accounts;
+
+ 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);
+ int (*waiting_disconnect_timer) (int tid, int64 tick, int id, intptr_t data);
+ DBData (*create_online_user) (DBKey key, va_list args);
+ struct online_login_data* (*add_online_user) (int char_server, int account_id);
+ void (*remove_online_user) (int account_id);
+ int (*online_db_setoffline) (DBKey key, DBData *data, va_list ap);
+ int (*online_data_cleanup_sub) (DBKey key, DBData *data, va_list ap);
+ int (*online_data_cleanup) (int tid, int64 tick, int id, intptr_t data);
+ int (*sync_ip_addresses) (int tid, int64 tick, int id, intptr_t data);
+ bool (*check_encrypted) (const char* str1, const char* str2, const char* passwd);
+ bool (*check_password) (const char* md5key, int passwdenc, const char* passwd, const char* refpass);
+ int (*lan_subnetcheck) (uint32 ip);
+ int (*lan_config_read) (const char *lancfgName);
+ void (*fromchar_accinfo) (int fd, int account_id, int u_fd, int u_aid, int u_group, int map_fd, struct mmo_account *acc);
+ void (*fromchar_account) (int fd, int account_id, struct mmo_account *acc);
+ void (*fromchar_account_update_other) (int account_id, unsigned int state);
+ void (*fromchar_auth_ack) (int fd, int account_id, uint32 login_id1, uint32 login_id2, uint8 sex, int request_id, struct login_auth_node* node);
+ void (*fromchar_ban) (int account_id, time_t timestamp);
+ void (*fromchar_change_sex_other) (int account_id, char sex);
+ void (*fromchar_pong) (int fd);
+ void (*fromchar_parse_auth) (int fd, int id, const char *ip);
+ void (*fromchar_parse_update_users) (int fd, int id);
+ void (*fromchar_parse_request_change_email) (int fd, int id, const char *ip);
+ void (*fromchar_parse_account_data) (int fd, int id, const char *ip);
+ void (*fromchar_parse_ping) (int fd);
+ void (*fromchar_parse_change_email) (int fd, int id, const char *ip);
+ void (*fromchar_parse_account_update) (int fd, int id, const char *ip);
+ void (*fromchar_parse_ban) (int fd, int id, const char *ip);
+ void (*fromchar_parse_change_sex) (int fd, int id, const char *ip);
+ void (*fromchar_parse_account_reg2) (int fd, int id, const char *ip);
+ void (*fromchar_parse_unban) (int fd, int id, const char *ip);
+ void (*fromchar_parse_account_online) (int fd, int id);
+ void (*fromchar_parse_account_offline) (int fd);
+ void (*fromchar_parse_online_accounts) (int fd, int id);
+ void (*fromchar_parse_request_account_reg2) (int fd);
+ void (*fromchar_parse_update_wan_ip) (int fd, int id);
+ void (*fromchar_parse_all_offline) (int fd, int id);
+ void (*fromchar_parse_change_pincode) (int fd);
+ bool (*fromchar_parse_wrong_pincode) (int fd);
+ void (*fromchar_parse_accinfo) (int fd);
+ int (*parse_fromchar) (int fd);
+ void (*connection_problem) (int fd, uint8 status);
+ void (*kick) (struct login_session_data* sd);
+ void (*auth_ok) (struct login_session_data* sd);
+ void (*auth_failed) (struct login_session_data* sd, int result);
+ void (*login_error) (int fd, uint8 status);
+ void (*parse_ping) (int fd, struct login_session_data* sd);
+ void (*parse_client_md5) (int fd, struct login_session_data* sd);
+ bool (*parse_client_login) (int fd, struct login_session_data* sd, const char *ip);
+ void (*send_coding_key) (int fd, struct login_session_data* sd);
+ void (*parse_request_coding_key) (int fd, struct login_session_data* sd);
+ void (*char_server_connection_status) (int fd, struct login_session_data* sd, uint8 status);
+ void (*parse_request_connection) (int fd, struct login_session_data* sd, const char *ip);
+ int (*parse_login) (int fd);
+};
+
+struct login_interface *login;
+
+void login_defaults(void);
#endif /* LOGIN_LOGIN_H */
diff --git a/src/login/loginlog_sql.c b/src/login/loginlog_sql.c
index 2c0b1cc03..5654b4c5b 100644
--- a/src/login/loginlog_sql.c
+++ b/src/login/loginlog_sql.c
@@ -19,14 +19,14 @@
static char global_db_hostname[32] = "127.0.0.1";
static uint16 global_db_port = 3306;
static char global_db_username[32] = "ragnarok";
-static char global_db_password[32] = "ragnarok";
+static char global_db_password[100] = "ragnarok";
static char global_db_database[32] = "ragnarok";
static char global_codepage[32] = "";
// local sql settings
static char log_db_hostname[32] = "";
static uint16 log_db_port = 0;
static char log_db_username[32] = "";
-static char log_db_password[32] = "";
+static char log_db_password[100] = "";
static char log_db_database[32] = "";
static char log_codepage[32] = "";
static char log_login_db[256] = "loginlog";
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index cb8c979c6..f1cdec538 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -74,11 +74,6 @@ struct HPM_atcommand_list {
struct HPM_atcommand_list *atcommand_list = NULL;
unsigned int atcommand_list_items = 0;
-/**
- * (char*) data name -> (unsigned int) HPMDataCheck[] index
- **/
-DBMap *datacheck_db;
-
bool HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr) {
/* record address */
switch( type ) {
@@ -106,6 +101,18 @@ bool HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataType
ret->HPDataSRCPtr = (void**)(&((struct instance_data *)ptr)->hdata);
ret->hdatac = &((struct instance_data *)ptr)->hdatac;
break;
+ case HPDT_MOBDB:
+ ret->HPDataSRCPtr = (void**)(&((struct mob_db *)ptr)->hdata);
+ ret->hdatac = &((struct mob_db *)ptr)->hdatac;
+ break;
+ case HPDT_MOBDATA:
+ ret->HPDataSRCPtr = (void**)(&((struct mob_data *)ptr)->hdata);
+ ret->hdatac = &((struct mob_data *)ptr)->hdatac;
+ break;
+ case HPDT_ITEMDATA:
+ ret->HPDataSRCPtr = (void**)(&((struct item_data *)ptr)->hdata);
+ ret->hdatac = &((struct item_data *)ptr)->hdatac;
+ break;
default:
return false;
}
@@ -147,29 +154,6 @@ void HPM_map_atcommands(void) {
}
/**
- * Called by HPM->DataCheck on a plugins incoming data, ensures data structs in use are matching!
- **/
-bool HPM_map_DataCheck (struct s_HPMDataCheck *src, unsigned int size, char *name) {
- unsigned int i, j;
-
- for(i = 0; i < size; i++) {
-
- if( !strdb_exists(datacheck_db, src[i].name) ) {
- ShowError("HPMDataCheck:%s: '%s' was not found\n",name,src[i].name);
- return false;
- } else {
- j = strdb_uiget(datacheck_db, src[i].name);/* not double lookup; exists sets cache to found data */
- if( src[i].size != HPMDataCheck[j].size ) {
- ShowWarning("HPMDataCheck:%s: '%s' size mismatch %u != %u\n",name,src[i].name,src[i].size,HPMDataCheck[j].size);
- return false;
- }
- }
- }
-
- return true;
-}
-
-/**
* Adds a new group permission to the HPM-provided list
**/
void HPM_map_add_group_permission(unsigned int pluginID, char *name, unsigned int *mask) {
@@ -183,17 +167,9 @@ void HPM_map_add_group_permission(unsigned int pluginID, char *name, unsigned in
}
void HPM_map_do_init(void) {
- unsigned int i;
-
- /**
- * Populates datacheck_db for easy lookup later on
- **/
- datacheck_db = strdb_alloc(DB_OPT_BASE,0);
-
- for(i = 0; i < HPMDataCheckLen; i++) {
- strdb_uiput(datacheck_db, HPMDataCheck[i].name, i);
- }
-
+ HPM->load_sub = HPM_map_plugin_load_sub;
+ HPM->grabHPDataSub = HPM_map_grabHPData;
+ HPM->datacheck_init(HPMDataCheck, HPMDataCheckLen, HPMDataCheckVer);
}
void HPM_map_do_final(void) {
@@ -211,5 +187,5 @@ void HPM_map_do_final(void) {
if( pcg->HPMpermissions )
aFree(pcg->HPMpermissions);
- db_destroy(datacheck_db);
+ HPM->datacheck_final();
}
diff --git a/src/map/HPMmap.h b/src/map/HPMmap.h
index 99c4224ff..fa2f625c0 100644
--- a/src/map/HPMmap.h
+++ b/src/map/HPMmap.h
@@ -22,8 +22,6 @@ void HPM_map_do_final(void);
void HPM_map_add_group_permission(unsigned int pluginID, char *name, unsigned int *mask);
-bool HPM_map_DataCheck(struct s_HPMDataCheck *src, unsigned int size, char *name);
-
void HPM_map_do_init(void);
#endif /* MAP_HPMMAP_H */
diff --git a/src/map/Makefile.in b/src/map/Makefile.in
index fc58c9d70..ee8b7ac56 100644
--- a/src/map/Makefile.in
+++ b/src/map/Makefile.in
@@ -104,7 +104,7 @@ map-server: ../../map-server@EXEEXT@
../../map-server@EXEEXT@: $(MAP_SERVER_SQL_DEPENDS) Makefile
@echo " LD $(notdir $@)"
- @$(CC) @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_OBJ) $(COMMON_D)/obj_sql/common_sql.a \
+ @$(CC) @STATIC@ @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_OBJ) $(COMMON_D)/obj_sql/common_sql.a \
$(COMMON_D)/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@
# map object files
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index b5e8fa797..330fe6284 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -162,15 +162,15 @@ ACMD(send)
{
int len=0,off,end,type;
long num;
-
+
// read message type as hex number (without the 0x)
if(!message || !*message ||
!((sscanf(message, "len %x", &type)==1 && (len=1))
|| sscanf(message, "%x", &type)==1) ) {
clif->message(fd, msg_txt(900)); // Usage:
- clif->message(fd, msg_txt(901)); // @send len <packet hex number>
- clif->message(fd, msg_txt(902)); // @send <packet hex number> {<value>}*
- clif->message(fd, msg_txt(903)); // Value: <type=B(default),W,L><number> or S<length>"<string>"
+ clif->message(fd, msg_txt(901)); // @send len <packet hex number>
+ clif->message(fd, msg_txt(902)); // @send <packet hex number> {<value>}*
+ clif->message(fd, msg_txt(903)); // Value: <type=B(default),W,L><number> or S<length>"<string>"
return false;
}
@@ -200,14 +200,13 @@ ACMD(send)
} while(0) //define GET_VALUE
if (type > 0 && type < MAX_PACKET_DB) {
-
if(len)
{// show packet length
sprintf(atcmd_output, msg_txt(904), type, packet_db[type].len); // Packet 0x%x length: %d
clif->message(fd, atcmd_output);
return true;
}
-
+
len=packet_db[type].len;
off=2;
if(len == 0)
@@ -222,7 +221,7 @@ ACMD(send)
}
WFIFOHEAD(sd->fd, len);
WFIFOW(sd->fd,0)=TOW(type);
-
+
// parse packet contents
SKIP_VALUE(message);
while(*message != 0 && off < len){
@@ -266,7 +265,7 @@ ACMD(send)
++message;
}
}
-
+
// parse string
++message;
CHECK_EOS(message);
@@ -344,7 +343,7 @@ ACMD(send)
++message;
CHECK_EOS(message);
}
-
+
// terminate the string
if(off < end)
{// fill the rest with 0's
@@ -358,7 +357,7 @@ ACMD(send)
}
SKIP_VALUE(message);
}
-
+
if(packet_db[type].len == -1) {// send dynamic packet
WFIFOW(sd->fd,2)=TOW(off);
WFIFOSET(sd->fd,off);
@@ -388,21 +387,20 @@ ACMD(mapmove) {
unsigned short map_index;
short x = 0, y = 0;
int16 m = -1;
-
+
memset(map_name, '\0', sizeof(map_name));
-
+
if (!message || !*message ||
(sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
-
clif->message(fd, msg_txt(909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
return false;
}
-
+
map_index = mapindex->name2id(map_name);
if (map_index)
m = map->mapindex2mapid(map_index);
-
+
if (!map_index || m < 0) { // m < 0 means on different server or that map is disabled! [Kevin]
clif->message(fd, msg_txt(1)); // Map not found.
return false;
@@ -412,7 +410,7 @@ ACMD(mapmove) {
clif->message(fd, msg_txt(253)); // You already are at your destination!
return false;
}
-
+
if ((x || y) && map->getcell(m, x, y, CELL_CHKNOPASS) && pc_get_group_level(sd) < battle_config.gm_ignore_warpable_area) {
//This is to prevent the pc->setpos call from printing an error.
clif->message(fd, msg_txt(2));
@@ -431,7 +429,7 @@ ACMD(mapmove) {
clif->message(fd, msg_txt(1)); // Map not found.
return false;
}
-
+
clif->message(fd, msg_txt(0)); // Warped.
return true;
}
@@ -441,14 +439,14 @@ ACMD(mapmove) {
*------------------------------------------*/
ACMD(where) {
struct map_session_data* pl_sd;
-
+
memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(910)); // Please enter a player name (usage: @where <char name>).
return false;
}
-
+
pl_sd = map->nick2sd(atcmd_player_name);
if (pl_sd == NULL ||
strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
@@ -457,10 +455,10 @@ ACMD(where) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
clif->message(fd, atcmd_output);
-
+
return true;
}
@@ -489,7 +487,7 @@ ACMD(jumpto) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(247)); // You are not authorized to warp to this map.
return false;
@@ -513,21 +511,21 @@ ACMD(jumpto) {
ACMD(jump)
{
short x = 0, y = 0;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
sscanf(message, "%hd %hd", &x, &y);
-
+
if (map->list[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map.
return false;
}
-
+
if( pc_isdead(sd) ) {
clif->message(fd, msg_txt(864)); // "You cannot use this command when dead."
return false;
}
-
+
if ((x || y) && map->getcell(sd->bl.m, x, y, CELL_CHKNOPASS)) {
//This is to prevent the pc->setpos call from printing an error.
clif->message(fd, msg_txt(2));
@@ -539,7 +537,7 @@ ACMD(jump)
clif->message(fd, msg_txt(253)); // You already are at your destination!
return false;
}
-
+
pc->setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
clif->message(fd, atcmd_output);
@@ -565,25 +563,25 @@ ACMD(who) {
*/
int display_type = 1;
int map_id = -1;
-
+
if (stristr(info->command, "map") != NULL) {
if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map->mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
} else {
sscanf(message, "%23s", player_name);
}
-
+
if (stristr(info->command, "2") != NULL)
display_type = 2;
else if (stristr(info->command, "3") != NULL)
display_type = 3;
-
+
level = pc_get_group_level(sd);
StrBuf->Init(&buf);
-
+
iter = mapit_getallusers();
- for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) {
- if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
+ for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) {
+ if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || pc_isinvisible(pl_sd)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
|| (map_id >= 0 && pl_sd->bl.m != map_id))
continue;
@@ -598,7 +596,7 @@ ACMD(who) {
}
case 3: {
if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
- StrBuf->Printf(&buf, msg_txt(912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
+ StrBuf->Printf(&buf, msg_txt(912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
StrBuf->Printf(&buf, msg_txt(344), pcg->get_name(pl_sd->group)); // "(%s) "
@@ -608,7 +606,7 @@ ACMD(who) {
default: {
struct party_data *p = party->search(pl_sd->status.party_id);
struct guild *g = pl_sd->guild;
-
+
StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
StrBuf->Printf(&buf, msg_txt(344), pcg->get_name(pl_sd->group)); // "(%s) "
@@ -619,13 +617,13 @@ ACMD(who) {
break;
}
}
- clif->message(fd, StrBuf->Value(&buf));
+ clif->colormes(fd, COLOR_DEFAULT, StrBuf->Value(&buf));/** for whatever reason clif->message crashes with some patterns, see bugreport:8186 **/
StrBuf->Clear(&buf);
count++;
}
}
mapit->free(iter);
-
+
if (map_id < 0) {
if (count == 0)
StrBuf->Printf(&buf, msg_txt(28)); // No player found.
@@ -659,65 +657,65 @@ ACMD(whogm)
char player_name[NAME_LENGTH];
struct guild *g;
struct party_data *p;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(match_text, '\0', sizeof(match_text));
memset(player_name, '\0', sizeof(player_name));
-
+
if (sscanf(message, "%199[^\n]", match_text) < 1)
strcpy(match_text, "");
for (j = 0; match_text[j]; j++)
match_text[j] = TOLOWER(match_text[j]);
-
+
count = 0;
level = pc_get_group_level(sd);
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
pl_level = pc_get_group_level(pl_sd);
if (!pl_level)
continue;
-
+
if (match_text[0])
{
memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
for (j = 0; player_name[j]; j++)
player_name[j] = TOLOWER(player_name[j]);
- // search with no case sensitive
+ // search with no case sensitive
if (strstr(player_name, match_text) == NULL)
continue;
}
if (pl_level > level) {
- if (pl_sd->sc.option & OPTION_INVISIBLE)
+ if (pc_isinvisible(pl_sd))
continue;
sprintf(atcmd_output, msg_txt(913), pl_sd->status.name); // Name: %s (GM)
clif->message(fd, atcmd_output);
count++;
continue;
}
-
+
sprintf(atcmd_output, msg_txt(914), // Name: %s (GM:%d) | Location: %s %d %d
pl_sd->status.name, pl_level,
mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
clif->message(fd, atcmd_output);
-
+
sprintf(atcmd_output, msg_txt(915), // BLvl: %d | Job: %s (Lvl: %d)
pl_sd->status.base_level,
pc->job_name(pl_sd->status.class_), pl_sd->status.job_level);
clif->message(fd, atcmd_output);
-
+
p = party->search(pl_sd->status.party_id);
g = pl_sd->guild;
-
- sprintf(atcmd_output,msg_txt(916), // Party: '%s' | Guild: '%s'
- p?p->party.name:msg_txt(917), g?g->name:msg_txt(917)); // None.
-
+
+ sprintf(atcmd_output,msg_txt(916), // Party: '%s' | Guild: '%s'
+ p?p->party.name:msg_txt(917), g?g->name:msg_txt(917)); // None.
+
clif->message(fd, atcmd_output);
count++;
}
mapit->free(iter);
-
+
if (count == 0)
clif->message(fd, msg_txt(150)); // No GM found.
else if (count == 1)
@@ -726,23 +724,23 @@ ACMD(whogm)
sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
clif->message(fd, atcmd_output);
}
-
+
return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD(save) {
-
+ACMD(save)
+{
pc->setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
if (sd->status.pet_id > 0 && sd->pd)
intif->save_petdata(sd->status.account_id, &sd->pd->pet);
-
+
chrif->save(sd,0);
-
+
clif->message(fd, msg_txt(6)); // Your save point has been changed.
-
+
return true;
}
@@ -751,7 +749,7 @@ ACMD(save) {
*------------------------------------------*/
ACMD(load) {
int16 m;
-
+
m = map->mapindex2mapid(sd->status.save_point.map);
if (m >= 0 && map->list[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(249)); // You are not authorized to warp to your save map.
@@ -761,10 +759,10 @@ ACMD(load) {
clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map.
return false;
}
-
+
pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
clif->message(fd, msg_txt(7)); // Warping to save point..
-
+
return true;
}
@@ -774,30 +772,30 @@ ACMD(load) {
ACMD(speed)
{
int speed;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
sprintf(atcmd_output, msg_txt(918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
clif->message(fd, atcmd_output);
return false;
}
-
+
sd->state.permanent_speed = 0;
-
+
if (speed < 0)
sd->base_status.speed = DEFAULT_WALK_SPEED;
else
sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
-
+
if( sd->base_status.speed != DEFAULT_WALK_SPEED ) {
sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
clif->message(fd, msg_txt(8)); // Speed changed.
} else
clif->message(fd, msg_txt(172)); //Speed returned to normal.
-
+
status_calc_bl(&sd->bl, SCB_SPEED);
-
+
return true;
}
@@ -808,14 +806,14 @@ ACMD(storage)
{
if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
return false;
-
+
if (storage->open(sd) == 1) { //Already open.
clif->message(fd, msg_txt(250));
return false;
}
-
+
clif->message(fd, msg_txt(919)); // Storage opened.
-
+
return true;
}
@@ -829,20 +827,20 @@ ACMD(guildstorage)
clif->message(fd, msg_txt(252));
return false;
}
-
+
if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
return false;
-
+
if (sd->state.storage_flag == 1) {
clif->message(fd, msg_txt(250));
return false;
}
-
+
if (sd->state.storage_flag == 2) {
clif->message(fd, msg_txt(251));
return false;
}
-
+
if( gstorage->open(sd) ) {
clif->message(fd, msg_txt(1201)); // Your guild's storage has already been opened by another member, try again later.
return false;
@@ -858,30 +856,30 @@ ACMD(guildstorage)
ACMD(option)
{
int param1 = 0, param2 = 0, param3 = 0;
-
+
if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
{// failed to match the parameters so inform the user of the options
const char* text;
-
+
// attempt to find the setting information for this command
text = atcommand_help_string( info );
-
+
// notify the user of the requirement to enter an option
clif->message(fd, msg_txt(921)); // Please enter at least one option.
-
+
if( text ) {// send the help text associated with this command
clif->messageln( fd, text );
}
-
+
return false;
}
-
+
sd->sc.opt1 = param1;
sd->sc.opt2 = param2;
pc->setoption(sd, param3);
-
+
clif->message(fd, msg_txt(9)); // Options changed.
-
+
return true;
}
@@ -889,17 +887,17 @@ ACMD(option)
*
*------------------------------------------*/
ACMD(hide) {
- if (sd->sc.option & OPTION_INVISIBLE) {
+ if (pc_isinvisible(sd)) {
sd->sc.option &= ~OPTION_INVISIBLE;
if (sd->disguise != -1 )
status->set_viewdata(&sd->bl, sd->disguise);
else
status->set_viewdata(&sd->bl, sd->status.class_);
clif->message(fd, msg_txt(10)); // Invisible: Off
-
+
// increment the number of pvp players on the map
map->list[sd->bl.m].users_pvp++;
-
+
if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank ) {
// register the player for ranking calculations
sd->pvp_timer = timer->add( timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 );
@@ -910,10 +908,10 @@ ACMD(hide) {
sd->sc.option |= OPTION_INVISIBLE;
sd->vd.class_ = INVISIBLE_CLASS;
clif->message(fd, msg_txt(11)); // Invisible: On
-
+
// decrement the number of pvp players on the map
map->list[sd->bl.m].users_pvp--;
-
+
if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {
// unregister the player for ranking
timer->delete( sd->pvp_timer, pc->calc_pvprank_timer );
@@ -921,7 +919,7 @@ ACMD(hide) {
}
}
clif->changeoption(&sd->bl);
-
+
return true;
}
@@ -931,11 +929,11 @@ ACMD(hide) {
ACMD(jobchange) {
int job = 0, upper = 0;
const char* text;
-
+
if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
upper = 0;
-
- if( message ) {
+
+ if( message ) {
int i;
bool found = false;
@@ -946,7 +944,7 @@ ACMD(jobchange) {
found = true;
}
}
-
+
// High Jobs, Babies and Third
for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ){
if (strncmpi(message, pc->job_name(i), 16) == 0) {
@@ -954,7 +952,7 @@ ACMD(jobchange) {
found = true;
}
}
-
+
if (!found) {
text = atcommand_help_string(info);
if (text)
@@ -965,14 +963,14 @@ ACMD(jobchange) {
}
/* WHY DO WE LIST THEM THEN? */
// Deny direct transformation into dummy jobs
- if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER
- || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
- || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
- ) {
+ if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER
+ || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
+ || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
+ ) {
clif->message(fd, msg_txt(923)); //"You can not change to this job by command."
return true;
}
-
+
if (pcdb_checkid(job)) {
if (pc->jobchange(sd, job, upper) == 0)
clif->message(fd, msg_txt(12)); // Your job has been changed.
@@ -982,11 +980,11 @@ ACMD(jobchange) {
}
} else {
text = atcommand_help_string(info);
- if (text)
- clif->messageln(fd, text);
+ if (text)
+ clif->messageln(fd, text);
return false;
}
-
+
return true;
}
@@ -1022,15 +1020,15 @@ ACMD(alive)
ACMD(kami)
{
unsigned int color=0;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if(*(info->command + 4) != 'c' && *(info->command + 4) != 'C') {
if (!message || !*message) {
clif->message(fd, msg_txt(980)); // Please enter a message (usage: @kami <message>).
return false;
}
-
+
sscanf(message, "%199[^\n]", atcmd_output);
if (stristr(info->command, "l") != NULL)
clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
@@ -1041,7 +1039,7 @@ ACMD(kami)
clif->message(fd, msg_txt(981)); // Please enter color and message (usage: @kamic <color> <message>).
return false;
}
-
+
if(color > 0xFFFFFF) {
clif->message(fd, msg_txt(982)); // Invalid color.
return false;
@@ -1057,13 +1055,13 @@ ACMD(kami)
ACMD(heal)
{
int hp = 0, sp = 0; // [Valaris] thanks to fov
-
+
sscanf(message, "%d %d", &hp, &sp);
-
+
// some overflow checks
if( hp == INT_MIN ) hp++;
if( sp == INT_MIN ) sp++;
-
+
if ( hp == 0 && sp == 0 ) {
if (!status_percent_heal(&sd->bl, 100, 100))
clif->message(fd, msg_txt(157)); // HP and SP have already been recovered.
@@ -1071,7 +1069,7 @@ ACMD(heal)
clif->message(fd, msg_txt(17)); // HP, SP recovered.
return true;
}
-
+
if ( hp > 0 && sp >= 0 ) {
if(!status->heal(&sd->bl, hp, sp, 0))
clif->message(fd, msg_txt(157)); // HP and SP are already with the good value.
@@ -1079,14 +1077,14 @@ ACMD(heal)
clif->message(fd, msg_txt(17)); // HP, SP recovered.
return true;
}
-
+
if ( hp < 0 && sp <= 0 ) {
status->damage(NULL, &sd->bl, -hp, -sp, 0, 0);
clif->damage(&sd->bl,&sd->bl, 0, 0, -hp, 0, 4, 0);
clif->message(fd, msg_txt(156)); // HP or/and SP modified.
return true;
}
-
+
//Opposing signs.
if ( hp ) {
if (hp > 0)
@@ -1096,14 +1094,14 @@ ACMD(heal)
clif->damage(&sd->bl,&sd->bl, 0, 0, -hp, 0, 4, 0);
}
}
-
+
if ( sp ) {
if (sp > 0)
status->heal(&sd->bl, 0, sp, 0);
else
status->damage(NULL, &sd->bl, 0, -sp, 0, 0);
}
-
+
clif->message(fd, msg_txt(156)); // HP or/and SP modified.
return true;
}
@@ -1119,7 +1117,7 @@ ACMD(item)
struct item item_tmp;
struct item_data *item_data;
int get_count, i;
-
+
memset(item_name, '\0', sizeof(item_name));
if (!strcmpi(info->command,"itembound") && (!message || !*message || (
@@ -1128,24 +1126,24 @@ ACMD(item)
))) {
clif->message(fd, msg_txt(295)); // Please enter an item name or ID (usage: @itembound <item name/ID> <quantity> <bound_type>).
return false;
- } else if (!message || !*message || (
- sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
- sscanf(message, "%99s %d", item_name, &number) < 1 ))
- {
- clif->message(fd, msg_txt(983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
+ } else if (!message || !*message
+ || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1
+ && sscanf(message, "%99s %d", item_name, &number) < 1
+ )) {
+ clif->message(fd, msg_txt(983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
return false;
}
-
+
if (number <= 0)
number = 1;
-
+
if ((item_data = itemdb->search_name(item_name)) == NULL &&
(item_data = itemdb->exists(atoi(item_name))) == NULL)
{
clif->message(fd, msg_txt(19)); // Invalid item ID or name.
return false;
}
-
+
if(!strcmpi(info->command,"itembound") ) {
if( !(bound >= IBT_MIN && bound <= IBT_MAX) ) {
clif->message(fd, msg_txt(298)); // Invalid bound type
@@ -1178,9 +1176,9 @@ ACMD(item)
clif->message(fd, msg_txt(498)); // Cannot create bounded pet eggs or pet armors.
return false;
}
- get_count = 1;
+ get_count = 1;
}
-
+
for (i = 0; i < number; i += get_count) {
// if not pet egg
if (!pet->create_egg(sd, item_id)) {
@@ -1188,12 +1186,12 @@ ACMD(item)
item_tmp.nameid = item_id;
item_tmp.identify = 1;
item_tmp.bound = (unsigned char)bound;
-
+
if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
clif->additem(sd, 0, 0, flag);
}
}
-
+
if (flag == 0)
clif->message(fd, msg_txt(18)); // Item created.
return true;
@@ -1210,24 +1208,24 @@ ACMD(item2)
int item_id, number = 0, bound = 0;
int identify = 0, refine = 0, attr = 0;
int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
-
+
memset(item_name, '\0', sizeof(item_name));
-
+
if (!strcmpi(info->command,"itembound2") && (!message || !*message || (
sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
sscanf(message, "%99s %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))) {
clif->message(fd, msg_txt(296)); // Please enter all parameters (usage: @itembound2 <item name/ID> <quantity>
clif->message(fd, msg_txt(297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
return false;
- } else if ( !message || !*message || (
- sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
- sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
- )) {
+ } else if ( !message || !*message
+ || ( sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
+ && sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
+ )) {
clif->message(fd, msg_txt(984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
clif->message(fd, msg_txt(985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
return false;
}
-
+
if (number <= 0)
number = 1;
@@ -1240,7 +1238,7 @@ ACMD(item2)
if ((item_data = itemdb->search_name(item_name)) != NULL ||
(item_data = itemdb->exists(atoi(item_name))) != NULL)
item_id = item_data->nameid;
-
+
if (item_id > 500) {
int flag = 0;
int loop, get_count, i;
@@ -1253,7 +1251,7 @@ ACMD(item2)
clif->message(fd, msg_txt(498)); // Cannot create bounded pet eggs or pet armors.
return false;
}
- loop = number;
+ loop = number;
get_count = 1;
if (item_data->type == IT_PETEGG) {
identify = 1;
@@ -1278,18 +1276,18 @@ ACMD(item2)
item_tmp.card[1] = c2;
item_tmp.card[2] = c3;
item_tmp.card[3] = c4;
-
+
if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
clif->additem(sd, 0, 0, flag);
}
-
+
if (flag == 0)
clif->message(fd, msg_txt(18)); // Item created.
} else {
clif->message(fd, msg_txt(19)); // Invalid item ID or name.
return false;
}
-
+
return true;
}
@@ -1299,14 +1297,14 @@ ACMD(item2)
ACMD(itemreset)
{
int i;
-
+
for (i = 0; i < MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
}
}
clif->message(fd, msg_txt(20)); // All of your items have been removed.
-
+
return true;
}
@@ -1318,12 +1316,12 @@ ACMD(baselevelup)
int level=0, i=0, status_point=0;
level = atoi(message);
-
+
if (!message || !*message || !level) {
clif->message(fd, msg_txt(986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
return false;
}
-
+
if (level > 0) {
if (sd->status.base_level >= pc->maxbaselv(sd)) { // check for max level by Valaris
clif->message(fd, msg_txt(47)); // Base level can't go any higher.
@@ -1333,7 +1331,7 @@ ACMD(baselevelup)
level = pc->maxbaselv(sd) - sd->status.base_level;
for (i = 0; i < level; i++)
status_point += pc->gets_status_point(sd->status.base_level + i);
-
+
sd->status.status_point += status_point;
sd->status.base_level += (unsigned int)level;
status_calc_pc(sd, SCO_FORCE);
@@ -1377,9 +1375,9 @@ ACMD(baselevelup)
ACMD(joblevelup)
{
int level=0;
-
+
level = atoi(message);
-
+
if (!message || !*message || !level) {
clif->message(fd, msg_txt(987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
return false;
@@ -1405,7 +1403,7 @@ ACMD(joblevelup)
level = sd->status.job_level-1;
sd->status.job_level -= (unsigned int)level;
if (sd->status.skill_point < level)
- pc->resetskill(sd,0); //Reset skills since we need to subtract more points.
+ pc->resetskill(sd,0); //Reset skills since we need to subtract more points.
if (sd->status.skill_point < level)
sd->status.skill_point = 0;
else
@@ -1418,7 +1416,7 @@ ACMD(joblevelup)
clif->updatestatus(sd, SP_NEXTJOBEXP);
clif->updatestatus(sd, SP_SKILLPOINT);
status_calc_pc(sd, SCO_FORCE);
-
+
return true;
}
@@ -1429,7 +1427,7 @@ ACMD(help) {
const char *command_name = NULL;
char *default_command = "help";
AtCommandInfo *tinfo = NULL;
-
+
if (!message || !*message) {
command_name = default_command; // If no command_name specified, display help for @help.
} else {
@@ -1437,33 +1435,33 @@ ACMD(help) {
++message;
command_name = atcommand->check_alias(message);
}
-
+
if (!atcommand->can_use2(sd, command_name, COMMAND_ATCOMMAND)) {
sprintf(atcmd_output, msg_txt(153), message); // "%s is Unknown Command"
clif->message(fd, atcmd_output);
atcommand->get_suggestions(sd, command_name, true);
return false;
}
-
+
tinfo = atcommand->get_info_byname(atcommand->check_alias(command_name));
-
+
if ( !tinfo || tinfo->help == NULL ) {
sprintf(atcmd_output, msg_txt(988), atcommand->at_symbol, command_name); // There is no help for %c%s.
clif->message(fd, atcmd_output);
atcommand->get_suggestions(sd, command_name, true);
return false;
}
-
+
sprintf(atcmd_output, msg_txt(989), atcommand->at_symbol, command_name); // Help for command %c%s:
clif->message(fd, atcmd_output);
-
+
{ // Display aliases
DBIterator* iter;
AtCommandInfo *command_info;
AliasInfo *alias_info = NULL;
StringBuf buf;
bool has_aliases = false;
-
+
StrBuf->Init(&buf);
StrBuf->AppendStr(&buf, msg_txt(990)); // Available aliases:
command_info = atcommand->get_info_byname(command_name);
@@ -1479,7 +1477,7 @@ ACMD(help) {
clif->message(fd, StrBuf->Value(&buf));
StrBuf->Destroy(&buf);
}
-
+
// Display help contents
clif->message(fd, tinfo->help);
return true;
@@ -1512,16 +1510,16 @@ int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
return 0;
}
-ACMD(pvpoff) {
-
+ACMD(pvpoff)
+{
if (!map->list[sd->bl.m].flag.pvp) {
clif->message(fd, msg_txt(160)); // PvP is already Off.
return false;
}
-
+
map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone);
map->list[sd->bl.m].flag.pvp = 0;
-
+
if (!battle_config.pk_mode) {
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
@@ -1549,24 +1547,24 @@ int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
return 0;
}
-ACMD(pvpon) {
-
+ACMD(pvpon)
+{
if (map->list[sd->bl.m].flag.pvp) {
clif->message(fd, msg_txt(161)); // PvP is already On.
return false;
}
-
+
map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_PVP_NAME));
map->list[sd->bl.m].flag.pvp = 1;
-
+
if (!battle_config.pk_mode) {// display pvp circle and rank
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
map->foreachinmap(atcommand->pvpon_sub,sd->bl.m, BL_PC);
}
-
+
clif->message(fd, msg_txt(32)); // PvP: On.
-
+
return true;
}
@@ -1574,38 +1572,38 @@ ACMD(pvpon) {
*
*------------------------------------------*/
ACMD(gvgoff) {
-
+
if (!map->list[sd->bl.m].flag.gvg) {
clif->message(fd, msg_txt(162)); // GvG is already Off.
return false;
}
-
+
map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone);
map->list[sd->bl.m].flag.gvg = 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_txt(33)); // GvG: Off.
-
+
return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD(gvgon) {
-
+ACMD(gvgon)
+{
if (map->list[sd->bl.m].flag.gvg) {
clif->message(fd, msg_txt(163)); // GvG is already On.
return false;
}
-
+
map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_GVG_NAME));
map->list[sd->bl.m].flag.gvg = 1;
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
clif->message(fd, msg_txt(34)); // GvG: On.
-
+
return true;
}
@@ -1615,16 +1613,16 @@ ACMD(gvgon) {
ACMD(model)
{
int hair_style = 0, hair_color = 0, cloth_color = 0;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
sprintf(atcmd_output, msg_txt(991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
clif->message(fd, atcmd_output);
return false;
}
-
+
if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
@@ -1636,7 +1634,7 @@ ACMD(model)
clif->message(fd, msg_txt(37)); // An invalid number was specified.
return false;
}
-
+
return true;
}
@@ -1646,15 +1644,15 @@ ACMD(model)
ACMD(dye)
{
int cloth_color = 0;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
sprintf(atcmd_output, msg_txt(992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
clif->message(fd, atcmd_output);
return false;
}
-
+
if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
pc->changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
clif->message(fd, msg_txt(36)); // Appearance changed.
@@ -1662,7 +1660,7 @@ ACMD(dye)
clif->message(fd, msg_txt(37)); // An invalid number was specified.
return false;
}
-
+
return true;
}
@@ -1672,15 +1670,15 @@ ACMD(dye)
ACMD(hair_style)
{
int hair_style = 0;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
sprintf(atcmd_output, msg_txt(993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
clif->message(fd, atcmd_output);
return false;
}
-
+
if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
pc->changelook(sd, LOOK_HAIR, hair_style);
clif->message(fd, msg_txt(36)); // Appearance changed.
@@ -1688,7 +1686,7 @@ ACMD(hair_style)
clif->message(fd, msg_txt(37)); // An invalid number was specified.
return false;
}
-
+
return true;
}
@@ -1698,15 +1696,15 @@ ACMD(hair_style)
ACMD(hair_color)
{
int hair_color = 0;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
sprintf(atcmd_output, msg_txt(994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
clif->message(fd, atcmd_output);
return false;
}
-
+
if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
pc->changelook(sd, LOOK_HAIR_COLOR, hair_color);
clif->message(fd, msg_txt(36)); // Appearance changed.
@@ -1714,7 +1712,7 @@ ACMD(hair_color)
clif->message(fd, msg_txt(37)); // An invalid number was specified.
return false;
}
-
+
return true;
}
@@ -1725,7 +1723,7 @@ ACMD(go) {
int i;
int town = INT_MAX; // Initialized to INT_MAX instead of -1 to avoid conflicts with those who map [-3:-1] to @memo locations.
char map_name[MAP_NAME_LENGTH];
-
+
const struct {
char map[MAP_NAME_LENGTH];
int x, y;
@@ -1772,23 +1770,23 @@ ACMD(go) {
{ MAP_MALAYA, 242, 211, 5 }, // 34 = Malaya Port
{ MAP_ECLAGE, 110, 39, 3 }, // 35 = Eclage
};
-
+
memset(map_name, '\0', sizeof(map_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%11s", map_name) < 1) {
// no value matched so send the list of locations
const char* text;
-
+
// attempt to find the text help string
text = atcommand_help_string( info );
-
+
clif->message(fd, msg_txt(38)); // Invalid location number, or name.
-
+
if( text ) {// send the text to the client
clif->messageln( fd, text );
}
-
+
return false;
}
@@ -1852,7 +1850,7 @@ ACMD(go) {
clif->message(fd, msg_txt(38)); // Invalid location number or name.
return false;
}
-
+
return true;
}
@@ -1870,11 +1868,11 @@ ACMD(monster)
int i, k, range;
short mx, my;
unsigned int size;
-
+
memset(name, '\0', sizeof(name));
memset(monster, '\0', sizeof(monster));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(80)); // Please specify a display name or monster name/id.
return false;
@@ -1895,35 +1893,35 @@ ACMD(monster)
clif->message(fd, msg_txt(80)); // Give a display name and monster name/id please.
return false;
}
-
+
if ((mob_id = mob->db_searchname(monster)) == 0) // check name first (to avoid possible name beginning by a number)
mob_id = mob->db_checkid(atoi(monster));
-
+
if (mob_id == 0) {
clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
return false;
}
-
+
if (number <= 0)
number = 1;
-
+
if( !name[0] )
strcpy(name, "--ja--");
-
+
// If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
number = battle_config.atc_spawn_quantity_limit;
-
+
if (strcmpi(info->command, "monstersmall") == 0)
- size = SZ_SMALL;
+ size = SZ_MEDIUM;
else if (strcmpi(info->command, "monsterbig") == 0)
size = SZ_BIG;
else
- size = SZ_MEDIUM;
-
+ size = SZ_SMALL;
+
if (battle_config.etc_log)
ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
-
+
count = 0;
range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
for (i = 0; i < number; i++) {
@@ -1931,7 +1929,7 @@ ACMD(monster)
k = mob->once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE|(mob_id == MOBID_EMPERIUM?0x200:0x0));
count += (k != 0) ? 1 : 0;
}
-
+
if (count != 0)
if (number == count)
clif->message(fd, msg_txt(39)); // All monster summoned!
@@ -1943,7 +1941,7 @@ ACMD(monster)
clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
return false;
}
-
+
return true;
}
@@ -1954,13 +1952,13 @@ int atkillmonster_sub(struct block_list *bl, va_list ap)
{
struct mob_data *md;
int flag;
-
+
nullpo_ret(md=(struct mob_data *)bl);
flag = va_arg(ap, int);
-
+
if (md->guardian_data)
return 0; //Do not touch WoE mobs!
-
+
if (flag)
status_zap(bl,md->status.hp, 0);
else
@@ -1971,22 +1969,22 @@ int atkillmonster_sub(struct block_list *bl, va_list ap)
ACMD(killmonster) {
int map_id, drop_flag;
char map_name[MAP_NAME_LENGTH_EXT];
-
+
memset(map_name, '\0', sizeof(map_name));
-
+
if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
map_id = sd->bl.m;
else {
if ((map_id = map->mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
-
+
drop_flag = strcmpi(info->command, "killmonster2");
-
+
map->foreachinmap(atcommand->atkillmonster_sub, map_id, BL_MOB, -drop_flag);
-
+
clif->message(fd, msg_txt(165)); // All monsters killed!
-
+
return true;
}
@@ -1997,9 +1995,9 @@ ACMD(refine)
{
int i,j, position = 0, refine = 0, current_position, final_refine;
int count;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
clif->message(fd, msg_txt(996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
sprintf(atcmd_output, msg_txt(997), EQP_HEAD_LOW); // %d: Lower Headgear
@@ -2024,9 +2022,9 @@ ACMD(refine)
clif->message(fd, atcmd_output);
return false;
}
-
+
refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
-
+
count = 0;
for (j = 0; j < EQI_MAX; j++) {
if ((i = sd->equip_index[j]) < 0)
@@ -2038,10 +2036,10 @@ ACMD(refine)
continue;
if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
continue;
-
+
if(position && !(sd->status.inventory[i].equip & position))
continue;
-
+
final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
if (sd->status.inventory[i].refine != final_refine) {
sd->status.inventory[i].refine = final_refine;
@@ -2055,7 +2053,7 @@ ACMD(refine)
count++;
}
}
-
+
if (count == 0)
clif->message(fd, msg_txt(166)); // No item has been refined.
else if (count == 1)
@@ -2064,7 +2062,7 @@ ACMD(refine)
sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
clif->message(fd, atcmd_output);
}
-
+
return true;
}
@@ -2077,10 +2075,10 @@ ACMD(produce)
int item_id, attribute = 0, star = 0;
struct item_data *item_data;
struct item tmp_item;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(item_name, '\0', sizeof(item_name));
-
+
if (!message || !*message || (
sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
@@ -2088,15 +2086,15 @@ ACMD(produce)
clif->message(fd, msg_txt(1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
return false;
}
-
+
if ( (item_data = itemdb->search_name(item_name)) == NULL &&
(item_data = itemdb->exists(atoi(item_name))) == NULL ) {
clif->message(fd, msg_txt(170)); //This item is not an equipment.
return false;
}
-
+
item_id = item_data->nameid;
-
+
if (itemdb->isequip2(item_data)) {
int flag = 0;
if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
@@ -2114,7 +2112,7 @@ ACMD(produce)
tmp_item.card[3] = GetWord(sd->status.char_id, 1);
clif->produce_effect(sd, 0, item_id);
clif->misceffect(&sd->bl, 3);
-
+
if ((flag = pc->additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
clif->additem(sd, 0, 0, flag);
} else {
@@ -2122,7 +2120,7 @@ ACMD(produce)
clif->message(fd, atcmd_output);
return false;
}
-
+
return true;
}
@@ -2132,9 +2130,9 @@ ACMD(produce)
ACMD(memo)
{
int position = 0;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if( !message || !*message || sscanf(message, "%d", &position) < 1 )
{
int i;
@@ -2146,17 +2144,17 @@ ACMD(memo)
else
sprintf(atcmd_output, msg_txt(171), i); // %d - void
clif->message(sd->fd, atcmd_output);
- }
+ }
return true;
- }
-
+ }
+
if( position < 0 || position >= MAX_MEMOPOINTS )
{
sprintf(atcmd_output, msg_txt(1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
clif->message(fd, atcmd_output);
return false;
}
-
+
pc->memo(sd, position);
return true;
}
@@ -2166,9 +2164,9 @@ ACMD(memo)
*------------------------------------------*/
ACMD(gat) {
int y;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
for (y = 2; y >= -2; y--) {
sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
map->list[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
@@ -2177,10 +2175,10 @@ ACMD(gat) {
map->getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
map->getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
map->getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
-
+
clif->message(fd, atcmd_output);
}
-
+
return true;
}
@@ -2190,19 +2188,19 @@ ACMD(gat) {
ACMD(displaystatus)
{
int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
-
+
if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
clif->message(fd, msg_txt(1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
return false;
}
if (i < 2) flag = 1;
if (i < 3) tick = 0;
-
+
if( flag == 0 )
clif->sc_end(&sd->bl,sd->bl.id,AREA,type);
else
clif->status_change(&sd->bl, type, flag, tick, val1, val2, val3);
-
+
return true;
}
@@ -2213,12 +2211,12 @@ ACMD(statuspoint)
{
int point;
unsigned int new_status_point;
-
+
if (!message || !*message || (point = atoi(message)) == 0) {
clif->message(fd, msg_txt(1010)); // Please enter a number (usage: @stpoint <number of points>).
return false;
}
-
+
if(point < 0)
{
if(sd->status.status_point < (unsigned int)(-point))
@@ -2238,7 +2236,7 @@ ACMD(statuspoint)
{
new_status_point = sd->status.status_point + point;
}
-
+
if (new_status_point != sd->status.status_point) {
sd->status.status_point = new_status_point;
clif->updatestatus(sd, SP_STATUSPOINT);
@@ -2250,7 +2248,7 @@ ACMD(statuspoint)
clif->message(fd, msg_txt(149)); // Unable to increase the number/value.
return false;
}
-
+
return true;
}
@@ -2261,12 +2259,12 @@ ACMD(skillpoint)
{
int point;
unsigned int new_skill_point;
-
+
if (!message || !*message || (point = atoi(message)) == 0) {
clif->message(fd, msg_txt(1011)); // Please enter a number (usage: @skpoint <number of points>).
return false;
}
-
+
if(point < 0)
{
if(sd->status.skill_point < (unsigned int)(-point))
@@ -2286,7 +2284,7 @@ ACMD(skillpoint)
{
new_skill_point = sd->status.skill_point + point;
}
-
+
if (new_skill_point != sd->status.skill_point) {
sd->status.skill_point = new_skill_point;
clif->updatestatus(sd, SP_SKILLPOINT);
@@ -2298,7 +2296,7 @@ ACMD(skillpoint)
clif->message(fd, msg_txt(149)); // Unable to increase the number/value.
return false;
}
-
+
return true;
}
@@ -2308,12 +2306,12 @@ ACMD(skillpoint)
ACMD(zeny)
{
int zeny=0, ret=-1;
-
+
if (!message || !*message || (zeny = atoi(message)) == 0) {
clif->message(fd, msg_txt(1012)); // Please enter an amount (usage: @zeny <amount>).
return false;
}
-
+
if(zeny > 0){
if((ret=pc->getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
clif->message(fd, msg_txt(149)); // Unable to increase the number/value.
@@ -2338,34 +2336,34 @@ ACMD(param) {
int i, value = 0, new_value, max;
const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
short* stats[6];
- //we don't use direct initialization because it isn't part of the c standard.
-
+ //we don't use direct initialization because it isn't part of the c standard.
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
clif->message(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
return false;
}
-
+
ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(info->command, param[i]) == 0 );
-
+
if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
clif->message(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
return false;
}
-
+
stats[0] = &sd->status.str;
stats[1] = &sd->status.agi;
stats[2] = &sd->status.vit;
stats[3] = &sd->status.int_;
stats[4] = &sd->status.dex;
stats[5] = &sd->status.luk;
-
+
if( battle_config.atcommand_max_stat_bypass )
max = SHRT_MAX;
else
max = pc_maxparameter(sd);
-
+
if(value < 0 && *stats[i] <= -value) {
new_value = 1;
} else if(max - *stats[i] < value) {
@@ -2373,7 +2371,7 @@ ACMD(param) {
} else {
new_value = *stats[i] + value;
}
-
+
if (new_value != *stats[i]) {
*stats[i] = new_value;
clif->updatestatus(sd, SP_STR + i);
@@ -2387,7 +2385,7 @@ ACMD(param) {
clif->message(fd, msg_txt(149)); // Unable to increase the number/value.
return false;
}
-
+
return true;
}
@@ -2397,15 +2395,15 @@ ACMD(param) {
ACMD(stat_all) {
int index, count, value, max, new_value;
short* stats[6];
- //we don't use direct initialization because it isn't part of the c standard.
-
+ //we don't use direct initialization because it isn't part of the c standard.
+
stats[0] = &sd->status.str;
stats[1] = &sd->status.agi;
stats[2] = &sd->status.vit;
stats[3] = &sd->status.int_;
stats[4] = &sd->status.dex;
stats[5] = &sd->status.luk;
-
+
if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
value = pc_maxparameter(sd);
max = pc_maxparameter(sd);
@@ -2415,17 +2413,16 @@ ACMD(stat_all) {
else
max = pc_maxparameter(sd);
}
-
+
count = 0;
for (index = 0; index < ARRAYLENGTH(stats); index++) {
-
if (value > 0 && *stats[index] > max - value)
new_value = max;
else if (value < 0 && *stats[index] <= -value)
new_value = 1;
else
new_value = *stats[index] +value;
-
+
if (new_value != (int)*stats[index]) {
*stats[index] = new_value;
clif->updatestatus(sd, SP_STR + index);
@@ -2433,7 +2430,7 @@ ACMD(stat_all) {
count++;
}
}
-
+
if (count > 0) { // if at least 1 stat modified
status_calc_pc(sd, SCO_FORCE);
clif->message(fd, msg_txt(84)); // All stats changed!
@@ -2444,7 +2441,7 @@ ACMD(stat_all) {
clif->message(fd, msg_txt(178)); // You cannot increase that stat anymore.
return false;
}
-
+
return true;
}
@@ -2455,12 +2452,12 @@ ACMD(guildlevelup) {
int level = 0;
int16 added_level;
struct guild *guild_info;
-
+
if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
clif->message(fd, msg_txt(1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
return false;
}
-
+
if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
clif->message(fd, msg_txt(43)); // You're not in a guild.
return false;
@@ -2471,13 +2468,13 @@ ACMD(guildlevelup) {
return false;
}
#endif // 0
-
+
if (level > INT16_MAX || (level > 0 && level > MAX_GUILDLEVEL - guild_info->guild_lv)) // fix positive overflow
level = MAX_GUILDLEVEL - guild_info->guild_lv;
else if (level < INT16_MIN || (level < 0 && level < 1 - guild_info->guild_lv)) // fix negative overflow
level = 1 - guild_info->guild_lv;
added_level = (int16)level;
-
+
if (added_level != 0) {
intif->guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
clif->message(fd, msg_txt(179)); // Guild level changed.
@@ -2485,7 +2482,7 @@ ACMD(guildlevelup) {
clif->message(fd, msg_txt(45)); // Guild level change failed.
return false;
}
-
+
return true;
}
@@ -2496,12 +2493,12 @@ ACMD(makeegg)
{
struct item_data *item_data;
int id, pet_id;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
return false;
}
-
+
if ((item_data = itemdb->search_name(message)) != NULL) // for egg name
id = item_data->nameid;
else
@@ -2509,7 +2506,7 @@ ACMD(makeegg)
;
else
id = atoi(message);
-
+
pet_id = pet->search_petDB_index(id, PET_CLASS);
if (pet_id < 0)
pet_id = pet->search_petDB_index(id, PET_EGG);
@@ -2524,7 +2521,7 @@ ACMD(makeegg)
clif->message(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
return false;
}
-
+
return true;
}
@@ -2539,7 +2536,7 @@ ACMD(hatch)
clif->message(fd, msg_txt(181)); // You already have a pet.
return false;
}
-
+
return true;
}
@@ -2550,29 +2547,29 @@ ACMD(petfriendly)
{
int friendly;
struct pet_data *pd;
-
+
if (!message || !*message || (friendly = atoi(message)) < 0) {
clif->message(fd, msg_txt(1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
return false;
}
-
+
pd = sd->pd;
if (!pd) {
clif->message(fd, msg_txt(184)); // Sorry, but you have no pet.
return false;
}
-
+
if (friendly < 0 || friendly > 1000)
{
clif->message(fd, msg_txt(37)); // An invalid number was specified.
return false;
}
-
+
if (friendly == pd->pet.intimate) {
clif->message(fd, msg_txt(183)); // Pet intimacy is already at maximum.
return false;
}
-
+
pet->set_intimate(pd, friendly);
clif->send_petstatus(sd);
clif->message(fd, msg_txt(182)); // Pet intimacy changed.
@@ -2586,12 +2583,12 @@ ACMD(pethungry)
{
int hungry;
struct pet_data *pd;
-
+
if (!message || !*message || (hungry = atoi(message)) < 0) {
clif->message(fd, msg_txt(1017)); // Please enter a valid number (usage: @pethungry <0-100>).
return false;
}
-
+
pd = sd->pd;
if (!sd->status.pet_id || !pd) {
clif->message(fd, msg_txt(184)); // Sorry, but you have no pet.
@@ -2605,11 +2602,11 @@ ACMD(pethungry)
clif->message(fd, msg_txt(186)); // Pet hunger is already at maximum.
return false;
}
-
+
pd->pet.hungry = hungry;
clif->send_petstatus(sd);
clif->message(fd, msg_txt(185)); // Pet hunger changed.
-
+
return true;
}
@@ -2628,12 +2625,12 @@ ACMD(petrename)
clif->message(fd, msg_txt(188)); // You can already rename your pet.
return false;
}
-
+
pd->pet.rename_flag = 0;
intif->save_petdata(sd->status.account_id, &pd->pet);
clif->send_petstatus(sd);
clif->message(fd, msg_txt(187)); // You can now rename your pet.
-
+
return true;
}
@@ -2642,24 +2639,23 @@ ACMD(petrename)
*------------------------------------------*/
ACMD(recall) {
struct map_session_data *pl_sd = NULL;
-
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1018)); // Please enter a player name (usage: @recall <char name/ID>).
return false;
}
-
+
if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
{
clif->message(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
return false;
}
-
+
if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(1019)); // You are not authorized to warp someone to this map.
return false;
@@ -2674,7 +2670,7 @@ ACMD(recall) {
pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
clif->message(fd, atcmd_output);
-
+
return true;
}
@@ -2684,17 +2680,17 @@ ACMD(recall) {
*------------------------------------------*/
ACMD(char_block)
{
-
+
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1021)); // Please enter a player name (usage: @block <char name>).
return false;
}
-
+
chrif->char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it.
-
+
return true;
}
@@ -2719,17 +2715,17 @@ ACMD(char_ban)
int year, month, day, hour, minute, second, value;
time_t timestamp;
struct tm *tmtime;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
clif->message(fd, msg_txt(1022)); // Please enter ban time and a player name (usage: @ban <time> <char name>).
return false;
}
-
+
atcmd_output[sizeof(atcmd_output)-1] = '\0';
-
+
modif_p = atcmd_output;
year = month = day = hour = minute = second = 0;
while (modif_p[0] != '\0') {
@@ -2787,10 +2783,10 @@ ACMD(char_ban)
clif->message(fd,msg_txt(1023)); // You are not allowed to reduce the length of a ban.
return false;
}
-
+
chrif->char_ask_name(sd->status.account_id, atcmd_player_name, !strcmpi(info->command,"charban") ? 6 : 2, year, month, day, hour, minute, second); // type: 2 - ban; 6 - charban
clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it.
-
+
return true;
}
@@ -2799,18 +2795,17 @@ ACMD(char_ban)
*------------------------------------------*/
ACMD(char_unblock)
{
-
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1024)); // Please enter a player name (usage: @unblock <char name>).
return false;
}
-
+
// send answer to login server via char-server
chrif->char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it.
-
+
return true;
}
@@ -2819,48 +2814,47 @@ ACMD(char_unblock)
*------------------------------------------*/
ACMD(char_unban)
{
-
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1025)); // Please enter a player name (usage: @unban <char name>).
return false;
}
-
+
// send answer to login server via char-server
chrif->char_ask_name(sd->status.account_id, atcmd_player_name, !strcmpi(info->command,"charunban") ? 7 : 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban account; type 7 - unban character
clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it.
-
+
return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD(night) {
-
+ACMD(night)
+{
if (map->night_flag != 1) {
pc->map_night_timer(pc->night_timer_tid, 0, 0, 1);
} else {
clif->message(fd, msg_txt(89)); // Night mode is already enabled.
return false;
}
-
+
return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD(day) {
-
+ACMD(day)
+{
if (map->night_flag != 0) {
pc->map_day_timer(pc->day_timer_tid, 0, 0, 1);
} else {
clif->message(fd, msg_txt(90)); // Day mode is already enabled.
return false;
}
-
+
return true;
}
@@ -2871,7 +2865,7 @@ ACMD(doom)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
@@ -2883,9 +2877,9 @@ ACMD(doom)
}
}
mapit->free(iter);
-
+
clif->message(fd, msg_txt(62)); // Judgment was made.
-
+
return true;
}
@@ -2896,7 +2890,7 @@ ACMD(doommap)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
@@ -2908,19 +2902,19 @@ ACMD(doommap)
}
}
mapit->free(iter);
-
+
clif->message(fd, msg_txt(62)); // Judgment was made.
-
+
return true;
}
/*==========================================
*
*------------------------------------------*/
-void atcommand_raise_sub(struct map_session_data* sd) {
-
+void atcommand_raise_sub(struct map_session_data* sd)
+{
status->revive(&sd->bl, 100, 100);
-
+
clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
clif->message(sd->fd, msg_txt(63)); // Mercy has been shown.
}
@@ -2932,15 +2926,15 @@ ACMD(raise)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
if( pc_isdead(pl_sd) )
atcommand->raise_sub(pl_sd);
mapit->free(iter);
-
+
clif->message(fd, msg_txt(64)); // Mercy has been granted.
-
+
return true;
}
@@ -2951,15 +2945,15 @@ ACMD(raisemap)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
atcommand->raise_sub(pl_sd);
mapit->free(iter);
-
+
clif->message(fd, msg_txt(64)); // Mercy has been granted.
-
+
return true;
}
@@ -2969,27 +2963,27 @@ ACMD(raisemap)
ACMD(kick)
{
struct map_session_data *pl_sd;
-
+
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1026)); // Please enter a player name (usage: @kick <char name/ID>).
return false;
}
-
+
if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
{
clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
return false;
}
-
+
clif->GM_kick(sd, pl_sd);
-
+
return true;
}
@@ -3000,7 +2994,7 @@ ACMD(kickall)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
@@ -3010,9 +3004,9 @@ ACMD(kickall)
}
}
mapit->free(iter);
-
+
clif->message(fd, msg_txt(195)); // All players have been kicked!
-
+
return true;
}
@@ -3025,7 +3019,7 @@ ACMD(allskill)
sd->status.skill_point = 0; // 0 skill points
clif->updatestatus(sd, SP_SKILLPOINT); // update
clif->message(fd, msg_txt(76)); // All skills have been added to your skill tree.
-
+
return true;
}
@@ -3035,21 +3029,21 @@ ACMD(allskill)
ACMD(questskill)
{
uint16 skill_id, index;
-
+
if (!message || !*message || (skill_id = atoi(message)) <= 0)
{// also send a list of skills applicable to this command
const char* text;
-
+
// attempt to find the text corresponding to this command
text = atcommand_help_string( info );
-
+
// send the error message as always
clif->message(fd, msg_txt(1027)); // Please enter a quest skill number.
-
+
if( text ) {// send the skill ID list associated with this command
clif->messageln( fd, text );
}
-
+
return false;
}
if( !(index = skill->get_index(skill_id)) ) {
@@ -3064,10 +3058,10 @@ ACMD(questskill)
clif->message(fd, msg_txt(196)); // You already have this quest skill.
return false;
}
-
+
pc->skill(sd, skill_id, 1, 0);
clif->message(fd, msg_txt(70)); // You have learned the skill.
-
+
return true;
}
@@ -3077,21 +3071,21 @@ ACMD(questskill)
ACMD(lostskill)
{
uint16 skill_id, index;
-
+
if (!message || !*message || (skill_id = atoi(message)) <= 0)
{// also send a list of skills applicable to this command
const char* text;
-
+
// attempt to find the text corresponding to this command
text = atcommand_help_string( info );
-
+
// send the error message as always
clif->message(fd, msg_txt(1027)); // Please enter a quest skill number.
-
+
if( text ) {// send the skill ID list associated with this command
clif->messageln( fd, text );
}
-
+
return false;
}
if ( !( index = skill->get_index(skill_id) ) ) {
@@ -3106,12 +3100,12 @@ ACMD(lostskill)
clif->message(fd, msg_txt(201)); // You don't have this quest skill.
return false;
}
-
+
sd->status.skill[index].lv = 0;
sd->status.skill[index].flag = 0;
clif->deleteskill(sd,skill_id);
clif->message(fd, msg_txt(71)); // You have forgotten the skill.
-
+
return true;
}
@@ -3122,9 +3116,9 @@ ACMD(spiritball)
{
int max_spiritballs;
int number;
-
+
max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
-
+
if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
{
char msg[CHAT_SIZE_MAX];
@@ -3132,13 +3126,13 @@ ACMD(spiritball)
clif->message(fd, msg);
return false;
}
-
+
if( sd->spiritball > 0 )
pc->delspiritball(sd, sd->spiritball, 1);
sd->spiritball = number;
clif->spiritball(&sd->bl);
// no message, player can look the difference
-
+
return true;
}
@@ -3148,16 +3142,16 @@ ACMD(spiritball)
ACMD(party)
{
char party_name[NAME_LENGTH];
-
+
memset(party_name, '\0', sizeof(party_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
clif->message(fd, msg_txt(1029)); // Please enter a party name (usage: @party <party_name>).
return false;
}
-
+
party->create(sd, party_name, 0, 0);
-
+
return true;
}
@@ -3168,25 +3162,24 @@ ACMD(guild)
{
char guild_name[NAME_LENGTH];
int prev;
-
+
memset(guild_name, '\0', sizeof(guild_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
clif->message(fd, msg_txt(1030)); // Please enter a guild name (usage: @guild <guild_name>).
return false;
}
-
+
prev = battle_config.guild_emperium_check;
battle_config.guild_emperium_check = 0;
guild->create(sd, guild_name);
battle_config.guild_emperium_check = prev;
-
+
return true;
}
ACMD(breakguild)
{
-
if (sd->status.guild_id) { // Check if the player has a guild
struct guild *g;
g = sd->guild; // Search the guild
@@ -3222,11 +3215,11 @@ ACMD(agitstart) {
clif->message(fd, msg_txt(73)); // War of Emperium is currently in progress.
return false;
}
-
+
map->agit_flag = 1;
guild->agit_start();
clif->message(fd, msg_txt(72)); // War of Emperium has been initiated.
-
+
return true;
}
@@ -3238,11 +3231,11 @@ ACMD(agitstart2) {
clif->message(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
return false;
}
-
+
map->agit2_flag = 1;
guild->agit2_start();
clif->message(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
-
+
return true;
}
@@ -3254,11 +3247,11 @@ ACMD(agitend) {
clif->message(fd, msg_txt(75)); // War of Emperium is currently not in progress.
return false;
}
-
+
map->agit_flag = 0;
guild->agit_end();
clif->message(fd, msg_txt(74)); // War of Emperium has been ended.
-
+
return true;
}
@@ -3270,11 +3263,11 @@ ACMD(agitend2) {
clif->message(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
return false;
}
-
+
map->agit2_flag = 0;
guild->agit2_end();
clif->message(fd, msg_txt(405)); // "War of Emperium SE has been ended."
-
+
return true;
}
@@ -3294,15 +3287,15 @@ ACMD(idsearch)
char item_name[100];
unsigned int i, match;
struct item_data *item_array[MAX_SEARCH];
-
+
memset(item_name, '\0', sizeof(item_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
clif->message(fd, msg_txt(1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
return false;
}
-
+
sprintf(atcmd_output, msg_txt(77), item_name); // Search results for '%s' (name: id):
clif->message(fd, atcmd_output);
match = itemdb->search_name_array(item_array, MAX_SEARCH, item_name, 0);
@@ -3317,7 +3310,7 @@ ACMD(idsearch)
}
sprintf(atcmd_output, msg_txt(79), match); // %d results found.
clif->message(fd, atcmd_output);
-
+
return true;
}
@@ -3329,14 +3322,14 @@ ACMD(recallall)
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
int count;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(1032)); // You are not authorized to warp someone to your current map.
return false;
}
-
+
count = 0;
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) {
@@ -3355,13 +3348,13 @@ ACMD(recallall)
}
}
mapit->free(iter);
-
+
clif->message(fd, msg_txt(92)); // All characters recalled!
if (count) {
sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
clif->message(fd, atcmd_output);
}
-
+
return true;
}
@@ -3375,29 +3368,29 @@ ACMD(guildrecall)
int count;
char guild_name[NAME_LENGTH];
struct guild *g;
-
+
memset(guild_name, '\0', sizeof(guild_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
clif->message(fd, msg_txt(1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
return false;
}
-
+
if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(1032)); // You are not authorized to warp someone to your current map.
return false;
}
-
+
if ((g = guild->searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
(g = guild->search(atoi(message))) == NULL)
{
clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
return false;
}
-
+
count = 0;
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
@@ -3411,14 +3404,14 @@ ACMD(guildrecall)
}
}
mapit->free(iter);
-
+
sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
clif->message(fd, atcmd_output);
if (count) {
sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
clif->message(fd, atcmd_output);
}
-
+
return true;
}
@@ -3432,29 +3425,29 @@ ACMD(partyrecall)
char party_name[NAME_LENGTH];
struct party_data *p;
int count;
-
+
memset(party_name, '\0', sizeof(party_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
clif->message(fd, msg_txt(1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
return false;
}
-
+
if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(1032)); // You are not authorized to warp someone to your current map.
return false;
}
-
+
if ((p = party->searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
(p = party->search(atoi(message))) == NULL)
{
clif->message(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
return false;
}
-
+
count = 0;
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) {
if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id) {
@@ -3467,14 +3460,14 @@ ACMD(partyrecall)
}
}
mapit->free(iter);
-
+
sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
clif->message(fd, atcmd_output);
if (count) {
sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
clif->message(fd, atcmd_output);
}
-
+
return true;
}
@@ -3485,7 +3478,7 @@ ACMD(reloaditemdb)
{
itemdb->reload();
clif->message(fd, msg_txt(97)); // Item database has been reloaded.
-
+
return true;
}
@@ -3500,7 +3493,7 @@ ACMD(reloadmobdb) {
mercenary->read_skilldb();
elemental->reload_db();
clif->message(fd, msg_txt(98)); // Monster database has been reloaded.
-
+
return true;
}
@@ -3514,7 +3507,7 @@ ACMD(reloadskilldb)
elemental->reload_skilldb();
mercenary->read_skilldb();
clif->message(fd, msg_txt(99)); // Skill database has been reloaded.
-
+
return true;
}
@@ -3523,21 +3516,21 @@ ACMD(reloadskilldb)
*------------------------------------------*/
ACMD(reloadatcommand) {
config_t run_test;
-
+
if (libconfig->read_file(&run_test, "conf/groups.conf")) {
clif->message(fd, msg_txt(1036)); // Error reading groups.conf, reload failed.
return false;
}
-
+
libconfig->destroy(&run_test);
-
+
if (libconfig->read_file(&run_test, map->ATCOMMAND_CONF_FILENAME)) {
clif->message(fd, msg_txt(1037)); // Error reading atcommand.conf, reload failed.
return false;
}
-
+
libconfig->destroy(&run_test);
-
+
atcommand->doload();
pcg->reload();
clif->message(fd, msg_txt(254));
@@ -3550,9 +3543,9 @@ ACMD(reloadbattleconf)
{
struct Battle_Config prev_config;
memcpy(&prev_config, &battle_config, sizeof(prev_config));
-
+
battle->config_read(map->BATTLE_CONF_FILENAME);
-
+
if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
|| prev_config.item_rate_common != battle_config.item_rate_common
|| prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
@@ -3583,8 +3576,7 @@ ACMD(reloadbattleconf)
|| prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
|| prev_config.base_exp_rate != battle_config.base_exp_rate
|| prev_config.job_exp_rate != battle_config.job_exp_rate
- )
- { // Exp or Drop rates changed.
+ ) { // Exp or Drop rates changed.
mob->reload(); //Needed as well so rate changes take effect.
chrif->ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
}
@@ -3618,7 +3610,7 @@ ACMD(reloadscript) {
//atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
//atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) {
if (pl_sd->npc_id || pl_sd->npc_shopid) {
@@ -3638,14 +3630,14 @@ ACMD(reloadscript) {
}
}
mapit->free(iter);
-
+
flush_fifos();
map->reloadnpc(true, NULL, 0); // reload config files seeking for npcs
script->reload();
npc->reload();
-
+
clif->message(fd, msg_txt(100)); // Scripts have been reloaded.
-
+
return true;
}
@@ -3667,33 +3659,33 @@ ACMD(mapinfo) {
int i, m_id, chat_num = 0, list = 0, vend_num = 0;
unsigned short m_index;
char mapname[24];
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(mapname, '\0', sizeof(mapname));
memset(direction, '\0', sizeof(direction));
-
+
sscanf(message, "%d %23[^\n]", &list, mapname);
-
+
if (list < 0 || list > 3) {
clif->message(fd, msg_txt(1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
return false;
}
-
+
if (mapname[0] == '\0') {
safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
m_id = map->mapindex2mapid(sd->mapindex);
} else {
m_id = map->mapname2mapid(mapname);
}
-
+
if (m_id < 0) {
clif->message(fd, msg_txt(1)); // Map not found.
return false;
}
m_index = mapindex->name2id(mapname); //This one shouldn't fail since the previous seek did not.
-
+
clif->message(fd, msg_txt(1039)); // ------ Map Info ------
-
+
// count chats (for initial message)
chat_num = 0;
iter = mapit_getallusers();
@@ -3706,21 +3698,21 @@ ACMD(mapinfo) {
}
}
mapit->free(iter);
-
+
sprintf(atcmd_output, msg_txt(1040), mapname, map->list[m_id].zone->name, map->list[m_id].users, map->list[m_id].npc_num, chat_num, vend_num); // Map: %s (Zone:%s) | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
clif->message(fd, atcmd_output);
clif->message(fd, msg_txt(1041)); // ------ Map Flags ------
if (map->list[m_id].flag.town)
clif->message(fd, msg_txt(1042)); // Town Map
-
+
if (battle_config.autotrade_mapflag == map->list[m_id].flag.autotrade)
clif->message(fd, msg_txt(1043)); // Autotrade Enabled
else
clif->message(fd, msg_txt(1044)); // Autotrade Disabled
-
+
if (map->list[m_id].flag.battleground)
clif->message(fd, msg_txt(1045)); // Battlegrounds ON
-
+
strcpy(atcmd_output,msg_txt(1046)); // PvP Flags:
if (map->list[m_id].flag.pvp)
strcat(atcmd_output, msg_txt(1047)); // Pvp ON |
@@ -3733,7 +3725,7 @@ ACMD(mapinfo) {
if (map->list[m_id].flag.pvp_nocalcrank)
strcat(atcmd_output, msg_txt(1051)); // NoCalcRank |
clif->message(fd, atcmd_output);
-
+
strcpy(atcmd_output,msg_txt(1052)); // GvG Flags:
if (map->list[m_id].flag.gvg)
strcat(atcmd_output, msg_txt(1053)); // GvG ON |
@@ -3744,7 +3736,7 @@ ACMD(mapinfo) {
if (map->list[m_id].flag.gvg_noparty)
strcat(atcmd_output, msg_txt(1056)); // NoParty |
clif->message(fd, atcmd_output);
-
+
strcpy(atcmd_output,msg_txt(1057)); // Teleport Flags:
if (map->list[m_id].flag.noteleport)
strcat(atcmd_output, msg_txt(1058)); // NoTeleport |
@@ -3759,12 +3751,12 @@ ACMD(mapinfo) {
if (map->list[m_id].flag.nomemo)
strcat(atcmd_output, msg_txt(1064)); // NoMemo |
clif->message(fd, atcmd_output);
-
+
sprintf(atcmd_output, msg_txt(1065), // No Exp Penalty: %s | No Zeny Penalty: %s
(map->list[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067),
(map->list[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off
clif->message(fd, atcmd_output);
-
+
if (map->list[m_id].flag.nosave) {
if (!map->list[m_id].save.map)
clif->message(fd, msg_txt(1068)); // No Save (Return to last Save Point)
@@ -3777,7 +3769,7 @@ ACMD(mapinfo) {
clif->message(fd, atcmd_output);
}
}
-
+
strcpy(atcmd_output,msg_txt(1071)); // Weather Flags:
if (map->list[m_id].flag.snow)
strcat(atcmd_output, msg_txt(1072)); // Snow |
@@ -3796,7 +3788,7 @@ ACMD(mapinfo) {
if (map->list[m_id].flag.nightenabled)
strcat(atcmd_output, msg_txt(1080)); // Displays Night |
clif->message(fd, atcmd_output);
-
+
strcpy(atcmd_output,msg_txt(1081)); // Other Flags:
if (map->list[m_id].flag.nobranch)
strcat(atcmd_output, msg_txt(1082)); // NoBranch |
@@ -3815,7 +3807,7 @@ ACMD(mapinfo) {
if (map->list[m_id].flag.reset)
strcat(atcmd_output, msg_txt(1089)); // Reset |
clif->message(fd, atcmd_output);
-
+
strcpy(atcmd_output,msg_txt(1090)); // Other Flags:
if (map->list[m_id].nocommand)
strcat(atcmd_output, msg_txt(1091)); // NoCommand |
@@ -3832,7 +3824,7 @@ ACMD(mapinfo) {
if (map->list[m_id].flag.guildlock)
strcat(atcmd_output, msg_txt(1097)); // GuildLock |
clif->message(fd, atcmd_output);
-
+
switch (list) {
case 0:
// Do nothing. It's list 0, no additional display.
@@ -3881,8 +3873,8 @@ ACMD(mapinfo) {
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
if ((cd = (struct chat_data*)map->id2bl(pl_sd->chatID)) != NULL &&
- pl_sd->mapindex == m_index &&
- cd->usersd[0] == pl_sd)
+ pl_sd->mapindex == m_index &&
+ cd->usersd[0] == pl_sd)
{
sprintf(atcmd_output, msg_txt(1114), // Chat: %s | Player: %s | Location: %d %d
cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
@@ -3898,7 +3890,7 @@ ACMD(mapinfo) {
clif->message(fd, msg_txt(1118)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
return false;
}
-
+
return true;
}
@@ -3911,24 +3903,24 @@ ACMD(mount_peco)
clif->message(fd, msg_txt(212)); // Cannot mount while in disguise.
return false;
}
-
+
if( sd->sc.data[SC_ALL_RIDING] ) {
clif->message(fd, msg_txt(1476)); // You are already mounting something else
return false;
}
-
+
if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT ) {
if( !pc->checkskill(sd,RK_DRAGONTRAINING) ) {
sprintf(atcmd_output, msg_txt(213), skill->get_desc(RK_DRAGONTRAINING)); // You need %s to mount!
clif->message(fd, atcmd_output);
return false;
}
- if( !(sd->sc.option&OPTION_DRAGON1) ) {
+ if (!pc_isridingdragon(sd)) {
clif->message(sd->fd,msg_txt(1119)); // You have mounted your Dragon.
- pc->setoption(sd, sd->sc.option|OPTION_DRAGON1);
+ pc->setridingdragon(sd, OPTION_DRAGON1);
} else {
clif->message(sd->fd,msg_txt(1120)); // You have released your Dragon.
- pc->setoption(sd, sd->sc.option&~OPTION_DRAGON1);
+ pc->setridingdragon(sd, 0);
}
return true;
}
@@ -3940,34 +3932,34 @@ ACMD(mount_peco)
}
if( !pc_isridingwug(sd) ) {
clif->message(sd->fd,msg_txt(1121)); // You have mounted your Warg.
- pc->setoption(sd, sd->sc.option|OPTION_WUGRIDER);
+ pc->setridingwug(sd, true);
} else {
clif->message(sd->fd,msg_txt(1122)); // You have released your Warg.
- pc->setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
+ pc->setridingwug(sd, false);
}
return true;
}
if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
if( !pc_ismadogear(sd) ) {
clif->message(sd->fd,msg_txt(1123)); // You have mounted your Mado Gear.
- pc->setoption(sd, sd->sc.option|OPTION_MADOGEAR);
+ pc->setmadogear(sd, true);
} else {
clif->message(sd->fd,msg_txt(1124)); // You have released your Mado Gear.
- pc->setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
+ pc->setmadogear(sd, false);
}
return true;
}
if( sd->class_&MAPID_SWORDMAN && sd->class_&JOBL_2 ) {
- if( !pc_isriding(sd) ) { // if actually no peco
+ if (!pc_isridingpeco(sd)) { // if actually no peco
if (!pc->checkskill(sd, KN_RIDING)) {
sprintf(atcmd_output, msg_txt(213), skill->get_desc(KN_RIDING)); // You need %s to mount!
clif->message(fd, atcmd_output);
return false;
}
- pc->setoption(sd, sd->sc.option | OPTION_RIDING);
+ pc->setridingpeco(sd, true);
clif->message(fd, msg_txt(102)); // You have mounted a Peco Peco.
} else {//Dismount
- pc->setoption(sd, sd->sc.option & ~OPTION_RIDING);
+ pc->setridingpeco(sd, false);
clif->message(fd, msg_txt(214)); // You have released your Peco Peco.
}
return true;
@@ -3982,10 +3974,10 @@ ACMD(mount_peco)
ACMD(guildspy) {
char guild_name[NAME_LENGTH];
struct guild *g;
-
+
memset(guild_name, '\0', sizeof(guild_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!map->enable_spy)
{
clif->message(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
@@ -3995,7 +3987,7 @@ ACMD(guildspy) {
clif->message(fd, msg_txt(1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
return false;
}
-
+
if ((g = guild->searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
(g = guild->search(atoi(message))) != NULL) {
if (sd->guildspy == g->guild_id) {
@@ -4011,7 +4003,7 @@ ACMD(guildspy) {
clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
return false;
}
-
+
return true;
}
@@ -4021,21 +4013,21 @@ ACMD(guildspy) {
ACMD(partyspy) {
char party_name[NAME_LENGTH];
struct party_data *p;
-
+
memset(party_name, '\0', sizeof(party_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!map->enable_spy)
{
clif->message(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
return false;
}
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
clif->message(fd, msg_txt(1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
return false;
}
-
+
if ((p = party->searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
(p = party->search(atoi(message))) != NULL) {
if (sd->partyspy == p->party.party_id) {
@@ -4051,7 +4043,7 @@ ACMD(partyspy) {
clif->message(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
return false;
}
-
+
return true;
}
@@ -4061,7 +4053,7 @@ ACMD(partyspy) {
ACMD(repairall)
{
int count, i;
-
+
count = 0;
for (i = 0; i < MAX_INVENTORY; i++) {
if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
@@ -4070,7 +4062,7 @@ ACMD(repairall)
count++;
}
}
-
+
if (count > 0) {
clif->misceffect(&sd->bl, 3);
clif->equiplist(sd);
@@ -4079,7 +4071,7 @@ ACMD(repairall)
clif->message(fd, msg_txt(108)); // No item need to be repaired.
return false;
}
-
+
return true;
}
@@ -4088,14 +4080,14 @@ ACMD(repairall)
*------------------------------------------*/
ACMD(nuke) {
struct map_session_data *pl_sd;
-
+
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1128)); // Please enter a player name (usage: @nuke <char name>).
return false;
}
-
+
if ((pl_sd = map->nick2sd(atcmd_player_name)) != NULL) {
if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, timer->gettick(), 0);
@@ -4108,7 +4100,7 @@ ACMD(nuke) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
return true;
}
@@ -4118,14 +4110,14 @@ ACMD(nuke) {
ACMD(tonpc) {
char npcname[NAME_LENGTH+1];
struct npc_data *nd;
-
+
memset(npcname, 0, sizeof(npcname));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
clif->message(fd, msg_txt(1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
return false;
}
-
+
if ((nd = npc->name2id(npcname)) != NULL) {
if (nd->bl.m != -1 && pc->setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
clif->message(fd, msg_txt(0)); // Warped.
@@ -4135,7 +4127,7 @@ ACMD(tonpc) {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
return false;
}
-
+
return true;
}
@@ -4145,14 +4137,14 @@ ACMD(tonpc) {
ACMD(shownpc)
{
char NPCname[NAME_LENGTH+1];
-
+
memset(NPCname, '\0', sizeof(NPCname));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
clif->message(fd, msg_txt(1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
return false;
}
-
+
if (npc->name2id(NPCname) != NULL) {
npc->enable(NPCname, 1);
clif->message(fd, msg_txt(110)); // Npc Enabled.
@@ -4160,7 +4152,7 @@ ACMD(shownpc)
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
return false;
}
-
+
return true;
}
@@ -4170,19 +4162,19 @@ ACMD(shownpc)
ACMD(hidenpc)
{
char NPCname[NAME_LENGTH+1];
-
+
memset(NPCname, '\0', sizeof(NPCname));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
clif->message(fd, msg_txt(1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
return false;
}
-
+
if (npc->name2id(NPCname) == NULL) {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
return false;
}
-
+
npc->enable(NPCname, 0);
clif->message(fd, msg_txt(112)); // Npc Disabled.
return true;
@@ -4191,26 +4183,26 @@ ACMD(hidenpc)
ACMD(loadnpc)
{
FILE *fp;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1132)); // Please enter a script file name (usage: @loadnpc <file name>).
return false;
}
-
+
// check if script file exists
if ((fp = fopen(message, "r")) == NULL) {
clif->message(fd, msg_txt(261));
return false;
}
fclose(fp);
-
+
// add to list of script sources and run it
npc->addsrcfile(message);
npc->parsesrcfile(message,true);
npc->read_event_script();
-
+
clif->message(fd, msg_txt(262));
-
+
return true;
}
@@ -4218,19 +4210,19 @@ ACMD(unloadnpc)
{
struct npc_data *nd;
char NPCname[NAME_LENGTH+1];
-
+
memset(NPCname, '\0', sizeof(NPCname));
-
+
if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
clif->message(fd, msg_txt(1133)); // Please enter a NPC name (usage: @npcoff <NPC_name>).
return false;
}
-
+
if ((nd = npc->name2id(NPCname)) == NULL) {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
return false;
}
-
+
npc->unload_duplicates(nd);
npc->unload(nd,true);
npc->read_event_script();
@@ -4246,16 +4238,16 @@ char* txt_time(unsigned int duration)
int days, hours, minutes, seconds;
static char temp1[CHAT_SIZE_MAX];
int tlen = 0;
-
+
memset(temp1, '\0', sizeof(temp1));
-
+
days = duration / (60 * 60 * 24);
duration = duration - (60 * 60 * 24 * days);
hours = duration / (60 * 60);
duration = duration - (60 * 60 * hours);
minutes = duration / 60;
seconds = duration - (60 * minutes);
-
+
if (days == 1)
tlen += sprintf(tlen + temp1, msg_txt(219), days); // %d day
else if (days > 1)
@@ -4272,7 +4264,7 @@ char* txt_time(unsigned int duration)
sprintf(tlen + temp1, msg_txt(225), seconds); // and %d second
else if (seconds > 1)
sprintf(tlen + temp1, msg_txt(226), seconds); // and %d seconds
-
+
return temp1;
}
@@ -4284,19 +4276,19 @@ ACMD(servertime) {
time_t time_server; // variable for number of seconds (used with time() function)
struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
char temp[CHAT_SIZE_MAX];
-
+
memset(temp, '\0', sizeof(temp));
-
+
time(&time_server); // get time in seconds since 1/1/1970
datetime = localtime(&time_server); // convert seconds in structure
// like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
clif->message(fd, temp);
-
+
if (pc->day_timer_tid != INVALID_TIMER && pc->night_timer_tid != INVALID_TIMER) {
const struct TimerData * timer_data = timer->get(pc->night_timer_tid);
const struct TimerData * timer_data2 = timer->get(pc->day_timer_tid);
-
+
if (map->night_flag == 0) {
sprintf(temp, msg_txt(235), // Game time: The game is actually in daylight for %s.
txt_time((unsigned int)(DIFF_TICK(timer_data->tick,timer->gettick())/1000)));
@@ -4328,7 +4320,7 @@ ACMD(servertime) {
else
clif->message(fd, msg_txt(232)); // Game time: The game is in permanent night.
}
-
+
return true;
}
@@ -4341,7 +4333,7 @@ void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int
const int factor_month = 43200; //30*24*60 = 43200
const int factor_day = 1440; //24*60 = 1440
const int factor_hour = 60;
-
+
*year = jailtime/factor_year;
jailtime -= *year*factor_year;
*month = jailtime/factor_month;
@@ -4351,7 +4343,7 @@ void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int
*hour = jailtime/factor_hour;
jailtime -= *hour*factor_hour;
*minute = jailtime;
-
+
*year = *year > 0? *year : 0;
*month = *month > 0? *month : 0;
*day = *day > 0? *day : 0;
@@ -4368,31 +4360,31 @@ ACMD(jail) {
struct map_session_data *pl_sd;
int x, y;
unsigned short m_index;
-
+
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1134)); // Please enter a player name (usage: @jail <char_name>).
return false;
}
-
+
if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
- if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
- { // you can jail only lower or same GM
+
+ if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
+ // you can jail only lower or same GM
clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
return false;
}
-
+
if (pl_sd->sc.data[SC_JAILED])
{
clif->message(fd, msg_txt(118)); // Player warped in jails.
return false;
}
-
+
switch(rnd() % 2) { //Jail Locations
case 0:
m_index = mapindex->name2id(MAP_JAIL);
@@ -4405,7 +4397,7 @@ ACMD(jail) {
y = 75;
break;
}
-
+
//Duration of INT_MAX to specify infinity.
sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
clif->message(pl_sd->fd, msg_txt(117)); // You have been jailed by a GM.
@@ -4419,31 +4411,31 @@ ACMD(jail) {
*------------------------------------------*/
ACMD(unjail) {
struct map_session_data *pl_sd;
-
+
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
return false;
}
-
+
if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
-
+
clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
return false;
}
-
+
if (!pl_sd->sc.data[SC_JAILED])
{
clif->message(fd, msg_txt(119)); // This player is not in jails.
return false;
}
-
+
//Reset jail time to 1 sec.
sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
clif->message(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
@@ -4457,14 +4449,14 @@ ACMD(jailfor) {
char * modif_p;
int jailtime = 0,x,y;
short m_index = 0;
-
+
if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
- clif->message(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
+ clif->message(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
return false;
}
-
+
atcmd_output[sizeof(atcmd_output)-1] = '\0';
-
+
modif_p = atcmd_output;
year = month = day = hour = minute = 0;
while (modif_p[0] != '\0') {
@@ -4499,33 +4491,32 @@ ACMD(jailfor) {
}
}
}
-
+
if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
clif->message(fd, msg_txt(1136)); // Invalid time for jail command.
return false;
}
-
+
if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
return false;
}
-
- jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
-
+
+ jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
+
if(jailtime==0) {
clif->message(fd, msg_txt(1136)); // Invalid time for jail command.
return false;
}
-
+
//Added by Coltaro
- if(pl_sd->sc.data[SC_JAILED] &&
- pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
- { //Update the player's jail time
+ if (pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) {
+ //Update the player's jail time
jailtime += pl_sd->sc.data[SC_JAILED]->val1;
if (jailtime <= 0) {
jailtime = 0;
@@ -4534,15 +4525,15 @@ ACMD(jailfor) {
} else {
atcommand->get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
sprintf(atcmd_output,msg_txt(402),msg_txt(1137),year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
- clif->message(pl_sd->fd, atcmd_output);
+ clif->message(pl_sd->fd, atcmd_output);
sprintf(atcmd_output,msg_txt(402),msg_txt(1138),year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
- clif->message(fd, atcmd_output);
+ clif->message(fd, atcmd_output);
}
} else if (jailtime < 0) {
clif->message(fd, msg_txt(1136));
return false;
}
-
+
//Jail locations, add more as you wish.
switch(rnd()%2)
{
@@ -4555,7 +4546,7 @@ ACMD(jailfor) {
x = 24; y = 75;
break;
}
-
+
sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status->change_timer).
return true;
}
@@ -4565,28 +4556,28 @@ ACMD(jailfor) {
ACMD(jailtime)
{
int year, month, day, hour, minute;
-
+
if (!sd->sc.data[SC_JAILED]) {
clif->message(fd, msg_txt(1139)); // You are not in jail.
return false;
}
-
+
if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
clif->message(fd, msg_txt(1140)); // You have been jailed indefinitely.
return true;
}
-
+
if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
clif->message(fd, msg_txt(1141)); // You have been jailed for an unknown amount of time.
return false;
}
-
+
//Get remaining jail time
atcommand->get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
sprintf(atcmd_output,msg_txt(402),msg_txt(1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
-
+
clif->message(fd, atcmd_output);
-
+
return true;
}
@@ -4596,17 +4587,18 @@ ACMD(jailtime)
ACMD(disguise)
{
int id = 0;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
return false;
}
-
- if ((id = atoi(message)) > 0)
- { //Acquired an ID
+
+ if ((id = atoi(message)) > 0) {
+ //Acquired an ID
if (!mob->db_checkid(id) && !npcdb_checkid(id))
id = 0; //Invalid id for either mobs or npcs.
- } else { //Acquired a Name
+ } else {
+ //Acquired a Name
if ((id = mob->db_searchname(message)) == 0)
{
struct npc_data* nd = npc->name2id(message);
@@ -4614,19 +4606,18 @@ ACMD(disguise)
id = nd->class_;
}
}
-
+
if (id == 0)
{
- clif->message(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
+ clif->message(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
return false;
}
-
- if(pc_isriding(sd))
- {
+
+ if (pc_hasmount(sd)) {
clif->message(fd, msg_txt(1144)); // Character cannot be disguised while mounted.
return false;
}
-
+
if(sd->sc.data[SC_MONSTER_TRANSFORM])
{
clif->message(fd, msg_txt(1487)); // Character cannot be disguised while in monster form.
@@ -4635,7 +4626,7 @@ ACMD(disguise)
pc->disguise(sd, id);
clif->message(fd, msg_txt(122)); // Disguise applied.
-
+
return true;
}
@@ -4647,25 +4638,25 @@ ACMD(disguiseall)
int mob_id=0;
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
return false;
}
-
+
if ((mob_id = mob->db_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
mob_id = atoi(message);
-
+
if (!mob->db_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
clif->message(fd, msg_txt(123)); // Monster/NPC name/id not found.
return false;
}
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
pc->disguise(pl_sd, mob_id);
mapit->free(iter);
-
+
clif->message(fd, msg_txt(122)); // Disguise applied.
return true;
}
@@ -4679,15 +4670,15 @@ ACMD(disguiseguild)
char monster[NAME_LENGTH], guild_name[NAME_LENGTH];
struct map_session_data *pl_sd;
struct guild *g;
-
+
memset(monster, '\0', sizeof(monster));
memset(guild_name, '\0', sizeof(guild_name));
-
+
if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild_name) < 2 ) {
clif->message(fd, msg_txt(1146)); // Please enter a mob name/ID and guild name/ID (usage: @disguiseguild <mob name/ID>, <guild name/ID>).
return false;
}
-
+
if( (id = atoi(monster)) > 0 ) {
if( !mob->db_checkid(id) && !npcdb_checkid(id) )
id = 0;
@@ -4698,21 +4689,21 @@ ACMD(disguiseguild)
id = nd->class_;
}
}
-
+
if( id == 0 ) {
- clif->message(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
+ clif->message(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
return false;
}
-
+
if( (g = guild->searchname(guild_name)) == NULL && (g = guild->search(atoi(guild_name))) == NULL ) {
clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
return false;
}
-
- for( i = 0; i < g->max_member; i++ )
- if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
+
+ for (i = 0; i < g->max_member; i++)
+ if ((pl_sd = g->member[i].sd) && !pc_hasmount(pl_sd))
pc->disguise(pl_sd, id);
-
+
clif->message(fd, msg_txt(122)); // Disguise applied.
return true;
}
@@ -4730,7 +4721,7 @@ ACMD(undisguise)
clif->message(fd, msg_txt(125)); // You're not disguised.
return false;
}
-
+
return true;
}
@@ -4740,15 +4731,15 @@ ACMD(undisguise)
ACMD(undisguiseall) {
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
if( pl_sd->disguise != -1 )
pc->disguise(pl_sd, -1);
mapit->free(iter);
-
+
clif->message(fd, msg_txt(124)); // Disguise removed.
-
+
return true;
}
@@ -4761,25 +4752,25 @@ ACMD(undisguiseguild)
struct map_session_data *pl_sd;
struct guild *g;
int i;
-
+
memset(guild_name, '\0', sizeof(guild_name));
-
+
if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
clif->message(fd, msg_txt(1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
return false;
}
-
+
if( (g = guild->searchname(guild_name)) == NULL && (g = guild->search(atoi(message))) == NULL ) {
clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
return false;
}
-
+
for(i = 0; i < g->max_member; i++)
if( (pl_sd = g->member[i].sd) && pl_sd->disguise != -1 )
pc->disguise(pl_sd, -1);
-
+
clif->message(fd, msg_txt(124)); // Disguise removed.
-
+
return true;
}
@@ -4792,15 +4783,15 @@ ACMD(exp)
double nextb, nextj;
memset(output, '\0', sizeof(output));
-
+
nextb = pc->nextbaseexp(sd);
if (nextb)
nextb = sd->status.base_exp*100.0/nextb;
-
+
nextj = pc->nextjobexp(sd);
if (nextj)
nextj = sd->status.job_exp*100.0/nextj;
-
+
sprintf(output, msg_txt(1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
clif->message(fd, output);
return true;
@@ -4812,17 +4803,16 @@ ACMD(exp)
*------------------------------------------*/
ACMD(broadcast)
{
-
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1149)); // Please enter a message (usage: @broadcast <message>).
return false;
}
-
+
sprintf(atcmd_output, "%s: %s", sd->status.name, message);
intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
-
+
return true;
}
@@ -4832,16 +4822,16 @@ ACMD(broadcast)
ACMD(localbroadcast)
{
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1150)); // Please enter a message (usage: @localbroadcast <message>).
return false;
}
-
+
sprintf(atcmd_output, "%s: %s", sd->status.name, message);
-
+
clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
-
+
return true;
}
@@ -4852,15 +4842,15 @@ ACMD(email)
{
char actual_email[100];
char new_email[100];
-
+
memset(actual_email, '\0', sizeof(actual_email));
memset(new_email, '\0', sizeof(new_email));
-
+
if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
clif->message(fd, msg_txt(1151)); // Please enter two e-mail addresses (usage: @email <current@email> <new@email>).
return false;
}
-
+
if (e_mail_check(actual_email) == 0) {
clif->message(fd, msg_txt(144)); // Invalid e-mail. If your email hasn't been set, use a@a.com.
return false;
@@ -4874,7 +4864,7 @@ ACMD(email)
clif->message(fd, msg_txt(147)); // New e-mail must be different from the current e-mail address.
return false;
}
-
+
chrif->changeemail(sd->status.account_id, actual_email, new_email);
clif->message(fd, msg_txt(148)); // Information sended to login-server via char-server.
return true;
@@ -4886,12 +4876,12 @@ ACMD(email)
ACMD(effect)
{
int type = 0, flag = 0;
-
+
if (!message || !*message || sscanf(message, "%d", &type) < 1) {
clif->message(fd, msg_txt(1152)); // Please enter an effect number (usage: @effect <effect number>).
return false;
}
-
+
clif->specialeffect(&sd->bl, type, (send_target)flag);
clif->message(fd, msg_txt(229)); // Your effect has changed.
return true;
@@ -4904,7 +4894,7 @@ ACMD(effect)
ACMD(killer)
{
sd->state.killer = !sd->state.killer;
-
+
if(sd->state.killer)
clif->message(fd, msg_txt(241));
else {
@@ -4920,7 +4910,7 @@ ACMD(killer)
*------------------------------------------*/
ACMD(killable) {
sd->state.killable = !sd->state.killable;
-
+
if(sd->state.killable)
clif->message(fd, msg_txt(242));
else {
@@ -4959,29 +4949,29 @@ ACMD(npcmove) {
struct npc_data *nd = 0;
memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
-
+
if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
clif->message(fd, msg_txt(1153)); // Usage: @npcmove <X> <Y> <npc_name>
return false;
}
-
+
if ((nd = npc->name2id(atcmd_player_name)) == NULL) {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
return false;
}
-
+
if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL) {
clif->message(fd, msg_txt(1154)); // NPC is not in this map.
- return false; //Not on a map.
+ return false; //Not on a map.
}
-
+
x = cap_value(x, 0, map->list[m].xs-1);
y = cap_value(y, 0, map->list[m].ys-1);
map->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
map->moveblock(&nd->bl, x, y, timer->gettick());
map->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
clif->message(fd, msg_txt(1155)); // NPC moved.
-
+
return true;
}
@@ -4995,14 +4985,14 @@ ACMD(addwarp)
int x,y;
unsigned short m;
struct npc_data* nd;
-
+
memset(warpname, '\0', sizeof(warpname));
-
+
if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) {
clif->message(fd, msg_txt(1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
return false;
}
-
+
m = mapindex->name2id(mapname);
if( m == 0 )
{
@@ -5010,11 +5000,11 @@ ACMD(addwarp)
clif->message(fd, atcmd_output);
return false;
}
-
+
nd = npc->add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
if( nd == NULL )
return false;
-
+
sprintf(atcmd_output, msg_txt(1158), nd->exname); // New warp NPC '%s' created.
clif->message(fd, atcmd_output);
return true;
@@ -5026,22 +5016,21 @@ ACMD(addwarp)
*------------------------------------------*/
ACMD(follow) {
struct map_session_data *pl_sd = NULL;
-
+
if (!message || !*message) {
if (sd->followtarget == -1)
return false;
-
pc->stop_following (sd);
clif->message(fd, msg_txt(1159)); // Follow mode OFF.
return true;
}
-
+
if ( (pl_sd = map->nick2sd((char *)message)) == NULL )
{
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
if (sd->followtarget == pl_sd->bl.id) {
pc->stop_following (sd);
clif->message(fd, msg_txt(1159)); // Follow mode OFF.
@@ -5049,7 +5038,7 @@ ACMD(follow) {
pc->follow(sd, pl_sd->bl.id);
clif->message(fd, msg_txt(1160)); // Follow mode ON.
}
-
+
return true;
}
@@ -5079,15 +5068,15 @@ ACMD(dropall)
ACMD(storeall)
{
int i;
-
- if (sd->state.storage_flag != 1)
- { //Open storage.
+
+ if (sd->state.storage_flag != 1) {
+ //Open storage.
if( storage->open(sd) == 1 ) {
clif->message(fd, msg_txt(1161)); // You currently cannot open your storage.
return false;
}
}
-
+
for (i = 0; i < MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount) {
if(sd->status.inventory[i].equip != 0)
@@ -5096,7 +5085,7 @@ ACMD(storeall)
}
}
storage->close(sd);
-
+
clif->message(fd, msg_txt(1162)); // All items stored.
return true;
}
@@ -5104,18 +5093,18 @@ ACMD(storeall)
ACMD(clearstorage)
{
int i, j;
-
+
if (sd->state.storage_flag == 1) {
clif->message(fd, msg_txt(250));
return false;
}
-
+
j = sd->status.storage.storage_amount;
for (i = 0; i < j; ++i) {
storage->delitem(sd, i, sd->status.storage.items[i].amount);
}
storage->close(sd);
-
+
clif->message(fd, msg_txt(1394)); // Your storage was cleaned.
return true;
}
@@ -5125,29 +5114,29 @@ ACMD(cleargstorage)
int i, j;
struct guild *g;
struct guild_storage *guild_storage;
-
+
g = sd->guild;
-
+
if (g == NULL) {
clif->message(fd, msg_txt(43));
return false;
}
-
+
if (sd->state.storage_flag == 1) {
clif->message(fd, msg_txt(250));
return false;
}
-
+
if (sd->state.storage_flag == 2) {
clif->message(fd, msg_txt(251));
return false;
}
-
- guild_storage = gstorage->id2storage2(sd->status.guild_id);
+
+ guild_storage = idb_get(gstorage->db,sd->status.guild_id);
if (guild_storage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
return false;
}
-
+
j = guild_storage->storage_amount;
guild_storage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
for (i = 0; i < j; ++i) {
@@ -5155,7 +5144,7 @@ ACMD(cleargstorage)
}
gstorage->close(sd);
guild_storage->lock = 0; // Cleaning done, release lock
-
+
clif->message(fd, msg_txt(1395)); // Your guild storage was cleaned.
return true;
}
@@ -5163,24 +5152,24 @@ ACMD(cleargstorage)
ACMD(clearcart)
{
int i;
-
+
if (pc_iscarton(sd) == 0) {
clif->message(fd, msg_txt(1396)); // You do not have a cart to be cleaned.
return false;
}
-
+
if( sd->state.vending == 1 ) {
clif->message(fd, msg_txt(548)); // You can't clean a cart while vending!
- return false;
- }
-
+ return false;
+ }
+
for( i = 0; i < MAX_CART; i++ )
if(sd->status.cart[i].nameid > 0)
pc->cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
-
+
clif->clearcart(fd);
clif->updatestatus(sd,SP_CARTINFO);
-
+
clif->message(fd, msg_txt(1397)); // Your cart was cleaned.
return true;
}
@@ -5198,16 +5187,16 @@ ACMD(skillid) {
DBKey key;
DBData *data;
char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
return false;
}
-
+
skillen = strlen(message);
-
+
iter = db_iterator(skill->name2id_db);
-
+
for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
idx = skill->get_index(DB->data2i(data));
if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill->db[idx].desc, message, skillen) == 0) {
@@ -5217,18 +5206,18 @@ ACMD(skillid) {
snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(1164), DB->data2i(data), skill->db[idx].desc, key.str);
}
}
-
+
dbi_destroy(iter);
-
+
if( found ) {
sprintf(atcmd_output, msg_txt(1398), found); // -- Displaying first %d partial matches
clif->message(fd, atcmd_output);
}
-
+
for(i = 0; i < found; i++) { /* partials */
clif->message(fd, partials[i]);
}
-
+
return true;
}
@@ -5242,38 +5231,38 @@ ACMD(useskill) {
uint16 skill_id;
uint16 skill_lv;
char target[100];
-
+
if(!message || !*message || sscanf(message, "%hu %hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
clif->message(fd, msg_txt(1165)); // Usage: @useskill <skill ID> <skill level> <target>
return false;
}
-
+
if(!strcmp(target,"self"))
pl_sd = sd; //quick keyword
else if ( (pl_sd = map->nick2sd(target)) == NULL ) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
{
clif->message(fd, msg_txt(81)); // Your GM level don't authorized you to do this action on this player.
return false;
}
-
+
if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL
&& sd->hd && homun_alive(sd->hd)) // (If used with @useskill, put the homunc as dest)
bl = &sd->hd->bl;
else
bl = &sd->bl;
-
+
pc->delinvincibletimer(sd);
-
+
if (skill->get_inf(skill_id)&INF_GROUND_SKILL)
unit->skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
else
unit->skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
-
+
return true;
}
@@ -5287,7 +5276,7 @@ ACMD(displayskill) {
int64 tick;
uint16 skill_id;
uint16 skill_lv = 1;
-
+
if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1) {
clif->message(fd, msg_txt(1166)); // Usage: @displayskill <skill ID> {<skill level>}
return false;
@@ -5310,32 +5299,32 @@ ACMD(skilltree) {
int meets, j, c=0;
char target[NAME_LENGTH];
struct skill_tree_entry *ent;
-
+
if(!message || !*message || sscanf(message, "%hu %23[^\r\n]", &skill_id, target) != 2) {
clif->message(fd, msg_txt(1167)); // Usage: @skilltree <skill ID> <target>
return false;
}
-
+
if ( (pl_sd = map->nick2sd(target)) == NULL ) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
c = pc->calc_skilltree_normalize_job(pl_sd);
c = pc->mapid2jobid(c, pl_sd->status.sex);
-
+
sprintf(atcmd_output, msg_txt(1168), pc->job_name(c), pc->checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
clif->message(fd, atcmd_output);
-
+
ARR_FIND( 0, MAX_SKILL_TREE, j, pc->skill_tree[c][j].id == 0 || pc->skill_tree[c][j].id == skill_id );
if( j == MAX_SKILL_TREE || pc->skill_tree[c][j].id == 0 )
{
clif->message(fd, msg_txt(1169)); // The player cannot use that skill.
return false;
}
-
+
ent = &pc->skill_tree[c][j];
-
+
meets = 1;
for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
{
@@ -5349,7 +5338,7 @@ ACMD(skilltree) {
if (meets == 1) {
clif->message(fd, msg_txt(1171)); // The player meets all the requirements for that skill.
}
-
+
return true;
}
@@ -5358,14 +5347,14 @@ void getring(struct map_session_data* sd) {
int flag, item_id;
struct item item_tmp;
item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
-
+
memset(&item_tmp, 0, sizeof(item_tmp));
item_tmp.nameid = item_id;
item_tmp.identify = 1;
item_tmp.card[0] = 255;
item_tmp.card[2] = sd->status.partner_id;
item_tmp.card[3] = sd->status.partner_id >> 16;
-
+
if((flag = pc->additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
clif->additem(sd,0,0,flag);
map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
@@ -5379,17 +5368,17 @@ void getring(struct map_session_data* sd) {
ACMD(marry) {
struct map_session_data *pl_sd = NULL;
char player_name[NAME_LENGTH] = "";
-
+
if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
clif->message(fd, msg_txt(1172)); // Usage: @marry <char name>
return false;
}
-
+
if ((pl_sd = map->nick2sd(player_name)) == NULL) {
clif->message(fd, msg_txt(3));
return false;
}
-
+
if (pc->marriage(sd, pl_sd) == 0) {
clif->message(fd, msg_txt(1173)); // They are married... wish them well.
clif->wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
@@ -5397,7 +5386,7 @@ ACMD(marry) {
getring(pl_sd);
return true;
}
-
+
clif->message(fd, msg_txt(1174)); // The two cannot wed because one is either a baby or already married.
return false;
}
@@ -5413,7 +5402,7 @@ ACMD(divorce)
clif->message(fd, atcmd_output);
return false;
}
-
+
sprintf(atcmd_output, msg_txt(1176), sd->status.name); // '%s' and his/her partner are now divorced.
clif->message(fd, atcmd_output);
return true;
@@ -5426,7 +5415,7 @@ ACMD(changelook)
{
int i, j = 0, k = 0;
int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
-
+
if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
clif->message(fd, msg_txt(1177)); // Usage: @changelook {<position>} <view id>
clif->message(fd, msg_txt(1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
@@ -5435,13 +5424,13 @@ ACMD(changelook)
if (j < 1 || j > 7)
j = 1;
j = pos[j - 1];
- } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
- k = j; // swap
+ } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
+ k = j; // swap
j = LOOK_HEAD_TOP;
}
-
+
clif->changelook(&sd->bl,j,k);
-
+
return true;
}
@@ -5449,44 +5438,42 @@ ACMD(changelook)
* @autotrade by durf [Lupus] [Paradox924X]
* Turns on/off Autotrade for a specific player
*------------------------------------------*/
-ACMD(autotrade) {
-
+ACMD(autotrade)
+{
if( map->list[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
clif->message(fd, msg_txt(1179)); // Autotrade is not allowed in this map.
return false;
}
-
+
if( pc_isdead(sd) ) {
clif->message(fd, msg_txt(1180)); // You cannot autotrade when dead.
return false;
}
-
+
if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
clif->message(fd, msg_txt(549)); // "You should have a shop open in order to use @autotrade."
return false;
}
-
+
sd->state.autotrade = 1;
if( battle_config.at_timeout ) {
int timeout = atoi(message);
- status->change_start(NULL,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
+ status->change_start(NULL,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0,
+ ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, SCFLAG_NONE);
}
+ clif->chsys_quit(sd);
+
+ clif->authfail_fd(sd->fd, 15);
+
/* currently standalone is not supporting buyingstores, so we rely on the previous method */
- if( sd->state.buyingstore ) {
- clif->authfail_fd(fd, 15);
+ if( sd->state.buyingstore )
return true;
- }
-
- clif->chsys_quit(sd);
-
- clif->authfail_fd(sd->fd, 15);
-
-
#ifdef AUTOTRADE_PERSISTENCY
+ sd->state.autotrade = 2;/** state will enter pre-save, we use it to rule out some criterias **/
pc->autotrade_prepare(sd);
-
+
return false;/* we fail to not cause it to proceed on is_atcommand */
#else
return true;
@@ -5500,27 +5487,27 @@ ACMD(autotrade) {
ACMD(changegm) {
struct guild *g;
struct map_session_data *pl_sd;
-
+
if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
clif->message(fd, msg_txt(1181)); // You need to be a Guild Master to use this command.
return false;
}
-
+
if( map->list[sd->bl.m].flag.guildlock || map->list[sd->bl.m].flag.gvg_castle ) {
clif->message(fd, msg_txt(1182)); // You cannot change guild leaders in this map.
return false;
}
-
+
if( !message[0] ) {
clif->message(fd, msg_txt(1183)); // Usage: @changegm <guild_member_name>
return false;
}
-
+
if((pl_sd=map->nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
clif->message(fd, msg_txt(1184)); // Target character must be online and be a guild member.
return false;
}
-
+
guild->gm_change(sd->status.guild_id, pl_sd);
return true;
}
@@ -5530,12 +5517,12 @@ ACMD(changegm) {
* Changes the leader of a party.
*------------------------------------------*/
ACMD(changeleader) {
-
+
if( !message[0] ) {
clif->message(fd, msg_txt(1185)); // Usage: @changeleader <party_member_name>
return false;
}
-
+
if (party->changeleader(sd, map->nick2sd((char *) message)))
return true;
return false;
@@ -5550,37 +5537,37 @@ ACMD(partyoption)
struct party_data *p;
int mi, option;
char w1[16], w2[16];
-
+
if (sd->status.party_id == 0 || (p = party->search(sd->status.party_id)) == NULL)
{
clif->message(fd, msg_txt(282));
return false;
}
-
+
ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
if (mi == MAX_PARTY)
return false; //Shouldn't happen
-
+
if (!p->party.member[mi].leader)
{
clif->message(fd, msg_txt(282));
return false;
}
-
+
if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
{
clif->message(fd, msg_txt(1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
return false;
}
-
+
option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
-
+
//Change item share type.
if (option != p->party.item)
party->changeoption(sd, p->party.exp, option);
else
clif->message(fd, msg_txt(286));
-
+
return true;
}
@@ -5606,14 +5593,14 @@ ACMD(autoloot)
}
if (rate < 0) rate = 0;
if (rate > 10000) rate = 10000;
-
+
sd->state.autoloot = rate;
if (sd->state.autoloot) {
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1187),((double)sd->state.autoloot)/100.); // Autolooting items with drop rates of %0.02f%% and below.
clif->message(fd, atcmd_output);
}else
clif->message(fd, msg_txt(1188)); // Autoloot is now off.
-
+
return true;
}
@@ -5625,7 +5612,7 @@ ACMD(autolootitem)
struct item_data *item_data = NULL;
int i;
int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
-
+
if (message && *message) {
if (message[0] == '+') {
message++;
@@ -5649,7 +5636,7 @@ ACMD(autolootitem)
}
}
}
-
+
switch(action) {
case 1:
ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
@@ -5813,8 +5800,8 @@ ACMD(autoloottype) {
/*==========================================
* It is made to snow.
*------------------------------------------*/
-ACMD(snow) {
-
+ACMD(snow)
+{
if (map->list[sd->bl.m].flag.snow) {
map->list[sd->bl.m].flag.snow=0;
clif->weather(sd->bl.m);
@@ -5824,7 +5811,7 @@ ACMD(snow) {
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(1204)); // It has started to snow.
}
-
+
return true;
}
@@ -5859,7 +5846,7 @@ ACMD(clouds) {
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(1208)); // Clouds appear.
}
-
+
return true;
}
@@ -5877,7 +5864,7 @@ ACMD(clouds2) {
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(1210)); // Alternative clouds appear.
}
-
+
return true;
}
@@ -5912,7 +5899,7 @@ ACMD(leaves) {
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(1214)); // Fallen leaves fall.
}
-
+
return true;
}
@@ -5930,15 +5917,15 @@ ACMD(fireworks) {
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(1216)); // Fireworks have launched.
}
-
+
return true;
}
/*==========================================
* Clearing Weather Effects by Dexity
*------------------------------------------*/
-ACMD(clearweather) {
-
+ACMD(clearweather)
+{
map->list[sd->bl.m].flag.snow=0;
map->list[sd->bl.m].flag.sakura=0;
map->list[sd->bl.m].flag.clouds=0;
@@ -5948,7 +5935,7 @@ ACMD(clearweather) {
map->list[sd->bl.m].flag.leaves=0;
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(291)); // "Weather effects will disappear after teleporting or refreshing."
-
+
return true;
}
@@ -5958,24 +5945,24 @@ ACMD(clearweather) {
ACMD(sound)
{
char sound_file[100];
-
+
memset(sound_file, '\0', sizeof(sound_file));
-
+
if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
clif->message(fd, msg_txt(1217)); // Please enter a sound filename (usage: @sound <filename>).
return false;
}
-
+
if(strstr(sound_file, ".wav") == NULL)
strcat(sound_file, ".wav");
-
+
clif->soundeffectall(&sd->bl, sound_file, 0, AREA);
-
+
return true;
}
/*==========================================
- * MOB Search
+ * MOB Search
*------------------------------------------*/
ACMD(mobsearch)
{
@@ -5983,12 +5970,12 @@ ACMD(mobsearch)
int mob_id;
int number = 0;
struct s_mapiterator* it;
-
+
if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
clif->message(fd, msg_txt(1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
return false;
}
-
+
if ((mob_id = atoi(mob_name)) == 0)
mob_id = mob->db_searchname(mob_name);
if(mob_id > 0 && mob->db_checkid(mob_id) == 0){
@@ -5997,24 +5984,24 @@ ACMD(mobsearch)
return false;
}
if(mob_id == atoi(mob_name) && mob->db(mob_id)->jname)
- strcpy(mob_name,mob->db(mob_id)->jname); // --ja--
- // strcpy(mob_name,mob_db(mob_id)->name); // --en--
-
+ strcpy(mob_name,mob->db(mob_id)->jname); // --ja--
+ //strcpy(mob_name,mob_db(mob_id)->name); // --en--
+
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
clif->message(fd, atcmd_output);
-
+
it = mapit_geteachmob();
for(;;)
{
TBL_MOB* md = (TBL_MOB*)mapit->next(it);
if( md == NULL )
break;// no more mobs
-
+
if( md->bl.m != sd->bl.m )
continue;
if( mob_id != -1 && md->class_ != mob_id )
continue;
-
+
++number;
if( md->spawn_timer == INVALID_TIMER )
snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
@@ -6023,7 +6010,7 @@ ACMD(mobsearch)
clif->message(fd, atcmd_output);
}
mapit->free(it);
-
+
return true;
}
@@ -6034,7 +6021,7 @@ ACMD(mobsearch)
int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) {
nullpo_ret(bl);
map->clearflooritem(bl);
-
+
return 0;
}
@@ -6046,7 +6033,7 @@ ACMD(cleanmap) {
ACMD(cleanarea) {
int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
-
+
if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
map->foreachinrange(atcommand->cleanfloor_sub, &sd->bl, AREA_SIZE * 2, BL_ITEM);
} else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) {
@@ -6054,7 +6041,7 @@ ACMD(cleanarea) {
} else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
map->foreachinarea(atcommand->cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
}
-
+
clif->message(fd, msg_txt(1221)); // All dropped items have been cleaned up.
return true;
}
@@ -6069,12 +6056,12 @@ ACMD(npctalk)
struct npc_data *nd;
bool ifcolor=(*(info->command + 7) != 'c' && *(info->command + 7) != 'C')?0:1;
unsigned int color = 0;
-
+
if (sd->sc.count && //no "chatting" while muted.
(sd->sc.data[SC_BERSERK] || (sd->sc.data[SC_DEEP_SLEEP] && sd->sc.data[SC_DEEP_SLEEP]->val2) ||
(sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
return false;
-
+
if(!ifcolor) {
if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
clif->message(fd, msg_txt(1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
@@ -6087,18 +6074,18 @@ ACMD(npctalk)
return false;
}
}
-
+
if (!(nd = npc->name2id(name))) {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist
return false;
}
-
+
strtok(name, "#"); // discard extra name identifier if present
snprintf(temp, sizeof(temp), "%s : %s", name, mes);
-
+
if(ifcolor) clif->messagecolor(&nd->bl,color,temp);
else clif->disp_overhead(&nd->bl, temp);
-
+
return true;
}
@@ -6106,29 +6093,29 @@ ACMD(pettalk)
{
char mes[100],temp[100];
struct pet_data *pd;
-
+
if ( battle_config.min_chat_delay ) {
if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 )
return true;
sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay;
}
-
+
if(!sd->status.pet_id || !(pd=sd->pd))
{
clif->message(fd, msg_txt(184));
return false;
}
-
+
if (sd->sc.count && //no "chatting" while muted.
(sd->sc.data[SC_BERSERK] || (sd->sc.data[SC_DEEP_SLEEP] && sd->sc.data[SC_DEEP_SLEEP]->val2) ||
(sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
return false;
-
+
if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
clif->message(fd, msg_txt(1224)); // Please enter a message (usage: @pettalk <message>).
return false;
}
-
+
if (message[0] == '/')
{// pet emotion processing
const char* emo[] = {
@@ -6152,15 +6139,15 @@ ACMD(pettalk)
return true;
}
sd->emotionlasttime = time(NULL);
-
+
clif->emotion(&pd->bl, i);
return true;
}
}
-
+
snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
clif->disp_overhead(&pd->bl, temp);
-
+
return true;
}
@@ -6173,10 +6160,10 @@ ACMD(users)
int users[MAX_MAPINDEX];
int users_all;
struct s_mapiterator* iter;
-
+
memset(users, 0, sizeof(users));
users_all = 0;
-
+
// count users on each map
iter = mapit_getallusers();
for(;;)
@@ -6184,29 +6171,29 @@ ACMD(users)
struct map_session_data* sd2 = (struct map_session_data*)mapit->next(iter);
if( sd2 == NULL )
break;// no more users
-
+
if( sd2->mapindex >= MAX_MAPINDEX )
continue;// invalid mapindex
-
+
if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
if( users_all < INT_MAX ) ++users_all;
}
mapit->free(iter);
-
+
// display results for each map
for( i = 0; i < MAX_MAPINDEX; ++i )
{
if( users[i] == 0 )
continue;// empty
-
+
safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
clif->message(sd->fd, buf);
}
-
+
// display overall count
safesnprintf(buf, sizeof(buf), "all: %d", users_all);
clif->message(sd->fd, buf);
-
+
return true;
}
@@ -6232,31 +6219,31 @@ ACMD(summon)
int duration = 0;
struct mob_data *md;
int64 tick=timer->gettick();
-
+
if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
{
clif->message(fd, msg_txt(1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
return false;
}
-
+
if (duration < 1)
duration =1;
else if (duration > 60)
duration =60;
-
+
if ((mob_id = atoi(name)) == 0)
mob_id = mob->db_searchname(name);
if(mob_id == 0 || mob->db_checkid(mob_id) == 0)
{
- clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
+ clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
return false;
}
-
- md = mob->once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_MEDIUM, AI_NONE);
-
+
+ md = mob->once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
+
if(!md)
return false;
-
+
md->master_id=sd->bl.id;
md->special_state.ai=1;
md->deletetimer=timer->add(tick+(duration*60000),mob->timer_delete,md->bl.id,0);
@@ -6264,8 +6251,8 @@ ACMD(summon)
mob->spawn(md);
sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
clif->skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
- clif->message(fd, msg_txt(39)); // All monster summoned!
-
+ clif->message(fd, msg_txt(39)); // All monster summoned!
+
return true;
}
@@ -6277,12 +6264,12 @@ ACMD(summon)
ACMD(adjgroup)
{
int new_group = 0;
-
+
if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
clif->message(fd, msg_txt(1226)); // Usage: @adjgroup <group_id>
return false;
}
-
+
if (pc->set_group(sd, new_group) != 0) {
clif->message(fd, msg_txt(1227)); // Specified group does not exist.
return false;
@@ -6298,18 +6285,18 @@ ACMD(adjgroup)
* Open a trade window with a remote player
*------------------------------------------*/
ACMD(trade) {
- struct map_session_data *pl_sd = NULL;
-
+ struct map_session_data *pl_sd = NULL;
+
if (!message || !*message) {
clif->message(fd, msg_txt(1230)); // Please enter a player name (usage: @trade <char name>).
return false;
}
-
+
if ( (pl_sd = map->nick2sd((char *)message)) == NULL ) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
trade->request(sd, pl_sd);
return true;
}
@@ -6321,19 +6308,19 @@ ACMD(trade) {
ACMD(setbattleflag)
{
char flag[128], value[128];
-
+
if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
clif->message(fd, msg_txt(1231)); // Usage: @setbattleflag <flag> <value>
return false;
}
-
+
if (battle->config_set_value(flag, value) == 0) {
clif->message(fd, msg_txt(1232)); // Unknown battle_config flag.
return false;
}
-
+
clif->message(fd, msg_txt(1233)); // Set battle_config as requested.
-
+
return true;
}
@@ -6342,27 +6329,27 @@ ACMD(setbattleflag)
*------------------------------------------*/
ACMD(unmute) {
struct map_session_data *pl_sd = NULL;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1234)); // Please enter a player name (usage: @unmute <char name>).
return false;
}
-
+
if ( (pl_sd = map->nick2sd((char *)message)) == NULL )
{
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
if(!pl_sd->sc.data[SC_NOCHAT]) {
clif->message(sd->fd,msg_txt(1235)); // Player is not muted.
return false;
}
-
+
pl_sd->status.manner = 0;
status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
clif->message(sd->fd,msg_txt(1236)); // Player unmuted.
-
+
return true;
}
@@ -6373,7 +6360,7 @@ ACMD(uptime)
{
unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
minute = 60, days = 0, hours = 0, minutes = 0;
-
+
seconds = timer->get_uptime();
days = seconds/day;
seconds -= (seconds/day>0)?(seconds/day)*day:0;
@@ -6381,10 +6368,10 @@ ACMD(uptime)
seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
minutes = seconds/minute;
seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
-
+
snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
clif->message(fd, atcmd_output);
-
+
return true;
}
@@ -6410,26 +6397,26 @@ ACMD(changesex)
ACMD(mute) {
struct map_session_data *pl_sd = NULL;
int manner;
-
+
if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1237)); // Usage: @mute <time> <char name>
return false;
}
-
+
if ( (pl_sd = map->nick2sd(atcmd_player_name)) == NULL ) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
{
clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
return false;
}
-
+
clif->manner_message(sd, 0);
clif->manner_message(pl_sd, 5);
-
+
if( pl_sd->status.manner < manner ) {
pl_sd->status.manner -= manner;
sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
@@ -6437,9 +6424,9 @@ ACMD(mute) {
pl_sd->status.manner = 0;
status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
}
-
+
clif->GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
-
+
return true;
}
@@ -6456,7 +6443,7 @@ ACMD(refreshall)
{
struct map_session_data* iter_sd;
struct s_mapiterator* iter;
-
+
iter = mapit_getallusers();
for (iter_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); iter_sd = (TBL_PC*)mapit->next(iter))
clif->refresh(iter_sd);
@@ -6471,7 +6458,7 @@ ACMD(refreshall)
ACMD(identify)
{
int i,num;
-
+
for(i=num=0;i<MAX_INVENTORY;i++){
if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
num++;
@@ -6493,7 +6480,7 @@ ACMD(misceffect) {
if (sscanf(message, "%d", &effect) < 1)
return false;
clif->misceffect(&sd->bl,effect);
-
+
return true;
}
@@ -6520,103 +6507,109 @@ ACMD(mobinfo)
struct mob_db *monster, *mob_array[MAX_SEARCH];
int count;
int i, j, k;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(atcmd_output2, '\0', sizeof(atcmd_output2));
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
return false;
}
-
+
// If monster identifier/name argument is a name
if ((i = mob->db_checkid(atoi(message)))) {
mob_array[0] = mob->db(i);
count = 1;
} else
count = mob->db_searchname_array(mob_array, MAX_SEARCH, message, 0);
-
+
if (!count) {
clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
return false;
}
-
+
if (count > MAX_SEARCH) {
sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
clif->message(fd, atcmd_output);
count = MAX_SEARCH;
}
-
+
for (k = 0; k < count; k++) {
unsigned int job_exp, base_exp;
-
+
monster = mob_array[k];
-
+
job_exp = monster->job_exp;
base_exp = monster->base_exp;
-
+
#ifdef RENEWAL_EXP
if( battle_config.atcommand_mobinfo_type ) {
base_exp = base_exp * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 1) / 100;
job_exp = job_exp * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 1) / 100;
}
#endif
-
+
// stats
if (monster->mexp)
sprintf(atcmd_output, msg_txt(1240), monster->name, monster->jname, monster->sprite, monster->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
else
sprintf(atcmd_output, msg_txt(1241), monster->name, monster->jname, monster->sprite, monster->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
clif->message(fd, atcmd_output);
-
+
sprintf(atcmd_output, msg_txt(1242), monster->lv, monster->status.max_hp, base_exp, job_exp, MOB_HIT(monster), MOB_FLEE(monster)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d
clif->message(fd, atcmd_output);
-
+
sprintf(atcmd_output, msg_txt(1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
monster->status.def, monster->status.mdef, monster->status.str, monster->status.agi,
monster->status.vit, monster->status.int_, monster->status.dex, monster->status.luk);
clif->message(fd, atcmd_output);
+
+#ifdef RENEWAL
+ sprintf(atcmd_output, msg_txt(1291), // ATK : %d~%d MATK : %d~%d Range : %d~%d~%d Size : %s Race : %s Element : %s(Lv : %d)
+ MOB_ATK1(monster), MOB_ATK2(monster), MOB_MATK1(monster), MOB_MATK2(monster), monster->status.rhw.range,
+#else
sprintf(atcmd_output, msg_txt(1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
monster->status.rhw.atk, monster->status.rhw.atk2, monster->status.rhw.range,
+#endif
monster->range2 , monster->range3, msize[monster->status.size],
mrace[monster->status.race], melement[monster->status.def_ele], monster->status.ele_lv);
clif->message(fd, atcmd_output);
-
+
// drops
clif->message(fd, msg_txt(1245)); // Drops:
strcpy(atcmd_output, " ");
j = 0;
for (i = 0; i < MAX_MOB_DROP; i++) {
int droprate;
-
+
if (monster->dropitem[i].nameid <= 0 || monster->dropitem[i].p < 1 || (item_data = itemdb->exists(monster->dropitem[i].nameid)) == NULL)
continue;
-
+
droprate = monster->dropitem[i].p;
#ifdef RENEWAL_DROP
if( battle_config.atcommand_mobinfo_type ) {
droprate = droprate * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 2) / 100;
-
+
if (droprate <= 0 && !battle_config.drop_rate0item)
droprate = 1;
}
#endif
-
+
if (item_data->slot)
sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
else
sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
-
+
strcat(atcmd_output, atcmd_output2);
-
+
if (++j % 3 == 0) {
clif->message(fd, atcmd_output);
strcpy(atcmd_output, " ");
}
}
-
+
if (j == 0)
clif->message(fd, msg_txt(1246)); // This monster has no drops.
else if (j % 3 != 0)
@@ -6625,7 +6618,7 @@ ACMD(mobinfo)
if (monster->mexp) {
sprintf(atcmd_output, msg_txt(1247), monster->mexp); // MVP Bonus EXP:%u
clif->message(fd, atcmd_output);
-
+
strcpy(atcmd_output, msg_txt(1248)); // MVP Items:
j = 0;
for (i = 0; i < MAX_MVP_DROP; i++) {
@@ -6659,7 +6652,7 @@ ACMD(showmobs)
int mob_id;
int number = 0;
struct s_mapiterator* it;
-
+
if( sscanf(message, "%99[^\n]", mob_name) < 0 ) {
clif->message(fd, msg_txt(546)); // Please enter a mob name/id (usage: @showmobs <mob name/id>)
return false;
@@ -6679,27 +6672,28 @@ ACMD(showmobs)
clif->message(fd, atcmd_output);
return false;
}
-
- if(mob->db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
+
+ if (mob->db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)) {
+ // If player group does not have access to boss mobs.
clif->message(fd, msg_txt(1251)); // Can't show boss mobs!
return false;
}
-
+
if(mob_id == atoi(mob_name) && mob->db(mob_id)->jname)
strcpy(mob_name,mob->db(mob_id)->jname); // --ja--
//strcpy(mob_name,mob_db(mob_id)->name); // --en--
-
+
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1252), // Mob Search... %s %s
mob_name, mapindex_id2name(sd->mapindex));
clif->message(fd, atcmd_output);
-
+
it = mapit_geteachmob();
for(;;)
{
TBL_MOB* md = (TBL_MOB*)mapit->next(it);
if( md == NULL )
break;// no more mobs
-
+
if( md->bl.m != sd->bl.m )
continue;
if( mob_id != -1 && md->class_ != mob_id )
@@ -6708,12 +6702,12 @@ ACMD(showmobs)
continue; // hide slaves and player summoned mobs
if( md->spawn_timer != INVALID_TIMER )
continue; // hide mobs waiting for respawn
-
+
++number;
clif->viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
}
mapit->free(it);
-
+
return true;
}
@@ -6724,19 +6718,19 @@ ACMD(homlevel) {
TBL_HOM * hd;
int level = 0;
enum homun_type htype;
-
+
if( !message || !*message || ( level = atoi(message) ) < 1 ) {
clif->message(fd, msg_txt(1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
return false;
}
-
+
if( !homun_alive(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
return false;
}
-
+
hd = sd->hd;
-
+
if( (htype = homun->class2type(hd->homunculus.class_)) == HT_INVALID ) {
ShowError("atcommand_homlevel: invalid homun class %d (player %s)\n", hd->homunculus.class_,sd->status.name);
return false;
@@ -6762,12 +6756,11 @@ ACMD(homlevel) {
ShowError("atcommand_homlevel: unknown htype '%d'\n",htype);
return false;
}
-
-
+
do {
hd->homunculus.exp += hd->exp_next;
} while( hd->homunculus.level < level && homun->levelup(hd) );
-
+
status_calc_homunculus(hd,SCO_NONE);
status_percent_heal(&hd->bl, 100, 100);
clif->specialeffect(&hd->bl,568,AREA);
@@ -6783,7 +6776,7 @@ ACMD(homevolution)
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
return false;
}
-
+
if ( !homun->evolve(sd->hd) ) {
clif->message(fd, msg_txt(1255)); // Your homunculus doesn't evolve.
return false;
@@ -6795,21 +6788,21 @@ ACMD(homevolution)
ACMD(hommutate) {
int homun_id;
enum homun_type m_class, m_id;
-
+
if( !homun_alive(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
return false;
}
-
+
if( !message || !*message ) {
homun_id = 6048 + (rnd() % 4);
} else {
homun_id = atoi(message);
}
-
+
m_class = homun->class2type(sd->hd->homunculus.class_);
- m_id = homun->class2type(homun_id);
-
+ m_id = homun->class2type(homun_id);
+
if( m_class != HT_INVALID && m_id != HT_INVALID && m_class == HT_EVO && m_id == HT_S && sd->hd->homunculus.level >= 99 ) {
homun->mutate(sd->hd, homun_id);
} else {
@@ -6823,14 +6816,14 @@ ACMD(hommutate) {
*------------------------------------------*/
ACMD(makehomun) {
int homunid;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
return false;
}
-
+
homunid = atoi(message);
-
+
if( homunid == -1 && sd->status.hom_id && !(sd->hd && homun_alive(sd->hd)) ) {
if( !sd->hd )
homun->call(sd);
@@ -6840,18 +6833,18 @@ ACMD(makehomun) {
homun->call(sd);
return true;
}
-
+
if ( sd->status.hom_id ) {
clif->message(fd, msg_txt(450));
return false;
}
-
+
if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
{
clif->message(fd, msg_txt(1257)); // Invalid Homunculus ID.
return false;
}
-
+
homun->creation_request(sd,homunid);
return true;
}
@@ -6862,20 +6855,20 @@ ACMD(makehomun) {
ACMD(homfriendly)
{
int friendly = 0;
-
+
if ( !homun_alive(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
return false;
}
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
return false;
}
-
+
friendly = atoi(message);
friendly = cap_value(friendly, 0, 1000);
-
+
sd->hd->homunculus.intimacy = friendly * 100 ;
clif->send_homdata(sd,SP_INTIMATE,friendly);
return true;
@@ -6887,20 +6880,20 @@ ACMD(homfriendly)
ACMD(homhungry)
{
int hungry = 0;
-
+
if ( !homun_alive(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
return false;
}
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
return false;
}
-
+
hungry = atoi(message);
hungry = cap_value(hungry, 0, 100);
-
+
sd->hd->homunculus.hunger = hungry;
clif->send_homdata(sd,SP_HUNGRY,hungry);
return true;
@@ -6912,31 +6905,31 @@ ACMD(homhungry)
ACMD(homtalk)
{
char mes[100],temp[100];
-
+
if ( battle_config.min_chat_delay ) {
if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 )
return true;
sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay;
}
-
+
if (sd->sc.count && //no "chatting" while muted.
(sd->sc.data[SC_BERSERK] || (sd->sc.data[SC_DEEP_SLEEP] && sd->sc.data[SC_DEEP_SLEEP]->val2) ||
(sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
return false;
-
+
if ( !homun_alive(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
return false;
}
-
+
if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
clif->message(fd, msg_txt(1260)); // Please enter a message (usage: @homtalk <message>).
return false;
}
-
+
snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
clif->disp_overhead(&sd->hd->bl, temp);
-
+
return true;
}
@@ -6946,34 +6939,34 @@ ACMD(homtalk)
ACMD(hominfo) {
struct homun_data *hd;
struct status_data *st;
-
+
if ( !homun_alive(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
return false;
}
-
+
hd = sd->hd;
st = status->get_status_data(&hd->bl);
clif->message(fd, msg_txt(1261)); // Homunculus stats:
-
+
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1262), // HP: %d/%d - SP: %d/%d
st->hp, st->max_hp, st->sp, st->max_sp);
clif->message(fd, atcmd_output);
-
+
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1263), // ATK: %d - MATK: %d~%d
st->rhw.atk2 +st->batk, st->matk_min, st->matk_max);
clif->message(fd, atcmd_output);
-
+
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1264), // Hungry: %d - Intimacy: %u
hd->homunculus.hunger, hd->homunculus.intimacy/100);
clif->message(fd, atcmd_output);
-
+
snprintf(atcmd_output, sizeof(atcmd_output) ,
msg_txt(1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
st->str, st->agi, st->vit,
st->int_, st->dex, st->luk);
clif->message(fd, atcmd_output);
-
+
return true;
}
@@ -6983,75 +6976,75 @@ ACMD(homstats)
struct s_homunculus_db *db;
struct s_homunculus *hom;
int lv, min, max, evo;
-
+
if ( !homun_alive(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
return false;
}
-
+
hd = sd->hd;
-
+
hom = &hd->homunculus;
db = hd->homunculusDB;
lv = hom->level;
-
+
snprintf(atcmd_output, sizeof(atcmd_output) ,
msg_txt(1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
clif->message(fd, atcmd_output);
lv--; //Since the first increase is at level 2.
-
+
evo = (hom->class_ == db->evo_class);
min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1269), hom->str/10, min, max); // Str: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1272), hom->int_/10, min, max); // Int: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
return true;
}
-ACMD(homshuffle) {
-
+ACMD(homshuffle)
+{
if(!sd->hd)
return false; // nothing to do
-
+
if(!homun->shuffle(sd->hd))
return false;
-
+
clif->message(sd->fd, msg_txt(1275)); // Homunculus stats altered.
atcommand_homstats(fd, sd, command, message, info); //Print out the new stats
return true;
@@ -7065,19 +7058,19 @@ ACMD(iteminfo)
{
struct item_data *item_data, *item_array[MAX_SEARCH];
int i, count = 1;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
return false;
}
if ((item_array[0] = itemdb->exists(atoi(message))) == NULL)
count = itemdb->search_name_array(item_array, MAX_SEARCH, message, 0);
-
+
if (!count) {
- clif->message(fd, msg_txt(19)); // Invalid item ID or name.
+ clif->message(fd, msg_txt(19)); // Invalid item ID or name.
return false;
}
-
+
if (count > MAX_SEARCH) {
sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
clif->message(fd, atcmd_output);
@@ -7091,10 +7084,10 @@ ACMD(iteminfo)
(item_data->script==NULL)? msg_txt(1278) : msg_txt(1279) // None / With script
);
clif->message(fd, atcmd_output);
-
+
sprintf(atcmd_output, msg_txt(1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
clif->message(fd, atcmd_output);
-
+
if (item_data->maxchance == -1)
strcpy(atcmd_output, msg_txt(1281)); // - Available in the shops only.
else if ( !battle_config.atcommand_mobinfo_type ) {
@@ -7104,7 +7097,7 @@ ACMD(iteminfo)
strcpy(atcmd_output, msg_txt(1283)); // - Monsters don't drop this item.
}
clif->message(fd, atcmd_output);
-
+
}
return true;
}
@@ -7116,19 +7109,19 @@ ACMD(whodrops)
{
struct item_data *item_data, *item_array[MAX_SEARCH];
int i,j, count = 1;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
return false;
}
if ((item_array[0] = itemdb->exists(atoi(message))) == NULL)
count = itemdb->search_name_array(item_array, MAX_SEARCH, message, 0);
-
+
if (!count) {
- clif->message(fd, msg_txt(19)); // Invalid item ID or name.
+ clif->message(fd, msg_txt(19)); // Invalid item ID or name.
return false;
}
-
+
if (count > MAX_SEARCH) {
sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
clif->message(fd, atcmd_output);
@@ -7138,14 +7131,14 @@ ACMD(whodrops)
item_data = item_array[i];
sprintf(atcmd_output, msg_txt(1285), item_data->jname,item_data->slot); // Item: '%s'[%d]
clif->message(fd, atcmd_output);
-
+
if (item_data->mob[0].chance == 0) {
strcpy(atcmd_output, msg_txt(1286)); // - Item is not dropped by mobs.
clif->message(fd, atcmd_output);
} else {
sprintf(atcmd_output, msg_txt(1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
clif->message(fd, atcmd_output);
-
+
for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
{
sprintf(atcmd_output, "- %s (%02.02f%%)", mob->db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
@@ -7161,12 +7154,12 @@ ACMD(whereis)
struct mob_db *monster, *mob_array[MAX_SEARCH];
int count;
int i, j, k;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
return false;
}
-
+
// If monster identifier/name argument is a name
if ((i = mob->db_checkid(atoi(message))))
{
@@ -7174,12 +7167,12 @@ ACMD(whereis)
count = 1;
} else
count = mob->db_searchname_array(mob_array, MAX_SEARCH, message, 0);
-
+
if (!count) {
clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
return false;
}
-
+
if (count > MAX_SEARCH) {
sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
clif->message(fd, atcmd_output);
@@ -7189,7 +7182,7 @@ ACMD(whereis)
monster = mob_array[k];
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1289), monster->jname); // %s spawns in:
clif->message(fd, atcmd_output);
-
+
for (i = 0; i < ARRAYLENGTH(monster->spawn) && monster->spawn[i].qty; i++) {
j = map->mapindex2mapid(monster->spawn[i].mapindex);
if (j < 0) continue;
@@ -7199,7 +7192,7 @@ ACMD(whereis)
if (i == 0)
clif->message(fd, msg_txt(1290)); // This monster does not spawn normally.
}
-
+
return true;
}
@@ -7217,15 +7210,15 @@ ACMD(version) {
*------------------------------------------*/
int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
{ // As it is being used [ACMD(mutearea)] there's no need to be a bool, but if there's need to reuse it, it's better to be this way
-
+
int time, id;
struct map_session_data *pl_sd = (struct map_session_data *)bl;
if (pl_sd == NULL)
return 0;
-
+
id = va_arg(ap, int);
time = va_arg(ap, int);
-
+
if (id != bl->id && !pc_get_group_level(pl_sd)) {
pl_sd->status.manner -= time;
if (pl_sd->status.manner < 0)
@@ -7238,18 +7231,18 @@ int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
ACMD(mutearea) {
int time;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
return false;
}
-
+
time = atoi(message);
-
+
map->foreachinarea(atcommand->mutearea_sub,sd->bl.m,
sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
-
+
return true;
}
@@ -7257,9 +7250,9 @@ ACMD(mutearea) {
ACMD(rates)
{
char buf[CHAT_SIZE_MAX];
-
+
memset(buf, '\0', sizeof(buf));
-
+
snprintf(buf, CHAT_SIZE_MAX, msg_txt(1298), // Experience rates: Base %.2fx / Job %.2fx
battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
clif->message(fd, buf);
@@ -7272,7 +7265,7 @@ ACMD(rates)
snprintf(buf, CHAT_SIZE_MAX, msg_txt(1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
clif->message(fd, buf);
-
+
return true;
}
@@ -7283,25 +7276,24 @@ ACMD(rates)
ACMD(me)
{
char tempmes[CHAT_SIZE_MAX];
-
+
memset(tempmes, '\0', sizeof(tempmes));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (sd->sc.count && //no "chatting" while muted.
(sd->sc.data[SC_BERSERK] || (sd->sc.data[SC_DEEP_SLEEP] && sd->sc.data[SC_DEEP_SLEEP]->val2) ||
(sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
return false;
-
+
if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
clif->message(fd, msg_txt(1302)); // Please enter a message (usage: @me <message>).
return false;
}
-
- sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
+
+ sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
clif->disp_overhead(&sd->bl, atcmd_output);
-
+
return true;
-
}
/*==========================================
@@ -7311,20 +7303,20 @@ ACMD(me)
ACMD(size)
{
int size = 0;
-
- size = cap_value(atoi(message),SZ_MEDIUM,SZ_BIG);
-
+
+ size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
+
if(sd->state.size) {
- sd->state.size = SZ_MEDIUM;
+ sd->state.size = SZ_SMALL;
pc->setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
}
-
+
sd->state.size = size;
- if( size == SZ_SMALL )
+ if( size == SZ_MEDIUM )
clif->specialeffect(&sd->bl,420,AREA);
else if( size == SZ_BIG )
clif->specialeffect(&sd->bl,422,AREA);
-
+
clif->message(fd, msg_txt(1303)); // Size change applied.
return true;
}
@@ -7334,27 +7326,27 @@ ACMD(sizeall)
int size;
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
-
+
size = atoi(message);
size = cap_value(size,0,2);
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) {
if( pl_sd->state.size != size ) {
if( pl_sd->state.size ) {
- pl_sd->state.size = SZ_MEDIUM;
+ pl_sd->state.size = SZ_SMALL;
pc->setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
}
-
+
pl_sd->state.size = size;
- if( size == SZ_SMALL )
+ if( size == SZ_MEDIUM )
clif->specialeffect(&pl_sd->bl,420,AREA);
else if( size == SZ_BIG )
clif->specialeffect(&pl_sd->bl,422,AREA);
}
}
mapit->free(iter);
-
+
clif->message(fd, msg_txt(1303)); // Size change applied.
return true;
}
@@ -7365,36 +7357,36 @@ ACMD(sizeguild)
char guild_name[NAME_LENGTH];
struct map_session_data *pl_sd;
struct guild *g;
-
+
memset(guild_name, '\0', sizeof(guild_name));
-
+
if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild_name) < 2 ) {
clif->message(fd, msg_txt(1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
return false;
}
-
+
if( (g = guild->searchname(guild_name)) == NULL && (g = guild->search(atoi(guild_name))) == NULL ) {
clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
return false;
}
-
- size = cap_value(size,SZ_MEDIUM,SZ_BIG);
-
+
+ size = cap_value(size,SZ_SMALL,SZ_BIG);
+
for( i = 0; i < g->max_member; i++ ) {
if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
if( pl_sd->state.size ) {
- pl_sd->state.size = SZ_MEDIUM;
+ pl_sd->state.size = SZ_SMALL;
pc->setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
}
-
+
pl_sd->state.size = size;
- if( size == SZ_SMALL )
+ if( size == SZ_MEDIUM )
clif->specialeffect(&pl_sd->bl,420,AREA);
else if( size == SZ_BIG )
clif->specialeffect(&pl_sd->bl,422,AREA);
}
}
-
+
clif->message(fd, msg_txt(1303)); // Size change applied.
return true;
}
@@ -7403,8 +7395,8 @@ ACMD(sizeguild)
* @monsterignore
* => Makes monsters ignore you. [Valaris]
*------------------------------------------*/
-ACMD(monsterignore) {
-
+ACMD(monsterignore)
+{
if (!sd->state.monster_ignore) {
sd->state.monster_ignore = 1;
clif->message(sd->fd, msg_txt(1305)); // You are now immune to attacks.
@@ -7412,15 +7404,15 @@ ACMD(monsterignore) {
sd->state.monster_ignore = 0;
clif->message(sd->fd, msg_txt(1306)); // Returned to normal state.
}
-
+
return true;
}
/*==========================================
* @fakename
* => Gives your character a fake name. [Valaris]
*------------------------------------------*/
-ACMD(fakename){
-
+ACMD(fakename)
+{
if( !message || !*message )
{
if( sd->fakename[0] )
@@ -7432,23 +7424,23 @@ ACMD(fakename){
clif->message(sd->fd, msg_txt(1307)); // Returned to real name.
return true;
}
-
+
clif->message(sd->fd, msg_txt(1308)); // You must enter a name.
return false;
}
-
+
if( strlen(message) < 2 )
{
clif->message(sd->fd, msg_txt(1309)); // Fake name must be at least two characters.
return false;
}
-
+
safestrncpy(sd->fakename, message, sizeof(sd->fakename));
clif->charnameack(0, &sd->bl);
if( sd->disguise ) // Another packet should be sent so the client updates the name for sd
clif->charnameack(sd->fd, &sd->bl);
clif->message(sd->fd, msg_txt(1310)); // Fake name enabled.
-
+
return true;
}
@@ -7470,7 +7462,7 @@ ACMD(mapflag) {
short flag=0,i;
memset(flag_name, '\0', sizeof(flag_name));
-
+
if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) {
clif->message(sd->fd,msg_txt(1311)); // Enabled Mapflags in this map:
clif->message(sd->fd,"----------------------------------");
@@ -7493,7 +7485,7 @@ ACMD(mapflag) {
return true;
}
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));
@@ -7510,7 +7502,7 @@ ACMD(mapflag) {
else if ( !flag && map->list[sd->bl.m].flag.battleground )
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);
@@ -7524,7 +7516,7 @@ ACMD(mapflag) {
SETFLAG(nodrop); SETFLAG(novending); SETFLAG(loadevent);
SETFLAG(nochat); SETFLAG(partylock); SETFLAG(guildlock); SETFLAG(src4instance);
SETFLAG(notomb); SETFLAG(nocashshop);
-
+
clif->message(sd->fd,msg_txt(1314)); // Invalid flag name or flag.
clif->message(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
clif->message(sd->fd,msg_txt(1315)); // Available Flags:
@@ -7536,10 +7528,9 @@ ACMD(mapflag) {
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");
-
#undef CHECKFLAG
#undef SETFLAG
-
+
return true;
}
@@ -7553,7 +7544,7 @@ ACMD(showexp)
clif->message(fd, msg_txt(1316)); // Gained exp will not be shown.
return true;
}
-
+
sd->state.showexp = 1;
clif->message(fd, msg_txt(1317)); // Gained exp is now shown.
return true;
@@ -7566,7 +7557,7 @@ ACMD(showzeny)
clif->message(fd, msg_txt(1318)); // Gained zeny will not be shown.
return true;
}
-
+
sd->state.showzeny = 1;
clif->message(fd, msg_txt(1319)); // Gained zeny is now shown.
return true;
@@ -7579,7 +7570,7 @@ ACMD(showdelay)
clif->message(fd, msg_txt(1320)); // Skill delay failures will not be shown.
return true;
}
-
+
sd->state.showdelay = 1;
clif->message(fd, msg_txt(1321)); // Skill delay failures are now shown.
return true;
@@ -7597,34 +7588,33 @@ ACMD(showdelay)
ACMD(invite) {
unsigned int did = sd->duel_group;
struct map_session_data *target_sd = map->nick2sd((char *)message);
-
+
if(did == 0)
{
// "Duel: @invite without @duel."
clif->message(fd, msg_txt(350));
return false;
}
-
+
if(duel->list[did].max_players_limit > 0 &&
duel->list[did].members_count >= duel->list[did].max_players_limit) {
-
// "Duel: Limit of players is reached."
clif->message(fd, msg_txt(351));
return false;
}
-
+
if(target_sd == NULL) {
// "Duel: Player not found."
clif->message(fd, msg_txt(352));
return false;
}
-
+
if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
// "Duel: Player already in duel."
clif->message(fd, msg_txt(353));
return false;
}
-
+
if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
{
// "Duel: You can't invite %s because he/she isn't in the same map."
@@ -7632,7 +7622,7 @@ ACMD(invite) {
clif->message(fd, atcmd_output);
return false;
}
-
+
duel->invite(did, sd, target_sd);
// "Duel: Invitation has been sent."
clif->message(fd, msg_txt(354));
@@ -7641,18 +7631,18 @@ ACMD(invite) {
ACMD(duel) {
unsigned int maxpl = 0;
-
+
if(sd->duel_group > 0) {
duel->showinfo(sd->duel_group, sd);
return true;
}
-
+
if(sd->duel_invite > 0) {
// "Duel: @duel without @reject."
clif->message(fd, msg_txt(355));
return false;
}
-
+
if(!duel->checktime(sd)) {
char output[CHAT_SIZE_MAX];
// "Duel: You can take part in duel only one time per %d minutes."
@@ -7660,7 +7650,7 @@ ACMD(duel) {
clif->message(fd, output);
return false;
}
-
+
if( message[0] ) {
if(sscanf(message, "%d", &maxpl) >= 1) {
if(maxpl < 2 || maxpl > 65535) {
@@ -7674,7 +7664,7 @@ ACMD(duel) {
if(target_sd != NULL) {
unsigned int newduel;
if((newduel = duel->create(sd, 2)) != -1) {
- if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
+ if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
clif->message(fd, msg_txt(353)); // "Duel: Player already in duel."
return false;
}
@@ -7689,7 +7679,7 @@ ACMD(duel) {
}
} else
duel->create(sd, 0);
-
+
return true;
}
@@ -7700,7 +7690,6 @@ ACMD(leave) {
clif->message(fd, msg_txt(358));
return false;
}
-
duel->leave(sd->duel_group, sd);
clif->message(fd, msg_txt(359)); // "Duel: You left the duel."
return true;
@@ -7714,20 +7703,20 @@ ACMD(accept) {
clif->message(fd, output);
return false;
}
-
+
if(sd->duel_invite <= 0) {
// "Duel: @accept without invitation."
clif->message(fd, msg_txt(360));
return false;
}
-
+
if( duel->list[sd->duel_invite].max_players_limit > 0
&& duel->list[sd->duel_invite].members_count >= duel->list[sd->duel_invite].max_players_limit ) {
// "Duel: Limit of players is reached."
clif->message(fd, msg_txt(351));
return false;
}
-
+
duel->accept(sd->duel_invite, sd);
// "Duel: Invitation has been accepted."
clif->message(fd, msg_txt(361));
@@ -7740,7 +7729,7 @@ ACMD(reject) {
clif->message(fd, msg_txt(362));
return false;
}
-
+
duel->reject(sd->duel_invite, sd);
// "Duel: Invitation has been rejected."
clif->message(fd, msg_txt(363));
@@ -7755,12 +7744,12 @@ ACMD(cash)
char output[128];
int value;
int ret=0;
-
+
if( !message || !*message || (value = atoi(message)) == 0 ) {
clif->message(fd, msg_txt(1322)); // Please enter an amount.
return false;
}
-
+
if( !strcmpi(info->command,"cash") ) {
if( value > 0 ) {
if( (ret=pc->getcash(sd, value, 0)) >= 0){
@@ -7796,7 +7785,7 @@ ACMD(cash)
clif->message(fd, msg_txt(41)); // Unable to decrease the number/value.
}
}
-
+
return true;
}
@@ -7804,22 +7793,22 @@ ACMD(cash)
ACMD(clone) {
int x=0,y=0,flag=0,master=0,i=0;
struct map_session_data *pl_sd=NULL;
-
+
if (!message || !*message) {
clif->message(sd->fd,msg_txt(1323)); // You must enter a player name or ID.
return false;
}
-
+
if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
- clif->message(fd, msg_txt(3)); // Character not found.
+ clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
-
+
if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
- clif->message(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
+ clif->message(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
return false;
}
-
+
if (strcmpi(info->command, "clone") == 0)
flag = 1;
else if (strcmpi(info->command, "slaveclone") == 0) {
@@ -7832,26 +7821,26 @@ ACMD(clone) {
master = sd->bl.id;
if (battle_config.atc_slave_clone_limit
&& mob->countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
- clif->message(fd, msg_txt(127)); // You've reached your slave clones limit.
+ clif->message(fd, msg_txt(127)); // You've reached your slave clones limit.
return false;
}
}
-
+
do {
x = sd->bl.x + (rnd() % 10 - 5);
y = sd->bl.y + (rnd() % 10 - 5);
} while (map->getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
-
+
if (i >= 10) {
x = sd->bl.x;
y = sd->bl.y;
}
-
+
if((x = mob->clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
- clif->message(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
+ clif->message(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
return true;
}
- clif->message(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
+ clif->message(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
return false;
}
@@ -7868,7 +7857,7 @@ ACMD(noask)
clif->message(fd, msg_txt(390)); // Autorejecting is activated.
sd->state.noask = 1;
}
-
+
return true;
}
@@ -7879,14 +7868,14 @@ ACMD(noask)
ACMD(request)
{
if (!message || !*message) {
- clif->message(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
+ clif->message(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
return false;
}
-
- sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
+
+ sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
intif->wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
- clif->message(sd->fd,msg_txt(279)); // @request sent.
+ clif->message(sd->fd,msg_txt(279)); // @request sent.
return true;
}
@@ -7897,7 +7886,7 @@ ACMD(feelreset)
{
pc->resetfeel(sd);
clif->message(fd, msg_txt(1324)); // Reset 'Feeling' maps.
-
+
return true;
}
@@ -7905,14 +7894,14 @@ ACMD(feelreset)
* AUCTION SYSTEM
*------------------------------------------*/
ACMD(auction) {
-
+
if( !battle_config.feature_auction ) {
clif->colormes(sd->fd,COLOR_RED,msg_txt(1484));
return false;
}
-
+
clif->auction_openwindow(sd);
-
+
return true;
}
@@ -7950,8 +7939,8 @@ ACMD(ksprotection)
/*==========================================
* Map Kill Steal Protection Setting
*------------------------------------------*/
-ACMD(allowks) {
-
+ACMD(allowks)
+{
if( map->list[sd->bl.m].flag.allowks ) {
map->list[sd->bl.m].flag.allowks = 0;
clif->message(fd, msg_txt(1330)); // [ Map K.S Protection Active ]
@@ -7962,16 +7951,16 @@ ACMD(allowks) {
return true;
}
-ACMD(resetstat) {
-
+ACMD(resetstat)
+{
pc->resetstate(sd);
sprintf(atcmd_output, msg_txt(207), sd->status.name);
clif->message(fd, atcmd_output);
return true;
}
-ACMD(resetskill) {
-
+ACMD(resetskill)
+{
pc->resetskill(sd,1);
sprintf(atcmd_output, msg_txt(206), sd->status.name);
clif->message(fd, atcmd_output);
@@ -7990,7 +7979,7 @@ ACMD(itemlist)
const struct item* items;
int size;
StringBuf buf;
-
+
if( strcmpi(info->command, "storagelist") == 0 ) {
location = "storage";
items = sd->status.storage.items;
@@ -8005,34 +7994,34 @@ ACMD(itemlist)
size = MAX_INVENTORY;
} else
return false;
-
+
StrBuf->Init(&buf);
-
+
count = 0; // total slots occupied
counter = 0; // total items found
for( i = 0; i < size; ++i )
{
const struct item* it = &items[i];
struct item_data* itd;
-
+
if( it->nameid == 0 || (itd = itemdb->exists(it->nameid)) == NULL )
continue;
-
+
counter += it->amount;
count++;
-
+
if( count == 1 )
{
StrBuf->Printf(&buf, msg_txt(1332), location, sd->status.name); // ------ %s items list of '%s' ------
clif->message(fd, StrBuf->Value(&buf));
StrBuf->Clear(&buf);
}
-
+
if( it->refine )
StrBuf->Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
else
StrBuf->Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
-
+
if( it->equip ) {
char equipstr[CHAT_SIZE_MAX];
strcpy(equipstr, msg_txt(1333)); // | equipped:
@@ -8068,10 +8057,10 @@ ACMD(itemlist)
equipstr[strlen(equipstr) - 2] = '\0';
StrBuf->AppendStr(&buf, equipstr);
}
-
+
clif->message(fd, StrBuf->Value(&buf));
StrBuf->Clear(&buf);
-
+
if( it->card[0] == CARD0_PET ) {
// pet egg
if (it->card[3])
@@ -8108,22 +8097,21 @@ ACMD(itemlist)
if( counter2 > 0 )
StrBuf->AppendStr(&buf, ")");
}
-
+
if( StrBuf->Length(&buf) > 0 )
clif->message(fd, StrBuf->Value(&buf));
StrBuf->Clear(&buf);
}
-
+
if( count == 0 )
StrBuf->Printf(&buf, msg_txt(1353), location); // No item found in this player's %s.
else
StrBuf->Printf(&buf, msg_txt(1354), counter, count, location); // %d item(s) found in %d %s slots.
-
+
clif->message(fd, StrBuf->Value(&buf));
-
+
StrBuf->Destroy(&buf);
-
return true;
}
@@ -8154,10 +8142,10 @@ ACMD(stats)
{ "JobChangeLvl (3rd) - %d", 0 },
{ NULL, 0 }
};
-
+
memset(job_jobname, '\0', sizeof(job_jobname));
memset(output, '\0', sizeof(output));
-
+
//direct array initialization with variables is not standard C compliant.
output_table[0].value = sd->status.base_level;
output_table[1].format = job_jobname;
@@ -8176,17 +8164,16 @@ ACMD(stats)
output_table[13].value = sd->status.skill_point;
output_table[14].value = sd->change_level_2nd;
output_table[15].value = sd->change_level_3rd;
-
+
sprintf(job_jobname, "Job - %s %s", pc->job_name(sd->status.class_), "(level %d)");
sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
-
+
clif->message(fd, output);
-
+
for (i = 0; output_table[i].format != NULL; i++) {
sprintf(output, output_table[i].format, output_table[i].value);
clif->message(fd, output);
}
-
return true;
}
@@ -8194,13 +8181,13 @@ ACMD(delitem) {
char item_name[100];
int nameid, amount = 0, total, idx;
struct item_data* id;
-
+
if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
{
clif->message(fd, msg_txt(1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
return false;
}
-
+
if( ( id = itemdb->search_name(item_name) ) != NULL || ( id = itemdb->exists(atoi(item_name)) ) != NULL )
{
nameid = id->nameid;
@@ -8210,26 +8197,26 @@ ACMD(delitem) {
clif->message(fd, msg_txt(19)); // Invalid item ID or name.
return false;
}
-
+
total = amount;
-
+
// delete items
while (amount && (idx = pc->search_inventory(sd, nameid)) != INDEX_NOT_FOUND) {
int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
-
+
if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
{// delete pet
intif->delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
}
pc->delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
-
+
amount-= delamount;
}
-
+
// notify target
sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
clif->message(sd->fd, atcmd_output);
-
+
// notify source
if( amount == total )
{
@@ -8245,7 +8232,6 @@ ACMD(delitem) {
sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
clif->message(fd, atcmd_output);
}
-
return true;
}
@@ -8254,7 +8240,7 @@ ACMD(delitem) {
*------------------------------------------*/
ACMD(font) {
int font_id;
-
+
font_id = atoi(message);
if( font_id == 0 )
{
@@ -8280,7 +8266,7 @@ ACMD(font) {
}
else
clif->message(fd, msg_txt(1361)); // Already using this font.
-
+
return true;
}
@@ -8294,15 +8280,15 @@ void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommand
AtCommandInfo* cmd;
DBIterator *iter = db_iterator(atcommand->db);
int count = 0;
-
+
memset(line_buff,' ',CHATBOX_SIZE);
line_buff[CHATBOX_SIZE-1] = 0;
-
+
clif->message(fd, msg_txt(273)); // "Available commands:"
-
+
for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
size_t slen;
-
+
switch( type ) {
case COMMAND_CHARCOMMAND:
if( cmd->char_groups[pcg->get_idx(sd->group)] == 0 )
@@ -8315,10 +8301,9 @@ void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommand
default:
continue;
}
-
-
+
slen = strlen(cmd->command);
-
+
// flush the text buffer if this command won't fit into it
if ( slen + cur - line_buff >= CHATBOX_SIZE )
{
@@ -8327,18 +8312,18 @@ void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommand
memset(line_buff,' ',CHATBOX_SIZE);
line_buff[CHATBOX_SIZE-1] = 0;
}
-
+
memcpy(cur,cmd->command,slen);
cur += slen+(10-slen%10);
-
+
count++;
}
dbi_destroy(iter);
clif->message(fd,line_buff);
-
+
sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
clif->message(fd, atcmd_output);
-
+
return;
}
@@ -8360,15 +8345,15 @@ ACMD(charcommands)
return true;
}
/* for new mounts */
-ACMD(mount2) {
-
- if( sd->sc.option&(OPTION_WUGRIDER|OPTION_RIDING|OPTION_DRAGON|OPTION_MADOGEAR) ) {
+ACMD(cashmount)
+{
+ if (pc_hasmount(sd)) {
clif->message(fd, msg_txt(1476)); // You are already mounting something else
return false;
}
-
+
clif->message(sd->fd,msg_txt(1362)); // NOTICE: If you crash with mount your LUA is outdated.
- if( !(sd->sc.data[SC_ALL_RIDING]) ) {
+ if (!sd->sc.data[SC_ALL_RIDING]) {
clif->message(sd->fd,msg_txt(1363)); // You have mounted.
sc_start(NULL,&sd->bl,SC_ALL_RIDING,100,0,-1);
} else {
@@ -8380,18 +8365,17 @@ ACMD(mount2) {
ACMD(accinfo) {
char query[NAME_LENGTH];
-
+
if (!message || !*message || strlen(message) > NAME_LENGTH ) {
clif->message(fd, msg_txt(1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
clif->message(fd, msg_txt(1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
return false;
}
-
+
//remove const type
safestrncpy(query, message, NAME_LENGTH);
-
intif->request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query );
-
+
return true;
}
@@ -8402,7 +8386,7 @@ ACMD(set) {
int toset = 0;
bool is_str = false;
size_t len;
-
+
if( !message || !*message || (toset = sscanf(message, "%31s %128[^\n]s", reg, val)) < 1 ) {
clif->message(fd, msg_txt(1367)); // Usage: @set <variable name> <value>
clif->message(fd, msg_txt(1368)); // Usage: ex. "@set PoringCharVar 50"
@@ -8410,7 +8394,7 @@ ACMD(set) {
clif->message(fd, msg_txt(1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
return false;
}
-
+
/* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
if( reg[0] == '.' ) {
clif->message(fd, msg_txt(1371)); // NPC variables may not be used with @set.
@@ -8419,29 +8403,26 @@ ACMD(set) {
clif->message(fd, msg_txt(1372)); // Instance variables may not be used with @set.
return false;
}
-
+
is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false;
-
+
if( ( len = strlen(val) ) > 1 ) {
if( val[0] == '"' && val[len-1] == '"') {
val[len-1] = '\0'; //Strip quotes.
memmove(val, val+1, len-1);
}
}
-
+
if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
if( is_str )
script->set_var(sd, reg, (void*) val);
else
script->set_var(sd, reg, (void*)h64BPTRSIZE((atoi(val))));
-
}
-
+
CREATE(data, struct script_data,1);
-
-
+
if( is_str ) {// string variable
-
switch( reg[0] ) {
case '@':
data->u.str = pc->readregstr(sd, script->add_str(reg));
@@ -8459,7 +8440,6 @@ ACMD(set) {
data->u.str = pc_readglobalreg_str(sd, script->add_str(reg));
break;
}
-
if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
data->type = C_CONSTSTR;
data->u.str = "";
@@ -8467,9 +8447,7 @@ ACMD(set) {
data->type = C_STR;
data->u.str = aStrdup(data->u.str);
}
-
} else {// integer variable
-
data->type = C_INT;
switch( reg[0] ) {
case '@':
@@ -8488,10 +8466,8 @@ ACMD(set) {
data->u.num = pc_readglobalreg(sd, script->add_str(reg));
break;
}
-
}
-
-
+
switch( data->type ) {
case C_INT:
sprintf(atcmd_output,msg_txt(1373),reg,data->u.num); // %s value is now :%d
@@ -8506,11 +8482,9 @@ ACMD(set) {
sprintf(atcmd_output,msg_txt(1376),reg,data->type); // %s data type is not supported :%u
break;
}
-
clif->message(fd, atcmd_output);
-
+
aFree(data);
-
return true;
}
ACMD(reloadquestdb) {
@@ -8522,7 +8496,7 @@ ACMD(addperm) {
int perm_size = pcg->permission_count;
bool add = (strcmpi(info->command, "addperm") == 0) ? true : false;
int i;
-
+
if( !message || !*message ) {
sprintf(atcmd_output, msg_txt(1378),command); // Usage: %s <permission_name>
clif->message(fd, atcmd_output);
@@ -8533,9 +8507,8 @@ ACMD(addperm) {
}
return false;
}
-
+
ARR_FIND(0, perm_size, i, strcmpi(pcg->permissions[i].name, message) == 0);
-
if( i == perm_size ) {
sprintf(atcmd_output,msg_txt(1380),message); // '%s' is not a known permission.
clif->message(fd, atcmd_output);
@@ -8546,7 +8519,7 @@ ACMD(addperm) {
}
return false;
}
-
+
if( add && (sd->extra_temp_permissions&pcg->permissions[i].permission) ) {
sprintf(atcmd_output, msg_txt(1381),sd->status.name,pcg->permissions[i].name); // User '%s' already possesses the '%s' permission.
clif->message(fd, atcmd_output);
@@ -8562,28 +8535,26 @@ ACMD(addperm) {
clif->message(fd, atcmd_output);
}
}
-
return false;
}
-
+
if( add )
sd->extra_temp_permissions |= pcg->permissions[i].permission;
else
sd->extra_temp_permissions &=~ pcg->permissions[i].permission;
-
-
+
sprintf(atcmd_output, msg_txt(1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
clif->message(fd, atcmd_output);
-
+
return true;
}
-ACMD(unloadnpcfile) {
-
+ACMD(unloadnpcfile)
+{
if( !message || !*message ) {
clif->message(fd, msg_txt(1385)); // Usage: @unloadnpcfile <file name>
return false;
}
-
+
if( npc->unloadfile(message) )
clif->message(fd, msg_txt(1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
else {
@@ -8598,39 +8569,39 @@ ACMD(cart) {
sd->status.skill[idx].lv = (x)?1:0; \
sd->status.skill[idx].flag = (x)?1:0; \
} while(0)
-
+
int val = atoi(message);
bool need_skill = pc->checkskill(sd, MC_PUSHCART) ? false : true;
unsigned int index = skill->get_index(MC_PUSHCART);
-
+
if( !message || !*message || val < 0 || val > MAX_CARTS ) {
sprintf(atcmd_output, msg_txt(1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
clif->message(fd, atcmd_output);
return false;
}
-
+
if( val == 0 && !pc_iscarton(sd) ) {
clif->message(fd, msg_txt(1391)); // You do not possess a cart to be removed
return false;
}
-
+
if( need_skill ) {
MC_CART_MDFY(1,index);
}
-
+
if( pc->setcart(sd, val) ) {
if( need_skill ) {
MC_CART_MDFY(0,index);
}
return false;/* @cart failed */
}
-
+
if( need_skill ) {
MC_CART_MDFY(0,index);
}
-
+
clif->message(fd, msg_txt(1392)); // Cart Added
-
+
return true;
#undef MC_CART_MDFY
}
@@ -8638,20 +8609,20 @@ ACMD(cart) {
ACMD(join) {
struct hChSysCh *channel = NULL;
char name[HCHSYS_NAME_LENGTH], pass[HCHSYS_NAME_LENGTH];
-
+
if (!message || !*message || sscanf(message, "%19s %19s", name, pass) < 1) {
sprintf(atcmd_output, msg_txt(1399),command); // Unknown Channel (usage: %s <#channel_name>)
clif->message(fd, atcmd_output);
return false;
}
- if( hChSys.local && strcmpi(name + 1, hChSys.local_name) == 0 ) {
+ if (clif->hChSys->local && strcmpi(name + 1, clif->hChSys->local_name) == 0) {
if( !map->list[sd->bl.m].channel ) {
clif->chsys_mjoin(sd);
if( map->list[sd->bl.m].channel ) /* join might have refused, map has chatting capabilities disabled */
return true;
} else
channel = map->list[sd->bl.m].channel;
- } else if( hChSys.ally && sd->status.guild_id && strcmpi(name + 1, hChSys.ally_name) == 0 ) {
+ } else if (clif->hChSys->ally && sd->status.guild_id && strcmpi(name + 1, clif->hChSys->ally_name) == 0) {
struct guild *g = sd->guild;
if( !g ) return false;/* unlikely, but we wont let it crash anyway. */
channel = g->channel;
@@ -8660,14 +8631,13 @@ ACMD(join) {
clif->message(fd, atcmd_output);
return false;
}
-
+
if( !channel ) {
sprintf(atcmd_output, msg_txt(1400),name,command); // Unknown Channel '%s' (usage: %s <#channel_name>)
clif->message(fd, atcmd_output);
return false;
}
-
-
+
if( idb_exists(channel->users, sd->status.char_id) ) {
sprintf(atcmd_output, msg_txt(1436),name); // You're already in the '%s' channel
clif->message(fd, atcmd_output);
@@ -8682,14 +8652,14 @@ ACMD(join) {
return false;
}
}
-
+
if( channel->banned && idb_exists(channel->banned, sd->status.account_id) ) {
sprintf(atcmd_output, msg_txt(1438),name); // You cannot join the '%s' channel because you've been banned from it
clif->message(fd, atcmd_output);
return false;
}
-
- if( !( channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) {
+
+ if (!(channel->opt & hChSys_OPT_ANNOUNCE_JOIN)) {
sprintf(atcmd_output, msg_txt(1403),name); // You're now in the '%s' channel
clif->message(fd, atcmd_output);
}
@@ -8705,7 +8675,7 @@ ACMD(join) {
}
}
clif->chsys_join(channel,sd);
-
+
return true;
}
/* [Ind/Hercules] */
@@ -8757,7 +8727,6 @@ static inline void atcmd_channel_help(int fd, const char *command, bool can_crea
clif->message(fd, atcmd_output);
clif->message(fd, msg_txt(1463));// - adds or removes <option name> with <option value> to <channel name> channel
}
-
}
/* [Ind/Hercules] */
ACMD(channel) {
@@ -8765,13 +8734,13 @@ ACMD(channel) {
char subcmd[HCHSYS_NAME_LENGTH], sub1[HCHSYS_NAME_LENGTH], sub2[HCHSYS_NAME_LENGTH], sub3[HCHSYS_NAME_LENGTH];
unsigned char k = 0;
sub1[0] = sub2[0] = sub3[0] = '\0';
-
+
if (!message || !*message || sscanf(message, "%19s %19s %19s %19s", subcmd, sub1, sub2, sub3) < 1) {
- atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ));
+ atcmd_channel_help(fd,command, (clif->hChSys->allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)));
return true;
}
-
- if (strcmpi(subcmd,"create") == 0 && (hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN))) {
+
+ if (strcmpi(subcmd,"create") == 0 && (clif->hChSys->allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN))) {
// sub1 = channel name; sub2 = password; sub3 = unused
if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
@@ -8784,38 +8753,37 @@ ACMD(channel) {
clif->message(fd, msg_txt(1408)); // Channel password may not contain spaces
return false;
}
- if (strcmpi(sub1 + 1,hChSys.local_name) == 0 || strcmpi(sub1 + 1,hChSys.ally_name) == 0 || strdb_exists(clif->channel_db, sub1 + 1)) {
+ if (strcmpi(sub1 + 1, clif->hChSys->local_name) == 0 || strcmpi(sub1 + 1, clif->hChSys->ally_name) == 0 || strdb_exists(clif->channel_db, sub1 + 1)) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
-
+
CREATE( channel, struct hChSysCh, 1 );
-
clif->chsys_create(channel,sub1 + 1,sub2,0);
-
+
channel->owner = sd->status.char_id;
channel->type = hChSys_PRIVATE;
-
+
if( !( channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) {
sprintf(atcmd_output, msg_txt(1403),sub1); // You're now in the '%s' channel
clif->message(fd, atcmd_output);
}
-
+
clif->chsys_join(channel,sd);
} else if (strcmpi(subcmd,"list") == 0) {
// sub1 = list type; sub2 = unused; sub3 = unused
if (sub1[0] != '\0' && strcmpi(sub1,"colors") == 0) {
char mout[40];
- for (k = 0; k < hChSys.colors_count; k++) {
+ for (k = 0; k < clif->hChSys->colors_count; k++) {
unsigned short msg_len = 1;
- msg_len += sprintf(mout, "[ %s list colors ] : %s",command,hChSys.colors_name[k]);
-
+ msg_len += sprintf(mout, "[ %s list colors ] : %s", command, clif->hChSys->colors_name[k]);
+
WFIFOHEAD(fd,msg_len + 12);
WFIFOW(fd,0) = 0x2C1;
WFIFOW(fd,2) = msg_len + 12;
WFIFOL(fd,4) = 0;
- WFIFOL(fd,8) = hChSys.colors[k];
+ WFIFOL(fd,8) = clif->hChSys->colors[k];
safestrncpy((char*)WFIFOP(fd,12), mout, msg_len);
WFIFOSET(fd, msg_len + 12);
}
@@ -8823,14 +8791,14 @@ ACMD(channel) {
DBIterator *iter = db_iterator(clif->channel_db);
bool show_all = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ? true : false;
clif->message(fd, msg_txt(1410)); // -- Public Channels
- if (hChSys.local) {
- sprintf(atcmd_output, msg_txt(1409), hChSys.local_name, map->list[sd->bl.m].channel ? db_size(map->list[sd->bl.m].channel->users) : 0);// - #%s ( %d users )
+ if (clif->hChSys->local) {
+ sprintf(atcmd_output, msg_txt(1409), clif->hChSys->local_name, map->list[sd->bl.m].channel ? db_size(map->list[sd->bl.m].channel->users) : 0);// - #%s ( %d users )
clif->message(fd, atcmd_output);
}
- if (hChSys.ally && sd->status.guild_id) {
+ if (clif->hChSys->ally && sd->status.guild_id) {
struct guild *g = sd->guild;
if( !g ) { dbi_destroy(iter); return false; }
- sprintf(atcmd_output, msg_txt(1409), hChSys.ally_name, db_size(g->channel->users));// - #%s ( %d users )
+ sprintf(atcmd_output, msg_txt(1409), clif->hChSys->ally_name, db_size(g->channel->users));// - #%s ( %d users )
clif->message(fd, atcmd_output);
}
for (channel = dbi_first(iter); dbi_exists(iter); channel = dbi_next(iter)) {
@@ -8847,30 +8815,30 @@ ACMD(channel) {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
-
+
if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
-
+
if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
-
- for (k = 0; k < hChSys.colors_count; k++) {
- if (strcmpi(sub2, hChSys.colors_name[k]) == 0)
+
+ for (k = 0; k < clif->hChSys->colors_count; k++) {
+ if (strcmpi(sub2, clif->hChSys->colors_name[k]) == 0)
break;
}
- if (k == hChSys.colors_count) {
+ if (k == clif->hChSys->colors_count) {
sprintf(atcmd_output, msg_txt(1411), sub2);// Unknown color '%s'
clif->message(fd, atcmd_output);
return false;
}
channel->color = k;
- sprintf(atcmd_output, msg_txt(1413),sub1,hChSys.colors_name[k]);// '%s' channel color updated to '%s'
+ sprintf(atcmd_output, msg_txt(1413), sub1, clif->hChSys->colors_name[k]);// '%s' channel color updated to '%s'
clif->message(fd, atcmd_output);
} else if (strcmpi(subcmd,"leave") == 0) {
// sub1 = channel name; sub2 = unused; sub3 = unused
@@ -8907,7 +8875,7 @@ ACMD(channel) {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
-
+
for (k = 0; k < sd->channel_count; k++) {
if (strcmpi(sub1+1,sd->channels[k]->name) == 0)
break;
@@ -8917,7 +8885,7 @@ ACMD(channel) {
clif->message(fd, atcmd_output);
return false;
}
-
+
sd->gcbind = sd->channels[k];
sprintf(atcmd_output, msg_txt(1431),sub1); // Your global chat is now bound to the '%s' channel
clif->message(fd, atcmd_output);
@@ -8927,34 +8895,34 @@ ACMD(channel) {
clif->message(fd, msg_txt(1432));// Your global chat is not bound to any channel
return false;
}
-
+
sprintf(atcmd_output, msg_txt(1433),sd->gcbind->name); // Your global chat is no longer bound to the '#%s' channel
clif->message(fd, atcmd_output);
-
+
sd->gcbind = NULL;
} else if (strcmpi(subcmd,"ban") == 0) {
// sub1 = channel name; sub2 = unused; sub3 = unused
struct map_session_data *pl_sd = NULL;
struct hChSysBanEntry *entry = NULL;
char sub4[NAME_LENGTH]; ///< player name
-
+
if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
-
+
if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
-
+
if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
-
+
if (!message || !*message || sscanf(message, "%19s %19s %23[^\n]", subcmd, sub1, sub4) < 3) {
sprintf(atcmd_output, msg_txt(1434), sub4);// Player '%s' was not found
clif->message(fd, atcmd_output);
@@ -8966,59 +8934,53 @@ ACMD(channel) {
clif->message(fd, atcmd_output);
return false;
}
-
+
if (pc_has_permission(pl_sd, PC_PERM_HCHSYS_ADMIN)) {
clif->message(fd, msg_txt(1464)); // Ban failed, not possible to ban this user.
return false;
}
-
+
if (channel->banned && idb_exists(channel->banned,pl_sd->status.account_id)) {
sprintf(atcmd_output, msg_txt(1465), pl_sd->status.name);// Player '%s' is already banned from this channel
clif->message(fd, atcmd_output);
return false;
}
-
+
if (!channel->banned)
channel->banned = idb_alloc(DB_OPT_BASE|DB_OPT_ALLOW_NULL_DATA|DB_OPT_RELEASE_DATA);
-
+
CREATE(entry, struct hChSysBanEntry, 1);
-
safestrncpy(entry->name, pl_sd->status.name, NAME_LENGTH);
-
idb_put(channel->banned, pl_sd->status.account_id, entry);
-
+
clif->chsys_left(channel,pl_sd);
-
+
sprintf(atcmd_output, msg_txt(1437),pl_sd->status.name,sub1); // Player '%s' has now been banned from '%s' channel
clif->message(fd, atcmd_output);
} else if (strcmpi(subcmd,"unban") == 0) {
// sub1 = channel name; sub2 = unused; sub3 = unused
struct map_session_data *pl_sd = NULL;
char sub4[NAME_LENGTH]; ///< player name
-
+
if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
-
if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
-
if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
-
if (!channel->banned) {
sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players
clif->message(fd, atcmd_output);
return false;
}
-
if (!message || !*message || sscanf(message, "%19s %19s %23[^\n]", subcmd, sub1, sub4) < 3) {
sprintf(atcmd_output, msg_txt(1434), sub4);// Player '%s' was not found
clif->message(fd, atcmd_output);
@@ -9030,20 +8992,18 @@ ACMD(channel) {
clif->message(fd, atcmd_output);
return false;
}
-
if (!idb_exists(channel->banned,pl_sd->status.account_id)) {
sprintf(atcmd_output, msg_txt(1440), pl_sd->status.name);// Player '%s' is not banned from this channel
clif->message(fd, atcmd_output);
return false;
}
-
+
idb_remove(channel->banned, pl_sd->status.account_id);
-
if (!db_size(channel->banned)) {
db_destroy(channel->banned);
channel->banned = NULL;
}
-
+
sprintf(atcmd_output, msg_txt(1441),pl_sd->status.name,sub1); // Player '%s' has now been unbanned from the '%s' channel
clif->message(fd, atcmd_output);
} else if (strcmpi(subcmd,"unbanall") == 0) {
@@ -9052,28 +9012,24 @@ ACMD(channel) {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
-
if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
-
if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
-
if (!channel->banned) {
sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players
clif->message(fd, atcmd_output);
return false;
}
-
db_destroy(channel->banned);
channel->banned = NULL;
-
+
sprintf(atcmd_output, msg_txt(1442),sub1); // Removed all bans from '%s' channel
clif->message(fd, atcmd_output);
} else if (strcmpi(subcmd,"banlist") == 0) {
@@ -9086,19 +9042,16 @@ ACMD(channel) {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
-
if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
-
if (channel->owner != sd->status.char_id && !isA) {
sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
-
if (!channel->banned) {
sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players
clif->message(fd, atcmd_output);
@@ -9106,22 +9059,19 @@ ACMD(channel) {
}
sprintf(atcmd_output, msg_txt(1443), channel->name);// -- '%s' ban list
clif->message(fd, atcmd_output);
-
+
iter = db_iterator(channel->banned);
-
for (data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key)) {
struct hChSysBanEntry * entry = DB->data2ptr(data);
-
+
if (!isA)
sprintf(atcmd_output, msg_txt(1444), entry->name);// - %s %s
else
sprintf(atcmd_output, msg_txt(1445), entry->name, key.i);// - %s (%d)
-
+
clif->message(fd, atcmd_output);
}
-
dbi_destroy(iter);
-
} else if (strcmpi(subcmd,"setopt") == 0) {
// sub1 = channel name; sub2 = option name; sub3 = value
const char* opt_str[3] = {
@@ -9129,34 +9079,28 @@ ACMD(channel) {
"JoinAnnounce",
"MessageDelay",
};
-
if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
-
if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
-
if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
-
if (sub2[0] == '\0') {
clif->message(fd, msg_txt(1446));// You need to input a option
return false;
}
-
for (k = 1; k < 3; k++) {
if (strcmpi(sub2,opt_str[k]) == 0)
break;
}
-
if (k == 3) {
sprintf(atcmd_output, msg_txt(1447), sub2);// '%s' is not a known channel option
clif->message(fd, atcmd_output);
@@ -9167,7 +9111,6 @@ ACMD(channel) {
}
return false;
}
-
if (sub3[0] == '\0') {
if (k == hChSys_OPT_MSG_DELAY) {
sprintf(atcmd_output, msg_txt(1466), opt_str[k]);// For '%s' you need the amount of seconds (from 0 to 10)
@@ -9228,12 +9171,10 @@ ACMD(channel) {
}
}
}
-
}
} else {
- atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ));
+ atcmd_channel_help(fd, command, (clif->hChSys->allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)));
}
-
return true;
}
/* debug only, delete after */
@@ -9243,50 +9184,50 @@ ACMD(fontcolor) {
char mout[40];
if( !message || !*message ) {
- for( k = 0; k < hChSys.colors_count; k++ ) {
- msg_len += sprintf(mout, "[ %s ] : %s",command,hChSys.colors_name[k]);
-
+ for( k = 0; k < clif->hChSys->colors_count; k++ ) {
+ msg_len += sprintf(mout, "[ %s ] : %s", command, clif->hChSys->colors_name[k]);
+
WFIFOHEAD(fd,msg_len + 12);
WFIFOW(fd,0) = 0x2C1;
WFIFOW(fd,2) = msg_len + 12;
WFIFOL(fd,4) = 0;
- WFIFOL(fd,8) = hChSys.colors[k];
+ WFIFOL(fd,8) = clif->hChSys->colors[k];
safestrncpy((char*)WFIFOP(fd,12), mout, msg_len);
WFIFOSET(fd, msg_len + 12);
}
return false;
}
-
+
if( message[0] == '0' ) {
sd->fontcolor = 0;
return true;
}
-
- for( k = 0; k < hChSys.colors_count; k++ ) {
- if( strcmpi(message,hChSys.colors_name[k]) == 0 )
+
+ for( k = 0; k < clif->hChSys->colors_count; k++ ) {
+ if (strcmpi(message, clif->hChSys->colors_name[k]) == 0)
break;
}
- if( k == hChSys.colors_count ) {
+ if( k == clif->hChSys->colors_count ) {
sprintf(atcmd_output, msg_txt(1411), message);// Unknown color '%s'
clif->message(fd, atcmd_output);
return false;
}
-
+
sd->fontcolor = k + 1;
- msg_len += sprintf(mout, "Color changed to '%s'",hChSys.colors_name[k]);
-
+ msg_len += sprintf(mout, "Color changed to '%s'", clif->hChSys->colors_name[k]);
+
WFIFOHEAD(fd,msg_len + 12);
WFIFOW(fd,0) = 0x2C1;
WFIFOW(fd,2) = msg_len + 12;
WFIFOL(fd,4) = 0;
- WFIFOL(fd,8) = hChSys.colors[k];
+ WFIFOL(fd,8) = clif->hChSys->colors[k];
safestrncpy((char*)WFIFOP(fd,12), mout, msg_len);
WFIFOSET(fd, msg_len + 12);
return true;
}
ACMD(searchstore){
int val = atoi(message);
-
+
switch( val ) {
case 0://EFFECTTYPE_NORMAL
case 1://EFFECTTYPE_CASH
@@ -9297,7 +9238,6 @@ ACMD(searchstore){
}
searchstore->open(sd, 99, val);
-
return true;
}
ACMD(costume){
@@ -9320,7 +9260,7 @@ ACMD(costume){
#endif
};
unsigned short k = 0, len = ARRAYLENGTH(names);
-
+
if( !message || !*message ) {
for( k = 0; k < len; k++ ) {
if( sd->sc.data[name2id[k]] ) {
@@ -9330,7 +9270,6 @@ ACMD(costume){
return true;
}
}
-
clif->message(sd->fd,msg_txt(1472));
for( k = 0; k < len; k++ ) {
sprintf(atcmd_output,msg_txt(1471),names[k]);//-- %s
@@ -9338,7 +9277,7 @@ ACMD(costume){
}
return false;
}
-
+
for( k = 0; k < len; k++ ) {
if( sd->sc.data[name2id[k]] ) {
sprintf(atcmd_output,msg_txt(1470),names[k]);// You're already with a '%s' costume, type '@costume' to remove it.
@@ -9346,7 +9285,7 @@ ACMD(costume){
return false;
}
}
-
+
for( k = 0; k < len; k++ ) {
if( strcmpi(message,names[k]) == 0 )
break;
@@ -9356,9 +9295,9 @@ ACMD(costume){
clif->message(sd->fd,atcmd_output);
return false;
}
-
+
sc_start(NULL,&sd->bl, name2id[k], 100, 0, -1);
-
+
return true;
}
/* for debugging purposes (so users can easily provide us with debug info) */
@@ -9636,7 +9575,7 @@ void atcommand_basecommands(void) {
ACMD_DEF2("rmvperm", addperm),
ACMD_DEF(unloadnpcfile),
ACMD_DEF(cart),
- ACMD_DEF(mount2),
+ ACMD_DEF(cashmount),
ACMD_DEF(join),
ACMD_DEF(channel),
ACMD_DEF(fontcolor),
@@ -9645,17 +9584,17 @@ void atcommand_basecommands(void) {
ACMD_DEF(skdebug),
};
int i;
-
+
for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
if(!atcommand->add(atcommand_base[i].command,atcommand_base[i].func,false)) { // Should not happen if atcommand_base[] array is OK
ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
continue;
}
}
-
+
/* @commands from plugins */
HPM_map_atcommands();
-
+
return;
}
#undef ACMD_DEF
@@ -9671,12 +9610,12 @@ bool atcommand_add(char *name,AtCommandFunc func, bool replace) {
CREATE(cmd, AtCommandInfo, 1);
strdb_put(atcommand->db, name, cmd);
}
-
+
safestrncpy(cmd->command, name, sizeof(cmd->command));
cmd->func = func;
cmd->help = NULL;
cmd->log = true;
-
+
return true;
}
@@ -9870,7 +9809,7 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa
if( battle_config.idletime_criteria & BCIDLE_ATCOMMAND )
sd->idletime = sockt->last_tick;
-
+
//Clearing these to be used once more.
memset(command, '\0', sizeof(command));
memset(params, '\0', sizeof(params));
@@ -9896,7 +9835,7 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa
) {
// Check if self or character invoking; if self == character invoked, then self invoke.
bool invokeFlag = ((*atcmd_msg == atcommand->at_symbol) ? 1 : 0);
-
+
// Check if the command initiated is a character command
if (*message == atcommand->char_symbol
&& (ssd = map->nick2sd(charname)) == NULL
@@ -9906,10 +9845,10 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa
clif->message(fd, output);
return true;
}
-
+
if( binding->log ) /* log only if this command should be logged [Ind/Hercules] */
logs->atcommand(sd, atcmd_msg);
-
+
npc->do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
return true;
}
@@ -9947,7 +9886,7 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa
}
}
}
-
+
// Check if target is valid only if confirmed that player can use command.
if (*message == atcommand->char_symbol
&& (ssd = map->nick2sd(charname)) == NULL
@@ -9961,8 +9900,7 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa
//Attempt to use the command
if ( (info->func(fd, (*atcmd_msg == atcommand->at_symbol) ? sd : ssd, command, params,info) != true) ) {
#ifdef AUTOTRADE_PERSISTENCY
- // Autotrade was successful if standalone is set
- if( ((*atcmd_msg == atcommand->at_symbol) ? sd->state.standalone : ssd->state.standalone) )
+ if( info->func == atcommand_autotrade ) /** autotrade deletes caster, so we got nothing more to do here **/
return true;
#endif
sprintf(output,msg_txt(154), command); // %s failed.
@@ -10023,7 +9961,7 @@ void atcommand_config_read(const char* config_filename) {
if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
continue;
commandname = config_setting_name(command);
- if ( !( commandinfo = atcommand_exists(commandname) ) ) {
+ if ( !( commandinfo = atcommand->exists(commandname) ) ) {
ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
continue;
}
@@ -10050,22 +9988,22 @@ void atcommand_config_read(const char* config_filename) {
if (nolog != NULL) {
int i = 0;
int count = libconfig->setting_length(nolog);
-
+
for (i = 0; i < count; ++i) {
config_setting_t *command;
const char *commandname = NULL;
AtCommandInfo *commandinfo = NULL;
-
+
command = libconfig->setting_get_elem(nolog, i);
commandname = config_setting_name(command);
- if ( !( commandinfo = atcommand_exists(commandname) ) ) {
+ if ( !( commandinfo = atcommand->exists(commandname) ) ) {
ShowConfigWarning(command, "atcommand_config_read: can not disable logging for non-existent command %s", commandname);
continue;
}
commandinfo->log = false;
}
}
-
+
// Commands help
// We only check if all commands exist
help = libconfig->lookup(&atcommand_config, "help");
@@ -10080,7 +10018,7 @@ void atcommand_config_read(const char* config_filename) {
command = libconfig->setting_get_elem(help, i);
commandname = config_setting_name(command);
- if ( !( commandinfo = atcommand_exists(commandname) ) )
+ if ( !( commandinfo = atcommand->exists(commandname) ) )
ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
else {
if( commandinfo->help == NULL ) {
@@ -10094,7 +10032,7 @@ void atcommand_config_read(const char* config_filename) {
}
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
-
+
libconfig->destroy(&atcommand_config);
return;
}
@@ -10127,7 +10065,7 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command
config_setting_t *commands = commands_[i];
int result = 0;
int idx = -1;
-
+
if (group == NULL) {
ShowError("atcommand_db_load_groups: group is NULL\n");
continue;
@@ -10138,12 +10076,12 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command
ShowError("atcommand_db_load_groups: index (%d) out of bounds [0,%"PRIuS"]\n", idx, sz - 1);
continue;
}
-
+
if (pcg->has_permission(group, PC_PERM_USE_ALL_COMMANDS)) {
atcmd->at_groups[idx] = atcmd->char_groups[idx] = 1;
continue;
}
-
+
if (commands != NULL) {
config_setting_t *cmd = NULL;
@@ -10173,28 +10111,28 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command
bool atcommand_can_use(struct map_session_data *sd, const char *command) {
AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command + 1));
-
+
if (info == NULL)
return false;
-
+
if ((*command == atcommand->at_symbol && info->at_groups[pcg->get_idx(sd->group)] != 0) ||
(*command == atcommand->char_symbol && info->char_groups[pcg->get_idx(sd->group)] != 0) ) {
return true;
}
-
+
return false;
}
bool atcommand_can_use2(struct map_session_data *sd, const char *command, AtCommandType type) {
AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command));
-
+
if (info == NULL)
return false;
-
+
if ((type == COMMAND_ATCOMMAND && info->at_groups[pcg->get_idx(sd->group)] != 0) ||
(type == COMMAND_CHARCOMMAND && info->char_groups[pcg->get_idx(sd->group)] != 0) ) {
return true;
}
-
+
return false;
}
bool atcommand_hp_add(char *name, AtCommandFunc func) {
@@ -10204,7 +10142,7 @@ bool atcommand_hp_add(char *name, AtCommandFunc func) {
ShowDebug("atcommand_hp_add: Commands can't be added after server is ready, skipping '%s'...\n",name);
return false;
}
-
+
return HPM_map_add_atcommand(name,func);
}
@@ -10249,7 +10187,7 @@ void do_init_atcommand(bool minimal) {
atcommand->at_symbol = '@';
atcommand->char_symbol = '#';
atcommand->binding_count = 0;
-
+
atcommand->doload();
}
@@ -10259,15 +10197,15 @@ void do_final_atcommand(void) {
void atcommand_defaults(void) {
atcommand = &atcommand_s;
-
+
atcommand->db = NULL;
atcommand->alias_db = NULL;
-
+
memset(atcommand->msg_table, 0, sizeof(atcommand->msg_table));
-
+
atcommand->init = do_init_atcommand;
atcommand->final = do_final_atcommand;
-
+
atcommand->exec = atcommand_exec;
atcommand->create = atcommand_hp_add;
atcommand->can_use = atcommand_can_use;
diff --git a/src/map/battle.c b/src/map/battle.c
index fc159c921..ddad2c705 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -218,11 +218,11 @@ int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) {
}
src = map->id2bl(dat->src_id);
-
+
//Check to see if you haven't teleported. [Skotlex]
- if( src && target->m == src->m
+ if( src
&& (target->type != BL_PC || ((TBL_PC*)target)->invincible_timer == INVALID_TIMER)
- && check_distance_bl(src, target, dat->distance)
+ && (dat->skill_id == MO_EXTREMITYFIST || (target->m == src->m && check_distance_bl(src, target, dat->distance)) )
) {
map->freeblock_lock();
status_fix_damage(src, target, dat->damage, dat->delay);
@@ -239,7 +239,7 @@ int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) {
status_fix_damage(target, target, dat->damage, dat->delay);
map->freeblock_unlock();
}
-
+
if( src && src->type == BL_PC && --((TBL_PC*)src)->delayed_damage == 0 && ((TBL_PC*)src)->state.hold_recalc ) {
((TBL_PC*)src)->state.hold_recalc = 0;
status_calc_pc(((TBL_PC*)src),SCO_FORCE);
@@ -252,12 +252,16 @@ int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) {
int battle_delay_damage(int64 tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int64 damage, enum damage_lv dmg_lv, int ddelay, bool additional_effects) {
struct delay_damage *dat;
struct status_change *sc;
+ struct block_list *d_tbl = NULL;
nullpo_ret(src);
nullpo_ret(target);
sc = status->get_sc(target);
- if( sc && sc->data[SC_DEVOTION] && damage > 0 && skill_id != PA_PRESSURE && skill_id != CR_REFLECTSHIELD )
+ if (sc && sc->data[SC_DEVOTION] && sc->data[SC_DEVOTION]->val1)
+ d_tbl = map->id2bl(sc->data[SC_DEVOTION]->val1);
+
+ if( d_tbl && check_distance_bl(target, d_tbl, sc->data[SC_DEVOTION]->val3) && damage > 0 && skill_id != PA_PRESSURE && skill_id != CR_REFLECTSHIELD )
damage = 0;
if ( !battle_config.delay_battle_damage || amotion <= 1 ) {
@@ -279,7 +283,7 @@ int battle_delay_damage(int64 tick, int amotion, struct block_list *src, struct
dat->damage = damage;
dat->dmg_lv = dmg_lv;
dat->delay = ddelay;
- dat->distance = distance_bl(src, target)+10; //Attack should connect regardless unless you teleported.
+ dat->distance = distance_bl(src, target) + (battle_config.snap_dodge ? 10 : battle_config.area_size);
dat->additional_effects = additional_effects;
dat->src_type = src->type;
if (src->type != BL_PC && amotion > 1000)
@@ -288,7 +292,7 @@ int battle_delay_damage(int64 tick, int amotion, struct block_list *src, struct
if( src->type == BL_PC ) {
((TBL_PC*)src)->delayed_damage++;
}
-
+
timer->add(tick+amotion, battle->delay_damage_sub, 0, (intptr_t)dat);
return 0;
@@ -397,24 +401,7 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d
break;
}
} //end tsc check
- if( src && src->type == BL_PC ){
- struct map_session_data *sd = BL_CAST(BL_PC, src);
- int s;
-
- ARR_FIND(1, 6, s, sd->charm[s] > 0);
-
- if( s < 5 && atk_elem == s )
- ratio += sd->charm[s] * 2; // +2% custom value
- }
- if( target && target->type == BL_PC ) {
- struct map_session_data *tsd = BL_CAST(BL_PC, target);
- int t;
- ARR_FIND(1, 6, t, tsd->charm[t] > 0);
-
- if( t < 5 && atk_elem == t )
- damage -= damage * ( tsd->charm[t] * 3 ) / 100;// -3% custom value
- }
if( ratio < 100 )
return damage - (damage * (100 - ratio) / 100);
else
@@ -433,13 +420,13 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u
sd = BL_CAST(BL_PC, src);
damage = status->get_weapon_atk(src, watk, flag);
-
+
if( sd ){
if( type == EQI_HAND_R )
damage = battle->calc_sizefix(sd, damage, EQI_HAND_R, size, flag&8);
else
damage = battle->calc_sizefix(sd, damage, EQI_HAND_L, size, flag&8);
-
+
if( flag&2 && sd->bonus.arrow_atk )
damage += sd->bonus.arrow_atk;
@@ -447,15 +434,18 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u
eatk = sd->base_status.equip_atk;
}
+ if ( skill_id == TF_POISON )
+ eatk += 15 * skill_lv;
+
if( sc && sc->count ){
if( sc->data[SC_ZENKAI] && watk->ele == sc->data[SC_ZENKAI]->val2 )
eatk += 200;
- #ifdef RENEWAL_EDP
+#ifdef RENEWAL_EDP
if( sc->data[SC_EDP] && skill_id != AS_GRIMTOOTH && skill_id != AS_VENOMKNIFE && skill_id != ASC_BREAKER ){
eatk = eatk * (sc->data[SC_EDP]->val4 / 100 - 1);
damage = damage * (sc->data[SC_EDP]->val4 / 100);
}
- #endif
+#endif
}
if( skill_id != ASC_METEORASSAULT ){
@@ -475,7 +465,7 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u
// attacker side
damage = battle->calc_cardfix(BF_WEAPON, src, bl, nk, s_ele, s_ele_, damage, 2|(type == EQI_HAND_L), flag2);
-
+
// target side
damage = battle->calc_cardfix(BF_WEAPON, src, bl, nk, s_ele, s_ele_, damage, 0, flag2);
@@ -500,14 +490,23 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u
int64 battle_calc_base_damage(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int nk, bool n_ele, short s_ele, short s_ele_, int type, int flag, int flag2) {
int64 damage, batk;
struct status_data *st = status->get_status_data(src);
-
- batk = battle->calc_elefix(src, bl, skill_id, skill_lv, status->calc_batk(bl, status->get_sc(src), st->batk, false), nk, n_ele, ELE_NEUTRAL, ELE_NEUTRAL, false, flag);
+ struct status_change *sc = status->get_sc(src);
+
+ if (src->type == BL_PC){
+ // Property from mild wind bypasses it
+ if (sc && sc->data[SC_TK_SEVENWIND])
+ batk = battle->calc_elefix(src, bl, skill_id, skill_lv, status->calc_batk(bl, sc, st->batk, false), nk, n_ele, s_ele, s_ele_, false, flag);
+ else
+ batk = battle->calc_elefix(src, bl, skill_id, skill_lv, status->calc_batk(bl, sc, st->batk, false), nk, n_ele, ELE_NEUTRAL, ELE_NEUTRAL, false, flag);
+ if (type == EQI_HAND_L)
+ damage = batk + 3 * battle->calc_weapon_damage(src, bl, skill_id, skill_lv, &st->lhw, nk, n_ele, s_ele, s_ele_, status_get_size(bl), type, flag, flag2) / 4;
+ else
+ damage = (batk << 1) + battle->calc_weapon_damage(src, bl, skill_id, skill_lv, &st->rhw, nk, n_ele, s_ele, s_ele_, status_get_size(bl), type, flag, flag2);
+ }
+ else{
+ damage = st->batk + battle->calc_weapon_damage(src, bl, skill_id, skill_lv, &st->rhw, nk, n_ele, s_ele, s_ele_, status_get_size(bl), type, flag, flag2);
+ }
- if( type == EQI_HAND_L )
- damage = batk + 3 * battle->calc_weapon_damage(src, bl, skill_id, skill_lv, &st->lhw, nk, n_ele, s_ele, s_ele_, status_get_size(bl), type, flag, flag2) / 4;
- else
- damage = (batk << 1) + battle->calc_weapon_damage(src, bl, skill_id, skill_lv, &st->rhw, nk, n_ele, s_ele, s_ele_, status_get_size(bl), type, flag, flag2);
-
return damage;
}
int64 battle_calc_base_damage2(struct status_data *st, struct weapon_atk *wa, struct status_change *sc, unsigned short t_size, struct map_session_data *sd, int flag) {
@@ -654,10 +653,10 @@ int64 battle_addmastery(struct map_session_data *sd,struct block_list *target,in
break;
case W_1HSPEAR:
case W_2HSPEAR:
- if((skill_lv = pc->checkskill(sd,KN_SPEARMASTERY)) > 0) {
- if(pc_isridingdragon(sd))
+ if ((skill_lv = pc->checkskill(sd,KN_SPEARMASTERY)) > 0) {
+ if (pc_isridingdragon(sd))
damage += (skill_lv * 10);
- else if(pc_isriding(sd))
+ else if (pc_isridingpeco(sd))
damage += (skill_lv * 5);
else
damage += (skill_lv * 4);
@@ -717,14 +716,14 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target,
nullpo_ret(src);
nullpo_ret(target);
-
+
sc = status->get_sc(src);
sd = BL_CAST(BL_PC, src);
tstatus = status->get_status_data(target);
if ( !sd )
return damage;
-
+
damage = battle->add_mastery(sd, target, damage, left);
switch( skill_id ){ // specific skill masteries
@@ -759,7 +758,7 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target,
damage += 40 * pc->checkskill(sd, RA_RESEARCHTRAP);
break;
}
-
+
if( sc ){ // sc considered as masteries
if(sc->data[SC_GN_CARTBOOST])
damage += 10 * sc->data[SC_GN_CARTBOOST]->val1;
@@ -771,25 +770,27 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target,
if(sc->data[SC_IMPOSITIO])
damage += sc->data[SC_IMPOSITIO]->val2;
if(sc->data[SC_DRUMBATTLE]){
- if(tstatus->size == SZ_MEDIUM)
+ if(tstatus->size == SZ_SMALL)
damage += sc->data[SC_DRUMBATTLE]->val2;
- else if(tstatus->size == SZ_SMALL)
+ else if(tstatus->size == SZ_MEDIUM)
damage += 10 * sc->data[SC_DRUMBATTLE]->val1;
//else no bonus for large target
}
if(sc->data[SC_GS_MADNESSCANCEL])
damage += 100;
if(sc->data[SC_GS_GATLINGFEVER]){
- if(tstatus->size == SZ_MEDIUM)
+ if(tstatus->size == SZ_SMALL)
damage += 10 * sc->data[SC_GS_GATLINGFEVER]->val1;
- else if(tstatus->size == SZ_SMALL)
+ else if(tstatus->size == SZ_MEDIUM)
damage += -5 * sc->data[SC_GS_GATLINGFEVER]->val1;
else
damage += sc->data[SC_GS_GATLINGFEVER]->val1;
}
- //if(sc->data[SC_SPECIALZONE])
- // damage += sc->data[SC_SPECIALZONE]->val2 >> 4;
-#endif
+#if 0
+ if(sc->data[SC_SPECIALZONE])
+ damage += sc->data[SC_SPECIALZONE]->val2 >> 4;
+#endif // 0
+#endif // RENEWAL
}
// general skill masteries
@@ -841,12 +842,12 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target,
*------------------------------------------*/
int64 battle_calc_elefix(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 damage, int nk, int n_ele, int s_ele, int s_ele_, bool left, int flag){
struct status_data *tstatus;
-
+
nullpo_ret(src);
nullpo_ret(target);
tstatus = status->get_status_data(target);
-
+
if( (nk&NK_NO_ELEFIX) || n_ele )
return damage;
@@ -865,12 +866,12 @@ int64 battle_calc_elefix(struct block_list *src, struct block_list *target, uint
damage += battle->attr_fix(src,target,50*skill_lv,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv);
}
}
-
+
#ifndef RENEWAL
{
struct status_data *sstatus;
struct status_change *sc;
-
+
sstatus = status->get_status_data(src);
sc = status->get_sc(src);
@@ -889,8 +890,8 @@ int64 battle_calc_elefix(struct block_list *src, struct block_list *target, uint
/*==========================================
* Calculates card bonuses damage adjustments.
* cflag(cardfix flag):
- * &1 - calc for left hand.
- * &2 - atker side cardfix(BF_WEAPON) otherwise target side(BF_WEAPON).
+ * &1 - calc for left hand.
+ * &2 - atker side cardfix(BF_WEAPON) otherwise target side(BF_WEAPON).
*------------------------------------------*/
int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_list *target, int nk, int s_ele, int s_ele_, int64 damage, int cflag, int wflag){
struct map_session_data *sd, *tsd;
@@ -900,7 +901,7 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
if( !damage )
return 0;
-
+
nullpo_ret(src);
nullpo_ret(target);
@@ -911,7 +912,7 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
sstatus = status->get_status_data(src);
tstatus = status->get_status_data(target);
s_race2 = status->get_race2(src);
-
+
switch(attack_type){
case BF_MAGIC:
if ( sd && !(nk&NK_NO_CARDFIX_ATK) ) {
@@ -1124,7 +1125,7 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
}
}
cardfix = cardfix * (100-tsd->subsize[sstatus->size]) / 100;
- cardfix = cardfix * (100-tsd->subrace2[s_race2]) / 100;
+ cardfix = cardfix * (100-tsd->subrace2[s_race2]) / 100;
cardfix = cardfix * (100-tsd->subrace[sstatus->race]) / 100;
cardfix = cardfix * (100-tsd->subrace[is_boss(src)?RC_BOSS:RC_NONBOSS]) / 100;
if( sstatus->race != RC_DEMIHUMAN )
@@ -1202,13 +1203,13 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_
struct map_session_data *sd, *tsd;
struct status_change *sc, *tsc;
int i;
-
+
if( !damage )
return 0;
-
+
nullpo_ret(src);
nullpo_ret(target);
-
+
sd = BL_CAST(BL_PC, src);
tsd = BL_CAST(BL_PC, target);
sstatus = status->get_status_data(src);
@@ -1219,10 +1220,10 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_
switch(attack_type){
case BF_WEAPON:
{
- /** Take note in RE
- * def1 = equip def
- * def2 = status def
- **/
+ /* Take note in RE
+ * def1 = equip def
+ * def2 = status def
+ */
defType def1 = status->get_def(target); //Don't use tstatus->def1 due to skill timer reductions.
short def2 = tstatus->def2, vit_def;
#ifdef RENEWAL
@@ -1233,14 +1234,16 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_
def2 = status->calc_def2(target, tsc, def2, false); // status def(RE)
#endif
- if( sd ){
- i = sd->ignore_def[is_boss(target)?RC_BOSS:RC_NONBOSS];
+ if ( sd ) {
+ i = sd->ignore_def[is_boss(target) ? RC_BOSS : RC_NONBOSS];
i += sd->ignore_def[tstatus->race];
- if( i ){
- if( i > 100 ) i = 100;
+ if ( i ) {
+ if ( i > 100 ) i = 100;
def1 -= def1 * i / 100;
def2 -= def2 * i / 100;
}
+ if ( sd->spiritcharm[SPIRITS_TYPE_CHARM_LAND] > 0 ) // hidden from status window
+ def1 += 10 * def1 * sd->spiritcharm[SPIRITS_TYPE_CHARM_LAND] / 100;
}
if( sc && sc->data[SC_EXPIATIO] ){
@@ -1248,7 +1251,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_
def1 -= def1 * i / 100;
def2 -= def2 * i / 100;
}
-
+
if( battle_config.vit_penalty_type && battle_config.vit_penalty_target&target->type ) {
unsigned char target_count; //256 max targets should be a sane max
target_count = unit->counttargeted(target);
@@ -1267,8 +1270,8 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_
if(def2 < 1) def2 = 1;
}
//Vitality reduction from rodatazone: http://rodatazone.simgaming.net/mechanics/substats.php#def
- if (tsd) //Sd vit-eq
- {
+ if (tsd) {
+ //Sd vit-eq
#ifndef RENEWAL
//[VIT*0.5] + rnd([VIT*0.3], max([VIT*0.3],[VIT^2/150]-1))
vit_def = def2*(def2-15)/150;
@@ -1292,7 +1295,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_
vit_def = def2;
#endif
}
-
+
if (battle_config.weapon_defense_type) {
vit_def += def1*battle_config.weapon_defense_type;
def1 = 0;
@@ -1316,7 +1319,6 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_
else
damage = (int)((100.0f - def1 / (def1 + 400.0f) * 90.0f) / 100.0f * damage - vit_def);
}
-
#else
if( def1 > 100 ) def1 = 100;
if( !(flag&1) ){
@@ -1332,7 +1334,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_
break;
case BF_MAGIC:
- {
+ {
defType mdef = tstatus->mdef;
short mdef2= tstatus->mdef2;
#ifdef RENEWAL
@@ -1370,7 +1372,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_
else
damage = damage * (100-mdef)/100 - mdef2;
#endif
- }
+ }
break;
}
return damage;
@@ -1396,7 +1398,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
int i;
struct status_change *sc, *tsc;
struct map_session_data *sd, *tsd;
- struct status_data *st, *tst;
+ struct status_data *st, *tst, *bst;
nullpo_ret(src);
nullpo_ret(target);
@@ -1406,6 +1408,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
sc = status->get_sc(src);
tsc = status->get_sc(target);
st = status->get_status_data(src);
+ bst = status->get_base_status(src);
tst = status->get_status_data(target);
switch(attack_type){
@@ -1452,9 +1455,9 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
break;
case WZ_FIREPILLAR:
if (skill_lv > 10)
- skillratio += 100;
+ skillratio += 2300; //200% MATK each hit
else
- skillratio -= 80;
+ skillratio += -60 + 20*skill_lv; //20% MATK each hit
break;
case WZ_SIGHTRASHER:
skillratio += 20 * skill_lv;
@@ -1479,20 +1482,38 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
break;
case NJ_KOUENKA:
skillratio -= 10;
+ if ( sd && sd->spiritcharm[SPIRITS_TYPE_CHARM_FIRE] > 0 )
+ skillratio += 20 * sd->spiritcharm[SPIRITS_TYPE_CHARM_FIRE];
break;
case NJ_KAENSIN:
skillratio -= 50;
+ if ( sd && sd->spiritcharm[SPIRITS_TYPE_CHARM_FIRE] > 0 )
+ skillratio += 10 * sd->spiritcharm[SPIRITS_TYPE_CHARM_FIRE];
break;
case NJ_BAKUENRYU:
- skillratio += 50 * (skill_lv-1);
+ skillratio += 50 * (skill_lv - 1);
+ if ( sd && sd->spiritcharm[SPIRITS_TYPE_CHARM_FIRE] > 0 )
+ skillratio += 15 * sd->spiritcharm[SPIRITS_TYPE_CHARM_FIRE];
break;
+#ifdef RENEWAL
+ case NJ_HYOUSENSOU:
+ skillratio -= 30;
+ if ( sd && sd->spiritcharm[SPIRITS_TYPE_CHARM_WATER] > 0 )
+ skillratio += 5 * sd->spiritcharm[SPIRITS_TYPE_CHARM_WATER];
+#endif
case NJ_HYOUSYOURAKU:
skillratio += 50 * skill_lv;
+ if ( sd && sd->spiritcharm[SPIRITS_TYPE_CHARM_WATER] > 0 )
+ skillratio += 25 * sd->spiritcharm[SPIRITS_TYPE_CHARM_WATER];
break;
case NJ_RAIGEKISAI:
skillratio += 60 + 40 * skill_lv;
+ if ( sd && sd->spiritcharm[SPIRITS_TYPE_CHARM_WIND] > 0 )
+ skillratio += 15 * sd->spiritcharm[SPIRITS_TYPE_CHARM_WIND];
break;
case NJ_KAMAITACHI:
+ if ( sd && sd->spiritcharm[SPIRITS_TYPE_CHARM_WIND] > 0 )
+ skillratio += 10 * sd->spiritcharm[SPIRITS_TYPE_CHARM_WIND];
case NPC_ENERGYDRAIN:
skillratio += 100 * skill_lv;
break;
@@ -1505,19 +1526,21 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
skillratio += 25;
break;
case WZ_VERMILION:
- {
- int interval = 0, per = interval, ratio = per;
- while( (per++) < skill_lv ){
- ratio += interval;
- if(per%3==0) interval += 20;
- }
- if( skill_lv > 9 )
- ratio -= 10;
- skillratio += ratio;
+ {
+ int interval = 0, per = interval, ratio = per;
+ while( (per++) < skill_lv ){
+ ratio += interval;
+ if(per%3==0) interval += 20;
}
+ if( skill_lv > 9 )
+ ratio -= 10;
+ skillratio += ratio;
+ }
break;
case NJ_HUUJIN:
skillratio += 50;
+ if ( sd && sd->spiritcharm[SPIRITS_TYPE_CHARM_WIND] > 0 )
+ skillratio += 20 * sd->spiritcharm[SPIRITS_TYPE_CHARM_WIND];
break;
#else
case WZ_VERMILION:
@@ -1739,12 +1762,12 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
skillratio += 100 * skill_lv;
break;
case KO_KAIHOU:
- if( sd ){
- ARR_FIND(1, 6, i, sd->charm[i] > 0);
- if( i < 5 ){
- skillratio += -100 + 200 * sd->charm[i];
+ if ( sd ) {
+ ARR_FIND(SPIRITS_TYPE_CHARM_WATER, SPIRITS_TYPE_SPHERE, i, sd->spiritcharm[i] > 0);
+ if ( i < SPIRITS_TYPE_SPHERE ) {
+ skillratio += -100 + 200 * sd->spiritcharm[i];
RE_LVL_DMOD(100);
- pc->del_charm(sd, sd->charm[i], i);
+ pc->del_charm(sd, sd->spiritcharm[i], i);
}
}
break;
@@ -1903,7 +1926,8 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
break;
#ifndef RENEWAL
case MO_EXTREMITYFIST:
- { //Overflow check. [Skotlex]
+ {
+ //Overflow check. [Skotlex]
unsigned int ratio = skillratio + 100*(8 + st->sp/10);
//You'd need something like 6K SP to reach this max, so should be fine for most purposes.
if (ratio > 60000) ratio = 60000; //We leave some room here in case skillratio gets further increased.
@@ -2054,11 +2078,6 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
case NJ_KIRIKAGE:
skillratio += 100 * (skill_lv-1);
break;
-#ifdef RENEWAL
- case NJ_KUNAI:
- skillratio += 50 + 150 * skill_lv;
- break;
-#endif
case KN_CHARGEATK:
{
int k = (flag-1)/3; //+100% every 3 cells of distance
@@ -2072,10 +2091,10 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
case MO_BALKYOUNG:
skillratio += 200;
break;
- case HFLI_MOON: //[orn]
+ case HFLI_MOON: //[orn]
skillratio += 10 + 110 * skill_lv;
break;
- case HFLI_SBR44: //[orn]
+ case HFLI_SBR44: //[orn]
skillratio += 100 * (skill_lv-1);
break;
case NPC_VAMPIRE_GIFT:
@@ -2196,17 +2215,17 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
break;
case NC_VULCANARM:
skillratio = 70 * skill_lv + status_get_dex(src);
- RE_LVL_DMOD(100);
+ RE_LVL_DMOD(120);
break;
case NC_FLAMELAUNCHER:
case NC_COLDSLOWER:
- skillratio += 200 + 100 * skill_lv + status_get_str(src);
- RE_LVL_DMOD(100);
+ skillratio += 200 + 300 * skill_lv;
+ RE_LVL_DMOD(150);
break;
case NC_ARMSCANNON:
switch( tst->size ) {
- case SZ_MEDIUM: skillratio = 300 + 350 * skill_lv; break; // Medium
- case SZ_SMALL: skillratio = 300 + 400 * skill_lv; break; // Small
+ case SZ_SMALL: skillratio = 300 + 350 * skill_lv; break; // Medium
+ case SZ_MEDIUM: skillratio = 300 + 400 * skill_lv; break; // Small
case SZ_BIG: skillratio = 300 + 300 * skill_lv; break; // Large
}
RE_LVL_DMOD(120);
@@ -2228,17 +2247,20 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
RE_LVL_DMOD(100);
if( st->rhw.ele == ELE_WIND )
skillratio = skillratio * 125 / 100;
- if ( distance_bl(src, target) > 2 ) // Will deal 75% damage outside of 5x5 area.
+ if ( distance_bl(src, target) > 2 ) // Will deal 75% damage outside of 5x5 area.
skillratio = skillratio * 75 / 100;
break;
case SC_FATALMENACE:
- skillratio = 100 * (skill_lv+1) * status->get_lv(src) / 100;
+ skillratio = 100 * (skill_lv+1);
+ RE_LVL_DMOD(100);
break;
case SC_TRIANGLESHOT:
- skillratio = ( 300 + (skill_lv-1) * status_get_agi(src)/2 ) * status->get_lv(src) / 120;
+ skillratio = ( 300 + (skill_lv-1) * status_get_agi(src)/2 );
+ RE_LVL_DMOD(120);
break;
case SC_FEINTBOMB:
- skillratio = (skill_lv+1) * (st->dex/2) * (sd?sd->status.job_level:50)/10 * status->get_lv(src) / 120;
+ skillratio = (skill_lv+1) * (st->dex/2) * (sd?sd->status.job_level:50)/10;
+ RE_LVL_DMOD(120);
break;
case LG_CANNONSPEAR:
skillratio = (50 + st->str) * skill_lv;
@@ -2282,15 +2304,15 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
RE_LVL_DMOD(100);
break;
case LG_OVERBRAND:
- skillratio += -100 + 50 * (((sd) ? pc->checkskill(sd,CR_SPEARQUICKEN) : 1) + 8 * skill_lv);
- RE_LVL_DMOD(150);
+ skillratio += -100 + 400 * skill_lv + 50 * ((sd) ? pc->checkskill(sd,CR_SPEARQUICKEN) : 1);
+ RE_LVL_DMOD(100);
break;
case LG_OVERBRAND_BRANDISH:
skillratio += -100 + 300 * skill_lv + status_get_str(src) + status_get_dex(src);
- RE_LVL_DMOD(150);
+ RE_LVL_DMOD(100);
break;
case LG_OVERBRAND_PLUSATK:
- skillratio += -100 + 100 * skill_lv;
+ skillratio = 200 * skill_lv + rnd_value( 10, 100);
RE_LVL_DMOD(100);
break;
case LG_RAYOFGENESIS:
@@ -2306,7 +2328,14 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
RE_LVL_DMOD(100);
break;
case LG_HESPERUSLIT:
- skillratio += 120 * skill_lv - 100;
+ skillratio = 120 * skill_lv;
+ if( sc && sc->data[SC_BANDING] )
+ skillratio += 200 * sc->data[SC_BANDING]->val2;
+ if( sc && sc->data[SC_BANDING] && sc->data[SC_BANDING]->val2 > 5 )
+ skillratio = skillratio * 150 / 100;
+ if( sc && sc->data[SC_INSPIRATION] )
+ skillratio += 600;
+ RE_LVL_DMOD(100);
break;
case SR_DRAGONCOMBO:
skillratio += 40 * skill_lv;
@@ -2334,7 +2363,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
case SR_FALLENEMPIRE:// ATK [(Skill Level x 150 + 100) x Caster Base Level / 150] %
skillratio += 150 *skill_lv;
RE_LVL_DMOD(150);
- break;
+ break;
case SR_TIGERCANNON:// ATK [((Caster consumed HP + SP) / 4) x Caster Base Level / 100] %
{
int hp = status_get_max_hp(src) * (10 + 2 * skill_lv) / 100,
@@ -2411,9 +2440,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
break;
case GN_CART_TORNADO:
{
- int strbonus = st->str; // FIXME Supposed to take only base STR, but current code wont allow that. So well just take STR for now. [Rytech]
- if ( strbonus > 130 ) // Max base stat limit on official is 130. So well allow no higher then 125 STR here. This limit prevents
- strbonus = 130; // the division from going any lower then 30 so the server wont divide by 0 if someone has 150 STR.
+ int strbonus = bst->str;
skillratio = 50 * skill_lv + (sd ? sd->cart_weight : battle_config.max_cart_weight) / 10 / (150 - strbonus) + 50 * (sd ? pc->checkskill(sd, GN_REMODELING_CART) : 5);
}
break;
@@ -2489,6 +2516,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
RE_LVL_DMOD(120);
if( tsc && tsc->data[SC_KO_JYUMONJIKIRI] )
skillratio += status->get_lv(src) * skill_lv;
+ break;
case KO_HUUMARANKA:
skillratio += -100 + 150 * skill_lv + status_get_agi(src) + status_get_dex(src) + 100 * (sd ? pc->checkskill(sd, NJ_HUUMA) : 0);
break;
@@ -2496,11 +2524,6 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
skillratio += -100 + 100 * skill_lv;
RE_LVL_DMOD(100);
break;
- case KO_BAKURETSU:
- skillratio += -100 + (50 + status_get_dex(src) / 4) * skill_lv * (sd?pc->checkskill(sd,NJ_TOBIDOUGU):10) * 4 / 100;
- RE_LVL_DMOD(120);
- skillratio += 10 * (sd ? sd->status.job_level : 0);
- break;
case MH_NEEDLE_OF_PARALYZE:
skillratio += 600 + 100 * skill_lv;
break;
@@ -2689,14 +2712,11 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
sc_start2(src,bl,SC_COMBOATTACK,100,GC_WEAPONBLOCKING,src->id,2000);
return 0;
}
- if( sc->data[SC_HOVERING] && skill_id && (skill->get_inf(skill_id)&INF_GROUND_SKILL || skill_id == SR_WINDMILL) ) {
- d->dmg_lv = ATK_BLOCK;
- return 0;
- }
- if( (sce=sc->data[SC_AUTOGUARD]) && flag&BF_WEAPON && !(skill->get_nk(skill_id)&NK_NO_CARDFIX_ATK) && rnd()%100 < sce->val2 )
- {
+ if ((sce=sc->data[SC_AUTOGUARD]) && flag&BF_WEAPON && !(skill->get_nk(skill_id)&NK_NO_CARDFIX_ATK) && rnd()%100 < sce->val2) {
int delay;
- clif->skill_nodamage(bl,bl,CR_AUTOGUARD,sce->val1,1);
+ struct block_list *d_bl = NULL;
+ struct status_change_entry *sce_d = sc->data[SC_DEVOTION];
+
// different delay depending on skill level [celest]
if (sce->val1 <= 5)
delay = 300;
@@ -2704,12 +2724,31 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
delay = 200;
else
delay = 100;
- unit->set_walkdelay(bl, timer->gettick(), delay, 1);
- if(sc->data[SC_CR_SHRINK] && rnd()%100<5*sce->val1)
- skill->blown(bl,src,skill->get_blewcount(CR_SHRINK,1),-1,0);
- d->dmg_lv = ATK_MISS;
- return 0;
+ if (sce_d) {
+ // If the target is too far away from the devotion caster, autoguard has no effect
+ // Autoguard will be disabled later on
+ if ((d_bl = map->id2bl(sce_d->val1)) && check_distance_bl(bl, d_bl, sce_d->val3)
+ && ((d_bl->type == BL_MER && ((TBL_MER*)d_bl)->master && ((TBL_MER*)d_bl)->master->bl.id == bl->id)
+ || (d_bl->type == BL_PC && ((TBL_PC*)d_bl)->devotion[sce_d->val2] == bl->id))
+ ) {
+ // if player is target of devotion, show guard effect on the devotion caster rather than the target
+ clif->skill_nodamage(d_bl, d_bl, CR_AUTOGUARD, sce->val1, 1);
+ unit->set_walkdelay(d_bl, timer->gettick(), delay, 1);
+
+ d->dmg_lv = ATK_MISS;
+ return 0;
+ }
+ } else {
+ clif->skill_nodamage(bl, bl, CR_AUTOGUARD, sce->val1, 1);
+ unit->set_walkdelay(bl, timer->gettick(), delay, 1);
+
+ if(sc->data[SC_CR_SHRINK] && rnd()%100<5*sce->val1)
+ skill->blown(bl,src,skill->get_blewcount(CR_SHRINK,1),-1,0);
+
+ d->dmg_lv = ATK_MISS;
+ return 0;
+ }
}
if( (sce = sc->data[SC_MILLENNIUMSHIELD]) && sce->val2 > 0 && damage > 0 ) {
@@ -2745,14 +2784,14 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
return 0;
}
- if((sc->data[SC_HERMODE] || sc->data[SC_HOVERING]) && flag&BF_MAGIC)
+ if((sc->data[SC_HERMODE]) && flag&BF_MAGIC)
return 0;
if(sc->data[SC_NJ_TATAMIGAESHI] && (flag&(BF_MAGIC|BF_LONG)) == BF_LONG)
return 0;
- if((sce=sc->data[SC_KAUPE]) && rnd()%100 < sce->val2)
- { //Kaupe blocks damage (skill or otherwise) from players, mobs, homuns, mercenaries.
+ if ((sce=sc->data[SC_KAUPE]) && rnd()%100 < sce->val2) {
+ //Kaupe blocks damage (skill or otherwise) from players, mobs, homuns, mercenaries.
clif->specialeffect(bl, 462, AREA);
//Shouldn't end until Breaker's non-weapon part connects.
if (skill_id != ASC_BREAKER || !(flag&BF_WEAPON))
@@ -2786,7 +2825,11 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
}
//Now damage increasing effects
- if( sc->data[SC_LEXAETERNA] && skill_id != PF_SOULBURN )
+ if( sc->data[SC_LEXAETERNA] && skill_id != PF_SOULBURN
+#ifdef RENEWAL
+ && skill_id != CR_ACIDDEMONSTRATION
+#endif
+ )
{
if( src->type != BL_MER || skill_id == 0 )
damage <<= 1; // Lex Aeterna only doubles damage of regular attacks from mercenaries
@@ -2862,14 +2905,21 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if(flag&BF_SKILL) { //25% reduction
if ( !(skill->get_inf(skill_id)&INF_GROUND_SKILL) && !(skill->get_nk(skill_id)&NK_SPLASH) )
damage -= 25*damage/100;
- }
- else if ((flag&(BF_LONG|BF_WEAPON)) == (BF_LONG|BF_WEAPON))
+ } else if ((flag&(BF_LONG|BF_WEAPON)) == (BF_LONG|BF_WEAPON)) {
damage >>= 2; //75% reduction
+ }
}
if ( sc->data[SC_WATER_BARRIER] )
damage = damage * ( 100 - 20 ) / 100;
+ if( sc->data[SC_FIRE_EXPANSION_SMOKE_POWDER] ) {
+ if( (flag&(BF_SHORT|BF_WEAPON)) == (BF_SHORT|BF_WEAPON) )
+ damage -= 15 * damage / 100;//15% reduction to physical melee attacks
+ else if( (flag&(BF_LONG|BF_WEAPON)) == (BF_LONG|BF_WEAPON) )
+ damage -= 50 * damage / 100;//50% reduction to physical ranged attacks
+ }
+
// Compressed code, fixed by map.h [Epoque]
if (src->type == BL_MOB) {
int i;
@@ -3044,10 +3094,10 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
status->change_spread(src, bl);
if (sc->data[SC_SHIELDSPELL_REF] && sc->data[SC_SHIELDSPELL_REF]->val1 == 1 && damage > 0)
skill->break_equip(bl,EQP_ARMOR,10000,BCT_ENEMY );
- if (sc->data[SC_STYLE_CHANGE] && rnd()%2) {
- TBL_HOM *hd = BL_CAST(BL_HOM,bl);
- if (hd) homun->addspiritball(hd, 10);
- }
+ if (sc->data[SC_STYLE_CHANGE] && rnd()%2) {
+ TBL_HOM *hd = BL_CAST(BL_HOM,bl);
+ if (hd) homun->addspiritball(hd, 10);
+ }
}
/* no data claims these settings affect anything other than players */
if( damage && sd && bl->type == BL_PC ) {
@@ -3124,7 +3174,7 @@ int64 battle_calc_bg_damage(struct block_list *src, struct block_list *bl, int64
if( bl->type == BL_MOB ) {
struct mob_data* md = BL_CAST(BL_MOB, bl);
-
+
if( flag&BF_SKILL && (md->class_ == MOBID_BLUE_CRYST || md->class_ == MOBID_PINK_CRYST) )
return 0; // Crystal cannot receive skill damage on battlegrounds
}
@@ -3148,8 +3198,9 @@ int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64
switch (skill_id) {
#ifndef RENEWAL
case MO_TRIPLEATTACK:
-#endif
case HW_GRAVITATION:
+#endif
+ case TF_DOUBLE:
break;
default:
return 0;
@@ -3181,7 +3232,6 @@ int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64
*/
break;
}
-
return damage;
}
@@ -3247,11 +3297,10 @@ int battle_adjust_skill_damage(int m, unsigned short skill_id) {
if( map->list[m].skill_count ) {
int i;
ARR_FIND(0, map->list[m].skill_count, i, map->list[m].skills[i]->skill_id == skill_id );
-
+
if( i < map->list[m].skill_count ) {
return map->list[m].skills[i]->modifier;
}
-
}
return 0;
@@ -3275,17 +3324,17 @@ int battle_blewcount_bonus(struct map_session_data *sd, uint16 skill_id) {
struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag) {
int i, nk;
short s_ele = 0;
- unsigned int skillratio = 100; //Skill dmg modifiers.
+ unsigned int skillratio = 100; //Skill dmg modifiers.
- TBL_PC *sd;
+ TBL_PC *sd;
struct status_change *sc;
struct Damage ad;
struct status_data *sstatus = status->get_status_data(src);
struct status_data *tstatus = status->get_status_data(target);
struct {
- unsigned imdef : 1;
+ unsigned imdef : 2;
unsigned infdef : 1;
- } flag;
+ } flag;
memset(&ad,0,sizeof(ad));
memset(&flag,0,sizeof(flag));
@@ -3313,9 +3362,9 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
if (s_ele == -1){ // pl=-1 : the skill takes the weapon's element
s_ele = sstatus->rhw.ele;
- if( sd ){ //Summoning 10 charm will endow your weapon
- ARR_FIND(1, 6, i, sd->charm[i] >= 10);
- if( i < 5 ) s_ele = i;
+ if( sd ){ //Summoning 10 spiritcharm will endow your weapon
+ ARR_FIND(SPIRITS_TYPE_CHARM_WATER, SPIRITS_TYPE_SPHERE, i, sd->spiritcharm[i] >= MAX_SPIRITCHARM);
+ if( i < SPIRITS_TYPE_SPHERE ) s_ele = i;
}
}else if (s_ele == -2) //Use status element
s_ele = status_get_attack_sc_element(src,status->get_sc(src));
@@ -3345,11 +3394,10 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
switch(skill_id) {
case MG_FIREWALL:
- case NJ_KAENSIN:
- ad.dmotion = 0; //No flinch animation.
if ( tstatus->def_ele == ELE_FIRE || battle->check_undead(tstatus->race, tstatus->def_ele) )
ad.blewcount = 0; //No knockback
break;
+ case NJ_KAENSIN:
case PR_SANCTUARY:
ad.dmotion = 0; //No flinch animation.
break;
@@ -3359,8 +3407,8 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
break;
case KO_KAIHOU:
if( sd ){
- ARR_FIND(1, 6, i, sd->charm[i] > 0);
- if( i < 5 )
+ ARR_FIND(SPIRITS_TYPE_CHARM_WATER, SPIRITS_TYPE_SPHERE, i, sd->spiritcharm[i] > 0);
+ if( i < SPIRITS_TYPE_SPHERE )
s_ele = i;
}
break;
@@ -3368,7 +3416,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
case CR_ACIDDEMONSTRATION:
case ASC_BREAKER:
case HW_MAGICCRASHER:
- flag.imdef = 1;
+ flag.imdef = 2;
break;
#endif
}
@@ -3385,8 +3433,8 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
//Adds an absolute value to damage. 100 = +100 damage
#define MATK_ADD( a ) ( ad.damage+= (a) )
- switch (skill_id)
- { //Calc base damage according to skill
+ switch (skill_id) {
+ //Calc base damage according to skill
case AL_HEAL:
case PR_BENEDICTIO:
case PR_SANCTUARY:
@@ -3405,7 +3453,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
case PR_TURNUNDEAD:
//Undead check is on skill_castend_damageid code.
i = 20*skill_lv + sstatus->luk + sstatus->int_ + status->get_lv(src)
- + 200 - 200*tstatus->hp/tstatus->max_hp; // there is no changed in success chance in renewal. [malufett]
+ + 200 - 200*tstatus->hp/tstatus->max_hp; // there is no changed in success chance in renewal. [malufett]
if(i > 700) i = 700;
if(rnd()%1000 < i && !(tstatus->mode&MD_BOSS))
ad.damage = tstatus->hp;
@@ -3429,7 +3477,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
break;
default: {
MATK_ADD( status->get_matk(src, 2) );
-
+
if (nk&NK_SPLASHSPLIT) { // Divide MATK in case of multiple targets skill
if(mflag>0)
ad.damage/= mflag;
@@ -3456,7 +3504,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
}
//Constant/misc additions from skills
if (skill_id == WZ_FIREPILLAR)
- MATK_ADD(50);
+ MATK_ADD(100+50*skill_lv);
if( sd && ( sd->status.class_ == JOB_ARCH_BISHOP_T || sd->status.class_ == JOB_ARCH_BISHOP ) &&
(i=pc->checkskill(sd,AB_EUCHARISTICA)) > 0 &&
(tstatus->race == RC_DEMON || tstatus->def_ele == ELE_DARK) )
@@ -3526,11 +3574,11 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
))
flag.imdef = 1;
}
-
- ad.damage = battle->calc_defense(BF_MAGIC, src, target, skill_id, skill_lv, ad.damage, (flag.imdef?1:0), 0);
-
- if (skill_id == NPC_EARTHQUAKE)
- { //Adds atk2 to the damage, should be influenced by number of hits and skill-ratio, but not mdef reductions. [Skotlex]
+
+ ad.damage = battle->calc_defense(BF_MAGIC, src, target, skill_id, skill_lv, ad.damage, flag.imdef, 0);
+
+ if (skill_id == NPC_EARTHQUAKE) {
+ //Adds atk2 to the damage, should be influenced by number of hits and skill-ratio, but not mdef reductions. [Skotlex]
//Also divide the extra bonuses from atk2 based on the number in range [Kevin]
if(mflag>0)
ad.damage+= (sstatus->rhw.atk2*skillratio/100)/mflag;
@@ -3574,7 +3622,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
}
}
#ifndef RENEWAL
- ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag);
+ ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag);
#endif
}
@@ -3582,8 +3630,8 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
if (flag.infdef && ad.damage)
ad.damage = ad.damage>0?1:-1;
-
- ad.damage=battle->calc_damage(src,target,&ad,ad.damage,skill_id,skill_lv);
+ if (skill_id != ASC_BREAKER)
+ ad.damage = battle->calc_damage(src, target, &ad, ad.damage, skill_id, skill_lv);
if( map_flag_gvg2(target->m) )
ad.damage=battle->calc_gvg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag);
else if( map->list[target->m].flag.battleground )
@@ -3621,7 +3669,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
#ifdef RENEWAL
struct status_change *sc = status->get_sc(src);
#endif
-
+
memset(&md,0,sizeof(md));
nullpo_retr(md, src);
@@ -3742,7 +3790,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
}*/
}else{
float vitfactor = 0.0f, ftemp;
-
+
if( (vitfactor=(status_get_vit(target)-120.0f)) > 0)
vitfactor = (vitfactor * (matk + atk) / 10) / status_get_vit(target);
ftemp = max(0, vitfactor) + (targetVit * (matk + atk)) / 10;
@@ -3751,6 +3799,10 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
md.damage >>= 1;
}
md.damage -= totaldef;
+ if( tsc && tsc->data[SC_LEXAETERNA] ) {
+ md.damage <<= 1;
+ status_change_end(target, SC_LEXAETERNA, INVALID_TIMER);
+ }
}
#else
// updated the formula based on a Japanese formula found to be exact [Reddozen]
@@ -3764,8 +3816,8 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
if( md.damage < 0 )
md.damage = 0;
if( md.damage > INT_MAX>>1 )
- //Overflow prevention, will anyone whine if I cap it to a few billion?
- //Not capped to INT_MAX to give some room for further damage increase.
+ //Overflow prevention, will anyone whine if I cap it to a few billion?
+ //Not capped to INT_MAX to give some room for further damage increase.
md.damage = INT_MAX>>1;
break;
@@ -3787,7 +3839,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
case GS_FLING:
md.damage = sd?sd->status.job_level:status->get_lv(src);
break;
- case HVAN_EXPLOSION: //[orn]
+ case HVAN_EXPLOSION: //[orn]
md.damage = sstatus->max_hp * (50 + 50 * skill_lv) / 100;
break ;
case ASC_BREAKER:
@@ -3800,7 +3852,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
int64 matk = battle->calc_magic_attack(src, target, skill_id, skill_lv, mflag).damage;
short totaldef = status->get_total_def(target) + status->get_total_mdef(target);
int64 atk = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, false, s_ele, ELE_NEUTRAL, EQI_HAND_R, (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), md.flag);
-
+
if( sc && sc->data[SC_EDP] )
ratio >>= 1;
md.damage = (matk + atk) * ratio / 100;
@@ -3827,7 +3879,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
**/
case RA_CLUSTERBOMB:
case RA_FIRINGTRAP:
- case RA_ICEBOUNDTRAP:
+ case RA_ICEBOUNDTRAP:
md.damage = skill_lv * sstatus->dex + sstatus->int_ * 5 ;
RE_LVL_TMDMOD();
if(sd)
@@ -3867,19 +3919,21 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
md.damage = 100 + 200 * skill_lv + sstatus->int_;
break;
case GN_HELLS_PLANT_ATK:
- md.damage = skill_lv * status->get_lv(src) * 10 + sstatus->int_ * 7 / 2 * (18 + (sd ? sd->status.job_level : 0) / 4) * (5 / (10 - (sd ? pc->checkskill(sd, AM_CANNIBALIZE) : 0)));
+ md.damage = skill_lv * status->get_lv(target) * 10 + sstatus->int_ * 7 / 2 * (18 + (sd ? sd->status.job_level : 0) / 4) * (5 / (10 - (sd ? pc->checkskill(sd, AM_CANNIBALIZE) : 0)));
md.damage = md.damage*(1000 + tstatus->mdef) / (1000 + tstatus->mdef * 10) - tstatus->mdef2;
break;
case KO_HAPPOKUNAI:
{
- struct Damage wd = battle->calc_weapon_attack(src,target,skill_id,skill_lv,mflag);
+ struct Damage wd = battle->calc_weapon_attack(src, target, 0, 1, mflag);
#ifdef RENEWAL
short totaldef = status->get_total_def(target);
#else
short totaldef = tstatus->def2 + (short)status->get_def(target);
#endif
- md.damage = 3 * wd.damage * (5 + skill_lv) / 5;
+ if ( sd ) wd.damage += sd->bonus.arrow_atk;
+ md.damage = (int)(3 * (1 + wd.damage) * (5 + skill_lv) / 5.0f);
md.damage -= totaldef;
+
}
break;
}
@@ -3927,7 +3981,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
#endif
if( skill_id == KO_MUCHANAGE )
hitrate = (int)((10 - ((float)1 / (status_get_dex(src) + status_get_luk(src))) * 500) * ((float)skill_lv / 2 + 5));
-
+
hitrate = cap_value(hitrate, battle_config.min_hitrate, battle_config.max_hitrate);
if(rnd()%100 < hitrate)
@@ -3957,7 +4011,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
}
}
#endif
- md.damage = battle->calc_cardfix(BF_MISC, src, target, nk, s_ele, 0, md.damage, 0, md.flag);
+ md.damage = battle->calc_cardfix(BF_MISC, src, target, nk, s_ele, 0, md.damage, 0, md.flag);
if(skill_id){
uint16 rskill;/* redirect skill id */
switch(skill_id){
@@ -4001,7 +4055,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
switch( skill_id ) {
case RA_FIRINGTRAP:
- case RA_ICEBOUNDTRAP:
+ case RA_ICEBOUNDTRAP:
if( md.damage == 1 ) break;
case RA_CLUSTERBOMB:
{
@@ -4027,7 +4081,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
*------------------------------------------*/
struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int wflag)
{
- unsigned int skillratio = 100; //Skill dmg modifiers.
+ unsigned int skillratio = 100; //Skill dmg modifiers.
short temp=0;
short s_ele, s_ele_;
int i, nk;
@@ -4040,21 +4094,21 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
struct status_data *sstatus = status->get_status_data(src);
struct status_data *tstatus = status->get_status_data(target);
struct {
- unsigned hit : 1; //the attack Hit? (not a miss)
- unsigned cri : 1; //Critical hit
- unsigned idef : 1; //Ignore defense
- unsigned idef2 : 1; //Ignore defense (left weapon)
- unsigned pdef : 2; //Pierces defense (Investigate/Ice Pick)
- unsigned pdef2 : 2; //1: Use def+def2/100, 2: Use def+def2/50
- unsigned infdef : 1; //Infinite defense (plants)
- unsigned arrow : 1; //Attack is arrow-based
- unsigned rh : 1; //Attack considers right hand (wd.damage)
- unsigned lh : 1; //Attack considers left hand (wd.damage2)
- unsigned weapon : 1; //It's a weapon attack (consider VVS, and all that)
+ unsigned hit : 1; ///< the attack Hit? (not a miss)
+ unsigned cri : 1; ///< Critical hit
+ unsigned idef : 1; ///< Ignore defense
+ unsigned idef2 : 1; ///< Ignore defense (left weapon)
+ unsigned pdef : 2; ///< Pierces defense (Investigate/Ice Pick)
+ unsigned pdef2 : 2; ///< 1: Use def+def2/100, 2: Use def+def2/50
+ unsigned infdef : 1; ///< Infinite defense (plants)
+ unsigned arrow : 1; ///< Attack is arrow-based
+ unsigned rh : 1; ///< Attack considers right hand (wd.damage)
+ unsigned lh : 1; ///< Attack considers left hand (wd.damage2)
+ unsigned weapon : 1; ///< It's a weapon attack (consider VVS, and all that)
#ifdef RENEWAL
- unsigned tdef : 1; //Total defense reduction
+ unsigned tdef : 1; ///< Total defense reduction
#endif
- } flag;
+ } flag;
memset(&wd,0,sizeof(wd));
memset(&flag,0,sizeof(flag));
@@ -4083,7 +4137,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
wd.blewcount=skill->get_blewcount(skill_id,skill_lv);
wd.flag = BF_WEAPON; //Initial Flag
wd.flag |= (skill_id||wflag)?BF_SKILL:BF_NORMAL; // Baphomet card's splash damage is counted as a skill. [Inkfish]
- wd.dmg_lv=ATK_DEF; //This assumption simplifies the assignation later
+ wd.dmg_lv=ATK_DEF; //This assumption simplifies the assignation later
nk = skill->get_nk(skill_id);
if( !skill_id && wflag ) //If flag, this is splash damage from Baphomet Card and it always hits.
nk |= NK_NO_CARDFIX_ATK|NK_IGNORE_FLEE;
@@ -4165,25 +4219,35 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
case LK_SPIRALPIERCE:
if (!sd) wd.flag=(wd.flag&~(BF_RANGEMASK|BF_WEAPONMASK))|BF_LONG|BF_MISC;
break;
-
+
+ //When in banding, the number of hits is equal to the number of Royal Guards in banding.
+ case LG_HESPERUSLIT:
+ if( sc && sc->data[SC_BANDING] && sc->data[SC_BANDING]->val2 > 3 )
+ wd.div_ = sc->data[SC_BANDING]->val2;
+ break;
+
case MO_INVESTIGATE:
flag.pdef = flag.pdef2 = 2;
break;
-
+
case RA_AIMEDBOLT:
if( tsc && (tsc->data[SC_WUGBITE] || tsc->data[SC_ANKLESNARE] || tsc->data[SC_ELECTRICSHOCKER]) )
wd.div_ = tstatus->size + 2 + ( (rnd()%100 < 50-tstatus->size*10) ? 1 : 0 );
break;
#ifdef RENEWAL
+ case NJ_KUNAI:
case HW_MAGICCRASHER:
+ case NJ_SYURIKEN:
+ case GS_MAGICALBULLET:
+ case KO_BAKURETSU:
flag.tdef = 1;
break;
#endif
}
} else //Range for normal attacks.
wd.flag |= flag.arrow?BF_LONG:BF_SHORT;
- if ( (!skill_id || skill_id == PA_SACRIFICE) && tstatus->flee2 && rnd()%1000 < tstatus->flee2 )
- { //Check for Lucky Dodge
+ if ((!skill_id || skill_id == PA_SACRIFICE) && tstatus->flee2 && rnd()%1000 < tstatus->flee2) {
+ //Check for Lucky Dodge
wd.type=0x0b;
wd.dmg_lv=ATK_LUCKY;
if (wd.div_ < 0) wd.div_*=-1;
@@ -4195,9 +4259,9 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
{ //Take weapon's element
s_ele = sstatus->rhw.ele;
s_ele_ = sstatus->lhw.ele;
- if( sd ){ //Summoning 10 charm will endow your weapon.
- ARR_FIND(1, 6, i, sd->charm[i] >= 10);
- if( i < 5 ) s_ele = s_ele_ = i;
+ if( sd ){ //Summoning 10 spiritcharm will endow your weapon.
+ ARR_FIND(SPIRITS_TYPE_CHARM_WATER, SPIRITS_TYPE_SPHERE, i, sd->spiritcharm[i] >= MAX_SPIRITCHARM);
+ if( i < SPIRITS_TYPE_SPHERE ) s_ele = s_ele_ = i;
}
if( flag.arrow && sd && sd->bonus.arrow_ele )
s_ele = sd->bonus.arrow_ele;
@@ -4216,6 +4280,10 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
case LK_SPIRALPIERCE:
if (!sd) n_ele = false; //forced neutral for monsters
break;
+ case LG_HESPERUSLIT:
+ if ( sc && sc->data[SC_BANDING] && sc->data[SC_BANDING]->val2 == 5 )
+ s_ele = ELE_HOLY; // Banding with 5 RGs: change atk element to Holy.
+ break;
}
if (!(nk & NK_NO_ELEFIX) && !n_ele)
@@ -4226,8 +4294,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
n_ele = false;
}
- if(!skill_id)
- { //Skills ALWAYS use ONLY your right-hand weapon (tested on Aegis 10.2)
+ if(!skill_id) {
+ //Skills ALWAYS use ONLY your right-hand weapon (tested on Aegis 10.2)
if (sd && sd->weapontype1 == 0 && sd->weapontype2 > 0)
{
flag.rh=0;
@@ -4237,11 +4305,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
flag.lh=1;
}
- if( sd && !skill_id ) { //Check for double attack.
- if( ( ( skill_lv = pc->checkskill(sd,TF_DOUBLE) ) > 0 && sd->weapontype1 == W_DAGGER )
- || ( sd->bonus.double_rate > 0 && sd->weapontype1 != W_FIST ) //Will fail bare-handed
- || ( sc && sc->data[SC_KAGEMUSYA] && sd->weapontype1 != W_FIST )) // Need confirmation
- { //Success chance is not added, the higher one is used [Skotlex]
+ if (sd && !skill_id) {
+ //Check for double attack.
+ if (( (skill_lv=pc->checkskill(sd,TF_DOUBLE)) > 0 && sd->weapontype1 == W_DAGGER )
+ || ( sd->bonus.double_rate > 0 && sd->weapontype1 != W_FIST ) //Will fail bare-handed
+ || ( sc && sc->data[SC_KAGEMUSYA] && sd->weapontype1 != W_FIST ) // Need confirmation
+ ) {
+ //Success chance is not added, the higher one is used [Skotlex]
if( rnd()%100 < ( 5*skill_lv > sd->bonus.double_rate ? 5*skill_lv : sc && sc->data[SC_KAGEMUSYA]?sc->data[SC_KAGEMUSYA]->val1*3:sd->bonus.double_rate ) )
{
wd.div_ = skill->get_num(TF_DOUBLE,skill_lv?skill_lv:1);
@@ -4343,7 +4413,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
flag.idef = flag.idef2 =
#endif
flag.hit = 1;
- } else { //Check for Perfect Hit
+ } else {
+ //Check for Perfect Hit
if(sd && sd->bonus.perfect_hit > 0 && rnd()%100 < sd->bonus.perfect_hit)
flag.hit = 1;
if (sc && sc->data[SC_FUSION]) {
@@ -4366,14 +4437,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
flag.hit = 1;
}
- if (!flag.hit)
- { //Hit/Flee calculation
- short
- flee = tstatus->flee,
+ if (!flag.hit) {
+ //Hit/Flee calculation
+ short flee = tstatus->flee;
#ifdef RENEWAL
- hitrate = 0; //Default hitrate
+ short hitrate = 0; //Default hitrate
#else
- hitrate = 80; //Default hitrate
+ short hitrate = 80; //Default hitrate
#endif
if(battle_config.agi_penalty_type && battle_config.agi_penalty_target&target->type) {
@@ -4400,9 +4470,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if( sd ) //in Renewal hit bonus from Vultures Eye is not anymore shown in status window
hitrate += pc->checkskill(sd,AC_VULTURE);
#endif
- if(skill_id)
- switch(skill_id)
- { //Hit skill modifiers
+ switch(skill_id) {
+ //Hit skill modifiers
//It is proven that bonus is applied on final hitrate, not hit.
case SM_BASH:
case MS_BASH:
@@ -4473,10 +4542,10 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
else
flag.hit = 1;
- } //End hit/miss calculation
+ } //End hit/miss calculation
- if (flag.hit && !flag.infdef) //No need to do the math for plants
- { //Hitting attack
+ if (flag.hit && !flag.infdef) { //No need to do the math for plants
+ //Hitting attack
//Assuming that 99% of the cases we will not need to check for the flag.rh... we don't.
//ATK_RATE scales the damage. 100 = no change. 50 is halved, 200 is doubled, etc
@@ -4494,8 +4563,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
#define GET_NORMAL_ATTACK( f ) ( wd.damage = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_R, (f), wd.flag) )
#define GET_NORMAL_ATTACK2( f ) ( wd.damage2 = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_L, (f), wd.flag) )
#endif
- switch (skill_id)
- { //Calc base damage according to skill
+ switch (skill_id) {
+ //Calc base damage according to skill
case PA_SACRIFICE:
wd.damage = sstatus->max_hp* 9/100;
wd.damage2 = 0;
@@ -4521,15 +4590,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_ADD(-totaldef);
if( is_boss(target) )
ATK_RATE(50);
- RE_SKILL_REDUCTION();
}
break;
case NJ_SYURIKEN: // [malufett]
GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0) );
- wd.damage += battle->calc_masteryfix(src, target, skill_id, skill_lv, 4 * skill_lv + (sd ? sd->bonus.arrow_atk : 0), wd.div_, 0, flag.weapon) - status->get_total_def(target);
- RE_SKILL_REDUCTION();
+ wd.damage += battle->calc_masteryfix(src, target, skill_id, skill_lv, 4 * skill_lv + (sd ? sd->bonus.arrow_atk : 0), wd.div_, 0, flag.weapon);
break;
- case MO_EXTREMITYFIST: // [malufett]
+ case MO_EXTREMITYFIST: // [malufett]
{
short totaldef = status->get_total_def(target);
GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|8 );
@@ -4537,7 +4604,6 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
wd.damage = (250 + 150 * skill_lv) + (10 * (status_get_sp(src)+1) * wd.damage / 100) + (8 * wd.damage);
ATK_ADD(-totaldef);
}
- RE_SKILL_REDUCTION();
}
#endif
break;
@@ -4559,10 +4625,10 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
i*=i;
ATK_ADD(i); //Add str bonus.
switch (tstatus->size) { //Size-fix. Is this modified by weapon perfection?
- case SZ_MEDIUM: //Medium: 125%
+ case SZ_SMALL: //Small: 125%
ATK_RATE(125);
break;
- //case SZ_SMALL: //Medium: 100%
+ //case SZ_MEDIUM: //Medium: 100%
case SZ_BIG: //Large: 75%
ATK_RATE(75);
break;
@@ -4582,7 +4648,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
} else
ATK_ADD(sstatus->rhw.atk2); //Else use Atk2
break;
- case HFLI_SBR44: //[orn]
+ case HFLI_SBR44: //[orn]
if(src->type == BL_HOM) {
wd.damage = ((TBL_HOM*)src)->homunculus.intimacy ;
break;
@@ -4648,7 +4714,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
#endif
}
break;
- } //End default case
+ } //End default case
} //End switch(skill_id)
if( sc && skill_id != PA_SACRIFICE && sc->data[SC_UNLIMIT] && (wd.flag&(BF_LONG|BF_MAGIC)) == BF_LONG) {
@@ -4667,18 +4733,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
status_change_end(src, SC_EXEEDBREAK, INVALID_TIMER);
}
-
- #ifdef RENEWAL
- if( sd && skill_id == NJ_KUNAI ){
- flag.tdef = 1;
- ATK_ADD( sd->bonus.arrow_atk );
- }
- #endif
switch(skill_id){
case SR_GATEOFHELL:
- #ifdef RENEWAL
- RE_SKILL_REDUCTION();
- #endif // RENEWAL
if (wd.dmg_lv != ATK_FLEE)
ATK_RATE(battle->calc_skillratio(BF_WEAPON, src, target, skill_id, skill_lv, skillratio, wflag));
else
@@ -4694,14 +4750,14 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0) );
wd.damage = wd.damage * 70 / 100;
//n_ele = true; // FIXME: This is has no effect if it's after GET_NORMAL_ATTACK (was this intended, or was it supposed to be put above?)
-
+
if (sd && index >= 0 &&
sd->inventory_data[index] &&
sd->inventory_data[index]->type == IT_WEAPON)
ATK_ADD(sd->inventory_data[index]->weight * 7 / 100);
-
+
switch (tstatus->size) {
- case SZ_MEDIUM: //Medium: 115%
+ case SZ_SMALL: //Small: 115%
ATK_RATE(115);
break;
case SZ_BIG: //Large: 85%
@@ -4710,6 +4766,17 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
wd.damage = battle->calc_masteryfix(src, target, skill_id, skill_lv, wd.damage, wd.div_, 0, flag.weapon);
}
#endif
+
+ case KO_BAKURETSU:
+ {
+#ifdef RENEWAL
+ GET_NORMAL_ATTACK((sc && sc->data[SC_MAXIMIZEPOWER] ? 1 : 0) | (sc && sc->data[SC_WEAPONPERFECT] ? 8 : 0));
+#endif
+ skillratio = skill_lv * (50 + status_get_dex(src) / 4);
+ skillratio = (int)(skillratio * (sd ? pc->checkskill(sd, NJ_TOBIDOUGU) : 10) * 40.f / 100.0f * status->get_lv(src) / 120);
+ ATK_RATE(skillratio + 10 * (sd ? sd->status.job_level : 0));
+ }
+ break;
default:
ATK_RATE(battle->calc_skillratio(BF_WEAPON, src, target, skill_id, skill_lv, skillratio, wflag));
}
@@ -4739,7 +4806,6 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_ADD( status->get_matk(src, 2) );
#else
ATK_ADD( battle->calc_magic_attack(src, target, skill_id, skill_lv, wflag).damage );
- flag.tdef = 1;
#endif
#ifndef RENEWAL
case NJ_SYURIKEN:
@@ -4811,14 +4877,11 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if( sc->data[SC_TRUESIGHT] )
ATK_ADDRATE(2*sc->data[SC_TRUESIGHT]->val1);
#endif
-
#ifndef RENEWAL_EDP
if( sc->data[SC_EDP] ){
switch(skill_id){
- case AS_SPLASHER:
- case AS_GRIMTOOTH:
+ case AS_SPLASHER: // Needs more info
case ASC_BREAKER:
- case AS_VENOMKNIFE:
case ASC_METEORASSAULT: break;
default:
ATK_ADDRATE(sc->data[SC_EDP]->val3);
@@ -4916,8 +4979,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
}
- if (skill_id != CR_GRANDCROSS && skill_id != NPC_GRANDDARKNESS)
- { //Ignore Defense?
+ if (skill_id != CR_GRANDCROSS && skill_id != NPC_GRANDDARKNESS) {
+ //Ignore Defense?
if (!flag.idef && (
sd->right_weapon.ignore_def_ele & (1<<tstatus->def_ele) ||
sd->right_weapon.ignore_def_race & (1<<tstatus->race) ||
@@ -4959,8 +5022,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
damage_div_fix(wd.damage, wd.div_);
#endif
//Post skill/vit reduction damage increases
- if( sc )
- { //SC skill damages
+ if (sc) {
+ //SC skill damages
if(sc->data[SC_AURABLADE]
#ifndef RENEWAL
&& skill_id != LK_SPIRALPIERCE && skill_id != ML_SPIRALPIERCE
@@ -4972,7 +5035,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
#endif
ATK_ADD(20*lv);
}
-
+
if( !skill_id ) {
if( sc->data[SC_ENCHANTBLADE] ) {
//[( ( Skill Lv x 20 ) + 100 ) x ( casterBaseLevel / 150 )] + casterInt
@@ -4984,7 +5047,6 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if( sc->data[SC_GIANTGROWTH] && rnd()%100 < 15 )
ATK_ADDRATE(200); // Triple Damage
}
-
}
#ifndef RENEWAL
//Refine bonus
@@ -5014,14 +5076,12 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_ADDRATE(40);
#endif
} //Here ends flag.hit section, the rest of the function applies to both hitting and missing attacks
- else if(wd.div_ < 0) //Since the attack missed...
+ else if(wd.div_ < 0) //Since the attack missed...
wd.div_ *= -1;
#ifndef RENEWAL
if(sd && (temp=pc->checkskill(sd,BS_WEAPONRESEARCH)) > 0)
ATK_ADD(temp*2);
#endif
- if(skill_id==TF_POISON)
- ATK_ADD(15*skill_lv);
#ifndef RENEWAL
wd.damage = battle->calc_elefix(src, target, skill_id, skill_lv, wd.damage, nk, n_ele, s_ele, s_ele_, false, flag.arrow);
@@ -5051,7 +5111,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
#endif
-#ifndef RENEWAL
+#ifndef RENEWAL // Offensive damage increment in renewal is done somewhere else
if (sd) {
if (skill_id != CR_SHIELDBOOMERANG) //Only Shield boomerang doesn't takes the Star Crumbs bonus.
ATK_ADD2(wd.div_*sd->right_weapon.star, wd.div_*sd->left_weapon.star);
@@ -5062,9 +5122,9 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
//Card Fix, sd side
- wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 2, wd.flag);
- if( flag.lh )
- wd.damage2 = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage2, 3, wd.flag);
+ wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 2, wd.flag);
+ if( flag.lh )
+ wd.damage2 = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage2, 3, wd.flag);
if( skill_id == CR_SHIELDBOOMERANG || skill_id == PA_SHIELDCHAIN )
{ //Refine bonus applies after cards and elements.
@@ -5073,11 +5133,11 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_ADD(10*sd->status.inventory[index].refine);
}
}
- //Card Fix, tsd side
- if(tsd){ //if player on player then it was already measured above
+#endif
+ //Card Fix, tsd side
+ if(tsd){ //if player on player then it was already measured above
wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, (flag.lh?1:0), wd.flag);
}
-#endif
if( flag.infdef ) { //Plants receive 1 damage when hit
short class_ = status->get_class(target);
if( flag.hit || wd.damage > 0 )
@@ -5101,12 +5161,14 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
if (sd) {
- if (!flag.rh && flag.lh) { //Move lh damage to the rh
+ if (!flag.rh && flag.lh) {
+ //Move lh damage to the rh
wd.damage = wd.damage2;
wd.damage2 = 0;
flag.rh=1;
flag.lh=0;
- } else if(flag.rh && flag.lh) { //Dual-wield
+ } else if(flag.rh && flag.lh) {
+ //Dual-wield
if (wd.damage) {
temp = pc->checkskill(sd,AS_RIGHT) * 10;
if( (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO )
@@ -5186,23 +5248,32 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if( wd.damage + wd.damage2 ) { //There is a total damage value
int64 damage = wd.damage + wd.damage2;
-
- if(!wd.damage2) {
- wd.damage = battle->calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv);
+
+ if (!wd.damage2) {
+#ifdef RENEWAL
+ if (skill_id != ASC_BREAKER)
+#endif
+ wd.damage = battle->calc_damage(src, target, &wd, wd.damage, skill_id, skill_lv);
if( map_flag_gvg2(target->m) )
wd.damage=battle->calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag);
else if( map->list[target->m].flag.battleground )
wd.damage=battle->calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag);
- } else if(!wd.damage) {
- wd.damage2 = battle->calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv);
- if( map_flag_gvg2(target->m) )
- wd.damage2 = battle->calc_gvg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag);
- else if( map->list[target->m].flag.battleground )
- wd.damage = battle->calc_bg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag);
+ }
+ else if (!wd.damage) {
+#ifdef RENEWAL
+ if (skill_id != ASC_BREAKER)
+#endif
+ wd.damage2 = battle->calc_damage(src, target, &wd, wd.damage2, skill_id, skill_lv);
+ if (map_flag_gvg2(target->m))
+ wd.damage2 = battle->calc_gvg_damage(src, target, wd.damage2, wd.div_, skill_id, skill_lv, wd.flag);
+ else if (map->list[target->m].flag.battleground)
+ wd.damage = battle->calc_bg_damage(src, target, wd.damage2, wd.div_, skill_id, skill_lv, wd.flag);
} else {
#ifdef RENEWAL
- wd.damage = battle->calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv);
- wd.damage2 = battle->calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv);
+ if( skill_id != ASC_BREAKER ){
+ wd.damage = battle->calc_damage(src, target, &wd, wd.damage, skill_id, skill_lv);
+ wd.damage2 = battle->calc_damage(src, target, &wd, wd.damage2, skill_id, skill_lv);
+ }
#else
int64 d1 = wd.damage + wd.damage2,d2 = wd.damage2;
wd.damage = battle->calc_damage(src,target,&wd,d1,skill_id,skill_lv);
@@ -5217,9 +5288,9 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
wd.damage-=wd.damage2;
#endif
}
-
- if( src != target ) { // Don't reflect your own damage (Grand Cross)
+
+ if( src != target ) { // Don't reflect your own damage (Grand Cross)
if( wd.dmg_lv == ATK_MISS || wd.dmg_lv == ATK_BLOCK ) {
int64 prev1 = wd.damage, prev2 = wd.damage2;
@@ -5233,9 +5304,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
} else
battle->reflect_damage(target, src, &wd, skill_id);
-
}
-
}
//Reject Sword bugreport:4493 by Daegaladh
if(wd.damage && tsc && tsc->data[SC_SWORDREJECT] &&
@@ -5253,7 +5322,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
status_change_end(target, SC_SWORDREJECT, INVALID_TIMER);
}
#ifndef RENEWAL
- if(skill_id == ASC_BREAKER) { //Breaker's int-based damage (a misc attack?)
+ if(skill_id == ASC_BREAKER) {
+ //Breaker's int-based damage (a misc attack?)
struct Damage md = battle->calc_misc_attack(src, target, skill_id, skill_lv, wflag);
wd.damage += md.damage;
}
@@ -5278,7 +5348,7 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl
memset(&d,0,sizeof(d));
break;
}
-
+
#ifdef HMAP_ZONE_DAMAGE_CAP_TYPE
if( target && skill_id ) {
int i;
@@ -5299,7 +5369,7 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl
}
}
#endif
-
+
if( d.damage + d.damage2 < 1 ) { //Miss/Absorbed
//Weapon attacks should go through to cause additional effects.
if (d.dmg_lv == ATK_DEF /*&& attack_type&(BF_MAGIC|BF_MISC)*/) // Isn't it that additional effects don't apply if miss?
@@ -5410,9 +5480,18 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st
if( wd->dmg_lv >= ATK_BLOCK ) {/* yes block still applies, somehow gravity thinks it makes sense. */
if( sc ) {
- if( sc->data[SC_REFLECTSHIELD] && skill_id != WS_CARTTERMINATION ) {
- NORMALIZE_RDAMAGE(damage * sc->data[SC_REFLECTSHIELD]->val2 / 100);
+ struct status_change_entry *sce_d = sc->data[SC_DEVOTION];
+ struct block_list *d_bl = NULL;
+
+ if (sce_d && sce_d->val1)
+ d_bl = map->id2bl(sce_d->val1);
+
+ if( sc->data[SC_REFLECTSHIELD] && skill_id != WS_CARTTERMINATION && skill_id != GS_DESPERADO
+ && !(d_bl && !(wd->flag&BF_SKILL)) // It should not be a basic attack if the target is under devotion
+ && !(d_bl && sce_d && !check_distance_bl(target, d_bl, sce_d->val3)) // It should not be out of range if the target is under devotion
+ ) {
+ NORMALIZE_RDAMAGE(damage * sc->data[SC_REFLECTSHIELD]->val2 / 100);
#ifndef RENEWAL
rdelay = clif->delay_damage(tick+delay,src, src, status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4);
#else
@@ -5622,7 +5701,10 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
{
int index = sd->equip_index[EQI_AMMO];
if (index<0) {
- clif->arrow_fail(sd,0);
+ if (sd->weapontype1 > W_KATAR || sd->weapontype1 < W_HUUMA)
+ clif->skill_fail(sd, 0, USESKILL_FAIL_NEED_MORE_BULLET, 0);
+ else
+ clif->arrow_fail(sd, 0);
return ATK_NONE;
}
//Ammo check by Ishizu-chan
@@ -5639,13 +5721,13 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
case W_GATLING:
case W_SHOTGUN:
if (sd->inventory_data[index]->look != A_BULLET) {
- clif->arrow_fail(sd,0);
+ clif->skill_fail(sd, 0, USESKILL_FAIL_NEED_MORE_BULLET, 0);
return ATK_NONE;
}
break;
case W_GRENADE:
if (sd->inventory_data[index]->look != A_GRENADE) {
- clif->arrow_fail(sd,0);
+ clif->skill_fail(sd, 0, USESKILL_FAIL_NEED_MORE_BULLET, 0);
return ATK_NONE;
}
break;
@@ -5750,6 +5832,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
if( --(sc->data[SC_SPELLFIST]->val1) >= 0 ){
struct Damage ad = battle->calc_attack(BF_MAGIC,src,target,sc->data[SC_SPELLFIST]->val3,sc->data[SC_SPELLFIST]->val4,flag|BF_SHORT);
wd.damage = ad.damage;
+ damage_div_fix(wd.damage, wd.div_);
}else
status_change_end(src,SC_SPELLFIST,INVALID_TIMER);
}
@@ -6033,7 +6116,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
if (flag&BCT_ENEMY && ( map->getcell(m,src->x,src->y,CELL_CHKBASILICA) || map->getcell(m,target->x,target->y,CELL_CHKBASILICA) ) ) {
return -1;
}
-
+
//t_bl/s_bl hold the 'master' of the attack, while src/target are the actual
//objects involved.
if( (t_bl = battle->get_master(target)) == NULL )
@@ -6072,7 +6155,8 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
if(((((TBL_MOB*)target)->special_state.ai == 2 || //Marine Spheres
(((TBL_MOB*)target)->special_state.ai == 3 && battle_config.summon_flora&1)) && //Floras
s_bl->type == BL_PC && src->type != BL_MOB) || (((TBL_MOB*)target)->special_state.ai == 4 && t_bl->id != s_bl->id)) //Zanzoe
- { //Targetable by players
+ {
+ //Targetable by players
state |= BCT_ENEMY;
strip_enemy = 0;
}
@@ -6082,7 +6166,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
TBL_SKILL *su = (TBL_SKILL*)target;
if( !su->group )
return 0;
- if( skill->get_inf2(su->group->skill_id)&INF2_TRAP ) { //Only a few skills can target traps...
+ if( skill->get_inf2(su->group->skill_id)&INF2_TRAP && su->group->unit_id != UNT_USED_TRAPS) { //Only a few skills can target traps...
switch( battle->get_current_skill(src) ) {
case RK_DRAGONBREATH:// it can only hit traps in pvp/gvg maps
case RK_DRAGONBREATH_WATER:
@@ -6129,8 +6213,10 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
su->group->skill_id == GN_WALLOFTHORN) {
state |= BCT_ENEMY;
strip_enemy = 0;
- } else //Excepting traps and icewall, you should not be able to target skills.
+ } else {
+ //Excepting traps and icewall, you should not be able to target skills.
return 0;
+ }
}
break;
//Valid targets with no special checks here.
@@ -6141,7 +6227,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
//All else not specified is an invalid target.
default:
return 0;
- } //end switch actual target
+ } //end switch actual target
switch( t_bl->type ) { //Checks on target master
case BL_PC:
@@ -6181,6 +6267,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
break;
case BL_SKILL: {
struct skill_unit *su = (struct skill_unit *)src;
+ struct status_change* sc = status->get_sc(target);
if (!su->group)
return 0;
@@ -6191,6 +6278,11 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
if (inf2&INF2_TARGET_SELF)
return 1;
}
+ //Status changes that prevent traps from triggering
+ if (sc && sc->count && skill->get_inf2(su->group->skill_id)&INF2_TRAP) {
+ if( sc->data[SC_WZ_SIGHTBLASTER] && sc->data[SC_WZ_SIGHTBLASTER]->val2 > 0 && sc->data[SC_WZ_SIGHTBLASTER]->val4%2 == 0)
+ return -1;
+ }
}
break;
case BL_MER:
@@ -6281,7 +6373,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
if( flag&(BCT_PARTY|BCT_ENEMY) ) {
int s_party = status->get_party_id(s_bl);
int s_guild = status->get_guild_id(s_bl);
-
+
if( s_party && s_party == status->get_party_id(t_bl)
&& !(map->list[m].flag.pvp && map->list[m].flag.pvp_noparty)
&& !(map_flag_gvg(m) && map->list[m].flag.gvg_noparty && !( s_guild && s_guild == status->get_guild_id(t_bl) ))
@@ -6330,7 +6422,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
if(s_guild && t_guild && (s_guild == t_guild || (!(flag&BCT_SAMEGUILD) && guild->isallied(s_guild, t_guild))))
state |= BCT_GUILD;
}
- } //end non pvp/gvg chk rivality
+ } //end non pvp/gvg chk rivality
if( !state ) //If not an enemy, nor a guild, nor party, nor yourself, it's neutral.
state = BCT_NEUTRAL;
@@ -6355,8 +6447,7 @@ bool battle_check_range(struct block_list *src, struct block_list *bl, int range
#ifndef CIRCULAR_AREA
if( src->type == BL_PC ) { // Range for players' attacks and skills should always have a circular check. [Angezerus]
- int dx = src->x - bl->x, dy = src->y - bl->y;
- if( !path->check_distance(dx, dy, range) )
+ if ( !check_distance_client_bl(src, bl, range) )
return false;
} else
#endif
@@ -6394,7 +6485,7 @@ static const struct battle_data {
{ "skill_add_range", &battle_config.skill_add_range, 0, 0, INT_MAX, },
{ "skill_out_range_consume", &battle_config.skill_out_range_consume, 1, 0, 1, },
{ "skillrange_by_distance", &battle_config.skillrange_by_distance, ~BL_PC, BL_NUL, BL_ALL, },
- { "skillrange_from_weapon", &battle_config.use_weapon_skill_range, ~BL_PC, BL_NUL, BL_ALL, },
+ { "skillrange_from_weapon", &battle_config.use_weapon_skill_range, BL_NUL, BL_NUL, BL_ALL, },
{ "player_damage_delay_rate", &battle_config.pc_damage_delay_rate, 100, 0, INT_MAX, },
{ "defunit_not_enemy", &battle_config.defnotenemy, 0, 0, 1, },
{ "gvg_traps_target_all", &battle_config.vs_traps_bctall, BL_PC, BL_NUL, BL_ALL, },
@@ -6445,7 +6536,7 @@ static const struct battle_data {
{ "monster_active_enable", &battle_config.monster_active_enable, 1, 0, 1, },
{ "monster_damage_delay_rate", &battle_config.monster_damage_delay_rate, 100, 0, INT_MAX, },
{ "monster_loot_type", &battle_config.monster_loot_type, 0, 0, 1, },
-// { "mob_skill_use", &battle_config.mob_skill_use, 1, 0, 1, }, //Deprecated
+ //{ "mob_skill_use", &battle_config.mob_skill_use, 1, 0, 1, }, //Deprecated
{ "mob_skill_rate", &battle_config.mob_skill_rate, 100, 0, INT_MAX, },
{ "mob_skill_delay", &battle_config.mob_skill_delay, 100, 0, INT_MAX, },
{ "mob_count_rate", &battle_config.mob_count_rate, 100, 0, INT_MAX, },
@@ -6571,7 +6662,8 @@ static const struct battle_data {
{ "bone_drop", &battle_config.bone_drop, 0, 0, 2, },
{ "buyer_name", &battle_config.buyer_name, 1, 0, 1, },
{ "skill_wall_check", &battle_config.skill_wall_check, 1, 0, 1, },
- { "cell_stack_limit", &battle_config.cell_stack_limit, 1, 1, 255, },
+ { "official_cell_stack_limit", &battle_config.official_cell_stack_limit, 1, 1, 255, },
+ { "custom_cell_stack_limit", &battle_config.custom_cell_stack_limit, 1, 1, 255, },
{ "dancing_weaponswitch_fix", &battle_config.dancing_weaponswitch_fix, 1, 0, 1, },
// eAthena additions
@@ -6714,7 +6806,7 @@ static const struct battle_data {
{ "invincible.nodamage", &battle_config.invincible_nodamage, 0, 0, 1, },
{ "mob_slave_keep_target", &battle_config.mob_slave_keep_target, 0, 0, 1, },
{ "autospell_check_range", &battle_config.autospell_check_range, 0, 0, 1, },
- { "knockback_left", &battle_config.knockback_left, 1, 0, 1, },
+ { "knockback_left", &battle_config.knockback_left, 1, 0, 1, },
{ "client_reshuffle_dice", &battle_config.client_reshuffle_dice, 0, 0, 1, },
{ "client_sort_storage", &battle_config.client_sort_storage, 0, 0, 1, },
{ "feature.buying_store", &battle_config.feature_buying_store, 1, 0, 1, },
@@ -6726,6 +6818,7 @@ static const struct battle_data {
{ "mail_show_status", &battle_config.mail_show_status, 0, 0, 2, },
{ "client_limit_unit_lv", &battle_config.client_limit_unit_lv, 0, 0, BL_ALL, },
{ "client_emblem_max_blank_percent", &battle_config.client_emblem_max_blank_percent, 100, 0, 100, },
+
// BattleGround Settings
{ "bg_update_interval", &battle_config.bg_update_interval, 1000, 100, INT_MAX, },
{ "bg_flee_penalty", &battle_config.bg_flee_penalty, 20, 0, INT_MAX, },
@@ -6750,6 +6843,7 @@ static const struct battle_data {
**/
{ "skill_trap_type", &battle_config.skill_trap_type, 0, 0, 1, },
{ "item_restricted_consumption_type", &battle_config.item_restricted_consumption_type,1, 0, 1, },
+ { "unequip_restricted_equipment", &battle_config.unequip_restricted_equipment, 0, 0, 3, },
{ "max_walk_path", &battle_config.max_walk_path, 17, 1, MAX_WALKPATH, },
{ "item_enabled_npc", &battle_config.item_enabled_npc, 1, 0, 1, },
{ "gm_ignore_warpable_area", &battle_config.gm_ignore_warpable_area, 0, 2, 100, },
@@ -6763,8 +6857,15 @@ static const struct battle_data {
{ "mon_trans_disable_in_gvg", &battle_config.mon_trans_disable_in_gvg, 0, 0, 1, },
{ "case_sensitive_aegisnames", &battle_config.case_sensitive_aegisnames, 1, 0, 1, },
- { "guild_castle_invite", &battle_config.guild_castle_invite, 0, 0, 1, },
- { "guild_castle_expulsion", &battle_config.guild_castle_expulsion, 0, 0, 1, },
+ { "guild_castle_invite", &battle_config.guild_castle_invite, 0, 0, 1, },
+ { "guild_castle_expulsion", &battle_config.guild_castle_expulsion, 0, 0, 1, },
+ { "song_timer_reset", &battle_config.song_timer_reset, 0, 0, 1, },
+ { "snap_dodge", &battle_config.snap_dodge, 0, 0, 1, },
+ { "stormgust_knockback", &battle_config.stormgust_knockback, 1, 0, 1, },
+ { "monster_chase_refresh", &battle_config.mob_chase_refresh, 1, 0, 30, },
+ { "mob_icewall_walk_block", &battle_config.mob_icewall_walk_block, 75, 0, 255, },
+ { "boss_icewall_walk_block", &battle_config.boss_icewall_walk_block, 0, 0, 255, },
+ { "feature.roulette", &battle_config.feature_roulette, 1, 0, 1, },
};
#ifndef STATS_OPT_OUT
/**
@@ -6805,7 +6906,7 @@ void Hercules_report(char* date, char *time_c) {
/* we get the current time */
time(&curtime);
strftime(timestring, 24, "%Y-%m-%d %H:%M:%S", localtime(&curtime));
-
+
#ifdef CIRCULAR_AREA
config |= C_CIRCULAR_AREA;
#endif
@@ -6817,7 +6918,7 @@ void Hercules_report(char* date, char *time_c) {
#ifdef CONSOLE_INPUT
config |= C_CONSOLE_INPUT;
#endif
-
+
#ifdef SCRIPT_CALLFUNC_CHECK
config |= C_SCRIPT_CALLFUNC_CHECK;
#endif
@@ -6861,7 +6962,7 @@ void Hercules_report(char* date, char *time_c) {
#ifdef PACKETVER_RE
config |= C_PACKETVER_RE;
#endif
-
+
/* non-define part */
if( map->db_use_sql_item_db )
config |= C_SQL_DB_ITEM;
@@ -7008,7 +7109,7 @@ void battle_adjust_conf(void) {
battle_config.feature_search_stores = 0;
}
#endif
-
+
#if PACKETVER < 20130724
if( battle_config.feature_banking ) {
ShowWarning("conf/battle/feature.conf banking is enabled but it requires PACKETVER 2013-07-24 or newer, disabling...\n");
@@ -7016,6 +7117,13 @@ void battle_adjust_conf(void) {
}
#endif
+#if PACKETVER < 20141022
+ if( battle_config.feature_roulette ) {
+ ShowWarning("conf/battle/feature.conf roulette is enabled but it requires PACKETVER 2014-10-22 or newer, disabling...\n");
+ battle_config.feature_roulette = 0;
+ }
+#endif
+
#if PACKETVER > 20120000 && PACKETVER < 20130515 /* exact date (when it started) not known */
if( battle_config.feature_auction == 1 ) {
ShowWarning("conf/battle/feature.conf:feature.auction is enabled but it is not stable on PACKETVER "EXPAND_AND_QUOTE(PACKETVER)", disabling...\n");
@@ -7026,8 +7134,8 @@ void battle_adjust_conf(void) {
#ifndef CELL_NOSTACK
- if (battle_config.cell_stack_limit != 1)
- ShowWarning("Battle setting 'cell_stack_limit' takes no effect as this server was compiled without Cell Stack Limit support (CELL_NOSTACK).\n");
+ if (battle_config.custom_cell_stack_limit != 1)
+ ShowWarning("Battle setting 'custom_cell_stack_limit' takes no effect as this server was compiled without Cell Stack Limit support.\n");
#endif
}
@@ -7094,15 +7202,15 @@ void do_final_battle(void) {
/* initialize the interface */
void battle_defaults(void) {
battle = &battle_s;
-
+
battle->bc = &battle_config;
-
+
memset(battle->attr_fix_table, 0, sizeof(battle->attr_fix_table));
battle->delay_damage_ers = NULL;
-
+
battle->init = do_init_battle;
battle->final = do_final_battle;
-
+
battle->calc_attack = battle_calc_attack;
battle->calc_damage = battle_calc_damage;
battle->calc_gvg_damage = battle_calc_gvg_damage;
diff --git a/src/map/battle.h b/src/map/battle.h
index dfa156796..e80e0091d 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -28,23 +28,24 @@ struct status_data;
#define MIN_CLOTH_COLOR (battle->bc->min_cloth_color)
#define MAX_CLOTH_COLOR (battle->bc->max_cloth_color)
-#define is_boss(bl) (status_get_mode(bl)&MD_BOSS) // Can refine later [Aru]
+#define is_boss(bl) (status_get_mode(bl)&MD_BOSS) // Can refine later [Aru]
/**
* Enumerations
**/
-enum { // Flag of the final calculation
- BF_WEAPON = 0x0001,
- BF_MAGIC = 0x0002,
- BF_MISC = 0x0004,
- BF_SHORT = 0x0010,
- BF_LONG = 0x0040,
- BF_SKILL = 0x0100,
- BF_NORMAL = 0x0200,
- BF_WEAPONMASK=0x000f,
- BF_RANGEMASK= 0x00f0,
- BF_SKILLMASK= 0x0f00,
+enum {
+ // Flag of the final calculation
+ BF_WEAPON = 0x0001,
+ BF_MAGIC = 0x0002,
+ BF_MISC = 0x0004,
+ BF_SHORT = 0x0010,
+ BF_LONG = 0x0040,
+ BF_SKILL = 0x0100,
+ BF_NORMAL = 0x0200,
+ BF_WEAPONMASK = 0x000f,
+ BF_RANGEMASK = 0x00f0,
+ BF_SKILLMASK = 0x0f00,
};
// state of a single attack attempt; used in flee/def penalty calculations when mobbed
@@ -62,17 +63,17 @@ enum e_battle_check_target { //New definitions [Skotlex]
BCT_SELF = 0x010000,
BCT_ENEMY = 0x020000,
BCT_PARTY = 0x040000,
- BCT_GUILDALLY = 0x080000, // Only allies, NOT guildmates
+ BCT_GUILDALLY = 0x080000, ///< Only allies, NOT guildmates
BCT_NEUTRAL = 0x100000,
- BCT_SAMEGUILD = 0x200000, // No Guild Allies
-
- BCT_GUILD = 0x280000, // Guild AND allies (BCT_SAMEGUILD|BCT_GUILDALLY)
-
- BCT_NOGUILD = 0x170000, // This should be (~BCT_GUILD&BCT_ALL)
- BCT_NOPARTY = 0x3b0000, // This should be (~BCT_PARTY&BCT_ALL)
- BCT_NOENEMY = 0x3d0000, // This should be (~BCT_ENEMY&BCT_ALL)
-
- BCT_ALL = 0x3f0000, // Sum of BCT_NOONE to BCT_SAMEGUILD
+ BCT_SAMEGUILD = 0x200000, ///< No Guild Allies
+
+ BCT_GUILD = 0x280000, ///< Guild AND allies (BCT_SAMEGUILD|BCT_GUILDALLY)
+
+ BCT_NOGUILD = 0x170000, ///< This must be (~BCT_GUILD&BCT_ALL)
+ BCT_NOPARTY = 0x3b0000, ///< This must be (~BCT_PARTY&BCT_ALL)
+ BCT_NOENEMY = 0x3d0000, ///< This must be (~BCT_ENEMY&BCT_ALL)
+
+ BCT_ALL = 0x3f0000, ///< Sum of BCT_NOONE to BCT_SAMEGUILD
};
/**
@@ -86,7 +87,7 @@ struct Damage {
int amotion,dmotion;
int blewcount; //nb of knockback
int flag; //chk BF_* flag, (enum below)
- enum damage_lv dmg_lv; //ATK_LUCKY,ATK_FLEE,ATK_DEF
+ enum damage_lv dmg_lv; //ATK_LUCKY,ATK_FLEE,ATK_DEF
};
struct Battle_Config {
@@ -147,12 +148,12 @@ struct Battle_Config {
int monster_active_enable;
int monster_damage_delay_rate;
int monster_loot_type;
- int mob_skill_rate; //[Skotlex]
- int mob_skill_delay; //[Skotlex]
+ int mob_skill_rate; //[Skotlex]
+ int mob_skill_delay; //[Skotlex]
int mob_count_rate;
int no_spawn_on_player; //[Skotlex]
int force_random_spawn; //[Skotlex]
- int mob_spawn_delay, plant_spawn_delay, boss_spawn_delay; // [Skotlex]
+ int mob_spawn_delay, plant_spawn_delay, boss_spawn_delay; // [Skotlex]
int slaves_inherit_mode;
int slaves_inherit_speed;
int summons_trigger_autospells;
@@ -169,7 +170,7 @@ struct Battle_Config {
int emergency_call;
int guild_aura;
int pc_invincible_time;
-
+
int pet_catch_rate;
int pet_rename;
int pet_friendly_rate;
@@ -178,7 +179,7 @@ struct Battle_Config {
int pet_status_support;
int pet_attack_support;
int pet_damage_support;
- int pet_support_min_friendly; //[Skotlex]
+ int pet_support_min_friendly; //[Skotlex]
int pet_equip_min_friendly;
int pet_support_rate;
int pet_attack_exp_to_master;
@@ -189,7 +190,7 @@ struct Battle_Config {
int pet_max_atk2; //[Skotlex]
int pet_no_gvg; //Disables pets in gvg. [Skotlex]
int pet_equip_required;
-
+
int skill_min_damage;
int finger_offensive_type;
int heal_exp;
@@ -199,11 +200,11 @@ struct Battle_Config {
int shop_exp;
int combo_delay_rate;
int item_check;
- int item_use_interval; //[Skotlex]
+ int item_use_interval; //[Skotlex]
int cashfood_use_interval;
int wedding_modifydisplay;
- int wedding_ignorepalette; //[Skotlex]
- int xmas_ignorepalette; // [Valaris]
+ int wedding_ignorepalette; //[Skotlex]
+ int xmas_ignorepalette; // [Valaris]
int summer_ignorepalette; // [Zephyrus]
int hanbok_ignorepalette;
int natural_healhp_interval;
@@ -212,7 +213,7 @@ struct Battle_Config {
int natural_heal_weight_rate;
int arrow_decrement;
int max_aspd;
- int max_walk_speed; //Maximum walking speed after buffs [Skotlex]
+ int max_walk_speed; //Maximum walking speed after buffs [Skotlex]
int max_hp;
int max_sp;
int max_lv, aura_lv;
@@ -224,8 +225,8 @@ struct Battle_Config {
int save_clothcolor;
int undead_detect_type;
int auto_counter_type;
- int min_hitrate; //[Skotlex]
- int max_hitrate; //[Skotlex]
+ int min_hitrate; //[Skotlex]
+ int max_hitrate; //[Skotlex]
int agi_penalty_target;
int agi_penalty_type;
int agi_penalty_count;
@@ -263,33 +264,33 @@ struct Battle_Config {
int item_rate_mvp, item_rate_common, item_rate_common_boss, item_rate_card, item_rate_card_boss,
item_rate_equip, item_rate_equip_boss, item_rate_heal, item_rate_heal_boss, item_rate_use,
item_rate_use_boss, item_rate_treasure, item_rate_adddrop;
-
+
int logarithmic_drops;
- int item_drop_common_min,item_drop_common_max; // Added by TyrNemesis^
+ int item_drop_common_min,item_drop_common_max; // Added by TyrNemesis^
int item_drop_card_min,item_drop_card_max;
int item_drop_equip_min,item_drop_equip_max;
- int item_drop_mvp_min,item_drop_mvp_max; // End Addition
- int item_drop_heal_min,item_drop_heal_max; // Added by Valatris
- int item_drop_use_min,item_drop_use_max; //End
+ int item_drop_mvp_min,item_drop_mvp_max; // End Addition
+ int item_drop_heal_min,item_drop_heal_max; // Added by Valatris
+ int item_drop_use_min,item_drop_use_max; //End
int item_drop_treasure_min,item_drop_treasure_max; //by [Skotlex]
int item_drop_adddrop_min,item_drop_adddrop_max; //[Skotlex]
-
- int prevent_logout; // Added by RoVeRT
-
- int alchemist_summon_reward; // [Valaris]
+
+ int prevent_logout; // Added by RoVeRT
+
+ int alchemist_summon_reward; // [Valaris]
int drops_by_luk;
int drops_by_luk2;
- int equip_natural_break_rate; //Base Natural break rate for attacks.
+ int equip_natural_break_rate; //Base Natural break rate for attacks.
int equip_self_break_rate; //Natural & Penalty skills break rate
int equip_skill_break_rate; //Offensive skills break rate
int multi_level_up;
int max_exp_gain_rate; //Max amount of exp bar % you can get in one go.
int pk_mode;
int pk_level_range;
-
+
int manner_system; // end additions [Valaris]
int show_mob_info;
-
+
int gx_allhit;
int gx_disptype;
int devotion_level_difference;
@@ -305,13 +306,13 @@ struct Battle_Config {
int bone_drop;
int buyer_name;
int dancing_weaponswitch_fix;
-
+
// eAthena additions
int night_at_start; // added by [Yor]
int day_duration; // added by [Yor]
int night_duration; // added by [Yor]
int ban_hack_trade; // added by [Yor]
-
+
int min_hair_style; // added by [MouseJstr]
int max_hair_style; // added by [MouseJstr]
int min_hair_color; // added by [MouseJstr]
@@ -319,12 +320,12 @@ struct Battle_Config {
int min_cloth_color; // added by [MouseJstr]
int max_cloth_color; // added by [MouseJstr]
int pet_hair_style; // added by [Skotlex]
-
+
int castrate_dex_scale; // added by [MouseJstr]
int area_size; // added by [MouseJstr]
-
+
int max_def, over_def_bonus; //added by [Skotlex]
-
+
int zeny_from_mobs; // [Valaris]
int mobs_level_up; // [Valaris]
int mobs_level_up_exp_rate; // [Valaris]
@@ -344,12 +345,12 @@ struct Battle_Config {
int delay_battle_damage;
int hide_woe_damage;
int display_version;
-
- int display_hallucination; // [Skotlex]
- int use_statpoint_table; // [Skotlex]
-
+
+ int display_hallucination; // [Skotlex]
+ int use_statpoint_table; // [Skotlex]
+
int ignore_items_gender; //[Lupus]
-
+
int copyskill_restrict; // [Aru]
int berserk_cancels_buffs; // [Aru]
int mob_ai; //Configures various mob_ai settings to make them smarter or dumber(official). [Skotlex]
@@ -359,36 +360,37 @@ struct Battle_Config {
int mob_remove_delay; // Dynamic Mobs - delay before removing mobs from a map [Skotlex]
int mob_active_time; //Duration through which mobs execute their Hard AI after players leave their area of sight.
int boss_active_time;
-
- int show_hp_sp_drain, show_hp_sp_gain; //[Skotlex]
-
+
+ int show_hp_sp_drain, show_hp_sp_gain; //[Skotlex]
+
int mob_npc_event_type; //Determines on who the npc_event is executed. [Skotlex]
-
+
int character_size; // if riders have size=2, and baby class riders size=1 [Lupus]
int rare_drop_announce; // chance <= to show rare drops global announces
-
- int retaliate_to_master; //Whether when a mob is attacked by another mob, it will retaliate versus the mob or the mob's master. [Skotlex]
-
+
+ int retaliate_to_master; //Whether when a mob is attacked by another mob, it will retaliate versus the mob or the mob's master. [Skotlex]
+
int duel_allow_pvp; // [LuzZza]
int duel_allow_gvg; // [LuzZza]
int duel_allow_teleport; // [LuzZza]
int duel_autoleave_when_die; // [LuzZza]
int duel_time_interval; // [LuzZza]
int duel_only_on_same_map; // [Toms]
-
+
int skip_teleport_lv1_menu; // possibility to disable (skip) Teleport Lv1 menu, that have only two lines `Random` and `Cancel` [LuzZza]
int mob_max_skilllvl;
int allow_skill_without_day; // [Komurka]
int allow_es_magic_pc; // [Skotlex]
int skill_wall_check; // [Skotlex]
- int cell_stack_limit; // [Skotlex]
+ int official_cell_stack_limit; // [Playtester]
+ int custom_cell_stack_limit; // [Skotlex]
int skill_caster_check; // [Skotlex]
int sc_castcancel; // [Skotlex]
int pc_sc_def_rate; // [Skotlex]
int mob_sc_def_rate;
int pc_max_sc_def;
int mob_max_sc_def;
-
+
int sg_angel_skill_ratio;
int sg_miracle_skill_ratio;
int sg_miracle_skill_duration;
@@ -396,9 +398,9 @@ struct Battle_Config {
int override_mob_names; //Enables overriding spawn mob names with the mob_db names. [Skotlex]
int min_chat_delay; //Minimum time between client messages. [Skotlex]
int friend_auto_add; //When accepting friends, both get friended. [Skotlex]
- int hvan_explosion_intimate; // fix [albator]
+ int hvan_explosion_intimate; // fix [albator]
int hom_rename;
- int homunculus_show_growth ; //[orn]
+ int homunculus_show_growth; //[orn]
int homunculus_friendly_rate;
int quest_exp_rate;
int autotrade_mapflag;
@@ -409,13 +411,13 @@ struct Battle_Config {
int ksprotection;
int auction_feeperhour;
int auction_maximumprice;
- int homunculus_auto_vapor; //Keep Homunculus from Vaporizing when master dies. [L0ne_W0lf]
- int display_status_timers; //Show or hide skill buff/delay timers in recent clients [Sara]
- int skill_add_heal_rate; //skills that bHealPower has effect on [Inkfish]
+ int homunculus_auto_vapor; //Keep Homunculus from Vaporizing when master dies. [L0ne_W0lf]
+ int display_status_timers; //Show or hide skill buff/delay timers in recent clients [Sara]
+ int skill_add_heal_rate; //skills that bHealPower has effect on [Inkfish]
int eq_single_target_reflectable;
int invincible_nodamage;
int mob_slave_keep_target;
- int autospell_check_range; //Enable range check for autospell bonus. [L0ne_W0lf]
+ int autospell_check_range; //Enable range check for autospell bonus. [L0ne_W0lf]
int knockback_left;
int client_reshuffle_dice; // Reshuffle /dice
int client_sort_storage;
@@ -430,11 +432,11 @@ struct Battle_Config {
int client_emblem_max_blank_percent;
int hom_max_level;
int hom_S_max_level;
-
+
// [BattleGround Settings]
int bg_update_interval;
int bg_flee_penalty;
-
+
// rAthena
int max_third_parameter;
int max_baby_third_parameter;
@@ -442,29 +444,33 @@ struct Battle_Config {
int atcommand_max_stat_bypass;
int max_third_aspd;
int vcast_stat_scale;
-
+
int mvp_tomb_enabled;
-
+
int atcommand_suggestions_enabled;
int min_npc_vendchat_distance;
int atcommand_mobinfo_type;
-
+
int mob_size_influence; // Enable modifications on earned experience, drop rates and monster status depending on monster size. [mkbu95]
int bowling_bash_area;
+ int mob_chase_refresh; //How often a monster should refresh its chase [Playtester]
+ int mob_icewall_walk_block; //How a normal monster should be trapped in icewall [Playtester]
+ int boss_icewall_walk_block; //How a boss monster should be trapped in icewall [Playtester]
/** Hercules **/
int skill_trap_type;
int item_restricted_consumption_type;
+ int unequip_restricted_equipment;
int max_walk_path;
int item_enabled_npc;
int packet_obfuscation;
int idletime_criteria;
int gm_ignore_warpable_area;
-
+
int client_accept_chatdori; // [Ai4rei/Mirei]
int snovice_call_type;
int guild_notice_changemap;
-
+
int feature_banking;
int feature_auction;
@@ -473,6 +479,12 @@ struct Battle_Config {
int case_sensitive_aegisnames;
int guild_castle_invite;
int guild_castle_expulsion;
+
+ int song_timer_reset; // [csnv]
+ int snap_dodge; // Enable or disable dodging damage snapping away [csnv]
+ int stormgust_knockback;
+
+ int feature_roulette;
};
extern struct Battle_Config battle_config;
diff --git a/src/map/battleground.c b/src/map/battleground.c
index f7131513d..190f7886d 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -157,11 +157,11 @@ int bg_team_leave(struct map_session_data *sd, enum bg_team_leave_type flag) {
if( bgd->logout_event[0] && flag )
npc->event(sd, bgd->logout_event, 0);
-
+
if( sd->bg_queue.arena ) {
bg->queue_pc_cleanup(sd);
}
-
+
return bgd->count;
}
@@ -267,11 +267,11 @@ int bg_send_xy_timer(int tid, int64 tick, int id, intptr_t data) {
enum bg_queue_types bg_str2teamtype (const char *str) {
char temp[200], *parse;
enum bg_queue_types type = BGQT_INVALID;
-
+
safestrncpy(temp, str, 200);
-
+
parse = strtok(temp,"|");
-
+
while (parse != NULL) {
normalize_name(parse," ");
if( strcmpi(parse,"all") == 0 )
@@ -287,7 +287,7 @@ enum bg_queue_types bg_str2teamtype (const char *str) {
}
parse = strtok(NULL,"|");
}
-
+
return type;
}
@@ -295,25 +295,24 @@ void bg_config_read(void) {
config_t bg_conf;
config_setting_t *data = NULL;
const char *config_filename = "conf/battlegrounds.conf"; // FIXME hardcoded name
-
+
if (libconfig->read_file(&bg_conf, config_filename))
return;
-
+
data = libconfig->lookup(&bg_conf, "battlegrounds");
-
+
if (data != NULL) {
config_setting_t *settings = libconfig->setting_get_elem(data, 0);
config_setting_t *arenas;
const char *delay_var;
int i, arena_count = 0, offline = 0;
-
+
if( !libconfig->setting_lookup_string(settings, "global_delay_var", &delay_var) )
delay_var = "BG_Delay_Tick";
-
+
safestrncpy(bg->gdelay_var, delay_var, BG_DELAY_VAR_LENGTH);
-
+
libconfig->setting_lookup_int(settings, "maximum_afk_seconds", &bg->mafksec);
-
libconfig->setting_lookup_bool(settings, "feature_off", &offline);
if( offline == 0 )
@@ -332,14 +331,14 @@ void bg_config_read(void) {
int maxDuration;
int fillup_duration = 0, pregame_duration = 0;
enum bg_queue_types allowedTypes;
-
+
bg->arena[i] = NULL;
-
+
if( !libconfig->setting_lookup_string(arena, "name", &aName) ) {
ShowError("bg_config_read: failed to find 'name' for arena #%d\n",i);
continue;
}
-
+
if( !libconfig->setting_lookup_string(arena, "event", &aEvent) ) {
ShowError("bg_config_read: failed to find 'event' for arena #%d\n",i);
continue;
@@ -347,7 +346,7 @@ void bg_config_read(void) {
libconfig->setting_lookup_int(arena, "minLevel", &minLevel);
libconfig->setting_lookup_int(arena, "maxLevel", &maxLevel);
-
+
if( minLevel < 0 ) {
ShowWarning("bg_config_read: invalid %d value for arena '%s' minLevel\n",minLevel,aName);
minLevel = 0;
@@ -356,16 +355,16 @@ void bg_config_read(void) {
ShowWarning("bg_config_read: invalid %d value for arena '%s' maxLevel\n",maxLevel,aName);
maxLevel = MAX_LEVEL;
}
-
+
if( !(reward = libconfig->setting_get_member(arena, "reward")) ) {
ShowError("bg_config_read: failed to find 'reward' for arena '%s'/#%d\n",aName,i);
continue;
}
-
+
libconfig->setting_lookup_int(reward, "win", &prizeWin);
libconfig->setting_lookup_int(reward, "loss", &prizeLoss);
libconfig->setting_lookup_int(reward, "draw", &prizeDraw);
-
+
if( prizeWin < 0 ) {
ShowWarning("bg_config_read: invalid %d value for arena '%s' reward:win\n",prizeWin,aName);
prizeWin = 0;
@@ -378,11 +377,11 @@ void bg_config_read(void) {
ShowWarning("bg_config_read: invalid %d value for arena '%s' reward:draw\n",prizeDraw,aName);
prizeDraw = 0;
}
-
+
libconfig->setting_lookup_int(arena, "minPlayers", &minPlayers);
libconfig->setting_lookup_int(arena, "maxPlayers", &maxPlayers);
libconfig->setting_lookup_int(arena, "minTeamPlayers", &minTeamPlayers);
-
+
if( minPlayers < 0 ) {
ShowWarning("bg_config_read: invalid %d value for arena '%s' minPlayers\n",minPlayers,aName);
minPlayers = 0;
@@ -400,20 +399,19 @@ void bg_config_read(void) {
ShowError("bg_config_read: failed to find 'delay_var' for arena '%s'/#%d\n",aName,i);
continue;
}
-
-
+
if( !libconfig->setting_lookup_string(arena, "allowedTypes", &aTeamTypes) ) {
ShowError("bg_config_read: failed to find 'allowedTypes' for arena '%s'/#%d\n",aName,i);
continue;
}
-
+
libconfig->setting_lookup_int(arena, "maxDuration", &maxDuration);
-
+
if( maxDuration < 0 ) {
ShowWarning("bg_config_read: invalid %d value for arena '%s' maxDuration\n",maxDuration,aName);
maxDuration = 30;
}
-
+
libconfig->setting_lookup_int(arena, "fillDuration", &fillup_duration);
libconfig->setting_lookup_int(arena, "pGameDuration", &pregame_duration);
@@ -428,9 +426,9 @@ void bg_config_read(void) {
}
allowedTypes = bg->str2teamtype(aTeamTypes);
-
+
CREATE( bg->arena[i], struct bg_arena, 1 );
-
+
bg->arena[i]->id = i;
safestrncpy(bg->arena[i]->name, aName, NAME_LENGTH);
safestrncpy(bg->arena[i]->npc_event, aEvent, EVENT_NAME_LENGTH);
@@ -455,7 +453,6 @@ void bg_config_read(void) {
}
bg->arenas = arena_count;
}
-
libconfig->destroy(&bg_conf);
}
}
@@ -493,7 +490,7 @@ void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bo
struct hQueue *queue = &script->hq[arena->queue_id];
int i, count = 0;
sd->bg_queue.ready = 1;
-
+
for( i = 0; i < queue->size; i++ ) {
if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) {
if( sd->bg_queue.ready == 1 )
@@ -506,10 +503,9 @@ void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bo
arena->begin_timer = INVALID_TIMER;
bg->begin(arena);
}
-
}
-
}
+
void bg_queue_player_cleanup(struct map_session_data *sd) {
if ( sd->bg_queue.client_has_bg_data ) {
if( sd->bg_queue.arena )
@@ -527,14 +523,14 @@ void bg_queue_player_cleanup(struct map_session_data *sd) {
void bg_match_over(struct bg_arena *arena, bool canceled) {
struct hQueue *queue = &script->hq[arena->queue_id];
int i;
-
+
if( !arena->ongoing )
return;
arena->ongoing = false;
for( i = 0; i < queue->size; i++ ) {
struct map_session_data * sd = NULL;
-
+
if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) {
if( sd->bg_queue.arena ) {
bg->team_leave(sd, 0);
@@ -559,7 +555,7 @@ void bg_begin(struct bg_arena *arena) {
for( i = 0; i < queue->size; i++ ) {
struct map_session_data * sd = NULL;
-
+
if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) {
if( sd->bg_queue.ready == 1 )
count++;
@@ -575,23 +571,21 @@ void bg_begin(struct bg_arena *arena) {
bg->match_over(arena,true);
} else {
arena->ongoing = true;
-
+
if( bg->afk_timer_id == INVALID_TIMER && bg->mafksec > 0 )
bg->afk_timer_id = timer->add(timer->gettick()+10000,bg->afk_timer,0,0);
-
+
/* TODO: make this a arena-independent var? or just .@? */
mapreg->setreg(script->add_str("$@bg_queue_id"),arena->queue_id);
mapreg->setregstr(script->add_str("$@bg_delay_var$"),bg->gdelay_var);
-
+
count = 0;
for( i = 0; i < queue->size; i++ ) {
struct map_session_data * sd = NULL;
-
+
if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) {
if( sd->bg_queue.ready == 1 ) {
-
mapreg->setreg(reference_uid(script->add_str("$@bg_member"), count), sd->status.account_id);
-
mapreg->setreg(reference_uid(script->add_str("$@bg_member_group"), count),
sd->bg_queue.type == BGQT_GUILD ? sd->status.guild_id :
sd->bg_queue.type == BGQT_PARTY ? sd->status.party_id :
@@ -607,7 +601,7 @@ void bg_begin(struct bg_arena *arena) {
}
}
mapreg->setreg(script->add_str("$@bg_member_size"),count);
-
+
npc->event_do(arena->npc_event);
}
}
@@ -631,7 +625,7 @@ int bg_afk_timer(int tid, int64 tick, int id, intptr_t data) {
count++;
}
mapit->free(iter);
-
+
if( count )
bg->afk_timer_id = timer->add(timer->gettick()+10000,bg->afk_timer,0,0);
else
@@ -642,10 +636,10 @@ int bg_afk_timer(int tid, int64 tick, int id, intptr_t data) {
void bg_queue_pregame(struct bg_arena *arena) {
struct hQueue *queue = &script->hq[arena->queue_id];
int i;
-
+
for( i = 0; i < queue->size; i++ ) {
struct map_session_data * sd = NULL;
-
+
if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) {
clif->bgqueue_battlebegins(sd,arena->id,SELF);
}
@@ -674,17 +668,17 @@ void bg_queue_add(struct map_session_data *sd, struct bg_arena *arena, enum bg_q
enum BATTLEGROUNDS_QUEUE_ACK result = bg->can_queue(sd,arena,type);
struct hQueue *queue;
int i, count = 0;
-
+
if( arena->begin_timer != INVALID_TIMER || arena->ongoing ) {
clif->bgqueue_ack(sd,BGQA_FAIL_QUEUING_FINISHED,arena->id);
return;
}
-
+
if( result != BGQA_SUCCESS ) {
clif->bgqueue_ack(sd,result,arena->id);
return;
}
-
+
switch( type ) { /* guild/party already validated in can_queue */
case BGQT_PARTY: {
struct party_data *p = party->search(sd->status.party_id);
@@ -705,7 +699,7 @@ void bg_queue_add(struct map_session_data *sd, struct bg_arena *arena, enum bg_q
count = 1;
break;
}
-
+
if( !(queue = script->queue(arena->queue_id)) || (queue->items+count) > arena->max_players ) {
clif->bgqueue_ack(sd,BGQA_FAIL_PPL_OVERAMOUNT,arena->id);
return;
@@ -746,26 +740,24 @@ void bg_queue_add(struct map_session_data *sd, struct bg_arena *arena, enum bg_q
}
break;
}
-
clif->bgqueue_ack(sd,BGQA_SUCCESS,arena->id);
-
bg->queue_check(arena);
}
enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type) {
int tick;
unsigned int tsec;
-
+
if( !(arena->allowed_types & type) )
return BGQA_FAIL_TYPE_INVALID;
-
+
if ( sd->status.base_level > arena->max_level || sd->status.base_level < arena->min_level )
return BGQA_FAIL_LEVEL_INCORRECT;
-
+
if ( !(sd->class_&JOBL_2) ) /* TODO: maybe make this a per-arena setting, so users may make custom arenas like baby-only,whatever. */
return BGQA_FAIL_CLASS_INVALID;
-
+
tsec = (unsigned int)time(NULL);
-
+
if ( ( tick = pc_readglobalreg(sd, script->add_str(bg->gdelay_var)) ) && tsec < tick ) {
char response[100];
if( (tick-tsec) > 60 )
@@ -775,7 +767,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
clif->colormes(sd->fd,COLOR_RED,response);
return BGQA_FAIL_DESERTER;
}
-
+
if ( ( tick = pc_readglobalreg(sd, script->add_str(arena->delay_var)) ) && tsec < tick ) {
char response[100];
if( (tick-tsec) > 60 )
@@ -788,7 +780,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
if( sd->bg_queue.arena != NULL )
return BGQA_DUPLICATE_REQUEST;
-
+
switch(type) {
case BGQT_GUILD:
if( !sd->guild || !sd->state.gmaster_flag )
@@ -831,7 +823,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
if( !is_leader )
return BGQA_NOT_PARTY_GUILD_LEADER;
-
+
if( count < arena->min_team_players ) {
char response[100];
if( count != p->party.count && p->party.count >= arena->min_team_players )
@@ -841,7 +833,6 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
clif->colormes(sd->fd,COLOR_RED,response);
return BGQA_FAIL_TEAM_COUNT;
}
-
} else
return BGQA_NOT_PARTY_GUILD_LEADER;
}
@@ -852,7 +843,6 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
ShowDebug("bg_canqueue: unknown/unsupported type %d\n",type);
return BGQA_DUPLICATE_REQUEST;
}
-
return BGQA_SUCCESS;
}
void do_init_battleground(bool minimal) {
@@ -867,22 +857,22 @@ void do_init_battleground(bool minimal) {
void do_final_battleground(void) {
int i;
-
+
db_destroy(bg->team_db);
-
+
for( i = 0; i < bg->arenas; i++ ) {
if( bg->arena[i] )
aFree(bg->arena[i]);
}
-
+
if( bg->arena )
aFree(bg->arena);
}
void battleground_defaults(void) {
bg = &bg_s;
-
+
bg->queue_on = false;
-
+
bg->mafksec = 0;
bg->afk_timer_id = INVALID_TIMER;
bg->arena = NULL;
diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c
index 626d102a3..8efffa342 100644
--- a/src/map/buyingstore.c
+++ b/src/map/buyingstore.c
@@ -169,7 +169,7 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha
// success
sd->state.buyingstore = true;
- sd->buyer_id = buyingstore_getuid();
+ sd->buyer_id = buyingstore->getuid();
sd->buyingstore.zenylimit = zenylimit;
sd->buyingstore.slots = i; // store actual amount of items
safestrncpy(sd->message, storename, sizeof(sd->message));
@@ -294,8 +294,11 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
return;
}
- if( sd->status.inventory[index].expire_time || (sd->status.inventory[index].bound && !pc_can_give_bound_items(sd)) || !itemdb_cantrade(&sd->status.inventory[index], pc_get_group_level(sd), pc_get_group_level(pl_sd)) || memcmp(sd->status.inventory[index].card, buyingstore->blankslots, sizeof(buyingstore->blankslots)) )
- {// non-tradable item
+ if (sd->status.inventory[index].expire_time || (sd->status.inventory[index].bound && !pc_can_give_bound_items(sd))
+ || !itemdb_cantrade(&sd->status.inventory[index], pc_get_group_level(sd), pc_get_group_level(pl_sd))
+ || memcmp(sd->status.inventory[index].card, buyingstore->blankslots, sizeof(buyingstore->blankslots))
+ ) {
+ // non-tradable item
clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid);
return;
}
@@ -367,7 +370,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
chrif->save(sd, 0);
chrif->save(pl_sd, 0);
}
-
+
// check whether or not there is still something to buy
ARR_FIND( 0, pl_sd->buyingstore.slots, i, pl_sd->buyingstore.items[i].amount != 0 );
if( i == pl_sd->buyingstore.slots )
@@ -384,7 +387,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
}
// cannot continue buying
- buyingstore_close(pl_sd);
+ buyingstore->close(pl_sd);
// remove auto-trader
if( pl_sd->state.autotrade ) {
@@ -459,7 +462,7 @@ bool buyingstore_searchall(struct map_session_data* sd, const struct s_search_st
}
void buyingstore_defaults(void) {
buyingstore = &buyingstore_s;
-
+
buyingstore->nextid = 0;
memset(buyingstore->blankslots,0,sizeof(buyingstore->blankslots));
/* */
diff --git a/src/map/chat.c b/src/map/chat.c
index cd7b5f811..9c67e0f44 100644
--- a/src/map/chat.c
+++ b/src/map/chat.c
@@ -61,10 +61,10 @@ struct chat_data* chat_createchat(struct block_list* bl, const char* title, cons
}
map->addiddb(&cd->bl);
-
+
if( bl->type != BL_NPC )
cd->kick_list = idb_alloc(DB_OPT_BASE);
-
+
return cd;
}
@@ -156,20 +156,20 @@ bool chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) {
pc_setchatid(sd,cd->bl.id);
- clif->joinchatok(sd, cd); //To the person who newly joined the list of all
- clif->addchat(cd, sd); //Reports To the person who already in the chat
- clif->dispchat(cd, 0); //Reported number of changes to the people around
+ clif->joinchatok(sd, cd); //To the person who newly joined the list of all
+ clif->addchat(cd, sd); //Reports To the person who already in the chat
+ clif->dispchat(cd, 0); //Reported number of changes to the people around
- chat->trigger_event(cd); //Event
+ chat->trigger_event(cd); //Event
- return true;
+ return true;
}
/*==========================================
* Leave a chatroom
* Return
- * 0: User not found in chatroom/Missing data
+ * 0: User not found in chatroom/Missing data
* 1: Success
* 2: Chat room deleted (chat room empty)
* 3: Owner changed (Owner left and a new one as assigned)
@@ -188,8 +188,8 @@ int chat_leavechat(struct map_session_data* sd, bool kicked) {
}
ARR_FIND( 0, cd->users, i, cd->usersd[i] == sd );
- if ( i == cd->users )
- { // Not found in the chatroom?
+ if (i == cd->users) {
+ // Not found in the chatroom?
pc_setchatid(sd, 0);
return 0;
}
@@ -213,7 +213,7 @@ int chat_leavechat(struct map_session_data* sd, bool kicked) {
map->deliddb(&cd->bl);
map->delblock(&cd->bl);
map->freeblock(&cd->bl);
-
+
su = map->find_skill_unit_oncell(&sd->bl, sd->bl.x, sd->bl.y, AL_WARP, NULL, 0);
group = (su != NULL) ? su->group : NULL;
if (group != NULL)
@@ -326,7 +326,7 @@ bool chat_kickchat(struct map_session_data* sd, const char* kickusername) {
nullpo_ret(sd);
cd = (struct chat_data *)map->id2bl(sd->chatID);
-
+
if( cd==NULL || (struct block_list *)sd != cd->owner )
return false;
@@ -336,7 +336,7 @@ bool chat_kickchat(struct map_session_data* sd, const char* kickusername) {
if (pc_has_permission(cd->usersd[i], PC_PERM_NO_CHAT_KICK))
return false; //gm kick protection [Valaris]
-
+
idb_iput(cd->kick_list,cd->usersd[i]->status.char_id,1);
chat->leave(cd->usersd[i],1);
@@ -385,14 +385,14 @@ bool chat_deletenpcchat(struct npc_data* nd) {
cd = (struct chat_data*)map->id2bl(nd->chat_id);
if( cd == NULL )
return false;
-
+
chat->npc_kick_all(cd);
clif->clearchat(cd, 0);
map->deliddb(&cd->bl);
map->delblock(&cd->bl);
map->freeblock(&cd->bl);
nd->chat_id = 0;
-
+
return true;
}
@@ -452,7 +452,7 @@ bool chat_npckickall(struct chat_data* cd)
*-------------------------------------*/
void chat_defaults(void) {
chat = &chat_s;
-
+
/* funcs */
chat->create_pc_chat = chat_createpcchat;
chat->join = chat_joinchat;
diff --git a/src/map/chat.h b/src/map/chat.h
index e055c04ed..6fca018f4 100644
--- a/src/map/chat.h
+++ b/src/map/chat.h
@@ -16,21 +16,21 @@ struct npc_data;
#define MAX_CHAT_USERS 20
struct chat_data {
- struct block_list bl; // data for this map object
- char title[CHATROOM_TITLE_SIZE]; // room title
- char pass[CHATROOM_PASS_SIZE]; // password
- bool pub; // private/public flag
- uint8 users; // current user count
- uint8 limit; // join limit
- uint8 trigger; // number of users needed to trigger event
- uint32 zeny; // required zeny to join
- uint32 minLvl; // minimum base level to join
- uint32 maxLvl; // maximum base level allowed to join
+ struct block_list bl; ///< data for this map object
+ char title[CHATROOM_TITLE_SIZE]; ///< room title
+ char pass[CHATROOM_PASS_SIZE]; ///< password
+ bool pub; ///< private/public flag
+ uint8 users; ///< current user count
+ uint8 limit; ///< join limit
+ uint8 trigger; ///< number of users needed to trigger event
+ uint32 zeny; ///< required zeny to join
+ uint32 minLvl; ///< minimum base level to join
+ uint32 maxLvl; ///< maximum base level allowed to join
struct map_session_data* usersd[MAX_CHAT_USERS];
struct block_list* owner;
char npc_event[EVENT_NAME_LENGTH];
/* isn't this a waste? there is a enormous overhead, wouldn't something like skill_blockpc_start be better here? [Ind] */
- DBMap* kick_list; //DBMap of users who were kicked from this chat
+ DBMap* kick_list; ///< DBMap of users who were kicked from this chat
};
/*=====================================
@@ -39,7 +39,6 @@ struct chat_data {
* created by Susu
*-------------------------------------*/
struct chat_interface {
-
/* funcs */
bool (*create_pc_chat) (struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub);
bool (*join) (struct map_session_data* sd, int chatid, const char* pass);
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 4c8cd747b..a5003ab95 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -116,7 +116,6 @@ struct auth_node* chrif_search(int account_id) {
struct auth_node* chrif_auth_check(int account_id, int char_id, enum sd_state state) {
struct auth_node *node = chrif->search(account_id);
-
return ( node && node->char_id == char_id && node->state == state ) ? node : NULL;
}
@@ -125,24 +124,23 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) {
if ( (node = chrif->auth_check(account_id, char_id, state) ) ) {
int fd = node->sd ? node->sd->fd : node->fd;
-
+
if ( session[fd] && session[fd]->session_data == node->sd )
session[fd]->session_data = NULL;
-
+
if ( node->sd ) {
-
if( node->sd->regs.vars )
node->sd->regs.vars->destroy(node->sd->regs.vars, script->reg_destroy);
-
+
if( node->sd->regs.arrays )
node->sd->regs.arrays->destroy(node->sd->regs.arrays, script->array_free_db);
-
+
aFree(node->sd);
}
-
+
ers_free(chrif->auth_db_ers, node);
idb_remove(chrif->auth_db,account_id);
-
+
return true;
}
return false;
@@ -151,52 +149,52 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) {
//Moves the sd character to the auth_db structure.
bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) {
struct auth_node *node;
-
+
if ( chrif->search(sd->status.account_id) )
return false; //Already exists?
node = ers_alloc(chrif->auth_db_ers, struct auth_node);
-
+
memset(node, 0, sizeof(struct auth_node));
-
+
node->account_id = sd->status.account_id;
node->char_id = sd->status.char_id;
node->login_id1 = sd->login_id1;
node->login_id2 = sd->login_id2;
node->sex = sd->status.sex;
node->fd = sd->fd;
- node->sd = sd; //Data from logged on char.
+ node->sd = sd; //Data from logged on char.
node->node_created = timer->gettick(); //timestamp for node timeouts
node->state = state;
sd->state.active = 0;
-
+
idb_put(chrif->auth_db, node->account_id, node);
-
+
return true;
}
-bool chrif_auth_logout(TBL_PC* sd, enum sd_state state) {
-
+bool chrif_auth_logout(TBL_PC* sd, enum sd_state state)
+{
if(sd->fd && state == ST_LOGOUT) { //Disassociate player, and free it after saving ack returns. [Skotlex]
//fd info must not be lost for ST_MAPCHANGE as a final packet needs to be sent to the player.
if ( session[sd->fd] )
session[sd->fd]->session_data = NULL;
sd->fd = 0;
}
-
+
return chrif->sd_to_auth(sd, state);
}
bool chrif_auth_finished(TBL_PC* sd) {
struct auth_node *node= chrif->search(sd->status.account_id);
-
+
if ( node && node->sd == sd && node->state == ST_LOGIN ) {
node->sd = NULL;
-
+
return chrif->auth_delete(node->account_id, node->char_id, ST_LOGIN);
}
-
+
return false;
}
// sets char-server's user id
@@ -221,16 +219,16 @@ void chrif_checkdefaultlogin(void) {
// sets char-server's ip address
bool chrif_setip(const char* ip) {
char ip_str[16];
-
+
if ( !( chrif->ip = host2ip(ip) ) ) {
ShowWarning("Failed to Resolve Char Server Address! (%s)\n", ip);
return false;
}
-
+
safestrncpy(chrif->ip_str, ip, sizeof(chrif->ip_str));
-
+
ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(chrif->ip, ip_str));
-
+
return true;
}
@@ -314,9 +312,9 @@ void chrif_connect(int fd) {
// sends maps to char-server
void chrif_sendmap(int fd) {
int i;
-
+
ShowStatus("Sending maps to char server...\n");
-
+
// Sending normal maps, not instances
WFIFOHEAD(fd, 4 + instance->start_id * 4);
WFIFOW(fd,0) = 0x2afa;
@@ -335,7 +333,7 @@ void chrif_recvmap(int fd) {
for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) {
map->setipport(RFIFOW(fd,i), ip, port);
}
-
+
if (battle_config.etc_log)
ShowStatus("Received maps from %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j);
@@ -352,7 +350,7 @@ void chrif_removemap(int fd) {
map->eraseipport(RFIFOW(fd, i), ip, port);
chrif->other_mapserver_count--;
-
+
if(battle_config.etc_log)
ShowStatus("remove map of server %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j);
}
@@ -389,7 +387,7 @@ bool chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port)
WFIFOL(chrif->fd,31) = htonl(session[sd->fd]->client_addr);
WFIFOL(chrif->fd,35) = sd->group_id;
WFIFOSET(chrif->fd,39);
-
+
return true;
}
@@ -397,7 +395,7 @@ bool chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port)
/// R 2b06 <account_id>.L <login_id1>.L <login_id2>.L <char_id>.L <map_index>.W <x>.W <y>.W <ip>.L <port>.W
bool chrif_changemapserverack(int account_id, int login_id1, int login_id2, int char_id, short map_index, short x, short y, uint32 ip, uint16 port) {
struct auth_node *node;
-
+
if ( !( node = chrif->auth_check(account_id, char_id, ST_MAPCHANGE) ) )
return false;
@@ -436,7 +434,7 @@ void chrif_connectack(int fd) {
ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc->event_doall("OnInterIfInitOnce"));
guild->castle_map_init();
}
-
+
sockt->datasync(fd, true);
chrif->skillid2idx(fd);
}
@@ -446,7 +444,7 @@ void chrif_connectack(int fd) {
*/
int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = DB->data2ptr(data);
-
+
switch (node->state) {
case ST_LOGIN:
if ( node->sd ) {//Since there is no way to request the char auth, make it fail.
@@ -463,7 +461,7 @@ int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
struct map_session_data *sd = node->sd;
uint32 ip;
uint16 port;
-
+
if( map->mapname2ipport(sd->mapindex,&ip,&port) == 0 )
chrif->changemapserver(sd, ip, port);
else //too much lag/timeout is the closest explanation for this error.
@@ -471,7 +469,6 @@ int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
break;
}
}
-
return 0;
}
@@ -480,9 +477,9 @@ int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
void chrif_on_ready(void) {
static bool once = false;
ShowStatus("Map Server is now online.\n");
-
+
chrif->state = 2;
-
+
chrif->check_shutdown();
//If there are players online, send them to the char-server. [Skotlex]
@@ -496,7 +493,7 @@ void chrif_on_ready(void) {
//Re-save any guild castles that were modified in the disconnection time.
guild->castle_reconnect(-1, 0, 0);
-
+
if( !once ) {
#ifdef AUTOTRADE_PERSISTENCY
pc->autotrade_load();
@@ -509,23 +506,23 @@ void chrif_on_ready(void) {
/*==========================================
*
*------------------------------------------*/
-void chrif_sendmapack(int fd) {
-
+void chrif_sendmapack(int fd)
+{
if (RFIFOB(fd,2)) {
ShowFatalError("chrif : send map list to char server failed %d\n", RFIFOB(fd,2));
exit(EXIT_FAILURE);
}
memcpy(map->wisp_server_name, RFIFOP(fd,3), NAME_LENGTH);
-
+
chrif->on_ready();
}
/*==========================================
* Request sc_data from charserver [Skotlex]
*------------------------------------------*/
-bool chrif_scdata_request(int account_id, int char_id) {
-
+bool chrif_scdata_request(int account_id, int char_id)
+{
#ifdef ENABLE_SC_SAVING
chrif_check(false);
@@ -535,7 +532,6 @@ bool chrif_scdata_request(int account_id, int char_id) {
WFIFOL(chrif->fd,6) = char_id;
WFIFOSET(chrif->fd,10);
#endif
-
return true;
}
@@ -544,7 +540,7 @@ bool chrif_scdata_request(int account_id, int char_id) {
*------------------------------------------*/
void chrif_authreq(struct map_session_data *sd, bool hstandalone) {
struct auth_node *node= chrif->search(sd->bl.id);
-
+
if( node != NULL || !chrif->isconnected() ) {
set_eof(sd->fd);
return;
@@ -621,7 +617,7 @@ void chrif_authok(int fd) {
} else { //Auth Failed
pc->authfail(sd);
}
-
+
chrif_char_offline(sd); //Set him offline, the char server likely has it set as online already.
chrif->auth_delete(account_id, char_id, ST_LOGIN);
}
@@ -639,7 +635,7 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (
sex = RFIFOB(fd,14);
node = chrif->search(account_id);
-
+
if( node != NULL &&
node->account_id == account_id &&
node->char_id == char_id &&
@@ -660,7 +656,7 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (
int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = DB->data2ptr(data);
const char* states[] = { "Login", "Logout", "Map change" };
-
+
if(DIFF_TICK(timer->gettick(),node->node_created)>60000) {
switch (node->state) {
case ST_LOGOUT:
@@ -694,7 +690,7 @@ bool chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) {
if( !sd->bl.id || !sd->login_id1 )
return false;
-
+
chrif_check(false);
WFIFOHEAD(chrif->fd,22);
@@ -713,10 +709,10 @@ bool chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) {
* Search Char trough id on char serv
*------------------------------------------*/
bool chrif_searchcharid(int char_id) {
-
+
if( !char_id )
return false;
-
+
chrif_check(false);
WFIFOHEAD(chrif->fd,6);
@@ -731,7 +727,7 @@ bool chrif_searchcharid(int char_id) {
* Change Email
*------------------------------------------*/
bool chrif_changeemail(int id, const char *actual_email, const char *new_email) {
-
+
if (battle_config.etc_log)
ShowInfo("chrif_changeemail: account: %d, actual_email: '%s', new_email: '%s'.\n", id, actual_email, new_email);
@@ -753,8 +749,8 @@ bool chrif_changeemail(int id, const char *actual_email, const char *new_email)
* type of operation:
* 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex (use next function for 5), 6: charban
*------------------------------------------*/
-bool chrif_char_ask_name(int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second) {
-
+bool chrif_char_ask_name(int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second)
+{
chrif_check(false);
WFIFOHEAD(chrif->fd,44);
@@ -762,7 +758,7 @@ bool chrif_char_ask_name(int acc, const char* character_name, unsigned short ope
WFIFOL(chrif->fd,2) = acc;
safestrncpy((char*)WFIFOP(chrif->fd,6), character_name, NAME_LENGTH);
WFIFOW(chrif->fd,30) = operation_type;
-
+
if ( operation_type == 2 || operation_type == 6 ) {
WFIFOW(chrif->fd,32) = year;
WFIFOW(chrif->fd,34) = month;
@@ -771,14 +767,14 @@ bool chrif_char_ask_name(int acc, const char* character_name, unsigned short ope
WFIFOW(chrif->fd,40) = minute;
WFIFOW(chrif->fd,42) = second;
}
-
+
WFIFOSET(chrif->fd,44);
return true;
}
bool chrif_changesex(struct map_session_data *sd) {
chrif_check(false);
-
+
WFIFOHEAD(chrif->fd,44);
WFIFOW(chrif->fd,0) = 0x2b0e;
WFIFOL(chrif->fd,2) = sd->status.account_id;
@@ -811,9 +807,9 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u
char action[25];
char output[256];
bool charsrv = ( type == 6 || type == 7 ) ? true : false;
-
+
sd = map->id2sd(acc);
-
+
if( acc < 0 || sd == NULL ) {
ShowError("chrif_char_ask_name_answer failed - player not online.\n");
return false;
@@ -822,7 +818,7 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u
/* re-use previous msg_txt */
if( type == 6 ) type = 2;
if( type == 7 ) type = 4;
-
+
if( type > 0 && type <= 5 )
snprintf(action,25,"%s",msg_txt(427+type)); //block|ban|unblock|unban|change the sex of
else
@@ -835,7 +831,7 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u
case 3 : sprintf(output, msg_txt(427), action, NAME_LENGTH, player_name); break;
default: output[0] = '\0'; break;
}
-
+
clif->message(sd->fd, output);
return true;
}
@@ -846,7 +842,7 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u
void chrif_changedsex(int fd) {
int acc = RFIFOL(fd,2);
//int sex = RFIFOL(fd,6); // Dead store. Uncomment if needed again.
-
+
if ( battle_config.etc_log )
ShowNotice("chrif_changedsex %d.\n", acc);
@@ -896,7 +892,7 @@ bool chrif_divorceack(int char_id, int partner_id) {
if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
}
-
+
return true;
}
/*==========================================
@@ -932,10 +928,10 @@ void chrif_idbanned(int fd) {
struct map_session_data *sd;
id = RFIFOL(fd,2);
-
+
if ( battle_config.etc_log )
ShowNotice("chrif_idbanned %d.\n", id);
-
+
sd = ( RFIFOB(fd,6) == 2 ) ? map->charid2sd(id) : map->id2sd(id);
if ( id < 0 || sd == NULL ) {
@@ -981,10 +977,10 @@ int chrif_disconnectplayer(int fd) {
sd = map->id2sd(account_id);
if( sd == NULL ) {
struct auth_node* auth = chrif->search(account_id);
-
+
if( auth != NULL && chrif->auth_delete(account_id, auth->char_id, ST_LOGIN) )
return 0;
-
+
return -1;
}
@@ -1011,7 +1007,7 @@ int chrif_disconnectplayer(int fd) {
*------------------------------------------*/
int chrif_updatefamelist(struct map_session_data* sd) {
char type;
-
+
chrif_check(-1);
switch(sd->class_ & MAPID_UPPERMASK) {
@@ -1051,30 +1047,24 @@ void chrif_recvfamelist(int fd) {
memset(pc->taekwon_fame_list, 0, sizeof(pc->taekwon_fame_list));
size = RFIFOW(fd, 6); //Blacksmith block size
-
for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
memcpy(&pc->smith_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
- len += sizeof(struct fame_list);
+ len += sizeof(struct fame_list);
}
-
total += num;
size = RFIFOW(fd, 4); //Alchemist block size
-
for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
memcpy(&pc->chemist_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
- len += sizeof(struct fame_list);
+ len += sizeof(struct fame_list);
}
-
total += num;
size = RFIFOW(fd, 2); //Total packet length
-
for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
memcpy(&pc->taekwon_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
- len += sizeof(struct fame_list);
+ len += sizeof(struct fame_list);
}
-
total += num;
ShowInfo("Received Fame List of '"CL_WHITE"%d"CL_RESET"' characters.\n", total);
@@ -1085,21 +1075,20 @@ void chrif_recvfamelist(int fd) {
int chrif_updatefamelist_ack(int fd) {
struct fame_list* list;
uint8 index;
-
+
switch (RFIFOB(fd,2)) {
case RANKTYPE_BLACKSMITH: list = pc->smith_fame_list; break;
case RANKTYPE_ALCHEMIST: list = pc->chemist_fame_list; break;
case RANKTYPE_TAEKWON: list = pc->taekwon_fame_list; break;
default: return 0;
}
-
+
index = RFIFOB(fd, 3);
-
if (index >= MAX_FAME_LIST)
return 0;
-
+
list[index].fame = RFIFOL(fd,4);
-
+
return 1;
}
@@ -1114,20 +1103,23 @@ bool chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of th
chrif_check(false);
tick = timer->gettick();
-
+
WFIFOHEAD(chrif->fd, 14 + SC_MAX*sizeof(struct status_change_data));
WFIFOW(chrif->fd,0) = 0x2b1c;
WFIFOL(chrif->fd,4) = sd->status.account_id;
WFIFOL(chrif->fd,8) = sd->status.char_id;
-
+
for (i = 0; i < SC_MAX; i++) {
if (!sc->data[i])
continue;
if (sc->data[i]->timer != INVALID_TIMER) {
td = timer->get(sc->data[i]->timer);
- if (td == NULL || td->func != status->change_timer || DIFF_TICK(td->tick,tick) < 0)
+ if (td == NULL || td->func != status->change_timer)
continue;
- data.tick = DIFF_TICK32(td->tick,tick); //Duration that is left before ending.
+ if (DIFF_TICK32(td->tick,tick) > 0)
+ data.tick = DIFF_TICK32(td->tick,tick); //Duration that is left before ending.
+ else
+ data.tick = 0; //Negative tick does not necessarily mean that sc has expired
} else
data.tick = -1; //Infinite duration
data.type = i;
@@ -1139,15 +1131,15 @@ bool chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of th
&data, sizeof(struct status_change_data));
count++;
}
-
+
if (count == 0)
return true; //Nothing to save. | Everything was as successful as if there was something to save.
-
+
WFIFOW(chrif->fd,12) = count;
WFIFOW(chrif->fd,2) = 14 +count*sizeof(struct status_change_data); //Total packet size
WFIFOSET(chrif->fd,WFIFOW(chrif->fd,2));
#endif
-
+
return true;
}
@@ -1161,29 +1153,29 @@ bool chrif_load_scdata(int fd) {
aid = RFIFOL(fd,4); //Player Account ID
cid = RFIFOL(fd,8); //Player Char ID
-
+
sd = map->id2sd(aid);
-
+
if ( !sd ) {
ShowError("chrif_load_scdata: Player of AID %d not found!\n", aid);
return false;
}
-
+
if ( sd->status.char_id != cid ) {
ShowError("chrif_load_scdata: Receiving data for account %d, char id does not matches (%d != %d)!\n", aid, sd->status.char_id, cid);
return false;
}
-
+
count = RFIFOW(fd,12); //sc_count
-
+
for (i = 0; i < count; i++) {
data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data));
- status->change_start(NULL, &sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15);
+ status->change_start(NULL, &sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4,
+ data->tick, SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_LOADED|SCFLAG_FIXEDRATE);
}
-
+
pc->scdata_received(sd);
#endif
-
return true;
}
@@ -1200,7 +1192,6 @@ bool chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) {
WFIFOL(chrif->fd,6) = job_rate;
WFIFOL(chrif->fd,10) = drop_rate;
WFIFOSET(chrif->fd,14);
-
return true;
}
@@ -1266,7 +1257,7 @@ void chrif_on_disconnect(void) {
if( chrif->connected != 1 )
ShowWarning("Connection to Char Server lost.\n\n");
chrif->connected = 0;
-
+
chrif->other_mapserver_count = 0; //Reset counter. We receive ALL maps from all map-servers on reconnect.
map->eraseallipport();
@@ -1277,19 +1268,19 @@ void chrif_on_disconnect(void) {
void chrif_update_ip(int fd) {
uint32 new_ip;
-
+
WFIFOHEAD(fd,6);
-
+
new_ip = host2ip(chrif->ip_str);
-
+
if (new_ip && new_ip != chrif->ip)
chrif->ip = new_ip; //Update chrif->ip
new_ip = clif->refresh_ip();
-
+
if (!new_ip)
return; //No change
-
+
WFIFOW(fd,0) = 0x2736;
WFIFOL(fd,2) = htonl(new_ip);
WFIFOSET(fd,6);
@@ -1306,12 +1297,12 @@ void chrif_keepalive_ack(int fd) {
}
void chrif_skillid2idx(int fd) {
int i, count = 0;
-
+
if( fd == 0 ) fd = chrif->fd;
-
+
if( !session_isValid(fd) )
return;
-
+
WFIFOHEAD(fd,4 + (MAX_SKILL * 4));
WFIFOW(fd,0) = 0x2b0b;
for(i = 0; i < MAX_SKILL; i++) {
@@ -1363,12 +1354,12 @@ int chrif_parse(int fd) {
}
cmd = RFIFOW(fd,0);
-
+
if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(chrif->packet_len_table) || chrif->packet_len_table[cmd-0x2af8] == 0) {
r = intif->parse(fd); // Passed on to the intif
- if (r == 1) continue; // Treated in intif
- if (r == 2) return 0; // Didn't have enough data (len==-1)
+ if (r == 1) continue; // Treated in intif
+ if (r == 2) return 0; // Didn't have enough data (len==-1)
ShowWarning("chrif_parse: session #%d, intif->parse failed (unrecognized command 0x%.4x).\n", fd, cmd);
set_eof(fd);
@@ -1444,20 +1435,18 @@ bool send_users_tochar(void) {
chrif_check(false);
users = map->usercount();
-
+
WFIFOHEAD(chrif->fd, 6+8*users);
WFIFOW(chrif->fd,0) = 0x2aff;
-
+
iter = mapit_getallusers();
-
for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) {
WFIFOL(chrif->fd,6+8*i) = sd->status.account_id;
WFIFOL(chrif->fd,6+8*i+4) = sd->status.char_id;
i++;
}
-
mapit->free(iter);
-
+
WFIFOW(chrif->fd,2) = 6 + 8*users;
WFIFOW(chrif->fd,4) = users;
WFIFOSET(chrif->fd, 6+8*users);
@@ -1467,7 +1456,7 @@ bool send_users_tochar(void) {
/*==========================================
* timerFunction
- * Check the connection to char server, (if it down)
+ * Check the connection to char server, (if it down)
*------------------------------------------*/
int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) {
static int displayed = 0;
@@ -1478,7 +1467,7 @@ int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) {
}
chrif->state = 0;
-
+
if ( ( chrif->fd = make_connection(chrif->ip, chrif->port,NULL) ) == -1) //Attempt to connect later. [Skotlex]
return 0;
@@ -1503,8 +1492,8 @@ int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) {
/*==========================================
* Asks char server to remove friend_id from the friend list of char_id
*------------------------------------------*/
-bool chrif_removefriend(int char_id, int friend_id) {
-
+bool chrif_removefriend(int char_id, int friend_id)
+{
chrif_check(false);
WFIFOHEAD(chrif->fd,10);
@@ -1512,7 +1501,6 @@ bool chrif_removefriend(int char_id, int friend_id) {
WFIFOL(chrif->fd,2) = char_id;
WFIFOL(chrif->fd,6) = friend_id;
WFIFOSET(chrif->fd,10);
-
return true;
}
@@ -1520,13 +1508,12 @@ void chrif_send_report(char* buf, int len) {
#ifndef STATS_OPT_OUT
if( chrif->fd > 0 ) {
WFIFOHEAD(chrif->fd,len + 2);
-
+
WFIFOW(chrif->fd,0) = 0x3008;
-
memcpy(WFIFOP(chrif->fd,2), buf, len);
-
+
WFIFOSET(chrif->fd,len + 2);
-
+
flush_fifo(chrif->fd); /* ensure it's sent now. */
}
#endif
@@ -1535,13 +1522,13 @@ void chrif_send_report(char* buf, int len) {
/**
* Sends a single scdata for saving into char server, meant to ensure integrity of duration-less conditions
**/
-void chrif_save_scdata_single(int account_id, int char_id, short type, struct status_change_entry *sce) {
-
+void chrif_save_scdata_single(int account_id, int char_id, short type, struct status_change_entry *sce)
+{
if( !chrif->isconnected() )
return;
-
+
WFIFOHEAD(chrif->fd, 28);
-
+
WFIFOW(chrif->fd, 0) = 0x2740;
WFIFOL(chrif->fd, 2) = account_id;
WFIFOL(chrif->fd, 6) = char_id;
@@ -1550,46 +1537,42 @@ void chrif_save_scdata_single(int account_id, int char_id, short type, struct st
WFIFOL(chrif->fd, 16) = sce->val2;
WFIFOL(chrif->fd, 20) = sce->val3;
WFIFOL(chrif->fd, 24) = sce->val4;
-
+
WFIFOSET(chrif->fd, 28);
-
}
/**
* Sends a single scdata deletion request into char server, meant to ensure integrity of duration-less conditions
**/
-void chrif_del_scdata_single(int account_id, int char_id, short type) {
-
+void chrif_del_scdata_single(int account_id, int char_id, short type)
+{
if( !chrif->isconnected() ) {
ShowError("MAYDAY! failed to delete status %d from CID:%d/AID:%d\n",type,char_id,account_id);
return;
}
-
WFIFOHEAD(chrif->fd, 12);
-
+
WFIFOW(chrif->fd, 0) = 0x2741;
WFIFOL(chrif->fd, 2) = account_id;
WFIFOL(chrif->fd, 6) = char_id;
WFIFOW(chrif->fd, 10) = type;
-
- WFIFOSET(chrif->fd, 12);
+ WFIFOSET(chrif->fd, 12);
}
-/** `
+/**
* @see DBApply
*/
int auth_db_final(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = DB->data2ptr(data);
-
+
if (node->sd) {
-
if( node->sd->regs.vars )
node->sd->regs.vars->destroy(node->sd->regs.vars, script->reg_destroy);
-
+
if( node->sd->regs.arrays )
node->sd->regs.arrays->destroy(node->sd->regs.arrays, script->array_free_db);
-
+
aFree(node->sd);
}
ers_free(chrif->auth_db_ers, node);
@@ -1600,15 +1583,15 @@ int auth_db_final(DBKey key, DBData *data, va_list ap) {
/*==========================================
* Destructor
*------------------------------------------*/
-void do_final_chrif(void) {
-
+void do_final_chrif(void)
+{
if( chrif->fd != -1 ) {
do_close(chrif->fd);
chrif->fd = -1;
}
chrif->auth_db->destroy(chrif->auth_db, chrif->auth_db_final);
-
+
ers_destroy(chrif->auth_db_ers);
}
@@ -1644,12 +1627,12 @@ void do_init_chrif(bool minimal) {
*-------------------------------------*/
void chrif_defaults(void) {
const int packet_len_table[CHRIF_PACKET_LEN_TABLE_SIZE] = { // U - used, F - free
- 60, 3,-1,27,10,-1, 6,-1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff
- 6,-1,18, 7,-1,39,30, 10, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, U->2b07
- 6,30, -1, 0,86, 7,44,34, // 2b08-2b0f: U->2b08, U->2b09, U->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f
- 11,10,10, 0,11, 0,266,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, F->2b13, U->2b14, F->2b15, U->2b16, U->2b17
- 2,10, 2,-1,-1,-1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f
- -1,10, 8, 2, 2,14,19,19, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, U->2b24, U->2b25, U->2b26, U->2b27
+ 60, 3, -1, 27, 10, -1, 6, -1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff
+ 6, -1, 18, 7, -1, 39, 30, 10, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, U->2b07
+ 6, 30, -1, 0, 86, 7, 44, 34, // 2b08-2b0f: U->2b08, U->2b09, U->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f
+ 11, 10, 10, 0, 11, 0,266, 10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, F->2b13, U->2b14, F->2b15, U->2b16, U->2b17
+ 2, 10, 2, -1, -1, -1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f
+ -1, 10, 8, 2, 2, 14, 19, 19, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, U->2b24, U->2b25, U->2b26, U->2b27
};
chrif = &chrif_s;
@@ -1657,7 +1640,7 @@ void chrif_defaults(void) {
/* vars */
chrif->connected = 0;
chrif->other_mapserver_count = 0;
-
+
memcpy(chrif->packet_len_table,&packet_len_table,sizeof(chrif->packet_len_table));
chrif->fd = -1;
chrif->srvinfo = 0;
@@ -1667,36 +1650,36 @@ void chrif_defaults(void) {
memset(chrif->userid,0,sizeof(chrif->userid));
memset(chrif->passwd,0,sizeof(chrif->passwd));
chrif->state = 0;
-
+
/* */
chrif->auth_db = NULL;
chrif->auth_db_ers = NULL;
/* */
chrif->init = do_init_chrif;
chrif->final = do_final_chrif;
-
+
/* funcs */
chrif->setuserid = chrif_setuserid;
chrif->setpasswd = chrif_setpasswd;
chrif->checkdefaultlogin = chrif_checkdefaultlogin;
chrif->setip = chrif_setip;
chrif->setport = chrif_setport;
-
+
chrif->isconnected = chrif_isconnected;
chrif->check_shutdown = chrif_check_shutdown;
-
+
chrif->search = chrif_search;
chrif->auth_check = chrif_auth_check;
chrif->auth_delete = chrif_auth_delete;
chrif->auth_finished = chrif_auth_finished;
-
+
chrif->authreq = chrif_authreq;
chrif->authok = chrif_authok;
chrif->scdata_request = chrif_scdata_request;
chrif->save = chrif_save;
chrif->charselectreq = chrif_charselectreq;
chrif->changemapserver = chrif_changemapserver;
-
+
chrif->searchcharid = chrif_searchcharid;
chrif->changeemail = chrif_changeemail;
chrif->char_ask_name = chrif_char_ask_name;
@@ -1711,13 +1694,13 @@ void chrif_defaults(void) {
chrif->changesex = chrif_changesex;
//chrif->chardisconnect = chrif_chardisconnect;
chrif->divorce = chrif_divorce;
-
+
chrif->removefriend = chrif_removefriend;
chrif->send_report = chrif_send_report;
-
+
chrif->flush = chrif_flush;
chrif->skillid2idx = chrif_skillid2idx;
-
+
chrif->sd_to_auth = chrif_sd_to_auth;
chrif->check_connect_char_server = check_connect_char_server;
chrif->auth_logout = chrif_auth_logout;
@@ -1728,7 +1711,7 @@ void chrif_defaults(void) {
chrif->auth_db_final = auth_db_final;
chrif->send_usercount_tochar = send_usercount_tochar;
chrif->auth_db_cleanup = auth_db_cleanup;
-
+
chrif->connect = chrif_connect;
chrif->connectack = chrif_connectack;
chrif->sendmap = chrif_sendmap;
diff --git a/src/map/chrif.h b/src/map/chrif.h
index 11baaf5ff..2ef4d0eb5 100644
--- a/src/map/chrif.h
+++ b/src/map/chrif.h
@@ -48,7 +48,7 @@ struct auth_node {
struct chrif_interface {
/* vars */
-
+
int connected;
int other_mapserver_count; //Holds count of how many other map servers are online (apart of this instance) [Skotlex]
@@ -73,22 +73,22 @@ struct chrif_interface {
void (*checkdefaultlogin) (void);
bool (*setip) (const char* ip);
void (*setport) (uint16 port);
-
+
int (*isconnected) (void);
void (*check_shutdown) (void);
-
+
struct auth_node* (*search) (int account_id);
struct auth_node* (*auth_check) (int account_id, int char_id, enum sd_state state);
bool (*auth_delete) (int account_id, int char_id, enum sd_state state);
bool (*auth_finished) (struct map_session_data* sd);
-
+
void (*authreq) (struct map_session_data* sd, bool hstandalone);
void (*authok) (int fd);
bool (*scdata_request) (int account_id, int char_id);
bool (*save) (struct map_session_data* sd, int flag);
bool (*charselectreq) (struct map_session_data* sd, uint32 s_ip);
bool (*changemapserver) (struct map_session_data* sd, uint32 ip, uint16 port);
-
+
bool (*searchcharid) (int char_id);
bool (*changeemail) (int id, const char *actual_email, const char *new_email);
bool (*char_ask_name) (int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second);
@@ -104,13 +104,13 @@ struct chrif_interface {
bool (*changesex) (struct map_session_data *sd);
//int (*chardisconnect) (struct map_session_data *sd); // FIXME: Commented out in clif.c, function does not exist
bool (*divorce) (int partner_id1, int partner_id2);
-
+
bool (*removefriend) (int char_id, int friend_id);
void (*send_report) (char* buf, int len);
-
+
bool (*flush) (void);
void (*skillid2idx) (int fd);
-
+
bool (*sd_to_auth) (TBL_PC* sd, enum sd_state state);
int (*check_connect_char_server) (int tid, int64 tick, int id, intptr_t data);
bool (*auth_logout) (TBL_PC* sd, enum sd_state state);
diff --git a/src/map/clif.c b/src/map/clif.c
index d9acf0792..d7b10f2f4 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -72,16 +72,21 @@ static struct packet_npc_market_open npcmarket_open;
//#define DUMP_UNKNOWN_PACKET
//#define DUMP_INVALID_PACKET
+static struct hChSysConfig clif_hChSys;
+
//Converts item type in case of pet eggs.
static inline int itemtype(int type) {
switch( type ) {
#if PACKETVER >= 20080827
- case IT_WEAPON: return IT_ARMOR;
+ case IT_WEAPON:
+ return IT_ARMOR;
case IT_ARMOR:
case IT_PETARMOR:
#endif
- case IT_PETEGG: return IT_WEAPON;
- default: return type;
+ case IT_PETEGG:
+ return IT_WEAPON;
+ default:
+ return type;
}
}
@@ -331,6 +336,11 @@ int clif_send_sub(struct block_list *bl, va_list ap) {
if( clif->ally_only && !sd->sc.data[SC_CLAIRVOYANCE] && !sd->special_state.intravision && battle->check_target( src_bl, &sd->bl, BCT_ENEMY ) > 0 )
return 0;
+ return clif->send_actual(fd, buf, len);
+}
+
+int clif_send_actual(int fd, void *buf, int len)
+{
WFIFOHEAD(fd, len);
if (WFIFOP(fd,0) == buf) {
ShowError("WARNING: Invalid use of clif->send function\n");
@@ -619,7 +629,9 @@ void clif_authok(struct map_session_data *sd)
#if PACKETVER >= 20080102
p.font = sd->status.font;
#endif
-
+#if PACKETVER >= 20141016
+ p.sex = sd->status.sex;
+#endif
clif->send(&p,sizeof(p),&sd->bl,SELF);
}
@@ -1265,11 +1277,15 @@ void clif_spiritball_single(int fd, struct map_session_data *sd) {
* Kagerou/Oboro amulet spirit
*------------------------------------------*/
void clif_charm_single(int fd, struct map_session_data *sd, short type) {
+
+ if ( type <= SPIRITS_TYPE_NONE || type >= SPIRITS_TYPE_SPHERE )
+ return;
+
WFIFOHEAD(fd, packet_len(0x08cf));
WFIFOW(fd,0)=0x08cf;
WFIFOL(fd,2)=sd->bl.id;
WFIFOW(fd,6)=type;
- WFIFOW(fd,8)=sd->charm[type];
+ WFIFOW(fd,8)=sd->spiritcharm[type];
WFIFOSET(fd, packet_len(0x08cf));
}
@@ -1311,7 +1327,7 @@ void clif_weather(int16 m)
for( sd = (struct map_session_data*)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data*)mapit->next(iter) )
{
if( sd->bl.m == m )
- clif_weather_check(sd);
+ clif->weather_check(sd);
}
mapit->free(iter);
}
@@ -1348,17 +1364,15 @@ bool clif_spawn(struct block_list *bl)
clif->spiritball(&sd->bl);
if(sd->state.size==SZ_BIG) // tiny/big players [Valaris]
clif->specialeffect(bl,423,AREA);
- else if(sd->state.size==SZ_SMALL)
+ else if(sd->state.size==SZ_MEDIUM)
clif->specialeffect(bl,421,AREA);
if( sd->bg_id && map->list[sd->bl.m].flag.battleground )
clif->sendbgemblem_area(sd);
for( i = 0; i < sd->sc_display_count; i++ ) {
clif->sc_load(&sd->bl, sd->bl.id,AREA,status->IconChangeTable[sd->sc_display[i]->type],sd->sc_display[i]->val1,sd->sc_display[i]->val2,sd->sc_display[i]->val3);
}
- for(i = 1; i < 5; i++){
- if( sd->charm[i] > 0 )
- clif->charm(sd, i);
- }
+ ARR_FIND(SPIRITS_TYPE_CHARM_WATER, SPIRITS_TYPE_SPHERE, i, sd->spiritcharm[i] > 0);
+ clif->spiritcharm(sd, i);
if (sd->status.robe)
clif->refreshlook(bl,bl->id,LOOK_ROBE,sd->status.robe,AREA);
}
@@ -1368,7 +1382,7 @@ bool clif_spawn(struct block_list *bl)
TBL_MOB *md = ((TBL_MOB*)bl);
if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
clif->specialeffect(&md->bl,423,AREA);
- else if(md->special_state.size==SZ_SMALL)
+ else if(md->special_state.size==SZ_MEDIUM)
clif->specialeffect(&md->bl,421,AREA);
}
break;
@@ -1377,7 +1391,7 @@ bool clif_spawn(struct block_list *bl)
TBL_NPC *nd = ((TBL_NPC*)bl);
if( nd->size == SZ_BIG )
clif->specialeffect(&nd->bl,423,AREA);
- else if( nd->size == SZ_SMALL )
+ else if( nd->size == SZ_MEDIUM )
clif->specialeffect(&nd->bl,421,AREA);
}
break;
@@ -1410,15 +1424,24 @@ void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag)
WBUFW(buf,29)=hd->homunculus.hunger;
WBUFW(buf,31)=(unsigned short) (hd->homunculus.intimacy / 100) ;
WBUFW(buf,33)=0; // equip id
+#ifdef RENEWAL
+ WBUFW(buf, 35) = cap_value(hstatus->rhw.atk2, 0, INT16_MAX);
+#else
WBUFW(buf,35)=cap_value(hstatus->rhw.atk2+hstatus->batk, 0, INT16_MAX);
+#endif
WBUFW(buf,37)=cap_value(hstatus->matk_max, 0, INT16_MAX);
WBUFW(buf,39)=hstatus->hit;
if (battle_config.hom_setting&0x10)
WBUFW(buf,41)=hstatus->luk/3 + 1; //crit is a +1 decimal value! Just display purpose.[Vicious]
else
WBUFW(buf,41)=hstatus->cri/10;
+#ifdef RENEWAL
+ WBUFW(buf, 43) = hstatus->def + hstatus->def2;
+ WBUFW(buf, 45) = hstatus->mdef + hstatus->mdef2;
+#else
WBUFW(buf,43)=hstatus->def + hstatus->vit ;
- WBUFW(buf,45)=hstatus->mdef;
+ WBUFW(buf, 45) = hstatus->mdef;
+#endif
WBUFW(buf,47)=hstatus->flee;
WBUFW(buf,49)=(flag)?0:hstatus->amotion;
if (hstatus->max_hp > INT16_MAX) {
@@ -1465,7 +1488,7 @@ void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag)
/// 3 = accessory?
/// ? = ignored
void clif_send_homdata(struct map_session_data *sd, int state, int param)
-{ //[orn]
+{
int fd = sd->fd;
if ( (state == SP_INTIMATE) && (param >= 910) && (sd->hd->homunculus.class_ == sd->hd->homunculusDB->evo_class) )
@@ -1536,7 +1559,7 @@ void clif_homskillup(struct map_session_data *sd, uint16 skill_id) { //[orn]
WFIFOSET(fd,packet_len(0x239));
}
-void clif_hom_food(struct map_session_data *sd,int foodid,int fail) //[orn]
+void clif_hom_food(struct map_session_data *sd,int foodid,int fail)
{
int fd;
nullpo_retv(sd);
@@ -1582,10 +1605,10 @@ void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *u
case BL_PC:
{
TBL_PC *sd = ((TBL_PC*)bl);
- // clif_movepc(sd);
+ //clif_movepc(sd);
if(sd->state.size==SZ_BIG) // tiny/big players [Valaris]
clif->specialeffect(&sd->bl,423,AREA);
- else if(sd->state.size==SZ_SMALL)
+ else if(sd->state.size==SZ_MEDIUM)
clif->specialeffect(&sd->bl,421,AREA);
}
break;
@@ -1594,7 +1617,7 @@ void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *u
TBL_MOB *md = ((TBL_MOB*)bl);
if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
clif->specialeffect(&md->bl,423,AREA);
- else if(md->special_state.size==SZ_SMALL)
+ else if(md->special_state.size==SZ_MEDIUM)
clif->specialeffect(&md->bl,421,AREA);
}
break;
@@ -2669,76 +2692,77 @@ void read_channels_config(void) {
if( !libconfig->setting_lookup_string(settings, "map_local_channel_name", &local_name) )
local_name = "map";
- safestrncpy(hChSys.local_name, local_name, HCHSYS_NAME_LENGTH);
+ safestrncpy(clif->hChSys->local_name, local_name, HCHSYS_NAME_LENGTH);
if( !libconfig->setting_lookup_string(settings, "ally_channel_name", &ally_name) )
ally_name = "ally";
- safestrncpy(hChSys.ally_name, ally_name, HCHSYS_NAME_LENGTH);
+ safestrncpy(clif->hChSys->ally_name, ally_name, HCHSYS_NAME_LENGTH);
if( !libconfig->setting_lookup_string(settings, "irc_channel_name", &irc_name) )
irc_name = "irc";
- safestrncpy(hChSys.irc_name, irc_name, HCHSYS_NAME_LENGTH);
+ safestrncpy(clif->hChSys->irc_name, irc_name, HCHSYS_NAME_LENGTH);
libconfig->setting_lookup_bool(settings, "map_local_channel", &local_enabled);
libconfig->setting_lookup_bool(settings, "ally_channel_enabled", &ally_enabled);
libconfig->setting_lookup_bool(settings, "irc_channel_enabled", &irc_enabled);
- if( local_enabled )
- hChSys.local = true;
- if( ally_enabled )
- hChSys.ally = true;
- if( irc_enabled )
- hChSys.irc = true;
+ if (local_enabled)
+ clif->hChSys->local = true;
+ if (ally_enabled)
+ clif->hChSys->ally = true;
+ if (irc_enabled)
+ clif->hChSys->irc = true;
- hChSys.irc_server[0] = hChSys.irc_channel[0] = hChSys.irc_nick[0] = hChSys.irc_nick_pw[0] = '\0';
+ clif->hChSys->irc_server[0] = clif->hChSys->irc_channel[0] = clif->hChSys->irc_nick[0] = clif->hChSys->irc_nick_pw[0] = '\0';
- if( hChSys.irc ) {
+ if (clif->hChSys->irc) {
const char *irc_server, *irc_channel,
*irc_nick, *irc_nick_pw;
int irc_use_ghost = 0;
if( libconfig->setting_lookup_string(settings, "irc_channel_network", &irc_server) ) {
if( !strstr(irc_server,":") ) {
- hChSys.irc = false;
+ clif->hChSys->irc = false;
ShowWarning("channels.conf : network port wasn't found in 'irc_channel_network', disabling irc channel...\n");
} else {
unsigned char d = 0, dlen = strlen(irc_server);
char server[40];
-
+ if (dlen > 39)
+ dlen = 39;
memset(server, '\0', sizeof(server));
for(d = 0; d < dlen; d++) {
if(irc_server[d] == ':') {
memcpy(server, irc_server, d);
- safestrncpy(hChSys.irc_server, server, 40);
- memcpy(server, &irc_server[d+1], dlen);
- hChSys.irc_server_port = atoi(server);
+ safestrncpy(clif->hChSys->irc_server, server, 40);
+ memcpy(server, &irc_server[d+1], dlen - d - 1);
+ clif->hChSys->irc_server_port = atoi(server);
break;
}
}
}
} else {
- hChSys.irc = false;
+ clif->hChSys->irc = false;
ShowWarning("channels.conf : irc channel enabled but irc_channel_network wasn't found, disabling irc channel...\n");
}
if( libconfig->setting_lookup_string(settings, "irc_channel_channel", &irc_channel) )
- safestrncpy(hChSys.irc_channel, irc_channel, 50);
+ safestrncpy(clif->hChSys->irc_channel, irc_channel, 50);
else {
- hChSys.irc = false;
+ clif->hChSys->irc = false;
ShowWarning("channels.conf : irc channel enabled but irc_channel_channel wasn't found, disabling irc channel...\n");
}
if( libconfig->setting_lookup_string(settings, "irc_channel_nick", &irc_nick) ) {
if( strcmpi(irc_nick,"Hercules_chSysBot") == 0 ) {
- sprintf(hChSys.irc_nick, "Hercules_chSysBot%d",rand()%777);
+ sprintf(clif->hChSys->irc_nick, "Hercules_chSysBot%d",rand()%777);
} else
- safestrncpy(hChSys.irc_nick, irc_nick, 40);
+ safestrncpy(clif->hChSys->irc_nick, irc_nick, 40);
} else {
- hChSys.irc = false;
+ clif->hChSys->irc = false;
ShowWarning("channels.conf : irc channel enabled but irc_channel_nick wasn't found, disabling irc channel...\n");
}
if( libconfig->setting_lookup_string(settings, "irc_channel_nick_pw", &irc_nick_pw) ) {
- safestrncpy(hChSys.irc_nick_pw, irc_nick_pw, 30);
+ safestrncpy(clif->hChSys->irc_nick_pw, irc_nick_pw, 30);
config_setting_lookup_bool(settings, "irc_channel_use_ghost", &irc_use_ghost);
- hChSys.irc_use_ghost = irc_use_ghost;
+ clif->hChSys->irc_use_ghost = irc_use_ghost;
}
}
@@ -2746,83 +2770,83 @@ void read_channels_config(void) {
libconfig->setting_lookup_bool(settings, "map_local_channel_autojoin", &local_autojoin);
libconfig->setting_lookup_bool(settings, "ally_channel_autojoin", &ally_autojoin);
- if( local_autojoin )
- hChSys.local_autojoin = true;
- if( ally_autojoin )
- hChSys.ally_autojoin = true;
+ if (local_autojoin)
+ clif->hChSys->local_autojoin = true;
+ if (ally_autojoin)
+ clif->hChSys->ally_autojoin = true;
libconfig->setting_lookup_bool(settings, "allow_user_channel_creation", &allow_user_channel_creation);
if( allow_user_channel_creation )
- hChSys.allow_user_channel_creation = true;
+ clif->hChSys->allow_user_channel_creation = true;
if( (colors = libconfig->setting_get_member(settings, "colors")) != NULL ) {
int color_count = libconfig->setting_length(colors);
- CREATE( hChSys.colors, unsigned int, color_count );
- CREATE( hChSys.colors_name, char *, color_count );
+ CREATE(clif->hChSys->colors, unsigned int, color_count);
+ CREATE(clif->hChSys->colors_name, char *, color_count);
for(i = 0; i < color_count; i++) {
config_setting_t *color = libconfig->setting_get_elem(colors, i);
- CREATE( hChSys.colors_name[i], char, HCHSYS_NAME_LENGTH );
+ CREATE(clif->hChSys->colors_name[i], char, HCHSYS_NAME_LENGTH);
- safestrncpy(hChSys.colors_name[i], config_setting_name(color), HCHSYS_NAME_LENGTH);
+ safestrncpy(clif->hChSys->colors_name[i], config_setting_name(color), HCHSYS_NAME_LENGTH);
- hChSys.colors[i] = (unsigned int)strtoul(libconfig->setting_get_string_elem(colors,i),NULL,0);
- hChSys.colors[i] = (hChSys.colors[i] & 0x0000FF) << 16 | (hChSys.colors[i] & 0x00FF00) | (hChSys.colors[i] & 0xFF0000) >> 16;//RGB to BGR
+ clif->hChSys->colors[i] = (unsigned int)strtoul(libconfig->setting_get_string_elem(colors,i),NULL,0);
+ clif->hChSys->colors[i] = (clif->hChSys->colors[i] & 0x0000FF) << 16 | (clif->hChSys->colors[i] & 0x00FF00) | (clif->hChSys->colors[i] & 0xFF0000) >> 16;//RGB to BGR
}
- hChSys.colors_count = color_count;
+ clif->hChSys->colors_count = color_count;
}
libconfig->setting_lookup_string(settings, "map_local_channel_color", &local_color);
- for (k = 0; k < hChSys.colors_count; k++) {
- if( strcmpi(hChSys.colors_name[k],local_color) == 0 )
+ for (k = 0; k < clif->hChSys->colors_count; k++) {
+ if (strcmpi(clif->hChSys->colors_name[k], local_color) == 0)
break;
}
- if( k < hChSys.colors_count ) {
- hChSys.local_color = k;
+ if (k < clif->hChSys->colors_count) {
+ clif->hChSys->local_color = k;
} else {
ShowError("channels.conf: unknown color '%s' for 'map_local_channel_color', disabling '#%s'...\n",local_color,local_name);
- hChSys.local = false;
+ clif->hChSys->local = false;
}
libconfig->setting_lookup_string(settings, "ally_channel_color", &ally_color);
- for (k = 0; k < hChSys.colors_count; k++) {
- if( strcmpi(hChSys.colors_name[k],ally_color) == 0 )
+ for (k = 0; k < clif->hChSys->colors_count; k++) {
+ if (strcmpi(clif->hChSys->colors_name[k], ally_color) == 0)
break;
}
- if( k < hChSys.colors_count ) {
- hChSys.ally_color = k;
+ if( k < clif->hChSys->colors_count ) {
+ clif->hChSys->ally_color = k;
} else {
ShowError("channels.conf: unknown color '%s' for 'ally_channel_color', disabling '#%s'...\n",ally_color,ally_name);
- hChSys.ally = false;
+ clif->hChSys->ally = false;
}
libconfig->setting_lookup_string(settings, "irc_channel_color", &irc_color);
- for (k = 0; k < hChSys.colors_count; k++) {
- if( strcmpi(hChSys.colors_name[k],irc_color) == 0 )
+ for (k = 0; k < clif->hChSys->colors_count; k++) {
+ if (strcmpi(clif->hChSys->colors_name[k], irc_color) == 0)
break;
}
- if( k < hChSys.colors_count ) {
- hChSys.irc_color = k;
+ if (k < clif->hChSys->colors_count) {
+ clif->hChSys->irc_color = k;
} else {
ShowError("channels.conf: unknown color '%s' for 'irc_channel_color', disabling '#%s'...\n",irc_color,irc_name);
- hChSys.irc = false;
+ clif->hChSys->irc = false;
}
- if( hChSys.irc ) {
+ if (clif->hChSys->irc) {
struct hChSysCh *chd;
- CREATE( chd, struct hChSysCh, 1 );
+ CREATE(chd, struct hChSysCh, 1);
- safestrncpy(chd->name, hChSys.irc_name, HCHSYS_NAME_LENGTH);
+ safestrncpy(chd->name, clif->hChSys->irc_name, HCHSYS_NAME_LENGTH);
chd->type = hChSys_IRC;
- clif->chsys_create(chd,NULL,NULL,hChSys.irc_color);
+ clif->chsys_create(chd, NULL, NULL, clif->hChSys->irc_color);
ircbot->channel = chd;
}
@@ -2835,15 +2859,15 @@ void read_channels_config(void) {
const char *color = libconfig->setting_get_string_elem(channels,i);
struct hChSysCh *chd;
- for (k = 0; k < hChSys.colors_count; k++) {
- if( strcmpi(hChSys.colors_name[k],color) == 0 )
+ for (k = 0; k < clif->hChSys->colors_count; k++) {
+ if (strcmpi(clif->hChSys->colors_name[k],color) == 0)
break;
}
- if( k == hChSys.colors_count ) {
+ if( k == clif->hChSys->colors_count) {
ShowError("channels.conf: unknown color '%s' for channel '%s', skipping channel...\n",color,name);
continue;
}
- if( strcmpi(name,hChSys.local_name) == 0 || strcmpi(name,hChSys.ally_name) == 0 || strcmpi(name,hChSys.irc_name) == 0 || strdb_exists(clif->channel_db, name) ) {
+ if( strcmpi(name, clif->hChSys->local_name) == 0 || strcmpi(name, clif->hChSys->ally_name) == 0 || strcmpi(name, clif->hChSys->irc_name) == 0 || strdb_exists(clif->channel_db, name) ) {
ShowError("channels.conf: duplicate channel '%s', skipping channel...\n",name);
continue;
@@ -2943,7 +2967,7 @@ void clif_updatestatus(struct map_session_data *sd,int type)
case SP_WEIGHT:
pc->updateweightstatus(sd);
WFIFOHEAD(fd,14);
- WFIFOW(fd,0)=0xb0; //Need to re-set as pc->updateweightstatus can alter the buffer. [Skotlex]
+ WFIFOW(fd,0)=0xb0; //Need to re-set as pc->updateweightstatus can alter the buffer. [Skotlex]
WFIFOW(fd,2)=type;
WFIFOL(fd,4)=sd->weight;
break;
@@ -3173,17 +3197,14 @@ void clif_changestatus(struct map_session_data* sd,int type,int val)
clif->send(buf,packet_len(0x1ab),&sd->bl,AREA_WOS);
}
-
/// Updates sprite/style properties of an object.
-/// 00c3 <id>.L <type>.B <value>.B (ZC_SPRITE_CHANGE)
-/// 01d7 <id>.L <type>.B <value>.L (ZC_SPRITE_CHANGE2)
void clif_changelook(struct block_list *bl,int type,int val)
{
- unsigned char buf[16];
struct map_session_data* sd;
struct status_change* sc;
struct view_data* vd;
enum send_target target = AREA;
+ int val2 = 0;
nullpo_retv(bl);
sd = BL_CAST(BL_PC, bl);
@@ -3210,12 +3231,6 @@ void clif_changelook(struct block_list *bl,int type,int val)
break;
case LOOK_BASE:
if( !sd ) break;
- // We shouldn't update LOOK_BASE if the player is disguised
- // if we do so the client will think that the player class
- // is really a mob and issues like 7725 will happen in every
- // SC_ that alters class_ in any way [Panikon]
- if( sd->disguise != -1 )
- return;
if( sd->sc.option&OPTION_COSTUME )
vd->weapon = vd->shield = 0;
@@ -3295,57 +3310,34 @@ void clif_changelook(struct block_list *bl,int type,int val)
}
// prevent leaking the presence of GM-hidden objects
- if( sc && sc->option&OPTION_INVISIBLE )
+ if( sc && sc->option&OPTION_INVISIBLE && !disguised(bl) )
target = SELF;
-
#if PACKETVER < 4
- WBUFW(buf,0)=0xc3;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=type;
- WBUFB(buf,7)=val;
- clif->send(buf,packet_len(0xc3),bl,target);
+ clif->sendlook(bl, bl->id, type, val, 0, target);
#else
- WBUFW(buf,0)=0x1d7;
- WBUFL(buf,2)=bl->id;
if(type == LOOK_WEAPON || type == LOOK_SHIELD) {
nullpo_retv(vd);
- WBUFB(buf,6)=LOOK_WEAPON;
- WBUFW(buf,7)=vd->weapon;
- WBUFW(buf,9)=vd->shield;
- } else {
- WBUFB(buf,6)=type;
- WBUFL(buf,7)=val;
- }
- clif->send(buf,packet_len(0x1d7),bl,target);
- if( disguised(bl) && sd && sd->fontcolor ) {
- WBUFL(buf,2)=-bl->id;
- clif->send(buf,packet_len(0x1d7),bl,SELF);
+ type = LOOK_WEAPON;
+ val = vd->weapon;
+ val2 = vd->shield;
}
+ if( disguised(bl) ) {
+ clif->sendlook(bl, bl->id, type, val, val2, AREA_WOS);
+ clif->sendlook(bl, -bl->id, type, val, val2, SELF);
+ } else
+ clif->sendlook(bl, bl->id, type, val, val2, target);
#endif
}
//Sends a change-base-look packet required for traps as they are triggered.
void clif_changetraplook(struct block_list *bl,int val)
{
- unsigned char buf[32];
-#if PACKETVER < 4
- WBUFW(buf,0)=0xc3;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=LOOK_BASE;
- WBUFB(buf,7)=val;
- clif->send(buf,packet_len(0xc3),bl,AREA);
-#else
- WBUFW(buf,0)=0x1d7;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=LOOK_BASE;
- WBUFW(buf,7)=val;
- WBUFW(buf,9)=0;
- clif->send(buf,packet_len(0x1d7),bl,AREA);
-#endif
+ clif->sendlook(bl, bl->id, LOOK_BASE, val, 0, AREA);
}
-//For the stupid cloth-dye bug. Resends the given view data to the area specified by bl.
-void clif_refreshlook(struct block_list *bl,int id,int type,int val,enum send_target target)
+/// 00c3 <id>.L <type>.B <value>.B (ZC_SPRITE_CHANGE)
+/// 01d7 <id>.L <type>.B <value>.L (ZC_SPRITE_CHANGE2)
+void clif_sendlook(struct block_list *bl, int id, int type, int val, int val2, enum send_target target)
{
unsigned char buf[32];
#if PACKETVER < 4
@@ -3359,11 +3351,17 @@ void clif_refreshlook(struct block_list *bl,int id,int type,int val,enum send_ta
WBUFL(buf,2)=id;
WBUFB(buf,6)=type;
WBUFW(buf,7)=val;
- WBUFW(buf,9)=0;
+ WBUFW(buf,9)=val2;
clif->send(buf,packet_len(0x1d7),bl,target);
#endif
}
+//For the stupid cloth-dye bug. Resends the given view data to the area specified by bl.
+void clif_refreshlook(struct block_list *bl,int id,int type,int val,enum send_target target)
+{
+ clif->sendlook(bl, id, type, val, 0, target);
+}
+
/// Character status (ZC_STATUS).
/// 00bd <stpoint>.W <str>.B <need str>.B <agi>.B <need agi>.B <vit>.B <need vit>.B
@@ -3437,7 +3435,6 @@ void clif_arrowequip(struct map_session_data *sd,int val)
nullpo_retv(sd);
- pc_stop_attack(sd); // [Valaris]
#if PACKETVER >= 20121128
clif->status_change(&sd->bl, SI_CLIENT_ONLY_EQUIP_ARROW, 1, INVALID_TIMER, 0, 0, 0);
#endif
@@ -4274,10 +4271,9 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds
if(dstsd->spiritball > 0)
clif->spiritball_single(sd->fd, dstsd);
- for(i = 1; i < 5; i++){
- if( dstsd->charm[i] > 0 )
- clif->charm_single(sd->fd, dstsd, i);
- }
+ ARR_FIND(SPIRITS_TYPE_CHARM_WATER, SPIRITS_TYPE_SPHERE, i, sd->spiritcharm[i] > 0);
+ clif->charm_single(sd->fd, dstsd, i);
+
for( i = 0; i < dstsd->sc_display_count; i++ ) {
clif->sc_load(&sd->bl,dstsd->bl.id,SELF,status->IconChangeTable[dstsd->sc_display[i]->type],dstsd->sc_display[i]->val1,dstsd->sc_display[i]->val2,dstsd->sc_display[i]->val3);
}
@@ -4326,7 +4322,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
clif->getareachar_pc(sd, tsd);
if(tsd->state.size==SZ_BIG) // tiny/big players [Valaris]
clif->specialeffect_single(bl,423,sd->fd);
- else if(tsd->state.size==SZ_SMALL)
+ else if(tsd->state.size==SZ_MEDIUM)
clif->specialeffect_single(bl,421,sd->fd);
if( tsd->bg_id && map->list[tsd->bl.m].flag.battleground )
clif->sendbgemblem_single(sd->fd,tsd);
@@ -4345,7 +4341,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
clif->dispchat((struct chat_data*)map->id2bl(nd->chat_id),sd->fd);
if( nd->size == SZ_BIG )
clif->specialeffect_single(bl,423,sd->fd);
- else if( nd->size == SZ_SMALL )
+ else if( nd->size == SZ_MEDIUM )
clif->specialeffect_single(bl,421,sd->fd);
}
break;
@@ -4354,7 +4350,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
TBL_MOB* md = (TBL_MOB*)bl;
if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
clif->specialeffect_single(bl,423,sd->fd);
- else if(md->special_state.size==SZ_SMALL)
+ else if(md->special_state.size==SZ_MEDIUM)
clif->specialeffect_single(bl,421,sd->fd);
#if PACKETVER >= 20120404
if( !(md->status.mode&MD_BOSS) ){
@@ -4791,7 +4787,9 @@ int clif_outsight(struct block_list *bl,va_list ap)
}
if (sd && sd->fd) { //sd is watching tbl go out of view.
nullpo_ret(tbl);
- if (((vd=status->get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS) &&
+ if(tbl->type == BL_SKILL) //Trap knocked out of sight
+ clif->clearchar_skillunit((struct skill_unit *)tbl,sd->fd);
+ else if (((vd=status->get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS) &&
!(tbl->type == BL_NPC && (((TBL_NPC*)tbl)->option&OPTION_INVISIBLE)))
clif->clearunit_single(tbl->id,CLR_OUTSIGHT,sd->fd);
}
@@ -4934,8 +4932,8 @@ void clif_deleteskill(struct map_session_data *sd, int id)
/// 010e <skill id>.W <level>.W <sp cost>.W <attack range>.W <upgradable>.B
/// Merged clif_skillup and clif_guild_skillup, same packet was used [panikon]
/// flag:
-/// 0: guild call
-/// 1: player call
+/// 0: guild call
+/// 1: player call
void clif_skillup(struct map_session_data *sd, uint16 skill_id, int skill_lv, int flag)
{
int fd;
@@ -5066,7 +5064,8 @@ void clif_skill_fail(struct map_session_data *sd,uint16 skill_id,enum useskill_f
{
int fd;
- if (!sd) { //Since this is the most common nullpo....
+ if (!sd) {
+ //Since this is the most common nullpo....
ShowDebug("clif_skill_fail: Error, received NULL sd for skill %d\n", skill_id);
return;
}
@@ -5128,8 +5127,12 @@ int clif_skill_damage(struct block_list *src, struct block_list *dst, int64 tick
damage = (int)cap_value(in_damage,INT_MIN,INT_MAX);
type = clif_calc_delay(type,div,damage,ddelay);
- sc = status->get_sc(dst);
- if(sc && sc->count) {
+
+#if PACKETVER >= 20131223
+ if( type == 6 ) type = 8; //bugreport:8263
+#endif
+
+ if( ( sc = status->get_sc(dst) ) && sc->count ) {
if(sc->data[SC_ILLUSION] && damage)
damage = damage*(sc->data[SC_ILLUSION]->val2) + rnd()%100;
}
@@ -5213,7 +5216,7 @@ int clif_skill_damage2(struct block_list *src, struct block_list *dst, int64 tic
nullpo_ret(src);
nullpo_ret(dst);
- type = (type>0)?type:skill_get_hit(skill_id);
+ type = (type>0)?type:skill->get_hit(skill_id);
type = clif_calc_delay(type,div,damage,ddelay);
sc = status->get_sc(dst);
@@ -5256,7 +5259,7 @@ int clif_skill_damage2(struct block_list *src, struct block_list *dst, int64 tic
}
//Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex]
- return clif_calc_walkdelay(dst,ddelay,type,damage,div);
+ return clif->calc_walkdelay(dst,ddelay,type,damage,div);
}
#endif // 0
@@ -5373,7 +5376,7 @@ void clif_skill_memomessage(struct map_session_data* sd, int type)
/// type:
/// 0 = "Unable to Teleport in this area" in color 0xFFFF00 (cyan)
/// 1 = "Saved point cannot be memorized." in color 0x0000FF (red)
-/// 2 = "This skill cannot be used within this area." in color 0xFFFF00 (cyan)
+/// 2 = "This skill cannot be used within this area." in color 0xFFFF00 (cyan)
///
/// @param sd Who receives the message
/// @param type What message
@@ -5418,10 +5421,11 @@ void clif_skill_estimation(struct map_session_data *sd,struct block_list *dst) {
WBUFW(buf,16) = (battle_config.estimation_type&1?dstatus->mdef:0)
+ (battle_config.estimation_type&2?dstatus->mdef2:0);
WBUFW(buf,18) = dstatus->def_ele;
- for(i=0;i<9;i++)
+ for(i=0;i<9;i++) {
WBUFB(buf,20+i)= (unsigned char)battle->attr_ratio(i+1,dstatus->def_ele, dstatus->ele_lv);
-// The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex]
-// WBUFB(buf,20+i)= (unsigned char)((fix=battle_attr_ratio(i+1,dstatus->def_ele, dstatus->ele_lv))<0?0:fix);
+ // The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex]
+ //WBUFB(buf,20+i)= (unsigned char)((fix=battle->attr_ratio(i+1,dstatus->def_ele, dstatus->ele_lv))<0?0:fix);
+ }
clif->send(buf,packet_len(0x18c),&sd->bl,sd->status.party_id>0?PARTY_SAMEMAP:SELF);
}
@@ -5504,7 +5508,8 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 skill_id
c++;
}
- if( skill_id == AM_PHARMACY ) { // Only send it while Cooking else check for c.
+ if( skill_id == AM_PHARMACY ) {
+ // Only send it while Cooking else check for c.
WFIFOW(fd,2) = 6 + 2 * c;
WFIFOSET(fd,WFIFOW(fd,2));
}
@@ -5580,6 +5585,7 @@ void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val
p.index = type;
p.AID = bl->id;
p.state = (unsigned char)flag;
+
#if PACKETVER >= 20120618
p.Total = tick; /* at this stage remain and total are the same value I believe */
#endif
@@ -5600,6 +5606,11 @@ void clif_displaymessage(const int fd, const char* mes) {
if( map->cpsd_active && fd == 0 ) {
ShowInfo("HCP: %s\n",mes);
} else if ( fd > 0 ) {
+ #if PACKETVER == 20141022
+ /** for some reason game client crashes depending on message pattern (only for this packet) **/
+ /** so we redirect to ZC_NPC_CHAT **/
+ clif->colormes(fd,COLOR_DEFAULT,mes);
+ #else
size_t len;
if ( ( len = strnlen(mes, 255) ) > 0 ) { // don't send a void message (it's not displaying on the client chat). @help can send void line.
@@ -5609,6 +5620,7 @@ void clif_displaymessage(const int fd, const char* mes) {
safestrncpy((char *)WFIFOP(fd,4), mes, len + 1);
WFIFOSET(fd, 5 + len);
}
+ #endif
}
}
void clif_displaymessage2(const int fd, const char* mes) {
@@ -5833,12 +5845,12 @@ void clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type)
unsigned char buf[32];
WBUFW(buf,0) = 0x19a;
WBUFL(buf,2) = sd->bl.id;
- if(sd->sc.option&(OPTION_HIDE|OPTION_CLOAK))
+ if (sd->sc.option&(OPTION_HIDE|OPTION_CLOAK)) // TODO[Haru] Should this be pc_ishiding(sd)? (i.e. include Chase Walk and any new options)
WBUFL(buf,6) = UINT32_MAX; //On client displays as --
else
WBUFL(buf,6) = pvprank;
WBUFL(buf,10) = pvpnum;
- if(sd->sc.option&OPTION_INVISIBLE || sd->disguise != -1) //Causes crashes when a 'mob' with pvp info dies.
+ if (pc_isinvisible(sd) || sd->disguise != -1) //Causes crashes when a 'mob' with pvp info dies.
clif->send(buf,packet_len(0x19a),&sd->bl,SELF);
else if(!type)
clif->send(buf,packet_len(0x19a),&sd->bl,AREA);
@@ -5988,17 +6000,17 @@ void clif_use_card(struct map_session_data *sd,int idx)
if(itemdb_isspecial(sd->status.inventory[i].card[0])) //Can't slot it
continue;
- if(sd->status.inventory[i].identify==0 ) //Not identified
+ if (sd->status.inventory[i].identify == 0) //Not identified
continue;
- if((sd->inventory_data[i]->equip&ep)==0) //Not equippable on this part.
+ if ((sd->inventory_data[i]->equip&ep) == 0) //Not equippable on this part.
continue;
if(sd->inventory_data[i]->type==IT_WEAPON && ep==EQP_SHIELD) //Shield card won't go on left weapon.
continue;
ARR_FIND( 0, sd->inventory_data[i]->slot, j, sd->status.inventory[i].card[j] == 0 );
- if( j == sd->inventory_data[i]->slot ) // No room
+ if (j == sd->inventory_data[i]->slot) // No room
continue;
if( sd->status.inventory[i].equip > 0 ) // Do not check items that are already equipped
@@ -6754,7 +6766,7 @@ void clif_party_message(struct party_data* p, int account_id, const char* mes, i
WBUFW(buf,0)=0x109;
WBUFW(buf,2)=len+8;
WBUFL(buf,4)=account_id;
- safestrncpy((char *)WBUFP(buf,8), mes, len);
+ safestrncpy((char *)WBUFP(buf,8), mes, len);
clif->send(buf,len+8,&sd->bl,PARTY);
}
}
@@ -7157,20 +7169,20 @@ void clif_devotion(struct block_list *src, struct map_session_data *tsd)
* 01e1 <id>.L <amount>.W (ZC_SPIRITS2)
*------------------------------------------*/
void clif_spiritball(struct block_list *bl) {
- unsigned char buf[16];
- TBL_PC *sd = BL_CAST(BL_PC,bl);
- TBL_HOM *hd = BL_CAST(BL_HOM,bl);
+ unsigned char buf[16];
+ TBL_PC *sd = BL_CAST(BL_PC,bl);
+ TBL_HOM *hd = BL_CAST(BL_HOM,bl);
- nullpo_retv(bl);
+ nullpo_retv(bl);
- WBUFW(buf, 0) = 0x1d0;
- WBUFL(buf, 2) = bl->id;
+ WBUFW(buf, 0) = 0x1d0;
+ WBUFL(buf, 2) = bl->id;
WBUFW(buf, 6) = 0; //init to 0
- switch(bl->type){
- case BL_PC: WBUFW(buf, 6) = sd->spiritball; break;
- case BL_HOM: WBUFW(buf, 6) = hd->homunculus.spiritball; break;
- }
- clif->send(buf, packet_len(0x1d0), bl, AREA);
+ switch(bl->type){
+ case BL_PC: WBUFW(buf, 6) = sd->spiritball; break;
+ case BL_HOM: WBUFW(buf, 6) = hd->homunculus.spiritball; break;
+ }
+ clif->send(buf, packet_len(0x1d0), bl, AREA);
}
@@ -7438,9 +7450,9 @@ void clif_guild_basicinfo(struct map_session_data *sd) {
WFIFOL(fd,18)=g->average_lv;
WFIFOL(fd,22)=(uint32)cap_value(g->exp,0,INT32_MAX);
WFIFOL(fd,26)=g->next_exp;
- WFIFOL(fd,30)=0; // Tax Points
- WFIFOL(fd,34)=0; // Honor: (left) Vulgar [-100,100] Famed (right)
- WFIFOL(fd,38)=0; // Virtue: (down) Wicked [-100,100] Righteous (up)
+ WFIFOL(fd,30)=0; // Tax Points
+ WFIFOL(fd,34)=0; // Honor: (left) Vulgar [-100,100] Famed (right)
+ WFIFOL(fd,38)=0; // Virtue: (down) Wicked [-100,100] Righteous (up)
WFIFOL(fd,42)=g->emblem_id;
memcpy(WFIFOP(fd,46),g->name, NAME_LENGTH);
memcpy(WFIFOP(fd,70),g->master, NAME_LENGTH);
@@ -7515,7 +7527,7 @@ void clif_guild_memberlist(struct map_session_data *sd)
WFIFOL(fd,c*104+22)=(int)cap_value(m->exp,0,INT32_MAX);
WFIFOL(fd,c*104+26)=m->online;
WFIFOL(fd,c*104+30)=m->position;
- memset(WFIFOP(fd,c*104+34),0,50); //[Ind] - This is displayed in the 'note' column but being you can't edit it it's sent empty.
+ memset(WFIFOP(fd,c*104+34),0,50); //[Ind] - This is displayed in the 'note' column but being you can't edit it it's sent empty.
memcpy(WFIFOP(fd,c*104+84),m->name,NAME_LENGTH);
c++;
}
@@ -8445,7 +8457,7 @@ void clif_refresh_storagewindow( struct map_session_data *sd ) {
// remain locked forever and nobody will be able to access it
if( sd->state.storage_flag == 2 ) {
struct guild_storage *gstor;
- if( (gstor = gstorage->id2storage2(sd->status.guild_id)) == NULL) {
+ if( (gstor = idb_get(gstorage->db,sd->status.guild_id)) == NULL) {
// Shouldn't happen... The information should already be at the map-server
intif->request_guild_storage(sd->status.account_id,sd->status.guild_id);
} else {
@@ -8478,10 +8490,9 @@ void clif_refresh(struct map_session_data *sd)
clif->updatestatus(sd,SP_LUK);
if (sd->spiritball)
clif->spiritball_single(sd->fd, sd);
- for(i = 1; i < 5; i++){
- if( sd->charm[i] > 0 )
- clif->charm_single(sd->fd, sd, i);
- }
+ ARR_FIND(SPIRITS_TYPE_CHARM_WATER, SPIRITS_TYPE_SPHERE, i, sd->spiritcharm[i] > 0);
+ clif->charm_single(sd->fd, sd, i);
+
if (sd->vd.cloth_color)
clif->refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF);
if(homun_alive(sd->hd))
@@ -8633,9 +8644,11 @@ void clif_charnameack (int fd, struct block_list *bl)
}
}
break;
- case BL_CHAT: //FIXME: Clients DO request this... what should be done about it? The chat's title may not fit... [Skotlex]
- // memcpy(WBUFP(buf,6), (struct chat*)->title, NAME_LENGTH);
- // break;
+ case BL_CHAT:
+#if 0 //FIXME: Clients DO request this... what should be done about it? The chat's title may not fit... [Skotlex]
+ memcpy(WBUFP(buf,6), (struct chat*)->title, NAME_LENGTH);
+ break;
+#endif
return;
case BL_ELEM:
memcpy(WBUFP(buf,6), ((TBL_ELEM*)bl)->db->name, NAME_LENGTH);
@@ -8944,7 +8957,7 @@ void clif_viewequip_ack(struct map_session_data* sd, struct map_session_data* ts
for( i = 0; i < EQI_MAX; i++ ) {
if( (k = tsd->equip_index[i]) >= 0 ) {
- if (tsd->status.inventory[k].nameid <= 0 || tsd->inventory_data[k] == NULL) // Item doesn't exist
+ if (tsd->status.inventory[k].nameid <= 0 || tsd->inventory_data[k] == NULL) // Item doesn't exist
continue;
clif_item_equip(k+2,&viewequip_list.list[equip++],&tsd->status.inventory[k],tsd->inventory_data[k],pc->equippoint(tsd,k));
@@ -9035,8 +9048,8 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_,
packetlen = RFIFOW(fd,2);
// basic structure checks
- if( packetlen < 4 + 1 )
- { // 4-byte header and at least an empty string is expected
+ if (packetlen < 4 + 1) {
+ // 4-byte header and at least an empty string is expected
ShowWarning("clif_process_message: Received malformed packet from player '%s' (no message data)!\n", sd->status.name);
return false;
}
@@ -9075,8 +9088,8 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_,
name = text;
namelen = strnlen(name, NAME_LENGTH-1); // name length (w/o zero byte)
- if( name[namelen] != '\0' )
- { // only restriction is that the name must be zero-terminated
+ if (name[namelen] != '\0') {
+ // only restriction is that the name must be zero-terminated
ShowWarning("clif_process_message: Player '%s' sent an unterminated name!\n", sd->status.name);
return false;
}
@@ -9085,19 +9098,19 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_,
messagelen = textlen - NAME_LENGTH; // this should be the message length (w/ zero byte included)
}
- if( messagelen != strnlen(message, messagelen)+1 )
- { // the declared length must match real length
+ if (messagelen != strnlen(message, messagelen)+1) {
+ // the declared length must match real length
ShowWarning("clif_process_message: Received malformed packet from player '%s' (length is incorrect)!\n", sd->status.name);
return false;
}
// verify <message> part of the packet
- if( message[messagelen-1] != '\0' )
- { // message must be zero-terminated
+ if (message[messagelen-1] != '\0') {
+ // message must be zero-terminated
ShowWarning("clif_process_message: Player '%s' sent an unterminated message string!\n", sd->status.name);
return false;
}
- if( messagelen > CHAT_SIZE_MAX-1 )
- { // messages mustn't be too long
+ if (messagelen > CHAT_SIZE_MAX-1) {
+ // messages mustn't be too long
// Normally you can only enter CHATBOX_SIZE-1 letters into the chat box, but Frost Joke / Dazzler's text can be longer.
// Also, the physical size of strings that use multibyte encoding can go multiple times over the chatbox capacity.
// Neither the official client nor server place any restriction on the length of the data in the packet,
@@ -9122,7 +9135,7 @@ void clif_hercules_chsys_msg(struct hChSysCh *channel, struct map_session_data *
WFIFOW(sd->fd,0) = 0x2C1;
WFIFOW(sd->fd,2) = msg_len + 12;
WFIFOL(sd->fd,4) = 0;
- WFIFOL(sd->fd,8) = hChSys.colors[channel->color];
+ WFIFOL(sd->fd,8) = clif->hChSys->colors[channel->color];
safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len);
for( user = dbi_first(iter); dbi_exists(iter); user = dbi_next(iter) ) {
@@ -9147,7 +9160,7 @@ void clif_hercules_chsys_msg2(struct hChSysCh *channel, char *msg) {
WBUFW(buf,0) = 0x2C1;
WBUFW(buf,2) = msg_len + 12;
WBUFL(buf,4) = 0;
- WBUFL(buf,8) = hChSys.colors[channel->color];
+ WBUFL(buf,8) = clif->hChSys->colors[channel->color];
safestrncpy((char*)WBUFP(buf,12), msg, msg_len);
for( user = dbi_first(iter); dbi_exists(iter); user = dbi_next(iter) ) {
@@ -9248,11 +9261,11 @@ void clif_hercules_chsys_mjoin(struct map_session_data *sd) {
return;
CREATE(map->list[sd->bl.m].channel, struct hChSysCh , 1);
- safestrncpy(map->list[sd->bl.m].channel->name, hChSys.local_name, HCHSYS_NAME_LENGTH);
+ safestrncpy(map->list[sd->bl.m].channel->name, clif->hChSys->local_name, HCHSYS_NAME_LENGTH);
map->list[sd->bl.m].channel->type = hChSys_MAP;
map->list[sd->bl.m].channel->m = sd->bl.m;
- clif->chsys_create(map->list[sd->bl.m].channel,NULL,NULL,hChSys.local_color);
+ clif->chsys_create(map->list[sd->bl.m].channel, NULL, NULL, clif->hChSys->local_color);
}
if( map->list[sd->bl.m].channel->banned && idb_exists(map->list[sd->bl.m].channel->banned, sd->status.account_id) ) {
@@ -9263,7 +9276,7 @@ void clif_hercules_chsys_mjoin(struct map_session_data *sd) {
if( !( map->list[sd->bl.m].channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) {
char mout[60];
- sprintf(mout, msg_txt(1435),hChSys.local_name,map->list[sd->bl.m].name); // You're now in the '#%s' channel for '%s'
+ sprintf(mout, msg_txt(1435), clif->hChSys->local_name, map->list[sd->bl.m].name); // You're now in the '#%s' channel for '%s'
clif->colormes(sd->fd, COLOR_DEFAULT, mout);
}
}
@@ -9340,7 +9353,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
sd->state.hpmeter_visible = 1;
}
- if( !(sd->sc.option&OPTION_INVISIBLE) ) { // increment the number of pvp players on the map
+ if (!pc_isinvisible(sd)) { // increment the number of pvp players on the map
map->list[sd->bl.m].users_pvp++;
}
@@ -9361,7 +9374,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
if( sd->bg_id ) clif->bg_hp(sd); // BattleGround System
- if(map->list[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) {
+ if (map->list[sd->bl.m].flag.pvp && !pc_isinvisible(sd)) {
if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris]
if (!map->list[sd->bl.m].flag.pvp_nocalcrank)
sd->pvp_timer = timer->add(timer->gettick()+200, pc->calc_pvprank_timer, sd->bl.id, 0);
@@ -9397,7 +9410,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
clif->spawn(&sd->pd->bl);
clif->send_petdata(sd,sd->pd,0,0);
clif->send_petstatus(sd);
-// skill->unit_move(&sd->pd->bl,timer->gettick(),1);
+ //skill->unit_move(&sd->pd->bl,timer->gettick(),1);
}
}
@@ -9446,11 +9459,11 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
clif->updatestatus(sd,SP_SKILLPOINT);
clif->initialstatus(sd);
- if (sd->sc.option&OPTION_FALCON)
+ if (pc_isfalcon(sd))
clif->status_change(&sd->bl, SI_FALCON, 1, 0, 0, 0, 0);
- if (sd->sc.option&(OPTION_RIDING|OPTION_DRAGON))
+ if (pc_isridingpeco(sd) || pc_isridingdragon(sd))
clif->status_change(&sd->bl, SI_RIDING, 1, 0, 0, 0, 0);
- else if (sd->sc.option&OPTION_WUGRIDER)
+ else if (pc_isridingwug(sd))
clif->status_change(&sd->bl, SI_WUGRIDER, 1, 0, 0, 0, 0);
if(sd->status.manner < 0)
@@ -9538,7 +9551,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
status_calc_pc(sd, SCO_NONE);/* some conditions are map-dependent so we must recalculate */
sd->state.changemap = false;
- if( hChSys.local && hChSys.local_autojoin ) {
+ if (clif->hChSys->local && clif->hChSys->local_autojoin) {
clif->chsys_mjoin(sd);
}
}
@@ -9584,7 +9597,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
if (map->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC))
npc->touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y);
else
- sd->areanpc_id = 0;
+ npc->untouch_areanpc(sd, sd->bl.m, sd->bl.x, sd->bl.y);
/* it broke at some point (e.g. during a crash), so we make it visibly dead again. */
if( !sd->status.hp && !pc_isdead(sd) && status->isdead(&sd->bl) )
@@ -9651,18 +9664,22 @@ void clif_hotkeys_send(struct map_session_data *sd) {
#ifdef HOTKEY_SAVING
const int fd = sd->fd;
int i;
+ int offset = 2;
#if PACKETVER < 20090603
const int cmd = 0x2b9;
-#else
+#elif PACKETVER < 20141022
const int cmd = 0x7d9;
+#else
+ const int cmd = 0xa00;
+ offset = 3;
#endif
if (!fd) return;
- WFIFOHEAD(fd, 2+MAX_HOTKEYS*7);
+ WFIFOHEAD(fd, offset+MAX_HOTKEYS*7);
WFIFOW(fd, 0) = cmd;
for(i = 0; i < MAX_HOTKEYS; i++) {
- WFIFOB(fd, 2 + 0 + i * 7) = sd->status.hotkeys[i].type; // type: 0: item, 1: skill
- WFIFOL(fd, 2 + 1 + i * 7) = sd->status.hotkeys[i].id; // item or skill ID
- WFIFOW(fd, 2 + 5 + i * 7) = sd->status.hotkeys[i].lv; // skill level
+ WFIFOB(fd, offset + 0 + i * 7) = sd->status.hotkeys[i].type; // type: 0: item, 1: skill
+ WFIFOL(fd, offset + 1 + i * 7) = sd->status.hotkeys[i].id; // item or skill ID
+ WFIFOW(fd, offset + 5 + i * 7) = sd->status.hotkeys[i].lv; // item qty or skill level
}
WFIFOSET(fd, packet_len(cmd));
#endif
@@ -9786,7 +9803,7 @@ void clif_disconnect_ack(struct map_session_data* sd, short result)
/// 0 = quit
void clif_parse_QuitGame(int fd, struct map_session_data *sd)
{
- /* Rovert's prevent logout option fixed [Valaris] */
+ /* Rovert's prevent logout option fixed [Valaris] */
if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] && !sd->sc.data[SC__INVISIBILITY] &&
(!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) )
{
@@ -9813,7 +9830,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) {
bl = map->id2bl(id);
if( bl == NULL )
- return; // Lagged clients could request names of already gone mobs/players. [Skotlex]
+ return; // Lagged clients could request names of already gone mobs/players. [Skotlex]
if( sd->bl.m != bl->m || !check_distance_bl(&sd->bl, bl, AREA_SIZE) )
return; // Block namerequests past view range
@@ -9921,7 +9938,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
sd->fontcolor_tid = timer->add(timer->gettick()+5000, clif->undisguise_timer, sd->bl.id, 0);
pc->disguise(sd,sd->status.class_);
if( pc_isdead(sd) )
- clif_clearunit_single(-sd->bl.id, CLR_DEAD, sd->fd);
+ clif->clearunit_single(-sd->bl.id, CLR_DEAD, sd->fd);
if( unit->is_walking(&sd->bl) )
clif->move(&sd->ud);
} else if ( sd->disguise == sd->status.class_ && sd->fontcolor_tid != INVALID_TIMER ) {
@@ -9937,7 +9954,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
WFIFOW(fd,0) = 0x2C1;
WFIFOW(fd,2) = mylen + 12;
WFIFOL(fd,4) = sd->bl.id;
- WFIFOL(fd,8) = hChSys.colors[sd->fontcolor - 1];
+ WFIFOL(fd,8) = clif->hChSys->colors[sd->fontcolor - 1];
safestrncpy((char*)WFIFOP(fd,12), mout, mylen);
clif->send(WFIFOP(fd,0), WFIFOW(fd,2), &sd->bl, AREA_WOS);
WFIFOL(fd,4) = -sd->bl.id;
@@ -10123,7 +10140,8 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type,
)
return;
- pc_stop_walking(sd, 1);
+ if(action_type != 0x00 && action_type != 0x07)
+ pc_stop_walking(sd, 1);
pc_stop_attack(sd);
if(target_id<0 && -target_id == sd->bl.id) // for disguises [Valaris]
@@ -10173,6 +10191,7 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type,
if (sd->sc.count && (
sd->sc.data[SC_DANCING] ||
+ sd->sc.data[SC_ANKLESNARE] ||
(sd->sc.data[SC_GRAVITATION] && sd->sc.data[SC_GRAVITATION]->val3 == BCT_SELF)
)) //No sitting during these states either.
break;
@@ -10212,7 +10231,7 @@ void clif_hercules_chsys_left(struct hChSysCh *channel, struct map_session_data
if( !db_size(channel->users) && channel->type == hChSys_PRIVATE ) {
clif->chsys_delete(channel);
- } else if( !hChSys.closing && (channel->opt & hChSys_OPT_ANNOUNCE_JOIN) ) {
+ } else if( !clif->hChSys->closing && (channel->opt & hChSys_OPT_ANNOUNCE_JOIN) ) {
char message[60];
sprintf(message, "#%s '%s' left",channel->name,sd->status.name);
clif->chsys_msg(channel,sd,message);
@@ -10256,9 +10275,9 @@ void clif_hercules_chsys_quitg(struct map_session_data *sd) {
if( channel == sd->gcbind )
sd->gcbind = NULL;
- if( !db_size(channel->users) && channel->type == hChSys_PRIVATE ) {
+ if (!db_size(channel->users) && channel->type == hChSys_PRIVATE) {
clif->chsys_delete(channel);
- } else if( !hChSys.closing && (channel->opt & hChSys_OPT_ANNOUNCE_JOIN) ) {
+ } else if (!clif->hChSys->closing && (channel->opt & hChSys_OPT_ANNOUNCE_JOIN)) {
char message[60];
sprintf(message, "#%s '%s' left",channel->name,sd->status.name);
clif->chsys_msg(channel,sd,message);
@@ -10297,9 +10316,9 @@ void clif_hercules_chsys_quit(struct map_session_data *sd) {
if( channel == sd->gcbind )
sd->gcbind = NULL;
- if( !db_size(channel->users) && channel->type == hChSys_PRIVATE ) {
+ if (!db_size(channel->users) && channel->type == hChSys_PRIVATE) {
clif->chsys_delete(channel);
- } else if( !hChSys.closing && (channel->opt & hChSys_OPT_ANNOUNCE_JOIN) ) {
+ } else if (!clif->hChSys->closing && (channel->opt & hChSys_OPT_ANNOUNCE_JOIN)) {
char message[60];
sprintf(message, "#%s '%s' left",channel->name,sd->status.name);
clif->chsys_msg(channel,sd,message);
@@ -10345,10 +10364,12 @@ void clif_parse_Restart(int fd, struct map_session_data *sd) {
pc->respawn(sd,CLR_OUTSIGHT);
break;
case 0x01:
- /* Rovert's Prevent logout option - Fixed [Valaris] */
- if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] && !sd->sc.data[SC__INVISIBILITY] &&
- (!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) )
- { //Send to char-server for character selection.
+ /* Rovert's Prevent logout option - Fixed [Valaris] */
+ if (!sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK]
+ && !sd->sc.data[SC_CLOAKINGEXCEED] && !sd->sc.data[SC__INVISIBILITY]
+ && (!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout)
+ ) {
+ //Send to char-server for character selection.
chrif->charselectreq(sd, session[fd]->client_addr);
} else {
clif->disconnect_ack(sd, 1);
@@ -10436,12 +10457,12 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
chname++;
- if( hChSys.local && strcmpi(chname, hChSys.local_name) == 0 ) {
+ if (clif->hChSys->local && strcmpi(chname, clif->hChSys->local_name) == 0) {
if( !map->list[sd->bl.m].channel ) {
clif->chsys_mjoin(sd);
}
channel = map->list[sd->bl.m].channel;
- } else if( hChSys.ally && sd->status.guild_id && strcmpi(chname, hChSys.ally_name) == 0 ) {
+ } else if (clif->hChSys->ally && sd->status.guild_id && strcmpi(chname, clif->hChSys->ally_name) == 0) {
struct guild *g = sd->guild;
if( !g ) return;
channel = g->channel;
@@ -10488,7 +10509,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
// if player ignores everyone
if (dstsd->state.ignoreAll && pc_get_group_level(sd) <= pc_get_group_level(dstsd)) {
- if (dstsd->sc.option & OPTION_INVISIBLE && pc_get_group_level(sd) < pc_get_group_level(dstsd))
+ if (pc_isinvisible(dstsd) && pc_get_group_level(sd) < pc_get_group_level(dstsd))
clif->wis_end(fd, 1); // 1: target character is not logged in
else
clif->wis_end(fd, 3); // 3: everyone ignored by target
@@ -10496,7 +10517,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
}
// if player is autotrading
- if( dstsd->state.autotrade == 1 ) {
+ if( dstsd->state.autotrade ) {
char output[256];
sprintf(output, "%s is in autotrade mode and cannot receive whispered messages.", dstsd->status.name);
clif->wis_message(fd, map->wisp_server_name, output, strlen(output) + 1);
@@ -10692,7 +10713,7 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd) {
}
void clif_hercules_chsys_delete(struct hChSysCh *channel) {
- if( db_size(channel->users) && !hChSys.closing ) {
+ if (db_size(channel->users) && !clif->hChSys->closing) {
DBIterator *iter;
struct map_session_data *sd;
unsigned char i;
@@ -10732,7 +10753,7 @@ void clif_hercules_chsys_delete(struct hChSysCh *channel) {
aFree(channel);
} else if ( channel->type == hChSys_ALLY )
aFree(channel);
- else if( !hChSys.closing )
+ else if (!clif->hChSys->closing)
strdb_remove(clif->channel_db, channel->name);
}
void clif_hercules_chsys_gjoin(struct guild *g1,struct guild *g2) {
@@ -10817,7 +10838,7 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
struct block_list *bl;
if( pc_isdead(sd) ) {
- clif_clearunit_area(&sd->bl,CLR_DEAD);
+ clif->clearunit_area(&sd->bl,CLR_DEAD);
return;
}
if( sd->npc_id || sd->state.workinprogress&2 ){
@@ -10886,7 +10907,7 @@ void clif_parse_NpcBuyListSend(int fd, struct map_session_data* sd)
unsigned short* item_list = (unsigned short*)RFIFOP(fd,4);
int result;
- if( sd->state.trading || !sd->npc_shopid )
+ if( sd->state.trading || !sd->npc_shopid || pc_has_permission(sd,PC_PERM_DISABLE_STORE) )
result = 1;
else
result = npc->buylist(sd,n,item_list);
@@ -11162,16 +11183,17 @@ void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd)
/// 012a
void clif_parse_RemoveOption(int fd,struct map_session_data *sd)
{
- if( !(sd->sc.option&(OPTION_RIDING|OPTION_FALCON|OPTION_DRAGON|OPTION_MADOGEAR))
+ if (pc_isridingpeco(sd) || pc_isfalcon(sd) || pc_isridingdragon(sd) || pc_ismadogear(sd)) {
+ // priority to remove this option before we can clear cart
+ pc->setoption(sd,sd->sc.option&~(OPTION_RIDING|OPTION_FALCON|OPTION_DRAGON|OPTION_MADOGEAR));
+ } else {
#ifdef NEW_CARTS
- && sd->sc.data[SC_PUSH_CART] ){
- pc->setcart(sd,0);
-#else
- ){
+ if (sd->sc.data[SC_PUSH_CART])
+ pc->setcart(sd,0);
+#else // not NEW_CARTS
pc->setoption(sd,sd->sc.option&~OPTION_CART);
-#endif
- }else // priority to remove this option before we can clear cart
- pc->setoption(sd,sd->sc.option&~(OPTION_RIDING|OPTION_FALCON|OPTION_DRAGON|OPTION_MADOGEAR));
+#endif // NEW_CARTS
+ }
}
@@ -11247,15 +11269,23 @@ void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_dat
if( !hd )
return;
- if( skill->not_ok_hom(skill_id, hd) )
+ if (skill->not_ok_hom(skill_id, hd)){
+ clif->emotion(&hd->bl, E_DOTS);
return;
- if( hd->bl.id != target_id && skill->get_inf(skill_id)&INF_SELF_SKILL )
+ }
+ if (hd->bl.id != target_id && skill->get_inf(skill_id)&INF_SELF_SKILL)
target_id = hd->bl.id;
- if( hd->ud.skilltimer != INVALID_TIMER ) {
- if( skill_id != SA_CASTCANCEL && skill_id != SO_SPELLFIST ) return;
- } else if( DIFF_TICK(tick, hd->ud.canact_tick) < 0 )
+ if (hd->ud.skilltimer != INVALID_TIMER) {
+ if (skill_id != SA_CASTCANCEL && skill_id != SO_SPELLFIST) return;
+ }
+ else if (DIFF_TICK(tick, hd->ud.canact_tick) < 0){
+ clif->emotion(&hd->bl, E_DOTS);
+ if (hd->master)
+ clif->skill_fail(hd->master, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0);
return;
+ }
+
lv = homun->checkskill(hd, skill_id);
if( skill_lv > lv )
skill_lv = lv;
@@ -11267,12 +11297,19 @@ void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_da
int lv;
if( !hd )
return;
- if( skill->not_ok_hom(skill_id, hd) )
+ if (skill->not_ok_hom(skill_id, hd)){
+ clif->emotion(&hd->bl, E_DOTS);
return;
- if( hd->ud.skilltimer != INVALID_TIMER ) {
- if( skill_id != SA_CASTCANCEL && skill_id != SO_SPELLFIST ) return;
- } else if( DIFF_TICK(tick, hd->ud.canact_tick) < 0 )
+ }
+ if ( hd->ud.skilltimer != INVALID_TIMER ) {
+ if ( skill_id != SA_CASTCANCEL && skill_id != SO_SPELLFIST ) return;
+
+ } else if ( DIFF_TICK(tick, hd->ud.canact_tick) < 0 ) {
+ clif->emotion(&hd->bl, E_DOTS);
+ if ( hd->master )
+ clif->skill_fail(hd->master, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0);
return;
+ }
if( hd->sc.data[SC_BASILICA] )
return;
@@ -11413,7 +11450,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
if( skill_lv != sd->skillitemlv )
skill_lv = sd->skillitemlv;
if( !(tmp&INF_SELF_SKILL) )
- pc->delinvincibletimer(sd); // Target skills thru items cancel invincibility. [Inkfish]
+ pc->delinvincibletimer(sd); // Target skills through items cancel invincibility. [Inkfish]
unit->skilluse_id(&sd->bl, target_id, skill_id, skill_lv);
return;
}
@@ -11536,7 +11573,7 @@ void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd)
RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[1]), //skill num
RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[2]), //pos x
RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[3]), //pos y
- -1 //Skill more info.
+ -1 //Skill more info.
);
}
@@ -12215,8 +12252,7 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd)
if( sd->sc.data[SC_BERSERK] || (sd->sc.data[SC_DEEP_SLEEP] && sd->sc.data[SC_DEEP_SLEEP]->val2) || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
return;
- if( battle_config.min_chat_delay )
- { //[Skotlex]
+ if (battle_config.min_chat_delay) {
if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0)
return;
sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay;
@@ -12234,7 +12270,7 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd)
void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd) {
party->changeleader(sd, map->id2sd(RFIFOL(fd,2)));
}
-
+
/// Party Booking in KRO [Spiria]
///
@@ -12721,11 +12757,11 @@ void clif_parse_PartyBookingAckRecall(int fd, struct map_session_data *sd)
/// 08f8 <caller AID>.L <reason>.B
/// <reason>:
-/// REASON_PROHIBITION = 0x0
-/// REASON_MASTER_IN_PROHIBITION_MAP = 0x1
-/// REASON_REFUSE = 0x2
-/// REASON_NOT_PARTY_MEMBER = 0x3
-/// REASON_ETC = 0x4
+/// REASON_PROHIBITION = 0x0
+/// REASON_MASTER_IN_PROHIBITION_MAP = 0x1
+/// REASON_REFUSE = 0x2
+/// REASON_NOT_PARTY_MEMBER = 0x3
+/// REASON_ETC = 0x4
void clif_PartyBookingFailedRecall(int fd, struct map_session_data *sd)
{
}
@@ -12951,22 +12987,22 @@ void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd)
return;
switch( RFIFOL(fd,2) ) {
- case 0: // Basic Information Guild, hostile alliance information
+ case 0: // Basic Information Guild, hostile alliance information
clif->guild_basicinfo(sd);
clif->guild_allianceinfo(sd);
break;
- case 1: // Members list, list job title
+ case 1: // Members list, list job title
clif->guild_positionnamelist(sd);
clif->guild_memberlist(sd);
break;
- case 2: // List job title, title information list
+ case 2: // List job title, title information list
clif->guild_positionnamelist(sd);
clif->guild_positioninfolist(sd);
break;
- case 3: // Skill list
+ case 3: // Skill list
clif->guild_skillinfo(sd);
break;
- case 4: // Expulsion list
+ case 4: // Expulsion list
clif->guild_expulsionlist(sd);
break;
default:
@@ -13278,8 +13314,7 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd)
if( sd->sc.data[SC_BERSERK] || (sd->sc.data[SC_DEEP_SLEEP] && sd->sc.data[SC_DEEP_SLEEP]->val2) || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
return;
- if( battle_config.min_chat_delay )
- { //[Skotlex]
+ if (battle_config.min_chat_delay) {
if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0)
return;
sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay;
@@ -14259,8 +14294,8 @@ void clif_PVPInfo(struct map_session_data* sd) {
WFIFOW(fd,0) = 0x210;
WFIFOL(fd,2) = sd->status.char_id;
WFIFOL(fd,6) = sd->status.account_id;
- WFIFOL(fd,10) = sd->pvp_won; // times won
- WFIFOL(fd,14) = sd->pvp_lost; // times lost
+ WFIFOL(fd,10) = sd->pvp_won; // times won
+ WFIFOL(fd,14) = sd->pvp_lost; // times lost
WFIFOL(fd,18) = sd->pvp_point;
WFIFOSET(fd, packet_len(0x210));
}
@@ -14318,7 +14353,7 @@ void clif_ranklist(struct map_session_data *sd, enum fame_list_type type) {
WFIFOW(fd, 0) = 0x97d;
WFIFOW(fd, 2) = type;
clif_ranklist_sub(WFIFOP(fd,4), type);
-
+
if( (upperMask == MAPID_BLACKSMITH && type == RANKTYPE_BLACKSMITH)
|| (upperMask == MAPID_ALCHEMIST && type == RANKTYPE_ALCHEMIST)
|| (upperMask == MAPID_TAEKWON && type == RANKTYPE_TAEKWON)
@@ -14493,9 +14528,10 @@ void clif_parse_FeelSaveOk(int fd,struct map_session_data *sd)
sd->feel_map[i].m = sd->bl.m;
pc_setglobalreg(sd,script->add_str(pc->sg_info[i].feel_var),sd->feel_map[i].index);
-//Are these really needed? Shouldn't they show up automatically from the feel save packet?
-// clif_misceffect2(&sd->bl, 0x1b0);
-// clif_misceffect2(&sd->bl, 0x21f);
+#if 0 // Are these really needed? Shouldn't they show up automatically from the feel save packet?
+ clif_misceffect2(&sd->bl, 0x1b0);
+ clif_misceffect2(&sd->bl, 0x21f);
+#endif // 0
clif->feel_info(sd, i, 0);
clif_menuskill_clear(sd);
}
@@ -15116,7 +15152,8 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
if (body_len > MAIL_BODY_LENGTH)
body_len = MAIL_BODY_LENGTH;
- if( !mail->setattachment(sd, &msg) ) { // Invalid Append condition
+ memset(&msg, 0, sizeof(msg));
+ if (!mail->setattachment(sd, &msg)) { // Invalid Append condition
clif->mail_send(sd->fd, true); // fail
mail->removeitem(sd,0);
mail->removezeny(sd,0);
@@ -15281,7 +15318,7 @@ void clif_parse_Auction_setitem(int fd, struct map_session_data *sd)
!sd->status.inventory[idx].identify ||
!itemdb_canauction(&sd->status.inventory[idx],pc_get_group_level(sd)) || // Quest Item or something else
(sd->status.inventory[idx].bound && !pc_can_give_bound_items(sd)) ) {
- clif->auction_setitem(sd->fd, idx, true);
+ clif->auction_setitem(sd->fd, idx, true);
return;
}
@@ -15334,9 +15371,10 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd)
struct auction_data auction;
struct item_data *item;
- if( !battle_config.feature_auction )
+ if (!battle_config.feature_auction)
return;
+ memset(&auction, 0, sizeof(auction));
auction.price = RFIFOL(fd,2);
auction.buynow = RFIFOL(fd,6);
auction.hours = RFIFOW(fd,10);
@@ -15391,7 +15429,7 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd)
if( sd->status.inventory[sd->auction.index].bound && !pc_can_give_bound_items(sd) ) {
clif->message(sd->fd, msg_txt(293));
clif->auction_message(fd, 2); // The auction has been canceled
- return;
+ return;
}
safestrncpy(auction.item_name, item->jname, sizeof(auction.item_name));
@@ -15568,7 +15606,7 @@ void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd) {
/// For error return codes see enum cashshop_error@clif.h
void clif_cashshop_ack(struct map_session_data* sd, int error) {
struct npc_data *nd;
- int fd = sd->fd;
+ int fd = sd->fd;
int currency[2] = { 0,0 };
if( (nd = map->id2nd(sd->npc_shopid)) && nd->subtype == SCRIPT ) {
@@ -15599,34 +15637,33 @@ void clif_cashshop_ack(struct map_session_data* sd, int error) {
/// 0288 <packet len>.W <kafra points>.L <count>.W { <amount>.W <name id>.W }.4B*count (PACKETVER >= 20100803)
void clif_parse_cashshop_buy(int fd, struct map_session_data *sd)
{
- int fail = 0;
- nullpo_retv(sd);
+ int fail = 0;
+ nullpo_retv(sd);
- if( sd->state.trading || !sd->npc_shopid )
- fail = 1;
- else {
+ if( sd->state.trading || !sd->npc_shopid || pc_has_permission(sd,PC_PERM_DISABLE_STORE) )
+ fail = 1;
+ else {
#if PACKETVER < 20101116
- short nameid = RFIFOW(fd,2);
- short amount = RFIFOW(fd,4);
- int points = RFIFOL(fd,6);
+ short nameid = RFIFOW(fd,2);
+ short amount = RFIFOW(fd,4);
+ int points = RFIFOL(fd,6);
- fail = npc->cashshop_buy(sd, nameid, amount, points);
+ fail = npc->cashshop_buy(sd, nameid, amount, points);
#else
- int len = RFIFOW(fd,2);
- int points = RFIFOL(fd,4);
- int count = RFIFOW(fd,8);
- unsigned short* item_list = (unsigned short*)RFIFOP(fd,10);
-
- if( len < 10 || len != 10 + count * 4)
- {
- ShowWarning("Player %u sent incorrect cash shop buy packet (len %u:%u)!\n", sd->status.char_id, len, 10 + count * 4);
- return;
- }
- fail = npc->cashshop_buylist(sd,points,count,item_list);
+ int len = RFIFOW(fd,2);
+ int points = RFIFOL(fd,4);
+ int count = RFIFOW(fd,8);
+ unsigned short* item_list = (unsigned short*)RFIFOP(fd,10);
+
+ if( len < 10 || len != 10 + count * 4) {
+ ShowWarning("Player %u sent incorrect cash shop buy packet (len %u:%u)!\n", sd->status.char_id, len, 10 + count * 4);
+ return;
+ }
+ fail = npc->cashshop_buylist(sd,points,count,item_list);
#endif
- }
+ }
- clif->cashshop_ack(sd,fail);
+ clif->cashshop_ack(sd,fail);
}
@@ -15795,18 +15832,33 @@ void clif_parse_PartyTick(int fd, struct map_session_data* sd)
void clif_quest_send_list(struct map_session_data *sd) {
int fd = sd->fd;
int i;
- int len = sd->avail_quests*5+8;
-
+#if PACKETVER >= 20141022
+ int info_len = 15;
+ int len = sd->avail_quests*info_len+8;
+ WFIFOHEAD(fd,len);
+ WFIFOW(fd, 0) = 0x97a;
+#else
+ int info_len = 5;
+ int len = sd->avail_quests*info_len+8;
WFIFOHEAD(fd,len);
WFIFOW(fd, 0) = 0x2b1;
+#endif
WFIFOW(fd, 2) = len;
WFIFOL(fd, 4) = sd->avail_quests;
for( i = 0; i < sd->avail_quests; i++ ) {
- WFIFOL(fd, i*5+8) = sd->quest_log[i].quest_id;
- WFIFOB(fd, i*5+12) = sd->quest_log[i].state;
+ #if PACKETVER >= 20141022
+ struct quest_db *qi = quest->db(sd->quest_log[i].quest_id);
+ #endif
+ WFIFOL(fd, i*info_len+8) = sd->quest_log[i].quest_id;
+ WFIFOB(fd, i*info_len+12) = sd->quest_log[i].state;
+ #if PACKETVER >= 20141022
+ WFIFOL(fd, i*info_len+13) = sd->quest_log[i].time - qi->time;
+ WFIFOL(fd, i*info_len+17) = sd->quest_log[i].time;
+ WFIFOW(fd, i*info_len+21) = qi->num_objectives;
+ #endif
}
-
+
WFIFOSET(fd, len);
}
@@ -16566,8 +16618,8 @@ void clif_parse_ItemListWindowSelected(int fd, struct map_session_data* sd) {
case 0: // Change Material
skill->changematerial(sd,n,item_list);
break;
- case 1: // Level 1: Pure to Rough
- case 2: // Level 2: Rough to Pure
+ case 1: // Level 1: Pure to Rough
+ case 2: // Level 2: Rough to Pure
skill->elementalanalysis(sd,n,type,item_list);
break;
}
@@ -17406,10 +17458,13 @@ void clif_charm(struct map_session_data *sd,short type)
nullpo_retv(sd);
+ if ( type <= SPIRITS_TYPE_NONE || type >= SPIRITS_TYPE_SPHERE )
+ return;
+
WBUFW(buf,0)=0x08cf;
WBUFL(buf,2)=sd->bl.id;
WBUFW(buf,6)=type;
- WBUFW(buf,8)=sd->charm[type];
+ WBUFW(buf,8)=sd->spiritcharm[type];
clif->send(buf,packet_len(0x08cf),&sd->bl,AREA);
}
/// Move Item from or to Personal Tab (CZ_WHATSOEVER) [FE]
@@ -17417,8 +17472,8 @@ void clif_charm(struct map_session_data *sd,short type)
///
/// R 0908 <index>.w <type>.b
/// type:
-/// 0 = move item to personal tab
-/// 1 = move item to normal tab
+/// 0 = move item to personal tab
+/// 1 = move item to normal tab
void clif_parse_MoveItem(int fd, struct map_session_data *sd) {
#if PACKETVER >= 20111122
int index;
@@ -17697,13 +17752,17 @@ void clif_parse_CashShopReqTab(int fd, struct map_session_data *sd) {
void clif_maptypeproperty2(struct block_list *bl,enum send_target t) {
#if PACKETVER >= 20121010
struct packet_maptypeproperty2 p;
+ struct map_session_data *sd = NULL;
+ nullpo_retv(bl);
+
+ sd = BL_CAST(BL_PC, bl);
p.PacketType = maptypeproperty2Type;
p.type = 0x28;
p.flag.party = map->list[bl->m].flag.pvp ? 1 : 0;
- p.flag.guild = map_flag_gvg(bl->m) ? 1 : 0;
- p.flag.siege = map_flag_gvg2(bl->m) ? 1: 0;
- p.flag.mineffect = map_flag_gvg(bl->m); // FIXME/CHECKME Forcing /mineffect in castles during WoE (probably redundant? I'm not sure)
+ p.flag.guild = (map->list[bl->m].flag.battleground || map_flag_gvg(bl->m)) ? 1 : 0;
+ p.flag.siege = (map->list[bl->m].flag.battleground || map_flag_gvg2(bl->m)) ? 1: 0;
+ p.flag.mineffect = map_flag_gvg(bl->m) ? 1 : ( (sd && sd->state.lesseffect) ? 1 : 0); // Forcing /mineffect in castles during WoE (probably redundant? I'm not sure)
p.flag.nolockon = 0; // TODO
p.flag.countpk = map->list[bl->m].flag.pvp ? 1 : 0;
p.flag.nopartyformation = map->list[bl->m].flag.partylock ? 1 : 0;
@@ -17836,7 +17895,7 @@ void clif_bgqueue_update_info(struct map_session_data *sd, unsigned char arena_i
safestrncpy(p.bg_name, bg->arena[arena_id]->name, sizeof(p.bg_name));
p.position = position;
- sd->bg_queue.client_has_bg_data = true; // Client creates bg data when this packet arrives
+ sd->bg_queue.client_has_bg_data = true; // Client creates bg data when this packet arrives
clif->send(&p,sizeof(p), &sd->bl, SELF);
}
@@ -18254,6 +18313,296 @@ void clif_parse_NPCMarketPurchase(int fd, struct map_session_data *sd) {
clif->npc_market_purchase_ack(sd,p,npc->market_buylist(sd,(p->PacketLength - 4) / sizeof(p->list[0]),p));
#endif
}
+
+void clif_PartyLeaderChanged(struct map_session_data *sd, int prev_leader_aid, int new_leader_aid) {
+ struct packet_party_leader_changed p;
+
+ p.PacketType = partyleaderchangedType;
+
+ p.prev_leader_aid = prev_leader_aid;
+ p.new_leader_aid = new_leader_aid;
+
+ clif->send(&p,sizeof(p),&sd->bl,PARTY);
+}
+
+/* Roulette System [Yommy/Hercules] */
+void clif_parse_RouletteOpen(int fd, struct map_session_data* sd) {
+ struct packet_roulette_open_ack p;
+
+ if( !battle_config.feature_roulette ) {
+ clif->message(fd,"Roulette is disabled");
+ return;
+ }
+
+ p.PacketType = 0xa1a;
+ p.Result = 0;
+ p.Serial = 0;
+ p.Step = sd->roulette.stage - 1;
+ p.Idx = (char)sd->roulette.prizeIdx;
+ p.AdditionItemID = -1; /** TODO **/
+ p.BronzePoint = pc_readglobalreg(sd, script->add_str("TmpRouletteBronze"));
+ p.GoldPoint = pc_readglobalreg(sd, script->add_str("TmpRouletteGold"));
+ p.SilverPoint = pc_readglobalreg(sd, script->add_str("TmpRouletteSilver"));
+
+ clif->send(&p,sizeof(p), &sd->bl, SELF);
+}
+void clif_parse_RouletteInfo(int fd, struct map_session_data* sd) {
+ struct packet_roulette_info_ack p;
+ unsigned short i, j, count = 0;
+
+ if( !battle_config.feature_roulette ) {
+ clif->message(fd,"Roulette is disabled");
+ return;
+ }
+
+ p.PacketType = rouletteinfoackType;
+ p.PacketLength = 8 + (42 * 8);
+ p.RouletteSerial = 1;
+
+ for(i = 0; i < MAX_ROULETTE_LEVEL; i++) {
+ for(j = 0; j < MAX_ROULETTE_COLUMNS-i; j++) {
+ p.ItemInfo[count].Row = i;
+ p.ItemInfo[count].Position = j;
+ p.ItemInfo[count].ItemId = clif->rd.nameid[i][j];
+ p.ItemInfo[count].Count = clif->rd.qty[i][j];
+ count++;
+ }
+ }
+
+ clif->send(&p,sizeof(p), &sd->bl, SELF);
+ return;
+}
+void clif_parse_RouletteClose(int fd, struct map_session_data* sd) {
+
+ if( !battle_config.feature_roulette ) {
+ clif->message(fd,"Roulette is disabled");
+ return;
+ }
+
+
+ /** What do we need this for? (other than state tracking), game client closes the window without our response. **/
+
+ //ShowDebug("clif_parse_RouletteClose\n");
+
+ return;
+}
+void clif_parse_RouletteGenerate(int fd, struct map_session_data* sd) {
+ unsigned char result = GENERATE_ROULETTE_SUCCESS;
+ short stage = sd->roulette.stage;
+
+ if( !battle_config.feature_roulette ) {
+ clif->message(fd,"Roulette is disabled");
+ return;
+ }
+
+ if( sd->roulette.stage >= MAX_ROULETTE_LEVEL )
+ stage = sd->roulette.stage = 0;
+
+ if( stage == 0 ) {
+ if( pc_readglobalreg(sd, script->add_str("TmpRouletteBronze")) <= 0 &&
+ pc_readglobalreg(sd, script->add_str("TmpRouletteSilver")) < 10 &&
+ pc_readglobalreg(sd, script->add_str("TmpRouletteGold")) < 10 )
+ result = GENERATE_ROULETTE_NO_ENOUGH_POINT;
+ }
+
+ if( result == GENERATE_ROULETTE_SUCCESS ) {
+
+ if( stage == 0 ) {
+ if( pc_readglobalreg(sd, script->add_str("TmpRouletteBronze")) > 0 ) {
+ pc_setglobalreg(sd, script->add_str("TmpRouletteBronze"), pc_readglobalreg(sd, script->add_str("TmpRouletteBronze")) - 1);
+ } else if( pc_readglobalreg(sd, script->add_str("TmpRouletteSilver")) > 9 ) {
+ pc_setglobalreg(sd, script->add_str("TmpRouletteSilver"), pc_readglobalreg(sd, script->add_str("TmpRouletteSilver")) - 10);
+ stage = sd->roulette.stage = 2;
+ } else if( pc_readglobalreg(sd, script->add_str("TmpRouletteGold")) > 9 ) {
+ pc_setglobalreg(sd, script->add_str("TmpRouletteGold"), pc_readglobalreg(sd, script->add_str("TmpRouletteGold")) - 10);
+ stage = sd->roulette.stage = 4;
+ }
+ }
+
+ sd->roulette.prizeStage = stage;
+ sd->roulette.prizeIdx = rnd()%clif->rd.items[stage];
+ if( sd->roulette.prizeIdx == 0 ) {
+ struct item it;
+ memset(&it, 0, sizeof(it));
+
+ it.nameid = clif->rd.nameid[stage][0];
+ it.identify = 1;
+
+ pc->additem(sd, &it, clif->rd.qty[stage][0], LOG_TYPE_OTHER);/** TODO maybe a new log type for roulette items? **/
+
+ sd->roulette.stage = 0;
+ result = GENERATE_ROULETTE_LOSING;
+ } else
+ sd->roulette.claimPrize = true;
+ }
+
+ clif->roulette_generate_ack(sd,result,stage,sd->roulette.prizeIdx,0);
+ if( result == GENERATE_ROULETTE_SUCCESS )
+ sd->roulette.stage++;
+}
+/**
+ * Request to cash in!
+ **/
+void clif_parse_RouletteRecvItem(int fd, struct map_session_data* sd) {
+ struct packet_roulette_itemrecv_ack p;
+
+ if( !battle_config.feature_roulette ) {
+ clif->message(fd,"Roulette is disabled");
+ return;
+ }
+
+ p.PacketType = roulettercvitemackType;
+ p.AdditionItemID = 0;/** TODO **/
+
+ if( sd->roulette.claimPrize ) {
+ struct item it;
+ memset(&it, 0, sizeof(it));
+
+ it.nameid = clif->rd.nameid[sd->roulette.prizeStage][sd->roulette.prizeIdx];
+ it.identify = 1;
+
+ switch (pc->additem(sd, &it, clif->rd.qty[sd->roulette.prizeStage][sd->roulette.prizeIdx], LOG_TYPE_OTHER)) {
+ case 0:
+ p.Result = RECV_ITEM_SUCCESS;
+ sd->roulette.claimPrize = false;
+ sd->roulette.prizeStage = 0;
+ sd->roulette.prizeIdx = 0;
+ sd->roulette.stage = 0;
+ break;
+ case 1:
+ case 4:
+ case 5:
+ p.Result = RECV_ITEM_OVERCOUNT;
+ break;
+ case 2:
+ p.Result = RECV_ITEM_OVERWEIGHT;
+ break;
+ default:
+ case 7:
+ p.Result = RECV_ITEM_FAILED;
+ break;
+ }
+ } else
+ p.Result = RECV_ITEM_FAILED;
+
+ clif->send(&p,sizeof(p), &sd->bl, SELF);
+ return;
+}
+
+bool clif_parse_roulette_db(void) {
+ config_t roulette_conf;
+ config_setting_t *roulette = NULL, *levels = NULL;
+ const char *config_filename = "db/roulette_db.conf"; // FIXME hardcoded name
+ int i, j, item_count_t = 0;
+
+ for( i = 0; i < MAX_ROULETTE_LEVEL; i++ ) {
+ clif->rd.items[i] = 0;
+ }
+
+ if (libconfig->read_file(&roulette_conf, config_filename)) {
+ ShowError("can't read %s\n", config_filename);
+ return false;
+ }
+
+ roulette = libconfig->lookup(&roulette_conf, "roulette");
+
+ if( roulette != NULL && (levels = libconfig->setting_get_elem(roulette, 0)) != NULL ) {
+ for(i = 0; i < MAX_ROULETTE_LEVEL; i++) {
+ config_setting_t *level;
+ char entry_name[10];
+
+ sprintf(entry_name,"level_%d",i+1);
+
+ if( (level = libconfig->setting_get_member(levels, entry_name)) != NULL ) {
+ int k, item_count = libconfig->setting_length(level);
+
+ for(k = 0; k < item_count; k++) {
+ config_setting_t *entry = libconfig->setting_get_elem(level,k);
+ const char *name = config_setting_name(entry);
+ int qty = libconfig->setting_get_int(entry);
+ struct item_data * data = NULL;
+
+ if( qty < 1 ) {
+ ShowWarning("roulette_db: unsupported qty '%d' for entry named '%s' in category '%s'\n", qty, name, entry_name);
+ continue;
+ }
+
+ if( name[0] == 'I' && name[1] == 'D' && strlen(name) <= 7 ) {
+ if( !( data = itemdb->exists(atoi(name+2))) ) {
+ ShowWarning("roulette_db: unknown item id '%s' in category '%s'\n", name+2, entry_name);
+ continue;
+ }
+ } else {
+ if( !( data = itemdb->search_name(name) ) ) {
+ ShowWarning("roulette_db: unknown item name '%s' in category '%s'\n", name, entry_name);
+ continue;
+ }
+ }
+
+ j = clif->rd.items[i];
+ RECREATE(clif->rd.nameid[i],int,++clif->rd.items[i]);
+ RECREATE(clif->rd.qty[i],int,clif->rd.items[i]);
+
+ clif->rd.nameid[i][j] = data->nameid;
+ clif->rd.qty[i][j] = qty;
+
+ item_count_t++;
+ }
+ }
+ }
+
+ libconfig->destroy(&roulette_conf);
+ }
+
+ for(i = 0; i < MAX_ROULETTE_LEVEL; i++) {
+ int limit = MAX_ROULETTE_COLUMNS-i;
+ if( clif->rd.items[i] == limit ) continue;
+
+ if( clif->rd.items[i] > limit ) {
+ ShowWarning("roulette_db: level %d has %d items, only %d supported, capping...\n",i+1,clif->rd.items[i],limit);
+ clif->rd.items[i] = limit;
+ continue;
+ }
+ /** this scenario = clif->rd.items[i] < limit **/
+ ShowWarning("roulette_db: level %d has %d items, %d are required. filling with apples\n",i+1,clif->rd.items[i],limit);
+
+ clif->rd.items[i] = limit;
+ RECREATE(clif->rd.nameid[i],int,clif->rd.items[i]);
+ RECREATE(clif->rd.qty[i],int,clif->rd.items[i]);
+
+
+ for(j = 0; j < MAX_ROULETTE_COLUMNS-i; j++) {
+ if( clif->rd.qty[i][j] ) continue;
+
+ clif->rd.nameid[i][j] = ITEMID_APPLE;
+ clif->rd.qty[i][j] = 1;
+ }
+ }
+
+
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", item_count_t, config_filename);
+
+ return true;
+}
+
+/**
+ *
+ **/
+void clif_roulette_generate_ack(struct map_session_data *sd, unsigned char result, short stage, short prizeIdx, short bonusItemID) {
+ struct packet_roulette_generate_ack p;
+
+ p.PacketType = roulettgenerateackType;
+ p.Result = result;
+ p.Step = stage;
+ p.Idx = prizeIdx;
+ p.AdditionItemID = bonusItemID;
+ p.RemainBronze = pc_readglobalreg(sd, script->add_str("TmpRouletteBronze"));
+ p.RemainGold = pc_readglobalreg(sd, script->add_str("TmpRouletteGold"));
+ p.RemainSilver = pc_readglobalreg(sd, script->add_str("TmpRouletteSilver"));
+
+ clif->send(&p,sizeof(p), &sd->bl, SELF);
+}
+
/* */
unsigned short clif_decrypt_cmd( int cmd, struct map_session_data *sd ) {
if( sd ) {
@@ -18533,7 +18882,7 @@ int do_init_clif(bool minimal) {
clif->delayed_damage_ers = ers_new(sizeof(struct cdelayed_damage),"clif.c::delayed_damage_ers",ERS_OPT_CLEAR);
clif->channel_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, HCHSYS_NAME_LENGTH);
- hChSys.ally = hChSys.local = hChSys.irc = hChSys.ally_autojoin = hChSys.local_autojoin = false;
+ clif->hChSys->ally = clif->hChSys->local = clif->hChSys->irc = clif->hChSys->ally_autojoin = clif->hChSys->local_autojoin = false;
clif->chann_config_read();
return 0;
@@ -18550,13 +18899,13 @@ void do_final_clif(void) {
dbi_destroy(iter);
- for(i = 0; i < hChSys.colors_count; i++) {
- aFree(hChSys.colors_name[i]);
+ for(i = 0; i < clif->hChSys->colors_count; i++) {
+ aFree(clif->hChSys->colors_name[i]);
}
- if( hChSys.colors_count ) {
- aFree(hChSys.colors_name);
- aFree(hChSys.colors);
+ if (clif->hChSys->colors_count) {
+ aFree(clif->hChSys->colors_name);
+ aFree(clif->hChSys->colors);
}
db_destroy(clif->channel_db);
@@ -18570,6 +18919,13 @@ void do_final_clif(void) {
}
aFree(clif->cs.data[i]);
}
+
+ for(i = 0; i < MAX_ROULETTE_LEVEL; i++) {
+ if( clif->rd.nameid[i] )
+ aFree(clif->rd.nameid[i]);
+ if( clif->rd.qty[i] )
+ aFree(clif->rd.qty[i]);
+ }
}
void clif_defaults(void) {
@@ -18588,6 +18944,7 @@ void clif_defaults(void) {
clif->refresh_ip = clif_refresh_ip;
clif->send = clif_send;
clif->send_sub = clif_send_sub;
+ clif->send_actual = clif_send_actual;
clif->parse = clif_parse;
clif->parse_cmd = clif_parse_cmd_optional;
clif->decrypt_cmd = clif_decrypt_cmd;
@@ -18632,6 +18989,7 @@ void clif_defaults(void) {
clif->changelook = clif_changelook;
clif->changetraplook = clif_changetraplook;
clif->refreshlook = clif_refreshlook;
+ clif->sendlook = clif_sendlook;
clif->class_change = clif_class_change;
clif->skill_delunit = clif_skill_delunit;
clif->skillunit_update = clif_skillunit_update;
@@ -18800,7 +19158,7 @@ void clif_defaults(void) {
clif->specialeffect_single = clif_specialeffect_single;
clif->specialeffect_value = clif_specialeffect_value;
clif->millenniumshield = clif_millenniumshield;
- clif->charm = clif_charm;
+ clif->spiritcharm = clif_charm;
clif->charm_single = clif_charm_single;
clif->snap = clif_snap;
clif->weather_check = clif_weather_check;
@@ -18884,6 +19242,7 @@ void clif_defaults(void) {
clif->party_xy_remove = clif_party_xy_remove;
clif->party_show_picker = clif_party_show_picker;
clif->partyinvitationstate = clif_partyinvitationstate;
+ clif->PartyLeaderChanged = clif_PartyLeaderChanged;
/* guild-specific */
clif->guild_created = clif_guild_created;
clif->guild_belonginfo = clif_guild_belonginfo;
@@ -19045,6 +19404,7 @@ void clif_defaults(void) {
clif->bc_ready = clif_bc_ready;
clif->undisguise_timer = clif_undisguise_timer;
/* Hercules Channel System */
+ clif->hChSys = &clif_hChSys;
clif->chsys_create = clif_hercules_chsys_create;
clif->chsys_msg = clif_hercules_chsys_msg;
clif->chsys_msg2 = clif_hercules_chsys_msg2;
@@ -19070,6 +19430,9 @@ void clif_defaults(void) {
/* NPC Market */
clif->npc_market_open = clif_npc_market_open;
clif->npc_market_purchase_ack = clif_npc_market_purchase_ack;
+ /* */
+ clif->parse_roulette_db = clif_parse_roulette_db;
+ clif->roulette_generate_ack = clif_roulette_generate_ack;
/*------------------------
*- Parse Incoming Packet
*------------------------*/
@@ -19299,6 +19662,12 @@ void clif_defaults(void) {
clif->pBankCheck = clif_parse_BankCheck;
clif->pBankOpen = clif_parse_BankOpen;
clif->pBankClose = clif_parse_BankClose;
+ /* Roulette System [Yommy/Hercules] */
+ clif->pRouletteOpen = clif_parse_RouletteOpen;
+ clif->pRouletteInfo = clif_parse_RouletteInfo;
+ clif->pRouletteClose = clif_parse_RouletteClose;
+ clif->pRouletteGenerate = clif_parse_RouletteGenerate;
+ clif->pRouletteRecvItem = clif_parse_RouletteRecvItem;
/* */
clif->pNPCShopClosed = clif_parse_NPCShopClosed;
/* NPC Market */
diff --git a/src/map/clif.h b/src/map/clif.h
index e4de51a83..4c90a3a28 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -18,8 +18,6 @@
**/
struct item;
struct item_data;
-struct storage_data;
-struct guild_storage;
struct unit_data;
struct map_session_data;
struct homun_data;
@@ -48,8 +46,10 @@ struct skill_cd;
#define P2PTR(fd) RFIFO2PTR(fd)
#define clif_menuskill_clear(sd) ((sd)->menuskill_id = (sd)->menuskill_val = (sd)->menuskill_val2 = 0)
#define clif_disp_onlyself(sd,mes,len) clif->disp_message( &(sd)->bl, (mes), (len), SELF )
-#define clif_viewequip_fail( sd ) clif_msg( (sd), 0x54d );
+#define clif_viewequip_fail( sd ) clif->msg( (sd), 0x54d );
#define HCHSYS_NAME_LENGTH 20
+#define MAX_ROULETTE_LEVEL 7 /** client-defined value **/
+#define MAX_ROULETTE_COLUMNS 9 /** client-defined value **/
/**
* Enumerations
@@ -86,14 +86,14 @@ typedef enum send_target {
DUEL,
DUEL_WOS,
SELF,
-
+
BG, // BattleGround System
BG_WOS,
BG_SAMEMAP,
BG_SAMEMAP_WOS,
BG_AREA,
BG_AREA_WOS,
-
+
BG_QUEUE,
} send_target;
@@ -340,6 +340,7 @@ typedef enum useskill_fail_cause { // clif_skill_fail
USESKILL_FAIL_STYLE_CHANGE_FIGHTER = 81,
USESKILL_FAIL_STYLE_CHANGE_GRAPPLER = 82,
USESKILL_FAIL_THERE_ARE_NPC_AROUND = 83,
+ USESKILL_FAIL_NEED_MORE_BULLET = 84,
}useskill_fail_cause;
enum clif_messages {
@@ -352,16 +353,16 @@ enum clif_messages {
* Used to answer CZ_PC_BUY_CASH_POINT_ITEM (clif_parse_cashshop_buy)
**/
enum cashshop_error {
- ERROR_TYPE_NONE = 0, // The deal has successfully completed. (ERROR_TYPE_NONE)
- ERROR_TYPE_NPC, // The Purchase has failed because the NPC does not exist. (ERROR_TYPE_NPC)
- ERROR_TYPE_SYSTEM, // The Purchase has failed because the Kafra Shop System is not working correctly. (ERROR_TYPE_SYSTEM)
- ERROR_TYPE_INVENTORY_WEIGHT, // You are over your Weight Limit. (ERROR_TYPE_INVENTORY_WEIGHT)
- ERROR_TYPE_EXCHANGE, // You cannot purchase items while you are in a trade. (ERROR_TYPE_EXCHANGE)
- ERROR_TYPE_ITEM_ID, // The Purchase has failed because the Item Information was incorrect. (ERROR_TYPE_ITEM_ID)
- ERROR_TYPE_MONEY, // You do not have enough Kafra Credit Points. (ERROR_TYPE_MONEY)
+ ERROR_TYPE_NONE = 0, ///< The deal has successfully completed. (ERROR_TYPE_NONE)
+ ERROR_TYPE_NPC = 1, ///< The Purchase has failed because the NPC does not exist. (ERROR_TYPE_NPC)
+ ERROR_TYPE_SYSTEM = 2, ///< The Purchase has failed because the Kafra Shop System is not working correctly. (ERROR_TYPE_SYSTEM)
+ ERROR_TYPE_INVENTORY_WEIGHT = 3, ///< You are over your Weight Limit. (ERROR_TYPE_INVENTORY_WEIGHT)
+ ERROR_TYPE_EXCHANGE = 4, ///< You cannot purchase items while you are in a trade. (ERROR_TYPE_EXCHANGE)
+ ERROR_TYPE_ITEM_ID = 5, ///< The Purchase has failed because the Item Information was incorrect. (ERROR_TYPE_ITEM_ID)
+ ERROR_TYPE_MONEY = 6, ///< You do not have enough Kafra Credit Points. (ERROR_TYPE_MONEY)
// Unofficial type names
- ERROR_TYPE_QUANTITY, // You can purchase up to 10 items. (ERROR_TYPE_QUANTITY)
- ERROR_TYPE_NOT_ALL, // Some items could not be purchased. (ERROR_TYPE_NOT_ALL)
+ ERROR_TYPE_QUANTITY = 7, ///< You can purchase up to 10 items. (ERROR_TYPE_QUANTITY)
+ ERROR_TYPE_NOT_ALL = 8, ///< Some items could not be purchased. (ERROR_TYPE_NOT_ALL)
};
/**
@@ -375,40 +376,40 @@ enum clif_colors {
};
enum hChSysChOpt {
- hChSys_OPT_BASE = 0x0,
- hChSys_OPT_ANNOUNCE_JOIN = 0x1,
- hChSys_OPT_MSG_DELAY = 0x2,
+ hChSys_OPT_BASE = 0x0,
+ hChSys_OPT_ANNOUNCE_JOIN = 0x1,
+ hChSys_OPT_MSG_DELAY = 0x2,
};
enum hChSysChType {
- hChSys_PUBLIC = 0,
- hChSys_PRIVATE = 1,
- hChSys_MAP = 2,
- hChSys_ALLY = 3,
- hChSys_IRC = 4,
+ hChSys_PUBLIC = 0,
+ hChSys_PRIVATE = 1,
+ hChSys_MAP = 2,
+ hChSys_ALLY = 3,
+ hChSys_IRC = 4,
};
enum CASH_SHOP_TABS {
- CASHSHOP_TAB_NEW = 0,
- CASHSHOP_TAB_POPULAR = 1,
- CASHSHOP_TAB_LIMITED = 2,
- CASHSHOP_TAB_RENTAL = 3,
+ CASHSHOP_TAB_NEW = 0,
+ CASHSHOP_TAB_POPULAR = 1,
+ CASHSHOP_TAB_LIMITED = 2,
+ CASHSHOP_TAB_RENTAL = 3,
CASHSHOP_TAB_PERPETUITY = 4,
- CASHSHOP_TAB_BUFF = 5,
- CASHSHOP_TAB_RECOVERY = 6,
- CASHSHOP_TAB_ETC = 7,
+ CASHSHOP_TAB_BUFF = 5,
+ CASHSHOP_TAB_RECOVERY = 6,
+ CASHSHOP_TAB_ETC = 7,
CASHSHOP_TAB_MAX,
};
enum CASH_SHOP_BUY_RESULT {
- CSBR_SUCCESS = 0x0,
- CSBR_SHORTTAGE_CASH = 0x2,
- CSBR_UNKONWN_ITEM = 0x3,
- CSBR_INVENTORY_WEIGHT = 0x4,
- CSBR_INVENTORY_ITEMCNT = 0x5,
- CSBR_RUNE_OVERCOUNT = 0x9,
- CSBR_EACHITEM_OVERCOUNT = 0xa,
- CSBR_UNKNOWN = 0xb,
+ CSBR_SUCCESS = 0x0,
+ CSBR_SHORTTAGE_CASH = 0x2,
+ CSBR_UNKONWN_ITEM = 0x3,
+ CSBR_INVENTORY_WEIGHT = 0x4,
+ CSBR_INVENTORY_ITEMCNT = 0x5,
+ CSBR_RUNE_OVERCOUNT = 0x9,
+ CSBR_EACHITEM_OVERCOUNT = 0xa,
+ CSBR_UNKNOWN = 0xb,
};
enum BATTLEGROUNDS_QUEUE_ACK {
@@ -478,6 +479,35 @@ enum e_trade_item_ok {
TIO_INDROCKS = 0x9,
};
+enum RECV_ROULETTE_ITEM_REQ {
+ RECV_ITEM_SUCCESS = 0x0,
+ RECV_ITEM_FAILED = 0x1,
+ RECV_ITEM_OVERCOUNT = 0x2,
+ RECV_ITEM_OVERWEIGHT = 0x3,
+};
+
+enum RECV_ROULETTE_ITEM_ACK {
+ RECV_ITEM_NORMAL = 0x0,
+ RECV_ITEM_LOSING = 0x1,
+};
+
+enum GENERATE_ROULETTE_ACK {
+ GENERATE_ROULETTE_SUCCESS = 0x0,
+ GENERATE_ROULETTE_FAILED = 0x1,
+ GENERATE_ROULETTE_NO_ENOUGH_POINT = 0x2,
+ GENERATE_ROULETTE_LOSING = 0x3,
+};
+
+enum OPEN_ROULETTE_ACK{
+ OPEN_ROULETTE_SUCCESS = 0x0,
+ OPEN_ROULETTE_FAILED = 0x1,
+};
+
+enum CLOSE_ROULETTE_ACK {
+ CLOSE_ROULETTE_SUCCESS = 0x0,
+ CLOSE_ROULETTE_FAILED = 0x1,
+};
+
/**
* Structures
**/
@@ -488,7 +518,7 @@ struct s_packet_db {
short pos[MAX_PACKET_POS];
};
-struct {
+struct hChSysConfig {
unsigned int *colors;
char **colors_name;
unsigned char colors_count;
@@ -501,7 +531,7 @@ struct {
char irc_server[40], irc_channel[50], irc_nick[40], irc_nick_pw[30];
unsigned short irc_server_port;
bool irc_use_ghost;
-} hChSys;
+};
struct hChSysBanEntry {
char name[NAME_LENGTH];
@@ -547,6 +577,7 @@ struct clif_interface {
char map_ip_str[128];
int map_fd;
DBMap* channel_db;
+ struct hChSysConfig *hChSys;
/* for clif_clearunit_delayed */
struct eri *delay_clearunit_ers;
/* Cash Shop [Ind/Hercules] */
@@ -554,6 +585,12 @@ struct clif_interface {
struct hCSData **data[CASHSHOP_TAB_MAX];
unsigned int item_count[CASHSHOP_TAB_MAX];
} cs;
+ /* roulette data */
+ struct {
+ int *nameid[MAX_ROULETTE_LEVEL];//nameid
+ int *qty[MAX_ROULETTE_LEVEL];//qty of nameid
+ int items[MAX_ROULETTE_LEVEL];//number of items in the list for each
+ } rd;
/* */
unsigned int cryptKey[3];
/* */
@@ -569,6 +606,7 @@ struct clif_interface {
uint32 (*refresh_ip) (void);
bool (*send) (const void* buf, int len, struct block_list* bl, enum send_target type);
int (*send_sub) (struct block_list *bl, va_list ap);
+ int (*send_actual) (int fd, void *buf, int len);
int (*parse) (int fd);
unsigned short (*parse_cmd) ( int fd, struct map_session_data *sd );
unsigned short (*decrypt_cmd) ( int cmd, struct map_session_data *sd );
@@ -613,6 +651,7 @@ struct clif_interface {
void (*changelook) (struct block_list *bl,int type,int val);
void (*changetraplook) (struct block_list *bl,int val);
void (*refreshlook) (struct block_list *bl,int id,int type,int val,enum send_target target);
+ void (*sendlook) (struct block_list *bl, int id, int type, int val, int val2, enum send_target target);
void (*class_change) (struct block_list *bl,int class_,int type);
void (*skill_delunit) (struct skill_unit *su);
void (*skillunit_update) (struct block_list* bl);
@@ -781,7 +820,7 @@ struct clif_interface {
void (*specialeffect_single) (struct block_list* bl, int type, int fd);
void (*specialeffect_value) (struct block_list* bl, int effect_id, int num, send_target target);
void (*millenniumshield) (struct block_list *bl, short shields );
- void (*charm) (struct map_session_data *sd, short type);
+ void (*spiritcharm) (struct map_session_data *sd, short type);
void (*charm_single) (int fd, struct map_session_data *sd, short type);
void (*snap) ( struct block_list *bl, short x, short y );
void (*weather_check) (struct map_session_data *sd);
@@ -866,6 +905,7 @@ struct clif_interface {
void (*party_xy_remove) (struct map_session_data *sd);
void (*party_show_picker) (struct map_session_data * sd, struct item * item_data);
void (*partyinvitationstate) (struct map_session_data* sd);
+ void (*PartyLeaderChanged) (struct map_session_data *sd, int prev_leader_aid, int new_leader_aid);
/* guild-specific */
void (*guild_created) (struct map_session_data *sd,int flag);
void (*guild_belonginfo) (struct map_session_data *sd, struct guild *g);
@@ -1052,6 +1092,9 @@ struct clif_interface {
/* NPC Market */
void (*npc_market_open) (struct map_session_data *sd, struct npc_data *nd);
void (*npc_market_purchase_ack) (struct map_session_data *sd, struct packet_npc_market_purchase *req, unsigned char response);
+ /* */
+ bool (*parse_roulette_db) (void);
+ void (*roulette_generate_ack) (struct map_session_data *sd, unsigned char result, short stage, short prizeIdx, short bonusItemID);
/*------------------------
*- Parse Incoming Packet
*------------------------*/
@@ -1279,6 +1322,12 @@ struct clif_interface {
void (*pBankCheck) (int fd, struct map_session_data *sd);
void (*pBankOpen) (int fd, struct map_session_data *sd);
void (*pBankClose) (int fd, struct map_session_data *sd);
+ /* Roulette System [Yommy/Hercules] */
+ void (*pRouletteOpen) (int fd, struct map_session_data *sd);
+ void (*pRouletteInfo) (int fd, struct map_session_data *sd);
+ void (*pRouletteClose) (int fd, struct map_session_data *sd);
+ void (*pRouletteGenerate) (int fd, struct map_session_data *sd);
+ void (*pRouletteRecvItem) (int fd, struct map_session_data *sd);
/* */
void (*pNPCShopClosed) (int fd, struct map_session_data *sd);
/* NPC Market (by Ind after an extensive debugging of the packet, only possible thanks to Yommy <3) */
diff --git a/src/map/duel.c b/src/map/duel.c
index 4e4eeef1f..0ae2770c4 100644
--- a/src/map/duel.c
+++ b/src/map/duel.c
@@ -16,6 +16,8 @@
#include "pc.h"
#include "../common/cbasetypes.h"
+struct duel_interface duel_s;
+
/*==========================================
* Duel organizing functions [LuzZza]
*------------------------------------------*/
diff --git a/src/map/duel.h b/src/map/duel.h
index de2bd1bf6..5466f3b43 100644
--- a/src/map/duel.h
+++ b/src/map/duel.h
@@ -37,10 +37,10 @@ struct duel_interface {
void (*leave) (const unsigned int did, struct map_session_data* sd);
void (*showinfo) (const unsigned int did, struct map_session_data* sd);
int (*checktime) (struct map_session_data* sd);
-
+
void (*init) (bool minimal);
void (*final) (void);
-} duel_s;
+};
struct duel_interface *duel;
diff --git a/src/map/elemental.c b/src/map/elemental.c
index caba02692..50d6c34b3 100644
--- a/src/map/elemental.c
+++ b/src/map/elemental.c
@@ -218,6 +218,9 @@ int elemental_delete(struct elemental_data *ed, int reply) {
sd->ed = NULL;
sd->status.ele_id = 0;
+ if( !ed->bl.prev )
+ return unit->free(&ed->bl, 0);
+
return unit->remove_map(&ed->bl, 0, ALC_MARK);
}
@@ -243,7 +246,8 @@ int elemental_data_received(struct s_elemental *ele, bool flag) {
}
db = &elemental->db[i];
- if( !sd->ed ) { // Initialize it after first summon.
+ if( !sd->ed ) {
+ // Initialize it after first summon.
sd->ed = ed = (struct elemental_data*)aCalloc(1,sizeof(struct elemental_data));
ed->bl.type = BL_ELEM;
ed->bl.id = npc->get_new_npc_id();
@@ -319,8 +323,8 @@ int elemental_clean_single_effect(struct elemental_data *ed, uint16 skill_id) {
case SC_UPHEAVAL_OPTION:
case SC_CIRCLE_OF_FIRE_OPTION:
case SC_TIDAL_WEAPON_OPTION:
- if( bl ) status_change_end(bl,type,INVALID_TIMER); // Master
- status_change_end(&ed->bl,type-1,INVALID_TIMER); // Elemental Spirit
+ if( bl ) status_change_end(bl,type,INVALID_TIMER); // Master
+ status_change_end(&ed->bl,type-1,INVALID_TIMER); // Elemental Spirit
break;
case SC_ZEPHYR:
if( bl ) status_change_end(bl,type,INVALID_TIMER);
@@ -406,7 +410,7 @@ int elemental_action(struct elemental_data *ed, struct block_list *bl, int64 tic
return 0;
if( ed->target_id )
- elemental->unlocktarget(ed); // Remove previous target.
+ elemental->unlocktarget(ed); // Remove previous target.
ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&EL_SKILLMODE_AGGRESSIVE));
if( i == MAX_ELESKILLTREE )
@@ -423,7 +427,7 @@ int elemental_action(struct elemental_data *ed, struct block_list *bl, int64 tic
else if( DIFF_TICK(tick, ed->ud.canact_tick) < 0 )
return 0;
- ed->target_id = ed->ud.skilltarget = bl->id; // Set new target
+ ed->target_id = ed->ud.skilltarget = bl->id; // Set new target
ed->last_thinktime = tick;
// Not in skill range.
@@ -501,7 +505,7 @@ int elemental_change_mode_ack(struct elemental_data *ed, int mode) {
else if( DIFF_TICK(timer->gettick(), ed->ud.canact_tick) < 0 )
return 0;
- ed->target_id = bl->id; // Set new target
+ ed->target_id = bl->id; // Set new target
ed->last_thinktime = timer->gettick();
if( skill->get_inf(skill_id) & INF_GROUND_SKILL )
@@ -509,7 +513,7 @@ int elemental_change_mode_ack(struct elemental_data *ed, int mode) {
else
unit->skilluse_id(&ed->bl,bl->id,skill_id,skill_lv);
- ed->target_id = 0; // Reset target after casting the skill to avoid continuous attack.
+ ed->target_id = 0; // Reset target after casting the skill to avoid continuous attack.
return 1;
}
@@ -529,9 +533,9 @@ int elemental_change_mode(struct elemental_data *ed, int mode) {
ed->battle_status.mode = ed->elemental.mode = mode;
// Normalize elemental mode to elemental skill mode.
- if( mode == EL_MODE_AGGRESSIVE ) mode = EL_SKILLMODE_AGGRESSIVE; // Aggressive spirit mode -> Aggressive spirit skill.
- else if( mode == EL_MODE_ASSIST ) mode = EL_SKILLMODE_ASSIST; // Assist spirit mode -> Assist spirit skill.
- else mode = EL_SKILLMODE_PASIVE; // Passive spirit mode -> Passive spirit skill.
+ if( mode == EL_MODE_AGGRESSIVE ) mode = EL_SKILLMODE_AGGRESSIVE; // Aggressive spirit mode -> Aggressive spirit skill.
+ else if( mode == EL_MODE_ASSIST ) mode = EL_SKILLMODE_ASSIST; // Assist spirit mode -> Assist spirit skill.
+ else mode = EL_SKILLMODE_PASIVE; // Passive spirit mode -> Passive spirit skill.
// Use a skill immediately after every change mode.
if( mode != EL_SKILLMODE_AGGRESSIVE )
@@ -577,7 +581,7 @@ struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16
memset(&req,0,sizeof(req));
if( idx == 0 ) // invalid skill id
- return req;
+ return req;
if( skill_lv < 1 || skill_lv > MAX_SKILL_LEVEL )
return req;
@@ -657,12 +661,16 @@ int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_data *s
int sp = 5;
switch(ed->vd->class_){
- case 2115: case 2118:
- case 2121: case 2124:
+ case 2115:
+ case 2118:
+ case 2121:
+ case 2124:
sp = 8;
break;
- case 2116: case 2119:
- case 2122: case 2125:
+ case 2116:
+ case 2119:
+ case 2122:
+ case 2125:
sp = 11;
break;
}
@@ -698,13 +706,15 @@ int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_data *s
mode = status_get_mode(&ed->bl);
master_dist = distance_bl(&sd->bl, &ed->bl);
- if( master_dist > AREA_SIZE ) { // Master out of vision range.
+ if( master_dist > AREA_SIZE ) {
+ // Master out of vision range.
elemental->unlocktarget(ed);
unit->warp(&ed->bl,sd->bl.m,sd->bl.x,sd->bl.y,CLR_TELEPORT);
clif->elemental_updatestatus(sd,SP_HP);
clif->elemental_updatestatus(sd,SP_SP);
return 0;
- } else if( master_dist > MAX_ELEDISTANCE ) { // Master too far, chase.
+ } else if( master_dist > MAX_ELEDISTANCE ) {
+ // Master too far, chase.
short x = sd->bl.x, y = sd->bl.y;
if( ed->target_id )
elemental->unlocktarget(ed);
diff --git a/src/map/elemental.h b/src/map/elemental.h
index 0c8fff8b3..ca13c30b8 100644
--- a/src/map/elemental.h
+++ b/src/map/elemental.h
@@ -79,22 +79,22 @@ struct elemental_interface {
/* funcs */
bool (*class) (int class_);
struct view_data * (*get_viewdata) (int class_);
-
+
int (*create) (struct map_session_data *sd, int class_, unsigned int lifetime);
int (*data_received) (struct s_elemental *ele, bool flag);
int (*save) (struct elemental_data *ed);
-
+
int (*change_mode_ack) (struct elemental_data *ed, int mode);
int (*change_mode) (struct elemental_data *ed, int mode);
-
+
void (*heal) (struct elemental_data *ed, int hp, int sp);
int (*dead) (struct elemental_data *ed);
-
+
int (*delete) (struct elemental_data *ed, int reply);
void (*summon_stop) (struct elemental_data *ed);
-
+
int (*get_lifetime) (struct elemental_data *ed);
-
+
int (*unlocktarget) (struct elemental_data *ed);
int (*skillnotok) (uint16 skill_id, struct elemental_data *ed);
int (*set_target) (struct map_session_data *sd, struct block_list *bl);
@@ -102,11 +102,11 @@ struct elemental_interface {
int (*clean_effect) (struct elemental_data *ed);
int (*action) (struct elemental_data *ed, struct block_list *bl, int64 tick);
struct skill_condition (*skill_get_requirements) (uint16 skill_id, uint16 skill_lv);
-
+
int (*read_skilldb) (void);
void (*reload_db) (void);
void (*reload_skilldb) (void);
-
+
int (*search_index) (int class_);
void (*summon_init) (struct elemental_data *ed);
int (*summon_end_timer) (int tid, int64 tick, int id, intptr_t data);
diff --git a/src/map/guild.c b/src/map/guild.c
index ac24edeab..d46da60a3 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -63,10 +63,10 @@ int guild_skill_get_max (int id) {
// Retrieve skill_lv learned by guild
int guild_checkskill(struct guild *g, int id) {
- int idx = id - GD_SKILLBASE;
- if (idx < 0 || idx >= MAX_GUILDSKILL)
- return 0;
- return g->skill[idx].lv;
+ int idx = id - GD_SKILLBASE;
+ if (idx < 0 || idx >= MAX_GUILDSKILL)
+ return 0;
+ return g->skill[idx].lv;
}
/*==========================================
@@ -236,17 +236,17 @@ void guild_makemember(struct guild_member *m,struct map_session_data *sd)
nullpo_retv(sd);
memset(m,0,sizeof(struct guild_member));
- m->account_id =sd->status.account_id;
- m->char_id =sd->status.char_id;
- m->hair =sd->status.hair;
- m->hair_color =sd->status.hair_color;
- m->gender =sd->status.sex;
- m->class_ =sd->status.class_;
- m->lv =sd->status.base_level;
-// m->exp =0;
-// m->exp_payper =0;
- m->online =1;
- m->position =MAX_GUILDPOSITION-1;
+ m->account_id = sd->status.account_id;
+ m->char_id = sd->status.char_id;
+ m->hair = sd->status.hair;
+ m->hair_color = sd->status.hair_color;
+ m->gender = sd->status.sex;
+ m->class_ = sd->status.class_;
+ m->lv = sd->status.base_level;
+ //m->exp = 0;
+ //m->exp_payper = 0;
+ m->online = 1;
+ m->position = MAX_GUILDPOSITION-1;
memcpy(m->name,sd->status.name,NAME_LENGTH);
return;
}
@@ -366,14 +366,14 @@ int guild_created(int account_id,int guild_id) {
if(sd==NULL)
return 0;
if(!guild_id) {
- clif->guild_created(sd, 2); // Creation failure (presence of the same name Guild)
+ clif->guild_created(sd, 2); // Creation failure (presence of the same name Guild)
return 0;
}
//struct guild *g;
sd->status.guild_id=guild_id;
clif->guild_created(sd,0);
if(battle_config.guild_emperium_check)
- pc->delitem(sd,pc->search_inventory(sd,ITEMID_EMPERIUM),1,0,0,LOG_TYPE_CONSUME); //emperium consumption
+ pc->delitem(sd,pc->search_inventory(sd,ITEMID_EMPERIUM),1,0,0,LOG_TYPE_CONSUME); //emperium consumption
return 0;
}
@@ -459,6 +459,8 @@ int guild_recv_info(struct guild *sg) {
struct map_session_data *sd;
bool guild_new = false;
struct hChSysCh *aChSysSave = NULL;
+ short *instance_save = NULL;
+ unsigned short instances_save = 0;
nullpo_ret(sg);
@@ -468,15 +470,15 @@ int guild_recv_info(struct guild *sg) {
g->instance = NULL;
g->instances = 0;
idb_put(guild->db,sg->guild_id,g);
- if( hChSys.ally ) {
+ if (clif->hChSys->ally) {
struct hChSysCh *channel;
-
+
CREATE(channel, struct hChSysCh , 1);
- safestrncpy(channel->name, hChSys.ally_name, HCHSYS_NAME_LENGTH);
+ safestrncpy(channel->name, clif->hChSys->ally_name, HCHSYS_NAME_LENGTH);
channel->type = hChSys_ALLY;
- clif->chsys_create(channel,NULL,NULL,hChSys.ally_color);
- if( hChSys.ally_autojoin ) {
+ clif->chsys_create(channel, NULL, NULL, clif->hChSys->ally_color);
+ if (clif->hChSys->ally_autojoin) {
struct s_mapiterator* iter = mapit_getallusers();
struct guild *tg[MAX_GUILDALLIANCE];
@@ -538,10 +540,16 @@ int guild_recv_info(struct guild *sg) {
before=*g;
if( g->channel )
aChSysSave = g->channel;
+ if( g->instance )
+ instance_save = g->instance;
+ if( g->instances )
+ instances_save = g->instances;
}
memcpy(g,sg,sizeof(struct guild));
g->channel = aChSysSave;
+ g->instance = instance_save;
+ g->instances = instances_save;
if(g->max_member > MAX_GUILD) {
ShowError("guild_recv_info: Received guild with %d members, but MAX_GUILD is only %d. Extra guild-members have been lost!\n", g->max_member, MAX_GUILD);
@@ -559,32 +567,32 @@ int guild_recv_info(struct guild *sg) {
bm++;
}
- for (i = 0; i < g->max_member; i++) { //Transmission of information at all members
+ for (i = 0; i < g->max_member; i++) { //Transmission of information at all members
sd = g->member[i].sd;
if( sd==NULL )
continue;
sd->guild = g;
- if (before.guild_lv != g->guild_lv || bm != m ||
- before.max_member != g->max_member) {
- clif->guild_basicinfo(sd); //Submit basic information
- clif->guild_emblem(sd, g); //Submit emblem
- }
+ if (before.guild_lv != g->guild_lv || bm != m
+ || before.max_member != g->max_member) {
+ clif->guild_basicinfo(sd); //Submit basic information
+ clif->guild_emblem(sd, g); //Submit emblem
+ }
- if (bm != m) { //Send members information
- clif->guild_memberlist(g->member[i].sd);
- }
+ if (bm != m) { //Send members information
+ clif->guild_memberlist(g->member[i].sd);
+ }
- if (before.skill_point != g->skill_point)
- clif->guild_skillinfo(sd); //Submit information skills
+ if (before.skill_point != g->skill_point)
+ clif->guild_skillinfo(sd); //Submit information skills
if (guild_new) { // Send information and affiliation if unsent
- clif->guild_belonginfo(sd, g);
- //clif->guild_notice(sd, g); Is already sent in clif_parse_LoadEndAck
- sd->guild_emblem_id = g->emblem_id;
- }
- }
+ clif->guild_belonginfo(sd, g);
+ //clif->guild_notice(sd, g); Is already sent in clif_parse_LoadEndAck
+ sd->guild_emblem_id = g->emblem_id;
+ }
+ }
- //Occurrence of an event
+ //Occurrence of an event
if (guild->infoevent_db->remove(guild->infoevent_db, DB->i2key(sg->guild_id), &data)) {
struct eventlist *ev = DB->data2ptr(&data), *ev2;
while(ev) {
@@ -602,8 +610,8 @@ int guild_recv_info(struct guild *sg) {
* Player sd send a guild invatation to player tsd to join his guild
*--------------------------------------------*/
int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) {
- struct guild *g;
- int i;
+ struct guild *g;
+ int i;
nullpo_ret(sd);
@@ -616,7 +624,7 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) {
return 0; //Invite permission.
if(!battle_config.invite_request_check) {
- if (tsd->party_invite > 0 || tsd->trade_partner || tsd->adopt_invite) { //checking if there no other invitation pending
+ if (tsd->party_invite > 0 || tsd->trade_partner || tsd->adopt_invite) { //checking if there no other invitation pending
clif->guild_inviteack(sd,0);
return 0;
}
@@ -627,8 +635,8 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) {
return 0;
}
- if( tsd->status.guild_id > 0
- || tsd->guild_invite > 0
+ if( tsd->status.guild_id > 0
+ || tsd->guild_invite > 0
|| ( (map->agit_flag || map->agit2_flag)
&& map->list[tsd->bl.m].flag.gvg_castle
&& !battle_config.guild_castle_invite
@@ -722,7 +730,8 @@ void guild_member_joined(struct map_session_data *sd)
guild->request_info(sd->status.guild_id);
return;
}
- if (strcmp(sd->status.name,g->master) == 0) { // set the Guild Master flag
+ if (strcmp(sd->status.name,g->master) == 0) {
+ // set the Guild Master flag
sd->state.gmaster_flag = 1;
// prevent Guild Skills from being used directly after relog
if( battle_config.guild_skill_relog_delay )
@@ -736,7 +745,7 @@ void guild_member_joined(struct map_session_data *sd)
g->member[i].sd = sd;
sd->guild = g;
- if( hChSys.ally && hChSys.ally_autojoin ) {
+ if (clif->hChSys->ally && clif->hChSys->ally_autojoin) {
struct guild* sg = NULL;
struct hChSysCh *channel = g->channel;
@@ -815,8 +824,8 @@ int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int c
return 0;
if( sd->status.account_id != account_id
- || sd->status.char_id != char_id
- || sd->status.guild_id != guild_id
+ || sd->status.char_id != char_id
+ || sd->status.guild_id != guild_id
// Can't leave inside castles
|| ((map->agit_flag || map->agit2_flag)
&& map->list[sd->bl.m].flag.gvg_castle
@@ -847,11 +856,11 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i
return 0;
if( (ps=guild->getposition(g,sd))<0 || !(g->position[ps].mode&0x0010) )
- return 0; //Expulsion permission
+ return 0; //Expulsion permission
//Can't leave inside guild castles.
- if ((tsd = map->id2sd(account_id))
- && tsd->status.char_id == char_id
+ if ((tsd = map->id2sd(account_id))
+ && tsd->status.char_id == char_id
&& ((map->agit_flag || map->agit2_flag)
&& map->list[sd->bl.m].flag.gvg_castle
&& !battle_config.guild_castle_expulsion)
@@ -904,7 +913,7 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c
if (sd->state.storage_flag == 2) //Close the guild storage.
gstorage->close(sd);
guild->send_dot_remove(sd);
- if( hChSys.ally ) {
+ if (clif->hChSys->ally) {
clif->chsys_quitg(sd);
}
sd->status.guild_id = 0;
@@ -928,7 +937,7 @@ void guild_retrieveitembound(int char_id,int aid,int guild_id) {
if(sd){ //Character is online
pc->bound_clear(sd,IBT_GUILD);
} else { //Character is offline, ask char server to do the job
- struct guild_storage *gstor = gstorage->id2storage2(guild_id);
+ struct guild_storage *gstor = idb_get(gstorage->db,guild_id);
if(gstor && gstor->storage_status == 1) { //Someone is in guild storage, close them
struct s_mapiterator* iter = mapit_getallusers();
for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) {
@@ -968,8 +977,8 @@ int guild_send_memberinfoshort(struct map_session_data *sd,int online)
return 0;
}
- if(sd->state.connect_new)
- { //Note that this works because it is invoked in parse_LoadEndAck before connect_new is cleared.
+ if (sd->state.connect_new) {
+ //Note that this works because it is invoked in parse_LoadEndAck before connect_new is cleared.
clif->guild_belonginfo(sd,g);
sd->guild_emblem_id = g->emblem_id;
}
@@ -1384,8 +1393,8 @@ void guild_guildaura_refresh(struct map_session_data *sd, uint16 skill_id, uint1
/*====================================================
* Count number of relations the guild has.
* Flag:
- * 0 = allied
- * 1 = enemy
+ * 0 = allied
+ * 1 = enemy
*---------------------------------------------------*/
int guild_get_alliance_count(struct guild *g,int flag)
{
@@ -1393,9 +1402,8 @@ int guild_get_alliance_count(struct guild *g,int flag)
nullpo_ret(g);
- for(i=c=0;i<MAX_GUILDALLIANCE;i++){
- if( g->alliance[i].guild_id>0 &&
- g->alliance[i].opposition==flag )
+ for(i=c=0;i<MAX_GUILDALLIANCE;i++) {
+ if(g->alliance[i].guild_id>0 && g->alliance[i].opposition==flag)
c++;
}
return c;
@@ -1413,8 +1421,8 @@ void guild_block_skill(struct map_session_data *sd, int time)
/*====================================================
* Check relation between guild_id1 and guild_id2.
* Flag:
- * 0 = allied
- * 1 = enemy
+ * 0 = allied
+ * 1 = enemy
* Returns true if yes.
*---------------------------------------------------*/
int guild_check_alliance(int guild_id1, int guild_id2, int flag)
@@ -1459,7 +1467,7 @@ int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd)
if(sd->status.guild_id == tsd->status.guild_id)
return 0;
- if( guild->get_alliance_count(g[0],0) >= battle_config.max_guild_alliance ) {
+ if( guild->get_alliance_count(g[0],0) >= battle_config.max_guild_alliance ) {
clif->guild_allianceack(sd,4);
return 0;
}
@@ -1473,9 +1481,8 @@ int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd)
return 0;
}
- for (i = 0; i < MAX_GUILDALLIANCE; i++) { // check if already allied
- if( g[0]->alliance[i].guild_id==tsd->status.guild_id &&
- g[0]->alliance[i].opposition==0){
+ for (i = 0; i < MAX_GUILDALLIANCE; i++) { // check if already allied
+ if(g[0]->alliance[i].guild_id==tsd->status.guild_id && g[0]->alliance[i].opposition==0) {
clif->guild_allianceack(sd,0);
return 0;
}
@@ -1501,13 +1508,13 @@ int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag)
return 0;
}
- if (sd->guild_alliance != tsd->status.guild_id) // proposed guild_id alliance doesn't match tsd guildid
+ if (sd->guild_alliance != tsd->status.guild_id) // proposed guild_id alliance doesn't match tsd guildid
return 0;
- if (flag == 1) { // consent
+ if (flag == 1) { // consent
int i;
- struct guild *g, *tg; // Reconfirm the number of alliance
+ struct guild *g, *tg; // Reconfirm the number of alliance
g=sd->guild;
tg=tsd->guild;
@@ -1535,11 +1542,11 @@ int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag)
tsd->status.account_id,sd->status.account_id,9 );
}
- // inform other servers
+ // inform other servers
intif->guild_alliance( sd->status.guild_id,tsd->status.guild_id,
sd->status.account_id,tsd->status.account_id,0 );
return 0;
- } else { // deny
+ } else { // deny
sd->guild_alliance=0;
sd->guild_alliance_account=0;
if(tsd!=NULL)
@@ -1582,7 +1589,7 @@ int guild_opposition(struct map_session_data *sd,struct map_session_data *tsd)
if(sd->status.guild_id == tsd->status.guild_id)
return 0;
- if( guild->get_alliance_count(g,1) >= battle_config.max_guild_alliance ) {
+ if( guild->get_alliance_count(g,1) >= battle_config.max_guild_alliance ) {
clif->guild_oppositionack(sd,1);
return 0;
}
@@ -1639,9 +1646,9 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id
return 0;
}
- if( g[0] && g[1] && hChSys.ally && ( flag & 1 ) == 0 ) {
+ if (g[0] && g[1] && clif->hChSys->ally && ( flag & 1 ) == 0) {
if( !(flag & 0x08) ) {
- if( hChSys.ally_autojoin )
+ if (clif->hChSys->ally_autojoin)
clif->chsys_gjoin(g[0],g[1]);
} else {
clif->chsys_gleave(g[0],g[1]);
@@ -1703,7 +1710,8 @@ int guild_broken_sub(DBKey key, DBData *data, va_list ap)
nullpo_ret(g);
- for(i=0;i<MAX_GUILDALLIANCE;i++){ // Destroy all relationships
+ for(i=0;i<MAX_GUILDALLIANCE;i++) {
+ // Destroy all relationships
if(g->alliance[i].guild_id==guild_id){
for(j=0;j<g->max_member;j++)
if( (sd=g->member[j].sd)!=NULL )
@@ -1749,7 +1757,8 @@ int guild_broken(int guild_id,int flag)
if(flag!=0 || g==NULL)
return 0;
- for(i=0;i<g->max_member;i++){ // Destroy all relationships
+ for(i=0;i<g->max_member;i++){
+ // Destroy all relationships
if((sd=g->member[i].sd)!=NULL){
if(sd->state.storage_flag == 2)
gstorage->pc_quit(sd,1);
@@ -1768,7 +1777,7 @@ int guild_broken(int guild_id,int flag)
guild->db->foreach(guild->db,guild->broken_sub,guild_id);
guild->castle_db->foreach(guild->castle_db,guild->castle_broken_sub,guild_id);
gstorage->delete(guild_id);
- if( hChSys.ally ) {
+ if (clif->hChSys->ally) {
if( g->channel != NULL ) {
clif->chsys_delete(g->channel);
}
@@ -1878,11 +1887,13 @@ int guild_break(struct map_session_data *sd,char *name) {
return 0;
if(!sd->state.gmaster_flag)
return 0;
- for(i=0;i<g->max_member;i++){
- if( g->member[i].account_id>0 && (
- g->member[i].account_id!=sd->status.account_id ||
- g->member[i].char_id!=sd->status.char_id ))
+ for (i = 0; i < g->max_member; i++) {
+ if (g->member[i].account_id > 0
+ && (g->member[i].account_id!=sd->status.account_id
+ || g->member[i].char_id!=sd->status.char_id
+ )) {
break;
+ }
}
if(i<g->max_member){
clif->guild_broken(sd,2);
@@ -2086,7 +2097,8 @@ int guild_castledataloadack(int len, struct guild_castle *gc)
* Start normal woe and triggers all npc OnAgitStart
*---------------------------------------------------*/
void guild_agit_start(void)
-{ // Run All NPC_Event[OnAgitStart]
+{
+ // Run All NPC_Event[OnAgitStart]
int c = npc->event_doall("OnAgitStart");
ShowStatus("NPC_Event:[OnAgitStart] Run (%d) Events by @AgitStart.\n",c);
}
@@ -2095,7 +2107,8 @@ void guild_agit_start(void)
* End normal woe and triggers all npc OnAgitEnd
*---------------------------------------------------*/
void guild_agit_end(void)
-{ // Run All NPC_Event[OnAgitEnd]
+{
+ // Run All NPC_Event[OnAgitEnd]
int c = npc->event_doall("OnAgitEnd");
ShowStatus("NPC_Event:[OnAgitEnd] Run (%d) Events by @AgitEnd.\n",c);
}
@@ -2104,7 +2117,8 @@ void guild_agit_end(void)
* Start woe2 and triggers all npc OnAgitStart2
*---------------------------------------------------*/
void guild_agit2_start(void)
-{ // Run All NPC_Event[OnAgitStart2]
+{
+ // Run All NPC_Event[OnAgitStart2]
int c = npc->event_doall("OnAgitStart2");
ShowStatus("NPC_Event:[OnAgitStart2] Run (%d) Events by @AgitStart2.\n",c);
}
@@ -2113,7 +2127,8 @@ void guild_agit2_start(void)
* End woe2 and triggers all npc OnAgitEnd2
*---------------------------------------------------*/
void guild_agit2_end(void)
-{ // Run All NPC_Event[OnAgitEnd2]
+{
+ // Run All NPC_Event[OnAgitEnd2]
int c = npc->event_doall("OnAgitEnd2");
ShowStatus("NPC_Event:[OnAgitEnd2] Run (%d) Events by @AgitEnd2.\n",c);
}
diff --git a/src/map/guild.h b/src/map/guild.h
index 126325eef..eb6de7070 100644
--- a/src/map/guild.h
+++ b/src/map/guild.h
@@ -13,8 +13,8 @@
/**
* Defines
**/
-#define GUILD_SEND_XY_INVERVAL 5000 // Interval of sending coordinates and HP
-#define GUILD_PAYEXP_INVERVAL 10000 //Interval (maximum survival time of the cache, in milliseconds)
+#define GUILD_SEND_XY_INVERVAL 5000 // Interval of sending coordinates and HP
+#define GUILD_PAYEXP_INVERVAL 10000 //Interval (maximum survival time of the cache, in milliseconds)
#define MAX_GUILD_SKILL_REQUIRE 5
/**
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index 0f76fcf5f..1d226749b 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -78,39 +78,39 @@ enum homun_type homunculus_class2type(int class_) {
}
void homunculus_addspiritball(struct homun_data *hd, int max) {
- nullpo_retv(hd);
+ nullpo_retv(hd);
- if (max > MAX_SKILL_LEVEL)
- max = MAX_SKILL_LEVEL;
- if (hd->homunculus.spiritball < 0)
- hd->homunculus.spiritball = 0;
+ if (max > MAX_SKILL_LEVEL)
+ max = MAX_SKILL_LEVEL;
+ if (hd->homunculus.spiritball < 0)
+ hd->homunculus.spiritball = 0;
- if (hd->homunculus.spiritball && hd->homunculus.spiritball >= max) {
- hd->homunculus.spiritball = max;
- }
- else
- hd->homunculus.spiritball++;
+ if (hd->homunculus.spiritball && hd->homunculus.spiritball >= max) {
+ hd->homunculus.spiritball = max;
+ }
+ else
+ hd->homunculus.spiritball++;
- clif->spiritball(&hd->bl);
+ clif->spiritball(&hd->bl);
}
void homunculus_delspiritball(struct homun_data *hd, int count, int type) {
- nullpo_retv(hd);
-
- if (hd->homunculus.spiritball <= 0) {
- hd->homunculus.spiritball = 0;
- return;
- }
- if (count <= 0)
- return;
- if (count > MAX_SKILL_LEVEL)
- count = MAX_SKILL_LEVEL;
- if (count > hd->homunculus.spiritball)
- count = hd->homunculus.spiritball;
-
- hd->homunculus.spiritball -= count;
- if (!type)
- clif->spiritball(&hd->bl);
+ nullpo_retv(hd);
+
+ if (hd->homunculus.spiritball <= 0) {
+ hd->homunculus.spiritball = 0;
+ return;
+ }
+ if (count <= 0)
+ return;
+ if (count > MAX_SKILL_LEVEL)
+ count = MAX_SKILL_LEVEL;
+ if (count > hd->homunculus.spiritball)
+ count = hd->homunculus.spiritball;
+
+ hd->homunculus.spiritball -= count;
+ if (!type)
+ clif->spiritball(&hd->bl);
}
void homunculus_damaged(struct homun_data *hd) {
@@ -313,7 +313,7 @@ bool homunculus_levelup(struct homun_data *hd) {
hom = &hd->homunculus;
hom->level++ ;
if (!(hom->level % 3))
- hom->skillpts++; //1 skillpoint each 3 base level
+ hom->skillpts++; //1 skillpoint each 3 base level
hom->exp -= hd->exp_next;
hd->exp_next = homun->exptable[hom->level - 1];
@@ -347,6 +347,8 @@ bool homunculus_levelup(struct homun_data *hd) {
hom->int_+= growth_int;
hom->luk += growth_luk;
+ APPLY_HOMUN_LEVEL_STATWEIGHT();
+
if ( battle_config.homunculus_show_growth ) {
char output[256] ;
sprintf(output,
@@ -500,7 +502,7 @@ int homunculus_gainexp(struct homun_data *hd,unsigned int exp) {
return 0;
}
- //levelup
+ //levelup
while( hd->homunculus.exp > hd->exp_next && homun->levelup(hd) );
if( hd->exp_next == 0 )
@@ -601,7 +603,7 @@ bool homunculus_feed(struct map_session_data *sd, struct homun_data *hd) {
emotion = E_HO;
}
- hd->homunculus.hunger += 10; //dunno increase value for each food
+ hd->homunculus.hunger += 10; //dunno increase value for each food
if(hd->homunculus.hunger > 100)
hd->homunculus.hunger = 100;
@@ -912,7 +914,7 @@ bool homunculus_ressurect(struct map_session_data* sd, unsigned char per, short
hd = sd->hd;
- if (hd->homunculus.vaporize != HOM_ST_ACTIVE)
+ if (hd->homunculus.vaporize != HOM_ST_ACTIVE)
return false; // vaporized homunculi need to be 'called'
if (!status->isdead(&hd->bl))
@@ -1126,7 +1128,7 @@ bool homunculus_read_db_sub(char* str[], int columns, int current) {
void homunculus_read_db(void) {
int i;
- const char *filename[]={"homunculus_db.txt","homunculus_db2.txt"};
+ const char *filename[]={DBPATH"homunculus_db.txt","homunculus_db2.txt"};
memset(homun->db,0,sizeof(homun->db));
for(i = 0; i<ARRAYLENGTH(filename); i++) {
@@ -1151,7 +1153,7 @@ bool homunculus_read_skill_db_sub(char* split[], int columns, int current) {
int minJobLevelPresent = 0;
if( columns == 15 )
- minJobLevelPresent = 1; // MinJobLvl has been added - FIXME: is this extra field even needed anymore?
+ minJobLevelPresent = 1; // MinJobLvl has been added - FIXME: is this extra field even needed anymore?
// check for bounds [celest]
classid = atoi(split[0]) - HM_CLASS_BASE;
diff --git a/src/map/homunculus.h b/src/map/homunculus.h
index 25ccabf48..5b1fd2031 100644
--- a/src/map/homunculus.h
+++ b/src/map/homunculus.h
@@ -14,6 +14,17 @@
#define homdb_checkid(id) ((id) >= HM_CLASS_BASE && (id) <= HM_CLASS_MAX)
#define homun_alive(x) ((x) && (x)->homunculus.vaporize == HOM_ST_ACTIVE && (x)->battle_status.hp > 0)
+#ifdef RENEWAL
+#define HOMUN_LEVEL_STATWEIGHT_VALUE 0
+#define APPLY_HOMUN_LEVEL_STATWEIGHT()( \
+ hom->str_value = hom->agi_value = \
+ hom->vit_value = hom->int_value = \
+ hom->dex_value = hom->luk_value = hom->level / 10 - HOMUN_LEVEL_STATWEIGHT_VALUE \
+ )
+#else
+#define APPLY_HOMUN_LEVEL_STATWEIGHT()
+#endif
+
struct h_stats {
unsigned int HP, SP;
unsigned short str, agi, vit, int_, dex, luk;
@@ -65,7 +76,7 @@ struct homun_data {
int hungry_timer; //[orn]
unsigned int exp_next;
char blockskill[MAX_SKILL]; // [orn]
-
+
int64 masterteleport_timer;
};
diff --git a/src/map/instance.c b/src/map/instance.c
index 5789d7dd6..4140973b1 100644
--- a/src/map/instance.c
+++ b/src/map/instance.c
@@ -273,7 +273,7 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const
* type : result (0 = map id | 1 = instance id)
*--------------------------------------*/
int instance_map2imap(int16 m, int instance_id) {
- int i;
+ int i;
if( !instance->valid(instance_id) ) {
return -1;
@@ -282,12 +282,12 @@ int instance_map2imap(int16 m, int instance_id) {
for( i = 0; i < instance->list[instance_id].num_map; i++ ) {
if( instance->list[instance_id].map[i] && map->list[instance->list[instance_id].map[i]].instance_src_map == m )
return instance->list[instance_id].map[i];
- }
- return -1;
+ }
+ return -1;
}
int instance_mapname2imap(const char *map_name, int instance_id) {
- int i;
+ int i;
if( !instance->valid(instance_id) ) {
return -1;
@@ -296,8 +296,8 @@ int instance_mapname2imap(const char *map_name, int instance_id) {
for( i = 0; i < instance->list[instance_id].num_map; i++ ) {
if( instance->list[instance_id].map[i] && !strcmpi(map->list[map->list[instance->list[instance_id].map[i]].instance_src_map].name,map_name) )
return instance->list[instance_id].map[i];
- }
- return -1;
+ }
+ return -1;
}
diff --git a/src/map/instance.h b/src/map/instance.h
index 2ee77d3e3..4848c9c59 100644
--- a/src/map/instance.h
+++ b/src/map/instance.h
@@ -41,17 +41,17 @@ struct instance_data {
unsigned short users;
struct reg_db regs; ///< Instance variables for scripts
-
+
int progress_timer;
unsigned int progress_timeout;
int idle_timer;
unsigned int idle_timeout, idle_timeoutval;
-
+
unsigned int original_progress_timeout;
-
+
struct point respawn; ///< reload spawn
-
+
/** HPM Custom Struct */
struct HPluginData **hdata;
unsigned int hdatac;
diff --git a/src/map/intif.c b/src/map/intif.c
index be82a7583..73fb648ae 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -210,8 +210,8 @@ int intif_wis_message(struct map_session_data *sd, char *nick, char *mes, size_t
if (intif->CheckForCharServer())
return 0;
- if (chrif->other_mapserver_count < 1)
- { //Character not found.
+ if (chrif->other_mapserver_count < 1) {
+ //Character not found.
clif->wis_end(sd->fd, 1);
return 0;
}
@@ -924,8 +924,8 @@ void intif_parse_WisMessage(int fd) {
strcmp(sd->ignore[i].name, wisp_source) != 0
; i++);
- if (i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0')
- { //Ignored
+ if (i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0') {
+ //Ignored
intif_wis_replay(id, 2);
return;
}
@@ -1098,7 +1098,7 @@ void intif_parse_LoadGuildStorage(int fd)
return;
}
}
- gstor=gstorage->id2storage(guild_id);
+ gstor=gstorage->ensure(guild_id);
if(!gstor) {
ShowWarning("intif_parse_LoadGuildStorage: error guild_id %d not exist\n",guild_id);
return;
@@ -1113,7 +1113,7 @@ void intif_parse_LoadGuildStorage(int fd)
}
if (RFIFOW(fd,2)-13 != sizeof(struct guild_storage)) {
ShowError("intif_parse_LoadGuildStorage: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2)-13, sizeof(struct guild_storage));
- gstor->storage_status = 0;
+ gstor->storage_status = 0;
return;
}
@@ -1567,10 +1567,8 @@ void intif_parse_MailInboxReceived(int fd) {
sd = map->charid2sd(RFIFOL(fd,4));
- if (sd == NULL) {
- ShowError("intif_parse_MailInboxReceived: char not found %d\n",RFIFOL(fd,4));
+ if (sd == NULL) /** user is not online anymore and its ok (quest log also does this) **/
return;
- }
if (RFIFOW(fd,2) - 9 != sizeof(struct mail_data)) {
ShowError("intif_parse_MailInboxReceived: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2) - 9, sizeof(struct mail_data));
@@ -2138,7 +2136,7 @@ void intif_request_accinfo( int u_fd, int aid, int group_lv, char* query ) {
WFIFOL(inter_fd,2) = u_fd;
WFIFOL(inter_fd,6) = aid;
WFIFOL(inter_fd,10) = group_lv;
- safestrncpy((char *)WFIFOP(inter_fd,14), query, NAME_LENGTH);
+ safestrncpy((char *)WFIFOP(inter_fd,14), query, NAME_LENGTH);
WFIFOSET(inter_fd,2 + 4 + 4 + 4 + NAME_LENGTH);
@@ -2167,7 +2165,7 @@ void intif_parse_MessageToFD(int fd) {
*------------------------------------------*/
void intif_itembound_req(int char_id,int aid,int guild_id) {
#ifdef GP_BOUND_ITEMS
- struct guild_storage *gstor = gstorage->id2storage2(guild_id);
+ struct guild_storage *gstor = idb_get(gstorage->db,guild_id);
WFIFOHEAD(inter_fd,12);
WFIFOW(inter_fd,0) = 0x3056;
WFIFOL(inter_fd,2) = char_id;
@@ -2185,7 +2183,7 @@ void intif_parse_Itembound_ack(int fd) {
struct guild_storage *gstor;
int guild_id = RFIFOW(fd,6);
- gstor = gstorage->id2storage2(guild_id);
+ gstor = idb_get(gstorage->db,guild_id);
if(gstor)
gstor->lock = 0; //Unlock now that operation is completed
#endif
@@ -2198,12 +2196,13 @@ int intif_parse(int fd)
{
int packet_len, cmd;
cmd = RFIFOW(fd,0);
- // Verify ID of the packet
- if(cmd<0x3800 || cmd>=0x3800+(sizeof(intif->packet_len_table)/sizeof(intif->packet_len_table[0])) ||
- intif->packet_len_table[cmd-0x3800]==0){
- return 0;
+ // Verify ID of the packet
+ if (cmd < 0x3800 || cmd >= 0x3800+(sizeof(intif->packet_len_table)/sizeof(intif->packet_len_table[0]))
+ || intif->packet_len_table[cmd-0x3800] == 0
+ ) {
+ return 0;
}
- // Check the length of the packet
+ // Check the length of the packet
packet_len = intif->packet_len_table[cmd-0x3800];
if(packet_len==-1){
if(RFIFOREST(fd)<4)
@@ -2213,7 +2212,7 @@ int intif_parse(int fd)
if((int)RFIFOREST(fd)<packet_len){
return 2;
}
- // Processing branch
+ // Processing branch
switch(cmd){
case 0x3800:
if (RFIFOL(fd,4) == 0xFF000000) //Normal announce.
@@ -2221,57 +2220,57 @@ int intif_parse(int fd)
else //Color announce.
clif->broadcast2(NULL, (char *) RFIFOP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT);
break;
- case 0x3801: intif->pWisMessage(fd); break;
- case 0x3802: intif->pWisEnd(fd); break;
- case 0x3803: intif->pWisToGM(fd); break;
- case 0x3804: intif->pRegisters(fd); break;
- case 0x3806: intif->pChangeNameOk(fd); break;
- case 0x3807: intif->pMessageToFD(fd); break;
- case 0x3818: intif->pLoadGuildStorage(fd); break;
- case 0x3819: intif->pSaveGuildStorage(fd); break;
- case 0x3820: intif->pPartyCreated(fd); break;
- case 0x3821: intif->pPartyInfo(fd); break;
- case 0x3822: intif->pPartyMemberAdded(fd); break;
- case 0x3823: intif->pPartyOptionChanged(fd); break;
- case 0x3824: intif->pPartyMemberWithdraw(fd); break;
- case 0x3825: intif->pPartyMove(fd); break;
- case 0x3826: intif->pPartyBroken(fd); break;
- case 0x3827: intif->pPartyMessage(fd); break;
- case 0x3830: intif->pGuildCreated(fd); break;
- case 0x3831: intif->pGuildInfo(fd); break;
- case 0x3832: intif->pGuildMemberAdded(fd); break;
- case 0x3834: intif->pGuildMemberWithdraw(fd); break;
- case 0x3835: intif->pGuildMemberInfoShort(fd); break;
- case 0x3836: intif->pGuildBroken(fd); break;
- case 0x3837: intif->pGuildMessage(fd); break;
- case 0x3839: intif->pGuildBasicInfoChanged(fd); break;
- case 0x383a: intif->pGuildMemberInfoChanged(fd); break;
- case 0x383b: intif->pGuildPosition(fd); break;
- case 0x383c: intif->pGuildSkillUp(fd); break;
- case 0x383d: intif->pGuildAlliance(fd); break;
- case 0x383e: intif->pGuildNotice(fd); break;
- case 0x383f: intif->pGuildEmblem(fd); break;
- case 0x3840: intif->pGuildCastleDataLoad(fd); break;
- case 0x3843: intif->pGuildMasterChanged(fd); break;
+ case 0x3801: intif->pWisMessage(fd); break;
+ case 0x3802: intif->pWisEnd(fd); break;
+ case 0x3803: intif->pWisToGM(fd); break;
+ case 0x3804: intif->pRegisters(fd); break;
+ case 0x3806: intif->pChangeNameOk(fd); break;
+ case 0x3807: intif->pMessageToFD(fd); break;
+ case 0x3818: intif->pLoadGuildStorage(fd); break;
+ case 0x3819: intif->pSaveGuildStorage(fd); break;
+ case 0x3820: intif->pPartyCreated(fd); break;
+ case 0x3821: intif->pPartyInfo(fd); break;
+ case 0x3822: intif->pPartyMemberAdded(fd); break;
+ case 0x3823: intif->pPartyOptionChanged(fd); break;
+ case 0x3824: intif->pPartyMemberWithdraw(fd); break;
+ case 0x3825: intif->pPartyMove(fd); break;
+ case 0x3826: intif->pPartyBroken(fd); break;
+ case 0x3827: intif->pPartyMessage(fd); break;
+ case 0x3830: intif->pGuildCreated(fd); break;
+ case 0x3831: intif->pGuildInfo(fd); break;
+ case 0x3832: intif->pGuildMemberAdded(fd); break;
+ case 0x3834: intif->pGuildMemberWithdraw(fd); break;
+ case 0x3835: intif->pGuildMemberInfoShort(fd); break;
+ case 0x3836: intif->pGuildBroken(fd); break;
+ case 0x3837: intif->pGuildMessage(fd); break;
+ case 0x3839: intif->pGuildBasicInfoChanged(fd); break;
+ case 0x383a: intif->pGuildMemberInfoChanged(fd); break;
+ case 0x383b: intif->pGuildPosition(fd); break;
+ case 0x383c: intif->pGuildSkillUp(fd); break;
+ case 0x383d: intif->pGuildAlliance(fd); break;
+ case 0x383e: intif->pGuildNotice(fd); break;
+ case 0x383f: intif->pGuildEmblem(fd); break;
+ case 0x3840: intif->pGuildCastleDataLoad(fd); break;
+ case 0x3843: intif->pGuildMasterChanged(fd); break;
//Quest system
- case 0x3860: intif->pQuestLog(fd); break;
- case 0x3861: intif->pQuestSave(fd); break;
+ case 0x3860: intif->pQuestLog(fd); break;
+ case 0x3861: intif->pQuestSave(fd); break;
// Mail System
- case 0x3848: intif->pMailInboxReceived(fd); break;
- case 0x3849: intif->pMailNew(fd); break;
- case 0x384a: intif->pMailGetAttach(fd); break;
- case 0x384b: intif->pMailDelete(fd); break;
- case 0x384c: intif->pMailReturn(fd); break;
- case 0x384d: intif->pMailSend(fd); break;
+ case 0x3848: intif->pMailInboxReceived(fd); break;
+ case 0x3849: intif->pMailNew(fd); break;
+ case 0x384a: intif->pMailGetAttach(fd); break;
+ case 0x384b: intif->pMailDelete(fd); break;
+ case 0x384c: intif->pMailReturn(fd); break;
+ case 0x384d: intif->pMailSend(fd); break;
// Auction System
- case 0x3850: intif->pAuctionResults(fd); break;
- case 0x3851: intif->pAuctionRegister(fd); break;
- case 0x3852: intif->pAuctionCancel(fd); break;
- case 0x3853: intif->pAuctionClose(fd); break;
- case 0x3854: intif->pAuctionMessage(fd); break;
- case 0x3855: intif->pAuctionBid(fd); break;
+ case 0x3850: intif->pAuctionResults(fd); break;
+ case 0x3851: intif->pAuctionRegister(fd); break;
+ case 0x3852: intif->pAuctionCancel(fd); break;
+ case 0x3853: intif->pAuctionClose(fd); break;
+ case 0x3854: intif->pAuctionMessage(fd); break;
+ case 0x3855: intif->pAuctionBid(fd); break;
//Bound items
case 0x3856:
#ifdef GP_BOUND_ITEMS
@@ -2281,27 +2280,27 @@ int intif_parse(int fd)
#endif
break;
// Mercenary System
- case 0x3870: intif->pMercenaryReceived(fd); break;
- case 0x3871: intif->pMercenaryDeleted(fd); break;
- case 0x3872: intif->pMercenarySaved(fd); break;
+ case 0x3870: intif->pMercenaryReceived(fd); break;
+ case 0x3871: intif->pMercenaryDeleted(fd); break;
+ case 0x3872: intif->pMercenarySaved(fd); break;
// Elemental System
- case 0x387c: intif->pElementalReceived(fd); break;
- case 0x387d: intif->pElementalDeleted(fd); break;
- case 0x387e: intif->pElementalSaved(fd); break;
+ case 0x387c: intif->pElementalReceived(fd); break;
+ case 0x387d: intif->pElementalDeleted(fd); break;
+ case 0x387e: intif->pElementalSaved(fd); break;
- case 0x3880: intif->pCreatePet(fd); break;
- case 0x3881: intif->pRecvPetData(fd); break;
- case 0x3882: intif->pSavePetOk(fd); break;
- case 0x3883: intif->pDeletePetOk(fd); break;
- case 0x3890: intif->pCreateHomunculus(fd); break;
- case 0x3891: intif->pRecvHomunculusData(fd); break;
- case 0x3892: intif->pSaveHomunculusOk(fd); break;
- case 0x3893: intif->pDeleteHomunculusOk(fd); break;
+ case 0x3880: intif->pCreatePet(fd); break;
+ case 0x3881: intif->pRecvPetData(fd); break;
+ case 0x3882: intif->pSavePetOk(fd); break;
+ case 0x3883: intif->pDeletePetOk(fd); break;
+ case 0x3890: intif->pCreateHomunculus(fd); break;
+ case 0x3891: intif->pRecvHomunculusData(fd); break;
+ case 0x3892: intif->pSaveHomunculusOk(fd); break;
+ case 0x3893: intif->pDeleteHomunculusOk(fd); break;
default:
ShowError("intif_parse : unknown packet %d %x\n",fd,RFIFOW(fd,0));
return 0;
}
- // Skip packet
+ // Skip packet
RFIFOSKIP(fd,packet_len);
return 1;
}
diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c
index 6f016697f..8b4991c20 100644
--- a/src/map/irc-bot.c
+++ b/src/map/irc-bot.c
@@ -41,7 +41,7 @@ int irc_connect_timer(int tid, int64 tick, int id, intptr_t data) {
ircbot->last_try = timer->gettick();
- if( ( ircbot->fd = make_connection(ircbot->ip,hChSys.irc_server_port,&opt) ) > 0 ){
+ if ((ircbot->fd = make_connection(ircbot->ip, clif->hChSys->irc_server_port, &opt)) > 0) {
session[ircbot->fd]->func_parse = ircbot->parse;
session[ircbot->fd]->flag.server = 1;
timer->add(timer->gettick() + 3000, ircbot->identify_timer, 0, 0);
@@ -60,7 +60,7 @@ int irc_identify_timer(int tid, int64 tick, int id, intptr_t data) {
sprintf(send_string, "USER HerculesWS%d 8 * : Hercules IRC Bridge",rand()%777);
ircbot->send(send_string);
- sprintf(send_string, "NICK %s", hChSys.irc_nick);
+ sprintf(send_string, "NICK %s", clif->hChSys->irc_nick);
ircbot->send(send_string);
timer->add(timer->gettick() + 3000, ircbot->join_timer, 0, 0);
@@ -76,15 +76,15 @@ int irc_join_timer(int tid, int64 tick, int id, intptr_t data) {
if( !ircbot->isOn )
return 0;
- if( hChSys.irc_nick_pw[0] != '\0' ) {
- sprintf(send_string, "PRIVMSG NICKSERV : IDENTIFY %s", hChSys.irc_nick_pw);
+ if (clif->hChSys->irc_nick_pw[0] != '\0') {
+ sprintf(send_string, "PRIVMSG NICKSERV : IDENTIFY %s", clif->hChSys->irc_nick_pw);
ircbot->send(send_string);
- if( hChSys.irc_use_ghost ) {
- sprintf(send_string, "PRIVMSG NICKSERV : GHOST %s %s", hChSys.irc_nick, hChSys.irc_nick_pw);
+ if (clif->hChSys->irc_use_ghost) {
+ sprintf(send_string, "PRIVMSG NICKSERV : GHOST %s %s", clif->hChSys->irc_nick, clif->hChSys->irc_nick_pw);
}
}
- sprintf(send_string, "JOIN %s", hChSys.irc_channel);
+ sprintf(send_string, "JOIN %s", clif->hChSys->irc_channel);
ircbot->send(send_string);
ircbot->isIn = true;
@@ -120,9 +120,9 @@ int irc_parse(int fd) {
ircbot->isOn = false;
ircbot->isIn = false;
ircbot->fails = 0;
- ircbot->ip = host2ip(hChSys.irc_server);
+ ircbot->ip = host2ip(clif->hChSys->irc_server);
timer->add(timer->gettick() + 120000, ircbot->connect_timer, 0, 0);
- return 0;
+ return 0;
}
if( !RFIFOREST(fd) )
@@ -289,10 +289,10 @@ void irc_privmsg(int fd, char *cmd, char *source, char *target, char *msg) {
irc_privmsg_ctcp(fd, command, source, target, message);
#ifdef IRCBOT_DEBUG
- } else if( strcmpi(target,hChSys.irc_nick) == 0 ) {
+ } else if (strcmpi(target, clif->hChSys->irc_nick) == 0) {
ShowDebug("irc_privmsg: Received message from %s: '%s'\n", source ? source : "(null)", msg);
#endif // IRCBOT_DEBUG
- } else if( msg && strcmpi(target,hChSys.irc_channel) == 0 ) {
+ } else if (msg && strcmpi(target, clif->hChSys->irc_channel) == 0) {
char source_nick[IRC_NICK_LENGTH], source_ident[IRC_IDENT_LENGTH], source_host[IRC_HOST_LENGTH];
source_nick[0] = source_ident[0] = source_host[0] = '\0';
@@ -382,7 +382,7 @@ void irc_usernick(int fd, char *cmd, char *source, char *target, char *msg) {
void irc_relay(char *name, const char *msg) {
if( !ircbot->isIn )
return;
- sprintf(send_string,"PRIVMSG %s :[ %s ] : %s",hChSys.irc_channel,name,msg);
+ sprintf(send_string,"PRIVMSG %s :[ %s ] : %s", clif->hChSys->irc_channel, name, msg);
ircbot->send(send_string);
}
@@ -405,12 +405,12 @@ void irc_bot_init(bool minimal) {
if (minimal)
return;
- if( !hChSys.irc )
+ if (!clif->hChSys->irc)
return;
- if (!(ircbot->ip = host2ip(hChSys.irc_server))) {
- ShowError("Unable to resolve '%s' (irc server), disabling irc channel...\n", hChSys.irc_server);
- hChSys.irc = false;
+ if (!(ircbot->ip = host2ip(clif->hChSys->irc_server))) {
+ ShowError("Unable to resolve '%s' (irc server), disabling irc channel...\n", clif->hChSys->irc_server);
+ clif->hChSys->irc = false;
return;
}
@@ -443,7 +443,7 @@ void irc_bot_init(bool minimal) {
void irc_bot_final(void) {
int i;
- if( !hChSys.irc )
+ if (!clif->hChSys->irc)
return;
if( ircbot->isOn ) {
ircbot->send("QUIT :Hercules is shutting down");
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 0d3146191..19cc02d21 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -16,6 +16,7 @@
#include "mob.h" // MAX_MOB_DB
#include "pc.h" // W_MUSICAL, W_WHIP
#include "script.h" // item script processing
+#include "../common/HPM.h"
#include "../common/conf.h"
#include "../common/malloc.h"
#include "../common/nullpo.h"
@@ -320,8 +321,8 @@ void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask)
int i;
bclass[0]= bclass[1]= bclass[2]= 0;
//Base classes
- if (jobmask & 1<<JOB_NOVICE)
- { //Both Novice/Super-Novice are counted with the same ID
+ if (jobmask & 1<<JOB_NOVICE) {
+ //Both Novice/Super-Novice are counted with the same ID
bclass[0] |= 1<<MAPID_NOVICE;
bclass[1] |= 1<<MAPID_NOVICE;
}
@@ -354,9 +355,10 @@ void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask)
bclass[2] |= 1<<MAPID_MERCHANT;
if (jobmask & 1<<JOB_BARD)
bclass[2] |= 1<<MAPID_ARCHER;
-// Bard/Dancer share the same slot now.
-// if (jobmask & 1<<JOB_DANCER)
-// bclass[2] |= 1<<MAPID_ARCHER;
+#if 0 // Bard/Dancer share the same slot now.
+ if (jobmask & 1<<JOB_DANCER)
+ bclass[2] |= 1<<MAPID_ARCHER;
+#endif // 0
if (jobmask & 1<<JOB_ROGUE)
bclass[2] |= 1<<MAPID_THIEF;
//Special classes that don't fit above.
@@ -487,16 +489,16 @@ int itemdb_isequip2(struct item_data *data) {
*------------------------------------------*/
int itemdb_isstackable(int nameid)
{
- int type=itemdb_type(nameid);
- switch(type) {
- case IT_WEAPON:
- case IT_ARMOR:
- case IT_PETEGG:
- case IT_PETARMOR:
- return 0;
- default:
- return 1;
- }
+ int type=itemdb_type(nameid);
+ switch(type) {
+ case IT_WEAPON:
+ case IT_ARMOR:
+ case IT_PETEGG:
+ case IT_PETARMOR:
+ return 0;
+ default:
+ return 1;
+ }
}
/*==========================================
@@ -504,16 +506,16 @@ int itemdb_isstackable(int nameid)
*------------------------------------------*/
int itemdb_isstackable2(struct item_data *data)
{
- nullpo_ret(data);
- switch(data->type) {
- case IT_WEAPON:
- case IT_ARMOR:
- case IT_PETEGG:
- case IT_PETARMOR:
- return 0;
- default:
- return 1;
- }
+ nullpo_ret(data);
+ switch(data->type) {
+ case IT_WEAPON:
+ case IT_ARMOR:
+ case IT_PETEGG:
+ case IT_PETARMOR:
+ return 0;
+ default:
+ return 1;
+ }
}
@@ -576,7 +578,7 @@ int itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, int (*func)(stru
}
/*==========================================
- * Specifies if item-type should drop unidentified.
+ * Specifies if item-type should drop unidentified.
*------------------------------------------*/
int itemdb_isidentified(int nameid) {
int type=itemdb_type(nameid);
@@ -1500,6 +1502,11 @@ int itemdb_validate_entry(struct item_data *entry, int n, const char *source) {
return item->nameid;
}
+void itemdb_readdb_additional_fields(int itemid, config_setting_t *it, int n, const char *source)
+{
+ // do nothing. plugins can do own work
+}
+
/**
* Processes one itemdb entry from the sql backend, loading and inserting it
* into the item database.
@@ -1675,7 +1682,7 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
* OnUnequipScript: <" OnUnequip Script ">
* Inherit: inherit or override
*/
- if( !libconfig->setting_lookup_int(it, "Id", &i32) ) {
+ if( !itemdb->lookup_const(it, "Id", &i32) ) {
ShowWarning("itemdb_readdb_libconfig_sub: Invalid or missing id in \"%s\", entry #%d, skipping.\n", source, n);
return 0;
}
@@ -1710,57 +1717,57 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
safestrncpy(id.jname, str, sizeof(id.jname));
}
- if( libconfig->setting_lookup_int(it, "Type", &i32) )
+ if( itemdb->lookup_const(it, "Type", &i32) )
id.type = i32;
else if( !inherit )
- id.type = IT_UNKNOWN;
+ id.type = IT_ETC;
- if( libconfig->setting_lookup_int(it, "Buy", &i32) )
+ if( itemdb->lookup_const(it, "Buy", &i32) )
id.value_buy = i32;
else if( !inherit )
id.value_buy = -1;
- if( libconfig->setting_lookup_int(it, "Sell", &i32) )
+ if( itemdb->lookup_const(it, "Sell", &i32) )
id.value_sell = i32;
else if( !inherit )
id.value_sell = -1;
- if( libconfig->setting_lookup_int(it, "Weight", &i32) && i32 >= 0 )
+ if( itemdb->lookup_const(it, "Weight", &i32) && i32 >= 0 )
id.weight = i32;
- if( libconfig->setting_lookup_int(it, "Atk", &i32) && i32 >= 0 )
+ if( itemdb->lookup_const(it, "Atk", &i32) && i32 >= 0 )
id.atk = i32;
- if( libconfig->setting_lookup_int(it, "Matk", &i32) && i32 >= 0 )
+ if( itemdb->lookup_const(it, "Matk", &i32) && i32 >= 0 )
id.matk = i32;
- if( libconfig->setting_lookup_int(it, "Def", &i32) && i32 >= 0 )
+ if( itemdb->lookup_const(it, "Def", &i32) && i32 >= 0 )
id.def = i32;
- if( libconfig->setting_lookup_int(it, "Range", &i32) && i32 >= 0 )
+ if( itemdb->lookup_const(it, "Range", &i32) && i32 >= 0 )
id.range = i32;
- if( libconfig->setting_lookup_int(it, "Slots", &i32) && i32 >= 0 )
+ if( itemdb->lookup_const(it, "Slots", &i32) && i32 >= 0 )
id.slot = i32;
- if( libconfig->setting_lookup_int(it, "Job", &i32) ) // This is an unsigned value, do not check for >= 0
+ if( itemdb->lookup_const(it, "Job", &i32) ) // This is an unsigned value, do not check for >= 0
itemdb->jobid2mapid(id.class_base, (unsigned int)i32);
else if( !inherit )
itemdb->jobid2mapid(id.class_base, UINT_MAX);
- if( libconfig->setting_lookup_int(it, "Upper", &i32) && i32 >= 0 )
+ if( itemdb->lookup_const(it, "Upper", &i32) && i32 >= 0 )
id.class_upper = (unsigned int)i32;
else if( !inherit )
id.class_upper = ITEMUPPER_ALL;
- if( libconfig->setting_lookup_int(it, "Gender", &i32) && i32 >= 0 )
+ if( itemdb->lookup_const(it, "Gender", &i32) && i32 >= 0 )
id.sex = i32;
else if( !inherit )
id.sex = 2;
- if( libconfig->setting_lookup_int(it, "Loc", &i32) && i32 >= 0 )
+ if( itemdb->lookup_const(it, "Loc", &i32) && i32 >= 0 )
id.equip = i32;
- if( libconfig->setting_lookup_int(it, "WeaponLv", &i32) && i32 >= 0 )
+ if( itemdb->lookup_const(it, "WeaponLv", &i32) && i32 >= 0 )
id.wlv = i32;
if( (t = libconfig->setting_get_member(it, "EquipLv")) ) {
@@ -1777,7 +1784,7 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
if( (t = libconfig->setting_get_member(it, "Refine")) )
id.flag.no_refine = libconfig->setting_get_bool(t) ? 0 : 1;
- if( libconfig->setting_lookup_int(it, "View", &i32) && i32 >= 0 )
+ if( itemdb->lookup_const(it, "View", &i32) && i32 >= 0 )
id.look = i32;
if( (t = libconfig->setting_get_member(it, "BindOnEquip")) )
@@ -1786,9 +1793,12 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
if ( (t = libconfig->setting_get_member(it, "BuyingStore")) )
id.flag.buyingstore = libconfig->setting_get_bool(t) ? 1 : 0;
- if (libconfig->setting_lookup_int(it, "Delay", &i32) && i32 >= 0)
+ if ((t = libconfig->setting_get_member(it, "KeepAfterUse")))
+ id.flag.keepafteruse = libconfig->setting_get_bool(t) ? 1 : 0;
+
+ if (itemdb->lookup_const(it, "Delay", &i32) && i32 >= 0)
id.delay = i32;
-
+
if ( (t = libconfig->setting_get_member(it, "Trade")) ) {
if (config_setting_is_group(t)) {
config_setting_t *tt = NULL;
@@ -1888,7 +1898,7 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
}
}
- if (libconfig->setting_lookup_int(it, "Sprite", &i32) && i32 >= 0) {
+ if (itemdb->lookup_const(it, "Sprite", &i32) && i32 >= 0) {
id.flag.available = 1;
id.view_id = i32;
}
@@ -1905,6 +1915,24 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
return itemdb->validate_entry(&id, n, source);
}
+bool itemdb_lookup_const(const config_setting_t *it, const char *name, int *value)
+{
+ if (libconfig->setting_lookup_int(it, name, value))
+ {
+ return true;
+ }
+ else
+ {
+ const char *str = NULL;
+ if (libconfig->setting_lookup_string(it, name, &str))
+ {
+ if (*str && script->get_constant(str, value))
+ return true;
+ }
+ }
+ return false;
+}
+
/**
* Reads from a libconfig-formatted itemdb file and inserts the found entries into the
* item database, overwriting duplicate ones (i.e. item_db2 overriding item_db.)
@@ -1932,6 +1960,7 @@ int itemdb_readdb_libconfig(const char *filename) {
if( !nameid )
continue;
+ itemdb->readdb_additional_fields(nameid, it, i - 1, filename);
count++;
if( duplicate[nameid] ) {
@@ -2050,6 +2079,14 @@ struct item_combo * itemdb_id2combo( unsigned short id ) {
return itemdb->combos[id];
}
+/**
+ * check is item have usable type
+ **/
+bool itemdb_is_item_usable(struct item_data *item)
+{
+ return item->type == IT_HEALING || item->type == IT_USABLE || item->type == IT_CASH;
+}
+
/*==========================================
* Initialize / Finalize
*------------------------------------------*/
@@ -2057,6 +2094,7 @@ struct item_combo * itemdb_id2combo( unsigned short id ) {
/// Destroys the item_data.
void destroy_item_data(struct item_data* self, int free_self)
{
+ int v;
if( self == NULL )
return;
// free scripts
@@ -2068,6 +2106,14 @@ void destroy_item_data(struct item_data* self, int free_self)
script->free_code(self->unequip_script);
if( self->combos )
aFree(self->combos);
+ for (v = 0; v < self->hdatac; v++ ) {
+ if (self->hdata[v]->flag.free ) {
+ aFree(self->hdata[v]->data);
+ }
+ aFree(self->hdata[v]);
+ }
+ if (self->hdata)
+ aFree(self->hdata);
#if defined(DEBUG)
// trash item
memset(self, 0xDD, sizeof(struct item_data));
@@ -2248,6 +2294,10 @@ void do_init_itemdb(bool minimal) {
return;
clif->cashshop_load();
+
+ /** it failed? we disable it **/
+ if( !clif->parse_roulette_db() )
+ battle_config.feature_roulette = 0;
}
void itemdb_defaults(void) {
itemdb = &itemdb_s;
@@ -2319,6 +2369,7 @@ void itemdb_defaults(void) {
itemdb->read_combos = itemdb_read_combos;
itemdb->gendercheck = itemdb_gendercheck;
itemdb->validate_entry = itemdb_validate_entry;
+ itemdb->readdb_additional_fields = itemdb_readdb_additional_fields;
itemdb->readdb_sql_sub = itemdb_readdb_sql_sub;
itemdb->readdb_libconfig_sub = itemdb_readdb_libconfig_sub;
itemdb->readdb_libconfig = itemdb_readdb_libconfig;
@@ -2329,4 +2380,6 @@ void itemdb_defaults(void) {
itemdb->final_sub = itemdb_final_sub;
itemdb->clear = itemdb_clear;
itemdb->id2combo = itemdb_id2combo;
+ itemdb->is_item_usable = itemdb_is_item_usable;
+ itemdb->lookup_const = itemdb_lookup_const;
}
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 198d7a542..902e6e5e9 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -41,7 +41,9 @@ enum item_itemid {
ITEMID_YELLOW_POTION = 503,
ITEMID_WHITE_POTION = 504,
ITEMID_BLUE_POTION = 505,
+ ITEMID_APPLE = 512,
ITEMID_HOLY_WATER = 523,
+ ITEMID_PUMPKIN = 535,
ITEMID_RED_SLIM_POTION = 545,
ITEMID_YELLOW_SLIM_POTION = 546,
ITEMID_WHITE_SLIM_POTION = 547,
@@ -372,7 +374,7 @@ enum ItemNouseRestrictions {
struct item_data {
uint16 nameid;
char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH];
-
+
//Do not add stuff between value_buy and view_id (see how getiteminfo works)
int value_buy;
int value_sell;
@@ -394,24 +396,25 @@ struct item_data {
int delay;
//Lupus: I rearranged order of these fields due to compatibility with ITEMINFO script command
-// some script commands should be revised as well...
- unsigned int class_base[3]; //Specifies if the base can wear this item (split in 3 indexes per type: 1-1, 2-1, 2-2)
- unsigned class_upper : 6; //Specifies if the upper-type can equip it (bitfield, 0x01: normal, 0x02: upper, 0x04: baby normal, 0x08: third normal, 0x10: third upper, 0x20: third baby)
+// some script commands should be revised as well...
+ unsigned int class_base[3]; ///< Specifies if the base can wear this item (split in 3 indexes per type: 1-1, 2-1, 2-2)
+ unsigned class_upper : 6; ///< Specifies if the upper-type can equip it (bitfield, 0x01: normal, 0x02: upper, 0x04: baby normal, 0x08: third normal, 0x10: third upper, 0x20: third baby)
struct {
unsigned short chance;
int id;
- } mob[MAX_SEARCH]; //Holds the mobs that have the highest drop rate for this item. [Skotlex]
- struct script_code *script; //Default script for everything.
- struct script_code *equip_script; //Script executed once when equipping.
- struct script_code *unequip_script;//Script executed once when unequipping.
+ } mob[MAX_SEARCH]; ///< Holds the mobs that have the highest drop rate for this item. [Skotlex]
+ struct script_code *script; ///< Default script for everything.
+ struct script_code *equip_script; ///< Script executed once when equipping.
+ struct script_code *unequip_script; ///< Script executed once when unequipping.
struct {
unsigned available : 1;
- unsigned no_refine : 1; // [celest]
- unsigned delay_consume : 1; // Signifies items that are not consumed immediately upon double-click [Skotlex]
- unsigned trade_restriction : 9; ///< Item trade restrictions mask (@see enum ItemTradeRestrictions)
+ unsigned no_refine : 1; // [celest]
+ unsigned delay_consume : 1; ///< Signifies items that are not consumed immediately upon double-click [Skotlex]
+ unsigned trade_restriction : 9; ///< Item trade restrictions mask (@see enum ItemTradeRestrictions)
unsigned autoequip: 1;
unsigned buyingstore : 1;
unsigned bindonequip : 1;
+ unsigned keepafteruse : 1;
} flag;
struct {// item stacking limitation
unsigned short amount;
@@ -424,13 +427,17 @@ struct item_data {
unsigned int flag; ///< Item nouse restriction mask (@see enum ItemNouseRestrictions)
unsigned short override;
} item_usage;
- short gm_lv_trade_override; //GM-level to override trade_restriction
+ short gm_lv_trade_override; ///< GM-level to override trade_restriction
/* bugreport:309 */
struct item_combo **combos;
unsigned char combos_count;
/* TODO add a pointer to some sort of (struct extra) and gather all the not-common vals into it to save memory */
struct item_group *group;
struct item_package *package;
+
+ /* HPM Custom Struct */
+ struct HPluginData **hdata;
+ unsigned int hdatac;
};
struct item_combo {
@@ -597,6 +604,7 @@ struct itemdb_interface {
void (*read_combos) ();
int (*gendercheck) (struct item_data *id);
int (*validate_entry) (struct item_data *entry, int n, const char *source);
+ void (*readdb_additional_fields) (int itemid, config_setting_t *it, int n, const char *source);
int (*readdb_sql_sub) (Sql *handle, int n, const char *source);
int (*readdb_libconfig_sub) (config_setting_t *it, int n, const char *source);
int (*readdb_libconfig) (const char *filename);
@@ -607,6 +615,8 @@ struct itemdb_interface {
int (*final_sub) (DBKey key, DBData *data, va_list ap);
void (*clear) (bool total);
struct item_combo * (*id2combo) (unsigned short id);
+ bool (*is_item_usable) (struct item_data *item);
+ bool (*lookup_const) (const config_setting_t *it, const char *name, int *value);
};
struct itemdb_interface *itemdb;
diff --git a/src/map/log.c b/src/map/log.c
index b5179e16b..92956fa67 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -20,6 +20,7 @@
#include "../common/showmsg.h"
#include "../common/sql.h" // SQL_INNODB
#include "../common/strlib.h"
+#include "../common/HPM.h"
struct log_interface log_s;
@@ -44,7 +45,7 @@ char log_picktype2char(e_log_pick_type type) {
case LOG_TYPE_BUYING_STORE: return 'B'; // (B)uying Store
case LOG_TYPE_LOOT: return 'L'; // (L)oot (consumed monster pick/drop)
case LOG_TYPE_BANK: return 'K'; // Ban(K) Transactions
- case LOG_TYPE_OTHER: return 'X'; // Other
+ case LOG_TYPE_OTHER: return 'X'; // Other
}
// should not get here, fallback
@@ -452,7 +453,9 @@ int log_config_read(const char* cfgName) {
safestrncpy(logs->config.log_chat, w2, sizeof(logs->config.log_chat));
//support the import command, just like any other config
else if( strcmpi(w1,"import") == 0 )
- log_config_read(w2);
+ logs->config_read(w2);
+ else if (HPM->parseConf(w1, w2, HPCT_LOG))
+ ; // handled by plugins
else
ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
}
diff --git a/src/map/log.h b/src/map/log.h
index 6ab142f87..fb61b6e66 100644
--- a/src/map/log.h
+++ b/src/map/log.h
@@ -98,7 +98,7 @@ struct log_interface {
char db_ip[32];
int db_port;
char db_id[32];
- char db_pw[32];
+ char db_pw[100];
char db_name[32];
Sql* mysql_handle;
/* */
@@ -110,7 +110,7 @@ struct log_interface {
void (*atcommand) (struct map_session_data* sd, const char* message);
void (*branch) (struct map_session_data* sd);
void (*mvpdrop) (struct map_session_data* sd, int monster_id, int* log_mvp);
-
+
void (*pick_sub) (int id, int16 m, e_log_pick_type type, int amount, struct item* itm, struct item_data *data);
void (*zeny_sub) (struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount);
void (*npc_sub) (struct map_session_data* sd, const char *message);
@@ -118,12 +118,12 @@ struct log_interface {
void (*atcommand_sub) (struct map_session_data* sd, const char* message);
void (*branch_sub) (struct map_session_data* sd);
void (*mvpdrop_sub) (struct map_session_data* sd, int monster_id, int* log_mvp);
-
+
int (*config_read) (const char* cfgName);
void (*config_done) (void);
void (*sql_init) (void);
void (*sql_final) (void);
-
+
char (*picktype2char) (e_log_pick_type type);
char (*chattype2char) (e_log_chat_type type);
bool (*should_log_item) (int nameid, int amount, int refine, struct item_data *id);
diff --git a/src/map/map.c b/src/map/map.c
index 0c8c2d949..25d7ce692 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -309,7 +309,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, int64 tick) {
skill->unit_move(bl,tick,2);
status_change_end(bl, SC_RG_CCONFINE_M, INVALID_TIMER);
status_change_end(bl, SC_RG_CCONFINE_S, INVALID_TIMER);
- // status_change_end(bl, SC_BLADESTOP, INVALID_TIMER); //Won't stop when you are knocked away, go figure...
+ //status_change_end(bl, SC_BLADESTOP, INVALID_TIMER); //Won't stop when you are knocked away, go figure...
status_change_end(bl, SC_NJ_TATAMIGAESHI, INVALID_TIMER);
status_change_end(bl, SC_MAGICROD, INVALID_TIMER);
if (sc && sc->data[SC_PROPERTYWALK] &&
@@ -395,9 +395,12 @@ int map_moveblock(struct block_list *bl, int x1, int y1, int64 tick) {
/*==========================================
* Counts specified number of objects on given cell.
+ * flag:
+ * 0x1 - only count standing units
+ * 0x2 - don't count invinsible units
* TODO: merge with bl_getall_area
*------------------------------------------*/
-int map_count_oncell(int16 m, int16 x, int16 y, int type) {
+int map_count_oncell(int16 m, int16 x, int16 y, int type, int flag) {
int bx,by;
struct block_list *bl;
int count = 0;
@@ -408,15 +411,41 @@ int map_count_oncell(int16 m, int16 x, int16 y, int type) {
bx = x/BLOCK_SIZE;
by = y/BLOCK_SIZE;
- if (type&~BL_MOB)
- for( bl = map->list[m].block[bx+by*map->list[m].bxs] ; bl != NULL ; bl = bl->next )
- if(bl->x == x && bl->y == y && bl->type&type)
+ if (type&~BL_MOB) {
+ for (bl = map->list[m].block[bx+by*map->list[m].bxs]; bl != NULL; bl = bl->next) {
+ if (bl->x == x && bl->y == y && bl->type&type) {
+ if (flag&0x2) {
+ struct status_change *sc = status->get_sc(bl);
+ if (sc && (sc->option&OPTION_INVISIBLE))
+ continue;
+ }
+ if (flag&0x1) {
+ struct unit_data *ud = unit->bl2ud(bl);
+ if (ud && ud->walktimer != INVALID_TIMER)
+ continue;
+ }
count++;
+ }
+ }
+ }
- if (type&BL_MOB)
- for( bl = map->list[m].block_mob[bx+by*map->list[m].bxs] ; bl != NULL ; bl = bl->next )
- if(bl->x == x && bl->y == y)
+ if (type&BL_MOB) {
+ for (bl = map->list[m].block_mob[bx+by*map->list[m].bxs]; bl != NULL; bl = bl->next) {
+ if (bl->x == x && bl->y == y) {
+ if (flag&0x2) {
+ struct status_change *sc = status->get_sc(bl);
+ if (sc && (sc->option&OPTION_INVISIBLE))
+ continue;
+ }
+ if (flag&0x1) {
+ struct unit_data *ud = unit->bl2ud(bl);
+ if (ud && ud->walktimer != INVALID_TIMER)
+ continue;
+ }
count++;
+ }
+ }
+ }
return count;
}
@@ -1379,7 +1408,7 @@ int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) {
if(map->getcell(m,j+*x,i+*y,CELL_CHKNOPASS) && !map->getcell(m,j+*x,i+*y,CELL_CHKICEWALL))
continue;
//Avoid item stacking to prevent against exploits. [Skotlex]
- if(stack && map->count_oncell(m,j+*x,i+*y, BL_ITEM) > stack)
+ if(stack && map->count_oncell(m,j+*x,i+*y, BL_ITEM, 0) > stack)
continue;
free_cells[free_cell][0] = j+*x;
free_cells[free_cell++][1] = i+*y;
@@ -1473,6 +1502,85 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1
}
/*==========================================
+ * Locates the closest, walkable cell with no blocks of a certain type on it
+ * Returns true on success and sets x and y to cell found.
+ * Otherwise returns false and x and y are not changed.
+ * type: Types of block to count
+ * flag:
+ * 0x1 - only count standing units
+ *------------------------------------------*/
+bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag)
+{
+ uint8 dir = 6;
+ int16 tx = *x;
+ int16 ty = *y;
+ int costrange = 10;
+
+ if(!map->count_oncell(m, tx, ty, type, flag))
+ return true; //Current cell is free
+
+ //Algorithm only works up to costrange of 34
+ while(costrange <= 34) {
+ short dx = dirx[dir];
+ short dy = diry[dir];
+
+ //Linear search
+ if(dir%2 == 0 && costrange%MOVE_COST == 0) {
+ tx = *x+dx*(costrange/MOVE_COST);
+ ty = *y+dy*(costrange/MOVE_COST);
+ if(!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m,tx,ty,CELL_CHKPASS)) {
+ *x = tx;
+ *y = ty;
+ return true;
+ }
+ }
+ //Full diagonal search
+ else if(dir%2 == 1 && costrange%MOVE_DIAGONAL_COST == 0) {
+ tx = *x+dx*(costrange/MOVE_DIAGONAL_COST);
+ ty = *y+dy*(costrange/MOVE_DIAGONAL_COST);
+ if(!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m,tx,ty,CELL_CHKPASS)) {
+ *x = tx;
+ *y = ty;
+ return true;
+ }
+ }
+ //One cell diagonal, rest linear (TODO: Find a better algorithm for this)
+ else if(dir%2 == 1 && costrange%MOVE_COST == 4) {
+ tx = *x+dx*((dir%4==3)?(costrange/MOVE_COST):1);
+ ty = *y+dy*((dir%4==1)?(costrange/MOVE_COST):1);
+ if(!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m,tx,ty,CELL_CHKPASS)) {
+ *x = tx;
+ *y = ty;
+ return true;
+ }
+ tx = *x+dx*((dir%4==1)?(costrange/MOVE_COST):1);
+ ty = *y+dy*((dir%4==3)?(costrange/MOVE_COST):1);
+ if(!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m,tx,ty,CELL_CHKPASS)) {
+ *x = tx;
+ *y = ty;
+ return true;
+ }
+ }
+
+ //Get next direction
+ if (dir == 5) {
+ //Diagonal search complete, repeat with higher cost range
+ if(costrange == 14) costrange += 6;
+ else if(costrange == 28 || costrange >= 38) costrange += 2;
+ else costrange += 4;
+ dir = 6;
+ } else if (dir == 4) {
+ //Linear search complete, switch to diagonal directions
+ dir = 7;
+ } else {
+ dir = (dir+2)%8;
+ }
+ }
+
+ return false;
+}
+
+/*==========================================
* Add an item to location (m,x,y)
* Parameters
* @item_data item attributes
@@ -1692,7 +1800,7 @@ 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->state.autotrade && runflag != MAPSERVER_ST_SHUTDOWN && !hChSys.closing )
+ if (sd->state.autotrade && runflag != MAPSERVER_ST_SHUTDOWN && !clif->hChSys->closing)
pc->autotrade_update(sd,PAUC_REMOVE);
skill->cooldown_save(sd);
@@ -1749,7 +1857,7 @@ int map_quit(struct map_session_data *sd) {
unit->remove_map(&sd->ed->bl,CLR_TELEPORT,ALC_MARK);
}
- if( hChSys.local && map->list[sd->bl.m].channel && idb_exists(map->list[sd->bl.m].channel->users, sd->status.char_id) ) {
+ if (clif->hChSys->local && map->list[sd->bl.m].channel && idb_exists(map->list[sd->bl.m].channel->users, sd->status.char_id)) {
clif->chsys_left(map->list[sd->bl.m].channel,sd);
}
@@ -2412,36 +2520,31 @@ uint8 map_calc_dir(struct block_list* src, int16 x, int16 y)
dx = x-src->x;
dy = y-src->y;
- if( dx == 0 && dy == 0 )
- { // both are standing on the same spot.
+ if (dx == 0 && dy == 0) {
+ // both are standing on the same spot.
// aegis-style, makes knockback default to the left.
// athena-style, makes knockback default to behind 'src'.
dir = (battle_config.knockback_left ? 6 : unit->getdir(src));
- }
- else if( dx >= 0 && dy >=0 )
- { // upper-right
- if( dx*2 <= dy ) dir = 0; // up
- else if( dx > dy*2 ) dir = 6; // right
- else dir = 7; // up-right
- }
- else if( dx >= 0 && dy <= 0 )
- { // lower-right
- if( dx*2 <= -dy ) dir = 4; // down
- else if( dx > -dy*2 ) dir = 6; // right
- else dir = 5; // down-right
- }
- else if( dx <= 0 && dy <= 0 )
- { // lower-left
- if( dx*2 >= dy ) dir = 4; // down
- else if( dx < dy*2 ) dir = 2; // left
- else dir = 3; // down-left
- }
- else
- { // upper-left
- if( -dx*2 <= dy ) dir = 0; // up
- else if( -dx > dy*2 ) dir = 2; // left
- else dir = 1; // up-left
-
+ } else if (dx >= 0 && dy >=0) {
+ // upper-right
+ if( dx*2 < dy || dx == 0 ) dir = 0; // up
+ else if( dx > dy*2+1 || dy == 0 ) dir = 6; // right
+ else dir = 7; // up-right
+ } else if (dx >= 0 && dy <= 0) {
+ // lower-right
+ if( dx*2 < -dy || dx == 0 ) dir = 4; // down
+ else if( dx > -dy*2+1 || dy == 0 ) dir = 6; // right
+ else dir = 5; // down-right
+ } else if (dx <= 0 && dy <= 0) {
+ // lower-left
+ if( dx*2 > dy || dx == 0 ) dir = 4; // down
+ else if( dx < dy*2-1 || dy == 0 ) dir = 2; // left
+ else dir = 3; // down-left
+ } else {
+ // upper-left
+ if( -dx*2 < dy || dx == 0 ) dir = 0; // up
+ else if( -dx > dy*2+1 || dy == 0) dir = 2; // left
+ else dir = 1; // up-left
}
return dir;
}
@@ -2479,7 +2582,7 @@ int map_random_dir(struct block_list *bl, int16 *x, int16 *y)
}
// gat system
-inline static struct mapcell map_gat2cell(int gat) {
+struct mapcell map_gat2cell(int gat) {
struct mapcell cell;
memset(&cell,0,sizeof(struct mapcell));
@@ -2526,9 +2629,6 @@ void map_cellfromcache(struct map_data *m) {
// Set cell properties
for( xy = 0; xy < size; ++xy ) {
m->cell[xy] = map->gat2cell(decode_buffer[xy]);
-#ifdef CELL_NOSTACK
- m->cell[xy].cell_bl = 0;
-#endif
}
m->getcellp = map->getcellp;
@@ -2587,25 +2687,27 @@ int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) {
return (cell.nochat);
case CELL_CHKICEWALL:
return (cell.icewall);
+ case CELL_CHKNOICEWALL:
+ return (cell.noicewall);
// special checks
case CELL_CHKPASS:
#ifdef CELL_NOSTACK
- if (cell.cell_bl >= battle_config.cell_stack_limit) return 0;
+ if (cell.cell_bl >= battle_config.custom_cell_stack_limit) return 0;
#endif
case CELL_CHKREACH:
return (cell.walkable);
case CELL_CHKNOPASS:
#ifdef CELL_NOSTACK
- if (cell.cell_bl >= battle_config.cell_stack_limit) return 1;
+ if (cell.cell_bl >= battle_config.custom_cell_stack_limit) return 1;
#endif
case CELL_CHKNOREACH:
return (!cell.walkable);
case CELL_CHKSTACK:
#ifdef CELL_NOSTACK
- return (cell.cell_bl >= battle_config.cell_stack_limit);
+ return (cell.cell_bl >= battle_config.custom_cell_stack_limit);
#else
return 0;
#endif
@@ -2646,6 +2748,8 @@ void map_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag) {
case CELL_NOVENDING: map->list[m].cell[j].novending = flag; break;
case CELL_NOCHAT: map->list[m].cell[j].nochat = flag; break;
case CELL_ICEWALL: map->list[m].cell[j].icewall = flag; break;
+ case CELL_NOICEWALL: map->list[m].cell[j].noicewall = flag; break;
+
default:
ShowWarning("map_setcell: invalid cell type '%d'\n", (int)cell);
break;
@@ -3300,9 +3404,6 @@ int map_readgat (struct map_data* m)
type = 3; // Cell is 0 (walkable) but under water level, set to 3 (walkable water)
m->cell[xy] = map->gat2cell(type);
-#ifdef CELL_NOSTACK
- m->cell[xy].cell_bl = 0;
-#endif
}
aFree(gat);
@@ -3384,8 +3485,8 @@ int map_readallmaps (void) {
map->list[i].m = i;
map->addmap2db(&map->list[i]);
- memset(map->list[i].moblist, 0, sizeof(map->list[i].moblist)); //Initialize moblist [Skotlex]
- map->list[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex]
+ memset(map->list[i].moblist, 0, sizeof(map->list[i].moblist)); //Initialize moblist [Skotlex]
+ map->list[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex]
map->list[i].bxs = (map->list[i].xs + BLOCK_SIZE - 1) / BLOCK_SIZE;
map->list[i].bys = (map->list[i].ys + BLOCK_SIZE - 1) / BLOCK_SIZE;
@@ -3621,15 +3722,19 @@ int inter_config_read(char *cfgName) {
if(strcmpi(w1,"item_db_db")==0)
strcpy(map->item_db_db,w2);
else if(strcmpi(w1,"mob_db_db")==0)
- strcpy(map->mob_db_db,w2);
+ strcpy(map->mob_db_db, w2);
+ else if (strcmpi(w1, "mob_db_re_db") == 0)
+ strcpy(map->mob_db_re_db, w2);
else if(strcmpi(w1,"item_db2_db")==0)
strcpy(map->item_db2_db,w2);
else if(strcmpi(w1,"item_db_re_db")==0)
strcpy(map->item_db_re_db,w2);
else if(strcmpi(w1,"mob_db2_db")==0)
- strcpy(map->mob_db2_db,w2);
- else if(strcmpi(w1,"mob_skill_db_db")==0)
- strcpy(map->mob_skill_db_db,w2);
+ strcpy(map->mob_db2_db, w2);
+ else if(strcmpi(w1, "mob_skill_db_db") == 0)
+ strcpy(map->mob_skill_db_db, w2);
+ else if(strcmpi(w1, "mob_skill_db_re_db") == 0)
+ strcpy(map->mob_skill_db_re_db, w2);
else if(strcmpi(w1,"mob_skill_db2_db")==0)
strcpy(map->mob_skill_db2_db,w2);
else if(strcmpi(w1,"interreg_db")==0)
@@ -3682,6 +3787,8 @@ int inter_config_read(char *cfgName) {
/* import */
else if(strcmpi(w1,"import")==0)
map->inter_config_read(w2);
+ else
+ HPM->parseConf(w1, w2, HPCT_MAP_INTER);
}
fclose(fp);
@@ -5020,6 +5127,7 @@ void read_map_zone_db(void) {
CREATE( entry, struct map_zone_disabled_skill_entry, 1 );
entry->nameid = izone->disabled_skills[j]->nameid;
entry->type = izone->disabled_skills[j]->type;
+ entry->subtype = izone->disabled_skills[j]->subtype;
zone->disabled_skills[zone->disabled_skills_count-1] = entry;
}
}
@@ -5114,6 +5222,7 @@ void read_map_zone_db(void) {
entry->nameid = izone->capped_skills[j]->nameid;
entry->cap = izone->capped_skills[j]->cap;
entry->type = izone->capped_skills[j]->type;
+ entry->subtype = izone->capped_skills[j]->subtype;
zone->capped_skills[zone->capped_skills_count-1] = entry;
}
}
@@ -5248,7 +5357,7 @@ int do_final(void) {
ShowStatus("Terminating...\n");
- hChSys.closing = true;
+ clif->hChSys->closing = true;
HPM->event(HPET_FINAL);
if (map->cpsd) aFree(map->cpsd);
@@ -5392,7 +5501,7 @@ void map_helpscreen(bool do_exit)
ShowInfo(" scripts passed through --load-script.\n");
ShowInfo(" --load-script <file> Loads an additional script (can be repeated).\n");
ShowInfo(" --load-plugin <name> Loads an additional plugin (can be repeated).\n");
- HPM->arg_help();/* display help for commands implemented thru HPM */
+ HPM->arg_help(); /* display help for commands implemented through HPM */
if( do_exit )
exit(EXIT_SUCCESS);
}
@@ -5489,9 +5598,9 @@ void map_cp_defaults(void) {
/* default HCP data */
map->cpsd = pc->get_dummy_sd();
strcpy(map->cpsd->status.name, "Hercules Console");
- map->cpsd->bl.x = MAP_DEFAULT_X;
- map->cpsd->bl.y = MAP_DEFAULT_Y;
- map->cpsd->bl.m = map->mapname2mapid(MAP_DEFAULT);
+ map->cpsd->bl.x = mapindex->default_x;
+ map->cpsd->bl.y = mapindex->default_y;
+ map->cpsd->bl.m = map->mapname2mapid(mapindex->default_map);
console->input->addCommand("gm:info",CPCMD_A(gm_position));
console->input->addCommand("gm:use",CPCMD_A(gm_use));
@@ -5609,10 +5718,7 @@ int do_init(int argc, char *argv[])
map_load_defaults();
HPM_map_do_init();
- HPM->DataCheck = HPM_map_DataCheck;
- HPM->load_sub = HPM_map_plugin_load_sub;
HPM->symbol_defaults_sub = map_hp_symbols;
- HPM->grabHPDataSub = HPM_map_grabHPData;
for( i = 1; i < argc; i++ ) {
const char* arg = argv[i];
if( strcmp(arg, "--load-plugin") == 0 ) {
@@ -5841,7 +5947,7 @@ int do_init(int argc, char *argv[])
exit(EXIT_SUCCESS);
}
- npc->event_do_oninit( false ); // Init npcs (OnInit)
+ npc->event_do_oninit( false ); // Init npcs (OnInit)
npc->market_fromsql(); /* after OnInit */
if (battle_config.pk_mode)
@@ -5903,8 +6009,10 @@ void map_defaults(void) {
sprintf(map->item_db2_db, "item_db2");
sprintf(map->item_db_re_db, "item_db_re");
sprintf(map->mob_db_db, "mob_db");
+ sprintf(map->mob_db_re_db, "mob_db_re");
sprintf(map->mob_db2_db, "mob_db2");
sprintf(map->mob_skill_db_db, "mob_skill_db");
+ sprintf(map->mob_skill_db_re_db, "mob_skill_db_re");
sprintf(map->mob_skill_db2_db, "mob_skill_db2");
sprintf(map->interreg_db, "interreg");
@@ -5998,6 +6106,7 @@ void map_defaults(void) {
// search and creation
map->get_new_object_id = map_get_new_object_id;
map->search_freecell = map_search_freecell;
+ map->closest_freecell = map_closest_freecell;
//
map->quit = map_quit;
// npc
diff --git a/src/map/map.h b/src/map/map.h
index dba565cc0..447437cf4 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -295,6 +295,16 @@ enum {
ELE_MAX
};
+enum {
+ SPIRITS_TYPE_NONE = 0,
+ SPIRITS_TYPE_CHARM_WATER,
+ SPIRITS_TYPE_CHARM_LAND,
+ SPIRITS_TYPE_CHARM_FIRE,
+ SPIRITS_TYPE_CHARM_WIND,
+ SPIRITS_TYPE_SPHERE,
+ SPIRITS_TYPE_END
+};
+
enum auto_trigger_flag {
ATF_SELF=0x01,
ATF_TARGET=0x02,
@@ -315,20 +325,20 @@ struct block_list {
// Mob List Held in memory for Dynamic Mobs [Wizputer]
// Expanded to specify all mob-related spawn data by [Skotlex]
struct spawn_data {
- short class_; //Class, used because a mob can change it's class
- unsigned short m, x, y; //Spawn information (map, point, spawn-area around point)
+ short class_; ///< Class, used because a mob can change it's class
+ unsigned short m, x, y; ///< Spawn information (map, point, spawn-area around point)
signed short xs, ys;
- unsigned short num; //Number of mobs using this structure
- unsigned short active;//Number of mobs that are already spawned (for mob_remove_damaged: no)
- unsigned int delay1, delay2; //Spawn delay (fixed base + random variance)
+ unsigned short num; ///< Number of mobs using this structure
+ unsigned short active; ///< Number of mobs that are already spawned (for mob_remove_damaged: no)
+ unsigned int delay1, delay2; ///< Spawn delay (fixed base + random variance)
unsigned int level;
struct {
- unsigned int size : 2; //Holds if mob has to be tiny/large
- unsigned int ai : 4; //Special AI for summoned monsters.
+ unsigned int size : 2; ///< Holds if mob has to be tiny/large
+ unsigned int ai : 4; ///< Special AI for summoned monsters.
//0: Normal mob | 1: Standard summon, attacks mobs
//2: Alchemist Marine Sphere | 3: Alchemist Summon Flora | 4: Summon Zanzou
- unsigned int dynamic : 1; //Whether this data is indexed by a map's dynamic mob list
- unsigned int boss : 1; //0: Non-boss monster | 1: Boss monster
+ unsigned int dynamic : 1; ///< Whether this data is indexed by a map's dynamic mob list
+ unsigned int boss : 1; ///< 0: Non-boss monster | 1: Boss monster
} state;
char name[NAME_LENGTH], eventname[EVENT_NAME_LENGTH]; //Name/event
};
@@ -343,18 +353,18 @@ struct flooritem_data {
};
enum status_point_types {
- SP_SPEED,SP_BASEEXP,SP_JOBEXP,SP_KARMA,SP_MANNER,SP_HP,SP_MAXHP,SP_SP, // 0-7
- SP_MAXSP,SP_STATUSPOINT,SP_0a,SP_BASELEVEL,SP_SKILLPOINT,SP_STR,SP_AGI,SP_VIT, // 8-15
- SP_INT,SP_DEX,SP_LUK,SP_CLASS,SP_ZENY,SP_SEX,SP_NEXTBASEEXP,SP_NEXTJOBEXP, // 16-23
- SP_WEIGHT,SP_MAXWEIGHT,SP_1a,SP_1b,SP_1c,SP_1d,SP_1e,SP_1f, // 24-31
- SP_USTR,SP_UAGI,SP_UVIT,SP_UINT,SP_UDEX,SP_ULUK,SP_26,SP_27, // 32-39
- SP_28,SP_ATK1,SP_ATK2,SP_MATK1,SP_MATK2,SP_DEF1,SP_DEF2,SP_MDEF1, // 40-47
- SP_MDEF2,SP_HIT,SP_FLEE1,SP_FLEE2,SP_CRITICAL,SP_ASPD,SP_36,SP_JOBLEVEL, // 48-55
- SP_UPPER,SP_PARTNER,SP_CART,SP_FAME,SP_UNBREAKABLE, //56-60
- SP_CARTINFO=99, // 99
-
- SP_BASEJOB=119, // 100+19 - celest
- SP_BASECLASS=120, //Hmm.. why 100+19? I just use the next one... [Skotlex]
+ SP_SPEED,SP_BASEEXP,SP_JOBEXP,SP_KARMA,SP_MANNER,SP_HP,SP_MAXHP,SP_SP, // 0-7
+ SP_MAXSP,SP_STATUSPOINT,SP_0a,SP_BASELEVEL,SP_SKILLPOINT,SP_STR,SP_AGI,SP_VIT, // 8-15
+ SP_INT,SP_DEX,SP_LUK,SP_CLASS,SP_ZENY,SP_SEX,SP_NEXTBASEEXP,SP_NEXTJOBEXP, // 16-23
+ SP_WEIGHT,SP_MAXWEIGHT,SP_1a,SP_1b,SP_1c,SP_1d,SP_1e,SP_1f, // 24-31
+ SP_USTR,SP_UAGI,SP_UVIT,SP_UINT,SP_UDEX,SP_ULUK,SP_26,SP_27, // 32-39
+ SP_28,SP_ATK1,SP_ATK2,SP_MATK1,SP_MATK2,SP_DEF1,SP_DEF2,SP_MDEF1, // 40-47
+ SP_MDEF2,SP_HIT,SP_FLEE1,SP_FLEE2,SP_CRITICAL,SP_ASPD,SP_36,SP_JOBLEVEL, // 48-55
+ SP_UPPER,SP_PARTNER,SP_CART,SP_FAME,SP_UNBREAKABLE, //56-60
+ SP_CARTINFO=99, // 99
+
+ SP_BASEJOB=119, // 100+19 - celest
+ SP_BASECLASS=120, //Hmm.. why 100+19? I just use the next one... [Skotlex]
SP_KILLERRID=121,
SP_KILLEDRID=122,
SP_SLOTCHANGE=123,
@@ -367,10 +377,10 @@ enum status_point_types {
SP_MERCFLEE=165, SP_MERCKILLS=189, SP_MERCFAITH=190,
// original 1000-
- SP_ATTACKRANGE=1000, SP_ATKELE,SP_DEFELE, // 1000-1002
+ SP_ATTACKRANGE=1000, SP_ATKELE,SP_DEFELE, // 1000-1002
SP_CASTRATE, SP_MAXHPRATE, SP_MAXSPRATE, SP_SPRATE, // 1003-1006
SP_ADDELE, SP_ADDRACE, SP_ADDSIZE, SP_SUBELE, SP_SUBRACE, // 1007-1011
- SP_ADDEFF, SP_RESEFF, // 1012-1013
+ SP_ADDEFF, SP_RESEFF, // 1012-1013
SP_BASE_ATK,SP_ASPD_RATE,SP_HP_RECOV_RATE,SP_SP_RECOV_RATE,SP_SPEED_RATE, // 1014-1018
SP_CRITICAL_DEF,SP_NEAR_ATK_DEF,SP_LONG_ATK_DEF, // 1019-1021
SP_DOUBLE_RATE, SP_DOUBLE_ADD_RATE, SP_SKILL_HEAL, SP_MATK_RATE, // 1022-1025
@@ -401,8 +411,8 @@ enum status_point_types {
SP_CRIT_ATK_RATE, SP_CRITICAL_ADDRACE, SP_NO_REGEN, SP_ADDEFF_WHENHIT, SP_AUTOSPELL_WHENHIT, // 2013-2017
SP_SKILL_ATK, SP_UNSTRIPABLE, SP_AUTOSPELL_ONSKILL, // 2018-2020
SP_SP_GAIN_VALUE, SP_HP_REGEN_RATE, SP_HP_LOSS_RATE, SP_ADDRACE2, SP_HP_GAIN_VALUE, // 2021-2025
- SP_SUBSIZE, SP_HP_DRAIN_VALUE_RACE, SP_ADD_ITEM_HEAL_RATE, SP_SP_DRAIN_VALUE_RACE, SP_EXP_ADDRACE, // 2026-2030
- SP_SP_GAIN_RACE, SP_SUBRACE2, SP_UNBREAKABLE_SHOES, // 2031-2033
+ SP_SUBSIZE, SP_HP_DRAIN_VALUE_RACE, SP_ADD_ITEM_HEAL_RATE, SP_SP_DRAIN_VALUE_RACE, SP_EXP_ADDRACE, // 2026-2030
+ SP_SP_GAIN_RACE, SP_SUBRACE2, SP_UNBREAKABLE_SHOES, // 2031-2033
SP_UNSTRIPABLE_WEAPON,SP_UNSTRIPABLE_ARMOR,SP_UNSTRIPABLE_HELM,SP_UNSTRIPABLE_SHIELD, // 2034-2037
SP_INTRAVISION, SP_ADD_MONSTER_DROP_CHAINITEM, SP_SP_LOSS_RATE, // 2038-2040
SP_ADD_SKILL_BLOW, SP_SP_VANISH_RATE, SP_MAGIC_SP_GAIN_VALUE, SP_MAGIC_HP_GAIN_VALUE, SP_ADD_CLASS_DROP_ITEM, //2041-2045
@@ -410,8 +420,7 @@ enum status_point_types {
SP_SKILL_COOLDOWN,SP_SKILL_FIXEDCAST, SP_SKILL_VARIABLECAST, SP_FIXCASTRATE, SP_VARCASTRATE, //2050-2054
SP_SKILL_USE_SP,SP_MAGIC_ATK_ELE, SP_ADD_FIXEDCAST, SP_ADD_VARIABLECAST, //2055-2058
SP_SET_DEF_RACE,SP_SET_MDEF_RACE, //2059-2060
-
-
+
/* must be the last, plugins add bonuses from this value onwards */
SP_LAST_KNOWN,
};
@@ -444,22 +453,23 @@ typedef enum {
CELL_NOVENDING,
CELL_NOCHAT,
CELL_ICEWALL,
+ CELL_NOICEWALL,
} cell_t;
// used by map->getcell()
typedef enum {
- CELL_GETTYPE, // retrieves a cell's 'gat' type
+ CELL_GETTYPE, ///< retrieves a cell's 'gat' type
- CELL_CHKWALL, // wall (gat type 1)
- CELL_CHKWATER, // water (gat type 3)
- CELL_CHKCLIFF, // cliff/gap (gat type 5)
+ CELL_CHKWALL, ///< wall (gat type 1)
+ CELL_CHKWATER, ///< water (gat type 3)
+ CELL_CHKCLIFF, ///< cliff/gap (gat type 5)
- CELL_CHKPASS, // passable cell (gat type non-1/5)
- CELL_CHKREACH, // Same as PASS, but ignores the cell-stacking mod.
- CELL_CHKNOPASS, // non-passable cell (gat types 1 and 5)
- CELL_CHKNOREACH, // Same as NOPASS, but ignores the cell-stacking mod.
- CELL_CHKSTACK, // whether cell is full (reached cell stacking limit)
+ CELL_CHKPASS, ///< passable cell (gat type non-1/5)
+ CELL_CHKREACH, ///< Same as PASS, but ignores the cell-stacking mod.
+ CELL_CHKNOPASS, ///< non-passable cell (gat types 1 and 5)
+ CELL_CHKNOREACH, ///< Same as NOPASS, but ignores the cell-stacking mod.
+ CELL_CHKSTACK, ///< whether cell is full (reached cell stacking limit)
CELL_CHKNPC,
CELL_CHKBASILICA,
@@ -467,6 +477,7 @@ typedef enum {
CELL_CHKNOVENDING,
CELL_CHKNOCHAT,
CELL_CHKICEWALL,
+ CELL_CHKNOICEWALL,
} cell_chk;
@@ -484,7 +495,8 @@ struct mapcell {
landprotector : 1,
novending : 1,
nochat : 1,
- icewall : 1;
+ icewall : 1,
+ noicewall : 1;
#ifdef CELL_NOSTACK
int cell_bl; //Holds amount of bls in this cell.
@@ -504,11 +516,11 @@ struct mapflag_skill_adjust {
};
enum map_zone_skill_subtype {
- MZS_NONE = 0x0,
- MZS_CLONE = 0x01,
- MZS_BOSS = 0x02,
+ MZS_NONE = 0x0,
+ MZS_CLONE = 0x01,
+ MZS_BOSS = 0x02,
- MZS_ALL = 0xFFF,
+ MZS_ALL = 0xFFF
};
struct map_zone_disabled_skill_entry {
@@ -575,7 +587,7 @@ struct map_data {
char name[MAP_NAME_LENGTH];
uint16 index; // The map index used by the mapindex* functions.
struct mapcell* cell; // Holds the information of each map cell (NULL if the map is not on this map-server).
-
+
/* 2D Orthogonal Range Search: Grid Implementation
"Algorithms in Java, Parts 1-4" 3.18, Robert Sedgewick
Map is divided into squares, called blocks (side length = BLOCK_SIZE).
@@ -587,7 +599,7 @@ struct map_data {
*/
struct block_list **block; // Grid array of block_lists containing only non-BL_MOB objects
struct block_list **block_mob; // Grid array of block_lists containing only BL_MOB objects
-
+
int16 m;
int16 xs,ys; // map dimensions (in cells)
int16 bxs,bys; // map dimensions (in blocks)
@@ -630,10 +642,10 @@ struct map_data {
unsigned fireworks : 1;
unsigned sakura : 1; // [Valaris]
unsigned leaves : 1; // [Valaris]
- unsigned nobaseexp : 1; // [Lorky] added by Lupus
- unsigned nojobexp : 1; // [Lorky]
- unsigned nomobloot : 1; // [Lorky]
- unsigned nomvploot : 1; // [Lorky]
+ unsigned nobaseexp : 1; // [Lorky] added by Lupus
+ unsigned nojobexp : 1; // [Lorky]
+ unsigned nomobloot : 1; // [Lorky]
+ unsigned nomvploot : 1; // [Lorky]
unsigned nightenabled :1; //For night display. [Skotlex]
unsigned nodrop : 1;
unsigned novending : 1;
@@ -654,17 +666,11 @@ struct map_data {
unsigned short drop_list_count;
struct spawn_data *moblist[MAX_MOB_LIST_PER_MAP]; // [Wizputer]
- int mob_delete_timer; // [Skotlex]
- int jexp; // map experience multiplicator
- int bexp; // map experience multiplicator
+ int mob_delete_timer; // [Skotlex]
+ int jexp; // map experience multiplicator
+ int bexp; // map experience multiplicator
int nocommand; //Blocks @/# commands for non-gms. [Skotlex]
- /**
- * Ice wall reference counter for bugreport:3574
- * - since there are a thousand mobs out there in a lot of maps checking on,
- * - every targeting for icewall on attack path would just be a waste, so,
- * - this counter allows icewall checking be only run when there is a actual ice wall on the map
- **/
- int icewall_num;
+
// Instance Variables
int instance_id;
int instance_src_map;
@@ -705,14 +711,14 @@ struct map_data {
int (*getcellp)(struct map_data* m,int16 x,int16 y,cell_chk cellchk);
void (*setcell) (int16 m, int16 x, int16 y, cell_t cell, bool flag);
char *cellPos;
-
+
/* ShowEvent Data Cache */
struct questinfo *qi_data;
unsigned short qi_count;
-
+
/* speeds up clif_updatestatus processing by causing hpmeter to run only when someone with the permission can view it */
unsigned short hpmeter_visible;
-
+
/* HPM Custom Struct */
struct HPluginData **hdata;
unsigned int hdatac;
@@ -733,7 +739,7 @@ struct map_data_other_server {
/// Bitfield of flags for the iterator.
enum e_mapitflags {
MAPIT_NORMAL = 0,
- // MAPIT_PCISPLAYING = 1,// Unneeded as pc_db/id_db will only hold authed, active players.
+ //MAPIT_PCISPLAYING = 1,// Unneeded as pc_db/id_db will only hold authed, active players.
};
struct s_mapiterator;
@@ -767,7 +773,7 @@ typedef struct skill_unit TBL_SKILL;
typedef struct pet_data TBL_PET;
typedef struct homun_data TBL_HOM;
typedef struct mercenary_data TBL_MER;
-typedef struct elemental_data TBL_ELEM;
+typedef struct elemental_data TBL_ELEM;
#define BL_CAST(type_, bl) \
( ((bl) == (struct block_list*)NULL || (bl)->type != (type_)) ? (T ## type_ *)NULL : (T ## type_ *)(bl) )
@@ -840,8 +846,10 @@ struct map_interface {
char item_db2_db[32];
char item_db_re_db[32];
char mob_db_db[32];
+ char mob_db_re_db[32];
char mob_db2_db[32];
char mob_skill_db_db[32];
+ char mob_skill_db_re_db[32];
char mob_skill_db2_db[32];
char interreg_db[32];
char autotrade_merchants_db[32];
@@ -849,17 +857,17 @@ struct map_interface {
char npc_market_data_db[32];
char default_codepage[32];
-
+
int server_port;
char server_ip[32];
char server_id[32];
- char server_pw[32];
+ char server_pw[100];
char server_db[32];
Sql* mysql_handle;
-
+
int port;
int users;
- int enable_grf; //To enable/disable reading maps from GRF files, bypassing mapcache [blackhole89]
+ int enable_grf; //To enable/disable reading maps from GRF files, bypassing mapcache [blackhole89]
bool ip_set;
bool char_ip_set;
@@ -920,11 +928,12 @@ struct map_interface {
int (*delblock) (struct block_list* bl);
int (*moveblock) (struct block_list *bl, int x1, int y1, int64 tick);
//blocklist nb in one cell
- int (*count_oncell) (int16 m,int16 x,int16 y,int type);
+ int (*count_oncell) (int16 m,int16 x,int16 y,int type,int flag);
struct skill_unit * (*find_skill_unit_oncell) (struct block_list* target,int16 x,int16 y,uint16 skill_id,struct skill_unit* out_unit, int flag);
// search and creation
int (*get_new_object_id) (void);
int (*search_freecell) (struct block_list *src, int16 m, int16 *x, int16 *y, int16 rx, int16 ry, int flag);
+ bool (*closest_freecell) (int16 m, int16 *x, int16 *y, int type, int flag);
//
int (*quit) (struct map_session_data *sd);
// npc
@@ -1018,7 +1027,7 @@ struct map_interface {
void (*clean) (int i);
void (*do_shutdown) (void);
-
+
int (*freeblock_timer) (int tid, int64 tick, int id, intptr_t data);
int (*searchrandfreecell) (int16 m, int16 *x, int16 *y, int stack);
int (*count_sub) (struct block_list *bl, va_list ap);
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index 80bcfdf05..a1503e97a 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -362,7 +362,7 @@ int mercenary_killbonus(struct mercenary_data *md)
const enum sc_type scs[] = { SC_MER_FLEE, SC_MER_ATK, SC_MER_HP, SC_MER_SP, SC_MER_HIT };
int index = rnd() % ARRAYLENGTH(scs);
- sc_start(NULL,&md->bl, scs[index], 100, rnd() % 5, 600000);
+ sc_start(NULL,&md->bl, scs[index], 100, rnd() % 5, 600000);
return 0;
}
diff --git a/src/map/mercenary.h b/src/map/mercenary.h
index 270245e96..68f60b08b 100644
--- a/src/map/mercenary.h
+++ b/src/map/mercenary.h
@@ -42,7 +42,7 @@ struct mercenary_data {
struct map_session_data *master;
int contract_timer;
-
+
unsigned devotion_flag : 1;
int64 masterteleport_timer;
};
@@ -55,26 +55,26 @@ struct mercenary_data {
struct mercenary_interface {
/* vars */
-
+
struct s_mercenary_db db[MAX_MERCENARY_CLASS];
/* funcs */
void (*init) (bool minimal);
-
+
bool (*class) (int class_);
struct view_data * (*get_viewdata) (int class_);
-
+
int (*create) (struct map_session_data *sd, int class_, unsigned int lifetime);
int (*data_received) (struct s_mercenary *merc, bool flag);
int (*save) (struct mercenary_data *md);
-
+
void (*heal) (struct mercenary_data *md, int hp, int sp);
int (*dead) (struct mercenary_data *md);
-
+
int (*delete) (struct mercenary_data *md, int reply);
void (*contract_stop) (struct mercenary_data *md);
-
+
int (*get_lifetime) (struct mercenary_data *md);
int (*get_guild) (struct mercenary_data *md);
int (*get_faith) (struct mercenary_data *md);
@@ -82,14 +82,14 @@ struct mercenary_interface {
int (*get_calls) (struct mercenary_data *md);
int (*set_calls) (struct mercenary_data *md, int value);
int (*kills) (struct mercenary_data *md);
-
+
int (*checkskill) (struct mercenary_data *md, uint16 skill_id);
int (*read_db) (void);
int (*read_skilldb) (void);
-
+
int (*killbonus) (struct mercenary_data *md);
int (*search_index) (int class_);
-
+
int (*contract_end_timer) (int tid, int64 tick, int id, intptr_t data);
bool (*read_db_sub) (char* str[], int columns, int current);
bool (*read_skill_db_sub) (char* str[], int columns, int current);
diff --git a/src/map/mob.c b/src/map/mob.c
index 3f1769d37..4db8cb2f6 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -34,6 +34,7 @@
#include "script.h"
#include "skill.h"
#include "status.h"
+#include "../common/HPM.h"
#include "../common/cbasetypes.h"
#include "../common/db.h"
#include "../common/ers.h"
@@ -48,17 +49,19 @@
struct mob_interface mob_s;
-#define ACTIVE_AI_RANGE 2 //Distance added on top of 'AREA_SIZE' at which mobs enter active AI mode.
+#define ACTIVE_AI_RANGE 2 //Distance added on top of 'AREA_SIZE' at which mobs enter active AI mode.
-#define IDLE_SKILL_INTERVAL 10 //Active idle skills should be triggered every 1 second (1000/MIN_MOBTHINKTIME)
+#define IDLE_SKILL_INTERVAL 10 //Active idle skills should be triggered every 1 second (1000/MIN_MOBTHINKTIME)
-#define MOB_LAZYSKILLPERC 0 // Probability for mobs far from players from doing their IDLE skill. (rate of 1000 minute)
+// Probability for mobs far from players from doing their IDLE skill. (rate of 1000 minute)
+// in Aegis, this is 100% for mobs that have been activated by players and none otherwise.
+#define MOB_LAZYSKILLPERC(md) (md->state.spotted?1000:0)
// Move probability for mobs away from players (rate of 1000 minute)
// in Aegis, this is 100% for mobs that have been activated by players and none otherwise.
#define MOB_LAZYMOVEPERC(md) ((md)->state.spotted?1000:0)
#define MOB_MAX_DELAY (24*3600*1000)
-#define MAX_MINCHASE 30 //Max minimum chase value to use for mobs.
-#define RUDE_ATTACKED_COUNT 2 //After how many rude-attacks should the skill be used?
+#define MAX_MINCHASE 30 //Max minimum chase value to use for mobs.
+#define RUDE_ATTACKED_COUNT 2 //After how many rude-attacks should the skill be used?
//Dynamic item drop ratio database for per-item drop ratio modifiers overriding global drop ratios.
#define MAX_ITEMRATIO_MOBS 10
@@ -139,14 +142,9 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time)
if ( md->tomb_nid )
mob->mvptomb_destroy(md);
- CREATE(nd, struct npc_data, 1);
-
- nd->bl.id = md->tomb_nid = npc->get_new_npc_id();
-
+ nd = npc->create_npc(md->bl.m, md->bl.x, md->bl.y);
+ md->tomb_nid = nd->bl.id;
nd->dir = md->ud.dir;
- nd->bl.m = md->bl.m;
- nd->bl.x = md->bl.x;
- nd->bl.y = md->bl.y;
nd->bl.type = BL_NPC;
safestrncpy(nd->name, msg_txt(856), sizeof(nd->name)); // "Tomb"
@@ -418,7 +416,8 @@ bool mob_ksprotected(struct block_list *src, struct block_list *target) {
return true;
} while(0);
- status->change_start(NULL, target, SC_KSPROTECTED, 10000, sd->bl.id, sd->state.noks, sd->status.party_id, sd->status.guild_id, battle_config.ksprotection, 0);
+ status->change_start(NULL, target, SC_KSPROTECTED, 10000, sd->bl.id, sd->state.noks,
+ sd->status.party_id, sd->status.guild_id, battle_config.ksprotection, SCFLAG_NONE);
return false;
}
@@ -499,7 +498,7 @@ int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const
else if( gc->guild_id ) //Guild not yet available, retry in 5.
timer->add(timer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,gc->guild_id);
}
- } // end addition [Valaris]
+ } // end addition [Valaris]
mob->spawn(md);
@@ -674,8 +673,8 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam
else
g = guild->search(gc->guild_id);
- if( has_index && gc->guardian[guardian].id )
- { //Check if guardian already exists, refuse to spawn if so.
+ if( has_index && gc->guardian[guardian].id ) {
+ //Check if guardian already exists, refuse to spawn if so.
struct mob_data *md2 = (TBL_MOB*)map->id2bl(gc->guardian[guardian].id);
if (md2 && md2->bl.type == BL_MOB
&& md2->guardian_data
@@ -802,7 +801,8 @@ int mob_linksearch(struct block_list *bl,va_list ap) {
&& !md->target_id)
{
md->last_linktime = tick;
- if( mob->can_reach(md,target,md->db->range2, MSS_FOLLOW) ){ // Reachability judging
+ if (mob->can_reach(md,target,md->db->range2, MSS_FOLLOW)) {
+ // Reachability judging
md->target_id = target->id;
md->min_chase=md->db->range3;
return 1;
@@ -850,17 +850,20 @@ int mob_setdelayspawn(struct mob_data *md)
//Apply the spawn delay fix [Skotlex]
db = mob->db(md->spawn->class_);
mode = db->status.mode;
- if (mode & MD_BOSS) { //Bosses
+ if (mode & MD_BOSS) {
+ //Bosses
if (battle_config.boss_spawn_delay != 100) {
// Divide by 100 first to prevent overflows
//(precision loss is minimal as duration is in ms already)
spawntime = spawntime/100*battle_config.boss_spawn_delay;
}
- } else if (mode&MD_PLANT) { //Plants
+ } else if (mode&MD_PLANT) {
+ //Plants
if (battle_config.plant_spawn_delay != 100) {
spawntime = spawntime/100*battle_config.plant_spawn_delay;
}
- } else if (battle_config.mob_spawn_delay != 100) { //Normal mobs
+ } else if (battle_config.mob_spawn_delay != 100) {
+ //Normal mobs
spawntime = spawntime/100*battle_config.mob_spawn_delay;
}
@@ -934,18 +937,19 @@ int mob_spawn (struct mob_data *md)
md->move_fail_count = 0;
md->ud.state.attack_continue = 0;
md->ud.target_to = 0;
+ md->ud.dir = 0;
if( md->spawn_timer != INVALID_TIMER )
{
timer->delete(md->spawn_timer, mob->delayspawn);
md->spawn_timer = INVALID_TIMER;
}
-// md->master_id = 0;
+ //md->master_id = 0;
md->master_dist = 0;
md->state.aggressive = md->status.mode&MD_ANGRY?1:0;
md->state.skillstate = MSS_IDLE;
- md->next_walktime = tick+rnd()%5000+1000;
+ md->next_walktime = tick+rnd()%1000+MIN_RANDOMWALKTIME;
md->last_linktime = tick;
md->dmgtick = tick - 5000;
md->last_pcneartime = 0;
@@ -1024,7 +1028,7 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist)
if(!status->check_skilluse(&md->bl, bl, 0, 0))
return 0;
- md->target_id = bl->id; // Since there was no disturbance, it locks on to target.
+ md->target_id = bl->id; // Since there was no disturbance, it locks on to target.
if (md->state.provoke_flag && bl->id != md->state.provoke_flag)
md->state.provoke_flag = 0;
md->min_chase=dist+md->db->range3;
@@ -1073,15 +1077,15 @@ int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap)
((*target) == NULL || !check_distance_bl(&md->bl, *target, dist)) &&
battle->check_range(&md->bl,bl,md->db->range2)
) { //Pick closest target?
-
- if( map->list[bl->m].icewall_num &&
- !path->search_long(NULL,bl->m,md->bl.x,md->bl.y,bl->x,bl->y,CELL_CHKICEWALL) ) {
-
- if( !check_distance_bl(&md->bl, bl, status_get_range(&md->bl) ) )
- return 0;
-
- }
-
+#ifdef ACTIVEPATHSEARCH
+ struct walkpath_data wpd;
+ if (!path->search(&wpd, md->bl.m, md->bl.x, md->bl.y, bl->x, bl->y, 0, CELL_CHKNOPASS)) // Count walk path cells
+ return 0;
+ //Standing monsters use range2, walking monsters use range3
+ if ((md->ud.walktimer == INVALID_TIMER && wpd.path_len > md->db->range2)
+ || (md->ud.walktimer != INVALID_TIMER && wpd.path_len > md->db->range3))
+ return 0;
+#endif
(*target) = bl;
md->target_id=bl->id;
md->min_chase= dist + md->db->range3;
@@ -1203,8 +1207,8 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md, int64 tick) {
if (bl->prev == NULL)
return 0; //Master not on a map? Could be warping, do not process.
- if(status_get_mode(&md->bl)&MD_CANMOVE)
- { //If the mob can move, follow around. [Check by Skotlex]
+ if (status_get_mode(&md->bl)&MD_CANMOVE) {
+ //If the mob can move, follow around. [Check by Skotlex]
int old_dist;
// Distance with between slave and master is measured.
@@ -1241,8 +1245,7 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md, int64 tick) {
}
//Avoid attempting to lock the master's target too often to avoid unnecessary overload. [Skotlex]
- if (DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME && !md->target_id)
- {
+ if (DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME && !md->target_id) {
struct unit_data *ud = unit->bl2ud(bl);
md->last_linktime = tick;
@@ -1285,22 +1288,23 @@ int mob_unlocktarget(struct mob_data *md, int64 tick) {
md->state.skillstate = MSS_IDLE;
case MSS_IDLE:
// Idle skill.
- if ((md->target_id || !(++md->ud.walk_count%IDLE_SKILL_INTERVAL)) &&
- mob->skill_use(md, tick, -1))
+ if (!(++md->ud.walk_count%IDLE_SKILL_INTERVAL) && mob->skill_use(md, tick, -1))
break;
//Random walk.
if (!md->master_id &&
DIFF_TICK(md->next_walktime, tick) <= 0 &&
!mob->randomwalk(md,tick))
//Delay next random walk when this one failed.
- md->next_walktime=tick+rnd()%3000;
+ md->next_walktime = tick+rnd()%1000;
break;
default:
mob_stop_attack(md);
- if (battle_config.mob_ai&0x8)
- mob_stop_walking(md,1); //Immediately stop chasing.
+ mob_stop_walking(md,1); //Stop chasing.
md->state.skillstate = MSS_IDLE;
- md->next_walktime=tick+rnd()%3000+3000;
+ if(battle_config.mob_ai&0x8) //Walk instantly after dropping target
+ md->next_walktime = tick+rnd()%1000;
+ else
+ md->next_walktime = tick+rnd()%1000+MIN_RANDOMWALKTIME;
break;
}
if (md->target_id) {
@@ -1308,6 +1312,10 @@ int mob_unlocktarget(struct mob_data *md, int64 tick) {
md->ud.target_to = 0;
unit->set_target(&md->ud, 0);
}
+ if(map->count_oncell(md->bl.m, md->bl.x, md->bl.y, BL_CHAR|BL_NPC, 1) > battle_config.official_cell_stack_limit) {
+ unit->walktoxy(&md->bl, md->bl.x, md->bl.y, 8);
+ }
+
return 0;
}
/*==========================================
@@ -1327,14 +1335,16 @@ int mob_randomwalk(struct mob_data *md, int64 tick) {
d =12-md->move_fail_count;
if(d<5) d=5;
- for(i=0;i<retrycount;i++){ // Search of a movable place
+ if(d>7) d=7;
+ for (i = 0; i < retrycount; i++) {
+ // Search of a movable place
int r=rnd();
x=r%(d*2+1)-d;
y=r/(d*2+1)%(d*2+1)-d;
x+=md->bl.x;
y+=md->bl.y;
- if((map->getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit->walktoxy(&md->bl,x,y,1)){
+ if(((x != md->bl.x) || (y != md->bl.y)) && map->getcell(md->bl.m,x,y,CELL_CHKPASS) && unit->walktoxy(&md->bl,x,y,8)){
break;
}
}
@@ -1357,7 +1367,7 @@ int mob_randomwalk(struct mob_data *md, int64 tick) {
}
md->state.skillstate=MSS_WALK;
md->move_fail_count=0;
- md->next_walktime = tick+rnd()%3000+3000+c;
+ md->next_walktime = tick+rnd()%1000+MIN_RANDOMWALKTIME+c;
return 1;
}
@@ -1403,9 +1413,6 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
if (md->ud.skilltimer != INVALID_TIMER)
return false;
- if(md->ud.walktimer != INVALID_TIMER && md->ud.walkpath.path_pos <= 3)
- return false;
-
// Abnormalities
if(( md->sc.opt1 > 0 && md->sc.opt1 != OPT1_STONEWAIT && md->sc.opt1 != OPT1_BURNING && md->sc.opt1 != OPT1_CRYSTALIZE )
|| md->sc.data[SC_DEEP_SLEEP] || md->sc.data[SC_BLADESTOP] || md->sc.data[SC__MANHOLE] || md->sc.data[SC_CURSEDCIRCLE_TARGET]) {
@@ -1433,30 +1440,35 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
|| ((TBL_PC*)tbl)->invincible_timer != INVALID_TIMER)
)
) {
- //Unlock current target.
+ //No valid target
if (mob->warpchase(md, tbl))
return true; //Chasing this target.
- mob->unlocktarget(md, tick-(battle_config.mob_ai&0x8?3000:0)); //Immediately do random walk.
+ if(md->ud.walktimer != INVALID_TIMER && (!can_move || md->ud.walkpath.path_pos <= battle_config.mob_chase_refresh)
+ && (tbl || md->ud.walkpath.path_pos == 0))
+ return true; //Walk at least "mob_chase_refresh" cells before dropping the target unless target is non-existent
+ mob->unlocktarget(md, tick); //Unlock target
tbl = NULL;
}
}
// Check for target change.
- if( md->attacked_id && mode&MD_CANATTACK )
- {
- if( md->attacked_id == md->target_id )
- { //Rude attacked check.
- if( !battle->check_range(&md->bl, tbl, md->status.rhw.range)
- && ( //Can't attack back and can't reach back.
- (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1)
- || md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP]
- || md->sc.data[SC__MANHOLE])) // Not yet confirmed if boss will teleport once it can't reach target.
- || !mob->can_reach(md, tbl, md->min_chase, MSS_RUSH)
- )
- && md->state.attacked_count++ >= RUDE_ATTACKED_COUNT
- && !mob->skill_use(md, tick, MSC_RUDEATTACKED) // If can't rude Attack
- && can_move && unit->escape(&md->bl, tbl, rnd()%10 +1)) // Attempt escape
- { //Escaped
+ if (md->attacked_id && mode&MD_CANATTACK) {
+ if (md->attacked_id == md->target_id) {
+ //Rude attacked check.
+ if (!battle->check_range(&md->bl, tbl, md->status.rhw.range)
+ && ( //Can't attack back and can't reach back.
+ (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1)
+ || md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP]
+ || md->sc.data[SC__MANHOLE] // Not yet confirmed if boss will teleport once it can't reach target.
+ || md->walktoxy_fail_count > 0)
+ )
+ || !mob->can_reach(md, tbl, md->min_chase, MSS_RUSH)
+ )
+ && md->state.attacked_count++ >= RUDE_ATTACKED_COUNT
+ && !mob->skill_use(md, tick, MSC_RUDEATTACKED) // If can't rude Attack
+ && can_move && unit->escape(&md->bl, tbl, rnd()%10 +1) // Attempt escape
+ ) {
+ //Escaped
md->attacked_id = 0;
return true;
}
@@ -1470,18 +1482,21 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
|| (battle_config.mob_ai&0x2 && !status->check_skilluse(&md->bl, abl, 0, 0)) // Cannot normal attack back to Attacker
|| (!battle->check_range(&md->bl, abl, md->status.rhw.range) // Not on Melee Range and ...
&& ( // Reach check
- (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1)
- || md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP]
- || md->sc.data[SC__MANHOLE])) // Not yet confirmed if boss will teleport once it can't reach target.
- || !mob->can_reach(md, abl, dist+md->db->range3, MSS_RUSH)
+ (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1)
+ || md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP]
+ || md->sc.data[SC__MANHOLE] // Not yet confirmed if boss will teleport once it can't reach target.
+ || md->walktoxy_fail_count > 0)
+ )
+ || !mob->can_reach(md, abl, dist+md->db->range3, MSS_RUSH)
)
)
) {
// Rude attacked
if (md->state.attacked_count++ >= RUDE_ATTACKED_COUNT
- && !mob->skill_use(md, tick, MSC_RUDEATTACKED) && can_move
- && !tbl && unit->escape(&md->bl, abl, rnd()%10 +1))
- { //Escaped.
+ && !mob->skill_use(md, tick, MSC_RUDEATTACKED) && can_move
+ && !tbl && unit->escape(&md->bl, abl, rnd()%10 +1)
+ ) {
+ //Escaped.
//TODO: Maybe it shouldn't attempt to run if it has another, valid target?
md->attacked_id = 0;
return true;
@@ -1492,9 +1507,11 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
//Can't attack back, but didn't invoke a rude attacked skill...
} else {
//Attackable
- if (!tbl || dist < md->status.rhw.range || !check_distance_bl(&md->bl, tbl, dist)
- || battle->get_target(tbl) != md->bl.id)
- { //Change if the new target is closer than the actual one
+ if (!tbl || dist < md->status.rhw.range
+ || !check_distance_bl(&md->bl, tbl, dist)
+ || battle->get_target(tbl) != md->bl.id
+ ) {
+ //Change if the new target is closer than the actual one
//or if the previous target is not attacking the mob. [Skotlex]
md->target_id = md->attacked_id; // set target
if (md->state.attacked_count)
@@ -1546,26 +1563,26 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
}
}
- //This handles triggering idle walk/skill.
+ //This handles triggering idle/walk skill.
mob->unlocktarget(md, tick);
return true;
}
//Target exists, attack or loot as applicable.
- if (tbl->type == BL_ITEM)
- { //Loot time.
+ if (tbl->type == BL_ITEM) {
+ //Loot time.
struct flooritem_data *fitem;
if (md->ud.target == tbl->id && md->ud.walktimer != INVALID_TIMER)
return true; //Already locked.
- if (md->lootitem == NULL)
- { //Can't loot...
+ if (md->lootitem == NULL) {
+ //Can't loot...
mob->unlocktarget (md, tick);
return true;
}
- if (!check_distance_bl(&md->bl, tbl, 1))
- { //Still not within loot range.
- if (!(mode&MD_CANMOVE))
- { //A looter that can't move? Real smart.
+ if (!check_distance_bl(&md->bl, tbl, 1)) {
+ //Still not within loot range.
+ if (!(mode&MD_CANMOVE)) {
+ //A looter that can't move? Real smart.
mob->unlocktarget(md,tick);
return true;
}
@@ -1586,14 +1603,15 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
if (md->lootitem_count < LOOTITEM_SIZE) {
memcpy (&md->lootitem[md->lootitem_count++], &fitem->item_data, sizeof(md->lootitem[0]));
- } else { //Destroy first looted item...
+ } else {
+ //Destroy first looted item...
if (md->lootitem[0].card[0] == CARD0_PET)
intif->delete_petdata( MakeDWord(md->lootitem[0].card[1],md->lootitem[0].card[2]) );
memmove(&md->lootitem[0], &md->lootitem[1], (LOOTITEM_SIZE-1)*sizeof(md->lootitem[0]));
memcpy (&md->lootitem[LOOTITEM_SIZE-1], &fitem->item_data, sizeof(md->lootitem[0]));
}
- if (pcdb_checkid(md->vd->class_))
- { //Give them walk act/delay to properly mimic players. [Skotlex]
+ if (pcdb_checkid(md->vd->class_)) {
+ //Give them walk act/delay to properly mimic players. [Skotlex]
clif->takeitem(&md->bl,tbl);
md->ud.canact_tick = tick + md->status.amotion;
unit->set_walkdelay(&md->bl, tick, md->status.amotion, 1);
@@ -1603,46 +1621,44 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
mob->unlocktarget (md,tick);
return true;
}
+
//Attempt to attack.
//At this point we know the target is attackable, we just gotta check if the range matches.
- if (md->ud.target == tbl->id && md->ud.attacktimer != INVALID_TIMER) //Already locked.
+ if (battle->check_range(&md->bl, tbl, md->status.rhw.range) && !(md->sc.option&OPTION_HIDE)) {
+ //Target within range and able to use normal attack, engage
+ if (md->ud.target != tbl->id || md->ud.attacktimer == INVALID_TIMER)
+ { //Only attack if no more attack delay left
+ if(tbl->type == BL_PC)
+ mob->log_damage(md, tbl, 0); //Log interaction (counts as 'attacker' for the exp bonus)
+ unit->attack(&md->bl,tbl->id,1);
+ }
return true;
+ }
- if (battle->check_range (&md->bl, tbl, md->status.rhw.range))
- { //Target within range, engage
+ //Monsters in berserk state, unable to use normal attacks, will always attempt a skill
+ if(md->ud.walktimer == INVALID_TIMER && (md->state.skillstate == MSS_BERSERK || md->state.skillstate == MSS_ANGRY)) {
+ if (DIFF_TICK(md->ud.canmove_tick, tick) <= MIN_MOBTHINKTIME && DIFF_TICK(md->ud.canact_tick, tick) < -MIN_MOBTHINKTIME*IDLE_SKILL_INTERVAL)
+ { //Only use skill if able to walk on next tick and not used a skill the last second
+ mob->skill_use(md, tick, -1);
+ }
+ }
- if(tbl->type == BL_PC)
- mob->log_damage(md, tbl, 0); //Log interaction (counts as 'attacker' for the exp bonus)
+ //Target still in attack range, no need to chase the target
+ if(battle->check_range(&md->bl, tbl, md->status.rhw.range))
+ return true;
- if(!(mode&MD_RANDOMTARGET))
- unit->attack(&md->bl,tbl->id,1);
- else { // Attack once and find new random target
- int search_size = (view_range < md->status.rhw.range) ? view_range : md->status.rhw.range;
- unit->attack(&md->bl,tbl->id,0);
- tbl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md), search_size);
- // If no target was found, keep atacking the old one
- if( tbl ) {
- md->target_id = tbl->id;
- md->min_chase = md->db->range3;
- }
- }
+ //Only update target cell / drop target after having moved at least "mob_chase_refresh" cells
+ if(md->ud.walktimer != INVALID_TIMER && (!can_move || md->ud.walkpath.path_pos <= battle_config.mob_chase_refresh))
return true;
- }
//Out of range...
- if (!(mode&MD_CANMOVE))
- { //Can't chase. Attempt an idle skill before unlocking.
- md->state.skillstate = MSS_IDLE;
- if (!mob->skill_use(md, tick, -1))
+ if (!(mode&MD_CANMOVE) || (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0)) {
+ //Can't chase. Immobile and trapped mobs should unlock target and use an idle skill.
+ if (md->ud.attacktimer == INVALID_TIMER)
+ { //Only unlock target if no more attack delay left
+ //This handles triggering idle/walk skill.
mob->unlocktarget(md,tick);
- return true;
- }
-
- if (!can_move)
- { //Stuck. Attempt an idle skill
- md->state.skillstate = MSS_IDLE;
- if (!(++md->ud.walk_count%IDLE_SKILL_INTERVAL))
- mob->skill_use(md, tick, -1);
+ }
return true;
}
@@ -1654,6 +1670,7 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
return true;
//Follow up if possible.
+ //Hint: Chase skills are handled in the walktobl routine
if(!mob->can_reach(md, tbl, md->min_chase, MSS_RUSH) ||
!unit->walktobl(&md->bl, tbl, md->status.rhw.range, 2))
mob->unlocktarget(md,tick);
@@ -1664,8 +1681,8 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
int mob_ai_sub_hard_timer(struct block_list *bl, va_list ap) {
struct mob_data *md = (struct mob_data*)bl;
int64 tick = va_arg(ap, int64);
- if (mob->ai_sub_hard(md, tick))
- { //Hard AI triggered.
+ if (mob->ai_sub_hard(md, tick)) {
+ //Hard AI triggered.
if(!md->state.spotted)
md->state.spotted = 1;
md->last_pcneartime = tick;
@@ -1703,11 +1720,11 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) {
if (md->bl.prev==NULL || md->status.hp == 0)
return 1;
- if(battle_config.mob_active_time &&
- md->last_pcneartime &&
- !(md->status.mode&MD_BOSS) &&
- DIFF_TICK(tick,md->last_thinktime) > MIN_MOBTHINKTIME)
- {
+ if (battle_config.mob_active_time
+ && md->last_pcneartime
+ && !(md->status.mode&MD_BOSS)
+ && DIFF_TICK(tick,md->last_thinktime) > MIN_MOBTHINKTIME
+ ) {
if (DIFF_TICK(tick,md->last_pcneartime) < battle_config.mob_active_time)
return (int)mob->ai_sub_hard(md, tick);
md->last_pcneartime = 0;
@@ -1734,20 +1751,17 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) {
}
if( DIFF_TICK(md->next_walktime,tick) < 0 && (status_get_mode(&md->bl)&MD_CANMOVE) && unit->can_move(&md->bl) ) {
- if( map->list[md->bl.m].users > 0 )
- {
- if( rnd()%1000 < MOB_LAZYMOVEPERC(md) )
- mob->randomwalk(md, tick);
- else
- if( rnd()%1000 < MOB_LAZYSKILLPERC ) //Chance to do a mob's idle skill.
- mob->skill_use(md, tick, -1);
- }
- else
- {
- if( rnd()%1000 < MOB_LAZYMOVEPERC(md) )
- mob->randomwalk(md, tick);
- }
+ if( rnd()%1000 < MOB_LAZYMOVEPERC(md) )
+ mob->randomwalk(md, tick);
+ }
+ else if( md->ud.walktimer == INVALID_TIMER )
+ {
+ //Because it is not unset when the mob finishes walking.
+ md->state.skillstate = MSS_IDLE;
+ if( rnd()%1000 < MOB_LAZYSKILLPERC(md) ) //Chance to do a mob's idle skill.
+ mob->skill_use(md, tick, -1);
}
+
return 0;
}
@@ -1840,7 +1854,8 @@ void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct ite
&& sd->bl.m == md->bl.m
&& check_distance_blxy(&sd->bl, dlist->x, dlist->y, AUTOLOOT_DISTANCE)
#endif
- ) { //Autoloot.
+ ) {
+ //Autoloot.
if (party->share_loot(party->search(sd->status.party_id),
sd, &ditem->item_data, sd->status.char_id) == 0
) {
@@ -1995,13 +2010,14 @@ void mob_log_damage(struct mob_data *md, struct block_list *src, int damage)
if(md->dmglog[i].id==char_id &&
md->dmglog[i].flag==flag)
break;
- if(md->dmglog[i].id==0) { //Store data in first empty slot.
+ if(md->dmglog[i].id==0) {
+ //Store data in first empty slot.
md->dmglog[i].id = char_id;
md->dmglog[i].flag= flag;
break;
}
- if(md->dmglog[i].dmg<mindmg && i)
- { //Never overwrite first hit slot (he gets double exp bonus)
+ if (md->dmglog[i].dmg<mindmg && i) {
+ //Never overwrite first hit slot (he gets double exp bonus)
minpos=i;
mindmg=md->dmglog[i].dmg;
}
@@ -2145,8 +2161,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
// determines, if the monster was killed by homunculus' damage only
homkillonly = (bool)( ( dmgbltypes&BL_HOM ) && !( dmgbltypes&~BL_HOM ) );
- if(!battle_config.exp_calc_type && count > 1)
- { //Apply first-attacker 200% exp share bonus
+ if (!battle_config.exp_calc_type && count > 1) {
+ //Apply first-attacker 200% exp share bonus
//TODO: Determine if this should go before calculating the MVP player instead of after.
if (UINT_MAX - md->dmglog[0].dmg > md->tdmg) {
md->tdmg += md->dmglog[0].dmg;
@@ -2203,7 +2219,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
// change experience for different sized monsters [Valaris]
if (battle_config.mob_size_influence) {
switch( md->special_state.size ) {
- case SZ_SMALL:
+ case SZ_MEDIUM:
per /= 2.;
break;
case SZ_BIG:
@@ -2246,7 +2262,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
pnum++;
flag=0;
}
- } else { //Add to total
+ } else {
+ //Add to total
if (pt[j].base_exp > UINT_MAX - base_exp)
pt[j].base_exp = UINT_MAX;
else
@@ -2324,7 +2341,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
// change drops depending on monsters size [Valaris]
if (battle_config.mob_size_influence)
{
- if (md->special_state.size == SZ_SMALL && drop_rate >= 2)
+ if (md->special_state.size == SZ_MEDIUM && drop_rate >= 2)
drop_rate /= 2;
else if( md->special_state.size == SZ_BIG)
drop_rate *= 2;
@@ -2445,7 +2462,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
timer->add(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist);
else //No drops
ers_free(item_drop_list_ers, dlist);
- } else if (md->lootitem && md->lootitem_count) { //Loot MUST drop!
+ } else if (md->lootitem && md->lootitem_count) {
+ //Loot MUST drop!
struct item_drop_list *dlist = ers_alloc(item_drop_list_ers, struct item_drop_list);
dlist->m = md->bl.m;
dlist->x = md->bl.x;
@@ -2540,9 +2558,10 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
logs->mvpdrop(mvp_sd, md->class_, log_mvp);
}
- if (type&2 && !sd && md->class_ == MOBID_EMPERIUM && md->guardian_data)
- //Emperium destroyed by script. Discard mvp character. [Skotlex]
+ if (type&2 && !sd && md->class_ == MOBID_EMPERIUM && md->guardian_data) {
+ //Emperium destroyed by script. Discard mvp character. [Skotlex]
mvp_sd = NULL;
+ }
rebirth = ( md->sc.data[SC_KAIZEL] || (md->sc.data[SC_REBIRTH] && !md->state.rebirth) );
if( !rebirth ) { // Only trigger event on final kill
@@ -2640,10 +2659,10 @@ void mob_revive(struct mob_data *md, unsigned int hp)
int64 tick = timer->gettick();
md->state.skillstate = MSS_IDLE;
md->last_thinktime = tick;
- md->next_walktime = tick+rnd()%50+5000;
+ md->next_walktime = tick+rnd()%1000+MIN_RANDOMWALKTIME;
md->last_linktime = tick;
md->last_pcneartime = 0;
- memset(md->dmglog, 0, sizeof(md->dmglog)); // Reset the damage done on the rebirthed monster, otherwise will grant full exp + damage done. [Valaris]
+ memset(md->dmglog, 0, sizeof(md->dmglog)); // Reset the damage done on the rebirthed monster, otherwise will grant full exp + damage done. [Valaris]
md->tdmg = 0;
if (!md->bl.prev)
map->addblock(&md->bl);
@@ -2662,8 +2681,8 @@ int mob_guardian_guildchange(struct mob_data *md)
if (!md->guardian_data)
return 0;
- if( md->guardian_data->castle->guild_id == 0 )
- { //Castle with no owner? Delete the guardians.
+ if (md->guardian_data->castle->guild_id == 0) {
+ //Castle with no owner? Delete the guardians.
if( md->class_ == MOBID_EMPERIUM ) //But don't delete the emperium, just clear it's guild-data
md->guardian_data->g = NULL;
else {
@@ -2675,8 +2694,8 @@ int mob_guardian_guildchange(struct mob_data *md)
}
g = guild->search(md->guardian_data->castle->guild_id);
- if( g == NULL )
- { //Properly remove guardian info from Castle data.
+ if (g == NULL) {
+ //Properly remove guardian info from Castle data.
ShowError("mob_guardian_guildchange: New Guild (id %d) does not exists!\n", md->guardian_data->castle->guild_id);
if (md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS)
guild->castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number, 0);
@@ -2700,7 +2719,7 @@ int mob_random_class (int *value, size_t count)
if (count < 1) {
count = 0;
while(count < 5 && mob->db_checkid(value[count])) count++;
- if(count < 1) // nothing found
+ if(count < 1) // nothing found
return 0;
} else {
// check if at least the first value is valid
@@ -2925,8 +2944,7 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id)
md->status.hp = md->status.max_hp*hp_rate/100;
//Inherit the aggressive mode of the master.
- if (battle_config.slaves_inherit_mode && md->master_id)
- {
+ if (battle_config.slaves_inherit_mode && md->master_id) {
switch (battle_config.slaves_inherit_mode) {
case 1: //Always aggressive
if (!(md->status.mode&MD_AGGRESSIVE))
@@ -3072,7 +3090,6 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) {
struct block_list *bl;
struct mob_data *fmd = NULL;
int i,j,n;
- short skill_target;
nullpo_ret(md);
nullpo_ret(ms = md->db->skill);
@@ -3117,16 +3134,16 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) {
{
case MSC_ALWAYS:
flag = 1; break;
- case MSC_MYHPLTMAXRATE: // HP< maxhp%
+ case MSC_MYHPLTMAXRATE: // HP< maxhp%
flag = get_percentage(md->status.hp, md->status.max_hp);
flag = (flag <= c2);
- break;
+ break;
case MSC_MYHPINRATE:
flag = get_percentage(md->status.hp, md->status.max_hp);
flag = (flag >= c2 && flag <= ms[i].val[0]);
break;
- case MSC_MYSTATUSON: // status[num] on
- case MSC_MYSTATUSOFF: // status[num] off
+ case MSC_MYSTATUSON: // status[num] on
+ case MSC_MYSTATUSOFF: // status[num] off
if (!md->sc.count) {
flag = 0;
} else if (ms[i].cond2 == -1) {
@@ -3137,26 +3154,26 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) {
flag = (md->sc.data[ms[i].cond2]!=NULL);
}
flag ^= (ms[i].cond1 == MSC_MYSTATUSOFF); break;
- case MSC_FRIENDHPLTMAXRATE: // friend HP < maxhp%
+ case MSC_FRIENDHPLTMAXRATE: // friend HP < maxhp%
flag = ((fbl = mob->getfriendhprate(md, 0, ms[i].cond2)) != NULL); break;
- case MSC_FRIENDHPINRATE :
+ case MSC_FRIENDHPINRATE:
flag = ((fbl = mob->getfriendhprate(md, ms[i].cond2, ms[i].val[0])) != NULL); break;
- case MSC_FRIENDSTATUSON: // friend status[num] on
- case MSC_FRIENDSTATUSOFF: // friend status[num] off
+ case MSC_FRIENDSTATUSON: // friend status[num] on
+ case MSC_FRIENDSTATUSOFF: // friend status[num] off
flag = ((fmd = mob->getfriendstatus(md, ms[i].cond1, ms[i].cond2)) != NULL); break;
- case MSC_SLAVELT: // slave < num
+ case MSC_SLAVELT: // slave < num
flag = (mob->countslave(&md->bl) < c2 ); break;
- case MSC_ATTACKPCGT: // attack pc > num
+ case MSC_ATTACKPCGT: // attack pc > num
flag = (unit->counttargeted(&md->bl) > c2); break;
- case MSC_SLAVELE: // slave <= num
+ case MSC_SLAVELE: // slave <= num
flag = (mob->countslave(&md->bl) <= c2 ); break;
- case MSC_ATTACKPCGE: // attack pc >= num
+ case MSC_ATTACKPCGE: // attack pc >= num
flag = (unit->counttargeted(&md->bl) >= c2); break;
case MSC_AFTERSKILL:
flag = (md->ud.skill_id == c2); break;
case MSC_RUDEATTACKED:
flag = (md->state.attacked_count >= RUDE_ATTACKED_COUNT);
- if (flag) md->state.attacked_count = 0; //Rude attacked count should be reset after the skill condition is met. Thanks to Komurka [Skotlex]
+ if (flag) md->state.attacked_count = 0; //Rude attacked count should be reset after the skill condition is met. Thanks to Komurka [Skotlex]
break;
case MSC_MASTERHPLTMAXRATE:
flag = ((fbl = mob->getmasterhpltmaxrate(md, ms[i].cond2)) != NULL); break;
@@ -3171,12 +3188,10 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) {
if (!flag)
continue; //Skill requisite failed to be fulfilled.
-
//Execute skill
- skill_target = (md->db->status.mode&MD_RANDOMTARGET)? MST_RANDOM : ms[i].target;
if (skill->get_casttype(ms[i].skill_id) == CAST_GROUND) {//Ground skill.
short x, y;
- switch (skill_target) {
+ switch (ms[i].target) {
case MST_RANDOM: //Pick a random enemy within skill range.
bl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md),
skill->get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv));
@@ -3204,12 +3219,12 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) {
if (!bl) continue;
x = bl->x;
- y = bl->y;
+ y = bl->y;
// Look for an area to cast the spell around...
- if (skill_target >= MST_AROUND1 || skill_target >= MST_AROUND5) {
- j = skill_target >= MST_AROUND1?
- (skill_target-MST_AROUND1) +1:
- (skill_target-MST_AROUND5) +1;
+ if (ms[i].target >= MST_AROUND1 || ms[i].target >= MST_AROUND5) {
+ j = ms[i].target >= MST_AROUND1?
+ (ms[i].target-MST_AROUND1) +1:
+ (ms[i].target-MST_AROUND5) +1;
map->search_freecell(&md->bl, md->bl.m, &x, &y, j, j, 3);
}
md->skill_idx = i;
@@ -3222,7 +3237,7 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) {
}
} else {
//Targeted skill
- switch (skill_target) {
+ switch (ms[i].target) {
case MST_RANDOM: //Pick a random enemy within skill range.
bl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md),
skill->get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv));
@@ -3263,10 +3278,10 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) {
if ( ms[ i ].msg_id ){ //Display color message [SnakeDrak]
struct mob_chat *mc = mob->chat(ms[i].msg_id);
char temp[CHAT_SIZE_MAX];
- char name[NAME_LENGTH];
- snprintf(name, sizeof name,"%s", md->name);
- strtok(name, "#"); // discard extra name identifier if present [Daegaladh]
- snprintf(temp, sizeof temp,"%s : %s", name, mc->msg);
+ char name[NAME_LENGTH];
+ snprintf(name, sizeof name,"%s", md->name);
+ strtok(name, "#"); // discard extra name identifier if present [Daegaladh]
+ snprintf(temp, sizeof temp,"%s : %s", name, mc->msg);
clif->messagecolor(&md->bl, mc->color, temp);
}
if(!(battle_config.mob_ai&0x200)) { //pass on delay to same skill.
@@ -3508,7 +3523,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons
sd->fd = fd;
//Finally, spawn it.
- md = mob->once_spawn_sub(&sd->bl, m, x, y, "--en--", class_, event, SZ_MEDIUM, AI_NONE);
+ md = mob->once_spawn_sub(&sd->bl, m, x, y, "--en--", class_, event, SZ_SMALL, AI_NONE);
if (!md) return 0; //Failed?
md->special_state.clone = 1;
@@ -3536,8 +3551,7 @@ int mob_clone_delete(struct mob_data *md)
const int class_ = md->class_;
if (class_ >= MOB_CLONE_START && class_ < MOB_CLONE_END
&& mob->db_data[class_]!=NULL) {
- aFree(mob->db_data[class_]);
- mob->db_data[class_]=NULL;
+ mob->destroy_mob_db(class_);
//Clear references to the db
md->db = mob->dummy;
md->vd = NULL;
@@ -3558,10 +3572,9 @@ int mob_makedummymobdb(int class_)
{
if (mob->db(class_) == mob->dummy)
return 1; //Using the mob->dummy data already. [Skotlex]
- if (class_ > 0 && class_ <= MAX_MOB_DB)
- { //Remove the mob data so that it uses the dummy data instead.
- aFree(mob->db_data[class_]);
- mob->db_data[class_] = NULL;
+ if (class_ > 0 && class_ <= MAX_MOB_DB) {
+ //Remove the mob data so that it uses the dummy data instead.
+ mob->destroy_mob_db(class_);
}
return 0;
}
@@ -3701,7 +3714,12 @@ bool mob_parse_dbrow(char** str) {
mstatus->int_ = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[17]));
mstatus->dex = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[18]));
mstatus->luk = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[19]));
-
+
+ /*
+ * Disabled for renewal since difference of 0 and 1 still has an impact in the formulas
+ * Just in case there is a mishandled division by zero please let us know. [malufett]
+ */
+#ifndef RENEWAL
//All status should be min 1 to prevent divisions by zero from some skills. [Skotlex]
if (mstatus->str < 1) mstatus->str = 1;
if (mstatus->agi < 1) mstatus->agi = 1;
@@ -3709,6 +3727,11 @@ bool mob_parse_dbrow(char** str) {
if (mstatus->int_< 1) mstatus->int_= 1;
if (mstatus->dex < 1) mstatus->dex = 1;
if (mstatus->luk < 1) mstatus->luk = 1;
+#endif
+
+ //Tests showed that chase range is effectively 2 cells larger than expected [Playtester]
+ if (db->range3 > 0)
+ db->range3 += 2;
db->range2 = atoi(str[20]);
db->range3 = atoi(str[21]);
@@ -3818,8 +3841,8 @@ bool mob_parse_dbrow(char** str) {
id = itemdb->search(db->dropitem[i].nameid);
type = id->type;
rate = atoi(str[k+1]);
- if( (class_ >= 1324 && class_ <= 1363) || (class_ >= 1938 && class_ <= 1946) )
- { //Treasure box drop rates [Skotlex]
+ if( (class_ >= 1324 && class_ <= 1363) || (class_ >= 1938 && class_ <= 1946) ) {
+ //Treasure box drop rates [Skotlex]
rate_adjust = battle_config.item_rate_treasure;
ratemin = battle_config.item_drop_treasure_min;
ratemax = battle_config.item_drop_treasure_max;
@@ -3919,7 +3942,13 @@ void mob_readdb(void) {
* mob_db table reading
*------------------------------------------*/
int mob_read_sqldb(void) {
- const char* mob_db_name[] = { map->mob_db_db, map->mob_db2_db };
+ const char* mob_db_name[] = {
+#ifdef RENEWAL
+ map->mob_db_re_db
+#else
+ map->mob_db_db
+#endif
+ , map->mob_db2_db };
int fi;
for( fi = 0; fi < ARRAYLENGTH(mob_db_name); ++fi ) {
@@ -3989,8 +4018,8 @@ bool mob_readdb_mobavail(char* str[], int columns, int current)
class_=atoi(str[0]);
- if(mob->db(class_) == mob->dummy) // invalid class (probably undefined in db)
- {
+ if(mob->db(class_) == mob->dummy) {
+ // invalid class (probably undefined in db)
ShowWarning("mob_readdb_mobavail: Unknown mob id %d.\n", class_);
return false;
}
@@ -4041,7 +4070,7 @@ int mob_read_randommonster(void)
for( i = 0; i < ARRAYLENGTH(mobfile) && i < MAX_RANDOMMONSTER; i++ ) {
unsigned int count = 0;
- mob->db_data[0]->summonper[i] = 1002; // Default fallback value, in case the database does not provide one
+ mob->db_data[0]->summonper[i] = 1002; // Default fallback value, in case the database does not provide one
sprintf(line, "%s/%s", map->db_path, mobfile[i]);
fp=fopen(line,"r");
if(fp==NULL){
@@ -4208,16 +4237,16 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current)
char str[32];
enum MobSkillState id;
} state[] = {
- { "any", MSS_ANY }, //All states except Dead
- { "idle", MSS_IDLE },
- { "walk", MSS_WALK },
- { "loot", MSS_LOOT },
- { "dead", MSS_DEAD },
- { "attack", MSS_BERSERK }, //Retaliating attack
- { "angry", MSS_ANGRY }, //Preemptive attack (aggressive mobs)
- { "chase", MSS_RUSH }, //Chase escaping target
- { "follow", MSS_FOLLOW }, //Preemptive chase (aggressive mobs)
- { "anytarget",MSS_ANYTARGET }, //Berserk+Angry+Rush+Follow
+ { "any", MSS_ANY }, //All states except Dead
+ { "idle", MSS_IDLE },
+ { "walk", MSS_WALK },
+ { "loot", MSS_LOOT },
+ { "dead", MSS_DEAD },
+ { "attack", MSS_BERSERK }, //Retaliating attack
+ { "angry", MSS_ANGRY }, //Preemptive attack (aggressive mobs)
+ { "chase", MSS_RUSH }, //Chase escaping target
+ { "follow", MSS_FOLLOW }, //Preemptive chase (aggressive mobs)
+ { "anytarget", MSS_ANYTARGET }, //Berserk+Angry+Rush+Follow
};
static const struct {
char str[32];
@@ -4247,33 +4276,33 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current)
{ "alchemist", MSC_ALCHEMIST },
{ "onspawn", MSC_SPAWN },
}, cond2[] ={
- { "anybad", -1 },
- { "stone", SC_STONE },
- { "freeze", SC_FREEZE },
- { "stun", SC_STUN },
- { "sleep", SC_SLEEP },
- { "poison", SC_POISON },
- { "curse", SC_CURSE },
- { "silence", SC_SILENCE },
- { "confusion", SC_CONFUSION },
- { "blind", SC_BLIND },
- { "hiding", SC_HIDING },
- { "sight", SC_SIGHT },
+ { "anybad", -1 },
+ { "stone", SC_STONE },
+ { "freeze", SC_FREEZE },
+ { "stun", SC_STUN },
+ { "sleep", SC_SLEEP },
+ { "poison", SC_POISON },
+ { "curse", SC_CURSE },
+ { "silence", SC_SILENCE },
+ { "confusion", SC_CONFUSION },
+ { "blind", SC_BLIND },
+ { "hiding", SC_HIDING },
+ { "sight", SC_SIGHT },
}, target[] = {
- { "target", MST_TARGET },
- { "randomtarget", MST_RANDOM },
- { "self", MST_SELF },
- { "friend", MST_FRIEND },
- { "master", MST_MASTER },
- { "around5", MST_AROUND5 },
- { "around6", MST_AROUND6 },
- { "around7", MST_AROUND7 },
- { "around8", MST_AROUND8 },
- { "around1", MST_AROUND1 },
- { "around2", MST_AROUND2 },
- { "around3", MST_AROUND3 },
- { "around4", MST_AROUND4 },
- { "around", MST_AROUND },
+ { "target", MST_TARGET },
+ { "randomtarget", MST_RANDOM },
+ { "self", MST_SELF },
+ { "friend", MST_FRIEND },
+ { "master", MST_MASTER },
+ { "around5", MST_AROUND5 },
+ { "around6", MST_AROUND6 },
+ { "around7", MST_AROUND7 },
+ { "around8", MST_AROUND8 },
+ { "around1", MST_AROUND1 },
+ { "around2", MST_AROUND2 },
+ { "around3", MST_AROUND3 },
+ { "around4", MST_AROUND4 },
+ { "around", MST_AROUND },
};
static int last_mob_id = 0; // ensures that only one error message per mob id is printed
@@ -4300,8 +4329,8 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current)
return true;
}
- if (mob_id < 0)
- { //Prepare global skill. [Skotlex]
+ if (mob_id < 0) {
+ //Prepare global skill. [Skotlex]
memset(&gms, 0, sizeof (struct mob_skill));
ms = &gms;
} else {
@@ -4412,8 +4441,8 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current)
ms->val[1] = 0;
ms->val[4] = 1; //request to return mode to normal.
}
- if(ms->skill_id == NPC_EMOTION_ON && mob_id>0 && ms->val[1])
- { //Adds a mode to the mob.
+ if (ms->skill_id == NPC_EMOTION_ON && mob_id>0 && ms->val[1]) {
+ //Adds a mode to the mob.
//Remove aggressive mode when the new mob type is passive.
if (!(ms->val[1]&MD_AGGRESSIVE))
ms->val[3]|=MD_AGGRESSIVE;
@@ -4431,8 +4460,8 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current)
else
ms->msg_id=0;
- if (mob_id < 0)
- { //Set this skill to ALL mobs. [Skotlex]
+ if (mob_id < 0) {
+ //Set this skill to ALL mobs. [Skotlex]
mob_id *= -1;
for (i = 1; i < MAX_MOB_DB; i++)
{
@@ -4492,7 +4521,13 @@ void mob_readskilldb(void) {
* seems to work though...
*/
int mob_read_sqlskilldb(void) {
- const char* mob_skill_db_name[] = { map->mob_skill_db_db, map->mob_skill_db2_db };
+ const char* mob_skill_db_name[] = {
+#ifdef RENEWAL
+ map->mob_skill_db_re_db
+#else
+ map->mob_skill_db_db
+#endif
+ , map->mob_skill_db2_db };
int fi;
if( battle_config.mob_skill_rate == 0 ) {
@@ -4637,8 +4672,11 @@ void mob_reload(void) {
mob->load(false);
}
+/**
+ * Clears spawn related information for a script reload.
+ */
void mob_clear_spawninfo()
-{ //Clears spawn related information for a script reload.
+{
int i;
for (i = 0; i < MAX_MOB_DB; i++)
if (mob->db_data[i])
@@ -4674,6 +4712,22 @@ int do_init_mob(bool minimal) {
return 0;
}
+void mob_destroy_mob_db(int index)
+{
+ struct mob_db *data = mob->db_data[index];
+ int v;
+ for (v = 0; v < data->hdatac; v++ ) {
+ if (data->hdata[v]->flag.free ) {
+ aFree(data->hdata[v]->data);
+ }
+ aFree(data->hdata[v]);
+ }
+ if (data->hdata)
+ aFree(data->hdata);
+ aFree(data);
+ mob->db_data[index] = NULL;
+}
+
/*==========================================
* Clean memory usage.
*------------------------------------------*/
@@ -4689,8 +4743,7 @@ int do_final_mob(void)
{
if (mob->db_data[i] != NULL)
{
- aFree(mob->db_data[i]);
- mob->db_data[i] = NULL;
+ mob->destroy_mob_db(i);
}
}
for (i = 0; i <= MAX_MOB_CHAT; i++)
@@ -4825,4 +4878,5 @@ void mob_defaults(void) {
mob->readdb_itemratio = mob_readdb_itemratio;
mob->load = mob_load;
mob->clear_spawninfo = mob_clear_spawninfo;
+ mob->destroy_mob_db = mob_destroy_mob_db;
}
diff --git a/src/map/mob.h b/src/map/mob.h
index c8d43dbb2..9aac2c664 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -16,7 +16,7 @@
// Change this to increase the table size in your mob_db to accommodate a larger mob database.
// Be sure to note that IDs 4001 to 4048 are reserved for advanced/baby/expanded classes.
// Notice that the last 1000 entries are used for player clones, so always set this to desired value +1000
-#define MAX_MOB_DB 4000
+#define MAX_MOB_DB 5000
//The number of drops all mobs have and the max drop-slot that the steal skill will attempt to steal from.
#define MAX_MOB_DROP 10
@@ -27,6 +27,8 @@
#define MIN_MOBTHINKTIME 100
//Min time before mobs do a check to call nearby friends for help (or for slaves to support their master)
#define MIN_MOBLINKTIME 1000
+//Min time between random walks
+#define MIN_RANDOMWALKTIME 4000
//Distance that slaves should keep from their master.
#define MOB_SLAVEDISTANCE 2
@@ -40,6 +42,15 @@
#define MAX_MOB_CHAT 250 //Max Skill's messages
+// On official servers, monsters will only seek targets that are closer to walk to than their
+// search range. The search range is affected depending on if the monster is walking or not.
+// On some maps there can be a quite long path for just walking two cells in a direction and
+// the client does not support displaying walk paths that are longer than 14 cells, so this
+// option reduces position lag in such situation. But doing a complex search for every possible
+// target, might be CPU intensive.
+// Disable this to make monsters not do any path search when looking for a target (old behavior).
+#define ACTIVEPATHSEARCH
+
//Mob skill states.
enum MobSkillState {
MSS_ANY = -1,
@@ -62,8 +73,8 @@ enum MobDamageLogFlag
};
enum size {
- SZ_MEDIUM = 0,
- SZ_SMALL,
+ SZ_SMALL = 0,
+ SZ_MEDIUM,
SZ_BIG,
};
@@ -104,7 +115,7 @@ struct mob_db {
unsigned int base_exp,job_exp;
unsigned int mexp;
short range2,range3;
- short race2; // celest
+ short race2; // celest
unsigned short lv;
struct { int nameid,p; } dropitem[MAX_MOB_DROP];
struct { int nameid,p; } mvpitem[MAX_MVP_DROP];
@@ -115,6 +126,10 @@ struct mob_db {
int maxskill;
struct mob_skill skill[MAX_MOBSKILL];
struct spawn_info spawn[10];
+
+ /* HPM Custom Struct */
+ struct HPluginData **hdata;
+ unsigned int hdatac;
};
struct mob_data {
@@ -123,7 +138,7 @@ struct mob_data {
struct view_data *vd;
struct status_data status, *base_status; //Second one is in case of leveling up mobs, or tiny/large mobs.
struct status_change sc;
- struct mob_db *db; //For quick data access (saves doing mob_db(md->class_) all the time) [Skotlex]
+ struct mob_db *db; //For quick data access (saves doing mob_db(md->class_) all the time) [Skotlex]
char name[NAME_LENGTH];
struct {
unsigned int size : 2; //Small/Big monsters.
@@ -169,6 +184,7 @@ struct mob_data {
short move_fail_count;
short lootitem_count;
short min_chase;
+ unsigned char walktoxy_fail_count; //Pathfinding succeeds but the actual walking failed (e.g. Icewall lock)
int deletetimer;
int master_id,master_dist;
@@ -185,13 +201,17 @@ struct mob_data {
* MvP Tombstone NPC ID
**/
int tomb_nid;
+
+ /* HPM Custom Struct */
+ struct HPluginData **hdata;
+ unsigned int hdatac;
};
enum {
- MST_TARGET = 0,
- MST_RANDOM, //Random Target!
+ MST_TARGET = 0,
+ MST_RANDOM, //Random Target!
MST_SELF,
MST_FRIEND,
MST_MASTER,
@@ -203,9 +223,9 @@ enum {
MST_AROUND2,
MST_AROUND3,
MST_AROUND4,
- MST_AROUND = MST_AROUND4,
+ MST_AROUND = MST_AROUND4,
- MSC_ALWAYS = 0x0000,
+ MSC_ALWAYS = 0x0000,
MSC_MYHPLTMAXRATE,
MSC_MYHPINRATE,
MSC_FRIENDHPLTMAXRATE,
@@ -357,6 +377,7 @@ struct mob_interface {
bool (*readdb_itemratio) (char *str[], int columns, int current);
void (*load) (bool minimal);
void (*clear_spawninfo) ();
+ void (*destroy_mob_db) (int index);
};
struct mob_interface *mob;
diff --git a/src/map/npc.c b/src/map/npc.c
index f1c6f4fbd..8b5bbc83e 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -63,14 +63,16 @@ static struct view_data npc_viewdb2[MAX_NPC_CLASS2_END-MAX_NPC_CLASS2_START];
unsigned int npc_market_qty[MAX_INVENTORY];
static struct script_event_s
-{ //Holds pointers to the commonly executed scripts for speedup. [Skotlex]
+{
+ //Holds pointers to the commonly executed scripts for speedup. [Skotlex]
struct event_data *event[UCHAR_MAX];
const char *event_name[UCHAR_MAX];
uint8 event_count;
} script_event[NPCE_MAX];
struct view_data* npc_get_viewdata(int class_)
-{ //Returns the viewdata for normal npc classes.
+{
+ //Returns the viewdata for normal npc classes.
if( class_ == INVISIBLE_CLASS )
return &npc_viewdb[0];
if (npcdb_checkid(class_) || class_ == WARP_CLASS){
@@ -103,12 +105,12 @@ int npc_get_new_npc_id(void) {
}
int npc_isnear_sub(struct block_list* bl, va_list args) {
- struct npc_data *nd = (struct npc_data*)bl;
-
- if( nd->option & (OPTION_HIDE|OPTION_INVISIBLE) )
- return 0;
+ struct npc_data *nd = (struct npc_data*)bl;
- return 1;
+ if( nd->option & (OPTION_HIDE|OPTION_INVISIBLE) )
+ return 0;
+
+ return 1;
}
bool npc_isnear(struct block_list * bl) {
@@ -137,11 +139,22 @@ int npc_ontouch2_event(struct map_session_data *sd, struct npc_data *nd)
{
char name[EVENT_NAME_LENGTH];
- if( sd->areanpc_id == nd->bl.id )
+ if (sd->areanpc_id == nd->bl.id)
return 0;
snprintf(name, ARRAYLENGTH(name), "%s::%s", nd->exname, script->config.ontouch2_name);
- return npc->event(sd,name,2);
+ return npc->event(sd, name, 2);
+}
+
+int npc_onuntouch_event(struct map_session_data *sd, struct npc_data *nd)
+{
+ char name[EVENT_NAME_LENGTH];
+
+ if (sd->areanpc_id != nd->bl.id)
+ return 0;
+
+ snprintf(name, ARRAYLENGTH(name), "%s::%s", nd->exname, script->config.onuntouch_name);
+ return npc->event(sd, name, 2);
}
/*==========================================
@@ -885,9 +898,10 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y)
nullpo_retr(1, sd);
- // Why not enqueue it? [Inkfish]
- //if(sd->npc_id)
- // return 1;
+#if 0 // Why not enqueue it? [Inkfish]
+ if(sd->npc_id)
+ return 1;
+#endif // 0
for(i=0;i<map->list[m].npc_num;i++) {
if (map->list[m].npc[i]->option&OPTION_INVISIBLE) {
@@ -961,6 +975,23 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y)
return 0;
}
+/*==========================================
+ * Exec OnUnTouch for player if out range of area event
+ *------------------------------------------*/
+int npc_untouch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y)
+{
+ struct npc_data *nd;
+ nullpo_retr(1, sd);
+
+ if (!sd->areanpc_id)
+ return 0;
+
+ nd = (struct npc_data *) map->id2bl(sd->areanpc_id);
+ npc->onuntouch_event(sd, nd);
+ sd->areanpc_id = 0;
+ return 0;
+}
+
// OnTouch NPC or Warp for Mobs
// Return 1 if Warped
int npc_touch_areanpc2(struct mob_data *md)
@@ -1083,22 +1114,28 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) {
struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* bl)
{
struct npc_data *nd;
+ int distance = AREA_SIZE + 1;
nullpo_retr(NULL, sd);
- if(bl == NULL) return NULL;
- if(bl->type != BL_NPC) return NULL;
+ if (bl == NULL) return NULL;
+ if (bl->type != BL_NPC) return NULL;
nd = (TBL_NPC*)bl;
- if(sd->state.using_fake_npc && sd->npc_id == bl->id)
+ if (sd->npc_id == bl->id)
return nd;
if (nd->class_<0) //Class-less npc, enable click from anywhere.
return nd;
- if (bl->m!=sd->bl.m ||
- bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
- bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)
+ if (distance > nd->area_size)
+ distance = nd->area_size;
+
+ if (bl->m != sd->bl.m ||
+ bl->x < sd->bl.x - distance || bl->x > sd->bl.x + distance ||
+ bl->y < sd->bl.y - distance || bl->y > sd->bl.y + distance)
+ {
return NULL;
+ }
return nd;
}
@@ -1211,7 +1248,7 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing) {
TBL_NPC* nd = BL_CAST(BL_NPC, target);
ShowDebug("npc_scriptcont: %s (sd->npc_id=%d) is not %s (id=%d).\n",
nd_sd?(char*)nd_sd->name:"'Unknown NPC'", (int)sd->npc_id,
- nd?(char*)nd->name:"'Unknown NPC'", (int)id);
+ nd?(char*)nd->name:"'Unknown NPC'", (int)id);
return 1;
}
@@ -1270,7 +1307,7 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type) {
sd->npc_id = 0;
return 1;
}
-
+
if (nd->option & OPTION_INVISIBLE) // can't buy if npc is not visible (hack?)
return 1;
@@ -1807,22 +1844,22 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) {
return npc->buylist_sub(sd,n,item_list,nd->master_nd);
if( z > (double)sd->status.zeny )
- return 1; // Not enough Zeny
+ return 1; // Not enough Zeny
if( w + sd->weight > sd->max_weight )
- return 2; // Too heavy
+ return 2; // Too heavy
if( pc->inventoryblank(sd) < new_ )
- return 3; // Not enough space to store items
+ return 3; // Not enough space to store items
pc->payzeny(sd,(int)z,LOG_TYPE_NPC, NULL);
for( i = 0; i < n; ++i ) {
int nameid = item_list[i*2+1];
int amount = item_list[i*2+0];
- struct item item_tmp;
- if (itemdb_type(nameid) == IT_PETEGG)
+ if (itemdb_type(nameid) == IT_PETEGG) {
pet->create_egg(sd, nameid);
- else {
+ } else {
+ struct item item_tmp;
memset(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid = nameid;
item_tmp.identify = 1;
@@ -1920,20 +1957,19 @@ int npc_market_buylist(struct map_session_data* sd, unsigned short list_size, st
}
if( z > (double)sd->status.zeny ) /* TODO find official response for this */
- return 1; // Not enough Zeny
+ return 1; // Not enough Zeny
if( w + sd->weight > sd->max_weight ) /* TODO find official response for this */
- return 1; // Too heavy
+ return 1; // Too heavy
if( pc->inventoryblank(sd) < new_ ) /* TODO find official response for this */
- return 1; // Not enough space to store items
+ return 1; // Not enough space to store items
pc->payzeny(sd,(int)z,LOG_TYPE_NPC, NULL);
for( i = 0; i < list_size; ++i ) {
int nameid = p->list[i].ITID;
int amount = p->list[i].qty;
- struct item item_tmp;
j = npc_market_qty[i];
@@ -1944,9 +1980,10 @@ int npc_market_buylist(struct map_session_data* sd, unsigned short list_size, st
npc->market_tosql(nd,j);
- if (itemdb_type(nameid) == IT_PETEGG)
+ if (itemdb_type(nameid) == IT_PETEGG) {
pet->create_egg(sd, nameid);
- else {
+ } else {
+ struct item item_tmp;
memset(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid = nameid;
item_tmp.identify = 1;
@@ -2179,6 +2216,10 @@ int npc_unload(struct npc_data* nd, bool single) {
nullpo_ret(nd);
+ if( nd->ud && nd->ud != &npc->base_ud ) {
+ skill->clear_unitgroup(&nd->bl);
+ }
+
npc->remove_map(nd);
map->deliddb(&nd->bl);
if( single )
@@ -2216,7 +2257,7 @@ int npc_unload(struct npc_data* nd, bool single) {
npc->ev_db->foreach(npc->ev_db,npc->unload_ev,nd->exname); //Clean up all events related
npc->ev_label_db->foreach(npc->ev_label_db,npc->unload_ev_label,nd);
}
-
+
iter = mapit_geteachpc();
for( bl = (struct block_list*)mapit->first(iter); mapit->exists(iter); bl = (struct block_list*)mapit->next(iter) ) {
struct map_session_data *sd = ((TBL_PC*)bl);
@@ -2263,7 +2304,7 @@ int npc_unload(struct npc_data* nd, bool single) {
guild->flag_remove(nd);
}
- if( nd->ud != &npc->base_ud ) {
+ if( nd->ud && nd->ud != &npc->base_ud ) {
aFree(nd->ud);
nd->ud = NULL;
}
@@ -2445,7 +2486,7 @@ void npc_parsename(struct npc_data* nd, const char* name, const char* start, con
// Support for using Constants in place of NPC View IDs.
int npc_parseview(const char* w4, const char* start, const char* buffer, const char* filepath) {
int val = -1, i = 0;
- char viewid[1024]; // Max size of name from const.txt, see script->read_constdb.
+ char viewid[1024]; // Max size of name from const.txt, see script->read_constdb.
// Extract view ID / constant
while (w4[i] != '\0') {
@@ -2485,7 +2526,22 @@ bool npc_viewisid(const char * viewid)
}
}
- return true;
+ return true;
+}
+
+struct npc_data* npc_create_npc(int m, int x, int y)
+{
+ struct npc_data *nd;
+
+ CREATE(nd, struct npc_data, 1);
+ nd->bl.id = npc->get_new_npc_id();
+ nd->bl.prev = nd->bl.next = NULL;
+ nd->bl.m = m;
+ nd->bl.x = x;
+ nd->bl.y = y;
+ nd->area_size = AREA_SIZE + 1;
+
+ return nd;
}
//Add then display an npc warp on map
@@ -2493,13 +2549,8 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short
int i, flag = 0;
struct npc_data *nd;
- CREATE(nd, struct npc_data, 1);
- nd->bl.id = npc->get_new_npc_id();
+ nd = npc->create_npc(from_mapid, from_x, from_y);
map->addnpc(from_mapid, nd);
- nd->bl.prev = nd->bl.next = NULL;
- nd->bl.m = from_mapid;
- nd->bl.x = from_x;
- nd->bl.y = from_y;
safestrncpy(nd->exname, name, ARRAYLENGTH(nd->exname));
if (npc->name2id(nd->exname) != NULL)
@@ -2567,14 +2618,8 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s
return strchr(start,'\n');;//try next
}
- CREATE(nd, struct npc_data, 1);
-
- nd->bl.id = npc->get_new_npc_id();
+ nd = npc->create_npc(m, x, y);
map->addnpc(m, nd);
- nd->bl.prev = nd->bl.next = NULL;
- nd->bl.m = m;
- nd->bl.x = x;
- nd->bl.y = y;
npc->parsename(nd, w3, start, buffer, filepath);
if (!battle_config.warp_point_debug)
@@ -2709,17 +2754,12 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s
return strchr(start,'\n');// continue
}
- CREATE(nd, struct npc_data, 1);
+ nd = npc->create_npc(m, x, y);
CREATE(nd->u.shop.shop_item, struct npc_item_list, i);
memcpy(nd->u.shop.shop_item, items, sizeof(items[0])*i);
aFree(items);
nd->u.shop.count = i;
- nd->bl.prev = nd->bl.next = NULL;
- nd->bl.m = m;
- nd->bl.x = x;
- nd->bl.y = y;
- nd->bl.id = npc->get_new_npc_id();
npc->parsename(nd, w3, start, buffer, filepath);
nd->class_ = m == -1 ? -1 : npc->parseview(w4, start, buffer, filepath);
nd->speed = 200;
@@ -2835,7 +2875,7 @@ const char* npc_skip_script(const char* start, const char* buffer, const char* f
/// <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,{<code>}
/// <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>,{<code>}
const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, int options, int *retval) {
- int x, y, dir = 0, m, xs = 0, ys = 0; // [Valaris] thanks to fov
+ int x, y, dir = 0, m, xs = 0, ys = 0; // [Valaris] thanks to fov
char mapname[32];
struct script_code *scriptroot;
int i;
@@ -2883,8 +2923,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char*
npc->convertlabel_db(label_list,filepath);
}
- CREATE(nd, struct npc_data, 1);
-
+ nd = npc->create_npc(m, x, y);
if( sscanf(w4, "%*[^,],%d,%d", &xs, &ys) == 2 )
{// OnTouch area defined
nd->u.scr.xs = xs;
@@ -2896,12 +2935,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char*
nd->u.scr.ys = -1;
}
- nd->bl.prev = nd->bl.next = NULL;
- nd->bl.m = m;
- nd->bl.x = x;
- nd->bl.y = y;
npc->parsename(nd, w3, start, buffer, filepath);
- nd->bl.id = npc->get_new_npc_id();
nd->class_ = m == -1 ? -1 : npc->parseview(w4, start, buffer, filepath);
nd->speed = 200;
nd->u.scr.script = scriptroot;
@@ -3033,14 +3067,8 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
return end;// next line, try to continue
}
- CREATE(nd, struct npc_data, 1);
-
- nd->bl.prev = nd->bl.next = NULL;
- nd->bl.m = m;
- nd->bl.x = x;
- nd->bl.y = y;
+ nd = npc->create_npc(m, x, y);
npc->parsename(nd, w3, start, buffer, filepath);
- nd->bl.id = npc->get_new_npc_id();
nd->class_ = m == -1 ? -1 : npc->parseview(w4, start, buffer, filepath);
nd->speed = 200;
nd->src_id = src_id;
@@ -3152,13 +3180,8 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) {
return 1;
}
- CREATE(wnd, struct npc_data, 1);
- wnd->bl.id = npc->get_new_npc_id();
+ wnd = npc->create_npc(m, snd->bl.x, snd->bl.y);
map->addnpc(m, wnd);
- wnd->bl.prev = wnd->bl.next = NULL;
- wnd->bl.m = m;
- wnd->bl.x = snd->bl.x;
- wnd->bl.y = snd->bl.y;
safestrncpy(wnd->name, "", ARRAYLENGTH(wnd->name));
safestrncpy(wnd->exname, newname, ARRAYLENGTH(wnd->exname));
wnd->class_ = WARP_CLASS;
@@ -3320,8 +3343,8 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
struct event_data* ev = (struct event_data*)strdb_get(npc->ev_db, eventname);
struct npc_data *nd;
struct script_state *st;
- int i = 0, j = 0, k = 0;
- char *temp;
+ int i = 0, nargs = 0;
+ size_t len;
nullpo_ret(sd);
@@ -3349,27 +3372,29 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
st = script->alloc_state(ev->nd->u.scr.script, ev->pos, sd->bl.id, ev->nd->bl.id);
script->setd_sub(st, NULL, ".@atcmd_command$", 0, (void *)command, NULL);
- // split atcmd parameters based on spaces
- temp = (char*)aMalloc(strlen(message) + 1);
-
- for( i = 0; i < ( strlen( message ) + 1 ) && k < 127; i ++ ) {
- if( message[i] == ' ' || message[i] == '\0' ) {
- if( message[ ( i - 1 ) ] == ' ' ) {
- continue; // To prevent "@atcmd [space][space]" and .@atcmd_numparameters return 1 without any parameter.
- }
- temp[k] = '\0';
- k = 0;
- if( temp[0] != '\0' ) {
- script->setd_sub( st, NULL, ".@atcmd_parameters$", j++, (void *)temp, NULL );
+ len = strlen(message);
+ if (len) {
+ char *temp, *p;
+ p = temp = aStrdup(message);
+ // Sanity check - Skip leading spaces (shouldn't happen)
+ while (i <= len && temp[i] == ' ') {
+ p++;
+ i++;
+ }
+ // split atcmd parameters based on spaces
+ while (i <= len) {
+ if (temp[i] != ' ' && temp[i] != '\0') {
+ i++;
+ continue;
}
- } else {
- temp[k] = message[i];
- k++;
+ temp[i] = '\0';
+ script->setd_sub(st, NULL, ".@atcmd_parameters$", nargs++, (void *)p, NULL);
+ i++;
+ p = temp + i;
}
+ aFree(temp);
}
-
- script->setd_sub(st, NULL, ".@atcmd_numparameters", 0, (void *)h64BPTRSIZE(j), NULL);
- aFree(temp);
+ script->setd_sub(st, NULL, ".@atcmd_numparameters", 0, (void *)h64BPTRSIZE(nargs), NULL);
script->run_main(st);
return 0;
@@ -3447,7 +3472,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st
// w4=<mob id>,<amount>,<delay1>,<delay2>,<event>{,<mob size>,<mob ai>}
if( sscanf(w1, "%31[^,],%d,%d,%d,%d", mapname, &x, &y, &xs, &ys) < 3
|| sscanf(w3, "%23[^,],%d", mobname, &mob_lv) < 1
- || sscanf(w4, "%d,%d,%u,%u,%127[^,],%d,%d[^\t\r\n]", &class_, &num, &mobspawn.delay1, &mobspawn.delay2, mobspawn.eventname, &size, &ai) < 2
+ || sscanf(w4, "%d,%d,%u,%u,%50[^,],%d,%d[^\t\r\n]", &class_, &num, &mobspawn.delay1, &mobspawn.delay2, mobspawn.eventname, &size, &ai) < 2
) {
ShowError("npc_parse_mob: Invalid mob definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
if (retval) *retval = EXIT_FAILURE;
@@ -3597,9 +3622,17 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st
return strchr(start,'\n');// continue
}
+
+void npc_parse_unknown_mapflag(const char *name, char *w3, char *w4, const char* start, const char* buffer, const char* filepath, int *retval)
+{
+ ShowError("npc_parse_mapflag: unrecognized mapflag '%s' in file '%s', line '%d'.\n", w3, filepath, strline(buffer,start-buffer));
+ if (retval)
+ *retval = EXIT_FAILURE;
+}
+
/*==========================================
* Set or disable mapflag on map
- * eg : bat_c01 mapflag battleground 2
+ * eg : bat_c01<TAB>mapflag<TAB>battleground<TAB>2
* also chking if mapflag conflict with another
*------------------------------------------*/
const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, int *retval) {
@@ -3623,7 +3656,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
}
if (w4 && !strcmpi(w4, "off"))
- state = 0; //Disable mapflag rather than enable it. [Skotlex]
+ state = 0; //Disable mapflag rather than enable it. [Skotlex]
if (!strcmpi(w3, "nosave")) {
char savemap[32];
@@ -3689,7 +3722,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
if( state && (zone = strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)) && map->list[m].zone != zone ) {
map->zone_change(m,zone,start,buffer,filepath);
} else if ( !state ) {
- map->list[m].zone = &map->zone_pk;
+ map->list[m].zone = &map->zone_all;
}
}
else if (!strcmpi(w3,"pvp_noparty"))
@@ -4004,13 +4037,20 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
} else if ( !strcmpi(w3,"nocashshop") ) {
map->list[m].flag.nocashshop = (state) ? 1 : 0;
} else {
- ShowError("npc_parse_mapflag: unrecognized mapflag '%s' in file '%s', line '%d'.\n", w3, filepath, strline(buffer,start-buffer));
- if (retval) *retval = EXIT_FAILURE;
+ npc->parse_unknown_mapflag(mapname, w3, w4, start, buffer, filepath, retval);
}
return strchr(start,'\n');// continue
}
+const char* npc_parse_unknown_object(char *w1, char *w2, char *w3, char *w4, const char* start, const char* buffer, const char* filepath, int *retval)
+{
+ ShowError("npc_parsesrcfile: Unable to parse, probably a missing or extra TAB in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
+ start = strchr(start,'\n');// skip and continue
+ *retval = EXIT_FAILURE;
+ return start;
+}
+
/**
* Parses a script file and creates NPCs/functions/mapflags/monsters/etc
* accordingly.
@@ -4175,9 +4215,6 @@ int npc_parsesrcfile(const char* filepath, bool runOnInit) {
if( strcmp(w1,"function") == 0 ) {
p = npc->parse_function(w1, w2, w3, w4, p, buffer, filepath, &success);
} else {
-#ifdef ENABLE_CASE_CHECK
- if( strcasecmp(w1, "function") == 0 ) DeprecationWarning("npc_parsesrcfile", w1, "function", filepath, strline(buffer, p-buffer)); // TODO
-#endif // ENABLE_CASE_CHECK
p = npc->parse_script(w1,w2,w3,w4, p, buffer, filepath,runOnInit?NPO_ONINIT:NPO_NONE, &success);
}
}
@@ -4202,25 +4239,7 @@ int npc_parsesrcfile(const char* filepath, bool runOnInit) {
}
else
{
-#ifdef ENABLE_CASE_CHECK
- if( strcasecmp(w2, "warp") == 0 ) { DeprecationWarning("npc_parsesrcfile", w2, "warp", filepath, strline(buffer, p-buffer)); } // TODO
- else if( strcasecmp(w2,"shop") == 0 ) { DeprecationWarning("npc_parsesrcfile", w2, "shop", filepath, strline(buffer, p-buffer)); } // TODO
- else if( strcasecmp(w2,"cashshop") == 0 ) { DeprecationWarning("npc_parsesrcfile", w2, "cashshop", filepath, strline(buffer, p-buffer)); } // TODO
- else if( strcasecmp(w2, "script") == 0 ) { DeprecationWarning("npc_parsesrcfile", w2, "script", filepath, strline(buffer, p-buffer)); } // TODO
- else if( strcasecmp(w2,"trader") == 0 ) DeprecationWarning("npc_parsesrcfile", w2, "trader", filepath, strline(buffer, p-buffer)) // TODO
- else if( strncasecmp(w2, "duplicate", 9) == 0 ) {
- char temp[10];
- safestrncpy(temp, w2, 10);
- DeprecationWarning("npc_parsesrcfile", temp, "duplicate", filepath, strline(buffer, p-buffer)); // TODO
- }
- else if( strcasecmp(w2,"monster") == 0 ) { DeprecationWarning("npc_parsesrcfile", w2, "monster", filepath, strline(buffer, p-buffer)); } // TODO:
- else if( strcasecmp(w2,"boss_monster") == 0 ) { DeprecationWarning("npc_parsesrcfile", w2, "boss_monster", filepath, strline(buffer, p-buffer)); } // TODO
- else if( strcasecmp(w2, "mapflag") == 0 ) { DeprecationWarning("npc_parsesrcfile", w2, "mapflag", filepath, strline(buffer, p-buffer)); } // TODO
- else
-#endif // ENABLE_CASE_CHECK
- ShowError("npc_parsesrcfile: Unable to parse, probably a missing or extra TAB in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,p-buffer), w1, w2, w3, w4);
- p = strchr(p,'\n');// skip and continue
- success = EXIT_FAILURE;
+ p = npc->parse_unknown_object(w1, w2, w3, w4, p, buffer, filepath, &success);
}
}
aFree(buffer);
@@ -4289,7 +4308,7 @@ void npc_read_event_script(void)
script_event[i].event_count++;
#ifdef ENABLE_CASE_CHECK
} else if( p && strcasecmp(name, p) == 0 ) {
- DeprecationWarning2("npc_read_event_script", p, name, config[i].event_name); // TODO
+ DeprecationCaseWarning("npc_read_event_script", p, name, config[i].event_name); // TODO
#endif // ENABLE_CASE_CHECK
}
}
@@ -4623,6 +4642,7 @@ void npc_defaults(void) {
npc->isnear = npc_isnear;
npc->ontouch_event = npc_ontouch_event;
npc->ontouch2_event = npc_ontouch2_event;
+ npc->onuntouch_event = npc_onuntouch_event;
npc->enable_sub = npc_enable_sub;
npc->enable = npc_enable;
npc->name2id = npc_name2id;
@@ -4647,6 +4667,7 @@ void npc_defaults(void) {
npc->touch_areanpc_sub = npc_touch_areanpc_sub;
npc->touchnext_areanpc = npc_touchnext_areanpc;
npc->touch_areanpc = npc_touch_areanpc;
+ npc->untouch_areanpc = npc_untouch_areanpc;
npc->touch_areanpc2 = npc_touch_areanpc2;
npc->check_areanpc = npc_check_areanpc;
npc->checknear = npc_checknear;
@@ -4673,6 +4694,7 @@ void npc_defaults(void) {
npc->parsename = npc_parsename;
npc->parseview = npc_parseview;
npc->viewisid = npc_viewisid;
+ npc->create_npc = npc_create_npc;
npc->add_warp = npc_add_warp;
npc->parse_warp = npc_parse_warp;
npc->parse_shop = npc_parse_shop;
@@ -4692,7 +4714,9 @@ void npc_defaults(void) {
npc->parse_mob2 = npc_parse_mob2;
npc->parse_mob = npc_parse_mob;
npc->parse_mapflag = npc_parse_mapflag;
+ npc->parse_unknown_mapflag = npc_parse_unknown_mapflag;
npc->parsesrcfile = npc_parsesrcfile;
+ npc->parse_unknown_object = npc_parse_unknown_object;
npc->script_event = npc_script_event;
npc->read_event_script = npc_read_event_script;
npc->path_db_clear_sub = npc_path_db_clear_sub;
diff --git a/src/map/npc.h b/src/map/npc.h
index 4c904e1ac..a5a2b4676 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -61,7 +61,8 @@ struct npc_data {
int touching_id;
int64 next_walktime;
uint8 dir;
-
+ uint8 area_size;
+
unsigned size : 2;
struct status_data status;
@@ -181,6 +182,7 @@ struct npc_interface {
bool (*isnear) (struct block_list *bl);
int (*ontouch_event) (struct map_session_data *sd, struct npc_data *nd);
int (*ontouch2_event) (struct map_session_data *sd, struct npc_data *nd);
+ int (*onuntouch_event) (struct map_session_data *sd, struct npc_data *nd);
int (*enable_sub) (struct block_list *bl, va_list ap);
int (*enable) (const char *name, int flag);
struct npc_data* (*name2id) (const char *name);
@@ -205,6 +207,7 @@ struct npc_interface {
int (*touch_areanpc_sub) (struct block_list *bl, va_list ap);
int (*touchnext_areanpc) (struct map_session_data *sd, bool leavemap);
int (*touch_areanpc) (struct map_session_data *sd, int16 m, int16 x, int16 y);
+ int (*untouch_areanpc) (struct map_session_data *sd, int16 m, int16 x, int16 y);
int (*touch_areanpc2) (struct mob_data *md);
int (*check_areanpc) (int flag, int16 m, int16 x, int16 y, int16 range);
struct npc_data* (*checknear) (struct map_session_data *sd, struct block_list *bl);
@@ -231,9 +234,11 @@ struct npc_interface {
void (*parsename) (struct npc_data *nd, const char *name, const char *start, const char *buffer, const char *filepath);
int (*parseview) (const char *w4, const char *start, const char *buffer, const char *filepath);
bool (*viewisid) (const char *viewid);
+ struct npc_data* (*create_npc) (int m, int x, int y);
struct npc_data* (*add_warp) (char *name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y);
const char* (*parse_warp) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval);
const char* (*parse_shop) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval);
+ const char* (*parse_unknown_object) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval);
void (*convertlabel_db) (struct npc_label_list *label_list, const char *filepath);
const char* (*skip_script) (const char *start, const char *buffer, const char *filepath, int *retval);
const char* (*parse_script) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int options, int *retval);
@@ -250,6 +255,7 @@ struct npc_interface {
void (*parse_mob2) (struct spawn_data *mobspawn);
const char* (*parse_mob) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval);
const char* (*parse_mapflag) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval);
+ void (*parse_unknown_mapflag) (const char *name, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval);
int (*parsesrcfile) (const char *filepath, bool runOnInit);
int (*script_event) (struct map_session_data *sd, enum npce_event type);
void (*read_event_script) (void);
diff --git a/src/map/packets.h b/src/map/packets.h
index 810f341d4..bb5222e93 100644
--- a/src/map/packets.h
+++ b/src/map/packets.h
@@ -1654,128 +1654,128 @@ packet(0x020d,-1);
packet(0x0802,18,clif->pPartyBookingRegisterReq,2,4,6); // Booking System
packet(0x0803,4);
packet(0x0804,8); // Booking System
- packet(0x0805,-1);
- packet(0x0806,4,clif->pPartyBookingDeleteReq,2);// Booking System
- //packet(0x0807,2);
- packet(0x0808,4); // Booking System
- //packet(0x0809,14);
- //packet(0x080A,50);
- //packet(0x080B,18);
- //packet(0x080C,6);
-#endif
-
- //2009-12-29aRagexeRE
+ packet(0x0805,-1);
+ packet(0x0806,4,clif->pPartyBookingDeleteReq,2);// Booking System
+ //packet(0x0807,2);
+ packet(0x0808,4); // Booking System
+ //packet(0x0809,14);
+ //packet(0x080A,50);
+ //packet(0x080B,18);
+ //packet(0x080C,6);
+#endif
+
+ //2009-12-29aRagexeRE
#if PACKETVER >= 20091229
- packet(0x0804,14,clif->pPartyBookingSearchReq,2,4,6,8,12);// Booking System
- packet(0x0806,2,clif->pPartyBookingDeleteReq,0);// Booking System
- packet(0x0807,4);
- packet(0x0808,14,clif->pPartyBookingUpdateReq,2); // Booking System
- packet(0x0809,50);
- packet(0x080A,18);
- packet(0x080B,6);// Booking System
-#endif
-
- //2010-01-05aRagexeRE
+ packet(0x0804,14,clif->pPartyBookingSearchReq,2,4,6,8,12);// Booking System
+ packet(0x0806,2,clif->pPartyBookingDeleteReq,0);// Booking System
+ packet(0x0807,4);
+ packet(0x0808,14,clif->pPartyBookingUpdateReq,2); // Booking System
+ packet(0x0809,50);
+ packet(0x080A,18);
+ packet(0x080B,6);// Booking System
+#endif
+
+ //2010-01-05aRagexeRE
#if PACKETVER >= 20100105
- packet(0x0801,-1,clif->pPurchaseReq2,2,4,8,12);
+ packet(0x0801,-1,clif->pPurchaseReq2,2,4,8,12);
#endif
-
- //2010-01-26aRagexeRE
+
+ //2010-01-26aRagexeRE
#if PACKETVER >= 20100126
- //packet(0x080C,2);
- //packet(0x080D,3);
- packet(0x080E,14);
+ //packet(0x080C,2);
+ //packet(0x080D,3);
+ packet(0x080E,14);
#endif
-
- //2010-02-09aRagexeRE
+
+ //2010-02-09aRagexeRE
#if PACKETVER >= 20100209
- //packet(0x07F0,6);
+ //packet(0x07F0,6);
#endif
-
- //2010-02-23aRagexeRE
+
+ //2010-02-23aRagexeRE
#if PACKETVER >= 20100223
- packet(0x080F,20);
+ packet(0x080F,20);
#endif
-
- //2010-03-03aRagexeRE
+
+ //2010-03-03aRagexeRE
#if PACKETVER >= 20100303
- packet(0x0810,3);
- packet(0x0811,-1,clif->pReqOpenBuyingStore,2,4,8,9,89);
- //packet(0x0812,86);
- //packet(0x0813,6);
- //packet(0x0814,6);
- //packet(0x0815,-1);
- //packet(0x0817,-1);
- //packet(0x0818,6);
- //packet(0x0819,4);
-#endif
-
- //2010-03-09aRagexeRE
+ packet(0x0810,3);
+ packet(0x0811,-1,clif->pReqOpenBuyingStore,2,4,8,9,89);
+ //packet(0x0812,86);
+ //packet(0x0813,6);
+ //packet(0x0814,6);
+ //packet(0x0815,-1);
+ //packet(0x0817,-1);
+ //packet(0x0818,6);
+ //packet(0x0819,4);
+#endif
+
+ //2010-03-09aRagexeRE
#if PACKETVER >= 20100309
- packet(0x0813,-1);
- //packet(0x0814,2);
- //packet(0x0815,6);
- packet(0x0816,6);
- packet(0x0818,-1);
- //packet(0x0819,10);
- //packet(0x081A,4);
- //packet(0x081B,4);
- //packet(0x081C,6);
- packet(0x081d,22);
- packet(0x081e,8);
-#endif
-
- //2010-03-23aRagexeRE
+ packet(0x0813,-1);
+ //packet(0x0814,2);
+ //packet(0x0815,6);
+ packet(0x0816,6);
+ packet(0x0818,-1);
+ //packet(0x0819,10);
+ //packet(0x081A,4);
+ //packet(0x081B,4);
+ //packet(0x081C,6);
+ packet(0x081d,22);
+ packet(0x081e,8);
+#endif
+
+ //2010-03-23aRagexeRE
#if PACKETVER >= 20100323
- //packet(0x081F,-1);
+ //packet(0x081F,-1);
#endif
-
- //2010-04-06aRagexeRE
+
+ //2010-04-06aRagexeRE
#if PACKETVER >= 20100406
- //packet(0x081A,6);
+ //packet(0x081A,6);
#endif
-
- //2010-04-13aRagexeRE
+
+ //2010-04-13aRagexeRE
#if PACKETVER >= 20100413
- //packet(0x081A,10);
- packet(0x0820,11);
- //packet(0x0821,2);
- //packet(0x0822,9);
- //packet(0x0823,-1);
-#endif
-
- //2010-04-14dRagexeRE
+ //packet(0x081A,10);
+ packet(0x0820,11);
+ //packet(0x0821,2);
+ //packet(0x0822,9);
+ //packet(0x0823,-1);
+#endif
+
+ //2010-04-14dRagexeRE
#if PACKETVER >= 20100414
- //packet(0x081B,8);
+ //packet(0x081B,8);
#endif
-
- //2010-04-20aRagexeRE
+
+ //2010-04-20aRagexeRE
#if PACKETVER >= 20100420
- packet(0x0812,8);
- packet(0x0814,86);
- packet(0x0815,2,clif->pReqCloseBuyingStore,0);
- packet(0x0817,6,clif->pReqClickBuyingStore,2);
- packet(0x0819,-1,clif->pReqTradeBuyingStore,2,4,8,12);
- packet(0x081a,4);
- packet(0x081b,10);
- packet(0x081c,10);
- packet(0x0824,6);
-#endif
-
- //2010-06-01aRagexeRE
+ packet(0x0812,8);
+ packet(0x0814,86);
+ packet(0x0815,2,clif->pReqCloseBuyingStore,0);
+ packet(0x0817,6,clif->pReqClickBuyingStore,2);
+ packet(0x0819,-1,clif->pReqTradeBuyingStore,2,4,8,12);
+ packet(0x081a,4);
+ packet(0x081b,10);
+ packet(0x081c,10);
+ packet(0x0824,6);
+#endif
+
+ //2010-06-01aRagexeRE
#if PACKETVER >= 20100601
- //packet(0x0825,-1);
- //packet(0x0826,4);
- packet(0x0835,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15);
- packet(0x0836,-1);
- packet(0x0837,3);
- //packet(0x0838,3);
-#endif
-
- //2010-06-08aRagexeRE
+ //packet(0x0825,-1);
+ //packet(0x0826,4);
+ packet(0x0835,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15);
+ packet(0x0836,-1);
+ packet(0x0837,3);
+ //packet(0x0838,3);
+#endif
+
+ //2010-06-08aRagexeRE
#if PACKETVER >= 20100608
- packet(0x0838,2,clif->pSearchStoreInfoNextPage,0);
- packet(0x083A,4); // Search Stalls Feature
+ packet(0x0838,2,clif->pSearchStoreInfoNextPage,0);
+ packet(0x083A,4); // Search Stalls Feature
packet(0x083B,2,clif->pCloseSearchStoreInfo,0);
packet(0x083C,12,clif->pSearchStoreInfoListItemClick,2,6,10);
packet(0x083D,6);
@@ -2415,7 +2415,7 @@ packet(0x020d,-1);
packet(0x0873,36,clif->pStoragePassword,0);
packet(0x097C,4,clif->pRanklist);
#endif
-
+
//2013-08-07Ragexe (Shakto)
#if PACKETVER >= 20130807
packet(0x0369,7,clif->pActionRequest,2,6);
@@ -2700,7 +2700,7 @@ packet(0x020d,-1);
#endif
// 2014-04-02gRagexe - Themon
-#if PACKETVER >= 20140402
+#if PACKETVER >= 20140402
packet(0x0946,7,clif->pActionRequest,2,6);
packet(0x0868,10,clif->pUseSkillToId,2,4,6);
packet(0x093F,5,clif->pWalkToXY,2);
@@ -2734,7 +2734,7 @@ packet(0x020d,-1);
#endif
// 2014-04-16aRagexe - Themon
-#if PACKETVER >= 20140416
+#if PACKETVER >= 20140416
packet(0x0369,7,clif->pActionRequest,2,6);
packet(0x083C,10,clif->pUseSkillToId,2,4,6);
packet(0x0437,5,clif->pWalkToXY,2);
@@ -2767,6 +2767,121 @@ packet(0x020d,-1);
packet(0x09DF,7);
#endif
+// 2014-10-22bRagexe - YomRawr
+#if PACKETVER >= 20141022
+ packet(0x0369,7,clif->pActionRequest,2,6);
+ packet(0x083C,10,clif->pUseSkillToId,2,4,6);
+ packet(0x0437,5,clif->pWalkToXY,2);
+ packet(0x035F,6,clif->pTickSend,2);
+ packet(0x08AD,5,clif->pChangeDir,2,4);
+ packet(0x094E,6,clif->pTakeItem,2);
+ packet(0x087D,6,clif->pDropItem,2,4);
+ packet(0x0878,8,clif->pMoveToKafra,2,4);
+ packet(0x08AA,8,clif->pMoveFromKafra,2,4);
+ packet(0x023B,10,clif->pUseSkillToPos,2,4,6,8);
+ packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10);
+ packet(0x096A,6,clif->pGetCharNameRequest,2);
+ packet(0x0368,6,clif->pSolveCharName,2);
+ packet(0x0835,12,clif->pSearchStoreInfoListItemClick,2,6,10);
+ packet(0x0940,2,clif->pSearchStoreInfoNextPage,0);
+ packet(0x0819,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15);
+ packet(0x0811,-1,clif->pReqTradeBuyingStore,2,4,8,12);
+ packet(0x0360,6,clif->pReqClickBuyingStore,2);
+ packet(0x0817,2,clif->pReqCloseBuyingStore,0);
+ packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89);
+ packet(0x0955,18,clif->pPartyBookingRegisterReq,2,4);
+ // packet(0x092B,8); // CZ_JOIN_BATTLE_FIELD
+ packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8);
+ packet(0x093B,19,clif->pWantToConnection,2,6,10,14,18);
+ packet(0x0896,26,clif->pPartyInvite2,2);
+ // packet(0x08AB,4); // CZ_GANGSI_RANK
+ packet(0x091A,26,clif->pFriendsListAdd,2);
+ packet(0x0899,5,clif->pHomMenu,2,4);
+ packet(0x0438,36,clif->pStoragePassword,0);
+#endif
+
+// 2014-10-16aRagexe - YomRawr
+#if PACKETVER >= 20141016
+ packet(0x0369,7,clif->pActionRequest,2,6);
+ packet(0x083C,10,clif->pUseSkillToId,2,4,6);
+ packet(0x0437,5,clif->pWalkToXY,2);
+ packet(0x035F,6,clif->pTickSend,2);
+ packet(0x0967,5,clif->pChangeDir,2,4);
+ packet(0x07E4,6,clif->pTakeItem,2);
+ packet(0x0362,6,clif->pDropItem,2,4);
+ packet(0x07EC,8,clif->pMoveToKafra,2,4);
+ packet(0x022D,8,clif->pMoveFromKafra,2,4);
+ packet(0x0438,10,clif->pUseSkillToPos,2,4,6,8);
+ packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10);
+ packet(0x096A,6,clif->pGetCharNameRequest,2);
+ packet(0x0368,6,clif->pSolveCharName,2);
+ packet(0x0838,12,clif->pSearchStoreInfoListItemClick,2,6,10);
+ packet(0x0835,2,clif->pSearchStoreInfoNextPage,0);
+ packet(0x0819,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15);
+ packet(0x0811,-1,clif->pReqTradeBuyingStore,2,4,8,12);
+ packet(0x0360,6,clif->pReqClickBuyingStore,2);
+ packet(0x0817,2,clif->pReqCloseBuyingStore,0);
+ packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89);
+ packet(0x0365,18,clif->pPartyBookingRegisterReq,2,4);
+ // packet(0x0363,8); // CZ_JOIN_BATTLE_FIELD
+ packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8);
+ packet(0x086E,19,clif->pWantToConnection,2,6,10,14,18);
+ packet(0x0802,26,clif->pPartyInvite2,2);
+ // packet(0x0922,4); // CZ_GANGSI_RANK
+ packet(0x094B,26,clif->pFriendsListAdd,2);
+ packet(0x0364,5,clif->pHomMenu,2,4);
+ packet(0x0936,36,clif->pStoragePassword,0);
+ packet(0x09DF,7);
+ packet(0x0a00,269);
+#endif
+
+// 2014-10-22bRagexe - YomRawr
+#if PACKETVER >= 20141022
+ packet(0x0369,7,clif->pActionRequest,2,6);
+ packet(0x083C,10,clif->pUseSkillToId,2,4,6);
+ packet(0x0437,5,clif->pWalkToXY,2);
+ packet(0x035F,6,clif->pTickSend,2);
+ packet(0x08AD,5,clif->pChangeDir,2,4);
+ packet(0x094E,6,clif->pTakeItem,2);
+ packet(0x087D,6,clif->pDropItem,2,4);
+ packet(0x0878,8,clif->pMoveToKafra,2,4);
+ packet(0x08AA,8,clif->pMoveFromKafra,2,4);
+ packet(0x023B,10,clif->pUseSkillToPos,2,4,6,8);
+ packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10);
+ packet(0x096A,6,clif->pGetCharNameRequest,2);
+ packet(0x0368,6,clif->pSolveCharName,2);
+ packet(0x0835,12,clif->pSearchStoreInfoListItemClick,2,6,10);
+ packet(0x0940,2,clif->pSearchStoreInfoNextPage,0);
+ packet(0x0819,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15);
+ packet(0x0811,-1,clif->pReqTradeBuyingStore,2,4,8,12);
+ packet(0x0360,6,clif->pReqClickBuyingStore,2);
+ packet(0x0817,2,clif->pReqCloseBuyingStore,0);
+ packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89);
+ packet(0x0955,18,clif->pPartyBookingRegisterReq,2,4);
+ // packet(0x092B,8); // CZ_JOIN_BATTLE_FIELD
+ packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8);
+ packet(0x093B,19,clif->pWantToConnection,2,6,10,14,18);
+ packet(0x0896,26,clif->pPartyInvite2,2);
+ // packet(0x08AB,4); // CZ_GANGSI_RANK
+ packet(0x091A,26,clif->pFriendsListAdd,2);
+ packet(0x0899,5,clif->pHomMenu,2,4);
+ packet(0x0438,36,clif->pStoragePassword,0);
+#endif
+
+/* Roulette System [Yommy/Hercules] */
+#if PACKETVER >= 20141016
+ packet(0x0A19,2,clif->pRouletteOpen,0); // HEADER_CZ_REQ_OPEN_ROULETTE
+ packet(0x0A1A,23); // HEADER_ZC_ACK_OPEN_ROULETTE
+ packet(0x0A1B,2,clif->pRouletteInfo,0); // HEADER_CZ_REQ_ROULETTE_INFO
+ packet(0x0A1C,-1); // HEADER_ZC_ACK_ROULEITTE_INFO
+ packet(0x0A1D,2,clif->pRouletteClose,0); // HEADER_CZ_REQ_CLOSE_ROULETTE
+ packet(0x0A1E,3); // HEADER_ZC_ACK_CLOSE_ROULETTE
+ packet(0x0A1F,2,clif->pRouletteGenerate,0); // HEADER_CZ_REQ_GENERATE_ROULETTE
+ packet(0x0A20,21); // HEADER_ZC_ACK_GENERATE_ROULETTE
+ packet(0x0A21,3,clif->pRouletteRecvItem,2); // HEADER_CZ_RECV_ROULETTE_ITEM
+ packet(0x0A22,5); // HEADER_ZC_RECV_ROULETTE_ITEM
+#endif
+
/* PacketKeys: http://hercules.ws/board/topic/1105-hercules-wpe-free-june-14th-patch/ */
#if PACKETVER >= 20110817
packetKeys(0x053D5CED,0x3DED6DED,0x6DED6DED); /* Thanks to Shakto */
@@ -2998,6 +3113,18 @@ packet(0x020d,-1);
packetKeys(0x04810281,0x42814281,0x42814281); /* Themon */
#endif
+#if PACKETVER >= 20141022
+ packetKeys(0x290551EA,0x2B952C75,0x2D67669B); /* YomRawr */
+#endif
+
+#if PACKETVER >= 20141016
+ packetKeys(0x2DFF467C,0x444B37EE,0x2C1B634F); /* YomRawr */
+#endif
+
+#if PACKETVER >= 20141022
+ packetKeys(0x290551EA,0x2B952C75,0x2D67669B); /* YomRawr */
+#endif
+
#if defined(OBFUSCATIONKEY1) && defined(OBFUSCATIONKEY2) && defined(OBFUSCATIONKEY3)
packetKeys(OBFUSCATIONKEY1,OBFUSCATIONKEY2,OBFUSCATIONKEY3);
#endif
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index b32baf53a..71471e5c6 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -77,8 +77,10 @@ enum packet_headers {
#endif
#if PACKETVER < 20080102
authokType = 0x73,
-#else
+#elif PACKETVER < 20141022
authokType = 0x2eb,
+#else
+ authokType = 0xa18,
#endif
script_clearType = 0x8d6,
package_item_announceType = 0x7fd,
@@ -209,6 +211,10 @@ enum packet_headers {
#else
wisendType = 0x98,
#endif
+ partyleaderchangedType = 0x7fc,
+ rouletteinfoackType = 0xa1c,
+ roulettgenerateackType = 0xA20,
+ roulettercvitemackType = 0xA22,
};
#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
@@ -273,10 +279,10 @@ struct EQUIPITEM_INFO {
int HireExpireDate;
#endif
#if PACKETVER >= 20080102
- unsigned short bindOnEquipType;
+ unsigned short bindOnEquipType;
#endif
#if PACKETVER >= 20100629
- unsigned short wItemSpriteNumber;
+ unsigned short wItemSpriteNumber;
#endif
#if PACKETVER >= 20120925
struct {
@@ -297,6 +303,9 @@ struct packet_authok {
#if PACKETVER >= 20080102
short font;
#endif
+#if PACKETVER >= 20141022
+ unsigned char sex;
+#endif
} __attribute__((packed));
struct packet_monster_hp {
@@ -663,7 +672,7 @@ struct packet_bgqueue_register {
struct packet_bgqueue_update_info {
short PacketType;
char bg_name[NAME_LENGTH];
- int position;
+ int position;
} __attribute__((packed));
struct packet_bgqueue_checkstate {
@@ -761,6 +770,58 @@ struct packet_banking_withdraw_ack {
int Balance;
} __attribute__((packed));
+/* Roulette System [Yommy/Hercules] */
+struct packet_roulette_open_ack {
+ short PacketType;
+ char Result;
+ int Serial;
+ char Step;
+ char Idx;
+ short AdditionItemID;
+ int GoldPoint;
+ int SilverPoint;
+ int BronzePoint;
+} __attribute__((packed));
+
+struct packet_roulette_info_ack {
+ short PacketType;
+ short PacketLength;
+ unsigned int RouletteSerial;
+ struct {
+ unsigned short Row;
+ unsigned short Position;
+ unsigned short ItemId;
+ unsigned short Count;
+ } ItemInfo[42];
+} __attribute__((packed));
+
+struct packet_roulette_close_ack {
+ short PacketType;
+ unsigned char Result;
+} __attribute__((packed));
+
+struct packet_roulette_generate_ack {
+ short PacketType;
+ unsigned char Result;
+ unsigned short Step;
+ unsigned short Idx;
+ unsigned short AdditionItemID;
+ int RemainGold;
+ int RemainSilver;
+ int RemainBronze;
+} __attribute__((packed));
+
+struct packet_roulette_itemrecv_req {
+ short PacketType;
+ unsigned char Condition;
+} __attribute__((packed));
+
+struct packet_roulette_itemrecv_ack {
+ short PacketType;
+ unsigned char Result;
+ unsigned short AdditionItemID;
+} __attribute__((packed));
+
struct packet_itemlist_normal {
short PacketType;
short PacketLength;
@@ -959,6 +1020,13 @@ struct packet_wis_end {
} __attribute__((packed));
+struct packet_party_leader_changed {
+ short PacketType;
+ unsigned int prev_leader_aid;
+ unsigned int new_leader_aid;
+} __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/party.c b/src/map/party.c
index 7cf340edb..668251b5d 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -11,7 +11,7 @@
#include <stdlib.h>
#include <string.h>
-#include "atcommand.h" //msg_txt()
+#include "atcommand.h" //msg_txt()
#include "battle.h"
#include "clif.h"
#include "instance.h"
@@ -41,7 +41,7 @@ struct party_interface party_s;
* Used when creating/adding people to a party. [Skotlex]
*------------------------------------------*/
void party_fill_member(struct party_member* member, struct map_session_data* sd, unsigned int leader) {
- member->account_id = sd->status.account_id;
+ member->account_id = sd->status.account_id;
member->char_id = sd->status.char_id;
safestrncpy(member->name, sd->status.name, NAME_LENGTH);
member->class_ = sd->status.class_;
@@ -87,8 +87,8 @@ TBL_PC* party_sd_check(int party_id, int account_id, int char_id) {
if( sd->status.party_id == 0 )
sd->status.party_id = party_id;// auto-join if not in a party
- if (sd->status.party_id != party_id)
- { //If player belongs to a different party, kick him out.
+ if (sd->status.party_id != party_id) {
+ //If player belongs to a different party, kick him out.
intif->party_leave(party_id,account_id,char_id);
return NULL;
}
@@ -674,8 +674,8 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts
if (mi == MAX_PARTY)
return false; //Shouldn't happen
- if (!p->party.member[mi].leader)
- { //Need to be a party leader.
+ if (!p->party.member[mi].leader) {
+ //Need to be a party leader.
clif->message(sd->fd, msg_txt(282));
return false;
}
@@ -686,12 +686,10 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts
//Change leadership.
p->party.member[mi].leader = 0;
- if (p->data[mi].sd->fd)
- clif->message(p->data[mi].sd->fd, msg_txt(284));
-
p->party.member[tmi].leader = 1;
- if (p->data[tmi].sd->fd)
- clif->message(p->data[tmi].sd->fd, msg_txt(285));
+
+ /** update members **/
+ clif->PartyLeaderChanged(p->data[mi].sd, p->data[mi].sd->status.account_id, p->data[tmi].sd->status.account_id);
//Update info.
intif->party_leaderchange(p->party.party_id,p->party.member[tmi].account_id,p->party.member[tmi].char_id);
@@ -981,14 +979,14 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i
if (p && p->party.item&2 && (first_charid || !(battle_config.party_share_type&1)))
{
//item distribution to party members.
- if (battle_config.party_share_type&2)
- { //Round Robin
+ if (battle_config.party_share_type&2) {
+ //Round Robin
TBL_PC* psd;
i = p->itemc;
do {
i++;
if (i >= MAX_PARTY)
- i = 0; // reset counter to 1st person in party so it'll stop when it reaches "itemc"
+ i = 0; // reset counter to 1st person in party so it'll stop when it reaches "itemc"
if( (psd = p->data[i].sd) == NULL || sd->bl.m != psd->bl.m || pc_isdead(psd) || (battle_config.idle_no_share && pc_isidle(psd)) )
continue;
@@ -1001,9 +999,8 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i
target = psd;
break;
} while (i != p->itemc);
- }
- else
- { //Random pick
+ } else {
+ //Random pick
TBL_PC* psd[MAX_PARTY];
int count = 0;
//Collect pick candidates
@@ -1015,11 +1012,12 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i
}
while (count > 0) { //Pick a random member.
i = rnd()%count;
- if (pc->additem(psd[i],item_data,item_data->amount,LOG_TYPE_PICKDROP_PLAYER))
- { //Discard this receiver.
+ if (pc->additem(psd[i],item_data,item_data->amount,LOG_TYPE_PICKDROP_PLAYER)) {
+ //Discard this receiver.
psd[i] = psd[count-1];
count--;
- } else { //Successful pick.
+ } else {
+ //Successful pick.
target = psd[i];
break;
}
@@ -1174,7 +1172,7 @@ void party_recruit_register(struct map_session_data *sd, short level, const char
memcpy(pb_ad->charname,sd->status.name,NAME_LENGTH);
pb_ad->expiretime = (int)time(NULL);
- pb_ad->p_detail.level = level;
+ pb_ad->p_detail.level = level;
safestrncpy(pb_ad->p_detail.notice, notice, PB_NOTICE_LENGTH);
clif->PartyRecruitRegisterAck(sd, 0);
@@ -1187,7 +1185,7 @@ void party_recruit_register(struct map_session_data *sd, short level, const char
void party_booking_register(struct map_session_data *sd, short level, short mapid, short* job) {
#ifndef PARTY_RECRUIT
struct party_booking_ad_info *pb_ad;
- int i;
+ int i;
pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id);
@@ -1204,7 +1202,7 @@ void party_booking_register(struct map_session_data *sd, short level, short mapi
memcpy(pb_ad->charname,sd->status.name,NAME_LENGTH);
pb_ad->expiretime = (int)time(NULL);
- pb_ad->p_detail.level = level;
+ pb_ad->p_detail.level = level;
pb_ad->p_detail.mapid = mapid;
for(i=0;i<PARTY_BOOKING_JOBS;i++)
diff --git a/src/map/party.h b/src/map/party.h
index d62db23a7..f6cd448a6 100644
--- a/src/map/party.h
+++ b/src/map/party.h
@@ -30,12 +30,12 @@ struct party_data {
short *instance;
unsigned short instances;
struct {
- unsigned monk : 1; //There's at least one monk in party?
- unsigned sg : 1; //There's at least one Star Gladiator in party?
- unsigned snovice :1; //There's a Super Novice
- unsigned tk : 1; //There's a taekwon
+ unsigned monk : 1; ///< There's at least one monk in party?
+ unsigned sg : 1; ///< There's at least one Star Gladiator in party?
+ unsigned snovice :1; ///< There's a Super Novice
+ unsigned tk : 1; ///< There's a taekwon
} state;
-
+
/* HPM Custom Struct */
struct HPluginData **hdata;
unsigned int hdatac;
@@ -46,8 +46,8 @@ struct party_data {
#ifndef PARTY_RECRUIT
struct party_booking_detail {
short level;
- short mapid;
- short job[PARTY_BOOKING_JOBS];
+ short mapid;
+ short job[PARTY_BOOKING_JOBS];
};
struct party_booking_ad_info {
@@ -87,7 +87,7 @@ struct party_interface {
struct party_data* (*searchname) (const char* str);
int (*getmemberid) (struct party_data* p, struct map_session_data* sd);
struct map_session_data* (*getavailablesd) (struct party_data *p);
-
+
int (*create) (struct map_session_data *sd,char *name, int item, int item2);
void (*created) (int account_id,int char_id,int fail,int party_id,char *name);
int (*request_info) (int party_id, int char_id);
diff --git a/src/map/path.c b/src/map/path.c
index 5a9ddf9c7..a7315da3c 100644
--- a/src/map/path.c
+++ b/src/map/path.c
@@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include "map.h"
#include "../common/cbasetypes.h"
@@ -52,7 +53,7 @@ BHEAP_STRUCT_DECL(node_heap, struct path_node*);
/// Estimates the cost from (x0,y0) to (x1,y1).
/// This is inadmissible (overestimating) heuristic used by game client.
-#define heuristic(x0, y0, x1, y1) (MOVE_COST * (abs((x1) - (x0)) + abs((y1) - (y0)))) // Manhattan distance
+#define heuristic(x0, y0, x1, y1) (MOVE_COST * (abs((x1) - (x0)) + abs((y1) - (y0)))) // Manhattan distance
/// @}
// Translates dx,dy into walking direction
@@ -128,9 +129,6 @@ bool path_search_long(struct shootpath_data *spd,int16 m,int16 x0,int16 y0,int16
spd->x[0] = x0;
spd->y[0] = y0;
- if (md->getcellp(md,x1,y1,cell))
- return false;
-
if (dx > abs(dy)) {
weight = dx;
spd->ry = 1;
@@ -141,8 +139,6 @@ bool path_search_long(struct shootpath_data *spd,int16 m,int16 x0,int16 y0,int16
while (x0 != x1 || y0 != y1)
{
- if (md->getcellp(md,x0,y0,cell))
- return false;
wx += dx;
wy += dy;
if (wx >= weight) {
@@ -162,6 +158,8 @@ bool path_search_long(struct shootpath_data *spd,int16 m,int16 x0,int16 y0,int16
spd->y[spd->len] = y0;
spd->len++;
}
+ if (md->getcellp(md,x0,y0,cell))
+ return false;
}
return true;
@@ -176,7 +174,7 @@ static void heap_push_node(struct node_heap *heap, struct path_node *node)
{
#ifndef __clang_analyzer__ // TODO: Figure out why clang's static analyzer doesn't like this
BHEAP_ENSURE(*heap, 1, 256);
- BHEAP_PUSH(*heap, node, NODE_MINTOPCMP, swap_ptr);
+ BHEAP_PUSH2(*heap, node, NODE_MINTOPCMP, swap_ptr);
#endif // __clang_analyzer__
}
@@ -189,8 +187,7 @@ static int heap_update_node(struct node_heap *heap, struct path_node *node)
ShowError("heap_update_node: node not found\n");
return 1;
}
- BHEAP_POPINDEX(*heap, i, NODE_MINTOPCMP, swap_ptr);
- BHEAP_PUSH(*heap, node, NODE_MINTOPCMP, swap_ptr);
+ BHEAP_UPDATE(*heap, i, NODE_MINTOPCMP, swap_ptr);
return 0;
}
@@ -251,12 +248,8 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x
return false;
md = &map->list[m];
-#ifdef CELL_NOSTACK
//Do not check starting cell as that would get you stuck.
- if (x0 < 0 || x0 >= md->xs || y0 < 0 || y0 >= md->ys)
-#else
if (x0 < 0 || x0 >= md->xs || y0 < 0 || y0 >= md->ys /*|| md->getcellp(md,x0,y0,cell)*/)
-#endif
return false;
// Check destination cell
@@ -304,7 +297,7 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x
// A* (A-star) pathfinding
// We always use A* for finding walkpaths because it is what game client uses.
// Easy pathfinding cuts corners of non-walkable cells, but client always walks around it.
-
+
BHEAP_STRUCT_VAR(node_heap, open_set); // 'Open' set
// FIXME: This array is too small to ensure all paths shorter than MAX_WALKPATH
@@ -327,8 +320,8 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x
tp[i].flag = SET_OPEN;
heap_push_node(&open_set, &tp[i]); // Put start node to 'open' set
- for(;;)
- {
+
+ for(;;) {
int e = 0; // error flag
// Saves allowed directions for the current cell. Diagonal directions
@@ -347,7 +340,7 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x
}
current = BHEAP_PEEK(open_set); // Look for the lowest f_cost node in the 'open' set
- BHEAP_POP(open_set, NODE_MINTOPCMP, swap_ptr); // Remove it from 'open' set
+ BHEAP_POP2(open_set, NODE_MINTOPCMP, swap_ptr); // Remove it from 'open' set
x = current->x;
y = current->y;
@@ -367,24 +360,22 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x
#define chk_dir(d) ((allowed_dirs & (d)) == (d))
// Process neighbors of current node
- // TODO: Processing order affects chosen path if there is more than one path with same cost.
- // In few cases path found by server will be different than path found by game client.
- if (chk_dir(DIR_SOUTH))
- e += add_path(&open_set, tp, x, y-1, g_cost + MOVE_COST, current, heuristic(x, y-1, x1, y1)); // (x, y-1) 4
- if (chk_dir(DIR_SOUTH|DIR_WEST) && !md->getcellp(md, x-1, y-1, cell))
- e += add_path(&open_set, tp, x-1, y-1, g_cost + MOVE_DIAGONAL_COST, current, heuristic(x-1, y-1, x1, y1)); // (x-1, y-1) 3
- if (chk_dir(DIR_WEST))
- e += add_path(&open_set, tp, x-1, y, g_cost + MOVE_COST, current, heuristic(x-1, y, x1, y1)); // (x-1, y) 2
- if (chk_dir(DIR_NORTH|DIR_WEST) && !md->getcellp(md, x-1, y+1, cell))
- e += add_path(&open_set, tp, x-1, y+1, g_cost + MOVE_DIAGONAL_COST, current, heuristic(x-1, y+1, x1, y1)); // (x-1, y+1) 1
- if (chk_dir(DIR_NORTH))
- e += add_path(&open_set, tp, x, y+1, g_cost + MOVE_COST, current, heuristic(x, y+1, x1, y1)); // (x, y+1) 0
- if (chk_dir(DIR_NORTH|DIR_EAST) && !md->getcellp(md, x+1, y+1, cell))
- e += add_path(&open_set, tp, x+1, y+1, g_cost + MOVE_DIAGONAL_COST, current, heuristic(x+1, y+1, x1, y1)); // (x+1, y+1) 7
- if (chk_dir(DIR_EAST))
- e += add_path(&open_set, tp, x+1, y, g_cost + MOVE_COST, current, heuristic(x+1, y, x1, y1)); // (x+1, y) 6
if (chk_dir(DIR_SOUTH|DIR_EAST) && !md->getcellp(md, x+1, y-1, cell))
e += add_path(&open_set, tp, x+1, y-1, g_cost + MOVE_DIAGONAL_COST, current, heuristic(x+1, y-1, x1, y1)); // (x+1, y-1) 5
+ if (chk_dir(DIR_EAST))
+ e += add_path(&open_set, tp, x+1, y, g_cost + MOVE_COST, current, heuristic(x+1, y, x1, y1)); // (x+1, y) 6
+ if (chk_dir(DIR_NORTH|DIR_EAST) && !md->getcellp(md, x+1, y+1, cell))
+ e += add_path(&open_set, tp, x+1, y+1, g_cost + MOVE_DIAGONAL_COST, current, heuristic(x+1, y+1, x1, y1)); // (x+1, y+1) 7
+ if (chk_dir(DIR_NORTH))
+ e += add_path(&open_set, tp, x, y+1, g_cost + MOVE_COST, current, heuristic(x, y+1, x1, y1)); // (x, y+1) 0
+ if (chk_dir(DIR_NORTH|DIR_WEST) && !md->getcellp(md, x-1, y+1, cell))
+ e += add_path(&open_set, tp, x-1, y+1, g_cost + MOVE_DIAGONAL_COST, current, heuristic(x-1, y+1, x1, y1)); // (x-1, y+1) 1
+ if (chk_dir(DIR_WEST))
+ e += add_path(&open_set, tp, x-1, y, g_cost + MOVE_COST, current, heuristic(x-1, y, x1, y1)); // (x-1, y) 2
+ if (chk_dir(DIR_SOUTH|DIR_WEST) && !md->getcellp(md, x-1, y-1, cell))
+ e += add_path(&open_set, tp, x-1, y-1, g_cost + MOVE_DIAGONAL_COST, current, heuristic(x-1, y-1, x1, y1)); // (x-1, y-1) 3
+ if (chk_dir(DIR_SOUTH))
+ e += add_path(&open_set, tp, x, y-1, g_cost + MOVE_COST, current, heuristic(x, y-1, x1, y1)); // (x, y-1) 4
#undef chk_dir
if (e) {
BHEAP_CLEAR(open_set);
@@ -413,7 +404,7 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x
//Distance functions, taken from http://www.flipcode.com/articles/article_fastdistance.shtml
-int check_distance(int dx, int dy, int distance)
+bool check_distance(int dx, int dy, int distance)
{
#ifdef CIRCULAR_AREA
//In this case, we just do a square comparison. Add 1 tile grace for diagonal range checks.
@@ -444,7 +435,7 @@ unsigned int distance(int dx, int dy)
min = dy;
max = dx;
}
- // coefficients equivalent to ( 123/128 * max ) and ( 51/128 * min )
+ // coefficients equivalent to ( 123/128 * max ) and ( 51/128 * min )
return ((( max << 8 ) + ( max << 3 ) - ( max << 4 ) - ( max << 1 ) +
( min << 7 ) - ( min << 5 ) + ( min << 3 ) - ( min << 1 )) >> 8 );
#else
@@ -453,6 +444,42 @@ unsigned int distance(int dx, int dy)
return (dx<dy?dy:dx);
#endif
}
+
+/**
+ * The client uses a circular distance instead of the square one. The circular distance
+ * is only used by units sending their attack commands via the client (not monsters).
+ * @param dx: Horizontal distance
+ * @param dy: Vertical distance
+ * @param distance: Distance to check against
+ * @return Within distance(1); Not within distance(0);
+ */
+bool check_distance_client(int dx, int dy, int distance)
+{
+ if(distance < 0) distance = 0;
+
+ return (path->distance_client(dx,dy) <= distance);
+}
+
+/**
+ * The client uses a circular distance instead of the square one. The circular distance
+ * is only used by units sending their attack commands via the client (not monsters).
+ * @param dx: Horizontal distance
+ * @param dy: Vertical distance
+ * @return Circular distance
+ */
+int distance_client(int dx, int dy)
+{
+ double temp_dist = sqrt((double)(dx*dx + dy*dy));
+
+ //Bonus factor used by client
+ //This affects even horizontal/vertical lines so they are one cell longer than expected
+ temp_dist -= 0.0625;
+
+ if(temp_dist < 0) temp_dist = 0;
+
+ return ((int)temp_dist);
+}
+
void path_defaults(void) {
path = &path_s;
@@ -461,4 +488,6 @@ void path_defaults(void) {
path->search = path_search;
path->check_distance = check_distance;
path->distance = distance;
+ path->check_distance_client = check_distance_client;
+ path->distance_client = distance_client;
}
diff --git a/src/map/path.h b/src/map/path.h
index 8d02e6558..4b71f2189 100644
--- a/src/map/path.h
+++ b/src/map/path.h
@@ -32,6 +32,14 @@ struct shootpath_data {
#define distance_blxy(bl, x1, y1) (path->distance((bl)->x - (x1), (bl)->y - (y1)))
#define distance_xy(x0, y0, x1, y1) (path->distance((x0) - (x1), (y0) - (y1)))
+#define check_distance_client_bl(bl1, bl2, distance) (path->check_distance_client((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y, distance))
+#define check_distance_client_blxy(bl, x1, y1, distance) (path->check_distance_client((bl)->x-(x1), (bl)->y-(y1), distance))
+#define check_distance_client_xy(x0, y0, x1, y1, distance) (path->check_distance_client((x0)-(x1), (y0)-(y1), distance))
+
+#define distance_client_bl(bl1, bl2) (path->distance_client((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y))
+#define distance_client_blxy(bl, x1, y1) (path->distance_client((bl)->x-(x1), (bl)->y-(y1)))
+#define distance_client_xy(x0, y0, x1, y1) (path->distance_client((x0)-(x1), (y0)-(y1)))
+
struct path_interface {
// calculates destination cell for knockback
int (*blownpos) (int16 m, int16 x0, int16 y0, int16 dx, int16 dy, int count);
@@ -39,8 +47,10 @@ struct path_interface {
bool (*search) (struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int flag, cell_chk cell);
// tries to find a shootable path
bool (*search_long) (struct shootpath_data *spd, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, cell_chk cell);
- int (*check_distance) (int dx, int dy, int distance);
+ bool (*check_distance) (int dx, int dy, int distance);
unsigned int (*distance) (int dx, int dy);
+ bool (*check_distance_client) (int dx, int dy, int distance);
+ int (*distance_client) (int dx, int dy);
};
struct path_interface *path;
diff --git a/src/map/pc.c b/src/map/pc.c
index a6619fad2..e39ddbff2 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -262,9 +262,6 @@ int pc_check_banding( struct block_list *bl, va_list ap ) {
sc = status->get_sc(bl);
- if( bl == src )
- return 0;
-
if( sc && sc->data[SC_BANDING] )
{
b_sd[(*c)++] = tsd->bl.id;
@@ -391,7 +388,8 @@ int pc_setrestartvalue(struct map_session_data *sd,int type) {
bst = &sd->base_status;
st = &sd->battle_status;
- if (type&1) { //Normal resurrection
+ if (type&1) {
+ //Normal resurrection
st->hp = 1; //Otherwise status->heal may fail if dead.
status->heal(&sd->bl, bst->hp, 0, 1);
if( st->sp < bst->sp )
@@ -557,7 +555,7 @@ int pc_makesavestatus(struct map_session_data *sd)
if(!battle_config.save_clothcolor)
sd->status.clothes_color=0;
- //Only copy the Cart/Peco/Falcon options, the rest are handled via
+ //Only copy the Cart/Peco/Falcon options, the rest are handled via
//status change load/saving. [Skotlex]
#ifdef NEW_CARTS
sd->status.option = sd->sc.option&(OPTION_INVISIBLE|OPTION_FALCON|OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR);
@@ -588,7 +586,7 @@ int pc_makesavestatus(struct map_session_data *sd)
sd->status.last_point.y = sd->bl.y;
}
- if(map->list[sd->bl.m].flag.nosave || map->list[sd->bl.m].instance_id >= 0) {
+ if( ( map->list[sd->bl.m].flag.nosave && sd->state.autotrade != 2 ) || map->list[sd->bl.m].instance_id >= 0) {
struct map_data *m=&map->list[sd->bl.m];
if(m->save.map)
memcpy(&sd->status.last_point,&m->save,sizeof(sd->status.last_point));
@@ -646,12 +644,15 @@ int pc_equippoint(struct map_session_data *sd,int n)
return 0; //Not equippable by players.
ep = sd->inventory_data[n]->equip;
- if(sd->inventory_data[n]->look == W_DAGGER ||
- sd->inventory_data[n]->look == W_1HSWORD ||
- sd->inventory_data[n]->look == W_1HAXE) {
- if( (pc->checkskill(sd,AS_LEFT) > 0 ||
- (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN ||
- (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO) ) { //Kagerou and Oboro can dual wield daggers. [Rytech]
+ if (sd->inventory_data[n]->look == W_DAGGER
+ || sd->inventory_data[n]->look == W_1HSWORD
+ || sd->inventory_data[n]->look == W_1HAXE
+ ) {
+ if (pc->checkskill(sd,AS_LEFT) > 0
+ || (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN
+ || (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO
+ ) {
+ //Kagerou and Oboro can dual wield daggers. [Rytech]
if( ep == EQP_HAND_R )
return EQP_ARMS;
if( ep == EQP_SHADOW_WEAPON )
@@ -756,24 +757,6 @@ int pc_setequipindex(struct map_session_data *sd)
return 0;
}
-//static int pc_isAllowedCardOn(struct map_session_data *sd,int s,int eqindex,int flag)
-//{
-// int i;
-// struct item *item = &sd->status.inventory[eqindex];
-// struct item_data *data;
-//
-// //Crafted/made/hatched items.
-// if (itemdb_isspecial(item->card[0]))
-// return 1;
-//
-// /* scan for enchant armor gems */
-// if( item->card[MAX_SLOTS - 1] && s < MAX_SLOTS - 1 )
-// s = MAX_SLOTS - 1;
-//
-// ARR_FIND( 0, s, i, item->card[i] && (data = itemdb->exists(item->card[i])) != NULL && data->flag.no_equip&flag );
-// return( i < s ) ? 0 : 1;
-//}
-
bool pc_isequipped(struct map_session_data *sd, int nameid)
{
@@ -919,6 +902,16 @@ int pc_isequip(struct map_session_data *sd,int n)
if(item->sex != 2 && sd->status.sex != item->sex)
return 0;
+ if ( item->equip & EQP_AMMO ) {
+ if ( !pc_iscarton(sd) && (sd->status.class_ == JOB_GENETIC_T || sd->status.class_ == JOB_GENETIC) ) {
+ clif->msg(sd, 0x5EF);
+ return 0;
+ }
+ if ( !pc_ismadogear(sd) && (sd->status.class_ == JOB_MECHANIC_T || sd->status.class_ == JOB_MECHANIC) ) {
+ clif->msg(sd, 0x59B);
+ return 0;
+ }
+ }
if (sd->sc.count) {
if(item->equip & EQP_ARMS && item->type == IT_WEAPON && sd->sc.data[SC_NOEQUIPWEAPON]) // Also works with left-hand weapons [DracoRPG]
@@ -962,6 +955,23 @@ int pc_isequip(struct map_session_data *sd,int n)
return 0;
}
+ if ( battle_config.unequip_restricted_equipment & 1 ) {
+ int i;
+ for ( i = 0; i < map->list[sd->bl.m].zone->disabled_items_count; i++ )
+ if ( map->list[sd->bl.m].zone->disabled_items[i] == sd->status.inventory[n].nameid )
+ return 0;
+ }
+
+ if ( battle_config.unequip_restricted_equipment & 2 ) {
+ if ( !itemdb_isspecial( sd->status.inventory[n].card[0] ) ) {
+ int i, slot;
+ for ( slot = 0; slot < MAX_SLOTS; slot++ )
+ for ( i = 0; i < map->list[sd->bl.m].zone->disabled_items_count; i++ )
+ if ( map->list[sd->bl.m].zone->disabled_items[i] == sd->status.inventory[n].card[slot] )
+ return 0;
+ }
+ }
+
return 1;
}
@@ -1205,8 +1215,8 @@ int pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl)
int class_;
if (!sd || !bl || pos < 0 || pos > 2)
return 0;
- if (sd->hate_mob[pos] != -1)
- { //Can't change hate targets.
+ if (sd->hate_mob[pos] != -1) {
+ //Can't change hate targets.
clif->hate_info(sd, pos, sd->hate_mob[pos], 0); //Display current
return 0;
}
@@ -1324,7 +1334,7 @@ int pc_reg_received(struct map_session_data *sd)
clif->pLoadEndAck(sd->fd, sd);
}
- if( sd->sc.option & OPTION_INVISIBLE ) {
+ if (pc_isinvisible(sd)) {
sd->vd.class_ = INVISIBLE_CLASS;
clif->message(sd->fd, msg_txt(11)); // Invisible: On
// decrement the number of pvp players on the map
@@ -1733,7 +1743,7 @@ int pc_disguise(struct map_session_data *sd, int class_) {
if (class_ >= 0 && sd->disguise == class_)
return 0;
- if(sd->sc.option&OPTION_INVISIBLE) { //Character is invisible. Stealth class-change. [Skotlex]
+ if (pc_isinvisible(sd)) { //Character is invisible. Stealth class-change. [Skotlex]
sd->disguise = class_; //viewdata is set on uncloaking.
return 2;
}
@@ -1834,10 +1844,10 @@ int pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short src_ski
return 0;
}
- spell[i].flag = src_skill;
- spell[i].id = id;
- spell[i].lv = lv;
- spell[i].rate = rate;
+ spell[i].flag = src_skill;
+ spell[i].id = id;
+ spell[i].lv = lv;
+ spell[i].rate = rate;
spell[i].card_id = card_id;
return 1;
}
@@ -1914,8 +1924,8 @@ int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id, short
&& race > 0
) {
drop[i].race |= race;
- if(drop[i].rate > 0 && rate > 0)
- { //Both are absolute rates.
+ if (drop[i].rate > 0 && rate > 0) {
+ //Both are absolute rates.
if (drop[i].rate < rate)
drop[i].rate = rate;
} else
@@ -2312,19 +2322,19 @@ int pc_bonus(struct map_session_data *sd,int type,int val) {
break;
}
break;
- case SP_SPEED_RATE: //Non stackable increase
+ case SP_SPEED_RATE: //Non stackable increase
if(sd->state.lr_flag != 2)
sd->bonus.speed_rate = min(sd->bonus.speed_rate, -val);
break;
- case SP_SPEED_ADDRATE: //Stackable increase
+ case SP_SPEED_ADDRATE: //Stackable increase
if(sd->state.lr_flag != 2)
sd->bonus.speed_add_rate -= val;
break;
- case SP_ASPD: //Raw increase
+ case SP_ASPD: //Raw increase
if(sd->state.lr_flag != 2)
sd->bonus.aspd_add -= 10*val;
break;
- case SP_ASPD_RATE: //Stackable increase - Made it linear as per rodatazone
+ case SP_ASPD_RATE: //Stackable increase - Made it linear as per rodatazone
if(sd->state.lr_flag != 2)
#ifndef RENEWAL_ASPD
bst->aspd_rate -= 10*val;
@@ -2537,7 +2547,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) {
if(sd->state.lr_flag != 2)
sd->bonus.magic_damage_return += val;
break;
- case SP_ALL_STATS: // [Valaris]
+ case SP_ALL_STATS: // [Valaris]
if(sd->state.lr_flag!=2) {
sd->param_bonus[SP_STR-SP_STR]+=val;
sd->param_bonus[SP_AGI-SP_STR]+=val;
@@ -2547,13 +2557,13 @@ int pc_bonus(struct map_session_data *sd,int type,int val) {
sd->param_bonus[SP_LUK-SP_STR]+=val;
}
break;
- case SP_AGI_VIT: // [Valaris]
+ case SP_AGI_VIT: // [Valaris]
if(sd->state.lr_flag!=2) {
sd->param_bonus[SP_AGI-SP_STR]+=val;
sd->param_bonus[SP_VIT-SP_STR]+=val;
}
break;
- case SP_AGI_DEX_STR: // [Valaris]
+ case SP_AGI_DEX_STR: // [Valaris]
if(sd->state.lr_flag!=2) {
sd->param_bonus[SP_AGI-SP_STR]+=val;
sd->param_bonus[SP_DEX-SP_STR]+=val;
@@ -2597,7 +2607,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) {
sd->bonus.classchange=val;
break;
case SP_LONG_ATK_RATE:
- if(sd->state.lr_flag != 2) //[Lupus] it should stack, too. As any other cards rate bonuses
+ if(sd->state.lr_flag != 2) //[Lupus] it should stack, too. As any other cards rate bonuses
sd->bonus.long_attack_atk_rate+=val;
break;
case SP_BREAK_WEAPON_RATE:
@@ -3106,11 +3116,11 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
}
if(sd->skillfixcastrate[i].id == type2)
- sd->skillfixcastrate[i].val += val;
+ sd->skillfixcastrate[i].val -= val;
else {
sd->skillfixcastrate[i].id = type2;
- sd->skillfixcastrate[i].val = val;
+ sd->skillfixcastrate[i].val -= val;
}
break;
@@ -3924,10 +3934,10 @@ int pc_getzeny(struct map_session_data *sd,int zeny, enum e_log_pick_type type,
/**
* Searches for the specified item ID in inventory and return its inventory index.
- *
+ *
* If the item is found, the returned value is guaranteed to be a valid index
* (non-negative, smaller than MAX_INVENTORY).
- *
+ *
* @param sd Character to search on.
* @param item_id The item ID to search.
* @return the inventory index of the first instance of the requested item.
@@ -3944,14 +3954,14 @@ int pc_search_inventory(struct map_session_data *sd, int item_id) {
/*==========================================
* Attempt to add a new item to inventory.
* Return:
- 0 = success
- 1 = invalid itemid not found or negative amount
- 2 = overweight
- 3 = ?
- 4 = no free place found
- 5 = max amount reached
- 6 = ?
- 7 = stack limitation
+ * 0 = success
+ * 1 = invalid itemid not found or negative amount
+ * 2 = overweight
+ * 3 = ?
+ * 4 = no free place found
+ * 5 = max amount reached
+ * 6 = ?
+ * 7 = stack limitation
*------------------------------------------*/
int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type)
{
@@ -4064,11 +4074,11 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
* Remove an item at index n from inventory by amount.
* Parameters :
* @type
- * 1 : don't notify deletion
- * 2 : don't notify weight change
+ * 1 : don't notify deletion
+ * 2 : don't notify weight change
* Return:
- * 0 = success
- * 1 = invalid itemid or negative amount
+ * 0 = success
+ * 1 = invalid itemid or negative amount
*------------------------------------------*/
int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reason, e_log_pick_type log_type)
{
@@ -4098,8 +4108,8 @@ int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reas
/*==========================================
* Attempt to drop an item.
* Return:
- * 0 = fail
- * 1 = success
+ * 0 = fail
+ * 1 = success
*------------------------------------------*/
int pc_dropitem(struct map_session_data *sd,int n,int amount)
{
@@ -4141,8 +4151,8 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount)
/*==========================================
* Attempt to pick up an item.
* Return:
- * 0 = fail
- * 1 = success
+ * 0 = fail
+ * 1 = success
*------------------------------------------*/
int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
{
@@ -4155,7 +4165,10 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
nullpo_ret(fitem);
if(!check_distance_bl(&fitem->bl, &sd->bl, 2) && sd->ud.skill_id!=BS_GREED)
- return 0; // Distance is too far
+ return 0; // Distance is too far
+
+ if( pc_has_permission(sd,PC_PERM_DISABLE_PICK_UP) )
+ return 0;
if (sd->status.party_id)
p = party->search(sd->status.party_id);
@@ -4209,8 +4222,8 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
/*==========================================
* Check if item is usable.
* Return:
- * 0 = no
- * 1 = yes
+ * 0 = no
+ * 1 = yes
*------------------------------------------*/
int pc_isUseitem(struct map_session_data *sd,int n)
{
@@ -4225,7 +4238,7 @@ int pc_isUseitem(struct map_session_data *sd,int n)
if( item == NULL )
return 0;
//Not consumable item
- if( item->type != IT_HEALING && item->type != IT_USABLE && item->type != IT_CASH )
+ if (!itemdb->is_item_usable(item))
return 0;
if( !item->script ) //if it has no script, you can't really consume it!
return 0;
@@ -4393,8 +4406,8 @@ int pc_isUseitem(struct map_session_data *sd,int n)
/*==========================================
* Last checks to use an item.
* Return:
- * 0 = fail
- * 1 = success
+ * 0 = fail
+ * 1 = success
*------------------------------------------*/
int pc_useitem(struct map_session_data *sd,int n) {
int64 tick = timer->gettick();
@@ -4475,7 +4488,7 @@ int pc_useitem(struct map_session_data *sd,int n) {
} else {// not yet used item (all slots are initially empty)
sd->item_delay[i].nameid = nameid;
}
- if( !(nameid == ITEMID_REINS_OF_MOUNT && sd->sc.option&(OPTION_WUGRIDER|OPTION_RIDING|OPTION_DRAGON|OPTION_MADOGEAR)) )
+ if (!(nameid == ITEMID_REINS_OF_MOUNT && pc_hasmount(sd)))
sd->item_delay[i].tick = tick + sd->inventory_data[n]->delay;
} else {// should not happen
ShowError("pc_useitem: Exceeded item delay array capacity! (nameid=%d, char_id=%d)\n", nameid, sd->status.char_id);
@@ -4516,7 +4529,7 @@ int pc_useitem(struct map_session_data *sd,int n) {
if( sd->inventory_data[n]->flag.delay_consume )
clif->useitemack(sd,n,amount,true);
else {
- if( sd->status.inventory[n].expire_time == 0 ) {
+ if (sd->status.inventory[n].expire_time == 0 && !(sd->inventory_data[n]->flag.keepafteruse)) {
clif->useitemack(sd,n,amount-1,true);
pc->delitem(sd,n,1,1,0,LOG_TYPE_CONSUME); // Rental Usable Items are not deleted until expiration
} else
@@ -4548,8 +4561,8 @@ int pc_useitem(struct map_session_data *sd,int n) {
/*==========================================
* Add item on cart for given index.
* Return:
- * 0 = success
- * 1 = fail
+ * 0 = success
+ * 1 = fail
*------------------------------------------*/
int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type)
{
@@ -4568,8 +4581,8 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
return 1;
}
- if( !itemdb_cancartstore(item_data, pc_get_group_level(sd)) || (item_data->bound > IBT_ACCOUNT && !pc_can_give_bound_items(sd)))
- { // Check item trade restrictions [Skotlex]
+ if (!itemdb_cancartstore(item_data, pc_get_group_level(sd)) || (item_data->bound > IBT_ACCOUNT && !pc_can_give_bound_items(sd))) {
+ // Check item trade restrictions
clif->message (sd->fd, msg_txt(264));
return 1;/* TODO: there is no official response to this? */
}
@@ -4582,7 +4595,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
{
ARR_FIND( 0, MAX_CART, i,
sd->status.cart[i].nameid == item_data->nameid && sd->status.cart[i].bound == item_data->bound &&
- sd->status.cart[i].card[0] == item_data->card[0] && sd->status.cart[i].card[1] == item_data->card[1] &&
+ sd->status.cart[i].card[0] == item_data->card[0] && sd->status.cart[i].card[1] == item_data->card[1] &&
sd->status.cart[i].card[2] == item_data->card[2] && sd->status.cart[i].card[3] == item_data->card[3] );
};
@@ -4617,8 +4630,8 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
/*==========================================
* Delete item on cart for given index.
* Return:
- * 0 = success
- * 1 = fail
+ * 0 = success
+ * 1 = fail
*------------------------------------------*/
int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type) {
struct item_data * data;
@@ -4646,8 +4659,8 @@ int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_
/*==========================================
* Transfer item from inventory to cart.
* Return:
- * 0 = fail
- * 1 = succes
+ * 0 = fail
+ * 1 = succes
*------------------------------------------*/
int pc_putitemtocart(struct map_session_data *sd,int idx,int amount)
{
@@ -4673,8 +4686,8 @@ int pc_putitemtocart(struct map_session_data *sd,int idx,int amount)
/*==========================================
* Get number of item in cart.
* Return:
- -1 = itemid not found or no amount found
- x = remaining itemid on cart after get
+ * -1 = itemid not found or no amount found
+ * x = remaining itemid on cart after get
*------------------------------------------*/
int pc_cartitem_amount(struct map_session_data* sd, int idx, int amount)
{
@@ -4692,8 +4705,8 @@ int pc_cartitem_amount(struct map_session_data* sd, int idx, int amount)
/*==========================================
* Retrieve an item at index idx from cart.
* Return:
- * 0 = player not found or (FIXME) succes (from pc->cart_delitem)
- * 1 = failure
+ * 0 = player not found or (FIXME) succes (from pc->cart_delitem)
+ * 1 = failure
*------------------------------------------*/
int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount)
{
@@ -4732,7 +4745,7 @@ void pc_bound_clear(struct map_session_data *sd, enum e_item_bound_type type) {
ShowError("Helllo! You reached pc_bound_clear for IBT_ACCOUNT, unfortunately no scenario was expected for this!\n");
break;
case IBT_GUILD: {
- struct guild_storage *gstor = gstorage->id2storage(sd->status.guild_id);
+ struct guild_storage *gstor = idb_get(gstorage->db,sd->status.guild_id);
for( i = 0; i < MAX_INVENTORY; i++ ){
if(sd->status.inventory[i].bound == type) {
@@ -4773,8 +4786,8 @@ int pc_show_steal(struct block_list *bl,va_list ap)
/*==========================================
* Steal an item from bl (mob).
* Return:
- * 0 = fail
- * 1 = succes
+ * 0 = fail
+ * 1 = succes
*------------------------------------------*/
int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skill_lv)
{
@@ -4800,7 +4813,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil
map->list[bl->m].flag.nomobloot || // check noloot map flag [Lorky]
(battle_config.skill_steal_max_tries && //Reached limit of steal attempts. [Lupus]
md->state.steal_flag++ >= battle_config.skill_steal_max_tries)
- ) { //Can't steal from
+ ) { //Can't steal from
md->state.steal_flag = UCHAR_MAX;
return 0;
}
@@ -5022,7 +5035,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short map_index, int x, int
vending->close(sd);
}
- if( hChSys.local && map->list[sd->bl.m].channel && idb_exists(map->list[sd->bl.m].channel->users, sd->status.char_id) ) {
+ if (clif->hChSys->local && map->list[sd->bl.m].channel && idb_exists(map->list[sd->bl.m].channel->users, sd->status.char_id)) {
clif->chsys_left(map->list[sd->bl.m].channel,sd);
}
}
@@ -5119,8 +5132,8 @@ int pc_setpos(struct map_session_data* sd, unsigned short map_index, int x, int
* Warp player sd to random location on current map.
* May fail if no walkable cell found (1000 attempts).
* Return:
- * 0 = fail or FIXME success (from pc->setpos)
- * x(1|2) = fail
+ * 0 = fail or FIXME success (from pc->setpos)
+ * x(1|2) = fail
*------------------------------------------*/
int pc_randomwarp(struct map_session_data *sd, clr_type type) {
int x,y,i=0;
@@ -5240,7 +5253,7 @@ int pc_checkskill2(struct map_session_data *sd,uint16 index) {
* Chk if we still have the correct weapon to continue the skill (actually status)
* If not ending it
* Return
- * 0 - No status found or all done
+ * 0 - No status found or all done
*------------------------------------------*/
int pc_checkallowskill(struct map_session_data *sd)
{
@@ -5736,7 +5749,7 @@ const char* job_name(int class_)
case JOB_ARCH_BISHOP_T: // 659
case JOB_MECHANIC_T: // 660
case JOB_GUILLOTINE_CROSS_T: // 661
- return msg_txt(656 - JOB_RUNE_KNIGHT_T+class_);
+ return msg_txt(656 - JOB_RUNE_KNIGHT_T+class_);
case JOB_ROYAL_GUARD: // 631
case JOB_SORCERER: // 632
@@ -5754,7 +5767,7 @@ const char* job_name(int class_)
case JOB_SURA_T: // 666
case JOB_GENETIC_T: // 667
case JOB_SHADOW_CHASER_T: // 668
- return msg_txt(662 - JOB_ROYAL_GUARD_T+class_);
+ return msg_txt(662 - JOB_ROYAL_GUARD_T+class_);
case JOB_RUNE_KNIGHT2:
return msg_txt(625);
@@ -5856,7 +5869,7 @@ int pc_follow_timer(int tid, int64 tick, int id, intptr_t data) {
pc->setpos(sd, map_id2index(tbl->m), tbl->x, tbl->y, CLR_TELEPORT);
}
sd->followtimer = timer->add(
- tick + 1000, // increase time a bit to loosen up map's load
+ tick + 1000, // increase time a bit to loosen up map's load
pc->follow_timer, sd->bl.id, 0);
return 0;
}
@@ -5908,7 +5921,7 @@ int pc_checkbaselevelup(struct map_session_data *sd) {
} while ((next=pc->nextbaseexp(sd)) > 0 && sd->status.base_exp >= next);
- if (battle_config.pet_lv_rate && sd->pd) //<Skotlex> update pet's level
+ if (battle_config.pet_lv_rate && sd->pd) //<Skotlex> update pet's level
status_calc_pet(sd->pd,SCO_NONE);
clif->updatestatus(sd,SP_STATUSPOINT);
@@ -6033,6 +6046,9 @@ bool pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned in
if(!battle_config.pvp_exp && map->list[sd->bl.m].flag.pvp) // [MouseJstr]
return false; // no exp on pvp maps
+ if( pc_has_permission(sd,PC_PERM_DISABLE_EXP) )
+ return false;
+
if(sd->status.guild_id>0)
base_exp-=guild->payexp(sd,base_exp);
@@ -6107,12 +6123,12 @@ bool pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned in
*------------------------------------------*/
unsigned int pc_maxbaselv(struct map_session_data *sd)
{
- return pc->max_level[pc->class2idx(sd->status.class_)][0];
+ return pc->max_level[pc->class2idx(sd->status.class_)][0];
}
unsigned int pc_maxjoblv(struct map_session_data *sd)
{
- return pc->max_level[pc->class2idx(sd->status.class_)][1];
+ return pc->max_level[pc->class2idx(sd->status.class_)][1];
}
/*==========================================
@@ -6143,8 +6159,8 @@ unsigned int pc_thisbaseexp(struct map_session_data *sd)
/*==========================================
* job level exp lookup
* Return:
- * 0 = not found
- * x = exp for level
+ * 0 = not found
+ * x = exp for level
*------------------------------------------*/
//Job exp needed for next level.
@@ -6468,7 +6484,7 @@ int pc_allskillup(struct map_session_data *sd)
continue; //Cannot be learned normally.
sd->status.skill[idx].id = id;
- sd->status.skill[idx].lv = skill->tree_get_max(id, sd->status.class_); // celest
+ sd->status.skill[idx].lv = skill->tree_get_max(id, sd->status.class_); // celest
}
}
status_calc_pc(sd,SCO_NONE);
@@ -6506,7 +6522,7 @@ int pc_resetlvl(struct map_session_data* sd,int type)
sd->status.dex=1;
sd->status.luk=1;
if(sd->status.class_ == JOB_NOVICE_HIGH) {
- sd->status.status_point=100; // not 88 [celest]
+ sd->status.status_point=100; // not 88 [celest]
// give platinum skills upon changing
pc->skill(sd,142,1,0);
pc->skill(sd,143,1,0);
@@ -6545,12 +6561,12 @@ int pc_resetlvl(struct map_session_data* sd,int type)
clif->updatestatus(sd,SP_NEXTJOBEXP);
clif->updatestatus(sd,SP_SKILLPOINT);
- clif->updatestatus(sd,SP_USTR); // Updates needed stat points - Valaris
+ clif->updatestatus(sd,SP_USTR); // Updates needed stat points - Valaris
clif->updatestatus(sd,SP_UAGI);
clif->updatestatus(sd,SP_UVIT);
clif->updatestatus(sd,SP_UINT);
clif->updatestatus(sd,SP_UDEX);
- clif->updatestatus(sd,SP_ULUK); // End Addition
+ clif->updatestatus(sd,SP_ULUK); // End Addition
for(i=0;i<EQI_MAX;i++) { // unequip items that can't be equipped by base 1 [Valaris]
if(sd->equip_index[i] >= 0)
@@ -6573,10 +6589,10 @@ int pc_resetstate(struct map_session_data* sd)
{
nullpo_ret(sd);
- if (battle_config.use_statpoint_table)
- { // New statpoint table used here - Dexity
- if (sd->status.base_level > MAX_LEVEL)
- { //pc->statp[] goes out of bounds, can't reset!
+ if (battle_config.use_statpoint_table) {
+ // New statpoint table used here - Dexity
+ if (sd->status.base_level > MAX_LEVEL) {
+ //pc->statp[] goes out of bounds, can't reset!
ShowError("pc_resetstate: Can't reset stats of %d:%d, the base level (%d) is greater than the max level supported (%d)\n",
sd->status.account_id, sd->status.char_id, sd->status.base_level, MAX_LEVEL);
return 0;
@@ -6611,12 +6627,12 @@ int pc_resetstate(struct map_session_data* sd)
clif->updatestatus(sd,SP_DEX);
clif->updatestatus(sd,SP_LUK);
- clif->updatestatus(sd,SP_USTR); // Updates needed stat points - Valaris
+ clif->updatestatus(sd,SP_USTR); // Updates needed stat points - Valaris
clif->updatestatus(sd,SP_UAGI);
clif->updatestatus(sd,SP_UVIT);
clif->updatestatus(sd,SP_UINT);
clif->updatestatus(sd,SP_UDEX);
- clif->updatestatus(sd,SP_ULUK); // End Addition
+ clif->updatestatus(sd,SP_ULUK); // End Addition
clif->updatestatus(sd,SP_STATUSPOINT);
@@ -6974,7 +6990,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
sd->st->state = END;
}
- /* e.g. not killed thru pc->damage */
+ /* e.g. not killed through pc->damage */
if( pc_issit(sd) ) {
clif->sc_end(&sd->bl,sd->bl.id,SELF,SI_SIT);
}
@@ -6988,23 +7004,23 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
//Reset ticks.
sd->hp_loss.tick = sd->sp_loss.tick = sd->hp_regen.tick = sd->sp_regen.tick = 0;
- if ( sd && sd->spiritball )
- pc->delspiritball(sd,sd->spiritball,0);
-
- for(i = 1; i < 5; i++)
- pc->del_charm(sd, sd->charm[i], i);
+ if ( sd->spiritball )
+ pc->delspiritball(sd, sd->spiritball, 0);
+ for ( i = SPIRITS_TYPE_CHARM_WATER; i < SPIRITS_TYPE_SPHERE; i++ )
+ pc->del_charm(sd, sd->spiritcharm[i], i);
if (src) {
switch (src->type) {
case BL_MOB:
{
struct mob_data *md=(struct mob_data *)src;
- if(md->target_id==sd->bl.id)
+ if (md->target_id==sd->bl.id)
mob->unlocktarget(md,tick);
- if(battle_config.mobs_level_up && md->status.hp &&
- (unsigned int)md->level < pc->maxbaselv(sd) &&
- !md->guardian_data && !md->special_state.ai// Guardians/summons should not level. [Skotlex]
- ) { // monster level up [Valaris]
+ if (battle_config.mobs_level_up && md->status.hp
+ && (unsigned int)md->level < pc->maxbaselv(sd)
+ && !md->guardian_data && !md->special_state.ai// Guardians/summons should not level. [Skotlex]
+ ) {
+ // monster level up [Valaris]
clif->misceffect(&md->bl,0);
md->level++;
status_calc_mob(md, SCO_NONE);
@@ -7046,19 +7062,20 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
// karma going down = more 'good' / more honourable.
// The Karma System way...
- if (sd->status.karma > ssd->status.karma) { // If player killed was more evil
+ if (sd->status.karma > ssd->status.karma) {
+ // If player killed was more evil
sd->status.karma--;
ssd->status.karma--;
}
- else if (sd->status.karma < ssd->status.karma) // If player killed was more good
+ else if (sd->status.karma < ssd->status.karma) // If player killed was more good
ssd->status.karma++;
// or the PK System way...
- if (sd->status.karma > 0) // player killed is dishonourable?
+ if (sd->status.karma > 0) // player killed is dishonourable?
ssd->status.karma--; // honour points earned
- sd->status.karma++; // honour points lost
+ sd->status.karma++; // honour points lost
// To-do: Receive exp on certain occasions
#endif
@@ -7116,7 +7133,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
}
if(base_penalty) {
- if (battle_config.pk_mode && src && src->type==BL_PC)
+ if (battle_config.pk_mode && src && src->type==BL_PC)
base_penalty*=2;
if( sd->status.mod_death != 100 )
base_penalty = base_penalty * sd->status.mod_death / 100;
@@ -7138,7 +7155,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
}
if(base_penalty) {
- if (battle_config.pk_mode && src && src->type==BL_PC)
+ if (battle_config.pk_mode && src && src->type==BL_PC)
base_penalty*=2;
if( sd->status.mod_death != 100 )
base_penalty = base_penalty * sd->status.mod_death / 100;
@@ -7307,32 +7324,32 @@ int pc_readparam(struct map_session_data* sd,int type)
case SP_FAME: val = sd->status.fame; break;
case SP_KILLERRID: val = sd->killerrid; break;
case SP_KILLEDRID: val = sd->killedrid; break;
- case SP_SLOTCHANGE: val = sd->status.slotchange; break;
- case SP_CHARRENAME: val = sd->status.rename; break;
+ case SP_SLOTCHANGE: val = sd->status.slotchange; break;
+ case SP_CHARRENAME: val = sd->status.rename; break;
case SP_MOD_EXP: val = sd->status.mod_exp; break;
case SP_MOD_DROP: val = sd->status.mod_drop; break;
case SP_MOD_DEATH: val = sd->status.mod_death; break;
case SP_CRITICAL: val = sd->battle_status.cri/10; break;
case SP_ASPD: val = (2000-sd->battle_status.amotion)/10; break;
- case SP_BASE_ATK: val = sd->battle_status.batk; break;
- case SP_DEF1: val = sd->battle_status.def; break;
- case SP_DEF2: val = sd->battle_status.def2; break;
- case SP_MDEF1: val = sd->battle_status.mdef; break;
- case SP_MDEF2: val = sd->battle_status.mdef2; break;
- case SP_HIT: val = sd->battle_status.hit; break;
- case SP_FLEE1: val = sd->battle_status.flee; break;
- case SP_FLEE2: val = sd->battle_status.flee2; break;
- case SP_DEFELE: val = sd->battle_status.def_ele; break;
+ case SP_BASE_ATK: val = sd->battle_status.batk; break;
+ case SP_DEF1: val = sd->battle_status.def; break;
+ case SP_DEF2: val = sd->battle_status.def2; break;
+ case SP_MDEF1: val = sd->battle_status.mdef; break;
+ case SP_MDEF2: val = sd->battle_status.mdef2; break;
+ case SP_HIT: val = sd->battle_status.hit; break;
+ case SP_FLEE1: val = sd->battle_status.flee; break;
+ case SP_FLEE2: val = sd->battle_status.flee2; break;
+ case SP_DEFELE: val = sd->battle_status.def_ele; break;
#ifndef RENEWAL_CAST
case SP_VARCASTRATE:
#endif
case SP_CASTRATE:
val = sd->castrate+=val;
break;
- case SP_MAXHPRATE: val = sd->hprate; break;
- case SP_MAXSPRATE: val = sd->sprate; break;
- case SP_SPRATE: val = sd->dsprate; break;
- case SP_SPEED_RATE: val = sd->bonus.speed_rate; break;
+ case SP_MAXHPRATE: val = sd->hprate; break;
+ case SP_MAXSPRATE: val = sd->sprate; break;
+ case SP_SPRATE: val = sd->dsprate; break;
+ case SP_SPEED_RATE: val = sd->bonus.speed_rate; break;
case SP_SPEED_ADDRATE: val = sd->bonus.speed_add_rate; break;
case SP_ASPD_RATE:
#ifndef RENEWAL_ASPD
@@ -7637,6 +7654,10 @@ int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp)
// Recovery Potion
if( sd->sc.data[SC_HEALPLUS] )
hp += (int)(hp * sd->sc.data[SC_HEALPLUS]->val1/100.);
+
+ // 2014 Halloween Event : Pumpkin Bonus
+ if ( sd->sc.data[SC_MTF_PUMPKIN] && itemid == ITEMID_PUMPKIN )
+ hp += (int)(hp * sd->sc.data[SC_MTF_PUMPKIN]->val1/100);
}
if(sp) {
bonus = 100 + (sd->battle_status.int_<<1)
@@ -7841,7 +7862,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
for(i=0;i<EQI_MAX;i++) {
if(sd->equip_index[i] >= 0)
if(!pc->isequip(sd,sd->equip_index[i]))
- pc->unequipitem(sd,sd->equip_index[i],2); // unequip invalid item for class
+ pc->unequipitem(sd,sd->equip_index[i],2); // unequip invalid item for class
}
//Change look, if disguised, you need to undisguise
@@ -7905,7 +7926,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
chrif->buildfamelist();
} else if (sd->status.fame > 0) {
//It may be that now they are famous?
- switch (sd->class_&MAPID_UPPERMASK) {
+ switch (sd->class_&MAPID_UPPERMASK) {
case MAPID_BLACKSMITH:
case MAPID_ALCHEMIST:
case MAPID_TAEKWON:
@@ -7952,7 +7973,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val)
clif->skillinfoblock(sd);
return 0;
break;
- case LOOK_HAIR: //Use the battle_config limits! [Skotlex]
+ case LOOK_HAIR: //Use the battle_config limits! [Skotlex]
val = cap_value(val, MIN_HAIR_STYLE, MAX_HAIR_STYLE);
if (sd->status.hair != val) {
@@ -7974,7 +7995,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val)
case LOOK_HEAD_MID:
sd->status.head_mid=val;
break;
- case LOOK_HAIR_COLOR: //Use the battle_config limits! [Skotlex]
+ case LOOK_HAIR_COLOR: //Use the battle_config limits! [Skotlex]
val = cap_value(val, MIN_HAIR_COLOR, MAX_HAIR_COLOR);
if (sd->status.hair_color != val) {
@@ -7984,7 +8005,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val)
GMI_HAIR_COLOR,&sd->status.hair_color,sizeof(sd->status.hair_color));
}
break;
- case LOOK_CLOTHES_COLOR: //Use the battle_config limits! [Skotlex]
+ case LOOK_CLOTHES_COLOR: //Use the battle_config limits! [Skotlex]
val = cap_value(val, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
sd->status.clothes_color=val;
@@ -8035,6 +8056,8 @@ int pc_setoption(struct map_session_data *sd,int type)
clif->clearcart(sd->fd);
if(pc->checkskill(sd, MC_PUSHCART) < 10)
status_calc_pc(sd,SCO_NONE); //Remove speed penalty.
+ if ( sd->equip_index[EQI_AMMO] > 0 )
+ pc->unequipitem(sd, sd->equip_index[EQI_AMMO], 2);
}
#endif
@@ -8070,6 +8093,8 @@ int pc_setoption(struct map_session_data *sd,int type)
}
status_change_end(&sd->bl, (sc_type)i, INVALID_TIMER);
}
+ if ( sd->equip_index[EQI_AMMO] > 0 )
+ pc->unequipitem(sd, sd->equip_index[EQI_AMMO], 2);
}
if (type&OPTION_FLYING && !(p_type&OPTION_FLYING))
@@ -8122,6 +8147,8 @@ int pc_setcart(struct map_session_data *sd,int type) {
status_change_end(&sd->bl,SC_PUSH_CART,INVALID_TIMER);
clif->clearcart(sd->fd);
clif->updatestatus(sd, SP_CARTINFO);
+ if ( sd->equip_index[EQI_AMMO] > 0 )
+ pc->unequipitem(sd, sd->equip_index[EQI_AMMO], 2);
break;
default:/* everything else is an allowed ID so we can move on */
if( !sd->sc.data[SC_PUSH_CART] ) /* first time, so fill cart data */
@@ -8147,48 +8174,111 @@ int pc_setcart(struct map_session_data *sd,int type) {
return 0;
}
-/*==========================================
- * Give player a falcon
- *------------------------------------------*/
-int pc_setfalcon(TBL_PC* sd, int flag)
+/* FIXME: These setter methods are inconsistent in their class/skill checks.
+ * They should be changed so that they all either do or skip the checks.*/
+
+/**
+ * Gives/removes a falcon.
+ *
+ * The target player needs the required skills in order to obtain a falcon.
+ *
+ * @param sd Target player.
+ * @param flag New state.
+ **/
+void pc_setfalcon(TBL_PC* sd, bool flag)
{
- if( flag ){
- if( pc->checkskill(sd,HT_FALCON)>0 ) // add falcon if he have the skill
+ if (flag) {
+ if (pc->checkskill(sd,HT_FALCON) > 0) // add falcon if he have the skill
pc->setoption(sd,sd->sc.option|OPTION_FALCON);
- } else if( pc_isfalcon(sd) ){
+ } else if (pc_isfalcon(sd)) {
pc->setoption(sd,sd->sc.option&~OPTION_FALCON); // remove falcon
}
-
- return 0;
}
-/*==========================================
- * Set player riding
- *------------------------------------------*/
-int pc_setriding(TBL_PC* sd, int flag)
+/**
+ * Mounts/dismounts a Peco or Gryphon.
+ *
+ * The target player needs the required skills in order to mount a peco.
+ *
+ * @param sd Target player.
+ * @param flag New state.
+ **/
+void pc_setridingpeco(TBL_PC* sd, bool flag)
{
- if( flag ){
- if( pc->checkskill(sd,KN_RIDING) > 0 ) // add peco
+ if (flag) {
+ if (pc->checkskill(sd, KN_RIDING))
pc->setoption(sd, sd->sc.option|OPTION_RIDING);
- } else if( pc_isriding(sd) ){
- pc->setoption(sd, sd->sc.option&~OPTION_RIDING);
+ } else if (pc_isridingpeco(sd)) {
+ pc->setoption(sd, sd->sc.option&~OPTION_RIDING);
}
-
- return 0;
}
/**
- * Gives player a mado
- * @param flag 1 Set mado
+ * Gives/removes a Mado Gear.
+ *
+ * The target player needs to be the correct class in order to obtain a mado gear.
+ *
+ * @param sd Target player.
+ * @param flag New state.
**/
-void pc_setmadogear( struct map_session_data *sd, int flag ) {
- if( flag ) {
- if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC )
+void pc_setmadogear(struct map_session_data *sd, bool flag)
+{
+ if (flag) {
+ if ((sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC)
pc->setoption(sd, sd->sc.option|OPTION_MADOGEAR);
- } else if( pc_ismadogear(sd) )
+ } else if (pc_ismadogear(sd)) {
pc->setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
+ }
+}
- return;
+/**
+ * Mounts/dismounts a dragon.
+ *
+ * The target player needs the required skills in order to mount a dragon.
+ *
+ * @param sd Target player.
+ * @param type New state. This must be a valid OPTION_DRAGON* or 0.
+ **/
+void pc_setridingdragon(TBL_PC* sd, unsigned int type)
+{
+ if (type&OPTION_DRAGON) {
+ // Ensure only one dragon is set at a time.
+ if (type&OPTION_DRAGON1)
+ type = OPTION_DRAGON1;
+ else if (type&OPTION_DRAGON2)
+ type = OPTION_DRAGON2;
+ else if (type&OPTION_DRAGON3)
+ type = OPTION_DRAGON3;
+ else if (type&OPTION_DRAGON4)
+ type = OPTION_DRAGON4;
+ else if (type&OPTION_DRAGON5)
+ type = OPTION_DRAGON5;
+ else
+ type = OPTION_DRAGON1;
+
+ if (pc->checkskill(sd, RK_DRAGONTRAINING))
+ pc->setoption(sd, (sd->sc.option&~OPTION_DRAGON)|type);
+ } else if (pc_isridingdragon(sd)) {
+ pc->setoption(sd,sd->sc.option&~OPTION_DRAGON); // remove dragon
+ }
+}
+
+/**
+ * Mounts/dismounts a wug.
+ *
+ * The target player needs the required skills in order to mount a wug.
+ *
+ * @param sd Target player.
+ * @param flag New state.
+ **/
+void pc_setridingwug(TBL_PC* sd, bool flag)
+{
+ if (flag) {
+ if (pc->checkskill(sd, RA_WUGRIDER) > 0)
+ pc->setoption(sd,sd->sc.option|OPTION_WUGRIDER);
+ } else if (pc_isridingwug(sd)) {
+ pc->setoption(sd,sd->sc.option&~OPTION_WUGRIDER); // remove wug
+ }
}
/**
@@ -8241,7 +8331,7 @@ bool pc_can_talk( struct map_session_data *sd ) {
int pc_candrop(struct map_session_data *sd, struct item *item)
{
if( item && (item->expire_time || (item->bound && !pc_can_give_bound_items(sd))) )
- return 0;
+ return 0;
if( !pc_can_give_items(sd) ) //check if this GM level can drop items
return 0;
return (itemdb_isdropable(item, pc_get_group_level(sd)));
@@ -8750,6 +8840,89 @@ int pc_load_combo(struct map_session_data *sd) {
}
return ret;
}
+
+void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int pos)
+{
+ if (pos & (EQP_HAND_R|EQP_SHADOW_WEAPON)) {
+ if(id)
+ sd->weapontype1 = id->look;
+ else
+ sd->weapontype1 = 0;
+ pc->calcweapontype(sd);
+ clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
+ }
+ if (pos & (EQP_HAND_L|EQP_SHADOW_SHIELD)) {
+ if (id) {
+ if(id->type == IT_WEAPON) {
+ sd->status.shield = 0;
+ sd->weapontype2 = id->look;
+ } else if(id->type == IT_ARMOR) {
+ sd->status.shield = id->look;
+ sd->weapontype2 = 0;
+ }
+ } else
+ sd->status.shield = sd->weapontype2 = 0;
+ pc->calcweapontype(sd);
+ clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
+ }
+ //Added check to prevent sending the same look on multiple slots ->
+ //causes client to redraw item on top of itself. (suggested by Lupus)
+ if (pos & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) {
+ if (id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID)))
+ sd->status.head_bottom = id->look;
+ else
+ sd->status.head_bottom = 0;
+ clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
+ }
+ if (pos & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) {
+ if (id)
+ sd->status.head_top = id->look;
+ else
+ sd->status.head_top = 0;
+ clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
+ }
+ if (pos & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) {
+ if (id && !(pos&EQP_HEAD_TOP))
+ sd->status.head_mid = id->look;
+ else
+ sd->status.head_mid = 0;
+ clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
+ }
+ if (pos & EQP_COSTUME_HEAD_TOP) {
+ if (id){
+ sd->status.head_top = id->look;
+ } else
+ sd->status.head_top = 0;
+ clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
+ }
+ if (pos & EQP_COSTUME_HEAD_MID) {
+ if(id && !(pos&EQP_HEAD_TOP)){
+ sd->status.head_mid = id->look;
+ } else
+ sd->status.head_mid = 0;
+ clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
+ }
+ if (pos & EQP_COSTUME_HEAD_LOW) {
+ if (id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID))){
+ sd->status.head_bottom = id->look;
+ } else
+ sd->status.head_bottom = 0;
+ clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
+ }
+
+ if (pos & EQP_SHOES)
+ clif->changelook(&sd->bl,LOOK_SHOES,0);
+ if (pos&EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1) {
+ sd->status.robe = id ? id->look : 0;
+ clif->changelook(&sd->bl, LOOK_ROBE, sd->status.robe);
+ }
+
+ if (pos & EQP_COSTUME_GARMENT) {
+ sd->status.robe = id ? id->look : 0;
+ clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe);
+ }
+}
+
/*==========================================
* Equip item on player sd at req_pos from inventory index n
*------------------------------------------*/
@@ -8778,13 +8951,13 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
ShowInfo("equip %d(%d) %x:%x\n",sd->status.inventory[n].nameid,n,id?id->equip:0,req_pos);
if(!pc->isequip(sd,n) || !(pos&req_pos) || sd->status.inventory[n].equip != 0 || sd->status.inventory[n].attribute==1 ) { // [Valaris]
// FIXME: pc->isequip: equip level failure uses 2 instead of 0
- clif->equipitemack(sd,n,0,EIA_FAIL); // fail
+ clif->equipitemack(sd,n,0,EIA_FAIL); // fail
return 0;
}
if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_NO_SWITCH_EQUIP])
{
- clif->equipitemack(sd,n,0,EIA_FAIL); // fail
+ clif->equipitemack(sd,n,0,EIA_FAIL); // fail
return 0;
}
@@ -8799,7 +8972,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
if (pos == EQP_ACC) //User specified both slots..
pos = sd->equip_index[EQI_ACC_R] >= 0 ? EQP_ACC_L : EQP_ACC_R;
} else if(pos == EQP_ARMS && id->equip == EQP_HAND_R) { //Dual wield capable weapon.
- pos = (req_pos&EQP_ARMS);
+ pos = (req_pos&EQP_ARMS);
if (pos == EQP_ARMS) //User specified both slots, pick one for them.
pos = sd->equip_index[EQI_HAND_R] >= 0 ? EQP_HAND_L : EQP_HAND_R;
} else if(pos == EQP_SHADOW_ACC) { //Accesories should only go in one of the two,
@@ -8807,13 +8980,13 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
if (pos == EQP_SHADOW_ACC) //User specified both slots..
pos = sd->equip_index[EQI_SHADOW_ACC_R] >= 0 ? EQP_SHADOW_ACC_L : EQP_SHADOW_ACC_R;
} else if( pos == EQP_SHADOW_ARMS && id->equip == EQP_SHADOW_WEAPON) { //Dual wield capable weapon.
- pos = (req_pos&EQP_SHADOW_ARMS);
+ pos = (req_pos&EQP_SHADOW_ARMS);
if (pos == EQP_SHADOW_ARMS) //User specified both slots, pick one for them.
pos = sd->equip_index[EQI_SHADOW_WEAPON] >= 0 ? EQP_SHADOW_SHIELD : EQP_SHADOW_WEAPON;
}
- if (pos&EQP_HAND_R && battle_config.use_weapon_skill_range&BL_PC)
- { //Update skill-block range database when weapon range changes. [Skotlex]
+ if (pos&EQP_HAND_R && battle_config.use_weapon_skill_range&BL_PC) {
+ //Update skill-block range database when weapon range changes. [Skotlex]
i = sd->equip_index[EQI_HAND_R];
if (i < 0 || !sd->inventory_data[i]) //No data, or no weapon equipped
flag = 1;
@@ -8839,86 +9012,8 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
sd->status.inventory[n].equip=pos;
- if(pos & (EQP_HAND_R|EQP_SHADOW_WEAPON)) {
- if(id)
- sd->weapontype1 = id->look;
- else
- sd->weapontype1 = 0;
- pc->calcweapontype(sd);
- clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
- }
- if(pos & (EQP_HAND_L|EQP_SHADOW_SHIELD)) {
- if(id) {
- if(id->type == IT_WEAPON) {
- sd->status.shield = 0;
- sd->weapontype2 = id->look;
- } else if(id->type == IT_ARMOR) {
- sd->status.shield = id->look;
- sd->weapontype2 = 0;
- }
- } else
- sd->status.shield = sd->weapontype2 = 0;
- pc->calcweapontype(sd);
- clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
- }
- //Added check to prevent sending the same look on multiple slots ->
- //causes client to redraw item on top of itself. (suggested by Lupus)
- if(pos & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) {
- if(id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID)))
- sd->status.head_bottom = id->look;
- else
- sd->status.head_bottom = 0;
- clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
- }
- if(pos & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) {
- if(id)
- sd->status.head_top = id->look;
- else
- sd->status.head_top = 0;
- clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
- }
- if(pos & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) {
- if(id && !(pos&EQP_HEAD_TOP))
- sd->status.head_mid = id->look;
- else
- sd->status.head_mid = 0;
- clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
- }
- if(pos & EQP_COSTUME_HEAD_TOP) {
- if(id){
- sd->status.head_top = id->look;
- } else
- sd->status.head_top = 0;
- clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
- }
- if(pos & EQP_COSTUME_HEAD_MID) {
- if(id && !(pos&EQP_HEAD_TOP)){
- sd->status.head_mid = id->look;
- } else
- sd->status.head_mid = 0;
- clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
- }
- if(pos & EQP_COSTUME_HEAD_LOW) {
- if(id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID))){
- sd->status.head_bottom = id->look;
- } else
- sd->status.head_bottom = 0;
- clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
- }
-
- if(pos & EQP_SHOES)
- clif->changelook(&sd->bl,LOOK_SHOES,0);
- if( pos&EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1 ) {
- sd->status.robe = id ? id->look : 0;
- clif->changelook(&sd->bl, LOOK_ROBE, sd->status.robe);
- }
-
- if(pos & EQP_COSTUME_GARMENT) {
- sd->status.robe = id ? id->look : 0;
- clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe);
- }
+ pc->equipitem_pos(sd, id, pos);
-
pc->checkallowskill(sd); //Check if status changes should be halted.
iflag = sd->npc_item_flag;
@@ -8968,6 +9063,63 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
return 0;
}
+void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos)
+{
+ if (pos & EQP_HAND_R) {
+ sd->weapontype1 = 0;
+ sd->status.weapon = sd->weapontype2;
+ pc->calcweapontype(sd);
+ clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
+ if (!battle_config.dancing_weaponswitch_fix)
+ status_change_end(&sd->bl, SC_DANCING, INVALID_TIMER); // Unequipping => stop dancing.
+ }
+ if (pos & EQP_HAND_L) {
+ sd->status.shield = sd->weapontype2 = 0;
+ pc->calcweapontype(sd);
+ clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
+ }
+ if (pos & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) {
+ sd->status.head_bottom = 0;
+ clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
+ }
+ if (pos & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) {
+ sd->status.head_top = 0;
+ clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
+ }
+ if (pos & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) {
+ sd->status.head_mid = 0;
+ clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
+ }
+
+ if (pos & EQP_COSTUME_HEAD_TOP) {
+ sd->status.head_top = ( pc->checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_TOP)]->look : 0;
+ clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
+ }
+
+ if (pos & EQP_COSTUME_HEAD_MID) {
+ sd->status.head_mid = ( pc->checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_MID)]->look : 0;
+ clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
+ }
+
+ if (pos & EQP_COSTUME_HEAD_LOW) {
+ sd->status.head_bottom = ( pc->checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_LOW)]->look : 0;
+ clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
+ }
+
+ if (pos & EQP_SHOES)
+ clif->changelook(&sd->bl,LOOK_SHOES,0);
+
+ if (pos & EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1) {
+ sd->status.robe = 0;
+ clif->changelook(&sd->bl, LOOK_ROBE, 0);
+ }
+
+ if (pos & EQP_COSTUME_GARMENT) {
+ sd->status.robe = ( pc->checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_GARMENT)]->look : 0;
+ clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe);
+ }
+}
+
/*==========================================
* Called when attemting to unequip an item from player
* type:
@@ -8978,6 +9130,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
int i,iflag;
bool status_cacl = false;
+ int pos;
nullpo_ret(sd);
if( n < 0 || n >= MAX_INVENTORY ) {
@@ -9010,73 +9163,22 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
sd->equip_index[i] = -1;
}
- if(sd->status.inventory[n].equip & EQP_HAND_R) {
- sd->weapontype1 = 0;
- sd->status.weapon = sd->weapontype2;
- pc->calcweapontype(sd);
- clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
- if( !battle_config.dancing_weaponswitch_fix )
- status_change_end(&sd->bl, SC_DANCING, INVALID_TIMER); // Unequipping => stop dancing.
- }
- if(sd->status.inventory[n].equip & EQP_HAND_L) {
- sd->status.shield = sd->weapontype2 = 0;
- pc->calcweapontype(sd);
- clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
- }
- if(sd->status.inventory[n].equip & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1 ) {
- sd->status.head_bottom = 0;
- clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
- }
- if(sd->status.inventory[n].equip & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1 ) {
- sd->status.head_top = 0;
- clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
- }
- if(sd->status.inventory[n].equip & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1 ) {
- sd->status.head_mid = 0;
- clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
- }
+ pos = sd->status.inventory[n].equip;
+ pc->unequipitem_pos(sd, n, pos);
- if(sd->status.inventory[n].equip & EQP_COSTUME_HEAD_TOP) {
- sd->status.head_top = ( pc->checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_TOP)]->look : 0;
- clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
- }
-
- if(sd->status.inventory[n].equip & EQP_COSTUME_HEAD_MID) {
- sd->status.head_mid = ( pc->checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_MID)]->look : 0;
- clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
- }
+ clif->unequipitemack(sd,n,pos,UIA_SUCCESS);
- if(sd->status.inventory[n].equip & EQP_COSTUME_HEAD_LOW) {
- sd->status.head_bottom = ( pc->checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_LOW)]->look : 0;
- clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
- }
-
- if(sd->status.inventory[n].equip & EQP_SHOES)
- clif->changelook(&sd->bl,LOOK_SHOES,0);
-
- if( sd->status.inventory[n].equip&EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1 ) {
- sd->status.robe = 0;
- clif->changelook(&sd->bl, LOOK_ROBE, 0);
- }
-
- if(sd->status.inventory[n].equip & EQP_COSTUME_GARMENT) {
- sd->status.robe = ( pc->checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_GARMENT)]->look : 0;
- clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe);
- }
-
- clif->unequipitemack(sd,n,sd->status.inventory[n].equip,UIA_SUCCESS);
-
- if((sd->status.inventory[n].equip & EQP_ARMS) &&
+ if((pos & EQP_ARMS) &&
sd->weapontype1 == 0 && sd->weapontype2 == 0 && (!sd->sc.data[SC_TK_SEVENWIND] || sd->sc.data[SC_ASPERSIO])) //Check for seven wind (but not level seven!)
skill->enchant_elemental_end(&sd->bl,-1);
- if(sd->status.inventory[n].equip & EQP_ARMOR) {
+ if(pos & EQP_ARMOR) {
// On Armor Change...
status_change_end(&sd->bl, SC_BENEDICTIO, INVALID_TIMER);
status_change_end(&sd->bl, SC_ARMOR_RESIST, INVALID_TIMER);
}
- if( sd->state.autobonus&sd->status.inventory[n].equip )
+ if( sd->state.autobonus&pos )
sd->state.autobonus &= ~sd->status.inventory[n].equip; //Check for activated autobonus [Inkfish]
sd->status.inventory[n].equip=0;
@@ -9114,8 +9216,15 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
//OnUnEquip script [Skotlex]
if (sd->inventory_data[n]) {
- if (sd->inventory_data[n]->unequip_script)
- script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id);
+ if (sd->inventory_data[n]->unequip_script) {
+ if ( battle_config.unequip_restricted_equipment & 1 ) {
+ ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, i, map->list[sd->bl.m].zone->disabled_items[i] == sd->status.inventory[n].nameid);
+ if ( i == map->list[sd->bl.m].zone->disabled_items_count )
+ script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id);
+ }
+ else
+ script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id);
+ }
if(itemdb_isspecial(sd->status.inventory[n].card[0]))
; //No cards
else {
@@ -9125,8 +9234,16 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
continue;
if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) {
- if( data->unequip_script )
- script->run(data->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id);
+ if ( data->unequip_script ) {
+ if ( battle_config.unequip_restricted_equipment & 2 ) {
+ int j;
+ ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, j, map->list[sd->bl.m].zone->disabled_items[j] == sd->status.inventory[n].card[i]);
+ if ( j == map->list[sd->bl.m].zone->disabled_items_count )
+ script->run(data->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id);
+ }
+ else
+ script->run(data->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id);
+ }
}
}
@@ -9201,7 +9318,7 @@ int pc_checkitem(struct map_session_data *sd)
}
if (sd->guild) {
- struct guild_storage *guild_storage = gstorage->id2storage2(sd->guild->guild_id);
+ struct guild_storage *guild_storage = idb_get(gstorage->db,sd->guild->guild_id);
if (guild_storage) {
for( i = 0; i < MAX_GUILD_STORAGE; i++ ) {
id = guild_storage->items[i].nameid;
@@ -9238,8 +9355,32 @@ int pc_checkitem(struct map_session_data *sd)
continue;
}
+ if ( battle_config.unequip_restricted_equipment & 1 ) {
+ int j;
+ for ( j = 0; j < map->list[sd->bl.m].zone->disabled_items_count; j++ ) {
+ if ( map->list[sd->bl.m].zone->disabled_items[j] == sd->status.inventory[i].nameid ) {
+ pc->unequipitem( sd, i, 2 );
+ calc_flag = 1;
+ }
+ }
+ }
+
+ if ( battle_config.unequip_restricted_equipment & 2 ) {
+ if ( !itemdb_isspecial( sd->status.inventory[i].card[0] ) ) {
+ int j, slot;
+ for ( slot = 0; slot < MAX_SLOTS; slot++ ) {
+ for ( j = 0; j < map->list[sd->bl.m].zone->disabled_items_count; j++ ) {
+ if ( map->list[sd->bl.m].zone->disabled_items[j] == sd->status.inventory[i].card[slot] ) {
+ pc->unequipitem( sd, i, 2 );
+ calc_flag = 1;
+ }
+ }
+ }
+ }
+ }
+
}
-
+
if( calc_flag && sd->state.active ) {
pc->checkallowskill(sd);
status_calc_pc(sd,SCO_NONE);
@@ -9258,8 +9399,8 @@ int pc_calc_pvprank_sub(struct block_list *bl,va_list ap)
sd1=(struct map_session_data *)bl;
sd2=va_arg(ap,struct map_session_data *);
- if( sd1->sc.option&OPTION_INVISIBLE || sd2->sc.option&OPTION_INVISIBLE )
- {// cannot register pvp rank for hidden GMs
+ if (pc_isinvisible(sd1) ||pc_isinvisible(sd2)) {
+ // cannot register pvp rank for hidden GMs
return 0;
}
@@ -9293,8 +9434,8 @@ int pc_calc_pvprank_timer(int tid, int64 tick, int id, intptr_t data) {
return 0;
sd->pvp_timer = INVALID_TIMER;
- if( sd->sc.option&OPTION_INVISIBLE )
- {// do not calculate the pvp rank for a hidden GM
+ if (pc_isinvisible(sd)) {
+ // do not calculate the pvp rank for a hidden GM
return 0;
}
@@ -9306,8 +9447,8 @@ int pc_calc_pvprank_timer(int tid, int64 tick, int id, intptr_t data) {
/*==========================================
* Checking if sd is married
* Return:
- * partner_id = yes
- * 0 = no
+ * partner_id = yes
+ * 0 = no
*------------------------------------------*/
int pc_ismarried(struct map_session_data *sd)
{
@@ -9321,8 +9462,8 @@ int pc_ismarried(struct map_session_data *sd)
/*==========================================
* Marry player sd to player dstsd
* Return:
- * -1 = fail
- * 0 = success
+ * -1 = fail
+ * 0 = success
*------------------------------------------*/
int pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd)
{
@@ -9338,8 +9479,8 @@ int pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd)
/*==========================================
* Divorce sd from its partner
* Return:
- * -1 = fail
- * 0 = success
+ * -1 = fail
+ * 0 = success
*------------------------------------------*/
int pc_divorce(struct map_session_data *sd)
{
@@ -9655,28 +9796,28 @@ int pc_charm_timer(int tid, int64 tick, int id, intptr_t data) {
if( (sd=(struct map_session_data *)map->id2sd(id)) == NULL || sd->bl.type!=BL_PC )
return 1;
- ARR_FIND(1, 5, type, sd->charm[type] > 0);
+ ARR_FIND(SPIRITS_TYPE_CHARM_WATER, SPIRITS_TYPE_SPHERE, type, sd->spiritcharm[type] > 0);
- if( sd->charm[type] <= 0 )
+ if( sd->spiritcharm[type] <= 0 )
{
- ShowError("pc_charm_timer: %d charm's available. (aid=%d cid=%d tid=%d)\n", sd->charm[type], sd->status.account_id, sd->status.char_id, tid);
- sd->charm[type] = 0;
+ ShowError("pc_charm_timer: %d spiritcharm's available. (aid=%d cid=%d tid=%d)\n", sd->spiritcharm[type], sd->status.account_id, sd->status.char_id, tid);
+ sd->spiritcharm[type] = 0;
return 0;
}
- ARR_FIND(0, sd->charm[type], i, sd->charm_timer[type][i] == tid);
- if( i == sd->charm[type] )
+ ARR_FIND(0, sd->spiritcharm[type], i, sd->charm_timer[type][i] == tid);
+ if( i == sd->spiritcharm[type] )
{
ShowError("pc_charm_timer: timer not found (aid=%d cid=%d tid=%d)\n", sd->status.account_id, sd->status.char_id, tid);
return 0;
}
- sd->charm[type]--;
- if( i != sd->charm[type] )
- memmove(sd->charm_timer[type]+i, sd->charm_timer[type]+i+1, (sd->charm[type]-i)*sizeof(int));
- sd->charm_timer[type][sd->charm[type]] = INVALID_TIMER;
+ sd->spiritcharm[type]--;
+ if( i != sd->spiritcharm[type] )
+ memmove(sd->charm_timer[type]+i, sd->charm_timer[type]+i+1, (sd->spiritcharm[type]-i)*sizeof(int));
+ sd->charm_timer[type][sd->spiritcharm[type]] = INVALID_TIMER;
- clif->charm(sd, type);
+ clif->spiritcharm(sd, type);
return 0;
}
@@ -9689,27 +9830,27 @@ int pc_add_charm(struct map_session_data *sd,int interval,int max,int type)
if(max > 10)
max = 10;
- if(sd->charm[type] < 0)
- sd->charm[type] = 0;
+ if(sd->spiritcharm[type] < 0)
+ sd->spiritcharm[type] = 0;
- if( sd->charm[type] && sd->charm[type] >= max )
+ if( sd->spiritcharm[type] && sd->spiritcharm[type] >= max )
{
if(sd->charm_timer[type][0] != INVALID_TIMER)
timer->delete(sd->charm_timer[type][0],pc->charm_timer);
- sd->charm[type]--;
- if( sd->charm[type] != 0 )
- memmove(sd->charm_timer[type]+0, sd->charm_timer[type]+1, (sd->charm[type])*sizeof(int));
- sd->charm_timer[type][sd->charm[type]] = INVALID_TIMER;
+ sd->spiritcharm[type]--;
+ if( sd->spiritcharm[type] != 0 )
+ memmove(sd->charm_timer[type]+0, sd->charm_timer[type]+1, (sd->spiritcharm[type])*sizeof(int));
+ sd->charm_timer[type][sd->spiritcharm[type]] = INVALID_TIMER;
}
tid = timer->add(timer->gettick()+interval, pc->charm_timer, sd->bl.id, 0);
- ARR_FIND(0, sd->charm[type], i, sd->charm_timer[type][i] == INVALID_TIMER || DIFF_TICK(timer->get(tid)->tick, timer->get(sd->charm_timer[type][i])->tick) < 0);
- if( i != sd->charm[type] )
- memmove(sd->charm_timer[type]+i+1, sd->charm_timer[type]+i, (sd->charm[type]-i)*sizeof(int));
+ ARR_FIND(0, sd->spiritcharm[type], i, sd->charm_timer[type][i] == INVALID_TIMER || DIFF_TICK(timer->get(tid)->tick, timer->get(sd->charm_timer[type][i])->tick) < 0);
+ if( i != sd->spiritcharm[type] )
+ memmove(sd->charm_timer[type]+i+1, sd->charm_timer[type]+i, (sd->spiritcharm[type]-i)*sizeof(int));
sd->charm_timer[type][i] = tid;
- sd->charm[type]++;
+ sd->spiritcharm[type]++;
- clif->charm(sd, type);
+ clif->spiritcharm(sd, type);
return 0;
}
@@ -9719,16 +9860,16 @@ int pc_del_charm(struct map_session_data *sd,int count,int type)
nullpo_ret(sd);
- if( sd->charm[type] <= 0 ) {
- sd->charm[type] = 0;
+ if( sd->spiritcharm[type] <= 0 ) {
+ sd->spiritcharm[type] = 0;
return 0;
}
if( count <= 0 )
return 0;
- if( count > sd->charm[type] )
- count = sd->charm[type];
- sd->charm[type] -= count;
+ if( count > sd->spiritcharm[type] )
+ count = sd->spiritcharm[type];
+ sd->spiritcharm[type] -= count;
if( count > 10 )
count = 10;
@@ -9743,7 +9884,7 @@ int pc_del_charm(struct map_session_data *sd,int count,int type)
sd->charm_timer[type][i] = INVALID_TIMER;
}
- clif->charm(sd, type);
+ clif->spiritcharm(sd, type);
return 0;
}
/*==========================================
@@ -10091,11 +10232,11 @@ void pc_read_skill_tree(void) {
libconfig->destroy(&skill_tree_conf);
- /* lets update all players skill tree */
- iter = mapit_getallusers();
- for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) )
- clif->skillinfoblock(sd);
- mapit->free(iter);
+ /* lets update all players skill tree */
+ iter = mapit_getallusers();
+ for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) )
+ clif->skillinfoblock(sd);
+ mapit->free(iter);
}
bool pc_readdb_levelpenalty(char* fields[], int columns, int current) {
#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
@@ -10183,7 +10324,7 @@ int pc_readdb(void) {
//Reverse check in case the array has a bunch of trailing zeros... [Skotlex]
//The reasoning behind the -2 is this... if the max level is 5, then the array
//should look like this:
- //0: x, 1: x, 2: x: 3: x 4: 0 <- last valid value is at 3.
+ //0: x, 1: x, 2: x: 3: x 4: 0 <- last valid value is at 3.
while ((ui = pc->max_level[job][type]) >= 2 && pc->exp_table[job][type][ui-2] <= 0)
pc->max_level[job][type]--;
if (pc->max_level[job][type] < maxlv) {
@@ -10195,7 +10336,7 @@ int pc_readdb(void) {
pc->exp_table[job][type][ui] = pc->exp_table[job][type][ui-1];
pc->max_level[job][type] = maxlv;
}
-// ShowDebug("%s - Class %d: %d\n", type?"Job":"Base", job_id, pc->max_level[job][type]);
+ //ShowDebug("%s - Class %d: %d\n", type?"Job":"Base", job_id, pc->max_level[job][type]);
for (i = 1; i < job_count; i++) {
job_id = jobs[i];
if (!pcdb_checkid(job_id)) {
@@ -10205,7 +10346,7 @@ int pc_readdb(void) {
job = pc->class2idx(job_id);
memcpy(pc->exp_table[job][type], pc->exp_table[jobs[0]][type], sizeof(pc->exp_table[0][0]));
pc->max_level[job][type] = maxlv;
-// ShowDebug("%s - Class %d: %u\n", type?"Job":"Base", job_id, pc->max_level[job][type]);
+ //ShowDebug("%s - Class %d: %u\n", type?"Job":"Base", job_id, pc->max_level[job][type]);
}
}
fclose(fp);
@@ -10445,8 +10586,8 @@ int pc_expiration_timer(int tid, int64 tick, int id, intptr_t data) {
return 0;
}
-/* this timer exists only when a character with a expire timer > 24h is online */
-/* it loops thru online players once an hour to check whether a new < 24h is available */
+/* This timer exists only when a character with an expire timer > 24h is online */
+/* It loops through online players once an hour to check whether a new < 24h is available */
int pc_global_expiration_timer(int tid, int64 tick, int id, intptr_t data) {
struct s_mapiterator* iter;
struct map_session_data* sd;
@@ -10914,7 +11055,9 @@ void pc_defaults(void) {
pc->resetfeel = pc_resetfeel;
pc->resethate = pc_resethate;
pc->equipitem = pc_equipitem;
+ pc->equipitem_pos = pc_equipitem_pos;
pc->unequipitem = pc_unequipitem;
+ pc->unequipitem_pos = pc_unequipitem_pos;
pc->checkitem = pc_checkitem;
pc->useitem = pc_useitem;
@@ -10932,8 +11075,10 @@ void pc_defaults(void) {
pc->setoption = pc_setoption;
pc->setcart = pc_setcart;
pc->setfalcon = pc_setfalcon;
- pc->setriding = pc_setriding;
+ pc->setridingpeco = pc_setridingpeco;
pc->setmadogear = pc_setmadogear;
+ pc->setridingdragon = pc_setridingdragon;
+ pc->setridingwug = pc_setridingwug;
pc->changelook = pc_changelook;
pc->equiplookall = pc_equiplookall;
diff --git a/src/map/pc.h b/src/map/pc.h
index bec4522df..8472eb34e 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -29,7 +29,7 @@
#define MAX_PC_BONUS 10
#define MAX_PC_SKILL_REQUIRE 5
#define MAX_PC_FEELHATE 3
-#define PVP_CALCRANK_INTERVAL 1000 // PVP calculation interval
+#define PVP_CALCRANK_INTERVAL 1000 // PVP calculation interval
//Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index
//where the arrows are equipped)
@@ -80,7 +80,7 @@ struct weapon_data {
} hp_drain[RC_MAX], sp_drain[RC_MAX];
struct {
short class_, rate;
- } add_dmg[MAX_PC_BONUS];
+ } add_dmg[MAX_PC_BONUS];
struct {
short flag, rate;
unsigned char ele;
@@ -145,7 +145,7 @@ struct map_session_data {
unsigned int snovice_dead_flag : 1; //Explosion spirits on death: 0 off, 1 used.
unsigned int abra_flag : 2; // Abracadabra bugfix by Aru
unsigned int autocast : 1; // Autospell flag [Inkfish]
- unsigned int autotrade : 1; //By Fantik
+ unsigned int autotrade : 2; //By Fantik
unsigned int showdelay :1;
unsigned int showexp :1;
unsigned int showzeny :1;
@@ -202,13 +202,13 @@ struct map_session_data {
unsigned int bonus_coma : 1;
} special_state;
int login_id1, login_id2;
- unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex]
-
+ unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex]
+
/// Groups & permissions
int group_id;
GroupSettings *group;
unsigned int extra_temp_permissions; /* permissions from @addperm */
-
+
struct mmo_charstatus status;
struct item_data* inventory_data[MAX_INVENTORY]; // direct pointers to itemdb entries (faster than doing item_id lookups)
short equip_index[EQI_MAX];
@@ -301,7 +301,7 @@ struct map_session_data {
} hp_loss, sp_loss, hp_regen, sp_regen;
struct {
short class_, rate;
- } add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS], add_mdmg[MAX_PC_BONUS];
+ } add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS], add_mdmg[MAX_PC_BONUS];
struct s_add_drop add_drop[MAX_PC_BONUS];
struct {
int nameid;
@@ -349,7 +349,7 @@ struct map_session_data {
short sp_gain_value, hp_gain_value, magic_sp_gain_value, magic_hp_gain_value;
short sp_vanish_rate;
short sp_vanish_per, sp_vanish_trigger;
- unsigned short unbreakable; // chance to prevent ANY equipment breaking [celest]
+ unsigned short unbreakable; // chance to prevent ANY equipment breaking [celest]
unsigned short unbreakable_equip; //100% break resistance on certain equipment
unsigned short unstripable_equip;
int fixcastrate,varcastrate;
@@ -362,12 +362,12 @@ struct map_session_data {
int matk_rate;
int critical_rate,hit_rate,flee_rate,flee2_rate,def_rate,def2_rate,mdef_rate,mdef2_rate;
int itemid;
- short itemindex; //Used item's index in sd->inventory [Skotlex]
+ short itemindex; //Used item's index in sd->inventory [Skotlex]
short catch_target_class; // pet catching, stores a pet class to catch (short now) [zzo]
short spiritball, spiritball_old;
int spirit_timer[MAX_SPIRITBALL];
- short charm[ELE_POISON+1]; // There are actually 5 charm Fire, Ice, Wind, Earth & Poison maybe because its color violet.
- int charm_timer[ELE_POISON+1][10];
+ short spiritcharm[SPIRITS_TYPE_END];
+ int charm_timer[SPIRITS_TYPE_END][MAX_SPIRITCHARM];
unsigned char potion_success_counter; //Potion successes in row counter
unsigned char mission_count; //Stores the bounty kill count for TK_MISSION
short mission_mobid; //Stores the target mob_id for TK_MISSION
@@ -400,7 +400,7 @@ struct map_session_data {
struct s_search_store_info searchstore;
struct pet_data *pd;
- struct homun_data *hd; // [blackhole89]
+ struct homun_data *hd; // [blackhole89]
struct mercenary_data *md;
struct elemental_data *ed;
@@ -481,14 +481,14 @@ struct map_session_data {
struct pc_combos *combos;
unsigned char combo_count;
-
+
/**
* Guarantees your friend request is legit (for bugreport:4629)
**/
int friend_req;
int shadowform_id;
-
+
/* [Ind/Hercules] */
struct hChSysCh **channels;
unsigned char channel_count;
@@ -497,14 +497,14 @@ struct map_session_data {
unsigned char fontcolor;
unsigned int fontcolor_tid;
int64 hchsysch_tick;
-
+
/* [Ind/Hercules] */
struct sc_display_entry **sc_display;
unsigned char sc_display_count;
-
+
short *instance;
unsigned short instances;
-
+
/* Possible Thanks to Yommy~! */
struct {
unsigned int ready : 1;/* did he accept the 'match is about to start, enter' dialog? */
@@ -515,26 +515,26 @@ struct map_session_data {
int *queues;
unsigned int queues_count;
-
+
/* Made Possible Thanks to Yommy~! */
unsigned int cryptKey; ///< Packet obfuscation key to be used for the next received packet
unsigned short (*parse_cmd_func)(int fd, struct map_session_data *sd); ///< parse_cmd_func used by this player
-
+
unsigned char delayed_damage;//ref. counter bugreport:7307 [Ind/Hercules]
-
+
/* HPM Custom Struct */
struct HPluginData **hdata;
unsigned int hdatac;
-
+
/* expiration_time timer id */
int expiration_tid;
time_t expiration_time;
-
+
/* */
struct {
unsigned int second,third;
} sktree;
-
+
/**
* Account/Char variables & array control of those variables
**/
@@ -542,7 +542,14 @@ struct map_session_data {
unsigned char vars_received;/* char loading is only complete when you get it all. */
bool vars_ok;
bool vars_dirty;
-
+
+ struct {
+ short stage;
+ short prizeIdx;
+ short prizeStage;
+ bool claimPrize;
+ } roulette;
+
// temporary debugging of bug #3504
const char* delunit_prevfile;
int delunit_prevline;
@@ -589,19 +596,20 @@ struct map_session_data {
#endif
#define pc_isfalcon(sd) ( (sd)->sc.option&OPTION_FALCON )
-#define pc_isriding(sd) ( (sd)->sc.option&OPTION_RIDING )
#define pc_isinvisible(sd) ( (sd)->sc.option&OPTION_INVISIBLE )
#define pc_is50overweight(sd) ( (sd)->weight*100 >= (sd)->max_weight*battle->bc->natural_heal_weight_rate )
#define pc_is90overweight(sd) ( (sd)->weight*10 >= (sd)->max_weight*9 )
#define pc_maxparameter(sd) ( (((sd)->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO || ((sd)->class_&MAPID_UPPERMASK) == MAPID_REBELLION || ((sd)->class_&MAPID_THIRDMASK) == MAPID_SUPER_NOVICE_E) ? battle->bc->max_extended_parameter : (sd)->class_&JOBL_THIRD ? ((sd)->class_&JOBL_BABY ? battle->bc->max_baby_third_parameter : battle->bc->max_third_parameter) : ((sd)->class_&JOBL_BABY ? battle->bc->max_baby_parameter : battle->bc->max_parameter) )
-/**
- * Ranger
- **/
+/// Generic check for mounts
+#define pc_hasmount(sd) ( (sd)->sc.option&(OPTION_RIDING|OPTION_WUGRIDER|OPTION_DRAGON|OPTION_MADOGEAR) )
+/// Knight classes Peco / Gryphon
+#define pc_isridingpeco(sd) ( (sd)->sc.option&(OPTION_RIDING) )
+/// Ranger Warg
#define pc_iswug(sd) ( (sd)->sc.option&OPTION_WUG )
#define pc_isridingwug(sd) ( (sd)->sc.option&OPTION_WUGRIDER )
-// Mechanic Magic Gear
+/// Mechanic Magic Gear
#define pc_ismadogear(sd) ( (sd)->sc.option&OPTION_MADOGEAR )
-// Rune Knight Dragon
+/// Rune Knight Dragon
#define pc_isridingdragon(sd) ( (sd)->sc.option&OPTION_DRAGON )
#define pc_stop_walking(sd, type) (unit->stop_walking(&(sd)->bl, (type)))
@@ -614,13 +622,13 @@ struct map_session_data {
//JOB_NOVICE isn't checked for class_ is supposed to be unsigned
#define pcdb_checkid_sub(class_) \
( \
- ( (class_) < JOB_MAX_BASIC ) \
-|| ( (class_) >= JOB_NOVICE_HIGH && (class_) <= JOB_DARK_COLLECTOR ) \
-|| ( (class_) >= JOB_RUNE_KNIGHT && (class_) <= JOB_MECHANIC_T2 ) \
-|| ( (class_) >= JOB_BABY_RUNE && (class_) <= JOB_BABY_MECHANIC2 ) \
-|| ( (class_) >= JOB_SUPER_NOVICE_E && (class_) <= JOB_SUPER_BABY_E ) \
-|| ( (class_) >= JOB_KAGEROU && (class_) <= JOB_OBORO ) \
-|| ( (class_) >= JOB_REBELLION && (class_) < JOB_MAX ) \
+ ( (class_) < JOB_MAX_BASIC ) \
+ || ( (class_) >= JOB_NOVICE_HIGH && (class_) <= JOB_DARK_COLLECTOR ) \
+ || ( (class_) >= JOB_RUNE_KNIGHT && (class_) <= JOB_MECHANIC_T2 ) \
+ || ( (class_) >= JOB_BABY_RUNE && (class_) <= JOB_BABY_MECHANIC2 ) \
+ || ( (class_) >= JOB_SUPER_NOVICE_E && (class_) <= JOB_SUPER_BABY_E ) \
+ || ( (class_) >= JOB_KAGEROU && (class_) <= JOB_OBORO ) \
+ || ( (class_) >= JOB_REBELLION && (class_) < JOB_MAX ) \
)
#define pcdb_checkid(class_) pcdb_checkid_sub((unsigned int)(class_))
@@ -632,8 +640,8 @@ struct map_session_data {
#define pc_rightside_def(sd) ((sd)->battle_status.def)
#define pc_leftside_mdef(sd) ((sd)->battle_status.mdef2)
#define pc_rightside_mdef(sd) ((sd)->battle_status.mdef)
-#define pc_leftside_matk(sd) (status->base_matk(status->get_status_data(&(sd)->bl), (sd)->status.base_level))
-#define pc_rightside_matk(sd) ((sd)->battle_status.rhw.matk+(sd)->battle_status.lhw.matk+(sd)->bonus.ematk)
+ #define pc_leftside_matk(sd) (status->base_matk(&(sd)->bl, status->get_status_data(&(sd)->bl), (sd)->status.base_level))
+ #define pc_rightside_matk(sd) ((sd)->battle_status.rhw.matk+(sd)->battle_status.lhw.matk+(sd)->bonus.ematk)
#else
#define pc_leftside_atk(sd) ((sd)->battle_status.batk + (sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk)
#define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2)
@@ -641,18 +649,16 @@ struct map_session_data {
#define pc_rightside_def(sd) ((sd)->battle_status.def2)
#define pc_leftside_mdef(sd) ((sd)->battle_status.mdef)
#define pc_rightside_mdef(sd) ( (sd)->battle_status.mdef2 - ((sd)->battle_status.vit>>1) )
-#define pc_leftside_matk(sd) \
- (\
- ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \
+#define pc_leftside_matk(sd) (\
+ ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \
?((sd)->battle_status.matk_min * 100 + 50) / ((sd)->sc.data[SC_MAGICPOWER]->val3+100) \
- :(sd)->battle_status.matk_min \
- )
-#define pc_rightside_matk(sd) \
- (\
- ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \
+ :(sd)->battle_status.matk_min \
+)
+#define pc_rightside_matk(sd) (\
+ ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \
?((sd)->battle_status.matk_max * 100 + 50) / ((sd)->sc.data[SC_MAGICPOWER]->val3+100) \
- :(sd)->battle_status.matk_max \
- )
+ :(sd)->battle_status.matk_max \
+)
#endif
#define pc_get_group_id(sd) ( (sd)->group_id )
@@ -769,15 +775,12 @@ struct pc_interface {
/* funcs */
void (*init) (bool minimal);
void (*final) (void);
-
+
struct map_session_data* (*get_dummy_sd) (void);
int (*class2idx) (int class_);
- //int (*getrefinebonus) (int lv,int type); FIXME: This function does not exist, nor it is ever called
- bool (*can_give_items) (struct map_session_data *sd);
- bool (*can_give_bound_items) (struct map_session_data *sd);
bool (*can_talk) (struct map_session_data *sd);
bool (*can_attack) ( struct map_session_data *sd, int target_id );
-
+
bool (*can_use_command) (struct map_session_data *sd, const char *command);
int (*set_group) (struct map_session_data *sd, int group_id);
bool (*should_log_commands) (struct map_session_data *sd);
@@ -789,25 +792,25 @@ struct pc_interface {
bool (*authok) (struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers);
void (*authfail) (struct map_session_data *sd);
int (*reg_received) (struct map_session_data *sd);
-
+
int (*isequip) (struct map_session_data *sd,int n);
int (*equippoint) (struct map_session_data *sd,int n);
int (*setinventorydata) (struct map_session_data *sd);
-
+
int (*checkskill) (struct map_session_data *sd,uint16 skill_id);
int (*checkskill2) (struct map_session_data *sd,uint16 index);
int (*checkallowskill) (struct map_session_data *sd);
int (*checkequip) (struct map_session_data *sd,int pos);
-
+
int (*calc_skilltree) (struct map_session_data *sd);
int (*calc_skilltree_normalize_job) (struct map_session_data *sd);
int (*clean_skilltree) (struct map_session_data *sd);
-
+
int (*setpos) (struct map_session_data* sd, unsigned short map_index, int x, int y, clr_type clrtype);
int (*setsavepoint) (struct map_session_data *sd, short map_index, int x, int y);
int (*randomwarp) (struct map_session_data *sd,clr_type type);
int (*memo) (struct map_session_data* sd, int pos);
-
+
int (*checkadditem) (struct map_session_data *sd,int nameid,int amount);
int (*inventoryblank) (struct map_session_data *sd);
int (*search_inventory) (struct map_session_data *sd,int item_id);
@@ -819,45 +822,45 @@ struct pc_interface {
// Special Shop System
int (*paycash) (struct map_session_data *sd, int price, int points);
int (*getcash) (struct map_session_data *sd, int cash, int points);
-
+
int (*cart_additem) (struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type);
int (*cart_delitem) (struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type);
int (*putitemtocart) (struct map_session_data *sd,int idx,int amount);
int (*getitemfromcart) (struct map_session_data *sd,int idx,int amount);
int (*cartitem_amount) (struct map_session_data *sd,int idx,int amount);
-
+
int (*takeitem) (struct map_session_data *sd,struct flooritem_data *fitem);
int (*dropitem) (struct map_session_data *sd,int n,int amount);
-
+
bool (*isequipped) (struct map_session_data *sd, int nameid);
bool (*can_Adopt) (struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd);
bool (*adoption) (struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd);
-
+
int (*updateweightstatus) (struct map_session_data *sd);
-
+
int (*addautobonus) (struct s_autobonus *bonus,char max,const char *bonus_script,short rate,unsigned int dur,short atk_type,const char *o_script,unsigned short pos,bool onskill);
int (*exeautobonus) (struct map_session_data* sd,struct s_autobonus *bonus);
int (*endautobonus) (int tid, int64 tick, int id, intptr_t data);
int (*delautobonus) (struct map_session_data* sd,struct s_autobonus *bonus,char max,bool restore);
-
+
int (*bonus) (struct map_session_data *sd,int type,int val);
int (*bonus2) (struct map_session_data *sd,int type,int type2,int val);
int (*bonus3) (struct map_session_data *sd,int type,int type2,int type3,int val);
int (*bonus4) (struct map_session_data *sd,int type,int type2,int type3,int type4,int val);
int (*bonus5) (struct map_session_data *sd,int type,int type2,int type3,int type4,int type5,int val);
int (*skill) (struct map_session_data *sd, int id, int level, int flag);
-
+
int (*insert_card) (struct map_session_data *sd,int idx_card,int idx_equip);
-
+
int (*steal_item) (struct map_session_data *sd,struct block_list *bl, uint16 skill_lv);
int (*steal_coin) (struct map_session_data *sd,struct block_list *bl);
-
+
int (*modifybuyvalue) (struct map_session_data *sd,int orig_value);
int (*modifysellvalue) (struct map_session_data *sd,int orig_value);
-
+
int (*follow) (struct map_session_data *sd, int target_id); // [MouseJstr]
int (*stop_following) (struct map_session_data *sd);
-
+
unsigned int (*maxbaselv) (struct map_session_data *sd);
unsigned int (*maxjoblv) (struct map_session_data *sd);
int (*checkbaselevelup) (struct map_session_data *sd);
@@ -880,14 +883,16 @@ struct pc_interface {
int (*resetfeel) (struct map_session_data *sd);
int (*resethate) (struct map_session_data *sd);
int (*equipitem) (struct map_session_data *sd,int n,int req_pos);
+ void (*equipitem_pos) (struct map_session_data *sd, struct item_data *id, int pos);
int (*unequipitem) (struct map_session_data *sd,int n,int flag);
+ void (*unequipitem_pos) (struct map_session_data *sd, int n, int pos);
int (*checkitem) (struct map_session_data *sd);
int (*useitem) (struct map_session_data *sd,int n);
-
+
int (*skillatk_bonus) (struct map_session_data *sd, uint16 skill_id);
int (*skillheal_bonus) (struct map_session_data *sd, uint16 skill_id);
int (*skillheal2_bonus) (struct map_session_data *sd, uint16 skill_id);
-
+
void (*damage) (struct map_session_data *sd,struct block_list *src,unsigned int hp, unsigned int sp);
int (*dead) (struct map_session_data *sd,struct block_list *src);
void (*revive) (struct map_session_data *sd,unsigned int hp, unsigned int sp);
@@ -897,12 +902,14 @@ struct pc_interface {
int (*jobchange) (struct map_session_data *sd,int job, int upper);
int (*setoption) (struct map_session_data *sd,int type);
int (*setcart) (struct map_session_data* sd, int type);
- int (*setfalcon) (struct map_session_data* sd, int flag);
- int (*setriding) (struct map_session_data* sd, int flag);
- void (*setmadogear) (struct map_session_data* sd, int flag);
+ void (*setfalcon) (struct map_session_data *sd, bool flag);
+ void (*setridingpeco) (struct map_session_data *sd, bool flag);
+ void (*setmadogear) (struct map_session_data *sd, bool flag);
+ void (*setridingdragon) (struct map_session_data *sd, unsigned int type);
+ void (*setridingwug) (struct map_session_data *sd, bool flag);
int (*changelook) (struct map_session_data *sd,int type,int val);
int (*equiplookall) (struct map_session_data *sd);
-
+
int (*readparam) (struct map_session_data *sd,int type);
int (*setparam) (struct map_session_data *sd,int type,int val);
int (*readreg) (struct map_session_data *sd, int64 reg);
@@ -913,15 +920,15 @@ struct pc_interface {
int (*setregistry) (struct map_session_data *sd, int64 reg, int val);
char * (*readregistry_str) (struct map_session_data *sd, int64 reg);
int (*setregistry_str) (struct map_session_data *sd, int64 reg, const char *val);
-
+
int (*addeventtimer) (struct map_session_data *sd,int tick,const char *name);
int (*deleventtimer) (struct map_session_data *sd,const char *name);
int (*cleareventtimer) (struct map_session_data *sd);
int (*addeventtimercount) (struct map_session_data *sd,const char *name,int tick);
-
+
int (*calc_pvprank) (struct map_session_data *sd);
int (*calc_pvprank_timer) (int tid, int64 tick, int id, intptr_t data);
-
+
int (*ismarried) (struct map_session_data *sd);
int (*marriage) (struct map_session_data *sd,struct map_session_data *dstsd);
int (*divorce) (struct map_session_data *sd);
@@ -929,27 +936,27 @@ struct pc_interface {
struct map_session_data * (*get_father) (struct map_session_data *sd);
struct map_session_data * (*get_mother) (struct map_session_data *sd);
struct map_session_data * (*get_child) (struct map_session_data *sd);
-
+
void (*bleeding) (struct map_session_data *sd, unsigned int diff_tick);
void (*regen) (struct map_session_data *sd, unsigned int diff_tick);
-
+
void (*setstand) (struct map_session_data *sd);
int (*candrop) (struct map_session_data *sd,struct item *item);
-
+
int (*jobid2mapid) (unsigned short b_class); // Skotlex
int (*mapid2jobid) (unsigned short class_, int sex); // Skotlex
-
+
const char * (*job_name) (int class_);
-
+
void (*setinvincibletimer) (struct map_session_data* sd, int val);
void (*delinvincibletimer) (struct map_session_data* sd);
-
+
int (*addspiritball) (struct map_session_data *sd,int interval,int max);
int (*delspiritball) (struct map_session_data *sd,int count,int type);
void (*addfame) (struct map_session_data *sd,int count);
unsigned char (*famerank) (int char_id, int job);
int (*set_hate_mob) (struct map_session_data *sd, int pos, struct block_list *bl);
-
+
int (*readdb) (void);
int (*map_day_timer) (int tid, int64 tick, int id, intptr_t data); // by [yor]
int (*map_night_timer) (int tid, int64 tick, int id, intptr_t data); // by [yor]
@@ -957,25 +964,25 @@ struct pc_interface {
void (*inventory_rentals) (struct map_session_data *sd);
int (*inventory_rental_clear) (struct map_session_data *sd);
void (*inventory_rental_add) (struct map_session_data *sd, int seconds);
-
+
int (*disguise) (struct map_session_data *sd, int class_);
bool (*isautolooting) (struct map_session_data *sd, int nameid);
-
+
void (*overheat) (struct map_session_data *sd, int val);
-
+
int (*banding) (struct map_session_data *sd, uint16 skill_lv);
-
+
void (*itemcd_do) (struct map_session_data *sd, bool load);
-
+
int (*load_combo) (struct map_session_data *sd);
-
+
int (*add_charm) (struct map_session_data *sd,int interval,int max,int type);
int (*del_charm) (struct map_session_data *sd,int count,int type);
-
+
void (*baselevelchanged) (struct map_session_data *sd);
int (*level_penalty_mod) (int diff, unsigned char race, unsigned short mode, int type);
int (*calc_skillpoint) (struct map_session_data* sd);
-
+
int (*invincible_timer) (int tid, int64 tick, int id, intptr_t data);
int (*spiritball_timer) (int tid, int64 tick, int id, intptr_t data);
int (*check_banding) ( struct block_list *bl, va_list ap );
@@ -1003,19 +1010,19 @@ struct pc_interface {
int (*checkcombo) (struct map_session_data *sd, struct item_data *data );
int (*calcweapontype) (struct map_session_data *sd);
int (*removecombo) (struct map_session_data *sd, struct item_data *data );
-
+
void (*bank_deposit) (struct map_session_data *sd, int money);
void (*bank_withdraw) (struct map_session_data *sd, int money);
-
+
void (*rental_expire) (struct map_session_data *sd, int i);
void (*scdata_received) (struct map_session_data *sd);
-
+
void (*bound_clear) (struct map_session_data *sd, enum e_item_bound_type type);
-
+
int (*expiration_timer) (int tid, int64 tick, int id, intptr_t data);
int (*global_expiration_timer) (int tid, int64 tick, int id, intptr_t data);
void (*expire_check) (struct map_session_data *sd);
-
+
/**
* Autotrade persistency [Ind/Hercules <3]
**/
diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
index e577c642f..9cd478b3f 100644
--- a/src/map/pc_groups.c
+++ b/src/map/pc_groups.c
@@ -420,6 +420,10 @@ void do_init_pc_groups(void) {
{ "disable_commands_when_dead", PC_PERM_DISABLE_CMD_DEAD },
{ "hchsys_admin", PC_PERM_HCHSYS_ADMIN },
{ "can_trade_bound", PC_PERM_TRADE_BOUND },
+ { "disable_pickup", PC_PERM_DISABLE_PICK_UP },
+ { "disable_store", PC_PERM_DISABLE_STORE },
+ { "disable_exp", PC_PERM_DISABLE_EXP },
+ { "disable_skill_usage", PC_PERM_DISABLE_SKILL_USAGE },
};
unsigned char i, len = ARRAYLENGTH(pc_g_defaults);
diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h
index f52e2ba22..48ff782dd 100644
--- a/src/map/pc_groups.h
+++ b/src/map/pc_groups.h
@@ -35,6 +35,10 @@ enum e_pc_permission {
PC_PERM_DISABLE_CMD_DEAD = 0x100000,
PC_PERM_HCHSYS_ADMIN = 0x200000,
PC_PERM_TRADE_BOUND = 0x400000,
+ PC_PERM_DISABLE_PICK_UP = 0x800000,
+ PC_PERM_DISABLE_STORE = 0x1000000,
+ PC_PERM_DISABLE_EXP = 0x2000000,
+ PC_PERM_DISABLE_SKILL_USAGE = 0x4000000,
};
// Cached config settings for quick lookup
diff --git a/src/map/pet.c b/src/map/pet.c
index 9275a6de5..71dd39401 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -510,7 +510,7 @@ int pet_catch_process2(struct map_session_data* sd, int target_id) {
if (sd->catch_target_class == 0 && !(md->status.mode&MD_BOSS))
sd->catch_target_class = md->class_;
if(i < 0 || sd->catch_target_class != md->class_) {
- clif->emotion(&md->bl, E_AG); //mob will do /ag if wrong lure is used on them.
+ clif->emotion(&md->bl, E_AG); //mob will do /ag if wrong lure is used on them.
clif->pet_roulette(sd,0);
sd->catch_target_class = -1;
return 1;
@@ -688,10 +688,7 @@ int pet_equipitem(struct map_session_data *sd,int index) {
//Skotlex: start support timers if need
int64 tick = timer->gettick();
if (pd->s_skill && pd->s_skill->timer == INVALID_TIMER) {
- if (pd->s_skill->id)
- pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000, pet->skill_support_timer, sd->bl.id, 0);
- else
- pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000, pet->heal_timer, sd->bl.id, 0);
+ pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000, pet->skill_support_timer, sd->bl.id, 0);
}
if (pd->bonus && pd->bonus->timer == INVALID_TIMER)
pd->bonus->timer=timer->add(tick+pd->bonus->delay*1000, pet->skill_bonus_timer, sd->bl.id, 0);
@@ -725,12 +722,8 @@ int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) {
pd->state.skillbonus = 0;
status_calc_pc(sd,SCO_NONE);
}
- if( pd->s_skill && pd->s_skill->timer != INVALID_TIMER )
- {
- if( pd->s_skill->id )
- timer->delete(pd->s_skill->timer, pet->skill_support_timer);
- else
- timer->delete(pd->s_skill->timer, pet->heal_timer);
+ if (pd->s_skill && pd->s_skill->timer != INVALID_TIMER) {
+ timer->delete(pd->s_skill->timer, pet->skill_support_timer);
pd->s_skill->timer = INVALID_TIMER;
}
if( pd->bonus && pd->bonus->timer != INVALID_TIMER )
@@ -821,7 +814,7 @@ int pet_randomwalk(struct pet_data *pd, int64 tick) {
else
c+=pd->status.speed;
}
- pd->next_walktime = tick+rnd()%3000+3000+c;
+ pd->next_walktime = tick+rnd()%1000+MIN_RANDOMWALKTIME+c;
return 1;
}
@@ -911,17 +904,18 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, int64 tick
if (target->type != BL_ITEM)
{ //enemy targetted
- if(!battle->check_range(&pd->bl,target,pd->status.rhw.range))
- { //Chase
+ if(!battle->check_range(&pd->bl,target,pd->status.rhw.range)) {
+ //Chase
if(!unit->walktobl(&pd->bl, target, pd->status.rhw.range, 2))
pet->unlocktarget(pd); //Unreachable target.
return 0;
}
//Continuous attack.
unit->attack(&pd->bl, pd->target_id, 1);
- } else { //Item Targeted, attempt loot
- if (!check_distance_bl(&pd->bl, target, 1))
- { //Out of range
+ } else {
+ //Item Targeted, attempt loot
+ if (!check_distance_bl(&pd->bl, target, 1)) {
+ //Out of range
if(!unit->walktobl(&pd->bl, target, 1, 1)) //Unreachable target.
pet->unlocktarget(pd);
return 0;
@@ -1036,7 +1030,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
memset(pd->loot->item,0,pd->loot->max * sizeof(struct item));
pd->loot->count = 0;
pd->loot->weight = 0;
- pd->ud.canact_tick = timer->gettick()+10000; //prevent picked up during 10*1000ms
+ pd->ud.canact_tick = timer->gettick()+10000; //prevent picked up during 10*1000ms
if (dlist->item)
timer->add(timer->gettick()+540,pet->delay_item_drop,0,(intptr_t)dlist);
@@ -1103,8 +1097,8 @@ int pet_recovery_timer(int tid, int64 tick, int id, intptr_t data) {
return 0;
}
- if(sd->sc.data[pd->recovery->type])
- { //Display a heal animation?
+ if (sd->sc.data[pd->recovery->type]) {
+ //Display a heal animation?
//Detoxify is chosen for now.
clif->skill_nodamage(&pd->bl,&sd->bl,TF_DETOXIFY,1,1);
status_change_end(&sd->bl, pd->recovery->type, INVALID_TIMER);
@@ -1116,40 +1110,6 @@ int pet_recovery_timer(int tid, int64 tick, int id, intptr_t data) {
return 0;
}
-int pet_heal_timer(int tid, int64 tick, int id, intptr_t data) {
- struct map_session_data *sd=map->id2sd(id);
- struct status_data *st;
- struct pet_data *pd;
- unsigned int rate = 100;
-
- if(sd==NULL || sd->pd == NULL || sd->pd->s_skill == NULL)
- return 1;
-
- pd=sd->pd;
-
- if(pd->s_skill->timer != tid) {
- ShowError("pet_heal_timer %d != %d\n",pd->s_skill->timer,tid);
- return 0;
- }
-
- st = status->get_status_data(&sd->bl);
-
- if(pc_isdead(sd) ||
- (rate = get_percentage(st->sp, st->max_sp)) > pd->s_skill->sp ||
- (rate = get_percentage(st->hp, st->max_hp)) > pd->s_skill->hp ||
- (rate = (pd->ud.skilltimer != INVALID_TIMER)) //Another skill is in effect
- ) { //Wait (how long? 1 sec for every 10% of remaining)
- pd->s_skill->timer=timer->add(timer->gettick()+(rate>10?rate:10)*100,pet->heal_timer,sd->bl.id,0);
- return 0;
- }
- pet_stop_attack(pd);
- pet_stop_walking(pd,1);
- clif->skill_nodamage(&pd->bl,&sd->bl,AL_HEAL,pd->s_skill->lv,1);
- status->heal(&sd->bl, pd->s_skill->lv,0, 0);
- pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0);
- return 0;
-}
-
/*==========================================
* pet support skills [Skotlex]
*------------------------------------------*/
@@ -1170,8 +1130,8 @@ int pet_skill_support_timer(int tid, int64 tick, int id, intptr_t data) {
st = status->get_status_data(&sd->bl);
- if (DIFF_TICK(pd->ud.canact_tick, tick) > 0)
- { //Wait until the pet can act again.
+ if (DIFF_TICK(pd->ud.canact_tick, tick) > 0) {
+ //Wait until the pet can act again.
pd->s_skill->timer=timer->add(pd->ud.canact_tick,pet->skill_support_timer,sd->bl.id,0);
return 0;
}
@@ -1360,7 +1320,6 @@ int do_init_pet(bool minimal) {
timer->add_func_list(pet->delay_item_drop,"pet_delay_item_drop");
timer->add_func_list(pet->skill_support_timer, "pet_skill_support_timer"); // [Skotlex]
timer->add_func_list(pet->recovery_timer,"pet_recovery_timer"); // [Valaris]
- timer->add_func_list(pet->heal_timer,"pet_heal_timer"); // [Valaris]
timer->add_interval(timer->gettick()+MIN_PETTHINKTIME,pet->ai_hard,0,0,MIN_PETTHINKTIME);
return 0;
@@ -1432,7 +1391,6 @@ void pet_defaults(void) {
pet->lootitem_drop = pet_lootitem_drop;
pet->skill_bonus_timer = pet_skill_bonus_timer;
pet->recovery_timer = pet_recovery_timer;
- pet->heal_timer = pet_heal_timer;
pet->skill_support_timer = pet_skill_support_timer;
pet->read_db = read_petdb;
}
diff --git a/src/map/pet.h b/src/map/pet.h
index 5c890ef85..cffcf7dd0 100644
--- a/src/map/pet.h
+++ b/src/map/pet.h
@@ -41,16 +41,16 @@ struct s_pet_db {
enum { PET_CLASS,PET_CATCH,PET_EGG,PET_EQUIP,PET_FOOD };
struct pet_recovery { //Stat recovery
- enum sc_type type; //Status Change id
- unsigned short delay; //How long before curing (secs).
+ enum sc_type type; ///< Status Change id
+ unsigned short delay; ///< How long before curing (secs).
int timer;
};
struct pet_bonus {
- unsigned short type; //bStr, bVit?
- unsigned short val; //Qty
+ unsigned short type; //bStr, bVit?
+ unsigned short val; //Qty
unsigned short duration; //in secs
- unsigned short delay; //Time before RENEWAL_CAST (secs)
+ unsigned short delay; //Time before RENEWAL_CAST (secs)
int timer;
};
@@ -93,7 +93,7 @@ struct pet_data {
} state;
int move_fail_count;
int64 next_walktime, last_thinktime;
- short rate_fix; //Support rate as modified by intimacy (1000 = 100%) [Skotlex]
+ short rate_fix; //Support rate as modified by intimacy (1000 = 100%) [Skotlex]
struct pet_recovery* recovery;
struct pet_bonus* bonus;
@@ -149,7 +149,6 @@ struct pet_interface {
int (*lootitem_drop) (struct pet_data *pd, struct map_session_data *sd);
int (*skill_bonus_timer) (int tid, int64 tick, int id, intptr_t data);
int (*recovery_timer) (int tid, int64 tick, int id, intptr_t data);
- int (*heal_timer) (int tid, int64 tick, int id, intptr_t data);
int (*skill_support_timer) (int tid, int64 tick, int id, intptr_t data);
int (*read_db) ();
};
diff --git a/src/map/script.c b/src/map/script.c
index ecd12a3c1..031dfc21b 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -55,6 +55,7 @@
#include "../common/sysinfo.h"
#include "../common/timer.h"
#include "../common/utils.h"
+#include "../common/HPM.h"
#ifndef WIN32
#include <sys/time.h>
@@ -140,7 +141,7 @@ static void script_dump_stack(struct script_state* st)
for( i = 0; i < st->stack->sp; ++i )
{
struct script_data* data = &st->stack->stack_data[i];
- ShowMessage("\t[%d] %s", i, script_op2name(data->type));
+ ShowMessage("\t[%d] %s", i, script->op2name(data->type));
switch( data->type )
{
case C_INT:
@@ -154,7 +155,7 @@ static void script_dump_stack(struct script_state* st)
break;
case C_NAME:
- ShowMessage(" \"%s\" (id=%d ref=%p subtype=%s)\n", reference_getname(data), data->u.num, data->ref, script_op2name(script->str_data[data->u.num].type));
+ ShowMessage(" \"%s\" (id=%d ref=%p subtype=%s)\n", reference_getname(data), data->u.num, data->ref, script->op2name(script->str_data[data->u.num].type));
break;
case C_RETINFO:
@@ -526,7 +527,7 @@ int script_add_str(const char* p)
}
}
if( existingentry ) {
- DeprecationWarning2("script_add_str", p, existingentry, script->parser_current_file); // TODO
+ DeprecationCaseWarning("script_add_str", p, existingentry, script->parser_current_file); // TODO
}
#endif // ENABLE_CASE_CHECK
@@ -772,6 +773,8 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom)
script->addl(func);
script->addc(C_ARG);
arg = script->buildin[script->str_data[func].val];
+ if (script->str_data[func].deprecated)
+ DeprecationWarning(p);
if( !arg ) arg = &null_arg; // Use a dummy, null string
} else if( script->str_data[func].type == C_USERFUNC || script->str_data[func].type == C_USERFUNC_POS ) {
// script defined function
@@ -1349,7 +1352,7 @@ const char* parse_curly_close(const char* p)
char label[256];
int l;
// Remove temporary variables
- sprintf(label,"set $@__SW%x_VAL,0;",script->syntax.curly[pos].index);
+ sprintf(label,"__setr $@__SW%x_VAL,0;",script->syntax.curly[pos].index);
script->syntax.curly[script->syntax.curly_count++].type = TYPE_NULL;
script->parse_line(label);
script->syntax.curly_count--;
@@ -1431,10 +1434,6 @@ const char* parse_syntax(const char* p)
// Closing decision if, for , while
p = script->parse_syntax_close(p + 1);
return p;
-#ifdef ENABLE_CASE_CHECK
- } else if( p2 - p == 5 && strncasecmp(p, "break", 5) == 0 ) {
- disp_deprecation_message("parse_syntax", "break", p); // TODO
-#endif // ENABLE_CASE_CHECK
}
break;
case 'c':
@@ -1506,7 +1505,7 @@ const char* parse_syntax(const char* p)
disp_error_message("parse_syntax: dup 'case'",p);
linkdb_insert(&script->syntax.curly[pos].case_label, (void*)h64BPTRSIZE(v), (void*)1);
- sprintf(label,"set $@__SW%x_VAL,0;",script->syntax.curly[pos].index);
+ sprintf(label,"__setr $@__SW%x_VAL,0;",script->syntax.curly[pos].index);
script->syntax.curly[script->syntax.curly_count++].type = TYPE_NULL;
script->parse_line(label);
@@ -1545,12 +1544,6 @@ const char* parse_syntax(const char* p)
//Closing decision if, for , while
p = script->parse_syntax_close(p + 1);
return p;
-#ifdef ENABLE_CASE_CHECK
- } else if( p2 - p == 4 && strncasecmp(p, "case", 4) == 0 ) {
- disp_deprecation_message("parse_syntax", "case", p); // TODO
- } else if( p2 - p == 8 && strncasecmp(p, "continue", 8) == 0 ) {
- disp_deprecation_message("parse_syntax", "continue", p); // TODO
-#endif // ENABLE_CASE_CHECK
}
break;
case 'd':
@@ -1604,12 +1597,6 @@ const char* parse_syntax(const char* p)
script->set_label(l,script->pos,p);
script->syntax.curly_count++;
return p;
-#ifdef ENABLE_CASE_CHECK
- } else if( p2 - p == 7 && strncasecmp(p, "default", 7) == 0 ) {
- disp_deprecation_message("parse_syntax", "default", p); // TODO
- } else if( p2 - p == 2 && strncasecmp(p, "do", 2) == 0 ) {
- disp_deprecation_message("parse_syntax", "do", p); // TODO
-#endif // ENABLE_CASE_CHECK
}
break;
case 'f':
@@ -1647,7 +1634,7 @@ const char* parse_syntax(const char* p)
} else {
// Skip to the end point if the condition is false
sprintf(label,"__FR%x_FIN",script->syntax.curly[pos].index);
- script->addl(script->add_str("jump_zero"));
+ script->addl(script->add_str("__jump_zero"));
script->addc(C_ARG);
p=script->parse_expr(p);
p=script->skip_space(p);
@@ -1749,12 +1736,6 @@ const char* parse_syntax(const char* p)
{
disp_error_message("expect ';' or '{' at function syntax",p);
}
-#ifdef ENABLE_CASE_CHECK
- } else if( p2 - p == 3 && strncasecmp(p, "for", 3) == 0 ) {
- disp_deprecation_message("parse_syntax", "for", p); // TODO
- } else if( p2 - p == 8 && strncasecmp(p, "function", 8) == 0 ) {
- disp_deprecation_message("parse_syntax", "function", p); // TODO
-#endif // ENABLE_CASE_CHECK
}
break;
case 'i':
@@ -1772,17 +1753,13 @@ const char* parse_syntax(const char* p)
script->syntax.curly[script->syntax.curly_count].flag = 0;
sprintf(label,"__IF%x_%x",script->syntax.curly[script->syntax.curly_count].index,script->syntax.curly[script->syntax.curly_count].count);
script->syntax.curly_count++;
- script->addl(script->add_str("jump_zero"));
+ script->addl(script->add_str("__jump_zero"));
script->addc(C_ARG);
p=script->parse_expr(p);
p=script->skip_space(p);
script->addl(script->add_str(label));
script->addc(C_FUNC);
return p;
-#ifdef ENABLE_CASE_CHECK
- } else if( p2 - p == 2 && strncasecmp(p, "if", 2) == 0 ) {
- disp_deprecation_message("parse_syntax", "if", p); // TODO
-#endif // ENABLE_CASE_CHECK
}
break;
case 's':
@@ -1800,7 +1777,7 @@ const char* parse_syntax(const char* p)
script->syntax.curly[script->syntax.curly_count].flag = 0;
sprintf(label,"$@__SW%x_VAL",script->syntax.curly[script->syntax.curly_count].index);
script->syntax.curly_count++;
- script->addl(script->add_str("set"));
+ script->addl(script->add_str("__setr"));
script->addc(C_ARG);
script->addl(script->add_str(label));
p=script->parse_expr(p);
@@ -1810,10 +1787,6 @@ const char* parse_syntax(const char* p)
}
script->addc(C_FUNC);
return p + 1;
-#ifdef ENABLE_CASE_CHECK
- } else if( p2 - p == 6 && strncasecmp(p, "switch", 6) == 0 ) {
- disp_deprecation_message("parse_syntax", "switch", p); // TODO
-#endif // ENABLE_CASE_CHECK
}
break;
case 'w':
@@ -1837,17 +1810,13 @@ const char* parse_syntax(const char* p)
// Skip to the end point if the condition is false
sprintf(label,"__WL%x_FIN",script->syntax.curly[script->syntax.curly_count].index);
script->syntax.curly_count++;
- script->addl(script->add_str("jump_zero"));
+ script->addl(script->add_str("__jump_zero"));
script->addc(C_ARG);
p=script->parse_expr(p);
p=script->skip_space(p);
script->addl(script->add_str(label));
script->addc(C_FUNC);
return p;
-#ifdef ENABLE_CASE_CHECK
- } else if( p2 - p == 5 && strncasecmp(p, "while", 5) == 0 ) {
- disp_deprecation_message("parse_syntax", "while", p); // TODO
-#endif // ENABLE_CASE_CHECK
}
break;
}
@@ -1909,7 +1878,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
disp_error_message("need '('",p);
}
sprintf(label,"__IF%x_%x",script->syntax.curly[pos].index,script->syntax.curly[pos].count);
- script->addl(script->add_str("jump_zero"));
+ script->addl(script->add_str("__jump_zero"));
script->addc(C_ARG);
p=script->parse_expr(p);
p=script->skip_space(p);
@@ -1917,10 +1886,6 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
script->addc(C_FUNC);
*flag = 0;
return p;
-#ifdef ENABLE_CASE_CHECK
- } else if( p2 - p == 2 && strncasecmp(p, "if", 2) == 0 ) {
- disp_deprecation_message("parse_syntax", "if", p); // TODO
-#endif // ENABLE_CASE_CHECK
} else {
// else
if(!script->syntax.curly[pos].flag) {
@@ -1929,10 +1894,6 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
return p;
}
}
-#ifdef ENABLE_CASE_CHECK
- } else if( !script->syntax.curly[pos].flag && p2 - p == 4 && strncasecmp(p, "else", 4) == 0 ) {
- disp_deprecation_message("parse_syntax", "else", p); // TODO
-#endif // ENABLE_CASE_CHECK
}
// Close if
script->syntax.curly_count--;
@@ -1959,9 +1920,6 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
p = script->skip_space(p);
p2 = script->skip_word(p);
if( p2 - p != 5 || strncmp(p, "while", 5) != 0 ) {
-#ifdef ENABLE_CASE_CHECK
- if( p2 - p == 5 && strncasecmp(p, "while", 5) == 0 ) disp_deprecation_message("parse_syntax", "while", p); // TODO
-#endif // ENABLE_CASE_CHECK
disp_error_message("parse_syntax: need 'while'",p);
}
@@ -1974,7 +1932,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
script->parse_nextline(false, p);
sprintf(label,"__DO%x_FIN",script->syntax.curly[pos].index);
- script->addl(script->add_str("jump_zero"));
+ script->addl(script->add_str("__jump_zero"));
script->addc(C_ARG);
p=script->parse_expr(p);
p=script->skip_space(p);
@@ -2908,7 +2866,7 @@ int set_reg(struct script_state* st, TBL_PC* sd, int64 num, const char* name, co
}
} else {
ShowError("script_set_reg: cannot write instance variable '%s', NPC not in a instance!\n", name);
- script_reportsrc(st);
+ script->reportsrc(st);
}
return 1;
default:
@@ -2974,7 +2932,7 @@ int set_reg(struct script_state* st, TBL_PC* sd, int64 num, const char* name, co
}
} else {
ShowError("script_set_reg: cannot write instance variable '%s', NPC not in a instance!\n", name);
- script_reportsrc(st);
+ script->reportsrc(st);
}
return 1;
default:
@@ -4184,7 +4142,9 @@ int script_config_read(char *cfgName) {
else if(strcmpi(w1,"import")==0) {
script->config_read(w2);
}
- else {
+ else if(HPM->parseConf(w1, w2, HPCT_SCRIPT)) {
+ ; // handled by plugin
+ } else {
ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
}
}
@@ -5681,7 +5641,7 @@ BUILDIN(copyarray);
/// The value is converted to the type of the variable.
///
/// set(<variable>,<value>) -> <variable>
-BUILDIN(setr) {
+BUILDIN(__setr) {
TBL_PC* sd = NULL;
struct script_data* data;
//struct script_data* datavalue;
@@ -5691,7 +5651,7 @@ BUILDIN(setr) {
data = script_getdata(st,2);
//datavalue = script_getdata(st,3);
- if( !data_isreference(data) || reference_toconstant(data) ) {
+ if (!data_isreference(data) || reference_toconstant(data)) {
ShowError("script:set: not a variable\n");
script->reportdata(script_getdata(st,2));
st->state = END;
@@ -5702,9 +5662,9 @@ BUILDIN(setr) {
name = reference_getname(data);
prefix = *name;
- if( not_server_variable(prefix) ) {
+ if (not_server_variable(prefix)) {
sd = script->rid2sd(st);
- if( sd == NULL ) {
+ if (sd == NULL) {
ShowError("script:set: no player attached for player variable '%s'\n", name);
return true;
}
@@ -5712,19 +5672,19 @@ BUILDIN(setr) {
#if 0
// TODO: see de43fa0f73be01080bd11c08adbfb7c158324c81
- if( data_isreference(datavalue) ) {
+ if (data_isreference(datavalue)) {
// the value being referenced is a variable
const char* namevalue = reference_getname(datavalue);
- if( !not_array_variable(*namevalue) ) {
+ if (!not_array_variable(*namevalue)) {
// array variable being copied into another array variable
- if( sd == NULL && not_server_variable(*namevalue) && !(sd = script->rid2sd(st)) ) {
+ if (sd == NULL && not_server_variable(*namevalue) && !(sd = script->rid2sd(st))) {
// player must be attached in order to copy a player variable
ShowError("script:set: no player attached for player variable '%s'\n", namevalue);
return true;
}
- if( is_string_variable(namevalue) != is_string_variable(name) ) {
+ if (is_string_variable(namevalue) != is_string_variable(name)) {
// non-matching array value types
ShowWarning("script:set: two array variables do not match in type.\n");
return true;
@@ -5739,9 +5699,9 @@ BUILDIN(setr) {
}
#endif
- if( script_hasdata(st, 4) ) {
+ if (script_hasdata(st, 4)) {
// Optional argument used by post-increment/post-decrement constructs to return the previous value
- if( is_string_variable(name) ) {
+ if (is_string_variable(name)) {
script_pushstrcopy(st, script_getstr(st, 4));
} else {
script_pushint(st, script_getnum(st, 4));
@@ -5751,7 +5711,7 @@ BUILDIN(setr) {
script_pushcopy(st,2);
}
- if( is_string_variable(name) )
+ if (is_string_variable(name))
script->set_reg(st,sd,num,name,(void*)script_getstr(st,3),script_getref(st,2));
else
script->set_reg(st,sd,num,name,(void*)h64BPTRSIZE(script_getnum(st,3)),script_getref(st,2));
@@ -7013,28 +6973,25 @@ BUILDIN(delitem) {
TBL_PC *sd;
struct item it;
- if( script_hasdata(st,4) )
- {
+ if (script_hasdata(st,4)) {
int account_id = script_getnum(st,4);
sd = map->id2sd(account_id); // <account id>
- if( sd == NULL )
- {
+ if (sd == NULL) {
ShowError("script:delitem: player not found (AID=%d).\n", account_id);
st->state = END;
return false;
}
- }
- else
- {
+ } else {
sd = script->rid2sd(st);// attached player
- if( sd == NULL )
+ if (sd == NULL)
return true;
}
- if( script_isstringtype(st, 2) ) {
+ memset(&it, 0, sizeof(it));
+ if (script_isstringtype(st, 2)) {
const char* item_name = script_getstr(st, 2);
struct item_data* id = itemdb->search_name(item_name);
- if( id == NULL ) {
+ if (id == NULL) {
ShowError("script:delitem: unknown item \"%s\".\n", item_name);
st->state = END;
return false;
@@ -7042,8 +6999,7 @@ BUILDIN(delitem) {
it.nameid = id->nameid;// "<item name>"
} else {
it.nameid = script_getnum(st, 2);// <item id>
- if( !itemdb->exists( it.nameid ) )
- {
+ if (!itemdb->exists(it.nameid)) {
ShowError("script:delitem: unknown item \"%d\".\n", it.nameid);
st->state = END;
return false;
@@ -7074,26 +7030,25 @@ BUILDIN(delitem2) {
TBL_PC *sd;
struct item it;
- if( script_hasdata(st,11) ) {
+ if (script_hasdata(st,11)) {
int account_id = script_getnum(st,11);
sd = map->id2sd(account_id); // <account id>
- if( sd == NULL ) {
+ if (sd == NULL) {
ShowError("script:delitem2: player not found (AID=%d).\n", account_id);
st->state = END;
return false;
}
- }
- else
- {
+ } else {
sd = script->rid2sd(st);// attached player
if( sd == NULL )
return true;
}
- if( script_isstringtype(st, 2) ) {
+ memset(&it, 0, sizeof(it));
+ if (script_isstringtype(st, 2)) {
const char* item_name = script_getstr(st, 2);
struct item_data* id = itemdb->search_name(item_name);
- if( id == NULL ) {
+ if (id == NULL) {
ShowError("script:delitem2: unknown item \"%s\".\n", item_name);
st->state = END;
return false;
@@ -7407,6 +7362,49 @@ BUILDIN(getguildmasterid)
}
/*==========================================
+ * Get the information of the members of a guild by type.
+ * getguildmember <guild_id>{,<type>};
+ * @param guild_id: ID of guild
+ * @param type:
+ * 0 : name (default)
+ * 1 : character ID
+ * 2 : account ID
+ *------------------------------------------*/
+BUILDIN(getguildmember)
+{
+ struct guild *g = NULL;
+ int j = 0;
+
+ g = guild->search(script_getnum(st,2));
+
+ if (g) {
+ int i, type = 0;
+
+ if (script_hasdata(st,3))
+ type = script_getnum(st,3);
+
+ for ( i = 0; i < MAX_GUILD; i++ ) {
+ if ( g->member[i].account_id ) {
+ switch (type) {
+ case 2:
+ mapreg->setreg(reference_uid(script->add_str("$@guildmemberaid"), j),g->member[i].account_id);
+ break;
+ case 1:
+ mapreg->setreg(reference_uid(script->add_str("$@guildmembercid"), j), g->member[i].char_id);
+ break;
+ default:
+ mapreg->setregstr(reference_uid(script->add_str("$@guildmembername$"), j), g->member[i].name);
+ break;
+ }
+ j++;
+ }
+ }
+ }
+ mapreg->setreg(script->add_str("$@guildmembercount"), j);
+ return true;
+}
+
+/*==========================================
* Get char string information by type :
* Return by @type :
* 0 : char_name
@@ -7615,6 +7613,29 @@ BUILDIN(getbrokenid)
}
/*==========================================
+ * getbrokencount
+ *------------------------------------------*/
+BUILDIN(getbrokencount)
+{
+ int i, counter = 0;
+ TBL_PC *sd;
+
+ sd = script->rid2sd(st);
+
+ if (sd == NULL)
+ return true;
+
+ for (i = 0; i < MAX_INVENTORY; i++) {
+ if (sd->status.inventory[i].attribute)
+ counter++;
+ }
+
+ script_pushint(st, counter);
+
+ return true;
+}
+
+/*==========================================
* repair [Valaris]
*------------------------------------------*/
BUILDIN(repair)
@@ -8569,10 +8590,10 @@ BUILDIN(checkfalcon)
TBL_PC* sd;
sd = script->rid2sd(st);
- if( sd == NULL )
+ if (sd == NULL)
return true;// no player attached, report source
- if( pc_isfalcon(sd) )
+ if (pc_isfalcon(sd))
script_pushint(st, 1);
else
script_pushint(st, 0);
@@ -8587,59 +8608,147 @@ BUILDIN(checkfalcon)
/// setfalcon;
BUILDIN(setfalcon)
{
- int flag = 1;
+ bool flag = true;
TBL_PC* sd;
sd = script->rid2sd(st);
- if( sd == NULL )
+ if (sd == NULL)
return true;// no player attached, report source
- if( script_hasdata(st,2) )
- flag = script_getnum(st,2);
+ if (script_hasdata(st,2))
+ flag = script_getnum(st,2) ? true : false;
pc->setfalcon(sd, flag);
return true;
}
-/// Returns if the player is riding.
-///
-/// checkriding() -> <bool>
-///
-/// @author Valaris
-BUILDIN(checkriding)
+enum setmount_type {
+ SETMOUNT_TYPE_AUTODETECT = -1,
+ SETMOUNT_TYPE_NONE = 0,
+ SETMOUNT_TYPE_PECO = 1,
+ SETMOUNT_TYPE_WUG = 2,
+ SETMOUNT_TYPE_MADO = 3,
+ SETMOUNT_TYPE_DRAGON_GREEN = 4,
+ SETMOUNT_TYPE_DRAGON_BROWN = 5,
+ SETMOUNT_TYPE_DRAGON_GRAY = 6,
+ SETMOUNT_TYPE_DRAGON_BLUE = 7,
+ SETMOUNT_TYPE_DRAGON_RED = 8,
+ SETMOUNT_TYPE_MAX,
+ SETMOUNT_TYPE_DRAGON = SETMOUNT_TYPE_DRAGON_GREEN,
+};
+
+/**
+ * Checks if the player is riding a combat mount.
+ *
+ * Returns 0 if the player isn't riding, and non-zero if it is.
+ * The exact returned values are the same used as flag in setmount, except for
+ * dragons, where SETMOUNT_TYPE_DRAGON is returned, regardless of color.
+ */
+BUILDIN(checkmount)
{
TBL_PC* sd;
sd = script->rid2sd(st);
- if( sd == NULL )
- return true;// no player attached, report source
+ if (sd == NULL)
+ return true; // no player attached, report source
- if( pc_isriding(sd) || pc_isridingwug(sd) || pc_isridingdragon(sd) )
- script_pushint(st, 1);
- else
- script_pushint(st, 0);
+ if (!pc_hasmount(sd)) {
+ script_pushint(st, SETMOUNT_TYPE_NONE);
+ } else if (pc_isridingpeco(sd)) {
+ script_pushint(st, SETMOUNT_TYPE_PECO);
+ } else if (pc_isridingwug(sd)) {
+ script_pushint(st, SETMOUNT_TYPE_WUG);
+ } else if (pc_ismadogear(sd)) {
+ script_pushint(st, SETMOUNT_TYPE_MADO);
+ } else { // if (pc_isridingdragon(sd))
+ script_pushint(st, SETMOUNT_TYPE_DRAGON);
+ }
return true;
}
-/// Sets if the player is riding.
-/// <flag> defaults to 1
-///
-/// setriding <flag>;
-/// setriding;
-BUILDIN(setriding)
+/**
+ * Mounts or dismounts a combat mount.
+ *
+ * setmount <flag>;
+ * setmount;
+ *
+ * Accepted values for flag:
+ * MOUNT_NONE - dismount
+ * MOUNT_PECO - Peco Peco / Grand Peco / Gryphon (depending on the class)
+ * MOUNT_WUG - Wug (Rider)
+ * MOUNT_MADO - Mado Gear
+ * MOUNT_DRAGON - Dragon (default color)
+ * MOUNT_DRAGON_GREEN - Green Dragon
+ * MOUNT_DRAGON_BROWN - Brown Dragon
+ * MOUNT_DRAGON_GRAY - Gray Dragon
+ * MOUNT_DRAGON_BLUE - Blue Dragon
+ * MOUNT_DRAGON_RED - Red Dragon
+ *
+ * If an invalid value or no flag is specified, the appropriate mount is
+ * auto-detected. As a result of this, there is no need to specify a flag at
+ * all, unless it is a dragon color other than green.
+ */
+BUILDIN(setmount)
{
- int flag = 1;
+ int flag = SETMOUNT_TYPE_AUTODETECT;
TBL_PC* sd;
sd = script->rid2sd(st);
- if( sd == NULL )
+
+ if (sd == NULL)
return true;// no player attached, report source
- if( script_hasdata(st,2) )
+ if (script_hasdata(st,2))
flag = script_getnum(st,2);
- pc->setriding(sd, flag);
+
+ // Color variants for Rune Knight dragon mounts.
+ if (flag != SETMOUNT_TYPE_NONE) {
+ if (flag < SETMOUNT_TYPE_AUTODETECT || flag >= SETMOUNT_TYPE_MAX) {
+ ShowWarning("script_setmount: Unknown flag %d specified. Using auto-detected value.\n", flag);
+ flag = SETMOUNT_TYPE_AUTODETECT;
+ }
+ // Sanity checks and auto-detection
+ if ((sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) {
+ if (pc->checkskill(sd, RK_DRAGONTRAINING)) {
+ // Rune Knight (Dragon)
+ unsigned int option;
+ option = ( flag == SETMOUNT_TYPE_DRAGON_GREEN ? OPTION_DRAGON1 :
+ flag == SETMOUNT_TYPE_DRAGON_BROWN ? OPTION_DRAGON2 :
+ flag == SETMOUNT_TYPE_DRAGON_GRAY ? OPTION_DRAGON3 :
+ flag == SETMOUNT_TYPE_DRAGON_RED ? OPTION_DRAGON4 :
+ flag == SETMOUNT_TYPE_DRAGON_RED ? OPTION_DRAGON5 :
+ OPTION_DRAGON1); // default value
+ pc->setridingdragon(sd, option);
+ }
+ } else if ((sd->class_&MAPID_THIRDMASK) == MAPID_RANGER) {
+ // Ranger (Warg)
+ if (pc->checkskill(sd, RA_WUGRIDER))
+ pc->setridingwug(sd, true);
+ } else if ((sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC) {
+ // Mechanic (Mado Gear)
+ if (pc->checkskill(sd, NC_MADOLICENCE))
+ pc->setmadogear(sd, true);
+ } else {
+ // Knight / Crusader (Peco Peco)
+ if (pc->checkskill(sd, KN_RIDING))
+ pc->setridingpeco(sd, true);
+ }
+ } else if (pc_hasmount(sd)) {
+ if (pc_isridingdragon(sd)) {
+ pc->setridingdragon(sd, 0);
+ }
+ if (pc_isridingwug(sd)) {
+ pc->setridingwug(sd, false);
+ }
+ if (pc_ismadogear(sd)) {
+ pc->setmadogear(sd, false);
+ }
+ if (pc_isridingpeco(sd)) {
+ pc->setridingpeco(sd, false);
+ }
+ }
return true;
}
@@ -8664,47 +8773,6 @@ BUILDIN(checkwug)
return true;
}
-/// Returns if the player is wearing MADO Gear.
-///
-/// checkmadogear() -> <bool>
-///
-BUILDIN(checkmadogear)
-{
- TBL_PC* sd;
-
- sd = script->rid2sd(st);
- if( sd == NULL )
- return true;// no player attached, report source
-
- if( pc_ismadogear(sd) )
- script_pushint(st, 1);
- else
- script_pushint(st, 0);
-
- return true;
-}
-
-/// Sets if the player is riding MADO Gear.
-/// <flag> defaults to 1
-///
-/// setmadogear <flag>;
-/// setmadogear;
-BUILDIN(setmadogear)
-{
- int flag = 1;
- TBL_PC* sd;
-
- sd = script->rid2sd(st);
- if( sd == NULL )
- return true;// no player attached, report source
-
- if( script_hasdata(st,2) )
- flag = script_getnum(st,2);
- pc->setmadogear(sd, flag);
-
- return true;
-}
-
/// Sets the save point of the player.
///
/// save "<map name>",<x>,<y>
@@ -9029,7 +9097,7 @@ BUILDIN(monster)
int class_ = script_getnum(st,6);
int amount = script_getnum(st,7);
const char *event = "";
- unsigned int size = SZ_MEDIUM;
+ unsigned int size = SZ_SMALL;
unsigned int ai = AI_NONE;
int mob_id;
@@ -9138,7 +9206,7 @@ BUILDIN(areamonster) {
int class_ = script_getnum(st,8);
int amount = script_getnum(st,9);
const char *event = "";
- unsigned int size = SZ_MEDIUM;
+ unsigned int size = SZ_SMALL;
unsigned int ai = AI_NONE;
int mob_id;
@@ -9939,22 +10007,62 @@ int buildin_getareausers_sub(struct block_list *bl,va_list ap)
(*users)++;
return 0;
}
+
BUILDIN(getareausers)
{
- const char *str;
- int16 m,x0,y0,x1,y1,users=0; //doubt we can have more then 32k users on
- str=script_getstr(st,2);
- x0=script_getnum(st,3);
- y0=script_getnum(st,4);
- x1=script_getnum(st,5);
- y1=script_getnum(st,6);
- if( (m=map->mapname2mapid(str))< 0) {
- script_pushint(st,-1);
- return true;
+ int16 m = -1, x0, y0, x1, y1;
+ int users = 0;
+ int idx = 2;
+
+ if (script_hasdata(st, 2) && script_isstringtype(st, 2)) {
+ const char *str = script_getstr(st, 2);
+ if ((m = map->mapname2mapid(str)) < 0) {
+ script_pushint(st, -1);
+ return true;
+ }
+ idx = 3;
+ } else {
+ TBL_PC *sd = script->rid2sd(st);
+ if (!sd) {
+ script_pushint(st, -1);
+ return false;
+ }
+ m = sd->bl.m;
+ }
+
+ if (script_hasdata(st, idx + 3)) {
+ x0 = script_getnum(st, idx + 0);
+ y0 = script_getnum(st, idx + 1);
+ x1 = script_getnum(st, idx + 2);
+ y1 = script_getnum(st, idx + 3);
+ } else if (st->oid) {
+ struct npc_data *nd = map->id2nd(st->oid);
+ if (!nd) {
+ script_pushint(st, -1);
+ return true;
+ }
+ if (script_hasdata(st, idx)) {
+ int range = script_getnum(st, idx);
+ x0 = nd->bl.x - range;
+ y0 = nd->bl.y - range;
+ x1 = nd->bl.x + range;
+ y1 = nd->bl.y + range;
+ } else if (nd->u.scr.xs != -1 && nd->u.scr.ys != -1) {
+ x0 = nd->bl.x - nd->u.scr.xs;
+ y0 = nd->bl.y - nd->u.scr.ys;
+ x1 = nd->bl.x + nd->u.scr.xs;
+ y1 = nd->bl.y + nd->u.scr.ys;
+ } else {
+ script_pushint(st, -1);
+ return true;
+ }
+ } else {
+ script_pushint(st, -1);
+ return false;
}
map->foreachinarea(script->buildin_getareausers_sub,
- m,x0,y0,x1,y1,BL_PC,&users);
- script_pushint(st,users);
+ m, x0, y0, x1, y1, BL_PC, &users);
+ script_pushint(st, users);
return true;
}
@@ -10039,117 +10147,74 @@ BUILDIN(hideonnpc)
return true;
}
-/// Starts a status effect on the target unit or on the attached player.
-///
-/// sc_start <effect_id>,<duration>,<val1>{,<unit_id>};
+/* Starts a status effect on the target unit or on the attached player.
+ *
+ * sc_start <effect_id>,<duration>,<val1>{,<rate>,<flag>,{<unit_id>}};
+ * sc_start2 <effect_id>,<duration>,<val1>,<val2>{,<rate,<flag>,{<unit_id>}};
+ * sc_start4 <effect_id>,<duration>,<val1>,<val2>,<val3>,<val4>{,<rate,<flag>,{<unit_id>}};
+ * <flag>: @see enum scstart_flag
+ */
BUILDIN(sc_start) {
+ TBL_NPC * nd = map->id2nd(st->oid);
struct block_list* bl;
enum sc_type type;
- int tick;
- int val1;
- int val4 = 0;
+ int tick, val1, val2, val3, val4=0, rate, flag;
+ char start_type;
+ const char* command = script->getfuncname(st);
+
+ if(strstr(command, "4"))
+ start_type = 4;
+ else if(strstr(command, "2"))
+ start_type = 2;
+ else
+ start_type = 1;
type = (sc_type)script_getnum(st,2);
tick = script_getnum(st,3);
val1 = script_getnum(st,4);
- if( script_hasdata(st,5) )
- bl = map->id2bl(script_getnum(st,5));
- else
- bl = map->id2bl(st->rid);
-
- if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status->sc2skill(type) != 0 ) {
- // When there isn't a duration specified, try to get it from the skill_db
- tick = skill->get_time(status->sc2skill(type), val1);
- }
- if( script->potion_flag == 1 && script->potion_target ) {
- //skill.c set the flags before running the script, this must be a potion-pitched effect.
- bl = map->id2bl(script->potion_target);
- tick /= 2;// Thrown potions only last half.
- val4 = 1;// Mark that this was a thrown sc_effect
- }
-
- if( bl )
- status->change_start(NULL, bl, type, 10000, val1, 0, 0, val4, tick, 2);
+ //If from NPC we make default flag SCFLAG_NOAVOID to be unavoidable
+ if(nd && nd->bl.id == npc->fake_nd->bl.id)
+ flag = script_hasdata(st,5+start_type) ? script_getnum(st,5+start_type) : SCFLAG_FIXEDTICK;
+ else
+ flag = script_hasdata(st,5+start_type) ? script_getnum(st,5+start_type) : SCFLAG_NOAVOID;
- return true;
-}
+ rate = script_hasdata(st,4+start_type)?min(script_getnum(st,4+start_type),10000):10000;
-/// Starts a status effect on the target unit or on the attached player.
-///
-/// sc_start2 <effect_id>,<duration>,<val1>,<percent chance>{,<unit_id>};
-BUILDIN(sc_start2) {
- struct block_list* bl;
- enum sc_type type;
- int tick;
- int val1;
- int val4 = 0;
- int rate;
-
- type = (sc_type)script_getnum(st,2);
- tick = script_getnum(st,3);
- val1 = script_getnum(st,4);
- rate = script_getnum(st,5);
- if( script_hasdata(st,6) )
- bl = map->id2bl(script_getnum(st,6));
+ if(script_hasdata(st,(6+start_type)))
+ bl = map->id2bl(script_getnum(st,(6+start_type)));
else
bl = map->id2bl(st->rid);
- if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status->sc2skill(type) != 0 ) {
- // When there isn't a duration specified, try to get it from the skill_db
+ if(tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status->sc2skill(type) != 0)
+ {// When there isn't a duration specified, try to get it from the skill_db
tick = skill->get_time(status->sc2skill(type), val1);
}
- if( script->potion_flag == 1 && script->potion_target ) {
- //skill.c set the flags before running the script, this must be a potion-pitched effect.
+ if(script->potion_flag == 1 && script->potion_target) { //skill.c set the flags before running the script, this is a potion-pitched effect.
bl = map->id2bl(script->potion_target);
tick /= 2;// Thrown potions only last half.
val4 = 1;// Mark that this was a thrown sc_effect
}
- if( bl )
- status->change_start(NULL, bl, type, rate, val1, 0, 0, val4, tick, 2);
-
- return true;
-}
-
-/// Starts a status effect on the target unit or on the attached player.
-///
-/// sc_start4 <effect_id>,<duration>,<val1>,<val2>,<val3>,<val4>{,<unit_id>};
-BUILDIN(sc_start4) {
- struct block_list* bl;
- enum sc_type type;
- int tick;
- int val1;
- int val2;
- int val3;
- int val4;
-
- type = (sc_type)script_getnum(st,2);
- tick = script_getnum(st,3);
- val1 = script_getnum(st,4);
- val2 = script_getnum(st,5);
- val3 = script_getnum(st,6);
- val4 = script_getnum(st,7);
- if( script_hasdata(st,8) )
- bl = map->id2bl(script_getnum(st,8));
- else
- bl = map->id2bl(st->rid);
-
- if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status->sc2skill(type) != 0 ) {
- // When there isn't a duration specified, try to get it from the skill_db
- tick = skill->get_time(status->sc2skill(type), val1);
- }
+ if(!bl)
+ return true;
- if( script->potion_flag == 1 && script->potion_target ) {
- //skill.c set the flags before running the script, this must be a potion-pitched effect.
- bl = map->id2bl(script->potion_target);
- tick /= 2;// Thrown potions only last half.
+ switch(start_type) {
+ case 1:
+ status->change_start(bl, bl, type, rate, val1, 0, 0, val4, tick, flag);
+ break;
+ case 2:
+ val2 = script_getnum(st,5);
+ status->change_start(bl, bl, type, rate, val1, val2, 0, val4, tick, flag);
+ break;
+ case 4:
+ val2 = script_getnum(st,5);
+ val3 = script_getnum(st,6);
+ val4 = script_getnum(st,7);
+ status->change_start(bl, bl, type, rate, val1, val2, val3, val4, tick, flag);
+ break;
}
-
- if( bl )
- status->change_start(NULL, bl, type, 10000, val1, val2, val3, val4, tick, 2);
-
return true;
}
@@ -10215,7 +10280,7 @@ BUILDIN(getscrate) {
bl = map->id2bl(st->rid);
if (bl)
- rate = status->get_sc_def(bl, bl, (sc_type)type, 10000, 10000, 0);
+ rate = status->get_sc_def(bl, bl, (sc_type)type, 10000, 10000, SCFLAG_NONE);
script_pushint(st,rate);
return true;
@@ -10568,40 +10633,57 @@ BUILDIN(changebase) {
return true;
}
- if(sd->disguise == -1 && vclass != sd->vd.class_) {
- status->set_viewdata(&sd->bl, vclass);
- //Updated client view. Base, Weapon and Cloth Colors.
- clif->changelook(&sd->bl,LOOK_BASE,sd->vd.class_);
- clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
- if (sd->vd.cloth_color)
- clif->changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color);
- clif->skillinfoblock(sd);
- }
+ if(sd->disguise == -1 && vclass != sd->vd.class_)
+ pc->changelook(sd,LOOK_BASE,vclass); //Updated client view. Base, Weapon and Cloth Colors.
return true;
}
+static TBL_PC *prepareChangeSex(struct script_state* st)
+{
+ int i;
+ TBL_PC *sd = script->rid2sd(st);
+
+ if (sd == NULL)
+ return NULL;
+
+ pc->resetskill(sd, 4);
+ // to avoid any problem with equipment and invalid sex, equipment is unequiped.
+ for (i=0; i<EQI_MAX; i++)
+ if (sd->equip_index[i] >= 0) pc->unequipitem(sd, sd->equip_index[i], 3);
+ return sd;
+}
+
/*==========================================
* Unequip all item and request for a changesex to char-serv
*------------------------------------------*/
BUILDIN(changesex)
{
- int i;
- TBL_PC *sd = NULL;
- sd = script->rid2sd(st);
-
- if( sd == NULL )
+ TBL_PC *sd = prepareChangeSex(st);
+ if (sd == NULL)
return false;
-
- pc->resetskill(sd,4);
- // to avoid any problem with equipment and invalid sex, equipment is unequiped.
- for( i=0; i<EQI_MAX; i++ )
- if( sd->equip_index[i] >= 0 ) pc->unequipitem(sd, sd->equip_index[i], 3);
chrif->changesex(sd);
return true;
}
/*==========================================
+ * Unequip all items and change character sex [4144]
+ *------------------------------------------*/
+BUILDIN(changecharsex)
+{
+ TBL_PC *sd = prepareChangeSex(st);
+ if (sd == NULL)
+ return false;
+ if (sd->status.sex == 99)
+ sd->status.sex = 0;
+ sd->status.sex = sd->status.sex ? 0 : 1;
+ chrif->save(sd, 0);
+ if (sd->fd)
+ clif->authfail_fd(sd->fd, 15);
+ return true;
+}
+
+/*==========================================
* Works like 'announce' but outputs in the common chat window
*------------------------------------------*/
BUILDIN(globalmes) {
@@ -12315,23 +12397,26 @@ BUILDIN(petloot)
* @inventorylist_card(0..3), @inventorylist_expire
* @inventorylist_count = scalar
*------------------------------------------*/
-BUILDIN(getinventorylist)
-{
+BUILDIN(getinventorylist){
TBL_PC *sd=script->rid2sd(st);
char card_var[NAME_LENGTH];
int i,j=0,k;
if(!sd) return true;
+
for(i=0;i<MAX_INVENTORY;i++) {
if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].amount > 0) {
pc->setreg(sd,reference_uid(script->add_str("@inventorylist_id"), j),sd->status.inventory[i].nameid);
pc->setreg(sd,reference_uid(script->add_str("@inventorylist_amount"), j),sd->status.inventory[i].amount);
- pc->setreg(sd,reference_uid(script->add_str("@inventorylist_equip"), j),sd->status.inventory[i].equip);
+ if(sd->status.inventory[i].equip) {
+ pc->setreg(sd,reference_uid(script->add_str("@inventorylist_equip"), j),pc->equippoint(sd,i));
+ } else {
+ pc->setreg(sd,reference_uid(script->add_str("@inventorylist_equip"), j),0);
+ }
pc->setreg(sd,reference_uid(script->add_str("@inventorylist_refine"), j),sd->status.inventory[i].refine);
pc->setreg(sd,reference_uid(script->add_str("@inventorylist_identify"), j),sd->status.inventory[i].identify);
pc->setreg(sd,reference_uid(script->add_str("@inventorylist_attribute"), j),sd->status.inventory[i].attribute);
- for (k = 0; k < MAX_SLOTS; k++)
- {
+ for (k = 0; k < MAX_SLOTS; k++) {
sprintf(card_var, "@inventorylist_card%d",k+1);
pc->setreg(sd,reference_uid(script->add_str(card_var), j),sd->status.inventory[i].card[k]);
}
@@ -12344,6 +12429,34 @@ BUILDIN(getinventorylist)
return true;
}
+BUILDIN(getcartinventorylist){
+ TBL_PC *sd=script->rid2sd(st);
+ char card_var[NAME_LENGTH];
+
+ int i,j=0,k;
+ if(!sd) return true;
+
+ for(i=0;i<MAX_CART;i++) {
+ if(sd->status.cart[i].nameid > 0 && sd->status.cart[i].amount > 0) {
+ pc->setreg(sd,reference_uid(script->add_str("@cartinventorylist_id"), j),sd->status.cart[i].nameid);
+ pc->setreg(sd,reference_uid(script->add_str("@cartinventorylist_amount"), j),sd->status.cart[i].amount);
+ pc->setreg(sd,reference_uid(script->add_str("@cartinventorylist_equip"), j),sd->status.cart[i].equip);
+ pc->setreg(sd,reference_uid(script->add_str("@cartinventorylist_refine"), j),sd->status.cart[i].refine);
+ pc->setreg(sd,reference_uid(script->add_str("@cartinventorylist_identify"), j),sd->status.cart[i].identify);
+ pc->setreg(sd,reference_uid(script->add_str("@cartinventorylist_attribute"), j),sd->status.cart[i].attribute);
+ for (k = 0; k < MAX_SLOTS; k++) {
+ sprintf(card_var, "@cartinventorylist_card%d",k+1);
+ pc->setreg(sd,reference_uid(script->add_str(card_var), j),sd->status.cart[i].card[k]);
+ }
+ pc->setreg(sd,reference_uid(script->add_str("@cartinventorylist_expire"), j),sd->status.cart[i].expire_time);
+ pc->setreg(sd,reference_uid(script->add_str("@cartinventorylist_bound"), j),sd->status.cart[i].bound);
+ j++;
+ }
+ }
+ pc->setreg(sd,script->add_str("@cartinventorylist_count"),j);
+ return true;
+}
+
BUILDIN(getskilllist)
{
TBL_PC *sd=script->rid2sd(st);
@@ -12629,46 +12742,6 @@ BUILDIN(petrecovery)
}
/*==========================================
- * pet healing [Valaris] //Rewritten by [Skotlex]
- *------------------------------------------*/
-BUILDIN(petheal)
-{
- struct pet_data *pd;
- TBL_PC *sd=script->rid2sd(st);
-
- if(sd==NULL || sd->pd==NULL)
- return true;
-
- pd=sd->pd;
- if (pd->s_skill)
- { //Clear previous skill
- if (pd->s_skill->timer != INVALID_TIMER)
- {
- if (pd->s_skill->id)
- timer->delete(pd->s_skill->timer, pet->skill_support_timer);
- else
- timer->delete(pd->s_skill->timer, pet->heal_timer);
- }
- } else //init memory
- pd->s_skill = (struct pet_skill_support *) aMalloc(sizeof(struct pet_skill_support));
-
- pd->s_skill->id=0; //This id identifies that it IS petheal rather than pet_skillsupport
- //Use the lv as the amount to heal
- pd->s_skill->lv=script_getnum(st,2);
- pd->s_skill->delay=script_getnum(st,3);
- pd->s_skill->hp=script_getnum(st,4);
- pd->s_skill->sp=script_getnum(st,5);
-
- //Use delay as initial offset to avoid skill/heal exploits
- if (battle_config.pet_equip_required && pd->pet.equip == 0)
- pd->s_skill->timer = INVALID_TIMER;
- else
- pd->s_skill->timer = timer->add(timer->gettick()+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0);
-
- return true;
-}
-
-/*==========================================
* pet attack skills [Valaris] //Rewritten by [Skotlex]
*------------------------------------------*/
/// petskillattack <skill id>,<level>,<rate>,<bonusrate>
@@ -12731,17 +12804,15 @@ BUILDIN(petskillsupport) {
return true;
pd=sd->pd;
- if (pd->s_skill)
- { //Clear previous skill
- if (pd->s_skill->timer != INVALID_TIMER)
- {
- if (pd->s_skill->id)
- timer->delete(pd->s_skill->timer, pet->skill_support_timer);
- else
- timer->delete(pd->s_skill->timer, pet->heal_timer);
+ if (pd->s_skill) {
+ //Clear previous skill
+ if (pd->s_skill->timer != INVALID_TIMER) {
+ timer->delete(pd->s_skill->timer, pet->skill_support_timer);
}
- } else //init memory
+ } else {
+ //init memory
pd->s_skill = (struct pet_skill_support *) aMalloc(sizeof(struct pet_skill_support));
+ }
pd->s_skill->id=( script_isstringtype(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
pd->s_skill->lv=script_getnum(st,3);
@@ -13094,14 +13165,14 @@ BUILDIN(checkequipedcard)
return true;
}
-BUILDIN(jump_zero)
+BUILDIN(__jump_zero)
{
int sel;
sel=script_getnum(st,2);
- if(!sel) {
+ if (!sel) {
int pos;
- if( !data_islabel(script_getdata(st,3)) ) {
- ShowError("script: jump_zero: not label !\n");
+ if (!data_islabel(script_getdata(st,3))) {
+ ShowError("script: jump_zero: not a label !\n");
st->state=END;
return false;
}
@@ -13220,6 +13291,112 @@ BUILDIN(npcstop) {
return true;
}
+// set click npc distance [4144]
+BUILDIN(setnpcdistance) {
+ struct npc_data *nd = (struct npc_data *) map->id2bl (st->oid);
+ if (!nd)
+ return false;
+
+ nd->area_size = script_getnum(st, 2);
+
+ return true;
+}
+
+// return current npc direction [4144]
+BUILDIN(getnpcdir)
+{
+ struct npc_data *nd = 0;
+
+ if (script_hasdata(st, 2))
+ {
+ nd = npc->name2id (script_getstr(st, 2));
+ }
+ if (!nd && !st->oid)
+ {
+ script_pushint(st, -1);
+ return true;
+ }
+
+ if (!nd)
+ nd = (struct npc_data *) map->id2bl (st->oid);
+
+ if (!nd)
+ {
+ script_pushint(st, -1);
+ return true;
+ }
+
+ script_pushint(st, (int)nd->dir);
+
+ return true;
+}
+
+// set npc direction [4144]
+BUILDIN(setnpcdir)
+{
+ int newdir;
+ struct npc_data *nd = 0;
+
+ if (script_hasdata(st, 3))
+ {
+ nd = npc->name2id (script_getstr(st, 2));
+ newdir = script_getnum(st, 3);
+ }
+ else if (script_hasdata(st, 2))
+ {
+ if (!st->oid)
+ return false;
+
+ nd = (struct npc_data *) map->id2bl (st->oid);
+ newdir = script_getnum(st, 2);
+ }
+ if (!nd)
+ return false;
+
+ if (newdir < 0)
+ newdir = 0;
+ else if (newdir > 7)
+ newdir = 7;
+
+ nd->dir = newdir;
+ if (nd->ud)
+ nd->ud->dir = newdir;
+
+ clif->clearunit_area(&nd->bl, CLR_OUTSIGHT);
+ clif->spawn(&nd->bl);
+
+ return true;
+}
+
+// return npc class [4144]
+BUILDIN(getnpcclass)
+{
+ struct npc_data *nd = 0;
+
+ if (script_hasdata(st, 2))
+ {
+ nd = npc->name2id (script_getstr(st, 2));
+ }
+ if (!nd && !st->oid)
+ {
+ script_pushint(st, -1);
+ return false;
+ }
+
+ if (!nd)
+ nd = (struct npc_data *) map->id2bl(st->oid);
+
+ if (!nd)
+ {
+ script_pushint(st, -1);
+ return false;
+ }
+
+ script_pushint(st, (int)nd->class_);
+
+ return true;
+}
+
/*==========================================
* getlook char info. getlook(arg)
@@ -13496,7 +13673,7 @@ BUILDIN(summon)
clif->skill_poseffect(&sd->bl,AM_CALLHOMUN,1,sd->bl.x,sd->bl.y,tick);
- md = mob->once_spawn_sub(&sd->bl, sd->bl.m, sd->bl.x, sd->bl.y, str, class_, event, SZ_MEDIUM, AI_NONE);
+ md = mob->once_spawn_sub(&sd->bl, sd->bl.m, sd->bl.x, sd->bl.y, str, class_, event, SZ_SMALL, AI_NONE);
if (md) {
md->master_id=sd->bl.id;
md->special_state.ai = AI_ATTACK;
@@ -13791,6 +13968,57 @@ BUILDIN(autoequip)
return true;
}
+/*=======================================================
+ * Equip2
+ * equip2 <item id>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>;
+ *-------------------------------------------------------*/
+BUILDIN(equip2)
+{
+ int i,nameid,ref,attr,c0,c1,c2,c3;
+ struct item_data *item_data;
+ TBL_PC *sd;
+
+ sd = script->rid2sd(st);
+
+ if ( sd == NULL ) {
+ script_pushint(st,0);
+ return true;
+ }
+
+ nameid = script_getnum(st,2);
+ if( (item_data = itemdb->exists(nameid)) == NULL )
+ {
+ ShowError("Wrong item ID : equip2(%i)\n",nameid);
+ script_pushint(st,0);
+ return false;
+ }
+
+ ref = script_getnum(st,3);
+ attr = script_getnum(st,4);
+ c0 = (short)script_getnum(st,5);
+ c1 = (short)script_getnum(st,6);
+ c2 = (short)script_getnum(st,7);
+ c3 = (short)script_getnum(st,8);
+
+ ARR_FIND( 0, MAX_INVENTORY, i,( sd->status.inventory[i].equip == 0 &&
+ sd->status.inventory[i].nameid == nameid &&
+ sd->status.inventory[i].refine == ref &&
+ sd->status.inventory[i].attribute == attr &&
+ sd->status.inventory[i].card[0] == c0 &&
+ sd->status.inventory[i].card[1] == c1 &&
+ sd->status.inventory[i].card[2] == c2 &&
+ sd->status.inventory[i].card[3] == c3 ) );
+
+ if( i < MAX_INVENTORY ) {
+ script_pushint(st,1);
+ pc->equipitem(sd,i,item_data->equip);
+ }
+ else
+ script_pushint(st,0);
+
+ return true;
+}
+
BUILDIN(setbattleflag)
{
const char *flag, *value;
@@ -14499,7 +14727,7 @@ BUILDIN(replacestr)
}
if(script_hasdata(st, 6)) {
- if (!script_isinttype(st, 5) || (count = script_getnum(st, 6) == 0)) {
+ if (!script_isinttype(st, 6) || (count = script_getnum(st, 6)) == 0) {
ShowError("script:replacestr: Invalid count value. Expected int.\n");
st->state = END;
return false;
@@ -14729,6 +14957,36 @@ BUILDIN(distance)
// <--- [zBuffer] List of mathematics commands
+BUILDIN(min)
+{
+ int i, min;
+
+ min = script_getnum(st, 2);
+ for (i = 3; script_hasdata(st, i); i++) {
+ int next = script_getnum(st, i);
+ if (next < min)
+ min = next;
+ }
+ script_pushint(st, min);
+
+ return true;
+}
+
+BUILDIN(max)
+{
+ int i, max;
+
+ max = script_getnum(st, 2);
+ for (i = 3; script_hasdata(st, i); i++) {
+ int next = script_getnum(st, i);
+ if (next > max)
+ max = next;
+ }
+ script_pushint(st, max);
+
+ return true;
+}
+
BUILDIN(md5)
{
const char *tmpstr;
@@ -15658,8 +15916,6 @@ BUILDIN(unittalk) {
StrBuf->Init(&sbuf);
StrBuf->Printf(&sbuf, "%s : %s", status->get_name(bl), message);
clif->disp_overhead(bl, StrBuf->Value(&sbuf));
- if( bl->type == BL_PC )
- clif->message(((TBL_PC*)bl)->fd, StrBuf->Value(&sbuf));
StrBuf->Destroy(&sbuf);
}
@@ -15909,8 +16165,7 @@ BUILDIN(warpportal) {
struct block_list* bl;
bl = map->id2bl(st->oid);
- if( bl == NULL )
- {
+ if( bl == NULL ) {
ShowError("script:warpportal: npc is needed\n");
return false;
}
@@ -15924,6 +16179,9 @@ BUILDIN(warpportal) {
if( map_index == 0 )
return true;// map not found
+ if( bl->type == BL_NPC )
+ unit->bl2ud2(bl); // ensure nd->ud is safe to edit
+
group = skill->unitsetting(bl, AL_WARP, 4, spx, spy, 0);
if( group == NULL )
return true;// failed
@@ -16058,7 +16316,7 @@ BUILDIN(mercenary_sc_start) {
tick = script_getnum(st,3);
val1 = script_getnum(st,4);
- status->change_start(NULL, &sd->md->bl, type, 10000, val1, 0, 0, 0, tick, 2);
+ status->change_start(NULL, &sd->md->bl, type, 10000, val1, 0, 0, 0, tick, SCFLAG_FIXEDTICK);
return true;
}
@@ -16281,21 +16539,45 @@ BUILDIN(setquest) {
BUILDIN(erasequest) {
struct map_session_data *sd = script->rid2sd(st);
+ int quest_id;
if( sd == NULL )
return false;
- quest->delete(sd, script_getnum(st, 2));
+ if (script_hasdata(st, 3)) {
+ if (script_getnum(st, 3) < script_getnum(st, 2)) {
+ ShowError("buildin_erasequest: The second quest id must be greater than the id of the first.\n");
+ return false;
+ }
+ for (quest_id = script_getnum(st, 2); quest_id < script_getnum(st, 3); quest_id++) {
+ quest->delete(sd, quest_id);
+ }
+ } else {
+ quest->delete(sd, script_getnum(st, 2));
+ }
+
return true;
}
BUILDIN(completequest) {
struct map_session_data *sd = script->rid2sd(st);
+ int quest_id;
if( sd == NULL )
return false;
- quest->update_status(sd, script_getnum(st, 2), Q_COMPLETE);
+ if (script_hasdata(st, 3)) {
+ if (script_getnum(st, 3) < script_getnum(st, 2)) {
+ ShowError("buildin_completequest: The second quest id must be greater than the id of the first.\n");
+ return false;
+ }
+ for (quest_id = script_getnum(st, 2); quest_id < script_getnum(st, 3); quest_id++) {
+ quest->update_status(sd, quest_id, Q_COMPLETE);
+ }
+ } else {
+ quest->update_status(sd, script_getnum(st, 2), Q_COMPLETE);
+ }
+
return true;
}
@@ -16309,17 +16591,46 @@ BUILDIN(changequest) {
return true;
}
-BUILDIN(checkquest) {
+BUILDIN(questactive) {
+ struct map_session_data *sd = script->rid2sd(st);
+ int quest_progress = 0;
+
+ if (sd == NULL)
+ return false;
+
+ if (quest->check(sd, script_getnum(st, 2), HAVEQUEST) == Q_ACTIVE)
+ script_pushint(st, 1);
+ else
+ script_pushint(st, 0);
+
+ script_pushint(st, quest_progress);
+
+ return true;
+}
+
+BUILDIN(questprogress) {
struct map_session_data *sd = script->rid2sd(st);
enum quest_check_type type = HAVEQUEST;
+ int quest_progress = 0;
- if( sd == NULL )
+ if (sd == NULL)
return false;
- if( script_hasdata(st, 3) )
+ if (script_hasdata(st, 3))
type = (enum quest_check_type)script_getnum(st, 3);
- script_pushint(st, quest->check(sd, script_getnum(st, 2), type));
+ quest_progress = quest->check(sd, script_getnum(st, 2), type);
+
+ // "Fix" returned quest state value to make more sense.
+ // 0 = Not Started, 1 = In Progress, 2 = Completed.
+ if (quest_progress == -1) // Not found
+ quest_progress = 0;
+ else if (quest_progress == 0 || quest_progress == 1)
+ quest_progress = 1;
+ else
+ quest_progress = 2;
+
+ script_pushint(st, quest_progress);
return true;
}
@@ -16977,6 +17288,63 @@ BUILDIN(instance_check_party) {
}
/*==========================================
+ * instance_check_guild
+ * Values:
+ * guild_id : Guild ID of the invoking character. [Required Parameter]
+ * amount : Amount of needed Guild Members for the Instance. [Optional Parameter]
+ * min : Minimum Level needed to join the Instance. [Optional Parameter]
+ * max : Maxium Level allowed to join the Instance. [Optional Parameter]
+ * Example: instance_check_guild (getcharid(2){,amount}{,min}{,max});
+ * Example 2: instance_check_guild (getcharid(2),1,1,99);
+ *------------------------------------------*/
+BUILDIN(instance_check_guild){
+ struct map_session_data *pl_sd;
+ int amount, min, max, i, guild_id, c = 0;
+ struct guild *g = NULL;
+
+ amount = script_hasdata(st,3) ? script_getnum(st,3) : 1;
+ min = script_hasdata(st,4) ? script_getnum(st,4) : 1;
+ max = script_hasdata(st,5) ? script_getnum(st,5) : MAX_LEVEL;
+
+ if( min < 1 || min > MAX_LEVEL ){
+ ShowError("instance_check_guild: Invalid min level, %d\n", min);
+ return true;
+ } else if( max < 1 || max > MAX_LEVEL ){
+ ShowError("instance_check_guild: Invalid max level, %d\n", max);
+ return true;
+ }
+
+ if( script_hasdata(st,2) )
+ guild_id = script_getnum(st,2);
+ else return true;
+
+ if( !(g = guild->search(guild_id)) ){
+ script_pushint(st,0);
+ return true;
+ }
+
+ for( i = 0; i < MAX_GUILD; i++ )
+ if( (pl_sd = g->member[i].sd) )
+ if( map->id2bl(pl_sd->bl.id) ){
+ if( pl_sd->status.base_level < min ){
+ script_pushint(st,0);
+ return true;
+ } else if( pl_sd->status.base_level > max ){
+ script_pushint(st,0);
+ return true;
+ }
+ c++;
+ }
+
+ if( c < amount )
+ script_pushint(st,0);
+ else
+ script_pushint(st,1);
+
+ return true;
+}
+
+/*==========================================
* Custom Fonts
*------------------------------------------*/
BUILDIN(setfont)
@@ -17215,63 +17583,12 @@ BUILDIN(makerune) {
sd->itemid = script_getnum(st,2);
return true;
}
-/**
- * checkdragon() returns 1 if mounting a dragon or 0 otherwise.
- **/
-BUILDIN(checkdragon) {
- TBL_PC* sd;
- if( (sd = script->rid2sd(st)) == NULL )
- return true;
- if( pc_isridingdragon(sd) )
- script_pushint(st,1);
- else
- script_pushint(st,0);
- return true;
-}
-/**
- * setdragon({optional Color}) returns 1 on success or 0 otherwise
- * - Toggles the dragon on a RK if he can mount;
- * @param Color - when not provided uses the green dragon;
- * - 1 : Green Dragon
- * - 2 : Brown Dragon
- * - 3 : Gray Dragon
- * - 4 : Blue Dragon
- * - 5 : Red Dragon
- **/
-BUILDIN(setdragon) {
- TBL_PC* sd;
- int color = script_hasdata(st,2) ? script_getnum(st,2) : 0;
-
- if( (sd = script->rid2sd(st)) == NULL )
- return true;
- if( !pc->checkskill(sd,RK_DRAGONTRAINING) || (sd->class_&MAPID_THIRDMASK) != MAPID_RUNE_KNIGHT )
- script_pushint(st,0);//Doesn't have the skill or it's not a Rune Knight
- else if ( pc_isridingdragon(sd) ) {//Is mounted; release
- pc->setoption(sd, sd->sc.option&~OPTION_DRAGON);
- script_pushint(st,1);
- } else {//Not mounted; Mount now.
- unsigned int option = OPTION_DRAGON1;
- if( color ) {
- option = ( color == 1 ? OPTION_DRAGON1 :
- color == 2 ? OPTION_DRAGON2 :
- color == 3 ? OPTION_DRAGON3 :
- color == 4 ? OPTION_DRAGON4 :
- color == 5 ? OPTION_DRAGON5 : 0);
- if( !option ) {
- ShowWarning("script_setdragon: Unknown Color %d used; changing to green (1)\n",color);
- option = OPTION_DRAGON1;
- }
- }
- pc->setoption(sd, sd->sc.option|option);
- script_pushint(st,1);
- }
- return true;
-}
/**
- * ismounting() returns 1 if mounting a new mount or 0 otherwise
+ * hascashmount() returns 1 if mounting a cash mount or 0 otherwise
**/
-BUILDIN(ismounting) {
+BUILDIN(hascashmount)
+{
TBL_PC* sd;
if( (sd = script->rid2sd(st)) == NULL )
return true;
@@ -17283,20 +17600,22 @@ BUILDIN(ismounting) {
}
/**
- * setmounting() returns 1 on success or 0 otherwise
- * - Toggles new mounts on a player when he can mount
- * - Will fail if the player is mounting a non-new mount, e.g. dragon, peco, wug, etc.
- * - Will unmount the player is he is already mounting
+ * setcashmount() returns 1 on success or 0 otherwise
+ *
+ * - Toggles cash mounts on a player when he can mount
+ * - Will fail if the player is already riding a standard mount e.g. dragon, peco, wug, mado, etc.
+ * - Will unmount the player is he is already mounting a cash mount
**/
-BUILDIN(setmounting) {
+BUILDIN(setcashmount)
+{
TBL_PC* sd;
- if( (sd = script->rid2sd(st)) == NULL )
+ if ((sd = script->rid2sd(st)) == NULL)
return true;
- if( sd->sc.option&(OPTION_WUGRIDER|OPTION_RIDING|OPTION_DRAGON|OPTION_MADOGEAR) ) {
+ if (pc_hasmount(sd)) {
clif->msgtable(sd->fd, 0X78b);
script_pushint(st,0);//can't mount with one of these
} else {
- if( sd->sc.data[SC_ALL_RIDING] )
+ if (sd->sc.data[SC_ALL_RIDING])
status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
else
sc_start(NULL,&sd->bl, SC_ALL_RIDING, 100, 0, -1);
@@ -17304,6 +17623,7 @@ BUILDIN(setmounting) {
}
return true;
}
+
/**
* Retrieves quantity of arguments provided to callfunc/callsub.
* getargcount() -> amount of arguments received in a function
@@ -17786,6 +18106,7 @@ BUILDIN(montransform) {
struct block_list* bl;
char msg[CHAT_SIZE_MAX];
int mob_id, val1, val2, val3, val4;
+ val1 = val2 = val3 = val4 = 0;
if( (bl = map->id2bl(st->rid)) == NULL )
return true;
@@ -17805,12 +18126,17 @@ BUILDIN(montransform) {
}
tick = script_getnum(st, 3);
- type = (sc_type)script_getnum(st, 4);
- val1 = val2 = val3 = val4 = 0;
- if( !(type > SC_NONE && type < SC_MAX) ) {
- ShowWarning("buildin_montransform: Unsupported status change id %d\n", type);
- return false;
+ if (script_hasdata(st, 4))
+ type = (sc_type)script_getnum(st, 4);
+ else
+ type = SC_NONE;
+
+ if (script_hasdata(st, 4)) {
+ if( !(type > SC_NONE && type < SC_MAX) ) {
+ ShowWarning("buildin_montransform: Unsupported status change id %d\n", type);
+ return false;
+ }
}
if (script_hasdata(st, 5))
@@ -17846,8 +18172,11 @@ BUILDIN(montransform) {
clif->ShowScript(&sd->bl, msg);
status_change_end(bl, SC_MONSTER_TRANSFORM, INVALID_TIMER); // Clear previous
sc_start2(NULL, bl, SC_MONSTER_TRANSFORM, 100, mob_id, type, tick);
- sc_start4(NULL, bl, type, 100, val1, val2, val3, val4, tick);
+
+ if (script_hasdata(st, 4))
+ sc_start4(NULL, bl, type, 100, val1, val2, val3, val4, tick);
}
+
return true;
}
@@ -18311,6 +18640,55 @@ BUILDIN(countbound)
return 0;
}
+/*==========================================
+ * checkbound(<item_id>{,<bound_type>{,<refine>{,<attribute>{,<card_1>{,<card_2>{,<card_3>{,<card_4>}}}}}}});
+ * Checks to see if specified item is in inventory.
+ * Returns the bound type of item found.
+ * Type:
+ * 1 - Account Bound
+ * 2 - Guild Bound
+ * 3 - Party Bound
+ * 4 - Character Bound
+ *------------------------------------------*/
+BUILDIN(checkbound){
+ int i, nameid = script_getnum(st,2);
+ int bound_type = 0, ref, attr, c1, c2, c3, c4;
+ TBL_PC *sd;
+
+ sd = script->rid2sd(st);
+ if( sd == NULL )
+ return false;
+
+ if( !(itemdb->exists(nameid)) ){
+ ShowError("script_checkbound: Invalid item ID = %d\n", nameid);
+ return false;
+ }
+
+ if (script_hasdata(st,3))
+ bound_type = script_getnum(st,3);
+
+ if( bound_type <= -1 || bound_type > IBT_MAX ){
+ ShowError("script_checkbound: Not a valid bind type! Type=%d\n", bound_type);
+ }
+
+ ARR_FIND( 0, MAX_INVENTORY, i, (sd->status.inventory[i].nameid == nameid &&
+ ( sd->status.inventory[i].refine == (script_hasdata(st,4)? (ref = script_getnum(st,4)) : sd->status.inventory[i].refine) ) &&
+ ( sd->status.inventory[i].attribute == (script_hasdata(st,5)? (attr = script_getnum(st,5)) : sd->status.inventory[i].attribute) ) &&
+ ( sd->status.inventory[i].card[0] == (script_hasdata(st,6)? (c1 = script_getnum(st,6)) : sd->status.inventory[i].card[0]) ) &&
+ ( sd->status.inventory[i].card[1] == (script_hasdata(st,7)? (c2 = script_getnum(st,7)) : sd->status.inventory[i].card[1]) ) &&
+ ( sd->status.inventory[i].card[2] == (script_hasdata(st,8)? (c3 = script_getnum(st,8)) : sd->status.inventory[i].card[2]) ) &&
+ ( sd->status.inventory[i].card[3] == (script_hasdata(st,9)? (c4 = script_getnum(st,9)) : sd->status.inventory[i].card[3]) ) &&
+ ((sd->status.inventory[i].bound > 0 && !bound_type) || sd->status.inventory[i].bound == bound_type )) );
+
+ if( i < MAX_INVENTORY ){
+ script_pushint(st, sd->status.inventory[i].bound);
+ return true;
+ } else
+ script_pushint(st,0);
+
+ return true;
+}
+
/* bg_match_over( arena_name {, optional canceled } ) */
/* returns 0 when successful, 1 otherwise */
BUILDIN(bg_match_over) {
@@ -18737,7 +19115,7 @@ bool script_add_builtin(const struct script_function *buildin, bool override) {
script->buildin[offset] = NULL;
} else {
// Adding new function
- if( strcmp(buildin->name, "setr") == 0 ) script->buildin_set_ref = n;
+ if( strcmp(buildin->name, "__setr") == 0 ) script->buildin_set_ref = n;
else if( strcmp(buildin->name, "callsub") == 0 ) script->buildin_callsub_ref = n;
else if( strcmp(buildin->name, "callfunc") == 0 ) script->buildin_callfunc_ref = n;
else if( strcmp(buildin->name, "getelementofarray") == 0 ) script->buildin_getelementofarray_ref = n;
@@ -18753,6 +19131,7 @@ bool script_add_builtin(const struct script_function *buildin, bool override) {
}
script->str_data[n].func = buildin->func;
+ script->str_data[n].deprecated = (buildin->deprecated ? 1 : 0);
/* we only store the arguments, its the only thing used out of this */
if( slen ) {
@@ -18765,18 +19144,25 @@ bool script_add_builtin(const struct script_function *buildin, bool override) {
return true;
}
-bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st)) {
+bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st), bool isDeprecated) {
struct script_function buildin;
buildin.name = name;
buildin.arg = args;
buildin.func = func;
+ buildin.deprecated = isDeprecated;
return script->add_builtin(&buildin, true);
}
-#define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args }
-#define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args }
+#define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args, false }
+#define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args, false }
+#define BUILDIN_DEF_DEPRECATED(x,args) { buildin_ ## x , #x , args, true }
+#define BUILDIN_DEF2_DEPRECATED(x,x2,args) { buildin_ ## x , x2 , args, true }
void script_parse_builtin(void) {
struct script_function BUILDIN[] = {
+ /* Commands for internal use by the script engine */
+ BUILDIN_DEF(__jump_zero,"il"),
+ BUILDIN_DEF(__setr,"rv?"),
+
// NPC interaction
BUILDIN_DEF(mes,"s*"),
BUILDIN_DEF(next,""),
@@ -18801,8 +19187,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(warpguild,"siii"), // [Fredzilla]
BUILDIN_DEF(setlook,"ii"),
BUILDIN_DEF(changelook,"ii"), // Simulates but don't Store it
- BUILDIN_DEF2(setr,"set","rv"),
- BUILDIN_DEF(setr,"rv?"), // Not meant to be used directly, required for var++/var--
+ BUILDIN_DEF2(__setr,"set","rv"),
BUILDIN_DEF(setarray,"rv*"),
BUILDIN_DEF(cleararray,"rvi"),
BUILDIN_DEF(copyarray,"rri"),
@@ -18838,11 +19223,13 @@ void script_parse_builtin(void) {
BUILDIN_DEF(getguildname,"i"),
BUILDIN_DEF(getguildmaster,"i"),
BUILDIN_DEF(getguildmasterid,"i"),
+ BUILDIN_DEF(getguildmember,"i?"),
BUILDIN_DEF(strcharinfo,"i"),
BUILDIN_DEF(strnpcinfo,"i"),
BUILDIN_DEF(getequipid,"i"),
BUILDIN_DEF(getequipname,"i"),
BUILDIN_DEF(getbrokenid,"i"), // [Valaris]
+ BUILDIN_DEF(getbrokencount,""),
BUILDIN_DEF(repair,"i"), // [Valaris]
BUILDIN_DEF(repairall,""),
BUILDIN_DEF(getequipisequiped,"i"),
@@ -18879,12 +19266,10 @@ void script_parse_builtin(void) {
BUILDIN_DEF(checkcart,""),
BUILDIN_DEF(setfalcon,"?"),
BUILDIN_DEF(checkfalcon,""),
- BUILDIN_DEF(setriding,"?"),
- BUILDIN_DEF(checkriding,""),
+ BUILDIN_DEF(setmount,"?"),
+ BUILDIN_DEF(checkmount,""),
BUILDIN_DEF(checkwug,""),
- BUILDIN_DEF(checkmadogear,""),
- BUILDIN_DEF(setmadogear,"?"),
- BUILDIN_DEF2(savepoint,"save","sii"),
+ BUILDIN_DEF2_DEPRECATED(savepoint,"save","sii"), // Deprecated 2014-11-02 [Haru]
BUILDIN_DEF(savepoint,"sii"),
BUILDIN_DEF(gettimetick,"i"),
BUILDIN_DEF(gettime,"i"),
@@ -18902,7 +19287,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(clone,"siisi????"),
BUILDIN_DEF(doevent,"s"),
BUILDIN_DEF(donpcevent,"s"),
- BUILDIN_DEF(cmdothernpc,"ss"),
+ BUILDIN_DEF_DEPRECATED(cmdothernpc,"ss"), // Deprecated 2014-11-02 [Haru]
BUILDIN_DEF(addtimer,"is"),
BUILDIN_DEF(deltimer,"s"),
BUILDIN_DEF(addtimercount,"si"),
@@ -18920,15 +19305,15 @@ void script_parse_builtin(void) {
BUILDIN_DEF(getusers,"i"),
BUILDIN_DEF(getmapguildusers,"si"),
BUILDIN_DEF(getmapusers,"s"),
- BUILDIN_DEF(getareausers,"siiii"),
+ BUILDIN_DEF(getareausers,"*"),
BUILDIN_DEF(getareadropitem,"siiiiv"),
BUILDIN_DEF(enablenpc,"s"),
BUILDIN_DEF(disablenpc,"s"),
BUILDIN_DEF(hideoffnpc,"s"),
BUILDIN_DEF(hideonnpc,"s"),
- BUILDIN_DEF(sc_start,"iii?"),
- BUILDIN_DEF(sc_start2,"iiii?"),
- BUILDIN_DEF(sc_start4,"iiiiii?"),
+ BUILDIN_DEF(sc_start,"iii???"),
+ BUILDIN_DEF2(sc_start,"sc_start2","iiii???"),
+ BUILDIN_DEF2(sc_start,"sc_start4","iiiiii???"),
BUILDIN_DEF(sc_end,"i?"),
BUILDIN_DEF(getstatus, "i?"),
BUILDIN_DEF(getscrate,"ii?"),
@@ -18941,13 +19326,14 @@ void script_parse_builtin(void) {
BUILDIN_DEF(skillpointcount,""),
BUILDIN_DEF(changebase,"i?"),
BUILDIN_DEF(changesex,""),
+ BUILDIN_DEF(changecharsex,""), // [4144]
BUILDIN_DEF(waitingroom,"si?????"),
BUILDIN_DEF(delwaitingroom,"?"),
BUILDIN_DEF2(waitingroomkickall,"kickwaitingroomall","?"),
BUILDIN_DEF(enablewaitingroomevent,"?"),
BUILDIN_DEF(disablewaitingroomevent,"?"),
- BUILDIN_DEF2(enablewaitingroomevent,"enablearena",""), // Added by RoVeRT
- BUILDIN_DEF2(disablewaitingroomevent,"disablearena",""), // Added by RoVeRT
+ BUILDIN_DEF2_DEPRECATED(enablewaitingroomevent,"enablearena",""), // Deprecated 2014-11-02 [Haru]
+ BUILDIN_DEF2_DEPRECATED(disablewaitingroomevent,"disablearena",""), // Deprecated 2014-11-02 [Haru]
BUILDIN_DEF(getwaitingroomstate,"i?"),
BUILDIN_DEF(warpwaitingpc,"sii?"),
BUILDIN_DEF(attachrid,"i"),
@@ -18988,6 +19374,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(makepet,"i"),
BUILDIN_DEF(getexp,"ii"),
BUILDIN_DEF(getinventorylist,""),
+ BUILDIN_DEF(getcartinventorylist,""),
BUILDIN_DEF(getskilllist,""),
BUILDIN_DEF(clearitem,""),
BUILDIN_DEF(classchange,"ii"),
@@ -19002,7 +19389,6 @@ void script_parse_builtin(void) {
BUILDIN_DEF(petskillbonus,"iiii"), // [Valaris]
BUILDIN_DEF(petrecovery,"ii"), // [Valaris]
BUILDIN_DEF(petloot,"i"), // [Valaris]
- BUILDIN_DEF(petheal,"iiii"), // [Valaris]
BUILDIN_DEF(petskillattack,"viii"), // [Skotlex]
BUILDIN_DEF(petskillattack2,"viiii"), // [Valaris]
BUILDIN_DEF(petskillsupport,"viiii"), // [Skotlex]
@@ -19023,6 +19409,10 @@ void script_parse_builtin(void) {
BUILDIN_DEF(npcspeed,"i"), // [Valaris]
BUILDIN_DEF(npcwalkto,"ii"), // [Valaris]
BUILDIN_DEF(npcstop,""), // [Valaris]
+ BUILDIN_DEF(setnpcdistance,"i"), // [4144]
+ BUILDIN_DEF(getnpcdir,"?"), // [4144]
+ BUILDIN_DEF(setnpcdir,"*"), // [4144]
+ BUILDIN_DEF(getnpcclass,"?"), // [4144]
BUILDIN_DEF(getmapxy,"rrri?"), //by Lorky [Lupus]
BUILDIN_DEF(checkoption1,"i"),
BUILDIN_DEF(checkoption2,"i"),
@@ -19052,7 +19442,6 @@ void script_parse_builtin(void) {
BUILDIN_DEF(gethominfo,"i"),
BUILDIN_DEF(getmercinfo,"i?"),
BUILDIN_DEF(checkequipedcard,"i"),
- BUILDIN_DEF(jump_zero,"il"), //for future jA script compatibility
BUILDIN_DEF(globalmes,"s?"), //end jA addition
BUILDIN_DEF(unequip,"i"), // unequip command [Spectre]
BUILDIN_DEF(getstrlen,"s"), //strlen [Valaris]
@@ -19083,6 +19472,8 @@ void script_parse_builtin(void) {
BUILDIN_DEF(pow,"ii"),
BUILDIN_DEF(distance,"iiii"),
// <--- [zBuffer] List of mathematics commands
+ BUILDIN_DEF(min, "i*"),
+ BUILDIN_DEF(max, "i*"),
BUILDIN_DEF(md5,"s"),
// [zBuffer] List of dynamic var commands --->
BUILDIN_DEF(getd,"s"),
@@ -19096,6 +19487,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(npcshopattach,"s?"),
BUILDIN_DEF(equip,"i"),
BUILDIN_DEF(autoequip,"ii"),
+ BUILDIN_DEF(equip2,"iiiiiii"),
BUILDIN_DEF(setbattleflag,"si"),
BUILDIN_DEF(getbattleflag,"s"),
BUILDIN_DEF(setitemscript,"is?"), //Set NEW item bonus script. Lupus
@@ -19196,6 +19588,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(has_instance,"s?"),
BUILDIN_DEF(instance_warpall,"sii?"),
BUILDIN_DEF(instance_check_party,"i???"),
+ BUILDIN_DEF(instance_check_guild,"i???"),
BUILDIN_DEF(instance_mapname,"s?"),
BUILDIN_DEF(instance_set_respawn,"sii?"),
BUILDIN_DEF2(has_instance,"has_instance2","s"),
@@ -19204,10 +19597,8 @@ void script_parse_builtin(void) {
* 3rd-related
**/
BUILDIN_DEF(makerune,"i"),
- BUILDIN_DEF(checkdragon,""),//[Ind]
- BUILDIN_DEF(setdragon,"?"),//[Ind]
- BUILDIN_DEF(ismounting,""),//[Ind]
- BUILDIN_DEF(setmounting,""),//[Ind]
+ BUILDIN_DEF(hascashmount,""),//[Ind]
+ BUILDIN_DEF(setcashmount,""),//[Ind]
BUILDIN_DEF(checkre,"i"),
/**
* rAthena and beyond!
@@ -19236,13 +19627,15 @@ void script_parse_builtin(void) {
BUILDIN_DEF2(getitem,"getitembound","vii?"),
BUILDIN_DEF2(getitem2,"getitembound2","viiiiiiiii?"),
BUILDIN_DEF(countbound, "?"),
+ BUILDIN_DEF(checkbound, "i???????"),
//Quest Log System [Inkfish]
BUILDIN_DEF(questinfo, "ii??"),
BUILDIN_DEF(setquest, "i"),
- BUILDIN_DEF(erasequest, "i"),
- BUILDIN_DEF(completequest, "i"),
- BUILDIN_DEF(checkquest, "i?"),
+ BUILDIN_DEF(erasequest, "i?"),
+ BUILDIN_DEF(completequest, "i?"),
+ BUILDIN_DEF(questprogress, "i?"),
+ BUILDIN_DEF(questactive, "i"),
BUILDIN_DEF(changequest, "ii"),
BUILDIN_DEF(showevent, "i?"),
@@ -19266,7 +19659,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(stand, "?"),
BUILDIN_DEF(issit, "?"),
- BUILDIN_DEF(montransform, "vii????"), // Monster Transform [malufett/Hercules]
+ BUILDIN_DEF(montransform, "vi?????"), // Monster Transform [malufett/Hercules]
/* New BG Commands [Hercules] */
BUILDIN_DEF(bg_create_team,"sii"),
@@ -19320,6 +19713,7 @@ void script_hardcoded_constants(void) {
script->set_constant("MAX_ZENY",MAX_ZENY,false);
script->set_constant("MAX_BG_MEMBERS",MAX_BG_MEMBERS,false);
script->set_constant("MAX_CHAT_USERS",MAX_CHAT_USERS,false);
+ script->set_constant("MAX_REFINE",MAX_REFINE,false);
/* status options */
script->set_constant("Option_Nothing",OPTION_NOTHING,false);
@@ -19609,8 +20003,9 @@ void script_defaults(void) {
script->config.loadmap_event_name = "OnPCLoadMapEvent";
script->config.baselvup_event_name = "OnPCBaseLvUpEvent";
script->config.joblvup_event_name = "OnPCJobLvUpEvent";
- script->config.ontouch_name = "OnTouch_";//ontouch_name (runs on first visible char to enter area, picks another char if the first char leaves)
- script->config.ontouch2_name = "OnTouch";//ontouch2_name (run whenever a char walks into the OnTouch area)
+ script->config.ontouch_name = "OnTouch_"; //ontouch_name (runs on first visible char to enter area, picks another char if the first char leaves)
+ script->config.ontouch2_name = "OnTouch"; //ontouch2_name (run whenever a char walks into the OnTouch area)
+ script->config.onuntouch_name = "OnUnTouch"; //onuntouch_name (run whenever a char walks from the OnTouch area)
// for ENABLE_CASE_CHECK
script->calc_hash_ci = calc_hash_ci;
diff --git a/src/map/script.h b/src/map/script.h
index 48abf1487..548c0f261 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -26,9 +26,9 @@ struct eri;
// TODO: Remove temporary code
#define ENABLE_CASE_CHECK
#define get_script_source(source) ((source) ? (source) : "Unknown (Possibly source or variables stored in database")
-#define DeprecationWarning(func, bad, good, file, line) ShowError("%s: use of deprecated keyword '%s' (use '%s' instead) in file '%s', line '%d'.\n", (func), (bad), (good), get_script_source(file), (line));
-#define DeprecationWarning2(func, bad, good, where) ShowError("%s: detected possible use of wrong case in a script. Found '%s', probably meant to be '%s' (in '%s').\n", (func), (bad), (good), get_script_source(where));
-#define disp_deprecation_message(func, good, p) disp_warning_message(func": use of deprecated keyword (use '"good"' instead).", (p));
+#define DeprecationCaseWarning(func, bad, good, where) ShowError("%s: detected possible use of wrong case in a script. Found '%s', probably meant to be '%s' (in '%s').\n", (func), (bad), (good), get_script_source(where))
+
+#define DeprecationWarning(p) disp_warning_message("This command is deprecated and it will be removed in a future update. Please see the script documentation for an alternative.\n", (p))
#define NUM_WHISPER_VAR 10
@@ -187,7 +187,7 @@ typedef enum c_op {
C_USERFUNC, // internal script function
C_USERFUNC_POS, // internal script function label
C_REF, // the next call to c_op2 should push back a ref to the left operand
-
+
// operators
C_OP3, // a ? b : c
C_LOR, // a || b
@@ -265,7 +265,7 @@ enum e_arglist {
*------------------------------------------*/
enum {
- MF_NOMEMO, //0
+ MF_NOMEMO, //0
MF_NOTELEPORT,
MF_NOSAVE,
MF_NOBRANCH,
@@ -275,7 +275,7 @@ enum {
MF_PVP_NOPARTY,
MF_PVP_NOGUILD,
MF_GVG,
- MF_GVG_NOPARTY, //10
+ MF_GVG_NOPARTY, //10
MF_NOTRADE,
MF_NOSKILL,
MF_NOWARP,
@@ -293,7 +293,7 @@ enum {
MF_GVG_DUNGEON,
MF_NIGHTENABLED,
MF_NOBASEEXP,
- MF_NOJOBEXP, //30
+ MF_NOJOBEXP, //30
MF_NOMOBLOOT,
MF_NOMVPLOOT,
MF_NORETURN,
@@ -303,7 +303,7 @@ enum {
MF_NOCOMMAND,
MF_NODROP,
MF_JEXP,
- MF_BEXP, //40
+ MF_BEXP, //40
MF_NOVENDING,
MF_LOADEVENT,
MF_NOCHAT,
@@ -313,7 +313,7 @@ enum {
MF_AUTOTRADE,
MF_ALLOWKS,
MF_MONSTER_NOTELEPORT,
- MF_PVP_NOCALCRANK, //50
+ MF_PVP_NOCALCRANK, //50
MF_BATTLEGROUND,
MF_RESET,
MF_NOTOMB,
@@ -343,6 +343,7 @@ struct Script_Config {
const char* ontouch_name;
const char* ontouch2_name;
+ const char* onuntouch_name;
};
/**
@@ -433,6 +434,7 @@ struct script_function {
bool (*func)(struct script_state *st);
char *name;
char *arg;
+ bool deprecated;
};
// String buffer structures.
@@ -445,6 +447,7 @@ struct str_data_struct {
bool (*func)(struct script_state *st);
int val;
int next;
+ uint8 deprecated : 1;
};
struct script_label_entry {
@@ -458,9 +461,9 @@ struct script_syntax_data {
int count;
int flag;
struct linkdb_node *case_label;
- } curly[256]; // Information right parenthesis
- int curly_count; // The number of right brackets
- int index; // Number of the syntax used in the script
+ } curly[256]; // Information right parenthesis
+ int curly_count; // The number of right brackets
+ int index; // Number of the syntax used in the script
};
struct casecheck_data {
@@ -574,7 +577,7 @@ struct script_interface {
void (*error) (const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos);
void (*warning) (const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos);
/* */
- bool (*addScript) (char *name, char *args, bool (*func)(struct script_state *st));
+ bool (*addScript) (char *name, char *args, bool (*func)(struct script_state *st), bool isDeprecated);
int (*conv_num) (struct script_state *st,struct script_data *data);
const char* (*conv_str) (struct script_state *st,struct script_data *data);
TBL_PC *(*rid2sd) (struct script_state *st);
diff --git a/src/map/searchstore.c b/src/map/searchstore.c
index 72b28aacd..782c14987 100644
--- a/src/map/searchstore.c
+++ b/src/map/searchstore.c
@@ -333,7 +333,7 @@ bool searchstore_result(struct map_session_data* sd, unsigned int store_id, int
void searchstore_defaults (void) {
searchstore = &searchstore_s;
-
+
searchstore->open = searchstore_open;
searchstore->query = searchstore_query;
searchstore->querynext = searchstore_querynext;
@@ -344,5 +344,5 @@ void searchstore_defaults (void) {
searchstore->queryremote = searchstore_queryremote;
searchstore->clearremote = searchstore_clearremote;
searchstore->result = searchstore_result;
-
+
}
diff --git a/src/map/skill.c b/src/map/skill.c
index b82c47a69..5eb319c02 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -45,7 +45,7 @@
#include "../common/timer.h"
#include "../common/utils.h"
-#define SKILLUNITTIMER_INTERVAL 100
+#define SKILLUNITTIMER_INTERVAL 100
// ranges reserved for mapping skill ids to skilldb offsets
#define HM_SKILLRANGEMIN 750
@@ -145,49 +145,49 @@ void skill_chk(uint16* skill_id) {
} while(0)
#define skill_glv(lv) min((lv),MAX_SKILL_LEVEL-1)
// Skill DB
-int skill_get_hit( uint16 skill_id ) { skill_get (skill->db[skill_id].hit, skill_id); }
-int skill_get_inf( uint16 skill_id ) { skill_get (skill->db[skill_id].inf, skill_id); }
-int skill_get_ele( uint16 skill_id , uint16 skill_lv ) { skill_get (skill->db[skill_id].element[skill_glv(skill_lv-1)], skill_id); }
-int skill_get_nk( uint16 skill_id ) { skill_get (skill->db[skill_id].nk, skill_id); }
-int skill_get_max( uint16 skill_id ) { skill_get (skill->db[skill_id].max, skill_id); }
-int skill_get_range( uint16 skill_id , uint16 skill_lv ) { skill_get2 (skill->db[skill_id].range[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_splash( uint16 skill_id , uint16 skill_lv ) { skill_get2 ( (skill->db[skill_id].splash[skill_glv(skill_lv-1)]>=0?skill->db[skill_id].splash[skill_glv(skill_lv-1)]:AREA_SIZE), skill_id, skill_lv); }
-int skill_get_hp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].hp[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_sp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].sp[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_hp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].hp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_sp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].sp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_state(uint16 skill_id) { skill_get (skill->db[skill_id].state, skill_id); }
-int skill_get_spiritball(uint16 skill_id, uint16 skill_lv) { skill_get2 (skill->db[skill_id].spiritball[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_itemid(uint16 skill_id, int idx) { skill_get (skill->db[skill_id].itemid[idx], skill_id); }
-int skill_get_itemqty(uint16 skill_id, int idx) { skill_get (skill->db[skill_id].amount[idx], skill_id); }
-int skill_get_zeny( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].zeny[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_num( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].num[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_cast( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].cast[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_delay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].delay[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].walkdelay[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_time( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].upkeep_time[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_time2( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].upkeep_time2[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_castdef( uint16 skill_id ) { skill_get (skill->db[skill_id].cast_def_rate, skill_id); }
-int skill_get_weapontype( uint16 skill_id ) { skill_get (skill->db[skill_id].weapon, skill_id); }
-int skill_get_ammotype( uint16 skill_id ) { skill_get (skill->db[skill_id].ammo, skill_id); }
-int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].ammo_qty[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_inf2( uint16 skill_id ) { skill_get (skill->db[skill_id].inf2, skill_id); }
-int skill_get_castcancel( uint16 skill_id ) { skill_get (skill->db[skill_id].castcancel, skill_id); }
-int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].maxcount[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].blewcount[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_mhp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].mhp[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_castnodex( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].castnodex[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_delaynodex( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill->db[skill_id].delaynodex[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_type( uint16 skill_id ) { skill_get (skill->db[skill_id].skill_type, skill_id); }
-int skill_get_unit_id ( uint16 skill_id, int flag ){ skill_get (skill->db[skill_id].unit_id[flag], skill_id); }
-int skill_get_unit_interval( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_interval, skill_id); }
-int skill_get_unit_range( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].unit_range[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_unit_target( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_target&BCT_ALL, skill_id); }
-int skill_get_unit_bl_target( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_target&BL_ALL, skill_id); }
-int skill_get_unit_flag( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_flag, skill_id); }
-int skill_get_unit_layout_type( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill->db[skill_id].unit_layout_type[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_cooldown( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].cooldown[skill_glv(skill_lv-1)], skill_id, skill_lv); }
-int skill_get_fixed_cast( uint16 skill_id ,uint16 skill_lv ) {
+int skill_get_hit( uint16 skill_id ) { skill_get (skill->db[skill_id].hit, skill_id); }
+int skill_get_inf( uint16 skill_id ) { skill_get (skill->db[skill_id].inf, skill_id); }
+int skill_get_ele( uint16 skill_id , uint16 skill_lv ) { skill_get (skill->db[skill_id].element[skill_glv(skill_lv-1)], skill_id); }
+int skill_get_nk( uint16 skill_id ) { skill_get (skill->db[skill_id].nk, skill_id); }
+int skill_get_max( uint16 skill_id ) { skill_get (skill->db[skill_id].max, skill_id); }
+int skill_get_range( uint16 skill_id , uint16 skill_lv ) { skill_get2 (skill->db[skill_id].range[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_splash( uint16 skill_id , uint16 skill_lv ) { skill_get2 ( (skill->db[skill_id].splash[skill_glv(skill_lv-1)]>=0?skill->db[skill_id].splash[skill_glv(skill_lv-1)]:AREA_SIZE), skill_id, skill_lv); }
+int skill_get_hp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].hp[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_sp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].sp[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_hp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].hp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_sp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].sp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_state(uint16 skill_id) { skill_get (skill->db[skill_id].state, skill_id); }
+int skill_get_spiritball(uint16 skill_id, uint16 skill_lv) { skill_get2 (skill->db[skill_id].spiritball[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_itemid(uint16 skill_id, int idx) { skill_get (skill->db[skill_id].itemid[idx], skill_id); }
+int skill_get_itemqty(uint16 skill_id, int idx) { skill_get (skill->db[skill_id].amount[idx], skill_id); }
+int skill_get_zeny( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].zeny[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_num( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].num[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_cast( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].cast[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_delay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].delay[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].walkdelay[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_time( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].upkeep_time[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_time2( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].upkeep_time2[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_castdef( uint16 skill_id ) { skill_get (skill->db[skill_id].cast_def_rate, skill_id); }
+int skill_get_weapontype( uint16 skill_id ) { skill_get (skill->db[skill_id].weapon, skill_id); }
+int skill_get_ammotype( uint16 skill_id ) { skill_get (skill->db[skill_id].ammo, skill_id); }
+int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].ammo_qty[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_inf2( uint16 skill_id ) { skill_get (skill->db[skill_id].inf2, skill_id); }
+int skill_get_castcancel( uint16 skill_id ) { skill_get (skill->db[skill_id].castcancel, skill_id); }
+int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].maxcount[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].blewcount[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_mhp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].mhp[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_castnodex( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].castnodex[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_delaynodex( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill->db[skill_id].delaynodex[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_type( uint16 skill_id ) { skill_get (skill->db[skill_id].skill_type, skill_id); }
+int skill_get_unit_id ( uint16 skill_id, int flag ){ skill_get (skill->db[skill_id].unit_id[flag], skill_id); }
+int skill_get_unit_interval( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_interval, skill_id); }
+int skill_get_unit_range( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].unit_range[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_unit_target( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_target&BCT_ALL, skill_id); }
+int skill_get_unit_bl_target( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_target&BL_ALL, skill_id); }
+int skill_get_unit_flag( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_flag, skill_id); }
+int skill_get_unit_layout_type( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill->db[skill_id].unit_layout_type[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_cooldown( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].cooldown[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_fixed_cast( uint16 skill_id ,uint16 skill_lv ) {
#ifdef RENEWAL_CAST
skill_get2 (skill->db[skill_id].fixed_cast[skill_glv(skill_lv-1)], skill_id, skill_lv);
#else
@@ -254,8 +254,10 @@ int skill_get_range2 (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
//TODO: Find a way better than hardcoding the list of skills affected by AC_VULTURE
switch( skill_id ) {
- case AC_SHOWER: case MA_SHOWER:
- case AC_DOUBLE: case MA_DOUBLE:
+ case AC_SHOWER:
+ case MA_SHOWER:
+ case AC_DOUBLE:
+ case MA_DOUBLE:
case HT_BLITZBEAT:
case AC_CHARGEARROW:
case MA_CHARGEARROW:
@@ -433,16 +435,12 @@ int can_copy (struct map_session_data *sd, uint16 skill_id, struct block_list* b
return 0;
// Couldn't preserve 3rd Class skills except only when using Reproduce skill. [Jobbie]
- if( !(sd->sc.data[SC__REPRODUCE]) && ((skill_id >= RK_ENCHANTBLADE && skill_id <= SR_RIDEINLIGHTNING) || (skill_id >= KO_YAMIKUMO && skill_id <= OB_AKAITSUKI)))
+ if( !(sd->sc.data[SC__REPRODUCE]) && ((skill_id >= RK_ENCHANTBLADE && skill_id <= LG_OVERBRAND_PLUSATK) || (skill_id >= RL_GLITTERING_GREED && skill_id <= OB_AKAITSUKI) || (skill_id >= GC_DARKCROW && skill_id <= NC_MAGMA_ERUPTION_DOTDAMAGE)))
return 0;
// Reproduce will only copy skills according on the list. [Jobbie]
else if( sd->sc.data[SC__REPRODUCE] && !skill->reproduce_db[skill->get_index(skill_id)] )
return 0;
- //Never copy new 3rd class skills By OmegaRed
- if(skill_id >= GC_DARKCROW && skill_id <= ALL_FULL_THROTTLE)
- return 0;
-
return 1;
}
@@ -457,6 +455,9 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd)
if (idx == 0)
return 1; // invalid skill id
+ if( pc_has_permission(sd, PC_PERM_DISABLE_SKILL_USAGE) )
+ return 1;
+
if (pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL))
return 0; // can do any damn thing they want
@@ -646,7 +647,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
nullpo_ret(src);
nullpo_ret(bl);
- if(skill_id > 0 && !skill_lv) return 0; // don't forget auto attacks! - celest
+ if(skill_id > 0 && !skill_lv) return 0; // don't forget auto attacks! - celest
if( dmg_lv < ATK_BLOCK ) // Don't apply effect if miss.
return 0;
@@ -695,10 +696,10 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
temp = skill->get_time2(status->sc2skill(type),7);
if (sd->addeff[i].flag&ATF_TARGET)
- status->change_start(src,bl,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,0);
+ status->change_start(src,bl,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,SCFLAG_NONE);
if (sd->addeff[i].flag&ATF_SELF)
- status->change_start(src,src,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,0);
+ status->change_start(src,src,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,SCFLAG_NONE);
}
}
@@ -713,9 +714,9 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
temp = skill->get_time2(status->sc2skill(type),7);
if( sd->addeff3[i].target&ATF_TARGET )
- status->change_start(src,bl,type,sd->addeff3[i].rate,7,0,0,0,temp,0);
+ status->change_start(src,bl,type,sd->addeff3[i].rate,7,0,0,0,temp,SCFLAG_NONE);
if( sd->addeff3[i].target&ATF_SELF )
- status->change_start(src,src,type,sd->addeff3[i].rate,7,0,0,0,temp,0);
+ status->change_start(src,src,type,sd->addeff3[i].rate,7,0,0,0,temp,SCFLAG_NONE);
}
}
}
@@ -782,7 +783,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
// Enchant Poison gives a chance to poison attacked enemies
if((sce=sc->data[SC_ENCHANTPOISON])) //Don't use sc_start since chance comes in 1/10000 rate.
status->change_start(src,bl,SC_POISON,sce->val2, sce->val1,src->id,0,0,
- skill->get_time2(AS_ENCHANTPOISON,sce->val1),0);
+ skill->get_time2(AS_ENCHANTPOISON,sce->val1),SCFLAG_NONE);
// Enchant Deadly Poison gives a chance to deadly poison attacked enemies
if((sce=sc->data[SC_EDP]))
sc_start4(src,bl,SC_DPOISON,sce->val2, sce->val1,src->id,0,0,
@@ -794,7 +795,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
case SM_BASH:
if( sd && skill_lv > 5 && pc->checkskill(sd,SM_FATALBLOW)>0 )
status->change_start(src,bl,SC_STUN,500*(skill_lv-5)*sd->status.base_level/50,
- skill_lv,0,0,0,skill->get_time2(SM_FATALBLOW,skill_lv),0);
+ skill_lv,0,0,0,skill->get_time2(SM_FATALBLOW,skill_lv),SCFLAG_NONE);
break;
case MER_CRASH:
@@ -806,8 +807,8 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
skill_lv = pc->checkskill(sd, TF_POISON);
case TF_POISON:
case AS_SPLASHER:
- if(!sc_start2(src,bl,SC_POISON,(4*skill_lv+10),skill_lv,src->id,skill->get_time2(skill_id,skill_lv))
- && sd && skill_id==TF_POISON
+ if (!sc_start2(src,bl,SC_POISON,(4*skill_lv+10),skill_lv,src->id,skill->get_time2(skill_id,skill_lv))
+ && sd && skill_id==TF_POISON
)
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
@@ -824,8 +825,9 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
#ifndef RENEWAL
case WZ_FROSTNOVA:
#endif
- if( !sc_start(src,bl,SC_FREEZE,skill_lv*3+35,skill_lv,skill->get_time2(skill_id,skill_lv))
- && sd && skill_id == MG_FROSTDIVER )
+ if (!sc_start(src,bl,SC_FREEZE,skill_lv*3+35,skill_lv,skill->get_time2(skill_id,skill_lv))
+ && sd && skill_id == MG_FROSTDIVER
+ )
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
@@ -842,9 +844,9 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
#ifdef RENEWAL
sc_start(src,bl,SC_FREEZE,65-(5*skill_lv),skill_lv,skill->get_time2(skill_id,skill_lv));
#else
- // [Tharis] pointed out that this is normal freeze chance with a base of 300%
+ //On third hit, there is a 150% to freeze the target
if(tsc->sg_counter >= 3 &&
- sc_start(src,bl,SC_FREEZE,300,skill_lv,skill->get_time2(skill_id,skill_lv)))
+ sc_start(src,bl,SC_FREEZE,150,skill_lv,skill->get_time2(skill_id,skill_lv)))
tsc->sg_counter = 0;
/**
* being it only resets on success it'd keep stacking and eventually overflowing on mvps, so we reset at a high value
@@ -984,7 +986,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
case NPC_MENTALBREAKER:
{
//Based on observations by [Tharis], Mental Breaker should do SP damage
- //equal to Matk*skLevel.
+ //equal to Matk*skLevel.
rate = status->get_matk(src, 2);
rate*=skill_lv;
status_zap(bl, 0, rate);
@@ -1010,7 +1012,8 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
case LK_SPIRALPIERCE:
case ML_SPIRALPIERCE:
- sc_start(src,bl,SC_ANKLESNARE,100,0,skill->get_time2(skill_id,skill_lv));
+ if( dstsd || ( dstmd && !is_boss(bl) ) ) //Does not work on bosses
+ sc_start(src,bl,SC_STOP,100,0,skill->get_time2(skill_id,skill_lv));
break;
case ST_REJECTSWORD:
@@ -1045,14 +1048,14 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
break;
default:
sc_start2(src,bl,SC_BLOODING,(5+skill_lv*5),skill_lv,src->id,skill->get_time2(skill_id,3));
- }
+ }
break;
case HW_NAPALMVULCAN:
sc_start(src,bl,SC_CURSE,5*skill_lv,skill_lv,skill->get_time2(skill_id,skill_lv));
break;
- case WS_CARTTERMINATION: // Cart termination
+ case WS_CARTTERMINATION:
sc_start(src,bl,SC_STUN,5*skill_lv,skill_lv,skill->get_time2(skill_id,skill_lv));
break;
@@ -1082,7 +1085,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
break;
case GS_BULLSEYE: //0.1% coma rate.
if(tstatus->race == RC_BRUTE || tstatus->race == RC_DEMIHUMAN)
- status->change_start(src,bl,SC_COMA,10,skill_lv,0,src->id,0,0,0);
+ status->change_start(src,bl,SC_COMA,10,skill_lv,0,src->id,0,0,SCFLAG_NONE);
break;
case GS_PIERCINGSHOT:
sc_start2(src,bl,SC_BLOODING,(skill_lv*3),skill_lv,src->id,skill->get_time2(skill_id,skill_lv));
@@ -1192,7 +1195,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
break;
case NC_POWERSWING:
// Use flag=2, the stun duration is not vit-reduced.
- status->change_start(src, bl, SC_STUN, 5*skill_lv*100, skill_lv, 0, 0, 0, skill->get_time(skill_id, skill_lv), 2);
+ status->change_start(src, bl, SC_STUN, 5*skill_lv*100, skill_lv, 0, 0, 0, skill->get_time(skill_id, skill_lv), SCFLAG_FIXEDTICK);
if( rnd()%100 < 5*skill_lv )
skill->castend_damage_id(src, bl, NC_AXEBOOMERANG, pc->checkskill(sd, NC_AXEBOOMERANG), tick, 1);
break;
@@ -1210,6 +1213,14 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
rate = 30 + 8 * skill_lv + sstatus->dex / 10 + (sd? sd->status.job_level:0) / 4;
sc_start(src, bl, SC_STUN, rate, skill_lv, skill->get_time(skill_id,skill_lv));
break;
+ case LG_HESPERUSLIT:
+ if ( sc && sc->data[SC_BANDING] ) {
+ if ( sc->data[SC_BANDING]->val2 == 4 ) // 4 banding RGs: Targets will be stunned at 100% chance for 4 ~ 8 seconds, irreducible by STAT.
+ status->change_start(src, bl, SC_STUN, 10000, skill_lv, 0, 0, 0, 1000*(4+rand()%4), SCFLAG_FIXEDTICK);
+ else if ( sc->data[SC_BANDING]->val2 == 6 ) // 6 banding RGs: activate Pinpoint Attack Lv1-5
+ skill->castend_damage_id(src,bl,LG_PINPOINTATTACK,1+rand()%5,tick,0);
+ }
+ break;
case LG_PINPOINTATTACK:
rate = 30 + 5 * (sd ? pc->checkskill(sd,LG_PINPOINTATTACK) : 1) + (sstatus->agi + status->get_lv(src)) / 10;
switch( skill_lv ) {
@@ -1237,7 +1248,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
else if( dstmd && !is_boss(bl) )
sc_start(src, bl,SC_STOP,100,skill_lv,skill->get_time(skill_id,skill_lv));
break;
- case LG_RAYOFGENESIS: // 50% chance to cause Blind on Undead and Demon monsters.
+ case LG_RAYOFGENESIS: // 50% chance to cause Blind on Undead and Demon monsters.
if ( battle->check_undead(tstatus->race, tstatus->def_ele) || tstatus->race == RC_DEMON )
sc_start(src, bl, SC_BLIND,50, skill_lv, skill->get_time(skill_id,skill_lv));
break;
@@ -1267,7 +1278,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
sc_start(src, bl, SC_FEAR, 5 + 5 * skill_lv, skill_lv, skill->get_time(skill_id, skill_lv));
break;
case SO_EARTHGRAVE:
- sc_start2(src, bl, SC_BLOODING, 5 * skill_lv, skill_lv, src->id, skill->get_time2(skill_id, skill_lv)); // Need official rate. [LimitLine]
+ sc_start2(src, bl, SC_BLOODING, 5 * skill_lv, skill_lv, src->id, skill->get_time2(skill_id, skill_lv)); // Need official rate. [LimitLine]
break;
case SO_DIAMONDDUST:
rate = 5 + 5 * skill_lv;
@@ -1280,7 +1291,8 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
break;
case GN_SLINGITEM_RANGEMELEEATK:
if( sd ) {
- switch( sd->itemid ) { // Starting SCs here instead of do it in skill->additional_effect to simplify the code.
+ switch( sd->itemid ) {
+ // Starting SCs here instead of do it in skill->additional_effect to simplify the code.
case ITEMID_COCONUT_BOMB:
sc_start(src, bl, SC_STUN, 100, skill_lv, 5000); // 5 seconds until I get official
sc_start(src, bl, SC_BLOODING, 100, skill_lv, 10000);
@@ -1300,7 +1312,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
sc_start(src, bl, SC_STUN, 20 + 10 * skill_lv, skill_lv, skill->get_time2(skill_id, skill_lv));
sc_start2(src, bl, SC_BLOODING, 5 + 5 * skill_lv, skill_lv, src->id,skill->get_time2(skill_id, skill_lv));
break;
- case EL_WIND_SLASH: // Non confirmed rate.
+ case EL_WIND_SLASH: // Non confirmed rate.
sc_start2(src, bl, SC_BLOODING, 25, skill_lv, src->id, skill->get_time(skill_id,skill_lv));
break;
case EL_STONE_HAMMER:
@@ -1351,10 +1363,10 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
rate += sd->weapon_coma_race[tstatus->race];
rate += sd->weapon_coma_race[tstatus->mode&MD_BOSS?RC_BOSS:RC_NONBOSS];
if (rate)
- status->change_start(src, bl, SC_COMA, rate, 0, 0, src->id, 0, 0, 0);
+ status->change_start(src, bl, SC_COMA, rate, 0, 0, src->id, 0, 0, SCFLAG_NONE);
}
- if( sd && battle_config.equip_self_break_rate )
- { // Self weapon breaking
+ if (sd && battle_config.equip_self_break_rate) {
+ // Self weapon breaking
rate = battle_config.equip_natural_break_rate;
if( sc )
{
@@ -1368,8 +1380,8 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
if( rate )
skill->break_equip(src, EQP_WEAPON, rate, BCT_SELF);
}
- if( battle_config.equip_skill_break_rate && skill_id != WS_CARTTERMINATION && skill_id != ITM_TOMAHAWK )
- { // Cart Termination/Tomahawk won't trigger breaking data. Why? No idea, go ask Gravity.
+ if (battle_config.equip_skill_break_rate && skill_id != WS_CARTTERMINATION && skill_id != ITM_TOMAHAWK) {
+ // Cart Termination/Tomahawk won't trigger breaking data. Why? No idea, go ask Gravity.
// Target weapon breaking
rate = 0;
if( sd )
@@ -1391,10 +1403,10 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
if (sd && !skill_id && bl->type == BL_PC) { // This effect does not work with skills.
if (sd->def_set_race[tstatus->race].rate)
status->change_start(src,bl, SC_DEFSET, sd->def_set_race[tstatus->race].rate, sd->def_set_race[tstatus->race].value,
- 0, 0, 0, sd->def_set_race[tstatus->race].tick, 2);
+ 0, 0, 0, sd->def_set_race[tstatus->race].tick, SCFLAG_FIXEDTICK);
if (sd->def_set_race[tstatus->race].rate)
status->change_start(src,bl, SC_MDEFSET, sd->mdef_set_race[tstatus->race].rate, sd->mdef_set_race[tstatus->race].value,
- 0, 0, 0, sd->mdef_set_race[tstatus->race].tick, 2);
+ 0, 0, 0, sd->mdef_set_race[tstatus->race].tick, SCFLAG_FIXEDTICK);
}
}
@@ -1557,7 +1569,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
monster = mob->db(class_);
} while (
(monster->status.mode&(MD_BOSS|MD_PLANT) || monster->summonper[0] <= rate) &&
- (temp++) < 2000);
+ (temp++) < 2000);
if (temp < 2000)
mob->class_change(dstmd,class_);
}
@@ -1667,14 +1679,16 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b
int rate;
struct map_session_data *sd=NULL;
struct map_session_data *dstsd=NULL;
+ struct status_change *sc;
nullpo_ret(src);
nullpo_ret(bl);
- if(skill_id > 0 && !skill_lv) return 0; // don't forget auto attacks! [celest]
+ if(skill_id > 0 && !skill_lv) return 0; // don't forget auto attacks! [celest]
sd = BL_CAST(BL_PC, src);
dstsd = BL_CAST(BL_PC, bl);
+ sc = status->get_sc(src);
if(dstsd && attack_type&BF_WEAPON) {
//Counter effects.
@@ -1696,10 +1710,10 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b
time = skill->get_time2(status->sc2skill(type),7);
if (dstsd->addeff2[i].flag&ATF_TARGET)
- status->change_start(bl,src,type,rate,7,0,0,0,time,0);
+ status->change_start(bl,src,type,rate,7,0,0,0,time,SCFLAG_NONE);
if (dstsd->addeff2[i].flag&ATF_SELF && !status->isdead(bl))
- status->change_start(bl,bl,type,rate,7,0,0,0,time,0);
+ status->change_start(bl,bl,type,rate,7,0,0,0,time,SCFLAG_NONE);
}
}
@@ -1710,7 +1724,7 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b
case GS_FULLBUSTER:
sc_start(src,src,SC_BLIND,2*skill_lv,skill_lv,skill->get_time2(skill_id,skill_lv));
break;
- case HFLI_SBR44: // [orn]
+ case HFLI_SBR44: // [orn]
case HVAN_EXPLOSION:
if(src->type == BL_HOM){
TBL_HOM *hd = (TBL_HOM*)src;
@@ -1723,6 +1737,13 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b
case NPC_GRANDDARKNESS:
attack_type |= BF_WEAPON;
break;
+ case LG_HESPERUSLIT:
+ if ( sc && sc->data[SC_FORCEOFVANGUARD] && sc->data[SC_BANDING] && sc->data[SC_BANDING]->val2 > 6 ) {
+ char i;
+ for( i = 0; i < sc->data[SC_FORCEOFVANGUARD]->val3 && sc->fv_counter <= sc->data[SC_FORCEOFVANGUARD]->val3 ; i++)
+ clif->millenniumshield(bl, sc->fv_counter++);
+ }
+ break;
}
if( sd && (sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR
@@ -1755,14 +1776,11 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b
sp += sd->bonus.magic_sp_gain_value;
hp += sd->bonus.magic_hp_gain_value;
if( skill_id == WZ_WATERBALL ) {// (bugreport:5303)
- struct status_change *sc = NULL;
- if( ( sc = status->get_sc(src) ) ) {
- if( sc->data[SC_SOULLINK]
- && sc->data[SC_SOULLINK]->val2 == SL_WIZARD
- && sc->data[SC_SOULLINK]->val3 == WZ_WATERBALL
- )
- sc->data[SC_SOULLINK]->val3 = 0; //Clear bounced spell check.
- }
+ if( sc->data[SC_SOULLINK]
+ && sc->data[SC_SOULLINK]->val2 == SL_WIZARD
+ && sc->data[SC_SOULLINK]->val3 == WZ_WATERBALL
+ )
+ sc->data[SC_SOULLINK]->val3 = 0; //Clear bounced spell check.
}
}
if( hp || sp ) {
@@ -1881,11 +1899,11 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b
return 0;
}
/*=========================================================================
- Breaks equipment. On-non players causes the corresponding strip effect.
- - rate goes from 0 to 10000 (100.00%)
- - flag is a BCT_ flag to indicate which type of adjustment should be used
- (BCT_ENEMY/BCT_PARTY/BCT_SELF) are the valid values.
---------------------------------------------------------------------------*/
+ * Breaks equipment. On-non players causes the corresponding strip effect.
+ * - rate goes from 0 to 10000 (100.00%)
+ * - flag is a BCT_ flag to indicate which type of adjustment should be used
+ * (BCT_ENEMY/BCT_PARTY/BCT_SELF) are the valid values.
+ *------------------------------------------------------------------------*/
int skill_break_equip (struct block_list *bl, unsigned short where, int rate, int flag) {
const int where_list[4] = {EQP_WEAPON, EQP_ARMOR, EQP_SHIELD, EQP_HELM};
const enum sc_type scatk[4] = {SC_NOEQUIPWEAPON, SC_NOEQUIPARMOR, SC_NOEQUIPSHIELD, SC_NOEQUIPHELM};
@@ -1904,7 +1922,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in
rate -= rate*sd->bonus.unbreakable/100;
if (where&EQP_WEAPON) {
switch (sd->status.weapon) {
- case W_FIST: //Bare fists should not break :P
+ case W_FIST: //Bare fists should not break :P
case W_1HAXE:
case W_2HAXE:
case W_MACE: // Axes and Maces can't be broken [DracoRPG]
@@ -2047,13 +2065,13 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in
if (dir == -1) // <optimized>: do the computation here instead of outside
dir = map->calc_dir(target, src->x, src->y); // direction from src to target, reversed
- if (dir >= 0 && dir < 8)
- { // take the reversed 'direction' and reverse it
+ if (dir >= 0 && dir < 8) {
+ // take the reversed 'direction' and reverse it
dx = -dirx[dir];
dy = -diry[dir];
}
- return unit->blown(target, dx, dy, count, flag); // send over the proper flag
+ return unit->blown(target, dx, dy, count, flag); // send over the proper flag
}
@@ -2109,6 +2127,7 @@ int skill_magic_reflect(struct block_list* src, struct block_list* bl, int type)
* packet shouldn't display a skill animation)
* flag&0x2000 is used to signal that the skill_lv should be passed as -1 to the
* client (causes player characters to not scream skill name)
+ * flag&0x4000 - Return 0 if damage was reflected
*-------------------------------------------------------------------------*/
int skill_attack(int attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) {
struct Damage dmg;
@@ -2122,7 +2141,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
if(skill_id > 0 && !skill_lv) return 0;
- nullpo_ret(src); // Source is the master behind the attack (player/mob/pet)
+ nullpo_ret(src); // Source is the master behind the attack (player/mob/pet)
nullpo_ret(dsrc); // dsrc is the actual originator of the damage, can be the same as src, or a skill casted by src.
nullpo_ret(bl); //Target to be attacked.
@@ -2339,14 +2358,14 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
case AC_DOUBLE:
// AC_DOUBLE can start the combo with other monster types, but the
// monster that's going to be hit by HT_POWER should be RC_BRUTE or RC_INSECT [Panikon]
- if( pc->checkskill(sd, HT_POWER) )
- {
+ if (pc->checkskill(sd, HT_POWER)) {
sc_start4(NULL,src,SC_COMBOATTACK,100,HT_POWER,0,1,0,2000);
clif->combo_delay(src,2000);
}
break;
case TK_COUNTER:
- { //bonus from SG_FRIEND [Komurka]
+ {
+ //bonus from SG_FRIEND [Komurka]
int level;
if(sd->status.party_id>0 && (level = pc->checkskill(sd,SG_FRIEND)))
party->skill_check(sd, sd->status.party_id, TK_COUNTER,level);
@@ -2373,7 +2392,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
if( pc->checkskill(sd, SR_TIGERCANNON) > 0 || pc->checkskill(sd, SR_GATEOFHELL) > 0 )
combo = 1;
break;
- } //Switch End
+ } //Switch End
if (combo) { //Possible to chain
if ( (combo = DIFF_TICK32(sd->ud.canact_tick, tick)) < 50 ) combo = 50;/* less is a waste. */
sc_start2(NULL,src,SC_COMBOATTACK,100,skill_id,bl->id,combo);
@@ -2445,6 +2464,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
case EL_HURRICANE_ATK:
case EL_TYPOON_MIS:
case EL_TYPOON_MIS_ATK:
+ case GN_CRAZYWEED_ATK:
case KO_BAKURETSU:
case NC_MAGMA_ERUPTION:
dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,skill_id,-1,5);
@@ -2455,9 +2475,6 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
case SC_FEINTBOMB:
dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,1,skill_id,skill_lv,5);
break;
- case GN_CRAZYWEED_ATK:
- dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,skill_id, -2, 6);
- break;
case EL_STONE_RAIN:
dmg.dmotion = clif->skill_damage(dsrc,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,skill_id,-1,(flag&1)?8:5);
break;
@@ -2507,11 +2524,12 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
map->freeblock_lock();
- if(damage > 0 && dmg.flag&BF_SKILL && tsd
- && pc->checkskill(tsd,RG_PLAGIARISM)
- && (!sc || !sc->data[SC_PRESERVE])
- && damage < tsd->battle_status.hp)
- { //Updated to not be able to copy skills if the blow will kill you. [Skotlex]
+ if (damage > 0 && dmg.flag&BF_SKILL && tsd
+ && pc->checkskill(tsd,RG_PLAGIARISM)
+ && (!sc || !sc->data[SC_PRESERVE])
+ && damage < tsd->battle_status.hp
+ ) {
+ //Updated to not be able to copy skills if the blow will kill you. [Skotlex]
int copy_skill = skill_id, cidx = 0;
/**
* Copy Referral: dummy skills should point to their source upon copying
@@ -2530,7 +2548,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
break;
case WM_SEVERE_RAINSTORM_MELEE:
copy_skill = WM_SEVERE_RAINSTORM;
- break;
+ break;
case GN_CRAZYWEED_ATK:
copy_skill = GN_CRAZYWEED;
break;
@@ -2547,7 +2565,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
}
cidx = skill->get_index(copy_skill);
if ((tsd->status.skill[cidx].id == 0 || tsd->status.skill[cidx].flag == SKILL_FLAG_PLAGIARIZED) &&
- can_copy(tsd,copy_skill,bl)) // Split all the check into their own function [Aru]
+ can_copy(tsd,copy_skill,bl)) // Split all the check into their own function [Aru]
{
int lv, idx = 0;
if( sc && sc->data[SC__REPRODUCE] && (lv = sc->data[SC__REPRODUCE]->val1) ) {
@@ -2640,7 +2658,8 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
break;
// This ensures the storm randomly pushes instead of exactly a cell backwards per official mechanics.
case WZ_STORMGUST:
- dir = rnd()%8;
+ if(!battle_config.stormgust_knockback)
+ dir = rand()%8;
break;
case WL_CRIMSONROCK:
dir = map->calc_dir(bl,skill->area_temp[4],skill->area_temp[5]);
@@ -2782,6 +2801,9 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
map->freeblock_unlock();
+ if ((flag&0x4000) && rmdamage == 1)
+ return 0; //Should return 0 when damage was reflected
+
return (int)cap_value(damage,INT_MIN,INT_MAX);
}
@@ -2835,9 +2857,11 @@ int skill_check_unit_range_sub (struct block_list *bl, va_list ap) {
g_skill_id = su->group->skill_id;
switch (skill_id) {
- case MH_STEINWAND:
- case MG_SAFETYWALL:
case AL_PNEUMA:
+ if(g_skill_id == SA_LANDPROTECTOR)
+ break;
+ case MG_SAFETYWALL:
+ case MH_STEINWAND:
case SC_MAELSTROM:
case SO_ELEMENTAL_SHIELD:
if(g_skill_id != MH_STEINWAND && g_skill_id != MG_SAFETYWALL && g_skill_id != AL_PNEUMA && g_skill_id != SC_MAELSTROM && g_skill_id != SO_ELEMENTAL_SHIELD)
@@ -2919,7 +2943,8 @@ int skill_check_unit_range2_sub (struct block_list *bl, va_list ap) {
int skill_check_unit_range2 (struct block_list *bl, int x, int y, uint16 skill_id, uint16 skill_lv) {
int range, type;
- switch (skill_id) { // to be expanded later
+ switch (skill_id) {
+ // to be expanded later
case WZ_ICEWALL:
range = 2;
break;
@@ -3281,12 +3306,18 @@ int skill_timerskill(int tid, int64 tick, int id, intptr_t data) {
int x = skl->type>>16, y = skl->type&0xFFFF;
if( path->search_long(NULL, src->m, src->x, src->y, x, y, CELL_CHKWALL) )
skill->unitsetting(src,skl->skill_id,skl->skill_lv,x,y,skl->flag);
- if( path->search_long(NULL, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) )
+ if( path->search_long(NULL, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL)
+ && !map->getcell(src->m, skl->x, skl->y, CELL_CHKLANDPROTECTOR) )
clif->skill_poseffect(src,skl->skill_id,skl->skill_lv,skl->x,skl->y,tick);
}
else if( path->search_long(NULL, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) )
skill->unitsetting(src,skl->skill_id,skl->skill_lv,skl->x,skl->y,skl->flag);
break;
+ case GN_CRAZYWEED_ATK: {
+ int dummy = 1, i = skill->get_unit_range(skl->skill_id,skl->skill_lv);
+
+ map->foreachinarea(skill->cell_overlap,src->m,skl->x-i,skl->y-i,skl->x+i,skl->y+i,BL_SKILL,skl->skill_id,&dummy,src);
+ }
// fall through ...
case WL_EARTHSTRAIN:
skill->unitsetting(src,skl->skill_id,skl->skill_lv,skl->x,skl->y,(skl->type<<16)|skl->flag);
@@ -3296,14 +3327,6 @@ int skill_timerskill(int tid, int64 tick, int id, intptr_t data) {
map->foreachinpath(skill->attack_area,src->m,src->x,src->y,skl->x,skl->y,4,2,BL_CHAR,
skill->get_type(skl->skill_id),src,src,skl->skill_id,skl->skill_lv,tick,skl->flag,BCT_ENEMY);
break;
- case GN_CRAZYWEED:
- if( skl->type >= 0 ) {
- int x = skl->type>>16, y = skl->type&0xFFFF;
- if( path->search_long(NULL, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) )
- skill->castend_pos2(src, x, y, GN_CRAZYWEED_ATK, skl->skill_lv, tick, skl->flag);
- } else if( path->search_long(NULL, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) )
- skill->castend_pos2(src, skl->x, skl->y, GN_CRAZYWEED_ATK, skl->skill_lv, tick, skl->flag);
- break;
}
}
} while (0);
@@ -3390,7 +3413,7 @@ int skill_activate_reverberation(struct block_list *bl, va_list ap) {
int skill_reveal_trap (struct block_list *bl, va_list ap) {
TBL_SKILL *su = (TBL_SKILL*)bl;
- if (su->alive && su->group && skill->get_inf2(su->group->skill_id)&INF2_TRAP) { //Reveal trap.
+ if (su->alive && su->group && skill->get_inf2(su->group->skill_id)&INF2_TRAP) { //Reveal trap.
//Change look is not good enough, the client ignores it as an actual trap still. [Skotlex]
//clif->changetraplook(bl, su->group->unit_id);
clif->getareachar_skillunit(&su->bl,su,AREA);
@@ -3503,9 +3526,9 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
case MO_TRIPLEATTACK:
case CH_CHAINCRUSH:
case CH_TIGERFIST:
- case PA_SHIELDCHAIN: // Shield Chain
+ case PA_SHIELDCHAIN:
case PA_SACRIFICE:
- case WS_CARTTERMINATION: // Cart Termination
+ case WS_CARTTERMINATION:
case AS_VENOMKNIFE:
case HT_PHANTASMIC:
case TK_DOWNKICK:
@@ -3517,15 +3540,15 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
case GS_PIERCINGSHOT:
case GS_RAPIDSHOWER:
case GS_DUST:
- case GS_DISARM: // Added disarm. [Reddozen]
+ case GS_DISARM:
case GS_FULLBUSTER:
case NJ_SYURIKEN:
case NJ_KUNAI:
#ifndef RENEWAL
case ASC_BREAKER:
#endif
- case HFLI_MOON: //[orn]
- case HFLI_SBR44: //[orn]
+ case HFLI_MOON: //[orn]
+ case HFLI_SBR44: //[orn]
case NPC_BLEEDING:
case NPC_CRITICALWOUND:
case NPC_HELLPOWER:
@@ -3550,9 +3573,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
case SR_GENTLETOUCH_QUIET:
case WM_SEVERE_RAINSTORM_MELEE:
case WM_GREAT_ECHO:
- case GN_CRAZYWEED_ATK:
case GN_SLINGITEM_RANGEMELEEATK:
- case KO_JYUMONJIKIRI:
case KO_SETSUDAN:
case GC_DARKCROW:
case LG_OVERBRAND_BRANDISH:
@@ -3740,8 +3761,6 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
case NPC_SPLASHATTACK:
flag |= SD_PREAMBLE; // a fake packet will be sent for the first target to be hit
case AS_SPLASHER:
- case SM_MAGNUM:
- case MS_MAGNUM:
case HT_BLITZBEAT:
case AC_SHOWER:
case MA_SHOWER:
@@ -3794,11 +3813,15 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
// skill->area_temp[1] holds the id of the original target
// skill->area_temp[2] counts how many targets have already been processed
int sflag = skill->area_temp[0] & 0xFFF, heal;
+ struct status_change *tsc = status->get_sc(bl);
if( flag&SD_LEVEL )
sflag |= SD_LEVEL; // -1 will be used in packets instead of the skill level
if( (skill->area_temp[1] != bl->id && !(skill->get_inf2(skill_id)&INF2_NPC_SKILL)) || flag&SD_ANIMATION )
sflag |= SD_ANIMATION; // original target gets no animation (as well as all NPC skills)
+ if ( tsc && tsc->data[SC_HOVERING] && ( skill_id == SR_WINDMILL || skill_id == LG_MOONSLASHER ) )
+ break;
+
heal = skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, sflag);
if( skill_id == NPC_VAMPIRE_GIFT && heal > 0 ) {
clif->skill_nodamage(NULL, src, AL_HEAL, heal, 1);
@@ -3847,6 +3870,14 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
}
break;
+ case SM_MAGNUM:
+ case MS_MAGNUM:
+ if( flag&1 ) {
+ //Damage depends on distance, so add it to flag if it is > 1
+ skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag|distance_bl(src, bl));
+ }
+ break;
+
case KN_BRANDISHSPEAR:
case ML_BRANDISH:
//Coded apart for it needs the flag passed to the damage calculation.
@@ -3912,7 +3943,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
// If target cell is a wall then break
if(map->getcell(bl->m,tx,ty,CELL_CHKWALL))
break;
- skill_blown(src,bl,1,dir,0);
+ skill->blown(src,bl,1,dir,0);
// Splash around target cell, but only cells inside area; we first have to check the area is not negative
if((max(min_x,tx-1) <= min(max_x,tx+1)) &&
(max(min_y,ty-1) <= min(max_y,ty+1)) &&
@@ -3964,8 +3995,8 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
skill->castend_nodamage_id);
}
break;
- case CH_PALMSTRIKE: // Palm Strike takes effect 1sec after casting. [Skotlex]
- // clif->skill_nodamage(src,bl,skill_id,skill_lv,0); //Can't make this one display the correct attack animation delay :/
+ case CH_PALMSTRIKE: // Palm Strike takes effect 1sec after casting. [Skotlex]
+ //clif->skill_nodamage(src,bl,skill_id,skill_lv,0); //Can't make this one display the correct attack animation delay :/
clif->damage(src,bl,status_get_amotion(src),0,-1,1,4,0); //Display an absorbed damage attack.
skill->addtimerskill(src, tick + (1000+status_get_amotion(src)), bl->id, 0, 0, skill_id, skill_lv, BF_WEAPON, flag);
break;
@@ -4068,7 +4099,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
case SL_STIN:
case SL_STUN:
if (sd && !battle_config.allow_es_magic_pc && bl->type != BL_MOB) {
- status->change_start(src,src,SC_STUN,10000,skill_lv,0,0,0,500,10);
+ status->change_start(src,src,SC_STUN,10000,skill_lv,0,0,0,500,SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE);
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
}
@@ -4184,27 +4215,27 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
}
break;
+ case KO_JYUMONJIKIRI:
case GC_DARKILLUSION:
{
short x, y;
- short dir = map->calc_dir(src,bl->x,bl->y);
+ short dir = map->calc_dir(bl, src->x, src->y);
- if( dir > 0 && dir < 4) x = 2;
- else if( dir > 4 ) x = -2;
- else x = 0;
- if( dir > 2 && dir < 6 ) y = 2;
- else if( dir == 7 || dir < 2 ) y = -2;
- else y = 0;
+ if ( dir < 4 ) {
+ x = bl->x + 2 * (dir > 0) - 3 * (dir > 0);
+ y = bl->y + 1 - (dir / 2) - (dir > 2);
+ } else {
+ x = bl->x + 2 * (dir > 4) - 1 * (dir > 4);
+ y = bl->y + (dir / 6) - 1 + (dir > 6);
+ }
- if( unit->movepos(src, bl->x+x, bl->y+y, 1, 1) )
- {
- clif->slide(src,bl->x+x,bl->y+y);
+ if ( unit->movepos(src, x, y, 1, 1) ) {
+ clif->slide(src, x, y);
clif->fixpos(src); // the official server send these two packets.
- skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
- if( rnd()%100 < 4 * skill_lv )
- skill->castend_damage_id(src,bl,GC_CROSSIMPACT,skill_lv,tick,flag);
+ skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag);
+ if ( rnd() % 100 < 4 * skill_lv && skill_id == GC_DARKILLUSION )
+ skill->castend_damage_id(src, bl, GC_CROSSIMPACT, skill_lv, tick, flag);
}
-
}
break;
case GC_WEAPONCRUSH:
@@ -4507,7 +4538,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
tsc->data[SC_MELODYOFSINK] || tsc->data[SC_BEYOND_OF_WARCRY] || tsc->data[SC_UNLIMITED_HUMMING_VOICE] ) &&
rnd()%100 < 4 * skill_lv + 2 * (sd ? pc->checkskill(sd,WM_LESSON) : 10) + 10 * battle->calc_chorusbonus(sd)) {
skill->attack(BF_MISC,src,src,bl,skill_id,skill_lv,tick,flag);
- status->change_start(src,bl,SC_STUN,10000,skill_lv,0,0,0,skill->get_time(skill_id,skill_lv),8);
+ status->change_start(src,bl,SC_STUN,10000,skill_lv,0,0,0,skill->get_time(skill_id,skill_lv),SCFLAG_FIXEDRATE);
status_change_end(bl, SC_SWING, INVALID_TIMER);
status_change_end(bl, SC_SYMPHONY_LOVE, INVALID_TIMER);
status_change_end(bl, SC_MOONLIT_SERENADE, INVALID_TIMER);
@@ -4844,7 +4875,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) {
break;
} else if( ud->skill_id == RK_PHANTOMTHRUST && target->type != BL_MOB ) {
if( !map_flag_vs(src->m) && battle->check_target(src,target,BCT_PARTY) <= 0 )
- break; // You can use Phantom Thurst on party members in normal maps too. [pakpil]
+ break; // You can use Phantom Thurst on party members in normal maps too. [pakpil]
}
if( inf&BCT_ENEMY
@@ -4893,8 +4924,8 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) {
break;
if (ud->state.running && ud->skill_id == TK_JUMPKICK) {
- ud->state.running = 0;
- status_change_end(src, SC_RUN, INVALID_TIMER);
+ ud->state.running = 0;
+ status_change_end(src, SC_RUN, INVALID_TIMER);
flag = 1;
}
@@ -4988,8 +5019,8 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) {
skill->consume_requirement(sd,ud->skill_id, ud->skill_lv,1);
status->set_sp(src, 0, 0);
sc = &sd->sc;
- if (sc->count)
- { //End states
+ if (sc->count) {
+ //End states
status_change_end(src, SC_EXPLOSIONSPIRITS, INVALID_TIMER);
status_change_end(src, SC_BLADESTOP, INVALID_TIMER);
#ifdef RENEWAL
@@ -5006,8 +5037,8 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) {
if( dir > 2 && dir < 6 ) y = -2;
else if( dir == 7 || dir < 2 ) y = 2;
else y = 0;
- if (unit->movepos(src, src->x+x, src->y+y, 1, 1))
- { //Display movement + animation.
+ if (unit->movepos(src, src->x+x, src->y+y, 1, 1)) {
+ //Display movement + animation.
clif->slide(src,src->x,src->y);
clif->spiritball(src);
}
@@ -5043,7 +5074,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
int element = 0;
enum sc_type type;
- if(skill_id > 0 && !skill_lv) return 0; // [Celest]
+ if(skill_id > 0 && !skill_lv) return 0; // [Celest]
nullpo_retr(1, src);
nullpo_retr(1, bl);
@@ -5099,12 +5130,12 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
//Check for undead skills that convert a no-damage skill into a damage one. [Skotlex]
switch (skill_id) {
- case HLIF_HEAL: // [orn]
+ case HLIF_HEAL: // [orn]
if (bl->type != BL_HOM) {
if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0) ;
break ;
}
- case AL_HEAL:
+ case AL_HEAL:
/**
* Arch Bishop
@@ -5117,7 +5148,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
//Apparently only player casted skills can be offensive like this.
if (sd && battle->check_undead(tstatus->race,tstatus->def_ele) && skill_id != AL_INCAGI) {
if (battle->check_target(src, bl, BCT_ENEMY) < 1) {
- //Offensive heal does not works on non-enemies. [Skotlex]
+ //Offensive heal does not works on non-enemies. [Skotlex]
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -5135,7 +5166,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if((p = party->search(sd->status.party_id)) == NULL)
break;
- range = skill_get_splash(skill_id,skill_lv);
+ range = skill->get_splash(skill_id,skill_lv);
x0 = sd->bl.x - range;
y0 = sd->bl.y - range;
x1 = sd->bl.x + range;
@@ -5184,7 +5215,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case RK_FIGHTINGSPIRIT:
case RK_ABUNDANCE:
if( sd && !pc->checkskill(sd, RK_RUNEMASTERY) ){
- if( status->change_start(src,&sd->bl, (sc_type)(rnd()%SC_CONFUSION), 1000, 1, 0, 0, 0, skill->get_time2(skill_id,skill_lv),8) ){
+ if( status->change_start(src,&sd->bl, (sc_type)(rnd()%SC_CONFUSION), 1000, 1, 0, 0, 0, skill->get_time2(skill_id,skill_lv),SCFLAG_FIXEDRATE) ){
skill->consume_requirement(sd,skill_id,skill_lv,2);
map->freeblock_unlock();
return 0;
@@ -5209,7 +5240,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
map->freeblock_lock();
switch(skill_id) {
- case HLIF_HEAL: // [orn]
+ case HLIF_HEAL: // [orn]
case AL_HEAL:
/**
* Arch Bishop
@@ -5398,7 +5429,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
bl = (struct block_list*)((TBL_PET*)src)->msd;
if (!bl) bl = src;
unit->skilluse_id(src, bl->id, abra_skill_id, abra_skill_lv);
- } else { //Assume offensive skills
+ } else { //Assume offensive skills
int target_id = 0;
if (ud->target)
target_id = ud->target;
@@ -5445,7 +5476,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
case SA_SUMMONMONSTER:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- if (sd) mob->once_spawn(sd, src->m, src->x, src->y," --ja--", -1, 1, "", SZ_MEDIUM, AI_NONE);
+ if (sd) mob->once_spawn(sd, src->m, src->x, src->y," --ja--", -1, 1, "", SZ_SMALL, AI_NONE);
break;
case SA_LEVELUP:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
@@ -5558,14 +5589,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start4(src,bl,type,100,skill_lv,src->id,0,0,skill->get_time(skill_id,skill_lv)));
break;
- case SA_FLAMELAUNCHER: // added failure chance and chance to break weapon if turned on [Valaris]
+ case SA_FLAMELAUNCHER: // added failure chance and chance to break weapon if turned on [Valaris]
case SA_FROSTWEAPON:
case SA_LIGHTNINGLOADER:
case SA_SEISMICWEAPON:
if (dstsd) {
if(dstsd->status.weapon == W_FIST ||
(dstsd->sc.count && !dstsd->sc.data[type] &&
- ( //Allow re-enchanting to lengthen time. [Skotlex]
+ ( //Allow re-enchanting to lengthen time. [Skotlex]
dstsd->sc.data[SC_PROPERTYFIRE] ||
dstsd->sc.data[SC_PROPERTYWATER] ||
dstsd->sc.data[SC_PROPERTYWIND] ||
@@ -5623,8 +5654,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case PR_KYRIE:
case MER_KYRIE:
- clif->skill_nodamage(bl,bl,skill_id,skill_lv,
- sc_start(src,bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
+ clif->skill_nodamage(bl, bl, skill_id, -1,
+ sc_start(src, bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)));
break;
//Passive Magnum, should had been casted on yourself.
case SM_MAGNUM:
@@ -5830,7 +5861,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
dstsd->sc.data[SC_PROPERTYGROUND] ||
dstsd->sc.data[SC_PROPERTYDARK] ||
dstsd->sc.data[SC_PROPERTYTELEKINESIS]
- // dstsd->sc.data[SC_ENCHANTPOISON] //People say you should be able to recast to lengthen the timer. [Skotlex]
+ //dstsd->sc.data[SC_ENCHANTPOISON] //People say you should be able to recast to lengthen the timer. [Skotlex]
) {
clif->skill_nodamage(src,bl,skill_id,skill_lv,0);
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
@@ -6009,15 +6040,23 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case MO_ABSORBSPIRITS:
{
int sp = 0;
- if (dstsd && dstsd->spiritball && (sd == dstsd || map_flag_vs(src->m) || (sd->duel_group && sd->duel_group == dstsd->duel_group)) && ((dstsd->class_&MAPID_BASEMASK)!=MAPID_GUNSLINGER || (dstsd->class_&MAPID_UPPERMASK)!=MAPID_REBELLION))
- { // split the if for readability, and included gunslingers in the check so that their coins cannot be removed [Reddozen]
+ if ( dstsd && dstsd->spiritball
+ && (sd == dstsd || map_flag_vs(src->m) || (sd->duel_group && sd->duel_group == dstsd->duel_group))
+ && ((dstsd->class_&MAPID_BASEMASK) != MAPID_GUNSLINGER || (dstsd->class_&MAPID_UPPERMASK) != MAPID_REBELLION)
+ ) {
+ // split the if for readability, and included gunslingers in the check so that their coins cannot be removed [Reddozen]
sp = dstsd->spiritball * 7;
- pc->delspiritball(dstsd,dstsd->spiritball,0);
- } else if (dstmd && !(tstatus->mode&MD_BOSS) && rnd() % 100 < 20)
- { // check if target is a monster and not a Boss, for the 20% chance to absorb 2 SP per monster's level [Reddozen]
+ pc->delspiritball(dstsd, dstsd->spiritball, 0);
+ } else if ( dstmd && !(tstatus->mode&MD_BOSS) && rnd() % 100 < 20 ) {
+ // check if target is a monster and not a Boss, for the 20% chance to absorb 2 SP per monster's level [Reddozen]
sp = 2 * dstmd->level;
mob->target(dstmd,src,0);
}
+ if ( dstsd ) {
+ int i;
+ for ( i = SPIRITS_TYPE_CHARM_WATER; i < SPIRITS_TYPE_SPHERE; i++ )
+ pc->del_charm(dstsd, dstsd->spiritcharm[i], i);
+ }
if (sp) status->heal(src, 0, sp, 3);
clif->skill_nodamage(src,bl,skill_id,skill_lv,sp?1:0);
}
@@ -6121,7 +6160,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
BF_MAGIC, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY);
break;
- case HVAN_EXPLOSION: // [orn]
+ case HVAN_EXPLOSION: // [orn]
case NPC_SELFDESTRUCTION:
{
//Self Destruction hits everyone in range (allies+enemies)
@@ -6213,7 +6252,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
|| dstsd->status.char_id == sd->status.child
)
) {
- status->change_start(src,src,SC_STUN,10000,skill_lv,0,0,0,500,8);
+ status->change_start(src,src,SC_STUN,10000,skill_lv,0,0,0,500,SCFLAG_FIXEDRATE);
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
}
@@ -6261,25 +6300,24 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case GC_CLOAKINGEXCEED:
case LG_FORCEOFVANGUARD:
case SC_REPRODUCE:
+ case RA_CAMOUFLAGE:
if (tsce) {
int failure = status_change_end(bl, type, INVALID_TIMER);
if( failure )
clif->skill_nodamage(src,bl,skill_id,( skill_id == LG_FORCEOFVANGUARD ) ? skill_lv : -1,failure);
else if( sd )
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- if ( skill_id == LG_FORCEOFVANGUARD )
+ if ( skill_id == LG_FORCEOFVANGUARD || skill_id == RA_CAMOUFLAGE )
break;
map->freeblock_unlock();
return 0;
+ } else {
+ int failure = sc_start(src,bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv));
+ if( failure )
+ clif->skill_nodamage(src,bl,skill_id,( skill_id == LG_FORCEOFVANGUARD ) ? skill_lv : -1,failure);
+ else if( sd )
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
}
- case RA_CAMOUFLAGE:
- {
- int failure = sc_start(src,bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv));
- if( failure )
- clif->skill_nodamage(src,bl,skill_id,( skill_id == LG_FORCEOFVANGUARD ) ? skill_lv : -1,failure);
- else if( sd )
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- }
break;
case BD_ADAPTATION:
@@ -6360,7 +6398,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if (tsc->data[SC_STONE]) {
status_change_end(bl, SC_STONE, INVALID_TIMER);
- if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
break;
}
if (sc_start4(src,bl,SC_STONE,(skill_lv*4+20)+brate,
@@ -6417,7 +6455,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if( battle->check_undead(tstatus->race,tstatus->def_ele) ) {
status->change_start(src, bl, SC_BLIND,
100*(100-(tstatus->int_/2+tstatus->vit/3+tstatus->luk/10)), 1,0,0,0,
- skill->get_time2(skill_id, skill_lv) * (100-(tstatus->int_+tstatus->vit)/2)/100,0);
+ skill->get_time2(skill_id, skill_lv) * (100-(tstatus->int_+tstatus->vit)/2)/100,SCFLAG_NONE);
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
if(dstmd)
@@ -6507,8 +6545,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
case MC_VENDING:
- if(sd)
- { //Prevent vending of GMs with unnecessary Level to trade/drop. [Skotlex]
+ if (sd) {
+ //Prevent vending of GMs with unnecessary Level to trade/drop. [Skotlex]
if ( !pc_can_give_items(sd) )
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
else {
@@ -6613,9 +6651,9 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if( skill_id == GC_WEAPONCRUSH){
d = skill->get_time(skill_id,skill_lv);
if(bl->type == BL_PC)
- d += skill_lv * 15 + (sstatus->dex - tstatus->dex);
+ d += 1000 * ( skill_lv * 15 + ( sstatus->dex - tstatus->dex ) );
else
- d += skill_lv * 30 + (sstatus->dex - tstatus->dex) / 2;
+ d += 1000 * ( skill_lv * 30 + ( sstatus->dex - tstatus->dex ) / 2 );
}else
d = skill->get_time(skill_id,skill_lv) + (sstatus->dex - tstatus->dex)*500;
@@ -6732,7 +6770,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
sp += sp * i / 100;
}
} else {
- hp = (1 + rnd()%400) * (100 + skill_lv*10) / 100;
+ //Maybe replace with potion_hp, but I'm unsure how that works [Playtester]
+ switch (skill_lv) {
+ case 1: hp = 45; break;
+ case 2: hp = 105; break;
+ case 3: hp = 175; break;
+ default: hp = 325; break;
+ }
+ hp = (hp + rnd()%(skill_lv*20+1)) * (150 + skill_lv*10) / 100;
hp = hp * (100 + (tstatus->vit<<1)) / 100;
if( dstsd )
hp = hp * (100 + pc->checkskill(dstsd,SM_RECOVERY)*10) / 100;
@@ -6778,7 +6823,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
case AM_CP_SHIELD: {
int i;
- if(dstsd && (i=dstsd->equip_index[EQI_HAND_L])>=0 && dstsd->inventory_data[i] &&
+ if(dstsd && (i=dstsd->equip_index[EQI_HAND_L])>=0 && dstsd->inventory_data[i] &&
dstsd->inventory_data[i]->type==IT_ARMOR)
clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start(src,bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
@@ -6929,7 +6974,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
}
clif->skill_nodamage(src,bl,TK_HIGHJUMP,skill_lv,1);
- if(!map->count_oncell(src->m,x,y,BL_PC|BL_NPC|BL_MOB) && map->getcell(src->m,x,y,CELL_CHKREACH)) {
+ if(!map->count_oncell(src->m,x,y,BL_PC|BL_NPC|BL_MOB,0) && map->getcell(src->m,x,y,CELL_CHKREACH)) {
clif->slide(src,x,y);
unit->movepos(src, x, y, 1, 0);
}
@@ -6968,8 +7013,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break; //Nothing to cancel.
bl_skill_id = ud->skill_id;
bl_skill_lv = ud->skill_lv;
- if (tstatus->mode & MD_BOSS)
- { //Only 10% success chance against bosses. [Skotlex]
+ if (tstatus->mode & MD_BOSS) {
+ //Only 10% success chance against bosses. [Skotlex]
if (rnd()%100 < 90)
{
if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
@@ -6984,7 +7029,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
status_zap(bl, hp, sp);
if (hp && skill_lv >= 5)
- hp>>=1; //Recover half damaged HP at level 5 [Skotlex]
+ hp>>=1; //Recover half damaged HP at level 5 [Skotlex]
else
hp = 0;
@@ -7010,9 +7055,11 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
static const int spellarray[3] = { MG_COLDBOLT,MG_FIREBOLT,MG_LIGHTNINGBOLT };
if(skill_lv >= 10) {
spellid = MG_FROSTDIVER;
- // if (tsc && tsc->data[SC_SOULLINK] && tsc->data[SC_SOULLINK]->val2 == SA_SAGE)
- // maxlv = 10;
- // else
+#if 0
+ if (tsc && tsc->data[SC_SOULLINK] && tsc->data[SC_SOULLINK]->val2 == SA_SAGE)
+ maxlv = 10;
+ else
+#endif // 0
maxlv = skill_lv - 9;
}
else if(skill_lv >=8) {
@@ -7088,7 +7135,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
struct unit_data *ud = unit->bl2ud(bl);
if (clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start(src,bl,type,100,skill_lv,skill_time))
- && ud) { //Disable attacking/acting/moving for skill's duration.
+ && ud) {
+ //Disable attacking/acting/moving for skill's duration.
ud->attackabletime =
ud->canact_tick =
ud->canmove_tick = tick + skill_time;
@@ -7265,7 +7313,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
return 0;
}
else
- status->change_start(src,bl,SC_STUN,10000,skill_lv,0,0,0,skill->get_time2(skill_id,skill_lv),8);
+ status->change_start(src,bl,SC_STUN,10000,skill_lv,0,0,0,skill->get_time2(skill_id,skill_lv),SCFLAG_FIXEDRATE);
}
break;
@@ -7337,7 +7385,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
struct skill_unit *su=NULL;
if((bl->type==BL_SKILL) && (su=(struct skill_unit *)bl) && (su->group) ){
switch(su->group->unit_id){
- case UNT_ANKLESNARE: // ankle snare
+ case UNT_ANKLESNARE:
if (su->group->val2 != 0)
// if it is already trapping something don't spring it,
// remove trap should be used instead
@@ -7492,7 +7540,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if(dstsd && dstsd->inventory_data[dstsd->equip_index[EQI_HAND_R]]) {
iused=true;
clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(src,bl,SC_PROTECTWEAPON,100,skill_lv,skill->get_time(skill_id,skill_lv)));
- } if(dstsd && (i=dstsd->equip_index[EQI_HAND_L])>=0 && dstsd->inventory_data[i] &&
+ } if(dstsd && (i=dstsd->equip_index[EQI_HAND_L])>=0 && dstsd->inventory_data[i] &&
dstsd->inventory_data[i]->type==IT_ARMOR) {
iused=true;
clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(src,bl,SC_PROTECTSHIELD,100,skill_lv,skill->get_time(skill_id,skill_lv)));
@@ -7511,7 +7559,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
}
break;
- case RG_CLEANER: //AppleGirl
+ case RG_CLEANER: //AppleGirl
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
break;
@@ -7549,16 +7597,16 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
clif->specialeffect(bl, 523 + eff, AREA);
switch (eff)
{
- case 0: // heals SP to 0
+ case 0: // heals SP to 0
status_percent_damage(src, bl, 0, 100, false);
break;
- case 1: // matk halved
+ case 1: // matk halved
sc_start(src,bl,SC_INCMATKRATE,100,-50,skill->get_time2(skill_id,skill_lv));
break;
- case 2: // all buffs removed
+ case 2: // all buffs removed
status->change_clear_buffs(bl,1);
break;
- case 3: // 1000 damage, random armor destroyed
+ case 3: // 1000 damage, random armor destroyed
{
status_fix_damage(src, bl, 1000, 0);
clif->damage(src,bl,0,0,1000,0,0,0);
@@ -7568,49 +7616,49 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
}
}
break;
- case 4: // atk halved
+ case 4: // atk halved
sc_start(src,bl,SC_INCATKRATE,100,-50,skill->get_time2(skill_id,skill_lv));
break;
- case 5: // 2000HP heal, random teleported
+ case 5: // 2000HP heal, random teleported
status->heal(src, 2000, 0, 0);
if( !map_flag_vs(bl->m) )
unit->warp(bl, -1,-1,-1, CLR_TELEPORT);
break;
- case 6: // random 2 other effects
+ case 6: // random 2 other effects
if (count == -1)
count = 3;
else
count++; //Should not re-trigger this one.
break;
- case 7: // stop freeze or stoned
+ case 7: // stop freeze or stoned
{
enum sc_type sc[] = { SC_STOP, SC_FREEZE, SC_STONE };
sc_start(src,bl,sc[rnd()%3],100,skill_lv,skill->get_time2(skill_id,skill_lv));
}
break;
- case 8: // curse coma and poison
+ case 8: // curse coma and poison
sc_start(src,bl,SC_COMA,100,skill_lv,skill->get_time2(skill_id,skill_lv));
sc_start(src,bl,SC_CURSE,100,skill_lv,skill->get_time2(skill_id,skill_lv));
sc_start(src,bl,SC_POISON,100,skill_lv,skill->get_time2(skill_id,skill_lv));
break;
- case 9: // confusion
+ case 9: // confusion
sc_start(src,bl,SC_CONFUSION,100,skill_lv,skill->get_time2(skill_id,skill_lv));
break;
- case 10: // 6666 damage, atk matk halved, cursed
+ case 10: // 6666 damage, atk matk halved, cursed
status_fix_damage(src, bl, 6666, 0);
clif->damage(src,bl,0,0,6666,0,0,0);
sc_start(src,bl,SC_INCATKRATE,100,-50,skill->get_time2(skill_id,skill_lv));
sc_start(src,bl,SC_INCMATKRATE,100,-50,skill->get_time2(skill_id,skill_lv));
sc_start(src,bl,SC_CURSE,skill_lv,100,skill->get_time2(skill_id,skill_lv));
break;
- case 11: // 4444 damage
+ case 11: // 4444 damage
status_fix_damage(src, bl, 4444, 0);
clif->damage(src,bl,0,0,4444,0,0,0);
break;
- case 12: // stun
+ case 12: // stun
sc_start(src,bl,SC_STUN,100,skill_lv,5000);
break;
- case 13: // atk,matk,hit,flee,def reduced
+ case 13: // atk,matk,hit,flee,def reduced
sc_start(src,bl,SC_INCATKRATE,100,-20,skill->get_time2(skill_id,skill_lv));
sc_start(src,bl,SC_INCMATKRATE,100,-20,skill->get_time2(skill_id,skill_lv));
sc_start(src,bl,SC_INCHITRATE,100,-20,skill->get_time2(skill_id,skill_lv));
@@ -7646,8 +7694,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
}
- if (skill_id == SL_SUPERNOVICE && dstsd && dstsd->die_counter && !(rnd()%100))
- { //Erase death count 1% of the casts
+ if (skill_id == SL_SUPERNOVICE && dstsd && dstsd->die_counter && !(rnd()%100)) {
+ //Erase death count 1% of the casts
dstsd->die_counter = 0;
pc_setglobalreg(dstsd,script->add_str("PC_DIE_COUNTER"), 0);
clif->specialeffect(bl, 0x152, AREA);
@@ -7671,7 +7719,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if (tsce) {
if(sd)
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- status->change_start(src,src,SC_STUN,10000,skill_lv,0,0,0,10000,8);
+ status->change_start(src,src,SC_STUN,10000,skill_lv,0,0,0,10000,SCFLAG_FIXEDRATE);
status_change_end(bl, SC_SWOO, INVALID_TIMER);
break;
}
@@ -7679,7 +7727,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case SL_SKE:
if (sd && !battle_config.allow_es_magic_pc && bl->type != BL_MOB) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- status->change_start(src,src,SC_STUN,10000,skill_lv,0,0,0,500,10);
+ status->change_start(src,src,SC_STUN,10000,skill_lv,0,0,0,500,SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE);
break;
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(src,bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
@@ -7795,7 +7843,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
}
break;
- case AM_CALLHOMUN: // [orn]
+ case AM_CALLHOMUN: // [orn]
if( sd ) {
if (homun->call(sd))
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
@@ -7813,7 +7861,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
}
break;
- case HAMI_CASTLE: // [orn]
+ case HAMI_CASTLE: // [orn]
if(rnd()%100 < 20*skill_lv && src != bl)
{
int x,y;
@@ -7842,7 +7890,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
else if (sd)
clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
break;
- case HVAN_CHAOTIC: // [orn]
+ case HVAN_CHAOTIC: // [orn]
{
static const int per[5][2]={{20,50},{50,60},{25,75},{60,64},{34,67}};
int r = rnd()%100;
@@ -8233,7 +8281,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if( sd == NULL || sd->status.party_id == 0 || flag&1 ) {
if( sd && tstatus && !battle->check_undead(tstatus->race, tstatus->def_ele) && !tsc->data[SC_BERSERK] ) {
int lv = pc->checkskill(sd, AL_HEAL);
- int heal = skill_calc_heal(src, bl, AL_HEAL, lv, true);
+ int heal = skill->calc_heal(src, bl, AL_HEAL, lv, true);
if( sd->status.party_id ) {
int partycount = party->foreachsamemap(party->sub_count, sd, 0);
@@ -8306,7 +8354,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if( flag&1 || (splash = skill->get_splash(skill_id, skill_lv)) < 1 ) {
int i;
//As of the behavior in official server Clearance is just a super version of Dispell skill. [Jobbie]
- if( bl->type != BL_MOB && battle->check_target(src,bl,BCT_PARTY) <= 0 ) // Only affect mob or party.
+ if( bl->type != BL_MOB && battle->check_target(src,bl,BCT_PARTY) <= 0 && sd ) // Only affect mob, party or self.
break;
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
@@ -8410,7 +8458,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if( tsc && tsc->data[SC_STONE] )
status_change_end(bl,SC_STONE,INVALID_TIMER);
else
- status->change_start(src,bl,SC_STONE,10000,skill_lv,0,0,500,skill->get_time(skill_id, skill_lv),2);
+ status->change_start(src,bl,SC_STONE,10000,skill_lv,0,0,500,skill->get_time(skill_id, skill_lv),SCFLAG_FIXEDTICK);
} else {
int rate = 45 + 5 * skill_lv;
if( rnd()%100 < rate ){
@@ -8518,9 +8566,9 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
case NC_SELFDESTRUCTION:
- if( sd ) {
- if( pc_ismadogear(sd) )
- pc->setmadogear(sd, 0);
+ if (sd) {
+ if (pc_ismadogear(sd))
+ pc->setmadogear(sd, false);
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
skill->castend_damage_id(src, src, skill_id, skill_lv, tick, flag);
status->set_sp(src, 0, 0);
@@ -8646,13 +8694,13 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
//If the target was successfully inflected with the Unlucky status, give 1 of 3 random status's.
switch(rnd()%3) {//Targets in the Unlucky status will be affected by one of the 3 random status's regardless of resistance.
case 0:
- status->change_start(src,bl,SC_POISON,10000,skill_lv,0,0,0,skill->get_time(skill_id,skill_lv),10);
+ status->change_start(src,bl,SC_POISON,10000,skill_lv,0,0,0,skill->get_time(skill_id,skill_lv),SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE);
break;
case 1:
- status->change_start(src,bl,SC_SILENCE,10000,skill_lv,0,0,0,skill->get_time(skill_id,skill_lv),10);
+ status->change_start(src,bl,SC_SILENCE,10000,skill_lv,0,0,0,skill->get_time(skill_id,skill_lv),SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE);
break;
case 2:
- status->change_start(src,bl,SC_BLIND,10000,skill_lv,0,0,0,skill->get_time(skill_id,skill_lv),10);
+ status->change_start(src,bl,SC_BLIND,10000,skill_lv,0,0,0,skill->get_time(skill_id,skill_lv),SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE);
}
}
} else if( sd )
@@ -8679,8 +8727,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
sc_start(src,bl,SC_SILENCE,100,skill_lv,sd->bonus.shieldmdef * 30000);
} else {
int opt = 0, val = 0, splashrange = 0;
- struct item_data *shield_data = sd->inventory_data[sd->equip_index[EQI_HAND_L]];
- if( !shield_data || shield_data->type != IT_ARMOR ) {
+ struct item_data *shield_data = NULL;
+ if( sd->equip_index[EQI_HAND_L] < 0 || !( shield_data = sd->inventory_data[sd->equip_index[EQI_HAND_L]] ) || shield_data->type != IT_ARMOR ) {
//Skill will first check if a shield is equipped. If none is found on the caster the skill will fail.
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
@@ -8792,15 +8840,24 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if (!tsc->data[i])
continue;
switch(i){
- case SC_POISON: case SC_BLIND:
- case SC_FREEZE: case SC_STONE:
- case SC_STUN: case SC_SLEEP:
- case SC_BLOODING: case SC_CURSE:
- case SC_CONFUSION: case SC_ILLUSION:
- case SC_SILENCE: case SC_BURNING:
- case SC_COLD: case SC_FROSTMISTY:
- case SC_DEEP_SLEEP: case SC_FEAR:
- case SC_MANDRAGORA: case SC__CHAOS:
+ case SC_POISON:
+ case SC_BLIND:
+ case SC_FREEZE:
+ case SC_STONE:
+ case SC_STUN:
+ case SC_SLEEP:
+ case SC_BLOODING:
+ case SC_CURSE:
+ case SC_CONFUSION:
+ case SC_ILLUSION:
+ case SC_SILENCE:
+ case SC_BURNING:
+ case SC_COLD:
+ case SC_FROSTMISTY:
+ case SC_DEEP_SLEEP:
+ case SC_FEAR:
+ case SC_MANDRAGORA:
+ case SC__CHAOS:
status_change_end(bl, (sc_type)i, INVALID_TIMER);
}
}
@@ -8864,6 +8921,11 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
pc->delspiritball(dstsd, dstsd->spiritball, 0);
status_percent_heal(src, 0, sp);
}
+ if ( dstsd ) {
+ int i;
+ for (i = SPIRITS_TYPE_CHARM_WATER; i < SPIRITS_TYPE_SPHERE; i++)
+ pc->del_charm(dstsd, dstsd->spiritcharm[i], i);
+ }
clif->skill_nodamage(src, bl, skill_id, skill_lv, sp ? 1:0);
} else {
clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
@@ -8912,10 +8974,13 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
}
break;
case SR_GENTLETOUCH_CHANGE:
- case SR_GENTLETOUCH_REVITALIZE:
clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start2(src,bl,type,100,skill_lv,bl->id,skill->get_time(skill_id,skill_lv)));
break;
+ case SR_GENTLETOUCH_REVITALIZE:
+ clif->skill_nodamage(src,bl,skill_id,skill_lv,
+ sc_start2(src,bl,type,100,skill_lv,status_get_vit(src),skill->get_time(skill_id,skill_lv)));
+ break;
case SR_FLASHCOMBO:
{
const int combo[] = {
@@ -8929,7 +8994,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
for( i = 0; i < ARRAYLENGTH(combo); i++ )
skill->addtimerskill(src, tick + 400 * i, bl->id, 0, 0, combo[i], skill_lv, BF_WEAPON, flag|SD_LEVEL);
- break;
+ break;
}
case WA_SWING_DANCE:
case WA_SYMPHONY_OF_LOVER:
@@ -9173,9 +9238,9 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case SO_EL_CONTROL:
if( sd ) {
- int mode = EL_MODE_PASSIVE; // Standard mode.
+ int mode = EL_MODE_PASSIVE; // Standard mode.
- if( !sd->ed ) break;
+ if( !sd->ed ) break;
if( skill_lv == 4 ) {// At level 4 delete elementals.
elemental->delete(sd->ed, 0);
@@ -9224,7 +9289,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
int s_hp = sd->battle_status.hp * 10 / 100, s_sp = sd->battle_status.sp * 10 / 100;
int e_hp, e_sp;
- if( !ed ) break;
+ if( !ed ) break;
if( !status->charge(&sd->bl,s_hp,s_sp) ) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
@@ -9353,7 +9418,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
} else {
clif->skill_nodamage(src,src,skill_id,skill_lv,1);
clif->skill_damage(src, ( skill_id == EL_GUST || skill_id == EL_BLAST || skill_id == EL_WILD_STORM )?src:bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
- if( skill_id == EL_WIND_STEP ) // There aren't teleport, just push the master away.
+ if( skill_id == EL_WIND_STEP ) // There aren't teleport, just push the master away.
skill->blown(src,bl,(rnd()%skill->get_blewcount(skill_id,skill_lv))+1,rnd()%8,0);
sc_start(src, src,type2,100,skill_lv,skill->get_time(skill_id,skill_lv));
sc_start(src, bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv));
@@ -9399,10 +9464,10 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
int i;
int ttype = skill->get_ele(skill_id, skill_lv);
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
- ARR_FIND(1, 6, i, sd->charm[i] > 0 && ttype != i);
- if( i < 6 )
- pc->del_charm(sd, sd->charm[i], i); // replace with a new one.
- pc->add_charm(sd, skill->get_time(skill_id, skill_lv), 10, ttype);
+ ARR_FIND(SPIRITS_TYPE_CHARM_WATER, SPIRITS_TYPE_SPHERE, i, sd->spiritcharm[i] > 0 && ttype != i);
+ if( i < SPIRITS_TYPE_SPHERE )
+ pc->del_charm(sd, sd->spiritcharm[i], i); // replace with a new one.
+ pc->add_charm(sd, skill->get_time(skill_id, skill_lv), MAX_SPIRITCHARM, ttype);
}
break;
@@ -9410,7 +9475,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if(sd) {
struct mob_data *summon_md;
- summon_md = mob->once_spawn_sub(src, src->m, src->x, src->y, status->get_name(src), 2308, "", SZ_MEDIUM, AI_NONE);
+ summon_md = mob->once_spawn_sub(src, src->m, src->x, src->y, status->get_name(src), 2308, "", SZ_SMALL, AI_NONE);
if( summon_md ) {
summon_md->master_id = src->id;
summon_md->special_state.ai = AI_ZANZOU;
@@ -9426,17 +9491,16 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
case KO_KYOUGAKU:
- {
- int rate = max(5, (45 + 5 * skill_lv - status_get_int(bl) / 10));
- if( sd && !map_flag_gvg2(src->m) ){
- clif->skill_fail(sd, skill_id, USESKILL_FAIL_SIZE, 0);
- break;
- }
- if( dstsd && tsc && !tsc->data[type] && rand()%100 < rate ){
- clif->skill_nodamage(src, bl, skill_id, skill_lv,
- sc_start(src, bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)));
- }else if( sd )
- clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
+ if (!map_flag_vs(src->m) || !dstsd) {
+ if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_SIZE, 0);
+ break;
+ } else {
+ int time;
+ int rate = 45+ 5*skill_lv - status_get_int(bl)/10;
+ if (rate < 5) rate = 5;
+
+ time = skill->get_time(skill_id, skill_lv) - 1000*status_get_int(bl)/20;
+ sc_start(src,bl, type, rate, skill_lv, time);
}
break;
@@ -9445,10 +9509,10 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
&& rand()%100 < (10 * (5 * skill_lv - status_get_int(bl) / 2 + 45 + 5 * skill_lv))
) {
clif->skill_nodamage(src, bl, skill_id, skill_lv,
- status->change_start(src, bl, type, 10000, skill_lv, 0, 0, 0, skill->get_time(skill_id, skill_lv), 1));
+ status->change_start(src, bl, type, 10000, skill_lv, 0, 0, 0, skill->get_time(skill_id, skill_lv), SCFLAG_NOAVOID));
status_zap(bl, tstatus->max_hp * skill_lv * 5 / 100 , 0);
if( status->get_lv(bl) <= status->get_lv(src) )
- status->change_start(src, bl, SC_COMA, skill_lv, skill_lv, 0, src->id, 0, 0, 0);
+ status->change_start(src, bl, SC_COMA, skill_lv, skill_lv, 0, src->id, 0, 0, SCFLAG_NONE);
} else if( sd )
clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
break;
@@ -9544,11 +9608,11 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if (tsc->data[scs[i]]) status_change_end(bl, scs[i], INVALID_TIMER);
}
}
- heal = 5 * status->get_lv(&hd->bl) + status->base_matk(&hd->battle_status, status->get_lv(&hd->bl));
+ heal = 5 * status->get_lv(&hd->bl) + status->base_matk(&hd->bl, &hd->battle_status, status->get_lv(&hd->bl));
status->heal(bl, heal, 0, 0);
clif->skill_nodamage(src, src, skill_id, skill_lv, clif->skill_nodamage(src, bl, AL_HEAL, heal, 1));
- status->change_start(src, src, type, 1000, skill_lv, 0, 0, 0, skill->get_time(skill_id,skill_lv), 1|2|8);
- status->change_start(src, bl, type, 1000, skill_lv, 0, 0, 0, skill->get_time(skill_id,skill_lv), 1|2|8);
+ status->change_start(src, src, type, 1000, skill_lv, 0, 0, 0, skill->get_time(skill_id,skill_lv), SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE);
+ status->change_start(src, bl, type, 1000, skill_lv, 0, 0, 0, skill->get_time(skill_id,skill_lv), SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE);
}
break;
@@ -9584,7 +9648,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
for(i=0; i<qty[skill_lv - 1]; i++){ //easy way
- summon_md = mob->once_spawn_sub(src, src->m, src->x, src->y, status->get_name(src), summons[skill_lv - 1], "", SZ_MEDIUM, AI_ATTACK);
+ summon_md = mob->once_spawn_sub(src, src->m, src->x, src->y, status->get_name(src), summons[skill_lv - 1], "", SZ_SMALL, AI_ATTACK);
if (summon_md) {
summon_md->master_id = src->id;
if (summon_md->deletetimer != INVALID_TIMER)
@@ -9717,9 +9781,11 @@ int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) {
if( sd )
{
- if( ud->skill_id != AL_WARP && !skill->check_condition_castend(sd, ud->skill_id, ud->skill_lv) )
+ if( ud->skill_id != AL_WARP && !skill->check_condition_castend(sd, ud->skill_id, ud->skill_lv) ) {
+ if( ud->skill_id == SA_LANDPROTECTOR )
+ clif->skill_poseffect(&sd->bl,ud->skill_id,ud->skill_lv,sd->bl.x,sd->bl.y,tick);
break;
- else
+ }else
skill->consume_requirement(sd,ud->skill_id,ud->skill_lv,1);
}
@@ -9741,7 +9807,7 @@ int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) {
if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) )
ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv);
- if (sd) { //Cooldown application
+ if (sd) { //Cooldown application
int i, cooldown = skill->get_cooldown(ud->skill_id, ud->skill_lv);
for (i = 0; i < ARRAYLENGTH(sd->skillcooldown) && sd->skillcooldown[i].id; i++) { // Increases/Decreases cooldown of a skill by item/card bonuses.
if (sd->skillcooldown[i].id == ud->skill_id){
@@ -9754,15 +9820,15 @@ int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) {
}
if( battle_config.display_status_timers && sd )
clif->status_change(src, SI_POSTDELAY, 1, skill->delay_fix(src, ud->skill_id, ud->skill_lv), 0, 0, 0);
-// if( sd )
-// {
-// switch( ud->skill_id )
-// {
-// case ????:
-// sd->canequip_tick = tick + ????;
-// break;
-// }
-// }
+#if 0
+ if (sd) {
+ switch (ud->skill_id) {
+ case ????:
+ sd->canequip_tick = tick + ????;
+ break;
+ }
+ }
+#endif // 0
unit->set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1);
status_change_end(src,SC_CAMOUFLAGE, INVALID_TIMER);// only normal attack and auto cast skills benefit from its bonuses
map->freeblock_lock();
@@ -9849,7 +9915,6 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char
}
pc_stop_attack(sd);
- pc_stop_walking(sd,0);
if(battle_config.skill_log && battle_config.skill_log&BL_PC)
ShowInfo("PC %d skill castend skill =%d map=%s\n",sd->bl.id,skill_id,mapname);
@@ -9959,7 +10024,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
int r;
//if(skill_lv <= 0) return 0;
- if(skill_id > 0 && !skill_lv) return 0; // [Celest]
+ if(skill_id > 0 && !skill_lv) return 0; // [Celest]
nullpo_ret(src);
@@ -10051,11 +10116,17 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
}
case MG_SAFETYWALL:
+ {
+ int alive = 1;
+ if ( map->foreachincell(skill->cell_overlap, src->m, x, y, BL_SKILL, skill_id, &alive, src) ) {
+ skill->unitsetting(src, skill_id, skill_lv, x, y, 0);
+ return 0; // Don't consume gems if cast on LP
+ }
+ }
case MG_FIREWALL:
case MG_THUNDERSTORM:
case AL_PNEUMA:
- case WZ_ICEWALL:
case WZ_FIREPILLAR:
case WZ_QUAGMIRE:
case WZ_VERMILION:
@@ -10086,7 +10157,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case WE_CALLPARTNER:
case WE_CALLPARENT:
case WE_CALLBABY:
- case AC_SHOWER: //Ground-placed skill implementation.
+ case AC_SHOWER: //Ground-placed skill implementation.
case MA_SHOWER:
case SA_LANDPROTECTOR:
case BD_LULLABY:
@@ -10140,6 +10211,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case GN_THORNS_TRAP:
case GN_DEMONIC_FIRE:
case GN_HELLS_PLANT:
+ case GN_FIRE_EXPANSION_SMOKE_POWDER:
+ case GN_FIRE_EXPANSION_TEAR_GAS:
case SO_EARTHGRAVE:
case SO_DIAMONDDUST:
case SO_FIRE_INSIGNIA:
@@ -10164,7 +10237,12 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
sc_start(src,src,SC_NO_SWITCH_EQUIP,100,0,skill->get_time(skill_id,skill_lv));
skill->unitsetting(src,skill_id,skill_lv,x,y,0);
break;
- case RG_GRAFFITI: /* Graffiti [Valaris] */
+ case WZ_ICEWALL:
+ flag |= 1;
+ if( skill->unitsetting(src,skill_id,skill_lv,x,y,0) )
+ map->list[src->m].setcell(src->m, x, y, CELL_NOICEWALL, true);
+ break;
+ case RG_GRAFFITI:
skill->clear_unitgroup(src);
skill->unitsetting(src,skill_id,skill_lv,x,y,0);
flag|=1;
@@ -10214,7 +10292,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
tmpx = x - area + rnd()%(area * 2 + 1);
tmpy = y - area + rnd()%(area * 2 + 1);
- if( i == 0 && path->search_long(NULL, src->m, src->x, src->y, tmpx, tmpy, CELL_CHKWALL) )
+ if( i == 0 && path->search_long(NULL, src->m, src->x, src->y, tmpx, tmpy, CELL_CHKWALL)
+ && !map->getcell(src->m, tmpx, tmpy, CELL_CHKLANDPROTECTOR))
clif->skill_poseffect(src,skill_id,skill_lv,tmpx,tmpy,tick);
if( i > 0 )
@@ -10268,7 +10347,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
struct mob_data *md;
// Correct info, don't change any of this! [Celest]
- md = mob->once_spawn_sub(src, src->m, x, y, status->get_name(src), class_, "", SZ_MEDIUM, AI_NONE);
+ md = mob->once_spawn_sub(src, src->m, x, y, status->get_name(src), class_, "", SZ_SMALL, AI_NONE);
if (md) {
md->master_id = src->id;
md->special_state.ai = (skill_id == AM_SPHEREMINE) ? AI_SPHERE : AI_FLORA;
@@ -10358,7 +10437,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
// Plant Cultivation [Celest]
case CR_CULTIVATION:
if (sd) {
- if( map->count_oncell(src->m,x,y,BL_CHAR) > 0 ) {
+ if( map->count_oncell(src->m,x,y,BL_CHAR,0) > 0 ) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 1;
}
@@ -10366,7 +10445,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
if (rnd()%100 < 50) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
} else {
- TBL_MOB* md = mob->once_spawn_sub(src, src->m, x, y, "--ja--",(skill_lv < 2 ? 1084+rnd()%2 : 1078+rnd()%6),"", SZ_MEDIUM, AI_NONE);
+ TBL_MOB* md = mob->once_spawn_sub(src, src->m, x, y, "--ja--",(skill_lv < 2 ? 1084+rnd()%2 : 1078+rnd()%6),"", SZ_SMALL, AI_NONE);
int i;
if (!md) break;
if ((i = skill->get_time(skill_id, skill_lv)) > 0)
@@ -10408,7 +10487,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
sc_start(src,src,type,100,skill_lv,skill->get_time2(skill_id,skill_lv));
break;
- case AM_RESURRECTHOMUN: // [orn]
+ case AM_RESURRECTHOMUN: // [orn]
if (sd) {
if (!homun->ressurect(sd, 20*skill_lv, x, y)) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
@@ -10513,7 +10592,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
int class_ = 2042;
struct mob_data *md;
- md = mob->once_spawn_sub(src, src->m, x, y, status->get_name(src), class_, "", SZ_MEDIUM, AI_NONE);
+ md = mob->once_spawn_sub(src, src->m, x, y, status->get_name(src), class_, "", SZ_SMALL, AI_NONE);
if( md ) {
md->master_id = src->id;
md->special_state.ai = AI_FLORA;
@@ -10577,42 +10656,27 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case GN_CRAZYWEED:
{
int area = skill->get_splash(skill_id, skill_lv);
- short tmpx = 0, tmpy = 0, x1 = 0, y1 = 0;
for( r = 0; r < 3 + (skill_lv>>1); r++ ) {
// Creates a random Cell in the Splash Area
- tmpx = x - area + rnd()%(area * 2 + 1);
- tmpy = y - area + rnd()%(area * 2 + 1);
-
- if( r > 0 )
- skill->addtimerskill(src,tick+r*250,0,tmpx,tmpy,GN_CRAZYWEED,skill_lv,(x1<<16)|y1,flag);
+ int tmpx = x - area + rnd()%(area * 2 + 1);
+ int tmpy = y - area + rnd()%(area * 2 + 1);
- x1 = tmpx;
- y1 = tmpy;
+ skill->addtimerskill(src,tick+r*250,0,tmpx,tmpy,GN_CRAZYWEED_ATK,skill_lv,-1,0);
}
-
- skill->addtimerskill(src,tick+r*250,0,tmpx,tmpy,GN_CRAZYWEED,skill_lv,-1,flag);
}
break;
- case GN_CRAZYWEED_ATK: {
- int dummy = 1;
- //Enable if any unique animation gets added to this skill ID in the future. [Rytech]
- //clif_skill_poseffect(src,skillid,skilllv,x,y,tick);
- r = skill->get_splash(skill_id, skill_lv);
- map->foreachinarea(skill->cell_overlap, src->m, x-r, y-r, x+r, y+r, BL_SKILL, skill_id, &dummy, src);
- map->foreachinarea(skill->area_sub, src->m, x-r, y-r, x+r, y+r, BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id);
- }
- break;
case GN_FIRE_EXPANSION: {
int i;
+ int aciddemocast = 5;//If player doesent know Acid Demonstration or knows level 5 or lower, effect 5 will cast level 5 Acid Demo.
struct unit_data *ud = unit->bl2ud(src);
if( !ud ) break;
for( i = 0; i < MAX_SKILLUNITGROUP && ud->skillunit[i]; i ++ ) {
if( ud->skillunit[i]->skill_id == GN_DEMONIC_FIRE &&
- distance_xy(x, y, ud->skillunit[i]->unit->bl.x, ud->skillunit[i]->unit->bl.y) < 4 ) {
+ distance_xy(x, y, ud->skillunit[i]->unit->bl.x, ud->skillunit[i]->unit->bl.y) < 3 ) {
switch( skill_lv ) {
case 3:
ud->skillunit[i]->unit_id = UNT_FIRE_EXPANSION_SMOKE_POWDER;
@@ -10622,11 +10686,13 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
ud->skillunit[i]->unit_id = UNT_FIRE_EXPANSION_TEAR_GAS;
clif->changetraplook(&ud->skillunit[i]->unit->bl, UNT_FIRE_EXPANSION_TEAR_GAS);
break;
- case 5:
+ case 5:// If player knows a level of Acid Demonstration greater then 5, that level will be casted.
+ if ( pc->checkskill(sd, CR_ACIDDEMONSTRATION) > 5 )
+ aciddemocast = pc->checkskill(sd, CR_ACIDDEMONSTRATION);
map->foreachinarea(skill->area_sub, src->m,
- ud->skillunit[i]->unit->bl.x - 3, ud->skillunit[i]->unit->bl.y - 3,
- ud->skillunit[i]->unit->bl.x + 3, ud->skillunit[i]->unit->bl.y + 3, BL_CHAR,
- src, CR_ACIDDEMONSTRATION, sd ? pc->checkskill(sd, CR_ACIDDEMONSTRATION) : skill_lv, tick, flag|BCT_ENEMY|1|SD_LEVEL, skill->castend_damage_id);
+ ud->skillunit[i]->unit->bl.x - 2, ud->skillunit[i]->unit->bl.y - 2,
+ ud->skillunit[i]->unit->bl.x + 2, ud->skillunit[i]->unit->bl.y + 2, BL_CHAR,
+ src, CR_ACIDDEMONSTRATION, aciddemocast, tick, flag|BCT_ENEMY|1|SD_LEVEL, skill->castend_damage_id);
skill->delunit(ud->skillunit[i]->unit);
break;
default:
@@ -10750,7 +10816,8 @@ bool skill_dance_switch(struct skill_unit* su, int flag) {
}
prevflag = flag;
- if( !flag ) { //Transform
+ if( !flag ) {
+ //Transform
uint16 skill_id = su->val2&UF_SONG ? BA_DISSONANCE : DC_UGLYDANCE;
// backup
@@ -10768,7 +10835,8 @@ bool skill_dance_switch(struct skill_unit* su, int flag) {
group->target_flag = skill->get_unit_target(skill_id);
group->bl_flag = skill->get_unit_bl_target(skill_id);
group->interval = skill->get_unit_interval(skill_id);
- } else { //Restore
+ } else {
+ //Restore
group->skill_id = backup.skill_id;
group->skill_lv = backup.skill_lv;
group->unit_id = backup.unit_id;
@@ -10779,28 +10847,6 @@ bool skill_dance_switch(struct skill_unit* su, int flag) {
return true;
}
-/**
- * Upon Ice Wall cast it checks all nearby mobs to find any who may be blocked by the IW
- **/
-int skill_icewall_block(struct block_list *bl,va_list ap) {
- struct block_list *target = NULL;
- struct mob_data *md = ((TBL_MOB*)bl);
-
- nullpo_ret(bl);
- nullpo_ret(md);
- if( !md->target_id || ( target = map->id2bl(md->target_id) ) == NULL )
- return 0;
-
- if( path->search_long(NULL,bl->m,bl->x,bl->y,target->x,target->y,CELL_CHKICEWALL) )
- return 0;
-
- if( !check_distance_bl(bl, target, status_get_range(bl) ) ) {
- mob->unlocktarget(md,timer->gettick());
- mob_stop_walking(md,1);
- }
-
- return 0;
-}
/*==========================================
* Initializes and sets a ground skill.
* flag&1 is used to determine when the skill 'morphs' (Warp portal becomes active, or Fire Pillar becomes active)
@@ -10835,7 +10881,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_
sd = BL_CAST(BL_PC, src);
st = status->get_status_data(src);
- sc = status->get_sc(src); // for traps, firewall and fogwall - celest
+ sc = status->get_sc(src); // for traps, firewall and fogwall - celest
switch( skill_id ) {
case SO_ELEMENTAL_SHIELD:
@@ -10862,10 +10908,10 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_
case AL_WARP:
val1=skill_lv+6;
- if(!(flag&1))
+ if(!(flag&1)) {
limit=2000;
- else // previous implementation (not used anymore)
- { //Warp Portal morphing to active mode, extract relevant data from src. [Skotlex]
+ } else { // previous implementation (not used anymore)
+ //Warp Portal morphing to active mode, extract relevant data from src. [Skotlex]
if( src->type != BL_SKILL ) return NULL;
group = ((TBL_SKILL*)src)->group;
src = map->id2bl(group->src_id);
@@ -10890,7 +10936,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_
limit=1000;
val1=skill_lv+2;
break;
- case WZ_QUAGMIRE: //The target changes to "all" if used in a gvg map. [Skotlex]
+ case WZ_QUAGMIRE: //The target changes to "all" if used in a gvg map. [Skotlex]
case AM_DEMONSTRATION:
case GN_HELLS_PLANT:
if( skill_id == GN_HELLS_PLANT && map->getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) )
@@ -10944,17 +10990,18 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_
case SA_VIOLENTGALE:
{
struct skill_unit_group *old_sg;
- if ((old_sg = skill->locate_element_field(src)) != NULL)
- { //HelloKitty confirmed that these are interchangeable,
+ if ((old_sg = skill->locate_element_field(src)) != NULL) {
+ //HelloKitty confirmed that these are interchangeable,
//so you can change element and not consume gemstones.
- if ((
- old_sg->skill_id == SA_VOLCANO ||
- old_sg->skill_id == SA_DELUGE ||
- old_sg->skill_id == SA_VIOLENTGALE
- ) && old_sg->limit > 0)
- { //Use the previous limit (minus the elapsed time) [Skotlex]
+ if (( old_sg->skill_id == SA_VOLCANO
+ || old_sg->skill_id == SA_DELUGE
+ || old_sg->skill_id == SA_VIOLENTGALE
+ )
+ && old_sg->limit > 0
+ ) {
+ //Use the previous limit (minus the elapsed time) [Skotlex]
limit = old_sg->limit - DIFF_TICK32(timer->gettick(), old_sg->tick);
- if (limit < 0) //This can happen...
+ if (limit < 0) //This can happen...
limit = skill->get_time(skill_id,skill_lv);
}
skill->clear_group(src,1);
@@ -11010,22 +11057,24 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_
val1 += pc->checkskill(sd,BA_MUSICALLESSON);
break;
case DC_SERVICEFORYOU:
- val1 = 15+skill_lv+(st->int_/10); // MaxSP percent increase TO-DO: this INT bonus value is guessed
+ val1 = 15+skill_lv+(st->int_/10); // MaxSP percent increase
val2 = 20+3*skill_lv+(st->int_/10); // SP cost reduction
if(sd){
- val1 += pc->checkskill(sd,DC_DANCINGLESSON); //TO-DO This bonus value is guessed
- val2 += pc->checkskill(sd,DC_DANCINGLESSON); //TO-DO Should be half this value
+ val1 += pc->checkskill(sd,DC_DANCINGLESSON) / 2;
+ val2 += pc->checkskill(sd,DC_DANCINGLESSON) / 2;
}
break;
case BA_ASSASSINCROSS:
-#ifdef RENEWAL
- val1 = 10 + skill_lv + (st->agi/10); // ASPD increase
if(sd)
- val1 += 4*pc->checkskill(sd,BA_MUSICALLESSON);
+ val1 = pc->checkskill(sd,BA_MUSICALLESSON) / 2;
+#ifdef RENEWAL
+ // This formula was taken from a RE calculator
+ // and the changes published on irowiki
+ // Luckily, official tests show it's the right one
+ val1 += skill_lv + (st->agi/20);
#else
- val1 = 100+(10*skill_lv)+(st->agi/10); // ASPD increase
- if(sd)
- val1 += 5*pc->checkskill(sd,BA_MUSICALLESSON);
+ val1 += 10 + skill_lv + (st->agi/10); // ASPD increase
+ val1 *= 10; // ASPD works with 1000 as 100%
#endif
break;
case DC_FORTUNEKISS:
@@ -11036,22 +11085,22 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_
break;
case BD_DRUMBATTLEFIELD:
#ifdef RENEWAL
- val1 = (skill_lv+5)*25; //Watk increase
- val2 = skill_lv*10; //Def increase
+ val1 = (skill_lv+5)*25; //Watk increase
+ val2 = skill_lv*10; //Def increase
#else
- val1 = (skill_lv+1)*25; //Watk increase
- val2 = (skill_lv+1)*2; //Def increase
+ val1 = (skill_lv+1)*25; //Watk increase
+ val2 = (skill_lv+1)*2; //Def increase
#endif
break;
case BD_RINGNIBELUNGEN:
- val1 = (skill_lv+2)*25; //Watk increase
+ val1 = (skill_lv+2)*25; //Watk increase
break;
case BD_RICHMANKIM:
val1 = 25 + 11*skill_lv; //Exp increase bonus.
break;
case BD_SIEGFRIED:
- val1 = 55 + skill_lv*5; //Elemental Resistance
- val2 = skill_lv*10; //Status ailment resistance
+ val1 = 55 + skill_lv*5; //Elemental Resistance
+ val2 = skill_lv*10; //Status ailment resistance
break;
case WE_CALLPARTNER:
if (sd) val1 = sd->status.partner_id;
@@ -11141,6 +11190,10 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_
case SO_WARMER:
skill->clear_group(src, 8);
break;
+ case SO_VACUUM_EXTREME:
+ val1 = x;
+ val2 = y;
+ break;
case GN_WALLOFTHORN:
if( flag&1 )
limit = 3000;
@@ -11148,13 +11201,13 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_
break;
case KO_ZENKAI:
if( sd ){
- ARR_FIND(1, 6, i, sd->charm[i] > 0);
- if( i < 5 ){
- val1 = sd->charm[i]; // no. of aura
+ ARR_FIND(SPIRITS_TYPE_CHARM_WATER, SPIRITS_TYPE_SPHERE, i, sd->spiritcharm[i] > 0);
+ if( i < SPIRITS_TYPE_SPHERE ){
+ val1 = sd->spiritcharm[i]; // no. of aura
val2 = i; // aura type
limit += val1 * 1000;
subunt = i - 1;
- pc->del_charm(sd, sd->charm[i], i);
+ pc->del_charm(sd, sd->spiritcharm[i], i);
}
}
break;
@@ -11170,7 +11223,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_
group->state.song_dance = (unit_flag&(UF_DANCE|UF_SONG)?1:0)|(unit_flag&UF_ENSEMBLE?2:0); //Signals if this is a song/dance/duet
group->state.guildaura = ( skill_id >= GD_LEADERSHIP && skill_id <= GD_HAWKEYES )?1:0;
group->item_id = req_item;
- //if tick is greater than current, do not invoke onplace function just yet. [Skotlex]
+ //if tick is greater than current, do not invoke onplace function just yet. [Skotlex]
if (DIFF_TICK(group->tick, timer->gettick()) > SKILLUNITTIMER_INTERVAL)
active_flag = 0;
@@ -11266,8 +11319,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_
if (skill->get_unit_flag(skill_id) & UF_RANGEDSINGLEUNIT && i == (layout->count / 2))
val2 |= UF_RANGEDSINGLEUNIT; // center.
- if( range <= 0 )
- map->foreachincell(skill->cell_overlap,src->m,ux,uy,BL_SKILL,skill_id, &alive, src);
+ map->foreachincell(skill->cell_overlap,src->m,ux,uy,BL_SKILL,skill_id, &alive, src);
if( !alive )
continue;
@@ -11294,9 +11346,6 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_
//success, unit created.
switch( skill_id ) {
- case WZ_ICEWALL:
- map->foreachinrange(skill->icewall_block, src, AREA_SIZE, BL_MOB);
- break;
case NJ_TATAMIGAESHI: //Store number of tiles.
group->val1 = group->alive_count;
break;
@@ -11325,7 +11374,7 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick
nullpo_ret(sg=src->group);
nullpo_ret(ss=map->id2bl(sg->src_id));
- if( skill->get_type(sg->skill_id) == BF_MAGIC && map->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) && sg->skill_id != SA_LANDPROTECTOR )
+ if( skill->get_type(sg->skill_id) == BF_MAGIC && map->getcell(src->bl.m, src->bl.x, src->bl.y, CELL_CHKLANDPROTECTOR) && sg->skill_id != SA_LANDPROTECTOR )
return 0; //AoE skills are ineffective. [Skotlex]
sc = status->get_sc(bl);
@@ -11335,6 +11384,9 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick
if (sc && sc->data[SC_VACUUM_EXTREME] && map->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR))
status_change_end(bl, SC_VACUUM_EXTREME, INVALID_TIMER);
+ if ( sc && sc->data[SC_HOVERING] && ( sg->skill_id == SO_VACUUM_EXTREME || sg->skill_id == SO_ELECTRICWALK || sg->skill_id == SO_FIREWALK || sg->skill_id == WZ_QUAGMIRE ) )
+ return 0;
+
type = status->skill2sc(sg->skill_id);
sce = (sc && type != -1)?sc->data[type]:NULL;
skill_id = sg->skill_id; //In case the group is deleted, we need to return the correct skill id, still.
@@ -11346,7 +11398,7 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick
break;
} else if( sc && battle->check_target(&sg->unit->bl,bl,sg->target_flag) > 0 ) {
int sec = skill->get_time2(sg->skill_id,sg->skill_lv);
- if( status->change_start(ss, bl,type,10000,sg->skill_lv,1,sg->group_id,0,sec,8) ) {
+ if( status->change_start(ss, bl,type,10000,sg->skill_lv,1,sg->group_id,0,sec,SCFLAG_FIXEDRATE) ) {
const struct TimerData* td = sc->data[type]?timer->get(sc->data[type]->timer):NULL;
if( td )
sec = DIFF_TICK32(td->tick, tick);
@@ -11444,10 +11496,10 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick
if (!sce)
sc_start4(ss,bl,type,100,sg->skill_lv,sg->val1,sg->val2,0,sg->limit);
break;
+ case UNT_APPLEIDUN:
case UNT_WHISTLE:
case UNT_ASSASSINCROSS:
case UNT_POEMBRAGI:
- case UNT_APPLEIDUN:
case UNT_HUMMING:
case UNT_DONTFORGETME:
case UNT_FORTUNEKISS:
@@ -11458,12 +11510,13 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick
if (!sc) return 0;
if (!sce)
sc_start4(ss,bl,type,100,sg->skill_lv,sg->val1,sg->val2,0,sg->limit);
- else if (sce->val4 == 1) {
+ else if (battle_config.song_timer_reset && sce->val4 == 1) {
//Readjust timers since the effect will not last long.
sce->val4 = 0;
timer->delete(sce->timer, status->change_timer);
sce->timer = timer->add(tick+sg->limit, status->change_timer, bl->id, type);
}
+
break;
case UNT_FOGWALL:
@@ -11480,12 +11533,13 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick
sc_start4(ss,bl,type,100,sg->skill_lv,0,BCT_ENEMY,sg->group_id,sg->limit);
break;
- // officially, icewall has no problems existing on occupied cells [ultramage]
- // case UNT_ICEWALL: //Destroy the cell. [Skotlex]
- // src->val1 = 0;
- // if(src->limit + sg->tick > tick + 700)
- // src->limit = DIFF_TICK32(tick+700,sg->tick);
- // break;
+#if 0 // officially, icewall has no problems existing on occupied cells [ultramage]
+ case UNT_ICEWALL: //Destroy the cell. [Skotlex]
+ src->val1 = 0;
+ if(src->limit + sg->tick > tick + 700)
+ src->limit = DIFF_TICK32(tick+700,sg->tick);
+ break;
+#endif // 0
case UNT_MOONLIT:
//Knockback out of area if affected char isn't in Moonlit effect
@@ -11498,7 +11552,7 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick
case UNT_WALLOFTHORN:
if( status_get_mode(bl)&MD_BOSS )
- break; // iRO Wiki says that this skill don't affect to Boss monsters.
+ break; // iRO Wiki says that this skill don't affect to Boss monsters.
if( map_flag_vs(bl->m) || bl->id == src->bl.id || battle->check_target(&src->bl,bl, BCT_ENEMY) == 1 )
skill->attack(skill->get_type(sg->skill_id), ss, &src->bl, bl, sg->skill_id, sg->skill_lv, tick, 0);
break;
@@ -11554,9 +11608,6 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
tsc = status->get_sc(bl);
ssc = status->get_sc(ss); // Status Effects for Unit caster.
- if ( tsc && tsc->data[SC_HOVERING] )
- return 0; //Under hovering characters are immune to trap and ground target skills.
-
// Maestro or Wanderer is unaffected by traps of trappers he or she charmed [SuperHulk]
if ( ssc && ssc->data[SC_SIREN] && ssc->data[SC_SIREN]->val2 == bl->id && (skill->get_inf2(sg->skill_id)&INF2_TRAP) )
return 0;
@@ -11565,6 +11616,26 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
type = status->skill2sc(sg->skill_id);
skill_id = sg->skill_id;
+ if ( tsc && tsc->data[SC_HOVERING] ) {
+ switch ( skill_id ) {
+ case HT_SKIDTRAP:
+ case HT_LANDMINE:
+ case HT_ANKLESNARE:
+ case HT_FLASHER:
+ case HT_SHOCKWAVE:
+ case HT_SANDMAN:
+ case HT_FREEZINGTRAP:
+ case HT_BLASTMINE:
+ case HT_CLAYMORETRAP:
+ case HW_GRAVITATION:
+ case SA_DELUGE:
+ case SA_VOLCANO:
+ case SA_VIOLENTGALE:
+ case NJ_SUITON:
+ return 0;
+ }
+ }
+
if (sg->interval == -1) {
switch (sg->unit_id) {
case UNT_ANKLESNARE: //These happen when a trap is splash-triggered by multiple targets on the same cell.
@@ -11586,7 +11657,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
ts->tick = tick+sg->interval;
if ((skill_id==CR_GRANDCROSS || skill_id==NPC_GRANDDARKNESS) && !battle_config.gx_allhit)
- ts->tick += sg->interval*(map->count_oncell(bl->m,bl->x,bl->y,BL_CHAR)-1);
+ ts->tick += sg->interval*(map->count_oncell(bl->m,bl->x,bl->y,BL_CHAR,0)-1);
}
switch (sg->unit_id) {
@@ -11727,7 +11798,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
case UNT_MANHOLE:
if( sg->val2 == 0 && tsc && (sg->unit_id == UNT_ANKLESNARE || bl->id != sg->src_id) ) {
int sec = skill->get_time2(sg->skill_id,sg->skill_lv);
- if( status->change_start(ss,bl,type,10000,sg->skill_lv,sg->group_id,0,0,sec, 8) ) {
+ if( status->change_start(ss,bl,type,10000,sg->skill_lv,sg->group_id,0,0,sec, SCFLAG_FIXEDRATE) ) {
const struct TimerData* td = tsc->data[type]?timer->get(tsc->data[type]->timer):NULL;
if( td )
sec = DIFF_TICK32(td->tick, tick);
@@ -11757,7 +11828,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
if( bl->id != ss->id ) {
if( status_get_mode(bl)&MD_BOSS )
break;
- if( status->change_start(ss,bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id, sg->skill_lv), 8) ) {
+ if( status->change_start(ss,bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id, sg->skill_lv), SCFLAG_FIXEDRATE) ) {
map->moveblock(bl, src->bl.x, src->bl.y, tick);
clif->fixpos(bl);
@@ -11770,7 +11841,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
case UNT_VENOMDUST:
if(tsc && !tsc->data[type])
- status->change_start(ss,bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id,sg->skill_lv),0);
+ status->change_start(ss,bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id,sg->skill_lv),SCFLAG_NONE);
break;
@@ -11822,7 +11893,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
skill->additional_effect(ss, bl, sg->skill_id, sg->skill_lv, BF_LONG|BF_SKILL|BF_MISC, ATK_DEF, tick);
break;
- case UNT_UGLYDANCE: //Ugly Dance [Skotlex]
+ case UNT_UGLYDANCE:
if (ss->id != bl->id)
skill->additional_effect(ss, bl, sg->skill_id, sg->skill_lv, BF_LONG|BF_SKILL|BF_MISC, ATK_DEF, tick);
break;
@@ -11836,20 +11907,39 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
int heal;
#ifdef RENEWAL
struct mob_data *md = BL_CAST(BL_MOB, bl);
- if( md && md->class_ == MOBID_EMPERIUM )
+ if (md && md->class_ == MOBID_EMPERIUM)
break;
#endif
- if( sg->src_id == bl->id && !(tsc && tsc->data[SC_SOULLINK] && tsc->data[SC_SOULLINK]->val2 == SL_BARDDANCER) )
- break; // affects self only when soullinked
+ if ((sg->src_id == bl->id && !(tsc && tsc->data[SC_SOULLINK] && tsc->data[SC_SOULLINK]->val2 == SL_BARDDANCER))
+ || (!(battle_config.song_timer_reset) && tsc && tsc->data[type] && tsc->data[type]->val4 == 1))
+ break;
+
heal = skill->calc_heal(ss,bl,sg->skill_id, sg->skill_lv, true);
if( tsc->data[SC_AKAITSUKI] && heal )
heal = ~heal + 1;
clif->skill_nodamage(&src->bl, bl, AL_HEAL, heal, 1);
status->heal(bl, heal, 0, 0);
- break;
- }
- case UNT_TATAMIGAESHI:
+ if (!battle_config.song_timer_reset)
+ sc_start4(ss, bl, type, 100, sg->skill_lv, sg->val1, sg->val2, 0, sg->limit);
+ }
+ break;
+ case UNT_POEMBRAGI:
+ case UNT_WHISTLE:
+ case UNT_ASSASSINCROSS:
+ case UNT_HUMMING:
+ case UNT_DONTFORGETME:
+ case UNT_FORTUNEKISS:
+ case UNT_SERVICEFORYOU:
+ if (battle_config.song_timer_reset
+ || (!(battle_config.song_timer_reset) && tsc && tsc->data[type] && tsc->data[type]->val4 == 1)
+ || (sg->src_id == bl->id && !(tsc && tsc->data[SC_SOULLINK] && tsc->data[SC_SOULLINK]->val2 == SL_BARDDANCER))
+ )
+ break;
+
+ sc_start4(ss, bl, type, 100, sg->skill_lv, sg->val1, sg->val2, 0, sg->limit);
+ break;
+ case UNT_TATAMIGAESHI:
case UNT_DEMONSTRATION:
skill->attack(BF_WEAPON,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0);
break;
@@ -12073,7 +12163,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
clif->fixpos(bl);
sg->val2 = bl->id;
} else
- sec = 3000; // Couldn't trap it?
+ sec = 3000; // Couldn't trap it?
sg->limit = DIFF_TICK32(tick, sg->tick) + sec;
} else if( tsc->data[SC_THORNS_TRAP] && bl->id == sg->val2 )
skill->attack(skill->get_type(GN_THORNS_TRAP), ss, ss, bl, sg->skill_id, sg->skill_lv, tick, SD_LEVEL|SD_ANIMATION);
@@ -12101,11 +12191,11 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
break;
case UNT_FIRE_EXPANSION_SMOKE_POWDER:
- sc_start(ss, bl, status->skill2sc(GN_FIRE_EXPANSION_SMOKE_POWDER), 100, sg->skill_lv, 1000);
+ sc_start(ss, bl, SC_FIRE_EXPANSION_SMOKE_POWDER, 100, sg->skill_lv, 1000);
break;
case UNT_FIRE_EXPANSION_TEAR_GAS:
- sc_start(ss, bl, status->skill2sc(GN_FIRE_EXPANSION_TEAR_GAS), 100, sg->skill_lv, 1000);
+ sc_start(ss, bl, SC_FIRE_EXPANSION_TEAR_GAS, 100, sg->skill_lv, 1000);
break;
case UNT_HELLS_PLANT:
@@ -12117,12 +12207,13 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
case UNT_CLOUD_KILL:
if(tsc && !tsc->data[type])
- status->change_start(ss,bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id,sg->skill_lv),8);
+ status->change_start(ss,bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id,sg->skill_lv),SCFLAG_FIXEDRATE);
skill->attack(skill->get_type(sg->skill_id),ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0);
break;
case UNT_WARMER:
- if( bl->type == BL_PC && !battle->check_undead(tstatus->race, tstatus->def_ele) && tstatus->race != RC_DEMON ) {
+ {
+ // It has effect on everything, including monsters, undead property and demon
int hp = 0;
if( ssc && ssc->data[SC_HEATER_OPTION] )
hp = tstatus->max_hp * 3 * sg->skill_lv / 100;
@@ -12134,10 +12225,9 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
if( tsc && tsc->data[SC_AKAITSUKI] && hp )
hp = ~hp + 1;
status->heal(bl, hp, 0, 0);
- sc_start(ss, bl, SC_WARMER, 100, sg->skill_lv, skill->get_time2(sg->skill_id,sg->skill_lv));
+ sc_start(ss, bl, type, 100, sg->skill_lv, sg->interval + 100);
}
break;
-
case UNT_FIRE_INSIGNIA:
case UNT_WATER_INSIGNIA:
case UNT_WIND_INSIGNIA:
@@ -12163,11 +12253,18 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
break;
case UNT_VACUUM_EXTREME:
- if ( tsc && tsc->data[SC_HALLUCINATIONWALK] ) {
+ if (tsc && (tsc->data[SC_HALLUCINATIONWALK] || tsc->data[SC_VACUUM_EXTREME])) {
return 0;
} else {
sg->limit -= 100 * tstatus->str/20;
sc_start(ss, bl, SC_VACUUM_EXTREME, 100, sg->skill_lv, sg->limit);
+
+ if ( !map_flag_gvg(bl->m) && !map->list[bl->m].flag.battleground && !is_boss(bl) ) {
+ if (unit->movepos(bl, sg->val1, sg->val2, 0, 0)) {
+ clif->slide(bl, sg->val1, sg->val2);
+ clif->fixpos(bl);
+ }
+ }
}
break;
@@ -12212,7 +12309,8 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
case UNT_POISON_MIST:
skill->attack(BF_MAGIC, ss, &src->bl, bl, sg->skill_id, sg->skill_lv, tick, 0);
- status->change_start(ss, bl, SC_BLIND, rnd() % 100 > sg->skill_lv * 10, sg->skill_lv, sg->skill_id, 0, 0, skill->get_time2(sg->skill_id, sg->skill_lv), 2|8);
+ status->change_start(ss, bl, SC_BLIND, rnd() % 100 > sg->skill_lv * 10, sg->skill_lv, sg->skill_id, 0, 0,
+ skill->get_time2(sg->skill_id, sg->skill_lv), SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE);
break;
}
@@ -12245,10 +12343,8 @@ int skill_unit_onout(struct skill_unit *src, struct block_list *bl, int64 tick)
switch(sg->unit_id){
case UNT_SAFETYWALL:
case UNT_PNEUMA:
- case UNT_EPICLESIS://Arch Bishop
case UNT_NEUTRALBARRIER:
case UNT_STEALTHFIELD:
- case UNT_WARMER:
if (sce)
status_change_end(bl, type, INVALID_TIMER);
break;
@@ -12257,7 +12353,8 @@ int skill_unit_onout(struct skill_unit *src, struct block_list *bl, int64 tick)
if( sce && sce->val4 == src->bl.id )
status_change_end(bl, type, INVALID_TIMER);
break;
- case UNT_HERMODE: //Clear Hermode if the owner moved.
+ case UNT_HERMODE:
+ //Clear Hermode if the owner moved.
if (sce && sce->val3 == BCT_SELF && sce->val4 == sg->group_id)
status_change_end(bl, type, INVALID_TIMER);
break;
@@ -12273,6 +12370,16 @@ int skill_unit_onout(struct skill_unit *src, struct block_list *bl, int64 tick)
}
}
break;
+ case UNT_WHISTLE:
+ case UNT_ASSASSINCROSS:
+ case UNT_POEMBRAGI:
+ case UNT_APPLEIDUN:
+ case UNT_HUMMING:
+ case UNT_DONTFORGETME:
+ case UNT_FORTUNEKISS:
+ case UNT_SERVICEFORYOU:
+ if (sg->src_id==bl->id && !(sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_BARDDANCER))
+ return -1;
}
return sg->skill_id;
}
@@ -12308,8 +12415,8 @@ int skill_unit_onleft(uint16 skill_id, struct block_list *bl, int64 tick) {
case BD_ROKISWEIL:
case BD_INTOABYSS:
case BD_SIEGFRIED:
- if(sc && sc->data[SC_DANCING] && (sc->data[SC_DANCING]->val1&0xFFFF) == skill_id)
- { //Check if you just stepped out of your ensemble skill to cancel dancing. [Skotlex]
+ if(sc && sc->data[SC_DANCING] && (sc->data[SC_DANCING]->val1&0xFFFF) == skill_id) {
+ //Check if you just stepped out of your ensemble skill to cancel dancing. [Skotlex]
//We don't check for SC_LONGING because someone could always have knocked you back and out of the song/dance.
//FIXME: This code is not perfect, it doesn't checks for the real ensemble's owner,
//it only checks if you are doing the same ensemble. So if there's two chars doing an ensemble
@@ -12350,7 +12457,9 @@ int skill_unit_onleft(uint16 skill_id, struct block_list *bl, int64 tick) {
case DC_DONTFORGETME:
case DC_FORTUNEKISS:
case DC_SERVICEFORYOU:
- if (sce) {
+ if ((battle_config.song_timer_reset && sce) // athena style
+ || (!battle_config.song_timer_reset && sce && sce->val4 != 1)
+ ) {
timer->delete(sce->timer, status->change_timer);
//NOTE: It'd be nice if we could get the skill_lv for a more accurate extra time, but alas...
//not possible on our current implementation.
@@ -12413,11 +12522,11 @@ int skill_unit_effect(struct block_list* bl, va_list ap) {
} else {
if( flag&1 )
skill->unit_onplace(su,bl,tick);
- else
- skill->unit_onout(su,bl,tick);
+ else if (skill->unit_onout(su,bl,tick) == -1)
+ return 0; // Don't let a Bard/Dancer update their own song timer
if( flag&4 )
- skill->unit_onleft(skill_id, bl, tick);
+ skill->unit_onleft(skill_id, bl, tick);
}
if( dissonance ) skill->dance_switch(su, 1);
@@ -12467,7 +12576,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) {
struct block_list *src;
struct map_session_data *sd;
struct map_session_data *tsd;
- int *p_sd; //Contains the list of characters found.
+ int *p_sd; //Contains the list of characters found.
nullpo_ret(bl);
nullpo_ret(tsd=(struct map_session_data*)bl);
@@ -12558,7 +12667,8 @@ int skill_check_pc_partner (struct map_session_data *sd, uint16 skill_id, uint16
if (!battle_config.player_skill_partner_check || pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL))
return is_chorus ? MAX_PARTY : 99; //As if there were infinite partners.
- if (cast_flag) { //Execute the skill on the partners.
+ if (cast_flag) {
+ //Execute the skill on the partners.
struct map_session_data* tsd;
switch (skill_id) {
case PR_BENEDICTIO:
@@ -12631,7 +12741,7 @@ int skill_isammotype (struct map_session_data *sd, int skill_id)
(sd->status.weapon == W_BOW || (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)) &&
skill_id != HT_PHANTASMIC &&
skill->get_type(skill_id) == BF_WEAPON &&
- !(skill->get_nk(skill_id)&NK_NO_DAMAGE) &&
+ !(skill->get_nk(skill_id)&NK_NO_DAMAGE) &&
!skill->get_spiritball(skill_id,1) //Assume spirit spheres are used as ammo instead.
);
}
@@ -12674,8 +12784,8 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
if (sd->chatID) return 0;
- if( pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id )
- { //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex]
+ if (pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id) {
+ //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex]
sd->state.arrow_atk = skill->get_ammotype(skill_id)?1:0; //Need to do arrow state check.
sd->spiritball_old = sd->spiritball; //Need to do Spiritball check.
return 1;
@@ -12717,8 +12827,8 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
sd->inventory_data[i] == NULL ||
!sd->inventory_data[i]->flag.delay_consume ||
sd->status.inventory[i].amount < 1
- )
- { //Something went wrong, item exploit?
+ ) {
+ //Something went wrong, item exploit?
sd->itemid = sd->itemindex = -1;
return 0;
}
@@ -12794,6 +12904,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
case RA_WUGSTRIKE:
// Other
case BS_GREED:
+ case ALL_FULL_THROTTLE:
break;
default: // in official there is no message.
return 0;
@@ -12803,12 +12914,40 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
// Check the skills that can be used whiled using mado
if( pc_ismadogear(sd) ) {
- if( !(skill_id > NC_MADOLICENCE && skill_id <= NC_DISJOINT)
- && skill_id != NC_MAGMA_ERUPTION
- && skill_id != BS_GREED ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_MADOGEAR,0);
- return 0;
- }
+ switch ( skill_id ) {
+ case BS_GREED:
+ case NC_BOOSTKNUCKLE:
+ case NC_PILEBUNKER:
+ case NC_VULCANARM:
+ case NC_FLAMELAUNCHER:
+ case NC_COLDSLOWER:
+ case NC_ARMSCANNON:
+ case NC_ACCELERATION:
+ case NC_HOVERING:
+ case NC_F_SIDESLIDE:
+ case NC_B_SIDESLIDE:
+ case NC_SELFDESTRUCTION:
+ case NC_SHAPESHIFT:
+ case NC_EMERGENCYCOOL:
+ case NC_INFRAREDSCAN:
+ case NC_ANALYZE:
+ case NC_MAGNETICFIELD:
+ case NC_NEUTRALBARRIER:
+ case NC_STEALTHFIELD:
+ case NC_REPAIR:
+ case NC_AXEBOOMERANG:
+ case NC_POWERSWING:
+ case NC_AXETORNADO:
+ case NC_SILVERSNIPER:
+ case NC_MAGICDECOY:
+ case NC_DISJOINT:
+ case NC_MAGMA_ERUPTION:
+ case ALL_FULL_THROTTLE:
+ case NC_MAGMA_ERUPTION_DOTDAMAGE:
+ break;
+ default:
+ return 0;
+ }
}
if( skill_lv < 1 || skill_lv > MAX_SKILL_LEVEL )
@@ -12895,12 +13034,13 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
}
return 0;
case MO_EXTREMITYFIST:
- // if(sc && sc->data[SC_EXTREMITYFIST]) //To disable Asura during the 5 min skill block uncomment this...
- // return 0;
- if( sc && (sc->data[SC_BLADESTOP] || sc->data[SC_CURSEDCIRCLE_ATKER]) )
+#if 0 //To disable Asura during the 5 min skill block uncomment this block...
+ if(sc && sc->data[SC_EXTREMITYFIST])
+ return 0;
+#endif // 0
+ if (sc && (sc->data[SC_BLADESTOP] || sc->data[SC_CURSEDCIRCLE_ATKER]))
break;
- if( sc && sc->data[SC_COMBOATTACK] )
- {
+ if (sc && sc->data[SC_COMBOATTACK]) {
switch(sc->data[SC_COMBOATTACK]->val1) {
case MO_COMBOFINISH:
case CH_TIGERFIST:
@@ -12909,9 +13049,8 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
default:
return 0;
}
- }
- else if( !unit->can_move(&sd->bl) )
- { //Placed here as ST_MOVE_ENABLE should not apply if rooted or on a combo. [Skotlex]
+ } else if (!unit->can_move(&sd->bl)) {
+ //Placed here as ST_MOVE_ENABLE should not apply if rooted or on a combo. [Skotlex]
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -12946,14 +13085,15 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
if(!(sc && sc->data[SC_COMBOATTACK]) || sc->data[SC_COMBOATTACK]->val1 == TK_JUMPKICK)
return 0; //Combo needs to be ready
- if (sc->data[SC_COMBOATTACK]->val3) { //Kick chain
+ if (sc->data[SC_COMBOATTACK]->val3) { //Kick chain
//Do not repeat a kick.
if (sc->data[SC_COMBOATTACK]->val3 != skill_id)
break;
status_change_end(&sd->bl, SC_COMBOATTACK, INVALID_TIMER);
return 0;
}
- if(sc->data[SC_COMBOATTACK]->val1 != skill_id && !( sd && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )) { //Cancel combo wait.
+ if(sc->data[SC_COMBOATTACK]->val1 != skill_id && !( sd && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )) {
+ //Cancel combo wait.
unit->cancel_combo(&sd->bl);
return 0;
}
@@ -13142,17 +13282,6 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
}
}
break;
- /**
- * Keeping as a note:
- * Bug Report #17 provides a link to a sep-2011 changelog that shows this requirement was removed
- **/
- //case AB_LAUDAAGNUS:
- //case AB_LAUDARAMUS:
- // if( !sd->status.party_id ) {
- // clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- // return 0;
- // }
- // break;
case AB_ADORAMUS:
/**
@@ -13269,19 +13398,16 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
}
break;
case LG_RAYOFGENESIS:
+ case LG_HESPERUSLIT:
if( sc && sc->data[SC_INSPIRATION] )
- return 1; // Don't check for partner.
+ return 1; // Don't check for partner.
if( !(sc && sc->data[SC_BANDING]) ) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL,0);
return 0;
- } else if( skill->check_pc_partner(sd,skill_id,&skill_lv,skill->get_range(skill_id,skill_lv),0) < 1 )
- return 0; // Just fails, no msg here.
- break;
- case LG_HESPERUSLIT:
- if( !sc || !sc->data[SC_BANDING] ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- return 0;
}
+ if( sc->data[SC_BANDING] &&
+ sc->data[SC_BANDING]->val2 < (skill_id == LG_RAYOFGENESIS ? 2 : 3) )
+ return 0; // Just fails, no msg here.
break;
case SR_FALLENEMPIRE:
if( sc && sc->data[SC_COMBOATTACK] ) {
@@ -13340,8 +13466,16 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
return 0;
}
break;
+ case NC_HOVERING:
+ if (( sd->equip_index[EQI_ACC_L] >= 0 && sd->status.inventory[sd->equip_index[EQI_ACC_L]].nameid == ITEMID_HOVERING_BOOSTER ) ||
+ ( sd->equip_index[EQI_ACC_R] >= 0 && sd->status.inventory[sd->equip_index[EQI_ACC_R]].nameid == ITEMID_HOVERING_BOOSTER ));
+ else {
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ return 0;
+ }
+ break;
case SO_FIREWALK:
- case SO_ELECTRICWALK: // Can't be casted until you've walked all cells.
+ case SO_ELECTRICWALK: // Can't be casted until you've walked all cells.
if( sc && sc->data[SC_PROPERTYWALK] &&
sc->data[SC_PROPERTYWALK]->val3 < skill->get_maxcount(sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2) ) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
@@ -13372,7 +13506,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
case KO_DOHU_KOUKAI:
{
int ttype = skill->get_ele(skill_id, skill_lv);
- if( sd->charm[ttype] >= 10 ){
+ if( sd->spiritcharm[ttype] >= MAX_SPIRITCHARM ){
clif->skill_fail(sd, skill_id, USESKILL_FAIL_SUMMON, 0);
return 0;
}
@@ -13382,8 +13516,8 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
case KO_ZENKAI:
{
int i;
- ARR_FIND(1, 6, i, sd->charm[i] > 0); // FIXME: 4 or 6?
- if( i > 4 ) {
+ ARR_FIND(SPIRITS_TYPE_CHARM_WATER, SPIRITS_TYPE_SPHERE, i, sd->spiritcharm[i] > 0);
+ if( i >= SPIRITS_TYPE_SPHERE ) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_SUMMON,0);
return 0;
}
@@ -13411,7 +13545,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
}
break;
case ST_RIDING:
- if(!pc_isriding(sd) && !pc_isridingdragon(sd)) {
+ if (!pc_isridingpeco(sd) && !pc_isridingdragon(sd)) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -13526,7 +13660,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
return 0;
}
case ST_PECO:
- if(!pc_isriding(sd)) {
+ if (!pc_isridingpeco(sd)) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -13560,12 +13694,14 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
return 0;
}
+#if 0
// There's no need to check if the skill is part of a combo if it's
// already been checked before, see unit_skilluse_id2 [Panikon]
// Note that if this check is read part of issue:8047 will reappear!
- //if( sd->sc.data[SC_COMBOATTACK] && !skill->is_combo(skill_id ) )
- // return 0;
-
+ if( sd->sc.data[SC_COMBOATTACK] && !skill->is_combo(skill_id ) )
+ return 0;
+#endif // 0
+
return 1;
}
@@ -13890,7 +14026,7 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
idx = skill->get_index(skill_id);
if( idx == 0 ) // invalid skill id
- return req;
+ return req;
if( skill_lv < 1 || skill_lv > MAX_SKILL_LEVEL )
return req;
@@ -13971,7 +14107,7 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
continue;
break;
case WZ_FIREPILLAR: // celest
- if (skill_lv <= 5) // no gems required at level 1-5
+ if (skill_lv <= 5) // no gems required at level 1-5
continue;
break;
case AB_ADORAMUS:
@@ -14002,10 +14138,9 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
req.itemid[i] = skill->db[idx].itemid[i];
req.amount[i] = skill->db[idx].amount[i];
- if( itemid_isgemstone(req.itemid[i]) && skill_id != HW_GANBANTEIN )
- {
- if( sd->special_state.no_gemstone )
- { // All gem skills except Hocus Pocus and Ganbantein can cast for free with Mistress card [helvetica]
+ if (itemid_isgemstone(req.itemid[i]) && skill_id != HW_GANBANTEIN) {
+ if (sd->special_state.no_gemstone) {
+ // All gem skills except Hocus Pocus and Ganbantein can cast for free with Mistress card [helvetica]
if( skill_id != SA_ABRACADABRA )
req.itemid[i] = req.amount[i] = 0;
else if( --req.amount[i] < 1 )
@@ -14117,7 +14252,7 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
case CH_TIGERFIST:
req.spiritball = 3;
break;
- case CH_CHAINCRUSH: //It should consume whatever is left as long as it's at least 1.
+ case CH_CHAINCRUSH: //It should consume whatever is left as long as it's at least 1.
req.spiritball = sd->spiritball?sd->spiritball:1;
break;
}
@@ -14167,10 +14302,10 @@ int skill_castfix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
// calculate base cast time (reduced by dex)
if( !(skill->get_castnodex(skill_id, skill_lv)&1) ) {
int scale = battle_config.castrate_dex_scale - status_get_dex(bl);
- if( scale > 0 ) // not instant cast
+ if( scale > 0 ) // not instant cast
time = time * scale / battle_config.castrate_dex_scale;
else
- return 0; // instant cast
+ return 0; // instant cast
}
// calculate cast time reduced by item/card bonuses
@@ -14195,9 +14330,9 @@ int skill_castfix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
if (battle_config.cast_rate != 100)
time = time * battle_config.cast_rate / 100;
// return final cast time
- time = max(time, 0);
+ time = max(time, 0);
-// ShowInfo("Castime castfix = %d\n",time);
+ //ShowInfo("Castime castfix = %d\n",time);
return time;
}
@@ -14279,9 +14414,8 @@ int skill_vfcastfix(struct block_list *bl, double time, uint16 skill_id, uint16
break;
}
for( i = 0; i < ARRAYLENGTH(sd->skillfixcastrate) && sd->skillfixcastrate[i].id; i++ )
-
if( sd->skillfixcastrate[i].id == skill_id ){ // bonus2 bFixedCastrate
- fixcast_r = sd->skillfixcastrate[i].val; // just speculation
+ fixcast_r = sd->skillfixcastrate[i].val;
break;
}
}
@@ -14383,10 +14517,11 @@ int skill_delay_fix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
return battle_config.min_skill_delay_limit;
if (time < 0)
- time = -time + status_get_amotion(bl); // If set to <0, add to attack motion.
+ time = -time + status_get_amotion(bl); // If set to <0, add to attack motion.
// Delay reductions
- switch (skill_id) { //Monk combo skills have their delay reduced by agi/dex.
+ switch (skill_id) {
+ //Monk combo skills have their delay reduced by agi/dex.
case MO_TRIPLEATTACK:
case MO_CHAINCOMBO:
case MO_COMBOFINISH:
@@ -14401,16 +14536,16 @@ int skill_delay_fix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
time = 0; // There is no Delay on Basilica creation, only on cancel
break;
default:
- if (battle_config.delay_dependon_dex && !(delaynodex&1))
- { // if skill delay is allowed to be reduced by dex
+ if (battle_config.delay_dependon_dex && !(delaynodex&1)) {
+ // if skill delay is allowed to be reduced by dex
int scale = battle_config.castrate_dex_scale - status_get_dex(bl);
if (scale > 0)
time = time * scale / battle_config.castrate_dex_scale;
else //To be capped later to minimum.
time = 0;
}
- if (battle_config.delay_dependon_agi && !(delaynodex&1))
- { // if skill delay is allowed to be reduced by agi
+ if (battle_config.delay_dependon_agi && !(delaynodex&1)) {
+ // if skill delay is allowed to be reduced by agi
int scale = battle_config.castrate_dex_scale - status_get_agi(bl);
if (scale > 0)
time = time * scale / battle_config.castrate_dex_scale;
@@ -14721,7 +14856,8 @@ void skill_weaponrefine (struct map_session_data *sd, int idx)
if(item->nameid > 0 && ditem->type == IT_WEAPON)
{
- if( ditem->flag.no_refine ){ // if the item isn't refinable
+ if( ditem->flag.no_refine ) {
+ // if the item isn't refinable
clif->skill_fail(sd,sd->menuskill_id,USESKILL_FAIL_LEVEL,0);
return;
}
@@ -14802,7 +14938,7 @@ int skill_autospell (struct map_session_data *sd, uint16 skill_id)
if(!skill_lv || !lv) return 0; // Player must learn the skill before doing auto-spell [Lance]
- if(skill_id==MG_NAPALMBEAT) maxlv=3;
+ if(skill_id==MG_NAPALMBEAT) maxlv=3;
else if(skill_id==MG_COLDBOLT || skill_id==MG_FIREBOLT || skill_id==MG_LIGHTNINGBOLT){
if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_SAGE)
maxlv =10; //Soul Linker bonus. [Skotlex]
@@ -14943,7 +15079,7 @@ int skill_frostjoke_scream(struct block_list *bl, va_list ap) {
return 0;
if (bl->type == BL_PC) {
struct map_session_data *sd = (struct map_session_data *)bl;
- if ( sd && sd->sc.option&(OPTION_INVISIBLE|OPTION_MADOGEAR) )
+ if (sd && (pc_isinvisible(sd) || pc_ismadogear(sd)))
return 0;//Frost Joke / Scream cannot target invisible or MADO Gear characters [Ind]
}
//It has been reported that Scream/Joke works the same regardless of woe-setting. [Skotlex]
@@ -15225,9 +15361,10 @@ int skill_cell_overlap(struct block_list *bl, va_list ap) {
break;
}
break;
+ case WZ_ICEWALL:
case HP_BASILICA:
- if (su->group->skill_id == HP_BASILICA) {
- //Basilica can't be placed on top of itself to avoid map-cell stacking problems. [Skotlex]
+ if (su->group->skill_id == skill_id) {
+ //These can't be placed on top of themselves (duration can't be refreshed)
(*alive) = 0;
return 1;
}
@@ -15430,7 +15567,7 @@ bool skill_can_cloak(struct map_session_data *sd) {
//Avoid cloaking with no wall and low skill level. [Skotlex]
//Due to the cloaking card, we have to check the wall versus to known
//skill level rather than the used one. [Skotlex]
- //if (sd && val1 < 3 && skill_check_cloaking(bl,NULL))
+ //if (sd && val1 < 3 && skill->check_cloaking(bl,NULL))
if (pc->checkskill(sd, AS_CLOAKING) < 3 && !skill->check_cloaking(&sd->bl,NULL))
return false;
@@ -15545,7 +15682,6 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int
map->setgatcell(su->bl.m,su->bl.x,su->bl.y,5);
clif->changemapcell(0,su->bl.m,su->bl.x,su->bl.y,5,AREA);
skill->unitsetmapcell(su,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,true);
- map->list[su->bl.m].icewall_num++;
break;
case SA_LANDPROTECTOR:
skill->unitsetmapcell(su,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,true);
@@ -15594,10 +15730,10 @@ int skill_delunit (struct skill_unit* su) {
}
break;
case WZ_ICEWALL:
+ map->list[su->bl.m].setcell(su->bl.m, su->bl.x, su->bl.y, CELL_NOICEWALL, false);
map->setgatcell(su->bl.m,su->bl.x,su->bl.y,su->val2);
clif->changemapcell(0,su->bl.m,su->bl.x,su->bl.y,su->val2,ALL_SAMEMAP); // hack to avoid clientside cell bug
skill->unitsetmapcell(su,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,false);
- map->list[su->bl.m].icewall_num--;
// AS_CLOAKING in low levels requires a wall to be cast, thus it needs to be
// checked again when a wall disapears! issue:8182 [Panikon]
map->foreachinarea(skill->check_cloaking_end, su->bl.m,
@@ -15745,7 +15881,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin
return 0;
}
- if( !status->isdead(src) && ((TBL_PC*)src)->state.warping && !((TBL_PC*)src)->state.changemap ) {
+ if( src->type == BL_PC && !status->isdead(src) && ((TBL_PC*)src)->state.warping && !((TBL_PC*)src)->state.changemap ) {
switch( group->skill_id ) {
case BA_DISSONANCE:
case BA_POEMBRAGI:
@@ -15925,7 +16061,7 @@ int skill_unit_timer_sub_onplace(struct block_list* bl, va_list ap) {
nullpo_ret(group);
- if( !(skill->get_inf2(group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP|INF2_NOLP)) && map->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) )
+ if( !(skill->get_inf2(group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP|INF2_NOLP)) && map->getcell(su->bl.m, su->bl.x, su->bl.y, CELL_CHKLANDPROTECTOR) )
return 0; //AoE skills are ineffective. [Skotlex]
if( battle->check_target(&su->bl,bl,group->target_flag) <= 0 )
@@ -15943,7 +16079,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) {
struct skill_unit* su = DB->data2ptr(data);
struct skill_unit_group* group = su->group;
int64 tick = va_arg(ap,int64);
- bool dissonance;
+ bool dissonance;
struct block_list* bl = &su->bl;
if( !su->alive )
@@ -16188,8 +16324,8 @@ int skill_unit_move_sub(struct block_list* bl, va_list ap) {
//Necessary in case the group is deleted after calling on_place/on_out [Skotlex]
skill_id = su->group->skill_id;
- if( su->group->interval != -1 && !(skill->get_unit_flag(skill_id)&UF_DUALMODE) && skill_id != BD_LULLABY ) //Lullaby is the exception, bugreport:411
- { //Non-dualmode unit skills with a timer don't trigger when walking, so just return
+ if( su->group->interval != -1 && !(skill->get_unit_flag(skill_id)&UF_DUALMODE) && skill_id != BD_LULLABY ) { //Lullaby is the exception, bugreport:411
+ //Non-dualmode unit skills with a timer don't trigger when walking, so just return
if( dissonance ) skill->dance_switch(su, 1);
return 0;
}
@@ -16303,11 +16439,11 @@ int skill_unit_move_unit_group(struct skill_unit_group *group, int16 m, int16 dx
return 0; //Icewalls and Wall of Thorns don't get knocked back
m_flag = (int *) aCalloc(group->unit_count, sizeof(int));
- // m_flag
- // 0: Neither of the following (skill_unit_onplace & skill_unit_onout are needed)
- // 1: Unit will move to a slot that had another unit of the same group (skill_unit_onplace not needed)
- // 2: Another unit from same group will end up positioned on this unit (skill_unit_onout not needed)
- // 3: Both 1+2.
+ // m_flag:
+ // 0: Neither of the following (skill_unit_onplace & skill_unit_onout are needed)
+ // 1: Unit will move to a slot that had another unit of the same group (skill_unit_onplace not needed)
+ // 2: Another unit from same group will end up positioned on this unit (skill_unit_onout not needed)
+ // 3: Both 1+2.
for(i=0;i<group->unit_count;i++) {
su1=&group->unit[i];
if (!su1->alive || su1->bl.m!=m)
@@ -16759,9 +16895,8 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
}
break;
default:
- if (sd->menuskill_id == AM_PHARMACY &&
- sd->menuskill_val > 10 && sd->menuskill_val <= 20)
- { //Assume Cooking Dish
+ if (sd->menuskill_id == AM_PHARMACY && sd->menuskill_val > 10 && sd->menuskill_val <= 20) {
+ //Assume Cooking Dish
if (sd->menuskill_val >= 15) //Legendary Cooking Set.
make_per = 10000; //100% Success
else
@@ -16852,9 +16987,10 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
}
}
-// if(log_config.produce > 0)
-// log_produce(sd,nameid,slot1,slot2,slot3,1);
-//TODO update PICKLOG
+#if 0 // TODO: update PICKLOG
+ if(log_config.produce > 0)
+ log_produce(sd,nameid,slot1,slot2,slot3,1);
+#endif // 0
if(equip){
clif->produce_effect(sd,0,nameid);
@@ -16865,7 +17001,8 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
int fame = 0;
tmp_item.amount = 0;
- for (i=0; i< qty; i++) { //Apply quantity modifiers.
+ for (i=0; i< qty; i++) {
+ //Apply quantity modifiers.
if( (skill_id == GN_MIX_COOKING || skill_id == GN_MAKEBOMB || skill_id == GN_S_PHARMACY) && make_per > 1){
tmp_item.amount = qty;
break;
@@ -16963,9 +17100,10 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
}
}
//Failure
-// if(log_config.produce)
-// log_produce(sd,nameid,slot1,slot2,slot3,0);
-//TODO update PICKLOG
+#if 0 // TODO: update PICKLOG
+ if(log_config.produce)
+ log_produce(sd,nameid,slot1,slot2,slot3,0);
+#endif // 0
if(equip){
clif->produce_effect(sd,1,nameid);
@@ -17154,7 +17292,7 @@ int skill_magicdecoy(struct map_session_data *sd, int nameid) {
class_ = (nameid == ITEMID_BOODY_RED || nameid == ITEMID_CRYSTAL_BLUE) ? 2043 + nameid - ITEMID_BOODY_RED : (nameid == ITEMID_WIND_OF_VERDURE) ? 2046 : 2045;
- md = mob->once_spawn_sub(&sd->bl, sd->bl.m, x, y, sd->status.name, class_, "", SZ_MEDIUM, AI_NONE);
+ md = mob->once_spawn_sub(&sd->bl, sd->bl.m, x, y, sd->status.name, class_, "", SZ_SMALL, AI_NONE);
if( md ) {
md->master_id = sd->bl.id;
md->special_state.ai = AI_FLORA;
@@ -17286,7 +17424,8 @@ int skill_elementalanalysis(struct map_session_data* sd, int n, uint16 skill_lv,
return 1;
}
- if( skill_lv == 2 && rnd()%100 < 25 ) { // At level 2 have a fail chance. You loose your items if it fails.
+ if( skill_lv == 2 && rnd()%100 < 25 ) {
+ // At level 2 have a fail chance. You loose your items if it fails.
clif->skill_fail(sd,SO_EL_ANALYSIS,USESKILL_FAIL_LEVEL,0);
return 1;
}
@@ -17338,7 +17477,7 @@ int skill_changematerial(struct map_session_data *sd, int n, unsigned short *ite
}
}
else
- break; // No more items required
+ break; // No more items required
}
p++;
} while(n == j && c == n);
@@ -17468,12 +17607,12 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick)
} else {
int i;
- for(i = 0; i < MAX_SKILL_TREE; i++) {
+ for(i = 0; i < cd->cursor; i++) {
if( cd->entry[i] && cd->entry[i]->skidx == idx )
break;
}
- if( i != MAX_SKILL_TREE ) {/* duplicate, update necessary */
+ if( i != cd->cursor ) {/* duplicate, update necessary */
cd->entry[i]->duration = tick;
#if PACKETVER >= 20120604
cd->entry[i]->total = tick;
@@ -17617,7 +17756,8 @@ int skill_split_atoi (char *str, int *val) {
}
if(i==0) //No data found.
return 0;
- if(i==1) { //Single value, have the whole range have the same value.
+ if(i==1) {
+ //Single value, have the whole range have the same value.
for (; i < MAX_SKILL_LEVEL; i++)
val[i] = val[i-1];
return i;
@@ -17932,44 +18072,132 @@ int skill_block_check(struct block_list *bl, sc_type type , uint16 skill_id) {
if( inf == INF2_SONG_DANCE || skill->get_inf2(skill_id) == INF2_CHORUS_SKILL || inf == INF2_SPIRIT_SKILL )
return 1; // Can't do it.
switch( skill_id ) {
- case NV_FIRSTAID: case TF_HIDING: case AS_CLOAKING: case WZ_SIGHTRASHER:
- case RG_STRIPWEAPON: case RG_STRIPSHIELD: case RG_STRIPARMOR: case WZ_METEOR:
- case RG_STRIPHELM: case SC_STRIPACCESSARY: case ST_FULLSTRIP: case WZ_SIGHTBLASTER:
- case ST_CHASEWALK: case SC_ENERVATION: case SC_GROOMY: case WZ_ICEWALL:
- case SC_IGNORANCE: case SC_LAZINESS: case SC_UNLUCKY: case WZ_STORMGUST:
- case SC_WEAKNESS: case AL_RUWACH: case AL_PNEUMA: case WZ_JUPITEL:
- case AL_HEAL: case AL_BLESSING: case AL_INCAGI: case WZ_VERMILION:
- case AL_TELEPORT: case AL_WARP: case AL_HOLYWATER: case WZ_EARTHSPIKE:
- case AL_HOLYLIGHT: case PR_IMPOSITIO: case PR_ASPERSIO: case WZ_HEAVENDRIVE:
- case PR_SANCTUARY: case PR_STRECOVERY: case PR_MAGNIFICAT: case WZ_QUAGMIRE:
- case ALL_RESURRECTION: case PR_LEXDIVINA: case PR_LEXAETERNA: case HW_GRAVITATION:
- case PR_MAGNUS: case PR_TURNUNDEAD: case MG_SRECOVERY: case HW_MAGICPOWER:
- case MG_SIGHT: case MG_NAPALMBEAT: case MG_SAFETYWALL: case HW_GANBANTEIN:
- case MG_SOULSTRIKE: case MG_COLDBOLT: case MG_FROSTDIVER: case WL_DRAINLIFE:
- case MG_STONECURSE: case MG_FIREBALL: case MG_FIREWALL: case WL_SOULEXPANSION:
- case MG_FIREBOLT: case MG_LIGHTNINGBOLT: case MG_THUNDERSTORM: case MG_ENERGYCOAT:
- case WL_WHITEIMPRISON: case WL_SUMMONFB: case WL_SUMMONBL: case WL_SUMMONWB:
- case WL_SUMMONSTONE: case WL_SIENNAEXECRATE: case WL_RELEASE: case WL_EARTHSTRAIN:
- case WL_RECOGNIZEDSPELL: case WL_READING_SB: case SA_MAGICROD: case SA_SPELLBREAKER:
- case SA_DISPELL: case SA_FLAMELAUNCHER: case SA_FROSTWEAPON: case SA_LIGHTNINGLOADER:
- case SA_SEISMICWEAPON: case SA_VOLCANO: case SA_DELUGE: case SA_VIOLENTGALE:
- case SA_LANDPROTECTOR: case PF_HPCONVERSION: case PF_SOULCHANGE: case PF_SPIDERWEB:
- case PF_FOGWALL: case TK_RUN: case TK_HIGHJUMP: case TK_SEVENWIND:
- case SL_KAAHI: case SL_KAUPE: case SL_KAITE:
+ case NV_FIRSTAID:
+ case TF_HIDING:
+ case AS_CLOAKING:
+ case WZ_SIGHTRASHER:
+ case RG_STRIPWEAPON:
+ case RG_STRIPSHIELD:
+ case RG_STRIPARMOR:
+ case WZ_METEOR:
+ case RG_STRIPHELM:
+ case SC_STRIPACCESSARY:
+ case ST_FULLSTRIP:
+ case WZ_SIGHTBLASTER:
+ case ST_CHASEWALK:
+ case SC_ENERVATION:
+ case SC_GROOMY:
+ case WZ_ICEWALL:
+ case SC_IGNORANCE:
+ case SC_LAZINESS:
+ case SC_UNLUCKY:
+ case WZ_STORMGUST:
+ case SC_WEAKNESS:
+ case AL_RUWACH:
+ case AL_PNEUMA:
+ case WZ_JUPITEL:
+ case AL_HEAL:
+ case AL_BLESSING:
+ case AL_INCAGI:
+ case WZ_VERMILION:
+ case AL_TELEPORT:
+ case AL_WARP:
+ case AL_HOLYWATER:
+ case WZ_EARTHSPIKE:
+ case AL_HOLYLIGHT:
+ case PR_IMPOSITIO:
+ case PR_ASPERSIO:
+ case WZ_HEAVENDRIVE:
+ case PR_SANCTUARY:
+ case PR_STRECOVERY:
+ case PR_MAGNIFICAT:
+ case WZ_QUAGMIRE:
+ case ALL_RESURRECTION:
+ case PR_LEXDIVINA:
+ case PR_LEXAETERNA:
+ case HW_GRAVITATION:
+ case PR_MAGNUS:
+ case PR_TURNUNDEAD:
+ case MG_SRECOVERY:
+ case HW_MAGICPOWER:
+ case MG_SIGHT:
+ case MG_NAPALMBEAT:
+ case MG_SAFETYWALL:
+ case HW_GANBANTEIN:
+ case MG_SOULSTRIKE:
+ case MG_COLDBOLT:
+ case MG_FROSTDIVER:
+ case WL_DRAINLIFE:
+ case MG_STONECURSE:
+ case MG_FIREBALL:
+ case MG_FIREWALL:
+ case WL_SOULEXPANSION:
+ case MG_FIREBOLT:
+ case MG_LIGHTNINGBOLT:
+ case MG_THUNDERSTORM:
+ case MG_ENERGYCOAT:
+ case WL_WHITEIMPRISON:
+ case WL_SUMMONFB:
+ case WL_SUMMONBL:
+ case WL_SUMMONWB:
+ case WL_SUMMONSTONE:
+ case WL_SIENNAEXECRATE:
+ case WL_RELEASE:
+ case WL_EARTHSTRAIN:
+ case WL_RECOGNIZEDSPELL:
+ case WL_READING_SB:
+ case SA_MAGICROD:
+ case SA_SPELLBREAKER:
+ case SA_DISPELL:
+ case SA_FLAMELAUNCHER:
+ case SA_FROSTWEAPON:
+ case SA_LIGHTNINGLOADER:
+ case SA_SEISMICWEAPON:
+ case SA_VOLCANO:
+ case SA_DELUGE:
+ case SA_VIOLENTGALE:
+ case SA_LANDPROTECTOR:
+ case PF_HPCONVERSION:
+ case PF_SOULCHANGE:
+ case PF_SPIDERWEB:
+ case PF_FOGWALL:
+ case TK_RUN:
+ case TK_HIGHJUMP:
+ case TK_SEVENWIND:
+ case SL_KAAHI:
+ case SL_KAUPE:
+ case SL_KAITE:
// Skills that need to be confirmed.
- case SO_FIREWALK: case SO_ELECTRICWALK: case SO_SPELLFIST: case SO_EARTHGRAVE:
- case SO_DIAMONDDUST: case SO_POISON_BUSTER: case SO_PSYCHIC_WAVE: case SO_CLOUD_KILL:
- case SO_STRIKING: case SO_WARMER: case SO_VACUUM_EXTREME: case SO_VARETYR_SPEAR:
+ case SO_FIREWALK:
+ case SO_ELECTRICWALK:
+ case SO_SPELLFIST:
+ case SO_EARTHGRAVE:
+ case SO_DIAMONDDUST:
+ case SO_POISON_BUSTER:
+ case SO_PSYCHIC_WAVE:
+ case SO_CLOUD_KILL:
+ case SO_STRIKING:
+ case SO_WARMER:
+ case SO_VACUUM_EXTREME:
+ case SO_VARETYR_SPEAR:
case SO_ARRULLO:
- return 1; // Can't do it.
+ return 1; // Can't do it.
}
break;
case SC_KG_KAGEHUMI:
switch(skill_id) {
- case TF_HIDING: case AS_CLOAKING: case GC_CLOAKINGEXCEED: case SC_SHADOWFORM:
- case MI_HARMONIZE: case CG_MARIONETTE: case AL_TELEPORT: case TF_BACKSLIDING:
- case RA_CAMOUFLAGE: case ST_CHASEWALK: case GD_EMERGENCYCALL:
+ case TF_HIDING:
+ case AS_CLOAKING:
+ case GC_CLOAKINGEXCEED:
+ case SC_SHADOWFORM:
+ case MI_HARMONIZE:
+ case CG_MARIONETTE:
+ case AL_TELEPORT:
+ case TF_BACKSLIDING:
+ case RA_CAMOUFLAGE:
+ case ST_CHASEWALK:
+ case GD_EMERGENCYCALL:
return 1; // needs more info
}
break;
@@ -17982,10 +18210,10 @@ int skill_get_elemental_type( uint16 skill_id , uint16 skill_lv ) {
int type = 0;
switch( skill_id ) {
- case SO_SUMMON_AGNI: type = 2114; break;
- case SO_SUMMON_AQUA: type = 2117; break;
- case SO_SUMMON_VENTUS: type = 2120; break;
- case SO_SUMMON_TERA: type = 2123; break;
+ case SO_SUMMON_AGNI: type = 2114; break;
+ case SO_SUMMON_AQUA: type = 2117; break;
+ case SO_SUMMON_VENTUS: type = 2120; break;
+ case SO_SUMMON_TERA: type = 2123; break;
}
type += skill_lv - 1;
@@ -18120,7 +18348,7 @@ bool skill_parse_row_requiredb(char* split[], int columns, int current) {
skill->split_atoi(split[5],skill->db[idx].sp_rate);
skill->split_atoi(split[6],skill->db[idx].zeny);
- //Which weapon type are required, see doc/item_db for types
+ //Which weapon type are required, see doc/item_db for types
p = split[7];
for( j = 0; j < 32; j++ ) {
int l = atoi(p);
@@ -18543,7 +18771,7 @@ int do_init_skill(bool minimal) {
skill->unit_ers = ers_new(sizeof(struct skill_unit_group),"skill.c::skill_unit_ers",ERS_OPT_CLEAN|ERS_OPT_FLEX_CHUNK);
skill->timer_ers = ers_new(sizeof(struct skill_timerskill),"skill.c::skill_timer_ers",ERS_OPT_NONE|ERS_OPT_FLEX_CHUNK);
skill->cd_ers = ers_new(sizeof(struct skill_cd),"skill.c::skill_cd_ers",ERS_OPT_CLEAR|ERS_OPT_CLEAN|ERS_OPT_FLEX_CHUNK);
- skill->cd_entry_ers = ers_new(sizeof(struct skill_cd_entry),"skill.c::skill_cd_entry_ers",ERS_OPT_CLEAR|ERS_OPT_FLEX_CHUNK);
+ skill->cd_entry_ers = ers_new(sizeof(struct skill_cd_entry),"skill.c::skill_cd_entry_ers",ERS_OPT_CLEAR|ERS_OPT_CLEAN|ERS_OPT_FLEX_CHUNK);
ers_chunk_size(skill->cd_ers, 25);
ers_chunk_size(skill->cd_entry_ers, 100);
@@ -18749,7 +18977,6 @@ void skill_defaults(void) {
skill->frostjoke_scream = skill_frostjoke_scream;
skill->greed = skill_greed;
skill->destroy_trap = skill_destroy_trap;
- skill->icewall_block = skill_icewall_block;
skill->unitgrouptickset_search = skill_unitgrouptickset_search;
skill->dance_switch = skill_dance_switch;
skill->check_condition_char_sub = skill_check_condition_char_sub;
diff --git a/src/map/skill.h b/src/map/skill.h
index 6373d9275..f0a54b982 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -26,29 +26,29 @@ struct status_change_entry;
/**
* Defines
**/
-#define MAX_SKILL_DB MAX_SKILL
-#define MAX_SKILL_PRODUCE_DB 270
-#define MAX_PRODUCE_RESOURCE 10
-#define MAX_SKILL_ARROW_DB 140
-#define MAX_ARROW_RESOURCE 5
-#define MAX_SKILL_ABRA_DB 210
-#define MAX_SKILL_IMPROVISE_DB 30
-#define MAX_SKILL_LEVEL 10
-#define MAX_SKILL_UNIT_LAYOUT 45
-#define MAX_SQUARE_LAYOUT 5 // 11*11 Placement of a maximum unit
-#define MAX_SKILL_UNIT_COUNT ((MAX_SQUARE_LAYOUT*2+1)*(MAX_SQUARE_LAYOUT*2+1))
-#define MAX_SKILLTIMERSKILL 15
-#define MAX_SKILLUNITGROUP 25
-#define MAX_SKILL_ITEM_REQUIRE 10
+#define MAX_SKILL_DB MAX_SKILL
+#define MAX_SKILL_PRODUCE_DB 270
+#define MAX_PRODUCE_RESOURCE 10
+#define MAX_SKILL_ARROW_DB 140
+#define MAX_ARROW_RESOURCE 5
+#define MAX_SKILL_ABRA_DB 210
+#define MAX_SKILL_IMPROVISE_DB 30
+#define MAX_SKILL_LEVEL 10
+#define MAX_SKILL_UNIT_LAYOUT 45
+#define MAX_SQUARE_LAYOUT 5 // 11*11 Placement of a maximum unit
+#define MAX_SKILL_UNIT_COUNT ((MAX_SQUARE_LAYOUT*2+1)*(MAX_SQUARE_LAYOUT*2+1))
+#define MAX_SKILLTIMERSKILL 15
+#define MAX_SKILLUNITGROUP 25
+#define MAX_SKILL_ITEM_REQUIRE 10
#define MAX_SKILLUNITGROUPTICKSET 25
-#define MAX_SKILL_NAME_LENGTH 30
+#define MAX_SKILL_NAME_LENGTH 30
// (Epoque:) To-do: replace this macro with some sort of skill tree check (rather than hard-coded skill names)
#define skill_ischangesex(id) ( \
((id) >= BD_ADAPTATION && (id) <= DC_SERVICEFORYOU) || ((id) >= CG_ARROWVULCAN && (id) <= CG_MARIONETTE) || \
((id) >= CG_LONGINGFREEDOM && (id) <= CG_TAROTCARD) || ((id) >= WA_SWING_DANCE && (id) <= WM_UNLIMITED_HUMMING_VOICE))
-#define MAX_SKILL_SPELLBOOK_DB 17
+#define MAX_SKILL_SPELLBOOK_DB 17
#define MAX_SKILL_MAGICMUSHROOM_DB 23
//Walk intervals at which chase-skills are attempted to be triggered.
@@ -99,7 +99,7 @@ enum e_skill_inf2 {
INF2_GUILD_ONLY = 0x0800,
INF2_NO_ENEMY = 0x1000,
INF2_NOLP = 0x2000, // Spells that can ignore Land Protector
- INF2_CHORUS_SKILL = 0x4000, // Chorus skill
+ INF2_CHORUS_SKILL = 0x4000, // Chorus skill
};
@@ -112,19 +112,19 @@ enum e_skill_display {
};
enum {
- UF_DEFNOTENEMY = 0x0001, // If 'defunit_not_enemy' is set, the target is changed to 'friend'
- UF_NOREITERATION = 0x0002, // Spell cannot be stacked
- UF_NOFOOTSET = 0x0004, // Spell cannot be cast near/on targets
- UF_NOOVERLAP = 0x0008, // Spell effects do not overlap
- UF_PATHCHECK = 0x0010, // Only cells with a shootable path will be placed
- UF_NOPC = 0x0020, // May not target players
- UF_NOMOB = 0x0040, // May not target mobs
- UF_SKILL = 0x0080, // May target skills
- UF_DANCE = 0x0100, // Dance
- UF_ENSEMBLE = 0x0200, // Duet
- UF_SONG = 0x0400, // Song
- UF_DUALMODE = 0x0800, // Spells should trigger both ontimer and onplace/onout/onleft effects.
- UF_RANGEDSINGLEUNIT = 0x2000 // Hack for ranged layout, only display center
+ UF_DEFNOTENEMY = 0x0001, // If 'defunit_not_enemy' is set, the target is changed to 'friend'
+ UF_NOREITERATION = 0x0002, // Spell cannot be stacked
+ UF_NOFOOTSET = 0x0004, // Spell cannot be cast near/on targets
+ UF_NOOVERLAP = 0x0008, // Spell effects do not overlap
+ UF_PATHCHECK = 0x0010, // Only cells with a shootable path will be placed
+ UF_NOPC = 0x0020, // May not target players
+ UF_NOMOB = 0x0040, // May not target mobs
+ UF_SKILL = 0x0080, // May target skills
+ UF_DANCE = 0x0100, // Dance
+ UF_ENSEMBLE = 0x0200, // Duet
+ UF_SONG = 0x0400, // Song
+ UF_DUALMODE = 0x0800, // Spells should trigger both ontimer and onplace/onout/onleft effects.
+ UF_RANGEDSINGLEUNIT = 0x2000, // Hack for ranged layout, only display center
};
//Returns the cast type of the skill: ground cast, castend damage, castend no damage
@@ -1623,14 +1623,14 @@ enum {
UNT_MAKIBISHI,
UNT_VENOMFOG,
UNT_ICEMINE,
- UNT_FLAMECROSS,
- UNT_HELLBURNING,
- UNT_MAGMA_ERUPTION,
+ UNT_FLAMECROSS,
+ UNT_HELLBURNING,
+ UNT_MAGMA_ERUPTION,
UNT_KINGS_GRACE,
UNT_GLITTERING_GREED,
UNT_B_TRAP,
UNT_FIRE_RAIN,
-
+
/**
* Guild Auras
**/
@@ -1638,7 +1638,7 @@ enum {
UNT_GD_GLORYWOUNDS = 0xc2,
UNT_GD_SOULCOLD = 0xc3,
UNT_GD_HAWKEYES = 0xc4,
-
+
UNT_MAX = 0x190
};
@@ -1703,10 +1703,10 @@ struct skill_unit_group {
int bg_id;
int map;
int target_flag; //Holds BCT_* flag for battle_check_target
- int bl_flag; //Holds BL_* flag for map_foreachin* functions
+ int bl_flag; //Holds BL_* flag for map_foreachin* functions
int64 tick;
int limit,interval;
-
+
uint16 skill_id,skill_lv;
int val1,val2,val3;
char *valstr;
@@ -1724,9 +1724,9 @@ struct skill_unit_group {
struct skill_unit {
struct block_list bl;
-
+
struct skill_unit_group *group;
-
+
int limit;
int val1,val2;
short alive,range;
@@ -1852,49 +1852,49 @@ struct skill_interface {
int unit_temp[20]; // temporary storage for tracking skill unit skill ids as players move in/out of them
int unit_group_newid;
/* accesssors */
- int (*get_index) ( uint16 skill_id );
- int (*get_type) ( uint16 skill_id );
- int (*get_hit) ( uint16 skill_id );
- int (*get_inf) ( uint16 skill_id );
- int (*get_ele) ( uint16 skill_id, uint16 skill_lv );
- int (*get_nk) ( uint16 skill_id );
- int (*get_max) ( uint16 skill_id );
- int (*get_range) ( uint16 skill_id, uint16 skill_lv );
- int (*get_range2) (struct block_list *bl, uint16 skill_id, uint16 skill_lv);
- int (*get_splash) ( uint16 skill_id, uint16 skill_lv );
- int (*get_hp) ( uint16 skill_id, uint16 skill_lv );
- int (*get_mhp) ( uint16 skill_id, uint16 skill_lv );
- int (*get_sp) ( uint16 skill_id, uint16 skill_lv );
- int (*get_state) (uint16 skill_id);
- int (*get_spiritball) (uint16 skill_id, uint16 skill_lv);
- int (*get_zeny) ( uint16 skill_id, uint16 skill_lv );
- int (*get_num) ( uint16 skill_id, uint16 skill_lv );
- int (*get_cast) ( uint16 skill_id, uint16 skill_lv );
- int (*get_delay) ( uint16 skill_id, uint16 skill_lv );
- int (*get_walkdelay) ( uint16 skill_id, uint16 skill_lv );
- int (*get_time) ( uint16 skill_id, uint16 skill_lv );
- int (*get_time2) ( uint16 skill_id, uint16 skill_lv );
- int (*get_castnodex) ( uint16 skill_id, uint16 skill_lv );
- int (*get_delaynodex) ( uint16 skill_id ,uint16 skill_lv );
- int (*get_castdef) ( uint16 skill_id );
- int (*get_weapontype) ( uint16 skill_id );
- int (*get_ammotype) ( uint16 skill_id );
- int (*get_ammo_qty) ( uint16 skill_id, uint16 skill_lv );
- int (*get_unit_id) (uint16 skill_id,int flag);
- int (*get_inf2) ( uint16 skill_id );
- int (*get_castcancel) ( uint16 skill_id );
- int (*get_maxcount) ( uint16 skill_id, uint16 skill_lv );
- int (*get_blewcount) ( uint16 skill_id, uint16 skill_lv );
- int (*get_unit_flag) ( uint16 skill_id );
- int (*get_unit_target) ( uint16 skill_id );
- int (*get_unit_interval) ( uint16 skill_id );
- int (*get_unit_bl_target) ( uint16 skill_id );
- int (*get_unit_layout_type) ( uint16 skill_id ,uint16 skill_lv );
- int (*get_unit_range) ( uint16 skill_id, uint16 skill_lv );
- int (*get_cooldown) ( uint16 skill_id, uint16 skill_lv );
- int (*tree_get_max) ( uint16 skill_id, int b_class );
- const char* (*get_name) ( uint16 skill_id );
- const char* (*get_desc) ( uint16 skill_id );
+ int (*get_index) ( uint16 skill_id );
+ int (*get_type) ( uint16 skill_id );
+ int (*get_hit) ( uint16 skill_id );
+ int (*get_inf) ( uint16 skill_id );
+ int (*get_ele) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_nk) ( uint16 skill_id );
+ int (*get_max) ( uint16 skill_id );
+ int (*get_range) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_range2) (struct block_list *bl, uint16 skill_id, uint16 skill_lv);
+ int (*get_splash) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_hp) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_mhp) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_sp) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_state) (uint16 skill_id);
+ int (*get_spiritball) (uint16 skill_id, uint16 skill_lv);
+ int (*get_zeny) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_num) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_cast) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_delay) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_walkdelay) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_time) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_time2) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_castnodex) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_delaynodex) ( uint16 skill_id ,uint16 skill_lv );
+ int (*get_castdef) ( uint16 skill_id );
+ int (*get_weapontype) ( uint16 skill_id );
+ int (*get_ammotype) ( uint16 skill_id );
+ int (*get_ammo_qty) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_unit_id) (uint16 skill_id,int flag);
+ int (*get_inf2) ( uint16 skill_id );
+ int (*get_castcancel) ( uint16 skill_id );
+ int (*get_maxcount) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_blewcount) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_unit_flag) ( uint16 skill_id );
+ int (*get_unit_target) ( uint16 skill_id );
+ int (*get_unit_interval) ( uint16 skill_id );
+ int (*get_unit_bl_target) ( uint16 skill_id );
+ int (*get_unit_layout_type) ( uint16 skill_id ,uint16 skill_lv );
+ int (*get_unit_range) ( uint16 skill_id, uint16 skill_lv );
+ int (*get_cooldown) ( uint16 skill_id, uint16 skill_lv );
+ int (*tree_get_max) ( uint16 skill_id, int b_class );
+ const char *(*get_name) ( uint16 skill_id );
+ const char *(*get_desc) ( uint16 skill_id );
/* check */
void (*chk) (uint16* skill_id);
/* whether its CAST_GROUND, CAST_DAMAGE or CAST_NODAMAGE */
@@ -1984,7 +1984,6 @@ struct skill_interface {
int (*frostjoke_scream) (struct block_list *bl, va_list ap);
int (*greed) (struct block_list *bl, va_list ap);
int (*destroy_trap) ( struct block_list *bl, va_list ap );
- int (*icewall_block) (struct block_list *bl,va_list ap);
struct skill_unit_group_tickset *(*unitgrouptickset_search) (struct block_list *bl, struct skill_unit_group *group, int64 tick);
bool (*dance_switch) (struct skill_unit* su, int flag);
int (*check_condition_char_sub) (struct block_list *bl, va_list ap);
diff --git a/src/map/status.c b/src/map/status.c
index 4a2a6c344..9cd01f7b3 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -245,7 +245,7 @@ void initChangeTables(void) {
set_sc( NPC_BARRIER , SC_BARRIER , SI_BLANK , SCB_MDEF|SCB_DEF );
add_sc( NPC_DEFENDER , SC_ARMOR );
add_sc( NPC_LICK , SC_STUN );
- set_sc( NPC_HALLUCINATION , SC_ILLUSION , SI_ILLUSION , SCB_NONE );
+ set_sc( NPC_HALLUCINATION , SC_ILLUSION , SI_ILLUSION , SCB_NONE );
add_sc( NPC_REBIRTH , SC_REBIRTH );
add_sc( RG_RAID , SC_STUN );
#ifdef RENEWAL
@@ -469,8 +469,8 @@ void initChangeTables(void) {
set_sc( HAMI_BLOODLUST , SC_HAMI_BLOODLUST , SI_BLANK , SCB_BATK|SCB_WATK );
// Homunculus S
- set_sc( MH_LIGHT_OF_REGENE , SC_LIGHT_OF_REGENE , SI_LIGHT_OF_REGENE , SCB_NONE );
- set_sc( MH_OVERED_BOOST , SC_OVERED_BOOST , SI_OVERED_BOOST , SCB_FLEE|SCB_ASPD|SCB_DEF );
+ set_sc( MH_LIGHT_OF_REGENE , SC_LIGHT_OF_REGENE , SI_LIGHT_OF_REGENE , SCB_NONE );
+ set_sc( MH_OVERED_BOOST , SC_OVERED_BOOST , SI_OVERED_BOOST , SCB_FLEE|SCB_ASPD|SCB_DEF );
add_sc(MH_STAHL_HORN, SC_STUN);
set_sc(MH_ANGRIFFS_MODUS, SC_ANGRIFFS_MODUS, SI_ANGRIFFS_MODUS, SCB_BATK | SCB_DEF | SCB_FLEE | SCB_MAXHP);
@@ -529,14 +529,14 @@ void initChangeTables(void) {
set_sc( RK_DEATHBOUND , SC_DEATHBOUND , SI_DEATHBOUND , SCB_NONE );
set_sc( RK_WINDCUTTER , SC_FEAR , SI_BLANK , SCB_FLEE|SCB_HIT );
add_sc( RK_DRAGONBREATH , SC_BURNING );
- set_sc( RK_MILLENNIUMSHIELD , SC_MILLENNIUMSHIELD , SI_BLANK , SCB_NONE );
+ set_sc( RK_MILLENNIUMSHIELD , SC_MILLENNIUMSHIELD , SI_BLANK , SCB_NONE );
set_sc( RK_REFRESH , SC_REFRESH , SI_REFRESH , SCB_NONE );
set_sc( RK_GIANTGROWTH , SC_GIANTGROWTH , SI_GIANTGROWTH , SCB_STR );
set_sc( RK_STONEHARDSKIN , SC_STONEHARDSKIN , SI_STONEHARDSKIN , SCB_NONE );
set_sc( RK_VITALITYACTIVATION, SC_VITALITYACTIVATION, SI_VITALITYACTIVATION, SCB_REGEN );
set_sc( RK_FIGHTINGSPIRIT , SC_FIGHTINGSPIRIT , SI_FIGHTINGSPIRIT , SCB_WATK|SCB_ASPD );
set_sc( RK_ABUNDANCE , SC_ABUNDANCE , SI_ABUNDANCE , SCB_NONE );
- set_sc( RK_CRUSHSTRIKE , SC_CRUSHSTRIKE , SI_CRUSHSTRIKE , SCB_NONE );
+ set_sc( RK_CRUSHSTRIKE , SC_CRUSHSTRIKE , SI_CRUSHSTRIKE , SCB_NONE );
add_sc( RK_DRAGONBREATH_WATER, SC_FROSTMISTY );
/**
* GC Guillotine Cross
@@ -643,7 +643,7 @@ void initChangeTables(void) {
set_sc( SR_RAISINGDRAGON , SC_RAISINGDRAGON , SI_RAISINGDRAGON , SCB_REGEN|SCB_MAXHP|SCB_MAXSP );
set_sc( SR_GENTLETOUCH_ENERGYGAIN, SC_GENTLETOUCH_ENERGYGAIN , SI_GENTLETOUCH_ENERGYGAIN, SCB_NONE );
set_sc( SR_GENTLETOUCH_CHANGE , SC_GENTLETOUCH_CHANGE , SI_GENTLETOUCH_CHANGE , SCB_ASPD|SCB_MDEF|SCB_MAXHP );
- set_sc( SR_GENTLETOUCH_REVITALIZE, SC_GENTLETOUCH_REVITALIZE , SI_GENTLETOUCH_REVITALIZE, SCB_MAXHP|SCB_REGEN );
+ set_sc( SR_GENTLETOUCH_REVITALIZE, SC_GENTLETOUCH_REVITALIZE , SI_GENTLETOUCH_REVITALIZE, SCB_MAXHP|SCB_DEF2|SCB_REGEN );
set_sc( SR_FLASHCOMBO , SC_FLASHCOMBO , SI_FLASHCOMBO , SCB_WATK );
/**
* Wanderer / Minstrel
@@ -677,7 +677,7 @@ void initChangeTables(void) {
set_sc_with_vfx( SO_DIAMONDDUST , SC_COLD , SI_COLD , SCB_NONE ); // it does show the snow icon on mobs but doesn't affect it.
set_sc( SO_CLOUD_KILL , SC_POISON , SI_CLOUDKILL , SCB_NONE );
set_sc( SO_STRIKING , SC_STRIKING , SI_STRIKING , SCB_WATK|SCB_CRI );
- set_sc( SO_WARMER , SC_WARMER , SI_WARMER , SCB_NONE );
+ add_sc( SO_WARMER , SC_WARMER ); // At the moment, no icon on officials
set_sc( SO_VACUUM_EXTREME , SC_VACUUM_EXTREME , SI_VACUUM_EXTREME , SCB_NONE );
set_sc( SO_ARRULLO , SC_DEEP_SLEEP , SI_DEEPSLEEP , SCB_NONE );
set_sc( SO_FIRE_INSIGNIA , SC_FIRE_INSIGNIA , SI_FIRE_INSIGNIA , SCB_MATK | SCB_BATK | SCB_WATK | SCB_ATK_ELE | SCB_REGEN );
@@ -724,25 +724,25 @@ void initChangeTables(void) {
set_sc( EL_ROCK_CRUSHER , SC_ROCK_CRUSHER , SI_ROCK_CRUSHER , SCB_DEF );
set_sc( EL_ROCK_CRUSHER_ATK, SC_ROCK_CRUSHER_ATK , SI_ROCK_CRUSHER_ATK , SCB_SPEED );
- add_sc( KO_YAMIKUMO , SC_HIDING );
- set_sc_with_vfx( KO_JYUMONJIKIRI , SC_KO_JYUMONJIKIRI , SI_KO_JYUMONJIKIRI , SCB_NONE );
- add_sc( KO_MAKIBISHI , SC_STUN );
- set_sc( KO_MEIKYOUSISUI , SC_MEIKYOUSISUI , SI_MEIKYOUSISUI , SCB_NONE );
- set_sc( KO_KYOUGAKU , SC_KYOUGAKU , SI_KYOUGAKU , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK );
- add_sc( KO_JYUSATSU , SC_CURSE );
- set_sc( KO_ZENKAI , SC_ZENKAI , SI_ZENKAI , SCB_NONE );
- set_sc( KO_IZAYOI , SC_IZAYOI , SI_IZAYOI , SCB_MATK );
- set_sc( KG_KYOMU , SC_KYOMU , SI_KYOMU , SCB_NONE );
- set_sc( KG_KAGEMUSYA , SC_KAGEMUSYA , SI_KAGEMUSYA , SCB_NONE );
- set_sc( KG_KAGEHUMI , SC_KG_KAGEHUMI , SI_KG_KAGEHUMI , SCB_NONE );
- set_sc( OB_ZANGETSU , SC_ZANGETSU , SI_ZANGETSU , SCB_MATK|SCB_BATK );
- set_sc_with_vfx( OB_AKAITSUKI , SC_AKAITSUKI , SI_AKAITSUKI , SCB_NONE );
- set_sc( OB_OBOROGENSOU , SC_GENSOU , SI_GENSOU , SCB_NONE );
-
- set_sc( ALL_FULL_THROTTLE , SC_FULL_THROTTLE , SI_FULL_THROTTLE , SCB_SPEED|SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK );
-
- add_sc( ALL_REVERSEORCISH , SC_ORCISH );
- set_sc( ALL_ANGEL_PROTECT , SC_ANGEL_PROTECT , SI_ANGEL_PROTECT , SCB_REGEN );
+ add_sc( KO_YAMIKUMO , SC_HIDING );
+ set_sc_with_vfx( KO_JYUMONJIKIRI , SC_KO_JYUMONJIKIRI , SI_KO_JYUMONJIKIRI , SCB_NONE );
+ add_sc( KO_MAKIBISHI , SC_STUN );
+ set_sc( KO_MEIKYOUSISUI , SC_MEIKYOUSISUI , SI_MEIKYOUSISUI , SCB_NONE );
+ set_sc( KO_KYOUGAKU , SC_KYOUGAKU , SI_KYOUGAKU , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK );
+ add_sc( KO_JYUSATSU , SC_CURSE );
+ set_sc( KO_ZENKAI , SC_ZENKAI , SI_ZENKAI , SCB_NONE );
+ set_sc( KO_IZAYOI , SC_IZAYOI , SI_IZAYOI , SCB_MATK );
+ set_sc( KG_KYOMU , SC_KYOMU , SI_KYOMU , SCB_NONE );
+ set_sc( KG_KAGEMUSYA , SC_KAGEMUSYA , SI_KAGEMUSYA , SCB_NONE );
+ set_sc( KG_KAGEHUMI , SC_KG_KAGEHUMI , SI_KG_KAGEHUMI , SCB_NONE );
+ set_sc( OB_ZANGETSU , SC_ZANGETSU , SI_ZANGETSU , SCB_MATK|SCB_BATK );
+ set_sc_with_vfx( OB_AKAITSUKI, SC_AKAITSUKI , SI_AKAITSUKI , SCB_NONE );
+ set_sc( OB_OBOROGENSOU , SC_GENSOU , SI_GENSOU , SCB_NONE );
+
+ set_sc( ALL_FULL_THROTTLE , SC_FULL_THROTTLE , SI_FULL_THROTTLE , SCB_SPEED|SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK );
+
+ add_sc( ALL_REVERSEORCISH , SC_ORCISH );
+ set_sc( ALL_ANGEL_PROTECT , SC_ANGEL_PROTECT , SI_ANGEL_PROTECT , SCB_REGEN );
add_sc( NPC_WIDEHEALTHFEAR , SC_FEAR );
add_sc( NPC_WIDEBODYBURNNING , SC_BURNING );
@@ -750,7 +750,7 @@ void initChangeTables(void) {
add_sc( NPC_WIDECOLD , SC_COLD );
add_sc( NPC_WIDE_DEEP_SLEEP , SC_DEEP_SLEEP );
add_sc( NPC_WIDESIREN , SC_SIREN );
-
+
set_sc_with_vfx( GN_ILLUSIONDOPING , SC_ILLUSIONDOPING , SI_ILLUSIONDOPING , SCB_HIT );
// Storing the target job rather than simply SC_SOULLINK simplifies code later on.
@@ -935,13 +935,16 @@ void initChangeTables(void) {
status->ChangeFlagTable[SC_INCHITRATE] |= SCB_HIT;
status->ChangeFlagTable[SC_INCFLEE] |= SCB_FLEE;
status->ChangeFlagTable[SC_INCFLEERATE] |= SCB_FLEE;
+ status->ChangeFlagTable[SC_MTF_HITFLEE] |= SCB_HIT|SCB_FLEE;
status->ChangeFlagTable[SC_CRITICALPERCENT] |= SCB_CRI;
status->ChangeFlagTable[SC_INCASPDRATE] |= SCB_ASPD;
status->ChangeFlagTable[SC_PLUSAVOIDVALUE] |= SCB_FLEE2;
status->ChangeFlagTable[SC_INCMHPRATE] |= SCB_MAXHP;
status->ChangeFlagTable[SC_INCMSPRATE] |= SCB_MAXSP;
status->ChangeFlagTable[SC_INCMHP] |= SCB_MAXHP;
+ status->ChangeFlagTable[SC_MTF_MHP] |= SCB_MAXHP;
status->ChangeFlagTable[SC_INCMSP] |= SCB_MAXSP;
+ status->ChangeFlagTable[SC_MTF_MSP] |= SCB_MAXSP;
status->ChangeFlagTable[SC_INCATKRATE] |= SCB_BATK|SCB_WATK;
status->ChangeFlagTable[SC_INCMATKRATE] |= SCB_MATK;
status->ChangeFlagTable[SC_INCDEFRATE] |= SCB_DEF;
@@ -1004,6 +1007,7 @@ void initChangeTables(void) {
status->ChangeFlagTable[SC_REBOUND] |= SCB_SPEED|SCB_REGEN;
status->ChangeFlagTable[SC_DEFSET] |= SCB_DEF|SCB_DEF2;
status->ChangeFlagTable[SC_MDEFSET] |= SCB_MDEF|SCB_MDEF2;
+ status->ChangeFlagTable[SC_MYSTERIOUS_POWDER] |= SCB_MAXHP;
status->ChangeFlagTable[SC_ALL_RIDING] = SCB_SPEED;
status->ChangeFlagTable[SC_WEDDING] = SCB_SPEED;
@@ -1018,32 +1022,32 @@ void initChangeTables(void) {
status->ChangeFlagTable[SC_DECORATION_OF_MUSIC] |= SCB_NONE;
/* status->DisplayType Table [Ind/Hercules] */
- status->DisplayType[SC_ALL_RIDING] = true;
- status->DisplayType[SC_PUSH_CART] = true;
- status->DisplayType[SC_SUMMON1] = true;
- status->DisplayType[SC_SUMMON2] = true;
- status->DisplayType[SC_SUMMON3] = true;
- status->DisplayType[SC_SUMMON4] = true;
- status->DisplayType[SC_SUMMON5] = true;
- status->DisplayType[SC_CAMOUFLAGE] = true;
- status->DisplayType[SC_DUPLELIGHT] = true;
- status->DisplayType[SC_ORATIO] = true;
- status->DisplayType[SC_FROSTMISTY] = true;
- status->DisplayType[SC_VENOMIMPRESS] = true;
- status->DisplayType[SC_HALLUCINATIONWALK] = true;
- status->DisplayType[SC_ROLLINGCUTTER] = true;
- status->DisplayType[SC_BANDING] = true;
- status->DisplayType[SC_COLD] = true;
- status->DisplayType[SC_DEEP_SLEEP] = true;
- status->DisplayType[SC_CURSEDCIRCLE_ATKER]= true;
- status->DisplayType[SC_CURSEDCIRCLE_TARGET]= true;
- status->DisplayType[SC_BLOOD_SUCKER] = true;
- status->DisplayType[SC__SHADOWFORM] = true;
- status->DisplayType[SC_MONSTER_TRANSFORM] = true;
- status->DisplayType[SC_MOONSTAR] = true;
- status->DisplayType[SC_SUPER_STAR] = true;
- status->DisplayType[SC_STRANGELIGHTS] = true;
- status->DisplayType[SC_DECORATION_OF_MUSIC] = true;
+ status->DisplayType[SC_ALL_RIDING] = true;
+ status->DisplayType[SC_PUSH_CART] = true;
+ status->DisplayType[SC_SUMMON1] = true;
+ status->DisplayType[SC_SUMMON2] = true;
+ status->DisplayType[SC_SUMMON3] = true;
+ status->DisplayType[SC_SUMMON4] = true;
+ status->DisplayType[SC_SUMMON5] = true;
+ status->DisplayType[SC_CAMOUFLAGE] = true;
+ status->DisplayType[SC_DUPLELIGHT] = true;
+ status->DisplayType[SC_ORATIO] = true;
+ status->DisplayType[SC_FROSTMISTY] = true;
+ status->DisplayType[SC_VENOMIMPRESS] = true;
+ status->DisplayType[SC_HALLUCINATIONWALK] = true;
+ status->DisplayType[SC_ROLLINGCUTTER] = true;
+ status->DisplayType[SC_BANDING] = true;
+ status->DisplayType[SC_COLD] = true;
+ status->DisplayType[SC_DEEP_SLEEP] = true;
+ status->DisplayType[SC_CURSEDCIRCLE_ATKER] = true;
+ status->DisplayType[SC_CURSEDCIRCLE_TARGET] = true;
+ status->DisplayType[SC_BLOOD_SUCKER] = true;
+ status->DisplayType[SC__SHADOWFORM] = true;
+ status->DisplayType[SC_MONSTER_TRANSFORM] = true;
+ status->DisplayType[SC_MOONSTAR] = true;
+ status->DisplayType[SC_SUPER_STAR] = true;
+ status->DisplayType[SC_STRANGELIGHTS] = true;
+ status->DisplayType[SC_DECORATION_OF_MUSIC] = true;
#ifdef RENEWAL_EDP
// renewal EDP increases your weapon atk
@@ -1134,10 +1138,10 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
struct status_change *sc;
int hp,sp;
- /* here onwards we consider it a 32-type, the client does not support higher and from here onwards the value doesn't get thru percentage modifiers */
+ /* From here onwards, we consider it a 32-type as the client does not support higher and the value doesn't get through percentage modifiers */
hp = (int)cap_value(in_hp,INT_MIN,INT_MAX);
sp = (int)cap_value(in_sp,INT_MIN,INT_MAX);
-
+
if(sp && !(target->type&BL_CONSUME))
sp = 0; //Not a valid SP target.
@@ -1174,10 +1178,12 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
if( !st->hp )
flag |= 8;
+#if 0
// Let through. battle.c/skill.c have the whole logic of when it's possible or
// not to hurt someone (and this check breaks pet catching) [Skotlex]
- // if (!target->prev && !(flag&2))
- // return 0; //Cannot damage a bl not on a map, except when "charging" hp/sp
+ if (!target->prev && !(flag&2))
+ return 0; //Cannot damage a bl not on a map, except when "charging" hp/sp
+#endif // 0
sc = status->get_sc(target);
if( hp && battle_config.invincible_nodamage && src && sc && sc->data[SC_INVINCIBLE] && !sc->data[SC_INVINCIBLEOFF] )
@@ -1186,11 +1192,11 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
if( hp && !(flag&1) ) {
if( sc ) {
struct status_change_entry *sce;
-
+
#ifdef DEVOTION_REFLECT_DAMAGE
if(src && (sce = sc->data[SC_DEVOTION])) {
struct block_list *d_bl = map->id2bl(sce->val1);
-
+
if(d_bl &&((d_bl->type == BL_MER && ((TBL_MER *)d_bl)->master && ((TBL_MER *)d_bl)->master->bl.id == target->id)
|| (d_bl->type == BL_PC && ((TBL_PC *)d_bl)->devotion[sce->val2] == target->id)) && check_distance_bl(target, d_bl, sce->val3)) {
clif->damage(d_bl, d_bl, 0, 0, hp, 0, 0, 0);
@@ -1200,7 +1206,6 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
status_change_end(target, SC_DEVOTION, INVALID_TIMER);
}
#endif
-
if (sc->data[SC_STONE] && sc->opt1 == OPT1_STONE)
status_change_end(target, SC_STONE, INVALID_TIMER);
status_change_end(target, SC_FREEZE, INVALID_TIMER);
@@ -1264,8 +1269,8 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
unit->stop_walking( target, 1 );
}
- if( st->hp || (flag&8) )
- { //Still lives or has been dead before this damage.
+ if (st->hp || (flag&8)) {
+ //Still lives or has been dead before this damage.
if (walkdelay)
unit->set_walkdelay(target, timer->gettick(), walkdelay, 0);
return (int)(hp+sp);
@@ -1283,7 +1288,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
case BL_HOM: flag = homun->dead((TBL_HOM*)target); break;
case BL_MER: flag = mercenary->dead((TBL_MER*)target); break;
case BL_ELEM: flag = elemental->dead((TBL_ELEM*)target); break;
- default: //Unhandled case, do nothing to object.
+ default: //Unhandled case, do nothing to object.
flag = 0;
break;
}
@@ -1366,10 +1371,10 @@ int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) {
if (st == &status->dummy || !st->hp)
return 0;
- /* here onwards we consider it a 32-type, the client does not support higher and from here onwards the value doesn't get thru percentage modifiers */
+ /* From here onwards, we consider it a 32-type as the client does not support higher and the value doesn't get through percentage modifiers */
hp = (int)cap_value(in_hp,INT_MIN,INT_MAX);
sp = (int)cap_value(in_sp,INT_MIN,INT_MAX);
-
+
sc = status->get_sc(bl);
if (sc && !sc->count)
sc = NULL;
@@ -1513,13 +1518,12 @@ int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per
if (bl->prev) //Animation only if character is already on a map.
clif->resurrection(bl, 1);
-
+
switch (bl->type) {
case BL_PC: pc->revive((TBL_PC*)bl, hp, sp); break;
case BL_MOB: mob->revive((TBL_MOB*)bl, hp); break;
case BL_HOM: homun->revive((TBL_HOM*)bl, hp, sp); break;
}
-
return 1;
}
@@ -1539,7 +1543,7 @@ int status_fixed_revive(struct block_list *bl, unsigned int per_hp, unsigned int
hp = st->max_hp - st->hp;
else if (per_hp && !hp)
hp = 1;
-
+
if(sp > st->max_sp - st->sp)
sp = st->max_sp - st->sp;
else if (per_sp && !sp)
@@ -1562,9 +1566,9 @@ int status_fixed_revive(struct block_list *bl, unsigned int per_hp, unsigned int
* Checks whether the src can use the skill on the target,
* taking into account status/option of both source/target. [Skotlex]
* flag:
-* 0 - Trying to use skill on target.
-* 1 - Cast bar is done.
-* 2 - Skill already pulled off, check is due to ground-based skills or splash-damage ones.
+* 0 - Trying to use skill on target.
+* 1 - Cast bar is done.
+* 2 - Skill already pulled off, check is due to ground-based skills or splash-damage ones.
* src MAY be null to indicate we shouldn't check it, this is a ground-based skill attack.
* target MAY Be null, in which case the checks are only to see
* whether the source can cast or not the skill on the ground.
@@ -1600,8 +1604,13 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
if( src->type == BL_PC )
clif->msg((TBL_PC*)src, SKILL_CANT_USE_AREA); // This skill cannot be used within this area
else if( src->type == BL_MOB && map->list[src->m].zone->disabled_skills[i]->subtype != MZS_NONE ) {
- if( (st->mode&MD_BOSS) && !(map->list[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) )
- break;
+ if( st->mode&MD_BOSS ) { /** is boss **/
+ if( !( map->list[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS ) )
+ break;
+ } else { /** is not boss **/
+ if( map->list[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS )
+ break;
+ }
}
return 0;
}
@@ -1692,12 +1701,13 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
}
}
if ((sc->data[SC_DANCING]->val1&0xFFFF) == CG_HERMODE && skill_id == BD_ADAPTATION)
- return 0; //Can't amp out of Wand of Hermode :/ [Skotlex]
+ return 0; //Can't amp out of Wand of Hermode :/ [Skotlex]
}
if (skill_id && //Do not block item-casted skills.
(src->type != BL_PC || ((TBL_PC*)src)->skillitem != skill_id)
- ) { //Skills blocked through status changes...
+ ) {
+ //Skills blocked through status changes...
if (!flag && ( //Blocked only from using the skill (stuff like autospell may still go through
sc->data[SC_SILENCE] ||
sc->data[SC_STEELBODY] ||
@@ -1789,17 +1799,10 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
//If targeting, cloak+hide protect you, otherwise only hiding does.
hide_flag = flag?OPTION_HIDE:(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK);
- //You cannot hide from ground skills.
- if( skill->get_ele(skill_id,1) == ELE_EARTH ) //TODO: Need Skill Lv here :/
+ // Applies even if the target hides
+ if ((skill->get_ele(skill_id,1) == ELE_EARTH && skill_id != MG_STONECURSE) // Ground type
+ || (flag&1 && skill->get_nk(skill_id)&NK_NO_DAMAGE && skill_id != ALL_RESURRECTION)) // Buff/debuff skills started before hiding
hide_flag &= ~OPTION_HIDE;
- else {
- switch ( skill_id ) {
- case MO_ABSORBSPIRITS: // it works when already casted and target suddenly hides.
- case SA_DISPELL:
- hide_flag &= ~OPTION_HIDE;
- break;
- }
- }
switch( target->type ) {
case BL_PC: {
@@ -1820,7 +1823,8 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
}
}
break;
- case BL_ITEM: //Allow targeting of items to pick'em up (or in the case of mobs, to loot them).
+ case BL_ITEM:
+ //Allow targeting of items to pick'em up (or in the case of mobs, to loot them).
//TODO: Would be nice if this could be used to judge whether the player can or not pick up the item it targets. [Skotlex]
if (st->mode&MD_LOOTER)
return 1;
@@ -1847,226 +1851,6 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
return 1;
}
-//Checks whether the source can see and chase target.
-int status_check_visibility(struct block_list *src, struct block_list *target) {
- int view_range;
- struct status_change *tsc = NULL;
-
- switch (src->type) {
- case BL_MOB:
- view_range = ((TBL_MOB*)src)->min_chase;
- break;
- case BL_PET:
- view_range = ((TBL_PET*)src)->db->range2;
- break;
- default:
- view_range = AREA_SIZE;
- }
-
- if (src->m != target->m || !check_distance_bl(src, target, view_range))
- return 0;
-
- if( src->type == BL_NPC ) /* NPCs don't care for the rest */
- return 1;
-
- if( ( tsc = status->get_sc(target) ) ) {
- struct status_data *st = status->get_status_data(src);
-
- switch (target->type) { //Check for chase-walk/hiding/cloaking opponents.
- case BL_PC:
- if ( tsc->data[SC_CLOAKINGEXCEED] && !(st->mode&MD_BOSS) )
- return 0;
- if( (tsc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || tsc->data[SC_STEALTHFIELD] || tsc->data[SC__INVISIBILITY] || tsc->data[SC_CAMOUFLAGE]) && !(st->mode&MD_BOSS) &&
- ( ((TBL_PC*)target)->special_state.perfect_hiding || !(st->mode&MD_DETECTOR) ) )
- return 0;
- break;
- default:
- if( (tsc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || tsc->data[SC_CAMOUFLAGE]) && !(st->mode&(MD_BOSS|MD_DETECTOR)) )
- return 0;
-
- }
- }
-
- return 1;
-}
-
-// Basic ASPD value
-int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) {
- int amotion;
-#ifdef RENEWAL_ASPD
- short mod = -1;
-
- switch( sd->weapontype2 ){ // adjustment for dual wielding
- case W_DAGGER: mod = 0; break; // 0, 1, 1
- case W_1HSWORD:
- case W_1HAXE: mod = 1;
- if( (sd->class_&MAPID_THIRDMASK) == MAPID_GUILLOTINE_CROSS ) // 0, 2, 3
- mod = sd->weapontype2 / W_1HSWORD + W_1HSWORD / sd->weapontype2 ;
- }
-
- amotion = ( sd->status.weapon < MAX_WEAPON_TYPE && mod < 0 )
- ? (status->aspd_base[pc->class2idx(sd->status.class_)][sd->status.weapon]) // single weapon
- : ((status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2] // dual-wield
- + status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2]) * 6 / 10 + 10 * mod
- - status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2]
- + status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1]);
-
- if ( sd->status.shield )
- amotion += ( 2000 - status->aspd_base[pc->class2idx(sd->status.class_)][W_FIST] ) +
- ( status->aspd_base[pc->class2idx(sd->status.class_)][MAX_WEAPON_TYPE] - 2000 );
-
-#else
- // base weapon delay
- amotion = (sd->status.weapon < MAX_WEAPON_TYPE)
- ? (status->aspd_base[pc->class2idx(sd->status.class_)][sd->status.weapon]) // single weapon
- : (status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1] + status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2])*7/10; // dual-wield
-
- // percentual delay reduction from stats
- amotion -= amotion * (4*st->agi + st->dex)/1000;
-#endif
-
- // raw delay adjustment from bAspd bonus
- amotion += sd->bonus.aspd_add;
-
- /* angra manyu disregards aspd_base and similar */
- if( sd->equip_index[EQI_HAND_R] >= 0 && sd->status.inventory[sd->equip_index[EQI_HAND_R]].nameid == ITEMID_ANGRA_MANYU )
- return 0;
-
- return amotion;
-}
-
-unsigned short status_base_atk(const struct block_list *bl, const struct status_data *st) {
- int flag = 0, str, dex,
-#ifdef RENEWAL
- rstr,
-#endif
- dstr;
-
-
- if(!(bl->type&battle_config.enable_baseatk))
- return 0;
-
- if (bl->type == BL_PC)
- switch(((TBL_PC*)bl)->status.weapon){
- case W_BOW:
- case W_MUSICAL:
- case W_WHIP:
- case W_REVOLVER:
- case W_RIFLE:
- case W_GATLING:
- case W_SHOTGUN:
- case W_GRENADE:
- flag = 1;
- }
- if (flag) {
-#ifdef RENEWAL
- rstr =
-#endif
- str = st->dex;
- dex = st->str;
- } else {
-#ifdef RENEWAL
- rstr =
-#endif
- str = st->str;
- dex = st->dex;
- }
- //Normally only players have base-atk, but homunc have a different batk
- // equation, hinting that perhaps non-players should use this for batk.
- // [Skotlex]
- dstr = str/10;
- str += dstr*dstr;
- if (bl->type == BL_PC)
-#ifdef RENEWAL
- str = (int)(rstr + (float)dex/5 + (float)st->luk/3 + (float)((TBL_PC*)bl)->status.base_level/4);
- else if(bl->type == BL_MOB)
- str = rstr + ((TBL_MOB*)bl)->level;
-#else
- str+= dex/5 + st->luk/5;
-#endif
- return cap_value(str, 0, USHRT_MAX);
-}
-
-#ifndef RENEWAL
-static inline unsigned short status_base_matk_min(const struct status_data *st){ return st->int_+(st->int_/7)*(st->int_/7); }
-#endif // not RENEWAL
-static inline unsigned short status_base_matk_max(const struct status_data *st){ return st->int_+(st->int_/5)*(st->int_/5); }
-
-unsigned short status_base_matk(const struct status_data *st, int level) {
-#ifdef RENEWAL
- return st->int_+(st->int_/2)+(st->dex/5)+(st->luk/3)+(level/4);
-#else
- return 0;
-#endif
-}
-
-//Fills in the misc data that can be calculated from the other status info (except for level)
-void status_calc_misc(struct block_list *bl, struct status_data *st, int level) {
- //Non players get the value set, players need to stack with previous bonuses.
- if( bl->type != BL_PC )
- st->batk =
- st->hit = st->flee =
- st->def2 = st->mdef2 =
- st->cri = st->flee2 = 0;
-
-#ifdef RENEWAL // renewal formulas
- st->matk_min = st->matk_max = bl->type == BL_PC ? status->base_matk(st, level) : level + st->int_;
- st->hit += level + st->dex + (bl->type == BL_PC ? st->luk/3 + 175 : 150); //base level + ( every 1 dex = +1 hit ) + (every 3 luk = +1 hit) + 175
- st->flee += level + st->agi + (bl->type == BL_PC ? st->luk/5 : 0) + 100; //base level + ( every 1 agi = +1 flee ) + (every 5 luk = +1 flee) + 100
- st->def2 += (int)(((float)level + st->vit)/2 + ( bl->type == BL_PC ? ((float)st->agi/5) : 0 )); //base level + (every 2 vit = +1 def) + (every 5 agi = +1 def)
- st->mdef2 += (int)( bl->type == BL_PC ?(st->int_ + ((float)level/4) + ((float)(st->dex+st->vit)/5)):((float)(st->int_ + level)/4)); //(every 4 base level = +1 mdef) + (every 1 int = +1 mdef) + (every 5 dex = +1 mdef) + (every 5 vit = +1 mdef)
-#else // not RENEWAL
- st->matk_min = status_base_matk_min(st);
- st->matk_max = status_base_matk_max(st);
- st->hit += level + st->dex;
- st->flee += level + st->agi;
- st->def2 += st->vit;
- st->mdef2 += st->int_ + (st->vit>>1);
-#endif // RENEWAL
-
- if( bl->type&battle_config.enable_critical )
- st->cri += 10 + (st->luk*10/3); //(every 1 luk = +0.3 critical)
- else
- st->cri = 0;
-
- if (bl->type&battle_config.enable_perfect_flee)
- st->flee2 += st->luk + 10; //(every 10 luk = +1 perfect flee)
- else
- st->flee2 = 0;
-
- if (st->batk) {
- int temp = st->batk + status->base_atk(bl, st);
- st->batk = cap_value(temp, 0, USHRT_MAX);
- } else
- st->batk = status->base_atk(bl, st);
- if (st->cri)
- switch (bl->type) {
- case BL_MOB:
- if(battle_config.mob_critical_rate != 100)
- st->cri = st->cri*battle_config.mob_critical_rate/100;
- if(!st->cri && battle_config.mob_critical_rate)
- st->cri = 10;
- break;
- case BL_PC:
- //Players don't have a critical adjustment setting as of yet.
- break;
- case BL_MER:
-#ifdef RENEWAL
- st->matk_min = st->matk_max = status_base_matk_max(st);
- st->def2 = st->vit + level / 10 + st->vit / 5;
- st->mdef2 = level / 10 + st->int_ / 5;
-#endif
- break;
- default:
- if(battle_config.critical_rate != 100)
- st->cri = st->cri*battle_config.critical_rate/100;
- if (!st->cri && battle_config.critical_rate)
- st->cri = 10;
- }
- if(bl->type&BL_REGEN)
- status->calc_regen(bl, st, status->get_regen_data(bl));
-}
-
//Skotlex: Calculates the initial status for the given mob
//first will only be false when the mob leveled up or got a GuardUp level.
int status_calc_mob_(struct mob_data* md, enum e_status_calc_opt opt) {
@@ -2169,7 +1953,7 @@ int status_calc_mob_(struct mob_data* md, enum e_status_calc_opt opt) {
if (flag&2 && battle_config.mob_size_influence) {
// change for sized monsters [Valaris]
- if (md->special_state.size==SZ_SMALL) {
+ if (md->special_state.size==SZ_MEDIUM) {
mstatus->max_hp>>=1;
mstatus->max_sp>>=1;
if (!mstatus->max_hp) mstatus->max_hp = 1;
@@ -2204,8 +1988,8 @@ int status_calc_mob_(struct mob_data* md, enum e_status_calc_opt opt) {
status->calc_misc(&md->bl, mstatus, md->level);
- if(flag&4)
- { // Strengthen Guardians - custom value +10% / lv
+ if (flag&4) {
+ // Strengthen Guardians - custom value +10% / lv
struct guild_castle *gc;
gc=guild->mapname2gc(map->list[md->bl.m].name);
if (!gc)
@@ -2286,7 +2070,7 @@ int status_calc_pet_(struct pet_data *pd, enum e_status_calc_opt opt)
status->calc_misc(&pd->bl, &pd->status, lv);
- if (! (opt&SCO_FIRST) ) //Not done the first time because the pet is not visible yet
+ if (! (opt&SCO_FIRST) ) //Not done the first time because the pet is not visible yet
clif->send_petstatus(sd);
}
} else if ( opt&SCO_FIRST ) {
@@ -2385,7 +2169,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
b_max_weight = sd->max_weight;
b_cart_weight_max = sd->cart_weight_max;
- pc->calc_skilltree(sd); // SkillTree calculation
+ pc->calc_skilltree(sd); // SkillTree calculation
sd->max_weight = status->max_weight_base[pc->class2idx(sd->status.class_)]+sd->status.str*300;
@@ -2461,7 +2245,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
clif->sc_end(&sd->bl,sd->bl.id,SELF,SI_CLAIRVOYANCE);
memset(&sd->special_state,0,sizeof(sd->special_state));
-
+
if (!sd->state.permanent_speed) {
memset(&bstatus->max_hp, 0, sizeof(struct status_data)-(sizeof(bstatus->hp)+sizeof(bstatus->sp)));
bstatus->speed = DEFAULT_WALK_SPEED;
@@ -2470,19 +2254,20 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
memset(&bstatus->max_hp, 0, sizeof(struct status_data)-(sizeof(bstatus->hp)+sizeof(bstatus->sp)));
bstatus->speed = pSpeed;
}
-
+
//FIXME: Most of these stuff should be calculated once, but how do I fix the memset above to do that? [Skotlex]
//Give them all modes except these (useful for clones)
bstatus->mode = MD_MASK&~(MD_BOSS|MD_PLANT|MD_DETECTOR|MD_ANGRY|MD_TARGETWEAK);
- bstatus->size = (sd->class_&JOBL_BABY)?SZ_MEDIUM:SZ_SMALL;
- if (battle_config.character_size && (pc_isriding(sd) || pc_isridingdragon(sd)) ) { //[Lupus]
+ bstatus->size = (sd->class_&JOBL_BABY)?SZ_SMALL:SZ_MEDIUM;
+ if (battle_config.character_size && (pc_isridingpeco(sd) || pc_isridingdragon(sd))) { //[Lupus]
if (sd->class_&JOBL_BABY) {
if (battle_config.character_size&SZ_BIG)
bstatus->size++;
- } else
- if(battle_config.character_size&SZ_SMALL)
+ } else {
+ if(battle_config.character_size&SZ_MEDIUM)
bstatus->size++;
+ }
}
bstatus->aspd_rate = 1000;
bstatus->ele_lv = 1;
@@ -2557,8 +2342,8 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
bstatus->def += sd->inventory_data[index]->def;
- if(opt&SCO_FIRST && sd->inventory_data[index]->equip_script)
- { //Execute equip-script on login
+ if (opt&SCO_FIRST && sd->inventory_data[index]->equip_script) {
+ //Execute equip-script on login
script->run(sd->inventory_data[index]->equip_script,0,sd->bl.id,0);
if (!calculating)
return 1;
@@ -2608,8 +2393,8 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
return 1;
}
- if(sd->status.inventory[index].card[0]==CARD0_FORGE)
- { // Forged weapon
+ if (sd->status.inventory[index].card[0]==CARD0_FORGE) {
+ // Forged weapon
wd->star += (sd->status.inventory[index].card[1]>>8);
if(wd->star >= 15) wd->star = 40; // 3 Star Crumbs now give +40 dmg
if(pc->famerank(MakeDWord(sd->status.inventory[index].card[2],sd->status.inventory[index].card[3]) ,MAPID_BLACKSMITH))
@@ -2637,7 +2422,8 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
if(sd->equip_index[EQI_AMMO] >= 0){
index = sd->equip_index[EQI_AMMO];
- if(sd->inventory_data[index]){ // Arrows
+ if (sd->inventory_data[index]) {
+ // Arrows
sd->bonus.arrow_atk += sd->inventory_data[index]->atk;
sd->state.lr_flag = 2;
if( !itemdb_is_GNthrowable(sd->inventory_data[index]->nameid) ) //don't run scripts on throwable items
@@ -2652,7 +2438,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
for( i = 0; i < sd->combo_count; i++ ) {
struct item_combo *combo = itemdb->id2combo(sd->combos[i].id);
unsigned char j;
-
+
/**
* ensure combo usage is allowed at this location
**/
@@ -2665,10 +2451,10 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
if( k != map->list[sd->bl.m].zone->disabled_items_count )
break;
}
-
+
if( j != combo->count )
continue;
-
+
script->run(sd->combos[i].bonus,0,sd->bl.id,0);
if (!calculating) //Abort, script->run retriggered this.
return 1;
@@ -2771,9 +2557,10 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
sd->left_weapon.atkmods[1] = status->atkmods[1][sd->weapontype2];
sd->left_weapon.atkmods[2] = status->atkmods[2][sd->weapontype2];
- if( (pc_isriding(sd) || pc_isridingdragon(sd)) &&
- (sd->status.weapon==W_1HSPEAR || sd->status.weapon==W_2HSPEAR))
- { //When Riding with spear, damage modifier to mid-class becomes
+ if ((pc_isridingpeco(sd) || pc_isridingdragon(sd))
+ && (sd->status.weapon==W_1HSPEAR || sd->status.weapon==W_2HSPEAR)
+ ) {
+ //When Riding with spear, damage modifier to mid-class becomes
//same as versus large size.
sd->right_weapon.atkmods[1] = sd->right_weapon.atkmods[2];
sd->left_weapon.atkmods[1] = sd->left_weapon.atkmods[2];
@@ -3053,9 +2840,9 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0 &&
(sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE))
bstatus->aspd_rate -= ((skill_lv+1)/2) * 10;
- if(pc_isriding(sd))
+ if (pc_isridingpeco(sd))
bstatus->aspd_rate += 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY);
- else if(pc_isridingdragon(sd))
+ else if (pc_isridingdragon(sd))
bstatus->aspd_rate += 250-50*pc->checkskill(sd,RK_DRAGONTRAINING);
#else // needs more info
if((skill_lv=pc->checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK)
@@ -3065,9 +2852,9 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0 &&
(sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE))
bstatus->aspd_rate += ((skill_lv+1)/2) * 10;
- if(pc_isriding(sd))
+ if (pc_isridingpeco(sd))
bstatus->aspd_rate -= 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY);
- else if(pc_isridingdragon(sd))
+ else if (pc_isridingdragon(sd))
bstatus->aspd_rate -= 250-50*pc->checkskill(sd,RK_DRAGONTRAINING);
#endif
bstatus->adelay = 2*bstatus->amotion;
@@ -3085,7 +2872,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
// Weight
if((skill_lv=pc->checkskill(sd,MC_INCCARRY))>0)
sd->max_weight += 2000*skill_lv;
- if(pc_isriding(sd) && pc->checkskill(sd,KN_RIDING)>0)
+ if (pc_isridingpeco(sd) && pc->checkskill(sd,KN_RIDING) > 0)
sd->max_weight += 10000;
else if(pc_isridingdragon(sd))
sd->max_weight += 5000+2000*pc->checkskill(sd,RK_DRAGONTRAINING);
@@ -3178,7 +2965,8 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
sd->subele[ELE_HOLY] += sc->data[SC_PROVIDENCE]->val2;
sd->subrace[RC_DEMON] += sc->data[SC_PROVIDENCE]->val2;
}
- if(sc->data[SC_ARMORPROPERTY]) { //This status change should grant card-type elemental resist.
+ if(sc->data[SC_ARMORPROPERTY]) {
+ //This status change should grant card-type elemental resist.
sd->subele[ELE_WATER] += sc->data[SC_ARMORPROPERTY]->val1;
sd->subele[ELE_EARTH] += sc->data[SC_ARMORPROPERTY]->val2;
sd->subele[ELE_FIRE] += sc->data[SC_ARMORPROPERTY]->val3;
@@ -3265,94 +3053,17 @@ int status_calc_mercenary_(struct mercenary_data *md, enum e_status_calc_opt opt
return 0;
}
-int status_calc_homunculus_(struct homun_data *hd, enum e_status_calc_opt opt) {
- struct status_data *hstatus = &hd->base_status;
- struct s_homunculus *hom = &hd->homunculus;
- int skill_lv;
- int amotion;
-
- hstatus->str = hom->str / 10;
- hstatus->agi = hom->agi / 10;
- hstatus->vit = hom->vit / 10;
- hstatus->dex = hom->dex / 10;
- hstatus->int_ = hom->int_ / 10;
- hstatus->luk = hom->luk / 10;
-
- if ( opt&SCO_FIRST ) { //[orn]
- const struct s_homunculus_db *db = hd->homunculusDB;
- hstatus->def_ele = db->element;
- hstatus->ele_lv = 1;
- hstatus->race = db->race;
- hstatus->size = (hom->class_ == db->evo_class)?db->evo_size:db->base_size;
- hstatus->rhw.range = 1 + hstatus->size;
- hstatus->mode = MD_CANMOVE|MD_CANATTACK;
- hstatus->speed = DEFAULT_WALK_SPEED;
- if (battle_config.hom_setting&0x8 && hd->master)
- hstatus->speed = status->get_speed(&hd->master->bl);
-
- hstatus->hp = 1;
- hstatus->sp = 1;
- }
- skill_lv = hom->level/10 + hstatus->vit/5;
- hstatus->def = cap_value(skill_lv, 0, 99);
-
- skill_lv = hom->level/10 + hstatus->int_/5;
- hstatus->mdef = cap_value(skill_lv, 0, 99);
-
- hstatus->max_hp = hom->max_hp;
- hstatus->max_sp = hom->max_sp;
-
- homun->calc_skilltree(hd, 0);
-
- if((skill_lv=homun->checkskill(hd,HAMI_SKIN)) > 0)
- hstatus->def += skill_lv * 4;
-
- if((skill_lv = homun->checkskill(hd,HVAN_INSTRUCT)) > 0) {
- hstatus->int_ += 1 +skill_lv/2 +skill_lv/4 +skill_lv/5;
- hstatus->str += 1 +skill_lv/3 +skill_lv/3 +skill_lv/4;
- }
-
- if((skill_lv=homun->checkskill(hd,HAMI_SKIN)) > 0)
- hstatus->max_hp += skill_lv * 2 * hstatus->max_hp / 100;
-
- if((skill_lv = homun->checkskill(hd,HLIF_BRAIN)) > 0)
- hstatus->max_sp += (1 +skill_lv/2 -skill_lv/4 +skill_lv/5) * hstatus->max_sp / 100;
-
- if ( opt&SCO_FIRST ) {
- hd->battle_status.hp = hom->hp;
- hd->battle_status.sp = hom->sp;
- }
-
- hstatus->rhw.atk = hstatus->dex;
- hstatus->rhw.atk2 = hstatus->str + hom->level;
-
- hstatus->aspd_rate = 1000;
-
- amotion = (1000 -4*hstatus->agi -hstatus->dex) * hd->homunculusDB->baseASPD/1000;
- hstatus->amotion = cap_value(amotion,battle_config.max_aspd,2000);
- hstatus->adelay = hstatus->amotion; //It seems adelay = amotion for Homunculus.
-
- status->calc_misc(&hd->bl, hstatus, hom->level);
-
-#ifdef RENEWAL
- hstatus->matk_max = hstatus->matk_min;
-#endif
-
- status_cpy(&hd->battle_status, hstatus);
- return 1;
-}
-
int status_calc_elemental_(struct elemental_data *ed, enum e_status_calc_opt opt) {
struct status_data *estatus = &ed->base_status;
struct s_elemental *ele = &ed->elemental;
struct map_session_data *sd = ed->master;
- if( !sd )
+ if ( !sd )
return 0;
- if( opt&SCO_FIRST ) {
+ if ( opt&SCO_FIRST ) {
memcpy(estatus, &ed->db->status, sizeof(struct status_data));
- if( !ele->mode )
+ if ( !ele->mode )
estatus->mode = EL_MODE_PASSIVE;
else
estatus->mode = ele->mode;
@@ -3372,7 +3083,7 @@ int status_calc_elemental_(struct elemental_data *ed, enum e_status_calc_opt opt
estatus->flee = ele->flee;
estatus->hit = ele->hit;
- memcpy(&ed->battle_status,estatus,sizeof(struct status_data));
+ memcpy(&ed->battle_status, estatus, sizeof(struct status_data));
} else {
status->calc_misc(&ed->bl, estatus, 0);
status_cpy(&ed->battle_status, estatus);
@@ -3415,6 +3126,89 @@ int status_calc_npc_(struct npc_data *nd, enum e_status_calc_opt opt) {
return 0;
}
+int status_calc_homunculus_(struct homun_data *hd, enum e_status_calc_opt opt) {
+ struct status_data *hstatus = &hd->base_status;
+ struct s_homunculus *hom = &hd->homunculus;
+ int skill_lv;
+ int amotion;
+
+ hstatus->str = hom->str / 10;
+ hstatus->agi = hom->agi / 10;
+ hstatus->vit = hom->vit / 10;
+ hstatus->dex = hom->dex / 10;
+ hstatus->int_ = hom->int_ / 10;
+ hstatus->luk = hom->luk / 10;
+
+ APPLY_HOMUN_LEVEL_STATWEIGHT();
+
+ if ( opt&SCO_FIRST ) { //[orn]
+ const struct s_homunculus_db *db = hd->homunculusDB;
+ hstatus->def_ele = db->element;
+ hstatus->ele_lv = 1;
+ hstatus->race = db->race;
+ hstatus->size = (hom->class_ == db->evo_class) ? db->evo_size : db->base_size;
+ hstatus->rhw.range = 1 + hstatus->size;
+ hstatus->mode = MD_CANMOVE | MD_CANATTACK;
+ hstatus->speed = DEFAULT_WALK_SPEED;
+ if ( battle_config.hom_setting & 0x8 && hd->master )
+ hstatus->speed = status->get_speed(&hd->master->bl);
+
+ hstatus->hp = 1;
+ hstatus->sp = 1;
+ }
+
+ hstatus->aspd_rate = 1000;
+
+#ifdef RENEWAL
+ amotion = hd->homunculusDB->baseASPD;
+ amotion = amotion - amotion * (hstatus->dex + hom->dex_value) / 1000 - (hstatus->agi + hom->agi_value) * amotion / 250;
+#else
+ skill_lv = hom->level / 10 + hstatus->vit / 5;
+ hstatus->def = cap_value(skill_lv, 0, 99);
+
+ skill_lv = hom->level / 10 + hstatus->int_ / 5;
+ hstatus->mdef = cap_value(skill_lv, 0, 99);
+ amotion = (1000 - 4 * hstatus->agi - hstatus->dex) * hd->homunculusDB->baseASPD / 1000;
+#endif
+
+ hstatus->amotion = cap_value(amotion, battle_config.max_aspd, 2000);
+ hstatus->adelay = hstatus->amotion; //It seems adelay = amotion for Homunculus.
+
+
+ hstatus->max_hp = hom->max_hp;
+ hstatus->max_sp = hom->max_sp;
+
+ homun->calc_skilltree(hd, 0);
+
+ if ( (skill_lv = homun->checkskill(hd, HAMI_SKIN)) > 0 )
+ hstatus->def += skill_lv * 4;
+
+ if ( (skill_lv = homun->checkskill(hd, HVAN_INSTRUCT)) > 0 ) {
+ hstatus->int_ += 1 + skill_lv / 2 + skill_lv / 4 + skill_lv / 5;
+ hstatus->str += 1 + skill_lv / 3 + skill_lv / 3 + skill_lv / 4;
+ }
+
+ if ( (skill_lv = homun->checkskill(hd, HAMI_SKIN)) > 0 )
+ hstatus->max_hp += skill_lv * 2 * hstatus->max_hp / 100;
+
+ if ( (skill_lv = homun->checkskill(hd, HLIF_BRAIN)) > 0 )
+ hstatus->max_sp += (1 + skill_lv / 2 - skill_lv / 4 + skill_lv / 5) * hstatus->max_sp / 100;
+
+ if ( opt&SCO_FIRST ) {
+ hd->battle_status.hp = hom->hp;
+ hd->battle_status.sp = hom->sp;
+ }
+
+#ifndef RENEWAL
+ hstatus->rhw.atk = hstatus->dex;
+ hstatus->rhw.atk2 = hstatus->str + hom->level;
+#endif
+
+ status->calc_misc(&hd->bl, hstatus, hom->level);
+
+ status_cpy(&hd->battle_status, hstatus);
+ return 1;
+}
//Calculates base regen values.
void status_calc_regen(struct block_list *bl, struct status_data *st, struct regen_data *regen) {
@@ -3554,8 +3348,8 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str
|| sc->data[SC_MAGICMUSHROOM]
|| sc->data[SC_RAISINGDRAGON]
|| sc->data[SC_SATURDAY_NIGHT_FEVER]
- ) //No regen
- regen->flag = 0;
+ )
+ regen->flag = 0; //No regen
if ( sc->data[SC_DANCING] || sc->data[SC_OBLIVIONCURSE] || sc->data[SC_MAXIMIZEPOWER] || sc->data[SC_REBOUND]
|| ( bl->type == BL_PC && (((TBL_PC*)bl)->class_&MAPID_UPPERMASK) == MAPID_MONK
@@ -3583,8 +3377,7 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str
regen->flag&=~sce->val4; //Remove regen as specified by val4
}
if(sc->data[SC_GENTLETOUCH_REVITALIZE]) {
- regen->hp = cap_value(regen->hp*sc->data[SC_GENTLETOUCH_REVITALIZE]->val3/100, 1, SHRT_MAX);
- regen->state.walk= 1;
+ regen->hp += regen->hp * ( 30 * sc->data[SC_GENTLETOUCH_REVITALIZE]->val1 + 50 ) / 100;
}
if ((sc->data[SC_FIRE_INSIGNIA] && sc->data[SC_FIRE_INSIGNIA]->val1 == 1) //if insignia lvl 1
|| (sc->data[SC_WATER_INSIGNIA] && sc->data[SC_WATER_INSIGNIA]->val1 == 1)
@@ -3610,6 +3403,21 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) {
if (!bst || !st)
return;
+ /** [Playtester]
+ * This needs to be done even if there is currently no status change active, because
+ * we need to update the speed on the client when the last status change ends.
+ **/
+ if(flag&SCB_SPEED) {
+ struct unit_data *ud = unit->bl2ud(bl);
+ /** [Skotlex]
+ * Re-walk to adjust speed (we do not check if walktimer != INVALID_TIMER
+ * because if you step on something while walking, the moment this
+ * piece of code triggers the walk-timer is set on INVALID_TIMER)
+ **/
+ if (ud)
+ ud->state.change_walk_target = ud->state.speed_changed = 1;
+ }
+
if((!(bl->type&BL_REGEN)) && (!sc || !sc->count)) { //No difference.
status_cpy(st, bst);
return;
@@ -3698,13 +3506,6 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) {
st->lhw.atk2 = status->calc_watk(bl, sc, bst->lhw.atk2, true);
}
}
-
- if( bl->type&BL_HOM ) {
- st->rhw.atk += (st->dex - bst->dex);
- st->rhw.atk2 += (st->str - bst->str);
- if( st->rhw.atk2 < st->rhw.atk )
- st->rhw.atk2 = st->rhw.atk;
- }
}
if(flag&SCB_HIT) {
@@ -3786,16 +3587,9 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) {
}
if(flag&SCB_SPEED) {
- struct unit_data *ud = unit->bl2ud(bl);
st->speed = status->calc_speed(bl, sc, bst->speed);
- //Re-walk to adjust speed (we do not check if walktimer != INVALID_TIMER
- //because if you step on something while walking, the moment this
- //piece of code triggers the walk-timer is set on INVALID_TIMER) [Skotlex]
- if (ud)
- ud->state.change_walk_target = ud->state.speed_changed = 1;
-
if( bl->type&BL_PC && !(sd && sd->state.permanent_speed) && st->speed < battle_config.max_walk_speed )
st->speed = battle_config.max_walk_speed;
@@ -3845,9 +3639,9 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) {
}
// No status changes alter these yet.
- // if(flag&SCB_SIZE)
- // if(flag&SCB_RACE)
- // if(flag&SCB_RANGE)
+ //if(flag&SCB_SIZE)
+ //if(flag&SCB_RACE)
+ //if(flag&SCB_RANGE)
if(flag&SCB_MAXHP) {
if( bl->type&BL_PC ) {
@@ -3891,76 +3685,82 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) {
if(flag&SCB_MATK) {
status->update_matk(bl);
}
+
+ if ( flag&SCB_DSPD ) {
+ int dmotion;
+ if ( bl->type&BL_PC ) {
+ if (bst->agi == st->agi)
+ st->dmotion = status->calc_dmotion(bl, sc, bst->dmotion);
+ else {
+ dmotion = 800-st->agi*4;
+ st->dmotion = cap_value(dmotion, 400, 800);
+ if ( battle_config.pc_damage_delay_rate != 100 )
+ st->dmotion = st->dmotion*battle_config.pc_damage_delay_rate / 100;
+ //It's safe to ignore bst->dmotion since no bonus affects it.
+ st->dmotion = status->calc_dmotion(bl, sc, st->dmotion);
+ }
+ } else if ( bl->type&BL_HOM ) {
+ dmotion = 800 - st->agi * 4;
+ st->dmotion = cap_value(dmotion, 400, 800);
+ st->dmotion = status->calc_dmotion(bl, sc, bst->dmotion);
+ } else { // mercenary and mobs
+ st->dmotion = status->calc_dmotion(bl, sc, bst->dmotion);
+ }
+ }
if(flag&SCB_ASPD) {
int amotion;
- if( bl->type&BL_PC ) {
- amotion = status->base_amotion_pc(sd,st);
-#ifndef RENEWAL_ASPD
- st->aspd_rate = status->calc_aspd_rate(bl, sc, bst->aspd_rate);
-
- if(st->aspd_rate != 1000)
- amotion = amotion*st->aspd_rate/1000;
+ if ( bl->type&BL_HOM ) {
+#ifdef RENEWAL
+ amotion = ((TBL_HOM*)bl)->homunculusDB->baseASPD;
+ amotion = amotion - amotion * status_get_homdex(bl) / 1000 - status_get_homagi(bl) * amotion / 250;
+ amotion = (amotion * status->calc_aspd(bl, sc, 1) + status->calc_aspd(bl, sc, 2)) / -100 + amotion;
#else
- // aspd = baseaspd + floor(sqrt((agi^2/2) + (dex^2/5))/4 + (potskillbonus*agi/200))
- amotion -= (int)(sqrt( (pow(st->agi, 2) / 2) + (pow(st->dex, 2) / 5) ) / 4 + ((float)status->calc_aspd(bl, sc, 1) * st->agi / 200)) * 10;
+ amotion = (1000 - 4 * st->agi - st->dex) * ((TBL_HOM*)bl)->homunculusDB->baseASPD / 1000;
- if( (status->calc_aspd(bl, sc, 2) + st->aspd_rate2) != 0 ) // RE ASPD percertage modifier
- amotion -= (( amotion - ((sd->class_&JOBL_THIRD) ? battle_config.max_third_aspd : battle_config.max_aspd) )
- * (status->calc_aspd(bl, sc, 2) + st->aspd_rate2) / 10 + 5) / 10;
+ amotion = status->calc_aspd_rate(bl, sc, bst->aspd_rate);
- if(st->aspd_rate != 1000) // absolute percentage modifier
- amotion = ( 200 - (200-amotion/10) * st->aspd_rate / 1000 ) * 10;
+ if ( st->aspd_rate != 1000 )
+ amotion = amotion*st->aspd_rate / 1000;
#endif
amotion = status->calc_fix_aspd(bl, sc, amotion);
- st->amotion = cap_value(amotion,((sd->class_&JOBL_THIRD) ? battle_config.max_third_aspd : battle_config.max_aspd),2000);
+ st->amotion = cap_value(amotion, battle_config.max_aspd, 2000);
- st->adelay = 2*st->amotion;
- } else if( bl->type&BL_HOM ) {
- amotion = (1000 - 4*st->agi - st->dex) * ((TBL_HOM*)bl)->homunculusDB->baseASPD/1000;
+ st->adelay = st->amotion;
+ } else if ( bl->type&BL_PC ) {
+ amotion = status->base_amotion_pc(sd, st);
+#ifndef RENEWAL_ASPD
st->aspd_rate = status->calc_aspd_rate(bl, sc, bst->aspd_rate);
if(st->aspd_rate != 1000)
amotion = amotion*st->aspd_rate/1000;
+#else
+ // aspd = baseaspd + floor(sqrt((agi^2/2) + (dex^2/5))/4 + (potskillbonus*agi/200))
+ amotion -= (int)(sqrt((pow(st->agi, 2) / 2) + (pow(st->dex, 2) / 5)) / 4 + ((float)status->calc_aspd(bl, sc, 1) * st->agi / 200)) * 10;
+
+ if ( (status->calc_aspd(bl, sc, 2) + st->aspd_rate2) != 0 ) // RE ASPD percertage modifier
+ amotion -= ((amotion - ((sd->class_&JOBL_THIRD) ? battle_config.max_third_aspd : battle_config.max_aspd))
+ * (status->calc_aspd(bl, sc, 2) + st->aspd_rate2) / 10 + 5) / 10;
+ if ( st->aspd_rate != 1000 ) // absolute percentage modifier
+ amotion = (200 - (200 - amotion / 10) * st->aspd_rate / 1000) * 10;
+#endif
amotion = status->calc_fix_aspd(bl, sc, amotion);
- st->amotion = cap_value(amotion,battle_config.max_aspd,2000);
+ st->amotion = cap_value(amotion, ((sd->class_&JOBL_THIRD) ? battle_config.max_third_aspd : battle_config.max_aspd), 2000);
- st->adelay = st->amotion;
+ st->adelay = 2 * st->amotion;
} else { // mercenary and mobs
amotion = bst->amotion;
st->aspd_rate = status->calc_aspd_rate(bl, sc, bst->aspd_rate);
- if(st->aspd_rate != 1000)
- amotion = amotion*st->aspd_rate/1000;
+ if ( st->aspd_rate != 1000 )
+ amotion = amotion*st->aspd_rate / 1000;
amotion = status->calc_fix_aspd(bl, sc, amotion);
st->amotion = cap_value(amotion, battle_config.monster_max_aspd, 2000);
- temp = bst->adelay*st->aspd_rate/1000;
- st->adelay = cap_value(temp, battle_config.monster_max_aspd*2, 4000);
- }
- }
-
- if(flag&SCB_DSPD) {
- int dmotion;
- if( bl->type&BL_PC ) {
- if (bst->agi == st->agi)
- st->dmotion = status->calc_dmotion(bl, sc, bst->dmotion);
- else {
- dmotion = 800-st->agi*4;
- st->dmotion = cap_value(dmotion, 400, 800);
- if(battle_config.pc_damage_delay_rate != 100)
- st->dmotion = st->dmotion*battle_config.pc_damage_delay_rate/100;
- //It's safe to ignore bst->dmotion since no bonus affects it.
- st->dmotion = status->calc_dmotion(bl, sc, st->dmotion);
- }
- } else if( bl->type&BL_HOM ) {
- dmotion = 800-st->agi*4;
- st->dmotion = cap_value(dmotion, 400, 800);
- st->dmotion = status->calc_dmotion(bl, sc, bst->dmotion);
- } else { // mercenary and mobs
- st->dmotion = status->calc_dmotion(bl, sc, bst->dmotion);
+ temp = bst->adelay*st->aspd_rate / 1000;
+ st->adelay = cap_value(temp, battle_config.monster_max_aspd * 2, 4000);
}
}
@@ -3986,7 +3786,7 @@ void status_calc_bl_(struct block_list *bl, enum scb_flag flag, enum e_status_ca
return;
}
}
-
+
// remember previous values
st = status->get_status_data(bl);
memcpy(&bst, st, sizeof(struct status_data));
@@ -4006,8 +3806,12 @@ void status_calc_bl_(struct block_list *bl, enum scb_flag flag, enum e_status_ca
if( bl->type == BL_PET )
return; // pets are not affected by statuses
- if( opt&SCO_FIRST && bl->type == BL_MOB )
+ if( opt&SCO_FIRST && bl->type == BL_MOB ) {
+#ifdef RENEWAL
+ status->update_matk(bl); // Otherwise, the mob will spawn with lower MATK values
+#endif
return; // assume there will be no statuses active
+ }
status->calc_bl_main(bl, flag);
@@ -4148,6 +3952,245 @@ void status_calc_bl_(struct block_list *bl, enum scb_flag flag, enum e_status_ca
clif->mercenary_updatestatus(ed->master, SP_SP);
}
}
+//Checks whether the source can see and chase target.
+int status_check_visibility(struct block_list *src, struct block_list *target) {
+ int view_range;
+ struct status_change *tsc = NULL;
+
+ switch ( src->type ) {
+ case BL_MOB:
+ view_range = ((TBL_MOB*)src)->min_chase;
+ break;
+ case BL_PET:
+ view_range = ((TBL_PET*)src)->db->range2;
+ break;
+ default:
+ view_range = AREA_SIZE;
+ }
+
+ if ( src->m != target->m || !check_distance_bl(src, target, view_range) )
+ return 0;
+
+ if ( src->type == BL_NPC ) /* NPCs don't care for the rest */
+ return 1;
+
+ if ( (tsc = status->get_sc(target)) ) {
+ struct status_data *st = status->get_status_data(src);
+
+ switch ( target->type ) { //Check for chase-walk/hiding/cloaking opponents.
+ case BL_PC:
+ if ( tsc->data[SC_CLOAKINGEXCEED] && !(st->mode&MD_BOSS) )
+ return 0;
+ if ( (tsc->option&(OPTION_HIDE | OPTION_CLOAK | OPTION_CHASEWALK) || tsc->data[SC_STEALTHFIELD] || tsc->data[SC__INVISIBILITY] || tsc->data[SC_CAMOUFLAGE]) && !(st->mode&MD_BOSS) &&
+ (((TBL_PC*)target)->special_state.perfect_hiding || !(st->mode&MD_DETECTOR)) )
+ return 0;
+ break;
+ default:
+ if ( (tsc->option&(OPTION_HIDE | OPTION_CLOAK | OPTION_CHASEWALK) || tsc->data[SC_CAMOUFLAGE]) && !(st->mode&(MD_BOSS | MD_DETECTOR)) )
+ return 0;
+
+ }
+ }
+
+ return 1;
+}
+
+// Basic ASPD value
+int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) {
+ int amotion;
+#ifdef RENEWAL_ASPD
+ short mod = -1;
+
+ switch ( sd->weapontype2 ) { // adjustment for dual wielding
+ case W_DAGGER:
+ mod = 0;
+ break; // 0, 1, 1
+ case W_1HSWORD:
+ case W_1HAXE:
+ mod = 1;
+ if ( (sd->class_&MAPID_THIRDMASK) == MAPID_GUILLOTINE_CROSS ) // 0, 2, 3
+ mod = sd->weapontype2 / W_1HSWORD + W_1HSWORD / sd->weapontype2;
+ }
+
+ amotion = (sd->status.weapon < MAX_WEAPON_TYPE && mod < 0)
+ ? (status->aspd_base[pc->class2idx(sd->status.class_)][sd->status.weapon]) // single weapon
+ : ((status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2] // dual-wield
+ + status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2]) * 6 / 10 + 10 * mod
+ - status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2]
+ + status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1]);
+
+ if ( sd->status.shield )
+ amotion += (2000 - status->aspd_base[pc->class2idx(sd->status.class_)][W_FIST]) +
+ (status->aspd_base[pc->class2idx(sd->status.class_)][MAX_WEAPON_TYPE] - 2000);
+
+#else
+ // base weapon delay
+ amotion = (sd->status.weapon < MAX_WEAPON_TYPE)
+ ? (status->aspd_base[pc->class2idx(sd->status.class_)][sd->status.weapon]) // single weapon
+ : (status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1] + status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2]) * 7 / 10; // dual-wield
+
+ // percentual delay reduction from stats
+ amotion -= amotion * (4 * st->agi + st->dex) / 1000;
+#endif
+ // raw delay adjustment from bAspd bonus
+ amotion += sd->bonus.aspd_add;
+
+ /* angra manyu disregards aspd_base and similar */
+ if ( sd->equip_index[EQI_HAND_R] >= 0 && sd->status.inventory[sd->equip_index[EQI_HAND_R]].nameid == ITEMID_ANGRA_MANYU )
+ return 0;
+
+ return amotion;
+}
+
+unsigned short status_base_atk(const struct block_list *bl, const struct status_data *st) {
+ int flag = 0, str, dex, dstr;
+
+ if ( !(bl->type&battle_config.enable_baseatk) )
+ return 0;
+
+ if ( bl->type == BL_PC )
+ switch ( ((TBL_PC*)bl)->status.weapon ) {
+ case W_BOW:
+ case W_MUSICAL:
+ case W_WHIP:
+ case W_REVOLVER:
+ case W_RIFLE:
+ case W_GATLING:
+ case W_SHOTGUN:
+ case W_GRENADE:
+ flag = 1;
+ }
+ if ( flag ) {
+#ifdef RENEWAL
+ dstr =
+#endif
+ str = st->dex;
+ dex = st->str;
+ } else {
+#ifdef RENEWAL
+ dstr =
+#endif
+ str = st->str;
+ dex = st->dex;
+ }
+ //Normally only players have base-atk, but homunc have a different batk
+ // equation, hinting that perhaps non-players should use this for batk.
+ // [Skotlex]
+#ifdef RENEWAL
+ if ( bl->type == BL_HOM )
+ str = 2 * (((TBL_HOM*)bl)->homunculus.level + status_get_homstr(bl));
+#else
+ dstr = str / 10;
+ str += dstr*dstr;
+#endif
+ if ( bl->type == BL_PC )
+#ifdef RENEWAL
+ str = (int)(dstr + (float)dex / 5 + (float)st->luk / 3 + (float)((TBL_PC*)bl)->status.base_level / 4);
+ else if ( bl->type == BL_MOB )
+ str = dstr + ((TBL_MOB*)bl)->level;
+#else
+ str += dex / 5 + st->luk / 5;
+#endif
+ return cap_value(str, 0, USHRT_MAX);
+}
+
+#ifndef RENEWAL
+static inline unsigned short status_base_matk_min(const struct status_data *st) { return st->int_ + (st->int_ / 7)*(st->int_ / 7); }
+#endif // not RENEWAL
+static inline unsigned short status_base_matk_max(const struct status_data *st) { return st->int_ + (st->int_ / 5)*(st->int_ / 5); }
+
+unsigned short status_base_matk(struct block_list *bl, const struct status_data *st, int level) {
+#ifdef RENEWAL
+ switch ( bl->type ) {
+ case BL_MOB:
+ return st->int_ + level;
+ case BL_HOM:
+ return status_get_homint(bl) + level;
+ case BL_PC:
+ default: // temporary until all are formulated
+ return st->int_ + (st->int_ / 2) + (st->dex / 5) + (st->luk / 3) + (level / 4);
+ }
+#else
+ return 0;
+#endif
+}
+
+//Fills in the misc data that can be calculated from the other status info (except for level)
+void status_calc_misc(struct block_list *bl, struct status_data *st, int level) {
+ //Non players get the value set, players need to stack with previous bonuses.
+ if ( bl->type != BL_PC )
+ st->batk =
+ st->hit = st->flee =
+ st->def2 = st->mdef2 =
+ st->cri = st->flee2 = 0;
+
+#ifdef RENEWAL // renewal formulas
+ if ( bl->type == BL_HOM ) {
+ st->def2 = status_get_homvit(bl) + status_get_homagi(bl) / 2;
+ st->mdef2 = (status_get_homvit(bl) + status_get_homint(bl)) / 2;
+ st->def += status_get_homvit(bl) + level / 2;
+ st->mdef = (int)(((float)status_get_homvit(bl) + level) / 4 + (float)status_get_homint(bl) / 2);
+ st->hit = level + st->dex + 150;
+ st->flee = level + status_get_homagi(bl);
+ st->rhw.atk = (status_get_homstr(bl) + status_get_homdex(bl)) / 5;
+ st->rhw.atk2 = (status_get_homluk(bl) + status_get_homstr(bl) + status_get_homdex(bl)) / 3;
+ } else {
+ st->hit += level + st->dex + (bl->type == BL_PC ? st->luk / 3 + 175 : 150); //base level + ( every 1 dex = +1 hit ) + (every 3 luk = +1 hit) + 175
+ st->flee += level + st->agi + (bl->type == BL_PC ? st->luk / 5 : 0) + 100; //base level + ( every 1 agi = +1 flee ) + (every 5 luk = +1 flee) + 100
+ st->def2 += (int)(((float)level + st->vit) / 2 + (bl->type == BL_PC ? ((float)st->agi / 5) : 0)); //base level + (every 2 vit = +1 def) + (every 5 agi = +1 def)
+ st->mdef2 += (int)(bl->type == BL_PC ? (st->int_ + ((float)level / 4) + ((float)(st->dex + st->vit) / 5)) : ((float)(st->int_ + level) / 4)); //(every 4 base level = +1 mdef) + (every 1 int = +1 mdef) + (every 5 dex = +1 mdef) + (every 5 vit = +1 mdef)
+ }
+#else // not RENEWAL
+ st->matk_min = status_base_matk_min(st);
+ st->matk_max = status_base_matk_max(st);
+ st->hit += level + st->dex;
+ st->flee += level + st->agi;
+ st->def2 += st->vit;
+ st->mdef2 += st->int_ + (st->vit >> 1);
+#endif // RENEWAL
+
+ if ( bl->type&battle_config.enable_critical )
+ st->cri += 10 + (st->luk * 10 / 3); //(every 1 luk = +0.3 critical)
+ else
+ st->cri = 0;
+
+ if ( bl->type&battle_config.enable_perfect_flee )
+ st->flee2 += st->luk + 10; //(every 10 luk = +1 perfect flee)
+ else
+ st->flee2 = 0;
+
+ if ( st->batk ) {
+ int temp = st->batk + status->base_atk(bl, st);
+ st->batk = cap_value(temp, 0, USHRT_MAX);
+ } else
+ st->batk = status->base_atk(bl, st);
+ if ( st->cri )
+ switch ( bl->type ) {
+ case BL_MOB:
+ if ( battle_config.mob_critical_rate != 100 )
+ st->cri = st->cri*battle_config.mob_critical_rate / 100;
+ if ( !st->cri && battle_config.mob_critical_rate )
+ st->cri = 10;
+ break;
+ case BL_PC:
+ //Players don't have a critical adjustment setting as of yet.
+ break;
+ case BL_MER:
+#ifdef RENEWAL
+ st->matk_min = st->matk_max = status_base_matk_max(st);
+ st->def2 = st->vit + level / 10 + st->vit / 5;
+ st->mdef2 = level / 10 + st->int_ / 5;
+#endif
+ break;
+ default:
+ if ( battle_config.critical_rate != 100 )
+ st->cri = st->cri*battle_config.critical_rate / 100;
+ if ( !st->cri && battle_config.critical_rate )
+ st->cri = 10;
+ }
+ if ( bl->type&BL_REGEN )
+ status->calc_regen(bl, st, status->get_regen_data(bl));
+}
/*==========================================
* Apply shared stat mods from status changes [DracoRPG]
@@ -4157,14 +4200,14 @@ unsigned short status_calc_str(struct block_list *bl, struct status_change *sc,
if(!sc || !sc->count)
return cap_value(str,0,USHRT_MAX);
+ if(sc->data[SC_FULL_THROTTLE])
+ str += str * 20 / 100;
if(sc->data[SC_HARMONIZE]) {
str -= sc->data[SC_HARMONIZE]->val2;
return (unsigned short)cap_value(str,0,USHRT_MAX);
}
if(sc->data[SC_BEYOND_OF_WARCRY])
str += sc->data[SC_BEYOND_OF_WARCRY]->val3;
- if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH && str < 50)
- return 50;
if(sc->data[SC_INCALLSTATUS])
str += sc->data[SC_INCALLSTATUS]->val1;
if(sc->data[SC_CHASEWALK2])
@@ -4195,6 +4238,8 @@ unsigned short status_calc_str(struct block_list *bl, struct status_change *sc,
str -= ((sc->data[SC_MARIONETTE_MASTER]->val3)>>16)&0xFF;
if(sc->data[SC_MARIONETTE])
str += ((sc->data[SC_MARIONETTE]->val3)>>16)&0xFF;
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH)
+ str += ((sc->data[SC_SOULLINK]->val3)>>16)&0xFF;
if(sc->data[SC_GIANTGROWTH])
str += 30;
if(sc->data[SC_SAVAGE_STEAK])
@@ -4204,9 +4249,7 @@ unsigned short status_calc_str(struct block_list *bl, struct status_change *sc,
if(sc->data[SC_STOMACHACHE])
str -= sc->data[SC_STOMACHACHE]->val1;
if(sc->data[SC_KYOUGAKU])
- str -= sc->data[SC_KYOUGAKU]->val2;
- if(sc->data[SC_FULL_THROTTLE])
- str += str * 20 / 100;
+ str -= sc->data[SC_KYOUGAKU]->val3;
return (unsigned short)cap_value(str,0,USHRT_MAX);
}
@@ -4216,12 +4259,12 @@ unsigned short status_calc_agi(struct block_list *bl, struct status_change *sc,
if(!sc || !sc->count)
return cap_value(agi,0,USHRT_MAX);
+ if(sc->data[SC_FULL_THROTTLE])
+ agi += agi * 20 / 100;
if(sc->data[SC_HARMONIZE]) {
agi -= sc->data[SC_HARMONIZE]->val2;
return (unsigned short)cap_value(agi,0,USHRT_MAX);
}
- if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH && agi < 50)
- return 50;
if(sc->data[SC_CONCENTRATION] && !sc->data[SC_QUAGMIRE])
agi += (agi-sc->data[SC_CONCENTRATION]->val3)*sc->data[SC_CONCENTRATION]->val2/100;
if(sc->data[SC_INCALLSTATUS])
@@ -4239,7 +4282,7 @@ unsigned short status_calc_agi(struct block_list *bl, struct status_change *sc,
if(sc->data[SC_INC_AGI])
agi += sc->data[SC_INC_AGI]->val2;
if(sc->data[SC_GS_ACCURACY])
- agi += 4; // added based on skill updates [Reddozen]
+ agi += 4; // added based on skill updates [Reddozen]
if(sc->data[SC_DEC_AGI])
agi -= sc->data[SC_DEC_AGI]->val2;
if(sc->data[SC_QUAGMIRE])
@@ -4250,6 +4293,8 @@ unsigned short status_calc_agi(struct block_list *bl, struct status_change *sc,
agi -= ((sc->data[SC_MARIONETTE_MASTER]->val3)>>8)&0xFF;
if(sc->data[SC_MARIONETTE])
agi += ((sc->data[SC_MARIONETTE]->val3)>>8)&0xFF;
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH)
+ agi += ((sc->data[SC_SOULLINK]->val3)>>8)&0xFF;
if(sc->data[SC_ADORAMUS])
agi -= sc->data[SC_ADORAMUS]->val2;
if(sc->data[SC_DROCERA_HERB_STEAMED])
@@ -4259,12 +4304,10 @@ unsigned short status_calc_agi(struct block_list *bl, struct status_change *sc,
if(sc->data[SC_STOMACHACHE])
agi -= sc->data[SC_STOMACHACHE]->val1;
if(sc->data[SC_KYOUGAKU])
- agi -= sc->data[SC_KYOUGAKU]->val2;
+ agi -= sc->data[SC_KYOUGAKU]->val3;
if(sc->data[SC_MARSHOFABYSS])
agi -= agi * sc->data[SC_MARSHOFABYSS]->val2 / 100;
- if(sc->data[SC_FULL_THROTTLE])
- agi += agi * 20 / 100;
return (unsigned short)cap_value(agi,0,USHRT_MAX);
}
@@ -4274,12 +4317,12 @@ unsigned short status_calc_vit(struct block_list *bl, struct status_change *sc,
if(!sc || !sc->count)
return cap_value(vit,0,USHRT_MAX);
+ if(sc->data[SC_FULL_THROTTLE])
+ vit += vit * 20 / 100;
if(sc->data[SC_HARMONIZE]) {
vit -= sc->data[SC_HARMONIZE]->val2;
return (unsigned short)cap_value(vit,0,USHRT_MAX);
}
- if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH && vit < 50)
- return 50;
if(sc->data[SC_INCALLSTATUS])
vit += sc->data[SC_INCALLSTATUS]->val1;
if(sc->data[SC_INCVIT])
@@ -4298,6 +4341,8 @@ unsigned short status_calc_vit(struct block_list *bl, struct status_change *sc,
vit -= sc->data[SC_MARIONETTE_MASTER]->val3&0xFF;
if(sc->data[SC_MARIONETTE])
vit += sc->data[SC_MARIONETTE]->val3&0xFF;
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH)
+ vit += sc->data[SC_SOULLINK]->val3&0xFF;
if(sc->data[SC_LAUDAAGNUS])
vit += 4 + sc->data[SC_LAUDAAGNUS]->val1;
if(sc->data[SC_MINOR_BBQ])
@@ -4307,12 +4352,10 @@ unsigned short status_calc_vit(struct block_list *bl, struct status_change *sc,
if(sc->data[SC_STOMACHACHE])
vit -= sc->data[SC_STOMACHACHE]->val1;
if(sc->data[SC_KYOUGAKU])
- vit -= sc->data[SC_KYOUGAKU]->val2;
+ vit -= sc->data[SC_KYOUGAKU]->val3;
if(sc->data[SC_NOEQUIPARMOR])
vit -= vit * sc->data[SC_NOEQUIPARMOR]->val2/100;
- if(sc->data[SC_FULL_THROTTLE])
- vit += vit * 20 / 100;
return (unsigned short)cap_value(vit,0,USHRT_MAX);
}
@@ -4322,14 +4365,14 @@ unsigned short status_calc_int(struct block_list *bl, struct status_change *sc,
if(!sc || !sc->count)
return cap_value(int_,0,USHRT_MAX);
+ if(sc->data[SC_FULL_THROTTLE])
+ int_ += int_ * 20 / 100;
if(sc->data[SC_HARMONIZE]) {
int_ -= sc->data[SC_HARMONIZE]->val2;
return (unsigned short)cap_value(int_,0,USHRT_MAX);
}
if(sc->data[SC_MELODYOFSINK])
int_ -= sc->data[SC_MELODYOFSINK]->val3;
- if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH && int_ < 50)
- return 50;
if(sc->data[SC_INCALLSTATUS])
int_ += sc->data[SC_INCALLSTATUS]->val1;
if(sc->data[SC_INCINT])
@@ -4356,6 +4399,8 @@ unsigned short status_calc_int(struct block_list *bl, struct status_change *sc,
int_ -= ((sc->data[SC_MARIONETTE_MASTER]->val4)>>16)&0xFF;
if(sc->data[SC_MARIONETTE])
int_ += ((sc->data[SC_MARIONETTE]->val4)>>16)&0xFF;
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH)
+ int_ += ((sc->data[SC_SOULLINK]->val4)>>16)&0xFF;
if(sc->data[SC_MANDRAGORA])
int_ -= 4 * sc->data[SC_MANDRAGORA]->val1;
if(sc->data[SC_COCKTAIL_WARG_BLOOD])
@@ -4365,7 +4410,7 @@ unsigned short status_calc_int(struct block_list *bl, struct status_change *sc,
if(sc->data[SC_STOMACHACHE])
int_ -= sc->data[SC_STOMACHACHE]->val1;
if(sc->data[SC_KYOUGAKU])
- int_ -= sc->data[SC_KYOUGAKU]->val2;
+ int_ -= sc->data[SC_KYOUGAKU]->val3;
if(bl->type != BL_PC){
if(sc->data[SC_NOEQUIPHELM])
@@ -4373,8 +4418,6 @@ unsigned short status_calc_int(struct block_list *bl, struct status_change *sc,
if(sc->data[SC__STRIPACCESSARY])
int_ -= int_ * sc->data[SC__STRIPACCESSARY]->val2 / 100;
}
- if(sc->data[SC_FULL_THROTTLE])
- int_ += int_ * 20 / 100;
return (unsigned short)cap_value(int_,0,USHRT_MAX);
}
@@ -4384,12 +4427,12 @@ unsigned short status_calc_dex(struct block_list *bl, struct status_change *sc,
if(!sc || !sc->count)
return cap_value(dex,0,USHRT_MAX);
+ if(sc->data[SC_FULL_THROTTLE])
+ dex += dex * 20 / 100;
if(sc->data[SC_HARMONIZE]) {
dex -= sc->data[SC_HARMONIZE]->val2;
return (unsigned short)cap_value(dex,0,USHRT_MAX);
}
- if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH && dex < 50)
- return 50;
if(sc->data[SC_CONCENTRATION] && !sc->data[SC_QUAGMIRE])
dex += (dex-sc->data[SC_CONCENTRATION]->val4)*sc->data[SC_CONCENTRATION]->val2/100;
if(sc->data[SC_INCALLSTATUS])
@@ -4415,11 +4458,13 @@ unsigned short status_calc_dex(struct block_list *bl, struct status_change *sc,
dex >>= 1;
}
if(sc->data[SC_GS_ACCURACY])
- dex += 4; // added based on skill updates [Reddozen]
+ dex += 4; // added based on skill updates [Reddozen]
if(sc->data[SC_MARIONETTE_MASTER])
dex -= ((sc->data[SC_MARIONETTE_MASTER]->val4)>>8)&0xFF;
if(sc->data[SC_MARIONETTE])
dex += ((sc->data[SC_MARIONETTE]->val4)>>8)&0xFF;
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH)
+ dex += ((sc->data[SC_SOULLINK]->val4)>>8)&0xFF;
if(sc->data[SC_SIROMA_ICE_TEA])
dex += sc->data[SC_SIROMA_ICE_TEA]->val1;
if(sc->data[SC_INSPIRATION])
@@ -4427,14 +4472,12 @@ unsigned short status_calc_dex(struct block_list *bl, struct status_change *sc,
if(sc->data[SC_STOMACHACHE])
dex -= sc->data[SC_STOMACHACHE]->val1;
if(sc->data[SC_KYOUGAKU])
- dex -= sc->data[SC_KYOUGAKU]->val2;
+ dex -= sc->data[SC_KYOUGAKU]->val3;
if(sc->data[SC_MARSHOFABYSS])
dex -= dex * sc->data[SC_MARSHOFABYSS]->val2 / 100;
if(sc->data[SC__STRIPACCESSARY] && bl->type != BL_PC)
dex -= dex * sc->data[SC__STRIPACCESSARY]->val2 / 100;
- if(sc->data[SC_FULL_THROTTLE])
- dex += dex * 20 / 100;
return (unsigned short)cap_value(dex,0,USHRT_MAX);
}
@@ -4444,14 +4487,14 @@ unsigned short status_calc_luk(struct block_list *bl, struct status_change *sc,
if(!sc || !sc->count)
return cap_value(luk,0,USHRT_MAX);
+ if(sc->data[SC_FULL_THROTTLE])
+ luk += luk * 20 / 100;
if(sc->data[SC_HARMONIZE]) {
luk -= sc->data[SC_HARMONIZE]->val2;
return (unsigned short)cap_value(luk,0,USHRT_MAX);
}
if(sc->data[SC_CURSE])
return 0;
- if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH && luk < 50)
- return 50;
if(sc->data[SC_INCALLSTATUS])
luk += sc->data[SC_INCALLSTATUS]->val1;
if(sc->data[SC_INCLUK])
@@ -4468,6 +4511,8 @@ unsigned short status_calc_luk(struct block_list *bl, struct status_change *sc,
luk -= sc->data[SC_MARIONETTE_MASTER]->val4&0xFF;
if(sc->data[SC_MARIONETTE])
luk += sc->data[SC_MARIONETTE]->val4&0xFF;
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH)
+ luk += sc->data[SC_SOULLINK]->val4&0xFF;
if(sc->data[SC_PUTTI_TAILS_NOODLES])
luk += sc->data[SC_PUTTI_TAILS_NOODLES]->val1;
if(sc->data[SC_INSPIRATION])
@@ -4475,7 +4520,7 @@ unsigned short status_calc_luk(struct block_list *bl, struct status_change *sc,
if(sc->data[SC_STOMACHACHE])
luk -= sc->data[SC_STOMACHACHE]->val1;
if(sc->data[SC_KYOUGAKU])
- luk -= sc->data[SC_KYOUGAKU]->val2;
+ luk -= sc->data[SC_KYOUGAKU]->val3;
if(sc->data[SC_LAUDARAMUS])
luk += 4 + sc->data[SC_LAUDARAMUS]->val1;
@@ -4483,8 +4528,6 @@ unsigned short status_calc_luk(struct block_list *bl, struct status_change *sc,
luk -= luk * sc->data[SC__STRIPACCESSARY]->val2 / 100;
if(sc->data[SC_BANANA_BOMB])
luk -= luk * sc->data[SC_BANANA_BOMB]->val1 / 100;
- if(sc->data[SC_FULL_THROTTLE])
- luk += luk * 20 / 100;
return (unsigned short)cap_value(luk,0,USHRT_MAX);
}
@@ -4547,9 +4590,10 @@ unsigned short status_calc_batk(struct block_list *bl, struct status_change *sc,
batk -= batk * 25/100;
if( sc->data[SC_ZANGETSU] )
batk += sc->data[SC_ZANGETSU]->val2;
- //Curse shouldn't effect on this? <- Curse OR Bleeding??
- // if(sc->data[SC_BLOODING])
- // batk -= batk * 25/100;
+#if 0 //Curse shouldn't effect on this? <- Curse OR Bleeding??
+ if(sc->data[SC_BLOODING])
+ batk -= batk * 25/100;
+#endif // 0
if(sc->data[SC_HLIF_FLEET])
batk += batk * sc->data[SC_HLIF_FLEET]->val3/100;
if(sc->data[SC__ENERVATION])
@@ -4591,7 +4635,7 @@ unsigned short status_calc_watk(struct block_list *bl, struct status_change *sc,
watk += sc->data[SC_SHIELDSPELL_DEF]->val2;
if(sc->data[SC_INSPIRATION])
watk += sc->data[SC_INSPIRATION]->val2;
- if( sc->data[SC_BANDING] && sc->data[SC_BANDING]->val2 > 0 )
+ if( sc->data[SC_BANDING] && sc->data[SC_BANDING]->val2 > 1 )
watk += (10 + 10 * sc->data[SC_BANDING]->val1) * (sc->data[SC_BANDING]->val2);
if( sc->data[SC_TROPIC_OPTION] )
watk += sc->data[SC_TROPIC_OPTION]->val2;
@@ -4776,6 +4820,8 @@ signed short status_calc_hit(struct block_list *bl, struct status_change *sc, in
if(sc->data[SC_INCHIT])
hit += sc->data[SC_INCHIT]->val1;
+ if(sc->data[SC_MTF_HITFLEE])
+ hit += sc->data[SC_MTF_HITFLEE]->val1;
if(sc->data[SC_FOOD_BASICHIT])
hit += sc->data[SC_FOOD_BASICHIT]->val1;
if(sc->data[SC_TRUESIGHT])
@@ -4797,6 +4843,8 @@ signed short status_calc_hit(struct block_list *bl, struct status_change *sc, in
hit += hit * sc->data[SC_INCHITRATE]->val1/100;
if(sc->data[SC_BLIND])
hit -= hit * 25/100;
+ if(sc->data[SC_FIRE_EXPANSION_TEAR_GAS])
+ hit -= hit * 50 / 100;
if(sc->data[SC__GROOMY])
hit -= hit * sc->data[SC__GROOMY]->val3 / 100;
if(sc->data[SC_FEAR])
@@ -4805,7 +4853,7 @@ signed short status_calc_hit(struct block_list *bl, struct status_change *sc, in
hit /= 2;
if(sc->data[SC_ILLUSIONDOPING])
hit -= hit * (5 + sc->data[SC_ILLUSIONDOPING]->val1) / 100; //custom
-
+
return (short)cap_value(hit,1,SHRT_MAX);
}
@@ -4827,6 +4875,8 @@ signed short status_calc_flee(struct block_list *bl, struct status_change *sc, i
if(sc->data[SC_INCFLEE])
flee += sc->data[SC_INCFLEE]->val1;
+ if(sc->data[SC_MTF_HITFLEE])
+ flee += sc->data[SC_MTF_HITFLEE]->val2;
if(sc->data[SC_FOOD_BASICAVOIDANCE])
flee += sc->data[SC_FOOD_BASICAVOIDANCE]->val1;
if(sc->data[SC_WHISTLE])
@@ -4880,6 +4930,10 @@ signed short status_calc_flee(struct block_list *bl, struct status_change *sc, i
flee -= flee * ( 20 + 5 * sc->data[SC_GLOOMYDAY]->val1 ) / 100;
if( sc->data[SC_SATURDAY_NIGHT_FEVER] )
flee -= flee * (40 + 10 * sc->data[SC_SATURDAY_NIGHT_FEVER]->val1) / 100;
+ if ( sc->data[SC_FIRE_EXPANSION_SMOKE_POWDER] )
+ flee += flee * 20 / 100;
+ if ( sc->data[SC_FIRE_EXPANSION_TEAR_GAS] )
+ flee -= flee * 50 / 100;
if( sc->data[SC_WIND_STEP_OPTION] )
flee += flee * sc->data[SC_WIND_STEP_OPTION]->val2 / 100;
if( sc->data[SC_ZEPHYR] )
@@ -4888,7 +4942,7 @@ signed short status_calc_flee(struct block_list *bl, struct status_change *sc, i
if(status_get_element(bl) == ELE_WATER) //water type
flee /= 2;
}
-
+
if( sc->data[SC_OVERED_BOOST] ) // should be final and unmodifiable by any means
flee = sc->data[SC_OVERED_BOOST]->val2;
@@ -4927,8 +4981,6 @@ defType status_calc_def(struct block_list *bl, struct status_change *sc, int def
def -= def * 50 / 100;
if( sc->data[SC_NEUTRALBARRIER] )
def += def * (10 + 5*sc->data[SC_NEUTRALBARRIER]->val1) / 100;
- if( sc && sc->data[SC_GENTLETOUCH_REVITALIZE] && sc->data[SC_GENTLETOUCH_REVITALIZE]->val4 )
- def += 2 * sc->data[SC_GENTLETOUCH_REVITALIZE]->val4;
if( sc->data[SC_FORCEOFVANGUARD] )
def += def * 2 * sc->data[SC_FORCEOFVANGUARD]->val1 / 100;
if(sc->data[SC_DEFSET])
@@ -4948,7 +5000,7 @@ defType status_calc_def(struct block_list *bl, struct status_change *sc, int def
if(sc->data[SC_STEELBODY])
return 90;
#endif
-
+
if(sc->data[SC_STONEHARDSKIN])
def += sc->data[SC_STONEHARDSKIN]->val1;
if(sc->data[SC_DRUMBATTLE])
@@ -4956,7 +5008,7 @@ defType status_calc_def(struct block_list *bl, struct status_change *sc, int def
if(sc->data[SC_STONESKIN])
def += sc->data[SC_STONESKIN]->val2;
- if(sc->data[SC_HAMI_DEFENCE]) //[orn]
+ if(sc->data[SC_HAMI_DEFENCE]) //[orn]
def += sc->data[SC_HAMI_DEFENCE]->val2;
if(sc->data[SC_EARTH_INSIGNIA] && sc->data[SC_EARTH_INSIGNIA]->val1 == 2)
@@ -5032,6 +5084,8 @@ signed short status_calc_def2(struct block_list *bl, struct status_change *sc, i
#endif
if( sc && sc->data[SC_CAMOUFLAGE] )
def2 -= def2 * 5 * (10-sc->data[SC_CAMOUFLAGE]->val4) / 100;
+ if(sc->data[SC_GENTLETOUCH_REVITALIZE])
+ def2 += sc->data[SC_GENTLETOUCH_REVITALIZE]->val2;
if(sc->data[SC_DEFSET])
return sc->data[SC_DEFSET]->val1;
#ifdef RENEWAL
@@ -5047,7 +5101,7 @@ signed short status_calc_def2(struct block_list *bl, struct status_change *sc, i
return 0;
if(sc->data[SC_SUN_COMFORT])
def2 += sc->data[SC_SUN_COMFORT]->val2;
- if( sc->data[SC_BANDING] && sc->data[SC_BANDING]->val2 > 0 )
+ if( sc->data[SC_BANDING] && sc->data[SC_BANDING]->val2 > 1 )
def2 += (5 + sc->data[SC_BANDING]->val1) * (sc->data[SC_BANDING]->val2);
if(sc->data[SC_ANGELUS])
#ifdef RENEWAL //in renewal only the VIT stat bonus is boosted by angelus
@@ -5204,16 +5258,16 @@ unsigned short status_calc_speed(struct block_list *bl, struct status_change *sc
{
int val = 0;
- if( sc->data[SC_FUSION] )
+ if(sc->data[SC_FUSION]) {
val = 25;
- else if( sd ) {
- if( pc_isriding(sd) || sd->sc.option&(OPTION_DRAGON) || sd->sc.data[SC_ALL_RIDING] )
+ } else if (sd) {
+ if (pc_isridingpeco(sd) || pc_isridingdragon(sd) || sd->sc.data[SC_ALL_RIDING])
val = 25;//Same bonus
- else if( pc_isridingwug(sd) )
+ else if (pc_isridingwug(sd))
val = 15 + 5 * pc->checkskill(sd, RA_WUGRIDER);
- else if( pc_ismadogear(sd) ) {
+ else if (pc_ismadogear(sd)) {
val = (- 10 * (5 - pc->checkskill(sd,NC_MADOLICENCE)));
- if( sc->data[SC_ACCELERATION] )
+ if (sc->data[SC_ACCELERATION])
val += 25;
}
}
@@ -5272,7 +5326,7 @@ unsigned short status_calc_speed(struct block_list *bl, struct status_change *sc
if( sc->data[SC__GROOMY] )
val = max( val, sc->data[SC__GROOMY]->val2);
if( sc->data[SC_GLOOMYDAY] )
- val = max( val, sc->data[SC_GLOOMYDAY]->val3 ); // Should be 50 (-50% speed)
+ val = max( val, sc->data[SC_GLOOMYDAY]->val3 ); // Should be 50 (-50% speed)
if( sc->data[SC_STEALTHFIELD_MASTER] )
val = max( val, 30 );
if( sc->data[SC_BANDING_DEFENCE] )
@@ -5329,7 +5383,7 @@ unsigned short status_calc_speed(struct block_list *bl, struct status_change *sc
if( sc->data[SC_WIND_STEP_OPTION] )
val = max( val, sc->data[SC_WIND_STEP_OPTION]->val2 );
if( sc->data[SC_FULL_THROTTLE] )
- val = max( val, 30);
+ val = max( val, 25);
//FIXME: official items use a single bonus for this [ultramage]
if( sc->data[SC_MOVHASTE_HORSE] ) // temporary item-based speedup
val = max( val, 25 );
@@ -5369,119 +5423,123 @@ unsigned short status_calc_speed(struct block_list *bl, struct status_change *sc
// flag&2 - percentage value
short status_calc_aspd(struct block_list *bl, struct status_change *sc, short flag) {
#ifdef RENEWAL_ASPD
- int i, pots = 0, skills1 = 0, skills2 = 0;
+ int i, pots = 0, bonus = 0;
- if(!sc || !sc->count)
+ if (!sc || !sc->count)
return 0;
- if(sc->data[i=SC_ATTHASTE_INFINITY] ||
- sc->data[i=SC_ATTHASTE_POTION3] ||
- sc->data[i=SC_ATTHASTE_POTION2] ||
- sc->data[i=SC_ATTHASTE_POTION1])
- pots += sc->data[i]->val1;
-
- if( !sc->data[SC_QUAGMIRE] ){
- if(sc->data[SC_TWOHANDQUICKEN] && skills1 < 7)
- skills1 = 7;
-
- if(sc->data[SC_ONEHANDQUICKEN] && skills1 < 7) skills1 = 7;
-
- if(sc->data[SC_MER_QUICKEN] && skills1 < 7) // needs more info
- skills1 = 7;
-
- if(sc->data[SC_ADRENALINE2] && skills1 < 6)
- skills1 = 6;
-
- if(sc->data[SC_ADRENALINE] && skills1 < 7)
- skills1 = 7;
-
- if(sc->data[SC_SPEARQUICKEN] && skills1 < 7)
- skills1 = 7;
+ if (flag&1) {
+ // ASPD fixed values
+ if (sc->data[i=SC_ATTHASTE_INFINITY]
+ || sc->data[i=SC_ATTHASTE_POTION3]
+ || sc->data[i=SC_ATTHASTE_POTION2]
+ || sc->data[i=SC_ATTHASTE_POTION1]
+ )
+ pots += sc->data[i]->val1;
+
+ if (!sc->data[SC_QUAGMIRE]) {
+ if(sc->data[SC_TWOHANDQUICKEN] && bonus < 7)
+ bonus = 7;
+ if(sc->data[SC_ONEHANDQUICKEN] && bonus < 7)
+ bonus = 7;
+ if(sc->data[SC_MER_QUICKEN] && bonus < 7) // needs more info
+ bonus = 7;
+ if(sc->data[SC_ADRENALINE2] && bonus < 6)
+ bonus = 6;
+ if(sc->data[SC_ADRENALINE] && bonus < 7)
+ bonus = 7;
+ if(sc->data[SC_SPEARQUICKEN] && bonus < 7)
+ bonus = 7;
+ if(sc->data[SC_HLIF_FLEET] && bonus < 5)
+ bonus = 5;
+ }
- if(sc->data[SC_HLIF_FLEET] && skills1 < 5)
- skills1 = 5;
- }
+ if (sc->data[SC_ASSNCROS] && bonus < sc->data[SC_ASSNCROS]->val2) {
+ if (bl->type!=BL_PC)
+ bonus = sc->data[SC_ASSNCROS]->val2;
+ else {
+ switch (((TBL_PC*)bl)->status.weapon)
+ {
+ case W_BOW:
+ case W_REVOLVER:
+ case W_RIFLE:
+ case W_GATLING:
+ case W_SHOTGUN:
+ case W_GRENADE:
+ break;
+ default:
+ bonus = sc->data[SC_ASSNCROS]->val2;
+ }
+ }
+ }
- if((sc->data[SC_BERSERK]) && skills1 < 15)
- skills1 = 15;
- else if(sc->data[SC_GS_MADNESSCANCEL] && skills1 < 20)
- skills1 = 20;
+ if ((sc->data[SC_BERSERK]) && bonus < 15)
+ bonus = 15;
+ else if (sc->data[SC_GS_MADNESSCANCEL] && bonus < 20)
+ bonus = 20;
- if(sc->data[SC_DONTFORGETME])
- skills2 -= sc->data[SC_DONTFORGETME]->val2;
- if(sc->data[SC_LONGING])
- skills2 -= sc->data[SC_LONGING]->val2;
- if(sc->data[SC_STEELBODY])
- skills2 -= 25;
- if(sc->data[SC_SKA])
- skills2 -= 25;
- if(sc->data[SC_DEFENDER])
- skills2 -= sc->data[SC_DEFENDER]->val4 / 10;
- if(sc->data[SC_GOSPEL] && sc->data[SC_GOSPEL]->val4 == BCT_ENEMY) // needs more info
- skills2 -= 25;
- if(sc->data[SC_GRAVITATION])
- skills2 -= sc->data[SC_GRAVITATION]->val2; // needs more info
- if(sc->data[SC_JOINTBEAT]) { // needs more info
- if( sc->data[SC_JOINTBEAT]->val2&BREAK_WRIST )
- skills2 -= 25;
- if( sc->data[SC_JOINTBEAT]->val2&BREAK_KNEE )
- skills2 -= 10;
- }
- if( sc->data[SC_FROSTMISTY] )
- skills2 -= 15;
- if( sc->data[SC_HALLUCINATIONWALK_POSTDELAY] )
- skills2 -= 50;
- if( sc->data[SC_PARALYSE] )
- skills2 -= 10;
- if( sc->data[SC__BODYPAINT] )
- skills2 -= sc->data[SC__BODYPAINT]->val1;
- if( sc->data[SC__INVISIBILITY] )
- skills2 -= sc->data[SC__INVISIBILITY]->val2 ;
- if( sc->data[SC__GROOMY] )
- skills2 -= sc->data[SC__GROOMY]->val2;
- if( sc->data[SC_GLOOMYDAY] )
- skills2 -= ( 15 + 5 * sc->data[SC_GLOOMYDAY]->val1 );
- if( sc->data[SC_EARTHDRIVE] )
- skills2 -= 25;
- if( sc->data[SC_MELON_BOMB] )
- skills2 -= sc->data[SC_MELON_BOMB]->val1;
- if( sc->data[SC_PAIN_KILLER] )
- skills2 -= sc->data[SC_PAIN_KILLER]->val2;
-
- if( sc->data[SC_SWING] )
- skills2 += sc->data[SC_SWING]->val3;
- if( sc->data[SC_DANCE_WITH_WUG] )
- skills2 += sc->data[SC_DANCE_WITH_WUG]->val3;
- if( sc->data[SC_GENTLETOUCH_CHANGE] )
- skills2 += sc->data[SC_GENTLETOUCH_CHANGE]->val3;
- if( sc->data[SC_BOOST500] )
- skills2 += sc->data[SC_BOOST500]->val1;
- if( sc->data[SC_EXTRACT_SALAMINE_JUICE] )
- skills2 += sc->data[SC_EXTRACT_SALAMINE_JUICE]->val1;
- if( sc->data[SC_INCASPDRATE] )
- skills2 += sc->data[SC_INCASPDRATE]->val1;
- if( sc->data[SC_GS_GATLINGFEVER] )
- skills2 += sc->data[SC_GS_GATLINGFEVER]->val1;
- if( sc->data[SC_STAR_COMFORT] )
- skills2 += 3 * sc->data[SC_STAR_COMFORT]->val1;
- if( sc->data[SC_ASSNCROS] && !skills1){
- if (bl->type!=BL_PC)
- skills2 += sc->data[SC_ASSNCROS]->val2;
- else
- switch(((TBL_PC*)bl)->status.weapon)
- {
- case W_BOW:
- case W_REVOLVER:
- case W_RIFLE:
- case W_GATLING:
- case W_SHOTGUN:
- case W_GRENADE:
- break;
- default:
- skills2 += sc->data[SC_ASSNCROS]->val2;
+ } else {
+ // ASPD percentage values
+ if (sc->data[SC_DONTFORGETME])
+ bonus -= sc->data[SC_DONTFORGETME]->val2;
+ if (sc->data[SC_LONGING])
+ bonus -= sc->data[SC_LONGING]->val2;
+ if (sc->data[SC_STEELBODY])
+ bonus -= 25;
+ if (sc->data[SC_SKA])
+ bonus -= 25;
+ if (sc->data[SC_DEFENDER])
+ bonus -= sc->data[SC_DEFENDER]->val4 / 10;
+ if (sc->data[SC_GOSPEL] && sc->data[SC_GOSPEL]->val4 == BCT_ENEMY) // needs more info
+ bonus -= 25;
+ if (sc->data[SC_GRAVITATION])
+ bonus -= sc->data[SC_GRAVITATION]->val2; // needs more info
+ if (sc->data[SC_JOINTBEAT]) { // needs more info
+ if (sc->data[SC_JOINTBEAT]->val2&BREAK_WRIST)
+ bonus -= 25;
+ if (sc->data[SC_JOINTBEAT]->val2&BREAK_KNEE)
+ bonus -= 10;
}
- }
- return ( flag&1? (skills1 + pots) : skills2 );
+ if (sc->data[SC_FROSTMISTY])
+ bonus -= 15;
+ if (sc->data[SC_HALLUCINATIONWALK_POSTDELAY])
+ bonus -= 50;
+ if (sc->data[SC_PARALYSE])
+ bonus -= 10;
+ if (sc->data[SC__BODYPAINT])
+ bonus -= sc->data[SC__BODYPAINT]->val1;
+ if (sc->data[SC__INVISIBILITY])
+ bonus -= sc->data[SC__INVISIBILITY]->val2 ;
+ if (sc->data[SC__GROOMY])
+ bonus -= sc->data[SC__GROOMY]->val2;
+ if (sc->data[SC_GLOOMYDAY])
+ bonus -= (15 + 5 * sc->data[SC_GLOOMYDAY]->val1);
+ if (sc->data[SC_EARTHDRIVE])
+ bonus -= 25;
+ if (sc->data[SC_MELON_BOMB])
+ bonus -= sc->data[SC_MELON_BOMB]->val1;
+ if (sc->data[SC_PAIN_KILLER])
+ bonus -= sc->data[SC_PAIN_KILLER]->val2;
+
+ if (sc->data[SC_SWING]) // TODO: SC_SWING shouldn't stack with skill1 modifiers
+ bonus += sc->data[SC_SWING]->val3;
+ if (sc->data[SC_DANCE_WITH_WUG])
+ bonus += sc->data[SC_DANCE_WITH_WUG]->val3;
+ if (sc->data[SC_GENTLETOUCH_CHANGE])
+ bonus += sc->data[SC_GENTLETOUCH_CHANGE]->val3;
+ if (sc->data[SC_BOOST500])
+ bonus += sc->data[SC_BOOST500]->val1;
+ if (sc->data[SC_EXTRACT_SALAMINE_JUICE])
+ bonus += sc->data[SC_EXTRACT_SALAMINE_JUICE]->val1;
+ if (sc->data[SC_INCASPDRATE])
+ bonus += sc->data[SC_INCASPDRATE]->val1;
+ if (sc->data[SC_GS_GATLINGFEVER])
+ bonus += sc->data[SC_GS_GATLINGFEVER]->val1;
+ if (sc->data[SC_STAR_COMFORT])
+ bonus += 3 * sc->data[SC_STAR_COMFORT]->val1;
+ }
+
+ return (bonus + pots);
#else
return 0;
#endif
@@ -5500,7 +5558,7 @@ short status_calc_fix_aspd(struct block_list *bl, struct status_change *sc, int
aspd -= 10;
if (sc->data[SC_OVERED_BOOST]) // should be final and unmodifiable by any means
- aspd = 2000 - sc->data[SC_OVERED_BOOST]->val3 * 10;
+ aspd = (200 - sc->data[SC_OVERED_BOOST]->val3) * 10;
return cap_value(aspd, 0, 2000); // will be recap for proper bl anyway
}
@@ -5569,6 +5627,7 @@ short status_calc_aspd_rate(struct block_list *bl, struct status_change *sc, int
max = sc->data[SC_ASSNCROS]->val2;
}
}
+
aspd_rate -= max;
if(sc->data[SC_BERSERK])
@@ -5668,6 +5727,8 @@ unsigned int status_calc_maxhp(struct block_list *bl, struct status_change *sc,
maxhp += maxhp * sc->data[SC_INCMHPRATE]->val1/100;
if(sc->data[SC_INCMHP])
maxhp += (sc->data[SC_INCMHP]->val1);
+ if(sc->data[SC_MTF_MHP])
+ maxhp += (sc->data[SC_MTF_MHP]->val1);
if(sc->data[SC_APPLEIDUN])
maxhp += maxhp * sc->data[SC_APPLEIDUN]->val2/100;
if(sc->data[SC_DELUGE])
@@ -5735,6 +5796,8 @@ unsigned int status_calc_maxsp(struct block_list *bl, struct status_change *sc,
maxsp += maxsp * sc->data[SC_INCMSPRATE]->val1/100;
if(sc->data[SC_INCMSP])
maxsp += (sc->data[SC_INCMSP]->val1);
+ if(sc->data[SC_MTF_MSP])
+ maxsp += (sc->data[SC_MTF_MSP]->val1);
if(sc->data[SC_SERVICEFORYOU])
maxsp += maxsp * sc->data[SC_SERVICEFORYOU]->val2/100;
if(sc->data[SC_MER_SP])
@@ -5857,8 +5920,8 @@ const char* status_get_name(struct block_list *bl) {
/*==========================================
* Get the class of the current bl
* return
-* 0 = fail
-* class_id = success
+* 0 = fail
+* class_id = success
*------------------------------------------*/
int status_get_class(struct block_list *bl) {
nullpo_ret(bl);
@@ -5876,8 +5939,8 @@ int status_get_class(struct block_list *bl) {
/*==========================================
* Get the base level of the current bl
* return
-* 1 = fail
-* level = success
+* 1 = fail
+* level = success
*------------------------------------------*/
int status_get_lv(struct block_list *bl) {
nullpo_ret(bl);
@@ -5983,7 +6046,9 @@ int status_get_party_id(struct block_list *bl) {
return ((TBL_MER*)bl)->master->status.party_id;
break;
case BL_SKILL:
- return ((TBL_SKILL*)bl)->group->party_id;
+ if (((TBL_SKILL*)bl)->group)
+ return ((TBL_SKILL*)bl)->group->party_id;
+ break;
case BL_ELEM:
if (((TBL_ELEM*)bl)->master)
return ((TBL_ELEM*)bl)->master->status.party_id;
@@ -6026,7 +6091,9 @@ int status_get_guild_id(struct block_list *bl) {
return ((TBL_NPC*)bl)->u.scr.guild_id;
break;
case BL_SKILL:
- return ((TBL_SKILL*)bl)->group->guild_id;
+ if (((TBL_SKILL*)bl)->group)
+ return ((TBL_SKILL*)bl)->group->guild_id;
+ break;
case BL_ELEM:
if (((TBL_ELEM*)bl)->master)
return ((TBL_ELEM*)bl)->master->status.guild_id;
@@ -6047,7 +6114,7 @@ int status_get_emblem_id(struct block_list *bl) {
case BL_MOB: {
struct map_session_data *msd;
struct mob_data *md = (struct mob_data *)bl;
- if (md->guardian_data) //Guardian's guild [Skotlex]
+ if (md->guardian_data) //Guardian's guild [Skotlex]
return (md->guardian_data->g) ? md->guardian_data->g->emblem_id:0;
if (md->special_state.ai && (msd = map->id2sd(md->master_id)) != NULL)
return msd->guild_emblem_id; //Alchemist's mobs [Skotlex]
@@ -6148,8 +6215,9 @@ void status_set_viewdata(struct block_list *bl, int class_)
{
TBL_PC* sd = (TBL_PC*)bl;
if (pcdb_checkid(class_)) {
- if (sd->sc.option&OPTION_RIDING) {
- switch (class_) { //Adapt class to a Mounted one.
+ if (pc_isridingpeco(sd)) {
+ switch (class_) {
+ //Adapt class to a Mounted one.
case JOB_KNIGHT:
class_ = JOB_KNIGHT2;
break;
@@ -6234,7 +6302,7 @@ void status_set_viewdata(struct block_list *bl, int class_)
ShowError("status_set_viewdata (NPC): No view data for class %d\n", class_);
}
break;
- case BL_HOM: //[blackhole89]
+ case BL_HOM: //[blackhole89]
{
struct homun_data *hd = (struct homun_data*)bl;
if (vd)
@@ -6285,36 +6353,33 @@ void status_change_init(struct block_list *bl) {
memset(sc, 0, sizeof (struct status_change));
}
-//Applies SC defense to a given status change.
-//Returns the adjusted duration based on flag values.
-//the flag values are the same as in status->change_start.
+/**
+ * Applies SC defense to a given status change.
+ *
+ * @see status_change_start for the expected parameters.
+ * @return the adjusted duration based on flag values.
+ */
int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_type type, int rate, int tick, int flag) {
//Percentual resistance: 10000 = 100% Resist
//Example: 50% -> sc_def=5000 -> 25%; 5000ms -> tick_def=5000 -> 2500ms
int sc_def = 0, tick_def = -1; //-1 = use sc_def
//Linear resistance substracted from rate and tick after percentual resistance was applied
//Example: 25% -> sc_def2=2000 -> 5%; 2500ms -> tick_def2=2000 -> 500ms
- int sc_def2 = 0, tick_def2 = -1; //-1 = use sc_def2 (pre-re only)
+ int sc_def2 = 0, tick_def2 = 0;
- struct status_data *st;
+ struct status_data *st, *bst;
struct status_change *sc;
struct map_session_data *sd;
nullpo_ret(bl);
-
+
if(!src)
return tick ? tick : 1; // If no source, it can't be resisted (NPC given)
/// Returns the 'bl's level, capped to 'cap'
#define SCDEF_LVL_CAP(bl, cap) ( (bl) ? (status->get_lv(bl) > (cap) ? (cap) : status->get_lv(bl)) : 0 )
-/// Renewal level modifier.
-/// In renewal, returns the difference between the levels of 'bl' and 'src', both capped to 'maxlv', multiplied by 'factor'
-/// In pre-renewal, returns zero.
-#ifdef RENEWAL
+/// returns the difference between the levels of 'bl' and 'src', both capped to 'maxlv', multiplied by 'factor'
#define SCDEF_LVL_DIFF(bl, src, maxlv, factor) ( ( SCDEF_LVL_CAP((bl), (maxlv)) - SCDEF_LVL_CAP((src), (maxlv)) ) * (factor) )
-#else
-#define SCDEF_LVL_DIFF(bl, src, maxlv, factor) 0
-#endif
//Status that are blocked by Golden Thief Bug card or Wand of Hermod
if (status->isimmune(bl))
@@ -6342,17 +6407,12 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
case SC_QUAGMIRE:
case SC_NJ_SUITON:
case SC_SWING:
- case SC__ENERVATION:
- case SC__GROOMY:
- case SC__IGNORANCE:
- case SC__LAZINESS:
- case SC__UNLUCKY:
- case SC__WEAKNESS:
return 0;
}
sd = BL_CAST(BL_PC,bl);
st = status->get_status_data(bl);
+ bst = status->get_base_status(bl);
sc = status->get_sc(bl);
if( sc && !sc->count )
sc = NULL;
@@ -6386,15 +6446,12 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
case SC_STUN:
sc_def = st->vit*100;
sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(bl, src, 99, 10);
-#ifdef RENEWAL
tick_def2 = st->luk*10;
-#endif
break;
case SC_POISON:
case SC_DPOISON:
sc_def = st->vit*100;
sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(bl, src, 99, 10);
-#ifdef RENEWAL
if (sd) {
//For players: 60000 - 450*vit - 100*luk
tick_def = st->vit*75;
@@ -6404,38 +6461,40 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
tick>>=1;
tick_def = (st->vit*200)/3;
}
-#endif
break;
case SC_SILENCE:
#ifdef RENEWAL
sc_def = st->int_*100;
sc_def2 = (st->vit + st->luk) * 5 + SCDEF_LVL_DIFF(bl, src, 99, 10);
- tick_def2 = st->luk * 10;
#else
sc_def = st->vit*100;
sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(bl, src, 99, 10);
#endif
+ tick_def2 = st->luk * 10;
break;
case SC_BLOODING:
#ifdef RENEWAL
sc_def = st->agi*100;
- tick_def2 = st->luk*10;
#else
sc_def = st->vit*100;
#endif
sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(bl, src, 99, 10);
+ tick_def2 = st->luk*10;
break;
case SC_SLEEP:
+#ifdef RENEWAL
+ sc_def = st->agi*100;
+ sc_def2 = (st->int_ + st->luk) * 5 + SCDEF_LVL_DIFF(bl, src, 99, 10);
+#else
sc_def = st->int_*100;
sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(bl, src, 99, 10);
-#ifdef RENEWAL
- tick_def2 = st->luk*10;
#endif
+ tick_def2 = st->luk*10;
break;
case SC_DEEP_SLEEP:
- sc_def = st->int_*50;
+ sc_def = bst->int_*50;
tick_def = 0; // Linear reduction instead
- tick_def2 = st->int_ * 50 + SCDEF_LVL_CAP(bl, 150) * 50; // kRO balance update lists this formula
+ tick_def2 = bst->int_ * 50 + SCDEF_LVL_CAP(bl, 150) * 50; // kRO balance update lists this formula
break;
case SC_DEC_AGI:
case SC_ADORAMUS:
@@ -6443,7 +6502,6 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
sc_def = st->mdef*100;
#ifndef RENEWAL
sc_def2 = st->luk*10;
- tick_def2 = 0; //No duration reduction
#endif
tick_def = 0; //No duration reduction
break;
@@ -6451,50 +6509,30 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
sc_def = st->mdef*100;
sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(bl, src, 99, 10);
tick_def = 0; //No duration reduction
-#ifndef RENEWAL
- tick_def2 = 0; //No duration reduction
-#endif
break;
case SC_FREEZE:
sc_def = st->mdef*100;
sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(bl, src, 99, 10);
- tick_def = 0; //No duration reduction
-#ifdef RENEWAL
tick_def2 = status_get_luk(src) * -10; //Caster can increase final duration with luk
-#else
- tick_def2 = 0; //No duration reduction
-#endif
break;
case SC_CURSE:
// Special property: immunity when luk is zero
if (st->luk == 0)
return 0;
-#ifndef RENEWAL
- // Special property: immunity when luk is greater than level
- if (st->luk > status->get_lv(bl))
- return 0;
-#endif
sc_def = st->luk*100;
sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(NULL, src, 99, 10); // Curse only has a level penalty and no resistance
tick_def = st->vit*100;
-#ifdef RENEWAL
tick_def2 = st->luk*10;
-#endif
break;
case SC_BLIND:
sc_def = (st->vit + st->int_)*50;
sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(bl, src, 99, 10);
-#ifdef RENEWAL
tick_def2 = st->luk*10;
-#endif
break;
case SC_CONFUSION:
sc_def = (st->str + st->int_)*50;
sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(bl, src, 99, 10);
-#ifdef RENEWAL
- sc_def2 = -sc_def2; // Reversed sc_def2
tick_def2 = st->luk*10;
-#endif
break;
case SC_ANKLESNARE:
if(st->mode&MD_BOSS) // Lasts 5 times less on bosses
@@ -6506,7 +6544,6 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
if (sd) //Duration greatly reduced for players.
tick /= 15;
sc_def2 = st->vit*25 + st->agi*10 + SCDEF_LVL_CAP(bl, 99) * 20; // Linear Reduction of Rate
- tick_def2 = 0; //No duration reduction
break;
case SC_MARSHOFABYSS:
//5 second (Fixed) + 25 second - {( INT + LUK ) / 20 second }
@@ -6548,10 +6585,10 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
tick_def2 = (st->vit + st->agi) * 70;
break;
case SC_COLD:
- tick_def2 = st->vit*100 + status->get_lv(bl)*20;
+ tick_def2 = bst->vit*100 + status->get_lv(bl)*20;
break;
case SC_VACUUM_EXTREME:
- tick_def2 = st->str*50;
+ tick_def2 = bst->str*50;
break;
case SC_MANDRAGORA:
sc_def = (st->vit + st->luk)*20;
@@ -6559,9 +6596,6 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
case SC_SIREN:
tick_def2 = (status->get_lv(bl) * 100) + ((bl->type == BL_PC)?((TBL_PC*)bl)->status.job_level : 0);
break;
- case SC_KYOUGAKU:
- tick_def2 = st->int_ * 50;
- break;
case SC_NEEDLE_OF_PARALYZE:
tick_def2 = (st->vit + st->luk) * 50;
break;
@@ -6612,16 +6646,9 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
//When tick def not set, reduction is the same for both.
if(tick_def == -1)
tick_def = sc_def;
- if(tick_def2 == -1) {
-#ifdef RENEWAL
- tick_def2 = 0;
-#else
- tick_def2 = sc_def2;
-#endif
- }
//Natural resistance
- if (!(flag&8)) {
+ if (!(flag&SCFLAG_FIXEDRATE)) {
rate -= rate*sc_def/10000;
rate -= sc_def2;
@@ -6655,7 +6682,7 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
if (tick < 1) return 1;
//Rate reduction
- if (flag&2)
+ if (flag&SCFLAG_FIXEDTICK)
return tick;
tick -= tick*tick_def/10000;
@@ -6687,19 +6714,19 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
void status_display_add(struct map_session_data *sd, enum sc_type type, int dval1, int dval2, int dval3) {
struct sc_display_entry *entry;
int i;
-
+
for( i = 0; i < sd->sc_display_count; i++ ) {
if( sd->sc_display[i]->type == type )
break;
}
-
+
if( i != sd->sc_display_count ) {
sd->sc_display[i]->val1 = dval1;
sd->sc_display[i]->val2 = dval2;
sd->sc_display[i]->val3 = dval3;
return;
}
-
+
entry = ers_alloc(pc->sc_display_ers, struct sc_display_entry);
entry->type = type;
@@ -6742,17 +6769,23 @@ void status_display_remove(struct map_session_data *sd, enum sc_type type) {
}
}
}
-/*==========================================
-* Starts a status change.
-* 'type' = type, 'val1~4' depend on the type.
-* 'rate' = base success rate. 10000 = 100%
-* 'tick' is base duration
-* 'flag':
-* &1: Cannot be avoided (it has to start)
-* &2: Tick should not be reduced (by vit, luk, lv, etc)
-* &4: sc_data loaded, no value has to be altered.
-* &8: rate should not be reduced
-*------------------------------------------*/
+/**
+ * Starts a status change.
+ *
+ * @param src Status change source bl.
+ * @param bl Status change target bl.
+ * @param type Status change type.
+ * @param rate Base success rate. 1 means 0.01%, 10000 means 100%.
+ * @param val1 Additional value (meaning depends on type).
+ * @param val2 Additional value (meaning depends on type).
+ * @param val3 Additional value (meaning depends on type).
+ * @param val4 Additional value (meaning depends on type).
+ * @param tick Base duration (milliseconds).
+ * @param flag Special flags (@see enum scstart_flag).
+ *
+ * @retval 0 if no status change happened.
+ * @retval 1 if the status change was successfully applied.
+ */
int status_change_start(struct block_list *src, struct block_list *bl, enum sc_type type, int rate, int val1, int val2, int val3, int val4, int tick, int flag) {
struct map_session_data *sd = NULL;
struct status_change* sc;
@@ -6780,8 +6813,10 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
struct mob_data *md = BL_CAST(BL_MOB,bl);
if(md && (md->class_ == MOBID_EMPERIUM || mob_is_battleground(md)) && type != SC_SAFETYWALL && type != SC_PNEUMA)
return 0; //Emperium/BG Monsters can't be afflicted by status changes
- //if(md && mob_is_gvg(md) && status->sc2scb_flag(type)&SCB_MAXHP)
- // return 0; //prevent status addinh hp to gvg mob (like bloodylust=hp*3 etc...
+#if 0
+ if(md && mob_is_gvg(md) && status->sc2scb_flag(type)&SCB_MAXHP)
+ return 0; //prevent status addinh hp to gvg mob (like bloodylust=hp*3 etc...
+#endif // 0
}
if( sc->data[SC_REFRESH] ) {
@@ -6855,7 +6890,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
sd = BL_CAST(BL_PC, bl);
//Adjust tick according to status resistances
- if( !(flag&(1|4)) ) {
+ if( !(flag&(SCFLAG_NOAVOID|SCFLAG_LOADED)) ) {
tick = status->get_sc_def(src, bl, type, rate, tick, flag);
if( !tick ) return 0;
}
@@ -6877,7 +6912,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
)
return 0;
case SC_VACUUM_EXTREME:
- if(sc->data[SC_HALLUCINATIONWALK] || sc->data[SC_HOVERING])
+ if(sc->data[SC_HALLUCINATIONWALK])
return 0;
break;
case SC_STONE:
@@ -6885,7 +6920,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
return 0;
case SC_FREEZE:
//Undead are immune to Freeze/Stone
- if (undead_flag && !(flag&1))
+ if (undead_flag && !(flag&SCFLAG_NOAVOID))
return 0;
case SC_SLEEP:
case SC_STUN:
@@ -6926,7 +6961,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
return 0; //Overthrust can't take effect if under Max Overthrust. [Skotlex]
case SC_OVERTHRUSTMAX:
if( sc->option&OPTION_MADOGEAR )
- return 0;//Overthrust and Overthrust Max cannot be used on Mado Gear [Ind]
+ return 0; //Overthrust and Overthrust Max cannot be used on Mado Gear [Ind]
break;
case SC_ADRENALINE:
if(sd && !pc_check_weapontype(sd,skill->get_weapontype(BS_ADRENALINE)))
@@ -6962,7 +6997,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
case SC_CARTBOOST:
case SC_ASSNCROS:
if(sc->option&OPTION_MADOGEAR)
- return 0;//Mado is immune to wind walk, cart boost, etc (others above) [Ind]
+ return 0; //Mado is immune to wind walk, cart boost, etc (others above) [Ind]
case SC_INC_AGI:
if (sc->data[SC_QUAGMIRE])
return 0;
@@ -6994,7 +7029,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
break;
//Strip skills, need to divest something or it fails.
case SC_NOEQUIPWEAPON:
- if (sd && !(flag&4)) { //apply sc anyway if loading saved sc_data
+ if (sd && !(flag&SCFLAG_LOADED)) { //apply sc anyway if loading saved sc_data
int i;
opt_flag = 0; //Reuse to check success condition.
if(sd->bonus.unstripable_equip&EQP_WEAPON)
@@ -7012,7 +7047,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
case SC_NOEQUIPSHIELD:
if( val2 == 1 ) val2 = 0; //GX effect. Do not take shield off..
else
- if (sd && !(flag&4)) {
+ if (sd && !(flag&SCFLAG_LOADED)) {
int i;
if(sd->bonus.unstripable_equip&EQP_SHIELD)
return 0;
@@ -7024,7 +7059,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
break;
case SC_NOEQUIPARMOR:
- if (sd && !(flag&4)) {
+ if (sd && !(flag&SCFLAG_LOADED)) {
int i;
if(sd->bonus.unstripable_equip&EQP_ARMOR)
return 0;
@@ -7036,7 +7071,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
break;
case SC_NOEQUIPHELM:
- if (sd && !(flag&4)) {
+ if (sd && !(flag&SCFLAG_LOADED)) {
int i;
if(sd->bonus.unstripable_equip&EQP_HELM)
return 0;
@@ -7135,7 +7170,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
{ // it doesn't stack or even renewed
int i = SC_TOXIN;
for(; i<= SC_LEECHESEND; i++)
- if(sc->data[i]) return 0;
+ if(sc->data[i]) return 0;
}
break;
case SC_MAGNETICFIELD:
@@ -7149,7 +7184,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
}
//Check for BOSS resistances
- if(st->mode&MD_BOSS && !(flag&1)) {
+ if(st->mode&MD_BOSS && !(flag&SCFLAG_NOAVOID)) {
if (type>=SC_COMMON_MIN && type <= SC_COMMON_MAX)
return 0;
switch (type) {
@@ -7210,9 +7245,13 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
if (sc->data[SC_STONE] && sc->opt1 == OPT1_STONE)
status_change_end(bl, SC_STONE, INVALID_TIMER);
}
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH)
+ status_change_end(bl, SC_SOULLINK, INVALID_TIMER);
break;
case SC_INC_AGI:
status_change_end(bl, SC_DEC_AGI, INVALID_TIMER);
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH)
+ status_change_end(bl, SC_SOULLINK, INVALID_TIMER);
break;
case SC_QUAGMIRE:
status_change_end(bl, SC_CONCENTRATION, INVALID_TIMER);
@@ -7285,8 +7324,8 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
status_change_end(bl, SC_ASSUMPTIO, INVALID_TIMER);
break;
case SC_CARTBOOST:
- if(sc->data[SC_DEC_AGI] || sc->data[SC_ADORAMUS])
- { //Cancel Decrease Agi, but take no further effect [Skotlex]
+ if (sc->data[SC_DEC_AGI] || sc->data[SC_ADORAMUS]) {
+ //Cancel Decrease Agi, but take no further effect [Skotlex]
status_change_end(bl, SC_DEC_AGI, INVALID_TIMER);
status_change_end(bl, SC_ADORAMUS, INVALID_TIMER);
return 0;
@@ -7547,7 +7586,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
vd = status->get_viewdata(bl);
calc_flag = status->ChangeFlagTable[type];
- if(!(flag&4)) { //&4 - Do not parse val settings when loading SCs
+ if(!(flag&SCFLAG_LOADED)) { // Do not parse val settings when loading SCs
switch(type) {
case SC_ADORAMUS:
sc_start(src,bl,SC_BLIND,100,val1,skill->get_time(status->sc2skill(type),val1));
@@ -7558,16 +7597,16 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
break;
case SC_ENDURE:
val2 = 7; // Hit-count [Celest]
- if( !(flag&1) && (bl->type&(BL_PC|BL_MER)) && !map_flag_gvg(bl->m) && !map->list[bl->m].flag.battleground && !val4 ) {
+ if( !(flag&SCFLAG_NOAVOID) && (bl->type&(BL_PC|BL_MER)) && !map_flag_gvg(bl->m) && !map->list[bl->m].flag.battleground && !val4 ) {
struct map_session_data *tsd;
if( sd ) {
int i;
for( i = 0; i < 5; i++ ) {
if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) )
- status->change_start(bl, &tsd->bl, type, 10000, val1, val2, val3, val4, tick, 1);
+ status->change_start(bl, &tsd->bl, type, 10000, val1, val2, val3, val4, tick, SCFLAG_ALL);
}
} else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) )
- status->change_start(bl, &tsd->bl, type, 10000, val1, val2, val3, val4, tick, 1);
+ status->change_start(bl, &tsd->bl, type, 10000, val1, val2, val3, val4, tick, SCFLAG_ALL);
}
//val4 signals infinite endure (if val4 == 2 it is infinite endure from Berserk)
if( val4 )
@@ -7588,7 +7627,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
tick_time = val2 = tick>0?tick:60000;
tick = -1; // duration sent to the client should be infinite
break;
- case SC_EDP: // [Celest]
+ case SC_EDP: // [Celest]
val2 = val1 + 2; //Chance to Poison enemies.
val3 = 50*(val1+1); //Damage increase (+50 +50*lv%)
#ifdef RENEWAL_EDP
@@ -7628,7 +7667,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
tick = -1;
break;
case SC_ENCHANTPOISON:
- val2= 250+50*val1; //Poisoning Chance (2.5+0.5%) in 1/10000 rate
+ val2= 250+50*val1; //Poisoning Chance (2.5+0.5%) in 1/10000 rate
case SC_ASPERSIO:
case SC_PROPERTYFIRE:
case SC_PROPERTYWATER:
@@ -7655,16 +7694,16 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
break;
case SC_REFLECTSHIELD:
val2=10+val1*3; // %Dmg reflected
- if( !(flag&1) && (bl->type&(BL_PC|BL_MER)) ) {
+ if( !(flag&SCFLAG_NOAVOID) && (bl->type&(BL_PC|BL_MER)) ) {
struct map_session_data *tsd;
if( sd ) {
int i;
for( i = 0; i < 5; i++ ) {
if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) )
- status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1);
+ status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL);
}
} else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) )
- status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1);
+ status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL);
}
break;
case SC_NOEQUIPWEAPON:
@@ -7877,17 +7916,17 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
//val4&1 signals the presence of a wall.
//val4&2 makes cloak not end on normal attacks [Skotlex]
//val4&4 makes cloak not end on using skills
- if (bl->type == BL_PC || (bl->type == BL_MOB && ((TBL_MOB*)bl)->special_state.clone) ) //Standard cloaking.
+ if (bl->type == BL_PC || (bl->type == BL_MOB && ((TBL_MOB*)bl)->special_state.clone) ) //Standard cloaking.
val4 |= battle_config.pc_cloak_check_type&7;
else
val4 |= battle_config.monster_cloak_check_type&7;
break;
- case SC_SIGHT: /* splash status */
+ case SC_SIGHT: /* splash status */
case SC_RUWACH:
case SC_WZ_SIGHTBLASTER:
val3 = skill->get_splash(val2, val1); //Val2 should bring the skill-id.
- val2 = tick/250;
- tick_time = 10; // [GodLesZ] tick time
+ val2 = tick/20;
+ tick_time = 20; // [GodLesZ] tick time
break;
//Permanent effects.
@@ -7907,7 +7946,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
break;
case SC_AUTOGUARD:
- if( !(flag&1) ) {
+ if( !(flag&SCFLAG_NOAVOID) ) {
struct map_session_data *tsd;
int i,t;
for( i = val2 = 0; i < val1; i++) {
@@ -7919,17 +7958,17 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
if( sd ) {
for( i = 0; i < 5; i++ ) {
if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) )
- status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1);
+ status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL);
}
}
else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) )
- status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1);
+ status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL);
}
}
break;
case SC_DEFENDER:
- if (!(flag&1)) {
+ if (!(flag&SCFLAG_NOAVOID)) {
val2 = 5 + 15*val1; //Damage reduction
val3 = 0; // unused, previously speed adjustment
val4 = 250 - 50*val1; //Aspd adjustment
@@ -7940,7 +7979,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
for (i = 0; i < 5; i++) {
//See if there are devoted characters, and pass the status to them. [Skotlex]
if (sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])))
- status->change_start(bl, &tsd->bl,type,10000,val1,5+val1*5,val3,val4,tick,1);
+ status->change_start(bl, &tsd->bl,type,10000,val1,5+val1*5,val3,val4,tick,SCFLAG_NOAVOID);
}
}
}
@@ -8030,6 +8069,23 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
stat = (psce->val4 >> 0)&0xFF; stat = min(stat, max_stat - tst->luk ); val4 |= cap_value(stat,0,0xFF);
}
break;
+ case SC_SOULLINK:
+ //1st Transcendent Spirit works similar to Marionette Control
+ if(sd && val2 == SL_HIGH) {
+ int stat,max_stat;
+ // Fetch target's stats
+ struct status_data* status2 = status->get_status_data(bl); // Battle status
+ val3 = 0;
+ val4 = 0;
+ max_stat = (status->get_lv(bl)-10<50)?status->get_lv(bl)-10:50;
+ stat = max(0, max_stat - status2->str ); val3 |= cap_value(stat,0,0xFF)<<16;
+ stat = max(0, max_stat - status2->agi ); val3 |= cap_value(stat,0,0xFF)<<8;
+ stat = max(0, max_stat - status2->vit ); val3 |= cap_value(stat,0,0xFF);
+ stat = max(0, max_stat - status2->int_); val4 |= cap_value(stat,0,0xFF)<<16;
+ stat = max(0, max_stat - status2->dex ); val4 |= cap_value(stat,0,0xFF)<<8;
+ stat = max(0, max_stat - status2->luk ); val4 |= cap_value(stat,0,0xFF);
+ }
+ break;
case SC_SWORDREJECT:
val2 = 15*val1; //Reflect chance
val3 = 3; //Reflections
@@ -8067,7 +8123,9 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
while( i >= 0 ) {
type2 = types[i];
if( d_sc->data[type2] )
- sc_start(bl, bl, type2, 100, d_sc->data[type2]->val1, skill->get_time(status->sc2skill(type2),d_sc->data[type2]->val1));
+ status->change_start(bl, bl, type2, 10000, d_sc->data[type2]->val1, 0, 0, 0,
+ skill->get_time(status->sc2skill(type2),d_sc->data[type2]->val1),
+ (type2 != SC_DEFENDER) ? SCFLAG_NOICON : SCFLAG_NONE);
i--;
}
}
@@ -8154,7 +8212,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
case SC_KAAHI:
val2 = 200*val1; //HP heal
val3 = 5*val1; //SP cost
- val4 = INVALID_TIMER; //Kaahi Timer.
+ val4 = INVALID_TIMER; //Kaahi Timer.
break;
case SC_BLESSING:
if ((!undead_flag && st->race!=RC_DEMON) || bl->type == BL_PC)
@@ -8290,7 +8348,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
//2. Set restore point (val3 -> return map, val4 return coords
val3 = map_index;
val4 = pos;
- } else if (!val3
+ } else if (!val3
|| val3 == sd->mapindex
|| !sd->sc.data[SC_JAILED] // If player is being jailed and is already in jail (issue: 8206)
) { //Use save point.
@@ -8344,11 +8402,12 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
break;
case SC_STONESKIN:
- if (val2 == NPC_ANTIMAGIC)
- { //Boost mdef
+ if (val2 == NPC_ANTIMAGIC) {
+ //Boost mdef
val2 =-20;
val3 = 20;
- } else { //Boost def
+ } else {
+ //Boost def
val2 = 20;
val3 =-20;
}
@@ -8466,7 +8525,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
tick_time = 4000; // [GodLesZ] tick time
break;
case SC_PYREXIA:
- status->change_start(src, bl,SC_BLIND,10000,val1,0,0,0,30000,11); // Blind status that last for 30 seconds
+ status->change_start(src, bl,SC_BLIND,10000,val1,0,0,0,30000,SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE); // Blind status that last for 30 seconds
val4 = tick / 3000;
tick_time = 3000; // [GodLesZ] tick time
break;
@@ -8578,20 +8637,33 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
break;
case SC__ENERVATION:
val2 = 20 + 10 * val1; // ATK Reduction
- if( sd ) pc->delspiritball(sd,sd->spiritball,0);
+ if ( sd ) {
+ int i;
+ pc->delspiritball(sd, sd->spiritball, 0);
+ for (i = SPIRITS_TYPE_CHARM_WATER; i < SPIRITS_TYPE_SPHERE; i++)
+ pc->del_charm(sd, sd->spiritcharm[i], i);
+ }
break;
case SC__GROOMY:
val2 = 20 + 10 * val1; //ASPD. Need to confirm if Movement Speed reduction is the same. [Jobbie]
val3 = 20 * val1; //HIT
if( sd ) { // Removes Animals
- if( pc_isriding(sd) ) pc->setriding(sd, 0);
- if( pc_isridingdragon(sd) ) pc->setoption(sd, sd->sc.option&~OPTION_DRAGON);
- if( pc_iswug(sd) ) pc->setoption(sd, sd->sc.option&~OPTION_WUG);
- if( pc_isridingwug(sd) ) pc->setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
- if( pc_isfalcon(sd) ) pc->setoption(sd, sd->sc.option&~OPTION_FALCON);
- if( sd->status.pet_id > 0 ) pet->menu(sd, 3);
- if( homun_alive(sd->hd) ) homun->vaporize(sd,HOM_ST_REST);
- if( sd->md ) mercenary->delete(sd->md,3);
+ if (pc_isridingpeco(sd))
+ pc->setridingpeco(sd, false);
+ if (pc_isridingdragon(sd))
+ pc->setridingdragon(sd, 0);
+ if (pc_iswug(sd))
+ pc->setoption(sd, sd->sc.option&~OPTION_WUG);
+ if (pc_isridingwug(sd))
+ pc->setridingwug(sd, false);
+ if (pc_isfalcon(sd))
+ pc->setfalcon(sd, false);
+ if (sd->status.pet_id > 0)
+ pet->menu(sd, 3);
+ if (homun_alive(sd->hd))
+ homun->vaporize(sd,HOM_ST_REST);
+ if (sd->md)
+ mercenary->delete(sd->md,3);
}
break;
case SC__LAZINESS:
@@ -8688,8 +8760,10 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
if ( !val3 )
val3 = 50;
if( sd ) {
- if( pc_isriding(sd) ) pc->setriding(sd, 0);
- if( pc_isridingdragon(sd) ) pc->setoption(sd, sd->sc.option&~OPTION_DRAGON);
+ if (pc_isridingpeco(sd))
+ pc->setridingpeco(sd, false);
+ if (pc_isridingdragon(sd))
+ pc->setridingdragon(sd, false);
}
}
break;
@@ -8785,18 +8859,16 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
struct block_list * src2;
val3 = st->agi * val1 / 60; // ASPD increase: [(Target AGI x Skill Level) / 60] %
if( (src2 = map->id2bl(val2)) ){
- val4 = ( 200/status_get_int(src2) ) * val1;// MDEF decrease: MDEF [(200 / Caster INT) x Skill Level]
+ val4 = ( 200/(status_get_int(src2)?status_get_int(src2):1) ) * val1;// MDEF decrease: MDEF [(200 / Caster INT) x Skill Level]
val2 = ( status_get_dex(src2)/4 + status_get_str(src2)/2 ) * val1 / 5; // ATK increase: ATK [{(Caster DEX / 4) + (Caster STR / 2)} x Skill Level / 5]
}
}
break;
case SC_GENTLETOUCH_REVITALIZE:
- {// take note there is no vit,aspd,speed increase as skill desc says. [malufett]
- struct block_list * src2;
- val3 = val1 * 30 + 150; // Natural HP recovery increase: [(Skill Level x 30) + 50] %
- if( (src2 = map->id2bl(val2)) ) // the stat def is not shown in the status window and it is process differently
- val4 = ( status_get_vit(src2)/4 ) * val1; // STAT DEF increase: [(Caster VIT / 4) x Skill Level]
- }
+ if(val2 < 0)
+ val2 = 0;
+ else
+ val2 = val2 / 4 * val1; // STAT DEF increase: [(Caster VIT / 4) x Skill Level]
break;
case SC_PYROTECHNIC_OPTION:
val2 = 60;
@@ -8804,7 +8876,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
case SC_HEATER_OPTION:
val2 = 120; // Watk. TODO: Renewal (Atk2)
val3 = (sd ? sd->status.job_level : 0); // % Increase damage.
- val4 = 3; // Change into fire element.
+ val4 = 3; // Change into fire element.
break;
case SC_TROPIC_OPTION:
val2 = 180; // Watk. TODO: Renewal (Atk2)
@@ -8814,16 +8886,16 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
val2 = 40;
break;
case SC_COOLER_OPTION:
- val2 = 80; // Bonus Matk
+ val2 = 80; // Bonus Matk
val3 = (sd ? sd->status.job_level : 0); // % Freezing chance
- val4 = 1; // Change into water elemet
+ val4 = 1; // Change into water elemet
break;
case SC_CHILLY_AIR_OPTION:
val2 = 120; // Matk. TODO: Renewal (Matk1)
val3 = MG_COLDBOLT;
break;
case SC_WIND_STEP_OPTION:
- val2 = 50; // % Increase speed and flee.
+ val2 = 50; // % Increase speed and flee.
break;
case SC_BLAST_OPTION:
val2 = (sd ? sd->status.job_level : 0); // % Increase damage
@@ -8855,7 +8927,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
case SC_WATER_DROP_OPTION:
case SC_WIND_CURTAIN_OPTION:
case SC_STONE_SHIELD_OPTION:
- val2 = 100; // Elemental modifier.
+ val2 = 100; // Elemental modifier.
break;
case SC_TROPIC:
case SC_CHILLY_AIR:
@@ -8887,10 +8959,10 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
tick_time = val3;
break;
case SC_WATER_BARRIER:
- val3 = 20; // Reductions. Atk2, Flee1
+ val3 = 20; // Reductions. Atk2, Flee1
break;
case SC_ZEPHYR:
- val2 = 25; // Flee.
+ val2 = 25; // Flee.
break;
case SC_TIDAL_WEAPON:
val2 = 20; // Increase Elemental's attack.
@@ -8905,13 +8977,17 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
val1 = 15;
break;
case SC_STOMACHACHE:
- val2 = 8; // SP consume.
+ val2 = 8; // SP consume.
val4 = tick / 10000;
tick_time = 10000; // [GodLesZ] tick time
break;
- case SC_KYOUGAKU:
- val2 = 2*val1 + rand()%(3 * val1);
- clif->status_change(bl, SI_ACTIVE_MONSTER_TRANSFORM, 1, 0, 1002, 0, 0); // Poring in disguise
+ case SC_KYOUGAKU: {
+ int min = val1*2;
+ int max = val1*3;
+ val3 = rnd()%(max-min)+min;
+ val2 = val1;
+ val1 = 1002; // Monster ID
+ }
break;
case SC_KAGEMUSYA:
val3 = val1 * 2;
@@ -9036,8 +9112,8 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
val2 = 20+(20*val1);
break;
default:
- if( calc_flag == SCB_NONE && status->SkillChangeTable[type] == 0 && status->IconChangeTable[type] == 0 )
- { //Status change with no calc, no icon, and no skill associated...?
+ if (calc_flag == SCB_NONE && status->SkillChangeTable[type] == 0 && status->IconChangeTable[type] == 0) {
+ //Status change with no calc, no icon, and no skill associated...?
ShowError("UnknownStatusChange [%d]\n", type);
return 0;
}
@@ -9058,13 +9134,10 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
case SC_KAAHI:
val4 = INVALID_TIMER;
break;
- case SC_KYOUGAKU:
- clif->status_change(bl, SI_ACTIVE_MONSTER_TRANSFORM, 1, 0, 1002, 0, 0); // Poring in disguise
- break;
}
}
- /* values that must be set regardless of flag&4 e.g. val_flag */
+ /* values that must be set regardless of SCFLAG_LOADED e.g. val_flag */
switch(type) {
case SC_FIGHTINGSPIRIT:
val_flag |= 1|2;
@@ -9181,6 +9254,9 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
case SC_WATER_BARRIER:
val_flag |= 1|2|4;
break;
+ case SC_KYOUGAKU:
+ val_flag |= 1;
+ break;
case SC_CASH_PLUSEXP:
case SC_CASH_PLUSONLYJOBEXP:
case SC_MONSTER_TRANSFORM:
@@ -9188,7 +9264,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
val_flag |= 1;
break;
}
-
+
/* [Ind/Hercules] */
if( sd && status->DisplayType[type] ) {
int dval1 = 0, dval2 = 0, dval3 = 0;
@@ -9239,7 +9315,6 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
case SC_CURSEDCIRCLE_TARGET:
case SC_FEAR:
case SC_MEIKYOUSISUI:
- case SC_KYOUGAKU:
case SC_NEEDLE_OF_PARALYZE:
case SC_DEATHBOUND:
unit->stop_walking(bl,1);
@@ -9293,13 +9368,13 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
opt_flag = 1;
switch(type) {
//OPT1
- case SC_STONE: sc->opt1 = OPT1_STONEWAIT; break;
- case SC_FREEZE: sc->opt1 = OPT1_FREEZE; break;
- case SC_STUN: sc->opt1 = OPT1_STUN; break;
- case SC_SLEEP: sc->opt1 = OPT1_SLEEP; break;
- case SC_BURNING: sc->opt1 = OPT1_BURNING; break; // Burning need this to be showed correctly. [pakpil]
- case SC_WHITEIMPRISON: sc->opt1 = OPT1_IMPRISON; break;
- case SC_COLD: sc->opt1 = OPT1_CRYSTALIZE; break;
+ case SC_STONE: sc->opt1 = OPT1_STONEWAIT; break;
+ case SC_FREEZE: sc->opt1 = OPT1_FREEZE; break;
+ case SC_STUN: sc->opt1 = OPT1_STUN; break;
+ case SC_SLEEP: sc->opt1 = OPT1_SLEEP; break;
+ case SC_BURNING: sc->opt1 = OPT1_BURNING; break; // Burning need this to be showed correctly. [pakpil]
+ case SC_WHITEIMPRISON: sc->opt1 = OPT1_IMPRISON; break;
+ case SC_COLD: sc->opt1 = OPT1_CRYSTALIZE; break;
//OPT2
case SC_POISON: sc->opt2 |= OPT2_POISON; break;
case SC_CURSE: sc->opt2 |= OPT2_CURSE; break;
@@ -9325,7 +9400,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
break;
case SC_OVERTHRUSTMAX:
case SC_OVERTHRUST:
- case SC_SWOO: //Why does it shares the same opt as Overthrust? Perhaps we'll never know...
+ case SC_SWOO: //Why does it shares the same opt as Overthrust? Perhaps we'll never know...
sc->opt3 |= OPT3_OVERTHRUST;
opt_flag = 0;
break;
@@ -9361,10 +9436,12 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
opt_flag = 0;
sc->opt3 |= OPT3_BERSERK;
break;
-// case ???: // doesn't seem to do anything
-// sc->opt3 |= OPT3_LIGHTBLADE;
-// opt_flag = 0;
-// break;
+#if 0
+ case ???: // doesn't seem to do anything
+ sc->opt3 |= OPT3_LIGHTBLADE;
+ opt_flag = 0;
+ break;
+#endif // 0
case SC_DANCING:
if ((val1&0xFFFF) == CG_MOONLIT)
sc->opt3 |= OPT3_MOONLIT;
@@ -9399,10 +9476,12 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
sc->opt3 |= OPT3_UNDEAD;
opt_flag = 0;
break;
-// case ???: // from DA_CONTRACT (looks like biolab mobs aura)
-// sc->opt3 |= OPT3_CONTRACT;
-// opt_flag = 0;
-// break;
+#if 0
+ case ???: // from DA_CONTRACT (looks like biolab mobs aura)
+ sc->opt3 |= OPT3_CONTRACT;
+ opt_flag = 0;
+ break;
+#endif // 0
//OPTION
case SC_HIDING:
sc->option |= OPTION_HIDE;
@@ -9468,7 +9547,8 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
clif->changelook(bl,LOOK_CLOTHES_COLOR,vd->cloth_color);
}
}
- if (calc_flag&SCB_DYE) { //Reset DYE color
+ if (calc_flag&SCB_DYE) {
+ //Reset DYE color
if (vd && vd->cloth_color) {
val4 = vd->cloth_color;
clif->changelook(bl,LOOK_CLOTHES_COLOR,0);
@@ -9476,7 +9556,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
calc_flag&=~SCB_DYE;
}
- if( !(flag&4 && status->DisplayType[type]) )
+ if(!(flag&SCFLAG_NOICON) && !(flag&SCFLAG_LOADED && status->DisplayType[type]))
clif->status_change(bl,status->IconChangeTable[type],1,tick,(val_flag&1)?val1:1,(val_flag&2)?val2:0,(val_flag&4)?val3:0);
/**
@@ -9670,7 +9750,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
#ifdef ANTI_MAYAP_CHEAT
bool invisible = false;
#endif
-
+
nullpo_ret(bl);
sc = status->get_sc(bl);
@@ -9686,7 +9766,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
if( sd && sce->timer == INVALID_TIMER && !sd->state.loggingout )
chrif->del_scdata_single(sd->status.account_id,sd->status.char_id,type);
-
+
if (tid == INVALID_TIMER) {
if (type == SC_ENDURE && sce->val4)
//Do not end infinite endure.
@@ -10132,9 +10212,6 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
}
}
break;
- case SC_KYOUGAKU:
- clif->sc_end(&sd->bl,sd->bl.id,AREA,SI_ACTIVE_MONSTER_TRANSFORM);
- break;
case SC_CLAIRVOYANCE:
calc_flag = SCB_ALL;/* required for overlapping */
break;
@@ -10312,10 +10389,12 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
opt_flag = 0;
sc->opt3 &= ~OPT3_BERSERK;
break;
- // case ???: // doesn't seem to do anything
- // sc->opt3 &= ~OPT3_LIGHTBLADE;
- // opt_flag = 0;
- // break;
+#if 0
+ case ???: // doesn't seem to do anything
+ sc->opt3 &= ~OPT3_LIGHTBLADE;
+ opt_flag = 0;
+ break;
+#endif // 0
case SC_DANCING:
if ((sce->val1&0xFFFF) == CG_MOONLIT)
sc->opt3 &= ~OPT3_MOONLIT;
@@ -10350,16 +10429,19 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
sc->opt3 &= ~OPT3_UNDEAD;
opt_flag = 0;
break;
- // case ???: // from DA_CONTRACT (looks like biolab mobs aura)
- // sc->opt3 &= ~OPT3_CONTRACT;
- // opt_flag = 0;
- // break;
+#if 0
+ case ???: // from DA_CONTRACT (looks like biolab mobs aura)
+ sc->opt3 &= ~OPT3_CONTRACT;
+ opt_flag = 0;
+ break;
+#endif // 0
default:
opt_flag = 0;
}
#ifdef ANTI_MAYAP_CHEAT
if (invisible && !(sc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_INVISIBLE))) {
+ clif->slide(bl, bl->x, bl->y);
clif->fixpos(bl);
}
#endif
@@ -10392,8 +10474,12 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
if(opt_flag&4) //Out of hiding, invoke on place.
skill->unit_move(bl,timer->gettick(),1);
- if(opt_flag&2 && sd && map->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC))
- npc->touch_areanpc(sd,bl->m,bl->x,bl->y); //Trigger on-touch event.
+ if (opt_flag & 2 && sd) {
+ if (map->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC))
+ npc->touch_areanpc(sd,bl->m,bl->x,bl->y); //Trigger on-touch event.
+ else
+ npc->untouch_areanpc(sd, bl->m, bl->x, bl->y);
+ }
ers_free(status->data_ers, sce);
return 1;
@@ -10515,14 +10601,17 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
case SC_SIGHT:
case SC_RUWACH:
case SC_WZ_SIGHTBLASTER:
- if(type == SC_WZ_SIGHTBLASTER)
+ if(type == SC_WZ_SIGHTBLASTER) {
+ //Restore trap immunity
+ if(sce->val4%2)
+ sce->val4--;
map->foreachinrange(status->change_timer_sub, bl, sce->val3, BL_CHAR|BL_SKILL, bl, sce, type, tick);
- else
+ } else
map->foreachinrange(status->change_timer_sub, bl, sce->val3, BL_CHAR, bl, sce, type, tick);
if( --(sce->val2)>0 ){
- sce->val4 += 250; // use for Shadow Form 2 seconds checking.
- sc_timer_next(250+tick, status->change_timer, bl->id, data);
+ sce->val4 += 20; // use for Shadow Form 2 seconds checking.
+ sc_timer_next(20+tick, status->change_timer, bl->id, data);
return 0;
}
break;
@@ -10584,10 +10673,11 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
case SC_KNOWLEDGE:
if (!sd) break;
- if(bl->m == sd->feel_map[0].m ||
- bl->m == sd->feel_map[1].m ||
- bl->m == sd->feel_map[2].m)
- { //Timeout will be handled by pc->setpos
+ if (bl->m == sd->feel_map[0].m
+ || bl->m == sd->feel_map[1].m
+ || bl->m == sd->feel_map[2].m
+ ) {
+ //Timeout will be handled by pc->setpos
sce->timer = INVALID_TIMER;
return 0;
}
@@ -10717,12 +10807,13 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
break;
case SC_SPLASHER:
- // custom Venom Splasher countdown timer
- //if (sce->val4 % 1000 == 0) {
- // char counter[10];
- // snprintf (counter, 10, "%d", sce->val4/1000);
- // clif->message(bl, counter);
- //}
+#if 0 // custom Venom Splasher countdown timer
+ if (sce->val4 % 1000 == 0) {
+ char counter[10];
+ snprintf (counter, 10, "%d", sce->val4/1000);
+ clif->message(bl, counter);
+ }
+#endif // 0
if((sce->val4 -= 500) > 0) {
sc_timer_next(500 + tick, status->change_timer, bl->id, data);
return 0;
@@ -10961,7 +11052,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
case SC__REPRODUCE:
if( --(sce->val4) >= 0 ) {
- if( !status_charge(bl, 0, 9 - (1 + sce->val1) / 2) )
+ if( !status->charge(bl, 0, 9 - (1 + sce->val1) / 2) )
break;
sc_timer_next(1000 + tick, status->change_timer, bl->id, data);
return 0;
@@ -11032,10 +11123,10 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
case SC_SIRCLEOFNATURE:
if( --(sce->val4) >= 0 ) {
- if( !status_charge(bl,0,sce->val3) )
+ if( !status->charge(bl,0,sce->val3) )
break;
status->heal(bl, sce->val2, 0, 1);
- sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
+ sc_timer_next(1000 + tick, status->change_timer, bl->id, data);
return 0;
}
break;
@@ -11051,7 +11142,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
case SC_SATURDAY_NIGHT_FEVER:
if( --(sce->val3) >= 0 ) {
- if( !status_charge(bl, st->max_hp * 1 / 100, st->max_sp * 1 / 100) )
+ if( !status->charge(bl, st->max_hp * 1 / 100, st->max_sp * 1 / 100) )
break;
sc_timer_next(3000+tick, status->change_timer, bl->id, data);
return 0;
@@ -11060,7 +11151,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
case SC_MELODYOFSINK:
if( --(sce->val4) >= 0 ) {
- status_charge(bl, 0, st->max_sp * ( 2 * sce->val1 + 2 * sce->val2 ) / 100);
+ status->charge(bl, 0, st->max_sp * ( 2 * sce->val1 + 2 * sce->val2 ) / 100);
sc_timer_next(1000+tick, status->change_timer, bl->id, data);
return 0;
}
@@ -11139,11 +11230,11 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
if(--(sce->val4) >= 0) {
// 1% SP Upkeep Cost
int sp = st->max_sp / 100;
-
+
if( st->sp <= sp )
status_change_end(bl,SC_STEALTHFIELD_MASTER,INVALID_TIMER);
- if( !status_charge(bl,0,sp) )
+ if( !status->charge(bl,0,sp) )
break;
if( !sc->data[SC_STEALTHFIELD_MASTER] )
@@ -11317,10 +11408,13 @@ int status_change_timer_sub(struct block_list* bl, va_list ap) {
if (battle->check_target( src, bl, BCT_ENEMY ) > 0
&& status->check_skilluse(src, bl, WZ_SIGHTBLASTER, 2)
) {
- if (sce && !(bl->type&BL_SKILL) //The hit is not counted if it's against a trap
- && skill->attack(BF_MAGIC,src,src,bl,WZ_SIGHTBLASTER,1,tick,0)
- ){
- sce->val2 = 0; //This signals it to end.
+ struct skill_unit *su = (struct skill_unit *)bl;
+ if (sce && skill->attack(BF_MAGIC,src,src,bl,WZ_SIGHTBLASTER,sce->val1,tick,0x4000)
+ && (!su || !su->group || !(skill->get_inf2(su->group->skill_id)&INF2_TRAP))) { // The hit is not counted if it's against a trap
+ sce->val2 = 0; // This signals it to end.
+ } else if ((bl->type&BL_SKILL) && sce && sce->val4%2 == 0) {
+ //Remove trap immunity temporarily so it triggers if you still stand on it
+ sce->val4++;
}
}
break;
@@ -11360,20 +11454,41 @@ int status_get_weapon_atk(struct block_list *bl, struct weapon_atk *watk, int fl
min = (int)(watk->atk - variance + strdex_bonus) + watk->atk2;
max = (int)(watk->atk + variance + strdex_bonus) + watk->atk2;
- }else if( watk->atk ){
+ }
+ else if (bl->type == BL_MOB && watk->atk){
min = watk->atk * 80 / 100;
max = watk->atk * 120 / 100;
}
+ else if (bl->type == BL_HOM && watk->atk){
+ if (flag & 4){
+ max = min = status->get_matk(bl, 2);
+ }
+ else{
+ min = watk->atk;
+ max = watk->atk2;
+ }
+ }
if( !(flag&1) ){
if( max > min )
- max = min + rnd()%(max - min);
+ max = min + rnd()%(max - min + 1);
else
max = min;
}
- if( bl->type == BL_PC && ((TBL_PC*)bl)->right_weapon.overrefine > 0 && !(flag&2) )
- max += rnd()%((TBL_PC*)bl)->right_weapon.overrefine + 1;
+ if ( bl->type == BL_PC && !(flag & 2) ) {
+ struct map_session_data *sd = (struct map_session_data *)bl;
+ short index = sd->equip_index[EQI_HAND_R], refine;
+ if ( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_WEAPON
+ && (refine = sd->status.inventory[index].refine) < 16 && refine ) {
+ int r = status->refine_info[watk->wlv].randombonus_max[refine + (4 - watk->wlv)] / 100;
+ if ( r )
+ max += (rnd() % 100) % r + 1;
+ }
+
+ if ( sd->spiritcharm[SPIRITS_TYPE_CHARM_LAND] > 0 )
+ max += 10 * max * sd->spiritcharm[SPIRITS_TYPE_CHARM_LAND] / 100;
+ }
max = status->calc_watk(bl, sc, max, false);
@@ -11384,31 +11499,21 @@ int status_get_weapon_atk(struct block_list *bl, struct weapon_atk *watk, int fl
}
/**
- * Gets a random matk value depending on min matk and max matk
- **/
-unsigned short status_get_rand_matk( unsigned short matk_max, unsigned short matk_min ) {
- if( matk_max > matk_min )
- return matk_min + rnd()%(matk_max - matk_min);
- else
- return matk_min;
-}
-
-/**
- * Get bl's matk_max and matk_min values depending on flag
- * @param flag
- * 0 - Get MATK
- * 1 - Get MATK w/o SC bonuses
- * 3 - Get MATK w/o EATK & SC bonuses
- **/
-void status_get_matk_sub( struct block_list *bl, int flag, unsigned short *matk_max, unsigned short *matk_min ) {
+* Get bl's matk_max and matk_min values depending on flag
+* @param flag
+* 0 - Get MATK
+* 1 - Get MATK w/o SC bonuses
+* 3 - Get MATK w/o EATK & SC bonuses
+**/
+void status_get_matk_sub(struct block_list *bl, int flag, unsigned short *matk_max, unsigned short *matk_min) {
struct status_data *st;
struct status_change *sc;
struct map_session_data *sd;
- if( bl == NULL )
+ if ( bl == NULL )
return;
- if( flag != 0 && flag != 1 && flag != 3 ) {
+ if ( flag != 0 && flag != 1 && flag != 3 ) {
ShowError("status_get_matk_sub: Unknown flag %d!\n", flag);
return;
}
@@ -11419,107 +11524,135 @@ void status_get_matk_sub( struct block_list *bl, int flag, unsigned short *matk_
#ifdef RENEWAL
/**
- * RE MATK Formula (from irowiki:http://irowiki.org/wiki/MATK)
- * MATK = (sMATK + wMATK + eMATK) * Multiplicative Modifiers
- **/
- *matk_min = status->base_matk(st, status->get_lv(bl));
+ * RE MATK Formula (from irowiki:http://irowiki.org/wiki/MATK)
+ * MATK = (sMATK + wMATK + eMATK) * Multiplicative Modifiers
+ **/
+ *matk_min = status->base_matk(bl, st, status->get_lv(bl));
// Any +MATK you get from skills and cards, including cards in weapon, is added here.
- if( sd && sd->bonus.ematk > 0 && flag != 3 )
+ if ( sd && sd->bonus.ematk > 0 && flag != 3 )
*matk_min += sd->bonus.ematk;
- if( flag != 3 )
+ if ( flag != 3 )
*matk_min = status->calc_ematk(bl, sc, *matk_min);
*matk_max = *matk_min;
- //This is the only portion in MATK that varies depending on the weapon level and refinement rate.
- if( bl->type&BL_PC && (st->rhw.matk + st->lhw.matk) > 0 ) {
- int wMatk = st->rhw.matk + st->lhw.matk; // Left and right matk stacks
- int variance = wMatk * st->rhw.wlv / 10; // Only use right hand weapon level
- *matk_min += wMatk - variance;
- *matk_max += wMatk + variance;
- } else if( bl->type&BL_MOB ) {
- *matk_min = *matk_max = status_get_int(bl) + status->get_lv(bl);
+ switch ( bl->type ) {
+ case BL_PC:
+ //This is the only portion in MATK that varies depending on the weapon level and refinement rate.
+ if ( (st->rhw.matk + st->lhw.matk) > 0 ) {
+ int wMatk = st->rhw.matk + st->lhw.matk; // Left and right matk stacks
+ int variance = wMatk * st->rhw.wlv / 10; // Only use right hand weapon level
+ *matk_min += wMatk - variance;
+ *matk_max += wMatk + variance;
+ }
+ break;
+ case BL_MOB:
*matk_min += 70 * ((TBL_MOB*)bl)->status.rhw.atk2 / 100;
*matk_max += 130 * ((TBL_MOB*)bl)->status.rhw.atk2 / 100;
+ break;
+ case BL_HOM:
+ *matk_min += (status_get_homint(bl) + status_get_homdex(bl)) / 5;
+ *matk_max += (status_get_homluk(bl) + status_get_homint(bl) + status_get_homdex(bl)) / 3;
+ break;
}
+
#else // not RENEWAL
- *matk_min = status_base_matk_min(st) + (sd?sd->bonus.ematk:0);
- *matk_max = status_base_matk_max(st) + (sd?sd->bonus.ematk:0);
+ *matk_min = status_base_matk_min(st) + (sd ? sd->bonus.ematk : 0);
+ *matk_max = status_base_matk_max(st) + (sd ? sd->bonus.ematk : 0);
#endif
- if (sd && sd->matk_rate != 100) {
- *matk_max = (*matk_max) * sd->matk_rate/100;
- *matk_min = (*matk_min) * sd->matk_rate/100;
+ if ( sd && sd->matk_rate != 100 ) {
+ *matk_max = (*matk_max) * sd->matk_rate / 100;
+ *matk_min = (*matk_min) * sd->matk_rate / 100;
}
- if ((bl->type&BL_HOM && battle_config.hom_setting&0x20) //Hom Min Matk is always the same as Max Matk
- || (sc && sc->data[SC_RECOGNIZEDSPELL]))
+ if ( (bl->type&BL_HOM && battle_config.hom_setting & 0x20) //Hom Min Matk is always the same as Max Matk
+ || (sc && sc->data[SC_RECOGNIZEDSPELL]) )
*matk_min = *matk_max;
#ifdef RENEWAL
- if( sd && sd->right_weapon.overrefine > 0 ) {
- (*matk_min)++;
- *matk_max += sd->right_weapon.overrefine - 1;
+ if ( sd && !(flag & 2) ) {
+ short index = sd->equip_index[EQI_HAND_R], refine;
+ if ( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_WEAPON
+ && (refine = sd->status.inventory[index].refine) < 16 && refine ) {
+ int r = status->refine_info[sd->inventory_data[index]->wlv].randombonus_max[refine + (4 - sd->inventory_data[index]->wlv)] / 100;
+ if ( r )
+ *matk_max += (rnd() % 100) % r + 1;
+ }
}
#endif
+
+ *matk_min = status->calc_matk(bl, sc, *matk_min, false);
+ *matk_max = status->calc_matk(bl, sc, *matk_max, false);
+
return;
}
/**
- * Get bl's matk value depending on flag
- * @param flag [malufett]
- * 1 - Get MATK w/o SC bonuses
- * 2 - Get modified MATK
- * 3 - Get MATK w/o eATK & SC bonuses
- * @retval 1 failure
- * @retval MATK success
- *
- * Shouldn't change _any_ value! [Panikon]
- **/
-int status_get_matk( struct block_list *bl, int flag ) {
+* Gets a random matk value depending on min matk and max matk
+**/
+unsigned short status_get_rand_matk(unsigned short matk_max, unsigned short matk_min) {
+ if ( matk_max > matk_min )
+ return matk_min + rnd() % (matk_max - matk_min);
+ else
+ return matk_min;
+}
+
+/**
+* Get bl's matk value depending on flag
+* @param flag [malufett]
+* 1 - Get MATK w/o SC bonuses
+* 2 - Get modified MATK
+* 3 - Get MATK w/o eATK & SC bonuses
+* @retval 1 failure
+* @retval MATK success
+*
+* Shouldn't change _any_ value! [Panikon]
+**/
+int status_get_matk(struct block_list *bl, int flag) {
struct status_data *st;
unsigned short matk_max, matk_min;
- if( bl == NULL )
+ if ( bl == NULL )
return 1;
- if( flag < 1 || flag > 3 ) {
+ if ( flag < 1 || flag > 3 ) {
ShowError("status_get_matk: Unknown flag %d!\n", flag);
return 1;
}
- if( (st = status->get_status_data(bl)) == NULL )
+ if ( (st = status->get_status_data(bl)) == NULL )
return 0;
// Just get matk
- if( flag == 2 )
+ if ( flag == 2 )
return status_get_rand_matk(st->matk_max, st->matk_min);
- status_get_matk_sub( bl, flag, &matk_max, &matk_min );
+ status_get_matk_sub(bl, flag, &matk_max, &matk_min);
// Get unmodified from sc matk
return status_get_rand_matk(matk_max, matk_min);
}
/**
- * Updates bl's MATK values
- **/
-void status_update_matk( struct block_list *bl ) {
+* Updates bl's MATK values
+**/
+void status_update_matk(struct block_list *bl) {
struct status_data *st;
struct status_change *sc;
unsigned short matk_max, matk_min;
- if( bl == NULL )
+ if ( bl == NULL )
return;
- if( (st = status->get_status_data(bl)) == NULL )
+ if ( (st = status->get_status_data(bl)) == NULL )
return;
- if( (sc = status->get_sc(bl)) == NULL )
+ if ( (sc = status->get_sc(bl)) == NULL )
return;
- status_get_matk_sub( bl, 0, &matk_max, &matk_min );
+ status_get_matk_sub(bl, 0, &matk_max, &matk_min);
// Update matk
st->matk_min = status->calc_matk(bl, sc, matk_min, true);
@@ -11669,7 +11802,7 @@ int status_change_spread( struct block_list *src, struct block_list *bl ) {
data.val2 = sc->data[i]->val2;
data.val3 = sc->data[i]->val3;
data.val4 = sc->data[i]->val4;
- status->change_start(src,bl,(sc_type)i,10000,data.val1,data.val2,data.val3,data.val4,data.tick,1|2|8);
+ status->change_start(src,bl,(sc_type)i,10000,data.val1,data.val2,data.val3,data.val4,data.tick,SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE);
flag = 1;
}
}
@@ -12053,7 +12186,7 @@ int status_readdb(void)
sv->readdb(map->db_path, "pre-re/job_db1.txt", ',', 5+MAX_WEAPON_TYPE, 5+MAX_WEAPON_TYPE, -1, status->readdb_job1);
#endif
sv->readdb(map->db_path, "job_db2.txt", ',', 1, 1+MAX_LEVEL, -1, status->readdb_job2);
- sv->readdb(map->db_path, "size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(status->atkmods), status->readdb_sizefix);
+ sv->readdb(map->db_path, DBPATH"size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(status->atkmods), status->readdb_sizefix);
sv->readdb(map->db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(status->refine_info), status->readdb_refine);
sv->readdb(map->db_path, "sc_config.txt", ',', 2, 2, SC_MAX, status->readdb_scconfig);
@@ -12204,7 +12337,7 @@ void status_defaults(void) {
status->readdb = status_readdb;
status->init = do_init_status;
status->final = do_final_status;
-
+
status->initChangeTables = initChangeTables;
status->initDummyData = initDummyData;
status->base_amotion_pc = status_base_amotion_pc;
diff --git a/src/map/status.h b/src/map/status.h
index 942f86d7c..63f9854d5 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -67,6 +67,20 @@ typedef enum sc_conf_type {
SC_NO_CLEAR = 0x80,
} sc_conf_type;
+/**
+ * Flags to be used with status->change_start
+ */
+enum scstart_flag {
+ // Note: When updating this enum, also update the documentation in doc/script_commands.txt and the constants in db/const.txt
+ SCFLAG_NONE = 0x00, ///< No special behavior.
+ SCFLAG_NOAVOID = 0x01, ///< Cannot be avoided (it has to start).
+ SCFLAG_FIXEDTICK = 0x02, ///< Tick should not be reduced (by vit, luk, lv, etc).
+ SCFLAG_LOADED = 0x04, ///< sc_data was loaded, no value has to be altered.
+ SCFLAG_FIXEDRATE = 0x08, ///< rate should not be reduced (not evaluated in status_change_start, but in some calls to other functions).
+ SCFLAG_NOICON = 0x10, ///< Status icon (SI) should not be sent.
+ SCFLAG_ALL = SCFLAG_NONE|SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_LOADED|SCFLAG_FIXEDRATE|SCFLAG_NOICON
+};
+
// Status changes listing. These code are for use by the server.
typedef enum sc_type {
SC_NONE = -1,
@@ -88,7 +102,7 @@ typedef enum sc_type {
SC_BURNING,
SC_DEEP_SLEEP,
SC_COMMON_MAX = 14, // end
-
+
//Next up, we continue on 20, to leave enough room for additional "common" ailments in the future.
SC_PROVOKE = 20,
SC_ENDURE,
@@ -253,7 +267,7 @@ typedef enum sc_type {
SC_DONTFORGETME, //180
SC_FORTUNE,
SC_SERVICEFORYOU,
- SC_STOP, //Prevents inflicted chars from walking. [Skotlex]
+ SC_STOP, //Prevents inflicted chars from walking. [Skotlex]
SC_STRUP,
SC_SOULLINK,
SC_COMA, //Not a real SC_, it makes a char's HP/SP hit 1.
@@ -310,7 +324,7 @@ typedef enum sc_type {
SC_NJ_SUITON,
SC_NJ_NEN,
SC_KNOWLEDGE,
- SC_SMA_READY, //240
+ SC_SMA_READY, //240
SC_FLING,
SC_HLIF_AVOID,
SC_HLIF_CHANGE,
@@ -320,7 +334,7 @@ typedef enum sc_type {
SC_HAMI_DEFENCE,
SC_INCASPDRATE,
SC_PLUSAVOIDVALUE,
- SC_JAILED, //250
+ SC_JAILED, //250
SC_ENCHANTARMS,
SC_MAGICALATTACK,
SC_STONESKIN,
@@ -665,7 +679,7 @@ typedef enum sc_type {
SC_ZANGETSU,
SC_GENSOU,
SC_AKAITSUKI,
-
+
//homon S
SC_STYLE_CHANGE,
SC_GOLDENE_FERSE, // 540
@@ -691,13 +705,13 @@ typedef enum sc_type {
SC_TELEKINESIS_INTENSE,
SC_OFFERTORIUM,
SC_FRIGG_SONG, // 560
-
+
SC_ALL_RIDING,
SC_HANBOK,
SC_MONSTER_TRANSFORM,
SC_ANGEL_PROTECT,
SC_ILLUSIONDOPING,
-
+
SC_MTF_ASPD,
SC_MTF_RANGEATK,
SC_MTF_MATK,
@@ -710,13 +724,13 @@ typedef enum sc_type {
SC_OKTOBERFEST,
SC_STRANGELIGHTS,
SC_DECORATION_OF_MUSIC,
-
+
SC__MAELSTROM,
SC__CHAOS,
-
+
SC__FEINTBOMB_MASTER,
SC_FALLENEMPIRE,
- SC_FLASHCOMBO,
+ SC_FLASHCOMBO, // 580
//Vellum Weapon reductions
SC_DEFSET,
@@ -724,6 +738,12 @@ typedef enum sc_type {
SC_NO_SWITCH_EQUIP,
+ // 2014 Halloween Event
+ SC_MTF_MHP,
+ SC_MTF_MSP,
+ SC_MTF_PUMPKIN,
+ SC_MTF_HITFLEE,
+
SC_MAX, //Automatically updated max, used in for's to check we are within bounds.
} sc_type;
@@ -1185,7 +1205,7 @@ enum si_type {
SI_ECHOSONG = 443,
SI_HARMONIZE = 444,
SI_STRIKING = 445,
- SI_WARMER = 446,
+ //SI_WARMER = 446,
SI_MOONLITSERENADE = 447,
SI_SATURDAYNIGHTFEVER = 448,
SI_SITDOWN_FORCE = 449,
@@ -1474,21 +1494,21 @@ enum si_type {
//SI_ = 735,
SI_CHILL = 736,
SI_BURNT = 737,
-// SI_PCCAFE_PLAY_TIME = 738,
-// SI_TWISTED_TIME = 739,
+ //SI_PCCAFE_PLAY_TIME = 738,
+ //SI_TWISTED_TIME = 739,
SI_FLASHCOMBO = 740,
-// SI_JITTER_BUFF1 = 741,
-// SI_JITTER_BUFF2 = 742,
-// SI_JITTER_BUFF3 = 743,
-// SI_JITTER_BUFF4 = 744,
-// SI_JITTER_BUFF5 = 745,
-// SI_JITTER_BUFF6 = 746,
-// SI_JITTER_BUFF7 = 747,
-// SI_JITTER_BUFF8 = 748,
-// SI_JITTER_BUFF9 = 749,
-// SI_JITTER_BUFF10 = 750,
-// SI_CUP_OF_BOZA = 751,
+ //SI_JITTER_BUFF1 = 741,
+ //SI_JITTER_BUFF2 = 742,
+ //SI_JITTER_BUFF3 = 743,
+ //SI_JITTER_BUFF4 = 744,
+ //SI_JITTER_BUFF5 = 745,
+ //SI_JITTER_BUFF6 = 746,
+ //SI_JITTER_BUFF7 = 747,
+ //SI_JITTER_BUFF8 = 748,
+ //SI_JITTER_BUFF9 = 749,
+ //SI_JITTER_BUFF10 = 750,
+ //SI_CUP_OF_BOZA = 751,
SI_B_TRAP = 752,
SI_E_CHAIN = 753,
SI_E_QD_SHOT_READY = 754,
@@ -1514,38 +1534,38 @@ enum si_type {
SI_PACKING_ENVELOPE9 = 774,
SI_PACKING_ENVELOPE10 = 775,
SI_GLASTHEIM_TRANS = 776,
-// SI_ZONGZI_POUCH_TRANS = 777,
+ //SI_ZONGZI_POUCH_TRANS = 777,
SI_HEAT_BARREL_AFTER = 778,
SI_DECORATION_OF_MUSIC = 779,
-// SI_OVERSEAEXPUP = 780,
-// SI_CLOWN_N_GYPSY_CARD = 781,
-// SI_OPEN_NPC_MARKET = 782,
-// SI_BEEF_RIB_STEW = 783,
-// SI_PORK_RIB_STEW = 784,
-// SI_CHUSEOK_MONDAY = 785,
-// SI_CHUSEOK_TUESDAY = 786,
-// SI_CHUSEOK_WEDNESDAY = 787,
-// SI_CHUSEOK_THURSDAY = 788,
-// SI_CHUSEOK_FRIDAY = 789,
-// SI_CHUSEOK_WEEKEND = 790,
-// SI_ALL_LIGHTGUARD = 791,
-// SI_ALL_LIGHTGUARD_COOL_TIME = 792,
-// SI_MTF_MHP = 793,
-// SI_MTF_MSP = 794,
-// SI_MTF_PUMPKIN = 795,
-// SI_MTF_HITFLEE = 796,
-// SI_MTF_CRIDAMAGE2 = 797,
-// SI_MTF_SPDRAIN = 798,
-// SI_ACUO_MINT_GUM = 799,
-// ...
-// SI_GUILD_STORAGE = 810,
-// ...
-// SI_JUMPINGCLAN = 815,
-// ...
-// SI_MTF_RANGEATK2 = 818,
-// SI_MTF_ASPD2 = 819,
-// SI_MTF_MATK2 = 820,
+ //SI_OVERSEAEXPUP = 780,
+ //SI_CLOWN_N_GYPSY_CARD = 781,
+ //SI_OPEN_NPC_MARKET = 782,
+ //SI_BEEF_RIB_STEW = 783,
+ //SI_PORK_RIB_STEW = 784,
+ //SI_CHUSEOK_MONDAY = 785,
+ //SI_CHUSEOK_TUESDAY = 786,
+ //SI_CHUSEOK_WEDNESDAY = 787,
+ //SI_CHUSEOK_THURSDAY = 788,
+ //SI_CHUSEOK_FRIDAY = 789,
+ //SI_CHUSEOK_WEEKEND = 790,
+ //SI_ALL_LIGHTGUARD = 791,
+ //SI_ALL_LIGHTGUARD_COOL_TIME = 792,
+ //SI_MTF_MHP = 793,
+ //SI_MTF_MSP = 794,
+ //SI_MTF_PUMPKIN = 795,
+ //SI_MTF_HITFLEE = 796,
+ //SI_MTF_CRIDAMAGE2 = 797,
+ //SI_MTF_SPDRAIN = 798,
+ //SI_ACUO_MINT_GUM = 799,
+ // ...
+ //SI_GUILD_STORAGE = 810,
+ // ...
+ //SI_JUMPINGCLAN = 815,
+ // ...
+ //SI_MTF_RANGEATK2 = 818,
+ //SI_MTF_ASPD2 = 819,
+ //SI_MTF_MATK2 = 820,
SI_MAX,
};
@@ -1580,7 +1600,6 @@ enum e_mode
MD_CHANGETARGET_MELEE = 0x1000,
MD_CHANGETARGET_CHASE = 0x2000,
MD_TARGETWEAK = 0x4000,
- MD_RANDOMTARGET = 0x8000,
MD_MASK = 0xFFFF,
};
@@ -1662,18 +1681,18 @@ enum {
OPTION_DRAGON5 = 0x04000000,
OPTION_HANBOK = 0x08000000,
OPTION_OKTOBERFEST = 0x10000000,
-
+
#ifndef NEW_CARTS
OPTION_CART1 = 0x00000008,
OPTION_CART2 = 0x00000080,
OPTION_CART3 = 0x00000100,
OPTION_CART4 = 0x00000200,
OPTION_CART5 = 0x00000400,
-
+
/* compound constant for older carts */
OPTION_CART = OPTION_CART1|OPTION_CART2|OPTION_CART3|OPTION_CART4|OPTION_CART5,
#endif
-
+
// compound constants
OPTION_DRAGON = OPTION_DRAGON1|OPTION_DRAGON2|OPTION_DRAGON3|OPTION_DRAGON4|OPTION_DRAGON5,
OPTION_COSTUME = OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK|OPTION_OKTOBERFEST,
@@ -1806,7 +1825,7 @@ struct regen_data_sub {
struct {
unsigned int hp,sp;
} tick;
-
+
//Regen rates (where every 1 means +100% regen)
struct {
unsigned char hp,sp;
@@ -1823,18 +1842,18 @@ struct regen_data {
struct {
unsigned int hp,sp,shp,ssp;
} tick;
-
+
//Regen rates (where every 1 means +100% regen)
struct {
unsigned char
hp,sp,shp,ssp;
} rate;
-
+
struct {
- unsigned walk:1; //Can you regen even when walking?
- unsigned gc:1; //Tags when you should have double regen due to GVG castle
+ unsigned walk:1; //Can you regen even when walking?
+ unsigned gc:1; //Tags when you should have double regen due to GVG castle
unsigned overweight :2; //overweight state (1: 50%, 2: 90%)
- unsigned block :2; //Block regen flag (1: Hp, 2: Sp)
+ unsigned block :2; //Block regen flag (1: Hp, 2: Sp)
} state;
//skill-regen, sitting-skill-regen (since not all chars with regen need it)
@@ -1920,10 +1939,17 @@ struct status_change {
#define status_get_size(bl) (status->get_status_data(bl)->size)
#define status_get_mode(bl) (status->get_status_data(bl)->mode)
+#define status_get_homstr(bl) (st->str + ((TBL_HOM*)bl)->homunculus.str_value)
+#define status_get_homagi(bl) (st->agi + ((TBL_HOM*)bl)->homunculus.agi_value)
+#define status_get_homvit(bl) (st->vit + ((TBL_HOM*)bl)->homunculus.vit_value)
+#define status_get_homint(bl) (st->int_ + ((TBL_HOM*)bl)->homunculus.int_value)
+#define status_get_homdex(bl) (st->dex + ((TBL_HOM*)bl)->homunculus.dex_value)
+#define status_get_homluk(bl) (st->luk + ((TBL_HOM*)bl)->homunculus.luk_value)
+
//Short version, receives rate in 1->100 range, and does not uses a flag setting.
-#define sc_start(src, bl, type, rate, val1, tick) (status->change_start((src),(bl),(type),100*(rate),(val1),0,0,0,(tick),0))
-#define sc_start2(src, bl, type, rate, val1, val2, tick) (status->change_start((src),(bl),(type),100*(rate),(val1),(val2),0,0,(tick),0))
-#define sc_start4(src, bl, type, rate, val1, val2, val3, val4, tick) (status->change_start((src),(bl),(type),100*(rate),(val1),(val2),(val3),(val4),(tick),0))
+#define sc_start(src, bl, type, rate, val1, tick) (status->change_start((src),(bl),(type),100*(rate),(val1),0,0,0,(tick),SCFLAG_NONE))
+#define sc_start2(src, bl, type, rate, val1, val2, tick) (status->change_start((src),(bl),(type),100*(rate),(val1),(val2),0,0,(tick),SCFLAG_NONE))
+#define sc_start4(src, bl, type, rate, val1, val2, val3, val4, tick) (status->change_start((src),(bl),(type),100*(rate),(val1),(val2),(val3),(val4),(tick),SCFLAG_NONE))
#define status_change_end(bl,type,tid) (status->change_end_((bl),(type),(tid),__FILE__,__LINE__))
@@ -2043,14 +2069,14 @@ struct status_interface {
defType (*calc_mdef) (struct block_list *bl, struct status_change *sc, int mdef, bool viewable);
short (*calc_mdef2) (struct block_list *bl, struct status_change *sc, int mdef2, bool viewable);
unsigned short (*calc_batk)(struct block_list *bl, struct status_change *sc, int batk, bool viewable);
- unsigned short (*base_matk) (const struct status_data *st, int level);
+ unsigned short(*base_matk) (struct block_list *bl, const struct status_data *st, int level);
int (*get_weapon_atk) (struct block_list *src, struct weapon_atk *watk, int flag);
int (*get_total_mdef) (struct block_list *src);
int (*get_total_def) (struct block_list *src);
int (*get_matk) (struct block_list *src, int flag);
void (*update_matk) ( struct block_list *bl );
int (*readdb) (void);
-
+
void (*initChangeTables) (void);
void (*initDummyData) (void);
int (*base_amotion_pc) (struct map_session_data *sd, struct status_data *st);
diff --git a/src/map/storage.c b/src/map/storage.c
index 217f14a3a..755f50cb7 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -85,13 +85,13 @@ int storage_storageopen(struct map_session_data *sd)
if(sd->state.storage_flag)
return 1; //Already open?
-
- if( !pc_can_give_items(sd) )
- { //check is this GM level is allowed to put items to storage
+
+ if( !pc_can_give_items(sd) ) {
+ //check is this GM level is allowed to put items to storage
clif->message(sd->fd, msg_txt(246));
return 1;
}
-
+
sd->state.storage_flag = 1;
storage->sortitem(sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items));
clif->storagelist(sd, sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items));
@@ -128,7 +128,7 @@ int storage_additem(struct map_session_data* sd, struct item* item_data, int amo
if( item_data->nameid <= 0 || amount <= 0 )
return 1;
-
+
data = itemdb->search(item_data->nameid);
if( data->stack.storage && amount > data->stack.amount )
@@ -136,12 +136,12 @@ int storage_additem(struct map_session_data* sd, struct item* item_data, int amo
return 1;
}
- if( !itemdb_canstore(item_data, pc_get_group_level(sd)) )
- { //Check if item is storable. [Skotlex]
+ if (!itemdb_canstore(item_data, pc_get_group_level(sd))) {
+ //Check if item is storable. [Skotlex]
clif->message (sd->fd, msg_txt(264));
return 1;
}
-
+
if( item_data->bound > IBT_ACCOUNT && !pc_can_give_bound_items(sd) ) {
clif->message(sd->fd, msg_txt(294));
return 1;
@@ -200,8 +200,8 @@ int storage_delitem(struct map_session_data* sd, int n, int amount)
* Add an item to the storage from the inventory.
* @index : inventory idx
* return
- * 0 : fail
- * 1 : success
+ * 0 : fail
+ * 1 : success
*------------------------------------------*/
int storage_storageadd(struct map_session_data* sd, int index, int amount) {
nullpo_ret(sd);
@@ -216,7 +216,7 @@ int storage_storageadd(struct map_session_data* sd, int index, int amount) {
return 0; // No item on that spot
if( amount < 1 || amount > sd->status.inventory[index].amount )
- return 0;
+ return 0;
if( storage->additem(sd,&sd->status.inventory[index],amount) == 0 )
pc->delitem(sd,index,amount,0,4,LOG_TYPE_STORAGE);
@@ -230,8 +230,8 @@ int storage_storageadd(struct map_session_data* sd, int index, int amount) {
* Retrieve an item from the storage into inventory
* @index : storage idx
* return
- * 0 : fail
- * 1 : success
+ * 0 : fail
+ * 1 : success
*------------------------------------------*/
int storage_storageget(struct map_session_data* sd, int index, int amount)
{
@@ -242,7 +242,7 @@ int storage_storageget(struct map_session_data* sd, int index, int amount)
if( sd->status.storage.items[index].nameid <= 0 )
return 0; //Nothing there
-
+
if( amount < 1 || amount > sd->status.storage.items[index].amount )
return 0;
@@ -258,22 +258,22 @@ int storage_storageget(struct map_session_data* sd, int index, int amount)
* Move an item from cart to storage.
* @index : cart inventory index
* return
- * 0 : fail
- * 1 : success
+ * 0 : fail
+ * 1 : success
*------------------------------------------*/
int storage_storageaddfromcart(struct map_session_data* sd, int index, int amount)
{
nullpo_ret(sd);
if( sd->status.storage.storage_amount > MAX_STORAGE )
- return 0; // storage full / storage closed
+ return 0; // storage full / storage closed
if( index < 0 || index >= MAX_CART )
- return 0;
+ return 0;
if( sd->status.cart[index].nameid <= 0 )
return 0; //No item there.
-
+
if( amount < 1 || amount > sd->status.cart[index].amount )
return 0;
@@ -287,8 +287,8 @@ int storage_storageaddfromcart(struct map_session_data* sd, int index, int amoun
* Get from Storage to the Cart inventory
* @index : storage index
* return
- * 0 : fail
- * 1 : success
+ * 0 : fail
+ * 1 : success
*------------------------------------------*/
int storage_storagegettocart(struct map_session_data* sd, int index, int amount) {
int flag = 0;
@@ -296,13 +296,13 @@ int storage_storagegettocart(struct map_session_data* sd, int index, int amount)
if( index < 0 || index >= MAX_STORAGE )
return 0;
-
+
if( sd->status.storage.items[index].nameid <= 0 )
return 0; //Nothing there.
-
+
if( amount < 1 || amount > sd->status.storage.items[index].amount )
return 0;
-
+
if( (flag = pc->cart_additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE)) == 0 )
storage->delitem(sd,index,amount);
else {
@@ -333,7 +333,7 @@ void storage_storageclose(struct map_session_data* sd) {
*------------------------------------------*/
void storage_storage_quit(struct map_session_data* sd, int flag) {
nullpo_retv(sd);
-
+
if (map->save_settings&4)
chrif->save(sd, flag); //Invokes the storage saving as well.
@@ -351,7 +351,7 @@ DBData create_guildstorage(DBKey key, va_list args)
return DB->ptr2data(gs);
}
-struct guild_storage *guild2storage(int guild_id)
+struct guild_storage *guild2storage_ensure(int guild_id)
{
struct guild_storage *gs = NULL;
if(guild->search(guild_id) != NULL)
@@ -359,11 +359,6 @@ struct guild_storage *guild2storage(int guild_id)
return gs;
}
-//For just locating a storage without creating one. [Skotlex]
-struct guild_storage *guild2storage2(int guild_id) {
- return (struct guild_storage*)idb_get(gstorage->db,guild_id);
-}
-
int guild_storage_delete(int guild_id) {
idb_remove(gstorage->db,guild_id);
return 0;
@@ -372,9 +367,9 @@ int guild_storage_delete(int guild_id) {
/*==========================================
* Attempt to open guild storage for sd
* return
-* 0 : success (open or req to create a new one)
-* 1 : fail
-* 2 : no guild for sd
+* 0 : success (open or req to create a new one)
+* 1 : fail
+* 2 : no guild for sd
*------------------------------------------*/
int storage_guild_storageopen(struct map_session_data* sd)
{
@@ -387,22 +382,22 @@ int storage_guild_storageopen(struct map_session_data* sd)
if(sd->state.storage_flag)
return 1; //Can't open both storages at a time.
-
+
if( !pc_can_give_items(sd) ) { //check is this GM level can open guild storage and store items [Lupus]
clif->message(sd->fd, msg_txt(246));
return 1;
}
- if((gstor = gstorage->id2storage2(sd->status.guild_id)) == NULL) {
+ if((gstor = idb_get(gstorage->db,sd->status.guild_id)) == NULL) {
intif->request_guild_storage(sd->status.account_id,sd->status.guild_id);
return 0;
}
if(gstor->storage_status)
return 1;
-
+
if( gstor->lock )
return 1;
-
+
gstor->storage_status = 1;
sd->state.storage_flag = 2;
storage->sortitem(gstor->items, ARRAYLENGTH(gstor->items));
@@ -414,8 +409,8 @@ int storage_guild_storageopen(struct map_session_data* sd)
/*==========================================
* Attempt to add an item in guild storage, then refresh it
* return
-* 0 : success
-* 1 : fail
+* 0 : success
+* 1 : fail
*------------------------------------------*/
int guild_storage_additem(struct map_session_data* sd, struct guild_storage* stor, struct item* item_data, int amount)
{
@@ -436,8 +431,8 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto
return 1;
}
- if( !itemdb_canguildstore(item_data, pc_get_group_level(sd)) || item_data->expire_time )
- { //Check if item is storable. [Skotlex]
+ if (!itemdb_canguildstore(item_data, pc_get_group_level(sd)) || item_data->expire_time) {
+ //Check if item is storable. [Skotlex]
clif->message (sd->fd, msg_txt(264));
return 1;
}
@@ -446,7 +441,7 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto
clif->message(sd->fd, msg_txt(294));
return 1;
}
-
+
if(itemdb->isstackable2(data)){ //Stackable
for(i=0;i<MAX_GUILD_STORAGE;i++){
if(compare_item(&stor->items[i], item_data)) {
@@ -461,10 +456,10 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto
}
//Add item
for(i=0;i<MAX_GUILD_STORAGE && stor->items[i].nameid;i++);
-
+
if(i>=MAX_GUILD_STORAGE)
return 1;
-
+
memcpy(&stor->items[i],item_data,sizeof(stor->items[0]));
stor->items[i].amount=amount;
stor->storage_amount++;
@@ -477,8 +472,8 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto
/*==========================================
* Attempt to delete an item in guild storage, then refresh it
* return
-* 0 : success
-* 1 : fail
+* 0 : success
+* 1 : fail
*------------------------------------------*/
int guild_storage_delitem(struct map_session_data* sd, struct guild_storage* stor, int n, int amount)
{
@@ -503,28 +498,28 @@ int guild_storage_delitem(struct map_session_data* sd, struct guild_storage* sto
* Attempt to add an item in guild storage from inventory, then refresh it
* @index : inventory idx
* return
-* 0 : fail
-* 1 : succes
+* 0 : fail
+* 1 : succes
*------------------------------------------*/
int storage_guild_storageadd(struct map_session_data* sd, int index, int amount)
{
struct guild_storage *stor;
nullpo_ret(sd);
- nullpo_ret(stor=gstorage->id2storage2(sd->status.guild_id));
-
+ nullpo_ret(stor=idb_get(gstorage->db,sd->status.guild_id));
+
if( !stor->storage_status || stor->storage_amount > MAX_GUILD_STORAGE )
return 0;
-
+
if( index<0 || index>=MAX_INVENTORY )
return 0;
if( sd->status.inventory[index].nameid <= 0 )
return 0;
-
+
if( amount < 1 || amount > sd->status.inventory[index].amount )
return 0;
-
+
if( stor->lock ) {
gstorage->close(sd);
return 0;
@@ -542,8 +537,8 @@ int storage_guild_storageadd(struct map_session_data* sd, int index, int amount)
* Attempt to retrieve an item from guild storage to inventory, then refresh it
* @index : storage idx
* return
-* 0 : fail
-* 1 : success
+* 0 : fail
+* 1 : success
*------------------------------------------*/
int storage_guild_storageget(struct map_session_data* sd, int index, int amount)
{
@@ -551,20 +546,20 @@ int storage_guild_storageget(struct map_session_data* sd, int index, int amount)
int flag;
nullpo_ret(sd);
- nullpo_ret(stor=guild2storage2(sd->status.guild_id));
+ nullpo_ret(stor=idb_get(gstorage->db,sd->status.guild_id));
if(!stor->storage_status)
- return 0;
-
+ return 0;
+
if(index<0 || index>=MAX_GUILD_STORAGE)
return 0;
if(stor->items[index].nameid <= 0)
return 0;
-
+
if(amount < 1 || amount > stor->items[index].amount)
- return 0;
-
+ return 0;
+
if( stor->lock ) {
gstorage->close(sd);
return 0;
@@ -574,7 +569,7 @@ int storage_guild_storageget(struct map_session_data* sd, int index, int amount)
gstorage->delitem(sd,stor,index,amount);
else //inform fail
clif->additem(sd,0,0,flag);
-// log_fromstorage(sd, index, 1);
+ //log_fromstorage(sd, index, 1);
return 0;
}
@@ -583,15 +578,15 @@ int storage_guild_storageget(struct map_session_data* sd, int index, int amount)
* Attempt to add an item in guild storage from cart, then refresh it
* @index : cart inventory idx
* return
-* 0 : fail
-* 1 : success
+* 0 : fail
+* 1 : success
*------------------------------------------*/
int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int amount)
{
struct guild_storage *stor;
nullpo_ret(sd);
- nullpo_ret(stor=guild2storage2(sd->status.guild_id));
+ nullpo_ret(stor=idb_get(gstorage->db,sd->status.guild_id));
if( !stor->storage_status || stor->storage_amount > MAX_GUILD_STORAGE )
return 0;
@@ -601,7 +596,7 @@ int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int
if( sd->status.cart[index].nameid <= 0 )
return 0;
-
+
if( amount < 1 || amount > sd->status.cart[index].amount )
return 0;
@@ -615,25 +610,25 @@ int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int
* Attempt to retrieve an item from guild storage to cart, then refresh it
* @index : storage idx
* return
-* 0 : fail
-* 1 : success
+* 0 : fail
+* 1 : success
*------------------------------------------*/
int storage_guild_storagegettocart(struct map_session_data* sd, int index, int amount)
{
struct guild_storage *stor;
nullpo_ret(sd);
- nullpo_ret(stor=guild2storage2(sd->status.guild_id));
+ nullpo_ret(stor=idb_get(gstorage->db,sd->status.guild_id));
if(!stor->storage_status)
- return 0;
+ return 0;
if(index<0 || index>=MAX_GUILD_STORAGE)
- return 0;
-
+ return 0;
+
if(stor->items[index].nameid<=0)
return 0;
-
+
if(amount < 1 || amount > stor->items[index].amount)
return 0;
@@ -646,18 +641,18 @@ int storage_guild_storagegettocart(struct map_session_data* sd, int index, int a
/*==========================================
* Request to save guild storage
* return
-* 0 : fail (no storage)
-* 1 : success
+* 0 : fail (no storage)
+* 1 : success
*------------------------------------------*/
int storage_guild_storagesave(int account_id, int guild_id, int flag)
{
- struct guild_storage *stor = guild2storage2(guild_id);
+ struct guild_storage *stor = idb_get(gstorage->db,guild_id);
if(stor)
{
if (flag) //Char quitting, close it.
stor->storage_status = 0;
- if (stor->dirty)
+ if (stor->dirty)
intif->send_guild_storage(account_id,stor);
return 1;
}
@@ -667,16 +662,16 @@ int storage_guild_storagesave(int account_id, int guild_id, int flag)
/*==========================================
* ACK save of guild storage
* return
-* 0 : fail (no storage)
-* 1 : success
+* 0 : fail (no storage)
+* 1 : success
*------------------------------------------*/
int storage_guild_storagesaved(int guild_id)
{
struct guild_storage *stor;
- if((stor=gstorage->id2storage2(guild_id)) != NULL) {
- if (stor->dirty && stor->storage_status == 0)
- { //Storage has been correctly saved.
+ if((stor=idb_get(gstorage->db,guild_id)) != NULL) {
+ if (stor->dirty && stor->storage_status == 0) {
+ //Storage has been correctly saved.
stor->dirty = 0;
}
return 1;
@@ -689,7 +684,7 @@ int storage_guild_storageclose(struct map_session_data* sd) {
struct guild_storage *stor;
nullpo_ret(sd);
- nullpo_ret(stor=gstorage->id2storage2(sd->status.guild_id));
+ nullpo_ret(stor=idb_get(gstorage->db,sd->status.guild_id));
clif->storageclose(sd);
if (stor->storage_status) {
@@ -708,8 +703,8 @@ int storage_guild_storage_quit(struct map_session_data* sd, int flag) {
struct guild_storage *stor;
nullpo_ret(sd);
- nullpo_ret(stor=gstorage->id2storage2(sd->status.guild_id));
-
+ nullpo_ret(stor=idb_get(gstorage->db,sd->status.guild_id));
+
if(flag) {
//Only during a guild break flag is 1 (don't save storage)
sd->state.storage_flag = 0;
@@ -760,13 +755,12 @@ void storage_defaults(void) {
}
void gstorage_defaults(void) {
gstorage = &gstorage_s;
-
+
/* */
gstorage->init = do_init_gstorage;
gstorage->final = do_final_gstorage;
/* */
- gstorage->id2storage = guild2storage;
- gstorage->id2storage2 = guild2storage2;
+ gstorage->ensure = guild2storage_ensure;
gstorage->delete = guild_storage_delete;
gstorage->open = storage_guild_storageopen;
gstorage->additem = guild_storage_additem;
diff --git a/src/map/storage.h b/src/map/storage.h
index 186f21263..fcf9a52e4 100644
--- a/src/map/storage.h
+++ b/src/map/storage.h
@@ -34,8 +34,7 @@ struct storage_interface *storage;
struct guild_storage_interface {
struct DBMap* db; // int guild_id -> struct guild_storage*
/* */
- struct guild_storage *(*id2storage) (int guild_id);
- struct guild_storage *(*id2storage2) (int guild_id);
+ struct guild_storage *(*ensure) (int guild_id);
/* */
void (*init) (bool minimal);
void (*final) (void);
diff --git a/src/map/trade.c b/src/map/trade.c
index 3bbb73568..4d6909957 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -43,8 +43,8 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta
return;
}
- if (target_sd->npc_id)
- { //Trade fails if you are using an NPC.
+ if (target_sd->npc_id) {
+ //Trade fails if you are using an NPC.
clif->tradestart(sd, 2);
return;
}
@@ -145,9 +145,10 @@ void trade_tradeack(struct map_session_data *sd, int type) {
}
//Check if you can start trade.
- if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.storage_flag ||
- tsd->npc_id || tsd->state.vending || tsd->state.buyingstore || tsd->state.storage_flag)
- { //Fail
+ if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.storage_flag
+ || tsd->npc_id || tsd->state.vending || tsd->state.buyingstore || tsd->state.storage_flag
+ ) {
+ //Fail
clif->tradestart(sd, 2);
clif->tradestart(tsd, 2);
sd->state.deal_locked = 0;
@@ -335,8 +336,8 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount)
return;
}
- if( amount == 0 )
- { //Why do this.. ~.~ just send an ack, the item won't display on the trade window.
+ if (amount == 0) {
+ //Why do this.. ~.~ just send an ack, the item won't display on the trade window.
clif->tradeitemok(sd, index, TIO_SUCCESS);
return;
}
@@ -375,7 +376,7 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount)
clif->tradeitemok(sd, index+2, TIO_INDROCKS);
return;
}
-
+
//Locate a trade position
ARR_FIND( 0, 10, trade_i, sd->deal.item[trade_i].index == index || sd->deal.item[trade_i].amount == 0 );
if( trade_i == 10 ) //No space left
@@ -385,23 +386,22 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount)
}
trade_weight = sd->inventory_data[index]->weight * amount;
- if( target_sd->weight + sd->deal.weight + trade_weight > target_sd->max_weight )
- { //fail to add item -- the player was over weighted.
+ if (target_sd->weight + sd->deal.weight + trade_weight > target_sd->max_weight) {
+ //fail to add item -- the player was over weighted.
clif->tradeitemok(sd, index+2, TIO_OVERWEIGHT);
return;
}
- if( sd->deal.item[trade_i].index == index )
- { //The same item as before is being readjusted.
- if( sd->deal.item[trade_i].amount + amount > sd->status.inventory[index].amount )
- { //packet deal exploit check
+ if (sd->deal.item[trade_i].index == index) {
+ //The same item as before is being readjusted.
+ if (sd->deal.item[trade_i].amount + amount > sd->status.inventory[index].amount) {
+ //packet deal exploit check
amount = sd->status.inventory[index].amount - sd->deal.item[trade_i].amount;
trade_weight = sd->inventory_data[index]->weight * amount;
}
sd->deal.item[trade_i].amount += amount;
- }
- else
- { //New deal item
+ } else {
+ //New deal item
sd->deal.item[trade_i].index = index;
sd->deal.item[trade_i].amount = amount;
}
@@ -427,8 +427,8 @@ void trade_tradeaddzeny(struct map_session_data* sd, int amount)
return;
}
- if( amount < 0 || amount > sd->status.zeny || amount > MAX_ZENY - target_sd->status.zeny )
- { // invalid values, no appropriate packet for it => abort
+ if (amount < 0 || amount > sd->status.zeny || amount > MAX_ZENY - target_sd->status.zeny) {
+ // invalid values, no appropriate packet for it => abort
trade->cancel(sd);
return;
}
@@ -606,8 +606,7 @@ void trade_tradecommit(struct map_session_data *sd) {
clif->tradecompleted(tsd, 0);
// save both player to avoid crash: they always have no advantage/disadvantage between the 2 players
- if (map->save_settings&1)
- {
+ if (map->save_settings&1) {
chrif->save(sd,0);
chrif->save(tsd,0);
}
@@ -616,7 +615,7 @@ void trade_tradecommit(struct map_session_data *sd) {
void trade_defaults(void)
{
trade = &trade_s;
-
+
trade->request = trade_traderequest;
trade->ack = trade_tradeack;
trade->check_impossible = impossible_trade_check;
diff --git a/src/map/unit.c b/src/map/unit.c
index af0c0a948..a5bd282a9 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -95,9 +95,18 @@ int unit_walktoxy_sub(struct block_list *bl)
ud = unit->bl2ud(bl);
if(ud == NULL) return 0;
+ memset(&wpd, 0, sizeof(wpd));
+
if( !path->search(&wpd,bl->m,bl->x,bl->y,ud->to_x,ud->to_y,ud->state.walk_easy,CELL_CHKNOPASS) )
return 0;
+#ifdef OFFICIAL_WALKPATH
+ if( !path->search_long(NULL, bl->m, bl->x, bl->y, ud->to_x, ud->to_y, 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]
+ && (bl->type != BL_NPC) ) // If type is a NPC, please disregard.
+ return 0;
+#endif
+
memcpy(&ud->walkpath,&wpd,sizeof(wpd));
if (ud->target_to && ud->chaserange>1) {
@@ -106,11 +115,11 @@ int unit_walktoxy_sub(struct block_list *bl)
uint8 dir;
//Trim the last part of the path to account for range,
//but always move at least one cell when requested to move.
- for (i = ud->chaserange*10; i > 0 && ud->walkpath.path_len>1;) {
+ for (i = (ud->chaserange*10)-10; i > 0 && ud->walkpath.path_len>1;) {
ud->walkpath.path_len--;
dir = ud->walkpath.path[ud->walkpath.path_len];
if(dir&1)
- i -= MOVE_DIAGONAL_COST;
+ i -= MOVE_COST*20; //When chasing, units will target a diamond-shaped area in range [Playtester]
else
i -= MOVE_COST;
ud->to_x -= dirx[dir];
@@ -137,9 +146,79 @@ int unit_walktoxy_sub(struct block_list *bl)
return 1;
}
+/**
+ * Triggered on full step if stepaction is true and executes remembered action.
+ * @param tid: Timer ID
+ * @param tick: Unused
+ * @param id: ID of bl to do the action
+ * @param data: Not used
+ * @return 1: Success 0: Fail (No valid bl)
+ */
+int unit_step_timer(int tid, int64 tick, int id, intptr_t data)
+{
+ struct block_list *bl;
+ struct unit_data *ud;
+ int target_id;
+
+ bl = map->id2bl(id);
+
+ if (!bl || bl->prev == NULL)
+ return 0;
+
+ ud = unit->bl2ud(bl);
+
+ if(!ud)
+ return 0;
+
+ if(ud->steptimer != tid) {
+ ShowError("unit_step_timer mismatch %d != %d\n",ud->steptimer,tid);
+ return 0;
+ }
+
+ ud->steptimer = INVALID_TIMER;
+
+ if(!ud->stepaction)
+ return 0;
+
+ //Set to false here because if an error occurs, it should not be executed again
+ ud->stepaction = false;
+
+ if(!ud->target_to)
+ return 0;
+
+ //Flush target_to as it might contain map coordinates which should not be used by other functions
+ target_id = ud->target_to;
+ ud->target_to = 0;
+
+ //If stepaction is set then we remembered a client request that should be executed on the next step
+ //Execute request now if target is in attack range
+ if(ud->stepskill_id && skill->get_inf(ud->stepskill_id) & INF_GROUND_SKILL) {
+ //Execute ground skill
+ struct map_data *md = &map->list[bl->m];
+ unit->skilluse_pos(bl, target_id%md->xs, target_id/md->xs, ud->stepskill_id, ud->stepskill_lv);
+ } else {
+ //If a player has target_id set and target is in range, attempt attack
+ struct block_list *tbl = map->id2bl(target_id);
+ if (!tbl || !status->check_visibility(bl, tbl)) {
+ return 0;
+ }
+ if(ud->stepskill_id == 0) {
+ //Execute normal attack
+ unit->attack(bl, tbl->id, (ud->state.attack_continue) + 2);
+ } else {
+ //Execute non-ground skill
+ unit->skilluse_id(bl, tbl->id, ud->stepskill_id, ud->stepskill_lv);
+ }
+ }
+
+ return 1;
+}
+
+
int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) {
int i;
int x,y,dx,dy;
+ unsigned char icewall_walk_block;
uint8 dir;
struct block_list *bl;
struct map_session_data *sd;
@@ -178,9 +257,34 @@ int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) {
dx = dirx[(int)dir];
dy = diry[(int)dir];
- if(map->getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS))
+ //Get icewall walk block depending on boss mode (players can't be trapped)
+ if(md && md->status.mode&MD_BOSS)
+ icewall_walk_block = battle_config.boss_icewall_walk_block;
+ else if(md)
+ icewall_walk_block = battle_config.mob_icewall_walk_block;
+ else
+ icewall_walk_block = 0;
+
+ //Monsters will walk into an icewall from the west and south if they already started walking
+ if(map->getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS)
+ && (icewall_walk_block == 0 || !map->getcell(bl->m,x+dx,y+dy,CELL_CHKICEWALL) || dx < 0 || dy < 0))
return unit->walktoxy_sub(bl);
+ //Monsters can only leave icewalls to the west and south
+ //But if movement fails more than icewall_walk_block times, they can ignore this rule
+ if(md && md->walktoxy_fail_count < icewall_walk_block && map->getcell(bl->m,x,y,CELL_CHKICEWALL) && (dx > 0 || dy > 0)) {
+ //Needs to be done here so that rudeattack skills are invoked
+ md->walktoxy_fail_count++;
+ clif->fixpos(bl);
+ //Monsters in this situation first use a chase skill, then unlock target and then use an idle skill
+ if (!(++ud->walk_count%WALK_SKILL_INTERVAL))
+ mob->skill_use(md, tick, -1);
+ mob->unlocktarget(md, tick);
+ if (!(++ud->walk_count%WALK_SKILL_INTERVAL))
+ mob->skill_use(md, tick, -1);
+ return 0;
+ }
+
//Refresh view for all those we lose sight
map->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl);
@@ -205,7 +309,7 @@ int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) {
if (bl->prev == NULL) //Script could have warped char, abort remaining of the function.
return 0;
} else
- sd->areanpc_id=0;
+ npc->untouch_areanpc(sd, bl->m, x, y);
if( sd->md ) { // mercenary should be warped after being 3 seconds too far from the master [greenbox]
if( !check_distance_bl(&sd->bl, &sd->md->bl, MAX_MER_DISTANCE) ) {
@@ -217,7 +321,6 @@ int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) {
}
} else // reset the tick, he is not far anymore
sd->md->masterteleport_timer = 0;
-
}
if( sd->hd ) {
if( homun_alive(sd->hd) && !check_distance_bl(&sd->bl, &sd->hd->bl, MAX_MER_DISTANCE) ) {
@@ -231,6 +334,8 @@ int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) {
sd->hd->masterteleport_timer = 0;
}
} else if (md) {
+ //Movement was successful, reset walktoxy_fail_count
+ md->walktoxy_fail_count = 0;
if( map->getcell(bl->m,x,y,CELL_CHKNPC) ) {
if( npc->touch_areanpc2(md) ) return 0; // Warped
} else
@@ -238,12 +343,15 @@ int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) {
if (md->min_chase > md->db->range3) md->min_chase--;
//Walk skills are triggered regardless of target due to the idle-walk mob state.
//But avoid triggering on stop-walk calls.
- if(tid != INVALID_TIMER &&
- !(ud->walk_count%WALK_SKILL_INTERVAL) &&
- mob->skill_use(md, tick, -1))
- {
- if (!(ud->skill_id == NPC_SELFDESTRUCTION && ud->skilltimer != INVALID_TIMER))
- { //Skill used, abort walking
+ if (tid != INVALID_TIMER
+ && !(ud->walk_count%WALK_SKILL_INTERVAL)
+ && map->list[bl->m].users > 0
+ && mob->skill_use(md, tick, -1)
+ ) {
+ if (!(ud->skill_id == NPC_SELFDESTRUCTION && ud->skilltimer != INVALID_TIMER)
+ && md->state.skillstate != MSS_WALK //Walk skills are supposed to be used while walking
+ ) {
+ //Skill used, abort walking
clif->fixpos(bl); //Fix position as walk has been canceled.
return 0;
}
@@ -275,8 +383,29 @@ int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) {
if(tid == INVALID_TIMER) //A directly invoked timer is from battle_stop_walking, therefore the rest is irrelevant.
return 0;
- if(ud->state.change_walk_target)
- return unit->walktoxy_sub(bl);
+ //If stepaction is set then we remembered a client request that should be executed on the next step
+ if (ud->stepaction && ud->target_to) {
+ //Delete old stepaction even if not executed yet, the latest command is what counts
+ if(ud->steptimer != INVALID_TIMER) {
+ timer->delete(ud->steptimer, unit->step_timer);
+ ud->steptimer = INVALID_TIMER;
+ }
+ //Delay stepactions by half a step (so they are executed at full step)
+ if(ud->walkpath.path[ud->walkpath.path_pos]&1)
+ i = status->get_speed(bl)*14/20;
+ else
+ i = status->get_speed(bl)/2;
+ ud->steptimer = timer->add(tick+i, unit->step_timer, bl->id, 0);
+ }
+
+ if(ud->state.change_walk_target) {
+ if(unit->walktoxy_sub(bl)) {
+ return 1;
+ } else {
+ clif->fixpos(bl);
+ return 0;
+ }
+ }
ud->walkpath.path_pos++;
if(ud->walkpath.path_pos>=ud->walkpath.path_len)
@@ -294,7 +423,7 @@ int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) {
//Keep trying to run.
if ( !(unit->run(bl, NULL, SC_RUN) || unit->run(bl, sd, SC_WUGDASH)) )
ud->state.running = 0;
- } else if (ud->target_to) {
+ } else if (!ud->stepaction && ud->target_to) {
//Update target trajectory.
struct block_list *tbl = map->id2bl(ud->target_to);
if (!tbl || !status->check_visibility(bl, tbl)) {
@@ -308,21 +437,31 @@ int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) {
}
if (tbl->m == bl->m && check_distance_bl(bl, tbl, ud->chaserange)) {
//Reached destination.
- if (ud->state.attack_continue)
- { //Aegis uses one before every attack, we should
+ if (ud->state.attack_continue) {
+ //Aegis uses one before every attack, we should
//only need this one for syncing purposes. [Skotlex]
ud->target_to = 0;
clif->fixpos(bl);
unit->attack(bl, tbl->id, ud->state.attack_continue);
}
} else { //Update chase-path
- unit->walktobl(bl, tbl, ud->chaserange, ud->state.walk_easy|(ud->state.attack_continue?2:0));
+ unit->walktobl(bl, tbl, ud->chaserange, ud->state.walk_easy|(ud->state.attack_continue? 1 : 0));
return 0;
}
} else {
//Stopped walking. Update to_x and to_y to current location [Skotlex]
ud->to_x = bl->x;
ud->to_y = bl->y;
+
+ if(map->count_oncell(bl->m, x, y, BL_CHAR|BL_NPC, 1) > battle_config.official_cell_stack_limit) {
+ //Walked on occupied cell, call unit_walktoxy again
+ if(ud->steptimer != INVALID_TIMER) {
+ //Execute step timer on next step instead
+ timer->delete(ud->steptimer, unit->step_timer);
+ ud->steptimer = INVALID_TIMER;
+ }
+ return unit->walktoxy(bl, x, y, 8);
+ }
}
return 0;
}
@@ -340,6 +479,7 @@ int unit_delay_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) {
//&1 -> 1/0 = easy/hard
//&2 -> force walking
//&4 -> Delay walking if the reason you can't walk is the canwalk delay
+//&8 -> Search for an unoccupied cell and cancel if none available
int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
{
struct unit_data* ud = NULL;
@@ -352,6 +492,9 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
if( ud == NULL) return 0;
+ if ((flag&8) && !map->closest_freecell(bl->m, &x, &y, BL_CHAR|BL_NPC, 1)) //This might change x and y
+ return 0;
+
if (!path->search(&wpd, bl->m, bl->x, bl->y, x, y, flag&1, CELL_CHKNOPASS)) // Count walk path cells
return 0;
@@ -377,7 +520,7 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
ud->state.walk_easy = flag&1;
ud->to_x = x;
ud->to_y = y;
- unit->set_target(ud, 0);
+ unit->stop_attack(bl); //Sets target to 0
sc = status->get_sc(bl);
if( sc ) {
@@ -394,11 +537,6 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
return 1;
}
- if(ud->attacktimer != INVALID_TIMER) {
- timer->delete( ud->attacktimer, unit->attack_timer );
- ud->attacktimer = INVALID_TIMER;
- }
-
return unit->walktoxy_sub(bl);
}
@@ -430,8 +568,8 @@ int unit_walktobl_sub(int tid, int64 tick, int id, intptr_t data) {
// if flag&2, start attacking upon arrival within range, otherwise just walk to that character.
int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int flag)
{
- struct unit_data *ud = NULL;
- struct status_change *sc = NULL;
+ struct unit_data *ud = NULL;
+ struct status_change *sc = NULL;
nullpo_ret(bl);
nullpo_ret(tbl);
@@ -447,13 +585,17 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
ud->to_y = bl->y;
ud->target_to = 0;
return 0;
+ } else if (range == 0) {
+ //Should walk on the same cell as target (for looters)
+ ud->to_x = tbl->x;
+ ud->to_y = tbl->y;
}
ud->state.walk_easy = flag&1;
ud->target_to = tbl->id;
ud->chaserange = range; //Note that if flag&2, this SHOULD be attack-range
ud->state.attack_continue = flag&2?1:0; //Chase to attack.
- unit->set_target(ud, 0);
+ unit->stop_attack(bl); //Sets target to 0
sc = status->get_sc(bl);
if (sc && (sc->data[SC_CONFUSION] || sc->data[SC__CHAOS])) //Randomize the target position
@@ -465,8 +607,8 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
return 1;
}
- if(DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0)
- { //Can't move, wait a bit before invoking the movement.
+ if (DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0) {
+ //Can't move, wait a bit before invoking the movement.
timer->add(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target);
return 1;
}
@@ -474,11 +616,6 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
if(!unit->can_move(bl))
return 0;
- if(ud->attacktimer != INVALID_TIMER) {
- timer->delete( ud->attacktimer, unit->attack_timer );
- ud->attacktimer = INVALID_TIMER;
- }
-
if (unit->walktoxy_sub(bl)) {
set_mobstate(bl, flag&2);
return 1;
@@ -548,7 +685,7 @@ bool unit_run( struct block_list *bl, struct map_session_data *sd, enum sc_type
break;
//if sprinting and there's a PC/Mob/NPC, block the path [Kevin]
- if( map->count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC) )
+ if ( map->count_oncell(bl->m, to_x + dir_x, to_y + dir_y, BL_PC | BL_MOB | BL_NPC, 0x2) )
break;
to_x += dir_x;
@@ -630,7 +767,7 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool
if (bl->prev == NULL) //Script could have warped char, abort remaining of the function.
return 0;
} else
- sd->areanpc_id=0;
+ npc->untouch_areanpc(sd, bl->m, bl->x, bl->y);
if( sd->status.pet_id > 0 && sd->pd && sd->pd->pet.intimate > 0 )
{ // Check if pet needs to be teleported. [Skotlex]
@@ -666,7 +803,7 @@ int unit_setdir(struct block_list *bl,unsigned char dir)
uint8 unit_getdir(struct block_list *bl) {
struct unit_data *ud;
nullpo_ret(bl);
-
+
if( bl->type == BL_NPC )
return ((TBL_NPC*)bl)->dir;
ud = unit->bl2ud(bl);
@@ -700,6 +837,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
}
if( sd ) {
+ unit->stop_stepaction(bl); //Stop stepaction when knocked back
sd->ud.to_x = nx;
sd->ud.to_y = ny;
}
@@ -729,7 +867,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
if(map->getcell(bl->m, bl->x, bl->y, CELL_CHKNPC)) {
npc->touch_areanpc(sd, bl->m, bl->x, bl->y);
} else {
- sd->areanpc_id = 0;
+ npc->untouch_areanpc(sd, bl->m, bl->x, bl->y);;
}
}
}
@@ -930,7 +1068,7 @@ int unit_can_move(struct block_list *bl) {
|| sc->data[SC_ELECTRICSHOCKER]
|| sc->data[SC_WUGBITE]
|| sc->data[SC_THORNS_TRAP]
- || sc->data[SC_MAGNETICFIELD]
+ || ( sc->data[SC_MAGNETICFIELD] && !sc->data[SC_HOVERING] )
|| sc->data[SC__MANHOLE]
|| sc->data[SC_CURSEDCIRCLE_ATKER]
|| sc->data[SC_CURSEDCIRCLE_TARGET]
@@ -939,7 +1077,6 @@ int unit_can_move(struct block_list *bl) {
|| (sc->data[SC_CAMOUFLAGE] && sc->data[SC_CAMOUFLAGE]->val1 < 3 && !(sc->data[SC_CAMOUFLAGE]->val3&1))
|| sc->data[SC_MEIKYOUSISUI]
|| sc->data[SC_KG_KAGEHUMI]
- || sc->data[SC_KYOUGAKU]
|| sc->data[SC_NEEDLE_OF_PARALYZE]
|| sc->data[SC_VACUUM_EXTREME]
|| (sc->data[SC_FEAR] && sc->data[SC_FEAR]->val2 > 0)
@@ -956,7 +1093,6 @@ int unit_can_move(struct block_list *bl) {
)
)
return 0;
-
if (sc->opt1 > 0 && sc->opt1 != OPT1_STONEWAIT && sc->opt1 != OPT1_BURNING && !(sc->opt1 == OPT1_CRYSTALIZE && bl->type == BL_MOB))
return 0;
@@ -965,6 +1101,17 @@ int unit_can_move(struct block_list *bl) {
return 0;
}
+
+ // Icewall walk block special trapped monster mode
+ if(bl->type == BL_MOB) {
+ struct mob_data *md = BL_CAST(BL_MOB, bl);
+ if(md && ((md->status.mode&MD_BOSS && battle_config.boss_icewall_walk_block == 1 && map->getcell(bl->m,bl->x,bl->y,CELL_CHKICEWALL))
+ || (!(md->status.mode&MD_BOSS) && battle_config.mob_icewall_walk_block == 1 && map->getcell(bl->m,bl->x,bl->y,CELL_CHKICEWALL)))) {
+ md->walktoxy_fail_count = 1; //Make sure rudeattacked skills are invoked
+ return 0;
+ }
+ }
+
return 1;
}
@@ -1000,25 +1147,26 @@ int unit_set_walkdelay(struct block_list *bl, int64 tick, int delay, int type) {
struct unit_data *ud = unit->bl2ud(bl);
if (delay <= 0 || !ud) return 0;
- /**
- * MvP mobs have no walk delay
- **/
- if( bl->type == BL_MOB && (((TBL_MOB*)bl)->status.mode&MD_BOSS) )
- return 0;
-
if (type) {
+ //Bosses can ignore skill induced walkdelay (but not damage induced)
+ if(bl->type == BL_MOB && (((TBL_MOB*)bl)->status.mode&MD_BOSS))
+ return 0;
+ //Make sure walk delay is not decreased
if (DIFF_TICK(ud->canmove_tick, tick+delay) > 0)
return 0;
} else {
//Don't set walk delays when already trapped.
if (!unit->can_move(bl))
return 0;
+ //Immune to being stopped for double the flinch time
+ if (DIFF_TICK(ud->canmove_tick, tick-delay) > 0)
+ return 0;
}
ud->canmove_tick = tick + delay;
- if (ud->walktimer != INVALID_TIMER)
- { //Stop walking, if chasing, readjust timers.
- if (delay == 1)
- { //Minimal delay (walk-delay) disabled. Just stop walking.
+ if (ud->walktimer != INVALID_TIMER) {
+ //Stop walking, if chasing, readjust timers.
+ if (delay == 1) {
+ //Minimal delay (walk-delay) disabled. Just stop walking.
unit->stop_walking(bl,4);
} else {
//Resume running after can move again [Kevin]
@@ -1028,7 +1176,7 @@ int unit_set_walkdelay(struct block_list *bl, int64 tick, int delay, int type) {
}
else
{
- unit->stop_walking(bl,2|4);
+ unit->stop_walking(bl,4);
if(ud->target)
timer->add(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target);
}
@@ -1086,7 +1234,8 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
if(skill->not_ok(skill_id, sd)) // [MouseJstr]
return 0;
- switch(skill_id) { //Check for skills that auto-select target
+ switch (skill_id) {
+ //Check for skills that auto-select target
case MO_CHAINCOMBO:
if (sc && sc->data[SC_BLADESTOP]) {
if ((target=map->id2bl(sc->data[SC_BLADESTOP]->val4)) == NULL)
@@ -1103,6 +1252,17 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
return 0;
}
break;
+ case GC_WEAPONCRUSH:
+ if( sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == GC_WEAPONBLOCKING ) {
+ if( (target=map->id2bl(sc->data[SC_COMBOATTACK]->val2)) == NULL ) {
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_GC_WEAPONBLOCKING,0);
+ return 0;
+ }
+ } else {
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_GC_WEAPONBLOCKING,0);
+ return 0;
+ }
+ break;
}
if (target)
target_id = target->id;
@@ -1138,33 +1298,48 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
if(!status->check_skilluse(src, target, skill_id, 0))
return 0;
+ if( src != target && status->isdead(target) ) {
+ /**
+ * Skills that may be cast on dead targets
+ **/
+ switch( skill_id ) {
+ case NPC_WIDESOULDRAIN:
+ case PR_REDEMPTIO:
+ case ALL_RESURRECTION:
+ case WM_DEADHILLHERE:
+ break;
+ default:
+ return 1;
+ }
+ }
+
tstatus = status->get_status_data(target);
// Record the status of the previous skill)
- if(sd) {
+ if (sd) {
- if( (skill->get_inf2(skill_id)&INF2_ENSEMBLE_SKILL) && skill->check_pc_partner(sd, skill_id, &skill_lv, 1, 0) < 1 ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ if ((skill->get_inf2(skill_id)&INF2_ENSEMBLE_SKILL) && skill->check_pc_partner(sd, skill_id, &skill_lv, 1, 0) < 1) {
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
return 0;
}
-
- switch(skill_id){
+
+ switch (skill_id){
case SA_CASTCANCEL:
- if(ud->skill_id != skill_id){
+ if (ud->skill_id != skill_id){
sd->skill_id_old = ud->skill_id;
sd->skill_lv_old = ud->skill_lv;
}
break;
case BD_ENCORE:
//Prevent using the dance skill if you no longer have the skill in your tree.
- if(!sd->skill_id_dance || pc->checkskill(sd,sd->skill_id_dance)<=0){
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ if (!sd->skill_id_dance || pc->checkskill(sd, sd->skill_id_dance) <= 0){
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
return 0;
}
sd->skill_id_old = skill_id;
break;
case WL_WHITEIMPRISON:
- if( battle->check_target(src,target,BCT_SELF|BCT_ENEMY) < 0 ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_TOTARGET,0);
+ if (battle->check_target(src, target, BCT_SELF | BCT_ENEMY) < 0) {
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_TOTARGET, 0);
return 0;
}
break;
@@ -1175,13 +1350,20 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
sd->skill_lv_old = skill_lv;
break;
}
- /* temporarily disabled, awaiting for kenpachi to detail this so we can make it work properly */
+ }
+
+ if (sd || src->type == BL_HOM){
+ if (!sd && (target = battle->get_master(src)))
+ sd = map->id2sd(target->id);
+ if (sd){
+ /* temporarily disabled, awaiting for kenpachi to detail this so we can make it work properly */
#if 0
- if ( sd->skillitem != skill_id && !skill->check_condition_castbegin(sd, skill_id, skill_lv) )
+ if (sd->skillitem != skill_id && !skill->check_condition_castbegin(sd, skill_id, skill_lv))
#else
- if ( !skill->check_condition_castbegin(sd, skill_id, skill_lv) )
+ if (!skill->check_condition_castbegin(sd, skill_id, skill_lv))
#endif
- return 0;
+ return 0;
+ }
}
if( src->type == BL_MOB )
@@ -1198,6 +1380,18 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
else
range = skill->get_range2(src, skill_id, skill_lv); // Skill cast distance from database
+ // New action request received, delete previous action request if not executed yet
+ if(ud->stepaction || ud->steptimer != INVALID_TIMER)
+ unit->stop_stepaction(src);
+ // Remember the skill request from the client while walking to the next cell
+ if(src->type == BL_PC && ud->walktimer != INVALID_TIMER && !battle->check_range(src, target, range-1)) {
+ ud->stepaction = true;
+ ud->target_to = target_id;
+ ud->stepskill_id = skill_id;
+ ud->stepskill_lv = skill_lv;
+ return 0; // Attacking will be handled by unit_walktoxy_timer in this case
+ }
+
//Check range when not using skill on yourself or is a combo-skill during attack
//(these are supposed to always have the same range as your attack)
if( src->id != target_id && (!temp || ud->attacktimer == INVALID_TIMER) ) {
@@ -1241,6 +1435,25 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
casttime = -1;
temp = 1;
break;
+ case CR_DEVOTION:
+ if (sd) {
+ int i = 0, count = min(skill_lv, 5);
+ ARR_FIND(0, count, i, sd->devotion[i] == target_id);
+ if (i == count) {
+ ARR_FIND(0, count, i, sd->devotion[i] == 0);
+ if(i == count) {
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
+ return 0; // Can't cast on other characters when limit is reached
+ }
+ }
+ }
+ break;
+ case AB_CLEARANCE:
+ if( target->type != BL_MOB && battle->check_target(src,target,BCT_PARTY) <= 0 && sd ) {
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_TOTARGET, 0);
+ return 0;
+ }
+ break;
case SR_GATEOFHELL:
case SR_TIGERCANNON:
if (sc && sc->data[SC_COMBOATTACK] &&
@@ -1277,7 +1490,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
case RA_WUGDASH:
if (sc && sc->data[SC_WUGDASH])
casttime = -1;
- break;
+ break;
case EL_WIND_SLASH:
case EL_HURRICANE:
case EL_TYPOON_MIS:
@@ -1320,7 +1533,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
/**
* why the if else chain: these 3 status do not stack, so its efficient that way.
**/
- if( sc->data[SC_CLOAKING] && !(sc->data[SC_CLOAKING]->val4&4) && skill_id != AS_CLOAKING ) {
+ if( sc->data[SC_CLOAKING] && !(sc->data[SC_CLOAKING]->val4&4) && skill_id != AS_CLOAKING ) {
status_change_end(src, SC_CLOAKING, INVALID_TIMER);
if (!src->prev) return 0; //Warped away!
} else if( sc->data[SC_CLOAKINGEXCEED] && !(sc->data[SC_CLOAKINGEXCEED]->val4&4) && skill_id != GC_CLOAKINGEXCEED ) {
@@ -1328,10 +1541,10 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
if (!src->prev) return 0;
}
}
-
+
if(!ud->state.running) //need TK_RUN or WUGDASH handler to be done before that, see bugreport:6026
unit->stop_walking(src,1);// even though this is not how official works but this will do the trick. bugreport:6829
-
+
// in official this is triggered even if no cast time.
clif->skillcasting(src, src->id, target_id, 0,0, skill_id, skill->get_ele(skill_id, skill_lv), casttime);
if( casttime > 0 || temp )
@@ -1434,13 +1647,11 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
if( skill->not_ok(skill_id, sd) || !skill->check_condition_castbegin(sd, skill_id, skill_lv) )
return 0;
/**
- * "WHY IS IT HEREE": pneuma cannot be canceled past this point, the client displays the animation even,
- * if we cancel it from nodamage_id, so it has to be here for it to not display the animation.
+ * "WHY IS IT HEREE": ice wall cannot be canceled past this point, the client displays the animation even,
+ * if we cancel it from castend_pos, so it has to be here for it to not display the animation.
**/
- if( skill_id == AL_PNEUMA && map->getcell(src->m, skill_x, skill_y, CELL_CHKLANDPROTECTOR) ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ if ( skill_id == WZ_ICEWALL && map->getcell(src->m, skill_x, skill_y, CELL_CHKNOICEWALL) )
return 0;
- }
}
if (!status->check_skilluse(src, NULL, skill_id, 0))
@@ -1452,7 +1663,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
return 0;
}
- /* Check range and obstacle */
+ /* Check range and obstacle */
bl.type = BL_NUL;
bl.m = src->m;
bl.x = skill_x;
@@ -1463,10 +1674,24 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
else
range = skill->get_range2(src, skill_id, skill_lv); // Skill cast distance from database
+ // New action request received, delete previous action request if not executed yet
+ if(ud->stepaction || ud->steptimer != INVALID_TIMER)
+ unit->stop_stepaction(src);
+ // Remember the skill request from the client while walking to the next cell
+ if(src->type == BL_PC && ud->walktimer != INVALID_TIMER && !battle->check_range(src, &bl, range-1)) {
+ struct map_data *md = &map->list[src->m];
+ // Convert coordinates to target_to so we can use it as target later
+ ud->stepaction = true;
+ ud->target_to = (skill_x + skill_y*md->xs);
+ ud->stepskill_id = skill_id;
+ ud->stepskill_lv = skill_lv;
+ return 0; // Attacking will be handled by unit_walktoxy_timer in this case
+ }
+
if( skill->get_state(ud->skill_id) == ST_MOVE_ENABLE ) {
if( !unit->can_reach_bl(src, &bl, range + 1, 1, NULL, NULL) )
return 0; //Walk-path check failed.
- } else if( !battle->check_range(src, &bl, range + 1) )
+ } else if( !battle->check_range(src, &bl, range) )
return 0; //Arrow-path check failed.
unit->stop_attack(src);
@@ -1486,14 +1711,14 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
ud->state.skillcastcancel = castcancel&&casttime>0?1:0;
if( !sd || sd->skillitem != skill_id || skill->get_cast(skill_id,skill_lv) )
ud->canact_tick = tick + casttime + 100;
-// if( sd )
-// {
-// switch( skill_id )
-// {
-// case ????:
-// sd->canequip_tick = tick + casttime;
-// }
-// }
+#if 0
+ if (sd) {
+ switch (skill_id) {
+ case ????:
+ sd->canequip_tick = tick + casttime;
+ }
+ }
+#endif // 0
ud->skill_id = skill_id;
ud->skill_lv = skill_lv;
ud->skillx = skill_x;
@@ -1548,18 +1773,51 @@ int unit_set_target(struct unit_data* ud, int target_id)
return 0;
}
-int unit_stop_attack(struct block_list *bl)
+/**
+ * Stop a unit's attacks
+ * @param bl: Object to stop
+ */
+void unit_stop_attack(struct block_list *bl)
{
- struct unit_data *ud = unit->bl2ud(bl);
- nullpo_ret(bl);
+ struct unit_data *ud;
+ nullpo_retv(bl);
+ ud = unit->bl2ud(bl);
+ nullpo_retv(ud);
- if(!ud || ud->attacktimer == INVALID_TIMER)
- return 0;
+ //Clear target
+ unit->set_target(ud, 0);
+
+ if(ud->attacktimer == INVALID_TIMER)
+ return;
- timer->delete( ud->attacktimer, unit->attack_timer );
+ //Clear timer
+ timer->delete(ud->attacktimer, unit->attack_timer);
ud->attacktimer = INVALID_TIMER;
- unit->set_target(ud, 0);
- return 0;
+}
+
+/**
+ * Stop a unit's step action
+ * @param bl: Object to stop
+ */
+void unit_stop_stepaction(struct block_list *bl)
+{
+ struct unit_data *ud;
+ nullpo_retv(bl);
+ ud = unit->bl2ud(bl);
+ nullpo_retv(ud);
+
+ //Clear remembered step action
+ ud->stepaction = false;
+ ud->target_to = 0;
+ ud->stepskill_id = 0;
+ ud->stepskill_lv = 0;
+
+ if(ud->steptimer == INVALID_TIMER)
+ return;
+
+ //Clear timer
+ timer->delete(ud->steptimer, unit->step_timer);
+ ud->steptimer = INVALID_TIMER;
}
//Means current target is unattackable. For now only unlocks mobs.
@@ -1568,6 +1826,7 @@ int unit_unattackable(struct block_list *bl)
struct unit_data *ud = unit->bl2ud(bl);
if (ud) {
ud->state.attack_continue = 0;
+ ud->state.step_attack = 0;
unit->set_target(ud, 0);
}
@@ -1585,6 +1844,7 @@ int unit_unattackable(struct block_list *bl)
int unit_attack(struct block_list *src,int target_id,int continuous) {
struct block_list *target;
struct unit_data *ud;
+ int range;
nullpo_ret(ud = unit->bl2ud(src));
@@ -1613,19 +1873,30 @@ int unit_attack(struct block_list *src,int target_id,int continuous) {
unit->unattackable(src);
return 1;
}
- ud->state.attack_continue = continuous;
+ ud->state.attack_continue = (continuous&1)?1:0;
+ ud->state.step_attack = (continuous&2)?1:0;
unit->set_target(ud, target_id);
+ range = status_get_range(src);
+
if (continuous) //If you're to attack continuously, set to auto-case character
- ud->chaserange = status_get_range(src);
+ ud->chaserange = range;
//Just change target/type. [Skotlex]
if(ud->attacktimer != INVALID_TIMER)
return 0;
- //Set Mob's ANGRY/BERSERK states.
- if(src->type == BL_MOB)
- ((TBL_MOB*)src)->state.skillstate = ((TBL_MOB*)src)->state.aggressive?MSS_ANGRY:MSS_BERSERK;
+ // New action request received, delete previous action request if not executed yet
+ if(ud->stepaction || ud->steptimer != INVALID_TIMER)
+ unit->stop_stepaction(src);
+ // Remember the attack request from the client while walking to the next cell
+ if(src->type == BL_PC && ud->walktimer != INVALID_TIMER && !battle->check_range(src, target, range-1)) {
+ ud->stepaction = true;
+ ud->target_to = ud->target;
+ ud->stepskill_id = 0;
+ ud->stepskill_lv = 0;
+ return 0; // Attacking will be handled by unit_walktoxy_timer in this case
+ }
if(DIFF_TICK(ud->attackabletime, timer->gettick()) > 0)
//Do attack next time it is possible. [Skotlex]
@@ -1710,7 +1981,7 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range,
/*==========================================
* Calculates position of Pet/Mercenary/Homunculus/Elemental
*------------------------------------------*/
-int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir)
+int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir)
{
int dx, dy, x, y, i, k;
struct unit_data *ud = unit->bl2ud(bl);
@@ -1827,15 +2098,19 @@ int unit_attack_timer_sub(struct block_list* src, int tid, int64 tick) {
}
sstatus = status->get_status_data(src);
- range = sstatus->rhw.range + 1;
+ range = sstatus->rhw.range;
- if( unit->is_walking(target) )
- range++; //Extra range when chasing
- if( !check_distance_bl(src,target,range) ) { //Chase if required.
- if(sd)
- clif->movetoattack(sd,target);
- else if(ud->state.attack_continue)
- unit->walktobl(src,target,ud->chaserange,ud->state.walk_easy|2);
+ if( (unit->is_walking(target) || ud->state.step_attack)
+ && (target->type == BL_PC || !map->getcell(target->m,target->x,target->y,CELL_CHKICEWALL)) )
+ range++; // Extra range when chasing (does not apply to mobs locked in an icewall)
+
+ if(sd && !check_distance_client_bl(src,target,range)) {
+ // Player tries to attack but target is too far, notify client
+ clif->movetoattack(sd,target);
+ return 1;
+ } else if(md && !check_distance_bl(src,target,range)) {
+ // Monster: Chase if required
+ unit->walktobl(src,target,ud->chaserange,ud->state.walk_easy|2);
return 1;
}
if( !battle->check_range(src,target,range) ) {
@@ -1857,10 +2132,17 @@ int unit_attack_timer_sub(struct block_list* src, int tid, int64 tick) {
if(ud->walktimer != INVALID_TIMER)
unit->stop_walking(src,1);
if(md) {
- if (mob->skill_use(md,tick,-1))
- return 1;
- if (sstatus->mode&MD_ASSIST && DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME)
- { // Link monsters nearby [Skotlex]
+ //First attack is always a normal attack
+ if(md->state.skillstate == MSS_ANGRY || md->state.skillstate == MSS_BERSERK) {
+ if (mob->skill_use(md,tick,-1))
+ return 1;
+ } else {
+ // Set mob's ANGRY/BERSERK states.
+ md->state.skillstate = md->state.aggressive?MSS_ANGRY:MSS_BERSERK;
+ }
+
+ if (sstatus->mode&MD_ASSIST && DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME) {
+ // Link monsters nearby [Skotlex]
md->last_linktime = tick;
map->foreachinrange(mob->linksearch, src, md->db->range2, BL_MOB, md->class_, target, tick);
}
@@ -1882,7 +2164,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, int64 tick) {
return 1;
ud->attackabletime = tick + sstatus->adelay;
-// You can't move if you can't attack neither.
+ // You can't move if you can't attack neither.
if (src->type&battle_config.attack_walk_delay)
unit->set_walkdelay(src, tick, sstatus->amotion, 1);
}
@@ -1927,8 +2209,8 @@ int unit_skillcastcancel(struct block_list *bl,int type)
if (!ud->state.skillcastcancel)
return 0;
- if (sd && (sd->special_state.no_castcancel2 ||
- ( sd->special_state.no_castcancel && !map_flag_gvg(bl->m) && !map->list[bl->m].flag.battleground))) //fixed flags being read the wrong way around [blackhole89]
+ if (sd && (sd->special_state.no_castcancel2
+ || (sd->special_state.no_castcancel && !map_flag_gvg(bl->m) && !map->list[bl->m].flag.battleground))) //fixed flags being read the wrong way around [blackhole89]
return 0;
}
@@ -1975,6 +2257,7 @@ void unit_dataset(struct block_list *bl) {
ud->walktimer = INVALID_TIMER;
ud->skilltimer = INVALID_TIMER;
ud->attacktimer = INVALID_TIMER;
+ ud->steptimer = INVALID_TIMER;
ud->attackabletime =
ud->canact_tick =
ud->canmove_tick = timer->gettick();
@@ -2040,15 +2323,19 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i
map->freeblock_lock();
- unit->set_target(ud, 0);
-
if (ud->walktimer != INVALID_TIMER)
unit->stop_walking(bl,0);
- if (ud->attacktimer != INVALID_TIMER)
- unit->stop_attack(bl);
if (ud->skilltimer != INVALID_TIMER)
unit->skillcastcancel(bl,0);
+ //Clear target even if there is no timer
+ if (ud->target || ud->attacktimer != INVALID_TIMER)
+ unit->stop_attack(bl);
+
+ //Clear stepaction even if there is no timer
+ if (ud->stepaction || ud->steptimer != INVALID_TIMER)
+ unit->stop_stepaction(bl);
+
// Do not reset can-act delay. [Skotlex]
ud->attackabletime = ud->canmove_tick /*= ud->canact_tick*/ = timer->gettick();
if(sc && sc->count ) { //map-change/warp dispells.
@@ -2172,7 +2459,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i
sd->debug_file, sd->debug_line, sd->debug_func, file, line, func);
} else if (--map->list[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex]
map->removemobs(bl->m);
- if( !(sd->sc.option&OPTION_INVISIBLE) ) {
+ if (!(pc_isinvisible(sd))) {
// decrement the number of active pvp players on the map
--map->list[bl->m].users_pvp;
}
@@ -2267,10 +2554,10 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i
void unit_remove_map_pc(struct map_session_data *sd, clr_type clrtype)
{
unit->remove_map(&sd->bl,clrtype,ALC_MARK);
-
+
//CLR_RESPAWN is the warp from logging out, CLR_TELEPORT is the warp from teleporting, but pets/homunc need to just 'vanish' instead of showing the warping animation.
if (clrtype == CLR_RESPAWN || clrtype == CLR_TELEPORT) clrtype = CLR_OUTSIGHT;
-
+
if(sd->pd)
unit->remove_map(&sd->pd->bl, clrtype, ALC_MARK);
if(homun_alive(sd->hd))
@@ -2299,7 +2586,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
nullpo_ret(ud);
map->freeblock_lock();
- if( bl->prev ) //Players are supposed to logout with a "warp" effect.
+ if( bl->prev ) //Players are supposed to logout with a "warp" effect.
unit->remove_map(bl, clrtype, ALC_MARK);
switch( bl->type ) {
@@ -2310,7 +2597,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
unsigned int k;
sd->state.loggingout = 1;
-
+
if( status->isdead(bl) )
pc->setrestartvalue(sd,2);
@@ -2332,8 +2619,8 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
pc->cleareventtimer(sd);
pc->inventory_rental_clear(sd);
pc->delspiritball(sd,sd->spiritball,1);
- for(i = 1; i < 5; i++)
- pc->del_charm(sd, sd->charm[i], i);
+ for(i = SPIRITS_TYPE_CHARM_WATER; i < SPIRITS_TYPE_SPHERE; i++)
+ pc->del_charm(sd, sd->spiritcharm[i], i);
if( sd->st && sd->st->state != RUN ) {// free attached scripts that are waiting
script->free_state(sd->st);
@@ -2369,7 +2656,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
sd->quest_log = NULL;
sd->num_quests = sd->avail_quests = 0;
}
-
+
for( k = 0; k < sd->hdatac; k++ ) {
if( sd->hdata[k]->flag.free ) {
aFree(sd->hdata[k]->data);
@@ -2393,10 +2680,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
if( pd->s_skill )
{
if (pd->s_skill->timer != INVALID_TIMER) {
- if (pd->s_skill->id)
- timer->delete(pd->s_skill->timer, pet->skill_support_timer);
- else
- timer->delete(pd->s_skill->timer, pet->heal_timer);
+ timer->delete(pd->s_skill->timer, pet->skill_support_timer);
}
aFree(pd->s_skill);
pd->s_skill = NULL;
@@ -2423,10 +2707,10 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
aFree (pd->loot);
pd->loot = NULL;
}
- if( pd->pet.intimate > 0 )
+ if (pd->pet.intimate > 0) {
intif->save_petdata(pd->pet.account_id,&pd->pet);
- else
- { //Remove pet.
+ } else {
+ //Remove pet.
intif->delete_petdata(pd->pet.pet_id);
if (sd) sd->status.pet_id = 0;
}
@@ -2436,6 +2720,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
}
case BL_MOB:
{
+ unsigned int k;
struct mob_data *md = (struct mob_data*)bl;
if( md->spawn_timer != INVALID_TIMER )
{
@@ -2490,6 +2775,15 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
mob->clone_delete(md);
if( md->tomb_nid )
mob->mvptomb_destroy(md);
+
+ for (k = 0; k < md->hdatac; k++) {
+ if( md->hdata[k]->flag.free ) {
+ aFree(md->hdata[k]->data);
+ }
+ aFree(md->hdata[k]);
+ }
+ if (md->hdata)
+ aFree(md->hdata);
break;
}
case BL_HOM:
@@ -2561,6 +2855,7 @@ int do_init_unit(bool minimal) {
timer->add_func_list(unit->walktoxy_timer,"unit_walktoxy_timer");
timer->add_func_list(unit->walktobl_sub, "unit_walktobl_sub");
timer->add_func_list(unit->delay_walktoxy_timer,"unit_delay_walktoxy_timer");
+ timer->add_func_list(unit->step_timer,"unit_step_timer");
return 0;
}
@@ -2571,7 +2866,7 @@ int do_final_unit(void) {
void unit_defaults(void) {
unit = &unit_s;
-
+
unit->init = do_init_unit;
unit->final = do_final_unit;
/* */
@@ -2594,6 +2889,8 @@ void unit_defaults(void) {
unit->warp = unit_warp;
unit->stop_walking = unit_stop_walking;
unit->skilluse_id = unit_skilluse_id;
+ unit->step_timer = unit_step_timer;
+ unit->stop_stepaction = unit_stop_stepaction;
unit->is_walking = unit_is_walking;
unit->can_move = unit_can_move;
unit->resume_running = unit_resume_running;
diff --git a/src/map/unit.h b/src/map/unit.h
index 9b95bae41..881fa16f4 100644
--- a/src/map/unit.h
+++ b/src/map/unit.h
@@ -30,6 +30,9 @@ struct unit_data {
int attacktimer;
int walktimer;
int chaserange;
+ bool stepaction; //Action should be executed on step [Playtester]
+ int steptimer; //Timer that triggers the action [Playtester]
+ uint16 stepskill_id,stepskill_lv; //Remembers skill that should be casted on step [Playtester]
int64 attackabletime;
int64 canact_tick;
int64 canmove_tick;
@@ -40,6 +43,7 @@ struct unit_data {
unsigned change_walk_target : 1 ;
unsigned skillcastcancel : 1 ;
unsigned attack_continue : 1 ;
+ unsigned step_attack : 1;
unsigned walk_easy : 1 ;
unsigned running : 1;
unsigned speed_changed : 1;
@@ -93,6 +97,8 @@ struct unit_interface {
int (*warp) (struct block_list *bl, short m, short x, short y, clr_type type);
int (*stop_walking) (struct block_list *bl, int type);
int (*skilluse_id) (struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv);
+ int (*step_timer) (int tid, int64 tick, int id, intptr_t data);
+ void (*stop_stepaction) (struct block_list *bl);
int (*is_walking) (struct block_list *bl);
int (*can_move) (struct block_list *bl);
int (*resume_running) (int tid, int64 tick, int id, intptr_t data);
@@ -101,7 +107,7 @@ struct unit_interface {
int (*skilluse_pos) (struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv);
int (*skilluse_pos2) (struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel);
int (*set_target) (struct unit_data *ud, int target_id);
- int (*stop_attack) (struct block_list *bl);
+ void (*stop_attack) (struct block_list *bl);
int (*unattackable) (struct block_list *bl);
int (*attack) (struct block_list *src, int target_id, int continuous);
int (*cancel_combo) (struct block_list *bl);
diff --git a/src/map/vending.c b/src/map/vending.c
index 7e9393bf2..bd61d482f 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -134,11 +134,11 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
clif->buyvending(sd, idx, amount, 2); // you can not buy, because overweight
return;
}
-
+
//Check to see if cart/vend info is in sync.
if( vend[j].amount > vsd->status.cart[idx].amount )
vend[j].amount = vsd->status.cart[idx].amount;
-
+
// if they try to add packets (example: get twice or more 2 apples if marchand has only 3 apples).
// here, we check cumulative amounts
if( vend[j].amount < amount ) {
@@ -146,12 +146,12 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
clif->buyvending(sd, idx, vsd->vending[j].amount, 4); // not enough quantity
return;
}
-
+
vend[j].amount -= amount;
switch( pc->checkadditem(sd, vsd->status.cart[idx].nameid, amount) ) {
case ADDITEM_EXIST:
- break; //We'd add this item to the existing one (in buyers inventory)
+ break; //We'd add this item to the existing one (in buyers inventory)
case ADDITEM_NEW:
new_++;
if (new_ > blank)
@@ -190,7 +190,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
for( i = 0, cursor = 0; i < vsd->vend_num; i++ ) {
if( vsd->vending[i].amount == 0 )
continue;
-
+
if( cursor != i ) { // speedup
vsd->vending[cursor].index = vsd->vending[i].index;
vsd->vending[cursor].amount = vsd->vending[i].amount;
@@ -245,7 +245,7 @@ void vending_openvending(struct map_session_data* sd, const char* message, const
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return;
}
-
+
// filter out invalid items
i = 0;
for( j = 0; j < count; j++ ) {
@@ -256,13 +256,13 @@ void vending_openvending(struct map_session_data* sd, const char* message, const
index -= 2; // offset adjustment (client says that the first cart position is 2)
if( index < 0 || index >= MAX_CART // invalid position
- || pc->cartitem_amount(sd, index, amount) < 0 // invalid item or insufficient quantity
+ || pc->cartitem_amount(sd, index, amount) < 0 // invalid item or insufficient quantity
//NOTE: official server does not do any of the following checks!
- || !sd->status.cart[index].identify // unidentified item
- || sd->status.cart[index].attribute == 1 // broken item
- || sd->status.cart[index].expire_time // It should not be in the cart but just in case
- || (sd->status.cart[index].bound && !pc_can_give_bound_items(sd)) // can't trade bound items w/o permission
- || !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) ) // untradeable item
+ || !sd->status.cart[index].identify // unidentified item
+ || sd->status.cart[index].attribute == 1 // broken item
+ || sd->status.cart[index].expire_time // It should not be in the cart but just in case
+ || (sd->status.cart[index].bound && !pc_can_give_bound_items(sd)) // can't trade bound items w/o permission
+ || !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) ) // untradeable item
continue;
sd->vending[i].index = index;
@@ -287,7 +287,7 @@ void vending_openvending(struct map_session_data* sd, const char* message, const
clif->openvending(sd,sd->bl.id,sd->vending);
clif->showvendingboard(&sd->bl,message,0);
-
+
idb_put(vending->db, sd->status.char_id, sd);
}
@@ -372,10 +372,10 @@ void init(bool minimal) {
void vending_defaults(void) {
vending = &vending_s;
-
+
vending->init = init;
vending->final = final;
-
+
vending->close = vending_closevending;
vending->open = vending_openvending;
vending->list = vending_vendinglistreq;
diff --git a/src/plugins/HPMHooking.c b/src/plugins/HPMHooking.c
index 46792b268..d1b267cf1 100644
--- a/src/plugins/HPMHooking.c
+++ b/src/plugins/HPMHooking.c
@@ -11,6 +11,45 @@
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/socket.h"
+
+#if defined (HPMHOOKING_LOGIN)
+#define HPM_SERVER_TYPE SERVER_TYPE_LOGIN
+#define HPM_CORE_INCLUDE "../plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc"
+#define HPM_SYMBOL_INCLUDE "../plugins/HPMHooking/HPMHooking_login.GetSymbol.inc"
+#define HPM_HOOKS_INCLUDE "../plugins/HPMHooking/HPMHooking_login.Hooks.inc"
+#define HPM_POINTS_INCLUDE "../plugins/HPMHooking/HPMHooking_login.HookingPoints.inc"
+#define HPM_SOURCES_INCLUDE "../plugins/HPMHooking/HPMHooking_login.sources.inc"
+#include "../login/login.h"
+#elif defined (HPMHOOKING_CHAR)
+#define HPM_SERVER_TYPE SERVER_TYPE_CHAR
+#define HPM_CORE_INCLUDE "../plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc"
+#define HPM_SYMBOL_INCLUDE "../plugins/HPMHooking/HPMHooking_char.GetSymbol.inc"
+#define HPM_HOOKS_INCLUDE "../plugins/HPMHooking/HPMHooking_char.Hooks.inc"
+#define HPM_POINTS_INCLUDE "../plugins/HPMHooking/HPMHooking_char.HookingPoints.inc"
+#define HPM_SOURCES_INCLUDE "../plugins/HPMHooking/HPMHooking_char.sources.inc"
+#include "../char/char.h"
+#include "../char/geoip.h"
+#include "../char/int_auction.h"
+#include "../char/int_elemental.h"
+#include "../char/int_guild.h"
+#include "../char/int_homun.h"
+#include "../char/int_mail.h"
+#include "../char/int_mercenary.h"
+#include "../char/int_party.h"
+#include "../char/int_pet.h"
+#include "../char/int_quest.h"
+#include "../char/int_storage.h"
+#include "../char/inter.h"
+#include "../char/loginif.h"
+#include "../char/mapif.h"
+#include "../char/pincode.h"
+#elif defined (HPMHOOKING_MAP)
+#define HPM_SERVER_TYPE SERVER_TYPE_MAP
+#define HPM_CORE_INCLUDE "../plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc"
+#define HPM_SYMBOL_INCLUDE "../plugins/HPMHooking/HPMHooking_map.GetSymbol.inc"
+#define HPM_HOOKS_INCLUDE "../plugins/HPMHooking/HPMHooking_map.Hooks.inc"
+#define HPM_POINTS_INCLUDE "../plugins/HPMHooking/HPMHooking_map.HookingPoints.inc"
+#define HPM_SOURCES_INCLUDE "../plugins/HPMHooking/HPMHooking_map.sources.inc"
#include "../map/atcommand.h"
#include "../map/battle.h"
#include "../map/battleground.h"
@@ -44,13 +83,22 @@
#include "../map/storage.h"
#include "../map/trade.h"
#include "../map/unit.h"
+#else
+#define HPM_SERVER_TYPE SERVER_TYPE_UNKNOWN
+#define HPM_CORE_INCLUDE "../plugins/HPMHooking/HPMHooking.HPMHooksCore.inc"
+#define HPM_SYMBOL_INCLUDE "../plugins/HPMHooking/HPMHooking.GetSymbol.inc"
+#define HPM_HOOKS_INCLUDE "../plugins/HPMHooking/HPMHooking.Hooks.inc"
+#define HPM_POINTS_INCLUDE "../plugins/HPMHooking/HPMHooking.HookingPoints.inc"
+#define HPM_SOURCES_INCLUDE "../plugins/HPMHooking/HPMHooking.sources.inc"
+#error HPMHooking plugin needs to be compiled for a specific server type. Please make sure your Makefiles are up to date.
+#endif
#include "../common/HPMDataCheck.h"
HPExport struct hplugin_info pinfo = {
"HPMHooking", // Plugin name
- SERVER_TYPE_MAP,// Which server types this plugin works with?
- "0.1", // Plugin version
+ HPM_SERVER_TYPE,// Which server types this plugin works with?
+ "0.2", // Plugin version
HPM_VERSION, // HPM Version (don't change, macro is automatically updated)
};
@@ -70,7 +118,7 @@ struct HPMHookPoint {
};
struct HPMHooksCore {
- #include "../plugins/HPMHooking/HPMHooking.HPMHooksCore.inc"
+ #include HPM_CORE_INCLUDE
struct {
int total;
} data;
@@ -89,7 +137,7 @@ HPExport bool Hooked (bool *fr) {
HPMforce_return = fr;
DB = GET_SYMBOL("DB");
iMalloc = GET_SYMBOL("iMalloc");
-#include "../plugins/HPMHooking/HPMHooking.GetSymbol.inc"
+#include HPM_SYMBOL_INCLUDE
HPM_HP_load();
return true;
}
@@ -97,11 +145,11 @@ HPExport bool Hooked (bool *fr) {
HPExport bool HPM_Plugin_AddHook(enum HPluginHookType type, const char *target, void *hook, unsigned int pID) {
struct HookingPointData *hpd;
-
+
if( hp_db && (hpd = strdb_get(hp_db,target)) ) {
struct HPMHookPoint **hp = NULL;
int *count = NULL;
-
+
if( type == HOOK_TYPE_PRE ) {
hp = (struct HPMHookPoint **)((char *)&HPMHooks.list + (sizeof(struct HPMHookPoint *)*hpd->idx));
count = (int *)((char *)&HPMHooks.count + (sizeof(int)*hpd->idx));
@@ -109,68 +157,67 @@ HPExport bool HPM_Plugin_AddHook(enum HPluginHookType type, const char *target,
hp = (struct HPMHookPoint **)((char *)&HPMHooks.list + (sizeof(struct HPMHookPoint *)*(hpd->idx+1)));
count = (int *)((char *)&HPMHooks.count + (sizeof(int)*(hpd->idx+1)));
}
-
+
if( hp ) {
*count += 1;
-
+
RECREATE(*hp, struct HPMHookPoint, *count);
-
+
(*hp)[*count - 1].func = hook;
(*hp)[*count - 1].pID = pID;
-
+
*(hpd->sref) = hpd->tref;
-
+
return true;
}
}
-
+
return false;
}
-#include "../plugins/HPMHooking/HPMHooking.Hooks.inc"
+#include HPM_HOOKS_INCLUDE
void HPM_HP_final(void) {
int i, len = HPMHooks.data.total * 2;
-
+
if( hp_db )
db_destroy(hp_db);
-
+
for(i = 0; i < len; i++) {
int *count = (int *)((char *)&HPMHooks.count + (sizeof(int)*(i)));
-
+
if( count && *count ) {
struct HPMHookPoint **hp = (struct HPMHookPoint **)((char *)&HPMHooks.list + (sizeof(struct HPMHookPoint *)*(i)));
-
+
if( hp && *hp )
aFree(*hp);
}
}
-
}
void HPM_HP_load(void) {
- #include "../plugins/HPMHooking/HPMHooking.HookingPoints.inc"
+ #include HPM_POINTS_INCLUDE
int i, len = ARRAYLENGTH(HookingPoints), idx = 0;
-
+
memset(&HPMHooks,0,sizeof(struct HPMHooksCore));
-
+
hp_db = strdb_alloc(DB_OPT_BASE|DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, HookingPointsLenMax);
-
+
for(i = 0; i < len; i++) {
struct HookingPointData *hpd = NULL;
-
+
CREATE(hpd, struct HookingPointData, 1);
-
+
memcpy(hpd, &HookingPoints[i], sizeof(struct HookingPointData));
-
+
hpd->idx = idx;
idx += 2;
-
+
strdb_put(hp_db, HookingPoints[i].name, hpd);
-
+
HPMHooks.data.total++;
}
-
- #include "../plugins/HPMHooking/HPMHooking.sources.inc"
+
+ #include HPM_SOURCES_INCLUDE
}
diff --git a/src/plugins/HPMHooking/HPMHooking_char.GetSymbol.inc b/src/plugins/HPMHooking/HPMHooking_char.GetSymbol.inc
new file mode 100644
index 000000000..6d6db24ae
--- /dev/null
+++ b/src/plugins/HPMHooking/HPMHooking_char.GetSymbol.inc
@@ -0,0 +1,22 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+//
+// NOTE: This file was auto-generated and should never be manually edited,
+// as it will get overwritten.
+
+if( !(chr = GET_SYMBOL("chr") ) ) return false;
+if( !(geoip = GET_SYMBOL("geoip") ) ) return false;
+if( !(inter_auction = GET_SYMBOL("inter_auction") ) ) return false;
+if( !(inter_elemental = GET_SYMBOL("inter_elemental") ) ) return false;
+if( !(inter_guild = GET_SYMBOL("inter_guild") ) ) return false;
+if( !(inter_homunculus = GET_SYMBOL("inter_homunculus") ) ) return false;
+if( !(inter = GET_SYMBOL("inter") ) ) return false;
+if( !(inter_mail = GET_SYMBOL("inter_mail") ) ) return false;
+if( !(inter_mercenary = GET_SYMBOL("inter_mercenary") ) ) return false;
+if( !(inter_party = GET_SYMBOL("inter_party") ) ) return false;
+if( !(inter_pet = GET_SYMBOL("inter_pet") ) ) return false;
+if( !(inter_quest = GET_SYMBOL("inter_quest") ) ) return false;
+if( !(inter_storage = GET_SYMBOL("inter_storage") ) ) return false;
+if( !(loginif = GET_SYMBOL("loginif") ) ) return false;
+if( !(mapif = GET_SYMBOL("mapif") ) ) return false;
+if( !(pincode = GET_SYMBOL("pincode") ) ) return false;
diff --git a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc
new file mode 100644
index 000000000..e2838b610
--- /dev/null
+++ b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc
@@ -0,0 +1,1814 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+//
+// NOTE: This file was auto-generated and should never be manually edited,
+// as it will get overwritten.
+
+struct {
+ struct HPMHookPoint *HP_chr_waiting_disconnect_pre;
+ struct HPMHookPoint *HP_chr_waiting_disconnect_post;
+ struct HPMHookPoint *HP_chr_delete_char_sql_pre;
+ struct HPMHookPoint *HP_chr_delete_char_sql_post;
+ struct HPMHookPoint *HP_chr_create_online_char_data_pre;
+ struct HPMHookPoint *HP_chr_create_online_char_data_post;
+ struct HPMHookPoint *HP_chr_set_account_online_pre;
+ struct HPMHookPoint *HP_chr_set_account_online_post;
+ struct HPMHookPoint *HP_chr_set_account_offline_pre;
+ struct HPMHookPoint *HP_chr_set_account_offline_post;
+ struct HPMHookPoint *HP_chr_set_char_charselect_pre;
+ struct HPMHookPoint *HP_chr_set_char_charselect_post;
+ struct HPMHookPoint *HP_chr_set_char_online_pre;
+ struct HPMHookPoint *HP_chr_set_char_online_post;
+ struct HPMHookPoint *HP_chr_set_char_offline_pre;
+ struct HPMHookPoint *HP_chr_set_char_offline_post;
+ struct HPMHookPoint *HP_chr_db_setoffline_pre;
+ struct HPMHookPoint *HP_chr_db_setoffline_post;
+ struct HPMHookPoint *HP_chr_db_kickoffline_pre;
+ struct HPMHookPoint *HP_chr_db_kickoffline_post;
+ struct HPMHookPoint *HP_chr_set_login_all_offline_pre;
+ struct HPMHookPoint *HP_chr_set_login_all_offline_post;
+ struct HPMHookPoint *HP_chr_set_all_offline_pre;
+ struct HPMHookPoint *HP_chr_set_all_offline_post;
+ struct HPMHookPoint *HP_chr_set_all_offline_sql_pre;
+ struct HPMHookPoint *HP_chr_set_all_offline_sql_post;
+ struct HPMHookPoint *HP_chr_create_charstatus_pre;
+ struct HPMHookPoint *HP_chr_create_charstatus_post;
+ struct HPMHookPoint *HP_chr_mmo_char_tosql_pre;
+ struct HPMHookPoint *HP_chr_mmo_char_tosql_post;
+ struct HPMHookPoint *HP_chr_memitemdata_to_sql_pre;
+ struct HPMHookPoint *HP_chr_memitemdata_to_sql_post;
+ struct HPMHookPoint *HP_chr_inventory_to_sql_pre;
+ struct HPMHookPoint *HP_chr_inventory_to_sql_post;
+ struct HPMHookPoint *HP_chr_mmo_chars_fromsql_pre;
+ struct HPMHookPoint *HP_chr_mmo_chars_fromsql_post;
+ struct HPMHookPoint *HP_chr_mmo_char_fromsql_pre;
+ struct HPMHookPoint *HP_chr_mmo_char_fromsql_post;
+ struct HPMHookPoint *HP_chr_mmo_char_sql_init_pre;
+ struct HPMHookPoint *HP_chr_mmo_char_sql_init_post;
+ struct HPMHookPoint *HP_chr_char_slotchange_pre;
+ struct HPMHookPoint *HP_chr_char_slotchange_post;
+ struct HPMHookPoint *HP_chr_rename_char_sql_pre;
+ struct HPMHookPoint *HP_chr_rename_char_sql_post;
+ struct HPMHookPoint *HP_chr_check_char_name_pre;
+ struct HPMHookPoint *HP_chr_check_char_name_post;
+ struct HPMHookPoint *HP_chr_make_new_char_sql_pre;
+ struct HPMHookPoint *HP_chr_make_new_char_sql_post;
+ struct HPMHookPoint *HP_chr_divorce_char_sql_pre;
+ struct HPMHookPoint *HP_chr_divorce_char_sql_post;
+ struct HPMHookPoint *HP_chr_count_users_pre;
+ struct HPMHookPoint *HP_chr_count_users_post;
+ struct HPMHookPoint *HP_chr_mmo_char_tobuf_pre;
+ struct HPMHookPoint *HP_chr_mmo_char_tobuf_post;
+ struct HPMHookPoint *HP_chr_mmo_char_send099d_pre;
+ struct HPMHookPoint *HP_chr_mmo_char_send099d_post;
+ struct HPMHookPoint *HP_chr_mmo_char_send_ban_list_pre;
+ struct HPMHookPoint *HP_chr_mmo_char_send_ban_list_post;
+ struct HPMHookPoint *HP_chr_mmo_char_send_slots_info_pre;
+ struct HPMHookPoint *HP_chr_mmo_char_send_slots_info_post;
+ struct HPMHookPoint *HP_chr_mmo_char_send_characters_pre;
+ struct HPMHookPoint *HP_chr_mmo_char_send_characters_post;
+ struct HPMHookPoint *HP_chr_char_married_pre;
+ struct HPMHookPoint *HP_chr_char_married_post;
+ struct HPMHookPoint *HP_chr_char_child_pre;
+ struct HPMHookPoint *HP_chr_char_child_post;
+ struct HPMHookPoint *HP_chr_char_family_pre;
+ struct HPMHookPoint *HP_chr_char_family_post;
+ struct HPMHookPoint *HP_chr_disconnect_player_pre;
+ struct HPMHookPoint *HP_chr_disconnect_player_post;
+ struct HPMHookPoint *HP_chr_authfail_fd_pre;
+ struct HPMHookPoint *HP_chr_authfail_fd_post;
+ struct HPMHookPoint *HP_chr_request_account_data_pre;
+ struct HPMHookPoint *HP_chr_request_account_data_post;
+ struct HPMHookPoint *HP_chr_auth_ok_pre;
+ struct HPMHookPoint *HP_chr_auth_ok_post;
+ struct HPMHookPoint *HP_chr_ping_login_server_pre;
+ struct HPMHookPoint *HP_chr_ping_login_server_post;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_connection_state_pre;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_connection_state_post;
+ struct HPMHookPoint *HP_chr_auth_error_pre;
+ struct HPMHookPoint *HP_chr_auth_error_post;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_auth_state_pre;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_auth_state_post;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_account_data_pre;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_account_data_post;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_login_pong_pre;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_login_pong_post;
+ struct HPMHookPoint *HP_chr_changesex_pre;
+ struct HPMHookPoint *HP_chr_changesex_post;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_changesex_reply_pre;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_changesex_reply_post;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_account_reg2_pre;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_account_reg2_post;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_ban_pre;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_ban_post;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_kick_pre;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_kick_post;
+ struct HPMHookPoint *HP_chr_update_ip_pre;
+ struct HPMHookPoint *HP_chr_update_ip_post;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_update_ip_pre;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_update_ip_post;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_accinfo2_failed_pre;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_accinfo2_failed_post;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_accinfo2_ok_pre;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_accinfo2_ok_post;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_pre;
+ struct HPMHookPoint *HP_chr_parse_fromlogin_post;
+ struct HPMHookPoint *HP_chr_request_accreg2_pre;
+ struct HPMHookPoint *HP_chr_request_accreg2_post;
+ struct HPMHookPoint *HP_chr_global_accreg_to_login_start_pre;
+ struct HPMHookPoint *HP_chr_global_accreg_to_login_start_post;
+ struct HPMHookPoint *HP_chr_global_accreg_to_login_send_pre;
+ struct HPMHookPoint *HP_chr_global_accreg_to_login_send_post;
+ struct HPMHookPoint *HP_chr_global_accreg_to_login_add_pre;
+ struct HPMHookPoint *HP_chr_global_accreg_to_login_add_post;
+ struct HPMHookPoint *HP_chr_read_fame_list_pre;
+ struct HPMHookPoint *HP_chr_read_fame_list_post;
+ struct HPMHookPoint *HP_chr_send_fame_list_pre;
+ struct HPMHookPoint *HP_chr_send_fame_list_post;
+ struct HPMHookPoint *HP_chr_update_fame_list_pre;
+ struct HPMHookPoint *HP_chr_update_fame_list_post;
+ struct HPMHookPoint *HP_chr_loadName_pre;
+ struct HPMHookPoint *HP_chr_loadName_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_datasync_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_datasync_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_skillid2idx_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_skillid2idx_post;
+ struct HPMHookPoint *HP_chr_map_received_ok_pre;
+ struct HPMHookPoint *HP_chr_map_received_ok_post;
+ struct HPMHookPoint *HP_chr_send_maps_pre;
+ struct HPMHookPoint *HP_chr_send_maps_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_map_names_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_map_names_post;
+ struct HPMHookPoint *HP_chr_send_scdata_pre;
+ struct HPMHookPoint *HP_chr_send_scdata_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_request_scdata_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_request_scdata_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_set_users_count_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_set_users_count_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_set_users_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_set_users_post;
+ struct HPMHookPoint *HP_chr_save_character_ack_pre;
+ struct HPMHookPoint *HP_chr_save_character_ack_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_save_character_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_save_character_post;
+ struct HPMHookPoint *HP_chr_select_ack_pre;
+ struct HPMHookPoint *HP_chr_select_ack_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_char_select_req_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_char_select_req_post;
+ struct HPMHookPoint *HP_chr_change_map_server_ack_pre;
+ struct HPMHookPoint *HP_chr_change_map_server_ack_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_change_map_server_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_change_map_server_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_remove_friend_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_remove_friend_post;
+ struct HPMHookPoint *HP_chr_char_name_ack_pre;
+ struct HPMHookPoint *HP_chr_char_name_ack_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_char_name_request_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_char_name_request_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_change_email_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_change_email_post;
+ struct HPMHookPoint *HP_chr_ban_pre;
+ struct HPMHookPoint *HP_chr_ban_post;
+ struct HPMHookPoint *HP_chr_unban_pre;
+ struct HPMHookPoint *HP_chr_unban_post;
+ struct HPMHookPoint *HP_chr_ask_name_ack_pre;
+ struct HPMHookPoint *HP_chr_ask_name_ack_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_change_account_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_change_account_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_fame_list_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_fame_list_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_divorce_char_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_divorce_char_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_ragsrvinfo_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_ragsrvinfo_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_set_char_offline_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_set_char_offline_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_set_all_offline_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_set_all_offline_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_set_char_online_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_set_char_online_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_build_fame_list_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_build_fame_list_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_save_status_change_data_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_save_status_change_data_post;
+ struct HPMHookPoint *HP_chr_send_pong_pre;
+ struct HPMHookPoint *HP_chr_send_pong_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_ping_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_ping_post;
+ struct HPMHookPoint *HP_chr_map_auth_ok_pre;
+ struct HPMHookPoint *HP_chr_map_auth_ok_post;
+ struct HPMHookPoint *HP_chr_map_auth_failed_pre;
+ struct HPMHookPoint *HP_chr_map_auth_failed_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_auth_request_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_auth_request_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_update_ip_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_update_ip_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_request_stats_report_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_request_stats_report_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_scdata_update_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_scdata_update_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_scdata_delete_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_scdata_delete_post;
+ struct HPMHookPoint *HP_chr_parse_frommap_pre;
+ struct HPMHookPoint *HP_chr_parse_frommap_post;
+ struct HPMHookPoint *HP_chr_search_mapserver_pre;
+ struct HPMHookPoint *HP_chr_search_mapserver_post;
+ struct HPMHookPoint *HP_chr_mapif_init_pre;
+ struct HPMHookPoint *HP_chr_mapif_init_post;
+ struct HPMHookPoint *HP_chr_lan_subnetcheck_pre;
+ struct HPMHookPoint *HP_chr_lan_subnetcheck_post;
+ struct HPMHookPoint *HP_chr_delete2_ack_pre;
+ struct HPMHookPoint *HP_chr_delete2_ack_post;
+ struct HPMHookPoint *HP_chr_delete2_accept_actual_ack_pre;
+ struct HPMHookPoint *HP_chr_delete2_accept_actual_ack_post;
+ struct HPMHookPoint *HP_chr_delete2_accept_ack_pre;
+ struct HPMHookPoint *HP_chr_delete2_accept_ack_post;
+ struct HPMHookPoint *HP_chr_delete2_cancel_ack_pre;
+ struct HPMHookPoint *HP_chr_delete2_cancel_ack_post;
+ struct HPMHookPoint *HP_chr_delete2_req_pre;
+ struct HPMHookPoint *HP_chr_delete2_req_post;
+ struct HPMHookPoint *HP_chr_delete2_accept_pre;
+ struct HPMHookPoint *HP_chr_delete2_accept_post;
+ struct HPMHookPoint *HP_chr_delete2_cancel_pre;
+ struct HPMHookPoint *HP_chr_delete2_cancel_post;
+ struct HPMHookPoint *HP_chr_send_account_id_pre;
+ struct HPMHookPoint *HP_chr_send_account_id_post;
+ struct HPMHookPoint *HP_chr_parse_char_connect_pre;
+ struct HPMHookPoint *HP_chr_parse_char_connect_post;
+ struct HPMHookPoint *HP_chr_send_map_info_pre;
+ struct HPMHookPoint *HP_chr_send_map_info_post;
+ struct HPMHookPoint *HP_chr_send_wait_char_server_pre;
+ struct HPMHookPoint *HP_chr_send_wait_char_server_post;
+ struct HPMHookPoint *HP_chr_search_default_maps_mapserver_pre;
+ struct HPMHookPoint *HP_chr_search_default_maps_mapserver_post;
+ struct HPMHookPoint *HP_chr_parse_char_select_pre;
+ struct HPMHookPoint *HP_chr_parse_char_select_post;
+ struct HPMHookPoint *HP_chr_creation_failed_pre;
+ struct HPMHookPoint *HP_chr_creation_failed_post;
+ struct HPMHookPoint *HP_chr_creation_ok_pre;
+ struct HPMHookPoint *HP_chr_creation_ok_post;
+ struct HPMHookPoint *HP_chr_parse_char_create_new_char_pre;
+ struct HPMHookPoint *HP_chr_parse_char_create_new_char_post;
+ struct HPMHookPoint *HP_chr_delete_char_failed_pre;
+ struct HPMHookPoint *HP_chr_delete_char_failed_post;
+ struct HPMHookPoint *HP_chr_delete_char_ok_pre;
+ struct HPMHookPoint *HP_chr_delete_char_ok_post;
+ struct HPMHookPoint *HP_chr_parse_char_delete_char_pre;
+ struct HPMHookPoint *HP_chr_parse_char_delete_char_post;
+ struct HPMHookPoint *HP_chr_parse_char_ping_pre;
+ struct HPMHookPoint *HP_chr_parse_char_ping_post;
+ struct HPMHookPoint *HP_chr_allow_rename_pre;
+ struct HPMHookPoint *HP_chr_allow_rename_post;
+ struct HPMHookPoint *HP_chr_parse_char_rename_char_pre;
+ struct HPMHookPoint *HP_chr_parse_char_rename_char_post;
+ struct HPMHookPoint *HP_chr_parse_char_rename_char2_pre;
+ struct HPMHookPoint *HP_chr_parse_char_rename_char2_post;
+ struct HPMHookPoint *HP_chr_rename_char_ack_pre;
+ struct HPMHookPoint *HP_chr_rename_char_ack_post;
+ struct HPMHookPoint *HP_chr_parse_char_rename_char_confirm_pre;
+ struct HPMHookPoint *HP_chr_parse_char_rename_char_confirm_post;
+ struct HPMHookPoint *HP_chr_captcha_notsupported_pre;
+ struct HPMHookPoint *HP_chr_captcha_notsupported_post;
+ struct HPMHookPoint *HP_chr_parse_char_request_captcha_pre;
+ struct HPMHookPoint *HP_chr_parse_char_request_captcha_post;
+ struct HPMHookPoint *HP_chr_parse_char_check_captcha_pre;
+ struct HPMHookPoint *HP_chr_parse_char_check_captcha_post;
+ struct HPMHookPoint *HP_chr_parse_char_delete2_req_pre;
+ struct HPMHookPoint *HP_chr_parse_char_delete2_req_post;
+ struct HPMHookPoint *HP_chr_parse_char_delete2_accept_pre;
+ struct HPMHookPoint *HP_chr_parse_char_delete2_accept_post;
+ struct HPMHookPoint *HP_chr_parse_char_delete2_cancel_pre;
+ struct HPMHookPoint *HP_chr_parse_char_delete2_cancel_post;
+ struct HPMHookPoint *HP_chr_login_map_server_ack_pre;
+ struct HPMHookPoint *HP_chr_login_map_server_ack_post;
+ struct HPMHookPoint *HP_chr_parse_char_login_map_server_pre;
+ struct HPMHookPoint *HP_chr_parse_char_login_map_server_post;
+ struct HPMHookPoint *HP_chr_parse_char_pincode_check_pre;
+ struct HPMHookPoint *HP_chr_parse_char_pincode_check_post;
+ struct HPMHookPoint *HP_chr_parse_char_pincode_window_pre;
+ struct HPMHookPoint *HP_chr_parse_char_pincode_window_post;
+ struct HPMHookPoint *HP_chr_parse_char_pincode_change_pre;
+ struct HPMHookPoint *HP_chr_parse_char_pincode_change_post;
+ struct HPMHookPoint *HP_chr_parse_char_pincode_first_pin_pre;
+ struct HPMHookPoint *HP_chr_parse_char_pincode_first_pin_post;
+ struct HPMHookPoint *HP_chr_parse_char_request_chars_pre;
+ struct HPMHookPoint *HP_chr_parse_char_request_chars_post;
+ struct HPMHookPoint *HP_chr_change_character_slot_ack_pre;
+ struct HPMHookPoint *HP_chr_change_character_slot_ack_post;
+ struct HPMHookPoint *HP_chr_parse_char_move_character_pre;
+ struct HPMHookPoint *HP_chr_parse_char_move_character_post;
+ struct HPMHookPoint *HP_chr_parse_char_unknown_packet_pre;
+ struct HPMHookPoint *HP_chr_parse_char_unknown_packet_post;
+ struct HPMHookPoint *HP_chr_parse_char_pre;
+ struct HPMHookPoint *HP_chr_parse_char_post;
+ struct HPMHookPoint *HP_chr_broadcast_user_count_pre;
+ struct HPMHookPoint *HP_chr_broadcast_user_count_post;
+ struct HPMHookPoint *HP_chr_send_accounts_tologin_sub_pre;
+ struct HPMHookPoint *HP_chr_send_accounts_tologin_sub_post;
+ struct HPMHookPoint *HP_chr_send_accounts_tologin_pre;
+ struct HPMHookPoint *HP_chr_send_accounts_tologin_post;
+ struct HPMHookPoint *HP_chr_check_connect_login_server_pre;
+ struct HPMHookPoint *HP_chr_check_connect_login_server_post;
+ struct HPMHookPoint *HP_chr_online_data_cleanup_sub_pre;
+ struct HPMHookPoint *HP_chr_online_data_cleanup_sub_post;
+ struct HPMHookPoint *HP_chr_online_data_cleanup_pre;
+ struct HPMHookPoint *HP_chr_online_data_cleanup_post;
+ struct HPMHookPoint *HP_chr_lan_config_read_pre;
+ struct HPMHookPoint *HP_chr_lan_config_read_post;
+ struct HPMHookPoint *HP_chr_sql_config_read_pre;
+ struct HPMHookPoint *HP_chr_sql_config_read_post;
+ struct HPMHookPoint *HP_chr_config_dispatch_pre;
+ struct HPMHookPoint *HP_chr_config_dispatch_post;
+ struct HPMHookPoint *HP_chr_config_read_pre;
+ struct HPMHookPoint *HP_chr_config_read_post;
+ struct HPMHookPoint *HP_geoip_getcountry_pre;
+ struct HPMHookPoint *HP_geoip_getcountry_post;
+ struct HPMHookPoint *HP_geoip_final_pre;
+ struct HPMHookPoint *HP_geoip_final_post;
+ struct HPMHookPoint *HP_geoip_init_pre;
+ struct HPMHookPoint *HP_geoip_init_post;
+ struct HPMHookPoint *HP_inter_auction_count_pre;
+ struct HPMHookPoint *HP_inter_auction_count_post;
+ struct HPMHookPoint *HP_inter_auction_save_pre;
+ struct HPMHookPoint *HP_inter_auction_save_post;
+ struct HPMHookPoint *HP_inter_auction_create_pre;
+ struct HPMHookPoint *HP_inter_auction_create_post;
+ struct HPMHookPoint *HP_inter_auction_end_timer_pre;
+ struct HPMHookPoint *HP_inter_auction_end_timer_post;
+ struct HPMHookPoint *HP_inter_auction_delete__pre;
+ struct HPMHookPoint *HP_inter_auction_delete__post;
+ struct HPMHookPoint *HP_inter_auction_fromsql_pre;
+ struct HPMHookPoint *HP_inter_auction_fromsql_post;
+ struct HPMHookPoint *HP_inter_auction_parse_frommap_pre;
+ struct HPMHookPoint *HP_inter_auction_parse_frommap_post;
+ struct HPMHookPoint *HP_inter_auction_sql_init_pre;
+ 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_elemental_sql_init_pre;
+ struct HPMHookPoint *HP_inter_elemental_sql_init_post;
+ struct HPMHookPoint *HP_inter_elemental_sql_final_pre;
+ struct HPMHookPoint *HP_inter_elemental_sql_final_post;
+ struct HPMHookPoint *HP_inter_elemental_parse_frommap_pre;
+ struct HPMHookPoint *HP_inter_elemental_parse_frommap_post;
+ struct HPMHookPoint *HP_inter_guild_save_timer_pre;
+ struct HPMHookPoint *HP_inter_guild_save_timer_post;
+ struct HPMHookPoint *HP_inter_guild_removemember_tosql_pre;
+ struct HPMHookPoint *HP_inter_guild_removemember_tosql_post;
+ struct HPMHookPoint *HP_inter_guild_tosql_pre;
+ struct HPMHookPoint *HP_inter_guild_tosql_post;
+ struct HPMHookPoint *HP_inter_guild_fromsql_pre;
+ struct HPMHookPoint *HP_inter_guild_fromsql_post;
+ struct HPMHookPoint *HP_inter_guild_castle_tosql_pre;
+ struct HPMHookPoint *HP_inter_guild_castle_tosql_post;
+ struct HPMHookPoint *HP_inter_guild_castle_fromsql_pre;
+ struct HPMHookPoint *HP_inter_guild_castle_fromsql_post;
+ struct HPMHookPoint *HP_inter_guild_exp_parse_row_pre;
+ struct HPMHookPoint *HP_inter_guild_exp_parse_row_post;
+ struct HPMHookPoint *HP_inter_guild_CharOnline_pre;
+ struct HPMHookPoint *HP_inter_guild_CharOnline_post;
+ struct HPMHookPoint *HP_inter_guild_CharOffline_pre;
+ struct HPMHookPoint *HP_inter_guild_CharOffline_post;
+ struct HPMHookPoint *HP_inter_guild_sql_init_pre;
+ struct HPMHookPoint *HP_inter_guild_sql_init_post;
+ struct HPMHookPoint *HP_inter_guild_db_final_pre;
+ struct HPMHookPoint *HP_inter_guild_db_final_post;
+ struct HPMHookPoint *HP_inter_guild_sql_final_pre;
+ struct HPMHookPoint *HP_inter_guild_sql_final_post;
+ struct HPMHookPoint *HP_inter_guild_search_guildname_pre;
+ struct HPMHookPoint *HP_inter_guild_search_guildname_post;
+ struct HPMHookPoint *HP_inter_guild_check_empty_pre;
+ struct HPMHookPoint *HP_inter_guild_check_empty_post;
+ struct HPMHookPoint *HP_inter_guild_nextexp_pre;
+ struct HPMHookPoint *HP_inter_guild_nextexp_post;
+ struct HPMHookPoint *HP_inter_guild_checkskill_pre;
+ struct HPMHookPoint *HP_inter_guild_checkskill_post;
+ struct HPMHookPoint *HP_inter_guild_calcinfo_pre;
+ struct HPMHookPoint *HP_inter_guild_calcinfo_post;
+ struct HPMHookPoint *HP_inter_guild_sex_changed_pre;
+ struct HPMHookPoint *HP_inter_guild_sex_changed_post;
+ struct HPMHookPoint *HP_inter_guild_charname_changed_pre;
+ struct HPMHookPoint *HP_inter_guild_charname_changed_post;
+ struct HPMHookPoint *HP_inter_guild_parse_frommap_pre;
+ struct HPMHookPoint *HP_inter_guild_parse_frommap_post;
+ struct HPMHookPoint *HP_inter_guild_leave_pre;
+ struct HPMHookPoint *HP_inter_guild_leave_post;
+ struct HPMHookPoint *HP_inter_guild_broken_pre;
+ struct HPMHookPoint *HP_inter_guild_broken_post;
+ struct HPMHookPoint *HP_inter_homunculus_sql_init_pre;
+ struct HPMHookPoint *HP_inter_homunculus_sql_init_post;
+ struct HPMHookPoint *HP_inter_homunculus_sql_final_pre;
+ struct HPMHookPoint *HP_inter_homunculus_sql_final_post;
+ struct HPMHookPoint *HP_inter_homunculus_parse_frommap_pre;
+ struct HPMHookPoint *HP_inter_homunculus_parse_frommap_post;
+ struct HPMHookPoint *HP_inter_msg_txt_pre;
+ struct HPMHookPoint *HP_inter_msg_txt_post;
+ struct HPMHookPoint *HP_inter_msg_config_read_pre;
+ struct HPMHookPoint *HP_inter_msg_config_read_post;
+ struct HPMHookPoint *HP_inter_do_final_msg_pre;
+ struct HPMHookPoint *HP_inter_do_final_msg_post;
+ struct HPMHookPoint *HP_inter_job_name_pre;
+ struct HPMHookPoint *HP_inter_job_name_post;
+ struct HPMHookPoint *HP_inter_vmsg_to_fd_pre;
+ struct HPMHookPoint *HP_inter_vmsg_to_fd_post;
+ struct HPMHookPoint *HP_inter_savereg_pre;
+ struct HPMHookPoint *HP_inter_savereg_post;
+ struct HPMHookPoint *HP_inter_accreg_fromsql_pre;
+ struct HPMHookPoint *HP_inter_accreg_fromsql_post;
+ struct HPMHookPoint *HP_inter_config_read_pre;
+ struct HPMHookPoint *HP_inter_config_read_post;
+ struct HPMHookPoint *HP_inter_vlog_pre;
+ struct HPMHookPoint *HP_inter_vlog_post;
+ struct HPMHookPoint *HP_inter_init_sql_pre;
+ struct HPMHookPoint *HP_inter_init_sql_post;
+ struct HPMHookPoint *HP_inter_mapif_init_pre;
+ struct HPMHookPoint *HP_inter_mapif_init_post;
+ struct HPMHookPoint *HP_inter_check_ttl_wisdata_sub_pre;
+ struct HPMHookPoint *HP_inter_check_ttl_wisdata_sub_post;
+ struct HPMHookPoint *HP_inter_check_ttl_wisdata_pre;
+ struct HPMHookPoint *HP_inter_check_ttl_wisdata_post;
+ struct HPMHookPoint *HP_inter_check_length_pre;
+ struct HPMHookPoint *HP_inter_check_length_post;
+ struct HPMHookPoint *HP_inter_parse_frommap_pre;
+ struct HPMHookPoint *HP_inter_parse_frommap_post;
+ struct HPMHookPoint *HP_inter_final_pre;
+ struct HPMHookPoint *HP_inter_final_post;
+ struct HPMHookPoint *HP_inter_mail_sql_init_pre;
+ struct HPMHookPoint *HP_inter_mail_sql_init_post;
+ struct HPMHookPoint *HP_inter_mail_sql_final_pre;
+ struct HPMHookPoint *HP_inter_mail_sql_final_post;
+ struct HPMHookPoint *HP_inter_mail_parse_frommap_pre;
+ struct HPMHookPoint *HP_inter_mail_parse_frommap_post;
+ struct HPMHookPoint *HP_inter_mail_fromsql_pre;
+ struct HPMHookPoint *HP_inter_mail_fromsql_post;
+ struct HPMHookPoint *HP_inter_mail_savemessage_pre;
+ struct HPMHookPoint *HP_inter_mail_savemessage_post;
+ struct HPMHookPoint *HP_inter_mail_loadmessage_pre;
+ struct HPMHookPoint *HP_inter_mail_loadmessage_post;
+ struct HPMHookPoint *HP_inter_mail_DeleteAttach_pre;
+ struct HPMHookPoint *HP_inter_mail_DeleteAttach_post;
+ struct HPMHookPoint *HP_inter_mail_sendmail_pre;
+ struct HPMHookPoint *HP_inter_mail_sendmail_post;
+ struct HPMHookPoint *HP_inter_mercenary_owner_fromsql_pre;
+ struct HPMHookPoint *HP_inter_mercenary_owner_fromsql_post;
+ struct HPMHookPoint *HP_inter_mercenary_owner_tosql_pre;
+ struct HPMHookPoint *HP_inter_mercenary_owner_tosql_post;
+ struct HPMHookPoint *HP_inter_mercenary_owner_delete_pre;
+ struct HPMHookPoint *HP_inter_mercenary_owner_delete_post;
+ struct HPMHookPoint *HP_inter_mercenary_sql_init_pre;
+ struct HPMHookPoint *HP_inter_mercenary_sql_init_post;
+ struct HPMHookPoint *HP_inter_mercenary_sql_final_pre;
+ struct HPMHookPoint *HP_inter_mercenary_sql_final_post;
+ struct HPMHookPoint *HP_inter_mercenary_parse_frommap_pre;
+ struct HPMHookPoint *HP_inter_mercenary_parse_frommap_post;
+ struct HPMHookPoint *HP_inter_party_check_lv_pre;
+ struct HPMHookPoint *HP_inter_party_check_lv_post;
+ struct HPMHookPoint *HP_inter_party_calc_state_pre;
+ struct HPMHookPoint *HP_inter_party_calc_state_post;
+ struct HPMHookPoint *HP_inter_party_tosql_pre;
+ struct HPMHookPoint *HP_inter_party_tosql_post;
+ struct HPMHookPoint *HP_inter_party_fromsql_pre;
+ struct HPMHookPoint *HP_inter_party_fromsql_post;
+ struct HPMHookPoint *HP_inter_party_sql_init_pre;
+ struct HPMHookPoint *HP_inter_party_sql_init_post;
+ struct HPMHookPoint *HP_inter_party_sql_final_pre;
+ struct HPMHookPoint *HP_inter_party_sql_final_post;
+ struct HPMHookPoint *HP_inter_party_search_partyname_pre;
+ struct HPMHookPoint *HP_inter_party_search_partyname_post;
+ struct HPMHookPoint *HP_inter_party_check_exp_share_pre;
+ struct HPMHookPoint *HP_inter_party_check_exp_share_post;
+ struct HPMHookPoint *HP_inter_party_check_empty_pre;
+ struct HPMHookPoint *HP_inter_party_check_empty_post;
+ struct HPMHookPoint *HP_inter_party_parse_frommap_pre;
+ struct HPMHookPoint *HP_inter_party_parse_frommap_post;
+ struct HPMHookPoint *HP_inter_party_leave_pre;
+ struct HPMHookPoint *HP_inter_party_leave_post;
+ struct HPMHookPoint *HP_inter_party_CharOnline_pre;
+ struct HPMHookPoint *HP_inter_party_CharOnline_post;
+ struct HPMHookPoint *HP_inter_party_CharOffline_pre;
+ struct HPMHookPoint *HP_inter_party_CharOffline_post;
+ struct HPMHookPoint *HP_inter_pet_tosql_pre;
+ struct HPMHookPoint *HP_inter_pet_tosql_post;
+ struct HPMHookPoint *HP_inter_pet_fromsql_pre;
+ struct HPMHookPoint *HP_inter_pet_fromsql_post;
+ struct HPMHookPoint *HP_inter_pet_sql_init_pre;
+ struct HPMHookPoint *HP_inter_pet_sql_init_post;
+ struct HPMHookPoint *HP_inter_pet_sql_final_pre;
+ struct HPMHookPoint *HP_inter_pet_sql_final_post;
+ struct HPMHookPoint *HP_inter_pet_delete__pre;
+ struct HPMHookPoint *HP_inter_pet_delete__post;
+ struct HPMHookPoint *HP_inter_pet_parse_frommap_pre;
+ struct HPMHookPoint *HP_inter_pet_parse_frommap_post;
+ struct HPMHookPoint *HP_inter_quest_parse_frommap_pre;
+ struct HPMHookPoint *HP_inter_quest_parse_frommap_post;
+ struct HPMHookPoint *HP_inter_storage_tosql_pre;
+ struct HPMHookPoint *HP_inter_storage_tosql_post;
+ struct HPMHookPoint *HP_inter_storage_fromsql_pre;
+ struct HPMHookPoint *HP_inter_storage_fromsql_post;
+ struct HPMHookPoint *HP_inter_storage_guild_storage_tosql_pre;
+ struct HPMHookPoint *HP_inter_storage_guild_storage_tosql_post;
+ struct HPMHookPoint *HP_inter_storage_guild_storage_fromsql_pre;
+ struct HPMHookPoint *HP_inter_storage_guild_storage_fromsql_post;
+ struct HPMHookPoint *HP_inter_storage_sql_init_pre;
+ struct HPMHookPoint *HP_inter_storage_sql_init_post;
+ struct HPMHookPoint *HP_inter_storage_sql_final_pre;
+ struct HPMHookPoint *HP_inter_storage_sql_final_post;
+ struct HPMHookPoint *HP_inter_storage_delete__pre;
+ struct HPMHookPoint *HP_inter_storage_delete__post;
+ struct HPMHookPoint *HP_inter_storage_guild_storage_delete_pre;
+ struct HPMHookPoint *HP_inter_storage_guild_storage_delete_post;
+ struct HPMHookPoint *HP_inter_storage_parse_frommap_pre;
+ struct HPMHookPoint *HP_inter_storage_parse_frommap_post;
+ struct HPMHookPoint *HP_loginif_init_pre;
+ struct HPMHookPoint *HP_loginif_init_post;
+ struct HPMHookPoint *HP_loginif_final_pre;
+ struct HPMHookPoint *HP_loginif_final_post;
+ struct HPMHookPoint *HP_loginif_reset_pre;
+ struct HPMHookPoint *HP_loginif_reset_post;
+ struct HPMHookPoint *HP_loginif_check_shutdown_pre;
+ struct HPMHookPoint *HP_loginif_check_shutdown_post;
+ struct HPMHookPoint *HP_loginif_on_disconnect_pre;
+ struct HPMHookPoint *HP_loginif_on_disconnect_post;
+ struct HPMHookPoint *HP_loginif_on_ready_pre;
+ struct HPMHookPoint *HP_loginif_on_ready_post;
+ struct HPMHookPoint *HP_loginif_block_account_pre;
+ struct HPMHookPoint *HP_loginif_block_account_post;
+ struct HPMHookPoint *HP_loginif_ban_account_pre;
+ struct HPMHookPoint *HP_loginif_ban_account_post;
+ struct HPMHookPoint *HP_loginif_unban_account_pre;
+ struct HPMHookPoint *HP_loginif_unban_account_post;
+ struct HPMHookPoint *HP_loginif_changesex_pre;
+ struct HPMHookPoint *HP_loginif_changesex_post;
+ struct HPMHookPoint *HP_loginif_auth_pre;
+ struct HPMHookPoint *HP_loginif_auth_post;
+ struct HPMHookPoint *HP_loginif_send_users_count_pre;
+ struct HPMHookPoint *HP_loginif_send_users_count_post;
+ struct HPMHookPoint *HP_loginif_connect_to_server_pre;
+ struct HPMHookPoint *HP_loginif_connect_to_server_post;
+ struct HPMHookPoint *HP_mapif_ban_pre;
+ struct HPMHookPoint *HP_mapif_ban_post;
+ struct HPMHookPoint *HP_mapif_server_init_pre;
+ struct HPMHookPoint *HP_mapif_server_init_post;
+ struct HPMHookPoint *HP_mapif_server_destroy_pre;
+ struct HPMHookPoint *HP_mapif_server_destroy_post;
+ struct HPMHookPoint *HP_mapif_server_reset_pre;
+ struct HPMHookPoint *HP_mapif_server_reset_post;
+ struct HPMHookPoint *HP_mapif_on_disconnect_pre;
+ struct HPMHookPoint *HP_mapif_on_disconnect_post;
+ struct HPMHookPoint *HP_mapif_on_parse_accinfo_pre;
+ struct HPMHookPoint *HP_mapif_on_parse_accinfo_post;
+ struct HPMHookPoint *HP_mapif_char_ban_pre;
+ struct HPMHookPoint *HP_mapif_char_ban_post;
+ struct HPMHookPoint *HP_mapif_sendall_pre;
+ struct HPMHookPoint *HP_mapif_sendall_post;
+ struct HPMHookPoint *HP_mapif_sendallwos_pre;
+ struct HPMHookPoint *HP_mapif_sendallwos_post;
+ struct HPMHookPoint *HP_mapif_send_pre;
+ struct HPMHookPoint *HP_mapif_send_post;
+ struct HPMHookPoint *HP_mapif_send_users_count_pre;
+ struct HPMHookPoint *HP_mapif_send_users_count_post;
+ struct HPMHookPoint *HP_mapif_auction_message_pre;
+ struct HPMHookPoint *HP_mapif_auction_message_post;
+ struct HPMHookPoint *HP_mapif_auction_sendlist_pre;
+ struct HPMHookPoint *HP_mapif_auction_sendlist_post;
+ struct HPMHookPoint *HP_mapif_parse_auction_requestlist_pre;
+ struct HPMHookPoint *HP_mapif_parse_auction_requestlist_post;
+ struct HPMHookPoint *HP_mapif_auction_register_pre;
+ struct HPMHookPoint *HP_mapif_auction_register_post;
+ struct HPMHookPoint *HP_mapif_parse_auction_register_pre;
+ struct HPMHookPoint *HP_mapif_parse_auction_register_post;
+ struct HPMHookPoint *HP_mapif_auction_cancel_pre;
+ struct HPMHookPoint *HP_mapif_auction_cancel_post;
+ struct HPMHookPoint *HP_mapif_parse_auction_cancel_pre;
+ struct HPMHookPoint *HP_mapif_parse_auction_cancel_post;
+ struct HPMHookPoint *HP_mapif_auction_close_pre;
+ struct HPMHookPoint *HP_mapif_auction_close_post;
+ struct HPMHookPoint *HP_mapif_parse_auction_close_pre;
+ struct HPMHookPoint *HP_mapif_parse_auction_close_post;
+ struct HPMHookPoint *HP_mapif_auction_bid_pre;
+ struct HPMHookPoint *HP_mapif_auction_bid_post;
+ struct HPMHookPoint *HP_mapif_parse_auction_bid_pre;
+ struct HPMHookPoint *HP_mapif_parse_auction_bid_post;
+ struct HPMHookPoint *HP_mapif_elemental_save_pre;
+ struct HPMHookPoint *HP_mapif_elemental_save_post;
+ struct HPMHookPoint *HP_mapif_elemental_load_pre;
+ struct HPMHookPoint *HP_mapif_elemental_load_post;
+ struct HPMHookPoint *HP_mapif_elemental_delete_pre;
+ struct HPMHookPoint *HP_mapif_elemental_delete_post;
+ struct HPMHookPoint *HP_mapif_elemental_send_pre;
+ struct HPMHookPoint *HP_mapif_elemental_send_post;
+ struct HPMHookPoint *HP_mapif_parse_elemental_create_pre;
+ struct HPMHookPoint *HP_mapif_parse_elemental_create_post;
+ struct HPMHookPoint *HP_mapif_parse_elemental_load_pre;
+ struct HPMHookPoint *HP_mapif_parse_elemental_load_post;
+ struct HPMHookPoint *HP_mapif_elemental_deleted_pre;
+ struct HPMHookPoint *HP_mapif_elemental_deleted_post;
+ struct HPMHookPoint *HP_mapif_parse_elemental_delete_pre;
+ struct HPMHookPoint *HP_mapif_parse_elemental_delete_post;
+ struct HPMHookPoint *HP_mapif_elemental_saved_pre;
+ struct HPMHookPoint *HP_mapif_elemental_saved_post;
+ struct HPMHookPoint *HP_mapif_parse_elemental_save_pre;
+ struct HPMHookPoint *HP_mapif_parse_elemental_save_post;
+ struct HPMHookPoint *HP_mapif_guild_created_pre;
+ struct HPMHookPoint *HP_mapif_guild_created_post;
+ struct HPMHookPoint *HP_mapif_guild_noinfo_pre;
+ struct HPMHookPoint *HP_mapif_guild_noinfo_post;
+ struct HPMHookPoint *HP_mapif_guild_info_pre;
+ struct HPMHookPoint *HP_mapif_guild_info_post;
+ struct HPMHookPoint *HP_mapif_guild_memberadded_pre;
+ struct HPMHookPoint *HP_mapif_guild_memberadded_post;
+ struct HPMHookPoint *HP_mapif_guild_withdraw_pre;
+ struct HPMHookPoint *HP_mapif_guild_withdraw_post;
+ struct HPMHookPoint *HP_mapif_guild_memberinfoshort_pre;
+ struct HPMHookPoint *HP_mapif_guild_memberinfoshort_post;
+ struct HPMHookPoint *HP_mapif_guild_broken_pre;
+ struct HPMHookPoint *HP_mapif_guild_broken_post;
+ struct HPMHookPoint *HP_mapif_guild_message_pre;
+ struct HPMHookPoint *HP_mapif_guild_message_post;
+ struct HPMHookPoint *HP_mapif_guild_basicinfochanged_pre;
+ struct HPMHookPoint *HP_mapif_guild_basicinfochanged_post;
+ struct HPMHookPoint *HP_mapif_guild_memberinfochanged_pre;
+ struct HPMHookPoint *HP_mapif_guild_memberinfochanged_post;
+ struct HPMHookPoint *HP_mapif_guild_skillupack_pre;
+ struct HPMHookPoint *HP_mapif_guild_skillupack_post;
+ struct HPMHookPoint *HP_mapif_guild_alliance_pre;
+ struct HPMHookPoint *HP_mapif_guild_alliance_post;
+ struct HPMHookPoint *HP_mapif_guild_position_pre;
+ struct HPMHookPoint *HP_mapif_guild_position_post;
+ struct HPMHookPoint *HP_mapif_guild_notice_pre;
+ struct HPMHookPoint *HP_mapif_guild_notice_post;
+ struct HPMHookPoint *HP_mapif_guild_emblem_pre;
+ struct HPMHookPoint *HP_mapif_guild_emblem_post;
+ struct HPMHookPoint *HP_mapif_guild_master_changed_pre;
+ struct HPMHookPoint *HP_mapif_guild_master_changed_post;
+ struct HPMHookPoint *HP_mapif_guild_castle_dataload_pre;
+ struct HPMHookPoint *HP_mapif_guild_castle_dataload_post;
+ struct HPMHookPoint *HP_mapif_parse_CreateGuild_pre;
+ struct HPMHookPoint *HP_mapif_parse_CreateGuild_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildInfo_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildInfo_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildAddMember_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildAddMember_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildLeave_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildLeave_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildChangeMemberInfoShort_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildChangeMemberInfoShort_post;
+ struct HPMHookPoint *HP_mapif_parse_BreakGuild_pre;
+ struct HPMHookPoint *HP_mapif_parse_BreakGuild_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildMessage_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildMessage_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildBasicInfoChange_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildBasicInfoChange_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildMemberInfoChange_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildMemberInfoChange_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildPosition_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildPosition_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildSkillUp_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildSkillUp_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildDeleteAlliance_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildDeleteAlliance_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildAlliance_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildAlliance_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildNotice_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildNotice_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildEmblem_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildEmblem_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildCastleDataLoad_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildCastleDataLoad_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildCastleDataSave_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildCastleDataSave_post;
+ struct HPMHookPoint *HP_mapif_parse_GuildMasterChange_pre;
+ struct HPMHookPoint *HP_mapif_parse_GuildMasterChange_post;
+ struct HPMHookPoint *HP_mapif_homunculus_created_pre;
+ struct HPMHookPoint *HP_mapif_homunculus_created_post;
+ struct HPMHookPoint *HP_mapif_homunculus_deleted_pre;
+ struct HPMHookPoint *HP_mapif_homunculus_deleted_post;
+ struct HPMHookPoint *HP_mapif_homunculus_loaded_pre;
+ struct HPMHookPoint *HP_mapif_homunculus_loaded_post;
+ struct HPMHookPoint *HP_mapif_homunculus_saved_pre;
+ struct HPMHookPoint *HP_mapif_homunculus_saved_post;
+ struct HPMHookPoint *HP_mapif_homunculus_renamed_pre;
+ struct HPMHookPoint *HP_mapif_homunculus_renamed_post;
+ struct HPMHookPoint *HP_mapif_homunculus_save_pre;
+ struct HPMHookPoint *HP_mapif_homunculus_save_post;
+ struct HPMHookPoint *HP_mapif_homunculus_load_pre;
+ struct HPMHookPoint *HP_mapif_homunculus_load_post;
+ struct HPMHookPoint *HP_mapif_homunculus_delete_pre;
+ struct HPMHookPoint *HP_mapif_homunculus_delete_post;
+ struct HPMHookPoint *HP_mapif_homunculus_rename_pre;
+ struct HPMHookPoint *HP_mapif_homunculus_rename_post;
+ struct HPMHookPoint *HP_mapif_parse_homunculus_create_pre;
+ struct HPMHookPoint *HP_mapif_parse_homunculus_create_post;
+ struct HPMHookPoint *HP_mapif_parse_homunculus_delete_pre;
+ struct HPMHookPoint *HP_mapif_parse_homunculus_delete_post;
+ struct HPMHookPoint *HP_mapif_parse_homunculus_load_pre;
+ struct HPMHookPoint *HP_mapif_parse_homunculus_load_post;
+ struct HPMHookPoint *HP_mapif_parse_homunculus_save_pre;
+ struct HPMHookPoint *HP_mapif_parse_homunculus_save_post;
+ struct HPMHookPoint *HP_mapif_parse_homunculus_rename_pre;
+ struct HPMHookPoint *HP_mapif_parse_homunculus_rename_post;
+ struct HPMHookPoint *HP_mapif_mail_sendinbox_pre;
+ struct HPMHookPoint *HP_mapif_mail_sendinbox_post;
+ struct HPMHookPoint *HP_mapif_parse_mail_requestinbox_pre;
+ struct HPMHookPoint *HP_mapif_parse_mail_requestinbox_post;
+ struct HPMHookPoint *HP_mapif_parse_mail_read_pre;
+ struct HPMHookPoint *HP_mapif_parse_mail_read_post;
+ struct HPMHookPoint *HP_mapif_mail_sendattach_pre;
+ struct HPMHookPoint *HP_mapif_mail_sendattach_post;
+ struct HPMHookPoint *HP_mapif_mail_getattach_pre;
+ struct HPMHookPoint *HP_mapif_mail_getattach_post;
+ struct HPMHookPoint *HP_mapif_parse_mail_getattach_pre;
+ struct HPMHookPoint *HP_mapif_parse_mail_getattach_post;
+ struct HPMHookPoint *HP_mapif_mail_delete_pre;
+ struct HPMHookPoint *HP_mapif_mail_delete_post;
+ struct HPMHookPoint *HP_mapif_parse_mail_delete_pre;
+ struct HPMHookPoint *HP_mapif_parse_mail_delete_post;
+ struct HPMHookPoint *HP_mapif_mail_new_pre;
+ struct HPMHookPoint *HP_mapif_mail_new_post;
+ struct HPMHookPoint *HP_mapif_mail_return_pre;
+ struct HPMHookPoint *HP_mapif_mail_return_post;
+ struct HPMHookPoint *HP_mapif_parse_mail_return_pre;
+ struct HPMHookPoint *HP_mapif_parse_mail_return_post;
+ struct HPMHookPoint *HP_mapif_mail_send_pre;
+ struct HPMHookPoint *HP_mapif_mail_send_post;
+ struct HPMHookPoint *HP_mapif_parse_mail_send_pre;
+ struct HPMHookPoint *HP_mapif_parse_mail_send_post;
+ struct HPMHookPoint *HP_mapif_mercenary_save_pre;
+ struct HPMHookPoint *HP_mapif_mercenary_save_post;
+ struct HPMHookPoint *HP_mapif_mercenary_load_pre;
+ struct HPMHookPoint *HP_mapif_mercenary_load_post;
+ struct HPMHookPoint *HP_mapif_mercenary_delete_pre;
+ struct HPMHookPoint *HP_mapif_mercenary_delete_post;
+ struct HPMHookPoint *HP_mapif_mercenary_send_pre;
+ struct HPMHookPoint *HP_mapif_mercenary_send_post;
+ struct HPMHookPoint *HP_mapif_parse_mercenary_create_pre;
+ struct HPMHookPoint *HP_mapif_parse_mercenary_create_post;
+ struct HPMHookPoint *HP_mapif_parse_mercenary_load_pre;
+ struct HPMHookPoint *HP_mapif_parse_mercenary_load_post;
+ struct HPMHookPoint *HP_mapif_mercenary_deleted_pre;
+ struct HPMHookPoint *HP_mapif_mercenary_deleted_post;
+ struct HPMHookPoint *HP_mapif_parse_mercenary_delete_pre;
+ struct HPMHookPoint *HP_mapif_parse_mercenary_delete_post;
+ struct HPMHookPoint *HP_mapif_mercenary_saved_pre;
+ struct HPMHookPoint *HP_mapif_mercenary_saved_post;
+ struct HPMHookPoint *HP_mapif_parse_mercenary_save_pre;
+ struct HPMHookPoint *HP_mapif_parse_mercenary_save_post;
+ struct HPMHookPoint *HP_mapif_party_created_pre;
+ struct HPMHookPoint *HP_mapif_party_created_post;
+ struct HPMHookPoint *HP_mapif_party_noinfo_pre;
+ struct HPMHookPoint *HP_mapif_party_noinfo_post;
+ struct HPMHookPoint *HP_mapif_party_info_pre;
+ struct HPMHookPoint *HP_mapif_party_info_post;
+ struct HPMHookPoint *HP_mapif_party_memberadded_pre;
+ struct HPMHookPoint *HP_mapif_party_memberadded_post;
+ struct HPMHookPoint *HP_mapif_party_optionchanged_pre;
+ struct HPMHookPoint *HP_mapif_party_optionchanged_post;
+ struct HPMHookPoint *HP_mapif_party_withdraw_pre;
+ struct HPMHookPoint *HP_mapif_party_withdraw_post;
+ struct HPMHookPoint *HP_mapif_party_membermoved_pre;
+ struct HPMHookPoint *HP_mapif_party_membermoved_post;
+ struct HPMHookPoint *HP_mapif_party_broken_pre;
+ struct HPMHookPoint *HP_mapif_party_broken_post;
+ struct HPMHookPoint *HP_mapif_party_message_pre;
+ struct HPMHookPoint *HP_mapif_party_message_post;
+ struct HPMHookPoint *HP_mapif_parse_CreateParty_pre;
+ struct HPMHookPoint *HP_mapif_parse_CreateParty_post;
+ struct HPMHookPoint *HP_mapif_parse_PartyInfo_pre;
+ struct HPMHookPoint *HP_mapif_parse_PartyInfo_post;
+ struct HPMHookPoint *HP_mapif_parse_PartyAddMember_pre;
+ struct HPMHookPoint *HP_mapif_parse_PartyAddMember_post;
+ struct HPMHookPoint *HP_mapif_parse_PartyChangeOption_pre;
+ struct HPMHookPoint *HP_mapif_parse_PartyChangeOption_post;
+ struct HPMHookPoint *HP_mapif_parse_PartyLeave_pre;
+ struct HPMHookPoint *HP_mapif_parse_PartyLeave_post;
+ struct HPMHookPoint *HP_mapif_parse_PartyChangeMap_pre;
+ struct HPMHookPoint *HP_mapif_parse_PartyChangeMap_post;
+ struct HPMHookPoint *HP_mapif_parse_BreakParty_pre;
+ struct HPMHookPoint *HP_mapif_parse_BreakParty_post;
+ struct HPMHookPoint *HP_mapif_parse_PartyMessage_pre;
+ struct HPMHookPoint *HP_mapif_parse_PartyMessage_post;
+ struct HPMHookPoint *HP_mapif_parse_PartyLeaderChange_pre;
+ struct HPMHookPoint *HP_mapif_parse_PartyLeaderChange_post;
+ struct HPMHookPoint *HP_mapif_pet_created_pre;
+ struct HPMHookPoint *HP_mapif_pet_created_post;
+ struct HPMHookPoint *HP_mapif_pet_info_pre;
+ struct HPMHookPoint *HP_mapif_pet_info_post;
+ struct HPMHookPoint *HP_mapif_pet_noinfo_pre;
+ struct HPMHookPoint *HP_mapif_pet_noinfo_post;
+ struct HPMHookPoint *HP_mapif_save_pet_ack_pre;
+ struct HPMHookPoint *HP_mapif_save_pet_ack_post;
+ struct HPMHookPoint *HP_mapif_delete_pet_ack_pre;
+ struct HPMHookPoint *HP_mapif_delete_pet_ack_post;
+ struct HPMHookPoint *HP_mapif_create_pet_pre;
+ struct HPMHookPoint *HP_mapif_create_pet_post;
+ struct HPMHookPoint *HP_mapif_load_pet_pre;
+ struct HPMHookPoint *HP_mapif_load_pet_post;
+ struct HPMHookPoint *HP_mapif_save_pet_pre;
+ struct HPMHookPoint *HP_mapif_save_pet_post;
+ struct HPMHookPoint *HP_mapif_delete_pet_pre;
+ struct HPMHookPoint *HP_mapif_delete_pet_post;
+ struct HPMHookPoint *HP_mapif_parse_CreatePet_pre;
+ struct HPMHookPoint *HP_mapif_parse_CreatePet_post;
+ struct HPMHookPoint *HP_mapif_parse_LoadPet_pre;
+ struct HPMHookPoint *HP_mapif_parse_LoadPet_post;
+ struct HPMHookPoint *HP_mapif_parse_SavePet_pre;
+ struct HPMHookPoint *HP_mapif_parse_SavePet_post;
+ struct HPMHookPoint *HP_mapif_parse_DeletePet_pre;
+ struct HPMHookPoint *HP_mapif_parse_DeletePet_post;
+ struct HPMHookPoint *HP_mapif_quests_fromsql_pre;
+ struct HPMHookPoint *HP_mapif_quests_fromsql_post;
+ struct HPMHookPoint *HP_mapif_quest_delete_pre;
+ struct HPMHookPoint *HP_mapif_quest_delete_post;
+ struct HPMHookPoint *HP_mapif_quest_add_pre;
+ struct HPMHookPoint *HP_mapif_quest_add_post;
+ struct HPMHookPoint *HP_mapif_quest_update_pre;
+ struct HPMHookPoint *HP_mapif_quest_update_post;
+ struct HPMHookPoint *HP_mapif_quest_save_ack_pre;
+ struct HPMHookPoint *HP_mapif_quest_save_ack_post;
+ struct HPMHookPoint *HP_mapif_parse_quest_save_pre;
+ struct HPMHookPoint *HP_mapif_parse_quest_save_post;
+ struct HPMHookPoint *HP_mapif_send_quests_pre;
+ struct HPMHookPoint *HP_mapif_send_quests_post;
+ struct HPMHookPoint *HP_mapif_parse_quest_load_pre;
+ struct HPMHookPoint *HP_mapif_parse_quest_load_post;
+ struct HPMHookPoint *HP_mapif_load_guild_storage_pre;
+ struct HPMHookPoint *HP_mapif_load_guild_storage_post;
+ struct HPMHookPoint *HP_mapif_save_guild_storage_ack_pre;
+ struct HPMHookPoint *HP_mapif_save_guild_storage_ack_post;
+ struct HPMHookPoint *HP_mapif_parse_LoadGuildStorage_pre;
+ struct HPMHookPoint *HP_mapif_parse_LoadGuildStorage_post;
+ struct HPMHookPoint *HP_mapif_parse_SaveGuildStorage_pre;
+ struct HPMHookPoint *HP_mapif_parse_SaveGuildStorage_post;
+ struct HPMHookPoint *HP_mapif_itembound_ack_pre;
+ struct HPMHookPoint *HP_mapif_itembound_ack_post;
+ struct HPMHookPoint *HP_mapif_parse_ItemBoundRetrieve_sub_pre;
+ struct HPMHookPoint *HP_mapif_parse_ItemBoundRetrieve_sub_post;
+ struct HPMHookPoint *HP_mapif_parse_ItemBoundRetrieve_pre;
+ struct HPMHookPoint *HP_mapif_parse_ItemBoundRetrieve_post;
+ struct HPMHookPoint *HP_mapif_parse_accinfo_pre;
+ struct HPMHookPoint *HP_mapif_parse_accinfo_post;
+ struct HPMHookPoint *HP_mapif_parse_accinfo2_pre;
+ struct HPMHookPoint *HP_mapif_parse_accinfo2_post;
+ struct HPMHookPoint *HP_mapif_broadcast_pre;
+ struct HPMHookPoint *HP_mapif_broadcast_post;
+ struct HPMHookPoint *HP_mapif_wis_message_pre;
+ struct HPMHookPoint *HP_mapif_wis_message_post;
+ struct HPMHookPoint *HP_mapif_wis_response_pre;
+ struct HPMHookPoint *HP_mapif_wis_response_post;
+ struct HPMHookPoint *HP_mapif_wis_end_pre;
+ struct HPMHookPoint *HP_mapif_wis_end_post;
+ struct HPMHookPoint *HP_mapif_account_reg_reply_pre;
+ struct HPMHookPoint *HP_mapif_account_reg_reply_post;
+ struct HPMHookPoint *HP_mapif_disconnectplayer_pre;
+ struct HPMHookPoint *HP_mapif_disconnectplayer_post;
+ struct HPMHookPoint *HP_mapif_parse_broadcast_pre;
+ struct HPMHookPoint *HP_mapif_parse_broadcast_post;
+ struct HPMHookPoint *HP_mapif_parse_WisRequest_pre;
+ struct HPMHookPoint *HP_mapif_parse_WisRequest_post;
+ struct HPMHookPoint *HP_mapif_parse_WisReply_pre;
+ struct HPMHookPoint *HP_mapif_parse_WisReply_post;
+ struct HPMHookPoint *HP_mapif_parse_WisToGM_pre;
+ struct HPMHookPoint *HP_mapif_parse_WisToGM_post;
+ struct HPMHookPoint *HP_mapif_parse_Registry_pre;
+ struct HPMHookPoint *HP_mapif_parse_Registry_post;
+ struct HPMHookPoint *HP_mapif_parse_RegistryRequest_pre;
+ struct HPMHookPoint *HP_mapif_parse_RegistryRequest_post;
+ struct HPMHookPoint *HP_mapif_namechange_ack_pre;
+ struct HPMHookPoint *HP_mapif_namechange_ack_post;
+ struct HPMHookPoint *HP_mapif_parse_NameChangeRequest_pre;
+ struct HPMHookPoint *HP_mapif_parse_NameChangeRequest_post;
+ struct HPMHookPoint *HP_pincode_handle_pre;
+ struct HPMHookPoint *HP_pincode_handle_post;
+ struct HPMHookPoint *HP_pincode_decrypt_pre;
+ struct HPMHookPoint *HP_pincode_decrypt_post;
+ struct HPMHookPoint *HP_pincode_error_pre;
+ struct HPMHookPoint *HP_pincode_error_post;
+ struct HPMHookPoint *HP_pincode_update_pre;
+ struct HPMHookPoint *HP_pincode_update_post;
+ struct HPMHookPoint *HP_pincode_sendstate_pre;
+ struct HPMHookPoint *HP_pincode_sendstate_post;
+ struct HPMHookPoint *HP_pincode_setnew_pre;
+ struct HPMHookPoint *HP_pincode_setnew_post;
+ struct HPMHookPoint *HP_pincode_change_pre;
+ struct HPMHookPoint *HP_pincode_change_post;
+ struct HPMHookPoint *HP_pincode_compare_pre;
+ struct HPMHookPoint *HP_pincode_compare_post;
+ struct HPMHookPoint *HP_pincode_check_pre;
+ struct HPMHookPoint *HP_pincode_check_post;
+ struct HPMHookPoint *HP_pincode_config_read_pre;
+ struct HPMHookPoint *HP_pincode_config_read_post;
+} list;
+
+struct {
+ int HP_chr_waiting_disconnect_pre;
+ int HP_chr_waiting_disconnect_post;
+ int HP_chr_delete_char_sql_pre;
+ int HP_chr_delete_char_sql_post;
+ int HP_chr_create_online_char_data_pre;
+ int HP_chr_create_online_char_data_post;
+ int HP_chr_set_account_online_pre;
+ int HP_chr_set_account_online_post;
+ int HP_chr_set_account_offline_pre;
+ int HP_chr_set_account_offline_post;
+ int HP_chr_set_char_charselect_pre;
+ int HP_chr_set_char_charselect_post;
+ int HP_chr_set_char_online_pre;
+ int HP_chr_set_char_online_post;
+ int HP_chr_set_char_offline_pre;
+ int HP_chr_set_char_offline_post;
+ int HP_chr_db_setoffline_pre;
+ int HP_chr_db_setoffline_post;
+ int HP_chr_db_kickoffline_pre;
+ int HP_chr_db_kickoffline_post;
+ int HP_chr_set_login_all_offline_pre;
+ int HP_chr_set_login_all_offline_post;
+ int HP_chr_set_all_offline_pre;
+ int HP_chr_set_all_offline_post;
+ int HP_chr_set_all_offline_sql_pre;
+ int HP_chr_set_all_offline_sql_post;
+ int HP_chr_create_charstatus_pre;
+ int HP_chr_create_charstatus_post;
+ int HP_chr_mmo_char_tosql_pre;
+ int HP_chr_mmo_char_tosql_post;
+ int HP_chr_memitemdata_to_sql_pre;
+ int HP_chr_memitemdata_to_sql_post;
+ int HP_chr_inventory_to_sql_pre;
+ int HP_chr_inventory_to_sql_post;
+ int HP_chr_mmo_chars_fromsql_pre;
+ int HP_chr_mmo_chars_fromsql_post;
+ int HP_chr_mmo_char_fromsql_pre;
+ int HP_chr_mmo_char_fromsql_post;
+ int HP_chr_mmo_char_sql_init_pre;
+ int HP_chr_mmo_char_sql_init_post;
+ int HP_chr_char_slotchange_pre;
+ int HP_chr_char_slotchange_post;
+ int HP_chr_rename_char_sql_pre;
+ int HP_chr_rename_char_sql_post;
+ int HP_chr_check_char_name_pre;
+ int HP_chr_check_char_name_post;
+ int HP_chr_make_new_char_sql_pre;
+ int HP_chr_make_new_char_sql_post;
+ int HP_chr_divorce_char_sql_pre;
+ int HP_chr_divorce_char_sql_post;
+ int HP_chr_count_users_pre;
+ int HP_chr_count_users_post;
+ int HP_chr_mmo_char_tobuf_pre;
+ int HP_chr_mmo_char_tobuf_post;
+ int HP_chr_mmo_char_send099d_pre;
+ int HP_chr_mmo_char_send099d_post;
+ int HP_chr_mmo_char_send_ban_list_pre;
+ int HP_chr_mmo_char_send_ban_list_post;
+ int HP_chr_mmo_char_send_slots_info_pre;
+ int HP_chr_mmo_char_send_slots_info_post;
+ int HP_chr_mmo_char_send_characters_pre;
+ int HP_chr_mmo_char_send_characters_post;
+ int HP_chr_char_married_pre;
+ int HP_chr_char_married_post;
+ int HP_chr_char_child_pre;
+ int HP_chr_char_child_post;
+ int HP_chr_char_family_pre;
+ int HP_chr_char_family_post;
+ int HP_chr_disconnect_player_pre;
+ int HP_chr_disconnect_player_post;
+ int HP_chr_authfail_fd_pre;
+ int HP_chr_authfail_fd_post;
+ int HP_chr_request_account_data_pre;
+ int HP_chr_request_account_data_post;
+ int HP_chr_auth_ok_pre;
+ int HP_chr_auth_ok_post;
+ int HP_chr_ping_login_server_pre;
+ int HP_chr_ping_login_server_post;
+ int HP_chr_parse_fromlogin_connection_state_pre;
+ int HP_chr_parse_fromlogin_connection_state_post;
+ int HP_chr_auth_error_pre;
+ int HP_chr_auth_error_post;
+ int HP_chr_parse_fromlogin_auth_state_pre;
+ int HP_chr_parse_fromlogin_auth_state_post;
+ int HP_chr_parse_fromlogin_account_data_pre;
+ int HP_chr_parse_fromlogin_account_data_post;
+ int HP_chr_parse_fromlogin_login_pong_pre;
+ int HP_chr_parse_fromlogin_login_pong_post;
+ int HP_chr_changesex_pre;
+ int HP_chr_changesex_post;
+ int HP_chr_parse_fromlogin_changesex_reply_pre;
+ int HP_chr_parse_fromlogin_changesex_reply_post;
+ int HP_chr_parse_fromlogin_account_reg2_pre;
+ int HP_chr_parse_fromlogin_account_reg2_post;
+ int HP_chr_parse_fromlogin_ban_pre;
+ int HP_chr_parse_fromlogin_ban_post;
+ int HP_chr_parse_fromlogin_kick_pre;
+ int HP_chr_parse_fromlogin_kick_post;
+ int HP_chr_update_ip_pre;
+ int HP_chr_update_ip_post;
+ int HP_chr_parse_fromlogin_update_ip_pre;
+ int HP_chr_parse_fromlogin_update_ip_post;
+ int HP_chr_parse_fromlogin_accinfo2_failed_pre;
+ int HP_chr_parse_fromlogin_accinfo2_failed_post;
+ int HP_chr_parse_fromlogin_accinfo2_ok_pre;
+ int HP_chr_parse_fromlogin_accinfo2_ok_post;
+ int HP_chr_parse_fromlogin_pre;
+ int HP_chr_parse_fromlogin_post;
+ int HP_chr_request_accreg2_pre;
+ int HP_chr_request_accreg2_post;
+ int HP_chr_global_accreg_to_login_start_pre;
+ int HP_chr_global_accreg_to_login_start_post;
+ int HP_chr_global_accreg_to_login_send_pre;
+ int HP_chr_global_accreg_to_login_send_post;
+ int HP_chr_global_accreg_to_login_add_pre;
+ int HP_chr_global_accreg_to_login_add_post;
+ int HP_chr_read_fame_list_pre;
+ int HP_chr_read_fame_list_post;
+ int HP_chr_send_fame_list_pre;
+ int HP_chr_send_fame_list_post;
+ int HP_chr_update_fame_list_pre;
+ int HP_chr_update_fame_list_post;
+ int HP_chr_loadName_pre;
+ int HP_chr_loadName_post;
+ int HP_chr_parse_frommap_datasync_pre;
+ int HP_chr_parse_frommap_datasync_post;
+ int HP_chr_parse_frommap_skillid2idx_pre;
+ int HP_chr_parse_frommap_skillid2idx_post;
+ int HP_chr_map_received_ok_pre;
+ int HP_chr_map_received_ok_post;
+ int HP_chr_send_maps_pre;
+ int HP_chr_send_maps_post;
+ int HP_chr_parse_frommap_map_names_pre;
+ int HP_chr_parse_frommap_map_names_post;
+ int HP_chr_send_scdata_pre;
+ int HP_chr_send_scdata_post;
+ int HP_chr_parse_frommap_request_scdata_pre;
+ int HP_chr_parse_frommap_request_scdata_post;
+ int HP_chr_parse_frommap_set_users_count_pre;
+ int HP_chr_parse_frommap_set_users_count_post;
+ int HP_chr_parse_frommap_set_users_pre;
+ int HP_chr_parse_frommap_set_users_post;
+ int HP_chr_save_character_ack_pre;
+ int HP_chr_save_character_ack_post;
+ int HP_chr_parse_frommap_save_character_pre;
+ int HP_chr_parse_frommap_save_character_post;
+ int HP_chr_select_ack_pre;
+ int HP_chr_select_ack_post;
+ int HP_chr_parse_frommap_char_select_req_pre;
+ int HP_chr_parse_frommap_char_select_req_post;
+ int HP_chr_change_map_server_ack_pre;
+ int HP_chr_change_map_server_ack_post;
+ int HP_chr_parse_frommap_change_map_server_pre;
+ int HP_chr_parse_frommap_change_map_server_post;
+ int HP_chr_parse_frommap_remove_friend_pre;
+ int HP_chr_parse_frommap_remove_friend_post;
+ int HP_chr_char_name_ack_pre;
+ int HP_chr_char_name_ack_post;
+ int HP_chr_parse_frommap_char_name_request_pre;
+ int HP_chr_parse_frommap_char_name_request_post;
+ int HP_chr_parse_frommap_change_email_pre;
+ int HP_chr_parse_frommap_change_email_post;
+ int HP_chr_ban_pre;
+ int HP_chr_ban_post;
+ int HP_chr_unban_pre;
+ int HP_chr_unban_post;
+ int HP_chr_ask_name_ack_pre;
+ int HP_chr_ask_name_ack_post;
+ int HP_chr_parse_frommap_change_account_pre;
+ int HP_chr_parse_frommap_change_account_post;
+ int HP_chr_parse_frommap_fame_list_pre;
+ int HP_chr_parse_frommap_fame_list_post;
+ int HP_chr_parse_frommap_divorce_char_pre;
+ int HP_chr_parse_frommap_divorce_char_post;
+ int HP_chr_parse_frommap_ragsrvinfo_pre;
+ int HP_chr_parse_frommap_ragsrvinfo_post;
+ int HP_chr_parse_frommap_set_char_offline_pre;
+ int HP_chr_parse_frommap_set_char_offline_post;
+ int HP_chr_parse_frommap_set_all_offline_pre;
+ int HP_chr_parse_frommap_set_all_offline_post;
+ int HP_chr_parse_frommap_set_char_online_pre;
+ int HP_chr_parse_frommap_set_char_online_post;
+ int HP_chr_parse_frommap_build_fame_list_pre;
+ int HP_chr_parse_frommap_build_fame_list_post;
+ int HP_chr_parse_frommap_save_status_change_data_pre;
+ int HP_chr_parse_frommap_save_status_change_data_post;
+ int HP_chr_send_pong_pre;
+ int HP_chr_send_pong_post;
+ int HP_chr_parse_frommap_ping_pre;
+ int HP_chr_parse_frommap_ping_post;
+ int HP_chr_map_auth_ok_pre;
+ int HP_chr_map_auth_ok_post;
+ int HP_chr_map_auth_failed_pre;
+ int HP_chr_map_auth_failed_post;
+ int HP_chr_parse_frommap_auth_request_pre;
+ int HP_chr_parse_frommap_auth_request_post;
+ int HP_chr_parse_frommap_update_ip_pre;
+ int HP_chr_parse_frommap_update_ip_post;
+ int HP_chr_parse_frommap_request_stats_report_pre;
+ int HP_chr_parse_frommap_request_stats_report_post;
+ int HP_chr_parse_frommap_scdata_update_pre;
+ int HP_chr_parse_frommap_scdata_update_post;
+ int HP_chr_parse_frommap_scdata_delete_pre;
+ int HP_chr_parse_frommap_scdata_delete_post;
+ int HP_chr_parse_frommap_pre;
+ int HP_chr_parse_frommap_post;
+ int HP_chr_search_mapserver_pre;
+ int HP_chr_search_mapserver_post;
+ int HP_chr_mapif_init_pre;
+ int HP_chr_mapif_init_post;
+ int HP_chr_lan_subnetcheck_pre;
+ int HP_chr_lan_subnetcheck_post;
+ int HP_chr_delete2_ack_pre;
+ int HP_chr_delete2_ack_post;
+ int HP_chr_delete2_accept_actual_ack_pre;
+ int HP_chr_delete2_accept_actual_ack_post;
+ int HP_chr_delete2_accept_ack_pre;
+ int HP_chr_delete2_accept_ack_post;
+ int HP_chr_delete2_cancel_ack_pre;
+ int HP_chr_delete2_cancel_ack_post;
+ int HP_chr_delete2_req_pre;
+ int HP_chr_delete2_req_post;
+ int HP_chr_delete2_accept_pre;
+ int HP_chr_delete2_accept_post;
+ int HP_chr_delete2_cancel_pre;
+ int HP_chr_delete2_cancel_post;
+ int HP_chr_send_account_id_pre;
+ int HP_chr_send_account_id_post;
+ int HP_chr_parse_char_connect_pre;
+ int HP_chr_parse_char_connect_post;
+ int HP_chr_send_map_info_pre;
+ int HP_chr_send_map_info_post;
+ int HP_chr_send_wait_char_server_pre;
+ int HP_chr_send_wait_char_server_post;
+ int HP_chr_search_default_maps_mapserver_pre;
+ int HP_chr_search_default_maps_mapserver_post;
+ int HP_chr_parse_char_select_pre;
+ int HP_chr_parse_char_select_post;
+ int HP_chr_creation_failed_pre;
+ int HP_chr_creation_failed_post;
+ int HP_chr_creation_ok_pre;
+ int HP_chr_creation_ok_post;
+ int HP_chr_parse_char_create_new_char_pre;
+ int HP_chr_parse_char_create_new_char_post;
+ int HP_chr_delete_char_failed_pre;
+ int HP_chr_delete_char_failed_post;
+ int HP_chr_delete_char_ok_pre;
+ int HP_chr_delete_char_ok_post;
+ int HP_chr_parse_char_delete_char_pre;
+ int HP_chr_parse_char_delete_char_post;
+ int HP_chr_parse_char_ping_pre;
+ int HP_chr_parse_char_ping_post;
+ int HP_chr_allow_rename_pre;
+ int HP_chr_allow_rename_post;
+ int HP_chr_parse_char_rename_char_pre;
+ int HP_chr_parse_char_rename_char_post;
+ int HP_chr_parse_char_rename_char2_pre;
+ int HP_chr_parse_char_rename_char2_post;
+ int HP_chr_rename_char_ack_pre;
+ int HP_chr_rename_char_ack_post;
+ int HP_chr_parse_char_rename_char_confirm_pre;
+ int HP_chr_parse_char_rename_char_confirm_post;
+ int HP_chr_captcha_notsupported_pre;
+ int HP_chr_captcha_notsupported_post;
+ int HP_chr_parse_char_request_captcha_pre;
+ int HP_chr_parse_char_request_captcha_post;
+ int HP_chr_parse_char_check_captcha_pre;
+ int HP_chr_parse_char_check_captcha_post;
+ int HP_chr_parse_char_delete2_req_pre;
+ int HP_chr_parse_char_delete2_req_post;
+ int HP_chr_parse_char_delete2_accept_pre;
+ int HP_chr_parse_char_delete2_accept_post;
+ int HP_chr_parse_char_delete2_cancel_pre;
+ int HP_chr_parse_char_delete2_cancel_post;
+ int HP_chr_login_map_server_ack_pre;
+ int HP_chr_login_map_server_ack_post;
+ int HP_chr_parse_char_login_map_server_pre;
+ int HP_chr_parse_char_login_map_server_post;
+ int HP_chr_parse_char_pincode_check_pre;
+ int HP_chr_parse_char_pincode_check_post;
+ int HP_chr_parse_char_pincode_window_pre;
+ int HP_chr_parse_char_pincode_window_post;
+ int HP_chr_parse_char_pincode_change_pre;
+ int HP_chr_parse_char_pincode_change_post;
+ int HP_chr_parse_char_pincode_first_pin_pre;
+ int HP_chr_parse_char_pincode_first_pin_post;
+ int HP_chr_parse_char_request_chars_pre;
+ int HP_chr_parse_char_request_chars_post;
+ int HP_chr_change_character_slot_ack_pre;
+ int HP_chr_change_character_slot_ack_post;
+ int HP_chr_parse_char_move_character_pre;
+ int HP_chr_parse_char_move_character_post;
+ int HP_chr_parse_char_unknown_packet_pre;
+ int HP_chr_parse_char_unknown_packet_post;
+ int HP_chr_parse_char_pre;
+ int HP_chr_parse_char_post;
+ int HP_chr_broadcast_user_count_pre;
+ int HP_chr_broadcast_user_count_post;
+ int HP_chr_send_accounts_tologin_sub_pre;
+ int HP_chr_send_accounts_tologin_sub_post;
+ int HP_chr_send_accounts_tologin_pre;
+ int HP_chr_send_accounts_tologin_post;
+ int HP_chr_check_connect_login_server_pre;
+ int HP_chr_check_connect_login_server_post;
+ int HP_chr_online_data_cleanup_sub_pre;
+ int HP_chr_online_data_cleanup_sub_post;
+ int HP_chr_online_data_cleanup_pre;
+ int HP_chr_online_data_cleanup_post;
+ int HP_chr_lan_config_read_pre;
+ int HP_chr_lan_config_read_post;
+ int HP_chr_sql_config_read_pre;
+ int HP_chr_sql_config_read_post;
+ int HP_chr_config_dispatch_pre;
+ int HP_chr_config_dispatch_post;
+ int HP_chr_config_read_pre;
+ int HP_chr_config_read_post;
+ int HP_geoip_getcountry_pre;
+ int HP_geoip_getcountry_post;
+ int HP_geoip_final_pre;
+ int HP_geoip_final_post;
+ int HP_geoip_init_pre;
+ int HP_geoip_init_post;
+ int HP_inter_auction_count_pre;
+ int HP_inter_auction_count_post;
+ int HP_inter_auction_save_pre;
+ int HP_inter_auction_save_post;
+ int HP_inter_auction_create_pre;
+ int HP_inter_auction_create_post;
+ int HP_inter_auction_end_timer_pre;
+ int HP_inter_auction_end_timer_post;
+ int HP_inter_auction_delete__pre;
+ int HP_inter_auction_delete__post;
+ int HP_inter_auction_fromsql_pre;
+ int HP_inter_auction_fromsql_post;
+ int HP_inter_auction_parse_frommap_pre;
+ int HP_inter_auction_parse_frommap_post;
+ int HP_inter_auction_sql_init_pre;
+ int HP_inter_auction_sql_init_post;
+ int HP_inter_auction_sql_final_pre;
+ int HP_inter_auction_sql_final_post;
+ int HP_inter_elemental_sql_init_pre;
+ int HP_inter_elemental_sql_init_post;
+ int HP_inter_elemental_sql_final_pre;
+ int HP_inter_elemental_sql_final_post;
+ int HP_inter_elemental_parse_frommap_pre;
+ int HP_inter_elemental_parse_frommap_post;
+ int HP_inter_guild_save_timer_pre;
+ int HP_inter_guild_save_timer_post;
+ int HP_inter_guild_removemember_tosql_pre;
+ int HP_inter_guild_removemember_tosql_post;
+ int HP_inter_guild_tosql_pre;
+ int HP_inter_guild_tosql_post;
+ int HP_inter_guild_fromsql_pre;
+ int HP_inter_guild_fromsql_post;
+ int HP_inter_guild_castle_tosql_pre;
+ int HP_inter_guild_castle_tosql_post;
+ int HP_inter_guild_castle_fromsql_pre;
+ int HP_inter_guild_castle_fromsql_post;
+ int HP_inter_guild_exp_parse_row_pre;
+ int HP_inter_guild_exp_parse_row_post;
+ int HP_inter_guild_CharOnline_pre;
+ int HP_inter_guild_CharOnline_post;
+ int HP_inter_guild_CharOffline_pre;
+ int HP_inter_guild_CharOffline_post;
+ int HP_inter_guild_sql_init_pre;
+ int HP_inter_guild_sql_init_post;
+ int HP_inter_guild_db_final_pre;
+ int HP_inter_guild_db_final_post;
+ int HP_inter_guild_sql_final_pre;
+ int HP_inter_guild_sql_final_post;
+ int HP_inter_guild_search_guildname_pre;
+ int HP_inter_guild_search_guildname_post;
+ int HP_inter_guild_check_empty_pre;
+ int HP_inter_guild_check_empty_post;
+ int HP_inter_guild_nextexp_pre;
+ int HP_inter_guild_nextexp_post;
+ int HP_inter_guild_checkskill_pre;
+ int HP_inter_guild_checkskill_post;
+ int HP_inter_guild_calcinfo_pre;
+ int HP_inter_guild_calcinfo_post;
+ int HP_inter_guild_sex_changed_pre;
+ int HP_inter_guild_sex_changed_post;
+ int HP_inter_guild_charname_changed_pre;
+ int HP_inter_guild_charname_changed_post;
+ int HP_inter_guild_parse_frommap_pre;
+ int HP_inter_guild_parse_frommap_post;
+ int HP_inter_guild_leave_pre;
+ int HP_inter_guild_leave_post;
+ int HP_inter_guild_broken_pre;
+ int HP_inter_guild_broken_post;
+ int HP_inter_homunculus_sql_init_pre;
+ int HP_inter_homunculus_sql_init_post;
+ int HP_inter_homunculus_sql_final_pre;
+ int HP_inter_homunculus_sql_final_post;
+ int HP_inter_homunculus_parse_frommap_pre;
+ int HP_inter_homunculus_parse_frommap_post;
+ int HP_inter_msg_txt_pre;
+ int HP_inter_msg_txt_post;
+ int HP_inter_msg_config_read_pre;
+ int HP_inter_msg_config_read_post;
+ int HP_inter_do_final_msg_pre;
+ int HP_inter_do_final_msg_post;
+ int HP_inter_job_name_pre;
+ int HP_inter_job_name_post;
+ int HP_inter_vmsg_to_fd_pre;
+ int HP_inter_vmsg_to_fd_post;
+ int HP_inter_savereg_pre;
+ int HP_inter_savereg_post;
+ int HP_inter_accreg_fromsql_pre;
+ int HP_inter_accreg_fromsql_post;
+ int HP_inter_config_read_pre;
+ int HP_inter_config_read_post;
+ int HP_inter_vlog_pre;
+ int HP_inter_vlog_post;
+ int HP_inter_init_sql_pre;
+ int HP_inter_init_sql_post;
+ int HP_inter_mapif_init_pre;
+ int HP_inter_mapif_init_post;
+ int HP_inter_check_ttl_wisdata_sub_pre;
+ int HP_inter_check_ttl_wisdata_sub_post;
+ int HP_inter_check_ttl_wisdata_pre;
+ int HP_inter_check_ttl_wisdata_post;
+ int HP_inter_check_length_pre;
+ int HP_inter_check_length_post;
+ int HP_inter_parse_frommap_pre;
+ int HP_inter_parse_frommap_post;
+ int HP_inter_final_pre;
+ int HP_inter_final_post;
+ int HP_inter_mail_sql_init_pre;
+ int HP_inter_mail_sql_init_post;
+ int HP_inter_mail_sql_final_pre;
+ int HP_inter_mail_sql_final_post;
+ int HP_inter_mail_parse_frommap_pre;
+ int HP_inter_mail_parse_frommap_post;
+ int HP_inter_mail_fromsql_pre;
+ int HP_inter_mail_fromsql_post;
+ int HP_inter_mail_savemessage_pre;
+ int HP_inter_mail_savemessage_post;
+ int HP_inter_mail_loadmessage_pre;
+ int HP_inter_mail_loadmessage_post;
+ int HP_inter_mail_DeleteAttach_pre;
+ int HP_inter_mail_DeleteAttach_post;
+ int HP_inter_mail_sendmail_pre;
+ int HP_inter_mail_sendmail_post;
+ int HP_inter_mercenary_owner_fromsql_pre;
+ int HP_inter_mercenary_owner_fromsql_post;
+ int HP_inter_mercenary_owner_tosql_pre;
+ int HP_inter_mercenary_owner_tosql_post;
+ int HP_inter_mercenary_owner_delete_pre;
+ int HP_inter_mercenary_owner_delete_post;
+ int HP_inter_mercenary_sql_init_pre;
+ int HP_inter_mercenary_sql_init_post;
+ int HP_inter_mercenary_sql_final_pre;
+ int HP_inter_mercenary_sql_final_post;
+ int HP_inter_mercenary_parse_frommap_pre;
+ int HP_inter_mercenary_parse_frommap_post;
+ int HP_inter_party_check_lv_pre;
+ int HP_inter_party_check_lv_post;
+ int HP_inter_party_calc_state_pre;
+ int HP_inter_party_calc_state_post;
+ int HP_inter_party_tosql_pre;
+ int HP_inter_party_tosql_post;
+ int HP_inter_party_fromsql_pre;
+ int HP_inter_party_fromsql_post;
+ int HP_inter_party_sql_init_pre;
+ int HP_inter_party_sql_init_post;
+ int HP_inter_party_sql_final_pre;
+ int HP_inter_party_sql_final_post;
+ int HP_inter_party_search_partyname_pre;
+ int HP_inter_party_search_partyname_post;
+ int HP_inter_party_check_exp_share_pre;
+ int HP_inter_party_check_exp_share_post;
+ int HP_inter_party_check_empty_pre;
+ int HP_inter_party_check_empty_post;
+ int HP_inter_party_parse_frommap_pre;
+ int HP_inter_party_parse_frommap_post;
+ int HP_inter_party_leave_pre;
+ int HP_inter_party_leave_post;
+ int HP_inter_party_CharOnline_pre;
+ int HP_inter_party_CharOnline_post;
+ int HP_inter_party_CharOffline_pre;
+ int HP_inter_party_CharOffline_post;
+ int HP_inter_pet_tosql_pre;
+ int HP_inter_pet_tosql_post;
+ int HP_inter_pet_fromsql_pre;
+ int HP_inter_pet_fromsql_post;
+ int HP_inter_pet_sql_init_pre;
+ int HP_inter_pet_sql_init_post;
+ int HP_inter_pet_sql_final_pre;
+ int HP_inter_pet_sql_final_post;
+ int HP_inter_pet_delete__pre;
+ int HP_inter_pet_delete__post;
+ int HP_inter_pet_parse_frommap_pre;
+ int HP_inter_pet_parse_frommap_post;
+ int HP_inter_quest_parse_frommap_pre;
+ int HP_inter_quest_parse_frommap_post;
+ int HP_inter_storage_tosql_pre;
+ int HP_inter_storage_tosql_post;
+ int HP_inter_storage_fromsql_pre;
+ int HP_inter_storage_fromsql_post;
+ int HP_inter_storage_guild_storage_tosql_pre;
+ int HP_inter_storage_guild_storage_tosql_post;
+ int HP_inter_storage_guild_storage_fromsql_pre;
+ int HP_inter_storage_guild_storage_fromsql_post;
+ int HP_inter_storage_sql_init_pre;
+ int HP_inter_storage_sql_init_post;
+ int HP_inter_storage_sql_final_pre;
+ int HP_inter_storage_sql_final_post;
+ int HP_inter_storage_delete__pre;
+ int HP_inter_storage_delete__post;
+ int HP_inter_storage_guild_storage_delete_pre;
+ int HP_inter_storage_guild_storage_delete_post;
+ int HP_inter_storage_parse_frommap_pre;
+ int HP_inter_storage_parse_frommap_post;
+ int HP_loginif_init_pre;
+ int HP_loginif_init_post;
+ int HP_loginif_final_pre;
+ int HP_loginif_final_post;
+ int HP_loginif_reset_pre;
+ int HP_loginif_reset_post;
+ int HP_loginif_check_shutdown_pre;
+ int HP_loginif_check_shutdown_post;
+ int HP_loginif_on_disconnect_pre;
+ int HP_loginif_on_disconnect_post;
+ int HP_loginif_on_ready_pre;
+ int HP_loginif_on_ready_post;
+ int HP_loginif_block_account_pre;
+ int HP_loginif_block_account_post;
+ int HP_loginif_ban_account_pre;
+ int HP_loginif_ban_account_post;
+ int HP_loginif_unban_account_pre;
+ int HP_loginif_unban_account_post;
+ int HP_loginif_changesex_pre;
+ int HP_loginif_changesex_post;
+ int HP_loginif_auth_pre;
+ int HP_loginif_auth_post;
+ int HP_loginif_send_users_count_pre;
+ int HP_loginif_send_users_count_post;
+ int HP_loginif_connect_to_server_pre;
+ int HP_loginif_connect_to_server_post;
+ int HP_mapif_ban_pre;
+ int HP_mapif_ban_post;
+ int HP_mapif_server_init_pre;
+ int HP_mapif_server_init_post;
+ int HP_mapif_server_destroy_pre;
+ int HP_mapif_server_destroy_post;
+ int HP_mapif_server_reset_pre;
+ int HP_mapif_server_reset_post;
+ int HP_mapif_on_disconnect_pre;
+ int HP_mapif_on_disconnect_post;
+ int HP_mapif_on_parse_accinfo_pre;
+ int HP_mapif_on_parse_accinfo_post;
+ int HP_mapif_char_ban_pre;
+ int HP_mapif_char_ban_post;
+ int HP_mapif_sendall_pre;
+ int HP_mapif_sendall_post;
+ int HP_mapif_sendallwos_pre;
+ int HP_mapif_sendallwos_post;
+ int HP_mapif_send_pre;
+ int HP_mapif_send_post;
+ int HP_mapif_send_users_count_pre;
+ int HP_mapif_send_users_count_post;
+ int HP_mapif_auction_message_pre;
+ int HP_mapif_auction_message_post;
+ int HP_mapif_auction_sendlist_pre;
+ int HP_mapif_auction_sendlist_post;
+ int HP_mapif_parse_auction_requestlist_pre;
+ int HP_mapif_parse_auction_requestlist_post;
+ int HP_mapif_auction_register_pre;
+ int HP_mapif_auction_register_post;
+ int HP_mapif_parse_auction_register_pre;
+ int HP_mapif_parse_auction_register_post;
+ int HP_mapif_auction_cancel_pre;
+ int HP_mapif_auction_cancel_post;
+ int HP_mapif_parse_auction_cancel_pre;
+ int HP_mapif_parse_auction_cancel_post;
+ int HP_mapif_auction_close_pre;
+ int HP_mapif_auction_close_post;
+ int HP_mapif_parse_auction_close_pre;
+ int HP_mapif_parse_auction_close_post;
+ int HP_mapif_auction_bid_pre;
+ int HP_mapif_auction_bid_post;
+ int HP_mapif_parse_auction_bid_pre;
+ int HP_mapif_parse_auction_bid_post;
+ int HP_mapif_elemental_save_pre;
+ int HP_mapif_elemental_save_post;
+ int HP_mapif_elemental_load_pre;
+ int HP_mapif_elemental_load_post;
+ int HP_mapif_elemental_delete_pre;
+ int HP_mapif_elemental_delete_post;
+ int HP_mapif_elemental_send_pre;
+ int HP_mapif_elemental_send_post;
+ int HP_mapif_parse_elemental_create_pre;
+ int HP_mapif_parse_elemental_create_post;
+ int HP_mapif_parse_elemental_load_pre;
+ int HP_mapif_parse_elemental_load_post;
+ int HP_mapif_elemental_deleted_pre;
+ int HP_mapif_elemental_deleted_post;
+ int HP_mapif_parse_elemental_delete_pre;
+ int HP_mapif_parse_elemental_delete_post;
+ int HP_mapif_elemental_saved_pre;
+ int HP_mapif_elemental_saved_post;
+ int HP_mapif_parse_elemental_save_pre;
+ int HP_mapif_parse_elemental_save_post;
+ int HP_mapif_guild_created_pre;
+ int HP_mapif_guild_created_post;
+ int HP_mapif_guild_noinfo_pre;
+ int HP_mapif_guild_noinfo_post;
+ int HP_mapif_guild_info_pre;
+ int HP_mapif_guild_info_post;
+ int HP_mapif_guild_memberadded_pre;
+ int HP_mapif_guild_memberadded_post;
+ int HP_mapif_guild_withdraw_pre;
+ int HP_mapif_guild_withdraw_post;
+ int HP_mapif_guild_memberinfoshort_pre;
+ int HP_mapif_guild_memberinfoshort_post;
+ int HP_mapif_guild_broken_pre;
+ int HP_mapif_guild_broken_post;
+ int HP_mapif_guild_message_pre;
+ int HP_mapif_guild_message_post;
+ int HP_mapif_guild_basicinfochanged_pre;
+ int HP_mapif_guild_basicinfochanged_post;
+ int HP_mapif_guild_memberinfochanged_pre;
+ int HP_mapif_guild_memberinfochanged_post;
+ int HP_mapif_guild_skillupack_pre;
+ int HP_mapif_guild_skillupack_post;
+ int HP_mapif_guild_alliance_pre;
+ int HP_mapif_guild_alliance_post;
+ int HP_mapif_guild_position_pre;
+ int HP_mapif_guild_position_post;
+ int HP_mapif_guild_notice_pre;
+ int HP_mapif_guild_notice_post;
+ int HP_mapif_guild_emblem_pre;
+ int HP_mapif_guild_emblem_post;
+ int HP_mapif_guild_master_changed_pre;
+ int HP_mapif_guild_master_changed_post;
+ int HP_mapif_guild_castle_dataload_pre;
+ int HP_mapif_guild_castle_dataload_post;
+ int HP_mapif_parse_CreateGuild_pre;
+ int HP_mapif_parse_CreateGuild_post;
+ int HP_mapif_parse_GuildInfo_pre;
+ int HP_mapif_parse_GuildInfo_post;
+ int HP_mapif_parse_GuildAddMember_pre;
+ int HP_mapif_parse_GuildAddMember_post;
+ int HP_mapif_parse_GuildLeave_pre;
+ int HP_mapif_parse_GuildLeave_post;
+ int HP_mapif_parse_GuildChangeMemberInfoShort_pre;
+ int HP_mapif_parse_GuildChangeMemberInfoShort_post;
+ int HP_mapif_parse_BreakGuild_pre;
+ int HP_mapif_parse_BreakGuild_post;
+ int HP_mapif_parse_GuildMessage_pre;
+ int HP_mapif_parse_GuildMessage_post;
+ int HP_mapif_parse_GuildBasicInfoChange_pre;
+ int HP_mapif_parse_GuildBasicInfoChange_post;
+ int HP_mapif_parse_GuildMemberInfoChange_pre;
+ int HP_mapif_parse_GuildMemberInfoChange_post;
+ int HP_mapif_parse_GuildPosition_pre;
+ int HP_mapif_parse_GuildPosition_post;
+ int HP_mapif_parse_GuildSkillUp_pre;
+ int HP_mapif_parse_GuildSkillUp_post;
+ int HP_mapif_parse_GuildDeleteAlliance_pre;
+ int HP_mapif_parse_GuildDeleteAlliance_post;
+ int HP_mapif_parse_GuildAlliance_pre;
+ int HP_mapif_parse_GuildAlliance_post;
+ int HP_mapif_parse_GuildNotice_pre;
+ int HP_mapif_parse_GuildNotice_post;
+ int HP_mapif_parse_GuildEmblem_pre;
+ int HP_mapif_parse_GuildEmblem_post;
+ int HP_mapif_parse_GuildCastleDataLoad_pre;
+ int HP_mapif_parse_GuildCastleDataLoad_post;
+ int HP_mapif_parse_GuildCastleDataSave_pre;
+ int HP_mapif_parse_GuildCastleDataSave_post;
+ int HP_mapif_parse_GuildMasterChange_pre;
+ int HP_mapif_parse_GuildMasterChange_post;
+ int HP_mapif_homunculus_created_pre;
+ int HP_mapif_homunculus_created_post;
+ int HP_mapif_homunculus_deleted_pre;
+ int HP_mapif_homunculus_deleted_post;
+ int HP_mapif_homunculus_loaded_pre;
+ int HP_mapif_homunculus_loaded_post;
+ int HP_mapif_homunculus_saved_pre;
+ int HP_mapif_homunculus_saved_post;
+ int HP_mapif_homunculus_renamed_pre;
+ int HP_mapif_homunculus_renamed_post;
+ int HP_mapif_homunculus_save_pre;
+ int HP_mapif_homunculus_save_post;
+ int HP_mapif_homunculus_load_pre;
+ int HP_mapif_homunculus_load_post;
+ int HP_mapif_homunculus_delete_pre;
+ int HP_mapif_homunculus_delete_post;
+ int HP_mapif_homunculus_rename_pre;
+ int HP_mapif_homunculus_rename_post;
+ int HP_mapif_parse_homunculus_create_pre;
+ int HP_mapif_parse_homunculus_create_post;
+ int HP_mapif_parse_homunculus_delete_pre;
+ int HP_mapif_parse_homunculus_delete_post;
+ int HP_mapif_parse_homunculus_load_pre;
+ int HP_mapif_parse_homunculus_load_post;
+ int HP_mapif_parse_homunculus_save_pre;
+ int HP_mapif_parse_homunculus_save_post;
+ int HP_mapif_parse_homunculus_rename_pre;
+ int HP_mapif_parse_homunculus_rename_post;
+ int HP_mapif_mail_sendinbox_pre;
+ int HP_mapif_mail_sendinbox_post;
+ int HP_mapif_parse_mail_requestinbox_pre;
+ int HP_mapif_parse_mail_requestinbox_post;
+ int HP_mapif_parse_mail_read_pre;
+ int HP_mapif_parse_mail_read_post;
+ int HP_mapif_mail_sendattach_pre;
+ int HP_mapif_mail_sendattach_post;
+ int HP_mapif_mail_getattach_pre;
+ int HP_mapif_mail_getattach_post;
+ int HP_mapif_parse_mail_getattach_pre;
+ int HP_mapif_parse_mail_getattach_post;
+ int HP_mapif_mail_delete_pre;
+ int HP_mapif_mail_delete_post;
+ int HP_mapif_parse_mail_delete_pre;
+ int HP_mapif_parse_mail_delete_post;
+ int HP_mapif_mail_new_pre;
+ int HP_mapif_mail_new_post;
+ int HP_mapif_mail_return_pre;
+ int HP_mapif_mail_return_post;
+ int HP_mapif_parse_mail_return_pre;
+ int HP_mapif_parse_mail_return_post;
+ int HP_mapif_mail_send_pre;
+ int HP_mapif_mail_send_post;
+ int HP_mapif_parse_mail_send_pre;
+ int HP_mapif_parse_mail_send_post;
+ int HP_mapif_mercenary_save_pre;
+ int HP_mapif_mercenary_save_post;
+ int HP_mapif_mercenary_load_pre;
+ int HP_mapif_mercenary_load_post;
+ int HP_mapif_mercenary_delete_pre;
+ int HP_mapif_mercenary_delete_post;
+ int HP_mapif_mercenary_send_pre;
+ int HP_mapif_mercenary_send_post;
+ int HP_mapif_parse_mercenary_create_pre;
+ int HP_mapif_parse_mercenary_create_post;
+ int HP_mapif_parse_mercenary_load_pre;
+ int HP_mapif_parse_mercenary_load_post;
+ int HP_mapif_mercenary_deleted_pre;
+ int HP_mapif_mercenary_deleted_post;
+ int HP_mapif_parse_mercenary_delete_pre;
+ int HP_mapif_parse_mercenary_delete_post;
+ int HP_mapif_mercenary_saved_pre;
+ int HP_mapif_mercenary_saved_post;
+ int HP_mapif_parse_mercenary_save_pre;
+ int HP_mapif_parse_mercenary_save_post;
+ int HP_mapif_party_created_pre;
+ int HP_mapif_party_created_post;
+ int HP_mapif_party_noinfo_pre;
+ int HP_mapif_party_noinfo_post;
+ int HP_mapif_party_info_pre;
+ int HP_mapif_party_info_post;
+ int HP_mapif_party_memberadded_pre;
+ int HP_mapif_party_memberadded_post;
+ int HP_mapif_party_optionchanged_pre;
+ int HP_mapif_party_optionchanged_post;
+ int HP_mapif_party_withdraw_pre;
+ int HP_mapif_party_withdraw_post;
+ int HP_mapif_party_membermoved_pre;
+ int HP_mapif_party_membermoved_post;
+ int HP_mapif_party_broken_pre;
+ int HP_mapif_party_broken_post;
+ int HP_mapif_party_message_pre;
+ int HP_mapif_party_message_post;
+ int HP_mapif_parse_CreateParty_pre;
+ int HP_mapif_parse_CreateParty_post;
+ int HP_mapif_parse_PartyInfo_pre;
+ int HP_mapif_parse_PartyInfo_post;
+ int HP_mapif_parse_PartyAddMember_pre;
+ int HP_mapif_parse_PartyAddMember_post;
+ int HP_mapif_parse_PartyChangeOption_pre;
+ int HP_mapif_parse_PartyChangeOption_post;
+ int HP_mapif_parse_PartyLeave_pre;
+ int HP_mapif_parse_PartyLeave_post;
+ int HP_mapif_parse_PartyChangeMap_pre;
+ int HP_mapif_parse_PartyChangeMap_post;
+ int HP_mapif_parse_BreakParty_pre;
+ int HP_mapif_parse_BreakParty_post;
+ int HP_mapif_parse_PartyMessage_pre;
+ int HP_mapif_parse_PartyMessage_post;
+ int HP_mapif_parse_PartyLeaderChange_pre;
+ int HP_mapif_parse_PartyLeaderChange_post;
+ int HP_mapif_pet_created_pre;
+ int HP_mapif_pet_created_post;
+ int HP_mapif_pet_info_pre;
+ int HP_mapif_pet_info_post;
+ int HP_mapif_pet_noinfo_pre;
+ int HP_mapif_pet_noinfo_post;
+ int HP_mapif_save_pet_ack_pre;
+ int HP_mapif_save_pet_ack_post;
+ int HP_mapif_delete_pet_ack_pre;
+ int HP_mapif_delete_pet_ack_post;
+ int HP_mapif_create_pet_pre;
+ int HP_mapif_create_pet_post;
+ int HP_mapif_load_pet_pre;
+ int HP_mapif_load_pet_post;
+ int HP_mapif_save_pet_pre;
+ int HP_mapif_save_pet_post;
+ int HP_mapif_delete_pet_pre;
+ int HP_mapif_delete_pet_post;
+ int HP_mapif_parse_CreatePet_pre;
+ int HP_mapif_parse_CreatePet_post;
+ int HP_mapif_parse_LoadPet_pre;
+ int HP_mapif_parse_LoadPet_post;
+ int HP_mapif_parse_SavePet_pre;
+ int HP_mapif_parse_SavePet_post;
+ int HP_mapif_parse_DeletePet_pre;
+ int HP_mapif_parse_DeletePet_post;
+ int HP_mapif_quests_fromsql_pre;
+ int HP_mapif_quests_fromsql_post;
+ int HP_mapif_quest_delete_pre;
+ int HP_mapif_quest_delete_post;
+ int HP_mapif_quest_add_pre;
+ int HP_mapif_quest_add_post;
+ int HP_mapif_quest_update_pre;
+ int HP_mapif_quest_update_post;
+ int HP_mapif_quest_save_ack_pre;
+ int HP_mapif_quest_save_ack_post;
+ int HP_mapif_parse_quest_save_pre;
+ int HP_mapif_parse_quest_save_post;
+ int HP_mapif_send_quests_pre;
+ int HP_mapif_send_quests_post;
+ int HP_mapif_parse_quest_load_pre;
+ int HP_mapif_parse_quest_load_post;
+ int HP_mapif_load_guild_storage_pre;
+ int HP_mapif_load_guild_storage_post;
+ int HP_mapif_save_guild_storage_ack_pre;
+ int HP_mapif_save_guild_storage_ack_post;
+ int HP_mapif_parse_LoadGuildStorage_pre;
+ int HP_mapif_parse_LoadGuildStorage_post;
+ int HP_mapif_parse_SaveGuildStorage_pre;
+ int HP_mapif_parse_SaveGuildStorage_post;
+ int HP_mapif_itembound_ack_pre;
+ int HP_mapif_itembound_ack_post;
+ int HP_mapif_parse_ItemBoundRetrieve_sub_pre;
+ int HP_mapif_parse_ItemBoundRetrieve_sub_post;
+ int HP_mapif_parse_ItemBoundRetrieve_pre;
+ int HP_mapif_parse_ItemBoundRetrieve_post;
+ int HP_mapif_parse_accinfo_pre;
+ int HP_mapif_parse_accinfo_post;
+ int HP_mapif_parse_accinfo2_pre;
+ int HP_mapif_parse_accinfo2_post;
+ int HP_mapif_broadcast_pre;
+ int HP_mapif_broadcast_post;
+ int HP_mapif_wis_message_pre;
+ int HP_mapif_wis_message_post;
+ int HP_mapif_wis_response_pre;
+ int HP_mapif_wis_response_post;
+ int HP_mapif_wis_end_pre;
+ int HP_mapif_wis_end_post;
+ int HP_mapif_account_reg_reply_pre;
+ int HP_mapif_account_reg_reply_post;
+ int HP_mapif_disconnectplayer_pre;
+ int HP_mapif_disconnectplayer_post;
+ int HP_mapif_parse_broadcast_pre;
+ int HP_mapif_parse_broadcast_post;
+ int HP_mapif_parse_WisRequest_pre;
+ int HP_mapif_parse_WisRequest_post;
+ int HP_mapif_parse_WisReply_pre;
+ int HP_mapif_parse_WisReply_post;
+ int HP_mapif_parse_WisToGM_pre;
+ int HP_mapif_parse_WisToGM_post;
+ int HP_mapif_parse_Registry_pre;
+ int HP_mapif_parse_Registry_post;
+ int HP_mapif_parse_RegistryRequest_pre;
+ int HP_mapif_parse_RegistryRequest_post;
+ int HP_mapif_namechange_ack_pre;
+ int HP_mapif_namechange_ack_post;
+ int HP_mapif_parse_NameChangeRequest_pre;
+ int HP_mapif_parse_NameChangeRequest_post;
+ int HP_pincode_handle_pre;
+ int HP_pincode_handle_post;
+ int HP_pincode_decrypt_pre;
+ int HP_pincode_decrypt_post;
+ int HP_pincode_error_pre;
+ int HP_pincode_error_post;
+ int HP_pincode_update_pre;
+ int HP_pincode_update_post;
+ int HP_pincode_sendstate_pre;
+ int HP_pincode_sendstate_post;
+ int HP_pincode_setnew_pre;
+ int HP_pincode_setnew_post;
+ int HP_pincode_change_pre;
+ int HP_pincode_change_post;
+ int HP_pincode_compare_pre;
+ int HP_pincode_compare_post;
+ int HP_pincode_check_pre;
+ int HP_pincode_check_post;
+ int HP_pincode_config_read_pre;
+ int HP_pincode_config_read_post;
+} count;
+
+struct {
+ struct char_interface chr;
+ struct geoip_interface geoip;
+ struct inter_auction_interface inter_auction;
+ struct inter_elemental_interface inter_elemental;
+ struct inter_guild_interface inter_guild;
+ struct inter_homunculus_interface inter_homunculus;
+ struct inter_interface inter;
+ struct inter_mail_interface inter_mail;
+ struct inter_mercenary_interface inter_mercenary;
+ struct inter_party_interface inter_party;
+ struct inter_pet_interface inter_pet;
+ struct inter_quest_interface inter_quest;
+ struct inter_storage_interface inter_storage;
+ struct loginif_interface loginif;
+ struct mapif_interface mapif;
+ struct pincode_interface pincode;
+} source;
diff --git a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc
new file mode 100644
index 000000000..aa279dbb4
--- /dev/null
+++ b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc
@@ -0,0 +1,472 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+//
+// NOTE: This file was auto-generated and should never be manually edited,
+// as it will get overwritten.
+
+struct HookingPointData HookingPoints[] = {
+/* chr */
+ { HP_POP(chr->waiting_disconnect, HP_chr_waiting_disconnect) },
+ { HP_POP(chr->delete_char_sql, HP_chr_delete_char_sql) },
+ { HP_POP(chr->create_online_char_data, HP_chr_create_online_char_data) },
+ { HP_POP(chr->set_account_online, HP_chr_set_account_online) },
+ { HP_POP(chr->set_account_offline, HP_chr_set_account_offline) },
+ { HP_POP(chr->set_char_charselect, HP_chr_set_char_charselect) },
+ { HP_POP(chr->set_char_online, HP_chr_set_char_online) },
+ { HP_POP(chr->set_char_offline, HP_chr_set_char_offline) },
+ { HP_POP(chr->db_setoffline, HP_chr_db_setoffline) },
+ { HP_POP(chr->db_kickoffline, HP_chr_db_kickoffline) },
+ { HP_POP(chr->set_login_all_offline, HP_chr_set_login_all_offline) },
+ { HP_POP(chr->set_all_offline, HP_chr_set_all_offline) },
+ { HP_POP(chr->set_all_offline_sql, HP_chr_set_all_offline_sql) },
+ { HP_POP(chr->create_charstatus, HP_chr_create_charstatus) },
+ { HP_POP(chr->mmo_char_tosql, HP_chr_mmo_char_tosql) },
+ { HP_POP(chr->memitemdata_to_sql, HP_chr_memitemdata_to_sql) },
+ { HP_POP(chr->inventory_to_sql, HP_chr_inventory_to_sql) },
+ { HP_POP(chr->mmo_chars_fromsql, HP_chr_mmo_chars_fromsql) },
+ { HP_POP(chr->mmo_char_fromsql, HP_chr_mmo_char_fromsql) },
+ { HP_POP(chr->mmo_char_sql_init, HP_chr_mmo_char_sql_init) },
+ { HP_POP(chr->char_slotchange, HP_chr_char_slotchange) },
+ { HP_POP(chr->rename_char_sql, HP_chr_rename_char_sql) },
+ { HP_POP(chr->check_char_name, HP_chr_check_char_name) },
+ { HP_POP(chr->make_new_char_sql, HP_chr_make_new_char_sql) },
+ { HP_POP(chr->divorce_char_sql, HP_chr_divorce_char_sql) },
+ { HP_POP(chr->count_users, HP_chr_count_users) },
+ { HP_POP(chr->mmo_char_tobuf, HP_chr_mmo_char_tobuf) },
+ { HP_POP(chr->mmo_char_send099d, HP_chr_mmo_char_send099d) },
+ { HP_POP(chr->mmo_char_send_ban_list, HP_chr_mmo_char_send_ban_list) },
+ { HP_POP(chr->mmo_char_send_slots_info, HP_chr_mmo_char_send_slots_info) },
+ { HP_POP(chr->mmo_char_send_characters, HP_chr_mmo_char_send_characters) },
+ { HP_POP(chr->char_married, HP_chr_char_married) },
+ { HP_POP(chr->char_child, HP_chr_char_child) },
+ { HP_POP(chr->char_family, HP_chr_char_family) },
+ { HP_POP(chr->disconnect_player, HP_chr_disconnect_player) },
+ { HP_POP(chr->authfail_fd, HP_chr_authfail_fd) },
+ { HP_POP(chr->request_account_data, HP_chr_request_account_data) },
+ { HP_POP(chr->auth_ok, HP_chr_auth_ok) },
+ { HP_POP(chr->ping_login_server, HP_chr_ping_login_server) },
+ { HP_POP(chr->parse_fromlogin_connection_state, HP_chr_parse_fromlogin_connection_state) },
+ { HP_POP(chr->auth_error, HP_chr_auth_error) },
+ { HP_POP(chr->parse_fromlogin_auth_state, HP_chr_parse_fromlogin_auth_state) },
+ { HP_POP(chr->parse_fromlogin_account_data, HP_chr_parse_fromlogin_account_data) },
+ { HP_POP(chr->parse_fromlogin_login_pong, HP_chr_parse_fromlogin_login_pong) },
+ { HP_POP(chr->changesex, HP_chr_changesex) },
+ { HP_POP(chr->parse_fromlogin_changesex_reply, HP_chr_parse_fromlogin_changesex_reply) },
+ { HP_POP(chr->parse_fromlogin_account_reg2, HP_chr_parse_fromlogin_account_reg2) },
+ { HP_POP(chr->parse_fromlogin_ban, HP_chr_parse_fromlogin_ban) },
+ { HP_POP(chr->parse_fromlogin_kick, HP_chr_parse_fromlogin_kick) },
+ { HP_POP(chr->update_ip, HP_chr_update_ip) },
+ { HP_POP(chr->parse_fromlogin_update_ip, HP_chr_parse_fromlogin_update_ip) },
+ { HP_POP(chr->parse_fromlogin_accinfo2_failed, HP_chr_parse_fromlogin_accinfo2_failed) },
+ { HP_POP(chr->parse_fromlogin_accinfo2_ok, HP_chr_parse_fromlogin_accinfo2_ok) },
+ { HP_POP(chr->parse_fromlogin, HP_chr_parse_fromlogin) },
+ { HP_POP(chr->request_accreg2, HP_chr_request_accreg2) },
+ { HP_POP(chr->global_accreg_to_login_start, HP_chr_global_accreg_to_login_start) },
+ { HP_POP(chr->global_accreg_to_login_send, HP_chr_global_accreg_to_login_send) },
+ { HP_POP(chr->global_accreg_to_login_add, HP_chr_global_accreg_to_login_add) },
+ { HP_POP(chr->read_fame_list, HP_chr_read_fame_list) },
+ { HP_POP(chr->send_fame_list, HP_chr_send_fame_list) },
+ { HP_POP(chr->update_fame_list, HP_chr_update_fame_list) },
+ { HP_POP(chr->loadName, HP_chr_loadName) },
+ { HP_POP(chr->parse_frommap_datasync, HP_chr_parse_frommap_datasync) },
+ { HP_POP(chr->parse_frommap_skillid2idx, HP_chr_parse_frommap_skillid2idx) },
+ { HP_POP(chr->map_received_ok, HP_chr_map_received_ok) },
+ { HP_POP(chr->send_maps, HP_chr_send_maps) },
+ { HP_POP(chr->parse_frommap_map_names, HP_chr_parse_frommap_map_names) },
+ { HP_POP(chr->send_scdata, HP_chr_send_scdata) },
+ { HP_POP(chr->parse_frommap_request_scdata, HP_chr_parse_frommap_request_scdata) },
+ { HP_POP(chr->parse_frommap_set_users_count, HP_chr_parse_frommap_set_users_count) },
+ { HP_POP(chr->parse_frommap_set_users, HP_chr_parse_frommap_set_users) },
+ { HP_POP(chr->save_character_ack, HP_chr_save_character_ack) },
+ { HP_POP(chr->parse_frommap_save_character, HP_chr_parse_frommap_save_character) },
+ { HP_POP(chr->select_ack, HP_chr_select_ack) },
+ { HP_POP(chr->parse_frommap_char_select_req, HP_chr_parse_frommap_char_select_req) },
+ { HP_POP(chr->change_map_server_ack, HP_chr_change_map_server_ack) },
+ { HP_POP(chr->parse_frommap_change_map_server, HP_chr_parse_frommap_change_map_server) },
+ { HP_POP(chr->parse_frommap_remove_friend, HP_chr_parse_frommap_remove_friend) },
+ { HP_POP(chr->char_name_ack, HP_chr_char_name_ack) },
+ { HP_POP(chr->parse_frommap_char_name_request, HP_chr_parse_frommap_char_name_request) },
+ { HP_POP(chr->parse_frommap_change_email, HP_chr_parse_frommap_change_email) },
+ { HP_POP(chr->ban, HP_chr_ban) },
+ { HP_POP(chr->unban, HP_chr_unban) },
+ { HP_POP(chr->ask_name_ack, HP_chr_ask_name_ack) },
+ { HP_POP(chr->parse_frommap_change_account, HP_chr_parse_frommap_change_account) },
+ { HP_POP(chr->parse_frommap_fame_list, HP_chr_parse_frommap_fame_list) },
+ { HP_POP(chr->parse_frommap_divorce_char, HP_chr_parse_frommap_divorce_char) },
+ { HP_POP(chr->parse_frommap_ragsrvinfo, HP_chr_parse_frommap_ragsrvinfo) },
+ { HP_POP(chr->parse_frommap_set_char_offline, HP_chr_parse_frommap_set_char_offline) },
+ { HP_POP(chr->parse_frommap_set_all_offline, HP_chr_parse_frommap_set_all_offline) },
+ { HP_POP(chr->parse_frommap_set_char_online, HP_chr_parse_frommap_set_char_online) },
+ { HP_POP(chr->parse_frommap_build_fame_list, HP_chr_parse_frommap_build_fame_list) },
+ { HP_POP(chr->parse_frommap_save_status_change_data, HP_chr_parse_frommap_save_status_change_data) },
+ { HP_POP(chr->send_pong, HP_chr_send_pong) },
+ { HP_POP(chr->parse_frommap_ping, HP_chr_parse_frommap_ping) },
+ { HP_POP(chr->map_auth_ok, HP_chr_map_auth_ok) },
+ { HP_POP(chr->map_auth_failed, HP_chr_map_auth_failed) },
+ { HP_POP(chr->parse_frommap_auth_request, HP_chr_parse_frommap_auth_request) },
+ { HP_POP(chr->parse_frommap_update_ip, HP_chr_parse_frommap_update_ip) },
+ { HP_POP(chr->parse_frommap_request_stats_report, HP_chr_parse_frommap_request_stats_report) },
+ { HP_POP(chr->parse_frommap_scdata_update, HP_chr_parse_frommap_scdata_update) },
+ { HP_POP(chr->parse_frommap_scdata_delete, HP_chr_parse_frommap_scdata_delete) },
+ { HP_POP(chr->parse_frommap, HP_chr_parse_frommap) },
+ { HP_POP(chr->search_mapserver, HP_chr_search_mapserver) },
+ { HP_POP(chr->mapif_init, HP_chr_mapif_init) },
+ { HP_POP(chr->lan_subnetcheck, HP_chr_lan_subnetcheck) },
+ { HP_POP(chr->delete2_ack, HP_chr_delete2_ack) },
+ { HP_POP(chr->delete2_accept_actual_ack, HP_chr_delete2_accept_actual_ack) },
+ { HP_POP(chr->delete2_accept_ack, HP_chr_delete2_accept_ack) },
+ { HP_POP(chr->delete2_cancel_ack, HP_chr_delete2_cancel_ack) },
+ { HP_POP(chr->delete2_req, HP_chr_delete2_req) },
+ { HP_POP(chr->delete2_accept, HP_chr_delete2_accept) },
+ { HP_POP(chr->delete2_cancel, HP_chr_delete2_cancel) },
+ { HP_POP(chr->send_account_id, HP_chr_send_account_id) },
+ { HP_POP(chr->parse_char_connect, HP_chr_parse_char_connect) },
+ { HP_POP(chr->send_map_info, HP_chr_send_map_info) },
+ { HP_POP(chr->send_wait_char_server, HP_chr_send_wait_char_server) },
+ { HP_POP(chr->search_default_maps_mapserver, HP_chr_search_default_maps_mapserver) },
+ { HP_POP(chr->parse_char_select, HP_chr_parse_char_select) },
+ { HP_POP(chr->creation_failed, HP_chr_creation_failed) },
+ { HP_POP(chr->creation_ok, HP_chr_creation_ok) },
+ { HP_POP(chr->parse_char_create_new_char, HP_chr_parse_char_create_new_char) },
+ { HP_POP(chr->delete_char_failed, HP_chr_delete_char_failed) },
+ { HP_POP(chr->delete_char_ok, HP_chr_delete_char_ok) },
+ { HP_POP(chr->parse_char_delete_char, HP_chr_parse_char_delete_char) },
+ { HP_POP(chr->parse_char_ping, HP_chr_parse_char_ping) },
+ { HP_POP(chr->allow_rename, HP_chr_allow_rename) },
+ { HP_POP(chr->parse_char_rename_char, HP_chr_parse_char_rename_char) },
+ { HP_POP(chr->parse_char_rename_char2, HP_chr_parse_char_rename_char2) },
+ { HP_POP(chr->rename_char_ack, HP_chr_rename_char_ack) },
+ { HP_POP(chr->parse_char_rename_char_confirm, HP_chr_parse_char_rename_char_confirm) },
+ { HP_POP(chr->captcha_notsupported, HP_chr_captcha_notsupported) },
+ { HP_POP(chr->parse_char_request_captcha, HP_chr_parse_char_request_captcha) },
+ { HP_POP(chr->parse_char_check_captcha, HP_chr_parse_char_check_captcha) },
+ { HP_POP(chr->parse_char_delete2_req, HP_chr_parse_char_delete2_req) },
+ { HP_POP(chr->parse_char_delete2_accept, HP_chr_parse_char_delete2_accept) },
+ { HP_POP(chr->parse_char_delete2_cancel, HP_chr_parse_char_delete2_cancel) },
+ { HP_POP(chr->login_map_server_ack, HP_chr_login_map_server_ack) },
+ { HP_POP(chr->parse_char_login_map_server, HP_chr_parse_char_login_map_server) },
+ { HP_POP(chr->parse_char_pincode_check, HP_chr_parse_char_pincode_check) },
+ { HP_POP(chr->parse_char_pincode_window, HP_chr_parse_char_pincode_window) },
+ { HP_POP(chr->parse_char_pincode_change, HP_chr_parse_char_pincode_change) },
+ { HP_POP(chr->parse_char_pincode_first_pin, HP_chr_parse_char_pincode_first_pin) },
+ { HP_POP(chr->parse_char_request_chars, HP_chr_parse_char_request_chars) },
+ { HP_POP(chr->change_character_slot_ack, HP_chr_change_character_slot_ack) },
+ { HP_POP(chr->parse_char_move_character, HP_chr_parse_char_move_character) },
+ { HP_POP(chr->parse_char_unknown_packet, HP_chr_parse_char_unknown_packet) },
+ { HP_POP(chr->parse_char, HP_chr_parse_char) },
+ { HP_POP(chr->broadcast_user_count, HP_chr_broadcast_user_count) },
+ { HP_POP(chr->send_accounts_tologin_sub, HP_chr_send_accounts_tologin_sub) },
+ { HP_POP(chr->send_accounts_tologin, HP_chr_send_accounts_tologin) },
+ { HP_POP(chr->check_connect_login_server, HP_chr_check_connect_login_server) },
+ { HP_POP(chr->online_data_cleanup_sub, HP_chr_online_data_cleanup_sub) },
+ { HP_POP(chr->online_data_cleanup, HP_chr_online_data_cleanup) },
+ { HP_POP(chr->lan_config_read, HP_chr_lan_config_read) },
+ { HP_POP(chr->sql_config_read, HP_chr_sql_config_read) },
+ { HP_POP(chr->config_dispatch, HP_chr_config_dispatch) },
+ { HP_POP(chr->config_read, HP_chr_config_read) },
+/* geoip */
+ { HP_POP(geoip->getcountry, HP_geoip_getcountry) },
+ { HP_POP(geoip->final, HP_geoip_final) },
+ { HP_POP(geoip->init, HP_geoip_init) },
+/* inter_auction */
+ { HP_POP(inter_auction->count, HP_inter_auction_count) },
+ { HP_POP(inter_auction->save, HP_inter_auction_save) },
+ { HP_POP(inter_auction->create, HP_inter_auction_create) },
+ { HP_POP(inter_auction->end_timer, HP_inter_auction_end_timer) },
+ { HP_POP(inter_auction->delete_, HP_inter_auction_delete_) },
+ { HP_POP(inter_auction->fromsql, HP_inter_auction_fromsql) },
+ { 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_elemental */
+ { HP_POP(inter_elemental->sql_init, HP_inter_elemental_sql_init) },
+ { HP_POP(inter_elemental->sql_final, HP_inter_elemental_sql_final) },
+ { HP_POP(inter_elemental->parse_frommap, HP_inter_elemental_parse_frommap) },
+/* inter_guild */
+ { HP_POP(inter_guild->save_timer, HP_inter_guild_save_timer) },
+ { HP_POP(inter_guild->removemember_tosql, HP_inter_guild_removemember_tosql) },
+ { HP_POP(inter_guild->tosql, HP_inter_guild_tosql) },
+ { HP_POP(inter_guild->fromsql, HP_inter_guild_fromsql) },
+ { HP_POP(inter_guild->castle_tosql, HP_inter_guild_castle_tosql) },
+ { HP_POP(inter_guild->castle_fromsql, HP_inter_guild_castle_fromsql) },
+ { HP_POP(inter_guild->exp_parse_row, HP_inter_guild_exp_parse_row) },
+ { HP_POP(inter_guild->CharOnline, HP_inter_guild_CharOnline) },
+ { HP_POP(inter_guild->CharOffline, HP_inter_guild_CharOffline) },
+ { HP_POP(inter_guild->sql_init, HP_inter_guild_sql_init) },
+ { HP_POP(inter_guild->db_final, HP_inter_guild_db_final) },
+ { HP_POP(inter_guild->sql_final, HP_inter_guild_sql_final) },
+ { HP_POP(inter_guild->search_guildname, HP_inter_guild_search_guildname) },
+ { HP_POP(inter_guild->check_empty, HP_inter_guild_check_empty) },
+ { HP_POP(inter_guild->nextexp, HP_inter_guild_nextexp) },
+ { HP_POP(inter_guild->checkskill, HP_inter_guild_checkskill) },
+ { HP_POP(inter_guild->calcinfo, HP_inter_guild_calcinfo) },
+ { HP_POP(inter_guild->sex_changed, HP_inter_guild_sex_changed) },
+ { HP_POP(inter_guild->charname_changed, HP_inter_guild_charname_changed) },
+ { HP_POP(inter_guild->parse_frommap, HP_inter_guild_parse_frommap) },
+ { HP_POP(inter_guild->leave, HP_inter_guild_leave) },
+ { HP_POP(inter_guild->broken, HP_inter_guild_broken) },
+/* inter_homunculus */
+ { HP_POP(inter_homunculus->sql_init, HP_inter_homunculus_sql_init) },
+ { HP_POP(inter_homunculus->sql_final, HP_inter_homunculus_sql_final) },
+ { HP_POP(inter_homunculus->parse_frommap, HP_inter_homunculus_parse_frommap) },
+/* inter */
+ { HP_POP(inter->msg_txt, HP_inter_msg_txt) },
+ { HP_POP(inter->msg_config_read, HP_inter_msg_config_read) },
+ { HP_POP(inter->do_final_msg, HP_inter_do_final_msg) },
+ { HP_POP(inter->job_name, HP_inter_job_name) },
+ { HP_POP(inter->vmsg_to_fd, HP_inter_vmsg_to_fd) },
+ { HP_POP(inter->savereg, HP_inter_savereg) },
+ { HP_POP(inter->accreg_fromsql, HP_inter_accreg_fromsql) },
+ { HP_POP(inter->config_read, HP_inter_config_read) },
+ { HP_POP(inter->vlog, HP_inter_vlog) },
+ { HP_POP(inter->init_sql, HP_inter_init_sql) },
+ { HP_POP(inter->mapif_init, HP_inter_mapif_init) },
+ { HP_POP(inter->check_ttl_wisdata_sub, HP_inter_check_ttl_wisdata_sub) },
+ { HP_POP(inter->check_ttl_wisdata, HP_inter_check_ttl_wisdata) },
+ { HP_POP(inter->check_length, HP_inter_check_length) },
+ { HP_POP(inter->parse_frommap, HP_inter_parse_frommap) },
+ { HP_POP(inter->final, HP_inter_final) },
+/* inter_mail */
+ { HP_POP(inter_mail->sql_init, HP_inter_mail_sql_init) },
+ { HP_POP(inter_mail->sql_final, HP_inter_mail_sql_final) },
+ { HP_POP(inter_mail->parse_frommap, HP_inter_mail_parse_frommap) },
+ { HP_POP(inter_mail->fromsql, HP_inter_mail_fromsql) },
+ { HP_POP(inter_mail->savemessage, HP_inter_mail_savemessage) },
+ { HP_POP(inter_mail->loadmessage, HP_inter_mail_loadmessage) },
+ { HP_POP(inter_mail->DeleteAttach, HP_inter_mail_DeleteAttach) },
+ { HP_POP(inter_mail->sendmail, HP_inter_mail_sendmail) },
+/* inter_mercenary */
+ { HP_POP(inter_mercenary->owner_fromsql, HP_inter_mercenary_owner_fromsql) },
+ { HP_POP(inter_mercenary->owner_tosql, HP_inter_mercenary_owner_tosql) },
+ { HP_POP(inter_mercenary->owner_delete, HP_inter_mercenary_owner_delete) },
+ { HP_POP(inter_mercenary->sql_init, HP_inter_mercenary_sql_init) },
+ { HP_POP(inter_mercenary->sql_final, HP_inter_mercenary_sql_final) },
+ { HP_POP(inter_mercenary->parse_frommap, HP_inter_mercenary_parse_frommap) },
+/* inter_party */
+ { HP_POP(inter_party->check_lv, HP_inter_party_check_lv) },
+ { HP_POP(inter_party->calc_state, HP_inter_party_calc_state) },
+ { HP_POP(inter_party->tosql, HP_inter_party_tosql) },
+ { HP_POP(inter_party->fromsql, HP_inter_party_fromsql) },
+ { HP_POP(inter_party->sql_init, HP_inter_party_sql_init) },
+ { HP_POP(inter_party->sql_final, HP_inter_party_sql_final) },
+ { HP_POP(inter_party->search_partyname, HP_inter_party_search_partyname) },
+ { HP_POP(inter_party->check_exp_share, HP_inter_party_check_exp_share) },
+ { HP_POP(inter_party->check_empty, HP_inter_party_check_empty) },
+ { HP_POP(inter_party->parse_frommap, HP_inter_party_parse_frommap) },
+ { HP_POP(inter_party->leave, HP_inter_party_leave) },
+ { HP_POP(inter_party->CharOnline, HP_inter_party_CharOnline) },
+ { HP_POP(inter_party->CharOffline, HP_inter_party_CharOffline) },
+/* inter_pet */
+ { HP_POP(inter_pet->tosql, HP_inter_pet_tosql) },
+ { HP_POP(inter_pet->fromsql, HP_inter_pet_fromsql) },
+ { HP_POP(inter_pet->sql_init, HP_inter_pet_sql_init) },
+ { HP_POP(inter_pet->sql_final, HP_inter_pet_sql_final) },
+ { HP_POP(inter_pet->delete_, HP_inter_pet_delete_) },
+ { HP_POP(inter_pet->parse_frommap, HP_inter_pet_parse_frommap) },
+/* inter_quest */
+ { HP_POP(inter_quest->parse_frommap, HP_inter_quest_parse_frommap) },
+/* inter_storage */
+ { HP_POP(inter_storage->tosql, HP_inter_storage_tosql) },
+ { HP_POP(inter_storage->fromsql, HP_inter_storage_fromsql) },
+ { HP_POP(inter_storage->guild_storage_tosql, HP_inter_storage_guild_storage_tosql) },
+ { HP_POP(inter_storage->guild_storage_fromsql, HP_inter_storage_guild_storage_fromsql) },
+ { HP_POP(inter_storage->sql_init, HP_inter_storage_sql_init) },
+ { HP_POP(inter_storage->sql_final, HP_inter_storage_sql_final) },
+ { HP_POP(inter_storage->delete_, HP_inter_storage_delete_) },
+ { HP_POP(inter_storage->guild_storage_delete, HP_inter_storage_guild_storage_delete) },
+ { HP_POP(inter_storage->parse_frommap, HP_inter_storage_parse_frommap) },
+/* loginif */
+ { HP_POP(loginif->init, HP_loginif_init) },
+ { HP_POP(loginif->final, HP_loginif_final) },
+ { HP_POP(loginif->reset, HP_loginif_reset) },
+ { HP_POP(loginif->check_shutdown, HP_loginif_check_shutdown) },
+ { HP_POP(loginif->on_disconnect, HP_loginif_on_disconnect) },
+ { HP_POP(loginif->on_ready, HP_loginif_on_ready) },
+ { HP_POP(loginif->block_account, HP_loginif_block_account) },
+ { HP_POP(loginif->ban_account, HP_loginif_ban_account) },
+ { HP_POP(loginif->unban_account, HP_loginif_unban_account) },
+ { HP_POP(loginif->changesex, HP_loginif_changesex) },
+ { HP_POP(loginif->auth, HP_loginif_auth) },
+ { HP_POP(loginif->send_users_count, HP_loginif_send_users_count) },
+ { HP_POP(loginif->connect_to_server, HP_loginif_connect_to_server) },
+/* mapif */
+ { HP_POP(mapif->ban, HP_mapif_ban) },
+ { HP_POP(mapif->server_init, HP_mapif_server_init) },
+ { HP_POP(mapif->server_destroy, HP_mapif_server_destroy) },
+ { HP_POP(mapif->server_reset, HP_mapif_server_reset) },
+ { HP_POP(mapif->on_disconnect, HP_mapif_on_disconnect) },
+ { HP_POP(mapif->on_parse_accinfo, HP_mapif_on_parse_accinfo) },
+ { HP_POP(mapif->char_ban, HP_mapif_char_ban) },
+ { HP_POP(mapif->sendall, HP_mapif_sendall) },
+ { HP_POP(mapif->sendallwos, HP_mapif_sendallwos) },
+ { HP_POP(mapif->send, HP_mapif_send) },
+ { HP_POP(mapif->send_users_count, HP_mapif_send_users_count) },
+ { HP_POP(mapif->auction_message, HP_mapif_auction_message) },
+ { HP_POP(mapif->auction_sendlist, HP_mapif_auction_sendlist) },
+ { HP_POP(mapif->parse_auction_requestlist, HP_mapif_parse_auction_requestlist) },
+ { HP_POP(mapif->auction_register, HP_mapif_auction_register) },
+ { HP_POP(mapif->parse_auction_register, HP_mapif_parse_auction_register) },
+ { HP_POP(mapif->auction_cancel, HP_mapif_auction_cancel) },
+ { HP_POP(mapif->parse_auction_cancel, HP_mapif_parse_auction_cancel) },
+ { HP_POP(mapif->auction_close, HP_mapif_auction_close) },
+ { HP_POP(mapif->parse_auction_close, HP_mapif_parse_auction_close) },
+ { HP_POP(mapif->auction_bid, HP_mapif_auction_bid) },
+ { HP_POP(mapif->parse_auction_bid, HP_mapif_parse_auction_bid) },
+ { HP_POP(mapif->elemental_save, HP_mapif_elemental_save) },
+ { HP_POP(mapif->elemental_load, HP_mapif_elemental_load) },
+ { HP_POP(mapif->elemental_delete, HP_mapif_elemental_delete) },
+ { HP_POP(mapif->elemental_send, HP_mapif_elemental_send) },
+ { HP_POP(mapif->parse_elemental_create, HP_mapif_parse_elemental_create) },
+ { HP_POP(mapif->parse_elemental_load, HP_mapif_parse_elemental_load) },
+ { HP_POP(mapif->elemental_deleted, HP_mapif_elemental_deleted) },
+ { HP_POP(mapif->parse_elemental_delete, HP_mapif_parse_elemental_delete) },
+ { HP_POP(mapif->elemental_saved, HP_mapif_elemental_saved) },
+ { HP_POP(mapif->parse_elemental_save, HP_mapif_parse_elemental_save) },
+ { HP_POP(mapif->guild_created, HP_mapif_guild_created) },
+ { HP_POP(mapif->guild_noinfo, HP_mapif_guild_noinfo) },
+ { HP_POP(mapif->guild_info, HP_mapif_guild_info) },
+ { HP_POP(mapif->guild_memberadded, HP_mapif_guild_memberadded) },
+ { HP_POP(mapif->guild_withdraw, HP_mapif_guild_withdraw) },
+ { HP_POP(mapif->guild_memberinfoshort, HP_mapif_guild_memberinfoshort) },
+ { HP_POP(mapif->guild_broken, HP_mapif_guild_broken) },
+ { HP_POP(mapif->guild_message, HP_mapif_guild_message) },
+ { HP_POP(mapif->guild_basicinfochanged, HP_mapif_guild_basicinfochanged) },
+ { HP_POP(mapif->guild_memberinfochanged, HP_mapif_guild_memberinfochanged) },
+ { HP_POP(mapif->guild_skillupack, HP_mapif_guild_skillupack) },
+ { HP_POP(mapif->guild_alliance, HP_mapif_guild_alliance) },
+ { HP_POP(mapif->guild_position, HP_mapif_guild_position) },
+ { HP_POP(mapif->guild_notice, HP_mapif_guild_notice) },
+ { HP_POP(mapif->guild_emblem, HP_mapif_guild_emblem) },
+ { HP_POP(mapif->guild_master_changed, HP_mapif_guild_master_changed) },
+ { HP_POP(mapif->guild_castle_dataload, HP_mapif_guild_castle_dataload) },
+ { HP_POP(mapif->parse_CreateGuild, HP_mapif_parse_CreateGuild) },
+ { HP_POP(mapif->parse_GuildInfo, HP_mapif_parse_GuildInfo) },
+ { HP_POP(mapif->parse_GuildAddMember, HP_mapif_parse_GuildAddMember) },
+ { HP_POP(mapif->parse_GuildLeave, HP_mapif_parse_GuildLeave) },
+ { HP_POP(mapif->parse_GuildChangeMemberInfoShort, HP_mapif_parse_GuildChangeMemberInfoShort) },
+ { HP_POP(mapif->parse_BreakGuild, HP_mapif_parse_BreakGuild) },
+ { HP_POP(mapif->parse_GuildMessage, HP_mapif_parse_GuildMessage) },
+ { HP_POP(mapif->parse_GuildBasicInfoChange, HP_mapif_parse_GuildBasicInfoChange) },
+ { HP_POP(mapif->parse_GuildMemberInfoChange, HP_mapif_parse_GuildMemberInfoChange) },
+ { HP_POP(mapif->parse_GuildPosition, HP_mapif_parse_GuildPosition) },
+ { HP_POP(mapif->parse_GuildSkillUp, HP_mapif_parse_GuildSkillUp) },
+ { HP_POP(mapif->parse_GuildDeleteAlliance, HP_mapif_parse_GuildDeleteAlliance) },
+ { HP_POP(mapif->parse_GuildAlliance, HP_mapif_parse_GuildAlliance) },
+ { HP_POP(mapif->parse_GuildNotice, HP_mapif_parse_GuildNotice) },
+ { HP_POP(mapif->parse_GuildEmblem, HP_mapif_parse_GuildEmblem) },
+ { HP_POP(mapif->parse_GuildCastleDataLoad, HP_mapif_parse_GuildCastleDataLoad) },
+ { HP_POP(mapif->parse_GuildCastleDataSave, HP_mapif_parse_GuildCastleDataSave) },
+ { HP_POP(mapif->parse_GuildMasterChange, HP_mapif_parse_GuildMasterChange) },
+ { HP_POP(mapif->homunculus_created, HP_mapif_homunculus_created) },
+ { HP_POP(mapif->homunculus_deleted, HP_mapif_homunculus_deleted) },
+ { HP_POP(mapif->homunculus_loaded, HP_mapif_homunculus_loaded) },
+ { HP_POP(mapif->homunculus_saved, HP_mapif_homunculus_saved) },
+ { HP_POP(mapif->homunculus_renamed, HP_mapif_homunculus_renamed) },
+ { HP_POP(mapif->homunculus_save, HP_mapif_homunculus_save) },
+ { HP_POP(mapif->homunculus_load, HP_mapif_homunculus_load) },
+ { HP_POP(mapif->homunculus_delete, HP_mapif_homunculus_delete) },
+ { HP_POP(mapif->homunculus_rename, HP_mapif_homunculus_rename) },
+ { HP_POP(mapif->parse_homunculus_create, HP_mapif_parse_homunculus_create) },
+ { HP_POP(mapif->parse_homunculus_delete, HP_mapif_parse_homunculus_delete) },
+ { HP_POP(mapif->parse_homunculus_load, HP_mapif_parse_homunculus_load) },
+ { HP_POP(mapif->parse_homunculus_save, HP_mapif_parse_homunculus_save) },
+ { HP_POP(mapif->parse_homunculus_rename, HP_mapif_parse_homunculus_rename) },
+ { HP_POP(mapif->mail_sendinbox, HP_mapif_mail_sendinbox) },
+ { HP_POP(mapif->parse_mail_requestinbox, HP_mapif_parse_mail_requestinbox) },
+ { HP_POP(mapif->parse_mail_read, HP_mapif_parse_mail_read) },
+ { HP_POP(mapif->mail_sendattach, HP_mapif_mail_sendattach) },
+ { HP_POP(mapif->mail_getattach, HP_mapif_mail_getattach) },
+ { HP_POP(mapif->parse_mail_getattach, HP_mapif_parse_mail_getattach) },
+ { HP_POP(mapif->mail_delete, HP_mapif_mail_delete) },
+ { HP_POP(mapif->parse_mail_delete, HP_mapif_parse_mail_delete) },
+ { HP_POP(mapif->mail_new, HP_mapif_mail_new) },
+ { HP_POP(mapif->mail_return, HP_mapif_mail_return) },
+ { HP_POP(mapif->parse_mail_return, HP_mapif_parse_mail_return) },
+ { HP_POP(mapif->mail_send, HP_mapif_mail_send) },
+ { HP_POP(mapif->parse_mail_send, HP_mapif_parse_mail_send) },
+ { HP_POP(mapif->mercenary_save, HP_mapif_mercenary_save) },
+ { HP_POP(mapif->mercenary_load, HP_mapif_mercenary_load) },
+ { HP_POP(mapif->mercenary_delete, HP_mapif_mercenary_delete) },
+ { HP_POP(mapif->mercenary_send, HP_mapif_mercenary_send) },
+ { HP_POP(mapif->parse_mercenary_create, HP_mapif_parse_mercenary_create) },
+ { HP_POP(mapif->parse_mercenary_load, HP_mapif_parse_mercenary_load) },
+ { HP_POP(mapif->mercenary_deleted, HP_mapif_mercenary_deleted) },
+ { HP_POP(mapif->parse_mercenary_delete, HP_mapif_parse_mercenary_delete) },
+ { HP_POP(mapif->mercenary_saved, HP_mapif_mercenary_saved) },
+ { HP_POP(mapif->parse_mercenary_save, HP_mapif_parse_mercenary_save) },
+ { HP_POP(mapif->party_created, HP_mapif_party_created) },
+ { HP_POP(mapif->party_noinfo, HP_mapif_party_noinfo) },
+ { HP_POP(mapif->party_info, HP_mapif_party_info) },
+ { HP_POP(mapif->party_memberadded, HP_mapif_party_memberadded) },
+ { HP_POP(mapif->party_optionchanged, HP_mapif_party_optionchanged) },
+ { HP_POP(mapif->party_withdraw, HP_mapif_party_withdraw) },
+ { HP_POP(mapif->party_membermoved, HP_mapif_party_membermoved) },
+ { HP_POP(mapif->party_broken, HP_mapif_party_broken) },
+ { HP_POP(mapif->party_message, HP_mapif_party_message) },
+ { HP_POP(mapif->parse_CreateParty, HP_mapif_parse_CreateParty) },
+ { HP_POP(mapif->parse_PartyInfo, HP_mapif_parse_PartyInfo) },
+ { HP_POP(mapif->parse_PartyAddMember, HP_mapif_parse_PartyAddMember) },
+ { HP_POP(mapif->parse_PartyChangeOption, HP_mapif_parse_PartyChangeOption) },
+ { HP_POP(mapif->parse_PartyLeave, HP_mapif_parse_PartyLeave) },
+ { HP_POP(mapif->parse_PartyChangeMap, HP_mapif_parse_PartyChangeMap) },
+ { HP_POP(mapif->parse_BreakParty, HP_mapif_parse_BreakParty) },
+ { HP_POP(mapif->parse_PartyMessage, HP_mapif_parse_PartyMessage) },
+ { HP_POP(mapif->parse_PartyLeaderChange, HP_mapif_parse_PartyLeaderChange) },
+ { HP_POP(mapif->pet_created, HP_mapif_pet_created) },
+ { HP_POP(mapif->pet_info, HP_mapif_pet_info) },
+ { HP_POP(mapif->pet_noinfo, HP_mapif_pet_noinfo) },
+ { HP_POP(mapif->save_pet_ack, HP_mapif_save_pet_ack) },
+ { HP_POP(mapif->delete_pet_ack, HP_mapif_delete_pet_ack) },
+ { HP_POP(mapif->create_pet, HP_mapif_create_pet) },
+ { HP_POP(mapif->load_pet, HP_mapif_load_pet) },
+ { HP_POP(mapif->save_pet, HP_mapif_save_pet) },
+ { HP_POP(mapif->delete_pet, HP_mapif_delete_pet) },
+ { HP_POP(mapif->parse_CreatePet, HP_mapif_parse_CreatePet) },
+ { HP_POP(mapif->parse_LoadPet, HP_mapif_parse_LoadPet) },
+ { HP_POP(mapif->parse_SavePet, HP_mapif_parse_SavePet) },
+ { HP_POP(mapif->parse_DeletePet, HP_mapif_parse_DeletePet) },
+ { HP_POP(mapif->quests_fromsql, HP_mapif_quests_fromsql) },
+ { HP_POP(mapif->quest_delete, HP_mapif_quest_delete) },
+ { HP_POP(mapif->quest_add, HP_mapif_quest_add) },
+ { HP_POP(mapif->quest_update, HP_mapif_quest_update) },
+ { HP_POP(mapif->quest_save_ack, HP_mapif_quest_save_ack) },
+ { HP_POP(mapif->parse_quest_save, HP_mapif_parse_quest_save) },
+ { HP_POP(mapif->send_quests, HP_mapif_send_quests) },
+ { HP_POP(mapif->parse_quest_load, HP_mapif_parse_quest_load) },
+ { HP_POP(mapif->load_guild_storage, HP_mapif_load_guild_storage) },
+ { HP_POP(mapif->save_guild_storage_ack, HP_mapif_save_guild_storage_ack) },
+ { HP_POP(mapif->parse_LoadGuildStorage, HP_mapif_parse_LoadGuildStorage) },
+ { HP_POP(mapif->parse_SaveGuildStorage, HP_mapif_parse_SaveGuildStorage) },
+ { HP_POP(mapif->itembound_ack, HP_mapif_itembound_ack) },
+ { HP_POP(mapif->parse_ItemBoundRetrieve_sub, HP_mapif_parse_ItemBoundRetrieve_sub) },
+ { HP_POP(mapif->parse_ItemBoundRetrieve, HP_mapif_parse_ItemBoundRetrieve) },
+ { HP_POP(mapif->parse_accinfo, HP_mapif_parse_accinfo) },
+ { HP_POP(mapif->parse_accinfo2, HP_mapif_parse_accinfo2) },
+ { HP_POP(mapif->broadcast, HP_mapif_broadcast) },
+ { HP_POP(mapif->wis_message, HP_mapif_wis_message) },
+ { HP_POP(mapif->wis_response, HP_mapif_wis_response) },
+ { HP_POP(mapif->wis_end, HP_mapif_wis_end) },
+ { HP_POP(mapif->account_reg_reply, HP_mapif_account_reg_reply) },
+ { HP_POP(mapif->disconnectplayer, HP_mapif_disconnectplayer) },
+ { HP_POP(mapif->parse_broadcast, HP_mapif_parse_broadcast) },
+ { HP_POP(mapif->parse_WisRequest, HP_mapif_parse_WisRequest) },
+ { HP_POP(mapif->parse_WisReply, HP_mapif_parse_WisReply) },
+ { HP_POP(mapif->parse_WisToGM, HP_mapif_parse_WisToGM) },
+ { HP_POP(mapif->parse_Registry, HP_mapif_parse_Registry) },
+ { 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) },
+/* pincode */
+ { HP_POP(pincode->handle, HP_pincode_handle) },
+ { HP_POP(pincode->decrypt, HP_pincode_decrypt) },
+ { HP_POP(pincode->error, HP_pincode_error) },
+ { HP_POP(pincode->update, HP_pincode_update) },
+ { HP_POP(pincode->sendstate, HP_pincode_sendstate) },
+ { HP_POP(pincode->setnew, HP_pincode_setnew) },
+ { HP_POP(pincode->change, HP_pincode_change) },
+ { HP_POP(pincode->compare, HP_pincode_compare) },
+ { HP_POP(pincode->check, HP_pincode_check) },
+ { HP_POP(pincode->config_read, HP_pincode_config_read) },
+};
+
+int HookingPointsLenMax = 42;
diff --git a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc
new file mode 100644
index 000000000..ffa2cd7e2
--- /dev/null
+++ b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc
@@ -0,0 +1,11904 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+//
+// NOTE: This file was auto-generated and should never be manually edited,
+// as it will get overwritten.
+
+/* chr */
+int HP_chr_waiting_disconnect(int tid, int64 tick, int id, intptr_t data) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_waiting_disconnect_pre ) {
+ int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_waiting_disconnect_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_waiting_disconnect_pre[hIndex].func;
+ retVal___ = preHookFunc(&tid, &tick, &id, &data);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.waiting_disconnect(tid, tick, id, data);
+ }
+ if( HPMHooks.count.HP_chr_waiting_disconnect_post ) {
+ int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_waiting_disconnect_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_waiting_disconnect_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_delete_char_sql(int char_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_delete_char_sql_pre ) {
+ int (*preHookFunc) (int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete_char_sql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_delete_char_sql_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.delete_char_sql(char_id);
+ }
+ if( HPMHooks.count.HP_chr_delete_char_sql_post ) {
+ int (*postHookFunc) (int retVal___, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete_char_sql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_delete_char_sql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id);
+ }
+ }
+ return retVal___;
+}
+DBData HP_chr_create_online_char_data(DBKey key, va_list args) {
+ int hIndex = 0;
+ DBData retVal___;
+ memset(&retVal___, '\0', sizeof(DBData));
+ if( HPMHooks.count.HP_chr_create_online_char_data_pre ) {
+ DBData (*preHookFunc) (DBKey *key, va_list args);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_create_online_char_data_pre; hIndex++ ) {
+ va_list args___copy; va_copy(args___copy, args);
+ preHookFunc = HPMHooks.list.HP_chr_create_online_char_data_pre[hIndex].func;
+ retVal___ = preHookFunc(&key, args___copy);
+ va_end(args___copy);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ va_list args___copy; va_copy(args___copy, args);
+ retVal___ = HPMHooks.source.chr.create_online_char_data(key, args___copy);
+ va_end(args___copy);
+ }
+ if( HPMHooks.count.HP_chr_create_online_char_data_post ) {
+ DBData (*postHookFunc) (DBData retVal___, DBKey *key, va_list args);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_create_online_char_data_post; hIndex++ ) {
+ va_list args___copy; va_copy(args___copy, args);
+ postHookFunc = HPMHooks.list.HP_chr_create_online_char_data_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &key, args___copy);
+ va_end(args___copy);
+ }
+ }
+ return retVal___;
+}
+void HP_chr_set_account_online(int account_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_set_account_online_pre ) {
+ void (*preHookFunc) (int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_account_online_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_set_account_online_pre[hIndex].func;
+ preHookFunc(&account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.set_account_online(account_id);
+ }
+ if( HPMHooks.count.HP_chr_set_account_online_post ) {
+ void (*postHookFunc) (int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_account_online_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_set_account_online_post[hIndex].func;
+ postHookFunc(&account_id);
+ }
+ }
+ return;
+}
+void HP_chr_set_account_offline(int account_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_set_account_offline_pre ) {
+ void (*preHookFunc) (int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_account_offline_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_set_account_offline_pre[hIndex].func;
+ preHookFunc(&account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.set_account_offline(account_id);
+ }
+ if( HPMHooks.count.HP_chr_set_account_offline_post ) {
+ void (*postHookFunc) (int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_account_offline_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_set_account_offline_post[hIndex].func;
+ postHookFunc(&account_id);
+ }
+ }
+ return;
+}
+void HP_chr_set_char_charselect(int account_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_set_char_charselect_pre ) {
+ void (*preHookFunc) (int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_char_charselect_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_set_char_charselect_pre[hIndex].func;
+ preHookFunc(&account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.set_char_charselect(account_id);
+ }
+ if( HPMHooks.count.HP_chr_set_char_charselect_post ) {
+ void (*postHookFunc) (int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_char_charselect_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_set_char_charselect_post[hIndex].func;
+ postHookFunc(&account_id);
+ }
+ }
+ return;
+}
+void HP_chr_set_char_online(int map_id, int char_id, int account_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_set_char_online_pre ) {
+ void (*preHookFunc) (int *map_id, int *char_id, int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_char_online_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_set_char_online_pre[hIndex].func;
+ preHookFunc(&map_id, &char_id, &account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.set_char_online(map_id, char_id, account_id);
+ }
+ if( HPMHooks.count.HP_chr_set_char_online_post ) {
+ void (*postHookFunc) (int *map_id, int *char_id, int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_char_online_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_set_char_online_post[hIndex].func;
+ postHookFunc(&map_id, &char_id, &account_id);
+ }
+ }
+ return;
+}
+void HP_chr_set_char_offline(int char_id, int account_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_set_char_offline_pre ) {
+ void (*preHookFunc) (int *char_id, int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_char_offline_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_set_char_offline_pre[hIndex].func;
+ preHookFunc(&char_id, &account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.set_char_offline(char_id, account_id);
+ }
+ if( HPMHooks.count.HP_chr_set_char_offline_post ) {
+ void (*postHookFunc) (int *char_id, int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_char_offline_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_set_char_offline_post[hIndex].func;
+ postHookFunc(&char_id, &account_id);
+ }
+ }
+ return;
+}
+int HP_chr_db_setoffline(DBKey key, DBData *data, va_list ap) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_db_setoffline_pre ) {
+ int (*preHookFunc) (DBKey *key, DBData *data, va_list ap);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_db_setoffline_pre; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ preHookFunc = HPMHooks.list.HP_chr_db_setoffline_pre[hIndex].func;
+ retVal___ = preHookFunc(&key, data, 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.chr.db_setoffline(key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ if( HPMHooks.count.HP_chr_db_setoffline_post ) {
+ int (*postHookFunc) (int retVal___, DBKey *key, DBData *data, va_list ap);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_db_setoffline_post; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ postHookFunc = HPMHooks.list.HP_chr_db_setoffline_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_db_kickoffline(DBKey key, DBData *data, va_list ap) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_db_kickoffline_pre ) {
+ int (*preHookFunc) (DBKey *key, DBData *data, va_list ap);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_db_kickoffline_pre; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ preHookFunc = HPMHooks.list.HP_chr_db_kickoffline_pre[hIndex].func;
+ retVal___ = preHookFunc(&key, data, 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.chr.db_kickoffline(key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ if( HPMHooks.count.HP_chr_db_kickoffline_post ) {
+ int (*postHookFunc) (int retVal___, DBKey *key, DBData *data, va_list ap);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_db_kickoffline_post; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ postHookFunc = HPMHooks.list.HP_chr_db_kickoffline_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ }
+ return retVal___;
+}
+void HP_chr_set_login_all_offline(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_set_login_all_offline_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_login_all_offline_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_set_login_all_offline_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.set_login_all_offline();
+ }
+ if( HPMHooks.count.HP_chr_set_login_all_offline_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_login_all_offline_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_set_login_all_offline_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_chr_set_all_offline(int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_set_all_offline_pre ) {
+ void (*preHookFunc) (int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_all_offline_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_set_all_offline_pre[hIndex].func;
+ preHookFunc(&id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.set_all_offline(id);
+ }
+ if( HPMHooks.count.HP_chr_set_all_offline_post ) {
+ void (*postHookFunc) (int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_all_offline_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_set_all_offline_post[hIndex].func;
+ postHookFunc(&id);
+ }
+ }
+ return;
+}
+void HP_chr_set_all_offline_sql(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_set_all_offline_sql_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_all_offline_sql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_set_all_offline_sql_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.set_all_offline_sql();
+ }
+ if( HPMHooks.count.HP_chr_set_all_offline_sql_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_set_all_offline_sql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_set_all_offline_sql_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+DBData HP_chr_create_charstatus(DBKey key, va_list args) {
+ int hIndex = 0;
+ DBData retVal___;
+ memset(&retVal___, '\0', sizeof(DBData));
+ if( HPMHooks.count.HP_chr_create_charstatus_pre ) {
+ DBData (*preHookFunc) (DBKey *key, va_list args);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_create_charstatus_pre; hIndex++ ) {
+ va_list args___copy; va_copy(args___copy, args);
+ preHookFunc = HPMHooks.list.HP_chr_create_charstatus_pre[hIndex].func;
+ retVal___ = preHookFunc(&key, args___copy);
+ va_end(args___copy);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ va_list args___copy; va_copy(args___copy, args);
+ retVal___ = HPMHooks.source.chr.create_charstatus(key, args___copy);
+ va_end(args___copy);
+ }
+ if( HPMHooks.count.HP_chr_create_charstatus_post ) {
+ DBData (*postHookFunc) (DBData retVal___, DBKey *key, va_list args);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_create_charstatus_post; hIndex++ ) {
+ va_list args___copy; va_copy(args___copy, args);
+ postHookFunc = HPMHooks.list.HP_chr_create_charstatus_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &key, args___copy);
+ va_end(args___copy);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_mmo_char_tosql(int char_id, struct mmo_charstatus *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_mmo_char_tosql_pre ) {
+ int (*preHookFunc) (int *char_id, struct mmo_charstatus *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_tosql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_mmo_char_tosql_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.mmo_char_tosql(char_id, p);
+ }
+ if( HPMHooks.count.HP_chr_mmo_char_tosql_post ) {
+ int (*postHookFunc) (int retVal___, int *char_id, struct mmo_charstatus *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_tosql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_mmo_char_tosql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, p);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_memitemdata_to_sql_pre ) {
+ int (*preHookFunc) (const struct item *items[], int *max, int *id, int *tableswitch);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_memitemdata_to_sql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_memitemdata_to_sql_pre[hIndex].func;
+ retVal___ = preHookFunc(&items, &max, &id, &tableswitch);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.memitemdata_to_sql(items, max, id, tableswitch);
+ }
+ if( HPMHooks.count.HP_chr_memitemdata_to_sql_post ) {
+ int (*postHookFunc) (int retVal___, const struct item *items[], int *max, int *id, int *tableswitch);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_memitemdata_to_sql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_memitemdata_to_sql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &items, &max, &id, &tableswitch);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_inventory_to_sql(const struct item items[], int max, int id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_inventory_to_sql_pre ) {
+ int (*preHookFunc) (const struct item *items[], int *max, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_inventory_to_sql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_inventory_to_sql_pre[hIndex].func;
+ retVal___ = preHookFunc(&items, &max, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.inventory_to_sql(items, max, id);
+ }
+ if( HPMHooks.count.HP_chr_inventory_to_sql_post ) {
+ int (*postHookFunc) (int retVal___, const struct item *items[], int *max, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_inventory_to_sql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_inventory_to_sql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &items, &max, &id);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_mmo_chars_fromsql(struct char_session_data *sd, uint8 *buf) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_mmo_chars_fromsql_pre ) {
+ int (*preHookFunc) (struct char_session_data *sd, uint8 *buf);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_chars_fromsql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_mmo_chars_fromsql_pre[hIndex].func;
+ retVal___ = preHookFunc(sd, buf);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.mmo_chars_fromsql(sd, buf);
+ }
+ if( HPMHooks.count.HP_chr_mmo_chars_fromsql_post ) {
+ int (*postHookFunc) (int retVal___, struct char_session_data *sd, uint8 *buf);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_chars_fromsql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_mmo_chars_fromsql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, sd, buf);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_mmo_char_fromsql(int char_id, struct mmo_charstatus *p, bool load_everything) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_mmo_char_fromsql_pre ) {
+ int (*preHookFunc) (int *char_id, struct mmo_charstatus *p, bool *load_everything);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_fromsql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_mmo_char_fromsql_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, p, &load_everything);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.mmo_char_fromsql(char_id, p, load_everything);
+ }
+ if( HPMHooks.count.HP_chr_mmo_char_fromsql_post ) {
+ int (*postHookFunc) (int retVal___, int *char_id, struct mmo_charstatus *p, bool *load_everything);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_fromsql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_mmo_char_fromsql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, p, &load_everything);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_mmo_char_sql_init(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_mmo_char_sql_init_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_sql_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_mmo_char_sql_init_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.mmo_char_sql_init();
+ }
+ if( HPMHooks.count.HP_chr_mmo_char_sql_init_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_sql_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_mmo_char_sql_init_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+bool HP_chr_char_slotchange(struct char_session_data *sd, int fd, unsigned short from, unsigned short to) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_chr_char_slotchange_pre ) {
+ bool (*preHookFunc) (struct char_session_data *sd, int *fd, unsigned short *from, unsigned short *to);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_char_slotchange_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_char_slotchange_pre[hIndex].func;
+ retVal___ = preHookFunc(sd, &fd, &from, &to);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.char_slotchange(sd, fd, from, to);
+ }
+ if( HPMHooks.count.HP_chr_char_slotchange_post ) {
+ bool (*postHookFunc) (bool retVal___, struct char_session_data *sd, int *fd, unsigned short *from, unsigned short *to);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_char_slotchange_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_char_slotchange_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, sd, &fd, &from, &to);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_rename_char_sql(struct char_session_data *sd, int char_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_rename_char_sql_pre ) {
+ int (*preHookFunc) (struct char_session_data *sd, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_rename_char_sql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_rename_char_sql_pre[hIndex].func;
+ retVal___ = preHookFunc(sd, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.rename_char_sql(sd, char_id);
+ }
+ if( HPMHooks.count.HP_chr_rename_char_sql_post ) {
+ int (*postHookFunc) (int retVal___, struct char_session_data *sd, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_rename_char_sql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_rename_char_sql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, sd, &char_id);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_check_char_name(char *name, char *esc_name) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_check_char_name_pre ) {
+ int (*preHookFunc) (char *name, char *esc_name);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_check_char_name_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_check_char_name_pre[hIndex].func;
+ retVal___ = preHookFunc(name, esc_name);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.check_char_name(name, esc_name);
+ }
+ if( HPMHooks.count.HP_chr_check_char_name_post ) {
+ int (*postHookFunc) (int retVal___, char *name, char *esc_name);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_check_char_name_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_check_char_name_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, name, esc_name);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_make_new_char_sql(struct char_session_data *sd, char *name_, int str, int agi, int vit, int int_, int dex, int luk, int slot, int hair_color, int hair_style) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_make_new_char_sql_pre ) {
+ int (*preHookFunc) (struct char_session_data *sd, char *name_, int *str, int *agi, int *vit, int *int_, int *dex, int *luk, int *slot, int *hair_color, int *hair_style);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_make_new_char_sql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_make_new_char_sql_pre[hIndex].func;
+ retVal___ = preHookFunc(sd, name_, &str, &agi, &vit, &int_, &dex, &luk, &slot, &hair_color, &hair_style);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.make_new_char_sql(sd, name_, str, agi, vit, int_, dex, luk, slot, hair_color, hair_style);
+ }
+ if( HPMHooks.count.HP_chr_make_new_char_sql_post ) {
+ int (*postHookFunc) (int retVal___, struct char_session_data *sd, char *name_, int *str, int *agi, int *vit, int *int_, int *dex, int *luk, int *slot, int *hair_color, int *hair_style);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_make_new_char_sql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_make_new_char_sql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, sd, name_, &str, &agi, &vit, &int_, &dex, &luk, &slot, &hair_color, &hair_style);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_divorce_char_sql(int partner_id1, int partner_id2) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_divorce_char_sql_pre ) {
+ int (*preHookFunc) (int *partner_id1, int *partner_id2);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_divorce_char_sql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_divorce_char_sql_pre[hIndex].func;
+ retVal___ = preHookFunc(&partner_id1, &partner_id2);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.divorce_char_sql(partner_id1, partner_id2);
+ }
+ if( HPMHooks.count.HP_chr_divorce_char_sql_post ) {
+ int (*postHookFunc) (int retVal___, int *partner_id1, int *partner_id2);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_divorce_char_sql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_divorce_char_sql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &partner_id1, &partner_id2);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_count_users(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_count_users_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_count_users_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_count_users_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.count_users();
+ }
+ if( HPMHooks.count.HP_chr_count_users_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_count_users_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_count_users_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_mmo_char_tobuf(uint8 *buffer, struct mmo_charstatus *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_mmo_char_tobuf_pre ) {
+ int (*preHookFunc) (uint8 *buffer, struct mmo_charstatus *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_tobuf_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_mmo_char_tobuf_pre[hIndex].func;
+ retVal___ = preHookFunc(buffer, p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.mmo_char_tobuf(buffer, p);
+ }
+ if( HPMHooks.count.HP_chr_mmo_char_tobuf_post ) {
+ int (*postHookFunc) (int retVal___, uint8 *buffer, struct mmo_charstatus *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_tobuf_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_mmo_char_tobuf_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, buffer, p);
+ }
+ }
+ return retVal___;
+}
+void HP_chr_mmo_char_send099d(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_mmo_char_send099d_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_send099d_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_mmo_char_send099d_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.mmo_char_send099d(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_mmo_char_send099d_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_send099d_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_mmo_char_send099d_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_mmo_char_send_ban_list(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_mmo_char_send_ban_list_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_send_ban_list_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_mmo_char_send_ban_list_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.mmo_char_send_ban_list(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_mmo_char_send_ban_list_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_send_ban_list_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_mmo_char_send_ban_list_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_mmo_char_send_slots_info(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_mmo_char_send_slots_info_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_send_slots_info_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_mmo_char_send_slots_info_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.mmo_char_send_slots_info(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_mmo_char_send_slots_info_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_send_slots_info_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_mmo_char_send_slots_info_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+int HP_chr_mmo_char_send_characters(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_mmo_char_send_characters_pre ) {
+ int (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_send_characters_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_mmo_char_send_characters_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.mmo_char_send_characters(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_mmo_char_send_characters_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_char_send_characters_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_mmo_char_send_characters_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, sd);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_char_married(int pl1, int pl2) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_char_married_pre ) {
+ int (*preHookFunc) (int *pl1, int *pl2);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_char_married_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_char_married_pre[hIndex].func;
+ retVal___ = preHookFunc(&pl1, &pl2);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.char_married(pl1, pl2);
+ }
+ if( HPMHooks.count.HP_chr_char_married_post ) {
+ int (*postHookFunc) (int retVal___, int *pl1, int *pl2);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_char_married_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_char_married_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &pl1, &pl2);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_char_child(int parent_id, int child_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_char_child_pre ) {
+ int (*preHookFunc) (int *parent_id, int *child_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_char_child_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_char_child_pre[hIndex].func;
+ retVal___ = preHookFunc(&parent_id, &child_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.char_child(parent_id, child_id);
+ }
+ if( HPMHooks.count.HP_chr_char_child_post ) {
+ int (*postHookFunc) (int retVal___, int *parent_id, int *child_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_char_child_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_char_child_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &parent_id, &child_id);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_char_family(int cid1, int cid2, int cid3) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_char_family_pre ) {
+ int (*preHookFunc) (int *cid1, int *cid2, int *cid3);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_char_family_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_char_family_pre[hIndex].func;
+ retVal___ = preHookFunc(&cid1, &cid2, &cid3);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.char_family(cid1, cid2, cid3);
+ }
+ if( HPMHooks.count.HP_chr_char_family_post ) {
+ int (*postHookFunc) (int retVal___, int *cid1, int *cid2, int *cid3);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_char_family_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_char_family_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &cid1, &cid2, &cid3);
+ }
+ }
+ return retVal___;
+}
+void HP_chr_disconnect_player(int account_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_disconnect_player_pre ) {
+ void (*preHookFunc) (int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_disconnect_player_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_disconnect_player_pre[hIndex].func;
+ preHookFunc(&account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.disconnect_player(account_id);
+ }
+ if( HPMHooks.count.HP_chr_disconnect_player_post ) {
+ void (*postHookFunc) (int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_disconnect_player_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_disconnect_player_post[hIndex].func;
+ postHookFunc(&account_id);
+ }
+ }
+ return;
+}
+void HP_chr_authfail_fd(int fd, int type) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_authfail_fd_pre ) {
+ void (*preHookFunc) (int *fd, int *type);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_authfail_fd_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_authfail_fd_pre[hIndex].func;
+ preHookFunc(&fd, &type);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.authfail_fd(fd, type);
+ }
+ if( HPMHooks.count.HP_chr_authfail_fd_post ) {
+ void (*postHookFunc) (int *fd, int *type);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_authfail_fd_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_authfail_fd_post[hIndex].func;
+ postHookFunc(&fd, &type);
+ }
+ }
+ return;
+}
+void HP_chr_request_account_data(int account_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_request_account_data_pre ) {
+ void (*preHookFunc) (int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_request_account_data_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_request_account_data_pre[hIndex].func;
+ preHookFunc(&account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.request_account_data(account_id);
+ }
+ if( HPMHooks.count.HP_chr_request_account_data_post ) {
+ void (*postHookFunc) (int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_request_account_data_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_request_account_data_post[hIndex].func;
+ postHookFunc(&account_id);
+ }
+ }
+ return;
+}
+void HP_chr_auth_ok(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_auth_ok_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_auth_ok_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_auth_ok_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.auth_ok(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_auth_ok_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_auth_ok_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_auth_ok_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_ping_login_server(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_ping_login_server_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_ping_login_server_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_ping_login_server_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.ping_login_server(fd);
+ }
+ if( HPMHooks.count.HP_chr_ping_login_server_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_ping_login_server_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_ping_login_server_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+int HP_chr_parse_fromlogin_connection_state(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_parse_fromlogin_connection_state_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_connection_state_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_connection_state_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.parse_fromlogin_connection_state(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_fromlogin_connection_state_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_connection_state_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_connection_state_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+void HP_chr_auth_error(int fd, unsigned char flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_auth_error_pre ) {
+ void (*preHookFunc) (int *fd, unsigned char *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_auth_error_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_auth_error_pre[hIndex].func;
+ preHookFunc(&fd, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.auth_error(fd, flag);
+ }
+ if( HPMHooks.count.HP_chr_auth_error_post ) {
+ void (*postHookFunc) (int *fd, unsigned char *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_auth_error_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_auth_error_post[hIndex].func;
+ postHookFunc(&fd, &flag);
+ }
+ }
+ return;
+}
+void HP_chr_parse_fromlogin_auth_state(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_fromlogin_auth_state_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_auth_state_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_auth_state_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_fromlogin_auth_state(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_fromlogin_auth_state_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_auth_state_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_auth_state_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_fromlogin_account_data(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_fromlogin_account_data_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_account_data_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_account_data_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_fromlogin_account_data(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_fromlogin_account_data_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_account_data_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_account_data_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_fromlogin_login_pong(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_fromlogin_login_pong_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_login_pong_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_login_pong_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_fromlogin_login_pong(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_fromlogin_login_pong_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_login_pong_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_login_pong_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_changesex(int account_id, int sex) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_changesex_pre ) {
+ void (*preHookFunc) (int *account_id, int *sex);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_changesex_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_changesex_pre[hIndex].func;
+ preHookFunc(&account_id, &sex);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.changesex(account_id, sex);
+ }
+ if( HPMHooks.count.HP_chr_changesex_post ) {
+ void (*postHookFunc) (int *account_id, int *sex);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_changesex_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_changesex_post[hIndex].func;
+ postHookFunc(&account_id, &sex);
+ }
+ }
+ return;
+}
+int HP_chr_parse_fromlogin_changesex_reply(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_parse_fromlogin_changesex_reply_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_changesex_reply_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_changesex_reply_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.parse_fromlogin_changesex_reply(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_fromlogin_changesex_reply_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_changesex_reply_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_changesex_reply_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+void HP_chr_parse_fromlogin_account_reg2(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_fromlogin_account_reg2_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_account_reg2_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_account_reg2_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_fromlogin_account_reg2(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_fromlogin_account_reg2_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_account_reg2_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_account_reg2_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_fromlogin_ban(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_fromlogin_ban_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_ban_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_ban_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_fromlogin_ban(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_fromlogin_ban_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_ban_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_ban_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_fromlogin_kick(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_fromlogin_kick_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_kick_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_kick_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_fromlogin_kick(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_fromlogin_kick_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_kick_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_kick_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_update_ip(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_update_ip_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_update_ip_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_update_ip_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.update_ip(fd);
+ }
+ if( HPMHooks.count.HP_chr_update_ip_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_update_ip_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_update_ip_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_fromlogin_update_ip(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_fromlogin_update_ip_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_update_ip_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_update_ip_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_fromlogin_update_ip(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_fromlogin_update_ip_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_update_ip_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_update_ip_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_fromlogin_accinfo2_failed(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_fromlogin_accinfo2_failed_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_accinfo2_failed_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_accinfo2_failed_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_fromlogin_accinfo2_failed(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_fromlogin_accinfo2_failed_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_accinfo2_failed_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_accinfo2_failed_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_fromlogin_accinfo2_ok(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_fromlogin_accinfo2_ok_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_accinfo2_ok_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_accinfo2_ok_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_fromlogin_accinfo2_ok(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_fromlogin_accinfo2_ok_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_accinfo2_ok_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_accinfo2_ok_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+int HP_chr_parse_fromlogin(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_parse_fromlogin_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.parse_fromlogin(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_fromlogin_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_fromlogin_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_fromlogin_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_request_accreg2(int account_id, int char_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_request_accreg2_pre ) {
+ int (*preHookFunc) (int *account_id, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_request_accreg2_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_request_accreg2_pre[hIndex].func;
+ retVal___ = preHookFunc(&account_id, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.request_accreg2(account_id, char_id);
+ }
+ if( HPMHooks.count.HP_chr_request_accreg2_post ) {
+ int (*postHookFunc) (int retVal___, int *account_id, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_request_accreg2_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_request_accreg2_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &account_id, &char_id);
+ }
+ }
+ return retVal___;
+}
+void HP_chr_global_accreg_to_login_start(int account_id, int char_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_global_accreg_to_login_start_pre ) {
+ void (*preHookFunc) (int *account_id, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_global_accreg_to_login_start_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_global_accreg_to_login_start_pre[hIndex].func;
+ preHookFunc(&account_id, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.global_accreg_to_login_start(account_id, char_id);
+ }
+ if( HPMHooks.count.HP_chr_global_accreg_to_login_start_post ) {
+ void (*postHookFunc) (int *account_id, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_global_accreg_to_login_start_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_global_accreg_to_login_start_post[hIndex].func;
+ postHookFunc(&account_id, &char_id);
+ }
+ }
+ return;
+}
+void HP_chr_global_accreg_to_login_send(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_global_accreg_to_login_send_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_global_accreg_to_login_send_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_global_accreg_to_login_send_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.global_accreg_to_login_send();
+ }
+ if( HPMHooks.count.HP_chr_global_accreg_to_login_send_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_global_accreg_to_login_send_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_global_accreg_to_login_send_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_chr_global_accreg_to_login_add(const char *key, unsigned int index, intptr_t val, bool is_string) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_global_accreg_to_login_add_pre ) {
+ void (*preHookFunc) (const char *key, unsigned int *index, intptr_t *val, bool *is_string);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_global_accreg_to_login_add_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_global_accreg_to_login_add_pre[hIndex].func;
+ preHookFunc(key, &index, &val, &is_string);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.global_accreg_to_login_add(key, index, val, is_string);
+ }
+ if( HPMHooks.count.HP_chr_global_accreg_to_login_add_post ) {
+ void (*postHookFunc) (const char *key, unsigned int *index, intptr_t *val, bool *is_string);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_global_accreg_to_login_add_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_global_accreg_to_login_add_post[hIndex].func;
+ postHookFunc(key, &index, &val, &is_string);
+ }
+ }
+ return;
+}
+void HP_chr_read_fame_list(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_read_fame_list_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_read_fame_list_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_read_fame_list_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.read_fame_list();
+ }
+ if( HPMHooks.count.HP_chr_read_fame_list_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_read_fame_list_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_read_fame_list_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+int HP_chr_send_fame_list(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_send_fame_list_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_fame_list_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_send_fame_list_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.send_fame_list(fd);
+ }
+ if( HPMHooks.count.HP_chr_send_fame_list_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_fame_list_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_send_fame_list_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+void HP_chr_update_fame_list(int type, int index, int fame) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_update_fame_list_pre ) {
+ void (*preHookFunc) (int *type, int *index, int *fame);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_update_fame_list_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_update_fame_list_pre[hIndex].func;
+ preHookFunc(&type, &index, &fame);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.update_fame_list(type, index, fame);
+ }
+ if( HPMHooks.count.HP_chr_update_fame_list_post ) {
+ void (*postHookFunc) (int *type, int *index, int *fame);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_update_fame_list_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_update_fame_list_post[hIndex].func;
+ postHookFunc(&type, &index, &fame);
+ }
+ }
+ return;
+}
+int HP_chr_loadName(int char_id, char *name) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_loadName_pre ) {
+ int (*preHookFunc) (int *char_id, char *name);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_loadName_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_loadName_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, name);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.loadName(char_id, name);
+ }
+ if( HPMHooks.count.HP_chr_loadName_post ) {
+ int (*postHookFunc) (int retVal___, int *char_id, char *name);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_loadName_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_loadName_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, name);
+ }
+ }
+ return retVal___;
+}
+void HP_chr_parse_frommap_datasync(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_datasync_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_datasync_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_datasync_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_datasync(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_datasync_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_datasync_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_datasync_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_skillid2idx(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_skillid2idx_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_skillid2idx_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_skillid2idx_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_skillid2idx(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_skillid2idx_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_skillid2idx_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_skillid2idx_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_map_received_ok(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_map_received_ok_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_map_received_ok_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_map_received_ok_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.map_received_ok(fd);
+ }
+ if( HPMHooks.count.HP_chr_map_received_ok_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_map_received_ok_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_map_received_ok_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_send_maps(int fd, int id, int j) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_send_maps_pre ) {
+ void (*preHookFunc) (int *fd, int *id, int *j);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_maps_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_send_maps_pre[hIndex].func;
+ preHookFunc(&fd, &id, &j);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.send_maps(fd, id, j);
+ }
+ if( HPMHooks.count.HP_chr_send_maps_post ) {
+ void (*postHookFunc) (int *fd, int *id, int *j);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_maps_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_send_maps_post[hIndex].func;
+ postHookFunc(&fd, &id, &j);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_map_names(int fd, int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_map_names_pre ) {
+ void (*preHookFunc) (int *fd, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_map_names_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_map_names_pre[hIndex].func;
+ preHookFunc(&fd, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_map_names(fd, id);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_map_names_post ) {
+ void (*postHookFunc) (int *fd, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_map_names_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_map_names_post[hIndex].func;
+ postHookFunc(&fd, &id);
+ }
+ }
+ return;
+}
+void HP_chr_send_scdata(int fd, int aid, int cid) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_send_scdata_pre ) {
+ void (*preHookFunc) (int *fd, int *aid, int *cid);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_scdata_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_send_scdata_pre[hIndex].func;
+ preHookFunc(&fd, &aid, &cid);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.send_scdata(fd, aid, cid);
+ }
+ if( HPMHooks.count.HP_chr_send_scdata_post ) {
+ void (*postHookFunc) (int *fd, int *aid, int *cid);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_scdata_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_send_scdata_post[hIndex].func;
+ postHookFunc(&fd, &aid, &cid);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_request_scdata(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_request_scdata_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_request_scdata_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_request_scdata_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_request_scdata(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_request_scdata_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_request_scdata_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_request_scdata_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_set_users_count(int fd, int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_set_users_count_pre ) {
+ void (*preHookFunc) (int *fd, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_set_users_count_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_set_users_count_pre[hIndex].func;
+ preHookFunc(&fd, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_set_users_count(fd, id);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_set_users_count_post ) {
+ void (*postHookFunc) (int *fd, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_set_users_count_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_set_users_count_post[hIndex].func;
+ postHookFunc(&fd, &id);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_set_users(int fd, int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_set_users_pre ) {
+ void (*preHookFunc) (int *fd, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_set_users_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_set_users_pre[hIndex].func;
+ preHookFunc(&fd, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_set_users(fd, id);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_set_users_post ) {
+ void (*postHookFunc) (int *fd, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_set_users_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_set_users_post[hIndex].func;
+ postHookFunc(&fd, &id);
+ }
+ }
+ return;
+}
+void HP_chr_save_character_ack(int fd, int aid, int cid) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_save_character_ack_pre ) {
+ void (*preHookFunc) (int *fd, int *aid, int *cid);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_save_character_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_save_character_ack_pre[hIndex].func;
+ preHookFunc(&fd, &aid, &cid);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.save_character_ack(fd, aid, cid);
+ }
+ if( HPMHooks.count.HP_chr_save_character_ack_post ) {
+ void (*postHookFunc) (int *fd, int *aid, int *cid);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_save_character_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_save_character_ack_post[hIndex].func;
+ postHookFunc(&fd, &aid, &cid);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_save_character(int fd, int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_save_character_pre ) {
+ void (*preHookFunc) (int *fd, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_save_character_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_save_character_pre[hIndex].func;
+ preHookFunc(&fd, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_save_character(fd, id);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_save_character_post ) {
+ void (*postHookFunc) (int *fd, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_save_character_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_save_character_post[hIndex].func;
+ postHookFunc(&fd, &id);
+ }
+ }
+ return;
+}
+void HP_chr_select_ack(int fd, int account_id, uint8 flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_select_ack_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id, uint8 *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_select_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_select_ack_pre[hIndex].func;
+ preHookFunc(&fd, &account_id, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.select_ack(fd, account_id, flag);
+ }
+ if( HPMHooks.count.HP_chr_select_ack_post ) {
+ void (*postHookFunc) (int *fd, int *account_id, uint8 *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_select_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_select_ack_post[hIndex].func;
+ postHookFunc(&fd, &account_id, &flag);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_char_select_req(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_char_select_req_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_char_select_req_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_char_select_req_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_char_select_req(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_char_select_req_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_char_select_req_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_char_select_req_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_change_map_server_ack(int fd, uint8 *data, bool ok) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_change_map_server_ack_pre ) {
+ void (*preHookFunc) (int *fd, uint8 *data, bool *ok);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_change_map_server_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_change_map_server_ack_pre[hIndex].func;
+ preHookFunc(&fd, data, &ok);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.change_map_server_ack(fd, data, ok);
+ }
+ if( HPMHooks.count.HP_chr_change_map_server_ack_post ) {
+ void (*postHookFunc) (int *fd, uint8 *data, bool *ok);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_change_map_server_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_change_map_server_ack_post[hIndex].func;
+ postHookFunc(&fd, data, &ok);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_change_map_server(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_change_map_server_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_change_map_server_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_change_map_server_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_change_map_server(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_change_map_server_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_change_map_server_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_change_map_server_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_remove_friend(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_remove_friend_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_remove_friend_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_remove_friend_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_remove_friend(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_remove_friend_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_remove_friend_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_remove_friend_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_char_name_ack(int fd, int char_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_char_name_ack_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_char_name_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_char_name_ack_pre[hIndex].func;
+ preHookFunc(&fd, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.char_name_ack(fd, char_id);
+ }
+ if( HPMHooks.count.HP_chr_char_name_ack_post ) {
+ void (*postHookFunc) (int *fd, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_char_name_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_char_name_ack_post[hIndex].func;
+ postHookFunc(&fd, &char_id);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_char_name_request(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_char_name_request_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_char_name_request_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_char_name_request_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_char_name_request(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_char_name_request_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_char_name_request_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_char_name_request_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_change_email(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_change_email_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_change_email_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_change_email_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_change_email(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_change_email_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_change_email_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_change_email_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_ban(int account_id, int char_id, time_t *unban_time, short year, short month, short day, short hour, short minute, short second) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_ban_pre ) {
+ void (*preHookFunc) (int *account_id, int *char_id, time_t *unban_time, short *year, short *month, short *day, short *hour, short *minute, short *second);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_ban_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_ban_pre[hIndex].func;
+ preHookFunc(&account_id, &char_id, unban_time, &year, &month, &day, &hour, &minute, &second);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.ban(account_id, char_id, unban_time, year, month, day, hour, minute, second);
+ }
+ if( HPMHooks.count.HP_chr_ban_post ) {
+ void (*postHookFunc) (int *account_id, int *char_id, time_t *unban_time, short *year, short *month, short *day, short *hour, short *minute, short *second);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_ban_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_ban_post[hIndex].func;
+ postHookFunc(&account_id, &char_id, unban_time, &year, &month, &day, &hour, &minute, &second);
+ }
+ }
+ return;
+}
+void HP_chr_unban(int char_id, int *result) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_unban_pre ) {
+ void (*preHookFunc) (int *char_id, int *result);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_unban_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_unban_pre[hIndex].func;
+ preHookFunc(&char_id, result);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.unban(char_id, result);
+ }
+ if( HPMHooks.count.HP_chr_unban_post ) {
+ void (*postHookFunc) (int *char_id, int *result);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_unban_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_unban_post[hIndex].func;
+ postHookFunc(&char_id, result);
+ }
+ }
+ return;
+}
+void HP_chr_ask_name_ack(int fd, int acc, const char *name, int type, int result) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_ask_name_ack_pre ) {
+ void (*preHookFunc) (int *fd, int *acc, const char *name, int *type, int *result);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_ask_name_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_ask_name_ack_pre[hIndex].func;
+ preHookFunc(&fd, &acc, name, &type, &result);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.ask_name_ack(fd, acc, name, type, result);
+ }
+ if( HPMHooks.count.HP_chr_ask_name_ack_post ) {
+ void (*postHookFunc) (int *fd, int *acc, const char *name, int *type, int *result);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_ask_name_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_ask_name_ack_post[hIndex].func;
+ postHookFunc(&fd, &acc, name, &type, &result);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_change_account(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_change_account_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_change_account_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_change_account_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_change_account(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_change_account_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_change_account_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_change_account_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_fame_list(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_fame_list_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_fame_list_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_fame_list_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_fame_list(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_fame_list_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_fame_list_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_fame_list_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_divorce_char(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_divorce_char_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_divorce_char_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_divorce_char_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_divorce_char(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_divorce_char_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_divorce_char_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_divorce_char_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_ragsrvinfo(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_ragsrvinfo_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_ragsrvinfo_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_ragsrvinfo_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_ragsrvinfo(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_ragsrvinfo_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_ragsrvinfo_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_ragsrvinfo_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_set_char_offline(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_set_char_offline_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_set_char_offline_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_set_char_offline_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_set_char_offline(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_set_char_offline_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_set_char_offline_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_set_char_offline_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_set_all_offline(int fd, int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_set_all_offline_pre ) {
+ void (*preHookFunc) (int *fd, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_set_all_offline_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_set_all_offline_pre[hIndex].func;
+ preHookFunc(&fd, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_set_all_offline(fd, id);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_set_all_offline_post ) {
+ void (*postHookFunc) (int *fd, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_set_all_offline_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_set_all_offline_post[hIndex].func;
+ postHookFunc(&fd, &id);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_set_char_online(int fd, int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_set_char_online_pre ) {
+ void (*preHookFunc) (int *fd, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_set_char_online_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_set_char_online_pre[hIndex].func;
+ preHookFunc(&fd, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_set_char_online(fd, id);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_set_char_online_post ) {
+ void (*postHookFunc) (int *fd, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_set_char_online_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_set_char_online_post[hIndex].func;
+ postHookFunc(&fd, &id);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_build_fame_list(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_build_fame_list_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_build_fame_list_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_build_fame_list_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_build_fame_list(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_build_fame_list_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_build_fame_list_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_build_fame_list_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_save_status_change_data(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_save_status_change_data_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_save_status_change_data_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_save_status_change_data_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_save_status_change_data(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_save_status_change_data_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_save_status_change_data_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_save_status_change_data_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_send_pong(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_send_pong_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_pong_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_send_pong_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.send_pong(fd);
+ }
+ if( HPMHooks.count.HP_chr_send_pong_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_pong_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_send_pong_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_ping(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_ping_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_ping_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_ping_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_ping(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_ping_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_ping_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_ping_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_map_auth_ok(int fd, int account_id, struct char_auth_node *node, struct mmo_charstatus *cd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_map_auth_ok_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id, struct char_auth_node *node, struct mmo_charstatus *cd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_map_auth_ok_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_map_auth_ok_pre[hIndex].func;
+ preHookFunc(&fd, &account_id, node, cd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.map_auth_ok(fd, account_id, node, cd);
+ }
+ if( HPMHooks.count.HP_chr_map_auth_ok_post ) {
+ void (*postHookFunc) (int *fd, int *account_id, struct char_auth_node *node, struct mmo_charstatus *cd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_map_auth_ok_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_map_auth_ok_post[hIndex].func;
+ postHookFunc(&fd, &account_id, node, cd);
+ }
+ }
+ return;
+}
+void HP_chr_map_auth_failed(int fd, int account_id, int char_id, int login_id1, char sex, uint32 ip) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_map_auth_failed_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id, int *char_id, int *login_id1, char *sex, uint32 *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_map_auth_failed_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_map_auth_failed_pre[hIndex].func;
+ preHookFunc(&fd, &account_id, &char_id, &login_id1, &sex, &ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.map_auth_failed(fd, account_id, char_id, login_id1, sex, ip);
+ }
+ if( HPMHooks.count.HP_chr_map_auth_failed_post ) {
+ void (*postHookFunc) (int *fd, int *account_id, int *char_id, int *login_id1, char *sex, uint32 *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_map_auth_failed_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_map_auth_failed_post[hIndex].func;
+ postHookFunc(&fd, &account_id, &char_id, &login_id1, &sex, &ip);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_auth_request(int fd, int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_auth_request_pre ) {
+ void (*preHookFunc) (int *fd, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_auth_request_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_auth_request_pre[hIndex].func;
+ preHookFunc(&fd, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_auth_request(fd, id);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_auth_request_post ) {
+ void (*postHookFunc) (int *fd, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_auth_request_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_auth_request_post[hIndex].func;
+ postHookFunc(&fd, &id);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_update_ip(int fd, int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_update_ip_pre ) {
+ void (*preHookFunc) (int *fd, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_update_ip_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_update_ip_pre[hIndex].func;
+ preHookFunc(&fd, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_update_ip(fd, id);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_update_ip_post ) {
+ void (*postHookFunc) (int *fd, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_update_ip_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_update_ip_post[hIndex].func;
+ postHookFunc(&fd, &id);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_request_stats_report(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_request_stats_report_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_request_stats_report_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_request_stats_report_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_request_stats_report(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_request_stats_report_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_request_stats_report_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_request_stats_report_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_scdata_update(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_scdata_update_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_scdata_update_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_scdata_update_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_scdata_update(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_scdata_update_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_scdata_update_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_scdata_update_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_frommap_scdata_delete(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_scdata_delete_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_scdata_delete_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_scdata_delete_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_frommap_scdata_delete(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_scdata_delete_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_scdata_delete_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_scdata_delete_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+int HP_chr_parse_frommap(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_parse_frommap_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_frommap_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.parse_frommap(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_frommap_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_frommap_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_frommap_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_search_mapserver(unsigned short map, uint32 ip, uint16 port) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_search_mapserver_pre ) {
+ int (*preHookFunc) (unsigned short *map, uint32 *ip, uint16 *port);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_search_mapserver_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_search_mapserver_pre[hIndex].func;
+ retVal___ = preHookFunc(&map, &ip, &port);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.search_mapserver(map, ip, port);
+ }
+ if( HPMHooks.count.HP_chr_search_mapserver_post ) {
+ int (*postHookFunc) (int retVal___, unsigned short *map, uint32 *ip, uint16 *port);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_search_mapserver_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_search_mapserver_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &map, &ip, &port);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_mapif_init(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_mapif_init_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mapif_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_mapif_init_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.mapif_init(fd);
+ }
+ if( HPMHooks.count.HP_chr_mapif_init_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mapif_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_mapif_init_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_lan_subnetcheck(uint32 ip) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_lan_subnetcheck_pre ) {
+ int (*preHookFunc) (uint32 *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_lan_subnetcheck_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_lan_subnetcheck_pre[hIndex].func;
+ retVal___ = preHookFunc(&ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.lan_subnetcheck(ip);
+ }
+ if( HPMHooks.count.HP_chr_lan_subnetcheck_post ) {
+ int (*postHookFunc) (int retVal___, uint32 *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_lan_subnetcheck_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_lan_subnetcheck_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &ip);
+ }
+ }
+ return retVal___;
+}
+void HP_chr_delete2_ack(int fd, int char_id, uint32 result, time_t delete_date) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_delete2_ack_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, uint32 *result, time_t *delete_date);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_delete2_ack_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, &result, &delete_date);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.delete2_ack(fd, char_id, result, delete_date);
+ }
+ if( HPMHooks.count.HP_chr_delete2_ack_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, uint32 *result, time_t *delete_date);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_delete2_ack_post[hIndex].func;
+ postHookFunc(&fd, &char_id, &result, &delete_date);
+ }
+ }
+ return;
+}
+void HP_chr_delete2_accept_actual_ack(int fd, int char_id, uint32 result) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_delete2_accept_actual_ack_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, uint32 *result);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_accept_actual_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_delete2_accept_actual_ack_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, &result);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.delete2_accept_actual_ack(fd, char_id, result);
+ }
+ if( HPMHooks.count.HP_chr_delete2_accept_actual_ack_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, uint32 *result);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_accept_actual_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_delete2_accept_actual_ack_post[hIndex].func;
+ postHookFunc(&fd, &char_id, &result);
+ }
+ }
+ return;
+}
+void HP_chr_delete2_accept_ack(int fd, int char_id, uint32 result) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_delete2_accept_ack_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, uint32 *result);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_accept_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_delete2_accept_ack_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, &result);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.delete2_accept_ack(fd, char_id, result);
+ }
+ if( HPMHooks.count.HP_chr_delete2_accept_ack_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, uint32 *result);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_accept_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_delete2_accept_ack_post[hIndex].func;
+ postHookFunc(&fd, &char_id, &result);
+ }
+ }
+ return;
+}
+void HP_chr_delete2_cancel_ack(int fd, int char_id, uint32 result) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_delete2_cancel_ack_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, uint32 *result);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_cancel_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_delete2_cancel_ack_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, &result);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.delete2_cancel_ack(fd, char_id, result);
+ }
+ if( HPMHooks.count.HP_chr_delete2_cancel_ack_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, uint32 *result);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_cancel_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_delete2_cancel_ack_post[hIndex].func;
+ postHookFunc(&fd, &char_id, &result);
+ }
+ }
+ return;
+}
+void HP_chr_delete2_req(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_delete2_req_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_req_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_delete2_req_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.delete2_req(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_delete2_req_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_req_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_delete2_req_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_delete2_accept(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_delete2_accept_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_accept_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_delete2_accept_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.delete2_accept(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_delete2_accept_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_accept_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_delete2_accept_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_delete2_cancel(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_delete2_cancel_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_cancel_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_delete2_cancel_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.delete2_cancel(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_delete2_cancel_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete2_cancel_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_delete2_cancel_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_send_account_id(int fd, int account_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_send_account_id_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_account_id_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_send_account_id_pre[hIndex].func;
+ preHookFunc(&fd, &account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.send_account_id(fd, account_id);
+ }
+ if( HPMHooks.count.HP_chr_send_account_id_post ) {
+ void (*postHookFunc) (int *fd, int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_account_id_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_send_account_id_post[hIndex].func;
+ postHookFunc(&fd, &account_id);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_connect(int fd, struct char_session_data *sd, uint32 ipl) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_connect_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd, uint32 *ipl);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_connect_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_connect_pre[hIndex].func;
+ preHookFunc(&fd, sd, &ipl);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_connect(fd, sd, ipl);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_connect_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd, uint32 *ipl);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_connect_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_connect_post[hIndex].func;
+ postHookFunc(&fd, sd, &ipl);
+ }
+ }
+ return;
+}
+void HP_chr_send_map_info(int fd, int i, uint32 subnet_map_ip, struct mmo_charstatus *cd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_send_map_info_pre ) {
+ void (*preHookFunc) (int *fd, int *i, uint32 *subnet_map_ip, struct mmo_charstatus *cd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_map_info_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_send_map_info_pre[hIndex].func;
+ preHookFunc(&fd, &i, &subnet_map_ip, cd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.send_map_info(fd, i, subnet_map_ip, cd);
+ }
+ if( HPMHooks.count.HP_chr_send_map_info_post ) {
+ void (*postHookFunc) (int *fd, int *i, uint32 *subnet_map_ip, struct mmo_charstatus *cd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_map_info_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_send_map_info_post[hIndex].func;
+ postHookFunc(&fd, &i, &subnet_map_ip, cd);
+ }
+ }
+ return;
+}
+void HP_chr_send_wait_char_server(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_send_wait_char_server_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_wait_char_server_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_send_wait_char_server_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.send_wait_char_server(fd);
+ }
+ if( HPMHooks.count.HP_chr_send_wait_char_server_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_wait_char_server_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_send_wait_char_server_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+int HP_chr_search_default_maps_mapserver(struct mmo_charstatus *cd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_search_default_maps_mapserver_pre ) {
+ int (*preHookFunc) (struct mmo_charstatus *cd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_search_default_maps_mapserver_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_search_default_maps_mapserver_pre[hIndex].func;
+ retVal___ = preHookFunc(cd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.search_default_maps_mapserver(cd);
+ }
+ if( HPMHooks.count.HP_chr_search_default_maps_mapserver_post ) {
+ int (*postHookFunc) (int retVal___, struct mmo_charstatus *cd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_search_default_maps_mapserver_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_search_default_maps_mapserver_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, cd);
+ }
+ }
+ return retVal___;
+}
+void HP_chr_parse_char_select(int fd, struct char_session_data *sd, uint32 ipl) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_select_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd, uint32 *ipl);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_select_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_select_pre[hIndex].func;
+ preHookFunc(&fd, sd, &ipl);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_select(fd, sd, ipl);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_select_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd, uint32 *ipl);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_select_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_select_post[hIndex].func;
+ postHookFunc(&fd, sd, &ipl);
+ }
+ }
+ return;
+}
+void HP_chr_creation_failed(int fd, int result) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_creation_failed_pre ) {
+ void (*preHookFunc) (int *fd, int *result);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_creation_failed_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_creation_failed_pre[hIndex].func;
+ preHookFunc(&fd, &result);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.creation_failed(fd, result);
+ }
+ if( HPMHooks.count.HP_chr_creation_failed_post ) {
+ void (*postHookFunc) (int *fd, int *result);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_creation_failed_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_creation_failed_post[hIndex].func;
+ postHookFunc(&fd, &result);
+ }
+ }
+ return;
+}
+void HP_chr_creation_ok(int fd, struct mmo_charstatus *char_dat) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_creation_ok_pre ) {
+ void (*preHookFunc) (int *fd, struct mmo_charstatus *char_dat);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_creation_ok_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_creation_ok_pre[hIndex].func;
+ preHookFunc(&fd, char_dat);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.creation_ok(fd, char_dat);
+ }
+ if( HPMHooks.count.HP_chr_creation_ok_post ) {
+ void (*postHookFunc) (int *fd, struct mmo_charstatus *char_dat);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_creation_ok_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_creation_ok_post[hIndex].func;
+ postHookFunc(&fd, char_dat);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_create_new_char(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_create_new_char_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_create_new_char_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_create_new_char_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_create_new_char(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_create_new_char_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_create_new_char_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_create_new_char_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_delete_char_failed(int fd, int flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_delete_char_failed_pre ) {
+ void (*preHookFunc) (int *fd, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete_char_failed_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_delete_char_failed_pre[hIndex].func;
+ preHookFunc(&fd, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.delete_char_failed(fd, flag);
+ }
+ if( HPMHooks.count.HP_chr_delete_char_failed_post ) {
+ void (*postHookFunc) (int *fd, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete_char_failed_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_delete_char_failed_post[hIndex].func;
+ postHookFunc(&fd, &flag);
+ }
+ }
+ return;
+}
+void HP_chr_delete_char_ok(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_delete_char_ok_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete_char_ok_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_delete_char_ok_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.delete_char_ok(fd);
+ }
+ if( HPMHooks.count.HP_chr_delete_char_ok_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_delete_char_ok_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_delete_char_ok_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_delete_char(int fd, struct char_session_data *sd, unsigned short cmd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_delete_char_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd, unsigned short *cmd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_delete_char_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_delete_char_pre[hIndex].func;
+ preHookFunc(&fd, sd, &cmd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_delete_char(fd, sd, cmd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_delete_char_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd, unsigned short *cmd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_delete_char_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_delete_char_post[hIndex].func;
+ postHookFunc(&fd, sd, &cmd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_ping(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_ping_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_ping_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_ping_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_ping(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_ping_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_ping_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_ping_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_allow_rename(int fd, int flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_allow_rename_pre ) {
+ void (*preHookFunc) (int *fd, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_allow_rename_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_allow_rename_pre[hIndex].func;
+ preHookFunc(&fd, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.allow_rename(fd, flag);
+ }
+ if( HPMHooks.count.HP_chr_allow_rename_post ) {
+ void (*postHookFunc) (int *fd, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_allow_rename_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_allow_rename_post[hIndex].func;
+ postHookFunc(&fd, &flag);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_rename_char(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_rename_char_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_rename_char_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_rename_char_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_rename_char(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_rename_char_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_rename_char_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_rename_char_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_rename_char2(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_rename_char2_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_rename_char2_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_rename_char2_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_rename_char2(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_rename_char2_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_rename_char2_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_rename_char2_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_rename_char_ack(int fd, int flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_rename_char_ack_pre ) {
+ void (*preHookFunc) (int *fd, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_rename_char_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_rename_char_ack_pre[hIndex].func;
+ preHookFunc(&fd, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.rename_char_ack(fd, flag);
+ }
+ if( HPMHooks.count.HP_chr_rename_char_ack_post ) {
+ void (*postHookFunc) (int *fd, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_rename_char_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_rename_char_ack_post[hIndex].func;
+ postHookFunc(&fd, &flag);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_rename_char_confirm(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_rename_char_confirm_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_rename_char_confirm_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_rename_char_confirm_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_rename_char_confirm(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_rename_char_confirm_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_rename_char_confirm_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_rename_char_confirm_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_captcha_notsupported(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_captcha_notsupported_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_captcha_notsupported_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_captcha_notsupported_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.captcha_notsupported(fd);
+ }
+ if( HPMHooks.count.HP_chr_captcha_notsupported_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_captcha_notsupported_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_captcha_notsupported_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_request_captcha(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_request_captcha_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_request_captcha_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_request_captcha_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_request_captcha(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_request_captcha_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_request_captcha_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_request_captcha_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_check_captcha(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_check_captcha_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_check_captcha_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_check_captcha_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_check_captcha(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_check_captcha_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_check_captcha_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_check_captcha_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_delete2_req(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_delete2_req_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_delete2_req_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_delete2_req_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_delete2_req(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_delete2_req_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_delete2_req_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_delete2_req_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_delete2_accept(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_delete2_accept_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_delete2_accept_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_delete2_accept_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_delete2_accept(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_delete2_accept_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_delete2_accept_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_delete2_accept_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_delete2_cancel(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_delete2_cancel_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_delete2_cancel_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_delete2_cancel_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_delete2_cancel(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_delete2_cancel_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_delete2_cancel_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_delete2_cancel_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_login_map_server_ack(int fd, uint8 flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_login_map_server_ack_pre ) {
+ void (*preHookFunc) (int *fd, uint8 *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_login_map_server_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_login_map_server_ack_pre[hIndex].func;
+ preHookFunc(&fd, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.login_map_server_ack(fd, flag);
+ }
+ if( HPMHooks.count.HP_chr_login_map_server_ack_post ) {
+ void (*postHookFunc) (int *fd, uint8 *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_login_map_server_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_login_map_server_ack_post[hIndex].func;
+ postHookFunc(&fd, &flag);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_login_map_server(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_login_map_server_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_login_map_server_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_login_map_server_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_login_map_server(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_login_map_server_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_login_map_server_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_login_map_server_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_pincode_check(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_pincode_check_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_pincode_check_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_pincode_check_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_pincode_check(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_pincode_check_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_pincode_check_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_pincode_check_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_pincode_window(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_pincode_window_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_pincode_window_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_pincode_window_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_pincode_window(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_pincode_window_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_pincode_window_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_pincode_window_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_pincode_change(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_pincode_change_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_pincode_change_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_pincode_change_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_pincode_change(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_pincode_change_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_pincode_change_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_pincode_change_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_pincode_first_pin(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_pincode_first_pin_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_pincode_first_pin_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_pincode_first_pin_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_pincode_first_pin(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_pincode_first_pin_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_pincode_first_pin_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_pincode_first_pin_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_request_chars(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_request_chars_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_request_chars_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_request_chars_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_request_chars(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_request_chars_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_request_chars_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_request_chars_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_chr_change_character_slot_ack(int fd, bool ret) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_change_character_slot_ack_pre ) {
+ void (*preHookFunc) (int *fd, bool *ret);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_change_character_slot_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_change_character_slot_ack_pre[hIndex].func;
+ preHookFunc(&fd, &ret);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.change_character_slot_ack(fd, ret);
+ }
+ if( HPMHooks.count.HP_chr_change_character_slot_ack_post ) {
+ void (*postHookFunc) (int *fd, bool *ret);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_change_character_slot_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_change_character_slot_ack_post[hIndex].func;
+ postHookFunc(&fd, &ret);
+ }
+ }
+ return;
+}
+void HP_chr_parse_char_move_character(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_parse_char_move_character_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_move_character_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_move_character_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.parse_char_move_character(fd, sd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_move_character_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_move_character_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_move_character_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+int HP_chr_parse_char_unknown_packet(int fd, uint32 ipl) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_parse_char_unknown_packet_pre ) {
+ int (*preHookFunc) (int *fd, uint32 *ipl);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_unknown_packet_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_unknown_packet_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &ipl);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.parse_char_unknown_packet(fd, ipl);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_unknown_packet_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, uint32 *ipl);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_unknown_packet_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_unknown_packet_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &ipl);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_parse_char(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_parse_char_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_parse_char_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.parse_char(fd);
+ }
+ if( HPMHooks.count.HP_chr_parse_char_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_parse_char_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_parse_char_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_broadcast_user_count(int tid, int64 tick, int id, intptr_t data) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_broadcast_user_count_pre ) {
+ int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_broadcast_user_count_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_broadcast_user_count_pre[hIndex].func;
+ retVal___ = preHookFunc(&tid, &tick, &id, &data);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.broadcast_user_count(tid, tick, id, data);
+ }
+ if( HPMHooks.count.HP_chr_broadcast_user_count_post ) {
+ int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_broadcast_user_count_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_broadcast_user_count_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_send_accounts_tologin_sub(DBKey key, DBData *data, va_list ap) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_send_accounts_tologin_sub_pre ) {
+ int (*preHookFunc) (DBKey *key, DBData *data, va_list ap);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_accounts_tologin_sub_pre; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ preHookFunc = HPMHooks.list.HP_chr_send_accounts_tologin_sub_pre[hIndex].func;
+ retVal___ = preHookFunc(&key, data, 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.chr.send_accounts_tologin_sub(key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ if( HPMHooks.count.HP_chr_send_accounts_tologin_sub_post ) {
+ int (*postHookFunc) (int retVal___, DBKey *key, DBData *data, va_list ap);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_accounts_tologin_sub_post; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ postHookFunc = HPMHooks.list.HP_chr_send_accounts_tologin_sub_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_send_accounts_tologin(int tid, int64 tick, int id, intptr_t data) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_send_accounts_tologin_pre ) {
+ int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_accounts_tologin_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_send_accounts_tologin_pre[hIndex].func;
+ retVal___ = preHookFunc(&tid, &tick, &id, &data);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.send_accounts_tologin(tid, tick, id, data);
+ }
+ if( HPMHooks.count.HP_chr_send_accounts_tologin_post ) {
+ int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_send_accounts_tologin_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_send_accounts_tologin_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_check_connect_login_server(int tid, int64 tick, int id, intptr_t data) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_check_connect_login_server_pre ) {
+ int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_check_connect_login_server_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_check_connect_login_server_pre[hIndex].func;
+ retVal___ = preHookFunc(&tid, &tick, &id, &data);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.check_connect_login_server(tid, tick, id, data);
+ }
+ if( HPMHooks.count.HP_chr_check_connect_login_server_post ) {
+ int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_check_connect_login_server_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_check_connect_login_server_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_online_data_cleanup_sub_pre ) {
+ int (*preHookFunc) (DBKey *key, DBData *data, va_list ap);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_online_data_cleanup_sub_pre; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ preHookFunc = HPMHooks.list.HP_chr_online_data_cleanup_sub_pre[hIndex].func;
+ retVal___ = preHookFunc(&key, data, 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.chr.online_data_cleanup_sub(key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ if( HPMHooks.count.HP_chr_online_data_cleanup_sub_post ) {
+ int (*postHookFunc) (int retVal___, DBKey *key, DBData *data, va_list ap);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_online_data_cleanup_sub_post; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ postHookFunc = HPMHooks.list.HP_chr_online_data_cleanup_sub_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_online_data_cleanup_pre ) {
+ int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_online_data_cleanup_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_online_data_cleanup_pre[hIndex].func;
+ retVal___ = preHookFunc(&tid, &tick, &id, &data);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.online_data_cleanup(tid, tick, id, data);
+ }
+ if( HPMHooks.count.HP_chr_online_data_cleanup_post ) {
+ int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_online_data_cleanup_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_online_data_cleanup_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data);
+ }
+ }
+ return retVal___;
+}
+int HP_chr_lan_config_read(const char *lancfgName) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_lan_config_read_pre ) {
+ int (*preHookFunc) (const char *lancfgName);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_lan_config_read_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_lan_config_read_pre[hIndex].func;
+ retVal___ = preHookFunc(lancfgName);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.lan_config_read(lancfgName);
+ }
+ if( HPMHooks.count.HP_chr_lan_config_read_post ) {
+ int (*postHookFunc) (int retVal___, const char *lancfgName);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_lan_config_read_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_lan_config_read_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, lancfgName);
+ }
+ }
+ return retVal___;
+}
+void HP_chr_sql_config_read(const char *cfgName) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_sql_config_read_pre ) {
+ void (*preHookFunc) (const char *cfgName);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_sql_config_read_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_sql_config_read_pre[hIndex].func;
+ preHookFunc(cfgName);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.sql_config_read(cfgName);
+ }
+ if( HPMHooks.count.HP_chr_sql_config_read_post ) {
+ void (*postHookFunc) (const char *cfgName);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_sql_config_read_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_sql_config_read_post[hIndex].func;
+ postHookFunc(cfgName);
+ }
+ }
+ return;
+}
+void HP_chr_config_dispatch(char *w1, char *w2) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_chr_config_dispatch_pre ) {
+ void (*preHookFunc) (char *w1, char *w2);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_config_dispatch_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_config_dispatch_pre[hIndex].func;
+ preHookFunc(w1, w2);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.chr.config_dispatch(w1, w2);
+ }
+ if( HPMHooks.count.HP_chr_config_dispatch_post ) {
+ void (*postHookFunc) (char *w1, char *w2);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_config_dispatch_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_config_dispatch_post[hIndex].func;
+ postHookFunc(w1, w2);
+ }
+ }
+ return;
+}
+int HP_chr_config_read(const char *cfgName) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_config_read_pre ) {
+ int (*preHookFunc) (const char *cfgName);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_config_read_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_config_read_pre[hIndex].func;
+ retVal___ = preHookFunc(cfgName);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.config_read(cfgName);
+ }
+ if( HPMHooks.count.HP_chr_config_read_post ) {
+ int (*postHookFunc) (int retVal___, const char *cfgName);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_config_read_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_config_read_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, cfgName);
+ }
+ }
+ return retVal___;
+}
+/* geoip */
+const char* HP_geoip_getcountry(uint32 ipnum) {
+ int hIndex = 0;
+ const char* retVal___ = NULL;
+ if( HPMHooks.count.HP_geoip_getcountry_pre ) {
+ const char* (*preHookFunc) (uint32 *ipnum);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_geoip_getcountry_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_geoip_getcountry_pre[hIndex].func;
+ retVal___ = preHookFunc(&ipnum);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.geoip.getcountry(ipnum);
+ }
+ if( HPMHooks.count.HP_geoip_getcountry_post ) {
+ const char* (*postHookFunc) (const char* retVal___, uint32 *ipnum);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_geoip_getcountry_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_geoip_getcountry_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &ipnum);
+ }
+ }
+ return retVal___;
+}
+void HP_geoip_final(bool shutdown) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_geoip_final_pre ) {
+ void (*preHookFunc) (bool *shutdown);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_geoip_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_geoip_final_pre[hIndex].func;
+ preHookFunc(&shutdown);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.geoip.final(shutdown);
+ }
+ if( HPMHooks.count.HP_geoip_final_post ) {
+ void (*postHookFunc) (bool *shutdown);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_geoip_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_geoip_final_post[hIndex].func;
+ postHookFunc(&shutdown);
+ }
+ }
+ return;
+}
+void HP_geoip_init(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_geoip_init_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_geoip_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_geoip_init_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.geoip.init();
+ }
+ if( HPMHooks.count.HP_geoip_init_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_geoip_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_geoip_init_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+/* inter_auction */
+int HP_inter_auction_count(int char_id, bool buy) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_auction_count_pre ) {
+ int (*preHookFunc) (int *char_id, bool *buy);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_count_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_auction_count_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, &buy);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_auction.count(char_id, buy);
+ }
+ if( HPMHooks.count.HP_inter_auction_count_post ) {
+ int (*postHookFunc) (int retVal___, int *char_id, bool *buy);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_count_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_auction_count_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, &buy);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_auction_save(struct auction_data *auction) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_auction_save_pre ) {
+ void (*preHookFunc) (struct auction_data *auction);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_save_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_auction_save_pre[hIndex].func;
+ preHookFunc(auction);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_auction.save(auction);
+ }
+ if( HPMHooks.count.HP_inter_auction_save_post ) {
+ void (*postHookFunc) (struct auction_data *auction);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_save_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_auction_save_post[hIndex].func;
+ postHookFunc(auction);
+ }
+ }
+ return;
+}
+unsigned int HP_inter_auction_create(struct auction_data *auction) {
+ int hIndex = 0;
+ unsigned int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_auction_create_pre ) {
+ unsigned int (*preHookFunc) (struct auction_data *auction);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_create_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_auction_create_pre[hIndex].func;
+ retVal___ = preHookFunc(auction);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_auction.create(auction);
+ }
+ if( HPMHooks.count.HP_inter_auction_create_post ) {
+ unsigned int (*postHookFunc) (unsigned int retVal___, struct auction_data *auction);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_create_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_auction_create_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, auction);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_auction_end_timer(int tid, int64 tick, int id, intptr_t data) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_auction_end_timer_pre ) {
+ int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_end_timer_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_auction_end_timer_pre[hIndex].func;
+ retVal___ = preHookFunc(&tid, &tick, &id, &data);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_auction.end_timer(tid, tick, id, data);
+ }
+ if( HPMHooks.count.HP_inter_auction_end_timer_post ) {
+ int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_end_timer_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_auction_end_timer_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_auction_delete_(struct auction_data *auction) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_auction_delete__pre ) {
+ void (*preHookFunc) (struct auction_data *auction);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_delete__pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_auction_delete__pre[hIndex].func;
+ preHookFunc(auction);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_auction.delete_(auction);
+ }
+ if( HPMHooks.count.HP_inter_auction_delete__post ) {
+ void (*postHookFunc) (struct auction_data *auction);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_delete__post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_auction_delete__post[hIndex].func;
+ postHookFunc(auction);
+ }
+ }
+ return;
+}
+void HP_inter_auction_fromsql(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_auction_fromsql_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_fromsql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_auction_fromsql_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_auction.fromsql();
+ }
+ if( HPMHooks.count.HP_inter_auction_fromsql_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_fromsql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_auction_fromsql_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+int HP_inter_auction_parse_frommap(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_auction_parse_frommap_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_parse_frommap_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_auction_parse_frommap_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_auction.parse_frommap(fd);
+ }
+ if( HPMHooks.count.HP_inter_auction_parse_frommap_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_parse_frommap_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_auction_parse_frommap_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_auction_sql_init(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_auction_sql_init_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_sql_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_auction_sql_init_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_auction.sql_init();
+ }
+ if( HPMHooks.count.HP_inter_auction_sql_init_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_sql_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_auction_sql_init_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_auction_sql_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_auction_sql_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_sql_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_auction_sql_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_auction.sql_final();
+ }
+ if( HPMHooks.count.HP_inter_auction_sql_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_auction_sql_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_auction_sql_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+/* inter_elemental */
+void HP_inter_elemental_sql_init(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_elemental_sql_init_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_elemental_sql_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_elemental_sql_init_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_elemental.sql_init();
+ }
+ if( HPMHooks.count.HP_inter_elemental_sql_init_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_elemental_sql_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_elemental_sql_init_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_inter_elemental_sql_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_elemental_sql_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_elemental_sql_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_elemental_sql_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_elemental.sql_final();
+ }
+ if( HPMHooks.count.HP_inter_elemental_sql_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_elemental_sql_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_elemental_sql_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+int HP_inter_elemental_parse_frommap(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_elemental_parse_frommap_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_elemental_parse_frommap_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_elemental_parse_frommap_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_elemental.parse_frommap(fd);
+ }
+ if( HPMHooks.count.HP_inter_elemental_parse_frommap_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_elemental_parse_frommap_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_elemental_parse_frommap_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+/* inter_guild */
+int HP_inter_guild_save_timer(int tid, int64 tick, int id, intptr_t data) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_save_timer_pre ) {
+ int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_save_timer_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_save_timer_pre[hIndex].func;
+ retVal___ = preHookFunc(&tid, &tick, &id, &data);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.save_timer(tid, tick, id, data);
+ }
+ if( HPMHooks.count.HP_inter_guild_save_timer_post ) {
+ int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_save_timer_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_save_timer_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_removemember_tosql(int account_id, int char_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_removemember_tosql_pre ) {
+ int (*preHookFunc) (int *account_id, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_removemember_tosql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_removemember_tosql_pre[hIndex].func;
+ retVal___ = preHookFunc(&account_id, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.removemember_tosql(account_id, char_id);
+ }
+ if( HPMHooks.count.HP_inter_guild_removemember_tosql_post ) {
+ int (*postHookFunc) (int retVal___, int *account_id, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_removemember_tosql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_removemember_tosql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &account_id, &char_id);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_tosql(struct guild *g, int flag) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_tosql_pre ) {
+ int (*preHookFunc) (struct guild *g, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_tosql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_tosql_pre[hIndex].func;
+ retVal___ = preHookFunc(g, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.tosql(g, flag);
+ }
+ if( HPMHooks.count.HP_inter_guild_tosql_post ) {
+ int (*postHookFunc) (int retVal___, struct guild *g, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_tosql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_tosql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, g, &flag);
+ }
+ }
+ return retVal___;
+}
+struct guild* HP_inter_guild_fromsql(int guild_id) {
+ int hIndex = 0;
+ struct guild* retVal___ = NULL;
+ if( HPMHooks.count.HP_inter_guild_fromsql_pre ) {
+ struct guild* (*preHookFunc) (int *guild_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_fromsql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_fromsql_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.fromsql(guild_id);
+ }
+ if( HPMHooks.count.HP_inter_guild_fromsql_post ) {
+ struct guild* (*postHookFunc) (struct guild* retVal___, int *guild_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_fromsql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_fromsql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_castle_tosql(struct guild_castle *gc) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_castle_tosql_pre ) {
+ int (*preHookFunc) (struct guild_castle *gc);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_castle_tosql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_castle_tosql_pre[hIndex].func;
+ retVal___ = preHookFunc(gc);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.castle_tosql(gc);
+ }
+ if( HPMHooks.count.HP_inter_guild_castle_tosql_post ) {
+ int (*postHookFunc) (int retVal___, struct guild_castle *gc);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_castle_tosql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_castle_tosql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, gc);
+ }
+ }
+ return retVal___;
+}
+struct guild_castle* HP_inter_guild_castle_fromsql(int castle_id) {
+ int hIndex = 0;
+ struct guild_castle* retVal___ = NULL;
+ if( HPMHooks.count.HP_inter_guild_castle_fromsql_pre ) {
+ struct guild_castle* (*preHookFunc) (int *castle_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_castle_fromsql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_castle_fromsql_pre[hIndex].func;
+ retVal___ = preHookFunc(&castle_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.castle_fromsql(castle_id);
+ }
+ if( HPMHooks.count.HP_inter_guild_castle_fromsql_post ) {
+ struct guild_castle* (*postHookFunc) (struct guild_castle* retVal___, int *castle_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_castle_fromsql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_castle_fromsql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &castle_id);
+ }
+ }
+ return retVal___;
+}
+bool HP_inter_guild_exp_parse_row(char *split[], int column, int current) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_inter_guild_exp_parse_row_pre ) {
+ bool (*preHookFunc) (char *split[], int *column, int *current);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_exp_parse_row_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_exp_parse_row_pre[hIndex].func;
+ retVal___ = preHookFunc(split, &column, &current);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.exp_parse_row(split, column, current);
+ }
+ if( HPMHooks.count.HP_inter_guild_exp_parse_row_post ) {
+ bool (*postHookFunc) (bool retVal___, char *split[], int *column, int *current);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_exp_parse_row_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_exp_parse_row_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, split, &column, &current);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_CharOnline(int char_id, int guild_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_CharOnline_pre ) {
+ int (*preHookFunc) (int *char_id, int *guild_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_CharOnline_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_CharOnline_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, &guild_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.CharOnline(char_id, guild_id);
+ }
+ if( HPMHooks.count.HP_inter_guild_CharOnline_post ) {
+ int (*postHookFunc) (int retVal___, int *char_id, int *guild_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_CharOnline_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_CharOnline_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, &guild_id);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_CharOffline(int char_id, int guild_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_CharOffline_pre ) {
+ int (*preHookFunc) (int *char_id, int *guild_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_CharOffline_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_CharOffline_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, &guild_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.CharOffline(char_id, guild_id);
+ }
+ if( HPMHooks.count.HP_inter_guild_CharOffline_post ) {
+ int (*postHookFunc) (int retVal___, int *char_id, int *guild_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_CharOffline_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_CharOffline_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, &guild_id);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_sql_init(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_sql_init_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_sql_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_sql_init_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.sql_init();
+ }
+ if( HPMHooks.count.HP_inter_guild_sql_init_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_sql_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_sql_init_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_db_final(DBKey key, DBData *data, va_list ap) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_db_final_pre ) {
+ int (*preHookFunc) (DBKey *key, DBData *data, va_list ap);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_db_final_pre; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ preHookFunc = HPMHooks.list.HP_inter_guild_db_final_pre[hIndex].func;
+ retVal___ = preHookFunc(&key, data, 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.inter_guild.db_final(key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ if( HPMHooks.count.HP_inter_guild_db_final_post ) {
+ int (*postHookFunc) (int retVal___, DBKey *key, DBData *data, va_list ap);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_db_final_post; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ postHookFunc = HPMHooks.list.HP_inter_guild_db_final_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_guild_sql_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_guild_sql_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_sql_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_sql_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_guild.sql_final();
+ }
+ if( HPMHooks.count.HP_inter_guild_sql_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_sql_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_sql_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+int HP_inter_guild_search_guildname(char *str) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_search_guildname_pre ) {
+ int (*preHookFunc) (char *str);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_search_guildname_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_search_guildname_pre[hIndex].func;
+ retVal___ = preHookFunc(str);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.search_guildname(str);
+ }
+ if( HPMHooks.count.HP_inter_guild_search_guildname_post ) {
+ int (*postHookFunc) (int retVal___, char *str);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_search_guildname_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_search_guildname_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, str);
+ }
+ }
+ return retVal___;
+}
+bool HP_inter_guild_check_empty(struct guild *g) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_inter_guild_check_empty_pre ) {
+ bool (*preHookFunc) (struct guild *g);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_check_empty_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_check_empty_pre[hIndex].func;
+ retVal___ = preHookFunc(g);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.check_empty(g);
+ }
+ if( HPMHooks.count.HP_inter_guild_check_empty_post ) {
+ bool (*postHookFunc) (bool retVal___, struct guild *g);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_check_empty_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_check_empty_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, g);
+ }
+ }
+ return retVal___;
+}
+unsigned int HP_inter_guild_nextexp(int level) {
+ int hIndex = 0;
+ unsigned int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_nextexp_pre ) {
+ unsigned int (*preHookFunc) (int *level);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_nextexp_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_nextexp_pre[hIndex].func;
+ retVal___ = preHookFunc(&level);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.nextexp(level);
+ }
+ if( HPMHooks.count.HP_inter_guild_nextexp_post ) {
+ unsigned int (*postHookFunc) (unsigned int retVal___, int *level);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_nextexp_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_nextexp_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &level);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_checkskill(struct guild *g, int id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_checkskill_pre ) {
+ int (*preHookFunc) (struct guild *g, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_checkskill_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_checkskill_pre[hIndex].func;
+ retVal___ = preHookFunc(g, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.checkskill(g, id);
+ }
+ if( HPMHooks.count.HP_inter_guild_checkskill_post ) {
+ int (*postHookFunc) (int retVal___, struct guild *g, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_checkskill_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_checkskill_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, g, &id);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_calcinfo(struct guild *g) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_calcinfo_pre ) {
+ int (*preHookFunc) (struct guild *g);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_calcinfo_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_calcinfo_pre[hIndex].func;
+ retVal___ = preHookFunc(g);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.calcinfo(g);
+ }
+ if( HPMHooks.count.HP_inter_guild_calcinfo_post ) {
+ int (*postHookFunc) (int retVal___, struct guild *g);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_calcinfo_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_calcinfo_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, g);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_sex_changed(int guild_id, int account_id, int char_id, short gender) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_sex_changed_pre ) {
+ int (*preHookFunc) (int *guild_id, int *account_id, int *char_id, short *gender);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_sex_changed_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_sex_changed_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id, &account_id, &char_id, &gender);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.sex_changed(guild_id, account_id, char_id, gender);
+ }
+ if( HPMHooks.count.HP_inter_guild_sex_changed_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id, int *account_id, int *char_id, short *gender);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_sex_changed_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_sex_changed_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id, &account_id, &char_id, &gender);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_charname_changed(int guild_id, int account_id, int char_id, char *name) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_charname_changed_pre ) {
+ int (*preHookFunc) (int *guild_id, int *account_id, int *char_id, char *name);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_charname_changed_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_charname_changed_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id, &account_id, &char_id, name);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.charname_changed(guild_id, account_id, char_id, name);
+ }
+ if( HPMHooks.count.HP_inter_guild_charname_changed_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id, int *account_id, int *char_id, char *name);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_charname_changed_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_charname_changed_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id, &account_id, &char_id, name);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_parse_frommap(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_parse_frommap_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_parse_frommap_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_parse_frommap_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.parse_frommap(fd);
+ }
+ if( HPMHooks.count.HP_inter_guild_parse_frommap_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_parse_frommap_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_parse_frommap_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_leave(int guild_id, int account_id, int char_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_leave_pre ) {
+ int (*preHookFunc) (int *guild_id, int *account_id, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_leave_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_leave_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id, &account_id, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.leave(guild_id, account_id, char_id);
+ }
+ if( HPMHooks.count.HP_inter_guild_leave_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id, int *account_id, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_leave_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_leave_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id, &account_id, &char_id);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_guild_broken(int guild_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_guild_broken_pre ) {
+ int (*preHookFunc) (int *guild_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_broken_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_guild_broken_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_guild.broken(guild_id);
+ }
+ if( HPMHooks.count.HP_inter_guild_broken_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_broken_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_guild_broken_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id);
+ }
+ }
+ return retVal___;
+}
+/* inter_homunculus */
+int HP_inter_homunculus_sql_init(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_homunculus_sql_init_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_homunculus_sql_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_homunculus_sql_init_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_homunculus.sql_init();
+ }
+ if( HPMHooks.count.HP_inter_homunculus_sql_init_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_homunculus_sql_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_homunculus_sql_init_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_homunculus_sql_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_homunculus_sql_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_homunculus_sql_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_homunculus_sql_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_homunculus.sql_final();
+ }
+ if( HPMHooks.count.HP_inter_homunculus_sql_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_homunculus_sql_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_homunculus_sql_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+int HP_inter_homunculus_parse_frommap(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_homunculus_parse_frommap_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_homunculus_parse_frommap_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_homunculus_parse_frommap_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_homunculus.parse_frommap(fd);
+ }
+ if( HPMHooks.count.HP_inter_homunculus_parse_frommap_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_homunculus_parse_frommap_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_homunculus_parse_frommap_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+/* inter */
+const char* HP_inter_msg_txt(int msg_number) {
+ int hIndex = 0;
+ const char* retVal___ = NULL;
+ if( HPMHooks.count.HP_inter_msg_txt_pre ) {
+ const char* (*preHookFunc) (int *msg_number);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_msg_txt_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_msg_txt_pre[hIndex].func;
+ retVal___ = preHookFunc(&msg_number);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter.msg_txt(msg_number);
+ }
+ if( HPMHooks.count.HP_inter_msg_txt_post ) {
+ const char* (*postHookFunc) (const char* retVal___, int *msg_number);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_msg_txt_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_msg_txt_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &msg_number);
+ }
+ }
+ return retVal___;
+}
+bool HP_inter_msg_config_read(const char *cfg_name, bool allow_override) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_inter_msg_config_read_pre ) {
+ bool (*preHookFunc) (const char *cfg_name, bool *allow_override);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_msg_config_read_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_msg_config_read_pre[hIndex].func;
+ retVal___ = preHookFunc(cfg_name, &allow_override);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter.msg_config_read(cfg_name, allow_override);
+ }
+ if( HPMHooks.count.HP_inter_msg_config_read_post ) {
+ bool (*postHookFunc) (bool retVal___, const char *cfg_name, bool *allow_override);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_msg_config_read_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_msg_config_read_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, cfg_name, &allow_override);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_do_final_msg(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_do_final_msg_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_do_final_msg_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_do_final_msg_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter.do_final_msg();
+ }
+ if( HPMHooks.count.HP_inter_do_final_msg_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_do_final_msg_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_do_final_msg_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+const char* HP_inter_job_name(int class_) {
+ int hIndex = 0;
+ const char* retVal___ = NULL;
+ if( HPMHooks.count.HP_inter_job_name_pre ) {
+ const char* (*preHookFunc) (int *class_);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_job_name_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_job_name_pre[hIndex].func;
+ retVal___ = preHookFunc(&class_);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter.job_name(class_);
+ }
+ if( HPMHooks.count.HP_inter_job_name_post ) {
+ const char* (*postHookFunc) (const char* retVal___, int *class_);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_job_name_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_job_name_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &class_);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_vmsg_to_fd(int fd, int u_fd, int aid, char *msg, va_list ap) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_vmsg_to_fd_pre ) {
+ void (*preHookFunc) (int *fd, int *u_fd, int *aid, char *msg, va_list ap);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_vmsg_to_fd_pre; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ preHookFunc = HPMHooks.list.HP_inter_vmsg_to_fd_pre[hIndex].func;
+ preHookFunc(&fd, &u_fd, &aid, msg, ap___copy);
+ va_end(ap___copy);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ HPMHooks.source.inter.vmsg_to_fd(fd, u_fd, aid, msg, ap___copy);
+ va_end(ap___copy);
+ }
+ if( HPMHooks.count.HP_inter_vmsg_to_fd_post ) {
+ void (*postHookFunc) (int *fd, int *u_fd, int *aid, char *msg, va_list ap);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_vmsg_to_fd_post; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ postHookFunc = HPMHooks.list.HP_inter_vmsg_to_fd_post[hIndex].func;
+ postHookFunc(&fd, &u_fd, &aid, msg, ap___copy);
+ va_end(ap___copy);
+ }
+ }
+ return;
+}
+void HP_inter_savereg(int account_id, int char_id, const char *key, unsigned int index, intptr_t val, bool is_string) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_savereg_pre ) {
+ void (*preHookFunc) (int *account_id, int *char_id, const char *key, unsigned int *index, intptr_t *val, bool *is_string);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_savereg_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_savereg_pre[hIndex].func;
+ preHookFunc(&account_id, &char_id, key, &index, &val, &is_string);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter.savereg(account_id, char_id, key, index, val, is_string);
+ }
+ if( HPMHooks.count.HP_inter_savereg_post ) {
+ void (*postHookFunc) (int *account_id, int *char_id, const char *key, unsigned int *index, intptr_t *val, bool *is_string);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_savereg_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_savereg_post[hIndex].func;
+ postHookFunc(&account_id, &char_id, key, &index, &val, &is_string);
+ }
+ }
+ return;
+}
+int HP_inter_accreg_fromsql(int account_id, int char_id, int fd, int type) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_accreg_fromsql_pre ) {
+ int (*preHookFunc) (int *account_id, int *char_id, int *fd, int *type);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_accreg_fromsql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_accreg_fromsql_pre[hIndex].func;
+ retVal___ = preHookFunc(&account_id, &char_id, &fd, &type);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter.accreg_fromsql(account_id, char_id, fd, type);
+ }
+ if( HPMHooks.count.HP_inter_accreg_fromsql_post ) {
+ int (*postHookFunc) (int retVal___, int *account_id, int *char_id, int *fd, int *type);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_accreg_fromsql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_accreg_fromsql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &account_id, &char_id, &fd, &type);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_config_read(const char *cfgName) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_config_read_pre ) {
+ int (*preHookFunc) (const char *cfgName);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_config_read_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_config_read_pre[hIndex].func;
+ retVal___ = preHookFunc(cfgName);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter.config_read(cfgName);
+ }
+ if( HPMHooks.count.HP_inter_config_read_post ) {
+ int (*postHookFunc) (int retVal___, const char *cfgName);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_config_read_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_config_read_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, cfgName);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_vlog(char *fmt, va_list ap) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_vlog_pre ) {
+ int (*preHookFunc) (char *fmt, va_list ap);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_vlog_pre; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ preHookFunc = HPMHooks.list.HP_inter_vlog_pre[hIndex].func;
+ retVal___ = preHookFunc(fmt, 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.inter.vlog(fmt, ap___copy);
+ va_end(ap___copy);
+ }
+ if( HPMHooks.count.HP_inter_vlog_post ) {
+ int (*postHookFunc) (int retVal___, char *fmt, va_list ap);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_vlog_post; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ postHookFunc = HPMHooks.list.HP_inter_vlog_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, fmt, ap___copy);
+ va_end(ap___copy);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_init_sql(const char *file) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_init_sql_pre ) {
+ int (*preHookFunc) (const char *file);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_init_sql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_init_sql_pre[hIndex].func;
+ retVal___ = preHookFunc(file);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter.init_sql(file);
+ }
+ if( HPMHooks.count.HP_inter_init_sql_post ) {
+ int (*postHookFunc) (int retVal___, const char *file);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_init_sql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_init_sql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, file);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_mapif_init(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_mapif_init_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mapif_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mapif_init_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter.mapif_init(fd);
+ }
+ if( HPMHooks.count.HP_inter_mapif_init_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mapif_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mapif_init_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_check_ttl_wisdata_sub_pre ) {
+ int (*preHookFunc) (DBKey *key, DBData *data, va_list ap);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_check_ttl_wisdata_sub_pre; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ preHookFunc = HPMHooks.list.HP_inter_check_ttl_wisdata_sub_pre[hIndex].func;
+ retVal___ = preHookFunc(&key, data, 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.inter.check_ttl_wisdata_sub(key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ if( HPMHooks.count.HP_inter_check_ttl_wisdata_sub_post ) {
+ int (*postHookFunc) (int retVal___, DBKey *key, DBData *data, va_list ap);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_check_ttl_wisdata_sub_post; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ postHookFunc = HPMHooks.list.HP_inter_check_ttl_wisdata_sub_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_check_ttl_wisdata(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_check_ttl_wisdata_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_check_ttl_wisdata_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_check_ttl_wisdata_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter.check_ttl_wisdata();
+ }
+ if( HPMHooks.count.HP_inter_check_ttl_wisdata_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_check_ttl_wisdata_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_check_ttl_wisdata_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_check_length(int fd, int length) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_check_length_pre ) {
+ int (*preHookFunc) (int *fd, int *length);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_check_length_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_check_length_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &length);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter.check_length(fd, length);
+ }
+ if( HPMHooks.count.HP_inter_check_length_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *length);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_check_length_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_check_length_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &length);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_parse_frommap(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_parse_frommap_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_parse_frommap_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_parse_frommap_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter.parse_frommap(fd);
+ }
+ if( HPMHooks.count.HP_inter_parse_frommap_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_parse_frommap_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_parse_frommap_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter.final();
+ }
+ if( HPMHooks.count.HP_inter_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+/* inter_mail */
+int HP_inter_mail_sql_init(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_mail_sql_init_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_sql_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mail_sql_init_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_mail.sql_init();
+ }
+ if( HPMHooks.count.HP_inter_mail_sql_init_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_sql_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mail_sql_init_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_mail_sql_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_mail_sql_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_sql_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mail_sql_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_mail.sql_final();
+ }
+ if( HPMHooks.count.HP_inter_mail_sql_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_sql_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mail_sql_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+int HP_inter_mail_parse_frommap(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_mail_parse_frommap_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_parse_frommap_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mail_parse_frommap_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_mail.parse_frommap(fd);
+ }
+ if( HPMHooks.count.HP_inter_mail_parse_frommap_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_parse_frommap_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mail_parse_frommap_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_mail_fromsql(int char_id, struct mail_data *md) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_mail_fromsql_pre ) {
+ int (*preHookFunc) (int *char_id, struct mail_data *md);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_fromsql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mail_fromsql_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, md);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_mail.fromsql(char_id, md);
+ }
+ if( HPMHooks.count.HP_inter_mail_fromsql_post ) {
+ int (*postHookFunc) (int retVal___, int *char_id, struct mail_data *md);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_fromsql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mail_fromsql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, md);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_mail_savemessage(struct mail_message *msg) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_mail_savemessage_pre ) {
+ int (*preHookFunc) (struct mail_message *msg);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_savemessage_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mail_savemessage_pre[hIndex].func;
+ retVal___ = preHookFunc(msg);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_mail.savemessage(msg);
+ }
+ if( HPMHooks.count.HP_inter_mail_savemessage_post ) {
+ int (*postHookFunc) (int retVal___, struct mail_message *msg);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_savemessage_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mail_savemessage_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, msg);
+ }
+ }
+ return retVal___;
+}
+bool HP_inter_mail_loadmessage(int mail_id, struct mail_message *msg) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_inter_mail_loadmessage_pre ) {
+ bool (*preHookFunc) (int *mail_id, struct mail_message *msg);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_loadmessage_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mail_loadmessage_pre[hIndex].func;
+ retVal___ = preHookFunc(&mail_id, msg);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_mail.loadmessage(mail_id, msg);
+ }
+ if( HPMHooks.count.HP_inter_mail_loadmessage_post ) {
+ bool (*postHookFunc) (bool retVal___, int *mail_id, struct mail_message *msg);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_loadmessage_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mail_loadmessage_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &mail_id, msg);
+ }
+ }
+ return retVal___;
+}
+bool HP_inter_mail_DeleteAttach(int mail_id) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_inter_mail_DeleteAttach_pre ) {
+ bool (*preHookFunc) (int *mail_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_DeleteAttach_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mail_DeleteAttach_pre[hIndex].func;
+ retVal___ = preHookFunc(&mail_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_mail.DeleteAttach(mail_id);
+ }
+ if( HPMHooks.count.HP_inter_mail_DeleteAttach_post ) {
+ bool (*postHookFunc) (bool retVal___, int *mail_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_DeleteAttach_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mail_DeleteAttach_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &mail_id);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_mail_sendmail(int send_id, const char *send_name, int dest_id, const char *dest_name, const char *title, const char *body, int zeny, struct item *item) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_mail_sendmail_pre ) {
+ void (*preHookFunc) (int *send_id, const char *send_name, int *dest_id, const char *dest_name, const char *title, const char *body, int *zeny, struct item *item);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_sendmail_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mail_sendmail_pre[hIndex].func;
+ preHookFunc(&send_id, send_name, &dest_id, dest_name, title, body, &zeny, item);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_mail.sendmail(send_id, send_name, dest_id, dest_name, title, body, zeny, item);
+ }
+ if( HPMHooks.count.HP_inter_mail_sendmail_post ) {
+ void (*postHookFunc) (int *send_id, const char *send_name, int *dest_id, const char *dest_name, const char *title, const char *body, int *zeny, struct item *item);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mail_sendmail_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mail_sendmail_post[hIndex].func;
+ postHookFunc(&send_id, send_name, &dest_id, dest_name, title, body, &zeny, item);
+ }
+ }
+ return;
+}
+/* inter_mercenary */
+bool HP_inter_mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_inter_mercenary_owner_fromsql_pre ) {
+ bool (*preHookFunc) (int *char_id, struct mmo_charstatus *status);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mercenary_owner_fromsql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mercenary_owner_fromsql_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, status);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_mercenary.owner_fromsql(char_id, status);
+ }
+ if( HPMHooks.count.HP_inter_mercenary_owner_fromsql_post ) {
+ bool (*postHookFunc) (bool retVal___, int *char_id, struct mmo_charstatus *status);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mercenary_owner_fromsql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mercenary_owner_fromsql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, status);
+ }
+ }
+ return retVal___;
+}
+bool HP_inter_mercenary_owner_tosql(int char_id, struct mmo_charstatus *status) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_inter_mercenary_owner_tosql_pre ) {
+ bool (*preHookFunc) (int *char_id, struct mmo_charstatus *status);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mercenary_owner_tosql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mercenary_owner_tosql_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, status);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_mercenary.owner_tosql(char_id, status);
+ }
+ if( HPMHooks.count.HP_inter_mercenary_owner_tosql_post ) {
+ bool (*postHookFunc) (bool retVal___, int *char_id, struct mmo_charstatus *status);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mercenary_owner_tosql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mercenary_owner_tosql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, status);
+ }
+ }
+ return retVal___;
+}
+bool HP_inter_mercenary_owner_delete(int char_id) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_inter_mercenary_owner_delete_pre ) {
+ bool (*preHookFunc) (int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mercenary_owner_delete_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mercenary_owner_delete_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_mercenary.owner_delete(char_id);
+ }
+ if( HPMHooks.count.HP_inter_mercenary_owner_delete_post ) {
+ bool (*postHookFunc) (bool retVal___, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mercenary_owner_delete_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mercenary_owner_delete_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_mercenary_sql_init(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_mercenary_sql_init_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mercenary_sql_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mercenary_sql_init_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_mercenary.sql_init();
+ }
+ if( HPMHooks.count.HP_inter_mercenary_sql_init_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mercenary_sql_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mercenary_sql_init_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_mercenary_sql_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_mercenary_sql_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mercenary_sql_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mercenary_sql_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_mercenary.sql_final();
+ }
+ if( HPMHooks.count.HP_inter_mercenary_sql_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mercenary_sql_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mercenary_sql_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+int HP_inter_mercenary_parse_frommap(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_mercenary_parse_frommap_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mercenary_parse_frommap_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_mercenary_parse_frommap_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_mercenary.parse_frommap(fd);
+ }
+ if( HPMHooks.count.HP_inter_mercenary_parse_frommap_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_mercenary_parse_frommap_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_mercenary_parse_frommap_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+/* inter_party */
+int HP_inter_party_check_lv(struct party_data *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_party_check_lv_pre ) {
+ int (*preHookFunc) (struct party_data *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_check_lv_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_party_check_lv_pre[hIndex].func;
+ retVal___ = preHookFunc(p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_party.check_lv(p);
+ }
+ if( HPMHooks.count.HP_inter_party_check_lv_post ) {
+ int (*postHookFunc) (int retVal___, struct party_data *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_check_lv_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_party_check_lv_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, p);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_party_calc_state(struct party_data *p) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_party_calc_state_pre ) {
+ void (*preHookFunc) (struct party_data *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_calc_state_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_party_calc_state_pre[hIndex].func;
+ preHookFunc(p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_party.calc_state(p);
+ }
+ if( HPMHooks.count.HP_inter_party_calc_state_post ) {
+ void (*postHookFunc) (struct party_data *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_calc_state_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_party_calc_state_post[hIndex].func;
+ postHookFunc(p);
+ }
+ }
+ return;
+}
+int HP_inter_party_tosql(struct party *p, int flag, int index) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_party_tosql_pre ) {
+ int (*preHookFunc) (struct party *p, int *flag, int *index);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_tosql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_party_tosql_pre[hIndex].func;
+ retVal___ = preHookFunc(p, &flag, &index);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_party.tosql(p, flag, index);
+ }
+ if( HPMHooks.count.HP_inter_party_tosql_post ) {
+ int (*postHookFunc) (int retVal___, struct party *p, int *flag, int *index);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_tosql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_party_tosql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, p, &flag, &index);
+ }
+ }
+ return retVal___;
+}
+struct party_data* HP_inter_party_fromsql(int party_id) {
+ int hIndex = 0;
+ struct party_data* retVal___ = NULL;
+ if( HPMHooks.count.HP_inter_party_fromsql_pre ) {
+ struct party_data* (*preHookFunc) (int *party_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_fromsql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_party_fromsql_pre[hIndex].func;
+ retVal___ = preHookFunc(&party_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_party.fromsql(party_id);
+ }
+ if( HPMHooks.count.HP_inter_party_fromsql_post ) {
+ struct party_data* (*postHookFunc) (struct party_data* retVal___, int *party_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_fromsql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_party_fromsql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &party_id);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_party_sql_init(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_party_sql_init_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_sql_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_party_sql_init_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_party.sql_init();
+ }
+ if( HPMHooks.count.HP_inter_party_sql_init_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_sql_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_party_sql_init_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_party_sql_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_party_sql_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_sql_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_party_sql_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_party.sql_final();
+ }
+ if( HPMHooks.count.HP_inter_party_sql_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_sql_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_party_sql_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+struct party_data* HP_inter_party_search_partyname(const char *str) {
+ int hIndex = 0;
+ struct party_data* retVal___ = NULL;
+ if( HPMHooks.count.HP_inter_party_search_partyname_pre ) {
+ struct party_data* (*preHookFunc) (const char *str);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_search_partyname_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_party_search_partyname_pre[hIndex].func;
+ retVal___ = preHookFunc(str);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_party.search_partyname(str);
+ }
+ if( HPMHooks.count.HP_inter_party_search_partyname_post ) {
+ struct party_data* (*postHookFunc) (struct party_data* retVal___, const char *str);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_search_partyname_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_party_search_partyname_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, str);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_party_check_exp_share(struct party_data *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_party_check_exp_share_pre ) {
+ int (*preHookFunc) (struct party_data *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_check_exp_share_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_party_check_exp_share_pre[hIndex].func;
+ retVal___ = preHookFunc(p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_party.check_exp_share(p);
+ }
+ if( HPMHooks.count.HP_inter_party_check_exp_share_post ) {
+ int (*postHookFunc) (int retVal___, struct party_data *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_check_exp_share_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_party_check_exp_share_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, p);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_party_check_empty(struct party_data *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_party_check_empty_pre ) {
+ int (*preHookFunc) (struct party_data *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_check_empty_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_party_check_empty_pre[hIndex].func;
+ retVal___ = preHookFunc(p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_party.check_empty(p);
+ }
+ if( HPMHooks.count.HP_inter_party_check_empty_post ) {
+ int (*postHookFunc) (int retVal___, struct party_data *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_check_empty_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_party_check_empty_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, p);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_party_parse_frommap(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_party_parse_frommap_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_parse_frommap_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_party_parse_frommap_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_party.parse_frommap(fd);
+ }
+ if( HPMHooks.count.HP_inter_party_parse_frommap_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_parse_frommap_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_party_parse_frommap_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_party_leave(int party_id, int account_id, int char_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_party_leave_pre ) {
+ int (*preHookFunc) (int *party_id, int *account_id, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_leave_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_party_leave_pre[hIndex].func;
+ retVal___ = preHookFunc(&party_id, &account_id, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_party.leave(party_id, account_id, char_id);
+ }
+ if( HPMHooks.count.HP_inter_party_leave_post ) {
+ int (*postHookFunc) (int retVal___, int *party_id, int *account_id, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_leave_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_party_leave_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &party_id, &account_id, &char_id);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_party_CharOnline(int char_id, int party_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_party_CharOnline_pre ) {
+ int (*preHookFunc) (int *char_id, int *party_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_CharOnline_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_party_CharOnline_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, &party_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_party.CharOnline(char_id, party_id);
+ }
+ if( HPMHooks.count.HP_inter_party_CharOnline_post ) {
+ int (*postHookFunc) (int retVal___, int *char_id, int *party_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_CharOnline_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_party_CharOnline_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, &party_id);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_party_CharOffline(int char_id, int party_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_party_CharOffline_pre ) {
+ int (*preHookFunc) (int *char_id, int *party_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_CharOffline_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_party_CharOffline_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, &party_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_party.CharOffline(char_id, party_id);
+ }
+ if( HPMHooks.count.HP_inter_party_CharOffline_post ) {
+ int (*postHookFunc) (int retVal___, int *char_id, int *party_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_party_CharOffline_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_party_CharOffline_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, &party_id);
+ }
+ }
+ return retVal___;
+}
+/* inter_pet */
+int HP_inter_pet_tosql(int pet_id, struct s_pet *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_pet_tosql_pre ) {
+ int (*preHookFunc) (int *pet_id, struct s_pet *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_pet_tosql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_pet_tosql_pre[hIndex].func;
+ retVal___ = preHookFunc(&pet_id, p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_pet.tosql(pet_id, p);
+ }
+ if( HPMHooks.count.HP_inter_pet_tosql_post ) {
+ int (*postHookFunc) (int retVal___, int *pet_id, struct s_pet *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_pet_tosql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_pet_tosql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &pet_id, p);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_pet_fromsql(int pet_id, struct s_pet *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_pet_fromsql_pre ) {
+ int (*preHookFunc) (int *pet_id, struct s_pet *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_pet_fromsql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_pet_fromsql_pre[hIndex].func;
+ retVal___ = preHookFunc(&pet_id, p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_pet.fromsql(pet_id, p);
+ }
+ if( HPMHooks.count.HP_inter_pet_fromsql_post ) {
+ int (*postHookFunc) (int retVal___, int *pet_id, struct s_pet *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_pet_fromsql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_pet_fromsql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &pet_id, p);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_pet_sql_init(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_pet_sql_init_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_pet_sql_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_pet_sql_init_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_pet.sql_init();
+ }
+ if( HPMHooks.count.HP_inter_pet_sql_init_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_pet_sql_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_pet_sql_init_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_pet_sql_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_pet_sql_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_pet_sql_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_pet_sql_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_pet.sql_final();
+ }
+ if( HPMHooks.count.HP_inter_pet_sql_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_pet_sql_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_pet_sql_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+int HP_inter_pet_delete_(int pet_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_pet_delete__pre ) {
+ int (*preHookFunc) (int *pet_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_pet_delete__pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_pet_delete__pre[hIndex].func;
+ retVal___ = preHookFunc(&pet_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_pet.delete_(pet_id);
+ }
+ if( HPMHooks.count.HP_inter_pet_delete__post ) {
+ int (*postHookFunc) (int retVal___, int *pet_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_pet_delete__post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_pet_delete__post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &pet_id);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_pet_parse_frommap(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_pet_parse_frommap_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_pet_parse_frommap_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_pet_parse_frommap_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_pet.parse_frommap(fd);
+ }
+ if( HPMHooks.count.HP_inter_pet_parse_frommap_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_pet_parse_frommap_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_pet_parse_frommap_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+/* inter_quest */
+int HP_inter_quest_parse_frommap(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_quest_parse_frommap_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_quest_parse_frommap_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_quest_parse_frommap_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_quest.parse_frommap(fd);
+ }
+ if( HPMHooks.count.HP_inter_quest_parse_frommap_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_quest_parse_frommap_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_quest_parse_frommap_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+/* inter_storage */
+int HP_inter_storage_tosql(int account_id, struct storage_data *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_storage_tosql_pre ) {
+ int (*preHookFunc) (int *account_id, struct storage_data *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_tosql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_storage_tosql_pre[hIndex].func;
+ retVal___ = preHookFunc(&account_id, p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_storage.tosql(account_id, p);
+ }
+ if( HPMHooks.count.HP_inter_storage_tosql_post ) {
+ int (*postHookFunc) (int retVal___, int *account_id, struct storage_data *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_tosql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_storage_tosql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &account_id, p);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_storage_fromsql(int account_id, struct storage_data *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_storage_fromsql_pre ) {
+ int (*preHookFunc) (int *account_id, struct storage_data *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_fromsql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_storage_fromsql_pre[hIndex].func;
+ retVal___ = preHookFunc(&account_id, p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_storage.fromsql(account_id, p);
+ }
+ if( HPMHooks.count.HP_inter_storage_fromsql_post ) {
+ int (*postHookFunc) (int retVal___, int *account_id, struct storage_data *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_fromsql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_storage_fromsql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &account_id, p);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_storage_guild_storage_tosql(int guild_id, struct guild_storage *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_storage_guild_storage_tosql_pre ) {
+ int (*preHookFunc) (int *guild_id, struct guild_storage *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_guild_storage_tosql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_storage_guild_storage_tosql_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id, p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_storage.guild_storage_tosql(guild_id, p);
+ }
+ if( HPMHooks.count.HP_inter_storage_guild_storage_tosql_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id, struct guild_storage *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_guild_storage_tosql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_storage_guild_storage_tosql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id, p);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_storage_guild_storage_fromsql(int guild_id, struct guild_storage *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_storage_guild_storage_fromsql_pre ) {
+ int (*preHookFunc) (int *guild_id, struct guild_storage *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_guild_storage_fromsql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_storage_guild_storage_fromsql_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id, p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_storage.guild_storage_fromsql(guild_id, p);
+ }
+ if( HPMHooks.count.HP_inter_storage_guild_storage_fromsql_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id, struct guild_storage *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_guild_storage_fromsql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_storage_guild_storage_fromsql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id, p);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_storage_sql_init(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_storage_sql_init_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_sql_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_storage_sql_init_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_storage.sql_init();
+ }
+ if( HPMHooks.count.HP_inter_storage_sql_init_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_sql_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_storage_sql_init_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_inter_storage_sql_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_inter_storage_sql_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_sql_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_storage_sql_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.inter_storage.sql_final();
+ }
+ if( HPMHooks.count.HP_inter_storage_sql_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_sql_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_storage_sql_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+int HP_inter_storage_delete_(int account_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_storage_delete__pre ) {
+ int (*preHookFunc) (int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_delete__pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_storage_delete__pre[hIndex].func;
+ retVal___ = preHookFunc(&account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_storage.delete_(account_id);
+ }
+ if( HPMHooks.count.HP_inter_storage_delete__post ) {
+ int (*postHookFunc) (int retVal___, int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_delete__post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_storage_delete__post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &account_id);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_storage_guild_storage_delete(int guild_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_storage_guild_storage_delete_pre ) {
+ int (*preHookFunc) (int *guild_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_guild_storage_delete_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_storage_guild_storage_delete_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_storage.guild_storage_delete(guild_id);
+ }
+ if( HPMHooks.count.HP_inter_storage_guild_storage_delete_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_guild_storage_delete_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_storage_guild_storage_delete_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id);
+ }
+ }
+ return retVal___;
+}
+int HP_inter_storage_parse_frommap(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_inter_storage_parse_frommap_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_parse_frommap_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_inter_storage_parse_frommap_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.inter_storage.parse_frommap(fd);
+ }
+ if( HPMHooks.count.HP_inter_storage_parse_frommap_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_inter_storage_parse_frommap_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_inter_storage_parse_frommap_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+/* loginif */
+void HP_loginif_init(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_loginif_init_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_loginif_init_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.loginif.init();
+ }
+ if( HPMHooks.count.HP_loginif_init_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_loginif_init_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_loginif_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_loginif_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_loginif_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.loginif.final();
+ }
+ if( HPMHooks.count.HP_loginif_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_loginif_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_loginif_reset(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_loginif_reset_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_reset_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_loginif_reset_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.loginif.reset();
+ }
+ if( HPMHooks.count.HP_loginif_reset_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_reset_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_loginif_reset_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_loginif_check_shutdown(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_loginif_check_shutdown_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_check_shutdown_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_loginif_check_shutdown_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.loginif.check_shutdown();
+ }
+ if( HPMHooks.count.HP_loginif_check_shutdown_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_check_shutdown_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_loginif_check_shutdown_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_loginif_on_disconnect(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_loginif_on_disconnect_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_on_disconnect_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_loginif_on_disconnect_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.loginif.on_disconnect();
+ }
+ if( HPMHooks.count.HP_loginif_on_disconnect_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_on_disconnect_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_loginif_on_disconnect_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_loginif_on_ready(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_loginif_on_ready_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_on_ready_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_loginif_on_ready_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.loginif.on_ready();
+ }
+ if( HPMHooks.count.HP_loginif_on_ready_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_on_ready_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_loginif_on_ready_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_loginif_block_account(int account_id, int flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_loginif_block_account_pre ) {
+ void (*preHookFunc) (int *account_id, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_block_account_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_loginif_block_account_pre[hIndex].func;
+ preHookFunc(&account_id, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.loginif.block_account(account_id, flag);
+ }
+ if( HPMHooks.count.HP_loginif_block_account_post ) {
+ void (*postHookFunc) (int *account_id, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_block_account_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_loginif_block_account_post[hIndex].func;
+ postHookFunc(&account_id, &flag);
+ }
+ }
+ return;
+}
+void HP_loginif_ban_account(int account_id, short year, short month, short day, short hour, short minute, short second) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_loginif_ban_account_pre ) {
+ void (*preHookFunc) (int *account_id, short *year, short *month, short *day, short *hour, short *minute, short *second);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_ban_account_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_loginif_ban_account_pre[hIndex].func;
+ preHookFunc(&account_id, &year, &month, &day, &hour, &minute, &second);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.loginif.ban_account(account_id, year, month, day, hour, minute, second);
+ }
+ if( HPMHooks.count.HP_loginif_ban_account_post ) {
+ void (*postHookFunc) (int *account_id, short *year, short *month, short *day, short *hour, short *minute, short *second);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_ban_account_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_loginif_ban_account_post[hIndex].func;
+ postHookFunc(&account_id, &year, &month, &day, &hour, &minute, &second);
+ }
+ }
+ return;
+}
+void HP_loginif_unban_account(int account_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_loginif_unban_account_pre ) {
+ void (*preHookFunc) (int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_unban_account_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_loginif_unban_account_pre[hIndex].func;
+ preHookFunc(&account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.loginif.unban_account(account_id);
+ }
+ if( HPMHooks.count.HP_loginif_unban_account_post ) {
+ void (*postHookFunc) (int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_unban_account_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_loginif_unban_account_post[hIndex].func;
+ postHookFunc(&account_id);
+ }
+ }
+ return;
+}
+void HP_loginif_changesex(int account_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_loginif_changesex_pre ) {
+ void (*preHookFunc) (int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_changesex_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_loginif_changesex_pre[hIndex].func;
+ preHookFunc(&account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.loginif.changesex(account_id);
+ }
+ if( HPMHooks.count.HP_loginif_changesex_post ) {
+ void (*postHookFunc) (int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_changesex_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_loginif_changesex_post[hIndex].func;
+ postHookFunc(&account_id);
+ }
+ }
+ return;
+}
+void HP_loginif_auth(int fd, struct char_session_data *sd, uint32 ipl) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_loginif_auth_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd, uint32 *ipl);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_auth_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_loginif_auth_pre[hIndex].func;
+ preHookFunc(&fd, sd, &ipl);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.loginif.auth(fd, sd, ipl);
+ }
+ if( HPMHooks.count.HP_loginif_auth_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd, uint32 *ipl);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_auth_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_loginif_auth_post[hIndex].func;
+ postHookFunc(&fd, sd, &ipl);
+ }
+ }
+ return;
+}
+void HP_loginif_send_users_count(int users) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_loginif_send_users_count_pre ) {
+ void (*preHookFunc) (int *users);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_send_users_count_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_loginif_send_users_count_pre[hIndex].func;
+ preHookFunc(&users);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.loginif.send_users_count(users);
+ }
+ if( HPMHooks.count.HP_loginif_send_users_count_post ) {
+ void (*postHookFunc) (int *users);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_send_users_count_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_loginif_send_users_count_post[hIndex].func;
+ postHookFunc(&users);
+ }
+ }
+ return;
+}
+void HP_loginif_connect_to_server(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_loginif_connect_to_server_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_connect_to_server_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_loginif_connect_to_server_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.loginif.connect_to_server();
+ }
+ if( HPMHooks.count.HP_loginif_connect_to_server_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_loginif_connect_to_server_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_loginif_connect_to_server_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+/* mapif */
+void HP_mapif_ban(int id, unsigned int flag, int status) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_ban_pre ) {
+ void (*preHookFunc) (int *id, unsigned int *flag, int *status);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_ban_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_ban_pre[hIndex].func;
+ preHookFunc(&id, &flag, &status);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.ban(id, flag, status);
+ }
+ if( HPMHooks.count.HP_mapif_ban_post ) {
+ void (*postHookFunc) (int *id, unsigned int *flag, int *status);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_ban_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_ban_post[hIndex].func;
+ postHookFunc(&id, &flag, &status);
+ }
+ }
+ return;
+}
+void HP_mapif_server_init(int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_server_init_pre ) {
+ void (*preHookFunc) (int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_server_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_server_init_pre[hIndex].func;
+ preHookFunc(&id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.server_init(id);
+ }
+ if( HPMHooks.count.HP_mapif_server_init_post ) {
+ void (*postHookFunc) (int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_server_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_server_init_post[hIndex].func;
+ postHookFunc(&id);
+ }
+ }
+ return;
+}
+void HP_mapif_server_destroy(int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_server_destroy_pre ) {
+ void (*preHookFunc) (int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_server_destroy_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_server_destroy_pre[hIndex].func;
+ preHookFunc(&id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.server_destroy(id);
+ }
+ if( HPMHooks.count.HP_mapif_server_destroy_post ) {
+ void (*postHookFunc) (int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_server_destroy_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_server_destroy_post[hIndex].func;
+ postHookFunc(&id);
+ }
+ }
+ return;
+}
+void HP_mapif_server_reset(int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_server_reset_pre ) {
+ void (*preHookFunc) (int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_server_reset_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_server_reset_pre[hIndex].func;
+ preHookFunc(&id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.server_reset(id);
+ }
+ if( HPMHooks.count.HP_mapif_server_reset_post ) {
+ void (*postHookFunc) (int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_server_reset_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_server_reset_post[hIndex].func;
+ postHookFunc(&id);
+ }
+ }
+ return;
+}
+void HP_mapif_on_disconnect(int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_on_disconnect_pre ) {
+ void (*preHookFunc) (int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_on_disconnect_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_on_disconnect_pre[hIndex].func;
+ preHookFunc(&id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.on_disconnect(id);
+ }
+ if( HPMHooks.count.HP_mapif_on_disconnect_post ) {
+ void (*postHookFunc) (int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_on_disconnect_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_on_disconnect_post[hIndex].func;
+ postHookFunc(&id);
+ }
+ }
+ return;
+}
+void HP_mapif_on_parse_accinfo(int account_id, int u_fd, int u_aid, int u_group, int map_fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_on_parse_accinfo_pre ) {
+ void (*preHookFunc) (int *account_id, int *u_fd, int *u_aid, int *u_group, int *map_fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_on_parse_accinfo_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_on_parse_accinfo_pre[hIndex].func;
+ preHookFunc(&account_id, &u_fd, &u_aid, &u_group, &map_fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.on_parse_accinfo(account_id, u_fd, u_aid, u_group, map_fd);
+ }
+ if( HPMHooks.count.HP_mapif_on_parse_accinfo_post ) {
+ void (*postHookFunc) (int *account_id, int *u_fd, int *u_aid, int *u_group, int *map_fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_on_parse_accinfo_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_on_parse_accinfo_post[hIndex].func;
+ postHookFunc(&account_id, &u_fd, &u_aid, &u_group, &map_fd);
+ }
+ }
+ return;
+}
+void HP_mapif_char_ban(int char_id, time_t timestamp) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_char_ban_pre ) {
+ void (*preHookFunc) (int *char_id, time_t *timestamp);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_char_ban_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_char_ban_pre[hIndex].func;
+ preHookFunc(&char_id, &timestamp);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.char_ban(char_id, timestamp);
+ }
+ if( HPMHooks.count.HP_mapif_char_ban_post ) {
+ void (*postHookFunc) (int *char_id, time_t *timestamp);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_char_ban_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_char_ban_post[hIndex].func;
+ postHookFunc(&char_id, &timestamp);
+ }
+ }
+ return;
+}
+int HP_mapif_sendall(unsigned char *buf, unsigned int len) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_sendall_pre ) {
+ int (*preHookFunc) (unsigned char *buf, unsigned int *len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_sendall_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_sendall_pre[hIndex].func;
+ retVal___ = preHookFunc(buf, &len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.sendall(buf, len);
+ }
+ if( HPMHooks.count.HP_mapif_sendall_post ) {
+ int (*postHookFunc) (int retVal___, unsigned char *buf, unsigned int *len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_sendall_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_sendall_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, buf, &len);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_sendallwos_pre ) {
+ int (*preHookFunc) (int *sfd, unsigned char *buf, unsigned int *len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_sendallwos_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_sendallwos_pre[hIndex].func;
+ retVal___ = preHookFunc(&sfd, buf, &len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.sendallwos(sfd, buf, len);
+ }
+ if( HPMHooks.count.HP_mapif_sendallwos_post ) {
+ int (*postHookFunc) (int retVal___, int *sfd, unsigned char *buf, unsigned int *len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_sendallwos_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_sendallwos_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &sfd, buf, &len);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_send(int fd, unsigned char *buf, unsigned int len) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_send_pre ) {
+ int (*preHookFunc) (int *fd, unsigned char *buf, unsigned int *len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_send_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_send_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, buf, &len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.send(fd, buf, len);
+ }
+ if( HPMHooks.count.HP_mapif_send_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, unsigned char *buf, unsigned int *len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_send_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_send_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, buf, &len);
+ }
+ }
+ return retVal___;
+}
+void HP_mapif_send_users_count(int users) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_send_users_count_pre ) {
+ void (*preHookFunc) (int *users);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_send_users_count_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_send_users_count_pre[hIndex].func;
+ preHookFunc(&users);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.send_users_count(users);
+ }
+ if( HPMHooks.count.HP_mapif_send_users_count_post ) {
+ void (*postHookFunc) (int *users);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_send_users_count_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_send_users_count_post[hIndex].func;
+ postHookFunc(&users);
+ }
+ }
+ return;
+}
+void HP_mapif_auction_message(int char_id, unsigned char result) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_auction_message_pre ) {
+ void (*preHookFunc) (int *char_id, unsigned char *result);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_auction_message_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_auction_message_pre[hIndex].func;
+ preHookFunc(&char_id, &result);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.auction_message(char_id, result);
+ }
+ if( HPMHooks.count.HP_mapif_auction_message_post ) {
+ void (*postHookFunc) (int *char_id, unsigned char *result);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_auction_message_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_auction_message_post[hIndex].func;
+ postHookFunc(&char_id, &result);
+ }
+ }
+ return;
+}
+void HP_mapif_auction_sendlist(int fd, int char_id, short count, short pages, unsigned char *buf) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_auction_sendlist_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, short *count, short *pages, unsigned char *buf);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_auction_sendlist_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_auction_sendlist_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, &count, &pages, buf);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.auction_sendlist(fd, char_id, count, pages, buf);
+ }
+ if( HPMHooks.count.HP_mapif_auction_sendlist_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, short *count, short *pages, unsigned char *buf);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_auction_sendlist_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_auction_sendlist_post[hIndex].func;
+ postHookFunc(&fd, &char_id, &count, &pages, buf);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_auction_requestlist(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_auction_requestlist_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_auction_requestlist_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_auction_requestlist_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_auction_requestlist(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_auction_requestlist_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_auction_requestlist_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_auction_requestlist_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_mapif_auction_register(int fd, struct auction_data *auction) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_auction_register_pre ) {
+ void (*preHookFunc) (int *fd, struct auction_data *auction);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_auction_register_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_auction_register_pre[hIndex].func;
+ preHookFunc(&fd, auction);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.auction_register(fd, auction);
+ }
+ if( HPMHooks.count.HP_mapif_auction_register_post ) {
+ void (*postHookFunc) (int *fd, struct auction_data *auction);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_auction_register_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_auction_register_post[hIndex].func;
+ postHookFunc(&fd, auction);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_auction_register(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_auction_register_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_auction_register_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_auction_register_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_auction_register(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_auction_register_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_auction_register_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_auction_register_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_mapif_auction_cancel(int fd, int char_id, unsigned char result) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_auction_cancel_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, unsigned char *result);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_auction_cancel_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_auction_cancel_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, &result);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.auction_cancel(fd, char_id, result);
+ }
+ if( HPMHooks.count.HP_mapif_auction_cancel_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, unsigned char *result);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_auction_cancel_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_auction_cancel_post[hIndex].func;
+ postHookFunc(&fd, &char_id, &result);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_auction_cancel(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_auction_cancel_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_auction_cancel_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_auction_cancel_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_auction_cancel(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_auction_cancel_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_auction_cancel_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_auction_cancel_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_mapif_auction_close(int fd, int char_id, unsigned char result) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_auction_close_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, unsigned char *result);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_auction_close_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_auction_close_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, &result);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.auction_close(fd, char_id, result);
+ }
+ if( HPMHooks.count.HP_mapif_auction_close_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, unsigned char *result);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_auction_close_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_auction_close_post[hIndex].func;
+ postHookFunc(&fd, &char_id, &result);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_auction_close(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_auction_close_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_auction_close_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_auction_close_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_auction_close(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_auction_close_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_auction_close_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_auction_close_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_mapif_auction_bid(int fd, int char_id, int bid, unsigned char result) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_auction_bid_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, int *bid, unsigned char *result);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_auction_bid_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_auction_bid_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, &bid, &result);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.auction_bid(fd, char_id, bid, result);
+ }
+ if( HPMHooks.count.HP_mapif_auction_bid_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, int *bid, unsigned char *result);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_auction_bid_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_auction_bid_post[hIndex].func;
+ postHookFunc(&fd, &char_id, &bid, &result);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_auction_bid(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_auction_bid_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_auction_bid_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_auction_bid_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_auction_bid(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_auction_bid_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_auction_bid_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_auction_bid_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+bool HP_mapif_elemental_save(struct s_elemental *ele) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mapif_elemental_save_pre ) {
+ bool (*preHookFunc) (struct s_elemental *ele);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_elemental_save_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_elemental_save_pre[hIndex].func;
+ retVal___ = preHookFunc(ele);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.elemental_save(ele);
+ }
+ if( HPMHooks.count.HP_mapif_elemental_save_post ) {
+ bool (*postHookFunc) (bool retVal___, struct s_elemental *ele);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_elemental_save_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_elemental_save_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, ele);
+ }
+ }
+ return retVal___;
+}
+bool HP_mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mapif_elemental_load_pre ) {
+ bool (*preHookFunc) (int *ele_id, int *char_id, struct s_elemental *ele);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_elemental_load_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_elemental_load_pre[hIndex].func;
+ retVal___ = preHookFunc(&ele_id, &char_id, ele);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.elemental_load(ele_id, char_id, ele);
+ }
+ if( HPMHooks.count.HP_mapif_elemental_load_post ) {
+ bool (*postHookFunc) (bool retVal___, int *ele_id, int *char_id, struct s_elemental *ele);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_elemental_load_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_elemental_load_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &ele_id, &char_id, ele);
+ }
+ }
+ return retVal___;
+}
+bool HP_mapif_elemental_delete(int ele_id) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mapif_elemental_delete_pre ) {
+ bool (*preHookFunc) (int *ele_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_elemental_delete_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_elemental_delete_pre[hIndex].func;
+ retVal___ = preHookFunc(&ele_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.elemental_delete(ele_id);
+ }
+ if( HPMHooks.count.HP_mapif_elemental_delete_post ) {
+ bool (*postHookFunc) (bool retVal___, int *ele_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_elemental_delete_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_elemental_delete_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &ele_id);
+ }
+ }
+ return retVal___;
+}
+void HP_mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_elemental_send_pre ) {
+ void (*preHookFunc) (int *fd, struct s_elemental *ele, unsigned char *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_elemental_send_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_elemental_send_pre[hIndex].func;
+ preHookFunc(&fd, ele, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.elemental_send(fd, ele, flag);
+ }
+ if( HPMHooks.count.HP_mapif_elemental_send_post ) {
+ void (*postHookFunc) (int *fd, struct s_elemental *ele, unsigned char *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_elemental_send_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_elemental_send_post[hIndex].func;
+ postHookFunc(&fd, ele, &flag);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_elemental_create(int fd, struct s_elemental *ele) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_elemental_create_pre ) {
+ void (*preHookFunc) (int *fd, struct s_elemental *ele);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_elemental_create_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_elemental_create_pre[hIndex].func;
+ preHookFunc(&fd, ele);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_elemental_create(fd, ele);
+ }
+ if( HPMHooks.count.HP_mapif_parse_elemental_create_post ) {
+ void (*postHookFunc) (int *fd, struct s_elemental *ele);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_elemental_create_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_elemental_create_post[hIndex].func;
+ postHookFunc(&fd, ele);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_elemental_load(int fd, int ele_id, int char_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_elemental_load_pre ) {
+ void (*preHookFunc) (int *fd, int *ele_id, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_elemental_load_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_elemental_load_pre[hIndex].func;
+ preHookFunc(&fd, &ele_id, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_elemental_load(fd, ele_id, char_id);
+ }
+ if( HPMHooks.count.HP_mapif_parse_elemental_load_post ) {
+ void (*postHookFunc) (int *fd, int *ele_id, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_elemental_load_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_elemental_load_post[hIndex].func;
+ postHookFunc(&fd, &ele_id, &char_id);
+ }
+ }
+ return;
+}
+void HP_mapif_elemental_deleted(int fd, unsigned char flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_elemental_deleted_pre ) {
+ void (*preHookFunc) (int *fd, unsigned char *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_elemental_deleted_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_elemental_deleted_pre[hIndex].func;
+ preHookFunc(&fd, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.elemental_deleted(fd, flag);
+ }
+ if( HPMHooks.count.HP_mapif_elemental_deleted_post ) {
+ void (*postHookFunc) (int *fd, unsigned char *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_elemental_deleted_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_elemental_deleted_post[hIndex].func;
+ postHookFunc(&fd, &flag);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_elemental_delete(int fd, int ele_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_elemental_delete_pre ) {
+ void (*preHookFunc) (int *fd, int *ele_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_elemental_delete_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_elemental_delete_pre[hIndex].func;
+ preHookFunc(&fd, &ele_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_elemental_delete(fd, ele_id);
+ }
+ if( HPMHooks.count.HP_mapif_parse_elemental_delete_post ) {
+ void (*postHookFunc) (int *fd, int *ele_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_elemental_delete_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_elemental_delete_post[hIndex].func;
+ postHookFunc(&fd, &ele_id);
+ }
+ }
+ return;
+}
+void HP_mapif_elemental_saved(int fd, unsigned char flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_elemental_saved_pre ) {
+ void (*preHookFunc) (int *fd, unsigned char *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_elemental_saved_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_elemental_saved_pre[hIndex].func;
+ preHookFunc(&fd, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.elemental_saved(fd, flag);
+ }
+ if( HPMHooks.count.HP_mapif_elemental_saved_post ) {
+ void (*postHookFunc) (int *fd, unsigned char *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_elemental_saved_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_elemental_saved_post[hIndex].func;
+ postHookFunc(&fd, &flag);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_elemental_save(int fd, struct s_elemental *ele) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_elemental_save_pre ) {
+ void (*preHookFunc) (int *fd, struct s_elemental *ele);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_elemental_save_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_elemental_save_pre[hIndex].func;
+ preHookFunc(&fd, ele);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_elemental_save(fd, ele);
+ }
+ if( HPMHooks.count.HP_mapif_parse_elemental_save_post ) {
+ void (*postHookFunc) (int *fd, struct s_elemental *ele);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_elemental_save_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_elemental_save_post[hIndex].func;
+ postHookFunc(&fd, ele);
+ }
+ }
+ return;
+}
+int HP_mapif_guild_created(int fd, int account_id, struct guild *g) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_created_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id, struct guild *g);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_created_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_created_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id, g);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_created(fd, account_id, g);
+ }
+ if( HPMHooks.count.HP_mapif_guild_created_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id, struct guild *g);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_created_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_created_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id, g);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_noinfo(int fd, int guild_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_noinfo_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_noinfo_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_noinfo_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_noinfo(fd, guild_id);
+ }
+ if( HPMHooks.count.HP_mapif_guild_noinfo_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_noinfo_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_noinfo_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_info(int fd, struct guild *g) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_info_pre ) {
+ int (*preHookFunc) (int *fd, struct guild *g);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_info_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_info_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, g);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_info(fd, g);
+ }
+ if( HPMHooks.count.HP_mapif_guild_info_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, struct guild *g);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_info_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_info_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, g);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_memberadded(int fd, int guild_id, int account_id, int char_id, int flag) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_memberadded_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id, int *account_id, int *char_id, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_memberadded_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_memberadded_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id, &account_id, &char_id, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_memberadded(fd, guild_id, account_id, char_id, flag);
+ }
+ if( HPMHooks.count.HP_mapif_guild_memberadded_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id, int *account_id, int *char_id, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_memberadded_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_memberadded_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id, &account_id, &char_id, &flag);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_withdraw(int guild_id, int account_id, int char_id, int flag, const char *name, const char *mes) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_withdraw_pre ) {
+ int (*preHookFunc) (int *guild_id, int *account_id, int *char_id, int *flag, const char *name, const char *mes);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_withdraw_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_withdraw_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id, &account_id, &char_id, &flag, name, mes);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_withdraw(guild_id, account_id, char_id, flag, name, mes);
+ }
+ if( HPMHooks.count.HP_mapif_guild_withdraw_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id, int *account_id, int *char_id, int *flag, const char *name, const char *mes);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_withdraw_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_withdraw_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id, &account_id, &char_id, &flag, name, mes);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_memberinfoshort(struct guild *g, int idx) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_memberinfoshort_pre ) {
+ int (*preHookFunc) (struct guild *g, int *idx);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_memberinfoshort_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_memberinfoshort_pre[hIndex].func;
+ retVal___ = preHookFunc(g, &idx);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_memberinfoshort(g, idx);
+ }
+ if( HPMHooks.count.HP_mapif_guild_memberinfoshort_post ) {
+ int (*postHookFunc) (int retVal___, struct guild *g, int *idx);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_memberinfoshort_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_memberinfoshort_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, g, &idx);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_broken(int guild_id, int flag) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_broken_pre ) {
+ int (*preHookFunc) (int *guild_id, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_broken_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_broken_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_broken(guild_id, flag);
+ }
+ if( HPMHooks.count.HP_mapif_guild_broken_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_broken_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_broken_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id, &flag);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_message(int guild_id, int account_id, char *mes, int len, int sfd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_message_pre ) {
+ int (*preHookFunc) (int *guild_id, int *account_id, char *mes, int *len, int *sfd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_message_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_message_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id, &account_id, mes, &len, &sfd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_message(guild_id, account_id, mes, len, sfd);
+ }
+ if( HPMHooks.count.HP_mapif_guild_message_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id, int *account_id, char *mes, int *len, int *sfd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_message_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_message_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id, &account_id, mes, &len, &sfd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_basicinfochanged(int guild_id, int type, const void *data, int len) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_basicinfochanged_pre ) {
+ int (*preHookFunc) (int *guild_id, int *type, const void *data, int *len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_basicinfochanged_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_basicinfochanged_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id, &type, data, &len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_basicinfochanged(guild_id, type, data, len);
+ }
+ if( HPMHooks.count.HP_mapif_guild_basicinfochanged_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id, int *type, const void *data, int *len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_basicinfochanged_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_basicinfochanged_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id, &type, data, &len);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_memberinfochanged(int guild_id, int account_id, int char_id, int type, const void *data, int len) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_memberinfochanged_pre ) {
+ int (*preHookFunc) (int *guild_id, int *account_id, int *char_id, int *type, const void *data, int *len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_memberinfochanged_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_memberinfochanged_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id, &account_id, &char_id, &type, data, &len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_memberinfochanged(guild_id, account_id, char_id, type, data, len);
+ }
+ if( HPMHooks.count.HP_mapif_guild_memberinfochanged_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id, int *account_id, int *char_id, int *type, const void *data, int *len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_memberinfochanged_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_memberinfochanged_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id, &account_id, &char_id, &type, data, &len);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_skillupack(int guild_id, uint16 skill_id, int account_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_skillupack_pre ) {
+ int (*preHookFunc) (int *guild_id, uint16 *skill_id, int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_skillupack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_skillupack_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id, &skill_id, &account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_skillupack(guild_id, skill_id, account_id);
+ }
+ if( HPMHooks.count.HP_mapif_guild_skillupack_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id, uint16 *skill_id, int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_skillupack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_skillupack_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id, &skill_id, &account_id);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_alliance(int guild_id1, int guild_id2, int account_id1, int account_id2, int flag, const char *name1, const char *name2) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_alliance_pre ) {
+ int (*preHookFunc) (int *guild_id1, int *guild_id2, int *account_id1, int *account_id2, int *flag, const char *name1, const char *name2);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_alliance_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_alliance_pre[hIndex].func;
+ retVal___ = preHookFunc(&guild_id1, &guild_id2, &account_id1, &account_id2, &flag, name1, name2);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_alliance(guild_id1, guild_id2, account_id1, account_id2, flag, name1, name2);
+ }
+ if( HPMHooks.count.HP_mapif_guild_alliance_post ) {
+ int (*postHookFunc) (int retVal___, int *guild_id1, int *guild_id2, int *account_id1, int *account_id2, int *flag, const char *name1, const char *name2);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_alliance_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_alliance_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &guild_id1, &guild_id2, &account_id1, &account_id2, &flag, name1, name2);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_position(struct guild *g, int idx) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_position_pre ) {
+ int (*preHookFunc) (struct guild *g, int *idx);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_position_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_position_pre[hIndex].func;
+ retVal___ = preHookFunc(g, &idx);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_position(g, idx);
+ }
+ if( HPMHooks.count.HP_mapif_guild_position_post ) {
+ int (*postHookFunc) (int retVal___, struct guild *g, int *idx);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_position_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_position_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, g, &idx);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_notice(struct guild *g) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_notice_pre ) {
+ int (*preHookFunc) (struct guild *g);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_notice_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_notice_pre[hIndex].func;
+ retVal___ = preHookFunc(g);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_notice(g);
+ }
+ if( HPMHooks.count.HP_mapif_guild_notice_post ) {
+ int (*postHookFunc) (int retVal___, struct guild *g);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_notice_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_notice_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, g);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_emblem(struct guild *g) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_emblem_pre ) {
+ int (*preHookFunc) (struct guild *g);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_emblem_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_emblem_pre[hIndex].func;
+ retVal___ = preHookFunc(g);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_emblem(g);
+ }
+ if( HPMHooks.count.HP_mapif_guild_emblem_post ) {
+ int (*postHookFunc) (int retVal___, struct guild *g);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_emblem_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_emblem_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, g);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_master_changed(struct guild *g, int aid, int cid) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_master_changed_pre ) {
+ int (*preHookFunc) (struct guild *g, int *aid, int *cid);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_master_changed_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_master_changed_pre[hIndex].func;
+ retVal___ = preHookFunc(g, &aid, &cid);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_master_changed(g, aid, cid);
+ }
+ if( HPMHooks.count.HP_mapif_guild_master_changed_post ) {
+ int (*postHookFunc) (int retVal___, struct guild *g, int *aid, int *cid);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_master_changed_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_master_changed_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, g, &aid, &cid);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_guild_castle_dataload(int fd, int sz, int *castle_ids) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_guild_castle_dataload_pre ) {
+ int (*preHookFunc) (int *fd, int *sz, int *castle_ids);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_castle_dataload_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_guild_castle_dataload_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &sz, castle_ids);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.guild_castle_dataload(fd, sz, castle_ids);
+ }
+ if( HPMHooks.count.HP_mapif_guild_castle_dataload_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *sz, int *castle_ids);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_guild_castle_dataload_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_guild_castle_dataload_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &sz, castle_ids);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_CreateGuild(int fd, int account_id, char *name, struct guild_member *master) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_CreateGuild_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id, char *name, struct guild_member *master);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_CreateGuild_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_CreateGuild_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id, name, master);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_CreateGuild(fd, account_id, name, master);
+ }
+ if( HPMHooks.count.HP_mapif_parse_CreateGuild_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id, char *name, struct guild_member *master);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_CreateGuild_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_CreateGuild_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id, name, master);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildInfo(int fd, int guild_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildInfo_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildInfo_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildInfo_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildInfo(fd, guild_id);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildInfo_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildInfo_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildInfo_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildAddMember(int fd, int guild_id, struct guild_member *m) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildAddMember_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id, struct guild_member *m);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildAddMember_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildAddMember_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id, m);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildAddMember(fd, guild_id, m);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildAddMember_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id, struct guild_member *m);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildAddMember_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildAddMember_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id, m);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, int flag, const char *mes) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildLeave_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id, int *account_id, int *char_id, int *flag, const char *mes);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildLeave_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildLeave_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id, &account_id, &char_id, &flag, mes);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildLeave(fd, guild_id, account_id, char_id, flag, mes);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildLeave_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id, int *account_id, int *char_id, int *flag, const char *mes);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildLeave_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildLeave_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id, &account_id, &char_id, &flag, mes);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, int char_id, int online, int lv, int class_) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildChangeMemberInfoShort_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id, int *account_id, int *char_id, int *online, int *lv, int *class_);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildChangeMemberInfoShort_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildChangeMemberInfoShort_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id, &account_id, &char_id, &online, &lv, &class_);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildChangeMemberInfoShort(fd, guild_id, account_id, char_id, online, lv, class_);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildChangeMemberInfoShort_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id, int *account_id, int *char_id, int *online, int *lv, int *class_);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildChangeMemberInfoShort_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildChangeMemberInfoShort_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id, &account_id, &char_id, &online, &lv, &class_);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_BreakGuild(int fd, int guild_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_BreakGuild_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_BreakGuild_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_BreakGuild_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_BreakGuild(fd, guild_id);
+ }
+ if( HPMHooks.count.HP_mapif_parse_BreakGuild_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_BreakGuild_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_BreakGuild_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildMessage(int fd, int guild_id, int account_id, char *mes, int len) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildMessage_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id, int *account_id, char *mes, int *len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildMessage_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildMessage_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id, &account_id, mes, &len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildMessage(fd, guild_id, account_id, mes, len);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildMessage_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id, int *account_id, char *mes, int *len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildMessage_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildMessage_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id, &account_id, mes, &len);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const void *data, int len) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildBasicInfoChange_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id, int *type, const void *data, int *len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildBasicInfoChange_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildBasicInfoChange_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id, &type, data, &len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildBasicInfoChange(fd, guild_id, type, data, len);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildBasicInfoChange_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id, int *type, const void *data, int *len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildBasicInfoChange_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildBasicInfoChange_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id, &type, data, &len);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int char_id, int type, const char *data, int len) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildMemberInfoChange_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id, int *account_id, int *char_id, int *type, const char *data, int *len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildMemberInfoChange_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildMemberInfoChange_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id, &account_id, &char_id, &type, data, &len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildMemberInfoChange(fd, guild_id, account_id, char_id, type, data, len);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildMemberInfoChange_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id, int *account_id, int *char_id, int *type, const char *data, int *len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildMemberInfoChange_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildMemberInfoChange_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id, &account_id, &char_id, &type, data, &len);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildPosition(int fd, int guild_id, int idx, struct guild_position *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildPosition_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id, int *idx, struct guild_position *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildPosition_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildPosition_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id, &idx, p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildPosition(fd, guild_id, idx, p);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildPosition_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id, int *idx, struct guild_position *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildPosition_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildPosition_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id, &idx, p);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildSkillUp(int fd, int guild_id, uint16 skill_id, int account_id, int max) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildSkillUp_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id, uint16 *skill_id, int *account_id, int *max);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildSkillUp_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildSkillUp_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id, &skill_id, &account_id, &max);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildSkillUp(fd, guild_id, skill_id, account_id, max);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildSkillUp_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id, uint16 *skill_id, int *account_id, int *max);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildSkillUp_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildSkillUp_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id, &skill_id, &account_id, &max);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int account_id1, int account_id2, int flag) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildDeleteAlliance_pre ) {
+ int (*preHookFunc) (struct guild *g, int *guild_id, int *account_id1, int *account_id2, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildDeleteAlliance_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildDeleteAlliance_pre[hIndex].func;
+ retVal___ = preHookFunc(g, &guild_id, &account_id1, &account_id2, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildDeleteAlliance(g, guild_id, account_id1, account_id2, flag);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildDeleteAlliance_post ) {
+ int (*postHookFunc) (int retVal___, struct guild *g, int *guild_id, int *account_id1, int *account_id2, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildDeleteAlliance_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildDeleteAlliance_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, g, &guild_id, &account_id1, &account_id2, &flag);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_id1, int account_id2, int flag) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildAlliance_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id1, int *guild_id2, int *account_id1, int *account_id2, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildAlliance_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildAlliance_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id1, &guild_id2, &account_id1, &account_id2, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildAlliance(fd, guild_id1, guild_id2, account_id1, account_id2, flag);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildAlliance_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id1, int *guild_id2, int *account_id1, int *account_id2, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildAlliance_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildAlliance_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id1, &guild_id2, &account_id1, &account_id2, &flag);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char *mes2) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildNotice_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id, const char *mes1, const char *mes2);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildNotice_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildNotice_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id, mes1, mes2);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildNotice(fd, guild_id, mes1, mes2);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildNotice_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id, const char *mes1, const char *mes2);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildNotice_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildNotice_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id, mes1, mes2);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char *data) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildEmblem_pre ) {
+ int (*preHookFunc) (int *fd, int *len, int *guild_id, int *dummy, const char *data);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildEmblem_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildEmblem_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &len, &guild_id, &dummy, data);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildEmblem(fd, len, guild_id, dummy, data);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildEmblem_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *len, int *guild_id, int *dummy, const char *data);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildEmblem_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildEmblem_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &len, &guild_id, &dummy, data);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildCastleDataLoad(int fd, int len, int *castle_ids) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildCastleDataLoad_pre ) {
+ int (*preHookFunc) (int *fd, int *len, int *castle_ids);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildCastleDataLoad_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildCastleDataLoad_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &len, castle_ids);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildCastleDataLoad(fd, len, castle_ids);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildCastleDataLoad_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *len, int *castle_ids);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildCastleDataLoad_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildCastleDataLoad_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &len, castle_ids);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildCastleDataSave_pre ) {
+ int (*preHookFunc) (int *fd, int *castle_id, int *index, int *value);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildCastleDataSave_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildCastleDataSave_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &castle_id, &index, &value);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildCastleDataSave(fd, castle_id, index, value);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildCastleDataSave_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *castle_id, int *index, int *value);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildCastleDataSave_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildCastleDataSave_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &castle_id, &index, &value);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_GuildMasterChange(int fd, int guild_id, const char *name, int len) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_GuildMasterChange_pre ) {
+ int (*preHookFunc) (int *fd, int *guild_id, const char *name, int *len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildMasterChange_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_GuildMasterChange_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &guild_id, name, &len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_GuildMasterChange(fd, guild_id, name, len);
+ }
+ if( HPMHooks.count.HP_mapif_parse_GuildMasterChange_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *guild_id, const char *name, int *len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_GuildMasterChange_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_GuildMasterChange_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &guild_id, name, &len);
+ }
+ }
+ return retVal___;
+}
+void HP_mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, unsigned char flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_homunculus_created_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id, struct s_homunculus *sh, unsigned char *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_created_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_homunculus_created_pre[hIndex].func;
+ preHookFunc(&fd, &account_id, sh, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.homunculus_created(fd, account_id, sh, flag);
+ }
+ if( HPMHooks.count.HP_mapif_homunculus_created_post ) {
+ void (*postHookFunc) (int *fd, int *account_id, struct s_homunculus *sh, unsigned char *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_created_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_homunculus_created_post[hIndex].func;
+ postHookFunc(&fd, &account_id, sh, &flag);
+ }
+ }
+ return;
+}
+void HP_mapif_homunculus_deleted(int fd, int flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_homunculus_deleted_pre ) {
+ void (*preHookFunc) (int *fd, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_deleted_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_homunculus_deleted_pre[hIndex].func;
+ preHookFunc(&fd, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.homunculus_deleted(fd, flag);
+ }
+ if( HPMHooks.count.HP_mapif_homunculus_deleted_post ) {
+ void (*postHookFunc) (int *fd, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_deleted_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_homunculus_deleted_post[hIndex].func;
+ postHookFunc(&fd, &flag);
+ }
+ }
+ return;
+}
+void HP_mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_homunculus_loaded_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id, struct s_homunculus *hd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_loaded_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_homunculus_loaded_pre[hIndex].func;
+ preHookFunc(&fd, &account_id, hd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.homunculus_loaded(fd, account_id, hd);
+ }
+ if( HPMHooks.count.HP_mapif_homunculus_loaded_post ) {
+ void (*postHookFunc) (int *fd, int *account_id, struct s_homunculus *hd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_loaded_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_homunculus_loaded_post[hIndex].func;
+ postHookFunc(&fd, &account_id, hd);
+ }
+ }
+ return;
+}
+void HP_mapif_homunculus_saved(int fd, int account_id, bool flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_homunculus_saved_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id, bool *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_saved_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_homunculus_saved_pre[hIndex].func;
+ preHookFunc(&fd, &account_id, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.homunculus_saved(fd, account_id, flag);
+ }
+ if( HPMHooks.count.HP_mapif_homunculus_saved_post ) {
+ void (*postHookFunc) (int *fd, int *account_id, bool *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_saved_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_homunculus_saved_post[hIndex].func;
+ postHookFunc(&fd, &account_id, &flag);
+ }
+ }
+ return;
+}
+void HP_mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, char *name) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_homunculus_renamed_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id, int *char_id, unsigned char *flag, char *name);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_renamed_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_homunculus_renamed_pre[hIndex].func;
+ preHookFunc(&fd, &account_id, &char_id, &flag, name);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.homunculus_renamed(fd, account_id, char_id, flag, name);
+ }
+ if( HPMHooks.count.HP_mapif_homunculus_renamed_post ) {
+ void (*postHookFunc) (int *fd, int *account_id, int *char_id, unsigned char *flag, char *name);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_renamed_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_homunculus_renamed_post[hIndex].func;
+ postHookFunc(&fd, &account_id, &char_id, &flag, name);
+ }
+ }
+ return;
+}
+bool HP_mapif_homunculus_save(struct s_homunculus *hd) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mapif_homunculus_save_pre ) {
+ bool (*preHookFunc) (struct s_homunculus *hd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_save_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_homunculus_save_pre[hIndex].func;
+ retVal___ = preHookFunc(hd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.homunculus_save(hd);
+ }
+ if( HPMHooks.count.HP_mapif_homunculus_save_post ) {
+ bool (*postHookFunc) (bool retVal___, struct s_homunculus *hd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_save_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_homunculus_save_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, hd);
+ }
+ }
+ return retVal___;
+}
+bool HP_mapif_homunculus_load(int homun_id, struct s_homunculus *hd) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mapif_homunculus_load_pre ) {
+ bool (*preHookFunc) (int *homun_id, struct s_homunculus *hd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_load_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_homunculus_load_pre[hIndex].func;
+ retVal___ = preHookFunc(&homun_id, hd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.homunculus_load(homun_id, hd);
+ }
+ if( HPMHooks.count.HP_mapif_homunculus_load_post ) {
+ bool (*postHookFunc) (bool retVal___, int *homun_id, struct s_homunculus *hd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_load_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_homunculus_load_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &homun_id, hd);
+ }
+ }
+ return retVal___;
+}
+bool HP_mapif_homunculus_delete(int homun_id) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mapif_homunculus_delete_pre ) {
+ bool (*preHookFunc) (int *homun_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_delete_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_homunculus_delete_pre[hIndex].func;
+ retVal___ = preHookFunc(&homun_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.homunculus_delete(homun_id);
+ }
+ if( HPMHooks.count.HP_mapif_homunculus_delete_post ) {
+ bool (*postHookFunc) (bool retVal___, int *homun_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_delete_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_homunculus_delete_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &homun_id);
+ }
+ }
+ return retVal___;
+}
+bool HP_mapif_homunculus_rename(char *name) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mapif_homunculus_rename_pre ) {
+ bool (*preHookFunc) (char *name);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_rename_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_homunculus_rename_pre[hIndex].func;
+ retVal___ = preHookFunc(name);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.homunculus_rename(name);
+ }
+ if( HPMHooks.count.HP_mapif_homunculus_rename_post ) {
+ bool (*postHookFunc) (bool retVal___, char *name);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_homunculus_rename_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_homunculus_rename_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, name);
+ }
+ }
+ return retVal___;
+}
+void HP_mapif_parse_homunculus_create(int fd, int len, int account_id, struct s_homunculus *phd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_homunculus_create_pre ) {
+ void (*preHookFunc) (int *fd, int *len, int *account_id, struct s_homunculus *phd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_homunculus_create_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_homunculus_create_pre[hIndex].func;
+ preHookFunc(&fd, &len, &account_id, phd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_homunculus_create(fd, len, account_id, phd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_homunculus_create_post ) {
+ void (*postHookFunc) (int *fd, int *len, int *account_id, struct s_homunculus *phd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_homunculus_create_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_homunculus_create_post[hIndex].func;
+ postHookFunc(&fd, &len, &account_id, phd);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_homunculus_delete(int fd, int homun_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_homunculus_delete_pre ) {
+ void (*preHookFunc) (int *fd, int *homun_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_homunculus_delete_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_homunculus_delete_pre[hIndex].func;
+ preHookFunc(&fd, &homun_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_homunculus_delete(fd, homun_id);
+ }
+ if( HPMHooks.count.HP_mapif_parse_homunculus_delete_post ) {
+ void (*postHookFunc) (int *fd, int *homun_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_homunculus_delete_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_homunculus_delete_post[hIndex].func;
+ postHookFunc(&fd, &homun_id);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_homunculus_load(int fd, int account_id, int homun_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_homunculus_load_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id, int *homun_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_homunculus_load_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_homunculus_load_pre[hIndex].func;
+ preHookFunc(&fd, &account_id, &homun_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_homunculus_load(fd, account_id, homun_id);
+ }
+ if( HPMHooks.count.HP_mapif_parse_homunculus_load_post ) {
+ void (*postHookFunc) (int *fd, int *account_id, int *homun_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_homunculus_load_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_homunculus_load_post[hIndex].func;
+ postHookFunc(&fd, &account_id, &homun_id);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_homunculus_save(int fd, int len, int account_id, struct s_homunculus *phd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_homunculus_save_pre ) {
+ void (*preHookFunc) (int *fd, int *len, int *account_id, struct s_homunculus *phd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_homunculus_save_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_homunculus_save_pre[hIndex].func;
+ preHookFunc(&fd, &len, &account_id, phd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_homunculus_save(fd, len, account_id, phd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_homunculus_save_post ) {
+ void (*postHookFunc) (int *fd, int *len, int *account_id, struct s_homunculus *phd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_homunculus_save_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_homunculus_save_post[hIndex].func;
+ postHookFunc(&fd, &len, &account_id, phd);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_homunculus_rename(int fd, int account_id, int char_id, char *name) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_homunculus_rename_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id, int *char_id, char *name);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_homunculus_rename_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_homunculus_rename_pre[hIndex].func;
+ preHookFunc(&fd, &account_id, &char_id, name);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_homunculus_rename(fd, account_id, char_id, name);
+ }
+ if( HPMHooks.count.HP_mapif_parse_homunculus_rename_post ) {
+ void (*postHookFunc) (int *fd, int *account_id, int *char_id, char *name);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_homunculus_rename_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_homunculus_rename_post[hIndex].func;
+ postHookFunc(&fd, &account_id, &char_id, name);
+ }
+ }
+ return;
+}
+void HP_mapif_mail_sendinbox(int fd, int char_id, unsigned char flag, struct mail_data *md) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_mail_sendinbox_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, unsigned char *flag, struct mail_data *md);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_sendinbox_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_mail_sendinbox_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, &flag, md);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.mail_sendinbox(fd, char_id, flag, md);
+ }
+ if( HPMHooks.count.HP_mapif_mail_sendinbox_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, unsigned char *flag, struct mail_data *md);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_sendinbox_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_mail_sendinbox_post[hIndex].func;
+ postHookFunc(&fd, &char_id, &flag, md);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_mail_requestinbox(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_mail_requestinbox_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mail_requestinbox_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_mail_requestinbox_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_mail_requestinbox(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_mail_requestinbox_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mail_requestinbox_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_mail_requestinbox_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_mail_read(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_mail_read_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mail_read_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_mail_read_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_mail_read(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_mail_read_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mail_read_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_mail_read_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_mapif_mail_sendattach(int fd, int char_id, struct mail_message *msg) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_mail_sendattach_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, struct mail_message *msg);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_sendattach_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_mail_sendattach_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, msg);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.mail_sendattach(fd, char_id, msg);
+ }
+ if( HPMHooks.count.HP_mapif_mail_sendattach_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, struct mail_message *msg);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_sendattach_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_mail_sendattach_post[hIndex].func;
+ postHookFunc(&fd, &char_id, msg);
+ }
+ }
+ return;
+}
+void HP_mapif_mail_getattach(int fd, int char_id, int mail_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_mail_getattach_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, int *mail_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_getattach_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_mail_getattach_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, &mail_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.mail_getattach(fd, char_id, mail_id);
+ }
+ if( HPMHooks.count.HP_mapif_mail_getattach_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, int *mail_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_getattach_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_mail_getattach_post[hIndex].func;
+ postHookFunc(&fd, &char_id, &mail_id);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_mail_getattach(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_mail_getattach_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mail_getattach_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_mail_getattach_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_mail_getattach(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_mail_getattach_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mail_getattach_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_mail_getattach_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_mapif_mail_delete(int fd, int char_id, int mail_id, bool failed) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_mail_delete_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, int *mail_id, bool *failed);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_delete_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_mail_delete_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, &mail_id, &failed);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.mail_delete(fd, char_id, mail_id, failed);
+ }
+ if( HPMHooks.count.HP_mapif_mail_delete_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, int *mail_id, bool *failed);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_delete_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_mail_delete_post[hIndex].func;
+ postHookFunc(&fd, &char_id, &mail_id, &failed);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_mail_delete(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_mail_delete_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mail_delete_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_mail_delete_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_mail_delete(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_mail_delete_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mail_delete_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_mail_delete_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_mapif_mail_new(struct mail_message *msg) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_mail_new_pre ) {
+ void (*preHookFunc) (struct mail_message *msg);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_new_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_mail_new_pre[hIndex].func;
+ preHookFunc(msg);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.mail_new(msg);
+ }
+ if( HPMHooks.count.HP_mapif_mail_new_post ) {
+ void (*postHookFunc) (struct mail_message *msg);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_new_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_mail_new_post[hIndex].func;
+ postHookFunc(msg);
+ }
+ }
+ return;
+}
+void HP_mapif_mail_return(int fd, int char_id, int mail_id, int new_mail) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_mail_return_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, int *mail_id, int *new_mail);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_return_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_mail_return_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, &mail_id, &new_mail);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.mail_return(fd, char_id, mail_id, new_mail);
+ }
+ if( HPMHooks.count.HP_mapif_mail_return_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, int *mail_id, int *new_mail);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_return_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_mail_return_post[hIndex].func;
+ postHookFunc(&fd, &char_id, &mail_id, &new_mail);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_mail_return(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_mail_return_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mail_return_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_mail_return_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_mail_return(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_mail_return_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mail_return_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_mail_return_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_mapif_mail_send(int fd, struct mail_message *msg) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_mail_send_pre ) {
+ void (*preHookFunc) (int *fd, struct mail_message *msg);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_send_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_mail_send_pre[hIndex].func;
+ preHookFunc(&fd, msg);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.mail_send(fd, msg);
+ }
+ if( HPMHooks.count.HP_mapif_mail_send_post ) {
+ void (*postHookFunc) (int *fd, struct mail_message *msg);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mail_send_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_mail_send_post[hIndex].func;
+ postHookFunc(&fd, msg);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_mail_send(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_mail_send_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mail_send_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_mail_send_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_mail_send(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_mail_send_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mail_send_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_mail_send_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+bool HP_mapif_mercenary_save(struct s_mercenary *merc) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mapif_mercenary_save_pre ) {
+ bool (*preHookFunc) (struct s_mercenary *merc);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mercenary_save_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_mercenary_save_pre[hIndex].func;
+ retVal___ = preHookFunc(merc);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.mercenary_save(merc);
+ }
+ if( HPMHooks.count.HP_mapif_mercenary_save_post ) {
+ bool (*postHookFunc) (bool retVal___, struct s_mercenary *merc);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mercenary_save_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_mercenary_save_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, merc);
+ }
+ }
+ return retVal___;
+}
+bool HP_mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mapif_mercenary_load_pre ) {
+ bool (*preHookFunc) (int *merc_id, int *char_id, struct s_mercenary *merc);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mercenary_load_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_mercenary_load_pre[hIndex].func;
+ retVal___ = preHookFunc(&merc_id, &char_id, merc);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.mercenary_load(merc_id, char_id, merc);
+ }
+ if( HPMHooks.count.HP_mapif_mercenary_load_post ) {
+ bool (*postHookFunc) (bool retVal___, int *merc_id, int *char_id, struct s_mercenary *merc);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mercenary_load_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_mercenary_load_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &merc_id, &char_id, merc);
+ }
+ }
+ return retVal___;
+}
+bool HP_mapif_mercenary_delete(int merc_id) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mapif_mercenary_delete_pre ) {
+ bool (*preHookFunc) (int *merc_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mercenary_delete_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_mercenary_delete_pre[hIndex].func;
+ retVal___ = preHookFunc(&merc_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.mercenary_delete(merc_id);
+ }
+ if( HPMHooks.count.HP_mapif_mercenary_delete_post ) {
+ bool (*postHookFunc) (bool retVal___, int *merc_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mercenary_delete_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_mercenary_delete_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &merc_id);
+ }
+ }
+ return retVal___;
+}
+void HP_mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_mercenary_send_pre ) {
+ void (*preHookFunc) (int *fd, struct s_mercenary *merc, unsigned char *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mercenary_send_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_mercenary_send_pre[hIndex].func;
+ preHookFunc(&fd, merc, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.mercenary_send(fd, merc, flag);
+ }
+ if( HPMHooks.count.HP_mapif_mercenary_send_post ) {
+ void (*postHookFunc) (int *fd, struct s_mercenary *merc, unsigned char *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mercenary_send_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_mercenary_send_post[hIndex].func;
+ postHookFunc(&fd, merc, &flag);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_mercenary_create(int fd, struct s_mercenary *merc) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_mercenary_create_pre ) {
+ void (*preHookFunc) (int *fd, struct s_mercenary *merc);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mercenary_create_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_mercenary_create_pre[hIndex].func;
+ preHookFunc(&fd, merc);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_mercenary_create(fd, merc);
+ }
+ if( HPMHooks.count.HP_mapif_parse_mercenary_create_post ) {
+ void (*postHookFunc) (int *fd, struct s_mercenary *merc);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mercenary_create_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_mercenary_create_post[hIndex].func;
+ postHookFunc(&fd, merc);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_mercenary_load(int fd, int merc_id, int char_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_mercenary_load_pre ) {
+ void (*preHookFunc) (int *fd, int *merc_id, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mercenary_load_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_mercenary_load_pre[hIndex].func;
+ preHookFunc(&fd, &merc_id, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_mercenary_load(fd, merc_id, char_id);
+ }
+ if( HPMHooks.count.HP_mapif_parse_mercenary_load_post ) {
+ void (*postHookFunc) (int *fd, int *merc_id, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mercenary_load_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_mercenary_load_post[hIndex].func;
+ postHookFunc(&fd, &merc_id, &char_id);
+ }
+ }
+ return;
+}
+void HP_mapif_mercenary_deleted(int fd, unsigned char flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_mercenary_deleted_pre ) {
+ void (*preHookFunc) (int *fd, unsigned char *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mercenary_deleted_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_mercenary_deleted_pre[hIndex].func;
+ preHookFunc(&fd, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.mercenary_deleted(fd, flag);
+ }
+ if( HPMHooks.count.HP_mapif_mercenary_deleted_post ) {
+ void (*postHookFunc) (int *fd, unsigned char *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mercenary_deleted_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_mercenary_deleted_post[hIndex].func;
+ postHookFunc(&fd, &flag);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_mercenary_delete(int fd, int merc_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_mercenary_delete_pre ) {
+ void (*preHookFunc) (int *fd, int *merc_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mercenary_delete_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_mercenary_delete_pre[hIndex].func;
+ preHookFunc(&fd, &merc_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_mercenary_delete(fd, merc_id);
+ }
+ if( HPMHooks.count.HP_mapif_parse_mercenary_delete_post ) {
+ void (*postHookFunc) (int *fd, int *merc_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mercenary_delete_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_mercenary_delete_post[hIndex].func;
+ postHookFunc(&fd, &merc_id);
+ }
+ }
+ return;
+}
+void HP_mapif_mercenary_saved(int fd, unsigned char flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_mercenary_saved_pre ) {
+ void (*preHookFunc) (int *fd, unsigned char *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mercenary_saved_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_mercenary_saved_pre[hIndex].func;
+ preHookFunc(&fd, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.mercenary_saved(fd, flag);
+ }
+ if( HPMHooks.count.HP_mapif_mercenary_saved_post ) {
+ void (*postHookFunc) (int *fd, unsigned char *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_mercenary_saved_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_mercenary_saved_post[hIndex].func;
+ postHookFunc(&fd, &flag);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_mercenary_save(int fd, struct s_mercenary *merc) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_mercenary_save_pre ) {
+ void (*preHookFunc) (int *fd, struct s_mercenary *merc);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mercenary_save_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_mercenary_save_pre[hIndex].func;
+ preHookFunc(&fd, merc);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_mercenary_save(fd, merc);
+ }
+ if( HPMHooks.count.HP_mapif_parse_mercenary_save_post ) {
+ void (*postHookFunc) (int *fd, struct s_mercenary *merc);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_mercenary_save_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_mercenary_save_post[hIndex].func;
+ postHookFunc(&fd, merc);
+ }
+ }
+ return;
+}
+int HP_mapif_party_created(int fd, int account_id, int char_id, struct party *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_party_created_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id, int *char_id, struct party *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_created_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_party_created_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id, &char_id, p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.party_created(fd, account_id, char_id, p);
+ }
+ if( HPMHooks.count.HP_mapif_party_created_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id, int *char_id, struct party *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_created_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_party_created_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id, &char_id, p);
+ }
+ }
+ return retVal___;
+}
+void HP_mapif_party_noinfo(int fd, int party_id, int char_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_party_noinfo_pre ) {
+ void (*preHookFunc) (int *fd, int *party_id, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_noinfo_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_party_noinfo_pre[hIndex].func;
+ preHookFunc(&fd, &party_id, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.party_noinfo(fd, party_id, char_id);
+ }
+ if( HPMHooks.count.HP_mapif_party_noinfo_post ) {
+ void (*postHookFunc) (int *fd, int *party_id, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_noinfo_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_party_noinfo_post[hIndex].func;
+ postHookFunc(&fd, &party_id, &char_id);
+ }
+ }
+ return;
+}
+void HP_mapif_party_info(int fd, struct party *p, int char_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_party_info_pre ) {
+ void (*preHookFunc) (int *fd, struct party *p, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_info_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_party_info_pre[hIndex].func;
+ preHookFunc(&fd, p, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.party_info(fd, p, char_id);
+ }
+ if( HPMHooks.count.HP_mapif_party_info_post ) {
+ void (*postHookFunc) (int *fd, struct party *p, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_info_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_party_info_post[hIndex].func;
+ postHookFunc(&fd, p, &char_id);
+ }
+ }
+ return;
+}
+int HP_mapif_party_memberadded(int fd, int party_id, int account_id, int char_id, int flag) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_party_memberadded_pre ) {
+ int (*preHookFunc) (int *fd, int *party_id, int *account_id, int *char_id, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_memberadded_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_party_memberadded_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &party_id, &account_id, &char_id, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.party_memberadded(fd, party_id, account_id, char_id, flag);
+ }
+ if( HPMHooks.count.HP_mapif_party_memberadded_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *party_id, int *account_id, int *char_id, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_memberadded_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_party_memberadded_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &party_id, &account_id, &char_id, &flag);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_party_optionchanged(int fd, struct party *p, int account_id, int flag) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_party_optionchanged_pre ) {
+ int (*preHookFunc) (int *fd, struct party *p, int *account_id, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_optionchanged_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_party_optionchanged_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, p, &account_id, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.party_optionchanged(fd, p, account_id, flag);
+ }
+ if( HPMHooks.count.HP_mapif_party_optionchanged_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, struct party *p, int *account_id, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_optionchanged_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_party_optionchanged_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, p, &account_id, &flag);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_party_withdraw(int party_id, int account_id, int char_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_party_withdraw_pre ) {
+ int (*preHookFunc) (int *party_id, int *account_id, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_withdraw_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_party_withdraw_pre[hIndex].func;
+ retVal___ = preHookFunc(&party_id, &account_id, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.party_withdraw(party_id, account_id, char_id);
+ }
+ if( HPMHooks.count.HP_mapif_party_withdraw_post ) {
+ int (*postHookFunc) (int retVal___, int *party_id, int *account_id, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_withdraw_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_party_withdraw_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &party_id, &account_id, &char_id);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_party_membermoved(struct party *p, int idx) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_party_membermoved_pre ) {
+ int (*preHookFunc) (struct party *p, int *idx);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_membermoved_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_party_membermoved_pre[hIndex].func;
+ retVal___ = preHookFunc(p, &idx);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.party_membermoved(p, idx);
+ }
+ if( HPMHooks.count.HP_mapif_party_membermoved_post ) {
+ int (*postHookFunc) (int retVal___, struct party *p, int *idx);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_membermoved_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_party_membermoved_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, p, &idx);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_party_broken(int party_id, int flag) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_party_broken_pre ) {
+ int (*preHookFunc) (int *party_id, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_broken_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_party_broken_pre[hIndex].func;
+ retVal___ = preHookFunc(&party_id, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.party_broken(party_id, flag);
+ }
+ if( HPMHooks.count.HP_mapif_party_broken_post ) {
+ int (*postHookFunc) (int retVal___, int *party_id, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_broken_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_party_broken_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &party_id, &flag);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_party_message(int party_id, int account_id, char *mes, int len, int sfd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_party_message_pre ) {
+ int (*preHookFunc) (int *party_id, int *account_id, char *mes, int *len, int *sfd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_message_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_party_message_pre[hIndex].func;
+ retVal___ = preHookFunc(&party_id, &account_id, mes, &len, &sfd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.party_message(party_id, account_id, mes, len, sfd);
+ }
+ if( HPMHooks.count.HP_mapif_party_message_post ) {
+ int (*postHookFunc) (int retVal___, int *party_id, int *account_id, char *mes, int *len, int *sfd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_party_message_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_party_message_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &party_id, &account_id, mes, &len, &sfd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct party_member *leader) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_CreateParty_pre ) {
+ int (*preHookFunc) (int *fd, char *name, int *item, int *item2, struct party_member *leader);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_CreateParty_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_CreateParty_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, name, &item, &item2, leader);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_CreateParty(fd, name, item, item2, leader);
+ }
+ if( HPMHooks.count.HP_mapif_parse_CreateParty_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, char *name, int *item, int *item2, struct party_member *leader);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_CreateParty_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_CreateParty_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, name, &item, &item2, leader);
+ }
+ }
+ return retVal___;
+}
+void HP_mapif_parse_PartyInfo(int fd, int party_id, int char_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_PartyInfo_pre ) {
+ void (*preHookFunc) (int *fd, int *party_id, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyInfo_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_PartyInfo_pre[hIndex].func;
+ preHookFunc(&fd, &party_id, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_PartyInfo(fd, party_id, char_id);
+ }
+ if( HPMHooks.count.HP_mapif_parse_PartyInfo_post ) {
+ void (*postHookFunc) (int *fd, int *party_id, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyInfo_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_PartyInfo_post[hIndex].func;
+ postHookFunc(&fd, &party_id, &char_id);
+ }
+ }
+ return;
+}
+int HP_mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_PartyAddMember_pre ) {
+ int (*preHookFunc) (int *fd, int *party_id, struct party_member *member);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyAddMember_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_PartyAddMember_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &party_id, member);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_PartyAddMember(fd, party_id, member);
+ }
+ if( HPMHooks.count.HP_mapif_parse_PartyAddMember_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *party_id, struct party_member *member);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyAddMember_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_PartyAddMember_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &party_id, member);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_PartyChangeOption(int fd, int party_id, int account_id, int exp, int item) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_PartyChangeOption_pre ) {
+ int (*preHookFunc) (int *fd, int *party_id, int *account_id, int *exp, int *item);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyChangeOption_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_PartyChangeOption_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &party_id, &account_id, &exp, &item);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_PartyChangeOption(fd, party_id, account_id, exp, item);
+ }
+ if( HPMHooks.count.HP_mapif_parse_PartyChangeOption_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *party_id, int *account_id, int *exp, int *item);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyChangeOption_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_PartyChangeOption_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &party_id, &account_id, &exp, &item);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_PartyLeave_pre ) {
+ int (*preHookFunc) (int *fd, int *party_id, int *account_id, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyLeave_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_PartyLeave_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &party_id, &account_id, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_PartyLeave(fd, party_id, account_id, char_id);
+ }
+ if( HPMHooks.count.HP_mapif_parse_PartyLeave_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *party_id, int *account_id, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyLeave_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_PartyLeave_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &party_id, &account_id, &char_id);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_PartyChangeMap_pre ) {
+ int (*preHookFunc) (int *fd, int *party_id, int *account_id, int *char_id, unsigned short *map, int *online, unsigned int *lv);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyChangeMap_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_PartyChangeMap_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &party_id, &account_id, &char_id, &map, &online, &lv);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_PartyChangeMap(fd, party_id, account_id, char_id, map, online, lv);
+ }
+ if( HPMHooks.count.HP_mapif_parse_PartyChangeMap_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *party_id, int *account_id, int *char_id, unsigned short *map, int *online, unsigned int *lv);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyChangeMap_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_PartyChangeMap_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &party_id, &account_id, &char_id, &map, &online, &lv);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_BreakParty(int fd, int party_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_BreakParty_pre ) {
+ int (*preHookFunc) (int *fd, int *party_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_BreakParty_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_BreakParty_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &party_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_BreakParty(fd, party_id);
+ }
+ if( HPMHooks.count.HP_mapif_parse_BreakParty_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *party_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_BreakParty_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_BreakParty_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &party_id);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_PartyMessage(int fd, int party_id, int account_id, char *mes, int len) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_PartyMessage_pre ) {
+ int (*preHookFunc) (int *fd, int *party_id, int *account_id, char *mes, int *len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyMessage_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_PartyMessage_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &party_id, &account_id, mes, &len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_PartyMessage(fd, party_id, account_id, mes, len);
+ }
+ if( HPMHooks.count.HP_mapif_parse_PartyMessage_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *party_id, int *account_id, char *mes, int *len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyMessage_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_PartyMessage_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &party_id, &account_id, mes, &len);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_PartyLeaderChange(int fd, int party_id, int account_id, int char_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_PartyLeaderChange_pre ) {
+ int (*preHookFunc) (int *fd, int *party_id, int *account_id, int *char_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyLeaderChange_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_PartyLeaderChange_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &party_id, &account_id, &char_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_PartyLeaderChange(fd, party_id, account_id, char_id);
+ }
+ if( HPMHooks.count.HP_mapif_parse_PartyLeaderChange_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *party_id, int *account_id, int *char_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_PartyLeaderChange_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_PartyLeaderChange_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &party_id, &account_id, &char_id);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_pet_created(int fd, int account_id, struct s_pet *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_pet_created_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id, struct s_pet *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_pet_created_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_pet_created_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id, p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.pet_created(fd, account_id, p);
+ }
+ if( HPMHooks.count.HP_mapif_pet_created_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id, struct s_pet *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_pet_created_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_pet_created_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id, p);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_pet_info(int fd, int account_id, struct s_pet *p) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_pet_info_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id, struct s_pet *p);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_pet_info_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_pet_info_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id, p);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.pet_info(fd, account_id, p);
+ }
+ if( HPMHooks.count.HP_mapif_pet_info_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id, struct s_pet *p);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_pet_info_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_pet_info_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id, p);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_pet_noinfo(int fd, int account_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_pet_noinfo_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_pet_noinfo_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_pet_noinfo_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.pet_noinfo(fd, account_id);
+ }
+ if( HPMHooks.count.HP_mapif_pet_noinfo_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_pet_noinfo_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_pet_noinfo_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_save_pet_ack(int fd, int account_id, int flag) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_save_pet_ack_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_save_pet_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_save_pet_ack_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.save_pet_ack(fd, account_id, flag);
+ }
+ if( HPMHooks.count.HP_mapif_save_pet_ack_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_save_pet_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_save_pet_ack_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id, &flag);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_delete_pet_ack(int fd, int flag) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_delete_pet_ack_pre ) {
+ int (*preHookFunc) (int *fd, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_delete_pet_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_delete_pet_ack_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.delete_pet_ack(fd, flag);
+ }
+ if( HPMHooks.count.HP_mapif_delete_pet_ack_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_delete_pet_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_delete_pet_ack_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &flag);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id, short pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_create_pet_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id, int *char_id, short *pet_class, short *pet_lv, short *pet_egg_id, short *pet_equip, short *intimate, short *hungry, char *rename_flag, char *incubate, char *pet_name);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_create_pet_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_create_pet_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id, &char_id, &pet_class, &pet_lv, &pet_egg_id, &pet_equip, &intimate, &hungry, &rename_flag, &incubate, pet_name);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.create_pet(fd, account_id, char_id, pet_class, pet_lv, pet_egg_id, pet_equip, intimate, hungry, rename_flag, incubate, pet_name);
+ }
+ if( HPMHooks.count.HP_mapif_create_pet_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id, int *char_id, short *pet_class, short *pet_lv, short *pet_egg_id, short *pet_equip, short *intimate, short *hungry, char *rename_flag, char *incubate, char *pet_name);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_create_pet_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_create_pet_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id, &char_id, &pet_class, &pet_lv, &pet_egg_id, &pet_equip, &intimate, &hungry, &rename_flag, &incubate, pet_name);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_load_pet(int fd, int account_id, int char_id, int pet_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_load_pet_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id, int *char_id, int *pet_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_load_pet_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_load_pet_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id, &char_id, &pet_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.load_pet(fd, account_id, char_id, pet_id);
+ }
+ if( HPMHooks.count.HP_mapif_load_pet_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id, int *char_id, int *pet_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_load_pet_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_load_pet_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id, &char_id, &pet_id);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_save_pet(int fd, int account_id, struct s_pet *data) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_save_pet_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id, struct s_pet *data);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_save_pet_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_save_pet_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id, data);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.save_pet(fd, account_id, data);
+ }
+ if( HPMHooks.count.HP_mapif_save_pet_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id, struct s_pet *data);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_save_pet_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_save_pet_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id, data);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_delete_pet(int fd, int pet_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_delete_pet_pre ) {
+ int (*preHookFunc) (int *fd, int *pet_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_delete_pet_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_delete_pet_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &pet_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.delete_pet(fd, pet_id);
+ }
+ if( HPMHooks.count.HP_mapif_delete_pet_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *pet_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_delete_pet_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_delete_pet_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &pet_id);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_CreatePet(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_CreatePet_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_CreatePet_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_CreatePet_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_CreatePet(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_CreatePet_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_CreatePet_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_CreatePet_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_LoadPet(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_LoadPet_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_LoadPet_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_LoadPet_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_LoadPet(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_LoadPet_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_LoadPet_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_LoadPet_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_SavePet(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_SavePet_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_SavePet_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_SavePet_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_SavePet(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_SavePet_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_SavePet_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_SavePet_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_DeletePet(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_DeletePet_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_DeletePet_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_DeletePet_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_DeletePet(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_DeletePet_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_DeletePet_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_DeletePet_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+struct quest* HP_mapif_quests_fromsql(int char_id, int *count) {
+ int hIndex = 0;
+ struct quest* retVal___ = NULL;
+ if( HPMHooks.count.HP_mapif_quests_fromsql_pre ) {
+ struct quest* (*preHookFunc) (int *char_id, int *count);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_quests_fromsql_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_quests_fromsql_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, count);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.quests_fromsql(char_id, count);
+ }
+ if( HPMHooks.count.HP_mapif_quests_fromsql_post ) {
+ struct quest* (*postHookFunc) (struct quest* retVal___, int *char_id, int *count);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_quests_fromsql_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_quests_fromsql_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, count);
+ }
+ }
+ return retVal___;
+}
+bool HP_mapif_quest_delete(int char_id, int quest_id) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mapif_quest_delete_pre ) {
+ bool (*preHookFunc) (int *char_id, int *quest_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_quest_delete_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_quest_delete_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, &quest_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.quest_delete(char_id, quest_id);
+ }
+ if( HPMHooks.count.HP_mapif_quest_delete_post ) {
+ bool (*postHookFunc) (bool retVal___, int *char_id, int *quest_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_quest_delete_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_quest_delete_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, &quest_id);
+ }
+ }
+ return retVal___;
+}
+bool HP_mapif_quest_add(int char_id, struct quest qd) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mapif_quest_add_pre ) {
+ bool (*preHookFunc) (int *char_id, struct quest *qd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_quest_add_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_quest_add_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, &qd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.quest_add(char_id, qd);
+ }
+ if( HPMHooks.count.HP_mapif_quest_add_post ) {
+ bool (*postHookFunc) (bool retVal___, int *char_id, struct quest *qd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_quest_add_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_quest_add_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, &qd);
+ }
+ }
+ return retVal___;
+}
+bool HP_mapif_quest_update(int char_id, struct quest qd) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mapif_quest_update_pre ) {
+ bool (*preHookFunc) (int *char_id, struct quest *qd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_quest_update_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_quest_update_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, &qd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.quest_update(char_id, qd);
+ }
+ if( HPMHooks.count.HP_mapif_quest_update_post ) {
+ bool (*postHookFunc) (bool retVal___, int *char_id, struct quest *qd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_quest_update_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_quest_update_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, &qd);
+ }
+ }
+ return retVal___;
+}
+void HP_mapif_quest_save_ack(int fd, int char_id, bool success) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_quest_save_ack_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, bool *success);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_quest_save_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_quest_save_ack_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, &success);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.quest_save_ack(fd, char_id, success);
+ }
+ if( HPMHooks.count.HP_mapif_quest_save_ack_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, bool *success);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_quest_save_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_quest_save_ack_post[hIndex].func;
+ postHookFunc(&fd, &char_id, &success);
+ }
+ }
+ return;
+}
+int HP_mapif_parse_quest_save(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_quest_save_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_quest_save_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_quest_save_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_quest_save(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_quest_save_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_quest_save_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_quest_save_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+void HP_mapif_send_quests(int fd, int char_id, struct quest *tmp_questlog, int num_quests) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_send_quests_pre ) {
+ void (*preHookFunc) (int *fd, int *char_id, struct quest *tmp_questlog, int *num_quests);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_send_quests_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_send_quests_pre[hIndex].func;
+ preHookFunc(&fd, &char_id, tmp_questlog, &num_quests);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.send_quests(fd, char_id, tmp_questlog, num_quests);
+ }
+ if( HPMHooks.count.HP_mapif_send_quests_post ) {
+ void (*postHookFunc) (int *fd, int *char_id, struct quest *tmp_questlog, int *num_quests);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_send_quests_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_send_quests_post[hIndex].func;
+ postHookFunc(&fd, &char_id, tmp_questlog, &num_quests);
+ }
+ }
+ return;
+}
+int HP_mapif_parse_quest_load(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_quest_load_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_quest_load_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_quest_load_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_quest_load(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_quest_load_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_quest_load_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_quest_load_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_load_guild_storage(int fd, int account_id, int guild_id, char flag) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_load_guild_storage_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id, int *guild_id, char *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_load_guild_storage_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_load_guild_storage_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id, &guild_id, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.load_guild_storage(fd, account_id, guild_id, flag);
+ }
+ if( HPMHooks.count.HP_mapif_load_guild_storage_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id, int *guild_id, char *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_load_guild_storage_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_load_guild_storage_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id, &guild_id, &flag);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_save_guild_storage_ack(int fd, int account_id, int guild_id, int fail) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_save_guild_storage_ack_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id, int *guild_id, int *fail);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_save_guild_storage_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_save_guild_storage_ack_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id, &guild_id, &fail);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.save_guild_storage_ack(fd, account_id, guild_id, fail);
+ }
+ if( HPMHooks.count.HP_mapif_save_guild_storage_ack_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id, int *guild_id, int *fail);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_save_guild_storage_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_save_guild_storage_ack_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id, &guild_id, &fail);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_LoadGuildStorage(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_LoadGuildStorage_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_LoadGuildStorage_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_LoadGuildStorage_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_LoadGuildStorage(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_LoadGuildStorage_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_LoadGuildStorage_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_LoadGuildStorage_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_SaveGuildStorage(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_SaveGuildStorage_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_SaveGuildStorage_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_SaveGuildStorage_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_SaveGuildStorage(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_SaveGuildStorage_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_SaveGuildStorage_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_SaveGuildStorage_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_itembound_ack(int fd, int aid, int guild_id) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_itembound_ack_pre ) {
+ int (*preHookFunc) (int *fd, int *aid, int *guild_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_itembound_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_itembound_ack_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &aid, &guild_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.itembound_ack(fd, aid, guild_id);
+ }
+ if( HPMHooks.count.HP_mapif_itembound_ack_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *aid, int *guild_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_itembound_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_itembound_ack_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &aid, &guild_id);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_ItemBoundRetrieve_sub(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_ItemBoundRetrieve_sub_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_ItemBoundRetrieve_sub_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_ItemBoundRetrieve_sub_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_ItemBoundRetrieve_sub(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_ItemBoundRetrieve_sub_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_ItemBoundRetrieve_sub_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_ItemBoundRetrieve_sub_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+void HP_mapif_parse_ItemBoundRetrieve(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_ItemBoundRetrieve_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_ItemBoundRetrieve_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_ItemBoundRetrieve_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_ItemBoundRetrieve(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_ItemBoundRetrieve_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_ItemBoundRetrieve_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_ItemBoundRetrieve_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_accinfo(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_accinfo_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_accinfo_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_accinfo_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_accinfo(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_accinfo_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_accinfo_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_accinfo_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_parse_accinfo2_pre ) {
+ void (*preHookFunc) (bool *success, int *map_fd, int *u_fd, int *u_aid, int *account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int *group_id, int *logincount, int *state);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_accinfo2_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_accinfo2_pre[hIndex].func;
+ preHookFunc(&success, &map_fd, &u_fd, &u_aid, &account_id, userid, user_pass, email, last_ip, lastlogin, pin_code, birthdate, &group_id, &logincount, &state);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.parse_accinfo2(success, map_fd, u_fd, u_aid, account_id, userid, user_pass, email, last_ip, lastlogin, pin_code, birthdate, group_id, logincount, state);
+ }
+ if( HPMHooks.count.HP_mapif_parse_accinfo2_post ) {
+ void (*postHookFunc) (bool *success, int *map_fd, int *u_fd, int *u_aid, int *account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int *group_id, int *logincount, int *state);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_accinfo2_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_accinfo2_post[hIndex].func;
+ postHookFunc(&success, &map_fd, &u_fd, &u_aid, &account_id, userid, user_pass, email, last_ip, lastlogin, pin_code, birthdate, &group_id, &logincount, &state);
+ }
+ }
+ return;
+}
+int HP_mapif_broadcast(unsigned char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, int sfd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_broadcast_pre ) {
+ int (*preHookFunc) (unsigned char *mes, int *len, unsigned int *fontColor, short *fontType, short *fontSize, short *fontAlign, short *fontY, int *sfd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_broadcast_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_broadcast_pre[hIndex].func;
+ retVal___ = preHookFunc(mes, &len, &fontColor, &fontType, &fontSize, &fontAlign, &fontY, &sfd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.broadcast(mes, len, fontColor, fontType, fontSize, fontAlign, fontY, sfd);
+ }
+ if( HPMHooks.count.HP_mapif_broadcast_post ) {
+ int (*postHookFunc) (int retVal___, unsigned char *mes, int *len, unsigned int *fontColor, short *fontType, short *fontSize, short *fontAlign, short *fontY, int *sfd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_broadcast_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_broadcast_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, mes, &len, &fontColor, &fontType, &fontSize, &fontAlign, &fontY, &sfd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_wis_message(struct WisData *wd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_wis_message_pre ) {
+ int (*preHookFunc) (struct WisData *wd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_wis_message_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_wis_message_pre[hIndex].func;
+ retVal___ = preHookFunc(wd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.wis_message(wd);
+ }
+ if( HPMHooks.count.HP_mapif_wis_message_post ) {
+ int (*postHookFunc) (int retVal___, struct WisData *wd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_wis_message_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_wis_message_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, wd);
+ }
+ }
+ return retVal___;
+}
+void HP_mapif_wis_response(int fd, unsigned char *src, int flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_wis_response_pre ) {
+ void (*preHookFunc) (int *fd, unsigned char *src, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_wis_response_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_wis_response_pre[hIndex].func;
+ preHookFunc(&fd, src, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.wis_response(fd, src, flag);
+ }
+ if( HPMHooks.count.HP_mapif_wis_response_post ) {
+ void (*postHookFunc) (int *fd, unsigned char *src, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_wis_response_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_wis_response_post[hIndex].func;
+ postHookFunc(&fd, src, &flag);
+ }
+ }
+ return;
+}
+int HP_mapif_wis_end(struct WisData *wd, int flag) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_wis_end_pre ) {
+ int (*preHookFunc) (struct WisData *wd, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_wis_end_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_wis_end_pre[hIndex].func;
+ retVal___ = preHookFunc(wd, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.wis_end(wd, flag);
+ }
+ if( HPMHooks.count.HP_mapif_wis_end_post ) {
+ int (*postHookFunc) (int retVal___, struct WisData *wd, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_wis_end_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_wis_end_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, wd, &flag);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_account_reg_reply(int fd, int account_id, int char_id, int type) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_account_reg_reply_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id, int *char_id, int *type);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_account_reg_reply_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_account_reg_reply_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id, &char_id, &type);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.account_reg_reply(fd, account_id, char_id, type);
+ }
+ if( HPMHooks.count.HP_mapif_account_reg_reply_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id, int *char_id, int *type);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_account_reg_reply_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_account_reg_reply_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id, &char_id, &type);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_disconnectplayer(int fd, int account_id, int char_id, int reason) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_disconnectplayer_pre ) {
+ int (*preHookFunc) (int *fd, int *account_id, int *char_id, int *reason);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_disconnectplayer_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_disconnectplayer_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, &account_id, &char_id, &reason);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.disconnectplayer(fd, account_id, char_id, reason);
+ }
+ if( HPMHooks.count.HP_mapif_disconnectplayer_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, int *account_id, int *char_id, int *reason);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_disconnectplayer_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_disconnectplayer_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, &account_id, &char_id, &reason);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_broadcast(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_broadcast_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_broadcast_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_broadcast_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_broadcast(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_broadcast_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_broadcast_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_broadcast_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_WisRequest(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_WisRequest_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_WisRequest_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_WisRequest_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_WisRequest(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_WisRequest_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_WisRequest_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_WisRequest_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_WisReply(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_WisReply_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_WisReply_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_WisReply_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_WisReply(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_WisReply_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_WisReply_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_WisReply_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_WisToGM(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_WisToGM_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_WisToGM_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_WisToGM_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_WisToGM(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_WisToGM_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_WisToGM_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_WisToGM_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_Registry(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_Registry_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_Registry_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_Registry_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_Registry(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_Registry_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_Registry_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_Registry_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+int HP_mapif_parse_RegistryRequest(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_RegistryRequest_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_RegistryRequest_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_RegistryRequest_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_RegistryRequest(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_RegistryRequest_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_RegistryRequest_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_RegistryRequest_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+void HP_mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, const char *name) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mapif_namechange_ack_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id, int *char_id, int *type, int *flag, const char *name);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_namechange_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_namechange_ack_pre[hIndex].func;
+ preHookFunc(&fd, &account_id, &char_id, &type, &flag, name);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mapif.namechange_ack(fd, account_id, char_id, type, flag, name);
+ }
+ if( HPMHooks.count.HP_mapif_namechange_ack_post ) {
+ void (*postHookFunc) (int *fd, int *account_id, int *char_id, int *type, int *flag, const char *name);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_namechange_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_namechange_ack_post[hIndex].func;
+ postHookFunc(&fd, &account_id, &char_id, &type, &flag, name);
+ }
+ }
+ return;
+}
+int HP_mapif_parse_NameChangeRequest(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_mapif_parse_NameChangeRequest_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_NameChangeRequest_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mapif_parse_NameChangeRequest_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mapif.parse_NameChangeRequest(fd);
+ }
+ if( HPMHooks.count.HP_mapif_parse_NameChangeRequest_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mapif_parse_NameChangeRequest_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mapif_parse_NameChangeRequest_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+/* pincode */
+void HP_pincode_handle(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_pincode_handle_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_handle_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pincode_handle_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.pincode.handle(fd, sd);
+ }
+ if( HPMHooks.count.HP_pincode_handle_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_handle_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pincode_handle_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_pincode_decrypt(unsigned int userSeed, char *pin) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_pincode_decrypt_pre ) {
+ void (*preHookFunc) (unsigned int *userSeed, char *pin);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_decrypt_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pincode_decrypt_pre[hIndex].func;
+ preHookFunc(&userSeed, pin);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.pincode.decrypt(userSeed, pin);
+ }
+ if( HPMHooks.count.HP_pincode_decrypt_post ) {
+ void (*postHookFunc) (unsigned int *userSeed, char *pin);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_decrypt_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pincode_decrypt_post[hIndex].func;
+ postHookFunc(&userSeed, pin);
+ }
+ }
+ return;
+}
+void HP_pincode_error(int account_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_pincode_error_pre ) {
+ void (*preHookFunc) (int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_error_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pincode_error_pre[hIndex].func;
+ preHookFunc(&account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.pincode.error(account_id);
+ }
+ if( HPMHooks.count.HP_pincode_error_post ) {
+ void (*postHookFunc) (int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_error_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pincode_error_post[hIndex].func;
+ postHookFunc(&account_id);
+ }
+ }
+ return;
+}
+void HP_pincode_update(int account_id, char *pin) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_pincode_update_pre ) {
+ void (*preHookFunc) (int *account_id, char *pin);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_update_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pincode_update_pre[hIndex].func;
+ preHookFunc(&account_id, pin);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.pincode.update(account_id, pin);
+ }
+ if( HPMHooks.count.HP_pincode_update_post ) {
+ void (*postHookFunc) (int *account_id, char *pin);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_update_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pincode_update_post[hIndex].func;
+ postHookFunc(&account_id, pin);
+ }
+ }
+ return;
+}
+void HP_pincode_sendstate(int fd, struct char_session_data *sd, uint16 state) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_pincode_sendstate_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd, uint16 *state);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_sendstate_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pincode_sendstate_pre[hIndex].func;
+ preHookFunc(&fd, sd, &state);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.pincode.sendstate(fd, sd, state);
+ }
+ if( HPMHooks.count.HP_pincode_sendstate_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd, uint16 *state);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_sendstate_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pincode_sendstate_post[hIndex].func;
+ postHookFunc(&fd, sd, &state);
+ }
+ }
+ return;
+}
+void HP_pincode_setnew(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_pincode_setnew_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_setnew_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pincode_setnew_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.pincode.setnew(fd, sd);
+ }
+ if( HPMHooks.count.HP_pincode_setnew_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_setnew_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pincode_setnew_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_pincode_change(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_pincode_change_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_change_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pincode_change_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.pincode.change(fd, sd);
+ }
+ if( HPMHooks.count.HP_pincode_change_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_change_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pincode_change_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+int HP_pincode_compare(int fd, struct char_session_data *sd, char *pin) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_pincode_compare_pre ) {
+ int (*preHookFunc) (int *fd, struct char_session_data *sd, char *pin);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_compare_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pincode_compare_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, sd, pin);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.pincode.compare(fd, sd, pin);
+ }
+ if( HPMHooks.count.HP_pincode_compare_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, struct char_session_data *sd, char *pin);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_compare_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pincode_compare_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, sd, pin);
+ }
+ }
+ return retVal___;
+}
+void HP_pincode_check(int fd, struct char_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_pincode_check_pre ) {
+ void (*preHookFunc) (int *fd, struct char_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_check_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pincode_check_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.pincode.check(fd, sd);
+ }
+ if( HPMHooks.count.HP_pincode_check_post ) {
+ void (*postHookFunc) (int *fd, struct char_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_check_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pincode_check_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+bool HP_pincode_config_read(char *w1, char *w2) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_pincode_config_read_pre ) {
+ bool (*preHookFunc) (char *w1, char *w2);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_config_read_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pincode_config_read_pre[hIndex].func;
+ retVal___ = preHookFunc(w1, w2);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.pincode.config_read(w1, w2);
+ }
+ if( HPMHooks.count.HP_pincode_config_read_post ) {
+ bool (*postHookFunc) (bool retVal___, char *w1, char *w2);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pincode_config_read_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pincode_config_read_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, w1, w2);
+ }
+ }
+ return retVal___;
+}
diff --git a/src/plugins/HPMHooking/HPMHooking_char.sources.inc b/src/plugins/HPMHooking/HPMHooking_char.sources.inc
new file mode 100644
index 000000000..00700756c
--- /dev/null
+++ b/src/plugins/HPMHooking/HPMHooking_char.sources.inc
@@ -0,0 +1,22 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+//
+// NOTE: This file was auto-generated and should never be manually edited,
+// as it will get overwritten.
+
+memcpy(&HPMHooks.source.chr, chr, sizeof(struct char_interface));
+memcpy(&HPMHooks.source.geoip, geoip, sizeof(struct geoip_interface));
+memcpy(&HPMHooks.source.inter_auction, inter_auction, sizeof(struct inter_auction_interface));
+memcpy(&HPMHooks.source.inter_elemental, inter_elemental, sizeof(struct inter_elemental_interface));
+memcpy(&HPMHooks.source.inter_guild, inter_guild, sizeof(struct inter_guild_interface));
+memcpy(&HPMHooks.source.inter_homunculus, inter_homunculus, sizeof(struct inter_homunculus_interface));
+memcpy(&HPMHooks.source.inter, inter, sizeof(struct inter_interface));
+memcpy(&HPMHooks.source.inter_mail, inter_mail, sizeof(struct inter_mail_interface));
+memcpy(&HPMHooks.source.inter_mercenary, inter_mercenary, sizeof(struct inter_mercenary_interface));
+memcpy(&HPMHooks.source.inter_party, inter_party, sizeof(struct inter_party_interface));
+memcpy(&HPMHooks.source.inter_pet, inter_pet, sizeof(struct inter_pet_interface));
+memcpy(&HPMHooks.source.inter_quest, inter_quest, sizeof(struct inter_quest_interface));
+memcpy(&HPMHooks.source.inter_storage, inter_storage, sizeof(struct inter_storage_interface));
+memcpy(&HPMHooks.source.loginif, loginif, sizeof(struct loginif_interface));
+memcpy(&HPMHooks.source.mapif, mapif, sizeof(struct mapif_interface));
+memcpy(&HPMHooks.source.pincode, pincode, sizeof(struct pincode_interface));
diff --git a/src/plugins/HPMHooking/HPMHooking_login.GetSymbol.inc b/src/plugins/HPMHooking/HPMHooking_login.GetSymbol.inc
new file mode 100644
index 000000000..3348b5cde
--- /dev/null
+++ b/src/plugins/HPMHooking/HPMHooking_login.GetSymbol.inc
@@ -0,0 +1,7 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+//
+// NOTE: This file was auto-generated and should never be manually edited,
+// as it will get overwritten.
+
+if( !(login = GET_SYMBOL("login") ) ) return false;
diff --git a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc
new file mode 100644
index 000000000..af7e7250c
--- /dev/null
+++ b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc
@@ -0,0 +1,235 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+//
+// NOTE: This file was auto-generated and should never be manually edited,
+// as it will get overwritten.
+
+struct {
+ struct HPMHookPoint *HP_login_mmo_auth_pre;
+ struct HPMHookPoint *HP_login_mmo_auth_post;
+ struct HPMHookPoint *HP_login_mmo_auth_new_pre;
+ struct HPMHookPoint *HP_login_mmo_auth_new_post;
+ struct HPMHookPoint *HP_login_waiting_disconnect_timer_pre;
+ struct HPMHookPoint *HP_login_waiting_disconnect_timer_post;
+ struct HPMHookPoint *HP_login_create_online_user_pre;
+ struct HPMHookPoint *HP_login_create_online_user_post;
+ struct HPMHookPoint *HP_login_add_online_user_pre;
+ struct HPMHookPoint *HP_login_add_online_user_post;
+ struct HPMHookPoint *HP_login_remove_online_user_pre;
+ struct HPMHookPoint *HP_login_remove_online_user_post;
+ struct HPMHookPoint *HP_login_online_db_setoffline_pre;
+ struct HPMHookPoint *HP_login_online_db_setoffline_post;
+ struct HPMHookPoint *HP_login_online_data_cleanup_sub_pre;
+ struct HPMHookPoint *HP_login_online_data_cleanup_sub_post;
+ struct HPMHookPoint *HP_login_online_data_cleanup_pre;
+ struct HPMHookPoint *HP_login_online_data_cleanup_post;
+ struct HPMHookPoint *HP_login_sync_ip_addresses_pre;
+ struct HPMHookPoint *HP_login_sync_ip_addresses_post;
+ struct HPMHookPoint *HP_login_check_encrypted_pre;
+ struct HPMHookPoint *HP_login_check_encrypted_post;
+ struct HPMHookPoint *HP_login_check_password_pre;
+ struct HPMHookPoint *HP_login_check_password_post;
+ struct HPMHookPoint *HP_login_lan_subnetcheck_pre;
+ struct HPMHookPoint *HP_login_lan_subnetcheck_post;
+ struct HPMHookPoint *HP_login_lan_config_read_pre;
+ struct HPMHookPoint *HP_login_lan_config_read_post;
+ struct HPMHookPoint *HP_login_fromchar_accinfo_pre;
+ struct HPMHookPoint *HP_login_fromchar_accinfo_post;
+ struct HPMHookPoint *HP_login_fromchar_account_pre;
+ struct HPMHookPoint *HP_login_fromchar_account_post;
+ struct HPMHookPoint *HP_login_fromchar_account_update_other_pre;
+ struct HPMHookPoint *HP_login_fromchar_account_update_other_post;
+ struct HPMHookPoint *HP_login_fromchar_auth_ack_pre;
+ struct HPMHookPoint *HP_login_fromchar_auth_ack_post;
+ struct HPMHookPoint *HP_login_fromchar_ban_pre;
+ struct HPMHookPoint *HP_login_fromchar_ban_post;
+ struct HPMHookPoint *HP_login_fromchar_change_sex_other_pre;
+ struct HPMHookPoint *HP_login_fromchar_change_sex_other_post;
+ struct HPMHookPoint *HP_login_fromchar_pong_pre;
+ struct HPMHookPoint *HP_login_fromchar_pong_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_auth_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_auth_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_update_users_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_update_users_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_request_change_email_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_request_change_email_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_account_data_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_account_data_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_ping_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_ping_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_change_email_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_change_email_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_account_update_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_account_update_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_ban_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_ban_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_change_sex_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_change_sex_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_account_reg2_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_account_reg2_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_unban_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_unban_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_account_online_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_account_online_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_account_offline_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_account_offline_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_online_accounts_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_online_accounts_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_request_account_reg2_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_request_account_reg2_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_update_wan_ip_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_update_wan_ip_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_all_offline_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_all_offline_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_change_pincode_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_change_pincode_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_wrong_pincode_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_wrong_pincode_post;
+ struct HPMHookPoint *HP_login_fromchar_parse_accinfo_pre;
+ struct HPMHookPoint *HP_login_fromchar_parse_accinfo_post;
+ struct HPMHookPoint *HP_login_parse_fromchar_pre;
+ struct HPMHookPoint *HP_login_parse_fromchar_post;
+ struct HPMHookPoint *HP_login_connection_problem_pre;
+ struct HPMHookPoint *HP_login_connection_problem_post;
+ struct HPMHookPoint *HP_login_kick_pre;
+ struct HPMHookPoint *HP_login_kick_post;
+ struct HPMHookPoint *HP_login_auth_ok_pre;
+ struct HPMHookPoint *HP_login_auth_ok_post;
+ struct HPMHookPoint *HP_login_auth_failed_pre;
+ struct HPMHookPoint *HP_login_auth_failed_post;
+ struct HPMHookPoint *HP_login_login_error_pre;
+ struct HPMHookPoint *HP_login_login_error_post;
+ struct HPMHookPoint *HP_login_parse_ping_pre;
+ struct HPMHookPoint *HP_login_parse_ping_post;
+ struct HPMHookPoint *HP_login_parse_client_md5_pre;
+ struct HPMHookPoint *HP_login_parse_client_md5_post;
+ struct HPMHookPoint *HP_login_parse_client_login_pre;
+ struct HPMHookPoint *HP_login_parse_client_login_post;
+ struct HPMHookPoint *HP_login_send_coding_key_pre;
+ struct HPMHookPoint *HP_login_send_coding_key_post;
+ struct HPMHookPoint *HP_login_parse_request_coding_key_pre;
+ struct HPMHookPoint *HP_login_parse_request_coding_key_post;
+ struct HPMHookPoint *HP_login_char_server_connection_status_pre;
+ struct HPMHookPoint *HP_login_char_server_connection_status_post;
+ struct HPMHookPoint *HP_login_parse_request_connection_pre;
+ struct HPMHookPoint *HP_login_parse_request_connection_post;
+ struct HPMHookPoint *HP_login_parse_login_pre;
+ struct HPMHookPoint *HP_login_parse_login_post;
+} list;
+
+struct {
+ int HP_login_mmo_auth_pre;
+ int HP_login_mmo_auth_post;
+ int HP_login_mmo_auth_new_pre;
+ int HP_login_mmo_auth_new_post;
+ int HP_login_waiting_disconnect_timer_pre;
+ int HP_login_waiting_disconnect_timer_post;
+ int HP_login_create_online_user_pre;
+ int HP_login_create_online_user_post;
+ int HP_login_add_online_user_pre;
+ int HP_login_add_online_user_post;
+ int HP_login_remove_online_user_pre;
+ int HP_login_remove_online_user_post;
+ int HP_login_online_db_setoffline_pre;
+ int HP_login_online_db_setoffline_post;
+ int HP_login_online_data_cleanup_sub_pre;
+ int HP_login_online_data_cleanup_sub_post;
+ int HP_login_online_data_cleanup_pre;
+ int HP_login_online_data_cleanup_post;
+ int HP_login_sync_ip_addresses_pre;
+ int HP_login_sync_ip_addresses_post;
+ int HP_login_check_encrypted_pre;
+ int HP_login_check_encrypted_post;
+ int HP_login_check_password_pre;
+ int HP_login_check_password_post;
+ int HP_login_lan_subnetcheck_pre;
+ int HP_login_lan_subnetcheck_post;
+ int HP_login_lan_config_read_pre;
+ int HP_login_lan_config_read_post;
+ int HP_login_fromchar_accinfo_pre;
+ int HP_login_fromchar_accinfo_post;
+ int HP_login_fromchar_account_pre;
+ int HP_login_fromchar_account_post;
+ int HP_login_fromchar_account_update_other_pre;
+ int HP_login_fromchar_account_update_other_post;
+ int HP_login_fromchar_auth_ack_pre;
+ int HP_login_fromchar_auth_ack_post;
+ int HP_login_fromchar_ban_pre;
+ int HP_login_fromchar_ban_post;
+ int HP_login_fromchar_change_sex_other_pre;
+ int HP_login_fromchar_change_sex_other_post;
+ int HP_login_fromchar_pong_pre;
+ int HP_login_fromchar_pong_post;
+ int HP_login_fromchar_parse_auth_pre;
+ int HP_login_fromchar_parse_auth_post;
+ int HP_login_fromchar_parse_update_users_pre;
+ int HP_login_fromchar_parse_update_users_post;
+ int HP_login_fromchar_parse_request_change_email_pre;
+ int HP_login_fromchar_parse_request_change_email_post;
+ int HP_login_fromchar_parse_account_data_pre;
+ int HP_login_fromchar_parse_account_data_post;
+ int HP_login_fromchar_parse_ping_pre;
+ int HP_login_fromchar_parse_ping_post;
+ int HP_login_fromchar_parse_change_email_pre;
+ int HP_login_fromchar_parse_change_email_post;
+ int HP_login_fromchar_parse_account_update_pre;
+ int HP_login_fromchar_parse_account_update_post;
+ int HP_login_fromchar_parse_ban_pre;
+ int HP_login_fromchar_parse_ban_post;
+ int HP_login_fromchar_parse_change_sex_pre;
+ int HP_login_fromchar_parse_change_sex_post;
+ int HP_login_fromchar_parse_account_reg2_pre;
+ int HP_login_fromchar_parse_account_reg2_post;
+ int HP_login_fromchar_parse_unban_pre;
+ int HP_login_fromchar_parse_unban_post;
+ int HP_login_fromchar_parse_account_online_pre;
+ int HP_login_fromchar_parse_account_online_post;
+ int HP_login_fromchar_parse_account_offline_pre;
+ int HP_login_fromchar_parse_account_offline_post;
+ int HP_login_fromchar_parse_online_accounts_pre;
+ int HP_login_fromchar_parse_online_accounts_post;
+ int HP_login_fromchar_parse_request_account_reg2_pre;
+ int HP_login_fromchar_parse_request_account_reg2_post;
+ int HP_login_fromchar_parse_update_wan_ip_pre;
+ int HP_login_fromchar_parse_update_wan_ip_post;
+ int HP_login_fromchar_parse_all_offline_pre;
+ int HP_login_fromchar_parse_all_offline_post;
+ int HP_login_fromchar_parse_change_pincode_pre;
+ int HP_login_fromchar_parse_change_pincode_post;
+ int HP_login_fromchar_parse_wrong_pincode_pre;
+ int HP_login_fromchar_parse_wrong_pincode_post;
+ int HP_login_fromchar_parse_accinfo_pre;
+ int HP_login_fromchar_parse_accinfo_post;
+ int HP_login_parse_fromchar_pre;
+ int HP_login_parse_fromchar_post;
+ int HP_login_connection_problem_pre;
+ int HP_login_connection_problem_post;
+ int HP_login_kick_pre;
+ int HP_login_kick_post;
+ int HP_login_auth_ok_pre;
+ int HP_login_auth_ok_post;
+ int HP_login_auth_failed_pre;
+ int HP_login_auth_failed_post;
+ int HP_login_login_error_pre;
+ int HP_login_login_error_post;
+ int HP_login_parse_ping_pre;
+ int HP_login_parse_ping_post;
+ int HP_login_parse_client_md5_pre;
+ int HP_login_parse_client_md5_post;
+ int HP_login_parse_client_login_pre;
+ int HP_login_parse_client_login_post;
+ int HP_login_send_coding_key_pre;
+ int HP_login_send_coding_key_post;
+ int HP_login_parse_request_coding_key_pre;
+ int HP_login_parse_request_coding_key_post;
+ int HP_login_char_server_connection_status_pre;
+ int HP_login_char_server_connection_status_post;
+ int HP_login_parse_request_connection_pre;
+ int HP_login_parse_request_connection_post;
+ int HP_login_parse_login_pre;
+ int HP_login_parse_login_post;
+} count;
+
+struct {
+ struct login_interface login;
+} source;
diff --git a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc
new file mode 100644
index 000000000..a4a9db119
--- /dev/null
+++ b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc
@@ -0,0 +1,66 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+//
+// NOTE: This file was auto-generated and should never be manually edited,
+// as it will get overwritten.
+
+struct HookingPointData HookingPoints[] = {
+/* login */
+ { HP_POP(login->mmo_auth, HP_login_mmo_auth) },
+ { HP_POP(login->mmo_auth_new, HP_login_mmo_auth_new) },
+ { HP_POP(login->waiting_disconnect_timer, HP_login_waiting_disconnect_timer) },
+ { HP_POP(login->create_online_user, HP_login_create_online_user) },
+ { HP_POP(login->add_online_user, HP_login_add_online_user) },
+ { HP_POP(login->remove_online_user, HP_login_remove_online_user) },
+ { HP_POP(login->online_db_setoffline, HP_login_online_db_setoffline) },
+ { HP_POP(login->online_data_cleanup_sub, HP_login_online_data_cleanup_sub) },
+ { HP_POP(login->online_data_cleanup, HP_login_online_data_cleanup) },
+ { HP_POP(login->sync_ip_addresses, HP_login_sync_ip_addresses) },
+ { HP_POP(login->check_encrypted, HP_login_check_encrypted) },
+ { HP_POP(login->check_password, HP_login_check_password) },
+ { HP_POP(login->lan_subnetcheck, HP_login_lan_subnetcheck) },
+ { HP_POP(login->lan_config_read, HP_login_lan_config_read) },
+ { HP_POP(login->fromchar_accinfo, HP_login_fromchar_accinfo) },
+ { HP_POP(login->fromchar_account, HP_login_fromchar_account) },
+ { HP_POP(login->fromchar_account_update_other, HP_login_fromchar_account_update_other) },
+ { HP_POP(login->fromchar_auth_ack, HP_login_fromchar_auth_ack) },
+ { HP_POP(login->fromchar_ban, HP_login_fromchar_ban) },
+ { HP_POP(login->fromchar_change_sex_other, HP_login_fromchar_change_sex_other) },
+ { HP_POP(login->fromchar_pong, HP_login_fromchar_pong) },
+ { HP_POP(login->fromchar_parse_auth, HP_login_fromchar_parse_auth) },
+ { HP_POP(login->fromchar_parse_update_users, HP_login_fromchar_parse_update_users) },
+ { HP_POP(login->fromchar_parse_request_change_email, HP_login_fromchar_parse_request_change_email) },
+ { HP_POP(login->fromchar_parse_account_data, HP_login_fromchar_parse_account_data) },
+ { HP_POP(login->fromchar_parse_ping, HP_login_fromchar_parse_ping) },
+ { HP_POP(login->fromchar_parse_change_email, HP_login_fromchar_parse_change_email) },
+ { HP_POP(login->fromchar_parse_account_update, HP_login_fromchar_parse_account_update) },
+ { HP_POP(login->fromchar_parse_ban, HP_login_fromchar_parse_ban) },
+ { HP_POP(login->fromchar_parse_change_sex, HP_login_fromchar_parse_change_sex) },
+ { HP_POP(login->fromchar_parse_account_reg2, HP_login_fromchar_parse_account_reg2) },
+ { HP_POP(login->fromchar_parse_unban, HP_login_fromchar_parse_unban) },
+ { HP_POP(login->fromchar_parse_account_online, HP_login_fromchar_parse_account_online) },
+ { HP_POP(login->fromchar_parse_account_offline, HP_login_fromchar_parse_account_offline) },
+ { HP_POP(login->fromchar_parse_online_accounts, HP_login_fromchar_parse_online_accounts) },
+ { HP_POP(login->fromchar_parse_request_account_reg2, HP_login_fromchar_parse_request_account_reg2) },
+ { HP_POP(login->fromchar_parse_update_wan_ip, HP_login_fromchar_parse_update_wan_ip) },
+ { HP_POP(login->fromchar_parse_all_offline, HP_login_fromchar_parse_all_offline) },
+ { HP_POP(login->fromchar_parse_change_pincode, HP_login_fromchar_parse_change_pincode) },
+ { HP_POP(login->fromchar_parse_wrong_pincode, HP_login_fromchar_parse_wrong_pincode) },
+ { HP_POP(login->fromchar_parse_accinfo, HP_login_fromchar_parse_accinfo) },
+ { HP_POP(login->parse_fromchar, HP_login_parse_fromchar) },
+ { HP_POP(login->connection_problem, HP_login_connection_problem) },
+ { HP_POP(login->kick, HP_login_kick) },
+ { HP_POP(login->auth_ok, HP_login_auth_ok) },
+ { HP_POP(login->auth_failed, HP_login_auth_failed) },
+ { HP_POP(login->login_error, HP_login_login_error) },
+ { HP_POP(login->parse_ping, HP_login_parse_ping) },
+ { HP_POP(login->parse_client_md5, HP_login_parse_client_md5) },
+ { HP_POP(login->parse_client_login, HP_login_parse_client_login) },
+ { HP_POP(login->send_coding_key, HP_login_send_coding_key) },
+ { HP_POP(login->parse_request_coding_key, HP_login_parse_request_coding_key) },
+ { HP_POP(login->char_server_connection_status, HP_login_char_server_connection_status) },
+ { HP_POP(login->parse_request_connection, HP_login_parse_request_connection) },
+ { HP_POP(login->parse_login, HP_login_parse_login) },
+};
+
+int HookingPointsLenMax = 42;
diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc
new file mode 100644
index 000000000..1ebd9fd1a
--- /dev/null
+++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc
@@ -0,0 +1,1473 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+//
+// NOTE: This file was auto-generated and should never be manually edited,
+// as it will get overwritten.
+
+/* login */
+int HP_login_mmo_auth(struct login_session_data *sd, bool isServer) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_login_mmo_auth_pre ) {
+ int (*preHookFunc) (struct login_session_data *sd, bool *isServer);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_mmo_auth_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_mmo_auth_pre[hIndex].func;
+ retVal___ = preHookFunc(sd, &isServer);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.mmo_auth(sd, isServer);
+ }
+ if( HPMHooks.count.HP_login_mmo_auth_post ) {
+ int (*postHookFunc) (int retVal___, struct login_session_data *sd, bool *isServer);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_mmo_auth_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_mmo_auth_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, sd, &isServer);
+ }
+ }
+ return retVal___;
+}
+int HP_login_mmo_auth_new(const char *userid, const char *pass, const char sex, const char *last_ip) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_login_mmo_auth_new_pre ) {
+ int (*preHookFunc) (const char *userid, const char *pass, const char *sex, const char *last_ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_mmo_auth_new_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_mmo_auth_new_pre[hIndex].func;
+ retVal___ = preHookFunc(userid, pass, &sex, last_ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.mmo_auth_new(userid, pass, sex, last_ip);
+ }
+ if( HPMHooks.count.HP_login_mmo_auth_new_post ) {
+ int (*postHookFunc) (int retVal___, const char *userid, const char *pass, const char *sex, const char *last_ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_mmo_auth_new_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_mmo_auth_new_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, userid, pass, &sex, last_ip);
+ }
+ }
+ return retVal___;
+}
+int HP_login_waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_login_waiting_disconnect_timer_pre ) {
+ int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_waiting_disconnect_timer_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_waiting_disconnect_timer_pre[hIndex].func;
+ retVal___ = preHookFunc(&tid, &tick, &id, &data);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.waiting_disconnect_timer(tid, tick, id, data);
+ }
+ if( HPMHooks.count.HP_login_waiting_disconnect_timer_post ) {
+ int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_waiting_disconnect_timer_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_waiting_disconnect_timer_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data);
+ }
+ }
+ return retVal___;
+}
+DBData HP_login_create_online_user(DBKey key, va_list args) {
+ int hIndex = 0;
+ DBData retVal___;
+ memset(&retVal___, '\0', sizeof(DBData));
+ if( HPMHooks.count.HP_login_create_online_user_pre ) {
+ DBData (*preHookFunc) (DBKey *key, va_list args);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_create_online_user_pre; hIndex++ ) {
+ va_list args___copy; va_copy(args___copy, args);
+ preHookFunc = HPMHooks.list.HP_login_create_online_user_pre[hIndex].func;
+ retVal___ = preHookFunc(&key, args___copy);
+ va_end(args___copy);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ va_list args___copy; va_copy(args___copy, args);
+ retVal___ = HPMHooks.source.login.create_online_user(key, args___copy);
+ va_end(args___copy);
+ }
+ if( HPMHooks.count.HP_login_create_online_user_post ) {
+ DBData (*postHookFunc) (DBData retVal___, DBKey *key, va_list args);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_create_online_user_post; hIndex++ ) {
+ va_list args___copy; va_copy(args___copy, args);
+ postHookFunc = HPMHooks.list.HP_login_create_online_user_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &key, args___copy);
+ va_end(args___copy);
+ }
+ }
+ return retVal___;
+}
+struct online_login_data* HP_login_add_online_user(int char_server, int account_id) {
+ int hIndex = 0;
+ struct online_login_data* retVal___ = NULL;
+ if( HPMHooks.count.HP_login_add_online_user_pre ) {
+ struct online_login_data* (*preHookFunc) (int *char_server, int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_add_online_user_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_add_online_user_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_server, &account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.add_online_user(char_server, account_id);
+ }
+ if( HPMHooks.count.HP_login_add_online_user_post ) {
+ struct online_login_data* (*postHookFunc) (struct online_login_data* retVal___, int *char_server, int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_add_online_user_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_add_online_user_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_server, &account_id);
+ }
+ }
+ return retVal___;
+}
+void HP_login_remove_online_user(int account_id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_remove_online_user_pre ) {
+ void (*preHookFunc) (int *account_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_remove_online_user_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_remove_online_user_pre[hIndex].func;
+ preHookFunc(&account_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.remove_online_user(account_id);
+ }
+ if( HPMHooks.count.HP_login_remove_online_user_post ) {
+ void (*postHookFunc) (int *account_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_remove_online_user_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_remove_online_user_post[hIndex].func;
+ postHookFunc(&account_id);
+ }
+ }
+ return;
+}
+int HP_login_online_db_setoffline(DBKey key, DBData *data, va_list ap) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_login_online_db_setoffline_pre ) {
+ int (*preHookFunc) (DBKey *key, DBData *data, va_list ap);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_online_db_setoffline_pre; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ preHookFunc = HPMHooks.list.HP_login_online_db_setoffline_pre[hIndex].func;
+ retVal___ = preHookFunc(&key, data, 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.login.online_db_setoffline(key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ if( HPMHooks.count.HP_login_online_db_setoffline_post ) {
+ int (*postHookFunc) (int retVal___, DBKey *key, DBData *data, va_list ap);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_online_db_setoffline_post; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ postHookFunc = HPMHooks.list.HP_login_online_db_setoffline_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ }
+ return retVal___;
+}
+int HP_login_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_login_online_data_cleanup_sub_pre ) {
+ int (*preHookFunc) (DBKey *key, DBData *data, va_list ap);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_online_data_cleanup_sub_pre; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ preHookFunc = HPMHooks.list.HP_login_online_data_cleanup_sub_pre[hIndex].func;
+ retVal___ = preHookFunc(&key, data, 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.login.online_data_cleanup_sub(key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ if( HPMHooks.count.HP_login_online_data_cleanup_sub_post ) {
+ int (*postHookFunc) (int retVal___, DBKey *key, DBData *data, va_list ap);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_online_data_cleanup_sub_post; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ postHookFunc = HPMHooks.list.HP_login_online_data_cleanup_sub_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ }
+ return retVal___;
+}
+int HP_login_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_login_online_data_cleanup_pre ) {
+ int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_online_data_cleanup_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_online_data_cleanup_pre[hIndex].func;
+ retVal___ = preHookFunc(&tid, &tick, &id, &data);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.online_data_cleanup(tid, tick, id, data);
+ }
+ if( HPMHooks.count.HP_login_online_data_cleanup_post ) {
+ int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_online_data_cleanup_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_online_data_cleanup_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data);
+ }
+ }
+ return retVal___;
+}
+int HP_login_sync_ip_addresses(int tid, int64 tick, int id, intptr_t data) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_login_sync_ip_addresses_pre ) {
+ int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_sync_ip_addresses_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_sync_ip_addresses_pre[hIndex].func;
+ retVal___ = preHookFunc(&tid, &tick, &id, &data);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.sync_ip_addresses(tid, tick, id, data);
+ }
+ if( HPMHooks.count.HP_login_sync_ip_addresses_post ) {
+ int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_sync_ip_addresses_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_sync_ip_addresses_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data);
+ }
+ }
+ return retVal___;
+}
+bool HP_login_check_encrypted(const char *str1, const char *str2, const char *passwd) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_login_check_encrypted_pre ) {
+ bool (*preHookFunc) (const char *str1, const char *str2, const char *passwd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_check_encrypted_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_check_encrypted_pre[hIndex].func;
+ retVal___ = preHookFunc(str1, str2, passwd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.check_encrypted(str1, str2, passwd);
+ }
+ if( HPMHooks.count.HP_login_check_encrypted_post ) {
+ bool (*postHookFunc) (bool retVal___, const char *str1, const char *str2, const char *passwd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_check_encrypted_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_check_encrypted_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, str1, str2, passwd);
+ }
+ }
+ return retVal___;
+}
+bool HP_login_check_password(const char *md5key, int passwdenc, const char *passwd, const char *refpass) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_login_check_password_pre ) {
+ bool (*preHookFunc) (const char *md5key, int *passwdenc, const char *passwd, const char *refpass);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_check_password_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_check_password_pre[hIndex].func;
+ retVal___ = preHookFunc(md5key, &passwdenc, passwd, refpass);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.check_password(md5key, passwdenc, passwd, refpass);
+ }
+ if( HPMHooks.count.HP_login_check_password_post ) {
+ bool (*postHookFunc) (bool retVal___, const char *md5key, int *passwdenc, const char *passwd, const char *refpass);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_check_password_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_check_password_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, md5key, &passwdenc, passwd, refpass);
+ }
+ }
+ return retVal___;
+}
+int HP_login_lan_subnetcheck(uint32 ip) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_login_lan_subnetcheck_pre ) {
+ int (*preHookFunc) (uint32 *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_lan_subnetcheck_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_lan_subnetcheck_pre[hIndex].func;
+ retVal___ = preHookFunc(&ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.lan_subnetcheck(ip);
+ }
+ if( HPMHooks.count.HP_login_lan_subnetcheck_post ) {
+ int (*postHookFunc) (int retVal___, uint32 *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_lan_subnetcheck_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_lan_subnetcheck_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &ip);
+ }
+ }
+ return retVal___;
+}
+int HP_login_lan_config_read(const char *lancfgName) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_login_lan_config_read_pre ) {
+ int (*preHookFunc) (const char *lancfgName);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_lan_config_read_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_lan_config_read_pre[hIndex].func;
+ retVal___ = preHookFunc(lancfgName);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.lan_config_read(lancfgName);
+ }
+ if( HPMHooks.count.HP_login_lan_config_read_post ) {
+ int (*postHookFunc) (int retVal___, const char *lancfgName);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_lan_config_read_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_lan_config_read_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, lancfgName);
+ }
+ }
+ return retVal___;
+}
+void HP_login_fromchar_accinfo(int fd, int account_id, int u_fd, int u_aid, int u_group, int map_fd, struct mmo_account *acc) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_accinfo_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id, int *u_fd, int *u_aid, int *u_group, int *map_fd, struct mmo_account *acc);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_accinfo_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_accinfo_pre[hIndex].func;
+ preHookFunc(&fd, &account_id, &u_fd, &u_aid, &u_group, &map_fd, acc);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_accinfo(fd, account_id, u_fd, u_aid, u_group, map_fd, acc);
+ }
+ if( HPMHooks.count.HP_login_fromchar_accinfo_post ) {
+ void (*postHookFunc) (int *fd, int *account_id, int *u_fd, int *u_aid, int *u_group, int *map_fd, struct mmo_account *acc);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_accinfo_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_accinfo_post[hIndex].func;
+ postHookFunc(&fd, &account_id, &u_fd, &u_aid, &u_group, &map_fd, acc);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_account(int fd, int account_id, struct mmo_account *acc) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_account_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id, struct mmo_account *acc);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_account_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_account_pre[hIndex].func;
+ preHookFunc(&fd, &account_id, acc);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_account(fd, account_id, acc);
+ }
+ if( HPMHooks.count.HP_login_fromchar_account_post ) {
+ void (*postHookFunc) (int *fd, int *account_id, struct mmo_account *acc);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_account_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_account_post[hIndex].func;
+ postHookFunc(&fd, &account_id, acc);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_account_update_other(int account_id, unsigned int state) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_account_update_other_pre ) {
+ void (*preHookFunc) (int *account_id, unsigned int *state);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_account_update_other_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_account_update_other_pre[hIndex].func;
+ preHookFunc(&account_id, &state);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_account_update_other(account_id, state);
+ }
+ if( HPMHooks.count.HP_login_fromchar_account_update_other_post ) {
+ void (*postHookFunc) (int *account_id, unsigned int *state);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_account_update_other_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_account_update_other_post[hIndex].func;
+ postHookFunc(&account_id, &state);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_auth_ack(int fd, int account_id, uint32 login_id1, uint32 login_id2, uint8 sex, int request_id, struct login_auth_node *node) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_auth_ack_pre ) {
+ void (*preHookFunc) (int *fd, int *account_id, uint32 *login_id1, uint32 *login_id2, uint8 *sex, int *request_id, struct login_auth_node *node);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_auth_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_auth_ack_pre[hIndex].func;
+ preHookFunc(&fd, &account_id, &login_id1, &login_id2, &sex, &request_id, node);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, node);
+ }
+ if( HPMHooks.count.HP_login_fromchar_auth_ack_post ) {
+ void (*postHookFunc) (int *fd, int *account_id, uint32 *login_id1, uint32 *login_id2, uint8 *sex, int *request_id, struct login_auth_node *node);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_auth_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_auth_ack_post[hIndex].func;
+ postHookFunc(&fd, &account_id, &login_id1, &login_id2, &sex, &request_id, node);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_ban(int account_id, time_t timestamp) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_ban_pre ) {
+ void (*preHookFunc) (int *account_id, time_t *timestamp);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_ban_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_ban_pre[hIndex].func;
+ preHookFunc(&account_id, &timestamp);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_ban(account_id, timestamp);
+ }
+ if( HPMHooks.count.HP_login_fromchar_ban_post ) {
+ void (*postHookFunc) (int *account_id, time_t *timestamp);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_ban_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_ban_post[hIndex].func;
+ postHookFunc(&account_id, &timestamp);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_change_sex_other(int account_id, char sex) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_change_sex_other_pre ) {
+ void (*preHookFunc) (int *account_id, char *sex);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_change_sex_other_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_change_sex_other_pre[hIndex].func;
+ preHookFunc(&account_id, &sex);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_change_sex_other(account_id, sex);
+ }
+ if( HPMHooks.count.HP_login_fromchar_change_sex_other_post ) {
+ void (*postHookFunc) (int *account_id, char *sex);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_change_sex_other_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_change_sex_other_post[hIndex].func;
+ postHookFunc(&account_id, &sex);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_pong(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_pong_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_pong_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_pong_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_pong(fd);
+ }
+ if( HPMHooks.count.HP_login_fromchar_pong_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_pong_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_pong_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_auth(int fd, int id, const char *ip) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_auth_pre ) {
+ void (*preHookFunc) (int *fd, int *id, const char *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_auth_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_auth_pre[hIndex].func;
+ preHookFunc(&fd, &id, ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_auth(fd, id, ip);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_auth_post ) {
+ void (*postHookFunc) (int *fd, int *id, const char *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_auth_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_auth_post[hIndex].func;
+ postHookFunc(&fd, &id, ip);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_update_users(int fd, int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_update_users_pre ) {
+ void (*preHookFunc) (int *fd, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_update_users_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_update_users_pre[hIndex].func;
+ preHookFunc(&fd, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_update_users(fd, id);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_update_users_post ) {
+ void (*postHookFunc) (int *fd, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_update_users_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_update_users_post[hIndex].func;
+ postHookFunc(&fd, &id);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_request_change_email(int fd, int id, const char *ip) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_request_change_email_pre ) {
+ void (*preHookFunc) (int *fd, int *id, const char *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_request_change_email_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_request_change_email_pre[hIndex].func;
+ preHookFunc(&fd, &id, ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_request_change_email(fd, id, ip);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_request_change_email_post ) {
+ void (*postHookFunc) (int *fd, int *id, const char *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_request_change_email_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_request_change_email_post[hIndex].func;
+ postHookFunc(&fd, &id, ip);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_account_data(int fd, int id, const char *ip) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_account_data_pre ) {
+ void (*preHookFunc) (int *fd, int *id, const char *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_data_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_data_pre[hIndex].func;
+ preHookFunc(&fd, &id, ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_account_data(fd, id, ip);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_account_data_post ) {
+ void (*postHookFunc) (int *fd, int *id, const char *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_data_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_data_post[hIndex].func;
+ postHookFunc(&fd, &id, ip);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_ping(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_ping_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_ping_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_ping_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_ping(fd);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_ping_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_ping_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_ping_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_change_email(int fd, int id, const char *ip) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_change_email_pre ) {
+ void (*preHookFunc) (int *fd, int *id, const char *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_change_email_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_change_email_pre[hIndex].func;
+ preHookFunc(&fd, &id, ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_change_email(fd, id, ip);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_change_email_post ) {
+ void (*postHookFunc) (int *fd, int *id, const char *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_change_email_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_change_email_post[hIndex].func;
+ postHookFunc(&fd, &id, ip);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_account_update(int fd, int id, const char *ip) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_account_update_pre ) {
+ void (*preHookFunc) (int *fd, int *id, const char *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_update_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_update_pre[hIndex].func;
+ preHookFunc(&fd, &id, ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_account_update(fd, id, ip);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_account_update_post ) {
+ void (*postHookFunc) (int *fd, int *id, const char *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_update_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_update_post[hIndex].func;
+ postHookFunc(&fd, &id, ip);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_ban(int fd, int id, const char *ip) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_ban_pre ) {
+ void (*preHookFunc) (int *fd, int *id, const char *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_ban_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_ban_pre[hIndex].func;
+ preHookFunc(&fd, &id, ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_ban(fd, id, ip);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_ban_post ) {
+ void (*postHookFunc) (int *fd, int *id, const char *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_ban_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_ban_post[hIndex].func;
+ postHookFunc(&fd, &id, ip);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_change_sex(int fd, int id, const char *ip) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_change_sex_pre ) {
+ void (*preHookFunc) (int *fd, int *id, const char *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_change_sex_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_change_sex_pre[hIndex].func;
+ preHookFunc(&fd, &id, ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_change_sex(fd, id, ip);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_change_sex_post ) {
+ void (*postHookFunc) (int *fd, int *id, const char *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_change_sex_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_change_sex_post[hIndex].func;
+ postHookFunc(&fd, &id, ip);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_account_reg2(int fd, int id, const char *ip) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_account_reg2_pre ) {
+ void (*preHookFunc) (int *fd, int *id, const char *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_reg2_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_reg2_pre[hIndex].func;
+ preHookFunc(&fd, &id, ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_account_reg2(fd, id, ip);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_account_reg2_post ) {
+ void (*postHookFunc) (int *fd, int *id, const char *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_reg2_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_reg2_post[hIndex].func;
+ postHookFunc(&fd, &id, ip);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_unban(int fd, int id, const char *ip) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_unban_pre ) {
+ void (*preHookFunc) (int *fd, int *id, const char *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_unban_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_unban_pre[hIndex].func;
+ preHookFunc(&fd, &id, ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_unban(fd, id, ip);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_unban_post ) {
+ void (*postHookFunc) (int *fd, int *id, const char *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_unban_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_unban_post[hIndex].func;
+ postHookFunc(&fd, &id, ip);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_account_online(int fd, int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_account_online_pre ) {
+ void (*preHookFunc) (int *fd, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_online_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_online_pre[hIndex].func;
+ preHookFunc(&fd, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_account_online(fd, id);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_account_online_post ) {
+ void (*postHookFunc) (int *fd, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_online_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_online_post[hIndex].func;
+ postHookFunc(&fd, &id);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_account_offline(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_account_offline_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_offline_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_offline_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_account_offline(fd);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_account_offline_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_offline_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_offline_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_online_accounts(int fd, int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_online_accounts_pre ) {
+ void (*preHookFunc) (int *fd, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_online_accounts_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_online_accounts_pre[hIndex].func;
+ preHookFunc(&fd, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_online_accounts(fd, id);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_online_accounts_post ) {
+ void (*postHookFunc) (int *fd, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_online_accounts_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_online_accounts_post[hIndex].func;
+ postHookFunc(&fd, &id);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_request_account_reg2(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_request_account_reg2_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_request_account_reg2_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_request_account_reg2_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_request_account_reg2(fd);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_request_account_reg2_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_request_account_reg2_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_request_account_reg2_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_update_wan_ip(int fd, int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_update_wan_ip_pre ) {
+ void (*preHookFunc) (int *fd, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_update_wan_ip_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_update_wan_ip_pre[hIndex].func;
+ preHookFunc(&fd, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_update_wan_ip(fd, id);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_update_wan_ip_post ) {
+ void (*postHookFunc) (int *fd, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_update_wan_ip_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_update_wan_ip_post[hIndex].func;
+ postHookFunc(&fd, &id);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_all_offline(int fd, int id) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_all_offline_pre ) {
+ void (*preHookFunc) (int *fd, int *id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_all_offline_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_all_offline_pre[hIndex].func;
+ preHookFunc(&fd, &id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_all_offline(fd, id);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_all_offline_post ) {
+ void (*postHookFunc) (int *fd, int *id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_all_offline_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_all_offline_post[hIndex].func;
+ postHookFunc(&fd, &id);
+ }
+ }
+ return;
+}
+void HP_login_fromchar_parse_change_pincode(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_change_pincode_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_change_pincode_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_change_pincode_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_change_pincode(fd);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_change_pincode_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_change_pincode_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_change_pincode_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+bool HP_login_fromchar_parse_wrong_pincode(int fd) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_login_fromchar_parse_wrong_pincode_pre ) {
+ bool (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_wrong_pincode_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_wrong_pincode_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.fromchar_parse_wrong_pincode(fd);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_wrong_pincode_post ) {
+ bool (*postHookFunc) (bool retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_wrong_pincode_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_wrong_pincode_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+void HP_login_fromchar_parse_accinfo(int fd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_fromchar_parse_accinfo_pre ) {
+ void (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_accinfo_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_fromchar_parse_accinfo_pre[hIndex].func;
+ preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.fromchar_parse_accinfo(fd);
+ }
+ if( HPMHooks.count.HP_login_fromchar_parse_accinfo_post ) {
+ void (*postHookFunc) (int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_accinfo_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_fromchar_parse_accinfo_post[hIndex].func;
+ postHookFunc(&fd);
+ }
+ }
+ return;
+}
+int HP_login_parse_fromchar(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_login_parse_fromchar_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_fromchar_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_parse_fromchar_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.parse_fromchar(fd);
+ }
+ if( HPMHooks.count.HP_login_parse_fromchar_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_fromchar_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_parse_fromchar_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
+void HP_login_connection_problem(int fd, uint8 status) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_connection_problem_pre ) {
+ void (*preHookFunc) (int *fd, uint8 *status);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_connection_problem_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_connection_problem_pre[hIndex].func;
+ preHookFunc(&fd, &status);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.connection_problem(fd, status);
+ }
+ if( HPMHooks.count.HP_login_connection_problem_post ) {
+ void (*postHookFunc) (int *fd, uint8 *status);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_connection_problem_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_connection_problem_post[hIndex].func;
+ postHookFunc(&fd, &status);
+ }
+ }
+ return;
+}
+void HP_login_kick(struct login_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_kick_pre ) {
+ void (*preHookFunc) (struct login_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_kick_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_kick_pre[hIndex].func;
+ preHookFunc(sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.kick(sd);
+ }
+ if( HPMHooks.count.HP_login_kick_post ) {
+ void (*postHookFunc) (struct login_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_kick_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_kick_post[hIndex].func;
+ postHookFunc(sd);
+ }
+ }
+ return;
+}
+void HP_login_auth_ok(struct login_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_auth_ok_pre ) {
+ void (*preHookFunc) (struct login_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_auth_ok_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_auth_ok_pre[hIndex].func;
+ preHookFunc(sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.auth_ok(sd);
+ }
+ if( HPMHooks.count.HP_login_auth_ok_post ) {
+ void (*postHookFunc) (struct login_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_auth_ok_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_auth_ok_post[hIndex].func;
+ postHookFunc(sd);
+ }
+ }
+ return;
+}
+void HP_login_auth_failed(struct login_session_data *sd, int result) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_auth_failed_pre ) {
+ void (*preHookFunc) (struct login_session_data *sd, int *result);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_auth_failed_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_auth_failed_pre[hIndex].func;
+ preHookFunc(sd, &result);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.auth_failed(sd, result);
+ }
+ if( HPMHooks.count.HP_login_auth_failed_post ) {
+ void (*postHookFunc) (struct login_session_data *sd, int *result);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_auth_failed_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_auth_failed_post[hIndex].func;
+ postHookFunc(sd, &result);
+ }
+ }
+ return;
+}
+void HP_login_login_error(int fd, uint8 status) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_login_error_pre ) {
+ void (*preHookFunc) (int *fd, uint8 *status);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_login_error_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_login_error_pre[hIndex].func;
+ preHookFunc(&fd, &status);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.login_error(fd, status);
+ }
+ if( HPMHooks.count.HP_login_login_error_post ) {
+ void (*postHookFunc) (int *fd, uint8 *status);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_login_error_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_login_error_post[hIndex].func;
+ postHookFunc(&fd, &status);
+ }
+ }
+ return;
+}
+void HP_login_parse_ping(int fd, struct login_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_parse_ping_pre ) {
+ void (*preHookFunc) (int *fd, struct login_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_ping_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_parse_ping_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.parse_ping(fd, sd);
+ }
+ if( HPMHooks.count.HP_login_parse_ping_post ) {
+ void (*postHookFunc) (int *fd, struct login_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_ping_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_parse_ping_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_login_parse_client_md5(int fd, struct login_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_parse_client_md5_pre ) {
+ void (*preHookFunc) (int *fd, struct login_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_client_md5_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_parse_client_md5_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.parse_client_md5(fd, sd);
+ }
+ if( HPMHooks.count.HP_login_parse_client_md5_post ) {
+ void (*postHookFunc) (int *fd, struct login_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_client_md5_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_parse_client_md5_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+bool HP_login_parse_client_login(int fd, struct login_session_data *sd, const char *ip) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_login_parse_client_login_pre ) {
+ bool (*preHookFunc) (int *fd, struct login_session_data *sd, const char *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_client_login_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_parse_client_login_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, sd, ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.parse_client_login(fd, sd, ip);
+ }
+ if( HPMHooks.count.HP_login_parse_client_login_post ) {
+ bool (*postHookFunc) (bool retVal___, int *fd, struct login_session_data *sd, const char *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_client_login_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_parse_client_login_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, sd, ip);
+ }
+ }
+ return retVal___;
+}
+void HP_login_send_coding_key(int fd, struct login_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_send_coding_key_pre ) {
+ void (*preHookFunc) (int *fd, struct login_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_send_coding_key_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_send_coding_key_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.send_coding_key(fd, sd);
+ }
+ if( HPMHooks.count.HP_login_send_coding_key_post ) {
+ void (*postHookFunc) (int *fd, struct login_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_send_coding_key_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_send_coding_key_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_login_parse_request_coding_key(int fd, struct login_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_parse_request_coding_key_pre ) {
+ void (*preHookFunc) (int *fd, struct login_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_request_coding_key_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_parse_request_coding_key_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.parse_request_coding_key(fd, sd);
+ }
+ if( HPMHooks.count.HP_login_parse_request_coding_key_post ) {
+ void (*postHookFunc) (int *fd, struct login_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_request_coding_key_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_parse_request_coding_key_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_login_char_server_connection_status(int fd, struct login_session_data *sd, uint8 status) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_char_server_connection_status_pre ) {
+ void (*preHookFunc) (int *fd, struct login_session_data *sd, uint8 *status);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_char_server_connection_status_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_char_server_connection_status_pre[hIndex].func;
+ preHookFunc(&fd, sd, &status);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.char_server_connection_status(fd, sd, status);
+ }
+ if( HPMHooks.count.HP_login_char_server_connection_status_post ) {
+ void (*postHookFunc) (int *fd, struct login_session_data *sd, uint8 *status);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_char_server_connection_status_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_char_server_connection_status_post[hIndex].func;
+ postHookFunc(&fd, sd, &status);
+ }
+ }
+ return;
+}
+void HP_login_parse_request_connection(int fd, struct login_session_data *sd, const char *ip) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_login_parse_request_connection_pre ) {
+ void (*preHookFunc) (int *fd, struct login_session_data *sd, const char *ip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_request_connection_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_parse_request_connection_pre[hIndex].func;
+ preHookFunc(&fd, sd, ip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.login.parse_request_connection(fd, sd, ip);
+ }
+ if( HPMHooks.count.HP_login_parse_request_connection_post ) {
+ void (*postHookFunc) (int *fd, struct login_session_data *sd, const char *ip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_request_connection_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_parse_request_connection_post[hIndex].func;
+ postHookFunc(&fd, sd, ip);
+ }
+ }
+ return;
+}
+int HP_login_parse_login(int fd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_login_parse_login_pre ) {
+ int (*preHookFunc) (int *fd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_login_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_login_parse_login_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.login.parse_login(fd);
+ }
+ if( HPMHooks.count.HP_login_parse_login_post ) {
+ int (*postHookFunc) (int retVal___, int *fd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_login_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_login_parse_login_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd);
+ }
+ }
+ return retVal___;
+}
diff --git a/src/plugins/HPMHooking/HPMHooking_login.sources.inc b/src/plugins/HPMHooking/HPMHooking_login.sources.inc
new file mode 100644
index 000000000..aa1bb2625
--- /dev/null
+++ b/src/plugins/HPMHooking/HPMHooking_login.sources.inc
@@ -0,0 +1,7 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+//
+// NOTE: This file was auto-generated and should never be manually edited,
+// as it will get overwritten.
+
+memcpy(&HPMHooks.source.login, login, sizeof(struct login_interface));
diff --git a/src/plugins/HPMHooking/HPMHooking.GetSymbol.inc b/src/plugins/HPMHooking/HPMHooking_map.GetSymbol.inc
index 8482b9f80..8482b9f80 100644
--- a/src/plugins/HPMHooking/HPMHooking.GetSymbol.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.GetSymbol.inc
diff --git a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
index d73525b70..034b14b79 100644
--- a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
@@ -423,6 +423,8 @@ struct {
struct HPMHookPoint *HP_clif_send_post;
struct HPMHookPoint *HP_clif_send_sub_pre;
struct HPMHookPoint *HP_clif_send_sub_post;
+ struct HPMHookPoint *HP_clif_send_actual_pre;
+ struct HPMHookPoint *HP_clif_send_actual_post;
struct HPMHookPoint *HP_clif_parse_pre;
struct HPMHookPoint *HP_clif_parse_post;
struct HPMHookPoint *HP_clif_parse_cmd_pre;
@@ -505,6 +507,8 @@ struct {
struct HPMHookPoint *HP_clif_changetraplook_post;
struct HPMHookPoint *HP_clif_refreshlook_pre;
struct HPMHookPoint *HP_clif_refreshlook_post;
+ struct HPMHookPoint *HP_clif_sendlook_pre;
+ struct HPMHookPoint *HP_clif_sendlook_post;
struct HPMHookPoint *HP_clif_class_change_pre;
struct HPMHookPoint *HP_clif_class_change_post;
struct HPMHookPoint *HP_clif_skill_delunit_pre;
@@ -825,8 +829,8 @@ struct {
struct HPMHookPoint *HP_clif_specialeffect_value_post;
struct HPMHookPoint *HP_clif_millenniumshield_pre;
struct HPMHookPoint *HP_clif_millenniumshield_post;
- struct HPMHookPoint *HP_clif_charm_pre;
- struct HPMHookPoint *HP_clif_charm_post;
+ struct HPMHookPoint *HP_clif_spiritcharm_pre;
+ struct HPMHookPoint *HP_clif_spiritcharm_post;
struct HPMHookPoint *HP_clif_charm_single_pre;
struct HPMHookPoint *HP_clif_charm_single_post;
struct HPMHookPoint *HP_clif_snap_pre;
@@ -977,6 +981,8 @@ struct {
struct HPMHookPoint *HP_clif_party_show_picker_post;
struct HPMHookPoint *HP_clif_partyinvitationstate_pre;
struct HPMHookPoint *HP_clif_partyinvitationstate_post;
+ struct HPMHookPoint *HP_clif_PartyLeaderChanged_pre;
+ struct HPMHookPoint *HP_clif_PartyLeaderChanged_post;
struct HPMHookPoint *HP_clif_guild_created_pre;
struct HPMHookPoint *HP_clif_guild_created_post;
struct HPMHookPoint *HP_clif_guild_belonginfo_pre;
@@ -1299,6 +1305,10 @@ struct {
struct HPMHookPoint *HP_clif_npc_market_open_post;
struct HPMHookPoint *HP_clif_npc_market_purchase_ack_pre;
struct HPMHookPoint *HP_clif_npc_market_purchase_ack_post;
+ struct HPMHookPoint *HP_clif_parse_roulette_db_pre;
+ struct HPMHookPoint *HP_clif_parse_roulette_db_post;
+ struct HPMHookPoint *HP_clif_roulette_generate_ack_pre;
+ struct HPMHookPoint *HP_clif_roulette_generate_ack_post;
struct HPMHookPoint *HP_clif_pWantToConnection_pre;
struct HPMHookPoint *HP_clif_pWantToConnection_post;
struct HPMHookPoint *HP_clif_pLoadEndAck_pre;
@@ -1739,6 +1749,16 @@ struct {
struct HPMHookPoint *HP_clif_pBankOpen_post;
struct HPMHookPoint *HP_clif_pBankClose_pre;
struct HPMHookPoint *HP_clif_pBankClose_post;
+ struct HPMHookPoint *HP_clif_pRouletteOpen_pre;
+ struct HPMHookPoint *HP_clif_pRouletteOpen_post;
+ struct HPMHookPoint *HP_clif_pRouletteInfo_pre;
+ struct HPMHookPoint *HP_clif_pRouletteInfo_post;
+ struct HPMHookPoint *HP_clif_pRouletteClose_pre;
+ struct HPMHookPoint *HP_clif_pRouletteClose_post;
+ struct HPMHookPoint *HP_clif_pRouletteGenerate_pre;
+ struct HPMHookPoint *HP_clif_pRouletteGenerate_post;
+ struct HPMHookPoint *HP_clif_pRouletteRecvItem_pre;
+ struct HPMHookPoint *HP_clif_pRouletteRecvItem_post;
struct HPMHookPoint *HP_clif_pNPCShopClosed_pre;
struct HPMHookPoint *HP_clif_pNPCShopClosed_post;
struct HPMHookPoint *HP_clif_pNPCMarketClosed_pre;
@@ -1999,10 +2019,8 @@ struct {
struct HPMHookPoint *HP_guild_get_alliance_count_post;
struct HPMHookPoint *HP_guild_castle_reconnect_sub_pre;
struct HPMHookPoint *HP_guild_castle_reconnect_sub_post;
- struct HPMHookPoint *HP_gstorage_id2storage_pre;
- struct HPMHookPoint *HP_gstorage_id2storage_post;
- struct HPMHookPoint *HP_gstorage_id2storage2_pre;
- struct HPMHookPoint *HP_gstorage_id2storage2_post;
+ struct HPMHookPoint *HP_gstorage_ensure_pre;
+ struct HPMHookPoint *HP_gstorage_ensure_post;
struct HPMHookPoint *HP_gstorage_init_pre;
struct HPMHookPoint *HP_gstorage_init_post;
struct HPMHookPoint *HP_gstorage_final_pre;
@@ -2549,6 +2567,8 @@ struct {
struct HPMHookPoint *HP_itemdb_gendercheck_post;
struct HPMHookPoint *HP_itemdb_validate_entry_pre;
struct HPMHookPoint *HP_itemdb_validate_entry_post;
+ struct HPMHookPoint *HP_itemdb_readdb_additional_fields_pre;
+ struct HPMHookPoint *HP_itemdb_readdb_additional_fields_post;
struct HPMHookPoint *HP_itemdb_readdb_sql_sub_pre;
struct HPMHookPoint *HP_itemdb_readdb_sql_sub_post;
struct HPMHookPoint *HP_itemdb_readdb_libconfig_sub_pre;
@@ -2569,6 +2589,10 @@ struct {
struct HPMHookPoint *HP_itemdb_clear_post;
struct HPMHookPoint *HP_itemdb_id2combo_pre;
struct HPMHookPoint *HP_itemdb_id2combo_post;
+ struct HPMHookPoint *HP_itemdb_is_item_usable_pre;
+ struct HPMHookPoint *HP_itemdb_is_item_usable_post;
+ struct HPMHookPoint *HP_itemdb_lookup_const_pre;
+ struct HPMHookPoint *HP_itemdb_lookup_const_post;
struct HPMHookPoint *HP_logs_pick_pc_pre;
struct HPMHookPoint *HP_logs_pick_pc_post;
struct HPMHookPoint *HP_logs_pick_mob_pre;
@@ -2673,6 +2697,8 @@ struct {
struct HPMHookPoint *HP_map_get_new_object_id_post;
struct HPMHookPoint *HP_map_search_freecell_pre;
struct HPMHookPoint *HP_map_search_freecell_post;
+ struct HPMHookPoint *HP_map_closest_freecell_pre;
+ struct HPMHookPoint *HP_map_closest_freecell_post;
struct HPMHookPoint *HP_map_quit_pre;
struct HPMHookPoint *HP_map_quit_post;
struct HPMHookPoint *HP_map_addnpc_pre;
@@ -3169,6 +3195,8 @@ struct {
struct HPMHookPoint *HP_mob_load_post;
struct HPMHookPoint *HP_mob_clear_spawninfo_pre;
struct HPMHookPoint *HP_mob_clear_spawninfo_post;
+ struct HPMHookPoint *HP_mob_destroy_mob_db_pre;
+ struct HPMHookPoint *HP_mob_destroy_mob_db_post;
struct HPMHookPoint *HP_npc_init_pre;
struct HPMHookPoint *HP_npc_init_post;
struct HPMHookPoint *HP_npc_final_pre;
@@ -3185,6 +3213,8 @@ struct {
struct HPMHookPoint *HP_npc_ontouch_event_post;
struct HPMHookPoint *HP_npc_ontouch2_event_pre;
struct HPMHookPoint *HP_npc_ontouch2_event_post;
+ struct HPMHookPoint *HP_npc_onuntouch_event_pre;
+ struct HPMHookPoint *HP_npc_onuntouch_event_post;
struct HPMHookPoint *HP_npc_enable_sub_pre;
struct HPMHookPoint *HP_npc_enable_sub_post;
struct HPMHookPoint *HP_npc_enable_pre;
@@ -3233,6 +3263,8 @@ struct {
struct HPMHookPoint *HP_npc_touchnext_areanpc_post;
struct HPMHookPoint *HP_npc_touch_areanpc_pre;
struct HPMHookPoint *HP_npc_touch_areanpc_post;
+ struct HPMHookPoint *HP_npc_untouch_areanpc_pre;
+ struct HPMHookPoint *HP_npc_untouch_areanpc_post;
struct HPMHookPoint *HP_npc_touch_areanpc2_pre;
struct HPMHookPoint *HP_npc_touch_areanpc2_post;
struct HPMHookPoint *HP_npc_check_areanpc_pre;
@@ -3285,12 +3317,16 @@ struct {
struct HPMHookPoint *HP_npc_parseview_post;
struct HPMHookPoint *HP_npc_viewisid_pre;
struct HPMHookPoint *HP_npc_viewisid_post;
+ struct HPMHookPoint *HP_npc_create_npc_pre;
+ struct HPMHookPoint *HP_npc_create_npc_post;
struct HPMHookPoint *HP_npc_add_warp_pre;
struct HPMHookPoint *HP_npc_add_warp_post;
struct HPMHookPoint *HP_npc_parse_warp_pre;
struct HPMHookPoint *HP_npc_parse_warp_post;
struct HPMHookPoint *HP_npc_parse_shop_pre;
struct HPMHookPoint *HP_npc_parse_shop_post;
+ struct HPMHookPoint *HP_npc_parse_unknown_object_pre;
+ struct HPMHookPoint *HP_npc_parse_unknown_object_post;
struct HPMHookPoint *HP_npc_convertlabel_db_pre;
struct HPMHookPoint *HP_npc_convertlabel_db_post;
struct HPMHookPoint *HP_npc_skip_script_pre;
@@ -3323,6 +3359,8 @@ struct {
struct HPMHookPoint *HP_npc_parse_mob_post;
struct HPMHookPoint *HP_npc_parse_mapflag_pre;
struct HPMHookPoint *HP_npc_parse_mapflag_post;
+ struct HPMHookPoint *HP_npc_parse_unknown_mapflag_pre;
+ struct HPMHookPoint *HP_npc_parse_unknown_mapflag_post;
struct HPMHookPoint *HP_npc_parsesrcfile_pre;
struct HPMHookPoint *HP_npc_parsesrcfile_post;
struct HPMHookPoint *HP_npc_script_event_pre;
@@ -3471,6 +3509,10 @@ struct {
struct HPMHookPoint *HP_path_check_distance_post;
struct HPMHookPoint *HP_path_distance_pre;
struct HPMHookPoint *HP_path_distance_post;
+ struct HPMHookPoint *HP_path_check_distance_client_pre;
+ struct HPMHookPoint *HP_path_check_distance_client_post;
+ struct HPMHookPoint *HP_path_distance_client_pre;
+ struct HPMHookPoint *HP_path_distance_client_post;
struct HPMHookPoint *HP_pcg_init_pre;
struct HPMHookPoint *HP_pcg_init_post;
struct HPMHookPoint *HP_pcg_final_pre;
@@ -3501,10 +3543,6 @@ struct {
struct HPMHookPoint *HP_pc_get_dummy_sd_post;
struct HPMHookPoint *HP_pc_class2idx_pre;
struct HPMHookPoint *HP_pc_class2idx_post;
- struct HPMHookPoint *HP_pc_can_give_items_pre;
- struct HPMHookPoint *HP_pc_can_give_items_post;
- struct HPMHookPoint *HP_pc_can_give_bound_items_pre;
- struct HPMHookPoint *HP_pc_can_give_bound_items_post;
struct HPMHookPoint *HP_pc_can_talk_pre;
struct HPMHookPoint *HP_pc_can_talk_post;
struct HPMHookPoint *HP_pc_can_attack_pre;
@@ -3675,8 +3713,12 @@ struct {
struct HPMHookPoint *HP_pc_resethate_post;
struct HPMHookPoint *HP_pc_equipitem_pre;
struct HPMHookPoint *HP_pc_equipitem_post;
+ struct HPMHookPoint *HP_pc_equipitem_pos_pre;
+ struct HPMHookPoint *HP_pc_equipitem_pos_post;
struct HPMHookPoint *HP_pc_unequipitem_pre;
struct HPMHookPoint *HP_pc_unequipitem_post;
+ struct HPMHookPoint *HP_pc_unequipitem_pos_pre;
+ struct HPMHookPoint *HP_pc_unequipitem_pos_post;
struct HPMHookPoint *HP_pc_checkitem_pre;
struct HPMHookPoint *HP_pc_checkitem_post;
struct HPMHookPoint *HP_pc_useitem_pre;
@@ -3707,10 +3749,14 @@ struct {
struct HPMHookPoint *HP_pc_setcart_post;
struct HPMHookPoint *HP_pc_setfalcon_pre;
struct HPMHookPoint *HP_pc_setfalcon_post;
- struct HPMHookPoint *HP_pc_setriding_pre;
- struct HPMHookPoint *HP_pc_setriding_post;
+ struct HPMHookPoint *HP_pc_setridingpeco_pre;
+ struct HPMHookPoint *HP_pc_setridingpeco_post;
struct HPMHookPoint *HP_pc_setmadogear_pre;
struct HPMHookPoint *HP_pc_setmadogear_post;
+ struct HPMHookPoint *HP_pc_setridingdragon_pre;
+ struct HPMHookPoint *HP_pc_setridingdragon_post;
+ struct HPMHookPoint *HP_pc_setridingwug_pre;
+ struct HPMHookPoint *HP_pc_setridingwug_post;
struct HPMHookPoint *HP_pc_changelook_pre;
struct HPMHookPoint *HP_pc_changelook_post;
struct HPMHookPoint *HP_pc_equiplookall_pre;
@@ -3975,8 +4021,6 @@ struct {
struct HPMHookPoint *HP_pet_skill_bonus_timer_post;
struct HPMHookPoint *HP_pet_recovery_timer_pre;
struct HPMHookPoint *HP_pet_recovery_timer_post;
- struct HPMHookPoint *HP_pet_heal_timer_pre;
- struct HPMHookPoint *HP_pet_heal_timer_post;
struct HPMHookPoint *HP_pet_skill_support_timer_pre;
struct HPMHookPoint *HP_pet_skill_support_timer_post;
struct HPMHookPoint *HP_pet_read_db_pre;
@@ -4563,8 +4607,6 @@ struct {
struct HPMHookPoint *HP_skill_greed_post;
struct HPMHookPoint *HP_skill_destroy_trap_pre;
struct HPMHookPoint *HP_skill_destroy_trap_post;
- struct HPMHookPoint *HP_skill_icewall_block_pre;
- struct HPMHookPoint *HP_skill_icewall_block_post;
struct HPMHookPoint *HP_skill_unitgrouptickset_search_pre;
struct HPMHookPoint *HP_skill_unitgrouptickset_search_post;
struct HPMHookPoint *HP_skill_dance_switch_pre;
@@ -4973,6 +5015,10 @@ struct {
struct HPMHookPoint *HP_unit_stop_walking_post;
struct HPMHookPoint *HP_unit_skilluse_id_pre;
struct HPMHookPoint *HP_unit_skilluse_id_post;
+ struct HPMHookPoint *HP_unit_step_timer_pre;
+ struct HPMHookPoint *HP_unit_step_timer_post;
+ struct HPMHookPoint *HP_unit_stop_stepaction_pre;
+ struct HPMHookPoint *HP_unit_stop_stepaction_post;
struct HPMHookPoint *HP_unit_is_walking_pre;
struct HPMHookPoint *HP_unit_is_walking_post;
struct HPMHookPoint *HP_unit_can_move_pre;
@@ -5460,6 +5506,8 @@ struct {
int HP_clif_send_post;
int HP_clif_send_sub_pre;
int HP_clif_send_sub_post;
+ int HP_clif_send_actual_pre;
+ int HP_clif_send_actual_post;
int HP_clif_parse_pre;
int HP_clif_parse_post;
int HP_clif_parse_cmd_pre;
@@ -5542,6 +5590,8 @@ struct {
int HP_clif_changetraplook_post;
int HP_clif_refreshlook_pre;
int HP_clif_refreshlook_post;
+ int HP_clif_sendlook_pre;
+ int HP_clif_sendlook_post;
int HP_clif_class_change_pre;
int HP_clif_class_change_post;
int HP_clif_skill_delunit_pre;
@@ -5862,8 +5912,8 @@ struct {
int HP_clif_specialeffect_value_post;
int HP_clif_millenniumshield_pre;
int HP_clif_millenniumshield_post;
- int HP_clif_charm_pre;
- int HP_clif_charm_post;
+ int HP_clif_spiritcharm_pre;
+ int HP_clif_spiritcharm_post;
int HP_clif_charm_single_pre;
int HP_clif_charm_single_post;
int HP_clif_snap_pre;
@@ -6014,6 +6064,8 @@ struct {
int HP_clif_party_show_picker_post;
int HP_clif_partyinvitationstate_pre;
int HP_clif_partyinvitationstate_post;
+ int HP_clif_PartyLeaderChanged_pre;
+ int HP_clif_PartyLeaderChanged_post;
int HP_clif_guild_created_pre;
int HP_clif_guild_created_post;
int HP_clif_guild_belonginfo_pre;
@@ -6336,6 +6388,10 @@ struct {
int HP_clif_npc_market_open_post;
int HP_clif_npc_market_purchase_ack_pre;
int HP_clif_npc_market_purchase_ack_post;
+ int HP_clif_parse_roulette_db_pre;
+ int HP_clif_parse_roulette_db_post;
+ int HP_clif_roulette_generate_ack_pre;
+ int HP_clif_roulette_generate_ack_post;
int HP_clif_pWantToConnection_pre;
int HP_clif_pWantToConnection_post;
int HP_clif_pLoadEndAck_pre;
@@ -6776,6 +6832,16 @@ struct {
int HP_clif_pBankOpen_post;
int HP_clif_pBankClose_pre;
int HP_clif_pBankClose_post;
+ int HP_clif_pRouletteOpen_pre;
+ int HP_clif_pRouletteOpen_post;
+ int HP_clif_pRouletteInfo_pre;
+ int HP_clif_pRouletteInfo_post;
+ int HP_clif_pRouletteClose_pre;
+ int HP_clif_pRouletteClose_post;
+ int HP_clif_pRouletteGenerate_pre;
+ int HP_clif_pRouletteGenerate_post;
+ int HP_clif_pRouletteRecvItem_pre;
+ int HP_clif_pRouletteRecvItem_post;
int HP_clif_pNPCShopClosed_pre;
int HP_clif_pNPCShopClosed_post;
int HP_clif_pNPCMarketClosed_pre;
@@ -7036,10 +7102,8 @@ struct {
int HP_guild_get_alliance_count_post;
int HP_guild_castle_reconnect_sub_pre;
int HP_guild_castle_reconnect_sub_post;
- int HP_gstorage_id2storage_pre;
- int HP_gstorage_id2storage_post;
- int HP_gstorage_id2storage2_pre;
- int HP_gstorage_id2storage2_post;
+ int HP_gstorage_ensure_pre;
+ int HP_gstorage_ensure_post;
int HP_gstorage_init_pre;
int HP_gstorage_init_post;
int HP_gstorage_final_pre;
@@ -7586,6 +7650,8 @@ struct {
int HP_itemdb_gendercheck_post;
int HP_itemdb_validate_entry_pre;
int HP_itemdb_validate_entry_post;
+ int HP_itemdb_readdb_additional_fields_pre;
+ int HP_itemdb_readdb_additional_fields_post;
int HP_itemdb_readdb_sql_sub_pre;
int HP_itemdb_readdb_sql_sub_post;
int HP_itemdb_readdb_libconfig_sub_pre;
@@ -7606,6 +7672,10 @@ struct {
int HP_itemdb_clear_post;
int HP_itemdb_id2combo_pre;
int HP_itemdb_id2combo_post;
+ int HP_itemdb_is_item_usable_pre;
+ int HP_itemdb_is_item_usable_post;
+ int HP_itemdb_lookup_const_pre;
+ int HP_itemdb_lookup_const_post;
int HP_logs_pick_pc_pre;
int HP_logs_pick_pc_post;
int HP_logs_pick_mob_pre;
@@ -7710,6 +7780,8 @@ struct {
int HP_map_get_new_object_id_post;
int HP_map_search_freecell_pre;
int HP_map_search_freecell_post;
+ int HP_map_closest_freecell_pre;
+ int HP_map_closest_freecell_post;
int HP_map_quit_pre;
int HP_map_quit_post;
int HP_map_addnpc_pre;
@@ -8206,6 +8278,8 @@ struct {
int HP_mob_load_post;
int HP_mob_clear_spawninfo_pre;
int HP_mob_clear_spawninfo_post;
+ int HP_mob_destroy_mob_db_pre;
+ int HP_mob_destroy_mob_db_post;
int HP_npc_init_pre;
int HP_npc_init_post;
int HP_npc_final_pre;
@@ -8222,6 +8296,8 @@ struct {
int HP_npc_ontouch_event_post;
int HP_npc_ontouch2_event_pre;
int HP_npc_ontouch2_event_post;
+ int HP_npc_onuntouch_event_pre;
+ int HP_npc_onuntouch_event_post;
int HP_npc_enable_sub_pre;
int HP_npc_enable_sub_post;
int HP_npc_enable_pre;
@@ -8270,6 +8346,8 @@ struct {
int HP_npc_touchnext_areanpc_post;
int HP_npc_touch_areanpc_pre;
int HP_npc_touch_areanpc_post;
+ int HP_npc_untouch_areanpc_pre;
+ int HP_npc_untouch_areanpc_post;
int HP_npc_touch_areanpc2_pre;
int HP_npc_touch_areanpc2_post;
int HP_npc_check_areanpc_pre;
@@ -8322,12 +8400,16 @@ struct {
int HP_npc_parseview_post;
int HP_npc_viewisid_pre;
int HP_npc_viewisid_post;
+ int HP_npc_create_npc_pre;
+ int HP_npc_create_npc_post;
int HP_npc_add_warp_pre;
int HP_npc_add_warp_post;
int HP_npc_parse_warp_pre;
int HP_npc_parse_warp_post;
int HP_npc_parse_shop_pre;
int HP_npc_parse_shop_post;
+ int HP_npc_parse_unknown_object_pre;
+ int HP_npc_parse_unknown_object_post;
int HP_npc_convertlabel_db_pre;
int HP_npc_convertlabel_db_post;
int HP_npc_skip_script_pre;
@@ -8360,6 +8442,8 @@ struct {
int HP_npc_parse_mob_post;
int HP_npc_parse_mapflag_pre;
int HP_npc_parse_mapflag_post;
+ int HP_npc_parse_unknown_mapflag_pre;
+ int HP_npc_parse_unknown_mapflag_post;
int HP_npc_parsesrcfile_pre;
int HP_npc_parsesrcfile_post;
int HP_npc_script_event_pre;
@@ -8508,6 +8592,10 @@ struct {
int HP_path_check_distance_post;
int HP_path_distance_pre;
int HP_path_distance_post;
+ int HP_path_check_distance_client_pre;
+ int HP_path_check_distance_client_post;
+ int HP_path_distance_client_pre;
+ int HP_path_distance_client_post;
int HP_pcg_init_pre;
int HP_pcg_init_post;
int HP_pcg_final_pre;
@@ -8538,10 +8626,6 @@ struct {
int HP_pc_get_dummy_sd_post;
int HP_pc_class2idx_pre;
int HP_pc_class2idx_post;
- int HP_pc_can_give_items_pre;
- int HP_pc_can_give_items_post;
- int HP_pc_can_give_bound_items_pre;
- int HP_pc_can_give_bound_items_post;
int HP_pc_can_talk_pre;
int HP_pc_can_talk_post;
int HP_pc_can_attack_pre;
@@ -8712,8 +8796,12 @@ struct {
int HP_pc_resethate_post;
int HP_pc_equipitem_pre;
int HP_pc_equipitem_post;
+ int HP_pc_equipitem_pos_pre;
+ int HP_pc_equipitem_pos_post;
int HP_pc_unequipitem_pre;
int HP_pc_unequipitem_post;
+ int HP_pc_unequipitem_pos_pre;
+ int HP_pc_unequipitem_pos_post;
int HP_pc_checkitem_pre;
int HP_pc_checkitem_post;
int HP_pc_useitem_pre;
@@ -8744,10 +8832,14 @@ struct {
int HP_pc_setcart_post;
int HP_pc_setfalcon_pre;
int HP_pc_setfalcon_post;
- int HP_pc_setriding_pre;
- int HP_pc_setriding_post;
+ int HP_pc_setridingpeco_pre;
+ int HP_pc_setridingpeco_post;
int HP_pc_setmadogear_pre;
int HP_pc_setmadogear_post;
+ int HP_pc_setridingdragon_pre;
+ int HP_pc_setridingdragon_post;
+ int HP_pc_setridingwug_pre;
+ int HP_pc_setridingwug_post;
int HP_pc_changelook_pre;
int HP_pc_changelook_post;
int HP_pc_equiplookall_pre;
@@ -9012,8 +9104,6 @@ struct {
int HP_pet_skill_bonus_timer_post;
int HP_pet_recovery_timer_pre;
int HP_pet_recovery_timer_post;
- int HP_pet_heal_timer_pre;
- int HP_pet_heal_timer_post;
int HP_pet_skill_support_timer_pre;
int HP_pet_skill_support_timer_post;
int HP_pet_read_db_pre;
@@ -9600,8 +9690,6 @@ struct {
int HP_skill_greed_post;
int HP_skill_destroy_trap_pre;
int HP_skill_destroy_trap_post;
- int HP_skill_icewall_block_pre;
- int HP_skill_icewall_block_post;
int HP_skill_unitgrouptickset_search_pre;
int HP_skill_unitgrouptickset_search_post;
int HP_skill_dance_switch_pre;
@@ -10010,6 +10098,10 @@ struct {
int HP_unit_stop_walking_post;
int HP_unit_skilluse_id_pre;
int HP_unit_skilluse_id_post;
+ int HP_unit_step_timer_pre;
+ int HP_unit_step_timer_post;
+ int HP_unit_stop_stepaction_pre;
+ int HP_unit_stop_stepaction_post;
int HP_unit_is_walking_pre;
int HP_unit_is_walking_post;
int HP_unit_can_move_pre;
diff --git a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
index 05d484d20..21f48134c 100644
--- a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
@@ -221,6 +221,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(clif->refresh_ip, HP_clif_refresh_ip) },
{ HP_POP(clif->send, HP_clif_send) },
{ HP_POP(clif->send_sub, HP_clif_send_sub) },
+ { HP_POP(clif->send_actual, HP_clif_send_actual) },
{ HP_POP(clif->parse, HP_clif_parse) },
{ HP_POP(clif->parse_cmd, HP_clif_parse_cmd) },
{ HP_POP(clif->decrypt_cmd, HP_clif_decrypt_cmd) },
@@ -262,6 +263,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(clif->changelook, HP_clif_changelook) },
{ HP_POP(clif->changetraplook, HP_clif_changetraplook) },
{ HP_POP(clif->refreshlook, HP_clif_refreshlook) },
+ { HP_POP(clif->sendlook, HP_clif_sendlook) },
{ HP_POP(clif->class_change, HP_clif_class_change) },
{ HP_POP(clif->skill_delunit, HP_clif_skill_delunit) },
{ HP_POP(clif->skillunit_update, HP_clif_skillunit_update) },
@@ -422,7 +424,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(clif->specialeffect_single, HP_clif_specialeffect_single) },
{ HP_POP(clif->specialeffect_value, HP_clif_specialeffect_value) },
{ HP_POP(clif->millenniumshield, HP_clif_millenniumshield) },
- { HP_POP(clif->charm, HP_clif_charm) },
+ { HP_POP(clif->spiritcharm, HP_clif_spiritcharm) },
{ HP_POP(clif->charm_single, HP_clif_charm_single) },
{ HP_POP(clif->snap, HP_clif_snap) },
{ HP_POP(clif->weather_check, HP_clif_weather_check) },
@@ -498,6 +500,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(clif->party_xy_remove, HP_clif_party_xy_remove) },
{ HP_POP(clif->party_show_picker, HP_clif_party_show_picker) },
{ HP_POP(clif->partyinvitationstate, HP_clif_partyinvitationstate) },
+ { HP_POP(clif->PartyLeaderChanged, HP_clif_PartyLeaderChanged) },
{ HP_POP(clif->guild_created, HP_clif_guild_created) },
{ HP_POP(clif->guild_belonginfo, HP_clif_guild_belonginfo) },
{ HP_POP(clif->guild_masterormember, HP_clif_guild_masterormember) },
@@ -659,6 +662,8 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(clif->delay_damage_sub, HP_clif_delay_damage_sub) },
{ HP_POP(clif->npc_market_open, HP_clif_npc_market_open) },
{ HP_POP(clif->npc_market_purchase_ack, HP_clif_npc_market_purchase_ack) },
+ { HP_POP(clif->parse_roulette_db, HP_clif_parse_roulette_db) },
+ { HP_POP(clif->roulette_generate_ack, HP_clif_roulette_generate_ack) },
{ HP_POP(clif->pWantToConnection, HP_clif_pWantToConnection) },
{ HP_POP(clif->pLoadEndAck, HP_clif_pLoadEndAck) },
{ HP_POP(clif->pTickSend, HP_clif_pTickSend) },
@@ -879,6 +884,11 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(clif->pBankCheck, HP_clif_pBankCheck) },
{ HP_POP(clif->pBankOpen, HP_clif_pBankOpen) },
{ HP_POP(clif->pBankClose, HP_clif_pBankClose) },
+ { HP_POP(clif->pRouletteOpen, HP_clif_pRouletteOpen) },
+ { HP_POP(clif->pRouletteInfo, HP_clif_pRouletteInfo) },
+ { HP_POP(clif->pRouletteClose, HP_clif_pRouletteClose) },
+ { HP_POP(clif->pRouletteGenerate, HP_clif_pRouletteGenerate) },
+ { HP_POP(clif->pRouletteRecvItem, HP_clif_pRouletteRecvItem) },
{ HP_POP(clif->pNPCShopClosed, HP_clif_pNPCShopClosed) },
{ HP_POP(clif->pNPCMarketClosed, HP_clif_pNPCMarketClosed) },
{ HP_POP(clif->pNPCMarketPurchase, HP_clif_pNPCMarketPurchase) },
@@ -1013,8 +1023,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(guild->get_alliance_count, HP_guild_get_alliance_count) },
{ HP_POP(guild->castle_reconnect_sub, HP_guild_castle_reconnect_sub) },
/* gstorage */
- { HP_POP(gstorage->id2storage, HP_gstorage_id2storage) },
- { HP_POP(gstorage->id2storage2, HP_gstorage_id2storage2) },
+ { HP_POP(gstorage->ensure, HP_gstorage_ensure) },
{ HP_POP(gstorage->init, HP_gstorage_init) },
{ HP_POP(gstorage->final, HP_gstorage_final) },
{ HP_POP(gstorage->delete, HP_gstorage_delete) },
@@ -1293,6 +1302,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(itemdb->read_combos, HP_itemdb_read_combos) },
{ HP_POP(itemdb->gendercheck, HP_itemdb_gendercheck) },
{ HP_POP(itemdb->validate_entry, HP_itemdb_validate_entry) },
+ { HP_POP(itemdb->readdb_additional_fields, HP_itemdb_readdb_additional_fields) },
{ HP_POP(itemdb->readdb_sql_sub, HP_itemdb_readdb_sql_sub) },
{ HP_POP(itemdb->readdb_libconfig_sub, HP_itemdb_readdb_libconfig_sub) },
{ HP_POP(itemdb->readdb_libconfig, HP_itemdb_readdb_libconfig) },
@@ -1303,6 +1313,8 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(itemdb->final_sub, HP_itemdb_final_sub) },
{ HP_POP(itemdb->clear, HP_itemdb_clear) },
{ HP_POP(itemdb->id2combo, HP_itemdb_id2combo) },
+ { HP_POP(itemdb->is_item_usable, HP_itemdb_is_item_usable) },
+ { HP_POP(itemdb->lookup_const, HP_itemdb_lookup_const) },
/* logs */
{ HP_POP(logs->pick_pc, HP_logs_pick_pc) },
{ HP_POP(logs->pick_mob, HP_logs_pick_mob) },
@@ -1358,6 +1370,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(map->find_skill_unit_oncell, HP_map_find_skill_unit_oncell) },
{ HP_POP(map->get_new_object_id, HP_map_get_new_object_id) },
{ HP_POP(map->search_freecell, HP_map_search_freecell) },
+ { HP_POP(map->closest_freecell, HP_map_closest_freecell) },
{ HP_POP(map->quit, HP_map_quit) },
{ HP_POP(map->addnpc, HP_map_addnpc) },
{ HP_POP(map->clearflooritem_timer, HP_map_clearflooritem_timer) },
@@ -1610,6 +1623,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(mob->readdb_itemratio, HP_mob_readdb_itemratio) },
{ HP_POP(mob->load, HP_mob_load) },
{ HP_POP(mob->clear_spawninfo, HP_mob_clear_spawninfo) },
+ { HP_POP(mob->destroy_mob_db, HP_mob_destroy_mob_db) },
/* npc */
{ HP_POP(npc->init, HP_npc_init) },
{ HP_POP(npc->final, HP_npc_final) },
@@ -1619,6 +1633,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(npc->isnear, HP_npc_isnear) },
{ HP_POP(npc->ontouch_event, HP_npc_ontouch_event) },
{ HP_POP(npc->ontouch2_event, HP_npc_ontouch2_event) },
+ { HP_POP(npc->onuntouch_event, HP_npc_onuntouch_event) },
{ HP_POP(npc->enable_sub, HP_npc_enable_sub) },
{ HP_POP(npc->enable, HP_npc_enable) },
{ HP_POP(npc->name2id, HP_npc_name2id) },
@@ -1643,6 +1658,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(npc->touch_areanpc_sub, HP_npc_touch_areanpc_sub) },
{ HP_POP(npc->touchnext_areanpc, HP_npc_touchnext_areanpc) },
{ HP_POP(npc->touch_areanpc, HP_npc_touch_areanpc) },
+ { HP_POP(npc->untouch_areanpc, HP_npc_untouch_areanpc) },
{ HP_POP(npc->touch_areanpc2, HP_npc_touch_areanpc2) },
{ HP_POP(npc->check_areanpc, HP_npc_check_areanpc) },
{ HP_POP(npc->checknear, HP_npc_checknear) },
@@ -1669,9 +1685,11 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(npc->parsename, HP_npc_parsename) },
{ HP_POP(npc->parseview, HP_npc_parseview) },
{ HP_POP(npc->viewisid, HP_npc_viewisid) },
+ { HP_POP(npc->create_npc, HP_npc_create_npc) },
{ HP_POP(npc->add_warp, HP_npc_add_warp) },
{ HP_POP(npc->parse_warp, HP_npc_parse_warp) },
{ HP_POP(npc->parse_shop, HP_npc_parse_shop) },
+ { HP_POP(npc->parse_unknown_object, HP_npc_parse_unknown_object) },
{ HP_POP(npc->convertlabel_db, HP_npc_convertlabel_db) },
{ HP_POP(npc->skip_script, HP_npc_skip_script) },
{ HP_POP(npc->parse_script, HP_npc_parse_script) },
@@ -1688,6 +1706,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(npc->parse_mob2, HP_npc_parse_mob2) },
{ HP_POP(npc->parse_mob, HP_npc_parse_mob) },
{ HP_POP(npc->parse_mapflag, HP_npc_parse_mapflag) },
+ { HP_POP(npc->parse_unknown_mapflag, HP_npc_parse_unknown_mapflag) },
{ HP_POP(npc->parsesrcfile, HP_npc_parsesrcfile) },
{ HP_POP(npc->script_event, HP_npc_script_event) },
{ HP_POP(npc->read_event_script, HP_npc_read_event_script) },
@@ -1764,6 +1783,8 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(path->search_long, HP_path_search_long) },
{ HP_POP(path->check_distance, HP_path_check_distance) },
{ HP_POP(path->distance, HP_path_distance) },
+ { HP_POP(path->check_distance_client, HP_path_check_distance_client) },
+ { HP_POP(path->distance_client, HP_path_distance_client) },
/* pcg */
{ HP_POP(pcg->init, HP_pcg_init) },
{ HP_POP(pcg->final, HP_pcg_final) },
@@ -1781,8 +1802,6 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(pc->final, HP_pc_final) },
{ HP_POP(pc->get_dummy_sd, HP_pc_get_dummy_sd) },
{ HP_POP(pc->class2idx, HP_pc_class2idx) },
- { HP_POP(pc->can_give_items, HP_pc_can_give_items) },
- { HP_POP(pc->can_give_bound_items, HP_pc_can_give_bound_items) },
{ HP_POP(pc->can_talk, HP_pc_can_talk) },
{ HP_POP(pc->can_attack, HP_pc_can_attack) },
{ HP_POP(pc->can_use_command, HP_pc_can_use_command) },
@@ -1868,7 +1887,9 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(pc->resetfeel, HP_pc_resetfeel) },
{ HP_POP(pc->resethate, HP_pc_resethate) },
{ HP_POP(pc->equipitem, HP_pc_equipitem) },
+ { HP_POP(pc->equipitem_pos, HP_pc_equipitem_pos) },
{ HP_POP(pc->unequipitem, HP_pc_unequipitem) },
+ { HP_POP(pc->unequipitem_pos, HP_pc_unequipitem_pos) },
{ HP_POP(pc->checkitem, HP_pc_checkitem) },
{ HP_POP(pc->useitem, HP_pc_useitem) },
{ HP_POP(pc->skillatk_bonus, HP_pc_skillatk_bonus) },
@@ -1884,8 +1905,10 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(pc->setoption, HP_pc_setoption) },
{ HP_POP(pc->setcart, HP_pc_setcart) },
{ HP_POP(pc->setfalcon, HP_pc_setfalcon) },
- { HP_POP(pc->setriding, HP_pc_setriding) },
+ { HP_POP(pc->setridingpeco, HP_pc_setridingpeco) },
{ HP_POP(pc->setmadogear, HP_pc_setmadogear) },
+ { HP_POP(pc->setridingdragon, HP_pc_setridingdragon) },
+ { HP_POP(pc->setridingwug, HP_pc_setridingwug) },
{ HP_POP(pc->changelook, HP_pc_changelook) },
{ HP_POP(pc->equiplookall, HP_pc_equiplookall) },
{ HP_POP(pc->readparam, HP_pc_readparam) },
@@ -2019,7 +2042,6 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(pet->lootitem_drop, HP_pet_lootitem_drop) },
{ HP_POP(pet->skill_bonus_timer, HP_pet_skill_bonus_timer) },
{ HP_POP(pet->recovery_timer, HP_pet_recovery_timer) },
- { HP_POP(pet->heal_timer, HP_pet_heal_timer) },
{ HP_POP(pet->skill_support_timer, HP_pet_skill_support_timer) },
{ HP_POP(pet->read_db, HP_pet_read_db) },
/* quest */
@@ -2317,7 +2339,6 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(skill->frostjoke_scream, HP_skill_frostjoke_scream) },
{ HP_POP(skill->greed, HP_skill_greed) },
{ HP_POP(skill->destroy_trap, HP_skill_destroy_trap) },
- { HP_POP(skill->icewall_block, HP_skill_icewall_block) },
{ HP_POP(skill->unitgrouptickset_search, HP_skill_unitgrouptickset_search) },
{ HP_POP(skill->dance_switch, HP_skill_dance_switch) },
{ HP_POP(skill->check_condition_char_sub, HP_skill_check_condition_char_sub) },
@@ -2526,6 +2547,8 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(unit->warp, HP_unit_warp) },
{ HP_POP(unit->stop_walking, HP_unit_stop_walking) },
{ HP_POP(unit->skilluse_id, HP_unit_skilluse_id) },
+ { HP_POP(unit->step_timer, HP_unit_step_timer) },
+ { HP_POP(unit->stop_stepaction, HP_unit_stop_stepaction) },
{ HP_POP(unit->is_walking, HP_unit_is_walking) },
{ HP_POP(unit->can_move, HP_unit_can_move) },
{ HP_POP(unit->resume_running, HP_unit_resume_running) },
diff --git a/src/plugins/HPMHooking/HPMHooking.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
index 8f209fe5c..9078efe2e 100644
--- a/src/plugins/HPMHooking/HPMHooking.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
@@ -5688,6 +5688,33 @@ int HP_clif_send_sub(struct block_list *bl, va_list ap) {
}
return retVal___;
}
+int HP_clif_send_actual(int fd, void *buf, int len) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_clif_send_actual_pre ) {
+ int (*preHookFunc) (int *fd, void *buf, int *len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_send_actual_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_send_actual_pre[hIndex].func;
+ retVal___ = preHookFunc(&fd, buf, &len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.clif.send_actual(fd, buf, len);
+ }
+ if( HPMHooks.count.HP_clif_send_actual_post ) {
+ int (*postHookFunc) (int retVal___, int *fd, void *buf, int *len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_send_actual_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_send_actual_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &fd, buf, &len);
+ }
+ }
+ return retVal___;
+}
int HP_clif_parse(int fd) {
int hIndex = 0;
int retVal___ = 0;
@@ -6757,6 +6784,32 @@ void HP_clif_refreshlook(struct block_list *bl, int id, int type, int val, enum
}
return;
}
+void HP_clif_sendlook(struct block_list *bl, int id, int type, int val, int val2, enum send_target target) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_clif_sendlook_pre ) {
+ void (*preHookFunc) (struct block_list *bl, int *id, int *type, int *val, int *val2, enum send_target *target);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_sendlook_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_sendlook_pre[hIndex].func;
+ preHookFunc(bl, &id, &type, &val, &val2, &target);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.clif.sendlook(bl, id, type, val, val2, target);
+ }
+ if( HPMHooks.count.HP_clif_sendlook_post ) {
+ void (*postHookFunc) (struct block_list *bl, int *id, int *type, int *val, int *val2, enum send_target *target);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_sendlook_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_sendlook_post[hIndex].func;
+ postHookFunc(bl, &id, &type, &val, &val2, &target);
+ }
+ }
+ return;
+}
void HP_clif_class_change(struct block_list *bl, int class_, int type) {
int hIndex = 0;
if( HPMHooks.count.HP_clif_class_change_pre ) {
@@ -10959,13 +11012,13 @@ void HP_clif_millenniumshield(struct block_list *bl, short shields) {
}
return;
}
-void HP_clif_charm(struct map_session_data *sd, short type) {
+void HP_clif_spiritcharm(struct map_session_data *sd, short type) {
int hIndex = 0;
- if( HPMHooks.count.HP_clif_charm_pre ) {
+ if( HPMHooks.count.HP_clif_spiritcharm_pre ) {
void (*preHookFunc) (struct map_session_data *sd, short *type);
*HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_charm_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_clif_charm_pre[hIndex].func;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_spiritcharm_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_spiritcharm_pre[hIndex].func;
preHookFunc(sd, &type);
}
if( *HPMforce_return ) {
@@ -10974,12 +11027,12 @@ void HP_clif_charm(struct map_session_data *sd, short type) {
}
}
{
- HPMHooks.source.clif.charm(sd, type);
+ HPMHooks.source.clif.spiritcharm(sd, type);
}
- if( HPMHooks.count.HP_clif_charm_post ) {
+ if( HPMHooks.count.HP_clif_spiritcharm_post ) {
void (*postHookFunc) (struct map_session_data *sd, short *type);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_charm_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_clif_charm_post[hIndex].func;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_spiritcharm_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_spiritcharm_post[hIndex].func;
postHookFunc(sd, &type);
}
}
@@ -12937,6 +12990,32 @@ void HP_clif_partyinvitationstate(struct map_session_data *sd) {
}
return;
}
+void HP_clif_PartyLeaderChanged(struct map_session_data *sd, int prev_leader_aid, int new_leader_aid) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_clif_PartyLeaderChanged_pre ) {
+ void (*preHookFunc) (struct map_session_data *sd, int *prev_leader_aid, int *new_leader_aid);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_PartyLeaderChanged_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_PartyLeaderChanged_pre[hIndex].func;
+ preHookFunc(sd, &prev_leader_aid, &new_leader_aid);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.clif.PartyLeaderChanged(sd, prev_leader_aid, new_leader_aid);
+ }
+ if( HPMHooks.count.HP_clif_PartyLeaderChanged_post ) {
+ void (*postHookFunc) (struct map_session_data *sd, int *prev_leader_aid, int *new_leader_aid);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_PartyLeaderChanged_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_PartyLeaderChanged_post[hIndex].func;
+ postHookFunc(sd, &prev_leader_aid, &new_leader_aid);
+ }
+ }
+ return;
+}
void HP_clif_guild_created(struct map_session_data *sd, int flag) {
int hIndex = 0;
if( HPMHooks.count.HP_clif_guild_created_pre ) {
@@ -17135,6 +17214,59 @@ void HP_clif_npc_market_purchase_ack(struct map_session_data *sd, struct packet_
}
return;
}
+bool HP_clif_parse_roulette_db(void) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_clif_parse_roulette_db_pre ) {
+ bool (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_parse_roulette_db_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_parse_roulette_db_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.clif.parse_roulette_db();
+ }
+ if( HPMHooks.count.HP_clif_parse_roulette_db_post ) {
+ bool (*postHookFunc) (bool retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_parse_roulette_db_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_parse_roulette_db_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_clif_roulette_generate_ack(struct map_session_data *sd, unsigned char result, short stage, short prizeIdx, short bonusItemID) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_clif_roulette_generate_ack_pre ) {
+ void (*preHookFunc) (struct map_session_data *sd, unsigned char *result, short *stage, short *prizeIdx, short *bonusItemID);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_roulette_generate_ack_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_roulette_generate_ack_pre[hIndex].func;
+ preHookFunc(sd, &result, &stage, &prizeIdx, &bonusItemID);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.clif.roulette_generate_ack(sd, result, stage, prizeIdx, bonusItemID);
+ }
+ if( HPMHooks.count.HP_clif_roulette_generate_ack_post ) {
+ void (*postHookFunc) (struct map_session_data *sd, unsigned char *result, short *stage, short *prizeIdx, short *bonusItemID);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_roulette_generate_ack_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_roulette_generate_ack_post[hIndex].func;
+ postHookFunc(sd, &result, &stage, &prizeIdx, &bonusItemID);
+ }
+ }
+ return;
+}
void HP_clif_pWantToConnection(int fd, struct map_session_data *sd) {
int hIndex = 0;
if( HPMHooks.count.HP_clif_pWantToConnection_pre ) {
@@ -22855,6 +22987,136 @@ void HP_clif_pBankClose(int fd, struct map_session_data *sd) {
}
return;
}
+void HP_clif_pRouletteOpen(int fd, struct map_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_clif_pRouletteOpen_pre ) {
+ void (*preHookFunc) (int *fd, struct map_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pRouletteOpen_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_pRouletteOpen_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.clif.pRouletteOpen(fd, sd);
+ }
+ if( HPMHooks.count.HP_clif_pRouletteOpen_post ) {
+ void (*postHookFunc) (int *fd, struct map_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pRouletteOpen_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_pRouletteOpen_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_clif_pRouletteInfo(int fd, struct map_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_clif_pRouletteInfo_pre ) {
+ void (*preHookFunc) (int *fd, struct map_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pRouletteInfo_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_pRouletteInfo_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.clif.pRouletteInfo(fd, sd);
+ }
+ if( HPMHooks.count.HP_clif_pRouletteInfo_post ) {
+ void (*postHookFunc) (int *fd, struct map_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pRouletteInfo_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_pRouletteInfo_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_clif_pRouletteClose(int fd, struct map_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_clif_pRouletteClose_pre ) {
+ void (*preHookFunc) (int *fd, struct map_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pRouletteClose_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_pRouletteClose_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.clif.pRouletteClose(fd, sd);
+ }
+ if( HPMHooks.count.HP_clif_pRouletteClose_post ) {
+ void (*postHookFunc) (int *fd, struct map_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pRouletteClose_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_pRouletteClose_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_clif_pRouletteGenerate(int fd, struct map_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_clif_pRouletteGenerate_pre ) {
+ void (*preHookFunc) (int *fd, struct map_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pRouletteGenerate_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_pRouletteGenerate_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.clif.pRouletteGenerate(fd, sd);
+ }
+ if( HPMHooks.count.HP_clif_pRouletteGenerate_post ) {
+ void (*postHookFunc) (int *fd, struct map_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pRouletteGenerate_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_pRouletteGenerate_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_clif_pRouletteRecvItem(int fd, struct map_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_clif_pRouletteRecvItem_pre ) {
+ void (*preHookFunc) (int *fd, struct map_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pRouletteRecvItem_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_pRouletteRecvItem_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.clif.pRouletteRecvItem(fd, sd);
+ }
+ if( HPMHooks.count.HP_clif_pRouletteRecvItem_post ) {
+ void (*postHookFunc) (int *fd, struct map_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pRouletteRecvItem_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_pRouletteRecvItem_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
void HP_clif_pNPCShopClosed(int fd, struct map_session_data *sd) {
int hIndex = 0;
if( HPMHooks.count.HP_clif_pNPCShopClosed_pre ) {
@@ -26404,41 +26666,14 @@ void HP_guild_castle_reconnect_sub(void *key, void *data, va_list ap) {
return;
}
/* gstorage */
-struct guild_storage* HP_gstorage_id2storage(int guild_id) {
- int hIndex = 0;
- struct guild_storage* retVal___ = NULL;
- if( HPMHooks.count.HP_gstorage_id2storage_pre ) {
- struct guild_storage* (*preHookFunc) (int *guild_id);
- *HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_gstorage_id2storage_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_gstorage_id2storage_pre[hIndex].func;
- retVal___ = preHookFunc(&guild_id);
- }
- if( *HPMforce_return ) {
- *HPMforce_return = false;
- return retVal___;
- }
- }
- {
- retVal___ = HPMHooks.source.gstorage.id2storage(guild_id);
- }
- if( HPMHooks.count.HP_gstorage_id2storage_post ) {
- struct guild_storage* (*postHookFunc) (struct guild_storage* retVal___, int *guild_id);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_gstorage_id2storage_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_gstorage_id2storage_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, &guild_id);
- }
- }
- return retVal___;
-}
-struct guild_storage* HP_gstorage_id2storage2(int guild_id) {
+struct guild_storage* HP_gstorage_ensure(int guild_id) {
int hIndex = 0;
struct guild_storage* retVal___ = NULL;
- if( HPMHooks.count.HP_gstorage_id2storage2_pre ) {
+ if( HPMHooks.count.HP_gstorage_ensure_pre ) {
struct guild_storage* (*preHookFunc) (int *guild_id);
*HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_gstorage_id2storage2_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_gstorage_id2storage2_pre[hIndex].func;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_gstorage_ensure_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_gstorage_ensure_pre[hIndex].func;
retVal___ = preHookFunc(&guild_id);
}
if( *HPMforce_return ) {
@@ -26447,12 +26682,12 @@ struct guild_storage* HP_gstorage_id2storage2(int guild_id) {
}
}
{
- retVal___ = HPMHooks.source.gstorage.id2storage2(guild_id);
+ retVal___ = HPMHooks.source.gstorage.ensure(guild_id);
}
- if( HPMHooks.count.HP_gstorage_id2storage2_post ) {
+ if( HPMHooks.count.HP_gstorage_ensure_post ) {
struct guild_storage* (*postHookFunc) (struct guild_storage* retVal___, int *guild_id);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_gstorage_id2storage2_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_gstorage_id2storage2_post[hIndex].func;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_gstorage_ensure_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_gstorage_ensure_post[hIndex].func;
retVal___ = postHookFunc(retVal___, &guild_id);
}
}
@@ -33756,6 +33991,32 @@ int HP_itemdb_validate_entry(struct item_data *entry, int n, const char *source)
}
return retVal___;
}
+void HP_itemdb_readdb_additional_fields(int itemid, config_setting_t *it, int n, const char *source) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_itemdb_readdb_additional_fields_pre ) {
+ void (*preHookFunc) (int *itemid, config_setting_t *it, int *n, const char *source);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_itemdb_readdb_additional_fields_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_itemdb_readdb_additional_fields_pre[hIndex].func;
+ preHookFunc(&itemid, it, &n, source);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.itemdb.readdb_additional_fields(itemid, it, n, source);
+ }
+ if( HPMHooks.count.HP_itemdb_readdb_additional_fields_post ) {
+ void (*postHookFunc) (int *itemid, config_setting_t *it, int *n, const char *source);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_itemdb_readdb_additional_fields_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_itemdb_readdb_additional_fields_post[hIndex].func;
+ postHookFunc(&itemid, it, &n, source);
+ }
+ }
+ return;
+}
int HP_itemdb_readdb_sql_sub(Sql *handle, int n, const char *source) {
int hIndex = 0;
int retVal___ = 0;
@@ -34029,6 +34290,60 @@ struct item_combo* HP_itemdb_id2combo(unsigned short id) {
}
return retVal___;
}
+bool HP_itemdb_is_item_usable(struct item_data *item) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_itemdb_is_item_usable_pre ) {
+ bool (*preHookFunc) (struct item_data *item);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_itemdb_is_item_usable_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_itemdb_is_item_usable_pre[hIndex].func;
+ retVal___ = preHookFunc(item);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.itemdb.is_item_usable(item);
+ }
+ if( HPMHooks.count.HP_itemdb_is_item_usable_post ) {
+ bool (*postHookFunc) (bool retVal___, struct item_data *item);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_itemdb_is_item_usable_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_itemdb_is_item_usable_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, item);
+ }
+ }
+ return retVal___;
+}
+bool HP_itemdb_lookup_const(const config_setting_t *it, const char *name, int *value) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_itemdb_lookup_const_pre ) {
+ bool (*preHookFunc) (const config_setting_t *it, const char *name, int *value);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_itemdb_lookup_const_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_itemdb_lookup_const_pre[hIndex].func;
+ retVal___ = preHookFunc(it, name, value);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.itemdb.lookup_const(it, name, value);
+ }
+ if( HPMHooks.count.HP_itemdb_lookup_const_post ) {
+ bool (*postHookFunc) (bool retVal___, const config_setting_t *it, const char *name, int *value);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_itemdb_lookup_const_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_itemdb_lookup_const_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, it, name, value);
+ }
+ }
+ return retVal___;
+}
/* logs */
void HP_logs_pick_pc(struct map_session_data *sd, e_log_pick_type type, int amount, struct item *itm, struct item_data *data) {
int hIndex = 0;
@@ -35299,15 +35614,15 @@ int HP_map_moveblock(struct block_list *bl, int x1, int y1, int64 tick) {
}
return retVal___;
}
-int HP_map_count_oncell(int16 m, int16 x, int16 y, int type) {
+int HP_map_count_oncell(int16 m, int16 x, int16 y, int type, int flag) {
int hIndex = 0;
int retVal___ = 0;
if( HPMHooks.count.HP_map_count_oncell_pre ) {
- int (*preHookFunc) (int16 *m, int16 *x, int16 *y, int *type);
+ int (*preHookFunc) (int16 *m, int16 *x, int16 *y, int *type, int *flag);
*HPMforce_return = false;
for(hIndex = 0; hIndex < HPMHooks.count.HP_map_count_oncell_pre; hIndex++ ) {
preHookFunc = HPMHooks.list.HP_map_count_oncell_pre[hIndex].func;
- retVal___ = preHookFunc(&m, &x, &y, &type);
+ retVal___ = preHookFunc(&m, &x, &y, &type, &flag);
}
if( *HPMforce_return ) {
*HPMforce_return = false;
@@ -35315,13 +35630,13 @@ int HP_map_count_oncell(int16 m, int16 x, int16 y, int type) {
}
}
{
- retVal___ = HPMHooks.source.map.count_oncell(m, x, y, type);
+ retVal___ = HPMHooks.source.map.count_oncell(m, x, y, type, flag);
}
if( HPMHooks.count.HP_map_count_oncell_post ) {
- int (*postHookFunc) (int retVal___, int16 *m, int16 *x, int16 *y, int *type);
+ int (*postHookFunc) (int retVal___, int16 *m, int16 *x, int16 *y, int *type, int *flag);
for(hIndex = 0; hIndex < HPMHooks.count.HP_map_count_oncell_post; hIndex++ ) {
postHookFunc = HPMHooks.list.HP_map_count_oncell_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, &m, &x, &y, &type);
+ retVal___ = postHookFunc(retVal___, &m, &x, &y, &type, &flag);
}
}
return retVal___;
@@ -35407,6 +35722,33 @@ int HP_map_search_freecell(struct block_list *src, int16 m, int16 *x, int16 *y,
}
return retVal___;
}
+bool HP_map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_map_closest_freecell_pre ) {
+ bool (*preHookFunc) (int16 *m, int16 *x, int16 *y, int *type, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_map_closest_freecell_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_map_closest_freecell_pre[hIndex].func;
+ retVal___ = preHookFunc(&m, x, y, &type, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.map.closest_freecell(m, x, y, type, flag);
+ }
+ if( HPMHooks.count.HP_map_closest_freecell_post ) {
+ bool (*postHookFunc) (bool retVal___, int16 *m, int16 *x, int16 *y, int *type, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_map_closest_freecell_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_map_closest_freecell_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &m, x, y, &type, &flag);
+ }
+ }
+ return retVal___;
+}
int HP_map_quit(struct map_session_data *sd) {
int hIndex = 0;
int retVal___ = 0;
@@ -42299,6 +42641,32 @@ void HP_mob_clear_spawninfo(void) {
}
return;
}
+void HP_mob_destroy_mob_db(int index) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mob_destroy_mob_db_pre ) {
+ void (*preHookFunc) (int *index);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_destroy_mob_db_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mob_destroy_mob_db_pre[hIndex].func;
+ preHookFunc(&index);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mob.destroy_mob_db(index);
+ }
+ if( HPMHooks.count.HP_mob_destroy_mob_db_post ) {
+ void (*postHookFunc) (int *index);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_destroy_mob_db_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mob_destroy_mob_db_post[hIndex].func;
+ postHookFunc(&index);
+ }
+ }
+ return;
+}
/* npc */
int HP_npc_init(bool minimal) {
int hIndex = 0;
@@ -42522,6 +42890,33 @@ int HP_npc_ontouch2_event(struct map_session_data *sd, struct npc_data *nd) {
}
return retVal___;
}
+int HP_npc_onuntouch_event(struct map_session_data *sd, struct npc_data *nd) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_npc_onuntouch_event_pre ) {
+ int (*preHookFunc) (struct map_session_data *sd, struct npc_data *nd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_onuntouch_event_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_npc_onuntouch_event_pre[hIndex].func;
+ retVal___ = preHookFunc(sd, nd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.npc.onuntouch_event(sd, nd);
+ }
+ if( HPMHooks.count.HP_npc_onuntouch_event_post ) {
+ int (*postHookFunc) (int retVal___, struct map_session_data *sd, struct npc_data *nd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_onuntouch_event_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_npc_onuntouch_event_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, sd, nd);
+ }
+ }
+ return retVal___;
+}
int HP_npc_enable_sub(struct block_list *bl, va_list ap) {
int hIndex = 0;
int retVal___ = 0;
@@ -43192,6 +43587,33 @@ int HP_npc_touch_areanpc(struct map_session_data *sd, int16 m, int16 x, int16 y)
}
return retVal___;
}
+int HP_npc_untouch_areanpc(struct map_session_data *sd, int16 m, int16 x, int16 y) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_npc_untouch_areanpc_pre ) {
+ int (*preHookFunc) (struct map_session_data *sd, int16 *m, int16 *x, int16 *y);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_untouch_areanpc_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_npc_untouch_areanpc_pre[hIndex].func;
+ retVal___ = preHookFunc(sd, &m, &x, &y);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.npc.untouch_areanpc(sd, m, x, y);
+ }
+ if( HPMHooks.count.HP_npc_untouch_areanpc_post ) {
+ int (*postHookFunc) (int retVal___, struct map_session_data *sd, int16 *m, int16 *x, int16 *y);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_untouch_areanpc_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_npc_untouch_areanpc_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, sd, &m, &x, &y);
+ }
+ }
+ return retVal___;
+}
int HP_npc_touch_areanpc2(struct mob_data *md) {
int hIndex = 0;
int retVal___ = 0;
@@ -43906,6 +44328,33 @@ bool HP_npc_viewisid(const char *viewid) {
}
return retVal___;
}
+struct npc_data* HP_npc_create_npc(int m, int x, int y) {
+ int hIndex = 0;
+ struct npc_data* retVal___ = NULL;
+ if( HPMHooks.count.HP_npc_create_npc_pre ) {
+ struct npc_data* (*preHookFunc) (int *m, int *x, int *y);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_create_npc_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_npc_create_npc_pre[hIndex].func;
+ retVal___ = preHookFunc(&m, &x, &y);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.npc.create_npc(m, x, y);
+ }
+ if( HPMHooks.count.HP_npc_create_npc_post ) {
+ struct npc_data* (*postHookFunc) (struct npc_data* retVal___, int *m, int *x, int *y);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_create_npc_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_npc_create_npc_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &m, &x, &y);
+ }
+ }
+ return retVal___;
+}
struct npc_data* HP_npc_add_warp(char *name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y) {
int hIndex = 0;
struct npc_data* retVal___ = NULL;
@@ -43987,6 +44436,33 @@ const char* HP_npc_parse_shop(char *w1, char *w2, char *w3, char *w4, const char
}
return retVal___;
}
+const char* HP_npc_parse_unknown_object(char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval) {
+ int hIndex = 0;
+ const char* retVal___ = NULL;
+ if( HPMHooks.count.HP_npc_parse_unknown_object_pre ) {
+ const char* (*preHookFunc) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_parse_unknown_object_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_npc_parse_unknown_object_pre[hIndex].func;
+ retVal___ = preHookFunc(w1, w2, w3, w4, start, buffer, filepath, retval);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.npc.parse_unknown_object(w1, w2, w3, w4, start, buffer, filepath, retval);
+ }
+ if( HPMHooks.count.HP_npc_parse_unknown_object_post ) {
+ const char* (*postHookFunc) (const char* retVal___, char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_parse_unknown_object_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_npc_parse_unknown_object_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, w1, w2, w3, w4, start, buffer, filepath, retval);
+ }
+ }
+ return retVal___;
+}
void HP_npc_convertlabel_db(struct npc_label_list *label_list, const char *filepath) {
int hIndex = 0;
if( HPMHooks.count.HP_npc_convertlabel_db_pre ) {
@@ -44418,6 +44894,32 @@ const char* HP_npc_parse_mapflag(char *w1, char *w2, char *w3, char *w4, const c
}
return retVal___;
}
+void HP_npc_parse_unknown_mapflag(const char *name, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_npc_parse_unknown_mapflag_pre ) {
+ void (*preHookFunc) (const char *name, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_parse_unknown_mapflag_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_npc_parse_unknown_mapflag_pre[hIndex].func;
+ preHookFunc(name, w3, w4, start, buffer, filepath, retval);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.npc.parse_unknown_mapflag(name, w3, w4, start, buffer, filepath, retval);
+ }
+ if( HPMHooks.count.HP_npc_parse_unknown_mapflag_post ) {
+ void (*postHookFunc) (const char *name, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_parse_unknown_mapflag_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_npc_parse_unknown_mapflag_post[hIndex].func;
+ postHookFunc(name, w3, w4, start, buffer, filepath, retval);
+ }
+ }
+ return;
+}
int HP_npc_parsesrcfile(const char *filepath, bool runOnInit) {
int hIndex = 0;
int retVal___ = 0;
@@ -46375,11 +46877,11 @@ bool HP_path_search_long(struct shootpath_data *spd, int16 m, int16 x0, int16 y0
}
return retVal___;
}
-int HP_path_check_distance(int dx, int dy, int distance) {
+bool HP_path_check_distance(int dx, int dy, int distance) {
int hIndex = 0;
- int retVal___ = 0;
+ bool retVal___ = false;
if( HPMHooks.count.HP_path_check_distance_pre ) {
- int (*preHookFunc) (int *dx, int *dy, int *distance);
+ bool (*preHookFunc) (int *dx, int *dy, int *distance);
*HPMforce_return = false;
for(hIndex = 0; hIndex < HPMHooks.count.HP_path_check_distance_pre; hIndex++ ) {
preHookFunc = HPMHooks.list.HP_path_check_distance_pre[hIndex].func;
@@ -46394,7 +46896,7 @@ int HP_path_check_distance(int dx, int dy, int distance) {
retVal___ = HPMHooks.source.path.check_distance(dx, dy, distance);
}
if( HPMHooks.count.HP_path_check_distance_post ) {
- int (*postHookFunc) (int retVal___, int *dx, int *dy, int *distance);
+ bool (*postHookFunc) (bool retVal___, int *dx, int *dy, int *distance);
for(hIndex = 0; hIndex < HPMHooks.count.HP_path_check_distance_post; hIndex++ ) {
postHookFunc = HPMHooks.list.HP_path_check_distance_post[hIndex].func;
retVal___ = postHookFunc(retVal___, &dx, &dy, &distance);
@@ -46429,6 +46931,60 @@ unsigned int HP_path_distance(int dx, int dy) {
}
return retVal___;
}
+bool HP_path_check_distance_client(int dx, int dy, int distance) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_path_check_distance_client_pre ) {
+ bool (*preHookFunc) (int *dx, int *dy, int *distance);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_path_check_distance_client_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_path_check_distance_client_pre[hIndex].func;
+ retVal___ = preHookFunc(&dx, &dy, &distance);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.path.check_distance_client(dx, dy, distance);
+ }
+ if( HPMHooks.count.HP_path_check_distance_client_post ) {
+ bool (*postHookFunc) (bool retVal___, int *dx, int *dy, int *distance);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_path_check_distance_client_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_path_check_distance_client_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &dx, &dy, &distance);
+ }
+ }
+ return retVal___;
+}
+int HP_path_distance_client(int dx, int dy) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_path_distance_client_pre ) {
+ int (*preHookFunc) (int *dx, int *dy);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_path_distance_client_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_path_distance_client_pre[hIndex].func;
+ retVal___ = preHookFunc(&dx, &dy);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.path.distance_client(dx, dy);
+ }
+ if( HPMHooks.count.HP_path_distance_client_post ) {
+ int (*postHookFunc) (int retVal___, int *dx, int *dy);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_path_distance_client_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_path_distance_client_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &dx, &dy);
+ }
+ }
+ return retVal___;
+}
/* pcg */
void HP_pcg_init(void) {
int hIndex = 0;
@@ -46831,60 +47387,6 @@ int HP_pc_class2idx(int class_) {
}
return retVal___;
}
-bool HP_pc_can_give_items(struct map_session_data *sd) {
- int hIndex = 0;
- bool retVal___ = false;
- if( HPMHooks.count.HP_pc_can_give_items_pre ) {
- bool (*preHookFunc) (struct map_session_data *sd);
- *HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_can_give_items_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_pc_can_give_items_pre[hIndex].func;
- retVal___ = preHookFunc(sd);
- }
- if( *HPMforce_return ) {
- *HPMforce_return = false;
- return retVal___;
- }
- }
- {
- retVal___ = HPMHooks.source.pc.can_give_items(sd);
- }
- if( HPMHooks.count.HP_pc_can_give_items_post ) {
- bool (*postHookFunc) (bool retVal___, struct map_session_data *sd);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_can_give_items_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_pc_can_give_items_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, sd);
- }
- }
- return retVal___;
-}
-bool HP_pc_can_give_bound_items(struct map_session_data *sd) {
- int hIndex = 0;
- bool retVal___ = false;
- if( HPMHooks.count.HP_pc_can_give_bound_items_pre ) {
- bool (*preHookFunc) (struct map_session_data *sd);
- *HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_can_give_bound_items_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_pc_can_give_bound_items_pre[hIndex].func;
- retVal___ = preHookFunc(sd);
- }
- if( *HPMforce_return ) {
- *HPMforce_return = false;
- return retVal___;
- }
- }
- {
- retVal___ = HPMHooks.source.pc.can_give_bound_items(sd);
- }
- if( HPMHooks.count.HP_pc_can_give_bound_items_post ) {
- bool (*postHookFunc) (bool retVal___, struct map_session_data *sd);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_can_give_bound_items_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_pc_can_give_bound_items_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, sd);
- }
- }
- return retVal___;
-}
bool HP_pc_can_talk(struct map_session_data *sd) {
int hIndex = 0;
bool retVal___ = false;
@@ -49178,6 +49680,32 @@ int HP_pc_equipitem(struct map_session_data *sd, int n, int req_pos) {
}
return retVal___;
}
+void HP_pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int pos) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_pc_equipitem_pos_pre ) {
+ void (*preHookFunc) (struct map_session_data *sd, struct item_data *id, int *pos);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_equipitem_pos_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pc_equipitem_pos_pre[hIndex].func;
+ preHookFunc(sd, id, &pos);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.pc.equipitem_pos(sd, id, pos);
+ }
+ if( HPMHooks.count.HP_pc_equipitem_pos_post ) {
+ void (*postHookFunc) (struct map_session_data *sd, struct item_data *id, int *pos);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_equipitem_pos_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pc_equipitem_pos_post[hIndex].func;
+ postHookFunc(sd, id, &pos);
+ }
+ }
+ return;
+}
int HP_pc_unequipitem(struct map_session_data *sd, int n, int flag) {
int hIndex = 0;
int retVal___ = 0;
@@ -49205,6 +49733,32 @@ int HP_pc_unequipitem(struct map_session_data *sd, int n, int flag) {
}
return retVal___;
}
+void HP_pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_pc_unequipitem_pos_pre ) {
+ void (*preHookFunc) (struct map_session_data *sd, int *n, int *pos);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_unequipitem_pos_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pc_unequipitem_pos_pre[hIndex].func;
+ preHookFunc(sd, &n, &pos);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.pc.unequipitem_pos(sd, n, pos);
+ }
+ if( HPMHooks.count.HP_pc_unequipitem_pos_post ) {
+ void (*postHookFunc) (struct map_session_data *sd, int *n, int *pos);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_unequipitem_pos_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pc_unequipitem_pos_post[hIndex].func;
+ postHookFunc(sd, &n, &pos);
+ }
+ }
+ return;
+}
int HP_pc_checkitem(struct map_session_data *sd) {
int hIndex = 0;
int retVal___ = 0;
@@ -49580,64 +50134,62 @@ int HP_pc_setcart(struct map_session_data *sd, int type) {
}
return retVal___;
}
-int HP_pc_setfalcon(struct map_session_data *sd, int flag) {
+void HP_pc_setfalcon(struct map_session_data *sd, bool flag) {
int hIndex = 0;
- int retVal___ = 0;
if( HPMHooks.count.HP_pc_setfalcon_pre ) {
- int (*preHookFunc) (struct map_session_data *sd, int *flag);
+ void (*preHookFunc) (struct map_session_data *sd, bool *flag);
*HPMforce_return = false;
for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_setfalcon_pre; hIndex++ ) {
preHookFunc = HPMHooks.list.HP_pc_setfalcon_pre[hIndex].func;
- retVal___ = preHookFunc(sd, &flag);
+ preHookFunc(sd, &flag);
}
if( *HPMforce_return ) {
*HPMforce_return = false;
- return retVal___;
+ return;
}
}
{
- retVal___ = HPMHooks.source.pc.setfalcon(sd, flag);
+ HPMHooks.source.pc.setfalcon(sd, flag);
}
if( HPMHooks.count.HP_pc_setfalcon_post ) {
- int (*postHookFunc) (int retVal___, struct map_session_data *sd, int *flag);
+ void (*postHookFunc) (struct map_session_data *sd, bool *flag);
for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_setfalcon_post; hIndex++ ) {
postHookFunc = HPMHooks.list.HP_pc_setfalcon_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, sd, &flag);
+ postHookFunc(sd, &flag);
}
}
- return retVal___;
+ return;
}
-int HP_pc_setriding(struct map_session_data *sd, int flag) {
+void HP_pc_setridingpeco(struct map_session_data *sd, bool flag) {
int hIndex = 0;
- int retVal___ = 0;
- if( HPMHooks.count.HP_pc_setriding_pre ) {
- int (*preHookFunc) (struct map_session_data *sd, int *flag);
+ if( HPMHooks.count.HP_pc_setridingpeco_pre ) {
+ void (*preHookFunc) (struct map_session_data *sd, bool *flag);
*HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_setriding_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_pc_setriding_pre[hIndex].func;
- retVal___ = preHookFunc(sd, &flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_setridingpeco_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pc_setridingpeco_pre[hIndex].func;
+ preHookFunc(sd, &flag);
}
if( *HPMforce_return ) {
*HPMforce_return = false;
- return retVal___;
+ return;
}
}
{
- retVal___ = HPMHooks.source.pc.setriding(sd, flag);
+ HPMHooks.source.pc.setridingpeco(sd, flag);
}
- if( HPMHooks.count.HP_pc_setriding_post ) {
- int (*postHookFunc) (int retVal___, struct map_session_data *sd, int *flag);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_setriding_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_pc_setriding_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, sd, &flag);
+ if( HPMHooks.count.HP_pc_setridingpeco_post ) {
+ void (*postHookFunc) (struct map_session_data *sd, bool *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_setridingpeco_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pc_setridingpeco_post[hIndex].func;
+ postHookFunc(sd, &flag);
}
}
- return retVal___;
+ return;
}
-void HP_pc_setmadogear(struct map_session_data *sd, int flag) {
+void HP_pc_setmadogear(struct map_session_data *sd, bool flag) {
int hIndex = 0;
if( HPMHooks.count.HP_pc_setmadogear_pre ) {
- void (*preHookFunc) (struct map_session_data *sd, int *flag);
+ void (*preHookFunc) (struct map_session_data *sd, bool *flag);
*HPMforce_return = false;
for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_setmadogear_pre; hIndex++ ) {
preHookFunc = HPMHooks.list.HP_pc_setmadogear_pre[hIndex].func;
@@ -49652,7 +50204,7 @@ void HP_pc_setmadogear(struct map_session_data *sd, int flag) {
HPMHooks.source.pc.setmadogear(sd, flag);
}
if( HPMHooks.count.HP_pc_setmadogear_post ) {
- void (*postHookFunc) (struct map_session_data *sd, int *flag);
+ void (*postHookFunc) (struct map_session_data *sd, bool *flag);
for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_setmadogear_post; hIndex++ ) {
postHookFunc = HPMHooks.list.HP_pc_setmadogear_post[hIndex].func;
postHookFunc(sd, &flag);
@@ -49660,6 +50212,58 @@ void HP_pc_setmadogear(struct map_session_data *sd, int flag) {
}
return;
}
+void HP_pc_setridingdragon(struct map_session_data *sd, unsigned int type) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_pc_setridingdragon_pre ) {
+ void (*preHookFunc) (struct map_session_data *sd, unsigned int *type);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_setridingdragon_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pc_setridingdragon_pre[hIndex].func;
+ preHookFunc(sd, &type);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.pc.setridingdragon(sd, type);
+ }
+ if( HPMHooks.count.HP_pc_setridingdragon_post ) {
+ void (*postHookFunc) (struct map_session_data *sd, unsigned int *type);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_setridingdragon_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pc_setridingdragon_post[hIndex].func;
+ postHookFunc(sd, &type);
+ }
+ }
+ return;
+}
+void HP_pc_setridingwug(struct map_session_data *sd, bool flag) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_pc_setridingwug_pre ) {
+ void (*preHookFunc) (struct map_session_data *sd, bool *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_setridingwug_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pc_setridingwug_pre[hIndex].func;
+ preHookFunc(sd, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.pc.setridingwug(sd, flag);
+ }
+ if( HPMHooks.count.HP_pc_setridingwug_post ) {
+ void (*postHookFunc) (struct map_session_data *sd, bool *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_setridingwug_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pc_setridingwug_post[hIndex].func;
+ postHookFunc(sd, &flag);
+ }
+ }
+ return;
+}
int HP_pc_changelook(struct map_session_data *sd, int type, int val) {
int hIndex = 0;
int retVal___ = 0;
@@ -53233,33 +53837,6 @@ int HP_pet_recovery_timer(int tid, int64 tick, int id, intptr_t data) {
}
return retVal___;
}
-int HP_pet_heal_timer(int tid, int64 tick, int id, intptr_t data) {
- int hIndex = 0;
- int retVal___ = 0;
- if( HPMHooks.count.HP_pet_heal_timer_pre ) {
- int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data);
- *HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_pet_heal_timer_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_pet_heal_timer_pre[hIndex].func;
- retVal___ = preHookFunc(&tid, &tick, &id, &data);
- }
- if( *HPMforce_return ) {
- *HPMforce_return = false;
- return retVal___;
- }
- }
- {
- retVal___ = HPMHooks.source.pet.heal_timer(tid, tick, id, data);
- }
- if( HPMHooks.count.HP_pet_heal_timer_post ) {
- int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_pet_heal_timer_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_pet_heal_timer_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data);
- }
- }
- return retVal___;
-}
int HP_pet_skill_support_timer(int tid, int64 tick, int id, intptr_t data) {
int hIndex = 0;
int retVal___ = 0;
@@ -53960,15 +54537,15 @@ void HP_script_warning(const char *src, const char *file, int start_line, const
}
return;
}
-bool HP_script_addScript(char *name, char *args, bool ( *func ) (struct script_state *st)) {
+bool HP_script_addScript(char *name, char *args, bool ( *func ) (struct script_state *st), bool isDeprecated) {
int hIndex = 0;
bool retVal___ = false;
if( HPMHooks.count.HP_script_addScript_pre ) {
- bool (*preHookFunc) (char *name, char *args, bool ( *func ) (struct script_state *st));
+ bool (*preHookFunc) (char *name, char *args, bool ( *func ) (struct script_state *st), bool *isDeprecated);
*HPMforce_return = false;
for(hIndex = 0; hIndex < HPMHooks.count.HP_script_addScript_pre; hIndex++ ) {
preHookFunc = HPMHooks.list.HP_script_addScript_pre[hIndex].func;
- retVal___ = preHookFunc(name, args, func);
+ retVal___ = preHookFunc(name, args, func, &isDeprecated);
}
if( *HPMforce_return ) {
*HPMforce_return = false;
@@ -53976,13 +54553,13 @@ bool HP_script_addScript(char *name, char *args, bool ( *func ) (struct script_s
}
}
{
- retVal___ = HPMHooks.source.script.addScript(name, args, func);
+ retVal___ = HPMHooks.source.script.addScript(name, args, func, isDeprecated);
}
if( HPMHooks.count.HP_script_addScript_post ) {
- bool (*postHookFunc) (bool retVal___, char *name, char *args, bool ( *func ) (struct script_state *st));
+ bool (*postHookFunc) (bool retVal___, char *name, char *args, bool ( *func ) (struct script_state *st), bool *isDeprecated);
for(hIndex = 0; hIndex < HPMHooks.count.HP_script_addScript_post; hIndex++ ) {
postHookFunc = HPMHooks.list.HP_script_addScript_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, name, args, func);
+ retVal___ = postHookFunc(retVal___, name, args, func, &isDeprecated);
}
}
return retVal___;
@@ -61331,39 +61908,6 @@ int HP_skill_destroy_trap(struct block_list *bl, va_list ap) {
}
return retVal___;
}
-int HP_skill_icewall_block(struct block_list *bl, va_list ap) {
- int hIndex = 0;
- int retVal___ = 0;
- if( HPMHooks.count.HP_skill_icewall_block_pre ) {
- int (*preHookFunc) (struct block_list *bl, va_list ap);
- *HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_icewall_block_pre; hIndex++ ) {
- va_list ap___copy; va_copy(ap___copy, ap);
- preHookFunc = HPMHooks.list.HP_skill_icewall_block_pre[hIndex].func;
- retVal___ = preHookFunc(bl, 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.skill.icewall_block(bl, ap___copy);
- va_end(ap___copy);
- }
- if( HPMHooks.count.HP_skill_icewall_block_post ) {
- int (*postHookFunc) (int retVal___, struct block_list *bl, va_list ap);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_icewall_block_post; hIndex++ ) {
- va_list ap___copy; va_copy(ap___copy, ap);
- postHookFunc = HPMHooks.list.HP_skill_icewall_block_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, bl, ap___copy);
- va_end(ap___copy);
- }
- }
- return retVal___;
-}
struct skill_unit_group_tickset* HP_skill_unitgrouptickset_search(struct block_list *bl, struct skill_unit_group *group, int64 tick) {
int hIndex = 0;
struct skill_unit_group_tickset* retVal___ = NULL;
@@ -64467,15 +65011,15 @@ unsigned short HP_status_calc_batk(struct block_list *bl, struct status_change *
}
return retVal___;
}
-unsigned short HP_status_base_matk(const struct status_data *st, int level) {
+unsigned short HP_status_base_matk(struct block_list *bl, const struct status_data *st, int level) {
int hIndex = 0;
unsigned short retVal___ = 0;
if( HPMHooks.count.HP_status_base_matk_pre ) {
- unsigned short (*preHookFunc) (const struct status_data *st, int *level);
+ unsigned short (*preHookFunc) (struct block_list *bl, const struct status_data *st, int *level);
*HPMforce_return = false;
for(hIndex = 0; hIndex < HPMHooks.count.HP_status_base_matk_pre; hIndex++ ) {
preHookFunc = HPMHooks.list.HP_status_base_matk_pre[hIndex].func;
- retVal___ = preHookFunc(st, &level);
+ retVal___ = preHookFunc(bl, st, &level);
}
if( *HPMforce_return ) {
*HPMforce_return = false;
@@ -64483,13 +65027,13 @@ unsigned short HP_status_base_matk(const struct status_data *st, int level) {
}
}
{
- retVal___ = HPMHooks.source.status.base_matk(st, level);
+ retVal___ = HPMHooks.source.status.base_matk(bl, st, level);
}
if( HPMHooks.count.HP_status_base_matk_post ) {
- unsigned short (*postHookFunc) (unsigned short retVal___, const struct status_data *st, int *level);
+ unsigned short (*postHookFunc) (unsigned short retVal___, struct block_list *bl, const struct status_data *st, int *level);
for(hIndex = 0; hIndex < HPMHooks.count.HP_status_base_matk_post; hIndex++ ) {
postHookFunc = HPMHooks.list.HP_status_base_matk_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, st, &level);
+ retVal___ = postHookFunc(retVal___, bl, st, &level);
}
}
return retVal___;
@@ -66920,6 +67464,59 @@ int HP_unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id,
}
return retVal___;
}
+int HP_unit_step_timer(int tid, int64 tick, int id, intptr_t data) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_unit_step_timer_pre ) {
+ int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_unit_step_timer_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_unit_step_timer_pre[hIndex].func;
+ retVal___ = preHookFunc(&tid, &tick, &id, &data);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.unit.step_timer(tid, tick, id, data);
+ }
+ if( HPMHooks.count.HP_unit_step_timer_post ) {
+ int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_unit_step_timer_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_unit_step_timer_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data);
+ }
+ }
+ return retVal___;
+}
+void HP_unit_stop_stepaction(struct block_list *bl) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_unit_stop_stepaction_pre ) {
+ void (*preHookFunc) (struct block_list *bl);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_unit_stop_stepaction_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_unit_stop_stepaction_pre[hIndex].func;
+ preHookFunc(bl);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.unit.stop_stepaction(bl);
+ }
+ if( HPMHooks.count.HP_unit_stop_stepaction_post ) {
+ void (*postHookFunc) (struct block_list *bl);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_unit_stop_stepaction_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_unit_stop_stepaction_post[hIndex].func;
+ postHookFunc(bl);
+ }
+ }
+ return;
+}
int HP_unit_is_walking(struct block_list *bl) {
int hIndex = 0;
int retVal___ = 0;
@@ -67136,32 +67733,31 @@ int HP_unit_set_target(struct unit_data *ud, int target_id) {
}
return retVal___;
}
-int HP_unit_stop_attack(struct block_list *bl) {
+void HP_unit_stop_attack(struct block_list *bl) {
int hIndex = 0;
- int retVal___ = 0;
if( HPMHooks.count.HP_unit_stop_attack_pre ) {
- int (*preHookFunc) (struct block_list *bl);
+ void (*preHookFunc) (struct block_list *bl);
*HPMforce_return = false;
for(hIndex = 0; hIndex < HPMHooks.count.HP_unit_stop_attack_pre; hIndex++ ) {
preHookFunc = HPMHooks.list.HP_unit_stop_attack_pre[hIndex].func;
- retVal___ = preHookFunc(bl);
+ preHookFunc(bl);
}
if( *HPMforce_return ) {
*HPMforce_return = false;
- return retVal___;
+ return;
}
}
{
- retVal___ = HPMHooks.source.unit.stop_attack(bl);
+ HPMHooks.source.unit.stop_attack(bl);
}
if( HPMHooks.count.HP_unit_stop_attack_post ) {
- int (*postHookFunc) (int retVal___, struct block_list *bl);
+ void (*postHookFunc) (struct block_list *bl);
for(hIndex = 0; hIndex < HPMHooks.count.HP_unit_stop_attack_post; hIndex++ ) {
postHookFunc = HPMHooks.list.HP_unit_stop_attack_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, bl);
+ postHookFunc(bl);
}
}
- return retVal___;
+ return;
}
int HP_unit_unattackable(struct block_list *bl) {
int hIndex = 0;
diff --git a/src/plugins/HPMHooking/HPMHooking.sources.inc b/src/plugins/HPMHooking/HPMHooking_map.sources.inc
index 53bb6bcad..53bb6bcad 100644
--- a/src/plugins/HPMHooking/HPMHooking.sources.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.sources.inc
diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in
index 77040d567..802d1015a 100644
--- a/src/plugins/Makefile.in
+++ b/src/plugins/Makefile.in
@@ -24,10 +24,11 @@ MYPLUGINS =
######### DO NOT EDIT ANYTHING BELOW THIS LINE!!! ##################
# All plugins in the src/plugins directory
-ALLPLUGINS = $(basename $(wildcard *.c))
+HPMHOOKING = $(addprefix HPMHooking_, login char map)
+ALLPLUGINS = $(filter-out HPMHooking, $(basename $(wildcard *.c))) $(HPMHOOKING)
# Plugins that will be built through 'make plugins' or 'make all'
-PLUGINS = sample db2sql HPMHooking $(MYPLUGINS)
+PLUGINS = sample db2sql HPMHooking_char HPMHooking_login HPMHooking_map $(MYPLUGINS)
COMMON_D = ../common
COMMON_H = $(wildcard $(COMMON_D)/*.h)
@@ -46,11 +47,14 @@ CC = @CC@
export CC
#####################################################################
-.PHONY: all $(ALLPLUGINS) clean buildclean help
+.PHONY: all $(ALLPLUGINS) HPMHooking clean buildclean help
all: $(PLUGINS) Makefile
$(ALLPLUGINS): %: ../../plugins/%@DLLEXT@
+ @echo " PLUGIN $@"
+
+HPMHooking: $(HPMHOOKING)
buildclean:
@echo " CLEAN plugins (build temp files)"
@@ -80,4 +84,12 @@ Makefile: Makefile.in
../../plugins/%@DLLEXT@: %.c $(ALL_H) $$(shell ls %/* 2>/dev/null)
@echo " CC $<"
- @$(CC) @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o $@ $<
+ @$(CC) @PLUGINSTATIC@ @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o $@ $<
+
+../../plugins/HPMHooking_login@DLLEXT@: HPMHOOKINGTYPE = LOGIN
+../../plugins/HPMHooking_char@DLLEXT@: HPMHOOKINGTYPE = CHAR
+../../plugins/HPMHooking_map@DLLEXT@: HPMHOOKINGTYPE = MAP
+
+../../plugins/HPMHooking_%@DLLEXT@: HPMHooking.c $(ALL_H) $$(shell ls HPMHooking/*_%* HPMHooking/*_common* 2>/dev/null)
+ @echo " CC $< ($(HPMHOOKINGTYPE))"
+ @$(CC) -DHPMHOOKING_$(HPMHOOKINGTYPE) @PLUGINSTATIC@ @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o $@ $<
diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c
index 751f4be8a..eda61d026 100644
--- a/src/plugins/db2sql.c
+++ b/src/plugins/db2sql.c
@@ -49,7 +49,7 @@ void hstr(const char *str) {
}
int db2sql(config_setting_t *entry, int n, const char *source) {
struct item_data *it = NULL;
-
+
if( (it = itemdb->exists(itemdb_readdb_libconfig_sub(entry,n,source))) ) {
char e_name[ITEM_NAME_LENGTH*2+1];
const char *bonus = NULL;
@@ -67,7 +67,7 @@ int db2sql(config_setting_t *entry, int n, const char *source) {
// name_english
SQL->EscapeString(NULL, e_name, it->name);
StrBuf->Printf(&buf, "'%s',", e_name);
-
+
// name_japanese
SQL->EscapeString(NULL, e_name, it->jname);
StrBuf->Printf(&buf, "'%s',", e_name);
@@ -200,7 +200,7 @@ int db2sql(config_setting_t *entry, int n, const char *source) {
SQL->EscapeString(NULL, tosql.buf[0].p, str);
}
StrBuf->Printf(&buf, "'%s',", it->script?tosql.buf[0].p:"");
-
+
// equip_script
if (it->equip_script) {
libconfig->setting_lookup_string(entry, "OnEquipScript", &bonus);
@@ -290,56 +290,56 @@ void do_db2sql(void) {
ShowInfo("db2sql: this should not be used with 'db_use_sql_item_db' enabled, skipping...\n");
return;
}
-
+
/* link */
itemdb_readdb_libconfig_sub = itemdb->readdb_libconfig_sub;
itemdb->readdb_libconfig_sub = db2sql;
/* */
-
+
if ((tosql.fp = fopen("sql-files/item_db_re.sql", "wt+")) == NULL) {
ShowError("itemdb_tosql: File not found \"%s\".\n", "sql-files/item_db_re.sql");
return;
- }
-
+ }
+
tosql.db_name = map->item_db_re_db;
totable();
-
+
memset(&tosql.buf, 0, sizeof(tosql.buf) );
-
+
itemdb->clear(false);
itemdb->readdb_libconfig("re/item_db.conf");
-
+
fclose(tosql.fp);
-
+
if ((tosql.fp = fopen("sql-files/item_db.sql", "wt+")) == NULL) {
ShowError("itemdb_tosql: File not found \"%s\".\n", "sql-files/item_db.sql");
return;
- }
-
+ }
+
tosql.db_name = map->item_db_db;
totable();
-
+
itemdb->clear(false);
itemdb->readdb_libconfig("pre-re/item_db.conf");
-
+
fclose(tosql.fp);
-
+
if ((tosql.fp = fopen("sql-files/item_db2.sql", "wt+")) == NULL) {
ShowError("itemdb_tosql: File not found \"%s\".\n", "sql-files/item_db2.sql");
return;
- }
-
+ }
+
tosql.db_name = map->item_db2_db;
totable();
-
+
itemdb->clear(false);
itemdb->readdb_libconfig("item_db2.conf");
-
+
fclose(tosql.fp);
-
+
/* unlink */
itemdb->readdb_libconfig_sub = itemdb_readdb_libconfig_sub;
-
+
if( tosql.buf[0].p ) aFree(tosql.buf[0].p);
if( tosql.buf[1].p ) aFree(tosql.buf[1].p);
if( tosql.buf[2].p ) aFree(tosql.buf[2].p);
@@ -359,7 +359,7 @@ HPExport void server_preinit (void) {
iMalloc = GET_SYMBOL("iMalloc");
libconfig = GET_SYMBOL("libconfig");
StrBuf = GET_SYMBOL("StrBuf");
-
+
addArg("--db2sql",false,db2sql_arg,NULL);
}
HPExport void plugin_init (void) {
diff --git a/src/plugins/dbghelpplug.c b/src/plugins/dbghelpplug.c
index d121e9492..bf43c0b23 100644
--- a/src/plugins/dbghelpplug.c
+++ b/src/plugins/dbghelpplug.c
@@ -44,65 +44,65 @@ HPExport struct hplugin_info pinfo = {
#ifdef _NO_CVCONST_H
typedef enum _BasicType {
- btNoType = 0,
- btVoid = 1,
- btChar = 2,
- btWChar = 3,
- btInt = 6,
- btUInt = 7,
- btFloat = 8,
- btBCD = 9,
- btBool = 10,
- btLong = 13,
- btULong = 14,
- btCurrency = 25,
- btDate = 26,
- btVariant = 27,
- btComplex = 28,
- btBit = 29,
- btBSTR = 30,
- btHresult = 31
+ btNoType = 0,
+ btVoid = 1,
+ btChar = 2,
+ btWChar = 3,
+ btInt = 6,
+ btUInt = 7,
+ btFloat = 8,
+ btBCD = 9,
+ btBool = 10,
+ btLong = 13,
+ btULong = 14,
+ btCurrency = 25,
+ btDate = 26,
+ btVariant = 27,
+ btComplex = 28,
+ btBit = 29,
+ btBSTR = 30,
+ btHresult = 31
} BasicType;
typedef enum _UdtKind
{
- UdtStruct,
- UdtClass,
- UdtUnion
+ UdtStruct,
+ UdtClass,
+ UdtUnion
} UdtKind;
/*
typedef enum _SymTag {
- SymTagNull = 0,
- SymTagExe = 1,
- SymTagCompiland = 2,
- SymTagCompilandDetails = 3,
- SymTagCompilandEnv = 4,
- SymTagFunction = 5,
- SymTagBlock = 6,
- SymTagData = 7,
- SymTagAnnotation = 8,
- SymTagLabel = 9,
- SymTagPublicSymbol = 10,
- SymTagUDT = 11,
- SymTagEnum = 12,
- SymTagFunctionType = 13,
- SymTagPointerType = 14,
- SymTagArrayType = 15,
- SymTagBaseType = 16,
- SymTagTypedef = 17,
- SymTagBaseClass = 18,
- SymTagFriend = 19,
- SymTagFunctionArgType = 20,
- SymTagFuncDebugStart = 21,
- SymTagFuncDebugEnd = 22,
- SymTagUsingNamespace = 23,
- SymTagVTableShape = 24,
- SymTagVTable = 25,
- SymTagCustom = 26,
- SymTagThunk = 27,
- SymTagCustomType = 28,
- SymTagManagedType = 29,
- SymTagDimension = 30
+ SymTagNull = 0,
+ SymTagExe = 1,
+ SymTagCompiland = 2,
+ SymTagCompilandDetails = 3,
+ SymTagCompilandEnv = 4,
+ SymTagFunction = 5,
+ SymTagBlock = 6,
+ SymTagData = 7,
+ SymTagAnnotation = 8,
+ SymTagLabel = 9,
+ SymTagPublicSymbol = 10,
+ SymTagUDT = 11,
+ SymTagEnum = 12,
+ SymTagFunctionType = 13,
+ SymTagPointerType = 14,
+ SymTagArrayType = 15,
+ SymTagBaseType = 16,
+ SymTagTypedef = 17,
+ SymTagBaseClass = 18,
+ SymTagFriend = 19,
+ SymTagFunctionArgType = 20,
+ SymTagFuncDebugStart = 21,
+ SymTagFuncDebugEnd = 22,
+ SymTagUsingNamespace = 23,
+ SymTagVTableShape = 24,
+ SymTagVTable = 25,
+ SymTagCustom = 26,
+ SymTagThunk = 27,
+ SymTagCustomType = 28,
+ SymTagManagedType = 29,
+ SymTagDimension = 30
} SymTag;
*/
#endif /* _NO_CVCONST_H */
@@ -429,17 +429,17 @@ Dhp__PrintProcessInfo(
fprintf(log_file,
"eip=%08x esp=%08x ebp=%08x iopl=%1x %s %s %s %s %s %s %s %s %s %s\n",
context->Eip, context->Esp, context->Ebp,
- (context->EFlags >> 12) & 3, // IOPL level value
- context->EFlags & 0x00100000 ? "vip" : " ", // VIP (virtual interrupt pending)
- context->EFlags & 0x00080000 ? "vif" : " ", // VIF (virtual interrupt flag)
- context->EFlags & 0x00000800 ? "ov" : "nv", // VIF (virtual interrupt flag)
- context->EFlags & 0x00000400 ? "dn" : "up", // OF (overflow flag)
- context->EFlags & 0x00000200 ? "ei" : "di", // IF (interrupt enable flag)
- context->EFlags & 0x00000080 ? "ng" : "pl", // SF (sign flag)
- context->EFlags & 0x00000040 ? "zr" : "nz", // ZF (zero flag)
- context->EFlags & 0x00000010 ? "ac" : "na", // AF (aux carry flag)
- context->EFlags & 0x00000004 ? "po" : "pe", // PF (parity flag)
- context->EFlags & 0x00000001 ? "cy" : "nc"); // CF (carry flag)
+ (context->EFlags >> 12) & 3, // IOPL level value
+ context->EFlags & 0x00100000 ? "vip" : " ", // VIP (virtual interrupt pending)
+ context->EFlags & 0x00080000 ? "vif" : " ", // VIF (virtual interrupt flag)
+ context->EFlags & 0x00000800 ? "ov" : "nv", // VIF (virtual interrupt flag)
+ context->EFlags & 0x00000400 ? "dn" : "up", // OF (overflow flag)
+ context->EFlags & 0x00000200 ? "ei" : "di", // IF (interrupt enable flag)
+ context->EFlags & 0x00000080 ? "ng" : "pl", // SF (sign flag)
+ context->EFlags & 0x00000040 ? "zr" : "nz", // ZF (zero flag)
+ context->EFlags & 0x00000010 ? "ac" : "na", // AF (aux carry flag)
+ context->EFlags & 0x00000004 ? "po" : "pe", // PF (parity flag)
+ context->EFlags & 0x00000001 ? "cy" : "nc"); // CF (carry flag)
}
if( context->ContextFlags & CONTEXT_SEGMENTS )
{
@@ -525,9 +525,9 @@ Dhp__PrintTypeName(
case btVoid: fprintf(log_file, "void"); break;
case btChar: fprintf(log_file, "char"); break;
case btWChar: fprintf(log_file, "wchar"); break;
- case btULong: fprintf(log_file, "unsigned "); // next
+ case btULong: fprintf(log_file, "unsigned "); // next
case btLong: fprintf(log_file, "long"); break;
- case btUInt: fprintf(log_file, "unsigned "); // next
+ case btUInt: fprintf(log_file, "unsigned "); // next
case btInt:
if( length == sizeof(char) ) fprintf(log_file, "char");
else if( length == sizeof(short) ) fprintf(log_file, "short");
@@ -870,7 +870,7 @@ Dhp__PrintValueCWideString(
}
__except( EXCEPTION_EXECUTE_HANDLER )
{
- if( length ) Dhp__PrintValueWideChars(log_file, str, length*sizeof(WCHAR), TRUE); // print readable part
+ if( length ) Dhp__PrintValueWideChars(log_file, str, length*sizeof(WCHAR), TRUE); // print readable part
fprintf(log_file, "<invalid memory>");
return;
}
@@ -901,7 +901,7 @@ Dhp__PrintValueCString(
}
__except( EXCEPTION_EXECUTE_HANDLER )
{
- if( length ) Dhp__PrintValueChars(log_file, str, length*sizeof(char), TRUE); // print readable part
+ if( length ) Dhp__PrintValueChars(log_file, str, length*sizeof(char), TRUE); // print readable part
fprintf(log_file, "<invalid memory>");
return;
}
@@ -954,7 +954,7 @@ Dhp__PrintDataValue(
ULONG i;
BYTE b = 0;
for( i = 0; i < length; ++i )
- b += p[i]; // add to make sure it's not optimized out in release mode
+ b += p[i]; // add to make sure it's not optimized out in release mode
// Don't continue if there's no valid data
if( b == 0 ) {
@@ -1091,7 +1091,7 @@ Dhp__PrintDataValue(
DWORD i;
// count children
- if( !SymGetTypeInfo_(hProcess, modBase, typeIndex, TI_GET_CHILDRENCOUNT, &childCount)
+ if( !SymGetTypeInfo_(hProcess, modBase, typeIndex, TI_GET_CHILDRENCOUNT, &childCount)
|| !childCount ) {
fprintf(log_file, "<no children found>");
Dhp__PrintValueBytes(log_file, (BYTE*)pVariable, length);
@@ -1228,28 +1228,27 @@ Dhp__PrintDataInfo(
nr_of_var = pInterData->nr_of_var;
// Determine the scope and address of the variable
- if( pSymInfo->Flags & SYMFLAG_REGREL )
- {
+ if( pSymInfo->Flags & SYMFLAG_REGREL ) {
pVariable = pStackframe->AddrFrame.Offset;
pVariable += (DWORD_PTR)pSymInfo->Address;
if( pSymInfo->Flags & SYMFLAG_PARAMETER )
- scope = PARAM; // parameter
+ scope = PARAM; // parameter
else if( pSymInfo->Flags & SYMFLAG_LOCAL )
{
- scope = LOCAL; // local
+ scope = LOCAL; // local
#if defined(_M_IX86)
- if( (LONG64)pSymInfo->Address > 0) scope = PARAM; // parameter as local (bug in DBGHELP 5.1)
+ if( (LONG64)pSymInfo->Address > 0) scope = PARAM; // parameter as local (bug in DBGHELP 5.1)
#endif
}
}
else if( pSymInfo->Flags & SYMFLAG_REGISTER )
{
- scope = ( pSymInfo->Flags & SYMFLAG_PARAMETER ? PARAM : LOCAL ); // register, optimized out(?)
+ scope = ( pSymInfo->Flags & SYMFLAG_PARAMETER ? PARAM : LOCAL ); // register, optimized out(?)
}
else
{
pVariable = (DWORD_PTR)pSymInfo->Address;
- scope = GLOBAL; // It must be a global variable
+ scope = GLOBAL; // It must be a global variable
}
// check if we should to log the variable
@@ -1311,7 +1310,7 @@ Dhp__EnumSymbolsCallback(
PVOID pData)
{
if( pSymInfo == NULL )
- return TRUE; // try other symbols
+ return TRUE; // try other symbols
if( pData == NULL )
{
@@ -1345,7 +1344,7 @@ Dhp__PrintSourceLine(
assert( log_file != NULL );
// generate search paths
- strcpy(path, filename); // original path
+ strcpy(path, filename); // original path
p = strrchr(path, '\\');
if( p )
{
@@ -1355,15 +1354,15 @@ Dhp__PrintSourceLine(
{
while( strstr(p+1, "\\src\\") )
p = strstr(p+1, "\\src\\");
- strcat(path, p+1); // last src folder path
+ strcat(path, p+1); // last src folder path
p = strrchr(path, '\\');
memcpy(p, ";\0", 2);
}
filename = strrchr(filename, '\\')+1;
}
else
- *path = '\0'; // no path
- strcat(path, "."); // current directoy
+ *path = '\0'; // no path
+ strcat(path, "."); // current directoy
// search for file and line
if( SearchPathA(path, filename, NULL, MAX_PATH, pathBuffer, NULL) )
@@ -1668,8 +1667,8 @@ Dhp__CreateFiles(
char* out_logFileName,
char* out_dmpFileName)
{
-#define LEN_TIMESTAMP 14 // "YYYYMMDDhhmmss"
-#define LEN_EXT 4 // ".rpt" or ".dmp"
+#define LEN_TIMESTAMP 14 // "YYYYMMDDhhmmss"
+#define LEN_EXT 4 // ".rpt" or ".dmp"
char baseFileName[MAX_PATH+1];
char timestamp[LEN_TIMESTAMP+1];
FILE* fp;
@@ -1682,7 +1681,7 @@ Dhp__CreateFiles(
char* pTerm = strrchr(baseFileName, '\\');
if( pTerm == NULL ) pTerm = baseFileName;
pTerm = strrchr(pTerm, '.');
- if( pTerm ) *pTerm = '\0'; // remove extension
+ if( pTerm ) *pTerm = '\0'; // remove extension
}
else if( GetTempPathA(MAX_PATH-6-LEN_TIMESTAMP-LEN_EXT, baseFileName) )
{// in temp folder
@@ -1700,20 +1699,20 @@ Dhp__CreateFiles(
strftime(timestamp, sizeof(timestamp), "%Y%m%d%H%M%S", localtime(&now));
#endif
timestamp[LEN_TIMESTAMP] = '\0';
-
+
sprintf(out_logFileName, "%s%s.rpt", baseFileName, timestamp);
fp = fopen(out_logFileName, "w");
if( fp == NULL )
- return FALSE; // failed to create log file
+ return FALSE; // failed to create log file
fclose(fp);
sprintf(out_dmpFileName, "%s%s.dmp", baseFileName, timestamp);
fp = fopen(out_dmpFileName, "w");
if( fp == NULL)
- return FALSE; // failed to create dump file
+ return FALSE; // failed to create dump file
fclose(fp);
- return TRUE; // success
+ return TRUE; // success
#undef LEN_EXT
#undef LEN_TIMESTAMP
}
diff --git a/src/plugins/sample.c b/src/plugins/sample.c
index 84df88e06..03d32b1f3 100644
--- a/src/plugins/sample.c
+++ b/src/plugins/sample.c
@@ -18,10 +18,10 @@
#include "../common/HPMDataCheck.h" /* should always be the last file included! (if you don't make it last, it'll intentionally break compile time) */
HPExport struct hplugin_info pinfo = {
- "Sample", // Plugin name
- SERVER_TYPE_MAP,// Which server types this plugin works with?
- "0.1", // Plugin version
- HPM_VERSION, // HPM Version (don't change, macro is automatically updated)
+ "Sample", // Plugin name
+ SERVER_TYPE_CHAR|SERVER_TYPE_LOGIN|SERVER_TYPE_MAP,// Which server types this plugin works with?
+ "0.1", // Plugin version
+ HPM_VERSION, // HPM Version (don't change, macro is automatically updated)
};
ACMD(sample) {//@sample command - 5 params: const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info
printf("I'm being run! message -> '%s' by %s\n",message,sd->status.name);
@@ -46,20 +46,20 @@ struct sample_data_struct {
void sample_packet0f3(int fd) {
struct map_session_data *sd = session[fd]->session_data;
struct sample_data_struct *data;
-
+
if( !sd ) return;/* socket didn't fully log-in? this packet shouldn't do anything then! */
-
+
ShowInfo("sample_packet0f3: Hello World! received 0xf3 for '%s', redirecting!\n",sd->status.name);
-
+
/* sample usage of appending data to a socket_data (session[]) entry */
if( !(data = getFromSession(session[fd],0)) ) {
CREATE(data,struct sample_data_struct,1);
-
+
data->lastMSGPosition.map = sd->status.last_point.map;
data->lastMSGPosition.x = sd->status.last_point.x;
data->lastMSGPosition.y = sd->status.last_point.y;
data->someNumber = rand()%777;
-
+
ShowInfo("Created Appended session[] data, %d %d %d %d\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber);
addToSession(session[fd],data,0,true);
} else {
@@ -69,16 +69,16 @@ void sample_packet0f3(int fd) {
removeFromSession(session[fd],0);
}
}
-
+
/* sample usage of appending data to a map_session_data (sd) entry */
if( !(data = getFromMSD(sd,0)) ) {
CREATE(data,struct sample_data_struct,1);
-
+
data->lastMSGPosition.map = sd->status.last_point.map;
data->lastMSGPosition.x = sd->status.last_point.x;
data->lastMSGPosition.y = sd->status.last_point.y;
data->someNumber = rand()%777;
-
+
ShowInfo("Created Appended map_session_data data, %d %d %d %d\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber);
addToMSD(sd,data,0,true);
} else {
@@ -89,7 +89,6 @@ void sample_packet0f3(int fd) {
}
}
-
clif->pGlobalMessage(fd,sd);
}
int my_pc_dropitem_storage;/* storage var */
@@ -120,7 +119,7 @@ void parse_my_setting(const char *val) {
HPExport void plugin_init (void) {
char *server_type;
char *server_name;
-
+
/* core vars */
server_type = GET_SYMBOL("SERVER_TYPE");
server_name = GET_SYMBOL("SERVER_NAME");
@@ -138,40 +137,40 @@ HPExport void plugin_init (void) {
session = GET_SYMBOL("session");
ShowInfo ("Server type is ");
-
+
switch (*server_type) {
case SERVER_TYPE_LOGIN: printf ("Login Server\n"); break;
case SERVER_TYPE_CHAR: printf ("Char Server\n"); break;
case SERVER_TYPE_MAP: printf ("Map Server\n"); break;
}
-
+
ShowInfo ("I'm being run from the '%s' filename\n", server_name);
-
+
/* addAtcommand("command-key",command-function) tells map server to call ACMD(sample) when "sample" command is used */
/* - it will print a warning when used on a non-map-server plugin */
addAtcommand("sample",sample);//link our '@sample' command
-
+
/* addScriptCommand("script-command-name","script-command-params-info",script-function) tells map server to call BUILDIN(sample) for the "sample(i)" command */
/* - it will print a warning when used on a non-map-server plugin */
addScriptCommand("sample","i",sample);
-
+
/* addCPCommand("console-command-name",command-function) tells server to call CPCMD(sample) for the 'this is a sample <optional-args>' console call */
/* in "console-command-name" usage of ':' indicates a category, for example 'this:is:a:sample' translates to 'this is a sample',
* therefore 'this -> is -> a -> sample', it can be used to aggregate multiple commands under the same category or to append commands to existing categories
* categories inherit the special keyword 'help' which prints the subsequent commands, e.g. 'server help' prints all categories and commands under 'server'
* therefore 'this help' would inform about 'is (category) -> a (category) -> sample (command)'*/
addCPCommand("this:is:a:sample",sample);
-
+
/* addPacket(packetID,packetLength,packetFunction,packetIncomingPoint) */
/* adds packetID of packetLength (-1 for dynamic length where length is defined in the packet { packetID (2 Byte) , packetLength (2 Byte) , ... })
* to trigger packetFunction in the packetIncomingPoint section ( available points listed in enum HPluginPacketHookingPoints within src/common/HPMi.h ) */
addPacket(0xf3,-1,sample_packet0f3,hpClif_Parse);
-
+
/* in this sample we add a PreHook to pc->dropitem */
/* to identify whether the item being dropped is on amount higher than 1 */
/* if so, it stores the amount on a variable (my_pc_dropitem_storage) and changes the amount to 1 */
addHookPre("pc->dropitem",my_pc_dropitem_pre);
-
+
/* in this sample we add a PostHook to pc->dropitem */
/* if the original pc->dropitem was successful and the amount stored on my_pc_dropitem_storage is higher than 1, */
/* our posthook will display a message to the user about the cap */
@@ -187,7 +186,6 @@ HPExport void server_preinit (void) {
}
/* run when server is ready (online) */
HPExport void server_online (void) {
-
}
/* run when server is shutting down */
HPExport void plugin_final (void) {
diff --git a/src/test/test_spinlock.c b/src/test/test_spinlock.c
index 19a25f9d2..1b31e9b46 100644
--- a/src/test/test_spinlock.c
+++ b/src/test/test_spinlock.c
@@ -25,19 +25,19 @@ static volatile int32 done_threads = 0;
static void *worker(void *p){
register int i;
-
+
for(i = 0; i < PERINC; i++){
EnterSpinLock(&lock);
EnterSpinLock(&lock);
-
+
val++;
-
+
LeaveSpinLock(&lock);
LeaveSpinLock(&lock);
}
-
+
InterlockedIncrement(&done_threads);
-
+
return NULL;
}//end: worker()
@@ -46,34 +46,31 @@ int do_init(int argc, char **argv){
rAthread *t[THRC];
int j, i;
int ok;
-
+
ShowStatus("==========\n");
ShowStatus("TEST: %u Runs, (%u Threads)\n", LOOPS, THRC);
ShowStatus("This can take a while\n");
ShowStatus("\n\n");
-
+
ok =0;
for(j = 0; j < LOOPS; j++){
val = 0;
done_threads = 0;
-
+
InitializeSpinLock(&lock);
-
for(i =0; i < THRC; i++){
t[i] = rathread_createEx( worker, NULL, 1024*512, RAT_PRIO_NORMAL);
}
-
-
+
while(1){
if(InterlockedCompareExchange(&done_threads, THRC, THRC) == THRC)
break;
-
rathread_yield();
}
-
+
FinalizeSpinLock(&lock);
-
+
// Everything fine?
if(val != (THRC*PERINC) ){
printf("FAILED! (Result: %u, Expected: %u)\n", val, (THRC*PERINC) );
@@ -83,7 +80,6 @@ int do_init(int argc, char **argv){
}
}
-
if(ok != LOOPS){
ShowFatalError("Test failed.\n");
diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in
index 127d3841b..2d7699db0 100644
--- a/src/tool/Makefile.in
+++ b/src/tool/Makefile.in
@@ -36,7 +36,7 @@ mapcache: ../../mapcache@EXEEXT@
../../mapcache@EXEEXT@: $(MAPCACHE_DEPENDS) Makefile
@echo " LD $(notdir $@)"
- @$(CC) @LDFLAGS@ -o ../../mapcache@EXEEXT@ $(MAPCACHE_DEPENDS) @LIBS@
+ @$(CC) @STATIC@ @LDFLAGS@ -o ../../mapcache@EXEEXT@ $(MAPCACHE_DEPENDS) @LIBS@
buildclean:
@echo " CLEAN tool (build temp files)"