summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/HPMchar.c63
-rw-r--r--src/char/HPMchar.h4
-rw-r--r--src/char/Makefile.in12
-rw-r--r--src/char/char.c613
-rw-r--r--src/char/char.h11
-rw-r--r--src/char/geoip.c30
-rw-r--r--src/char/geoip.h3
-rw-r--r--src/char/int_auction.c40
-rw-r--r--src/char/int_auction.h3
-rw-r--r--src/char/int_elemental.c27
-rw-r--r--src/char/int_elemental.h2
-rw-r--r--src/char/int_guild.c100
-rw-r--r--src/char/int_guild.h3
-rw-r--r--src/char/int_homun.c29
-rw-r--r--src/char/int_homun.h2
-rw-r--r--src/char/int_mail.c34
-rw-r--r--src/char/int_mail.h2
-rw-r--r--src/char/int_mercenary.c30
-rw-r--r--src/char/int_mercenary.h2
-rw-r--r--src/char/int_party.c53
-rw-r--r--src/char/int_party.h3
-rw-r--r--src/char/int_pet.c29
-rw-r--r--src/char/int_quest.c32
-rw-r--r--src/char/int_storage.c31
-rw-r--r--src/char/inter.c75
-rw-r--r--src/char/inter.h8
-rw-r--r--src/char/loginif.c27
-rw-r--r--src/char/loginif.h4
-rw-r--r--src/char/mapif.c22
-rw-r--r--src/char/mapif.h11
-rw-r--r--src/char/pincode.c35
-rw-r--r--src/char/pincode.h4
-rw-r--r--src/common/HPM.c109
-rw-r--r--src/common/HPM.h4
-rw-r--r--src/common/HPMDataCheck.h429
-rw-r--r--src/common/HPMi.h15
-rw-r--r--src/common/Makefile.in17
-rw-r--r--src/common/atomic.h4
-rw-r--r--src/common/cbasetypes.h7
-rw-r--r--src/common/conf.c4
-rw-r--r--src/common/conf.h4
-rw-r--r--src/common/console.c37
-rw-r--r--src/common/console.h12
-rw-r--r--src/common/core.c50
-rw-r--r--src/common/core.h4
-rw-r--r--src/common/db.c12
-rw-r--r--src/common/db.h26
-rw-r--r--src/common/des.c2
-rw-r--r--src/common/des.h2
-rw-r--r--src/common/ers.c10
-rw-r--r--src/common/ers.h12
-rw-r--r--src/common/grfio.c20
-rw-r--r--src/common/malloc.c16
-rw-r--r--src/common/malloc.h2
-rw-r--r--src/common/mapindex.c15
-rw-r--r--src/common/mapindex.h5
-rw-r--r--src/common/md5calc.c9
-rw-r--r--src/common/mmo.h102
-rw-r--r--src/common/mutex.c12
-rw-r--r--src/common/mutex.h2
-rw-r--r--src/common/nullpo.c21
-rw-r--r--src/common/nullpo.h2
-rw-r--r--src/common/random.c12
-rw-r--r--src/common/random.h2
-rw-r--r--src/common/showmsg.c16
-rw-r--r--src/common/showmsg.h95
-rw-r--r--src/common/socket.c22
-rw-r--r--src/common/socket.h6
-rw-r--r--src/common/spinlock.h8
-rw-r--r--src/common/sql.c16
-rw-r--r--src/common/sql.h4
-rw-r--r--src/common/strlib.c8
-rw-r--r--src/common/strlib.h4
-rw-r--r--src/common/sysinfo.c14
-rw-r--r--src/common/sysinfo.h4
-rw-r--r--src/common/thread.c11
-rw-r--r--src/common/thread.h2
-rw-r--r--src/common/timer.c21
-rw-r--r--src/common/timer.h2
-rw-r--r--src/common/utils.c28
-rw-r--r--src/common/utils.h5
-rw-r--r--src/config/classes/general.h2
-rw-r--r--src/config/const.h4
-rw-r--r--src/config/renewal.h5
-rw-r--r--src/config/secure.h4
-rw-r--r--src/login/HPMlogin.c48
-rw-r--r--src/login/HPMlogin.h4
-rw-r--r--src/login/Makefile.in12
-rw-r--r--src/login/account.h6
-rw-r--r--src/login/account_sql.c78
-rw-r--r--src/login/ipban.h2
-rw-r--r--src/login/ipban_sql.c31
-rw-r--r--src/login/login.c132
-rw-r--r--src/login/login.h25
-rw-r--r--src/login/loginlog.h2
-rw-r--r--src/login/loginlog_sql.c19
-rw-r--r--src/map/HPMmap.c124
-rw-r--r--src/map/HPMmap.h6
-rw-r--r--src/map/Makefile.in12
-rw-r--r--src/map/atcommand.c286
-rw-r--r--src/map/atcommand.h9
-rw-r--r--src/map/battle.c631
-rw-r--r--src/map/battle.h26
-rw-r--r--src/map/battleground.c81
-rw-r--r--src/map/battleground.h15
-rw-r--r--src/map/buyingstore.c28
-rw-r--r--src/map/buyingstore.h4
-rw-r--r--src/map/channel.c61
-rw-r--r--src/map/channel.h11
-rw-r--r--src/map/chat.c38
-rw-r--r--src/map/chat.h6
-rw-r--r--src/map/chrif.c136
-rw-r--r--src/map/chrif.h12
-rw-r--r--src/map/clif.c811
-rw-r--r--src/map/clif.h130
-rw-r--r--src/map/date.c4
-rw-r--r--src/map/date.h2
-rw-r--r--src/map/duel.c10
-rw-r--r--src/map/duel.h2
-rw-r--r--src/map/elemental.c70
-rw-r--r--src/map/elemental.h9
-rw-r--r--src/map/guild.c80
-rw-r--r--src/map/guild.h8
-rw-r--r--src/map/homunculus.c148
-rw-r--r--src/map/homunculus.h17
-rw-r--r--src/map/instance.c37
-rw-r--r--src/map/instance.h7
-rw-r--r--src/map/intif.c56
-rw-r--r--src/map/intif.h2
-rw-r--r--src/map/irc-bot.c24
-rw-r--r--src/map/irc-bot.h4
-rw-r--r--src/map/itemdb.c102
-rw-r--r--src/map/itemdb.h131
-rw-r--r--src/map/log.c24
-rw-r--r--src/map/log.h4
-rw-r--r--src/map/mail.c21
-rw-r--r--src/map/mail.h2
-rw-r--r--src/map/map.c112
-rw-r--r--src/map/map.h46
-rw-r--r--src/map/mapreg.h8
-rw-r--r--src/map/mapreg_sql.c22
-rw-r--r--src/map/mercenary.c66
-rw-r--r--src/map/mercenary.h10
-rw-r--r--src/map/mob.c108
-rw-r--r--src/map/mob.h43
-rw-r--r--src/map/npc.c142
-rw-r--r--src/map/npc.h14
-rw-r--r--src/map/npc_chat.c22
-rw-r--r--src/map/packets.h74
-rw-r--r--src/map/packets_struct.h18
-rw-r--r--src/map/party.c50
-rw-r--r--src/map/party.h10
-rw-r--r--src/map/path.c20
-rw-r--r--src/map/path.h4
-rw-r--r--src/map/pc.c1399
-rw-r--r--src/map/pc.h120
-rw-r--r--src/map/pc_groups.c22
-rw-r--r--src/map/pc_groups.h6
-rw-r--r--src/map/pet.c80
-rw-r--r--src/map/pet.h10
-rw-r--r--src/map/quest.c50
-rw-r--r--src/map/quest.h8
-rw-r--r--src/map/script.c443
-rw-r--r--src/map/script.h15
-rw-r--r--src/map/searchstore.c18
-rw-r--r--src/map/searchstore.h8
-rw-r--r--src/map/skill.c1220
-rw-r--r--src/map/skill.h39
-rw-r--r--src/map/status.c1519
-rw-r--r--src/map/status.h96
-rw-r--r--src/map/storage.c68
-rw-r--r--src/map/storage.h13
-rw-r--r--src/map/trade.c42
-rw-r--r--src/map/unit.c159
-rw-r--r--src/map/unit.h21
-rw-r--r--src/map/vending.c32
-rw-r--r--src/map/vending.h4
-rw-r--r--src/plugins/HPMHooking.c170
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.GetSymbol.inc32
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc8
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc2
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.Hooks.inc66
-rw-r--r--src/plugins/HPMHooking/HPMHooking_login.GetSymbol.inc2
-rw-r--r--src/plugins/HPMHooking/HPMHooking_login.Hooks.inc12
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.GetSymbol.inc78
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc100
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc25
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.Hooks.inc635
-rw-r--r--src/plugins/Makefile.in7
-rw-r--r--src/plugins/db2sql.c36
-rw-r--r--src/plugins/dbghelpplug.c13
-rw-r--r--src/plugins/sample.c24
-rw-r--r--src/test/Makefile.in12
-rw-r--r--src/test/test_spinlock.c14
-rw-r--r--src/tool/Makefile.in9
-rw-r--r--src/tool/mapcache.c83
196 files changed, 8105 insertions, 5539 deletions
diff --git a/src/char/HPMchar.c b/src/char/HPMchar.c
index 4b153b244..2d4c570d7 100644
--- a/src/char/HPMchar.c
+++ b/src/char/HPMchar.c
@@ -5,26 +5,49 @@
#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"
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+
+#if 0 // TODO (HPMDataCheck is disabled for the time being)
+#include "char/char.h"
+#include "char/geoip.h"
+#include "char/inter.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/loginif.h"
+#include "char/mapif.h"
+#include "char/pincode.h"
+#include "common/HPMi.h"
+#include "common/conf.h"
+#include "common/console.h"
+#include "common/core.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/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/spinlock.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+#include "common/sysinfo.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
+// HPMDataCheck comes after all the other includes
+#include "common/HPMDataCheck.h"
+#endif
bool HPM_char_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr) {
/* record address */
diff --git a/src/char/HPMchar.h b/src/char/HPMchar.h
index aa266f1de..594bb7f00 100644
--- a/src/char/HPMchar.h
+++ b/src/char/HPMchar.h
@@ -8,8 +8,8 @@
#error You should never include HPMchar.h from a plugin.
#endif
-#include "../common/cbasetypes.h"
-#include "../common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/HPM.h"
struct hplugin;
diff --git a/src/char/Makefile.in b/src/char/Makefile.in
index 20d19966e..035dbf711 100644
--- a/src/char/Makefile.in
+++ b/src/char/Makefile.in
@@ -9,18 +9,20 @@ CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h)
COMMON_D = ../common
COMMON_H = $(wildcard $(COMMON_D)/*.h)
SYSINFO_INC = $(COMMON_D)/sysinfo.inc
+COMMON_INCLUDE = -I..
-LIBCONFIG_D = ../../3rdparty/libconfig
+THIRDPARTY_D = ../../3rdparty
+THIRDPARTY_INCLUDE = -I$(THIRDPARTY_D)
+
+LIBCONFIG_D = $(THIRDPARTY_D)/libconfig
LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
scanner.o strbuf.o)
LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
scanctx.h scanner.h strbuf.h wincompat.h)
-LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
-MT19937AR_D = ../../3rdparty/mt19937ar
+MT19937AR_D = $(THIRDPARTY_D)/mt19937ar
MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
-MT19937AR_INCLUDE = -I$(MT19937AR_D)
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 \
@@ -98,7 +100,7 @@ char-server: ../../char-server@EXEEXT@
obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql
@echo " CC $<"
- @$(CC) @CFLAGS@ @DEFS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+ @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing object files
$(COMMON_D)/obj_all/common.a:
diff --git a/src/char/char.c b/src/char/char.c
index e43ebbfbc..7b1078e37 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -4,49 +4,49 @@
#define HERCULES_CORE
-#include "../config/core.h" // CONSOLE_INPUT
+#include "config/core.h" // CONSOLE_INPUT
#include "char.h"
+#include "char/HPMchar.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"
+
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/console.h"
+#include "common/core.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/mapindex.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/sql.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#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"
-#include "../common/console.h"
-#include "../common/core.h"
-#include "../common/db.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/timer.h"
-#include "../common/utils.h"
-
#ifndef WIN32
- #include <unistd.h>
+# include <unistd.h>
#endif
// private declarations
@@ -147,11 +147,6 @@ struct fame_list smith_fame_list[MAX_FAME_LIST];
struct fame_list chemist_fame_list[MAX_FAME_LIST];
struct fame_list taekwon_fame_list[MAX_FAME_LIST];
-// check for exit signal
-// 0 is saving complete
-// other is char_id
-unsigned int save_flag = 0;
-
// Initial position (it's possible to set it in conf file)
struct point start_point = { 0, 53, 111 };
@@ -239,7 +234,7 @@ void char_set_char_online(int map_id, int char_id, int account_id)
{
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(chr->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); // 2: Already connected to server
}
//Update state data
@@ -317,6 +312,7 @@ static int char_db_setoffline(DBKey key, DBData *data, va_list ap)
{
struct online_char_data* character = (struct online_char_data*)DB->data2ptr(data);
int server_id = va_arg(ap, int);
+ nullpo_ret(character);
if (server_id == -1) {
character->char_id = -1;
character->server = -1;
@@ -336,13 +332,14 @@ static int char_db_kickoffline(DBKey key, DBData *data, va_list ap)
{
struct online_char_data* character = (struct online_char_data*)DB->data2ptr(data);
int server_id = va_arg(ap, int);
+ nullpo_ret(character);
if (server_id > -1 && character->server != server_id)
return 0;
//Kick out any connected characters, and set them offline as appropriate.
- if (character->server > -1)
- mapif->disconnectplayer(chr->server[character->server].fd, character->account_id, character->char_id, 1);
+ if (character->server > -1 && character->server < MAX_MAP_SERVERS)
+ mapif->disconnectplayer(chr->server[character->server].fd, character->account_id, character->char_id, 1); // 1: Server closed
else if (character->waiting_disconnect == INVALID_TIMER)
chr->set_char_offline(character->char_id, character->account_id);
else
@@ -404,7 +401,8 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
int errors = 0; //If there are any errors while saving, "cp" will not be updated at the end.
StringBuf buf;
- if (char_id!=p->char_id) return 0;
+ nullpo_ret(p);
+ if (char_id != p->char_id) return 0;
cp = idb_ensure(chr->char_db_, char_id, chr->create_charstatus);
@@ -453,31 +451,16 @@ int char_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 ) || (p->sex != cp->sex)
+ (p->uniqueitem_counter != cp->uniqueitem_counter)
) {
//Save status
unsigned int opt = 0;
- char sex;
if( p->allow_party )
opt |= OPT_ALLOW_PARTY;
if( p->show_equip )
opt |= OPT_SHOW_EQUIP;
- 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',"
@@ -485,8 +468,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
"`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',"
- " sex = '%c'"
+ "`delete_date`='%lu',`robe`='%d',`slotchange`='%d', `char_opt`='%u', `font`='%u', `uniqueitem_counter` ='%u'"
" WHERE `account_id`='%d' AND `char_id` = '%d'",
char_db, p->base_level, p->job_level,
p->base_exp, p->job_exp, p->zeny,
@@ -497,7 +479,7 @@ int char_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, sex,
+ p->robe,p->slotchange,opt,p->font,p->uniqueitem_counter,
p->account_id, p->char_id) )
{
Sql_ShowDebug(inter->sql_handle);
@@ -868,6 +850,7 @@ int char_inventory_to_sql(const struct item items[], int max, int id) {
bool found;
int errors = 0;
+ nullpo_ret(items);
// The following code compares inventory with current database values
// and performs modification/deletion/insertion only on relevant rows.
@@ -997,6 +980,55 @@ int char_inventory_to_sql(const struct item items[], int max, int id) {
return errors;
}
+/**
+ * Returns the correct gender ID for the given character and enum value.
+ *
+ * If the per-character sex is defined but not supported by the current packetver, the database entries are corrected.
+ *
+ * @param sd Character data, if available.
+ * @param p Character status.
+ * @param sex Character sex (database enum)
+ *
+ * @retval SEX_MALE if the per-character sex is male
+ * @retval SEX_FEMALE if the per-character sex is female
+ * @retval 99 if the per-character sex is not defined or the current PACKETVER doesn't support it.
+ */
+int char_mmo_gender(const struct char_session_data *sd, const struct mmo_charstatus *p, char sex)
+{
+#if PACKETVER >= 20141016
+ (void)sd; (void)p; // Unused
+ switch (sex) {
+ case 'M':
+ return SEX_MALE;
+ case 'F':
+ return SEX_FEMALE;
+ case 'U':
+ default:
+ return 99;
+ }
+#else
+ if (sex == 'M' || sex == 'F') {
+ if (!sd) {
+ // sd is not available, there isn't much we can do. Just return and print a warning.
+ ShowWarning("Character '%s' (CID: %d, AID: %d) has sex '%c', but PACKETVER does not support per-character sex. Defaulting to 'U'.\n",
+ p->name, p->char_id, p->account_id, sex);
+ return 99;
+ }
+ if ((sex == 'M' && sd->sex == SEX_FEMALE)
+ || (sex == 'F' && sd->sex == SEX_MALE)) {
+ ShowWarning("Changing sex of character '%s' (CID: %d, AID: %d) to 'U' due to incompatible PACKETVER.\n", p->name, p->char_id, p->account_id);
+ chr->changecharsex(p->char_id, sd->sex);
+ } else {
+ ShowInfo("Resetting sex of character '%s' (CID: %d, AID: %d) to 'U' due to incompatible PACKETVER.\n", p->name, p->char_id, p->account_id);
+ }
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `sex` = 'U' WHERE `char_id` = '%d'", char_db, p->char_id)) {
+ Sql_ShowDebug(inter->sql_handle);
+ }
+ }
+ return 99;
+#endif
+}
+
//=====================================================================================================
// Loads the basic character rooster for the given account. Returns total buffer used.
int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
@@ -1008,6 +1040,9 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
time_t unban_time = 0;
char sex[2];
+ nullpo_ret(sd);
+ nullpo_ret(buf);
+
stmt = SQL->StmtMalloc(inter->sql_handle);
if( stmt == NULL ) {
SqlStmt_ShowDebug(stmt);
@@ -1075,21 +1110,12 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
}
for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SQL->StmtNextRow(stmt); i++ ) {
+ if (p.slot >= MAX_CHARS)
+ continue;
p.last_point.map = mapindex->name2id(last_map);
sd->found_char[p.slot] = p.char_id;
sd->unban_time[p.slot] = unban_time;
- switch( sex[0] ) {
- case 'M':
- p.sex = 1;
- break;
- case 'F':
- p.sex = 0;
- break;
- case 'U':
- default:
- p.sex = 99;
- break;
- }
+ p.sex = chr->mmo_gender(sd, &p, sex[0]);
j += chr->mmo_char_tobuf(WBUFP(buf, j), &p);
}
@@ -1116,12 +1142,14 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every
struct s_friend tmp_friend;
#ifdef HOTKEY_SAVING
struct hotkey tmp_hotkey;
- int hotkey_num;
+ int hotkey_num = 0;
#endif
unsigned int opt;
int account_id;
char sex[2];
+ nullpo_ret(p);
+
memset(p, 0, sizeof(struct mmo_charstatus));
if (save_log) ShowInfo("Char load request (%d)\n", char_id);
@@ -1200,31 +1228,20 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every
|| 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)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 56, SQLDT_ENUM, &sex, sizeof(sex), NULL, NULL)
) {
SqlStmt_ShowDebug(stmt);
SQL->StmtFree(stmt);
return 0;
}
- if( SQL_ERROR == SQL->StmtNextRow(stmt) )
+ if (SQL_SUCCESS != SQL->StmtNextRow(stmt))
{
ShowError("Requested non-existant character id: %d!\n", char_id);
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;
- }
+ p->sex = chr->mmo_gender(NULL, p, sex[0]);
account_id = p->account_id;
@@ -1325,8 +1342,9 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every
|| 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);
@@ -1348,8 +1366,9 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every
|| 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;
@@ -1370,8 +1389,10 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every
|| 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) )
+ || 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 )
memcpy(&p->friends[i], &tmp_friend, sizeof(tmp_friend));
@@ -1414,8 +1435,10 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every
|| 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) )
+ || 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");
@@ -1457,6 +1480,7 @@ bool char_char_slotchange(struct char_session_data *sd, int fd, unsigned short f
struct mmo_charstatus char_dat;
int from_id = 0;
+ nullpo_ret(sd);
if( from >= MAX_CHARS || to >= MAX_CHARS || ( sd->char_slots && to > sd->char_slots ) || sd->found_char[from] <= 0 )
return false;
@@ -1473,7 +1497,8 @@ bool char_char_slotchange(struct char_session_data *sd, int fd, unsigned short f
/* update both at once */
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_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;
@@ -1508,12 +1533,17 @@ 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];
+ nullpo_retr(2, sd);
+
if( sd->new_name[0] == 0 ) // Not ready for rename
return 2;
if( !chr->mmo_char_fromsql(char_id, &char_dat, false) ) // Only the short data is needed.
return 2;
+ if (sd->account_id != char_dat.account_id) // Try rename not own char
+ return 2;
+
if( char_dat.rename == 0 )
return 1;
@@ -1556,8 +1586,11 @@ int char_check_char_name(char * name, char * esc_name)
{
int i;
+ nullpo_retr(-2, name);
+ nullpo_retr(-2, esc_name);
+
// check length of character name
- if( name[0] == '\0' )
+ if (name[0] == '\0')
return -2; // empty character name
/**
* The client does not allow you to create names with less than 4 characters, however,
@@ -1618,6 +1651,8 @@ int char_make_new_char_sql(struct char_session_data* sd, char* name_, int str, i
char esc_name[NAME_LENGTH*2+1];
int char_id, flag, k, l;
+ nullpo_retr(-2, sd);
+ nullpo_retr(-2, name_);
safestrncpy(name, name_, NAME_LENGTH);
normalize_name(name,TRIM_CHARS);
SQL->EscapeStringLen(inter->sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
@@ -1961,7 +1996,8 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) {
#endif
//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;
+ // FIXME[Haru]: is OPTION_HANBOK intended to be part of this list? And if it is, should the list also include other OPTION_ costumes?
+ WBUFL(buf,56) = p->option&(OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR|OPTION_HANBOK) ? 0 : p->weapon;
WBUFW(buf,58) = p->base_level;
WBUFW(buf,60) = min(p->skill_point, INT16_MAX);
@@ -2027,6 +2063,7 @@ void char_mmo_char_send_ban_list(int fd, struct char_session_data *sd) {
int i;
time_t now = time(NULL);
+ nullpo_retv(sd);
ARR_FIND(0, MAX_CHARS, i, sd->unban_time[i]);
if( i != MAX_CHARS ) {
int c;
@@ -2063,6 +2100,7 @@ void char_mmo_char_send_ban_list(int fd, struct char_session_data *sd) {
// [Ind/Hercules] notify client about charselect window data
//----------------------------------------
void char_mmo_char_send_slots_info(int fd, struct char_session_data* sd) {
+ nullpo_retv(sd);
WFIFOHEAD(fd,29);
WFIFOW(fd,0) = 0x82d;
WFIFOW(fd,2) = 29;
@@ -2080,6 +2118,7 @@ void char_mmo_char_send_slots_info(int fd, struct char_session_data* sd) {
int char_mmo_char_send_characters(int fd, struct char_session_data* sd)
{
int j, offset = 0;
+ nullpo_ret(sd);
#if PACKETVER >= 20100413
offset += 3;
#endif
@@ -2201,11 +2240,13 @@ static void char_auth_ok(int fd, struct char_session_data *sd)
{
struct online_char_data* character;
+ nullpo_retv(sd);
+
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);
+ mapif->disconnectplayer(chr->server[character->server].fd, character->account_id, character->char_id, 2); // 2: Already connected to server
if (character->waiting_disconnect == INVALID_TIMER)
character->waiting_disconnect = timer->add(timer->gettick()+20000, chr->waiting_disconnect, character->account_id, 0);
character->pincode_enable = -1;
@@ -2356,7 +2397,8 @@ void char_parse_fromlogin_account_data(int fd)
void char_parse_fromlogin_login_pong(int fd)
{
RFIFOSKIP(fd,2);
- session[fd]->flag.ping = 0;
+ if (session[fd])
+ session[fd]->flag.ping = 0;
}
void char_changesex(int account_id, int sex)
@@ -2369,15 +2411,52 @@ void char_changesex(int account_id, int sex)
mapif->sendall(buf, 7);
}
+/**
+ * Performs the necessary operations when changing a character's sex, such as
+ * correcting the job class and unequipping items, and propagating the
+ * information to the guild data.
+ *
+ * @param sex The new sex (SEX_MALE or SEX_FEMALE).
+ * @param acc The character's account ID.
+ * @param char_id The character ID.
+ * @param class_ The character's current job class.
+ * @param guild_id The character's guild ID.
+ */
+void char_change_sex_sub(int sex, int acc, int char_id, int class_, int guild_id)
+{
+ // job modification
+ if (class_ == JOB_BARD || class_ == JOB_DANCER)
+ class_ = (sex == SEX_MALE ? JOB_BARD : JOB_DANCER);
+ else if (class_ == JOB_CLOWN || class_ == JOB_GYPSY)
+ class_ = (sex == SEX_MALE ? JOB_CLOWN : JOB_GYPSY);
+ else if (class_ == JOB_BABY_BARD || class_ == JOB_BABY_DANCER)
+ class_ = (sex == SEX_MALE ? JOB_BABY_BARD : JOB_BABY_DANCER);
+ else if (class_ == JOB_MINSTREL || class_ == JOB_WANDERER)
+ class_ = (sex == SEX_MALE ? JOB_MINSTREL : JOB_WANDERER);
+ else if (class_ == JOB_MINSTREL_T || class_ == JOB_WANDERER_T)
+ class_ = (sex == SEX_MALE ? JOB_MINSTREL_T : JOB_WANDERER_T);
+ else if (class_ == JOB_BABY_MINSTREL || class_ == JOB_BABY_WANDERER)
+ class_ = (sex == SEX_MALE ? JOB_BABY_MINSTREL : JOB_BABY_WANDERER);
+ else if (class_ == JOB_KAGEROU || class_ == JOB_OBORO)
+ class_ = (sex == SEX_MALE ? 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))
+ 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_, char_id))
+ Sql_ShowDebug(inter->sql_handle);
+ if (guild_id) // If there is a guild, update the guild_member data [Skotlex]
+ inter_guild->sex_changed(guild_id, acc, char_id, sex);
+}
+
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 char_id = 0, class_ = 0, guild_id = 0;
int i;
- char* data;
- struct char_auth_node* node;
+ struct char_auth_node *node;
+ SqlStmt *stmt;
int acc = RFIFOL(fd,2);
int sex = RFIFOB(fd,6);
@@ -2385,65 +2464,31 @@ int char_parse_fromlogin_changesex_reply(int fd)
RFIFOSKIP(fd,7);
// This should _never_ happen
- if( acc <= 0 ) {
+ if (acc <= 0) {
ShowError("Received invalid account id from login server! (aid: %d)\n", acc);
return 1;
}
node = (struct char_auth_node*)idb_get(auth_db, acc);
- if( node != NULL )
+ if (node != NULL)
node->sex = sex;
// 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);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
+ if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `char_id`,`class`,`guild_id` FROM `%s` WHERE `account_id` = '%d'", char_db, acc)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ ) {
+ SqlStmt_ShowDebug(stmt);
+ SQL->StmtFree(stmt);
}
- 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->StmtBindColumn(stmt, 0, SQLDT_INT, &char_id, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &class_, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 2, SQLDT_INT, &guild_id, 0, NULL, NULL);
+
+ for (i = 0; i < MAX_CHARS && SQL_SUCCESS == SQL->StmtNextRow(stmt); ++i) {
+ char_change_sex_sub(sex, acc, char_id, class_, guild_id);
}
- SQL->FreeResult(inter->sql_handle);
+ SQL->StmtFree(stmt);
// disconnect player if online on char-server
chr->disconnect_player(acc);
@@ -2488,7 +2533,7 @@ void char_parse_fromlogin_kick(int fd)
{// 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);
+ mapif->disconnectplayer(chr->server[character->server].fd, character->account_id, character->char_id, 2); // 2: Already connected to server
if (character->waiting_disconnect == INVALID_TIMER)
character->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, chr->waiting_disconnect, character->account_id, 0);
}
@@ -2870,7 +2915,7 @@ void char_update_fame_list(int type, int index, int fame) {
mapif->sendall(buf, 8);
}
-//Loads a character's name and stores it in the buffer given (must be NAME_LENGTH in size)
+//Loads a character's name and stores it in the buffer given (must be NAME_LENGTH in size) and not NULL
//Returns 1 on found, 0 on not found (buffer is filled with Unknown char name)
int char_loadName(int char_id, char* name)
{
@@ -2943,6 +2988,7 @@ 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) {
+ Assert_retv(chr->login_fd > 0);
WFIFOHEAD(chr->login_fd,22);
WFIFOW(chr->login_fd,0) = 0x2740;
WFIFOL(chr->login_fd,2) = account_id;
@@ -2964,7 +3010,7 @@ void char_parse_frommap_skillid2idx(int fd)
int i;
int j = RFIFOW(fd, 2) - 4;
- memset(&skillid2idx, 0, sizeof(skillid2idx));
+ memset(&skillid2idx, 0, sizeof(skillid2idx));
if( j )
j /= 4;
for(i = 0; i < j; i++) {
@@ -3134,7 +3180,7 @@ void char_parse_frommap_set_users(int fd, int id)
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);
+ mapif->disconnectplayer(chr->server[character->server].fd, character->account_id, character->char_id, 2); // 2: Already connected to server
}
character->server = id;
character->char_id = cid;
@@ -3348,6 +3394,8 @@ void char_ban(int account_id, int char_id, time_t *unban_time, short year, short
struct tm *tmtime;
SqlStmt* stmt = SQL->StmtMalloc(inter->sql_handle);
+ nullpo_retv(unban_time);
+
if (*unban_time == 0 || *unban_time < time(NULL))
timestamp = time(NULL); // new ban
else
@@ -3363,13 +3411,12 @@ void char_ban(int account_id, int char_id, time_t *unban_time, short year, short
timestamp = mktime(tmtime);
if( SQL_SUCCESS != SQL->StmtPrepare(stmt,
- "UPDATE `%s` SET `unban_time` = ? WHERE `char_id` = ? LIMIT 1",
- char_db)
+ "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);
}
@@ -3388,12 +3435,14 @@ 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;
+ if (result)
+ *result = 1;
}
}
void char_ask_name_ack(int fd, int acc, const char* name, int type, int result)
{
+ nullpo_retv(name);
WFIFOHEAD(fd,34);
WFIFOW(fd, 0) = 0x2b0f;
WFIFOL(fd, 2) = acc;
@@ -3403,6 +3452,49 @@ void char_ask_name_ack(int fd, int acc, const char* name, int type, int result)
WFIFOSET(fd,34);
}
+/**
+ * Changes a character's sex.
+ * The information is updated on database, and the character is kicked if it
+ * currently is online.
+ *
+ * @param char_id The character's ID.
+ * @param sex The new sex.
+ * @retval 0 in case of success.
+ * @retval 1 in case of failure.
+ */
+int char_changecharsex(int char_id, int sex)
+{
+ int class_ = 0, guild_id = 0, account_id = 0;
+ char *data;
+
+ // get character data
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`class`,`guild_id` FROM `%s` WHERE `char_id` = '%d'", char_db, char_id)) {
+ Sql_ShowDebug(inter->sql_handle);
+ return 1;
+ }
+ if (SQL->NumRows(inter->sql_handle) != 1 || SQL_ERROR == SQL->NextRow(inter->sql_handle)) {
+ SQL->FreeResult(inter->sql_handle);
+ return 1;
+ }
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); guild_id = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
+
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `sex` = '%c' WHERE `char_id` = '%d'", char_db, sex == SEX_MALE ? 'M' : 'F', char_id)) {
+ Sql_ShowDebug(inter->sql_handle);
+ return 1;
+ }
+ char_change_sex_sub(sex, account_id, char_id, class_, guild_id);
+
+ // disconnect player if online on char-server
+ chr->disconnect_player(account_id);
+
+ // notify all mapservers about this change
+ chr->changesex(account_id, sex);
+ return 0;
+}
+
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
@@ -3411,31 +3503,40 @@ void char_parse_frommap_change_account(int fd)
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);
+ short year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
+ int sex = SEX_MALE;
+ if (type == 2 || type == 6) {
+ year = RFIFOW(fd,32);
+ month = RFIFOW(fd,34);
+ day = RFIFOW(fd,36);
+ hour = RFIFOW(fd,38);
+ minute = RFIFOW(fd,40);
+ second = RFIFOW(fd,42);
+ } else if (type == 8) {
+ sex = RFIFOB(fd, 32);
+ }
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) )
+ 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 ) {
+ } else if (SQL->NumRows(inter->sql_handle) == 0) {
+ SQL->FreeResult(inter->sql_handle);
result = 1; // 1-player not found
- } else if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) ) {
+ } else if (SQL_SUCCESS != SQL->NextRow(inter->sql_handle)) {
Sql_ShowDebug(inter->sql_handle);
+ SQL->FreeResult(inter->sql_handle);
result = 1; // 1-player not found
} else {
int account_id, char_id;
- char* data;
+ 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);
+ SQL->FreeResult(inter->sql_handle);
if( chr->login_fd <= 0 ) {
result = 3; // 3-login-server offline
@@ -3444,40 +3545,38 @@ void char_parse_frommap_change_account(int fd)
result = 2; // 2-gm level too low
#endif // 0
} else {
- switch( type ) {
- case 1: // block
- loginif->block_account(account_id, 5);
+ switch (type) {
+ case CHAR_ASK_NAME_BLOCK:
+ loginif->block_account(account_id, 5);
break;
- case 2: // ban
- loginif->ban_account(account_id, year, month, day, hour, minute, second);
+ case CHAR_ASK_NAME_BAN:
+ loginif->ban_account(account_id, year, month, day, hour, minute, second);
break;
- case 3: // unblock
- loginif->block_account(account_id, 0);
+ case CHAR_ASK_NAME_UNBLOCK:
+ loginif->block_account(account_id, 0);
break;
- case 4: // unban
- loginif->unban_account(account_id);
+ case CHAR_ASK_NAME_UNBAN:
+ loginif->unban_account(account_id);
break;
- case 5: // changesex
- loginif->changesex(account_id);
+ case CHAR_ASK_NAME_CHANGESEX:
+ loginif->changesex(account_id);
break;
- case 6: //char ban
+ case CHAR_ASK_NAME_CHARBAN:
/* handled by char server, so no redirection */
- {
- chr->ban(account_id, char_id, &unban_time, year, month, day, hour, minute, second);
- }
+ chr->ban(account_id, char_id, &unban_time, year, month, day, hour, minute, second);
break;
- case 7: //char unban
+ case CHAR_ASK_NAME_CHARUNBAN:
chr->unban(char_id, &result);
break;
-
+ case CHAR_ASK_NAME_CHANGECHARSEX:
+ result = chr->changecharsex(char_id, sex);
+ 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
+ if (acc != -1 && type != CHAR_ASK_NAME_CHANGESEX && type != CHAR_ASK_NAME_CHANGECHARSEX) { // Don't send answer for changesex
chr->ask_name_ack(fd, acc, name, type, result);
}
}
@@ -3499,6 +3598,10 @@ void char_parse_frommap_fame_list(int fd)
default: size = 0; list = NULL; break;
}
+ if (!list) {
+ RFIFOSKIP(fd, 11);
+ return;
+ }
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
@@ -3624,6 +3727,7 @@ void char_parse_frommap_ping(int fd)
void char_map_auth_ok(int fd, int account_id, struct char_auth_node* node, struct mmo_charstatus* cd)
{
+ nullpo_retv(cd);
WFIFOHEAD(fd,25 + sizeof(struct mmo_charstatus));
WFIFOW(fd,0) = 0x2afd;
WFIFOW(fd,2) = 25 + sizeof(struct mmo_charstatus);
@@ -3729,7 +3833,7 @@ void char_parse_frommap_request_stats_report(int fd)
opt.silent = 1;
opt.setTimeo = 1;
- if( (sfd = make_connection(host2ip("stats.hercules.ws"),(uint16)25427,&opt) ) == -1 ) {
+ if( (sfd = make_connection(host2ip("stats.herc.ws"),(uint16)25427,&opt) ) == -1 ) {
RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
RFIFOFLUSH(fd);
return;/* connection not possible, we drop the report */
@@ -4156,25 +4260,26 @@ static void char_delete2_req(int fd, struct char_session_data* sd)
time_t delete_date;
char_id = RFIFOL(fd,2);
+ nullpo_retv(sd);
ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id );
if( i == MAX_CHARS )
{// character not found
- chr->delete2_ack(fd, char_id, 3, 0);
+ chr->delete2_ack(fd, char_id, 3, 0); // 3: A database error occurred
return;
}
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(inter->sql_handle);
- chr->delete2_ack(fd, char_id, 3, 0);
+ chr->delete2_ack(fd, char_id, 3, 0); // 3: A database error occurred
return;
}
SQL->GetData(inter->sql_handle, 0, &data, NULL); delete_date = strtoul(data, NULL, 10);
if( delete_date ) {// character already queued for deletion
- chr->delete2_ack(fd, char_id, 0, 0);
+ chr->delete2_ack(fd, char_id, 0, 0); // 0: An unknown error occurred
return;
}
@@ -4187,7 +4292,7 @@ static void char_delete2_req(int fd, struct char_session_data* sd)
|| SQL_SUCCESS != SQL->NextRow(inter->sql_handle)
) {
Sql_ShowDebug(inter->sql_handle);
- chr->delete2_ack(fd, char_id, 3, 0);
+ chr->delete2_ack(fd, char_id, 3, 0); // 3: A database error occurred
return;
}
SQL->GetData(inter->sql_handle, 0, &data, NULL); party_id = atoi(data);
@@ -4195,13 +4300,13 @@ static void char_delete2_req(int fd, struct char_session_data* sd)
if( guild_id )
{
- chr->delete2_ack(fd, char_id, 4, 0);
+ chr->delete2_ack(fd, char_id, 4, 0); // 4: To delete a character you must withdraw from the guild
return;
}
if( party_id )
{
- chr->delete2_ack(fd, char_id, 5, 0);
+ chr->delete2_ack(fd, char_id, 5, 0); // 5: To delete a character you must withdraw from the party
return;
}
}
@@ -4212,11 +4317,11 @@ static void char_delete2_req(int fd, struct char_session_data* sd)
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(inter->sql_handle);
- chr->delete2_ack(fd, char_id, 3, 0);
+ chr->delete2_ack(fd, char_id, 3, 0); // 3: A database error occurred
return;
}
- chr->delete2_ack(fd, char_id, 1, delete_date);
+ chr->delete2_ack(fd, char_id, 1, delete_date); // 1: success
}
static void char_delete2_accept(int fd, struct char_session_data* sd)
@@ -4227,6 +4332,7 @@ static void char_delete2_accept(int fd, struct char_session_data* sd)
char* data;
time_t delete_date;
+ nullpo_retv(sd);
char_id = RFIFOL(fd,2);
ShowInfo(CL_RED"Request Char Deletion: "CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, char_id);
@@ -4245,14 +4351,14 @@ 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
- chr->delete2_accept_ack(fd, char_id, 3);
+ chr->delete2_accept_ack(fd, char_id, 3); // 3: A database error occurred
return;
}
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(inter->sql_handle);
- chr->delete2_accept_ack(fd, char_id, 3);
+ chr->delete2_accept_ack(fd, char_id, 3); // 3: A database error occurred
return;
}
@@ -4261,45 +4367,46 @@ static void char_delete2_accept(int fd, struct char_session_data* sd)
if( !delete_date || delete_date>time(NULL) )
{// not queued or delay not yet passed
- chr->delete2_accept_ack(fd, char_id, 4);
+ chr->delete2_accept_ack(fd, char_id, 4); // 4: Deleting not yet possible time
return;
}
if( strcmp(sd->birthdate+2, birthdate) ) // +2 to cut off the century
{// birth date is wrong
- chr->delete2_accept_ack(fd, char_id, 5);
+ chr->delete2_accept_ack(fd, char_id, 5); // 5: Date of birth do not match
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
- chr->delete2_accept_ack(fd, char_id, 2);
+ chr->delete2_accept_ack(fd, char_id, 2); // 2: Due to system settings can not be deleted
return;
}
// success
if( chr->delete_char_sql(char_id) < 0 )
{
- chr->delete2_accept_ack(fd, char_id, 3);
+ chr->delete2_accept_ack(fd, char_id, 3); // 3: A database error occurred
return;
}
// refresh character list cache
sd->found_char[i] = -1;
- chr->delete2_accept_ack(fd, char_id, 1);
+ chr->delete2_accept_ack(fd, char_id, 1); // 1: success
}
static void char_delete2_cancel(int fd, struct char_session_data* sd)
{// CH: <082b>.W <char id>.L
int char_id, i;
+ nullpo_retv(sd);
char_id = RFIFOL(fd,2);
ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id );
if( i == MAX_CHARS )
{// character not found
- chr->delete2_cancel_ack(fd, char_id, 2);
+ chr->delete2_cancel_ack(fd, char_id, 2); // 2: A database error occurred
return;
}
@@ -4309,11 +4416,11 @@ static void char_delete2_cancel(int fd, struct char_session_data* sd)
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);
+ chr->delete2_cancel_ack(fd, char_id, 2); // 2: A database error occurred
return;
}
- chr->delete2_cancel_ack(fd, char_id, 1);
+ chr->delete2_cancel_ack(fd, char_id, 1); // 1: success
}
void char_send_account_id(int fd, int account_id)
@@ -4391,6 +4498,7 @@ void char_parse_char_connect(int fd, struct char_session_data* sd, uint32 ipl)
void char_send_map_info(int fd, int i, uint32 subnet_map_ip, struct mmo_charstatus *cd)
{
+ nullpo_retv(cd);
WFIFOHEAD(fd,28);
WFIFOW(fd,0) = 0x71;
WFIFOL(fd,2) = cd->char_id;
@@ -4413,6 +4521,7 @@ int char_search_default_maps_mapserver(struct mmo_charstatus *cd)
{
int i;
int j;
+ nullpo_retr(-1, cd);
if ((i = chr->search_mapserver((j=mapindex->name2id(MAP_PRONTERA)),-1,-1)) >= 0) {
cd->last_point.x = 273;
cd->last_point.y = 354;
@@ -4440,6 +4549,7 @@ int char_search_default_maps_mapserver(struct mmo_charstatus *cd)
return i;
}
+void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl) __attribute__((nonnull (2)));
void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl)
{
struct mmo_charstatus char_dat;
@@ -4481,7 +4591,7 @@ void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl)
//Not found?? May be forged packet.
Sql_ShowDebug(inter->sql_handle);
SQL->FreeResult(inter->sql_handle);
- chr->auth_error(fd, 0);
+ chr->auth_error(fd, 0); // rejected from server
return;
}
@@ -4490,7 +4600,7 @@ void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl)
/* 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);
+ chr->auth_error(fd, 0); // rejected from server
return;
}
@@ -4499,12 +4609,13 @@ void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl)
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);
+ chr->auth_error(fd, 0); // rejected from server
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);
+ nullpo_retv(cd);
if( cd->sex == 99 )
cd->sex = sd->sex;
@@ -4529,14 +4640,14 @@ void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl)
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);
+ chr->authfail_fd(fd, 1); // 1 = Server closed
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);
+ chr->authfail_fd(fd, 1); // 1 = Server closed
return;
}
}
@@ -4548,8 +4659,7 @@ void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl)
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);
+ chr->authfail_fd(fd, 1); // 1 = Server closed
return;
}
@@ -4604,18 +4714,22 @@ void char_creation_ok(int fd, struct mmo_charstatus *char_dat)
WFIFOSET(fd,len);
}
+void char_parse_char_create_new_char(int fd, struct char_session_data* sd) __attribute__((nonnull (2)));
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]
+ if( !char_new ) {
+ //turn character creation on/off [Kevin]
result = -2;
- else
+ } 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
+ }
+ //'Charname already exists' (-1), 'Char creation denied' (-2) and 'You are underaged' (-3)
if (result < 0) {
chr->creation_failed(fd, result);
} else {
@@ -4651,6 +4765,7 @@ void char_delete_char_ok(int fd)
WFIFOSET(fd,2);
}
+void char_parse_char_delete_char(int fd, struct char_session_data* sd, unsigned short cmd) __attribute__((nonnull (2)));
void char_parse_char_delete_char(int fd, struct char_session_data* sd, unsigned short cmd)
{
char email[40];
@@ -4658,7 +4773,7 @@ void char_parse_char_delete_char(int fd, struct char_session_data* sd, unsigned
int i;
#if PACKETVER >= 20110309
- if( pincode->enabled ){ // hack check
+ 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 ){
@@ -4718,6 +4833,7 @@ void char_allow_rename(int fd, int flag)
WFIFOSET(fd,4);
}
+void char_parse_char_rename_char(int fd, struct char_session_data* sd) __attribute__((nonnull (2)));
void char_parse_char_rename_char(int fd, struct char_session_data* sd)
{
int i, cid =RFIFOL(fd,2);
@@ -4742,6 +4858,7 @@ void char_parse_char_rename_char(int fd, struct char_session_data* sd)
chr->allow_rename(fd, i);
}
+void char_parse_char_rename_char2(int fd, struct char_session_data* sd) __attribute__((nonnull (2)));
void char_parse_char_rename_char2(int fd, struct char_session_data* sd)
{
int i, aid = RFIFOL(fd,2), cid =RFIFOL(fd,6);
@@ -4777,6 +4894,7 @@ void char_rename_char_ack(int fd, int flag)
WFIFOSET(fd,4);
}
+void char_parse_char_rename_char_confirm(int fd, struct char_session_data* sd) __attribute__((nonnull (2)));
void char_parse_char_rename_char_confirm(int fd, struct char_session_data* sd)
{
int i;
@@ -4841,22 +4959,24 @@ void char_login_map_server_ack(int fd, uint8 flag)
WFIFOSET(fd,3);
}
-void char_parse_char_login_map_server(int fd)
+void char_parse_char_login_map_server(int fd, uint32 ipl)
{
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 ||
+ if (runflag != CHARSERVER_ST_RUNNING ||
i == ARRAYLENGTH(chr->server) ||
strcmp(l_user, chr->userid) != 0 ||
- strcmp(l_pass, chr->passwd) != 0 )
+ strcmp(l_pass, chr->passwd) != 0 ||
+ !chr->lan_subnetcheck(ipl))
{
- chr->login_map_server_ack(fd, 3);
+ chr->login_map_server_ack(fd, 3); // Failure
} else {
- chr->login_map_server_ack(fd, 0);
+ chr->login_map_server_ack(fd, 0); // Success
chr->server[i].fd = fd;
chr->server[i].ip = ntohl(RFIFOL(fd,54));
@@ -4872,35 +4992,39 @@ void char_parse_char_login_map_server(int fd)
RFIFOSKIP(fd,60);
}
+void char_parse_char_pincode_check(int fd, struct char_session_data* sd) __attribute__((nonnull (2)));
void char_parse_char_pincode_check(int fd, struct char_session_data* sd)
{
- if( RFIFOL(fd,2) == sd->account_id )
- pincode->check( fd, sd );
+ if (RFIFOL(fd,2) == sd->account_id)
+ pincode->check(fd, sd);
- RFIFOSKIP(fd,10);
+ RFIFOSKIP(fd, 10);
}
+void char_parse_char_pincode_window(int fd, struct char_session_data* sd) __attribute__((nonnull (2)));
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 );
+ if (RFIFOL(fd,2) == sd->account_id)
+ pincode->sendstate(fd, sd, PINCODE_NOTSET);
- RFIFOSKIP(fd,6);
+ RFIFOSKIP(fd, 6);
}
+void char_parse_char_pincode_change(int fd, struct char_session_data* sd) __attribute__((nonnull (2)));
void char_parse_char_pincode_change(int fd, struct char_session_data* sd)
{
- if( RFIFOL(fd,2) == sd->account_id )
- pincode->change( fd, sd );
+ if (RFIFOL(fd,2) == sd->account_id)
+ pincode->change(fd, sd);
- RFIFOSKIP(fd,14);
+ RFIFOSKIP(fd, 14);
}
+void char_parse_char_pincode_first_pin(int fd, struct char_session_data* sd) __attribute__((nonnull (2)));
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);
+ 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)
@@ -4994,7 +5118,6 @@ int char_parse_char(int fd)
FIFOSD_CHECK(3);
{
chr->parse_char_select(fd, sd, ipl);
-
}
break;
@@ -5099,7 +5222,7 @@ int char_parse_char(int fd)
if (RFIFOREST(fd) < 60)
return 0;
{
- chr->parse_char_login_map_server(fd);
+ chr->parse_char_login_map_server(fd, ipl);
}
return 0; // avoid processing of follow-up packets here
@@ -5155,6 +5278,7 @@ int mapif_sendall(unsigned char *buf, unsigned int len)
{
int i, c;
+ nullpo_ret(buf);
c = 0;
for(i = 0; i < ARRAYLENGTH(chr->server); i++) {
int fd;
@@ -5173,6 +5297,7 @@ int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len)
{
int i, c;
+ nullpo_ret(buf);
c = 0;
for(i = 0; i < ARRAYLENGTH(chr->server); i++) {
int fd;
@@ -5189,6 +5314,7 @@ int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len)
int mapif_send(int fd, unsigned char *buf, unsigned int len)
{
+ nullpo_ret(buf);
if (fd >= 0) {
int i;
ARR_FIND( 0, ARRAYLENGTH(chr->server), i, fd == chr->server[i].fd );
@@ -5241,6 +5367,7 @@ 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*);
+ nullpo_ret(character);
if(character->server > -1)
{
WFIFOL(chr->login_fd,8+(*i)*4) = character->account_id;
@@ -5307,6 +5434,7 @@ static int char_waiting_disconnect(int tid, int64 tick, int id, intptr_t data) {
static int char_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap)
{
struct online_char_data *character= DB->data2ptr(data);
+ nullpo_ret(character);
if (character->fd != -1)
return 0; //Character still connected
if (character->server == -2) //Unknown server.. set them offline
@@ -5955,6 +6083,7 @@ void char_defaults(void)
memset(chr->userid, 0, sizeof(chr->userid));
memset(chr->passwd, 0, sizeof(chr->passwd));
+ memset(chr->server_name, 0, sizeof(chr->server_name));
chr->ip = 0;
chr->port = 6121;
@@ -5978,6 +6107,7 @@ void char_defaults(void)
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_gender = char_mmo_gender;
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;
@@ -6045,6 +6175,7 @@ void char_defaults(void)
chr->ban = char_ban;
chr->unban = char_unban;
chr->ask_name_ack = char_ask_name_ack;
+ chr->changecharsex = char_changecharsex;
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;
diff --git a/src/char/char.h b/src/char/char.h
index e27aa0b44..5f2f8571a 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -5,9 +5,10 @@
#ifndef COMMON_CHAR_H
#define COMMON_CHAR_H
-#include "../common/cbasetypes.h"
-#include "../common/core.h" // CORE_ST_LAST
-#include "../common/db.h"
+#include "common/cbasetypes.h"
+#include "common/core.h" // CORE_ST_LAST
+#include "common/db.h"
+#include "common/mmo.h"
enum E_CHARSERVER_ST {
CHARSERVER_ST_RUNNING = CORE_ST_LAST,
@@ -166,6 +167,7 @@ struct char_interface {
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_gender) (const struct char_session_data *sd, const struct mmo_charstatus *p, char sex);
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);
@@ -233,6 +235,7 @@ struct char_interface {
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);
+ int (*changecharsex) (int char_id, int sex);
void (*parse_frommap_change_account) (int fd);
void (*parse_frommap_fame_list) (int fd);
void (*parse_frommap_divorce_char) (int fd);
@@ -287,7 +290,7 @@ struct char_interface {
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_login_map_server) (int fd, uint32 ipl);
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);
diff --git a/src/char/geoip.c b/src/char/geoip.c
index 889958e16..8c415b6bf 100644
--- a/src/char/geoip.c
+++ b/src/char/geoip.c
@@ -6,14 +6,14 @@
#include "geoip.h"
+#include "common/cbasetypes.h"
+#include "common/malloc.h"
+#include "common/showmsg.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;
@@ -145,18 +145,20 @@ void geoip_init(void)
}
// 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) {
+ if (fseek(db, -3l, SEEK_END) != 0) {
+ db_type = 0;
+ } else {
+ 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;
}
- break;
- } else {
if (fseek(db, -4l, SEEK_CUR) != 0) {
db_type = 0;
break;
diff --git a/src/char/geoip.h b/src/char/geoip.h
index a7ab6b9a4..4d39011aa 100644
--- a/src/char/geoip.h
+++ b/src/char/geoip.h
@@ -5,7 +5,7 @@
#ifndef CHAR_GEOIP_H
#define CHAR_GEOIP_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
/**
* GeoIP information
@@ -15,6 +15,7 @@ struct s_geoip {
bool active;
};
+
/**
* geoip interface
**/
diff --git a/src/char/int_auction.c b/src/char/int_auction.c
index 57eae641d..8d51777fb 100644
--- a/src/char/int_auction.c
+++ b/src/char/int_auction.c
@@ -6,22 +6,23 @@
#include "int_auction.h"
+#include "char/char.h"
+#include "char/int_mail.h"
+#include "char/inter.h"
+#include "char/mapif.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#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"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/sql.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
struct inter_auction_interface inter_auction_s;
@@ -33,7 +34,7 @@ static int inter_auction_count(int char_id, bool buy)
for( auction = dbi_first(iter); dbi_exists(iter); auction = dbi_next(iter) )
{
- if( (buy && auction->buyer_id == char_id) || (!buy && auction->seller_id == char_id) )
+ if ((buy && auction->buyer_id == char_id) || (!buy && auction->seller_id == char_id))
i++;
}
dbi_destroy(iter);
@@ -160,7 +161,10 @@ static int inter_auction_end_timer(int tid, int64 tick, int id, intptr_t data) {
void inter_auction_delete(struct auction_data *auction)
{
- unsigned int auction_id = auction->auction_id;
+ unsigned int auction_id;
+ nullpo_retv(auction);
+
+ auction_id = auction->auction_id;
if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `auction_id` = '%d'", auction_db, auction_id) )
Sql_ShowDebug(inter->sql_handle);
@@ -240,6 +244,8 @@ void mapif_auction_sendlist(int fd, int char_id, short count, short pages, unsig
{
int len = (sizeof(struct auction_data) * count) + 12;
+ nullpo_retv(buf);
+
WFIFOHEAD(fd, len);
WFIFOW(fd,0) = 0x3850;
WFIFOW(fd,2) = len;
@@ -297,6 +303,8 @@ void mapif_auction_register(int fd, struct auction_data *auction)
{
int len = sizeof(struct auction_data) + 4;
+ nullpo_retv(auction);
+
WFIFOHEAD(fd,len);
WFIFOW(fd,0) = 0x3851;
WFIFOW(fd,2) = len;
diff --git a/src/char/int_auction.h b/src/char/int_auction.h
index c27ecd6c3..610042b9a 100644
--- a/src/char/int_auction.h
+++ b/src/char/int_auction.h
@@ -4,7 +4,8 @@
#ifndef CHAR_INT_AUCTION_H
#define CHAR_INT_AUCTION_H
-#include "../common/mmo.h"
+#include "common/db.h"
+#include "common/mmo.h"
#ifdef HERCULES_CORE
void inter_auction_defaults(void);
diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c
index d14d1e1e0..eff84c57d 100644
--- a/src/char/int_elemental.c
+++ b/src/char/int_elemental.c
@@ -6,26 +6,27 @@
#include "int_elemental.h"
+#include "char/char.h"
+#include "char/inter.h"
+#include "char/mapif.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#include "char.h"
-#include "inter.h"
-#include "mapif.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/sql.h"
-#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;
+ nullpo_retr(false, ele);
if( ele->elemental_id == 0 ) { // Create new DB entry
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`)"
@@ -53,6 +54,7 @@ bool mapif_elemental_save(struct s_elemental* ele) {
bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) {
char* data;
+ nullpo_retr(false, ele);
memset(ele, 0, sizeof(struct s_elemental));
ele->elemental_id = ele_id;
ele->char_id = char_id;
@@ -105,6 +107,7 @@ bool mapif_elemental_delete(int ele_id) {
void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) {
int size = sizeof(struct s_elemental) + 5;
+ nullpo_retv(ele);
WFIFOHEAD(fd,size);
WFIFOW(fd,0) = 0x387c;
WFIFOW(fd,2) = size;
diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h
index 7aa379ebb..7385fc496 100644
--- a/src/char/int_elemental.h
+++ b/src/char/int_elemental.h
@@ -4,7 +4,7 @@
#ifndef CHAR_INT_ELEMENTAL_H
#define CHAR_INT_ELEMENTAL_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
#ifdef HERCULES_CORE
void inter_elemental_defaults(void);
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 20db452af..24561fe21 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -4,24 +4,24 @@
#define HERCULES_CORE
-#include "../config/core.h" // DBPATH
+#include "config/core.h" // DBPATH
#include "int_guild.h"
+#include "char/char.h"
+#include "char/inter.h"
+#include "char/mapif.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#include "char.h"
-#include "inter.h"
-#include "mapif.h"
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
#define GS_MEMBER_UNMODIFIED 0x00
#define GS_MEMBER_MODIFIED 0x01
@@ -50,6 +50,8 @@ int inter_guild_save_timer(int tid, int64 tick, int id, intptr_t data) {
for( g = DB->data2ptr(iter->first(iter, &key)); dbi_exists(iter); g = DB->data2ptr(iter->next(iter, &key)) )
{
+ if (!g)
+ continue;
if( state == 0 && g->guild_id == last_id )
state++; //Save next guild in the list.
else
@@ -114,6 +116,7 @@ int inter_guild_tosql(struct guild *g,int flag)
char new_guild = 0;
int i=0;
+ nullpo_ret(g);
if (g->guild_id<=0 && g->guild_id != -1) return 0;
#ifdef NOISY
@@ -253,7 +256,7 @@ int inter_guild_tosql(struct guild *g,int flag)
//printf("- Insert guild %d to guild_position\n",g->guild_id);
for(i=0;i<MAX_GUILDPOSITION;i++){
struct guild_position *p = &g->position[i];
- if (!p->modified)
+ if (!p || !p->modified)
continue;
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')",
@@ -521,6 +524,7 @@ int inter_guild_castle_tosql(struct guild_castle *gc)
StringBuf buf;
int i;
+ nullpo_ret(gc);
StrBuf->Init(&buf);
StrBuf->Printf(&buf, "REPLACE INTO `%s` SET `castle_id`='%d', `guild_id`='%d', `economy`='%d', `defense`='%d', "
"`triggerE`='%d', `triggerD`='%d', `nextTime`='%d', `payTime`='%d', `createTime`='%d', `visibleC`='%d'",
@@ -593,6 +597,7 @@ struct guild_castle* inter_guild_castle_fromsql(int castle_id)
// Read exp_guild.txt
bool inter_guild_exp_parse_row(char* split[], int column, int current) {
int64 exp = strtoll(split[0], NULL, 10);
+ nullpo_retr(true, split);
if (exp < 0 || exp >= UINT_MAX) {
ShowError("exp_guild: Invalid exp %"PRId64" (valid range: 0 - %u) at line %d\n", exp, UINT_MAX, current);
@@ -729,6 +734,7 @@ int inter_guild_sql_init(void)
int inter_guild_db_final(DBKey key, DBData *data, va_list ap)
{
struct guild *g = DB->data2ptr(data);
+ nullpo_ret(g);
if (g->save_flag&GS_MASK) {
inter_guild->tosql(g, g->save_flag&GS_MASK);
return 1;
@@ -749,6 +755,7 @@ int inter_guild_search_guildname(char *str)
int guild_id;
char esc_name[NAME_LENGTH*2+1];
+ nullpo_retr(-1, str);
SQL->EscapeStringLen(inter->sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
//Lookup guilds with the same name
if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT guild_id FROM `%s` WHERE name='%s'", guild_db, esc_name) )
@@ -776,6 +783,7 @@ int inter_guild_search_guildname(char *str)
static bool inter_guild_check_empty(struct guild *g)
{
int i;
+ nullpo_ret(g);
ARR_FIND( 0, g->max_member, i, g->member[i].account_id > 0 );
if( i < g->max_member)
return false; // not empty
@@ -788,16 +796,17 @@ static bool inter_guild_check_empty(struct guild *g)
unsigned int inter_guild_nextexp(int level) {
if (level == 0)
return 1;
- if (level <= 0 || level >= MAX_GUILDLEVEL)
+ if (level <= 0 || level > MAX_GUILDLEVEL)
return 0;
return inter_guild->exp[level-1];
}
-int inter_guild_checkskill(struct guild *g,int id)
+int inter_guild_checkskill(struct guild *g, int id)
{
int idx = id - GD_SKILLBASE;
+ nullpo_ret(g);
if(idx < 0 || idx >= MAX_GUILDSKILL)
return 0;
@@ -810,6 +819,7 @@ int inter_guild_calcinfo(struct guild *g)
unsigned int nextexp;
struct guild before = *g; // Save guild current values
+ nullpo_ret(g);
if(g->guild_lv<=0)
g->guild_lv = 1;
nextexp = inter_guild->nextexp(g->guild_lv);
@@ -826,7 +836,7 @@ int inter_guild_calcinfo(struct guild *g)
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 + inter_guild->checkskill(g, GD_EXTENSION) * 6;
+ g->max_member = BASE_GUILD_SIZE + 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);
@@ -905,6 +915,7 @@ int mapif_guild_noinfo(int fd, int guild_id)
int mapif_guild_info(int fd, struct guild *g)
{
unsigned char buf[8+sizeof(struct guild)];
+ nullpo_ret(g);
WBUFW(buf,0)=0x3831;
WBUFW(buf,2)=4+sizeof(struct guild);
memcpy(buf+4,g,sizeof(struct guild));
@@ -932,6 +943,10 @@ int mapif_guild_memberadded(int fd, int guild_id, int account_id, int char_id, i
int mapif_guild_withdraw(int guild_id,int account_id,int char_id,int flag, const char *name, const char *mes)
{
unsigned char buf[55+NAME_LENGTH];
+
+ nullpo_ret(name);
+ nullpo_ret(mes);
+
WBUFW(buf, 0)=0x3834;
WBUFL(buf, 2)=guild_id;
WBUFL(buf, 6)=account_id;
@@ -948,6 +963,8 @@ int mapif_guild_withdraw(int guild_id,int account_id,int char_id,int flag, const
int mapif_guild_memberinfoshort(struct guild *g, int idx)
{
unsigned char buf[19];
+ nullpo_ret(g);
+ Assert_ret(idx >= 0 && idx < MAX_GUILD);
WBUFW(buf, 0)=0x3835;
WBUFL(buf, 2)=g->guild_id;
WBUFL(buf, 6)=g->member[idx].account_id;
@@ -975,6 +992,7 @@ 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)
{
unsigned char buf[512];
+ nullpo_ret(mes);
if (len > 500)
len = 500;
WBUFW(buf,0)=0x3837;
@@ -990,6 +1008,7 @@ int mapif_guild_message(int guild_id, int account_id, char *mes, int len, int sf
int mapif_guild_basicinfochanged(int guild_id, int type, const void *data, int len)
{
unsigned char buf[2048];
+ nullpo_ret(data);
if (len > 2038)
len = 2038;
WBUFW(buf, 0)=0x3839;
@@ -1005,6 +1024,7 @@ int mapif_guild_basicinfochanged(int guild_id, int type, const void *data, int l
int mapif_guild_memberinfochanged(int guild_id, int account_id, int char_id, int type, const void *data, int len)
{
unsigned char buf[2048];
+ nullpo_ret(data);
if (len > 2030)
len = 2030;
WBUFW(buf, 0)=0x383a;
@@ -1034,6 +1054,8 @@ 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)
{
unsigned char buf[19+2*NAME_LENGTH];
+ nullpo_ret(name1);
+ nullpo_ret(name2);
WBUFW(buf, 0)=0x383d;
WBUFL(buf, 2)=guild_id1;
WBUFL(buf, 6)=guild_id2;
@@ -1050,6 +1072,8 @@ int mapif_guild_alliance(int guild_id1, int guild_id2, int account_id1, int acco
int mapif_guild_position(struct guild *g, int idx)
{
unsigned char buf[12 + sizeof(struct guild_position)];
+ nullpo_ret(g);
+ Assert_ret(idx >= 0 && idx < MAX_GUILDPOSITION);
WBUFW(buf,0)=0x383b;
WBUFW(buf,2)=sizeof(struct guild_position)+12;
WBUFL(buf,4)=g->guild_id;
@@ -1063,6 +1087,7 @@ int mapif_guild_position(struct guild *g, int idx)
int mapif_guild_notice(struct guild *g)
{
unsigned char buf[256];
+ nullpo_ret(g);
WBUFW(buf,0)=0x383e;
WBUFL(buf,2)=g->guild_id;
memcpy(WBUFP(buf,6),g->mes1,MAX_GUILDMES1);
@@ -1075,6 +1100,7 @@ int mapif_guild_notice(struct guild *g)
int mapif_guild_emblem(struct guild *g)
{
unsigned char buf[12 + sizeof(g->emblem_data)];
+ nullpo_ret(g);
WBUFW(buf,0)=0x383f;
WBUFW(buf,2)=g->emblem_len+12;
WBUFL(buf,4)=g->guild_id;
@@ -1087,6 +1113,7 @@ int mapif_guild_emblem(struct guild *g)
int mapif_guild_master_changed(struct guild *g, int aid, int cid)
{
unsigned char buf[14];
+ nullpo_ret(g);
WBUFW(buf,0)=0x3843;
WBUFL(buf,2)=g->guild_id;
WBUFL(buf,6)=aid;
@@ -1102,6 +1129,7 @@ int mapif_guild_castle_dataload(int fd, int sz, int *castle_ids)
int len = 4 + num * sizeof(*gc);
int i;
+ nullpo_ret(castle_ids);
WFIFOHEAD(fd, len);
WFIFOW(fd, 0) = 0x3840;
WFIFOW(fd, 2) = len;
@@ -1125,6 +1153,8 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member
#ifdef NOISY
ShowInfo("Creating Guild (%s)\n", name);
#endif
+ nullpo_ret(name);
+ nullpo_ret(master);
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);
@@ -1154,7 +1184,7 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member
g->member[0].modified = GS_MEMBER_MODIFIED;
// Set default positions
- g->position[0].mode=0x11;
+ g->position[0].mode = GPERM_BOTH;
strcpy(g->position[0].name,"GuildMaster");
strcpy(g->position[MAX_GUILDPOSITION-1].name,"Newbie");
g->position[0].modified = g->position[MAX_GUILDPOSITION-1].modified = GS_POSITION_MODIFIED;
@@ -1164,10 +1194,10 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member
}
// Initialize guild property
- g->max_member=16;
- g->average_lv=master->lv;
- g->connect_member=1;
- g->guild_lv=1;
+ g->max_member = BASE_GUILD_SIZE;
+ g->average_lv = master->lv;
+ g->connect_member = 1;
+ g->guild_lv = 1;
for(i=0;i<MAX_GUILDSKILL;i++)
g->skill[i].id=i + GD_SKILLBASE;
@@ -1217,10 +1247,10 @@ int mapif_parse_GuildAddMember(int fd, int guild_id, struct guild_member *m)
struct guild * g;
int i;
+ nullpo_ret(m);
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); // 1: Failed to add
return 0;
}
@@ -1231,7 +1261,7 @@ 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);
+ mapif->guild_memberadded(fd,guild_id,m->account_id,m->char_id,0); // 0: success
if (!inter_guild->calcinfo(g)) //Send members if it was not invoked.
mapif->guild_info(-1,g);
@@ -1242,8 +1272,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); // 1: Failed to add
return 0;
}
@@ -1262,6 +1291,7 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in
return 0;
}
+ nullpo_ret(mes);
// Find the member
ARR_FIND( 0, g->max_member, i, g->member[i].account_id == account_id && g->member[i].char_id == char_id );
if( i == g->max_member )
@@ -1426,6 +1456,7 @@ int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const void
if( g == NULL )
return 0;
+ nullpo_ret(data);
switch(type) {
case GBI_EXP:
value = *((const int16 *)data);
@@ -1478,6 +1509,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
int i;
struct guild * g;
+ nullpo_ret(data);
g = inter_guild->fromsql(guild_id);
if(g==NULL)
return 0;
@@ -1588,6 +1620,7 @@ int inter_guild_charname_changed(int guild_id, int account_id, int char_id, char
struct guild *g;
int i, flag = 0;
+ nullpo_ret(name);
g = inter_guild->fromsql(guild_id);
if( g == NULL )
{
@@ -1625,6 +1658,7 @@ int mapif_parse_GuildPosition(int fd, int guild_id, int idx, struct guild_positi
// Could make some improvement in speed, because only change guild_position
struct guild * g;
+ nullpo_ret(p);
g = inter_guild->fromsql(guild_id);
if(g==NULL || idx<0 || idx>=MAX_GUILDPOSITION)
return 0;
@@ -1664,6 +1698,7 @@ int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int account_i
int i;
char name[NAME_LENGTH];
+ nullpo_retr(-1, g);
ARR_FIND( 0, MAX_GUILDALLIANCE, i, g->alliance[i].guild_id == guild_id );
if( i == MAX_GUILDALLIANCE )
return -1;
@@ -1726,6 +1761,8 @@ int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char *
{
struct guild *g;
+ nullpo_ret(mes1);
+ nullpo_ret(mes2);
g = inter_guild->fromsql(guild_id);
if(g==NULL)
return 0;
@@ -1740,6 +1777,7 @@ int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char
{
struct guild * g;
+ nullpo_ret(data);
g = inter_guild->fromsql(guild_id);
if(g==NULL)
return 0;
@@ -1804,6 +1842,7 @@ int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int le
struct guild_member gm;
int pos;
+ nullpo_ret(name);
g = inter_guild->fromsql(guild_id);
if(g==NULL || len > NAME_LENGTH)
@@ -1840,8 +1879,8 @@ 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);
@@ -1888,6 +1927,7 @@ void inter_guild_defaults(void)
inter_guild->guild_db = NULL;
inter_guild->castle_db = NULL;
+ memset(inter_guild->exp, 0, sizeof(inter_guild->exp));
inter_guild->save_timer = inter_guild_save_timer;
inter_guild->removemember_tosql = inter_guild_removemember_tosql;
diff --git a/src/char/int_guild.h b/src/char/int_guild.h
index e7d089943..eb4c930fc 100644
--- a/src/char/int_guild.h
+++ b/src/char/int_guild.h
@@ -4,7 +4,8 @@
#ifndef CHAR_INT_GUILD_H
#define CHAR_INT_GUILD_H
-#include "../common/mmo.h"
+#include "common/db.h"
+#include "common/mmo.h"
enum {
GS_BASIC = 0x0001,
diff --git a/src/char/int_homun.c b/src/char/int_homun.c
index dd23261c2..eda2afe69 100644
--- a/src/char/int_homun.c
+++ b/src/char/int_homun.c
@@ -6,20 +6,20 @@
#include "int_homun.h"
+#include "char/char.h"
+#include "char/inter.h"
+#include "char/mapif.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#include "char.h"
-#include "inter.h"
-#include "mapif.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/sql.h"
-#include "../common/strlib.h"
-#include "../common/utils.h"
struct inter_homunculus_interface inter_homunculus_s;
@@ -34,6 +34,7 @@ void inter_homunculus_sql_final(void)
void mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, unsigned char flag)
{
+ nullpo_retv(sh);
WFIFOHEAD(fd, sizeof(struct s_homunculus)+9);
WFIFOW(fd,0) = 0x3890;
WFIFOW(fd,2) = sizeof(struct s_homunculus)+9;
@@ -81,6 +82,7 @@ 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)
{
+ nullpo_retv(name);
WFIFOHEAD(fd, NAME_LENGTH+12);
WFIFOW(fd, 0) = 0x3894;
WFIFOL(fd, 2) = account_id;
@@ -95,6 +97,7 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
bool flag = true;
char esc_name[NAME_LENGTH*2+1];
+ nullpo_ret(hd);
SQL->EscapeStringLen(inter->sql_handle, esc_name, hd->name, strnlen(hd->name, NAME_LENGTH));
if( hd->hom_id == 0 )
@@ -158,6 +161,7 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
char* data;
size_t len;
+ nullpo_ret(hd);
memset(hd, 0, sizeof(*hd));
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) )
@@ -247,6 +251,7 @@ bool mapif_homunculus_rename(char *name)
{
int i;
+ nullpo_ret(name);
// Check Authorized letters/symbols in the name of the homun
if( char_name_option == 1 )
{// only letters/symbols in char_name_letters are authorized
diff --git a/src/char/int_homun.h b/src/char/int_homun.h
index 0212da150..113c6d340 100644
--- a/src/char/int_homun.h
+++ b/src/char/int_homun.h
@@ -4,7 +4,7 @@
#ifndef CHAR_INT_HOMUN_H
#define CHAR_INT_HOMUN_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
struct s_homunculus;
diff --git a/src/char/int_mail.c b/src/char/int_mail.c
index 17fb9d424..d4bfe14e4 100644
--- a/src/char/int_mail.c
+++ b/src/char/int_mail.c
@@ -6,20 +6,20 @@
#include "int_mail.h"
+#include "char/char.h"
+#include "char/inter.h"
+#include "char/mapif.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#include "char.h"
-#include "inter.h"
-#include "mapif.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/sql.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
struct inter_mail_interface inter_mail_s;
@@ -30,6 +30,7 @@ static int inter_mail_fromsql(int char_id, struct mail_data* md)
char *data;
StringBuf buf;
+ nullpo_ret(md);
memset(md, 0, sizeof(struct mail_data));
md->amount = 0;
md->full = false;
@@ -114,6 +115,7 @@ int inter_mail_savemessage(struct mail_message* msg)
SqlStmt* stmt;
int j;
+ nullpo_ret(msg);
// build message save query
StrBuf->Init(&buf);
StrBuf->Printf(&buf, "INSERT INTO `%s` (`send_name`, `send_id`, `dest_name`, `dest_id`, `title`, `message`, `time`, `status`, `zeny`, `amount`, `nameid`, `refine`, `attribute`, `identify`, `unique_id`", mail_db);
@@ -151,6 +153,7 @@ static bool inter_mail_loadmessage(int mail_id, struct mail_message* msg)
{
int j;
StringBuf buf;
+ nullpo_ret(msg);
memset(msg, 0, sizeof(struct mail_message)); // Initialize data
StrBuf->Init(&buf);
@@ -203,6 +206,7 @@ static bool inter_mail_loadmessage(int mail_id, struct mail_message* msg)
void mapif_mail_sendinbox(int fd, int char_id, unsigned char flag, struct mail_data *md)
{
+ nullpo_retv(md);
//FIXME: dumping the whole structure like this is unsafe [ultramage]
WFIFOHEAD(fd, sizeof(struct mail_data) + 9);
WFIFOW(fd,0) = 0x3848;
@@ -263,6 +267,7 @@ static bool inter_mail_DeleteAttach(int mail_id)
void mapif_mail_sendattach(int fd, int char_id, struct mail_message *msg)
{
+ nullpo_retv(msg);
WFIFOHEAD(fd, sizeof(struct item) + 12);
WFIFOW(fd,0) = 0x384a;
WFIFOW(fd,2) = sizeof(struct item) + 12;
@@ -402,6 +407,7 @@ void mapif_mail_send(int fd, struct mail_message* msg)
{
int len = sizeof(struct mail_message) + 4;
+ nullpo_retv(msg);
WFIFOHEAD(fd,len);
WFIFOW(fd,0) = 0x384d;
WFIFOW(fd,2) = len;
@@ -449,6 +455,10 @@ void mapif_parse_mail_send(int fd)
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;
+ nullpo_retv(send_name);
+ nullpo_retv(dest_name);
+ nullpo_retv(title);
+ nullpo_retv(body);
memset(&msg, 0, sizeof(struct mail_message));
msg.send_id = send_id;
diff --git a/src/char/int_mail.h b/src/char/int_mail.h
index 02f640ae2..8e6acf846 100644
--- a/src/char/int_mail.h
+++ b/src/char/int_mail.h
@@ -4,7 +4,7 @@
#ifndef CHAR_INT_MAIL_H
#define CHAR_INT_MAIL_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
struct item;
struct mail_data;
diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c
index 2bd94b97e..02082aa13 100644
--- a/src/char/int_mercenary.c
+++ b/src/char/int_mercenary.c
@@ -6,20 +6,21 @@
#include "int_mercenary.h"
+#include "char/char.h"
+#include "char/inter.h"
+#include "char/mapif.h"
+#include "common/cbasetypes.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#include "char.h"
-#include "inter.h"
-#include "mapif.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/sql.h"
-#include "../common/strlib.h"
-#include "../common/utils.h"
struct inter_mercenary_interface inter_mercenary_s;
@@ -27,6 +28,7 @@ bool inter_mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status)
{
char* data;
+ nullpo_ret(status);
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(inter->sql_handle);
@@ -53,6 +55,7 @@ bool inter_mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status)
bool inter_mercenary_owner_tosql(int char_id, struct mmo_charstatus *status)
{
+ nullpo_ret(status);
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) )
{
@@ -78,6 +81,7 @@ bool mapif_mercenary_save(struct s_mercenary* merc)
{
bool flag = true;
+ nullpo_ret(merc);
if( merc->mercenary_id == 0 )
{ // Create new DB entry
if( SQL_ERROR == SQL->Query(inter->sql_handle,
@@ -105,6 +109,7 @@ bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc)
{
char* data;
+ nullpo_ret(merc);
memset(merc, 0, sizeof(struct s_mercenary));
merc->mercenary_id = merc_id;
merc->char_id = char_id;
@@ -148,6 +153,7 @@ void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag)
{
int size = sizeof(struct s_mercenary) + 5;
+ nullpo_retv(merc);
WFIFOHEAD(fd,size);
WFIFOW(fd,0) = 0x3870;
WFIFOW(fd,2) = size;
diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h
index 049429e1d..632a9ab37 100644
--- a/src/char/int_mercenary.h
+++ b/src/char/int_mercenary.h
@@ -4,7 +4,7 @@
#ifndef CHAR_INT_MERCENARY_H
#define CHAR_INT_MERCENARY_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
struct mmo_charstatus;
diff --git a/src/char/int_party.c b/src/char/int_party.c
index bf950ec42..3b857318c 100644
--- a/src/char/int_party.c
+++ b/src/char/int_party.c
@@ -6,22 +6,22 @@
#include "int_party.h"
+#include "char/char.h"
+#include "char/inter.h"
+#include "char/mapif.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/mapindex.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#include "char.h"
-#include "inter.h"
-#include "mapif.h"
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/mapindex.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/sql.h"
-#include "../common/strlib.h"
struct inter_party_interface inter_party_s;
@@ -29,6 +29,7 @@ struct inter_party_interface inter_party_s;
static int inter_party_check_lv(struct party_data *p) {
int i;
unsigned int lv;
+ nullpo_ret(p);
p->min_lv = UINT_MAX;
p->max_lv = 0;
for(i=0;i<MAX_PARTY;i++){
@@ -54,6 +55,7 @@ static int inter_party_check_lv(struct party_data *p) {
static void inter_party_calc_state(struct party_data *p)
{
int i;
+ nullpo_retv(p);
p->min_lv = UINT_MAX;
p->max_lv = 0;
p->party.count =
@@ -67,9 +69,10 @@ static void inter_party_calc_state(struct party_data *p)
if(p->party.member[i].online)
p->party.count++;
}
+ // FIXME[Haru]: What if the occupied positions aren't the first three? It can happen if some party members leave. This is the reason why family sharing some times stops working until you recreate your party
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?
+ if(p->party.member[0].class_&JOBL_BABY) //first slot is the child?
p->family = p->party.member[0].char_id;
else
p->family = p->party.member[1].char_id;
@@ -109,6 +112,7 @@ int inter_party_tosql(struct party *p, int flag, int index)
if( p == NULL || p->party_id == 0 )
return 0;
+ Assert_ret(index >= 0 && index < MAX_PARTY);
party_id = p->party_id;
#ifdef NOISY
@@ -257,12 +261,12 @@ int inter_party_sql_init(void)
exit(EXIT_FAILURE);
}
- /* Uncomment the following if you want to do a party_db cleanup (remove parties with no members) on startup.[Skotlex]
+#if 0 // Enable 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(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(inter->sql_handle);
- */
+#endif // 0
return 0;
}
@@ -295,6 +299,7 @@ struct party_data* inter_party_search_partyname(const char *const str)
// Returns whether this party can keep having exp share or not.
int inter_party_check_exp_share(struct party_data *const p)
{
+ nullpo_ret(p);
return (p->party.count < 2 || p->max_lv - p->min_lv <= party_share_level);
}
@@ -353,6 +358,7 @@ void mapif_party_noinfo(int fd, int party_id, int char_id)
void mapif_party_info(int fd, struct party* p, int char_id)
{
unsigned char buf[8 + sizeof(struct party)];
+ nullpo_retv(p);
WBUFW(buf,0) = 0x3821;
WBUFW(buf,2) = 8 + sizeof(struct party);
WBUFL(buf,4) = char_id;
@@ -381,6 +387,7 @@ int mapif_party_memberadded(int fd, int party_id, int account_id, int char_id, i
int mapif_party_optionchanged(int fd, struct party *p, int account_id, int flag)
{
unsigned char buf[16];
+ nullpo_ret(p);
WBUFW(buf,0)=0x3823;
WBUFL(buf,2)=p->party_id;
WBUFL(buf,6)=account_id;
@@ -411,6 +418,8 @@ int mapif_party_membermoved(struct party *p, int idx)
{
unsigned char buf[20];
+ nullpo_ret(p);
+ Assert_ret(idx >= 0 && idx < MAX_PARTY);
WBUFW(buf,0) = 0x3825;
WBUFL(buf,2) = p->party_id;
WBUFL(buf,6) = p->member[idx].account_id;
@@ -438,6 +447,7 @@ 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)
{
unsigned char buf[512];
+ nullpo_ret(mes);
WBUFW(buf,0)=0x3827;
WBUFW(buf,2)=len+12;
WBUFL(buf,4)=party_id;
@@ -456,6 +466,8 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part
{
struct party_data *p;
int i;
+ nullpo_ret(name);
+ nullpo_ret(leader);
if( (p=inter_party->search_partyname(name))!=NULL){
mapif->party_created(fd,leader->account_id,leader->char_id,NULL);
return 0;
@@ -523,6 +535,7 @@ int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member
struct party_data *p;
int i;
+ nullpo_ret(member);
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);
@@ -580,7 +593,7 @@ int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int
int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
{
struct party_data *p;
- int i,j=-1;
+ int i,j;
p = inter_party->fromsql(party_id);
if( p == NULL )
@@ -731,8 +744,8 @@ int mapif_parse_PartyLeaderChange(int fd, int party_id, int account_id, int char
// 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);
diff --git a/src/char/int_party.h b/src/char/int_party.h
index 61d828bc0..99ee5b13e 100644
--- a/src/char/int_party.h
+++ b/src/char/int_party.h
@@ -4,7 +4,8 @@
#ifndef CHAR_INT_PARTY_H
#define CHAR_INT_PARTY_H
-#include "../common/mmo.h"
+#include "common/db.h"
+#include "common/mmo.h"
//Party Flags on what to save/delete.
enum {
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index b37037844..22fe2dcc2 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -6,20 +6,20 @@
#include "int_pet.h"
+#include "char/char.h"
+#include "char/inter.h"
+#include "char/mapif.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#include "char.h"
-#include "inter.h"
-#include "mapif.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/sql.h"
-#include "../common/strlib.h"
-#include "../common/utils.h"
struct inter_pet_interface inter_pet_s;
@@ -29,6 +29,7 @@ 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
+ nullpo_ret(p);
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);
@@ -70,6 +71,7 @@ int inter_pet_fromsql(int pet_id, struct s_pet* p)
#ifdef NOISY
ShowInfo("Loading pet (%d)...\n",pet_id);
#endif
+ nullpo_ret(p);
memset(p, 0, sizeof(struct s_pet));
//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`)
@@ -145,6 +147,7 @@ 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)
{
+ nullpo_ret(p);
WFIFOHEAD(fd, sizeof(struct s_pet) + 9);
WFIFOW(fd, 0) =0x3881;
WFIFOW(fd, 2) =sizeof(struct s_pet) + 9;
@@ -193,6 +196,7 @@ 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)
{
+ nullpo_ret(pet_name);
memset(inter_pet->pt, 0, sizeof(struct s_pet));
safestrncpy(inter_pet->pt->name, pet_name, NAME_LENGTH);
if(incubate == 1)
@@ -254,6 +258,7 @@ int mapif_save_pet(int fd, int account_id, struct s_pet *data)
{
//here process pet save request.
int len;
+ nullpo_ret(data);
RFIFOHEAD(fd);
len=RFIFOW(fd, 2);
if (sizeof(struct s_pet) != len-8) {
diff --git a/src/char/int_quest.c b/src/char/int_quest.c
index dd3d4e1bf..cf9b9c172 100644
--- a/src/char/int_quest.c
+++ b/src/char/int_quest.c
@@ -6,21 +6,20 @@
#include "int_quest.h"
+#include "char/char.h"
+#include "char/inter.h"
+#include "char/mapif.h"
+#include "common/cbasetypes.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#include "char.h"
-#include "inter.h"
-#include "mapif.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/sql.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
struct inter_quest_interface inter_quest_s;
@@ -66,8 +65,9 @@ struct quest *mapif_quests_fromsql(int char_id, int *count)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_quest.quest_id, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &tmp_quest.state, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UINT, &tmp_quest.time, 0, NULL, NULL)
- )
+ ) {
sqlerror = SQL_ERROR;
+ }
StrBuf->Destroy(&buf);
@@ -249,8 +249,10 @@ void mapif_send_quests(int fd, int char_id, struct quest *tmp_questlog, int num_
WFIFOW(fd,2) = num_quests*sizeof(struct quest)+8;
WFIFOL(fd,4) = char_id;
- if (num_quests > 0)
+ if (num_quests > 0) {
+ nullpo_retv(tmp_questlog);
memcpy(WFIFOP(fd,8), tmp_questlog, sizeof(struct quest)*num_quests);
+ }
WFIFOSET(fd,num_quests*sizeof(struct quest)+8);
}
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index db49eb46e..a12d9fe17 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -4,22 +4,22 @@
#define HERCULES_CORE
-#include "../config/core.h" // GP_BOUND_ITEMS
+#include "config/core.h" // GP_BOUND_ITEMS
#include "int_storage.h"
+#include "char/char.h"
+#include "char/inter.h"
+#include "char/mapif.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/sql.h"
+#include "common/strlib.h" // StringBuf
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#include "char.h"
-#include "inter.h"
-#include "mapif.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/sql.h"
-#include "../common/strlib.h" // StringBuf
#define STORAGE_MEMINC 16
@@ -28,6 +28,7 @@ struct inter_storage_interface inter_storage_s;
/// Save storage data to sql
int inter_storage_tosql(int account_id, struct storage_data* p)
{
+ nullpo_ret(p);
chr->memitemdata_to_sql(p->items, MAX_STORAGE, account_id, TABLE_STORAGE);
return 0;
}
@@ -40,6 +41,7 @@ int inter_storage_fromsql(int account_id, struct storage_data* p)
int i;
int j;
+ nullpo_ret(p);
memset(p, 0, sizeof(struct storage_data)); //clean up memory
p->storage_amount = 0;
@@ -82,6 +84,7 @@ int inter_storage_fromsql(int account_id, struct storage_data* p)
/// Save guild_storage data to sql
int inter_storage_guild_storage_tosql(int guild_id, struct guild_storage* p)
{
+ nullpo_ret(p);
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;
@@ -95,6 +98,7 @@ int inter_storage_guild_storage_fromsql(int guild_id, struct guild_storage* p)
int i;
int j;
+ nullpo_ret(p);
memset(p, 0, sizeof(struct guild_storage)); //clean up memory
p->storage_amount = 0;
p->guild_id = guild_id;
@@ -297,7 +301,8 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
for( j = 0; j < MAX_SLOTS; ++j )
SQL->StmtBindColumn(stmt, 10+j, SQLDT_SHORT, &item.card[j], 0, NULL, NULL);
- while( SQL_SUCCESS == SQL->StmtNextRow(stmt) ) {
+ while( SQL_SUCCESS == SQL->StmtNextRow(stmt)) {
+ Assert_retb(i < MAX_INVENTORY);
memcpy(&items[i],&item,sizeof(struct item));
i++;
}
diff --git a/src/char/inter.c b/src/char/inter.c
index eb14f1593..dbb782093 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -6,31 +6,31 @@
#include "inter.h"
+#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/mapif.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#include "char.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 "mapif.h"
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#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
@@ -97,6 +97,7 @@ bool inter_msg_config_read(const char *cfg_name, bool allow_override)
FILE *fp;
static int called = 1;
+ nullpo_ret(cfg_name);
if ((fp = fopen(cfg_name, "r")) == NULL) {
ShowError("Messages file not found: %s\n", cfg_name);
return 1;
@@ -384,6 +385,7 @@ void inter_vmsg_to_fd(int fd, int u_fd, int aid, char* msg, va_list ap)
va_list apcopy;
int len = 1;/* yes we start at 1 */
+ nullpo_retv(msg);
va_copy(apcopy, ap);
len += vsnprintf(msg_out, 512, msg, apcopy);
va_end(apcopy);
@@ -484,6 +486,12 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc
const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate,
int group_id, int logincount, int state)
{
+ nullpo_retv(userid);
+ nullpo_retv(user_pass);
+ nullpo_retv(email);
+ nullpo_retv(last_ip);
+ nullpo_retv(lastlogin);
+ nullpo_retv(birthdate);
if (map_fd <= 0 || !session_isActive(map_fd))
return; // check if we have a valid fd
@@ -495,7 +503,7 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc
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 (*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);
else
@@ -546,6 +554,7 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc
**/
void inter_savereg(int account_id, int char_id, const char *key, unsigned int index, intptr_t val, bool is_string)
{
+ nullpo_retv(key);
/* to login server we go! */
if( key[0] == '#' && key[1] == '#' ) {/* global account reg */
if( session_isValid(chr->login_fd) )
@@ -769,6 +778,7 @@ static int inter_config_read(const char* cfgName)
char line[1024], w1[1024], w2[1024];
FILE* fp;
+ nullpo_retr(1, cfgName);
fp = fopen(cfgName, "r");
if(fp == NULL) {
ShowError("File not found: %s\n", cfgName);
@@ -916,6 +926,8 @@ int mapif_broadcast(unsigned char *mes, int len, unsigned int fontColor, short f
{
unsigned char *buf = (unsigned char*)aMalloc((len)*sizeof(unsigned char));
+ nullpo_ret(mes);
+ Assert_ret(len >= 16);
WBUFW(buf,0) = 0x3800;
WBUFW(buf,2) = len;
WBUFL(buf,4) = fontColor;
@@ -934,8 +946,12 @@ int mapif_broadcast(unsigned char *mes, int len, unsigned int fontColor, short f
int mapif_wis_message(struct WisData *wd)
{
unsigned char buf[2048];
+ nullpo_ret(wd);
//if (wd->len > 2047-56) wd->len = 2047-56; //Force it to fit to avoid crashes. [Skotlex]
- if( wd->len >= sizeof(wd->msg) - 1 ) wd->len = sizeof(wd->msg) - 1;
+ if (wd->len < 0)
+ wd->len = 0;
+ if (wd->len >= sizeof(wd->msg) - 1)
+ wd->len = sizeof(wd->msg) - 1;
WBUFW(buf, 0) = 0x3801;
WBUFW(buf, 2) = 56 +wd->len;
@@ -951,6 +967,7 @@ int mapif_wis_message(struct WisData *wd)
void mapif_wis_response(int fd, unsigned char *src, int flag)
{
unsigned char buf[27];
+ nullpo_retv(src);
WBUFW(buf, 0)=0x3802;
memcpy(WBUFP(buf, 2),src,24);
WBUFB(buf,26)=flag;
@@ -960,6 +977,7 @@ void mapif_wis_response(int fd, unsigned char *src, int flag)
// Wis sending result
int mapif_wis_end(struct WisData *wd, int flag)
{
+ nullpo_ret(wd);
mapif->wis_response(wd->fd, wd->src, flag);
return 0;
}
@@ -968,6 +986,7 @@ int mapif_wis_end(struct WisData *wd, int flag)
// Account registry transfer to map-server
static void mapif_account_reg(int fd, unsigned char *src)
{
+ nullpo_retv(src);
WBUFW(src,0)=0x3804; //NOTE: writing to RFIFO
mapif->sendallwos(fd, src, WBUFW(src,2));
}
@@ -1005,6 +1024,7 @@ int inter_check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap)
{
int64 tick;
struct WisData *wd = DB->data2ptr(data);
+ nullpo_ret(wd);
tick = va_arg(ap, int64);
if (DIFF_TICK(tick, wd->tick) > WISDATA_TTL && wis_delnum < WISDELLIST_MAX)
@@ -1198,9 +1218,9 @@ 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); // 3: char reg
//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); // 2: account reg
//Ask Login Server for Account2 values.
if (RFIFOB(fd,10)) chr->request_accreg2(RFIFOL(fd,2),RFIFOL(fd,6));
return 1;
@@ -1208,6 +1228,7 @@ 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)
{
+ nullpo_retv(name);
WFIFOHEAD(fd, NAME_LENGTH+13);
WFIFOW(fd, 0) = 0x3806;
WFIFOL(fd, 2) = account_id;
diff --git a/src/char/inter.h b/src/char/inter.h
index a58d3b3a9..2e89a685b 100644
--- a/src/char/inter.h
+++ b/src/char/inter.h
@@ -5,9 +5,11 @@
#ifndef CHAR_INTER_H
#define CHAR_INTER_H
-#include "char.h"
-#include "../common/cbasetypes.h"
-#include "../common/sql.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/sql.h"
+
+#include <stdarg.h>
struct accreg;
diff --git a/src/char/loginif.c b/src/char/loginif.c
index 5247e6c3e..881c8f2ac 100644
--- a/src/char/loginif.c
+++ b/src/char/loginif.c
@@ -6,18 +6,19 @@
#include "loginif.h"
+#include "char/char.h"
+#include "char/mapif.h"
+#include "common/cbasetypes.h"
+#include "common/core.h"
+#include "common/db.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/timer.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.
@@ -88,6 +89,7 @@ void do_final_loginif(void)
void loginif_block_account(int account_id, int flag)
{
+ Assert_retv(chr->login_fd != -1);
WFIFOHEAD(chr->login_fd,10);
WFIFOW(chr->login_fd,0) = 0x2724;
WFIFOL(chr->login_fd,2) = account_id;
@@ -97,6 +99,7 @@ void loginif_block_account(int account_id, int flag)
void loginif_ban_account(int account_id, short year, short month, short day, short hour, short minute, short second)
{
+ Assert_retv(chr->login_fd != -1);
WFIFOHEAD(chr->login_fd,18);
WFIFOW(chr->login_fd, 0) = 0x2725;
WFIFOL(chr->login_fd, 2) = account_id;
@@ -111,6 +114,7 @@ void loginif_ban_account(int account_id, short year, short month, short day, sho
void loginif_unban_account(int account_id)
{
+ Assert_retv(chr->login_fd != -1);
WFIFOHEAD(chr->login_fd,6);
WFIFOW(chr->login_fd,0) = 0x272a;
WFIFOL(chr->login_fd,2) = account_id;
@@ -119,6 +123,7 @@ void loginif_unban_account(int account_id)
void loginif_changesex(int account_id)
{
+ Assert_retv(chr->login_fd != -1);
WFIFOHEAD(chr->login_fd,6);
WFIFOW(chr->login_fd,0) = 0x2727;
WFIFOL(chr->login_fd,2) = account_id;
@@ -127,6 +132,8 @@ void loginif_changesex(int account_id)
void loginif_auth(int fd, struct char_session_data* sd, uint32 ipl)
{
+ Assert_retv(chr->login_fd != -1);
+ nullpo_retv(sd);
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;
@@ -140,6 +147,7 @@ void loginif_auth(int fd, struct char_session_data* sd, uint32 ipl)
void loginif_send_users_count(int users)
{
+ Assert_retv(chr->login_fd != -1);
WFIFOHEAD(chr->login_fd,6);
WFIFOW(chr->login_fd,0) = 0x2714;
WFIFOL(chr->login_fd,2) = users;
@@ -148,6 +156,7 @@ void loginif_send_users_count(int users)
void loginif_connect_to_server(void)
{
+ Assert_retv(chr->login_fd != -1);
WFIFOHEAD(chr->login_fd,86);
WFIFOW(chr->login_fd,0) = 0x2710;
memcpy(WFIFOP(chr->login_fd,2), chr->userid, NAME_LENGTH);
diff --git a/src/char/loginif.h b/src/char/loginif.h
index 634bd4b8b..548eaff02 100644
--- a/src/char/loginif.h
+++ b/src/char/loginif.h
@@ -5,7 +5,9 @@
#ifndef CHAR_LOGINIF_H
#define CHAR_LOGINIF_H
-#include "char.h"
+#include "common/cbasetypes.h"
+
+struct char_session_data;
/**
* loginif interface
diff --git a/src/char/mapif.c b/src/char/mapif.c
index 65f2984fd..92506cd49 100644
--- a/src/char/mapif.c
+++ b/src/char/mapif.c
@@ -6,18 +6,18 @@
#include "mapif.h"
-#include <stdlib.h>
+#include "char/char.h"
+#include "char/int_auction.h"
+#include "char/int_guild.h"
+#include "char/int_homun.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"
-#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"
+#include <stdlib.h>
void mapif_ban(int id, unsigned int flag, int status);
void mapif_server_init(int id);
diff --git a/src/char/mapif.h b/src/char/mapif.h
index 528522d1e..6b015d155 100644
--- a/src/char/mapif.h
+++ b/src/char/mapif.h
@@ -5,16 +5,9 @@
#ifndef CHAR_MAPIF_H
#define CHAR_MAPIF_H
-#include "char.h"
+#include "common/cbasetypes.h"
+#include "common/mmo.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;
/**
diff --git a/src/char/pincode.c b/src/char/pincode.c
index b8b30a1b8..5085349cc 100644
--- a/src/char/pincode.c
+++ b/src/char/pincode.c
@@ -6,21 +6,25 @@
#include "pincode.h"
-#include <stdlib.h>
+#include "char/char.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
-#include "char.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"
+#include <stdlib.h>
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(chr->online_char_db, sd->account_id);
+void pincode_handle (int fd, struct char_session_data* sd) {
+ struct online_char_data* character;
+ nullpo_retv(sd);
+ 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{
@@ -44,6 +48,7 @@ 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";
+ nullpo_retv(sd);
safestrncpy(pin, (char*)RFIFOP(fd, 6), sizeof(pin));
pincode->decrypt(sd->pincode_seed, pin);
if( pincode->compare( fd, sd, pin ) ){
@@ -55,6 +60,8 @@ void pincode_check(int fd, struct char_session_data* sd) {
}
int pincode_compare(int fd, struct char_session_data* sd, char* pin) {
+ nullpo_ret(sd);
+ nullpo_ret(pin);
if( strcmp( sd->pincode, pin ) == 0 ){
sd->pincode_try = 0;
return 1;
@@ -70,6 +77,7 @@ int pincode_compare(int fd, struct char_session_data* sd, char* pin) {
void pincode_change(int fd, struct char_session_data* sd) {
char oldpin[5] = "\0\0\0\0", newpin[5] = "\0\0\0\0";
+ nullpo_retv(sd);
safestrncpy(oldpin, (char*)RFIFOP(fd,6), sizeof(oldpin));
pincode->decrypt(sd->pincode_seed,oldpin);
if( !pincode->compare( fd, sd, oldpin ) )
@@ -85,6 +93,7 @@ void pincode_change(int fd, struct char_session_data* sd) {
void pincode_setnew(int fd, struct char_session_data* sd) {
char newpin[5] = "\0\0\0\0";
+ nullpo_retv(sd);
safestrncpy(newpin, (char*)RFIFOP(fd,6), sizeof(newpin));
pincode->decrypt(sd->pincode_seed,newpin);
pincode->update( sd->account_id, newpin );
@@ -102,6 +111,7 @@ void pincode_setnew(int fd, struct char_session_data* sd) {
// 7 = char select window shows a button - client sends 0x8c5
// 8 = pincode was incorrect
void pincode_sendstate(int fd, struct char_session_data* sd, uint16 state) {
+ nullpo_retv(sd);
WFIFOHEAD(fd, 12);
WFIFOW(fd, 0) = 0x8b9;
WFIFOL(fd, 2) = sd->pincode_seed = rnd() % 0xFFFF;
@@ -111,6 +121,8 @@ void pincode_sendstate(int fd, struct char_session_data* sd, uint16 state) {
}
void pincode_notifyLoginPinUpdate(int account_id, char* pin) {
+ nullpo_retv(pin);
+ Assert_retv(chr->login_fd != -1);
WFIFOHEAD(chr->login_fd,11);
WFIFOW(chr->login_fd,0) = 0x2738;
WFIFOL(chr->login_fd,2) = account_id;
@@ -129,6 +141,7 @@ void pincode_decrypt(unsigned int userSeed, char* pin) {
int i;
char tab[10] = {0,1,2,3,4,5,6,7,8,9};
+ nullpo_retv(pin);
for (i = 1; i < 10; i++) {
int pos;
userSeed = pincode->baseSeed + userSeed * pincode->multiplier;
@@ -149,6 +162,8 @@ void pincode_decrypt(unsigned int userSeed, char* pin) {
bool pincode_config_read(char *w1, char *w2) {
+ nullpo_ret(w1);
+ nullpo_ret(w2);
while ( true ) {
if ( strcmpi(w1, "pincode_enabled") == 0 ) {
pincode->enabled = atoi(w2);
diff --git a/src/char/pincode.h b/src/char/pincode.h
index 178d7e427..01f6c7bf9 100644
--- a/src/char/pincode.h
+++ b/src/char/pincode.h
@@ -5,7 +5,9 @@
#ifndef CHAR_PINCODE_H
#define CHAR_PINCODE_H
-#include "char.h"
+#include "common/cbasetypes.h"
+
+struct char_session_data;
enum PincodeResponseCode {
PINCODE_OK = 0,
diff --git a/src/common/HPM.c b/src/common/HPM.c
index 6e73d1b2a..cdd9bb769 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -3,28 +3,29 @@
#define HERCULES_CORE
-#include "../config/core.h" // CONSOLE_INPUT
+#include "config/core.h" // CONSOLE_INPUT
#include "HPM.h"
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/console.h"
+#include "common/core.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+#include "common/sysinfo.h"
+#include "common/timer.h"
+#include "common/utils.h"
+#include "common/nullpo.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "../common/cbasetypes.h"
-#include "../common/conf.h"
-#include "../common/console.h"
-#include "../common/core.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/sql.h"
-#include "../common/strlib.h"
-#include "../common/sysinfo.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-#include "../common/nullpo.h"
-
#ifndef WIN32
# include <unistd.h>
#endif
@@ -114,9 +115,8 @@ bool hplugin_populate(struct hplugin *plugin, const char *filename) {
for(i = 0; i < length; i++) {
void **Link;
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);
- HPM->unload(plugin);
- return false;
+ ShowFatalError("HPM:plugin_load: failed to retrieve '%s' for '"CL_WHITE"%s"CL_RESET"'!\n", ToLink[i].name, filename);
+ exit(EXIT_FAILURE);
}
*Link = ToLink[i].Ref;
}
@@ -144,15 +144,13 @@ struct hplugin *hplugin_load(const char* filename) {
if (!(plugin->dll = plugin_open(filename))) {
char buf[1024];
- ShowWarning("HPM:plugin_load: failed to load '"CL_WHITE"%s"CL_RESET"' (error: %s), skipping...\n", filename, plugin_geterror(buf));
- HPM->unload(plugin);
- return NULL;
+ ShowFatalError("HPM:plugin_load: failed to load '"CL_WHITE"%s"CL_RESET"' (error: %s)!\n", filename, plugin_geterror(buf));
+ exit(EXIT_FAILURE);
}
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;
+ ShowFatalError("HPM:plugin_load: failed to retrieve 'plugin_info' for '"CL_WHITE"%s"CL_RESET"'!\n", filename);
+ exit(EXIT_FAILURE);
}
if( !(info->type & SERVER_TYPE) ) {
@@ -161,40 +159,35 @@ struct hplugin *hplugin_load(const char* filename) {
}
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;
+ ShowFatalError("HPM:plugin_load: '"CL_WHITE"%s"CL_RESET"' incompatible version '%s' -> '%s'!\n", filename, info->req_version, HPM_VERSION);
+ exit(EXIT_FAILURE);
}
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;
+ ShowFatalError("HPM:plugin_load: failed to retrieve 'import_symbol' for '"CL_WHITE"%s"CL_RESET"'!\n", filename);
+ exit(EXIT_FAILURE);
}
*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;
+ ShowFatalError("HPM:plugin_load: failed to retrieve 'mysql_handle' for '"CL_WHITE"%s"CL_RESET"'!\n", filename);
+ exit(EXIT_FAILURE);
}
*sql_handle = HPM->import_symbol("sql_handle",plugin->idx);
if( !( HPMi = plugin_import(plugin->dll, "HPMi",struct HPMi_interface **) ) ) {
- ShowWarning("HPM:plugin_load: failed to retrieve 'HPMi' for '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename);
- HPM->unload(plugin);
- return NULL;
+ ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMi' for '"CL_WHITE"%s"CL_RESET"'!\n", filename);
+ exit(EXIT_FAILURE);
}
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;
+ ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMi_s' for '"CL_WHITE"%s"CL_RESET"'!\n", filename);
+ exit(EXIT_FAILURE);
}
plugin->hpi = *HPMi;
@@ -214,37 +207,32 @@ struct hplugin *hplugin_load(const char* filename) {
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;
+ ShowWarning("HPM:plugin_load: no events found for '"CL_WHITE"%s"CL_RESET"'!\n", filename);
+ exit(EXIT_FAILURE);
}
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;
+ ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMDataCheckLen' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h!\n", filename);
+ exit(EXIT_FAILURE);
}
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;
+ ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMDataCheckVer' for '"CL_WHITE"%s"CL_RESET"', most likely an outdated plugin!\n", filename);
+ exit(EXIT_FAILURE);
}
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;
+ ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMDataCheck' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h!\n", filename);
+ exit(EXIT_FAILURE);
}
// 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;
+ ShowFatalError("HPM:plugin_load: '"CL_WHITE"%s"CL_RESET"' failed DataCheck, out of sync from the core (recompile plugin)!\n", filename);
+ exit(EXIT_FAILURE);
}
/* id */
@@ -264,6 +252,8 @@ struct hplugin *hplugin_load(const char* filename) {
if( HPM->load_sub )
HPM->load_sub(plugin);
+ ShowStatus("HPM: Loaded plugin '"CL_WHITE"%s"CL_RESET"' (%s).\n", plugin->info->name, plugin->info->version);
+
return plugin;
}
@@ -351,11 +341,14 @@ void hplugins_config_read(void) {
struct hplugin *plugin;
snprintf(filename, 60, "plugins/%s%s", hooking_plugin_name, DLL_EXT);
if ((plugin = HPM->load(filename))) {
- bool (*func)(bool *fr);
+ const char * (*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 *)))
+ if ((func = plugin_import(plugin->dll, "Hooked",const char * (*)(bool *)))
&& (addhook_sub = plugin_import(plugin->dll, "HPM_Plugin_AddHook",bool (*)(enum HPluginHookType, const char *, void *, unsigned int)))) {
- if (func(&HPM->force_return)) {
+ const char *failed = func(&HPM->force_return);
+ if (failed) {
+ ShowError("HPM: failed to retrieve '%s' for '"CL_WHITE"%s"CL_RESET"'!\n", failed, plugin_name);
+ } else {
HPM->hooking = true;
HPM->addhook_sub = addhook_sub;
}
diff --git a/src/common/HPM.h b/src/common/HPM.h
index e99b0f2ae..1358f19dc 100644
--- a/src/common/HPM.h
+++ b/src/common/HPM.h
@@ -8,8 +8,8 @@
#error You should never include HPM.h from a plugin.
#endif
-#include "../common/HPMi.h"
-#include "../common/cbasetypes.h"
+#include "common/HPMi.h"
+#include "common/cbasetypes.h"
#ifdef WIN32
#ifndef WIN32_LEAN_AND_MEAN
diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h
index 40c949d53..a27dbeb07 100644
--- a/src/common/HPMDataCheck.h
+++ b/src/common/HPMDataCheck.h
@@ -9,7 +9,11 @@
HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
#ifdef CHAR_CHAR_H
+ { "char_auth_node", sizeof(struct char_auth_node), SERVER_TYPE_CHAR },
{ "char_interface", sizeof(struct char_interface), SERVER_TYPE_CHAR },
+ { "char_session_data", sizeof(struct char_session_data), SERVER_TYPE_CHAR },
+ { "mmo_map_server", sizeof(struct mmo_map_server), SERVER_TYPE_CHAR },
+ { "online_char_data", sizeof(struct online_char_data), SERVER_TYPE_CHAR },
#else
#define CHAR_CHAR_H
#endif // CHAR_CHAR_H
@@ -94,10 +98,24 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
#else
#define COMMON_CONF_H
#endif // COMMON_CONF_H
+ #ifdef COMMON_CONSOLE_H
+ { "CParseEntry", sizeof(struct CParseEntry), SERVER_TYPE_ALL },
+ { "console_interface", sizeof(struct console_interface), SERVER_TYPE_ALL },
+ #else
+ #define COMMON_CONSOLE_H
+ #endif // COMMON_CONSOLE_H
+ #ifdef COMMON_CORE_H
+ { "CmdlineArgData", sizeof(struct CmdlineArgData), SERVER_TYPE_ALL },
+ { "cmdline_interface", sizeof(struct cmdline_interface), SERVER_TYPE_ALL },
+ #else
+ #define COMMON_CORE_H
+ #endif // COMMON_CORE_H
#ifdef COMMON_DB_H
{ "DBData", sizeof(struct DBData), SERVER_TYPE_ALL },
{ "DBIterator", sizeof(struct DBIterator), SERVER_TYPE_ALL },
{ "DBMap", sizeof(struct DBMap), SERVER_TYPE_ALL },
+ { "db_interface", sizeof(struct db_interface), SERVER_TYPE_ALL },
+ { "linkdb_node", sizeof(struct linkdb_node), SERVER_TYPE_ALL },
#else
#define COMMON_DB_H
#endif // COMMON_DB_H
@@ -111,24 +129,85 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
#else
#define COMMON_ERS_H
#endif // COMMON_ERS_H
+ #ifdef COMMON_HPMI_H
+ { "HPMi_interface", sizeof(struct HPMi_interface), SERVER_TYPE_ALL },
+ { "hplugin_info", sizeof(struct hplugin_info), SERVER_TYPE_ALL },
+ { "s_HPMDataCheck", sizeof(struct s_HPMDataCheck), SERVER_TYPE_ALL },
+ #else
+ #define COMMON_HPMI_H
+ #endif // COMMON_HPMI_H
+ #ifdef COMMON_MALLOC_H
+ { "malloc_interface", sizeof(struct malloc_interface), SERVER_TYPE_ALL },
+ #else
+ #define COMMON_MALLOC_H
+ #endif // COMMON_MALLOC_H
#ifdef COMMON_MAPINDEX_H
{ "mapindex_interface", sizeof(struct mapindex_interface), SERVER_TYPE_ALL },
#else
#define COMMON_MAPINDEX_H
#endif // COMMON_MAPINDEX_H
#ifdef COMMON_MMO_H
+ { "auction_data", sizeof(struct auction_data), SERVER_TYPE_ALL },
+ { "fame_list", sizeof(struct fame_list), SERVER_TYPE_ALL },
+ { "guild", sizeof(struct guild), SERVER_TYPE_ALL },
+ { "guild_alliance", sizeof(struct guild_alliance), SERVER_TYPE_ALL },
+ { "guild_castle", sizeof(struct guild_castle), SERVER_TYPE_ALL },
+ { "guild_expulsion", sizeof(struct guild_expulsion), SERVER_TYPE_ALL },
+ { "guild_member", sizeof(struct guild_member), SERVER_TYPE_ALL },
+ { "guild_position", sizeof(struct guild_position), SERVER_TYPE_ALL },
+ { "guild_skill", sizeof(struct guild_skill), SERVER_TYPE_ALL },
+ { "guild_storage", sizeof(struct guild_storage), SERVER_TYPE_ALL },
+ { "hotkey", sizeof(struct hotkey), SERVER_TYPE_ALL },
+ { "item", sizeof(struct item), SERVER_TYPE_ALL },
+ { "mail_data", sizeof(struct mail_data), SERVER_TYPE_ALL },
+ { "mail_message", sizeof(struct mail_message), SERVER_TYPE_ALL },
+ { "mmo_charstatus", sizeof(struct mmo_charstatus), SERVER_TYPE_ALL },
+ { "party", sizeof(struct party), SERVER_TYPE_ALL },
+ { "party_member", sizeof(struct party_member), SERVER_TYPE_ALL },
+ { "point", sizeof(struct point), SERVER_TYPE_ALL },
{ "quest", sizeof(struct quest), SERVER_TYPE_ALL },
+ { "s_elemental", sizeof(struct s_elemental), SERVER_TYPE_ALL },
+ { "s_friend", sizeof(struct s_friend), SERVER_TYPE_ALL },
+ { "s_homunculus", sizeof(struct s_homunculus), SERVER_TYPE_ALL },
+ { "s_mercenary", sizeof(struct s_mercenary), SERVER_TYPE_ALL },
+ { "s_pet", sizeof(struct s_pet), SERVER_TYPE_ALL },
+ { "s_skill", sizeof(struct s_skill), SERVER_TYPE_ALL },
+ { "script_reg_num", sizeof(struct script_reg_num), SERVER_TYPE_ALL },
+ { "script_reg_state", sizeof(struct script_reg_state), SERVER_TYPE_ALL },
+ { "script_reg_str", sizeof(struct script_reg_str), SERVER_TYPE_ALL },
+ { "status_change_data", sizeof(struct status_change_data), SERVER_TYPE_ALL },
+ { "storage_data", sizeof(struct storage_data), SERVER_TYPE_ALL },
#else
#define COMMON_MMO_H
#endif // COMMON_MMO_H
+ #ifdef COMMON_NULLPO_H
+ { "nullpo_interface", sizeof(struct nullpo_interface), SERVER_TYPE_ALL },
+ #else
+ #define COMMON_NULLPO_H
+ #endif // COMMON_NULLPO_H
#ifdef COMMON_SOCKET_H
+ { "hSockOpt", sizeof(struct hSockOpt), SERVER_TYPE_ALL },
+ { "socket_data", sizeof(struct socket_data), SERVER_TYPE_ALL },
{ "socket_interface", sizeof(struct socket_interface), SERVER_TYPE_ALL },
#else
#define COMMON_SOCKET_H
#endif // COMMON_SOCKET_H
+ #ifdef COMMON_SPINLOCK_H
+ { "SPIN_LOCK", sizeof(struct SPIN_LOCK), SERVER_TYPE_ALL },
+ #else
+ #define COMMON_SPINLOCK_H
+ #endif // COMMON_SPINLOCK_H
+ #ifdef COMMON_SQL_H
+ { "sql_interface", sizeof(struct sql_interface), SERVER_TYPE_ALL },
+ #else
+ #define COMMON_SQL_H
+ #endif // COMMON_SQL_H
#ifdef COMMON_STRLIB_H
{ "StringBuf", sizeof(struct StringBuf), SERVER_TYPE_ALL },
{ "s_svstate", sizeof(struct s_svstate), SERVER_TYPE_ALL },
+ { "stringbuf_interface", sizeof(struct stringbuf_interface), SERVER_TYPE_ALL },
+ { "strlib_interface", sizeof(struct strlib_interface), SERVER_TYPE_ALL },
+ { "sv_interface", sizeof(struct sv_interface), SERVER_TYPE_ALL },
#else
#define COMMON_STRLIB_H
#endif // COMMON_STRLIB_H
@@ -137,96 +216,446 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
#else
#define COMMON_SYSINFO_H
#endif // COMMON_SYSINFO_H
+ #ifdef COMMON_TIMER_H
+ { "TimerData", sizeof(struct TimerData), SERVER_TYPE_ALL },
+ { "timer_interface", sizeof(struct timer_interface), SERVER_TYPE_ALL },
+ #else
+ #define COMMON_TIMER_H
+ #endif // COMMON_TIMER_H
+ #ifdef COMMON_UTILS_H
+ { "HCache_interface", sizeof(struct HCache_interface), SERVER_TYPE_ALL },
+ #else
+ #define COMMON_UTILS_H
+ #endif // COMMON_UTILS_H
+ #ifdef LOGIN_ACCOUNT_H
+ { "Account_engine", sizeof(struct Account_engine), SERVER_TYPE_LOGIN },
+ { "AccountDB", sizeof(struct AccountDB), SERVER_TYPE_LOGIN },
+ { "AccountDBIterator", sizeof(struct AccountDBIterator), SERVER_TYPE_LOGIN },
+ { "mmo_account", sizeof(struct mmo_account), SERVER_TYPE_LOGIN },
+ #else
+ #define LOGIN_ACCOUNT_H
+ #endif // LOGIN_ACCOUNT_H
#ifdef LOGIN_LOGIN_H
+ { "Login_Config", sizeof(struct Login_Config), SERVER_TYPE_LOGIN },
+ { "client_hash_node", sizeof(struct client_hash_node), SERVER_TYPE_LOGIN },
+ { "login_auth_node", sizeof(struct login_auth_node), SERVER_TYPE_LOGIN },
{ "login_interface", sizeof(struct login_interface), SERVER_TYPE_LOGIN },
+ { "login_session_data", sizeof(struct login_session_data), SERVER_TYPE_LOGIN },
+ { "mmo_char_server", sizeof(struct mmo_char_server), SERVER_TYPE_LOGIN },
+ { "online_login_data", sizeof(struct online_login_data), SERVER_TYPE_LOGIN },
#else
#define LOGIN_LOGIN_H
#endif // LOGIN_LOGIN_H
#ifdef MAP_ATCOMMAND_H
{ "AliasInfo", sizeof(struct AliasInfo), SERVER_TYPE_MAP },
+ { "AtCommandInfo", sizeof(struct AtCommandInfo), SERVER_TYPE_MAP },
+ { "atcmd_binding_data", sizeof(struct atcmd_binding_data), SERVER_TYPE_MAP },
{ "atcommand_interface", sizeof(struct atcommand_interface), SERVER_TYPE_MAP },
#else
#define MAP_ATCOMMAND_H
#endif // MAP_ATCOMMAND_H
+ #ifdef MAP_BATTLEGROUND_H
+ { "battleground_data", sizeof(struct battleground_data), SERVER_TYPE_MAP },
+ { "battleground_interface", sizeof(struct battleground_interface), SERVER_TYPE_MAP },
+ { "battleground_member_data", sizeof(struct battleground_member_data), SERVER_TYPE_MAP },
+ { "bg_arena", sizeof(struct bg_arena), SERVER_TYPE_MAP },
+ #else
+ #define MAP_BATTLEGROUND_H
+ #endif // MAP_BATTLEGROUND_H
#ifdef MAP_BATTLE_H
+ { "Battle_Config", sizeof(struct Battle_Config), SERVER_TYPE_MAP },
{ "Damage", sizeof(struct Damage), SERVER_TYPE_MAP },
{ "battle_interface", sizeof(struct battle_interface), SERVER_TYPE_MAP },
+ { "delay_damage", sizeof(struct delay_damage), SERVER_TYPE_MAP },
#else
#define MAP_BATTLE_H
#endif // MAP_BATTLE_H
#ifdef MAP_BUYINGSTORE_H
{ "buyingstore_interface", sizeof(struct buyingstore_interface), SERVER_TYPE_MAP },
+ { "s_buyingstore", sizeof(struct s_buyingstore), 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_CHANNEL_H
{ "Channel_Config", sizeof(struct Channel_Config), SERVER_TYPE_MAP },
+ { "channel_ban_entry", sizeof(struct channel_ban_entry), SERVER_TYPE_MAP },
+ { "channel_data", sizeof(struct channel_data), SERVER_TYPE_MAP },
+ { "channel_interface", sizeof(struct channel_interface), SERVER_TYPE_MAP },
#else
#define MAP_CHANNEL_H
#endif // MAP_CHANNEL_H
+ #ifdef MAP_CHAT_H
+ { "chat_data", sizeof(struct chat_data), SERVER_TYPE_MAP },
+ { "chat_interface", sizeof(struct chat_interface), SERVER_TYPE_MAP },
+ #else
+ #define MAP_CHAT_H
+ #endif // MAP_CHAT_H
#ifdef MAP_CHRIF_H
{ "auth_node", sizeof(struct auth_node), SERVER_TYPE_MAP },
+ { "chrif_interface", sizeof(struct chrif_interface), SERVER_TYPE_MAP },
#else
#define MAP_CHRIF_H
#endif // MAP_CHRIF_H
#ifdef MAP_CLIF_H
+ { "cdelayed_damage", sizeof(struct cdelayed_damage), SERVER_TYPE_MAP },
{ "clif_interface", sizeof(struct clif_interface), SERVER_TYPE_MAP },
+ { "hCSData", sizeof(struct hCSData), SERVER_TYPE_MAP },
+ { "merge_item", sizeof(struct merge_item), SERVER_TYPE_MAP },
+ { "s_packet_db", sizeof(struct s_packet_db), SERVER_TYPE_MAP },
#else
#define MAP_CLIF_H
#endif // MAP_CLIF_H
+ #ifdef MAP_DUEL_H
+ { "duel", sizeof(struct duel), SERVER_TYPE_MAP },
+ { "duel_interface", sizeof(struct duel_interface), SERVER_TYPE_MAP },
+ #else
+ #define MAP_DUEL_H
+ #endif // MAP_DUEL_H
#ifdef MAP_ELEMENTAL_H
+ { "elemental_data", sizeof(struct elemental_data), SERVER_TYPE_MAP },
+ { "elemental_interface", sizeof(struct elemental_interface), SERVER_TYPE_MAP },
{ "elemental_skill", sizeof(struct elemental_skill), SERVER_TYPE_MAP },
+ { "s_elemental_db", sizeof(struct s_elemental_db), SERVER_TYPE_MAP },
#else
#define MAP_ELEMENTAL_H
#endif // MAP_ELEMENTAL_H
#ifdef MAP_GUILD_H
{ "eventlist", sizeof(struct eventlist), SERVER_TYPE_MAP },
{ "guardian_data", sizeof(struct guardian_data), SERVER_TYPE_MAP },
+ { "guild_expcache", sizeof(struct guild_expcache), SERVER_TYPE_MAP },
+ { "guild_interface", sizeof(struct guild_interface), SERVER_TYPE_MAP },
+ { "s_guild_skill_tree", sizeof(struct s_guild_skill_tree), SERVER_TYPE_MAP },
#else
#define MAP_GUILD_H
#endif // MAP_GUILD_H
+ #ifdef MAP_HOMUNCULUS_H
+ { "h_stats", sizeof(struct h_stats), SERVER_TYPE_MAP },
+ { "homun_data", sizeof(struct homun_data), SERVER_TYPE_MAP },
+ { "homun_dbs", sizeof(struct homun_dbs), SERVER_TYPE_MAP },
+ { "homun_skill_tree_entry", sizeof(struct homun_skill_tree_entry), SERVER_TYPE_MAP },
+ { "homunculus_interface", sizeof(struct homunculus_interface), SERVER_TYPE_MAP },
+ { "s_homunculus_db", sizeof(struct s_homunculus_db), SERVER_TYPE_MAP },
+ #else
+ #define MAP_HOMUNCULUS_H
+ #endif // MAP_HOMUNCULUS_H
+ #ifdef MAP_INSTANCE_H
+ { "instance_data", sizeof(struct instance_data), SERVER_TYPE_MAP },
+ { "instance_interface", sizeof(struct instance_interface), SERVER_TYPE_MAP },
+ #else
+ #define MAP_INSTANCE_H
+ #endif // MAP_INSTANCE_H
+ #ifdef MAP_INTIF_H
+ { "intif_interface", sizeof(struct intif_interface), SERVER_TYPE_MAP },
+ #else
+ #define MAP_INTIF_H
+ #endif // MAP_INTIF_H
+ #ifdef MAP_IRC_BOT_H
+ { "irc_bot_interface", sizeof(struct irc_bot_interface), SERVER_TYPE_MAP },
+ { "irc_func", sizeof(struct irc_func), SERVER_TYPE_MAP },
+ #else
+ #define MAP_IRC_BOT_H
+ #endif // MAP_IRC_BOT_H
+ #ifdef MAP_ITEMDB_H
+ { "item_chain", sizeof(struct item_chain), SERVER_TYPE_MAP },
+ { "item_chain_entry", sizeof(struct item_chain_entry), SERVER_TYPE_MAP },
+ { "item_combo", sizeof(struct item_combo), SERVER_TYPE_MAP },
+ { "item_data", sizeof(struct item_data), SERVER_TYPE_MAP },
+ { "item_group", sizeof(struct item_group), SERVER_TYPE_MAP },
+ { "item_package", sizeof(struct item_package), SERVER_TYPE_MAP },
+ { "item_package_must_entry", sizeof(struct item_package_must_entry), SERVER_TYPE_MAP },
+ { "item_package_rand_entry", sizeof(struct item_package_rand_entry), SERVER_TYPE_MAP },
+ { "item_package_rand_group", sizeof(struct item_package_rand_group), SERVER_TYPE_MAP },
+ { "itemdb_interface", sizeof(struct itemdb_interface), SERVER_TYPE_MAP },
+ #else
+ #define MAP_ITEMDB_H
+ #endif // MAP_ITEMDB_H
+ #ifdef MAP_LOG_H
+ { "log_interface", sizeof(struct log_interface), SERVER_TYPE_MAP },
+ #else
+ #define MAP_LOG_H
+ #endif // MAP_LOG_H
+ #ifdef MAP_MAIL_H
+ { "mail_interface", sizeof(struct mail_interface), SERVER_TYPE_MAP },
+ #else
+ #define MAP_MAIL_H
+ #endif // MAP_MAIL_H
#ifdef MAP_MAPREG_H
+ { "mapreg_interface", sizeof(struct mapreg_interface), SERVER_TYPE_MAP },
{ "mapreg_save", sizeof(struct mapreg_save), SERVER_TYPE_MAP },
#else
#define MAP_MAPREG_H
#endif // MAP_MAPREG_H
#ifdef MAP_MAP_H
+ { "block_list", sizeof(struct block_list), SERVER_TYPE_MAP },
+ { "charid2nick", sizeof(struct charid2nick), SERVER_TYPE_MAP },
+ { "charid_request", sizeof(struct charid_request), SERVER_TYPE_MAP },
+ { "flooritem_data", sizeof(struct flooritem_data), SERVER_TYPE_MAP },
+ { "iwall_data", sizeof(struct iwall_data), SERVER_TYPE_MAP },
+ { "map_cache_main_header", sizeof(struct map_cache_main_header), SERVER_TYPE_MAP },
+ { "map_cache_map_info", sizeof(struct map_cache_map_info), SERVER_TYPE_MAP },
+ { "map_data", sizeof(struct map_data), SERVER_TYPE_MAP },
{ "map_data_other_server", sizeof(struct map_data_other_server), SERVER_TYPE_MAP },
+ { "map_drop_list", sizeof(struct map_drop_list), SERVER_TYPE_MAP },
+ { "map_interface", sizeof(struct map_interface), SERVER_TYPE_MAP },
+ { "map_zone_data", sizeof(struct map_zone_data), SERVER_TYPE_MAP },
+ { "map_zone_disabled_command_entry", sizeof(struct map_zone_disabled_command_entry), SERVER_TYPE_MAP },
+ { "map_zone_disabled_skill_entry", sizeof(struct map_zone_disabled_skill_entry), SERVER_TYPE_MAP },
+ { "map_zone_skill_damage_cap_entry", sizeof(struct map_zone_skill_damage_cap_entry), SERVER_TYPE_MAP },
+ { "mapcell", sizeof(struct mapcell), SERVER_TYPE_MAP },
+ { "mapflag_skill_adjust", sizeof(struct mapflag_skill_adjust), SERVER_TYPE_MAP },
+ { "mapit_interface", sizeof(struct mapit_interface), SERVER_TYPE_MAP },
+ { "questinfo", sizeof(struct questinfo), SERVER_TYPE_MAP },
+ { "spawn_data", sizeof(struct spawn_data), SERVER_TYPE_MAP },
#else
#define MAP_MAP_H
#endif // MAP_MAP_H
+ #ifdef MAP_MERCENARY_H
+ { "mercenary_data", sizeof(struct mercenary_data), SERVER_TYPE_MAP },
+ { "mercenary_interface", sizeof(struct mercenary_interface), SERVER_TYPE_MAP },
+ { "s_mercenary_db", sizeof(struct s_mercenary_db), SERVER_TYPE_MAP },
+ #else
+ #define MAP_MERCENARY_H
+ #endif // MAP_MERCENARY_H
+ #ifdef MAP_MOB_H
+ { "item_drop", sizeof(struct item_drop), SERVER_TYPE_MAP },
+ { "item_drop_list", sizeof(struct item_drop_list), SERVER_TYPE_MAP },
+ { "mob_chat", sizeof(struct mob_chat), SERVER_TYPE_MAP },
+ { "mob_data", sizeof(struct mob_data), SERVER_TYPE_MAP },
+ { "mob_db", sizeof(struct mob_db), SERVER_TYPE_MAP },
+ { "mob_interface", sizeof(struct mob_interface), SERVER_TYPE_MAP },
+ { "mob_skill", sizeof(struct mob_skill), SERVER_TYPE_MAP },
+ { "spawn_info", sizeof(struct spawn_info), SERVER_TYPE_MAP },
+ #else
+ #define MAP_MOB_H
+ #endif // MAP_MOB_H
+ #ifdef MAP_NPC_H
+ { "event_data", sizeof(struct event_data), SERVER_TYPE_MAP },
+ { "npc_data", sizeof(struct npc_data), SERVER_TYPE_MAP },
+ { "npc_interface", sizeof(struct npc_interface), SERVER_TYPE_MAP },
+ { "npc_item_list", sizeof(struct npc_item_list), SERVER_TYPE_MAP },
+ { "npc_label_list", sizeof(struct npc_label_list), SERVER_TYPE_MAP },
+ { "npc_path_data", sizeof(struct npc_path_data), SERVER_TYPE_MAP },
+ { "npc_shop_data", sizeof(struct npc_shop_data), SERVER_TYPE_MAP },
+ { "npc_src_list", sizeof(struct npc_src_list), SERVER_TYPE_MAP },
+ { "npc_timerevent_list", sizeof(struct npc_timerevent_list), SERVER_TYPE_MAP },
+ #else
+ #define MAP_NPC_H
+ #endif // MAP_NPC_H
#ifdef MAP_PACKETS_STRUCT_H
+ { "EQUIPITEM_INFO", sizeof(struct EQUIPITEM_INFO), SERVER_TYPE_MAP },
{ "EQUIPSLOTINFO", sizeof(struct EQUIPSLOTINFO), SERVER_TYPE_MAP },
+ { "NORMALITEM_INFO", sizeof(struct NORMALITEM_INFO), SERVER_TYPE_MAP },
+ { "packet_additem", sizeof(struct packet_additem), SERVER_TYPE_MAP },
+ { "packet_authok", sizeof(struct packet_authok), SERVER_TYPE_MAP },
+ { "packet_banking_check", sizeof(struct packet_banking_check), SERVER_TYPE_MAP },
+ { "packet_banking_deposit_ack", sizeof(struct packet_banking_deposit_ack), SERVER_TYPE_MAP },
+ { "packet_banking_deposit_req", sizeof(struct packet_banking_deposit_req), SERVER_TYPE_MAP },
+ { "packet_banking_withdraw_ack", sizeof(struct packet_banking_withdraw_ack), SERVER_TYPE_MAP },
+ { "packet_banking_withdraw_req", sizeof(struct packet_banking_withdraw_req), SERVER_TYPE_MAP },
+ { "packet_bgqueue_ack", sizeof(struct packet_bgqueue_ack), SERVER_TYPE_MAP },
+ { "packet_bgqueue_battlebegin_ack", sizeof(struct packet_bgqueue_battlebegin_ack), SERVER_TYPE_MAP },
+ { "packet_bgqueue_battlebegins", sizeof(struct packet_bgqueue_battlebegins), SERVER_TYPE_MAP },
+ { "packet_bgqueue_checkstate", sizeof(struct packet_bgqueue_checkstate), SERVER_TYPE_MAP },
+ { "packet_bgqueue_notice_delete", sizeof(struct packet_bgqueue_notice_delete), SERVER_TYPE_MAP },
+ { "packet_bgqueue_notify_entry", sizeof(struct packet_bgqueue_notify_entry), SERVER_TYPE_MAP },
+ { "packet_bgqueue_register", sizeof(struct packet_bgqueue_register), SERVER_TYPE_MAP },
+ { "packet_bgqueue_revoke_req", sizeof(struct packet_bgqueue_revoke_req), SERVER_TYPE_MAP },
+ { "packet_bgqueue_update_info", sizeof(struct packet_bgqueue_update_info), SERVER_TYPE_MAP },
+ { "packet_cart_additem_ack", sizeof(struct packet_cart_additem_ack), SERVER_TYPE_MAP },
+ { "packet_damage", sizeof(struct packet_damage), SERVER_TYPE_MAP },
+ { "packet_dropflooritem", sizeof(struct packet_dropflooritem), SERVER_TYPE_MAP },
+ { "packet_equip_item", sizeof(struct packet_equip_item), SERVER_TYPE_MAP },
+ { "packet_equipitem_ack", sizeof(struct packet_equipitem_ack), SERVER_TYPE_MAP },
+ { "packet_gm_monster_item", sizeof(struct packet_gm_monster_item), SERVER_TYPE_MAP },
+ { "packet_graffiti_entry", sizeof(struct packet_graffiti_entry), SERVER_TYPE_MAP },
+ { "packet_idle_unit", sizeof(struct packet_idle_unit), SERVER_TYPE_MAP },
+ { "packet_idle_unit2", sizeof(struct packet_idle_unit2), SERVER_TYPE_MAP },
+ { "packet_item_drop_announce", sizeof(struct packet_item_drop_announce), SERVER_TYPE_MAP },
+ { "packet_itemlist_equip", sizeof(struct packet_itemlist_equip), SERVER_TYPE_MAP },
+ { "packet_itemlist_normal", sizeof(struct packet_itemlist_normal), SERVER_TYPE_MAP },
+ { "packet_maptypeproperty2", sizeof(struct packet_maptypeproperty2), SERVER_TYPE_MAP },
+ { "packet_monster_hp", sizeof(struct packet_monster_hp), SERVER_TYPE_MAP },
+ { "packet_notify_bounditem", sizeof(struct packet_notify_bounditem), SERVER_TYPE_MAP },
+ { "packet_npc_market_open", sizeof(struct packet_npc_market_open), SERVER_TYPE_MAP },
+ { "packet_npc_market_purchase", sizeof(struct packet_npc_market_purchase), SERVER_TYPE_MAP },
+ { "packet_npc_market_result_ack", sizeof(struct packet_npc_market_result_ack), SERVER_TYPE_MAP },
+ { "packet_package_item_announce", sizeof(struct packet_package_item_announce), SERVER_TYPE_MAP },
+ { "packet_party_leader_changed", sizeof(struct packet_party_leader_changed), SERVER_TYPE_MAP },
+ { "packet_roulette_close_ack", sizeof(struct packet_roulette_close_ack), SERVER_TYPE_MAP },
+ { "packet_roulette_generate_ack", sizeof(struct packet_roulette_generate_ack), SERVER_TYPE_MAP },
+ { "packet_roulette_info_ack", sizeof(struct packet_roulette_info_ack), SERVER_TYPE_MAP },
+ { "packet_roulette_itemrecv_ack", sizeof(struct packet_roulette_itemrecv_ack), SERVER_TYPE_MAP },
+ { "packet_roulette_itemrecv_req", sizeof(struct packet_roulette_itemrecv_req), SERVER_TYPE_MAP },
+ { "packet_roulette_open_ack", sizeof(struct packet_roulette_open_ack), SERVER_TYPE_MAP },
+ { "packet_sc_notick", sizeof(struct packet_sc_notick), SERVER_TYPE_MAP },
+ { "packet_script_clear", sizeof(struct packet_script_clear), SERVER_TYPE_MAP },
+ { "packet_skill_entry", sizeof(struct packet_skill_entry), SERVER_TYPE_MAP },
+ { "packet_spawn_unit", sizeof(struct packet_spawn_unit), SERVER_TYPE_MAP },
+ { "packet_spawn_unit2", sizeof(struct packet_spawn_unit2), SERVER_TYPE_MAP },
+ { "packet_status_change", sizeof(struct packet_status_change), SERVER_TYPE_MAP },
+ { "packet_status_change2", sizeof(struct packet_status_change2), SERVER_TYPE_MAP },
+ { "packet_status_change_end", sizeof(struct packet_status_change_end), SERVER_TYPE_MAP },
+ { "packet_storelist_equip", sizeof(struct packet_storelist_equip), SERVER_TYPE_MAP },
+ { "packet_storelist_normal", sizeof(struct packet_storelist_normal), SERVER_TYPE_MAP },
+ { "packet_unequipitem_ack", sizeof(struct packet_unequipitem_ack), SERVER_TYPE_MAP },
+ { "packet_unit_walking", sizeof(struct packet_unit_walking), SERVER_TYPE_MAP },
+ { "packet_viewequip_ack", sizeof(struct packet_viewequip_ack), SERVER_TYPE_MAP },
+ { "packet_wis_end", sizeof(struct packet_wis_end), SERVER_TYPE_MAP },
#else
#define MAP_PACKETS_STRUCT_H
#endif // MAP_PACKETS_STRUCT_H
+ #ifdef MAP_PARTY_H
+ { "party_booking_ad_info", sizeof(struct party_booking_ad_info), SERVER_TYPE_MAP },
+ { "party_booking_detail", sizeof(struct party_booking_detail), SERVER_TYPE_MAP },
+ { "party_data", sizeof(struct party_data), SERVER_TYPE_MAP },
+ { "party_interface", sizeof(struct party_interface), SERVER_TYPE_MAP },
+ { "party_member_data", sizeof(struct party_member_data), SERVER_TYPE_MAP },
+ #else
+ #define MAP_PARTY_H
+ #endif // MAP_PARTY_H
+ #ifdef MAP_PATH_H
+ { "path_interface", sizeof(struct path_interface), SERVER_TYPE_MAP },
+ { "shootpath_data", sizeof(struct shootpath_data), SERVER_TYPE_MAP },
+ { "walkpath_data", sizeof(struct walkpath_data), SERVER_TYPE_MAP },
+ #else
+ #define MAP_PATH_H
+ #endif // MAP_PATH_H
+ #ifdef MAP_PC_GROUPS_H
+ { "GroupSettings", sizeof(struct GroupSettings), SERVER_TYPE_MAP },
+ { "pc_groups_interface", sizeof(struct pc_groups_interface), SERVER_TYPE_MAP },
+ { "pc_groups_new_permission", sizeof(struct pc_groups_new_permission), SERVER_TYPE_MAP },
+ { "pc_groups_permission_table", sizeof(struct pc_groups_permission_table), SERVER_TYPE_MAP },
+ #else
+ #define MAP_PC_GROUPS_H
+ #endif // MAP_PC_GROUPS_H
#ifdef MAP_PC_H
{ "autotrade_vending", sizeof(struct autotrade_vending), SERVER_TYPE_MAP },
{ "item_cd", sizeof(struct item_cd), SERVER_TYPE_MAP },
+ { "map_session_data", sizeof(struct map_session_data), SERVER_TYPE_MAP },
+ { "pc_combos", sizeof(struct pc_combos), SERVER_TYPE_MAP },
+ { "pc_interface", sizeof(struct pc_interface), SERVER_TYPE_MAP },
+ { "s_add_drop", sizeof(struct s_add_drop), SERVER_TYPE_MAP },
+ { "s_addeffect", sizeof(struct s_addeffect), SERVER_TYPE_MAP },
+ { "s_addeffectonskill", sizeof(struct s_addeffectonskill), SERVER_TYPE_MAP },
+ { "s_autobonus", sizeof(struct s_autobonus), SERVER_TYPE_MAP },
+ { "s_autospell", sizeof(struct s_autospell), SERVER_TYPE_MAP },
+ { "sg_data", sizeof(struct sg_data), SERVER_TYPE_MAP },
+ { "skill_tree_entry", sizeof(struct skill_tree_entry), SERVER_TYPE_MAP },
+ { "weapon_data", sizeof(struct weapon_data), SERVER_TYPE_MAP },
#else
#define MAP_PC_H
#endif // MAP_PC_H
+ #ifdef MAP_PET_H
+ { "pet_bonus", sizeof(struct pet_bonus), SERVER_TYPE_MAP },
+ { "pet_data", sizeof(struct pet_data), SERVER_TYPE_MAP },
+ { "pet_interface", sizeof(struct pet_interface), SERVER_TYPE_MAP },
+ { "pet_loot", sizeof(struct pet_loot), SERVER_TYPE_MAP },
+ { "pet_recovery", sizeof(struct pet_recovery), SERVER_TYPE_MAP },
+ { "pet_skill_attack", sizeof(struct pet_skill_attack), SERVER_TYPE_MAP },
+ { "pet_skill_support", sizeof(struct pet_skill_support), SERVER_TYPE_MAP },
+ { "s_pet_db", sizeof(struct s_pet_db), SERVER_TYPE_MAP },
+ #else
+ #define MAP_PET_H
+ #endif // MAP_PET_H
+ #ifdef MAP_QUEST_H
+ { "quest_db", sizeof(struct quest_db), SERVER_TYPE_MAP },
+ { "quest_dropitem", sizeof(struct quest_dropitem), SERVER_TYPE_MAP },
+ { "quest_interface", sizeof(struct quest_interface), SERVER_TYPE_MAP },
+ { "quest_objective", sizeof(struct quest_objective), SERVER_TYPE_MAP },
+ #else
+ #define MAP_QUEST_H
+ #endif // MAP_QUEST_H
#ifdef MAP_SCRIPT_H
{ "Script_Config", sizeof(struct Script_Config), SERVER_TYPE_MAP },
+ { "casecheck_data", sizeof(struct casecheck_data), SERVER_TYPE_MAP },
+ { "hQueue", sizeof(struct hQueue), SERVER_TYPE_MAP },
+ { "hQueueIterator", sizeof(struct hQueueIterator), SERVER_TYPE_MAP },
{ "reg_db", sizeof(struct reg_db), SERVER_TYPE_MAP },
+ { "script_array", sizeof(struct script_array), SERVER_TYPE_MAP },
+ { "script_code", sizeof(struct script_code), SERVER_TYPE_MAP },
+ { "script_data", sizeof(struct script_data), SERVER_TYPE_MAP },
+ { "script_function", sizeof(struct script_function), SERVER_TYPE_MAP },
{ "script_interface", sizeof(struct script_interface), SERVER_TYPE_MAP },
+ { "script_label_entry", sizeof(struct script_label_entry), SERVER_TYPE_MAP },
+ { "script_retinfo", sizeof(struct script_retinfo), SERVER_TYPE_MAP },
+ { "script_stack", sizeof(struct script_stack), SERVER_TYPE_MAP },
+ { "script_state", sizeof(struct script_state), SERVER_TYPE_MAP },
+ { "script_string_buf", sizeof(struct script_string_buf), SERVER_TYPE_MAP },
+ { "script_syntax_data", sizeof(struct script_syntax_data), SERVER_TYPE_MAP },
+ { "str_data_struct", sizeof(struct str_data_struct), SERVER_TYPE_MAP },
+ { "string_translation", sizeof(struct string_translation), SERVER_TYPE_MAP },
#else
#define MAP_SCRIPT_H
#endif // MAP_SCRIPT_H
#ifdef MAP_SEARCHSTORE_H
+ { "s_search_store_info", sizeof(struct s_search_store_info), SERVER_TYPE_MAP },
+ { "s_search_store_info_item", sizeof(struct s_search_store_info_item), SERVER_TYPE_MAP },
{ "searchstore_interface", sizeof(struct searchstore_interface), SERVER_TYPE_MAP },
#else
#define MAP_SEARCHSTORE_H
#endif // MAP_SEARCHSTORE_H
#ifdef MAP_SKILL_H
+ { "s_skill_abra_db", sizeof(struct s_skill_abra_db), SERVER_TYPE_MAP },
+ { "s_skill_arrow_db", sizeof(struct s_skill_arrow_db), SERVER_TYPE_MAP },
+ { "s_skill_changematerial_db", sizeof(struct s_skill_changematerial_db), SERVER_TYPE_MAP },
+ { "s_skill_db", sizeof(struct s_skill_db), SERVER_TYPE_MAP },
+ { "s_skill_dbs", sizeof(struct s_skill_dbs), SERVER_TYPE_MAP },
+ { "s_skill_improvise_db", sizeof(struct s_skill_improvise_db), SERVER_TYPE_MAP },
+ { "s_skill_magicmushroom_db", sizeof(struct s_skill_magicmushroom_db), SERVER_TYPE_MAP },
+ { "s_skill_produce_db", sizeof(struct s_skill_produce_db), SERVER_TYPE_MAP },
+ { "s_skill_spellbook_db", sizeof(struct s_skill_spellbook_db), SERVER_TYPE_MAP },
+ { "s_skill_unit_layout", sizeof(struct s_skill_unit_layout), SERVER_TYPE_MAP },
{ "skill_cd", sizeof(struct skill_cd), SERVER_TYPE_MAP },
+ { "skill_cd_entry", sizeof(struct skill_cd_entry), SERVER_TYPE_MAP },
{ "skill_condition", sizeof(struct skill_condition), SERVER_TYPE_MAP },
{ "skill_interface", sizeof(struct skill_interface), SERVER_TYPE_MAP },
+ { "skill_timerskill", sizeof(struct skill_timerskill), SERVER_TYPE_MAP },
+ { "skill_unit", sizeof(struct skill_unit), SERVER_TYPE_MAP },
+ { "skill_unit_group", sizeof(struct skill_unit_group), SERVER_TYPE_MAP },
+ { "skill_unit_group_tickset", sizeof(struct skill_unit_group_tickset), SERVER_TYPE_MAP },
{ "skill_unit_save", sizeof(struct skill_unit_save), SERVER_TYPE_MAP },
#else
#define MAP_SKILL_H
#endif // MAP_SKILL_H
+ #ifdef MAP_STATUS_H
+ { "regen_data", sizeof(struct regen_data), SERVER_TYPE_MAP },
+ { "regen_data_sub", sizeof(struct regen_data_sub), SERVER_TYPE_MAP },
+ { "s_refine_info", sizeof(struct s_refine_info), SERVER_TYPE_MAP },
+ { "s_status_dbs", sizeof(struct s_status_dbs), SERVER_TYPE_MAP },
+ { "sc_display_entry", sizeof(struct sc_display_entry), SERVER_TYPE_MAP },
+ { "status_change", sizeof(struct status_change), SERVER_TYPE_MAP },
+ { "status_change_entry", sizeof(struct status_change_entry), SERVER_TYPE_MAP },
+ { "status_data", sizeof(struct status_data), SERVER_TYPE_MAP },
+ { "status_interface", sizeof(struct status_interface), SERVER_TYPE_MAP },
+ { "weapon_atk", sizeof(struct weapon_atk), SERVER_TYPE_MAP },
+ #else
+ #define MAP_STATUS_H
+ #endif // MAP_STATUS_H
+ #ifdef MAP_STORAGE_H
+ { "guild_storage_interface", sizeof(struct guild_storage_interface), SERVER_TYPE_MAP },
+ { "storage_interface", sizeof(struct storage_interface), SERVER_TYPE_MAP },
+ #else
+ #define MAP_STORAGE_H
+ #endif // MAP_STORAGE_H
+ #ifdef MAP_TRADE_H
+ { "trade_interface", sizeof(struct trade_interface), SERVER_TYPE_MAP },
+ #else
+ #define MAP_TRADE_H
+ #endif // MAP_TRADE_H
+ #ifdef MAP_UNIT_H
+ { "unit_data", sizeof(struct unit_data), SERVER_TYPE_MAP },
+ { "unit_interface", sizeof(struct unit_interface), SERVER_TYPE_MAP },
+ { "view_data", sizeof(struct view_data), SERVER_TYPE_MAP },
+ #else
+ #define MAP_UNIT_H
+ #endif // MAP_UNIT_H
+ #ifdef MAP_VENDING_H
+ { "s_vending", sizeof(struct s_vending), SERVER_TYPE_MAP },
+ { "vending_interface", sizeof(struct vending_interface), SERVER_TYPE_MAP },
+ #else
+ #define MAP_VENDING_H
+ #endif // MAP_VENDING_H
};
HPExport unsigned int HPMDataCheckLen = ARRAYLENGTH(HPMDataCheck);
HPExport int HPMDataCheckVer = 1;
diff --git a/src/common/HPMi.h b/src/common/HPMi.h
index d4b2e323c..b700c1b73 100644
--- a/src/common/HPMi.h
+++ b/src/common/HPMi.h
@@ -4,10 +4,10 @@
#ifndef COMMON_HPMI_H
#define COMMON_HPMI_H
-#include "../common/cbasetypes.h"
-#include "../common/console.h"
-#include "../common/core.h"
-#include "../common/sql.h"
+#include "common/cbasetypes.h"
+#include "common/console.h"
+#include "common/core.h"
+#include "common/sql.h"
struct script_state;
struct AtCommandInfo;
@@ -21,7 +21,7 @@ struct map_session_data;
#endif
/* after */
-#include "../common/showmsg.h"
+#include "common/showmsg.h"
#define HPM_VERSION "1.0"
#define HPM_ADDCONF_LENGTH 40
@@ -83,6 +83,7 @@ enum HPluginDataTypes {
HPDT_MOBDB,
HPDT_MOBDATA,
HPDT_ITEMDATA,
+ HPDT_BGDATA,
};
/* used in macros and conf storage */
@@ -146,6 +147,10 @@ enum HPluginConfType {
#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)))
+/* battleground_data */
+#define addToBGDATA(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_BGDATA,HPMi->pid,(ptr),(data),(index),(autofree)))
+#define getFromBGDATA(ptr,index) (HPMi->getFromHPData(HPDT_BGDATA,HPMi->pid,(ptr),(index)))
+#define removeFromBGDATA(ptr,index) (HPMi->removeFromHPData(HPDT_BGDATA,HPMi->pid,(ptr),(index)))
/* HPMi->addCommand */
#define addAtcommand(cname,funcname) \
diff --git a/src/common/Makefile.in b/src/common/Makefile.in
index 5dfdd35bd..f6f993165 100644
--- a/src/common/Makefile.in
+++ b/src/common/Makefile.in
@@ -6,17 +6,20 @@
CONFIG_D = ../config
CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h)
-LIBCONFIG_D = ../../3rdparty/libconfig
+COMMON_INCLUDE = -I..
+
+THIRDPARTY_D = ../../3rdparty
+THIRDPARTY_INCLUDE = -I$(THIRDPARTY_D)
+
+LIBCONFIG_D = $(THIRDPARTY_D)/libconfig
LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
scanner.o strbuf.o)
LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
scanctx.h scanner.h strbuf.h wincompat.h)
-LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
-MT19937AR_D = ../../3rdparty/mt19937ar
+MT19937AR_D = $(THIRDPARTY_D)/mt19937ar
MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
-MT19937AR_INCLUDE = -I$(MT19937AR_D)
COMMON_SHARED_C = conf.c db.c des.c ers.c grfio.c HPM.c mapindex.c md5calc.c \
mutex.c nullpo.c random.c showmsg.c strlib.c sysinfo.c \
@@ -116,15 +119,15 @@ obj_all/sysinfo.o: sysinfo.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_
obj_all/%.o: %.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | $(SYSINFO_INC) obj_all
@echo " CC $<"
- @$(CC) @CFLAGS@ @DEFS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+ @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
obj_all/mini%.o: %.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | $(SYSINFO_INC) obj_all
@echo " CC $<"
- @$(CC) @CFLAGS@ @DEFS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+ @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
obj_sql/%.o: %.c $(COMMON_H) $(COMMON_SQL_H) $(CONFIG_H) $(LIBCONFIG_H) | $(SYSINFO_INC) obj_sql
@echo " CC $<"
- @$(CC) @CFLAGS@ @DEFS@ $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+ @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing object files
$(MT19937AR_OBJ):
diff --git a/src/common/atomic.h b/src/common/atomic.h
index a42dfad1c..c1ea2aa48 100644
--- a/src/common/atomic.h
+++ b/src/common/atomic.h
@@ -14,10 +14,10 @@
//
// our Abstraction is fully API-Compatible to Microsoft's implementation @ NT5.0+
//
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
#if defined(_MSC_VER)
-#include "../common/winapi.h"
+#include "common/winapi.h"
// This checks if C/C++ Compiler Version is 18.00
#if _MSC_VER < 1800
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h
index 3ff0db795..ce8fc6bcf 100644
--- a/src/common/cbasetypes.h
+++ b/src/common/cbasetypes.h
@@ -97,6 +97,7 @@
#include <inttypes.h>
#include <stdint.h>
#include <limits.h>
+#include <time.h>
// temporary fix for bugreport:4961 (unintended conversion from signed to unsigned)
// (-20 >= UCHAR_MAX) returns true
@@ -419,4 +420,10 @@ typedef char bool;
#define h64BPTRSIZE(y) (y)
#endif
+/** Support macros for marking blocks to memset to 0 */
+#define BEGIN_ZEROED_BLOCK int8 HERC__zeroed_block_BEGIN
+#define END_ZEROED_BLOCK int8 HERC__zeroed_block_END
+#define ZEROED_BLOCK_POS(x) (&(x)->HERC__zeroed_block_BEGIN)
+#define ZEROED_BLOCK_SIZE(x) ((char*)&((x)->HERC__zeroed_block_END) - (char*)&((x)->HERC__zeroed_block_BEGIN) + sizeof((x)->HERC__zeroed_block_END))
+
#endif /* COMMON_CBASETYPES_H */
diff --git a/src/common/conf.c b/src/common/conf.c
index c974decf9..cb0194c3a 100644
--- a/src/common/conf.c
+++ b/src/common/conf.c
@@ -6,9 +6,9 @@
#include "conf.h"
-#include "../../3rdparty/libconfig/libconfig.h"
+#include "common/showmsg.h" // ShowError
-#include "../common/showmsg.h" // ShowError
+#include <libconfig/libconfig.h>
/* interface source */
struct libconfig_interface libconfig_s;
diff --git a/src/common/conf.h b/src/common/conf.h
index bd97d5c1e..1889aeb3a 100644
--- a/src/common/conf.h
+++ b/src/common/conf.h
@@ -5,9 +5,9 @@
#ifndef COMMON_CONF_H
#define COMMON_CONF_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
-#include "../../3rdparty/libconfig/libconfig.h"
+#include <libconfig/libconfig.h>
/**
* The libconfig interface -- specially for plugins, but we enforce it throughout the core to be consistent
diff --git a/src/common/console.c b/src/common/console.c
index 97ca0650e..95d1e69fe 100644
--- a/src/common/console.c
+++ b/src/common/console.c
@@ -4,34 +4,33 @@
#define HERCULES_CORE
-#include "../config/core.h" // CONSOLE_INPUT, MAX_CONSOLE_INPUT
+#include "config/core.h" // CONSOLE_INPUT, MAX_CONSOLE_INPUT
#include "console.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "../common/cbasetypes.h"
-#include "../common/core.h"
-#include "../common/showmsg.h"
-#include "../common/sysinfo.h"
+#include "common/cbasetypes.h"
+#include "common/core.h"
+#include "common/showmsg.h"
+#include "common/sysinfo.h"
#ifndef MINICORE
-# include "../common/atomic.h"
-# include "../common/ers.h"
-# include "../common/malloc.h"
-# include "../common/mutex.h"
-# include "../common/spinlock.h"
-# include "../common/sql.h"
-# include "../common/strlib.h"
-# include "../common/thread.h"
-# include "../common/timer.h"
+# include "common/atomic.h"
+# include "common/ers.h"
+# include "common/malloc.h"
+# include "common/mutex.h"
+# include "common/spinlock.h"
+# include "common/sql.h"
+# include "common/strlib.h"
+# include "common/thread.h"
+# include "common/timer.h"
#endif
+#include <stdio.h>
+#include <stdlib.h>
#if !defined(WIN32)
# include <sys/time.h>
# include <unistd.h>
#else
-# include "../common/winapi.h" // Console close event handling
+# include "common/winapi.h" // Console close event handling
# ifdef CONSOLE_INPUT
# include <conio.h> /* _kbhit() */
# endif
@@ -63,7 +62,7 @@ void display_title(void) {
ShowMessage(""CL_BG_RED""CL_BT_WHITE" | | | | __/ | | (__| |_| | | __/\\__ \\ "CL_CLL""CL_NORMAL"\n");
ShowMessage(""CL_BG_RED""CL_BT_WHITE" \\_| |_/\\___|_| \\___|\\__,_|_|\\___||___/ "CL_CLL""CL_NORMAL"\n");
ShowMessage(""CL_BG_RED""CL_BT_WHITE" "CL_CLL""CL_NORMAL"\n");
- ShowMessage(""CL_BG_RED""CL_BT_WHITE" http://hercules.ws/board/ "CL_CLL""CL_NORMAL"\n");
+ ShowMessage(""CL_BG_RED""CL_BT_WHITE" http://herc.ws/board/ "CL_CLL""CL_NORMAL"\n");
ShowMessage(""CL_BG_RED""CL_BT_WHITE" "CL_CLL""CL_NORMAL"\n");
ShowInfo("Hercules %d-bit for %s\n", sysinfo->is64bit() ? 64 : 32, sysinfo->platform());
diff --git a/src/common/console.h b/src/common/console.h
index 3d3c8e9dd..643edc3d9 100644
--- a/src/common/console.h
+++ b/src/common/console.h
@@ -4,13 +4,13 @@
#ifndef COMMON_CONSOLE_H
#define COMMON_CONSOLE_H
-#include "../config/core.h" // MAX_CONSOLE_INPUT
+#include "config/core.h" // MAX_CONSOLE_INPUT
-#include "../common/cbasetypes.h"
-#include "../common/mutex.h"
-#include "../common/spinlock.h"
-#include "../common/sql.h"
-#include "../common/thread.h"
+#include "common/cbasetypes.h"
+#include "common/mutex.h"
+#include "common/spinlock.h"
+#include "common/sql.h"
+#include "common/thread.h"
/**
* Queue Max
diff --git a/src/common/core.c b/src/common/core.c
index 8bf381589..e663c4e4c 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -4,41 +4,39 @@
#define HERCULES_CORE
-#include "../config/core.h"
+#include "config/core.h"
#include "core.h"
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "../common/cbasetypes.h"
-#include "../common/console.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-#include "../common/sysinfo.h"
-#include "../common/nullpo.h"
+#include "common/cbasetypes.h"
+#include "common/console.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+#include "common/sysinfo.h"
+#include "common/nullpo.h"
#ifndef MINICORE
-# include "../common/HPM.h"
-# include "../common/conf.h"
-# include "../common/db.h"
-# include "../common/ers.h"
-# include "../common/socket.h"
-# include "../common/sql.h"
-# include "../common/thread.h"
-# include "../common/timer.h"
-# include "../common/utils.h"
+# include "common/HPM.h"
+# include "common/conf.h"
+# include "common/ers.h"
+# include "common/socket.h"
+# include "common/sql.h"
+# include "common/thread.h"
+# include "common/timer.h"
+# include "common/utils.h"
#endif
#ifndef _WIN32
# include <unistd.h>
#else
-# include "../common/winapi.h" // Console close event handling
+# include "common/winapi.h" // Console close event handling
#endif
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
/// Called when a terminate signal is received.
void (*shutdown_callback)(void) = NULL;
@@ -250,7 +248,7 @@ static CMDLINEARG(help)
*/
static CMDLINEARG(version)
{
- ShowInfo(CL_GREEN"Website/Forum:"CL_RESET"\thttp://hercules.ws/\n");
+ ShowInfo(CL_GREEN"Website/Forum:"CL_RESET"\thttp://herc.ws/\n");
ShowInfo(CL_GREEN"IRC Channel:"CL_RESET"\tirc://irc.rizon.net/#Hercules\n");
ShowInfo("Open "CL_WHITE"readme.txt"CL_RESET" for more information.\n");
return false;
diff --git a/src/common/core.h b/src/common/core.h
index 827d345ba..c2a8d9e58 100644
--- a/src/common/core.h
+++ b/src/common/core.h
@@ -5,9 +5,7 @@
#ifndef COMMON_CORE_H
#define COMMON_CORE_H
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/mmo.h"
+#include "common/cbasetypes.h"
/* so that developers with --enable-debug can raise signals from any section of the code they'd like */
#ifdef DEBUG
diff --git a/src/common/db.c b/src/common/db.c
index 69e2333a9..5063425e6 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -72,15 +72,15 @@
#include "db.h"
+#include "common/ers.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include "../common/ers.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-
struct db_interface DB_s;
/*****************************************************************************\
diff --git a/src/common/db.h b/src/common/db.h
index cd61e1543..f75cbd8dc 100644
--- a/src/common/db.h
+++ b/src/common/db.h
@@ -42,9 +42,9 @@
#ifndef COMMON_DB_H
#define COMMON_DB_H
-#include <stdarg.h>
+#include "common/cbasetypes.h"
-#include "../common/cbasetypes.h"
+#include <stdarg.h>
/*****************************************************************************\
* (1) Section with public typedefs, enums, unions, structures and defines. *
@@ -71,10 +71,10 @@
* @see #db_custom_release(DBRelease)
*/
typedef enum DBRelease {
- DB_RELEASE_NOTHING = 0,
- DB_RELEASE_KEY = 1,
- DB_RELEASE_DATA = 2,
- DB_RELEASE_BOTH = 3
+ DB_RELEASE_NOTHING = 0x0,
+ DB_RELEASE_KEY = 0x1,
+ DB_RELEASE_DATA = 0x2,
+ DB_RELEASE_BOTH = DB_RELEASE_KEY|DB_RELEASE_DATA,
} DBRelease;
/**
@@ -127,13 +127,13 @@ typedef enum DBType {
* @see #db_alloc(const char *,int,DBType,DBOptions,unsigned short)
*/
typedef enum DBOptions {
- DB_OPT_BASE = 0,
- DB_OPT_DUP_KEY = 1,
- DB_OPT_RELEASE_KEY = 2,
- DB_OPT_RELEASE_DATA = 4,
- DB_OPT_RELEASE_BOTH = 6,
- DB_OPT_ALLOW_NULL_KEY = 8,
- DB_OPT_ALLOW_NULL_DATA = 16,
+ DB_OPT_BASE = 0x00,
+ DB_OPT_DUP_KEY = 0x01,
+ DB_OPT_RELEASE_KEY = 0x02,
+ DB_OPT_RELEASE_DATA = 0x04,
+ DB_OPT_RELEASE_BOTH = DB_OPT_RELEASE_KEY|DB_OPT_RELEASE_DATA,
+ DB_OPT_ALLOW_NULL_KEY = 0x08,
+ DB_OPT_ALLOW_NULL_DATA = 0x10,
} DBOptions;
/**
diff --git a/src/common/des.c b/src/common/des.c
index 89a920bc9..0a702bfdf 100644
--- a/src/common/des.c
+++ b/src/common/des.c
@@ -5,7 +5,7 @@
#include "des.h"
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
/// DES (Data Encryption Standard) algorithm, modified version.
/// @see http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=5099.
diff --git a/src/common/des.h b/src/common/des.h
index 9e6aec4fd..6f54b36f2 100644
--- a/src/common/des.h
+++ b/src/common/des.h
@@ -3,7 +3,7 @@
#ifndef COMMON_DES_H
#define COMMON_DES_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
/// One 64-bit block.
typedef struct BIT64 { uint8_t b[8]; } BIT64;
diff --git a/src/common/ers.c b/src/common/ers.c
index 52cba0fe5..91fc6ccfb 100644
--- a/src/common/ers.c
+++ b/src/common/ers.c
@@ -44,14 +44,14 @@
#include "ers.h"
+#include "common/cbasetypes.h"
+#include "common/malloc.h" // CREATE, RECREATE, aMalloc, aFree
+#include "common/nullpo.h"
+#include "common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL
+
#include <stdlib.h>
#include <string.h>
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h" // CREATE, RECREATE, aMalloc, aFree
-#include "../common/nullpo.h"
-#include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL
-
#ifndef DISABLE_ERS
#define ERS_BLOCK_ENTRIES 2048
diff --git a/src/common/ers.h b/src/common/ers.h
index 85ddfed7a..09290186e 100644
--- a/src/common/ers.h
+++ b/src/common/ers.h
@@ -40,7 +40,7 @@
#ifndef COMMON_ERS_H
#define COMMON_ERS_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
/*****************************************************************************\
* (1) All public parts of the Entry Reusage System. *
@@ -71,11 +71,11 @@
#endif /* not ERS_ALIGN_ENTRY */
enum ERSOptions {
- ERS_OPT_NONE = 0x0,
- ERS_OPT_CLEAR = 0x1,/* silently clears any entries left in the manager upon destruction */
- ERS_OPT_WAIT = 0x2,/* wait for entries to come in order to list! */
- 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_NONE = 0x00,
+ ERS_OPT_CLEAR = 0x01,/* silently clears any entries left in the manager upon destruction */
+ ERS_OPT_WAIT = 0x02,/* wait for entries to come in order to list! */
+ ERS_OPT_FREE_NAME = 0x04,/* name is dynamic memory, and should be freed */
+ ERS_OPT_CLEAN = 0x08,/* 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 */
diff --git a/src/common/grfio.c b/src/common/grfio.c
index d226fb158..614678da8 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -6,20 +6,19 @@
#include "grfio.h"
+#include "common/cbasetypes.h"
+#include "common/des.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/stat.h>
#include <zlib.h>
-#include "../common/cbasetypes.h"
-#include "../common/des.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-#include "../common/utils.h"
-
//----------------------------
// file entry table struct
//----------------------------
@@ -36,8 +35,8 @@ typedef struct FILELIST {
} FILELIST;
#define FILELIST_TYPE_FILE 0x01 // entry is a file
-#define FILELIST_TYPE_ENCRYPT_HEADER 0x04 // encryption mode 1 (header DES only)
#define FILELIST_TYPE_ENCRYPT_MIXED 0x02 // encryption mode 0 (header DES + periodic DES/shuffle)
+#define FILELIST_TYPE_ENCRYPT_HEADER 0x04 // encryption mode 1 (header DES only)
//gentry ... > 0 : data read from a grf file (gentry_table[gentry-1])
//gentry ... 0 : data read from a local file (data directory)
@@ -645,6 +644,7 @@ static int grfio_entryread(const char *grfname, int gentry)
aFree(rBuf);
entrys = getlong(grf_header+0x26) - 7;
+ Assert_retr(4, entrys >= 0);
// Get an entry
for (entry = 0, ofs = 0; entry < entrys; ++entry) {
diff --git a/src/common/malloc.c b/src/common/malloc.c
index c647dc18f..ec0467495 100644
--- a/src/common/malloc.c
+++ b/src/common/malloc.c
@@ -6,14 +6,14 @@
#include "malloc.h"
+#include "common/cbasetypes.h"
+#include "common/core.h"
+#include "common/showmsg.h"
+#include "common/sysinfo.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <time.h>
-
-#include "../common/core.h"
-#include "../common/showmsg.h"
-#include "../common/sysinfo.h"
struct malloc_interface iMalloc_s;
@@ -22,7 +22,7 @@ struct malloc_interface iMalloc_s;
#if defined(MEMWATCH)
# include <string.h>
-# include "memwatch.h"
+# include <memwatch.h>
# define MALLOC(n,file,line,func) mwMalloc((n),(file),(line))
# define CALLOC(m,n,file,line,func) mwCalloc((m),(n),(file),(line))
# define REALLOC(p,n,file,line,func) mwRealloc((p),(n),(file),(line))
@@ -36,7 +36,7 @@ struct malloc_interface iMalloc_s;
# include <string.h>
# include <stdlib.h>
-# include "dmalloc.h"
+# include <dmalloc.h>
# define MALLOC(n,file,line,func) dmalloc_malloc((file),(line),(n),DMALLOC_FUNC_MALLOC,0,0)
# define CALLOC(m,n,file,line,func) dmalloc_malloc((file),(line),(m)*(n),DMALLOC_FUNC_CALLOC,0,0)
# define REALLOC(p,n,file,line,func) dmalloc_realloc((file),(line),(p),(n),DMALLOC_FUNC_REALLOC,0)
@@ -48,7 +48,7 @@ struct malloc_interface iMalloc_s;
#elif defined(GCOLLECT)
-# include "gc.h"
+# include <gc.h>
# ifdef GC_ADD_CALLER
# define RETURN_ADDR 0,
# else
diff --git a/src/common/malloc.h b/src/common/malloc.h
index 7ed2fb19c..20260de84 100644
--- a/src/common/malloc.h
+++ b/src/common/malloc.h
@@ -4,7 +4,7 @@
#ifndef COMMON_MALLOC_H
#define COMMON_MALLOC_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
#define ALC_MARK __FILE__, __LINE__, __func__
diff --git a/src/common/mapindex.c b/src/common/mapindex.c
index 035518f68..18aa413cc 100644
--- a/src/common/mapindex.c
+++ b/src/common/mapindex.c
@@ -6,15 +6,14 @@
#include "mapindex.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/mmo.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
/* mapindex.c interface source */
struct mapindex_interface mapindex_s;
@@ -193,7 +192,7 @@ void mapindex_defaults(void) {
mapindex = &mapindex_s;
/* TODO: place it in inter-server.conf? */
- snprintf(mapindex->config_file, 80, "%s","db/map_index.txt");
+ snprintf(mapindex->config_file, sizeof(mapindex->config_file), "%s","db/map_index.txt");
/* */
mapindex->db = NULL;
mapindex->num = 0;
diff --git a/src/common/mapindex.h b/src/common/mapindex.h
index 87a275f57..c334e7cca 100644
--- a/src/common/mapindex.h
+++ b/src/common/mapindex.h
@@ -5,8 +5,9 @@
#ifndef COMMON_MAPINDEX_H
#define COMMON_MAPINDEX_H
-#include "../common/db.h"
-#include "../common/mmo.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/mmo.h"
#define MAX_MAPINDEX 2000
diff --git a/src/common/md5calc.c b/src/common/md5calc.c
index 7b31a38d6..e594c364f 100644
--- a/src/common/md5calc.c
+++ b/src/common/md5calc.c
@@ -10,16 +10,13 @@
#include "md5calc.h"
+#include "common/cbasetypes.h"
+#include "common/random.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "../common/random.h"
-
-#ifndef UINT_MAX
-#define UINT_MAX 4294967295U
-#endif
-
// Global variable
static unsigned int *pX;
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 48eba0041..3e497c667 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -5,10 +5,8 @@
#ifndef COMMON_MMO_H
#define COMMON_MMO_H
-#include <time.h>
-
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
+#include "config/core.h"
+#include "common/cbasetypes.h"
// server->client protocol version
// 0 - pre-?
@@ -118,15 +116,16 @@
#define MAX_STORAGE 600
#define MAX_GUILD_STORAGE 600
#define MAX_PARTY 12
-#define MAX_GUILD (16+10*6) // Increased max guild members +6 per 1 extension levels [Lupus]
-#define MAX_GUILDPOSITION 20 // Increased max guild positions to accommodate for all members [Valaris] (removed) [PoW]
+#define BASE_GUILD_SIZE 16 // Base guild members (without GD_EXTENSION)
+#define MAX_GUILD (BASE_GUILD_SIZE+10*6) // Increased max guild members +6 per 1 extension levels [Lupus]
+#define MAX_GUILDPOSITION 20 // Increased max guild positions to accomodate for all members [Valaris] (removed) [PoW]
#define MAX_GUILDEXPULSION 32
#define MAX_GUILDALLIANCE 16
-#define MAX_GUILDSKILL 15 // Increased max guild skills because of new skills [Sara-chan]
+#define MAX_GUILDSKILL 15 // Increased max guild skills because of new skills [Sara-chan]
#define MAX_GUILDLEVEL 50
-#define MAX_GUARDIANS 8 // Local max per castle. [Skotlex]
-#define MAX_QUEST_OBJECTIVES 3 // Max quest objectives for a quest
-#define MAX_START_ITEMS 32 // Max number of items allowed to be given to a char whenever it's created. [mkbu95]
+#define MAX_GUARDIANS 8 // Local max per castle. [Skotlex]
+#define MAX_QUEST_OBJECTIVES 3 // Max quest objectives for a quest
+#define MAX_START_ITEMS 32 // Max number of items allowed to be given to a char whenever it's created. [mkbu95]
// for produce
#define MIN_ATTRIBUTE 0
@@ -189,6 +188,16 @@
#define EL_CLASS_BASE 2114
#define EL_CLASS_MAX (EL_CLASS_BASE+MAX_ELEMENTAL_CLASS-1)
+// The following system marks a different job ID system used by the map server,
+// which makes a lot more sense than the normal one. [Skotlex]
+// These marks the "level" of the job.
+#define JOBL_2_1 0x100 //256
+#define JOBL_2_2 0x200 //512
+#define JOBL_2 0x300
+#define JOBL_UPPER 0x1000 //4096
+#define JOBL_BABY 0x2000 //8192
+#define JOBL_THIRD 0x4000 //16384
+
struct HPluginData;
enum item_types {
@@ -298,6 +307,49 @@ enum e_item_bound_type {
IBT_MAX = 0x4,
};
+enum {
+ OPTION_NOTHING = 0x00000000,
+ OPTION_SIGHT = 0x00000001,
+ OPTION_HIDE = 0x00000002,
+ OPTION_CLOAK = 0x00000004,
+ OPTION_FALCON = 0x00000010,
+ OPTION_RIDING = 0x00000020,
+ OPTION_INVISIBLE = 0x00000040,
+ OPTION_ORCISH = 0x00000800,
+ OPTION_WEDDING = 0x00001000,
+ OPTION_RUWACH = 0x00002000,
+ OPTION_CHASEWALK = 0x00004000,
+ OPTION_FLYING = 0x00008000, //Note that clientside Flying and Xmas are 0x8000 for clients prior to 2007.
+ OPTION_XMAS = 0x00010000,
+ OPTION_TRANSFORM = 0x00020000,
+ OPTION_SUMMER = 0x00040000,
+ OPTION_DRAGON1 = 0x00080000,
+ OPTION_WUG = 0x00100000,
+ OPTION_WUGRIDER = 0x00200000,
+ OPTION_MADOGEAR = 0x00400000,
+ OPTION_DRAGON2 = 0x00800000,
+ OPTION_DRAGON3 = 0x01000000,
+ OPTION_DRAGON4 = 0x02000000,
+ 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,
+};
+
struct s_skill {
unsigned short id;
unsigned char lv;
@@ -677,6 +729,12 @@ enum { //Change Member Infos
GMI_LEVEL,
};
+enum guild_permission { // Guild permissions
+ GPERM_INVITE = 0x01,
+ GPERM_EXPEL = 0x10,
+ GPERM_BOTH = GPERM_INVITE|GPERM_EXPEL,
+};
+
enum {
GD_SKILLBASE=10000,
GD_APPROVAL=10000,
@@ -927,6 +985,30 @@ enum e_pc_reg_loading {
PRL_ALL = 0xFF,
};
+/**
+ * Values to be used as operation_type in chrif_char_ask_name
+ */
+enum zh_char_ask_name_type {
+ CHAR_ASK_NAME_BLOCK = 1, // account block
+ CHAR_ASK_NAME_BAN = 2, // account ban
+ CHAR_ASK_NAME_UNBLOCK = 3, // account unblock
+ CHAR_ASK_NAME_UNBAN = 4, // account unban
+ CHAR_ASK_NAME_CHANGESEX = 5, // change sex
+ CHAR_ASK_NAME_CHARBAN = 6, // character ban
+ CHAR_ASK_NAME_CHARUNBAN = 7, // character unban
+ CHAR_ASK_NAME_CHANGECHARSEX = 8, // change character sex
+};
+
+/**
+ * Values to be used as answer in chrig_char_ask_name_answer
+ */
+enum hz_char_ask_name_answer {
+ CHAR_ASK_NAME_ANS_DONE = 0, // login-server request done
+ CHAR_ASK_NAME_ANS_NOTFOUND = 1, // player not found
+ CHAR_ASK_NAME_ANS_GMLOW = 2, // gm level too low
+ CHAR_ASK_NAME_ANS_OFFLINE = 3, // login-server offline
+};
+
/* packet size constant for itemlist */
#if MAX_INVENTORY > MAX_STORAGE && MAX_INVENTORY > MAX_CART
#define MAX_ITEMLIST MAX_INVENTORY
diff --git a/src/common/mutex.c b/src/common/mutex.c
index 7307f5f15..5dfb3d01c 100644
--- a/src/common/mutex.c
+++ b/src/common/mutex.c
@@ -5,20 +5,18 @@
#include "mutex.h"
-#include "../common/cbasetypes.h" // for WIN32
+#include "common/cbasetypes.h" // for WIN32
+#include "common/malloc.h"
+#include "common/showmsg.h"
+#include "common/timer.h"
#ifdef WIN32
-#include "../common/winapi.h"
+#include "common/winapi.h"
#else
#include <pthread.h>
-#include <time.h>
#include <sys/time.h>
#endif
-#include "../common/malloc.h"
-#include "../common/showmsg.h"
-#include "../common/timer.h"
-
struct ramutex{
#ifdef WIN32
CRITICAL_SECTION hMutex;
diff --git a/src/common/mutex.h b/src/common/mutex.h
index fa8170c98..a70f0e8fd 100644
--- a/src/common/mutex.h
+++ b/src/common/mutex.h
@@ -4,7 +4,7 @@
#ifndef COMMON_MUTEX_H
#define COMMON_MUTEX_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
typedef struct ramutex ramutex; // Mutex
typedef struct racond racond; // Condition Var
diff --git a/src/common/nullpo.c b/src/common/nullpo.c
index e61d52257..a8980885f 100644
--- a/src/common/nullpo.c
+++ b/src/common/nullpo.c
@@ -6,11 +6,15 @@
#include "nullpo.h"
+#include "common/showmsg.h"
+
#include <stdio.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <string.h>
-
-#include "../common/showmsg.h"
+#ifdef __GNUC__
+#include <execinfo.h>
+#endif
struct nullpo_interface nullpo_s;
@@ -24,6 +28,12 @@ struct nullpo_interface nullpo_s;
* @param title Message title to display (i.e. failed assertion or nullpo info)
*/
void assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) {
+#ifdef __GNUC__
+ void *array[10];
+ int size;
+ char **strings;
+ int i;
+#endif
if (file == NULL)
file = "??";
@@ -32,6 +42,13 @@ void assert_report(const char *file, int line, const char *func, const char *tar
ShowError("--- %s --------------------------------------------\n", title);
ShowError("%s:%d: '%s' in function `%s'\n", file, line, targetname, func);
+#ifdef __GNUC__
+ size = (int)backtrace(array, 10);
+ strings = backtrace_symbols(array, size);
+ for (i = 0; i < size; i++)
+ ShowError("%s\n", strings[i]);
+ free(strings);
+#endif
ShowError("--- end %s ----------------------------------------\n", title);
}
diff --git a/src/common/nullpo.h b/src/common/nullpo.h
index 573e351e0..a59c2ac2b 100644
--- a/src/common/nullpo.h
+++ b/src/common/nullpo.h
@@ -5,7 +5,7 @@
#ifndef COMMON_NULLPO_H
#define COMMON_NULLPO_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
// enabled by default on debug builds
#if defined(DEBUG) && !defined(NULLPO_CHECK)
diff --git a/src/common/random.c b/src/common/random.c
index 88d5748cf..a4d7c5d34 100644
--- a/src/common/random.c
+++ b/src/common/random.c
@@ -5,16 +5,14 @@
#include "random.h"
-#include <time.h> // time
+#include "common/cbasetypes.h" // for WIN32
+#include "common/showmsg.h"
+#include "common/timer.h" // gettick
-#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53
-
-#include "../common/cbasetypes.h" // for WIN32
-#include "../common/showmsg.h"
-#include "../common/timer.h" // gettick
+#include <mt19937ar/mt19937ar.h> // init_genrand, genrand_int32, genrand_res53
#if defined(WIN32)
-# include "../common/winapi.h"
+# include "common/winapi.h"
#elif defined(HAVE_GETPID) || defined(HAVE_GETTID)
# include <sys/types.h>
# include <unistd.h>
diff --git a/src/common/random.h b/src/common/random.h
index 0ca375d28..379e675b2 100644
--- a/src/common/random.h
+++ b/src/common/random.h
@@ -4,7 +4,7 @@
#ifndef COMMON_RANDOM_H
#define COMMON_RANDOM_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
#ifdef HERCULES_CORE
void rnd_init(void);
diff --git a/src/common/showmsg.c b/src/common/showmsg.c
index 0dd645eeb..01dc0b01a 100644
--- a/src/common/showmsg.c
+++ b/src/common/showmsg.c
@@ -6,20 +6,18 @@
#include "showmsg.h"
+#include "common/cbasetypes.h"
+#include "common/core.h" //[Ind] - For SERVER_TYPE
+#include "common/strlib.h" // StringBuf
+
+#include <libconfig/libconfig.h>
+
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h> // atexit
-#include <string.h>
-#include <time.h>
-
-#include "../../3rdparty/libconfig/libconfig.h"
-
-#include "../common/cbasetypes.h"
-#include "../common/core.h" //[Ind] - For SERVER_TYPE
-#include "../common/strlib.h" // StringBuf
#ifdef WIN32
-# include "../common/winapi.h"
+# include "common/winapi.h"
#else // not WIN32
# include <unistd.h>
#endif // WIN32
diff --git a/src/common/showmsg.h b/src/common/showmsg.h
index 48e763c25..63e42ab57 100644
--- a/src/common/showmsg.h
+++ b/src/common/showmsg.h
@@ -5,16 +5,16 @@
#ifndef COMMON_SHOWMSG_H
#define COMMON_SHOWMSG_H
-#include <stdarg.h>
-
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
#ifdef HERCULES_CORE
-# include "../../3rdparty/libconfig/libconfig.h"
+# include <libconfig/libconfig.h>
#else
-# include "../common/HPMi.h"
+# include "common/HPMi.h"
#endif
+#include <stdarg.h>
+
// for help with the console colors look here:
// http://www.edoceo.com/liberum/?doc=printf-with-color
// some code explanation (used here):
@@ -23,58 +23,55 @@
// \033[0m : reset color parameter
// \033[1m : use bold for font
-#define CL_RESET "\033[0m"
-#define CL_CLS "\033[2J"
-#define CL_CLL "\033[K"
+#define CL_RESET "\033[0m"
+#define CL_CLS "\033[2J"
+#define CL_CLL "\033[K"
// font settings
-#define CL_BOLD "\033[1m"
-#define CL_NORM CL_RESET
-#define CL_NORMAL CL_RESET
-#define CL_NONE CL_RESET
-// foreground color and bold font (bright color on windows)
-#define CL_WHITE "\033[1;37m"
-#define CL_GRAY "\033[1;30m"
-#define CL_RED "\033[1;31m"
-#define CL_GREEN "\033[1;32m"
-#define CL_YELLOW "\033[1;33m"
-#define CL_BLUE "\033[1;34m"
-#define CL_MAGENTA "\033[1;35m"
-#define CL_CYAN "\033[1;36m"
+#define CL_BOLD "\033[1m"
+#define CL_NORM CL_RESET
+#define CL_NORMAL CL_RESET
+#define CL_NONE CL_RESET
// background color
-#define CL_BG_BLACK "\033[40m"
-#define CL_BG_RED "\033[41m"
-#define CL_BG_GREEN "\033[42m"
-#define CL_BG_YELLOW "\033[43m"
-#define CL_BG_BLUE "\033[44m"
-#define CL_BG_MAGENTA "\033[45m"
-#define CL_BG_CYAN "\033[46m"
-#define CL_BG_WHITE "\033[47m"
+#define CL_BG_BLACK "\033[40m"
+#define CL_BG_RED "\033[41m"
+#define CL_BG_GREEN "\033[42m"
+#define CL_BG_YELLOW "\033[43m"
+#define CL_BG_BLUE "\033[44m"
+#define CL_BG_MAGENTA "\033[45m"
+#define CL_BG_CYAN "\033[46m"
+#define CL_BG_WHITE "\033[47m"
// foreground color and normal font (normal color on windows)
-#define CL_LT_BLACK "\033[0;30m"
-#define CL_LT_RED "\033[0;31m"
-#define CL_LT_GREEN "\033[0;32m"
-#define CL_LT_YELLOW "\033[0;33m"
-#define CL_LT_BLUE "\033[0;34m"
-#define CL_LT_MAGENTA "\033[0;35m"
-#define CL_LT_CYAN "\033[0;36m"
-#define CL_LT_WHITE "\033[0;37m"
+#define CL_LT_BLACK "\033[0;30m"
+#define CL_LT_RED "\033[0;31m"
+#define CL_LT_GREEN "\033[0;32m"
+#define CL_LT_YELLOW "\033[0;33m"
+#define CL_LT_BLUE "\033[0;34m"
+#define CL_LT_MAGENTA "\033[0;35m"
+#define CL_LT_CYAN "\033[0;36m"
+#define CL_LT_WHITE "\033[0;37m"
// foreground color and bold font (bright color on windows)
-#define CL_BT_BLACK "\033[1;30m"
-#define CL_BT_RED "\033[1;31m"
-#define CL_BT_GREEN "\033[1;32m"
-#define CL_BT_YELLOW "\033[1;33m"
-#define CL_BT_BLUE "\033[1;34m"
-#define CL_BT_MAGENTA "\033[1;35m"
-#define CL_BT_CYAN "\033[1;36m"
-#define CL_BT_WHITE "\033[1;37m"
+#define CL_BT_BLACK "\033[1;30m"
+#define CL_BT_RED "\033[1;31m"
+#define CL_BT_GREEN "\033[1;32m"
+#define CL_BT_YELLOW "\033[1;33m"
+#define CL_BT_BLUE "\033[1;34m"
+#define CL_BT_MAGENTA "\033[1;35m"
+#define CL_BT_CYAN "\033[1;36m"
+#define CL_BT_WHITE "\033[1;37m"
-#define CL_WTBL "\033[37;44m" // white on blue
-#define CL_XXBL "\033[0;44m" // default on blue
-#define CL_PASS "\033[0;32;42m" // green on green
+// foreground color and bold font (bright color on windows)
+#define CL_WHITE CL_BT_WHITE
+#define CL_GRAY CL_BT_BLACK
+#define CL_RED CL_BT_RED
+#define CL_GREEN CL_BT_GREEN
+#define CL_YELLOW CL_BT_YELLOW
+#define CL_BLUE CL_BT_BLUE
+#define CL_MAGENTA CL_BT_MAGENTA
+#define CL_CYAN CL_BT_CYAN
-#define CL_SPACE " " // space equivalent of the print messages
+#define CL_SPACE " " // space aquivalent of the print messages
enum msg_type {
MSG_NONE,
diff --git a/src/common/socket.c b/src/common/socket.c
index 1b7f36f8b..17c31db50 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -4,26 +4,26 @@
#define HERCULES_CORE
-#include "../config/core.h" // SHOW_SERVER_STATS
+#include "config/core.h" // SHOW_SERVER_STATS
#define H_SOCKET_C
#include "socket.h"
#undef H_SOCKET_C
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/types.h>
-#include "../common/HPM.h"
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-
#ifdef WIN32
-# include "../common/winapi.h"
+# include "common/winapi.h"
#else
# include <arpa/inet.h>
# include <errno.h>
diff --git a/src/common/socket.h b/src/common/socket.h
index 6323a6862..bd5d9baa2 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -5,12 +5,10 @@
#ifndef COMMON_SOCKET_H
#define COMMON_SOCKET_H
-#include <time.h>
-
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
#ifdef WIN32
-# include "../common/winapi.h"
+# include "common/winapi.h"
typedef long in_addr_t;
#else
# include <netinet/in.h>
diff --git a/src/common/spinlock.h b/src/common/spinlock.h
index 413067b68..811b239df 100644
--- a/src/common/spinlock.h
+++ b/src/common/spinlock.h
@@ -14,12 +14,12 @@
//
//
-#include "../common/atomic.h"
-#include "../common/cbasetypes.h"
-#include "../common/thread.h"
+#include "common/atomic.h"
+#include "common/cbasetypes.h"
+#include "common/thread.h"
#ifdef WIN32
-#include "../common/winapi.h"
+#include "common/winapi.h"
#endif
#ifdef WIN32
diff --git a/src/common/sql.c b/src/common/sql.c
index 4ca14d43b..a93092533 100644
--- a/src/common/sql.c
+++ b/src/common/sql.c
@@ -6,19 +6,17 @@
#include "sql.h"
-#include <stdlib.h> // strtoul
-#include <string.h> // strlen/strnlen/memcpy/memset
-
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
+#include "common/cbasetypes.h"
+#include "common/malloc.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+#include "common/timer.h"
#ifdef WIN32
-# include "../common/winapi.h" // Needed before mysql.h
+# include "common/winapi.h" // Needed before mysql.h
#endif
#include <mysql.h>
+#include <stdlib.h> // strtoul
void hercules_mysql_error_handler(unsigned int ecode);
diff --git a/src/common/sql.h b/src/common/sql.h
index c3598273e..d76b4f9d4 100644
--- a/src/common/sql.h
+++ b/src/common/sql.h
@@ -5,9 +5,9 @@
#ifndef COMMON_SQL_H
#define COMMON_SQL_H
-#include <stdarg.h>// va_list
+#include "common/cbasetypes.h"
-#include "../common/cbasetypes.h"
+#include <stdarg.h>// va_list
// Return codes
#define SQL_ERROR (-1)
diff --git a/src/common/strlib.c b/src/common/strlib.c
index b5fcff576..555f591e6 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -8,14 +8,14 @@
#include "strlib.h"
#undef H_STRLIB_C
+#include "common/cbasetypes.h"
+#include "common/malloc.h"
+#include "common/showmsg.h"
+
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h"
-#include "../common/showmsg.h"
-
#define J_MAX_MALLOC_SIZE 65535
struct strlib_interface strlib_s;
diff --git a/src/common/strlib.h b/src/common/strlib.h
index c687d9e17..a768ebff5 100644
--- a/src/common/strlib.h
+++ b/src/common/strlib.h
@@ -5,11 +5,11 @@
#ifndef COMMON_STRLIB_H
#define COMMON_STRLIB_H
+#include "common/cbasetypes.h"
+
#include <stdarg.h>
#include <string.h>
-#include "../common/cbasetypes.h"
-
#ifdef WIN32
#define HAVE_STRTOK_R
#define strtok_r(s,delim,save_ptr) strtok_r_((s),(delim),(save_ptr))
diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c
index a1dbed4d1..a27357e7e 100644
--- a/src/common/sysinfo.c
+++ b/src/common/sysinfo.c
@@ -1,6 +1,6 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
-// Base Author: Haru @ http://hercules.ws
+// Base Author: Haru @ http://herc.ws
/// See sysinfo.h for a description of this file
@@ -8,16 +8,14 @@
#include "sysinfo.h"
+#include "common/cbasetypes.h"
+#include "common/core.h"
+#include "common/malloc.h"
+#include "common/strlib.h"
+
#include <stdio.h> // fopen
#include <stdlib.h> // atoi
-
-#include "../common/cbasetypes.h"
-#include "../common/core.h"
-#include "../common/malloc.h"
-#include "../common/strlib.h"
-
#ifdef WIN32
-# include <string.h> // strlen
# include <windows.h>
#else
# include <unistd.h>
diff --git a/src/common/sysinfo.h b/src/common/sysinfo.h
index 70f665071..3c0d01ca1 100644
--- a/src/common/sysinfo.h
+++ b/src/common/sysinfo.h
@@ -1,6 +1,6 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
-// Base Author: Haru @ http://hercules.ws
+// Base Author: Haru @ http://herc.ws
#ifndef COMMON_SYSINFO_H
#define COMMON_SYSINFO_H
@@ -11,7 +11,7 @@
* cached at compile time)
*/
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
struct sysinfo_private;
diff --git a/src/common/thread.c b/src/common/thread.c
index 95212b4b0..9b9308d06 100644
--- a/src/common/thread.c
+++ b/src/common/thread.c
@@ -10,10 +10,13 @@
#include "thread.h"
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
+#include "common/malloc.h"
+#include "common/showmsg.h"
+#include "common/sysinfo.h" // sysinfo->getpagesize()
#ifdef WIN32
-# include "../common/winapi.h"
+# include "common/winapi.h"
# define __thread __declspec( thread )
#else
# include <pthread.h>
@@ -24,10 +27,6 @@
# include <unistd.h>
#endif
-#include "../common/malloc.h"
-#include "../common/showmsg.h"
-#include "../common/sysinfo.h" // sysinfo->getpagesize()
-
// When Compiling using MSC (on win32..) we know we have support in any case!
#ifdef _MSC_VER
#define HAS_TLS
diff --git a/src/common/thread.h b/src/common/thread.h
index f79eb77f9..36ea006b3 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -4,7 +4,7 @@
#ifndef COMMON_THREAD_H
#define COMMON_THREAD_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
typedef struct rAthread rAthread;
typedef void* (*rAthreadProc)(void*);
diff --git a/src/common/timer.c b/src/common/timer.c
index 45dbb9f50..06309642e 100644
--- a/src/common/timer.c
+++ b/src/common/timer.c
@@ -6,24 +6,23 @@
#include "timer.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/showmsg.h"
-#include "../common/utils.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/showmsg.h"
+#include "common/utils.h"
#ifdef WIN32
-# include "../common/winapi.h" // GetTickCount()
+# include "common/winapi.h" // GetTickCount()
#else
# include <sys/time.h> // struct timeval, gettimeofday()
# include <unistd.h>
#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
struct timer_interface timer_s;
// If the server can't handle processing thousands of monsters
diff --git a/src/common/timer.h b/src/common/timer.h
index 6e8a72389..46a036ec7 100644
--- a/src/common/timer.h
+++ b/src/common/timer.h
@@ -5,7 +5,7 @@
#ifndef COMMON_TIMER_H
#define COMMON_TIMER_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
#define DIFF_TICK(a,b) ((a)-(b))
#define DIFF_TICK32(a,b) ((int32)((a)-(b)))
diff --git a/src/common/utils.c b/src/common/utils.c
index ad68706ca..07e2e9fdf 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -6,32 +6,28 @@
#include "utils.h"
-#include <math.h> // floor()
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h> // cache purposes [Ind/Hercules]
-
-#include "../common/cbasetypes.h"
-#include "../common/core.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
+#include "common/cbasetypes.h"
+#include "common/core.h"
+#include "common/mmo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
#ifdef WIN32
-# include "../common/winapi.h"
+# include "common/winapi.h"
# ifndef F_OK
# define F_OK 0x0
# endif /* F_OK */
#else
# include <dirent.h>
-# include <sys/stat.h>
# include <unistd.h>
#endif
+#include <math.h> // floor()
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h> // cache purposes [Ind/Hercules]
+
struct HCache_interface HCache_s;
/// Dumps given buffer into file pointed to by a handle.
diff --git a/src/common/utils.h b/src/common/utils.h
index e6102f184..0ac818468 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -5,10 +5,9 @@
#ifndef COMMON_UTILS_H
#define COMMON_UTILS_H
-#include <stdio.h> // FILE*
-#include <time.h>
+#include "common/cbasetypes.h"
-#include "../common/cbasetypes.h"
+#include <stdio.h> // FILE*
/* [HCache] 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */
#define HCACHE_KEY 'k'
diff --git a/src/config/classes/general.h b/src/config/classes/general.h
index b75c907e3..bf9c05bf5 100644
--- a/src/config/classes/general.h
+++ b/src/config/classes/general.h
@@ -5,7 +5,7 @@
#define CONFIG_GENERAL_H
/**
- * Hercules configuration file (http://hercules.ws)
+ * Hercules configuration file (http://herc.ws)
**/
/**
diff --git a/src/config/const.h b/src/config/const.h
index e10d2ad2a..b6eb5db77 100644
--- a/src/config/const.h
+++ b/src/config/const.h
@@ -6,8 +6,8 @@
#define CONFIG_CONSTANTS_H
/**
- * Hercules configuration file (http://hercules.ws)
- * For detailed guidance on these check http://hercules.ws/wiki/SRC/config/
+ * Hercules configuration file (http://herc.ws)
+ * For detailed guidance on these check http://herc.ws/wiki/SRC/config/
**/
/**
diff --git a/src/config/renewal.h b/src/config/renewal.h
index 939ad9b73..e4b8e699b 100644
--- a/src/config/renewal.h
+++ b/src/config/renewal.h
@@ -5,8 +5,8 @@
#define CONFIG_RENEWAL_H
/**
- * Hercules configuration file (http://hercules.ws)
- * For detailed guidance on these check http://hercules.ws/wiki/SRC/config/
+ * Hercules configuration file (http://herc.ws)
+ * For detailed guidance on these check http://herc.ws/wiki/SRC/config/
**/
/**
@@ -74,7 +74,6 @@
#define RENEWAL_EDP
/// renewal ASPD [malufett]
-/// (disable by commenting the line)
///
/// leave this line to enable renewal ASPD
/// - shield penalty is applied
diff --git a/src/config/secure.h b/src/config/secure.h
index 418d24751..67f7a972b 100644
--- a/src/config/secure.h
+++ b/src/config/secure.h
@@ -5,8 +5,8 @@
#define CONFIG_SECURE_H
/**
- * Hercules configuration file (http://hercules.ws)
- * For detailed guidance on these check http://hercules.ws/wiki/SRC/config/
+ * Hercules configuration file (http://herc.ws)
+ * For detailed guidance on these check http://herc.ws/wiki/SRC/config/
**/
/**
diff --git a/src/login/HPMlogin.c b/src/login/HPMlogin.c
index 6b223d249..129f88c38 100644
--- a/src/login/HPMlogin.c
+++ b/src/login/HPMlogin.c
@@ -5,26 +5,34 @@
#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"
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+
+#if 0 // TODO (HPMDataCheck is disabled for the time being)
+#include "login/account.h"
+#include "login/login.h"
+#include "common/HPMi.h"
+#include "common/conf.h"
+#include "common/console.h"
+#include "common/core.h"
+#include "common/db.h"
+#include "common/des.h"
+#include "common/ers.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/spinlock.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+#include "common/sysinfo.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
+// HPMDataCheck comes after all the other includes
+#include "common/HPMDataCheck.h"
+#endif
bool HPM_login_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr) {
/* record address */
diff --git a/src/login/HPMlogin.h b/src/login/HPMlogin.h
index 6e01eae01..2a4d5c538 100644
--- a/src/login/HPMlogin.h
+++ b/src/login/HPMlogin.h
@@ -8,8 +8,8 @@
#error You should never include HPMlogin.h from a plugin.
#endif
-#include "../common/cbasetypes.h"
-#include "../common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/HPM.h"
struct hplugin;
diff --git a/src/login/Makefile.in b/src/login/Makefile.in
index 9b1db69c2..60382dc87 100644
--- a/src/login/Makefile.in
+++ b/src/login/Makefile.in
@@ -9,18 +9,20 @@ CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h)
COMMON_D = ../common
COMMON_H = $(wildcard $(COMMON_D)/*.h)
SYSINFO_INC = $(COMMON_D)/sysinfo.inc
+COMMON_INCLUDE = -I..
-LIBCONFIG_D = ../../3rdparty/libconfig
+THIRDPARTY_D = ../../3rdparty
+THIRDPARTY_INCLUDE = -I$(THIRDPARTY_D)
+
+LIBCONFIG_D = $(THIRDPARTY_D)/libconfig
LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
scanner.o strbuf.o)
LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
scanctx.h scanner.h strbuf.h wincompat.h)
-LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
-MT19937AR_D = ../../3rdparty/mt19937ar
+MT19937AR_D = $(THIRDPARTY_D)/mt19937ar
MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
-MT19937AR_INCLUDE = -I$(MT19937AR_D)
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)))
@@ -94,7 +96,7 @@ login-server: ../../login-server@EXEEXT@
obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql
@echo " CC $<"
- @$(CC) @CFLAGS@ @DEFS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+ @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing object files
$(COMMON_D)/obj_all/common.a:
diff --git a/src/login/account.h b/src/login/account.h
index 82ae28bbb..1e95c19de 100644
--- a/src/login/account.h
+++ b/src/login/account.h
@@ -5,9 +5,9 @@
#ifndef LOGIN_ACCOUNT_H
#define LOGIN_ACCOUNT_H
-#include "../common/cbasetypes.h"
-#include "../common/mmo.h" // ACCOUNT_REG2_NUM
-#include "../common/sql.h" // Sql
+#include "common/cbasetypes.h"
+#include "common/mmo.h" // ACCOUNT_REG2_NUM
+#include "common/sql.h" // Sql
typedef struct AccountDB AccountDB;
typedef struct AccountDBIterator AccountDBIterator;
diff --git a/src/login/account_sql.c b/src/login/account_sql.c
index f745d3d13..37837fc35 100644
--- a/src/login/account_sql.c
+++ b/src/login/account_sql.c
@@ -4,20 +4,20 @@
#define HERCULES_CORE
-#include "../config/core.h" // CONSOLE_INPUT
+#include "config/core.h" // CONSOLE_INPUT
#include "account.h"
-#include <stdlib.h>
-#include <string.h>
+#include "common/cbasetypes.h"
+#include "common/console.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/sql.h"
+#include "common/strlib.h"
-#include "../common/console.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/sql.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
+#include <stdlib.h>
/// global defines
#define ACCOUNT_SQL_DB_VERSION 20110114
@@ -136,6 +136,7 @@ static bool account_db_sql_init(AccountDB* self)
const char* database;
const char* codepage;
+ nullpo_ret(db);
db->accounts = SQL->Malloc();
sql_handle = db->accounts;
@@ -181,6 +182,7 @@ static void account_db_sql_destroy(AccountDB* self)
{
AccountDB_SQL* db = (AccountDB_SQL*)self;
+ nullpo_retv(db);
SQL->Free(db->accounts);
db->accounts = NULL;
aFree(db);
@@ -192,6 +194,9 @@ static bool account_db_sql_get_property(AccountDB* self, const char* key, char*
AccountDB_SQL* db = (AccountDB_SQL*)self;
const char* signature;
+ nullpo_ret(db);
+ nullpo_ret(key);
+ nullpo_ret(buf);
signature = "engine.";
if( strncmpi(key, signature, strlen(signature)) == 0 )
{
@@ -282,7 +287,9 @@ static bool account_db_sql_set_property(AccountDB* self, const char* key, const
AccountDB_SQL* db = (AccountDB_SQL*)self;
const char* signature;
-
+ nullpo_ret(db);
+ nullpo_ret(key);
+ nullpo_ret(value);
signature = "sql.";
if( strncmp(key, signature, strlen(signature)) == 0 )
{
@@ -356,10 +363,13 @@ static bool account_db_sql_set_property(AccountDB* self, const char* key, const
static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc)
{
AccountDB_SQL* db = (AccountDB_SQL*)self;
- Sql* sql_handle = db->accounts;
+ Sql* sql_handle;
// decide on the account id to assign
int account_id;
+ nullpo_ret(db);
+ nullpo_ret(acc);
+ sql_handle = db->accounts;
if( acc->account_id != -1 )
{// caller specifies it manually
account_id = acc->account_id;
@@ -407,9 +417,11 @@ static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc)
static bool account_db_sql_remove(AccountDB* self, const int account_id)
{
AccountDB_SQL* db = (AccountDB_SQL*)self;
- Sql* sql_handle = db->accounts;
+ Sql* sql_handle;
bool result = false;
+ nullpo_ret(db);
+ sql_handle = db->accounts;
if( SQL_SUCCESS != SQL->QueryStr(sql_handle, "START TRANSACTION")
|| SQL_SUCCESS != SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = %d", db->account_db, account_id)
|| SQL_SUCCESS != SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = %d", db->global_acc_reg_num_db, account_id)
@@ -442,11 +454,13 @@ static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, co
static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, const char* userid)
{
AccountDB_SQL* db = (AccountDB_SQL*)self;
- Sql* sql_handle = db->accounts;
+ Sql* sql_handle;
char esc_userid[2*NAME_LENGTH+1];
int account_id;
char* data;
+ nullpo_ret(db);
+ sql_handle = db->accounts;
SQL->EscapeString(sql_handle, esc_userid, userid);
// get the list of account IDs for this user ID
@@ -481,8 +495,10 @@ static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, co
static AccountDBIterator* account_db_sql_iterator(AccountDB* self)
{
AccountDB_SQL* db = (AccountDB_SQL*)self;
- AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)aCalloc(1, sizeof(AccountDBIterator_SQL));
+ AccountDBIterator_SQL* iter;
+ nullpo_retr(NULL, db);
+ iter = (AccountDBIterator_SQL*)aCalloc(1, sizeof(AccountDBIterator_SQL));
// set up the vtable
iter->vtable.destroy = &account_db_sql_iter_destroy;
iter->vtable.next = &account_db_sql_iter_next;
@@ -507,10 +523,14 @@ static void account_db_sql_iter_destroy(AccountDBIterator* self)
static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account* acc)
{
AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)self;
- AccountDB_SQL* db = (AccountDB_SQL*)iter->db;
- Sql* sql_handle = db->accounts;
+ AccountDB_SQL* db;
+ Sql* sql_handle;
char* data;
+ nullpo_ret(iter);
+ db = (AccountDB_SQL*)iter->db;
+ nullpo_ret(db);
+ sql_handle = db->accounts;
// get next account ID
if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id` FROM `%s` WHERE `account_id` > '%d' ORDER BY `account_id` ASC LIMIT 1",
db->account_db, iter->last_account_id) )
@@ -539,9 +559,12 @@ static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account
static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int account_id)
{
- Sql* sql_handle = db->accounts;
+ Sql* sql_handle;
char* data;
+ nullpo_ret(db);
+ nullpo_ret(acc);
+ sql_handle = db->accounts;
// retrieve login entry for the specified account
if( SQL_ERROR == SQL->Query(sql_handle,
"SELECT `account_id`,`userid`,`user_pass`,`sex`,`email`,`group_id`,`state`,`unban_time`,`expiration_time`,`logincount`,`lastlogin`,`last_ip`,`birthdate`,`character_slots`,`pincode`,`pincode_change` FROM `%s` WHERE `account_id` = %d",
@@ -581,10 +604,15 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc
static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, bool is_new)
{
- Sql* sql_handle = db->accounts;
- SqlStmt* stmt = SQL->StmtMalloc(sql_handle);
+ Sql* sql_handle;
+ SqlStmt* stmt;
bool result = false;
+ nullpo_ret(db);
+ nullpo_ret(acc);
+ sql_handle = db->accounts;
+ stmt = SQL->StmtMalloc(sql_handle);
+
// try
do
{
@@ -662,10 +690,12 @@ Sql* account_db_sql_up(AccountDB* self) {
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;
+ Sql* sql_handle;
AccountDB_SQL* db = (AccountDB_SQL*)self;
int count = RFIFOW(fd, 12);
+ nullpo_retv(db);
+ sql_handle = db->accounts;
if (count) {
int cursor = 14, i;
char key[32], sval[254];
@@ -709,12 +739,14 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
}
void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
- Sql* sql_handle = ((AccountDB_SQL*)self)->accounts;
+ Sql* sql_handle;
AccountDB_SQL* db = (AccountDB_SQL*)self;
char* data;
int plen = 0;
size_t len;
+ nullpo_retv(db);
+ sql_handle = db->accounts;
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);
diff --git a/src/login/ipban.h b/src/login/ipban.h
index c6535ec10..8f3cac16c 100644
--- a/src/login/ipban.h
+++ b/src/login/ipban.h
@@ -4,7 +4,7 @@
#ifndef LOGIN_IPBAN_H
#define LOGIN_IPBAN_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
#ifdef HERCULES_CORE
// TODO: Interface
diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c
index bfc90ad11..b4fce009d 100644
--- a/src/login/ipban_sql.c
+++ b/src/login/ipban_sql.c
@@ -6,18 +6,15 @@
#include "ipban.h"
+#include "login/login.h"
+#include "login/loginlog.h"
+#include "common/cbasetypes.h"
+#include "common/nullpo.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+
#include <stdlib.h>
-#include <string.h>
-
-#include "login.h"
-#include "loginlog.h"
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/sql.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
// global sql settings
static char global_db_hostname[32] = "127.0.0.1";
@@ -118,6 +115,8 @@ bool ipban_config_read(const char* key, const char* value)
{
const char* signature;
+ nullpo_ret(key);
+ nullpo_ret(value);
if( ipban_inited )
return false;// settings can only be changed before init
@@ -220,8 +219,8 @@ bool ipban_check(uint32 ip)
return true;
}
- if( SQL_ERROR == SQL->NextRow(sql_handle) )
- return true;// Shouldn't happen, but just in case...
+ if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ return false;
SQL->GetData(sql_handle, 0, &data, NULL);
matches = atoi(data);
@@ -244,9 +243,11 @@ void ipban_log(uint32 ip)
if( failures >= login_config.dynamic_pass_failure_ban_limit )
{
uint8* p = (uint8*)&ip;
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s`(`list`,`btime`,`rtime`,`reason`) VALUES ('%u.%u.%u.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban')",
- ipban_table, p[3], p[2], p[1], login_config.dynamic_pass_failure_ban_duration) )
+ if (SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s`(`list`,`btime`,`rtime`,`reason`) VALUES ('%u.%u.%u.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban')",
+ ipban_table, p[3], p[2], p[1], login_config.dynamic_pass_failure_ban_duration))
+ {
Sql_ShowDebug(sql_handle);
+ }
}
}
diff --git a/src/login/login.c b/src/login/login.c
index 846f24027..caace34da 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -6,25 +6,26 @@
#include "login.h"
+#include "login/HPMlogin.h"
+#include "login/account.h"
+#include "login/ipban.h"
+#include "login/loginlog.h"
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/core.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/md5calc.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#include "HPMlogin.h"
-#include "account.h"
-#include "ipban.h"
-#include "loginlog.h"
-#include "../common/HPM.h"
-#include "../common/core.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/md5calc.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
struct login_interface login_s;
struct Login_Config login_config;
@@ -98,6 +99,7 @@ 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);
+ nullpo_ret(p);
if( server_id == -1 )
{
p->char_server = -1;
@@ -118,6 +120,7 @@ static int login_online_db_setoffline(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);
+ nullpo_ret(character);
if (character->char_server == -2) //Unknown server.. set them offline
login->remove_online_user(character->account_id);
return 0;
@@ -136,6 +139,7 @@ int charif_sendallwos(int sfd, uint8* buf, size_t len)
{
int i, c;
+ nullpo_ret(buf);
for( i = 0, c = 0; i < ARRAYLENGTH(server); ++i )
{
int fd = server[i].fd;
@@ -155,6 +159,7 @@ int charif_sendallwos(int sfd, uint8* buf, size_t len)
/// Initializes a server structure.
void chrif_server_init(int id)
{
+ Assert_retv(id >= 0 && id < MAX_SERVERS);
memset(&server[id], 0, sizeof(server[id]));
server[id].fd = -1;
}
@@ -163,7 +168,8 @@ void chrif_server_init(int id)
/// Destroys a server structure.
void chrif_server_destroy(int id)
{
- if( server[id].fd != -1 )
+ Assert_retv(id >= 0 && id < MAX_SERVERS);
+ if (server[id].fd != -1)
{
do_close(server[id].fd);
server[id].fd = -1;
@@ -183,6 +189,7 @@ void chrif_server_reset(int id)
/// Called when the connection to Char Server is disconnected.
void chrif_on_disconnect(int id)
{
+ Assert_retv(id >= 0 && id < MAX_SERVERS);
ShowStatus("Char-server '%s' has disconnected.\n", server[id].name);
chrif_server_reset(id);
}
@@ -207,6 +214,9 @@ bool login_check_encrypted(const char* str1, const char* str2, const char* passw
{
char tmpstr[64+1], md5str[32+1];
+ nullpo_ret(str1);
+ nullpo_ret(str2);
+ nullpo_ret(passwd);
safesnprintf(tmpstr, sizeof(tmpstr), "%s%s", str1, str2);
MD5_String(tmpstr, md5str);
@@ -215,17 +225,16 @@ bool login_check_encrypted(const char* str1, const char* str2, const char* passw
bool login_check_password(const char* md5key, int passwdenc, const char* passwd, const char* refpass)
{
- if(passwdenc == 0)
- {
+ nullpo_ret(passwd);
+ nullpo_ret(refpass);
+ if(passwdenc == PWENC_NONE) {
return (0==strcmp(passwd, refpass));
- }
- else
- {
- // password mode set to 1 -> md5(md5key, refpass) enable with <passwordencrypt></passwordencrypt>
- // password mode set to 2 -> md5(refpass, md5key) enable with <passwordencrypt2></passwordencrypt2>
+ } else {
+ // password mode set to PWENC_ENCRYPT -> md5(md5key, refpass) enable with <passwordencrypt></passwordencrypt>
+ // password mode set to PWENC_ENCRYPT2 -> md5(refpass, md5key) enable with <passwordencrypt2></passwordencrypt2>
- return ((passwdenc&0x01) && login->check_encrypted(md5key, refpass, passwd)) ||
- ((passwdenc&0x02) && login->check_encrypted(refpass, md5key, passwd));
+ return ((passwdenc&PWENC_ENCRYPT) && login->check_encrypted(md5key, refpass, passwd)) ||
+ ((passwdenc&PWENC_ENCRYPT2) && login->check_encrypted(refpass, md5key, passwd));
}
}
@@ -248,6 +257,7 @@ int login_lan_config_read(const char *lancfgName)
int line_num = 0;
char line[1024], w1[64], w2[64], w3[64], w4[64];
+ nullpo_ret(lancfgName);
if((fp = fopen(lancfgName, "r")) == NULL) {
ShowWarning("LAN Support configuration file is not found: %s\n", lancfgName);
return 1;
@@ -348,6 +358,7 @@ void login_fromchar_parse_auth(int fd, int id, const char *const ip)
}
else
{// authentication not found
+ nullpo_retv(ip);
ShowStatus("Char-server '%s': authentication of the account %d REFUSED (ip: %s).\n", server[id].name, account_id, ip);
login->fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, NULL);
}
@@ -382,7 +393,7 @@ void login_fromchar_parse_request_change_email(int fd, int id, const char *const
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);
+ memcpy(acc.email, email, sizeof(acc.email));
ShowNotice("Char-server '%s': Create an e-mail on an account with a default e-mail (account: %d, new e-mail: %s, ip: %s).\n", server[id].name, account_id, email, ip);
// Save
accounts->save(accounts, &acc);
@@ -489,7 +500,7 @@ void login_fromchar_parse_change_email(int fd, int id, const char *const ip)
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);
+ safestrncpy(acc.email, new_email, sizeof(acc.email));
ShowNotice("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s).\n", server[id].name, account_id, acc.userid, new_email, ip);
// Save
accounts->save(accounts, &acc);
@@ -719,9 +730,9 @@ void login_fromchar_parse_change_pincode(int fd)
{
struct mmo_account acc;
- if( accounts->load_num(accounts, &acc, RFIFOL(fd,2) ) ) {
- safestrncpy( acc.pincode, (char*)RFIFOP(fd,6), sizeof(acc.pincode) );
- acc.pincode_change = ((unsigned int)time( NULL ));
+ if (accounts->load_num(accounts, &acc, RFIFOL(fd,2))) {
+ safestrncpy(acc.pincode, (char*)RFIFOP(fd,6), sizeof(acc.pincode));
+ acc.pincode_change = ((unsigned int)time(NULL));
accounts->save(accounts, &acc);
}
RFIFOSKIP(fd,11);
@@ -739,7 +750,7 @@ bool login_fromchar_parse_wrong_pincode(int fd)
return true;
}
- login_log(host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed");
+ login_log(host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed"); // FIXME: Do we really want to log this with the same code as successful logins?
}
login->remove_online_user(acc.account_id);
@@ -1008,6 +1019,9 @@ int login_mmo_auth_new(const char* userid, const char* pass, const char sex, con
int64 tick = timer->gettick();
struct mmo_account acc;
+ nullpo_retr(3, userid);
+ nullpo_retr(3, pass);
+ nullpo_retr(3, last_ip);
//Account Registration Flood Protection by [Kevin]
if( new_reg_tick == 0 )
new_reg_tick = timer->gettick();
@@ -1060,11 +1074,13 @@ int login_mmo_auth_new(const char* userid, const char* pass, const char sex, con
//-----------------------------------------------------
// Check/authentication of a connection
//-----------------------------------------------------
+// TODO: Map result values to an enum (or at least document them)
int login_mmo_auth(struct login_session_data* sd, bool isServer) {
struct mmo_account acc;
size_t len;
char ip[16];
+ nullpo_ret(sd);
ip2str(session[sd->fd]->client_addr, ip);
// DNS Blacklist check
@@ -1095,7 +1111,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) {
// Account creation with _M/_F
if( login_config.new_account_flag ) {
if (len > 2 && sd->passwd[0] != '\0' && // valid user and password lengths
- sd->passwdenc == 0 && // unencoded password
+ sd->passwdenc == PWENC_NONE && // unencoded password
sd->userid[len-2] == '_' && memchr("FfMm", sd->userid[len-1], 4)) // _M/_F suffix
{
int result;
@@ -1206,6 +1222,7 @@ void login_connection_problem(int fd, uint8 status)
void login_kick(struct login_session_data* sd)
{
uint8 buf[6];
+ nullpo_retv(sd);
WBUFW(buf,0) = 0x2734;
WBUFL(buf,2) = sd->account_id;
charif_sendallwos(-1, buf, 6);
@@ -1213,14 +1230,16 @@ void login_kick(struct login_session_data* sd)
void login_auth_ok(struct login_session_data* sd)
{
- int fd = sd->fd;
- uint32 ip = session[fd]->client_addr;
-
+ int fd = 0;
+ uint32 ip;
uint8 server_num, n;
uint32 subnet_char_ip;
struct login_auth_node* node;
int i;
+ nullpo_retv(sd);
+ fd = sd->fd;
+ ip = session[fd]->client_addr;
if( runflag != LOGINSERVER_ST_RUNNING )
{
// players can only login while running
@@ -1336,9 +1355,12 @@ void login_auth_ok(struct login_session_data* sd)
void login_auth_failed(struct login_session_data* sd, int result)
{
- int fd = sd->fd;
- uint32 ip = session[fd]->client_addr;
+ int fd;
+ uint32 ip;
+ nullpo_retv(sd);
+ fd = sd->fd;
+ ip = session[fd]->client_addr;
if (login_config.log_login)
{
const char* error;
@@ -1368,7 +1390,7 @@ void login_auth_failed(struct login_session_data* sd, int result)
default : error = "Unknown Error."; break;
}
- login_log(ip, sd->userid, result, error);
+ login_log(ip, sd->userid, result, error); // FIXME: result can be 100, conflicting with the value 100 we use for successful login...
}
if( result == 1 && login_config.dynamic_pass_failure_ban )
@@ -1409,11 +1431,13 @@ void login_login_error(int fd, uint8 status)
WFIFOSET(fd,23);
}
+void login_parse_ping(int fd, struct login_session_data* sd) __attribute__((nonnull (2)));
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) __attribute__((nonnull (2)));
void login_parse_client_md5(int fd, struct login_session_data* sd)
{
sd->has_client_hash = 1;
@@ -1422,6 +1446,7 @@ void login_parse_client_md5(int fd, struct login_session_data* sd)
RFIFOSKIP(fd,18);
}
+bool login_parse_client_login(int fd, struct login_session_data* sd, const char *const ip) __attribute__((nonnull (2)));
bool login_parse_client_login(int fd, struct login_session_data* sd, const char *const ip)
{
uint32 version;
@@ -1478,7 +1503,7 @@ bool login_parse_client_login(int fd, struct login_session_data* sd, const char
safestrncpy(sd->passwd, password, PASSWD_LEN);
if( login_config.use_md5_passwds )
MD5_String(sd->passwd, sd->passwd);
- sd->passwdenc = 0;
+ sd->passwdenc = PWENC_NONE;
}
else
{
@@ -1487,8 +1512,7 @@ bool login_parse_client_login(int fd, struct login_session_data* sd, const char
sd->passwdenc = PASSWORDENC;
}
- if( sd->passwdenc != 0 && login_config.use_md5_passwds )
- {
+ if (sd->passwdenc != PWENC_NONE && login_config.use_md5_passwds) {
login->auth_failed(sd, 3); // send "rejected from server"
return true;
}
@@ -1502,6 +1526,7 @@ bool login_parse_client_login(int fd, struct login_session_data* sd, const char
return false;
}
+void login_send_coding_key(int fd, struct login_session_data* sd) __attribute__((nonnull (2)));
void login_send_coding_key(int fd, struct login_session_data* sd)
{
WFIFOHEAD(fd,4 + sd->md5keylen);
@@ -1511,6 +1536,7 @@ void login_send_coding_key(int fd, struct login_session_data* sd)
WFIFOSET(fd,WFIFOW(fd,2));
}
+void login_parse_request_coding_key(int fd, struct login_session_data* sd) __attribute__((nonnull (2)));
void login_parse_request_coding_key(int fd, struct login_session_data* sd)
{
memset(sd->md5key, '\0', sizeof(sd->md5key));
@@ -1520,6 +1546,7 @@ void login_parse_request_coding_key(int fd, struct login_session_data* sd)
login->send_coding_key(fd, sd);
}
+void login_char_server_connection_status(int fd, struct login_session_data* sd, uint8 status) __attribute__((nonnull (2)));
void login_char_server_connection_status(int fd, struct login_session_data* sd, uint8 status)
{
WFIFOHEAD(fd,3);
@@ -1528,7 +1555,8 @@ void login_char_server_connection_status(int fd, struct login_session_data* sd,
WFIFOSET(fd,3);
}
-void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip)
+void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip, uint32 ipl) __attribute__((nonnull (2, 3)));
+void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip, uint32 ipl)
{
char server_name[20];
char message[256];
@@ -1542,7 +1570,7 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const
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->passwdenc = PWENC_NONE;
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));
@@ -1556,11 +1584,13 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const
login_log(session[fd]->client_addr, sd->userid, 100, message);
result = login->mmo_auth(sd, true);
- if( runflag == LOGINSERVER_ST_RUNNING &&
+ 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) )
+ sd->account_id >= 0 &&
+ sd->account_id < ARRAYLENGTH(server) &&
+ !session_isValid(server[sd->account_id].fd) &&
+ login->lan_subnetcheck(ipl))
{
ShowStatus("Connection of the char-server '%s' accepted.\n", server_name);
safestrncpy(server[sd->account_id].name, server_name, sizeof(server[sd->account_id].name));
@@ -1686,7 +1716,7 @@ int login_parse_login(int fd)
if (RFIFOREST(fd) < 86)
return 0;
{
- login->parse_request_connection(fd, sd, ip);
+ login->parse_request_connection(fd, sd, ip, ipl);
}
return 0; // processing will continue elsewhere
@@ -1738,7 +1768,9 @@ void login_set_defaults()
int login_config_read(const char* cfgName)
{
char line[1024], w1[1024], w2[1024];
- FILE* fp = fopen(cfgName, "r");
+ FILE* fp;
+ nullpo_retr(1, cfgName);
+ fp = fopen(cfgName, "r");
if (fp == NULL) {
ShowError("Configuration file (%s) not found.\n", cfgName);
return 1;
diff --git a/src/login/login.h b/src/login/login.h
index 7254b5db2..de504db07 100644
--- a/src/login/login.h
+++ b/src/login/login.h
@@ -5,8 +5,10 @@
#ifndef LOGIN_LOGIN_H
#define LOGIN_LOGIN_H
-#include "../common/core.h" // CORE_ST_LAST
-#include "../common/mmo.h" // NAME_LENGTH,SEX_*
+#include "common/cbasetypes.h"
+#include "common/core.h" // CORE_ST_LAST
+#include "common/db.h"
+#include "common/mmo.h" // NAME_LENGTH,SEX_*
struct mmo_account;
struct AccountDB;
@@ -18,8 +20,15 @@ enum E_LOGINSERVER_ST
LOGINSERVER_ST_LAST
};
-// supported encryption types: 1- passwordencrypt, 2- passwordencrypt2, 3- both
-#define PASSWORDENC 3
+enum password_enc {
+ PWENC_NONE = 0x0, ///< No encryption
+ PWENC_ENCRYPT = 0x1, ///< passwordencrypt
+ PWENC_ENCRYPT2 = 0x2, ///< passwordencrypt2
+ PWENC_BOTH = PWENC_ENCRYPT|PWENC_ENCRYPT2, ///< both the above
+};
+
+#define PASSWORDENC PWENC_BOTH
+
#define PASSWD_LEN (32+1) // 23+1 for plaintext, 32+1 for md5-ed passwords
struct login_session_data {
@@ -53,9 +62,9 @@ struct mmo_char_server {
int fd;
uint32 ip;
uint16 port;
- uint16 users; // user count on this server
- uint16 type; // 0=normal, 1=maintenance, 2=over 18, 3=paying, 4=P2P
- uint16 new_; // should display as 'new'?
+ uint16 users; ///< user count on this server
+ uint16 type; ///< 0=normal, 1=maintenance, 2=over 18, 3=paying, 4=P2P (@see e_char_server_type in mmo.h)
+ uint16 new_; ///< should display as 'new'?
};
struct client_hash_node {
@@ -195,7 +204,7 @@ struct login_interface {
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);
+ void (*parse_request_connection) (int fd, struct login_session_data* sd, const char *ip, uint32 ipl);
int (*parse_login) (int fd);
char *LOGIN_CONF_NAME;
char *LAN_CONF_NAME;
diff --git a/src/login/loginlog.h b/src/login/loginlog.h
index 2104ff277..f4327764a 100644
--- a/src/login/loginlog.h
+++ b/src/login/loginlog.h
@@ -4,7 +4,7 @@
#ifndef LOGIN_LOGINLOG_H
#define LOGIN_LOGINLOG_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
#ifdef HERCULES_CORE
// TODO: Interface
diff --git a/src/login/loginlog_sql.c b/src/login/loginlog_sql.c
index 5654b4c5b..da698e187 100644
--- a/src/login/loginlog_sql.c
+++ b/src/login/loginlog_sql.c
@@ -6,14 +6,14 @@
#include "loginlog.h"
-#include <string.h>
-#include <stdlib.h> // exit
+#include "common/cbasetypes.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/socket.h"
+#include "common/sql.h"
+#include "common/strlib.h"
-#include "../common/cbasetypes.h"
-#include "../common/mmo.h"
-#include "../common/socket.h"
-#include "../common/sql.h"
-#include "../common/strlib.h"
+#include <stdlib.h> // exit
// global sql settings (in ipban_sql.c)
static char global_db_hostname[32] = "127.0.0.1";
@@ -61,12 +61,15 @@ unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes)
/*=============================================
* Records an event in the login log
*---------------------------------------------*/
+// TODO: add an enum of rcode values
void login_log(uint32 ip, const char* username, int rcode, const char* message)
{
char esc_username[NAME_LENGTH*2+1];
char esc_message[255*2+1];
int retcode;
+ nullpo_retv(username);
+ nullpo_retv(message);
if( !enabled )
return;
@@ -137,6 +140,8 @@ bool loginlog_config_read(const char* key, const char* value)
{
const char* signature;
+ nullpo_ret(key);
+ nullpo_ret(value);
signature = "sql.";
if( strncmpi(key, signature, strlen(signature)) == 0 )
{
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index 3da49c3b9..7600d3d0c 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -5,63 +5,73 @@
#include "HPMmap.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+
+#include "common/HPMi.h"
+#include "common/conf.h"
+#include "common/console.h"
+#include "common/core.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/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/spinlock.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+#include "common/sysinfo.h"
+#include "common/timer.h"
+#include "common/utils.h"
+#include "map/atcommand.h"
+#include "map/battle.h"
+#include "map/battleground.h"
+#include "map/buyingstore.h"
+#include "map/channel.h"
+#include "map/chat.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/date.h"
+#include "map/duel.h"
+#include "map/elemental.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/instance.h"
+#include "map/intif.h"
+#include "map/irc-bot.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/mail.h"
+#include "map/map.h"
+#include "map/mapreg.h"
+#include "map/mercenary.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/packets_struct.h"
+#include "map/party.h"
+#include "map/path.h"
+#include "map/pc.h"
+#include "map/pc_groups.h"
+#include "map/pet.h"
+#include "map/quest.h"
+#include "map/script.h"
+#include "map/searchstore.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "map/storage.h"
+#include "map/trade.h"
+#include "map/unit.h"
+#include "map/vending.h"
-#include "atcommand.h"
-#include "battle.h"
-#include "battleground.h"
-#include "channel.h"
-#include "chat.h"
-#include "chrif.h"
-#include "clif.h"
-#include "date.h"
-#include "duel.h"
-#include "elemental.h"
-#include "guild.h"
-#include "homunculus.h"
-#include "instance.h"
-#include "intif.h"
-#include "irc-bot.h"
-#include "itemdb.h"
-#include "log.h"
-#include "mail.h"
-#include "map.h"
-#include "mapreg.h"
-#include "mercenary.h"
-#include "mob.h"
-#include "npc.h"
-#include "party.h"
-#include "path.h"
-#include "pc.h"
-#include "pc_groups.h"
-#include "pet.h"
-#include "quest.h"
-#include "script.h"
-#include "searchstore.h"
-#include "skill.h"
-#include "status.h"
-#include "storage.h"
-#include "trade.h"
-#include "unit.h"
-#include "vending.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"
+// HPMDataCheck comes after all the other includes
+#include "common/HPMDataCheck.h"
-#include "../common/HPMDataCheck.h"
+#include <stdio.h>
+#include <stdlib.h>
struct HPM_atcommand_list {
//tracking currently not enabled
@@ -114,6 +124,10 @@ bool HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataType
ret->HPDataSRCPtr = (void**)(&((struct item_data *)ptr)->hdata);
ret->hdatac = &((struct item_data *)ptr)->hdatac;
break;
+ case HPDT_BGDATA:
+ ret->HPDataSRCPtr = (void**)(&((struct battleground_data *)ptr)->hdata);
+ ret->hdatac = &((struct battleground_data *)ptr)->hdatac;
+ break;
default:
return false;
}
diff --git a/src/map/HPMmap.h b/src/map/HPMmap.h
index 0c727d017..00a8f43c3 100644
--- a/src/map/HPMmap.h
+++ b/src/map/HPMmap.h
@@ -8,9 +8,9 @@
#error You should never include HPMmap.h from a plugin.
#endif
-#include "../common/cbasetypes.h"
-#include "../map/atcommand.h"
-#include "../common/HPM.h"
+#include "map/atcommand.h"
+#include "common/cbasetypes.h"
+#include "common/HPM.h"
struct hplugin;
struct map_session_data;
diff --git a/src/map/Makefile.in b/src/map/Makefile.in
index 90bb55694..ac1b4d837 100644
--- a/src/map/Makefile.in
+++ b/src/map/Makefile.in
@@ -9,18 +9,20 @@ CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h)
COMMON_D = ../common
COMMON_H = $(wildcard $(COMMON_D)/*.h)
SYSINFO_INC = $(COMMON_D)/sysinfo.inc
+COMMON_INCLUDE = -I..
-LIBCONFIG_D = ../../3rdparty/libconfig
+THIRDPARTY_D = ../../3rdparty
+THIRDPARTY_INCLUDE = -I$(THIRDPARTY_D)
+
+LIBCONFIG_D = $(THIRDPARTY_D)/libconfig
LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
scanner.o strbuf.o)
LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
scanctx.h scanner.h strbuf.h wincompat.h)
-LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
-MT19937AR_D = ../../3rdparty/mt19937ar
+MT19937AR_D = $(THIRDPARTY_D)/mt19937ar
MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
-MT19937AR_INCLUDE = -I$(MT19937AR_D)
MAP_C = atcommand.c battle.c battleground.c buyingstore.c channel.c chat.c \
chrif.c clif.c date.c duel.c elemental.c guild.c homunculus.c HPMmap.c \
@@ -111,7 +113,7 @@ map-server: ../../map-server@EXEEXT@
obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql
@echo " CC $<"
- @$(CC) @CFLAGS@ @DEFS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+ @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing object files
$(COMMON_D)/obj_all/common.a:
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 560848c5b..fb0b89381 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -4,59 +4,59 @@
#define HERCULES_CORE
-#include "../config/core.h" // AUTOLOOTITEM_SIZE, AUTOTRADE_PERSISTENCY, MAX_SUGGESTIONS, MOB_FLEE(), MOB_HIT(), RENEWAL, RENEWAL_DROP, RENEWAL_EXP
+#include "config/core.h" // AUTOLOOTITEM_SIZE, AUTOTRADE_PERSISTENCY, MAX_SUGGESTIONS, MOB_FLEE(), MOB_HIT(), RENEWAL, RENEWAL_DROP, RENEWAL_EXP
#include "atcommand.h"
+#include "map/HPMmap.h"
+#include "map/battle.h"
+#include "map/channel.h"
+#include "map/chat.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/duel.h"
+#include "map/elemental.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/mail.h"
+#include "map/map.h"
+#include "map/mapreg.h"
+#include "map/mercenary.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/party.h"
+#include "map/pc.h"
+#include "map/pc_groups.h" // groupid2name
+#include "map/pet.h"
+#include "map/quest.h"
+#include "map/script.h"
+#include "map/searchstore.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "map/storage.h"
+#include "map/trade.h"
+#include "map/unit.h"
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/core.h"
+#include "common/malloc.h"
+#include "common/mmo.h" // MAX_CARTS
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/sysinfo.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "HPMmap.h"
-#include "battle.h"
-#include "channel.h"
-#include "chat.h"
-#include "chrif.h"
-#include "clif.h"
-#include "duel.h"
-#include "elemental.h"
-#include "guild.h"
-#include "homunculus.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "mail.h"
-#include "map.h"
-#include "mapreg.h"
-#include "mercenary.h"
-#include "mob.h"
-#include "npc.h"
-#include "party.h"
-#include "pc.h"
-#include "pc_groups.h" // groupid2name
-#include "pet.h"
-#include "quest.h"
-#include "script.h"
-#include "searchstore.h"
-#include "skill.h"
-#include "status.h"
-#include "storage.h"
-#include "trade.h"
-#include "unit.h"
-#include "../common/cbasetypes.h"
-#include "../common/conf.h"
-#include "../common/core.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h" // MAX_CARTS
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/sysinfo.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct atcommand_interface atcommand_s;
static char atcmd_output[CHAT_SIZE_MAX];
@@ -209,9 +209,10 @@ ACMD(send)
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) ) {
+ if (!message || !*message
+ || !((sscanf(message, "len %x", &type)==1 && (len=1))
+ || sscanf(message, "%x", &type)==1)
+ ) {
clif->message(fd, msg_fd(fd,900)); // Usage:
clif->message(fd, msg_fd(fd,901)); // @send len <packet hex number>
clif->message(fd, msg_fd(fd,902)); // @send <packet hex number> {<value>}*
@@ -663,7 +664,7 @@ ACMD(who) {
break;
}
}
- clif->colormes(fd, COLOR_DEFAULT, StrBuf->Value(&buf));/** for whatever reason clif->message crashes with some patterns, see bugreport:8186 **/
+ clif->messagecolor_self(fd, COLOR_DEFAULT, StrBuf->Value(&buf));/** for whatever reason clif->message crashes with some patterns, see bugreport:8186 **/
StrBuf->Clear(&buf);
count++;
}
@@ -875,12 +876,12 @@ ACMD(guildstorage)
if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
return false;
- if (sd->state.storage_flag == 1) {
+ if (sd->state.storage_flag == STORAGE_FLAG_NORMAL) {
clif->message(fd, msg_fd(fd,250));
return false;
}
- if (sd->state.storage_flag == 2) {
+ if (sd->state.storage_flag == STORAGE_FLAG_GUILD) {
clif->message(fd, msg_fd(fd,251));
return false;
}
@@ -1124,7 +1125,7 @@ ACMD(heal)
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->damage(&sd->bl,&sd->bl, 0, 0, -hp, 0, BDT_ENDURE, 0);
clif->message(fd, msg_fd(fd,156)); // HP or/and SP modified.
return true;
}
@@ -1135,7 +1136,7 @@ ACMD(heal)
status->heal(&sd->bl, hp, 0, 0);
else {
status->damage(NULL, &sd->bl, -hp, 0, 0, 0);
- clif->damage(&sd->bl,&sd->bl, 0, 0, -hp, 0, 4, 0);
+ clif->damage(&sd->bl,&sd->bl, 0, 0, -hp, 0, BDT_ENDURE, 0);
}
}
@@ -1344,7 +1345,7 @@ ACMD(itemreset)
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);
+ pc->delitem(sd, i, sd->status.inventory[i].amount, 0, DELITEM_NORMAL, LOG_TYPE_COMMAND);
}
}
clif->message(fd, msg_fd(fd,20)); // All of your items have been removed.
@@ -1443,7 +1444,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, PCRESETSKILL_NONE); //Reset skills since we need to subtract more points.
if (sd->status.skill_point < level)
sd->status.skill_point = 0;
else
@@ -2086,9 +2087,9 @@ ACMD(refine)
if (sd->status.inventory[idx].refine != final_refine) {
sd->status.inventory[idx].refine = final_refine;
current_position = sd->status.inventory[idx].equip;
- pc->unequipitem(sd, idx, 3);
+ pc->unequipitem(sd, idx, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
clif->refine(fd, 0, idx, sd->status.inventory[idx].refine);
- clif->delitem(sd, idx, 1, 3);
+ clif->delitem(sd, idx, 1, DELITEM_MATERIALCHANGE);
clif->additem(sd, idx, 1, 0);
pc->equipitem(sd, idx, current_position);
clif->misceffect(&sd->bl, 3);
@@ -2730,7 +2731,7 @@ ACMD(char_block)
return false;
}
- chrif->char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
+ chrif->char_ask_name(sd->status.account_id, atcmd_player_name, CHAR_ASK_NAME_BLOCK, 0, 0, 0, 0, 0, 0);
clif->message(fd, msg_fd(fd,88)); // Character name sent to char-server to ask it.
return true;
@@ -2826,7 +2827,8 @@ ACMD(char_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
+ chrif->char_ask_name(sd->status.account_id, atcmd_player_name,
+ !strcmpi(info->command,"charban") ? CHAR_ASK_NAME_CHARBAN : CHAR_ASK_NAME_BAN, year, month, day, hour, minute, second);
clif->message(fd, msg_fd(fd,88)); // Character name sent to char-server to ask it.
return true;
@@ -2845,7 +2847,7 @@ ACMD(char_unblock)
}
// 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
+ chrif->char_ask_name(sd->status.account_id, atcmd_player_name, CHAR_ASK_NAME_UNBLOCK, 0, 0, 0, 0, 0, 0);
clif->message(fd, msg_fd(fd,88)); // Character name sent to char-server to ask it.
return true;
@@ -2864,7 +2866,8 @@ ACMD(char_unban)
}
// 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
+ chrif->char_ask_name(sd->status.account_id, atcmd_player_name,
+ !strcmpi(info->command,"charunban") ? CHAR_ASK_NAME_CHARUNBAN : CHAR_ASK_NAME_UNBAN, 0, 0, 0, 0, 0, 0);
clif->message(fd, msg_fd(fd,88)); // Character name sent to char-server to ask it.
return true;
@@ -3101,7 +3104,7 @@ ACMD(questskill)
return false;
}
- pc->skill(sd, skill_id, 1, 0);
+ pc->skill(sd, skill_id, 1, SKILL_GRANT_PERMANENT);
clif->message(fd, msg_fd(fd,70)); // You have learned the skill.
return true;
@@ -5096,7 +5099,7 @@ ACMD(dropall)
for (i = 0; i < MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount) {
if(sd->status.inventory[i].equip != 0)
- pc->unequipitem(sd, i, 3);
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
pc->dropitem(sd, i, sd->status.inventory[i].amount);
}
}
@@ -5111,7 +5114,7 @@ ACMD(storeall)
{
int i;
- if (sd->state.storage_flag != 1) {
+ if (sd->state.storage_flag != STORAGE_FLAG_NORMAL) {
//Open storage.
if( storage->open(sd) == 1 ) {
clif->message(fd, msg_fd(fd,1161)); // You currently cannot open your storage.
@@ -5122,7 +5125,7 @@ ACMD(storeall)
for (i = 0; i < MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount) {
if(sd->status.inventory[i].equip != 0)
- pc->unequipitem(sd, i, 3);
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
storage->add(sd, i, sd->status.inventory[i].amount);
}
}
@@ -5136,7 +5139,7 @@ ACMD(clearstorage)
{
int i, j;
- if (sd->state.storage_flag == 1) {
+ if (sd->state.storage_flag == STORAGE_FLAG_NORMAL) {
clif->message(fd, msg_fd(fd,250));
return false;
}
@@ -5164,12 +5167,12 @@ ACMD(cleargstorage)
return false;
}
- if (sd->state.storage_flag == 1) {
+ if (sd->state.storage_flag == STORAGE_FLAG_NORMAL) {
clif->message(fd, msg_fd(fd,250));
return false;
}
- if (sd->state.storage_flag == 2) {
+ if (sd->state.storage_flag == STORAGE_FLAG_GUILD) {
clif->message(fd, msg_fd(fd,251));
return false;
}
@@ -5200,7 +5203,7 @@ ACMD(clearcart)
return false;
}
- if( sd->state.vending == 1 ) {
+ if (sd->state.vending) {
clif->message(fd, msg_fd(fd,548)); // You can't clean a cart while vending!
return false;
}
@@ -5241,11 +5244,11 @@ ACMD(skillid) {
for (data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key)) {
int idx = skill->get_index(DB->data2i(data));
- if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill->db[idx].desc, message, skillen) == 0) {
- sprintf(atcmd_output, msg_fd(fd,1164), DB->data2i(data), skill->db[idx].desc, key.str); // skill %d: %s (%s)
+ if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill->dbs->db[idx].desc, message, skillen) == 0) {
+ sprintf(atcmd_output, msg_fd(fd,1164), DB->data2i(data), skill->dbs->db[idx].desc, key.str); // skill %d: %s (%s)
clif->message(fd, atcmd_output);
- } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill->db[idx].desc,message) ) ) {
- snprintf(partials[found], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_fd(fd,1164), DB->data2i(data), skill->db[idx].desc, key.str);
+ } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill->dbs->db[idx].desc,message) ) ) {
+ snprintf(partials[found], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_fd(fd,1164), DB->data2i(data), skill->dbs->db[idx].desc, key.str);
found++;
}
}
@@ -5326,7 +5329,7 @@ ACMD(displayskill) {
}
st = status->get_status_data(&sd->bl);
tick = timer->gettick();
- clif->skill_damage(&sd->bl,&sd->bl, tick, st->amotion, st->dmotion, 1, 1, skill_id, skill_lv, 5);
+ clif->skill_damage(&sd->bl,&sd->bl, tick, st->amotion, st->dmotion, 1, 1, skill_id, skill_lv, BDT_SPLASH);
clif->skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
clif->skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
return true;
@@ -5373,7 +5376,7 @@ ACMD(skilltree) {
{
if( ent->need[j].id && pc->checkskill(sd,ent->need[j].id) < ent->need[j].lv)
{
- sprintf(atcmd_output, msg_fd(fd,1170), ent->need[j].lv, skill->db[ent->need[j].id].desc); // Player requires level %d of skill %s.
+ sprintf(atcmd_output, msg_fd(fd,1170), ent->need[j].lv, skill->dbs->db[ent->need[j].id].desc); // Player requires level %d of skill %s.
clif->message(fd, atcmd_output);
meets = 0;
}
@@ -5603,7 +5606,7 @@ ACMD(partyoption)
return false;
}
- option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
+ option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0); // TODO: Add documentation for these values
//Change item share type.
if (option != p->party.item)
@@ -6075,14 +6078,14 @@ ACMD(cleanmap) {
}
ACMD(cleanarea) {
- int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
+ int x0 = 0, y0 = 0, x1 = 0, y1 = 0, n = 0;
- if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
+ if (!message || !*message || (n=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) {
- map->foreachinrange(atcommand->cleanfloor_sub, &sd->bl, x0, BL_ITEM);
- } else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
+ } else if (n == 4) {
map->foreachinarea(atcommand->cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
+ } else {
+ map->foreachinrange(atcommand->cleanfloor_sub, &sd->bl, x0, BL_ITEM);
}
clif->message(fd, msg_fd(fd,1221)); // All dropped items have been cleaned up.
@@ -6244,10 +6247,9 @@ ACMD(users)
/*==========================================
*
*------------------------------------------*/
-ACMD(reset)
-{
+ACMD(reset) {
pc->resetstate(sd);
- pc->resetskill(sd,1);
+ pc->resetskill(sd, PCRESETSKILL_RESYNC);
sprintf(atcmd_output, msg_fd(fd,208), sd->status.name); // '%s' skill and stats points reseted!
clif->message(fd, atcmd_output);
return true;
@@ -6288,9 +6290,9 @@ ACMD(summon)
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);
+ md->master_id = sd->bl.id;
+ md->special_state.ai = AI_ATTACK;
+ md->deletetimer = timer->add(tick+(duration*60000),mob->timer_delete,md->bl.id,0);
clif->specialeffect(&md->bl,344,AREA);
mob->spawn(md);
sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
@@ -6423,15 +6425,14 @@ ACMD(uptime)
* @changesex <sex>
* => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
*------------------------------------------*/
-ACMD(changesex)
-{
+ACMD(changesex) {
int i;
- pc->resetskill(sd,4);
+ pc->resetskill(sd, PCRESETSKILL_CHSEX);
// to avoid any problem with equipment and invalid sex, equipment is unequipped.
for( i=0; i<EQI_MAX; i++ )
- if( sd->equip_index[i] >= 0 ) pc->unequipitem(sd, sd->equip_index[i], 3);
- chrif->changesex(sd);
+ if( sd->equip_index[i] >= 0 ) pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
+ chrif->changesex(sd, true);
return true;
}
@@ -6745,7 +6746,7 @@ ACMD(showmobs)
continue;
if( mob_id != -1 && md->class_ != mob_id )
continue;
- if( md->special_state.ai || md->master_id )
+ if (md->special_state.ai != AI_NONE || md->master_id)
continue; // hide slaves and player summoned mobs
if( md->spawn_timer != INVALID_TIMER )
continue; // hide mobs waiting for respawn
@@ -7804,13 +7805,15 @@ ACMD(cash)
if( !battle_config.cashshop_show_points ){
sprintf(output, msg_fd(fd,505), ret, sd->cashPoints);
clif_disp_onlyself(sd, output, strlen(output));
+ clif->message(fd, output);
}
} else
clif->message(fd, msg_fd(fd,149)); // Unable to decrease the number/value.
} else {
if( (ret=pc->paycash(sd, -value, 0)) >= 0){
sprintf(output, msg_fd(fd,410), ret, sd->cashPoints);
- clif_disp_onlyself(sd, output, strlen(output));
+ clif_disp_onlyself(sd, output, strlen(output));
+ clif->message(fd, output);
} else
clif->message(fd, msg_fd(fd,41)); // Unable to decrease the number/value.
}
@@ -7821,13 +7824,15 @@ ACMD(cash)
if( !battle_config.cashshop_show_points ){
sprintf(output, msg_fd(fd,506), ret, sd->kafraPoints);
clif_disp_onlyself(sd, output, strlen(output));
+ clif->message(fd, output);
}
} else
clif->message(fd, msg_fd(fd,149)); // Unable to decrease the number/value.
} else {
if( (ret=pc->paycash(sd, -value, -value)) >= 0){
sprintf(output, msg_fd(fd,411), ret, sd->kafraPoints);
- clif_disp_onlyself(sd, output, strlen(output));
+ clif_disp_onlyself(sd, output, strlen(output));
+ clif->message(fd, output);
} else
clif->message(fd, msg_fd(fd,41)); // Unable to decrease the number/value.
}
@@ -7940,10 +7945,10 @@ ACMD(feelreset)
/*==========================================
* AUCTION SYSTEM
*------------------------------------------*/
-ACMD(auction) {
-
- if( !battle_config.feature_auction ) {
- clif->colormes(sd->fd,COLOR_RED,msg_fd(fd,1484));
+ACMD(auction)
+{
+ if (!battle_config.feature_auction) {
+ clif->messagecolor_self(sd->fd, COLOR_RED, msg_fd(fd,1484));
return false;
}
@@ -7955,31 +7960,22 @@ ACMD(auction) {
/*==========================================
* Kill Steal Protection
*------------------------------------------*/
-ACMD(ksprotection)
-{
+ACMD(ksprotection) {
if( sd->state.noks ) {
- sd->state.noks = 0;
+ sd->state.noks = KSPROTECT_NONE;
clif->message(fd, msg_fd(fd,1325)); // [ K.S Protection Inactive ]
- }
- else
- {
- if( !message || !*message || !strcmpi(message, "party") )
- { // Default is Party
- sd->state.noks = 2;
- clif->message(fd, msg_fd(fd,1326)); // [ K.S Protection Active - Option: Party ]
- }
- else if( !strcmpi(message, "self") )
- {
- sd->state.noks = 1;
- clif->message(fd, msg_fd(fd,1327)); // [ K.S Protection Active - Option: Self ]
- }
- else if( !strcmpi(message, "guild") )
- {
- sd->state.noks = 3;
- clif->message(fd, msg_fd(fd,1328)); // [ K.S Protection Active - Option: Guild ]
- }
- else
- clif->message(fd, msg_fd(fd,1329)); // Usage: @noks <self|party|guild>
+ } else if( !message || !*message || strcmpi(message, "party") == 0 ) {
+ // Default is Party
+ sd->state.noks = KSPROTECT_PARTY;
+ clif->message(fd, msg_fd(fd,1326)); // [ K.S Protection Active - Option: Party ]
+ } else if( strcmpi(message, "self") == 0 ) {
+ sd->state.noks = KSPROTECT_SELF;
+ clif->message(fd, msg_fd(fd,1327)); // [ K.S Protection Active - Option: Self ]
+ } else if( strcmpi(message, "guild") == 0 ) {
+ sd->state.noks = KSPROTECT_GUILD;
+ clif->message(fd, msg_fd(fd,1328)); // [ K.S Protection Active - Option: Guild ]
+ } else {
+ clif->message(fd, msg_fd(fd,1329)); // Usage: @noks <self|party|guild>
}
return true;
}
@@ -8008,7 +8004,7 @@ ACMD(resetstat)
ACMD(resetskill)
{
- pc->resetskill(sd,1);
+ pc->resetskill(sd, PCRESETSKILL_RESYNC);
sprintf(atcmd_output, msg_fd(fd,206), sd->status.name);
clif->message(fd, atcmd_output);
return true;
@@ -8255,7 +8251,7 @@ ACMD(delitem) {
{// 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);
+ pc->delitem(sd, idx, delamount, 0, DELITEM_NORMAL, LOG_TYPE_COMMAND);
amount-= delamount;
}
@@ -8793,13 +8789,7 @@ ACMD(channel) {
unsigned short msg_len = 1;
msg_len += sprintf(mout, "[ %s list colors ] : %s", command, channel->config->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) = channel->config->colors[k];
- safestrncpy((char*)WFIFOP(fd,12), mout, msg_len);
- WFIFOSET(fd, msg_len + 12);
+ clif->messagecolor_self(fd, channel->config->colors[k], mout);
}
} else {
DBIterator *iter = db_iterator(channel->db);
@@ -9153,7 +9143,7 @@ ACMD(channel) {
return false;
} else {
channel->set_options(chan, chan->options | k);
- sprintf(atcmd_output, msg_fd(fd,1454), opt_str[k],chan->name);//option '%s' is now enabled for channel '%s'
+ sprintf(atcmd_output, msg_fd(fd,1450), opt_str[k],chan->name);//option '%s' is now enabled for channel '%s'
clif->message(fd, atcmd_output);
}
} else {
@@ -9185,13 +9175,7 @@ ACMD(fontcolor) {
for( k = 0; k < channel->config->colors_count; k++ ) {
msg_len += sprintf(mout, "[ %s ] : %s", command, channel->config->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) = channel->config->colors[k];
- safestrncpy((char*)WFIFOP(fd,12), mout, msg_len);
- WFIFOSET(fd, msg_len + 12);
+ clif->messagecolor_self(fd, channel->config->colors[k], mout);
}
return false;
}
@@ -9214,13 +9198,8 @@ ACMD(fontcolor) {
sd->fontcolor = k + 1;
msg_len += sprintf(mout, "Color changed to '%s'", channel->config->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) = channel->config->colors[k];
- safestrncpy((char*)WFIFOP(fd,12), mout, msg_len);
- WFIFOSET(fd, msg_len + 12);
+ clif->messagecolor_self(fd, channel->config->colors[k], mout);
+
return true;
}
ACMD(searchstore){
@@ -9327,7 +9306,7 @@ ACMD(cddebug) {
const struct TimerData *td = timer->get(cd->entry[i]->timer);
if( !td || td->func != skill->blockpc_end ) {
- clif->messages(fd,"Found invalid entry in slot %d for skill %s",i,skill->db[cd->entry[i]->skidx].name);
+ clif->messages(fd,"Found invalid entry in slot %d for skill %s",i,skill->dbs->db[cd->entry[i]->skidx].name);
sd->blockskill[cd->entry[i]->skidx] = false;
}
}
@@ -9337,7 +9316,7 @@ ACMD(cddebug) {
if( !cd || (message && *message && !strcmpi(message,"reset")) ) {
for(i = 0; i < MAX_SKILL; i++) {
if( sd->blockskill[i] ) {
- clif->messages(fd,"Found skill '%s', unblocking...",skill->db[i].name);
+ clif->messages(fd,"Found skill '%s', unblocking...",skill->dbs->db[i].name);
sd->blockskill[i] = false;
}
}
@@ -9959,11 +9938,12 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa
}
for(i = 0; i < map->list[sd->bl.m].zone->disabled_commands_count; i++) {
if( info->func == map->list[sd->bl.m].zone->disabled_commands[i]->cmd ) {
- if( pc_get_group_level(sd) < map->list[sd->bl.m].zone->disabled_commands[i]->group_lv ) {
- clif->colormes(sd->fd,COLOR_RED,"This command is disabled in this area");
+ if (pc_get_group_level(sd) < map->list[sd->bl.m].zone->disabled_commands[i]->group_lv) {
+ clif->messagecolor_self(sd->fd, COLOR_RED, "This command is disabled in this area");
return true;
- } else
+ } else {
break;/* already found the matching command, no need to keep checking -- just go on */
+ }
}
}
}
@@ -10263,7 +10243,7 @@ void atcommand_doload(void) {
void atcommand_expand_message_table(void) {
RECREATE(atcommand->msg_table, char **, ++atcommand->max_message_table);
- RECREATE(atcommand->msg_table[atcommand->max_message_table - 1], char *, MAX_MSG);
+ CREATE(atcommand->msg_table[atcommand->max_message_table - 1], char *, MAX_MSG);
}
void do_init_atcommand(bool minimal) {
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index c1f451ad3..88ddde8c2 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -5,9 +5,12 @@
#ifndef MAP_ATCOMMAND_H
#define MAP_ATCOMMAND_H
-#include "pc_groups.h"
-#include "../common/conf.h"
-#include "../common/db.h"
+#include "map/pc_groups.h"
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/db.h"
+
+#include <stdarg.h>
/**
* Declarations
diff --git a/src/map/battle.c b/src/map/battle.c
index b2ee9cf1d..3575dea6f 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -4,43 +4,43 @@
#define HERCULES_CORE
-#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, HMAP_ZONE_DAMAGE_CAP_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, RE_LVL_DMOD(), RE_LVL_MDMOD(), RE_LVL_TMDMOD(), RE_SKILL_REDUCTION(), SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, STATS_OPT_OUT
+#include "config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, HMAP_ZONE_DAMAGE_CAP_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, RE_LVL_DMOD(), RE_LVL_MDMOD(), RE_LVL_TMDMOD(), RE_SKILL_REDUCTION(), SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, STATS_OPT_OUT
#include "battle.h"
+#include "map/battleground.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/elemental.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/itemdb.h"
+#include "map/map.h"
+#include "map/mercenary.h"
+#include "map/mob.h"
+#include "map/party.h"
+#include "map/path.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/ers.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/sysinfo.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "battleground.h"
-#include "chrif.h"
-#include "clif.h"
-#include "elemental.h"
-#include "guild.h"
-#include "homunculus.h"
-#include "itemdb.h"
-#include "map.h"
-#include "mercenary.h"
-#include "mob.h"
-#include "party.h"
-#include "path.h"
-#include "pc.h"
-#include "pet.h"
-#include "skill.h"
-#include "status.h"
-#include "../common/HPM.h"
-#include "../common/cbasetypes.h"
-#include "../common/ers.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/sysinfo.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct Battle_Config battle_config;
struct battle_interface battle_s;
@@ -300,10 +300,10 @@ int battle_delay_damage(int64 tick, int amotion, struct block_list *src, struct
int battle_attr_ratio(int atk_elem,int def_type, int def_lv)
{
- if (atk_elem < 0 || atk_elem >= ELE_MAX)
+ if (atk_elem < ELE_NEUTRAL || atk_elem >= ELE_MAX)
return 100;
- if (def_type < 0 || def_type >= ELE_MAX || def_lv < 1 || def_lv > 4)
+ if (def_type < ELE_NEUTRAL || def_type >= ELE_MAX || def_lv < 1 || def_lv > 4)
return 100;
return battle->attr_fix_table[def_lv-1][atk_elem][def_type];
@@ -322,10 +322,10 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d
if (src) sc = status->get_sc(src);
if (target) tsc = status->get_sc(target);
- if (atk_elem < 0 || atk_elem >= ELE_MAX)
+ if (atk_elem < ELE_NEUTRAL || atk_elem >= ELE_MAX)
atk_elem = rnd()%ELE_MAX;
- if (def_type < 0 || def_type >= ELE_MAX ||
+ if (def_type < ELE_NEUTRAL || def_type >= ELE_MAX ||
def_lv < 1 || def_lv > 4) {
ShowError("battle_attr_fix: unknown attr type: atk=%d def_type=%d def_lv=%d\n",atk_elem,def_type,def_lv);
return damage;
@@ -407,6 +407,8 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d
else
return damage + (damage * (ratio - 100) / 100);
}
+
+//FIXME: Missing documentation for flag, flag2
int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, struct weapon_atk *watk, int nk, bool n_ele, short s_ele, short s_ele_, int size, int type, int flag, int flag2){ // [malufett]
#ifdef RENEWAL
int64 damage, eatk = 0;
@@ -421,41 +423,47 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u
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);
+ 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);
+ damage = battle->calc_sizefix(sd, damage, EQI_HAND_L, size, flag & 8);
- if( flag&2 && sd->bonus.arrow_atk )
+ if ( flag & 2 && sd->bonus.arrow_atk && skill_id != GN_CARTCANNON )
damage += sd->bonus.arrow_atk;
- if( sd->battle_status.equip_atk != 0 )
+ if ( sd->battle_status.equip_atk != 0 )
eatk = sd->base_status.equip_atk;
+
+ if ( sd->bonus.atk_rate )
+ damage += damage * sd->bonus.atk_rate / 100;
}
if ( skill_id == TF_POISON )
eatk += 15 * skill_lv;
+ if ( skill_id != ASC_METEORASSAULT ) {
+ if ( sc && sc->data[SC_SUB_WEAPONPROPERTY] ) // Temporary. [malufett]
+ damage += damage * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100;
+ }
+
if( sc && sc->count ){
if( sc->data[SC_ZENKAI] && watk->ele == sc->data[SC_ZENKAI]->val2 )
eatk += 200;
+ }
+
#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);
- }
+ if ( sc && sc->data[SC_EDP] && skill_id != AS_GRIMTOOTH && skill_id != AS_VENOMKNIFE && skill_id != ASC_BREAKER ) {
+ struct status_data *tstatus;
+ tstatus = status->get_status_data(bl);
+ eatk += damage * 0x19 * battle->attr_fix_table[tstatus->ele_lv - 1][ELE_POISON][tstatus->def_ele] / 10000;
+ damage += (eatk + damage) * sc->data[SC_EDP]->val3 / 100 + eatk;
+ } else /* fall through */
#endif
- }
-
- if( skill_id != ASC_METEORASSAULT ){
- if( sc && sc->data[SC_SUB_WEAPONPROPERTY] ) // Temporary. [malufett]
- damage += damage * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100;
- }
-
- // Temporary. [malufett]
- damage = battle->calc_elefix(src, bl, skill_id, skill_lv, damage + eatk, nk, n_ele, s_ele, s_ele_, type == EQI_HAND_L, flag);
-
+ damage += eatk;
+
+ damage = battle->calc_elefix(src, bl, skill_id, skill_lv, damage, nk, n_ele, s_ele, s_ele_, type == EQI_HAND_L, flag);
+
/**
* In RE Shield Boomerang takes weapon element only for damage calculation,
* - resist calculation is always against neutral
@@ -479,7 +487,7 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u
* it calculates nothing extra fancy, is needed for magnum breaks WATK_ELEMENT bonus. [Skotlex]
*------------------------------------------
* Pass damage2 as NULL to not calc it.
- * Flag values:
+ * Flag values: // TODO: Check whether these values are correct (the flag parameter seems to be passed through to other functions), and replace them with an enum.
* &1: Critical hit
* &2: Arrow attack
* &4: Skill is Magic Crasher
@@ -487,11 +495,23 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u
*&16: Arrow attack but BOW, REVOLVER, RIFLE, SHOTGUN, GATLING or GRENADE type weapon not equipped (i.e. shuriken, kunai and venom knives not affected by DEX)
*/
/* 'battle_calc_base_damage' is used on renewal, 'battle_calc_base_damage2' otherwise. */
+// FIXME: Missing documentation for flag2
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;
struct status_data *st = status->get_status_data(src);
struct status_change *sc = status->get_sc(src);
-
+
+ if ( !skill_id ) {
+ s_ele = st->rhw.ele;
+ s_ele_ = st->lhw.ele;
+ if ( src->type == BL_PC ) {
+ if ( ((TBL_PC*)src)->charm_type != CHARM_TYPE_NONE && ((TBL_PC*)src)->charm_count >= MAX_SPIRITCHARM ) {
+ s_ele = s_ele_ = ((TBL_PC*)src)->charm_type;
+ }
+ if ( flag & 2 && ((TBL_PC*)src)->bonus.arrow_ele )
+ s_ele = ((TBL_PC*)src)->bonus.arrow_ele;
+ }
+ }
if (src->type == BL_PC) {
int64 batk;
// Property from mild wind bypasses it
@@ -599,6 +619,7 @@ int64 battle_calc_sizefix(struct map_session_data *sd, int64 damage, int type, i
/*==========================================
* Passive skill damages increases
*------------------------------------------*/
+// FIXME: type is undocumented
int64 battle_addmastery(struct map_session_data *sd,struct block_list *target,int64 dmg,int type) {
int64 damage;
struct status_data *st = status->get_status_data(target);
@@ -849,6 +870,7 @@ void battle_calc_masteryfix_unknown(struct block_list *src, struct block_list *t
/*==========================================
* Elemental attribute fix.
*------------------------------------------*/
+// FIXME: flag is undocumented
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;
@@ -869,8 +891,6 @@ int64 battle_calc_elefix(struct block_list *src, struct block_list *target, uint
damage = battle->attr_fix(src,target,damage,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv);
if( skill_id == NC_ARMSCANNON )
damage = battle->attr_fix(src,target,damage,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv);
- if( skill_id == GN_CARTCANNON )
- damage = battle->attr_fix(src,target,damage,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv);
if( skill_id == GS_GROUNDDRIFT ) //Additional 50*lv Neutral damage.
damage += battle->attr_fix(src,target,50*skill_lv,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv);
}
@@ -896,15 +916,53 @@ int64 battle_calc_elefix(struct block_list *src, struct block_list *target, uint
#endif
return damage;
}
+int64 battle_calc_cardfix2(struct block_list *src, struct block_list *bl, int64 damage, int s_ele, int nk, int flag) {
+#ifdef RENEWAL
+ struct map_session_data *tsd;
+ struct status_data *sstatus;
+
+ if ( !damage )
+ return 0;
+
+ nullpo_ret(bl);
+ nullpo_ret(src);
+
+ tsd = BL_CAST(BL_PC, bl);
+ sstatus = status->get_status_data(src);
+
+ if ( tsd ) {
+ if ( !(nk&NK_NO_CARDFIX_DEF) ) {
+ // RaceAddTolerance
+ damage -= damage * tsd->race_tolerance[sstatus->race] / 100;
+ damage -= damage * tsd->race_tolerance[is_boss(src) ? RC_BOSS : RC_NONBOSS] / 100;
+ if ( flag&BF_SHORT )
+ damage -= damage * tsd->bonus.near_attack_def_rate / 100;
+ else // SubRangeAttackDamage or bLongAtkDef
+ damage -= damage * tsd->bonus.long_attack_def_rate / 100;
+ }
+ if ( flag&BF_LONG && tsd->sc.data[SC_GS_ADJUSTMENT] ) {
+ damage -= 20 * damage / 100;
+ }
+ }
+#endif
+ return damage;
+}
/*==========================================
* Calculates card bonuses damage adjustments.
* cflag(cardfix flag):
* &1 - calc for left hand.
* &2 - atker side cardfix(BF_WEAPON) otherwise target side(BF_WEAPON).
*------------------------------------------*/
+// FIXME: wflag is undocumented
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;
- short cardfix = 1000, t_class, s_class, s_race2, t_race2;
+ short cardfix =
+#ifdef RENEWAL
+ 100;
+#else
+ 1000;
+#endif
+ short t_class, s_class, s_race2, t_race2;
struct status_data *sstatus, *tstatus;
int i;
@@ -937,8 +995,6 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
break;
}
}
- if (cardfix != 1000)
- damage = damage * cardfix / 1000;
}
if( tsd && !(nk&NK_NO_CARDFIX_DEF) )
@@ -961,8 +1017,6 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
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 )
- cardfix = cardfix * (100-tsd->subrace[RC_NONDEMIHUMAN]) / 100;
for(i=0; i < ARRAYLENGTH(tsd->add_mdef) && tsd->add_mdef[i].rate;i++) {
if(tsd->add_mdef[i].class_ == s_class) {
@@ -982,16 +1036,25 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
if( tsd->sc.data[SC_PROTECT_MDEF] )
cardfix = cardfix * ( 100 - tsd->sc.data[SC_PROTECT_MDEF]->val1 ) / 100;
-
- if( cardfix != 1000 )
- damage = damage * cardfix / 1000;
}
+#ifdef RENEWAL
+ if ( cardfix != 100 )
+ damage += damage * (cardfix - 100) / 100;
+#else
+ if ( cardfix != 1000 )
+ damage = damage * cardfix / 1000;
+#endif
break;
case BF_WEAPON:
t_race2 = status->get_race2(target);
if( cflag&2 ){
if( sd && !(nk&NK_NO_CARDFIX_ATK) ){
- short cardfix_ = 1000;
+ short cardfix_ =
+#ifdef RENEWAL
+ 100;
+#else
+ 1000;
+#endif
if( sd->state.arrow_atk ){
cardfix = cardfix * (100 + sd->right_weapon.addrace[tstatus->race] + sd->arrow_addrace[tstatus->race]) / 100;
if( !(nk&NK_NO_ELEFIX) ){
@@ -1009,8 +1072,6 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
cardfix = cardfix * (100 + sd->right_weapon.addsize[tstatus->size]+sd->arrow_addsize[tstatus->size]) / 100;
cardfix = cardfix * (100 + sd->right_weapon.addrace2[t_race2]) / 100;
cardfix = cardfix * (100 + sd->right_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS] + sd->arrow_addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]) / 100;
- if( tstatus->race != RC_DEMIHUMAN )
- cardfix = cardfix * (100 + sd->right_weapon.addrace[RC_NONDEMIHUMAN]+sd->arrow_addrace[RC_NONDEMIHUMAN]) / 100;
}else{ // Melee attack
if( !battle_config.left_cardfix_to_right ){
cardfix=cardfix*(100+sd->right_weapon.addrace[tstatus->race])/100;
@@ -1029,8 +1090,6 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
cardfix = cardfix * (100+sd->right_weapon.addsize[tstatus->size]) / 100;
cardfix = cardfix * (100+sd->right_weapon.addrace2[t_race2]) / 100;
cardfix = cardfix * (100+sd->right_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]) / 100;
- if( tstatus->race != RC_DEMIHUMAN )
- cardfix = cardfix * (100 + sd->right_weapon.addrace[RC_NONDEMIHUMAN]) / 100;
if( cflag&1 ){
cardfix_ = cardfix_*(100+sd->left_weapon.addrace[tstatus->race])/100;
@@ -1049,8 +1108,6 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
cardfix_ = cardfix_ * (100+sd->left_weapon.addsize[tstatus->size]) / 100;
cardfix_ = cardfix_ * (100+sd->left_weapon.addrace2[t_race2]) / 100;
cardfix_ = cardfix_ * (100+sd->left_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]) / 100;
- if( tstatus->race != RC_DEMIHUMAN )
- cardfix_ = cardfix_*(100+sd->left_weapon.addrace[RC_NONDEMIHUMAN])/100;
}
}else{
int ele_fix = sd->right_weapon.addele[tstatus->def_ele] + sd->left_weapon.addele[tstatus->def_ele];
@@ -1076,8 +1133,6 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
cardfix = cardfix * (100 + sd->right_weapon.addsize[tstatus->size] + sd->left_weapon.addsize[tstatus->size])/100;
cardfix = cardfix * (100 + sd->right_weapon.addrace2[t_race2] + sd->left_weapon.addrace2[t_race2])/100;
cardfix = cardfix * (100 + sd->right_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS] + sd->left_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]) / 100;
- if( tstatus->race != RC_DEMIHUMAN )
- cardfix = cardfix * (100+sd->right_weapon.addrace[RC_NONDEMIHUMAN] + sd->left_weapon.addrace[RC_NONDEMIHUMAN]) / 100;
}
}
@@ -1099,11 +1154,16 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
#ifndef RENEWAL
if( wflag&BF_LONG )
cardfix = cardfix * (100 + sd->bonus.long_attack_atk_rate) / 100;
-#endif
if( (cflag&1) && cardfix_ != 1000 )
damage = damage * cardfix_ / 1000;
else if( cardfix != 1000 )
damage = damage * cardfix / 1000;
+#else
+ if ( (cflag & 1) && cardfix_ != 100 )
+ damage += damage * (cardfix - 100) / 100;
+ else if ( cardfix != 100 )
+ damage += damage * (cardfix - 100) / 100;
+#endif
}
}else{
// Target side
@@ -1137,8 +1197,6 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
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 )
- cardfix = cardfix * (100-tsd->subrace[RC_NONDEMIHUMAN]) / 100;
for( i = 0; i < ARRAYLENGTH(tsd->add_def) && tsd->add_def[i].rate;i++ ){
if( tsd->add_def[i].class_ == s_class )
@@ -1147,52 +1205,59 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
break;
}
}
-
+#ifndef RENEWAL
if( wflag&BF_SHORT )
cardfix = cardfix * (100 - tsd->bonus.near_attack_def_rate) / 100;
else // BF_LONG (there's no other choice)
cardfix = cardfix * (100 - tsd->bonus.long_attack_def_rate) / 100;
-
+#endif
if( tsd->sc.data[SC_PROTECT_DEF] )
cardfix = cardfix * (100 - tsd->sc.data[SC_PROTECT_DEF]->val1) / 100;
-
+#ifdef RENEWAL
+ if ( cardfix != 100 )
+ damage += damage * (cardfix - 100) / 100;
+#else
if( cardfix != 1000 )
damage = damage * cardfix / 1000;
+#endif
}
}
break;
case BF_MISC:
- if( tsd && !(nk&NK_NO_CARDFIX_DEF) ){
- // misc damage reduction from equipment
- if (!(nk&NK_NO_ELEFIX))
+ if ( tsd && !(nk&NK_NO_CARDFIX_DEF) ) {
+ // misc damage reduction from equipment
+#ifndef RENEWAL
+ if ( !(nk&NK_NO_ELEFIX) )
{
int ele_fix = tsd->subele[s_ele];
for (i = 0; ARRAYLENGTH(tsd->subele2) > i && tsd->subele2[i].rate != 0; i++)
{
if(tsd->subele2[i].ele != s_ele) continue;
if(!(tsd->subele2[i].flag&wflag&BF_WEAPONMASK &&
- tsd->subele2[i].flag&wflag&BF_RANGEMASK &&
- tsd->subele2[i].flag&wflag&BF_SKILLMASK))
+ tsd->subele2[i].flag&wflag&BF_RANGEMASK &&
+ tsd->subele2[i].flag&wflag&BF_SKILLMASK))
continue;
ele_fix += tsd->subele2[i].rate;
}
cardfix = cardfix * (100 - ele_fix) / 100;
}
- cardfix = cardfix*(100-tsd->subsize[sstatus->size]) / 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 )
- cardfix = cardfix * (100 - tsd->subrace[RC_NONDEMIHUMAN]) / 100;
-
- cardfix = cardfix * ( 100 - tsd->bonus.misc_def_rate ) / 100;
if( wflag&BF_SHORT )
cardfix = cardfix * ( 100 - tsd->bonus.near_attack_def_rate ) / 100;
else // BF_LONG (there's no other choice)
cardfix = cardfix * ( 100 - tsd->bonus.long_attack_def_rate ) / 100;
-
- if (cardfix != 1000)
+#endif
+ cardfix = cardfix*(100 - tsd->subsize[sstatus->size]) / 100;
+ cardfix = cardfix*(100 - tsd->subrace2[s_race2]) / 100;
+ cardfix = cardfix * (100 - tsd->bonus.misc_def_rate) / 100;
+#ifdef RENEWAL
+ if ( cardfix != 100 )
+ damage += damage * (cardfix - 100) / 100;
+#else
+ if ( cardfix != 1000 )
damage = damage * cardfix / 1000;
+#endif
}
break;
}
@@ -1207,6 +1272,7 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_
* &2 - pdef(Pierce defense)
* &4 - tdef(Total defense reduction)
*------------------------------------------*/
+// TODO: Add an enum for flag
int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 damage, int flag, int pdef){
struct status_data *sstatus, *tstatus;
struct map_session_data *sd, *tsd;
@@ -1244,21 +1310,26 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_
#endif
if ( sd ) {
+ if ( sd->charm_type == CHARM_TYPE_LAND && sd->charm_count > 0 ) // hidden from status window
+ def1 += 10 * def1 * sd->charm_count / 100;
+
i = sd->ignore_def[is_boss(target) ? RC_BOSS : RC_NONBOSS];
i += sd->ignore_def[tstatus->race];
if ( i ) {
if ( i > 100 ) i = 100;
def1 -= def1 * i / 100;
+#ifndef RENEWAL
def2 -= def2 * i / 100;
+#endif
}
- if (sd->charm_type == CHARM_TYPE_LAND && sd->charm_count > 0 ) // hidden from status window
- def1 += 10 * def1 * sd->charm_count / 100;
}
if( sc && sc->data[SC_EXPIATIO] ){
i = 5 * sc->data[SC_EXPIATIO]->val1; // 5% per level
def1 -= def1 * i / 100;
+#ifndef RENEWAL
def2 -= def2 * i / 100;
+#endif
}
if( battle_config.vit_penalty_type && battle_config.vit_penalty_target&target->type ) {
@@ -1275,7 +1346,9 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_
def2 -= (target_count - (battle_config.vit_penalty_count - 1))*battle_config.vit_penalty_num;
}
}
+#ifndef RENEWAL
if(skill_id == AM_ACIDTERROR) def1 = 0; //Acid Terror ignores only armor defense. [Skotlex]
+#endif
if(def2 < 1) def2 = 1;
}
//Vitality reduction from rodatazone: http://rodatazone.simgaming.net/mechanics/substats.php#def
@@ -1403,6 +1476,7 @@ int battle_calc_chorusbonus(struct map_session_data *sd) {
return members - 2; // Effect bonus from additional Minstrel's/Wanderer's if not above the max possible
}
+// FIXME: flag is undocumented
int battle_calc_skillratio(int attack_type, struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int skillratio, int flag){
int i;
struct status_change *sc, *tsc;
@@ -1927,7 +2001,11 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
skillratio += 20 * skill_lv;
break;
case AM_ACIDTERROR:
+#ifdef RENEWAL
+ skillratio += 80 * skill_lv + 100;
+#else
skillratio += 40 * skill_lv;
+#endif
break;
case MO_FINGEROFFENSIVE:
skillratio+= 50 * skill_lv;
@@ -1935,8 +2013,8 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
case MO_INVESTIGATE:
skillratio += 75 * skill_lv;
break;
- #ifndef RENEWAL
case MO_EXTREMITYFIST:
+ #ifndef RENEWAL
{
//Overflow check. [Skotlex]
unsigned int ratio = skillratio + 100*(8 + st->sp/10);
@@ -1944,8 +2022,8 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
if (ratio > 60000) ratio = 60000; //We leave some room here in case skillratio gets further increased.
skillratio = (unsigned short)ratio;
}
+#endif
break;
- #endif
case MO_TRIPLEATTACK:
skillratio += 20 * skill_lv;
break;
@@ -2050,14 +2128,11 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
case GS_TRACKING:
skillratio += 100 * (skill_lv+1);
break;
+#ifndef RENEWAL
case GS_PIERCINGSHOT:
-#ifdef RENEWAL
- if( sd && sd->weapontype1 == W_RIFLE )
- skillratio += 50 + 30 * skill_lv;
- else
-#endif
skillratio += 20 * skill_lv;
break;
+#endif
case GS_RAPIDSHOWER:
skillratio += 10 * skill_lv;
break;
@@ -2456,7 +2531,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
}
break;
case GN_CARTCANNON:
- skillratio = 50 * (sd ? pc->checkskill(sd, GN_REMODELING_CART) : 5) * (st->int_ / 40) + 60 * skill_lv;
+ skillratio += -100 + (int)(50.0f * (sd ? pc->checkskill(sd, GN_REMODELING_CART) : 5) * (st->int_ / 40.0f) + 60.0f * skill_lv);
break;
case GN_SPORE_EXPLOSION:
skillratio = 100 * skill_lv + (200 + st->int_) * status->get_lv(src) / 100;
@@ -2705,6 +2780,8 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
group->val2 -= (int)cap_value(damage,INT_MIN,INT_MAX);
} else
skill->del_unitgroup(group,ALC_MARK);
+ if (--group->val3<=0)
+ skill->del_unitgroup(group,ALC_MARK);
#else
if (--group->val2<=0)
skill->del_unitgroup(group,ALC_MARK);
@@ -2920,11 +2997,11 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if(sc->data[SC_DEFENDER] &&
((flag&(BF_LONG|BF_WEAPON)) == (BF_LONG|BF_WEAPON) || skill_id == CR_ACIDDEMONSTRATION))
damage = damage * ( 100 - sc->data[SC_DEFENDER]->val2 ) / 100;
-
+#ifndef RENEWAL
if(sc->data[SC_GS_ADJUSTMENT] &&
(flag&(BF_LONG|BF_WEAPON)) == (BF_LONG|BF_WEAPON))
damage -= damage * 20 / 100;
-
+#endif
if(sc->data[SC_FOGWALL]) {
if(flag&BF_SKILL) { //25% reduction
if ( !(skill->get_inf(skill_id)&INF_GROUND_SKILL) && !(skill->get_nk(skill_id)&NK_SPLASH) )
@@ -3076,28 +3153,31 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if( sc->data[SC__DEADLYINFECT] && flag&BF_SHORT && damage > 0 && rnd()%100 < 30 + 10 * sc->data[SC__DEADLYINFECT]->val1 && !is_boss(src) )
status->change_spread(bl, src); // Deadly infect attacked side
+
+ if ( sd && damage > 0 && (sce = sc->data[SC_GENTLETOUCH_ENERGYGAIN]) ) {
+ if ( rnd() % 100 < sce->val2 )
+ pc->addspiritball(sd, skill->get_time(MO_CALLSPIRITS, 1), pc->getmaxspiritball(sd, 0));
+ }
}
//SC effects from caster side.
- sc = status->get_sc(src);
-
- if (sc && sc->count) {
- if( sc->data[SC_INVINCIBLE] && !sc->data[SC_INVINCIBLEOFF] )
+ if (tsc && tsc->count) {
+ if( tsc->data[SC_INVINCIBLE] && !tsc->data[SC_INVINCIBLEOFF] )
damage += damage * 75 / 100;
// [Epoque]
if (bl->type == BL_MOB) {
int i;
- if ( ((sce=sc->data[SC_MANU_ATK]) && (flag&BF_WEAPON)) ||
- ((sce=sc->data[SC_MANU_MATK]) && (flag&BF_MAGIC))
+ if ( ((sce=tsc->data[SC_MANU_ATK]) && (flag&BF_WEAPON)) ||
+ ((sce=tsc->data[SC_MANU_MATK]) && (flag&BF_MAGIC))
)
for (i=0;ARRAYLENGTH(mob->manuk)>i;i++)
if (((TBL_MOB*)bl)->class_==mob->manuk[i]) {
damage += damage * sce->val1 / 100;
break;
}
- if ( ((sce=sc->data[SC_SPL_ATK]) && (flag&BF_WEAPON)) ||
- ((sce=sc->data[SC_SPL_MATK]) && (flag&BF_MAGIC))
+ if ( ((sce=tsc->data[SC_SPL_ATK]) && (flag&BF_WEAPON)) ||
+ ((sce=tsc->data[SC_SPL_MATK]) && (flag&BF_MAGIC))
)
for (i=0;ARRAYLENGTH(mob->splendide)>i;i++)
if (((TBL_MOB*)bl)->class_==mob->splendide[i]) {
@@ -3114,14 +3194,19 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
sc_start(src,bl,tsc->data[SC_POISONINGWEAPON]->val2,rate,tsc->data[SC_POISONINGWEAPON]->val1,skill->get_time2(GC_POISONINGWEAPON,1) - (tstatus->vit + tstatus->luk) / 2 * 1000);
}
}
- if( sc->data[SC__DEADLYINFECT] && flag&BF_SHORT && damage > 0 && rnd()%100 < 30 + 10 * sc->data[SC__DEADLYINFECT]->val1 && !is_boss(src) )
+ if( tsc->data[SC__DEADLYINFECT] && flag&BF_SHORT && damage > 0 && rnd()%100 < 30 + 10 * tsc->data[SC__DEADLYINFECT]->val1 && !is_boss(src) )
status->change_spread(src, bl);
- if (sc->data[SC_SHIELDSPELL_REF] && sc->data[SC_SHIELDSPELL_REF]->val1 == 1 && damage > 0)
+ if (tsc->data[SC_SHIELDSPELL_REF] && tsc->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) {
+ if (tsc->data[SC_STYLE_CHANGE] && rnd()%2) {
TBL_HOM *hd = BL_CAST(BL_HOM,bl);
if (hd) homun->addspiritball(hd, 10);
}
+ if ( src->type == BL_PC && damage > 0 && (sce = tsc->data[SC_GENTLETOUCH_ENERGYGAIN]) ) {
+ struct map_session_data *tsd = (struct map_session_data *)src;
+ if ( tsd && rnd() % 100 < sce->val2 )
+ pc->addspiritball(tsd, skill->get_time(MO_CALLSPIRITS, 1), pc->getmaxspiritball(tsd, 0));
+ }
}
/* no data claims these settings affect anything other than players */
if( damage && sd && bl->type == BL_PC ) {
@@ -3191,6 +3276,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
/*==========================================
* Calculates BG related damage adjustments.
*------------------------------------------*/
+// FIXME: flag is undocumented
int64 battle_calc_bg_damage(struct block_list *src, struct block_list *bl, int64 damage, int div_, uint16 skill_id, uint16 skill_lv, int flag)
{
if( !damage )
@@ -3209,6 +3295,7 @@ int64 battle_calc_bg_damage(struct block_list *src, struct block_list *bl, int64
/*==========================================
* Calculates GVG related damage adjustments.
*------------------------------------------*/
+// FIXME: flag is undocumented
int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64 damage,int div_,uint16 skill_id,uint16 skill_lv,int flag) {
struct mob_data* md = BL_CAST(BL_MOB, bl);
int class_ = status->get_class(bl);
@@ -3285,13 +3372,13 @@ void battle_consume_ammo(TBL_PC*sd, int skill_id, int lv) {
if (!battle_config.arrow_decrement)
return;
- if (skill_id) {
+ if (skill_id && lv) {
qty = skill->get_ammo_qty(skill_id, lv);
if (!qty) qty = 1;
}
if(sd->equip_index[EQI_AMMO]>=0) //Qty check should have been done in skill_check_condition
- pc->delitem(sd,sd->equip_index[EQI_AMMO],qty,0,1,LOG_TYPE_CONSUME);
+ pc->delitem(sd, sd->equip_index[EQI_AMMO], qty, 0, DELITEM_SKILLUSE, LOG_TYPE_CONSUME);
sd->state.arrow_atk = 0;
}
@@ -3345,6 +3432,7 @@ int battle_blewcount_bonus(struct map_session_data *sd, uint16 skill_id) {
/*==========================================
* battle_calc_magic_attack [DracoRPG]
*------------------------------------------*/
+// FIXME: mflag is undocumented
struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag) {
int nk;
short s_ele = 0;
@@ -3500,7 +3588,10 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
break;
default: {
MATK_ADD( status->get_matk(src, 2) );
-
+#ifdef RENEWAL
+ ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag);
+ ad.damage = battle->calc_cardfix2(src, target, ad.damage, s_ele, nk, ad.flag);
+#endif
if (nk&NK_SPLASHSPLIT) { // Divide MATK in case of multiple targets skill
if(mflag>0)
ad.damage/= mflag;
@@ -3520,7 +3611,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
skillratio = sc->data[SC_SPELLFIST]->val2 * 50 + sc->data[SC_SPELLFIST]->val4 * 100;// val4 = used bolt level, val2 = used spellfist level. [Rytech]
ad.div_ = 1;// ad mods, to make it work similar to regular hits [Xazax]
ad.flag = BF_WEAPON|BF_SHORT;
- ad.type = 0;
+ ad.type = BDT_NORMAL;
}
/* Fall through */
default:
@@ -3536,7 +3627,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
}
}
#ifndef HMAP_ZONE_DAMAGE_CAP_TYPE
- if( target && skill_id ) {
+ if (skill_id) {
for(i = 0; i < map->list[target->m].zone->capped_skills_count; i++) {
if( skill_id == map->list[target->m].zone->capped_skills[i]->nameid && (map->list[target->m].zone->capped_skills[i]->type & target->type) ) {
if( target->type == BL_MOB && map->list[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) {
@@ -3554,9 +3645,6 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
}
}
#endif
-#ifdef RENEWAL
- ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag);
-#endif
if(sd) {
uint16 rskill;/* redirect skill */
//Damage bonuses
@@ -3671,6 +3759,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
/*==========================================
* Calculate Misc damage for skill_id
*------------------------------------------*/
+// FIXME: mflag is undocumented
struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag) {
int temp;
short i, nk;
@@ -3789,7 +3878,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
short tdef = status->get_total_def(target);
short tmdef = status->get_total_mdef(target);
int targetVit = min(120, status_get_vit(target));
- short totaldef = (tmdef + tdef - ((uint64)(tmdef + tdef) >> 32)) >> 1;
+ short totaldef = (tmdef + tdef - ((uint64)(tmdef + tdef) >> 32)) >> 1; // FIXME: What's the >> 32 supposed to do here? tmdef and tdef are both 16-bit...
matk = battle->calc_magic_attack(src, target, skill_id, skill_lv, mflag).damage;
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);
@@ -3866,10 +3955,11 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
int ratio = 300 + 50 * skill_lv;
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);
-
+ 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);
+#ifdef RENEWAL_EDP
if( sc && sc->data[SC_EDP] )
ratio >>= 1;
+#endif
md.damage = (matk + atk) * ratio / 100;
md.damage -= totaldef;
#endif
@@ -3895,7 +3985,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
case RA_CLUSTERBOMB:
case RA_FIRINGTRAP:
case RA_ICEBOUNDTRAP:
- md.damage = skill_lv * sstatus->dex + sstatus->int_ * 5 ;
+ md.damage = (int64)skill_lv * sstatus->dex + sstatus->int_ * 5 ;
RE_LVL_TMDMOD();
if(sd)
{
@@ -3909,7 +3999,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
break;
case WM_SOUND_OF_DESTRUCTION:
- md.damage = 1000 * skill_lv + sstatus->int_ * (sd ? pc->checkskill(sd,WM_LESSON) : 10);
+ md.damage = 1000 * (int64)skill_lv + sstatus->int_ * (sd ? pc->checkskill(sd,WM_LESSON) : 10);
md.damage += md.damage * 10 * battle->calc_chorusbonus(sd) / 100;
break;
/**
@@ -4011,7 +4101,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
}
}
#ifndef HMAP_ZONE_DAMAGE_CAP_TYPE
- if( target && skill_id ) {
+ if (skill_id) {
for(i = 0; i < map->list[target->m].zone->capped_skills_count; i++) {
if( skill_id == map->list[target->m].zone->capped_skills[i]->nameid && (map->list[target->m].zone->capped_skills[i]->type & target->type) ) {
if( target->type == BL_MOB && map->list[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) {
@@ -4030,6 +4120,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_cardfix2(src, target, md.damage, s_ele, nk, md.flag);
if(skill_id){
uint16 rskill;/* redirect skill id */
switch(skill_id){
@@ -4100,6 +4191,7 @@ void battle_calc_misc_attack_unknown(struct block_list *src, struct block_list *
/*==========================================
* battle_calc_weapon_attack (by Skotlex)
*------------------------------------------*/
+// FIXME: wflag is undocumented
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.
@@ -4128,6 +4220,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
unsigned weapon : 1; ///< It's a weapon attack (consider VVS, and all that)
#ifdef RENEWAL
unsigned tdef : 1; ///< Total defense reduction
+ unsigned distinct : 1; ///< Has its own battle calc formula
#endif
} flag;
@@ -4149,13 +4242,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
flag.infdef = 1; // Reverberation takes 1 damage
//Initial Values
- wd.type=0; //Normal attack
- wd.div_=skill_id?skill->get_num(skill_id,skill_lv):1;
+ wd.type = BDT_NORMAL;
+ wd.div_ = skill_id ? skill->get_num(skill_id,skill_lv) : 1;
wd.amotion=(skill_id && skill->get_inf(skill_id)&INF_GROUND_SKILL)?0:sstatus->amotion; //Amotion should be 0 for ground skills.
if(skill_id == KN_AUTOCOUNTER)
wd.amotion >>= 1;
wd.dmotion=tstatus->dmotion;
- wd.blewcount=skill->get_blewcount(skill_id,skill_lv);
+ wd.blewcount = skill_id ? skill->get_blewcount(skill_id,skill_lv) : 0;
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
@@ -4216,7 +4309,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
case TF_DOUBLE: //For NPC used skill.
case GS_CHAINACTION:
- wd.type = 0x08;
+ wd.type = BDT_MULTIHIT;
break;
case GS_GROUNDDRIFT:
@@ -4255,13 +4348,28 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
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;
+
+ case NPC_EARTHQUAKE:
+ wd.flag = (wd.flag&~(BF_WEAPON)) | BF_MAGIC;
+ break;
#ifdef RENEWAL
+ case MO_EXTREMITYFIST:
+ case GS_PIERCINGSHOT:
+ case AM_ACIDTERROR:
+ case AM_DEMONSTRATION:
+ case NJ_ISSEN:
+ case PA_SACRIFICE:
+ flag.distinct = 1;
+ break;
+ case GN_CARTCANNON:
case PA_SHIELDCHAIN:
- case NJ_KUNAI:
- case HW_MAGICCRASHER:
- case NJ_SYURIKEN:
case GS_MAGICALBULLET:
+ case NJ_SYURIKEN:
case KO_BAKURETSU:
+ flag.distinct = 1;
+ /* Fall through */
+ case NJ_KUNAI:
+ case HW_MAGICCRASHER:
flag.tdef = 1;
break;
#endif
@@ -4270,15 +4378,15 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
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
- wd.type=0x0b;
+ wd.type = BDT_PDODGE;
wd.dmg_lv=ATK_LUCKY;
if (wd.div_ < 0) wd.div_*=-1;
return wd;
}
- s_ele = s_ele_ = skill->get_ele(skill_id, skill_lv);
- if( !skill_id || s_ele == -1 )
- { //Take weapon's element
+ s_ele = s_ele_ = skill_id ? skill->get_ele(skill_id, skill_lv) : -1;
+ if (s_ele == -1) {
+ //Take weapon's element
s_ele = sstatus->rhw.ele;
s_ele_ = sstatus->lhw.ele;
if (sd && sd->charm_type != CHARM_TYPE_NONE && sd->charm_count >= MAX_SPIRITCHARM) {
@@ -4289,13 +4397,14 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
s_ele = sd->bonus.arrow_ele;
if( battle_config.attack_attr_none&src->type )
n_ele = true; //Weapon's element is "not elemental"
- }
- else if( s_ele == -2 ) //Use enchantment's element
+ } else if (s_ele == -2) {
+ //Use enchantment's element
s_ele = s_ele_ = status_get_attack_sc_element(src,sc);
- else if( s_ele == -3 ) //Use random element
+ } else if (s_ele == -3) {
+ //Use random element
s_ele = s_ele_ = rnd()%ELE_MAX;
- switch( skill_id )
- {
+ }
+ switch (skill_id) {
case GS_GROUNDDRIFT:
s_ele = s_ele_ = wflag; //element comes in flag.
break;
@@ -4337,13 +4446,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
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);
- wd.type = 0x08;
+ wd.type = BDT_MULTIHIT;
}
}
else if( sd->weapontype1 == W_REVOLVER && (skill_lv = pc->checkskill(sd,GS_CHAINACTION)) > 0 && rnd()%100 < 5*skill_lv )
{
wd.div_ = skill->get_num(GS_CHAINACTION,skill_lv);
- wd.type = 0x08;
+ wd.type = BDT_MULTIHIT;
}
else if(sc && sc->data[SC_FEARBREEZE] && sd->weapontype1==W_BOW
&& (i = sd->equip_index[EQI_AMMO]) >= 0 && sd->inventory_data[i] && sd->status.inventory[i].amount > 1){
@@ -4374,13 +4483,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if ( wd.div_ > 1 ) {
wd.div_ = min(wd.div_, sd->status.inventory[i].amount);
sc->data[SC_FEARBREEZE]->val4 = wd.div_ - 1;
- wd.type = 0x08;
+ wd.type = BDT_MULTIHIT;
}
}
}
//Check for critical
- if( !flag.cri && !(wd.type&0x08) && sstatus->cri &&
+ if( !flag.cri && wd.type != BDT_MULTIHIT && sstatus->cri &&
(!skill_id ||
skill_id == KN_AUTOCOUNTER ||
skill_id == SN_SHARPSHOOTING || skill_id == MA_SHARPSHOOTING ||
@@ -4432,7 +4541,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
flag.cri = 1;
}
if (flag.cri) {
- wd.type = 0x0a;
+ wd.type = BDT_CRIT;
#ifndef RENEWAL
flag.idef = flag.idef2 =
#endif
@@ -4590,8 +4699,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
#define ATK_ADD( a ) do { int64 temp__ = (a); wd.damage += temp__; if (flag.lh) wd.damage2 += temp__; } while(0)
#define ATK_ADD2( a , b ) do { wd.damage += (a); if (flag.lh) wd.damage2 += (b); } while(0)
#ifdef RENEWAL
-#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) )
+#define GET_NORMAL_ATTACK( f , s ) ( wd.damage = battle->calc_base_damage(src, target, s, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_R, (f), wd.flag) )
+#define GET_NORMAL_ATTACK2( f , s ) ( wd.damage2 = battle->calc_base_damage(src, target, s, 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
@@ -4610,7 +4719,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
{
short totaldef = status->get_total_def(target);
i = 0;
- GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0) );
+ GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), 0 );
if( sc && sc->data[SC_NJ_BUNSINJYUTSU] && (i=sc->data[SC_NJ_BUNSINJYUTSU]->val2) > 0 )
wd.div_ = ~( i++ + 2 ) + 1;
if( wd.damage ){
@@ -4623,18 +4732,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
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);
- break;
- case MO_EXTREMITYFIST: // [malufett]
- {
- short totaldef = status->get_total_def(target);
- GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|8 );
- if( wd.damage ){
- wd.damage = (250 + 150 * skill_lv) + (10 * (status_get_sp(src)+1) * wd.damage / 100) + (8 * wd.damage);
- ATK_ADD(-totaldef);
- }
- }
+ GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), 0);
+ ATK_ADD(battle->calc_masteryfix(src, target, skill_id, skill_lv, 4 * skill_lv + (sd ? sd->bonus.arrow_atk : 0), wd.div_, 0, flag.weapon));
#endif
break;
#ifndef RENEWAL
@@ -4710,11 +4809,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
i |= 16; // for ex. shuriken must not be influenced by DEX
}
#ifdef RENEWAL
- GET_NORMAL_ATTACK( i );
+ GET_NORMAL_ATTACK( i, skill_id);
wd.damage = battle->calc_masteryfix(src, target, skill_id, skill_lv, wd.damage, wd.div_, 0, flag.weapon);
+ wd.damage = battle->calc_cardfix2(src, target, wd.damage, s_ele, nk, wd.flag);
if (flag.lh){
- GET_NORMAL_ATTACK2( i );
+ GET_NORMAL_ATTACK2( i, skill_id );
wd.damage2 = battle->calc_masteryfix(src, target, skill_id, skill_lv, wd.damage2, wd.div_, 1, flag.weapon);
+ wd.damage2 = battle->calc_cardfix2(src, target, wd.damage2, s_ele, nk, wd.flag);
}
#else
wd.damage = battle->calc_base_damage2(sstatus, &sstatus->rhw, sc, tstatus->size, sd, i);
@@ -4730,8 +4831,10 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
//Add any bonuses that modify the base baseatk+watk (pre-skills)
if(sd) {
+#ifndef RENEWAL
if (sd->bonus.atk_rate)
ATK_ADDRATE(sd->bonus.atk_rate);
+#endif
if(flag.cri && sd->bonus.crit_atk_rate)
ATK_ADDRATE(sd->bonus.crit_atk_rate);
if(flag.cri && sc && sc->data[SC_MTF_CRIDAMAGE])
@@ -4775,7 +4878,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
case KO_BAKURETSU:
{
#ifdef RENEWAL
- GET_NORMAL_ATTACK((sc && sc->data[SC_MAXIMIZEPOWER] ? 1 : 0) | (sc && sc->data[SC_WEAPONPERFECT] ? 8 : 0));
+ GET_NORMAL_ATTACK((sc && sc->data[SC_MAXIMIZEPOWER] ? 1 : 0) | (sc && sc->data[SC_WEAPONPERFECT] ? 8 : 0), skill_id);
#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);
@@ -4784,7 +4887,32 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
break;
#ifdef RENEWAL
+ case GS_MAGICALBULLET:
+ GET_NORMAL_ATTACK((sc && sc->data[SC_MAXIMIZEPOWER] ? 1 : 0) | (sc && sc->data[SC_WEAPONPERFECT] ? 8 : 0), skill_id);
+ ATK_ADD(battle->attr_fix(src, target,
+ battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, status->get_matk(src, 2), 0, wd.flag), ELE_NEUTRAL, tstatus->def_ele, tstatus->ele_lv));
+ break;
+ case GS_PIERCINGSHOT:
+ GET_NORMAL_ATTACK((sc && sc->data[SC_MAXIMIZEPOWER] ? 1 : 0) | (sc && sc->data[SC_WEAPONPERFECT] ? 8 : 0), 0);
+ if ( wd.damage ) {
+ if ( sd && sd->weapontype1 == W_RIFLE )
+ ATK_RATE(30 * (skill_lv + 5));
+ else
+ ATK_RATE(20 * (skill_lv + 5));
+ }
+ break;
+ case MO_EXTREMITYFIST: // [malufett]
+ {
+ short totaldef = status->get_total_def(target);
+ GET_NORMAL_ATTACK((sc && sc->data[SC_MAXIMIZEPOWER] ? 1 : 0) | 8, skill_id);
+ if ( wd.damage ) {
+ ATK_ADD(250 * (skill_lv + 1) + (10 * (status_get_sp(src) + 1) * wd.damage / 100) + (8 * wd.damage));
+ ATK_ADD(-totaldef);
+ }
+ }
+ break;
case PA_SHIELDCHAIN:
+ GET_NORMAL_ATTACK((sc && sc->data[SC_MAXIMIZEPOWER] ? 1 : 0) | (sc && sc->data[SC_WEAPONPERFECT] ? 8 : 0), skill_id);
if ( sd ) {
short index = sd->equip_index[EQI_HAND_L];
if ( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_ARMOR ) {
@@ -4794,6 +4922,32 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_ADD(sstatus->rhw.atk2); //Else use Atk2
ATK_RATE(battle->calc_skillratio(BF_WEAPON, src, target, skill_id, skill_lv, skillratio, wflag));
break;
+ case AM_DEMONSTRATION:
+ case AM_ACIDTERROR: // [malufett/Hercules]
+ {
+ int64 matk;
+ int totaldef = status->get_total_def(target) + status->get_total_mdef(target);
+ matk = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, status->get_matk(src, 2), 0, wd.flag);
+ matk = battle->attr_fix(src, target, matk, ELE_NEUTRAL, tstatus->def_ele, tstatus->ele_lv);
+ matk = matk * battle->calc_skillratio(BF_WEAPON, src, target, skill_id, skill_lv, skillratio, wflag) / 100;
+ GET_NORMAL_ATTACK((sc && sc->data[SC_MAXIMIZEPOWER] ? 1 : 0) | (sc && sc->data[SC_WEAPONPERFECT] ? 8 : 0), 0);
+ ATK_RATE(battle->calc_skillratio(BF_WEAPON, src, target, skill_id, skill_lv, skillratio, wflag));
+ ATK_ADD(matk);
+ ATK_ADD(-totaldef);
+ if ( skill_id == AM_ACIDTERROR && is_boss(target) )
+ ATK_RATE(50);
+ if ( skill_id == AM_DEMONSTRATION )
+ wd.damage = max(wd.damage, 1);
+ }
+ break;
+ case GN_CARTCANNON:
+ GET_NORMAL_ATTACK((sc && sc->data[SC_MAXIMIZEPOWER] ? 1 : 0) | (sc && sc->data[SC_WEAPONPERFECT] ? 8 : 0), skill_id);
+ ATK_ADD(sd ? sd->bonus.arrow_atk : 0);
+ wd.damage = battle->calc_masteryfix(src, target, skill_id, skill_lv, wd.damage, wd.div_, 0, flag.weapon);
+ ATK_RATE(battle->calc_skillratio(BF_WEAPON, src, target, skill_id, skill_lv, skillratio, wflag));
+ if ( sd && s_ele != sd->bonus.arrow_ele )
+ s_ele = sd->bonus.arrow_ele;
+ break;
case NJ_TATAMIGAESHI:
ATK_RATE(200);
/* Fall through */
@@ -4801,7 +4955,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
case ML_SPIRALPIERCE: // [malufett]
if( skill_id != NJ_TATAMIGAESHI ){
short index = sd?sd->equip_index[EQI_HAND_R]:0;
- GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0) );
+ GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), 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?)
@@ -4818,6 +4972,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_RATE(85);
}
wd.damage = battle->calc_masteryfix(src, target, skill_id, skill_lv, wd.damage, wd.div_, 0, flag.weapon);
+ wd.damage = battle->calc_cardfix2(src, target, wd.damage, s_ele, nk, wd.flag);
}
/* Fall through */
#endif
@@ -4845,13 +5000,11 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if(sd && sd->weapontype1 == W_FIST && sd->weapontype2 == W_FIST)
ATK_ADD(10*pc->checkskill(sd, TK_RUN));
break;
- case GS_MAGICALBULLET:
+
#ifndef RENEWAL
+ case GS_MAGICALBULLET:
ATK_ADD( status->get_matk(src, 2) );
-#else
- ATK_ADD( battle->calc_magic_attack(src, target, skill_id, skill_lv, wflag).damage );
-#endif
-#ifndef RENEWAL
+ break;
case NJ_SYURIKEN:
ATK_ADD(4*skill_lv);
#endif
@@ -4886,15 +5039,15 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
break;
case SR_GATEOFHELL:
- ATK_ADD (sstatus->max_hp - status_get_hp(src));
- if(sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == SR_FALLENEMPIRE) {
- ATK_ADD( (sstatus->max_sp * (1 + skill_lv * 2 / 10)) + 40 * status->get_lv(src) );
+ ATK_ADD(sstatus->max_hp - status_get_hp(src));
+ if ( sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == SR_FALLENEMPIRE ) {
+ ATK_ADD((sstatus->max_sp * (1 + skill_lv * 2 / 10)) + 40 * status->get_lv(src));
} else {
- ATK_ADD( (sstatus->sp * (1 + skill_lv * 2 / 10)) + 10 * status->get_lv(src) );
+ ATK_ADD((sstatus->sp * (1 + skill_lv * 2 / 10)) + 10 * status->get_lv(src));
}
break;
case SR_FALLENEMPIRE:// [(Target Size value + Skill Level - 1) x Caster STR] + [(Target current weight x Caster DEX / 120)]
- ATK_ADD( ((tstatus->size+1)*2 + skill_lv - 1) * sstatus->str);
+ ATK_ADD( ((tstatus->size+1)*2 + (int64)skill_lv - 1) * sstatus->str);
if( tsd && tsd->weight ){
ATK_ADD( (tsd->weight/10) * sstatus->dex / 120 );
}else{
@@ -5045,7 +5198,11 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
}
- if(!flag.idef || !flag.idef2) { //Defense reduction
+ if((!flag.idef || !flag.idef2)
+#ifdef RENEWAL
+ && (!flag.distinct || flag.tdef)
+#endif
+ ) { //Defense reduction
wd.damage = battle->calc_defense(BF_WEAPON, src, target, skill_id, skill_lv, wd.damage,
(flag.idef?1:0)|(flag.pdef?2:0)
#ifdef RENEWAL
@@ -5062,8 +5219,19 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
#ifdef RENEWAL
+ if ( flag.distinct ) {
+ wd.damage = battle->calc_cardfix2(src, target, wd.damage, s_ele, nk, wd.flag);
+ if ( flag.lh ) {
+ wd.damage2 = battle->calc_cardfix2(src, target, wd.damage2, s_ele, nk, wd.flag);
+ }
+ }
//Div fix.
damage_div_fix(wd.damage, wd.div_);
+ if ( skill_id > 0 && (skill->get_ele(skill_id, skill_lv) == ELE_NEUTRAL || flag.distinct) ) { // re-evaluate forced neutral skills
+ wd.damage = battle->attr_fix(src, target, wd.damage, s_ele, tstatus->def_ele, tstatus->ele_lv);
+ if ( flag.lh )
+ wd.damage2 = battle->attr_fix(src, target, wd.damage2, s_ele_, tstatus->def_ele, tstatus->ele_lv);
+ }
#endif
#if 0 // Can't find any source about this one even in eagis
if (skill_id == NPC_EARTHQUAKE) {
@@ -5146,7 +5314,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if(skill_id == CR_GRANDCROSS || skill_id == NPC_GRANDDARKNESS)
return wd; //Enough, rest is not needed.
#ifndef HMAP_ZONE_DAMAGE_CAP_TYPE
- if( target && skill_id ) {
+ if (skill_id) {
for(i = 0; i < map->list[target->m].zone->capped_skills_count; i++) {
if( skill_id == map->list[target->m].zone->capped_skills[i]->nameid && (map->list[target->m].zone->capped_skills[i]->type & target->type) ) {
if( target->type == BL_MOB && map->list[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) {
@@ -5187,11 +5355,12 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_ADD(10*sd->status.inventory[index].refine);
}
}
-#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);
+ 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 )
@@ -5370,7 +5539,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
rnd()%100 < tsc->data[SC_SWORDREJECT]->val2
) {
ATK_RATER(50);
- status_fix_damage(target,src,wd.damage,clif->damage(target,src,0,0,wd.damage,0,0,0));
+ status_fix_damage(target,src,wd.damage,clif->damage(target,src,0,0,wd.damage,0,BDT_NORMAL,0));
clif->skill_nodamage(target,target,ST_REJECTSWORD,tsc->data[SC_SWORDREJECT]->val1,1);
if( --(tsc->data[SC_SWORDREJECT]->val3) <= 0 )
status_change_end(target, SC_SWORDREJECT, INVALID_TIMER);
@@ -5476,8 +5645,8 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st
rdamage = ratio + (damage)* (10 + sc->data[SC_CRESCENTELBOW]->val1 * 20 / 10) / 10;
skill->blown(target, src, skill->get_blewcount(SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1), unit->getdir(src), 0);
clif->skill_damage(target, src, tick, status_get_amotion(src), 0, rdamage,
- 1, SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1, 6); // This is how official does
- clif->delay_damage(tick + delay, src, target,status_get_amotion(src)+1000,0, rdamage/10, 1, 0);
+ 1, SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1, BDT_SKILL); // This is how official does
+ clif->delay_damage(tick + delay, src, target,status_get_amotion(src)+1000,0, rdamage/10, 1, BDT_NORMAL);
status->damage(src, target, status->damage(target, src, rdamage, 0, 0, 1)/10, 0, 0, 1);
status_change_end(target, SC_CRESCENTELBOW, INVALID_TIMER);
/* shouldn't this trigger skill->additional_effect? */
@@ -5495,7 +5664,7 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st
int64 rd1 = damage * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage.
trdamage += rdamage = rd1 - (damage = rd1 * 30 / 100); // not normalized as intended.
- rdelay = clif->skill_damage(src, target, tick, status_get_amotion(src), status_get_dmotion(src), -3000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, 6);
+ rdelay = clif->skill_damage(src, target, tick, status_get_amotion(src), status_get_dmotion(src), -3000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, BDT_SKILL);
skill->blown(target, src, skill->get_blewcount(RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1), unit->getdir(src), 0);
if( tsd ) /* is this right? rdamage as both left and right? */
@@ -5522,7 +5691,7 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st
if ( tsd && tsd->bonus.short_weapon_damage_return ) {
NORMALIZE_RDAMAGE(damage * tsd->bonus.short_weapon_damage_return / 100);
- rdelay = clif->delay_damage(tick+delay,src, src, status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4);
+ rdelay = clif->delay_damage(tick+delay,src, src, status_get_amotion(src), status_get_dmotion(src), rdamage, 1, BDT_ENDURE);
/* is this right? rdamage as both left and right? */
battle->drain(tsd, src, rdamage, rdamage, status_get_race(src), 0);
@@ -5547,9 +5716,9 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st
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);
+ rdelay = clif->delay_damage(tick+delay,src, src, status_get_amotion(src), status_get_dmotion(src), rdamage, 1, BDT_ENDURE);
#else
- rdelay = clif->skill_damage(src, src, tick, delay, status_get_dmotion(src), rdamage, 1, CR_REFLECTSHIELD, 1, 4);
+ rdelay = clif->skill_damage(src, src, tick, delay, status_get_dmotion(src), rdamage, 1, CR_REFLECTSHIELD, 1, BDT_ENDURE);
#endif
/* is this right? rdamage as both left and right? */
if( tsd )
@@ -5583,7 +5752,7 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st
if( sc->data[SC_SHIELDSPELL_DEF] && sc->data[SC_SHIELDSPELL_DEF]->val1 == 2 ){
NORMALIZE_RDAMAGE(damage * sc->data[SC_SHIELDSPELL_DEF]->val2 / 100);
- rdelay = clif->delay_damage(tick+delay,src, src, status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4);
+ rdelay = clif->delay_damage(tick+delay,src, src, status_get_amotion(src), status_get_dmotion(src), rdamage, 1, BDT_ENDURE);
/* is this right? rdamage as both left and right? */
if( tsd )
@@ -5597,7 +5766,7 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st
if( ssc->data[SC_INSPIRATION] ) {
NORMALIZE_RDAMAGE(damage / 100);
- rdelay = clif->delay_damage(tick+delay,target, target, status_get_amotion(target), status_get_dmotion(target), rdamage, 1, 4);
+ rdelay = clif->delay_damage(tick+delay,target, target, status_get_amotion(target), status_get_dmotion(target), rdamage, 1, BDT_ENDURE);
/* is this right? rdamage as both left and right? */
if( sd )
@@ -5612,7 +5781,7 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st
if ( tsd && tsd->bonus.long_weapon_damage_return ) {
NORMALIZE_RDAMAGE(damage * tsd->bonus.long_weapon_damage_return / 100);
- rdelay = clif->delay_damage(tick+delay,src, src, status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4);
+ rdelay = clif->delay_damage(tick+delay,src, src, status_get_amotion(src), status_get_dmotion(src), rdamage, 1, BDT_ENDURE);
/* is this right? rdamage as both left and right? */
battle->drain(tsd, src, rdamage, rdamage, status_get_race(src), 0);
@@ -5707,7 +5876,7 @@ int battle_damage_area(struct block_list *bl, va_list ap) {
battle->delay_damage(tick, amotion,src,bl,0,CR_REFLECTSHIELD,0,damage,ATK_DEF,0,true);
else
status_fix_damage(src,bl,damage,0);
- clif->damage(bl,bl,amotion,dmotion,damage,1,ATK_BLOCK,0);
+ clif->damage(bl,bl,amotion,dmotion,damage,1,BDT_ENDURE,0);
if( !(src->type == BL_PC && ((TBL_PC*)src)->state.autocast) )
skill->additional_effect(src, bl, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,tick);
map->freeblock_unlock();
@@ -5718,6 +5887,7 @@ int battle_damage_area(struct block_list *bl, va_list ap) {
/*==========================================
* Do a basic physical attack (call trough unit_attack_timer)
*------------------------------------------*/
+// FIXME: flag is undocumented
enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* target, int64 tick, int flag) {
struct map_session_data *sd = NULL, *tsd = NULL;
struct status_data *sstatus, *tstatus;
@@ -5753,10 +5923,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) {
- if (sd->weapontype1 > W_KATAR && sd->weapontype1 < W_HUUMA)
- clif->arrow_fail(sd, 0);
- else
+ 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
@@ -5799,7 +5969,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
if(dist <= 0 || (!map->check_dir(dir,t_dir) && dist <= tstatus->rhw.range+1)) {
uint16 skill_lv = tsc->data[SC_AUTOCOUNTER]->val1;
clif->skillcastcancel(target); //Remove the casting bar. [Skotlex]
- clif->damage(src, target, sstatus->amotion, 1, 0, 1, 0, 0); //Display MISS.
+ clif->damage(src, target, sstatus->amotion, 1, 0, 1, BDT_NORMAL, 0); //Display MISS.
status_change_end(target, SC_AUTOCOUNTER, INVALID_TIMER);
skill->attack(BF_WEAPON,target,target,src,KN_AUTOCOUNTER,skill_lv,tick,0);
return ATK_BLOCK;
@@ -5812,7 +5982,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
status_change_end(target, SC_BLADESTOP_WAIT, INVALID_TIMER);
if(sc_start4(target, src, SC_BLADESTOP, 100, sd?pc->checkskill(sd, MO_BLADESTOP):5, 0, 0, target->id, duration)) {
//Target locked.
- clif->damage(src, target, sstatus->amotion, 1, 0, 1, 0, 0); //Display MISS.
+ clif->damage(src, target, sstatus->amotion, 1, 0, 1, BDT_NORMAL, 0); //Display MISS.
clif->bladestop(target, src->id, 1);
sc_start4(target, target, SC_BLADESTOP, 100, skill_lv, 0, 0, src->id, duration);
return ATK_BLOCK;
@@ -5856,18 +6026,6 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
return ATK_DEF;
return ATK_MISS;
}
- if( sc->data[SC_GENTLETOUCH_ENERGYGAIN] ) {
- if( sd && rnd()%100 < 10 + 5 * sc->data[SC_GENTLETOUCH_ENERGYGAIN]->val1)
- pc->addspiritball(sd,
- skill->get_time(MO_CALLSPIRITS, sc->data[SC_GENTLETOUCH_ENERGYGAIN]->val1),
- sc->data[SC_GENTLETOUCH_ENERGYGAIN]->val1);
- }
- if( tsc && tsc->data[SC_GENTLETOUCH_ENERGYGAIN] ) {
- if( tsd && rnd()%100 < 10 + 5 * tsc->data[SC_GENTLETOUCH_ENERGYGAIN]->val1)
- pc->addspiritball(tsd,
- skill->get_time(MO_CALLSPIRITS, tsc->data[SC_GENTLETOUCH_ENERGYGAIN]->val1),
- tsc->data[SC_GENTLETOUCH_ENERGYGAIN]->val1);
- }
if( tsc && tsc->data[SC_MTF_MLEATKED] && rnd()%100 < 20 )
clif->skill_nodamage(target, target, SM_ENDURE, 5,
@@ -5890,7 +6048,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
}
if( sd && sc->data[SC_FEARBREEZE] && sc->data[SC_FEARBREEZE]->val4 > 0 && sd->status.inventory[sd->equip_index[EQI_AMMO]].amount >= sc->data[SC_FEARBREEZE]->val4 && battle_config.arrow_decrement){
- pc->delitem(sd,sd->equip_index[EQI_AMMO],sc->data[SC_FEARBREEZE]->val4,0,1,LOG_TYPE_CONSUME);
+ pc->delitem(sd, sd->equip_index[EQI_AMMO], sc->data[SC_FEARBREEZE]->val4, 0, DELITEM_SKILLUSE, LOG_TYPE_CONSUME);
sc->data[SC_FEARBREEZE]->val4 = 0;
}
}
@@ -5938,7 +6096,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
(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, damage, 0, 0, 0);
+ clif->damage(d_bl, d_bl, 0, 0, damage, 0, BDT_NORMAL, 0);
status_fix_damage(NULL, d_bl, damage, 0);
}
else
@@ -5946,7 +6104,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
} else if( tsc->data[SC_CIRCLE_OF_FIRE_OPTION] && (wd.flag&BF_SHORT) && target->type == BL_PC ) {
struct elemental_data *ed = ((TBL_PC*)target)->ed;
if( ed ) {
- clif->skill_damage(&ed->bl, target, tick, status_get_amotion(src), 0, -30000, 1, EL_CIRCLE_OF_FIRE, tsc->data[SC_CIRCLE_OF_FIRE_OPTION]->val1, 6);
+ clif->skill_damage(&ed->bl, target, tick, status_get_amotion(src), 0, -30000, 1, EL_CIRCLE_OF_FIRE, tsc->data[SC_CIRCLE_OF_FIRE_OPTION]->val1, BDT_SKILL);
skill->attack(BF_MAGIC,&ed->bl,&ed->bl,src,EL_CIRCLE_OF_FIRE,tsc->data[SC_CIRCLE_OF_FIRE_OPTION]->val1,tick,wd.flag);
}
} else if( tsc->data[SC_WATER_SCREEN_OPTION] && tsc->data[SC_WATER_SCREEN_OPTION]->val1 ) {
@@ -6215,21 +6373,28 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
}
break;
case BL_MOB:
- 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
- {
+ {
+ TBL_MOB *md = BL_CAST(BL_MOB, target);
+ if((
+ (md->special_state.ai == AI_SPHERE || (md->special_state.ai == AI_FLORA && battle_config.summon_flora&1))
+ && s_bl->type == BL_PC && src->type != BL_MOB
+ )
+ || (md->special_state.ai == AI_ZANZOU && t_bl->id != s_bl->id)
+ ) {
//Targetable by players
state |= BCT_ENEMY;
strip_enemy = 0;
}
break;
+ }
case BL_SKILL:
{
TBL_SKILL *su = (TBL_SKILL*)target;
if( !su->group )
return 0;
- if( skill->get_inf2(su->group->skill_id)&INF2_TRAP && su->group->unit_id != UNT_USED_TRAPS) { //Only a few skills can target traps...
+ if( skill->get_inf2(su->group->skill_id)&INF2_TRAP &&
+ su->group->unit_id != UNT_USED_TRAPS &&
+ su->group->unit_id != UNT_NETHERWORLD ) { //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:
@@ -6367,8 +6532,8 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
) {
if( t_bl->type == BL_PC && (sd->duel_group == ((TBL_PC*)t_bl)->duel_group) )
return (BCT_ENEMY&flag)?1:-1; // Duel targets can ONLY be your enemy, nothing else.
- else
- return 0; // You can't target anything out of your duel
+ else if ( src->type != BL_SKILL || (flag&BCT_ENEMY) )
+ return 0;
}
}
if( map_flag_gvg(m) && !sd->status.guild_id && t_bl->type == BL_MOB && ((TBL_MOB*)t_bl)->class_ == MOBID_EMPERIUM )
@@ -6384,19 +6549,16 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
&& md->guardian_data && (md->guardian_data->g || md->guardian_data->castle->guild_id) )
return 0; // Disable guardians/emperium owned by Guilds on non-woe times.
- if( !md->special_state.ai )
- { //Normal mobs
- if(
- ( target->type == BL_MOB && t_bl->type == BL_PC && ( ((TBL_MOB*)target)->special_state.ai != 4 && ((TBL_MOB*)target)->special_state.ai != 1 ) ) ||
- ( t_bl->type == BL_MOB && !((TBL_MOB*)t_bl)->special_state.ai )
- )
+ if (md->special_state.ai == AI_NONE) {
+ //Normal mobs
+ struct mob_data *target_md = BL_CAST(BL_MOB, target);
+ if( (target_md && t_bl->type == BL_PC && target_md->special_state.ai != AI_ZANZOU && target_md->special_state.ai != AI_ATTACK)
+ || (t_bl->type == BL_MOB && !((TBL_MOB*)t_bl)->special_state.ai) )
state |= BCT_PARTY; //Normal mobs with no ai are friends.
else
state |= BCT_ENEMY; //However, all else are enemies.
- }
- else
- {
- if( t_bl->type == BL_MOB && !((TBL_MOB*)t_bl)->special_state.ai )
+ } else {
+ if (t_bl->type == BL_MOB && ((TBL_MOB*)t_bl)->special_state.ai == AI_NONE)
state |= BCT_ENEMY; //Natural enemy for AI mobs are normal mobs.
}
break;
@@ -7287,6 +7449,7 @@ void battle_defaults(void) {
battle->attr_ratio = battle_attr_ratio;
battle->attr_fix = battle_attr_fix;
battle->calc_cardfix = battle_calc_cardfix;
+ battle->calc_cardfix2 = battle_calc_cardfix2;
battle->calc_elefix = battle_calc_elefix;
battle->calc_masteryfix = battle_calc_masteryfix;
battle->calc_chorusbonus = battle_calc_chorusbonus;
diff --git a/src/map/battle.h b/src/map/battle.h
index 233c325cf..6bc2659b9 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -5,8 +5,8 @@
#ifndef MAP_BATTLE_H
#define MAP_BATTLE_H
-#include "map.h" //ELE_MAX
-#include "../common/cbasetypes.h"
+#include "map/map.h" //ELE_MAX
+#include "common/cbasetypes.h"
/**
* Declarations
@@ -77,6 +77,27 @@ enum e_battle_check_target { //New definitions [Skotlex]
};
/**
+ * Values used by (struct Damage).type, as well as clif->damage(type) and clif->skill_damage(type)
+ *
+ * Note: some values may not apply in some contexts.
+ */
+enum battle_dmg_type {
+ BDT_NORMAL = 0, // Normal attack
+ //BDT_PICKUP = 1, // Pick up item
+ //BDT_SITDOWN = 2, // Sit down
+ //BDT_STANDUP = 3, // Stand up
+ BDT_ENDURE = 4, // Damage (endure)
+ BDT_SPLASH = 5, // Splash
+ BDT_SKILL = 6, // Skill
+ //BDT_REPEAT = 7, // (repeat damage?)
+ BDT_MULTIHIT = 8, // Multi-hit damage
+ BDT_MULTIENDURE = 9, // Multi-hit damage (endure)
+ BDT_CRIT = 10, // Critical hit
+ BDT_PDODGE = 11, // Lucky dodge
+ //BDT_TOUCH = 12, // (touch skill?)
+};
+
+/**
* Structures
**/
@@ -558,6 +579,7 @@ struct battle_interface {
int64 (*attr_fix) (struct block_list *src, struct block_list *target, int64 damage, int atk_elem, int def_type, int def_lv);
/* applies card modifiers */
int64 (*calc_cardfix) (int attack_type, struct block_list *src, struct block_list *target, int nk, int s_ele, int s_ele_, int64 damage, int left, int flag);
+ int64 (*calc_cardfix2) (struct block_list *src, struct block_list *bl, int64 damage, int s_ele, int nk, int flag);
/* applies element modifiers */
int64 (*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);
/* applies mastery modifiers */
diff --git a/src/map/battleground.c b/src/map/battleground.c
index 2d4ba6bf1..0fe42110f 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -6,29 +6,31 @@
#include "battleground.h"
+#include "map/battle.h"
+#include "map/clif.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/map.h"
+#include "map/mapreg.h"
+#include "map/mercenary.h"
+#include "map/mob.h" // struct mob_data
+#include "map/npc.h"
+#include "map/party.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/HPM.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+
#include <stdio.h>
#include <string.h>
-#include "battle.h"
-#include "clif.h"
-#include "homunculus.h"
-#include "map.h"
-#include "mapreg.h"
-#include "mercenary.h"
-#include "mob.h" // struct mob_data
-#include "npc.h"
-#include "party.h"
-#include "pc.h"
-#include "pet.h"
-#include "../common/cbasetypes.h"
-#include "../common/conf.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-
struct battleground_interface bg_s;
/// Search a BG Team using bg_id
@@ -210,7 +212,7 @@ int bg_team_get_id(struct block_list *bl) {
{
struct map_session_data *msd;
struct mob_data *md = (TBL_MOB*)bl;
- if( md->special_state.ai && (msd = map->id2sd(md->master_id)) != NULL )
+ if (md->special_state.ai != AI_NONE && (msd = map->id2sd(md->master_id)) != NULL)
return msd->bg_id;
return md->bg_id;
}
@@ -537,11 +539,10 @@ void bg_match_over(struct bg_arena *arena, bool canceled) {
bg->team_leave(sd, 0);
bg->queue_pc_cleanup(sd);
}
- if( canceled )
- clif->colormes(sd->fd,COLOR_RED,"BG Match Canceled: not enough players");
- else {
+ if (canceled)
+ clif->messagecolor_self(sd->fd, COLOR_RED, "BG Match Canceled: not enough players");
+ else
pc_setglobalreg(sd, script->add_str(arena->delay_var), (unsigned int)time(NULL));
- }
}
}
@@ -765,7 +766,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
sprintf(response, "You are a deserter! Wait %d minute(s) before you can apply again",(tick-tsec)/60);
else
sprintf(response, "You are a deserter! Wait %d seconds before you can apply again",(tick-tsec));
- clif->colormes(sd->fd,COLOR_RED,response);
+ clif->messagecolor_self(sd->fd, COLOR_RED, response);
return BGQA_FAIL_DESERTER;
}
@@ -775,7 +776,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
sprintf(response, "You can't reapply to this arena so fast. Apply to the different arena or wait %d minute(s)",(tick-tsec)/60);
else
sprintf(response, "You can't reapply to this arena so fast. Apply to the different arena or wait %d seconds",(tick-tsec));
- clif->colormes(sd->fd,COLOR_RED,response);
+ clif->messagecolor_self(sd->fd, COLOR_RED, response);
return BGQA_FAIL_COOLDOWN;
}
@@ -799,7 +800,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
sprintf(response, "Can't apply: not enough members in your team/guild that have not entered the queue in individual mode, minimum is %d",arena->min_team_players);
else
sprintf(response, "Can't apply: not enough members in your team/guild, minimum is %d",arena->min_team_players);
- clif->colormes(sd->fd,COLOR_RED,response);
+ clif->messagecolor_self(sd->fd, COLOR_RED, response);
return BGQA_FAIL_TEAM_COUNT;
}
}
@@ -831,7 +832,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
sprintf(response, "Can't apply: not enough members in your team/party that have not entered the queue in individual mode, minimum is %d",arena->min_team_players);
else
sprintf(response, "Can't apply: not enough members in your team/party, minimum is %d",arena->min_team_players);
- clif->colormes(sd->fd,COLOR_RED,response);
+ clif->messagecolor_self(sd->fd, COLOR_RED, response);
return BGQA_FAIL_TEAM_COUNT;
}
} else
@@ -856,9 +857,27 @@ void do_init_battleground(bool minimal) {
bg->config_read();
}
+/**
+ * @see DBApply
+ */
+int bg_team_db_final(DBKey key, DBData *data, va_list ap) {
+ struct battleground_data* bgd = DB->data2ptr(data);
+ int i;
+ for(i = 0; i < bgd->hdatac; i++ ) {
+ if( bgd->hdata[i]->flag.free ) {
+ aFree(bgd->hdata[i]->data);
+ }
+ aFree(bgd->hdata[i]);
+ }
+ if( bgd->hdata )
+ aFree(bgd->hdata);
+
+ return 0;
+}
+
void do_final_battleground(void)
{
- db_destroy(bg->team_db);
+ bg->team_db->destroy(bg->team_db,bg->team_db_final);
if (bg->arena) {
int i;
@@ -868,6 +887,7 @@ void do_final_battleground(void)
}
aFree(bg->arena);
}
+
}
void battleground_defaults(void) {
bg = &bg_s;
@@ -911,6 +931,7 @@ void battleground_defaults(void) {
bg->send_xy_timer_sub = bg_send_xy_timer_sub;
bg->send_xy_timer = bg_send_xy_timer;
bg->afk_timer = bg_afk_timer;
+ bg->team_db_final = bg_team_db_final;
/* */
bg->str2teamtype = bg_str2teamtype;
/* */
diff --git a/src/map/battleground.h b/src/map/battleground.h
index 9878d6be0..a67deb722 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -5,9 +5,14 @@
#ifndef MAP_BATTLEGROUND_H
#define MAP_BATTLEGROUND_H
-#include "clif.h"
-#include "guild.h"
-#include "../common/mmo.h" // struct party
+#include "map/map.h" // EVENT_NAME_LENGTH
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/mmo.h" // struct party
+
+struct HPluginData;
+struct block_list;
+struct map_session_data;
/**
* Defines
@@ -48,6 +53,9 @@ struct battleground_data {
// Logout Event
char logout_event[EVENT_NAME_LENGTH];
char die_event[EVENT_NAME_LENGTH];
+ /* HPM Custom Struct */
+ struct HPluginData **hdata;
+ unsigned int hdatac;
};
struct bg_arena {
@@ -112,6 +120,7 @@ struct battleground_interface {
int (*send_xy_timer_sub) (DBKey key, DBData *data, va_list ap);
int (*send_xy_timer) (int tid, int64 tick, int id, intptr_t data);
int (*afk_timer) (int tid, int64 tick, int id, intptr_t data);
+ int (*team_db_final) (DBKey key, DBData *data, va_list ap);
/* */
enum bg_queue_types (*str2teamtype) (const char *str);
/* */
diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c
index 85fef98aa..d1ce4ba0d 100644
--- a/src/map/buyingstore.c
+++ b/src/map/buyingstore.c
@@ -4,19 +4,19 @@
#define HERCULES_CORE
-#include "buyingstore.h" // struct s_buyingstore
-
-#include "atcommand.h" // msg_txt
-#include "battle.h" // battle_config.*
-#include "chrif.h"
-#include "clif.h" // clif->buyingstore_*
-#include "log.h" // log_pick_pc, log_zeny
-#include "pc.h" // struct map_session_data
-#include "../common/cbasetypes.h"
-#include "../common/db.h" // ARR_FIND
-#include "../common/showmsg.h" // ShowWarning
-#include "../common/socket.h" // RBUF*
-#include "../common/strlib.h" // safestrncpy
+#include "buyingstore.h" // struct s_buyingstore
+
+#include "map/atcommand.h" // msg_txt
+#include "map/battle.h" // battle_config.*
+#include "map/chrif.h"
+#include "map/clif.h" // clif-"buyingstore_*
+#include "map/log.h" // log_pick_pc, log_zeny
+#include "map/pc.h" // struct map_session_data
+#include "common/cbasetypes.h"
+#include "common/db.h" // ARR_FIND
+#include "common/showmsg.h" // ShowWarning
+#include "common/socket.h" // RBUF*
+#include "common/strlib.h" // safestrncpy
struct buyingstore_interface buyingstore_s;
@@ -353,7 +353,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
// move item
pc->additem(pl_sd, &sd->status.inventory[index], amount, LOG_TYPE_BUYING_STORE);
- pc->delitem(sd, index, amount, 1, 0, LOG_TYPE_BUYING_STORE);
+ pc->delitem(sd, index, amount, 1, DELITEM_NORMAL, LOG_TYPE_BUYING_STORE);
pl_sd->buyingstore.items[listidx].amount-= amount;
// pay up
diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h
index 7b8e369d2..f23790459 100644
--- a/src/map/buyingstore.h
+++ b/src/map/buyingstore.h
@@ -5,8 +5,8 @@
#ifndef MAP_BUYINGSTORE_H
#define MAP_BUYINGSTORE_H
-#include "../common/cbasetypes.h"
-#include "../common/mmo.h" // MAX_SLOTS
+#include "common/cbasetypes.h"
+#include "common/mmo.h" // MAX_SLOTS
struct map_session_data;
diff --git a/src/map/channel.c b/src/map/channel.c
index 0704bf706..69f7ab872 100644
--- a/src/map/channel.c
+++ b/src/map/channel.c
@@ -5,28 +5,28 @@
#include "channel.h"
+#include "map/atcommand.h"
+#include "map/guild.h"
+#include "map/instance.h"
+#include "map/irc-bot.h"
+#include "map/map.h"
+#include "map/pc.h"
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "atcommand.h"
-#include "guild.h"
-#include "instance.h"
-#include "irc-bot.h"
-#include "map.h"
-#include "pc.h"
-#include "../common/cbasetypes.h"
-#include "../common/conf.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct channel_interface channel_s;
static struct Channel_Config channel_config;
@@ -258,7 +258,7 @@ void channel_send(struct channel_data *chan, struct map_session_data *sd, const
if (sd && chan->msg_delay != 0
&& DIFF_TICK(sd->hchsysch_tick + chan->msg_delay*1000, timer->gettick()) > 0
&& !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
- clif->colormes(sd->fd,COLOR_RED,msg_sd(sd,1455));
+ clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1455));
return;
} else if (sd) {
snprintf(message, 150, "[ #%s ] %s : %s",chan->name,sd->status.name, msg);
@@ -352,7 +352,7 @@ enum channel_operation_status channel_join(struct channel_data *chan, struct map
} else {
sprintf(output, msg_sd(sd,1403), chan->name); // You're now in the '%s' channel
}
- clif->colormes(sd->fd, COLOR_DEFAULT, output);
+ clif->messagecolor_self(sd->fd, COLOR_DEFAULT, output);
}
if (chan->type == HCS_TYPE_ALLY) {
@@ -477,6 +477,17 @@ void channel_map_join(struct map_session_data *sd)
channel->join(map->list[sd->bl.m].channel, sd, NULL, false);
}
+void channel_irc_join(struct map_session_data *sd)
+{
+ struct channel_data *chan = ircbot->channel;
+ if (sd->state.autotrade || sd->state.standalone)
+ return;
+ if (channel->config->irc_name[0] == '\0')
+ return;
+ if (chan)
+ channel->join(chan, sd, NULL, false);
+}
+
/**
* Lets a guild's members join a newly allied guild's channel.
*
@@ -574,7 +585,8 @@ void read_channels_config(void)
int ally_enabled = 0, local_enabled = 0,
local_autojoin = 0, ally_autojoin = 0,
allow_user_channel_creation = 0,
- irc_enabled = 0;
+ irc_enabled = 0,
+ irc_autojoin = 0;
if( !libconfig->setting_lookup_string(settings, "map_local_channel_name", &local_name) )
local_name = "map";
@@ -655,11 +667,14 @@ 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);
+ libconfig->setting_lookup_bool(settings, "irc_channel_autojoin", &irc_autojoin);
if (local_autojoin)
channel->config->local_autojoin = true;
if (ally_autojoin)
channel->config->ally_autojoin = true;
+ if (irc_autojoin)
+ channel->config->irc_autojoin = true;
libconfig->setting_lookup_bool(settings, "allow_user_channel_creation", &allow_user_channel_creation);
@@ -678,7 +693,6 @@ void read_channels_config(void)
safestrncpy(channel->config->colors_name[i], config_setting_name(color), HCS_NAME_LENGTH);
channel->config->colors[i] = (unsigned int)strtoul(libconfig->setting_get_string_elem(colors,i),NULL,0);
- channel->config->colors[i] = (channel->config->colors[i] & 0x0000FF) << 16 | (channel->config->colors[i] & 0x00FF00) | (channel->config->colors[i] & 0xFF0000) >> 16;//RGB to BGR
}
channel->config->colors_count = color_count;
}
@@ -768,7 +782,7 @@ int do_init_channel(bool minimal)
return 0;
channel->db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, HCS_NAME_LENGTH);
- channel->config->ally = channel->config->local = channel->config->irc = channel->config->ally_autojoin = channel->config->local_autojoin = false;
+ channel->config->ally = channel->config->local = channel->config->irc = channel->config->ally_autojoin = channel->config->local_autojoin = channel->config->irc_autojoin = false;
channel->config_read();
return 0;
@@ -828,6 +842,7 @@ void channel_defaults(void)
channel->guild_join_alliance = channel_guild_join_alliance;
channel->guild_leave_alliance = channel_guild_leave_alliance;
channel->quit_guild = channel_quit_guild;
+ channel->irc_join = channel_irc_join;
channel->config_read = read_channels_config;
}
diff --git a/src/map/channel.h b/src/map/channel.h
index ba6aafc79..de1779d96 100644
--- a/src/map/channel.h
+++ b/src/map/channel.h
@@ -4,11 +4,9 @@
#ifndef MAP_CHANNEL_H
#define MAP_CHANNEL_H
-#include <stdarg.h>
-
-#include "map.h"
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/mmo.h"
/**
* Declarations
@@ -51,7 +49,7 @@ struct Channel_Config {
char **colors_name;
unsigned char colors_count;
bool local, ally, irc;
- bool local_autojoin, ally_autojoin;
+ bool local_autojoin, ally_autojoin, irc_autojoin;
char local_name[HCS_NAME_LENGTH], ally_name[HCS_NAME_LENGTH], irc_name[HCS_NAME_LENGTH];
unsigned char local_color, ally_color, irc_color;
bool closing;
@@ -106,6 +104,7 @@ struct channel_interface {
void (*guild_join_alliance) (const struct guild *g_source, const struct guild *g_ally);
void (*guild_leave_alliance) (const struct guild *g_source, const struct guild *g_ally);
void (*quit_guild) (struct map_session_data *sd);
+ void (*irc_join) (struct map_session_data *sd);
void (*config_read) (void);
};
diff --git a/src/map/chat.c b/src/map/chat.c
index a232781ca..08c904290 100644
--- a/src/map/chat.c
+++ b/src/map/chat.c
@@ -6,23 +6,23 @@
#include "chat.h"
+#include "map/atcommand.h" // msg_sd(sd,)
+#include "map/battle.h" // struct battle_config
+#include "map/clif.h"
+#include "map/map.h"
+#include "map/npc.h" // npc_event_do()
+#include "map/pc.h"
+#include "map/skill.h" // ext_skill_unit_onplace()
+#include "common/cbasetypes.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+
#include <stdio.h>
#include <string.h>
-#include "atcommand.h" // msg_sd(sd,)
-#include "battle.h" // struct battle_config
-#include "clif.h"
-#include "map.h"
-#include "npc.h" // npc_event_do()
-#include "pc.h"
-#include "skill.h" // ext_skill_unit_onplace()
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-
struct chat_interface chat_s;
/// Initializes a chatroom object (common functionality for both pc and npc chatrooms).
@@ -93,7 +93,7 @@ bool chat_createpcchat(struct map_session_data* sd, const char* title, const cha
return false;
}
- pc_stop_walking(sd,1);
+ pc_stop_walking(sd, STOPWALKING_FLAG_FIXPOS);
cd = chat->create(&sd->bl, title, pass, limit, pub, 0, "", 0, 1, MAX_LEVEL);
if( cd ) {
@@ -101,7 +101,7 @@ bool chat_createpcchat(struct map_session_data* sd, const char* title, const cha
cd->usersd[0] = sd;
pc_setchatid(sd,cd->bl.id);
pc_stop_attack(sd);
- clif->createchat(sd,0);
+ clif->createchat(sd,0); // 0 = success
clif->dispchat(cd,0);
return true;
}
@@ -150,7 +150,7 @@ bool chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) {
return false;
}
- pc_stop_walking(sd,1);
+ pc_stop_walking(sd, STOPWALKING_FLAG_FIXPOS);
cd->usersd[cd->users] = sd;
cd->users++;
@@ -339,7 +339,7 @@ bool chat_kickchat(struct map_session_data* sd, const char* kickusername) {
idb_iput(cd->kick_list,cd->usersd[i]->status.char_id,1);
- chat->leave(cd->usersd[i],1);
+ chat->leave(cd->usersd[i], true);
return true;
}
@@ -440,7 +440,7 @@ bool chat_npckickall(struct chat_data* cd)
nullpo_ret(cd);
while( cd->users > 0 )
- chat->leave(cd->usersd[cd->users-1],0);
+ chat->leave(cd->usersd[cd->users-1], false);
return true;
}
diff --git a/src/map/chat.h b/src/map/chat.h
index ced216b41..31048d5dd 100644
--- a/src/map/chat.h
+++ b/src/map/chat.h
@@ -5,9 +5,9 @@
#ifndef MAP_CHAT_H
#define MAP_CHAT_H
-#include "map.h" // struct block_list, CHATROOM_TITLE_SIZE
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
+#include "map/map.h" // struct block_list, CHATROOM_TITLE_SIZE
+#include "common/cbasetypes.h"
+#include "common/db.h"
struct chat_data;
struct map_session_data;
diff --git a/src/map/chrif.c b/src/map/chrif.c
index da946f050..5bd1e436f 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -4,39 +4,38 @@
#define HERCULES_CORE
-#include "../config/core.h" // AUTOTRADE_PERSISTENCY, STATS_OPT_OUT
+#include "config/core.h" // AUTOTRADE_PERSISTENCY, STATS_OPT_OUT
#include "chrif.h"
+#include "map/battle.h"
+#include "map/clif.h"
+#include "map/elemental.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/instance.h"
+#include "map/intif.h"
+#include "map/map.h"
+#include "map/mercenary.h"
+#include "map/npc.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/quest.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "map/storage.h"
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/ers.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/types.h>
-#include <time.h>
-
-#include "map.h"
-#include "battle.h"
-#include "clif.h"
-#include "intif.h"
-#include "npc.h"
-#include "pc.h"
-#include "pet.h"
-#include "skill.h"
-#include "status.h"
-#include "homunculus.h"
-#include "instance.h"
-#include "mercenary.h"
-#include "elemental.h"
-#include "quest.h"
-#include "storage.h"
-#include "../common/HPM.h"
-#include "../common/cbasetypes.h"
-#include "../common/ers.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
struct chrif_interface chrif_s;
@@ -62,7 +61,7 @@ struct chrif_interface chrif_s;
//2b0a: Incoming/Outgoing, socket_datasync()
//2b0b: Outgoing, update charserv skillid2idx
//2b0c: Outgoing, chrif_changeemail -> 'change mail address ...'
-//2b0d: Incoming, chrif_changedsex -> 'Change sex of acc XY'
+//2b0d: Incoming, chrif_changedsex -> 'Change sex of acc XY' (or char)
//2b0e: Outgoing, chrif_char_ask_name -> 'Do some operations (change sex, ban / unban etc)'
//2b0f: Incoming, chrif_char_ask_name_answer -> 'answer of the 2b0e'
//2b10: Outgoing, chrif_updatefamelist -> 'Update the fame ranking lists and send them'
@@ -247,6 +246,7 @@ int chrif_isconnected(void) {
* Flag = 1: Character is quitting
* Flag = 2: Character is changing map-servers
*------------------------------------------*/
+// TODO: Flag enum
bool chrif_save(struct map_session_data *sd, int flag) {
nullpo_ret(sd);
@@ -263,11 +263,11 @@ bool chrif_save(struct map_session_data *sd, int flag) {
chrif_check(false); //Character is saved on reconnect.
//For data sync
- if (sd->state.storage_flag == 2)
+ if (sd->state.storage_flag == STORAGE_FLAG_GUILD)
gstorage->save(sd->status.account_id, sd->status.guild_id, flag);
if (flag)
- sd->state.storage_flag = 0; //Force close it.
+ sd->state.storage_flag = STORAGE_FLAG_CLOSED; //Force close it.
//Saving of registry values.
if (sd->vars_dirty)
@@ -401,7 +401,7 @@ bool chrif_changemapserverack(int account_id, int login_id1, int login_id2, int
if ( !login_id1 ) {
ShowError("chrif_changemapserverack: map server change failed.\n");
- clif->authfail_fd(node->fd, 0);
+ clif->authfail_fd(node->fd, 0); // Disconnected from server
} else
clif->changemapserver(node->sd, map_index, x, y, ntohl(ip), ntohs(port));
@@ -465,7 +465,7 @@ int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
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.
- clif->authfail_fd(sd->fd, 3);
+ clif->authfail_fd(sd->fd, 3); // timeout
break;
}
}
@@ -643,7 +643,7 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (
node->sex == sex &&
node->state == ST_LOGIN )
{// found a match
- clif->authfail_fd(node->fd, 0);
+ clif->authfail_fd(node->fd, 0); // Disconnected from server
chrif->auth_delete(account_id, char_id, ST_LOGIN);
}
}
@@ -744,10 +744,18 @@ bool chrif_changeemail(int id, const char *actual_email, const char *new_email)
}
/*==========================================
- * S 2b0e <accid>.l <name>.24B <type>.w { <year>.w <month>.w <day>.w <hour>.w <minute>.w <second>.w }
+ * S 2b0e <accid>.l <name>.24B <type>.w { <additional fields>.12B }
+ * { <year>.w <month>.w <day>.w <hour>.w <minute>.w <second>.w }
* Send an account modification request to the login server (via char server).
- * type of operation:
- * 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex (use next function for 5), 6: charban
+ * type of operation: @see enum zh_char_ask_name
+ * block { n/a }
+ * ban { <year>.w <month>.w <day>.w <hour>.w <minute>.w <second>.w }
+ * unblock { n/a }
+ * unban { n/a }
+ * changesex { n/a } -- use chrif_changesex
+ * charban { <year>.w <month>.w <day>.w <hour>.w <minute>.w <second>.w }
+ * charunban { n/a }
+ * changecharsex { <sex>.b } -- use chrif_changesex
*------------------------------------------*/
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)
{
@@ -759,7 +767,7 @@ bool chrif_char_ask_name(int acc, const char* character_name, unsigned short ope
safestrncpy((char*)WFIFOP(chrif->fd,6), character_name, NAME_LENGTH);
WFIFOW(chrif->fd,30) = operation_type;
- if ( operation_type == 2 || operation_type == 6 ) {
+ if (operation_type == CHAR_ASK_NAME_BAN || operation_type == CHAR_ASK_NAME_CHARBAN) {
WFIFOW(chrif->fd,32) = year;
WFIFOW(chrif->fd,34) = month;
WFIFOW(chrif->fd,36) = day;
@@ -772,14 +780,24 @@ bool chrif_char_ask_name(int acc, const char* character_name, unsigned short ope
return true;
}
-bool chrif_changesex(struct map_session_data *sd) {
+/**
+ * Requests a sex change (either per character or per account).
+ *
+ * @param sd The character's data.
+ * @param change_account Whether to change the per-account sex.
+ * @retval true.
+ */
+bool chrif_changesex(struct map_session_data *sd, bool change_account)
+{
chrif_check(false);
WFIFOHEAD(chrif->fd,44);
WFIFOW(chrif->fd,0) = 0x2b0e;
WFIFOL(chrif->fd,2) = sd->status.account_id;
safestrncpy((char*)WFIFOP(chrif->fd,6), sd->status.name, NAME_LENGTH);
- WFIFOW(chrif->fd,30) = 5;
+ WFIFOW(chrif->fd,30) = change_account ? CHAR_ASK_NAME_CHANGESEX : CHAR_ASK_NAME_CHANGECHARSEX;
+ if (!change_account)
+ WFIFOB(chrif->fd,32) = sd->status.sex == SEX_MALE ? SEX_FEMALE : SEX_MALE;
WFIFOSET(chrif->fd,44);
clif->message(sd->fd, msg_sd(sd,408)); //"Disconnecting to perform change-sex request..."
@@ -794,19 +812,14 @@ bool chrif_changesex(struct map_session_data *sd) {
/*==========================================
* R 2b0f <accid>.l <name>.24B <type>.w <answer>.w
* Processing a reply to chrif->char_ask_name() (request to modify an account).
- * type of operation:
- * 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex, 6: charban, 7: charunban
- * type of answer:
- * 0: login-server request done
- * 1: player not found
- * 2: gm level too low
- * 3: login-server offline
+ * type of operation: @see chrif_char_ask_name
+ * type of answer: @see hz_char_ask_name_answer
*------------------------------------------*/
bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, uint16 answer) {
struct map_session_data* sd;
char action[25];
char output[256];
- bool charsrv = ( type == 6 || type == 7 ) ? true : false;
+ bool charsrv = ( type == CHAR_ASK_NAME_CHARBAN || type == CHAR_ASK_NAME_CHARUNBAN ) ? true : false;
sd = map->id2sd(acc);
@@ -816,19 +829,19 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u
}
/* re-use previous msg_number */
- if( type == 6 ) type = 2;
- if( type == 7 ) type = 4;
+ if( type == CHAR_ASK_NAME_CHARBAN ) type = CHAR_ASK_NAME_BAN;
+ if( type == CHAR_ASK_NAME_CHARUNBAN ) type = CHAR_ASK_NAME_UNBAN;
- if( type > 0 && type <= 5 )
+ if( type >= CHAR_ASK_NAME_BLOCK && type <= CHAR_ASK_NAME_CHANGESEX )
snprintf(action,25,"%s",msg_sd(sd,427+type)); //block|ban|unblock|unban|change the sex of
else
snprintf(action,25,"???");
switch( answer ) {
- case 0 : sprintf(output, msg_sd(sd,charsrv?434:424), action, NAME_LENGTH, player_name); break;
- case 1 : sprintf(output, msg_sd(sd,425), NAME_LENGTH, player_name); break;
- case 2 : sprintf(output, msg_sd(sd,426), action, NAME_LENGTH, player_name); break;
- case 3 : sprintf(output, msg_sd(sd,427), action, NAME_LENGTH, player_name); break;
+ case CHAR_ASK_NAME_ANS_DONE: sprintf(output, msg_sd(sd,charsrv?434:424), action, NAME_LENGTH, player_name); break;
+ case CHAR_ASK_NAME_ANS_NOTFOUND: sprintf(output, msg_sd(sd,425), NAME_LENGTH, player_name); break;
+ case CHAR_ASK_NAME_ANS_GMLOW: sprintf(output, msg_sd(sd,426), action, NAME_LENGTH, player_name); break;
+ case CHAR_ASK_NAME_ANS_OFFLINE: sprintf(output, msg_sd(sd,427), action, NAME_LENGTH, player_name); break;
default: output[0] = '\0'; break;
}
@@ -847,8 +860,11 @@ void chrif_changedsex(int fd) {
ShowNotice("chrif_changedsex %d.\n", acc);
// Path to activate this response:
- // Map(start) (0x2b0e) -> Char(0x2727) -> Login
+ // Map(start) (0x2b0e type 5) -> Char(0x2727) -> Login
// Login(0x2723) [ALL] -> Char (0x2b0d)[ALL] -> Map (HERE)
+ // OR
+ // Map(start) (0x2b03 type 8) -> Char
+ // Char(0x2b0d)[ALL] -> Map (HERE)
// Char will usually be "logged in" despite being forced to log-out in the beginning
// of this process, but there's no need to perform map-server specific response
// as everything should been changed through char-server [Panikon]
@@ -883,14 +899,14 @@ bool chrif_divorceack(int char_id, int partner_id) {
sd->status.partner_id = 0;
for(i = 0; i < MAX_INVENTORY; i++)
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);
+ pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_OTHER);
}
if( ( sd = map->charid2sd(partner_id) ) != NULL && sd->status.partner_id == char_id ) {
sd->status.partner_id = 0;
for(i = 0; i < MAX_INVENTORY; i++)
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);
+ pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_OTHER);
}
return true;
@@ -1305,8 +1321,8 @@ void chrif_skillid2idx(int fd) {
WFIFOHEAD(fd,4 + (MAX_SKILL * 4));
WFIFOW(fd,0) = 0x2b0b;
for(i = 0; i < MAX_SKILL; i++) {
- if( skill->db[i].nameid ) {
- WFIFOW(fd, 4 + (count*4)) = skill->db[i].nameid;
+ if( skill->dbs->db[i].nameid ) {
+ WFIFOW(fd, 4 + (count*4)) = skill->dbs->db[i].nameid;
WFIFOW(fd, 6 + (count*4)) = i;
count++;
}
diff --git a/src/map/chrif.h b/src/map/chrif.h
index 271fc076d..cac965f74 100644
--- a/src/map/chrif.h
+++ b/src/map/chrif.h
@@ -5,12 +5,12 @@
#ifndef MAP_CHRIF_H
#define MAP_CHRIF_H
-#include <time.h>
-
-#include "map.h" //TBL_stuff
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
+#include "map/map.h" //TBL_PC
+#include "common/cbasetypes.h"
+#include "common/db.h"
+struct eri;
+struct map_session_data;
struct status_change_entry;
/**
@@ -103,7 +103,7 @@ struct chrif_interface {
bool (*char_reset_offline) (void);
bool (*send_users_tochar) (void);
bool (*char_online) (struct map_session_data *sd);
- bool (*changesex) (struct map_session_data *sd);
+ bool (*changesex) (struct map_session_data *sd, bool change_account);
//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);
diff --git a/src/map/clif.c b/src/map/clif.c
index 029080958..d00cac0ee 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -4,60 +4,60 @@
#define HERCULES_CORE
-#include "../config/core.h" // ANTI_MAYAP_CHEAT, RENEWAL, SECURE_NPCTIMEOUT
+#include "config/core.h" // ANTI_MAYAP_CHEAT, RENEWAL, SECURE_NPCTIMEOUT
#include "clif.h"
+#include "map/atcommand.h"
+#include "map/battle.h"
+#include "map/battleground.h"
+#include "map/channel.h"
+#include "map/chat.h"
+#include "map/chrif.h"
+#include "map/elemental.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/instance.h"
+#include "map/intif.h"
+#include "map/irc-bot.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/mail.h"
+#include "map/map.h"
+#include "map/mercenary.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/party.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/quest.h"
+#include "map/script.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "map/storage.h"
+#include "map/trade.h"
+#include "map/unit.h"
+#include "map/vending.h"
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/ers.h"
+#include "common/grfio.h"
+#include "common/malloc.h"
+#include "common/mmo.h" // NEW_CARTS
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>
-#include "atcommand.h"
-#include "battle.h"
-#include "battleground.h"
-#include "channel.h"
-#include "chat.h"
-#include "chrif.h"
-#include "elemental.h"
-#include "guild.h"
-#include "homunculus.h"
-#include "instance.h"
-#include "intif.h"
-#include "irc-bot.h"
-#include "itemdb.h"
-#include "log.h"
-#include "mail.h"
-#include "map.h"
-#include "mercenary.h"
-#include "mob.h"
-#include "npc.h"
-#include "party.h"
-#include "pc.h"
-#include "pet.h"
-#include "quest.h"
-#include "script.h"
-#include "skill.h"
-#include "status.h"
-#include "storage.h"
-#include "trade.h"
-#include "unit.h"
-#include "vending.h"
-#include "../common/HPM.h"
-#include "../common/cbasetypes.h"
-#include "../common/conf.h"
-#include "../common/ers.h"
-#include "../common/grfio.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h" // NEW_CARTS
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct clif_interface clif_s;
/* re-usable */
@@ -688,6 +688,7 @@ void clif_authrefuse(int fd, uint8 error_code)
/// 109 = BAN_INVALID_PWD_CNT
/// 110 = BAN_NOT_ALLOWED_JOBCLASS
/// ? = disconnected -> MsgStringTable[3]
+// TODO: type enum
void clif_authfail_fd(int fd, int type)
{
if (!fd || !session[fd] || session[fd]->func_parse != clif->parse) //clif_authfail should only be invoked on players!
@@ -1369,7 +1370,7 @@ bool clif_spawn(struct block_list *bl)
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);
+ clif->sc_load(&sd->bl, sd->bl.id,AREA,status->dbs->IconChangeTable[sd->sc_display[i]->type],sd->sc_display[i]->val1,sd->sc_display[i]->val2,sd->sc_display[i]->val3);
}
if (sd->charm_type != CHARM_TYPE_NONE && sd->charm_count > 0)
clif->spiritcharm(sd);
@@ -1520,19 +1521,24 @@ void clif_homskillinfoblock(struct map_session_data *sd) {
WFIFOHEAD(fd, 4+37*MAX_HOMUNSKILL);
WFIFOW(fd,0)=0x235;
- for ( i = 0; i < MAX_HOMUNSKILL; i++){
+ for ( i = 0; i < MAX_HOMUNSKILL; i++ ) {
int id = hd->homunculus.hskill[i].id;
- if (id != 0) {
+ if ( id != 0 ) {
j = id - HM_SKILLBASE;
- WFIFOW(fd,len ) = id;
- WFIFOW(fd,len+2) = skill->get_inf(id);
- WFIFOW(fd,len+4) = 0;
- WFIFOW(fd,len+6) = hd->homunculus.hskill[j].lv;
- WFIFOW(fd,len+8) = skill->get_sp(id,hd->homunculus.hskill[j].lv);
- WFIFOW(fd,len+10)= skill->get_range2(&sd->hd->bl, id,hd->homunculus.hskill[j].lv);
- safestrncpy((char*)WFIFOP(fd,len+12), skill->get_name(id), NAME_LENGTH);
- WFIFOB(fd,len+36) = (hd->homunculus.hskill[j].lv < homun->skill_tree_get_max(id, hd->homunculus.class_))?1:0;
- len+=37;
+ WFIFOW(fd, len) = id;
+ WFIFOW(fd, len + 2) = skill->get_inf(id);
+ WFIFOW(fd, len + 4) = 0;
+ WFIFOW(fd, len + 6) = hd->homunculus.hskill[j].lv;
+ if ( hd->homunculus.hskill[j].lv ) {
+ WFIFOW(fd, len + 8) = skill->get_sp(id, hd->homunculus.hskill[j].lv);
+ WFIFOW(fd, len + 10) = skill->get_range2(&sd->hd->bl, id, hd->homunculus.hskill[j].lv);
+ } else {
+ WFIFOW(fd, len + 8) = 0;
+ WFIFOW(fd, len + 10) = 0;
+ }
+ safestrncpy((char*)WFIFOP(fd, len + 12), skill->get_name(id), NAME_LENGTH);
+ WFIFOB(fd, len + 36) = (hd->homunculus.hskill[j].lv < homun->skill_tree_get_max(id, hd->homunculus.class_)) ? 1 : 0;
+ len += 37;
}
}
WFIFOW(fd,2)=len;
@@ -2292,15 +2298,7 @@ void clif_dropitem(struct map_session_data *sd,int n,int amount)
/// Notifies the client, that an inventory item was deleted (ZC_DELETE_ITEM_FROM_BODY).
/// 07fa <delete type>.W <index>.W <amount>.W
-/// delete type:
-/// 0 = Normal
-/// 1 = Item used for a skill
-/// 2 = Refine failed
-/// 3 = Material changed
-/// 4 = Moved to storage
-/// 5 = Moved to cart
-/// 6 = Item sold
-/// 7 = Consumed by Four Spirit Analysis (SO_EL_ANALYSIS) skill
+/// delete type: @see enum delitem_reason
void clif_delitem(struct map_session_data *sd,int n,int amount, short reason)
{
#if PACKETVER < 20091117
@@ -2976,6 +2974,9 @@ void clif_changelook(struct block_list *bl,int type,int val)
case LOOK_BASE:
if( !sd ) break;
+ if ( val == INVISIBLE_CLASS ) /* nothing to change look */
+ return;
+
if( sd->sc.option&OPTION_COSTUME )
vd->weapon = vd->shield = 0;
@@ -3226,14 +3227,14 @@ void clif_arrow_create_list(struct map_session_data *sd)
for (i = 0, c = 0; i < MAX_SKILL_ARROW_DB; i++) {
int j;
- if (skill->arrow_db[i].nameid > 0
- && (j = pc->search_inventory(sd, skill->arrow_db[i].nameid)) != INDEX_NOT_FOUND
+ if (skill->dbs->arrow_db[i].nameid > 0
+ && (j = pc->search_inventory(sd, skill->dbs->arrow_db[i].nameid)) != INDEX_NOT_FOUND
&& !sd->status.inventory[j].equip && sd->status.inventory[j].identify
) {
- if ((j = itemdb_viewid(skill->arrow_db[i].nameid)) > 0)
+ if ((j = itemdb_viewid(skill->dbs->arrow_db[i].nameid)) > 0)
WFIFOW(fd,c*2+4) = j;
else
- WFIFOW(fd,c*2+4) = skill->arrow_db[i].nameid;
+ WFIFOW(fd,c*2+4) = skill->dbs->arrow_db[i].nameid;
c++;
}
}
@@ -3459,6 +3460,7 @@ void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok)
/// 0 = Room has been successfully created (opens chat room)
/// 1 = Room limit exceeded
/// 2 = Same room already exists
+// TODO: Flag enum
void clif_createchat(struct map_session_data* sd, int flag)
{
int fd;
@@ -4003,7 +4005,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds
clif->charm_single(sd->fd, dstsd);
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);
+ clif->sc_load(&sd->bl,dstsd->bl.id,SELF,status->dbs->IconChangeTable[dstsd->sc_display[i]->type],dstsd->sc_display[i]->val1,dstsd->sc_display[i]->val2,dstsd->sc_display[i]->val3);
}
if( (sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting.
(sd->bg_id && sd->bg_id == dstsd->bg_id) || //BattleGround
@@ -4012,11 +4014,11 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds
clif->hpmeter_single(sd->fd, dstsd->bl.id, dstsd->battle_status.hp, dstsd->battle_status.max_hp);
// display link (sd - dstsd) to sd
- ARR_FIND( 0, 5, i, sd->devotion[i] == dstsd->bl.id );
- if( i < 5 ) clif->devotion(&sd->bl, sd);
+ ARR_FIND( 0, MAX_PC_DEVOTION, i, sd->devotion[i] == dstsd->bl.id );
+ if( i < MAX_PC_DEVOTION ) clif->devotion(&sd->bl, sd);
// display links (dstsd - devotees) to sd
- ARR_FIND( 0, 5, i, dstsd->devotion[i] > 0 );
- if( i < 5 ) clif->devotion(&dstsd->bl, sd);
+ ARR_FIND( 0, MAX_PC_DEVOTION, i, dstsd->devotion[i] > 0 );
+ if( i < MAX_PC_DEVOTION ) clif->devotion(&dstsd->bl, sd);
// display link (dstsd - crusader) to sd
if( dstsd->sc.data[SC_DEVOTION] && (d_bl = map->id2bl(dstsd->sc.data[SC_DEVOTION]->val1)) != NULL )
clif->devotion(d_bl, sd);
@@ -4131,20 +4133,8 @@ int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int damage, i
/// Sends a 'damage' packet (src performs action on dst)
/// 008a <src ID>.L <dst ID>.L <server tick>.L <src speed>.L <dst speed>.L <damage>.W <div>.W <type>.B <damage2>.W (ZC_NOTIFY_ACT)
/// 02e1 <src ID>.L <dst ID>.L <server tick>.L <src speed>.L <dst speed>.L <damage>.L <div>.W <type>.B <damage2>.L (ZC_NOTIFY_ACT2)
-/// type:
-/// 0 = damage [ damage: total damage, div: amount of hits, damage2: assassin dual-wield damage ]
-/// 1 = pick up item
-/// 2 = sit down
-/// 3 = stand up
-/// 4 = damage (endure)
-/// 5 = (splash?)
-/// 6 = (skill?)
-/// 7 = (repeat damage?)
-/// 8 = multi-hit damage
-/// 9 = multi-hit damage (endure)
-/// 10 = critical hit
-/// 11 = lucky dodge
-/// 12 = (touch skill?)
+/// type: @see enum battle_dmg_type
+/// for BDT_NORMAL: [ damage: total damage, div: amount of hits, damage2: assassin dual-wield damage ]
int clif_damage(struct block_list* src, struct block_list* dst, int sdelay, int ddelay, int64 in_damage, short div, unsigned char type, int64 in_damage2) {
struct packet_damage p;
struct status_change *sc;
@@ -4222,7 +4212,7 @@ int clif_damage(struct block_list* src, struct block_list* dst, int sdelay, int
*------------------------------------------*/
void clif_takeitem(struct block_list* src, struct block_list* dst)
{
- //clif->damage(src,dst,0,0,0,0,1,0);
+ //clif->damage(src,dst,0,0,0,0,BDT_PICKUP,0);
unsigned char buf[32];
nullpo_retv(src);
@@ -4576,15 +4566,23 @@ void clif_skillinfoblock(struct map_session_data *sd)
WFIFOW(fd,0) = 0x10f;
for ( i = 0, len = 4; i < MAX_SKILL; i++) {
if( (id = sd->status.skill[i].id) != 0 ) {
+ int level;
// workaround for bugreport:5348
if (len + 37 > 8192)
break;
- WFIFOW(fd,len) = id;
- WFIFOL(fd,len+2) = skill->get_inf(id);
- WFIFOW(fd,len+6) = sd->status.skill[i].lv;
- WFIFOW(fd,len+8) = skill->get_sp(id,sd->status.skill[i].lv);
- WFIFOW(fd,len+10)= skill->get_range2(&sd->bl, id,sd->status.skill[i].lv);
+ WFIFOW(fd, len) = id;
+ WFIFOL(fd, len + 2) = skill->get_inf(id);
+ level = sd->status.skill[i].lv;
+ WFIFOW(fd, len + 6) = level;
+ if (level) {
+ WFIFOW(fd, len + 8) = skill->get_sp(id, level);
+ WFIFOW(fd, len + 10)= skill->get_range2(&sd->bl, id, level);
+ }
+ else {
+ WFIFOW(fd, len + 8) = 0;
+ WFIFOW(fd, len + 10)= 0;
+ }
safestrncpy((char*)WFIFOP(fd,len+12), skill->get_name(id), NAME_LENGTH);
if(sd->status.skill[i].flag == SKILL_FLAG_PERMANENT)
WFIFOB(fd,len+36) = (sd->status.skill[i].lv < skill->tree_get_max(id, sd->status.class_))? 1:0;
@@ -4612,26 +4610,33 @@ void clif_skillinfoblock(struct map_session_data *sd)
/// 0111 <skill id>.W <type>.L <level>.W <sp cost>.W <attack range>.W <skill name>.24B <upgradable>.B
void clif_addskill(struct map_session_data *sd, int id)
{
- int fd, idx = skill->get_index(id);
+ int fd, skill_lv, idx = skill->get_index(id);
nullpo_retv(sd);
fd = sd->fd;
if (!fd) return;
- if( sd->status.skill[idx].id <= 0 )
+ if (sd->status.skill[idx].id <= 0)
return;
+ skill_lv = sd->status.skill[idx].lv;
+
WFIFOHEAD(fd, packet_len(0x111));
WFIFOW(fd,0) = 0x111;
WFIFOW(fd,2) = id;
WFIFOL(fd,4) = skill->get_inf(id);
- WFIFOW(fd,8) = sd->status.skill[idx].lv;
- WFIFOW(fd,10) = skill->get_sp(id,sd->status.skill[idx].lv);
- WFIFOW(fd,12)= skill->get_range2(&sd->bl, id,sd->status.skill[idx].lv);
+ WFIFOW(fd,8) = skill_lv;
+ if (skill_lv > 0) {
+ WFIFOW(fd,10) = skill->get_sp(id, skill_lv);
+ WFIFOW(fd,12) = skill->get_range2(&sd->bl, id, skill_lv);
+ } else {
+ WFIFOW(fd,10) = 0;
+ WFIFOW(fd,12) = 0;
+ }
safestrncpy((char*)WFIFOP(fd,14), skill->get_name(id), NAME_LENGTH);
- if( sd->status.skill[idx].flag == SKILL_FLAG_PERMANENT )
- WFIFOB(fd,38) = (sd->status.skill[idx].lv < skill->tree_get_max(id, sd->status.class_))? 1:0;
+ if (sd->status.skill[idx].flag == SKILL_FLAG_PERMANENT)
+ WFIFOB(fd,38) = (skill_lv < skill->tree_get_max(id, sd->status.class_))? 1:0;
else
WFIFOB(fd,38) = 0;
WFIFOSET(fd,packet_len(0x111));
@@ -4691,16 +4696,22 @@ void clif_skillinfo(struct map_session_data *sd,int skill_id, int inf)
{
const int fd = sd->fd;
int idx = skill->get_index(skill_id);
+ int skill_lv = sd->status.skill[idx].lv;
WFIFOHEAD(fd,packet_len(0x7e1));
WFIFOW(fd,0) = 0x7e1;
WFIFOW(fd,2) = skill_id;
WFIFOL(fd,4) = inf?inf:skill->get_inf(skill_id);
- WFIFOW(fd,8) = sd->status.skill[idx].lv;
- WFIFOW(fd,10) = skill->get_sp(skill_id,sd->status.skill[idx].lv);
- WFIFOW(fd,12) = skill->get_range2(&sd->bl,skill_id,sd->status.skill[idx].lv);
- if( sd->status.skill[idx].flag == SKILL_FLAG_PERMANENT )
- WFIFOB(fd,14) = (sd->status.skill[idx].lv < skill->tree_get_max(skill_id, sd->status.class_))? 1:0;
+ WFIFOW(fd,8) = skill_lv;
+ if (skill_lv > 0) {
+ WFIFOW(fd,10) = skill->get_sp(skill_id, skill_lv);
+ WFIFOW(fd,12) = skill->get_range2(&sd->bl, skill_id, skill_lv);
+ } else {
+ WFIFOW(fd,10) = 0;
+ WFIFOW(fd,12) = 0;
+ }
+ if (sd->status.skill[idx].flag == SKILL_FLAG_PERMANENT)
+ WFIFOB(fd,14) = (skill_lv < skill->tree_get_max(skill_id, sd->status.class_))? 1:0;
else
WFIFOB(fd,14) = 0;
WFIFOSET(fd,packet_len(0x7e1));
@@ -5179,13 +5190,13 @@ void clif_skill_produce_mix_list(struct map_session_data *sd, int skill_id , int
WFIFOW(fd, 0)=0x18d;
for(i=0,c=0;i<MAX_SKILL_PRODUCE_DB;i++){
- if( skill->can_produce_mix(sd,skill->produce_db[i].nameid, trigger, 1) &&
- ( ( skill_id > 0 && skill->produce_db[i].req_skill == skill_id ) || skill_id < 0 )
+ if( skill->can_produce_mix(sd,skill->dbs->produce_db[i].nameid, trigger, 1) &&
+ ( ( skill_id > 0 && skill->dbs->produce_db[i].req_skill == skill_id ) || skill_id < 0 )
){
- if((view = itemdb_viewid(skill->produce_db[i].nameid)) > 0)
+ if((view = itemdb_viewid(skill->dbs->produce_db[i].nameid)) > 0)
WFIFOW(fd,c*8+ 4)= view;
else
- WFIFOW(fd,c*8+ 4)= skill->produce_db[i].nameid;
+ WFIFOW(fd,c*8+ 4)= skill->dbs->produce_db[i].nameid;
WFIFOW(fd,c*8+ 6)= 0;
WFIFOW(fd,c*8+ 8)= 0;
WFIFOW(fd,c*8+10)= 0;
@@ -5226,13 +5237,13 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 skill_id
c = 0;
for( i = 0; i < MAX_SKILL_PRODUCE_DB; i++ ) {
- if( !skill->can_produce_mix(sd,skill->produce_db[i].nameid,trigger, qty) )
+ if( !skill->can_produce_mix(sd,skill->dbs->produce_db[i].nameid,trigger, qty) )
continue;
- if( (view = itemdb_viewid(skill->produce_db[i].nameid)) > 0 )
+ if( (view = itemdb_viewid(skill->dbs->produce_db[i].nameid)) > 0 )
WFIFOW(fd, 6 + 2 * c) = view;
else
- WFIFOW(fd, 6 + 2 * c) = skill->produce_db[i].nameid;
+ WFIFOW(fd, 6 + 2 * c) = skill->dbs->produce_db[i].nameid;
c++;
}
@@ -5256,7 +5267,7 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 skill_id
if( skill_id != AM_PHARMACY ) { // AM_PHARMACY is used to Cooking.
// It fails.
#if PACKETVER >= 20090922
- clif->msg_skill(sd,skill_id,0x625);
+ clif->msgtable_skill(sd, skill_id, MSG_COOKING_LIST_FAIL);
#else
WFIFOW(fd,2) = 6 + 2 * c;
WFIFOSET(fd,WFIFOW(fd,2));
@@ -5338,7 +5349,7 @@ void clif_displaymessage(const int fd, const char* mes) {
#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);
+ clif->messagecolor_self(fd, COLOR_DEFAULT, mes);
#else
size_t len;
@@ -5558,6 +5569,7 @@ void clif_map_type(struct map_session_data* sd, enum map_type type) {
/// Updates PvP ranking (ZC_NOTIFY_RANKING).
/// 019a <id>.L <ranking>.L <total>.L
+// FIXME: missing documentation for the 'type' parameter
void clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type)
{
if(type == 2) {
@@ -5703,54 +5715,30 @@ void clif_solved_charname(int fd, int charid, const char* name)
/// 017b <packet len>.W { <name id>.W }*
void clif_use_card(struct map_session_data *sd,int idx)
{
- int i,c,ep;
- int fd=sd->fd;
+ int i, c;
+ int fd;
nullpo_retv(sd);
- if (idx < 0 || idx >= MAX_INVENTORY) //Crash-fix from bad packets.
+ fd = sd->fd;
+ if (sd->state.trading != 0)
+ return;
+ if (!pc->can_insert_card(sd, idx))
return;
- if (!sd->inventory_data[idx] || sd->inventory_data[idx]->type != IT_CARD)
- return; //Avoid parsing invalid item indexes (no card/no item)
-
- ep=sd->inventory_data[idx]->equip;
- WFIFOHEAD(fd,MAX_INVENTORY * 2 + 4);
- WFIFOW(fd,0)=0x17b;
-
- for(i=c=0;i<MAX_INVENTORY;i++){
- int j;
-
- if(sd->inventory_data[i] == NULL)
- continue;
- if(sd->inventory_data[i]->type!=IT_WEAPON && sd->inventory_data[i]->type!=IT_ARMOR)
- continue;
- if(itemdb_isspecial(sd->status.inventory[i].card[0])) //Can't slot it
- continue;
-
- if (sd->status.inventory[i].identify == 0) //Not identified
- continue;
-
- 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
- continue;
+ WFIFOHEAD(fd, MAX_INVENTORY * 2 + 4);
+ WFIFOW(fd, 0) = 0x17b;
- if( sd->status.inventory[i].equip > 0 ) // Do not check items that are already equipped
+ for (i = c = 0; i < MAX_INVENTORY; i++) {
+ if (!pc->can_insert_card_into(sd, idx, i))
continue;
-
- WFIFOW(fd,4+c*2)=i+2;
+ WFIFOW(fd, 4 + c * 2) = i + 2;
c++;
}
- if( !c ) return; // no item is available for card insertion
+ if (!c) return; // no item is available for card insertion
- WFIFOW(fd,2)=4+c*2;
- WFIFOSET(fd,WFIFOW(fd,2));
+ WFIFOW(fd, 2) = 4 + c * 2;
+ WFIFOSET(fd, WFIFOW(fd, 2));
}
@@ -6183,6 +6171,14 @@ void clif_openvending(struct map_session_data* sd, int id, struct s_vending* ven
clif->addcards(WFIFOP(fd,22+i*22), &sd->status.cart[index]);
}
WFIFOSET(fd,WFIFOW(fd,2));
+
+#if PACKETVER >= 20141022
+ /** should go elsewhere perhaps? it has to be bundled with this however. **/
+ WFIFOHEAD(fd, 3);
+ WFIFOW(fd, 0) = 0xa28;
+ WFIFOB(fd, 2) = 0;/** 1 is failure. our current responses to failure are working so not yet implemented **/
+ WFIFOSET(fd, 3);
+#endif
}
@@ -6877,7 +6873,7 @@ void clif_devotion(struct block_list *src, struct map_session_data *tsd)
if( sd == NULL )
return;
- for( i = 0; i < 5; i++ )
+ for( i = 0; i < MAX_PC_DEVOTION; i++ )
WBUFL(buf,6+4*i) = sd->devotion[i];
WBUFW(buf,26) = skill->get_range2(src, CR_DEVOTION, pc->checkskill(sd, CR_DEVOTION));
}
@@ -7034,9 +7030,7 @@ void clif_guild_created(struct map_session_data *sd,int flag)
/// Notifies the client that it is belonging to a guild (ZC_UPDATE_GDID).
/// 016c <guild id>.L <emblem id>.L <mode>.L <ismaster>.B <inter sid>.L <guild name>.24B
-/// mode:
-/// &0x01 = allow invite
-/// &0x10 = allow expel
+/// mode: @see enum guild_permission
void clif_guild_belonginfo(struct map_session_data *sd, struct guild *g)
{
int ps,fd;
@@ -7286,9 +7280,7 @@ void clif_guild_positionnamelist(struct map_session_data *sd) {
/// Guild position information (ZC_POSITION_INFO).
/// 0160 <packet len>.W { <position id>.L <mode>.L <ranking>.L <pay rate>.L }*
-/// mode:
-/// &0x01 = allow invite
-/// &0x10 = allow expel
+/// mode: @see enum guild_permission
/// ranking:
/// TODO
void clif_guild_positioninfolist(struct map_session_data *sd) {
@@ -7316,9 +7308,7 @@ void clif_guild_positioninfolist(struct map_session_data *sd) {
/// Notifies clients in a guild about updated position information (ZC_ACK_CHANGE_GUILD_POSITIONINFO).
/// 0174 <packet len>.W { <position id>.L <mode>.L <ranking>.L <pay rate>.L <position name>.24B }*
-/// mode:
-/// &0x01 = allow invite
-/// &0x10 = allow expel
+/// mode: @see enum guild_permission
/// ranking:
/// TODO
void clif_guild_positionchanged(struct guild *g,int idx)
@@ -7432,8 +7422,13 @@ void clif_guild_skillinfo(struct map_session_data* sd)
WFIFOW(fd,p+0) = id;
WFIFOL(fd,p+2) = skill->get_inf(id);
WFIFOW(fd,p+6) = g->skill[i].lv;
- WFIFOW(fd,p+8) = skill->get_sp(id, g->skill[i].lv);
- WFIFOW(fd,p+10) = skill->get_range(id, g->skill[i].lv);
+ if ( g->skill[i].lv ) {
+ WFIFOW(fd, p + 8) = skill->get_sp(id, g->skill[i].lv);
+ WFIFOW(fd, p + 10) = skill->get_range(id, g->skill[i].lv);
+ } else {
+ WFIFOW(fd, p + 8) = 0;
+ WFIFOW(fd, p + 10) = 0;
+ }
safestrncpy((char*)WFIFOP(fd,p+12), skill->get_name(id), NAME_LENGTH);
WFIFOB(fd,p+36)= (g->skill[i].lv < guild->skill_get_max(id) && sd == g->member[0].sd) ? 1 : 0;
c++;
@@ -8107,28 +8102,41 @@ void clif_specialeffect_value(struct block_list* bl, int effect_id, int num, sen
clif->send(buf, packet_len(0x284), bl, SELF);
}
}
-// Modification of clif_messagecolor to send colored messages to players to chat log only (doesn't display overhead)
-/// 02c1 <packet len>.W <id>.L <color>.L <message>.?B
-int clif_colormes(int fd, enum clif_colors color, const char* msg) {
+/**
+ * Modification of clif_messagecolor to send colored messages to players to chat log only (doesn't display overhead).
+ *
+ * 02c1 <packet len>.W <id>.L <color>.L <message>.?B
+ *
+ * @param fd Target fd to send the message to
+ * @param color Message color (RGB format: 0xRRGGBB)
+ * @param msg Message text
+ */
+void clif_messagecolor_self(int fd, uint32 color, const char *msg)
+{
size_t msg_len = strlen(msg) + 1;
WFIFOHEAD(fd,msg_len + 12);
WFIFOW(fd,0) = 0x2C1;
WFIFOW(fd,2) = msg_len + 12;
WFIFOL(fd,4) = 0;
- WFIFOL(fd,8) = color_table[color];
+ WFIFOL(fd,8) = RGB2BGR(color);
safestrncpy((char*)WFIFOP(fd,12), msg, msg_len);
WFIFOSET(fd, msg_len + 12);
-
- return 0;
}
-/// Monster/NPC color chat [SnakeDrak] (ZC_NPC_CHAT).
-/// 02c1 <packet len>.W <id>.L <color>.L <message>.?B
-void clif_messagecolor(struct block_list* bl, unsigned int color, const char* msg) {
+/**
+ * Monster/NPC color chat [SnakeDrak] (ZC_NPC_CHAT).
+ *
+ * 02c1 <packet len>.W <id>.L <color>.L <message>.?B
+ *
+ * @param bl Source block list.
+ * @param color Message color (RGB format: 0xRRGGBB)
+ * @param msg Message text
+ */
+void clif_messagecolor(struct block_list* bl, uint32 color, const char *msg)
+{
size_t msg_len = strlen(msg) + 1;
uint8 buf[256];
- color = (color & 0x0000FF) << 16 | (color & 0x00FF00) | (color & 0xFF0000) >> 16; // RGB to BGR
nullpo_retv(bl);
@@ -8140,48 +8148,29 @@ void clif_messagecolor(struct block_list* bl, unsigned int color, const char* ms
WBUFW(buf,0) = 0x2C1;
WBUFW(buf,2) = msg_len + 12;
WBUFL(buf,4) = bl->id;
- WBUFL(buf,8) = color;
+ WBUFL(buf,8) = RGB2BGR(color);
memcpy(WBUFP(buf,12), msg, msg_len);
clif->send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC);
}
-/// Public chat message [Valaris] (ZC_NOTIFY_CHAT).
-/// 008d <packet len>.W <id>.L <message>.?B
-void clif_message(struct block_list* bl, const char* msg) {
- unsigned short msg_len = strlen(msg) + 1;
- uint8 buf[256];
- nullpo_retv(bl);
-
- if( msg_len > sizeof(buf)-8 ) {
- ShowWarning("clif_message: Truncating too long message '%s' (len=%u).\n", msg, msg_len);
- msg_len = sizeof(buf)-8;
- }
-
- WBUFW(buf,0) = 0x8d;
- WBUFW(buf,2) = msg_len + 8;
- WBUFL(buf,4) = bl->id;
- safestrncpy((char*)WBUFP(buf,8), msg, msg_len);
-
- clif->send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC);
-}
-
/**
* Notifies the client that the storage window is still open
*
* Should only be used in cases where the client closed the
* storage window without server's consent
**/
-void clif_refresh_storagewindow( struct map_session_data *sd ) {
+void clif_refresh_storagewindow(struct map_session_data *sd)
+{
// Notify the client that the storage is open
- if( sd->state.storage_flag == 1 ) {
+ if (sd->state.storage_flag == STORAGE_FLAG_NORMAL) {
storage->sortitem(sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items));
clif->storagelist(sd, sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items));
clif->updatestorageamount(sd, sd->status.storage.storage_amount, MAX_STORAGE);
}
// Notify the client that the gstorage is open otherwise it will
// remain locked forever and nobody will be able to access it
- if( sd->state.storage_flag == 2 ) {
+ if (sd->state.storage_flag == STORAGE_FLAG_GUILD) {
struct guild_storage *gstor;
if( (gstor = idb_get(gstorage->db,sd->status.guild_id)) == NULL) {
// Shouldn't happen... The information should already be at the map-server
@@ -8231,7 +8220,7 @@ void clif_refresh(struct map_session_data *sd)
map->foreachinrange(clif->getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd);
clif->weather_check(sd);
if( sd->chatID )
- chat->leave(sd,0);
+ chat->leave(sd, false);
if( sd->state.vending )
clif->openvending(sd, sd->bl.id, sd->vending);
if( pc_issit(sd) )
@@ -8712,9 +8701,15 @@ void clif_viewequip_ack(struct map_session_data* sd, struct map_session_data* ts
}
-/// Display msgstringtable.txt string (ZC_MSG).
-/// 0291 <message>.W
-void clif_msg(struct map_session_data* sd, unsigned short id)
+/**
+ * Displays a string from msgstringtable.txt (ZC_MSG).
+ *
+ * 0291 <msg id>.W
+ *
+ * @param sd The target character.
+ * @param msg_id msgstringtable message index, 0-based (@see enum clif_messages)
+ */
+void clif_msgtable(struct map_session_data* sd, unsigned short msg_id)
{
int fd;
nullpo_retv(sd);
@@ -8722,31 +8717,47 @@ void clif_msg(struct map_session_data* sd, unsigned short id)
WFIFOHEAD(fd, packet_len(0x291));
WFIFOW(fd, 0) = 0x291;
- WFIFOW(fd, 2) = id; // zero-based msgstringtable.txt index
+ WFIFOW(fd, 2) = msg_id; // zero-based msgstringtable.txt index
WFIFOSET(fd, packet_len(0x291));
}
-
-/// Display msgstringtable.txt string and fill in a valid for %d format (ZC_MSG_VALUE).
-/// 0x7e2 <message>.W <value>.L
-void clif_msg_value(struct map_session_data* sd, unsigned short id, int value)
+/**
+ * Displays a format string from msgstringtable.txt with a %d value (ZC_MSG_VALUE).
+ *
+ * 0x7e2 <msg id>.W <value>.L
+ *
+ * @param sd The target character.
+ * @param msg_id msgstringtable message index, 0-based (@see enum clif_messages)
+ * @param value The value to fill %d.
+ */
+void clif_msgtable_num(struct map_session_data *sd, unsigned short msg_id, int value)
{
- int fd = sd->fd;
+#if PACKETVER >= 20090805
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd, packet_len(0x7e2));
- WFIFOW(fd,0) = 0x7e2;
- WFIFOW(fd,2) = id;
- WFIFOL(fd,4) = value;
+ WFIFOW(fd, 0) = 0x7e2;
+ WFIFOW(fd, 2) = msg_id;
+ WFIFOL(fd, 4) = value;
WFIFOSET(fd, packet_len(0x7e2));
+#endif
}
-
-/// Displays msgstringtable.txt string, prefixed with a skill name. (ZC_MSG_SKILL).
-/// 07e6 <skill id>.W <msg id>.L
-///
-/// NOTE: Message has following format and is printed in color 0xCDCDFF (purple):
-/// "[SkillName] Message"
-void clif_msg_skill(struct map_session_data* sd, uint16 skill_id, int msg_id)
+/**
+ * Displays a string from msgstringtable.txt, prefixed with a skill name (ZC_MSG_SKILL).
+ *
+ * 07e6 <skill id>.W <msg id>.L
+ *
+ * NOTE: Message has following format and is printed in color 0xCDCDFF (purple):
+ * "[SkillName] Message"
+ *
+ * @param sd The target character.
+ * @param skill_id ID of the skill to display.
+ * @param msg_id msgstringtable message index, 0-based (@see enum clif_messages)
+ */
+void clif_msgtable_skill(struct map_session_data* sd, uint16 skill_id, int msg_id)
{
int fd = sd->fd;
@@ -8857,12 +8868,13 @@ void clif_channel_msg(struct channel_data *chan, struct map_session_data *sd, ch
DBIterator *iter = db_iterator(chan->users);
struct map_session_data *user;
unsigned short msg_len = strlen(msg) + 1;
+ uint32 color = channel->config->colors[chan->color];
WFIFOHEAD(sd->fd,msg_len + 12);
WFIFOW(sd->fd,0) = 0x2C1;
WFIFOW(sd->fd,2) = msg_len + 12;
WFIFOL(sd->fd,4) = 0;
- WFIFOL(sd->fd,8) = channel->config->colors[chan->color];
+ WFIFOL(sd->fd,8) = RGB2BGR(color);
safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len);
for (user = dbi_first(iter); dbi_exists(iter); user = dbi_next(iter)) {
@@ -8884,11 +8896,12 @@ void clif_channel_msg2(struct channel_data *chan, char *msg)
struct map_session_data *user;
unsigned char buf[210];
unsigned short msg_len = strlen(msg) + 1;
+ uint32 color = channel->config->colors[chan->color];
WBUFW(buf,0) = 0x2C1;
WBUFW(buf,2) = msg_len + 12;
WBUFL(buf,4) = 0;
- WBUFL(buf,8) = channel->config->colors[chan->color];
+ WBUFL(buf,8) = RGB2BGR(color);
safestrncpy((char*)WBUFP(buf,12), msg, msg_len);
for (user = dbi_first(iter); dbi_exists(iter); user = dbi_next(iter)) {
@@ -8984,9 +8997,6 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) {
/// Notification from the client, that it has finished map loading and is about to display player's character (CZ_NOTIFY_ACTORINIT).
/// 007d
void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
-#if PACKETVER >= 20090218
- int i;
-#endif
bool first_time = false;
if(sd->bl.prev != NULL)
@@ -9171,10 +9181,13 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
//Auron reported that This skill only triggers when you logon on the map o.O [Skotlex]
if ((lv = pc->checkskill(sd,SG_KNOWLEDGE)) > 0) {
- if(sd->bl.m == sd->feel_map[0].m
- || sd->bl.m == sd->feel_map[1].m
- || sd->bl.m == sd->feel_map[2].m)
- sc_start(NULL,&sd->bl, SC_KNOWLEDGE, 100, lv, skill->get_time(SG_KNOWLEDGE, lv));
+ int i;
+ for (i = 0; i < MAX_PC_FEELHATE; i++) {
+ if (sd->bl.m == sd->feel_map[i].m) {
+ sc_start(NULL,&sd->bl, SC_KNOWLEDGE, 100, lv, skill->get_time(SG_KNOWLEDGE, lv));
+ break;
+ }
+ }
}
if(sd->pd && sd->pd->pet.intimate > 900)
@@ -9202,14 +9215,16 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
clif->updatestatus(sd,SP_DEX);
clif->updatestatus(sd,SP_LUK);
- // abort currently running script
- sd->state.using_fake_npc = 0;
- sd->state.menu_or_input = 0;
- sd->npc_menu = 0;
-
- if(sd->npc_id)
- npc->event_dequeue(sd);
-
+ if (sd->state.warp_clean) {
+ // abort currently running script
+ sd->state.using_fake_npc = 0;
+ sd->state.menu_or_input = 0;
+ sd->npc_menu = 0;
+ if(sd->npc_id)
+ npc->event_dequeue(sd);
+ } else {
+ sd->state.warp_clean = 1;
+ }
if( sd->guild && ( battle_config.guild_notice_changemap == 2 || ( battle_config.guild_notice_changemap == 1 && sd->state.changemap ) ) )
clif->guild_notice(sd,sd->guild);
}
@@ -9254,6 +9269,9 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
if (channel->config->local && channel->config->local_autojoin) {
channel->map_join(sd);
}
+ if (channel->config->irc && channel->config->irc_autojoin) {
+ channel->irc_join(sd);
+ }
}
mail->clear(sd);
@@ -9317,14 +9335,17 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
// NPC Quest / Event Icon Check [Kisuka]
#if PACKETVER >= 20090218
- for(i = 0; i < map->list[sd->bl.m].qi_count; i++) {
- struct questinfo *qi = &map->list[sd->bl.m].qi_data[i];
- if( quest->check(sd, qi->quest_id, HAVEQUEST) == -1 ) {// Check if quest is not started
- if( qi->hasJob ) { // Check if quest is job-specific, check is user is said job class.
- if( sd->class_ == qi->job )
+ {
+ int i;
+ for(i = 0; i < map->list[sd->bl.m].qi_count; i++) {
+ struct questinfo *qi = &map->list[sd->bl.m].qi_data[i];
+ if( quest->check(sd, qi->quest_id, HAVEQUEST) == -1 ) {// Check if quest is not started
+ if( qi->hasJob ) { // Check if quest is job-specific, check is user is said job class.
+ if( sd->class_ == qi->job )
+ clif->quest_show_event(sd, &qi->nd->bl, qi->icon, qi->color);
+ } else {
clif->quest_show_event(sd, &qi->nd->bl, qi->icon, qi->color);
- } else {
- clif->quest_show_event(sd, &qi->nd->bl, qi->icon, qi->color);
+ }
}
}
}
@@ -9633,6 +9654,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
} else if ( sd->fontcolor && !sd->chatID ) {
char mout[200];
unsigned char mylen = 1;
+ uint32 color = 0;
if( sd->disguise == -1 ) {
sd->fontcolor_tid = timer->add(timer->gettick()+5000, clif->undisguise_timer, sd->bl.id, 0);
@@ -9650,11 +9672,12 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
mylen += snprintf(mout, 200, "%s : %s",sd->fakename[0]?sd->fakename:sd->status.name,message);
+ color = channel->config->colors[sd->fontcolor - 1];
WFIFOHEAD(fd,mylen + 12);
WFIFOW(fd,0) = 0x2C1;
WFIFOW(fd,2) = mylen + 12;
WFIFOL(fd,4) = sd->bl.id;
- WFIFOL(fd,8) = channel->config->colors[sd->fontcolor - 1];
+ WFIFOL(fd,8) = RGB2BGR(color);
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;
@@ -9841,7 +9864,7 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type,
return;
if(action_type != 0x00 && action_type != 0x07)
- pc_stop_walking(sd, 1);
+ pc_stop_walking(sd, STOPWALKING_FLAG_FIXPOS);
pc_stop_attack(sd);
if(target_id<0 && -target_id == sd->bl.id) // for disguises [Valaris]
@@ -10245,7 +10268,7 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd) {
if( sd->npc_id ) {
if ( !sd->npc_item_flag )
return;
- } else if ( sd->state.storage_flag || sd->sc.opt1 )
+ } else if (sd->state.storage_flag != STORAGE_FLAG_CLOSED || sd->sc.opt1)
; //You can equip/unequip stuff while storage is open/under status changes
else if ( pc_cant_act2(sd) || sd->state.prerefining )
return;
@@ -10287,7 +10310,7 @@ void clif_parse_UnequipItem(int fd,struct map_session_data *sd)
if( sd->npc_id ) {
if ( !sd->npc_item_flag )
return;
- } else if ( sd->state.storage_flag || sd->sc.opt1 )
+ } else if (sd->state.storage_flag != STORAGE_FLAG_CLOSED || sd->sc.opt1)
; //You can equip/unequip stuff while storage is open/under status changes
else if ( pc_cant_act2(sd) || sd->state.prerefining )
return;
@@ -10297,7 +10320,7 @@ void clif_parse_UnequipItem(int fd,struct map_session_data *sd)
if( battle_config.idletime_criteria & BCIDLE_USEITEM )
sd->idletime = sockt->last_tick;
- pc->unequipitem(sd,index,1);
+ pc->unequipitem(sd,index, PCUNEQUIPITEM_RECALC);
}
@@ -10315,7 +10338,7 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
}
if( sd->npc_id || sd->state.workinprogress&2 ){
#ifdef RENEWAL
- clif->msg(sd, 0x783); // TODO look for the client date that has this message.
+ clif->msgtable(sd, MSG_NPC_WORK_IN_PROGRESS); // TODO look for the client date that has this message.
#endif
return;
}
@@ -10330,7 +10353,7 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
case BL_NPC:
if( sd->ud.skill_id < RK_ENCHANTBLADE && sd->ud.skilltimer != INVALID_TIMER ) {// TODO: should only work with none 3rd job skills
#ifdef RENEWAL
- clif->msg(sd, 0x783);
+ clif->msgtable(sd, MSG_NPC_WORK_IN_PROGRESS);
#endif
break;
}
@@ -10525,7 +10548,7 @@ void clif_parse_KickFromChat(int fd,struct map_session_data *sd)
/// 00e3
void clif_parse_ChatLeave(int fd, struct map_session_data* sd)
{
- chat->leave(sd,0);
+ chat->leave(sd, false);
}
@@ -10682,7 +10705,7 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
#ifdef RENEWAL
if( sd->npc_id || sd->state.workinprogress&1 ){
- clif->msg(sd, 0x783);
+ clif->msgtable(sd, MSG_NPC_WORK_IN_PROGRESS);
return;
}
#endif
@@ -10872,7 +10895,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
if( sd->npc_id || sd->state.workinprogress&1 ){
#ifdef RENEWAL
- clif->msg(sd, 0x783); // TODO look for the client date that has this message.
+ clif->msgtable(sd, MSG_NPC_WORK_IN_PROGRESS); // TODO look for the client date that has this message.
#endif
return;
}
@@ -10880,7 +10903,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
if( pc_cant_act(sd)
&& skill_id != RK_REFRESH
&& !(skill_id == SR_GENTLETOUCH_CURE && (sd->sc.opt1 == OPT1_STONE || sd->sc.opt1 == OPT1_FREEZE || sd->sc.opt1 == OPT1_STUN))
- && ( sd->state.storage_flag && !(tmp&INF_SELF_SKILL) ) // SELF skills can be used with the storage open, issue: 8027
+ && (sd->state.storage_flag != STORAGE_FLAG_CLOSED && !(tmp&INF_SELF_SKILL)) // SELF skills can be used with the storage open, issue: 8027
)
return;
@@ -10968,7 +10991,7 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski
#ifdef RENEWAL
if( sd->state.workinprogress&1 ){
- clif->msg(sd, 0x783); // TODO look for the client date that has this message.
+ clif->msgtable(sd, MSG_NPC_WORK_IN_PROGRESS); // TODO look for the client date that has this message.
return;
}
#endif
@@ -11085,7 +11108,7 @@ void clif_parse_UseSkillMap(int fd, struct map_session_data* sd)
return;
// It is possible to use teleport with the storage window open issue:8027
- if( pc_cant_act(sd) && (!sd->state.storage_flag && skill_id != AL_TELEPORT) ) {
+ if (pc_cant_act(sd) && (sd->state.storage_flag == STORAGE_FLAG_CLOSED && skill_id != AL_TELEPORT)) {
clif_menuskill_clear(sd);
return;
}
@@ -11349,8 +11372,6 @@ void clif_parse_AutoSpell(int fd,struct map_session_data *sd)
/// 017a <card index>.W
void clif_parse_UseCard(int fd,struct map_session_data *sd)
{
- if (sd->state.trading != 0)
- return;
clif->use_card(sd,RFIFOW(fd,2)-2);
}
@@ -11359,8 +11380,6 @@ void clif_parse_UseCard(int fd,struct map_session_data *sd)
/// 017c <card index>.W <equip index>.W
void clif_parse_InsertCard(int fd,struct map_session_data *sd)
{
- if (sd->state.trading != 0)
- return;
pc->insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2);
}
@@ -11428,9 +11447,9 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd)
if (item_index < 0 || item_index >= MAX_INVENTORY || item_amount < 1)
return;
- if (sd->state.storage_flag == 1)
+ if (sd->state.storage_flag == STORAGE_FLAG_NORMAL)
storage->add(sd, item_index, item_amount);
- else if (sd->state.storage_flag == 2)
+ else if (sd->state.storage_flag == STORAGE_FLAG_GUILD)
gstorage->add(sd, item_index, item_amount);
}
@@ -11446,9 +11465,9 @@ void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd)
item_index = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0])-1;
item_amount = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[1]);
- if (sd->state.storage_flag == 1)
+ if (sd->state.storage_flag == STORAGE_FLAG_NORMAL)
storage->get(sd, item_index, item_amount);
- else if(sd->state.storage_flag == 2)
+ else if(sd->state.storage_flag == STORAGE_FLAG_GUILD)
gstorage->get(sd, item_index, item_amount);
}
@@ -11462,9 +11481,9 @@ void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd)
if (!pc_iscarton(sd))
return;
- if (sd->state.storage_flag == 1)
+ if (sd->state.storage_flag == STORAGE_FLAG_NORMAL)
storage->addfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
- else if (sd->state.storage_flag == 2)
+ else if (sd->state.storage_flag == STORAGE_FLAG_GUILD)
gstorage->addfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
}
@@ -11478,9 +11497,9 @@ void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd)
if (!pc_iscarton(sd))
return;
- if (sd->state.storage_flag == 1)
+ if (sd->state.storage_flag == STORAGE_FLAG_NORMAL)
storage->gettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
- else if (sd->state.storage_flag == 2)
+ else if (sd->state.storage_flag == STORAGE_FLAG_GUILD)
gstorage->gettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
}
@@ -11489,9 +11508,9 @@ void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd)
/// 00f7
void clif_parse_CloseKafra(int fd, struct map_session_data *sd)
{
- if( sd->state.storage_flag == 1 )
+ if( sd->state.storage_flag == STORAGE_FLAG_NORMAL )
storage->close(sd);
- else if( sd->state.storage_flag == 2 )
+ else if( sd->state.storage_flag == STORAGE_FLAG_GUILD )
gstorage->close(sd);
}
@@ -12701,7 +12720,7 @@ bool clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_sessi
return false;
}
- if ( t_sd && t_sd->state.noask ) {// @noask [LuzZza]
+ if (t_sd->state.noask) {// @noask [LuzZza]
clif->noask_sub(sd, t_sd, 2);
return false;
}
@@ -14142,7 +14161,7 @@ void clif_parse_AutoRevive(int fd, struct map_session_data *sd) {
if (item_position == INDEX_NOT_FOUND)
status_change_end(&sd->bl,SC_LIGHT_OF_REGENE,INVALID_TIMER);
else
- pc->delitem(sd, item_position, 1, 0, 1, LOG_TYPE_CONSUME);
+ pc->delitem(sd, item_position, 1, 0, DELITEM_SKILLUSE, LOG_TYPE_CONSUME);
clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
}
@@ -14672,7 +14691,7 @@ void clif_Auction_openwindow(struct map_session_data *sd)
{
int fd = sd->fd;
- if( sd->state.storage_flag || sd->state.vending || sd->state.buyingstore || sd->state.trading )
+ if (sd->state.storage_flag != STORAGE_FLAG_CLOSED || sd->state.vending || sd->state.buyingstore || sd->state.trading)
return;
if( !battle_config.feature_auction )
@@ -14918,7 +14937,7 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd)
{
int zeny = auction.hours*battle_config.auction_feeperhour;
- pc->delitem(sd, sd->auction.index, sd->auction.amount, 1, 6, LOG_TYPE_AUCTION);
+ pc->delitem(sd, sd->auction.index, sd->auction.amount, 1, DELITEM_SOLD, LOG_TYPE_AUCTION);
sd->auction.amount = 0;
pc->payzeny(sd, zeny, LOG_TYPE_AUCTION, NULL);
@@ -15269,7 +15288,7 @@ void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) {
if( tsd->status.show_equip || pc_has_permission(sd, PC_PERM_VIEW_EQUIPMENT) )
clif->viewequip_ack(sd, tsd);
else
- clif_viewequip_fail(sd);
+ clif->msgtable(sd, MSG_EQUIP_NOT_PUBLIC);
}
@@ -15632,8 +15651,13 @@ void clif_mercenary_skillblock(struct map_session_data *sd)
WFIFOW(fd,len) = id;
WFIFOL(fd,len+2) = skill->get_inf(id);
WFIFOW(fd,len+6) = md->db->skill[j].lv;
- WFIFOW(fd,len+8) = skill->get_sp(id, md->db->skill[j].lv);
- WFIFOW(fd,len+10) = skill->get_range2(&md->bl, id, md->db->skill[j].lv);
+ if ( md->db->skill[j].lv ) {
+ WFIFOW(fd, len + 8) = skill->get_sp(id, md->db->skill[j].lv);
+ WFIFOW(fd, len + 10) = skill->get_range2(&md->bl, id, md->db->skill[j].lv);
+ } else {
+ WFIFOW(fd, len + 8) = 0;
+ WFIFOW(fd, len + 10) = 0;
+ }
safestrncpy((char*)WFIFOP(fd,len+12), skill->get_name(id), NAME_LENGTH);
WFIFOB(fd,len+36) = 0; // Skillable for Mercenary?
len += 37;
@@ -15667,7 +15691,7 @@ void clif_parse_mercenary_action(int fd, struct map_session_data* sd)
/// 3 = Your mercenary soldier has ran away.
void clif_mercenary_message(struct map_session_data* sd, int message)
{
- clif->msg(sd, 1266 + message);
+ clif->msgtable(sd, MSG_MERCENARY_EXPIRED + message);
}
@@ -16701,11 +16725,11 @@ int clif_elementalconverter_list(struct map_session_data *sd) {
WFIFOW(fd, 0)=0x1ad;
for(i=0,c=0;i<MAX_SKILL_PRODUCE_DB;i++){
- if( skill->can_produce_mix(sd,skill->produce_db[i].nameid,23, 1) ){
- if((view = itemdb_viewid(skill->produce_db[i].nameid)) > 0)
+ if( skill->can_produce_mix(sd,skill->dbs->produce_db[i].nameid,23, 1) ){
+ if((view = itemdb_viewid(skill->dbs->produce_db[i].nameid)) > 0)
WFIFOW(fd,c*2+ 4)= view;
else
- WFIFOW(fd,c*2+ 4)= skill->produce_db[i].nameid;
+ WFIFOW(fd,c*2+ 4)= skill->dbs->produce_db[i].nameid;
c++;
}
}
@@ -16903,26 +16927,6 @@ int clif_skill_itemlistwindow( struct map_session_data *sd, uint16 skill_id, uin
return 1;
}
-// msgstringtable.txt
-// 0x291 <line>.W
-void clif_msgtable(int fd, int line) {
- WFIFOHEAD(fd, packet_len(0x291));
- WFIFOW(fd, 0) = 0x291;
- WFIFOW(fd, 2) = line;
- WFIFOSET(fd, packet_len(0x291));
-}
-
-// msgstringtable.txt
-// 0x7e2 <line>.W <value>.L
-void clif_msgtable_num(int fd, int line, int num) {
-#if PACKETVER >= 20090805
- WFIFOHEAD(fd, packet_len(0x7e2));
- WFIFOW(fd, 0) = 0x7e2;
- WFIFOW(fd, 2) = line;
- WFIFOL(fd, 4) = num;
- WFIFOSET(fd, packet_len(0x7e2));
-#endif
-}
/*==========================================
* used by SC_AUTOSHADOWSPELL
* RFIFOL(fd,2) - flag (currently not used)
@@ -17062,7 +17066,7 @@ void clif_favorite_item(struct map_session_data* sd, unsigned short index) {
WFIFOHEAD(fd,packet_len(0x908));
WFIFOW(fd,0) = 0x908;
WFIFOW(fd,2) = index+2;
- WFIFOL(fd,4) = (sd->status.inventory[index].favorite == 1) ? 0 : 1;
+ WFIFOB(fd,4) = (sd->status.inventory[index].favorite == 1) ? 0 : 1;
WFIFOSET(fd,packet_len(0x908));
}
@@ -17093,8 +17097,8 @@ void __attribute__ ((unused)) clif_parse_dull(int fd,struct map_session_data *sd
}
void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) {
- if( map->list[sd->bl.m].flag.nocashshop ) {
- clif->colormes(fd,COLOR_RED,msg_fd(fd,1489)); //Cash Shop is disabled in this map
+ if (map->list[sd->bl.m].flag.nocashshop) {
+ clif->messagecolor_self(fd, COLOR_RED, msg_fd(fd,1489)); //Cash Shop is disabled in this map
return;
}
@@ -17134,8 +17138,8 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
unsigned short limit = RFIFOW(fd, 4), i, j;
unsigned int kafra_pay = RFIFOL(fd, 6);// [Ryuuzaki] - These are free cash points (strangely #CASH = main cash currently for us, confusing)
- if( map->list[sd->bl.m].flag.nocashshop ) {
- clif->colormes(fd,COLOR_RED,msg_fd(fd,1489)); //Cash Shop is disabled in this map
+ if (map->list[sd->bl.m].flag.nocashshop) {
+ clif->messagecolor_self(fd, COLOR_RED, msg_fd(fd,1489)); //Cash Shop is disabled in this map
return;
}
@@ -17536,8 +17540,8 @@ void clif_parse_BankDeposit(int fd, struct map_session_data* sd) {
struct packet_banking_deposit_req *p = P2PTR(fd);
int money;
- if( !battle_config.feature_banking ) {
- clif->colormes(fd,COLOR_RED,msg_fd(fd,1483));
+ if (!battle_config.feature_banking) {
+ clif->messagecolor_self(fd, COLOR_RED, msg_fd(fd,1483));
return;
}
@@ -17550,8 +17554,8 @@ void clif_parse_BankWithdraw(int fd, struct map_session_data* sd) {
struct packet_banking_withdraw_req *p = P2PTR(fd);
int money;
- if( !battle_config.feature_banking ) {
- clif->colormes(fd,COLOR_RED,msg_fd(fd,1483));
+ if (!battle_config.feature_banking) {
+ clif->messagecolor_self(fd, COLOR_RED, msg_fd(fd,1483));
return;
}
@@ -17563,8 +17567,8 @@ void clif_parse_BankWithdraw(int fd, struct map_session_data* sd) {
void clif_parse_BankCheck(int fd, struct map_session_data* sd) {
struct packet_banking_check p;
- if( !battle_config.feature_banking ) {
- clif->colormes(fd,COLOR_RED,msg_fd(fd,1483));
+ if (!battle_config.feature_banking) {
+ clif->messagecolor_self(fd, COLOR_RED, msg_fd(fd,1483));
return;
}
@@ -17639,7 +17643,7 @@ void clif_parse_GMFullStrip(int fd, struct map_session_data *sd) {
for( i = 0; i < EQI_MAX; i++ ) {
if( tsd->equip_index[ i ] >= 0 )
- pc->unequipitem( tsd , tsd->equip_index[ i ] , 2 );
+ pc->unequipitem(tsd, tsd->equip_index[i], PCUNEQUIPITEM_FORCE);
}
}
/**
@@ -18093,6 +18097,157 @@ void clif_roulette_generate_ack(struct map_session_data *sd, unsigned char resul
clif->send(&p,sizeof(p), &sd->bl, SELF);
}
+/**
+* Stackable items merger
+**/
+void clif_openmergeitem(int fd, struct map_session_data *sd)
+{
+ int i = 0, n = 0, j = 0;
+ struct merge_item merge_items[MAX_INVENTORY];
+ struct merge_item *merge_items_[MAX_INVENTORY] = {0};
+
+ memset(&merge_items,'\0',sizeof(merge_items));
+
+ for (i = 0; i < MAX_INVENTORY; i++) {
+ struct item *item_data = &sd->status.inventory[i];
+
+ if (item_data->nameid == 0 || !itemdb->isstackable(item_data->nameid))
+ continue;
+
+ merge_items[n].nameid = item_data->nameid;
+ merge_items[n].position = i + 2;
+ n++;
+
+
+ }
+
+ qsort(merge_items,n,sizeof(struct merge_item),clif->comparemergeitem);
+
+ for (i = 0, j = 0; i < n; i++) {
+ if (i > 0 && merge_items[i].nameid == merge_items[i-1].nameid)
+ {
+ merge_items_[j] = &merge_items[i];
+ j++;
+ continue;
+ }
+
+ if (i < n - 1 && merge_items[i].nameid == merge_items[i+1].nameid)
+ {
+ merge_items_[j] = &merge_items[i];
+ j++;
+ continue;
+ }
+ }
+
+ WFIFOHEAD(fd,2*j+4);
+ WFIFOW(fd,0) = 0x96d;
+ WFIFOW(fd,2) = 2*j+4;
+ for ( i = 0; i < j; i++ )
+ WFIFOW(fd,i*2+4) = merge_items_[i]->position;
+ WFIFOSET(fd,2*j+4);
+}
+
+int clif_comparemergeitem(const void *a, const void *b)
+{
+ const struct merge_item *a_ = a;
+ const struct merge_item *b_ = b;
+
+ if (a_->nameid == b_->nameid)
+ return 0;
+ return a_->nameid > b_->nameid ? -1 : 1;
+}
+
+void clif_ackmergeitems(int fd, struct map_session_data *sd)
+{
+ int i = 0, n = 0, length = 0, count = 0;
+ int16 nameid = 0, indexes[MAX_INVENTORY] = {0}, amounts[MAX_INVENTORY] = {0};
+ struct item item_data;
+
+ length = (RFIFOW(fd,2) - 4)/2;
+
+ if (length >= MAX_INVENTORY || length < 2) {
+ WFIFOHEAD(fd,7);
+ WFIFOW(fd,0) = 0x96f;
+ WFIFOW(fd,2) = 0;
+ WFIFOW(fd,4) = 0;
+ WFIFOB(fd,6) = MERGEITEM_FAILD;
+ WFIFOSET(fd,7);
+ return;
+ }
+
+ for (i = 0, n = 0; i < length; i++) {
+ int16 idx = RFIFOW(fd,i*2+4) - 2;
+ struct item *it = NULL;
+
+ if (idx < 0 || idx >= MAX_INVENTORY)
+ continue;
+
+ it = &sd->status.inventory[idx];
+
+ if (it->nameid == 0 || !itemdb->isstackable(it->nameid))
+ continue;
+
+ if (nameid == 0)
+ nameid = it->nameid;
+
+ if (nameid != it->nameid)
+ continue;
+
+ count += it->amount;
+ indexes[n] = idx;
+ amounts[n] = it->amount;
+ n++;
+ }
+
+
+ if (n < 2 || count == 0) {
+ WFIFOHEAD(fd,7);
+ WFIFOW(fd,0) = 0x96f;
+ WFIFOW(fd,2) = 0;
+ WFIFOW(fd,4) = 0;
+ WFIFOB(fd,6) = MERGEITEM_FAILD;
+ WFIFOSET(fd,7);
+ return;
+ }
+
+ if (count > MAX_AMOUNT) {
+ WFIFOHEAD(fd,7);
+ WFIFOW(fd,0) = 0x96f;
+ WFIFOW(fd,2) = 0;
+ WFIFOW(fd,4) = 0;
+ WFIFOB(fd,6) = MERGEITEM_MAXCOUNTFAILD;
+ WFIFOSET(fd,7);
+ return;
+ }
+
+ for (i = 0; i < n; i++)
+ pc->delitem(sd,indexes[i],amounts[i],0,DELITEM_NORMAL,LOG_TYPE_NPC);
+
+
+ memset(&item_data,'\0',sizeof(item_data));
+
+ item_data.nameid = nameid;
+ item_data.identify = 1;
+ item_data.unique_id = itemdb->unique_id(sd);
+ pc->additem(sd,&item_data,count,LOG_TYPE_NPC);
+
+ ARR_FIND(0,MAX_INVENTORY,i,item_data.unique_id == sd->status.inventory[i].unique_id);
+
+ WFIFOHEAD(fd,7);
+ WFIFOW(fd,0) = 0x96f;
+ WFIFOW(fd,2) = i+2;
+ WFIFOW(fd,4) = count;
+ WFIFOB(fd,6) = MERGEITEM_SUCCESS;
+ WFIFOSET(fd,7);
+
+}
+
+void clif_cancelmergeitem (int fd, struct map_session_data *sd)
+{
+ //Track The merge item cancelation ?
+ return;
+}
+
/* */
unsigned short clif_decrypt_cmd( int cmd, struct map_session_data *sd ) {
if( sd ) {
@@ -18344,21 +18499,11 @@ void clif_bc_ready(void) {
/*==========================================
*
*------------------------------------------*/
-int do_init_clif(bool minimal) {
- const char* colors[COLOR_MAX] = { "0xFF0000", "0x00ff00", "0xffffff" };
- int i;
-
+int do_init_clif(bool minimal)
+{
if (minimal)
return 0;
- /**
- * Setup Color Table (saves unnecessary load of strtoul on every call)
- **/
- for(i = 0; i < COLOR_MAX; i++) {
- color_table[i] = (unsigned int)strtoul(colors[i],NULL,0);
- color_table[i] = (color_table[i] & 0x0000FF) << 16 | (color_table[i] & 0x00FF00) | (color_table[i] & 0xFF0000) >> 16;//RGB to BGR
- }
-
packetdb_loaddb();
set_defaultparse(clif->parse);
@@ -18653,17 +18798,15 @@ void clif_defaults(void) {
clif->disp_message = clif_disp_message;
clif->broadcast = clif_broadcast;
clif->broadcast2 = clif_broadcast2;
+ clif->messagecolor_self = clif_messagecolor_self;
clif->messagecolor = clif_messagecolor;
clif->disp_overhead = clif_disp_overhead;
- clif->msg = clif_msg;
- clif->msg_value = clif_msg_value;
- clif->msg_skill = clif_msg_skill;
+ clif->msgtable_skill = clif_msgtable_skill;
clif->msgtable = clif_msgtable;
clif->msgtable_num = clif_msgtable_num;
clif->message = clif_displaymessage;
clif->messageln = clif_displaymessage2;
clif->messages = clif_displaymessage_sprintf;
- clif->colormes = clif_colormes;
clif->process_message = clif_process_message;
clif->wisexin = clif_wisexin;
clif->wisall = clif_wisall;
@@ -18894,6 +19037,12 @@ void clif_defaults(void) {
/* */
clif->parse_roulette_db = clif_parse_roulette_db;
clif->roulette_generate_ack = clif_roulette_generate_ack;
+ /* Merge Items */
+ clif->openmergeitem = clif_openmergeitem;
+ clif->cancelmergeitem = clif_cancelmergeitem;
+ clif->comparemergeitem = clif_comparemergeitem;
+ clif->ackmergeitems = clif_ackmergeitems;
+
/*------------------------
*- Parse Incoming Packet
*------------------------*/
diff --git a/src/map/clif.h b/src/map/clif.h
index 5f1a2a899..c827406ca 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -5,40 +5,38 @@
#ifndef MAP_CLIF_H
#define MAP_CLIF_H
-#include <stdarg.h>
+#include "map/map.h"
+#include "map/packets_struct.h"
+#include "common/cbasetypes.h"
+#include "common/mmo.h"
-#include "map.h"
-#include "packets_struct.h"
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/mmo.h"
+#include <stdarg.h>
/**
* Declarations
**/
+struct battleground_data;
+struct channel_data;
+struct chat_data;
+struct eri;
+struct flooritem_data;
+struct guild;
+struct homun_data;
struct item;
struct item_data;
-struct unit_data;
struct map_session_data;
-struct homun_data;
struct mercenary_data;
-struct pet_data;
struct mob_data;
struct npc_data;
-struct chat_data;
-struct flooritem_data;
-struct skill_unit;
-struct s_vending;
-struct party;
+struct party_booking_ad_info;
struct party_data;
-struct guild;
-struct battleground_data;
+struct pet_data;
struct quest;
-struct party_booking_ad_info;
-struct view_data;
-struct eri;
+struct s_vending;
struct skill_cd;
-struct channel_data;
+struct skill_unit;
+struct unit_data;
+struct view_data;
/**
* Defines
@@ -47,9 +45,14 @@ struct channel_data;
#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 MAX_ROULETTE_LEVEL 7 /** client-defined value **/
#define MAX_ROULETTE_COLUMNS 9 /** client-defined value **/
+#define RGB2BGR(c) ((c & 0x0000FF) << 16 | (c & 0x00FF00) | (c & 0xFF0000) >> 16)
+
+#define COLOR_RED 0xff0000U
+#define COLOR_GREEN 0x00ff00U
+#define COLOR_WHITE 0xffffffU
+#define COLOR_DEFAULT COLOR_GREEN
/**
* Enumerations
@@ -344,9 +347,30 @@ typedef enum useskill_fail_cause { // clif_skill_fail
}useskill_fail_cause;
enum clif_messages {
- ITEM_CANT_OBTAIN_WEIGHT = 0x34, /* you cannot carry more items because you are overweight. */
- SKILL_CANT_USE_AREA = 0x536,
- ITEM_CANT_USE_AREA = 0x537,
+ MSG_ITEM_CANT_OBTAIN_WEIGHT = 0x034, ///< You cannot carry more items because you are overweight.
+ MSG_ITEM_NEED_STANDING = 0x297, ///< You cannot use this item while sitting.
+ MSG_MERCENARY_EXPIRED = 0x4f2, ///< The mercenary contract has expired.
+ MSG_MERCENARY_DIED = 0x4f3, ///< The mercenary has died.
+ MSG_MERCENARY_RELEASED = 0x4f4, ///< You have released the mercenary.
+ MSG_MERCENARY_ESCAPED = 0x4f5, ///< The mercenary has run away.
+ MSG_SKILL_CANT_USE_AREA = 0x536, ///< This skill cannot be used within this area
+ MSG_ITEM_CANT_USE_AREA = 0x537, ///< This item cannot be used within this area.
+ MSG_EQUIP_NOT_PUBLIC = 0x54d, ///< This character's equipment information is not open to the public.
+ MSG_ITEM_NEED_MADO = 0x59b, ///< Item can only be used when Mado Gear is mounted.
+ MSG_ITEM_NEED_CART = 0x5ef, ///< Usable only when cart is put on
+ MSG_RUNE_STONE_MAX_AMOUNT = 0x61b, ///< Cannot create Rune stone more than the maximum amount.
+ MSG_SKILL_POINTS_LEFT_JOB1 = 0x61e, ///< You must consume all '%d' remaining points in your 1st Job tab.
+ MSG_SKILL_POINTS_LEFT_JOB2 = 0x61f, ///< You must consume all '%d' remaining points in your 2nd Job tab. 1st Tab is already done.
+ MSG_SKILL_ITEM_NOT_FOUND = 0x623, // FIXME[Haru]: This seems to be 0x622 in the msgstringtable files I found.
+ MSG_SKILL_SUCCESS = 0x627, // FIXME[Haru]: This seems to be 0x626 in the msgstringtable files I found.
+ MSG_SKILL_FAILURE = 0x628, // FIXME[Haru]: This seems to be 0x627 in the msgstringtable files I found.
+ MSG_SKILL_ITEM_NEED_IDENTIFY = 0x62d, ///< Unable to use unchecked items as materials.
+ MSG_ITEM_CANT_EQUIP_LVL = 0x6ed, // FIXME[Haru]: This seems to be 0x6ee in the msgstringtable files I found.
+ MSG_ITEM_CANT_USE_LVL = 0x6ee, // FIXME[Haru]: This seems to be 0x6ef in the msgstringtable files I found.
+ MSG_COOKING_LIST_FAIL = 0x625, // FIXME[Haru]: This might be a wrong message ID. Not sure what it should be.
+ MSG_SECONDS_UNTIL_USE = 0x746, ///< %d seconds left until you can use
+ MSG_NPC_WORK_IN_PROGRESS = 0x783, // FIXME[Haru]: This seems to be 0x784 in the msgstringtable files I found.
+ MSG_REINS_CANT_USE_MOUNTED = 0x78b, // FIXME[Haru]: This seems to be 0x785 in the msgstringtalbe files I found.
};
/**
@@ -365,16 +389,6 @@ enum cashshop_error {
ERROR_TYPE_NOT_ALL = 8, ///< Some items could not be purchased. (ERROR_TYPE_NOT_ALL)
};
-/**
- * Color Table
- **/
-enum clif_colors {
- COLOR_RED,
- COLOR_DEFAULT,
- COLOR_WHITE,
- COLOR_MAX
-};
-
enum CASH_SHOP_TABS {
CASHSHOP_TAB_NEW = 0,
CASHSHOP_TAB_POPULAR = 1,
@@ -495,6 +509,30 @@ enum CLOSE_ROULETTE_ACK {
};
/**
+ * Reason for item deletion (clif->delitem)
+ */
+enum delitem_reason {
+ DELITEM_NORMAL = 0, /// Normal
+ DELITEM_SKILLUSE = 1, /// Item used for a skill
+ DELITEM_FAILREFINE = 2, /// Refine failed
+ DELITEM_MATERIALCHANGE = 3, /// Material changed
+ DELITEM_TOSTORAGE = 4, /// Moved to storage
+ DELITEM_TOCART = 5, /// Moved to cart
+ DELITEM_SOLD = 6, /// Item sold
+ DELITEM_ANALYSIS = 7, /// Consumed by Four Spirit Analysis (SO_EL_ANALYSIS) skill
+};
+
+/*
+* Merge items reasons
+*/
+
+enum mergeitem_reason {
+ MERGEITEM_SUCCESS = 0x0,
+ MERGEITEM_FAILD = 0x1,
+ MERGEITEM_MAXCOUNTFAILD = 0x2,
+};
+
+/**
* Structures
**/
typedef void (*pFunc)(int, struct map_session_data *); //cant help but put it first
@@ -514,11 +552,15 @@ struct cdelayed_damage {
struct block_list bl;
};
+struct merge_item {
+ int16 position;
+ int16 nameid;
+};
+
/**
* Vars
**/
struct s_packet_db packet_db[MAX_PACKET_DB + 1];
-unsigned int color_table[COLOR_MAX];
/**
* Clif.c Interface
@@ -796,18 +838,16 @@ struct clif_interface {
void (*disp_message) (struct block_list* src, const char* mes, size_t len, enum send_target target);
void (*broadcast) (struct block_list* bl, const char* mes, size_t len, int type, enum send_target target);
void (*broadcast2) (struct block_list* bl, const char* mes, size_t len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, enum send_target target);
- void (*messagecolor) (struct block_list* bl, unsigned int color, const char* msg);
+ void (*messagecolor_self) (int fd, uint32 color, const char *msg);
+ void (*messagecolor) (struct block_list* bl, uint32 color, const char* msg);
void (*disp_overhead) (struct block_list *bl, const char* mes);
- void (*msg) (struct map_session_data* sd, unsigned short id);
- void (*msg_value) (struct map_session_data* sd, unsigned short id, int value);
- void (*msg_skill) (struct map_session_data* sd, uint16 skill_id, int msg_id);
- void (*msgtable) (int fd, int line);
- void (*msgtable_num) (int fd, int line, int num);
+ void (*msgtable) (struct map_session_data* sd, unsigned short msg_id);
+ void (*msgtable_num) (struct map_session_data *sd, unsigned short msg_id, int value);
+ void (*msgtable_skill) (struct map_session_data *sd, uint16 skill_id, int msg_id);
void (*message) (const int fd, const char* mes);
void (*messageln) (const int fd, const char* mes);
/* message+s(printf) */
void (*messages) (const int fd, const char *mes, ...) __attribute__((format(printf, 2, 3)));
- int (*colormes) (int fd, enum clif_colors color, const char* msg);
bool (*process_message) (struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_);
void (*wisexin) (struct map_session_data *sd,int type,int flag);
void (*wisall) (struct map_session_data *sd,int type,int flag);
@@ -1037,6 +1077,12 @@ struct clif_interface {
/* */
bool (*parse_roulette_db) (void);
void (*roulette_generate_ack) (struct map_session_data *sd, unsigned char result, short stage, short prizeIdx, short bonusItemID);
+ /* Merge Items */
+ void (*openmergeitem) (int fd, struct map_session_data *sd);
+ void (*cancelmergeitem) (int fd, struct map_session_data *sd);
+ int (*comparemergeitem) (const void *a, const void *b);
+ void (*ackmergeitems) (int fd, struct map_session_data *sd);
+
/*------------------------
*- Parse Incoming Packet
*------------------------*/
diff --git a/src/map/date.c b/src/map/date.c
index 975a00c50..e2ad2b179 100644
--- a/src/map/date.c
+++ b/src/map/date.c
@@ -5,9 +5,9 @@
#include "date.h"
-#include <time.h>
+#include "common/cbasetypes.h"
-#include "../common/cbasetypes.h"
+#include <time.h>
int date_get_year(void)
{
diff --git a/src/map/date.h b/src/map/date.h
index a57d8132c..e7d06f29d 100644
--- a/src/map/date.h
+++ b/src/map/date.h
@@ -4,7 +4,7 @@
#ifndef MAP_DATE_H
#define MAP_DATE_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
#ifdef HERCULES_CORE
// TODO: Interface
diff --git a/src/map/duel.c b/src/map/duel.c
index 2dae0ae0e..4cd2e276f 100644
--- a/src/map/duel.c
+++ b/src/map/duel.c
@@ -6,16 +6,16 @@
#include "duel.h"
+#include "map/atcommand.h" // msg_txt
+#include "map/clif.h"
+#include "map/pc.h"
+#include "common/cbasetypes.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include "atcommand.h" // msg_txt
-#include "clif.h"
-#include "pc.h"
-#include "../common/cbasetypes.h"
-
struct duel_interface duel_s;
/*==========================================
diff --git a/src/map/duel.h b/src/map/duel.h
index fa12a4032..0c55c1266 100644
--- a/src/map/duel.h
+++ b/src/map/duel.h
@@ -5,7 +5,7 @@
#ifndef MAP_DUEL_H
#define MAP_DUEL_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
struct map_session_data;
diff --git a/src/map/elemental.c b/src/map/elemental.c
index a21c128b0..459ce2a39 100644
--- a/src/map/elemental.c
+++ b/src/map/elemental.c
@@ -6,41 +6,41 @@
#include "elemental.h"
+#include "map/atcommand.h"
+#include "map/battle.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/guild.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/map.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/party.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/script.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "map/trade.h"
+#include "map/unit.h"
+#include "common/cbasetypes.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "atcommand.h"
-#include "battle.h"
-#include "chrif.h"
-#include "clif.h"
-#include "guild.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "map.h"
-#include "mob.h"
-#include "npc.h"
-#include "party.h"
-#include "pc.h"
-#include "pet.h"
-#include "script.h"
-#include "skill.h"
-#include "status.h"
-#include "trade.h"
-#include "unit.h"
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct elemental_interface elemental_s;
int elemental_search_index(int class_) {
@@ -442,9 +442,9 @@ int elemental_action(struct elemental_data *ed, struct block_list *bl, int64 tic
ed->ud.skill_lv = skill_lv;
if( skill->get_inf(skill_id) & INF_GROUND_SKILL )
- ed->ud.skilltimer = timer->add( tick+status->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 );
+ ed->ud.skilltimer = timer->add(tick+(int64)status->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0);
else
- ed->ud.skilltimer = timer->add( tick+status->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 );
+ ed->ud.skilltimer = timer->add(tick+(int64)status->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0);
}
return 1;
@@ -560,7 +560,7 @@ int elemental_unlocktarget(struct elemental_data *ed) {
ed->target_id = 0;
elemental_stop_attack(ed);
- elemental_stop_walking(ed,1);
+ elemental_stop_walking(ed, STOPWALKING_FLAG_FIXPOS);
return 0;
}
@@ -586,8 +586,8 @@ struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16
if( skill_lv < 1 || skill_lv > MAX_SKILL_LEVEL )
return req;
- req.hp = skill->db[idx].hp[skill_lv-1];
- req.sp = skill->db[idx].sp[skill_lv-1];
+ req.hp = skill->dbs->db[idx].hp[skill_lv-1];
+ req.sp = skill->dbs->db[idx].sp[skill_lv-1];
return req;
}
diff --git a/src/map/elemental.h b/src/map/elemental.h
index 8015f84c0..582e1059c 100644
--- a/src/map/elemental.h
+++ b/src/map/elemental.h
@@ -5,9 +5,12 @@
#ifndef MAP_ELEMENTAL_H
#define MAP_ELEMENTAL_H
-#include "status.h" // struct status_data, struct status_change
-#include "unit.h" // struct unit_data
-#include "../common/mmo.h" // NAME_LENGTH
+#include "map/status.h" // struct status_data, struct status_change
+#include "map/unit.h" // struct unit_data
+#include "common/cbasetypes.h"
+#include "common/mmo.h" // NAME_LENGTH
+
+#include <stdarg.h>
/**
* Defines
diff --git a/src/map/guild.c b/src/map/guild.c
index 936b4c900..5f6ce83c6 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -4,37 +4,37 @@
#define HERCULES_CORE
-#include "../config/core.h" // GP_BOUND_ITEMS
+#include "config/core.h" // GP_BOUND_ITEMS
#include "guild.h"
+#include "map/battle.h"
+#include "map/channel.h"
+#include "map/clif.h"
+#include "map/instance.h"
+#include "map/intif.h"
+#include "map/log.h"
+#include "map/map.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/pc.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "map/storage.h"
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/ers.h"
+#include "common/malloc.h"
+#include "common/mapindex.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "battle.h"
-#include "channel.h"
-#include "clif.h"
-#include "instance.h"
-#include "intif.h"
-#include "log.h"
-#include "map.h"
-#include "mob.h"
-#include "npc.h"
-#include "pc.h"
-#include "skill.h"
-#include "status.h"
-#include "storage.h"
-#include "../common/HPM.h"
-#include "../common/cbasetypes.h"
-#include "../common/ers.h"
-#include "../common/malloc.h"
-#include "../common/mapindex.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct guild_interface guild_s;
/*==========================================
@@ -343,14 +343,12 @@ int guild_create(struct map_session_data *sd, const char *name)
if( !tname[0] )
return 0; // empty name
- if( sd->status.guild_id )
- {// already in a guild
- clif->guild_created(sd,1);
+ if( sd->status.guild_id ) {
+ clif->guild_created(sd,1); // You're already in a guild
return 0;
}
if (battle_config.guild_emperium_check && pc->search_inventory(sd, ITEMID_EMPERIUM) == INDEX_NOT_FOUND) {
- // item required
- clif->guild_created(sd,3);
+ clif->guild_created(sd,3); // You need the necessary item to create a guild
return 0;
}
@@ -367,14 +365,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 (The guild name already exists)
return 0;
}
//struct guild *g;
sd->status.guild_id=guild_id;
- clif->guild_created(sd,0);
+ clif->guild_created(sd,0); // Success
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, DELITEM_NORMAL, LOG_TYPE_CONSUME); //emperium consumption
return 0;
}
@@ -615,7 +613,7 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) {
if(tsd==NULL || g==NULL)
return 0;
- if( (i=guild->getposition(g,sd))<0 || !(g->position[i].mode&0x0001) )
+ if( (i=guild->getposition(g,sd)) < 0 || !(g->position[i].mode&GPERM_INVITE) )
return 0; //Invite permission.
if(!battle_config.invite_request_check) {
@@ -840,7 +838,7 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i
if(sd->status.guild_id!=guild_id)
return 0;
- if( (ps=guild->getposition(g,sd))<0 || !(g->position[ps].mode&0x0010) )
+ if ((ps=guild->getposition(g,sd))<0 || !(g->position[ps].mode&GPERM_EXPEL))
return 0; //Expulsion permission
//Can't leave inside guild castles.
@@ -895,7 +893,7 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c
// update char, if online
if(sd != NULL && sd->status.guild_id == guild_id) {
// do stuff that needs the guild_id first, BEFORE we wipe it
- if (sd->state.storage_flag == 2) //Close the guild storage.
+ if (sd->state.storage_flag == STORAGE_FLAG_GUILD) //Close the guild storage.
gstorage->close(sd);
guild->send_dot_remove(sd);
if (channel->config->ally) {
@@ -926,7 +924,7 @@ void guild_retrieveitembound(int char_id,int aid,int 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) ) {
- if(sd->status.guild_id == guild_id && sd->state.storage_flag == 2) {
+ if(sd->status.guild_id == guild_id && sd->state.storage_flag == STORAGE_FLAG_GUILD) {
gstorage->close(sd);
break;
}
@@ -1095,9 +1093,7 @@ int guild_change_position(int guild_id,int idx,int mode,int exp_mode,const char
struct guild_position p;
exp_mode = cap_value(exp_mode, 0, battle_config.guild_exp_limit);
- //Mode 0x01 <- Invite
- //Mode 0x10 <- Expel.
- p.mode=mode&0x11;
+ p.mode=mode&GPERM_BOTH; // Invite and Expel
p.exp_mode=exp_mode;
safestrncpy(p.name,name,NAME_LENGTH);
return intif->guild_position(guild_id,idx,&p);
@@ -1750,7 +1746,7 @@ int guild_broken(int guild_id,int flag)
for(i=0;i<g->max_member;i++){
// Destroy all relationships
if((sd=g->member[i].sd)!=NULL){
- if(sd->state.storage_flag == 2)
+ if(sd->state.storage_flag == STORAGE_FLAG_GUILD)
gstorage->pc_quit(sd,1);
sd->status.guild_id=0;
sd->guild = NULL;
@@ -1910,7 +1906,7 @@ int guild_break(struct map_session_data *sd,char *name) {
}
}
- for(i = 0; i < count; i++) {
+ for(i = 0; i < count; i++) { // FIXME: Why is this not done in the above loop?
skill->del_unitgroup(groups[i],ALC_MARK);
}
}
diff --git a/src/map/guild.h b/src/map/guild.h
index a75b8a7a5..18a25af58 100644
--- a/src/map/guild.h
+++ b/src/map/guild.h
@@ -5,10 +5,10 @@
#ifndef MAP_GUILD_H
#define MAP_GUILD_H
-#include "map.h" // EVENT_NAME_LENGTH, TBL_PC
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/mmo.h"
+#include "map/map.h" // EVENT_NAME_LENGTH, TBL_PC
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/mmo.h"
/**
* Defines
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index 51686d3aa..305d60f5b 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -4,50 +4,51 @@
#define HERCULES_CORE
-#include "../config/core.h" // DBPATH
+#include "config/core.h" // DBPATH
#include "homunculus.h"
+#include "map/atcommand.h"
+#include "map/battle.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/guild.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/map.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/party.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/script.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "map/trade.h"
+#include "map/unit.h"
+#include "common/cbasetypes.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "atcommand.h"
-#include "battle.h"
-#include "chrif.h"
-#include "clif.h"
-#include "guild.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "map.h"
-#include "mob.h"
-#include "npc.h"
-#include "party.h"
-#include "pc.h"
-#include "pet.h"
-#include "script.h"
-#include "skill.h"
-#include "status.h"
-#include "trade.h"
-#include "unit.h"
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct homunculus_interface homunculus_s;
+struct homun_dbs homundbs;
//Returns the viewdata for homunculus
struct view_data* homunculus_get_viewdata(int class_) {
if (homdb_checkid(class_))
- return &homun->viewdb[class_-HM_CLASS_BASE];
+ return &homun->dbs->viewdb[class_-HM_CLASS_BASE];
return NULL;
}
@@ -193,13 +194,13 @@ int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve) {
if( hd->homunculus.prev_class != 0 ) {
c = hd->homunculus.prev_class - HM_CLASS_BASE;
- for( i = 0; i < MAX_SKILL_TREE && ( id = homun->skill_tree[c][i].id ) > 0; i++ ) {
+ for( i = 0; i < MAX_SKILL_TREE && ( id = homun->dbs->skill_tree[c][i].id ) > 0; i++ ) {
if( hd->homunculus.hskill[ id - HM_SKILLBASE ].id )
continue; //Skill already known.
if(!battle_config.skillfree) {
for( j = 0; j < MAX_PC_SKILL_REQUIRE; j++ ) {
- if( homun->skill_tree[c][i].need[j].id &&
- homun->checkskill(hd,homun->skill_tree[c][i].need[j].id) < homun->skill_tree[c][i].need[j].lv ) {
+ if( homun->dbs->skill_tree[c][i].need[j].id &&
+ homun->checkskill(hd,homun->dbs->skill_tree[c][i].need[j].id) < homun->dbs->skill_tree[c][i].need[j].lv ) {
f = 0;
break;
}
@@ -214,16 +215,16 @@ int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve) {
c = hd->homunculus.class_ - HM_CLASS_BASE;
- for( i = 0; i < MAX_SKILL_TREE && ( id = homun->skill_tree[c][i].id ) > 0; i++ ) {
+ for( i = 0; i < MAX_SKILL_TREE && ( id = homun->dbs->skill_tree[c][i].id ) > 0; i++ ) {
if( hd->homunculus.hskill[ id - HM_SKILLBASE ].id )
continue; //Skill already known.
j = ( flag_evolve ) ? 10 : hd->homunculus.intimacy;
- if( j < homun->skill_tree[c][i].intimacylv )
+ if( j < homun->dbs->skill_tree[c][i].intimacylv )
continue;
if(!battle_config.skillfree) {
for( j = 0; j < MAX_PC_SKILL_REQUIRE; j++ ) {
- if( homun->skill_tree[c][i].need[j].id &&
- homun->checkskill(hd,homun->skill_tree[c][i].need[j].id) < homun->skill_tree[c][i].need[j].lv ) {
+ if( homun->dbs->skill_tree[c][i].need[j].id &&
+ homun->checkskill(hd,homun->dbs->skill_tree[c][i].need[j].id) < homun->dbs->skill_tree[c][i].need[j].lv ) {
f = 0;
break;
}
@@ -252,9 +253,9 @@ int homunculus_checkskill(struct homun_data *hd,uint16 skill_id) {
int homunculus_skill_tree_get_max(int id, int b_class) {
int i, skill_id;
b_class -= HM_CLASS_BASE;
- for(i=0;(skill_id=homun->skill_tree[b_class][i].id)>0;i++)
+ for(i=0;(skill_id=homun->dbs->skill_tree[b_class][i].id)>0;i++)
if (id == skill_id)
- return homun->skill_tree[b_class][i].max;
+ return homun->dbs->skill_tree[b_class][i].max;
return skill->get_max(id);
}
@@ -316,7 +317,7 @@ bool homunculus_levelup(struct homun_data *hd) {
hom->skillpts++; //1 skillpoint each 3 base level
hom->exp -= hd->exp_next;
- hd->exp_next = homun->exptable[hom->level - 1];
+ hd->exp_next = homun->dbs->exptable[hom->level - 1];
max = &hd->homunculusDB->gmax;
min = &hd->homunculusDB->gmin;
@@ -366,7 +367,7 @@ int homunculus_change_class(struct homun_data *hd, short class_) {
i = homun->db_search(class_,HOMUNCULUS_CLASS);
if(i < 0)
return 0;
- hd->homunculusDB = &homun->db[i];
+ hd->homunculusDB = &homun->dbs->db[i];
hd->homunculus.class_ = class_;
status->set_viewdata(&hd->bl, class_);
homun->calc_skilltree(hd, 1);
@@ -584,7 +585,7 @@ bool homunculus_feed(struct map_session_data *sd, struct homun_data *hd) {
clif->hom_food(sd,foodID,0);
return false;
}
- pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);
+ pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME);
if ( hd->homunculus.hunger >= 91 ) {
homun->consume_intimacy(hd, 50);
@@ -703,16 +704,16 @@ int homunculus_db_search(int key,int type) {
int i;
for(i=0;i<MAX_HOMUNCULUS_CLASS;i++) {
- if(homun->db[i].base_class <= 0)
+ if(homun->dbs->db[i].base_class <= 0)
continue;
switch(type) {
case HOMUNCULUS_CLASS:
- if(homun->db[i].base_class == key ||
- homun->db[i].evo_class == key)
+ if(homun->dbs->db[i].base_class == key ||
+ homun->dbs->db[i].evo_class == key)
return i;
break;
case HOMUNCULUS_FOOD:
- if(homun->db[i].foodID == key)
+ if(homun->dbs->db[i].foodID == key)
return i;
break;
default:
@@ -729,7 +730,7 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) {
nullpo_retr(false, sd);
- Assert((sd->status.hom_id == 0 || sd->hd == 0) || sd->hd->master == sd);
+ Assert_retr(false, sd->status.hom_id == 0 || sd->hd == 0 || sd->hd->master == sd);
i = homun->db_search(hom->class_,HOMUNCULUS_CLASS);
if(i < 0) {
@@ -743,9 +744,9 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) {
hd->bl.id = npc->get_new_npc_id();
hd->master = sd;
- hd->homunculusDB = &homun->db[i];
+ hd->homunculusDB = &homun->dbs->db[i];
memcpy(&hd->homunculus, hom, sizeof(struct s_homunculus));
- hd->exp_next = homun->exptable[hd->homunculus.level - 1];
+ hd->exp_next = homun->dbs->exptable[hd->homunculus.level - 1];
status->set_viewdata(&hd->bl, hd->homunculus.class_);
status->change_init(&hd->bl);
@@ -879,7 +880,7 @@ bool homunculus_creation_request(struct map_session_data *sd, int class_) {
memset(&hom, 0, sizeof(struct s_homunculus));
//Initial data
- safestrncpy(hom.name, homun->db[i].name, NAME_LENGTH-1);
+ safestrncpy(hom.name, homun->dbs->db[i].name, NAME_LENGTH-1);
hom.class_ = class_;
hom.level = 1;
hom.hunger = 32; //32%
@@ -887,7 +888,7 @@ bool homunculus_creation_request(struct map_session_data *sd, int class_) {
hom.char_id = sd->status.char_id;
hom.hp = 10 ;
- base = &homun->db[i].base;
+ base = &homun->dbs->db[i].base;
hom.max_hp = base->HP;
hom.max_sp = base->SP;
hom.str = base->str *10;
@@ -963,7 +964,7 @@ void homunculus_stat_reset(struct homun_data *hd) {
hom->dex = base->dex *10;
hom->luk = base->luk *10;
hom->exp = 0;
- hd->exp_next = homun->exptable[0];
+ hd->exp_next = homun->dbs->exptable[0];
memset(&hd->homunculus.hskill, 0, sizeof hd->homunculus.hskill);
hd->homunculus.skillpts = 0;
}
@@ -1026,7 +1027,7 @@ bool homunculus_read_db_sub(char* str[], int columns, int current) {
ShowError("homunculus_read_db_sub : Invalid class %d\n", classid);
return false;
}
- db = &homun->db[current];
+ db = &homun->dbs->db[current];
db->base_class = classid;
classid = atoi(str[1]);
if (classid < HM_CLASS_BASE || classid > HM_CLASS_MAX) {
@@ -1129,8 +1130,7 @@ bool homunculus_read_db_sub(char* str[], int columns, int current) {
void homunculus_read_db(void) {
int i;
const char *filename[]={DBPATH"homunculus_db.txt","homunculus_db2.txt"};
-
- memset(homun->db,0,sizeof(homun->db));
+ memset(homun->dbs->db, 0, sizeof(homun->dbs->db));
for(i = 0; i<ARRAYLENGTH(filename); i++) {
if( i > 0 ) {
char filepath[256];
@@ -1165,23 +1165,23 @@ bool homunculus_read_skill_db_sub(char* split[], int columns, int current) {
k = atoi(split[1]); //This is to avoid adding two lines for the same skill. [Skotlex]
// Search an empty line or a line with the same skill_id (stored in j)
- ARR_FIND( 0, MAX_SKILL_TREE, j, !homun->skill_tree[classid][j].id || homun->skill_tree[classid][j].id == k );
+ ARR_FIND( 0, MAX_SKILL_TREE, j, !homun->dbs->skill_tree[classid][j].id || homun->dbs->skill_tree[classid][j].id == k );
if (j == MAX_SKILL_TREE) {
ShowWarning("Unable to load skill %d into homunculus %d's tree. Maximum number of skills per class has been reached.\n", k, classid);
return false;
}
- homun->skill_tree[classid][j].id = k;
- homun->skill_tree[classid][j].max = atoi(split[2]);
+ homun->dbs->skill_tree[classid][j].id = k;
+ homun->dbs->skill_tree[classid][j].max = atoi(split[2]);
if (minJobLevelPresent)
- homun->skill_tree[classid][j].joblv = atoi(split[3]);
+ homun->dbs->skill_tree[classid][j].joblv = atoi(split[3]);
for( k = 0; k < MAX_PC_SKILL_REQUIRE; k++ ) {
- homun->skill_tree[classid][j].need[k].id = atoi(split[3+k*2+minJobLevelPresent]);
- homun->skill_tree[classid][j].need[k].lv = atoi(split[3+k*2+minJobLevelPresent+1]);
+ homun->dbs->skill_tree[classid][j].need[k].id = atoi(split[3+k*2+minJobLevelPresent]);
+ homun->dbs->skill_tree[classid][j].need[k].lv = atoi(split[3+k*2+minJobLevelPresent+1]);
}
- homun->skill_tree[classid][j].intimacylv = atoi(split[13+minJobLevelPresent]);
+ homun->dbs->skill_tree[classid][j].intimacylv = atoi(split[13+minJobLevelPresent]);
return true;
}
@@ -1205,9 +1205,8 @@ int8 homunculus_get_intimacy_grade(struct homun_data *hd) {
}
void homunculus_skill_db_read(void) {
- memset(homun->skill_tree,0,sizeof(homun->skill_tree));
+ memset(homun->dbs->skill_tree, 0, sizeof(homun->dbs->skill_tree));
sv->readdb(map->db_path, "homun_skill_tree.txt", ',', 13, 15, -1, homun->read_skill_db_sub);
-
}
void homunculus_exp_db_read(void) {
@@ -1217,7 +1216,7 @@ void homunculus_exp_db_read(void) {
DBPATH"exp_homun.txt",
"exp_homun2.txt"};
- memset(homun->exptable,0,sizeof(homun->exptable));
+ memset(homun->dbs->exptable, 0, sizeof(homun->dbs->exptable));
for(i = 0; i < 2; i++) {
FILE *fp;
sprintf(line, "%s/%s", map->db_path, filename[i]);
@@ -1231,13 +1230,13 @@ void homunculus_exp_db_read(void) {
if(line[0] == '/' && line[1] == '/')
continue;
- if (!(homun->exptable[j++] = (unsigned int)strtoul(line, NULL, 10)))
+ if (!(homun->dbs->exptable[j++] = (unsigned int)strtoul(line, NULL, 10)))
break;
}
// Last permitted level have to be 0!
- if (homun->exptable[MAX_LEVEL - 1]) {
+ if (homun->dbs->exptable[MAX_LEVEL - 1]) {
ShowWarning("homunculus_exp_db_read: Reached max level in exp_homun [%d]. Remaining lines were not read.\n ", MAX_LEVEL);
- homun->exptable[MAX_LEVEL - 1] = 0;
+ homun->dbs->exptable[MAX_LEVEL - 1] = 0;
}
fclose(fp);
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' levels in '"CL_WHITE"%s"CL_RESET"'.\n", j, filename[i]);
@@ -1266,9 +1265,9 @@ void do_init_homunculus(bool minimal) {
timer->add_func_list(homun->hunger_timer, "homunculus_hunger_timer");
//Stock view data for homuncs
- memset(&homun->viewdb, 0, sizeof(homun->viewdb));
- for (class_ = 0; class_ < ARRAYLENGTH(homun->viewdb); class_++)
- homun->viewdb[class_].class_ = HM_CLASS_BASE+class_;
+ memset(homun->dbs->viewdb, 0, sizeof(homun->dbs->viewdb));
+ for (class_ = 0; class_ < MAX_HOMUNCULUS_CLASS; class_++)
+ homun->dbs->viewdb[class_].class_ = HM_CLASS_BASE+class_;
}
void do_final_homunculus(void) {
@@ -1277,7 +1276,8 @@ void do_final_homunculus(void) {
void homunculus_defaults(void) {
homun = &homunculus_s;
-
+ homun->dbs = &homundbs;
+
homun->init = do_init_homunculus;
homun->final = do_final_homunculus;
homun->reload = homunculus_reload;
diff --git a/src/map/homunculus.h b/src/map/homunculus.h
index 18f8728d3..95b613fff 100644
--- a/src/map/homunculus.h
+++ b/src/map/homunculus.h
@@ -5,10 +5,11 @@
#ifndef MAP_HOMUNCULUS_H
#define MAP_HOMUNCULUS_H
-#include "pc.h"
-#include "status.h" // struct status_data, struct status_change
-#include "unit.h" // struct unit_data
-#include "../common/mmo.h"
+#include "map/status.h" // struct status_data, struct status_change
+#include "map/unit.h" // struct unit_data
+#include "common/mmo.h"
+
+struct map_session_data;
#define MAX_HOM_SKILL_REQUIRE 5
#define homdb_checkid(id) ((id) >= HM_CLASS_BASE && (id) <= HM_CLASS_MAX)
@@ -98,12 +99,16 @@ enum homun_type {
HT_INVALID = -1, // Invalid Homunculus
};
-/* homunculus.c interface */
-struct homunculus_interface {
+struct homun_dbs {
unsigned int exptable[MAX_LEVEL];
struct view_data viewdb[MAX_HOMUNCULUS_CLASS];
struct s_homunculus_db db[MAX_HOMUNCULUS_CLASS];
struct homun_skill_tree_entry skill_tree[MAX_HOMUNCULUS_CLASS][MAX_SKILL_TREE];
+};
+
+/* homunculus.c interface */
+struct homunculus_interface {
+ struct homun_dbs *dbs;
/* */
void (*init) (bool minimal);
void (*final) (void);
diff --git a/src/map/instance.c b/src/map/instance.c
index dd5709452..f5688d02c 100644
--- a/src/map/instance.c
+++ b/src/map/instance.c
@@ -4,32 +4,33 @@
#define HERCULES_CORE
+#include "config/core.h" // CELL_NOSTACK
#include "instance.h"
+#include "map/channel.h"
+#include "map/clif.h"
+#include "map/guild.h"
+#include "map/map.h"
+#include "map/npc.h"
+#include "map/party.h"
+#include "map/pc.h"
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include "../config/core.h" // CELL_NOSTACK
-#include "channel.h"
-#include "clif.h"
-#include "map.h"
-#include "npc.h"
-#include "party.h"
-#include "pc.h"
-#include "../common/HPM.h"
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct instance_interface instance_s;
/// Checks whether given instance id is valid or not.
diff --git a/src/map/instance.h b/src/map/instance.h
index 80bd1f012..e17d6866f 100644
--- a/src/map/instance.h
+++ b/src/map/instance.h
@@ -5,10 +5,11 @@
#ifndef MAP_INSTANCE_H
#define MAP_INSTANCE_H
-#include "script.h" // struct reg_db
-#include "../common/cbasetypes.h"
-#include "../common/mmo.h" // struct point
+#include "map/script.h" // struct reg_db
+#include "common/cbasetypes.h"
+#include "common/mmo.h" // struct point
+struct HPluginData;
struct block_list;
struct map_session_data;
diff --git a/src/map/intif.c b/src/map/intif.c
index 50857baa8..26fd1949c 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -3,9 +3,32 @@
#define HERCULES_CORE
-#include "../config/core.h" // GP_BOUND_ITEMS
+#include "config/core.h" // GP_BOUND_ITEMS
#include "intif.h"
+#include "map/atcommand.h"
+#include "map/battle.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/elemental.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/log.h"
+#include "map/mail.h"
+#include "map/map.h"
+#include "map/mercenary.h"
+#include "map/party.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/quest.h"
+#include "map/storage.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
@@ -13,29 +36,6 @@
#include <string.h>
#include <sys/types.h>
-#include "atcommand.h"
-#include "battle.h"
-#include "chrif.h"
-#include "clif.h"
-#include "elemental.h"
-#include "guild.h"
-#include "homunculus.h"
-#include "log.h"
-#include "mail.h"
-#include "map.h"
-#include "mercenary.h"
-#include "party.h"
-#include "pc.h"
-#include "pet.h"
-#include "quest.h"
-#include "storage.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-
struct intif_interface intif_s;
#define inter_fd (chrif->fd) // alias
@@ -130,7 +130,7 @@ int intif_rename(struct map_session_data *sd, int type, char *name)
// GM Send a message
int intif_broadcast(const char* mes, size_t len, int type)
{
- int lp = (type|BC_COLOR_MASK) ? 4 : 0;
+ int lp = (type&BC_COLOR_MASK) ? 4 : 0;
// Send to the local players
clif->broadcast(NULL, mes, len, type, ALL_CLIENT);
@@ -149,9 +149,9 @@ int intif_broadcast(const char* mes, size_t len, int type)
WFIFOW(inter_fd,10) = 0; // fontSize not used with standard broadcast
WFIFOW(inter_fd,12) = 0; // fontAlign not used with standard broadcast
WFIFOW(inter_fd,14) = 0; // fontY not used with standard broadcast
- if( type|BC_BLUE )
+ if (type&BC_BLUE)
WFIFOL(inter_fd,16) = 0x65756c62; //If there's "blue" at the beginning of the message, game client will display it in blue instead of yellow.
- else if( type|BC_WOE )
+ else if (type&BC_WOE)
WFIFOL(inter_fd,16) = 0x73737373; //If there's "ssss", game client will recognize message as 'WoE broadcast'.
memcpy(WFIFOP(inter_fd,16 + lp), mes, len);
WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
@@ -2152,7 +2152,7 @@ void intif_parse_MessageToFD(int fd) {
if( sd && sd->bl.id == aid ) {
char msg[512];
safestrncpy(msg, (char*)RFIFOP(fd,12), RFIFOW(fd,2) - 12);
- clif->message(u_fd,msg);
+ clif->messagecolor_self(u_fd, COLOR_DEFAULT ,msg);
}
}
diff --git a/src/map/intif.h b/src/map/intif.h
index 52aa32259..3303feb6e 100644
--- a/src/map/intif.h
+++ b/src/map/intif.h
@@ -5,7 +5,7 @@
#ifndef MAP_INTIF_H
#define MAP_INTIF_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
/**
* Declarations
diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c
index d492ad9ca..b0f687c0d 100644
--- a/src/map/irc-bot.c
+++ b/src/map/irc-bot.c
@@ -1,26 +1,26 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
-// Base Author: shennetsind @ http://hercules.ws
+// Base Author: shennetsind @ http://herc.ws
#define HERCULES_CORE
#include "irc-bot.h"
+#include "map/channel.h"
+#include "map/map.h"
+#include "map/pc.h"
+#include "common/cbasetypes.h"
+#include "common/malloc.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "channel.h"
-#include "map.h"
-#include "pc.h"
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-
//#define IRCBOT_DEBUG
struct irc_bot_interface irc_bot_s;
diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h
index 8dcfea5bd..b0bfd72f8 100644
--- a/src/map/irc-bot.h
+++ b/src/map/irc-bot.h
@@ -1,12 +1,12 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
-// Base Author: shennetsind @ http://hercules.ws
+// Base Author: shennetsind @ http://herc.ws
#ifndef MAP_IRC_BOT_H
#define MAP_IRC_BOT_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
#define IRC_NICK_LENGTH 40
#define IRC_IDENT_LENGTH 40
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index fb6bcc730..09303978c 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -4,27 +4,27 @@
#define HERCULES_CORE
-#include "../config/core.h" // DBPATH, RENEWAL
+#include "config/core.h" // DBPATH, RENEWAL
#include "itemdb.h"
+#include "map/battle.h" // struct battle_config
+#include "map/map.h"
+#include "map/mob.h" // MAX_MOB_DB
+#include "map/pc.h" // W_MUSICAL, W_WHIP
+#include "map/script.h" // item script processing
+#include "common/HPM.h"
+#include "common/conf.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "battle.h" // struct battle_config
-#include "map.h"
-#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"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-#include "../common/utils.h"
-
struct itemdb_interface itemdb_s;
/**
@@ -199,6 +199,9 @@ void itemdb_package_item(struct map_session_data *sd, struct item_package *packa
if( package->must_items[i].announce )
clif->package_announce(sd,package->must_items[i].id,package->id);
+ if ( package->must_items[i].force_serial )
+ it.unique_id = itemdb->unique_id(sd);
+
get_count = itemdb->isstackable(package->must_items[i].id) ? package->must_items[i].qty : 1;
it.amount = get_count == 1 ? 1 : get_count;
@@ -719,7 +722,7 @@ void itemdb_write_cached_packages(const char *config_filename) {
//now we loop into must
for(c = 0; c < must_qty; c++) {
struct item_package_must_entry *entry = &itemdb->packages[i].must_items[c];
- unsigned char announce = entry->announce == 1 ? 1 : 0, named = entry->named == 1 ? 1 : 0;
+ unsigned char announce = entry->announce == 1 ? 1 : 0, named = entry->named == 1 ? 1 : 0, force_serial = entry->force_serial == 1 ? 1 : 0;
//first 2 byte = item id
hwrite(&entry->id,sizeof(entry->id),1,file);
//next 2 byte = qty
@@ -729,7 +732,9 @@ void itemdb_write_cached_packages(const char *config_filename) {
//next 1 byte = announce (1:0)
hwrite(&announce,sizeof(announce),1,file);
//next 1 byte = named (1:0)
- hwrite(&named,sizeof(announce),1,file);
+ hwrite(&named,sizeof(named),1,file);
+ //next 1 byte = ForceSerial (1:0)
+ hwrite(&force_serial,sizeof(force_serial),1,file);
}
//now we loop into random groups
for(c = 0; c < random_qty; c++) {
@@ -741,7 +746,7 @@ void itemdb_write_cached_packages(const char *config_filename) {
//now we loop into the group's list
for(h = 0; h < group_qty; h++) {
struct item_package_rand_entry *entry = &itemdb->packages[i].random_groups[c].random_list[h];
- unsigned char announce = entry->announce == 1 ? 1 : 0, named = entry->named == 1 ? 1 : 0;
+ unsigned char announce = entry->announce == 1 ? 1 : 0, named = entry->named == 1 ? 1 : 0, force_serial = entry->force_serial == 1 ? 1 : 0;
//first 2 byte = item id
hwrite(&entry->id,sizeof(entry->id),1,file);
//next 2 byte = qty
@@ -753,7 +758,9 @@ void itemdb_write_cached_packages(const char *config_filename) {
//next 1 byte = announce (1:0)
hwrite(&announce,sizeof(announce),1,file);
//next 1 byte = named (1:0)
- hwrite(&named,sizeof(announce),1,file);
+ hwrite(&named,sizeof(named),1,file);
+ //next 1 byte = ForceSerial (1:0)
+ hwrite(&force_serial,sizeof(force_serial),1,file);
}
}
}
@@ -807,7 +814,7 @@ bool itemdb_read_cached_packages(const char *config_filename) {
for(c = 0; c < package->must_qty; c++) {
struct item_package_must_entry *entry = &itemdb->packages[i].must_items[c];
unsigned short mid = 0, qty = 0, hours = 0;
- unsigned char announce = 0, named = 0;
+ unsigned char announce = 0, named = 0, force_serial = 0;
struct item_data *data;
//first 2 byte = item id
hread(&mid,sizeof(mid),1,file);
@@ -818,8 +825,10 @@ bool itemdb_read_cached_packages(const char *config_filename) {
//next 1 byte = announce (1:0)
hread(&announce,sizeof(announce),1,file);
//next 1 byte = named (1:0)
- hread(&named,sizeof(announce),1,file);
-
+ hread(&named,sizeof(named),1,file);
+ //next 1 byte = ForceSerial (1:0)
+ hread(&force_serial,sizeof(force_serial),1,file);
+
if( !(data = itemdb->exists(mid)) )
ShowWarning("itemdb_read_cached_packages: unknown item '%d' in package '%s'!\n",mid,itemdb_name(package->id));
@@ -828,6 +837,7 @@ bool itemdb_read_cached_packages(const char *config_filename) {
entry->qty = qty;
entry->announce = announce ? 1 : 0;
entry->named = named ? 1 : 0;
+ entry->force_serial = force_serial ? 1 : 0;
}
}
if( package->random_qty ) {
@@ -847,7 +857,7 @@ bool itemdb_read_cached_packages(const char *config_filename) {
for(h = 0; h < group_qty; h++) {
struct item_package_rand_entry *entry = &itemdb->packages[i].random_groups[c].random_list[h];
unsigned short mid = 0, qty = 0, hours = 0, rate = 0;
- unsigned char announce = 0, named = 0;
+ unsigned char announce = 0, named = 0, force_serial = 0;
struct item_data *data;
if( prev ) prev->next = entry;
@@ -863,8 +873,10 @@ bool itemdb_read_cached_packages(const char *config_filename) {
//next 1 byte = announce (1:0)
hread(&announce,sizeof(announce),1,file);
//next 1 byte = named (1:0)
- hread(&named,sizeof(announce),1,file);
-
+ hread(&named,sizeof(named),1,file);
+ //next 1 byte = ForceSerial (1:0)
+ hread(&force_serial,sizeof(force_serial),1,file);
+
if( !(data = itemdb->exists(mid)) )
ShowWarning("itemdb_read_cached_packages: unknown item '%d' in package '%s'!\n",mid,itemdb_name(package->id));
@@ -874,7 +886,7 @@ bool itemdb_read_cached_packages(const char *config_filename) {
entry->qty = qty;
entry->announce = announce ? 1 : 0;
entry->named = named ? 1 : 0;
-
+ entry->force_serial = force_serial ? 1 : 0;
prev = entry;
}
if( prev )
@@ -1020,7 +1032,7 @@ void itemdb_read_packages(void) {
c = 0;
while( (it = libconfig->setting_get_elem(itg,c++)) ) {
int icount = 1, expire = 0, rate = 10000, gid = 0;
- bool announce = false, named = false;
+ bool announce = false, named = false, force_serial = false;
itname = config_setting_name(it);
@@ -1049,6 +1061,9 @@ void itemdb_read_packages(void) {
if( ( t = libconfig->setting_get_member(it, "Named")) && libconfig->setting_get_bool(t) )
named = true;
+ if( ( t = libconfig->setting_get_member(it, "ForceSerial")) && libconfig->setting_get_bool(t) )
+ force_serial = true;
+
if( !( t = libconfig->setting_get_member(it, "Random") ) ) {
ShowWarning("itemdb_read_packages: missing 'Random' field for item '%s' in package '%s', defaulting to must!\n",itname,config_setting_name(itg));
gid = 0;
@@ -1061,6 +1076,7 @@ void itemdb_read_packages(void) {
itemdb->packages[count].must_items[m].hours = expire;
itemdb->packages[count].must_items[m].announce = announce == true ? 1 : 0;
itemdb->packages[count].must_items[m].named = named == true ? 1 : 0;
+ itemdb->packages[count].must_items[m].force_serial = force_serial == true ? 1 : 0;
m++;
} else {
int gidx = gid - 1;
@@ -1078,6 +1094,7 @@ void itemdb_read_packages(void) {
itemdb->packages[count].random_groups[gidx].random_list[r].hours = expire;
itemdb->packages[count].random_groups[gidx].random_list[r].announce = announce == true ? 1 : 0;
itemdb->packages[count].random_groups[gidx].random_list[r].named = named == true ? 1 : 0;
+ itemdb->packages[count].random_groups[gidx].random_list[r].force_serial = force_serial == true ? 1 : 0;
itemdb->packages[count].random_groups[gidx].random_qty += 1;
prev[gidx] = &itemdb->packages[count].random_groups[gidx].random_list[r];
@@ -1583,14 +1600,15 @@ int itemdb_readdb_sql_sub(Sql *handle, int n, const char *source) {
SQL->GetData(handle, 19, &data, NULL); id.flag.no_refine = data && atoi(data) ? 0 : 1;
SQL->GetData(handle, 20, &data, NULL); id.look = data ? atoi(data) : 0;
SQL->GetData(handle, 21, &data, NULL); id.flag.bindonequip = data && atoi(data) ? 1 : 0;
- SQL->GetData(handle, 22, &data, NULL); id.flag.buyingstore = data && atoi(data) ? 1 : 0;
- SQL->GetData(handle, 23, &data, NULL); id.delay = data ? atoi(data) : 0;
- SQL->GetData(handle, 24, &data, NULL); id.flag.trade_restriction = data ? atoi(data) : ITR_NONE;
- SQL->GetData(handle, 25, &data, NULL); id.gm_lv_trade_override = data ? atoi(data) : 0;
- SQL->GetData(handle, 26, &data, NULL); id.item_usage.flag = data ? atoi(data) : INR_NONE;
- SQL->GetData(handle, 27, &data, NULL); id.item_usage.override = data ? atoi(data) : 0;
- SQL->GetData(handle, 28, &data, NULL); id.stack.amount = data ? atoi(data) : 0;
- SQL->GetData(handle, 29, &data, NULL);
+ SQL->GetData(handle, 22, &data, NULL); id.flag.force_serial = data && atoi(data) ? 1 : 0;
+ SQL->GetData(handle, 23, &data, NULL); id.flag.buyingstore = data && atoi(data) ? 1 : 0;
+ SQL->GetData(handle, 24, &data, NULL); id.delay = data ? atoi(data) : 0;
+ SQL->GetData(handle, 25, &data, NULL); id.flag.trade_restriction = data ? atoi(data) : ITR_NONE;
+ SQL->GetData(handle, 26, &data, NULL); id.gm_lv_trade_override = data ? atoi(data) : 0;
+ SQL->GetData(handle, 27, &data, NULL); id.item_usage.flag = data ? atoi(data) : INR_NONE;
+ SQL->GetData(handle, 28, &data, NULL); id.item_usage.override = data ? atoi(data) : 0;
+ SQL->GetData(handle, 29, &data, NULL); id.stack.amount = data ? atoi(data) : 0;
+ SQL->GetData(handle, 30, &data, NULL);
if (data) {
int stack_flag = atoi(data);
id.stack.inventory = (stack_flag&1)!=0;
@@ -1598,15 +1616,15 @@ int itemdb_readdb_sql_sub(Sql *handle, int n, const char *source) {
id.stack.storage = (stack_flag&4)!=0;
id.stack.guildstorage = (stack_flag&8)!=0;
}
- SQL->GetData(handle, 30, &data, NULL);
+ SQL->GetData(handle, 31, &data, NULL);
if (data) {
id.view_id = atoi(data);
if (id.view_id)
id.flag.available = 1;
}
- SQL->GetData(handle, 31, &data, NULL); id.script = data && *data ? script->parse(data, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL;
- SQL->GetData(handle, 32, &data, NULL); id.equip_script = data && *data ? script->parse(data, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL;
- SQL->GetData(handle, 33, &data, NULL); id.unequip_script = data && *data ? script->parse(data, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL;
+ SQL->GetData(handle, 32, &data, NULL); id.script = data && *data ? script->parse(data, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL;
+ SQL->GetData(handle, 33, &data, NULL); id.equip_script = data && *data ? script->parse(data, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL;
+ SQL->GetData(handle, 34, &data, NULL); id.unequip_script = data && *data ? script->parse(data, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL;
return itemdb->validate_entry(&id, n, source);
}
@@ -1657,6 +1675,7 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
* BindOnEquip: (true or false)
* BuyingStore: (true or false)
* Delay: Delay to use item
+ * ForceSerial: (true or false)
* Trade: {
* override: Group to override
* nodrop: (true or false)
@@ -1790,6 +1809,9 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
if( (t = libconfig->setting_get_member(it, "BindOnEquip")) )
id.flag.bindonequip = libconfig->setting_get_bool(t) ? 1 : 0;
+
+ if( (t = libconfig->setting_get_member(it, "ForceSerial")) )
+ id.flag.force_serial = libconfig->setting_get_bool(t) ? 1 : 0;
if ( (t = libconfig->setting_get_member(it, "BuyingStore")) )
id.flag.buyingstore = libconfig->setting_get_bool(t) ? 1 : 0;
@@ -1992,7 +2014,7 @@ int itemdb_readdb_sql(const char *tablename) {
" `matk`, `defence`, `range`, `slots`,"
" `equip_jobs`, `equip_upper`, `equip_genders`, `equip_locations`,"
" `weapon_level`, `equip_level_min`, `equip_level_max`, `refineable`,"
- " `view`, `bindonequip`, `buyingstore`, `delay`,"
+ " `view`, `bindonequip`, `forceserial`, `buyingstore`, `delay`,"
" `trade_flag`, `trade_group`, `nouse_flag`, `nouse_group`,"
" `stack_amount`, `stack_flag`, `sprite`, `script`,"
" `equip_script`, `unequip_script`"
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 1d811e3cb..e50ebfd3d 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -5,18 +5,14 @@
#ifndef MAP_ITEMDB_H
#define MAP_ITEMDB_H
-#include "map.h"
-#include "../common/cbasetypes.h"
-#include "../common/conf.h"
-#include "../common/db.h"
-#include "../common/mmo.h" // ITEM_NAME_LENGTH
-#include "../common/sql.h"
+/* #include "map/map.h" */
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/db.h"
+#include "common/mmo.h" // ITEM_NAME_LENGTH
+#include "common/sql.h"
-/**
- * Declarations
- **/
-struct item_group;
-struct item_package;
+struct script_code;
/**
* Defines
@@ -371,6 +367,63 @@ enum ItemNouseRestrictions {
INR_ALL = 0x1 ///< Sum of all the above values
};
+struct item_combo {
+ struct script_code *script;
+ unsigned short nameid[MAX_ITEMS_PER_COMBO];/* nameid array */
+ unsigned char count;
+ unsigned short id;/* id of this combo */
+};
+
+struct item_group {
+ unsigned short id;
+ unsigned short *nameid;
+ unsigned short qty;
+};
+
+struct item_chain_entry {
+ unsigned short id;
+ unsigned short rate;
+ struct item_chain_entry *next;
+};
+
+struct item_chain {
+ struct item_chain_entry *items;
+ unsigned short qty;
+};
+
+struct item_package_rand_entry {
+ unsigned short id;
+ unsigned short qty;
+ unsigned short rate;
+ unsigned short hours;
+ unsigned int announce : 1;
+ unsigned int named : 1;
+ unsigned int force_serial: 1;
+ struct item_package_rand_entry *next;
+};
+
+struct item_package_must_entry {
+ unsigned short id;
+ unsigned short qty;
+ unsigned short hours;
+ unsigned int announce : 1;
+ unsigned int named : 1;
+ unsigned int force_serial : 1;
+};
+
+struct item_package_rand_group {
+ struct item_package_rand_entry *random_list;
+ unsigned short random_qty;
+};
+
+struct item_package {
+ unsigned short id;
+ struct item_package_rand_group *random_groups;
+ struct item_package_must_entry *must_items;
+ unsigned short random_qty;
+ unsigned short must_qty;
+};
+
struct item_data {
uint16 nameid;
char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH];
@@ -415,6 +468,7 @@ struct item_data {
unsigned buyingstore : 1;
unsigned bindonequip : 1;
unsigned keepafteruse : 1;
+ unsigned force_serial : 1;
} flag;
struct {// item stacking limitation
unsigned short amount;
@@ -440,61 +494,6 @@ struct item_data {
unsigned int hdatac;
};
-struct item_combo {
- struct script_code *script;
- unsigned short nameid[MAX_ITEMS_PER_COMBO];/* nameid array */
- unsigned char count;
- unsigned short id;/* id of this combo */
-};
-
-struct item_group {
- unsigned short id;
- unsigned short *nameid;
- unsigned short qty;
-};
-
-struct item_chain_entry {
- unsigned short id;
- unsigned short rate;
- struct item_chain_entry *next;
-};
-
-struct item_chain {
- struct item_chain_entry *items;
- unsigned short qty;
-};
-
-struct item_package_rand_entry {
- unsigned short id;
- unsigned short qty;
- unsigned short rate;
- unsigned short hours;
- unsigned int announce : 1;
- unsigned int named : 1;
- struct item_package_rand_entry *next;
-};
-
-struct item_package_must_entry {
- unsigned short id;
- unsigned short qty;
- unsigned short hours;
- unsigned int announce : 1;
- unsigned int named : 1;
-};
-
-struct item_package_rand_group {
- struct item_package_rand_entry *random_list;
- unsigned short random_qty;
-};
-
-struct item_package {
- unsigned short id;
- struct item_package_rand_group *random_groups;
- struct item_package_must_entry *must_items;
- unsigned short random_qty;
- unsigned short must_qty;
-};
-
#define itemdb_name(n) (itemdb->search(n)->name)
#define itemdb_jname(n) (itemdb->search(n)->jname)
#define itemdb_type(n) (itemdb->search(n)->type)
diff --git a/src/map/log.c b/src/map/log.c
index f18efbfb7..0a9b16418 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -6,22 +6,22 @@
#include "log.h"
+#include "map/battle.h"
+#include "map/itemdb.h"
+#include "map/map.h"
+#include "map/mob.h"
+#include "map/pc.h"
+#include "common/cbasetypes.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/sql.h" // SQL_INNODB
+#include "common/strlib.h"
+#include "common/HPM.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "battle.h"
-#include "itemdb.h"
-#include "map.h"
-#include "mob.h"
-#include "pc.h"
-#include "../common/cbasetypes.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-#include "../common/sql.h" // SQL_INNODB
-#include "../common/strlib.h"
-#include "../common/HPM.h"
-
struct log_interface log_s;
/// obtain log type character for item/zeny logs
diff --git a/src/map/log.h b/src/map/log.h
index b4b8b84f4..ef654149c 100644
--- a/src/map/log.h
+++ b/src/map/log.h
@@ -5,8 +5,8 @@
#ifndef MAP_LOG_H
#define MAP_LOG_H
-#include "../common/cbasetypes.h"
-#include "../common/sql.h"
+#include "common/cbasetypes.h"
+#include "common/sql.h"
/**
* Declarations
diff --git a/src/map/mail.c b/src/map/mail.c
index 7ba7d7470..184e2be8d 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -6,17 +6,18 @@
#include "mail.h"
+#include "map/atcommand.h"
+#include "map/clif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/pc.h"
+#include "map/storage.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+
#include <time.h>
#include <string.h>
-#include "atcommand.h"
-#include "clif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "pc.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-
struct mail_interface mail_s;
void mail_clear(struct map_session_data *sd)
@@ -36,7 +37,7 @@ int mail_removeitem(struct map_session_data *sd, short flag)
if( sd->mail.amount )
{
if (flag) // Item send
- pc->delitem(sd, sd->mail.index, sd->mail.amount, 1, 0, LOG_TYPE_MAIL);
+ pc->delitem(sd, sd->mail.index, sd->mail.amount, 1, DELITEM_NORMAL, LOG_TYPE_MAIL);
else
clif->additem(sd, sd->mail.index, sd->mail.amount, 0);
}
@@ -151,7 +152,7 @@ int mail_openmail(struct map_session_data *sd)
{
nullpo_ret(sd);
- if( sd->state.storage_flag || sd->state.vending || sd->state.buyingstore || sd->state.trading )
+ if (sd->state.storage_flag != STORAGE_FLAG_CLOSED || sd->state.vending || sd->state.buyingstore || sd->state.trading)
return 0;
clif->mail_window(sd->fd, 0);
diff --git a/src/map/mail.h b/src/map/mail.h
index db49ca39e..4f325067d 100644
--- a/src/map/mail.h
+++ b/src/map/mail.h
@@ -5,7 +5,7 @@
#ifndef MAP_MAIL_H
#define MAP_MAIL_H
-#include "../common/cbasetypes.h"
+#include "common/cbasetypes.h"
struct item;
struct mail_message;
diff --git a/src/map/map.c b/src/map/map.c
index c79d49c3e..dc935079a 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -4,65 +4,64 @@
#define HERCULES_CORE
-#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, DBPATH, RENEWAL
+#include "config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, DBPATH, RENEWAL
#include "map.h"
+#include "map/HPMmap.h"
+#include "map/atcommand.h"
+#include "map/battle.h"
+#include "map/battleground.h"
+#include "map/channel.h"
+#include "map/chat.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/duel.h"
+#include "map/elemental.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/instance.h"
+#include "map/intif.h"
+#include "map/irc-bot.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/mail.h"
+#include "map/mapreg.h"
+#include "map/mercenary.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/npc.h" // npc_setcells(), npc_unsetcells()
+#include "map/party.h"
+#include "map/path.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/quest.h"
+#include "map/script.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "map/storage.h"
+#include "map/trade.h"
+#include "map/unit.h"
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/console.h"
+#include "common/core.h"
+#include "common/ers.h"
+#include "common/grfio.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h" // WFIFO*()
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
-#include "HPMmap.h"
-#include "atcommand.h"
-#include "battle.h"
-#include "battleground.h"
-#include "channel.h"
-#include "chat.h"
-#include "chrif.h"
-#include "clif.h"
-#include "duel.h"
-#include "elemental.h"
-#include "guild.h"
-#include "homunculus.h"
-#include "instance.h"
-#include "intif.h"
-#include "irc-bot.h"
-#include "itemdb.h"
-#include "log.h"
-#include "mail.h"
-#include "mapreg.h"
-#include "mercenary.h"
-#include "mob.h"
-#include "npc.h"
-#include "npc.h" // npc_setcells(), npc_unsetcells()
-#include "party.h"
-#include "path.h"
-#include "pc.h"
-#include "pet.h"
-#include "quest.h"
-#include "script.h"
-#include "skill.h"
-#include "status.h"
-#include "storage.h"
-#include "trade.h"
-#include "unit.h"
-#include "../common/HPM.h"
-#include "../common/cbasetypes.h"
-#include "../common/conf.h"
-#include "../common/console.h"
-#include "../common/core.h"
-#include "../common/ers.h"
-#include "../common/grfio.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h" // WFIFO*()
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
#ifndef _WIN32
#include <unistd.h>
#endif
@@ -1844,13 +1843,13 @@ int map_quit(struct map_session_data *sd) {
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 );
+ pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_FORCE);
}
// Return loot to owner
if( sd->pd ) pet->lootitem_drop(sd->pd, sd);
- if( sd->state.storage_flag == 1 ) sd->state.storage_flag = 0; // No need to Double Save Storage on Quit.
+ if( sd->state.storage_flag == STORAGE_FLAG_NORMAL ) sd->state.storage_flag = STORAGE_FLAG_CLOSED; // No need to Double Save Storage on Quit.
if( sd->ed ) {
elemental->clean_effect(sd->ed);
@@ -6140,10 +6139,7 @@ void map_defaults(void) {
map->bl_list_size = 0;
//all in a big chunk, respects order
- memset(&map->bl_head,0,sizeof(map->bl_head)
- + sizeof(map->zone_all)
- + sizeof(map->zone_pk)
- );
+ memset(ZEROED_BLOCK_POS(map), 0, ZEROED_BLOCK_SIZE(map));
map->cpsd = NULL;
map->list = NULL;
diff --git a/src/map/map.h b/src/map/map.h
index 26aac7720..8d879cd56 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -5,17 +5,18 @@
#ifndef MAP_MAP_H
#define MAP_MAP_H
-#include "../config/core.h"
+#include "config/core.h"
-#include <stdarg.h>
+#include "map/atcommand.h"
+#include "common/cbasetypes.h"
+#include "common/core.h" // CORE_ST_LAST
+#include "common/db.h"
+#include "common/mapindex.h"
+#include "common/mmo.h"
+#include "common/sql.h"
-#include "atcommand.h"
-#include "../common/cbasetypes.h"
-#include "../common/core.h" // CORE_ST_LAST
-#include "../common/db.h"
-#include "../common/mapindex.h"
-#include "../common/mmo.h"
-#include "../common/sql.h"
+#include <stdio.h>
+#include <stdarg.h>
struct mob_data;
struct npc_data;
@@ -65,16 +66,6 @@ enum MOBID {
MOBID_MAGICDECOY_WIND = 2046,
};
-// The following system marks a different job ID system used by the map server,
-// which makes a lot more sense than the normal one. [Skotlex]
-// These marks the "level" of the job.
-#define JOBL_2_1 0x100 //256
-#define JOBL_2_2 0x200 //512
-#define JOBL_2 0x300
-#define JOBL_UPPER 0x1000 //4096
-#define JOBL_BABY 0x2000 //8192
-#define JOBL_THIRD 0x4000 //16384
-
// For filtering and quick checking.
#define MAPID_BASEMASK 0x00ff
#define MAPID_UPPERMASK 0x0fff
@@ -266,10 +257,15 @@ enum {
RC_DEMIHUMAN,
RC_ANGEL,
RC_DRAGON,
+ RC_PLAYER,
RC_BOSS,
RC_NONBOSS,
+ RC_MAX,
RC_NONDEMIHUMAN,
- RC_MAX
+ RC_NONPLAYER,
+ RC_DEMIPLAYER,
+ RC_NONDEMIPLAYER,
+ RC_ALL = 0xFF
};
enum {
@@ -280,6 +276,8 @@ enum {
RC2_GOLEM,
RC2_GUARDIAN,
RC2_NINJA,
+ RC2_SCARABA,
+ RC2_TURTLE,
RC2_MAX
};
@@ -294,7 +292,8 @@ enum elements {
ELE_DARK,
ELE_GHOST,
ELE_UNDEAD,
- ELE_MAX
+ ELE_MAX,
+ ELE_ALL = 0xFF
};
/**
@@ -425,6 +424,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
+ SP_RACE_TOLERANCE, //2061
/* must be the last, plugins add bonuses from this value onwards */
SP_LAST_KNOWN,
@@ -895,15 +895,15 @@ struct map_interface {
DBMap* regen_db; // int id -> struct block_list* (status_natural_heal processing)
DBMap* zone_db; // string => struct map_zone_data
DBMap* iwall_db;
- /* order respected by map_defaults() in order to zero */
- /* from block_free until zone_pk */
struct block_list **block_free;
int block_free_count, block_free_lock, block_free_list_size;
struct block_list **bl_list;
int bl_list_count, bl_list_size;
+BEGIN_ZEROED_BLOCK; // This block is zeroed in map_defaults()
struct block_list bl_head;
struct map_zone_data zone_all;/* used as a base on all maps */
struct map_zone_data zone_pk;/* used for (pk_mode) */
+END_ZEROED_BLOCK;
/* */
struct map_session_data *cpsd;
struct map_data *list;
diff --git a/src/map/mapreg.h b/src/map/mapreg.h
index 9c9a1acee..cafd25b64 100644
--- a/src/map/mapreg.h
+++ b/src/map/mapreg.h
@@ -5,9 +5,11 @@
#ifndef MAP_MAPREG_H
#define MAP_MAPREG_H
-#include "script.h" // struct reg_db
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
+#include "map/script.h" // struct reg_db
+#include "common/cbasetypes.h"
+#include "common/db.h"
+
+struct eri;
/** Container for a mapreg value */
struct mapreg_save {
diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c
index 0092a6c61..bed40e295 100644
--- a/src/map/mapreg_sql.c
+++ b/src/map/mapreg_sql.c
@@ -6,20 +6,20 @@
#include "mapreg.h"
+#include "map/map.h" // map-"mysql_handle
+#include "map/script.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/ers.h"
+#include "common/malloc.h"
+#include "common/showmsg.h"
+#include "common/sql.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+
#include <stdlib.h>
#include <string.h>
-#include "map.h" // map->mysql_handle
-#include "script.h"
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/ers.h"
-#include "../common/malloc.h"
-#include "../common/showmsg.h"
-#include "../common/sql.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-
struct mapreg_interface mapreg_s;
#define MAPREG_AUTOSAVE_INTERVAL (300*1000)
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index 84f6a3c41..c60234d5d 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -6,42 +6,43 @@
#include "mercenary.h"
+#include "map/atcommand.h"
+#include "map/battle.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/guild.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/map.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/party.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/script.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "map/trade.h"
+#include "map/unit.h"
+#include "common/cbasetypes.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "atcommand.h"
-#include "battle.h"
-#include "chrif.h"
-#include "clif.h"
-#include "guild.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "map.h"
-#include "mob.h"
-#include "npc.h"
-#include "party.h"
-#include "pc.h"
-#include "pet.h"
-#include "script.h"
-#include "skill.h"
-#include "status.h"
-#include "trade.h"
-#include "unit.h"
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct mercenary_interface mercenary_s;
+struct s_mercenary_db mercdb[MAX_MERCENARY_CLASS];
int merc_search_index(int class_)
{
@@ -449,7 +450,7 @@ bool read_mercenarydb_sub(char* str[], int columns, int current) {
}
int read_mercenarydb(void) {
- memset(mercenary->db,0,sizeof(mercenary->db));
+ memset(mercenary->db, 0, sizeof(struct s_mercenary_db) * MAX_MERCENARY_CLASS);
sv->readdb(map->db_path, "mercenary_db.txt", ',', 26, 26, MAX_MERCENARY_CLASS, mercenary->read_db_sub);
return 0;
@@ -511,7 +512,8 @@ void mercenary_defaults(void) {
mercenary = &mercenary_s;
/* vars */
- memset(mercenary->db,0,sizeof(mercenary->db));
+ mercenary->db = mercdb;
+ memset(mercenary->db, 0, sizeof(struct s_mercenary_db) * MAX_MERCENARY_CLASS);
/* funcs */
diff --git a/src/map/mercenary.h b/src/map/mercenary.h
index fbf3603f6..c96b5a5ef 100644
--- a/src/map/mercenary.h
+++ b/src/map/mercenary.h
@@ -4,9 +4,11 @@
#ifndef MAP_MERCENARY_H
#define MAP_MERCENARY_H
-#include "status.h" // struct status_data, struct status_change
-#include "unit.h" // struct unit_data
-#include "../common/cbasetypes.h"
+#include "map/status.h" // struct status_data, struct status_change
+#include "map/unit.h" // struct unit_data
+#include "common/cbasetypes.h"
+
+struct map_session_data;
// number of cells that a mercenary can walk to from it's master before being warped
#define MAX_MER_DISTANCE 15
@@ -56,7 +58,7 @@ struct mercenary_interface {
/* vars */
- struct s_mercenary_db db[MAX_MERCENARY_CLASS];
+ struct s_mercenary_db *db;
/* funcs */
diff --git a/src/map/mob.c b/src/map/mob.c
index 8a8e96508..8112c208c 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -4,49 +4,49 @@
#define HERCULES_CORE
-#include "../config/core.h" // AUTOLOOT_DISTANCE, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, RENEWAL_DROP, RENEWAL_EXP
+#include "config/core.h" // AUTOLOOT_DISTANCE, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, RENEWAL_DROP, RENEWAL_EXP
#include "mob.h"
+#include "map/atcommand.h"
+#include "map/battle.h"
+#include "map/clif.h"
+#include "map/date.h"
+#include "map/elemental.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/map.h"
+#include "map/mercenary.h"
+#include "map/npc.h"
+#include "map/party.h"
+#include "map/path.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/quest.h"
+#include "map/script.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/ers.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "atcommand.h"
-#include "battle.h"
-#include "clif.h"
-#include "date.h"
-#include "elemental.h"
-#include "guild.h"
-#include "homunculus.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "map.h"
-#include "mercenary.h"
-#include "npc.h"
-#include "party.h"
-#include "path.h"
-#include "pc.h"
-#include "pet.h"
-#include "quest.h"
-#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"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct mob_interface mob_s;
#define ACTIVE_AI_RANGE 2 //Distance added on top of 'AREA_SIZE' at which mobs enter active AI mode.
@@ -378,14 +378,14 @@ bool mob_ksprotected(struct block_list *src, struct block_list *target) {
break; // No KS Protected
if( sd->bl.id == sce->val1 || // Same Owner
- (sce->val2 == 2 && sd->status.party_id && sd->status.party_id == sce->val3) || // Party KS allowed
- (sce->val2 == 3 && sd->status.guild_id && sd->status.guild_id == sce->val4) ) // Guild KS allowed
+ (sce->val2 == KSPROTECT_PARTY && sd->status.party_id && sd->status.party_id == sce->val3) || // Party KS allowed
+ (sce->val2 == KSPROTECT_GUILD && sd->status.guild_id && sd->status.guild_id == sce->val4) ) // Guild KS allowed
break;
if( t_sd && (
- (sce->val2 == 1 && sce->val1 != t_sd->bl.id) ||
- (sce->val2 == 2 && sce->val3 && sce->val3 != t_sd->status.party_id) ||
- (sce->val2 == 3 && sce->val4 && sce->val4 != t_sd->status.guild_id)) )
+ (sce->val2 == KSPROTECT_SELF && sce->val1 != t_sd->bl.id) ||
+ (sce->val2 == KSPROTECT_PARTY && sce->val3 && sce->val3 != t_sd->status.party_id) ||
+ (sce->val2 == KSPROTECT_GUILD && sce->val4 && sce->val4 != t_sd->status.guild_id)) )
break;
if( (pl_sd = map->id2sd(sce->val1)) == NULL || pl_sd->bl.m != md->bl.m )
@@ -1298,7 +1298,7 @@ int mob_unlocktarget(struct mob_data *md, int64 tick) {
break;
default:
mob_stop_attack(md);
- mob_stop_walking(md,1); //Stop chasing.
+ mob_stop_walking(md, STOPWALKING_FLAG_FIXPOS); //Stop chasing.
md->state.skillstate = MSS_IDLE;
if(battle_config.mob_ai&0x8) //Walk instantly after dropping target
md->next_walktime = tick+rnd()%1000;
@@ -1975,7 +1975,7 @@ void mob_log_damage(struct mob_data *md, struct block_list *src, int damage)
case BL_MOB:
{
struct mob_data* md2 = (TBL_MOB*)src;
- if( md2->special_state.ai && md2->master_id ) {
+ if (md2->special_state.ai != AI_NONE && md2->master_id) {
struct map_session_data* msd = map->id2sd(md2->master_id);
if( msd )
char_id = msd->status.char_id;
@@ -2170,7 +2170,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
if( !(type&2) //No exp
&& (!map->list[m].flag.pvp || battle_config.pvp_exp) //Pvp no exp rule [MouseJstr]
- && (!md->master_id || !md->special_state.ai) //Only player-summoned mobs do not give exp. [Skotlex]
+ && (!md->master_id || md->special_state.ai == AI_NONE) //Only player-summoned mobs do not give exp. [Skotlex]
&& (!map->list[m].flag.nobaseexp || !map->list[m].flag.nojobexp) //Gives Exp
) { //Experience calculation.
int bonus = 100; //Bonus on top of your share (common to all attackers).
@@ -2298,9 +2298,9 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
} //End EXP giving.
if( !(type&1) && !map->list[m].flag.nomobloot && !md->state.rebirth && (
- !md->special_state.ai || //Non special mob
+ md->special_state.ai == AI_NONE || //Non special mob
battle_config.alchemist_summon_reward == 2 || //All summoned give drops
- (md->special_state.ai==2 && battle_config.alchemist_summon_reward == 1) //Marine Sphere Drops items.
+ (md->special_state.ai == AI_SPHERE && battle_config.alchemist_summon_reward == 1) //Marine Sphere Drops items.
) )
{ // Item Drop
struct item_drop_list *dlist = ers_alloc(item_drop_list_ers, struct item_drop_list);
@@ -2473,7 +2473,7 @@ 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);
}
- if(mvp_sd && md->db->mexp > 0 && !md->special_state.ai) {
+ if(mvp_sd && md->db->mexp > 0 && md->special_state.ai == AI_NONE) {
int log_mvp[2] = {0};
unsigned int mexp;
double exp;
@@ -2746,7 +2746,7 @@ int mob_class_change (struct mob_data *md, int class_)
if( mob_is_treasure(md) )
return 0; //Treasure Boxes
- if( md->special_state.ai > 1 )
+ if( md->special_state.ai > AI_ATTACK )
return 0; //Marine Spheres and Floras.
if( mob->is_clone(md->class_) )
@@ -2764,7 +2764,7 @@ int mob_class_change (struct mob_data *md, int class_)
memcpy(md->name,md->db->jname,NAME_LENGTH);
mob_stop_attack(md);
- mob_stop_walking(md, 0);
+ mob_stop_walking(md, STOPWALKING_FLAG_NONE);
unit->skillcastcancel(&md->bl, 0);
status->set_viewdata(&md->bl, class_);
clif->class_change(&md->bl, md->vd->class_, 1);
@@ -3016,7 +3016,7 @@ struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,int max_
nullpo_retr(NULL, md);
- if (md->special_state.ai) //Summoned creatures. [Skotlex]
+ if (md->special_state.ai != AI_NONE) //Summoned creatures. [Skotlex]
type = BL_PC;
map->foreachinrange(mob->getfriendhprate_sub, &md->bl, 8, type,md,min_rate,max_rate,&fr);
@@ -3302,7 +3302,7 @@ int mobskill_event(struct mob_data *md, struct block_list *src, int64 tick, int
if(md->bl.prev == NULL || md->status.hp <= 0)
return 0;
- if( md->special_state.ai == 2 ) {//LOne WOlf explained that ANYONE can trigger the marine countdown skill. [Skotlex]
+ if (md->special_state.ai == AI_SPHERE) {//LOne WOlf explained that ANYONE can trigger the marine countdown skill. [Skotlex]
md->state.alchemist = 1;
return mob->skill_use(md, timer->gettick(), MSC_ALCHEMIST);
}
@@ -3402,7 +3402,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons
int idx = pc->skill_tree[pc->class2idx(sd->status.class_)][j].idx;
int skill_id = pc->skill_tree[pc->class2idx(sd->status.class_)][j].id;
if (!skill_id || sd->status.skill[idx].lv < 1 ||
- (skill->db[idx].inf2&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL))
+ (skill->dbs->db[idx].inf2&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL))
)
continue;
for(h = 0; h < map->list[sd->bl.m].zone->disabled_skills_count; h++) {
@@ -3435,7 +3435,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons
ms[i].casttime = skill->cast_fix(&sd->bl,skill_id, ms[i].skill_lv);
ms[i].delay = 5000+skill->delay_fix(&sd->bl,skill_id, ms[i].skill_lv);
- inf = skill->db[idx].inf;
+ inf = skill->dbs->db[idx].inf;
if (inf&INF_ATTACK_SKILL) {
ms[i].target = MST_TARGET;
ms[i].cond1 = MSC_ALWAYS;
@@ -4399,13 +4399,13 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current)
if ( skill->get_casttype2(sidx) == CAST_GROUND) {//Ground skill.
if (ms->target > MST_AROUND) {
ShowWarning("mob_parse_row_mobskilldb: Wrong mob skill target for ground skill %d (%s) for %s.\n",
- ms->skill_id, skill->db[sidx].name,
+ ms->skill_id, skill->dbs->db[sidx].name,
mob_id < 0?"all mobs":mob->db_data[mob_id]->sprite);
ms->target = MST_TARGET;
}
} else if (ms->target > MST_MASTER) {
ShowWarning("mob_parse_row_mobskilldb: Wrong mob skill target 'around' for non-ground skill %d (%s) for %s.\n",
- ms->skill_id, skill->db[sidx].name,
+ ms->skill_id, skill->dbs->db[sidx].name,
mob_id < 0?"all mobs":mob->db_data[mob_id]->sprite);
ms->target = MST_TARGET;
}
diff --git a/src/map/mob.h b/src/map/mob.h
index 02ae1630a..85d2bf9b8 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -5,11 +5,11 @@
#ifndef MAP_MOB_H
#define MAP_MOB_H
-#include "map.h" // struct status_data, struct view_data, struct mob_skill
-#include "status.h" // struct status_data, struct status_change
-#include "unit.h" // struct unit_data
-#include "../common/cbasetypes.h"
-#include "../common/mmo.h" // struct item
+#include "map/map.h" // struct block_list
+#include "map/status.h" // struct status_data, struct status_change
+#include "map/unit.h" // struct unit_data, view_data
+#include "common/cbasetypes.h"
+#include "common/mmo.h" // struct item
#define MAX_RANDOMMONSTER 5
@@ -38,7 +38,7 @@
#define MOB_CLONE_END MAX_MOB_DB
//Used to determine default enemy type of mobs (for use in each in range calls)
-#define DEFAULT_ENEMY_TYPE(md) ((md)->special_state.ai?BL_CHAR:BL_MOB|BL_PC|BL_HOM|BL_MER)
+#define DEFAULT_ENEMY_TYPE(md) ((md)->special_state.ai != AI_NONE ?BL_CHAR:BL_MOB|BL_PC|BL_HOM|BL_MER)
#define MAX_MOB_CHAT 250 //Max Skill's messages
@@ -79,11 +79,23 @@ enum size {
};
enum ai {
- AI_NONE = 0,
- AI_ATTACK,
- AI_SPHERE,
- AI_FLORA,
- AI_ZANZOU,
+ AI_NONE = 0, //0: Normal mob.
+ AI_ATTACK, //1: Standard summon, attacks mobs.
+ AI_SPHERE, //2: Alchemist Marine Sphere
+ AI_FLORA, //3: Alchemist Summon Flora
+ AI_ZANZOU, //4: Summon Zanzou
+
+ AI_MAX
+};
+
+/**
+ * Acceptable values for map_session_data.state.noks
+ */
+enum ksprotection_mode {
+ KSPROTECT_NONE = 0,
+ KSPROTECT_SELF = 1,
+ KSPROTECT_PARTY = 2,
+ KSPROTECT_GUILD = 3,
};
struct mob_skill {
@@ -141,13 +153,8 @@ struct mob_data {
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.
- 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 size : 2; //Small/Big monsters. @see enum size
+ unsigned int ai : 4; //Special AI for summoned monsters. @see enum ai
unsigned int clone : 1;/* is clone? 1:0 */
} special_state; //Special mob information that does not needs to be zero'ed on mob respawn.
struct {
diff --git a/src/map/npc.c b/src/map/npc.c
index 16789b726..a79062c77 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -4,9 +4,37 @@
#define HERCULES_CORE
-#include "../config/core.h" // NPC_SECURE_TIMEOUT_INPUT, NPC_SECURE_TIMEOUT_MENU, NPC_SECURE_TIMEOUT_NEXT, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL
+#include "config/core.h" // NPC_SECURE_TIMEOUT_INPUT, NPC_SECURE_TIMEOUT_MENU, NPC_SECURE_TIMEOUT_NEXT, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL
#include "npc.h"
+#include "map/battle.h"
+#include "map/chat.h"
+#include "map/clif.h"
+#include "map/guild.h"
+#include "map/instance.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/map.h"
+#include "map/mob.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/script.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "map/unit.h"
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/ers.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <errno.h>
#include <math.h>
#include <stdio.h>
@@ -14,33 +42,6 @@
#include <string.h>
#include <time.h>
-#include "battle.h"
-#include "chat.h"
-#include "clif.h"
-#include "instance.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "map.h"
-#include "mob.h"
-#include "pc.h"
-#include "pet.h"
-#include "script.h"
-#include "skill.h"
-#include "status.h"
-#include "unit.h"
-#include "../common/HPM.h"
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/ers.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct npc_interface npc_s;
static int npc_id=START_NPC_NUM;
@@ -62,34 +63,52 @@ static struct view_data npc_viewdb2[MAX_NPC_CLASS2_END-MAX_NPC_CLASS2_START];
/* for speedup */
unsigned int npc_market_qty[MAX_INVENTORY];
-static struct script_event_s
-{
+static struct script_event_s {
//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.
+ * @param class_ The NPC class ID.
+ * @return The viewdata, or NULL if the ID is invalid.
+ */
+struct view_data *npc_get_viewdata(int class_)
{
- //Returns the viewdata for normal npc classes.
- if( class_ == INVISIBLE_CLASS )
+ if (class_ == INVISIBLE_CLASS)
return &npc_viewdb[0];
- if (npc->db_checkid(class_) || class_ == WARP_CLASS){
- if( class_ > MAX_NPC_CLASS2_START ){
- return &npc_viewdb2[class_-MAX_NPC_CLASS2_START];
- }else{
+ if (npc->db_checkid(class_)) {
+ if (class_ < MAX_NPC_CLASS) {
return &npc_viewdb[class_];
+ } else if (class_ >= MAX_NPC_CLASS2_START && class_ < MAX_NPC_CLASS2_END) {
+ return &npc_viewdb2[class_-MAX_NPC_CLASS2_START];
}
}
return NULL;
}
-//Checks if a given id is a valid npc id. [Skotlex]
-//Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001)
+/**
+ * Checks if a given id is a valid npc id.
+ *
+ * Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001)
+ *
+ * @param id The NPC ID to validate.
+ * @return Whether the value is a valid ID.
+ */
bool npc_db_checkid(int id)
{
- return ((id >= 46 && id <= 125) || id == HIDDEN_WARP_CLASS || (id > 400 && id < MAX_NPC_CLASS) || id == INVISIBLE_CLASS || (id > MAX_NPC_CLASS2_START && id < MAX_NPC_CLASS2_END));
+ if (id >= WARP_CLASS && id <= 125) // First subrange
+ return true;
+ if (id == HIDDEN_WARP_CLASS || id == INVISIBLE_CLASS) // Special IDs not included in the valid ranges
+ return true;
+ if (id > 400 && id < MAX_NPC_CLASS) // Second subrange
+ return true;
+ if (id >= MAX_NPC_CLASS2_START && id < MAX_NPC_CLASS2_END) // Second range
+ return true;
+ // Anything else is invalid
+ return false;
}
/// Returns a new npc id that isn't being used in id_db.
@@ -185,7 +204,7 @@ int npc_enable_sub(struct block_list *bl, va_list ap)
if (sd->npc_id != 0)
return 0;
- pc_stop_walking(sd,1);
+ pc_stop_walking(sd, STOPWALKING_FLAG_FIXPOS);
npc->click(sd,nd);
}
}
@@ -1565,8 +1584,8 @@ bool npc_trader_open(struct map_session_data *sd, struct npc_data *nd) {
}
/* nothing to display, no items available */
- if( i == nd->u.scr.shop->items ) {
- clif->colormes(sd->fd,COLOR_RED, msg_sd(sd,881));
+ if (i == nd->u.scr.shop->items) {
+ clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,881));
return false;
}
@@ -2038,19 +2057,18 @@ int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short* item_li
script->setarray_pc(sd, "@sold_nameid", i, (void*)(intptr_t)sd->status.inventory[idx].nameid, &key_nameid);
script->setarray_pc(sd, "@sold_quantity", i, (void*)(intptr_t)item_list[i*2+1], &key_amount);
-
- if (itemdb->isequip(sd->status.inventory[idx].nameid)) {
- // process equipment based information into the arrays
- script->setarray_pc(sd, "@sold_refine", i, (void*)(intptr_t)sd->status.inventory[idx].refine, &key_refine);
- script->setarray_pc(sd, "@sold_attribute", i, (void*)(intptr_t)sd->status.inventory[idx].attribute, &key_attribute);
- script->setarray_pc(sd, "@sold_identify", i, (void*)(intptr_t)sd->status.inventory[idx].identify, &key_identify);
-
- for (j = 0; j < MAX_SLOTS; j++) {
- // store each of the cards from the equipment in the array
- snprintf(card_slot, sizeof(card_slot), "@sold_card%d", j + 1);
- script->setarray_pc(sd, card_slot, i, (void*)(intptr_t)sd->status.inventory[idx].card[j], &key_card[j]);
- }
+
+ // process item based information into the arrays
+ script->setarray_pc(sd, "@sold_refine", i, (void*)(intptr_t)sd->status.inventory[idx].refine, &key_refine);
+ script->setarray_pc(sd, "@sold_attribute", i, (void*)(intptr_t)sd->status.inventory[idx].attribute, &key_attribute);
+ script->setarray_pc(sd, "@sold_identify", i, (void*)(intptr_t)sd->status.inventory[idx].identify, &key_identify);
+
+ for (j = 0; j < MAX_SLOTS; j++) {
+ // store each of the cards/special info from the item in the array
+ snprintf(card_slot, sizeof(card_slot), "@sold_card%d", j + 1);
+ script->setarray_pc(sd, card_slot, i, (void*)(intptr_t)sd->status.inventory[idx].card[j], &key_card[j]);
}
+
}
// invoke event
@@ -2127,7 +2145,7 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list)
}
}
- pc->delitem(sd, idx, amount, 0, 6, LOG_TYPE_NPC);
+ pc->delitem(sd, idx, amount, 0, DELITEM_SOLD, LOG_TYPE_NPC);
}
if( z > MAX_ZENY )
@@ -3537,7 +3555,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st
return strchr(start, '\n');
}
- if (mobspawn.state.ai > 4 && ai != -1) {
+ if (mobspawn.state.ai >= AI_MAX && ai != -1) {
ShowError("npc_parse_mob: Invalid ai %d for mob ID %d in file '%s', line '%d'.\n", mobspawn.state.ai, class_, filepath, strline(buffer, start - buffer));
if (retval) *retval = EXIT_FAILURE;
return strchr(start, '\n');
@@ -3560,7 +3578,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st
mobspawn.level = mob_lv;
if (size > 0 && size <= 2)
mobspawn.state.size = size;
- if (ai > 0 && ai <= 4)
+ if (ai > AI_NONE && ai < AI_MAX)
mobspawn.state.ai = ai;
if (mobspawn.num > 1 && battle_config.mob_count_rate != 100) {
@@ -3812,13 +3830,14 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
}
else if (!strcmpi(w3,"battleground")) {
struct map_zone_data *zone;
- if( state ) {
- if( sscanf(w4, "%d", &state) == 1 )
+ if (state) {
+ if (w4 && sscanf(w4, "%d", &state) == 1)
map->list[m].flag.battleground = state;
else
map->list[m].flag.battleground = 1; // Default value
- } else
+ } else {
map->list[m].flag.battleground = 0;
+ }
if( map->list[m].flag.battleground && map->list[m].flag.pvp ) {
map->list[m].flag.pvp = 0;
@@ -4624,6 +4643,7 @@ int do_init_npc(bool minimal) {
}
if( script->lang_export_fp ) {
+ ShowInfo("Lang exported to '%s'\n",script->lang_export_file);
fclose(script->lang_export_fp);
script->lang_export_fp = NULL;
}
diff --git a/src/map/npc.h b/src/map/npc.h
index 68d683847..bc779b56b 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -5,11 +5,11 @@
#ifndef MAP_NPC_H
#define MAP_NPC_H
-#include "map.h" // struct block_list
-#include "status.h" // struct status_change
-#include "unit.h" // struct unit_data
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
+#include "map/map.h" // struct block_list
+#include "map/status.h" // struct status_change
+#include "map/unit.h" // struct unit_data
+#include "common/cbasetypes.h"
+#include "common/db.h"
struct HPluginData;
struct view_data;
@@ -121,7 +121,7 @@ enum actor_classes {
// Old NPC range
#define MAX_NPC_CLASS 1000
// New NPC range
-#define MAX_NPC_CLASS2_START 10000
+#define MAX_NPC_CLASS2_START 10001
#define MAX_NPC_CLASS2_END 10110
//Script NPC events.
@@ -288,7 +288,7 @@ void npc_defaults(void);
/* comes from npc_chat.c */
#ifdef PCRE_SUPPORT
-#include "../../3rdparty/pcre/include/pcre.h"
+#include <pcre/include/pcre.h>
/* Structure containing all info associated with a single pattern block */
struct pcrematch_entry {
struct pcrematch_entry* next;
diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c
index 8bc246819..3fe379f36 100644
--- a/src/map/npc_chat.c
+++ b/src/map/npc_chat.c
@@ -8,22 +8,22 @@
#include "npc.h" // struct npc_data
+#include "map/mob.h" // struct mob_data
+#include "map/pc.h" // struct map_session_data
+#include "map/script.h" // set_var()
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+
+#include <pcre/include/pcre.h>
+
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "../../3rdparty/pcre/include/pcre.h"
-
-#include "mob.h" // struct mob_data
-#include "pc.h" // struct map_session_data
-#include "script.h" // set_var()
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-
/**
* interface sources
**/
diff --git a/src/map/packets.h b/src/map/packets.h
index ccf1c28ef..6623c091c 100644
--- a/src/map/packets.h
+++ b/src/map/packets.h
@@ -448,6 +448,8 @@ packet(0x020a,10);
//packet(0x020b,-1);
//packet(0x020c,-1);
packet(0x020d,-1);
+packet(0x974,2,clif->cancelmergeitem);
+packet(0x96e,-1,clif->ackmergeitems);
//2004-07-05aSakexe
#if PACKETVER >= 20040705
@@ -2802,6 +2804,21 @@ packet(0x020d,-1);
packet(0x0a00,269);
#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
+
+
// 2014-10-22bRagexe - YomRawr
#if PACKETVER >= 20141022
packet(0x0369,7,clif->pActionRequest,2,6);
@@ -2835,21 +2852,42 @@ packet(0x020d,-1);
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/ */
+// 2015-05-13aRagexe
+#if PACKETVER >= 20150513
+ 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(0x0924,5,clif->pChangeDir,2,4);
+ packet(0x0958,6,clif->pTakeItem,2);
+ packet(0x0885,6,clif->pDropItem,2,4);
+ packet(0x0879,8,clif->pMoveToKafra,2,4);
+ packet(0x0864,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(0x022D,2,clif->pReqCloseBuyingStore,0);
+ packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89);
+ packet(0x0883,18,clif->pPartyBookingRegisterReq,2,4);
+ packet(0x02C4,8); // CZ_JOIN_BATTLE_FIELD
+ packet(0x0960,-1,clif->pItemListWindowSelected,2,4,8);
+ packet(0x0363,19,clif->pWantToConnection,2,6,10,14,18);
+ packet(0x094A,26,clif->pPartyInvite2,2);
+ packet(0x0927,4); // CZ_GANGSI_RANK
+ packet(0x08A8,26,clif->pFriendsListAdd,2);
+ packet(0x0817,5,clif->pHomMenu,2,4);
+ packet(0x0923,36,clif->pStoragePassword,0);
+ packet(0x09e8,11,clif->pDull); //CZ_OPEN_MAILBOX
+ packet(0x0a2e,6,clif->pDull); //TITLE
+#endif
+
+/* PacketKeys: http://herc.ws/board/topic/1105-hercules-wpe-free-june-14th-patch/ */
#if PACKETVER >= 20110817
packetKeys(0x053D5CED,0x3DED6DED,0x6DED6DED); /* Thanks to Shakto */
#endif
@@ -3088,6 +3126,12 @@ packet(0x020d,-1);
packetKeys(0x290551EA,0x2B952C75,0x2D67669B); /* YomRawr */
#endif
+// 2015 Packet Keys
+
+#if PACKETVER >= 20150513
+ packetKeys(0x62C86D09,0x75944F17,0x112C133D); /* Dastgir */
+#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 71471e5c6..231321c88 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -1,13 +1,13 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
-/* Hercules Renewal: Phase Two http://hercules.ws/board/topic/383-hercules-renewal-phase-two/ */
+/* Hercules Renewal: Phase Two http://herc.ws/board/topic/383-hercules-renewal-phase-two/ */
#ifndef MAP_PACKETS_STRUCT_H
#define MAP_PACKETS_STRUCT_H
-#include "../common/cbasetypes.h"
-#include "../common/mmo.h"
+#include "common/cbasetypes.h"
+#include "common/mmo.h"
/**
*
@@ -360,8 +360,8 @@ struct packet_dropflooritem {
unsigned char subY;
short count;
} __attribute__((packed));
-#if PACKETVER < 20091103
struct packet_idle_unit2 {
+#if PACKETVER < 20091103
short PacketType;
#if PACKETVER >= 20071106
unsigned char objecttype;
@@ -392,8 +392,13 @@ struct packet_idle_unit2 {
unsigned char ySize;
unsigned char state;
short clevel;
+#else // ! PACKETVER < 20091103
+ char UNUSED;
+#endif // PACKETVER < 20091103
} __attribute__((packed));
+
struct packet_spawn_unit2 {
+#if PACKETVER < 20091103
short PacketType;
#if PACKETVER >= 20071106
unsigned char objecttype;
@@ -418,8 +423,11 @@ struct packet_spawn_unit2 {
unsigned char PosDir[3];
unsigned char xSize;
unsigned char ySize;
+#else // ! PACKETVER < 20091103
+ char UNUSED;
+#endif // PACKETVER < 20091103
} __attribute__((packed));
-#endif
+
struct packet_spawn_unit {
short PacketType;
#if PACKETVER >= 20091103
diff --git a/src/map/party.c b/src/map/party.c
index fb738a12b..6b35debe5 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -4,36 +4,36 @@
#define HERCULES_CORE
-#include "../config/core.h" // GP_BOUND_ITEMS, RENEWAL_EXP
+#include "config/core.h" // GP_BOUND_ITEMS, RENEWAL_EXP
#include "party.h"
+#include "map/atcommand.h" //msg_txt()
+#include "map/battle.h"
+#include "map/clif.h"
+#include "map/instance.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/map.h"
+#include "map/mob.h" // struct mob_data
+#include "map/pc.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "common/HPM.h"
+#include "common/cbasetypes.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h" // last_tick
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "atcommand.h" //msg_txt()
-#include "battle.h"
-#include "clif.h"
-#include "instance.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "map.h"
-#include "mob.h" // struct mob_data
-#include "pc.h"
-#include "skill.h"
-#include "status.h"
-#include "../common/HPM.h"
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h" // last_tick
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct party_interface party_s;
/*==========================================
@@ -640,7 +640,7 @@ int party_optionchanged(int party_id,int account_id,int exp,int item,int flag) {
if( (p=party->search(party_id))==NULL)
return 0;
- //Flag&1: Exp change denied. Flag&2: Item change denied.
+ //Flag&0x1: Exp change denied. Flag&0x10: Item change denied.
if(!(flag&0x01) && p->party.exp != exp)
p->party.exp=exp;
if(!(flag&0x10) && p->party.item != item) {
diff --git a/src/map/party.h b/src/map/party.h
index a541d03cb..95faa2213 100644
--- a/src/map/party.h
+++ b/src/map/party.h
@@ -5,12 +5,12 @@
#ifndef MAP_PARTY_H
#define MAP_PARTY_H
-#include <stdarg.h>
+#include "map/map.h" // TBL_PC
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/mmo.h" // struct party
-#include "map.h" // TBL_PC
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/mmo.h" // struct party
+#include <stdarg.h>
#define PARTY_BOOKING_JOBS 6
#define PARTY_BOOKING_RESULTS 10
diff --git a/src/map/path.c b/src/map/path.c
index 600dfc082..3ded5423e 100644
--- a/src/map/path.c
+++ b/src/map/path.c
@@ -4,21 +4,21 @@
#define HERCULES_CORE
-#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA
+#include "config/core.h" // CELL_NOSTACK, CIRCULAR_AREA
#include "path.h"
+#include "map/map.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <math.h>
-
-#include "map.h"
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
#define SET_OPEN 0
#define SET_CLOSED 1
diff --git a/src/map/path.h b/src/map/path.h
index eb42df6d0..bbd81b8c6 100644
--- a/src/map/path.h
+++ b/src/map/path.h
@@ -5,8 +5,8 @@
#ifndef MAP_PATH_H
#define MAP_PATH_H
-#include "map.h" // enum cell_chk
-#include "../common/cbasetypes.h"
+#include "map/map.h" // enum cell_chk
+#include "common/cbasetypes.h"
#define MOVE_COST 10
#define MOVE_DIAGONAL_COST 14
diff --git a/src/map/pc.c b/src/map/pc.c
index 3d5e240f8..107d656f0 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -4,58 +4,58 @@
#define HERCULES_CORE
-#include "../config/core.h" // DBPATH, GP_BOUND_ITEMS, MAX_SPIRITBALL, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EXP, SECURE_NPCTIMEOUT
+#include "config/core.h" // DBPATH, GP_BOUND_ITEMS, MAX_SPIRITBALL, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EXP, SECURE_NPCTIMEOUT
#include "pc.h"
+#include "map/atcommand.h" // get_atcommand_level()
+#include "map/battle.h" // battle_config
+#include "map/battleground.h"
+#include "map/channel.h"
+#include "map/chat.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/date.h" // is_day_of_*()
+#include "map/duel.h"
+#include "map/elemental.h"
+#include "map/guild.h" // guild-"search(), guild_request_info()
+#include "map/homunculus.h"
+#include "map/instance.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/mail.h"
+#include "map/map.h"
+#include "map/mercenary.h"
+#include "map/mob.h" // struct mob_data
+#include "map/npc.h" // fake_nd
+#include "map/party.h" // party-"search()
+#include "map/path.h"
+#include "map/pc_groups.h"
+#include "map/pet.h" // pet_unlocktarget()
+#include "map/quest.h"
+#include "map/script.h" // script_config
+#include "map/skill.h"
+#include "map/status.h" // struct status_data
+#include "map/storage.h"
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/core.h" // get_svn_revision()
+#include "common/malloc.h"
+#include "common/mmo.h" // NAME_LENGTH, MAX_CARTS, NEW_CARTS
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h" // session[]
+#include "common/strlib.h" // safestrncpy()
+#include "common/sysinfo.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include "atcommand.h" // get_atcommand_level()
-#include "battle.h" // battle_config
-#include "battleground.h"
-#include "channel.h"
-#include "chat.h"
-#include "chrif.h"
-#include "clif.h"
-#include "date.h" // is_day_of_*()
-#include "duel.h"
-#include "elemental.h"
-#include "guild.h" // guild->search(), guild_request_info()
-#include "homunculus.h"
-#include "instance.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "mail.h"
-#include "map.h"
-#include "mercenary.h"
-#include "mob.h" // struct mob_data
-#include "npc.h" // fake_nd
-#include "party.h" // party->search()
-#include "path.h"
-#include "pc_groups.h"
-#include "pet.h" // pet_unlocktarget()
-#include "quest.h"
-#include "script.h" // script_config
-#include "skill.h"
-#include "status.h" // struct status_data
-#include "storage.h"
-#include "../common/cbasetypes.h"
-#include "../common/conf.h"
-#include "../common/core.h" // get_svn_revision()
-#include "../common/malloc.h"
-#include "../common/mmo.h" // NAME_LENGTH, MAX_CARTS, NEW_CARTS
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h" // session[]
-#include "../common/strlib.h" // safestrncpy()
-#include "../common/sysinfo.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct pc_interface pc_s;
//Converts a class to its array index for CLASS_COUNT defined arrays.
@@ -174,6 +174,28 @@ int pc_spiritball_timer(int tid, int64 tick, int id, intptr_t data) {
return 0;
}
+/**
+* Get the possible number of spiritball that a player can call.
+* @param sd the affected player structure
+* @param min the minimum number of spiritball regardless the level of MO_CALLSPIRITS
+* @retval total number of spiritball
+**/
+int pc_getmaxspiritball(struct map_session_data *sd, int min) {
+ int result;
+
+ nullpo_ret(sd);
+
+ result = pc->checkskill(sd, MO_CALLSPIRITS);
+
+ if ( min && result < min )
+ result = min;
+ else if ( sd->sc.data[SC_RAISINGDRAGON] )
+ result += sd->sc.data[SC_RAISINGDRAGON]->val1;
+ if ( result > MAX_SPIRITBALL )
+ result = MAX_SPIRITBALL;
+ return result;
+}
+
int pc_addspiritball(struct map_session_data *sd,int interval,int max)
{
int tid, i;
@@ -495,7 +517,7 @@ void pc_rental_expire(struct map_session_data *sd, int i) {
}
clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid);
- pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER);
+ pc->delitem(sd, i, sd->status.inventory[i].amount, 0, DELITEM_NORMAL, LOG_TYPE_OTHER);
}
void pc_inventory_rentals(struct map_session_data *sd)
{
@@ -629,6 +651,7 @@ int pc_setnewpc(struct map_session_data *sd, int account_id, int char_id, int lo
sd->canlog_tick = timer->gettick();
//Required to prevent homunculus copuing a base speed of 0.
sd->battle_status.speed = sd->base_status.speed = DEFAULT_WALK_SPEED;
+ sd->state.warp_clean = 1;
return 0;
}
@@ -861,12 +884,12 @@ bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd,
clif->updatestatus(b_sd, SP_JOBEXP);
// Baby Skills
- pc->skill(b_sd, WE_BABY, 1, 0);
- pc->skill(b_sd, WE_CALLPARENT, 1, 0);
+ pc->skill(b_sd, WE_BABY, 1, SKILL_GRANT_PERMANENT);
+ pc->skill(b_sd, WE_CALLPARENT, 1, SKILL_GRANT_PERMANENT);
// Parents Skills
- pc->skill(p1_sd, WE_CALLBABY, 1, 0);
- pc->skill(p2_sd, WE_CALLBABY, 1, 0);
+ pc->skill(p1_sd, WE_CALLBABY, 1, SKILL_GRANT_PERMANENT);
+ pc->skill(p2_sd, WE_CALLBABY, 1, SKILL_GRANT_PERMANENT);
return true;
}
@@ -892,12 +915,12 @@ int pc_isequip(struct map_session_data *sd,int n)
if(pc_has_permission(sd, PC_PERM_USE_ALL_EQUIPMENT))
return 1;
- if(item->elv && sd->status.base_level < (unsigned int)item->elv){
- clif->msg(sd, 0x6ED);
+ if (item->elv && sd->status.base_level < (unsigned int)item->elv) {
+ clif->msgtable(sd, MSG_ITEM_CANT_EQUIP_LVL);
return 0;
}
- if(item->elvmax && sd->status.base_level > (unsigned int)item->elvmax){
- clif->msg(sd, 0x6ED);
+ if (item->elvmax && sd->status.base_level > (unsigned int)item->elvmax) {
+ clif->msgtable(sd, MSG_ITEM_CANT_EQUIP_LVL);
return 0;
}
if(item->sex != 2 && sd->status.sex != item->sex)
@@ -906,11 +929,11 @@ int pc_isequip(struct map_session_data *sd,int n)
if ( item->equip & EQP_AMMO ) {
if ( (sd->state.active && !pc_iscarton(sd)) // check if sc data is already loaded.
&& (sd->status.class_ == JOB_GENETIC_T || sd->status.class_ == JOB_GENETIC) ) {
- clif->msg(sd, 0x5EF);
+ clif->msgtable(sd, MSG_ITEM_NEED_CART);
return 0;
}
if ( !pc_ismadogear(sd) && (sd->status.class_ == JOB_MECHANIC_T || sd->status.class_ == JOB_MECHANIC) ) {
- clif->msg(sd, 0x59B);
+ clif->msgtable(sd, MSG_ITEM_NEED_MADO);
return 0;
}
}
@@ -1119,7 +1142,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
// Rental Timer
sd->rental_timer = INVALID_TIMER;
- for( i = 0; i < 3; i++ )
+ for( i = 0; i < MAX_PC_FEELHATE; i++ )
sd->hate_mob[i] = -1;
sd->quest_log = NULL;
@@ -1217,7 +1240,7 @@ void pc_authfail(struct map_session_data *sd)
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)
+ if (!sd || !bl || pos < 0 || pos >= MAX_PC_FEELHATE)
return 0;
if (sd->hate_mob[pos] != -1) {
//Can't change hate targets.
@@ -1367,7 +1390,7 @@ int pc_calc_skillpoint(struct map_session_data* sd) {
for (i = 1; i < MAX_SKILL; i++) {
int skill_lv = pc->checkskill2(sd,i);
if (skill_lv > 0) {
- inf2 = skill->db[i].inf2;
+ inf2 = skill->dbs->db[i].inf2;
if((!(inf2&INF2_QUEST_SKILL) || battle_config.quest_skill_learn) &&
!(inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL|INF2_GUILD_SKILL)) //Do not count wedding/link skills. [Skotlex]
) {
@@ -1406,7 +1429,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
sd->status.skill[i].id = 0; //First clear skills.
/* permanent skills that must be re-checked */
if( sd->status.skill[i].flag == SKILL_FLAG_PERMANENT ) {
- switch( skill->db[i].nameid ) {
+ switch( skill->dbs->db[i].nameid ) {
case NV_TRICKDEAD:
if( (sd->class_&(MAPID_BASEMASK|JOBL_2)) != MAPID_NOVICE ) {
sd->status.skill[i].id = 0;
@@ -1425,21 +1448,21 @@ int pc_calc_skilltree(struct map_session_data *sd)
sd->status.skill[i].flag = SKILL_FLAG_PERMANENT;
}
- if( sd->sc.count && sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_BARDDANCER && skill->db[i].nameid >= DC_HUMMING && skill->db[i].nameid <= DC_SERVICEFORYOU )
+ if( sd->sc.count && sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_BARDDANCER && skill->dbs->db[i].nameid >= DC_HUMMING && skill->dbs->db[i].nameid <= DC_SERVICEFORYOU )
{ //Enable Bard/Dancer spirit linked skills.
if( sd->status.sex )
{ //Link dancer skills to bard.
// i can be < 8?
if( sd->status.skill[i-8].lv < 10 )
continue;
- sd->status.skill[i].id = skill->db[i].nameid;
+ sd->status.skill[i].id = skill->dbs->db[i].nameid;
sd->status.skill[i].lv = sd->status.skill[i-8].lv; // Set the level to the same as the linking skill
sd->status.skill[i].flag = SKILL_FLAG_TEMPORARY; // Tag it as a non-savable, non-uppable, bonus skill
} else { //Link bard skills to dancer.
if( sd->status.skill[i].lv < 10 )
continue;
// i can be < 8?
- sd->status.skill[i-8].id = skill->db[i-8].nameid;
+ sd->status.skill[i-8].id = skill->dbs->db[i-8].nameid;
sd->status.skill[i-8].lv = sd->status.skill[i].lv; // Set the level to the same as the linking skill
sd->status.skill[i-8].flag = SKILL_FLAG_TEMPORARY; // Tag it as a non-savable, non-uppable, bonus skill
}
@@ -1448,7 +1471,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
if( pc_has_permission(sd, PC_PERM_ALL_SKILL) ) {
for( i = 0; i < MAX_SKILL; i++ ) {
- switch(skill->db[i].nameid) {
+ switch(skill->dbs->db[i].nameid) {
/**
* Dummy skills must be added here otherwise they'll be displayed in the,
* skill tree and since they have no icons they'll give resource errors
@@ -1471,10 +1494,10 @@ int pc_calc_skilltree(struct map_session_data *sd)
default:
break;
}
- if( skill->db[i].inf2&(INF2_NPC_SKILL|INF2_GUILD_SKILL) )
+ if( skill->dbs->db[i].inf2&(INF2_NPC_SKILL|INF2_GUILD_SKILL) )
continue; //Only skills you can't have are npc/guild ones
- if( skill->db[i].max > 0 )
- sd->status.skill[i].id = skill->db[i].nameid;
+ if( skill->dbs->db[i].max > 0 )
+ sd->status.skill[i].id = skill->dbs->db[i].nameid;
}
return 0;
}
@@ -1517,7 +1540,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
}
if( f ) {
int inf2;
- inf2 = skill->db[idx].inf2;
+ inf2 = skill->dbs->db[idx].inf2;
if(!sd->status.skill[idx].lv && (
(inf2&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) ||
@@ -1548,7 +1571,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
for( i = 0; i < MAX_SKILL_TREE && (id = pc->skill_tree[c][i].id) > 0; i++ ) {
int idx = pc->skill_tree[c][i].idx;
- if( (skill->db[idx].inf2&(INF2_QUEST_SKILL|INF2_WEDDING_SKILL)) )
+ if( (skill->dbs->db[idx].inf2&(INF2_QUEST_SKILL|INF2_WEDDING_SKILL)) )
continue; //Do not include Quest/Wedding skills.
if( sd->status.skill[idx].id == 0 ) {
@@ -1618,7 +1641,7 @@ void pc_check_skilltree(struct map_session_data *sd, int skill_id)
continue;
}
- j = skill->db[idx].inf2;
+ j = skill->dbs->db[idx].inf2;
if( !sd->status.skill[idx].lv && (
(j&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) ||
j&INF2_WEDDING_SKILL ||
@@ -1777,7 +1800,7 @@ int pc_disguise(struct map_session_data *sd, int class_) {
if( class_ == -1 && sd->disguise == sd->status.class_ ) {
clif->clearunit_single(-sd->bl.id,CLR_OUTSIGHT,sd->fd);
} else if ( class_ != sd->status.class_ ) {
- pc_stop_walking(sd, 0);
+ pc_stop_walking(sd, STOPWALKING_FLAG_NONE);
clif->clearunit_area(&sd->bl, CLR_OUTSIGHT);
}
}
@@ -1877,7 +1900,20 @@ int pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short src_ski
return 1;
}
-int pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id, short rate, short arrow_rate, unsigned char flag)
+/**
+ * Adds an AddEff/AddEff2/AddEffWhenHit bonus to a character.
+ *
+ * @param effect Effects array to append to.
+ * @param max Size of the effect array.
+ * @param id Effect ID (@see enum sc_type).
+ * @param rate Trigger rate.
+ * @param arrow_rate Trigger rate modifier for ranged attacks (adds to the base rate).
+ * @param flag Trigger flags (@see enum auto_trigger_flag).
+ * @param duration Fixed (non-reducible) duration in ms. If 0, uses the default (reducible) duration of the given effect.
+ * @retval 1 on success.
+ * @retval 0 on failure.
+ */
+int pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id, int16 rate, int16 arrow_rate, uint8 flag, uint16 duration)
{
int i;
if (!(flag&(ATF_SHORT|ATF_LONG)))
@@ -1888,8 +1924,8 @@ int pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id, short
flag|=ATF_WEAPON; //Default type: weapon.
for (i = 0; i < max && effect[i].flag; i++) {
- if (effect[i].id == id && effect[i].flag == flag)
- {
+ // Update existing effect if any.
+ if (effect[i].id == id && effect[i].flag == flag && effect[i].duration == duration) {
effect[i].rate += rate;
effect[i].arrow_rate += arrow_rate;
return 1;
@@ -1903,6 +1939,7 @@ int pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id, short
effect[i].rate = rate;
effect[i].arrow_rate = arrow_rate;
effect[i].flag = flag;
+ effect[i].duration = duration;
return 1;
}
@@ -2769,24 +2806,56 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
switch(type){
case SP_ADDELE:
- if(type2 >= ELE_MAX) {
+ if( (type2 >= ELE_MAX && type2 != ELE_ALL) || (type2 < ELE_NEUTRAL) ) {
ShowError("pc_bonus2: SP_ADDELE: Invalid element %d\n", type2);
break;
}
- if(!sd->state.lr_flag)
- sd->right_weapon.addele[type2]+=val;
- else if(sd->state.lr_flag == 1)
- sd->left_weapon.addele[type2]+=val;
- else if(sd->state.lr_flag == 2)
- sd->arrow_addele[type2]+=val;
+ if ( type2 == ELE_ALL ) {
+ for ( i = ELE_NEUTRAL; i < ELE_MAX; i++ ) {
+ if ( !sd->state.lr_flag )
+ sd->right_weapon.addele[i] += val;
+ else if ( sd->state.lr_flag == 1 )
+ sd->left_weapon.addele[i] += val;
+ else if ( sd->state.lr_flag == 2 )
+ sd->arrow_addele[i] += val;
+ }
+ } else {
+ if(!sd->state.lr_flag)
+ sd->right_weapon.addele[type2] += val;
+ else if(sd->state.lr_flag == 1)
+ sd->left_weapon.addele[type2] += val;
+ else if(sd->state.lr_flag == 2)
+ sd->arrow_addele[type2] += val;
+ }
break;
case SP_ADDRACE:
- if(!sd->state.lr_flag)
- sd->right_weapon.addrace[type2]+=val;
- else if(sd->state.lr_flag == 1)
- sd->left_weapon.addrace[type2]+=val;
- else if(sd->state.lr_flag == 2)
- sd->arrow_addrace[type2]+=val;
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus2: SP_ADDRACE: Invalid Race(%d)\n",type2);
+ break;
+ }
+ if ( type2 >= RC_MAX ) {
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ) {
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ if ( !sd->state.lr_flag )
+ sd->right_weapon.addrace[i] += val;
+ else if ( sd->state.lr_flag == 1 )
+ sd->left_weapon.addrace[i] += val;
+ else if ( sd->state.lr_flag == 2 )
+ sd->arrow_addrace[i] += val;
+ }
+ } else {
+ if(!sd->state.lr_flag)
+ sd->right_weapon.addrace[type2] += val;
+ else if(sd->state.lr_flag == 1)
+ sd->left_weapon.addrace[type2] += val;
+ else if(sd->state.lr_flag == 2)
+ sd->arrow_addrace[type2] += val;
+ }
break;
case SP_ADDSIZE:
if(!sd->state.lr_flag)
@@ -2797,16 +2866,40 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
sd->arrow_addsize[type2]+=val;
break;
case SP_SUBELE:
- if(type2 >= ELE_MAX) {
+ if( (type2 >= ELE_MAX && type2 != ELE_ALL) || (type2 < ELE_NEUTRAL) ) {
ShowError("pc_bonus2: SP_SUBELE: Invalid element %d\n", type2);
break;
}
- if(sd->state.lr_flag != 2)
- sd->subele[type2]+=val;
+ if(sd->state.lr_flag != 2) {
+ if ( type2 == ELE_ALL ) {
+ for ( i = ELE_NEUTRAL; i < ELE_MAX; i++ ){
+ sd->subele[i] += val;
+ }
+ } else {
+ sd->subele[type2] += val;
+ }
+ }
break;
case SP_SUBRACE:
- if(sd->state.lr_flag != 2)
- sd->subrace[type2]+=val;
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus2: SP_SUBRACE: Invalid Race(%d)\n",type2);
+ break;
+ }
+ if(sd->state.lr_flag != 2) {
+ if (type2 >= RC_MAX ) {
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ sd->subrace[i] += val;
+ }
+ } else {
+ sd->subrace[type2]+=val;
+ }
+ }
break;
case SP_ADDEFF:
if (type2 > SC_MAX) {
@@ -2814,7 +2907,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
break;
}
pc->bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
- sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, 0);
+ sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, 0, 0);
break;
case SP_ADDEFF2:
if (type2 > SC_MAX) {
@@ -2822,7 +2915,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
break;
}
pc->bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
- sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, ATF_SELF);
+ sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, ATF_SELF, 0);
break;
case SP_RESEFF:
if (type2 < SC_COMMON_MIN || type2 > SC_COMMON_MAX) {
@@ -2835,24 +2928,57 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
sd->reseff[type2-SC_COMMON_MIN]= cap_value(i, 0, 10000);
break;
case SP_MAGIC_ADDELE:
- if(type2 >= ELE_MAX) {
+ if( (type2 >= ELE_MAX && type2 != ELE_ALL) || (type2 < ELE_NEUTRAL) ) {
ShowError("pc_bonus2: SP_MAGIC_ADDELE: Invalid element %d\n", type2);
break;
}
- if(sd->state.lr_flag != 2)
- sd->magic_addele[type2]+=val;
+ if ( sd->state.lr_flag != 2 ) {
+ if ( type2 == ELE_ALL ) {
+ for ( i = ELE_NEUTRAL; i < ELE_MAX; i++ )
+ sd->magic_addele[i] += val;
+ } else {
+ sd->magic_addele[type2] += val;
+ }
+ }
break;
case SP_MAGIC_ADDRACE:
- if(sd->state.lr_flag != 2)
- sd->magic_addrace[type2]+=val;
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus2: SP_MAGIC_ADDRACE: Invalid Race(%d)\n",type2);
+ break;
+ }
+ if(sd->state.lr_flag != 2){
+ if ( type2 >= RC_MAX ){
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ sd->magic_addrace[i] += val;
+ }
+ } else {
+ sd->magic_addrace[type2]+=val;
+ }
+ }
break;
case SP_MAGIC_ADDSIZE:
if(sd->state.lr_flag != 2)
sd->magic_addsize[type2]+=val;
break;
case SP_MAGIC_ATK_ELE:
- if(sd->state.lr_flag != 2)
- sd->magic_atk_ele[type2]+=val;
+ if( (type2 >= ELE_MAX && type2 != ELE_ALL) || (type2 < ELE_NEUTRAL) ) {
+ ShowError("pc_bonus2: SP_MAGIC_ATK_ELE: Invalid element %d\n", type2);
+ break;
+ }
+ if ( sd->state.lr_flag != 2 ) {
+ if ( type2 == ELE_ALL ) {
+ for ( i = ELE_NEUTRAL; i < ELE_MAX; i++ )
+ sd->magic_atk_ele[i] += val;
+ } else {
+ sd->magic_atk_ele[type2] += val;
+ }
+ }
break;
case SP_ADD_DAMAGE_CLASS:
switch (sd->state.lr_flag) {
@@ -3001,19 +3127,40 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
}
break;
case SP_WEAPON_COMA_ELE:
- if(type2 >= ELE_MAX) {
+ if( (type2 >= ELE_MAX && type2 != ELE_ALL) || (type2 < ELE_NEUTRAL) ) {
ShowError("pc_bonus2: SP_WEAPON_COMA_ELE: Invalid element %d\n", type2);
break;
}
if(sd->state.lr_flag == 2)
break;
- sd->weapon_coma_ele[type2] += val;
+ if ( type2 == ELE_ALL ) {
+ for ( i = ELE_NEUTRAL; i < ELE_MAX; i++ )
+ sd->weapon_coma_ele[i] += val;
+ } else {
+ sd->weapon_coma_ele[type2] += val;
+ }
sd->special_state.bonus_coma = 1;
break;
case SP_WEAPON_COMA_RACE:
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus2: SP_WEAPON_COMA_RACE: Invalid Race(%d)\n",type2);
+ break;
+ }
if(sd->state.lr_flag == 2)
break;
- sd->weapon_coma_race[type2] += val;
+ if ( type2 >= RC_MAX ) {
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ sd->weapon_coma_race[i] += val;
+ }
+ } else {
+ sd->weapon_coma_race[type2] += val;
+ }
sd->special_state.bonus_coma = 1;
break;
case SP_WEAPON_ATK:
@@ -3025,8 +3172,25 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
sd->weapon_atk_rate[type2]+=val;
break;
case SP_CRITICAL_ADDRACE:
- if(sd->state.lr_flag != 2)
- sd->critaddrace[type2] += val*10;
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus2: SP_CRITICAL_ADDRACE: Invalid Race(%d)\n",type2);
+ break;
+ }
+ if(sd->state.lr_flag != 2){
+ if ( type2 >= RC_MAX ){
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ sd->critaddrace[i] += val*10;
+ }
+ } else {
+ sd->critaddrace[type2] += val*10;
+ }
+ }
break;
case SP_ADDEFF_WHENHIT:
if (type2 > SC_MAX) {
@@ -3034,7 +3198,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
break;
}
if(sd->state.lr_flag != 2)
- pc->bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, val, 0, 0);
+ pc->bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, val, 0, 0, 0);
break;
case SP_SKILL_ATK:
if(sd->state.lr_flag == 2)
@@ -3197,12 +3361,46 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
sd->itemhealrate[i].rate += val;
break;
case SP_EXP_ADDRACE:
- if(sd->state.lr_flag != 2)
- sd->expaddrace[type2]+=val;
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus2: SP_EXP_ADDRACE: Invalid Race(%d)\n",type2);
+ break;
+ }
+ if(sd->state.lr_flag != 2) {
+ if ( type2 >= RC_MAX ){
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ sd->expaddrace[i] += val;
+ }
+ } else {
+ sd->expaddrace[type2] += val;
+ }
+ }
break;
case SP_SP_GAIN_RACE:
- if(sd->state.lr_flag != 2)
- sd->sp_gain_race[type2]+=val;
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus2: SP_SP_GAIN_RACE: Invalid Race(%d)\n",type2);
+ break;
+ }
+ if(sd->state.lr_flag != 2) {
+ if ( type2 >= RC_MAX ){
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ sd->sp_gain_race[i] += val;
+ }
+ } else {
+ sd->sp_gain_race[type2] += val;
+ }
+ }
break;
case SP_ADD_MONSTER_DROP_ITEM:
if (sd->state.lr_flag != 2)
@@ -3221,19 +3419,61 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
}
break;
case SP_HP_DRAIN_VALUE_RACE:
- if(!sd->state.lr_flag) {
- sd->right_weapon.hp_drain[type2].value += val;
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus2: SP_HP_DRAIN_VALUE_RACE: Invalid Race(%d)\n",type2);
+ break;
}
- else if(sd->state.lr_flag == 1) {
- sd->left_weapon.hp_drain[type2].value += val;
+ if ( type2 >= RC_MAX ){
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.hp_drain[i].value += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.hp_drain[i].value += val;
+ }
+ }
+ } else {
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.hp_drain[type2].value += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.hp_drain[type2].value += val;
+ }
}
break;
case SP_SP_DRAIN_VALUE_RACE:
- if(!sd->state.lr_flag) {
- sd->right_weapon.sp_drain[type2].value += val;
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus2: SP_SP_DRAIN_VALUE_RACE: Invalid Race(%d)\n",type2);
+ break;
}
- else if(sd->state.lr_flag == 1) {
- sd->left_weapon.sp_drain[type2].value += val;
+ if ( type2 >= RC_MAX ){
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.sp_drain[i].value += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.sp_drain[i].value += val;
+ }
+ }
+ } else {
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.sp_drain[type2].value += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.sp_drain[type2].value += val;
+ }
}
break;
case SP_IGNORE_MDEF_RATE:
@@ -3245,12 +3485,46 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
sd->ignore_def[type2] += val;
break;
case SP_SP_GAIN_RACE_ATTACK:
- if(sd->state.lr_flag != 2)
- sd->sp_gain_race_attack[type2] = cap_value(sd->sp_gain_race_attack[type2] + val, 0, INT16_MAX);
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus2: SP_SP_GAIN_RACE_ATTACK: Invalid Race(%d)\n",type2);
+ break;
+ }
+ if(sd->state.lr_flag != 2) {
+ if ( type2 >= RC_MAX ) {
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ sd->sp_gain_race_attack[i] = cap_value(sd->sp_gain_race_attack[i] + val, 0, INT16_MAX);
+ }
+ } else {
+ sd->sp_gain_race_attack[type2] = cap_value(sd->sp_gain_race_attack[type2] + val, 0, INT16_MAX);
+ }
+ }
break;
case SP_HP_GAIN_RACE_ATTACK:
- if(sd->state.lr_flag != 2)
- sd->hp_gain_race_attack[type2] = cap_value(sd->hp_gain_race_attack[type2] + val, 0, INT16_MAX);
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus2: SP_HP_GAIN_RACE_ATTACK: Invalid Race(%d)\n",type2);
+ break;
+ }
+ if(sd->state.lr_flag != 2) {
+ if ( type2 >= RC_MAX ) {
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ sd->hp_gain_race_attack[i] = cap_value(sd->hp_gain_race_attack[i] + val, 0, INT16_MAX);
+ }
+ } else {
+ sd->hp_gain_race_attack[type2] = cap_value(sd->hp_gain_race_attack[type2] + val, 0, INT16_MAX);
+ }
+ }
break;
case SP_SKILL_USE_SP_RATE: //bonus2 bSkillUseSPrate,n,x;
if(sd->state.lr_flag == 2)
@@ -3354,6 +3628,29 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if (sd->state.lr_flag != 2)
pc->bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), 0, val, 1<<type2, 10000);
break;
+#ifdef RENEWAL
+ case SP_RACE_TOLERANCE:
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus2: SP_RACE_TOLERANCE: Invalid Race(%d)\n",type2);
+ break;
+ }
+ if(sd->state.lr_flag != 2) {
+ if ( type2 >= RC_MAX ) {
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ sd->race_tolerance[i] += val;
+ }
+ } else {
+ sd->race_tolerance[type2] += val;
+ }
+ }
+ break;
+#endif
default:
ShowWarning("pc_bonus2: unknown type %d %d %d!\n",type,type2,val);
break;
@@ -3363,6 +3660,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
{
+ int i;
nullpo_ret(sd);
switch(type){
@@ -3412,23 +3710,69 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
}
break;
case SP_HP_DRAIN_RATE_RACE:
- if(!sd->state.lr_flag) {
- sd->right_weapon.hp_drain[type2].rate += type3;
- sd->right_weapon.hp_drain[type2].per += val;
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus3: SP_HP_DRAIN_RATE_RACE: Invalid Race(%d)\n",type2);
+ break;
}
- else if(sd->state.lr_flag == 1) {
- sd->left_weapon.hp_drain[type2].rate += type3;
- sd->left_weapon.hp_drain[type2].per += val;
+ if ( type2 >= RC_MAX ) {
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.hp_drain[i].rate += type3;
+ sd->right_weapon.hp_drain[i].per += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.hp_drain[i].rate += type3;
+ sd->left_weapon.hp_drain[i].per += val;
+ }
+ }
+ } else {
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.hp_drain[type2].rate += type3;
+ sd->right_weapon.hp_drain[type2].per += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.hp_drain[type2].rate += type3;
+ sd->left_weapon.hp_drain[type2].per += val;
+ }
}
break;
case SP_SP_DRAIN_RATE_RACE:
- if(!sd->state.lr_flag) {
- sd->right_weapon.sp_drain[type2].rate += type3;
- sd->right_weapon.sp_drain[type2].per += val;
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus3: SP_SP_DRAIN_RATE_RACE: Invalid Race(%d)\n",type2);
+ break;
}
- else if(sd->state.lr_flag == 1) {
- sd->left_weapon.sp_drain[type2].rate += type3;
- sd->left_weapon.sp_drain[type2].per += val;
+ if ( type2 >= RC_MAX ) {
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.sp_drain[i].rate += type3;
+ sd->right_weapon.sp_drain[i].per += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.sp_drain[i].rate += type3;
+ sd->left_weapon.sp_drain[i].per += val;
+ }
+ }
+ } else {
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.sp_drain[type2].rate += type3;
+ sd->right_weapon.sp_drain[type2].per += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.sp_drain[type2].rate += type3;
+ sd->left_weapon.sp_drain[type2].per += val;
+ }
}
break;
case SP_ADDEFF:
@@ -3437,7 +3781,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
break;
}
pc->bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
- sd->state.lr_flag!=2?type3:0, sd->state.lr_flag==2?type3:0, val);
+ sd->state.lr_flag!=2?type3:0, sd->state.lr_flag==2?type3:0, val, 0);
break;
case SP_ADDEFF_WHENHIT:
@@ -3446,7 +3790,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
break;
}
if(sd->state.lr_flag != 2)
- pc->bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, type3, 0, val);
+ pc->bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, type3, 0, val, 0);
break;
case SP_ADDEFF_ONSKILL:
@@ -3459,21 +3803,33 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
break;
case SP_ADDELE:
- if (type2 > ELE_MAX) {
- ShowWarning("pc_bonus3 (SP_ADDELE): element %d is out of range.\n", type2);
+ if( (type2 >= ELE_MAX && type2 != ELE_ALL) || (type2 < ELE_NEUTRAL) ) {
+ ShowError("pc_bonus3: SP_ADDELE: Invalid element %d\n", type2);
break;
}
- if (sd->state.lr_flag != 2)
- pc_bonus_addele(sd, (unsigned char)type2, type3, val);
+ if ( sd->state.lr_flag != 2 ) {
+ if ( type2 == ELE_ALL ) {
+ for ( i = ELE_NEUTRAL; i < ELE_MAX; i++ )
+ pc_bonus_addele(sd, (unsigned char)i, type3, val);
+ } else {
+ pc_bonus_addele(sd, (unsigned char)type2, type3, val);
+ }
+ }
break;
case SP_SUBELE:
- if (type2 > ELE_MAX) {
- ShowWarning("pc_bonus3 (SP_SUBELE): element %d is out of range.\n", type2);
+ if( (type2 >= ELE_MAX && type2 != ELE_ALL) || (type2 < ELE_NEUTRAL) ) {
+ ShowError("pc_bonus3: SP_SUBELE: Invalid element %d\n", type2);
break;
}
- if (sd->state.lr_flag != 2)
- pc_bonus_subele(sd, (unsigned char)type2, type3, val);
+ if ( sd->state.lr_flag != 2 ) {
+ if ( type2 == ELE_ALL ) {
+ for ( i = ELE_NEUTRAL; i < ELE_MAX; i++ )
+ pc_bonus_subele(sd, (unsigned char)i, type3, val);
+ } else {
+ pc_bonus_subele(sd, (unsigned char)type2, type3, val);
+ }
+ }
break;
case SP_SP_VANISH_RATE:
if(sd->state.lr_flag != 2) {
@@ -3492,6 +3848,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
}
int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4,int val) {
+ int i;
nullpo_ret(sd);
switch(type) {
@@ -3524,27 +3881,74 @@ int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4
break;
case SP_SET_DEF_RACE: //bonus4 bSetDefRace,n,x,r,y;
- if( type2 >= RC_MAX ) {
- ShowWarning("pc_bonus4 (DEF_SET): %d is not supported.\n", type2);
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus4: SP_SET_DEF_RACE: Invalid Race(%d)\n",type2);
break;
}
if(sd->state.lr_flag == 2)
break;
- sd->def_set_race[type2].rate = type3;
- sd->def_set_race[type2].tick = type4;
- sd->def_set_race[type2].value = val;
+ if ( type2 >= RC_MAX ) {
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ sd->def_set_race[i].rate = type3;
+ sd->def_set_race[i].tick = type4;
+ sd->def_set_race[i].value = val;
+ }
+ } else {
+ sd->def_set_race[type2].rate = type3;
+ sd->def_set_race[type2].tick = type4;
+ sd->def_set_race[type2].value = val;
+ }
break;
case SP_SET_MDEF_RACE: //bonus4 bSetMDefRace,n,x,r,y;
- if( type2 >= RC_MAX ) {
- ShowWarning("pc_bonus4 (MDEF_SET): %d is not supported.\n", type2);
+ if (type2 == RC_MAX || (type2 > RC_NONDEMIPLAYER && type2 != RC_ALL) || type2 < RC_FORMLESS ){
+ ShowWarning("pc_bonus4: SP_SET_MDEF_RACE: Invalid Race(%d)\n",type2);
break;
}
if(sd->state.lr_flag == 2)
break;
- sd->mdef_set_race[type2].rate = type3;
- sd->mdef_set_race[type2].tick = type4;
- sd->mdef_set_race[type2].value = val;
+ if ( type2 >= RC_MAX ) {
+ for ( i = RC_FORMLESS; i < RC_MAX; i++ ){
+ if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) ||
+ (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) ||
+ (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) ||
+ (type2 == RC_NONDEMIPLAYER && (i == RC_PLAYER || i == RC_DEMIHUMAN))
+ )
+ continue;
+ sd->mdef_set_race[i].rate = type3;
+ sd->mdef_set_race[i].tick = type4;
+ sd->mdef_set_race[i].value = val;
+ }
+ } else {
+ sd->mdef_set_race[type2].rate = type3;
+ sd->mdef_set_race[type2].tick = type4;
+ sd->mdef_set_race[type2].value = val;
+ }
+ break;
+
+ case SP_ADDEFF:
+ {
+ uint16 duration;
+ if (type2 > SC_MAX) {
+ ShowWarning("pc_bonus4 (Add Effect): %d is not supported.\n", type2);
+ break;
+ }
+ if (val < 0 || val > UINT16_MAX) {
+ ShowWarning("pc_bonus4 (Add Effect): invalid duration %d. Valid range: [0:%d].\n", val, UINT16_MAX);
+ duration = (val < 0 ? 0 : UINT16_MAX);
+ } else {
+ duration = (uint16)val;
+ }
+
+ pc->bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
+ sd->state.lr_flag!=2?type3:0, sd->state.lr_flag==2?type3:0, type4, duration);
+ }
break;
default:
@@ -3583,13 +3987,11 @@ int pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type4
}
/*==========================================
- * Grants a player a given skill. Flag values are:
- * 0 - Grant permanent skill to be bound to skill tree
- * 1 - Grant an item skill (temporary)
- * 2 - Like 1, except the level granted can stack with previously learned level.
- * 3 - Grant skill unconditionally and forever (persistent to job changes and skill resets)
+ * Grants a player a given skill.
+ * Flag values: @see enum pc_skill_flag
*------------------------------------------*/
-int pc_skill(TBL_PC* sd, int id, int level, int flag) {
+int pc_skill(TBL_PC* sd, int id, int level, int flag)
+{
uint16 index = 0;
nullpo_ret(sd);
@@ -3601,13 +4003,13 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) {
ShowError("pc_skill: Skill level %d too high. Max lv supported is %d\n", level, MAX_SKILL_LEVEL);
return 0;
}
- if( flag == 2 && sd->status.skill[index].lv + level > MAX_SKILL_LEVEL ) {
+ if( flag == SKILL_GRANT_TEMPSTACK && sd->status.skill[index].lv + level > MAX_SKILL_LEVEL ) {
ShowError("pc_skill: Skill level bonus %d too high. Max lv supported is %d. Curr lv is %d\n", level, MAX_SKILL_LEVEL, sd->status.skill[index].lv);
return 0;
}
switch( flag ){
- case 0: //Set skill data overwriting whatever was there before.
+ case SKILL_GRANT_PERMANENT: //Set skill data overwriting whatever was there before.
sd->status.skill[index].id = id;
sd->status.skill[index].lv = level;
sd->status.skill[index].flag = SKILL_FLAG_PERMANENT;
@@ -3616,10 +4018,10 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) {
clif->deleteskill(sd,id);
} else
clif->addskill(sd,id);
- if( !skill->db[index].inf ) //Only recalculate for passive skills.
+ if( !skill->dbs->db[index].inf ) //Only recalculate for passive skills.
status_calc_pc(sd, SCO_NONE);
break;
- case 1: //Item bonus skill.
+ case SKILL_GRANT_TEMPORARY: //Item bonus skill.
if( sd->status.skill[index].id == id ) {
if( sd->status.skill[index].lv >= level )
return 0;
@@ -3631,7 +4033,7 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) {
}
sd->status.skill[index].lv = level;
break;
- case 2: //Add skill bonus on top of what you had.
+ case SKILL_GRANT_TEMPSTACK: //Add skill bonus on top of what you had.
if( sd->status.skill[index].id == id ) {
if( sd->status.skill[index].flag == SKILL_FLAG_PERMANENT )
sd->status.skill[index].flag = SKILL_FLAG_REPLACED_LV_0 + sd->status.skill[index].lv; // Store previous level.
@@ -3641,7 +4043,7 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) {
}
sd->status.skill[index].lv += level;
break;
- case 3:
+ case SKILL_GRANT_UNCONDITIONAL:
sd->status.skill[index].id = id;
sd->status.skill[index].lv = level;
sd->status.skill[index].flag = SKILL_FLAG_PERM_GRANTED;
@@ -3650,60 +4052,100 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) {
clif->deleteskill(sd,id);
} else
clif->addskill(sd,id);
- if( !skill->db[index].inf ) //Only recalculate for passive skills.
+ if( !skill->dbs->db[index].inf ) //Only recalculate for passive skills.
status_calc_pc(sd, SCO_NONE);
break;
- default: //Unknown flag?
- return 0;
+ default: //Unknown flag?
+ return 0;
}
return 1;
}
+
+/**
+ * Checks if the given card can be inserted into the given equipment piece.
+ *
+ * @param sd The current character.
+ * @param idx_card The card's inventory index (note: it must be a valid index and can be checked by pc_can_insert_card)
+ * @param idx_equip The target equipment's inventory index.
+ * @retval true if the card can be inserted.
+ */
+bool pc_can_insert_card_into(struct map_session_data* sd, int idx_card, int idx_equip)
+{
+ int i;
+
+ nullpo_ret(sd);
+
+ if (idx_equip < 0 || idx_equip >= MAX_INVENTORY || sd->inventory_data[idx_equip] == NULL)
+ return false; //Invalid item index.
+ if (sd->status.inventory[idx_equip].nameid <= 0 || sd->status.inventory[idx_equip].amount < 1)
+ return false; // target item missing
+ if (sd->inventory_data[idx_equip]->type != IT_WEAPON && sd->inventory_data[idx_equip]->type != IT_ARMOR)
+ return false; // only weapons and armor are allowed
+ if (sd->status.inventory[idx_equip].identify == 0)
+ return false; // target must be identified
+ if (itemdb_isspecial(sd->status.inventory[idx_equip].card[0]))
+ return false; // card slots reserved for other purposes
+ if (sd->status.inventory[idx_equip].equip != 0)
+ return false; // item must be unequipped
+ if ((sd->inventory_data[idx_equip]->equip & sd->inventory_data[idx_card]->equip) == 0)
+ return false; // card cannot be compounded on this item type
+ if (sd->inventory_data[idx_equip]->type == IT_WEAPON && sd->inventory_data[idx_card]->equip == EQP_SHIELD)
+ return false; // attempted to place shield card on left-hand weapon.
+
+ ARR_FIND( 0, sd->inventory_data[idx_equip]->slot, i, sd->status.inventory[idx_equip].card[i] == 0);
+ if (i == sd->inventory_data[idx_equip]->slot)
+ return false; // no free slots
+ return true;
+}
+
+/**
+ * Checks if the given item is card and it can be inserted into some equipment.
+ *
+ * @param sd The current character.
+ * @param idx_card The card's inventory index.
+ * @retval true if the card can be inserted.
+ */
+bool pc_can_insert_card(struct map_session_data* sd, int idx_card)
+{
+ nullpo_ret(sd);
+
+ if (idx_card < 0 || idx_card >= MAX_INVENTORY || sd->inventory_data[idx_card] == NULL)
+ return false; //Invalid card index.
+ if (sd->status.inventory[idx_card].nameid <= 0 || sd->status.inventory[idx_card].amount < 1)
+ return false; // target card missing
+ if (sd->inventory_data[idx_card]->type != IT_CARD)
+ return false; // must be a card
+ return true;
+}
+
/*==========================================
* Append a card to an item ?
*------------------------------------------*/
int pc_insert_card(struct map_session_data* sd, int idx_card, int idx_equip)
{
- int i;
int nameid;
nullpo_ret(sd);
- if( idx_equip < 0 || idx_equip >= MAX_INVENTORY || sd->inventory_data[idx_equip] == NULL )
- return 0; //Invalid item index.
- if( idx_card < 0 || idx_card >= MAX_INVENTORY || sd->inventory_data[idx_card] == NULL )
- return 0; //Invalid card index.
- if( sd->status.inventory[idx_equip].nameid <= 0 || sd->status.inventory[idx_equip].amount < 1 )
- return 0; // target item missing
- if( sd->status.inventory[idx_card].nameid <= 0 || sd->status.inventory[idx_card].amount < 1 )
- return 0; // target card missing
- if( sd->inventory_data[idx_equip]->type != IT_WEAPON && sd->inventory_data[idx_equip]->type != IT_ARMOR )
- return 0; // only weapons and armor are allowed
- if( sd->inventory_data[idx_card]->type != IT_CARD )
- return 0; // must be a card
- if( sd->status.inventory[idx_equip].identify == 0 )
- return 0; // target must be identified
- if( itemdb_isspecial(sd->status.inventory[idx_equip].card[0]) )
- return 0; // card slots reserved for other purposes
- if( (sd->inventory_data[idx_equip]->equip & sd->inventory_data[idx_card]->equip) == 0 )
- return 0; // card cannot be compounded on this item type
- if( sd->inventory_data[idx_equip]->type == IT_WEAPON && sd->inventory_data[idx_card]->equip == EQP_SHIELD )
- return 0; // attempted to place shield card on left-hand weapon.
- if( sd->status.inventory[idx_equip].equip != 0 )
- return 0; // item must be unequipped
-
- ARR_FIND( 0, sd->inventory_data[idx_equip]->slot, i, sd->status.inventory[idx_equip].card[i] == 0 );
- if( i == sd->inventory_data[idx_equip]->slot )
- return 0; // no free slots
+ if (sd->state.trading != 0)
+ return 0;
+
+ if (!pc->can_insert_card(sd, idx_card) || !pc->can_insert_card_into(sd, idx_card, idx_equip))
+ return 0;
// remember the card id to insert
nameid = sd->status.inventory[idx_card].nameid;
- if( pc->delitem(sd,idx_card,1,1,0,LOG_TYPE_OTHER) == 1 )
+ if( pc->delitem(sd, idx_card, 1, 1, DELITEM_NORMAL, LOG_TYPE_OTHER) == 1 )
{// failed
clif->insert_card(sd,idx_equip,idx_card,1);
}
else
{// success
+ int i;
+ ARR_FIND( 0, sd->inventory_data[idx_equip]->slot, i, sd->status.inventory[idx_equip].card[i] == 0);
+ if (i == sd->inventory_data[idx_equip]->slot)
+ return 0; // no free slots
logs->pick_pc(sd, LOG_TYPE_OTHER, -1, &sd->status.inventory[idx_equip],sd->inventory_data[idx_equip]);
sd->status.inventory[idx_equip].card[i] = nameid;
logs->pick_pc(sd, LOG_TYPE_OTHER, 1, &sd->status.inventory[idx_equip],sd->inventory_data[idx_equip]);
@@ -4047,6 +4489,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
if( sd->status.inventory[i].nameid == item_data->nameid &&
sd->status.inventory[i].bound == item_data->bound &&
sd->status.inventory[i].expire_time == 0 &&
+ sd->status.inventory[i].unique_id == item_data->unique_id &&
memcmp(&sd->status.inventory[i].card, &item_data->card, sizeof(item_data->card)) == 0 ) {
if( amount > MAX_AMOUNT - sd->status.inventory[i].amount || ( data->stack.inventory && amount > data->stack.amount - sd->status.inventory[i].amount ) )
return 5;
@@ -4074,8 +4517,8 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
clif->additem(sd,i,amount,0);
}
- if( !itemdb->isstackable2(data) && !item_data->unique_id )
- sd->status.inventory[i].unique_id = itemdb->unique_id(sd);
+ if( ( !itemdb->isstackable2(data) || data->flag.force_serial || data->type == IT_CASH) && !item_data->unique_id )
+ sd->status.inventory[i].unique_id = itemdb->unique_id(sd);
logs->pick_pc(sd, log_type, amount, &sd->status.inventory[i],sd->inventory_data[i]);
@@ -4105,6 +4548,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
* @type
* 1 : don't notify deletion
* 2 : don't notify weight change
+ * reason: @see enum delitem_reason
* Return:
* 0 = success
* 1 = invalid itemid or negative amount
@@ -4122,7 +4566,7 @@ int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reas
sd->weight -= sd->inventory_data[n]->weight*amount ;
if( sd->status.inventory[n].amount <= 0 ){
if(sd->status.inventory[n].equip)
- pc->unequipitem(sd,n,3);
+ pc->unequipitem(sd, n, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
memset(&sd->status.inventory[n],0,sizeof(sd->status.inventory[0]));
sd->inventory_data[n] = NULL;
}
@@ -4172,7 +4616,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount)
if (!map->addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2))
return 0;
- pc->delitem(sd, n, amount, 1, 0, LOG_TYPE_PICKDROP_PLAYER);
+ pc->delitem(sd, n, amount, 1, DELITEM_NORMAL, LOG_TYPE_PICKDROP_PLAYER);
clif->dropitem(sd, n, amount);
return 1;
}
@@ -4267,14 +4711,14 @@ int pc_isUseitem(struct map_session_data *sd,int n)
if( !item->script ) //if it has no script, you can't really consume it!
return 0;
- if( (item->item_usage.flag&INR_SITTING) && (pc_issit(sd) == 1) && (pc_get_group_level(sd) < item->item_usage.override) ) {
- clif->msgtable(sd->fd,0x297);
- //clif->colormes(sd->fd,COLOR_WHITE,msg_txt(1474));
+ if ((item->item_usage.flag&INR_SITTING) && (pc_issit(sd) == 1) && (pc_get_group_level(sd) < item->item_usage.override)) {
+ clif->msgtable(sd, MSG_ITEM_NEED_STANDING);
+ //clif->messagecolor_self(sd->fd, COLOR_WHITE, msg_txt(1474));
return 0; // You cannot use this item while sitting.
}
- if (sd->state.storage_flag && item->type != IT_CASH) {
- clif->colormes(sd->fd, COLOR_RED, msg_sd(sd,1475));
+ if (sd->state.storage_flag != STORAGE_FLAG_CLOSED && item->type != IT_CASH) {
+ clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1475));
return 0; // You cannot use this item while storage is open.
}
@@ -4373,12 +4817,12 @@ int pc_isUseitem(struct map_session_data *sd,int n)
return 0;
if( item->package || item->group ) {
- if( pc_is90overweight(sd) ) {
- clif->msgtable(sd->fd,ITEM_CANT_OBTAIN_WEIGHT);
+ if (pc_is90overweight(sd)) {
+ clif->msgtable(sd, MSG_ITEM_CANT_OBTAIN_WEIGHT);
return 0;
}
- if( !pc->inventoryblank(sd) ) {
- clif->colormes(sd->fd,COLOR_RED,msg_sd(sd,1477));
+ if (!pc->inventoryblank(sd)) {
+ clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1477));
return 0;
}
}
@@ -4387,13 +4831,13 @@ int pc_isUseitem(struct map_session_data *sd,int n)
if(item->sex != 2 && sd->status.sex != item->sex)
return 0;
//Required level check
- if(item->elv && sd->status.base_level < (unsigned int)item->elv){
- clif->msg(sd, 0x6EE);
+ if (item->elv && sd->status.base_level < (unsigned int)item->elv) {
+ clif->msgtable(sd, MSG_ITEM_CANT_USE_LVL);
return 0;
}
- if(item->elvmax && sd->status.base_level > (unsigned int)item->elvmax){
- clif->msg(sd, 0x6EE);
+ if (item->elvmax && sd->status.base_level > (unsigned int)item->elvmax) {
+ clif->msgtable(sd, MSG_ITEM_CANT_USE_LVL);
return 0;
}
@@ -4445,7 +4889,7 @@ int pc_useitem(struct map_session_data *sd,int n) {
if( sd->npc_id || sd->state.workinprogress&1 ){
/* TODO: add to clif->messages enum */
#ifdef RENEWAL
- clif->msg(sd, 0x783); // TODO look for the client date that has this message.
+ clif->msgtable(sd, MSG_NPC_WORK_IN_PROGRESS); // TODO look for the client date that has this message.
#endif
return 0;
}
@@ -4508,7 +4952,7 @@ int pc_useitem(struct map_session_data *sd,int n) {
if( sd->item_delay[i].nameid ) {// found
if( DIFF_TICK(sd->item_delay[i].tick, tick) > 0 ) {
int e_tick = (int)(DIFF_TICK(sd->item_delay[i].tick, tick)/1000);
- clif->msgtable_num(sd->fd, 0x746, e_tick + 1); // [%d] seconds left until you can use
+ clif->msgtable_num(sd, MSG_SECONDS_UNTIL_USE, e_tick + 1); // [%d] seconds left until you can use
return 0; // Delay has not expired yet
}
} else {// not yet used item (all slots are initially empty)
@@ -4531,10 +4975,10 @@ int pc_useitem(struct map_session_data *sd,int n) {
/* on restricted maps the item is consumed but the effect is not used */
for(i = 0; i < map->list[sd->bl.m].zone->disabled_items_count; i++) {
if( map->list[sd->bl.m].zone->disabled_items[i] == nameid ) {
- clif->msg(sd, ITEM_CANT_USE_AREA); // This item cannot be used within this area
+ clif->msgtable(sd, MSG_ITEM_CANT_USE_AREA); // This item cannot be used within this area
if( battle_config.item_restricted_consumption_type && sd->status.inventory[n].expire_time == 0 ) {
clif->useitemack(sd,n,sd->status.inventory[n].amount-1,true);
- pc->delitem(sd,n,1,1,0,LOG_TYPE_CONSUME);
+ pc->delitem(sd, n, 1, 1, DELITEM_NORMAL, LOG_TYPE_CONSUME);
}
return 0;
}
@@ -4552,14 +4996,15 @@ int pc_useitem(struct map_session_data *sd,int n) {
amount = sd->status.inventory[n].amount;
item_script = sd->inventory_data[n]->script;
//Check if the item is to be consumed immediately [Skotlex]
- if( sd->inventory_data[n]->flag.delay_consume )
+ if (sd->inventory_data[n]->flag.delay_consume || sd->inventory_data[n]->flag.keepafteruse)
clif->useitemack(sd,n,amount,true);
else {
- 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
- clif->useitemack(sd,n,0,false);
+ if (sd->status.inventory[n].expire_time == 0) {
+ clif->useitemack(sd, n, amount - 1, true);
+ pc->delitem(sd, n, 1, 1, DELITEM_NORMAL, LOG_TYPE_CONSUME); // Rental Usable Items are not deleted until expiration
+ } else {
+ clif->useitemack(sd, n, 0, false);
+ }
}
if(sd->status.inventory[n].card[0]==CARD0_CREATE &&
pc->famerank(MakeDWord(sd->status.inventory[n].card[2],sd->status.inventory[n].card[3]), MAPID_ALCHEMIST))
@@ -4625,7 +5070,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
sd->status.cart[i].card[2] == item_data->card[2] && sd->status.cart[i].card[3] == item_data->card[3] );
};
- if( i < MAX_CART )
+ if( i < MAX_CART && item_data->unique_id == sd->status.cart[i].unique_id)
{// item already in cart, stack it
if( amount > MAX_AMOUNT - sd->status.cart[i].amount || ( data->stack.cart && amount > data->stack.amount - sd->status.cart[i].amount ) )
return 2; // no room
@@ -4704,7 +5149,7 @@ int pc_putitemtocart(struct map_session_data *sd,int idx,int amount)
return 1;
if( (flag = pc->cart_additem(sd,item_data,amount,LOG_TYPE_NONE)) == 0 )
- return pc->delitem(sd,idx,amount,0,5,LOG_TYPE_NONE);
+ return pc->delitem(sd, idx, amount, 0, DELITEM_TOCART, LOG_TYPE_NONE);
return flag;
}
@@ -4763,7 +5208,7 @@ void pc_bound_clear(struct map_session_data *sd, enum e_item_bound_type type) {
case IBT_CHARACTER:
for( i = 0; i < MAX_INVENTORY; i++ ){
if( sd->status.inventory[i].bound == type ) {
- pc->delitem(sd,i,sd->status.inventory[i].amount,0,1,LOG_TYPE_OTHER);
+ pc->delitem(sd, i, sd->status.inventory[i].amount, 0, DELITEM_SKILLUSE, LOG_TYPE_OTHER); // FIXME: is this the correct reason flag?
}
}
break;
@@ -4777,7 +5222,7 @@ void pc_bound_clear(struct map_session_data *sd, enum e_item_bound_type type) {
if(sd->status.inventory[i].bound == type) {
if( gstor )
gstorage->additem(sd,gstor,&sd->status.inventory[i],sd->status.inventory[i].amount);
- pc->delitem(sd,i,sd->status.inventory[i].amount,0,1,gstor?LOG_TYPE_GSTORAGE:LOG_TYPE_OTHER);
+ pc->delitem(sd, i, sd->status.inventory[i].amount, 0, DELITEM_SKILLUSE, gstor ? LOG_TYPE_GSTORAGE : LOG_TYPE_OTHER); // FIXME: is this the correct reason flag?
}
}
if( gstor )
@@ -5046,7 +5491,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short map_index, int x, int
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 );
+ pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_FORCE);
}
if (battle_config.clear_unit_onwarp&BL_PC)
skill->clear_unitgroup(&sd->bl);
@@ -5262,14 +5707,14 @@ int pc_checkskill2(struct map_session_data *sd,uint16 index) {
ShowError("pc_checkskill: Invalid skill index %d (char_id=%d).\n", index, sd->status.char_id);
return 0;
}
- if( skill->db[index].nameid >= GD_SKILLBASE && skill->db[index].nameid < GD_MAX ) {
+ if( skill->dbs->db[index].nameid >= GD_SKILLBASE && skill->dbs->db[index].nameid < GD_MAX ) {
struct guild *g;
if( sd->status.guild_id>0 && (g=sd->guild)!=NULL)
- return guild->checkskill(g,skill->db[index].nameid);
+ return guild->checkskill(g,skill->dbs->db[index].nameid);
return 0;
}
- if(sd->status.skill[index].id == skill->db[index].nameid)
+ if(sd->status.skill[index].id == skill->dbs->db[index].nameid)
return (sd->status.skill[index].lv);
return 0;
@@ -5862,6 +6307,138 @@ const char* job_name(int class_)
}
}
+int pc_check_job_name(const char *name) {
+ int i, len;
+ struct {
+ const char *name;
+ int id;
+ } names[] = {
+ { "Novice", JOB_NOVICE },
+ { "Swordsman", JOB_SWORDMAN },
+ { "Magician", JOB_MAGE },
+ { "Archer", JOB_ARCHER },
+ { "Acolyte", JOB_ACOLYTE },
+ { "Merchant", JOB_MERCHANT },
+ { "Thief", JOB_THIEF },
+ { "Knight", JOB_KNIGHT },
+ { "Priest", JOB_PRIEST },
+ { "Wizard", JOB_WIZARD },
+ { "Blacksmith", JOB_BLACKSMITH },
+ { "Hunter", JOB_HUNTER },
+ { "Assassin", JOB_ASSASSIN },
+ { "Crusader", JOB_CRUSADER },
+ { "Monk", JOB_MONK },
+ { "Sage", JOB_SAGE },
+ { "Rogue", JOB_ROGUE },
+ { "Alchemist", JOB_ALCHEMIST },
+ { "Bard", JOB_BARD },
+ { "Dancer", JOB_DANCER },
+ { "Super_Novice", JOB_SUPER_NOVICE },
+ { "Gunslinger", JOB_GUNSLINGER },
+ { "Ninja", JOB_NINJA },
+ { "Novice_High", JOB_NOVICE_HIGH },
+ { "Swordsman_High", JOB_SWORDMAN_HIGH },
+ { "Magician_High", JOB_MAGE_HIGH },
+ { "Archer_High", JOB_ARCHER_HIGH },
+ { "Acolyte_High", JOB_ACOLYTE_HIGH },
+ { "Merchant_High", JOB_MERCHANT_HIGH },
+ { "Thief_High", JOB_THIEF_HIGH },
+ { "Lord_Knight", JOB_LORD_KNIGHT },
+ { "High_Priest", JOB_HIGH_PRIEST },
+ { "High_Wizard", JOB_HIGH_WIZARD },
+ { "Whitesmith", JOB_WHITESMITH },
+ { "Sniper", JOB_SNIPER },
+ { "Assassin_Cross", JOB_ASSASSIN_CROSS },
+ { "Paladin", JOB_PALADIN },
+ { "Champion", JOB_CHAMPION },
+ { "Professor", JOB_PROFESSOR },
+ { "Stalker", JOB_STALKER },
+ { "Creator", JOB_CREATOR },
+ { "Clown", JOB_CLOWN },
+ { "Gypsy", JOB_GYPSY },
+ { "Baby_Novice", JOB_BABY },
+ { "Baby_Swordsman", JOB_BABY_SWORDMAN },
+ { "Baby_Magician", JOB_BABY_MAGE },
+ { "Baby_Archer", JOB_BABY_ARCHER },
+ { "Baby_Acolyte", JOB_BABY_ACOLYTE },
+ { "Baby_Merchant", JOB_BABY_MERCHANT },
+ { "Baby_Thief", JOB_BABY_THIEF },
+ { "Baby_Knight", JOB_BABY_KNIGHT },
+ { "Baby_Priest", JOB_BABY_PRIEST },
+ { "Baby_Wizard", JOB_BABY_WIZARD },
+ { "Baby_Blacksmith", JOB_BABY_BLACKSMITH },
+ { "Baby_Hunter", JOB_BABY_HUNTER },
+ { "Baby_Assassin", JOB_BABY_ASSASSIN },
+ { "Baby_Crusader", JOB_BABY_CRUSADER },
+ { "Baby_Monk", JOB_BABY_MONK },
+ { "Baby_Sage", JOB_BABY_SAGE },
+ { "Baby_Rogue", JOB_BABY_ROGUE },
+ { "Baby_Alchemist", JOB_BABY_ALCHEMIST },
+ { "Baby_Bard", JOB_BABY_BARD },
+ { "Baby_Dancer", JOB_BABY_DANCER },
+ { "Super_Baby", JOB_SUPER_BABY },
+ { "Taekwon", JOB_TAEKWON },
+ { "Star_Gladiator", JOB_STAR_GLADIATOR },
+ { "Soul_Linker", JOB_SOUL_LINKER },
+ { "Gangsi", JOB_GANGSI },
+ { "Death_Knight", JOB_DEATH_KNIGHT },
+ { "Dark_Collector", JOB_DARK_COLLECTOR },
+ { "Rune_Knight", JOB_RUNE_KNIGHT },
+ { "Warlock", JOB_WARLOCK },
+ { "Ranger", JOB_RANGER },
+ { "Arch_Bishop", JOB_ARCH_BISHOP },
+ { "Mechanic", JOB_MECHANIC },
+ { "Guillotine_Cross", JOB_GUILLOTINE_CROSS },
+ { "Rune_Knight_Trans", JOB_RUNE_KNIGHT_T },
+ { "Warlock_Trans", JOB_WARLOCK_T },
+ { "Ranger_Trans", JOB_RANGER_T },
+ { "Arch_Bishop_Trans", JOB_ARCH_BISHOP_T },
+ { "Mechanic_Trans", JOB_MECHANIC_T },
+ { "Guillotine_Cross_Trans", JOB_GUILLOTINE_CROSS_T },
+ { "Royal_Guard", JOB_ROYAL_GUARD },
+ { "Sorcerer", JOB_SORCERER },
+ { "Minstrel", JOB_MINSTREL },
+ { "Wanderer", JOB_WANDERER },
+ { "Sura", JOB_SURA },
+ { "Genetic", JOB_GENETIC },
+ { "Shadow_Chaser", JOB_SHADOW_CHASER },
+ { "Royal_Guard_Trans", JOB_ROYAL_GUARD_T },
+ { "Sorcerer_Trans", JOB_SORCERER_T },
+ { "Minstrel_Trans", JOB_MINSTREL_T },
+ { "Wanderer_Trans", JOB_WANDERER_T },
+ { "Sura_Trans", JOB_SURA_T },
+ { "Genetic_Trans", JOB_GENETIC_T },
+ { "Shadow_Chaser_Trans", JOB_SHADOW_CHASER_T },
+ { "Baby_Rune_Knight", JOB_BABY_RUNE },
+ { "Baby_Warlock", JOB_BABY_WARLOCK },
+ { "Baby_Ranger", JOB_BABY_RANGER },
+ { "Baby_Arch_Bishop", JOB_BABY_BISHOP },
+ { "Baby_Mechanic", JOB_BABY_MECHANIC },
+ { "Baby_Guillotine_Cross", JOB_BABY_CROSS },
+ { "Baby_Royal_Guard", JOB_BABY_GUARD },
+ { "Baby_Sorcerer", JOB_BABY_SORCERER },
+ { "Baby_Minstrel", JOB_BABY_MINSTREL },
+ { "Baby_Wanderer", JOB_BABY_WANDERER },
+ { "Baby_Sura", JOB_BABY_SURA },
+ { "Baby_Genetic", JOB_BABY_GENETIC },
+ { "Baby_Shadow_Chaser", JOB_BABY_CHASER },
+ { "Expanded_Super_Novice", JOB_SUPER_NOVICE_E },
+ { "Expanded_Super_Baby", JOB_SUPER_BABY_E },
+ { "Kagerou", JOB_KAGEROU },
+ { "Oboro", JOB_OBORO },
+ { "Rebellion", JOB_REBELLION },
+ };
+
+ len = ARRAYLENGTH(names);
+
+ ARR_FIND(0, len, i, strcmpi(names[i].name, name) == 0);
+
+ if ( i == len )
+ return -1;
+
+ return names[i].id;
+}
+
int pc_follow_timer(int tid, int64 tick, int id, intptr_t data) {
struct map_session_data *sd;
struct block_list *tbl;
@@ -5911,7 +6488,7 @@ int pc_stop_following (struct map_session_data *sd)
sd->followtarget = -1;
sd->ud.target_to = 0;
- unit->stop_walking(&sd->bl, 1);
+ unit->stop_walking(&sd->bl, STOPWALKING_FLAG_FIXPOS);
return 0;
}
@@ -5984,7 +6561,7 @@ void pc_baselevelchanged(struct map_session_data *sd) {
for( i = 0; i < EQI_MAX; i++ ) {
if( sd->equip_index[i] >= 0 ) {
if( sd->inventory_data[ sd->equip_index[i] ]->elvmax && sd->status.base_level > (unsigned int)sd->inventory_data[ sd->equip_index[i] ]->elvmax )
- pc->unequipitem(sd, sd->equip_index[i], 3);
+ pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
}
}
}
@@ -6439,7 +7016,7 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) {
{
sd->status.skill[index].lv++;
sd->status.skill_point--;
- if( !skill->db[index].inf )
+ if( !skill->dbs->db[index].inf )
status_calc_pc(sd,SCO_NONE); // Only recalculate for passive skills.
else if( sd->status.skill_point == 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )
pc->calc_skilltree(sd); // Required to grant all TK Ranger skills.
@@ -6453,14 +7030,12 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) {
if (!pc_has_permission(sd, PC_PERM_ALL_SKILL)) // may skill everything at any time anyways, and this would cause a huge slowdown
clif->skillinfoblock(sd);
} else if( battle_config.skillup_limit ){
- if( sd->sktree.second )
- clif->msg_value(sd, 0x61E, sd->sktree.second);
- else if( sd->sktree.third )
- clif->msg_value(sd, 0x61F, sd->sktree.third);
- else if( pc->calc_skillpoint(sd) < 9 ) {
- /* TODO: official response? */
- clif->colormes(sd->fd,COLOR_RED,"You need the basic skills");
- }
+ if (sd->sktree.second)
+ clif->msgtable_num(sd, MSG_SKILL_POINTS_LEFT_JOB1, sd->sktree.second);
+ else if (sd->sktree.third)
+ clif->msgtable_num(sd, MSG_SKILL_POINTS_LEFT_JOB2, sd->sktree.third);
+ else if (pc->calc_skillpoint(sd) < 9) /* TODO: official response? */
+ clif->messagecolor_self(sd->fd, COLOR_RED, "You need the basic skills");
}
return 0;
}
@@ -6486,22 +7061,22 @@ int pc_allskillup(struct map_session_data *sd)
if (pc_has_permission(sd, PC_PERM_ALL_SKILL)) { //Get ALL skills except npc/guild ones. [Skotlex]
//and except SG_DEVIL [Komurka] and MO_TRIPLEATTACK and RG_SNATCHER [ultramage]
for(i=0;i<MAX_SKILL;i++){
- switch( skill->db[i].nameid ) {
+ switch( skill->dbs->db[i].nameid ) {
case SG_DEVIL:
case MO_TRIPLEATTACK:
case RG_SNATCHER:
continue;
default:
- if( !(skill->db[i].inf2&(INF2_NPC_SKILL|INF2_GUILD_SKILL)) )
- if ( ( sd->status.skill[i].lv = skill->db[i].max ) )//Nonexistant skills should return a max of 0 anyway.
- sd->status.skill[i].id = skill->db[i].nameid;
+ if( !(skill->dbs->db[i].inf2&(INF2_NPC_SKILL|INF2_GUILD_SKILL)) )
+ if ( ( sd->status.skill[i].lv = skill->dbs->db[i].max ) )//Nonexistant skills should return a max of 0 anyway.
+ sd->status.skill[i].id = skill->dbs->db[i].nameid;
}
}
} else {
int id;
for (i = 0; i < MAX_SKILL_TREE && (id=pc->skill_tree[pc->class2idx(sd->status.class_)][i].id) > 0; i++) {
int idx = pc->skill_tree[pc->class2idx(sd->status.class_)][i].idx;
- int inf2 = skill->db[idx].inf2;
+ int inf2 = skill->dbs->db[idx].inf2;
if (
(inf2&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) ||
(inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL)) ||
@@ -6530,9 +7105,9 @@ int pc_resetlvl(struct map_session_data* sd,int type)
nullpo_ret(sd);
if (type != 3) //Also reset skills
- pc->resetskill(sd, 0);
+ pc->resetskill(sd, PCRESETSKILL_NONE);
- if(type == 1){
+ if(type == 1) {
sd->status.skill_point=0;
sd->status.base_level=1;
sd->status.job_level=1;
@@ -6550,8 +7125,8 @@ int pc_resetlvl(struct map_session_data* sd,int type)
if(sd->status.class_ == JOB_NOVICE_HIGH) {
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);
+ pc->skill(sd, NV_FIRSTAID, 1, SKILL_GRANT_PERMANENT);
+ pc->skill(sd, NV_TRICKDEAD, 1, SKILL_GRANT_PERMANENT);
}
}
@@ -6597,7 +7172,7 @@ int pc_resetlvl(struct map_session_data* sd,int type)
for(i=0;i<EQI_MAX;i++) { // unequip items that can't be equipped by base 1 [Valaris]
if(sd->equip_index[i] >= 0)
if(!pc->isequip(sd,sd->equip_index[i]))
- pc->unequipitem(sd,sd->equip_index[i],2);
+ pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_FORCE);
}
if ((type == 1 || type == 2 || type == 3) && sd->status.party_id)
@@ -6675,19 +7250,17 @@ int pc_resetstate(struct map_session_data* sd)
/*==========================================
* /resetskill
- * if flag&1, perform block resync and status_calc call.
- * if flag&2, just count total amount of skill points used by player, do not really reset.
- * if flag&4, just reset the skills if the player class is a bard/dancer type (for changesex.)
+ * @param flag: @see enum pc_resetskill_flag
*------------------------------------------*/
int pc_resetskill(struct map_session_data* sd, int flag)
{
int i, inf2, skill_point=0;
nullpo_ret(sd);
- if( flag&4 && (sd->class_&MAPID_UPPERMASK) != MAPID_BARDDANCER )
+ if( flag&PCRESETSKILL_CHSEX && (sd->class_&MAPID_UPPERMASK) != MAPID_BARDDANCER )
return 0;
- if( !(flag&2) ) { //Remove stuff lost when resetting skills.
+ if( !(flag&PCRESETSKILL_RECOUNT) ) { //Remove stuff lost when resetting skills.
/**
* It has been confirmed on official server that when you reset skills with a ranked tweakwon your skills are not reset (because you have all of them anyway)
@@ -6726,17 +7299,17 @@ int pc_resetskill(struct map_session_data* sd, int flag)
for( i = 1; i < MAX_SKILL; i++ ) {
// FIXME: We're looping on i = [1..MAX_SKILL-1] (which makes sense as index for sd->status.skill[]) but then we're using the
- // same i to access skill->db[], and especially to check skill_ischangesex(). This is wrong.
+ // same i to access skill->dbs->db[], and especially to check skill_ischangesex(). This is wrong.
uint16 skill_id = 0;
int lv = sd->status.skill[i].lv;
if (lv < 1) continue;
- inf2 = skill->db[i].inf2;
+ inf2 = skill->dbs->db[i].inf2;
if( inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL) ) //Avoid reseting wedding/linker skills.
continue;
- skill_id = skill->db[i].nameid;
+ skill_id = skill->dbs->db[i].nameid;
// Don't reset trick dead if not a novice/baby
if( skill_id == NV_TRICKDEAD && (sd->class_&(MAPID_BASEMASK|JOBL_2)) != MAPID_NOVICE ) {
@@ -6752,12 +7325,12 @@ int pc_resetskill(struct map_session_data* sd, int flag)
if( sd->status.skill[i].flag == SKILL_FLAG_PERM_GRANTED )
continue;
- if( flag&4 && !skill_ischangesex(i) )
+ if( flag&PCRESETSKILL_CHSEX && !skill_ischangesex(i) )
continue;
if( inf2&INF2_QUEST_SKILL && !battle_config.quest_skill_learn ) {
//Only handle quest skills in a special way when you can't learn them manually
- if( battle_config.quest_skill_reset && !(flag&2) ) { //Wipe them
+ if( battle_config.quest_skill_reset && !(flag&PCRESETSKILL_RECOUNT) ) { //Wipe them
sd->status.skill[i].lv = 0;
sd->status.skill[i].flag = 0;
}
@@ -6768,18 +7341,18 @@ int pc_resetskill(struct map_session_data* sd, int flag)
else if( sd->status.skill[i].flag >= SKILL_FLAG_REPLACED_LV_0 )
skill_point += (sd->status.skill[i].flag - SKILL_FLAG_REPLACED_LV_0);
- if( !(flag&2) ) {// reset
+ if( !(flag&PCRESETSKILL_RECOUNT) ) {// reset
sd->status.skill[i].lv = 0;
sd->status.skill[i].flag = 0;
}
}
- if( flag&2 || !skill_point ) return skill_point;
+ if( flag&PCRESETSKILL_RECOUNT || !skill_point ) return skill_point;
sd->status.skill_point += skill_point;
- if( !(flag&2) ) {
+ if (!(flag&PCRESETSKILL_RECOUNT)) {
// Remove all SCs that can't be inactivated without a skill
if( sd->sc.data[SC_STORMKICK_READY] )
status_change_end(&sd->bl, SC_STORMKICK_READY, INVALID_TIMER);
@@ -6793,7 +7366,7 @@ int pc_resetskill(struct map_session_data* sd, int flag)
status_change_end(&sd->bl, SC_DODGE_READY, INVALID_TIMER);
}
- if( flag&1 ) {
+ if (flag&PCRESETSKILL_RESYNC) {
clif->updatestatus(sd,SP_SKILLPOINT);
clif->skillinfoblock(sd);
status_calc_pc(sd,SCO_FORCE);
@@ -6825,8 +7398,7 @@ int pc_resethate(struct map_session_data* sd)
int i;
nullpo_ret(sd);
- for (i=0; i<3; i++)
- {
+ for (i = 0; i < MAX_PC_FEELHATE; i++) {
sd->hate_mob[i] = -1;
pc_setglobalreg(sd,script->add_str(pc->sg_info[i].hate_var),0);
}
@@ -6943,8 +7515,8 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
nullpo_retr(0, sd);
- for(j = 0; j < 5; j++) {
- if (sd->devotion[j]){
+ for (j = 0; j < MAX_PC_DEVOTION; j++) {
+ if (sd->devotion[j]) {
struct map_session_data *devsd = map->id2sd(sd->devotion[j]);
if (devsd)
status_change_end(&devsd->bl, SC_DEVOTION, INVALID_TIMER);
@@ -7048,7 +7620,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
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]
+ && !md->guardian_data && md->special_state.ai == AI_NONE// Guardians/summons should not level. [Skotlex]
) {
// monster level up [Valaris]
clif->misceffect(&md->bl,0);
@@ -7228,7 +7800,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
int n = eq_n[rnd()%eq_num];
if(rnd()%10000 < per){
if(sd->status.inventory[n].equip)
- pc->unequipitem(sd,n,3);
+ pc->unequipitem(sd, n, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
pc->dropitem(sd,n,1);
}
}
@@ -7241,7 +7813,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
|| (type == 2 && sd->status.inventory[i].equip)
|| type == 3) ){
if(sd->status.inventory[i].equip)
- pc->unequipitem(sd,i,3);
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
pc->dropitem(sd,i,1);
break;
}
@@ -7890,7 +8462,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], PCUNEQUIPITEM_FORCE); // unequip invalid item for class
}
//Change look, if disguised, you need to undisguise
@@ -8085,7 +8657,7 @@ int pc_setoption(struct map_session_data *sd,int type)
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);
+ pc->unequipitem(sd, sd->equip_index[EQI_AMMO], PCUNEQUIPITEM_FORCE);
}
#endif
@@ -8122,7 +8694,7 @@ 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);
+ pc->unequipitem(sd, sd->equip_index[EQI_AMMO], PCUNEQUIPITEM_FORCE);
}
if (type&OPTION_FLYING && !(p_type&OPTION_FLYING))
@@ -8176,7 +8748,7 @@ int pc_setcart(struct map_session_data *sd,int type) {
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);
+ pc->unequipitem(sd, sd->equip_index[EQI_AMMO], PCUNEQUIPITEM_FORCE);
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 */
@@ -8952,6 +9524,9 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int pos
/*==========================================
* Equip item on player sd at req_pos from inventory index n
+ * Return:
+ * 0 = fail
+ * 1 = success
*------------------------------------------*/
int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
{
@@ -9024,7 +9599,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
for(i=0;i<EQI_MAX;i++) {
if(pos & pc->equip_pos[i]) {
if(sd->equip_index[i] >= 0) //Slot taken, remove item from there.
- pc->unequipitem(sd,sd->equip_index[i],2);
+ pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_FORCE);
sd->equip_index[i] = n;
}
@@ -9083,7 +9658,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
}
sd->npc_item_flag = iflag;
- return 0;
+ return 1;
}
void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos)
@@ -9145,12 +9720,13 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos)
/*==========================================
* Called when attemting to unequip an item from player
- * type:
- * 0 - only unequip
- * 1 - calculate status after unequipping
- * 2 - force unequip
+ * type: @see enum pc_unequipitem_flag
+ * Return:
+ * 0 = fail
+ * 1 = success
*------------------------------------------*/
-int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
+int pc_unequipitem(struct map_session_data *sd,int n,int flag)
+{
int i,iflag;
bool status_cacl = false;
int pos;
@@ -9162,13 +9738,13 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
}
// if player is berserk then cannot unequip
- if (!(flag & 2) && sd->sc.count && (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_NO_SWITCH_EQUIP]) )
+ if (!(flag&PCUNEQUIPITEM_FORCE) && sd->sc.count && (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_NO_SWITCH_EQUIP]) )
{
clif->unequipitemack(sd,n,0,UIA_FAIL);
return 0;
}
- if( !(flag&2) && sd->sc.count && sd->sc.data[SC_KYOUGAKU] )
+ if( !(flag&PCUNEQUIPITEM_FORCE) && sd->sc.count && sd->sc.data[SC_KYOUGAKU] )
{
clif->unequipitemack(sd,n,0,UIA_FAIL);
return 0;
@@ -9229,7 +9805,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
}
}
- if(flag&1 || status_cacl) {
+ if(flag&PCUNEQUIPITEM_RECALC || status_cacl) {
pc->checkallowskill(sd);
status_calc_pc(sd,SCO_NONE);
}
@@ -9274,7 +9850,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
}
sd->npc_item_flag = iflag;
- return 0;
+ return 1;
}
/*==========================================
@@ -9300,7 +9876,7 @@ int pc_checkitem(struct map_session_data *sd)
if (!itemdb_available(id)) {
ShowWarning("Removed invalid/disabled item id %d from inventory (amount=%d, char_id=%d).\n", id, sd->status.inventory[i].amount, sd->status.char_id);
- pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER);
+ pc->delitem(sd, i, sd->status.inventory[i].amount, 0, DELITEM_NORMAL, LOG_TYPE_OTHER);
continue;
}
@@ -9374,28 +9950,28 @@ int pc_checkitem(struct map_session_data *sd)
continue;
if( sd->status.inventory[i].equip&~pc->equippoint(sd,i) ) {
- pc->unequipitem(sd, i, 2);
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_FORCE);
calc_flag = 1;
continue;
}
- if ( battle_config.unequip_restricted_equipment & 1 ) {
+ 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 );
+ 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, PCUNEQUIPITEM_FORCE);
calc_flag = 1;
}
}
}
- if ( battle_config.unequip_restricted_equipment & 2 ) {
- if ( !itemdb_isspecial( sd->status.inventory[i].card[0] ) ) {
+ 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 );
+ 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, PCUNEQUIPITEM_FORCE);
calc_flag = 1;
}
}
@@ -9531,9 +10107,9 @@ int pc_divorce(struct map_session_data *sd)
for( i = 0; i < MAX_INVENTORY; i++ )
{
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);
+ pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_OTHER);
if( p_sd->status.inventory[i].nameid == WEDDING_RING_M || p_sd->status.inventory[i].nameid == WEDDING_RING_F )
- pc->delitem(p_sd, i, 1, 0, 0, LOG_TYPE_OTHER);
+ pc->delitem(p_sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_OTHER);
}
clif->divorced(sd, p_sd->status.name);
@@ -10035,151 +10611,27 @@ void pc_read_skill_tree(void) {
#else
const char *config_filename = "db/pre-re/skill_tree.conf"; // FIXME hardcoded name
#endif
- int i = 0, jnamelen = 0;
+ int i = 0;
struct s_mapiterator *iter;
struct map_session_data *sd;
- struct {
- const char *name;
- int id;
- } jnames[] = {
- { "Novice", JOB_NOVICE },
- { "Swordsman", JOB_SWORDMAN },
- { "Magician", JOB_MAGE },
- { "Archer", JOB_ARCHER },
- { "Acolyte", JOB_ACOLYTE },
- { "Merchant", JOB_MERCHANT },
- { "Thief", JOB_THIEF },
- { "Knight", JOB_KNIGHT },
- { "Priest", JOB_PRIEST },
- { "Wizard", JOB_WIZARD },
- { "Blacksmith", JOB_BLACKSMITH },
- { "Hunter", JOB_HUNTER },
- { "Assassin", JOB_ASSASSIN },
- { "Crusader", JOB_CRUSADER },
- { "Monk", JOB_MONK },
- { "Sage", JOB_SAGE },
- { "Rogue", JOB_ROGUE },
- { "Alchemist", JOB_ALCHEMIST },
- { "Bard", JOB_BARD },
- { "Dancer", JOB_DANCER },
- { "Super_Novice", JOB_SUPER_NOVICE },
- { "Gunslinger", JOB_GUNSLINGER },
- { "Ninja", JOB_NINJA },
- { "Novice_High", JOB_NOVICE_HIGH },
- { "Swordsman_High", JOB_SWORDMAN_HIGH },
- { "Magician_High", JOB_MAGE_HIGH },
- { "Archer_High", JOB_ARCHER_HIGH },
- { "Acolyte_High", JOB_ACOLYTE_HIGH },
- { "Merchant_High", JOB_MERCHANT_HIGH },
- { "Thief_High", JOB_THIEF_HIGH },
- { "Lord_Knight", JOB_LORD_KNIGHT },
- { "High_Priest", JOB_HIGH_PRIEST },
- { "High_Wizard", JOB_HIGH_WIZARD },
- { "Whitesmith", JOB_WHITESMITH },
- { "Sniper", JOB_SNIPER },
- { "Assassin_Cross", JOB_ASSASSIN_CROSS },
- { "Paladin", JOB_PALADIN },
- { "Champion", JOB_CHAMPION },
- { "Professor", JOB_PROFESSOR },
- { "Stalker", JOB_STALKER },
- { "Creator", JOB_CREATOR },
- { "Clown", JOB_CLOWN },
- { "Gypsy", JOB_GYPSY },
- { "Baby_Novice", JOB_BABY },
- { "Baby_Swordsman", JOB_BABY_SWORDMAN },
- { "Baby_Magician", JOB_BABY_MAGE },
- { "Baby_Archer", JOB_BABY_ARCHER },
- { "Baby_Acolyte", JOB_BABY_ACOLYTE },
- { "Baby_Merchant", JOB_BABY_MERCHANT },
- { "Baby_Thief", JOB_BABY_THIEF },
- { "Baby_Knight", JOB_BABY_KNIGHT },
- { "Baby_Priest", JOB_BABY_PRIEST },
- { "Baby_Wizard", JOB_BABY_WIZARD },
- { "Baby_Blacksmith", JOB_BABY_BLACKSMITH },
- { "Baby_Hunter", JOB_BABY_HUNTER },
- { "Baby_Assassin", JOB_BABY_ASSASSIN },
- { "Baby_Crusader", JOB_BABY_CRUSADER },
- { "Baby_Monk", JOB_BABY_MONK },
- { "Baby_Sage", JOB_BABY_SAGE },
- { "Baby_Rogue", JOB_BABY_ROGUE },
- { "Baby_Alchemist", JOB_BABY_ALCHEMIST },
- { "Baby_Bard", JOB_BABY_BARD },
- { "Baby_Dancer", JOB_BABY_DANCER },
- { "Super_Baby", JOB_SUPER_BABY },
- { "Taekwon", JOB_TAEKWON },
- { "Star_Gladiator", JOB_STAR_GLADIATOR },
- { "Soul_Linker", JOB_SOUL_LINKER },
- { "Gangsi", JOB_GANGSI },
- { "Death_Knight", JOB_DEATH_KNIGHT },
- { "Dark_Collector", JOB_DARK_COLLECTOR },
- { "Rune_Knight", JOB_RUNE_KNIGHT },
- { "Warlock", JOB_WARLOCK },
- { "Ranger", JOB_RANGER },
- { "Arch_Bishop", JOB_ARCH_BISHOP },
- { "Mechanic", JOB_MECHANIC },
- { "Guillotine_Cross", JOB_GUILLOTINE_CROSS },
- { "Rune_Knight_Trans", JOB_RUNE_KNIGHT_T },
- { "Warlock_Trans", JOB_WARLOCK_T },
- { "Ranger_Trans", JOB_RANGER_T },
- { "Arch_Bishop_Trans", JOB_ARCH_BISHOP_T },
- { "Mechanic_Trans", JOB_MECHANIC_T },
- { "Guillotine_Cross_Trans", JOB_GUILLOTINE_CROSS_T },
- { "Royal_Guard", JOB_ROYAL_GUARD },
- { "Sorcerer", JOB_SORCERER },
- { "Minstrel", JOB_MINSTREL },
- { "Wanderer", JOB_WANDERER },
- { "Sura", JOB_SURA },
- { "Genetic", JOB_GENETIC },
- { "Shadow_Chaser", JOB_SHADOW_CHASER },
- { "Royal_Guard_Trans", JOB_ROYAL_GUARD_T },
- { "Sorcerer_Trans", JOB_SORCERER_T },
- { "Minstrel_Trans", JOB_MINSTREL_T },
- { "Wanderer_Trans", JOB_WANDERER_T },
- { "Sura_Trans", JOB_SURA_T },
- { "Genetic_Trans", JOB_GENETIC_T },
- { "Shadow_Chaser_Trans", JOB_SHADOW_CHASER_T },
- { "Baby_Rune_Knight", JOB_BABY_RUNE },
- { "Baby_Warlock", JOB_BABY_WARLOCK },
- { "Baby_Ranger", JOB_BABY_RANGER },
- { "Baby_Arch_Bishop", JOB_BABY_BISHOP },
- { "Baby_Mechanic", JOB_BABY_MECHANIC },
- { "Baby_Guillotine_Cross", JOB_BABY_CROSS },
- { "Baby_Royal_Guard", JOB_BABY_GUARD },
- { "Baby_Sorcerer", JOB_BABY_SORCERER },
- { "Baby_Minstrel", JOB_BABY_MINSTREL },
- { "Baby_Wanderer", JOB_BABY_WANDERER },
- { "Baby_Sura", JOB_BABY_SURA },
- { "Baby_Genetic", JOB_BABY_GENETIC },
- { "Baby_Shadow_Chaser", JOB_BABY_CHASER },
- { "Expanded_Super_Novice", JOB_SUPER_NOVICE_E },
- { "Expanded_Super_Baby", JOB_SUPER_BABY_E },
- { "Kagerou", JOB_KAGEROU },
- { "Oboro", JOB_OBORO },
- { "Rebellion", JOB_REBELLION },
- };
if (libconfig->read_file(&skill_tree_conf, config_filename)) {
ShowError("can't read %s\n", config_filename);
return;
}
-
- jnamelen = ARRAYLENGTH(jnames);
-
+
while ((skt = libconfig->setting_get_elem(skill_tree_conf.root,i++))) {
int k;
const char *name = config_setting_name(skt);
- ARR_FIND(0, jnamelen, k, strcmpi(jnames[k].name,name) == 0 );
-
- if( k == jnamelen ) {
- ShowWarning("pc_read_skill_tree: '%s' unknown job name!\n",name);
+ if ( (k = pc->check_job_name(name)) == -1 ) {
+ ShowWarning("pc_read_skill_tree: '%s' unknown job name!\n", name);
continue;
}
-
-
+
if( ( skills = libconfig->setting_get_member(skt,"skills") ) ) {
int c = 0;
- int idx = pc->class2idx(jnames[k].id);
+ int idx = pc->class2idx(k);
while ((sk = libconfig->setting_get_elem(skills,c++))) {
const char *sk_name = config_setting_name(sk);
@@ -10193,7 +10645,7 @@ void pc_read_skill_tree(void) {
ShowWarning("pc_read_skill_tree: Unable to load skill %d (%s) into '%s's tree. Maximum number of skills per class has been reached.\n", skill_id, sk_name, name);
continue;
} else if (pc->skill_tree[idx][skidx].id) {
- ShowNotice("pc_read_skill_tree: Overwriting %d for '%s' (%d)\n", skill_id, name, jnames[k].id);
+ ShowNotice("pc_read_skill_tree: Overwriting %d for '%s' (%d)\n", skill_id, name, k);
}
pc->skill_tree[idx][skidx].id = skill_id;
@@ -10237,46 +10689,42 @@ void pc_read_skill_tree(void) {
while( (skt = libconfig->setting_get_elem(skill_tree_conf.root,i++)) ) {
int k, idx;
const char *name = config_setting_name(skt);
-
- ARR_FIND(0, jnamelen, k, strcmpi(jnames[k].name,name) == 0 );
-
- if( k == jnamelen ) {
- ShowWarning("pc_read_skill_tree: '%s' unknown job name!\n",name);
+ if ( (k = pc->check_job_name(name)) == -1 ) {
+ ShowWarning("pc_read_skill_tree: '%s' unknown job name!\n", name);
continue;
}
- idx = pc->class2idx(jnames[k].id);
+
+ idx = pc->class2idx(k);
if( ( inherit = libconfig->setting_get_member(skt,"inherit") ) ) {
const char *iname;
int v = 0;
- while ((iname = libconfig->setting_get_string_elem(inherit, v++))) {
+ while ( (iname = libconfig->setting_get_string_elem(inherit, v++)) ) {
int b = 0, a, d, f, fidx;
- ARR_FIND(0, jnamelen, b, strcmpi(jnames[b].name,iname) == 0 );
-
- if( b == jnamelen ) {
- ShowWarning("pc_read_skill_tree: '%s' trying to inherit unknown '%s'!\n",name,iname);
+ if ( (b = pc->check_job_name(iname)) == -1 ) {
+ ShowWarning("pc_read_skill_tree: '%s' trying to inherit unknown '%s'!\n", name, iname);
continue;
}
-
- fidx = pc->class2idx(jnames[b].id);
-
- ARR_FIND( 0, MAX_SKILL_TREE, d, pc->skill_tree[fidx][d].id == 0 );
- for( f = 0; f < d; f++ ) {
-
- ARR_FIND( 0, MAX_SKILL_TREE, a, pc->skill_tree[idx][a].id == 0 || pc->skill_tree[idx][a].id == pc->skill_tree[fidx][f].id );
+ fidx = pc->class2idx(b);
+
+ ARR_FIND(0, MAX_SKILL_TREE, d, pc->skill_tree[fidx][d].id == 0);
+
+ for ( f = 0; f < d; f++ ) {
+
+ ARR_FIND(0, MAX_SKILL_TREE, a, pc->skill_tree[idx][a].id == 0 || pc->skill_tree[idx][a].id == pc->skill_tree[fidx][f].id);
- if( a == MAX_SKILL_TREE ) {
- ShowWarning("pc_read_skill_tree: '%s' can't inherit '%s', skill tree is full!\n", name,iname);
+ if ( a == MAX_SKILL_TREE ) {
+ ShowWarning("pc_read_skill_tree: '%s' can't inherit '%s', skill tree is full!\n", name, iname);
break;
- } else if ( pc->skill_tree[idx][a].id || ( pc->skill_tree[idx][a].id == NV_TRICKDEAD && ((pc->jobid2mapid(jnames[k].id)&(MAPID_BASEMASK|JOBL_2))!=MAPID_NOVICE) ) ) /* we skip trickdead for non-novices */
+ } else if ( pc->skill_tree[idx][a].id || (pc->skill_tree[idx][a].id == NV_TRICKDEAD && ((pc->jobid2mapid(k)&(MAPID_BASEMASK | JOBL_2)) != MAPID_NOVICE)) ) /* we skip trickdead for non-novices */
continue;/* skip */
memcpy(&pc->skill_tree[idx][a], &pc->skill_tree[fidx][f], sizeof(pc->skill_tree[fidx][f]));
pc->skill_tree[idx][a].inherited = 1;
}
-
+
}
}
@@ -10427,8 +10875,8 @@ int pc_readdb(void) {
// Reset then read attr_fix
for(i=0;i<4;i++)
- for(j=0;j<ELE_MAX;j++)
- for(k=0;k<ELE_MAX;k++)
+ for ( j = ELE_NEUTRAL; j<ELE_MAX; j++ )
+ for ( k = ELE_NEUTRAL; k<ELE_MAX; k++ )
battle->attr_fix_table[i][j][k]=100;
sprintf(line, "%s/"DBPATH"attr_fix.txt", map->db_path);
@@ -10455,13 +10903,13 @@ int pc_readdb(void) {
lv=atoi(split[0]);
n=atoi(split[1]);
count++;
- for(i=0;i<n && i<ELE_MAX;){
+ for ( i = ELE_NEUTRAL; i<n && i<ELE_MAX; ) {
if( !fgets(line, sizeof(line), fp) )
break;
if(line[0]=='/' && line[1]=='/')
continue;
- for(j=0,p=line;j<n && j<ELE_MAX && p;j++){
+ for ( j = ELE_NEUTRAL, p = line; j<n && j<ELE_MAX && p; j++ ) {
while(*p==32 && *p>0)
p++;
battle->attr_fix_table[lv-1][i][j]=atoi(p);
@@ -10589,15 +11037,15 @@ void pc_bank_deposit(struct map_session_data *sd, int money) {
void pc_bank_withdraw(struct map_session_data *sd, int money) {
unsigned int limit_check = money+sd->status.zeny;
- if( money <= 0 ) {
+ if (money <= 0) {
clif->bank_withdraw(sd,BWA_UNKNOWN_ERROR);
return;
- } else if ( money > sd->status.bank_vault ) {
+ } else if (money > sd->status.bank_vault) {
clif->bank_withdraw(sd,BWA_NO_MONEY);
return;
- } else if ( limit_check > MAX_ZENY ) {
+ } else if (limit_check > MAX_ZENY) {
/* no official response for this scenario exists. */
- clif->colormes(sd->fd,COLOR_RED,msg_sd(sd,1482));
+ clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1482));
return;
}
@@ -10997,16 +11445,10 @@ void pc_defaults(void) {
/* */
pc->day_timer_tid = INVALID_TIMER;
pc->night_timer_tid = INVALID_TIMER;
- /* respecting order */
- memset(pc->exp_table, 0, sizeof(pc->exp_table)
- + sizeof(pc->max_level)
- + sizeof(pc->statp)
- + sizeof(pc->level_penalty)
- + sizeof(pc->skill_tree)
- + sizeof(pc->smith_fame_list)
- + sizeof(pc->chemist_fame_list)
- + sizeof(pc->taekwon_fame_list)
- );
+
+ // These macros are used instead of a sum of sizeof(), to ensure that padding won't interfere with our size, and code won't rot when adding more fields
+ memset(ZEROED_BLOCK_POS(pc), 0, ZEROED_BLOCK_SIZE(pc));
+
/* */
memcpy(pc->equip_pos, &equip_pos, sizeof(pc->equip_pos));
/* */
@@ -11096,7 +11538,9 @@ void pc_defaults(void) {
pc->skill = pc_skill;
pc->insert_card = pc_insert_card;
-
+ pc->can_insert_card = pc_can_insert_card;
+ pc->can_insert_card_into = pc_can_insert_card_into;
+
pc->steal_item = pc_steal_item;
pc->steal_coin = pc_steal_coin;
@@ -11203,6 +11647,7 @@ void pc_defaults(void) {
pc->addfame = pc_addfame;
pc->famerank = pc_famerank;
pc->set_hate_mob = pc_set_hate_mob;
+ pc->getmaxspiritball = pc_getmaxspiritball;
pc->readdb = pc_readdb;
pc->map_day_timer = map_day_timer; // by [yor]
@@ -11281,4 +11726,6 @@ void pc_defaults(void) {
pc->autotrade_start = pc_autotrade_start;
pc->autotrade_prepare = pc_autotrade_prepare;
pc->autotrade_populate = pc_autotrade_populate;
+
+ pc->check_job_name = pc_check_job_name;
}
diff --git a/src/map/pc.h b/src/map/pc.h
index 56380447e..f546d4910 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -5,23 +5,23 @@
#ifndef MAP_PC_H
#define MAP_PC_H
-#include "../config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT
-
-#include "battle.h" // battle
-#include "battleground.h" // enum bg_queue_types
-#include "buyingstore.h" // struct s_buyingstore
-#include "itemdb.h" // MAX_ITEMDELAYS
-#include "log.h" // struct e_log_pick_type
-#include "map.h" // RC_MAX, ELE_MAX
-#include "pc_groups.h" // GroupSettings
-#include "script.h" // struct reg_db
-#include "searchstore.h" // struct s_search_store_info
-#include "status.h" // enum sc_type, OPTION_*
-#include "unit.h" // struct unit_data, struct view_data
-#include "vending.h" // struct s_vending
-#include "../common/cbasetypes.h"
-#include "../common/ers.h" // struct eri
-#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus, NEW_CARTS
+#include "config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT
+
+#include "map/battle.h" // battle
+#include "map/battleground.h" // enum bg_queue_types
+#include "map/buyingstore.h" // struct s_buyingstore
+#include "map/itemdb.h" // MAX_ITEMDELAYS
+#include "map/log.h" // struct e_log_pick_type
+#include "map/map.h" // RC_MAX, ELE_MAX
+#include "map/pc_groups.h" // GroupSettings
+#include "map/script.h" // struct reg_db
+#include "map/searchstore.h" // struct s_search_store_info
+#include "map/status.h" // enum sc_type, OPTION_*
+#include "map/unit.h" // struct unit_data, struct view_data
+#include "map/vending.h" // struct s_vending
+#include "common/cbasetypes.h"
+#include "common/ers.h" // struct eri
+#include "common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus, NEW_CARTS
/**
* Defines
@@ -29,7 +29,8 @@
#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 MAX_PC_DEVOTION 5 ///< Max amount of devotion targets
+#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)
@@ -57,11 +58,23 @@ enum equip_index {
EQI_SHADOW_ACC_L,
EQI_MAX
};
+
+enum pc_unequipitem_flag {
+ PCUNEQUIPITEM_NONE = 0x0, ///< Just unequip
+ PCUNEQUIPITEM_RECALC = 0x1, ///< Recalculate status after unequipping
+ PCUNEQUIPITEM_FORCE = 0x2, ///< Force unequip
+};
+
+enum pc_resetskill_flag {
+ PCRESETSKILL_NONE = 0x0,
+ PCRESETSKILL_RESYNC = 0x1, // perform block resync and status_calc call
+ PCRESETSKILL_RECOUNT = 0x2, // just count total amount of skill points used by player, do not really reset
+ PCRESETSKILL_CHSEX = 0x4, // just reset the skills if the player class is a bard/dancer type (for changesex.)
+};
+
struct weapon_data {
int atkmods[3];
- // all the variables except atkmods get zero'ed in each call of status_calc_pc
- // NOTE: if you want to add a non-zeroed variable, you need to update the memset call
- // in status_calc_pc as well! All the following are automatically zero'ed. [Skotlex]
+BEGIN_ZEROED_BLOCK; // all the variables within this block get zero'ed in each call of status_calc_pc
int overrefine;
int star;
int ignore_def_ele;
@@ -85,15 +98,20 @@ struct weapon_data {
short flag, rate;
unsigned char ele;
} addele2[MAX_PC_BONUS];
+END_ZEROED_BLOCK;
};
struct s_autospell {
short id, lv, rate, card_id, flag;
bool lock; // bAutoSpellOnSkill: blocks autospell from triggering again, while being executed
};
+/// AddEff bonus data
struct s_addeffect {
- enum sc_type id;
- short rate, arrow_rate;
- unsigned char flag;
+ enum sc_type id; ///< Effect ID
+ int16 rate; ///< Base success rate
+ int16 arrow_rate; ///< Success rate modifier for ranged attacks (adds to the base rate)
+ uint8 flag; ///< Trigger flag (@see enum auto_trigger_flag)
+ uint16 duration; ///< Optional, non-reducible duration in ms. If 0, the default, reducible effect's duration is used.
+ // TODO[Haru]: Duration is only used in addeff (set through bonus4 bAddEff). The other addeffect types could also use it.
};
struct s_addeffectonskill {
enum sc_type id;
@@ -141,7 +159,7 @@ struct map_session_data {
unsigned int arrow_atk : 1;
unsigned int gangsterparadise : 1;
unsigned int rest : 1;
- unsigned int storage_flag : 2; //0: closed, 1: Normal Storage open, 2: guild storage open [Skotlex]
+ unsigned int storage_flag : 2; // @see enum storage_flag
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]
@@ -188,6 +206,7 @@ struct map_session_data {
unsigned int itemcheck : 1;
unsigned int standalone : 1;/* [Ind/Hercules <3] */
unsigned int loggingout : 1;
+ unsigned int warp_clean : 1;
} state;
struct {
unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
@@ -260,7 +279,8 @@ struct map_session_data {
short weapontype1,weapontype2;
short disguise; // [Valaris]
struct weapon_data right_weapon, left_weapon;
- // here start arrays to be globally zeroed at the beginning of status_calc_pc()
+
+BEGIN_ZEROED_BLOCK; // this block will be globally zeroed at the beginning of status_calc_pc()
int param_bonus[6],param_equip[6]; //Stores card/equipment bonuses.
int subele[ELE_MAX];
int subrace[RC_MAX];
@@ -285,8 +305,9 @@ struct map_session_data {
short sp_gain_race[RC_MAX];
short sp_gain_race_attack[RC_MAX];
short hp_gain_race_attack[RC_MAX];
- // zeroed arrays end here.
- // zeroed structures start here
+#ifdef RENEWAL
+ int race_tolerance[RC_MAX];
+#endif
struct s_autospell autospell[15], autospell2[15], autospell3[15];
struct s_addeffect addeff[MAX_PC_BONUS], addeff2[MAX_PC_BONUS];
struct s_addeffectonskill addeff3[MAX_PC_BONUS];
@@ -315,11 +336,6 @@ struct map_session_data {
short value;
int rate, tick;
} def_set_race[RC_MAX], mdef_set_race[RC_MAX];
- // zeroed structures end here
- // manually zeroed structures start here.
- struct s_autobonus autobonus[MAX_PC_BONUS], autobonus2[MAX_PC_BONUS], autobonus3[MAX_PC_BONUS]; //Auto script on attack, when attacked, on skill usage
- // manually zeroed structures end here.
- // zeroed vars start here.
struct {
int atk_rate;
int arrow_atk,arrow_ele,arrow_cri,arrow_hit;
@@ -356,7 +372,11 @@ struct map_session_data {
int add_fixcast,add_varcast;
int ematk; // matk bonus from equipment
} bonus;
- // zeroed vars end here.
+END_ZEROED_BLOCK;
+
+ // The following structures are zeroed manually in status_calc_pc_
+ struct s_autobonus autobonus[MAX_PC_BONUS], autobonus2[MAX_PC_BONUS], autobonus3[MAX_PC_BONUS]; //Auto script on attack, when attacked, on skill usage
+
int castrate,delayrate,hprate,sprate,dsprate;
int hprecov_rate,sprecov_rate;
int matk_rate;
@@ -373,7 +393,7 @@ struct map_session_data {
unsigned char mission_count; //Stores the bounty kill count for TK_MISSION
short mission_mobid; //Stores the target mob_id for TK_MISSION
int die_counter; //Total number of times you've died
- int devotion[5]; //Stores the account IDs of chars devoted to.
+ int devotion[MAX_PC_DEVOTION]; //Stores the account IDs of chars devoted to.
int trade_partner;
struct {
struct {
@@ -405,11 +425,11 @@ struct map_session_data {
struct mercenary_data *md;
struct elemental_data *ed;
- struct{
+ struct {
int m; //-1 - none, other: map index corresponding to map name.
unsigned short index; //map index
- } feel_map[3];// 0 - Sun; 1 - Moon; 2 - Stars
- short hate_mob[3];
+ } feel_map[MAX_PC_FEELHATE];// 0 - Sun; 1 - Moon; 2 - Stars
+ short hate_mob[MAX_PC_FEELHATE];
int pvp_timer;
short pvp_point;
@@ -723,6 +743,16 @@ enum e_pc_autotrade_update_action {
};
/**
+ * Flag values for pc->skill
+ */
+enum pc_skill_flag {
+ SKILL_GRANT_PERMANENT = 0, // Grant permanent skill to be bound to skill tree
+ SKILL_GRANT_TEMPORARY = 1, // Grant an item skill (temporary)
+ SKILL_GRANT_TEMPSTACK = 2, // Like 1, except the level granted can stack with previously learned level.
+ SKILL_GRANT_UNCONDITIONAL = 3, // Grant skill unconditionally and forever (persistent to job changes and skill resets)
+};
+
+/**
* Used to temporarily remember vending data
**/
struct autotrade_vending {
@@ -746,17 +776,20 @@ struct pc_interface {
int day_timer_tid;
int night_timer_tid;
/* */
+
+BEGIN_ZEROED_BLOCK; /* Everything within this block will be memset to 0 when status_defaults() is executed */
unsigned int exp_table[CLASS_COUNT][2][MAX_LEVEL];
unsigned int max_level[CLASS_COUNT][2];
unsigned int statp[MAX_LEVEL+1];
unsigned int level_penalty[3][RC_MAX][MAX_LEVEL*2+1];
-
- unsigned int equip_pos[EQI_MAX];
/* */
struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE];
struct fame_list smith_fame_list[MAX_FAME_LIST];
struct fame_list chemist_fame_list[MAX_FAME_LIST];
struct fame_list taekwon_fame_list[MAX_FAME_LIST];
+END_ZEROED_BLOCK; /* End */
+
+ unsigned int equip_pos[EQI_MAX];
struct sg_data sg_info[MAX_PC_FEELHATE];
/* */
struct eri *sc_display_ers;
@@ -848,6 +881,8 @@ struct pc_interface {
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);
+ bool (*can_insert_card) (struct map_session_data* sd, int idx_card);
+ bool (*can_insert_card_into) (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);
@@ -950,6 +985,7 @@ struct pc_interface {
int (*addspiritball) (struct map_session_data *sd,int interval,int max);
int (*delspiritball) (struct map_session_data *sd,int count,int type);
+ int (*getmaxspiritball) (struct map_session_data *sd, int min);
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);
@@ -987,7 +1023,7 @@ struct pc_interface {
void (*check_skilltree) (struct map_session_data *sd, int skill_id);
int (*bonus_autospell) (struct s_autospell *spell, int max, short id, short lv, short rate, short flag, short card_id);
int (*bonus_autospell_onskill) (struct s_autospell *spell, int max, short src_skill, short id, short lv, short rate, short card_id);
- int (*bonus_addeff) (struct s_addeffect* effect, int max, enum sc_type id, short rate, short arrow_rate, unsigned char flag);
+ int (*bonus_addeff) (struct s_addeffect* effect, int max, enum sc_type id, int16 rate, int16 arrow_rate, uint8 flag, uint16 duration);
int (*bonus_addeff_onskill) (struct s_addeffectonskill* effect, int max, enum sc_type id, short rate, short skill_id, unsigned char target);
int (*bonus_item_drop) (struct s_add_drop *drop, const short max, short id, short group, int race, int rate);
void (*calcexp) (struct map_session_data *sd, unsigned int *base_exp, unsigned int *job_exp, struct block_list *src);
@@ -1032,6 +1068,8 @@ struct pc_interface {
void (*autotrade_start) (struct map_session_data *sd);
void (*autotrade_prepare) (struct map_session_data *sd);
void (*autotrade_populate) (struct map_session_data *sd);
+
+ int (*check_job_name) (const char *name);
};
struct pc_interface *pc;
diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
index 9cd478b3f..f9a442d97 100644
--- a/src/map/pc_groups.c
+++ b/src/map/pc_groups.c
@@ -6,17 +6,17 @@
#include "pc_groups.h"
-#include "atcommand.h" // atcommand->exists(), atcommand->load_groups()
-#include "clif.h" // clif->GM_kick()
-#include "map.h" // mapiterator
-#include "pc.h" // pc->set_group()
-#include "../common/cbasetypes.h"
-#include "../common/conf.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h" // strcmp
+#include "map/atcommand.h" // atcommand-"exists(), atcommand-"load_groups()
+#include "map/clif.h" // clif-"GM_kick()
+#include "map/map.h" // mapiterator
+#include "map/pc.h" // pc-"set_group()
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/strlib.h" // strcmp
static GroupSettings dummy_group; ///< dummy group used in dummy map sessions @see pc_get_dummy_sd()
diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h
index 8dd95a177..4fee312a4 100644
--- a/src/map/pc_groups.h
+++ b/src/map/pc_groups.h
@@ -5,9 +5,9 @@
#ifndef MAP_PC_GROUPS_H
#define MAP_PC_GROUPS_H
-#include "../common/cbasetypes.h"
-#include "../common/conf.h"
-#include "../common/db.h"
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/db.h"
/// PC permissions
enum e_pc_permission {
diff --git a/src/map/pet.c b/src/map/pet.c
index b37d3c350..2379ec984 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -6,36 +6,36 @@
#include "pet.h"
+#include "map/atcommand.h" // msg_txt()
+#include "map/battle.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/map.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/path.h"
+#include "map/pc.h"
+#include "map/script.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "map/unit.h"
+#include "common/db.h"
+#include "common/ers.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "atcommand.h" // msg_txt()
-#include "battle.h"
-#include "chrif.h"
-#include "clif.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "map.h"
-#include "mob.h"
-#include "npc.h"
-#include "path.h"
-#include "pc.h"
-#include "script.h"
-#include "skill.h"
-#include "status.h"
-#include "unit.h"
-#include "../common/db.h"
-#include "../common/ers.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct pet_interface pet_s;
#define MIN_PETTHINKTIME 100
@@ -91,7 +91,7 @@ int pet_unlocktarget(struct pet_data *pd)
pd->target_id=0;
pet_stop_attack(pd);
- pet_stop_walking(pd,1);
+ pet_stop_walking(pd, STOPWALKING_FLAG_FIXPOS);
return 0;
}
@@ -132,7 +132,7 @@ int pet_target_check(struct map_session_data *sd,struct block_list *bl,int type)
pd = sd->pd;
- Assert((pd->msd == 0) || (pd->msd->pd == pd));
+ Assert_ret(pd->msd == 0 || pd->msd->pd == pd);
if( bl == NULL || bl->type != BL_MOB || bl->prev == NULL
|| pd->pet.intimate < battle_config.pet_support_min_friendly
@@ -280,7 +280,7 @@ int pet_performance(struct map_session_data *sd, struct pet_data *pd)
else
val = 1;
- pet_stop_walking(pd,2000<<8);
+ pet_stop_walking(pd,STOPWALKING_FLAG_NONE | (2000<<8)); // Stop walking for 2000ms
clif->send_petdata(NULL, pd, 4, rnd()%val + 1);
pet->lootitem_drop(pd,NULL);
return 1;
@@ -318,8 +318,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo)
int i=0,interval=0;
nullpo_retr(1, sd);
-
- Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd);
+ Assert_retr(1, sd->status.pet_id == 0 || sd->pd == 0 || sd->pd->msd == sd);
if(sd->status.account_id != petinfo->account_id || sd->status.char_id != petinfo->char_id) {
sd->status.pet_id = 0;
@@ -389,8 +388,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo)
int pet_birth_process(struct map_session_data *sd, struct s_pet *petinfo)
{
nullpo_retr(1, sd);
-
- Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd);
+ Assert_retr(1, sd->status.pet_id == 0 || sd->pd == 0 || sd->pd->msd == sd);
if(sd->status.pet_id && petinfo->incubate == 1) {
sd->status.pet_id = 0;
@@ -418,7 +416,7 @@ int pet_birth_process(struct map_session_data *sd, struct s_pet *petinfo)
clif->send_petdata(NULL, sd->pd, 3, sd->pd->vd.head_bottom);
clif->send_petstatus(sd);
}
- Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd);
+ Assert_retr(1, sd->status.pet_id == 0 || sd->pd == 0 || sd->pd->msd == sd);
return 0;
}
@@ -447,7 +445,7 @@ int pet_recv_petdata(int account_id,struct s_pet *p,int flag) {
return 1;
}
if (!pet->birth_process(sd,p)) //Pet hatched. Delete egg.
- pc->delitem(sd,i,1,0,0,LOG_TYPE_OTHER);
+ pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_OTHER);
} else {
pet->data_init(sd,p);
if(sd->pd && sd->bl.prev != NULL) {
@@ -680,7 +678,7 @@ int pet_equipitem(struct map_session_data *sd,int index) {
return 1;
}
- pc->delitem(sd,index,1,0,0,LOG_TYPE_OTHER);
+ pc->delitem(sd, index, 1, 0, DELITEM_NORMAL, LOG_TYPE_OTHER);
pd->pet.equip = nameid;
status->set_viewdata(&pd->bl, pd->pet.class_); //Updates view_data.
clif->send_petdata(NULL, sd->pd, 3, sd->pd->vd.head_bottom);
@@ -745,7 +743,7 @@ int pet_food(struct map_session_data *sd, struct pet_data *pd) {
clif->pet_food(sd, food_id, 0);
return 1;
}
- pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);
+ pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME);
if (pd->pet.hungry > 90) {
pet->set_intimate(pd, pd->pet.intimate - pd->petDB->r_full);
@@ -781,10 +779,10 @@ int pet_food(struct map_session_data *sd, struct pet_data *pd) {
return 0;
}
-int pet_randomwalk(struct pet_data *pd, int64 tick) {
+int pet_randomwalk(struct pet_data *pd, int64 tick)
+{
nullpo_ret(pd);
-
- Assert((pd->msd == 0) || (pd->msd->pd == pd));
+ Assert_ret(pd->msd == 0 || pd->msd->pd == pd);
if (DIFF_TICK(pd->next_walktime,tick) < 0 && unit->can_move(&pd->bl)) {
const int retrycount=20;
@@ -1146,7 +1144,7 @@ int pet_skill_support_timer(int tid, int64 tick, int id, intptr_t data) {
}
pet_stop_attack(pd);
- pet_stop_walking(pd,1);
+ pet_stop_walking(pd, STOPWALKING_FLAG_FIXPOS);
pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000,pet->skill_support_timer,sd->bl.id,0);
if (skill->get_inf(pd->s_skill->id) & INF_GROUND_SKILL)
unit->skilluse_pos(&pd->bl, sd->bl.x, sd->bl.y, pd->s_skill->id, pd->s_skill->lv);
diff --git a/src/map/pet.h b/src/map/pet.h
index 0b51bcb16..06302c9b2 100644
--- a/src/map/pet.h
+++ b/src/map/pet.h
@@ -5,11 +5,11 @@
#ifndef MAP_PET_H
#define MAP_PET_H
-#include "map.h" // struct block_list
-#include "status.h" // enum sc_type
-#include "unit.h" // struct unit_data
-#include "../common/cbasetypes.h"
-#include "../common/mmo.h" // NAME_LENGTH, struct s_pet
+#include "map/map.h" // struct block_list
+#include "map/status.h" // enum sc_type
+#include "map/unit.h" // struct unit_data
+#include "common/cbasetypes.h"
+#include "common/mmo.h" // NAME_LENGTH, struct s_pet
#define MAX_PET_DB 300
#define MAX_PETLOOT_SIZE 30
diff --git a/src/map/quest.c b/src/map/quest.c
index 93ec1b04c..463a3395a 100644
--- a/src/map/quest.c
+++ b/src/map/quest.c
@@ -6,37 +6,38 @@
#include "quest.h"
+#include "map/battle.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/map.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/party.h"
+#include "map/pc.h"
+#include "map/script.h"
+#include "map/unit.h"
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include "battle.h"
-#include "chrif.h"
-#include "clif.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "map.h"
-#include "mob.h"
-#include "npc.h"
-#include "party.h"
-#include "pc.h"
-#include "script.h"
-#include "unit.h"
-#include "../common/cbasetypes.h"
-#include "../common/conf.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct quest_interface quest_s;
+struct quest_db *db_data[MAX_QUEST_DB]; ///< Quest database
/**
* Searches a quest by ID.
@@ -618,6 +619,7 @@ void do_reload_quest(void) {
*/
void quest_defaults(void) {
quest = &quest_s;
+ quest->db_data = db_data;
memset(&quest->db, 0, sizeof(quest->db));
memset(&quest->dummy, 0, sizeof(quest->dummy));
diff --git a/src/map/quest.h b/src/map/quest.h
index 36ac69a53..9b5199625 100644
--- a/src/map/quest.h
+++ b/src/map/quest.h
@@ -5,9 +5,9 @@
#ifndef MAP_QUEST_H
#define MAP_QUEST_H
-#include "map.h" // TBL_PC
-#include "../common/cbasetypes.h"
-#include "../common/conf.h"
+#include "map/map.h" // TBL_PC
+#include "common/cbasetypes.h"
+#include "common/conf.h"
#define MAX_QUEST_DB (60355+1) // Highest quest ID + 1
@@ -40,7 +40,7 @@ enum quest_check_type {
};
struct quest_interface {
- struct quest_db *db_data[MAX_QUEST_DB]; ///< Quest database
+ struct quest_db **db_data; ///< Quest database
struct quest_db dummy; ///< Dummy entry for invalid quest lookups
/* */
void (*init) (bool minimal);
diff --git a/src/map/script.c b/src/map/script.c
index d5cf58946..e7a0175c7 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -4,60 +4,59 @@
#define HERCULES_CORE
-#include "../config/core.h" // RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL
+#include "config/core.h" // RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL
#include "script.h"
+#include "map/atcommand.h"
+#include "map/battle.h"
+#include "map/battleground.h"
+#include "map/channel.h"
+#include "map/chat.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/elemental.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/instance.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/mail.h"
+#include "map/map.h"
+#include "map/mapreg.h"
+#include "map/mercenary.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/party.h"
+#include "map/path.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/pet.h"
+#include "map/quest.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "map/status.h"
+#include "map/storage.h"
+#include "map/unit.h"
+#include "common/cbasetypes.h"
+#include "common/malloc.h"
+#include "common/md5calc.h"
+#include "common/mmo.h" // NEW_CARTS
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h" // usage: getcharip
+#include "common/strlib.h"
+#include "common/sysinfo.h"
+#include "common/timer.h"
+#include "common/utils.h"
+#include "common/HPM.h"
+
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
-#include "atcommand.h"
-#include "battle.h"
-#include "battleground.h"
-#include "channel.h"
-#include "chat.h"
-#include "chrif.h"
-#include "clif.h"
-#include "elemental.h"
-#include "guild.h"
-#include "homunculus.h"
-#include "instance.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "mail.h"
-#include "map.h"
-#include "mapreg.h"
-#include "mercenary.h"
-#include "mob.h"
-#include "npc.h"
-#include "party.h"
-#include "path.h"
-#include "pc.h"
-#include "pet.h"
-#include "pet.h"
-#include "quest.h"
-#include "skill.h"
-#include "status.h"
-#include "status.h"
-#include "storage.h"
-#include "unit.h"
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h"
-#include "../common/md5calc.h"
-#include "../common/mmo.h" // NEW_CARTS
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h" // usage: getcharip
-#include "../common/strlib.h"
-#include "../common/sysinfo.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-#include "../common/HPM.h"
-
#ifndef WIN32
#include <sys/time.h>
#endif
@@ -406,7 +405,7 @@ unsigned int calc_hash_ci(const char* p) {
/// Looks up string using the provided id.
const char* script_get_str(int id)
{
- Assert( id >= LABEL_START && id < script->str_size );
+ Assert_retr(NULL, id >= LABEL_START && id < script->str_size);
return script->str_buf+script->str_data[id].str;
}
@@ -462,7 +461,7 @@ const char *script_casecheck_add_str_sub(struct casecheck_data *ccd, const char
int i;
for (i = ccd->str_hash[h]; ; i = ccd->str_data[i].next) {
const char *s = NULL;
- Assert( i >= 0 && i < ccd->str_size );
+ Assert_retb(i >= 0 && i < ccd->str_size);
s = ccd->str_buf+ccd->str_data[i].str;
if (strcasecmp(s,p) == 0) {
return s; // string already in list
@@ -1295,7 +1294,8 @@ const char* parse_simpleexpr(const char *p)
const char *line_start = start_point;
const char *line_end = start_point;
struct script_string_buf *lbuf = &script->lang_export_line_buf;
- size_t line_length;
+ struct script_string_buf *ubuf = &script->lang_export_unescaped_buf;
+ size_t line_length, cursor;
while( line_start > script->parser_current_src ) {
if( *line_start != '\n' )
@@ -1319,6 +1319,13 @@ const char* parse_simpleexpr(const char *p)
normalize_name(lbuf->ptr, "\r\n\t ");
}
+ for(cursor = 0; cursor < sbuf->pos; cursor++) {
+ if( sbuf->ptr[cursor] == '"' )
+ script_string_buf_addb(ubuf, '\\');
+ script_string_buf_addb(ubuf, sbuf->ptr[cursor]);
+ }
+ script_string_buf_addb(ubuf, 0);
+
fprintf(script->lang_export_fp, "#: %s\n"
"# %s\n"
"msgctxt \"%s\"\n"
@@ -1327,10 +1334,11 @@ const char* parse_simpleexpr(const char *p)
script->parser_current_file ? script->parser_current_file : "Unknown File",
lbuf->ptr,
script->parser_current_npc_name ? script->parser_current_npc_name : "Unknown NPC",
- sbuf->ptr
+ ubuf->ptr
);
lbuf->pos = 0;
+ ubuf->pos = 0;
}
sbuf->pos = 0;
@@ -2427,9 +2435,11 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
script->syntax.translation_db = strdb_get(script->translation_db, script->parser_current_npc_name);
}
- script->buf=(unsigned char *)aMalloc(SCRIPT_BLOCK_SIZE*sizeof(unsigned char));
+ if( !script->buf ) {
+ script->buf = (unsigned char *)aMalloc(SCRIPT_BLOCK_SIZE*sizeof(unsigned char));
+ script->size = SCRIPT_BLOCK_SIZE;
+ }
script->pos=0;
- script->size=SCRIPT_BLOCK_SIZE;
script->parse_nextline(true, NULL);
// who called parse_script is responsible for clearing the database after using it, but just in case... lets clear it here
@@ -2443,10 +2453,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
if( script->error_report )
script->error(src,file,line,script->error_msg,script->error_pos);
aFree( script->error_msg );
- aFree( script->buf );
script->pos = 0;
- script->size = 0;
- script->buf = NULL;
for(i=LABEL_START;i<script->str_num;i++)
if(script->str_data[i].type == C_NOP) script->str_data[i].type = C_NAME;
for(i=0; i<size; i++)
@@ -2468,10 +2475,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
{// does not require brackets around the script
if( *p == '\0' && !(options&SCRIPT_RETURN_EMPTY_SCRIPT) )
{// empty script and can return NULL
- aFree( script->buf );
script->pos = 0;
- script->size = 0;
- script->buf = NULL;
#ifdef ENABLE_CASE_CHECK
script->local_casecheck.clear();
script->parser_current_src = NULL;
@@ -2491,10 +2495,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
p = script->skip_space(p+1);
if( *p == '}' && !(options&SCRIPT_RETURN_EMPTY_SCRIPT) )
{// empty script and can return NULL
- aFree( script->buf );
script->pos = 0;
- script->size = 0;
- script->buf = NULL;
#ifdef ENABLE_CASE_CHECK
script->local_casecheck.clear();
script->parser_current_src = NULL;
@@ -2543,10 +2544,6 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
script->addc(C_NOP);
- // trim code to size
- script->size = script->pos;
- RECREATE(script->buf,unsigned char,script->pos);
-
// default unknown references to variables
for (i = LABEL_START; i < script->str_num; i++) {
if (script->str_data[i].type == C_NOP) {
@@ -2611,8 +2608,9 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
#endif
CREATE(code,struct script_code,1);
- code->script_buf = script->buf;
- code->script_size = script->size;
+ code->script_buf = (unsigned char *)aMalloc(script->pos*sizeof(unsigned char));
+ memcpy(code->script_buf, script->buf, script->pos);
+ code->script_size = script->pos;
code->local.vars = NULL;
code->local.arrays = NULL;
#ifdef ENABLE_CASE_CHECK
@@ -3397,15 +3395,13 @@ void script_free_code(struct script_code* code)
{
nullpo_retv(code);
- if( code->instances )
+ if (code->instances)
script->stop_instances(code);
- else {
- script->free_vars(code->local.vars);
- if( code->local.arrays )
- code->local.arrays->destroy(code->local.arrays,script->array_free_db);
- }
- aFree( code->script_buf );
- aFree( code );
+ script->free_vars(code->local.vars);
+ if (code->local.arrays)
+ code->local.arrays->destroy(code->local.arrays,script->array_free_db);
+ aFree(code->script_buf);
+ aFree(code);
}
/// Creates a new script state.
@@ -4682,6 +4678,9 @@ void script_load_translations(void) {
int i, size;
uint32 total = 0;
uint8 lang_id = 0, k;
+
+ if (map->minimal) // No translations in minimal mode
+ return;
script->translation_db = strdb_alloc(DB_OPT_DUP_KEY, NAME_LENGTH*2+1);
@@ -4815,6 +4814,7 @@ void script_load_translation(const char *file, uint8 lang_id, uint32 *total) {
continue;
if( strncasecmp(line,"msgctxt \"", 9) == 0 ) {
+ msgctxt[0] = '\0';
for(i = 9; i < len - 2; i++) {
if( line[i] == '\\' && line[i+1] == '"' ) {
msgctxt[cursor] = '"';
@@ -4826,6 +4826,7 @@ void script_load_translation(const char *file, uint8 lang_id, uint32 *total) {
}
msgctxt[cursor] = '\0';
} else if ( strncasecmp(line, "msgid \"", 7) == 0 ) {
+ msgid.pos = 0;
for(i = 7; i < len - 2; i++) {
if( line[i] == '\\' && line[i+1] == '"' ) {
script_string_buf_addb(&msgid, '"');
@@ -4835,6 +4836,7 @@ void script_load_translation(const char *file, uint8 lang_id, uint32 *total) {
}
script_string_buf_addb(&msgid,0);
} else if ( len > 9 && line[9] != '"' && strncasecmp(line, "msgstr \"",8) == 0 ) {
+ msgstr.pos = 0;
for(i = 8; i < len - 2; i++) {
if( line[i] == '\\' && line[i+1] == '"' ) {
script_string_buf_addb(&msgstr, '"');
@@ -4886,7 +4888,6 @@ void script_load_translation(const char *file, uint8 lang_id, uint32 *total) {
st->translations++;
st->len += inner_len;
}
-
msgctxt[0] = '\0';
msgid.pos = msgstr.pos = 0;
translations++;
@@ -4967,6 +4968,13 @@ int script_translation_db_destroyer(DBKey key, DBData *data, va_list ap) {
*
**/
void script_parser_clean_leftovers(void) {
+
+ if( script->buf )
+ aFree(script->buf);
+
+ script->buf = NULL;
+ script->size = 0;
+
if( script->translation_db ) {
script->translation_db->destroy(script->translation_db,script->translation_db_destroyer);
script->translation_db = NULL;
@@ -4979,6 +4987,7 @@ void script_parser_clean_leftovers(void) {
script_string_buf_destroy(&script->parse_simpleexpr_str);
script_string_buf_destroy(&script->lang_export_line_buf);
+ script_string_buf_destroy(&script->lang_export_unescaped_buf);
}
/**
@@ -5672,6 +5681,13 @@ BUILDIN(getarg)
/// return;
/// return <value>;
BUILDIN(return) {
+ st->state = RETFUNC;
+
+ if( st->stack->defsp < 1 || st->stack->stack_data[st->stack->defsp-1].type != C_RETINFO ) {
+ // Incorrect usage of return outside the scope of a function or subroutine.
+ return true; // No need for further processing, running script is about to be aborted.
+ }
+
if( script_hasdata(st,2) )
{// return value
struct script_data* data;
@@ -5685,16 +5701,19 @@ BUILDIN(return) {
script->get_val(st, data);// current scope, convert to value
if( data->ref && data->ref->vars == st->stack->stack_data[st->stack->defsp-1].u.ri->scope.vars )
data->ref = NULL; // Reference to the parent scope, remove reference pointer
- } else if( name[0] == '.' && !data->ref ) {
- // script variable without a reference set, link to current script
- data->ref = (struct reg_db *)aCalloc(sizeof(struct reg_db), 1);
- script->add_pending_ref(st, data->ref);
- data->ref->vars = st->script->local.vars;
- if( !st->script->local.arrays )
- st->script->local.arrays = idb_alloc(DB_OPT_BASE);
- data->ref->arrays = st->script->local.arrays;
- } else if ( name[0] == '.' /* && data->ref != NULL */ ) {
- data->ref = NULL; // Reference to the parent scope's script, remove reference pointer.
+ } else if( name[0] == '.' ) {
+ // npc variable
+ if( !data->ref ) {
+ // npc variable without a reference set, link to current script
+ data->ref = (struct reg_db *)aCalloc(sizeof(struct reg_db), 1);
+ script->add_pending_ref(st, data->ref);
+ data->ref->vars = st->script->local.vars;
+ if( !st->script->local.arrays )
+ st->script->local.arrays = idb_alloc(DB_OPT_BASE);
+ data->ref->arrays = st->script->local.arrays;
+ } else if( data->ref->vars == st->stack->stack_data[st->stack->defsp-1].u.ri->script->local.vars ) {
+ data->ref = NULL; // Reference to the parent scope's script, remove reference pointer.
+ }
}
}
}
@@ -5702,7 +5721,7 @@ BUILDIN(return) {
{// no return value
script_pushnil(st);
}
- st->state = RETFUNC;
+
return true;
}
@@ -5744,6 +5763,7 @@ BUILDIN(warp)
{
int ret;
int x,y;
+ int warp_clean = 1;
const char* str;
TBL_PC* sd;
@@ -5755,6 +5775,11 @@ BUILDIN(warp)
x = script_getnum(st,3);
y = script_getnum(st,4);
+ if (script_hasdata(st, 5)) {
+ warp_clean = script_getnum(st, 5);
+ }
+
+ sd->state.warp_clean = warp_clean;
if(strcmp(str,"Random")==0)
ret = pc->randomwarp(sd,CLR_TELEPORT);
else if(strcmp(str,"SavePoint")==0 || strcmp(str,"Save")==0)
@@ -7424,7 +7449,7 @@ void buildin_delitem_delete(struct map_session_data* sd, int idx, int* amount, b
{// delete associated pet
intif->delete_petdata(MakeDWord(inv->card[1], inv->card[2]));
}
- pc->delitem(sd, idx, delamount, 0, 0, LOG_TYPE_SCRIPT);
+ pc->delitem(sd, idx, delamount, 0, DELITEM_NORMAL, LOG_TYPE_SCRIPT);
}
amount[0]-= delamount;
@@ -8085,6 +8110,23 @@ BUILDIN(strnpcinfo) {
return true;
}
+/**
+ * charid2rid: Returns the RID associated to the given character ID
+ */
+BUILDIN(charid2rid)
+{
+ int cid = script_getnum(st, 2);
+ TBL_PC *sd = map->charid2sd(cid);
+
+ if (sd == NULL) {
+ script_pushint(st, 0);
+ return true;
+ }
+
+ script_pushint(st, sd->status.account_id);
+ return true;
+}
+
/*==========================================
* GetEquipID(Pos); Pos: 1-SCRIPT_EQUIP_TABLE_SIZE
*------------------------------------------*/
@@ -8455,10 +8497,10 @@ BUILDIN(successrefitem)
sd->status.inventory[i].refine += up;
sd->status.inventory[i].refine = cap_value( sd->status.inventory[i].refine, 0, MAX_REFINE);
- pc->unequipitem(sd,i,2); // status calc will happen in pc->equipitem() below
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_FORCE); // status calc will happen in pc->equipitem() below
clif->refine(sd->fd,0,i,sd->status.inventory[i].refine);
- clif->delitem(sd,i,1,3);
+ clif->delitem(sd, i, 1, DELITEM_MATERIALCHANGE);
//Logs items, got from (N)PC scripts [Lupus]
logs->pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i],sd->inventory_data[i]);
@@ -8504,10 +8546,10 @@ BUILDIN(failedrefitem)
i=pc->checkequip(sd,script->equip[num-1]);
if(i >= 0) {
sd->status.inventory[i].refine = 0;
- pc->unequipitem(sd,i,3); //recalculate bonus
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE); //recalculate bonus
clif->refine(sd->fd,1,i,sd->status.inventory[i].refine); //notify client of failure
- pc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
+ pc->delitem(sd, i, 1, 0, DELITEM_FAILREFINE, LOG_TYPE_SCRIPT);
clif->misceffect(&sd->bl,2); // display failure effect
}
@@ -8538,12 +8580,12 @@ BUILDIN(downrefitem)
//Logs items, got from (N)PC scripts [Lupus]
logs->pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i],sd->inventory_data[i]);
- pc->unequipitem(sd,i,2); // status calc will happen in pc->equipitem() below
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_FORCE); // status calc will happen in pc->equipitem() below
sd->status.inventory[i].refine -= down;
sd->status.inventory[i].refine = cap_value( sd->status.inventory[i].refine, 0, MAX_REFINE);
clif->refine(sd->fd,2,i,sd->status.inventory[i].refine);
- clif->delitem(sd,i,1,3);
+ clif->delitem(sd, i, 1, DELITEM_MATERIALCHANGE);
//Logs items, got from (N)PC scripts [Lupus]
logs->pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i],sd->inventory_data[i]);
@@ -8572,8 +8614,8 @@ BUILDIN(delequip)
if (num > 0 && num <= ARRAYLENGTH(script->equip))
i=pc->checkequip(sd,script->equip[num-1]);
if(i >= 0) {
- pc->unequipitem(sd,i,3); //recalculate bonus
- pc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE); //recalculate bonus
+ pc->delitem(sd, i, 1, 0, DELITEM_FAILREFINE, LOG_TYPE_SCRIPT);
return true;
}
@@ -8829,7 +8871,7 @@ BUILDIN(autobonus3) {
BUILDIN(skill) {
int id;
int level;
- int flag = 1;
+ int flag = SKILL_GRANT_TEMPORARY;
TBL_PC* sd;
sd = script->rid2sd(st);
@@ -8857,7 +8899,7 @@ BUILDIN(skill) {
BUILDIN(addtoskill) {
int id;
int level;
- int flag = 2;
+ int flag = SKILL_GRANT_TEMPSTACK;
TBL_PC* sd;
sd = script->rid2sd(st);
@@ -9702,8 +9744,7 @@ BUILDIN(monster)
if (script_hasdata(st, 10))
{
ai = script_getnum(st, 10);
- if (ai > 4)
- {
+ if (ai > AI_FLORA) {
ShowWarning("buildin_monster: Attempted to spawn non-existing ai %d for monster class %d\n", ai, class_);
return false;
}
@@ -9807,7 +9848,7 @@ BUILDIN(areamonster) {
if (script_hasdata(st, 12)) {
ai = script_getnum(st, 12);
- if (ai > 4) {
+ if (ai > AI_FLORA) {
ShowWarning("buildin_monster: Attempted to spawn non-existing ai %d for monster class %d\n", ai, class_);
return false;
}
@@ -10977,7 +11018,7 @@ BUILDIN(homunculus_mutate)
if (m_class == HT_EVO && m_id == HT_S &&
sd->hd->homunculus.level >= 99 && i != INDEX_NOT_FOUND &&
- !pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_SCRIPT) ) {
+ !pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_SCRIPT) ) {
sd->hd->homunculus.vaporize = HOM_ST_REST; // Remove morph state.
homun->call(sd); // Respawn homunculus.
homun->mutate(sd->hd, homun_id);
@@ -11158,26 +11199,24 @@ BUILDIN(resetstatus)
/*==========================================
* script command resetskill
*------------------------------------------*/
-BUILDIN(resetskill)
-{
+BUILDIN(resetskill) {
TBL_PC *sd;
sd=script->rid2sd(st);
if( sd == NULL )
return false;
- pc->resetskill(sd,1);
+ pc->resetskill(sd, PCRESETSKILL_RESYNC);
return true;
}
/*==========================================
* Counts total amount of skill points.
*------------------------------------------*/
-BUILDIN(skillpointcount)
-{
+BUILDIN(skillpointcount) {
TBL_PC *sd;
sd=script->rid2sd(st);
if( sd == NULL )
return false;
- script_pushint(st,sd->status.skill_point + pc->resetskill(sd,2));
+ script_pushint(st,sd->status.skill_point + pc->resetskill(sd, PCRESETSKILL_RECOUNT));
return true;
}
@@ -11219,10 +11258,10 @@ static TBL_PC *prepareChangeSex(struct script_state* st)
if (sd == NULL)
return NULL;
- pc->resetskill(sd, 4);
+ pc->resetskill(sd, PCRESETSKILL_CHSEX);
// 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);
+ if (sd->equip_index[i] >= 0) pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
return sd;
}
@@ -11234,7 +11273,7 @@ BUILDIN(changesex)
TBL_PC *sd = prepareChangeSex(st);
if (sd == NULL)
return false;
- chrif->changesex(sd);
+ chrif->changesex(sd, true);
return true;
}
@@ -11246,12 +11285,7 @@ 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);
+ chrif->changesex(sd, false);
return true;
}
@@ -12280,7 +12314,7 @@ BUILDIN(successremovecards)
for (j = sd->inventory_data[i]->slot; j < MAX_SLOTS; j++)
item_tmp.card[j]=sd->status.inventory[i].card[j];
- pc->delitem(sd,i,1,0,3,LOG_TYPE_SCRIPT);
+ pc->delitem(sd, i, 1, 0, DELITEM_MATERIALCHANGE, LOG_TYPE_SCRIPT);
if ((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))) {
//chk if can be spawn in inventory otherwise put on floor
clif->additem(sd,0,0,flag);
@@ -12342,7 +12376,7 @@ BUILDIN(failedremovecards)
if (cardflag == 1) {
if (typefail == 0 || typefail == 2) {
// destroy the item
- pc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
+ pc->delitem(sd, i, 1, 0, DELITEM_FAILREFINE, LOG_TYPE_SCRIPT);
} else if (typefail == 1) {
// destroy the card
int flag, j;
@@ -12360,7 +12394,7 @@ BUILDIN(failedremovecards)
for (j = sd->inventory_data[i]->slot; j < MAX_SLOTS; j++)
item_tmp.card[j]=sd->status.inventory[i].card[j];
- pc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
+ pc->delitem(sd, i, 1, 0, DELITEM_FAILREFINE, LOG_TYPE_SCRIPT);
if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))) {
clif->additem(sd,0,0,flag);
@@ -13054,7 +13088,7 @@ BUILDIN(clearitem)
if(sd==NULL) return true;
for (i=0; i<MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount) {
- pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_SCRIPT);
+ pc->delitem(sd, i, sd->status.inventory[i].amount, 0, DELITEM_NORMAL, LOG_TYPE_SCRIPT);
}
}
return true;
@@ -13483,7 +13517,7 @@ BUILDIN(nude)
if( sd->equip_index[ i ] >= 0 ) {
if( !calcflag )
calcflag = 1;
- pc->unequipitem( sd , sd->equip_index[ i ] , 2);
+ pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_FORCE);
}
}
@@ -13830,7 +13864,7 @@ BUILDIN(npcstop) {
if( nd ) {
unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit
- unit->stop_walking(&nd->bl,1|4);
+ unit->stop_walking(&nd->bl, STOPWALKING_FLAG_FIXPOS|STOPWALKING_FLAG_NEXTCELL);
}
return true;
@@ -14240,11 +14274,6 @@ BUILDIN(isnight) {
return true;
}
-BUILDIN(isday) {
- script_pushint(st,(map->night_flag == 0));
- return true;
-}
-
/*================================================
* Check how many items/cards in the list are
* equipped - used for 2/15's cards patch [celest]
@@ -14460,7 +14489,7 @@ BUILDIN(unequip)
if (sd != NULL && num >= 1 && num <= ARRAYLENGTH(script->equip)) {
int i = pc->checkequip(sd,script->equip[num-1]);
if (i >= 0)
- pc->unequipitem(sd,i,1|2);
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
}
return true;
}
@@ -15466,8 +15495,26 @@ BUILDIN(compare)
return true;
}
-// [zBuffer] List of mathematics commands --->
-BUILDIN(sqrt)
+BUILDIN(strcmp)
+{
+ const char *str1 = script_getstr(st,2);
+ const char *str2 = script_getstr(st,3);
+ script_pushint(st,strcmp(str1, str2));
+ return true;
+}
+
+// List of mathematics commands --->
+
+BUILDIN(log10)
+{
+ double i, a;
+ i = script_getnum(st,2);
+ a = log10(i);
+ script_pushint(st,(int)a);
+ return true;
+}
+
+BUILDIN(sqrt) //[zBuffer]
{
double i, a;
i = script_getnum(st,2);
@@ -15476,7 +15523,7 @@ BUILDIN(sqrt)
return true;
}
-BUILDIN(pow)
+BUILDIN(pow) //[zBuffer]
{
double i, a, b;
a = script_getnum(st,2);
@@ -15486,7 +15533,7 @@ BUILDIN(pow)
return true;
}
-BUILDIN(distance)
+BUILDIN(distance) //[zBuffer]
{
int x0, y0, x1, y1;
@@ -15499,7 +15546,7 @@ BUILDIN(distance)
return true;
}
-// <--- [zBuffer] List of mathematics commands
+// <--- List of mathematics commands
BUILDIN(min)
{
@@ -16432,7 +16479,7 @@ BUILDIN(unitstop) {
if( bl != NULL ) {
unit->bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit
unit->stop_attack(bl);
- unit->stop_walking(bl,4);
+ unit->stop_walking(bl, STOPWALKING_FLAG_NEXTCELL);
if( bl->type == BL_MOB )
((TBL_MOB*)bl)->target_id = 0;
}
@@ -17136,18 +17183,27 @@ BUILDIN(changequest) {
BUILDIN(questactive) {
struct map_session_data *sd = script->rid2sd(st);
- int quest_progress = 0;
+ int qid, i;
- if (sd == NULL)
+ if (sd == NULL) {
+ ShowError("questactive: no player attached!");
return false;
+ }
+
+ qid = script_getnum(st, 2);
+
+ ARR_FIND(0, sd->avail_quests, i, sd->quest_log[i].quest_id == qid );
+
+ if( i >= sd->avail_quests ) {
+ script_pushint(st, 0);
+ return true;
+ }
- if (quest->check(sd, script_getnum(st, 2), HAVEQUEST) == Q_ACTIVE)
+ if(sd->quest_log[i].state == Q_ACTIVE)
script_pushint(st, 1);
else
script_pushint(st, 0);
- script_pushint(st, quest_progress);
-
return true;
}
@@ -17251,7 +17307,9 @@ BUILDIN(waitingroom2bg) {
return true;
}
+ Assert_retr(false, cd->users < MAX_CHAT_USERS);
n = cd->users; // This is always < MAX_CHAT_USERS
+
for (i = 0; i < n && i < MAX_BG_MEMBERS; i++) {
struct map_session_data *sd = cd->usersd[i];
if (sd != NULL && bg->team_join(bg_id, sd))
@@ -17356,7 +17414,7 @@ BUILDIN(bg_monster_set_team) {
md->bg_id = bg_id;
mob_stop_attack(md);
- mob_stop_walking(md, 0);
+ mob_stop_walking(md, STOPWALKING_FLAG_NONE);
md->target_id = md->attacked_id = 0;
clif->charnameack(0, &md->bl);
@@ -18158,7 +18216,7 @@ BUILDIN(setcashmount)
if ((sd = script->rid2sd(st)) == NULL)
return true;
if (pc_hasmount(sd)) {
- clif->msgtable(sd->fd, 0X78b);
+ clif->msgtable(sd, MSG_REINS_CANT_USE_MOUNTED);
script_pushint(st,0);//can't mount with one of these
} else {
if (sd->sc.data[SC_ALL_RIDING])
@@ -19617,6 +19675,48 @@ BUILDIN(channelmes)
return true;
}
+
+/** By Cydh
+Display script message
+showscript "<message>"{,<GID>};
+*/
+BUILDIN(showscript) {
+ struct block_list *bl = NULL;
+ const char *msg = script_getstr(st, 2);
+ int id = 0;
+
+ if (script_hasdata(st, 3)) {
+ id = script_getnum(st, 3);
+ bl = map->id2bl(id);
+ }
+ else {
+ bl = st->rid ? map->id2bl(st->rid) : map->id2bl(st->oid);
+ }
+
+ if (!bl) {
+ ShowError("buildin_showscript: Script not attached. (id=%d, rid=%d, oid=%d)\n", id, st->rid, st->oid);
+ script_pushint(st, 0);
+ return false;
+ }
+
+ clif->ShowScript(bl, msg);
+
+ script_pushint(st, 1);
+
+ return true;
+}
+
+BUILDIN(mergeitem)
+{
+ struct map_session_data *sd = script->rid2sd(st);
+
+ if (sd == NULL)
+ return true;
+
+ clif->openmergeitem(sd->fd, sd);
+
+ return true;
+}
/** place holder for the translation macro **/
BUILDIN(_) {
return true;
@@ -19761,7 +19861,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(jobchange,"i?"),
BUILDIN_DEF(jobname,"i"),
BUILDIN_DEF(input,"r??"),
- BUILDIN_DEF(warp,"sii"),
+ BUILDIN_DEF(warp,"sii?"),
BUILDIN_DEF(areawarp,"siiiisii??"),
BUILDIN_DEF(warpchar,"siii"), // [LuzZza]
BUILDIN_DEF(warpparty,"siii?"), // [Fredzilla] [Paradox924X]
@@ -19807,6 +19907,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(getguildmember,"i?"),
BUILDIN_DEF(strcharinfo,"i"),
BUILDIN_DEF(strnpcinfo,"i"),
+ BUILDIN_DEF(charid2rid,"i"),
BUILDIN_DEF(getequipid,"i"),
BUILDIN_DEF(getequipname,"i"),
BUILDIN_DEF(getbrokenid,"i"), // [Valaris]
@@ -19997,7 +20098,6 @@ void script_parse_builtin(void) {
BUILDIN_DEF(logmes,"s"), //this command actls as MES but rints info into LOG file either SQL/TXT [Lupus]
BUILDIN_DEF(summon,"si??"), // summons a slave monster [Celest]
BUILDIN_DEF(isnight,""), // check whether it is night time [Celest]
- BUILDIN_DEF_DEPRECATED(isday,""), // check whether it is day time [Celest] // DEPRECATED 2015-01-21 [Haru]
BUILDIN_DEF(isequipped,"i*"), // check whether another item/card has been equipped [Celest]
BUILDIN_DEF(isequippedcnt,"i*"), // check how many items/cards are being equipped [Celest]
BUILDIN_DEF(cardscnt,"i*"), // check how many items/cards are being equipped in the same arm [Lupus]
@@ -20040,14 +20140,16 @@ void script_parse_builtin(void) {
BUILDIN_DEF(countstr,"ss?"),
BUILDIN_DEF(setnpcdisplay,"sv??"),
BUILDIN_DEF(compare,"ss"), // Lordalfa - To bring strstr to scripting Engine.
+ BUILDIN_DEF(strcmp,"ss"),
BUILDIN_DEF(getiteminfo,"ii"), //[Lupus] returns Items Buy / sell Price, etc info
BUILDIN_DEF(setiteminfo,"iii"), //[Lupus] set Items Buy / sell Price, etc info
BUILDIN_DEF(getequipcardid,"ii"), //[Lupus] returns CARD ID or other info from CARD slot N of equipped item
- // [zBuffer] List of mathematics commands --->
- BUILDIN_DEF(sqrt,"i"),
- BUILDIN_DEF(pow,"ii"),
- BUILDIN_DEF(distance,"iiii"),
- // <--- [zBuffer] List of mathematics commands
+ // List of mathematics commands --->
+ BUILDIN_DEF(log10,"i"),
+ BUILDIN_DEF(sqrt,"i"), //[zBuffer]
+ BUILDIN_DEF(pow,"ii"), //[zBuffer]
+ BUILDIN_DEF(distance,"iiii"), //[zBuffer]
+ // <--- List of mathematics commands
BUILDIN_DEF(min, "i*"),
BUILDIN_DEF(max, "i*"),
BUILDIN_DEF(md5,"s"),
@@ -20175,7 +20277,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(makerune,"i"),
BUILDIN_DEF(hascashmount,""),//[Ind]
BUILDIN_DEF(setcashmount,""),//[Ind]
- BUILDIN_DEF(checkre,"i"),
+ BUILDIN_DEF_DEPRECATED(checkre,"i"), // Deprecated 2015-05-08 [Haru]
/**
* rAthena and beyond!
**/
@@ -20252,6 +20354,8 @@ void script_parse_builtin(void) {
BUILDIN_DEF(shopcount, "i"),
BUILDIN_DEF(channelmes, "ss"),
+ BUILDIN_DEF(showscript, "s?"),
+ BUILDIN_DEF(mergeitem,""),
BUILDIN_DEF(_,"s"),
};
int i, len = ARRAYLENGTH(BUILDIN);
@@ -20357,6 +20461,43 @@ void script_hardcoded_constants(void) {
script->set_constant("BG_AREA",BG_AREA,false);
script->set_constant("BG_AREA_WOS",BG_AREA_WOS,false);
script->set_constant("BG_QUEUE",BG_QUEUE,false);
+
+ /* Renewal */
+#ifdef RENEWAL
+ script->set_constant("RENEWAL", 1, false);
+#else
+ script->set_constant("RENEWAL", 0, false);
+#endif
+#ifdef RENEWAL_CAST
+ script->set_constant("RENEWAL_CAST", 1, false);
+#else
+ script->set_constant("RENEWAL_CAST", 0, false);
+#endif
+#ifdef RENEWAL_DROP
+ script->set_constant("RENEWAL_DROP", 1, false);
+#else
+ script->set_constant("RENEWAL_DROP", 0, false);
+#endif
+#ifdef RENEWAL_EXP
+ script->set_constant("RENEWAL_EXP", 1, false);
+#else
+ script->set_constant("RENEWAL_EXP", 0, false);
+#endif
+#ifdef RENEWAL_LVDMG
+ script->set_constant("RENEWAL_LVDMG", 1, false);
+#else
+ script->set_constant("RENEWAL_LVDMG", 0, false);
+#endif
+#ifdef RENEWAL_EDP
+ script->set_constant("RENEWAL_EDP", 1, false);
+#else
+ script->set_constant("RENEWAL_EDP", 0, false);
+#endif
+#ifdef RENEWAL_ASPD
+ script->set_constant("RENEWAL_ASPD", 1, false);
+#else
+ script->set_constant("RENEWAL_ASPD", 0, false);
+#endif
}
/**
diff --git a/src/map/script.h b/src/map/script.h
index 51bdf23b5..93d60f416 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -5,16 +5,16 @@
#ifndef MAP_SCRIPT_H
#define MAP_SCRIPT_H
+#include "map/map.h" //EVENT_NAME_LENGTH
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/mmo.h" // struct item
+#include "common/sql.h" // Sql
+#include "common/strlib.h" //StringBuf
+
#include <errno.h>
#include <setjmp.h>
-#include "map.h" //EVENT_NAME_LENGTH
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/mmo.h" // struct item
-#include "../common/sql.h" // Sql
-#include "../common/strlib.h" //StringBuf
-
/**
* Declarations
**/
@@ -605,6 +605,7 @@ struct script_interface {
/* */
struct script_string_buf parse_simpleexpr_str;
struct script_string_buf lang_export_line_buf;
+ struct script_string_buf lang_export_unescaped_buf;
/* */
int parse_cleanup_timer_id;
/* */
diff --git a/src/map/searchstore.c b/src/map/searchstore.c
index 782c14987..b9e23ae82 100644
--- a/src/map/searchstore.c
+++ b/src/map/searchstore.c
@@ -4,15 +4,15 @@
#define HERCULES_CORE
-#include "searchstore.h" // struct s_search_store_info
-
-#include "battle.h" // battle_config.*
-#include "clif.h" // clif->open_search_store_info, clif->search_store_info_*
-#include "pc.h" // struct map_session_data
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h" // aMalloc, aRealloc, aFree
-#include "../common/showmsg.h" // ShowError, ShowWarning
-#include "../common/strlib.h" // safestrncpy
+#include "searchstore.h" // struct s_search_store_info
+
+#include "map/battle.h" // battle_config.*
+#include "map/clif.h" // clif-"open_search_store_info, clif-"search_store_info_*
+#include "map/pc.h" // struct map_session_data
+#include "common/cbasetypes.h"
+#include "common/malloc.h" // aMalloc, aRealloc, aFree
+#include "common/showmsg.h" // ShowError, ShowWarning
+#include "common/strlib.h" // safestrncpy
struct searchstore_interface searchstore_s;
diff --git a/src/map/searchstore.h b/src/map/searchstore.h
index 6664eddfa..2778740a5 100644
--- a/src/map/searchstore.h
+++ b/src/map/searchstore.h
@@ -5,11 +5,11 @@
#ifndef MAP_SEARCHSTORE_H
#define MAP_SEARCHSTORE_H
-#include <time.h>
+#include "map/map.h" // MESSAGE_SIZE
+#include "common/cbasetypes.h"
+#include "common/mmo.h" // MAX_SLOTS
-#include "map.h" // MESSAGE_SIZE
-#include "../common/cbasetypes.h"
-#include "../common/mmo.h" // MAX_SLOTS
+#include <time.h>
/**
* Defines
diff --git a/src/map/skill.c b/src/map/skill.c
index 96ade3908..f2154aa22 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -4,47 +4,47 @@
#define HERCULES_CORE
-#include "../config/core.h" // DBPATH, MAGIC_REFLECTION_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_CAST, VARCAST_REDUCTION()
+#include "config/core.h" // DBPATH, MAGIC_REFLECTION_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_CAST, VARCAST_REDUCTION()
#include "skill.h"
+#include "map/battle.h"
+#include "map/battleground.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/date.h"
+#include "map/elemental.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/map.h"
+#include "map/mercenary.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/party.h"
+#include "map/path.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/script.h"
+#include "map/status.h"
+#include "map/unit.h"
+#include "common/cbasetypes.h"
+#include "common/ers.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include "battle.h"
-#include "battleground.h"
-#include "chrif.h"
-#include "clif.h"
-#include "date.h"
-#include "elemental.h"
-#include "guild.h"
-#include "homunculus.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "map.h"
-#include "mercenary.h"
-#include "mob.h"
-#include "npc.h"
-#include "party.h"
-#include "path.h"
-#include "pc.h"
-#include "pet.h"
-#include "script.h"
-#include "status.h"
-#include "unit.h"
-#include "../common/cbasetypes.h"
-#include "../common/ers.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
#define SKILLUNITTIMER_INTERVAL 100
// ranges reserved for mapping skill ids to skilldb offsets
@@ -62,6 +62,7 @@
#endif
struct skill_interface skill_s;
+struct s_skill_dbs skilldbs;
//Since only mob-casted splash skills can hit ice-walls
static inline int splash_target(struct block_list* bl) {
@@ -99,7 +100,7 @@ int skill_get_index( uint16 skill_id ) {
skill_id = MC_SKILLRANGEMIN + skill_id - MC_SKILLBASE;
else if( skill_id >= HM_SKILLBASE )
skill_id = HM_SKILLRANGEMIN + skill_id - HM_SKILLBASE;
- //[Ind/Hercules] GO GO GO LESS! - http://hercules.ws/board/topic/512-skill-id-processing-overhaul/
+ //[Ind/Hercules] GO GO GO LESS! - http://herc.ws/board/topic/512-skill-id-processing-overhaul/
else if( skill_id > 1019 && skill_id < 8001 ) {
if( skill_id < 2058 ) // 1020 - 2000 are empty
skill_id = 1020 + skill_id - 2001;
@@ -121,11 +122,11 @@ int skill_get_index( uint16 skill_id ) {
}
const char* skill_get_name( uint16 skill_id ) {
- return skill->db[skill->get_index(skill_id)].name;
+ return skill->dbs->db[skill->get_index(skill_id)].name;
}
const char* skill_get_desc( uint16 skill_id ) {
- return skill->db[skill->get_index(skill_id)].desc;
+ return skill->dbs->db[skill->get_index(skill_id)].desc;
}
// out of bounds error checking [celest]
@@ -138,58 +139,58 @@ void skill_chk(uint16* skill_id) {
skill->chk(&(id)); \
if(!(id)) return 0; \
if( (lv) > MAX_SKILL_LEVEL && (var) > 1 ) { \
- int lv2__ = (lv); (lv) = skill->db[(id)].max; \
+ int lv2__ = (lv); (lv) = skill->dbs->db[(id)].max; \
return (var) + ((lv2__-(lv))/2);\
} \
return (var);\
} 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_hit( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].hit, skill_id); }
+int skill_get_inf( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].inf, skill_id); }
+int skill_get_ele( uint16 skill_id , uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get (skill->dbs->db[skill_id].element[skill_glv(skill_lv-1)], skill_id); }
+int skill_get_nk( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].nk, skill_id); }
+int skill_get_max( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].max, skill_id); }
+int skill_get_range( uint16 skill_id , uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].range[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_splash( uint16 skill_id , uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 ( (skill->dbs->db[skill_id].splash[skill_glv(skill_lv-1)]>=0?skill->dbs->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 ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].hp[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_sp( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].sp[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_hp_rate(uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->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 ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].sp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_state(uint16 skill_id) { skill_get (skill->dbs->db[skill_id].state, skill_id); }
+int skill_get_spiritball(uint16 skill_id, uint16 skill_lv) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->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->dbs->db[skill_id].itemid[idx], skill_id); }
+int skill_get_itemqty(uint16 skill_id, int idx) { skill_get (skill->dbs->db[skill_id].amount[idx], skill_id); }
+int skill_get_zeny( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].zeny[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_num( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].num[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_cast( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].cast[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_delay( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].delay[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].walkdelay[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_time( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].upkeep_time[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_time2( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].upkeep_time2[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_castdef( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].cast_def_rate, skill_id); }
+int skill_get_weapontype( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].weapon, skill_id); }
+int skill_get_ammotype( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].ammo, skill_id); }
+int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].ammo_qty[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_inf2( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].inf2, skill_id); }
+int skill_get_castcancel( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].castcancel, skill_id); }
+int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].maxcount[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].blewcount[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_mhp( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].mhp[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_castnodex( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].castnodex[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_delaynodex( uint16 skill_id ,uint16 skill_lv ){ Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].delaynodex[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_type( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].skill_type, skill_id); }
+int skill_get_unit_id ( uint16 skill_id, int flag ){ skill_get (skill->dbs->db[skill_id].unit_id[flag], skill_id); }
+int skill_get_unit_interval( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].unit_interval, skill_id); }
+int skill_get_unit_range( uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->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->dbs->db[skill_id].unit_target&BCT_ALL, skill_id); }
+int skill_get_unit_bl_target( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].unit_target&BL_ALL, skill_id); }
+int skill_get_unit_flag( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].unit_flag, skill_id); }
+int skill_get_unit_layout_type( uint16 skill_id ,uint16 skill_lv ){ Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->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 ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->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);
+ Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].fixed_cast[skill_glv(skill_lv-1)], skill_id, skill_lv);
#else
return 0;
#endif
@@ -223,17 +224,17 @@ int skill_get_casttype (uint16 skill_id) {
}
int skill_get_casttype2 (uint16 index) {
- int inf = skill->db[index].inf;
+ int inf = skill->dbs->db[index].inf;
if (inf&(INF_GROUND_SKILL))
return CAST_GROUND;
if (inf&INF_SUPPORT_SKILL)
return CAST_NODAMAGE;
if (inf&INF_SELF_SKILL) {
- if(skill->db[index].inf2&INF2_NO_TARGET_SELF)
+ if(skill->dbs->db[index].inf2&INF2_NO_TARGET_SELF)
return CAST_DAMAGE; //Combo skill.
return CAST_NODAMAGE;
}
- if (skill->db[index].nk&NK_NO_DAMAGE)
+ if (skill->dbs->db[index].nk&NK_NO_DAMAGE)
return CAST_NODAMAGE;
return CAST_DAMAGE;
}
@@ -438,7 +439,7 @@ int can_copy (struct map_session_data *sd, uint16 skill_id, struct block_list* b
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)] )
+ else if( sd->sc.data[SC__REPRODUCE] && !skill->dbs->reproduce_db[skill->get_index(skill_id)] )
return 0;
return 1;
@@ -619,19 +620,19 @@ struct s_skill_unit_layout* skill_get_unit_layout (uint16 skill_id, uint16 skill
}
if (pos != -1) // simple single-definition layout
- return &skill->unit_layout[pos];
+ return &skill->dbs->unit_layout[pos];
dir = (src->x == x && src->y == y) ? 6 : map->calc_dir(src,x,y); // 6 - default aegis direction
if (skill_id == MG_FIREWALL)
- return &skill->unit_layout [skill->firewall_unit_pos + dir];
+ return &skill->dbs->unit_layout [skill->firewall_unit_pos + dir];
else if (skill_id == WZ_ICEWALL)
- return &skill->unit_layout [skill->icewall_unit_pos + dir];
+ return &skill->dbs->unit_layout [skill->icewall_unit_pos + dir];
else if( skill_id == WL_EARTHSTRAIN ) //Warlock
- return &skill->unit_layout [skill->earthstrain_unit_pos + dir];
+ return &skill->dbs->unit_layout [skill->earthstrain_unit_pos + dir];
ShowError("skill_get_unit_layout: unknown unit layout for skill %d (level %d)\n", skill_id, skill_lv);
- return &skill->unit_layout[0]; // default 1x1 layout
+ return &skill->dbs->unit_layout[0]; // default 1x1 layout
}
/*==========================================
@@ -671,7 +672,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
if( skill_id != WS_CARTTERMINATION && skill_id != AM_DEMONSTRATION && skill_id != CR_REFLECTSHIELD && skill_id != MS_REFLECTSHIELD && skill_id != ASC_BREAKER ) {
// Trigger status effects
enum sc_type type;
- int i;
+ int i, flag;
for( i = 0; i < ARRAYLENGTH(sd->addeff) && sd->addeff[i].flag; i++ ) {
rate = sd->addeff[i].rate;
if( attack_type&BF_LONG ) // Any ranged physical attack takes status arrows into account (Grimtooth...) [DracoRPG]
@@ -695,13 +696,22 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
}
type = sd->addeff[i].id;
- temp = skill->get_time2(status->sc2skill(type),7);
+
+ if (sd->addeff[i].duration > 0) {
+ // Fixed duration
+ temp = sd->addeff[i].duration;
+ flag = SCFLAG_FIXEDRATE|SCFLAG_FIXEDTICK;
+ } else {
+ // Default duration
+ temp = skill->get_time2(status->sc2skill(type),7);
+ flag = SCFLAG_NONE;
+ }
if (sd->addeff[i].flag&ATF_TARGET)
- status->change_start(src,bl,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,SCFLAG_NONE);
+ status->change_start(src,bl,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,flag);
if (sd->addeff[i].flag&ATF_SELF)
- status->change_start(src,src,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,SCFLAG_NONE);
+ status->change_start(src,src,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,flag);
}
}
@@ -912,9 +922,11 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
break;
case AM_ACIDTERROR:
- sc_start2(src,bl,SC_BLOODING,(skill_lv*3),skill_lv,src->id,skill->get_time2(skill_id,skill_lv));
- if (skill->break_equip(bl, EQP_ARMOR, 100*skill->get_time(skill_id,skill_lv), BCT_ENEMY))
- clif->emotion(bl,E_OMG);
+ sc_start2(src, bl, SC_BLOODING, (skill_lv * 3), skill_lv, src->id, skill->get_time2(skill_id, skill_lv));
+ if ( bl->type == BL_PC && rnd() % 1000 < 10 * skill->get_time(skill_id, skill_lv) ) {
+ skill->break_equip(bl, EQP_ARMOR, 10000, BCT_ENEMY);
+ clif->emotion(bl, E_OMG); // emote icon still shows even there is no armor equip.
+ }
break;
case AM_DEMONSTRATION:
@@ -1356,7 +1368,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
break;
}
- if (md && battle_config.summons_trigger_autospells && md->master_id && md->special_state.ai) {
+ if (md && battle_config.summons_trigger_autospells && md->master_id && md->special_state.ai != AI_NONE) {
//Pass heritage to Master for status causing effects. [Skotlex]
sd = map->id2sd(md->master_id);
src = sd?&sd->bl:src;
@@ -2002,7 +2014,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in
}
if (flag) {
sd->status.inventory[j].attribute = 1;
- pc->unequipitem(sd, j, 3);
+ pc->unequipitem(sd, j, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
}
}
clif->equiplist(sd);
@@ -2194,7 +2206,12 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
//Trick Dead protects you from damage, but not from buffs and the like, hence it's placed here.
if (sc && sc->data[SC_TRICKDEAD])
return 0;
-
+ if ( skill_id != HW_GRAVITATION ) {
+ struct status_change *csc = status->get_sc(src);
+ if(csc && csc->data[SC_GRAVITATION] && csc->data[SC_GRAVITATION]->val3 == BCT_SELF )
+ return 0;
+ }
+
dmg = battle->calc_attack(attack_type,src,bl,skill_id,skill_lv,flag&0xFFF);
//Skotlex: Adjusted to the new system
@@ -2213,9 +2230,11 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
}
}
- if( dmg.flag&BF_MAGIC && ( (battle_config.eq_single_target_reflectable && (flag&0xFFF) == 1) ) ) {
+ if( dmg.flag&BF_MAGIC
+ && (skill_id != NPC_EARTHQUAKE || (battle_config.eq_single_target_reflectable && (flag & 0xFFF) == 1)) ) { /* Need more info cause NPC_EARTHQUAKE is ground type */
// Earthquake on multiple targets is not counted as a target skill. [Inkfish]
- if( (dmg.damage || dmg.damage2) && (type = skill->magic_reflect(src, bl, src==dsrc)) ) {
+ int reflecttype;
+ if( (dmg.damage || dmg.damage2) && (reflecttype = skill->magic_reflect(src, bl, src==dsrc)) ) {
//Magic reflection, switch caster/target
struct block_list *tbl = bl;
rmdamage = true;
@@ -2232,17 +2251,17 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
/* bugreport:7859 magical reflected zeroes blow count */
dmg.blewcount = 0;
//Spirit of Wizard blocks Kaite's reflection
- if (type == 2 && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_WIZARD) {
+ if (reflecttype == 2 && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_WIZARD) {
//Consume one Fragment per hit of the casted skill? [Skotlex]
- type = tsd ? pc->search_inventory(tsd, ITEMID_FRAGMENT_OF_CRYSTAL) : 0;
- if (type != INDEX_NOT_FOUND) {
- if ( tsd ) pc->delitem(tsd, type, 1, 0, 1, LOG_TYPE_CONSUME);
+ int consumeitem = tsd ? pc->search_inventory(tsd, ITEMID_FRAGMENT_OF_CRYSTAL) : 0;
+ if (consumeitem != INDEX_NOT_FOUND) {
+ if ( tsd ) pc->delitem(tsd, consumeitem, 1, 0, DELITEM_SKILLUSE, LOG_TYPE_CONSUME);
dmg.damage = dmg.damage2 = 0;
dmg.dmg_lv = ATK_MISS;
sc->data[SC_SOULLINK]->val3 = skill_id;
sc->data[SC_SOULLINK]->val4 = dsrc->id;
}
- } else if( type != 2 ) /* Kaite bypasses */
+ } else if( reflecttype != 2 ) /* Kaite bypasses */
additional_effects = false;
/**
@@ -2255,7 +2274,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
#else
// issue:6415 in pre-renewal Kaite reflected the entire damage received
// regardless of caster's equipment (Aegis 11.1)
- if( dmg.dmg_lv != ATK_MISS && type == 1 ) //Wiz SL canceled and consumed fragment
+ if( dmg.dmg_lv != ATK_MISS && reflecttype == 1 ) //Wiz SL canceled and consumed fragment
#endif
{
short s_ele = skill->get_ele(skill_id, skill_lv);
@@ -2303,14 +2322,13 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
if( damage && sc && sc->data[SC_GENSOU] && dmg.flag&BF_MAGIC ){
struct block_list *nbl;
nbl = battle->get_enemy_area(bl,bl->x,bl->y,2,BL_CHAR,bl->id);
- if( nbl ){ // Only one target is chosen.
- int temp = (int)(damage / (float)(10 / skill_lv));
- clif->skill_damage(bl, nbl, tick, status_get_amotion(src), 0, status_fix_damage(bl,nbl,temp,0), 1, OB_OBOROGENSOU_TRANSITION_ATK, -1, 6);
+ if (nbl) { // Only one target is chosen.
+ clif->skill_damage(bl, nbl, tick, status_get_amotion(src), 0, status_fix_damage(bl,nbl,damage * skill_lv / 10,0), 1, OB_OBOROGENSOU_TRANSITION_ATK, -1, BDT_SKILL);
}
}
//Skill hit type
- type=(skill_id==0)?5:skill->get_hit(skill_id);
+ type=(skill_id==0)?BDT_SPLASH:skill->get_hit(skill_id);
if(damage < dmg.div_
//Only skills that knockback even when they miss. [Skotlex]
@@ -2319,7 +2337,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
if(skill_id == CR_GRANDCROSS||skill_id == NPC_GRANDDARKNESS) {
if(battle_config.gx_disptype) dsrc = src;
- if(src == bl) type = 4;
+ if(src == bl) type = BDT_ENDURE;
else flag|=SD_ANIMATION;
}
if(skill_id == NJ_TATAMIGAESHI) {
@@ -2425,7 +2443,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
//Display damage.
switch( skill_id ) {
case PA_GOSPEL: //Should look like Holy Cross [Skotlex]
- dmg.dmotion = clif->skill_damage(dsrc,bl,tick,dmg.amotion,dmg.dmotion, damage, dmg.div_, CR_HOLYCROSS, -1, 5);
+ dmg.dmotion = clif->skill_damage(dsrc,bl,tick,dmg.amotion,dmg.dmotion, damage, dmg.div_, CR_HOLYCROSS, -1, BDT_SPLASH);
break;
//Skills that need be passed as a normal attack for the client to display correctly.
case HVAN_EXPLOSION:
@@ -2443,13 +2461,13 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
case AS_SPLASHER:
if( flag&SD_ANIMATION ) // the surrounding targets
- dmg.dmotion = clif->skill_damage(dsrc,bl,tick, dmg.amotion, dmg.dmotion, damage, dmg.div_, skill_id, -1, 5); // needs -1 as skill level
+ dmg.dmotion = clif->skill_damage(dsrc,bl,tick, dmg.amotion, dmg.dmotion, damage, dmg.div_, skill_id, -1, BDT_SPLASH); // needs -1 as skill level
else // the central target doesn't display an animation
- dmg.dmotion = clif->skill_damage(dsrc,bl,tick, dmg.amotion, dmg.dmotion, damage, dmg.div_, skill_id, -2, 5); // needs -2(!) as skill level
+ dmg.dmotion = clif->skill_damage(dsrc,bl,tick, dmg.amotion, dmg.dmotion, damage, dmg.div_, skill_id, -2, BDT_SPLASH); // needs -2(!) as skill level
break;
case WL_HELLINFERNO:
case SR_EARTHSHAKER:
- dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,1,skill_id,-2,6);
+ dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,1,skill_id,-2,BDT_SKILL);
break;
case KO_MUCHANAGE:
if( dmg.dmg_lv == ATK_FLEE )
@@ -2457,17 +2475,17 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
case WL_SOULEXPANSION:
case WL_COMET:
case NJ_HUUMA:
- dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,skill_id,skill_lv,8);
+ dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,skill_id,skill_lv,BDT_MULTIHIT);
break;
case WL_CHAINLIGHTNING_ATK:
- dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,1,WL_CHAINLIGHTNING,-2,6);
+ dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,1,WL_CHAINLIGHTNING,-2,BDT_SKILL);
break;
case LG_OVERBRAND_BRANDISH:
case LG_OVERBRAND:
/* Fall through */
dmg.amotion = status_get_amotion(src) * 2;
case LG_OVERBRAND_PLUSATK:
- dmg.dmotion = clif->skill_damage(dsrc,bl,tick,status_get_amotion(src),dmg.dmotion,damage,dmg.div_,skill_id,-1,5);
+ dmg.dmotion = clif->skill_damage(dsrc,bl,tick,status_get_amotion(src),dmg.dmotion,damage,dmg.div_,skill_id,-1,BDT_SPLASH);
break;
case EL_FIRE_BOMB:
case EL_FIRE_BOMB_ATK:
@@ -2490,29 +2508,29 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
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);
+ dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,skill_id,-1,BDT_SPLASH);
break;
case GN_SLINGITEM_RANGEMELEEATK:
- dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,GN_SLINGITEM,-2,6);
+ dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,GN_SLINGITEM,-2,BDT_SKILL);
break;
case SC_FEINTBOMB:
- dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,1,skill_id,skill_lv,5);
+ dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,1,skill_id,skill_lv,BDT_SPLASH);
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);
+ dmg.dmotion = clif->skill_damage(dsrc,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,skill_id,-1,(flag&1)?BDT_MULTIHIT:BDT_SPLASH);
break;
case WM_SEVERE_RAINSTORM_MELEE:
- dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,WM_SEVERE_RAINSTORM,-2,6);
+ dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,WM_SEVERE_RAINSTORM,-2,BDT_SPLASH);
break;
case WM_REVERBERATION_MELEE:
case WM_REVERBERATION_MAGIC:
- dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,WM_REVERBERATION,-2,6);
+ dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,WM_REVERBERATION,-2,BDT_SKILL);
break;
case WL_TETRAVORTEX_FIRE:
case WL_TETRAVORTEX_WATER:
case WL_TETRAVORTEX_WIND:
case WL_TETRAVORTEX_GROUND:
- dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_, WL_TETRAVORTEX,-1,5);
+ dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_, WL_TETRAVORTEX,-1,BDT_SPLASH);
break;
case HT_CLAYMORETRAP:
case HT_BLASTMINE:
@@ -2521,14 +2539,17 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
case RA_CLUSTERBOMB:
case RA_FIRINGTRAP:
case RA_ICEBOUNDTRAP:
- dmg.dmotion = clif->skill_damage(src,bl,tick, dmg.amotion, dmg.dmotion, damage, dmg.div_, skill_id, (flag&SD_LEVEL) ? -1 : skill_lv, 5);
+ dmg.dmotion = clif->skill_damage(src,bl,tick, dmg.amotion, dmg.dmotion, damage, dmg.div_, skill_id, (flag&SD_LEVEL) ? -1 : skill_lv, BDT_SPLASH);
if( dsrc != src ) // avoid damage display redundancy
break;
case HT_LANDMINE:
dmg.dmotion = clif->skill_damage(dsrc,bl,tick, dmg.amotion, dmg.dmotion, damage, dmg.div_, skill_id, -1, type);
break;
+ case HW_GRAVITATION:
+ dmg.dmotion = clif->damage(bl, bl, 0, 0, damage, 1, BDT_ENDURE, 0);
+ break;
case WZ_SIGHTBLASTER:
- dmg.dmotion = clif->skill_damage(src,bl,tick, dmg.amotion, dmg.dmotion, damage, dmg.div_, skill_id, (flag&SD_LEVEL) ? -1 : skill_lv, 5);
+ dmg.dmotion = clif->skill_damage(src,bl,tick, dmg.amotion, dmg.dmotion, damage, dmg.div_, skill_id, (flag&SD_LEVEL) ? -1 : skill_lv, BDT_SPLASH);
break;
case AB_DUPLELIGHT_MELEE:
case AB_DUPLELIGHT_MAGIC:
@@ -2610,6 +2631,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
tsd->status.skill[cidx].flag = SKILL_FLAG_PLAGIARIZED;
clif->addskill(tsd,copy_skill);
} else {
+ int plagiarismlvl;
lv = skill_lv;
if ( tsd->cloneskill_id ) {
idx = skill->get_index(tsd->cloneskill_id);
@@ -2621,8 +2643,8 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
}
}
- if ((type = pc->checkskill(tsd,RG_PLAGIARISM)) < lv)
- lv = type;
+ if ((plagiarismlvl = pc->checkskill(tsd,RG_PLAGIARISM)) < lv)
+ lv = plagiarismlvl;
tsd->cloneskill_id = copy_skill;
pc_setglobalreg(tsd, script->add_str("CLONE_SKILL"), copy_skill);
@@ -2693,7 +2715,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
}
/* monsters with skill lv higher than MAX_SKILL_LEVEL may get this value beyond the max depending on conditions, we cap to the system's limit */
- if( dsrc && dsrc->type == BL_MOB && skill_lv > MAX_SKILL_LEVEL && dmg.blewcount > 25 )
+ if (dsrc->type == BL_MOB && skill_lv > MAX_SKILL_LEVEL && dmg.blewcount > 25)
dmg.blewcount = 25;
//blown-specific handling
@@ -2738,12 +2760,12 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
) && check_distance_bl(bl, d_bl, sce->val3) )
{
if(!rmdamage){
- clif->damage(d_bl,d_bl, 0, 0, damage, 0, 0, 0);
+ clif->damage(d_bl,d_bl, 0, 0, damage, 0, BDT_NORMAL, 0);
status_fix_damage(NULL,d_bl, damage, 0);
} else{ //Reflected magics are done directly on the target not on paladin
//This check is only for magical skill.
//For BF_WEAPON skills types track var rdamage and function battle_calc_return_damage
- clif->damage(bl,bl, 0, 0, damage, 0, 0, 0);
+ clif->damage(bl,bl, 0, 0, damage, 0, BDT_NORMAL, 0);
status_fix_damage(bl,bl, damage, 0);
}
}
@@ -2837,11 +2859,11 @@ void skill_attack_combo2_unknown(int *attack_type, struct block_list* src, struc
void skill_attack_display_unknown(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, int *type, struct Damage *dmg, int64 *damage) {
if (*flag & SD_ANIMATION && dmg->div_ < 2) //Disabling skill animation doesn't works on multi-hit.
- *type = 5;
+ *type = BDT_SPLASH;
if (bl->type == BL_SKILL ) {
TBL_SKILL *su = (TBL_SKILL*)bl;
if (su->group && skill->get_inf2(su->group->skill_id) & INF2_TRAP) // show damage on trap targets
- clif->skill_damage(src, bl, *tick, dmg->amotion, dmg->dmotion, *damage, dmg->div_, *skill_id, (*flag & SD_LEVEL) ? -1 : *skill_lv, 5);
+ clif->skill_damage(src, bl, *tick, dmg->amotion, dmg->dmotion, *damage, dmg->div_, *skill_id, (*flag & SD_LEVEL) ? -1 : *skill_lv, BDT_SPLASH);
}
dmg->dmotion = clif->skill_damage(dsrc, bl, *tick, dmg->amotion, dmg->dmotion, *damage, dmg->div_, *skill_id, (*flag & SD_LEVEL) ? -1 : *skill_lv, *type);
}
@@ -2890,7 +2912,7 @@ int skill_area_sub(struct block_list *bl, va_list ap) {
if(battle->check_target(src,bl,flag) > 0) {
// several splash skills need this initial dummy packet to display correctly
if (flag&SD_PREAMBLE && skill->area_temp[2] == 0)
- clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
if (flag&(SD_SPLASH|SD_PREAMBLE))
skill->area_temp[2]++;
@@ -3065,15 +3087,15 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv,
// Requirements
for( i = 0; i < ARRAYLENGTH(itemid); i++ )
{
- itemid[i] = skill->db[idx].itemid[i];
- amount[i] = skill->db[idx].amount[i];
- }
- hp = skill->db[idx].hp[lv-1];
- sp = skill->db[idx].sp[lv-1];
- hp_rate = skill->db[idx].hp_rate[lv-1];
- sp_rate = skill->db[idx].sp_rate[lv-1];
- state = skill->db[idx].state;
- if( (mhp = skill->db[idx].mhp[lv-1]) > 0 )
+ itemid[i] = skill->dbs->db[idx].itemid[i];
+ amount[i] = skill->dbs->db[idx].amount[i];
+ }
+ hp = skill->dbs->db[idx].hp[lv-1];
+ sp = skill->dbs->db[idx].sp[lv-1];
+ hp_rate = skill->dbs->db[idx].hp_rate[lv-1];
+ sp_rate = skill->dbs->db[idx].sp_rate[lv-1];
+ state = skill->dbs->db[idx].state;
+ if( (mhp = skill->dbs->db[idx].mhp[lv-1]) > 0 )
hp += (st->max_hp * mhp) / 100;
if( hp_rate > 0 )
hp += (st->hp * hp_rate) / 100;
@@ -3135,7 +3157,7 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv,
// Consume items
for (i = 0; i < ARRAYLENGTH(itemid); i++) {
if (index[i] != INDEX_NOT_FOUND)
- pc->delitem(sd, index[i], amount[i], 0, 1, LOG_TYPE_CONSUME);
+ pc->delitem(sd, index[i], amount[i], 0, DELITEM_SKILLUSE, LOG_TYPE_CONSUME);
}
if( type&2 )
@@ -3315,7 +3337,7 @@ int skill_timerskill(int tid, int64 tick, int id, intptr_t data) {
break;
case SC_ESCAPE:
if( skl->type < 4+skl->skill_lv ){
- clif->skill_damage(src,src,tick,0,0,-30000,1,skl->skill_id,skl->skill_lv,5);
+ clif->skill_damage(src,src,tick,0,0,-30000,1,skl->skill_id,skl->skill_lv,BDT_SPLASH);
skill->blown(src,src,1,unit->getdir(src),0);
skill->addtimerskill(src,tick+80,src->id,0,0,skl->skill_id,skl->skill_lv,skl->type+1,0);
}
@@ -3814,9 +3836,16 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
if( dir > 2 && dir < 6 ) y = -i;
else if( dir == 7 || dir < 2 ) y = i;
else y = 0;
- if( (mbl == src || (!map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground) ) // only NJ_ISSEN don't have slide effect in GVG
- && unit->movepos(src, mbl->x+x, mbl->y+y, 1, 1)
- ) {
+ if ((mbl == src || (!map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground))) { // only NJ_ISSEN don't have slide effect in GVG
+ if (!(unit->movepos(src, mbl->x+x, mbl->y+y, 1, 1))) {
+ // The cell is not reachable (wall, object, ...), move next to the target
+ if (x > 0) x = -1;
+ else if (x < 0) x = 1;
+ if (y > 0) y = -1;
+ else if (y < 0) y = 1;
+
+ unit->movepos(src, bl->x+x, bl->y+y, 1, 1);
+ }
clif->slide(src, src->x, src->y);
clif->fixpos(src);
clif->spiritball(src);
@@ -3914,7 +3943,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
/* Fall through */
case LG_MOONSLASHER:
case MH_XENO_SLASHER:
- clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
break;
default:
break;
@@ -3946,7 +3975,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
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));
+ skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag|SD_ANIMATION|distance_bl(src, bl));
}
break;
@@ -4069,7 +4098,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
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 :/
- clif->damage(src,bl,status_get_amotion(src),0,-1,1,4,0); //Display an absorbed damage attack.
+ clif->damage(src,bl,status_get_amotion(src),0,-1,1,BDT_ENDURE,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;
@@ -4523,7 +4552,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER); // Need confirm it.
} else {
map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id);
- clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
if( sd ) pc->overheat(sd,1);
}
break;
@@ -4542,7 +4571,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
skill->area_temp[5] = y;
map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id);
skill->addtimerskill(src,tick + 800,src->id,x,y,skill_id,skill_lv,0,flag); // To teleport Self
- clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,6);
+ clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,BDT_SKILL);
}
break;
case LG_PINPOINTATTACK:
@@ -4581,14 +4610,12 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
status_change_end(bl, SC_RUSH_WINDMILL, INVALID_TIMER);
status_change_end(bl, SC_ECHOSONG, INVALID_TIMER);
status_change_end(bl, SC_HARMONIZE, INVALID_TIMER);
+ status_change_end(bl, SC_NETHERWORLD, INVALID_TIMER);
status_change_end(bl, SC_SIREN, INVALID_TIMER);
- status_change_end(bl, SC_DEEP_SLEEP, INVALID_TIMER);
- status_change_end(bl, SC_SIRCLEOFNATURE, INVALID_TIMER);
status_change_end(bl, SC_GLOOMYDAY, INVALID_TIMER);
status_change_end(bl, SC_SONG_OF_MANA, INVALID_TIMER);
status_change_end(bl, SC_DANCE_WITH_WUG, INVALID_TIMER);
status_change_end(bl, SC_SATURDAY_NIGHT_FEVER, INVALID_TIMER);
- status_change_end(bl, SC_LERADS_DEW, INVALID_TIMER);
status_change_end(bl, SC_MELODYOFSINK, INVALID_TIMER);
status_change_end(bl, SC_BEYOND_OF_WARCRY, INVALID_TIMER);
status_change_end(bl, SC_UNLIMITED_HUMMING_VOICE, INVALID_TIMER);
@@ -4602,7 +4629,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER);
} else{
map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id);
- clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
}
break;
@@ -4669,7 +4696,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
else {
int i = skill->get_splash(skill_id,skill_lv);
clif->skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1);
- clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
if( rnd()%100 < 30 )
map->foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
else
@@ -4679,7 +4706,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
case EL_ROCK_CRUSHER:
clif->skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1);
- clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
if( rnd()%100 < 50 )
skill->attack(BF_MAGIC,src,src,bl,skill_id,skill_lv,tick,flag);
else
@@ -4692,7 +4719,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
else {
int i = skill->get_splash(skill_id,skill_lv);
clif->skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1);
- clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
if( rnd()%100 < 30 )
map->foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
else
@@ -4705,7 +4732,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
case EL_WIND_SLASH:
case EL_STONE_HAMMER:
clif->skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1);
- clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
skill->attack(skill->get_type(skill_id),src,src,bl,skill_id,skill_lv,tick,flag);
break;
@@ -4718,7 +4745,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1
type2 = type-1;
clif->skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1);
- clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
if( (esc && esc->data[type2]) || (tsc && tsc->data[type]) ) {
elemental->clean_single_effect(ele, skill_id);
}
@@ -4855,7 +4882,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) {
if( sd && ud->skilltimer != INVALID_TIMER && (pc->checkskill(sd,SA_FREECAST) > 0 || ud->skill_id == LG_EXEEDBREAK) )
{// restore original walk speed
ud->skilltimer = INVALID_TIMER;
- status_calc_bl(&sd->bl, SCB_SPEED);
+ status_calc_bl(&sd->bl, SCB_SPEED|SCB_ASPD);
}
ud->skilltimer = INVALID_TIMER;
@@ -5021,7 +5048,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) {
}
if (ud->walktimer != INVALID_TIMER && ud->skill_id != TK_RUN && ud->skill_id != RA_WUGDASH)
- unit->stop_walking(src,1);
+ unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS);
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); // Tests show wings don't overwrite the delay but skill scrolls do. [Inkfish]
@@ -5141,9 +5168,9 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) {
}
}
- ud->skill_id = ud->skill_lv = ud->skilltarget = 0;
if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) )
ud->canact_tick = tick;
+ ud->skill_id = ud->skill_lv = ud->skilltarget = 0;
//You can't place a skill failed packet here because it would be
//sent in ALL cases, even cases where skill_check_condition fails
//which would lead to double 'skill failed' messages u.u [Skotlex]
@@ -5512,10 +5539,10 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
int abra_skill_id = 0, abra_skill_lv, abra_idx;
do {
abra_idx = rnd() % MAX_SKILL_ABRA_DB;
- abra_skill_id = skill->abra_db[abra_idx].skill_id;
+ abra_skill_id = skill->dbs->abra_db[abra_idx].skill_id;
} while (abra_skill_id == 0 ||
- skill->abra_db[abra_idx].req_lv > skill_lv || //Required lv for it to appear
- rnd()%10000 >= skill->abra_db[abra_idx].per
+ skill->dbs->abra_db[abra_idx].req_lv > skill_lv || //Required lv for it to appear
+ rnd()%10000 >= skill->dbs->abra_db[abra_idx].per
);
abra_skill_lv = min(skill_lv, skill->get_max(abra_skill_id));
clif->skill_nodamage (src, bl, skill_id, skill_lv, 1);
@@ -6081,7 +6108,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
}
i = 0;
- count = (sd)? min(skill_lv,5) : 1; // Mercenary only can Devote owner
+ count = (sd)? min(skill_lv,MAX_PC_DEVOTION) : 1; // Mercenary only can Devote owner
if( sd )
{ // Player Devoting Player
ARR_FIND(0, count, i, sd->devotion[i] == bl->id );
@@ -6109,22 +6136,17 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case MO_CALLSPIRITS:
if(sd) {
- int limit = skill_lv;
- if( sd->sc.data[SC_RAISINGDRAGON] )
- limit += sd->sc.data[SC_RAISINGDRAGON]->val1;
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- pc->addspiritball(sd,skill->get_time(skill_id,skill_lv),limit);
+ pc->addspiritball(sd, skill->get_time(skill_id, skill_lv), pc->getmaxspiritball(sd, 0));
}
break;
case CH_SOULCOLLECT:
if(sd) {
- int limit = 5, i;
- if( sd->sc.data[SC_RAISINGDRAGON] )
- limit += sd->sc.data[SC_RAISINGDRAGON]->val1;
+ int i, limit = pc->getmaxspiritball(sd, 5);
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- for (i = 0; i < limit; i++)
- pc->addspiritball(sd,skill->get_time(skill_id,skill_lv),limit);
+ for ( i = 0; i < limit; i++ )
+ pc->addspiritball(sd, skill->get_time(skill_id, skill_lv), limit);
}
break;
@@ -6146,7 +6168,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
{
int sp = 0;
if ( dstsd && dstsd->spiritball
- && (sd == dstsd || map_flag_vs(src->m) || (sd->duel_group && sd->duel_group == dstsd->duel_group))
+ && (sd == dstsd || map_flag_vs(src->m) || (sd && 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]
@@ -6216,7 +6238,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
count = map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src),
src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id);
if( !count && ( skill_id == NC_AXETORNADO || skill_id == SR_SKYNETBLOW || skill_id == KO_HAPPOKUNAI ) )
- clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
}
break;
@@ -6268,7 +6290,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
{
//Self Destruction hits everyone in range (allies+enemies)
//Except for Summoned Marine spheres on non-versus maps, where it's just enemy.
- int targetmask = ((!md || md->special_state.ai == 2) && !map_flag_vs(src->m))?
+ int targetmask = ((!md || md->special_state.ai == AI_SPHERE) && !map_flag_vs(src->m))?
BCT_ENEMY:BCT_ALL;
clif->skill_nodamage(src, src, skill_id, -1, 1);
map->delblock(src); //Required to prevent chain-self-destructions hitting back.
@@ -6439,7 +6461,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
// custom hack to make the mob display the skill, because these skills don't show the skill use text themselves
//NOTE: mobs don't have the sprite animation that is used when performing this skill (will cause glitches)
char temp[70];
- snprintf(temp, sizeof(temp), "%s : %s !!",md->name,skill->db[skill_id].desc);
+ snprintf(temp, sizeof(temp), "%s : %s !!",md->name,skill->dbs->db[skill_id].desc);
clif->disp_overhead(&md->bl,temp);
}
break;
@@ -6554,6 +6576,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
status_change_end(bl, SC_STUN, INVALID_TIMER);
status_change_end(bl, SC_WHITEIMPRISON, INVALID_TIMER);
}
+ status_change_end(bl, SC_NETHERWORLD, INVALID_TIMER);
//Is this equation really right? It looks so... special.
if( battle->check_undead(tstatus->race,tstatus->def_ele) ) {
status->change_start(src, bl, SC_BLIND,
@@ -6636,7 +6659,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
return 1;
}
if( sd->skillitem != skill_id )
- status_zap(src,0,skill->db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded
+ status_zap(src,0,skill->dbs->db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded
}
break;
@@ -6814,13 +6837,13 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if( sd ) {
int x,bonus=100, potion = min(500+skill_lv,505);
x = skill_lv%11 - 1;
- i = pc->search_inventory(sd,skill->db[skill_id].itemid[x]);
- if (i == INDEX_NOT_FOUND || skill->db[skill_id].itemid[x] <= 0) {
+ i = pc->search_inventory(sd,skill->dbs->db[skill_id].itemid[x]);
+ if (i == INDEX_NOT_FOUND || skill->dbs->db[skill_id].itemid[x] <= 0) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
map->freeblock_unlock();
return 1;
}
- if(sd->inventory_data[i] == NULL || sd->status.inventory[i].amount < skill->db[skill_id].amount[x]) {
+ if(sd->inventory_data[i] == NULL || sd->status.inventory[i].amount < skill->dbs->db[skill_id].amount[x]) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
map->freeblock_unlock();
return 1;
@@ -6917,44 +6940,24 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
}
break;
case AM_CP_WEAPON:
- if(dstsd && dstsd->inventory_data[dstsd->equip_index[EQI_HAND_R]])
- 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 {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- return 0;
- }
- break;
- case AM_CP_SHIELD: {
- int 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)));
- else {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- return 0;
- }
- }
- break;
+ case AM_CP_SHIELD:
case AM_CP_ARMOR:
- if(dstsd && dstsd->inventory_data[dstsd->equip_index[EQI_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)));
- else {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- return 0;
- }
- break;
case AM_CP_HELM:
- if(dstsd && dstsd->inventory_data[dstsd->equip_index[EQI_HEAD_TOP]])
- 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 {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ {
+ unsigned int equip[] = { EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HEAD_TOP };
+ int index;
+ if ( sd && (bl->type != BL_PC || (dstsd && pc->checkequip(dstsd, equip[skill_id - AM_CP_WEAPON]) < 0) ||
+ (dstsd && equip[skill_id - AM_CP_WEAPON] == EQP_SHIELD && pc->checkequip(dstsd, EQP_SHIELD) > 0
+ && (index = dstsd->equip_index[EQI_HAND_L]) >= 0 && dstsd->inventory_data[index]
+ && dstsd->inventory_data[index]->type != IT_ARMOR)) ) {
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
+ map->freeblock_unlock(); // Don't consume item requirements
return 0;
}
+ clif->skill_nodamage(src, bl, skill_id, skill_lv,
+ sc_start(src, bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)));
break;
+ }
case AM_TWILIGHT1:
if (sd) {
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
@@ -7382,14 +7385,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case WE_MALE:
{
- int hp_rate = (!skill_lv)? 0:skill->db[skill_id].hp_rate[skill_lv-1];
+ int hp_rate = (!skill_lv)? 0:skill->dbs->db[skill_id].hp_rate[skill_lv-1];
int gain_hp = tstatus->max_hp*abs(hp_rate)/100; // The earned is the same % of the target HP than it cost the caster. [Skotlex]
clif->skill_nodamage(src,bl,skill_id,status->heal(bl, gain_hp, 0, 0),1);
}
break;
case WE_FEMALE:
{
- int sp_rate = (!skill_lv)? 0:skill->db[skill_id].sp_rate[skill_lv-1];
+ int sp_rate = (!skill_lv)? 0:skill->dbs->db[skill_id].sp_rate[skill_lv-1];
int gain_sp = tstatus->max_sp*abs(sp_rate)/100;// The earned is the same % of the target SP than it cost the caster. [Skotlex]
clif->skill_nodamage(src,bl,skill_id,status->heal(bl, 0, gain_sp, 0),1);
}
@@ -7453,15 +7456,15 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
int i;
// get back all items used to deploy the trap
for( i = 0; i < 10; i++ ) {
- if( skill->db[su->group->skill_id].itemid[i] > 0 ) {
+ if( skill->dbs->db[su->group->skill_id].itemid[i] > 0 ) {
int success;
struct item item_tmp;
memset(&item_tmp,0,sizeof(item_tmp));
- item_tmp.nameid = skill->db[su->group->skill_id].itemid[i];
+ item_tmp.nameid = skill->dbs->db[su->group->skill_id].itemid[i];
item_tmp.identify = 1;
- if( item_tmp.nameid && (success=pc->additem(sd,&item_tmp,skill->db[su->group->skill_id].amount[i],LOG_TYPE_OTHER)) ) {
+ if( item_tmp.nameid && (success=pc->additem(sd,&item_tmp,skill->dbs->db[su->group->skill_id].amount[i],LOG_TYPE_OTHER)) ) {
clif->additem(sd,0,0,success);
- map->addflooritem(&item_tmp,skill->db[su->group->skill_id].amount[i],sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ map->addflooritem(&item_tmp,skill->dbs->db[su->group->skill_id].amount[i],sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
}
@@ -7638,28 +7641,27 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
}
break;
// Full Chemical Protection
- case CR_FULLPROTECTION: {
- bool iused=false;
- int i;
- 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] &&
- 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)));
- } if(dstsd && dstsd->inventory_data[dstsd->equip_index[EQI_ARMOR]]) {
- iused=true;
- clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(src,bl,SC_PROTECTARMOR,100,skill_lv,skill->get_time(skill_id,skill_lv)));
- } if(dstsd && dstsd->inventory_data[dstsd->equip_index[EQI_HEAD_TOP]]) {
- iused=true;
- clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(src,bl,SC_PROTECTHELM,100,skill_lv,skill->get_time(skill_id,skill_lv)));
- } if(iused)
- clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- else {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ case CR_FULLPROTECTION:
+ {
+ unsigned int equip[] = { EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HEAD_TOP };
+ int i, s = 0, skilltime = skill->get_time(skill_id, skill_lv);
+ for ( i = 0; i < 4; i++ ) {
+ if ( bl->type != BL_PC || (dstsd && pc->checkequip(dstsd, equip[i]) < 0) )
+ continue;
+ if ( dstsd && equip[i] == EQP_SHIELD ) {
+ short index = dstsd->equip_index[EQI_HAND_L];
+ if ( index >= 0 && dstsd->inventory_data[index] && dstsd->inventory_data[index]->type != IT_ARMOR )
+ continue;
+ }
+ sc_start(src, bl, (sc_type)(SC_PROTECTWEAPON + i), 100, skill_lv, skilltime);
+ s++;
+ }
+ if ( sd && !s ) {
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
+ map->freeblock_unlock(); // Don't consume item requirements
return 0;
}
+ clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
}
break;
@@ -7692,7 +7694,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
map->freeblock_unlock();
return 0;
}
- status_zap(src,0,skill->db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded [Inkfish]
+ status_zap(src,0,skill->dbs->db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded [Inkfish]
do {
int eff = rnd() % 14;
if( eff == 5 )
@@ -7713,7 +7715,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case 3: // 1000 damage, random armor destroyed
{
status_fix_damage(src, bl, 1000, 0);
- clif->damage(src,bl,0,0,1000,0,0,0);
+ clif->damage(src,bl,0,0,1000,0,BDT_NORMAL,0);
if( !status->isdead(bl) ) {
int where[] = { EQP_ARMOR, EQP_SHIELD, EQP_HELM, EQP_SHOES, EQP_GARMENT };
skill->break_equip(bl, where[rnd()%5], 10000, BCT_ENEMY);
@@ -7750,14 +7752,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
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);
+ clif->damage(src,bl,0,0,6666,0,BDT_NORMAL,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
status_fix_damage(src, bl, 4444, 0);
- clif->damage(src,bl,0,0,4444,0,0,0);
+ clif->damage(src,bl,0,0,4444,0,BDT_NORMAL,0);
break;
case 12: // stun
sc_start(src,bl,SC_STUN,100,skill_lv,5000);
@@ -8135,7 +8137,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case LG_EARTHDRIVE:
{
int splash;
- clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
splash = skill->get_splash(skill_id,skill_lv);
if( skill_id == LG_EARTHDRIVE ) {
int dummy = 1;
@@ -8316,7 +8318,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case GC_PHANTOMMENACE:
{
int r;
- clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
r = skill->get_splash(skill_id, skill_lv);
map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,
@@ -8612,7 +8614,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
* Ranger
**/
case RA_FEARBREEZE:
- clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
clif->skill_nodamage(src, bl, skill_id, skill_lv, sc_start(src, bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)));
break;
@@ -8653,7 +8655,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case RA_SENSITIVEKEEN:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY,skill->castend_damage_id);
break;
/**
@@ -8680,7 +8682,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
case NC_ANALYZE:
- clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
clif->skill_nodamage(src, bl, skill_id, skill_lv,
sc_start(src,bl,type, 30 + 12 * skill_lv,skill_lv,skill->get_time(skill_id,skill_lv)));
if( sd ) pc->overheat(sd,1);
@@ -8692,7 +8694,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if( (failure = sc_start2(src,bl,type,100,skill_lv,src->id,skill->get_time(skill_id,skill_lv))) )
{
map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),splash_target(src),src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_SPLASH|1,skill->castend_damage_id);;
- clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,6);
+ clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,BDT_SKILL);
if (sd) pc->overheat(sd,1);
}
clif->skill_nodamage(src,src,skill_id,skill_lv,failure);
@@ -8812,7 +8814,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
case LG_TRAMPLE:
- clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
map->foreachinrange(skill->destroy_trap,bl,skill->get_splash(skill_id,skill_lv),BL_SKILL,tick);
break;
@@ -8850,7 +8852,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
switch( opt ) {
case 1:
sc_start(src,bl,SC_SHIELDSPELL_DEF,100,opt,INVALID_TIMER); //Splash AoE ATK
- clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
map->foreachinrange(skill->area_sub,src,splashrange,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
status_change_end(bl,SC_SHIELDSPELL_DEF,INVALID_TIMER);
break;
@@ -8877,13 +8879,13 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
switch( opt ) {
case 1:
sc_start(src,bl,SC_SHIELDSPELL_MDEF,100,opt,INVALID_TIMER); //Splash AoE MATK
- clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
map->foreachinrange(skill->area_sub,src,splashrange,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
status_change_end(bl,SC_SHIELDSPELL_MDEF,INVALID_TIMER);
break;
case 2:
sc_start(src,bl,SC_SHIELDSPELL_MDEF,100,opt,sd->bonus.shieldmdef * 2000); //Splash AoE Lex Divina
- clif->skill_damage(src,bl,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,6);
+ clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
map->foreachinrange(skill->area_sub,src,splashrange,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_nodamage_id);
break;
case 3:
@@ -8996,7 +8998,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
}
} else {
int count = 0;
- clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
count = map->forcountinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv), (sd)?sd->spiritball_old:15, // Assume 15 spiritballs in non-characters
BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id);
if( sd ) pc->delspiritball(sd, count, 0);
@@ -9006,13 +9008,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
case SR_RAISINGDRAGON:
- if( sd ) {
- short max = 5 + skill_lv;
- int i;
+ if ( sd ) {
+ int i, max;
sc_start(src, bl, SC_EXPLOSIONSPIRITS, 100, skill_lv, skill->get_time(skill_id, skill_lv));
- for( i = 0; i < max; i++ ) // Don't call more than max available spheres.
- pc->addspiritball(sd, skill->get_time(skill_id, skill_lv), max);
- clif->skill_nodamage(src, bl, skill_id, skill_lv, sc_start(src, bl, type, 100, skill_lv,skill->get_time(skill_id, skill_lv)));
+ clif->skill_nodamage(src, bl, skill_id, skill_lv,
+ sc_start(src, bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)));
+ max = pc->getmaxspiritball(sd, 0);
+ for ( i = 0; i < max; i++ )
+ pc->addspiritball(sd, skill->get_time(MO_CALLSPIRITS, skill_lv), max);
}
break;
@@ -9030,7 +9033,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
}
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);
+ clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF|SD_SPLASH|1, skill->castend_nodamage_id);
}
break;
@@ -9038,12 +9041,12 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case SR_POWERVELOCITY:
if( !dstsd )
break;
- if( sd && dstsd->spiritball <= 5 ) {
- int i;
- for(i = 0; i <= 5; i++) {
- pc->addspiritball(dstsd, skill->get_time(MO_CALLSPIRITS, pc->checkskill(sd,MO_CALLSPIRITS)), i);
- pc->delspiritball(sd, sd->spiritball, 0);
+ if ( sd && (dstsd->class_&MAPID_BASEMASK) != MAPID_GUNSLINGER ) {
+ int i, max = pc->getmaxspiritball(dstsd, 5);
+ for ( i = 0; i < max; i++ ) {
+ pc->addspiritball(dstsd, skill->get_time(MO_CALLSPIRITS, 1), max);
}
+ pc->delspiritball(sd, sd->spiritball, 0);
}
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
break;
@@ -9199,7 +9202,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
madnesscheck = map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->area_sub_count);
sc_start(src, bl, type, 100, skill_lv,skill->get_time(skill_id, skill_lv));
if ( madnesscheck >= 8 )//The god of madness deals 9999 fixed unreduceable damage when 8 or more enemy players are affected.
- status_fix_damage(src, bl, 9999, clif->damage(src, bl, 0, 0, 9999, 0, 0, 0));
+ status_fix_damage(src, bl, 9999, clif->damage(src, bl, 0, 0, 9999, 0, BDT_NORMAL, 0));
//skill->attack(BF_MISC,src,src,bl,skillid,skilllv,tick,flag);//To renable when I can confirm it deals damage like this. Data shows its dealt as reflected damage which I don't have it coded like that yet. [Rytech]
} else if( sd ) {
int rate = sstatus->int_ / 6 + (sd? sd->status.job_level:0) / 5 + skill_lv * 4;
@@ -9230,8 +9233,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
int improv_skill_id = 0, improv_skill_lv, improv_idx;
do {
improv_idx = rnd() % MAX_SKILL_IMPROVISE_DB;
- improv_skill_id = skill->improvise_db[improv_idx].skill_id;
- } while( improv_skill_id == 0 || rnd()%10000 >= skill->improvise_db[improv_idx].per );
+ improv_skill_id = skill->dbs->improvise_db[improv_idx].skill_id;
+ } while( improv_skill_id == 0 || rnd()%10000 >= skill->dbs->improvise_db[improv_idx].per );
improv_skill_lv = 4 + skill_lv;
clif->skill_nodamage (src, bl, skill_id, skill_lv, 1);
@@ -9335,7 +9338,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, 0, 1, skill_id, -2, 6);
+ clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, 0, 1, skill_id, -2, BDT_SKILL);
break;
case GM_SANDMAN:
@@ -9560,7 +9563,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
elemental->clean_single_effect(ele, skill_id);
} 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);
+ 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, BDT_SKILL);
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));
@@ -9575,7 +9578,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case EL_ZEPHYR:
case EL_POWER_OF_GAIA:
clif->skill_nodamage(src,src,skill_id,skill_lv,1);
- clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
skill->unitsetting(src,skill_id,skill_lv,bl->x,bl->y,0);
break;
@@ -9591,7 +9594,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
elemental->clean_single_effect(ele, skill_id);
} else {
// This not heals at the end.
- clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
sc_start(src, src,type2,100,skill_lv,skill->get_time(skill_id,skill_lv));
sc_start(src, bl,type,100,src->id,skill->get_time(skill_id,skill_lv));
}
@@ -9668,8 +9671,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
clif->skill_nodamage(src, src, skill_id, skill_lv, 1);
clif->slide(src, bl->x, bl->y) ;
sc_start(src, src, SC_CONFUSION, 25, skill_lv, skill->get_time(skill_id, skill_lv));
- if ( !is_boss(bl) && unit->stop_walking(&sd->bl, 1) && unit->movepos(bl, x, y, 0, 0) )
- {
+ if ( !is_boss(bl) && unit->stop_walking(&sd->bl, STOPWALKING_FLAG_FIXPOS) && unit->movepos(bl, x, y, 0, 0) ) {
if( dstsd && pc_issit(dstsd) )
pc->setstand(dstsd);
clif->slide(bl, x, y) ;
@@ -9692,7 +9694,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case KG_KAGEMUSYA:
clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start(src, bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
- clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
break;
case KG_KAGEHUMI:
@@ -9711,7 +9713,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
status_change_end(bl, SC_HARMONIZE, INVALID_TIMER);
}
if( skill->area_temp[2] == 1 ){
- clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
sc_start(src, src, SC_STOP, 100, skill_lv, skill->get_time(skill_id, skill_lv));
}
} else {
@@ -9889,7 +9891,7 @@ int skill_castend_pos(int tid, int64 tick, int id, intptr_t data)
if( sd && ud->skilltimer != INVALID_TIMER && ( pc->checkskill(sd,SA_FREECAST) > 0 || ud->skill_id == LG_EXEEDBREAK ) )
{// restore original walk speed
ud->skilltimer = INVALID_TIMER;
- status_calc_bl(&sd->bl, SCB_SPEED);
+ status_calc_bl(&sd->bl, SCB_SPEED|SCB_ASPD);
}
ud->skilltimer = INVALID_TIMER;
@@ -9965,7 +9967,7 @@ int skill_castend_pos(int tid, int64 tick, int id, intptr_t data)
src->type, src->id, ud->skill_id, ud->skill_lv, ud->skillx, ud->skilly);
if (ud->walktimer != INVALID_TIMER)
- unit->stop_walking(src,1);
+ unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS);
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);
@@ -10527,9 +10529,9 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case CR_SLIMPITCHER:
if (sd) {
int i = skill_lv%11 - 1;
- int j = pc->search_inventory(sd,skill->db[skill_id].itemid[i]);
- if (j == INDEX_NOT_FOUND || skill->db[skill_id].itemid[i] <= 0
- || sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < skill->db[skill_id].amount[i]
+ int j = pc->search_inventory(sd,skill->dbs->db[skill_id].itemid[i]);
+ if (j == INDEX_NOT_FOUND || skill->dbs->db[skill_id].itemid[i] <= 0
+ || sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < skill->dbs->db[skill_id].amount[i]
) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 1;
@@ -10558,7 +10560,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
} else {
int i = skill_lv%11 - 1;
struct item_data *item;
- i = skill->db[skill_id].itemid[i];
+ i = skill->dbs->db[skill_id].itemid[i];
item = itemdb->search(i);
script->potion_flag = 1;
script->potion_hp = 0;
@@ -10661,7 +10663,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
break;
case RK_WINDCUTTER:
- clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
/* Fall through */
case NC_COLDSLOWER:
case RK_DRAGONBREATH:
@@ -10701,7 +10703,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
clif->skill_fail(sd,skill_id,USESKILL_FAIL_GC_POISONINGWEAPON,0);
return 0;
}
- clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,6);
+ clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,BDT_SKILL);
skill->unitsetting(src, skill_id, skill_lv, x, y, flag);
//status_change_end(src,SC_POISONINGWEAPON,INVALID_TIMER); // 08/31/2011 - When using poison smoke, you no longer lose the poisoning weapon effect.
break;
@@ -10738,7 +10740,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case RA_DETONATOR:
r = skill->get_splash(skill_id, skill_lv);
map->foreachinarea(skill->detonator, src->m, x-r, y-r, x+r, y+r, BL_SKILL, src);
- clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
break;
/**
* Mechanic
@@ -11074,6 +11076,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_
* According to data provided in RE, SW life is equal to 3 times caster's health
**/
val2 = status_get_max_hp(src) * 3;
+ val3 = skill_lv+1;
#else
val2 = skill_lv+1;
#endif
@@ -11389,7 +11392,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_
}
break;
case NPC_EARTHQUAKE:
- clif->skill_damage(src, src, timer->gettick(), status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
+ clif->skill_damage(src, src, timer->gettick(), status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL);
break;
default:
skill->unitsetting1_unknown(src, &skill_id, &skill_lv, &x, &y, &flag, &val1, &val2, &val3);
@@ -11785,7 +11788,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
struct skill_unit_group *sg;
struct block_list *ss;
TBL_PC* tsd;
- struct status_data *tstatus;
+ struct status_data *tstatus, *bst;
struct status_change *tsc, *ssc;
struct skill_unit_group_tickset *ts;
enum sc_type type;
@@ -11809,6 +11812,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
return 0;
tstatus = status->get_status_data(bl);
+ bst = status->get_base_status(bl);
type = status->skill2sc(sg->skill_id);
skill_id = sg->skill_id;
@@ -12346,10 +12350,11 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
skill->attack(BF_WEAPON,ss,&src->bl,bl,WM_SEVERE_RAINSTORM_MELEE,sg->skill_lv,tick,0);
break;
case UNT_NETHERWORLD:
- if( !(status_get_mode(bl)&MD_BOSS)) {
- if( !(tsc && tsc->data[type]) ){
- sc_start(ss, bl, type, 100, sg->skill_lv, skill->get_time2(sg->skill_id,sg->skill_lv));
- }
+ if ( battle->check_target(&src->bl, bl, BCT_PARTY) == -1 && bl->id != sg->src_id ) {
+ sc_start(ss, bl, type, 100, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
+ sg->limit = 0;
+ clif->changetraplook(&src->bl, UNT_USED_TRAPS);
+ sg->unit_id = UNT_USED_TRAPS;
}
break;
case UNT_THORNS_TRAP:
@@ -12420,7 +12425,6 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
hp = tstatus->max_hp * 3 * sg->skill_lv / 100;
else
hp = tstatus->max_hp * sg->skill_lv / 100;
- status->heal(bl, hp, 0, 0);
if( tstatus->hp != tstatus->max_hp )
clif->skill_nodamage(&src->bl, bl, AL_HEAL, hp, 0);
if( tsc && tsc->data[SC_AKAITSUKI] && hp )
@@ -12457,7 +12461,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6
if (tsc && (tsc->data[SC_HALLUCINATIONWALK] || tsc->data[SC_VACUUM_EXTREME])) {
return 0;
} else {
- sg->limit -= 100 * tstatus->str/20;
+ sg->limit -= 1000 * bst->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) ) {
@@ -12924,7 +12928,8 @@ int skill_check_condition_mob_master_sub (struct block_list *bl, va_list ap) {
mob_class=va_arg(ap,int);
skill_id=va_arg(ap,int);
c=va_arg(ap,int *);
- if( md->master_id != src_id || md->special_state.ai != (unsigned)(skill_id == AM_SPHEREMINE?2:skill_id == KO_ZANZOU?4:skill_id == MH_SUMMON_LEGION?1:3) )
+ if( md->master_id != src_id
+ || md->special_state.ai != (skill_id == AM_SPHEREMINE?AI_SPHERE:skill_id == KO_ZANZOU?AI_ZANZOU:skill_id == MH_SUMMON_LEGION?AI_ATTACK:AI_FLORA) )
return 0; //Non alchemist summoned mobs have nothing to do here.
if(md->class_==mob_class)
(*c)++;
@@ -13038,8 +13043,8 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
sd->itemid = sd->itemindex = -1;
if( skill_id == WZ_EARTHSPIKE && sc && sc->data[SC_EARTHSCROLL] && rnd()%100 > sc->data[SC_EARTHSCROLL]->val2 ) // [marquis007]
; //Do not consume item.
- else if( sd->status.inventory[i].expire_time == 0 )
- pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME); // Rental usable items are not consumed until expiration
+ else if( sd->status.inventory[i].expire_time == 0 ) // Rental usable items are not consumed until expiration
+ pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME);
}
return 1;
}
@@ -13644,7 +13649,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
MOBID_EMPERIUM, MOBID_GUARIDAN_STONE1, MOBID_GUARIDAN_STONE2)) {
char output[128];
sprintf(output, "You're too close to a stone or emperium to do this skill"); /* TODO official response? or message.conf it */
- clif->colormes(sd->fd, COLOR_RED, output);
+ clif->messagecolor_self(sd->fd, COLOR_RED, output);
return 0;
}
}
@@ -14078,7 +14083,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id,
skill->get_desc(skill_id),
require.ammo_qty,
itemdb_jname(sd->status.inventory[i].nameid));
- clif->colormes(sd->fd,COLOR_RED,e_msg);
+ clif->messagecolor_self(sd->fd, COLOR_RED, e_msg);
return 0;
}
if (!(require.ammo&1<<sd->inventory_data[i]->look)) { //Ammo type check. Send the "wrong weapon type" message
@@ -14214,7 +14219,7 @@ int skill_consume_requirement( struct map_session_data *sd, uint16 skill_id, uin
}
if ((n = pc->search_inventory(sd,req.itemid[i])) != INDEX_NOT_FOUND)
- pc->delitem(sd,n,req.amount[i],0,1,LOG_TYPE_CONSUME);
+ pc->delitem(sd, n, req.amount[i], 0, DELITEM_SKILLUSE, LOG_TYPE_CONSUME);
}
}
@@ -14280,17 +14285,17 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
st = &sd->battle_status;
- req.hp = skill->db[idx].hp[skill_lv-1];
- hp_rate = skill->db[idx].hp_rate[skill_lv-1];
+ req.hp = skill->dbs->db[idx].hp[skill_lv-1];
+ hp_rate = skill->dbs->db[idx].hp_rate[skill_lv-1];
if(hp_rate > 0)
req.hp += (st->hp * hp_rate)/100;
else
req.hp += (st->max_hp * (-hp_rate))/100;
- req.sp = skill->db[idx].sp[skill_lv-1];
+ req.sp = skill->dbs->db[idx].sp[skill_lv-1];
if((sd->skill_id_old == BD_ENCORE) && skill_id == sd->skill_id_dance)
req.sp /= 2;
- sp_rate = skill->db[idx].sp_rate[skill_lv-1];
+ sp_rate = skill->dbs->db[idx].sp_rate[skill_lv-1];
if(sp_rate > 0)
req.sp += (st->sp * sp_rate)/100;
else
@@ -14318,22 +14323,22 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
req.sp -= req.sp * sc->data[SC_TELEKINESIS_INTENSE]->val2 / 100;
}
- req.zeny = skill->db[idx].zeny[skill_lv-1];
+ req.zeny = skill->dbs->db[idx].zeny[skill_lv-1];
if( sc && sc->data[SC__UNLUCKY] )
req.zeny += sc->data[SC__UNLUCKY]->val1 * 500;
- req.spiritball = skill->db[idx].spiritball[skill_lv-1];
+ req.spiritball = skill->dbs->db[idx].spiritball[skill_lv-1];
- req.state = skill->db[idx].state;
+ req.state = skill->dbs->db[idx].state;
- req.mhp = skill->db[idx].mhp[skill_lv-1];
+ req.mhp = skill->dbs->db[idx].mhp[skill_lv-1];
- req.weapon = skill->db[idx].weapon;
+ req.weapon = skill->dbs->db[idx].weapon;
- req.ammo_qty = skill->db[idx].ammo_qty[skill_lv-1];
+ req.ammo_qty = skill->dbs->db[idx].ammo_qty[skill_lv-1];
if (req.ammo_qty)
- req.ammo = skill->db[idx].ammo;
+ req.ammo = skill->dbs->db[idx].ammo;
if (!req.ammo && skill_id && skill->isammotype(sd, skill_id)) {
//Assume this skill is using the weapon, therefore it requires arrows.
@@ -14359,11 +14364,11 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
continue;
break;
case AB_ADORAMUS:
- if( itemid_isgemstone(skill->db[idx].itemid[i]) && skill->check_pc_partner(sd,skill_id,&skill_lv, 1, 2) )
+ if( itemid_isgemstone(skill->dbs->db[idx].itemid[i]) && skill->check_pc_partner(sd,skill_id,&skill_lv, 1, 2) )
continue;
break;
case WL_COMET:
- if( itemid_isgemstone(skill->db[idx].itemid[i]) && skill->check_pc_partner(sd,skill_id,&skill_lv, 1, 0) )
+ if( itemid_isgemstone(skill->dbs->db[idx].itemid[i]) && skill->check_pc_partner(sd,skill_id,&skill_lv, 1, 0) )
continue;
break;
case GN_FIRE_EXPANSION:
@@ -14389,8 +14394,8 @@ 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];
+ req.itemid[i] = skill->dbs->db[idx].itemid[i];
+ req.amount[i] = skill->dbs->db[idx].amount[i];
if (itemid_isgemstone(req.itemid[i]) && skill_id != HW_GANBANTEIN) {
if (sd->special_state.no_gemstone) {
@@ -14432,8 +14437,8 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
case SO_FIRE_INSIGNIA:
case SO_WIND_INSIGNIA:
case SO_EARTH_INSIGNIA:
- req.itemid[skill_lv-1] = skill->db[idx].itemid[skill_lv-1];
- req.amount[skill_lv-1] = skill->db[idx].amount[skill_lv-1];
+ req.itemid[skill_lv-1] = skill->dbs->db[idx].itemid[skill_lv-1];
+ req.amount[skill_lv-1] = skill->dbs->db[idx].amount[skill_lv-1];
break;
}
if (skill_id == NC_REPAIR) {
@@ -14737,8 +14742,11 @@ int skill_vfcastfix(struct block_list *bl, double time, uint16 skill_id, uint16
fixcast_r = max(fixcast_r, sc->data[SC_DANCE_WITH_WUG]->val4);
if( sc->data[SC_SECRAMENT] )
fixcast_r = max(fixcast_r, sc->data[SC_SECRAMENT]->val2);
- if( sd && ( skill_lv = pc->checkskill(sd, WL_RADIUS) ) && (skill_id >= WL_WHITEIMPRISON && skill_id < WL_FREEZE_SP) )
- fixcast_r = max(fixcast_r, (status_get_int(bl) + status->get_lv(bl)) / 15 + skill_lv * 5); // [{(Caster?s INT / 15) + (Caster?s Base Level / 15) + (Radius Skill Level x 5)}] %
+ if (sd && skill_id >= WL_WHITEIMPRISON && skill_id < WL_FREEZE_SP) {
+ int radius_lv = pc->checkskill(sd, WL_RADIUS);
+ if (radius_lv)
+ fixcast_r = max(fixcast_r, (status_get_int(bl) + status->get_lv(bl)) / 15 + radius_lv * 5); // [{(Caster?s INT / 15) + (Caster?s Base Level / 15) + (Radius Skill Level x 5)}] %
+ }
// Fixed cast non percentage bonuses
if( sc->data[SC_MANDRAGORA] )
fixed += sc->data[SC_MANDRAGORA]->val1 * 500;
@@ -15078,7 +15086,7 @@ void skill_repairweapon (struct map_session_data *sd, int idx) {
clif->equiplist(target_sd);
- pc->delitem(sd,pc->search_inventory(sd,material),1,0,0,LOG_TYPE_CONSUME);
+ pc->delitem(sd, pc->search_inventory(sd, material), 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME); // FIXME: is this the correct reason flag?
clif->item_repaireffect(sd,idx,0);
@@ -15147,7 +15155,7 @@ void skill_weaponrefine (struct map_session_data *sd, int idx)
else
per += 5 * ((signed int)sd->status.job_level - 50);
- pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
+ pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_OTHER); // FIXME: is this the correct reason flag?
if (per > rnd() % 1000) {
int ep = 0;
logs->pick_pc(sd, LOG_TYPE_OTHER, -1, item, ditem);
@@ -15155,9 +15163,9 @@ void skill_weaponrefine (struct map_session_data *sd, int idx)
logs->pick_pc(sd, LOG_TYPE_OTHER, 1, item, ditem);
if(item->equip) {
ep = item->equip;
- pc->unequipitem(sd,idx,3);
+ pc->unequipitem(sd, idx, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
}
- clif->delitem(sd,idx,1,0);
+ clif->delitem(sd, idx, 1, DELITEM_NORMAL);
clif->upgrademessage(sd->fd, 0,item->nameid);
clif->inventorylist(sd);
clif->refine(sd->fd,0,idx,item->refine);
@@ -15183,9 +15191,9 @@ void skill_weaponrefine (struct map_session_data *sd, int idx)
} else {
item->refine = 0;
if(item->equip)
- pc->unequipitem(sd,idx,3);
+ pc->unequipitem(sd, idx, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
clif->refine(sd->fd,1,idx,item->refine);
- pc->delitem(sd,idx,1,0,0, LOG_TYPE_OTHER);
+ pc->delitem(sd, idx, 1, 0, DELITEM_NORMAL, LOG_TYPE_OTHER);
clif->misceffect(&sd->bl,2);
clif->emotion(&sd->bl, E_OMG);
}
@@ -15488,7 +15496,6 @@ int skill_graffitiremover (struct block_list *bl, va_list ap) {
struct skill_unit *su=NULL;
nullpo_ret(bl);
- nullpo_ret(ap);
if(bl->type != BL_SKILL)
return 0;
@@ -15519,7 +15526,6 @@ int skill_detonator(struct block_list *bl, va_list ap) {
int unit_id;
nullpo_ret(bl);
- nullpo_ret(ap);
src = va_arg(ap,struct block_list *);
if( bl->type != BL_SKILL )
@@ -15725,7 +15731,7 @@ int skill_trap_splash(struct block_list *bl, va_list ap) {
skill->blown(src,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),-1,0);
break;
case UNT_ELECTRICSHOCKER:
- clif->skill_damage(src,bl,tick,0,0,-30000,1,sg->skill_id,sg->skill_lv,5);
+ clif->skill_damage(src,bl,tick,0,0,-30000,1,sg->skill_id,sg->skill_lv,BDT_SPLASH);
break;
case UNT_MAGENTATRAP:
case UNT_COBALTTRAP:
@@ -15912,7 +15918,7 @@ bool skill_check_shadowform(struct block_list *bl, int64 damage, int hit)
return false;
}
- status->damage(bl, src, damage, 0, clif->damage(src, src, 500, 500, damage, hit, (hit > 1 ? 8 : 0), 0), 0);
+ status->damage(bl, src, damage, 0, clif->damage(src, src, 500, 500, damage, hit, (hit > 1 ? BDT_MULTIHIT : BDT_NORMAL), 0), 0);
/* because damage can cancel it */
if( sc->data[SC__SHADOWFORM] && (--sc->data[SC__SHADOWFORM]->val3) <= 0 ) {
@@ -15945,7 +15951,8 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int
su->group=group;
su->alive=1;
su->val1=val1;
- su->val2=val2;
+ su->val2 = val2;
+ su->prev = 0;
idb_put(skill->unit_db, su->bl.id, su);
map->addiddb(&su->bl);
@@ -16539,7 +16546,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) {
dissonance = skill->dance_switch(su, 0);
- if( su->range >= 0 && group->interval != -1 ) {
+ if( su->range >= 0 && group->interval != -1 && su->bl.id != su->prev) {
if( battle_config.skill_wall_check )
map->foreachinshootrange(skill->unit_timer_sub_onplace, bl, su->range, group->bl_flag, bl,tick);
else
@@ -16555,6 +16562,8 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) {
group->bl_flag= BL_NUL;
}
}
+ if ( group->limit == group->interval )
+ su->prev = su->bl.id;
}
if( dissonance ) skill->dance_switch(su, 1);
@@ -16795,9 +16804,9 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger,
return 0;
for(i=0;i<MAX_SKILL_PRODUCE_DB;i++){
- if(skill->produce_db[i].nameid == nameid ){
- if((j=skill->produce_db[i].req_skill)>0 &&
- pc->checkskill(sd,j) < skill->produce_db[i].req_skill_lv)
+ if(skill->dbs->produce_db[i].nameid == nameid ){
+ if((j=skill->dbs->produce_db[i].req_skill)>0 &&
+ pc->checkskill(sd,j) < skill->dbs->produce_db[i].req_skill_lv)
continue; // must iterate again to check other skills that produce it. [malufett]
if( j > 0 && sd->menuskill_id > 0 && sd->menuskill_id != j )
continue; // special case
@@ -16815,22 +16824,22 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger,
if(trigger>=0){
if(trigger>20) { // Non-weapon, non-food item (itemlv must match)
- if(skill->produce_db[i].itemlv!=trigger)
+ if(skill->dbs->produce_db[i].itemlv!=trigger)
return 0;
} else if(trigger>10) { // Food (any item level between 10 and 20 will do)
- if(skill->produce_db[i].itemlv<=10 || skill->produce_db[i].itemlv>20)
+ if(skill->dbs->produce_db[i].itemlv<=10 || skill->dbs->produce_db[i].itemlv>20)
return 0;
} else { // Weapon (itemlv must be higher or equal)
- if(skill->produce_db[i].itemlv>trigger)
+ if(skill->dbs->produce_db[i].itemlv>trigger)
return 0;
}
}
for (j = 0; j < MAX_PRODUCE_RESOURCE; j++) {
- int id = skill->produce_db[i].mat_id[j];
+ int id = skill->dbs->produce_db[i].mat_id[j];
if (id <= 0)
continue;
- if (skill->produce_db[i].mat_amount[j] <= 0) {
+ if (skill->dbs->produce_db[i].mat_amount[j] <= 0) {
if (pc->search_inventory(sd,id) == INDEX_NOT_FOUND)
return 0;
} else {
@@ -16838,7 +16847,7 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger,
for(y=0,x=0;y<MAX_INVENTORY;y++)
if( sd->status.inventory[y].nameid == id )
x+=sd->status.inventory[y].amount;
- if(x<qty*skill->produce_db[i].mat_amount[j])
+ if(x<qty*skill->dbs->produce_db[i].mat_amount[j])
return 0;
}
}
@@ -16869,7 +16878,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
qty = 1;
if (!skill_id) //A skill can be specified for some override cases.
- skill_id = skill->produce_db[idx].req_skill;
+ skill_id = skill->dbs->produce_db[idx].req_skill;
if( skill_id == GC_RESEARCHNEWPOISON )
skill_id = GC_CREATENEWPOISON;
@@ -16886,12 +16895,12 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
if (j == INDEX_NOT_FOUND)
continue;
if( slot[i]==ITEMID_STAR_CRUMB ) {
- pc->delitem(sd,j,1,1,0,LOG_TYPE_PRODUCE);
+ pc->delitem(sd, j, 1, 1, DELITEM_NORMAL, LOG_TYPE_PRODUCE); // FIXME: is this the correct reason flag?
sc++;
}
if( slot[i] >= ITEMID_FLAME_HEART && slot[i] <= ITEMID_GREAT_NATURE && ele == 0 ) {
static const int ele_table[4]={3,1,4,2};
- pc->delitem(sd,j,1,1,0,LOG_TYPE_PRODUCE);
+ pc->delitem(sd, j, 1, 1, DELITEM_NORMAL, LOG_TYPE_PRODUCE); // FIXME: is this the correct reason flag?
ele=ele_table[slot[i]-994];
}
}
@@ -16908,7 +16917,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
for( i = 0; i < MAX_INVENTORY; i++ ) {
if( sd->status.inventory[i].nameid == nameid ) {
if( sd->status.inventory[i].amount >= data->stack.amount ) {
- clif->msgtable(sd->fd,0x61b);
+ clif->msgtable(sd, MSG_RUNE_STONE_MAX_AMOUNT);
return 0;
} else {
/**
@@ -16926,10 +16935,10 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
for(i=0;i<MAX_PRODUCE_RESOURCE;i++){
int j,id,x;
- if( (id=skill->produce_db[idx].mat_id[i]) <= 0 )
+ if( (id=skill->dbs->produce_db[idx].mat_id[i]) <= 0 )
continue;
num++;
- x=( skill_id == RK_RUNEMASTERY ? 1 : qty)*skill->produce_db[idx].mat_amount[i];
+ x=( skill_id == RK_RUNEMASTERY ? 1 : qty)*skill->dbs->produce_db[idx].mat_amount[i];
do{
int y=0;
j = pc->search_inventory(sd,id);
@@ -16937,7 +16946,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
if (j != INDEX_NOT_FOUND) {
y = sd->status.inventory[j].amount;
if(y>x)y=x;
- pc->delitem(sd,j,y,0,0,LOG_TYPE_PRODUCE);
+ pc->delitem(sd, j, y, 0, DELITEM_NORMAL, LOG_TYPE_PRODUCE); // FIXME: is this the correct reason flag?
} else
ShowError("skill_produce_mix: material item error\n");
@@ -17070,8 +17079,8 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
break;
case GN_CHANGEMATERIAL:
for(i=0; i<MAX_SKILL_PRODUCE_DB; i++)
- if( skill->changematerial_db[i].itemid == nameid ){
- make_per = skill->changematerial_db[i].rate * 10;
+ if( skill->dbs->changematerial_db[i].itemid == nameid ){
+ make_per = skill->dbs->changematerial_db[i].rate * 10;
break;
}
break;
@@ -17183,7 +17192,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
+ 20 * (sd->status.base_level + 1)
+ 20 * (st->dex + 1)
+ 100 * (rnd()%(30+5*(sd->cook_mastery/400) - (6+sd->cook_mastery/80)) + (6+sd->cook_mastery/80))
- - 400 * (skill->produce_db[idx].itemlv - 11 + 1)
+ - 400 * (skill->dbs->produce_db[idx].itemlv - 11 + 1)
- 10 * (100 - st->luk + 1)
- 500 * (num - 1)
- 100 * (rnd()%4 + 1);
@@ -17339,11 +17348,11 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
clif->misceffect(&sd->bl,5);
break;
default: //Those that don't require a skill?
- if( skill->produce_db[idx].itemlv > 10 && skill->produce_db[idx].itemlv <= 20)
+ if( skill->dbs->produce_db[idx].itemlv > 10 && skill->dbs->produce_db[idx].itemlv <= 20)
{ //Cooking items.
clif->specialeffect(&sd->bl, 608, AREA);
if( sd->cook_mastery < 1999 )
- pc_setglobalreg(sd, script->add_str("COOK_MASTERY"),sd->cook_mastery + ( 1 << ( (skill->produce_db[idx].itemlv - 11) / 2 ) ) * 5);
+ pc_setglobalreg(sd, script->add_str("COOK_MASTERY"),sd->cook_mastery + ( 1 << ( (skill->dbs->produce_db[idx].itemlv - 11) / 2 ) ) * 5);
}
break;
}
@@ -17351,10 +17360,10 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
if ( skill_id == GN_CHANGEMATERIAL && tmp_item.amount) { //Success
int j, k = 0;
for(i=0; i<MAX_SKILL_PRODUCE_DB; i++)
- if( skill->changematerial_db[i].itemid == nameid ){
+ if( skill->dbs->changematerial_db[i].itemid == nameid ){
for(j=0; j<5; j++){
- if( rnd()%1000 < skill->changematerial_db[i].qty_rate[j] ){
- tmp_item.amount = qty * skill->changematerial_db[i].qty[j];
+ if( rnd()%1000 < skill->dbs->changematerial_db[i].qty_rate[j] ){
+ tmp_item.amount = qty * skill->dbs->changematerial_db[i].qty[j];
if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) {
clif->additem(sd,0,0,flag);
map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
@@ -17365,7 +17374,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
break;
}
if( k ){
- clif->msg_skill(sd,skill_id,0x627);
+ clif->msgtable_skill(sd, skill_id, MSG_SKILL_SUCCESS);
return 1;
}
} else if (tmp_item.amount) { //Success
@@ -17374,7 +17383,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
if( skill_id == GN_MIX_COOKING || skill_id == GN_MAKEBOMB || skill_id == GN_S_PHARMACY )
- clif->msg_skill(sd,skill_id,0x627);
+ clif->msgtable_skill(sd, skill_id, MSG_SKILL_SUCCESS);
return 1;
}
}
@@ -17433,20 +17442,20 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
clif->additem(sd,0,0,flag);
map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
- clif->msg_skill(sd,skill_id,0x628);
+ clif->msgtable_skill(sd, skill_id, MSG_SKILL_FAILURE);
}
break;
case GN_MAKEBOMB:
case GN_S_PHARMACY:
case GN_CHANGEMATERIAL:
- clif->msg_skill(sd,skill_id,0x628);
+ clif->msgtable_skill(sd, skill_id, MSG_SKILL_FAILURE);
break;
default:
- if( skill->produce_db[idx].itemlv > 10 && skill->produce_db[idx].itemlv <= 20 )
+ if( skill->dbs->produce_db[idx].itemlv > 10 && skill->dbs->produce_db[idx].itemlv <= 20 )
{ //Cooking items.
clif->specialeffect(&sd->bl, 609, AREA);
if( sd->cook_mastery > 0 )
- pc_setglobalreg(sd, script->add_str("COOK_MASTERY"), sd->cook_mastery - ( 1 << ((skill->produce_db[idx].itemlv - 11) / 2) ) - ( ( ( 1 << ((skill->produce_db[idx].itemlv - 11) / 2) ) >> 1 ) * 3 ));
+ pc_setglobalreg(sd, script->add_str("COOK_MASTERY"), sd->cook_mastery - ( 1 << ((skill->dbs->produce_db[idx].itemlv - 11) / 2) ) - ( ( ( 1 << ((skill->dbs->produce_db[idx].itemlv - 11) / 2) ) >> 1 ) * 3 ));
}
}
}
@@ -17464,7 +17473,7 @@ int skill_arrow_create (struct map_session_data *sd, int nameid)
return 1;
for(i=0;i<MAX_SKILL_ARROW_DB;i++)
- if(nameid == skill->arrow_db[i].nameid) {
+ if(nameid == skill->dbs->arrow_db[i].nameid) {
index = i;
break;
}
@@ -17472,12 +17481,12 @@ int skill_arrow_create (struct map_session_data *sd, int nameid)
if(index < 0 || (j = pc->search_inventory(sd,nameid)) == INDEX_NOT_FOUND)
return 1;
- pc->delitem(sd,j,1,0,0,LOG_TYPE_PRODUCE);
+ pc->delitem(sd, j, 1, 0, DELITEM_NORMAL, LOG_TYPE_PRODUCE); // FIXME: is this the correct reason flag?
for(i=0;i<MAX_ARROW_RESOURCE;i++) {
memset(&tmp_item,0,sizeof(tmp_item));
tmp_item.identify = 1;
- tmp_item.nameid = skill->arrow_db[index].cre_id[i];
- tmp_item.amount = skill->arrow_db[index].cre_amount[i];
+ tmp_item.nameid = skill->dbs->arrow_db[index].cre_id[i];
+ tmp_item.amount = skill->dbs->arrow_db[index].cre_amount[i];
if(battle_config.produce_item_name_input&0x4) {
tmp_item.card[0]=CARD0_CREATE;
tmp_item.card[1]=0;
@@ -17498,7 +17507,7 @@ int skill_poisoningweapon( struct map_session_data *sd, int nameid) {
sc_type type;
int chance, i;
nullpo_ret(sd);
- if( nameid <= 0 || (i = pc->search_inventory(sd,nameid)) == INDEX_NOT_FOUND || pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME) ) {
+ if (nameid <= 0 || (i = pc->search_inventory(sd,nameid)) == INDEX_NOT_FOUND || pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME)) {
clif->skill_fail(sd,GC_POISONINGWEAPON,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -17555,15 +17564,16 @@ int skill_magicdecoy(struct map_session_data *sd, int nameid) {
nullpo_ret(sd);
skill_id = sd->menuskill_val;
- if (nameid <= 0 || !itemdb_is_element(nameid) || (i = pc->search_inventory(sd,nameid)) == INDEX_NOT_FOUND
- || !skill_id || pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME)
+ if (nameid <= 0 || !itemdb_is_element(nameid) || !skill_id
+ || (i = pc->search_inventory(sd, nameid)) == INDEX_NOT_FOUND
+ || pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME) != 0
) {
clif->skill_fail(sd,NC_MAGICDECOY,USESKILL_FAIL_LEVEL,0);
return 0;
}
// Spawn Position
- pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);
+ pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME); // FIXME: is this intended to be there twice?
x = sd->sc.comet_x;
y = sd->sc.comet_y;
sd->sc.comet_x = sd->sc.comet_y = 0;
@@ -17603,10 +17613,10 @@ int skill_spellbook (struct map_session_data *sd, int nameid) {
return 0;
}
- ARR_FIND(0,MAX_SKILL_SPELLBOOK_DB,i,skill->spellbook_db[i].nameid == nameid); // Search for information of this item
+ ARR_FIND(0,MAX_SKILL_SPELLBOOK_DB,i,skill->dbs->spellbook_db[i].nameid == nameid); // Search for information of this item
if( i == MAX_SKILL_SPELLBOOK_DB ) return 0;
- if( !pc->checkskill(sd, (skill_id = skill->spellbook_db[i].skill_id)) )
+ if( !pc->checkskill(sd, (skill_id = skill->dbs->spellbook_db[i].skill_id)) )
{ // User don't know the skill
sc_start(&sd->bl, &sd->bl, SC_SLEEP, 100, 1, skill->get_time(WL_READING_SB, pc->checkskill(sd,WL_READING_SB)));
clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_DIFFICULT_SLEEP, 0);
@@ -17614,7 +17624,7 @@ int skill_spellbook (struct map_session_data *sd, int nameid) {
}
max_preserve = 4 * pc->checkskill(sd, WL_FREEZE_SP) + (status_get_int(&sd->bl) + sd->status.base_level) / 10;
- point = skill->spellbook_db[i].point;
+ point = skill->dbs->spellbook_db[i].point;
if( sc && sc->data[SC_READING_SB] ) {
if( (sc->data[SC_READING_SB]->val2 + point) > max_preserve ) {
@@ -17699,7 +17709,7 @@ int skill_elementalanalysis(struct map_session_data* sd, int n, uint16 skill_lv,
return 1;
}
- if( pc->delitem(sd,idx,del_amount,0,1,LOG_TYPE_CONSUME) ) {
+ if( pc->delitem(sd, idx, del_amount, 0, DELITEM_SKILLUSE, LOG_TYPE_CONSUME) ) {
clif->skill_fail(sd,SO_EL_ANALYSIS,USESKILL_FAIL_LEVEL,0);
return 1;
}
@@ -17737,23 +17747,23 @@ int skill_changematerial(struct map_session_data *sd, int n, unsigned short *ite
// Search for objects that can be created.
for( i = 0; i < MAX_SKILL_PRODUCE_DB; i++ ) {
- if( skill->produce_db[i].itemlv == 26 ) {
+ if( skill->dbs->produce_db[i].itemlv == 26 ) {
p = 0;
do {
c = 0;
// Verification of overlap between the objects required and the list submitted.
for( j = 0; j < MAX_PRODUCE_RESOURCE; j++ ) {
- if( skill->produce_db[i].mat_id[j] > 0 ) {
+ if( skill->dbs->produce_db[i].mat_id[j] > 0 ) {
for( k = 0; k < n; k++ ) {
int idx = item_list[k*2+0]-2;
nameid = sd->status.inventory[idx].nameid;
amount = item_list[k*2+1];
if( nameid > 0 && sd->status.inventory[idx].identify == 0 ){
- clif->msg_skill(sd,GN_CHANGEMATERIAL,0x62D);
+ clif->msgtable_skill(sd, GN_CHANGEMATERIAL, MSG_SKILL_ITEM_NEED_IDENTIFY);
return 0;
}
- if( nameid == skill->produce_db[i].mat_id[j] && (amount-p*skill->produce_db[i].mat_amount[j]) >= skill->produce_db[i].mat_amount[j]
- && (amount-p*skill->produce_db[i].mat_amount[j])%skill->produce_db[i].mat_amount[j] == 0 ) // must be in exact amount
+ if( nameid == skill->dbs->produce_db[i].mat_id[j] && (amount-p*skill->dbs->produce_db[i].mat_amount[j]) >= skill->dbs->produce_db[i].mat_amount[j]
+ && (amount-p*skill->dbs->produce_db[i].mat_amount[j])%skill->dbs->produce_db[i].mat_amount[j] == 0 ) // must be in exact amount
c++; // match
}
}
@@ -17764,14 +17774,14 @@ int skill_changematerial(struct map_session_data *sd, int n, unsigned short *ite
} while(n == j && c == n);
p--;
if ( p > 0 ) {
- skill->produce_mix(sd,GN_CHANGEMATERIAL,skill->produce_db[i].nameid,0,0,0,p);
+ skill->produce_mix(sd,GN_CHANGEMATERIAL,skill->dbs->produce_db[i].nameid,0,0,0,p);
return 1;
}
}
}
if( p == 0)
- clif->msg_skill(sd,GN_CHANGEMATERIAL,0x623);
+ clif->msgtable_skill(sd, GN_CHANGEMATERIAL, MSG_SKILL_ITEM_NOT_FOUND);
return 0;
}
@@ -17894,6 +17904,9 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick)
}
if( i != cd->cursor ) {/* duplicate, update necessary */
+ // Don't do anything if there's already a tick longer than the incoming one
+ if (DIFF_TICK32(cd->entry[i]->started + cd->entry[i]->duration, now) > tick)
+ return 0;
cd->entry[i]->duration = tick;
#if PACKETVER >= 20120604
cd->entry[i]->total = tick;
@@ -18077,25 +18090,25 @@ void skill_init_unit_layout (void)
//when != it was already cleared during skill_defaults() no need to repeat
if( runflag == MAPSERVER_ST_RUNNING )
- memset(skill->unit_layout,0,sizeof(skill->unit_layout));
+ memset(skill->dbs->unit_layout, 0, sizeof(skill->dbs->unit_layout));
// standard square layouts go first
for (i=0; i<=MAX_SQUARE_LAYOUT; i++) {
int size = i*2+1;
- skill->unit_layout[i].count = size*size;
+ skill->dbs->unit_layout[i].count = size*size;
for (j=0; j<size*size; j++) {
- skill->unit_layout[i].dx[j] = (j%size-i);
- skill->unit_layout[i].dy[j] = (j/size-i);
+ skill->dbs->unit_layout[i].dx[j] = (j%size-i);
+ skill->dbs->unit_layout[i].dy[j] = (j/size-i);
}
}
// afterwards add special ones
pos = i;
for (i=0;i<MAX_SKILL_DB;i++) {
- if (!skill->db[i].unit_id[0] || skill->db[i].unit_layout_type[0] != -1)
+ if (!skill->dbs->db[i].unit_id[0] || skill->dbs->db[i].unit_layout_type[0] != -1)
continue;
- switch (skill->db[i].nameid) {
+ switch (skill->dbs->db[i].nameid) {
case MG_FIREWALL:
case WZ_ICEWALL:
case WL_EARTHSTRAIN://Warlock
@@ -18109,9 +18122,9 @@ void skill_init_unit_layout (void)
static const int dy[]={
-2,-2,-2,-1,-1,-1,-1,-1, 0, 0,
0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2};
- skill->unit_layout[pos].count = 21;
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ skill->dbs->unit_layout[pos].count = 21;
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
break;
case PR_MAGNUS: {
@@ -18123,18 +18136,18 @@ void skill_init_unit_layout (void)
-3,-3,-3,-2,-2,-2,-1,-1,-1,-1,
-1,-1,-1, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3};
- skill->unit_layout[pos].count = 33;
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ skill->dbs->unit_layout[pos].count = 33;
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
break;
case MH_POISON_MIST:
case AS_VENOMDUST: {
static const int dx[] = {-1, 0, 0, 0, 1};
static const int dy[] = { 0,-1, 0, 1, 0};
- skill->unit_layout[pos].count = 5;
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ skill->dbs->unit_layout[pos].count = 5;
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
break;
case CR_GRANDCROSS:
@@ -18147,9 +18160,9 @@ void skill_init_unit_layout (void)
-4,-3,-2,-2,-2,-1,-1,-1,-1,-1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 2, 2, 2, 3, 4};
- skill->unit_layout[pos].count = 29;
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ skill->dbs->unit_layout[pos].count = 29;
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
break;
case PF_FOGWALL: {
@@ -18157,9 +18170,9 @@ void skill_init_unit_layout (void)
-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2};
static const int dy[] = {
-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1};
- skill->unit_layout[pos].count = 15;
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ skill->dbs->unit_layout[pos].count = 15;
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
break;
case PA_GOSPEL: {
@@ -18173,17 +18186,17 @@ void skill_init_unit_layout (void)
-1,-1,-1, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
3, 3, 3};
- skill->unit_layout[pos].count = 33;
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ skill->dbs->unit_layout[pos].count = 33;
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
break;
case NJ_KAENSIN: {
static const int dx[] = {-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2};
static const int dy[] = { 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2};
- skill->unit_layout[pos].count = 24;
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ skill->dbs->unit_layout[pos].count = 24;
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
break;
case NJ_TATAMIGAESHI: {
@@ -18198,29 +18211,29 @@ void skill_init_unit_layout (void)
static const int dy3[] = { 0, 0, 0, 0, 0, 0,-3,-2,-1, 1, 2, 3};
//lv1
j = 0;
- skill->unit_layout[pos].count = 4;
- memcpy(skill->unit_layout[pos].dx,dx1,sizeof(dx1));
- memcpy(skill->unit_layout[pos].dy,dy1,sizeof(dy1));
- skill->db[i].unit_layout_type[j] = pos;
+ skill->dbs->unit_layout[pos].count = 4;
+ memcpy(skill->dbs->unit_layout[pos].dx,dx1,sizeof(dx1));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy1,sizeof(dy1));
+ skill->dbs->db[i].unit_layout_type[j] = pos;
//lv2/3
j++;
pos++;
- skill->unit_layout[pos].count = 8;
- memcpy(skill->unit_layout[pos].dx,dx2,sizeof(dx2));
- memcpy(skill->unit_layout[pos].dy,dy2,sizeof(dy2));
- skill->db[i].unit_layout_type[j] = pos;
- skill->db[i].unit_layout_type[++j] = pos;
+ skill->dbs->unit_layout[pos].count = 8;
+ memcpy(skill->dbs->unit_layout[pos].dx,dx2,sizeof(dx2));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy2,sizeof(dy2));
+ skill->dbs->db[i].unit_layout_type[j] = pos;
+ skill->dbs->db[i].unit_layout_type[++j] = pos;
//lv4/5
j++;
pos++;
- skill->unit_layout[pos].count = 12;
- memcpy(skill->unit_layout[pos].dx,dx3,sizeof(dx3));
- memcpy(skill->unit_layout[pos].dy,dy3,sizeof(dy3));
- skill->db[i].unit_layout_type[j] = pos;
- skill->db[i].unit_layout_type[++j] = pos;
+ skill->dbs->unit_layout[pos].count = 12;
+ memcpy(skill->dbs->unit_layout[pos].dx,dx3,sizeof(dx3));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy3,sizeof(dy3));
+ skill->dbs->db[i].unit_layout_type[j] = pos;
+ skill->dbs->db[i].unit_layout_type[++j] = pos;
//Fill in the rest using lv 5.
for (;j<MAX_SKILL_LEVEL;j++)
- skill->db[i].unit_layout_type[j] = pos;
+ skill->dbs->db[i].unit_layout_type[j] = pos;
//Skip, this way the check below will fail and continue to the next skill.
pos++;
}
@@ -18228,27 +18241,27 @@ void skill_init_unit_layout (void)
case GN_WALLOFTHORN: {
static const int dx[] = {-1,-2,-2,-2,-2,-2,-1, 0, 1, 2, 2, 2, 2, 2, 1, 0};
static const int dy[] = { 2, 2, 1, 0,-1,-2,-2,-2,-2,-2,-1, 0, 1, 2, 2, 2};
- skill->unit_layout[pos].count = 16;
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ skill->dbs->unit_layout[pos].count = 16;
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
break;
case EL_FIRE_MANTLE: {
static const int dx[] = {-1, 0, 1, 1, 1, 0,-1,-1};
static const int dy[] = { 1, 1, 1, 0,-1,-1,-1, 0};
- skill->unit_layout[pos].count = 8;
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ skill->dbs->unit_layout[pos].count = 8;
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
break;
default:
ShowError("unknown unit layout at skill %d\n",i);
break;
}
- if (!skill->unit_layout[pos].count)
+ if (!skill->dbs->unit_layout[pos].count)
continue;
for (j=0;j<MAX_SKILL_LEVEL;j++)
- skill->db[i].unit_layout_type[j] = pos;
+ skill->dbs->db[i].unit_layout_type[j] = pos;
pos++;
}
@@ -18256,60 +18269,60 @@ void skill_init_unit_layout (void)
skill->firewall_unit_pos = pos;
for (i=0;i<8;i++) {
if (i&1) {
- skill->unit_layout[pos].count = 5;
+ skill->dbs->unit_layout[pos].count = 5;
if (i&0x2) {
int dx[] = {-1,-1, 0, 0, 1};
int dy[] = { 1, 0, 0,-1,-1};
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
} else {
int dx[] = { 1, 1 ,0, 0,-1};
int dy[] = { 1, 0, 0,-1,-1};
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
} else {
- skill->unit_layout[pos].count = 3;
+ skill->dbs->unit_layout[pos].count = 3;
if (i%4==0) {
int dx[] = {-1, 0, 1};
int dy[] = { 0, 0, 0};
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
} else {
int dx[] = { 0, 0, 0};
int dy[] = {-1, 0, 1};
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
}
pos++;
}
skill->icewall_unit_pos = pos;
for (i=0;i<8;i++) {
- skill->unit_layout[pos].count = 5;
+ skill->dbs->unit_layout[pos].count = 5;
if (i&1) {
if (i&0x2) {
int dx[] = {-2,-1, 0, 1, 2};
int dy[] = { 2, 1, 0,-1,-2};
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
} else {
int dx[] = { 2, 1 ,0,-1,-2};
int dy[] = { 2, 1, 0,-1,-2};
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
} else {
if (i%4==0) {
int dx[] = {-2,-1, 0, 1, 2};
int dy[] = { 0, 0, 0, 0, 0};
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
} else {
int dx[] = { 0, 0, 0, 0, 0};
int dy[] = {-2,-1, 0, 1, 2};
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
}
pos++;
@@ -18317,15 +18330,15 @@ void skill_init_unit_layout (void)
skill->earthstrain_unit_pos = pos;
for( i = 0; i < 8; i++ )
{ // For each Direction
- skill->unit_layout[pos].count = 15;
+ skill->dbs->unit_layout[pos].count = 15;
switch( i )
{
case 0: case 1: case 3: case 4: case 5: case 7:
{
int dx[] = {-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7};
int dy[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
break;
case 2:
@@ -18333,8 +18346,8 @@ void skill_init_unit_layout (void)
{
int dx[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int dy[] = {-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7};
- memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx));
- memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy));
+ memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx));
+ memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy));
}
break;
}
@@ -18581,36 +18594,36 @@ bool skill_parse_row_skilldb(char* split[], int columns, int current) {
if( !idx ) // invalid skill id
return false;
- skill->db[idx].nameid = skill_id;
- skill->split_atoi(split[1],skill->db[idx].range);
- skill->db[idx].hit = atoi(split[2]);
- skill->db[idx].inf = atoi(split[3]);
- skill->split_atoi(split[4],skill->db[idx].element);
- skill->db[idx].nk = (int)strtol(split[5], NULL, 0);
- skill->split_atoi(split[6],skill->db[idx].splash);
- skill->db[idx].max = atoi(split[7]);
- skill->split_atoi(split[8],skill->db[idx].num);
+ skill->dbs->db[idx].nameid = skill_id;
+ skill->split_atoi(split[1],skill->dbs->db[idx].range);
+ skill->dbs->db[idx].hit = atoi(split[2]);
+ skill->dbs->db[idx].inf = atoi(split[3]);
+ skill->split_atoi(split[4],skill->dbs->db[idx].element);
+ skill->dbs->db[idx].nk = (int)strtol(split[5], NULL, 0);
+ skill->split_atoi(split[6],skill->dbs->db[idx].splash);
+ skill->dbs->db[idx].max = atoi(split[7]);
+ skill->split_atoi(split[8],skill->dbs->db[idx].num);
if( strcmpi(split[9],"yes") == 0 )
- skill->db[idx].castcancel = 1;
+ skill->dbs->db[idx].castcancel = 1;
else
- skill->db[idx].castcancel = 0;
- skill->db[idx].cast_def_rate = atoi(split[10]);
- skill->db[idx].inf2 = (int)strtol(split[11], NULL, 0);
- skill->split_atoi(split[12],skill->db[idx].maxcount);
+ skill->dbs->db[idx].castcancel = 0;
+ skill->dbs->db[idx].cast_def_rate = atoi(split[10]);
+ skill->dbs->db[idx].inf2 = (int)strtol(split[11], NULL, 0);
+ skill->split_atoi(split[12],skill->dbs->db[idx].maxcount);
if( strcmpi(split[13],"weapon") == 0 )
- skill->db[idx].skill_type = BF_WEAPON;
+ skill->dbs->db[idx].skill_type = BF_WEAPON;
else if( strcmpi(split[13],"magic") == 0 )
- skill->db[idx].skill_type = BF_MAGIC;
+ skill->dbs->db[idx].skill_type = BF_MAGIC;
else if( strcmpi(split[13],"misc") == 0 )
- skill->db[idx].skill_type = BF_MISC;
+ skill->dbs->db[idx].skill_type = BF_MISC;
else
- skill->db[idx].skill_type = 0;
- skill->split_atoi(split[14],skill->db[idx].blewcount);
- safestrncpy(skill->db[idx].name, trim(split[15]), sizeof(skill->db[idx].name));
- safestrncpy(skill->db[idx].desc, trim(split[16]), sizeof(skill->db[idx].desc));
- strdb_iput(skill->name2id_db, skill->db[idx].name, skill_id);
- script->set_constant2(skill->db[idx].name,(int)skill_id,0);
+ skill->dbs->db[idx].skill_type = 0;
+ skill->split_atoi(split[14],skill->dbs->db[idx].blewcount);
+ safestrncpy(skill->dbs->db[idx].name, trim(split[15]), sizeof(skill->dbs->db[idx].name));
+ safestrncpy(skill->dbs->db[idx].desc, trim(split[16]), sizeof(skill->dbs->db[idx].desc));
+ strdb_iput(skill->name2id_db, skill->dbs->db[idx].name, skill_id);
+ script->set_constant2(skill->dbs->db[idx].name,(int)skill_id,0);
return true;
}
@@ -18625,22 +18638,22 @@ bool skill_parse_row_requiredb(char* split[], int columns, int current) {
if( !idx ) // invalid skill id
return false;
- skill->split_atoi(split[1],skill->db[idx].hp);
- skill->split_atoi(split[2],skill->db[idx].mhp);
- skill->split_atoi(split[3],skill->db[idx].sp);
- skill->split_atoi(split[4],skill->db[idx].hp_rate);
- skill->split_atoi(split[5],skill->db[idx].sp_rate);
- skill->split_atoi(split[6],skill->db[idx].zeny);
+ skill->split_atoi(split[1],skill->dbs->db[idx].hp);
+ skill->split_atoi(split[2],skill->dbs->db[idx].mhp);
+ skill->split_atoi(split[3],skill->dbs->db[idx].sp);
+ skill->split_atoi(split[4],skill->dbs->db[idx].hp_rate);
+ skill->split_atoi(split[5],skill->dbs->db[idx].sp_rate);
+ skill->split_atoi(split[6],skill->dbs->db[idx].zeny);
//Which weapon type are required, see doc/item_db for types
p = split[7];
for( j = 0; j < 32; j++ ) {
int l = atoi(p);
if( l == 99 ) { // Any weapon
- skill->db[idx].weapon = 0;
+ skill->dbs->db[idx].weapon = 0;
break;
} else
- skill->db[idx].weapon |= 1<<l;
+ skill->dbs->db[idx].weapon |= 1<<l;
p = strchr(p,':');
if(!p)
break;
@@ -18652,49 +18665,49 @@ bool skill_parse_row_requiredb(char* split[], int columns, int current) {
for( j = 0; j < 32; j++ ) {
int l = atoi(p);
if( l == 99 ) { // Any ammo type
- skill->db[idx].ammo = 0xFFFFFFFF;
+ skill->dbs->db[idx].ammo = 0xFFFFFFFF;
break;
} else if( l ) // 0 stands for no requirement
- skill->db[idx].ammo |= 1<<l;
+ skill->dbs->db[idx].ammo |= 1<<l;
p = strchr(p,':');
if( !p )
break;
p++;
}
- skill->split_atoi(split[9],skill->db[idx].ammo_qty);
-
- if( strcmpi(split[10],"hiding") == 0 ) skill->db[idx].state = ST_HIDING;
- else if( strcmpi(split[10],"cloaking") == 0 ) skill->db[idx].state = ST_CLOAKING;
- else if( strcmpi(split[10],"hidden") == 0 ) skill->db[idx].state = ST_HIDDEN;
- else if( strcmpi(split[10],"riding") == 0 ) skill->db[idx].state = ST_RIDING;
- else if( strcmpi(split[10],"falcon") == 0 ) skill->db[idx].state = ST_FALCON;
- else if( strcmpi(split[10],"cart") == 0 ) skill->db[idx].state = ST_CART;
- else if( strcmpi(split[10],"shield") == 0 ) skill->db[idx].state = ST_SHIELD;
- else if( strcmpi(split[10],"sight") == 0 ) skill->db[idx].state = ST_SIGHT;
- else if( strcmpi(split[10],"explosionspirits") == 0 ) skill->db[idx].state = ST_EXPLOSIONSPIRITS;
- else if( strcmpi(split[10],"cartboost") == 0 ) skill->db[idx].state = ST_CARTBOOST;
- else if( strcmpi(split[10],"recover_weight_rate") == 0 ) skill->db[idx].state = ST_RECOV_WEIGHT_RATE;
- else if( strcmpi(split[10],"move_enable") == 0 ) skill->db[idx].state = ST_MOVE_ENABLE;
- else if( strcmpi(split[10],"water") == 0 ) skill->db[idx].state = ST_WATER;
- else if( strcmpi(split[10],"dragon") == 0 ) skill->db[idx].state = ST_RIDINGDRAGON;
- else if( strcmpi(split[10],"warg") == 0 ) skill->db[idx].state = ST_WUG;
- else if( strcmpi(split[10],"ridingwarg") == 0 ) skill->db[idx].state = ST_RIDINGWUG;
- else if( strcmpi(split[10],"mado") == 0 ) skill->db[idx].state = ST_MADO;
- else if( strcmpi(split[10],"elementalspirit") == 0 ) skill->db[idx].state = ST_ELEMENTALSPIRIT;
- else if( strcmpi(split[10],"poisonweapon") == 0 ) skill->db[idx].state = ST_POISONINGWEAPON;
- else if( strcmpi(split[10],"rollingcutter") == 0 ) skill->db[idx].state = ST_ROLLINGCUTTER;
- else if( strcmpi(split[10],"mh_fighting") == 0 ) skill->db[idx].state = ST_MH_FIGHTING;
- else if( strcmpi(split[10],"mh_grappling") == 0 ) skill->db[idx].state = ST_MH_GRAPPLING;
- else if( strcmpi(split[10],"peco") == 0 ) skill->db[idx].state = ST_PECO;
+ skill->split_atoi(split[9],skill->dbs->db[idx].ammo_qty);
+
+ if( strcmpi(split[10],"hiding") == 0 ) skill->dbs->db[idx].state = ST_HIDING;
+ else if( strcmpi(split[10],"cloaking") == 0 ) skill->dbs->db[idx].state = ST_CLOAKING;
+ else if( strcmpi(split[10],"hidden") == 0 ) skill->dbs->db[idx].state = ST_HIDDEN;
+ else if( strcmpi(split[10],"riding") == 0 ) skill->dbs->db[idx].state = ST_RIDING;
+ else if( strcmpi(split[10],"falcon") == 0 ) skill->dbs->db[idx].state = ST_FALCON;
+ else if( strcmpi(split[10],"cart") == 0 ) skill->dbs->db[idx].state = ST_CART;
+ else if( strcmpi(split[10],"shield") == 0 ) skill->dbs->db[idx].state = ST_SHIELD;
+ else if( strcmpi(split[10],"sight") == 0 ) skill->dbs->db[idx].state = ST_SIGHT;
+ else if( strcmpi(split[10],"explosionspirits") == 0 ) skill->dbs->db[idx].state = ST_EXPLOSIONSPIRITS;
+ else if( strcmpi(split[10],"cartboost") == 0 ) skill->dbs->db[idx].state = ST_CARTBOOST;
+ else if( strcmpi(split[10],"recover_weight_rate") == 0 ) skill->dbs->db[idx].state = ST_RECOV_WEIGHT_RATE;
+ else if( strcmpi(split[10],"move_enable") == 0 ) skill->dbs->db[idx].state = ST_MOVE_ENABLE;
+ else if( strcmpi(split[10],"water") == 0 ) skill->dbs->db[idx].state = ST_WATER;
+ else if( strcmpi(split[10],"dragon") == 0 ) skill->dbs->db[idx].state = ST_RIDINGDRAGON;
+ else if( strcmpi(split[10],"warg") == 0 ) skill->dbs->db[idx].state = ST_WUG;
+ else if( strcmpi(split[10],"ridingwarg") == 0 ) skill->dbs->db[idx].state = ST_RIDINGWUG;
+ else if( strcmpi(split[10],"mado") == 0 ) skill->dbs->db[idx].state = ST_MADO;
+ else if( strcmpi(split[10],"elementalspirit") == 0 ) skill->dbs->db[idx].state = ST_ELEMENTALSPIRIT;
+ else if( strcmpi(split[10],"poisonweapon") == 0 ) skill->dbs->db[idx].state = ST_POISONINGWEAPON;
+ else if( strcmpi(split[10],"rollingcutter") == 0 ) skill->dbs->db[idx].state = ST_ROLLINGCUTTER;
+ else if( strcmpi(split[10],"mh_fighting") == 0 ) skill->dbs->db[idx].state = ST_MH_FIGHTING;
+ else if( strcmpi(split[10],"mh_grappling") == 0 ) skill->dbs->db[idx].state = ST_MH_GRAPPLING;
+ else if( strcmpi(split[10],"peco") == 0 ) skill->dbs->db[idx].state = ST_PECO;
/**
* Unknown or no state
**/
- else skill->db[idx].state = ST_NONE;
+ else skill->dbs->db[idx].state = ST_NONE;
- skill->split_atoi(split[11],skill->db[idx].spiritball);
+ skill->split_atoi(split[11],skill->dbs->db[idx].spiritball);
for( j = 0; j < MAX_SKILL_ITEM_REQUIRE; j++ ) {
- skill->db[idx].itemid[j] = atoi(split[12+ 2*j]);
- skill->db[idx].amount[j] = atoi(split[13+ 2*j]);
+ skill->dbs->db[idx].itemid[j] = atoi(split[12+ 2*j]);
+ skill->dbs->db[idx].amount[j] = atoi(split[13+ 2*j]);
}
return true;
@@ -18707,14 +18720,14 @@ bool skill_parse_row_castdb(char* split[], int columns, int current) {
if( !idx ) // invalid skill id
return false;
- skill->split_atoi(split[1],skill->db[idx].cast);
- skill->split_atoi(split[2],skill->db[idx].delay);
- skill->split_atoi(split[3],skill->db[idx].walkdelay);
- skill->split_atoi(split[4],skill->db[idx].upkeep_time);
- skill->split_atoi(split[5],skill->db[idx].upkeep_time2);
- skill->split_atoi(split[6],skill->db[idx].cooldown);
+ skill->split_atoi(split[1],skill->dbs->db[idx].cast);
+ skill->split_atoi(split[2],skill->dbs->db[idx].delay);
+ skill->split_atoi(split[3],skill->dbs->db[idx].walkdelay);
+ skill->split_atoi(split[4],skill->dbs->db[idx].upkeep_time);
+ skill->split_atoi(split[5],skill->dbs->db[idx].upkeep_time2);
+ skill->split_atoi(split[6],skill->dbs->db[idx].cooldown);
#ifdef RENEWAL_CAST
- skill->split_atoi(split[7],skill->db[idx].fixed_cast);
+ skill->split_atoi(split[7],skill->dbs->db[idx].fixed_cast);
#endif
return true;
}
@@ -18726,9 +18739,9 @@ bool skill_parse_row_castnodexdb(char* split[], int columns, int current) {
if( !idx ) // invalid skill id
return false;
- skill->split_atoi(split[1],skill->db[idx].castnodex);
+ skill->split_atoi(split[1],skill->dbs->db[idx].castnodex);
if( split[2] ) // optional column
- skill->split_atoi(split[2],skill->db[idx].delaynodex);
+ skill->split_atoi(split[2],skill->dbs->db[idx].delaynodex);
return true;
}
@@ -18740,37 +18753,37 @@ bool skill_parse_row_unitdb(char* split[], int columns, int current) {
if( !idx ) // invalid skill id
return false;
- skill->db[idx].unit_id[0] = (int)strtol(split[1],NULL,16);
- skill->db[idx].unit_id[1] = (int)strtol(split[2],NULL,16);
- skill->split_atoi(split[3],skill->db[idx].unit_layout_type);
- skill->split_atoi(split[4],skill->db[idx].unit_range);
- skill->db[idx].unit_interval = atoi(split[5]);
-
- if( strcmpi(split[6],"noenemy")==0 ) skill->db[idx].unit_target = BCT_NOENEMY;
- else if( strcmpi(split[6],"friend")==0 ) skill->db[idx].unit_target = BCT_NOENEMY;
- else if( strcmpi(split[6],"party")==0 ) skill->db[idx].unit_target = BCT_PARTY;
- else if( strcmpi(split[6],"ally")==0 ) skill->db[idx].unit_target = BCT_PARTY|BCT_GUILD;
- else if( strcmpi(split[6],"guild")==0 ) skill->db[idx].unit_target = BCT_GUILD;
- else if( strcmpi(split[6],"all")==0 ) skill->db[idx].unit_target = BCT_ALL;
- else if( strcmpi(split[6],"enemy")==0 ) skill->db[idx].unit_target = BCT_ENEMY;
- else if( strcmpi(split[6],"self")==0 ) skill->db[idx].unit_target = BCT_SELF;
- else if( strcmpi(split[6],"sameguild")==0 ) skill->db[idx].unit_target = BCT_GUILD|BCT_SAMEGUILD;
- else if( strcmpi(split[6],"noone")==0 ) skill->db[idx].unit_target = BCT_NOONE;
- else skill->db[idx].unit_target = (int)strtol(split[6],NULL,16);
-
- skill->db[idx].unit_flag = (int)strtol(split[7],NULL,16);
-
- if (skill->db[idx].unit_flag&UF_DEFNOTENEMY && battle_config.defnotenemy)
- skill->db[idx].unit_target = BCT_NOENEMY;
+ skill->dbs->db[idx].unit_id[0] = (int)strtol(split[1],NULL,16);
+ skill->dbs->db[idx].unit_id[1] = (int)strtol(split[2],NULL,16);
+ skill->split_atoi(split[3],skill->dbs->db[idx].unit_layout_type);
+ skill->split_atoi(split[4],skill->dbs->db[idx].unit_range);
+ skill->dbs->db[idx].unit_interval = atoi(split[5]);
+
+ if( strcmpi(split[6],"noenemy")==0 ) skill->dbs->db[idx].unit_target = BCT_NOENEMY;
+ else if( strcmpi(split[6],"friend")==0 ) skill->dbs->db[idx].unit_target = BCT_NOENEMY;
+ else if( strcmpi(split[6],"party")==0 ) skill->dbs->db[idx].unit_target = BCT_PARTY;
+ else if( strcmpi(split[6],"ally")==0 ) skill->dbs->db[idx].unit_target = BCT_PARTY|BCT_GUILD;
+ else if( strcmpi(split[6],"guild")==0 ) skill->dbs->db[idx].unit_target = BCT_GUILD;
+ else if( strcmpi(split[6],"all")==0 ) skill->dbs->db[idx].unit_target = BCT_ALL;
+ else if( strcmpi(split[6],"enemy")==0 ) skill->dbs->db[idx].unit_target = BCT_ENEMY;
+ else if( strcmpi(split[6],"self")==0 ) skill->dbs->db[idx].unit_target = BCT_SELF;
+ else if( strcmpi(split[6],"sameguild")==0 ) skill->dbs->db[idx].unit_target = BCT_GUILD|BCT_SAMEGUILD;
+ else if( strcmpi(split[6],"noone")==0 ) skill->dbs->db[idx].unit_target = BCT_NOONE;
+ else skill->dbs->db[idx].unit_target = (int)strtol(split[6],NULL,16);
+
+ skill->dbs->db[idx].unit_flag = (int)strtol(split[7],NULL,16);
+
+ if (skill->dbs->db[idx].unit_flag&UF_DEFNOTENEMY && battle_config.defnotenemy)
+ skill->dbs->db[idx].unit_target = BCT_NOENEMY;
//By default, target just characters.
- skill->db[idx].unit_target |= BL_CHAR;
- if (skill->db[idx].unit_flag&UF_NOPC)
- skill->db[idx].unit_target &= ~BL_PC;
- if (skill->db[idx].unit_flag&UF_NOMOB)
- skill->db[idx].unit_target &= ~BL_MOB;
- if (skill->db[idx].unit_flag&UF_SKILL)
- skill->db[idx].unit_target |= BL_SKILL;
+ skill->dbs->db[idx].unit_target |= BL_CHAR;
+ if (skill->dbs->db[idx].unit_flag&UF_NOPC)
+ skill->dbs->db[idx].unit_target &= ~BL_PC;
+ if (skill->dbs->db[idx].unit_flag&UF_NOMOB)
+ skill->dbs->db[idx].unit_target &= ~BL_MOB;
+ if (skill->dbs->db[idx].unit_flag&UF_SKILL)
+ skill->dbs->db[idx].unit_target |= BL_SKILL;
return true;
}
@@ -18783,14 +18796,14 @@ bool skill_parse_row_producedb(char* split[], int columns, int current) {
if( !i )
return false;
- skill->produce_db[current].nameid = i;
- skill->produce_db[current].itemlv = atoi(split[1]);
- skill->produce_db[current].req_skill = atoi(split[2]);
- skill->produce_db[current].req_skill_lv = atoi(split[3]);
+ skill->dbs->produce_db[current].nameid = i;
+ skill->dbs->produce_db[current].itemlv = atoi(split[1]);
+ skill->dbs->produce_db[current].req_skill = atoi(split[2]);
+ skill->dbs->produce_db[current].req_skill_lv = atoi(split[3]);
for( x = 4, y = 0; x+1 < columns && split[x] && split[x+1] && y < MAX_PRODUCE_RESOURCE; x += 2, y++ ) {
- skill->produce_db[current].mat_id[y] = atoi(split[x]);
- skill->produce_db[current].mat_amount[y] = atoi(split[x+1]);
+ skill->dbs->produce_db[current].mat_id[y] = atoi(split[x]);
+ skill->dbs->produce_db[current].mat_amount[y] = atoi(split[x+1]);
}
return true;
@@ -18804,11 +18817,11 @@ bool skill_parse_row_createarrowdb(char* split[], int columns, int current) {
if( !i )
return false;
- skill->arrow_db[current].nameid = i;
+ skill->dbs->arrow_db[current].nameid = i;
for( x = 1, y = 0; x+1 < columns && split[x] && split[x+1] && y < MAX_ARROW_RESOURCE; x += 2, y++ ) {
- skill->arrow_db[current].cre_id[y] = atoi(split[x]);
- skill->arrow_db[current].cre_amount[y] = atoi(split[x+1]);
+ skill->dbs->arrow_db[current].cre_id[y] = atoi(split[x]);
+ skill->dbs->arrow_db[current].cre_amount[y] = atoi(split[x+1]);
}
return true;
@@ -18827,9 +18840,9 @@ bool skill_parse_row_spellbookdb(char* split[], int columns, int current) {
if( points < 1 )
ShowError("spellbook_db: PreservePoints have to be 1 or above! (%d/%s)\n", skill_id, skill->get_name(skill_id));
else {
- skill->spellbook_db[current].skill_id = skill_id;
- skill->spellbook_db[current].point = points;
- skill->spellbook_db[current].nameid = nameid;
+ skill->dbs->spellbook_db[current].skill_id = skill_id;
+ skill->dbs->spellbook_db[current].point = points;
+ skill->dbs->spellbook_db[current].nameid = nameid;
return true;
}
@@ -18857,8 +18870,8 @@ bool skill_parse_row_improvisedb(char* split[], int columns, int current) {
ShowError("skill_improvise_db: Maximum amount of entries reached (%d), increase MAX_SKILL_IMPROVISE_DB\n",MAX_SKILL_IMPROVISE_DB);
return false;
}
- skill->improvise_db[current].skill_id = skill_id;
- skill->improvise_db[current].per = j; // Still need confirm it.
+ skill->dbs->improvise_db[current].skill_id = skill_id;
+ skill->dbs->improvise_db[current].per = j; // Still need confirm it.
return true;
}
@@ -18875,7 +18888,7 @@ bool skill_parse_row_magicmushroomdb(char* split[], int column, int current) {
return false;
}
- skill->magicmushroom_db[current].skill_id = skill_id;
+ skill->dbs->magicmushroom_db[current].skill_id = skill_id;
return true;
}
@@ -18886,7 +18899,7 @@ bool skill_parse_row_reproducedb(char* split[], int column, int current) {
if( !idx )
return false;
- skill->reproduce_db[idx] = true;
+ skill->dbs->reproduce_db[idx] = true;
return true;
}
@@ -18904,9 +18917,9 @@ bool skill_parse_row_abradb(char* split[], int columns, int current) {
return false;
}
- skill->abra_db[current].skill_id = skill_id;
- skill->abra_db[current].req_lv = atoi(split[2]);
- skill->abra_db[current].per = atoi(split[3]);
+ skill->dbs->abra_db[current].skill_id = skill_id;
+ skill->dbs->abra_db[current].req_lv = atoi(split[2]);
+ skill->dbs->abra_db[current].per = atoi(split[3]);
return true;
}
@@ -18918,8 +18931,8 @@ bool skill_parse_row_changematerialdb(char* split[], int columns, int current) {
int x,y;
for(x=0; x<MAX_SKILL_PRODUCE_DB; x++){
- if( skill->produce_db[x].nameid == skill_id )
- if( skill->produce_db[x].req_skill == GN_CHANGEMATERIAL )
+ if( skill->dbs->produce_db[x].nameid == skill_id )
+ if( skill->dbs->produce_db[x].req_skill == GN_CHANGEMATERIAL )
break;
}
@@ -18933,12 +18946,12 @@ bool skill_parse_row_changematerialdb(char* split[], int columns, int current) {
return false;
}
- skill->changematerial_db[current].itemid = skill_id;
- skill->changematerial_db[current].rate = j;
+ skill->dbs->changematerial_db[current].itemid = skill_id;
+ skill->dbs->changematerial_db[current].rate = j;
for( x = 2, y = 0; x+1 < columns && split[x] && split[x+1] && y < 5; x += 2, y++ ) {
- skill->changematerial_db[current].qty[y] = atoi(split[x]);
- skill->changematerial_db[current].qty_rate[y] = atoi(split[x+1]);
+ skill->dbs->changematerial_db[current].qty[y] = atoi(split[x]);
+ skill->dbs->changematerial_db[current].qty_rate[y] = atoi(split[x+1]);
}
return true;
@@ -18962,21 +18975,12 @@ void skill_readdb(bool minimal) {
/* when != it was called during init and this procedure was already performed by skill_defaults() */
if( runflag == MAPSERVER_ST_RUNNING ) {
- memset(skill->db,0,sizeof(skill->db)
- + sizeof(skill->produce_db)
- + sizeof(skill->arrow_db)
- + sizeof(skill->abra_db)
- + sizeof(skill->magicmushroom_db)
- + sizeof(skill->improvise_db)
- + sizeof(skill->changematerial_db)
- + sizeof(skill->spellbook_db)
- + sizeof(skill->reproduce_db)
- );
+ memset(ZEROED_BLOCK_POS(skill->dbs), 0, ZEROED_BLOCK_SIZE(skill->dbs));
}
// load skill databases
- safestrncpy(skill->db[0].name, "UNKNOWN_SKILL", sizeof(skill->db[0].name));
- safestrncpy(skill->db[0].desc, "Unknown Skill", sizeof(skill->db[0].desc));
+ safestrncpy(skill->dbs->db[0].name, "UNKNOWN_SKILL", sizeof(skill->dbs->db[0].name));
+ safestrncpy(skill->dbs->db[0].desc, "Unknown Skill", sizeof(skill->dbs->db[0].desc));
#ifdef ENABLE_CASE_CHECK
script->parser_current_file = DBPATH"skill_db.txt";
@@ -19094,6 +19098,8 @@ void skill_defaults(void) {
const int skill_deluge_eff[5] = { 5, 9, 12, 14, 15 };
skill = &skill_s;
+ skill->dbs = &skilldbs;
+
skill->init = do_init_skill;
skill->final = do_final_skill;
skill->reload = skill_reload;
@@ -19110,18 +19116,10 @@ void skill_defaults(void) {
skill->timer_ers = NULL;
skill->cd_ers = NULL;
skill->cd_entry_ers = NULL;
- /* one huge 0, follows skill.h order */
- memset(skill->db,0,sizeof(skill->db)
- + sizeof(skill->produce_db)
- + sizeof(skill->arrow_db)
- + sizeof(skill->abra_db)
- + sizeof(skill->magicmushroom_db)
- + sizeof(skill->improvise_db)
- + sizeof(skill->changematerial_db)
- + sizeof(skill->spellbook_db)
- + sizeof(skill->reproduce_db)
- + sizeof(skill->unit_layout)
- );
+
+ memset(ZEROED_BLOCK_POS(skill->dbs), 0, ZEROED_BLOCK_SIZE(skill->dbs));
+ memset(skill->dbs->unit_layout, 0, sizeof(skill->dbs->unit_layout));
+
/* */
memcpy(skill->enchant_eff, skill_enchant_eff, sizeof(skill->enchant_eff));
memcpy(skill->deluge_eff, skill_deluge_eff, sizeof(skill->deluge_eff));
diff --git a/src/map/skill.h b/src/map/skill.h
index b598b91c8..aa0188be6 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -5,13 +5,13 @@
#ifndef MAP_SKILL_H
#define MAP_SKILL_H
-#include "../config/core.h" // RENEWAL_CAST
+#include "config/core.h" // RENEWAL_CAST
-#include "map.h" // struct block_list
-#include "status.h" // enum sc_type
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/mmo.h" // MAX_SKILL, struct square
+#include "map/map.h" // struct block_list
+#include "map/status.h" // enum sc_type
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/mmo.h" // MAX_SKILL, struct square
/**
* Declarations
@@ -1732,6 +1732,7 @@ struct skill_unit {
int limit;
int val1,val2;
short alive,range;
+ int prev;
};
struct skill_unit_group_tickset {
@@ -1813,6 +1814,21 @@ struct s_skill_spellbook_db {
typedef int (*SkillFunc)(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 tick, int flag);
+struct s_skill_dbs {
+BEGIN_ZEROED_BLOCK; // This block will be zeroed in skill_defaults() as well as skill_readdb()
+ struct s_skill_db db[MAX_SKILL_DB];
+ struct s_skill_produce_db produce_db[MAX_SKILL_PRODUCE_DB];
+ struct s_skill_arrow_db arrow_db[MAX_SKILL_ARROW_DB];
+ struct s_skill_abra_db abra_db[MAX_SKILL_ABRA_DB];
+ struct s_skill_magicmushroom_db magicmushroom_db[MAX_SKILL_MAGICMUSHROOM_DB];
+ struct s_skill_improvise_db improvise_db[MAX_SKILL_IMPROVISE_DB];
+ struct s_skill_changematerial_db changematerial_db[MAX_SKILL_PRODUCE_DB];
+ struct s_skill_spellbook_db spellbook_db[MAX_SKILL_SPELLBOOK_DB];
+ bool reproduce_db[MAX_SKILL_DB];
+END_ZEROED_BLOCK;
+ struct s_skill_unit_layout unit_layout[MAX_SKILL_UNIT_LAYOUT];
+};
+
/**
* Skill.c Interface
**/
@@ -1834,16 +1850,7 @@ struct skill_interface {
struct eri *cd_ers; // ERS Storage for skill cool down managers [Ind/Hercules]
struct eri *cd_entry_ers; // ERS Storage for skill cool down entries [Ind/Hercules]
/* */
- struct s_skill_db db[MAX_SKILL_DB];
- struct s_skill_produce_db produce_db[MAX_SKILL_PRODUCE_DB];
- struct s_skill_arrow_db arrow_db[MAX_SKILL_ARROW_DB];
- struct s_skill_abra_db abra_db[MAX_SKILL_ABRA_DB];
- struct s_skill_magicmushroom_db magicmushroom_db[MAX_SKILL_MAGICMUSHROOM_DB];
- struct s_skill_improvise_db improvise_db[MAX_SKILL_IMPROVISE_DB];
- struct s_skill_changematerial_db changematerial_db[MAX_SKILL_PRODUCE_DB];
- struct s_skill_spellbook_db spellbook_db[MAX_SKILL_SPELLBOOK_DB];
- bool reproduce_db[MAX_SKILL_DB];
- struct s_skill_unit_layout unit_layout[MAX_SKILL_UNIT_LAYOUT];
+ struct s_skill_dbs *dbs;
/* */
int enchant_eff[5];
int deluge_eff[5];
diff --git a/src/map/status.c b/src/map/status.c
index 16f5f3906..b513c6975 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -4,9 +4,38 @@
#define HERCULES_CORE
-#include "../config/core.h" // ANTI_MAYAP_CHEAT, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, DEVOTION_REFLECT_DAMAGE, RENEWAL, RENEWAL_ASPD, RENEWAL_EDP
+#include "config/core.h" // ANTI_MAYAP_CHEAT, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, DEVOTION_REFLECT_DAMAGE, RENEWAL, RENEWAL_ASPD, RENEWAL_EDP
#include "status.h"
+#include "map/battle.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/elemental.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/itemdb.h"
+#include "map/map.h"
+#include "map/mercenary.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/path.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/script.h"
+#include "map/skill.h"
+#include "map/skill.h"
+#include "map/unit.h"
+#include "map/vending.h"
+#include "common/cbasetypes.h"
+#include "common/ers.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "common/utils.h"
+
#include <math.h>
#include <memory.h>
#include <stdio.h>
@@ -14,36 +43,8 @@
#include <string.h>
#include <time.h>
-#include "battle.h"
-#include "chrif.h"
-#include "clif.h"
-#include "elemental.h"
-#include "guild.h"
-#include "homunculus.h"
-#include "itemdb.h"
-#include "map.h"
-#include "mercenary.h"
-#include "mob.h"
-#include "npc.h"
-#include "path.h"
-#include "pc.h"
-#include "pet.h"
-#include "script.h"
-#include "skill.h"
-#include "skill.h"
-#include "unit.h"
-#include "vending.h"
-#include "../common/cbasetypes.h"
-#include "../common/ers.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../common/utils.h"
-
struct status_interface status_s;
+struct s_status_dbs statusdbs;
/**
* Returns the status change associated with a skill.
@@ -56,7 +57,7 @@ sc_type status_skill2sc(int skill_id) {
ShowError("status_skill2sc: Unsupported skill id %d\n", skill_id);
return SC_NONE;
}
- return status->Skill2SCTable[idx];
+ return status->dbs->Skill2SCTable[idx];
}
/**
@@ -72,7 +73,7 @@ int status_sc2skill(sc_type sc)
return 0;
}
- return status->SkillChangeTable[sc];
+ return status->dbs->SkillChangeTable[sc];
}
/**
@@ -87,7 +88,7 @@ unsigned int status_sc2scb_flag(sc_type sc)
return SCB_NONE;
}
- return status->ChangeFlagTable[sc];
+ return status->dbs->ChangeFlagTable[sc];
}
/**
@@ -102,7 +103,7 @@ int status_type2relevant_bl_types(int type)
return BL_NUL;
}
- return status->RelevantBLTypes[type];
+ return status->dbs->RelevantBLTypes[type];
}
static void set_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag) {
@@ -116,35 +117,35 @@ static void set_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag) {
return;
}
- if( status->SkillChangeTable[sc] == 0 )
- status->SkillChangeTable[sc] = skill_id;
- if( status->IconChangeTable[sc] == SI_BLANK )
- status->IconChangeTable[sc] = icon;
- status->ChangeFlagTable[sc] |= flag;
+ if( status->dbs->SkillChangeTable[sc] == 0 )
+ status->dbs->SkillChangeTable[sc] = skill_id;
+ if( status->dbs->IconChangeTable[sc] == SI_BLANK )
+ status->dbs->IconChangeTable[sc] = icon;
+ status->dbs->ChangeFlagTable[sc] |= flag;
- if( status->Skill2SCTable[idx] == SC_NONE )
- status->Skill2SCTable[idx] = sc;
+ if( status->dbs->Skill2SCTable[idx] == SC_NONE )
+ status->dbs->Skill2SCTable[idx] = sc;
}
void initChangeTables(void) {
#define add_sc(skill,sc) set_sc((skill),(sc),SI_BLANK,SCB_NONE)
// indicates that the status displays a visual effect for the affected unit, and should be sent to the client for all supported units
-#define set_sc_with_vfx(skill, sc, icon, flag) do { set_sc((skill), (sc), (icon), (flag)); if((icon) < SI_MAX) status->RelevantBLTypes[(icon)] |= BL_SCEFFECT; } while(0)
+#define set_sc_with_vfx(skill, sc, icon, flag) do { set_sc((skill), (sc), (icon), (flag)); if((icon) < SI_MAX) status->dbs->RelevantBLTypes[(icon)] |= BL_SCEFFECT; } while(0)
int i;
for (i = 0; i < SC_MAX; i++)
- status->IconChangeTable[i] = SI_BLANK;
+ status->dbs->IconChangeTable[i] = SI_BLANK;
for (i = 0; i < MAX_SKILL; i++)
- status->Skill2SCTable[i] = SC_NONE;
+ status->dbs->Skill2SCTable[i] = SC_NONE;
for (i = 0; i < SI_MAX; i++)
- status->RelevantBLTypes[i] = BL_PC;
+ status->dbs->RelevantBLTypes[i] = BL_PC;
- memset(status->SkillChangeTable, 0, sizeof(status->SkillChangeTable));
- memset(status->ChangeFlagTable, 0, sizeof(status->ChangeFlagTable));
- memset(status->DisplayType, 0, sizeof(status->DisplayType));
+ memset(status->dbs->SkillChangeTable, 0, sizeof(status->dbs->SkillChangeTable));
+ memset(status->dbs->ChangeFlagTable, 0, sizeof(status->dbs->ChangeFlagTable));
+ memset(status->dbs->DisplayType, 0, sizeof(status->dbs->DisplayType));
//First we define the skill for common ailments. These are used in skill_additional_effect through sc cards. [Skotlex]
set_sc( NPC_PETRIFYATTACK , SC_STONE , SI_BLANK , SCB_DEF_ELE|SCB_DEF|SCB_MDEF );
@@ -654,7 +655,7 @@ void initChangeTables(void) {
set_sc( MI_RUSH_WINDMILL , SC_RUSH_WINDMILL , SI_RUSHWINDMILL , SCB_WATK );
set_sc( MI_ECHOSONG , SC_ECHOSONG , SI_ECHOSONG , SCB_DEF2 );
set_sc( MI_HARMONIZE , SC_HARMONIZE , SI_HARMONIZE , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK );
- set_sc( WM_POEMOFNETHERWORLD , SC_STOP , SI_NETHERWORLD , SCB_NONE );
+ set_sc_with_vfx(WM_POEMOFNETHERWORLD, SC_NETHERWORLD , SI_NETHERWORLD , SCB_NONE);
set_sc_with_vfx( WM_VOICEOFSIREN , SC_SIREN , SI_SIREN , SCB_NONE );
set_sc_with_vfx( WM_LULLABY_DEEPSLEEP , SC_DEEP_SLEEP , SI_DEEPSLEEP , SCB_NONE );
set_sc( WM_SIRCLEOFNATURE , SC_SIRCLEOFNATURE , SI_SIRCLEOFNATURE , SCB_NONE );
@@ -754,308 +755,303 @@ void initChangeTables(void) {
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.
- status->Skill2SCTable[SL_ALCHEMIST] = (sc_type)MAPID_ALCHEMIST,
- status->Skill2SCTable[SL_MONK] = (sc_type)MAPID_MONK,
- status->Skill2SCTable[SL_STAR] = (sc_type)MAPID_STAR_GLADIATOR,
- status->Skill2SCTable[SL_SAGE] = (sc_type)MAPID_SAGE,
- status->Skill2SCTable[SL_CRUSADER] = (sc_type)MAPID_CRUSADER,
- status->Skill2SCTable[SL_SUPERNOVICE] = (sc_type)MAPID_SUPER_NOVICE,
- status->Skill2SCTable[SL_KNIGHT] = (sc_type)MAPID_KNIGHT,
- status->Skill2SCTable[SL_WIZARD] = (sc_type)MAPID_WIZARD,
- status->Skill2SCTable[SL_PRIEST] = (sc_type)MAPID_PRIEST,
- status->Skill2SCTable[SL_BARDDANCER] = (sc_type)MAPID_BARDDANCER,
- status->Skill2SCTable[SL_ROGUE] = (sc_type)MAPID_ROGUE,
- status->Skill2SCTable[SL_ASSASIN] = (sc_type)MAPID_ASSASSIN,
- status->Skill2SCTable[SL_BLACKSMITH] = (sc_type)MAPID_BLACKSMITH,
- status->Skill2SCTable[SL_HUNTER] = (sc_type)MAPID_HUNTER,
- status->Skill2SCTable[SL_SOULLINKER] = (sc_type)MAPID_SOUL_LINKER,
+ status->dbs->Skill2SCTable[SL_ALCHEMIST] = (sc_type)MAPID_ALCHEMIST,
+ status->dbs->Skill2SCTable[SL_MONK] = (sc_type)MAPID_MONK,
+ status->dbs->Skill2SCTable[SL_STAR] = (sc_type)MAPID_STAR_GLADIATOR,
+ status->dbs->Skill2SCTable[SL_SAGE] = (sc_type)MAPID_SAGE,
+ status->dbs->Skill2SCTable[SL_CRUSADER] = (sc_type)MAPID_CRUSADER,
+ status->dbs->Skill2SCTable[SL_SUPERNOVICE] = (sc_type)MAPID_SUPER_NOVICE,
+ status->dbs->Skill2SCTable[SL_KNIGHT] = (sc_type)MAPID_KNIGHT,
+ status->dbs->Skill2SCTable[SL_WIZARD] = (sc_type)MAPID_WIZARD,
+ status->dbs->Skill2SCTable[SL_PRIEST] = (sc_type)MAPID_PRIEST,
+ status->dbs->Skill2SCTable[SL_BARDDANCER] = (sc_type)MAPID_BARDDANCER,
+ status->dbs->Skill2SCTable[SL_ROGUE] = (sc_type)MAPID_ROGUE,
+ status->dbs->Skill2SCTable[SL_ASSASIN] = (sc_type)MAPID_ASSASSIN,
+ status->dbs->Skill2SCTable[SL_BLACKSMITH] = (sc_type)MAPID_BLACKSMITH,
+ status->dbs->Skill2SCTable[SL_HUNTER] = (sc_type)MAPID_HUNTER,
+ status->dbs->Skill2SCTable[SL_SOULLINKER] = (sc_type)MAPID_SOUL_LINKER,
//Status that don't have a skill associated.
- status->IconChangeTable[SC_WEIGHTOVER50] = SI_WEIGHTOVER50;
- status->IconChangeTable[SC_WEIGHTOVER90] = SI_WEIGHTOVER90;
- status->IconChangeTable[SC_ATTHASTE_POTION1] = SI_ATTHASTE_POTION1;
- status->IconChangeTable[SC_ATTHASTE_POTION2] = SI_ATTHASTE_POTION2;
- status->IconChangeTable[SC_ATTHASTE_POTION3] = SI_ATTHASTE_POTION3;
- status->IconChangeTable[SC_ATTHASTE_INFINITY] = SI_ATTHASTE_INFINITY;
- status->IconChangeTable[SC_MOVHASTE_HORSE] = SI_MOVHASTE_HORSE;
- status->IconChangeTable[SC_MOVHASTE_INFINITY] = SI_MOVHASTE_INFINITY;
- status->IconChangeTable[SC_CHASEWALK2] = SI_INCSTR;
- status->IconChangeTable[SC_MIRACLE] = SI_SOULLINK;
- status->IconChangeTable[SC_CLAIRVOYANCE] = SI_CLAIRVOYANCE;
- status->IconChangeTable[SC_FOOD_STR] = SI_FOOD_STR;
- status->IconChangeTable[SC_FOOD_AGI] = SI_FOOD_AGI;
- status->IconChangeTable[SC_FOOD_VIT] = SI_FOOD_VIT;
- status->IconChangeTable[SC_FOOD_INT] = SI_FOOD_INT;
- status->IconChangeTable[SC_FOOD_DEX] = SI_FOOD_DEX;
- status->IconChangeTable[SC_FOOD_LUK] = SI_FOOD_LUK;
- status->IconChangeTable[SC_FOOD_BASICAVOIDANCE]= SI_FOOD_BASICAVOIDANCE;
- status->IconChangeTable[SC_FOOD_BASICHIT] = SI_FOOD_BASICHIT;
- status->IconChangeTable[SC_MANU_ATK] = SI_MANU_ATK;
- status->IconChangeTable[SC_MANU_DEF] = SI_MANU_DEF;
- status->IconChangeTable[SC_SPL_ATK] = SI_SPL_ATK;
- status->IconChangeTable[SC_SPL_DEF] = SI_SPL_DEF;
- status->IconChangeTable[SC_MANU_MATK] = SI_MANU_MATK;
- status->IconChangeTable[SC_SPL_MATK] = SI_SPL_MATK;
- status->IconChangeTable[SC_PLUSATTACKPOWER] = SI_PLUSATTACKPOWER;
- status->IconChangeTable[SC_PLUSMAGICPOWER] = SI_PLUSMAGICPOWER;
+ status->dbs->IconChangeTable[SC_WEIGHTOVER50] = SI_WEIGHTOVER50;
+ status->dbs->IconChangeTable[SC_WEIGHTOVER90] = SI_WEIGHTOVER90;
+ status->dbs->IconChangeTable[SC_ATTHASTE_POTION1] = SI_ATTHASTE_POTION1;
+ status->dbs->IconChangeTable[SC_ATTHASTE_POTION2] = SI_ATTHASTE_POTION2;
+ status->dbs->IconChangeTable[SC_ATTHASTE_POTION3] = SI_ATTHASTE_POTION3;
+ status->dbs->IconChangeTable[SC_ATTHASTE_INFINITY] = SI_ATTHASTE_INFINITY;
+ status->dbs->IconChangeTable[SC_MOVHASTE_HORSE] = SI_MOVHASTE_HORSE;
+ status->dbs->IconChangeTable[SC_MOVHASTE_INFINITY] = SI_MOVHASTE_INFINITY;
+ status->dbs->IconChangeTable[SC_CHASEWALK2] = SI_INCSTR;
+ status->dbs->IconChangeTable[SC_MIRACLE] = SI_SOULLINK;
+ status->dbs->IconChangeTable[SC_CLAIRVOYANCE] = SI_CLAIRVOYANCE;
+ status->dbs->IconChangeTable[SC_FOOD_STR] = SI_FOOD_STR;
+ status->dbs->IconChangeTable[SC_FOOD_AGI] = SI_FOOD_AGI;
+ status->dbs->IconChangeTable[SC_FOOD_VIT] = SI_FOOD_VIT;
+ status->dbs->IconChangeTable[SC_FOOD_INT] = SI_FOOD_INT;
+ status->dbs->IconChangeTable[SC_FOOD_DEX] = SI_FOOD_DEX;
+ status->dbs->IconChangeTable[SC_FOOD_LUK] = SI_FOOD_LUK;
+ status->dbs->IconChangeTable[SC_FOOD_BASICAVOIDANCE]= SI_FOOD_BASICAVOIDANCE;
+ status->dbs->IconChangeTable[SC_FOOD_BASICHIT] = SI_FOOD_BASICHIT;
+ status->dbs->IconChangeTable[SC_MANU_ATK] = SI_MANU_ATK;
+ status->dbs->IconChangeTable[SC_MANU_DEF] = SI_MANU_DEF;
+ status->dbs->IconChangeTable[SC_SPL_ATK] = SI_SPL_ATK;
+ status->dbs->IconChangeTable[SC_SPL_DEF] = SI_SPL_DEF;
+ status->dbs->IconChangeTable[SC_MANU_MATK] = SI_MANU_MATK;
+ status->dbs->IconChangeTable[SC_SPL_MATK] = SI_SPL_MATK;
+ status->dbs->IconChangeTable[SC_PLUSATTACKPOWER] = SI_PLUSATTACKPOWER;
+ status->dbs->IconChangeTable[SC_PLUSMAGICPOWER] = SI_PLUSMAGICPOWER;
//Cash Items
- status->IconChangeTable[SC_FOOD_STR_CASH] = SI_FOOD_STR_CASH;
- status->IconChangeTable[SC_FOOD_AGI_CASH] = SI_FOOD_AGI_CASH;
- status->IconChangeTable[SC_FOOD_VIT_CASH] = SI_FOOD_VIT_CASH;
- status->IconChangeTable[SC_FOOD_DEX_CASH] = SI_FOOD_DEX_CASH;
- status->IconChangeTable[SC_FOOD_INT_CASH] = SI_FOOD_INT_CASH;
- status->IconChangeTable[SC_FOOD_LUK_CASH] = SI_FOOD_LUK_CASH;
- status->IconChangeTable[SC_CASH_PLUSEXP] = SI_CASH_PLUSEXP;
- status->IconChangeTable[SC_CASH_RECEIVEITEM] = SI_CASH_RECEIVEITEM;
- status->IconChangeTable[SC_CASH_PLUSONLYJOBEXP] = SI_CASH_PLUSONLYJOBEXP;
- status->IconChangeTable[SC_CASH_DEATHPENALTY] = SI_CASH_DEATHPENALTY;
- status->IconChangeTable[SC_CASH_BOSS_ALARM] = SI_CASH_BOSS_ALARM;
- status->IconChangeTable[SC_PROTECT_DEF] = SI_PROTECT_DEF;
- status->IconChangeTable[SC_PROTECT_MDEF] = SI_PROTECT_MDEF;
- status->IconChangeTable[SC_CRITICALPERCENT] = SI_CRITICALPERCENT;
- status->IconChangeTable[SC_PLUSAVOIDVALUE] = SI_PLUSAVOIDVALUE;
- status->IconChangeTable[SC_HEALPLUS] = SI_HEALPLUS;
- status->IconChangeTable[SC_S_LIFEPOTION] = SI_S_LIFEPOTION;
- status->IconChangeTable[SC_L_LIFEPOTION] = SI_L_LIFEPOTION;
- status->IconChangeTable[SC_ATKER_BLOOD] = SI_ATKER_BLOOD;
- status->IconChangeTable[SC_TARGET_BLOOD] = SI_TARGET_BLOOD;
+ status->dbs->IconChangeTable[SC_FOOD_STR_CASH] = SI_FOOD_STR_CASH;
+ status->dbs->IconChangeTable[SC_FOOD_AGI_CASH] = SI_FOOD_AGI_CASH;
+ status->dbs->IconChangeTable[SC_FOOD_VIT_CASH] = SI_FOOD_VIT_CASH;
+ status->dbs->IconChangeTable[SC_FOOD_DEX_CASH] = SI_FOOD_DEX_CASH;
+ status->dbs->IconChangeTable[SC_FOOD_INT_CASH] = SI_FOOD_INT_CASH;
+ status->dbs->IconChangeTable[SC_FOOD_LUK_CASH] = SI_FOOD_LUK_CASH;
+ status->dbs->IconChangeTable[SC_CASH_PLUSEXP] = SI_CASH_PLUSEXP;
+ status->dbs->IconChangeTable[SC_CASH_RECEIVEITEM] = SI_CASH_RECEIVEITEM;
+ status->dbs->IconChangeTable[SC_CASH_PLUSONLYJOBEXP] = SI_CASH_PLUSONLYJOBEXP;
+ status->dbs->IconChangeTable[SC_CASH_DEATHPENALTY] = SI_CASH_DEATHPENALTY;
+ status->dbs->IconChangeTable[SC_CASH_BOSS_ALARM] = SI_CASH_BOSS_ALARM;
+ status->dbs->IconChangeTable[SC_PROTECT_DEF] = SI_PROTECT_DEF;
+ status->dbs->IconChangeTable[SC_PROTECT_MDEF] = SI_PROTECT_MDEF;
+ status->dbs->IconChangeTable[SC_CRITICALPERCENT] = SI_CRITICALPERCENT;
+ status->dbs->IconChangeTable[SC_PLUSAVOIDVALUE] = SI_PLUSAVOIDVALUE;
+ status->dbs->IconChangeTable[SC_HEALPLUS] = SI_HEALPLUS;
+ status->dbs->IconChangeTable[SC_S_LIFEPOTION] = SI_S_LIFEPOTION;
+ status->dbs->IconChangeTable[SC_L_LIFEPOTION] = SI_L_LIFEPOTION;
+ status->dbs->IconChangeTable[SC_ATKER_BLOOD] = SI_ATKER_BLOOD;
+ status->dbs->IconChangeTable[SC_TARGET_BLOOD] = SI_TARGET_BLOOD;
// Mercenary Bonus Effects
- status->IconChangeTable[SC_MER_FLEE] = SI_MER_FLEE;
- status->IconChangeTable[SC_MER_ATK] = SI_MER_ATK;
- status->IconChangeTable[SC_MER_HP] = SI_MER_HP;
- status->IconChangeTable[SC_MER_SP] = SI_MER_SP;
- status->IconChangeTable[SC_MER_HIT] = SI_MER_HIT;
+ status->dbs->IconChangeTable[SC_MER_FLEE] = SI_MER_FLEE;
+ status->dbs->IconChangeTable[SC_MER_ATK] = SI_MER_ATK;
+ status->dbs->IconChangeTable[SC_MER_HP] = SI_MER_HP;
+ status->dbs->IconChangeTable[SC_MER_SP] = SI_MER_SP;
+ status->dbs->IconChangeTable[SC_MER_HIT] = SI_MER_HIT;
// Warlock Spheres
- status->IconChangeTable[SC_SUMMON1] = SI_SPHERE_1;
- status->IconChangeTable[SC_SUMMON2] = SI_SPHERE_2;
- status->IconChangeTable[SC_SUMMON3] = SI_SPHERE_3;
- status->IconChangeTable[SC_SUMMON4] = SI_SPHERE_4;
- status->IconChangeTable[SC_SUMMON5] = SI_SPHERE_5;
+ status->dbs->IconChangeTable[SC_SUMMON1] = SI_SPHERE_1;
+ status->dbs->IconChangeTable[SC_SUMMON2] = SI_SPHERE_2;
+ status->dbs->IconChangeTable[SC_SUMMON3] = SI_SPHERE_3;
+ status->dbs->IconChangeTable[SC_SUMMON4] = SI_SPHERE_4;
+ status->dbs->IconChangeTable[SC_SUMMON5] = SI_SPHERE_5;
// Warlock Preserved spells
- status->IconChangeTable[SC_SPELLBOOK1] = SI_SPELLBOOK1;
- status->IconChangeTable[SC_SPELLBOOK2] = SI_SPELLBOOK2;
- status->IconChangeTable[SC_SPELLBOOK3] = SI_SPELLBOOK3;
- status->IconChangeTable[SC_SPELLBOOK4] = SI_SPELLBOOK4;
- status->IconChangeTable[SC_SPELLBOOK5] = SI_SPELLBOOK5;
- status->IconChangeTable[SC_SPELLBOOK6] = SI_SPELLBOOK6;
- status->IconChangeTable[SC_SPELLBOOK7] = SI_SPELLBOOK7;
-
- status->IconChangeTable[SC_NEUTRALBARRIER_MASTER] = SI_NEUTRALBARRIER_MASTER;
- status->IconChangeTable[SC_STEALTHFIELD_MASTER] = SI_STEALTHFIELD_MASTER;
- status->IconChangeTable[SC_OVERHEAT] = SI_OVERHEAT;
- status->IconChangeTable[SC_OVERHEAT_LIMITPOINT] = SI_OVERHEAT_LIMITPOINT;
-
- status->IconChangeTable[SC_HALLUCINATIONWALK_POSTDELAY] = SI_HALLUCINATIONWALK_POSTDELAY;
- status->IconChangeTable[SC_TOXIN] = SI_TOXIN;
- status->IconChangeTable[SC_PARALYSE] = SI_PARALYSE;
- status->IconChangeTable[SC_VENOMBLEED] = SI_VENOMBLEED;
- status->IconChangeTable[SC_MAGICMUSHROOM] = SI_MAGICMUSHROOM;
- status->IconChangeTable[SC_DEATHHURT] = SI_DEATHHURT;
- status->IconChangeTable[SC_PYREXIA] = SI_PYREXIA;
- status->IconChangeTable[SC_OBLIVIONCURSE] = SI_OBLIVIONCURSE;
- status->IconChangeTable[SC_LEECHESEND] = SI_LEECHESEND;
-
- status->IconChangeTable[SC_SHIELDSPELL_DEF] = SI_SHIELDSPELL_DEF;
- status->IconChangeTable[SC_SHIELDSPELL_MDEF] = SI_SHIELDSPELL_MDEF;
- status->IconChangeTable[SC_SHIELDSPELL_REF] = SI_SHIELDSPELL_REF;
- status->IconChangeTable[SC_BANDING_DEFENCE] = SI_BANDING_DEFENCE;
-
- status->IconChangeTable[SC_CURSEDCIRCLE_ATKER] = SI_CURSEDCIRCLE_ATKER;
-
- status->IconChangeTable[SC_STOMACHACHE] = SI_STOMACHACHE;
- status->IconChangeTable[SC_MYSTERIOUS_POWDER] = SI_MYSTERIOUS_POWDER;
- status->IconChangeTable[SC_MELON_BOMB] = SI_MELON_BOMB;
- status->IconChangeTable[SC_BANANA_BOMB] = SI_BANANA_BOMB;
- status->IconChangeTable[SC_BANANA_BOMB_SITDOWN_POSTDELAY] = SI_BANANA_BOMB_SITDOWN_POSTDELAY;
+ status->dbs->IconChangeTable[SC_SPELLBOOK1] = SI_SPELLBOOK1;
+ status->dbs->IconChangeTable[SC_SPELLBOOK2] = SI_SPELLBOOK2;
+ status->dbs->IconChangeTable[SC_SPELLBOOK3] = SI_SPELLBOOK3;
+ status->dbs->IconChangeTable[SC_SPELLBOOK4] = SI_SPELLBOOK4;
+ status->dbs->IconChangeTable[SC_SPELLBOOK5] = SI_SPELLBOOK5;
+ status->dbs->IconChangeTable[SC_SPELLBOOK6] = SI_SPELLBOOK6;
+ status->dbs->IconChangeTable[SC_SPELLBOOK7] = SI_SPELLBOOK7;
+
+ status->dbs->IconChangeTable[SC_NEUTRALBARRIER_MASTER] = SI_NEUTRALBARRIER_MASTER;
+ status->dbs->IconChangeTable[SC_STEALTHFIELD_MASTER] = SI_STEALTHFIELD_MASTER;
+ status->dbs->IconChangeTable[SC_OVERHEAT] = SI_OVERHEAT;
+ status->dbs->IconChangeTable[SC_OVERHEAT_LIMITPOINT] = SI_OVERHEAT_LIMITPOINT;
+
+ status->dbs->IconChangeTable[SC_HALLUCINATIONWALK_POSTDELAY] = SI_HALLUCINATIONWALK_POSTDELAY;
+ status->dbs->IconChangeTable[SC_TOXIN] = SI_TOXIN;
+ status->dbs->IconChangeTable[SC_PARALYSE] = SI_PARALYSE;
+ status->dbs->IconChangeTable[SC_VENOMBLEED] = SI_VENOMBLEED;
+ status->dbs->IconChangeTable[SC_MAGICMUSHROOM] = SI_MAGICMUSHROOM;
+ status->dbs->IconChangeTable[SC_DEATHHURT] = SI_DEATHHURT;
+ status->dbs->IconChangeTable[SC_PYREXIA] = SI_PYREXIA;
+ status->dbs->IconChangeTable[SC_OBLIVIONCURSE] = SI_OBLIVIONCURSE;
+ status->dbs->IconChangeTable[SC_LEECHESEND] = SI_LEECHESEND;
+
+ status->dbs->IconChangeTable[SC_SHIELDSPELL_DEF] = SI_SHIELDSPELL_DEF;
+ status->dbs->IconChangeTable[SC_SHIELDSPELL_MDEF] = SI_SHIELDSPELL_MDEF;
+ status->dbs->IconChangeTable[SC_SHIELDSPELL_REF] = SI_SHIELDSPELL_REF;
+ status->dbs->IconChangeTable[SC_BANDING_DEFENCE] = SI_BANDING_DEFENCE;
+
+ status->dbs->IconChangeTable[SC_CURSEDCIRCLE_ATKER] = SI_CURSEDCIRCLE_ATKER;
+
+ status->dbs->IconChangeTable[SC_STOMACHACHE] = SI_STOMACHACHE;
+ status->dbs->IconChangeTable[SC_MYSTERIOUS_POWDER] = SI_MYSTERIOUS_POWDER;
+ status->dbs->IconChangeTable[SC_MELON_BOMB] = SI_MELON_BOMB;
+ status->dbs->IconChangeTable[SC_BANANA_BOMB] = SI_BANANA_BOMB;
+ status->dbs->IconChangeTable[SC_BANANA_BOMB_SITDOWN_POSTDELAY] = SI_BANANA_BOMB_SITDOWN_POSTDELAY;
//Genetics New Food Items Status Icons
- status->IconChangeTable[SC_SAVAGE_STEAK] = SI_SAVAGE_STEAK;
- status->IconChangeTable[SC_COCKTAIL_WARG_BLOOD] = SI_COCKTAIL_WARG_BLOOD;
- status->IconChangeTable[SC_MINOR_BBQ] = SI_MINOR_BBQ;
- status->IconChangeTable[SC_SIROMA_ICE_TEA] = SI_SIROMA_ICE_TEA;
- status->IconChangeTable[SC_DROCERA_HERB_STEAMED] = SI_DROCERA_HERB_STEAMED;
- status->IconChangeTable[SC_PUTTI_TAILS_NOODLES] = SI_PUTTI_TAILS_NOODLES;
-
- status->IconChangeTable[SC_BOOST500] |= SI_BOOST500;
- status->IconChangeTable[SC_FULL_SWING_K] |= SI_FULL_SWING_K;
- status->IconChangeTable[SC_MANA_PLUS] |= SI_MANA_PLUS;
- status->IconChangeTable[SC_MUSTLE_M] |= SI_MUSTLE_M;
- status->IconChangeTable[SC_LIFE_FORCE_F] |= SI_LIFE_FORCE_F;
- status->IconChangeTable[SC_EXTRACT_WHITE_POTION_Z] |= SI_EXTRACT_WHITE_POTION_Z;
- status->IconChangeTable[SC_VITATA_500] |= SI_VITATA_500;
- status->IconChangeTable[SC_EXTRACT_SALAMINE_JUICE] |= SI_EXTRACT_SALAMINE_JUICE;
+ status->dbs->IconChangeTable[SC_SAVAGE_STEAK] = SI_SAVAGE_STEAK;
+ status->dbs->IconChangeTable[SC_COCKTAIL_WARG_BLOOD] = SI_COCKTAIL_WARG_BLOOD;
+ status->dbs->IconChangeTable[SC_MINOR_BBQ] = SI_MINOR_BBQ;
+ status->dbs->IconChangeTable[SC_SIROMA_ICE_TEA] = SI_SIROMA_ICE_TEA;
+ status->dbs->IconChangeTable[SC_DROCERA_HERB_STEAMED] = SI_DROCERA_HERB_STEAMED;
+ status->dbs->IconChangeTable[SC_PUTTI_TAILS_NOODLES] = SI_PUTTI_TAILS_NOODLES;
+
+ status->dbs->IconChangeTable[SC_BOOST500] |= SI_BOOST500;
+ status->dbs->IconChangeTable[SC_FULL_SWING_K] |= SI_FULL_SWING_K;
+ status->dbs->IconChangeTable[SC_MANA_PLUS] |= SI_MANA_PLUS;
+ status->dbs->IconChangeTable[SC_MUSTLE_M] |= SI_MUSTLE_M;
+ status->dbs->IconChangeTable[SC_LIFE_FORCE_F] |= SI_LIFE_FORCE_F;
+ status->dbs->IconChangeTable[SC_EXTRACT_WHITE_POTION_Z] |= SI_EXTRACT_WHITE_POTION_Z;
+ status->dbs->IconChangeTable[SC_VITATA_500] |= SI_VITATA_500;
+ status->dbs->IconChangeTable[SC_EXTRACT_SALAMINE_JUICE] |= SI_EXTRACT_SALAMINE_JUICE;
// Elemental Spirit's 'side' status change icons.
- status->IconChangeTable[SC_CIRCLE_OF_FIRE] = SI_CIRCLE_OF_FIRE;
- status->IconChangeTable[SC_FIRE_CLOAK] = SI_FIRE_CLOAK;
- status->IconChangeTable[SC_WATER_SCREEN] = SI_WATER_SCREEN;
- status->IconChangeTable[SC_WATER_DROP] = SI_WATER_DROP;
- status->IconChangeTable[SC_WIND_STEP] = SI_WIND_STEP;
- status->IconChangeTable[SC_WIND_CURTAIN] = SI_WIND_CURTAIN;
- status->IconChangeTable[SC_SOLID_SKIN] = SI_SOLID_SKIN;
- status->IconChangeTable[SC_STONE_SHIELD] = SI_STONE_SHIELD;
- status->IconChangeTable[SC_PYROTECHNIC] = SI_PYROTECHNIC;
- status->IconChangeTable[SC_HEATER] = SI_HEATER;
- status->IconChangeTable[SC_TROPIC] = SI_TROPIC;
- status->IconChangeTable[SC_AQUAPLAY] = SI_AQUAPLAY;
- status->IconChangeTable[SC_COOLER] = SI_COOLER;
- status->IconChangeTable[SC_CHILLY_AIR] = SI_CHILLY_AIR;
- status->IconChangeTable[SC_GUST] = SI_GUST;
- status->IconChangeTable[SC_BLAST] = SI_BLAST;
- status->IconChangeTable[SC_WILD_STORM] = SI_WILD_STORM;
- status->IconChangeTable[SC_PETROLOGY] = SI_PETROLOGY;
- status->IconChangeTable[SC_CURSED_SOIL] = SI_CURSED_SOIL;
- status->IconChangeTable[SC_UPHEAVAL] = SI_UPHEAVAL;
- status->IconChangeTable[SC_PUSH_CART] = SI_ON_PUSH_CART;
- status->IconChangeTable[SC_REBOUND] = SI_REBOUND;
- status->IconChangeTable[SC_ALL_RIDING] = SI_ALL_RIDING;
- status->IconChangeTable[SC_MONSTER_TRANSFORM] = SI_MONSTER_TRANSFORM;
- status->IconChangeTable[SC_MOONSTAR] = SI_MOONSTAR;
- status->IconChangeTable[SC_SUPER_STAR] = SI_SUPER_STAR;
- status->IconChangeTable[SC_STRANGELIGHTS] = SI_STRANGELIGHTS;
- status->IconChangeTable[SC_DECORATION_OF_MUSIC] = SI_DECORATION_OF_MUSIC;
+ status->dbs->IconChangeTable[SC_CIRCLE_OF_FIRE] = SI_CIRCLE_OF_FIRE;
+ status->dbs->IconChangeTable[SC_FIRE_CLOAK] = SI_FIRE_CLOAK;
+ status->dbs->IconChangeTable[SC_WATER_SCREEN] = SI_WATER_SCREEN;
+ status->dbs->IconChangeTable[SC_WATER_DROP] = SI_WATER_DROP;
+ status->dbs->IconChangeTable[SC_WIND_STEP] = SI_WIND_STEP;
+ status->dbs->IconChangeTable[SC_WIND_CURTAIN] = SI_WIND_CURTAIN;
+ status->dbs->IconChangeTable[SC_SOLID_SKIN] = SI_SOLID_SKIN;
+ status->dbs->IconChangeTable[SC_STONE_SHIELD] = SI_STONE_SHIELD;
+ status->dbs->IconChangeTable[SC_PYROTECHNIC] = SI_PYROTECHNIC;
+ status->dbs->IconChangeTable[SC_HEATER] = SI_HEATER;
+ status->dbs->IconChangeTable[SC_TROPIC] = SI_TROPIC;
+ status->dbs->IconChangeTable[SC_AQUAPLAY] = SI_AQUAPLAY;
+ status->dbs->IconChangeTable[SC_COOLER] = SI_COOLER;
+ status->dbs->IconChangeTable[SC_CHILLY_AIR] = SI_CHILLY_AIR;
+ status->dbs->IconChangeTable[SC_GUST] = SI_GUST;
+ status->dbs->IconChangeTable[SC_BLAST] = SI_BLAST;
+ status->dbs->IconChangeTable[SC_WILD_STORM] = SI_WILD_STORM;
+ status->dbs->IconChangeTable[SC_PETROLOGY] = SI_PETROLOGY;
+ status->dbs->IconChangeTable[SC_CURSED_SOIL] = SI_CURSED_SOIL;
+ status->dbs->IconChangeTable[SC_UPHEAVAL] = SI_UPHEAVAL;
+ status->dbs->IconChangeTable[SC_PUSH_CART] = SI_ON_PUSH_CART;
+ status->dbs->IconChangeTable[SC_REBOUND] = SI_REBOUND;
+ status->dbs->IconChangeTable[SC_ALL_RIDING] = SI_ALL_RIDING;
+ status->dbs->IconChangeTable[SC_MONSTER_TRANSFORM] = SI_MONSTER_TRANSFORM;
+ status->dbs->IconChangeTable[SC_MOONSTAR] = SI_MOONSTAR;
+ status->dbs->IconChangeTable[SC_SUPER_STAR] = SI_SUPER_STAR;
+ status->dbs->IconChangeTable[SC_STRANGELIGHTS] = SI_STRANGELIGHTS;
+ status->dbs->IconChangeTable[SC_DECORATION_OF_MUSIC] = SI_DECORATION_OF_MUSIC;
//Other SC which are not necessarily associated to skills.
- status->ChangeFlagTable[SC_ATTHASTE_POTION1] = SCB_ASPD;
- status->ChangeFlagTable[SC_ATTHASTE_POTION2] = SCB_ASPD;
- status->ChangeFlagTable[SC_ATTHASTE_POTION3] = SCB_ASPD;
- status->ChangeFlagTable[SC_ATTHASTE_INFINITY] = SCB_ASPD;
- status->ChangeFlagTable[SC_MOVHASTE_HORSE] = SCB_SPEED;
- status->ChangeFlagTable[SC_MOVHASTE_INFINITY] = SCB_SPEED;
- status->ChangeFlagTable[SC_PLUSATTACKPOWER] = SCB_BATK;
- status->ChangeFlagTable[SC_PLUSMAGICPOWER] = SCB_MATK;
- status->ChangeFlagTable[SC_INCALLSTATUS] |= SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK;
- status->ChangeFlagTable[SC_CHASEWALK2] |= SCB_STR;
- status->ChangeFlagTable[SC_INCAGI] |= SCB_AGI;
- status->ChangeFlagTable[SC_INCVIT] |= SCB_VIT;
- status->ChangeFlagTable[SC_INCINT] |= SCB_INT;
- status->ChangeFlagTable[SC_INCDEX] |= SCB_DEX;
- status->ChangeFlagTable[SC_INCLUK] |= SCB_LUK;
- status->ChangeFlagTable[SC_INCHIT] |= SCB_HIT;
- 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;
- status->ChangeFlagTable[SC_FOOD_STR] |= SCB_STR;
- status->ChangeFlagTable[SC_FOOD_AGI] |= SCB_AGI;
- status->ChangeFlagTable[SC_FOOD_VIT] |= SCB_VIT;
- status->ChangeFlagTable[SC_FOOD_INT] |= SCB_INT;
- status->ChangeFlagTable[SC_FOOD_DEX] |= SCB_DEX;
- status->ChangeFlagTable[SC_FOOD_LUK] |= SCB_LUK;
- status->ChangeFlagTable[SC_FOOD_BASICHIT] |= SCB_HIT;
- status->ChangeFlagTable[SC_FOOD_BASICAVOIDANCE] |= SCB_FLEE;
- status->ChangeFlagTable[SC_BATKFOOD] |= SCB_BATK;
- status->ChangeFlagTable[SC_WATKFOOD] |= SCB_WATK;
- status->ChangeFlagTable[SC_MATKFOOD] |= SCB_MATK;
- status->ChangeFlagTable[SC_ARMORPROPERTY] |= SCB_ALL;
- status->ChangeFlagTable[SC_ARMOR_RESIST] |= SCB_ALL;
- status->ChangeFlagTable[SC_ATKER_BLOOD] |= SCB_ALL;
- status->ChangeFlagTable[SC_WALKSPEED] |= SCB_SPEED;
- status->ChangeFlagTable[SC_ITEMSCRIPT] |= SCB_ALL;
+ status->dbs->ChangeFlagTable[SC_ATTHASTE_POTION1] = SCB_ASPD;
+ status->dbs->ChangeFlagTable[SC_ATTHASTE_POTION2] = SCB_ASPD;
+ status->dbs->ChangeFlagTable[SC_ATTHASTE_POTION3] = SCB_ASPD;
+ status->dbs->ChangeFlagTable[SC_ATTHASTE_INFINITY] = SCB_ASPD;
+ status->dbs->ChangeFlagTable[SC_MOVHASTE_HORSE] = SCB_SPEED;
+ status->dbs->ChangeFlagTable[SC_MOVHASTE_INFINITY] = SCB_SPEED;
+ status->dbs->ChangeFlagTable[SC_PLUSATTACKPOWER] = SCB_BATK;
+ status->dbs->ChangeFlagTable[SC_PLUSMAGICPOWER] = SCB_MATK;
+ status->dbs->ChangeFlagTable[SC_INCALLSTATUS] |= SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK;
+ status->dbs->ChangeFlagTable[SC_CHASEWALK2] |= SCB_STR;
+ status->dbs->ChangeFlagTable[SC_INCAGI] |= SCB_AGI;
+ status->dbs->ChangeFlagTable[SC_INCVIT] |= SCB_VIT;
+ status->dbs->ChangeFlagTable[SC_INCINT] |= SCB_INT;
+ status->dbs->ChangeFlagTable[SC_INCDEX] |= SCB_DEX;
+ status->dbs->ChangeFlagTable[SC_INCLUK] |= SCB_LUK;
+ status->dbs->ChangeFlagTable[SC_INCHIT] |= SCB_HIT;
+ status->dbs->ChangeFlagTable[SC_INCHITRATE] |= SCB_HIT;
+ status->dbs->ChangeFlagTable[SC_INCFLEE] |= SCB_FLEE;
+ status->dbs->ChangeFlagTable[SC_INCFLEERATE] |= SCB_FLEE;
+ status->dbs->ChangeFlagTable[SC_MTF_HITFLEE] |= SCB_HIT|SCB_FLEE;
+ status->dbs->ChangeFlagTable[SC_CRITICALPERCENT] |= SCB_CRI;
+ status->dbs->ChangeFlagTable[SC_INCASPDRATE] |= SCB_ASPD;
+ status->dbs->ChangeFlagTable[SC_PLUSAVOIDVALUE] |= SCB_FLEE2;
+ status->dbs->ChangeFlagTable[SC_INCMHPRATE] |= SCB_MAXHP;
+ status->dbs->ChangeFlagTable[SC_INCMSPRATE] |= SCB_MAXSP;
+ status->dbs->ChangeFlagTable[SC_INCMHP] |= SCB_MAXHP;
+ status->dbs->ChangeFlagTable[SC_MTF_MHP] |= SCB_MAXHP;
+ status->dbs->ChangeFlagTable[SC_INCMSP] |= SCB_MAXSP;
+ status->dbs->ChangeFlagTable[SC_MTF_MSP] |= SCB_MAXSP;
+ status->dbs->ChangeFlagTable[SC_INCATKRATE] |= SCB_BATK|SCB_WATK;
+ status->dbs->ChangeFlagTable[SC_INCMATKRATE] |= SCB_MATK;
+ status->dbs->ChangeFlagTable[SC_INCDEFRATE] |= SCB_DEF;
+ status->dbs->ChangeFlagTable[SC_FOOD_STR] |= SCB_STR;
+ status->dbs->ChangeFlagTable[SC_FOOD_AGI] |= SCB_AGI;
+ status->dbs->ChangeFlagTable[SC_FOOD_VIT] |= SCB_VIT;
+ status->dbs->ChangeFlagTable[SC_FOOD_INT] |= SCB_INT;
+ status->dbs->ChangeFlagTable[SC_FOOD_DEX] |= SCB_DEX;
+ status->dbs->ChangeFlagTable[SC_FOOD_LUK] |= SCB_LUK;
+ status->dbs->ChangeFlagTable[SC_FOOD_BASICHIT] |= SCB_HIT;
+ status->dbs->ChangeFlagTable[SC_FOOD_BASICAVOIDANCE] |= SCB_FLEE;
+ status->dbs->ChangeFlagTable[SC_BATKFOOD] |= SCB_BATK;
+ status->dbs->ChangeFlagTable[SC_WATKFOOD] |= SCB_WATK;
+ status->dbs->ChangeFlagTable[SC_MATKFOOD] |= SCB_MATK;
+ status->dbs->ChangeFlagTable[SC_ARMORPROPERTY] |= SCB_ALL;
+ status->dbs->ChangeFlagTable[SC_ARMOR_RESIST] |= SCB_ALL;
+ status->dbs->ChangeFlagTable[SC_ATKER_BLOOD] |= SCB_ALL;
+ status->dbs->ChangeFlagTable[SC_WALKSPEED] |= SCB_SPEED;
+ status->dbs->ChangeFlagTable[SC_ITEMSCRIPT] |= SCB_ALL;
// Cash Items
- status->ChangeFlagTable[SC_FOOD_STR_CASH] = SCB_STR;
- status->ChangeFlagTable[SC_FOOD_AGI_CASH] = SCB_AGI;
- status->ChangeFlagTable[SC_FOOD_VIT_CASH] = SCB_VIT;
- status->ChangeFlagTable[SC_FOOD_DEX_CASH] = SCB_DEX;
- status->ChangeFlagTable[SC_FOOD_INT_CASH] = SCB_INT;
- status->ChangeFlagTable[SC_FOOD_LUK_CASH] = SCB_LUK;
+ status->dbs->ChangeFlagTable[SC_FOOD_STR_CASH] = SCB_STR;
+ status->dbs->ChangeFlagTable[SC_FOOD_AGI_CASH] = SCB_AGI;
+ status->dbs->ChangeFlagTable[SC_FOOD_VIT_CASH] = SCB_VIT;
+ status->dbs->ChangeFlagTable[SC_FOOD_DEX_CASH] = SCB_DEX;
+ status->dbs->ChangeFlagTable[SC_FOOD_INT_CASH] = SCB_INT;
+ status->dbs->ChangeFlagTable[SC_FOOD_LUK_CASH] = SCB_LUK;
// Mercenary Bonus Effects
- status->ChangeFlagTable[SC_MER_FLEE] |= SCB_FLEE;
- status->ChangeFlagTable[SC_MER_ATK] |= SCB_WATK;
- status->ChangeFlagTable[SC_MER_HP] |= SCB_MAXHP;
- status->ChangeFlagTable[SC_MER_SP] |= SCB_MAXSP;
- status->ChangeFlagTable[SC_MER_HIT] |= SCB_HIT;
+ status->dbs->ChangeFlagTable[SC_MER_FLEE] |= SCB_FLEE;
+ status->dbs->ChangeFlagTable[SC_MER_ATK] |= SCB_WATK;
+ status->dbs->ChangeFlagTable[SC_MER_HP] |= SCB_MAXHP;
+ status->dbs->ChangeFlagTable[SC_MER_SP] |= SCB_MAXSP;
+ status->dbs->ChangeFlagTable[SC_MER_HIT] |= SCB_HIT;
// Guillotine Cross Poison Effects
- status->ChangeFlagTable[SC_PARALYSE] |= SCB_FLEE|SCB_SPEED|SCB_ASPD;
- status->ChangeFlagTable[SC_VENOMBLEED] |= SCB_MAXHP;
- status->ChangeFlagTable[SC_MAGICMUSHROOM] |= SCB_REGEN;
- status->ChangeFlagTable[SC_DEATHHURT] |= SCB_REGEN;
- status->ChangeFlagTable[SC_PYREXIA] |= SCB_HIT|SCB_FLEE;
- status->ChangeFlagTable[SC_OBLIVIONCURSE] |= SCB_REGEN;
+ status->dbs->ChangeFlagTable[SC_PARALYSE] |= SCB_FLEE|SCB_SPEED|SCB_ASPD;
+ status->dbs->ChangeFlagTable[SC_VENOMBLEED] |= SCB_MAXHP;
+ status->dbs->ChangeFlagTable[SC_MAGICMUSHROOM] |= SCB_REGEN;
+ status->dbs->ChangeFlagTable[SC_DEATHHURT] |= SCB_REGEN;
+ status->dbs->ChangeFlagTable[SC_PYREXIA] |= SCB_HIT|SCB_FLEE;
+ status->dbs->ChangeFlagTable[SC_OBLIVIONCURSE] |= SCB_REGEN;
// RG status
- status->ChangeFlagTable[SC_SHIELDSPELL_DEF] |= SCB_WATK;
- status->ChangeFlagTable[SC_SHIELDSPELL_REF] |= SCB_DEF;
+ status->dbs->ChangeFlagTable[SC_SHIELDSPELL_DEF] |= SCB_WATK;
+ status->dbs->ChangeFlagTable[SC_SHIELDSPELL_REF] |= SCB_DEF;
// Meca status
- status->ChangeFlagTable[SC_STEALTHFIELD_MASTER] |= SCB_SPEED;
-
- status->ChangeFlagTable[SC_SAVAGE_STEAK] |= SCB_STR;
- status->ChangeFlagTable[SC_COCKTAIL_WARG_BLOOD] |= SCB_INT;
- status->ChangeFlagTable[SC_MINOR_BBQ] |= SCB_VIT;
- status->ChangeFlagTable[SC_SIROMA_ICE_TEA] |= SCB_DEX;
- status->ChangeFlagTable[SC_DROCERA_HERB_STEAMED] |= SCB_AGI;
- status->ChangeFlagTable[SC_PUTTI_TAILS_NOODLES] |= SCB_LUK;
- status->ChangeFlagTable[SC_BOOST500] |= SCB_ASPD;
- status->ChangeFlagTable[SC_FULL_SWING_K] |= SCB_BATK;
- status->ChangeFlagTable[SC_MANA_PLUS] |= SCB_MATK;
- status->ChangeFlagTable[SC_MUSTLE_M] |= SCB_MAXHP;
- status->ChangeFlagTable[SC_LIFE_FORCE_F] |= SCB_MAXSP;
- status->ChangeFlagTable[SC_EXTRACT_WHITE_POTION_Z] |= SCB_REGEN;
- status->ChangeFlagTable[SC_VITATA_500] |= SCB_REGEN;
- status->ChangeFlagTable[SC_EXTRACT_SALAMINE_JUICE] |= SCB_ASPD;
- 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;
-
- status->ChangeFlagTable[SC_MTF_ASPD] = SCB_ASPD|SCB_HIT;
- status->ChangeFlagTable[SC_MTF_MATK] = SCB_MATK;
- status->ChangeFlagTable[SC_MTF_MLEATKED] |= SCB_ALL;
-
- status->ChangeFlagTable[SC_MOONSTAR] |= SCB_NONE;
- status->ChangeFlagTable[SC_SUPER_STAR] |= SCB_NONE;
- status->ChangeFlagTable[SC_STRANGELIGHTS] |= SCB_NONE;
- 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;
-
-#ifdef RENEWAL_EDP
- // renewal EDP increases your weapon atk
- status->ChangeFlagTable[SC_EDP] |= SCB_WATK;
-#endif
+ status->dbs->ChangeFlagTable[SC_STEALTHFIELD_MASTER] |= SCB_SPEED;
+
+ status->dbs->ChangeFlagTable[SC_SAVAGE_STEAK] |= SCB_STR;
+ status->dbs->ChangeFlagTable[SC_COCKTAIL_WARG_BLOOD] |= SCB_INT;
+ status->dbs->ChangeFlagTable[SC_MINOR_BBQ] |= SCB_VIT;
+ status->dbs->ChangeFlagTable[SC_SIROMA_ICE_TEA] |= SCB_DEX;
+ status->dbs->ChangeFlagTable[SC_DROCERA_HERB_STEAMED] |= SCB_AGI;
+ status->dbs->ChangeFlagTable[SC_PUTTI_TAILS_NOODLES] |= SCB_LUK;
+ status->dbs->ChangeFlagTable[SC_BOOST500] |= SCB_ASPD;
+ status->dbs->ChangeFlagTable[SC_FULL_SWING_K] |= SCB_BATK;
+ status->dbs->ChangeFlagTable[SC_MANA_PLUS] |= SCB_MATK;
+ status->dbs->ChangeFlagTable[SC_MUSTLE_M] |= SCB_MAXHP;
+ status->dbs->ChangeFlagTable[SC_LIFE_FORCE_F] |= SCB_MAXSP;
+ status->dbs->ChangeFlagTable[SC_EXTRACT_WHITE_POTION_Z] |= SCB_REGEN;
+ status->dbs->ChangeFlagTable[SC_VITATA_500] |= SCB_REGEN;
+ status->dbs->ChangeFlagTable[SC_EXTRACT_SALAMINE_JUICE] |= SCB_ASPD;
+ status->dbs->ChangeFlagTable[SC_REBOUND] |= SCB_SPEED|SCB_REGEN;
+ status->dbs->ChangeFlagTable[SC_DEFSET] |= SCB_DEF|SCB_DEF2;
+ status->dbs->ChangeFlagTable[SC_MDEFSET] |= SCB_MDEF|SCB_MDEF2;
+ status->dbs->ChangeFlagTable[SC_MYSTERIOUS_POWDER] |= SCB_MAXHP;
+
+ status->dbs->ChangeFlagTable[SC_ALL_RIDING] = SCB_SPEED;
+ status->dbs->ChangeFlagTable[SC_WEDDING] = SCB_SPEED;
+
+ status->dbs->ChangeFlagTable[SC_MTF_ASPD] = SCB_ASPD|SCB_HIT;
+ status->dbs->ChangeFlagTable[SC_MTF_MATK] = SCB_MATK;
+ status->dbs->ChangeFlagTable[SC_MTF_MLEATKED] |= SCB_ALL;
+
+ status->dbs->ChangeFlagTable[SC_MOONSTAR] |= SCB_NONE;
+ status->dbs->ChangeFlagTable[SC_SUPER_STAR] |= SCB_NONE;
+ status->dbs->ChangeFlagTable[SC_STRANGELIGHTS] |= SCB_NONE;
+ status->dbs->ChangeFlagTable[SC_DECORATION_OF_MUSIC] |= SCB_NONE;
+
+ /* status->dbs->DisplayType Table [Ind/Hercules] */
+ status->dbs->DisplayType[SC_ALL_RIDING] = true;
+ status->dbs->DisplayType[SC_PUSH_CART] = true;
+ status->dbs->DisplayType[SC_SUMMON1] = true;
+ status->dbs->DisplayType[SC_SUMMON2] = true;
+ status->dbs->DisplayType[SC_SUMMON3] = true;
+ status->dbs->DisplayType[SC_SUMMON4] = true;
+ status->dbs->DisplayType[SC_SUMMON5] = true;
+ status->dbs->DisplayType[SC_CAMOUFLAGE] = true;
+ status->dbs->DisplayType[SC_DUPLELIGHT] = true;
+ status->dbs->DisplayType[SC_ORATIO] = true;
+ status->dbs->DisplayType[SC_FROSTMISTY] = true;
+ status->dbs->DisplayType[SC_VENOMIMPRESS] = true;
+ status->dbs->DisplayType[SC_HALLUCINATIONWALK] = true;
+ status->dbs->DisplayType[SC_ROLLINGCUTTER] = true;
+ status->dbs->DisplayType[SC_BANDING] = true;
+ status->dbs->DisplayType[SC_COLD] = true;
+ status->dbs->DisplayType[SC_DEEP_SLEEP] = true;
+ status->dbs->DisplayType[SC_CURSEDCIRCLE_ATKER] = true;
+ status->dbs->DisplayType[SC_CURSEDCIRCLE_TARGET] = true;
+ status->dbs->DisplayType[SC_BLOOD_SUCKER] = true;
+ status->dbs->DisplayType[SC__SHADOWFORM] = true;
+ status->dbs->DisplayType[SC_MONSTER_TRANSFORM] = true;
+ status->dbs->DisplayType[SC_MOONSTAR] = true;
+ status->dbs->DisplayType[SC_SUPER_STAR] = true;
+ status->dbs->DisplayType[SC_STRANGELIGHTS] = true;
+ status->dbs->DisplayType[SC_DECORATION_OF_MUSIC] = true;
if( !battle_config.display_hallucination ) //Disable Hallucination.
- status->IconChangeTable[SC_ILLUSION] = SI_BLANK;
+ status->dbs->IconChangeTable[SC_ILLUSION] = SI_BLANK;
#undef add_sc
#undef set_sc_with_vfx
}
@@ -1199,7 +1195,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
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);
+ clif->damage(d_bl, d_bl, 0, 0, hp, 0, BDT_NORMAL, 0);
status_fix_damage(NULL, d_bl, hp, 0);
return 0;
}
@@ -1266,7 +1262,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
}
if( src && target->type == BL_PC && (((TBL_PC*)target)->disguise) > 0 ) {// stop walking when attacked in disguise to prevent walk-delay bug
- unit->stop_walking( target, 1 );
+ unit->stop_walking(target, STOPWALKING_FLAG_FIXPOS);
}
if (st->hp || (flag&8)) {
@@ -1349,7 +1345,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
unit->remove_map(target,CLR_DEAD,ALC_MARK);
else { //Some death states that would normally be handled by unit_remove_map
unit->stop_attack(target);
- unit->stop_walking(target,1);
+ unit->stop_walking(target, STOPWALKING_FLAG_FIXPOS);
unit->skillcastcancel(target,0);
clif->clearunit_area(target,CLR_DEAD);
skill->unit_move(target,timer->gettick(),4);
@@ -1601,13 +1597,13 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
for(i = 0; i < map->list[src->m].zone->disabled_skills_count; i++) {
if( skill_id == map->list[src->m].zone->disabled_skills[i]->nameid && (map->list[src->m].zone->disabled_skills[i]->type&src->type) ) {
- 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 ) { /** is boss **/
+ if (src->type == BL_PC) {
+ clif->msgtable((TBL_PC*)src, MSG_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 ) { /* is boss */
if( !( map->list[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS ) )
break;
- } else { /** is not boss **/
+ } else { /* is not boss */
if( map->list[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS )
break;
}
@@ -1657,15 +1653,19 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
(sc->data[SC_TRICKDEAD] && skill_id != NV_TRICKDEAD)
|| (sc->data[SC_AUTOCOUNTER] && !flag && skill_id)
|| (sc->data[SC_GOSPEL] && sc->data[SC_GOSPEL]->val4 == BCT_SELF && skill_id != PA_GOSPEL)
- || (sc->data[SC_GRAVITATION] && sc->data[SC_GRAVITATION]->val3 == BCT_SELF && flag != 2)
)
return 0;
if (sc->data[SC_DC_WINKCHARM] && target && !flag) { //Prevents skill usage
- if( unit->bl2ud(src) && (unit->bl2ud(src))->walktimer == INVALID_TIMER )
- unit->walktobl(src, map->id2bl(sc->data[SC_DC_WINKCHARM]->val2), 3, 1);
- clif->emotion(src, E_LV);
- return 0;
+ struct block_list *winkcharm_target = map->id2bl(sc->data[SC_DC_WINKCHARM]->val2);
+ if (winkcharm_target != NULL) {
+ if (unit->bl2ud(src) && (unit->bl2ud(src))->walktimer == INVALID_TIMER)
+ unit->walktobl(src, map->id2bl(sc->data[SC_DC_WINKCHARM]->val2), 3, 1);
+ clif->emotion(src, E_LV);
+ return 0;
+ } else {
+ status_change_end(src, SC_DC_WINKCHARM, INVALID_TIMER);
+ }
}
if (sc->data[SC_BLADESTOP]) {
@@ -1880,7 +1880,7 @@ int status_calc_mob_(struct mob_data* md, enum e_status_calc_opt opt) {
if (battle_config.slaves_inherit_speed && md->master_id)
flag|=8;
- if (md->master_id && md->special_state.ai>1)
+ if (md->master_id && md->special_state.ai > AI_ATTACK)
flag|=16;
if (!flag)
@@ -1916,8 +1916,8 @@ int status_calc_mob_(struct mob_data* md, enum e_status_calc_opt opt) {
//Max HP setting from Summon Flora/marine Sphere
struct unit_data *ud = unit->bl2ud(mbl);
//Remove special AI when this is used by regular mobs.
- if (mbl->type == BL_MOB && !((TBL_MOB*)mbl)->special_state.ai)
- md->special_state.ai = 0;
+ if (mbl->type == BL_MOB && ((TBL_MOB*)mbl)->special_state.ai == AI_NONE)
+ md->special_state.ai = AI_NONE;
if (ud) {
// different levels of HP according to skill level
if (ud->skill_id == AM_SPHEREMINE) {
@@ -2087,64 +2087,42 @@ int status_calc_pet_(struct pet_data *pd, enum e_status_calc_opt opt)
return 1;
}
-/// Helper function for status_base_pc_maxhp(), used to pre-calculate the hp_sigma_val[] array
-void status_calc_sigma(void)
-{
- int i,j;
+unsigned int status_get_base_maxsp(struct map_session_data* sd, struct status_data *st) {
+ uint64 val = pc->class2idx(sd->status.class_);
- for(i = 0; i < CLASS_COUNT; i++)
- {
- unsigned int k = 0;
- status->hp_sigma_val[i][0] = status->hp_sigma_val[i][1] = 0;
- for(j = 2; j <= MAX_LEVEL; j++)
- {
- k += (status->hp_coefficient[i]*j + 50) / 100;
- status->hp_sigma_val[i][j] = k;
- if (k >= INT_MAX)
- break; //Overflow protection. [Skotlex]
- }
- for(; j <= MAX_LEVEL; j++)
- status->hp_sigma_val[i][j] = INT_MAX;
- }
+ val = status->dbs->SP_table[val][sd->status.base_level];
+
+ if ( sd->class_&JOBL_UPPER )
+ val += val * 25 / 100;
+ else if ( sd->class_&JOBL_BABY )
+ val = val * 70 / 100;
+ if ( (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )
+ val *= 3; //Triple max SP for top ranking Taekwons over level 90.
+
+ val += val * st->int_ / 100;
+
+ return (unsigned int)cap_value(val, 0, UINT_MAX);
}
-/// Calculates base MaxHP value according to class and base level
-/// The recursive equation used to calculate level bonus is (using integer operations)
-/// f(0) = 35 | f(x+1) = f(x) + A + (x + B)*C/D
-/// which reduces to something close to
-/// f(x) = 35 + x*(A + B*C/D) + sum(i=2..x){ i*C/D }
-unsigned int status_base_pc_maxhp(struct map_session_data *sd, struct status_data *st) {
+unsigned int status_get_base_maxhp(struct map_session_data *sd, struct status_data *st) {
uint64 val = pc->class2idx(sd->status.class_);
- val = 35 + sd->status.base_level*(int64)status->hp_coefficient2[val]/100 + status->hp_sigma_val[val][sd->status.base_level];
- if((sd->class_&MAPID_UPPERMASK) == MAPID_NINJA || (sd->class_&MAPID_UPPERMASK) == MAPID_GUNSLINGER || (sd->class_&MAPID_UPPERMASK) == MAPID_REBELLION)
- val += 100; //Since their HP can't be approximated well enough without this.
- if((sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON))
- val *= 3; //Triple max HP for top ranking Taekwons over level 90.
- if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->status.base_level >= 99)
- val += 2000; //Supernovice lvl99 hp bonus.
-
- val += val * st->vit/100; // +1% per each point of VIT
+ val = status->dbs->HP_table[val][sd->status.base_level];
- if (sd->class_&JOBL_UPPER)
- val += val * 25/100; //Trans classes get a 25% hp bonus
- else if (sd->class_&JOBL_BABY)
- val -= val * 30/100; //Baby classes get a 30% hp penalty
- return (unsigned int)cap_value(val,0,UINT_MAX);
-}
+ if ( (sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->status.base_level >= 99 )
+ val += 2000; //Supernovice lvl99 hp bonus.
+ if ( (sd->class_&MAPID_THIRDMASK) == MAPID_SUPER_NOVICE_E && sd->status.base_level >= 150 )
+ val += 2000; //Extented Supernovice lvl150 hp bonus.
-unsigned int status_base_pc_maxsp(struct map_session_data* sd, struct status_data *st) {
- uint64 val;
+ if ( sd->class_&JOBL_UPPER )
+ val += val * 25 / 100; //Trans classes get a 25% hp bonus
+ else if ( sd->class_&JOBL_BABY )
+ val = val * 70 / 100; //Baby classes get a 30% hp penalty
- val = 10 + sd->status.base_level*(int64)status->sp_coefficient[pc->class2idx(sd->status.class_)]/100;
- val += val * st->int_/100;
+ if ( (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )
+ val *= 3; //Triple max HP for top ranking Taekwons over level 90.
- if (sd->class_&JOBL_UPPER)
- val += val * 25/100;
- else if (sd->class_&JOBL_BABY)
- val -= val * 30/100;
- if ((sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON))
- val *= 3; //Triple max SP for top ranking Taekwons over level 90.
+ val += val * st->vit / 100; // +1% per each point of VIT
return (unsigned int)cap_value(val,0,UINT_MAX);
}
@@ -2176,7 +2154,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
pc->calc_skilltree(sd); // SkillTree calculation
- sd->max_weight = status->max_weight_base[pc->class2idx(sd->status.class_)]+sd->status.str*300;
+ sd->max_weight = status->dbs->max_weight_base[pc->class2idx(sd->status.class_)]+sd->status.str*300;
if(opt&SCO_FIRST) {
//Load Hp/SP from char-received data.
@@ -2214,37 +2192,11 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
sd->def_rate = sd->def2_rate = sd->mdef_rate = sd->mdef2_rate = 100;
sd->regen.state.block = 0;
- // zeroed arrays, order follows the order in pc.h.
- // add new arrays to the end of zeroed area in pc.h (see comments) and size here. [zzo]
- memset (sd->param_bonus, 0, sizeof(sd->param_bonus)
- + sizeof(sd->param_equip)
- + sizeof(sd->subele)
- + sizeof(sd->subrace)
- + sizeof(sd->subrace2)
- + sizeof(sd->subsize)
- + sizeof(sd->reseff)
- + sizeof(sd->weapon_coma_ele)
- + sizeof(sd->weapon_coma_race)
- + sizeof(sd->weapon_atk)
- + sizeof(sd->weapon_atk_rate)
- + sizeof(sd->arrow_addele)
- + sizeof(sd->arrow_addrace)
- + sizeof(sd->arrow_addsize)
- + sizeof(sd->magic_addele)
- + sizeof(sd->magic_addrace)
- + sizeof(sd->magic_addsize)
- + sizeof(sd->magic_atk_ele)
- + sizeof(sd->critaddrace)
- + sizeof(sd->expaddrace)
- + sizeof(sd->ignore_mdef)
- + sizeof(sd->ignore_def)
- + sizeof(sd->sp_gain_race)
- + sizeof(sd->sp_gain_race_attack)
- + sizeof(sd->hp_gain_race_attack)
- );
+ // zeroed arrays
+ memset(ZEROED_BLOCK_POS(sd), 0, ZEROED_BLOCK_SIZE(sd));
- memset (&sd->right_weapon.overrefine, 0, sizeof(sd->right_weapon) - sizeof(sd->right_weapon.atkmods));
- memset (&sd->left_weapon.overrefine, 0, sizeof(sd->left_weapon) - sizeof(sd->left_weapon.atkmods));
+ memset(ZEROED_BLOCK_POS(&(sd->right_weapon)), 0, ZEROED_BLOCK_SIZE(&(sd->right_weapon)));
+ memset(ZEROED_BLOCK_POS(&(sd->left_weapon)), 0, ZEROED_BLOCK_SIZE(&(sd->left_weapon)));
if (sd->special_state.intravision && !sd->sc.data[SC_CLAIRVOYANCE]) //Clear intravision as long as nothing else is using it
clif->sc_end(&sd->bl,sd->bl.id,SELF,SI_CLAIRVOYANCE);
@@ -2276,41 +2228,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
}
bstatus->aspd_rate = 1000;
bstatus->ele_lv = 1;
- bstatus->race = RC_DEMIHUMAN;
-
- //zero up structures...
- memset(&sd->autospell,0,sizeof(sd->autospell)
- + sizeof(sd->autospell2)
- + sizeof(sd->autospell3)
- + sizeof(sd->addeff)
- + sizeof(sd->addeff2)
- + sizeof(sd->addeff3)
- + sizeof(sd->skillatk)
- + sizeof(sd->skillusesprate)
- + sizeof(sd->skillusesp)
- + sizeof(sd->skillheal)
- + sizeof(sd->skillheal2)
- + sizeof(sd->hp_loss)
- + sizeof(sd->sp_loss)
- + sizeof(sd->hp_regen)
- + sizeof(sd->sp_regen)
- + sizeof(sd->skillblown)
- + sizeof(sd->skillcast)
- + sizeof(sd->add_def)
- + sizeof(sd->add_mdef)
- + sizeof(sd->add_mdmg)
- + sizeof(sd->add_drop)
- + sizeof(sd->itemhealrate)
- + sizeof(sd->subele2)
- + sizeof(sd->skillcooldown)
- + sizeof(sd->skillfixcast)
- + sizeof(sd->skillvarcast)
- + sizeof(sd->skillfixcastrate)
- + sizeof(sd->def_set_race)
- + sizeof(sd->mdef_set_race)
- );
-
- memset (&sd->bonus, 0,sizeof(sd->bonus));
+ bstatus->race = RC_PLAYER;
// Autobonus
pc->delautobonus(sd,sd->autobonus,ARRAYLENGTH(sd->autobonus),true);
@@ -2373,18 +2291,18 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
}
wa->atk += sd->inventory_data[index]->atk;
if ( (r = sd->status.inventory[index].refine) )
- wa->atk2 = status->refine_info[wlv].bonus[r-1] / 100;
+ wa->atk2 = status->dbs->refine_info[wlv].bonus[r-1] / 100;
#ifdef RENEWAL
wa->matk += sd->inventory_data[index]->matk;
wa->wlv = wlv;
if( r && sd->weapontype1 != W_BOW ) // renewal magic attack refine bonus
- wa->matk += status->refine_info[wlv].bonus[r-1] / 100;
+ wa->matk += status->dbs->refine_info[wlv].bonus[r-1] / 100;
#endif
//Overrefined bonus.
if (r)
- wd->overrefine = status->refine_info[wlv].randombonus_max[r-1] / 100;
+ wd->overrefine = status->dbs->refine_info[wlv].randombonus_max[r-1] / 100;
wa->range += sd->inventory_data[index]->range;
if(sd->inventory_data[index]->script) {
@@ -2412,7 +2330,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
else if(sd->inventory_data[index]->type == IT_ARMOR) {
int r;
if ( (r = sd->status.inventory[index].refine) )
- refinedef += status->refine_info[REFINE_TYPE_ARMOR].bonus[r-1];
+ refinedef += status->dbs->refine_info[REFINE_TYPE_ARMOR].bonus[r-1];
if(sd->inventory_data[index]->script) {
if( i == EQI_HAND_L ) //Shield
sd->state.lr_flag = 3;
@@ -2557,12 +2475,12 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
sd->bonus.splash_range += sd->bonus.splash_add_range;
// Damage modifiers from weapon type
- sd->right_weapon.atkmods[0] = status->atkmods[0][sd->weapontype1];
- sd->right_weapon.atkmods[1] = status->atkmods[1][sd->weapontype1];
- sd->right_weapon.atkmods[2] = status->atkmods[2][sd->weapontype1];
- sd->left_weapon.atkmods[0] = status->atkmods[0][sd->weapontype2];
- sd->left_weapon.atkmods[1] = status->atkmods[1][sd->weapontype2];
- sd->left_weapon.atkmods[2] = status->atkmods[2][sd->weapontype2];
+ sd->right_weapon.atkmods[0] = status->dbs->atkmods[0][sd->weapontype1];
+ sd->right_weapon.atkmods[1] = status->dbs->atkmods[1][sd->weapontype1];
+ sd->right_weapon.atkmods[2] = status->dbs->atkmods[2][sd->weapontype1];
+ sd->left_weapon.atkmods[0] = status->dbs->atkmods[0][sd->weapontype2];
+ sd->left_weapon.atkmods[1] = status->dbs->atkmods[1][sd->weapontype2];
+ sd->left_weapon.atkmods[2] = status->dbs->atkmods[2][sd->weapontype2];
if ((pc_isridingpeco(sd) || pc_isridingdragon(sd))
&& (sd->status.weapon==W_1HSPEAR || sd->status.weapon==W_2HSPEAR)
@@ -2578,9 +2496,9 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
// Job bonuses
index = pc->class2idx(sd->status.class_);
for(i=0;i<(int)sd->status.job_level && i<MAX_LEVEL;i++){
- if(!status->job_bonus[index][i])
+ if(!status->dbs->job_bonus[index][i])
continue;
- switch(status->job_bonus[index][i]) {
+ switch(status->dbs->job_bonus[index][i]) {
case 1: bstatus->str++; break;
case 2: bstatus->agi++; break;
case 3: bstatus->vit++; break;
@@ -2640,7 +2558,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
// Basic MaxHP value
//We hold the standard Max HP here to make it faster to recalculate on vit changes.
- sd->status.max_hp = status->base_pc_maxhp(sd,bstatus);
+ sd->status.max_hp = status->get_base_maxhp(sd,bstatus);
//This is done to handle underflows from negative Max HP bonuses
i64 = sd->status.max_hp + (int)bstatus->max_hp;
bstatus->max_hp = (unsigned int)cap_value(i64, 0, INT_MAX);
@@ -2665,7 +2583,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
// ----- SP MAX CALCULATION -----
// Basic MaxSP value
- sd->status.max_sp = status->base_pc_maxsp(sd,bstatus);
+ sd->status.max_sp = status->get_base_maxsp(sd,bstatus);
//This is done to handle underflows from negative Max SP bonuses
i64 = sd->status.max_sp + (int)bstatus->max_sp;
bstatus->max_sp = (unsigned int)cap_value(i64, 0, INT_MAX);
@@ -2852,17 +2770,12 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
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)
- bstatus->aspd_rate += 5*skill_lv;
- if((skill_lv = pc->checkskill(sd,SG_DEVIL)) > 0 && !pc->nextjobexp(sd))
- bstatus->aspd_rate += 30*skill_lv;
- 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_isridingpeco(sd))
- bstatus->aspd_rate -= 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY);
- else if (pc_isridingdragon(sd))
- bstatus->aspd_rate -= 250-50*pc->checkskill(sd,RK_DRAGONTRAINING);
+ if ( (skill_lv = pc->checkskill(sd, SG_DEVIL)) > 0 && !pc->nextjobexp(sd) )
+ bstatus->aspd_rate += 30 * skill_lv;
+ if ( pc_isridingpeco(sd) )
+ bstatus->aspd_rate -= 500 - 100 * pc->checkskill(sd, KN_CAVALIERMASTERY);
+ else if ( pc_isridingdragon(sd) )
+ bstatus->aspd_rate -= 250 - 50 * pc->checkskill(sd, RK_DRAGONTRAINING);
#endif
bstatus->adelay = 2*bstatus->amotion;
@@ -2937,7 +2850,11 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
sd->right_weapon.addrace[RC_DRAGON]+=skill_lv;
sd->left_weapon.addrace[RC_DRAGON]+=skill_lv;
sd->magic_addrace[RC_DRAGON]+=skill_lv;
+#ifdef RENEWAL
+ sd->race_tolerance[RC_DRAGON] += skill_lv;
+#else
sd->subrace[RC_DRAGON]+=skill_lv;
+#endif
}
if( (skill_lv = pc->checkskill(sd, AB_EUCHARISTICA)) > 0 ) {
@@ -2947,7 +2864,11 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
sd->left_weapon.addele[ELE_DARK] += skill_lv;
sd->magic_addrace[RC_DEMON] += skill_lv;
sd->magic_addele[ELE_DARK] += skill_lv;
+#ifdef RENEWAL
+ sd->race_tolerance[RC_DEMON] += skill_lv;
+#else
sd->subrace[RC_DEMON] += skill_lv;
+#endif
sd->subele[ELE_DARK] += skill_lv;
}
@@ -2970,7 +2891,11 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
}
if(sc->data[SC_PROVIDENCE]){
sd->subele[ELE_HOLY] += sc->data[SC_PROVIDENCE]->val2;
+#ifdef RENEWAL
+ sd->race_tolerance[RC_DEMON] += sc->data[SC_PROVIDENCE]->val2;
+#else
sd->subrace[RC_DEMON] += sc->data[SC_PROVIDENCE]->val2;
+#endif
}
if(sc->data[SC_ARMORPROPERTY]) {
//This status change should grant card-type elemental resist.
@@ -3115,7 +3040,7 @@ int status_calc_npc_(struct npc_data *nd, enum e_status_calc_opt opt) {
nstatus->def_ele = ELE_NEUTRAL;
nstatus->ele_lv = 1;
- nstatus->race = RC_DEMIHUMAN;
+ nstatus->race = RC_PLAYER;
nstatus->size = nd->size;
nstatus->rhw.range = 1 + nstatus->size;
nstatus->mode = (MD_CANMOVE|MD_CANATTACK);
@@ -3169,6 +3094,8 @@ int status_calc_homunculus_(struct homun_data *hd, enum e_status_calc_opt opt) {
hstatus->aspd_rate = 1000;
#ifdef RENEWAL
+ hstatus->def = 0;
+
amotion = hd->homunculusDB->baseASPD;
amotion = amotion - amotion * (hstatus->dex + hom->dex_value) / 1000 - (hstatus->agi + hom->agi_value) * amotion / 250;
#else
@@ -3183,7 +3110,6 @@ int status_calc_homunculus_(struct homun_data *hd, enum e_status_calc_opt opt) {
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;
@@ -3644,7 +3570,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) {
if (!(st->mode&MD_CANATTACK))
unit->stop_attack(bl);
if (!(st->mode&MD_CANMOVE))
- unit->stop_walking(bl,1);
+ unit->stop_walking(bl, STOPWALKING_FLAG_FIXPOS);
}
// No status changes alter these yet.
@@ -3654,7 +3580,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) {
if(flag&SCB_MAXHP) {
if( bl->type&BL_PC ) {
- st->max_hp = status->base_pc_maxhp(sd,st);
+ st->max_hp = status->get_base_maxhp(sd,st);
if (sd)
st->max_hp += bst->max_hp - sd->status.max_hp;
@@ -3675,7 +3601,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) {
if(flag&SCB_MAXSP) {
if( bl->type&BL_PC ) {
- st->max_sp = status->base_pc_maxsp(sd,st);
+ st->max_sp = status->get_base_maxsp(sd,st);
if (sd)
st->max_sp += bst->max_sp - sd->status.max_sp;
@@ -3742,19 +3668,14 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) {
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;
-
+#endif
if ( st->aspd_rate != 1000 ) // absolute percentage modifier
- amotion = (200 - (200 - amotion / 10) * st->aspd_rate / 1000) * 10;
+ amotion = amotion * st->aspd_rate / 1000;
+ if ( sd && sd->ud.skilltimer != INVALID_TIMER && pc->checkskill(sd, SA_FREECAST) > 0 )
+ amotion = amotion * 5 * (pc->checkskill(sd, SA_FREECAST) + 10) / 100;
+#ifdef RENEWAL_ASPD
+ amotion += (max(0xc3 - amotion, 2) * (st->aspd_rate2 + status->calc_aspd(bl, sc, 2))) / 100;
+ amotion = 10 * (200 - amotion) + sd->bonus.aspd_add;
#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);
@@ -4009,46 +3930,46 @@ int status_check_visibility(struct block_list *src, struct block_list *target) {
// 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]);
-
+#ifdef RENEWAL_ASPD /* [malufett/Hercules] */
+ float temp;
+ int skill_lv, val = 0;
+ amotion = status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1];
+ if ( sd->status.weapon > MAX_WEAPON_TYPE )
+ amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2] / 4;
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);
-
+ amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class_)][MAX_WEAPON_TYPE];
+ switch ( sd->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:
+ temp = st->dex * st->dex / 7.0f + st->agi * st->agi * 0.5f;
+ break;
+ default:
+ temp = st->dex * st->dex / 5.0f + st->agi * st->agi * 0.5f;
+ }
+ temp = (float)(sqrt(temp) * 0.25f) + 0xc4;
+ if ( (skill_lv = pc->checkskill(sd, SA_ADVANCEDBOOK)) > 0 && sd->status.weapon == W_BOOK )
+ val += (skill_lv - 1) / 2 + 1;
+ if ( (skill_lv = pc->checkskill(sd, GS_SINGLEACTION)) > 0 )
+ val += ((skill_lv + 1) / 2);
+ amotion = ((int)(temp + ((float)(status->calc_aspd(&sd->bl, &sd->sc, 1) + val) * st->agi / 200)) - min(amotion, 200));
#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
+ ? (status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->status.weapon]) // single weapon
+ : (status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1] + status->dbs->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;
+#endif
return amotion;
}
@@ -4141,7 +4062,7 @@ void status_calc_misc(struct block_list *bl, struct status_data *st, int level)
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->def += status_get_homvit(bl) + level / 2; // Increase. Already initialized in status_calc_homunculus_
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);
@@ -4593,6 +4514,9 @@ unsigned short status_calc_batk(struct block_list *bl, struct status_change *sc,
#ifndef RENEWAL
if(sc->data[SC_LKCONCENTRATION])
batk += batk * sc->data[SC_LKCONCENTRATION]->val2/100;
+#else
+ if ( sc->data[SC_NOEQUIPWEAPON] && bl->type != BL_PC )
+ batk -= batk * sc->data[SC_NOEQUIPWEAPON]->val2 / 100;
#endif
if(sc->data[SC_SKE])
batk += batk * 3;
@@ -4672,7 +4596,7 @@ unsigned short status_calc_watk(struct block_list *bl, struct status_change *sc,
if(sc->data[SC_LKCONCENTRATION])
watk += watk * sc->data[SC_LKCONCENTRATION]->val2/100;
#endif
- if(sc->data[SC_INCATKRATE])
+ if(sc->data[SC_INCATKRATE] && bl->type != BL_MOB)
watk += watk * sc->data[SC_INCATKRATE]->val1/100;
if(sc->data[SC_PROVOKE])
watk += watk * sc->data[SC_PROVOKE]->val3/100;
@@ -4682,8 +4606,10 @@ unsigned short status_calc_watk(struct block_list *bl, struct status_change *sc,
watk += watk * sc->data[SC_HLIF_FLEET]->val3/100;
if(sc->data[SC_CURSE])
watk -= watk * 25/100;
+#ifndef RENEWAL
if(sc->data[SC_NOEQUIPWEAPON] && bl->type != BL_PC)
watk -= watk * sc->data[SC_NOEQUIPWEAPON]->val2/100;
+#endif
if(sc->data[SC__ENERVATION])
watk -= watk * sc->data[SC__ENERVATION]->val2 / 100;
if(sc->data[SC_RUSH_WINDMILL])
@@ -5227,7 +5153,7 @@ signed short status_calc_mdef2(struct block_list *bl, struct status_change *sc,
if(sc->data[SC_MINDBREAKER])
mdef2 -= mdef2 * sc->data[SC_MINDBREAKER]->val3/100;
#ifdef RENEWAL
- if(sc && sc->data[SC_ASSUMPTIO])
+ if (sc->data[SC_ASSUMPTIO])
mdef2 <<= 1;
return (short)cap_value(mdef2,SHRT_MIN,SHRT_MAX);
#else
@@ -5508,8 +5434,8 @@ short status_calc_aspd(struct block_list *bl, struct status_change *sc, short fl
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_GRAVITATION] && sc->data[SC_GRAVITATION]->val3 != BCT_SELF)
+ bonus -= sc->data[SC_GRAVITATION]->val2 / 10;
if (sc->data[SC_JOINTBEAT]) { // needs more info
if (sc->data[SC_JOINTBEAT]->val2&BREAK_WRIST)
bonus -= 25;
@@ -5670,7 +5596,7 @@ short status_calc_aspd_rate(struct block_list *bl, struct status_change *sc, int
aspd_rate += sc->data[SC_DEFENDER]->val4;
if(sc->data[SC_GOSPEL] && sc->data[SC_GOSPEL]->val4 == BCT_ENEMY)
aspd_rate += 250;
- if(sc->data[SC_GRAVITATION])
+ if(sc->data[SC_GRAVITATION] && sc->data[SC_GRAVITATION]->val3 != BCT_SELF)
aspd_rate += sc->data[SC_GRAVITATION]->val2;
if(sc->data[SC_JOINTBEAT]) {
if( sc->data[SC_JOINTBEAT]->val2&BREAK_WRIST )
@@ -6047,7 +5973,7 @@ int status_get_party_id(struct block_list *bl) {
struct mob_data *md=(TBL_MOB*)bl;
if( md->master_id > 0 ) {
struct map_session_data *msd;
- if (md->special_state.ai && (msd = map->id2sd(md->master_id)) != NULL)
+ if (md->special_state.ai != AI_NONE && (msd = map->id2sd(md->master_id)) != NULL)
return msd->status.party_id;
return -md->master_id;
}
@@ -6090,7 +6016,7 @@ int status_get_guild_id(struct block_list *bl) {
// Guardian guild data may not been available yet, castle data is always set
return (md->guardian_data->g)?md->guardian_data->g->guild_id:md->guardian_data->castle->guild_id;
}
- if( md->special_state.ai && (msd = map->id2sd(md->master_id)) != NULL )
+ if (md->special_state.ai != AI_NONE && (msd = map->id2sd(md->master_id)) != NULL)
return msd->status.guild_id; //Alchemist's mobs [Skotlex]
break;
}
@@ -6132,7 +6058,7 @@ int status_get_emblem_id(struct block_list *bl) {
struct mob_data *md = (struct mob_data *)bl;
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)
+ if (md->special_state.ai != AI_NONE && (msd = map->id2sd(md->master_id)) != NULL)
return msd->guild_emblem_id; //Alchemist's mobs [Skotlex]
}
break;
@@ -6315,7 +6241,7 @@ void status_set_viewdata(struct block_list *bl, int class_)
if (vd)
nd->vd = vd;
else
- ShowError("status_set_viewdata (NPC): No view data for class %d\n", class_);
+ ShowError("status_set_viewdata (NPC): No view data for class %d (name=%s)\n", class_, nd->name);
}
break;
case BL_HOM: //[blackhole89]
@@ -6604,9 +6530,6 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
case SC_COLD:
tick_def2 = bst->vit*100 + status->get_lv(bl)*20;
break;
- case SC_VACUUM_EXTREME:
- tick_def2 = bst->str*50;
- break;
case SC_MANDRAGORA:
sc_def = (st->vit + st->luk)*20;
break;
@@ -6616,6 +6539,9 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
case SC_NEEDLE_OF_PARALYZE:
tick_def2 = (st->vit + st->luk) * 50;
break;
+ case SC_NETHERWORLD:
+ tick_def2 = 1000 * (((bl->type == BL_PC) ? ((TBL_PC*)bl)->status.job_level : 0) / 10 + status->get_lv(bl) / 50);
+ break;
default:
//Effect that cannot be reduced? Likely a buff.
if (!(rnd()%10000 < rate))
@@ -6717,6 +6643,9 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ
case SC_FROSTMISTY:
tick = max(tick, 6000);
break;
+ case SC_NETHERWORLD:
+ tick = max(tick, 4000);
+ break;
default:
//Skills need to trigger even if the duration is reduced below 1ms
tick = max(tick, 1);
@@ -7055,7 +6984,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
i = sd->equip_index[EQI_HAND_R];
if (i>=0 && sd->inventory_data[i] && sd->inventory_data[i]->type == IT_WEAPON) {
opt_flag|=2;
- pc->unequipitem(sd,i,3);
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
}
if (!opt_flag) return 0;
}
@@ -7071,7 +7000,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
i = sd->equip_index[EQI_HAND_L];
if ( i < 0 || !sd->inventory_data[i] || sd->inventory_data[i]->type != IT_ARMOR )
return 0;
- pc->unequipitem(sd,i,3);
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
}
if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
break;
@@ -7083,7 +7012,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
i = sd->equip_index[EQI_ARMOR];
if ( i < 0 || !sd->inventory_data[i] )
return 0;
- pc->unequipitem(sd,i,3);
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
}
if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
break;
@@ -7095,7 +7024,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
i = sd->equip_index[EQI_HEAD_TOP];
if ( i < 0 || !sd->inventory_data[i] )
return 0;
- pc->unequipitem(sd,i,3);
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
}
if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
break;
@@ -7165,12 +7094,12 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
if( !(sd->bonus.unstripable_equip&EQP_ACC_L) ) {
i = sd->equip_index[EQI_ACC_L];
if( i >= 0 && sd->inventory_data[i] && sd->inventory_data[i]->type == IT_ARMOR )
- pc->unequipitem(sd,i,3); //L-Accessory
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE); //L-Accessory
}
if( !(sd->bonus.unstripable_equip&EQP_ACC_R) ) {
i = sd->equip_index[EQI_ACC_R];
if( i >= 0 && sd->inventory_data[i] && sd->inventory_data[i]->type == IT_ARMOR )
- pc->unequipitem(sd,i,3); //R-Accessory
+ pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE); //R-Accessory
}
if( i < 0 )
return 0;
@@ -7248,6 +7177,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
// Other Effects
case SC_VACUUM_EXTREME:
+ case SC_NETHERWORLD:
return 0;
}
@@ -7400,7 +7330,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
status_change_end(bl, SC_FOOD_LUK, INVALID_TIMER);
break;
case SC_ENDURE:
- if( val4 )
+ if( val4 == 1 )
status_change_end(bl, SC_LKCONCENTRATION, INVALID_TIMER);
break;
case SC_FIGHTINGSPIRIT:
@@ -7603,7 +7533,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];
+ calc_flag = status->dbs->ChangeFlagTable[type];
if(!(flag&SCFLAG_LOADED)) { // Do not parse val settings when loading SCs
switch(type) {
case SC_ADORAMUS:
@@ -7619,7 +7549,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
struct map_session_data *tsd;
if( sd ) {
int i;
- for( i = 0; i < 5; i++ ) {
+ for( i = 0; i < MAX_PC_DEVOTION; i++ ) {
if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) )
status->change_start(bl, &tsd->bl, type, 10000, val1, val2, val3, val4, tick, SCFLAG_ALL);
}
@@ -7646,11 +7576,13 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
tick = -1; // duration sent to the client should be infinite
break;
case SC_EDP: // [Celest]
- val2 = val1 + 2; //Chance to Poison enemies.
- val3 = 50*(val1+1); //Damage increase (+50 +50*lv%)
- #ifdef RENEWAL_EDP
- val4 = 100 * ((val1 + 1)/2 + 2);
- #endif
+ //Chance to Poison enemies.
+#ifdef RENEWAL_EDP
+ val2 = ((val1 + 1) / 2 + 2);
+#else
+ val2 = val1 + 2;
+#endif
+ val3 = 50 * (val1 + 1); //Damage increase (+50 +50*lv%)
if( sd )//[Ind] - iROwiki says each level increases its duration by 3 seconds
tick += pc->checkskill(sd,GC_RESEARCHNEWPOISON)*3000;
break;
@@ -7716,7 +7648,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
struct map_session_data *tsd;
if( sd ) {
int i;
- for( i = 0; i < 5; i++ ) {
+ for( i = 0; i < MAX_PC_DEVOTION; i++ ) {
if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) )
status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL);
}
@@ -7974,7 +7906,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
if( bl->type&(BL_PC|BL_MER) ) {
if( sd ) {
- for( i = 0; i < 5; i++ ) {
+ for( i = 0; i < MAX_PC_DEVOTION; i++ ) {
if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) )
status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL);
}
@@ -7994,7 +7926,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
if (sd) {
struct map_session_data *tsd;
int i;
- for (i = 0; i < 5; i++) {
+ for (i = 0; i < MAX_PC_DEVOTION; 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,SCFLAG_NOAVOID);
@@ -8030,7 +7962,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
case SC_BERSERK:
if( val3 == SC__BLOODYLUST )
sc_start(src,bl,(sc_type)val3,100,val1,tick);
- if( !val3 && !(!sc->data[SC_ENDURE] || !sc->data[SC_ENDURE]->val4) )
+ if (!val3 && (!sc->data[SC_ENDURE] || !sc->data[SC_ENDURE]->val4))
sc_start4(src, bl, SC_ENDURE, 100,10,0,0,2, tick);
//HP healing is performing after the calc_status call.
//Val2 holds HP penalty
@@ -8887,6 +8819,9 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
else
val2 = val2 / 4 * val1; // STAT DEF increase: [(Caster VIT / 4) x Skill Level]
break;
+ case SC_GENTLETOUCH_ENERGYGAIN:
+ val2 = 10 + 5 * val1;
+ break;
case SC_PYROTECHNIC_OPTION:
val2 = 60;
break;
@@ -9129,7 +9064,7 @@ 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) {
+ if (calc_flag == SCB_NONE && status->dbs->SkillChangeTable[type] == 0 && status->dbs->IconChangeTable[type] == 0) {
//Status change with no calc, no icon, and no skill associated...?
ShowError("UnknownStatusChange [%d]\n", type);
return 0;
@@ -9283,7 +9218,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
}
/* [Ind/Hercules] */
- if( sd && status->DisplayType[type] ) {
+ if( sd && status->dbs->DisplayType[type] ) {
int dval1 = 0, dval2 = 0, dval3 = 0;
switch( type ) {
case SC_ALL_RIDING:
@@ -9334,11 +9269,12 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
case SC_MEIKYOUSISUI:
case SC_NEEDLE_OF_PARALYZE:
case SC_DEATHBOUND:
- unit->stop_walking(bl,1);
+ case SC_NETHERWORLD:
+ unit->stop_walking(bl, STOPWALKING_FLAG_FIXPOS);
break;
case SC_ANKLESNARE:
if( battle_config.skill_trap_type || !map_flag_gvg(bl->m) )
- unit->stop_walking(bl,1);
+ unit->stop_walking(bl, STOPWALKING_FLAG_FIXPOS);
break;
case SC_HIDING:
case SC_CLOAKING:
@@ -9575,8 +9511,8 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
calc_flag&=~SCB_DYE;
}
- 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);
+ if(!(flag&SCFLAG_NOICON) && !(flag&SCFLAG_LOADED && status->dbs->DisplayType[type]))
+ clif->status_change(bl,status->dbs->IconChangeTable[type],1,tick,(val_flag&1)?val1:1,(val_flag&2)?val2:0,(val_flag&4)?val3:0);
/**
* used as temporary storage for scs with interval ticks, so that the actual duration is sent to the client first.
@@ -9592,14 +9528,18 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
++(sc->count);
sce = sc->data[type] = ers_alloc(status->data_ers, struct status_change_entry);
}
+
sce->val1 = val1;
sce->val2 = val2;
sce->val3 = val3;
sce->val4 = val4;
- if (tick >= 0)
+
+ if (tick >= 0) {
sce->timer = timer->add(timer->gettick() + tick, status->change_timer, bl->id, type);
- else {
+ sce->infinite_duration = false;
+ } else {
sce->timer = INVALID_TIMER; //Infinite duration
+ sce->infinite_duration = true;
if( sd )
chrif->save_scdata_single(sd->status.account_id,sd->status.char_id,type,sce);
}
@@ -9629,7 +9569,8 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
}
break;
case SC_CASH_BOSS_ALARM:
- clif->bossmapinfo(sd->fd, map->id2boss(sce->val1), 0); // First Message
+ if( sd )
+ clif->bossmapinfo(sd->fd, map->id2boss(sce->val1), 0); // First Message
break;
case SC_MER_HP:
status_percent_heal(bl, 100, 0); // Recover Full HP
@@ -9773,17 +9714,18 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
nullpo_ret(bl);
sc = status->get_sc(bl);
- st = status->get_status_data(bl);
if(type < 0 || type >= SC_MAX || !sc || !(sce = sc->data[type]))
return 0;
sd = BL_CAST(BL_PC,bl);
- if (sce->timer != tid && tid != INVALID_TIMER)
+ if (sce->timer != tid && tid != INVALID_TIMER && sce->timer != INVALID_TIMER)
return 0;
- if( sd && sce->timer == INVALID_TIMER && !sd->state.loggingout )
+ st = status->get_status_data(bl);
+
+ if( sd && sce->infinite_duration && !sd->state.loggingout )
chrif->del_scdata_single(sd->status.account_id,sd->status.char_id,type);
if (tid == INVALID_TIMER) {
@@ -9817,7 +9759,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
sc->data[type] = NULL;
- if( sd && status->DisplayType[type] ) {
+ if( sd && status->dbs->DisplayType[type] ) {
status->display_remove(sd,type);
}
@@ -9827,7 +9769,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
#endif
vd = status->get_viewdata(bl);
- calc_flag = status->ChangeFlagTable[type];
+ calc_flag = status->dbs->ChangeFlagTable[type];
switch(type) {
case SC_GRANITIC_ARMOR:
{
@@ -9854,7 +9796,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
begin_spurt = false;
ud->state.running = 0;
if (ud->walktimer != INVALID_TIMER)
- unit->stop_walking(bl,1);
+ unit->stop_walking(bl, STOPWALKING_FLAG_FIXPOS);
}
if (begin_spurt && sce->val1 >= 7
&& DIFF_TICK(timer->gettick(), starttick) <= 1000
@@ -9877,7 +9819,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
if( bl->type == BL_PC ) {
// Clear Status from others
int i;
- for( i = 0; i < 5; i++ ) {
+ for( i = 0; i < MAX_PC_DEVOTION; i++ ) {
if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) && tsd->sc.data[type] )
status_change_end(&tsd->bl, type, INVALID_TIMER);
}
@@ -9964,7 +9906,9 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
}
sce->val2 = 0;
- skill->del_unitgroup(group,ALC_MARK);
+
+ if( group )
+ skill->del_unitgroup(group,ALC_MARK);
}
if ((sce->val1&0xFFFF) == CG_MOONLIT)
@@ -9996,11 +9940,11 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
if (src && sc2 && sc2->data[SC_RG_CCONFINE_M]) {
//If status was already ended, do nothing.
//Decrease count
- if (--(sc2->data[SC_RG_CCONFINE_M]->val1) <= 0) //No more holds, free him up.
+ if (--(sc2->data[SC_RG_CCONFINE_M]->val2) <= 0) //No more holds, free him up.
status_change_end(src, SC_RG_CCONFINE_M, INVALID_TIMER);
}
}
- /* Fall through */
+ break;
case SC_RG_CCONFINE_M:
if (sce->val2 > 0) {
//Caster has been unlocked... nearby chars need to be unlocked.
@@ -10067,7 +10011,8 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
if (sce->val3) { //Clear the group.
struct skill_unit_group* group = skill->id2group(sce->val3);
sce->val3 = 0;
- skill->del_unitgroup(group,ALC_MARK);
+ if( group )
+ skill->del_unitgroup(group,ALC_MARK);
}
break;
case SC_HERMODE:
@@ -10113,10 +10058,12 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
break;
// Note: vending/buying is closed by unit_remove_map, no
// need to do it here.
- map->quit(sd);
- // Because map->quit calls status_change_end with tid -1
- // from here it's not neccesary to continue
- return 1;
+ if( sd ) {
+ map->quit(sd);
+ // Because map->quit calls status_change_end with tid -1
+ // from here it's not neccesary to continue
+ return 1;
+ }
break;
case SC_STOP:
if( sce->val2 ) {
@@ -10128,7 +10075,8 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
}
break;
case SC_LKCONCENTRATION:
- status_change_end(bl, SC_ENDURE, INVALID_TIMER);
+ if (sc->data[SC_ENDURE] && sc->data[SC_ENDURE]->val4 != 2)
+ status_change_end(bl, SC_ENDURE, INVALID_TIMER);
break;
/**
* 3rd Stuff
@@ -10144,7 +10092,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
struct block_list* src = map->id2bl(sce->val2);
if( tid == -1 || !src)
break; // Terminated by Damage
- status_fix_damage(src,bl,400*sce->val1,clif->damage(bl,bl,0,0,400*sce->val1,0,0,0));
+ status_fix_damage(src,bl,400*sce->val1,clif->damage(bl,bl,0,0,400*sce->val1,0,BDT_NORMAL,0));
}
break;
case SC_WUGDASH:
@@ -10153,7 +10101,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
if (ud) {
ud->state.running = 0;
if (ud->walktimer != -1)
- unit->stop_walking(bl,1);
+ unit->stop_walking(bl, STOPWALKING_FLAG_FIXPOS);
}
}
break;
@@ -10196,15 +10144,11 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
map->foreachinrange(status->change_timer_sub, bl, battle_config.area_size,BL_CHAR, bl, sce, SC_CURSEDCIRCLE_TARGET, timer->gettick());
break;
case SC_RAISINGDRAGON:
- if( sd && sce->val2 && !pc_isdead(sd) ) {
+ if ( sd && sce->val2 && !pc_isdead(sd) ) {
int i;
- i = min(sd->spiritball,5);
- pc->delspiritball(sd, sd->spiritball, 0);
+ if ( (i = (sd->spiritball - 5)) > 0 )
+ pc->delspiritball(sd, i, 0);
status_change_end(bl, SC_EXPLOSIONSPIRITS, INVALID_TIMER);
- while( i > 0 ) {
- pc->addspiritball(sd, skill->get_time(MO_CALLSPIRITS, pc->checkskill(sd,MO_CALLSPIRITS)), 5);
- --i;
- }
}
break;
case SC_CURSEDCIRCLE_TARGET:
@@ -10222,7 +10166,8 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
struct block_list *src = map->id2bl(sce->val2);
if(src) {
struct status_change *ssc = status->get_sc(src);
- ssc->bs_counter--;
+ if( ssc )
+ ssc->bs_counter--;
}
}
break;
@@ -10468,7 +10413,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
}
//On Aegis, when turning off a status change, first goes the sc packet, then the option packet.
- clif->sc_end(bl,bl->id,AREA,status->IconChangeTable[type]);
+ clif->sc_end(bl,bl->id,AREA,status->dbs->IconChangeTable[type]);
if( opt_flag&8 ) //bugreport:681
clif->changeoption2(bl);
@@ -10563,6 +10508,8 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
ShowError("status_change_timer: Mismatch for type %d: %d != %d (bl id %d)\n",type,tid,sce->timer, bl->id);
return 0;
}
+
+ sce->timer = INVALID_TIMER;
sd = BL_CAST(BL_PC, bl);
@@ -10593,7 +10540,6 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
}
sc_timer_next(sce->val2+tick, status->change_timer, bl->id, data);
return 0;
- break;
case SC_SKA:
if(--(sce->val2)>0) {
@@ -10641,12 +10587,12 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
case SC_STONE:
if(sc->opt1 == OPT1_STONEWAIT && sce->val3) {
sce->val4 = 0;
- unit->stop_walking(bl,1);
+ unit->stop_walking(bl, STOPWALKING_FLAG_FIXPOS);
unit->stop_attack(bl);
sc->opt1 = OPT1_STONE;
clif->changeoption(bl);
sc_timer_next(1000+tick, status->change_timer, bl->id, data );
- status_calc_bl(bl, status->ChangeFlagTable[type]);
+ status_calc_bl(bl, status->dbs->ChangeFlagTable[type]);
return 0;
}
if(--(sce->val3) > 0) {
@@ -10688,14 +10634,16 @@ 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
- sce->timer = INVALID_TIMER;
- return 0;
+ {
+ int i;
+ for (i = 0; i < MAX_PC_FEELHATE; i++) {
+ if (bl->m == sd->feel_map[i].m) {
+ //Timeout will be handled by pc->setpos
+ sce->timer = INVALID_TIMER;
+ return 0;
+ }
}
+ }
break;
case SC_BLOODING:
@@ -10882,7 +10830,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
case SC_PYREXIA:
if( --(sce->val4) > 0 ) {
map->freeblock_lock();
- clif->damage(bl,bl,status_get_amotion(bl),status_get_dmotion(bl)+500,100,0,0,0);
+ clif->damage(bl,bl,status_get_amotion(bl),status_get_dmotion(bl)+500,100,0,BDT_NORMAL,0);
status_fix_damage(NULL,bl,100,0);
if( sc->data[type] ) {
sc_timer_next(3000+tick,status->change_timer,bl->id,data);
@@ -10898,7 +10846,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
damage += st->vit * (sce->val1 - 3);
unit->skillcastcancel(bl,2);
map->freeblock_lock();
- status->damage(bl, bl, damage, 0, clif->damage(bl,bl,status_get_amotion(bl),status_get_dmotion(bl)+500,damage,1,0,0), 1);
+ status->damage(bl, bl, damage, 0, clif->damage(bl,bl,status_get_amotion(bl),status_get_dmotion(bl)+500,damage,1,BDT_NORMAL,0), 1);
if( sc->data[type] ) {
sc_timer_next(1000 + tick, status->change_timer, bl->id, data );
}
@@ -10922,13 +10870,15 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
}
if( !flag ) { // Random Skill Cast
+ map->freeblock_lock();
+
if (sd && !pc_issit(sd)) { //can't cast if sit
int mushroom_skill_id = 0;
unit->stop_attack(bl);
unit->skillcastcancel(bl,0);
do {
int i = rnd() % MAX_SKILL_MAGICMUSHROOM_DB;
- mushroom_skill_id = skill->magicmushroom_db[i].skill_id;
+ mushroom_skill_id = skill->dbs->magicmushroom_db[i].skill_id;
} while (mushroom_skill_id == 0);
switch( skill->get_casttype(mushroom_skill_id) ) { // Magic Mushroom skills are buffs or area damage
@@ -10945,7 +10895,10 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
}
clif->emotion(bl,E_HEH);
- sc_timer_next(4000+tick,status->change_timer,bl->id,data);
+ if( sc->data[type] )
+ sc_timer_next(4000+tick,status->change_timer,bl->id,data);
+
+ map->freeblock_unlock();
}
return 0;
}
@@ -10955,7 +10908,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
if( --(sce->val4) > 0 ) {
//Damage is every 10 seconds including 3%sp drain.
map->freeblock_lock();
- clif->damage(bl,bl,status_get_amotion(bl),1,1,0,0,0);
+ clif->damage(bl,bl,status_get_amotion(bl),1,1,0,BDT_NORMAL,0);
status->damage(NULL, bl, 1, st->max_sp * 3 / 100, 0, 0); //cancel dmg only if cancelable
if( sc->data[type] ) {
sc_timer_next(10000 + tick, status->change_timer, bl->id, data );
@@ -10993,8 +10946,15 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
int heal = st->max_hp * 3 / 100;
if (sc->count && sc->data[SC_AKAITSUKI] && heal)
heal = ~heal + 1;
+
+ map->freeblock_lock();
+
status->heal(bl, heal, 0, 2);
- sc_timer_next(5000 + tick, status->change_timer, bl->id, data);
+ if( sc->data[type] ) {
+ sc_timer_next(5000 + tick, status->change_timer, bl->id, data);
+ }
+ map->freeblock_unlock();
+
return 0;
}
break;
@@ -11005,7 +10965,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
int damage = 1000 + 3 * status_get_max_hp(bl) / 100; // Deals fixed (1000 + 3%*MaxHP)
map->freeblock_lock();
- clif->damage(bl,bl,0,0,damage,1,9,0); //damage is like endure effect with no walk delay
+ clif->damage(bl,bl,0,0,damage,1,BDT_MULTIENDURE,0); //damage is like endure effect with no walk delay
status->damage(src, bl, damage, 0, 0, 1);
if( sc->data[type]){ // Target still lives. [LimitLine]
@@ -11107,13 +11067,13 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
break;
map->freeblock_lock();
damage = sce->val3;
- status->damage(src, bl, damage, 0, clif->damage(bl,bl,st->amotion,st->dmotion+200,damage,1,0,0), 1);
+ status->damage(src, bl, damage, 0, clif->damage(bl,bl,st->amotion,st->dmotion+200,damage,1,BDT_NORMAL,0), 1);
unit->skillcastcancel(bl,1);
if ( sc->data[type] ) {
sc_timer_next(1000 + tick, status->change_timer, bl->id, data);
}
- map->freeblock_unlock();
status->heal(src, damage*(5 + 5 * sce->val1)/100, 0, 0); // 5 + 5% per level
+ map->freeblock_unlock();
return 0;
}
break;
@@ -11215,11 +11175,12 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
int damage = st->max_hp / 100; // Suggestion 1% each second
if( damage >= st->hp ) damage = st->hp - 1; // Do not kill, just keep you with 1 hp minimum
map->freeblock_lock();
- status_fix_damage(NULL,bl,damage,clif->damage(bl,bl,0,0,damage,0,0,0));
+ status_fix_damage(NULL,bl,damage,clif->damage(bl,bl,0,0,damage,0,BDT_NORMAL,0));
if( sc->data[type] ) {
sc_timer_next(1000 + tick, status->change_timer, bl->id, data);
}
map->freeblock_unlock();
+ return 0;
}
break;
@@ -11300,18 +11261,19 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
case SC_WATER_DROP:
case SC_WIND_CURTAIN:
case SC_STONE_SHIELD:
- if(status->charge(bl, 0, sce->val2) && (sce->val4==-1 || (sce->val4-=sce->val3)>=0))
+ if(status->charge(bl, 0, sce->val2) && (sce->val4==-1 || (sce->val4-=sce->val3)>=0)) {
sc_timer_next(sce->val3 + tick, status->change_timer, bl->id, data);
- else
+ return 0;
+ } else
if (bl->type == BL_ELEM)
elemental->change_mode(BL_CAST(BL_ELEM,bl),MAX_ELESKILLTREE);
- return 0;
+ break;
case SC_STOMACHACHE:
if( --(sce->val4) > 0 ) {
status->charge(bl,0,sce->val2); // Reduce 8 every 10 seconds.
if( sd && !pc_issit(sd) ) { // Force to sit every 10 seconds.
- pc_stop_walking(sd,1|4);
+ pc_stop_walking(sd, STOPWALKING_FLAG_FIXPOS|STOPWALKING_FLAG_NEXTCELL);
pc_stop_attack(sd);
pc_setsit(sd);
clif->sitting(bl);
@@ -11495,7 +11457,7 @@ int status_get_weapon_atk(struct block_list *bl, struct weapon_atk *watk, int fl
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;
+ int r = status->dbs->refine_info[watk->wlv].randombonus_max[refine + (4 - watk->wlv)] / 100;
if ( r )
max += (rnd() % 100) % r + 1;
}
@@ -11594,7 +11556,7 @@ void status_get_matk_sub(struct block_list *bl, int flag, unsigned short *matk_m
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;
+ int r = status->dbs->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;
}
@@ -11691,6 +11653,8 @@ int status_change_clear_buffs (struct block_list* bl, int type) {
if (!sc || !sc->count)
return 0;
+ map->freeblock_lock();
+
if (type&6) //Debuffs
for (i = SC_COMMON_MIN; i <= SC_COMMON_MAX; i++)
status_change_end(bl, (sc_type)i, INVALID_TIMER);
@@ -11737,6 +11701,9 @@ int status_change_clear_buffs (struct block_list* bl, int type) {
}
status_change_end(bl, (sc_type)i, INVALID_TIMER);
}
+
+ map->freeblock_unlock();
+
return 0;
}
@@ -12032,7 +11999,7 @@ int status_get_refine_chance(enum refine_type wlv, int refine) {
if ( refine < 0 || refine >= MAX_REFINE)
return 0;
- return status->refine_info[wlv].chance[refine];
+ return status->dbs->refine_info[wlv].chance[refine];
}
int status_get_sc_type(sc_type type) {
@@ -12040,43 +12007,206 @@ int status_get_sc_type(sc_type type) {
if( type <= SC_NONE || type >= SC_MAX )
return 0;
- return status->sc_conf[type];
+ return status->dbs->sc_conf[type];
+}
+
+void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb)
+{
+ config_setting_t *temp = NULL;
+ int i32 = 0;
+
+ struct {
+ const char *name;
+ int id;
+ } wnames[] = {
+ { "Fist", W_FIST },
+ { "Dagger", W_DAGGER },
+ { "Sword", W_1HSWORD },
+ { "TwoHandSword", W_2HSWORD },
+ { "Spear", W_1HSPEAR },
+ { "TwoHandSpear", W_2HSPEAR },
+ { "Axe", W_1HAXE },
+ { "TwoHandAxe", W_2HAXE },
+ { "Mace", W_MACE },
+ { "TwoHandMace", W_2HMACE },
+ { "Rod", W_STAFF },
+ { "Bow", W_BOW },
+ { "Knuckle", W_KNUCKLE },
+ { "Instrument", W_MUSICAL },
+ { "Whip", W_WHIP },
+ { "Book", W_BOOK },
+ { "Katar", W_KATAR },
+ { "Revolver", W_REVOLVER },
+ { "Rifle", W_RIFLE },
+ { "GatlingGun", W_GATLING },
+ { "Shotgun", W_SHOTGUN },
+ { "GrenadeLauncher", W_GRENADE },
+ { "FuumaShuriken", W_HUUMA },
+ { "TwoHandRod", W_2HSTAFF },
+#ifdef RENEWAL_ASPD
+ { "Shield", MAX_WEAPON_TYPE }
+#endif
+ };
+
+ if ((temp = libconfig->setting_get_member(jdb, "Inherit"))) {
+ int nidx = 0;
+ const char *iname;
+ while ((iname = libconfig->setting_get_string_elem(temp, nidx++))) {
+ int i, iidx, iclass, avg_increment, base;
+ if ((iclass = pc->check_job_name(iname)) == -1) {
+ ShowWarning("status_read_job_db: '%s' trying to inherit unknown '%s'!\n", name, iname);
+ continue;
+ }
+ iidx = pc->class2idx(iclass);
+ status->dbs->max_weight_base[idx] = status->dbs->max_weight_base[iidx];
+ memcpy(&status->dbs->aspd_base[idx], &status->dbs->aspd_base[iidx], sizeof(status->dbs->aspd_base[iidx]));
+
+ for (i = 1; i <= MAX_LEVEL && status->dbs->HP_table[iidx][i]; i++) {
+ status->dbs->HP_table[idx][i] = status->dbs->HP_table[iidx][i];
+ }
+ base = (i > 1 ? status->dbs->HP_table[idx][1] : 35); // Safe value if none are specified
+ avg_increment = (i > 2 ? (status->dbs->HP_table[idx][i] - base) / (i-1) : 5); // Safe value if none are specified
+ for ( ; i <= pc->max_level[idx][0]; i++) {
+ status->dbs->HP_table[idx][i] = min(base + avg_increment * i, battle_config.max_hp);
+ }
+
+ for (i = 1; i <= MAX_LEVEL && status->dbs->SP_table[iidx][i]; i++) {
+ status->dbs->SP_table[idx][i] = status->dbs->SP_table[iidx][i];
+ }
+ base = (i > 1 ? status->dbs->SP_table[idx][1] : 10); // Safe value if none are specified
+ avg_increment = (i > 2 ? (status->dbs->SP_table[idx][i] - base) / (i-1) : 1); // Safe value if none are specified
+ for ( ; i <= pc->max_level[idx][0]; i++) {
+ status->dbs->SP_table[idx][i] = min(base + avg_increment * i, battle_config.max_sp);
+ }
+ }
+ }
+ if ((temp = libconfig->setting_get_member(jdb, "InheritHP"))) {
+ int nidx = 0;
+ const char *iname;
+ while ((iname = libconfig->setting_get_string_elem(temp, nidx++))) {
+ int i, iidx, iclass, avg_increment, base;
+ if ((iclass = pc->check_job_name(iname)) == -1) {
+ ShowWarning("status_read_job_db: '%s' trying to inherit unknown '%s' HP!\n", name, iname);
+ continue;
+ }
+ iidx = pc->class2idx(iclass);
+ for (i = 1; i <= MAX_LEVEL && status->dbs->HP_table[iidx][i]; i++) {
+ status->dbs->HP_table[idx][i] = status->dbs->HP_table[iidx][i];
+ }
+ base = (i > 1 ? status->dbs->HP_table[idx][1] : 35); // Safe value if none are specified
+ avg_increment = (i > 2 ? (status->dbs->HP_table[idx][i] - base) / (i-1) : 5); // Safe value if none are specified
+ for ( ; i <= pc->max_level[idx][0]; i++) {
+ status->dbs->HP_table[idx][i] = min(base + avg_increment * i, battle_config.max_hp);
+ }
+ }
+ }
+ if ((temp = libconfig->setting_get_member(jdb, "InheritSP"))) {
+ int nidx = 0;
+ const char *iname;
+ while ((iname = libconfig->setting_get_string_elem(temp, nidx++))) {
+ int i, iidx, iclass, avg_increment, base;
+ if ((iclass = pc->check_job_name(iname)) == -1) {
+ ShowWarning("status_read_job_db: '%s' trying to inherit unknown '%s' SP!\n", name, iname);
+ continue;
+ }
+ iidx = pc->class2idx(iclass);
+ for (i = 1; i <= MAX_LEVEL && status->dbs->SP_table[iidx][i]; i++) {
+ status->dbs->SP_table[idx][i] = status->dbs->SP_table[iidx][i];
+ }
+ base = (i > 1 ? status->dbs->SP_table[idx][1] : 10); // Safe value if none are specified
+ avg_increment = (i > 2 ? (status->dbs->SP_table[idx][i] - base) / (i-1) : 1); // Safe value if none are specified
+ for ( ; i <= pc->max_level[idx][0]; i++) {
+ status->dbs->SP_table[idx][i] = min(avg_increment * i, battle_config.max_sp);
+ }
+ }
+ }
+
+ if (libconfig->setting_lookup_int(jdb, "Weight", &i32))
+ status->dbs->max_weight_base[idx] = i32;
+ else if (!status->dbs->max_weight_base[idx])
+ status->dbs->max_weight_base[idx] = 20000;
+
+ if ((temp = libconfig->setting_get_member(jdb, "BaseASPD"))) {
+ int widx = 0;
+ config_setting_t *wpn = NULL;
+ while ((wpn = libconfig->setting_get_elem(temp, widx++))) {
+ int w, wlen = ARRAYLENGTH(wnames);
+ const char *wname = config_setting_name(wpn);
+
+ ARR_FIND(0, wlen, w, strcmp(wnames[w].name, wname) == 0);
+ if (w != wlen) {
+ status->dbs->aspd_base[idx][wnames[w].id] = libconfig->setting_get_int(wpn);
+ } else {
+ ShowWarning("status_read_job_db: unknown weapon type '%s'!\n", wname);
+ }
+ }
+ }
+
+ if ((temp = libconfig->setting_get_member(jdb, "HPTable"))) {
+ int level = 0, avg_increment, base;
+ config_setting_t *hp = NULL;
+ while (level <= MAX_LEVEL && (hp = libconfig->setting_get_elem(temp, level))) {
+ i32 = libconfig->setting_get_int(hp);
+ status->dbs->HP_table[idx][++level] = min(i32, battle_config.max_hp);
+ }
+ base = (level > 0 ? status->dbs->HP_table[idx][1] : 35); // Safe value if none are specified
+ avg_increment = (level > 1 ? (status->dbs->HP_table[idx][level] - base) / level : 5); // Safe value if none are specified
+ for (++level; level <= pc->max_level[idx][0]; ++level) { /* limit only to possible maximum level of the given class */
+ status->dbs->HP_table[idx][level] = min(base + avg_increment * level, battle_config.max_hp); /* some are still empty? then let's use the average increase */
+ }
+ }
+
+ if ((temp = libconfig->setting_get_member(jdb, "SPTable"))) {
+ int level = 0, avg_increment, base;
+ config_setting_t *sp = NULL;
+ while (level <= MAX_LEVEL && (sp = libconfig->setting_get_elem(temp, level))) {
+ i32 = libconfig->setting_get_int(sp);
+ status->dbs->SP_table[idx][++level] = min(i32, battle_config.max_sp);
+ }
+ base = (level > 0 ? status->dbs->SP_table[idx][1] : 10); // Safe value if none are specified
+ avg_increment = (level > 1 ? (status->dbs->SP_table[idx][level] - base) / level : 1);
+ for ( ; level <= pc->max_level[idx][0]; level++ ) {
+ status->dbs->SP_table[idx][level] = min(base + avg_increment * level, battle_config.max_sp);
+ }
+ }
}
/*------------------------------------------
* DB reading.
-* job_db1.txt - weight, hp, sp, aspd
+* job_db.conf - weight, hp, sp, aspd
* job_db2.txt - job level stat bonuses
* size_fix.txt - size adjustment table for weapons
* refine_db.txt - refining data table
*------------------------------------------*/
-bool status_readdb_job1(char* fields[], int columns, int current)
-{// Job-specific values (weight, HP, SP, ASPD)
- int idx, class_;
- unsigned int i;
-
- class_ = atoi(fields[0]);
-
- if(!pc->db_checkid(class_))
- {
- ShowWarning("status_readdb_job1: Invalid job class %d specified.\n", class_);
- return false;
- }
- idx = pc->class2idx(class_);
-
- status->max_weight_base[idx] = atoi(fields[1]);
- status->hp_coefficient[idx] = atoi(fields[2]);
- status->hp_coefficient2[idx] = atoi(fields[3]);
- status->sp_coefficient[idx] = atoi(fields[4]);
+void status_read_job_db(void) { /* [malufett/Hercules] */
+ int i = 0;
+ config_t job_db_conf;
+ config_setting_t *jdb = NULL;
+ const char *config_filename =
#ifdef RENEWAL_ASPD
- for(i = 0; i <= MAX_WEAPON_TYPE; i++)
+ "db/re/job_db.conf";
#else
- for(i = 0; i < MAX_WEAPON_TYPE; i++)
+ "db/pre-re/job_db.conf";
#endif
- {
- status->aspd_base[idx][i] = atoi(fields[i+5]);
+
+ if ( libconfig->read_file(&job_db_conf, config_filename) ) {
+ ShowError("can't read %s\n", config_filename);
+ return;
}
- return true;
+ while ( (jdb = libconfig->setting_get_elem(job_db_conf.root, i++)) ) {
+ int class_, idx;
+ const char *name = config_setting_name(jdb);
+
+ if ( (class_ = pc->check_job_name(name)) == -1 ) {
+ ShowWarning("pc_read_job_db: '%s' unknown job name!\n", name);
+ continue;
+ }
+
+ idx = pc->class2idx(class_);
+ status->read_job_db_sub(idx, name, jdb);
+ }
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, config_filename);
+ libconfig->destroy(&job_db_conf);
}
bool status_readdb_job2(char* fields[], int columns, int current)
@@ -12094,7 +12224,7 @@ bool status_readdb_job2(char* fields[], int columns, int current)
for(i = 1; i < columns; i++)
{
- status->job_bonus[idx][i-1] = atoi(fields[i]);
+ status->dbs->job_bonus[idx][i-1] = atoi(fields[i]);
}
return true;
}
@@ -12105,7 +12235,7 @@ bool status_readdb_sizefix(char* fields[], int columns, int current)
for(i = 0; i < MAX_WEAPON_TYPE; i++)
{
- status->atkmods[current][i] = atoi(fields[i]);
+ status->dbs->atkmods[current][i] = atoi(fields[i]);
}
return true;
}
@@ -12132,14 +12262,14 @@ bool status_readdb_refine(char* fields[], int columns, int current)
*delim = '\0';
- status->refine_info[current].chance[i] = atoi(fields[4+i]);
+ status->dbs->refine_info[current].chance[i] = atoi(fields[4+i]);
if (i >= random_bonus_start_level - 1)
- status->refine_info[current].randombonus_max[i] = random_bonus * (i - random_bonus_start_level + 2);
+ status->dbs->refine_info[current].randombonus_max[i] = random_bonus * (i - random_bonus_start_level + 2);
- status->refine_info[current].bonus[i] = bonus_per_level + atoi(delim+1);
+ status->dbs->refine_info[current].bonus[i] = bonus_per_level + atoi(delim+1);
if (i > 0)
- status->refine_info[current].bonus[i] += status->refine_info[current].bonus[i-1];
+ status->dbs->refine_info[current].bonus[i] += status->dbs->refine_info[current].bonus[i-1];
}
return true;
}
@@ -12153,7 +12283,7 @@ bool status_readdb_scconfig(char* fields[], int columns, int current) {
return false;
}
- status->sc_conf[val] = (int)strtol(fields[1], NULL, 0);
+ status->dbs->sc_conf[val] = (int)strtol(fields[1], NULL, 0);
return true;
}
@@ -12171,42 +12301,42 @@ int status_readdb(void)
// initialize databases to default
//
if( runflag == MAPSERVER_ST_RUNNING ) {//not necessary during boot
- // reset job_db1.txt data
- memset(status->max_weight_base, 0, sizeof(status->max_weight_base));
- memset(status->hp_coefficient, 0, sizeof(status->hp_coefficient));
- memset(status->hp_coefficient2, 0, sizeof(status->hp_coefficient2));
- memset(status->sp_coefficient, 0, sizeof(status->sp_coefficient));
- memset(status->aspd_base, 0, sizeof(status->aspd_base));
+ // reset job_db.conf data
+ memset(status->dbs->max_weight_base, 0, sizeof(status->dbs->max_weight_base));
+ memset(status->dbs->HP_table, 0, sizeof(status->dbs->HP_table));
+ memset(status->dbs->SP_table, 0, sizeof(status->dbs->SP_table));
// reset job_db2.txt data
- memset(status->job_bonus,0,sizeof(status->job_bonus)); // Job-specific stats bonus
+ memset(status->dbs->job_bonus,0,sizeof(status->dbs->job_bonus)); // Job-specific stats bonus
+ }
+ for ( i = 0; i < CLASS_COUNT; i++ ) {
+ for ( j = 0; j < MAX_WEAPON_TYPE; j++ )
+ status->dbs->aspd_base[i][j] = 2000;
+#ifdef RENEWAL_ASPD
+ status->dbs->aspd_base[i][MAX_WEAPON_TYPE] = 0;
+#endif
}
+
// size_fix.txt
- for(i = 0; i < ARRAYLENGTH(status->atkmods); i++)
+ for(i = 0; i < ARRAYLENGTH(status->dbs->atkmods); i++)
for(j = 0; j < MAX_WEAPON_TYPE; j++)
- status->atkmods[i][j] = 100;
+ status->dbs->atkmods[i][j] = 100;
// refine_db.txt
- for(i=0;i<ARRAYLENGTH(status->refine_info);i++) {
+ for(i=0;i<ARRAYLENGTH(status->dbs->refine_info);i++) {
for(j=0;j<MAX_REFINE; j++) {
- status->refine_info[i].chance[j] = 100;
- status->refine_info[i].bonus[j] = 0;
- status->refine_info[i].randombonus_max[j] = 0;
+ status->dbs->refine_info[i].chance[j] = 100;
+ status->dbs->refine_info[i].bonus[j] = 0;
+ status->dbs->refine_info[i].randombonus_max[j] = 0;
}
}
// read databases
//
-
-
-#ifdef RENEWAL_ASPD
- sv->readdb(map->db_path, "re/job_db1.txt", ',', 6+MAX_WEAPON_TYPE, 6+MAX_WEAPON_TYPE, -1, status->readdb_job1);
-#else
- 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, 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, DBPATH"size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(status->dbs->atkmods), status->readdb_sizefix);
+ sv->readdb(map->db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(status->dbs->refine_info), status->readdb_refine);
sv->readdb(map->db_path, "sc_config.txt", ',', 2, 2, SC_MAX, status->readdb_scconfig);
+ status->read_job_db();
return 0;
}
@@ -12224,7 +12354,6 @@ int do_init_status(bool minimal) {
status->initChangeTables();
status->initDummyData();
status->readdb();
- status->calc_sigma();
status->natural_heal_prev_tick = timer->gettick();
status->data_ers = ers_new(sizeof(struct status_change_entry),"status.c::data_ers",ERS_OPT_NONE);
timer->add_interval(status->natural_heal_prev_tick + NATURAL_HEAL_INTERVAL, status->natural_heal_timer, 0, 0, NATURAL_HEAL_INTERVAL);
@@ -12241,6 +12370,7 @@ void do_final_status(void) {
*-------------------------------------*/
void status_defaults(void) {
status = &status_s;
+ status->dbs = &statusdbs;
/* vars */
//we need it for new cards 15 Feb 2005, to check if the combo cards are insrerted into the CURRENT weapon only
@@ -12248,23 +12378,8 @@ void status_defaults(void) {
status->current_equip_item_index = 0; //Contains inventory index of an equipped item. To pass it into the EQUP_SCRIPT [Lupus]
status->current_equip_card_id = 0; //To prevent card-stacking (from jA) [Skotlex]
- memset(status->max_weight_base,0,sizeof(status->max_weight_base)
- + sizeof(status->hp_coefficient)
- + sizeof(status->hp_coefficient2)
- + sizeof(status->hp_sigma_val)
- + sizeof(status->sp_coefficient)
- + sizeof(status->aspd_base)
- + sizeof(status->Skill2SCTable)
- + sizeof(status->IconChangeTable)
- + sizeof(status->ChangeFlagTable)
- + sizeof(status->SkillChangeTable)
- + sizeof(status->RelevantBLTypes)
- + sizeof(status->DisplayType)
- + sizeof(status->refine_info)
- + sizeof(status->atkmods)
- + sizeof(status->job_bonus)
- + sizeof(status->sc_conf)
- );
+ // These macros are used instead of a sum of sizeof(), to ensure that padding won't interfere with our size, and code won't rot when adding more fields
+ memset(ZEROED_BLOCK_POS(status->dbs), 0, ZEROED_BLOCK_SIZE(status->dbs));
status->data_ers = NULL;
memset(&status->dummy, 0, sizeof(status->dummy));
@@ -12361,9 +12476,8 @@ void status_defaults(void) {
status->initDummyData = initDummyData;
status->base_amotion_pc = status_base_amotion_pc;
status->base_atk = status_base_atk;
- status->calc_sigma = status_calc_sigma;
- status->base_pc_maxhp = status_base_pc_maxhp;
- status->base_pc_maxsp = status_base_pc_maxsp;
+ status->get_base_maxhp = status_get_base_maxhp;
+ status->get_base_maxsp = status_get_base_maxsp;
status->calc_npc_ = status_calc_npc_;
status->calc_str = status_calc_str;
status->calc_agi = status_calc_agi;
@@ -12393,9 +12507,10 @@ void status_defaults(void) {
status->display_remove = status_display_remove;
status->natural_heal = status_natural_heal;
status->natural_heal_timer = status_natural_heal_timer;
- status->readdb_job1 = status_readdb_job1;
status->readdb_job2 = status_readdb_job2;
status->readdb_sizefix = status_readdb_sizefix;
status->readdb_refine = status_readdb_refine;
status->readdb_scconfig = status_readdb_scconfig;
+ status->read_job_db = status_read_job_db;
+ status->read_job_db_sub = status_read_job_db_sub;
}
diff --git a/src/map/status.h b/src/map/status.h
index 1a8d7ef51..45a1300a0 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -5,10 +5,11 @@
#ifndef MAP_STATUS_H
#define MAP_STATUS_H
-#include "../config/core.h" // defType, RENEWAL, RENEWAL_ASPD
+#include "config/core.h" // defType, RENEWAL, RENEWAL_ASPD
-#include "../common/cbasetypes.h"
-#include "../common/mmo.h" // NEW_CARTS
+#include "common/conf.h"
+#include "common/cbasetypes.h"
+#include "common/mmo.h" // NEW_CARTS
struct block_list;
struct elemental_data;
@@ -527,7 +528,7 @@ typedef enum sc_type {
SC_BEYOND_OF_WARCRY,
SC_UNLIMITED_HUMMING_VOICE, // 410
SC_SITDOWN_FORCE,
- //SC_NETHERWORLD,
+ SC_NETHERWORLD,
/**
* Sura
**/
@@ -1655,49 +1656,6 @@ enum {
OPT3_CONTRACT = 0x00020000,
};
-enum {
- OPTION_NOTHING = 0x00000000,
- OPTION_SIGHT = 0x00000001,
- OPTION_HIDE = 0x00000002,
- OPTION_CLOAK = 0x00000004,
- OPTION_FALCON = 0x00000010,
- OPTION_RIDING = 0x00000020,
- OPTION_INVISIBLE = 0x00000040,
- OPTION_ORCISH = 0x00000800,
- OPTION_WEDDING = 0x00001000,
- OPTION_RUWACH = 0x00002000,
- OPTION_CHASEWALK = 0x00004000,
- OPTION_FLYING = 0x00008000, //Note that clientside Flying and Xmas are 0x8000 for clients prior to 2007.
- OPTION_XMAS = 0x00010000,
- OPTION_TRANSFORM = 0x00020000,
- OPTION_SUMMER = 0x00040000,
- OPTION_DRAGON1 = 0x00080000,
- OPTION_WUG = 0x00100000,
- OPTION_WUGRIDER = 0x00200000,
- OPTION_MADOGEAR = 0x00400000,
- OPTION_DRAGON2 = 0x00800000,
- OPTION_DRAGON3 = 0x01000000,
- OPTION_DRAGON4 = 0x02000000,
- 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,
-};
-
//Defines for the manner system [Skotlex]
enum manner_flags
{
@@ -1868,6 +1826,7 @@ struct sc_display_entry {
struct status_change_entry {
int timer;
int val1,val2,val3,val4;
+ bool infinite_duration;
};
struct status_change {
@@ -1969,22 +1928,11 @@ struct s_refine_info {
int randombonus_max[MAX_REFINE]; // cumulative maximum random bonus damage
};
-/*=====================================
-* Interface : status.h
-* Generated by HerculesInterfaceMaker
-* created by Susu
-*-------------------------------------*/
-struct status_interface {
-
- /* vars */
- int current_equip_item_index;
- int current_equip_card_id;
- /* */
+struct s_status_dbs {
+BEGIN_ZEROED_BLOCK; /* Everything within this block will be memset to 0 when status_defaults() is executed */
int max_weight_base[CLASS_COUNT];
- int hp_coefficient[CLASS_COUNT];
- int hp_coefficient2[CLASS_COUNT];
- int hp_sigma_val[CLASS_COUNT][MAX_LEVEL+1];
- int sp_coefficient[CLASS_COUNT];
+ int HP_table[CLASS_COUNT][MAX_LEVEL + 1];
+ int SP_table[CLASS_COUNT][MAX_LEVEL + 1];
int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE+1]; // +1 for RENEWAL_ASPD
sc_type Skill2SCTable[MAX_SKILL]; // skill -> status
int IconChangeTable[SC_MAX]; // status -> "icon" (icon is a bit of a misnomer, since there exist values with no icon associated)
@@ -1998,6 +1946,22 @@ struct status_interface {
int atkmods[3][MAX_WEAPON_TYPE];//ATK weapon modification for size (size_fix.txt)
char job_bonus[CLASS_COUNT][MAX_LEVEL];
sc_conf_type sc_conf[SC_MAX];
+END_ZEROED_BLOCK; /* End */
+};
+
+/*=====================================
+* Interface : status.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+struct status_interface {
+
+ /* vars */
+ int current_equip_item_index;
+ int current_equip_card_id;
+
+ struct s_status_dbs *dbs;
+
struct eri *data_ers; //For sc_data entries
struct status_data dummy;
int64 natural_heal_prev_tick;
@@ -2082,9 +2046,8 @@ struct status_interface {
void (*initDummyData) (void);
int (*base_amotion_pc) (struct map_session_data *sd, struct status_data *st);
unsigned short (*base_atk) (const struct block_list *bl, const struct status_data *st);
- void (*calc_sigma) (void);
- unsigned int (*base_pc_maxhp) (struct map_session_data *sd, struct status_data *st);
- unsigned int (*base_pc_maxsp) (struct map_session_data *sd, struct status_data *st);
+ unsigned int (*get_base_maxhp) (struct map_session_data *sd, struct status_data *st);
+ unsigned int (*get_base_maxsp) (struct map_session_data *sd, struct status_data *st);
int (*calc_npc_) (struct npc_data *nd, enum e_status_calc_opt opt);
unsigned short (*calc_str) (struct block_list *bl, struct status_change *sc, int str);
unsigned short (*calc_agi) (struct block_list *bl, struct status_change *sc, int agi);
@@ -2114,11 +2077,12 @@ struct status_interface {
void (*display_remove) (struct map_session_data *sd, enum sc_type type);
int (*natural_heal) (struct block_list *bl, va_list args);
int (*natural_heal_timer) (int tid, int64 tick, int id, intptr_t data);
- bool (*readdb_job1) (char *fields[], int columns, int current);
bool (*readdb_job2) (char *fields[], int columns, int current);
bool (*readdb_sizefix) (char *fields[], int columns, int current);
bool (*readdb_refine) (char *fields[], int columns, int current);
bool (*readdb_scconfig) (char *fields[], int columns, int current);
+ void (*read_job_db) (void);
+ void (*read_job_db_sub) (int idx, const char *name, config_setting_t *jdb);
};
struct status_interface *status;
diff --git a/src/map/storage.c b/src/map/storage.c
index 79a5ad52d..95194bc47 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -6,25 +6,25 @@
#include "storage.h"
+#include "map/atcommand.h"
+#include "map/battle.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/guild.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/map.h" // struct map_session_data
+#include "map/pc.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "atcommand.h"
-#include "battle.h"
-#include "chrif.h"
-#include "clif.h"
-#include "guild.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "map.h" // struct map_session_data
-#include "pc.h"
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-
struct storage_interface storage_s;
struct guild_storage_interface gstorage_s;
@@ -83,7 +83,7 @@ int storage_storageopen(struct map_session_data *sd)
{
nullpo_ret(sd);
- if(sd->state.storage_flag)
+ if (sd->state.storage_flag != STORAGE_FLAG_CLOSED)
return 1; //Already open?
if( !pc_can_give_items(sd) ) {
@@ -92,7 +92,7 @@ int storage_storageopen(struct map_session_data *sd)
return 1;
}
- sd->state.storage_flag = 1;
+ sd->state.storage_flag = STORAGE_FLAG_NORMAL;
storage->sortitem(sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items));
clif->storagelist(sd, sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items));
clif->updatestorageamount(sd, sd->status.storage.storage_amount, MAX_STORAGE);
@@ -109,7 +109,8 @@ int compare_item(struct item *a, struct item *b)
a->refine == b->refine &&
a->attribute == b->attribute &&
a->expire_time == b->expire_time &&
- a->bound == b->bound )
+ a->bound == b->bound &&
+ a->unique_id == b->unique_id)
{
int i;
for (i = 0; i < MAX_SLOTS && (a->card[i] == b->card[i]); i++);
@@ -155,6 +156,7 @@ int storage_additem(struct map_session_data* sd, struct item* item_data, int amo
{// existing items found, stack them
if( amount > MAX_AMOUNT - stor->items[i].amount || ( data->stack.storage && amount > data->stack.amount - stor->items[i].amount ) )
return 1;
+
stor->items[i].amount += amount;
clif->storageitemadded(sd,&stor->items[i],i,amount);
return 0;
@@ -190,9 +192,11 @@ int storage_delitem(struct map_session_data* sd, int n, int amount)
{
memset(&sd->status.storage.items[n],0,sizeof(sd->status.storage.items[0]));
sd->status.storage.storage_amount--;
- if( sd->state.storage_flag == 1 ) clif->updatestorageamount(sd, sd->status.storage.storage_amount, MAX_STORAGE);
+ if( sd->state.storage_flag == STORAGE_FLAG_NORMAL )
+ clif->updatestorageamount(sd, sd->status.storage.storage_amount, MAX_STORAGE);
}
- if( sd->state.storage_flag == 1 ) clif->storageitemremoved(sd,n,amount);
+ if( sd->state.storage_flag == STORAGE_FLAG_NORMAL )
+ clif->storageitemremoved(sd,n,amount);
return 0;
}
@@ -219,9 +223,9 @@ int storage_storageadd(struct map_session_data* sd, int index, int amount) {
return 0;
if( storage->additem(sd,&sd->status.inventory[index],amount) == 0 )
- pc->delitem(sd,index,amount,0,4,LOG_TYPE_STORAGE);
+ pc->delitem(sd, index, amount, 0, DELITEM_TOSTORAGE, LOG_TYPE_STORAGE);
else
- clif->dropitem(sd, index,0);
+ clif->dropitem(sd, index, 0);
return 1;
}
@@ -325,7 +329,7 @@ void storage_storageclose(struct map_session_data* sd) {
if( map->save_settings&4 )
chrif->save(sd,0); //Invokes the storage saving as well.
- sd->state.storage_flag = 0;
+ sd->state.storage_flag = STORAGE_FLAG_CLOSED;
}
/*==========================================
@@ -337,7 +341,7 @@ void storage_storage_quit(struct map_session_data* sd, int flag) {
if (map->save_settings&4)
chrif->save(sd, flag); //Invokes the storage saving as well.
- sd->state.storage_flag = 0;
+ sd->state.storage_flag = STORAGE_FLAG_CLOSED;
}
/**
@@ -380,7 +384,7 @@ int storage_guild_storageopen(struct map_session_data* sd)
if(sd->status.guild_id <= 0)
return 2;
- if(sd->state.storage_flag)
+ if (sd->state.storage_flag != STORAGE_FLAG_CLOSED)
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]
@@ -399,7 +403,7 @@ int storage_guild_storageopen(struct map_session_data* sd)
return 1;
gstor->storage_status = 1;
- sd->state.storage_flag = 2;
+ sd->state.storage_flag = STORAGE_FLAG_GUILD;
storage->sortitem(gstor->items, ARRAYLENGTH(gstor->items));
clif->storagelist(sd, gstor->items, ARRAYLENGTH(gstor->items));
clif->updatestorageamount(sd, gstor->storage_amount, MAX_GUILD_STORAGE);
@@ -525,10 +529,10 @@ int storage_guild_storageadd(struct map_session_data* sd, int index, int amount)
return 0;
}
- if(gstorage->additem(sd,stor,&sd->status.inventory[index],amount)==0)
- pc->delitem(sd,index,amount,0,4,LOG_TYPE_GSTORAGE);
+ if( gstorage->additem(sd,stor,&sd->status.inventory[index],amount) == 0 )
+ pc->delitem(sd, index, amount, 0, DELITEM_TOSTORAGE, LOG_TYPE_GSTORAGE);
else
- clif->dropitem(sd, index,0);
+ clif->dropitem(sd, index, 0);
return 1;
}
@@ -694,7 +698,7 @@ int storage_guild_storageclose(struct map_session_data* sd) {
gstorage->save(sd->status.account_id, sd->status.guild_id,0);
stor->storage_status=0;
}
- sd->state.storage_flag = 0;
+ sd->state.storage_flag = STORAGE_FLAG_CLOSED;
return 0;
}
@@ -707,7 +711,7 @@ int storage_guild_storage_quit(struct map_session_data* sd, int flag) {
if(flag) {
//Only during a guild break flag is 1 (don't save storage)
- sd->state.storage_flag = 0;
+ sd->state.storage_flag = STORAGE_FLAG_CLOSED;
stor->storage_status = 0;
clif->storageclose(sd);
if (map->save_settings&4)
@@ -721,7 +725,7 @@ int storage_guild_storage_quit(struct map_session_data* sd, int flag) {
else
gstorage->save(sd->status.account_id,sd->status.guild_id,1);
}
- sd->state.storage_flag = 0;
+ sd->state.storage_flag = STORAGE_FLAG_CLOSED;
stor->storage_status = 0;
return 0;
diff --git a/src/map/storage.h b/src/map/storage.h
index 6393e124a..5f2c69f56 100644
--- a/src/map/storage.h
+++ b/src/map/storage.h
@@ -5,13 +5,22 @@
#ifndef MAP_STORAGE_H
#define MAP_STORAGE_H
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
struct guild_storage;
struct item;
struct map_session_data;
+/**
+ * Acceptable values for map_session_data.state.storage_flag
+ */
+enum storage_flag {
+ STORAGE_FLAG_CLOSED = 0, // Closed
+ STORAGE_FLAG_NORMAL = 1, // Normal Storage open
+ STORAGE_FLAG_GUILD = 2, // Guild Storage open
+};
+
struct storage_interface {
/* */
void (*reconnect) (void);
diff --git a/src/map/trade.c b/src/map/trade.c
index 7417f05af..4dd6ffafa 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -6,24 +6,24 @@
#include "trade.h"
+#include "map/atcommand.h"
+#include "map/battle.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/map.h"
+#include "map/npc.h"
+#include "map/path.h"
+#include "map/pc.h"
+#include "map/storage.h"
+#include "common/nullpo.h"
+#include "common/socket.h"
+
#include <stdio.h>
#include <string.h>
-#include "atcommand.h"
-#include "battle.h"
-#include "chrif.h"
-#include "clif.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "map.h"
-#include "npc.h"
-#include "path.h"
-#include "pc.h"
-#include "storage.h"
-#include "../common/nullpo.h"
-#include "../common/socket.h"
-
struct trade_interface trade_s;
/*==========================================
@@ -145,8 +145,8 @@ 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
+ if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.storage_flag != STORAGE_FLAG_CLOSED
+ || tsd->npc_id || tsd->state.vending || tsd->state.buyingstore || tsd->state.storage_flag != STORAGE_FLAG_CLOSED
) {
//Fail
clif->tradestart(sd, 2);
@@ -208,13 +208,13 @@ int impossible_trade_check(struct map_session_data *sd)
intif->wis_message_to_gm(map->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm);
// if we block people
if (battle_config.ban_hack_trade < 0) {
- chrif->char_ask_name(-1, sd->status.name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
+ chrif->char_ask_name(-1, sd->status.name, CHAR_ASK_NAME_BLOCK, 0, 0, 0, 0, 0, 0);
set_eof(sd->fd); // forced to disconnect because of the hack
// message about the ban
safestrncpy(message_to_gm, msg_txt(540), sizeof(message_to_gm)); // This player has been definitively blocked.
// if we ban people
} else if (battle_config.ban_hack_trade > 0) {
- chrif->char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_hack_trade, 0); // type: 2 - ban (year, month, day, hour, minute, second)
+ chrif->char_ask_name(-1, sd->status.name, CHAR_ASK_NAME_BAN, 0, 0, 0, 0, battle_config.ban_hack_trade, 0); // type: 2 - ban (year, month, day, hour, minute, second)
set_eof(sd->fd); // forced to disconnect because of the hack
// message about the ban
sprintf(message_to_gm, msg_txt(507), battle_config.ban_hack_trade); // This player has been banned for %d minute(s).
@@ -561,7 +561,7 @@ void trade_tradecommit(struct map_session_data *sd) {
flag = pc->additem(tsd, &sd->status.inventory[n], sd->deal.item[trade_i].amount,LOG_TYPE_TRADE);
if (flag == 0)
- pc->delitem(sd, n, sd->deal.item[trade_i].amount, 1, 6, LOG_TYPE_TRADE);
+ pc->delitem(sd, n, sd->deal.item[trade_i].amount, 1, DELITEM_SOLD, LOG_TYPE_TRADE);
else
clif->additem(sd, n, sd->deal.item[trade_i].amount, 0);
sd->deal.item[trade_i].index = 0;
@@ -573,7 +573,7 @@ void trade_tradecommit(struct map_session_data *sd) {
flag = pc->additem(sd, &tsd->status.inventory[n], tsd->deal.item[trade_i].amount,LOG_TYPE_TRADE);
if (flag == 0)
- pc->delitem(tsd, n, tsd->deal.item[trade_i].amount, 1, 6, LOG_TYPE_TRADE);
+ pc->delitem(tsd, n, tsd->deal.item[trade_i].amount, 1, DELITEM_SOLD, LOG_TYPE_TRADE);
else
clif->additem(tsd, n, tsd->deal.item[trade_i].amount, 0);
tsd->deal.item[trade_i].index = 0;
diff --git a/src/map/unit.c b/src/map/unit.c
index 2e96e9c20..60911b85a 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -4,47 +4,47 @@
#define HERCULES_CORE
-#include "../config/core.h" // RENEWAL_CAST
+#include "config/core.h" // RENEWAL_CAST
#include "unit.h"
+#include "map/battle.h"
+#include "map/battleground.h"
+#include "map/chat.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/duel.h"
+#include "map/elemental.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/instance.h"
+#include "map/intif.h"
+#include "map/map.h"
+#include "map/mercenary.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/party.h"
+#include "map/path.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/script.h"
+#include "map/skill.h"
+#include "map/status.h"
+#include "map/storage.h"
+#include "map/trade.h"
+#include "map/vending.h"
+#include "common/HPM.h"
+#include "common/db.h"
+#include "common/malloc.h"
+#include "common/nullpo.h"
+#include "common/random.h"
+#include "common/showmsg.h"
+#include "common/socket.h"
+#include "common/timer.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "battle.h"
-#include "battleground.h"
-#include "chat.h"
-#include "chrif.h"
-#include "clif.h"
-#include "duel.h"
-#include "elemental.h"
-#include "guild.h"
-#include "homunculus.h"
-#include "instance.h"
-#include "intif.h"
-#include "map.h"
-#include "mercenary.h"
-#include "mob.h"
-#include "npc.h"
-#include "party.h"
-#include "path.h"
-#include "pc.h"
-#include "pet.h"
-#include "script.h"
-#include "skill.h"
-#include "status.h"
-#include "storage.h"
-#include "trade.h"
-#include "vending.h"
-#include "../common/HPM.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/random.h"
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/timer.h"
-
const short dirx[8]={0,-1,-1,-1,0,1,1,1};
const short diry[8]={1,1,0,-1,-1,-1,0,1};
@@ -737,7 +737,7 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool
if( ud == NULL) return 0;
- unit->stop_walking(bl,1);
+ unit->stop_walking(bl, STOPWALKING_FLAG_FIXPOS);
unit->stop_attack(bl);
if( checkpath && (map->getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) )
@@ -834,7 +834,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
ny = result&0xffff;
if(!su) {
- unit->stop_walking(bl, 0);
+ unit->stop_walking(bl, STOPWALKING_FLAG_NONE);
}
if( sd ) {
@@ -952,14 +952,10 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
/*==========================================
* Caused the target object to stop moving.
- * Flag values:
- * &0x1: Issue a fixpos packet afterwards
- * &0x2: Force the unit to move one cell if it hasn't yet
- * &0x4: Enable moving to the next cell when unit was already half-way there
- * (may cause on-touch/place side-effects, such as a scripted map change)
+ * Flag values: @see unit_stopwalking_flag.
+ * Upper bytes may be used for other purposes depending on the unit type.
*------------------------------------------*/
-int unit_stop_walking(struct block_list *bl,int type)
-{
+int unit_stop_walking(struct block_list *bl, int flag) {
struct unit_data *ud;
const struct TimerData* td;
int64 tick;
@@ -976,22 +972,22 @@ int unit_stop_walking(struct block_list *bl,int type)
ud->walktimer = INVALID_TIMER;
ud->state.change_walk_target = 0;
tick = timer->gettick();
- if( (type&0x02 && !ud->walkpath.path_pos) //Force moving at least one cell.
- || (type&0x04 && td && DIFF_TICK(td->tick, tick) <= td->data/2) //Enough time has passed to cover half-cell
+ if( (flag&STOPWALKING_FLAG_ONESTEP && !ud->walkpath.path_pos) //Force moving at least one cell.
+ || (flag&STOPWALKING_FLAG_NEXTCELL && td && DIFF_TICK(td->tick, tick) <= td->data/2) //Enough time has passed to cover half-cell
) {
ud->walkpath.path_len = ud->walkpath.path_pos+1;
unit->walktoxy_timer(INVALID_TIMER, tick, bl->id, ud->walkpath.path_pos);
}
- if(type&0x01)
+ if(flag&STOPWALKING_FLAG_FIXPOS)
clif->fixpos(bl);
ud->walkpath.path_len = 0;
ud->walkpath.path_pos = 0;
ud->to_x = bl->x;
ud->to_y = bl->y;
- if(bl->type == BL_PET && type&~0xff)
- ud->canmove_tick = timer->gettick() + (type>>8);
+ if(bl->type == BL_PET && flag&~STOPWALKING_FLAG_MASK)
+ ud->canmove_tick = timer->gettick() + (flag>>8);
//Read, the check in unit_set_walkdelay means dmg during running won't fall through to this place in code [Kevin]
if (ud->state.running) {
@@ -1081,6 +1077,7 @@ int unit_can_move(struct block_list *bl) {
|| sc->data[SC_NEEDLE_OF_PARALYZE]
|| sc->data[SC_VACUUM_EXTREME]
|| (sc->data[SC_FEAR] && sc->data[SC_FEAR]->val2 > 0)
+ || sc->data[SC_NETHERWORLD]
|| (sc->data[SC_SPIDERWEB] && sc->data[SC_SPIDERWEB]->val1)
|| (sc->data[SC_CLOAKING] && sc->data[SC_CLOAKING]->val1 < 3 && !(sc->data[SC_CLOAKING]->val4&1)) //Need wall at level 1-2
|| (
@@ -1168,17 +1165,14 @@ int unit_set_walkdelay(struct block_list *bl, int64 tick, int delay, int type) {
//Stop walking, if chasing, readjust timers.
if (delay == 1) {
//Minimal delay (walk-delay) disabled. Just stop walking.
- unit->stop_walking(bl,4);
+ unit->stop_walking(bl, STOPWALKING_FLAG_NEXTCELL);
} else {
//Resume running after can move again [Kevin]
- if(ud->state.running)
- {
+ if (ud->state.running) {
timer->add(ud->canmove_tick, unit->resume_running, bl->id, (intptr_t)ud);
- }
- else
- {
- unit->stop_walking(bl,4);
- if(ud->target)
+ } else {
+ unit->stop_walking(bl, STOPWALKING_FLAG_NEXTCELL);
+ if (ud->target)
timer->add(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target);
}
}
@@ -1353,18 +1347,21 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
}
}
- 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 (src->type == BL_HOM) {
+ // In case of homunuculus, set the sd to the homunculus' master, as needed below
+ struct block_list *master = battle->get_master(src);
+ if (master)
+ sd = map->id2sd(master->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 )
@@ -1372,7 +1369,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
case NPC_SUMMONSLAVE:
case NPC_SUMMONMONSTER:
case AL_TELEPORT:
- if( ((TBL_MOB*)src)->master_id && ((TBL_MOB*)src)->special_state.ai )
+ if (((TBL_MOB*)src)->master_id && ((TBL_MOB*)src)->special_state.ai != AI_NONE)
return 0;
}
@@ -1543,8 +1540,8 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
}
}
- 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
+ if (!ud->state.running) //need TK_RUN or WUGDASH handler to be done before that, see bugreport:6026
+ unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS);// 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);
@@ -1604,7 +1601,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
unit->setdir(src, map->calc_dir(src, target->x, target->y));
ud->skilltimer = timer->add( tick+casttime, skill->castend_id, src->id, 0 );
if( sd && (pc->checkskill(sd,SA_FREECAST) > 0 || skill_id == LG_EXEEDBREAK) )
- status_calc_bl(&sd->bl, SCB_SPEED);
+ status_calc_bl(&sd->bl, SCB_SPEED|SCB_ASPD);
} else
skill->castend_id(ud->skilltimer,tick,src->id,0);
@@ -1741,14 +1738,15 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
}
}
- unit->stop_walking(src,1);
+ unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS);
// in official this is triggered even if no cast time.
clif->skillcasting(src, src->id, 0, skill_x, skill_y, skill_id, skill->get_ele(skill_id, skill_lv), casttime);
if( casttime > 0 ) {
unit->setdir(src, map->calc_dir(src, skill_x, skill_y));
ud->skilltimer = timer->add( tick+casttime, skill->castend_pos, src->id, 0 );
- if( (sd && pc->checkskill(sd,SA_FREECAST) > 0) || skill_id == LG_EXEEDBREAK)
- status_calc_bl(&sd->bl, SCB_SPEED);
+ if ( (sd && pc->checkskill(sd, SA_FREECAST) > 0) || skill_id == LG_EXEEDBREAK ) {
+ status_calc_bl(&sd->bl, SCB_SPEED|SCB_ASPD);
+ }
} else {
ud->skilltimer = INVALID_TIMER;
skill->castend_pos(ud->skilltimer,tick,src->id,0);
@@ -2129,7 +2127,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, int64 tick) {
ud->dir = map->calc_dir(src, target->x,target->y );
}
if(ud->walktimer != INVALID_TIMER)
- unit->stop_walking(src,1);
+ unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS);
if(md) {
//First attack is always a normal attack
if(md->state.skillstate == MSS_ANGRY || md->state.skillstate == MSS_BERSERK) {
@@ -2231,7 +2229,7 @@ int unit_skillcastcancel(struct block_list *bl,int type)
ud->skilltimer = INVALID_TIMER;
if( sd && pc->checkskill(sd,SA_FREECAST) > 0 )
- status_calc_bl(&sd->bl, SCB_SPEED);
+ status_calc_bl(&sd->bl, SCB_SPEED|SCB_ASPD);
if( sd ) {
switch( skill_id ) {
@@ -2324,7 +2322,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i
map->freeblock_lock();
if (ud->walktimer != INVALID_TIMER)
- unit->stop_walking(bl,0);
+ unit->stop_walking(bl, STOPWALKING_FLAG_NONE);
if (ud->skilltimer != INVALID_TIMER)
unit->skillcastcancel(bl,0);
@@ -2374,6 +2372,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i
status_change_end(bl, SC__MANHOLE, INVALID_TIMER);
status_change_end(bl, SC_VACUUM_EXTREME, INVALID_TIMER);
status_change_end(bl, SC_CURSEDCIRCLE_ATKER, INVALID_TIMER); //callme before warp
+ status_change_end(bl, SC_NETHERWORLD, INVALID_TIMER);
}
if (bl->type&(BL_CHAR|BL_PET)) {
@@ -2392,18 +2391,18 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i
}
//Leave/reject all invitations.
if(sd->chatID)
- chat->leave(sd,0);
+ chat->leave(sd, false);
if(sd->trade_partner)
trade->cancel(sd);
buyingstore->close(sd);
searchstore->close(sd);
if( sd->menuskill_id != AL_TELEPORT ) { // issue: 8027
- if(sd->state.storage_flag == 1)
+ if(sd->state.storage_flag == STORAGE_FLAG_NORMAL)
storage->pc_quit(sd,0);
- else if (sd->state.storage_flag == 2)
+ else if (sd->state.storage_flag == STORAGE_FLAG_GUILD)
gstorage->pc_quit(sd,0);
- sd->state.storage_flag = 0; //Force close it when being warped.
+ sd->state.storage_flag = STORAGE_FLAG_CLOSED; //Force close it when being warped.
}
if(sd->party_invite>0)
party->reply_invite(sd,sd->party_invite,0);
diff --git a/src/map/unit.h b/src/map/unit.h
index 881fa16f4..00fff5981 100644
--- a/src/map/unit.h
+++ b/src/map/unit.h
@@ -5,14 +5,27 @@
#ifndef MAP_UNIT_H
#define MAP_UNIT_H
-#include "clif.h" // clr_type
-#include "path.h" // struct walkpath_data
-#include "skill.h" // 'MAX_SKILLTIMERSKILL, struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset
-#include "../common/cbasetypes.h"
+#include "map/clif.h" // clr_type
+#include "map/path.h" // struct walkpath_data
+#include "map/skill.h" // 'MAX_SKILLTIMERSKILL, struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset
+#include "common/cbasetypes.h"
struct map_session_data;
struct block_list;
+/**
+ * Bitmask values usable as a flag in unit_stopwalking
+ */
+enum unit_stopwalking_flag {
+ STOPWALKING_FLAG_NONE = 0x00,
+ STOPWALKING_FLAG_FIXPOS = 0x01, ///< Issue a fixpos packet afterwards
+ STOPWALKING_FLAG_ONESTEP = 0x02, ///< Force the unit to move one cell if it hasn't yet
+ STOPWALKING_FLAG_NEXTCELL = 0x04, ///< Enable moving to the next cell when unit was already half-way there
+ /// (may cause on-touch/place side-effects, such as a scripted map change)
+ STOPWALKING_FLAG_MASK = 0xff, ///< Mask all of the above
+ // Note: Upper bytes are reserved for duration.
+};
+
struct unit_data {
struct block_list *bl;
struct walkpath_data walkpath;
diff --git a/src/map/vending.c b/src/map/vending.c
index 8ae3f36a4..d0f0dee00 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -6,24 +6,24 @@
#include "vending.h"
+#include "map/atcommand.h"
+#include "map/battle.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/map.h"
+#include "map/npc.h"
+#include "map/path.h"
+#include "map/pc.h"
+#include "map/skill.h"
+#include "common/nullpo.h"
+#include "common/strlib.h"
+#include "common/utils.h"
+
#include <stdio.h>
#include <string.h>
-#include "atcommand.h"
-#include "battle.h"
-#include "chrif.h"
-#include "clif.h"
-#include "itemdb.h"
-#include "log.h"
-#include "map.h"
-#include "npc.h"
-#include "path.h"
-#include "pc.h"
-#include "skill.h"
-#include "../common/nullpo.h"
-#include "../common/strlib.h"
-#include "../common/utils.h"
-
struct vending_interface vending_s;
/// Returns an unique vending shop id.
@@ -38,7 +38,7 @@ void vending_closevending(struct map_session_data* sd) {
nullpo_retv(sd);
if( sd->state.vending ) {
- sd->state.vending = false;
+ sd->state.vending = 0;
clif->closevendingboard(&sd->bl, 0);
idb_remove(vending->db, sd->status.char_id);
}
diff --git a/src/map/vending.h b/src/map/vending.h
index 00d3eefff..189189227 100644
--- a/src/map/vending.h
+++ b/src/map/vending.h
@@ -5,8 +5,8 @@
#ifndef MAP_VENDING_H
#define MAP_VENDING_H
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
+#include "common/cbasetypes.h"
+#include "common/db.h"
struct map_session_data;
struct s_search_store_search;
diff --git a/src/plugins/HPMHooking.c b/src/plugins/HPMHooking.c
index c6fb6462d..e15cc363d 100644
--- a/src/plugins/HPMHooking.c
+++ b/src/plugins/HPMHooking.c
@@ -2,99 +2,99 @@
// See the LICENSE file
// Sample Hercules Plugin
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "../common/HPMi.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/socket.h"
+#include "common/HPMi.h"
+#include "common/db.h"
+#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"
+#define HPM_CORE_INCLUDE "HPMHooking/HPMHooking_login.HPMHooksCore.inc"
+#define HPM_SYMBOL_INCLUDE "HPMHooking/HPMHooking_login.GetSymbol.inc"
+#define HPM_HOOKS_INCLUDE "HPMHooking/HPMHooking_login.Hooks.inc"
+#define HPM_POINTS_INCLUDE "HPMHooking/HPMHooking_login.HookingPoints.inc"
+#define HPM_SOURCES_INCLUDE "HPMHooking/HPMHooking_login.sources.inc"
+#include "login/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"
+#define HPM_CORE_INCLUDE "HPMHooking/HPMHooking_char.HPMHooksCore.inc"
+#define HPM_SYMBOL_INCLUDE "HPMHooking/HPMHooking_char.GetSymbol.inc"
+#define HPM_HOOKS_INCLUDE "HPMHooking/HPMHooking_char.Hooks.inc"
+#define HPM_POINTS_INCLUDE "HPMHooking/HPMHooking_char.HookingPoints.inc"
+#define HPM_SOURCES_INCLUDE "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"
-#include "../map/channel.h"
-#include "../map/chat.h"
-#include "../map/chrif.h"
-#include "../map/clif.h"
-#include "../map/duel.h"
-#include "../map/elemental.h"
-#include "../map/guild.h"
-#include "../map/homunculus.h"
-#include "../map/instance.h"
-#include "../map/intif.h"
-#include "../map/irc-bot.h"
-#include "../map/itemdb.h"
-#include "../map/log.h"
-#include "../map/mail.h"
-#include "../map/map.h"
-#include "../map/mapreg.h"
-#include "../map/mercenary.h"
-#include "../map/mob.h"
-#include "../map/npc.h"
-#include "../map/npc.h"
-#include "../map/party.h"
-#include "../map/path.h"
-#include "../map/pc.h"
-#include "../map/pet.h"
-#include "../map/quest.h"
-#include "../map/script.h"
-#include "../map/skill.h"
-#include "../map/status.h"
-#include "../map/storage.h"
-#include "../map/trade.h"
-#include "../map/unit.h"
+#define HPM_CORE_INCLUDE "HPMHooking/HPMHooking_map.HPMHooksCore.inc"
+#define HPM_SYMBOL_INCLUDE "HPMHooking/HPMHooking_map.GetSymbol.inc"
+#define HPM_HOOKS_INCLUDE "HPMHooking/HPMHooking_map.Hooks.inc"
+#define HPM_POINTS_INCLUDE "HPMHooking/HPMHooking_map.HookingPoints.inc"
+#define HPM_SOURCES_INCLUDE "HPMHooking/HPMHooking_map.sources.inc"
+#include "map/atcommand.h"
+#include "map/battle.h"
+#include "map/battleground.h"
+#include "map/channel.h"
+#include "map/chat.h"
+#include "map/chrif.h"
+#include "map/clif.h"
+#include "map/duel.h"
+#include "map/elemental.h"
+#include "map/guild.h"
+#include "map/homunculus.h"
+#include "map/instance.h"
+#include "map/intif.h"
+#include "map/irc-bot.h"
+#include "map/itemdb.h"
+#include "map/log.h"
+#include "map/mail.h"
+#include "map/map.h"
+#include "map/mapreg.h"
+#include "map/mercenary.h"
+#include "map/mob.h"
+#include "map/npc.h"
+#include "map/npc.h"
+#include "map/party.h"
+#include "map/path.h"
+#include "map/pc.h"
+#include "map/pet.h"
+#include "map/quest.h"
+#include "map/script.h"
+#include "map/skill.h"
+#include "map/status.h"
+#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"
+#define HPM_CORE_INCLUDE "HPMHooking/HPMHooking.HPMHooksCore.inc"
+#define HPM_SYMBOL_INCLUDE "HPMHooking/HPMHooking.GetSymbol.inc"
+#define HPM_HOOKS_INCLUDE "HPMHooking/HPMHooking.Hooks.inc"
+#define HPM_POINTS_INCLUDE "HPMHooking/HPMHooking.HookingPoints.inc"
+#define HPM_SOURCES_INCLUDE "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"
+#include "common/HPMDataCheck.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
HPExport struct hplugin_info pinfo = {
"HPMHooking", // Plugin name
@@ -134,13 +134,13 @@ HPExport void server_post_final (void) {
HPM_HP_final();
}
-HPExport bool Hooked (bool *fr) {
+HPExport const char *Hooked (bool *fr) {
HPMforce_return = fr;
- DB = GET_SYMBOL("DB");
- iMalloc = GET_SYMBOL("iMalloc");
+ if (!(DB = GET_SYMBOL("DB"))) return "DB";
+ if (!(iMalloc = GET_SYMBOL("iMalloc"))) return "iMalloc";
#include HPM_SYMBOL_INCLUDE
HPM_HP_load();
- return true;
+ return NULL;
}
diff --git a/src/plugins/HPMHooking/HPMHooking_char.GetSymbol.inc b/src/plugins/HPMHooking/HPMHooking_char.GetSymbol.inc
index 6d6db24ae..af7df2980 100644
--- a/src/plugins/HPMHooking/HPMHooking_char.GetSymbol.inc
+++ b/src/plugins/HPMHooking/HPMHooking_char.GetSymbol.inc
@@ -4,19 +4,19 @@
// 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;
+if( !(chr = GET_SYMBOL("chr") ) ) return "chr";
+if( !(geoip = GET_SYMBOL("geoip") ) ) return "geoip";
+if( !(inter_auction = GET_SYMBOL("inter_auction") ) ) return "inter_auction";
+if( !(inter_elemental = GET_SYMBOL("inter_elemental") ) ) return "inter_elemental";
+if( !(inter_guild = GET_SYMBOL("inter_guild") ) ) return "inter_guild";
+if( !(inter_homunculus = GET_SYMBOL("inter_homunculus") ) ) return "inter_homunculus";
+if( !(inter = GET_SYMBOL("inter") ) ) return "inter";
+if( !(inter_mail = GET_SYMBOL("inter_mail") ) ) return "inter_mail";
+if( !(inter_mercenary = GET_SYMBOL("inter_mercenary") ) ) return "inter_mercenary";
+if( !(inter_party = GET_SYMBOL("inter_party") ) ) return "inter_party";
+if( !(inter_pet = GET_SYMBOL("inter_pet") ) ) return "inter_pet";
+if( !(inter_quest = GET_SYMBOL("inter_quest") ) ) return "inter_quest";
+if( !(inter_storage = GET_SYMBOL("inter_storage") ) ) return "inter_storage";
+if( !(loginif = GET_SYMBOL("loginif") ) ) return "loginif";
+if( !(mapif = GET_SYMBOL("mapif") ) ) return "mapif";
+if( !(pincode = GET_SYMBOL("pincode") ) ) return "pincode";
diff --git a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc
index e2838b610..09d6ce1b6 100644
--- a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc
+++ b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc
@@ -39,6 +39,8 @@ struct {
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_gender_pre;
+ struct HPMHookPoint *HP_chr_mmo_gender_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;
@@ -173,6 +175,8 @@ struct {
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_changecharsex_pre;
+ struct HPMHookPoint *HP_chr_changecharsex_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;
@@ -934,6 +938,8 @@ struct {
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_gender_pre;
+ int HP_chr_mmo_gender_post;
int HP_chr_mmo_chars_fromsql_pre;
int HP_chr_mmo_chars_fromsql_post;
int HP_chr_mmo_char_fromsql_pre;
@@ -1068,6 +1074,8 @@ struct {
int HP_chr_unban_post;
int HP_chr_ask_name_ack_pre;
int HP_chr_ask_name_ack_post;
+ int HP_chr_changecharsex_pre;
+ int HP_chr_changecharsex_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;
diff --git a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc
index aa279dbb4..631544248 100644
--- a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc
+++ b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc
@@ -23,6 +23,7 @@ struct HookingPointData HookingPoints[] = {
{ 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_gender, HP_chr_mmo_gender) },
{ 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) },
@@ -90,6 +91,7 @@ struct HookingPointData HookingPoints[] = {
{ 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->changecharsex, HP_chr_changecharsex) },
{ 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) },
diff --git a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc
index ffa2cd7e2..c6cca0b0c 100644
--- a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc
@@ -482,6 +482,33 @@ int HP_chr_inventory_to_sql(const struct item items[], int max, int id) {
}
return retVal___;
}
+int HP_chr_mmo_gender(const struct char_session_data *sd, const struct mmo_charstatus *p, char sex) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_mmo_gender_pre ) {
+ int (*preHookFunc) (const struct char_session_data *sd, const struct mmo_charstatus *p, char *sex);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_gender_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_mmo_gender_pre[hIndex].func;
+ retVal___ = preHookFunc(sd, p, &sex);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.mmo_gender(sd, p, sex);
+ }
+ if( HPMHooks.count.HP_chr_mmo_gender_post ) {
+ int (*postHookFunc) (int retVal___, const struct char_session_data *sd, const struct mmo_charstatus *p, char *sex);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_mmo_gender_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_mmo_gender_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, sd, p, &sex);
+ }
+ }
+ return retVal___;
+}
int HP_chr_mmo_chars_fromsql(struct char_session_data *sd, uint8 *buf) {
int hIndex = 0;
int retVal___ = 0;
@@ -2244,6 +2271,33 @@ void HP_chr_ask_name_ack(int fd, int acc, const char *name, int type, int result
}
return;
}
+int HP_chr_changecharsex(int char_id, int sex) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_chr_changecharsex_pre ) {
+ int (*preHookFunc) (int *char_id, int *sex);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_changecharsex_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_chr_changecharsex_pre[hIndex].func;
+ retVal___ = preHookFunc(&char_id, &sex);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.chr.changecharsex(char_id, sex);
+ }
+ if( HPMHooks.count.HP_chr_changecharsex_post ) {
+ int (*postHookFunc) (int retVal___, int *char_id, int *sex);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_chr_changecharsex_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_chr_changecharsex_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &char_id, &sex);
+ }
+ }
+ return retVal___;
+}
void HP_chr_parse_frommap_change_account(int fd) {
int hIndex = 0;
if( HPMHooks.count.HP_chr_parse_frommap_change_account_pre ) {
@@ -3653,14 +3707,14 @@ void HP_chr_login_map_server_ack(int fd, uint8 flag) {
}
return;
}
-void HP_chr_parse_char_login_map_server(int fd) {
+void HP_chr_parse_char_login_map_server(int fd, uint32 ipl) {
int hIndex = 0;
if( HPMHooks.count.HP_chr_parse_char_login_map_server_pre ) {
- void (*preHookFunc) (int *fd);
+ void (*preHookFunc) (int *fd, uint32 *ipl);
*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);
+ preHookFunc(&fd, &ipl);
}
if( *HPMforce_return ) {
*HPMforce_return = false;
@@ -3668,13 +3722,13 @@ void HP_chr_parse_char_login_map_server(int fd) {
}
}
{
- HPMHooks.source.chr.parse_char_login_map_server(fd);
+ HPMHooks.source.chr.parse_char_login_map_server(fd, ipl);
}
if( HPMHooks.count.HP_chr_parse_char_login_map_server_post ) {
- void (*postHookFunc) (int *fd);
+ void (*postHookFunc) (int *fd, uint32 *ipl);
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);
+ postHookFunc(&fd, &ipl);
}
}
return;
diff --git a/src/plugins/HPMHooking/HPMHooking_login.GetSymbol.inc b/src/plugins/HPMHooking/HPMHooking_login.GetSymbol.inc
index 3348b5cde..fd9eeba8c 100644
--- a/src/plugins/HPMHooking/HPMHooking_login.GetSymbol.inc
+++ b/src/plugins/HPMHooking/HPMHooking_login.GetSymbol.inc
@@ -4,4 +4,4 @@
// NOTE: This file was auto-generated and should never be manually edited,
// as it will get overwritten.
-if( !(login = GET_SYMBOL("login") ) ) return false;
+if( !(login = GET_SYMBOL("login") ) ) return "login";
diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc
index 1ebd9fd1a..375b78e11 100644
--- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc
@@ -1418,14 +1418,14 @@ void HP_login_char_server_connection_status(int fd, struct login_session_data *s
}
return;
}
-void HP_login_parse_request_connection(int fd, struct login_session_data *sd, const char *ip) {
+void HP_login_parse_request_connection(int fd, struct login_session_data *sd, const char *ip, uint32 ipl) {
int hIndex = 0;
if( HPMHooks.count.HP_login_parse_request_connection_pre ) {
- void (*preHookFunc) (int *fd, struct login_session_data *sd, const char *ip);
+ void (*preHookFunc) (int *fd, struct login_session_data *sd, const char *ip, uint32 *ipl);
*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);
+ preHookFunc(&fd, sd, ip, &ipl);
}
if( *HPMforce_return ) {
*HPMforce_return = false;
@@ -1433,13 +1433,13 @@ void HP_login_parse_request_connection(int fd, struct login_session_data *sd, co
}
}
{
- HPMHooks.source.login.parse_request_connection(fd, sd, ip);
+ HPMHooks.source.login.parse_request_connection(fd, sd, ip, ipl);
}
if( HPMHooks.count.HP_login_parse_request_connection_post ) {
- void (*postHookFunc) (int *fd, struct login_session_data *sd, const char *ip);
+ void (*postHookFunc) (int *fd, struct login_session_data *sd, const char *ip, uint32 *ipl);
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);
+ postHookFunc(&fd, sd, ip, &ipl);
}
}
return;
diff --git a/src/plugins/HPMHooking/HPMHooking_map.GetSymbol.inc b/src/plugins/HPMHooking/HPMHooking_map.GetSymbol.inc
index 6b1b84c69..88fe7745a 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.GetSymbol.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.GetSymbol.inc
@@ -4,42 +4,42 @@
// NOTE: This file was auto-generated and should never be manually edited,
// as it will get overwritten.
-if( !(atcommand = GET_SYMBOL("atcommand") ) ) return false;
-if( !(battle = GET_SYMBOL("battle") ) ) return false;
-if( !(bg = GET_SYMBOL("battlegrounds") ) ) return false;
-if( !(buyingstore = GET_SYMBOL("buyingstore") ) ) return false;
-if( !(channel = GET_SYMBOL("channel") ) ) return false;
-if( !(chat = GET_SYMBOL("chat") ) ) return false;
-if( !(chrif = GET_SYMBOL("chrif") ) ) return false;
-if( !(clif = GET_SYMBOL("clif") ) ) return false;
-if( !(duel = GET_SYMBOL("duel") ) ) return false;
-if( !(elemental = GET_SYMBOL("elemental") ) ) return false;
-if( !(guild = GET_SYMBOL("guild") ) ) return false;
-if( !(gstorage = GET_SYMBOL("gstorage") ) ) return false;
-if( !(homun = GET_SYMBOL("homun") ) ) return false;
-if( !(instance = GET_SYMBOL("instance") ) ) return false;
-if( !(intif = GET_SYMBOL("intif") ) ) return false;
-if( !(ircbot = GET_SYMBOL("ircbot") ) ) return false;
-if( !(itemdb = GET_SYMBOL("itemdb") ) ) return false;
-if( !(logs = GET_SYMBOL("logs") ) ) return false;
-if( !(mail = GET_SYMBOL("mail") ) ) return false;
-if( !(map = GET_SYMBOL("map") ) ) return false;
-if( !(mapit = GET_SYMBOL("mapit") ) ) return false;
-if( !(mapreg = GET_SYMBOL("mapreg") ) ) return false;
-if( !(mercenary = GET_SYMBOL("mercenary") ) ) return false;
-if( !(mob = GET_SYMBOL("mob") ) ) return false;
-if( !(npc = GET_SYMBOL("npc") ) ) return false;
-if( !(party = GET_SYMBOL("party") ) ) return false;
-if( !(path = GET_SYMBOL("path") ) ) return false;
-if( !(pcg = GET_SYMBOL("pc_groups") ) ) return false;
-if( !(pc = GET_SYMBOL("pc") ) ) return false;
-if( !(pet = GET_SYMBOL("pet") ) ) return false;
-if( !(quest = GET_SYMBOL("quest") ) ) return false;
-if( !(script = GET_SYMBOL("script") ) ) return false;
-if( !(searchstore = GET_SYMBOL("searchstore") ) ) return false;
-if( !(skill = GET_SYMBOL("skill") ) ) return false;
-if( !(status = GET_SYMBOL("status") ) ) return false;
-if( !(storage = GET_SYMBOL("storage") ) ) return false;
-if( !(trade = GET_SYMBOL("trade") ) ) return false;
-if( !(unit = GET_SYMBOL("unit") ) ) return false;
-if( !(vending = GET_SYMBOL("vending") ) ) return false;
+if( !(atcommand = GET_SYMBOL("atcommand") ) ) return "atcommand";
+if( !(battle = GET_SYMBOL("battle") ) ) return "battle";
+if( !(bg = GET_SYMBOL("battlegrounds") ) ) return "battlegrounds";
+if( !(buyingstore = GET_SYMBOL("buyingstore") ) ) return "buyingstore";
+if( !(channel = GET_SYMBOL("channel") ) ) return "channel";
+if( !(chat = GET_SYMBOL("chat") ) ) return "chat";
+if( !(chrif = GET_SYMBOL("chrif") ) ) return "chrif";
+if( !(clif = GET_SYMBOL("clif") ) ) return "clif";
+if( !(duel = GET_SYMBOL("duel") ) ) return "duel";
+if( !(elemental = GET_SYMBOL("elemental") ) ) return "elemental";
+if( !(guild = GET_SYMBOL("guild") ) ) return "guild";
+if( !(gstorage = GET_SYMBOL("gstorage") ) ) return "gstorage";
+if( !(homun = GET_SYMBOL("homun") ) ) return "homun";
+if( !(instance = GET_SYMBOL("instance") ) ) return "instance";
+if( !(intif = GET_SYMBOL("intif") ) ) return "intif";
+if( !(ircbot = GET_SYMBOL("ircbot") ) ) return "ircbot";
+if( !(itemdb = GET_SYMBOL("itemdb") ) ) return "itemdb";
+if( !(logs = GET_SYMBOL("logs") ) ) return "logs";
+if( !(mail = GET_SYMBOL("mail") ) ) return "mail";
+if( !(map = GET_SYMBOL("map") ) ) return "map";
+if( !(mapit = GET_SYMBOL("mapit") ) ) return "mapit";
+if( !(mapreg = GET_SYMBOL("mapreg") ) ) return "mapreg";
+if( !(mercenary = GET_SYMBOL("mercenary") ) ) return "mercenary";
+if( !(mob = GET_SYMBOL("mob") ) ) return "mob";
+if( !(npc = GET_SYMBOL("npc") ) ) return "npc";
+if( !(party = GET_SYMBOL("party") ) ) return "party";
+if( !(path = GET_SYMBOL("path") ) ) return "path";
+if( !(pcg = GET_SYMBOL("pc_groups") ) ) return "pc_groups";
+if( !(pc = GET_SYMBOL("pc") ) ) return "pc";
+if( !(pet = GET_SYMBOL("pet") ) ) return "pet";
+if( !(quest = GET_SYMBOL("quest") ) ) return "quest";
+if( !(script = GET_SYMBOL("script") ) ) return "script";
+if( !(searchstore = GET_SYMBOL("searchstore") ) ) return "searchstore";
+if( !(skill = GET_SYMBOL("skill") ) ) return "skill";
+if( !(status = GET_SYMBOL("status") ) ) return "status";
+if( !(storage = GET_SYMBOL("storage") ) ) return "storage";
+if( !(trade = GET_SYMBOL("trade") ) ) return "trade";
+if( !(unit = GET_SYMBOL("unit") ) ) return "unit";
+if( !(vending = GET_SYMBOL("vending") ) ) return "vending";
diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
index d92f2079f..f3e3711c1 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
@@ -99,6 +99,8 @@ struct {
struct HPMHookPoint *HP_battle_attr_fix_post;
struct HPMHookPoint *HP_battle_calc_cardfix_pre;
struct HPMHookPoint *HP_battle_calc_cardfix_post;
+ struct HPMHookPoint *HP_battle_calc_cardfix2_pre;
+ struct HPMHookPoint *HP_battle_calc_cardfix2_post;
struct HPMHookPoint *HP_battle_calc_elefix_pre;
struct HPMHookPoint *HP_battle_calc_elefix_post;
struct HPMHookPoint *HP_battle_calc_masteryfix_pre;
@@ -235,6 +237,8 @@ struct {
struct HPMHookPoint *HP_bg_send_xy_timer_post;
struct HPMHookPoint *HP_bg_afk_timer_pre;
struct HPMHookPoint *HP_bg_afk_timer_post;
+ struct HPMHookPoint *HP_bg_team_db_final_pre;
+ struct HPMHookPoint *HP_bg_team_db_final_post;
struct HPMHookPoint *HP_bg_str2teamtype_pre;
struct HPMHookPoint *HP_bg_str2teamtype_post;
struct HPMHookPoint *HP_bg_config_read_pre;
@@ -293,6 +297,8 @@ struct {
struct HPMHookPoint *HP_channel_guild_leave_alliance_post;
struct HPMHookPoint *HP_channel_quit_guild_pre;
struct HPMHookPoint *HP_channel_quit_guild_post;
+ struct HPMHookPoint *HP_channel_irc_join_pre;
+ struct HPMHookPoint *HP_channel_irc_join_post;
struct HPMHookPoint *HP_channel_config_read_pre;
struct HPMHookPoint *HP_channel_config_read_post;
struct HPMHookPoint *HP_chat_create_pc_chat_pre;
@@ -927,26 +933,22 @@ struct {
struct HPMHookPoint *HP_clif_broadcast_post;
struct HPMHookPoint *HP_clif_broadcast2_pre;
struct HPMHookPoint *HP_clif_broadcast2_post;
+ struct HPMHookPoint *HP_clif_messagecolor_self_pre;
+ struct HPMHookPoint *HP_clif_messagecolor_self_post;
struct HPMHookPoint *HP_clif_messagecolor_pre;
struct HPMHookPoint *HP_clif_messagecolor_post;
struct HPMHookPoint *HP_clif_disp_overhead_pre;
struct HPMHookPoint *HP_clif_disp_overhead_post;
- struct HPMHookPoint *HP_clif_msg_pre;
- struct HPMHookPoint *HP_clif_msg_post;
- struct HPMHookPoint *HP_clif_msg_value_pre;
- struct HPMHookPoint *HP_clif_msg_value_post;
- struct HPMHookPoint *HP_clif_msg_skill_pre;
- struct HPMHookPoint *HP_clif_msg_skill_post;
struct HPMHookPoint *HP_clif_msgtable_pre;
struct HPMHookPoint *HP_clif_msgtable_post;
struct HPMHookPoint *HP_clif_msgtable_num_pre;
struct HPMHookPoint *HP_clif_msgtable_num_post;
+ struct HPMHookPoint *HP_clif_msgtable_skill_pre;
+ struct HPMHookPoint *HP_clif_msgtable_skill_post;
struct HPMHookPoint *HP_clif_message_pre;
struct HPMHookPoint *HP_clif_message_post;
struct HPMHookPoint *HP_clif_messageln_pre;
struct HPMHookPoint *HP_clif_messageln_post;
- struct HPMHookPoint *HP_clif_colormes_pre;
- struct HPMHookPoint *HP_clif_colormes_post;
struct HPMHookPoint *HP_clif_process_message_pre;
struct HPMHookPoint *HP_clif_process_message_post;
struct HPMHookPoint *HP_clif_wisexin_pre;
@@ -1343,6 +1345,14 @@ struct {
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_openmergeitem_pre;
+ struct HPMHookPoint *HP_clif_openmergeitem_post;
+ struct HPMHookPoint *HP_clif_cancelmergeitem_pre;
+ struct HPMHookPoint *HP_clif_cancelmergeitem_post;
+ struct HPMHookPoint *HP_clif_comparemergeitem_pre;
+ struct HPMHookPoint *HP_clif_comparemergeitem_post;
+ struct HPMHookPoint *HP_clif_ackmergeitems_pre;
+ struct HPMHookPoint *HP_clif_ackmergeitems_post;
struct HPMHookPoint *HP_clif_pWantToConnection_pre;
struct HPMHookPoint *HP_clif_pWantToConnection_post;
struct HPMHookPoint *HP_clif_pLoadEndAck_pre;
@@ -3687,6 +3697,10 @@ struct {
struct HPMHookPoint *HP_pc_skill_post;
struct HPMHookPoint *HP_pc_insert_card_pre;
struct HPMHookPoint *HP_pc_insert_card_post;
+ struct HPMHookPoint *HP_pc_can_insert_card_pre;
+ struct HPMHookPoint *HP_pc_can_insert_card_post;
+ struct HPMHookPoint *HP_pc_can_insert_card_into_pre;
+ struct HPMHookPoint *HP_pc_can_insert_card_into_post;
struct HPMHookPoint *HP_pc_steal_item_pre;
struct HPMHookPoint *HP_pc_steal_item_post;
struct HPMHookPoint *HP_pc_steal_coin_pre;
@@ -3859,6 +3873,8 @@ struct {
struct HPMHookPoint *HP_pc_addspiritball_post;
struct HPMHookPoint *HP_pc_delspiritball_pre;
struct HPMHookPoint *HP_pc_delspiritball_post;
+ struct HPMHookPoint *HP_pc_getmaxspiritball_pre;
+ struct HPMHookPoint *HP_pc_getmaxspiritball_post;
struct HPMHookPoint *HP_pc_addfame_pre;
struct HPMHookPoint *HP_pc_addfame_post;
struct HPMHookPoint *HP_pc_famerank_pre;
@@ -3983,6 +3999,8 @@ struct {
struct HPMHookPoint *HP_pc_autotrade_prepare_post;
struct HPMHookPoint *HP_pc_autotrade_populate_pre;
struct HPMHookPoint *HP_pc_autotrade_populate_post;
+ struct HPMHookPoint *HP_pc_check_job_name_pre;
+ struct HPMHookPoint *HP_pc_check_job_name_post;
struct HPMHookPoint *HP_pet_init_pre;
struct HPMHookPoint *HP_pet_init_post;
struct HPMHookPoint *HP_pet_final_pre;
@@ -4973,12 +4991,10 @@ struct {
struct HPMHookPoint *HP_status_base_amotion_pc_post;
struct HPMHookPoint *HP_status_base_atk_pre;
struct HPMHookPoint *HP_status_base_atk_post;
- struct HPMHookPoint *HP_status_calc_sigma_pre;
- struct HPMHookPoint *HP_status_calc_sigma_post;
- struct HPMHookPoint *HP_status_base_pc_maxhp_pre;
- struct HPMHookPoint *HP_status_base_pc_maxhp_post;
- struct HPMHookPoint *HP_status_base_pc_maxsp_pre;
- struct HPMHookPoint *HP_status_base_pc_maxsp_post;
+ struct HPMHookPoint *HP_status_get_base_maxhp_pre;
+ struct HPMHookPoint *HP_status_get_base_maxhp_post;
+ struct HPMHookPoint *HP_status_get_base_maxsp_pre;
+ struct HPMHookPoint *HP_status_get_base_maxsp_post;
struct HPMHookPoint *HP_status_calc_npc__pre;
struct HPMHookPoint *HP_status_calc_npc__post;
struct HPMHookPoint *HP_status_calc_str_pre;
@@ -5037,8 +5053,6 @@ struct {
struct HPMHookPoint *HP_status_natural_heal_post;
struct HPMHookPoint *HP_status_natural_heal_timer_pre;
struct HPMHookPoint *HP_status_natural_heal_timer_post;
- struct HPMHookPoint *HP_status_readdb_job1_pre;
- struct HPMHookPoint *HP_status_readdb_job1_post;
struct HPMHookPoint *HP_status_readdb_job2_pre;
struct HPMHookPoint *HP_status_readdb_job2_post;
struct HPMHookPoint *HP_status_readdb_sizefix_pre;
@@ -5047,6 +5061,10 @@ struct {
struct HPMHookPoint *HP_status_readdb_refine_post;
struct HPMHookPoint *HP_status_readdb_scconfig_pre;
struct HPMHookPoint *HP_status_readdb_scconfig_post;
+ struct HPMHookPoint *HP_status_read_job_db_pre;
+ struct HPMHookPoint *HP_status_read_job_db_post;
+ struct HPMHookPoint *HP_status_read_job_db_sub_pre;
+ struct HPMHookPoint *HP_status_read_job_db_sub_post;
struct HPMHookPoint *HP_storage_reconnect_pre;
struct HPMHookPoint *HP_storage_reconnect_post;
struct HPMHookPoint *HP_storage_delitem_pre;
@@ -5300,6 +5318,8 @@ struct {
int HP_battle_attr_fix_post;
int HP_battle_calc_cardfix_pre;
int HP_battle_calc_cardfix_post;
+ int HP_battle_calc_cardfix2_pre;
+ int HP_battle_calc_cardfix2_post;
int HP_battle_calc_elefix_pre;
int HP_battle_calc_elefix_post;
int HP_battle_calc_masteryfix_pre;
@@ -5436,6 +5456,8 @@ struct {
int HP_bg_send_xy_timer_post;
int HP_bg_afk_timer_pre;
int HP_bg_afk_timer_post;
+ int HP_bg_team_db_final_pre;
+ int HP_bg_team_db_final_post;
int HP_bg_str2teamtype_pre;
int HP_bg_str2teamtype_post;
int HP_bg_config_read_pre;
@@ -5494,6 +5516,8 @@ struct {
int HP_channel_guild_leave_alliance_post;
int HP_channel_quit_guild_pre;
int HP_channel_quit_guild_post;
+ int HP_channel_irc_join_pre;
+ int HP_channel_irc_join_post;
int HP_channel_config_read_pre;
int HP_channel_config_read_post;
int HP_chat_create_pc_chat_pre;
@@ -6128,26 +6152,22 @@ struct {
int HP_clif_broadcast_post;
int HP_clif_broadcast2_pre;
int HP_clif_broadcast2_post;
+ int HP_clif_messagecolor_self_pre;
+ int HP_clif_messagecolor_self_post;
int HP_clif_messagecolor_pre;
int HP_clif_messagecolor_post;
int HP_clif_disp_overhead_pre;
int HP_clif_disp_overhead_post;
- int HP_clif_msg_pre;
- int HP_clif_msg_post;
- int HP_clif_msg_value_pre;
- int HP_clif_msg_value_post;
- int HP_clif_msg_skill_pre;
- int HP_clif_msg_skill_post;
int HP_clif_msgtable_pre;
int HP_clif_msgtable_post;
int HP_clif_msgtable_num_pre;
int HP_clif_msgtable_num_post;
+ int HP_clif_msgtable_skill_pre;
+ int HP_clif_msgtable_skill_post;
int HP_clif_message_pre;
int HP_clif_message_post;
int HP_clif_messageln_pre;
int HP_clif_messageln_post;
- int HP_clif_colormes_pre;
- int HP_clif_colormes_post;
int HP_clif_process_message_pre;
int HP_clif_process_message_post;
int HP_clif_wisexin_pre;
@@ -6544,6 +6564,14 @@ struct {
int HP_clif_parse_roulette_db_post;
int HP_clif_roulette_generate_ack_pre;
int HP_clif_roulette_generate_ack_post;
+ int HP_clif_openmergeitem_pre;
+ int HP_clif_openmergeitem_post;
+ int HP_clif_cancelmergeitem_pre;
+ int HP_clif_cancelmergeitem_post;
+ int HP_clif_comparemergeitem_pre;
+ int HP_clif_comparemergeitem_post;
+ int HP_clif_ackmergeitems_pre;
+ int HP_clif_ackmergeitems_post;
int HP_clif_pWantToConnection_pre;
int HP_clif_pWantToConnection_post;
int HP_clif_pLoadEndAck_pre;
@@ -8888,6 +8916,10 @@ struct {
int HP_pc_skill_post;
int HP_pc_insert_card_pre;
int HP_pc_insert_card_post;
+ int HP_pc_can_insert_card_pre;
+ int HP_pc_can_insert_card_post;
+ int HP_pc_can_insert_card_into_pre;
+ int HP_pc_can_insert_card_into_post;
int HP_pc_steal_item_pre;
int HP_pc_steal_item_post;
int HP_pc_steal_coin_pre;
@@ -9060,6 +9092,8 @@ struct {
int HP_pc_addspiritball_post;
int HP_pc_delspiritball_pre;
int HP_pc_delspiritball_post;
+ int HP_pc_getmaxspiritball_pre;
+ int HP_pc_getmaxspiritball_post;
int HP_pc_addfame_pre;
int HP_pc_addfame_post;
int HP_pc_famerank_pre;
@@ -9184,6 +9218,8 @@ struct {
int HP_pc_autotrade_prepare_post;
int HP_pc_autotrade_populate_pre;
int HP_pc_autotrade_populate_post;
+ int HP_pc_check_job_name_pre;
+ int HP_pc_check_job_name_post;
int HP_pet_init_pre;
int HP_pet_init_post;
int HP_pet_final_pre;
@@ -10174,12 +10210,10 @@ struct {
int HP_status_base_amotion_pc_post;
int HP_status_base_atk_pre;
int HP_status_base_atk_post;
- int HP_status_calc_sigma_pre;
- int HP_status_calc_sigma_post;
- int HP_status_base_pc_maxhp_pre;
- int HP_status_base_pc_maxhp_post;
- int HP_status_base_pc_maxsp_pre;
- int HP_status_base_pc_maxsp_post;
+ int HP_status_get_base_maxhp_pre;
+ int HP_status_get_base_maxhp_post;
+ int HP_status_get_base_maxsp_pre;
+ int HP_status_get_base_maxsp_post;
int HP_status_calc_npc__pre;
int HP_status_calc_npc__post;
int HP_status_calc_str_pre;
@@ -10238,8 +10272,6 @@ struct {
int HP_status_natural_heal_post;
int HP_status_natural_heal_timer_pre;
int HP_status_natural_heal_timer_post;
- int HP_status_readdb_job1_pre;
- int HP_status_readdb_job1_post;
int HP_status_readdb_job2_pre;
int HP_status_readdb_job2_post;
int HP_status_readdb_sizefix_pre;
@@ -10248,6 +10280,10 @@ struct {
int HP_status_readdb_refine_post;
int HP_status_readdb_scconfig_pre;
int HP_status_readdb_scconfig_post;
+ int HP_status_read_job_db_pre;
+ int HP_status_read_job_db_post;
+ int HP_status_read_job_db_sub_pre;
+ int HP_status_read_job_db_sub_post;
int HP_storage_reconnect_pre;
int HP_storage_reconnect_post;
int HP_storage_delitem_pre;
diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
index a3e4340be..4e23425ec 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
@@ -54,6 +54,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(battle->attr_ratio, HP_battle_attr_ratio) },
{ HP_POP(battle->attr_fix, HP_battle_attr_fix) },
{ HP_POP(battle->calc_cardfix, HP_battle_calc_cardfix) },
+ { HP_POP(battle->calc_cardfix2, HP_battle_calc_cardfix2) },
{ HP_POP(battle->calc_elefix, HP_battle_calc_elefix) },
{ HP_POP(battle->calc_masteryfix, HP_battle_calc_masteryfix) },
{ HP_POP(battle->calc_chorusbonus, HP_battle_calc_chorusbonus) },
@@ -123,6 +124,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(bg->send_xy_timer_sub, HP_bg_send_xy_timer_sub) },
{ HP_POP(bg->send_xy_timer, HP_bg_send_xy_timer) },
{ HP_POP(bg->afk_timer, HP_bg_afk_timer) },
+ { HP_POP(bg->team_db_final, HP_bg_team_db_final) },
{ HP_POP(bg->str2teamtype, HP_bg_str2teamtype) },
{ HP_POP(bg->config_read, HP_bg_config_read) },
/* buyingstore */
@@ -154,6 +156,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(channel->guild_join_alliance, HP_channel_guild_join_alliance) },
{ HP_POP(channel->guild_leave_alliance, HP_channel_guild_leave_alliance) },
{ HP_POP(channel->quit_guild, HP_channel_quit_guild) },
+ { HP_POP(channel->irc_join, HP_channel_irc_join) },
{ HP_POP(channel->config_read, HP_channel_config_read) },
/* chat */
{ HP_POP(chat->create_pc_chat, HP_chat_create_pc_chat) },
@@ -474,16 +477,14 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(clif->disp_message, HP_clif_disp_message) },
{ HP_POP(clif->broadcast, HP_clif_broadcast) },
{ HP_POP(clif->broadcast2, HP_clif_broadcast2) },
+ { HP_POP(clif->messagecolor_self, HP_clif_messagecolor_self) },
{ HP_POP(clif->messagecolor, HP_clif_messagecolor) },
{ HP_POP(clif->disp_overhead, HP_clif_disp_overhead) },
- { HP_POP(clif->msg, HP_clif_msg) },
- { HP_POP(clif->msg_value, HP_clif_msg_value) },
- { HP_POP(clif->msg_skill, HP_clif_msg_skill) },
{ HP_POP(clif->msgtable, HP_clif_msgtable) },
{ HP_POP(clif->msgtable_num, HP_clif_msgtable_num) },
+ { HP_POP(clif->msgtable_skill, HP_clif_msgtable_skill) },
{ HP_POP(clif->message, HP_clif_message) },
{ HP_POP(clif->messageln, HP_clif_messageln) },
- { HP_POP(clif->colormes, HP_clif_colormes) },
{ HP_POP(clif->process_message, HP_clif_process_message) },
{ HP_POP(clif->wisexin, HP_clif_wisexin) },
{ HP_POP(clif->wisall, HP_clif_wisall) },
@@ -682,6 +683,10 @@ struct HookingPointData HookingPoints[] = {
{ 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->openmergeitem, HP_clif_openmergeitem) },
+ { HP_POP(clif->cancelmergeitem, HP_clif_cancelmergeitem) },
+ { HP_POP(clif->comparemergeitem, HP_clif_comparemergeitem) },
+ { HP_POP(clif->ackmergeitems, HP_clif_ackmergeitems) },
{ HP_POP(clif->pWantToConnection, HP_clif_pWantToConnection) },
{ HP_POP(clif->pLoadEndAck, HP_clif_pLoadEndAck) },
{ HP_POP(clif->pTickSend, HP_clif_pTickSend) },
@@ -1875,6 +1880,8 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(pc->bonus5, HP_pc_bonus5) },
{ HP_POP(pc->skill, HP_pc_skill) },
{ HP_POP(pc->insert_card, HP_pc_insert_card) },
+ { HP_POP(pc->can_insert_card, HP_pc_can_insert_card) },
+ { HP_POP(pc->can_insert_card_into, HP_pc_can_insert_card_into) },
{ HP_POP(pc->steal_item, HP_pc_steal_item) },
{ HP_POP(pc->steal_coin, HP_pc_steal_coin) },
{ HP_POP(pc->modifybuyvalue, HP_pc_modifybuyvalue) },
@@ -1961,6 +1968,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(pc->delinvincibletimer, HP_pc_delinvincibletimer) },
{ HP_POP(pc->addspiritball, HP_pc_addspiritball) },
{ HP_POP(pc->delspiritball, HP_pc_delspiritball) },
+ { HP_POP(pc->getmaxspiritball, HP_pc_getmaxspiritball) },
{ HP_POP(pc->addfame, HP_pc_addfame) },
{ HP_POP(pc->famerank, HP_pc_famerank) },
{ HP_POP(pc->set_hate_mob, HP_pc_set_hate_mob) },
@@ -2023,6 +2031,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(pc->autotrade_start, HP_pc_autotrade_start) },
{ HP_POP(pc->autotrade_prepare, HP_pc_autotrade_prepare) },
{ HP_POP(pc->autotrade_populate, HP_pc_autotrade_populate) },
+ { HP_POP(pc->check_job_name, HP_pc_check_job_name) },
/* pet */
{ HP_POP(pet->init, HP_pet_init) },
{ HP_POP(pet->final, HP_pet_final) },
@@ -2524,9 +2533,8 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(status->initDummyData, HP_status_initDummyData) },
{ HP_POP(status->base_amotion_pc, HP_status_base_amotion_pc) },
{ HP_POP(status->base_atk, HP_status_base_atk) },
- { HP_POP(status->calc_sigma, HP_status_calc_sigma) },
- { HP_POP(status->base_pc_maxhp, HP_status_base_pc_maxhp) },
- { HP_POP(status->base_pc_maxsp, HP_status_base_pc_maxsp) },
+ { HP_POP(status->get_base_maxhp, HP_status_get_base_maxhp) },
+ { HP_POP(status->get_base_maxsp, HP_status_get_base_maxsp) },
{ HP_POP(status->calc_npc_, HP_status_calc_npc_) },
{ HP_POP(status->calc_str, HP_status_calc_str) },
{ HP_POP(status->calc_agi, HP_status_calc_agi) },
@@ -2556,11 +2564,12 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(status->display_remove, HP_status_display_remove) },
{ HP_POP(status->natural_heal, HP_status_natural_heal) },
{ HP_POP(status->natural_heal_timer, HP_status_natural_heal_timer) },
- { HP_POP(status->readdb_job1, HP_status_readdb_job1) },
{ HP_POP(status->readdb_job2, HP_status_readdb_job2) },
{ HP_POP(status->readdb_sizefix, HP_status_readdb_sizefix) },
{ HP_POP(status->readdb_refine, HP_status_readdb_refine) },
{ HP_POP(status->readdb_scconfig, HP_status_readdb_scconfig) },
+ { HP_POP(status->read_job_db, HP_status_read_job_db) },
+ { HP_POP(status->read_job_db_sub, HP_status_read_job_db_sub) },
/* storage */
{ HP_POP(storage->reconnect, HP_storage_reconnect) },
{ HP_POP(storage->delitem, HP_storage_delitem) },
diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
index c36525c21..85f477bec 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
@@ -1302,6 +1302,33 @@ int64 HP_battle_calc_cardfix(int attack_type, struct block_list *src, struct blo
}
return retVal___;
}
+int64 HP_battle_calc_cardfix2(struct block_list *src, struct block_list *bl, int64 damage, int s_ele, int nk, int flag) {
+ int hIndex = 0;
+ int64 retVal___ = 0;
+ if( HPMHooks.count.HP_battle_calc_cardfix2_pre ) {
+ int64 (*preHookFunc) (struct block_list *src, struct block_list *bl, int64 *damage, int *s_ele, int *nk, int *flag);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_battle_calc_cardfix2_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_battle_calc_cardfix2_pre[hIndex].func;
+ retVal___ = preHookFunc(src, bl, &damage, &s_ele, &nk, &flag);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.battle.calc_cardfix2(src, bl, damage, s_ele, nk, flag);
+ }
+ if( HPMHooks.count.HP_battle_calc_cardfix2_post ) {
+ int64 (*postHookFunc) (int64 retVal___, struct block_list *src, struct block_list *bl, int64 *damage, int *s_ele, int *nk, int *flag);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_battle_calc_cardfix2_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_battle_calc_cardfix2_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, src, bl, &damage, &s_ele, &nk, &flag);
+ }
+ }
+ return retVal___;
+}
int64 HP_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) {
int hIndex = 0;
int64 retVal___ = 0;
@@ -3154,6 +3181,39 @@ int HP_bg_afk_timer(int tid, int64 tick, int id, intptr_t data) {
}
return retVal___;
}
+int HP_bg_team_db_final(DBKey key, DBData *data, va_list ap) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_bg_team_db_final_pre ) {
+ int (*preHookFunc) (DBKey *key, DBData *data, va_list ap);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_bg_team_db_final_pre; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ preHookFunc = HPMHooks.list.HP_bg_team_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.bg.team_db_final(key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ if( HPMHooks.count.HP_bg_team_db_final_post ) {
+ int (*postHookFunc) (int retVal___, DBKey *key, DBData *data, va_list ap);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_bg_team_db_final_post; hIndex++ ) {
+ va_list ap___copy; va_copy(ap___copy, ap);
+ postHookFunc = HPMHooks.list.HP_bg_team_db_final_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &key, data, ap___copy);
+ va_end(ap___copy);
+ }
+ }
+ return retVal___;
+}
enum bg_queue_types HP_bg_str2teamtype(const char *str) {
int hIndex = 0;
enum bg_queue_types retVal___ = BGQT_INVALID;
@@ -3921,6 +3981,32 @@ void HP_channel_quit_guild(struct map_session_data *sd) {
}
return;
}
+void HP_channel_irc_join(struct map_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_channel_irc_join_pre ) {
+ void (*preHookFunc) (struct map_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_channel_irc_join_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_channel_irc_join_pre[hIndex].func;
+ preHookFunc(sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.channel.irc_join(sd);
+ }
+ if( HPMHooks.count.HP_channel_irc_join_post ) {
+ void (*postHookFunc) (struct map_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_channel_irc_join_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_channel_irc_join_post[hIndex].func;
+ postHookFunc(sd);
+ }
+ }
+ return;
+}
void HP_channel_config_read(void) {
int hIndex = 0;
if( HPMHooks.count.HP_channel_config_read_pre ) {
@@ -5101,15 +5187,15 @@ bool HP_chrif_char_online(struct map_session_data *sd) {
}
return retVal___;
}
-bool HP_chrif_changesex(struct map_session_data *sd) {
+bool HP_chrif_changesex(struct map_session_data *sd, bool change_account) {
int hIndex = 0;
bool retVal___ = false;
if( HPMHooks.count.HP_chrif_changesex_pre ) {
- bool (*preHookFunc) (struct map_session_data *sd);
+ bool (*preHookFunc) (struct map_session_data *sd, bool *change_account);
*HPMforce_return = false;
for(hIndex = 0; hIndex < HPMHooks.count.HP_chrif_changesex_pre; hIndex++ ) {
preHookFunc = HPMHooks.list.HP_chrif_changesex_pre[hIndex].func;
- retVal___ = preHookFunc(sd);
+ retVal___ = preHookFunc(sd, &change_account);
}
if( *HPMforce_return ) {
*HPMforce_return = false;
@@ -5117,13 +5203,13 @@ bool HP_chrif_changesex(struct map_session_data *sd) {
}
}
{
- retVal___ = HPMHooks.source.chrif.changesex(sd);
+ retVal___ = HPMHooks.source.chrif.changesex(sd, change_account);
}
if( HPMHooks.count.HP_chrif_changesex_post ) {
- bool (*postHookFunc) (bool retVal___, struct map_session_data *sd);
+ bool (*postHookFunc) (bool retVal___, struct map_session_data *sd, bool *change_account);
for(hIndex = 0; hIndex < HPMHooks.count.HP_chrif_changesex_post; hIndex++ ) {
postHookFunc = HPMHooks.list.HP_chrif_changesex_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, sd);
+ retVal___ = postHookFunc(retVal___, sd, &change_account);
}
}
return retVal___;
@@ -12295,10 +12381,36 @@ void HP_clif_broadcast2(struct block_list *bl, const char *mes, size_t len, unsi
}
return;
}
-void HP_clif_messagecolor(struct block_list *bl, unsigned int color, const char *msg) {
+void HP_clif_messagecolor_self(int fd, uint32 color, const char *msg) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_clif_messagecolor_self_pre ) {
+ void (*preHookFunc) (int *fd, uint32 *color, const char *msg);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_messagecolor_self_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_messagecolor_self_pre[hIndex].func;
+ preHookFunc(&fd, &color, msg);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.clif.messagecolor_self(fd, color, msg);
+ }
+ if( HPMHooks.count.HP_clif_messagecolor_self_post ) {
+ void (*postHookFunc) (int *fd, uint32 *color, const char *msg);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_messagecolor_self_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_messagecolor_self_post[hIndex].func;
+ postHookFunc(&fd, &color, msg);
+ }
+ }
+ return;
+}
+void HP_clif_messagecolor(struct block_list *bl, uint32 color, const char *msg) {
int hIndex = 0;
if( HPMHooks.count.HP_clif_messagecolor_pre ) {
- void (*preHookFunc) (struct block_list *bl, unsigned int *color, const char *msg);
+ void (*preHookFunc) (struct block_list *bl, uint32 *color, const char *msg);
*HPMforce_return = false;
for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_messagecolor_pre; hIndex++ ) {
preHookFunc = HPMHooks.list.HP_clif_messagecolor_pre[hIndex].func;
@@ -12313,7 +12425,7 @@ void HP_clif_messagecolor(struct block_list *bl, unsigned int color, const char
HPMHooks.source.clif.messagecolor(bl, color, msg);
}
if( HPMHooks.count.HP_clif_messagecolor_post ) {
- void (*postHookFunc) (struct block_list *bl, unsigned int *color, const char *msg);
+ void (*postHookFunc) (struct block_list *bl, uint32 *color, const char *msg);
for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_messagecolor_post; hIndex++ ) {
postHookFunc = HPMHooks.list.HP_clif_messagecolor_post[hIndex].func;
postHookFunc(bl, &color, msg);
@@ -12347,14 +12459,14 @@ void HP_clif_disp_overhead(struct block_list *bl, const char *mes) {
}
return;
}
-void HP_clif_msg(struct map_session_data *sd, unsigned short id) {
+void HP_clif_msgtable(struct map_session_data *sd, unsigned short msg_id) {
int hIndex = 0;
- if( HPMHooks.count.HP_clif_msg_pre ) {
- void (*preHookFunc) (struct map_session_data *sd, unsigned short *id);
+ if( HPMHooks.count.HP_clif_msgtable_pre ) {
+ void (*preHookFunc) (struct map_session_data *sd, unsigned short *msg_id);
*HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msg_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_clif_msg_pre[hIndex].func;
- preHookFunc(sd, &id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msgtable_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_msgtable_pre[hIndex].func;
+ preHookFunc(sd, &msg_id);
}
if( *HPMforce_return ) {
*HPMforce_return = false;
@@ -12362,25 +12474,25 @@ void HP_clif_msg(struct map_session_data *sd, unsigned short id) {
}
}
{
- HPMHooks.source.clif.msg(sd, id);
+ HPMHooks.source.clif.msgtable(sd, msg_id);
}
- if( HPMHooks.count.HP_clif_msg_post ) {
- void (*postHookFunc) (struct map_session_data *sd, unsigned short *id);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msg_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_clif_msg_post[hIndex].func;
- postHookFunc(sd, &id);
+ if( HPMHooks.count.HP_clif_msgtable_post ) {
+ void (*postHookFunc) (struct map_session_data *sd, unsigned short *msg_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msgtable_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_msgtable_post[hIndex].func;
+ postHookFunc(sd, &msg_id);
}
}
return;
}
-void HP_clif_msg_value(struct map_session_data *sd, unsigned short id, int value) {
+void HP_clif_msgtable_num(struct map_session_data *sd, unsigned short msg_id, int value) {
int hIndex = 0;
- if( HPMHooks.count.HP_clif_msg_value_pre ) {
- void (*preHookFunc) (struct map_session_data *sd, unsigned short *id, int *value);
+ if( HPMHooks.count.HP_clif_msgtable_num_pre ) {
+ void (*preHookFunc) (struct map_session_data *sd, unsigned short *msg_id, int *value);
*HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msg_value_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_clif_msg_value_pre[hIndex].func;
- preHookFunc(sd, &id, &value);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msgtable_num_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_msgtable_num_pre[hIndex].func;
+ preHookFunc(sd, &msg_id, &value);
}
if( *HPMforce_return ) {
*HPMforce_return = false;
@@ -12388,24 +12500,24 @@ void HP_clif_msg_value(struct map_session_data *sd, unsigned short id, int value
}
}
{
- HPMHooks.source.clif.msg_value(sd, id, value);
+ HPMHooks.source.clif.msgtable_num(sd, msg_id, value);
}
- if( HPMHooks.count.HP_clif_msg_value_post ) {
- void (*postHookFunc) (struct map_session_data *sd, unsigned short *id, int *value);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msg_value_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_clif_msg_value_post[hIndex].func;
- postHookFunc(sd, &id, &value);
+ if( HPMHooks.count.HP_clif_msgtable_num_post ) {
+ void (*postHookFunc) (struct map_session_data *sd, unsigned short *msg_id, int *value);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msgtable_num_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_msgtable_num_post[hIndex].func;
+ postHookFunc(sd, &msg_id, &value);
}
}
return;
}
-void HP_clif_msg_skill(struct map_session_data *sd, uint16 skill_id, int msg_id) {
+void HP_clif_msgtable_skill(struct map_session_data *sd, uint16 skill_id, int msg_id) {
int hIndex = 0;
- if( HPMHooks.count.HP_clif_msg_skill_pre ) {
+ if( HPMHooks.count.HP_clif_msgtable_skill_pre ) {
void (*preHookFunc) (struct map_session_data *sd, uint16 *skill_id, int *msg_id);
*HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msg_skill_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_clif_msg_skill_pre[hIndex].func;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msgtable_skill_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_msgtable_skill_pre[hIndex].func;
preHookFunc(sd, &skill_id, &msg_id);
}
if( *HPMforce_return ) {
@@ -12414,69 +12526,17 @@ void HP_clif_msg_skill(struct map_session_data *sd, uint16 skill_id, int msg_id)
}
}
{
- HPMHooks.source.clif.msg_skill(sd, skill_id, msg_id);
+ HPMHooks.source.clif.msgtable_skill(sd, skill_id, msg_id);
}
- if( HPMHooks.count.HP_clif_msg_skill_post ) {
+ if( HPMHooks.count.HP_clif_msgtable_skill_post ) {
void (*postHookFunc) (struct map_session_data *sd, uint16 *skill_id, int *msg_id);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msg_skill_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_clif_msg_skill_post[hIndex].func;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msgtable_skill_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_msgtable_skill_post[hIndex].func;
postHookFunc(sd, &skill_id, &msg_id);
}
}
return;
}
-void HP_clif_msgtable(int fd, int line) {
- int hIndex = 0;
- if( HPMHooks.count.HP_clif_msgtable_pre ) {
- void (*preHookFunc) (int *fd, int *line);
- *HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msgtable_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_clif_msgtable_pre[hIndex].func;
- preHookFunc(&fd, &line);
- }
- if( *HPMforce_return ) {
- *HPMforce_return = false;
- return;
- }
- }
- {
- HPMHooks.source.clif.msgtable(fd, line);
- }
- if( HPMHooks.count.HP_clif_msgtable_post ) {
- void (*postHookFunc) (int *fd, int *line);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msgtable_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_clif_msgtable_post[hIndex].func;
- postHookFunc(&fd, &line);
- }
- }
- return;
-}
-void HP_clif_msgtable_num(int fd, int line, int num) {
- int hIndex = 0;
- if( HPMHooks.count.HP_clif_msgtable_num_pre ) {
- void (*preHookFunc) (int *fd, int *line, int *num);
- *HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msgtable_num_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_clif_msgtable_num_pre[hIndex].func;
- preHookFunc(&fd, &line, &num);
- }
- if( *HPMforce_return ) {
- *HPMforce_return = false;
- return;
- }
- }
- {
- HPMHooks.source.clif.msgtable_num(fd, line, num);
- }
- if( HPMHooks.count.HP_clif_msgtable_num_post ) {
- void (*postHookFunc) (int *fd, int *line, int *num);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_msgtable_num_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_clif_msgtable_num_post[hIndex].func;
- postHookFunc(&fd, &line, &num);
- }
- }
- return;
-}
void HP_clif_message(const int fd, const char *mes) {
int hIndex = 0;
if( HPMHooks.count.HP_clif_message_pre ) {
@@ -12529,33 +12589,6 @@ void HP_clif_messageln(const int fd, const char *mes) {
}
return;
}
-int HP_clif_colormes(int fd, enum clif_colors color, const char *msg) {
- int hIndex = 0;
- int retVal___ = 0;
- if( HPMHooks.count.HP_clif_colormes_pre ) {
- int (*preHookFunc) (int *fd, enum clif_colors *color, const char *msg);
- *HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_colormes_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_clif_colormes_pre[hIndex].func;
- retVal___ = preHookFunc(&fd, &color, msg);
- }
- if( *HPMforce_return ) {
- *HPMforce_return = false;
- return retVal___;
- }
- }
- {
- retVal___ = HPMHooks.source.clif.colormes(fd, color, msg);
- }
- if( HPMHooks.count.HP_clif_colormes_post ) {
- int (*postHookFunc) (int retVal___, int *fd, enum clif_colors *color, const char *msg);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_colormes_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_clif_colormes_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, &fd, &color, msg);
- }
- }
- return retVal___;
-}
bool HP_clif_process_message(struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_) {
int hIndex = 0;
bool retVal___ = false;
@@ -17718,6 +17751,111 @@ void HP_clif_roulette_generate_ack(struct map_session_data *sd, unsigned char re
}
return;
}
+void HP_clif_openmergeitem(int fd, struct map_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_clif_openmergeitem_pre ) {
+ void (*preHookFunc) (int *fd, struct map_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_openmergeitem_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_openmergeitem_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.clif.openmergeitem(fd, sd);
+ }
+ if( HPMHooks.count.HP_clif_openmergeitem_post ) {
+ void (*postHookFunc) (int *fd, struct map_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_openmergeitem_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_openmergeitem_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+void HP_clif_cancelmergeitem(int fd, struct map_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_clif_cancelmergeitem_pre ) {
+ void (*preHookFunc) (int *fd, struct map_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_cancelmergeitem_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_cancelmergeitem_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.clif.cancelmergeitem(fd, sd);
+ }
+ if( HPMHooks.count.HP_clif_cancelmergeitem_post ) {
+ void (*postHookFunc) (int *fd, struct map_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_cancelmergeitem_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_cancelmergeitem_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
+int HP_clif_comparemergeitem(const void *a, const void *b) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_clif_comparemergeitem_pre ) {
+ int (*preHookFunc) (const void *a, const void *b);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_comparemergeitem_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_comparemergeitem_pre[hIndex].func;
+ retVal___ = preHookFunc(a, b);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.clif.comparemergeitem(a, b);
+ }
+ if( HPMHooks.count.HP_clif_comparemergeitem_post ) {
+ int (*postHookFunc) (int retVal___, const void *a, const void *b);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_comparemergeitem_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_comparemergeitem_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, a, b);
+ }
+ }
+ return retVal___;
+}
+void HP_clif_ackmergeitems(int fd, struct map_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_clif_ackmergeitems_pre ) {
+ void (*preHookFunc) (int *fd, struct map_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_ackmergeitems_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_ackmergeitems_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.clif.ackmergeitems(fd, sd);
+ }
+ if( HPMHooks.count.HP_clif_ackmergeitems_post ) {
+ void (*postHookFunc) (int *fd, struct map_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_ackmergeitems_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_ackmergeitems_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
void HP_clif_pWantToConnection(int fd, struct map_session_data *sd) {
int hIndex = 0;
if( HPMHooks.count.HP_clif_pWantToConnection_pre ) {
@@ -49323,6 +49461,60 @@ int HP_pc_insert_card(struct map_session_data *sd, int idx_card, int idx_equip)
}
return retVal___;
}
+bool HP_pc_can_insert_card(struct map_session_data *sd, int idx_card) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_pc_can_insert_card_pre ) {
+ bool (*preHookFunc) (struct map_session_data *sd, int *idx_card);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_can_insert_card_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pc_can_insert_card_pre[hIndex].func;
+ retVal___ = preHookFunc(sd, &idx_card);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.pc.can_insert_card(sd, idx_card);
+ }
+ if( HPMHooks.count.HP_pc_can_insert_card_post ) {
+ bool (*postHookFunc) (bool retVal___, struct map_session_data *sd, int *idx_card);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_can_insert_card_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pc_can_insert_card_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, sd, &idx_card);
+ }
+ }
+ return retVal___;
+}
+bool HP_pc_can_insert_card_into(struct map_session_data *sd, int idx_card, int idx_equip) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_pc_can_insert_card_into_pre ) {
+ bool (*preHookFunc) (struct map_session_data *sd, int *idx_card, int *idx_equip);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_can_insert_card_into_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pc_can_insert_card_into_pre[hIndex].func;
+ retVal___ = preHookFunc(sd, &idx_card, &idx_equip);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.pc.can_insert_card_into(sd, idx_card, idx_equip);
+ }
+ if( HPMHooks.count.HP_pc_can_insert_card_into_post ) {
+ bool (*postHookFunc) (bool retVal___, struct map_session_data *sd, int *idx_card, int *idx_equip);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_can_insert_card_into_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pc_can_insert_card_into_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, sd, &idx_card, &idx_equip);
+ }
+ }
+ return retVal___;
+}
int HP_pc_steal_item(struct map_session_data *sd, struct block_list *bl, uint16 skill_lv) {
int hIndex = 0;
int retVal___ = 0;
@@ -51628,6 +51820,33 @@ int HP_pc_delspiritball(struct map_session_data *sd, int count, int type) {
}
return retVal___;
}
+int HP_pc_getmaxspiritball(struct map_session_data *sd, int min) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_pc_getmaxspiritball_pre ) {
+ int (*preHookFunc) (struct map_session_data *sd, int *min);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_getmaxspiritball_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pc_getmaxspiritball_pre[hIndex].func;
+ retVal___ = preHookFunc(sd, &min);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.pc.getmaxspiritball(sd, min);
+ }
+ if( HPMHooks.count.HP_pc_getmaxspiritball_post ) {
+ int (*postHookFunc) (int retVal___, struct map_session_data *sd, int *min);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_getmaxspiritball_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pc_getmaxspiritball_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, sd, &min);
+ }
+ }
+ return retVal___;
+}
void HP_pc_addfame(struct map_session_data *sd, int count) {
int hIndex = 0;
if( HPMHooks.count.HP_pc_addfame_pre ) {
@@ -52354,15 +52573,15 @@ int HP_pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short src_
}
return retVal___;
}
-int HP_pc_bonus_addeff(struct s_addeffect *effect, int max, enum sc_type id, short rate, short arrow_rate, unsigned char flag) {
+int HP_pc_bonus_addeff(struct s_addeffect *effect, int max, enum sc_type id, int16 rate, int16 arrow_rate, uint8 flag, uint16 duration) {
int hIndex = 0;
int retVal___ = 0;
if( HPMHooks.count.HP_pc_bonus_addeff_pre ) {
- int (*preHookFunc) (struct s_addeffect *effect, int *max, enum sc_type *id, short *rate, short *arrow_rate, unsigned char *flag);
+ int (*preHookFunc) (struct s_addeffect *effect, int *max, enum sc_type *id, int16 *rate, int16 *arrow_rate, uint8 *flag, uint16 *duration);
*HPMforce_return = false;
for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_bonus_addeff_pre; hIndex++ ) {
preHookFunc = HPMHooks.list.HP_pc_bonus_addeff_pre[hIndex].func;
- retVal___ = preHookFunc(effect, &max, &id, &rate, &arrow_rate, &flag);
+ retVal___ = preHookFunc(effect, &max, &id, &rate, &arrow_rate, &flag, &duration);
}
if( *HPMforce_return ) {
*HPMforce_return = false;
@@ -52370,13 +52589,13 @@ int HP_pc_bonus_addeff(struct s_addeffect *effect, int max, enum sc_type id, sho
}
}
{
- retVal___ = HPMHooks.source.pc.bonus_addeff(effect, max, id, rate, arrow_rate, flag);
+ retVal___ = HPMHooks.source.pc.bonus_addeff(effect, max, id, rate, arrow_rate, flag, duration);
}
if( HPMHooks.count.HP_pc_bonus_addeff_post ) {
- int (*postHookFunc) (int retVal___, struct s_addeffect *effect, int *max, enum sc_type *id, short *rate, short *arrow_rate, unsigned char *flag);
+ int (*postHookFunc) (int retVal___, struct s_addeffect *effect, int *max, enum sc_type *id, int16 *rate, int16 *arrow_rate, uint8 *flag, uint16 *duration);
for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_bonus_addeff_post; hIndex++ ) {
postHookFunc = HPMHooks.list.HP_pc_bonus_addeff_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, effect, &max, &id, &rate, &arrow_rate, &flag);
+ retVal___ = postHookFunc(retVal___, effect, &max, &id, &rate, &arrow_rate, &flag, &duration);
}
}
return retVal___;
@@ -53303,6 +53522,33 @@ void HP_pc_autotrade_populate(struct map_session_data *sd) {
}
return;
}
+int HP_pc_check_job_name(const char *name) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_pc_check_job_name_pre ) {
+ int (*preHookFunc) (const char *name);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_check_job_name_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pc_check_job_name_pre[hIndex].func;
+ retVal___ = preHookFunc(name);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.pc.check_job_name(name);
+ }
+ if( HPMHooks.count.HP_pc_check_job_name_post ) {
+ int (*postHookFunc) (int retVal___, const char *name);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_check_job_name_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pc_check_job_name_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, name);
+ }
+ }
+ return retVal___;
+}
/* pet */
int HP_pet_init(bool minimal) {
int hIndex = 0;
@@ -66876,40 +67122,14 @@ unsigned short HP_status_base_atk(const struct block_list *bl, const struct stat
}
return retVal___;
}
-void HP_status_calc_sigma(void) {
- int hIndex = 0;
- if( HPMHooks.count.HP_status_calc_sigma_pre ) {
- void (*preHookFunc) (void);
- *HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_status_calc_sigma_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_status_calc_sigma_pre[hIndex].func;
- preHookFunc();
- }
- if( *HPMforce_return ) {
- *HPMforce_return = false;
- return;
- }
- }
- {
- HPMHooks.source.status.calc_sigma();
- }
- if( HPMHooks.count.HP_status_calc_sigma_post ) {
- void (*postHookFunc) (void);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_status_calc_sigma_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_status_calc_sigma_post[hIndex].func;
- postHookFunc();
- }
- }
- return;
-}
-unsigned int HP_status_base_pc_maxhp(struct map_session_data *sd, struct status_data *st) {
+unsigned int HP_status_get_base_maxhp(struct map_session_data *sd, struct status_data *st) {
int hIndex = 0;
unsigned int retVal___ = 0;
- if( HPMHooks.count.HP_status_base_pc_maxhp_pre ) {
+ if( HPMHooks.count.HP_status_get_base_maxhp_pre ) {
unsigned int (*preHookFunc) (struct map_session_data *sd, struct status_data *st);
*HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_status_base_pc_maxhp_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_status_base_pc_maxhp_pre[hIndex].func;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_status_get_base_maxhp_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_status_get_base_maxhp_pre[hIndex].func;
retVal___ = preHookFunc(sd, st);
}
if( *HPMforce_return ) {
@@ -66918,25 +67138,25 @@ unsigned int HP_status_base_pc_maxhp(struct map_session_data *sd, struct status_
}
}
{
- retVal___ = HPMHooks.source.status.base_pc_maxhp(sd, st);
+ retVal___ = HPMHooks.source.status.get_base_maxhp(sd, st);
}
- if( HPMHooks.count.HP_status_base_pc_maxhp_post ) {
+ if( HPMHooks.count.HP_status_get_base_maxhp_post ) {
unsigned int (*postHookFunc) (unsigned int retVal___, struct map_session_data *sd, struct status_data *st);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_status_base_pc_maxhp_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_status_base_pc_maxhp_post[hIndex].func;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_status_get_base_maxhp_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_status_get_base_maxhp_post[hIndex].func;
retVal___ = postHookFunc(retVal___, sd, st);
}
}
return retVal___;
}
-unsigned int HP_status_base_pc_maxsp(struct map_session_data *sd, struct status_data *st) {
+unsigned int HP_status_get_base_maxsp(struct map_session_data *sd, struct status_data *st) {
int hIndex = 0;
unsigned int retVal___ = 0;
- if( HPMHooks.count.HP_status_base_pc_maxsp_pre ) {
+ if( HPMHooks.count.HP_status_get_base_maxsp_pre ) {
unsigned int (*preHookFunc) (struct map_session_data *sd, struct status_data *st);
*HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_status_base_pc_maxsp_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_status_base_pc_maxsp_pre[hIndex].func;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_status_get_base_maxsp_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_status_get_base_maxsp_pre[hIndex].func;
retVal___ = preHookFunc(sd, st);
}
if( *HPMforce_return ) {
@@ -66945,12 +67165,12 @@ unsigned int HP_status_base_pc_maxsp(struct map_session_data *sd, struct status_
}
}
{
- retVal___ = HPMHooks.source.status.base_pc_maxsp(sd, st);
+ retVal___ = HPMHooks.source.status.get_base_maxsp(sd, st);
}
- if( HPMHooks.count.HP_status_base_pc_maxsp_post ) {
+ if( HPMHooks.count.HP_status_get_base_maxsp_post ) {
unsigned int (*postHookFunc) (unsigned int retVal___, struct map_session_data *sd, struct status_data *st);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_status_base_pc_maxsp_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_status_base_pc_maxsp_post[hIndex].func;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_status_get_base_maxsp_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_status_get_base_maxsp_post[hIndex].func;
retVal___ = postHookFunc(retVal___, sd, st);
}
}
@@ -67742,33 +67962,6 @@ int HP_status_natural_heal_timer(int tid, int64 tick, int id, intptr_t data) {
}
return retVal___;
}
-bool HP_status_readdb_job1(char *fields[], int columns, int current) {
- int hIndex = 0;
- bool retVal___ = false;
- if( HPMHooks.count.HP_status_readdb_job1_pre ) {
- bool (*preHookFunc) (char *fields[], int *columns, int *current);
- *HPMforce_return = false;
- for(hIndex = 0; hIndex < HPMHooks.count.HP_status_readdb_job1_pre; hIndex++ ) {
- preHookFunc = HPMHooks.list.HP_status_readdb_job1_pre[hIndex].func;
- retVal___ = preHookFunc(fields, &columns, &current);
- }
- if( *HPMforce_return ) {
- *HPMforce_return = false;
- return retVal___;
- }
- }
- {
- retVal___ = HPMHooks.source.status.readdb_job1(fields, columns, current);
- }
- if( HPMHooks.count.HP_status_readdb_job1_post ) {
- bool (*postHookFunc) (bool retVal___, char *fields[], int *columns, int *current);
- for(hIndex = 0; hIndex < HPMHooks.count.HP_status_readdb_job1_post; hIndex++ ) {
- postHookFunc = HPMHooks.list.HP_status_readdb_job1_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, fields, &columns, &current);
- }
- }
- return retVal___;
-}
bool HP_status_readdb_job2(char *fields[], int columns, int current) {
int hIndex = 0;
bool retVal___ = false;
@@ -67877,6 +68070,58 @@ bool HP_status_readdb_scconfig(char *fields[], int columns, int current) {
}
return retVal___;
}
+void HP_status_read_job_db(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_status_read_job_db_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_status_read_job_db_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_status_read_job_db_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.status.read_job_db();
+ }
+ if( HPMHooks.count.HP_status_read_job_db_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_status_read_job_db_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_status_read_job_db_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_status_read_job_db_sub_pre ) {
+ void (*preHookFunc) (int *idx, const char *name, config_setting_t *jdb);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_status_read_job_db_sub_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_status_read_job_db_sub_pre[hIndex].func;
+ preHookFunc(&idx, name, jdb);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.status.read_job_db_sub(idx, name, jdb);
+ }
+ if( HPMHooks.count.HP_status_read_job_db_sub_post ) {
+ void (*postHookFunc) (int *idx, const char *name, config_setting_t *jdb);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_status_read_job_db_sub_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_status_read_job_db_sub_post[hIndex].func;
+ postHookFunc(&idx, name, jdb);
+ }
+ }
+ return;
+}
/* storage */
void HP_storage_reconnect(void) {
int hIndex = 0;
diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in
index 802d1015a..3184353d1 100644
--- a/src/plugins/Makefile.in
+++ b/src/plugins/Makefile.in
@@ -32,6 +32,9 @@ PLUGINS = sample db2sql HPMHooking_char HPMHooking_login HPMHooking_map $(MYPLUG
COMMON_D = ../common
COMMON_H = $(wildcard $(COMMON_D)/*.h)
+COMMON_INCLUDE = -I..
+
+THIRDPARTY_INCLUDE = -I../../3rdparty
CONFIG_D = ../config
CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h)
@@ -84,7 +87,7 @@ Makefile: Makefile.in
../../plugins/%@DLLEXT@: %.c $(ALL_H) $$(shell ls %/* 2>/dev/null)
@echo " CC $<"
- @$(CC) @PLUGINSTATIC@ @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o $@ $<
+ @$(CC) $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @PLUGINSTATIC@ @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o $@ $<
../../plugins/HPMHooking_login@DLLEXT@: HPMHOOKINGTYPE = LOGIN
../../plugins/HPMHooking_char@DLLEXT@: HPMHOOKINGTYPE = CHAR
@@ -92,4 +95,4 @@ Makefile: Makefile.in
../../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 $@ $<
+ @$(CC) -DHPMHOOKING_$(HPMHOOKINGTYPE) $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @PLUGINSTATIC@ @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o $@ $<
diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c
index 1e27058c0..2741ce468 100644
--- a/src/plugins/db2sql.c
+++ b/src/plugins/db2sql.c
@@ -1,25 +1,25 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
-#include "../config/core.h"
+#include "config/core.h"
+
+#include "common/HPMi.h"
+#include "common/cbasetypes.h"
+#include "common/conf.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/strlib.h"
+#include "common/timer.h"
+#include "map/clif.h"
+#include "map/itemdb.h"
+#include "map/map.h"
+#include "map/pc.h"
+
+#include "common/HPMDataCheck.h"
#include <stdio.h>
#include <stdlib.h>
-#include "../common/HPMi.h"
-#include "../common/cbasetypes.h"
-#include "../common/conf.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/strlib.h"
-#include "../common/timer.h"
-#include "../map/clif.h"
-#include "../map/itemdb.h"
-#include "../map/map.h"
-#include "../map/pc.h"
-
-#include "../common/HPMDataCheck.h"
-
HPExport struct hplugin_info pinfo = {
"DB2SQL", // Plugin name
SERVER_TYPE_MAP, // Which server types this plugin works with?
@@ -139,7 +139,10 @@ int db2sql(config_setting_t *entry, int n, const char *source) {
// bindonequip
StrBuf->Printf(&buf, "'%u',", it->flag.bindonequip?1:0);
-
+
+ // forceserial
+ StrBuf->Printf(&buf, "'%u',", it->flag.force_serial?1:0);
+
// buyingstore
StrBuf->Printf(&buf, "'%u',", it->flag.buyingstore?1:0);
@@ -269,6 +272,7 @@ void totable(void) {
" `refineable` tinyint(1) UNSIGNED DEFAULT NULL,\n"
" `view` smallint(3) UNSIGNED DEFAULT NULL,\n"
" `bindonequip` tinyint(1) UNSIGNED DEFAULT NULL,\n"
+ " `forceserial` tinyint(1) UNSIGNED DEFAULT NULL,\n"
" `buyingstore` tinyint(1) UNSIGNED DEFAULT NULL,\n"
" `delay` mediumint(9) UNSIGNED DEFAULT NULL,\n"
" `trade_flag` smallint(4) UNSIGNED DEFAULT NULL,\n"
diff --git a/src/plugins/dbghelpplug.c b/src/plugins/dbghelpplug.c
index bf43c0b23..6ed16d7a6 100644
--- a/src/plugins/dbghelpplug.c
+++ b/src/plugins/dbghelpplug.c
@@ -5,12 +5,13 @@
// Ported from eAthena Dev Team's version @ http://eathena-project.googlecode.com/svn/trunk/src/plugins/dbghelpplug.c
// Currently supported dbghelp 5.1
+#include "common/sysinfo.h"
+#include "common/HPMi.h"
+
+#include "common/HPMDataCheck.h"
+
#include <stdio.h>
#include <string.h>
-#include "../common/sysinfo.h"
-#include "../common/HPMi.h"
-
-#include "../common/HPMDataCheck.h"
/**
* Plugin basic information
@@ -217,8 +218,8 @@ typedef struct _InternalData {
// Extended information printed in the console
#define DBG_EXTENDED_INFORMATION \
- "Please report the crash in the bug tracker:\n" \
- "http://hercules.ws/board/tracker/\n"
+ "Please report the crash in our Issues tracker:\n" \
+ "https://github.com/HerculesWS/Hercules/issues\n"
// Print object children?
// WARNING: This will generate huge dump files!
diff --git a/src/plugins/sample.c b/src/plugins/sample.c
index 03d32b1f3..b034775b0 100644
--- a/src/plugins/sample.c
+++ b/src/plugins/sample.c
@@ -2,21 +2,21 @@
// See the LICENSE file
// Sample Hercules Plugin
+#include "common/HPMi.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "map/clif.h"
+#include "map/pc.h"
+#include "map/script.h"
+
+#include "common/HPMDataCheck.h" /* should always be the last file included! (if you don't make it last, it'll intentionally break compile time) */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "../common/HPMi.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../map/clif.h"
-#include "../map/pc.h"
-#include "../map/script.h"
-
-#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_CHAR|SERVER_TYPE_LOGIN|SERVER_TYPE_MAP,// Which server types this plugin works with?
@@ -107,7 +107,7 @@ int my_pc_dropitem_post(int retVal, struct map_session_data *sd,int *n,int *amou
if( my_pc_dropitem_storage ) {/* signs whether pre-hook did this */
char output[99];
safesnprintf(output,99,"[ Warning ] you can only drop 1 item at a time, capped from %d to 1",my_pc_dropitem_storage);
- clif->colormes(sd->fd,COLOR_RED,output);
+ clif->messagecolor_self(sd->fd, COLOR_RED, output);
}
return 1;
}
diff --git a/src/test/Makefile.in b/src/test/Makefile.in
index dea126e46..8f999fb37 100644
--- a/src/test/Makefile.in
+++ b/src/test/Makefile.in
@@ -9,18 +9,20 @@ CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h)
COMMON_D = ../common
COMMON_H = $(wildcard $(COMMON_D)/*.h)
SYSINFO_INC = $(COMMON_D)/sysinfo.inc
+COMMON_INCLUDE = -I..
-LIBCONFIG_D = ../../3rdparty/libconfig
+THIRDPARTY_D = ../../3rdparty
+THIRDPARTY_INCLUDE = -I$(THIRDPARTY_D)
+
+LIBCONFIG_D = $(THIRDPARTY_D)/libconfig
LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
scanner.o strbuf.o)
LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
scanctx.h scanner.h strbuf.h wincompat.h)
-LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
-MT19937AR_D = ../../3rdparty/mt19937ar
+MT19937AR_D = $(THIRDPARTY_D)/mt19937ar
MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
-MT19937AR_INCLUDE = -I$(MT19937AR_D)
TEST_SPINLOCK_OBJ = obj/test_spinlock.o
TEST_SPINLOCK_C = test_spinlock.c
@@ -70,7 +72,7 @@ test_spinlock: $(TEST_SPINLOCK_DEPENDS) Makefile
obj/%.o: %.c $(TEST_SPINLOCK_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj
@echo " CC $<"
- @$(CC) @CFLAGS@ @DEFS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+ @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing object files
$(COMMON_D)/obj_all/common.a:
diff --git a/src/test/test_spinlock.c b/src/test/test_spinlock.c
index 19ae9aee7..4f235907d 100644
--- a/src/test/test_spinlock.c
+++ b/src/test/test_spinlock.c
@@ -1,9 +1,11 @@
+#define HERCULES_CORE
-#include "../common/core.h"
-#include "../common/atomic.h"
-#include "../common/thread.h"
-#include "../common/spinlock.h"
-#include "../common/showmsg.h"
+#include "common/atomic.h"
+#include "common/cbasetypes.h"
+#include "common/core.h"
+#include "common/thread.h"
+#include "common/spinlock.h"
+#include "common/showmsg.h"
#include <stdio.h>
#include <stdlib.h>
@@ -12,8 +14,6 @@
// Simple test for the spinlock implementation to see if it works properly..
//
-
-
#define THRC 32 //thread Count
#define PERINC 100000
#define LOOPS 47
diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in
index 2d7699db0..b0c07b2fb 100644
--- a/src/tool/Makefile.in
+++ b/src/tool/Makefile.in
@@ -9,13 +9,16 @@ CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h)
COMMON_D = ../common
COMMON_H = $(wildcard $(COMMON_D)/*.h)
SYSINFO_INC = $(COMMON_D)/sysinfo.inc
+COMMON_INCLUDE = -I..
-LIBCONFIG_D = ../../3rdparty/libconfig
+THIRDPARTY_D = ../../3rdparty
+THIRDPARTY_INCLUDE = -I$(THIRDPARTY_D)
+
+LIBCONFIG_D = $(THIRDPARTY_D)/libconfig
LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
scanner.o strbuf.o)
LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
scanctx.h scanner.h strbuf.h wincompat.h)
-LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
MAPCACHE_OBJ = obj_all/mapcache.o
MAPCACHE_C = mapcache.c
@@ -70,7 +73,7 @@ obj_all:
obj_all/%.o: %.c $(MAPCACHE_H) $(COMMON_H) $(CONFIG_H) $(LIBCONFIG_H) | obj_all
@echo " CC $<"
- @$(CC) @CFLAGS@ @DEFS@ $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+ @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing common object files
$(COMMON_D)/obj_all/common_mini.a:
diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c
index 4b2b4bd49..356cdd352 100644
--- a/src/tool/mapcache.c
+++ b/src/tool/mapcache.c
@@ -3,21 +3,17 @@
#define HERCULES_CORE
-#include "../config/core.h" // RENEWAL
+#include "common/cbasetypes.h"
+#include "common/core.h"
+#include "common/grfio.h"
+#include "common/malloc.h"
+#include "common/mmo.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+#include "common/utils.h"
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-
-#include "../common/cbasetypes.h"
-#include "../common/core.h"
-#include "../common/grfio.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/utils.h"
-#include "../common/strlib.h"
-
#ifndef _WIN32
#include <unistd.h>
#endif
@@ -114,8 +110,14 @@ int read_map(char *name, struct map_data *m)
return 1;
}
-// Adds a map to the cache
-void cache_map(char *name, struct map_data *m)
+/**
+ * Adds a map to the cache.
+ *
+ * @param name The map name.
+ * @param m Map data to cache.
+ * @retval true if the map was successfully added to the cache.
+ */
+bool cache_map(char *name, struct map_data *m)
{
struct map_info info;
unsigned long len;
@@ -130,14 +132,18 @@ void cache_map(char *name, struct map_data *m)
// Fill the map header
safestrncpy(info.name, name, MAP_NAME_LENGTH);
if (strlen(name) > MAP_NAME_LENGTH) // It does not hurt to warn that there are maps with name longer than allowed.
- ShowWarning("Map name '%s' (length %"PRIuS") is too long. Truncating to '%s' (lentgh %d).\n",
+ ShowWarning("Map name '%s' (length %"PRIuS") is too long. Truncating to '%s' (length %d).\n",
name, strlen(name), info.name, MAP_NAME_LENGTH);
info.xs = MakeShortLE(m->xs);
info.ys = MakeShortLE(m->ys);
info.len = MakeLongLE((uint32)len);
// Append map header then compressed cells at the end of the file
- fseek(map_cache_fp, header.file_size, SEEK_SET);
+ if (fseek(map_cache_fp, header.file_size, SEEK_SET) != 0) {
+ aFree(write_buf);
+ aFree(m->cells);
+ return false;
+ }
fwrite(&info, sizeof(struct map_info), 1, map_cache_fp);
fwrite(write_buf, 1, len, map_cache_fp);
header.file_size += sizeof(struct map_info) + len;
@@ -146,26 +152,34 @@ void cache_map(char *name, struct map_data *m)
aFree(write_buf);
aFree(m->cells);
- return;
+ return true;
}
-// Checks whether a map is already is the cache
-int find_map(char *name)
+/**
+ * Checks whether a map is already is the cache.
+ *
+ * @param name The map name.
+ * @retval true if the map is already cached.
+ */
+bool find_map(char *name)
{
int i;
struct map_info info;
- fseek(map_cache_fp, sizeof(struct main_header), SEEK_SET);
-
- for(i = 0; i < header.map_count; i++) {
- if(fread(&info, sizeof(info), 1, map_cache_fp) != 1) printf("An error as occured in fread while reading map_cache\n");
- if(strcmp(name, info.name) == 0) // Map found
- return 1;
- else // Map not found, jump to the beginning of the next map info header
- fseek(map_cache_fp, GetLong((unsigned char *)&(info.len)), SEEK_CUR);
+ if (fseek(map_cache_fp, sizeof(struct main_header), SEEK_SET) != 0)
+ return false;
+
+ for (i = 0; i < header.map_count; i++) {
+ if (fread(&info, sizeof(info), 1, map_cache_fp) != 1)
+ printf("An error as occured in fread while reading map_cache\n");
+ if (strcmp(name, info.name) == 0) // Map found
+ return true;
+ // Map not found, jump to the beginning of the next map info header
+ if (fseek(map_cache_fp, GetLong((unsigned char *)&(info.len)), SEEK_CUR) != 0)
+ return false;
}
- return 0;
+ return false;
}
// Cuts the extension from a map name
@@ -314,14 +328,15 @@ int do_init(int argc, char** argv)
name[MAP_NAME_LENGTH_EXT-1] = '\0';
remove_extension(name);
- if(find_map(name))
+ if (find_map(name)) {
ShowInfo("Map '"CL_WHITE"%s"CL_RESET"' already in cache.\n", name);
- else if(read_map(name, &map)) {
- cache_map(name, &map);
- ShowInfo("Map '"CL_WHITE"%s"CL_RESET"' successfully cached.\n", name);
- } else
+ } else if(!read_map(name, &map)) {
ShowError("Map '"CL_WHITE"%s"CL_RESET"' not found!\n", name);
-
+ } else if (!cache_map(name, &map)) {
+ ShowError("Map '"CL_WHITE"%s"CL_RESET"' failed to cache (write error).\n", name);
+ } else {
+ ShowInfo("Map '"CL_WHITE"%s"CL_RESET"' successfully cached.\n", name);
+ }
}
ShowStatus("Closing map list: %s\n", map_list_file);