Add Guild Leader and City Mayor Chat Channels

This commit is contained in:
AconiteGodOfSWG
2020-10-08 11:15:45 -04:00
parent 625e4d168f
commit d5508fcf93
3 changed files with 40 additions and 0 deletions
@@ -224,6 +224,8 @@ void Chat::createSystemRooms(const std::string & galaxyName, const std::string &
createRoom(avatarName, true, galaxyRoom + ChatRoomTypes::ROOM_TRADER , "Trader chat for this galaxy");
createRoom(avatarName, true, galaxyRoom + ChatRoomTypes::ROOM_BEAST_MASTERY , "Beast Mastery chat for this galaxy");
createRoom(avatarName, true, galaxyRoom + ChatRoomTypes::ROOM_WARDEN , "Warden chat for this galaxy");
createRoom(avatarName, true, galaxyRoom + ChatRoomTypes::ROOM_GUILD_LEADER , "Guild Leader chat for this galaxy");
createRoom(avatarName, true, galaxyRoom + ChatRoomTypes::ROOM_CITY_MAYOR , "City Mayor chat for this galaxy");
std::string planetRoom = gamePrefix + galaxyName + "." + planetName + ".";
createRoom(avatarName, true, planetRoom + ChatRoomTypes::ROOM_PLANET, "public chat for this planet, cannot create rooms here");
@@ -673,6 +675,40 @@ unsigned int Chat::isAllowedToEnterRoom(const CreatureObject & who, const std::s
}
}
// player must be a guild leader to enter the guild leader room
static std::string s_guildLeaderChatRoom = getGameCode() + "." + instance().m_serverAvatar->cluster + "." + ChatRoomTypes::ROOM_GUILD_LEADER;
if (_stricmp(room.c_str(), s_guildLeaderChatRoom.c_str()) == 0)
{
PlayerObject const * const playerObject = PlayerCreatureController::getPlayerObject(&who);
int guildId = GuildInterface::getGuildId(who.getNetworkId());
NetworkId leader = GuildInterface::getGuildLeaderId(guildId);
if(!playerObject || who.getNetworkId() != leader) {
return SWG_CHAT_ERR_NOT_GUILD_LEADER;
}
}
// player must be a city mayor to enter the city mayor room
static std::string s_cityMayorChatRoom = getGameCode() + "." + instance().m_serverAvatar->cluster + "." + ChatRoomTypes::ROOM_CITY_MAYOR;
if (_stricmp(room.c_str(), s_cityMayorChatRoom.c_str()) == 0)
{
PlayerObject const * const playerObject = PlayerCreatureController::getPlayerObject(&who);
// note: because the city interface design took into account a bug that allows players to be a citizen of multiple cities,
// the getCitizenOfCityId function is, in this application, annoyingly packing all possible citizenship(s) into a vector
// thus requiring more work from us here
bool isMayor = false;
std::vector<int> cityId = CityInterface::getCitizenOfCityId(who.getNetworkId());
for(int i = 0; i < cityId.size(); ++i){
NetworkId leader = CityInterface::getCityInfo(cityId[i]).getLeaderId();
if(playerObject && who.getNetworkId() == leader) {
isMayor = true;
}
}
if(!isMayor) {
return SWG_CHAT_ERR_NOT_CITY_MAYOR;
}
}
return CHATRESULT_SUCCESS;
}
@@ -52,6 +52,8 @@ enum ERROR_CODES
SWG_CHAT_ERR_INVALID_OBJECT,
SWG_CHAT_ERR_NO_GAME_SERVER,
SWG_CHAT_ERR_NOT_WARDEN,
SWG_CHAT_ERR_NOT_GUILD_LEADER,
SWG_CHAT_ERR_NOT_CITY_MAYOR,
SWG_CHAT_ERR_WRONG_GCW_REGION_DEFENDER_FACTION
};
@@ -44,6 +44,8 @@ namespace ChatRoomTypes
static const std::string ROOM_TRADER = "Trader";
static const std::string ROOM_BEAST_MASTERY = "BeastMastery";
static const std::string ROOM_WARDEN = "Warden";
static const std::string ROOM_GUILD_LEADER = "GuildLeaders";
static const std::string ROOM_CITY_MAYOR = "CityMayors";
}//namespace ChatRoomTypes
enum