/**
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
* Copyright (C) 2012-2015 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#define HERCULES_CORE
#include "config/core.h" // GP_BOUND_ITEMS
#include "guild.h"
#include "map/battle.h"
#include "map/channel.h"
#include "map/clif.h"
#include "map/instance.h"
#include "map/intif.h"
#include "map/log.h"
#include "map/map.h"
#include "map/mob.h"
#include "map/npc.h"
#include "map/pc.h"
#include "map/skill.h"
#include "map/status.h"
#include "map/storage.h"
#include "common/HPM.h"
#include "common/cbasetypes.h"
#include "common/ers.h"
#include "common/memmgr.h"
#include "common/mapindex.h"
#include "common/nullpo.h"
#include "common/showmsg.h"
#include "common/strlib.h"
#include "common/timer.h"
#include "common/utils.h"
#include
#include
#include
struct guild_interface guild_s;
struct guild_interface *guild;
/*==========================================
* Retrieves and validates the sd pointer for this guild member [Skotlex]
*------------------------------------------*/
TBL_PC* guild_sd_check(int guild_id, int account_id, int char_id) {
TBL_PC* sd = map->id2sd(account_id);
if (!(sd && sd->status.char_id == char_id))
return NULL;
if (sd->status.guild_id != guild_id) {
//If player belongs to a different guild, kick him out.
intif->guild_leave(guild_id,account_id,char_id,0,"** Guild Mismatch **");
return NULL;
}
return sd;
}
// Modified [Komurka]
int guild_skill_get_max (int id) {
if (id < GD_SKILLBASE || id >= GD_SKILLBASE+MAX_GUILDSKILL)
return 0;
return guild->skill_tree[id-GD_SKILLBASE].max;
}
// Retrieve skill_lv learned by guild
int guild_checkskill(struct guild *g, int id) {
int idx = id - GD_SKILLBASE;
nullpo_ret(g);
if (idx < 0 || idx >= MAX_GUILDSKILL)
return 0;
return g->skill[idx].lv;
}
/*==========================================
* guild_skill_tree.txt reading - from jA [Komurka]
*------------------------------------------*/
bool guild_read_guildskill_tree_db(char* split[], int columns, int current)
{// ,,,,,,,,,,,
int k, id, skill_id;
skill_id = atoi(split[0]);
id = skill_id - GD_SKILLBASE;
if( id < 0 || id >= MAX_GUILDSKILL )
{
ShowWarning("guild_read_guildskill_tree_db: Invalid skill id %d.\n", skill_id);
return false;
}
guild->skill_tree[id].id = skill_id;
guild->skill_tree[id].max = atoi(split[1]);
if( guild->skill_tree[id].id == GD_GLORYGUILD && battle_config.require_glory_guild && guild->skill_tree[id].max == 0 )
{// enable guild's glory when required for emblems
guild->skill_tree[id].max = 1;
}
for( k = 0; k < MAX_GUILD_SKILL_REQUIRE; k++ )
{
guild->skill_tree[id].need[k].id = atoi(split[k*2+2]);
guild->skill_tree[id].need[k].lv = atoi(split[k*2+3]);
}
return true;
}
/*==========================================
* Guild skill check - from jA [Komurka]
*------------------------------------------*/
int guild_check_skill_require(struct guild *g,int id)
{
int i;
int idx = id-GD_SKILLBASE;
if(g == NULL)
return 0;
if (idx < 0 || idx >= MAX_GUILDSKILL)
return 0;
for(i=0;iskill_tree[idx].need[i].id == 0) break;
if(guild->skill_tree[idx].need[i].lv > guild->checkskill(g,guild->skill_tree[idx].need[i].id))
return 0;
}
return 1;
}
bool guild_read_castledb(char* str[], int columns, int current)
{// ,