1 #ifndef SPRINGLOBBY_HEADERGUARD_BATTLE_H 2 #define SPRINGLOBBY_HEADERGUARD_BATTLE_H 3 4 #include <set> 5 6 #include "hosting/autohost.h" 7 #include "ibattle.h" 8 9 class Ui; 10 class Server; 11 class User; 12 class wxTimerEvent; 13 14 15 /** \brief model of a sp/mp battle 16 * \todo DOCME */ 17 class Battle : public IBattle 18 { 19 public: 20 Battle( Server& serv, int id ); 21 ~Battle(); 22 23 //const BattleOptions& opts() { return m_opts; } 24 GetServer()25 Server& GetServer() { return m_serv; } GetAutoHost()26 AutoHost& GetAutoHost() { return m_ah; } 27 28 void SendHostInfo( HostInfo update ); 29 void SendHostInfo( const wxString& Tag ); 30 31 void Update(); 32 void Update( const wxString& Tag ); 33 34 void Join( const wxString& password = wxEmptyString ); 35 void Leave(); 36 37 void KickPlayer( User& user ); 38 39 void RingNotReadyPlayers(); 40 void RingNotSyncedPlayers(); 41 void RingNotSyncedAndNotReadyPlayers(); 42 void RingPlayer( const User& u ); 43 44 void Say( const wxString& msg ); 45 void DoAction( const wxString& msg ); 46 47 void SetLocalMap( const LSL::UnitsyncMap& map ); 48 49 void OnRequestBattleStatus(); 50 void SendMyBattleStatus(); 51 52 bool ExecuteSayCommand( const wxString& cmd ); 53 54 void AddBot( const wxString& nick, UserBattleStatus status ); 55 56 void ForceSide( User& user, int side ); 57 void ForceTeam( User& user, int team ); 58 void ForceAlly( User& user, int ally ); 59 void ForceColour( User& user, const wxColour& col ); 60 void ForceSpectator( User& user, bool spectator ); 61 void BattleKickPlayer( User& user ); 62 void SetHandicap( User& user, int handicap); 63 64 User& OnUserAdded( User& user ); 65 void OnUserBattleStatusUpdated( User &user, UserBattleStatus status ); 66 void OnUserRemoved( User& user ); 67 68 void ForceUnsyncedToSpectate(); 69 void ForceUnReadyToSpectate(); 70 void ForceUnsyncedAndUnreadyToSpectate(); 71 72 void SetAutoLockOnStart( bool value ); 73 bool GetAutoLockOnStart(); 74 75 void SetLockExternalBalanceChanges( bool value ); 76 bool GetLockExternalBalanceChanges(); 77 78 void FixColours(); 79 void Autobalance( BalanceType balance_type = balance_divide, bool clans = true, bool strong_clans = true, int allyteamsize = 0 ); 80 void FixTeamIDs( BalanceType balance_type = balance_divide, bool clans = true, bool strong_clans = true, int controlteamsize = 0 ); 81 82 void SendScriptToClients(); 83 84 ///< quick hotfix for bans 85 bool CheckBan(User &user); 86 ///> 87 88 void SetImReady( bool ready ); 89 90 User& GetMe(); 91 const User& GetMe() const; 92 93 void UserPositionChanged( const User& user ); 94 GetID()95 int GetID() const { return m_id; } 96 97 void SaveMapDefaults(); 98 void LoadMapDefaults( const wxString& mapname ); 99 100 void StartHostedBattle(); 101 void StartSpring(); 102 103 void OnTimer( wxTimerEvent& /*event*/ ); 104 105 void SetInGame( bool ingame ); 106 107 void OnUnitsyncReloaded( wxEvent& data ); 108 109 110 void SetAutoUnspec(bool value); GetAutoUnspec()111 bool GetAutoUnspec() { return m_auto_unspec; } 112 private: 113 void ShouldAutoUnspec(); 114 115 protected: 116 // Battle variables 117 118 ///< quick hotfix for bans 119 std::set<wxString> m_banned_users; 120 std::set<wxString> m_banned_ips; 121 ///> 122 123 Server& m_serv; 124 AutoHost m_ah; 125 bool m_autolock_on_start; 126 127 const int m_id; 128 129 DECLARE_EVENT_TABLE() 130 }; 131 132 #endif // SPRINGLOBBY_HEADERGUARD_BATTLE_H 133 134 /** 135 This file is part of SpringLobby, 136 Copyright (C) 2007-2011 137 138 SpringLobby is free software: you can redistribute it and/or modify 139 it under the terms of the GNU General Public License version 2 as published by 140 the Free Software Foundation. 141 142 SpringLobby is distributed in the hope that it will be useful, 143 but WITHOUT ANY WARRANTY; without even the implied warranty of 144 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 145 GNU General Public License for more details. 146 147 You should have received a copy of the GNU General Public License 148 along with SpringLobby. If not, see <http://www.gnu.org/licenses/>. 149 **/ 150 151