void IOGuild::frag(Player* player, uint64_t deathId, const DeathList& list) { Database* db = Database::getInstance(); War_t war; std::stringstream s; for(DeathList::const_iterator it = list.begin(); it != list.end(); ) { if(it->isLast()) war = it->getWar(); Creature* creature = it->getKillerCreature(); if(it != list.begin()) { ++it; if(it == list.end()) s << " and "; else s << ", "; } else ++it; s << creature->getName(); } std::string killers = s.str(); s.str(""); ChatChannel* channel = NULL; if((channel = g_chat.getChannel(player, CHANNEL_GUILD))) { s << "Guild member " << player->getName() << " was killed by " << killers << ". The new score is " << war.frags[ war.type == WAR_GUILD] << ":" << war.frags[war.type] << " frags (limit " << war.limit << ")."; channel->talk("", SPEAK_CHANNEL_RA, s.str()); } s.str(""); if((channel = g_chat.getChannel(list[0].getKillerCreature()->getPlayer(), CHANNEL_GUILD))) { s << "Opponent " << player->getName() << " was killed by " << killers << ". The new score is " << war.frags[ war.type] << ":" << war.frags[war.type == WAR_GUILD] << " frags (limit " << war.limit << ")."; channel->talk("", SPEAK_CHANNEL_RA, s.str()); } DBQuery query; query << "INSERT INTO `guild_kills` (`guild_id`, `war_id`, `death_id`) VALUES (" << war.ids[war.type] << ", " << war.war << ", " << deathId << ");"; db->query(query.str()); }
bool ChatChannel::addUser(Player* player) { if(m_users.find(player->getID()) != m_users.end()) return false; ChatChannel* channel = g_chat.getChannel(player, m_id); if(!channel) { #ifdef __DEBUG_CHAT__ std::clog << "ChatChannel::addUser - failed retrieving channel." << std::endl; #endif return false; } if(m_id == CHANNEL_PARTY || m_id == CHANNEL_GUILD || m_id == CHANNEL_PRIVATE) { Player* tmpPlayer = NULL; for(UsersMap::iterator cit = m_users.begin(); cit != m_users.end(); ++cit) { if((tmpPlayer = cit->second->getPlayer())) tmpPlayer->sendChannelEvent(m_id, player->getName(), CHANNELEVENT_JOIN); } } m_users[player->getID()] = player; CreatureEventList joinEvents = player->getCreatureEvents(CREATURE_EVENT_CHANNEL_JOIN); for(CreatureEventList::iterator it = joinEvents.begin(); it != joinEvents.end(); ++it) (*it)->executeChannelJoin(player, m_id, m_users); Manager::getInstance()->addUser(player->getID(), m_id); return true; }
void IOGuild::frag(Player* player, uint64_t deathId, const DeathList& list, bool score) { War_t war; std::stringstream s; for(DeathList::const_iterator it = list.begin(); it != list.end(); ) { if(score) { if(it->isLast()) war = it->getWar(); } else if(!war.war) war = it->getWar(); Creature* creature = it->getKillerCreature(); if(it != list.begin()) { ++it; if(it == list.end()) s << " and "; else s << ", "; } else ++it; s << creature->getName(); } if(!war.ids[war.type]) { #ifdef __DEBUG__ std::clog << "[Notice - IOGuild::frag] Unable to attach war frag to player " << player->getName() << "." << std::endl; #endif return; } std::string killers = s.str(); s.str(""); ChatChannel* channel = NULL; if((channel = g_chat.getChannel(player, CHANNEL_GUILD))) { s << "Guild member " << player->getName() << " was killed by " << killers << "."; if(score) s << " The new score is " << war.frags[war.type == WAR_GUILD] << ":" << war.frags[war.type] << " frags (limit " << war.limit << ")."; channel->talk("", MSG_GAMEMASTER_CHANNEL, s.str()); } s.str(""); if((channel = g_chat.getChannel(list[0].getKillerCreature()->getPlayer(), CHANNEL_GUILD))) { s << "Opponent " << player->getName() << " was killed by " << killers << "."; if(score) s << " The new score is " << war.frags[war.type] << ":" << war.frags[war.type == WAR_GUILD] << " frags (limit " << war.limit << ")."; channel->talk("", MSG_CHANNEL_HIGHLIGHT, s.str()); } Database* db = Database::getInstance(); DBQuery query; query << "INSERT INTO `guild_kills` (`guild_id`, `war_id`, `death_id`) VALUES (" << war.ids[war.type] << ", " << war.war << ", " << deathId << ");"; db->query(query.str()); }
bool Party::leaveParty(Player* player) { if(!player){ return false; } if(!isPlayerMember(player) && getLeader() != player){ return false; } // Remove from chat PrivateChatChannel* pcc = static_cast<PrivateChatChannel*>(g_chat.getChannel(this)); if(pcc){ pcc->removeUser(player, true); } bool hasNoLeader = false; if(getLeader() == player){ if(!memberList.empty()){ if(memberList.size() == 1 && inviteList.empty()){ //just one member left, disband instead of passing leadership hasNoLeader = true; } else{ passPartyLeadership(memberList.front()); } } else{ hasNoLeader = true; } } //since we already passed the leadership, we remove the player from the list PlayerVector::iterator it = std::find(memberList.begin(), memberList.end(), player); if(it != memberList.end()){ memberList.erase(it); } it = std::find(inviteList.begin(), inviteList.end(), player); if(it != inviteList.end()){ inviteList.erase(it); } player->setParty(NULL); player->sendTextMessage(MSG_INFO_DESCR, "You have left the party."); player->sendPlayerPartyIcons(player); updateSharedExperience(); updatePartyIcons(player); clearPlayerPoints(player); std::stringstream ss; ss << player->getName() << " has left the party."; broadcastPartyMessage(MSG_INFO_DESCR, ss.str()); if(hasNoLeader || disbandParty()){ disband(); } return true; }