CGuild::CGuild(TGuildCreateParameter& cp)
{
Initialize();
m_general_count = 0;
m_iMemberCountBonus = 0;
strlcpy(m_data.name, cp.name, sizeof(m_data.name));
m_data.master_pid = cp.master->GetPlayerID();
strlcpy(m_data.grade_array[0].grade_name, LC_TEXT("길드장"), sizeof(m_data.grade_array[0].grade_name));
m_data.grade_array[0].auth_flag = GUILD_AUTH_ADD_MEMBER | GUILD_AUTH_REMOVE_MEMBER | GUILD_AUTH_NOTICE | GUILD_AUTH_USE_SKILL;
for (int i = 1; i < GUILD_GRADE_COUNT; ++i)
{
strlcpy(m_data.grade_array[i].grade_name, LC_TEXT("길드원"), sizeof(m_data.grade_array[i].grade_name));
m_data.grade_array[i].auth_flag = 0;
}
std::unique_ptr<SQLMsg> pmsg(DBManager::instance().DirectQuery(
"INSERT INTO guild%s(name, master, sp, level, exp, skill_point, skill) "
"VALUES('%s', %u, 1000, 20, 0, 0, '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0')", // değişen 1->20
get_table_postfix(), m_data.name, m_data.master_pid));
// TODO if error occur?
m_data.guild_id = pmsg->Get()->uiInsertID;
for (int i = 0; i < GUILD_GRADE_COUNT; ++i)
{
DBManager::instance().Query("INSERT INTO guild_grade%s VALUES(%u, %d, '%s', %d)",
get_table_postfix(),
m_data.guild_id,
i + 1,
m_data.grade_array[i].grade_name,
m_data.grade_array[i].auth_flag);
}
ComputeGuildPoints();
m_data.power = m_data.max_power;
m_data.ladder_point = 0;
db_clientdesc->DBPacket(HEADER_GD_GUILD_CREATE, 0, &m_data.guild_id, sizeof(DWORD));
TPacketGuildSkillUpdate guild_skill;
guild_skill.guild_id = m_data.guild_id;
guild_skill.amount = 0;
guild_skill.skill_point = 19; // 0->19
memset(guild_skill.skill_levels, 0, GUILD_SKILL_COUNT);
db_clientdesc->DBPacket(HEADER_GD_GUILD_SKILL_UPDATE, 0, &guild_skill, sizeof(guild_skill));
// TODO GUILD_NAME
CHARACTER_MANAGER::instance().for_each_pc(FGuildNameSender(GetID(), GetName()));
/*
TPacketDGGuildMember p;
memset(&p, 0, sizeof(p));
p.dwPID = cp.master->GetPlayerID();
p.bGrade = 15;
AddMember(&p);
*/
RequestAddMember(cp.master, GUILD_LEADER_GRADE);
}
void CGuild::Initialize()
{
memset(&m_data, 0, sizeof(m_data));
m_data.level = 20; // 1->20
for (int i = 0; i < GUILD_SKILL_COUNT; ++i)
abSkillUsable[i] = true;
m_iMemberCountBonus = 0;
}