Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
NetLobby.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.exe
6
FILE: NetLobby.h
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Base Class for Multiplayer Game Lobby classes
13
*/
14
15
#ifndef NetLobby_h
16
#define NetLobby_h
17
18
#include "
Types.h
"
19
#include "
NetLink.h
"
20
#include "
List.h
"
21
22
#define NET_CAMPAIGN_SHIFT 12
23
#define NET_MISSION_MASK 0xfff
24
#define NET_DISCONNECT_TIME 30
25
26
// +-------------------------------------------------------------------+
27
28
class
Campaign
;
29
class
Mission
;
30
class
MissionElement
;
31
class
MissionInfo
;
32
class
NetCampaignInfo
;
33
class
NetChatEntry
;
34
class
NetUser
;
35
class
NetUnitEntry
;
36
class
NetLobbyParam
;
37
class
ModInfo
;
38
39
// +--------------------------------------------------------------------+
40
41
class
NetLobby
42
{
43
public
:
44
static
const
char
*
TYPENAME
() {
return
"NetLobby"
; }
45
46
NetLobby
(
bool
temporary =
false
);
47
virtual
~NetLobby
();
48
49
virtual
bool
IsClient
()
const
{
return
false
; }
50
virtual
bool
IsServer
()
const
{
return
false
; }
51
virtual
bool
IsActive
()
const
{
return
active
; }
52
53
virtual
void
ExecFrame
();
54
virtual
void
Recv
();
55
virtual
void
Send
();
56
virtual
int
GetLastError
()
const
{
return
0; }
57
58
virtual
NetUser
*
FindUserByAddr
(
const
NetAddr
& addr);
59
virtual
NetUser
*
FindUserByName
(
const
char
* name);
60
virtual
NetUser
*
FindUserByNetID
(DWORD
id
);
61
62
virtual
void
BanUser
(
NetUser
* user);
63
virtual
void
AddUser
(
NetUser
* user);
64
virtual
void
DelUser
(
NetUser
* user);
65
virtual
bool
SetUserHost
(
NetUser
* user,
bool
host);
66
virtual
int
NumUsers
();
67
virtual
NetUser
*
GetHost
();
68
virtual
bool
HasHost
();
69
virtual
bool
IsHost
()
const
{
return
false
; }
70
virtual
List<NetUser>
&
GetUsers
();
71
72
virtual
List<ModInfo>
&
GetServerMods
();
73
74
virtual
NetUser
*
GetLocalUser
();
75
virtual
void
SetLocalUser
(
NetUser
* user);
76
77
virtual
int
GetStatus
()
const
{
return
status
; }
78
virtual
void
SetStatus
(
int
s) {
status
= s; }
79
80
virtual
void
AddChat
(
NetUser
* user,
const
char
* msg,
bool
route=
true
);
81
virtual
List<NetChatEntry>
&
82
GetChat
();
83
virtual
void
ClearChat
();
84
virtual
void
SaveChat
() { }
85
virtual
DWORD
GetStartTime
()
const
{
return
start_time
; }
86
87
virtual
List<NetCampaignInfo>
&
88
GetCampaigns
();
89
90
virtual
void
AddUnitMap
(
MissionElement
* elem,
int
index=0);
91
virtual
List<NetUnitEntry>
&
92
GetUnitMap
();
93
virtual
void
ClearUnitMap
();
94
virtual
void
MapUnit
(
int
n,
const
char
* user,
bool
lock=
false
);
95
virtual
void
UnmapUnit
(
const
char
* user);
96
virtual
bool
IsMapped
(
const
char
* user);
97
98
virtual
Mission
*
GetSelectedMission
() {
return
mission
; }
99
virtual
DWORD
GetSelectedMissionID
()
const
{
return
selected_mission
; }
100
virtual
void
SelectMission
(DWORD
id
);
101
102
virtual
const
Text
&
GetMachineInfo
() {
return
machine_info
; }
103
virtual
WORD
GetGamePort
() {
return
0; }
104
105
// actions:
106
virtual
bool
Ping
();
107
virtual
void
GameStart
() { }
108
virtual
void
GameStop
() { }
109
virtual
DWORD
GetLag
();
110
111
// instance management:
112
static
NetLobby
*
GetInstance
();
113
static
bool
IsNetLobbyClient
();
114
static
bool
IsNetLobbyServer
();
115
116
protected
:
117
virtual
void
DoPing
(
NetPeer
* peer,
Text
msg) { }
118
virtual
void
DoServerInfo
(
NetPeer
* peer,
Text
msg) { }
119
virtual
void
DoServerMods
(
NetPeer
* peer,
Text
msg) { }
120
virtual
void
DoLogin
(
NetPeer
* peer,
Text
msg) { }
121
virtual
void
DoLogout
(
NetPeer
* peer,
Text
msg) { }
122
virtual
void
DoAuthUser
(
NetPeer
* peer,
Text
msg) { }
123
virtual
void
DoUserAuth
(
NetPeer
* peer,
Text
msg) { }
124
virtual
void
DoChat
(
NetPeer
* peer,
Text
msg) { }
125
virtual
void
DoUserList
(
NetPeer
* peer,
Text
msg) { }
126
virtual
void
DoBanUser
(
NetPeer
* peer,
Text
msg) { }
127
virtual
void
DoMissionList
(
NetPeer
* peer,
Text
msg) { }
128
virtual
void
DoMissionSelect
(
NetPeer
* peer,
Text
msg) { }
129
virtual
void
DoMissionData
(
NetPeer
* peer,
Text
msg) { }
130
virtual
void
DoUnitList
(
NetPeer
* peer,
Text
msg) { }
131
virtual
void
DoMapUnit
(
NetPeer
* peer,
Text
msg) { }
132
virtual
void
DoGameStart
(
NetPeer
* peer,
Text
msg) { }
133
virtual
void
DoGameStop
(
NetPeer
* peer,
Text
msg) { }
134
virtual
void
DoExit
(
NetPeer
* peer,
Text
msg) { }
135
136
virtual
void
ParseMsg
(
Text
msg,
List<NetLobbyParam>
& params);
137
138
NetLink
*
link
;
139
NetUser
*
local_user
;
140
List<NetUser>
users
;
141
List<NetChatEntry>
chat_log
;
142
List<NetCampaignInfo>
campaigns
;
143
List<NetUnitEntry>
unit_map
;
144
Text
machine_info
;
145
List<ModInfo>
server_mods
;
146
147
bool
active
;
148
DWORD
last_send_time
;
149
DWORD
start_time
;
150
DWORD
selected_mission
;
151
Mission
*
mission
;
152
int
status
;
153
};
154
155
// +-------------------------------------------------------------------+
156
157
class
NetLobbyParam
158
{
159
public
:
160
static
const
char
*
TYPENAME
() {
return
"NetLobbyParam"
; }
161
162
NetLobbyParam
(
const
char
* n,
const
char
* v) :
name
(n),
value
(v) { }
163
164
int
operator ==
(
const
NetLobbyParam
& p)
const
{
return
name
== p.
name
; }
165
166
Text
name
;
167
Text
value
;
168
};
169
170
// +-------------------------------------------------------------------+
171
172
class
NetUnitEntry
173
{
174
public
:
175
static
const
char
*
TYPENAME
() {
return
"NetUnitEntry"
; }
176
177
NetUnitEntry
(
MissionElement
* elem,
int
index=0);
178
NetUnitEntry
(
const
char
* elem,
const
char
* design,
int
iff,
int
index=0);
179
~NetUnitEntry
();
180
181
int
operator ==
(
const
NetUnitEntry
& e)
const
{
return
(elem == e.elem) && (index == e.index); }
182
183
Text
GetDescription
()
const
;
184
const
Text
&
GetUserName
()
const
{
return
user; }
185
const
Text
&
GetElemName
()
const
{
return
elem; }
186
const
Text
&
GetDesign
()
const
{
return
design; }
187
int
GetIFF
()
const
{
return
iff; }
188
int
GetIndex
()
const
{
return
index; }
189
int
GetLives
()
const
{
return
lives; }
190
int
GetIntegrity
()
const
{
return
hull; }
191
int
GetMissionRole
()
const
{
return
role; }
192
bool
GetLocked
()
const
{
return
lock; }
193
194
void
SetUserName
(
const
char
* u) { user = u; }
195
void
SetElemName
(
const
char
* e) { elem = e; }
196
void
SetDesign
(
const
char
* d) { design = d; }
197
void
SetIFF
(
int
i) { iff = i; }
198
void
SetIndex
(
int
i) { index = i; }
199
void
SetLives
(
int
i) { lives = i; }
200
void
SetIntegrity
(
int
i) { hull = i; }
201
void
SetMissionRole
(
int
i) { role = i; }
202
void
SetLock
(
bool
l) { lock = l; }
203
204
private
:
205
Text
user;
206
Text
elem;
207
Text
design;
208
int
iff;
209
int
index;
210
int
lives;
211
int
hull;
212
int
role;
213
bool
lock;
214
};
215
216
// +--------------------------------------------------------------------+
217
218
class
NetServerInfo
219
{
220
public
:
221
static
const
char
*
TYPENAME
() {
return
"NetServerInfo"
; }
222
223
enum
STATUS
{
OFFLINE
,
LOBBY
,
BRIEFING
,
ACTIVE
,
DEBRIEFING
,
PERSISTENT
};
224
225
NetServerInfo
();
226
227
Text
name
;
228
Text
hostname
;
229
Text
password
;
230
Text
type
;
231
NetAddr
addr
;
232
WORD
port
;
233
WORD
gameport
;
234
bool
save
;
235
236
Text
version
;
237
Text
machine_info
;
238
int
nplayers
;
239
int
hosted
;
240
int
status
;
241
242
DWORD
ping_time
;
243
};
244
245
// +--------------------------------------------------------------------+
246
247
class
NetCampaignInfo
248
{
249
public
:
250
static
const
char
*
TYPENAME
() {
return
"NetCampaignInfo"
; }
251
252
NetCampaignInfo
() :
id
(0) { }
253
~NetCampaignInfo
() { }
254
255
int
id
;
256
Text
name
;
257
258
List<MissionInfo>
missions
;
259
};
260
261
// +--------------------------------------------------------------------+
262
263
enum
NET_LOBBY_MESSAGES
{
264
NET_LOBBY_PING
= 0x10,
265
NET_LOBBY_SERVER_INFO
,
266
NET_LOBBY_SERVER_MODS
,
267
NET_LOBBY_LOGIN
,
268
NET_LOBBY_LOGOUT
,
269
NET_LOBBY_CHAT
,
270
NET_LOBBY_USER_LIST
,
271
NET_LOBBY_BAN_USER
,
272
NET_LOBBY_MISSION_LIST
,
273
NET_LOBBY_MISSION_SELECT
,
274
NET_LOBBY_MISSION_DATA
,
275
NET_LOBBY_UNIT_LIST
,
276
NET_LOBBY_MAP_UNIT
,
277
278
NET_LOBBY_AUTH_USER
,
279
NET_LOBBY_USER_AUTH
,
280
281
NET_LOBBY_GAME_START
,
282
NET_LOBBY_GAME_STOP
,
283
NET_LOBBY_EXIT
284
};
285
286
// +--------------------------------------------------------------------+
287
288
#endif NetLobby_h
289
Stars45
NetLobby.h
Generated on Tue Jun 5 2012 20:47:04 for Starshatter_Open by
1.8.1