summaryrefslogtreecommitdiff
path: root/src/map/guild.c
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-09-12 13:13:23 -0300
committerJesusaves <cpntb1@ymail.com>2020-09-12 13:13:23 -0300
commit1443f47ca63972f737bd9cc0322f77dc416ff2a0 (patch)
tree6b851ced5b878ac8b2b13eeb01e04d598bacfe43 /src/map/guild.c
parentc53f8a099151f2e8c26c0ab36f35d34256c0d6cb (diff)
downloadhercules-1443f47ca63972f737bd9cc0322f77dc416ff2a0.tar.gz
hercules-1443f47ca63972f737bd9cc0322f77dc416ff2a0.tar.bz2
hercules-1443f47ca63972f737bd9cc0322f77dc416ff2a0.tar.xz
hercules-1443f47ca63972f737bd9cc0322f77dc416ff2a0.zip
This is Hercules v2019.09.22
Diffstat (limited to 'src/map/guild.c')
-rw-r--r--src/map/guild.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/src/map/guild.c b/src/map/guild.c
index 415a46db5..2faf60e2b 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -169,7 +169,7 @@ static bool guild_read_castledb_libconfig(void)
}
libconfig->destroy(&castle_conf);
- ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, config_filename);
+ ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", db_size(guild->castle_db), config_filename);
return true;
}
@@ -217,10 +217,59 @@ static bool guild_read_castledb_libconfig_sub(struct config_setting_t *it, int i
}
safestrncpy(gc->castle_event, name, sizeof(gc->castle_event));
+ if (itemdb->lookup_const(it, "SiegeType", &i32) && (i32 >= SIEGE_TYPE_MAX || i32 < 0)) {
+ ShowWarning("guild_read_castledb_libconfig_sub: Invalid SiegeType in \"%s\", entry #%d, defaulting to SIEGE_TYPE_FE.\n", source, idx);
+ gc->siege_type = SIEGE_TYPE_FE;
+ } else {
+ gc->siege_type = i32;
+ }
+
+ libconfig->setting_lookup_bool_real(it, "EnableClientWarp", &gc->enable_client_warp);
+ if (gc->enable_client_warp == true) {
+ struct config_setting_t *wd = libconfig->setting_get_member(it, "ClientWarp");
+ guild->read_castledb_libconfig_sub_warp(wd, source, gc);
+ }
idb_put(guild->castle_db, gc->castle_id, gc);
return true;
}
+static bool guild_read_castledb_libconfig_sub_warp(struct config_setting_t *wd, const char *source, struct guild_castle *gc)
+{
+ nullpo_retr(false, wd);
+ nullpo_retr(false, gc);
+ nullpo_retr(false, source);
+
+ int64 i64 = 0;
+ struct config_setting_t *it = libconfig->setting_get_member(wd, "Position");
+ if (config_setting_is_list(it)) {
+ int m = map->mapindex2mapid(gc->mapindex);
+
+ gc->client_warp.x = libconfig->setting_get_int_elem(it, 0);
+ gc->client_warp.y = libconfig->setting_get_int_elem(it, 1);
+ if (gc->client_warp.x < 0 || gc->client_warp.x >= map->list[m].xs || gc->client_warp.y < 0 || gc->client_warp.y >= map->list[m].ys) {
+ ShowWarning("guild_read_castledb_libconfig_sub_warp: Invalid Position in \"%s\", for castle (%d).\n", source, gc->castle_id);
+ return false;
+ }
+ } else {
+ ShowWarning("guild_read_castledb_libconfig_sub_warp: Invalid format for Position in \"%s\", for castle (%d).\n", source, gc->castle_id);
+ return false;
+ }
+
+ if (libconfig->setting_lookup_int64(wd, "ZenyCost", &i64)) {
+ if (i64 > MAX_ZENY) {
+ ShowWarning("guild_read_castledb_libconfig_sub_warp: ZenyCost is too big in \"%s\", for castle (%d), capping to MAX_ZENY.\n", source, gc->castle_id);
+ }
+ gc->client_warp.zeny = cap_value((int)i64, 0, MAX_ZENY);
+ }
+ if (libconfig->setting_lookup_int64(wd, "ZenyCostSiegeTime", &i64)) {
+ if (i64 > MAX_ZENY) {
+ ShowWarning("guild_read_castledb_libconfig_sub_warp: ZenyCostSiegeTime is too big in \"%s\", for castle (%d), capping to MAX_ZENY.\n", source, gc->castle_id);
+ }
+ gc->client_warp.zeny_siege = cap_value((int)i64, 0, MAX_ZENY);
+ }
+ return true;
+}
+
/// lookup: guild id -> guild*
static struct guild *guild_search(int guild_id)
{
@@ -605,7 +654,7 @@ static int guild_recv_info(const struct guild *sg)
before=*sg;
//Perform the check on the user because the first load
guild->check_member(sg);
- if ((sd = map->nick2sd(sg->master)) != NULL) {
+ if ((sd = map->nick2sd(sg->master, false)) != NULL) {
//If the guild master is online the first time the guild_info is received,
//that means he was the first to join, so apply guild skill blocking here.
if( battle_config.guild_skill_relog_delay == 1)
@@ -2497,6 +2546,7 @@ void guild_defaults(void)
guild->read_guildskill_tree_db = guild_read_guildskill_tree_db;
guild->read_castledb_libconfig = guild_read_castledb_libconfig;
guild->read_castledb_libconfig_sub = guild_read_castledb_libconfig_sub;
+ guild->read_castledb_libconfig_sub_warp = guild_read_castledb_libconfig_sub_warp;
guild->payexp_timer_sub = guild_payexp_timer_sub;
guild->send_xy_timer_sub = guild_send_xy_timer_sub;
guild->send_xy_timer = guild_send_xy_timer;