Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
NetServerConfig.h
Go to the documentation of this file.
1 /* Project Starshatter 4.5
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: Stars
6  FILE: NetServerConfig.h
7  AUTHOR: John DiCamillo
8 
9 */
10 
11 #ifndef NetServerConfig_h
12 #define NetServerConfig_h
13 
14 #include "Types.h"
15 #include "Game.h"
16 #include "Text.h"
17 
18 // +--------------------------------------------------------------------+
19 
20 class NetAddr;
21 class NetUser;
22 
23 // +--------------------------------------------------------------------+
24 
26 {
27 public:
28  static const char* TYPENAME() { return "NetServerConfig"; }
29 
32 
33  enum GAME_TYPE {
37  };
38 
39  const Text& Name() const { return name; }
40  const Text& GetAdminName() const { return admin_name; }
41  const Text& GetAdminPass() const { return admin_pass; }
42  const Text& GetGamePass() const { return game_pass; }
43  const Text& GetMission() const { return mission; }
44  WORD GetAdminPort() const { return admin_port; }
45  WORD GetLobbyPort() const { return lobby_port; }
46  WORD GetGamePort() const { return game_port; }
47  int GetPoolsize() const { return poolsize; }
48  int GetSessionTimeout() const { return session_timeout; }
49  int GetGameType() const { return game_type; }
50  int GetAuthLevel() const { return auth_level; }
51 
52  void SetName(const char* s) { name = Clean(s); }
53  void SetAdminName(const char* s){ admin_name = Clean(s); }
54  void SetAdminPass(const char* s){ admin_pass = Clean(s); }
55  void SetGamePass(const char* s) { game_pass = Clean(s); }
56  void SetMission(const char* s) { mission = Clean(s); }
57  void SetGameType(int t) { game_type = t; }
58  void SetAdminPort(WORD p) { admin_port = p; }
59  void SetLobbyPort(WORD p) { lobby_port = p; }
60  void SetGamePort(WORD p) { game_port = p; }
61  void SetPoolsize(int s) { poolsize = s; }
62  void SetSessionTimeout(int t) { session_timeout = t; }
63  void SetAuthLevel(int n) { auth_level = n; }
64 
65  void Load();
66  void Save();
67 
68  bool IsUserBanned(NetUser* user);
69  void BanUser(NetUser* user);
70 
71  static void Initialize();
72  static void Close();
73  static NetServerConfig* GetInstance() { return instance; }
74 
75 private:
76  void LoadBanList();
77  Text Clean(const char* s);
78 
79  Text name;
80  Text admin_name;
81  Text admin_pass;
82  Text game_pass;
83  Text mission;
84 
85  WORD admin_port;
86  WORD lobby_port;
87  WORD game_port;
88  int poolsize;
89  int session_timeout;
90  int game_type;
91  int auth_level;
92 
93  List<NetAddr> banned_addrs;
94  List<Text> banned_names;
95 
96  static NetServerConfig* instance;
97 };
98 
99 #endif NetServerConfig_h