Planeshift
|
00001 /* 00002 * guildmanager.h 00003 * 00004 * Copyright (C) 2003 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 */ 00019 00020 00021 #ifndef __GUILDMANAGER_H__ 00022 #define __GUILDMANAGER_H__ 00023 00024 //============================================================================= 00025 // Crystal Space Includes 00026 //============================================================================= 00027 #include <iutil/document.h> 00028 00029 //============================================================================= 00030 // Project Includes 00031 //============================================================================= 00032 #include "bulkobjects/psguildinfo.h" 00033 00034 //============================================================================= 00035 // Local Includes 00036 //============================================================================= 00037 #include "msgmanager.h" // Parent class 00038 00039 class ClientConnectionSet; 00040 class ChatManager; 00041 class PendingGuildInvite; 00042 class PendingGuildWarInvite; 00043 00044 00052 class GuildNotifySubscription 00053 { 00054 public: 00055 GuildNotifySubscription(int guild, int clientnum, bool onlineOnly) 00056 { 00057 this->guild = guild; 00058 this->clientnum = clientnum; 00059 this->onlineOnly = onlineOnly; 00060 } 00061 int guild; 00062 int clientnum; 00063 bool onlineOnly; 00064 }; 00065 00066 00067 class GuildManager : public MessageManager<GuildManager> 00068 { 00069 friend class PendingAllianceInvite; 00070 public: 00071 00072 GuildManager(ClientConnectionSet* pCCS, ChatManager* chat); 00073 virtual ~GuildManager(); 00074 00075 void HandleJoinGuild(PendingGuildInvite* invite); 00076 void AcceptWar(PendingGuildWarInvite* invite); 00077 00078 void ResendGuildData(int id); 00079 00083 void RequirementsDeadline(int guild_id); 00084 00088 void CheckMinimumRequirements(psGuildInfo* guild, gemActor* notify); 00089 00090 00091 protected: 00092 int GetClientLevel(Client* client); 00093 bool CheckAllianceOperation(Client* client, bool checkLeaderGuild, psGuildInfo* &guild, psGuildAlliance* &alliance); 00094 00095 void HandleCmdMessage(MsgEntry* me,Client* client); 00096 void HandleGUIMessage(MsgEntry* me,Client* client); 00097 void HandleMOTDSet(MsgEntry* me,Client* client); 00098 void HandleSubscribeGuildData(Client* client,iDocumentNode* root); 00099 void UnsubscribeGuildData(Client* client); 00100 void HandleSetOnline(Client* client,iDocumentNode* root); 00102 void HandleSetGuildNotifications(Client* client,iDocumentNode* root); 00104 void HandleSetAllianceNotifications(Client* client,iDocumentNode* root); 00105 void HandleSetLevelRight(Client* client,iDocumentNode* root); 00106 void HandleRemoveMember(Client* client,iDocumentNode* root); 00107 void HandleSetMemberLevel(Client* client,iDocumentNode* root); 00108 void HandleSetMemberPoints(Client* client,iDocumentNode* root); 00109 00116 void HandleSetMaxMemberPoints(Client* client,iDocumentNode* root); 00117 void HandleSetMemberNotes(Client* client,iDocumentNode* root, bool isPublic); 00118 00122 bool CheckClientRights(Client* client, GUILD_PRIVILEGE priv); 00123 00129 bool CheckClientRights(Client* client, GUILD_PRIVILEGE priv, const char* denialMsg); 00130 00134 bool RetrieveOnlineOnly(iDocumentNode* root); 00135 00139 bool RetrieveGuildNotifications(iDocumentNode* root); 00140 00144 bool RetrieveAllianceNotifications(iDocumentNode* root); 00145 00146 00147 void SendGuildData(Client* client); 00148 void SendLevelData(Client* client); 00149 void SendMemberData(Client* client, bool onlineOnly); 00150 void SendAllianceData(Client* client); 00151 00152 csString MakeAllianceMemberXML(psGuildInfo* member, bool allianceLeader); 00153 00161 bool ParseRightString(csString privilege, GUILD_PRIVILEGE &right); 00162 00163 void CreateGuild(psGuildCmdMessage &msg,Client* client); 00164 00168 void EndGuild(psGuildInfo* guild,int clientnum); 00169 00173 void EndGuild(psGuildCmdMessage &msg,Client* client); 00174 00175 void ChangeGuildName(psGuildCmdMessage &msg,Client* client); 00176 bool FilterGuildName(const char* name); 00177 void Invite(psGuildCmdMessage &msg,Client* client); 00178 void Remove(psGuildCmdMessage &msg,Client* client); 00179 void Rename(psGuildCmdMessage &msg,Client* client); 00180 void Promote(psGuildCmdMessage &msg,Client* client); 00181 00192 void GetMemberPermissions(psGuildCmdMessage &msg,Client* client); 00193 00202 void SetMemberPermissions(psGuildCmdMessage &msg,Client* client); 00203 void ListMembers(psGuildCmdMessage &msg,Client* client); 00204 void Secret(psGuildCmdMessage &msg, Client* client); 00205 void Web(psGuildCmdMessage &msg, Client* client); 00206 void MOTD(psGuildCmdMessage &msg, Client* client); 00207 void GuildWar(psGuildCmdMessage &msg, Client* client); 00208 void GuildYield(psGuildCmdMessage &msg, Client* client); 00209 00210 void NewAlliance(psGuildCmdMessage &msg, Client* client); 00211 void AllianceInvite(psGuildCmdMessage &msg, Client* client); 00212 void AllianceRemove(psGuildCmdMessage &msg, Client* client); 00213 void AllianceLeave(psGuildCmdMessage &msg, Client* client); 00214 void AllianceLeader(psGuildCmdMessage &msg, Client* client); 00215 void EndAlliance(psGuildCmdMessage &msg, Client* client); 00216 00228 void EndAlliance(psGuildAlliance* alliance, int clientNum); 00229 void RemoveMemberFromAlliance(Client* client, psGuildInfo* guild, psGuildAlliance* alliance, 00230 psGuildInfo* removedGuild); 00231 00232 bool AddPlayerToGuild(int guild,const char* guildname,Client* client,int level); 00233 GuildNotifySubscription* FindNotifySubscr(Client* client); 00234 00246 void SendNotifications(int guild, int msg); 00247 00251 void SendAllianceNotifications(psGuildAlliance* alliance); 00252 00259 void SendNoAllianceNotifications(psGuildAlliance* alliance); 00260 void SendNoAllianceNotifications(psGuildInfo* guild); 00261 00262 void SendGuildPoints(psGuildCmdMessage &msg,Client* client); 00263 00264 void UnsubscribeWholeGuild(psGuildInfo* guild); 00265 00266 bool IsLeader(Client* client); 00267 00268 ChatManager* chatserver; 00269 ClientConnectionSet* clients; 00270 csArray<GuildNotifySubscription*> notifySubscr; 00271 00272 csRef<iDocumentSystem> xml; 00273 }; 00274 00277 #endif 00278