summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
Diffstat (limited to 'src/char')
-rw-r--r--src/char/HPMchar.c2
-rw-r--r--src/char/HPMchar.h2
-rw-r--r--src/char/Makefile.in29
-rw-r--r--src/char/char.c78
-rw-r--r--src/char/char.h6
-rw-r--r--src/char/geoip.c9
-rw-r--r--src/char/geoip.h4
-rw-r--r--src/char/int_achievement.c2
-rw-r--r--src/char/int_achievement.h2
-rw-r--r--src/char/int_auction.c4
-rw-r--r--src/char/int_auction.h4
-rw-r--r--src/char/int_clan.c2
-rw-r--r--src/char/int_clan.h2
-rw-r--r--src/char/int_elemental.c4
-rw-r--r--src/char/int_elemental.h4
-rw-r--r--src/char/int_guild.c27
-rw-r--r--src/char/int_guild.h4
-rw-r--r--src/char/int_homun.c4
-rw-r--r--src/char/int_homun.h4
-rw-r--r--src/char/int_mail.c4
-rw-r--r--src/char/int_mail.h4
-rw-r--r--src/char/int_mercenary.c4
-rw-r--r--src/char/int_mercenary.h4
-rw-r--r--src/char/int_party.c506
-rw-r--r--src/char/int_party.h17
-rw-r--r--src/char/int_pet.c236
-rw-r--r--src/char/int_pet.h4
-rw-r--r--src/char/int_quest.c4
-rw-r--r--src/char/int_quest.h4
-rw-r--r--src/char/int_rodex.c140
-rw-r--r--src/char/int_rodex.h6
-rw-r--r--src/char/int_storage.c4
-rw-r--r--src/char/int_storage.h4
-rw-r--r--src/char/inter.c101
-rw-r--r--src/char/inter.h15
-rw-r--r--src/char/loginif.c4
-rw-r--r--src/char/loginif.h4
-rw-r--r--src/char/mapif.c236
-rw-r--r--src/char/mapif.h18
-rw-r--r--src/char/packets_hc_struct.h2
-rw-r--r--src/char/pincode.c4
-rw-r--r--src/char/pincode.h4
42 files changed, 791 insertions, 731 deletions
diff --git a/src/char/HPMchar.c b/src/char/HPMchar.c
index f3cf2cff4..517bc0835 100644
--- a/src/char/HPMchar.c
+++ b/src/char/HPMchar.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2014-2018 Hercules Dev Team
+ * Copyright (C) 2014-2020 Hercules Dev Team
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/HPMchar.h b/src/char/HPMchar.h
index 0de3b88b8..d2fc69301 100644
--- a/src/char/HPMchar.h
+++ b/src/char/HPMchar.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2014-2018 Hercules Dev Team
+ * Copyright (C) 2014-2020 Hercules Dev Team
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/Makefile.in b/src/char/Makefile.in
index f159a443f..88a99c96c 100644
--- a/src/char/Makefile.in
+++ b/src/char/Makefile.in
@@ -1,8 +1,8 @@
# This file is part of Hercules.
# http://herc.ws - http://github.com/HerculesWS/Hercules
#
-# Copyright (C) 2012-2018 Hercules Dev Team
-# Copyright (C) Athena Dev Teams
+# Copyright (C) 2012-2020 Hercules Dev Team
+# Copyright (C) Athena Dev Teams
#
# Hercules is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -36,6 +36,19 @@ LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
scanctx.h scanner.h strbuf.h wincompat.h)
+ifeq (@USE_LIBBACKTRACE@,yes)
+ LIBBACKTRACE_D = $(THIRDPARTY_D)/libbacktrace
+ LIBBACKTRACE_OBJ = $(addprefix $(LIBBACKTRACE_D)/, atomic.o backtrace.o \
+ dwarf.o @LIBBACKTRACE_FORMAT_FILE@ fileline.o mmapio.o mmap.o posix.o print.o \
+ simple.o sort.o state.o)
+ LIBBACKTRACE_H = $(addprefix $(LIBBACKTRACE_D)/, backtrace.h \
+ backtrace-supported.h config.h filenames.h internal.h)
+else
+ LIBBACKTRACE_D =
+ LIBBACKTRACE_OBJ =
+ LIBBACKTRACE_H =
+endif
+
MT19937AR_D = $(THIRDPARTY_D)/mt19937ar
MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
@@ -51,7 +64,7 @@ CHAR_PH =
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
- CHAR_SERVER_SQL_DEPENDS=$(CHAR_OBJ) $(COMMON_D)/obj_all/common.a $(COMMON_D)/obj_sql/common_sql.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) $(SYSINFO_INC)
+ CHAR_SERVER_SQL_DEPENDS=$(CHAR_OBJ) $(COMMON_D)/obj_all/common.a $(COMMON_D)/obj_sql/common_sql.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) $(LIBBACKTRACE_OBJ) $(SYSINFO_INC)
else
CHAR_SERVER_SQL_DEPENDS=needs_mysql
endif
@@ -90,7 +103,7 @@ help:
Makefile: Makefile.in
@$(MAKE) -C ../.. src/char/Makefile
-$(SYSINFO_INC): $(CHAR_C) $(CHAR_PH) $(CHAR_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H)
+$(SYSINFO_INC): $(CHAR_C) $(CHAR_PH) $(CHAR_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) $(LIBBACKTRACE_H)
@echo " MAKE $@"
@$(MAKE) -C ../.. sysinfo
@@ -111,7 +124,7 @@ char-server: ../../char-server@EXEEXT@
../../char-server@EXEEXT@: $(CHAR_SERVER_SQL_DEPENDS) Makefile
@echo " LD $(notdir $@)"
@$(CC) @STATIC@ @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) $(COMMON_D)/obj_all/common.a $(COMMON_D)/obj_sql/common_sql.a \
- $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@
+ $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) $(LIBBACKTRACE_OBJ) @LIBS@ @MYSQL_LIBS@
# missing object files
$(COMMON_D)/obj_all/common.a:
@@ -130,10 +143,14 @@ $(LIBCONFIG_OBJ):
@echo " MAKE $@"
@$(MAKE) -C $(LIBCONFIG_D)
+$(LIBBACKTRACE_OBJ):
+ @echo " MAKE $@"
+ @$(MAKE) -C $(LIBBACKTRACE_D)
+
.SECONDEXPANSION:
# char object files
-obj_sql/%.o: %.c $$(filter %.p.h, $(CHAR_PH)) $(CHAR_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql
+obj_sql/%.o: %.c $$(filter %.p.h, $(CHAR_PH)) $(CHAR_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) $(LIBBACKTRACE_H) | obj_sql
@echo " CC $<"
@$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
diff --git a/src/char/char.c b/src/char/char.c
index 34a3ea7a8..aac9ad20c 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -120,8 +120,6 @@ char char_achievement_db[256] = "char_achievements";
static struct char_interface char_s;
struct char_interface *chr;
-char db_path[1024] = "db";
-
static char wisp_server_name[NAME_LENGTH] = "Server";
static char login_ip_str[128];
static uint32 login_ip = 0;
@@ -477,9 +475,10 @@ static int char_mmo_char_tosql(int char_id, struct mmo_charstatus *p)
(p->look.head_mid != cp->look.head_mid) || (p->look.head_bottom != cp->look.head_bottom) || (p->delete_date != cp->delete_date) ||
(p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->look.robe != cp->look.robe) ||
(p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) || (p->font != cp->font) ||
- (p->uniqueitem_counter != cp->uniqueitem_counter) || (p->hotkey_rowshift != cp->hotkey_rowshift) ||
+ (p->uniqueitem_counter != cp->uniqueitem_counter) || (p->hotkey_rowshift != cp->hotkey_rowshift) || (p->hotkey_rowshift2 != cp->hotkey_rowshift2) ||
(p->clan_id != cp->clan_id) || (p->last_login != cp->last_login) || (p->attendance_count != cp->attendance_count) ||
- (p->attendance_timer != cp->attendance_timer) || (p->title_id != cp->title_id) || (p->inventorySize != cp->inventorySize)
+ (p->attendance_timer != cp->attendance_timer) || (p->title_id != cp->title_id) || (p->inventorySize != cp->inventorySize) ||
+ (p->allow_call != cp->allow_call)
) {
//Save status
unsigned int opt = 0;
@@ -491,10 +490,12 @@ static int char_mmo_char_tosql(int char_id, struct mmo_charstatus *p)
p->inventorySize = FIXED_INVENTORY_SIZE;
}
- if( p->allow_party )
+ if (p->allow_party)
opt |= OPT_ALLOW_PARTY;
- if( p->show_equip )
+ if (p->show_equip)
opt |= OPT_SHOW_EQUIP;
+ if (p->allow_call)
+ opt |= OPT_ALLOW_CALL;
if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `base_level`='%d', `job_level`='%d',"
"`base_exp`='%"PRIu64"', `job_exp`='%"PRIu64"', `zeny`='%d',"
@@ -504,7 +505,7 @@ static int char_mmo_char_tosql(int char_id, struct mmo_charstatus *p)
"`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d',"
"`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d', `rename`='%d',"
"`delete_date`='%lu',`robe`='%d',`slotchange`='%d', `char_opt`='%u', `font`='%u', `uniqueitem_counter` ='%u',"
- "`hotkey_rowshift`='%d',`clan_id`='%d',`last_login`='%"PRId64"',`attendance_count`='%d',`attendance_timer`='%"PRId64"',"
+ "`hotkey_rowshift`='%d',`hotkey_rowshift2`='%d',`clan_id`='%d',`last_login`='%"PRId64"',`attendance_count`='%d',`attendance_timer`='%"PRId64"',"
"`title_id`='%d', `inventory_size`='%d'"
" WHERE `account_id`='%d' AND `char_id` = '%d'",
char_db, p->base_level, p->job_level,
@@ -517,7 +518,7 @@ static int char_mmo_char_tosql(int char_id, struct mmo_charstatus *p)
mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename,
(unsigned long)p->delete_date, // FIXME: platform-dependent size
p->look.robe,p->slotchange,opt,p->font,p->uniqueitem_counter,
- p->hotkey_rowshift,p->clan_id,p->last_login, p->attendance_count, p->attendance_timer,
+ p->hotkey_rowshift,p->hotkey_rowshift2,p->clan_id,p->last_login, p->attendance_count, p->attendance_timer,
p->title_id, p->inventorySize,
p->account_id, p->char_id) )
{
@@ -1212,7 +1213,7 @@ static int char_mmo_char_fromsql(int char_id, struct mmo_charstatus *p, bool loa
"`status_point`,`skill_point`,`option`,`karma`,`manner`,`party_id`,`guild_id`,`pet_id`,`homun_id`,`elemental_id`,`hair`,"
"`hair_color`,`clothes_color`,`body`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,`last_map`,`last_x`,`last_y`,"
"`save_map`,`save_x`,`save_y`,`partner_id`,`father`,`mother`,`child`,`fame`,`rename`,`delete_date`,`robe`,`slotchange`,"
- "`char_opt`,`font`,`uniqueitem_counter`,`sex`,`hotkey_rowshift`,`clan_id`,`last_login`, `attendance_count`, `attendance_timer`,"
+ "`char_opt`,`font`,`uniqueitem_counter`,`sex`,`hotkey_rowshift`,`hotkey_rowshift2`,`clan_id`,`last_login`, `attendance_count`, `attendance_timer`,"
"`title_id`, `inventory_size`"
" FROM `%s` WHERE `char_id`=? LIMIT 1", char_db)
|| SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, sizeof char_id)
@@ -1276,12 +1277,13 @@ static int char_mmo_char_fromsql(int char_id, struct mmo_charstatus *p, bool loa
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 56, SQLDT_UINT32, &p->uniqueitem_counter, sizeof p->uniqueitem_counter, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 57, SQLDT_ENUM, &sex, sizeof sex, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 58, SQLDT_UCHAR, &p->hotkey_rowshift, sizeof p->hotkey_rowshift, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 59, SQLDT_INT, &p->clan_id, sizeof p->clan_id, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 60, SQLDT_INT64, &p->last_login, sizeof p->last_login, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 61, SQLDT_SHORT, &p->attendance_count, sizeof p->attendance_count, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 62, SQLDT_INT64, &p->attendance_timer, sizeof p->attendance_timer, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 63, SQLDT_INT, &p->title_id, sizeof p->title_id, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 64, SQLDT_INT, &p->inventorySize, sizeof p->inventorySize, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 59, SQLDT_UCHAR, &p->hotkey_rowshift2, sizeof p->hotkey_rowshift2, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 60, SQLDT_INT, &p->clan_id, sizeof p->clan_id, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 61, SQLDT_INT64, &p->last_login, sizeof p->last_login, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 62, SQLDT_SHORT, &p->attendance_count, sizeof p->attendance_count, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 63, SQLDT_INT64, &p->attendance_timer, sizeof p->attendance_timer, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 64, SQLDT_INT, &p->title_id, sizeof p->title_id, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 65, SQLDT_INT, &p->inventorySize, sizeof p->inventorySize, NULL, NULL)
) {
SqlStmt_ShowDebug(stmt);
SQL->StmtFree(stmt);
@@ -1412,7 +1414,7 @@ static int char_mmo_char_fromsql(int char_id, struct mmo_charstatus *p, bool loa
while( SQL_SUCCESS == SQL->StmtNextRow(stmt) )
{
- if( hotkey_num >= 0 && hotkey_num < MAX_HOTKEYS )
+ if( hotkey_num >= 0 && hotkey_num < MAX_HOTKEYS_DB )
memcpy(&p->hotkeys[hotkey_num], &tmp_hotkey, sizeof(tmp_hotkey));
else
ShowWarning("chr->mmo_char_fromsql: ignoring invalid hotkey (hotkey=%d,type=%u,id=%u,lv=%u) of character %s (AID=%d,CID=%d)\n", hotkey_num, tmp_hotkey.type, tmp_hotkey.id, tmp_hotkey.lv, p->name, p->account_id, p->char_id);
@@ -1447,10 +1449,12 @@ static int char_mmo_char_fromsql(int char_id, struct mmo_charstatus *p, bool loa
SQL->StmtFree(stmt);
/* load options into proper vars */
- if( opt & OPT_ALLOW_PARTY )
+ if (opt & OPT_ALLOW_PARTY)
p->allow_party = true;
- if( opt & OPT_SHOW_EQUIP )
+ if (opt & OPT_SHOW_EQUIP)
p->show_equip = true;
+ if (opt & OPT_ALLOW_CALL)
+ p->allow_call = true;
cp = idb_ensure(chr->char_db_, char_id, chr->create_charstatus);
memcpy(cp, p, sizeof(struct mmo_charstatus));
@@ -2148,11 +2152,13 @@ static void char_send_HC_ACK_CHARINFO_PER_PAGE(int fd, struct char_session_data
static void char_send_HC_ACK_CHARINFO_PER_PAGE_tail(int fd, struct char_session_data *sd)
{
+#if PACKETVER_MAIN_NUM >= 20130522 || PACKETVER_RE_NUM >= 20130327 || defined(PACKETVER_ZERO)
WFIFOHEAD(fd, sizeof(struct PACKET_HC_ACK_CHARINFO_PER_PAGE));
struct PACKET_HC_ACK_CHARINFO_PER_PAGE *p = WFIFOP(fd, 0);
p->packetId = HEADER_HC_ACK_CHARINFO_PER_PAGE;
p->packetLen = sizeof(struct PACKET_HC_ACK_CHARINFO_PER_PAGE);
WFIFOSET(fd, p->packetLen);
+#endif
}
/* Sends character ban list */
@@ -2265,6 +2271,8 @@ static int char_char_married(int pl1, int pl2)
static int char_char_child(int parent_id, int child_id)
{
+ if (parent_id == 0 || child_id == 0) // Failsafe, avoild querys and fix EXP bug dividing with lower level chars
+ return 0;
if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id) )
Sql_ShowDebug(inter->sql_handle);
else if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
@@ -2284,6 +2292,8 @@ static int char_char_child(int parent_id, int child_id)
static int char_char_family(int cid1, int cid2, int cid3)
{
+ if (cid1 == 0 || cid2 == 0 || cid3 == 0) //Failsafe, and avoid querys where there is no sense to keep executing if any of the inputs are 0
+ return 0;
if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", char_db, cid1, cid2, cid3) )
Sql_ShowDebug(inter->sql_handle);
else while( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
@@ -3137,7 +3147,7 @@ static void char_parse_frommap_map_names(int fd, int id)
static void char_send_scdata(int fd, int aid, int cid)
{
#ifdef ENABLE_SC_SAVING
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `type`, `tick`, `val1`, `val2`, `val3`, `val4` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `type`, `tick`, `total_tick`, `val1`, `val2`, `val3`, `val4` "
"FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'",
scdata_db, aid, cid) )
{
@@ -3158,10 +3168,11 @@ static void char_send_scdata(int fd, int aid, int cid)
{
SQL->GetData(inter->sql_handle, 0, &data, NULL); scdata.type = atoi(data);
SQL->GetData(inter->sql_handle, 1, &data, NULL); scdata.tick = atoi(data);
- SQL->GetData(inter->sql_handle, 2, &data, NULL); scdata.val1 = atoi(data);
- SQL->GetData(inter->sql_handle, 3, &data, NULL); scdata.val2 = atoi(data);
- SQL->GetData(inter->sql_handle, 4, &data, NULL); scdata.val3 = atoi(data);
- SQL->GetData(inter->sql_handle, 5, &data, NULL); scdata.val4 = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); scdata.total_tick = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); scdata.val1 = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); scdata.val2 = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); scdata.val3 = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); scdata.val4 = atoi(data);
memcpy(WFIFOP(fd, 14+count*sizeof(struct status_change_data)), &scdata, sizeof(struct status_change_data));
}
if (count >= 50)
@@ -3731,14 +3742,14 @@ static void char_parse_frommap_save_status_change_data(int fd)
int i;
StrBuf->Init(&buf);
- StrBuf->Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db);
+ StrBuf->Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `total_tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db);
for( i = 0; i < count; ++i )
{
memcpy (&data, RFIFOP(fd, 14+i*sizeof(struct status_change_data)), sizeof(struct status_change_data));
if( i > 0 )
StrBuf->AppendStr(&buf, ", ");
- StrBuf->Printf(&buf, "('%d','%d','%hu','%d','%d','%d','%d','%d')", aid, cid,
- data.type, data.tick, data.val1, data.val2, data.val3, data.val4);
+ StrBuf->Printf(&buf, "('%d','%d','%hu','%d','%d','%d','%d','%d','%d')", aid, cid,
+ data.type, data.tick, data.total_tick, data.val1, data.val2, data.val3, data.val4);
}
if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
Sql_ShowDebug(inter->sql_handle);
@@ -3871,9 +3882,9 @@ static void char_parse_frommap_scdata_update(int fd)
short type = RFIFOW(fd, 10);
if (SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s`"
- " (`account_id`,`char_id`,`type`,`tick`,`val1`,`val2`,`val3`,`val4`)"
- " VALUES ('%d','%d','%d','%d','%d','%d','%d','%d')",
- scdata_db, account_id, char_id, type, INFINITE_DURATION, val1, val2, val3, val4)
+ " (`account_id`,`char_id`,`type`,`tick`,`total_tick`,`val1`,`val2`,`val3`,`val4`)"
+ " VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d')",
+ scdata_db, account_id, char_id, type, INFINITE_DURATION, INFINITE_DURATION, val1, val2, val3, val4)
) {
Sql_ShowDebug(inter->sql_handle);
}
@@ -5779,7 +5790,8 @@ static bool char_config_read_database(const char *filename, const struct config_
if (autosave_interval <= 0)
autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
}
- libconfig->setting_lookup_mutable_string(setting, "db_path", db_path, sizeof(db_path));
+ libconfig->setting_lookup_mutable_string(setting, "db_path", chr->db_path, sizeof(chr->db_path));
+ libconfig->set_db_path(chr->db_path);
libconfig->setting_lookup_bool_real(setting, "log_char", &chr->enable_logs);
return true;
}
@@ -6441,6 +6453,8 @@ void char_defaults(void)
chr = &char_s;
memset(chr->server, 0, sizeof(chr->server));
+ sprintf(chr->db_path, "db");
+ libconfig->set_db_path(chr->db_path);
chr->login_fd = 0;
chr->char_fd = -1;
diff --git a/src/char/char.h b/src/char/char.h
index 5de3e2a80..413007868 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -124,6 +124,8 @@ struct char_interface {
bool show_save_log; ///< Show loading/saving messages.
bool enable_logs; ///< Whether to log char server operations.
+ char db_path[256]; //< Database directory (db)
+
int (*waiting_disconnect) (int tid, int64 tick, int id, intptr_t data);
int (*delete_char_sql) (int char_id);
struct DBData (*create_online_char_data) (union DBKey key, va_list args);
diff --git a/src/char/geoip.c b/src/char/geoip.c
index 2870e5f0c..daace34d5 100644
--- a/src/char/geoip.c
+++ b/src/char/geoip.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@
#include "geoip.h"
#include "common/cbasetypes.h"
+#include "common/conf.h"
#include "common/memmgr.h"
#include "common/showmsg.h"
@@ -141,7 +142,9 @@ static void geoip_init(void)
geoip->data->active = true;
- db = fopen("./db/GeoIP.dat","rb");
+ char file_path[256];
+ libconfig->format_db_path("GeoIP.dat", file_path, sizeof(file_path));
+ db = fopen(file_path, "rb");
if (db == NULL) {
ShowError("geoip_readdb: Error reading GeoIP.dat!\n");
geoip->final(false);
diff --git a/src/char/geoip.h b/src/char/geoip.h
index be9fe4fff..f8070dc2e 100644
--- a/src/char/geoip.h
+++ b/src/char/geoip.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_achievement.c b/src/char/int_achievement.c
index 14311ecf0..167178482 100644
--- a/src/char/int_achievement.c
+++ b/src/char/int_achievement.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
-* Copyright (C) 2017 Hercules Dev Team
+* Copyright (C) 2017-2020 Hercules Dev Team
* Copyright (C) Smokexyz
*
* Hercules is free software: you can redistribute it and/or modify
diff --git a/src/char/int_achievement.h b/src/char/int_achievement.h
index 4a44a798d..6c6ddc7f4 100644
--- a/src/char/int_achievement.h
+++ b/src/char/int_achievement.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
-* Copyright (C) 2017 Hercules Dev Team
+* Copyright (C) 2017-2020 Hercules Dev Team
* Copyright (C) Smokexyz
*
* Hercules is free software: you can redistribute it and/or modify
diff --git a/src/char/int_auction.c b/src/char/int_auction.c
index 1e5b0a06d..aa01872f9 100644
--- a/src/char/int_auction.c
+++ b/src/char/int_auction.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_auction.h b/src/char/int_auction.h
index 720efe22a..642fd21e3 100644
--- a/src/char/int_auction.h
+++ b/src/char/int_auction.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_clan.c b/src/char/int_clan.c
index 9fb8ad95e..87f21f3fd 100644
--- a/src/char/int_clan.c
+++ b/src/char/int_clan.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2017 Hercules Dev Team
+ * Copyright (C) 2017-2020 Hercules Dev Team
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_clan.h b/src/char/int_clan.h
index e7b44ecd3..abc026efb 100644
--- a/src/char/int_clan.h
+++ b/src/char/int_clan.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2017 Hercules Dev Team
+ * Copyright (C) 2017-2020 Hercules Dev Team
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c
index 175007b66..76ea7d56f 100644
--- a/src/char/int_elemental.c
+++ b/src/char/int_elemental.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h
index 3172dcacf..8c326faef 100644
--- a/src/char/int_elemental.h
+++ b/src/char/int_elemental.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 9c0be1629..af2088403 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -319,8 +319,8 @@ static int inter_guild_tosql(struct guild *g, int flag)
SQL->EscapeStringLen(inter->sql_handle, esc_name, e->name, strnlen(e->name, NAME_LENGTH));
SQL->EscapeStringLen(inter->sql_handle, esc_mes, e->mes, strnlen(e->mes, sizeof(e->mes)));
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`name`,`mes`) "
- "VALUES ('%d','%d','%s','%s')", guild_expulsion_db, g->guild_id, e->account_id, esc_name, esc_mes) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`, `char_id`, `name`,`mes`) "
+ "VALUES ('%d','%d','%d','%s','%s')", guild_expulsion_db, g->guild_id, e->account_id, e->char_id, esc_name, esc_mes) )
Sql_ShowDebug(inter->sql_handle);
}
}
@@ -444,8 +444,14 @@ static struct guild *inter_guild_fromsql(int guild_id)
m->position = MAX_GUILDPOSITION - 1;
SQL->GetData(inter->sql_handle, 11, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
SQL->GetData(inter->sql_handle, 12, &data, NULL);
- if (data != NULL)
+ if (data != NULL) {
m->last_login = atoi(data);
+ // 2036-12-31
+ if (m->last_login > 2114283600) {
+ ShowError("Last login time bigger than allowd value in %d:%s: %u\n", guild_id, g->name, m->last_login);
+ m->last_login = 0;
+ }
+ }
m->modified = GS_MEMBER_UNMODIFIED;
}
@@ -488,7 +494,7 @@ static struct guild *inter_guild_fromsql(int guild_id)
}
//printf("- Read guild_expulsion %d from sql \n",guild_id);
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`name`,`mes` FROM `%s` WHERE `guild_id`='%d'", guild_expulsion_db, guild_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`char_id`,`name`,`mes` FROM `%s` WHERE `guild_id`='%d'", guild_expulsion_db, guild_id) )
{
Sql_ShowDebug(inter->sql_handle);
aFree(g);
@@ -499,8 +505,9 @@ static struct guild *inter_guild_fromsql(int guild_id)
struct guild_expulsion *e = &g->expulsion[i];
SQL->GetData(inter->sql_handle, 0, &data, NULL); e->account_id = atoi(data);
- SQL->GetData(inter->sql_handle, 1, &data, &len); memcpy(e->name, data, min(len, NAME_LENGTH));
- SQL->GetData(inter->sql_handle, 2, &data, &len); memcpy(e->mes, data, min(len, sizeof(e->mes)));
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); e->char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, &len); memcpy(e->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 3, &data, &len); memcpy(e->mes, data, min(len, sizeof(e->mes)));
}
//printf("- Read guild_skill %d from sql \n",guild_id);
@@ -740,7 +747,7 @@ static int inter_guild_sql_init(void)
inter_guild->castle_db = idb_alloc(DB_OPT_RELEASE_DATA);
//Read exp file
- sv->readdb("db", DBPATH"exp_guild.txt", ',', 1, 1, MAX_GUILDLEVEL, inter_guild->exp_parse_row);
+ sv->readdb(chr->db_path, DBPATH"exp_guild.txt", ',', 1, 1, MAX_GUILDLEVEL, inter_guild->exp_parse_row);
timer->add_func_list(inter_guild->save_timer, "inter_guild->save_timer");
timer->add(timer->gettick() + 10000, inter_guild->save_timer, 0, 0);
@@ -1038,6 +1045,7 @@ static bool inter_guild_leave(int guild_id, int account_id, int char_id, int fla
}
// Save the expulsion entry
g->expulsion[j].account_id = account_id;
+ g->expulsion[j].char_id = char_id;
safestrncpy(g->expulsion[j].name, g->member[i].name, NAME_LENGTH);
safestrncpy(g->expulsion[j].mes, mes, 40);
}
@@ -1604,7 +1612,6 @@ static int inter_guild_parse_frommap(int fd)
case 0x3034: mapif->parse_GuildLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOB(fd,14), RFIFOP(fd,15)); break;
case 0x3035: mapif->parse_GuildChangeMemberInfoShort(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOL(fd,15),RFIFOL(fd,19)); break;
case 0x3036: mapif->parse_BreakGuild(fd,RFIFOL(fd,2)); break;
- case 0x3037: mapif->parse_GuildMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12), RFIFOW(fd,2)-12); break;
case 0x3039: mapif->parse_GuildBasicInfoChange(fd, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOP(fd,10), RFIFOW(fd,2)-10); break;
case 0x303A: mapif->parse_GuildMemberInfoChange(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOL(fd,12), RFIFOW(fd,16), RFIFOP(fd,18), RFIFOW(fd,2)-18); break;
case 0x303B: mapif->parse_GuildPosition(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12)); break;
diff --git a/src/char/int_guild.h b/src/char/int_guild.h
index 4ed0f526e..252a4970f 100644
--- a/src/char/int_guild.h
+++ b/src/char/int_guild.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_homun.c b/src/char/int_homun.c
index 5a1c9d23f..52418a1fa 100644
--- a/src/char/int_homun.c
+++ b/src/char/int_homun.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_homun.h b/src/char/int_homun.h
index 8eba66963..f68dfb4e4 100644
--- a/src/char/int_homun.h
+++ b/src/char/int_homun.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_mail.c b/src/char/int_mail.c
index e0625fcab..5a698eb3c 100644
--- a/src/char/int_mail.c
+++ b/src/char/int_mail.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_mail.h b/src/char/int_mail.h
index 95934d0a1..8fd6e70a5 100644
--- a/src/char/int_mail.h
+++ b/src/char/int_mail.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c
index 21bfb5538..a39bd9ad6 100644
--- a/src/char/int_mercenary.c
+++ b/src/char/int_mercenary.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h
index 6291bfcf6..85292938f 100644
--- a/src/char/int_mercenary.h
+++ b/src/char/int_mercenary.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_party.c b/src/char/int_party.c
index 8ee03ecc5..c16eea34e 100644
--- a/src/char/int_party.c
+++ b/src/char/int_party.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -42,83 +42,139 @@
static struct inter_party_interface inter_party_s;
struct inter_party_interface *inter_party;
-//Updates party's level range and unsets even share if broken.
+/**
+ * Updates party's level range and disables even share if requirements are not fulfilled.
+ *
+ * @param p The party.
+ * @return 0 on failure, 1 on success.
+ *
+ **/
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++){
- /**
- * - If not online OR if it's a family party and this is the child (doesn't affect exp range)
- **/
- if(!p->party.member[i].online || p->party.member[i].char_id == p->family )
- continue;
- lv=p->party.member[i].lv;
- if (lv < p->min_lv) p->min_lv = lv;
- if (lv > p->max_lv) p->max_lv = lv;
+ p->min_lv = MAX_LEVEL;
+ p->max_lv = 1;
+
+ for (int i = 0; i < MAX_PARTY; i++) {
+ if (p->party.member[i].online == 0 || p->party.member[i].char_id == p->family)
+ continue; /// If not online OR if it's a family party and this is the child, don't affect exp range.
+
+ p->min_lv = min(p->min_lv, p->party.member[i].lv);
+ p->max_lv = max(p->max_lv, p->party.member[i].lv);
}
- if (p->party.exp && !inter_party->check_exp_share(p)) {
+ if (p->party.exp == 1 && inter_party->check_exp_share(p) == 0) {
p->party.exp = 0;
mapif->party_optionchanged(0, &p->party, 0, 0);
return 0;
}
+
return 1;
}
-//Calculates the state of a party.
+
+/**
+ * Checks if a party is a family state party. (Family share feature.)
+ * Conditions for a family state party:
+ * - All party members have to belong to the same family. Not even offline strangers are allowed.
+ * So only parties with 2 or 3 members come in question.
+ * - At least one parent has to be on the same map with the child.
+ * - Parents within the party have to be level 70 or higher, even when offline.
+ *
+ * @param p The party.
+ * @return The child's char ID on success, otherwise 0.
+ *
+ **/
+static int inter_party_is_family_party(struct party_data *p)
+{
+ nullpo_ret(p);
+
+ if (p->size < 2 || p->size > 3 || p->party.count < 2)
+ return 0;
+
+ int child_id = 0;
+
+ for (int i = 0; i < MAX_PARTY - 1; i++) {
+ if (p->party.member[i].online == 0)
+ continue;
+
+ struct mmo_charstatus *char_i = idb_get(chr->char_db_, p->party.member[i].char_id);
+
+ if (char_i == NULL)
+ continue;
+
+ for (int j = i + 1; j < MAX_PARTY; j++) {
+ if (p->party.member[j].online == 0)
+ continue;
+
+ struct mmo_charstatus *char_j = idb_get(chr->char_db_, p->party.member[j].char_id);
+
+ if (char_j == NULL)
+ continue;
+
+ if (p->party.member[i].map != p->party.member[j].map)
+ continue;
+
+ if (char_i->char_id == char_j->child && char_j->base_level >= 70)
+ child_id = char_i->char_id;
+
+ if (char_j->char_id == char_i->child && char_i->base_level >= 70)
+ child_id = char_j->char_id;
+
+ if (child_id != 0)
+ break;
+ }
+
+ if (child_id != 0)
+ break;
+ }
+
+ if (child_id != 0 && p->size > 2) {
+ for (int i = 0; i < MAX_PARTY; i++) {
+ struct mmo_charstatus *party_member = idb_get(chr->char_db_, p->party.member[i].char_id);
+
+ /// Check if there is a stranger within the party.
+ if (party_member != NULL && party_member->char_id != child_id && party_member->child != child_id) {
+ child_id = 0; /// Stranger detected.
+ break;
+ }
+
+ /// Check if there is a parents with level lower than 70 within the party.
+ if (party_member != NULL && party_member->child == child_id && party_member->base_level < 70) {
+ child_id = 0; /// Parent with level lower than 70 detected.
+ break;
+ }
+ }
+ }
+
+ return child_id;
+}
+
+/**
+ * Calculates the state of a party.
+ *
+ * @param p The party.
+ *
+ **/
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 =
- p->size =
- p->family = 0;
-
- //Check party size
- for(i=0;i<MAX_PARTY;i++){
- if (!p->party.member[i].lv) continue;
+
+ p->party.count = 0;
+ p->size = 0;
+
+ for (int i = 0; i < MAX_PARTY; i++) {
+ if (p->party.member[i].lv == 0) /// Is this even possible? [Kenpachi]
+ continue;
+
p->size++;
- if(p->party.member[i].online)
+
+ if (p->party.member[i].online == 1)
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 >= JOB_BABY && p->party.member[0].class <= JOB_SUPER_BABY) //first slot is the child?
- p->family = p->party.member[0].char_id;
- else
- p->family = p->party.member[1].char_id;
- } else if( p->size == 3 ) {
- //Check Family State.
- p->family = chr->char_family(
- p->party.member[0].char_id,
- p->party.member[1].char_id,
- p->party.member[2].char_id
- );
- }
- //max/min levels.
- for (i = 0; i < MAX_PARTY; i++) {
- unsigned int lv = p->party.member[i].lv;
- if (!lv) continue;
- if (p->party.member[i].online
- && p->party.member[i].char_id != p->family /* In families, the kid is not counted towards exp share rules. */
- ) {
- if( lv < p->min_lv ) p->min_lv=lv;
- if( p->max_lv < lv ) p->max_lv=lv;
- }
- }
- if (p->party.exp && !inter_party->check_exp_share(p)) {
- p->party.exp = 0; //Set off even share.
- mapif->party_optionchanged(0, &p->party, 0, 0);
- }
- return;
+ p->family = inter_party->is_family_party(p);
+ inter_party->check_lv(p);
}
// Save party to mysql
@@ -196,6 +252,39 @@ static int inter_party_tosql(struct party *p, int flag, int index)
return 1;
}
+/**
+ * Updates the `char`.`party_id` column and removes party data from memory.
+ * Sets the party ID of all characters whose party ID matches the passed one to 0.
+ * Calls idb_remove() to remove party data from memory.
+ *
+ * @param party_id The party ID.
+ * @return 0 on failure, 1 on success.
+ *
+ **/
+static int inter_party_del_nonexistent_party(int party_id)
+{
+ struct SqlStmt *stmt = SQL->StmtMalloc(inter->sql_handle);
+
+ if (stmt == NULL) {
+ SqlStmt_ShowDebug(stmt);
+ return 0;
+ }
+
+ const char *query = "UPDATE `%s` SET `party_id`='0' WHERE `party_id`=?";
+
+ if (SQL_ERROR == SQL->StmtPrepare(stmt, query, char_db)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_UINT32, &party_id, sizeof(party_id))
+ || SQL_ERROR == SQL->StmtExecute(stmt)) {
+ SqlStmt_ShowDebug(stmt);
+ SQL->StmtFree(stmt);
+ return 0;
+ }
+
+ idb_remove(inter_party->db, party_id);
+
+ return 1;
+}
+
// Read party from mysql
static struct party_data *inter_party_fromsql(int party_id)
{
@@ -314,11 +403,18 @@ static struct party_data *inter_party_search_partyname(const char *const str)
return p;
}
-// Returns whether this party can keep having exp share or not.
+/**
+ * Checks if a party fulfills the requirements to share EXP.
+ *
+ * @param p The party.
+ * @return 1 if party can share EXP, otherwise 0.
+ *
+ **/
static 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);
+
+ return (p->party.count < 2 || p->family != 0 || p->max_lv - p->min_lv <= party_share_level);
}
// Is there any member in the party?
@@ -389,36 +485,38 @@ static struct party_data *inter_party_create(const char *name, int item, int ite
return p;
}
-// Add a player to party request
+/**
+ * Add a player to party request.
+ *
+ * @param party_id The ID of the party.
+ * @param member The member to add.
+ * @return true on success, otherwise false.
+ *
+ **/
static bool inter_party_add_member(int party_id, const struct party_member *member)
{
- struct party_data *p;
- int i;
+ nullpo_retr(false, member);
- nullpo_ret(member);
- p = inter_party->fromsql(party_id);
- if( p == NULL || p->size == MAX_PARTY ) {
+ if (party_id < 1) /// Invalid party ID.
return false;
- }
- ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == 0 );
- if (i == MAX_PARTY) {
- // Party full
+ struct party_data *p = inter_party->fromsql(party_id);
+
+ if (p == NULL) { /// Party does not exist.
+ inter_party->del_nonexistent_party(party_id);
return false;
}
+ int i;
+
+ ARR_FIND(0, MAX_PARTY, i, p->party.member[i].account_id == 0);
+
+ if (i == MAX_PARTY) /// Party is full.
+ return false;
+
memcpy(&p->party.member[i], member, sizeof(struct party_member));
p->party.member[i].leader = 0;
- if (p->party.member[i].online) p->party.count++;
- p->size++;
- if (p->size == 2 || p->size == 3) // Check family state. And also accept either of their Parents. [RoM]
- inter_party->calc_state(p);
- else //Check even share range.
- if (member->lv < p->min_lv || member->lv > p->max_lv || p->family) {
- if (p->family) p->family = 0; //Family state broken.
- inter_party->check_lv(p);
- }
-
+ inter_party->calc_state(p); /// Count online/offline members and check family state and even share range.
mapif->party_info(-1, &p->party, 0);
inter_party->tosql(&p->party, PS_ADDMEMBER, i);
@@ -446,103 +544,92 @@ static bool inter_party_change_option(int party_id, int account_id, int exp, int
return true;
}
-//Request leave party
+/**
+ * Leave party request.
+ *
+ * @param party_id The ID of the party.
+ * @param account_id The account ID of the leaving character.
+ * @param char_id The char ID of the leaving character.
+ * @return true on success, otherwise false.
+ *
+ **/
static bool inter_party_leave(int party_id, int account_id, int char_id)
{
- struct party_data *p;
- int i,j;
+ if (party_id < 1) /// Invalid party ID.
+ return false;
- p = inter_party->fromsql(party_id);
- if( p == NULL )
- {// Party does not exists?
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
- Sql_ShowDebug(inter->sql_handle);
+ struct party_data *p = inter_party->fromsql(party_id);
+
+ if (p == NULL) { /// Party does not exist.
+ inter_party->del_nonexistent_party(party_id);
return false;
}
- for (i = 0; i < MAX_PARTY; i++) {
- if(p->party.member[i].account_id == account_id &&
- p->party.member[i].char_id == char_id) {
- break;
- }
- }
- if (i >= MAX_PARTY)
- return false; //Member not found?
+ int i;
+
+ ARR_FIND(0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id);
+
+ if (i == MAX_PARTY) /// Character not found in party.
+ return false;
mapif->party_withdraw(party_id, account_id, char_id);
- j = p->party.member[i].lv;
- if (p->party.member[i].online > 0)
- p->party.count--;
+ if (p->party.member[i].online == 1)
+ p->party.member[i].online = 0;
+
memset(&p->party.member[i], 0, sizeof(struct party_member));
- p->size--;
- if (j == p->min_lv || j == p->max_lv || p->family) {
- if(p->family) p->family = 0; //Family state broken.
- inter_party->check_lv(p);
- }
+ inter_party->calc_state(p); /// Count online/offline members and check family state and even share range.
+ inter_party->tosql(&p->party, PS_DELMEMBER, i);
- if (inter_party->check_empty(p) == 0) {
- inter_party->tosql(&p->party, PS_DELMEMBER, i);
+ if (inter_party->check_empty(p) == 0)
mapif->party_info(-1, &p->party, 0);
- }
+
return true;
}
-// When member goes to other map or levels up.
-static bool inter_party_change_map(int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv)
+/**
+ * Updates party data if a member changes map or levels up.
+ *
+ * @param party_id The ID of the party.
+ * @param account_id The character's account ID.
+ * @param char_id The character's char ID.
+ * @param map The character's map index.
+ * @param online The character's online state.
+ * @param lv The character's level.
+ * @return true on success, otherwise false.
+ *
+ **/
+static bool inter_party_change_map(int party_id, int account_id, int char_id, unsigned short map, int online, int lv)
{
- struct party_data *p;
- int i;
+ if (party_id < 1) /// Invalid party ID.
+ return false;
- p = inter_party->fromsql(party_id);
- if (p == NULL)
+ struct party_data *p = inter_party->fromsql(party_id);
+
+ if (p == NULL) { /// Party does not exist.
+ inter_party->del_nonexistent_party(party_id);
return false;
+ }
+
+ int i;
- for(i = 0; i < MAX_PARTY &&
- (p->party.member[i].account_id != account_id ||
- p->party.member[i].char_id != char_id); i++);
+ ARR_FIND(0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id);
- if (i == MAX_PARTY)
+ if (i == MAX_PARTY) /// Character not found in party.
return false;
if (p->party.member[i].online != online)
- {
p->party.member[i].online = online;
- if (online)
- p->party.count++;
- else
- p->party.count--;
- // Even share check situations: Family state (always breaks)
- // character logging on/off is max/min level (update level range)
- // or character logging on/off has a different level (update level range using new level)
- if (p->family ||
- (p->party.member[i].lv <= p->min_lv || p->party.member[i].lv >= p->max_lv) ||
- (p->party.member[i].lv != lv && (lv <= p->min_lv || lv >= p->max_lv))
- )
- {
- p->party.member[i].lv = lv;
- inter_party->check_lv(p);
- }
- //Send online/offline update.
- mapif->party_membermoved(&p->party, i);
- }
- if (p->party.member[i].lv != lv) {
- if(p->party.member[i].lv == p->min_lv ||
- p->party.member[i].lv == p->max_lv)
- {
- p->party.member[i].lv = lv;
- inter_party->check_lv(p);
- } else
- p->party.member[i].lv = lv;
- //There is no need to send level update to map servers
- //since they do nothing with it.
- }
+ if (p->party.member[i].lv != lv)
+ p->party.member[i].lv = lv;
- if (p->party.member[i].map != map) {
+ if (p->party.member[i].map != map)
p->party.member[i].map = map;
- mapif->party_membermoved(&p->party, i);
- }
+
+ inter_party->calc_state(p); /// Count online/offline members and check family state and even share range.
+ mapif->party_membermoved(&p->party, i); /// Send online/offline update.
+
return true;
}
@@ -599,7 +686,6 @@ static int inter_party_parse_frommap(int fd)
case 0x3024: mapif->parse_PartyLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break;
case 0x3025: mapif->parse_PartyChangeMap(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOW(fd,14), RFIFOB(fd,16), RFIFOW(fd,17)); break;
case 0x3026: mapif->parse_BreakParty(fd, RFIFOL(fd,2)); break;
- case 0x3027: mapif->parse_PartyMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12), RFIFOW(fd,2)-12); break;
case 0x3029: mapif->parse_PartyLeaderChange(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break;
default:
return 0;
@@ -607,98 +693,104 @@ static int inter_party_parse_frommap(int fd)
return 1;
}
+/**
+ * Sets the online state of a charcter within a party to online.
+ *
+ * @param char_id The character's char ID.
+ * @param party_id The ID of the party.
+ * @return 1 on success, otherwise 0.
+ *
+ **/
static int inter_party_CharOnline(int char_id, int party_id)
{
- struct party_data* p;
- int i;
-
- if( party_id == -1 )
- {// Get party_id from the database
+ if (party_id == INDEX_NOT_FOUND) { /// Get party_id from the database.
char* data;
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
- {
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id)) {
Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
- return 0; //Eh? No party?
+ if (SQL_SUCCESS != SQL->NextRow(inter->sql_handle))
+ return 0;
SQL->GetData(inter->sql_handle, 0, &data, NULL);
party_id = atoi(data);
SQL->FreeResult(inter->sql_handle);
}
- if (party_id == 0)
- return 0; //No party...
- p = inter_party->fromsql(party_id);
- if(!p) {
- ShowError("Character %d's party %d not found!\n", char_id, party_id);
+ if (party_id == 0) /// Character isn't member of a party.
return 0;
- }
- //Set member online
- for(i=0; i<MAX_PARTY; i++) {
- if (p->party.member[i].char_id == char_id) {
- if (!p->party.member[i].online) {
- p->party.member[i].online = 1;
- p->party.count++;
- if (p->party.member[i].lv < p->min_lv ||
- p->party.member[i].lv > p->max_lv)
- inter_party->check_lv(p);
- }
- break;
- }
+ struct party_data *p = inter_party->fromsql(party_id);
+
+ if (p == NULL) { /// Party does not exist.
+ inter_party->del_nonexistent_party(party_id);
+ return 0;
}
+
+ int i;
+
+ ARR_FIND(0, MAX_PARTY, i, p->party.member[i].char_id == char_id);
+
+ if (i == MAX_PARTY) /// Character not found in party.
+ return 0;
+
+ p->party.member[i].online = 1; /// Set member online.
+ inter_party->calc_state(p); /// Count online/offline members and check family state and even share range.
+
return 1;
}
+/**
+ * Sets the online state of a charcter within a party to offline.
+ *
+ * @param char_id The character's char ID.
+ * @param party_id The ID of the party.
+ * @return 1 on success, otherwise 0.
+ *
+ **/
static int inter_party_CharOffline(int char_id, int party_id)
{
- struct party_data *p=NULL;
- int i;
-
- if( party_id == -1 )
- {// Get guild_id from the database
+ if (party_id == INDEX_NOT_FOUND) { /// Get party_id from the database.
char* data;
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
- {
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id)) {
Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
- return 0; //Eh? No party?
+ if (SQL_SUCCESS != SQL->NextRow(inter->sql_handle))
+ return 0;
SQL->GetData(inter->sql_handle, 0, &data, NULL);
party_id = atoi(data);
SQL->FreeResult(inter->sql_handle);
}
- if (party_id == 0)
- return 0; //No party...
- //Character has a party, set character offline and check if they were the only member online
- if ((p = inter_party->fromsql(party_id)) == NULL)
+ if (party_id == 0) /// Character isn't member of a party.
return 0;
- //Set member offline
- for(i=0; i< MAX_PARTY; i++) {
- if(p->party.member[i].char_id == char_id)
- {
- p->party.member[i].online = 0;
- p->party.count--;
- if(p->party.member[i].lv == p->min_lv ||
- p->party.member[i].lv == p->max_lv)
- inter_party->check_lv(p);
- break;
- }
+ struct party_data *p = inter_party->fromsql(party_id);
+
+ if (p == NULL) { /// Party does not exist.
+ inter_party->del_nonexistent_party(party_id);
+ return 0;
}
- if(!p->party.count)
- //Parties don't have any data that needs be saved at this point... so just remove it from memory.
+ int i;
+
+ ARR_FIND(0, MAX_PARTY, i, p->party.member[i].char_id == char_id);
+
+ if (i == MAX_PARTY) /// Character not found in party.
+ return 0;
+
+ p->party.member[i].online = 0; /// Set member offline.
+ inter_party->calc_state(p); /// Count online/offline members and check family state and even share range.
+
+ if (p->party.count == 0) /// Parties don't have any data that needs be saved at this point... so just remove it from memory.
idb_remove(inter_party->db, party_id);
+
return 1;
}
@@ -712,8 +804,10 @@ void inter_party_defaults(void)
inter_party->sql_init = inter_party_sql_init;
inter_party->sql_final = inter_party_sql_final;
inter_party->check_lv = inter_party_check_lv;
+ inter_party->is_family_party = inter_party_is_family_party;
inter_party->calc_state = inter_party_calc_state;
inter_party->tosql = inter_party_tosql;
+ inter_party->del_nonexistent_party = inter_party_del_nonexistent_party;
inter_party->fromsql = inter_party_fromsql;
inter_party->search_partyname = inter_party_search_partyname;
inter_party->check_exp_share = inter_party_check_exp_share;
diff --git a/src/char/int_party.h b/src/char/int_party.h
index b9a888cca..0385b0e87 100644
--- a/src/char/int_party.h
+++ b/src/char/int_party.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,10 +38,11 @@ enum {
};
struct party_data {
- struct party party;
- unsigned int min_lv, max_lv;
- int family; //Is this party a family? if so, this holds the child id.
- unsigned char size; //Total size of party.
+ struct party party; // Party data.
+ int min_lv; // The lowest base level of all party members.
+ int max_lv; // The highest base level of all party members.
+ int family; // Is this party a family? If so, this holds the child's char ID.
+ int size; // Amount of party members, including offline members.
};
/**
@@ -51,8 +52,10 @@ struct inter_party_interface {
struct party_data *pt;
struct DBMap *db; // int party_id -> struct party_data*
int (*check_lv) (struct party_data *p);
+ int (*is_family_party) (struct party_data *p);
void (*calc_state) (struct party_data *p);
int (*tosql) (struct party *p, int flag, int index);
+ int (*del_nonexistent_party) (int party_id);
struct party_data* (*fromsql) (int party_id);
int (*sql_init) (void);
void (*sql_final) (void);
@@ -66,7 +69,7 @@ struct inter_party_interface {
struct party_data *(*create) (const char *name, int item, int item2, const struct party_member *leader);
bool (*add_member) (int party_id, const struct party_member *member);
bool (*change_option) (int party_id, int account_id, int exp, int item, int map_fd);
- bool (*change_map) (int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv);
+ bool (*change_map) (int party_id, int account_id, int char_id, unsigned short map, int online, int lv);
bool (*disband) (int party_id);
bool (*change_leader) (int party_id, int account_id, int char_id);
};
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index d31e7545c..8b42bac1d 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -43,97 +43,162 @@ struct inter_pet_interface *inter_pet;
/**
* Saves a pet to the SQL database.
*
- * @remark
- * In case of newly created pet, the pet ID is not updated to reflect the
- * newly assigned ID. The caller must do so.
+ * Table structure:
+ * `pet` (`pet_id`, `class`, `name`, `account_id`, `char_id`, `level`, `egg_id`, `equip`, `intimate`, `hungry`, `rename_flag`, `incubate`, `autofeed`)
+ *
+ * @remark In case of newly created pet, the pet ID is not updated to reflect the newly assigned ID. The caller must do so.
*
* @param p The pet data to save.
- * @return The ID of the saved pet.
- * @retval 0 in case of errors.
- */
+ * @return The ID of the saved pet, or 0 in case of errors.
+ *
+ **/
static int inter_pet_tosql(const 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
- int pet_id = 0, hungry = 0, intimate = 0;
-
nullpo_ret(p);
- SQL->EscapeStringLen(inter->sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
- hungry = cap_value(p->hungry, 0, 100);
- intimate = cap_value(p->intimate, 0, 1000);
-
- if (p->pet_id == 0) {
- // New pet.
- if (SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` "
- "(`class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`, `autofeed`) "
- "VALUES ('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
- pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
- p->equip, intimate, hungry, p->rename_flag, p->incubate, p->autofeed)) {
- Sql_ShowDebug(inter->sql_handle);
+ struct SqlStmt *stmt = SQL->StmtMalloc(inter->sql_handle);
+
+ if (stmt == NULL) {
+ SqlStmt_ShowDebug(stmt);
+ return 0;
+ }
+
+ int pet_id = 0;
+
+ if (p->pet_id == 0) { // New pet.
+ const char *query = "INSERT INTO `%s` "
+ "(`class`, `name`, `account_id`, `char_id`, `level`, `egg_id`, `equip`, "
+ "`intimate`, `hungry`, `rename_flag`, `incubate`, `autofeed`) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+
+ if (SQL_ERROR == SQL->StmtPrepare(stmt, query, pet_db) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT32, &p->class_, sizeof(p->class_)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 1, SQLDT_STRING, &p->name, strnlen(p->name, sizeof(p->name))) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 2, SQLDT_INT32, &p->account_id, sizeof(p->account_id)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 3, SQLDT_INT32, &p->char_id, sizeof(p->char_id)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 4, SQLDT_INT16, &p->level, sizeof(p->level)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 5, SQLDT_INT32, &p->egg_id, sizeof(p->egg_id)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 6, SQLDT_INT32, &p->equip, sizeof(p->equip)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 7, SQLDT_INT16, &p->intimate, sizeof(p->intimate)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 8, SQLDT_INT16, &p->hungry, sizeof(p->hungry)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 9, SQLDT_INT8, &p->rename_flag, sizeof(p->rename_flag)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 10, SQLDT_INT8, &p->incubate, sizeof(p->incubate)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 11, SQLDT_INT32, &p->autofeed, sizeof(p->autofeed)) ||
+ SQL_ERROR == SQL->StmtExecute(stmt)) {
+ SqlStmt_ShowDebug(stmt);
+ SQL->StmtFree(stmt);
return 0;
}
+
pet_id = (int)SQL->LastInsertId(inter->sql_handle);
- } else {
- // Update pet.
- if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incubate`='%d', `autofeed`='%d' WHERE `pet_id`='%d'",
- pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
- p->equip, intimate, hungry, p->rename_flag, p->incubate, p->autofeed, p->pet_id)) {
- Sql_ShowDebug(inter->sql_handle);
+ } else { // Update pet.
+ const char *query = "UPDATE `%s` SET "
+ "`class`=?, `name`=?, `account_id`=?, `char_id`=?, `level`=?, `egg_id`=?, `equip`=?, "
+ "`intimate`=?, `hungry`=?, `rename_flag`=?, `incubate`=?, `autofeed`=? "
+ "WHERE `pet_id`=?";
+
+ if (SQL_ERROR == SQL->StmtPrepare(stmt, query, pet_db) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT32, &p->class_, sizeof(p->class_)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 1, SQLDT_STRING, &p->name, strnlen(p->name, sizeof(p->name))) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 2, SQLDT_INT32, &p->account_id, sizeof(p->account_id)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 3, SQLDT_INT32, &p->char_id, sizeof(p->char_id)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 4, SQLDT_INT16, &p->level, sizeof(p->level)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 5, SQLDT_INT32, &p->egg_id, sizeof(p->egg_id)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 6, SQLDT_INT32, &p->equip, sizeof(p->equip)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 7, SQLDT_INT16, &p->intimate, sizeof(p->intimate)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 8, SQLDT_INT16, &p->hungry, sizeof(p->hungry)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 9, SQLDT_INT8, &p->rename_flag, sizeof(p->rename_flag)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 10, SQLDT_INT8, &p->incubate, sizeof(p->incubate)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 11, SQLDT_INT32, &p->autofeed, sizeof(p->autofeed)) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 12, SQLDT_INT32, &p->pet_id, sizeof(p->pet_id)) ||
+ SQL_ERROR == SQL->StmtExecute(stmt)) {
+ SqlStmt_ShowDebug(stmt);
+ SQL->StmtFree(stmt);
return 0;
}
+
pet_id = p->pet_id;
}
+ SQL->StmtFree(stmt);
+
if (chr->show_save_log)
ShowInfo("Pet saved %d - %s.\n", pet_id, p->name);
return pet_id;
}
+/**
+ * Loads a pet's data from the SQL database.
+ *
+ * Table structure:
+ * `pet` (`pet_id`, `class`, `name`, `account_id`, `char_id`, `level`, `egg_id`, `equip`, `intimate`, `hungry`, `rename_flag`, `incubate`, `autofeed`)
+ *
+ * @param pet_id The pet's ID.
+ * @param p The pet data to save the SQL data in.
+ * @return Always 0.
+ *
+ **/
static int inter_pet_fromsql(int pet_id, struct s_pet *p)
{
- char* data;
- size_t len;
+ nullpo_ret(p);
+
+ struct SqlStmt *stmt = SQL->StmtMalloc(inter->sql_handle);
+
+ if (stmt == NULL) {
+ SqlStmt_ShowDebug(stmt);
+ return 0;
+ }
#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`, `autofeed`)
+ const char *query = "SELECT "
+ "`class`, `name`, `account_id`, `char_id`, `level`, `egg_id`, `equip`, "
+ "`intimate`, `hungry`, `rename_flag`, `incubate`, `autofeed` "
+ "FROM `%s` WHERE `pet_id`=?";
+
+ if (SQL_ERROR == SQL->StmtPrepare(stmt, query, pet_db) ||
+ SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT32, &pet_id, sizeof(pet_id)) ||
+ SQL_ERROR == SQL->StmtExecute(stmt) ||
+ SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT32, &p->class_, sizeof(p->class_), NULL, NULL) ||
+ SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_STRING, &p->name, sizeof(p->name), NULL, NULL) ||
+ SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_INT32, &p->account_id, sizeof(p->account_id), NULL, NULL) ||
+ SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_INT32, &p->char_id, sizeof(p->char_id), NULL, NULL) ||
+ SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_INT16, &p->level, sizeof(p->level), NULL, NULL) ||
+ SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_INT32, &p->egg_id, sizeof(p->egg_id), NULL, NULL) ||
+ SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_INT32, &p->equip, sizeof(p->equip), NULL, NULL) ||
+ SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_INT16, &p->intimate, sizeof(p->intimate), NULL, NULL) ||
+ SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_INT16, &p->hungry, sizeof(p->hungry), NULL, NULL) ||
+ SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_INT8, &p->rename_flag, sizeof(p->rename_flag), NULL, NULL) ||
+ SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_INT8, &p->incubate, sizeof(p->incubate), NULL, NULL) ||
+ SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_INT32, &p->autofeed, sizeof(p->autofeed), NULL, NULL)) {
+ SqlStmt_ShowDebug(stmt);
+ SQL->StmtFree(stmt);
+ return 0;
+ }
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`,`autofeed` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
- {
- Sql_ShowDebug(inter->sql_handle);
+ if (SQL->StmtNumRows(stmt) < 1) {
+ ShowError("inter_pet_fromsql: Requested non-existant pet ID: %d\n", pet_id);
+ SQL->StmtFree(stmt);
return 0;
}
- if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
- {
- p->pet_id = pet_id;
- SQL->GetData(inter->sql_handle, 1, &data, NULL); p->class_ = atoi(data);
- SQL->GetData(inter->sql_handle, 2, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH));
- SQL->GetData(inter->sql_handle, 3, &data, NULL); p->account_id = atoi(data);
- SQL->GetData(inter->sql_handle, 4, &data, NULL); p->char_id = atoi(data);
- SQL->GetData(inter->sql_handle, 5, &data, NULL); p->level = atoi(data);
- SQL->GetData(inter->sql_handle, 6, &data, NULL); p->egg_id = atoi(data);
- SQL->GetData(inter->sql_handle, 7, &data, NULL); p->equip = atoi(data);
- SQL->GetData(inter->sql_handle, 8, &data, NULL); p->intimate = atoi(data);
- SQL->GetData(inter->sql_handle, 9, &data, NULL); p->hungry = atoi(data);
- SQL->GetData(inter->sql_handle, 10, &data, NULL); p->rename_flag = atoi(data);
- SQL->GetData(inter->sql_handle, 11, &data, NULL); p->incubate = atoi(data);
- SQL->GetData(inter->sql_handle, 12, &data, NULL); p->autofeed = atoi(data);
-
- SQL->FreeResult(inter->sql_handle);
-
- p->hungry = cap_value(p->hungry, 0, 100);
- p->intimate = cap_value(p->intimate, 0, 1000);
-
- if (chr->show_save_log)
- ShowInfo("Pet loaded (%d - %s).\n", pet_id, p->name);
+ if (SQL_ERROR == SQL->StmtNextRow(stmt)) {
+ SqlStmt_ShowDebug(stmt);
+ SQL->StmtFree(stmt);
+ return 0;
}
+
+ SQL->StmtFree(stmt);
+ p->pet_id = pet_id;
+
+ if (chr->show_save_log)
+ ShowInfo("Pet loaded %d - %s.\n", pet_id, p->name);
+
return 0;
}
//----------------------------------------------
@@ -160,41 +225,48 @@ static int inter_pet_delete(int pet_id)
return 0;
}
//------------------------------------------------------
+
+/**
+ * Creates a new pet and inserts its data into the `pet` SQL table.
+ *
+ * @param account_id The pet's master's account ID.
+ * @param char_id The pet's master's char ID.
+ * @param pet_class The pet's class/monster ID.
+ * @param pet_lv The pet's level.
+ * @param pet_egg_id The pet's egg's item ID.
+ * @param pet_equip The pet's equipment's item ID.
+ * @param intimate The pet's intimacy value.
+ * @param hungry The pet's hunger value.
+ * @param rename_flag The pet's rename flag.
+ * @param incubate The pet's incubate state.
+ * @param pet_name The pet's name.
+ * @return The created pet's data struct, or NULL in case of errors.
+ *
+ **/
static struct s_pet *inter_pet_create(int account_id, int char_id, int pet_class, int pet_lv, int pet_egg_id,
- int pet_equip, short intimate, short hungry, char rename_flag, char incubate, const char *pet_name)
+ int pet_equip, short intimate, short hungry, char rename_flag,
+ char incubate, const char *pet_name)
{
- nullpo_ret(pet_name);
+ nullpo_retr(NULL, pet_name);
+
memset(inter_pet->pt, 0, sizeof(struct s_pet));
safestrncpy(inter_pet->pt->name, pet_name, NAME_LENGTH);
- if(incubate == 1)
- inter_pet->pt->account_id = inter_pet->pt->char_id = 0;
- else {
- inter_pet->pt->account_id = account_id;
- inter_pet->pt->char_id = char_id;
- }
+ inter_pet->pt->account_id = (incubate == 1) ? 0 : account_id;
+ inter_pet->pt->char_id = (incubate == 1) ? 0 : char_id;
inter_pet->pt->class_ = pet_class;
inter_pet->pt->level = pet_lv;
inter_pet->pt->egg_id = pet_egg_id;
inter_pet->pt->equip = pet_equip;
- inter_pet->pt->intimate = intimate;
- inter_pet->pt->hungry = hungry;
+ inter_pet->pt->intimate = cap_value(intimate, PET_INTIMACY_NONE, PET_INTIMACY_MAX);
+ inter_pet->pt->hungry = cap_value(hungry, PET_HUNGER_STARVING, PET_HUNGER_STUFFED);
inter_pet->pt->rename_flag = rename_flag;
inter_pet->pt->incubate = incubate;
+ inter_pet->pt->pet_id = 0; // Signal NEW pet.
- if(inter_pet->pt->hungry < 0)
- inter_pet->pt->hungry = 0;
- else if(inter_pet->pt->hungry > 100)
- inter_pet->pt->hungry = 100;
- if(inter_pet->pt->intimate < 0)
- inter_pet->pt->intimate = 0;
- else if(inter_pet->pt->intimate > 1000)
- inter_pet->pt->intimate = 1000;
-
- inter_pet->pt->pet_id = 0; //Signal NEW pet.
if ((inter_pet->pt->pet_id = inter_pet->tosql(inter_pet->pt)) != 0)
return inter_pet->pt;
- else //Failed...
- return NULL;
+
+ return NULL;
}
static struct s_pet *inter_pet_load(int account_id, int char_id, int pet_id)
diff --git a/src/char/int_pet.h b/src/char/int_pet.h
index b5852d441..43360ccda 100644
--- a/src/char/int_pet.h
+++ b/src/char/int_pet.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_quest.c b/src/char/int_quest.c
index 0fa7771cb..4269b3da1 100644
--- a/src/char/int_quest.c
+++ b/src/char/int_quest.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_quest.h b/src/char/int_quest.h
index e71afc561..a5fb4805b 100644
--- a/src/char/int_quest.h
+++ b/src/char/int_quest.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_rodex.c b/src/char/int_rodex.c
index 5725c3777..0539eab7e 100644
--- a/src/char/int_rodex.c
+++ b/src/char/int_rodex.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2017 Hercules Dev Team
+ * Copyright (C) 2017-2020 Hercules Dev Team
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -346,11 +346,128 @@ static int64 inter_rodex_savemessage(struct rodex_message *msg)
return msg->id;
}
+static int64 inter_rodex_getzeny(int64 mail_id)
+{
+ Assert_retr(-1, mail_id > 0);
+
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `zeny`, `type` FROM `%s` WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id)) {
+ Sql_ShowDebug(inter->sql_handle);
+ } else {
+ if (SQL_SUCCESS == SQL->NextRow(inter->sql_handle)) {
+ char *data;
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
+ int64 zeny = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL);
+ uint8 type = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
+ if ((type & MAIL_TYPE_ZENY) == 0)
+ return -1;
+ return zeny;
+ }
+ }
+ SQL->FreeResult(inter->sql_handle);
+
+ return -1;
+}
+
+static int inter_rodex_getitems(int64 mail_id, struct rodex_item *items)
+{
+ Assert_retr(-1, mail_id > 0);
+ nullpo_retr(-1, items);
+
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `type` FROM `%s` WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id)) {
+ Sql_ShowDebug(inter->sql_handle);
+ return -1;
+ } else {
+ if (SQL_SUCCESS == SQL->NextRow(inter->sql_handle)) {
+ char *data;
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
+ uint8 type = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
+ if ((type & MAIL_TYPE_ITEM) == 0)
+ return -1;
+ } else {
+ SQL->FreeResult(inter->sql_handle);
+ return -1;
+ }
+ }
+
+
+ int itemsCount = 0;
+
+ struct SqlStmt *stmt_items = SQL->StmtMalloc(inter->sql_handle);
+
+ if (stmt_items == NULL) {
+ return -1;
+ }
+
+ StringBuf buf;
+ StrBuf->Init(&buf);
+
+ StrBuf->AppendStr(&buf, "SELECT `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `bound`, `unique_id`");
+ for (int i = 0; i < MAX_SLOTS; i++) {
+ StrBuf->Printf(&buf, ", `card%d`", i);
+ }
+ for (int i = 0; i < MAX_ITEM_OPTIONS; i++) {
+ StrBuf->Printf(&buf, ", `opt_idx%d`, `opt_val%d`", i, i);
+ }
+ StrBuf->Printf(&buf, "FROM `%s` WHERE mail_id = ? ORDER BY `mail_id` ASC", rodex_item_db);
+
+ struct item it = { 0 };
+
+ if (SQL_ERROR == SQL->StmtPrepareStr(stmt_items, StrBuf->Value(&buf))
+ || SQL_ERROR == SQL->StmtBindParam(stmt_items, 0, SQLDT_INT64, &mail_id, sizeof mail_id)
+ ) {
+ SqlStmt_ShowDebug(stmt_items);
+ }
+
+ if (SQL_ERROR == SQL->StmtExecute(stmt_items)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt_items, 0, SQLDT_INT, &it.nameid, sizeof it.nameid, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt_items, 1, SQLDT_SHORT, &it.amount, sizeof it.amount, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt_items, 2, SQLDT_UINT, &it.equip, sizeof it.equip, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt_items, 3, SQLDT_CHAR, &it.identify, sizeof it.identify, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt_items, 4, SQLDT_CHAR, &it.refine, sizeof it.refine, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt_items, 5, SQLDT_CHAR, &it.attribute, sizeof it.attribute, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt_items, 6, SQLDT_UINT, &it.expire_time, sizeof it.expire_time, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt_items, 7, SQLDT_UCHAR, &it.bound, sizeof it.bound, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt_items, 8, SQLDT_UINT64, &it.unique_id, sizeof it.unique_id, NULL, NULL)
+ ) {
+ SqlStmt_ShowDebug(stmt_items);
+ }
+ for (int i = 0; i < MAX_SLOTS; i++) {
+ if (SQL_ERROR == SQL->StmtBindColumn(stmt_items, 9 + i, SQLDT_INT, &it.card[i], sizeof it.card[i], NULL, NULL))
+ SqlStmt_ShowDebug(stmt_items);
+ }
+ for (int i = 0; i < MAX_ITEM_OPTIONS; i++) {
+ if (SQL_ERROR == SQL->StmtBindColumn(stmt_items, 9 + MAX_SLOTS + i * 2, SQLDT_INT16, &it.option[i].index, sizeof it.option[i].index, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt_items, 10 + MAX_SLOTS + i * 2, SQLDT_INT16, &it.option[i].value, sizeof it.option[i].value, NULL, NULL)
+ ) {
+ SqlStmt_ShowDebug(stmt_items);
+ }
+ }
+
+ for (int i = 0; i < RODEX_MAX_ITEM && SQL_SUCCESS == SQL->StmtNextRow(stmt_items); ++i) {
+ items[i].item = it;
+ items[i].idx = itemsCount;
+ itemsCount++;
+ }
+
+ SQL->StmtFreeResult(stmt_items);
+
+ StrBuf->Destroy(&buf);
+ SQL->StmtFree(stmt_items);
+
+ return itemsCount;
+}
+
/*==========================================
* Update/Delete mail
*------------------------------------------*/
-static bool inter_rodex_updatemail(int64 mail_id, int8 flag)
+static bool inter_rodex_updatemail(int fd, int account_id, int char_id, int64 mail_id, uint8 opentype, int8 flag)
{
+ Assert_retr(false, fd >= 0);
+ Assert_retr(false, account_id > 0);
+ Assert_retr(false, char_id > 0);
Assert_retr(false, mail_id > 0);
Assert_retr(false, flag >= 0 && flag <= 4);
@@ -361,17 +478,24 @@ static bool inter_rodex_updatemail(int64 mail_id, int8 flag)
break;
case 1: // Get Zeny
- if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `zeny` = 0, `type` = `type` & (~2) WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id))
+ {
+ const int64 zeny = inter_rodex->getzeny(mail_id);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `zeny` = 0, `type` = `type` & (~2) WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id)) {
Sql_ShowDebug(inter->sql_handle);
+ break;
+ }
+ mapif->rodex_getzenyack(fd, char_id, mail_id, opentype, zeny);
break;
-
+ }
case 2: // Get Items
+ {
+ struct rodex_item items[RODEX_MAX_ITEM];
+ const int count = inter_rodex->getitems(mail_id, &items[0]);
if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `mail_id` = '%"PRId64"'", rodex_item_db, mail_id))
Sql_ShowDebug(inter->sql_handle);
- if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `zeny` = 0, `type` = `type` & (~4) WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id))
- Sql_ShowDebug(inter->sql_handle);
+ mapif->rodex_getitemsack(fd, char_id, mail_id, opentype, count, &items[0]);
break;
-
+ }
case 3: // Delete Mail
if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id))
Sql_ShowDebug(inter->sql_handle);
@@ -429,4 +553,6 @@ void inter_rodex_defaults(void)
inter_rodex->hasnew = inter_rodex_hasnew;
inter_rodex->checkname = inter_rodex_checkname;
inter_rodex->updatemail = inter_rodex_updatemail;
+ inter_rodex->getzeny = inter_rodex_getzeny;
+ inter_rodex->getitems = inter_rodex_getitems;
}
diff --git a/src/char/int_rodex.h b/src/char/int_rodex.h
index 7fae77d8d..44b9ce477 100644
--- a/src/char/int_rodex.h
+++ b/src/char/int_rodex.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2017 Hercules Dev Team
+ * Copyright (C) 2017-2020 Hercules Dev Team
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -36,7 +36,9 @@ struct inter_rodex_interface {
bool (*hasnew) (int char_id, int account_id);
bool (*checkname) (const char *name, int *target_char_id, int *target_class, int *target_level);
int64 (*savemessage) (struct rodex_message* msg);
- bool (*updatemail) (int64 mail_id, int8 flag);
+ bool (*updatemail) (int fd, int account_id, int char_id, int64 mail_id, uint8 opentype, int8 flag);
+ int64 (*getzeny) (int64 mail_id);
+ int (*getitems) (int64 mail_id, struct rodex_item *items);
};
#ifdef HERCULES_CORE
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index 130df5515..d82440270 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/int_storage.h b/src/char/int_storage.h
index 918927620..886c54e15 100644
--- a/src/char/int_storage.h
+++ b/src/char/int_storage.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/inter.c b/src/char/inter.c
index 1f1750e32..2d8d06a9c 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -53,9 +53,6 @@
#include <stdio.h>
#include <stdlib.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
-
static struct inter_interface inter_s;
struct inter_interface *inter;
@@ -70,21 +67,18 @@ int party_share_level = 10;
// recv. packet list
static int inter_recv_packet_length[] = {
- -1,-1, 7,-1, -1,13,36, (2 + 4 + 4 + 4 + NAME_LENGTH), 0, 0, 0, 0, 0, 0, 0, 0, // 3000-
+ 0, 0, 0, 0, -1,13,36, (2 + 4 + 4 + 4 + NAME_LENGTH), 0, 0, 0, 0, 0, 0, 0, 0, // 3000-
6,-1, 6,-1, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, // 3010- Account Storage, Achievements [Smokexyz]
- -1,10,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, // 3020- Party
- -1, 6,-1,-1, 55,23, 6,-1, 14,-1,-1,-1, 18,19,186,-1, // 3030-
+ -1,10,-1,14, 14,19, 6, 0, 14,14, 0, 0, 0, 0, 0, 0, // 3020- Party
+ -1, 6,-1,-1, 55,23, 6, 0, 14,-1,-1,-1, 18,19,186,-1, // 3030-
-1, 9, 0, 0, 10,10, 0, 0, 7, 6,10,10, 10,-1, 0, 0, // 3040- Clan System(3044-3045)
-1,-1,10,10, 0,-1,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3050- Auction System [Zephyrus], Item Bound [Mhalicot]
6,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3060- Quest system [Kevin] [Inkfish]
-1,10, 6,-1, 0, 0, 0, 0, 0, 0, 0, 0, -1,10, 6,-1, // 3070- Mercenary packets [Zephyrus], Elemental packets [pakpil]
56,14,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3080-
- -1,10,-1, 6, 0, 20,10,11, -1,6 + NAME_LENGTH, 0, 0, 0, 0, 0, 0, // 3090- Homunculus packets [albator], RoDEX packets
+ -1,10,-1, 6, 0, 20,10,20, -1,6 + NAME_LENGTH, 0, 0, 0, 0, 0, 0, // 3090- Homunculus packets [albator], RoDEX packets
};
-static struct DBMap *wis_db = NULL; // int wis_id -> struct WisData*
-static int wis_dellist[WISDELLIST_MAX], wis_delnum;
-
#define MAX_JOB_NAMES 150
static char *msg_table[MAX_JOB_NAMES]; // messages 550 ~ 699 are job names
@@ -964,7 +958,6 @@ static int inter_init_sql(const char *file)
Sql_ShowDebug(inter->sql_handle);
}
- wis_db = idb_alloc(DB_OPT_RELEASE_DATA);
inter_guild->sql_init();
inter_storage->sql_init();
inter_party->sql_init();
@@ -985,8 +978,6 @@ static int inter_init_sql(const char *file)
// finalize
static void inter_final(void)
{
- wis_db->destroy(wis_db, NULL);
-
inter_guild->sql_final();
inter_storage->sql_final();
inter_party->sql_final();
@@ -1011,77 +1002,6 @@ static int inter_mapif_init(int fd)
//--------------------------------------------------------
-/**
- * Existence check of WISP data
- * @see DBApply
- */
-static int inter_check_ttl_wisdata_sub(union DBKey key, struct 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)
- wis_dellist[wis_delnum++] = wd->id;
-
- return 0;
-}
-
-static int inter_check_ttl_wisdata(void)
-{
- int64 tick = timer->gettick();
- int i;
-
- do {
- wis_delnum = 0;
- wis_db->foreach(wis_db, inter->check_ttl_wisdata_sub, tick);
- for(i = 0; i < wis_delnum; i++) {
- struct WisData *wd = (struct WisData*)idb_get(wis_db, wis_dellist[i]);
- ShowWarning("inter: wis data id=%d time out : from %s to %s\n", wd->id, wd->src, wd->dst);
- // removed. not send information after a timeout. Just no answer for the player
- //mapif->wis_end(wd, 1); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target
- idb_remove(wis_db, wd->id);
- }
- } while(wis_delnum >= WISDELLIST_MAX);
-
- return 0;
-}
-
-static struct WisData *inter_add_wisdata(int fd, const unsigned char *src, const unsigned char *dst, const unsigned char *msg, int msg_len)
-{
- static int wisid = 0;
- struct WisData *wd;
-
- CREATE(wd, struct WisData, 1);
-
- // Whether the failure of previous wisp/page transmission (timeout)
- inter->check_ttl_wisdata();
-
- wd->id = ++wisid;
- wd->fd = fd;
- wd->len = msg_len;
- memcpy(wd->src, src, NAME_LENGTH);
- memcpy(wd->dst, dst, NAME_LENGTH);
- memcpy(wd->msg, msg, wd->len);
- wd->tick = timer->gettick();
- idb_put(wis_db, wd->id, wd);
-
- return wd;
-}
-
-static struct WisData *inter_get_wisdata(int id)
-{
- return idb_get(wis_db, id);
-}
-
-static void inter_remove_wisdata(int id)
-{
- idb_remove(wis_db, id);
-}
-
-//--------------------------------------------------------
-
/// Returns the length of the next complete packet to process,
/// or 0 if no complete packet exists in the queue.
///
@@ -1115,10 +1035,6 @@ static int inter_parse_frommap(int fd)
return 2;
switch(cmd) {
- case 0x3000: mapif->parse_broadcast(fd); break;
- case 0x3001: mapif->parse_WisRequest(fd); break;
- case 0x3002: mapif->parse_WisReply(fd); break;
- case 0x3003: mapif->parse_WisToGM(fd); break;
case 0x3004: mapif->parse_Registry(fd); break;
case 0x3005: mapif->parse_RegistryRequest(fd); break;
case 0x3006: mapif->parse_NameChangeRequest(fd); break;
@@ -1167,8 +1083,6 @@ void inter_defaults(void)
inter->log = inter_log;
inter->init_sql = inter_init_sql;
inter->mapif_init = inter_mapif_init;
- inter->check_ttl_wisdata_sub = inter_check_ttl_wisdata_sub;
- inter->check_ttl_wisdata = inter_check_ttl_wisdata;
inter->check_length = inter_check_length;
inter->parse_frommap = inter_parse_frommap;
inter->final = inter_final;
@@ -1176,7 +1090,4 @@ void inter_defaults(void)
inter->config_read_connection = inter_config_read_connection;
inter->accinfo = inter_accinfo;
inter->accinfo2 = inter_accinfo2;
- inter->add_wisdata = inter_add_wisdata;
- inter->get_wisdata = inter_get_wisdata;
- inter->remove_wisdata = inter_remove_wisdata;
}
diff --git a/src/char/inter.h b/src/char/inter.h
index 94ee3ab60..36d28b656 100644
--- a/src/char/inter.h
+++ b/src/char/inter.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,12 +30,6 @@
struct Sql; // common/sql.h
struct config_t; // common/conf.h
-struct WisData {
- int id, fd, count, len;
- int64 tick;
- unsigned char src[24], dst[24], msg[512];
-};
-
/**
* inter interface
**/
@@ -54,8 +48,6 @@ struct inter_interface {
int (*log) (char* fmt, ...);
int (*init_sql) (const char *file);
int (*mapif_init) (int fd);
- int (*check_ttl_wisdata_sub) (union DBKey key, struct DBData *data, va_list ap);
- int (*check_ttl_wisdata) (void);
int (*check_length) (int fd, int length);
int (*parse_frommap) (int fd);
void (*final) (void);
@@ -66,9 +58,6 @@ struct inter_interface {
void (*accinfo2) (bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass,
const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate,
int group_id, int logincount, int state);
- struct WisData *(*add_wisdata) (int fd, const unsigned char *src, const unsigned char *dst, const unsigned char *msg, int msg_len);
- struct WisData *(*get_wisdata) (int id);
- void (*remove_wisdata) (int id);
};
#ifdef HERCULES_CORE
diff --git a/src/char/loginif.c b/src/char/loginif.c
index a093c8cf5..554513420 100644
--- a/src/char/loginif.c
+++ b/src/char/loginif.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/loginif.h b/src/char/loginif.h
index 5dfedb952..55fd03f83 100644
--- a/src/char/loginif.h
+++ b/src/char/loginif.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/mapif.c b/src/char/mapif.c
index fb904a46d..9077afae4 100644
--- a/src/char/mapif.c
+++ b/src/char/mapif.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -596,22 +596,6 @@ static int mapif_guild_broken(int guild_id, int flag)
return 0;
}
-// Send guild message
-static int mapif_guild_message(int guild_id, int account_id, const char *mes, int len, int sfd)
-{
- unsigned char buf[512];
- nullpo_ret(mes);
- if (len > 500)
- len = 500;
- WBUFW(buf, 0) = 0x3837;
- WBUFW(buf, 2) = len + 12;
- WBUFL(buf, 4) = guild_id;
- WBUFL(buf, 8) = account_id;
- memcpy(WBUFP(buf, 12), mes, len);
- mapif->sendallwos(sfd, buf, len + 12);
- return 0;
-}
-
// Send basic info
static int mapif_guild_basicinfochanged(int guild_id, int type, const void *data, int len)
{
@@ -810,12 +794,6 @@ static int mapif_parse_BreakGuild(int fd, int guild_id)
return 0;
}
-// Forward Guild message to others map servers
-static int mapif_parse_GuildMessage(int fd, int guild_id, int account_id, const char *mes, int len)
-{
- return mapif->guild_message(guild_id,account_id,mes,len, fd);
-}
-
/**
* Changes basic guild information
* The types are available in mmo.h::guild_basic_info
@@ -1319,20 +1297,6 @@ static int mapif_party_broken(int party_id, int flag)
return 0;
}
-//Remarks in the party
-static int mapif_party_message(int party_id, int account_id, const 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;
- WBUFL(buf, 8) = account_id;
- memcpy(WBUFP(buf, 12), mes, len);
- mapif->sendallwos(sfd, buf, len + 12);
- return 0;
-}
-
// Create Party
static int mapif_parse_CreateParty(int fd, const char *name, int item, int item2, const struct party_member *leader)
{
@@ -1408,12 +1372,6 @@ static int mapif_parse_BreakParty(int fd, int party_id)
return 0;
}
-//Party sending the message
-static int mapif_parse_PartyMessage(int fd, int party_id, int account_id, const char *mes, int len)
-{
- return mapif->party_message(party_id, account_id, mes, len, fd);
-}
-
static int mapif_parse_PartyLeaderChange(int fd, int party_id, int account_id, int char_id)
{
if (!inter_party->change_leader(party_id, account_id, char_id))
@@ -1744,10 +1702,13 @@ static void mapif_rodex_sendhasnew(int fd, int char_id, bool has_new)
*------------------------------------------*/
static void mapif_parse_rodex_updatemail(int fd)
{
- int64 mail_id = RFIFOL(fd, 2);
- int8 flag = RFIFOB(fd, 10);
+ int account_id = RFIFOL(fd, 2);
+ int char_id = RFIFOL(fd, 6);
+ int64 mail_id = RFIFOQ(fd, 10);
+ uint8 opentype = RFIFOB(fd, 18);
+ int8 flag = RFIFOB(fd, 19);
- inter_rodex->updatemail(mail_id, flag);
+ inter_rodex->updatemail(fd, account_id, char_id, mail_id, opentype, flag);
}
/*==========================================
@@ -2031,67 +1992,6 @@ static void mapif_parse_accinfo(int fd)
inter->accinfo(u_fd, aid, castergroup, query, fd);
}
-// broadcast sending
-static int mapif_broadcast(const unsigned char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, int sfd)
-{
- 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;
- WBUFW(buf, 8) = fontType;
- WBUFW(buf, 10) = fontSize;
- WBUFW(buf, 12) = fontAlign;
- WBUFW(buf, 14) = fontY;
- memcpy(WBUFP(buf, 16), mes, len - 16);
- mapif->sendallwos(sfd, buf, len);
-
- aFree(buf);
- return 0;
-}
-
-// Wis sending
-static 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 < 0)
- wd->len = 0;
- if (wd->len >= (int)sizeof(wd->msg) - 1)
- wd->len = (int)sizeof(wd->msg) - 1;
-
- WBUFW(buf, 0) = 0x3801;
- WBUFW(buf, 2) = 56 + wd->len;
- WBUFL(buf, 4) = wd->id;
- memcpy(WBUFP(buf, 8), wd->src, NAME_LENGTH);
- memcpy(WBUFP(buf, 32), wd->dst, NAME_LENGTH);
- memcpy(WBUFP(buf, 56), wd->msg, wd->len);
- wd->count = mapif->sendall(buf, WBUFW(buf, 2));
-
- return 0;
-}
-
-static void mapif_wis_response(int fd, const 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;
- mapif->send(fd, buf, 27);
-}
-
-// Wis sending result
-static int mapif_wis_end(struct WisData *wd, int flag)
-{
- nullpo_ret(wd);
- mapif->wis_response(wd->fd, wd->src, flag);
- return 0;
-}
-
#if 0
// Account registry transfer to map-server
static void mapif_account_reg(int fd, unsigned char *src)
@@ -2123,89 +2023,6 @@ static int mapif_disconnectplayer(int fd, int account_id, int char_id, int reaso
return 0;
}
-// broadcast sending
-static int mapif_parse_broadcast(int fd)
-{
- mapif->broadcast(RFIFOP(fd, 16), RFIFOW(fd, 2), RFIFOL(fd, 4), RFIFOW(fd, 8), RFIFOW(fd, 10), RFIFOW(fd, 12), RFIFOW(fd, 14), fd);
- return 0;
-}
-
-// Wisp/page request to send
-static int mapif_parse_WisRequest(int fd)
-{
- struct WisData* wd;
- char name[NAME_LENGTH];
- char *data;
- size_t len;
-
- if (fd <= 0) // check if we have a valid fd
- return 0;
-
- if (RFIFOW(fd, 2) - 52 >= sizeof(wd->msg)) {
- ShowWarning("inter: Wis message size too long.\n");
- return 0;
- } else if (RFIFOW(fd, 2) - 52 <= 0) { // normally, impossible, but who knows...
- ShowError("inter: Wis message doesn't exist.\n");
- return 0;
- }
-
- safestrncpy(name, RFIFOP(fd, 28), NAME_LENGTH); //Received name may be too large and not contain \0! [Skotlex]
-
- // search if character exists before to ask all map-servers
- if (!chr->name_exists(name, NULL)) {
- mapif->wis_response(fd, RFIFOP(fd, 4), 1);
- } else {
- // Character exists. So, ask all map-servers
-
- // to be sure of the correct name, rewrite it
- SQL->GetData(inter->sql_handle, 0, &data, &len);
- memset(name, 0, NAME_LENGTH);
- memcpy(name, data, min(len, NAME_LENGTH));
- // if source is destination, don't ask other servers.
- if (strncmp(RFIFOP(fd, 4), name, NAME_LENGTH) == 0) {
- mapif->wis_response(fd, RFIFOP(fd, 4), 1);
- } else {
- wd = inter->add_wisdata(fd, RFIFOP(fd, 4), RFIFOP(fd, 28), RFIFOP(fd, 52), RFIFOW(fd, 2) - 52);
- mapif->wis_message(wd);
- }
- }
-
- SQL->FreeResult(inter->sql_handle);
- return 0;
-}
-
-// Wisp/page transmission result
-static int mapif_parse_WisReply(int fd)
-{
- int id, flag;
- struct WisData *wd;
-
- id = RFIFOL(fd,2);
- flag = RFIFOB(fd,6);
- wd = inter->get_wisdata(id);
- if (wd == NULL)
- return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server
-
- if ((--wd->count) <= 0 || flag != 1) {
- mapif->wis_end(wd, flag); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target
- inter->remove_wisdata(id);
- }
-
- return 0;
-}
-
-// Received wisp message from map-server for ALL gm (just copy the message and resends it to ALL map-servers)
-static int mapif_parse_WisToGM(int fd)
-{
- unsigned char buf[2048]; // 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B
-
- memcpy(WBUFP(buf,0), RFIFOP(fd,0), RFIFOW(fd,2)); // Message contains the NUL terminator (see intif_wis_message_to_gm())
- WBUFW(buf, 0) = 0x3803;
- mapif->sendall(buf, RFIFOW(fd,2));
-
- return 0;
-}
-
// Save account_reg into sql (type=2)
static int mapif_parse_Registry(int fd)
{
@@ -2461,6 +2278,29 @@ static void mapif_achievement_save(int char_id, struct char_achievements *p)
inter_achievement->tosql(char_id, cp, p);
}
+static void mapif_rodex_getzenyack(int fd, int char_id, int64 mail_id, uint8 opentype, int64 zeny)
+{
+ WFIFOHEAD(fd, 23);
+ WFIFOW(fd, 0) = 0x3899;
+ WFIFOL(fd, 2) = char_id;
+ WFIFOQ(fd, 6) = zeny;
+ WFIFOQ(fd, 14) = mail_id;
+ WFIFOB(fd, 22) = opentype;
+ WFIFOSET(fd, 23);
+}
+
+static void mapif_rodex_getitemsack(int fd, int char_id, int64 mail_id, uint8 opentype, int count, const struct rodex_item *items)
+{
+ WFIFOHEAD(fd, 15 + sizeof(struct rodex_item) * RODEX_MAX_ITEM);
+ WFIFOW(fd, 0) = 0x389a;
+ WFIFOL(fd, 2) = char_id;
+ WFIFOQ(fd, 6) = mail_id;
+ WFIFOB(fd, 14) = opentype;
+ WFIFOB(fd, 15) = count;
+ memcpy(WFIFOP(fd, 16), items, sizeof(struct rodex_item) * RODEX_MAX_ITEM);
+ WFIFOSET(fd, 16 + sizeof(struct rodex_item) * RODEX_MAX_ITEM);
+}
+
void mapif_defaults(void)
{
mapif = &mapif_s;
@@ -2506,7 +2346,6 @@ void mapif_defaults(void)
mapif->guild_withdraw = mapif_guild_withdraw;
mapif->guild_memberinfoshort = mapif_guild_memberinfoshort;
mapif->guild_broken = mapif_guild_broken;
- mapif->guild_message = mapif_guild_message;
mapif->guild_basicinfochanged = mapif_guild_basicinfochanged;
mapif->guild_memberinfochanged = mapif_guild_memberinfochanged;
mapif->guild_skillupack = mapif_guild_skillupack;
@@ -2522,7 +2361,6 @@ void mapif_defaults(void)
mapif->parse_GuildLeave = mapif_parse_GuildLeave;
mapif->parse_GuildChangeMemberInfoShort = mapif_parse_GuildChangeMemberInfoShort;
mapif->parse_BreakGuild = mapif_parse_BreakGuild;
- mapif->parse_GuildMessage = mapif_parse_GuildMessage;
mapif->parse_GuildBasicInfoChange = mapif_parse_GuildBasicInfoChange;
mapif->parse_GuildMemberInfoChange = mapif_parse_GuildMemberInfoChange;
mapif->parse_GuildPosition = mapif_parse_GuildPosition;
@@ -2570,7 +2408,6 @@ void mapif_defaults(void)
mapif->party_withdraw = mapif_party_withdraw;
mapif->party_membermoved = mapif_party_membermoved;
mapif->party_broken = mapif_party_broken;
- mapif->party_message = mapif_party_message;
mapif->parse_CreateParty = mapif_parse_CreateParty;
mapif->parse_PartyInfo = mapif_parse_PartyInfo;
mapif->parse_PartyAddMember = mapif_parse_PartyAddMember;
@@ -2578,7 +2415,6 @@ void mapif_defaults(void)
mapif->parse_PartyLeave = mapif_parse_PartyLeave;
mapif->parse_PartyChangeMap = mapif_parse_PartyChangeMap;
mapif->parse_BreakParty = mapif_parse_BreakParty;
- mapif->parse_PartyMessage = mapif_parse_PartyMessage;
mapif->parse_PartyLeaderChange = mapif_parse_PartyLeaderChange;
mapif->pet_created = mapif_pet_created;
mapif->pet_info = mapif_pet_info;
@@ -2605,6 +2441,8 @@ void mapif_defaults(void)
mapif->rodex_send = mapif_rodex_send;
mapif->parse_rodex_checkname = mapif_parse_rodex_checkname;
mapif->rodex_checkname = mapif_rodex_checkname;
+ mapif->rodex_getzenyack = mapif_rodex_getzenyack;
+ mapif->rodex_getitemsack = mapif_rodex_getitemsack;
mapif->load_guild_storage = mapif_load_guild_storage;
mapif->save_guild_storage_ack = mapif_save_guild_storage_ack;
mapif->parse_LoadGuildStorage = mapif_parse_LoadGuildStorage;
@@ -2616,16 +2454,8 @@ void mapif_defaults(void)
mapif->itembound_ack = mapif_itembound_ack;
mapif->parse_ItemBoundRetrieve = mapif_parse_ItemBoundRetrieve;
mapif->parse_accinfo = mapif_parse_accinfo;
- mapif->broadcast = mapif_broadcast;
- mapif->wis_message = mapif_wis_message;
- mapif->wis_response = mapif_wis_response;
- mapif->wis_end = mapif_wis_end;
mapif->account_reg_reply = mapif_account_reg_reply;
mapif->disconnectplayer = mapif_disconnectplayer;
- mapif->parse_broadcast = mapif_parse_broadcast;
- mapif->parse_WisRequest = mapif_parse_WisRequest;
- mapif->parse_WisReply = mapif_parse_WisReply;
- mapif->parse_WisToGM = mapif_parse_WisToGM;
mapif->parse_Registry = mapif_parse_Registry;
mapif->parse_RegistryRequest = mapif_parse_RegistryRequest;
mapif->namechange_ack = mapif_namechange_ack;
diff --git a/src/char/mapif.h b/src/char/mapif.h
index f57748ac6..11dd79504 100644
--- a/src/char/mapif.h
+++ b/src/char/mapif.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
+ * Copyright (C) 2012-2020 Hercules Dev Team
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
#include "common/hercules.h"
#include "common/mmo.h"
-struct WisData;
+struct rodex_item;
/**
* mapif interface
@@ -70,7 +70,6 @@ struct mapif_interface {
int (*guild_withdraw) (int guild_id, int account_id, int char_id, int flag, const char *name, const char *mes);
int (*guild_memberinfoshort) (struct guild *g, int idx);
int (*guild_broken) (int guild_id, int flag);
- int (*guild_message) (int guild_id, int account_id, const char *mes, int len, int sfd);
int (*guild_basicinfochanged) (int guild_id, int type, const void *data, int len);
int (*guild_memberinfochanged) (int guild_id, int account_id, int char_id, int type, const void *data, int len);
int (*guild_skillupack) (int guild_id, uint16 skill_id, int account_id);
@@ -86,7 +85,6 @@ struct mapif_interface {
int (*parse_GuildLeave) (int fd, int guild_id, int account_id, int char_id, int flag, const char *mes);
int (*parse_GuildChangeMemberInfoShort) (int fd, int guild_id, int account_id, int char_id, int online, int lv, int class);
int (*parse_BreakGuild) (int fd, int guild_id);
- int (*parse_GuildMessage) (int fd, int guild_id, int account_id, const char *mes, int len);
int (*parse_GuildBasicInfoChange) (int fd, int guild_id, int type, const void *data, int len);
int (*parse_GuildMemberInfoChange) (int fd, int guild_id, int account_id, int char_id, int type, const char *data, int len);
int (*parse_GuildPosition) (int fd, int guild_id, int idx, const struct guild_position *p);
@@ -134,7 +132,6 @@ struct mapif_interface {
int (*party_withdraw) (int party_id,int account_id, int char_id);
int (*party_membermoved) (struct party *p, int idx);
int (*party_broken) (int party_id, int flag);
- int (*party_message) (int party_id, int account_id, const char *mes, int len, int sfd);
int (*parse_CreateParty) (int fd, const char *name, int item, int item2, const struct party_member *leader);
void (*parse_PartyInfo) (int fd, int party_id, int char_id);
int (*parse_PartyAddMember) (int fd, int party_id, const struct party_member *member);
@@ -142,7 +139,6 @@ struct mapif_interface {
int (*parse_PartyLeave) (int fd, int party_id, int account_id, int char_id);
int (*parse_PartyChangeMap) (int fd, int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv);
int (*parse_BreakParty) (int fd, int party_id);
- int (*parse_PartyMessage) (int fd, int party_id, int account_id, const char *mes, int len);
int (*parse_PartyLeaderChange) (int fd, int party_id, int account_id, int char_id);
int (*pet_created) (int fd, int account_id, struct s_pet *p);
int (*pet_info) (int fd, int account_id, struct s_pet *p);
@@ -168,6 +164,8 @@ struct mapif_interface {
void (*rodex_send) (int fd, int sender_id, int receiver_id, int receiver_accountid, bool result);
void (*parse_rodex_checkname) (int fd);
void (*rodex_checkname) (int fd, int reqchar_id, int target_char_id, int target_class, int target_level, char *name);
+ void (*rodex_getzenyack) (int fd, int char_id, int64 mail_id, uint8 opentype, int64 zeny);
+ void (*rodex_getitemsack) (int fd, int char_id, int64 mail_id, uint8 opentype, int count, const struct rodex_item *items);
int (*load_guild_storage) (int fd, int account_id, int guild_id, char flag);
int (*save_guild_storage_ack) (int fd, int account_id, int guild_id, int fail);
int (*parse_LoadGuildStorage) (int fd);
@@ -179,16 +177,8 @@ struct mapif_interface {
int (*itembound_ack) (int fd, int aid, int guild_id);
void (*parse_ItemBoundRetrieve) (int fd);
void (*parse_accinfo) (int fd);
- int (*broadcast) (const unsigned char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, int sfd);
- int (*wis_message) (struct WisData *wd);
- void (*wis_response) (int fd, const unsigned char *src, int flag);
- int (*wis_end) (struct WisData *wd, int flag);
int (*account_reg_reply) (int fd,int account_id,int char_id, int type);
int (*disconnectplayer) (int fd, int account_id, int char_id, int reason);
- int (*parse_broadcast) (int fd);
- int (*parse_WisRequest) (int fd);
- int (*parse_WisReply) (int fd);
- int (*parse_WisToGM) (int fd);
int (*parse_Registry) (int fd);
int (*parse_RegistryRequest) (int fd);
void (*namechange_ack) (int fd, int account_id, int char_id, int type, int flag, const char *name);
diff --git a/src/char/packets_hc_struct.h b/src/char/packets_hc_struct.h
index 196493cac..dc5feab60 100644
--- a/src/char/packets_hc_struct.h
+++ b/src/char/packets_hc_struct.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2016-2018 Hercules Dev Team
+ * Copyright (C) 2016-2020 Hercules Dev Team
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/pincode.c b/src/char/pincode.c
index 5a7eb1cab..6346f3266 100644
--- a/src/char/pincode.c
+++ b/src/char/pincode.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/char/pincode.h b/src/char/pincode.h
index 699758179..594aabb19 100644
--- a/src/char/pincode.h
+++ b/src/char/pincode.h
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by