-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathgcbi-extend-old-v1.patch
602 lines (551 loc) · 21.4 KB
/
gcbi-extend-old-v1.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
Index: ghost/game_base.h
===================================================================
--- ghost/game_base.h (revision 573)
+++ ghost/game_base.h (working copy)
@@ -39,6 +39,7 @@
class CIncomingChatPlayer;
class CIncomingMapSize;
class CCallableScoreCheck;
+class CIncomingGarenaPlayer;
class CBaseGame
{
Index: ghost/Makefile
===================================================================
--- ghost/Makefile (revision 573)
+++ ghost/Makefile (working copy)
@@ -4,7 +4,7 @@
CC = gcc
DFLAGS = -DGHOST_MYSQL
OFLAGS = -O3
-LFLAGS = -L. -L../bncsutil/src/bncsutil/ -L../StormLib/stormlib/ -lbncsutil -lpthread -ldl -lz -lStorm -lmysqlclient_r -lboost_date_time-mt -lboost_thread-mt -lboost_system-mt -lboost_filesystem-mt
+LFLAGS = -L. -L../bncsutil/src/bncsutil/ -L../StormLib/stormlib/ -lbncsutil -lpthread -ldl -lz -lStorm -lmysqlclient_r -lboost_date_time -lboost_thread -lboost_system -lboost_filesystem
CFLAGS =
ifeq ($(SYSTEM),Darwin)
@@ -29,7 +29,7 @@
CFLAGS += -I../mysql/include/
endif
-OBJS = bncsutilinterface.o bnet.o bnetprotocol.o bnlsclient.o bnlsprotocol.o commandpacket.o config.o crc32.o csvparser.o game.o game_admin.o game_base.o gameplayer.o gameprotocol.o gameslot.o ghost.o ghostdb.o ghostdbmysql.o ghostdbsqlite.o gpsprotocol.o language.o map.o packed.o replay.o savegame.o sha1.o socket.o stats.o statsdota.o statsw3mmd.o util.o
+OBJS = bncsutilinterface.o bnet.o bnetprotocol.o bnlsclient.o bnlsprotocol.o commandpacket.o config.o crc32.o csvparser.o game.o game_admin.o game_base.o gameplayer.o gameprotocol.o gameslot.o gcbiprotocol.o ghost.o ghostdb.o ghostdbmysql.o ghostdbsqlite.o gpsprotocol.o language.o map.o packed.o replay.o savegame.o sha1.o socket.o stats.o statsdota.o statsw3mmd.o util.o
COBJS = sqlite3.o
PROGS = ./ghost++
@@ -63,10 +63,11 @@
game.o: ghost.h includes.h util.h config.h language.h socket.h ghostdb.h bnet.h map.h packed.h savegame.h gameplayer.h gameprotocol.h game_base.h game.h stats.h statsdota.h statsw3mmd.h
game_admin.o: ghost.h includes.h util.h config.h language.h socket.h ghostdb.h bnet.h map.h packed.h savegame.h replay.h gameplayer.h gameprotocol.h game_base.h game_admin.h
game_base.o: ghost.h includes.h util.h config.h language.h socket.h ghostdb.h bnet.h map.h packed.h savegame.h replay.h gameplayer.h gameprotocol.h game_base.h next_combination.h
-gameplayer.o: ghost.h includes.h util.h language.h socket.h commandpacket.h bnet.h map.h gameplayer.h gameprotocol.h gpsprotocol.h game_base.h
+gameplayer.o: ghost.h includes.h util.h language.h socket.h commandpacket.h bnet.h map.h gameplayer.h gameprotocol.h gpsprotocol.h game_base.h gcbiprotocol.h
gameprotocol.o: ghost.h includes.h util.h crc32.h gameplayer.h gameprotocol.h game_base.h
gameslot.o: ghost.h includes.h gameslot.h
-ghost.o: ghost.h includes.h util.h crc32.h sha1.h csvparser.h config.h language.h socket.h ghostdb.h ghostdbsqlite.h ghostdbmysql.h bnet.h map.h packed.h savegame.h gameplayer.h gameprotocol.h gpsprotocol.h game_base.h game.h game_admin.h
+gcbiprotocol.o: gcbiprotocol.h ghost.h util.h
+ghost.o: ghost.h includes.h util.h crc32.h sha1.h csvparser.h config.h language.h socket.h ghostdb.h ghostdbsqlite.h ghostdbmysql.h bnet.h map.h packed.h savegame.h gameplayer.h gameprotocol.h gpsprotocol.h game_base.h game.h game_admin.h gcbiprotocol.h
ghostdb.o: ghost.h includes.h util.h config.h ghostdb.h
ghostdbmysql.o: ghost.h includes.h util.h config.h ghostdb.h ghostdbmysql.h
ghostdbsqlite.o: ghost.h includes.h util.h config.h ghostdb.h ghostdbsqlite.h
Index: ghost/game_base.cpp
===================================================================
--- ghost/game_base.cpp (revision 573)
+++ ghost/game_base.cpp (working copy)
@@ -32,6 +32,7 @@
#include "gameplayer.h"
#include "gameprotocol.h"
#include "game_base.h"
+#include "gcbiprotocol.h"
#include <cmath>
#include <string.h>
@@ -200,6 +201,7 @@
if( !m_GameLoaded || m_Lagging )
return 50;
+
uint32_t TicksSinceLastUpdate = GetTicks( ) - m_LastActionSentTicks;
if( TicksSinceLastUpdate > m_Latency - m_LastActionLateBy )
@@ -363,7 +365,7 @@
// create the virtual host player
- if( !m_GameLoading && !m_GameLoaded && GetNumPlayers( ) < 12 )
+ if( !m_GameLoading && !m_GameLoaded && GetSlotsOccupied() < m_Slots.size() )
CreateVirtualHost( );
// unlock the game
@@ -411,6 +413,11 @@
// so if we try to send accurate numbers it'll always be off by one and results in Warcraft 3 assuming the game is full when it still needs one more player
// the easiest solution is to simply send 12 for both so the game will always show up as (1/12) players
+ uint32_t slotstotal = m_Slots.size( );
+ uint32_t slotsopen = GetSlotsOpen();
+ if (slotsopen<2) slotsopen = 2;
+ if(slotstotal > 12) slotstotal = 12;
+
if( m_SaveGame )
{
// note: the PrivateGame flag is not set when broadcasting to LAN (as you might expect)
@@ -422,7 +429,7 @@
BYTEARRAY MapHeight;
MapHeight.push_back( 0 );
MapHeight.push_back( 0 );
- m_GHost->m_UDPSocket->Broadcast( 6112, m_Protocol->SEND_W3GS_GAMEINFO( m_GHost->m_TFT, m_GHost->m_LANWar3Version, UTIL_CreateByteArray( MapGameType, false ), m_Map->GetMapGameFlags( ), MapWidth, MapHeight, m_GameName, "Varlock", GetTime( ) - m_CreationTime, "Save\\Multiplayer\\" + m_SaveGame->GetFileNameNoPath( ), m_SaveGame->GetMagicNumber( ), 12, 12, m_HostPort, FixedHostCounter, m_EntryKey ) );
+ m_GHost->m_UDPSocket->Broadcast( 6112, m_Protocol->SEND_W3GS_GAMEINFO( m_GHost->m_TFT, m_GHost->m_LANWar3Version, UTIL_CreateByteArray( MapGameType, false ), m_Map->GetMapGameFlags( ), MapWidth, MapHeight, m_GameName, "Varlock", GetTime( ) - m_CreationTime, "Save\\Multiplayer\\" + m_SaveGame->GetFileNameNoPath( ), m_SaveGame->GetMagicNumber( ), slotstotal, slotsopen, m_HostPort, FixedHostCounter, m_EntryKey ) );
}
else
{
@@ -430,7 +437,7 @@
// note: we do not use m_Map->GetMapGameType because none of the filters are set when broadcasting to LAN (also as you might expect)
uint32_t MapGameType = MAPGAMETYPE_UNKNOWN0;
- m_GHost->m_UDPSocket->Broadcast( 6112, m_Protocol->SEND_W3GS_GAMEINFO( m_GHost->m_TFT, m_GHost->m_LANWar3Version, UTIL_CreateByteArray( MapGameType, false ), m_Map->GetMapGameFlags( ), m_Map->GetMapWidth( ), m_Map->GetMapHeight( ), m_GameName, "Varlock", GetTime( ) - m_CreationTime, m_Map->GetMapPath( ), m_Map->GetMapCRC( ), 12, 12, m_HostPort, FixedHostCounter, m_EntryKey ) );
+ m_GHost->m_UDPSocket->Broadcast( 6112, m_Protocol->SEND_W3GS_GAMEINFO( m_GHost->m_TFT, m_GHost->m_LANWar3Version, UTIL_CreateByteArray( MapGameType, false ), m_Map->GetMapGameFlags( ), m_Map->GetMapWidth( ), m_Map->GetMapHeight( ), m_GameName, "Varlock", GetTime( ) - m_CreationTime, m_Map->GetMapPath( ), m_Map->GetMapCRC( ), slotstotal, slotsopen, m_HostPort, FixedHostCounter, m_EntryKey ) );
}
}
@@ -826,6 +833,7 @@
// this resets the lag screen timer
if( UsingGProxy && !(*i)->GetGProxy( ) )
+
{
// we must send additional empty actions to non-GProxy++ players
// GProxy++ will insert these itself so we don't need to send them to GProxy++ players
@@ -1599,6 +1607,8 @@
}
return;
+
+
}
player->SetDeleteMe( true );
@@ -1914,7 +1924,7 @@
// we have a slot for the new player
// make room for them by deleting the virtual host player if we have to
- if( GetNumPlayers( ) >= 11 || EnforcePID == m_VirtualHostPID )
+ if( GetSlotsOccupied( ) >= m_Slots.size() - 1 || EnforcePID == m_VirtualHostPID )
DeleteVirtualHost( );
// turning the CPotentialPlayer into a CGamePlayer is a bit of a pain because we have to be careful not to close the socket
@@ -1924,6 +1934,11 @@
CONSOLE_Print( "[GAME: " + m_GameName + "] player [" + joinPlayer->GetName( ) + "|" + potential->GetExternalIPString( ) + "] joined the game" );
CGamePlayer *Player = new CGamePlayer( potential, m_SaveGame ? EnforcePID : GetNewPID( ), JoinedRealm, joinPlayer->GetName( ), joinPlayer->GetInternalIP( ), Reserved );
+ if( potential->GetGarenaUser( ) != NULL ) {
+ Player->SetGarenaUser( potential->GetGarenaUser( ) );
+ potential->SetGarenaUser( NULL );
+ }
+
// consider LAN players to have already spoof checked since they can't
// since so many people have trouble with this feature we now use the JoinedRealm to determine LAN status
@@ -2304,7 +2319,7 @@
// we have a slot for the new player
// make room for them by deleting the virtual host player if we have to
- if( GetNumPlayers( ) >= 11 )
+ if( GetSlotsOccupied( ) >= m_Slots.size() - 1 )
DeleteVirtualHost( );
// identify their joined realm
@@ -4063,6 +4078,7 @@
if( Difference > LargestDifference )
LargestDifference = Difference;
+
}
}
}
@@ -4319,6 +4335,7 @@
bool CBaseGame :: IsGameDataSaved( )
{
return true;
+
}
void CBaseGame :: SaveGameData( )
@@ -4349,6 +4366,7 @@
string StillDownloading;
+
for( vector<CGameSlot> :: iterator i = m_Slots.begin( ); i != m_Slots.end( ); ++i )
{
if( (*i).GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && (*i).GetComputer( ) == 0 && (*i).GetDownloadStatus( ) != 100 )
@@ -4570,7 +4588,7 @@
if( SID < m_Slots.size( ) )
{
- if( GetNumPlayers( ) >= 11 )
+ if( GetSlotsOccupied( ) >= m_Slots.size() - 1 )
DeleteVirtualHost( );
m_FakePlayerPID = GetNewPID( );
Index: ghost/ghost.cpp
===================================================================
--- ghost/ghost.cpp (revision 573)
+++ ghost/ghost.cpp (working copy)
@@ -35,6 +35,7 @@
#include "savegame.h"
#include "gameplayer.h"
#include "gameprotocol.h"
+#include "gcbiprotocol.h"
#include "gpsprotocol.h"
#include "game_base.h"
#include "game.h"
@@ -398,6 +399,7 @@
m_UDPSocket->SetDontRoute( CFG->GetInt( "udp_dontroute", 0 ) == 0 ? false : true );
m_ReconnectSocket = NULL;
m_GPSProtocol = new CGPSProtocol( );
+ m_GCBIProtocol = new CGCBIProtocol( );
m_CRC = new CCRC32( );
m_CRC->Initialize( );
m_SHA = new CSHA1( );
@@ -699,6 +701,7 @@
delete *i;
delete m_GPSProtocol;
+ delete m_GCBIProtocol;
delete m_CRC;
delete m_SHA;
@@ -827,6 +830,7 @@
CONSOLE_Print( "[GHOST] error listening for GProxy++ reconnects on port " + UTIL_ToString( m_ReconnectPort ) );
delete m_ReconnectSocket;
m_ReconnectSocket = NULL;
+
m_Reconnect = false;
}
}
Index: ghost/gcbiprotocol.cpp
===================================================================
--- ghost/gcbiprotocol.cpp (revision 0)
+++ ghost/gcbiprotocol.cpp (revision 0)
@@ -0,0 +1,126 @@
+/*
+
+ Copyright 2010 Trevor Hogan
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+#include "ghost.h"
+#include "util.h"
+#include "gcbiprotocol.h"
+
+//
+// CGCBIProtocol
+//
+
+CGCBIProtocol :: CGCBIProtocol( )
+{
+
+}
+
+CGCBIProtocol :: ~CGCBIProtocol( )
+{
+
+}
+
+///////////////////////
+// RECEIVE FUNCTIONS //
+///////////////////////
+
+CIncomingGarenaUser *CGCBIProtocol :: RECEIVE_GCBI_INIT( BYTEARRAY data )
+{
+ // 2 bytes -> Header
+ // 2 bytes -> Length
+ // 4 bytes -> actual IP address (big endian)
+ // 4 bytes -> Garena user ID (big endian)
+ // 4 bytes -> Garena room ID (big endian)
+ // 4 bytes -> Garena user experience (big endian)
+ // 2 bytes -> country string from Garena
+
+ if( ValidateLength( data ) && data.size( ) == 22 )
+ {
+ BYTEARRAY IP = BYTEARRAY( data.begin( ) + 4, data.begin( ) + 8 );
+ BYTEARRAY UserID = BYTEARRAY( data.begin( ) + 8, data.begin( ) + 12 );
+ BYTEARRAY RoomID = BYTEARRAY( data.begin( ) + 12, data.begin( ) + 16 );
+ BYTEARRAY UserExp = BYTEARRAY( data.begin( ) + 16, data.begin( ) + 20 );
+ BYTEARRAY Country = BYTEARRAY( data.begin( ) + 20, data.begin( ) + 22 );
+
+ return new CIncomingGarenaUser(UTIL_ByteArrayToUInt32( IP, true ),
+ UTIL_ByteArrayToUInt32( UserID, true ),
+ UTIL_ByteArrayToUInt32( RoomID, true ),
+ UTIL_ByteArrayToUInt32( UserExp, true ),
+ string( Country.begin( ), Country.end( ) ) );
+ }
+
+ return NULL;
+}
+
+////////////////////
+// SEND FUNCTIONS //
+////////////////////
+
+/////////////////////
+// OTHER FUNCTIONS //
+/////////////////////
+
+bool CGCBIProtocol :: AssignLength( BYTEARRAY &content )
+{
+ // insert the actual length of the content array into bytes 3 and 4 (indices 2 and 3)
+
+ BYTEARRAY LengthBytes;
+
+ if( content.size( ) >= 4 && content.size( ) <= 65535 )
+ {
+ LengthBytes = UTIL_CreateByteArray( (uint16_t)content.size( ), false );
+ content[2] = LengthBytes[0];
+ content[3] = LengthBytes[1];
+ return true;
+ }
+
+ return false;
+}
+
+bool CGCBIProtocol :: ValidateLength( BYTEARRAY &content )
+{
+ // verify that bytes 3 and 4 (indices 2 and 3) of the content array describe the length
+
+ uint16_t Length;
+ BYTEARRAY LengthBytes;
+
+ if( content.size( ) >= 4 && content.size( ) <= 65535 )
+ {
+ LengthBytes.push_back( content[2] );
+ LengthBytes.push_back( content[3] );
+ Length = UTIL_ByteArrayToUInt16( LengthBytes, false );
+
+ if( Length == content.size( ) )
+ return true;
+ }
+
+ return false;
+}
+
+//
+// CIncomingGarenaUser
+//
+
+CIncomingGarenaUser :: CIncomingGarenaUser( uint32_t nIP, uint32_t nUserID, uint32_t nRoomID, uint32_t nUserExp, string nCountryCode ) : m_IP( nIP ), m_UserID( nUserID ), m_RoomID( nRoomID ), m_UserExp( nUserExp ), m_CountryCode( nCountryCode )
+{
+
+}
+
+CIncomingGarenaUser :: ~CIncomingGarenaUser( )
+{
+
+}
Index: ghost/gameplayer.cpp
===================================================================
--- ghost/gameplayer.cpp (revision 573)
+++ ghost/gameplayer.cpp (working copy)
@@ -27,6 +27,7 @@
#include "map.h"
#include "gameplayer.h"
#include "gameprotocol.h"
+#include "gcbiprotocol.h"
#include "gpsprotocol.h"
#include "game_base.h"
@@ -34,7 +35,7 @@
// CPotentialPlayer
//
-CPotentialPlayer :: CPotentialPlayer( CGameProtocol *nProtocol, CBaseGame *nGame, CTCPSocket *nSocket ) : m_Protocol( nProtocol ), m_Game( nGame ), m_Socket( nSocket ), m_DeleteMe( false ), m_Error( false ), m_IncomingJoinPlayer( NULL )
+CPotentialPlayer :: CPotentialPlayer( CGameProtocol *nProtocol, CBaseGame *nGame, CTCPSocket *nSocket ) : m_Protocol( nProtocol ), m_Game( nGame ), m_Socket( nSocket ), m_DeleteMe( false ), m_Error( false ), m_IncomingJoinPlayer( NULL ), m_IncomingGarenaUser( NULL )
{
}
@@ -51,22 +52,42 @@
}
delete m_IncomingJoinPlayer;
+ delete m_IncomingGarenaUser;
}
+BYTEARRAY CPotentialPlayer :: GetGarenaIP( )
+{
+ if( m_IncomingGarenaUser == NULL ) {
+ return UTIL_CreateByteArray( (uint32_t) 0, true );
+ } else {
+ return UTIL_CreateByteArray( m_IncomingGarenaUser->GetIP( ), true );
+ }
+}
+
BYTEARRAY CPotentialPlayer :: GetExternalIP( )
{
unsigned char Zeros[] = { 0, 0, 0, 0 };
- if( m_Socket )
- return m_Socket->GetIP( );
+ if( m_Socket ) {
+ if( m_IncomingGarenaUser != NULL )
+ return GetGarenaIP( );
+ else
+ return m_Socket->GetIP( );
+ }
return UTIL_CreateByteArray( Zeros, 4 );
}
string CPotentialPlayer :: GetExternalIPString( )
{
- if( m_Socket )
- return m_Socket->GetIPString( );
+ if( m_Socket ) {
+ if( m_IncomingGarenaUser != NULL ) {
+ BYTEARRAY GarenaIP = GetGarenaIP( );
+ return UTIL_ToString(GarenaIP[0]) + "." + UTIL_ToString(GarenaIP[1]) + "." + UTIL_ToString(GarenaIP[2]) + "." + UTIL_ToString(GarenaIP[3]);
+ } else {
+ return m_Socket->GetIPString( );
+ }
+ }
return string( );
}
@@ -103,7 +124,7 @@
while( Bytes.size( ) >= 4 )
{
- if( Bytes[0] == W3GS_HEADER_CONSTANT || Bytes[0] == GPS_HEADER_CONSTANT )
+ if( Bytes[0] == W3GS_HEADER_CONSTANT || Bytes[0] == GPS_HEADER_CONSTANT || Bytes[0] == GCBI_HEADER_CONSTANT )
{
// bytes 2 and 3 contain the length of the packet
@@ -169,6 +190,16 @@
return;
}
}
+
+ else if( Packet->GetPacketType( ) == GCBI_HEADER_CONSTANT )
+ {
+ if( Packet->GetID( ) == CGCBIProtocol :: GCBI_INIT )
+ {
+ delete m_IncomingGarenaUser;
+ m_IncomingGarenaUser = m_Game->m_GHost->m_GCBIProtocol->RECEIVE_GCBI_INIT( Packet->GetData( ) );
+ CONSOLE_Print( "[GCBI] Garena user detected; userid=" + UTIL_ToString( m_IncomingGarenaUser->GetUserID( ) ) + ", roomid=" + UTIL_ToString( m_IncomingGarenaUser->GetRoomID( ) ) + ", experience=" + UTIL_ToString( m_IncomingGarenaUser->GetUserExp( ) ) + ", country=" + m_IncomingGarenaUser->GetCountryCode( ) );
+ }
+ }
delete Packet;
}
@@ -348,7 +379,7 @@
while( Bytes.size( ) >= 4 )
{
- if( Bytes[0] == W3GS_HEADER_CONSTANT || Bytes[0] == GPS_HEADER_CONSTANT )
+ if( Bytes[0] == W3GS_HEADER_CONSTANT || Bytes[0] == GPS_HEADER_CONSTANT || Bytes[0] == GCBI_HEADER_CONSTANT )
{
// bytes 2 and 3 contain the length of the packet
@@ -480,6 +511,7 @@
case CGameProtocol :: W3GS_PONG_TO_HOST:
Pong = m_Protocol->RECEIVE_W3GS_PONG_TO_HOST( Packet->GetData( ) );
+
// we discard pong values of 1
// the client sends one of these when connecting plus we return 1 on error to kill two birds with one stone
Index: ghost/ghost.h
===================================================================
--- ghost/ghost.h (revision 573)
+++ ghost/ghost.h (working copy)
@@ -31,6 +31,7 @@
class CTCPServer;
class CTCPSocket;
class CGPSProtocol;
+class CGCBIProtocol;
class CCRC32;
class CSHA1;
class CBNET;
@@ -50,6 +51,7 @@
CTCPServer *m_ReconnectSocket; // listening socket for GProxy++ reliable reconnects
vector<CTCPSocket *> m_ReconnectSockets;// vector of sockets attempting to reconnect (connected but not identified yet)
CGPSProtocol *m_GPSProtocol;
+ CGCBIProtocol *m_GCBIProtocol;
CCRC32 *m_CRC; // for calculating CRC's
CSHA1 *m_SHA; // for calculating SHA1's
vector<CBNET *> m_BNETs; // all our battle.net connections (there can be more than one)
Index: ghost/gcbiprotocol.h
===================================================================
--- ghost/gcbiprotocol.h (revision 0)
+++ ghost/gcbiprotocol.h (revision 0)
@@ -0,0 +1,79 @@
+/*
+
+ Copyright 2010 Trevor Hogan
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+#ifndef GCBIPROTOCOL_H
+#define GCBIPROTOCOL_H
+
+//
+// CGCBIProtocol
+//
+
+#define GCBI_HEADER_CONSTANT 249
+
+#define REJECTGCBI_INVALID 1
+#define REJECTGCBI_NOTFOUND 2
+
+class CIncomingGarenaUser;
+
+class CGCBIProtocol
+{
+public:
+ enum Protocol {
+ GCBI_INIT = 1
+ };
+
+ CGCBIProtocol( );
+ ~CGCBIProtocol( );
+
+ // receive functions
+ CIncomingGarenaUser *RECEIVE_GCBI_INIT( BYTEARRAY data );
+
+ // send functions
+
+ // other functions
+
+private:
+ bool AssignLength( BYTEARRAY &content );
+ bool ValidateLength( BYTEARRAY &content );
+};
+
+//
+// CIncomingGarenaUser
+//
+
+class CIncomingGarenaUser
+{
+private:
+ uint32_t m_IP;
+ uint32_t m_UserID;
+ uint32_t m_RoomID;
+ uint32_t m_UserExp;
+ string m_CountryCode;
+
+public:
+ CIncomingGarenaUser( uint32_t nIP, uint32_t nUserID, uint32_t nRoomID, uint32_t nUserExp, string nCountryCode );
+ ~CIncomingGarenaUser( );
+
+ uint32_t GetIP( ) { return m_IP; }
+ uint32_t GetUserID( ) { return m_UserID; }
+ uint32_t GetRoomID( ) { return m_RoomID; }
+ uint32_t GetUserExp( ) { return m_UserExp; }
+ string GetCountryCode( ) { return m_CountryCode; }
+};
+
+#endif
Index: ghost/gameplayer.h
===================================================================
--- ghost/gameplayer.h (revision 573)
+++ ghost/gameplayer.h (working copy)
@@ -26,6 +26,7 @@
class CGameProtocol;
class CGame;
class CIncomingJoinPlayer;
+class CIncomingGarenaUser;
//
// CPotentialPlayer
@@ -47,6 +48,7 @@
bool m_Error;
string m_ErrorString;
CIncomingJoinPlayer *m_IncomingJoinPlayer;
+ CIncomingGarenaUser *m_IncomingGarenaUser;
public:
CPotentialPlayer( CGameProtocol *nProtocol, CBaseGame *nGame, CTCPSocket *nSocket );
@@ -60,9 +62,12 @@
virtual bool GetError( ) { return m_Error; }
virtual string GetErrorString( ) { return m_ErrorString; }
virtual CIncomingJoinPlayer *GetJoinPlayer( ) { return m_IncomingJoinPlayer; }
+ virtual CIncomingGarenaUser *GetGarenaUser( ) { return m_IncomingGarenaUser; }
+ virtual BYTEARRAY GetGarenaIP( );
virtual void SetSocket( CTCPSocket *nSocket ) { m_Socket = nSocket; }
virtual void SetDeleteMe( bool nDeleteMe ) { m_DeleteMe = nDeleteMe; }
+ virtual void SetGarenaUser( CIncomingGarenaUser *nIncomingGarenaUser ) { m_IncomingGarenaUser = nIncomingGarenaUser; }
// processing functions