void Guild::CreateDefaultGuildRanks(int locale_idx) { CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid='%u'", m_Id); CreateRank(sObjectMgr.GetMangosString(LANG_GUILD_MASTER, locale_idx), GR_RIGHT_ALL); CreateRank(sObjectMgr.GetMangosString(LANG_GUILD_OFFICER, locale_idx), GR_RIGHT_ALL); CreateRank(sObjectMgr.GetMangosString(LANG_GUILD_VETERAN, locale_idx), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); CreateRank(sObjectMgr.GetMangosString(LANG_GUILD_MEMBER, locale_idx), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); CreateRank(sObjectMgr.GetMangosString(LANG_GUILD_INITIATE, locale_idx), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); }
bool Guild::create(uint64 lGuid, std::string gname) { std::string rname; std::string lName; if(!objmgr.GetPlayerNameByGUID(lGuid, lName)) return false; if(objmgr.GetGuildByName(gname)) return false; sLog.outDebug("GUILD: creating guild %s to leader: %u", gname.c_str(), GUID_LOPART(lGuid)); leaderGuid = lGuid; name = gname; GINFO = ""; MOTD = "No message set."; guildbank_money = 0; purchased_tabs = 0; Id = objmgr.GenerateGuildId(); // gname already assigned to Guild::name, use it to encode string for DB CharacterDatabase.escape_string(gname); std::string dbGINFO = GINFO; std::string dbMOTD = MOTD; CharacterDatabase.escape_string(dbGINFO); CharacterDatabase.escape_string(dbMOTD); CharacterDatabase.BeginTransaction(); // CharacterDatabase.PExecute("DELETE FROM guild WHERE guildid='%u'", Id); - MAX(guildid)+1 not exist CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid='%u'", Id); CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guildid='%u'", Id); CharacterDatabase.PExecute("INSERT INTO guild (guildid,name,leaderguid,info,motd,createdate,EmblemStyle,EmblemColor,BorderStyle,BorderColor,BackgroundColor,BankMoney) " "VALUES('%u','%s','%u', '%s', '%s', NOW(),'%u','%u','%u','%u','%u','" I64FMTD "')", Id, gname.c_str(), GUID_LOPART(leaderGuid), dbGINFO.c_str(), dbMOTD.c_str(), EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor, guildbank_money); CharacterDatabase.CommitTransaction(); rname = "Guild Master"; CreateRank(rname,GR_RIGHT_ALL); rname = "Officer"; CreateRank(rname,GR_RIGHT_ALL); rname = "Veteran"; CreateRank(rname,GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); rname = "Member"; CreateRank(rname,GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); rname = "Initiate"; CreateRank(rname,GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); return AddMember(lGuid, (uint32)GR_GUILDMASTER); }
void Guild::create(uint64 lGuid, std::string gname) { Player *pl; MemberSlot *newmember; std::string rname; pl = ObjectAccessor::Instance().FindPlayer(lGuid); if(!pl) return; leaderGuid = lGuid; name = gname; MOTD = "No message set."; rname = "Guild Master"; CreateRank(rname,GR_RIGHT_ALL); rname = "Officer"; CreateRank(rname,GR_RIGHT_ALL); rname = "Veteran"; CreateRank(rname,GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); rname = "Member"; CreateRank(rname,GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); rname = "Initiate"; CreateRank(rname,GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); Log::getSingleton().outDebug("GUILD: creating guild %s to leader:%d", gname.c_str(), leaderGuid); QueryResult *result = sDatabase.Query( "SELECT MAX(guildId) FROM guilds" ); if( result ) { Id = (*result)[0].GetUInt32()+1; delete result; } else Id = 1; if(pl) { pl->SetInGuild(Id); pl->SetRank( GR_GUILDMASTER ); } newmember = new MemberSlot; newmember->guid = leaderGuid; newmember->RankId = GR_GUILDMASTER; newmember->Pnote = ""; newmember->OFFnote = ""; AddMember(newmember); SaveGuildToDB(); }
void Guild::LoadRanksFromDB(uint32 GuildId) { std::stringstream query, ss; Field *fields; query << "SELECT * FROM `guilds_ranks` where guildId= " << GuildId; QueryResult *result = sDatabase.Query( query.str().c_str() ); if(!result) return; do { fields = result->Fetch(); CreateRank(fields[1].GetString(),fields[2].GetUInt32()); }while( result->NextRow() ); }