Planeshift

groupmanager.h

Go to the documentation of this file.
00001 /*
00002  * groupmanager.h by Anders Reggestad <[email protected]>
00003  *
00004  * Copyright (C) 2001 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 #ifndef __GROUPMANAGER_H__
00020 #define __GROUPMANAGER_H__
00021 
00022 //=============================================================================
00023 // Crystal Space Includes
00024 //=============================================================================
00025 #include <csutil/ref.h>
00026 #include <csutil/refarr.h>
00027 #include <csutil/array.h>
00028 
00029 //=============================================================================
00030 // Project Includes
00031 //=============================================================================
00032 
00033 //=============================================================================
00034 // Local Includes
00035 //=============================================================================
00036 #include "msgmanager.h"   // Subscriber class
00037 #include "playergroup.h"
00038 
00039 class gemActor;
00040 class GroupManager;
00041 class Client;
00042 class ChatManager;
00043 class ClientConnectionSet;
00044 
00045 //---------------------------------------------------------------------------
00046 
00047 
00048 //---------------------------------------------------------------------------
00049 class PendingGroupInvite;
00050 class PendingGroupChallenge;
00051 
00056 class GroupManager : public MessageManager<GroupManager>
00057 {
00058 public:
00059 
00060     GroupManager(ClientConnectionSet* pCCS, ChatManager* chat);
00061     virtual ~GroupManager();
00062 
00063     void HandleJoinGroup(PendingGroupInvite* invite);
00064 
00070     void HandleChallengeGroup(PendingGroupChallenge* invite);
00071 
00072 protected:
00073     friend class PlayerGroup;
00074 
00075     void HandleGroupCommand(MsgEntry* pMsg,Client* client);
00076 
00077     void Invite(psGroupCmdMessage &msg,Client* client);
00078     void Disband(psGroupCmdMessage &msg,gemActor* client);
00079     void Leave(psGroupCmdMessage &msg,gemActor* client);
00080     void ListMembers(psGroupCmdMessage &msg,gemActor* client);
00081     void RemovePlayerFromGroup(psGroupCmdMessage &msg,gemActor* client);
00082     void Leader(psGroupCmdMessage &msg,gemActor* client);
00083 
00090     void Challenge(psGroupCmdMessage &msg,Client* Challenger);
00097     void Yield(psGroupCmdMessage &msg,Client* Yielder);
00098 
00104     bool AddGroupChallenge(PlayerGroup* ChallengerGroup, PlayerGroup* ChallengedGroup);
00105 
00106     void SendGroup(gemActor* client);
00107     void SendLeave(gemActor* client);
00108     csPtr<PlayerGroup> NewGroup(gemActor* leader);
00109     bool AddPlayerToGroup(PlayerGroup* group, gemActor* client);
00110     void Remove(PlayerGroup* group);
00111     void GroupChat(gemActor* client, const char* fmt, ...);
00112     PlayerGroup* FindGroup(int id);
00113 
00114 
00115     ChatManager* chatserver;
00116     ClientConnectionSet* clients;
00117     csRef<EventManager> eventmanager;
00118     csRefArray<PlayerGroup> groups;
00119 };
00120 
00121 #endif